fix 'sign' method in Chrome extension context (#177)

This commit is contained in:
Paul Bernier 2021-04-12 00:38:54 -07:00 committed by GitHub
parent cf67838230
commit 543a0a8f1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 2 deletions

View File

@ -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"

View File

@ -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 }) {