Skip to content

Commit

Permalink
feat: use fetched chain info
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Jun 10, 2024
1 parent 1ae0327 commit df15efd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 184 deletions.
150 changes: 0 additions & 150 deletions packages/boot/test/bootstrapTests/snapshots/orchestration.test.ts.md

This file was deleted.

Binary file not shown.
44 changes: 13 additions & 31 deletions packages/orchestration/src/chain-info.js
Original file line number Diff line number Diff line change
@@ -1,47 +1,29 @@
// UNTIL https://github.com/Agoric/agoric-sdk/issues/8879

/** @file temporary static lookup of chain info */

import { registerChain } from './utils/chainHub.js';

// Refresh with scripts/refresh-chain-info.ts
import fetchedChainInfo from './fetched-chain-info.js';

/** @import {CosmosChainInfo, EthChainInfo} from './types.js'; */

/** @typedef {CosmosChainInfo | EthChainInfo} ChainInfo */

// TODO generate this automatically with a build script drawing on data sources such as https://github.com/cosmos/chain-registry
const knownChains = /** @satisfies {Record<string, ChainInfo>} */ (
harden({
...fetchedChainInfo,
agoric: {
chainId: 'agoriclocal',
},
})
);

export const wellKnownChainInfo =
/** @satisfies {Record<string, ChainInfo>} */ (
harden({
agoric: {
chainId: 'agoriclocal',
},
// https://github.com/cosmos/chain-registry/blob/master/stride/chain.json
stride: {
chainId: 'stride-1',
stakingTokens: [{ denom: 'ustride' }],
},
cosmos: {
chainId: 'cosmoslocal',
stakingTokens: [{ denom: 'uatom' }],
},
celestia: {
chainId: 'celestia',
stakingTokens: [{ denom: 'utia' }],
},
osmosis: {
chainId: 'osmosislocal',
stakingTokens: [{ denom: 'uosmo' }],
},
})
);
/** @typedef {typeof knownChains} KnownChains */

/**
* @param {ERef<import('@agoric/vats').NameHubKit['nameAdmin']>} agoricNamesAdmin
* @param {(...messages: string[]) => void} log
*/
export const registerChainNamespace = async (agoricNamesAdmin, log) => {
for await (const [name, info] of Object.entries(wellKnownChainInfo)) {
for await (const [name, info] of Object.entries(knownChains)) {
log(`registering agoricNames chain.${name}`);
await registerChain(agoricNamesAdmin, name, info);
}
Expand Down
4 changes: 1 addition & 3 deletions packages/orchestration/src/orchestration-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@ import type {
CosmosChainAccountMethods,
CosmosChainInfo,
IBCMsgTransferOptions,
wellKnownChainInfo,
KnownChains,
} from './types.js';

type KnownChains = typeof wellKnownChainInfo;

/**
* A denom that designates a path to a token type on some blockchain.
*
Expand Down

0 comments on commit df15efd

Please sign in to comment.