UNPKG

@keplr-ewallet/ewallet-sdk-core

Version:
38 lines 1.22 kB
import { KeplrEWallet } from "@keplr-ewallet-sdk-core/keplr_ewallet"; const WAIT_TIME = 300000; export async function showModal(msg) { let timeoutId = null; const timeout = new Promise((_, reject) => { timeoutId = setTimeout(() => reject(new Error("Show modal timeout")), WAIT_TIME); }); try { this.iframe.style.display = "block"; const showModalAck = await Promise.race([ this.sendMsgToIframe(msg), timeout, ]); if (timeoutId) { clearTimeout(timeoutId); timeoutId = null; } if (showModalAck.msg_type !== "show_modal_ack") { throw new Error("Unreachable"); } if (!showModalAck.payload.success) { throw new Error(showModalAck.payload.err); } return showModalAck.payload.data; } catch (error) { if (timeoutId) { clearTimeout(timeoutId); timeoutId = null; } if (error instanceof Error && error.message === "Show modal timeout") { await this.hideModal(); throw new Error("Show modal timeout"); } throw error; } } //# sourceMappingURL=show_modal.js.map