forked from cerc-io/laconic-wallet-web
Add event listener for iframe message
This commit is contained in:
parent
b94fd22c76
commit
53095dbc2d
@ -18,6 +18,35 @@ import { createTheme, ThemeProvider } from "@mui/material";
|
|||||||
|
|
||||||
globalThis.Buffer = Buffer;
|
globalThis.Buffer = Buffer;
|
||||||
|
|
||||||
|
window.addEventListener('message', (event: MessageEvent) => {
|
||||||
|
if (event.origin !== 'http://localhost:3001') return;
|
||||||
|
|
||||||
|
if (event.data.type === 'REQUEST_WALLET_ACCOUNTS') {
|
||||||
|
try {
|
||||||
|
const accountsData = localStorage.getItem('accounts/cosmos:laconic-testnet-2/0');
|
||||||
|
|
||||||
|
if (!accountsData) {
|
||||||
|
event.source?.postMessage({
|
||||||
|
type: 'ERROR',
|
||||||
|
message: 'Wallet accounts not found in local storage'
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
(event.source as Window)?.postMessage({
|
||||||
|
type: 'WALLET_ACCOUNTS_DATA',
|
||||||
|
data: accountsData
|
||||||
|
}, 'http://localhost:3001');
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
(event.source as Window)?.postMessage({
|
||||||
|
type: 'ERROR',
|
||||||
|
message: 'Error accessing wallet accounts data'
|
||||||
|
}, 'http://localhost:3001');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const linking = {
|
const linking = {
|
||||||
prefixes: ["https://wallet.laconic.com"],
|
prefixes: ["https://wallet.laconic.com"],
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user