diff --git a/multichain-testing/test/auto-stake-it.test.ts b/multichain-testing/test/auto-stake-it.test.ts index 1716ed59efe..10e3bac8db8 100644 --- a/multichain-testing/test/auto-stake-it.test.ts +++ b/multichain-testing/test/auto-stake-it.test.ts @@ -89,6 +89,7 @@ const autoStakeItScenario = test.macro({ chainName, validator: { value: validatorAddress, + encoding: 'bech32', chainId: remoteChainInfo.chainId, }, }, diff --git a/multichain-testing/test/send-anywhere.test.ts b/multichain-testing/test/send-anywhere.test.ts index 9f4020323e6..df4bbdca8d6 100644 --- a/multichain-testing/test/send-anywhere.test.ts +++ b/multichain-testing/test/send-anywhere.test.ts @@ -84,6 +84,7 @@ const sendAnywhereScenario = test.macro({ const receiver = { chainId: chain.chain_id, value: (await wallet.getAccounts())[0].address, + encoding: 'bech32', }; t.log('Will send payment to:', receiver); t.log(`${destChainName} offer`); diff --git a/multichain-testing/test/stake-ica.test.ts b/multichain-testing/test/stake-ica.test.ts index 1f2f6f3f68e..c0d118734b7 100644 --- a/multichain-testing/test/stake-ica.test.ts +++ b/multichain-testing/test/stake-ica.test.ts @@ -126,6 +126,7 @@ const stakeScenario = test.macro(async (t, scenario: StakeIcaScenario) => { const validatorChainAddress = { value: validatorAddress, chainId: scenario.chainId, + encoding: 'bech32', }; await doOffer({ id: delegateOfferId, diff --git a/packages/boot/test/bootstrapTests/lca.test.ts b/packages/boot/test/bootstrapTests/lca.test.ts index ceec92f944e..df475d8a484 100644 --- a/packages/boot/test/bootstrapTests/lca.test.ts +++ b/packages/boot/test/bootstrapTests/lca.test.ts @@ -130,6 +130,7 @@ test.serial('stakeBld', async t => { toAccount: { value: 'agoric1EOAAccAddress', chainId: 'agoriclocal', + encoding: 'bech32', }, amount: { denom: 'ibc/1234', value: 10n }, }, @@ -150,6 +151,7 @@ test.serial('stakeBld', async t => { toAccount: { value: 'agoric1EOAAccAddress', chainId: 'agoriclocal', + encoding: 'bech32', }, amounts: [ { denom: 'uatom', value: 10n }, @@ -174,6 +176,7 @@ test.serial('stakeBld', async t => { toAccount: { value: 'agoric1EOAAccAddress', chainId: 'agoriclocal', + encoding: 'bech32', }, amount: { denom: 'ibc/1234', diff --git a/packages/boot/test/bootstrapTests/orchestration.test.ts b/packages/boot/test/bootstrapTests/orchestration.test.ts index 668a798de51..e59e5f1d20c 100644 --- a/packages/boot/test/bootstrapTests/orchestration.test.ts +++ b/packages/boot/test/bootstrapTests/orchestration.test.ts @@ -35,6 +35,7 @@ const test: TestFn< const validatorAddress: CosmosValidatorAddress = { value: 'cosmosvaloper1test', chainId: 'gaiatest', + encoding: 'bech32', }; const ATOM_DENOM = 'uatom'; @@ -235,6 +236,7 @@ test.serial('stakeAtom - smart wallet', async t => { const validatorAddressFail: CosmosValidatorAddress = { value: 'cosmosvaloper1fail', chainId: 'gaiatest', + encoding: 'bech32', }; // This will trigger the immediate ack of the mock bridge diff --git a/packages/boot/test/fast-usdc/fast-usdc.test.ts b/packages/boot/test/fast-usdc/fast-usdc.test.ts index 21fc93e4ea4..880b89588be 100644 --- a/packages/boot/test/fast-usdc/fast-usdc.test.ts +++ b/packages/boot/test/fast-usdc/fast-usdc.test.ts @@ -58,7 +58,9 @@ test.after.always(t => t.context.shutdown?.()); test.serial('oracles provision before contract deployment', async t => { const { walletFactoryDriver: wfd } = t.context; - const watcherWallet = await wfd.provideSmartWallet('agoric1watcher1'); + const [watcherWallet] = await Promise.all( + oracleAddrs.map(addr => wfd.provideSmartWallet(addr)), + ); t.truthy(watcherWallet); }); @@ -75,9 +77,7 @@ test.serial( walletFactoryDriver: wfd, } = t.context; - const [watcherWallet] = await Promise.all( - oracleAddrs.map(addr => wfd.provideSmartWallet(addr)), - ); + const watcherWallet = await wfd.provideSmartWallet(oracleAddrs[0]); // inbound `startChannelOpenInit` responses immediately. // needed since the Fusdc StartFn relies on an ICA being created diff --git a/packages/boot/test/orchestration/restart-contracts.test.ts b/packages/boot/test/orchestration/restart-contracts.test.ts index 63dd30518e4..593f4b71deb 100644 --- a/packages/boot/test/orchestration/restart-contracts.test.ts +++ b/packages/boot/test/orchestration/restart-contracts.test.ts @@ -127,6 +127,7 @@ test.serial('send-anywhere', async t => { const validatorAddress: CosmosValidatorAddress = { value: 'cosmosvaloper1test', chainId: 'gaiatest', + encoding: 'bech32', }; const ATOM_DENOM = 'uatom'; diff --git a/packages/builders/test/snapshots/orchestration-imports.test.js.md b/packages/builders/test/snapshots/orchestration-imports.test.js.md index b7e8a61bc42..4030cf35908 100644 --- a/packages/builders/test/snapshots/orchestration-imports.test.js.md +++ b/packages/builders/test/snapshots/orchestration-imports.test.js.md @@ -14,20 +14,16 @@ Generated by [AVA](https://avajs.dev). Object @match:string { payload: [], }, - Object @match:splitRecord { - payload: [ - { - chainId: Object @match:string { - payload: [], - }, - value: Object @match:string { - payload: [], - }, - }, - { - encoding: 'bech32', - }, - ], + { + chainId: Object @match:string { + payload: [], + }, + encoding: Object @match:string { + payload: [], + }, + value: Object @match:string { + payload: [], + }, }, ], }, @@ -87,20 +83,16 @@ Generated by [AVA](https://avajs.dev). }, ], }, - ChainAddressShape: Object @match:splitRecord { - payload: [ - { - chainId: Object @match:string { - payload: [], - }, - value: Object @match:string { - payload: [], - }, - }, - { - encoding: 'bech32', - }, - ], + ChainAddressShape: { + chainId: Object @match:string { + payload: [], + }, + encoding: Object @match:string { + payload: [], + }, + value: Object @match:string { + payload: [], + }, }, ChainInfoShape: Object @match:splitRecord { payload: [ @@ -153,20 +145,16 @@ Generated by [AVA](https://avajs.dev). }, ], }, - CosmosChainAddressShape: Object @match:splitRecord { - payload: [ - { - chainId: Object @match:string { - payload: [], - }, - value: Object @match:string { - payload: [], - }, - }, - { - encoding: 'bech32', - }, - ], + CosmosChainAddressShape: { + chainId: Object @match:string { + payload: [], + }, + encoding: Object @match:string { + payload: [], + }, + value: Object @match:string { + payload: [], + }, }, CosmosChainInfoShape: Object @match:splitRecord { payload: [ @@ -232,37 +220,29 @@ Generated by [AVA](https://avajs.dev). }, ], }, - validator: Object @match:splitRecord { - payload: [ - { - chainId: Object @match:string { - payload: [], - }, - value: Object @match:string { - payload: [], - }, - }, - { - encoding: 'bech32', - }, - ], + validator: { + chainId: Object @match:string { + payload: [], + }, + encoding: Object @match:string { + payload: [], + }, + value: Object @match:string { + payload: [], + }, }, }, { - delegator: Object @match:splitRecord { - payload: [ - { - chainId: Object @match:string { - payload: [], - }, - value: Object @match:string { - payload: [], - }, - }, - { - encoding: 'bech32', - }, - ], + delegator: { + chainId: Object @match:string { + payload: [], + }, + encoding: Object @match:string { + payload: [], + }, + value: Object @match:string { + payload: [], + }, }, }, ], @@ -371,20 +351,16 @@ Generated by [AVA](https://avajs.dev). payload: [ {}, { - intermediateRecipient: Object @match:splitRecord { - payload: [ - { - chainId: Object @match:string { - payload: [], - }, - value: Object @match:string { - payload: [], - }, - }, - { - encoding: 'bech32', - }, - ], + intermediateRecipient: { + chainId: Object @match:string { + payload: [], + }, + encoding: Object @match:string { + payload: [], + }, + value: Object @match:string { + payload: [], + }, }, retries: Object @match:kind { payload: 'number', @@ -487,20 +463,16 @@ Generated by [AVA](https://avajs.dev). payload: [ {}, { - intermediateRecipient: Object @match:splitRecord { - payload: [ - { - chainId: Object @match:string { - payload: [], - }, - value: Object @match:string { - payload: [], - }, - }, - { - encoding: 'bech32', - }, - ], + intermediateRecipient: { + chainId: Object @match:string { + payload: [], + }, + encoding: Object @match:string { + payload: [], + }, + value: Object @match:string { + payload: [], + }, }, retries: Object @match:kind { payload: 'number', diff --git a/packages/builders/test/snapshots/orchestration-imports.test.js.snap b/packages/builders/test/snapshots/orchestration-imports.test.js.snap index dfa11462cc5..44d4ef6c72d 100644 Binary files a/packages/builders/test/snapshots/orchestration-imports.test.js.snap and b/packages/builders/test/snapshots/orchestration-imports.test.js.snap differ diff --git a/packages/fast-usdc/src/exos/transaction-feed.js b/packages/fast-usdc/src/exos/transaction-feed.js index 33d76f4bbc8..98e668357bf 100644 --- a/packages/fast-usdc/src/exos/transaction-feed.js +++ b/packages/fast-usdc/src/exos/transaction-feed.js @@ -209,20 +209,19 @@ export const prepareTransactionFeedKit = (zone, zcf) => { let lastEvidence; for (const store of found) { const next = store.get(txHash); - if (lastEvidence) { - if (keyEQ(lastEvidence, next)) { - lastEvidence = next; - } else { - trace( - '🚨 conflicting evidence for', - txHash, - ':', - lastEvidence, - '!=', - next, - ); - Fail`conflicting evidence for ${quote(txHash)}`; - } + if (lastEvidence && !keyEQ(lastEvidence, next)) { + // Ignore conflicting evidence, but treat it as an error + // because it should never happen and needs to be prevented + // from happening again. + trace( + '🚨 conflicting evidence for', + txHash, + ':', + lastEvidence, + '!=', + next, + ); + Fail`conflicting evidence for ${quote(txHash)}`; } lastEvidence = next; } diff --git a/packages/fast-usdc/src/start-fast-usdc.core.js b/packages/fast-usdc/src/start-fast-usdc.core.js index 6f7efc8f590..e13fbc4d597 100644 --- a/packages/fast-usdc/src/start-fast-usdc.core.js +++ b/packages/fast-usdc/src/start-fast-usdc.core.js @@ -59,6 +59,7 @@ const POOL_METRICS = 'poolMetrics'; * }} FastUSDCCorePowers * * @typedef {StartedInstanceKitWithLabel & { + * publicFacet: StartedInstanceKit['publicFacet']; * creatorFacet: StartedInstanceKit['creatorFacet']; * privateArgs: StartParams['privateArgs']; * }} FastUSDCKit diff --git a/packages/fast-usdc/test/exos/advancer.test.ts b/packages/fast-usdc/test/exos/advancer.test.ts index 26bb3c29158..e21d52c13b6 100644 --- a/packages/fast-usdc/test/exos/advancer.test.ts +++ b/packages/fast-usdc/test/exos/advancer.test.ts @@ -251,6 +251,7 @@ test('updates status to ADVANCING in happy path', async t => { }, destination: { chainId: 'osmosis-1', + encoding: 'bech32', value: 'osmo183dejcnmkka5dzcu9xw6mywq0p2m5peks28men', }, }, @@ -659,6 +660,7 @@ test('will not advance same txHash:chainId evidence twice', async t => { advanceAmount: { brand: usdc.brand, value: 146999999n }, destination: { chainId: 'osmosis-1', + encoding: 'bech32', value: 'osmo183dejcnmkka5dzcu9xw6mywq0p2m5peks28men', }, }, @@ -911,6 +913,7 @@ test('uses bank send for agoric1 EUD', async t => { }, destination: { chainId: 'agoric-3', + encoding: 'bech32', value: 'agoric13rj0cc0hm5ac2nt0sdup2l7gvkx4v9tyvgq3h2', }, }, diff --git a/packages/fast-usdc/test/exos/settler.test.ts b/packages/fast-usdc/test/exos/settler.test.ts index 31e5c4b2ece..61ea505df15 100644 --- a/packages/fast-usdc/test/exos/settler.test.ts +++ b/packages/fast-usdc/test/exos/settler.test.ts @@ -371,6 +371,7 @@ test('slow path: forward to EUD; remove pending tx', async t => { forwardOpts: { intermediateRecipient: { chainId: 'noble-1', + encoding: 'bech32', value: 'noble1test', }, }, @@ -445,6 +446,7 @@ test('skip advance: forward to EUD; remove pending tx', async t => { forwardOpts: { intermediateRecipient: { chainId: 'noble-1', + encoding: 'bech32', value: 'noble1test', }, }, diff --git a/packages/fast-usdc/test/exos/snapshots/advancer.test.ts.md b/packages/fast-usdc/test/exos/snapshots/advancer.test.ts.md index 8e879733071..8f795a6e31b 100644 --- a/packages/fast-usdc/test/exos/snapshots/advancer.test.ts.md +++ b/packages/fast-usdc/test/exos/snapshots/advancer.test.ts.md @@ -17,20 +17,16 @@ Generated by [AVA](https://avajs.dev). Object @match:kind { payload: 'undefined', }, - Object @match:splitRecord { - payload: [ - { - chainId: Object @match:string { - payload: [], - }, - value: Object @match:string { - payload: [], - }, - }, - { - encoding: 'bech32', - }, - ], + { + chainId: Object @match:string { + payload: [], + }, + encoding: Object @match:string { + payload: [], + }, + value: Object @match:string { + payload: [], + }, }, ], }, @@ -45,20 +41,16 @@ Generated by [AVA](https://avajs.dev). Object @match:kind { payload: 'undefined', }, - Object @match:splitRecord { - payload: [ - { - chainId: Object @match:string { - payload: [], - }, - value: Object @match:string { - payload: [], - }, - }, - { - encoding: 'bech32', - }, - ], + { + chainId: Object @match:string { + payload: [], + }, + encoding: Object @match:string { + payload: [], + }, + value: Object @match:string { + payload: [], + }, }, ], }, diff --git a/packages/fast-usdc/test/exos/snapshots/advancer.test.ts.snap b/packages/fast-usdc/test/exos/snapshots/advancer.test.ts.snap index 14586bdbd08..b807bae2ec4 100644 Binary files a/packages/fast-usdc/test/exos/snapshots/advancer.test.ts.snap and b/packages/fast-usdc/test/exos/snapshots/advancer.test.ts.snap differ diff --git a/packages/fast-usdc/test/exos/snapshots/settler.test.ts.md b/packages/fast-usdc/test/exos/snapshots/settler.test.ts.md index 66f5262a1e6..2ac29525e21 100644 --- a/packages/fast-usdc/test/exos/snapshots/settler.test.ts.md +++ b/packages/fast-usdc/test/exos/snapshots/settler.test.ts.md @@ -14,20 +14,16 @@ Generated by [AVA](https://avajs.dev). Object @match:kind { payload: 'undefined', }, - Object @match:splitRecord { - payload: [ - { - chainId: Object @match:string { - payload: [], - }, - value: Object @match:string { - payload: [], - }, - }, - { - encoding: 'bech32', - }, - ], + { + chainId: Object @match:string { + payload: [], + }, + encoding: Object @match:string { + payload: [], + }, + value: Object @match:string { + payload: [], + }, }, ], }, diff --git a/packages/fast-usdc/test/exos/snapshots/settler.test.ts.snap b/packages/fast-usdc/test/exos/snapshots/settler.test.ts.snap index 5c62f284d2d..51f80fcb163 100644 Binary files a/packages/fast-usdc/test/exos/snapshots/settler.test.ts.snap and b/packages/fast-usdc/test/exos/snapshots/settler.test.ts.snap differ diff --git a/packages/fast-usdc/test/fixtures.ts b/packages/fast-usdc/test/fixtures.ts index 7a5410e7448..130f278a5b8 100644 --- a/packages/fast-usdc/test/fixtures.ts +++ b/packages/fast-usdc/test/fixtures.ts @@ -197,10 +197,12 @@ export const MockVTransferEvents: Record< export const intermediateRecipient: CosmosChainAddress = harden({ chainId: 'noble-1', value: 'noble1test', + encoding: 'bech32', }); export const settlementAddress: CosmosChainAddress = harden({ chainId: 'agoric-3', + encoding: 'bech32' as const, // Random value, copied from tests of address hooks value: 'agoric16kv2g7snfc4q24vg3pjdlnnqgngtjpwtetd2h689nz09lcklvh5s8u37ek', }); diff --git a/packages/fast-usdc/test/snapshots/fast-usdc.contract.test.ts.md b/packages/fast-usdc/test/snapshots/fast-usdc.contract.test.ts.md index 06a347a660e..df1cc4e571c 100644 --- a/packages/fast-usdc/test/snapshots/fast-usdc.contract.test.ts.md +++ b/packages/fast-usdc/test/snapshots/fast-usdc.contract.test.ts.md @@ -1530,16 +1530,6 @@ Generated by [AVA](https://avajs.dev). LocalChainFacade_kindHandle: 'Alleged: kind', Orchestrator_kindHandle: 'Alleged: kind', RemoteChainFacade_kindHandle: 'Alleged: kind', - chainName: { - agoric: { - pending: false, - value: Object @Alleged: LocalChainFacade public {}, - }, - noble: { - pending: false, - value: Object @Alleged: RemoteChainFacade public {}, - }, - }, ibcTools: { IBCTransferSenderKit_kindHandle: 'Alleged: kind', ibcResultWatcher_kindHandle: 'Alleged: kind', @@ -3276,16 +3266,6 @@ Generated by [AVA](https://avajs.dev). LocalChainFacade_kindHandle: 'Alleged: kind', Orchestrator_kindHandle: 'Alleged: kind', RemoteChainFacade_kindHandle: 'Alleged: kind', - chainName: { - agoric: { - pending: false, - value: Object @Alleged: LocalChainFacade public {}, - }, - noble: { - pending: false, - value: Object @Alleged: RemoteChainFacade public {}, - }, - }, ibcTools: { IBCTransferSenderKit_kindHandle: 'Alleged: kind', ibcResultWatcher_kindHandle: 'Alleged: kind', diff --git a/packages/fast-usdc/test/snapshots/fast-usdc.contract.test.ts.snap b/packages/fast-usdc/test/snapshots/fast-usdc.contract.test.ts.snap index 0e5e7133207..6cfb1231583 100644 Binary files a/packages/fast-usdc/test/snapshots/fast-usdc.contract.test.ts.snap and b/packages/fast-usdc/test/snapshots/fast-usdc.contract.test.ts.snap differ diff --git a/packages/orchestration/src/cosmos-api.ts b/packages/orchestration/src/cosmos-api.ts index 605d56a43e3..801d6f22bce 100644 --- a/packages/orchestration/src/cosmos-api.ts +++ b/packages/orchestration/src/cosmos-api.ts @@ -52,6 +52,7 @@ export type Bech32Address = `${string}1${string}`; export type CosmosValidatorAddress = CosmosChainAddress & { // infix for Validator Operator https://docs.cosmos.network/main/learn/beginner/accounts#addresses value: `${string}valoper${string}`; + encoding: 'bech32'; }; /** Represents an IBC Connection between two chains, which can contain multiple Channels. */ diff --git a/packages/orchestration/src/examples/send-anywhere.flows.js b/packages/orchestration/src/examples/send-anywhere.flows.js index 58466e31d8f..6022fcb40f1 100644 --- a/packages/orchestration/src/examples/send-anywhere.flows.js +++ b/packages/orchestration/src/examples/send-anywhere.flows.js @@ -64,6 +64,7 @@ export const sendIt = async ( await sharedLocalAccount.transfer( { value: destAddr, + encoding: 'bech32', chainId, }, { denom, value: amt.value }, diff --git a/packages/orchestration/src/examples/stake-bld.contract.js b/packages/orchestration/src/examples/stake-bld.contract.js index 7b0741130ed..db657e1235c 100644 --- a/packages/orchestration/src/examples/stake-bld.contract.js +++ b/packages/orchestration/src/examples/stake-bld.contract.js @@ -87,6 +87,7 @@ export const start = async (zcf, privateArgs, baggage) => { account, address: harden({ value: address, + encoding: 'bech32', chainId: 'agoriclocal', }), storageNode: privateArgs.storageNode, diff --git a/packages/orchestration/src/exos/chain-hub.js b/packages/orchestration/src/exos/chain-hub.js index eef5f835b2b..49026b13cdc 100644 --- a/packages/orchestration/src/exos/chain-hub.js +++ b/packages/orchestration/src/exos/chain-hub.js @@ -533,6 +533,7 @@ export const makeChainHub = (zone, agoricNames, vowTools) => { assert.equal(parsed.namespace, 'cosmos'); return harden({ chainId: parsed.reference, + encoding: 'bech32', value: parsed.accountAddress, }); } @@ -541,6 +542,7 @@ export const makeChainHub = (zone, agoricNames, vowTools) => { return harden({ chainId, value: parsed.accountAddress, + encoding: /** @type {const} */ ('bech32'), }); }, // TODO document whether this is limited to IBC diff --git a/packages/orchestration/src/exos/ica-account-kit.js b/packages/orchestration/src/exos/ica-account-kit.js index 33afee99554..2dcadf3fbd5 100644 --- a/packages/orchestration/src/exos/ica-account-kit.js +++ b/packages/orchestration/src/exos/ica-account-kit.js @@ -191,6 +191,7 @@ export const prepareIcaAccountKit = (zone, { watch, asVow }) => this.state.chainAddress = harden({ value: address || UNPARSABLE_CHAIN_ADDRESS, chainId: this.state.chainId, + encoding: 'bech32', }); }, /** diff --git a/packages/orchestration/src/exos/local-chain-facade.js b/packages/orchestration/src/exos/local-chain-facade.js index fec218a3009..a13d8a96829 100644 --- a/packages/orchestration/src/exos/local-chain-facade.js +++ b/packages/orchestration/src/exos/local-chain-facade.js @@ -168,6 +168,7 @@ const prepareLocalChainFacadeKit = ( account, address: harden({ value: address, + encoding: 'bech32', chainId: localChainInfo.chainId, }), // FIXME storage path https://github.com/Agoric/agoric-sdk/issues/9066 diff --git a/packages/orchestration/src/exos/orchestrator.js b/packages/orchestration/src/exos/orchestrator.js index 0d5dae350b8..d4a596ad7f5 100644 --- a/packages/orchestration/src/exos/orchestrator.js +++ b/packages/orchestration/src/exos/orchestrator.js @@ -1,6 +1,6 @@ /** @file Orchestrator exo */ import { AmountShape } from '@agoric/ertp'; -import { pickFacet } from '@agoric/vat-data'; +import { makeScalarMapStore, pickFacet } from '@agoric/vat-data'; import { makeTracer } from '@agoric/internal'; import { Shape as NetworkShape } from '@agoric/network'; import { Fail, q } from '@endo/errors'; @@ -61,8 +61,12 @@ const prepareOrchestratorKit = ( * @typedef {{ vow: Vow; pending: true } | { value: T; pending: false }} MaybePendingValue */ - /** @type {MapStore>>} */ - const chainByName = zone.mapStore('chainName'); + /** + * heap store is fine for a cache + * + * @type {MapStore>>} + */ + const chainByName = makeScalarMapStore('chainName'); return zone.exoClassKit( 'Orchestrator', diff --git a/packages/orchestration/src/exos/portfolio-holder-kit.js b/packages/orchestration/src/exos/portfolio-holder-kit.js index e232335edb9..0b8f213796d 100644 --- a/packages/orchestration/src/exos/portfolio-holder-kit.js +++ b/packages/orchestration/src/exos/portfolio-holder-kit.js @@ -200,6 +200,7 @@ const preparePortfolioHolderKit = (zone, { asVow, when }) => { * { * value: 'cosmos1valoper', * chainId: 'cosmoshub-99', + * encoding: 'bech32', * }, * { * denom: 'uatom', diff --git a/packages/orchestration/src/orchestration-api.ts b/packages/orchestration/src/orchestration-api.ts index bfb7736530e..8e3954b736a 100644 --- a/packages/orchestration/src/orchestration-api.ts +++ b/packages/orchestration/src/orchestration-api.ts @@ -85,6 +85,7 @@ export type CosmosChainAddress = { chainId: string; /** The address value used on-chain */ value: string; + encoding: 'bech32' | 'ethereum'; }; /** diff --git a/packages/orchestration/src/typeGuards.js b/packages/orchestration/src/typeGuards.js index 3dd18448309..3085af7a913 100644 --- a/packages/orchestration/src/typeGuards.js +++ b/packages/orchestration/src/typeGuards.js @@ -29,16 +29,12 @@ export const OutboundConnectionHandlerI = M.interface( // XXX @type {TypedPattern} but that's causing error: // Declaration emit for this file requires using private name 'validatedType' from module '"/opt/agoric/agoric-sdk/packages/internal/src/types"'. An explicit type annotation may unblock declaration emit. -export const CosmosChainAddressShape = M.splitRecord( - { - chainId: M.string(), - value: M.string(), - }, - { - // Ignored but maintained for backwards compatibility - encoding: 'bech32', - }, -); +export const CosmosChainAddressShape = { + chainId: M.string(), + // Ignored but maintained for backwards compatibility + encoding: M.string(), + value: M.string(), +}; harden(CosmosChainAddressShape); /** @deprecated use CosmosChainAddressShape */ export const ChainAddressShape = CosmosChainAddressShape; diff --git a/packages/orchestration/src/types.ts b/packages/orchestration/src/types.ts index 7a0b23566e4..e20fdc40b18 100644 --- a/packages/orchestration/src/types.ts +++ b/packages/orchestration/src/types.ts @@ -1,5 +1,8 @@ /** @file Rollup of all type definitions in the package, for local import and external export */ +// For ZCF which is only available ambiently +/// + export type * from './chain-info.js'; export type * from './cosmos-api.js'; export type * from './ethereum-api.js'; diff --git a/packages/orchestration/src/utils/cosmos.js b/packages/orchestration/src/utils/cosmos.js index 85310370555..5082a1c5ed9 100644 --- a/packages/orchestration/src/utils/cosmos.js +++ b/packages/orchestration/src/utils/cosmos.js @@ -57,6 +57,7 @@ export const toTruncatedDenomAmount = c => ({ * ) => CosmosValidatorAddress} */ export const toCosmosValidatorAddress = (r, chainId) => ({ + encoding: 'bech32', value: /** @type {CosmosValidatorAddress['value']} */ (r.validatorAddress), chainId, }); @@ -73,6 +74,7 @@ export const toCosmosValidatorAddress = (r, chainId) => ({ export const toCosmosDelegationResponse = ({ chainId }, r) => ({ delegator: { chainId, + encoding: 'bech32', value: r.delegation.delegatorAddress, }, validator: toCosmosValidatorAddress(r.delegation, chainId), diff --git a/packages/orchestration/src/utils/orc.js b/packages/orchestration/src/utils/orc.js index 9e8e86c5ab8..47a0d260e8f 100644 --- a/packages/orchestration/src/utils/orc.js +++ b/packages/orchestration/src/utils/orc.js @@ -13,6 +13,7 @@ export const orcUtils = { toAccount: { chainId: 'osmosis-test', value: 'osmo1234', + encoding: 'bech32', }, }; }, @@ -30,6 +31,7 @@ export const orcUtils = { toAccount: { chainId: 'osmosis-test', value: 'osmo1234', + encoding: 'bech32', }, }; }, diff --git a/packages/orchestration/test/examples/auto-stake-it.contract.test.ts b/packages/orchestration/test/examples/auto-stake-it.contract.test.ts index f96b05a7aac..d462e7e236c 100644 --- a/packages/orchestration/test/examples/auto-stake-it.contract.test.ts +++ b/packages/orchestration/test/examples/auto-stake-it.contract.test.ts @@ -49,6 +49,7 @@ test('make accounts, register tap, return invitationMakers', async t => { validator: { chainId: 'cosmoshub-4', value: 'cosmosvaloper1test', + encoding: 'bech32', }, }); const result = await heapVowE(userSeat).getOfferResult(); @@ -136,6 +137,7 @@ test('make accounts, register tap, return invitationMakers', async t => { validator: { chainId: 'cosmoshub-4', value: 'cosmosvaloper1test', + encoding: 'bech32', }, }); const { publicSubscribers: pubSubs2 } = diff --git a/packages/orchestration/test/examples/snapshots/send-anywhere.test.ts.md b/packages/orchestration/test/examples/snapshots/send-anywhere.test.ts.md index 7a169967c91..da8fa18a1e4 100644 --- a/packages/orchestration/test/examples/snapshots/send-anywhere.test.ts.md +++ b/packages/orchestration/test/examples/snapshots/send-anywhere.test.ts.md @@ -4716,16 +4716,6 @@ Generated by [AVA](https://avajs.dev). LocalChainFacade_kindHandle: 'Alleged: kind', Orchestrator_kindHandle: 'Alleged: kind', RemoteChainFacade_kindHandle: 'Alleged: kind', - chainName: { - agoric: { - pending: true, - vow: Object @Vow { - payload: { - vowV0: Object @Alleged: VowInternalsKit vowV0 {}, - }, - }, - }, - }, ibcTools: { IBCTransferSenderKit_kindHandle: 'Alleged: kind', ibcResultWatcher_kindHandle: 'Alleged: kind', diff --git a/packages/orchestration/test/examples/snapshots/send-anywhere.test.ts.snap b/packages/orchestration/test/examples/snapshots/send-anywhere.test.ts.snap index 5a8397638f0..0e546206182 100644 Binary files a/packages/orchestration/test/examples/snapshots/send-anywhere.test.ts.snap and b/packages/orchestration/test/examples/snapshots/send-anywhere.test.ts.snap differ diff --git a/packages/orchestration/test/examples/snapshots/staking-combinations.test.ts.md b/packages/orchestration/test/examples/snapshots/staking-combinations.test.ts.md index a980b9e0366..988e7ca6faf 100644 --- a/packages/orchestration/test/examples/snapshots/staking-combinations.test.ts.md +++ b/packages/orchestration/test/examples/snapshots/staking-combinations.test.ts.md @@ -204,16 +204,6 @@ Generated by [AVA](https://avajs.dev). LocalChainFacade_kindHandle: 'Alleged: kind', Orchestrator_kindHandle: 'Alleged: kind', RemoteChainFacade_kindHandle: 'Alleged: kind', - chainName: { - agoric: { - pending: false, - value: Object @Alleged: LocalChainFacade public {}, - }, - cosmoshub: { - pending: false, - value: Object @Alleged: RemoteChainFacade public {}, - }, - }, ibcTools: { IBCTransferSenderKit_kindHandle: 'Alleged: kind', ibcResultWatcher_kindHandle: 'Alleged: kind', diff --git a/packages/orchestration/test/examples/snapshots/staking-combinations.test.ts.snap b/packages/orchestration/test/examples/snapshots/staking-combinations.test.ts.snap index 49117d40b18..cf5069eaed4 100644 Binary files a/packages/orchestration/test/examples/snapshots/staking-combinations.test.ts.snap and b/packages/orchestration/test/examples/snapshots/staking-combinations.test.ts.snap differ diff --git a/packages/orchestration/test/examples/snapshots/unbond.contract.test.ts.md b/packages/orchestration/test/examples/snapshots/unbond.contract.test.ts.md index 38afb579572..4183011ae3d 100644 --- a/packages/orchestration/test/examples/snapshots/unbond.contract.test.ts.md +++ b/packages/orchestration/test/examples/snapshots/unbond.contract.test.ts.md @@ -156,16 +156,6 @@ Generated by [AVA](https://avajs.dev). LocalChainFacade_kindHandle: 'Alleged: kind', Orchestrator_kindHandle: 'Alleged: kind', RemoteChainFacade_kindHandle: 'Alleged: kind', - chainName: { - osmosis: { - pending: false, - value: Object @Alleged: RemoteChainFacade public {}, - }, - stride: { - pending: false, - value: Object @Alleged: RemoteChainFacade public {}, - }, - }, ibcTools: { IBCTransferSenderKit_kindHandle: 'Alleged: kind', ibcResultWatcher_kindHandle: 'Alleged: kind', diff --git a/packages/orchestration/test/examples/snapshots/unbond.contract.test.ts.snap b/packages/orchestration/test/examples/snapshots/unbond.contract.test.ts.snap index fbf1182ba9f..a4f86b7a9dd 100644 Binary files a/packages/orchestration/test/examples/snapshots/unbond.contract.test.ts.snap and b/packages/orchestration/test/examples/snapshots/unbond.contract.test.ts.snap differ diff --git a/packages/orchestration/test/examples/stake-ica.contract.test.ts b/packages/orchestration/test/examples/stake-ica.contract.test.ts index 7d54031782b..d1956b72d96 100644 --- a/packages/orchestration/test/examples/stake-ica.contract.test.ts +++ b/packages/orchestration/test/examples/stake-ica.contract.test.ts @@ -80,7 +80,7 @@ test('makeAccount, getAddress', async t => { t.truthy(account, 'account is returned'); const chainAddress = await E(account).getAddress(); t.regex(chainAddress.value, /cosmos1/); - t.like(chainAddress, { chainId: 'cosmoshub-4' }); + t.like(chainAddress, { chainId: 'cosmoshub-4', encoding: 'bech32' }); const accountP = E(publicFacet).makeAccount(); const { value: address2 } = await E(accountP).getAddress(); @@ -122,6 +122,7 @@ test('delegate, undelegate, redelegate, withdrawReward', async t => { const validatorAddr = { value: 'cosmosvaloper1test' as const, chainId: 'cosmoshub-4', + encoding: 'bech32' as const, }; const delegation = { denom: 'uatom', diff --git a/packages/orchestration/test/examples/staking-combinations.test.ts b/packages/orchestration/test/examples/staking-combinations.test.ts index 8f5eb82b809..6ef704c2376 100644 --- a/packages/orchestration/test/examples/staking-combinations.test.ts +++ b/packages/orchestration/test/examples/staking-combinations.test.ts @@ -121,6 +121,7 @@ test(expectUnhandled(1), 'start', async t => { validator: { chainId: 'cosmoshub', value: 'cosmosvaloper1test', + encoding: 'bech32', }, }, ); @@ -158,6 +159,7 @@ test(expectUnhandled(1), 'start', async t => { const destination = { chainId: 'osmosis-1', value: 'osmo1receiver', + encoding: 'bech32', }; const undelegateAndTransferInv = await E( result.invitationMakers, @@ -166,6 +168,7 @@ test(expectUnhandled(1), 'start', async t => { { validator: { value: 'osmovaloper1test', + encoding: 'bech32', chainId: 'osmosis', }, amount: { denom: 'uosmo', value: 100n }, @@ -227,6 +230,7 @@ test(expectUnhandled(1), 'start', async t => { validator: { chainId: 'cosmoshub', value: 'cosmosvaloper1test', + encoding: 'bech32', }, }, ); diff --git a/packages/orchestration/test/examples/swap.contract.test.ts b/packages/orchestration/test/examples/swap.contract.test.ts index 3f9a7ddbcbf..7eb8869eb38 100644 --- a/packages/orchestration/test/examples/swap.contract.test.ts +++ b/packages/orchestration/test/examples/swap.contract.test.ts @@ -56,6 +56,7 @@ test('start', async t => { validator: { chainId: 'agoric-3', value: 'agoric1valoperfufu', + encoding: 'bech32', } as const, }, ); diff --git a/packages/orchestration/test/exos/chain-hub-transfer-routes.test.ts b/packages/orchestration/test/exos/chain-hub-transfer-routes.test.ts index 5aa33e85648..5b8596e6ee9 100644 --- a/packages/orchestration/test/exos/chain-hub-transfer-routes.test.ts +++ b/packages/orchestration/test/exos/chain-hub-transfer-routes.test.ts @@ -216,6 +216,7 @@ test('takes forwardOpts', t => { const nobleAddr = harden({ value: 'noble1234', + encoding: 'bech32' as const, chainId: 'noble-1', }); @@ -254,6 +255,7 @@ test('takes forwardOpts', t => { const nobleDest: CosmosChainAddress = harden({ value: 'noble1234', chainId: 'noble-1', + encoding: 'bech32', }); test('no chain info', t => { diff --git a/packages/orchestration/test/exos/chain-hub.test.ts b/packages/orchestration/test/exos/chain-hub.test.ts index fd6491b6df8..d905c0b4c05 100644 --- a/packages/orchestration/test/exos/chain-hub.test.ts +++ b/packages/orchestration/test/exos/chain-hub.test.ts @@ -173,6 +173,7 @@ test('makeChainAddress', async t => { t.deepEqual(chainHub.makeChainAddress(MOCK_ICA_ADDRESS), { chainId: 'osmosis-1', value: MOCK_ICA_ADDRESS, + encoding: 'bech32', }); t.throws( diff --git a/packages/orchestration/test/exos/cosmos-orchestration-account.test.ts b/packages/orchestration/test/exos/cosmos-orchestration-account.test.ts index a59105a5cc3..f590bfa7af0 100644 --- a/packages/orchestration/test/exos/cosmos-orchestration-account.test.ts +++ b/packages/orchestration/test/exos/cosmos-orchestration-account.test.ts @@ -96,6 +96,7 @@ test('send (to addr on same chain)', async t => { const toAddress: CosmosChainAddress = { value: 'cosmos99test', chainId: 'cosmoshub-4', + encoding: 'bech32', }; // single send @@ -284,6 +285,7 @@ test('transfer', async t => { const mockDestination: CosmosChainAddress = { value: 'noble1test', chainId: 'noble-1', + encoding: 'bech32', }; const mockAmountArg: AmountArg = { value: 10n, denom: 'ibc/uusdchash' }; const res = E(account).transfer(mockDestination, mockAmountArg); @@ -533,6 +535,7 @@ test('StakingAccountQueries', async t => { const mockValidator: CosmosValidatorAddress = { value: 'cosmosvaloper1xyz', chainId: 'cosmoshub-4', + encoding: 'bech32', }; const makeDelegationReq = () => @@ -767,6 +770,7 @@ test('StakingAccountQueries', async t => { const mockValidator: CosmosValidatorAddress = { value: 'cosmosvaloper1xyz', chainId: 'cosmoshub-4', + encoding: 'bech32', }; // Test getDelegation @@ -775,10 +779,12 @@ test('StakingAccountQueries', async t => { amount: { denom: 'uatom', value: 1000000n }, delegator: { chainId: 'cosmoshub-4', + encoding: 'bech32', value: 'cosmos1test', }, validator: { chainId: 'cosmoshub-4', + encoding: 'bech32', value: mockValidator.value, }, }); @@ -791,10 +797,12 @@ test('StakingAccountQueries', async t => { delegator: { chainId: 'cosmoshub-4', + encoding: 'bech32', value: 'cosmos1test', }, validator: { chainId: 'cosmoshub-4', + encoding: 'bech32', value: mockValidator.value, }, }, @@ -874,6 +882,7 @@ test('StakingAccountQueries', async t => { rewards: [ { validator: { + encoding: 'bech32', value: mockValidator.value, chainId: 'cosmoshub-4', }, diff --git a/packages/orchestration/test/exos/local-orchestration-account-kit.test.ts b/packages/orchestration/test/exos/local-orchestration-account-kit.test.ts index 3e53d8da200..0c8421721f6 100644 --- a/packages/orchestration/test/exos/local-orchestration-account-kit.test.ts +++ b/packages/orchestration/test/exos/local-orchestration-account-kit.test.ts @@ -144,6 +144,7 @@ test(expectUnhandled(1), 'transfer', async t => { const destination: CosmosChainAddress = { chainId: 'cosmoshub-4', value: 'cosmos1pleab', + encoding: 'bech32', }; /** The running tally of transfer messages that were sent over the bridge */ @@ -205,6 +206,7 @@ test(expectUnhandled(1), 'transfer', async t => { const unknownDestination: CosmosChainAddress = { chainId: 'fakenet', value: 'fakenet1pleab', + encoding: 'bech32', }; // XXX dev has to know not to startTransfer here await t.throwsAsync( @@ -284,6 +286,7 @@ test(expectUnhandled(1), 'transfer', async t => { ); const dydxDest: CosmosChainAddress = { chainId: 'dydx-mainnet-1', + encoding: 'bech32', value: 'dydx1test', }; const aDenomAmount: DenomAmount = { @@ -393,6 +396,7 @@ test('send', async t => { const toAddress = { value: 'agoric1EOAAccAddress', chainId: 'agoric-3', + encoding: 'bech32' as const, }; t.log(`send 10 bld to ${toAddress.value}`); diff --git a/packages/orchestration/test/exos/make-test-loa-kit.ts b/packages/orchestration/test/exos/make-test-loa-kit.ts index 235507ff5e7..79126fa9f59 100644 --- a/packages/orchestration/test/exos/make-test-loa-kit.ts +++ b/packages/orchestration/test/exos/make-test-loa-kit.ts @@ -59,6 +59,7 @@ export const prepareMakeTestLOAKit = ( address: harden({ value: address, chainId: 'agoric-3', + encoding: 'bech32', }), storageNode: storageNode.makeChildNode(address), }); diff --git a/packages/orchestration/test/exos/portfolio-holder-kit.test.ts b/packages/orchestration/test/exos/portfolio-holder-kit.test.ts index e881925aa05..b456399b57c 100644 --- a/packages/orchestration/test/exos/portfolio-holder-kit.test.ts +++ b/packages/orchestration/test/exos/portfolio-holder-kit.test.ts @@ -86,6 +86,7 @@ test('portfolio holder kit behaviors', async t => { { value: 'cosmos1valoper', chainId: 'cosmoshub-99', + encoding: 'bech32', }, { denom: 'uatom', diff --git a/packages/orchestration/test/staking-ops.test.ts b/packages/orchestration/test/staking-ops.test.ts index 8c811ccc187..33434eb2c45 100644 --- a/packages/orchestration/test/staking-ops.test.ts +++ b/packages/orchestration/test/staking-ops.test.ts @@ -70,6 +70,7 @@ const configStaking = { }, validator: { value: 'agoric1valoper234', + encoding: 'bech32', chainId: 'agoric-3', }, delegations: { @@ -82,6 +83,7 @@ const configStaking = { const configRedelegate = { validator: { value: 'agoric1valoper444', + encoding: 'bech32', chainId: 'atom-test', }, delegations: { @@ -156,6 +158,7 @@ const makeScenario = () => { const chainAddress: CosmosChainAddress = harden({ value: addr, + encoding: 'bech32', chainId: 'mock-1', }); diff --git a/packages/orchestration/test/tx-encoding.test.ts b/packages/orchestration/test/tx-encoding.test.ts index 0324e107fc3..1206536f1a7 100644 --- a/packages/orchestration/test/tx-encoding.test.ts +++ b/packages/orchestration/test/tx-encoding.test.ts @@ -15,7 +15,7 @@ const scenario1 = { acct1: { address: 'agoric1spy36ltduehs5dmszfrp792f0k2emcntrql3nx', }, - validator: { address: 'agoric1valoper234' }, + validator: { address: 'agoric1valoper234', encoding: 'bech32' }, delegations: { agoric1valoper234: { denom: 'uatom', amount: '200' }, }, diff --git a/packages/orchestration/test/typeGuards.test.ts b/packages/orchestration/test/typeGuards.test.ts index 4f3258cc15d..5ce80a6dbed 100644 --- a/packages/orchestration/test/typeGuards.test.ts +++ b/packages/orchestration/test/typeGuards.test.ts @@ -9,30 +9,33 @@ test('CosmosChainAddress', t => { mustMatch( harden({ chainId: 'noble-1', + encoding: 'bech32', value: 'noble1test', }), CosmosChainAddressShape, ); + t.throws(() => + mustMatch( + harden({ + chainId: 'noble-1', + encoding: 'bech32', + value: 'noble1test', + extraField: 'extraValue', + }), + CosmosChainAddressShape, + ), + ); + mustMatch( harden({ chainId: 'noble-1', + // ignored + encoding: 'invalid', value: 'noble1test', - extraField: 'extraValue', }), CosmosChainAddressShape, ); - - t.throws(() => { - mustMatch( - harden({ - chainId: 'noble-1', - encoding: 'bech32boo', - value: 'noble1test', - }), - CosmosChainAddressShape, - ); - }); }); test('backwards compatibility', t => { diff --git a/packages/orchestration/test/types.test-d.ts b/packages/orchestration/test/types.test-d.ts index 7157ad621ab..a5c96b352a8 100644 --- a/packages/orchestration/test/types.test-d.ts +++ b/packages/orchestration/test/types.test-d.ts @@ -43,12 +43,14 @@ const vt: VowTools = null as any; const validatorAddr = { chainId: 'agoric3', value: 'agoric1valoperhello', + encoding: 'bech32', } as const; expectType(validatorAddr); const chainAddr = { chainId: 'agoric-3', value: 'agoric1pleab', + encoding: 'bech32', } as const; expectType(chainAddr); expectNotType(chainAddr); @@ -259,6 +261,7 @@ expectNotType(chainAddr); { const addr = { chainId: 'chainId', + encoding: 'bech32', value: 'agoric1valoperfoo', }; expectAssignable(addr); diff --git a/packages/orchestration/test/utils/zoe-tools.test.ts b/packages/orchestration/test/utils/zoe-tools.test.ts index 33b7ecd1d1e..dbe5a5252c2 100644 --- a/packages/orchestration/test/utils/zoe-tools.test.ts +++ b/packages/orchestration/test/utils/zoe-tools.test.ts @@ -100,6 +100,7 @@ test('zoeTool.localTransfer error paths', async t => { const destAddr = { chainId: 'agoriclocal', value: 'agoric1testrecipient', + encoding: 'bech32', }; t.log('localTransfer recovers when presented non-vbank asset'); @@ -232,6 +233,7 @@ test('localTransfer happy path', async t => { const destAddr = { chainId: 'agoriclocal', value: 'agoric1testrecipient', + encoding: 'bech32', }; const tenStable = ist.make(10n);