Skip to content

Commit

Permalink
feat(vats): put RUN, BLD issuer, brand in agoricNames
Browse files Browse the repository at this point in the history
  • Loading branch information
dckc authored and michaelfig committed Jan 26, 2022
1 parent ee4e2fb commit 3c9eef2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
6 changes: 2 additions & 4 deletions packages/vats/decentral-core-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,8 @@
},
"makeBLDKit": {
"consume": {
"bankManager": true
},
"produce": {
"BLDKit": true
"bankManager": true,
"nameAdmins": true
}
}
}
Expand Down
26 changes: 16 additions & 10 deletions packages/vats/src/core/behaviors.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ const makeVatsFromBundles = ({
* consume: {
* vatAdminSvc: ERef<VatAdminSvc>,
* loadVat: ERef<VatLoader<ZoeVat>>,
* nameAdmins: ERef<Record<string, NameAdmin>>,
* client: ERef<ClientConfig>
* },
* produce: { zoe: Producer<ZoeService>, feeMintAccess: Producer<FeeMintAccess> },
Expand All @@ -92,14 +93,19 @@ const makeVatsFromBundles = ({
* @typedef {ERef<ReturnType<import('../vat-zoe.js').buildRootObject>>} ZoeVat
*/
const buildZoe = async ({
consume: { vatAdminSvc, loadVat, client },
consume: { vatAdminSvc, loadVat, client, nameAdmins },
produce: { zoe, feeMintAccess },
}) => {
const { zoeService, feeMintAccess: fma } = await E(
E(loadVat)('zoe'),
).buildZoe(vatAdminSvc, feeIssuerConfig);

zoe.resolve(zoeService);
const runIssuer = await E(zoeService).getFeeIssuer();
const runBrand = await E(runIssuer).getBrand();
E(E(nameAdmins).get('issuer')).update('RUN', runIssuer);
E(E(nameAdmins).get('brand')).update('RUN', runBrand);

feeMintAccess.resolve(fma);
E(client).assignBundle({ zoe: _addr => zoeService });
};
Expand Down Expand Up @@ -158,6 +164,9 @@ const makeAddressNameHubs = async ({ consume: { client }, produce }) => {
if (nm === 'uiConfig') {
// Reserve the Vault Factory's config until we've populated it.
nameAdmin.reserve('vaultFactory');
} else if (['issuer', 'brand'].includes(nm)) {
nameAdmin.reserve('BLD');
nameAdmin.reserve('RUN');
}
},
),
Expand Down Expand Up @@ -254,24 +263,21 @@ const makeClientBanks = async ({
/**
* @param {{
* consume: {
* bankManager: Promise<BankManager>
* bankManager: Promise<BankManager>,
* nameAdmins: Promise<Record<string, NameAdmin>>,
* },
* produce: {
* BLDKit: Producer<{ brand: Brand, issuer: Issuer }>
* }
* }} powers
* @typedef {*} BankManager // TODO
*/
const makeBLDKit = async ({
consume: { bankManager },
produce: { BLDKit },
}) => {
const makeBLDKit = async ({ consume: { bankManager, nameAdmins } }) => {
const [issuerName, { bankDenom, bankPurse, issuerArgs }] = BLD_ISSUER_ENTRY;
assert(issuerArgs);
const kit = makeIssuerKit(issuerName, ...issuerArgs); // TODO: should this live in another vat???
await E(bankManager).addAsset(bankDenom, issuerName, bankPurse, kit);
// How to be clear that this "kit" has no mint? Do we have a name for brand and issuer?
const { brand, issuer } = kit;
BLDKit.resolve({ brand, issuer });
E(E(nameAdmins).get('issuer')).update('BLD', issuer);
E(E(nameAdmins).get('brand')).update('BLD', brand);
};

/**
Expand Down

0 comments on commit 3c9eef2

Please sign in to comment.