Skip to content

Commit

Permalink
feat: add agoric.priceAuthority via priceAuthorityRegistry
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Oct 31, 2020
1 parent e01c1b0 commit c602d14
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
9 changes: 9 additions & 0 deletions packages/cosmic-swingset/lib/ag-solo/vats/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@ export function buildRootObject(vatPowers, vatParameters) {
chainTimerService,
zoe,
contractHost,
{ priceAuthority, adminFacet: priceAuthorityAdmin },
] = await Promise.all([
E(vats.sharing).getSharingService(),
E(vats.registrar).getSharedRegistrar(),
E(vats.board).getBoard(),
E(vats.timer).createTimerService(timerDevice),
E(vats.zoe).buildZoe(vatAdminSvc),
E(vats.host).makeHost(),
E(vats.priceAuthority).makePriceAuthority(),
]);

// Make the other demo mints
Expand All @@ -61,6 +63,8 @@ export function buildRootObject(vatPowers, vatParameters) {
),
);

// TODO: Create priceAuthority pairs for

// Register the moola and simolean issuers
const issuerInfo = await Promise.all(
issuerNames.map(async (issuerName, i) =>
Expand All @@ -86,6 +90,9 @@ export function buildRootObject(vatPowers, vatParameters) {
// Give the authority to create a new host for vattp to share objects with.
additionalPowers.vattp = makeVattpFrom(vats);
}
if (powerFlags && powerFlags.includes('agoric.priceAuthorityAdmin')) {
additionalPowers.priceAuthorityAdmin = priceAuthorityAdmin;
}

const pursePetnames = {
moola: 'Fun budget',
Expand Down Expand Up @@ -121,6 +128,7 @@ export function buildRootObject(vatPowers, vatParameters) {
contractHost,
faucet,
ibcport,
priceAuthority,
registrar: registry,
registry,
board,
Expand Down Expand Up @@ -365,6 +373,7 @@ export function buildRootObject(vatPowers, vatParameters) {
// to give capabilities to all clients (since we are running
// locally with the `--give-me-all-the-agoric-powers` flag).
return chainBundler.createUserBundle(nickname, [
'agoric.priceAuthorityAdmin',
'agoric.vattp',
]);
}
Expand Down
3 changes: 3 additions & 0 deletions packages/cosmic-swingset/lib/ag-solo/vats/chain-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
"network": {
"sourceSpec": "vat-network.js"
},
"priceAuthority": {
"sourceSpec": "vat-priceAuthority.js"
},
"provisioning": {
"sourceSpec": "vat-provisioning.js"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { makePriceAuthorityRegistry } from '@agoric/zoe/tools/priceAuthorityRegistry';

export function buildRootObject(_vatPowers) {
return harden({
makePriceAuthority: makePriceAuthorityRegistry,
});
}
8 changes: 4 additions & 4 deletions packages/zoe/tools/priceAuthorityRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ export const makePriceAuthorityRegistry = () => {
const record = lookup(brandIn, brandOut);
return E(record.priceAuthority).getTimerService(brandIn, brandOut);
},
async getAmountInQuote(amountIn, brandOut) {
async quoteGiven(amountIn, brandOut) {
const record = lookup(amountIn.brand, brandOut);
return E(record.priceAuthority).getAmountInQuote(amountIn, brandOut);
return E(record.priceAuthority).quoteGiven(amountIn, brandOut);
},
async getAmountOutQuote(brandIn, amountOut) {
async quoteWanted(brandIn, amountOut) {
const record = lookup(brandIn, amountOut.brand);
return E(record.priceAuthority).getAmountOutQuote(brandIn, amountOut);
return E(record.priceAuthority).quoteWanted(brandIn, amountOut);
},
async getPriceNotifier(brandIn, brandOut) {
const record = lookup(brandIn, brandOut);
Expand Down

0 comments on commit c602d14

Please sign in to comment.