-
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.
- split start-send-anywhere.js into proposal and start script so we can pass options - init-send-anywhere.js takes `--chainInfo` and `--assetInfo` options - send-anywhere.contrac.js registers chainInfo and assetInfo from privateArgs in ChainHub
- Loading branch information
1 parent
647e79d
commit 2c1661d
Showing
5 changed files
with
152 additions
and
54 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { makeHelpers } from '@agoric/deploy-script-support'; | ||
import { | ||
getManifest, | ||
startSendAnywhere, | ||
} from '@agoric/orchestration/src/proposals/start-send-anywhere.js'; | ||
import { parseArgs } from 'node:util'; | ||
|
||
/** | ||
* @import {ParseArgsConfig} from 'node:util' | ||
*/ | ||
|
||
const chainInfoUsage = 'use --chainInfo chainName:CosmosChainInfo ...'; | ||
const assetInfoUsage = | ||
'use --assetInfo denom:DenomInfo & {brandKey?: string} ...'; | ||
|
||
/** @type {ParseArgsConfig['options']} */ | ||
const parserOpts = { | ||
chainInfo: { type: 'string' }, | ||
assetInfo: { type: 'string' }, | ||
}; | ||
|
||
/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').CoreEvalBuilder} */ | ||
export const defaultProposalBuilder = async ( | ||
{ publishRef, install }, | ||
options, | ||
) => | ||
harden({ | ||
sourceSpec: '@agoric/orchestration/src/proposals/start-send-anywhere.js', | ||
getManifestCall: [ | ||
getManifest.name, | ||
{ | ||
installationRef: publishRef( | ||
install( | ||
'@agoric/orchestration/src/examples/send-anywhere.contract.js', | ||
), | ||
), | ||
options, | ||
}, | ||
], | ||
}); | ||
|
||
/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').DeployScriptFunction} */ | ||
export default async (homeP, endowments) => { | ||
const { scriptArgs } = endowments; | ||
|
||
const { | ||
values: { chainInfo, assetInfo }, | ||
} = parseArgs({ | ||
args: scriptArgs, | ||
options: parserOpts, | ||
}); | ||
|
||
const parseChainInfo = () => { | ||
if (!chainInfo) throw Error(chainInfoUsage); | ||
if (typeof chainInfo !== 'string') throw Error('chainInfo must be string'); | ||
return JSON.parse(chainInfo); | ||
}; | ||
const parseAssetInfo = () => { | ||
if (!assetInfo) throw Error(assetInfoUsage); | ||
if (typeof assetInfo !== 'string') throw Error('assetInfo must be string'); | ||
return JSON.parse(assetInfo); | ||
}; | ||
const opts = harden({ | ||
chainInfo: parseChainInfo(), | ||
assetInfo: parseAssetInfo(), | ||
}); | ||
|
||
const { writeCoreEval } = await makeHelpers(homeP, endowments); | ||
|
||
await writeCoreEval(startSendAnywhere.name, 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
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