diff --git a/multichain-testing/test/support.ts b/multichain-testing/test/support.ts index 988776a679c..d4d0f481c84 100644 --- a/multichain-testing/test/support.ts +++ b/multichain-testing/test/support.ts @@ -81,31 +81,65 @@ export const commonSetup = async (t: ExecutionContext) => { const hermes = makeHermes(childProcess); const nobleTools = makeNobleTools(childProcess); - // common assetInfo for contract chainHub - const commonAssetInfo: Record = { - uosmo: { - baseName: 'osmosis', - chainName: 'osmosis', - baseDenom: 'uosmo', - }, - [`ibc/${denomHash({ denom: 'uosmo', channelId: starshipChainInfo.agoric.connections['osmosislocal'].transferChannel.channelId })}`]: - { - baseName: 'osmosis', - chainName: 'agoric', - baseDenom: 'uosmo', - }, - uatom: { - baseName: 'cosmoshub', - chainName: 'cosmoshub', - baseDenom: 'uatom', - }, - [`ibc/${denomHash({ denom: 'uatom', channelId: starshipChainInfo.agoric.connections['gaialocal'].transferChannel.channelId })}`]: - { - baseName: 'cosmoshub', - chainName: 'agoric', - baseDenom: 'uatom', - }, + const makeCommonAssetInfo = () => { + const getChannelId = ( + issuingChainId: string, + holdingChainName: string = 'agoric', + ) => { + return starshipChainInfo[holdingChainName].connections[issuingChainId] + .transferChannel.channelId; + }; + + const uosmoOnAgoric = () => + `ibc/${denomHash({ denom: 'uosmo', channelId: getChannelId('osmosislocal') })}`; + const uatomOnAgoric = () => + `ibc/${denomHash({ denom: 'uatom', channelId: getChannelId('gaialocal') })}`; + const uusdcOnAgoric = () => + `ibc/${denomHash({ denom: 'uusdc', channelId: getChannelId('noblelocal') })}`; + + const assetInfo: Record = {}; + for (const chain of Object.keys(starshipChainInfo)) { + if (chain === 'osmosis') { + assetInfo.uosmo = { + baseName: 'osmosis', + chainName: 'osmosis', + baseDenom: 'uosmo', + }; + assetInfo[uosmoOnAgoric()] = { + baseName: 'osmosis', + chainName: 'agoric', + baseDenom: 'uosmo', + }; + } + if (chain === 'cosmoshub') { + assetInfo.uatom = { + baseName: 'cosmoshub', + chainName: 'cosmoshub', + baseDenom: 'uatom', + }; + assetInfo[uatomOnAgoric()] = { + baseName: 'cosmoshub', + chainName: 'agoric', + baseDenom: 'uatom', + }; + } + if (chain === 'noble') { + assetInfo.uusdc = { + baseName: 'noble', + chainName: 'noble', + baseDenom: 'uusdc', + }; + assetInfo[uusdcOnAgoric()] = { + baseName: 'noble', + chainName: 'agoric', + baseDenom: 'uusdc', + }; + } + return assetInfo; + } }; + // common assetInfo for contract chainHub + const commonAssetInfo = makeCommonAssetInfo(); /** * Starts a contract if instance not found. Takes care of installing