From 699311efcf74b838b9a86cc451843b2faed8ec6e Mon Sep 17 00:00:00 2001 From: Michael FIG Date: Mon, 10 Jun 2019 14:42:31 -0600 Subject: [PATCH] fix: syntax --- lib/ag-solo/vats/bootstrap.js | 31 ++++++++++++++++++++----------- lib/ag-solo/vats/vat-demo.js | 4 ++-- lib/ag-solo/vats/vat-http.js | 10 +++++++++- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/lib/ag-solo/vats/bootstrap.js b/lib/ag-solo/vats/bootstrap.js index 9679e58d06c..18c79689f23 100644 --- a/lib/ag-solo/vats/bootstrap.js +++ b/lib/ag-solo/vats/bootstrap.js @@ -6,18 +6,18 @@ import { GCI, IS_CONTROLLER } from './gci'; console.log(`loading bootstrap.js`); -// TODO: Any wiring necessary to make the demo work. -async function startDemo(vats) { - await E(vats.demo).startup(vats.mint); - return vats.demo; -} - export default function setup(syscall, state, helpers) { return helpers.makeLiveSlots( syscall, state, - (E, D) => - harden({ + (E, D) => { + // TODO: Any wiring necessary to make the demo work. + async function startDemo(vats) { + await E(vats.demo).startup(vats.mint); + return vats.demo; + } + + return harden({ async bootstrap(argv, vats, devices) { console.log('bootstrap() called'); D(devices.mailbox).registerInboundHandler(vats.vattp); @@ -29,7 +29,7 @@ export default function setup(syscall, state, helpers) { // FIXME: Need to request the 'demo' vat from the chain, not locally. // TODO(mfig): this will be generic. demoVat = harden({ - provisionClient(nickname) { + getChainBundle(nickname) { return harden({hello() {return `FIXME: Hello, ${nickname}`}}); }, }); @@ -39,7 +39,7 @@ export default function setup(syscall, state, helpers) { } const fetch = harden({ - getChainBundle(nickname) { return E(demoVat).provisionClient(nickname); }, + getChainBundle(nickname) { return E(demoVat).getChainBundle(nickname); }, }); if (vats.http) { @@ -64,9 +64,18 @@ export default function setup(syscall, state, helpers) { // 'provisioning' vat lives in all solo instances, including the controller. await E(vats.provisioning).register(demoVat, vats.comms); await E(vats.provisioning).registerHTTP(vats.http); + + const provisioner = harden({ + pleaseProvision(nickname, pubkey) { + return E(vats.provisioning).pleaseProvision(nickname, pubkey); + }, + }); + // Allow access from HTTP to the provisioner. + await E(vats.http).setProvisioner(provisioner); } }, - }), + }); + }, helpers.vatID, ); } diff --git a/lib/ag-solo/vats/vat-demo.js b/lib/ag-solo/vats/vat-demo.js index a445a60013c..33cca9f5778 100644 --- a/lib/ag-solo/vats/vat-demo.js +++ b/lib/ag-solo/vats/vat-demo.js @@ -28,7 +28,7 @@ function build(E) { sharedHandoffService = makeHandoffService(); } - async function provisionClient(nickname) { + async function getChainBundle(nickname) { const purse = E(sharedMint).mint(100); const issuer = sharedIssuer; const handoffService = sharedHandoffService; @@ -36,7 +36,7 @@ function build(E) { return harden(chainBundle); } - return harden({ startup, provisionClient }); + return harden({ startup, getChainBundle }); } export default function setup(syscall, state, helpers) { diff --git a/lib/ag-solo/vats/vat-http.js b/lib/ag-solo/vats/vat-http.js index a954ac647fb..fedcc90b769 100644 --- a/lib/ag-solo/vats/vat-http.js +++ b/lib/ag-solo/vats/vat-http.js @@ -40,7 +40,7 @@ function stringify(value, spaces) { } function build(E, D) { - let commandDevice; + let commandDevice, provisioner; const command = {}; const history = {}; const homeObjects = {}; @@ -63,6 +63,10 @@ function build(E, D) { return { highestHistory }; }, + pleaseProvision(nickname, pubkey) { + return E(provisioner).pleaseProvision(nickname, pubkey); + }, + doEval(obj) { const { number: histnum, body } = obj; //console.log(`doEval`, histnum, body); @@ -102,6 +106,10 @@ function build(E, D) { commandDevice = d; }, + setProvisioner(p) { + provisioner = p; + }, + async registerFetch(fetch) { const chainBundle = await E(fetch).getChainBundle(); Object.assign(homeObjects, chainBundle);