UNPKG

coinley-checkout

Version:

A React SDK for Coinley cryptocurrency payment processing with multi-network support

1,812 lines (1,811 loc) 786 kB
import { B as Buffer } from "./index-2161e56b.mjs"; import { g as global } from "./index-703c58ee.mjs"; import { bx as createTransport, by as TransactionRejectedRpcError, bz as UserRejectedRequestError, bA as ExecutionRevertedError, ax as wait, p as process$1, bB as formatUnits, ba as http, t as toHex$1 } from "./index-1c96ce10.mjs"; import { e as eventsExports, N as Nt$2 } from "./events-856718af.mjs"; import { d as destr, s as safeJsonStringify, a as safeJsonParse, I as IEvents, b as bases, g as getWindowMetadata_1, c as cjs, e as getDocument_1, f as getNavigator_1, h as detect, i as getLocation_1, j as sn$2, C as C$3, E as E$5, y as y$7, k as k$5, A as A$3, l as i$5, O as Ot$2, o as o$4, m as f$4, n as isJsonRpcRequest, p as isJsonRpcResponse, q as formatJsonRpcResult, r as r$3, t as formatJsonRpcRequest, P as Po$1, Q as Qe$3, u as Qo, v as getBigIntRpcId, w as formatJsonRpcError, x as isJsonRpcResult, z as isJsonRpcError, B as payloadId, D as f$5 } from "./index.es-2cef285a.mjs"; import { c as createStore, g as get, s as set, d as del, k as keys, a as clear } from "./index-ad797676.mjs"; function fallback(transports_, config = {}) { const { key = "fallback", name = "Fallback", rank = false, shouldThrow: shouldThrow_ = shouldThrow, retryCount, retryDelay } = config; return ({ chain, pollingInterval = 4e3, timeout, ...rest }) => { let transports = transports_; let onResponse = () => { }; const transport = createTransport({ key, name, async request({ method, params }) { let includes; const fetch2 = async (i2 = 0) => { const transport2 = transports[i2]({ ...rest, chain, retryCount: 0, timeout }); try { const response = await transport2.request({ method, params }); onResponse({ method, params, response, transport: transport2, status: "success" }); return response; } catch (err) { onResponse({ error: err, method, params, transport: transport2, status: "error" }); if (shouldThrow_(err)) throw err; if (i2 === transports.length - 1) throw err; includes ??= transports.slice(i2 + 1).some((transport3) => { const { include, exclude } = transport3({ chain }).config.methods || {}; if (include) return include.includes(method); if (exclude) return !exclude.includes(method); return true; }); if (!includes) throw err; return fetch2(i2 + 1); } }; return fetch2(); }, retryCount, retryDelay, type: "fallback" }, { onResponse: (fn2) => onResponse = fn2, transports: transports.map((fn2) => fn2({ chain, retryCount: 0 })) }); if (rank) { const rankOptions = typeof rank === "object" ? rank : {}; rankTransports({ chain, interval: rankOptions.interval ?? pollingInterval, onTransports: (transports_2) => transports = transports_2, ping: rankOptions.ping, sampleCount: rankOptions.sampleCount, timeout: rankOptions.timeout, transports, weights: rankOptions.weights }); } return transport; }; } function shouldThrow(error) { if ("code" in error && typeof error.code === "number") { if (error.code === TransactionRejectedRpcError.code || error.code === UserRejectedRequestError.code || ExecutionRevertedError.nodeMessage.test(error.message) || error.code === 5e3) return true; } return false; } function rankTransports({ chain, interval = 4e3, onTransports, ping, sampleCount = 10, timeout = 1e3, transports, weights = {} }) { const { stability: stabilityWeight = 0.7, latency: latencyWeight = 0.3 } = weights; const samples = []; const rankTransports_ = async () => { const sample = await Promise.all(transports.map(async (transport) => { const transport_ = transport({ chain, retryCount: 0, timeout }); const start = Date.now(); let end; let success; try { await (ping ? ping({ transport: transport_ }) : transport_.request({ method: "net_listening" })); success = 1; } catch { success = 0; } finally { end = Date.now(); } const latency = end - start; return { latency, success }; })); samples.push(sample); if (samples.length > sampleCount) samples.shift(); const maxLatency = Math.max(...samples.map((sample2) => Math.max(...sample2.map(({ latency }) => latency)))); const scores = transports.map((_3, i2) => { const latencies = samples.map((sample2) => sample2[i2].latency); const meanLatency = latencies.reduce((acc, latency) => acc + latency, 0) / latencies.length; const latencyScore = 1 - meanLatency / maxLatency; const successes = samples.map((sample2) => sample2[i2].success); const stabilityScore = successes.reduce((acc, success) => acc + success, 0) / successes.length; if (stabilityScore === 0) return [0, i2]; return [ latencyWeight * latencyScore + stabilityWeight * stabilityScore, i2 ]; }).sort((a2, b2) => b2[0] - a2[0]); onTransports(scores.map(([, i2]) => transports[i2])); await wait(interval); rankTransports_(); }; rankTransports_(); } const ConstantsUtil$3 = { WC_NAME_SUFFIX: ".reown.id", WC_NAME_SUFFIX_LEGACY: ".wcn.id", BLOCKCHAIN_API_RPC_URL: "https://rpc.walletconnect.org", PULSE_API_URL: "https://pulse.walletconnect.org", W3M_API_URL: "https://api.web3modal.org", CONNECTOR_ID: { WALLET_CONNECT: "walletConnect", INJECTED: "injected", WALLET_STANDARD: "announced", COINBASE: "coinbaseWallet", COINBASE_SDK: "coinbaseWalletSDK", SAFE: "safe", LEDGER: "ledger", OKX: "okx", EIP6963: "eip6963", AUTH: "ID_AUTH" }, CONNECTOR_NAMES: { AUTH: "Auth" }, AUTH_CONNECTOR_SUPPORTED_CHAINS: ["eip155", "solana"], LIMITS: { PENDING_TRANSACTIONS: 99 }, CHAIN: { EVM: "eip155", SOLANA: "solana", POLKADOT: "polkadot", BITCOIN: "bip122" }, CHAIN_NAME_MAP: { eip155: "EVM Networks", solana: "Solana", polkadot: "Polkadot", bip122: "Bitcoin", cosmos: "Cosmos" }, ADAPTER_TYPES: { BITCOIN: "bitcoin", SOLANA: "solana", WAGMI: "wagmi", ETHERS: "ethers", ETHERS5: "ethers5" }, USDT_CONTRACT_ADDRESSES: [ "0xdac17f958d2ee523a2206206994597c13d831ec7", "0xc2132d05d31c914a87c6611c10748aeb04b58e8f", "0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7", "0x919C1c267BC06a7039e03fcc2eF738525769109c", "0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e", "0x55d398326f99059fF775485246999027B3197955", "0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9" ], HTTP_STATUS_CODES: { SERVICE_UNAVAILABLE: 503, FORBIDDEN: 403 }, UNSUPPORTED_NETWORK_NAME: "Unknown Network", SECURE_SITE_SDK_ORIGIN: (typeof process$1 !== "undefined" && typeof process$1.env !== "undefined" ? process$1.env["NEXT_PUBLIC_SECURE_SITE_ORIGIN"] : void 0) || "https://secure.walletconnect.org" }; const NetworkUtil$1 = { caipNetworkIdToNumber(caipnetworkId) { return caipnetworkId ? Number(caipnetworkId.split(":")[1]) : void 0; }, parseEvmChainId(chainId) { return typeof chainId === "string" ? this.caipNetworkIdToNumber(chainId) : chainId; }, getNetworksByNamespace(networks, namespace) { return networks?.filter((network) => network.chainNamespace === namespace) || []; }, getFirstNetworkByNamespace(networks, namespace) { return this.getNetworksByNamespace(networks, namespace)[0]; }, getNetworkNameByCaipNetworkId(caipNetworks, caipNetworkId) { if (!caipNetworkId) { return void 0; } const caipNetwork = caipNetworks.find((network) => network.caipNetworkId === caipNetworkId); if (caipNetwork) { return caipNetwork.name; } const [namespace] = caipNetworkId.split(":"); return ConstantsUtil$3.CHAIN_NAME_MAP?.[namespace] || void 0; } }; var DP = 20, RM = 1, MAX_DP = 1e6, MAX_POWER = 1e6, NE = -7, PE = 21, STRICT = false, NAME = "[big.js] ", INVALID = NAME + "Invalid ", INVALID_DP = INVALID + "decimal places", INVALID_RM = INVALID + "rounding mode", DIV_BY_ZERO = NAME + "Division by zero", P$3 = {}, UNDEFINED = void 0, NUMERIC = /^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i; function _Big_() { function Big2(n3) { var x2 = this; if (!(x2 instanceof Big2)) return n3 === UNDEFINED ? _Big_() : new Big2(n3); if (n3 instanceof Big2) { x2.s = n3.s; x2.e = n3.e; x2.c = n3.c.slice(); } else { if (typeof n3 !== "string") { if (Big2.strict === true && typeof n3 !== "bigint") { throw TypeError(INVALID + "value"); } n3 = n3 === 0 && 1 / n3 < 0 ? "-0" : String(n3); } parse(x2, n3); } x2.constructor = Big2; } Big2.prototype = P$3; Big2.DP = DP; Big2.RM = RM; Big2.NE = NE; Big2.PE = PE; Big2.strict = STRICT; Big2.roundDown = 0; Big2.roundHalfUp = 1; Big2.roundHalfEven = 2; Big2.roundUp = 3; return Big2; } function parse(x2, n3) { var e2, i2, nl; if (!NUMERIC.test(n3)) { throw Error(INVALID + "number"); } x2.s = n3.charAt(0) == "-" ? (n3 = n3.slice(1), -1) : 1; if ((e2 = n3.indexOf(".")) > -1) n3 = n3.replace(".", ""); if ((i2 = n3.search(/e/i)) > 0) { if (e2 < 0) e2 = i2; e2 += +n3.slice(i2 + 1); n3 = n3.substring(0, i2); } else if (e2 < 0) { e2 = n3.length; } nl = n3.length; for (i2 = 0; i2 < nl && n3.charAt(i2) == "0"; ) ++i2; if (i2 == nl) { x2.c = [x2.e = 0]; } else { for (; nl > 0 && n3.charAt(--nl) == "0"; ) ; x2.e = e2 - i2 - 1; x2.c = []; for (e2 = 0; i2 <= nl; ) x2.c[e2++] = +n3.charAt(i2++); } return x2; } function round(x2, sd, rm, more) { var xc2 = x2.c; if (rm === UNDEFINED) rm = x2.constructor.RM; if (rm !== 0 && rm !== 1 && rm !== 2 && rm !== 3) { throw Error(INVALID_RM); } if (sd < 1) { more = rm === 3 && (more || !!xc2[0]) || sd === 0 && (rm === 1 && xc2[0] >= 5 || rm === 2 && (xc2[0] > 5 || xc2[0] === 5 && (more || xc2[1] !== UNDEFINED))); xc2.length = 1; if (more) { x2.e = x2.e - sd + 1; xc2[0] = 1; } else { xc2[0] = x2.e = 0; } } else if (sd < xc2.length) { more = rm === 1 && xc2[sd] >= 5 || rm === 2 && (xc2[sd] > 5 || xc2[sd] === 5 && (more || xc2[sd + 1] !== UNDEFINED || xc2[sd - 1] & 1)) || rm === 3 && (more || !!xc2[0]); xc2.length = sd; if (more) { for (; ++xc2[--sd] > 9; ) { xc2[sd] = 0; if (sd === 0) { ++x2.e; xc2.unshift(1); break; } } } for (sd = xc2.length; !xc2[--sd]; ) xc2.pop(); } return x2; } function stringify$1(x2, doExponential, isNonzero) { var e2 = x2.e, s2 = x2.c.join(""), n3 = s2.length; if (doExponential) { s2 = s2.charAt(0) + (n3 > 1 ? "." + s2.slice(1) : "") + (e2 < 0 ? "e" : "e+") + e2; } else if (e2 < 0) { for (; ++e2; ) s2 = "0" + s2; s2 = "0." + s2; } else if (e2 > 0) { if (++e2 > n3) { for (e2 -= n3; e2--; ) s2 += "0"; } else if (e2 < n3) { s2 = s2.slice(0, e2) + "." + s2.slice(e2); } } else if (n3 > 1) { s2 = s2.charAt(0) + "." + s2.slice(1); } return x2.s < 0 && isNonzero ? "-" + s2 : s2; } P$3.abs = function() { var x2 = new this.constructor(this); x2.s = 1; return x2; }; P$3.cmp = function(y4) { var isneg, x2 = this, xc2 = x2.c, yc2 = (y4 = new x2.constructor(y4)).c, i2 = x2.s, j2 = y4.s, k2 = x2.e, l2 = y4.e; if (!xc2[0] || !yc2[0]) return !xc2[0] ? !yc2[0] ? 0 : -j2 : i2; if (i2 != j2) return i2; isneg = i2 < 0; if (k2 != l2) return k2 > l2 ^ isneg ? 1 : -1; j2 = (k2 = xc2.length) < (l2 = yc2.length) ? k2 : l2; for (i2 = -1; ++i2 < j2; ) { if (xc2[i2] != yc2[i2]) return xc2[i2] > yc2[i2] ^ isneg ? 1 : -1; } return k2 == l2 ? 0 : k2 > l2 ^ isneg ? 1 : -1; }; P$3.div = function(y4) { var x2 = this, Big2 = x2.constructor, a2 = x2.c, b2 = (y4 = new Big2(y4)).c, k2 = x2.s == y4.s ? 1 : -1, dp = Big2.DP; if (dp !== ~~dp || dp < 0 || dp > MAX_DP) { throw Error(INVALID_DP); } if (!b2[0]) { throw Error(DIV_BY_ZERO); } if (!a2[0]) { y4.s = k2; y4.c = [y4.e = 0]; return y4; } var bl, bt2, n3, cmp, ri2, bz = b2.slice(), ai2 = bl = b2.length, al = a2.length, r2 = a2.slice(0, bl), rl = r2.length, q2 = y4, qc2 = q2.c = [], qi2 = 0, p2 = dp + (q2.e = x2.e - y4.e) + 1; q2.s = k2; k2 = p2 < 0 ? 0 : p2; bz.unshift(0); for (; rl++ < bl; ) r2.push(0); do { for (n3 = 0; n3 < 10; n3++) { if (bl != (rl = r2.length)) { cmp = bl > rl ? 1 : -1; } else { for (ri2 = -1, cmp = 0; ++ri2 < bl; ) { if (b2[ri2] != r2[ri2]) { cmp = b2[ri2] > r2[ri2] ? 1 : -1; break; } } } if (cmp < 0) { for (bt2 = rl == bl ? b2 : bz; rl; ) { if (r2[--rl] < bt2[rl]) { ri2 = rl; for (; ri2 && !r2[--ri2]; ) r2[ri2] = 9; --r2[ri2]; r2[rl] += 10; } r2[rl] -= bt2[rl]; } for (; !r2[0]; ) r2.shift(); } else { break; } } qc2[qi2++] = cmp ? n3 : ++n3; if (r2[0] && cmp) r2[rl] = a2[ai2] || 0; else r2 = [a2[ai2]]; } while ((ai2++ < al || r2[0] !== UNDEFINED) && k2--); if (!qc2[0] && qi2 != 1) { qc2.shift(); q2.e--; p2--; } if (qi2 > p2) round(q2, p2, Big2.RM, r2[0] !== UNDEFINED); return q2; }; P$3.eq = function(y4) { return this.cmp(y4) === 0; }; P$3.gt = function(y4) { return this.cmp(y4) > 0; }; P$3.gte = function(y4) { return this.cmp(y4) > -1; }; P$3.lt = function(y4) { return this.cmp(y4) < 0; }; P$3.lte = function(y4) { return this.cmp(y4) < 1; }; P$3.minus = P$3.sub = function(y4) { var i2, j2, t2, xlty, x2 = this, Big2 = x2.constructor, a2 = x2.s, b2 = (y4 = new Big2(y4)).s; if (a2 != b2) { y4.s = -b2; return x2.plus(y4); } var xc2 = x2.c.slice(), xe2 = x2.e, yc2 = y4.c, ye2 = y4.e; if (!xc2[0] || !yc2[0]) { if (yc2[0]) { y4.s = -b2; } else if (xc2[0]) { y4 = new Big2(x2); } else { y4.s = 1; } return y4; } if (a2 = xe2 - ye2) { if (xlty = a2 < 0) { a2 = -a2; t2 = xc2; } else { ye2 = xe2; t2 = yc2; } t2.reverse(); for (b2 = a2; b2--; ) t2.push(0); t2.reverse(); } else { j2 = ((xlty = xc2.length < yc2.length) ? xc2 : yc2).length; for (a2 = b2 = 0; b2 < j2; b2++) { if (xc2[b2] != yc2[b2]) { xlty = xc2[b2] < yc2[b2]; break; } } } if (xlty) { t2 = xc2; xc2 = yc2; yc2 = t2; y4.s = -y4.s; } if ((b2 = (j2 = yc2.length) - (i2 = xc2.length)) > 0) for (; b2--; ) xc2[i2++] = 0; for (b2 = i2; j2 > a2; ) { if (xc2[--j2] < yc2[j2]) { for (i2 = j2; i2 && !xc2[--i2]; ) xc2[i2] = 9; --xc2[i2]; xc2[j2] += 10; } xc2[j2] -= yc2[j2]; } for (; xc2[--b2] === 0; ) xc2.pop(); for (; xc2[0] === 0; ) { xc2.shift(); --ye2; } if (!xc2[0]) { y4.s = 1; xc2 = [ye2 = 0]; } y4.c = xc2; y4.e = ye2; return y4; }; P$3.mod = function(y4) { var ygtx, x2 = this, Big2 = x2.constructor, a2 = x2.s, b2 = (y4 = new Big2(y4)).s; if (!y4.c[0]) { throw Error(DIV_BY_ZERO); } x2.s = y4.s = 1; ygtx = y4.cmp(x2) == 1; x2.s = a2; y4.s = b2; if (ygtx) return new Big2(x2); a2 = Big2.DP; b2 = Big2.RM; Big2.DP = Big2.RM = 0; x2 = x2.div(y4); Big2.DP = a2; Big2.RM = b2; return this.minus(x2.times(y4)); }; P$3.neg = function() { var x2 = new this.constructor(this); x2.s = -x2.s; return x2; }; P$3.plus = P$3.add = function(y4) { var e2, k2, t2, x2 = this, Big2 = x2.constructor; y4 = new Big2(y4); if (x2.s != y4.s) { y4.s = -y4.s; return x2.minus(y4); } var xe2 = x2.e, xc2 = x2.c, ye2 = y4.e, yc2 = y4.c; if (!xc2[0] || !yc2[0]) { if (!yc2[0]) { if (xc2[0]) { y4 = new Big2(x2); } else { y4.s = x2.s; } } return y4; } xc2 = xc2.slice(); if (e2 = xe2 - ye2) { if (e2 > 0) { ye2 = xe2; t2 = yc2; } else { e2 = -e2; t2 = xc2; } t2.reverse(); for (; e2--; ) t2.push(0); t2.reverse(); } if (xc2.length - yc2.length < 0) { t2 = yc2; yc2 = xc2; xc2 = t2; } e2 = yc2.length; for (k2 = 0; e2; xc2[e2] %= 10) k2 = (xc2[--e2] = xc2[e2] + yc2[e2] + k2) / 10 | 0; if (k2) { xc2.unshift(k2); ++ye2; } for (e2 = xc2.length; xc2[--e2] === 0; ) xc2.pop(); y4.c = xc2; y4.e = ye2; return y4; }; P$3.pow = function(n3) { var x2 = this, one = new x2.constructor("1"), y4 = one, isneg = n3 < 0; if (n3 !== ~~n3 || n3 < -MAX_POWER || n3 > MAX_POWER) { throw Error(INVALID + "exponent"); } if (isneg) n3 = -n3; for (; ; ) { if (n3 & 1) y4 = y4.times(x2); n3 >>= 1; if (!n3) break; x2 = x2.times(x2); } return isneg ? one.div(y4) : y4; }; P$3.prec = function(sd, rm) { if (sd !== ~~sd || sd < 1 || sd > MAX_DP) { throw Error(INVALID + "precision"); } return round(new this.constructor(this), sd, rm); }; P$3.round = function(dp, rm) { if (dp === UNDEFINED) dp = 0; else if (dp !== ~~dp || dp < -MAX_DP || dp > MAX_DP) { throw Error(INVALID_DP); } return round(new this.constructor(this), dp + this.e + 1, rm); }; P$3.sqrt = function() { var r2, c2, t2, x2 = this, Big2 = x2.constructor, s2 = x2.s, e2 = x2.e, half = new Big2("0.5"); if (!x2.c[0]) return new Big2(x2); if (s2 < 0) { throw Error(NAME + "No square root"); } s2 = Math.sqrt(+stringify$1(x2, true, true)); if (s2 === 0 || s2 === 1 / 0) { c2 = x2.c.join(""); if (!(c2.length + e2 & 1)) c2 += "0"; s2 = Math.sqrt(c2); e2 = ((e2 + 1) / 2 | 0) - (e2 < 0 || e2 & 1); r2 = new Big2((s2 == 1 / 0 ? "5e" : (s2 = s2.toExponential()).slice(0, s2.indexOf("e") + 1)) + e2); } else { r2 = new Big2(s2 + ""); } e2 = r2.e + (Big2.DP += 4); do { t2 = r2; r2 = half.times(t2.plus(x2.div(t2))); } while (t2.c.slice(0, e2).join("") !== r2.c.slice(0, e2).join("")); return round(r2, (Big2.DP -= 4) + r2.e + 1, Big2.RM); }; P$3.times = P$3.mul = function(y4) { var c2, x2 = this, Big2 = x2.constructor, xc2 = x2.c, yc2 = (y4 = new Big2(y4)).c, a2 = xc2.length, b2 = yc2.length, i2 = x2.e, j2 = y4.e; y4.s = x2.s == y4.s ? 1 : -1; if (!xc2[0] || !yc2[0]) { y4.c = [y4.e = 0]; return y4; } y4.e = i2 + j2; if (a2 < b2) { c2 = xc2; xc2 = yc2; yc2 = c2; j2 = a2; a2 = b2; b2 = j2; } for (c2 = new Array(j2 = a2 + b2); j2--; ) c2[j2] = 0; for (i2 = b2; i2--; ) { b2 = 0; for (j2 = a2 + i2; j2 > i2; ) { b2 = c2[j2] + yc2[i2] * xc2[j2 - i2 - 1] + b2; c2[j2--] = b2 % 10; b2 = b2 / 10 | 0; } c2[j2] = b2; } if (b2) ++y4.e; else c2.shift(); for (i2 = c2.length; !c2[--i2]; ) c2.pop(); y4.c = c2; return y4; }; P$3.toExponential = function(dp, rm) { var x2 = this, n3 = x2.c[0]; if (dp !== UNDEFINED) { if (dp !== ~~dp || dp < 0 || dp > MAX_DP) { throw Error(INVALID_DP); } x2 = round(new x2.constructor(x2), ++dp, rm); for (; x2.c.length < dp; ) x2.c.push(0); } return stringify$1(x2, true, !!n3); }; P$3.toFixed = function(dp, rm) { var x2 = this, n3 = x2.c[0]; if (dp !== UNDEFINED) { if (dp !== ~~dp || dp < 0 || dp > MAX_DP) { throw Error(INVALID_DP); } x2 = round(new x2.constructor(x2), dp + x2.e + 1, rm); for (dp = dp + x2.e + 1; x2.c.length < dp; ) x2.c.push(0); } return stringify$1(x2, false, !!n3); }; P$3[Symbol.for("nodejs.util.inspect.custom")] = P$3.toJSON = P$3.toString = function() { var x2 = this, Big2 = x2.constructor; return stringify$1(x2, x2.e <= Big2.NE || x2.e >= Big2.PE, !!x2.c[0]); }; P$3.toNumber = function() { var n3 = +stringify$1(this, true, true); if (this.constructor.strict === true && !this.eq(n3.toString())) { throw Error(NAME + "Imprecise conversion"); } return n3; }; P$3.toPrecision = function(sd, rm) { var x2 = this, Big2 = x2.constructor, n3 = x2.c[0]; if (sd !== UNDEFINED) { if (sd !== ~~sd || sd < 1 || sd > MAX_DP) { throw Error(INVALID + "precision"); } x2 = round(new Big2(x2), sd, rm); for (; x2.c.length < sd; ) x2.c.push(0); } return stringify$1(x2, sd <= x2.e || x2.e <= Big2.NE || x2.e >= Big2.PE, !!n3); }; P$3.valueOf = function() { var x2 = this, Big2 = x2.constructor; if (Big2.strict === true) { throw Error(NAME + "valueOf disallowed"); } return stringify$1(x2, x2.e <= Big2.NE || x2.e >= Big2.PE, true); }; var Big = _Big_(); const NumberUtil = { bigNumber(value) { if (!value) { return new Big(0); } return new Big(value); }, multiply(a2, b2) { if (a2 === void 0 || b2 === void 0) { return new Big(0); } const aBigNumber = new Big(a2); const bBigNumber = new Big(b2); return aBigNumber.times(bBigNumber); }, formatNumberToLocalString(value, decimals = 2) { if (value === void 0) { return "0.00"; } if (typeof value === "number") { return value.toLocaleString("en-US", { maximumFractionDigits: decimals, minimumFractionDigits: decimals }); } return parseFloat(value).toLocaleString("en-US", { maximumFractionDigits: decimals, minimumFractionDigits: decimals }); }, parseLocalStringToNumber(value) { if (value === void 0) { return 0; } return parseFloat(value.replace(/,/gu, "")); } }; const erc20ABI = [ { type: "function", name: "transfer", stateMutability: "nonpayable", inputs: [ { name: "_to", type: "address" }, { name: "_value", type: "uint256" } ], outputs: [ { name: "", type: "bool" } ] }, { type: "function", name: "transferFrom", stateMutability: "nonpayable", inputs: [ { name: "_from", type: "address" }, { name: "_to", type: "address" }, { name: "_value", type: "uint256" } ], outputs: [ { name: "", type: "bool" } ] } ]; const swapABI = [ { type: "function", name: "approve", stateMutability: "nonpayable", inputs: [ { name: "spender", type: "address" }, { name: "amount", type: "uint256" } ], outputs: [{ type: "bool" }] } ]; const usdtABI = [ { type: "function", name: "transfer", stateMutability: "nonpayable", inputs: [ { name: "recipient", type: "address" }, { name: "amount", type: "uint256" } ], outputs: [] }, { type: "function", name: "transferFrom", stateMutability: "nonpayable", inputs: [ { name: "sender", type: "address" }, { name: "recipient", type: "address" }, { name: "amount", type: "uint256" } ], outputs: [ { name: "", type: "bool" } ] } ]; const ContractUtil = { getERC20Abi: (tokenAddress) => { if (ConstantsUtil$3.USDT_CONTRACT_ADDRESSES.includes(tokenAddress)) { return usdtABI; } return erc20ABI; }, getSwapAbi: () => swapABI }; const ParseUtil = { validateCaipAddress(address) { if (address.split(":")?.length !== 3) { throw new Error("Invalid CAIP Address"); } return address; }, parseCaipAddress(caipAddress) { const parts = caipAddress.split(":"); if (parts.length !== 3) { throw new Error(`Invalid CAIP-10 address: ${caipAddress}`); } const [chainNamespace, chainId, address] = parts; if (!chainNamespace || !chainId || !address) { throw new Error(`Invalid CAIP-10 address: ${caipAddress}`); } return { chainNamespace, chainId, address }; }, parseCaipNetworkId(caipNetworkId) { const parts = caipNetworkId.split(":"); if (parts.length !== 2) { throw new Error(`Invalid CAIP-2 network id: ${caipNetworkId}`); } const [chainNamespace, chainId] = parts; if (!chainNamespace || !chainId) { throw new Error(`Invalid CAIP-2 network id: ${caipNetworkId}`); } return { chainNamespace, chainId }; } }; const SafeLocalStorageKeys = { WALLET_ID: "@appkit/wallet_id", WALLET_NAME: "@appkit/wallet_name", SOLANA_WALLET: "@appkit/solana_wallet", SOLANA_CAIP_CHAIN: "@appkit/solana_caip_chain", ACTIVE_CAIP_NETWORK_ID: "@appkit/active_caip_network_id", CONNECTED_SOCIAL: "@appkit/connected_social", CONNECTED_SOCIAL_USERNAME: "@appkit-wallet/SOCIAL_USERNAME", RECENT_WALLETS: "@appkit/recent_wallets", DEEPLINK_CHOICE: "WALLETCONNECT_DEEPLINK_CHOICE", ACTIVE_NAMESPACE: "@appkit/active_namespace", CONNECTED_NAMESPACES: "@appkit/connected_namespaces", CONNECTION_STATUS: "@appkit/connection_status", SIWX_AUTH_TOKEN: "@appkit/siwx-auth-token", SIWX_NONCE_TOKEN: "@appkit/siwx-nonce-token", TELEGRAM_SOCIAL_PROVIDER: "@appkit/social_provider", NATIVE_BALANCE_CACHE: "@appkit/native_balance_cache", PORTFOLIO_CACHE: "@appkit/portfolio_cache", ENS_CACHE: "@appkit/ens_cache", IDENTITY_CACHE: "@appkit/identity_cache", PREFERRED_ACCOUNT_TYPES: "@appkit/preferred_account_types", CONNECTIONS: "@appkit/connections" }; function getSafeConnectorIdKey(namespace) { if (!namespace) { throw new Error("Namespace is required for CONNECTED_CONNECTOR_ID"); } return `@appkit/${namespace}:connected_connector_id`; } const SafeLocalStorage = { setItem(key, value) { if (isSafe$1() && value !== void 0) { localStorage.setItem(key, value); } }, getItem(key) { if (isSafe$1()) { return localStorage.getItem(key) || void 0; } return void 0; }, removeItem(key) { if (isSafe$1()) { localStorage.removeItem(key); } }, clear() { if (isSafe$1()) { localStorage.clear(); } } }; function isSafe$1() { return typeof window !== "undefined" && typeof localStorage !== "undefined"; } function getW3mThemeVariables(themeVariables, themeType) { if (themeType === "light") { return { "--w3m-accent": themeVariables?.["--w3m-accent"] || "hsla(231, 100%, 70%, 1)", "--w3m-background": "#fff" }; } return { "--w3m-accent": themeVariables?.["--w3m-accent"] || "hsla(230, 100%, 67%, 1)", "--w3m-background": "#121313" }; } const t$2 = Symbol(); const s$3 = Object.getPrototypeOf, c$6 = /* @__PURE__ */ new WeakMap(), l$4 = (e2) => e2 && (c$6.has(e2) ? c$6.get(e2) : s$3(e2) === Object.prototype || s$3(e2) === Array.prototype), y$6 = (e2) => l$4(e2) && e2[t$2] || null, h$5 = (e2, t2 = true) => { c$6.set(e2, t2); }; const isObject = (x2) => typeof x2 === "object" && x2 !== null; const proxyStateMap = /* @__PURE__ */ new WeakMap(); const refSet = /* @__PURE__ */ new WeakSet(); const buildProxyFunction = (objectIs = Object.is, newProxy = (target, handler) => new Proxy(target, handler), canProxy = (x2) => isObject(x2) && !refSet.has(x2) && (Array.isArray(x2) || !(Symbol.iterator in x2)) && !(x2 instanceof WeakMap) && !(x2 instanceof WeakSet) && !(x2 instanceof Error) && !(x2 instanceof Number) && !(x2 instanceof Date) && !(x2 instanceof String) && !(x2 instanceof RegExp) && !(x2 instanceof ArrayBuffer), defaultHandlePromise = (promise) => { switch (promise.status) { case "fulfilled": return promise.value; case "rejected": throw promise.reason; default: throw promise; } }, snapCache = /* @__PURE__ */ new WeakMap(), createSnapshot = (target, version2, handlePromise = defaultHandlePromise) => { const cache = snapCache.get(target); if ((cache == null ? void 0 : cache[0]) === version2) { return cache[1]; } const snap = Array.isArray(target) ? [] : Object.create(Object.getPrototypeOf(target)); h$5(snap, true); snapCache.set(target, [version2, snap]); Reflect.ownKeys(target).forEach((key) => { if (Object.getOwnPropertyDescriptor(snap, key)) { return; } const value = Reflect.get(target, key); const { enumerable } = Reflect.getOwnPropertyDescriptor( target, key ); const desc = { value, enumerable, // This is intentional to avoid copying with proxy-compare. // It's still non-writable, so it avoids assigning a value. configurable: true }; if (refSet.has(value)) { h$5(value, false); } else if (value instanceof Promise) { delete desc.value; desc.get = () => handlePromise(value); } else if (proxyStateMap.has(value)) { const [target2, ensureVersion] = proxyStateMap.get( value ); desc.value = createSnapshot( target2, ensureVersion(), handlePromise ); } Object.defineProperty(snap, key, desc); }); return Object.preventExtensions(snap); }, proxyCache = /* @__PURE__ */ new WeakMap(), versionHolder = [1, 1], proxyFunction = (initialObject) => { if (!isObject(initialObject)) { throw new Error("object required"); } const found = proxyCache.get(initialObject); if (found) { return found; } let version2 = versionHolder[0]; const listeners = /* @__PURE__ */ new Set(); const notifyUpdate = (op, nextVersion = ++versionHolder[0]) => { if (version2 !== nextVersion) { version2 = nextVersion; listeners.forEach((listener) => listener(op, nextVersion)); } }; let checkVersion = versionHolder[1]; const ensureVersion = (nextCheckVersion = ++versionHolder[1]) => { if (checkVersion !== nextCheckVersion && !listeners.size) { checkVersion = nextCheckVersion; propProxyStates.forEach(([propProxyState]) => { const propVersion = propProxyState[1](nextCheckVersion); if (propVersion > version2) { version2 = propVersion; } }); } return version2; }; const createPropListener = (prop) => (op, nextVersion) => { const newOp = [...op]; newOp[1] = [prop, ...newOp[1]]; notifyUpdate(newOp, nextVersion); }; const propProxyStates = /* @__PURE__ */ new Map(); const addPropListener = (prop, propProxyState) => { if (({ "BASE_URL": "/", "MODE": "production", "DEV": false, "PROD": true, "SSR": false } ? "production" : void 0) !== "production" && propProxyStates.has(prop)) { throw new Error("prop listener already exists"); } if (listeners.size) { const remove = propProxyState[3](createPropListener(prop)); propProxyStates.set(prop, [propProxyState, remove]); } else { propProxyStates.set(prop, [propProxyState]); } }; const removePropListener = (prop) => { var _a; const entry = propProxyStates.get(prop); if (entry) { propProxyStates.delete(prop); (_a = entry[1]) == null ? void 0 : _a.call(entry); } }; const addListener = (listener) => { listeners.add(listener); if (listeners.size === 1) { propProxyStates.forEach(([propProxyState, prevRemove], prop) => { if (({ "BASE_URL": "/", "MODE": "production", "DEV": false, "PROD": true, "SSR": false } ? "production" : void 0) !== "production" && prevRemove) { throw new Error("remove already exists"); } const remove = propProxyState[3](createPropListener(prop)); propProxyStates.set(prop, [propProxyState, remove]); }); } const removeListener = () => { listeners.delete(listener); if (listeners.size === 0) { propProxyStates.forEach(([propProxyState, remove], prop) => { if (remove) { remove(); propProxyStates.set(prop, [propProxyState]); } }); } }; return removeListener; }; const baseObject = Array.isArray(initialObject) ? [] : Object.create(Object.getPrototypeOf(initialObject)); const handler = { deleteProperty(target, prop) { const prevValue = Reflect.get(target, prop); removePropListener(prop); const deleted = Reflect.deleteProperty(target, prop); if (deleted) { notifyUpdate(["delete", [prop], prevValue]); } return deleted; }, set(target, prop, value, receiver) { const hasPrevValue = Reflect.has(target, prop); const prevValue = Reflect.get(target, prop, receiver); if (hasPrevValue && (objectIs(prevValue, value) || proxyCache.has(value) && objectIs(prevValue, proxyCache.get(value)))) { return true; } removePropListener(prop); if (isObject(value)) { value = y$6(value) || value; } let nextValue = value; if (value instanceof Promise) { value.then((v2) => { value.status = "fulfilled"; value.value = v2; notifyUpdate(["resolve", [prop], v2]); }).catch((e2) => { value.status = "rejected"; value.reason = e2; notifyUpdate(["reject", [prop], e2]); }); } else { if (!proxyStateMap.has(value) && canProxy(value)) { nextValue = proxyFunction(value); } const childProxyState = !refSet.has(nextValue) && proxyStateMap.get(nextValue); if (childProxyState) { addPropListener(prop, childProxyState); } } Reflect.set(target, prop, nextValue, receiver); notifyUpdate(["set", [prop], value, prevValue]); return true; } }; const proxyObject = newProxy(baseObject, handler); proxyCache.set(initialObject, proxyObject); const proxyState = [ baseObject, ensureVersion, createSnapshot, addListener ]; proxyStateMap.set(proxyObject, proxyState); Reflect.ownKeys(initialObject).forEach((key) => { const desc = Object.getOwnPropertyDescriptor( initialObject, key ); if ("value" in desc) { proxyObject[key] = initialObject[key]; delete desc.value; delete desc.writable; } Object.defineProperty(baseObject, key, desc); }); return proxyObject; }) => [ // public functions proxyFunction, // shared state proxyStateMap, refSet, // internal things objectIs, newProxy, canProxy, defaultHandlePromise, snapCache, createSnapshot, proxyCache, versionHolder ]; const [defaultProxyFunction] = buildProxyFunction(); function proxy(initialObject = {}) { return defaultProxyFunction(initialObject); } function subscribe(proxyObject, callback, notifyInSync) { const proxyState = proxyStateMap.get(proxyObject); if (({ "BASE_URL": "/", "MODE": "production", "DEV": false, "PROD": true, "SSR": false } ? "production" : void 0) !== "production" && !proxyState) { console.warn("Please use proxy object"); } let promise; const ops = []; const addListener = proxyState[3]; let isListenerActive = false; const listener = (op) => { ops.push(op); if (notifyInSync) { callback(ops.splice(0)); return; } if (!promise) { promise = Promise.resolve().then(() => { promise = void 0; if (isListenerActive) { callback(ops.splice(0)); } }); } }; const removeListener = addListener(listener); isListenerActive = true; return () => { isListenerActive = false; removeListener(); }; } function snapshot(proxyObject, handlePromise) { const proxyState = proxyStateMap.get(proxyObject); if (({ "BASE_URL": "/", "MODE": "production", "DEV": false, "PROD": true, "SSR": false } ? "production" : void 0) !== "production" && !proxyState) { console.warn("Please use proxy object"); } const [target, ensureVersion, createSnapshot] = proxyState; return createSnapshot(target, ensureVersion(), handlePromise); } function ref(obj) { refSet.add(obj); return obj; } function subscribeKey(proxyObject, key, callback, notifyInSync) { let prevValue = proxyObject[key]; return subscribe( proxyObject, () => { const nextValue = proxyObject[key]; if (!Object.is(prevValue, nextValue)) { callback(prevValue = nextValue); } }, notifyInSync ); } function proxyMap(entries2) { const map = proxy({ data: Array.from(entries2 || []), has(key) { return this.data.some((p2) => p2[0] === key); }, set(key, value) { const record = this.data.find((p2) => p2[0] === key); if (record) { record[1] = value; } else { this.data.push([key, value]); } return this; }, get(key) { var _a; return (_a = this.data.find((p2) => p2[0] === key)) == null ? void 0 : _a[1]; }, delete(key) { const index = this.data.findIndex((p2) => p2[0] === key); if (index === -1) { return false; } this.data.splice(index, 1); return true; }, clear() { this.data.splice(0); }, get size() { return this.data.length; }, toJSON() { return new Map(this.data); }, forEach(cb) { this.data.forEach((p2) => { cb(p2[1], p2[0], this); }); }, keys() { return this.data.map((p2) => p2[0]).values(); }, values() { return this.data.map((p2) => p2[1]).values(); }, entries() { return new Map(this.data).entries(); }, get [Symbol.toStringTag]() { return "Map"; }, [Symbol.iterator]() { return this.entries(); } }); Object.defineProperties(map, { data: { enumerable: false }, size: { enumerable: false }, toJSON: { enumerable: false } }); Object.seal(map); return map; } const SECURE_SITE = ( // eslint-disable-next-line @typescript-eslint/prefer-optional-chain (typeof process$1 !== "undefined" && typeof process$1.env !== "undefined" ? process$1.env["NEXT_PUBLIC_SECURE_SITE_ORIGIN"] : void 0) || "https://secure.walletconnect.org" ); const ONRAMP_PROVIDERS = [ { label: "Coinbase", name: "coinbase", feeRange: "1-2%", url: "", supportedChains: ["eip155"] }, { label: "Meld.io", name: "meld", feeRange: "1-2%", url: "https://meldcrypto.com", supportedChains: ["eip155", "solana"] } ]; const MELD_PUBLIC_KEY = "WXETMuFUQmqqybHuRkSgxv:25B8LJHSfpG6LVjR2ytU5Cwh7Z4Sch2ocoU"; const ConstantsUtil$2 = { FOUR_MINUTES_MS: 24e4, TEN_SEC_MS: 1e4, FIVE_SEC_MS: 5e3, THREE_SEC_MS: 3e3, ONE_SEC_MS: 1e3, SECURE_SITE, SECURE_SITE_DASHBOARD: `${SECURE_SITE}/dashboard`, SECURE_SITE_FAVICON: `${SECURE_SITE}/images/favicon.png`, RESTRICTED_TIMEZONES: [ "ASIA/SHANGHAI", "ASIA/URUMQI", "ASIA/CHONGQING", "ASIA/HARBIN", "ASIA/KASHGAR", "ASIA/MACAU", "ASIA/HONG_KONG", "ASIA/MACAO", "ASIA/BEIJING", "ASIA/HARBIN" ], /** * Network name to Coinbase Pay SDK chain name map object * @see supported chain names on Coinbase for Pay SDK: https://github.com/coinbase/cbpay-js/blob/d4bda2c05c4d5917c8db6a05476b603546046394/src/types/onramp.ts */ WC_COINBASE_PAY_SDK_CHAINS: [ "ethereum", "arbitrum", "polygon", "berachain", "avalanche-c-chain", "optimism", "celo", "base" ], WC_COINBASE_PAY_SDK_FALLBACK_CHAIN: "ethereum", WC_COINBASE_PAY_SDK_CHAIN_NAME_MAP: { Ethereum: "ethereum", "Arbitrum One": "arbitrum", Polygon: "polygon", Berachain: "berachain", Avalanche: "avalanche-c-chain", "OP Mainnet": "optimism", Celo: "celo", Base: "base" }, WC_COINBASE_ONRAMP_APP_ID: "bf18c88d-495a-463b-b249-0b9d3656cf5e", SWAP_SUGGESTED_TOKENS: [ "ETH", "UNI", "1INCH", "AAVE", "SOL", "ADA", "AVAX", "DOT", "LINK", "NITRO", "GAIA", "MILK", "TRX", "NEAR", "GNO", "WBTC", "DAI", "WETH", "USDC", "USDT", "ARB", "BAL", "BICO", "CRV", "ENS", "MATIC", "OP" ], SWAP_POPULAR_TOKENS: [ "ETH", "UNI", "1INCH", "AAVE", "SOL", "ADA", "AVAX", "DOT", "LINK", "NITRO", "GAIA", "MILK", "TRX", "NEAR", "GNO", "WBTC", "DAI", "WETH", "USDC", "USDT", "ARB", "BAL", "BICO", "CRV", "ENS", "MATIC", "OP", "METAL", "DAI", "CHAMP", "WOLF", "SALE", "BAL", "BUSD", "MUST", "BTCpx", "ROUTE", "HEX", "WELT", "amDAI", "VSQ", "VISION", "AURUM", "pSP", "SNX", "VC", "LINK", "CHP", "amUSDT", "SPHERE", "FOX", "GIDDY", "GFC", "OMEN", "OX_OLD", "DE", "WNT" ], BALANCE_SUPPORTED_CHAINS: ["eip155", "solana"], SWAP_SUPPORTED_NETWORKS: [ // Ethereum' "eip155:1", // Arbitrum One' "eip155:42161", // Optimism' "eip155:10", // ZKSync Era' "eip155:324", // Base' "eip155:8453", // BNB Smart Chain' "eip155:56", // Polygon' "eip155:137", // Gnosis' "eip155:100", // Avalanche' "eip155:43114", // Fantom' "eip155:250", // Klaytn' "eip155:8217", // Aurora "eip155:1313161554" ], NAMES_SUPPORTED_CHAIN_NAMESPACES: ["eip155"], ONRAMP_SUPPORTED_CHAIN_NAMESPACES: ["eip155", "solana"], ACTIVITY_ENABLED_CHAIN_NAMESPACES: ["eip155"], NATIVE_TOKEN_ADDRESS: { eip155: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", solana: "So11111111111111111111111111111111111111111", polkadot: "0x", bip122: "0x", cosmos: "0x" }, CONVERT_SLIPPAGE_TOLERANCE: 1, CONNECT_LABELS: { MOBILE: "Open and continue in the wallet app", WEB: "Open and continue in the wallet app" }, SEND_SUPPORTED_NAMESPACES: ["eip155", "solana"], DEFAULT_REMOTE_FEATURES: { swaps: ["1inch"], onramp: ["coinbase", "meld"], email: true, socials: [ "google", "x", "discord", "farcaster", "github", "apple", "facebook" ], activity: true, reownBranding: true }, DEFAULT_REMOTE_FEATURES_DISABLED: { email: false, socials: false, swaps: false, onramp: false, activity: false, reownBranding: false }, DEFAULT_FEATURES: { receive: true, send: true, emailShowWallets: true, connectorTypeOrder: [ "walletConnect", "recent", "injected", "featured", "custom", "external", "recommended" ], analytics: true, allWallets: true, legalCheckbox: false, smartSessions: false, collapseWallets: false, walletFeaturesOrder: ["onramp", "swaps", "receive", "send"], connectMethodsOrder: void 0, pay: false }, DEFAULT_SOCIALS: [ "google", "x", "farcaster", "discord", "apple", "github", "facebook" ], DEFAULT_ACCOUNT_TYPES: { bip122: "payment", eip155: "smartAccount", polkadot: "eoa", solana: "eoa" }, ADAPTER_TYPES: { UNIVERSAL: "universal", SOLANA: "solana", WAGMI: "wagmi", ETHERS: "ethers", ETHERS5: "ethers5", BITCOIN: "bitcoin" } }; const StorageUtil = { // Cache expiry in milliseconds cacheExpiry: { portfolio: 3e4, nativeBalance: 3e4, ens: 3e5, identity: 3e5 }, isCacheExpired(timestamp, cacheExpiry) { return Date.now() - timestamp > cacheExpiry; }, getActiveNetworkProps() { const namespace = StorageUtil.getActiveNamespace(); const caipNetworkId = StorageUtil.getActiveCaipNetworkId(); const stringChainId = caipNetworkId ? caipNetworkId.split(":")[1] : void 0; const chainId = stringChainId ? isNaN(Number(stringChainId)) ? stringChainId : Number(stringChainId) : void 0; return { namespace, caipNetworkId, chainId }; }, setWalletConnectDeepLink({ name, href }) { try { SafeLocalStorage.setItem(SafeLocalStorageKeys.DEEPLINK_CHOICE, JSON.stringify({ href, name })); } catch { console.info("Unable to set WalletConnect deep link"); } }, getWalletConnectDeepLink() { try { const deepLink = SafeLocalStorage.getItem(SafeLocalStorageKeys.DEEPLINK_CHOICE); if (deepLink) { return JSON.parse(deepLink); } } catch { console.info("Unable to get WalletConnect deep link"); } return void 0; }, deleteWalletConnectDeepLink() { try { SafeLocalStorage.removeItem(SafeLocalStorageKeys.DEEPLINK_CHOICE); } catch { console.info("Unable to delete WalletConnect deep link"); } }, setActiveNamespace(namespace) { try { SafeLocalStorage.setItem(SafeLocalStorageKeys.ACTIVE_NAMESPACE, namespace); } catch { console.info("Unable to set active namespace"); } }, setActiveCaipNetworkId(caipNetworkId) { try { SafeLocalStorage.setItem(SafeLocalStorageKeys.ACTIVE_CAIP_NETWORK_ID, caipNetworkId); StorageUtil.setActiveNamespace(caipNetworkId.split(":")[0]); } catch { console.info("Unable to set active caip network id"); } }, getActiveCaipNetworkId() { try { return SafeLocalStorage.getItem(SafeLocalStorageKeys.ACTIVE_CAIP_NETWORK_ID); } catch { console.info("Unable to get active caip network id"); return void 0; } }, deleteActiveCaipNetworkId() { try { SafeLocalStorage.removeItem(SafeLocalStorageKeys.ACTIVE_CAIP_NETWORK_ID); } catch { console.info("Unable to delete active caip network id"); } }, deleteConnectedConnectorId(namespace) { try { const key = getSafeConnectorIdKey(namespace); SafeLocalStorage.removeItem(key); } catch { console.info("Unable to delete connected connector id"); } }, setAppKitRecent(wallet) { try { const recentWallets = StorageUtil.getRecentWallets(); const exists = recentWallets.find((w2) => w2.id === wallet.id); if (!exists) { recentWallets.unshift(wallet); if (recentWallets.length > 2) { recentWallets.pop(); } SafeLocalStorage.setItem(SafeLocalStorageKeys.RECENT_WALLETS, JSON.stringify(recentWallets)); } } catch { console.info("Unable to set AppKit recent"); } }, getRecentWallets() { try { const recent = SafeLocalStorage.getItem(SafeLocalStorageKeys.RECENT_WALLETS); return recent ? JSON.parse(recent) : []; } catch { console.info("Unable to get AppKit recent"); } return []; }, setConnectedConnectorId(namespace, connectorId) { try { const key = getSafeConnectorIdKey(namespace); SafeLocalStorage.setItem(key, connectorId); } catch { console.info("Unable to set Connected Connector Id"); } }, getActiveNamespace() { try { const activeNamespace = SafeLocalStorage.getItem(SafeLocalStorageKeys.ACTIVE_NAMESPACE); return activeNamespace; } catch { console.info("Unable to get active namespace"); } return void 0; }, getConnectedConnectorId(namespace) { if (!namespace) { return void 0; } try { const key = getSafeConnectorIdKey(namespace); return SafeLocalStorage.getItem(key); } catch (e2) { console.info("Unable to get connected connector id in namespace ", namespace); } return void 0; }, setConnectedSocialProvider(socialProvider) { try { SafeLocalStorage.setItem(SafeLocalStorageKeys.CONNECTED_SOCIAL, socialProvider); } catch { console.info("Unable to set connected social provider"); } }, getConnectedSocialProvider() { try { return SafeLocalStorage.getItem(SafeLocalStorageKeys.CONNECTED_SOCIAL); } catch { console.info("Unable to get connected social provider"); } return void 0; }, deleteConnectedSocialProvider() { try { SafeLocalStorage.removeItem(SafeLocalStorageKeys.CONNECTED_SOCIAL); } catch { console.info("Unable to delete connected social provider"); } }, getConnectedSocialUsername() { try { return SafeLocalStorage.getItem(SafeLocalStorageKeys.CONNECTED_SOCIAL_USERNAME); } catch { console.info("Unable to get connected social username"); } return void 0; }, getStoredActiveCaipNetworkId() { const storedCaipNetworkId = SafeLocalStorage.getItem(SafeLocalStorageKeys.ACTIVE_CAIP_NETWORK_ID); const networkId = storedCaipNetworkId?.split(":")?.[1]; return networkId; }, setConnectionStatus(status) { try { SafeLocalStorage.setItem(SafeLocalStorageKeys.CONNECTION_STATUS, status); } catch { console.info("Unable to set connection status"); } }, getConnectionStatus() { try { return SafeLocalStorage.getItem(SafeLocalStorageKeys.CONNECTION_STATUS); } catch { return void 0; } }, getConnectedNamespaces() { try { const namespaces = SafeLocalStorage.getItem(SafeLocalStorageKeys.CONNECTED_NAMESPACES); if (!namespaces?.length) { return []; } return namespaces.split(","); } catch { return []; } }, setConnectedNamespaces(namespaces) { try { const uniqueNamespaces = Array.from(new Set(namespaces)); SafeLocalStorage.setItem(SafeLocalStorageKeys.CONNECTED_NAMESPACES, uniqueNamespaces.join(",")); } catch { console.info("Unable to set namespaces in storage"); } }, addConnectedNamespace(namespace) {