Skip to content

Commit

Permalink
feat: chain-capabilities.js constants
Browse files Browse the repository at this point in the history
- adds `IcqEnabled` and `PfmEnabled` constants to support `CosmosChainInfo`
- this data is not available via a well-known registry like cosmos/chain-registry,
  but necessary for the Orchestration API
- exports `withChainCapabilities` helper so consumers can include this data with fetched-chain-info.js
  • Loading branch information
0xpatrickdev committed Nov 26, 2024
1 parent e1c35da commit 52ff70a
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -544,5 +544,6 @@ Generated by [AVA](https://avajs.dev).
denomHash: Function denomHash {},
prepareChainHubAdmin: Function prepareChainHubAdmin {},
prepareCosmosInterchainService: Function prepareCosmosInterchainService {},
withChainCapabilities: Function withChainCapabilities {},
withOrchestration: Function withOrchestration {},
}
Binary file not shown.
1 change: 1 addition & 0 deletions packages/orchestration/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ export * from './src/typeGuards.js';
export * from './src/utils/denomHash.js';

export { withOrchestration } from './src/utils/start-helper.js';
export { withChainCapabilities } from './src/chain-capabilities.js';
60 changes: 60 additions & 0 deletions packages/orchestration/src/chain-capabilities.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* @file Contains ChainInfo that not available from a well-known chain registry.
*/

import { objectMap } from '@endo/patterns';

/** @import {CosmosChainInfo, KnownChains} from '@agoric/orchestration'; */

/**
* Chains with the async-icq (icq-1) module available.
*
* @satisfies {Partial<Record<keyof KnownChains, boolean>>}
*/
const IcqEnabled = /** @type {const} */ ({
omniflixhub: true,
osmosis: true,
});
harden(IcqEnabled);

/**
* Chains with the packet-forward-middleware module available.
*
* @satisfies {Partial<Record<keyof KnownChains, boolean>>}
*/
const PfmEnabled = /** @type {const} */ ({
agoric: true,
celestia: true,
cosmoshub: true,
juno: true,
neutron: true,
noble: true,
omniflixhub: true,
osmosis: true,
secretnetwork: true,
stargaze: true,
stride: true,
umee: true,
});
harden(PfmEnabled);

/**
* @param {Record<string, CosmosChainInfo>} chainInfo
* @param {{
* PfmEnabled: Record<string, boolean>;
* IcqEnabled: Record<string, boolean>;
* }} [opts]
*/
export const withChainCapabilities = (
chainInfo,
opts = {
PfmEnabled,
IcqEnabled,
},
) => {
return objectMap(chainInfo, (info, name) => ({
...info,
pfmEnabled: !!opts.PfmEnabled[name],
icqEnabled: !!opts.IcqEnabled[name],
}));
};

0 comments on commit 52ff70a

Please sign in to comment.