Skip to content

Commit

Permalink
fixup! feat(orchestration): add more chain infos for fusdc
Browse files Browse the repository at this point in the history
  • Loading branch information
samsiegart committed Jan 16, 2025
1 parent 8057723 commit 9f28f36
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 76 deletions.
3 changes: 2 additions & 1 deletion multichain-testing/scripts/fetch-starship-chain-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import fsp from 'node:fs/promises';
import prettier from 'prettier';

import { convertChainInfo } from '@agoric/orchestration/src/utils/registry.js';
import { icaChainNames } from '@agoric/orchestration/scripts/fetch-chain-info.ts';

import type { IBCInfo, Chains } from '@chain-registry/types';

Expand Down Expand Up @@ -32,7 +33,7 @@ const chainInfo = await convertChainInfo(
chains,
ibcData: ibc.data,
},
() => true,
chainName => icaChainNames.has(chainName),
);

const record = JSON.stringify(chainInfo, null, 2);
Expand Down
22 changes: 3 additions & 19 deletions packages/boot/test/bootstrapTests/orchestration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import type { start as startStakeIca } from '@agoric/orchestration/src/examples/
import type { Instance } from '@agoric/zoe/src/zoeService/utils.js';
import type { TestFn } from 'ava';
import { SIMULATED_ERRORS } from '@agoric/vats/tools/fake-bridge.js';
import fetchedChainInfo from '@agoric/orchestration/src/fetched-chain-info.js';
import { buildVTransferEvent } from '@agoric/orchestration/tools/ibc-mocks.js';
import { BridgeId } from '@agoric/internal';
import { makeTestAddress } from '@agoric/orchestration/tools/make-test-address.js';
Expand All @@ -25,6 +24,7 @@ import {
insistManagerType,
makeSwingsetHarness,
} from '../../tools/supports.js';
import { minimalChainInfos } from '../tools/chainInfo.js';

const test: TestFn<
WalletFactoryTestContext & {
Expand Down Expand Up @@ -331,15 +331,7 @@ test.serial('basic-flows', async t => {
'@agoric/builders/scripts/orchestration/init-basic-flows.js',
[
'--chainInfo',
JSON.stringify(
withChainCapabilities({
agoric: fetchedChainInfo.agoric,
osmosis: fetchedChainInfo.osmosis,
dydx: fetchedChainInfo.dydx,
noble: fetchedChainInfo.noble,
cosmoshub: fetchedChainInfo.cosmoshub,
}),
),
JSON.stringify(withChainCapabilities(minimalChainInfos)),
'--assetInfo',
JSON.stringify([
[
Expand Down Expand Up @@ -564,15 +556,7 @@ test.serial('basic-flows - portfolio holder', async t => {
'@agoric/builders/scripts/orchestration/init-basic-flows.js',
[
'--chainInfo',
JSON.stringify(
withChainCapabilities({
agoric: fetchedChainInfo.agoric,
osmosis: fetchedChainInfo.osmosis,
dydx: fetchedChainInfo.dydx,
noble: fetchedChainInfo.noble,
cosmoshub: fetchedChainInfo.cosmoshub,
}),
),
JSON.stringify(withChainCapabilities(minimalChainInfos)),
'--assetInfo',
JSON.stringify([
[
Expand Down
24 changes: 0 additions & 24 deletions packages/boot/test/fast-usdc/fast-usdc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,12 +386,6 @@ test.serial('distributes fees per BLD staker decision', async t => {
const ContractFee = 302000n; // see split above
t.is(((ContractFee - 250000n) * 5n) / 10n, 26000n);

if (defaultManagerType === 'xs-worker') {
// XXX for some reason the code after this when run under XS fails with:
// message: 'unsettled value for "kp2526"',
return;
}

const cases = [
{ dest: 'agoric1a', args: ['--fixedFees', '0.25'], rxd: '250000' },
{ dest: 'agoric1b', args: ['--feePortion', '0.5'], rxd: '26000' },
Expand Down Expand Up @@ -529,12 +523,6 @@ test.serial('LP withdraws', async t => {
test.serial('restart contract', async t => {
const { EV } = t.context.runUtils;
await null;
if (defaultManagerType === 'xs-worker') {
t.is(defaultManagerType, 'xs-worker');
// XXX for some reason the code after this when run under XS fails with:
// message: 'unsettled value for "kp2526"',
return;
}
const kit = await EV.vat('bootstrap').consumeItem('fastUsdcKit');
const actual = await EV(kit.adminFacet).restartContract(kit.privateArgs);
t.deepEqual(actual, { incarnationNumber: 1 });
Expand All @@ -549,12 +537,6 @@ test.serial('replace operators', async t => {
runUtils: { EV },
walletFactoryDriver: wfd,
} = t.context;
if (defaultManagerType === 'xs-worker') {
t.is(defaultManagerType, 'xs-worker');
// XXX for some reason the code after this when run under XS fails with:
// message: 'unsettled value for "kp2526"',
return;
}
const { creatorFacet } = await EV.vat('bootstrap').consumeItem('fastUsdcKit');

const EUD = 'dydx1anything';
Expand Down Expand Up @@ -603,12 +585,6 @@ test.serial('replace operators', async t => {
}
}

if (defaultManagerType === 'xs-worker') {
// XXX for some reason the code after this when run under XS fails with:
// message: 'unsettled value for "kp2526"',
return;
}

// Add some new oracle operator
const {
// any one would do
Expand Down
12 changes: 2 additions & 10 deletions packages/boot/test/orchestration/contract-upgrade.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import type { TestFn } from 'ava';

import { BridgeId } from '@agoric/internal';
import { buildVTransferEvent } from '@agoric/orchestration/tools/ibc-mocks.js';
import fetchedChainInfo from '@agoric/orchestration/src/fetched-chain-info.js';
import { withChainCapabilities } from '@agoric/orchestration';
import { makeTestAddress } from '@agoric/orchestration/tools/make-test-address.js';
import {
makeWalletFactoryContext,
type WalletFactoryTestContext,
} from '../bootstrapTests/walletFactory.js';
import { minimalChainInfos } from '../tools/chainInfo.js';

const test: TestFn<WalletFactoryTestContext> = anyTest;
test.before(async t => {
Expand Down Expand Up @@ -45,15 +45,7 @@ test('resume', async t => {
await evalProposal(
buildProposal('@agoric/builders/scripts/testing/init-send-anywhere.js', [
'--chainInfo',
JSON.stringify(
withChainCapabilities({
agoric: fetchedChainInfo.agoric,
osmosis: fetchedChainInfo.osmosis,
dydx: fetchedChainInfo.dydx,
noble: fetchedChainInfo.noble,
cosmoshub: fetchedChainInfo.cosmoshub,
}),
),
JSON.stringify(withChainCapabilities(minimalChainInfos)),
'--assetInfo',
JSON.stringify([
[
Expand Down
12 changes: 2 additions & 10 deletions packages/boot/test/orchestration/restart-contracts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import {
} from '@agoric/orchestration';
import { buildVTransferEvent } from '@agoric/orchestration/tools/ibc-mocks.js';
import type { UpdateRecord } from '@agoric/smart-wallet/src/smartWallet.js';
import fetchedChainInfo from '@agoric/orchestration/src/fetched-chain-info.js';
import { makeTestAddress } from '@agoric/orchestration/tools/make-test-address.js';
import {
makeWalletFactoryContext,
type WalletFactoryTestContext,
} from '../bootstrapTests/walletFactory.js';
import { minimalChainInfos } from '../tools/chainInfo.js';

const test: TestFn<WalletFactoryTestContext> = anyTest;
test.before(async t => {
Expand All @@ -39,15 +39,7 @@ test.serial('send-anywhere', async t => {
await evalProposal(
buildProposal('@agoric/builders/scripts/testing/init-send-anywhere.js', [
'--chainInfo',
JSON.stringify(
withChainCapabilities({
agoric: fetchedChainInfo.agoric,
osmosis: fetchedChainInfo.osmosis,
dydx: fetchedChainInfo.dydx,
noble: fetchedChainInfo.noble,
cosmoshub: fetchedChainInfo.cosmoshub,
}),
),
JSON.stringify(withChainCapabilities(minimalChainInfos)),
'--assetInfo',
JSON.stringify([
[
Expand Down
9 changes: 9 additions & 0 deletions packages/boot/test/tools/chainInfo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import fetchedChainInfo from '@agoric/orchestration/src/fetched-chain-info.js';

export const minimalChainInfos = {
agoric: fetchedChainInfo.agoric,
osmosis: fetchedChainInfo.osmosis,
dydx: fetchedChainInfo.dydx,
noble: fetchedChainInfo.noble,
cosmoshub: fetchedChainInfo.cosmoshub,
};
9 changes: 5 additions & 4 deletions packages/orchestration/scripts/fetch-chain-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const outputFile = 'src/fetched-chain-info.js';
/**
* Names for which to fetch info
*/
const icaChainNames = [
export const icaChainNames = new Set([
'agoric',
'celestia',
'cosmoshub',
Expand All @@ -26,7 +26,7 @@ const icaChainNames = [
'stargaze',
'stride',
'umee',
];
]);

const nonIcaChainNames = [
'migaloo',
Expand Down Expand Up @@ -65,8 +65,9 @@ const client = new ChainRegistryClient({
// chain info, assets and ibc data will be downloaded dynamically by invoking fetchUrls method
await client.fetchUrls();

const icaChainSet = new Set(icaChainNames);
const chainInfo = await convertChainInfo(client, name => icaChainSet.has(name));
const chainInfo = await convertChainInfo(client, name =>
icaChainNames.has(name),
);

const record = JSON.stringify(chainInfo, null, 2);
const src = `/** @file Generated by fetch-chain-info.ts */\nexport default /** @type {const} } */ (${record});`;
Expand Down
10 changes: 5 additions & 5 deletions packages/orchestration/src/exos/chain-hub.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ const CHAIN_ID_SEPARATOR = '_';
/**
* Vstorage keys can be only alphanumerics, dash, or underscore, which are all
* valid characters in chain IDs. So, double each occurence of
* {@link CHAIN_ID_SEPARATOR} in the chain ID to make it clear that it's part of
* the chain ID rather than a separator.
* {@link CHAIN_ID_SEPARATOR} in the chain ID so the encoded tuple can be
* decoded.
*
* @param {string} chainId
* @see {@link https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-2.md}
*/
export const sanitizeChainId = chainId =>
export const encodeChainId = chainId =>
chainId.replaceAll(
CHAIN_ID_SEPARATOR,
`${CHAIN_ID_SEPARATOR}${CHAIN_ID_SEPARATOR}`,
Expand All @@ -98,8 +98,8 @@ export const sanitizeChainId = chainId =>
* @param {string} chainId2
*/
export const connectionKey = (chainId1, chainId2) => {
const chainId1Sanitized = sanitizeChainId(chainId1);
const chainId2Sanitized = sanitizeChainId(chainId2);
const chainId1Sanitized = encodeChainId(chainId1);
const chainId2Sanitized = encodeChainId(chainId2);

return [chainId1Sanitized, chainId2Sanitized].sort().join(CHAIN_ID_SEPARATOR);
};
Expand Down
6 changes: 3 additions & 3 deletions packages/orchestration/src/utils/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ function toConnectionEntry(ibcInfo, name, chainInfo) {
* Converts the given chain info to our local config format
*
* @param {Pick<ChainRegistryClient, 'chains' | 'ibcData'>} registry
* @param {(chainName: string) => boolean} icaEnabled
* @param {(chainName: string) => boolean} isIcaEnabled
*/
export const convertChainInfo = async (registry, icaEnabled) => {
export const convertChainInfo = async (registry, isIcaEnabled) => {
/** @type {Record<string, CosmosChainInfo>} */
const chainInfo = {};

Expand All @@ -96,7 +96,7 @@ export const convertChainInfo = async (registry, icaEnabled) => {
stakingTokens: chain.staking?.staking_tokens,
// UNTIL https://github.com/Agoric/agoric-sdk/issues/9326
icqEnabled: chain.chain_name === 'osmosis',
icaEnabled: icaEnabled(chain.chain_name),
icaEnabled: isIcaEnabled(chain.chain_name),
};
}

Expand Down

0 comments on commit 9f28f36

Please sign in to comment.