Skip to content

Commit

Permalink
fix 'sign' method in Chrome extension context (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulBernier authored Apr 12, 2021
1 parent cf67838 commit 543a0a8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion extension/src/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Sollet",
"description": "Solana SPL Token Wallet",
"version": "0.2.4",
"version": "0.2.5",
"browser_action": {
"default_popup": "index.html",
"default_title": "Open the popup"
Expand Down
18 changes: 17 additions & 1 deletion src/pages/PopupPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,23 @@ function getInitialRequests() {
// TODO CHECK OPENER (?)

const urlParams = new URLSearchParams(window.location.hash.slice(1));
return [JSON.parse(urlParams.get('request'))];
const request = JSON.parse(urlParams.get('request'));

if (request.method === 'sign') {
const dataObj = request.params.data;
// Deserialize `data` into a Uint8Array
if (!dataObj) {
throw new Error('Missing "data" params for "sign" request');
}

const data = new Uint8Array(Object.keys(dataObj).length);
for (const [index, value] of Object.entries(dataObj)) {
data[index] = value;
}
request.params.data = data;
}

return [request];
}

export default function PopupPage({ opener }) {
Expand Down

0 comments on commit 543a0a8

Please sign in to comment.