@solana/connector 0.1.9 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +403 -50
- package/dist/chunk-4KD6HQQG.js +69 -0
- package/dist/chunk-4KD6HQQG.js.map +1 -0
- package/dist/chunk-BJAVJQLK.js +230 -0
- package/dist/chunk-BJAVJQLK.js.map +1 -0
- package/dist/{chunk-5HRJKCIL.js → chunk-BZ2VBJCZ.js} +1061 -424
- package/dist/chunk-BZ2VBJCZ.js.map +1 -0
- package/dist/{chunk-WDXEP4AJ.js → chunk-EM4KNOKG.js} +658 -190
- package/dist/chunk-EM4KNOKG.js.map +1 -0
- package/dist/chunk-HN5AJF7F.js +507 -0
- package/dist/chunk-HN5AJF7F.js.map +1 -0
- package/dist/chunk-HO6QNKFM.mjs +61 -0
- package/dist/chunk-HO6QNKFM.mjs.map +1 -0
- package/dist/chunk-HPQ5T32K.mjs +178 -0
- package/dist/chunk-HPQ5T32K.mjs.map +1 -0
- package/dist/{chunk-MAXA3HEP.mjs → chunk-IDTUFDNB.mjs} +962 -344
- package/dist/chunk-IDTUFDNB.mjs.map +1 -0
- package/dist/{chunk-P5LXUDP6.mjs → chunk-RTXUS5KG.mjs} +579 -119
- package/dist/chunk-RTXUS5KG.mjs.map +1 -0
- package/dist/{chunk-DSUCH44G.js → chunk-SITQ4JWM.js} +23 -67
- package/dist/chunk-SITQ4JWM.js.map +1 -0
- package/dist/chunk-UCISIAOG.mjs +501 -0
- package/dist/chunk-UCISIAOG.mjs.map +1 -0
- package/dist/{chunk-J7DHGLW6.mjs → chunk-ZZTY3O4N.mjs} +21 -61
- package/dist/chunk-ZZTY3O4N.mjs.map +1 -0
- package/dist/compat.d.mts +1 -1
- package/dist/compat.d.ts +1 -1
- package/dist/compat.js +10 -9
- package/dist/compat.js.map +1 -1
- package/dist/compat.mjs +2 -1
- package/dist/compat.mjs.map +1 -1
- package/dist/headless.d.mts +239 -104
- package/dist/headless.d.ts +239 -104
- package/dist/headless.js +255 -169
- package/dist/headless.mjs +5 -3
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +316 -206
- package/dist/index.mjs +6 -4
- package/dist/react.d.mts +299 -9
- package/dist/react.d.ts +299 -9
- package/dist/react.js +90 -38
- package/dist/react.mjs +2 -2
- package/dist/{standard-shim-CT49DM5l.d.mts → standard-shim-CGB88PPO.d.mts} +673 -52
- package/dist/{standard-shim-D9guL5fz.d.ts → standard-shim-tmnQelaJ.d.ts} +673 -52
- package/dist/{transaction-signer-T-KVQFi8.d.mts → transaction-signer-7NaYmP5w.d.mts} +1 -0
- package/dist/{transaction-signer-T-KVQFi8.d.ts → transaction-signer-7NaYmP5w.d.ts} +1 -0
- package/dist/walletconnect-447EY3OJ.js +28 -0
- package/dist/walletconnect-447EY3OJ.js.map +1 -0
- package/dist/walletconnect-U455PO4I.mjs +3 -0
- package/dist/walletconnect-U455PO4I.mjs.map +1 -0
- package/package.json +6 -2
- package/dist/chunk-5HRJKCIL.js.map +0 -1
- package/dist/chunk-DSUCH44G.js.map +0 -1
- package/dist/chunk-I6TJLYNA.js +0 -535
- package/dist/chunk-I6TJLYNA.js.map +0 -1
- package/dist/chunk-J7DHGLW6.mjs.map +0 -1
- package/dist/chunk-JOBLG62A.mjs +0 -476
- package/dist/chunk-JOBLG62A.mjs.map +0 -1
- package/dist/chunk-MAXA3HEP.mjs.map +0 -1
- package/dist/chunk-P5LXUDP6.mjs.map +0 -1
- package/dist/chunk-WDXEP4AJ.js.map +0 -1
|
@@ -1,11 +1,55 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
1
|
+
import { tryCatchSync, isWeb3jsTransaction, prepareTransactionForWallet, convertSignedTransaction } from './chunk-HO6QNKFM.mjs';
|
|
2
|
+
import { createLogger, getPublicSolanaRpcUrl, getExplorerLink, __publicField, TransactionError, Errors, ValidationError } from './chunk-ZZTY3O4N.mjs';
|
|
4
3
|
import { install } from '@solana/webcrypto-ed25519-polyfill';
|
|
5
|
-
import {
|
|
4
|
+
import { Storage, createSolanaMainnet, createSolanaDevnet, createSolanaTestnet, createSolanaLocalnet } from '@wallet-ui/core';
|
|
5
|
+
import { isAddress, address } from '@solana/addresses';
|
|
6
|
+
import { z } from 'zod/v4';
|
|
6
7
|
import { getBase58Decoder } from '@solana/codecs';
|
|
7
8
|
import { getTransactionDecoder, assertIsTransactionWithinSizeLimit } from '@solana/transactions';
|
|
8
9
|
|
|
10
|
+
// src/types/session.ts
|
|
11
|
+
function createConnectorId(walletName) {
|
|
12
|
+
return `wallet-standard:${walletName.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "")}`;
|
|
13
|
+
}
|
|
14
|
+
function isWalletConnectorId(value) {
|
|
15
|
+
return typeof value == "string" && (value.startsWith("wallet-standard:") || value === "walletconnect" || value.startsWith("mwa:"));
|
|
16
|
+
}
|
|
17
|
+
function getWalletNameFromConnectorId(connectorId) {
|
|
18
|
+
return connectorId === "walletconnect" ? "WalletConnect" : connectorId.startsWith("mwa:") ? connectorId.slice(4) : connectorId.startsWith("wallet-standard:") ? connectorId.slice(16).split("-").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ") : connectorId;
|
|
19
|
+
}
|
|
20
|
+
function isDisconnected(status) {
|
|
21
|
+
return status.status === "disconnected";
|
|
22
|
+
}
|
|
23
|
+
function isConnecting(status) {
|
|
24
|
+
return status.status === "connecting";
|
|
25
|
+
}
|
|
26
|
+
function isConnected(status) {
|
|
27
|
+
return status.status === "connected";
|
|
28
|
+
}
|
|
29
|
+
function isStatusError(status) {
|
|
30
|
+
return status.status === "error";
|
|
31
|
+
}
|
|
32
|
+
var isWalletStatusError = isStatusError, INITIAL_WALLET_STATUS = {
|
|
33
|
+
status: "disconnected"
|
|
34
|
+
};
|
|
35
|
+
function toLegacyWalletState(wallet) {
|
|
36
|
+
switch (wallet.status) {
|
|
37
|
+
case "disconnected":
|
|
38
|
+
return { connected: false, connecting: false, selectedAccount: null, accounts: [] };
|
|
39
|
+
case "connecting":
|
|
40
|
+
return { connected: false, connecting: true, selectedAccount: null, accounts: [] };
|
|
41
|
+
case "connected":
|
|
42
|
+
return {
|
|
43
|
+
connected: true,
|
|
44
|
+
connecting: false,
|
|
45
|
+
selectedAccount: wallet.session.selectedAccount.address,
|
|
46
|
+
accounts: wallet.session.accounts.map((a) => ({ address: a.address, label: a.label }))
|
|
47
|
+
};
|
|
48
|
+
case "error":
|
|
49
|
+
return { connected: false, connecting: false, selectedAccount: null, accounts: [] };
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
9
53
|
// src/lib/wallet/standard-shim.ts
|
|
10
54
|
var registry = null, registryInitPromise = null, registryInitResolve = null, ready = new Promise((resolve, reject) => {
|
|
11
55
|
if (typeof window > "u") {
|
|
@@ -620,8 +664,43 @@ var logger2 = createLogger("WalletAuthenticity"), WalletAuthenticityVerifier = c
|
|
|
620
664
|
}
|
|
621
665
|
};
|
|
622
666
|
|
|
667
|
+
// src/lib/wallet/wallet-icon-overrides.ts
|
|
668
|
+
var PHANTOM_ICON = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiBmaWxsPSIjOTc4NkU0Ii8+CjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMF80NF82MTApIj4KPHBhdGggZD0iTTUuNzY1NSAxNS43OTdDNS43NjU1IDE3LjIyMiA2LjQ5ODc5IDE3LjU1IDcuMjYxNDEgMTcuNTVDOC44NzQ2MyAxNy41NSAxMC4wODcgMTYuMDg0MSAxMC44MTA1IDE0LjkyNTZDMTAuNzIyNSAxNS4xODE5IDEwLjY3MzYgMTUuNDM4MiAxMC42NzM2IDE1LjY4NDJDMTAuNjczNiAxNi4zNjA5IDExLjA0NTIgMTYuODQyNyAxMS43Nzg1IDE2Ljg0MjdDMTIuNzg1NSAxNi44NDI3IDEzLjg2MSAxNS45MiAxNC40MTgzIDE0LjkyNTZDMTQuMzc5MiAxNS4wNjkyIDE0LjM1OTYgMTUuMjAyNCAxNC4zNTk2IDE1LjMyNTRDMTQuMzU5NiAxNS43OTcgMTQuNjEzOCAxNi4wOTQzIDE1LjEzMiAxNi4wOTQzQzE2Ljc2NDggMTYuMDk0MyAxOC40MDc0IDEzLjA3MDEgMTguNDA3NCAxMC40MjUyQzE4LjQwNzQgOC4zNjQ1OSAxNy40MTAxIDYuNTUwMDUgMTQuOTA3MSA2LjU1MDA1QzEwLjUwNzQgNi41NTAwNSA1Ljc2NTUgMTIuMTY3OSA1Ljc2NTUgMTUuNzk3Wk0xMy4zOTE3IDEwLjE5OTZDMTMuMzkxNyA5LjY4NzA1IDEzLjY2NTQgOS4zMjgyNSAxNC4wNjYzIDkuMzI4MjVDMTQuNDU3NCA5LjMyODI1IDE0LjczMTIgOS42ODcwNSAxNC43MzEyIDEwLjE5OTZDMTQuNzMxMiAxMC43MTIyIDE0LjQ1NzQgMTEuMDgxMyAxNC4wNjYzIDExLjA4MTNDMTMuNjY1NCAxMS4wODEzIDEzLjM5MTcgMTAuNzEyMiAxMy4zOTE3IDEwLjE5OTZaTTE1LjQ4NCAxMC4xOTk2QzE1LjQ4NCA5LjY4NzA1IDE1Ljc1NzggOS4zMjgyNSAxNi4xNTg2IDkuMzI4MjVDMTYuNTQ5NyA5LjMyODI1IDE2LjgyMzUgOS42ODcwNSAxNi44MjM1IDEwLjE5OTZDMTYuODIzNSAxMC43MTIyIDE2LjU0OTcgMTEuMDgxMyAxNi4xNTg2IDExLjA4MTNDMTUuNzU3OCAxMS4wODEzIDE1LjQ4NCAxMC43MTIyIDE1LjQ4NCAxMC4xOTk2WiIgZmlsbD0iI0ZFRkRGOCIvPgo8L2c+CjxkZWZzPgo8Y2xpcFBhdGggaWQ9ImNsaXAwXzQ0XzYxMCI+CjxyZWN0IHdpZHRoPSIxMi43NiIgaGVpZ2h0PSIxMSIgZmlsbD0id2hpdGUiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDUuNzA2NDIgNi41NDk5MykiLz4KPC9jbGlwUGF0aD4KPC9kZWZzPgo8L3N2Zz4=", SOLFLARE_ICON = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiBmaWxsPSIjRkZFRjQ2Ii8+CjxwYXRoIGQ9Ik0xMi4xMjg1IDEyLjUyNjZMMTIuOTU1NiAxMS43Mjc2TDE0LjQ5NzYgMTIuMjMyM0MxNS41MDcgMTIuNTY4NyAxNi4wMTE3IDEzLjE4NTUgMTYuMDExNyAxNC4wNTQ3QzE2LjAxMTcgMTQuNzEzNiAxNS43NTkzIDE1LjE0ODIgMTUuMjU0NyAxNS43MDg5TDE1LjEwMDUgMTUuODc3MUwxNS4xNTY1IDE1LjQ4NDZDMTUuMzgwOCAxNC4wNTQ3IDE0Ljk2MDMgMTMuNDM3OSAxMy41NzI0IDEyLjk4OTJMMTIuMTI4NSAxMi41MjY2Wk0xMC4wNTM3IDcuNjM0MTRMMTQuMjU5MyA5LjAzNkwxMy4zNDgxIDkuOTA1MTdMMTEuMTYxMiA5LjE3NjE5QzEwLjQwNDIgOC45MjM4NSAxMC4xNTE4IDguNTE3MzEgMTAuMDUzNyA3LjY2MjE3VjcuNjM0MTRaTTkuODAxMzUgMTQuNzU1NkwxMC43NTQ2IDEzLjg0NDRMMTIuNTQ5MSAxNC40MzMyQzEzLjQ4ODMgMTQuNzQxNiAxMy44MTA3IDE1LjE0ODIgMTMuNzEyNiAxNi4xNzE1TDkuODAxMzUgMTQuNzU1NlpNOC41OTU3NyAxMC42OTAyQzguNTk1NzcgMTAuNDIzOSA4LjczNTk1IDEwLjE3MTUgOC45NzQyNyA5Ljk2MTIyQzkuMjI2NjEgMTAuMzI1NyA5LjY2MTE4IDEwLjY0ODEgMTAuMzQ4MSAxMC44NzI1TDExLjgzNDEgMTEuMzYzMUwxMS4wMDcgMTIuMTYyMkw5LjU0OTAzIDExLjY4NTVDOC44NzYxNCAxMS40NjEyIDguNTk1NzcgMTEuMTI0OCA4LjU5NTc3IDEwLjY5MDJaTTEyLjk5NzYgMTguMDVDMTYuMDgxNyAxNi4wMDMzIDE3LjczNTkgMTQuNjE1NCAxNy43MzU5IDEyLjkwNTJDMTcuNzM1OSAxMS43Njk2IDE3LjA2MyAxMS4xMzg4IDE1LjU3NzEgMTAuNjQ4MUwxNC40NTU2IDEwLjI2OTZMMTcuNTI1NyA3LjMyNTcyTDE2LjkwODggNi42NjY4NEwxNS45OTc2IDcuNDY1OUwxMS42OTM5IDYuMDUwMDJDMTAuMzYyMSA2LjQ4NDYgOC42Nzk4OCA3Ljc2MDMgOC42Nzk4OCA5LjAzNkM4LjY3OTg4IDkuMTc2MTggOC42OTM5IDkuMzE2MzcgOC43MzU5NSA5LjQ3MDU5QzcuNjI4NDcgMTAuMTAxNCA3LjE3OTg4IDEwLjY5MDIgNy4xNzk4OCAxMS40MTkxQzcuMTc5ODggMTIuMTA2MSA3LjU0NDM2IDEyLjc5MyA4LjcwNzkyIDEzLjE3MTVMOS42MzMxNCAxMy40Nzk5TDYuNDM2ODkgMTYuNTVMNy4wNTM3MSAxNy4yMDg5TDguMDQ5MDQgMTYuMjk3N0wxMi45OTc2IDE4LjA1WiIgZmlsbD0iIzAyMDUwQSIvPgo8L3N2Zz4=", BACKPACK_ICON = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiBmaWxsPSIjRTMzRTNGIi8+CjxwYXRoIGQ9Ik0xNS41MTg2IDEzLjkyNzJDMTUuOTgxMSAxMy45MjcyIDE2LjIxMjcgMTMuOTI3MSAxNi4zNTY0IDE0LjA3MDhDMTYuNTAwMiAxNC4yMTQ1IDE2LjUgMTQuNDQ2MiAxNi41IDE0LjkwODdWMTUuNTY0QzE2LjUgMTYuNDg5MyAxNi41MDAyIDE2Ljk1MjIgMTYuMjEyOSAxNy4yMzk3QzE1LjkyNTMgMTcuNTI3MyAxNS40NjE4IDE3LjUyNzggMTQuNTM2MSAxNy41Mjc4SDkuNDYzODdDOC41Mzg0MiAxNy41Mjc4IDguMDc1NjcgMTcuNTI3MSA3Ljc4ODA5IDE3LjIzOTdDNy41MDA1NCAxNi45NTIyIDcuNSAxNi40ODk0IDcuNSAxNS41NjRWMTQuOTA4N0M3LjUgMTQuNDQ2MiA3LjQ5OTgyIDE0LjIxNDUgNy42NDM1NSAxNC4wNzA4QzcuNzg3MyAxMy45MjcxIDguMDE4OTEgMTMuOTI3MiA4LjQ4MTQ1IDEzLjkyNzJIMTUuNTE4NlpNMTIgNi4zNTg4OUMxNi41NjUzIDYuMzU4ODkgMTYuNSA5LjQwMjM4IDE2LjUgMTAuODU4OVYxMi40OTU2QzE2LjQ5OTkgMTIuNzY2NyAxNi4yNzk5IDEyLjk4NjggMTYuMDA4OCAxMi45ODY4SDcuOTkxMjFDNy43MjAxMiAxMi45ODY4IDcuNTAwMDYgMTIuNzY2NyA3LjUgMTIuNDk1NkM3LjUgMTIuNDk1NiA3LjUgMTIuMzE1MyA3LjUgMTAuODU4OUM3LjQ5OTk5IDkuNDAyMzkgNy40MzQ3OCA2LjM1ODkzIDEyIDYuMzU4ODlaTTEyIDcuNTE5MDRDMTEuMjMxOSA3LjUxOTEgMTAuNjA5NCA4LjE0MTU1IDEwLjYwOTQgOC45MDk2N0MxMC42MDk0IDkuNjc3NzggMTEuMjMxOSAxMC4zMDAyIDEyIDEwLjMwMDNDMTIuNzY4MiAxMC4zMDAzIDEzLjM5MDYgOS42Nzc4MiAxMy4zOTA2IDguOTA5NjdDMTMuMzkwNiA4LjE0MTUxIDEyLjc2ODIgNy41MTkwNCAxMiA3LjUxOTA0Wk0xMS45OTkgNC40NzIxN0MxMi45ODQxIDQuNDcyMjIgMTMuODQ2MiA0LjgxNjczIDE0LjA3NDIgNS4zNzc0NEMxNC4xMDg1IDUuNDczODcgMTQuMTI1OCA1LjUyMjIyIDE0LjA5NTcgNS41NTgxMUMxNC4wNjUyIDUuNTk0MDIgMTQuMDA1OCA1LjU4MzQyIDEzLjg4NzcgNS41NjIwMUMxMy41ODIyIDUuNTA2NjUgMTMuMTQ5MyA1LjQ2ODc3IDEyLjc2ODYgNS40NTc1MkMxMi41MjU4IDUuNDQ0NDggMTIuMjY5NSA1LjQzNzk5IDEyIDUuNDM3OTlDMTEuNzMwNSA1LjQzNzk5IDExLjQ3NDIgNS40NDQ0OCAxMS4yMzE0IDUuNDU3NTJDMTAuODQ5IDUuNDY4NzcgMTAuNDE0OSA1LjUwNjU4IDEwLjEwODQgNS41NjAwNkM5Ljk5MzM1IDUuNTgwMTMgOS45MzU2NSA1LjU5MDQ3IDkuOTA1MjcgNS41NTUxOEM5Ljg3NDk3IDUuNTE5MzUgOS44OTEyOCA1LjQ3MTQ0IDkuOTI0OCA1LjM3NjQ2QzEwLjE1MSA0LjgxNzQ4IDExLjAxNDIgNC40NzIxNyAxMS45OTkgNC40NzIxN1oiIGZpbGw9IndoaXRlIi8+Cjwvc3ZnPg==", WALLET_ICON_OVERRIDES = {
|
|
669
|
+
Phantom: PHANTOM_ICON,
|
|
670
|
+
Solflare: SOLFLARE_ICON,
|
|
671
|
+
Backpack: BACKPACK_ICON
|
|
672
|
+
}, ICON_PROXY_CACHE = /* @__PURE__ */ new WeakMap();
|
|
673
|
+
function getWalletIconOverride(walletName) {
|
|
674
|
+
return WALLET_ICON_OVERRIDES[walletName];
|
|
675
|
+
}
|
|
676
|
+
function createIconProxy(wallet, icon) {
|
|
677
|
+
let cached = ICON_PROXY_CACHE.get(wallet);
|
|
678
|
+
if (cached) return cached;
|
|
679
|
+
let proxy = new Proxy(wallet, {
|
|
680
|
+
get(target, prop) {
|
|
681
|
+
if (prop === "icon") return icon;
|
|
682
|
+
let value = Reflect.get(target, prop, target);
|
|
683
|
+
return typeof value == "function" ? value.bind(target) : value;
|
|
684
|
+
}
|
|
685
|
+
});
|
|
686
|
+
return ICON_PROXY_CACHE.set(wallet, proxy), proxy;
|
|
687
|
+
}
|
|
688
|
+
function applyWalletIconOverride(wallet) {
|
|
689
|
+
let override = getWalletIconOverride(wallet.name);
|
|
690
|
+
if (!override || wallet.icon === override) return wallet;
|
|
691
|
+
if (Object.isExtensible(wallet))
|
|
692
|
+
try {
|
|
693
|
+
return wallet.icon = override, wallet;
|
|
694
|
+
} catch {
|
|
695
|
+
}
|
|
696
|
+
return createIconProxy(wallet, override);
|
|
697
|
+
}
|
|
698
|
+
|
|
623
699
|
// src/lib/wallet/detector.ts
|
|
624
700
|
var logger3 = createLogger("WalletDetector");
|
|
701
|
+
function isSolanaWallet(wallet) {
|
|
702
|
+
return Array.isArray(wallet.chains) && wallet.chains.some((chain) => typeof chain == "string" && chain.startsWith("solana:"));
|
|
703
|
+
}
|
|
625
704
|
function hasFeature(wallet, featureName) {
|
|
626
705
|
return wallet.features != null && wallet.features[featureName] !== void 0;
|
|
627
706
|
}
|
|
@@ -644,6 +723,8 @@ var WalletDetector = class extends BaseCollaborator {
|
|
|
644
723
|
constructor(stateManager, eventEmitter, debug = false) {
|
|
645
724
|
super({ stateManager, eventEmitter, debug }, "WalletDetector");
|
|
646
725
|
__publicField(this, "unsubscribers", []);
|
|
726
|
+
/** Map from stable connector ID to Wallet reference (not stored in state) */
|
|
727
|
+
__publicField(this, "connectorRegistry", /* @__PURE__ */ new Map());
|
|
647
728
|
}
|
|
648
729
|
/**
|
|
649
730
|
* Initialize wallet detection (synchronous)
|
|
@@ -659,11 +740,10 @@ var WalletDetector = class extends BaseCollaborator {
|
|
|
659
740
|
if (!(typeof window > "u"))
|
|
660
741
|
try {
|
|
661
742
|
let walletsApi = getWalletsRegistry(), update = () => {
|
|
662
|
-
let
|
|
663
|
-
newCount !== previousCount && this.log("\u{1F50D} WalletDetector: found wallets:", newCount)
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
wallets: unique.map((w) => this.mapToWalletInfo(w))
|
|
743
|
+
let solanaWallets = walletsApi.get().filter(isSolanaWallet), unique = this.deduplicateWallets(solanaWallets), previousCount = this.getState().wallets.length, newCount = unique.length;
|
|
744
|
+
newCount !== previousCount && this.log("\u{1F50D} WalletDetector: found wallets:", newCount), this.updateConnectorRegistry(unique), this.stateManager.updateState({
|
|
745
|
+
wallets: unique.map((w) => this.mapToWalletInfo(w)),
|
|
746
|
+
connectors: unique.map((w) => this.mapToConnectorMetadata(w))
|
|
667
747
|
}), newCount !== previousCount && newCount > 0 && this.eventEmitter.emit({
|
|
668
748
|
type: "wallets:detected",
|
|
669
749
|
count: newCount,
|
|
@@ -741,20 +821,64 @@ var WalletDetector = class extends BaseCollaborator {
|
|
|
741
821
|
return null;
|
|
742
822
|
}
|
|
743
823
|
/**
|
|
744
|
-
* Get currently detected wallets
|
|
824
|
+
* Get currently detected wallets (legacy)
|
|
825
|
+
* @deprecated Use getConnectors() for vNext API
|
|
745
826
|
*/
|
|
746
827
|
getDetectedWallets() {
|
|
747
828
|
return this.getState().wallets;
|
|
748
829
|
}
|
|
749
830
|
/**
|
|
750
|
-
*
|
|
831
|
+
* Get all available connectors (vNext API)
|
|
832
|
+
*/
|
|
833
|
+
getConnectors() {
|
|
834
|
+
return this.getState().connectors;
|
|
835
|
+
}
|
|
836
|
+
/**
|
|
837
|
+
* Get a wallet by its stable connector ID (vNext API)
|
|
838
|
+
* Returns the Wallet reference for connection operations
|
|
839
|
+
*/
|
|
840
|
+
getConnectorById(connectorId) {
|
|
841
|
+
return this.connectorRegistry.get(connectorId);
|
|
842
|
+
}
|
|
843
|
+
/**
|
|
844
|
+
* Get connector metadata by ID
|
|
845
|
+
*/
|
|
846
|
+
getConnectorMetadata(connectorId) {
|
|
847
|
+
return this.getState().connectors.find((c) => c.id === connectorId);
|
|
848
|
+
}
|
|
849
|
+
/**
|
|
850
|
+
* Update the connector registry map
|
|
851
|
+
*/
|
|
852
|
+
updateConnectorRegistry(wallets) {
|
|
853
|
+
this.connectorRegistry.clear();
|
|
854
|
+
for (let wallet of wallets) {
|
|
855
|
+
let connectorId = createConnectorId(wallet.name);
|
|
856
|
+
this.connectorRegistry.set(connectorId, wallet);
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
/**
|
|
860
|
+
* Convert a Wallet Standard wallet to WalletConnectorMetadata (serializable)
|
|
861
|
+
*/
|
|
862
|
+
mapToConnectorMetadata(wallet) {
|
|
863
|
+
let walletWithIcon = applyWalletIconOverride(wallet), hasConnect = hasFeature(walletWithIcon, "standard:connect"), isSolana = isSolanaWallet(walletWithIcon), ready2 = hasConnect && isSolana;
|
|
864
|
+
return {
|
|
865
|
+
id: createConnectorId(wallet.name),
|
|
866
|
+
name: wallet.name,
|
|
867
|
+
icon: typeof walletWithIcon.icon == "string" ? walletWithIcon.icon : "",
|
|
868
|
+
ready: ready2,
|
|
869
|
+
chains: walletWithIcon.chains ?? [],
|
|
870
|
+
features: Object.keys(walletWithIcon.features ?? {})
|
|
871
|
+
};
|
|
872
|
+
}
|
|
873
|
+
/**
|
|
874
|
+
* Convert a Wallet Standard wallet to WalletInfo with capability checks (legacy)
|
|
751
875
|
*/
|
|
752
876
|
mapToWalletInfo(wallet) {
|
|
753
|
-
let
|
|
877
|
+
let walletWithIcon = applyWalletIconOverride(wallet), hasConnect = hasFeature(walletWithIcon, "standard:connect"), isSolana = isSolanaWallet(walletWithIcon);
|
|
754
878
|
return {
|
|
755
|
-
wallet,
|
|
879
|
+
wallet: walletWithIcon,
|
|
756
880
|
installed: true,
|
|
757
|
-
connectable: hasConnect &&
|
|
881
|
+
connectable: hasConnect && isSolana
|
|
758
882
|
};
|
|
759
883
|
}
|
|
760
884
|
/**
|
|
@@ -797,26 +921,258 @@ var ConnectionManager = class extends BaseCollaborator {
|
|
|
797
921
|
__publicField(this, "walletChangeUnsub", null);
|
|
798
922
|
__publicField(this, "pollTimer", null);
|
|
799
923
|
__publicField(this, "pollAttempts", 0);
|
|
924
|
+
__publicField(this, "connectAttemptId", 0);
|
|
925
|
+
__publicField(this, "pendingWallet", null);
|
|
926
|
+
__publicField(this, "pendingWalletName", null);
|
|
800
927
|
this.walletStorage = walletStorage;
|
|
801
928
|
}
|
|
929
|
+
// ========================================================================
|
|
930
|
+
// vNext Connection Methods (connector-id based, silent-first)
|
|
931
|
+
// ========================================================================
|
|
932
|
+
/**
|
|
933
|
+
* Connect to a wallet using the vNext API with silent-first support.
|
|
934
|
+
*
|
|
935
|
+
* @param wallet - Wallet Standard wallet instance
|
|
936
|
+
* @param connectorId - Stable connector identifier
|
|
937
|
+
* @param options - Connection options (silent mode, preferred account, etc.)
|
|
938
|
+
*/
|
|
939
|
+
async connectWallet(wallet, connectorId, options) {
|
|
940
|
+
if (typeof window > "u") return;
|
|
941
|
+
let attemptId = ++this.connectAttemptId;
|
|
942
|
+
this.pendingWallet = wallet, this.pendingWalletName = wallet.name;
|
|
943
|
+
let { silent = false, allowInteractiveFallback = true, preferredAccount } = options ?? {};
|
|
944
|
+
this.updateWalletStatus({
|
|
945
|
+
status: "connecting",
|
|
946
|
+
connectorId
|
|
947
|
+
}), this.stateManager.updateState({ connecting: true }, true), this.eventEmitter.emit({
|
|
948
|
+
type: "connecting",
|
|
949
|
+
wallet: wallet.name,
|
|
950
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
951
|
+
});
|
|
952
|
+
try {
|
|
953
|
+
let connect = getConnectFeature(wallet);
|
|
954
|
+
if (!connect) throw new Error(`Wallet ${wallet.name} does not support standard connect`);
|
|
955
|
+
let result;
|
|
956
|
+
if (silent)
|
|
957
|
+
try {
|
|
958
|
+
if (result = await connect({ silent: true }), attemptId !== this.connectAttemptId) throw new Error("Connection cancelled");
|
|
959
|
+
let hasAccounts = result.accounts.length > 0 || wallet.accounts.length > 0;
|
|
960
|
+
if (!hasAccounts && allowInteractiveFallback)
|
|
961
|
+
this.log("Silent connect returned no accounts, trying interactive..."), result = await connect({ silent: false });
|
|
962
|
+
else if (!hasAccounts)
|
|
963
|
+
throw new Error("Silent connection failed: no accounts returned");
|
|
964
|
+
} catch (silentError) {
|
|
965
|
+
if (attemptId !== this.connectAttemptId) throw new Error("Connection cancelled");
|
|
966
|
+
if (allowInteractiveFallback)
|
|
967
|
+
this.log("Silent connect failed, trying interactive...", silentError), result = await connect({ silent: false });
|
|
968
|
+
else
|
|
969
|
+
throw silentError;
|
|
970
|
+
}
|
|
971
|
+
else
|
|
972
|
+
result = await connect({ silent: false });
|
|
973
|
+
if (attemptId !== this.connectAttemptId) throw new Error("Connection cancelled");
|
|
974
|
+
let walletAccounts = wallet.accounts, accountMap = /* @__PURE__ */ new Map();
|
|
975
|
+
for (let a of [...walletAccounts, ...result.accounts]) accountMap.set(a.address, a);
|
|
976
|
+
let sessionAccounts = Array.from(accountMap.values()).map((a) => ({
|
|
977
|
+
address: a.address,
|
|
978
|
+
label: a.label,
|
|
979
|
+
account: a
|
|
980
|
+
})), legacyAccounts = sessionAccounts.map((a) => this.toAccountInfo(a.account)), selectedAccount = sessionAccounts[0];
|
|
981
|
+
if (preferredAccount) {
|
|
982
|
+
let preferred = sessionAccounts.find((a) => a.address === preferredAccount);
|
|
983
|
+
preferred && (selectedAccount = preferred);
|
|
984
|
+
}
|
|
985
|
+
let session = this.createSession(wallet, connectorId, sessionAccounts, selectedAccount);
|
|
986
|
+
this.updateWalletStatus({
|
|
987
|
+
status: "connected",
|
|
988
|
+
session
|
|
989
|
+
}), this.stateManager.updateState(
|
|
990
|
+
{
|
|
991
|
+
selectedWallet: wallet,
|
|
992
|
+
connected: true,
|
|
993
|
+
connecting: false,
|
|
994
|
+
accounts: legacyAccounts,
|
|
995
|
+
selectedAccount: selectedAccount?.address ?? null
|
|
996
|
+
},
|
|
997
|
+
true
|
|
998
|
+
), this.log("\u2705 Connection successful (vNext)", {
|
|
999
|
+
connectorId,
|
|
1000
|
+
selectedAccount: selectedAccount?.address,
|
|
1001
|
+
accountsCount: sessionAccounts.length
|
|
1002
|
+
}), selectedAccount && this.eventEmitter.emit({
|
|
1003
|
+
type: "wallet:connected",
|
|
1004
|
+
wallet: wallet.name,
|
|
1005
|
+
account: selectedAccount.address,
|
|
1006
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
1007
|
+
}), this.walletStorage && (!("isAvailable" in this.walletStorage) || typeof this.walletStorage.isAvailable != "function" || this.walletStorage.isAvailable()) && this.walletStorage.set(wallet.name), this.subscribeToWalletEventsVNext(wallet, connectorId);
|
|
1008
|
+
} catch (e) {
|
|
1009
|
+
if (attemptId !== this.connectAttemptId) throw e;
|
|
1010
|
+
let errorMessage = e instanceof Error ? e.message : String(e), error = e instanceof Error ? e : new Error(errorMessage);
|
|
1011
|
+
throw this.updateWalletStatus({
|
|
1012
|
+
status: "error",
|
|
1013
|
+
error,
|
|
1014
|
+
connectorId,
|
|
1015
|
+
recoverable: this.isRecoverableError(error)
|
|
1016
|
+
}), this.stateManager.updateState(
|
|
1017
|
+
{
|
|
1018
|
+
selectedWallet: null,
|
|
1019
|
+
connected: false,
|
|
1020
|
+
connecting: false,
|
|
1021
|
+
accounts: [],
|
|
1022
|
+
selectedAccount: null
|
|
1023
|
+
},
|
|
1024
|
+
true
|
|
1025
|
+
), this.eventEmitter.emit({
|
|
1026
|
+
type: "connection:failed",
|
|
1027
|
+
wallet: wallet.name,
|
|
1028
|
+
error: errorMessage,
|
|
1029
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
1030
|
+
}), e;
|
|
1031
|
+
} finally {
|
|
1032
|
+
this.pendingWallet === wallet && (this.pendingWallet = null, this.pendingWalletName = null);
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
/**
|
|
1036
|
+
* Create a WalletSession object
|
|
1037
|
+
*/
|
|
1038
|
+
createSession(wallet, connectorId, accounts, selectedAccount) {
|
|
1039
|
+
let listeners = /* @__PURE__ */ new Set();
|
|
1040
|
+
return {
|
|
1041
|
+
connectorId,
|
|
1042
|
+
accounts,
|
|
1043
|
+
selectedAccount,
|
|
1044
|
+
onAccountsChanged: (listener) => (listeners.add(listener), () => listeners.delete(listener)),
|
|
1045
|
+
selectAccount: async (address) => {
|
|
1046
|
+
if (accounts.find((a) => a.address === address))
|
|
1047
|
+
return this.selectAccount(address);
|
|
1048
|
+
}
|
|
1049
|
+
};
|
|
1050
|
+
}
|
|
1051
|
+
/**
|
|
1052
|
+
* Update wallet status in state
|
|
1053
|
+
*/
|
|
1054
|
+
updateWalletStatus(status) {
|
|
1055
|
+
this.stateManager.updateState({ wallet: status });
|
|
1056
|
+
}
|
|
1057
|
+
/**
|
|
1058
|
+
* Subscribe to wallet events (vNext version with improved account change handling)
|
|
1059
|
+
*/
|
|
1060
|
+
subscribeToWalletEventsVNext(wallet, connectorId) {
|
|
1061
|
+
this.walletChangeUnsub && (this.walletChangeUnsub(), this.walletChangeUnsub = null), this.stopPollingWalletAccounts();
|
|
1062
|
+
let eventsOn = getEventsFeature(wallet);
|
|
1063
|
+
if (!eventsOn) {
|
|
1064
|
+
this.startPollingWalletAccountsVNext(wallet, connectorId);
|
|
1065
|
+
return;
|
|
1066
|
+
}
|
|
1067
|
+
try {
|
|
1068
|
+
this.walletChangeUnsub = eventsOn("change", (properties) => {
|
|
1069
|
+
let changeAccounts = properties?.accounts ?? [];
|
|
1070
|
+
this.handleAccountsChanged(changeAccounts, connectorId, wallet);
|
|
1071
|
+
});
|
|
1072
|
+
} catch {
|
|
1073
|
+
this.startPollingWalletAccountsVNext(wallet, connectorId);
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
/**
|
|
1077
|
+
* Handle accounts changed event with proper validation
|
|
1078
|
+
*/
|
|
1079
|
+
handleAccountsChanged(newAccounts, connectorId, wallet) {
|
|
1080
|
+
let state = this.getState();
|
|
1081
|
+
if (newAccounts.length === 0) {
|
|
1082
|
+
this.log("No accounts available, disconnecting..."), this.disconnect();
|
|
1083
|
+
return;
|
|
1084
|
+
}
|
|
1085
|
+
let sessionAccounts = newAccounts.map((a) => ({
|
|
1086
|
+
address: a.address,
|
|
1087
|
+
label: a.label,
|
|
1088
|
+
account: a
|
|
1089
|
+
})), legacyAccounts = sessionAccounts.map((a) => this.toAccountInfo(a.account)), currentSelected = state.selectedAccount, selectedAccount = sessionAccounts.find((a) => a.address === currentSelected);
|
|
1090
|
+
if (selectedAccount || (selectedAccount = sessionAccounts[0], this.eventEmitter.emit({
|
|
1091
|
+
type: "account:changed",
|
|
1092
|
+
account: selectedAccount.address,
|
|
1093
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
1094
|
+
})), state.wallet.status === "connected") {
|
|
1095
|
+
let session = this.createSession(wallet, connectorId, sessionAccounts, selectedAccount);
|
|
1096
|
+
this.updateWalletStatus({
|
|
1097
|
+
status: "connected",
|
|
1098
|
+
session
|
|
1099
|
+
});
|
|
1100
|
+
}
|
|
1101
|
+
this.stateManager.updateState({
|
|
1102
|
+
accounts: legacyAccounts,
|
|
1103
|
+
selectedAccount: selectedAccount.address
|
|
1104
|
+
});
|
|
1105
|
+
}
|
|
1106
|
+
/**
|
|
1107
|
+
* Start polling wallet accounts (vNext version)
|
|
1108
|
+
*/
|
|
1109
|
+
startPollingWalletAccountsVNext(wallet, connectorId) {
|
|
1110
|
+
if (this.pollTimer) return;
|
|
1111
|
+
this.pollAttempts = 0;
|
|
1112
|
+
let poll = () => {
|
|
1113
|
+
if (this.pollAttempts >= 20) {
|
|
1114
|
+
this.stopPollingWalletAccounts(), this.log("Stopped wallet polling after max attempts");
|
|
1115
|
+
return;
|
|
1116
|
+
}
|
|
1117
|
+
try {
|
|
1118
|
+
let walletAccounts = wallet.accounts;
|
|
1119
|
+
walletAccounts.length > 0 && (this.handleAccountsChanged(walletAccounts, connectorId, wallet), this.pollAttempts = 0);
|
|
1120
|
+
} catch (error) {
|
|
1121
|
+
this.log("Wallet polling error:", error);
|
|
1122
|
+
}
|
|
1123
|
+
this.pollAttempts++;
|
|
1124
|
+
let intervalIndex = Math.min(this.pollAttempts, POLL_INTERVALS_MS.length - 1), interval = POLL_INTERVALS_MS[intervalIndex];
|
|
1125
|
+
this.pollTimer = setTimeout(poll, interval);
|
|
1126
|
+
};
|
|
1127
|
+
poll();
|
|
1128
|
+
}
|
|
802
1129
|
/**
|
|
803
|
-
*
|
|
1130
|
+
* Check if an error is recoverable
|
|
1131
|
+
*/
|
|
1132
|
+
isRecoverableError(error) {
|
|
1133
|
+
let message = error.message.toLowerCase();
|
|
1134
|
+
return message.includes("user rejected") || message.includes("user denied") || message.includes("cancelled") || message.includes("canceled");
|
|
1135
|
+
}
|
|
1136
|
+
// ========================================================================
|
|
1137
|
+
// Legacy Connection Methods (kept for backwards compatibility)
|
|
1138
|
+
// ========================================================================
|
|
1139
|
+
/**
|
|
1140
|
+
* Connect to a wallet (legacy API)
|
|
1141
|
+
* @deprecated Use connectWallet() instead
|
|
804
1142
|
*/
|
|
805
1143
|
async connect(wallet, walletName) {
|
|
806
1144
|
if (typeof window > "u") return;
|
|
807
|
-
let name = walletName || wallet.name;
|
|
1145
|
+
let name = walletName || wallet.name, attemptId = ++this.connectAttemptId;
|
|
1146
|
+
this.pendingWallet = wallet, this.pendingWalletName = name;
|
|
1147
|
+
let connectorId = createConnectorId(name);
|
|
808
1148
|
this.eventEmitter.emit({
|
|
809
1149
|
type: "connecting",
|
|
810
1150
|
wallet: name,
|
|
811
1151
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
1152
|
+
}), this.updateWalletStatus({
|
|
1153
|
+
status: "connecting",
|
|
1154
|
+
connectorId
|
|
812
1155
|
}), this.stateManager.updateState({ connecting: true }, true);
|
|
813
1156
|
try {
|
|
814
1157
|
let connect = getConnectFeature(wallet);
|
|
815
1158
|
if (!connect) throw new Error(`Wallet ${name} does not support standard connect`);
|
|
816
|
-
let result = await connect({ silent: false })
|
|
1159
|
+
let result = await connect({ silent: false });
|
|
1160
|
+
if (attemptId !== this.connectAttemptId)
|
|
1161
|
+
throw new Error("Connection cancelled");
|
|
1162
|
+
let walletAccounts = wallet.accounts, accountMap = /* @__PURE__ */ new Map();
|
|
817
1163
|
for (let a of [...walletAccounts, ...result.accounts]) accountMap.set(a.address, a);
|
|
818
|
-
let
|
|
819
|
-
|
|
1164
|
+
let sessionAccounts = Array.from(accountMap.values()).map((a) => ({
|
|
1165
|
+
address: a.address,
|
|
1166
|
+
label: a.label,
|
|
1167
|
+
account: a
|
|
1168
|
+
}));
|
|
1169
|
+
if (sessionAccounts.length === 0)
|
|
1170
|
+
throw new Error(`Wallet ${name} connected but returned no accounts`);
|
|
1171
|
+
let accounts = sessionAccounts.map((a) => this.toAccountInfo(a.account)), state = this.getState(), previouslySelected = state.selectedAccount, previousAddresses = new Set(state.accounts.map((a) => a.address)), selected = accounts.find((a) => !previousAddresses.has(a.address))?.address ?? previouslySelected ?? accounts[0]?.address ?? null, selectedSessionAccount = (selected ? sessionAccounts.find((a) => a.address === selected) : void 0) ?? sessionAccounts[0], session = this.createSession(wallet, connectorId, sessionAccounts, selectedSessionAccount);
|
|
1172
|
+
this.updateWalletStatus({
|
|
1173
|
+
status: "connected",
|
|
1174
|
+
session
|
|
1175
|
+
}), this.stateManager.updateState(
|
|
820
1176
|
{
|
|
821
1177
|
selectedWallet: wallet,
|
|
822
1178
|
connected: true,
|
|
@@ -840,7 +1196,9 @@ var ConnectionManager = class extends BaseCollaborator {
|
|
|
840
1196
|
accountsCount: accounts.length
|
|
841
1197
|
}), this.walletStorage && (!("isAvailable" in this.walletStorage) || typeof this.walletStorage.isAvailable != "function" || this.walletStorage.isAvailable() ? this.walletStorage.set(name) : this.log("Storage not available (private browsing?), skipping wallet persistence")), this.subscribeToWalletEvents();
|
|
842
1198
|
} catch (e) {
|
|
843
|
-
|
|
1199
|
+
if (attemptId !== this.connectAttemptId)
|
|
1200
|
+
throw e;
|
|
1201
|
+
let errorMessage = e instanceof Error ? e.message : String(e), error = e instanceof Error ? e : new Error(errorMessage);
|
|
844
1202
|
throw this.eventEmitter.emit({
|
|
845
1203
|
type: "connection:failed",
|
|
846
1204
|
wallet: name,
|
|
@@ -848,9 +1206,14 @@ var ConnectionManager = class extends BaseCollaborator {
|
|
|
848
1206
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
849
1207
|
}), this.eventEmitter.emit({
|
|
850
1208
|
type: "error",
|
|
851
|
-
error
|
|
1209
|
+
error,
|
|
852
1210
|
context: "wallet-connection",
|
|
853
1211
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
1212
|
+
}), this.updateWalletStatus({
|
|
1213
|
+
status: "error",
|
|
1214
|
+
error,
|
|
1215
|
+
connectorId,
|
|
1216
|
+
recoverable: this.isRecoverableError(error)
|
|
854
1217
|
}), this.stateManager.updateState(
|
|
855
1218
|
{
|
|
856
1219
|
selectedWallet: null,
|
|
@@ -861,22 +1224,21 @@ var ConnectionManager = class extends BaseCollaborator {
|
|
|
861
1224
|
},
|
|
862
1225
|
true
|
|
863
1226
|
), e;
|
|
1227
|
+
} finally {
|
|
1228
|
+
this.pendingWallet === wallet && this.pendingWalletName === name && (this.pendingWallet = null, this.pendingWalletName = null);
|
|
864
1229
|
}
|
|
865
1230
|
}
|
|
866
1231
|
/**
|
|
867
1232
|
* Disconnect from wallet
|
|
868
1233
|
*/
|
|
869
1234
|
async disconnect() {
|
|
870
|
-
this.walletChangeUnsub && (this.walletChangeUnsub(), this.walletChangeUnsub = null), this.stopPollingWalletAccounts();
|
|
871
|
-
let wallet = this.getState().selectedWallet;
|
|
872
|
-
if (
|
|
873
|
-
let disconnect = getDisconnectFeature(wallet);
|
|
874
|
-
disconnect && await disconnect();
|
|
875
|
-
}
|
|
876
|
-
this.stateManager.updateState(
|
|
1235
|
+
this.connectAttemptId++, this.walletChangeUnsub && (this.walletChangeUnsub(), this.walletChangeUnsub = null), this.stopPollingWalletAccounts();
|
|
1236
|
+
let wallet = this.getState().selectedWallet ?? this.pendingWallet;
|
|
1237
|
+
if (this.pendingWallet = null, this.pendingWalletName = null, this.updateWalletStatus(INITIAL_WALLET_STATUS), this.stateManager.updateState(
|
|
877
1238
|
{
|
|
878
1239
|
selectedWallet: null,
|
|
879
1240
|
connected: false,
|
|
1241
|
+
connecting: false,
|
|
880
1242
|
accounts: [],
|
|
881
1243
|
selectedAccount: null
|
|
882
1244
|
},
|
|
@@ -884,7 +1246,14 @@ var ConnectionManager = class extends BaseCollaborator {
|
|
|
884
1246
|
), this.eventEmitter.emit({
|
|
885
1247
|
type: "wallet:disconnected",
|
|
886
1248
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
887
|
-
}), this.walletStorage && "clear" in this.walletStorage && typeof this.walletStorage.clear == "function" ? this.walletStorage.clear() : this.walletStorage?.set(void 0)
|
|
1249
|
+
}), this.walletStorage && "clear" in this.walletStorage && typeof this.walletStorage.clear == "function" ? this.walletStorage.clear() : this.walletStorage?.set(void 0), wallet) {
|
|
1250
|
+
let disconnect = getDisconnectFeature(wallet);
|
|
1251
|
+
if (disconnect)
|
|
1252
|
+
try {
|
|
1253
|
+
await disconnect();
|
|
1254
|
+
} catch {
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
888
1257
|
}
|
|
889
1258
|
/**
|
|
890
1259
|
* Select a different account
|
|
@@ -992,16 +1361,49 @@ var ConnectionManager = class extends BaseCollaborator {
|
|
|
992
1361
|
|
|
993
1362
|
// src/lib/wallet/auto-connector.ts
|
|
994
1363
|
var logger4 = createLogger("AutoConnector"), MIN_ADDRESS_LENGTH = 30, AutoConnector = class {
|
|
995
|
-
constructor(walletDetector, connectionManager, stateManager, walletStorage, debug = false) {
|
|
1364
|
+
constructor(walletDetector, connectionManager, stateManager, walletStorage, debug = false, walletStateStorage) {
|
|
996
1365
|
__publicField(this, "walletDetector");
|
|
997
1366
|
__publicField(this, "connectionManager");
|
|
998
1367
|
__publicField(this, "stateManager");
|
|
1368
|
+
/** Legacy wallet name storage */
|
|
999
1369
|
__publicField(this, "walletStorage");
|
|
1370
|
+
/** vNext wallet state storage (connector ID + account) */
|
|
1371
|
+
__publicField(this, "walletStateStorage");
|
|
1000
1372
|
__publicField(this, "debug");
|
|
1001
|
-
this.walletDetector = walletDetector, this.connectionManager = connectionManager, this.stateManager = stateManager, this.walletStorage = walletStorage, this.debug = debug;
|
|
1373
|
+
this.walletDetector = walletDetector, this.connectionManager = connectionManager, this.stateManager = stateManager, this.walletStorage = walletStorage, this.walletStateStorage = walletStateStorage, this.debug = debug;
|
|
1002
1374
|
}
|
|
1003
1375
|
async attemptAutoConnect() {
|
|
1004
|
-
return await this.attemptInstantConnect() ? true : (await this.attemptStandardConnect(), this.stateManager.getSnapshot().connected);
|
|
1376
|
+
return this.walletStateStorage && await this.attemptVNextAutoConnect() || await this.attemptInstantConnect() ? true : (await this.attemptStandardConnect(), this.stateManager.getSnapshot().connected);
|
|
1377
|
+
}
|
|
1378
|
+
/**
|
|
1379
|
+
* vNext auto-connect using stored connector ID with silent-first approach.
|
|
1380
|
+
* This won't prompt the user unless they explicitly initiated the connect.
|
|
1381
|
+
*/
|
|
1382
|
+
async attemptVNextAutoConnect() {
|
|
1383
|
+
let walletState = this.walletStateStorage?.get();
|
|
1384
|
+
if (!walletState || !walletState.autoConnect)
|
|
1385
|
+
return this.debug && logger4.debug("vNext auto-connect: No stored wallet state or autoConnect disabled"), false;
|
|
1386
|
+
let { connectorId, lastAccount } = walletState;
|
|
1387
|
+
await ready;
|
|
1388
|
+
let wallet = this.walletDetector.getConnectorById(connectorId);
|
|
1389
|
+
if (!wallet)
|
|
1390
|
+
return this.debug && logger4.debug("vNext auto-connect: Connector not found", { connectorId }), false;
|
|
1391
|
+
try {
|
|
1392
|
+
return this.debug && logger4.info("vNext auto-connect: Attempting silent connect", {
|
|
1393
|
+
connectorId,
|
|
1394
|
+
lastAccount
|
|
1395
|
+
}), await this.connectionManager.connectWallet(wallet, connectorId, {
|
|
1396
|
+
silent: true,
|
|
1397
|
+
allowInteractiveFallback: false,
|
|
1398
|
+
// Don't prompt on auto-connect
|
|
1399
|
+
preferredAccount: lastAccount
|
|
1400
|
+
}), this.debug && logger4.info("vNext auto-connect: Silent connect successful", { connectorId }), true;
|
|
1401
|
+
} catch (error) {
|
|
1402
|
+
return this.debug && logger4.debug("vNext auto-connect: Silent connect failed (expected for first-time or revoked)", {
|
|
1403
|
+
connectorId,
|
|
1404
|
+
error: error instanceof Error ? error.message : error
|
|
1405
|
+
}), false;
|
|
1406
|
+
}
|
|
1005
1407
|
}
|
|
1006
1408
|
async attemptInstantConnect() {
|
|
1007
1409
|
let storedWalletName = this.walletStorage?.get();
|
|
@@ -1092,12 +1494,12 @@ var logger4 = createLogger("AutoConnector"), MIN_ADDRESS_LENGTH = 30, AutoConnec
|
|
|
1092
1494
|
],
|
|
1093
1495
|
features,
|
|
1094
1496
|
accounts: []
|
|
1095
|
-
};
|
|
1497
|
+
}, walletWithIcon = applyWalletIconOverride(wallet);
|
|
1096
1498
|
this.stateManager.updateState(
|
|
1097
1499
|
{
|
|
1098
1500
|
wallets: [
|
|
1099
1501
|
{
|
|
1100
|
-
wallet,
|
|
1502
|
+
wallet: walletWithIcon,
|
|
1101
1503
|
installed: true,
|
|
1102
1504
|
connectable: true
|
|
1103
1505
|
}
|
|
@@ -1105,7 +1507,7 @@ var logger4 = createLogger("AutoConnector"), MIN_ADDRESS_LENGTH = 30, AutoConnec
|
|
|
1105
1507
|
},
|
|
1106
1508
|
true
|
|
1107
1509
|
), await ready;
|
|
1108
|
-
let walletsApi = getWalletsRegistry(), registryWallet = walletsApi.get().find((w) => w.name === storedWalletName), walletToUse = registryWallet ||
|
|
1510
|
+
let walletsApi = getWalletsRegistry(), registryWallet = walletsApi.get().find((w) => w.name === storedWalletName), walletToUse = applyWalletIconOverride(registryWallet || walletWithIcon);
|
|
1109
1511
|
return this.debug && logger4.info("Attempting to connect via instant auto-connect", {
|
|
1110
1512
|
walletName: storedWalletName,
|
|
1111
1513
|
usingRegistry: !!registryWallet
|
|
@@ -1319,8 +1721,13 @@ var logger5 = createLogger("ConnectorClient"), ConnectorClient = class {
|
|
|
1319
1721
|
__publicField(this, "healthMonitor");
|
|
1320
1722
|
__publicField(this, "initialized", false);
|
|
1321
1723
|
__publicField(this, "config");
|
|
1724
|
+
__publicField(this, "walletConnectRegistration", null);
|
|
1322
1725
|
this.config = config;
|
|
1323
1726
|
let initialState = {
|
|
1727
|
+
// vNext wallet status
|
|
1728
|
+
wallet: INITIAL_WALLET_STATUS,
|
|
1729
|
+
connectors: [],
|
|
1730
|
+
// Legacy fields (for backwards compatibility)
|
|
1324
1731
|
wallets: [],
|
|
1325
1732
|
selectedWallet: null,
|
|
1326
1733
|
connected: false,
|
|
@@ -1362,7 +1769,9 @@ var logger5 = createLogger("ConnectorClient"), ConnectorClient = class {
|
|
|
1362
1769
|
initialize() {
|
|
1363
1770
|
if (typeof window > "u" || this.initialized) return;
|
|
1364
1771
|
let { error } = tryCatchSync(() => {
|
|
1365
|
-
this.walletDetector.initialize(), this.config.
|
|
1772
|
+
this.walletDetector.initialize(), this.config.walletConnect?.enabled && this.initializeWalletConnect().catch((err) => {
|
|
1773
|
+
this.config.debug && logger5.error("WalletConnect initialization failed", { error: err });
|
|
1774
|
+
}), this.config.autoConnect && setTimeout(() => {
|
|
1366
1775
|
this.autoConnector.attemptAutoConnect().catch((err) => {
|
|
1367
1776
|
this.config.debug && logger5.error("Auto-connect error", { error: err });
|
|
1368
1777
|
});
|
|
@@ -1370,11 +1779,62 @@ var logger5 = createLogger("ConnectorClient"), ConnectorClient = class {
|
|
|
1370
1779
|
});
|
|
1371
1780
|
error && this.config.debug && logger5.error("Connector initialization failed", { error });
|
|
1372
1781
|
}
|
|
1782
|
+
/**
|
|
1783
|
+
* Initialize WalletConnect integration
|
|
1784
|
+
* Dynamically imports and registers the WalletConnect wallet
|
|
1785
|
+
*/
|
|
1786
|
+
async initializeWalletConnect() {
|
|
1787
|
+
if (this.config.walletConnect?.enabled)
|
|
1788
|
+
try {
|
|
1789
|
+
let { registerWalletConnectWallet } = await import('./walletconnect-U455PO4I.mjs');
|
|
1790
|
+
this.walletConnectRegistration = await registerWalletConnectWallet(this.config.walletConnect), this.config.debug && logger5.info("WalletConnect wallet registered successfully");
|
|
1791
|
+
} catch (error) {
|
|
1792
|
+
this.config.debug && logger5.error("Failed to register WalletConnect wallet", { error });
|
|
1793
|
+
}
|
|
1794
|
+
}
|
|
1795
|
+
// ========================================================================
|
|
1796
|
+
// vNext Wallet Actions (connector-id based)
|
|
1797
|
+
// ========================================================================
|
|
1798
|
+
/**
|
|
1799
|
+
* Connect to a wallet using its stable connector ID.
|
|
1800
|
+
* This is the recommended way to connect in vNext.
|
|
1801
|
+
*
|
|
1802
|
+
* @param connectorId - Stable connector identifier
|
|
1803
|
+
* @param options - Connection options (silent mode, preferred account, etc.)
|
|
1804
|
+
*/
|
|
1805
|
+
async connectWallet(connectorId, options) {
|
|
1806
|
+
let connector = this.walletDetector.getConnectorById(connectorId);
|
|
1807
|
+
if (!connector)
|
|
1808
|
+
throw new Error(`Connector ${connectorId} not found`);
|
|
1809
|
+
await this.connectionManager.connectWallet(connector, connectorId, options);
|
|
1810
|
+
}
|
|
1811
|
+
/**
|
|
1812
|
+
* Disconnect the current wallet session.
|
|
1813
|
+
* This is the vNext equivalent of disconnect().
|
|
1814
|
+
*/
|
|
1815
|
+
async disconnectWallet() {
|
|
1816
|
+
await this.connectionManager.disconnect();
|
|
1817
|
+
}
|
|
1818
|
+
/**
|
|
1819
|
+
* Get a connector by its ID (for advanced use cases).
|
|
1820
|
+
*/
|
|
1821
|
+
getConnector(connectorId) {
|
|
1822
|
+
return this.walletDetector.getConnectorById(connectorId);
|
|
1823
|
+
}
|
|
1824
|
+
// ========================================================================
|
|
1825
|
+
// Legacy Actions (kept for backwards compatibility)
|
|
1826
|
+
// ========================================================================
|
|
1827
|
+
/**
|
|
1828
|
+
* @deprecated Use `connectWallet(connectorId)` instead.
|
|
1829
|
+
*/
|
|
1373
1830
|
async select(walletName) {
|
|
1374
1831
|
let wallet = this.stateManager.getSnapshot().wallets.find((w) => w.wallet.name === walletName)?.wallet;
|
|
1375
1832
|
if (!wallet) throw new Error(`Wallet ${walletName} not found`);
|
|
1376
1833
|
await this.connectionManager.connect(wallet, walletName);
|
|
1377
1834
|
}
|
|
1835
|
+
/**
|
|
1836
|
+
* @deprecated Use `disconnectWallet()` instead.
|
|
1837
|
+
*/
|
|
1378
1838
|
async disconnect() {
|
|
1379
1839
|
await this.connectionManager.disconnect();
|
|
1380
1840
|
}
|
|
@@ -1462,288 +1922,23 @@ var logger5 = createLogger("ConnectorClient"), ConnectorClient = class {
|
|
|
1462
1922
|
this.debugMetrics.resetMetrics();
|
|
1463
1923
|
}
|
|
1464
1924
|
destroy() {
|
|
1465
|
-
this.
|
|
1466
|
-
}), this.walletDetector.destroy(), this.eventEmitter.offAll(), this.stateManager.clear();
|
|
1467
|
-
}
|
|
1468
|
-
};
|
|
1469
|
-
var logger6 = createLogger("ErrorBoundary"), WalletErrorType = /* @__PURE__ */ ((WalletErrorType2) => (WalletErrorType2.CONNECTION_FAILED = "CONNECTION_FAILED", WalletErrorType2.TRANSACTION_FAILED = "TRANSACTION_FAILED", WalletErrorType2.NETWORK_ERROR = "NETWORK_ERROR", WalletErrorType2.WALLET_NOT_FOUND = "WALLET_NOT_FOUND", WalletErrorType2.USER_REJECTED = "USER_REJECTED", WalletErrorType2.INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS", WalletErrorType2.UNKNOWN_ERROR = "UNKNOWN_ERROR", WalletErrorType2))(WalletErrorType || {}), ErrorLogger = class {
|
|
1470
|
-
static log(error, errorInfo, context) {
|
|
1471
|
-
if (process.env.NODE_ENV === "development" && logger6.error(error.message, {
|
|
1472
|
-
error,
|
|
1473
|
-
errorInfo,
|
|
1474
|
-
context
|
|
1475
|
-
}), process.env.NODE_ENV === "production" && typeof window < "u")
|
|
1925
|
+
if (this.walletConnectRegistration)
|
|
1476
1926
|
try {
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
fatal: false,
|
|
1481
|
-
custom_map: { error_type: "wallet_error", ...context }
|
|
1482
|
-
});
|
|
1483
|
-
} catch {
|
|
1927
|
+
this.walletConnectRegistration.unregister(), this.walletConnectRegistration = null;
|
|
1928
|
+
} catch (error) {
|
|
1929
|
+
this.config.debug && logger5.warn("Error unregistering WalletConnect wallet", { error });
|
|
1484
1930
|
}
|
|
1931
|
+
this.connectionManager.disconnect().catch(() => {
|
|
1932
|
+
}), this.walletDetector.destroy(), this.eventEmitter.offAll(), this.stateManager.clear();
|
|
1485
1933
|
}
|
|
1486
1934
|
};
|
|
1487
|
-
|
|
1488
|
-
if (isConnectorError(error))
|
|
1489
|
-
return {
|
|
1490
|
-
...error,
|
|
1491
|
-
type: {
|
|
1492
|
-
WALLET_NOT_CONNECTED: "CONNECTION_FAILED" /* CONNECTION_FAILED */,
|
|
1493
|
-
WALLET_NOT_FOUND: "WALLET_NOT_FOUND" /* WALLET_NOT_FOUND */,
|
|
1494
|
-
CONNECTION_FAILED: "CONNECTION_FAILED" /* CONNECTION_FAILED */,
|
|
1495
|
-
USER_REJECTED: "USER_REJECTED" /* USER_REJECTED */,
|
|
1496
|
-
RPC_ERROR: "NETWORK_ERROR" /* NETWORK_ERROR */,
|
|
1497
|
-
NETWORK_TIMEOUT: "NETWORK_ERROR" /* NETWORK_ERROR */,
|
|
1498
|
-
SIGNING_FAILED: "TRANSACTION_FAILED" /* TRANSACTION_FAILED */,
|
|
1499
|
-
SEND_FAILED: "TRANSACTION_FAILED" /* TRANSACTION_FAILED */
|
|
1500
|
-
}[error.code] || "UNKNOWN_ERROR" /* UNKNOWN_ERROR */,
|
|
1501
|
-
recoverable: error.recoverable,
|
|
1502
|
-
context: error.context
|
|
1503
|
-
};
|
|
1504
|
-
let walletError = error;
|
|
1505
|
-
if (walletError.type) return walletError;
|
|
1506
|
-
let type = "UNKNOWN_ERROR" /* UNKNOWN_ERROR */, recoverable = false;
|
|
1507
|
-
return error.message.includes("User rejected") || error.message.includes("User denied") ? (type = "USER_REJECTED" /* USER_REJECTED */, recoverable = true) : error.message.includes("Insufficient funds") ? (type = "INSUFFICIENT_FUNDS" /* INSUFFICIENT_FUNDS */, recoverable = false) : error.message.includes("Network") || error.message.includes("fetch") ? (type = "NETWORK_ERROR" /* NETWORK_ERROR */, recoverable = true) : error.message.includes("Wallet not found") || error.message.includes("not installed") ? (type = "WALLET_NOT_FOUND" /* WALLET_NOT_FOUND */, recoverable = true) : (error.message.includes("Failed to connect") || error.message.includes("Connection")) && (type = "CONNECTION_FAILED" /* CONNECTION_FAILED */, recoverable = true), {
|
|
1508
|
-
...error,
|
|
1509
|
-
type,
|
|
1510
|
-
recoverable,
|
|
1511
|
-
context: { originalMessage: error.message }
|
|
1512
|
-
};
|
|
1513
|
-
}
|
|
1514
|
-
var ConnectorErrorBoundary = class extends Component {
|
|
1515
|
-
constructor(props) {
|
|
1516
|
-
super(props);
|
|
1517
|
-
__publicField(this, "retryTimeouts", /* @__PURE__ */ new Set());
|
|
1518
|
-
__publicField(this, "retry", () => {
|
|
1519
|
-
let { maxRetries = 3 } = this.props;
|
|
1520
|
-
this.state.retryCount >= maxRetries || this.setState((prevState) => ({
|
|
1521
|
-
hasError: false,
|
|
1522
|
-
error: null,
|
|
1523
|
-
errorInfo: null,
|
|
1524
|
-
retryCount: prevState.retryCount + 1
|
|
1525
|
-
}));
|
|
1526
|
-
});
|
|
1527
|
-
this.state = {
|
|
1528
|
-
hasError: false,
|
|
1529
|
-
error: null,
|
|
1530
|
-
errorInfo: null,
|
|
1531
|
-
errorId: "",
|
|
1532
|
-
retryCount: 0
|
|
1533
|
-
};
|
|
1534
|
-
}
|
|
1535
|
-
static getDerivedStateFromError(error) {
|
|
1536
|
-
return {
|
|
1537
|
-
hasError: true,
|
|
1538
|
-
error,
|
|
1539
|
-
errorId: `error_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`
|
|
1540
|
-
};
|
|
1541
|
-
}
|
|
1542
|
-
componentDidCatch(error, errorInfo) {
|
|
1543
|
-
this.setState({ errorInfo }), ErrorLogger.log(error, errorInfo, {
|
|
1544
|
-
retryCount: this.state.retryCount,
|
|
1545
|
-
errorId: this.state.errorId,
|
|
1546
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
1547
|
-
}), this.props.onError?.(error, errorInfo);
|
|
1548
|
-
}
|
|
1549
|
-
componentWillUnmount() {
|
|
1550
|
-
this.retryTimeouts.forEach((timeout) => clearTimeout(timeout));
|
|
1551
|
-
}
|
|
1552
|
-
render() {
|
|
1553
|
-
if (this.state.hasError && this.state.error) {
|
|
1554
|
-
let walletError = classifyError(this.state.error);
|
|
1555
|
-
return this.props.fallback ? this.props.fallback(walletError, this.retry) : /* @__PURE__ */ jsx(DefaultErrorFallback, { error: walletError, onRetry: this.retry });
|
|
1556
|
-
}
|
|
1557
|
-
return this.props.children;
|
|
1558
|
-
}
|
|
1559
|
-
};
|
|
1560
|
-
function DefaultErrorFallback({ error, onRetry }) {
|
|
1561
|
-
let [isPending, startTransition] = useTransition(), [isRetrying, setIsRetrying] = useState(false), handleRetry = useCallback(() => {
|
|
1562
|
-
setIsRetrying(true), startTransition(() => {
|
|
1563
|
-
setTimeout(() => {
|
|
1564
|
-
onRetry(), setIsRetrying(false);
|
|
1565
|
-
}, 500);
|
|
1566
|
-
});
|
|
1567
|
-
}, [onRetry]), { title, message, actionText, showRetry } = useMemo(() => {
|
|
1568
|
-
switch (error.type) {
|
|
1569
|
-
case "USER_REJECTED" /* USER_REJECTED */:
|
|
1570
|
-
return {
|
|
1571
|
-
title: "Transaction Cancelled",
|
|
1572
|
-
message: "You cancelled the transaction. No problem!",
|
|
1573
|
-
actionText: "Try Again",
|
|
1574
|
-
showRetry: true
|
|
1575
|
-
};
|
|
1576
|
-
case "WALLET_NOT_FOUND" /* WALLET_NOT_FOUND */:
|
|
1577
|
-
return {
|
|
1578
|
-
title: "Wallet Not Found",
|
|
1579
|
-
message: "Please install a supported Solana wallet to continue.",
|
|
1580
|
-
actionText: "Check Wallets",
|
|
1581
|
-
showRetry: true
|
|
1582
|
-
};
|
|
1583
|
-
case "NETWORK_ERROR" /* NETWORK_ERROR */:
|
|
1584
|
-
return {
|
|
1585
|
-
title: "Network Error",
|
|
1586
|
-
message: "Having trouble connecting. Please check your internet connection.",
|
|
1587
|
-
actionText: "Retry",
|
|
1588
|
-
showRetry: true
|
|
1589
|
-
};
|
|
1590
|
-
case "INSUFFICIENT_FUNDS" /* INSUFFICIENT_FUNDS */:
|
|
1591
|
-
return {
|
|
1592
|
-
title: "Insufficient Funds",
|
|
1593
|
-
message: "You don't have enough SOL for this transaction.",
|
|
1594
|
-
actionText: "Add Funds",
|
|
1595
|
-
showRetry: false
|
|
1596
|
-
};
|
|
1597
|
-
default:
|
|
1598
|
-
return {
|
|
1599
|
-
title: "Something went wrong",
|
|
1600
|
-
message: "An unexpected error occurred. Please try again.",
|
|
1601
|
-
actionText: "Retry",
|
|
1602
|
-
showRetry: error.recoverable
|
|
1603
|
-
};
|
|
1604
|
-
}
|
|
1605
|
-
}, [error.type, error.recoverable]);
|
|
1606
|
-
return /* @__PURE__ */ jsxs(
|
|
1607
|
-
"div",
|
|
1608
|
-
{
|
|
1609
|
-
style: {
|
|
1610
|
-
display: "flex",
|
|
1611
|
-
flexDirection: "column",
|
|
1612
|
-
alignItems: "center",
|
|
1613
|
-
justifyContent: "center",
|
|
1614
|
-
padding: "2rem",
|
|
1615
|
-
textAlign: "center",
|
|
1616
|
-
borderRadius: "12px",
|
|
1617
|
-
border: "1px solid #e5e7eb",
|
|
1618
|
-
backgroundColor: "#fafafa",
|
|
1619
|
-
maxWidth: "400px",
|
|
1620
|
-
margin: "0 auto"
|
|
1621
|
-
},
|
|
1622
|
-
children: [
|
|
1623
|
-
/* @__PURE__ */ jsx(
|
|
1624
|
-
"div",
|
|
1625
|
-
{
|
|
1626
|
-
style: {
|
|
1627
|
-
width: "48px",
|
|
1628
|
-
height: "48px",
|
|
1629
|
-
borderRadius: "50%",
|
|
1630
|
-
backgroundColor: "#fee2e2",
|
|
1631
|
-
display: "flex",
|
|
1632
|
-
alignItems: "center",
|
|
1633
|
-
justifyContent: "center",
|
|
1634
|
-
marginBottom: "1rem"
|
|
1635
|
-
},
|
|
1636
|
-
children: /* @__PURE__ */ jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "#dc2626", children: /* @__PURE__ */ jsx("path", { d: "M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126zM12 15.75h.007v.008H12v-.008z" }) })
|
|
1637
|
-
}
|
|
1638
|
-
),
|
|
1639
|
-
/* @__PURE__ */ jsx(
|
|
1640
|
-
"h3",
|
|
1641
|
-
{
|
|
1642
|
-
style: {
|
|
1643
|
-
margin: "0 0 0.5rem 0",
|
|
1644
|
-
fontSize: "1.125rem",
|
|
1645
|
-
fontWeight: "600",
|
|
1646
|
-
color: "#111827"
|
|
1647
|
-
},
|
|
1648
|
-
children: title
|
|
1649
|
-
}
|
|
1650
|
-
),
|
|
1651
|
-
/* @__PURE__ */ jsx(
|
|
1652
|
-
"p",
|
|
1653
|
-
{
|
|
1654
|
-
style: {
|
|
1655
|
-
margin: "0 0 1.5rem 0",
|
|
1656
|
-
fontSize: "0.875rem",
|
|
1657
|
-
color: "#6b7280",
|
|
1658
|
-
lineHeight: "1.5"
|
|
1659
|
-
},
|
|
1660
|
-
children: message
|
|
1661
|
-
}
|
|
1662
|
-
),
|
|
1663
|
-
/* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: "0.75rem", flexWrap: "wrap" }, children: [
|
|
1664
|
-
showRetry && /* @__PURE__ */ jsx(
|
|
1665
|
-
"button",
|
|
1666
|
-
{
|
|
1667
|
-
onClick: handleRetry,
|
|
1668
|
-
disabled: isPending || isRetrying,
|
|
1669
|
-
style: {
|
|
1670
|
-
padding: "0.5rem 1rem",
|
|
1671
|
-
backgroundColor: "#3b82f6",
|
|
1672
|
-
color: "white",
|
|
1673
|
-
border: "none",
|
|
1674
|
-
borderRadius: "6px",
|
|
1675
|
-
fontSize: "0.875rem",
|
|
1676
|
-
fontWeight: "500",
|
|
1677
|
-
cursor: isPending || isRetrying ? "wait" : "pointer",
|
|
1678
|
-
opacity: isPending || isRetrying ? 0.7 : 1,
|
|
1679
|
-
transition: "all 0.2s"
|
|
1680
|
-
},
|
|
1681
|
-
children: isRetrying ? "Retrying..." : actionText
|
|
1682
|
-
}
|
|
1683
|
-
),
|
|
1684
|
-
/* @__PURE__ */ jsx(
|
|
1685
|
-
"button",
|
|
1686
|
-
{
|
|
1687
|
-
onClick: () => window.location.reload(),
|
|
1688
|
-
style: {
|
|
1689
|
-
padding: "0.5rem 1rem",
|
|
1690
|
-
backgroundColor: "transparent",
|
|
1691
|
-
color: "#6b7280",
|
|
1692
|
-
border: "1px solid #d1d5db",
|
|
1693
|
-
borderRadius: "6px",
|
|
1694
|
-
fontSize: "0.875rem",
|
|
1695
|
-
fontWeight: "500",
|
|
1696
|
-
cursor: "pointer",
|
|
1697
|
-
transition: "all 0.2s"
|
|
1698
|
-
},
|
|
1699
|
-
children: "Refresh Page"
|
|
1700
|
-
}
|
|
1701
|
-
)
|
|
1702
|
-
] }),
|
|
1703
|
-
process.env.NODE_ENV === "development" && /* @__PURE__ */ jsxs(
|
|
1704
|
-
"details",
|
|
1705
|
-
{
|
|
1706
|
-
style: {
|
|
1707
|
-
marginTop: "1rem",
|
|
1708
|
-
fontSize: "0.75rem",
|
|
1709
|
-
color: "#6b7280",
|
|
1710
|
-
width: "100%"
|
|
1711
|
-
},
|
|
1712
|
-
children: [
|
|
1713
|
-
/* @__PURE__ */ jsx("summary", { style: { cursor: "pointer", marginBottom: "0.5rem" }, children: "Error Details" }),
|
|
1714
|
-
/* @__PURE__ */ jsx(
|
|
1715
|
-
"pre",
|
|
1716
|
-
{
|
|
1717
|
-
style: {
|
|
1718
|
-
whiteSpace: "pre-wrap",
|
|
1719
|
-
wordBreak: "break-all",
|
|
1720
|
-
backgroundColor: "#f3f4f6",
|
|
1721
|
-
padding: "0.5rem",
|
|
1722
|
-
borderRadius: "4px",
|
|
1723
|
-
overflow: "auto",
|
|
1724
|
-
maxHeight: "200px"
|
|
1725
|
-
},
|
|
1726
|
-
children: error.message
|
|
1727
|
-
}
|
|
1728
|
-
)
|
|
1729
|
-
]
|
|
1730
|
-
}
|
|
1731
|
-
)
|
|
1732
|
-
]
|
|
1733
|
-
}
|
|
1734
|
-
);
|
|
1735
|
-
}
|
|
1736
|
-
function withErrorBoundary(Component2, errorBoundaryProps) {
|
|
1737
|
-
let WrappedComponent = (props) => /* @__PURE__ */ jsx(ConnectorErrorBoundary, { ...errorBoundaryProps, children: /* @__PURE__ */ jsx(Component2, { ...props }) });
|
|
1738
|
-
return WrappedComponent.displayName = `withErrorBoundary(${Component2.displayName || Component2.name})`, WrappedComponent;
|
|
1739
|
-
}
|
|
1740
|
-
var logger7 = createLogger("Polyfills"), installed = false;
|
|
1935
|
+
var logger6 = createLogger("Polyfills"), installed = false;
|
|
1741
1936
|
function installPolyfills() {
|
|
1742
1937
|
if (!(installed || typeof window > "u"))
|
|
1743
1938
|
try {
|
|
1744
|
-
install(), installed = true,
|
|
1939
|
+
install(), installed = true, logger6.info("Browser compatibility polyfills installed");
|
|
1745
1940
|
} catch (error) {
|
|
1746
|
-
|
|
1941
|
+
logger6 && logger6.warn("Failed to install polyfills", { error }), installed = true;
|
|
1747
1942
|
}
|
|
1748
1943
|
}
|
|
1749
1944
|
function isPolyfillInstalled() {
|
|
@@ -1764,6 +1959,404 @@ function getPolyfillStatus() {
|
|
|
1764
1959
|
environment: typeof window < "u" ? "browser" : "server"
|
|
1765
1960
|
};
|
|
1766
1961
|
}
|
|
1962
|
+
var logger7 = createLogger("EnhancedStorage"), STORAGE_VERSION = "v1", EnhancedStorage = class extends Storage {
|
|
1963
|
+
constructor(key, initial, options) {
|
|
1964
|
+
super(key, initial);
|
|
1965
|
+
this.options = options;
|
|
1966
|
+
__publicField(this, "errorHandlers", /* @__PURE__ */ new Set());
|
|
1967
|
+
__publicField(this, "validators", []);
|
|
1968
|
+
__publicField(this, "memoryFallback");
|
|
1969
|
+
this.memoryFallback = initial, options?.onError && this.errorHandlers.add(options.onError), options?.validator && this.validators.push(options.validator);
|
|
1970
|
+
}
|
|
1971
|
+
set(value) {
|
|
1972
|
+
try {
|
|
1973
|
+
return this.validate(value) ? (super.set(value), this.memoryFallback = value, true) : (logger7.warn("Validation failed", { key: this.key }), false);
|
|
1974
|
+
} catch (error) {
|
|
1975
|
+
return this.handleError(error), this.options?.useMemoryFallback ? (this.memoryFallback = value, true) : false;
|
|
1976
|
+
}
|
|
1977
|
+
}
|
|
1978
|
+
get() {
|
|
1979
|
+
try {
|
|
1980
|
+
return super.get();
|
|
1981
|
+
} catch (error) {
|
|
1982
|
+
return this.handleError(error), this.options?.useMemoryFallback ? this.memoryFallback : this.initial;
|
|
1983
|
+
}
|
|
1984
|
+
}
|
|
1985
|
+
validate(value) {
|
|
1986
|
+
return this.validators.every((validator) => validator(value));
|
|
1987
|
+
}
|
|
1988
|
+
addValidator(validator) {
|
|
1989
|
+
return this.validators.push(validator), this;
|
|
1990
|
+
}
|
|
1991
|
+
onError(handler) {
|
|
1992
|
+
return this.errorHandlers.add(handler), this;
|
|
1993
|
+
}
|
|
1994
|
+
transform(transformer) {
|
|
1995
|
+
return transformer(this.get());
|
|
1996
|
+
}
|
|
1997
|
+
reset() {
|
|
1998
|
+
this.set(this.initial);
|
|
1999
|
+
}
|
|
2000
|
+
clear() {
|
|
2001
|
+
try {
|
|
2002
|
+
typeof window < "u" && window.localStorage && window.localStorage.removeItem(this.key), this.reset();
|
|
2003
|
+
} catch (error) {
|
|
2004
|
+
this.handleError(error);
|
|
2005
|
+
}
|
|
2006
|
+
}
|
|
2007
|
+
isAvailable() {
|
|
2008
|
+
try {
|
|
2009
|
+
if (typeof window > "u") return false;
|
|
2010
|
+
let testKey = `__storage_test_${this.key}__`;
|
|
2011
|
+
return window.localStorage.setItem(testKey, "test"), window.localStorage.removeItem(testKey), true;
|
|
2012
|
+
} catch {
|
|
2013
|
+
return false;
|
|
2014
|
+
}
|
|
2015
|
+
}
|
|
2016
|
+
static migrate(oldKey, newStorage) {
|
|
2017
|
+
try {
|
|
2018
|
+
if (typeof window > "u") return false;
|
|
2019
|
+
let oldValue = window.localStorage.getItem(oldKey);
|
|
2020
|
+
if (oldValue) {
|
|
2021
|
+
let parsed = JSON.parse(oldValue);
|
|
2022
|
+
return newStorage.set(parsed), window.localStorage.removeItem(oldKey), true;
|
|
2023
|
+
}
|
|
2024
|
+
return false;
|
|
2025
|
+
} catch {
|
|
2026
|
+
return false;
|
|
2027
|
+
}
|
|
2028
|
+
}
|
|
2029
|
+
handleError(error) {
|
|
2030
|
+
logger7.error("Storage error", { key: this.key, error }), this.errorHandlers.forEach((handler) => {
|
|
2031
|
+
try {
|
|
2032
|
+
handler(error);
|
|
2033
|
+
} catch (err) {
|
|
2034
|
+
logger7.error("Error in error handler", { error: err });
|
|
2035
|
+
}
|
|
2036
|
+
});
|
|
2037
|
+
}
|
|
2038
|
+
};
|
|
2039
|
+
function createEnhancedStorageAccount(options) {
|
|
2040
|
+
let key = options?.key ?? `connector-kit:${STORAGE_VERSION}:account`;
|
|
2041
|
+
return new EnhancedStorage(key, options?.initial, {
|
|
2042
|
+
validator: options?.validator,
|
|
2043
|
+
onError: options?.onError,
|
|
2044
|
+
useMemoryFallback: true
|
|
2045
|
+
// Always fallback for SSR
|
|
2046
|
+
});
|
|
2047
|
+
}
|
|
2048
|
+
function createEnhancedStorageCluster(options) {
|
|
2049
|
+
let key = options?.key ?? `connector-kit:${STORAGE_VERSION}:cluster`, storage = new EnhancedStorage(key, options?.initial ?? "solana:mainnet", {
|
|
2050
|
+
onError: options?.onError,
|
|
2051
|
+
useMemoryFallback: true
|
|
2052
|
+
});
|
|
2053
|
+
return options?.validClusters && storage.addValidator((clusterId) => options.validClusters.includes(clusterId)), storage;
|
|
2054
|
+
}
|
|
2055
|
+
function createEnhancedStorageWallet(options) {
|
|
2056
|
+
let key = options?.key ?? `connector-kit:${STORAGE_VERSION}:wallet`;
|
|
2057
|
+
return new EnhancedStorage(key, options?.initial, {
|
|
2058
|
+
onError: options?.onError,
|
|
2059
|
+
useMemoryFallback: true
|
|
2060
|
+
});
|
|
2061
|
+
}
|
|
2062
|
+
var WALLET_STATE_VERSION = 1;
|
|
2063
|
+
function createEnhancedStorageWalletState(options) {
|
|
2064
|
+
let key = options?.key ?? `connector-kit:${STORAGE_VERSION}:wallet-state`, legacyKey = `connector-kit:${STORAGE_VERSION}:wallet`, storage = new EnhancedStorage(key, options?.initial ?? null, {
|
|
2065
|
+
onError: options?.onError,
|
|
2066
|
+
useMemoryFallback: true
|
|
2067
|
+
});
|
|
2068
|
+
if (typeof window < "u" && storage.isAvailable())
|
|
2069
|
+
try {
|
|
2070
|
+
if (!storage.get()) {
|
|
2071
|
+
let legacyValue = window.localStorage.getItem(legacyKey);
|
|
2072
|
+
if (legacyValue) {
|
|
2073
|
+
let legacyWalletName = JSON.parse(legacyValue);
|
|
2074
|
+
if (legacyWalletName && typeof legacyWalletName == "string") {
|
|
2075
|
+
let connectorId = options?.migrateLegacy ? options.migrateLegacy(legacyWalletName) : createConnectorId(legacyWalletName);
|
|
2076
|
+
if (connectorId) {
|
|
2077
|
+
let migratedState = {
|
|
2078
|
+
version: WALLET_STATE_VERSION,
|
|
2079
|
+
connectorId,
|
|
2080
|
+
autoConnect: true,
|
|
2081
|
+
lastConnected: (/* @__PURE__ */ new Date()).toISOString()
|
|
2082
|
+
};
|
|
2083
|
+
storage.set(migratedState), logger7.info("Migrated legacy wallet storage", {
|
|
2084
|
+
from: legacyWalletName,
|
|
2085
|
+
to: connectorId
|
|
2086
|
+
}), window.localStorage.removeItem(legacyKey);
|
|
2087
|
+
}
|
|
2088
|
+
}
|
|
2089
|
+
}
|
|
2090
|
+
}
|
|
2091
|
+
} catch (error) {
|
|
2092
|
+
logger7.warn("Failed to migrate legacy wallet storage", { error });
|
|
2093
|
+
}
|
|
2094
|
+
return storage;
|
|
2095
|
+
}
|
|
2096
|
+
function saveWalletState(storage, connectorId, account, autoConnect = true) {
|
|
2097
|
+
let state = {
|
|
2098
|
+
version: WALLET_STATE_VERSION,
|
|
2099
|
+
connectorId,
|
|
2100
|
+
lastAccount: account,
|
|
2101
|
+
autoConnect,
|
|
2102
|
+
lastConnected: (/* @__PURE__ */ new Date()).toISOString()
|
|
2103
|
+
};
|
|
2104
|
+
storage.set(state);
|
|
2105
|
+
}
|
|
2106
|
+
function clearWalletState(storage) {
|
|
2107
|
+
storage.set(null);
|
|
2108
|
+
}
|
|
2109
|
+
var EnhancedStorageAdapter = class {
|
|
2110
|
+
constructor(storage) {
|
|
2111
|
+
this.storage = storage;
|
|
2112
|
+
}
|
|
2113
|
+
get() {
|
|
2114
|
+
return this.storage.get();
|
|
2115
|
+
}
|
|
2116
|
+
set(value) {
|
|
2117
|
+
this.storage.set(value);
|
|
2118
|
+
}
|
|
2119
|
+
subscribe(callback) {
|
|
2120
|
+
return this.storage.value.subscribe(callback);
|
|
2121
|
+
}
|
|
2122
|
+
validate(value) {
|
|
2123
|
+
return this.storage.validate(value);
|
|
2124
|
+
}
|
|
2125
|
+
reset() {
|
|
2126
|
+
this.storage.reset();
|
|
2127
|
+
}
|
|
2128
|
+
clear() {
|
|
2129
|
+
this.storage.clear();
|
|
2130
|
+
}
|
|
2131
|
+
isAvailable() {
|
|
2132
|
+
return this.storage.isAvailable();
|
|
2133
|
+
}
|
|
2134
|
+
transform(transformer) {
|
|
2135
|
+
return this.storage.transform(transformer);
|
|
2136
|
+
}
|
|
2137
|
+
addValidator(validator) {
|
|
2138
|
+
return this.storage.addValidator(validator), this;
|
|
2139
|
+
}
|
|
2140
|
+
onError(handler) {
|
|
2141
|
+
return this.storage.onError(handler), this;
|
|
2142
|
+
}
|
|
2143
|
+
};
|
|
2144
|
+
var logger8 = createLogger("DefaultConfig");
|
|
2145
|
+
function getDefaultConfig(options) {
|
|
2146
|
+
let {
|
|
2147
|
+
appName,
|
|
2148
|
+
appUrl,
|
|
2149
|
+
autoConnect = true,
|
|
2150
|
+
debug,
|
|
2151
|
+
network = "mainnet-beta",
|
|
2152
|
+
enableMobile = true,
|
|
2153
|
+
storage,
|
|
2154
|
+
clusters,
|
|
2155
|
+
customClusters = [],
|
|
2156
|
+
persistClusterSelection = true,
|
|
2157
|
+
clusterStorageKey,
|
|
2158
|
+
enableErrorBoundary = true,
|
|
2159
|
+
maxRetries = DEFAULT_MAX_RETRIES,
|
|
2160
|
+
onError,
|
|
2161
|
+
imageProxy,
|
|
2162
|
+
programLabels,
|
|
2163
|
+
coingecko,
|
|
2164
|
+
walletConnect
|
|
2165
|
+
} = options, defaultClusters = clusters ?? [
|
|
2166
|
+
createSolanaMainnet(),
|
|
2167
|
+
createSolanaDevnet(),
|
|
2168
|
+
createSolanaTestnet(),
|
|
2169
|
+
...network === "localnet" ? [createSolanaLocalnet()] : [],
|
|
2170
|
+
...customClusters || []
|
|
2171
|
+
], validClusterIds = defaultClusters.map((c) => c.id), accountStorage = createEnhancedStorageAccount({
|
|
2172
|
+
validator: (address) => address ? isAddress(address) : true,
|
|
2173
|
+
onError: (error) => {
|
|
2174
|
+
debug && logger8.error("Account Storage error", { error }), onError && onError(error, {
|
|
2175
|
+
componentStack: "account-storage"
|
|
2176
|
+
});
|
|
2177
|
+
}
|
|
2178
|
+
}), clusterStorage = createEnhancedStorageCluster({
|
|
2179
|
+
key: clusterStorageKey,
|
|
2180
|
+
initial: getInitialCluster(network),
|
|
2181
|
+
validClusters: persistClusterSelection ? validClusterIds : void 0,
|
|
2182
|
+
onError: (error) => {
|
|
2183
|
+
debug && logger8.error("Cluster Storage error", { error }), onError && onError(error, {
|
|
2184
|
+
componentStack: "cluster-storage"
|
|
2185
|
+
});
|
|
2186
|
+
}
|
|
2187
|
+
}), walletStorage = createEnhancedStorageWallet({
|
|
2188
|
+
onError: (error) => {
|
|
2189
|
+
debug && logger8.error("Wallet Storage error", { error }), onError && onError(error, {
|
|
2190
|
+
componentStack: "wallet-storage"
|
|
2191
|
+
});
|
|
2192
|
+
}
|
|
2193
|
+
});
|
|
2194
|
+
if (typeof window < "u") {
|
|
2195
|
+
let oldAccountKey = "connector-kit:account", oldWalletKey = "connector-kit:wallet", oldClusterKey = clusterStorageKey || "connector-kit:cluster";
|
|
2196
|
+
EnhancedStorage.migrate(oldAccountKey, accountStorage), EnhancedStorage.migrate(oldWalletKey, walletStorage), EnhancedStorage.migrate(oldClusterKey, clusterStorage);
|
|
2197
|
+
}
|
|
2198
|
+
let defaultStorage = storage ?? {
|
|
2199
|
+
account: new EnhancedStorageAdapter(accountStorage),
|
|
2200
|
+
cluster: new EnhancedStorageAdapter(clusterStorage),
|
|
2201
|
+
wallet: new EnhancedStorageAdapter(walletStorage)
|
|
2202
|
+
}, walletConnectConfig = buildWalletConnectConfig(walletConnect, appName, appUrl, clusterStorageKey ?? "connector-kit:v1:cluster");
|
|
2203
|
+
return {
|
|
2204
|
+
autoConnect,
|
|
2205
|
+
debug: debug ?? process.env.NODE_ENV === "development",
|
|
2206
|
+
storage: defaultStorage,
|
|
2207
|
+
appName,
|
|
2208
|
+
appUrl,
|
|
2209
|
+
enableMobile,
|
|
2210
|
+
network,
|
|
2211
|
+
cluster: {
|
|
2212
|
+
clusters: defaultClusters,
|
|
2213
|
+
persistSelection: persistClusterSelection,
|
|
2214
|
+
initialCluster: getInitialCluster(network)
|
|
2215
|
+
},
|
|
2216
|
+
errorBoundary: {
|
|
2217
|
+
enabled: enableErrorBoundary,
|
|
2218
|
+
maxRetries,
|
|
2219
|
+
onError
|
|
2220
|
+
},
|
|
2221
|
+
imageProxy,
|
|
2222
|
+
programLabels,
|
|
2223
|
+
coingecko,
|
|
2224
|
+
walletConnect: walletConnectConfig
|
|
2225
|
+
};
|
|
2226
|
+
}
|
|
2227
|
+
function buildWalletConnectConfig(walletConnect, appName, appUrl, clusterStorageKey) {
|
|
2228
|
+
if (!walletConnect) return;
|
|
2229
|
+
let configProjectId = typeof walletConnect == "object" ? walletConnect.projectId : void 0, envProjectId = typeof process < "u" ? process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID : void 0, projectId = configProjectId || envProjectId;
|
|
2230
|
+
if (!projectId) {
|
|
2231
|
+
(typeof walletConnect == "object" || walletConnect === true) && logger8.warn(
|
|
2232
|
+
"WalletConnect enabled but no project ID found. Set NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID or provide projectId in config."
|
|
2233
|
+
);
|
|
2234
|
+
return;
|
|
2235
|
+
}
|
|
2236
|
+
let origin = appUrl || (typeof window < "u" ? window.location.origin : "http://localhost:3000"), customMetadata = typeof walletConnect == "object" ? walletConnect.metadata : void 0, customDefaultChain = typeof walletConnect == "object" ? walletConnect.defaultChain : void 0, customRelayUrl = typeof walletConnect == "object" ? walletConnect.relayUrl : void 0;
|
|
2237
|
+
return {
|
|
2238
|
+
enabled: true,
|
|
2239
|
+
projectId,
|
|
2240
|
+
metadata: {
|
|
2241
|
+
name: customMetadata?.name ?? appName,
|
|
2242
|
+
description: customMetadata?.description ?? `${appName} - Powered by ConnectorKit`,
|
|
2243
|
+
url: customMetadata?.url ?? origin,
|
|
2244
|
+
icons: customMetadata?.icons ?? [`${origin}/icon.svg`]
|
|
2245
|
+
},
|
|
2246
|
+
defaultChain: customDefaultChain ?? "solana:mainnet",
|
|
2247
|
+
relayUrl: customRelayUrl,
|
|
2248
|
+
// Auto-sync with cluster storage
|
|
2249
|
+
getCurrentChain: () => {
|
|
2250
|
+
if (typeof window > "u") return "solana:mainnet";
|
|
2251
|
+
let storageKey = clusterStorageKey || "connector-kit:v1:cluster";
|
|
2252
|
+
try {
|
|
2253
|
+
let stored = localStorage.getItem(storageKey);
|
|
2254
|
+
if (stored) {
|
|
2255
|
+
let id = JSON.parse(stored);
|
|
2256
|
+
if (id === "solana:mainnet" || id === "solana:devnet" || id === "solana:testnet")
|
|
2257
|
+
return id;
|
|
2258
|
+
}
|
|
2259
|
+
} catch {
|
|
2260
|
+
}
|
|
2261
|
+
return customDefaultChain ?? "solana:mainnet";
|
|
2262
|
+
}
|
|
2263
|
+
// Note: onDisplayUri, onSessionEstablished, onSessionDisconnected are auto-wired by AppProvider
|
|
2264
|
+
};
|
|
2265
|
+
}
|
|
2266
|
+
function getInitialCluster(network = "mainnet-beta") {
|
|
2267
|
+
return toClusterId(network);
|
|
2268
|
+
}
|
|
2269
|
+
function getDefaultMobileConfig(options) {
|
|
2270
|
+
let baseUrl = options.appUrl || (typeof window < "u" ? window.location.origin : "https://localhost:3000");
|
|
2271
|
+
return {
|
|
2272
|
+
appIdentity: {
|
|
2273
|
+
name: options.appName,
|
|
2274
|
+
uri: baseUrl,
|
|
2275
|
+
icon: `${baseUrl}/favicon.ico`
|
|
2276
|
+
},
|
|
2277
|
+
cluster: options.network || "mainnet-beta"
|
|
2278
|
+
};
|
|
2279
|
+
}
|
|
2280
|
+
var solanaNetworkSchema = z.enum(["mainnet", "mainnet-beta", "devnet", "testnet", "localnet"]), solanaClusterIdSchema = z.string().regex(/^solana:(mainnet|devnet|testnet|localnet|[a-zA-Z0-9-]+)$/, {
|
|
2281
|
+
message: 'Cluster ID must be in format "solana:<network>" (e.g., "solana:mainnet")'
|
|
2282
|
+
}), urlSchema = z.string().url("Invalid URL format"), optionalUrlSchema = urlSchema.optional(), coinGeckoConfigSchema = z.strictObject({
|
|
2283
|
+
apiKey: z.string().optional(),
|
|
2284
|
+
isPro: z.boolean().optional(),
|
|
2285
|
+
maxRetries: z.number().int().positive().max(10).optional(),
|
|
2286
|
+
baseDelay: z.number().int().positive().max(3e4).optional(),
|
|
2287
|
+
maxTimeout: z.number().int().positive().max(12e4).optional()
|
|
2288
|
+
}).optional(), walletConnectMetadataSchema = z.object({
|
|
2289
|
+
name: z.string().min(1, "WalletConnect app name is required"),
|
|
2290
|
+
description: z.string(),
|
|
2291
|
+
url: urlSchema,
|
|
2292
|
+
icons: z.array(z.string())
|
|
2293
|
+
}), walletConnectObjectConfigSchema = z.object({
|
|
2294
|
+
enabled: z.boolean().optional(),
|
|
2295
|
+
projectId: z.string().min(1, "WalletConnect projectId is required"),
|
|
2296
|
+
metadata: walletConnectMetadataSchema,
|
|
2297
|
+
defaultChain: z.enum(["solana:mainnet", "solana:devnet", "solana:testnet"]).optional(),
|
|
2298
|
+
onDisplayUri: z.custom((val) => typeof val == "function").optional(),
|
|
2299
|
+
onSessionEstablished: z.custom((val) => typeof val == "function").optional(),
|
|
2300
|
+
onSessionDisconnected: z.custom((val) => typeof val == "function").optional(),
|
|
2301
|
+
relayUrl: urlSchema.optional()
|
|
2302
|
+
}), walletConnectConfigSchema = z.union([z.literal(true), walletConnectObjectConfigSchema]).optional(), storageAdapterSchema = z.looseObject({
|
|
2303
|
+
get: z.custom((val) => typeof val == "function"),
|
|
2304
|
+
set: z.custom((val) => typeof val == "function")
|
|
2305
|
+
}), storageConfigSchema = z.object({
|
|
2306
|
+
account: storageAdapterSchema,
|
|
2307
|
+
cluster: storageAdapterSchema,
|
|
2308
|
+
wallet: storageAdapterSchema
|
|
2309
|
+
}).optional(), solanaClusterSchema = z.object({
|
|
2310
|
+
id: solanaClusterIdSchema,
|
|
2311
|
+
label: z.string().min(1, "Cluster label cannot be empty"),
|
|
2312
|
+
url: urlSchema,
|
|
2313
|
+
urlWs: urlSchema.optional()
|
|
2314
|
+
}), clusterConfigSchema = z.object({
|
|
2315
|
+
clusters: z.array(solanaClusterSchema).optional(),
|
|
2316
|
+
persistSelection: z.boolean().optional(),
|
|
2317
|
+
initialCluster: solanaClusterIdSchema.optional()
|
|
2318
|
+
}).optional(), defaultConfigOptionsSchema = z.object({
|
|
2319
|
+
// Required
|
|
2320
|
+
appName: z.string().min(1, "Application name is required"),
|
|
2321
|
+
// Optional strings
|
|
2322
|
+
appUrl: optionalUrlSchema,
|
|
2323
|
+
imageProxy: z.string().optional(),
|
|
2324
|
+
clusterStorageKey: z.string().optional(),
|
|
2325
|
+
// Optional booleans
|
|
2326
|
+
autoConnect: z.boolean().optional(),
|
|
2327
|
+
debug: z.boolean().optional(),
|
|
2328
|
+
enableMobile: z.boolean().optional(),
|
|
2329
|
+
persistClusterSelection: z.boolean().optional(),
|
|
2330
|
+
enableErrorBoundary: z.boolean().optional(),
|
|
2331
|
+
// Network
|
|
2332
|
+
network: solanaNetworkSchema.optional(),
|
|
2333
|
+
// Numbers
|
|
2334
|
+
maxRetries: z.number().int().positive().max(10).optional(),
|
|
2335
|
+
// Complex types
|
|
2336
|
+
storage: storageConfigSchema,
|
|
2337
|
+
clusters: z.array(solanaClusterSchema).optional(),
|
|
2338
|
+
customClusters: z.array(solanaClusterSchema).optional(),
|
|
2339
|
+
programLabels: z.record(z.string(), z.string()).optional(),
|
|
2340
|
+
coingecko: coinGeckoConfigSchema,
|
|
2341
|
+
walletConnect: walletConnectConfigSchema,
|
|
2342
|
+
// Functions (can't validate implementation, just existence)
|
|
2343
|
+
onError: z.custom((val) => typeof val == "function").optional()
|
|
2344
|
+
}); z.strictObject({
|
|
2345
|
+
autoConnect: z.boolean().optional(),
|
|
2346
|
+
debug: z.boolean().optional(),
|
|
2347
|
+
storage: storageConfigSchema,
|
|
2348
|
+
cluster: clusterConfigSchema,
|
|
2349
|
+
imageProxy: z.string().optional(),
|
|
2350
|
+
programLabels: z.record(z.string(), z.string()).optional(),
|
|
2351
|
+
coingecko: coinGeckoConfigSchema,
|
|
2352
|
+
walletConnect: walletConnectConfigSchema
|
|
2353
|
+
}).optional();
|
|
2354
|
+
function validateConfigOptions(options) {
|
|
2355
|
+
return defaultConfigOptionsSchema.safeParse(options);
|
|
2356
|
+
}
|
|
2357
|
+
function parseConfigOptions(options) {
|
|
2358
|
+
return defaultConfigOptionsSchema.parse(options);
|
|
2359
|
+
}
|
|
1767
2360
|
|
|
1768
2361
|
// src/utils/formatting.ts
|
|
1769
2362
|
function formatAddress(address, options = {}) {
|
|
@@ -1975,7 +2568,7 @@ async function copySignatureToClipboard(signature, options) {
|
|
|
1975
2568
|
}
|
|
1976
2569
|
|
|
1977
2570
|
// src/lib/transaction/transaction-validator.ts
|
|
1978
|
-
var
|
|
2571
|
+
var logger9 = createLogger("TransactionValidator"), MAX_TRANSACTION_SIZE = 1232, MIN_TRANSACTION_SIZE = 64, TransactionValidator = class {
|
|
1979
2572
|
/**
|
|
1980
2573
|
* Validate a transaction before signing
|
|
1981
2574
|
*
|
|
@@ -1998,7 +2591,7 @@ var logger8 = createLogger("TransactionValidator"), MAX_TRANSACTION_SIZE = 1232,
|
|
|
1998
2591
|
try {
|
|
1999
2592
|
serialized = transaction.serialize();
|
|
2000
2593
|
} catch (serializeError) {
|
|
2001
|
-
|
|
2594
|
+
logger9.debug("Transaction not yet serializable (may need signing)", {
|
|
2002
2595
|
error: serializeError instanceof Error ? serializeError.message : String(serializeError)
|
|
2003
2596
|
});
|
|
2004
2597
|
}
|
|
@@ -2008,10 +2601,10 @@ var logger8 = createLogger("TransactionValidator"), MAX_TRANSACTION_SIZE = 1232,
|
|
|
2008
2601
|
return errors.push(
|
|
2009
2602
|
"Transaction type not recognized - must be a Transaction object with serialize() or Uint8Array"
|
|
2010
2603
|
), { valid: false, errors, warnings };
|
|
2011
|
-
serialized && (size = serialized.length, size > maxSize && (errors.push(`Transaction too large: ${size} bytes (max ${maxSize} bytes)`),
|
|
2604
|
+
serialized && (size = serialized.length, size > maxSize && (errors.push(`Transaction too large: ${size} bytes (max ${maxSize} bytes)`), logger9.warn("Transaction exceeds maximum size", { size, maxSize })), size < minSize && warnings.push(`Transaction is very small: ${size} bytes (min recommended ${minSize} bytes)`), size === 0 && errors.push("Transaction is empty (0 bytes)"), this.hasSuspiciousPattern(serialized) && warnings.push("Transaction contains unusual patterns - please review carefully"));
|
|
2012
2605
|
} catch (error) {
|
|
2013
2606
|
let errorMessage = error instanceof Error ? error.message : String(error);
|
|
2014
|
-
errors.push(`Transaction validation failed: ${errorMessage}`),
|
|
2607
|
+
errors.push(`Transaction validation failed: ${errorMessage}`), logger9.error("Validation error", { error: errorMessage });
|
|
2015
2608
|
}
|
|
2016
2609
|
if (checkDuplicateSignatures && typeof transaction == "object" && "signatures" in transaction) {
|
|
2017
2610
|
let signatures = transaction.signatures;
|
|
@@ -2024,7 +2617,7 @@ var logger8 = createLogger("TransactionValidator"), MAX_TRANSACTION_SIZE = 1232,
|
|
|
2024
2617
|
}
|
|
2025
2618
|
strict && warnings.length > 0 && (errors.push(...warnings.map((w) => `Strict mode: ${w}`)), warnings.length = 0);
|
|
2026
2619
|
let valid = errors.length === 0;
|
|
2027
|
-
return valid ? warnings.length > 0 ?
|
|
2620
|
+
return valid ? warnings.length > 0 ? logger9.debug("Transaction validation passed with warnings", { warnings, size }) : logger9.debug("Transaction validation passed", { size }) : logger9.warn("Transaction validation failed", { errors, size }), {
|
|
2028
2621
|
valid,
|
|
2029
2622
|
errors,
|
|
2030
2623
|
warnings,
|
|
@@ -2064,7 +2657,7 @@ var logger8 = createLogger("TransactionValidator"), MAX_TRANSACTION_SIZE = 1232,
|
|
|
2064
2657
|
let result = this.validate(transaction, options);
|
|
2065
2658
|
if (!result.valid)
|
|
2066
2659
|
throw new Error(`Transaction validation failed: ${result.errors.join(", ")}`);
|
|
2067
|
-
result.warnings.length > 0 &&
|
|
2660
|
+
result.warnings.length > 0 && logger9.warn("Transaction validation warnings", { warnings: result.warnings });
|
|
2068
2661
|
}
|
|
2069
2662
|
/**
|
|
2070
2663
|
* Batch validate multiple transactions
|
|
@@ -2075,10 +2668,10 @@ var logger8 = createLogger("TransactionValidator"), MAX_TRANSACTION_SIZE = 1232,
|
|
|
2075
2668
|
* @returns Array of validation results
|
|
2076
2669
|
*/
|
|
2077
2670
|
static validateBatch(transactions, options) {
|
|
2078
|
-
return transactions.map((tx, index) => (
|
|
2671
|
+
return transactions.map((tx, index) => (logger9.debug(`Validating transaction ${index + 1}/${transactions.length}`), this.validate(tx, options)));
|
|
2079
2672
|
}
|
|
2080
2673
|
};
|
|
2081
|
-
var
|
|
2674
|
+
var logger10 = createLogger("TransactionSigner");
|
|
2082
2675
|
function signatureBytesToBase58(bytes) {
|
|
2083
2676
|
if (bytes.length !== 64)
|
|
2084
2677
|
throw new Error(`Invalid signature length: expected 64 bytes, got ${bytes.length}`);
|
|
@@ -2100,6 +2693,24 @@ function extractSignatureString(result) {
|
|
|
2100
2693
|
}
|
|
2101
2694
|
throw new Error("Unexpected wallet response format for signAndSendTransaction");
|
|
2102
2695
|
}
|
|
2696
|
+
function extractSignatureBytes(result) {
|
|
2697
|
+
if (result instanceof Uint8Array)
|
|
2698
|
+
return result;
|
|
2699
|
+
if (Array.isArray(result)) {
|
|
2700
|
+
let [first] = result;
|
|
2701
|
+
if (!first)
|
|
2702
|
+
throw new Error("Wallet returned empty results array");
|
|
2703
|
+
return extractSignatureBytes(first);
|
|
2704
|
+
}
|
|
2705
|
+
if (result && typeof result == "object") {
|
|
2706
|
+
let record = result;
|
|
2707
|
+
if ("signature" in record)
|
|
2708
|
+
return extractSignatureBytes(record.signature);
|
|
2709
|
+
if (Array.isArray(record.signatures) && record.signatures.length > 0)
|
|
2710
|
+
return extractSignatureBytes(record.signatures[0]);
|
|
2711
|
+
}
|
|
2712
|
+
throw new Error("Unexpected wallet response format for signMessage");
|
|
2713
|
+
}
|
|
2103
2714
|
function createTransactionSigner(config) {
|
|
2104
2715
|
let { wallet, account, cluster, eventEmitter } = config;
|
|
2105
2716
|
if (!wallet || !account)
|
|
@@ -2116,11 +2727,11 @@ function createTransactionSigner(config) {
|
|
|
2116
2727
|
throw Errors.featureNotSupported("transaction signing");
|
|
2117
2728
|
let validation = TransactionValidator.validate(transaction);
|
|
2118
2729
|
if (!validation.valid)
|
|
2119
|
-
throw
|
|
2120
|
-
validation.warnings.length > 0 &&
|
|
2730
|
+
throw logger10.error("Transaction validation failed", { errors: validation.errors }), Errors.invalidTransaction(validation.errors.join(", "));
|
|
2731
|
+
validation.warnings.length > 0 && logger10.warn("Transaction validation warnings", { warnings: validation.warnings });
|
|
2121
2732
|
try {
|
|
2122
2733
|
let signFeature = features["solana:signTransaction"], { serialized, wasWeb3js } = prepareTransactionForWallet(transaction);
|
|
2123
|
-
|
|
2734
|
+
logger10.debug("Signing transaction", {
|
|
2124
2735
|
wasWeb3js,
|
|
2125
2736
|
serializedLength: serialized.length,
|
|
2126
2737
|
serializedType: serialized.constructor.name,
|
|
@@ -2129,26 +2740,26 @@ function createTransactionSigner(config) {
|
|
|
2129
2740
|
});
|
|
2130
2741
|
let result, usedFormat = "";
|
|
2131
2742
|
try {
|
|
2132
|
-
|
|
2743
|
+
logger10.debug("Trying array format: transactions: [Uint8Array]"), result = await signFeature.signTransaction({
|
|
2133
2744
|
account,
|
|
2134
2745
|
transactions: [serialized],
|
|
2135
2746
|
...cluster ? { chain: cluster.id } : {}
|
|
2136
2747
|
}), usedFormat = "array";
|
|
2137
2748
|
} catch (err1) {
|
|
2138
2749
|
let error1 = err1 instanceof Error ? err1 : new Error(String(err1));
|
|
2139
|
-
|
|
2750
|
+
logger10.debug("Array format failed, trying singular format", { error: error1.message });
|
|
2140
2751
|
try {
|
|
2141
|
-
|
|
2752
|
+
logger10.debug("Trying singular format: transaction: Uint8Array"), result = await signFeature.signTransaction({
|
|
2142
2753
|
account,
|
|
2143
2754
|
transaction: serialized,
|
|
2144
2755
|
...cluster ? { chain: cluster.id } : {}
|
|
2145
2756
|
}), usedFormat = "singular";
|
|
2146
2757
|
} catch (err2) {
|
|
2147
2758
|
let error2 = err2 instanceof Error ? err2 : new Error(String(err2));
|
|
2148
|
-
throw
|
|
2759
|
+
throw logger10.error("Both array and singular formats failed", { error: error2.message }), error2;
|
|
2149
2760
|
}
|
|
2150
2761
|
}
|
|
2151
|
-
|
|
2762
|
+
logger10.debug("Wallet signed successfully", { format: usedFormat });
|
|
2152
2763
|
let signedTx;
|
|
2153
2764
|
if (Array.isArray(result.signedTransactions) && result.signedTransactions[0])
|
|
2154
2765
|
signedTx = result.signedTransactions[0];
|
|
@@ -2160,23 +2771,23 @@ function createTransactionSigner(config) {
|
|
|
2160
2771
|
signedTx = result;
|
|
2161
2772
|
else
|
|
2162
2773
|
throw new Error(`Unexpected wallet response format: ${JSON.stringify(Object.keys(result))}`);
|
|
2163
|
-
if (
|
|
2774
|
+
if (logger10.debug("Extracted signed transaction", {
|
|
2164
2775
|
hasSignedTx: !!signedTx,
|
|
2165
2776
|
signedTxType: signedTx?.constructor?.name,
|
|
2166
2777
|
signedTxLength: signedTx?.length,
|
|
2167
2778
|
isUint8Array: signedTx instanceof Uint8Array,
|
|
2168
2779
|
hasSerialize: typeof signedTx?.serialize == "function"
|
|
2169
2780
|
}), signedTx && typeof signedTx.serialize == "function")
|
|
2170
|
-
return
|
|
2781
|
+
return logger10.debug("Wallet returned web3.js object directly, no conversion needed"), signedTx;
|
|
2171
2782
|
if (signedTx && signedTx.signedTransaction) {
|
|
2172
|
-
|
|
2783
|
+
logger10.debug("Found signedTransaction property");
|
|
2173
2784
|
let bytes = signedTx.signedTransaction;
|
|
2174
2785
|
if (bytes instanceof Uint8Array)
|
|
2175
2786
|
return await convertSignedTransaction(bytes, wasWeb3js);
|
|
2176
2787
|
}
|
|
2177
2788
|
if (signedTx instanceof Uint8Array)
|
|
2178
2789
|
return await convertSignedTransaction(signedTx, wasWeb3js);
|
|
2179
|
-
throw
|
|
2790
|
+
throw logger10.error("Unexpected wallet response format", {
|
|
2180
2791
|
type: typeof signedTx,
|
|
2181
2792
|
constructor: signedTx?.constructor?.name
|
|
2182
2793
|
}), new ValidationError(
|
|
@@ -2196,9 +2807,15 @@ function createTransactionSigner(config) {
|
|
|
2196
2807
|
account,
|
|
2197
2808
|
transactions: serializedTxs,
|
|
2198
2809
|
...cluster ? { chain: cluster.id } : {}
|
|
2199
|
-
});
|
|
2810
|
+
}), signedBytesArray;
|
|
2811
|
+
if (Array.isArray(result))
|
|
2812
|
+
signedBytesArray = result.map((item) => item.signedTransaction);
|
|
2813
|
+
else if ("signedTransactions" in result)
|
|
2814
|
+
signedBytesArray = result.signedTransactions;
|
|
2815
|
+
else
|
|
2816
|
+
throw new Error("Unexpected signAllTransactions response format");
|
|
2200
2817
|
return await Promise.all(
|
|
2201
|
-
|
|
2818
|
+
signedBytesArray.map(
|
|
2202
2819
|
(signedBytes) => convertSignedTransaction(signedBytes, wasWeb3js)
|
|
2203
2820
|
)
|
|
2204
2821
|
);
|
|
@@ -2292,11 +2909,12 @@ function createTransactionSigner(config) {
|
|
|
2292
2909
|
...capabilities.canSignMessage && {
|
|
2293
2910
|
async signMessage(message) {
|
|
2294
2911
|
try {
|
|
2295
|
-
|
|
2912
|
+
let result = await features["solana:signMessage"].signMessage({
|
|
2296
2913
|
account,
|
|
2297
2914
|
message,
|
|
2298
2915
|
...cluster ? { chain: cluster.id } : {}
|
|
2299
|
-
})
|
|
2916
|
+
});
|
|
2917
|
+
return extractSignatureBytes(result);
|
|
2300
2918
|
} catch (error) {
|
|
2301
2919
|
throw new TransactionError("SIGNING_FAILED", "Failed to sign message", void 0, error);
|
|
2302
2920
|
}
|
|
@@ -2317,7 +2935,7 @@ var TransactionSignerError = class extends TransactionError {
|
|
|
2317
2935
|
function isTransactionSignerError(error) {
|
|
2318
2936
|
return error instanceof TransactionSignerError || error instanceof TransactionError;
|
|
2319
2937
|
}
|
|
2320
|
-
var
|
|
2938
|
+
var logger11 = createLogger("KitTransactionSigner");
|
|
2321
2939
|
function encodeShortVecLength(value) {
|
|
2322
2940
|
let bytes = [], remaining = value;
|
|
2323
2941
|
for (; remaining >= 128; )
|
|
@@ -2392,7 +3010,7 @@ function createKitTransactionSigner(connectorSigner) {
|
|
|
2392
3010
|
async modifyAndSignTransactions(transactions) {
|
|
2393
3011
|
let transactionData = transactions.map((tx) => {
|
|
2394
3012
|
let messageBytes = new Uint8Array(tx.messageBytes), { numSigners } = parseMessageSigners(messageBytes), wireFormat = createTransactionBytesForSigning(messageBytes, numSigners);
|
|
2395
|
-
return
|
|
3013
|
+
return logger11.debug("Preparing wire format for wallet", {
|
|
2396
3014
|
signerAddress,
|
|
2397
3015
|
messageBytesLength: messageBytes.length,
|
|
2398
3016
|
wireFormatLength: wireFormat.length,
|
|
@@ -2421,14 +3039,14 @@ function createKitTransactionSigner(connectorSigner) {
|
|
|
2421
3039
|
throw new Error("Web3.js transaction without serialize method");
|
|
2422
3040
|
} else
|
|
2423
3041
|
throw new Error("Unknown signed transaction format");
|
|
2424
|
-
if (
|
|
3042
|
+
if (logger11.debug("Wallet returned signed transaction", {
|
|
2425
3043
|
returnedLength: signedTxBytes.length,
|
|
2426
3044
|
sentLength: wireFormat.length,
|
|
2427
3045
|
lengthsMatch: signedTxBytes.length === wireFormat.length,
|
|
2428
3046
|
signedFirstBytes: Array.from(signedTxBytes.slice(0, 20)),
|
|
2429
3047
|
sentFirstBytes: Array.from(wireFormat.slice(0, 20))
|
|
2430
3048
|
}), signedTxBytes.length !== wireFormat.length) {
|
|
2431
|
-
|
|
3049
|
+
logger11.warn("Wallet modified transaction! Using wallet version", {
|
|
2432
3050
|
originalLength: wireFormat.length,
|
|
2433
3051
|
modifiedLength: signedTxBytes.length,
|
|
2434
3052
|
difference: signedTxBytes.length - wireFormat.length
|
|
@@ -2439,13 +3057,13 @@ function createKitTransactionSigner(connectorSigner) {
|
|
|
2439
3057
|
lifetimeConstraint: originalWithLifetime.lifetimeConstraint
|
|
2440
3058
|
} : {}
|
|
2441
3059
|
};
|
|
2442
|
-
return
|
|
3060
|
+
return logger11.debug("Using modified transaction from wallet", {
|
|
2443
3061
|
modifiedMessageBytesLength: walletTransaction.messageBytes.length,
|
|
2444
3062
|
signatures: Object.keys(walletTransaction.signatures)
|
|
2445
3063
|
}), assertIsTransactionWithinSizeLimit(result), result;
|
|
2446
3064
|
}
|
|
2447
3065
|
let extractedSignatureBytes = extractSignature(signedTxBytes), signatureBase58 = getBase58Decoder().decode(extractedSignatureBytes);
|
|
2448
|
-
|
|
3066
|
+
logger11.debug("Extracted signature from wallet (unmodified)", {
|
|
2449
3067
|
signerAddress,
|
|
2450
3068
|
signatureLength: extractedSignatureBytes.length,
|
|
2451
3069
|
signatureBase58
|
|
@@ -2460,7 +3078,7 @@ function createKitTransactionSigner(connectorSigner) {
|
|
|
2460
3078
|
};
|
|
2461
3079
|
return assertIsTransactionWithinSizeLimit(signedTransaction), signedTransaction;
|
|
2462
3080
|
} catch (error) {
|
|
2463
|
-
return
|
|
3081
|
+
return logger11.error("Failed to decode signed transaction", { error }), assertIsTransactionWithinSizeLimit(originalTransaction), originalTransaction;
|
|
2464
3082
|
}
|
|
2465
3083
|
});
|
|
2466
3084
|
}
|
|
@@ -2468,6 +3086,6 @@ function createKitTransactionSigner(connectorSigner) {
|
|
|
2468
3086
|
}
|
|
2469
3087
|
var createGillTransactionSigner = createKitTransactionSigner;
|
|
2470
3088
|
|
|
2471
|
-
export { ClipboardErrorType, ConnectorClient,
|
|
2472
|
-
//# sourceMappingURL=chunk-
|
|
2473
|
-
//# sourceMappingURL=chunk-
|
|
3089
|
+
export { ClipboardErrorType, ConnectorClient, EnhancedStorage, EnhancedStorageAdapter, INITIAL_WALLET_STATUS, PUBLIC_RPC_ENDPOINTS, TransactionSignerError, WALLET_STATE_VERSION, clearWalletState, copyAddressToClipboard, copySignatureToClipboard, copyToClipboard, createConnectorId, createEnhancedStorageAccount, createEnhancedStorageCluster, createEnhancedStorageWallet, createEnhancedStorageWalletState, createGillTransactionSigner, createKitTransactionSigner, createTransactionSigner, formatAddress, formatBigIntBalance, formatBigIntUsd, formatLamportsToSolSafe, formatNumber, formatSOL, formatTokenAmount, formatTokenBalanceSafe, getAddressUrl, getBlockUrl, getChainIdForWalletStandard, getClusterChainId, getClusterExplorerUrl, getClusterName, getClusterRpcUrl, getClusterType, getDefaultConfig, getDefaultMobileConfig, getDefaultRpcUrl, getNetworkDisplayName, getPolyfillStatus, getTokenUrl, getTransactionUrl, getWalletNameFromConnectorId, getWalletsRegistry, installPolyfills, isClipboardAvailable, isConnected, isConnecting, isCryptoAvailable, isDevnet, isDevnetCluster, isDisconnected, isLocalCluster, isLocalnet, isMainnet, isMainnetCluster, isPolyfillInstalled, isStatusError, isTestnet, isTestnetCluster, isTransactionSignerError, isWalletConnectorId, isWalletStatusError, normalizeNetwork, parseConfigOptions, ready, saveWalletState, toClusterId, toLegacyWalletState, truncate, validateConfigOptions };
|
|
3090
|
+
//# sourceMappingURL=chunk-IDTUFDNB.mjs.map
|
|
3091
|
+
//# sourceMappingURL=chunk-IDTUFDNB.mjs.map
|