diff --git a/multichain-testing/package.json b/multichain-testing/package.json index 7088cc34fb2..781b7825dc3 100644 --- a/multichain-testing/package.json +++ b/multichain-testing/package.json @@ -36,7 +36,7 @@ "execa": "^9.2.0", "fs-extra": "^11.2.0", "patch-package": "^8.0.0", - "starshipjs": "2.0.0", + "starshipjs": "2.4.0", "tsimp": "^2.0.10", "tsx": "^4.15.6", "typescript": "^5.3.3" diff --git a/multichain-testing/patches/starshipjs+2.0.0.patch b/multichain-testing/patches/starshipjs+2.0.0.patch deleted file mode 100644 index d8c2ab9a825..00000000000 --- a/multichain-testing/patches/starshipjs+2.0.0.patch +++ /dev/null @@ -1,35 +0,0 @@ -diff --git a/node_modules/starshipjs/hooks.js b/node_modules/starshipjs/hooks.js -index fb3e3cf..6b6567b 100644 ---- a/node_modules/starshipjs/hooks.js -+++ b/node_modules/starshipjs/hooks.js -@@ -14,7 +14,7 @@ const useRegistry = async (configFile) => { - const registryUrl = `http://localhost:${config.registry.ports.rest}`; - const urls = []; - config.chains?.forEach((chain) => { -- urls.push(`${registryUrl}/chains/${chain.name}`, `${registryUrl}/chains/${chain.name}/assets`); -+ urls.push(`${registryUrl}/chains/${chain.id}`, `${registryUrl}/chains/${chain.id}/assets`); - }); - config.relayers?.forEach((relayer) => { - urls.push(`${registryUrl}/ibc/${relayer.chains[0]}/${relayer.chains[1]}`, `${registryUrl}/ibc/${relayer.chains[1]}/${relayer.chains[0]}`); -@@ -35,10 +35,10 @@ const useChain = (chainName) => { - const chainInfo = registry.getChainInfo(chainName); - const chainID = chainInfo.chain.chain_id; - const getRpcEndpoint = () => { -- return `http://localhost:${config.chains.find((chain) => chain.name === chainID).ports.rpc}`; -+ return `http://localhost:${config.chains.find((chain) => chain.id === chainID).ports.rpc}`; - }; - const getRestEndpoint = () => { -- return `http://localhost:${config.chains.find((chain) => chain.name === chainID).ports.rest}`; -+ return `http://localhost:${config.chains.find((chain) => chain.id === chainID).ports.rest}`; - }; - const getGenesisMnemonic = async () => { - const url = `http://localhost:${config.registry.ports.rest}/chains/${chainID}/keys`; -@@ -50,7 +50,7 @@ const useChain = (chainName) => { - return chainInfo.fetcher.getChainAssetList(chainName).assets[0]; - }; - const creditFromFaucet = async (address, denom = null) => { -- const faucetEndpoint = `http://localhost:${config.chains.find((chain) => chain.name === chainID).ports.faucet}/credit`; -+ const faucetEndpoint = `http://localhost:${config.chains.find((chain) => chain.id === chainID).ports.faucet}/credit`; - if (!denom) { - denom = getCoin().base; - } diff --git a/multichain-testing/test/auto-stake-it.test.ts b/multichain-testing/test/auto-stake-it.test.ts index 06cea4c4f10..0c1ab6abbe7 100644 --- a/multichain-testing/test/auto-stake-it.test.ts +++ b/multichain-testing/test/auto-stake-it.test.ts @@ -117,7 +117,7 @@ const autoStakeItScenario = test.macro({ const { portId, channelId } = agoricConns[remoteChainInfo.chainId].transferChannel; const agoricQueryClient = makeQueryClient( - useChain('agoric').getRestEndpoint(), + await useChain('agoric').getRestEndpoint(), ); const stakingDenom = remoteChainInfo?.stakingTokens?.[0].denom; if (!stakingDenom) throw Error(`staking denom found for ${chainName}`); @@ -131,7 +131,7 @@ const autoStakeItScenario = test.macro({ // 3. Find a remoteChain validator to delegate to const remoteQueryClient = makeQueryClient( - useChain(chainName).getRestEndpoint(), + await useChain(chainName).getRestEndpoint(), ); const { validators } = await remoteQueryClient.queryValidators(); const validatorAddress = validators[0]?.operator_address; diff --git a/multichain-testing/test/smart-wallet.test.ts b/multichain-testing/test/smart-wallet.test.ts index ceaea0aa555..4dc3d664e45 100644 --- a/multichain-testing/test/smart-wallet.test.ts +++ b/multichain-testing/test/smart-wallet.test.ts @@ -29,7 +29,9 @@ test('provision smart wallet', async t => { ); t.like(walletCurrent, { liveOffers: [], offerToPublicSubscriberPaths: [] }); - const agQueryClient = makeQueryClient(useChain('agoric').getRestEndpoint()); + const agQueryClient = makeQueryClient( + await useChain('agoric').getRestEndpoint(), + ); const { balances } = await agQueryClient.queryBalances(wallets.user1); t.deepEqual( balances, diff --git a/multichain-testing/test/stake-ica.test.ts b/multichain-testing/test/stake-ica.test.ts index 3be46210d9b..df3e8c9ba1d 100644 --- a/multichain-testing/test/stake-ica.test.ts +++ b/multichain-testing/test/stake-ica.test.ts @@ -103,7 +103,7 @@ const stakeScenario = test.macro(async (t, scenario: StakeIcaScenario) => { ); const { creditFromFaucet, getRestEndpoint } = useChain(scenario.chain); - const queryClient = makeQueryClient(getRestEndpoint()); + const queryClient = makeQueryClient(await getRestEndpoint()); t.log(`Requesting faucet funds for ${address}`); // XXX fails intermittently until https://github.com/cosmology-tech/starship/issues/417 diff --git a/multichain-testing/test/tools/wallet.test.ts b/multichain-testing/test/tools/wallet.test.ts index 01c9119feec..8667d5cbcfc 100644 --- a/multichain-testing/test/tools/wallet.test.ts +++ b/multichain-testing/test/tools/wallet.test.ts @@ -16,7 +16,7 @@ const walletScenario = test.macro(async (t, scenario: string) => { t.regex(addr, new RegExp(`^${prefix}1`)); t.log('Made temp wallet:', addr); - const apiUrl = useChain(scenario).getRestEndpoint(); + const apiUrl = await useChain(scenario).getRestEndpoint(); const queryClient = makeQueryClient(apiUrl); t.log('Made query client'); diff --git a/multichain-testing/tools/ibc-transfer.ts b/multichain-testing/tools/ibc-transfer.ts index b4384f13313..173f8c9aaa6 100644 --- a/multichain-testing/tools/ibc-transfer.ts +++ b/multichain-testing/tools/ibc-transfer.ts @@ -126,7 +126,7 @@ export const createFundedWalletAndClient = async ( // TODO use telescope generated rpc client from @agoric/cosmic-proto // https://github.com/Agoric/agoric-sdk/issues/9200 const client = await SigningStargateClient.connectWithSigner( - getRpcEndpoint(), + await getRpcEndpoint(), wallet, ); return { client, wallet, address }; diff --git a/multichain-testing/tools/registry.ts b/multichain-testing/tools/registry.ts index 3d29c9baf0a..d4b15c5b8b7 100644 --- a/multichain-testing/tools/registry.ts +++ b/multichain-testing/tools/registry.ts @@ -8,6 +8,7 @@ export const makeGetFile = type GetFilePathFn = ReturnType; export const makeSetupRegistry = (getFile: GetFilePathFn) => { + let initialized = false; /** * @param {Object} opts * @param {string} [opts.config='../config.yaml'] - The path to the starship configuration file. @@ -20,8 +21,11 @@ export const makeSetupRegistry = (getFile: GetFilePathFn) => { * ``` */ const setupRegistry = async ({ config = '../config.yaml' } = {}) => { - ConfigContext.setConfigFile(getFile(config)); - ConfigContext.setRegistry(await useRegistry(ConfigContext.configFile!)); + if (initialized) return { useChain }; + const configFile = getFile(config); + const fetcher = await useRegistry(configFile); + await ConfigContext.init(configFile, fetcher); + initialized = true; return { useChain }; }; diff --git a/multichain-testing/yarn.lock b/multichain-testing/yarn.lock index 7c87c33808a..37e3e4fd458 100644 --- a/multichain-testing/yarn.lock +++ b/multichain-testing/yarn.lock @@ -608,7 +608,7 @@ __metadata: languageName: node linkType: hard -"@noble/hashes@npm:^1, @noble/hashes@npm:^1.0.0": +"@noble/hashes@npm:^1, @noble/hashes@npm:^1.0.0, @noble/hashes@npm:^1.2.0": version: 1.4.0 resolution: "@noble/hashes@npm:1.4.0" checksum: 10c0/8c3f005ee72e7b8f9cff756dfae1241485187254e3f743873e22073d63906863df5d4f13d441b7530ea614b7a093f0d889309f28b59850f33b66cb26a779a4a5 @@ -1319,6 +1319,15 @@ __metadata: languageName: node linkType: hard +"bip39@npm:^3.1.0": + version: 3.1.0 + resolution: "bip39@npm:3.1.0" + dependencies: + "@noble/hashes": "npm:^1.2.0" + checksum: 10c0/68f9673a0d6a851e9635f3af8a85f2a1ecef9066c76d77e6f0d58d274b5bf22a67f429da3997e07c0d2cf153a4d7321f9273e656cac0526f667575ddee28ef71 + languageName: node + linkType: hard + "blueimp-md5@npm:^2.10.0": version: 2.19.0 resolution: "blueimp-md5@npm:2.19.0" @@ -3843,7 +3852,7 @@ __metadata: execa: "npm:^9.2.0" fs-extra: "npm:^11.2.0" patch-package: "npm:^8.0.0" - starshipjs: "npm:2.0.0" + starshipjs: "npm:2.4.0" tsimp: "npm:^2.0.10" tsx: "npm:^4.15.6" typescript: "npm:^5.3.3" @@ -4081,14 +4090,15 @@ __metadata: languageName: node linkType: hard -"starshipjs@npm:2.0.0": - version: 2.0.0 - resolution: "starshipjs@npm:2.0.0" +"starshipjs@npm:2.4.0": + version: 2.4.0 + resolution: "starshipjs@npm:2.4.0" dependencies: "@chain-registry/client": "npm:1.18.1" + bip39: "npm:^3.1.0" js-yaml: "npm:^4.1.0" node-fetch: "npm:^2.6.9" - checksum: 10c0/8091142dac71b0f0544db87f0f6d101c4fa26792adda05f629dfb3c2f6d087233ede3672fa41ada2cd92d42ad07bbb17481049c491a2adba4a3114f363299121 + checksum: 10c0/e62cc540bc9e8700d3bdb61ac1261b71417f0e687c98a0e3733317d363e425c7188a205d9af70f5218e87f99195fbfb5b759b4f3f9d87823989ef6b4d90442d6 languageName: node linkType: hard