-
Notifications
You must be signed in to change notification settings - Fork 207
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
f59c735
commit d6db026
Showing
5 changed files
with
146 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,67 @@ | ||
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' | ||
*/ | ||
|
||
/** @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 (typeof chainInfo !== 'string') return undefined; | ||
return JSON.parse(chainInfo); | ||
}; | ||
const parseAssetInfo = () => { | ||
if (typeof assetInfo !== 'string') return undefined; | ||
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