Skip to content

Commit 7af41bc

Browse files
committed
fix: wire through the CapTP bootstrap message
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.
1 parent 0dde1bc commit 7af41bc

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

packages/captp/lib/captp.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ export function makeCapTP(ourId, rawSend, bootstrapObj = undefined, opts = {}) {
259259
async CTP_BOOTSTRAP(obj) {
260260
const { questionID } = obj;
261261
const bootstrap =
262-
typeof bootstrapObj === 'function' ? bootstrapObj() : bootstrapObj;
262+
typeof bootstrapObj === 'function' ? bootstrapObj(obj) : bootstrapObj;
263263
E.when(bootstrap, bs => {
264264
// console.log('sending bootstrap', bootstrap);
265265
answers.set(questionID, bs);

packages/cosmic-swingset/lib/ag-solo/vats/captp.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const getCapTPHandler = (
2525
const { dispatch, abort, getBootstrap: getRemoteBootstrap } = makeCapTP(
2626
origin,
2727
sendObj,
28-
async () => getLocalBootstrap(getRemoteBootstrap(), meta),
28+
async o => getLocalBootstrap(getRemoteBootstrap(), meta, o),
2929
{
3030
onReject(err) {
3131
// Be quieter for sanity's sake.

packages/cosmic-swingset/lib/ag-solo/vats/vat-http.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ export function buildRootObject(vatPowers) {
6161
.catch(_ => undefined);
6262
const commandHandler = getCapTPHandler(
6363
send,
64-
(otherSide, meta) =>
64+
(otherSide, meta, obj) =>
6565
E(handler)
66-
.getBootstrap(otherSide, meta)
66+
.getBootstrap(otherSide, meta, obj)
6767
.catch(_e => undefined),
6868
fallback,
6969
);

packages/dapp-svelte-wallet/api/src/wallet.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,10 @@ export function buildRootObject(_vatPowers) {
290290
*
291291
* @param {ERef<WalletOtherSide>} otherSide
292292
* @param {Record<string, any>} meta
293+
* @param {Record<string, any>} obj
293294
*/
294-
async getBootstrap(otherSide, meta) {
295-
const dappOrigin = meta.origin;
295+
async getBootstrap(otherSide, meta, obj) {
296+
const { dappOrigin = meta.origin } = obj;
296297
const suggestedDappPetname = String(
297298
(meta.query && meta.query.suggestedDappPetname) ||
298299
meta.dappOrigin ||

0 commit comments

Comments
 (0)