@tomo-inc/wallet-adaptor-base 0.0.2 → 0.0.3

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.
Files changed (46) hide show
  1. package/dist/index.cjs +331 -48
  2. package/dist/index.d.cts +23 -3
  3. package/dist/index.d.ts +23 -3
  4. package/dist/index.js +331 -50
  5. package/package.json +2 -1
  6. package/src/index.ts +3 -0
  7. package/src/type.ts +5 -0
  8. package/src/utils/browsers.ts +13 -0
  9. package/src/utils/chainId.ts +1 -1
  10. package/src/wallet-api/chain.ts +9 -2
  11. package/src/wallet-api/connect.ts +83 -20
  12. package/src/wallet-api/sign-in.ts +4 -1
  13. package/src/wallet-api/sign-message.ts +38 -5
  14. package/src/wallets/Wallet.ts +4 -0
  15. package/src/wallets/default/binanceWallet/binanceWallet.ts +27 -0
  16. package/src/wallets/default/bitgetWallet/bitgetWallet.ts +10 -0
  17. package/src/wallets/default/bitverseWallet/bitverseWallet.ts +3 -0
  18. package/src/wallets/default/bybitWallet/bybitWallet.ts +5 -0
  19. package/src/wallets/default/coinbaseWallet/coinbaseWallet.ts +7 -0
  20. package/src/wallets/default/foxWallet/foxWallet.ts +5 -0
  21. package/src/wallets/default/gateWallet/gateWallet.ts +6 -0
  22. package/src/wallets/default/imTokenWallet/imTokenWallet.ts +9 -0
  23. package/src/wallets/default/iopayWallet/iopayWallet.ts +6 -0
  24. package/src/wallets/default/kaiaWallet/kaiaWallet.ts +5 -0
  25. package/src/wallets/default/kaikasWallet/kaikasWallet.ts +5 -0
  26. package/src/wallets/default/krakenWallet/krakenWallet.ts +5 -0
  27. package/src/wallets/default/kresusWallet/kresusWallet.ts +3 -0
  28. package/src/wallets/default/ledgerWallet/ledgerWallet.ts +6 -0
  29. package/src/wallets/default/metaMaskWallet/metaMaskWallet.ts +17 -0
  30. package/src/wallets/default/oktoWallet/oktoWallet.ts +6 -0
  31. package/src/wallets/default/okxWallet/okxWallet.ts +11 -0
  32. package/src/wallets/default/omniWallet/omniWallet.ts +6 -0
  33. package/src/wallets/default/oneInchWallet/oneInchWallet.ts +3 -0
  34. package/src/wallets/default/paraSwapWallet/paraswapWallet.ts +5 -0
  35. package/src/wallets/default/phantomWallet/phantomWallet.ts +7 -0
  36. package/src/wallets/default/rainbowWallet/rainbowWallet.ts +10 -0
  37. package/src/wallets/default/solflareWallet/solflareWallet.ts +7 -0
  38. package/src/wallets/default/tokenPocketWallet/tokenPocketWallet.ts +6 -0
  39. package/src/wallets/default/trustWallet/trustWallet.ts +6 -0
  40. package/src/wallets/default/uniswapWallet/uniswapWallet.ts +5 -0
  41. package/src/wallets/default/valoraWallet/valoraWallet.ts +4 -0
  42. package/src/wallets/default/zealWallet/zealWallet.ts +5 -0
  43. package/src/wallets/default/zerionWallet/zerionWallet.ts +6 -0
  44. package/src/wallets/detector.ts +32 -16
  45. package/src/wallets/providers/WalletConnectProvider.ts +3 -2
  46. package/src/wallets/wallet-walletconnect.ts +1 -1
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { getWallets } from '@wallet-standard/core';
2
2
  import { WalletConnectClient } from '@tomo-inc/wallet-connect-protocol';
3
- import { isHex, fromHex, toHex } from 'viem';
3
+ import { toHex, isHex, fromHex } from 'viem';
4
4
  import { Aptos, AptosConfig } from '@aptos-labs/ts-sdk';
5
5
  import { Connection, PublicKey } from '@solana/web3.js';
6
6
 
@@ -36,6 +36,23 @@ var __objRest = (source, exclude) => {
36
36
  return target;
37
37
  };
38
38
 
39
+ // src/utils/isMobile.ts
40
+ function isAndroid() {
41
+ return typeof navigator !== "undefined" && /android/i.test(navigator.userAgent);
42
+ }
43
+ function isSmallIOS() {
44
+ return typeof navigator !== "undefined" && /iPhone|iPod/.test(navigator.userAgent);
45
+ }
46
+ function isLargeIOS() {
47
+ return typeof navigator !== "undefined" && (/iPad/.test(navigator.userAgent) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1);
48
+ }
49
+ function isIOS() {
50
+ return isSmallIOS() || isLargeIOS();
51
+ }
52
+ function isMobile() {
53
+ return isAndroid() || isIOS() || isLargeIOS();
54
+ }
55
+
39
56
  // src/utils/utils.ts
40
57
  function uniqueConnectors(allConnectors) {
41
58
  const connectors = [];
@@ -117,6 +134,24 @@ var binanceWallet = () => {
117
134
  mobile: "https://www.binance.com/en/download",
118
135
  qrCode: "https://www.binance.com/en/web3wallet",
119
136
  chrome: "https://chromewebstore.google.com/detail/cadiboklkpojfamcoggejbbdjcoiljjk"
137
+ },
138
+ mobile: {
139
+ getUri: (uri) => {
140
+ return isAndroid() ? uri : `bnc://app.binance.com/cedefi/wc?uri=${encodeURIComponent(uri)}`;
141
+ },
142
+ getDeeplink: async (dappUrl, chainId) => {
143
+ if (!dappUrl) return "";
144
+ try {
145
+ const binanceUtils = await import('@binance/w3w-utils').catch(() => null);
146
+ if (binanceUtils && "getDeepLink" in binanceUtils) {
147
+ const getDeepLink = binanceUtils.getDeepLink;
148
+ const result = getDeepLink(dappUrl, chainId);
149
+ return (result == null ? void 0 : result.http) || "";
150
+ }
151
+ } catch (e) {
152
+ }
153
+ return `bnc://app.binance.com/cedefi/dapp?url=${encodeURIComponent(dappUrl)}`;
154
+ }
120
155
  }
121
156
  };
122
157
  };
@@ -147,6 +182,15 @@ var bitgetWallet = () => {
147
182
  qrCode: "https://web3.bitget.com/en/wallet-download",
148
183
  chrome: "https://chrome.google.com/webstore/detail/bitkeep-crypto-nft-wallet/jiidiaalihmmhddjgbnbgdfflelocpak",
149
184
  browserExtension: "https://web3.bitget.com/en/wallet-download"
185
+ },
186
+ mobile: {
187
+ getUri: (uri) => {
188
+ return isAndroid() ? uri : `bitkeep://wc?uri=${encodeURIComponent(uri)}`;
189
+ },
190
+ getDeeplink: (dappUrl) => {
191
+ if (!dappUrl) return "";
192
+ return `https://bkcode.vip?action=dapp&url=${dappUrl}`;
193
+ }
150
194
  }
151
195
  };
152
196
  };
@@ -182,6 +226,9 @@ var bitverseWallet = () => ({
182
226
  android: "https://play.google.com/store/apps/details?id=com.bitverse.app&pli=1",
183
227
  ios: "https://apps.apple.com/us/app/bitverse-discover-web3-wealth/id1645515614",
184
228
  qrCode: "https://www.bitverse.zone/download"
229
+ },
230
+ mobile: {
231
+ getUri: (uri) => `bitverseapp://open/wallet/wc?uri=${encodeURIComponent(uri)}`
185
232
  }
186
233
  });
187
234
 
@@ -239,6 +286,11 @@ var bybitWallet = () => {
239
286
  ios: "https://apps.apple.com/us/app/bybit-buy-trade-crypto/id1488296980",
240
287
  mobile: "https://www.bybit.com/en/web3",
241
288
  qrCode: "https://www.bybit.com/en/web3"
289
+ },
290
+ mobile: {
291
+ getUri: (uri) => {
292
+ return `bybitapp://open/route?targetUrl=by://web3/walletconnect/wc?uri=${encodeURIComponent(uri)}`;
293
+ }
242
294
  }
243
295
  };
244
296
  };
@@ -310,6 +362,13 @@ var coinbaseWallet = () => {
310
362
  qrCode: "https://coinbase-wallet.onelink.me/q5Sx/fdb9b250",
311
363
  chrome: "https://chrome.google.com/webstore/detail/coinbase-wallet-extension/hnfanknocfeofbddgcijnmhnfnkdnaad",
312
364
  browserExtension: "https://coinbase.com/wallet"
365
+ },
366
+ mobile: {
367
+ getDeeplink: (dappUrl) => {
368
+ if (!dappUrl) return "";
369
+ const encodedDappUrl = encodeURIComponent(dappUrl);
370
+ return `https://go.cb-w.com/dapp?cb_url=${encodedDappUrl}`;
371
+ }
313
372
  }
314
373
  };
315
374
  };
@@ -452,6 +511,11 @@ var foxWallet = () => {
452
511
  android: "https://play.google.com/store/apps/details?id=com.foxwallet.play",
453
512
  ios: "https://apps.apple.com/app/foxwallet-crypto-web3/id1590983231",
454
513
  qrCode: "https://foxwallet.com/download"
514
+ },
515
+ mobile: {
516
+ getUri: (uri) => {
517
+ return `foxwallet://wc?uri=${encodeURIComponent(uri)}`;
518
+ }
455
519
  }
456
520
  };
457
521
  };
@@ -493,6 +557,11 @@ var gateWallet = () => {
493
557
  qrCode: "https://www.gate.io/web3",
494
558
  chrome: "https://chromewebstore.google.com/detail/gate-wallet/cpmkedoipcpimgecpmgpldfpohjplkpp",
495
559
  browserExtension: "https://www.gate.io/web3"
560
+ },
561
+ mobile: {
562
+ getUri: (uri) => {
563
+ return isAndroid() ? uri : `gtweb3wallet://wc?uri=${encodeURIComponent(uri)}`;
564
+ }
496
565
  }
497
566
  };
498
567
  };
@@ -512,6 +581,15 @@ var imTokenWallet = () => ({
512
581
  ios: "https://itunes.apple.com/us/app/imtoken2/id1384798940",
513
582
  mobile: "https://token.im/download",
514
583
  qrCode: "https://token.im/download"
584
+ },
585
+ mobile: {
586
+ getUri: (uri) => {
587
+ return `imtokenv2://wc?uri=${encodeURIComponent(uri)}`;
588
+ },
589
+ getDeeplink: (dappUrl) => {
590
+ if (!dappUrl) return "";
591
+ return `imtokenv2://navigate?screen=DappView&url=${dappUrl}`;
592
+ }
515
593
  }
516
594
  });
517
595
 
@@ -542,6 +620,11 @@ var iopayWallet = () => ({
542
620
  ios: "https://apps.apple.com/us/app/iopay-multichain-crypto-wallet/id1478086371",
543
621
  qrCode: "https://iopay.me/",
544
622
  browserExtension: "https://iopay.me/"
623
+ },
624
+ mobile: {
625
+ getUri: (uri) => {
626
+ return isAndroid() ? uri : `iopay://wc?uri=${encodeURIComponent(uri)}`;
627
+ }
545
628
  }
546
629
  });
547
630
 
@@ -563,6 +646,11 @@ var kaiaWallet = () => {
563
646
  ios: "https://apps.apple.com/us/app/kaia-wallet/id6502896387",
564
647
  android: "https://play.google.com/store/apps/details?id=io.klutch.wallet",
565
648
  mobile: "https://app.kaiawallet.io"
649
+ },
650
+ mobile: {
651
+ getUri: (uri) => {
652
+ return `kaikas://walletconnect?uri=${encodeURIComponent(uri)}`;
653
+ }
566
654
  }
567
655
  };
568
656
  };
@@ -585,6 +673,11 @@ var kaikasWallet = () => {
585
673
  ios: "https://apps.apple.com/us/app/kaikas-mobile-crypto-wallet/id1626107061",
586
674
  android: "https://play.google.com/store/apps/details?id=io.klutch.wallet",
587
675
  mobile: "https://app.kaikas.io"
676
+ },
677
+ mobile: {
678
+ getUri: (uri) => {
679
+ return `kaikas://walletconnect?uri=${encodeURIComponent(uri)}`;
680
+ }
588
681
  }
589
682
  };
590
683
  };
@@ -603,6 +696,11 @@ var krakenWallet = () => ({
603
696
  ios: "https://apps.apple.com/us/app/kraken-wallet/id1626327149",
604
697
  mobile: "https://kraken.com/wallet",
605
698
  qrCode: "https://kraken.com/wallet"
699
+ },
700
+ mobile: {
701
+ getUri: (uri) => {
702
+ return `krakenwallet://wc?uri=${encodeURIComponent(uri)}`;
703
+ }
606
704
  }
607
705
  });
608
706
 
@@ -620,6 +718,9 @@ var kresusWallet = () => ({
620
718
  android: "https://play.google.com/store/apps/details?id=com.kresus.superapp",
621
719
  ios: "https://apps.apple.com/us/app/kresus-crypto-nft-superapp/id6444355152",
622
720
  qrCode: "https://kresusconnect.kresus.com/download"
721
+ },
722
+ mobile: {
723
+ getUri: (uri) => `com.kresus.superapp://wc?uri=${encodeURIComponent(uri)}`
623
724
  }
624
725
  });
625
726
 
@@ -643,6 +744,11 @@ var ledgerWallet = () => ({
643
744
  macos: "https://www.ledger.com/ledger-live/download",
644
745
  linux: "https://www.ledger.com/ledger-live/download",
645
746
  desktop: "https://www.ledger.com/ledger-live"
747
+ },
748
+ mobile: {
749
+ getUri: (uri) => {
750
+ return isAndroid() ? uri : `ledgerlive://wc?uri=${encodeURIComponent(uri)}`;
751
+ }
646
752
  }
647
753
  });
648
754
 
@@ -768,6 +874,19 @@ var metaMaskWallet = () => {
768
874
  firefox: "https://addons.mozilla.org/firefox/addon/ether-metamask",
769
875
  opera: "https://addons.opera.com/extensions/details/metamask-10",
770
876
  browserExtension: "https://metamask.io/download"
877
+ },
878
+ mobile: {
879
+ getUri: (uri) => {
880
+ return isAndroid() ? uri : isIOS() ? (
881
+ // currently broken in MetaMask v6.5.0 https://github.com/MetaMask/metamask-mobile/issues/6457
882
+ `metamask://wc?uri=${encodeURIComponent(uri)}`
883
+ ) : `https://metamask.app.link/wc?uri=${encodeURIComponent(uri)}`;
884
+ },
885
+ getDeeplink: (dappUrl) => {
886
+ if (!dappUrl) return "";
887
+ const urlWithoutProtocol = dappUrl.split("://")[1] || dappUrl;
888
+ return `https://metamask.app.link/dapp/${urlWithoutProtocol}`;
889
+ }
771
890
  }
772
891
  };
773
892
  };
@@ -853,6 +972,11 @@ var oktoWallet = () => ({
853
972
  ios: "https://apps.apple.com/in/app/okto-wallet/id6450688229",
854
973
  mobile: "https://okto.tech/",
855
974
  qrCode: "https://okto.tech/"
975
+ },
976
+ mobile: {
977
+ getUri: (uri) => {
978
+ return isAndroid() ? uri : `okto://wc?uri=${encodeURIComponent(uri)}`;
979
+ }
856
980
  }
857
981
  });
858
982
 
@@ -884,6 +1008,16 @@ var okxWallet = () => {
884
1008
  edge: "https://microsoftedge.microsoft.com/addons/detail/okx-wallet/pbpjkcldjiffchgbbndmhojiacbgflha",
885
1009
  firefox: "https://addons.mozilla.org/firefox/addon/okexwallet/",
886
1010
  browserExtension: "https://okx.com/download"
1011
+ },
1012
+ mobile: {
1013
+ getUri: (uri) => {
1014
+ return isAndroid() ? uri : `okex://main/wc?uri=${encodeURIComponent(uri)}`;
1015
+ },
1016
+ getDeeplink: (uri) => {
1017
+ const encodedDappUrl = encodeURIComponent(uri || "");
1018
+ const deepLink = `okx://wallet/dapp/url?dappUrl=${encodedDappUrl}`;
1019
+ return "https://www.okx.com/download?deeplink=" + encodeURIComponent(deepLink);
1020
+ }
887
1021
  }
888
1022
  };
889
1023
  };
@@ -903,6 +1037,11 @@ var omniWallet = () => ({
903
1037
  ios: "https://itunes.apple.com/us/app/id1569375204",
904
1038
  mobile: "https://omniwallet.app.link",
905
1039
  qrCode: "https://omniwallet.app.link"
1040
+ },
1041
+ mobile: {
1042
+ getUri: (uri) => {
1043
+ return isAndroid() ? uri : `omni://wc?uri=${encodeURIComponent(uri)}`;
1044
+ }
906
1045
  }
907
1046
  });
908
1047
 
@@ -921,6 +1060,9 @@ var oneInchWallet = () => ({
921
1060
  ios: "https://apps.apple.com/us/app/1inch-crypto-defi-wallet/id1546049391",
922
1061
  mobile: "https://1inch.io/wallet",
923
1062
  qrCode: "https://1inch.io/wallet"
1063
+ },
1064
+ mobile: {
1065
+ getUri: (uri) => `oneinch://wc?uri=${encodeURIComponent(uri)}`
924
1066
  }
925
1067
  });
926
1068
 
@@ -963,6 +1105,11 @@ var paraSwapWallet = () => ({
963
1105
  ios: "https://apps.apple.com/us/app/paraswap-multichain-wallet/id1584610690",
964
1106
  mobile: "https://paraswap.io",
965
1107
  qrCode: "https://paraswap.io"
1108
+ },
1109
+ mobile: {
1110
+ getUri: (uri) => {
1111
+ return `paraswap://wc?uri=${encodeURIComponent(uri)}`;
1112
+ }
966
1113
  }
967
1114
  });
968
1115
 
@@ -1017,6 +1164,13 @@ var phantomWallet = () => {
1017
1164
  chrome: "https://chrome.google.com/webstore/detail/phantom/bfnaelmomeimhlpmgjnjophhpkkoljpa",
1018
1165
  firefox: "https://addons.mozilla.org/firefox/addon/phantom-app/",
1019
1166
  browserExtension: "https://phantom.app/download"
1167
+ },
1168
+ mobile: {
1169
+ getDeeplink: (dappUrl, _chainId) => {
1170
+ if (!dappUrl) return "";
1171
+ const encodedDappUrl = encodeURIComponent(dappUrl);
1172
+ return `https://phantom.app/ul/v1/connect?app_url=${encodedDappUrl}`;
1173
+ }
1020
1174
  }
1021
1175
  };
1022
1176
  };
@@ -1058,6 +1212,11 @@ var rainbowWallet = () => {
1058
1212
  mobile: "https://rainbow.download?utm_source=rainbowkit",
1059
1213
  qrCode: "https://rainbow.download?utm_source=rainbowkit&utm_medium=qrcode",
1060
1214
  browserExtension: "https://rainbow.me/extension?utm_source=rainbowkit"
1215
+ },
1216
+ mobile: {
1217
+ getUri: (uri) => {
1218
+ return isAndroid() ? uri : isIOS() ? `rainbow://wc?uri=${encodeURIComponent(uri)}&connector=rainbowkit` : `https://rnbwapp.com/wc?uri=${encodeURIComponent(uri)}&connector=rainbowkit`;
1219
+ }
1061
1220
  }
1062
1221
  };
1063
1222
  };
@@ -1222,6 +1381,13 @@ var solflareWallet = () => {
1222
1381
  ios: "https://apps.apple.com/app/id1667469122",
1223
1382
  mobile: "https://solflare.com/",
1224
1383
  qrCode: "https://solflare.com/"
1384
+ },
1385
+ mobile: {
1386
+ getDeeplink: (dappUrl) => {
1387
+ if (!dappUrl) return "";
1388
+ const encodedDappUrl = encodeURIComponent(dappUrl);
1389
+ return `https://solflare.com/ul/v1/browse/${encodedDappUrl}?ref=${encodedDappUrl}`;
1390
+ }
1225
1391
  }
1226
1392
  };
1227
1393
  };
@@ -1311,6 +1477,12 @@ var tokenPocketWallet = () => {
1311
1477
  ios: "https://apps.apple.com/us/app/tp-global-wallet/id6444625622",
1312
1478
  qrCode: "https://tokenpocket.pro/en/download/app",
1313
1479
  mobile: "https://tokenpocket.pro/en/download/app"
1480
+ },
1481
+ mobile: {
1482
+ getDeeplink: (dappUrl) => {
1483
+ if (!dappUrl) return "";
1484
+ return `tpdapp://open?params={"url":"${dappUrl}"}`;
1485
+ }
1314
1486
  }
1315
1487
  };
1316
1488
  };
@@ -1376,6 +1548,12 @@ var trustWallet = () => {
1376
1548
  qrCode: "https://trustwallet.com/download",
1377
1549
  chrome: "https://chrome.google.com/webstore/detail/trust-wallet/egjidjbpglichdcondbcbdnbeeppgdph",
1378
1550
  browserExtension: "https://trustwallet.com/browser-extension"
1551
+ },
1552
+ mobile: {
1553
+ getDeeplink: (dappUrl) => {
1554
+ if (!dappUrl) return "";
1555
+ return `https://link.trustwallet.com/open_url?coin_id=60&url=${dappUrl}`;
1556
+ }
1379
1557
  }
1380
1558
  };
1381
1559
  };
@@ -1394,6 +1572,11 @@ var uniswapWallet = () => ({
1394
1572
  ios: "https://apps.apple.com/app/apple-store/id6443944476",
1395
1573
  mobile: "https://wallet.uniswap.org/",
1396
1574
  qrCode: "https://wallet.uniswap.org/"
1575
+ },
1576
+ mobile: {
1577
+ getUri: (uri) => {
1578
+ return `uniswap://wc?uri=${encodeURIComponent(uri)}`;
1579
+ }
1397
1580
  }
1398
1581
  });
1399
1582
 
@@ -1436,6 +1619,9 @@ var valoraWallet = () => ({
1436
1619
  android: "https://play.google.com/store/apps/details?id=co.clabs.valora",
1437
1620
  mobile: "https://valora.xyz",
1438
1621
  qrCode: "https://valora.xyz"
1622
+ },
1623
+ mobile: {
1624
+ getUri: (uri) => isAndroid() ? uri : `celo://wallet/wc?uri=${encodeURIComponent(uri)}`
1439
1625
  }
1440
1626
  });
1441
1627
 
@@ -1520,6 +1706,11 @@ var zealWallet = () => {
1520
1706
  ios: "https://testflight.apple.com/join/MP72Ytw8",
1521
1707
  mobile: "https://zeal.app",
1522
1708
  qrCode: "https://zeal.app"
1709
+ },
1710
+ mobile: {
1711
+ getUri: (uri) => {
1712
+ return `zeal://wc?uri=${encodeURIComponent(uri)}`;
1713
+ }
1523
1714
  }
1524
1715
  };
1525
1716
  };
@@ -1544,6 +1735,11 @@ var zerionWallet = () => {
1544
1735
  qrCode: "https://link.zerion.io/pt3gdRP0njb",
1545
1736
  chrome: "https://chrome.google.com/webstore/detail/klghhnkeealcohjjanjjdaeeggmfmlpl",
1546
1737
  browserExtension: "https://zerion.io/extension"
1738
+ },
1739
+ mobile: {
1740
+ getUri: (uri) => {
1741
+ return isIOS() ? `zerion://wc?uri=${encodeURIComponent(uri)}` : uri;
1742
+ }
1547
1743
  }
1548
1744
  };
1549
1745
  };
@@ -1657,22 +1853,31 @@ function connectorDector(wallet) {
1657
1853
  const isAptosExists = hasInjectedProvider(aptosNS);
1658
1854
  const isInstalled = isEvmExists || isSolanaExists || isAptosExists;
1659
1855
  const providers = {};
1660
- if (isEvmExists) {
1661
- providers.evm = {
1856
+ if (evmNS.namespace || evmNS.flag) {
1857
+ providers.evm = isEvmExists ? {
1662
1858
  provider: getInjectedProvider(evmNS),
1663
1859
  protocol: "eip6963" /* EIP6963 */
1860
+ } : {
1861
+ provider: void 0,
1862
+ protocol: void 0
1664
1863
  };
1665
1864
  }
1666
- if (isSolanaExists) {
1667
- providers.solana = {
1865
+ if (solanaNS.namespace) {
1866
+ providers.solana = isSolanaExists ? {
1668
1867
  provider: getInjectedProvider(solanaNS),
1669
1868
  protocol: "inject" /* INJECT */
1869
+ } : {
1870
+ provider: void 0,
1871
+ protocol: void 0
1670
1872
  };
1671
1873
  }
1672
- if (isAptosExists) {
1673
- providers.aptos = {
1874
+ if (aptosNS.namespace) {
1875
+ providers.aptos = isAptosExists ? {
1674
1876
  provider: getInjectedProvider(aptosNS),
1675
1877
  protocol: "inject" /* INJECT */
1878
+ } : {
1879
+ provider: void 0,
1880
+ protocol: void 0
1676
1881
  };
1677
1882
  }
1678
1883
  return {
@@ -1683,6 +1888,7 @@ function connectorDector(wallet) {
1683
1888
  iconBackground: wallet == null ? void 0 : wallet.iconBackground,
1684
1889
  rdns: wallet == null ? void 0 : wallet.rdns,
1685
1890
  deeplink: wallet == null ? void 0 : wallet.deeplink,
1891
+ mobile: wallet == null ? void 0 : wallet.mobile,
1686
1892
  links: {
1687
1893
  homepage: ((_c = wallet == null ? void 0 : wallet.downloadUrls) == null ? void 0 : _c.qrCode) || "",
1688
1894
  ios_install: ((_d = wallet == null ? void 0 : wallet.downloadUrls) == null ? void 0 : _d.ios) || "",
@@ -1993,7 +2199,7 @@ var WalletConnectProvider = class {
1993
2199
  if (sessions.length > 0) {
1994
2200
  this.session = sessions[0];
1995
2201
  this.updateAccountsFromSession();
1996
- this.emit("connect", { chainId: this.chainId });
2202
+ this.emit("connect", { chainId: this.chainId, accounts: this.accounts });
1997
2203
  }
1998
2204
  });
1999
2205
  this.client.on("session_delete", () => {
@@ -2067,6 +2273,7 @@ var WalletConnectProvider = class {
2067
2273
  return new Promise((resolve, reject) => {
2068
2274
  const timeout2 = setTimeout(() => {
2069
2275
  reject(new Error("Connection timeout"));
2276
+ this.emit("error", new Error("Connection timeout"));
2070
2277
  }, 3e5);
2071
2278
  const checkConnection = () => {
2072
2279
  const sessions = this.client.getActiveSessions();
@@ -2075,7 +2282,7 @@ var WalletConnectProvider = class {
2075
2282
  clearTimeout(timeout2);
2076
2283
  this.session = newSessions[0];
2077
2284
  this.updateAccountsFromSession();
2078
- this.emit("connect", { chainId: this.chainId });
2285
+ this.emit("connect", { chainId: this.chainId, accounts: this.accounts });
2079
2286
  resolve(true);
2080
2287
  } else {
2081
2288
  setTimeout(checkConnection, 500);
@@ -2320,40 +2527,31 @@ function createWalletConnectEVMProvider() {
2320
2527
  };
2321
2528
  }
2322
2529
 
2323
- // src/utils/isMobile.ts
2324
- function isAndroid() {
2325
- return typeof navigator !== "undefined" && /android/i.test(navigator.userAgent);
2326
- }
2327
- function isSmallIOS() {
2328
- return typeof navigator !== "undefined" && /iPhone|iPod/.test(navigator.userAgent);
2329
- }
2330
- function isLargeIOS() {
2331
- return typeof navigator !== "undefined" && (/iPad/.test(navigator.userAgent) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1);
2332
- }
2333
- function isIOS() {
2334
- return isSmallIOS() || isLargeIOS();
2335
- }
2336
- function isMobile() {
2337
- return isAndroid() || isIOS() || isLargeIOS();
2530
+ // src/utils/browsers.ts
2531
+ function openUri(uri) {
2532
+ if (uri.startsWith("http")) {
2533
+ const link = document.createElement("a");
2534
+ link.href = uri;
2535
+ link.target = "_blank";
2536
+ link.rel = "noreferrer noopener";
2537
+ link.click();
2538
+ } else {
2539
+ window.location.href = uri;
2540
+ }
2338
2541
  }
2339
2542
 
2340
2543
  // src/wallet-api/connect.ts
2341
2544
  var connect = async (connectParams, walletOptions) => {
2342
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
2343
- if (isMobile()) {
2344
- const deeplink = ((_a = walletOptions == null ? void 0 : walletOptions.walletInfo) == null ? void 0 : _a.deeplink) || "";
2345
- if (!deeplink) {
2346
- throw new Error("Deeplink not supported");
2347
- }
2348
- const dappLink = (connectParams == null ? void 0 : connectParams.dappLink) || "";
2349
- if (!dappLink) {
2350
- throw new Error("Dapp link is required");
2351
- }
2352
- const { hostname, pathname } = new URL(dappLink);
2353
- const link = `${deeplink}${hostname}${pathname}`;
2354
- window.location.href = link;
2545
+ var _a, _b, _c, _d, _e, _f, _g, _h;
2546
+ const { provider, chainType, walletInfo } = walletOptions;
2547
+ if (isMobile() && (walletInfo == null ? void 0 : walletInfo.uuid) !== "walletConnect" && !provider) {
2548
+ const res = await connectMobile({
2549
+ connectParams,
2550
+ walletOptions
2551
+ });
2552
+ const { address: address2, chainId: chainId2, network: network2, provider: mobileProvider } = res || {};
2553
+ return { address: address2, chainId: chainId2, network: network2, provider: mobileProvider };
2355
2554
  }
2356
- const { provider, chainType } = walletOptions;
2357
2555
  if (!provider) {
2358
2556
  throw new Error("Provider is required");
2359
2557
  }
@@ -2372,17 +2570,17 @@ var connect = async (connectParams, walletOptions) => {
2372
2570
  let res = null;
2373
2571
  if (provider == null ? void 0 : provider.connect) {
2374
2572
  res = await provider.connect();
2375
- address = ((_b = res == null ? void 0 : res.publicKey) == null ? void 0 : _b.toString()) || "";
2573
+ address = ((_a = res == null ? void 0 : res.publicKey) == null ? void 0 : _a.toString()) || "";
2376
2574
  }
2377
2575
  if (provider == null ? void 0 : provider.request) {
2378
2576
  res = await provider.request({
2379
2577
  method: "connect"
2380
2578
  });
2381
- address = ((_c = res == null ? void 0 : res.publicKey) == null ? void 0 : _c.toString()) || "";
2579
+ address = ((_b = res == null ? void 0 : res.publicKey) == null ? void 0 : _b.toString()) || "";
2382
2580
  }
2383
2581
  if (provider == null ? void 0 : provider["standard:connect"]) {
2384
- res = await ((_d = provider["standard:connect"]) == null ? void 0 : _d.connect());
2385
- address = ((_f = (_e = res == null ? void 0 : res.accounts) == null ? void 0 : _e[0]) == null ? void 0 : _f.address) || "";
2582
+ res = await ((_c = provider["standard:connect"]) == null ? void 0 : _c.connect());
2583
+ address = ((_e = (_d = res == null ? void 0 : res.accounts) == null ? void 0 : _d[0]) == null ? void 0 : _e.address) || "";
2386
2584
  }
2387
2585
  network = "mainnet-beta";
2388
2586
  }
@@ -2392,14 +2590,14 @@ var connect = async (connectParams, walletOptions) => {
2392
2590
  } else if (provider == null ? void 0 : provider.request) {
2393
2591
  await provider.request({ method: "connect" });
2394
2592
  } else if (provider == null ? void 0 : provider["aptos:connect"]) {
2395
- await ((_g = provider["aptos:connect"]) == null ? void 0 : _g.connect());
2593
+ await ((_f = provider["aptos:connect"]) == null ? void 0 : _f.connect());
2396
2594
  }
2397
2595
  if (provider == null ? void 0 : provider.account) {
2398
2596
  const account = await (provider == null ? void 0 : provider.account());
2399
2597
  address = (account == null ? void 0 : account.address) || "";
2400
2598
  } else if (provider == null ? void 0 : provider["aptos:account"]) {
2401
- const account = await ((_h = provider == null ? void 0 : provider["aptos:account"]) == null ? void 0 : _h.account());
2402
- const addressData = (_i = account == null ? void 0 : account.address) == null ? void 0 : _i.data;
2599
+ const account = await ((_g = provider == null ? void 0 : provider["aptos:account"]) == null ? void 0 : _g.account());
2600
+ const addressData = (_h = account == null ? void 0 : account.address) == null ? void 0 : _h.data;
2403
2601
  const hexString = addressData ? Array.from(addressData).map((b) => b.toString(16).padStart(2, "0")).join("") : null;
2404
2602
  address = `0x${hexString}`;
2405
2603
  }
@@ -2442,22 +2640,88 @@ var disconnect = async (walletOptions) => {
2442
2640
  }
2443
2641
  return false;
2444
2642
  };
2643
+ var connectMobile = async ({
2644
+ connectParams,
2645
+ walletOptions
2646
+ }) => {
2647
+ var _a, _b, _c;
2648
+ const { useWalletConnect, dappLink } = connectParams;
2649
+ const { mobile, links } = walletOptions.walletInfo;
2650
+ const connectWithWalletConnect = () => {
2651
+ return new Promise((resolve, reject) => {
2652
+ const { mobile: mobile2, uuid } = walletOptions.walletInfo || {};
2653
+ (async () => {
2654
+ var _a2;
2655
+ try {
2656
+ const wcInstance = createWalletConnectEVMProvider();
2657
+ const mobileProvider = await wcInstance.getProvider();
2658
+ const wcUri = wcInstance.connectUri;
2659
+ const mobileUri = await ((_a2 = mobile2 == null ? void 0 : mobile2.getUri) == null ? void 0 : _a2.call(mobile2, wcUri));
2660
+ if (!mobileUri) {
2661
+ resolve({ address: "", chainId: "" });
2662
+ return;
2663
+ }
2664
+ if (uuid !== "walletConnect") openUri(mobileUri);
2665
+ const res = await wcInstance.connect().catch((error) => {
2666
+ reject(error);
2667
+ });
2668
+ const address = (res == null ? void 0 : res[0]) || "";
2669
+ const chainId = await mobileProvider.request({ method: "eth_chainId" });
2670
+ resolve({ address, chainId, provider: mobileProvider });
2671
+ } catch (error) {
2672
+ reject(error);
2673
+ }
2674
+ })();
2675
+ });
2676
+ };
2677
+ if (useWalletConnect) {
2678
+ return connectWithWalletConnect();
2679
+ } else if (mobile == null ? void 0 : mobile.getDeeplink) {
2680
+ const deeplink = await ((_a = mobile == null ? void 0 : mobile.getDeeplink) == null ? void 0 : _a.call(mobile, dappLink));
2681
+ if (deeplink) {
2682
+ openUri(deeplink);
2683
+ }
2684
+ } else if (mobile == null ? void 0 : mobile.getUri) {
2685
+ return connectWithWalletConnect();
2686
+ } else if (links.android_install || links.ios_install || links.homepage) {
2687
+ if (isAndroid()) {
2688
+ openUri(links.android_install || links.homepage || "");
2689
+ } else if (isIOS()) {
2690
+ openUri(links.ios_install || links.homepage || "");
2691
+ } else {
2692
+ openUri(links.homepage || "");
2693
+ }
2694
+ throw new Error(`${(_b = walletOptions.walletInfo) == null ? void 0 : _b.name} not supported`);
2695
+ } else {
2696
+ throw new Error(`${(_c = walletOptions.walletInfo) == null ? void 0 : _c.name} not supported`);
2697
+ }
2698
+ return new Promise(() => {
2699
+ });
2700
+ };
2445
2701
 
2446
2702
  // src/wallet-api/sign-message.ts
2447
2703
  var signMessage = async (data, walletOptions) => {
2448
2704
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
2449
- const { chainType, account, provider } = walletOptions;
2705
+ const { chainType, account, provider, walletInfo, isInstalled } = walletOptions;
2450
2706
  const { message, nonce } = data;
2707
+ const isMobileDevice = isMobile();
2708
+ const isWalletConnect = (walletInfo == null ? void 0 : walletInfo.uuid) === "walletConnect";
2451
2709
  if (!provider) {
2452
2710
  throw new Error("Provider is required");
2453
2711
  }
2454
2712
  const { address } = account;
2455
2713
  if (chainType === "evm") {
2456
2714
  try {
2457
- const signature = await provider.request({
2715
+ const signaturePromise = provider.request({
2458
2716
  method: "personal_sign",
2459
2717
  params: [message, address]
2460
2718
  });
2719
+ if (isMobileDevice && !isWalletConnect && !isInstalled) {
2720
+ handleOpenMobileWalletDelayed(walletOptions, 100).catch((error) => {
2721
+ console.error("Failed to schedule mobile wallet open:", error);
2722
+ });
2723
+ }
2724
+ const signature = await signaturePromise;
2461
2725
  console.log("signMessage res:", chainType, provider, message, signature);
2462
2726
  return signature;
2463
2727
  } catch (error) {
@@ -2546,6 +2810,18 @@ function getAPTOSSignatureFromResponse(res) {
2546
2810
  }
2547
2811
  return signature;
2548
2812
  }
2813
+ async function handleOpenMobileWalletDelayed(walletOptions, delay = 100) {
2814
+ var _a, _b;
2815
+ const { mobile } = walletOptions.walletInfo || {};
2816
+ const dappUrl = typeof window !== "undefined" ? window.location.href : "";
2817
+ const chainId = ((_a = walletOptions.account) == null ? void 0 : _a.chainId) ? parseInt(walletOptions.account.chainId, 16) : void 0;
2818
+ const deeplink = await ((_b = mobile == null ? void 0 : mobile.getDeeplink) == null ? void 0 : _b.call(mobile, dappUrl, chainId));
2819
+ if (!deeplink) return;
2820
+ const actualDelay = deeplink && !deeplink.startsWith("http") ? Math.max(delay, 300) : delay;
2821
+ setTimeout(() => {
2822
+ openUri(deeplink);
2823
+ }, actualDelay);
2824
+ }
2549
2825
 
2550
2826
  // src/wallet-api/sign-in.ts
2551
2827
  var signInWithWallet = async (signInData, walletOptions) => {
@@ -2681,8 +2957,13 @@ var addChain = async (chainInfo, walletOptions) => {
2681
2957
  throw new Error("Chain type is required");
2682
2958
  }
2683
2959
  if (chainType === "evm") {
2684
- if (!(chainInfo == null ? void 0 : chainInfo.chainId) || !(chainInfo == null ? void 0 : chainInfo.chainId.startsWith("0x"))) {
2685
- throw new Error("Chain ID must starting with 0x");
2960
+ if (!(chainInfo == null ? void 0 : chainInfo.chainId)) {
2961
+ throw new Error("Chain ID is required");
2962
+ }
2963
+ if (!(chainInfo == null ? void 0 : chainInfo.chainId.startsWith("0x"))) {
2964
+ const chainId = Number(chainInfo.chainId);
2965
+ const chainIdHex = toHex(chainId);
2966
+ chainInfo.chainId = chainIdHex;
2686
2967
  }
2687
2968
  try {
2688
2969
  await provider.request({
@@ -2810,4 +3091,4 @@ async function loadConnectors({
2810
3091
  };
2811
3092
  }
2812
3093
 
2813
- export { ProviderChainType, ProviderProtocol, SupportedChainTypes, TomoDefaultConnectors, addChain, backpackWallet, berasigWallet, binanceWallet, bitgetWallet, bitskiWallet, bitverseWallet, bloomWallet, braveWallet, bybitWallet, clvWallet, coin98Wallet, coinbaseWallet, compassWallet, connect, coreWallet, ctrlWallet, dawnWallet, desigWallet, disconnect, enkryptWallet, foxWallet, frameWallet, gateWallet, getBalance, imTokenWallet, injectedWallet, iopayWallet, kaiaWallet, kaikasWallet, krakenWallet, kresusWallet, ledgerWallet, loadConnectors, magicEdenWallet, mathWallet, metaMaskWallet, mydogeWallet, nestWallet, novaWallet, oktoWallet, okxWallet, omniWallet, oneInchWallet, oneKeyWallet, paraSwapWallet, petraWallet, phantomWallet, rabbyWallet, rainbowWallet, ramperWallet, readyWallet, roninWallet, safeWallet, safeheronWallet, safepalWallet, seifWallet, setWalletConnectConfig, signInWithWallet, signMessage, solflareWallet, subWallet, switchChain, tahoWallet, talismanWallet, tokenPocketWallet, tokenaryWallet, trezorWallet, trustWallet, uniswapWallet, universalProfilesWallet, valoraWallet, walletConnectWallet, wigwamWallet, xPortalWallet, zealWallet, zerionWallet, zilPayWallet };
3094
+ export { ProviderChainType, ProviderProtocol, SupportedChainTypes, TomoDefaultConnectors, addChain, backpackWallet, berasigWallet, binanceWallet, bitgetWallet, bitskiWallet, bitverseWallet, bloomWallet, braveWallet, bybitWallet, clvWallet, coin98Wallet, coinbaseWallet, compassWallet, connect, connectMobile, coreWallet, ctrlWallet, dawnWallet, desigWallet, disconnect, enkryptWallet, foxWallet, frameWallet, gateWallet, getBalance, imTokenWallet, injectedWallet, iopayWallet, isMobile, kaiaWallet, kaikasWallet, krakenWallet, kresusWallet, ledgerWallet, loadConnectors, magicEdenWallet, mathWallet, metaMaskWallet, mydogeWallet, nestWallet, novaWallet, oktoWallet, okxWallet, omniWallet, oneInchWallet, oneKeyWallet, paraSwapWallet, petraWallet, phantomWallet, rabbyWallet, rainbowWallet, ramperWallet, readyWallet, roninWallet, safeWallet, safeheronWallet, safepalWallet, seifWallet, setWalletConnectConfig, signInWithWallet, signMessage, solflareWallet, subWallet, switchChain, tahoWallet, talismanWallet, tokenPocketWallet, tokenaryWallet, trezorWallet, trustWallet, uniswapWallet, universalProfilesWallet, valoraWallet, walletConnectWallet, wigwamWallet, xPortalWallet, zealWallet, zerionWallet, zilPayWallet };