-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(builders): fast-usdc policy update builder
- use deploy config from fast-usdc package
- Loading branch information
Showing
2 changed files
with
63 additions
and
138 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
packages/builders/scripts/fast-usdc/fast-usdc-update.build.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,61 @@ | ||
import { parseArgs } from 'node:util'; | ||
import { getManifestForUpdateFastUsdcPolicy } from '@agoric/fast-usdc/src/fast-usdc-policy.core.js'; | ||
import { toExternalConfig } from '@agoric/fast-usdc/src/utils/config-marshal.js'; | ||
import { FeedPolicyShape } from '@agoric/fast-usdc/src/type-guards.js'; | ||
import { makeHelpers } from '@agoric/deploy-script-support'; | ||
|
||
/** | ||
* @import {CoreEvalBuilder, DeployScriptFunction} from '@agoric/deploy-script-support/src/externalTypes.js' | ||
* @import {ParseArgsConfig} from 'node:util' | ||
* @import {FastUSDCConfig} from '@agoric/fast-usdc/src/types.js' | ||
*/ | ||
|
||
/** @type {ParseArgsConfig['options']} */ | ||
const options = { | ||
feedPolicy: { type: 'string' }, | ||
}; | ||
const feedPolicyUsage = 'use --feedPolicy <policy> ...'; | ||
|
||
/** | ||
* @typedef {{ | ||
* feedPolicy?: string; | ||
* }} FastUSDCUpdateOpts | ||
*/ | ||
|
||
/** @type {CoreEvalBuilder} */ | ||
export const updateProposalBuilder = async ( | ||
_utils, | ||
/** @type {FastUSDCConfig} */ config, | ||
) => { | ||
return harden({ | ||
sourceSpec: '@agoric/fast-usdc/src/fast-usdc-policy.core.js', | ||
/** @type {[string, Parameters<typeof getManifestForUpdateFastUsdcPolicy>[1]]} */ | ||
getManifestCall: [ | ||
getManifestForUpdateFastUsdcPolicy.name, | ||
{ | ||
options: toExternalConfig( | ||
config, | ||
{}, | ||
harden({ feedPolicy: FeedPolicyShape }), | ||
), | ||
}, | ||
], | ||
}); | ||
}; | ||
|
||
/** @type {DeployScriptFunction} */ | ||
export default async (homeP, endowments) => { | ||
const { writeCoreEval } = await makeHelpers(homeP, endowments); | ||
const { | ||
values: { feedPolicy }, | ||
} = parseArgs({ args: endowments.scriptArgs, options }); | ||
|
||
const parseFeedPolicy = () => { | ||
if (typeof feedPolicy !== 'string') throw Error(feedPolicyUsage); | ||
return JSON.parse(feedPolicy); | ||
}; | ||
const config = harden({ feedPolicy: parseFeedPolicy() }); | ||
await writeCoreEval('eval-fast-usdc-policy-update', utils => | ||
updateProposalBuilder(utils, config), | ||
); | ||
}; |
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