Skip to content

Commit

Permalink
fix: wire through the CapTP bootstrap message
Browse files Browse the repository at this point in the history
This allows handlers (such as the wallet) to examine any
additional properties on the CTP_BOOTSTRAP message (such
as the dappOrigin).  Useful to have sometimes.
  • Loading branch information
michaelfig committed Jan 9, 2021
1 parent 0dde1bc commit 7af41bc
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/captp/lib/captp.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ export function makeCapTP(ourId, rawSend, bootstrapObj = undefined, opts = {}) {
async CTP_BOOTSTRAP(obj) {
const { questionID } = obj;
const bootstrap =
typeof bootstrapObj === 'function' ? bootstrapObj() : bootstrapObj;
typeof bootstrapObj === 'function' ? bootstrapObj(obj) : bootstrapObj;
E.when(bootstrap, bs => {
// console.log('sending bootstrap', bootstrap);
answers.set(questionID, bs);
Expand Down
2 changes: 1 addition & 1 deletion packages/cosmic-swingset/lib/ag-solo/vats/captp.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const getCapTPHandler = (
const { dispatch, abort, getBootstrap: getRemoteBootstrap } = makeCapTP(
origin,
sendObj,
async () => getLocalBootstrap(getRemoteBootstrap(), meta),
async o => getLocalBootstrap(getRemoteBootstrap(), meta, o),
{
onReject(err) {
// Be quieter for sanity's sake.
Expand Down
4 changes: 2 additions & 2 deletions packages/cosmic-swingset/lib/ag-solo/vats/vat-http.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ export function buildRootObject(vatPowers) {
.catch(_ => undefined);
const commandHandler = getCapTPHandler(
send,
(otherSide, meta) =>
(otherSide, meta, obj) =>
E(handler)
.getBootstrap(otherSide, meta)
.getBootstrap(otherSide, meta, obj)
.catch(_e => undefined),
fallback,
);
Expand Down
5 changes: 3 additions & 2 deletions packages/dapp-svelte-wallet/api/src/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,10 @@ export function buildRootObject(_vatPowers) {
*
* @param {ERef<WalletOtherSide>} otherSide
* @param {Record<string, any>} meta
* @param {Record<string, any>} obj
*/
async getBootstrap(otherSide, meta) {
const dappOrigin = meta.origin;
async getBootstrap(otherSide, meta, obj) {
const { dappOrigin = meta.origin } = obj;
const suggestedDappPetname = String(
(meta.query && meta.query.suggestedDappPetname) ||
meta.dappOrigin ||
Expand Down

0 comments on commit 7af41bc

Please sign in to comment.