Skip to content

Commit

Permalink
feat: allow dapps to suggest a petname that is forwarded
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Aug 7, 2020
1 parent 8748674 commit 1183a19
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion packages/cosmic-swingset/lib/ag-solo/html/wallet-bridge.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
}
});

// Get the dapp's suggested petname, if there is one.
const sp = new URLSearchParams(location.search);
let suggestedDappPetname = sp.get('suggestedDappPetname');

window.addEventListener('message', ev => {
// console.log('inbound', ev.data);
Expand All @@ -50,6 +53,8 @@
if (origin === undefined) {
// First-come, first-serve.
origin = ev.origin;
// Default the petname, if there isn't a better one.
suggestedDappPetname = suggestedDappPetname || origin;
while (dappQueue.length) {
const dappObj = dappQueue.shift();
if (window.parent !== window) {
Expand All @@ -58,7 +63,11 @@
}
}
// console.debug('from dapp', origin, ev.data);
const obj = { ...ev.data, dappOrigin: origin };
const obj = {
...ev.data,
dappOrigin: origin,
suggestedDappPetname,
};
if (ws.readyState !== ws.OPEN) {
// console.log('queuing', obj);
wsQueue.push(obj);
Expand Down
2 changes: 1 addition & 1 deletion packages/cosmic-swingset/lib/ag-solo/vats/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function stringify(
depth = 0,
) {
if (Object(value) !== value) {
return JSON.stringify(value, spaces);
return JSON.stringify(value, null, spaces);
}

// Identify functions.
Expand Down

0 comments on commit 1183a19

Please sign in to comment.