Skip to content

Commit aa06324

Browse files
authored
feat(portfolio-contract): resolve USDC issuer/brand (#11628)
refs: - https://github.com/Agoric/agoric-private/issues/346 ## Description / Upgrade Considerations resolve USDC issuer/brand in bootstrap promise space, which was not done 2023-11 in [#59](https://ping.pub/agoric/gov/59) when the USDC issuer was established. ### Security / Scaling Considerations nothing new ### Documentation Considerations presumes documentation suitable for proposal to stakers is forthcoming ### Testing Considerations A PR stacked on this one should build an a3p-integration test using [fetchCoreEvalRelease](https://github.com/Agoric/agoric-sdk/blob/master/packages/boot/tools/supports.ts#L966) and [evalReleasedProposal](https://github.com/Agoric/agoric-sdk/blob/master/packages/fast-usdc-deploy/test/walletFactory.ts) expanded to handle multiple evals as in 100. cc @LuqiPan
2 parents 1feb156 + d815b4f commit aa06324

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/**
2+
* @file resolve USDC issuer/brand in bootstrap promise space,
3+
* which was not done in #59 when the USDC issuer was established.
4+
*
5+
* This is a combined builder and core eval.
6+
*
7+
* @see resolveUSDC
8+
* @see {@link https://ping.pub/agoric/gov/59 59. Start USDC (Noble) PSM} 2023-11-01
9+
*/
10+
import { E } from '@endo/eventual-send';
11+
import { makeTracer } from '@agoric/internal/src/debug.js';
12+
13+
/**
14+
* @import {BootstrapManifestPermit} from '@agoric/vats/src/core/lib-boot';
15+
* @import {DeployScriptFunction, CoreEvalBuilder} from '@agoric/deploy-script-support/src/externalTypes.js';
16+
*/
17+
18+
const trace = makeTracer('USDC-R');
19+
20+
/**
21+
* XXX: should add this to BootstrapPowers
22+
*
23+
* @typedef {{
24+
* issuer: PromiseSpaceOf<{USDC: Issuer<'nat'>}>,
25+
* brand: PromiseSpaceOf<{USDC: Brand<'nat'>}>,
26+
* }} USDCResolvePowers
27+
*/
28+
29+
/** @param {BootstrapPowers & USDCResolvePowers} permitted */
30+
export const resolveUSDC = async permitted => {
31+
trace('resolveUSDC...');
32+
const { agoricNames } = permitted.consume;
33+
34+
/** @type {Promise<Issuer<'nat'>>} */
35+
const issuerP = E(agoricNames).lookup('issuer', 'USDC');
36+
const [issuer, brand] = await Promise.all([issuerP, E(issuerP).getBrand()]);
37+
38+
const { USDC: produceIssuer } = permitted.issuer.produce;
39+
const { USDC: produceBrand } = permitted.brand.produce;
40+
41+
produceIssuer.resolve(issuer);
42+
produceBrand.resolve(brand);
43+
44+
trace('... resolveUSDC done', { issuer, brand });
45+
};
46+
47+
export const getManifestForResolveUSDC = _utils => {
48+
return {
49+
manifest: {
50+
/** @type {BootstrapManifestPermit} */
51+
[resolveUSDC.name]: {
52+
consume: { agoricNames: true },
53+
issuer: { produce: { USDC: true } },
54+
brand: { produce: { USDC: true } },
55+
},
56+
},
57+
};
58+
};
59+
60+
/** @type {CoreEvalBuilder} */
61+
export const defaultProposalBuilder = async _utils =>
62+
harden({
63+
// Somewhat unorthodox, source the exports from this builder module
64+
sourceSpec: './usdc-resolve.build.js',
65+
getManifestCall: [getManifestForResolveUSDC.name],
66+
});
67+
68+
/** @type {DeployScriptFunction} */
69+
export default async (homeP, endowments) => {
70+
// import dynamically so the module can work in CoreEval environment
71+
const dspModule = await import('@agoric/deploy-script-support');
72+
const { makeHelpers } = dspModule;
73+
const { writeCoreEval } = await makeHelpers(homeP, endowments);
74+
await writeCoreEval('eval-usdc-resolve', defaultProposalBuilder);
75+
};

0 commit comments

Comments
 (0)