From a1132f46ed70fb44ebba6bbb5eff5d8d33c61044 Mon Sep 17 00:00:00 2001 From: 0xPatrick Date: Tue, 3 Dec 2024 13:03:58 -0500 Subject: [PATCH] chore: `startContract` stringifies `builderOpts` --- multichain-testing/test/auto-stake-it.test.ts | 4 ++-- multichain-testing/test/basic-flows.test.ts | 4 ++-- .../test/deposit-withdraw-lca.test.ts | 4 ++-- .../test/deposit-withdraw-portfolio.test.ts | 4 ++-- .../test/ica-channel-close.test.ts | 4 ++-- multichain-testing/test/send-anywhere.test.ts | 4 ++-- multichain-testing/test/support.ts | 16 ++++++++++++++-- 7 files changed, 26 insertions(+), 14 deletions(-) diff --git a/multichain-testing/test/auto-stake-it.test.ts b/multichain-testing/test/auto-stake-it.test.ts index 1c185c588b7..29b984ceec0 100644 --- a/multichain-testing/test/auto-stake-it.test.ts +++ b/multichain-testing/test/auto-stake-it.test.ts @@ -27,8 +27,8 @@ test.before(async t => { t.context = { ...common, wallets }; await startContract(contractName, contractBuilder, { - chainInfo: JSON.stringify(chainInfo), - assetInfo: JSON.stringify(assetInfo), + chainInfo, + assetInfo, }); }); diff --git a/multichain-testing/test/basic-flows.test.ts b/multichain-testing/test/basic-flows.test.ts index 658ce851d67..689db323524 100644 --- a/multichain-testing/test/basic-flows.test.ts +++ b/multichain-testing/test/basic-flows.test.ts @@ -22,8 +22,8 @@ test.before(async t => { const wallets = await setupTestKeys(accounts); t.context = { ...common, wallets }; await startContract(contractName, contractBuilder, { - chainInfo: JSON.stringify(chainInfo), - assetInfo: JSON.stringify(assetInfo), + chainInfo, + assetInfo, }); }); diff --git a/multichain-testing/test/deposit-withdraw-lca.test.ts b/multichain-testing/test/deposit-withdraw-lca.test.ts index 226b29d45dd..ad7fd4824d9 100644 --- a/multichain-testing/test/deposit-withdraw-lca.test.ts +++ b/multichain-testing/test/deposit-withdraw-lca.test.ts @@ -20,8 +20,8 @@ test.before(async t => { const wallets = await setupTestKeys(accounts); t.context = { ...common, wallets }; await startContract(contractName, contractBuilder, { - chainInfo: JSON.stringify(chainInfo), - assetInfo: JSON.stringify(assetInfo), + chainInfo, + assetInfo, }); }); diff --git a/multichain-testing/test/deposit-withdraw-portfolio.test.ts b/multichain-testing/test/deposit-withdraw-portfolio.test.ts index afd484284b8..ea97f1e7f17 100644 --- a/multichain-testing/test/deposit-withdraw-portfolio.test.ts +++ b/multichain-testing/test/deposit-withdraw-portfolio.test.ts @@ -20,8 +20,8 @@ test.before(async t => { const wallets = await setupTestKeys(accounts); t.context = { ...common, wallets }; await startContract(contractName, contractBuilder, { - chainInfo: JSON.stringify(chainInfo), - assetInfo: JSON.stringify(assetInfo), + chainInfo, + assetInfo, }); }); diff --git a/multichain-testing/test/ica-channel-close.test.ts b/multichain-testing/test/ica-channel-close.test.ts index ab7437da525..03b0ef9ac95 100644 --- a/multichain-testing/test/ica-channel-close.test.ts +++ b/multichain-testing/test/ica-channel-close.test.ts @@ -28,8 +28,8 @@ test.before(async t => { const wallets = await setupTestKeys(accounts); t.context = { ...common, wallets }; await startContract(contractName, contractBuilder, { - chainInfo: JSON.stringify(chainInfo), - assetInfo: JSON.stringify(assetInfo), + chainInfo, + assetInfo, }); }); diff --git a/multichain-testing/test/send-anywhere.test.ts b/multichain-testing/test/send-anywhere.test.ts index ba74b23338a..f1a8a720e5f 100644 --- a/multichain-testing/test/send-anywhere.test.ts +++ b/multichain-testing/test/send-anywhere.test.ts @@ -27,8 +27,8 @@ test.before(async t => { t.context = { ...common, wallets }; await startContract(contractName, contractBuilder, { - chainInfo: JSON.stringify(chainInfo), - assetInfo: JSON.stringify(assetInfo), + chainInfo, + assetInfo, }); }); diff --git a/multichain-testing/test/support.ts b/multichain-testing/test/support.ts index aef2bfab173..f3f8e752d96 100644 --- a/multichain-testing/test/support.ts +++ b/multichain-testing/test/support.ts @@ -4,6 +4,7 @@ import { execa } from 'execa'; import fse from 'fs-extra'; import childProcess from 'node:child_process'; import { withChainCapabilities } from '@agoric/orchestration'; +import { objectMap } from '@endo/patterns'; import { makeAgdTools } from '../tools/agd-tools.js'; import { type E2ETools } from '../tools/e2e-tools.js'; import { @@ -94,7 +95,7 @@ export const commonSetup = async (t: ExecutionContext) => { const startContract = async ( contractName: string, contractBuilder: string, - builderOpts?: Record, + builderOpts?: Record, ) => { const { vstorageClient } = tools; const instances = Object.fromEntries( @@ -104,7 +105,18 @@ export const commonSetup = async (t: ExecutionContext) => { return t.log('Contract found. Skipping installation...'); } t.log('bundle and install contract', contractName); - await deployBuilder(contractBuilder, builderOpts); + + const formattedOpts = builderOpts + ? objectMap( + // eslint-disable-next-line @typescript-eslint/no-explicit-any + builderOpts as Record, + value => { + if (typeof value === 'string') return value; + return JSON.stringify(value); + }, + ) + : undefined; + await deployBuilder(contractBuilder, formattedOpts); await retryUntilCondition( () => vstorageClient.queryData(`published.agoricNames.instance`), res => contractName in Object.fromEntries(res),