Skip to content

Commit

Permalink
feat: add bech32Prefix?: string to CosmosChainInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
0xpatrickdev committed Oct 31, 2024
1 parent a6b3352 commit cb9e1ee
Show file tree
Hide file tree
Showing 17 changed files with 74 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,55 +14,55 @@ Generated by [AVA](https://avajs.dev).
[
[
'published.agoricNames.chain.agoric',
'{"blockHeight":"0","values":["{\\"body\\":\\"{\\\\\\"chainId\\\\\\":\\\\\\"agoric-3\\\\\\",\\\\\\"icqEnabled\\\\\\":false,\\\\\\"stakingTokens\\\\\\":[{\\\\\\"denom\\\\\\":\\\\\\"ubld\\\\\\"}]}\\",\\"slots\\":[]}"]}',
'{"blockHeight":"0","values":["{\\"body\\":\\"{\\\\\\"bech32Prefix\\\\\\":\\\\\\"agoric\\\\\\",\\\\\\"chainId\\\\\\":\\\\\\"agoric-3\\\\\\",\\\\\\"icqEnabled\\\\\\":false,\\\\\\"stakingTokens\\\\\\":[{\\\\\\"denom\\\\\\":\\\\\\"ubld\\\\\\"}]}\\",\\"slots\\":[]}"]}',
],
[
'published.agoricNames.chain.celestia',
'{"blockHeight":"0","values":["{\\"body\\":\\"{\\\\\\"chainId\\\\\\":\\\\\\"celestia\\\\\\",\\\\\\"icqEnabled\\\\\\":false,\\\\\\"stakingTokens\\\\\\":[{\\\\\\"denom\\\\\\":\\\\\\"utia\\\\\\"}]}\\",\\"slots\\":[]}"]}',
'{"blockHeight":"0","values":["{\\"body\\":\\"{\\\\\\"bech32Prefix\\\\\\":\\\\\\"celestia\\\\\\",\\\\\\"chainId\\\\\\":\\\\\\"celestia\\\\\\",\\\\\\"icqEnabled\\\\\\":false,\\\\\\"stakingTokens\\\\\\":[{\\\\\\"denom\\\\\\":\\\\\\"utia\\\\\\"}]}\\",\\"slots\\":[]}"]}',
],
[
'published.agoricNames.chain.cosmoshub',
'{"blockHeight":"0","values":["{\\"body\\":\\"{\\\\\\"chainId\\\\\\":\\\\\\"cosmoshub-4\\\\\\",\\\\\\"icqEnabled\\\\\\":false,\\\\\\"stakingTokens\\\\\\":[{\\\\\\"denom\\\\\\":\\\\\\"uatom\\\\\\"}]}\\",\\"slots\\":[]}"]}',
'{"blockHeight":"0","values":["{\\"body\\":\\"{\\\\\\"bech32Prefix\\\\\\":\\\\\\"cosmos\\\\\\",\\\\\\"chainId\\\\\\":\\\\\\"cosmoshub-4\\\\\\",\\\\\\"icqEnabled\\\\\\":false,\\\\\\"stakingTokens\\\\\\":[{\\\\\\"denom\\\\\\":\\\\\\"uatom\\\\\\"}]}\\",\\"slots\\":[]}"]}',
],
[
'published.agoricNames.chain.dydx',
'{"blockHeight":"0","values":["{\\"body\\":\\"{\\\\\\"chainId\\\\\\":\\\\\\"dydx-mainnet-1\\\\\\",\\\\\\"icqEnabled\\\\\\":false,\\\\\\"stakingTokens\\\\\\":[{\\\\\\"denom\\\\\\":\\\\\\"adydx\\\\\\"}]}\\",\\"slots\\":[]}"]}',
'{"blockHeight":"0","values":["{\\"body\\":\\"{\\\\\\"bech32Prefix\\\\\\":\\\\\\"dydx\\\\\\",\\\\\\"chainId\\\\\\":\\\\\\"dydx-mainnet-1\\\\\\",\\\\\\"icqEnabled\\\\\\":false,\\\\\\"stakingTokens\\\\\\":[{\\\\\\"denom\\\\\\":\\\\\\"adydx\\\\\\"}]}\\",\\"slots\\":[]}"]}',
],
[
'published.agoricNames.chain.juno',
'{"blockHeight":"0","values":["{\\"body\\":\\"{\\\\\\"chainId\\\\\\":\\\\\\"juno-1\\\\\\",\\\\\\"icqEnabled\\\\\\":false,\\\\\\"stakingTokens\\\\\\":[{\\\\\\"denom\\\\\\":\\\\\\"ujuno\\\\\\"}]}\\",\\"slots\\":[]}"]}',
'{"blockHeight":"0","values":["{\\"body\\":\\"{\\\\\\"bech32Prefix\\\\\\":\\\\\\"juno\\\\\\",\\\\\\"chainId\\\\\\":\\\\\\"juno-1\\\\\\",\\\\\\"icqEnabled\\\\\\":false,\\\\\\"stakingTokens\\\\\\":[{\\\\\\"denom\\\\\\":\\\\\\"ujuno\\\\\\"}]}\\",\\"slots\\":[]}"]}',
],
[
'published.agoricNames.chain.neutron',
'{"blockHeight":"0","values":["{\\"body\\":\\"{\\\\\\"chainId\\\\\\":\\\\\\"neutron-1\\\\\\",\\\\\\"icqEnabled\\\\\\":false,\\\\\\"stakingTokens\\\\\\":[{\\\\\\"denom\\\\\\":\\\\\\"untrn\\\\\\"}]}\\",\\"slots\\":[]}"]}',
'{"blockHeight":"0","values":["{\\"body\\":\\"{\\\\\\"bech32Prefix\\\\\\":\\\\\\"neutron\\\\\\",\\\\\\"chainId\\\\\\":\\\\\\"neutron-1\\\\\\",\\\\\\"icqEnabled\\\\\\":false,\\\\\\"stakingTokens\\\\\\":[{\\\\\\"denom\\\\\\":\\\\\\"untrn\\\\\\"}]}\\",\\"slots\\":[]}"]}',
],
[
'published.agoricNames.chain.noble',
'{"blockHeight":"0","values":["{\\"body\\":\\"{\\\\\\"chainId\\\\\\":\\\\\\"noble-1\\\\\\",\\\\\\"icqEnabled\\\\\\":false}\\",\\"slots\\":[]}"]}',
'{"blockHeight":"0","values":["{\\"body\\":\\"{\\\\\\"bech32Prefix\\\\\\":\\\\\\"noble\\\\\\",\\\\\\"chainId\\\\\\":\\\\\\"noble-1\\\\\\",\\\\\\"icqEnabled\\\\\\":false}\\",\\"slots\\":[]}"]}',
],
[
'published.agoricNames.chain.omniflixhub',
'{"blockHeight":"0","values":["{\\"body\\":\\"{\\\\\\"chainId\\\\\\":\\\\\\"omniflixhub-1\\\\\\",\\\\\\"icqEnabled\\\\\\":false,\\\\\\"stakingTokens\\\\\\":[{\\\\\\"denom\\\\\\":\\\\\\"uflix\\\\\\"}]}\\",\\"slots\\":[]}"]}',
'{"blockHeight":"0","values":["{\\"body\\":\\"{\\\\\\"bech32Prefix\\\\\\":\\\\\\"omniflix\\\\\\",\\\\\\"chainId\\\\\\":\\\\\\"omniflixhub-1\\\\\\",\\\\\\"icqEnabled\\\\\\":false,\\\\\\"stakingTokens\\\\\\":[{\\\\\\"denom\\\\\\":\\\\\\"uflix\\\\\\"}]}\\",\\"slots\\":[]}"]}',
],
[
'published.agoricNames.chain.osmosis',
'{"blockHeight":"0","values":["{\\"body\\":\\"{\\\\\\"chainId\\\\\\":\\\\\\"osmosis-1\\\\\\",\\\\\\"icqEnabled\\\\\\":true,\\\\\\"stakingTokens\\\\\\":[{\\\\\\"denom\\\\\\":\\\\\\"uosmo\\\\\\"}]}\\",\\"slots\\":[]}"]}',
'{"blockHeight":"0","values":["{\\"body\\":\\"{\\\\\\"bech32Prefix\\\\\\":\\\\\\"osmo\\\\\\",\\\\\\"chainId\\\\\\":\\\\\\"osmosis-1\\\\\\",\\\\\\"icqEnabled\\\\\\":true,\\\\\\"stakingTokens\\\\\\":[{\\\\\\"denom\\\\\\":\\\\\\"uosmo\\\\\\"}]}\\",\\"slots\\":[]}"]}',
],
[
'published.agoricNames.chain.secretnetwork',
'{"blockHeight":"0","values":["{\\"body\\":\\"{\\\\\\"chainId\\\\\\":\\\\\\"secret-4\\\\\\",\\\\\\"icqEnabled\\\\\\":false,\\\\\\"stakingTokens\\\\\\":[{\\\\\\"denom\\\\\\":\\\\\\"uscrt\\\\\\"}]}\\",\\"slots\\":[]}"]}',
'{"blockHeight":"0","values":["{\\"body\\":\\"{\\\\\\"bech32Prefix\\\\\\":\\\\\\"secret\\\\\\",\\\\\\"chainId\\\\\\":\\\\\\"secret-4\\\\\\",\\\\\\"icqEnabled\\\\\\":false,\\\\\\"stakingTokens\\\\\\":[{\\\\\\"denom\\\\\\":\\\\\\"uscrt\\\\\\"}]}\\",\\"slots\\":[]}"]}',
],
[
'published.agoricNames.chain.stargaze',
'{"blockHeight":"0","values":["{\\"body\\":\\"{\\\\\\"chainId\\\\\\":\\\\\\"stargaze-1\\\\\\",\\\\\\"icqEnabled\\\\\\":false,\\\\\\"stakingTokens\\\\\\":[{\\\\\\"denom\\\\\\":\\\\\\"ustars\\\\\\"}]}\\",\\"slots\\":[]}"]}',
'{"blockHeight":"0","values":["{\\"body\\":\\"{\\\\\\"bech32Prefix\\\\\\":\\\\\\"stars\\\\\\",\\\\\\"chainId\\\\\\":\\\\\\"stargaze-1\\\\\\",\\\\\\"icqEnabled\\\\\\":false,\\\\\\"stakingTokens\\\\\\":[{\\\\\\"denom\\\\\\":\\\\\\"ustars\\\\\\"}]}\\",\\"slots\\":[]}"]}',
],
[
'published.agoricNames.chain.stride',
'{"blockHeight":"0","values":["{\\"body\\":\\"{\\\\\\"chainId\\\\\\":\\\\\\"stride-1\\\\\\",\\\\\\"icqEnabled\\\\\\":false,\\\\\\"stakingTokens\\\\\\":[{\\\\\\"denom\\\\\\":\\\\\\"ustrd\\\\\\"}]}\\",\\"slots\\":[]}"]}',
'{"blockHeight":"0","values":["{\\"body\\":\\"{\\\\\\"bech32Prefix\\\\\\":\\\\\\"stride\\\\\\",\\\\\\"chainId\\\\\\":\\\\\\"stride-1\\\\\\",\\\\\\"icqEnabled\\\\\\":false,\\\\\\"stakingTokens\\\\\\":[{\\\\\\"denom\\\\\\":\\\\\\"ustrd\\\\\\"}]}\\",\\"slots\\":[]}"]}',
],
[
'published.agoricNames.chain.umee',
'{"blockHeight":"0","values":["{\\"body\\":\\"{\\\\\\"chainId\\\\\\":\\\\\\"umee-1\\\\\\",\\\\\\"icqEnabled\\\\\\":false,\\\\\\"stakingTokens\\\\\\":[{\\\\\\"denom\\\\\\":\\\\\\"uumee\\\\\\"}]}\\",\\"slots\\":[]}"]}',
'{"blockHeight":"0","values":["{\\"body\\":\\"{\\\\\\"bech32Prefix\\\\\\":\\\\\\"umee\\\\\\",\\\\\\"chainId\\\\\\":\\\\\\"umee-1\\\\\\",\\\\\\"icqEnabled\\\\\\":false,\\\\\\"stakingTokens\\\\\\":[{\\\\\\"denom\\\\\\":\\\\\\"uumee\\\\\\"}]}\\",\\"slots\\":[]}"]}',
],
[
'published.agoricNames.chainConnection.agoric-3_cosmoshub-4',
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ Generated by [AVA](https://avajs.dev).
},
},
{
bech32Prefix: Object @match:string {
payload: [],
},
connections: Object @match:recordOf {
payload: [
Object @match:any {
Expand Down
Binary file not shown.
2 changes: 2 additions & 0 deletions packages/orchestration/src/cosmos-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ export interface CosmosAssetInfo extends Record<string, unknown> {
* Info for a Cosmos-based chain.
*/
export type CosmosChainInfo = Readonly<{
/** can be used to lookup chainInfo (chainId) from an address value */
bech32Prefix?: string;
chainId: string;

connections?: Record<string, IBCConnectionInfo>; // chainId or wellKnownName
Expand Down
49 changes: 31 additions & 18 deletions packages/orchestration/src/fetched-chain-info.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/** @file Generated by fetch-chain-info.ts */
export default /** @type {const} } */ ({
agoric: {
bech32Prefix: 'agoric',
chainId: 'agoric-3',
stakingTokens: [
{
Expand Down Expand Up @@ -138,6 +139,7 @@ export default /** @type {const} } */ ({
},
},
celestia: {
bech32Prefix: 'celestia',
chainId: 'celestia',
stakingTokens: [
{
Expand Down Expand Up @@ -239,6 +241,7 @@ export default /** @type {const} } */ ({
},
},
cosmoshub: {
bech32Prefix: 'cosmos',
chainId: 'cosmoshub-4',
stakingTokens: [
{
Expand All @@ -247,24 +250,6 @@ export default /** @type {const} } */ ({
],
icqEnabled: false,
connections: {
'stargaze-1': {
id: 'connection-918',
client_id: '07-tendermint-1188',
counterparty: {
client_id: '07-tendermint-320',
connection_id: 'connection-256',
},
state: 3,
transferChannel: {
channelId: 'channel-730',
portId: 'transfer',
counterPartyChannelId: 'channel-239',
counterPartyPortId: 'transfer',
ordering: 0,
state: 3,
version: 'ics20-1',
},
},
'agoric-3': {
id: 'connection-649',
client_id: '07-tendermint-927',
Expand Down Expand Up @@ -391,6 +376,24 @@ export default /** @type {const} } */ ({
version: 'ics20-1',
},
},
'stargaze-1': {
id: 'connection-918',
client_id: '07-tendermint-1188',
counterparty: {
client_id: '07-tendermint-320',
connection_id: 'connection-256',
},
state: 3,
transferChannel: {
channelId: 'channel-730',
portId: 'transfer',
counterPartyChannelId: 'channel-239',
counterPartyPortId: 'transfer',
ordering: 0,
state: 3,
version: 'ics20-1',
},
},
'stride-1': {
id: 'connection-635',
client_id: '07-tendermint-913',
Expand All @@ -412,6 +415,7 @@ export default /** @type {const} } */ ({
},
},
dydx: {
bech32Prefix: 'dydx',
chainId: 'dydx-mainnet-1',
stakingTokens: [
{
Expand Down Expand Up @@ -513,6 +517,7 @@ export default /** @type {const} } */ ({
},
},
juno: {
bech32Prefix: 'juno',
chainId: 'juno-1',
stakingTokens: [
{
Expand Down Expand Up @@ -650,6 +655,7 @@ export default /** @type {const} } */ ({
},
},
neutron: {
bech32Prefix: 'neutron',
chainId: 'neutron-1',
stakingTokens: [
{
Expand Down Expand Up @@ -823,6 +829,7 @@ export default /** @type {const} } */ ({
},
},
noble: {
bech32Prefix: 'noble',
chainId: 'noble-1',
icqEnabled: false,
connections: {
Expand Down Expand Up @@ -1009,6 +1016,7 @@ export default /** @type {const} } */ ({
},
},
omniflixhub: {
bech32Prefix: 'omniflix',
chainId: 'omniflixhub-1',
stakingTokens: [
{
Expand Down Expand Up @@ -1092,6 +1100,7 @@ export default /** @type {const} } */ ({
},
},
osmosis: {
bech32Prefix: 'osmo',
chainId: 'osmosis-1',
stakingTokens: [
{
Expand Down Expand Up @@ -1319,6 +1328,7 @@ export default /** @type {const} } */ ({
},
},
secretnetwork: {
bech32Prefix: 'secret',
chainId: 'secret-4',
stakingTokens: [
{
Expand Down Expand Up @@ -1510,6 +1520,7 @@ export default /** @type {const} } */ ({
},
},
stargaze: {
bech32Prefix: 'stars',
chainId: 'stargaze-1',
stakingTokens: [
{
Expand Down Expand Up @@ -1665,6 +1676,7 @@ export default /** @type {const} } */ ({
},
},
stride: {
bech32Prefix: 'stride',
chainId: 'stride-1',
stakingTokens: [
{
Expand Down Expand Up @@ -1856,6 +1868,7 @@ export default /** @type {const} } */ ({
},
},
umee: {
bech32Prefix: 'umee',
chainId: 'umee-1',
stakingTokens: [
{
Expand Down
1 change: 1 addition & 0 deletions packages/orchestration/src/typeGuards.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export const CosmosChainInfoShape = M.splitRecord(
chainId: M.string(),
},
{
bech32Prefix: M.string(),
connections: M.record(),
stakingTokens: M.arrayOf({ denom: M.string() }),
// UNTIL https://github.com/Agoric/agoric-sdk/issues/9326
Expand Down
1 change: 1 addition & 0 deletions packages/orchestration/src/utils/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export const convertChainInfo = async registry => {
for (const chain of registry.chains) {
console.log('processing info', chain.chain_name);
chainInfo[chain.chain_name] = {
bech32Prefix: chain.bech32_prefix,
chainId: chain.chain_id,
stakingTokens: chain.staking?.staking_tokens,
// UNTIL https://github.com/Agoric/agoric-sdk/issues/9326
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Generated by [AVA](https://avajs.dev).
brandDenom: {},
chainInfos: {
agoric: {
bech32Prefix: 'agoric',
chainId: 'agoric-3',
icqEnabled: false,
stakingTokens: [
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Generated by [AVA](https://avajs.dev).
},
chainInfos: {
agoric: {
bech32Prefix: 'agoric',
chainId: 'agoric-3',
icqEnabled: false,
stakingTokens: [
Expand All @@ -44,6 +45,7 @@ Generated by [AVA](https://avajs.dev).
],
},
cosmoshub: {
bech32Prefix: 'cosmos',
chainId: 'cosmoshub-4',
icqEnabled: false,
stakingTokens: [
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Generated by [AVA](https://avajs.dev).
brandDenom: {},
chainInfos: {
agoric: {
bech32Prefix: 'agoric',
chainId: 'agoric-3',
icqEnabled: false,
stakingTokens: [
Expand All @@ -42,6 +43,7 @@ Generated by [AVA](https://avajs.dev).
],
},
osmosis: {
bech32Prefix: 'osmo',
chainId: 'osmosis-1',
icqEnabled: true,
stakingTokens: [
Expand All @@ -51,6 +53,7 @@ Generated by [AVA](https://avajs.dev).
],
},
stride: {
bech32Prefix: 'stride',
chainId: 'stride-1',
icqEnabled: false,
stakingTokens: [
Expand Down
Binary file not shown.
7 changes: 4 additions & 3 deletions packages/orchestration/test/exos/chain-hub.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,12 @@ test.serial('getConnectionInfo', async t => {
t.deepEqual(await vt.when(chainHub.getConnectionInfo(b, a)), ba);
});

test('denom info support via getAsset and getDenom', async t => {
test.serial('denom info support via getAsset and getDenom', async t => {
const { chainHub } = setup();

const denom = 'utok1';
const info1: CosmosChainInfo = {
bech32Prefix: 'chain',
chainId: 'chain1',
stakingTokens: [{ denom }],
};
Expand Down Expand Up @@ -139,15 +140,15 @@ test('denom info support via getAsset and getDenom', async t => {
);
});

test('toward asset info in agoricNames (#9572)', async t => {
test.serial('toward asset info in agoricNames (#9572)', async t => {
const { chainHub, nameAdmin, vt } = setup();
// use fetched chain info
await registerKnownChains(nameAdmin);

await vt.when(chainHub.getChainInfo('cosmoshub'));

for (const name of ['kava', 'fxcore']) {
chainHub.registerChain(name, { chainId: name });
chainHub.registerChain(name, { chainId: name, bech32Prefix: name });
}

await registerChainAssets(nameAdmin, 'cosmoshub', assetFixture.cosmoshub);
Expand Down
Loading

0 comments on commit cb9e1ee

Please sign in to comment.