-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: register interchain bank assets proposal
- create `register-interchain-bank-assets.js` for multichain-testing environment - allow users to submit offers using new brands like OSMO, ION - override existing brands like ATOM (ibc/toyatom) with starship denom - create `make-bank-asset-info.ts` to gather `InterchainAssetOptions` from starship env - update `make start` and ci `multichain-e2e-template.yaml` to call these scripts - deploy-cli.ts `deployBuilder` accepts `builderOpts`
- Loading branch information
1 parent
ce195ab
commit 0e20707
Showing
14 changed files
with
359 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/env -S node --import ts-blank-space/register | ||
/* eslint-env node */ | ||
|
||
import '@endo/init'; | ||
import starshipChainInfo from '../starship-chain-info.js'; | ||
import { makeAssetInfo } from '../tools/asset-info.ts'; | ||
|
||
const main = () => { | ||
if (!starshipChainInfo) { | ||
throw new Error( | ||
'starshipChainInfo not found. run `./scripts/fetch-starship-chain-info.ts` first.', | ||
); | ||
} | ||
|
||
const assetInfo = makeAssetInfo(starshipChainInfo) | ||
.filter( | ||
([_, { chainName, baseName }]) => | ||
chainName === 'agoric' && baseName !== 'agoric', | ||
) | ||
.map(([denom, { baseDenom }]) => ({ | ||
denom, | ||
issuerName: baseDenom.replace(/^u/, '').toUpperCase(), | ||
decimalPlaces: 6, // TODO do not assume 6 | ||
})); | ||
|
||
// Directly output JSON string for proposal builder options | ||
process.stdout.write(JSON.stringify(assetInfo)); | ||
}; | ||
|
||
main(); |
51 changes: 51 additions & 0 deletions
51
multichain-testing/src/register-interchain-bank-assets.builder.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* global harden */ | ||
/// <reference types="ses" /> | ||
import { makeHelpers } from '@agoric/deploy-script-support'; | ||
import { parseArgs } from 'node:util'; | ||
|
||
/** | ||
* @import {ParseArgsConfig} from 'node:util'; | ||
* @import {CoreEvalBuilder, DeployScriptFunction} from '@agoric/deploy-script-support/src/externalTypes.js'; | ||
*/ | ||
|
||
/** @type {ParseArgsConfig['options']} */ | ||
const parserOpts = { | ||
assets: { type: 'string' }, | ||
}; | ||
|
||
/** @type {CoreEvalBuilder} */ | ||
export const defaultProposalBuilder = async (_, options) => { | ||
return harden({ | ||
sourceSpec: | ||
'@agoric/builders/scripts/testing/register-interchain-bank-assets.js', | ||
getManifestCall: ['getManifestCall', options], | ||
}); | ||
}; | ||
|
||
/** @type {DeployScriptFunction} */ | ||
export default async (homeP, endowments) => { | ||
const { scriptArgs } = endowments; | ||
|
||
const { | ||
values: { assets }, | ||
} = parseArgs({ | ||
args: scriptArgs, | ||
options: parserOpts, | ||
}); | ||
|
||
const parseAssets = () => { | ||
if (typeof assets !== 'string') { | ||
throw Error( | ||
'must provide --assets=JSON.stringify({ denom: Denom; issuerName: string; decimalPlaces: number; }[])', | ||
); | ||
} | ||
return JSON.parse(assets); | ||
}; | ||
|
||
const opts = harden({ assets: parseAssets() }); | ||
|
||
const { writeCoreEval } = await makeHelpers(homeP, endowments); | ||
await writeCoreEval('eval-register-interchain-bank-assets', utils => | ||
defaultProposalBuilder(utils, opts), | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
multichain-testing/test/scripts/make-bank-asset-info.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import test from 'ava'; | ||
import { execFileSync } from 'node:child_process'; | ||
|
||
test('make-bank-asset-info', async t => { | ||
const stdout = execFileSync('./scripts/make-bank-asset-info.ts', { | ||
encoding: 'utf8', | ||
}); | ||
|
||
const assetInfo = JSON.parse(stdout); | ||
|
||
t.like(assetInfo, [ | ||
{ | ||
issuerName: 'ATOM', | ||
decimalPlaces: 6, | ||
}, | ||
{ | ||
issuerName: 'OSMO', | ||
decimalPlaces: 6, | ||
}, | ||
{ | ||
issuerName: 'ION', | ||
decimalPlaces: 6, | ||
}, | ||
]); | ||
|
||
for (const { denom } of assetInfo) { | ||
t.regex(denom, /^ibc\//); | ||
t.is(denom.length, 68); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
{ | ||
"extends": "../tsconfig.json", | ||
"include": [ | ||
"src", | ||
"tools", | ||
"test" | ||
], | ||
|
Oops, something went wrong.