forked from cerc-io/laconic-wallet-web
Remove event listener from index.tsx
This commit is contained in:
parent
0cba7ab55d
commit
a1cc6307cf
@ -18,51 +18,6 @@ import { createTheme, ThemeProvider } from "@mui/material";
|
|||||||
|
|
||||||
globalThis.Buffer = Buffer;
|
globalThis.Buffer = Buffer;
|
||||||
|
|
||||||
window.addEventListener('message', (event: MessageEvent) => {
|
|
||||||
if (event.origin !== 'http://localhost:3000') return;
|
|
||||||
|
|
||||||
if (event.data.type === 'REQUEST_WALLET_ACCOUNTS') {
|
|
||||||
try {
|
|
||||||
let accountsData = '';
|
|
||||||
const indices = localStorage.getItem(`addAccountCounter/cosmos:${event.data.chainId}`);
|
|
||||||
for (let i = 0; i < Number(indices); i++) {
|
|
||||||
const account = localStorage.getItem(`accounts/cosmos:${event.data.chainId}/${i}`);
|
|
||||||
if (account) {
|
|
||||||
accountsData += `${account},`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove trailing comma
|
|
||||||
accountsData = accountsData.slice(0, -1);
|
|
||||||
|
|
||||||
if (!accountsData) {
|
|
||||||
event.source?.postMessage({
|
|
||||||
type: 'ERROR',
|
|
||||||
message: 'Wallet accounts not found in local storage',
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const elements = accountsData.split(',');
|
|
||||||
const addresses = elements.filter((_, index) => (index + 1) % 4 === 0);
|
|
||||||
|
|
||||||
(event.source as Window)?.postMessage(
|
|
||||||
{
|
|
||||||
type: 'WALLET_ACCOUNTS_DATA',
|
|
||||||
data: addresses,
|
|
||||||
},
|
|
||||||
'http://localhost:3000'
|
|
||||||
);
|
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
(event.source as Window)?.postMessage({
|
|
||||||
type: 'ERROR',
|
|
||||||
message: 'Error accessing wallet accounts data'
|
|
||||||
}, 'http://localhost:3000');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const linking = {
|
const linking = {
|
||||||
prefixes: ["https://wallet.laconic.com"],
|
prefixes: ["https://wallet.laconic.com"],
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user