Skip to content

Commit

Permalink
feat(vats): boostrap-core connects vattp<->mailbox (WIP)
Browse files Browse the repository at this point in the history
REGRESSION: bootstrap.js is skipped!

 - provide bootstrap() method per swingset
 - avoid: deliverInboundMessages before registerInboundHandler

 - refactor(vats): factor out connectVattpWithMailbox
  • Loading branch information
dckc authored and michaelfig committed Jan 16, 2022
1 parent f0f3a75 commit 2be2939
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/vats/decentral-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
}
},
"bootstrap": {
"sourceSpec": "./src/bootstrap.js"
"sourceSpec": "./src/bootstrap-core.js"
}
}
}
43 changes: 43 additions & 0 deletions packages/vats/src/bootstrap-core.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// @ts-check
import { E, Far } from '@agoric/far';

/**
* @typedef { import('@agoric/eventual-send').EProxy } EProxy
* @typedef { ReturnType<typeof
* import('@agoric/swingset-vat/src/devices/mailbox-src.js').buildRootDeviceNode> } MailboxDevice
* @typedef { ReturnType<typeof
* import('@agoric/swingset-vat/src/vats/vat-tp.js').buildRootObject> } VattpVat
*/

/**
* Build root object of the bootstrap vat.
*
* @param {{
* D: EProxy // approximately
* }} vatPowers
* @param {Record<string, unknown>} _vatParameters
*/
export function buildRootObject(vatPowers, _vatParameters) {
const { D } = vatPowers;

/**
* @param {VattpVat} vattp
* @param {MailboxDevice} mailbox
*/
const connectVattpWithMailbox = async (vattp, mailbox) => {
D(mailbox).registerInboundHandler(vattp);
await E(vattp).registerMailboxDevice(mailbox);
};

return Far('bootstrap', {
/**
* Bootstrap vats and devices.
*
* @param {{vattp: VattpVat }} vats
* @param {{mailbox: MailboxDevice}} devices
*/
bootstrap: async (vats, devices) => {
await connectVattpWithMailbox(vats.vattp, devices.mailbox);
},
});
}

0 comments on commit 2be2939

Please sign in to comment.