Skip to content

Commit

Permalink
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 15, 2025
1 parent d703190 commit 111a842
Show file tree
Hide file tree
Showing 5 changed files with 6,983 additions and 674 deletions.
37 changes: 34 additions & 3 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 chainNames = [
const icaChainNames = [
'agoric',
'celestia',
'cosmoshub',
Expand All @@ -28,14 +28,45 @@ const chainNames = [
'umee',
];

const nonIcaChainNames = [
'migaloo',
'terra',
'planq',
'coreum',
'haqq',
'evmos',
'pryzm',
'nibiru',
'carbon',
'sei',
'archway',
'doravota',
'persistence',
'injective',
'sifchain',
'quicksilver',
'provenance',
'crescent',
'nolus',
'empowerchain',
'kava',
'kujira',
'shido',
'dymension',
'lava',
'titan',
'beezee',
];

const client = new ChainRegistryClient({
chainNames,
chainNames: [...icaChainNames, ...nonIcaChainNames],
});

// chain info, assets and ibc data will be downloaded dynamically by invoking fetchUrls method
await client.fetchUrls();

const chainInfo = await convertChainInfo(client);
const icaChainSet = new Set(icaChainNames);
const chainInfo = await convertChainInfo(client, name => icaChainSet.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
1 change: 1 addition & 0 deletions packages/orchestration/src/cosmos-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export type CosmosChainInfo = Readonly<{
* cf https://github.com/cosmos/chain-registry/blob/master/chain.schema.json#L117
*/
stakingTokens?: Readonly<Array<{ denom: string }>>;
icaEnabled?: boolean;
}>;

// #region Orchestration views on Cosmos response types
Expand Down
32 changes: 19 additions & 13 deletions packages/orchestration/src/exos/chain-hub.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,24 @@ export const CONNECTIONS_KEY = HubName.ChainConnection;
export const ASSETS_KEY = HubName.ChainAssets;

/**
* Character used in a connection tuple key to separate the two chain ids. Valid
* because a chainId can contain only alphanumerics and dash.
*
* Vstorage keys can be only alphanumerics, dash or underscore. That leaves
* underscore as the only valid separator.
* Character used in a connection tuple key to separate the two chain ids.
*/
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.
*
* @param {string} chainId
* @see {@link https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-2.md}
*/
const CHAIN_ID_SEPARATOR = '_';
export const sanitizeChainId = chainId =>
chainId.replaceAll(
CHAIN_ID_SEPARATOR,
`${CHAIN_ID_SEPARATOR}${CHAIN_ID_SEPARATOR}`,
);

/**
* The entries of the top-level namehubs in agoricNames are reflected to
Expand All @@ -89,13 +98,10 @@ const CHAIN_ID_SEPARATOR = '_';
* @param {string} chainId2
*/
export const connectionKey = (chainId1, chainId2) => {
if (
chainId1.includes(CHAIN_ID_SEPARATOR) ||
chainId2.includes(CHAIN_ID_SEPARATOR)
) {
Fail`invalid chain id ${chainId1} or ${chainId2}`;
}
return [chainId1, chainId2].sort().join(CHAIN_ID_SEPARATOR);
const chainId1Sanitized = sanitizeChainId(chainId1);
const chainId2Sanitized = sanitizeChainId(chainId2);

return [chainId1Sanitized, chainId2Sanitized].sort().join(CHAIN_ID_SEPARATOR);
};

/**
Expand Down
Loading

0 comments on commit 111a842

Please sign in to comment.