From 90e8ce16d9d9875330d4a5a3f3d9f59e1faf6ea2 Mon Sep 17 00:00:00 2001 From: Patrick Cooney Date: Tue, 22 Aug 2023 11:28:25 -0400 Subject: [PATCH] fix(addAssetToVault): support issuerName separate from keyword agoric/agoric-sdk#8229 - @dckc --- .../src/proposals/addAssetToVault.js | 51 +++++++++++-------- packages/vats/src/core/utils.js | 1 + packages/vats/src/mintHolder.js | 2 + 3 files changed, 34 insertions(+), 20 deletions(-) diff --git a/packages/inter-protocol/src/proposals/addAssetToVault.js b/packages/inter-protocol/src/proposals/addAssetToVault.js index 3b632b27f92..9bda811c25d 100644 --- a/packages/inter-protocol/src/proposals/addAssetToVault.js +++ b/packages/inter-protocol/src/proposals/addAssetToVault.js @@ -16,8 +16,9 @@ export * from './startPSM.js'; * @property {string} [issuerBoardId] * @property {string} [denom] * @property {number} [decimalPlaces] - * @property {string} [proposedName] + * @property {string} proposedName * @property {string} keyword + * @property {string} [issuerName] * @property {string} oracleBrand * @property {number} [initialPrice] */ @@ -32,18 +33,22 @@ export const publishInterchainAssetFromBoardId = async ( { consume: { board, agoricNamesAdmin } }, { options: { interchainAssetOptions } }, ) => { - const { issuerBoardId, keyword } = interchainAssetOptions; + const { + issuerBoardId, + keyword, + issuerName = keyword, + } = interchainAssetOptions; // Incompatible with denom. assert.equal(interchainAssetOptions.denom, undefined); assert.typeof(issuerBoardId, 'string'); - assert.typeof(keyword, 'string'); + assert.typeof(issuerName, 'string'); const issuer = await E(board).getValue(issuerBoardId); const brand = await E(issuer).getBrand(); return Promise.all([ - E(E(agoricNamesAdmin).lookupAdmin('issuer')).update(keyword, issuer), - E(E(agoricNamesAdmin).lookupAdmin('brand')).update(keyword, brand), + E(E(agoricNamesAdmin).lookupAdmin('issuer')).update(issuerName, issuer), + E(E(agoricNamesAdmin).lookupAdmin('brand')).update(issuerName, brand), ]); }; @@ -62,18 +67,23 @@ export const publishInterchainAssetFromBank = async ( }, { options: { interchainAssetOptions } }, ) => { - const { denom, decimalPlaces, proposedName, keyword } = - interchainAssetOptions; + const { + denom, + decimalPlaces, + keyword, + issuerName = keyword, + proposedName, + } = interchainAssetOptions; // Incompatible with issuerBoardId. assert.equal(interchainAssetOptions.issuerBoardId, undefined); assert.typeof(denom, 'string'); - assert.typeof(keyword, 'string'); - assert.typeof(decimalPlaces, 'number'); + assert.typeof(issuerName, 'string'); assert.typeof(proposedName, 'string'); + assert.typeof(decimalPlaces, 'number'); const terms = { - keyword, + keyword: issuerName, // "keyword" is a misnomer in mintHolder terms assetKind: AssetKind.NAT, displayInfo: { decimalPlaces, @@ -83,7 +93,7 @@ export const publishInterchainAssetFromBank = async ( const { creatorFacet: mint, publicFacet: issuer } = await E(startUpgradable)({ installation: mintHolder, - label: keyword, + label: issuerName, privateArgs: undefined, terms, }); @@ -94,9 +104,9 @@ export const publishInterchainAssetFromBank = async ( await E(E.get(reserveKit).creatorFacet).addIssuer(issuer, keyword); await Promise.all([ - E(E(agoricNamesAdmin).lookupAdmin('issuer')).update(keyword, issuer), - E(E(agoricNamesAdmin).lookupAdmin('brand')).update(keyword, brand), - E(bankManager).addAsset(denom, keyword, proposedName, kit), + E(E(agoricNamesAdmin).lookupAdmin('issuer')).update(issuerName, issuer), + E(E(agoricNamesAdmin).lookupAdmin('brand')).update(issuerName, brand), + E(bankManager).addAsset(denom, issuerName, proposedName, kit), ]); }; @@ -118,11 +128,12 @@ export const registerScaledPriceAuthority = async ( { options: { interchainAssetOptions } }, ) => { const { - keyword, + keyword: kwd, + issuerName = kwd, oracleBrand, initialPrice: initialPriceRaw, } = interchainAssetOptions; - assert.typeof(keyword, 'string'); + assert.typeof(issuerName, 'string'); assert.typeof(oracleBrand, 'string'); const [ @@ -133,7 +144,7 @@ export const registerScaledPriceAuthority = async ( ] = await Promise.all([ priceAuthority, reserveThenGetNames(E(agoricNamesAdmin).lookupAdmin('brand'), [ - keyword, + issuerName, 'IST', ]), reserveThenGetNames(E(agoricNamesAdmin).lookupAdmin('oracleBrand'), [ @@ -191,7 +202,7 @@ export const registerScaledPriceAuthority = async ( const spaKit = await E(startUpgradable)({ installation: scaledPriceAuthority, - label: `scaledPriceAuthority-${keyword}`, + label: `scaledPriceAuthority-${issuerName}`, terms, }); @@ -233,8 +244,8 @@ export const addAssetToVault = async ( }, }, ) => { - const { keyword, oracleBrand } = interchainAssetOptions; - assert.typeof(keyword, 'string'); + const { keyword, issuerName = keyword, oracleBrand } = interchainAssetOptions; + assert.typeof(issuerName, 'string'); assert.typeof(oracleBrand, 'string'); const [interchainIssuer] = await reserveThenGetNames( E(agoricNamesAdmin).lookupAdmin('issuer'), diff --git a/packages/vats/src/core/utils.js b/packages/vats/src/core/utils.js index 7f66592f697..60a38cac888 100644 --- a/packages/vats/src/core/utils.js +++ b/packages/vats/src/core/utils.js @@ -54,6 +54,7 @@ export const agoricNamesReserved = harden({ psm: 'Parity Stability Module', econCommitteeCharter: 'Charter for Econ Governance questions', priceAggregator: 'simple price aggregator', + scaledPriceAuthority: 'scaled price authority', }, instance: { economicCommittee: 'Economic Committee', diff --git a/packages/vats/src/mintHolder.js b/packages/vats/src/mintHolder.js index 0529d3f16e0..27880481009 100644 --- a/packages/vats/src/mintHolder.js +++ b/packages/vats/src/mintHolder.js @@ -10,6 +10,8 @@ import { /** @typedef {import('@agoric/vat-data').Baggage} Baggage */ /** + * NOTE: "keyword" connotes initial caps constraint, which doesn't apply here. + * * @template {AssetKind} K * @typedef {{ * keyword: string;