fix 'sign' method in Chrome extension context (#177)
This commit is contained in:
parent
cf67838230
commit
543a0a8f1e
|
@ -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"
|
||||
|
|
|
@ -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 }) {
|
||||
|
|
Loading…
Reference in New Issue