Skip to content

Commit

Permalink
fix: syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Jun 10, 2019
1 parent ef71db6 commit 699311e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 14 deletions.
31 changes: 20 additions & 11 deletions lib/ag-solo/vats/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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}`}});
},
});
Expand All @@ -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) {
Expand All @@ -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,
);
}
4 changes: 2 additions & 2 deletions lib/ag-solo/vats/vat-demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ 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;
const chainBundle = { purse, issuer, handoffService };
return harden(chainBundle);
}

return harden({ startup, provisionClient });
return harden({ startup, getChainBundle });
}

export default function setup(syscall, state, helpers) {
Expand Down
10 changes: 9 additions & 1 deletion lib/ag-solo/vats/vat-http.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function stringify(value, spaces) {
}

function build(E, D) {
let commandDevice;
let commandDevice, provisioner;
const command = {};
const history = {};
const homeObjects = {};
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 699311e

Please sign in to comment.