@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.cjs CHANGED
@@ -38,6 +38,23 @@ var __objRest = (source, exclude) => {
38
38
  return target;
39
39
  };
40
40
 
41
+ // src/utils/isMobile.ts
42
+ function isAndroid() {
43
+ return typeof navigator !== "undefined" && /android/i.test(navigator.userAgent);
44
+ }
45
+ function isSmallIOS() {
46
+ return typeof navigator !== "undefined" && /iPhone|iPod/.test(navigator.userAgent);
47
+ }
48
+ function isLargeIOS() {
49
+ return typeof navigator !== "undefined" && (/iPad/.test(navigator.userAgent) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1);
50
+ }
51
+ function isIOS() {
52
+ return isSmallIOS() || isLargeIOS();
53
+ }
54
+ function isMobile() {
55
+ return isAndroid() || isIOS() || isLargeIOS();
56
+ }
57
+
41
58
  // src/utils/utils.ts
42
59
  function uniqueConnectors(allConnectors) {
43
60
  const connectors = [];
@@ -119,6 +136,24 @@ var binanceWallet = () => {
119
136
  mobile: "https://www.binance.com/en/download",
120
137
  qrCode: "https://www.binance.com/en/web3wallet",
121
138
  chrome: "https://chromewebstore.google.com/detail/cadiboklkpojfamcoggejbbdjcoiljjk"
139
+ },
140
+ mobile: {
141
+ getUri: (uri) => {
142
+ return isAndroid() ? uri : `bnc://app.binance.com/cedefi/wc?uri=${encodeURIComponent(uri)}`;
143
+ },
144
+ getDeeplink: async (dappUrl, chainId) => {
145
+ if (!dappUrl) return "";
146
+ try {
147
+ const binanceUtils = await import('@binance/w3w-utils').catch(() => null);
148
+ if (binanceUtils && "getDeepLink" in binanceUtils) {
149
+ const getDeepLink = binanceUtils.getDeepLink;
150
+ const result = getDeepLink(dappUrl, chainId);
151
+ return (result == null ? void 0 : result.http) || "";
152
+ }
153
+ } catch (e) {
154
+ }
155
+ return `bnc://app.binance.com/cedefi/dapp?url=${encodeURIComponent(dappUrl)}`;
156
+ }
122
157
  }
123
158
  };
124
159
  };
@@ -149,6 +184,15 @@ var bitgetWallet = () => {
149
184
  qrCode: "https://web3.bitget.com/en/wallet-download",
150
185
  chrome: "https://chrome.google.com/webstore/detail/bitkeep-crypto-nft-wallet/jiidiaalihmmhddjgbnbgdfflelocpak",
151
186
  browserExtension: "https://web3.bitget.com/en/wallet-download"
187
+ },
188
+ mobile: {
189
+ getUri: (uri) => {
190
+ return isAndroid() ? uri : `bitkeep://wc?uri=${encodeURIComponent(uri)}`;
191
+ },
192
+ getDeeplink: (dappUrl) => {
193
+ if (!dappUrl) return "";
194
+ return `https://bkcode.vip?action=dapp&url=${dappUrl}`;
195
+ }
152
196
  }
153
197
  };
154
198
  };
@@ -184,6 +228,9 @@ var bitverseWallet = () => ({
184
228
  android: "https://play.google.com/store/apps/details?id=com.bitverse.app&pli=1",
185
229
  ios: "https://apps.apple.com/us/app/bitverse-discover-web3-wealth/id1645515614",
186
230
  qrCode: "https://www.bitverse.zone/download"
231
+ },
232
+ mobile: {
233
+ getUri: (uri) => `bitverseapp://open/wallet/wc?uri=${encodeURIComponent(uri)}`
187
234
  }
188
235
  });
189
236
 
@@ -241,6 +288,11 @@ var bybitWallet = () => {
241
288
  ios: "https://apps.apple.com/us/app/bybit-buy-trade-crypto/id1488296980",
242
289
  mobile: "https://www.bybit.com/en/web3",
243
290
  qrCode: "https://www.bybit.com/en/web3"
291
+ },
292
+ mobile: {
293
+ getUri: (uri) => {
294
+ return `bybitapp://open/route?targetUrl=by://web3/walletconnect/wc?uri=${encodeURIComponent(uri)}`;
295
+ }
244
296
  }
245
297
  };
246
298
  };
@@ -312,6 +364,13 @@ var coinbaseWallet = () => {
312
364
  qrCode: "https://coinbase-wallet.onelink.me/q5Sx/fdb9b250",
313
365
  chrome: "https://chrome.google.com/webstore/detail/coinbase-wallet-extension/hnfanknocfeofbddgcijnmhnfnkdnaad",
314
366
  browserExtension: "https://coinbase.com/wallet"
367
+ },
368
+ mobile: {
369
+ getDeeplink: (dappUrl) => {
370
+ if (!dappUrl) return "";
371
+ const encodedDappUrl = encodeURIComponent(dappUrl);
372
+ return `https://go.cb-w.com/dapp?cb_url=${encodedDappUrl}`;
373
+ }
315
374
  }
316
375
  };
317
376
  };
@@ -454,6 +513,11 @@ var foxWallet = () => {
454
513
  android: "https://play.google.com/store/apps/details?id=com.foxwallet.play",
455
514
  ios: "https://apps.apple.com/app/foxwallet-crypto-web3/id1590983231",
456
515
  qrCode: "https://foxwallet.com/download"
516
+ },
517
+ mobile: {
518
+ getUri: (uri) => {
519
+ return `foxwallet://wc?uri=${encodeURIComponent(uri)}`;
520
+ }
457
521
  }
458
522
  };
459
523
  };
@@ -495,6 +559,11 @@ var gateWallet = () => {
495
559
  qrCode: "https://www.gate.io/web3",
496
560
  chrome: "https://chromewebstore.google.com/detail/gate-wallet/cpmkedoipcpimgecpmgpldfpohjplkpp",
497
561
  browserExtension: "https://www.gate.io/web3"
562
+ },
563
+ mobile: {
564
+ getUri: (uri) => {
565
+ return isAndroid() ? uri : `gtweb3wallet://wc?uri=${encodeURIComponent(uri)}`;
566
+ }
498
567
  }
499
568
  };
500
569
  };
@@ -514,6 +583,15 @@ var imTokenWallet = () => ({
514
583
  ios: "https://itunes.apple.com/us/app/imtoken2/id1384798940",
515
584
  mobile: "https://token.im/download",
516
585
  qrCode: "https://token.im/download"
586
+ },
587
+ mobile: {
588
+ getUri: (uri) => {
589
+ return `imtokenv2://wc?uri=${encodeURIComponent(uri)}`;
590
+ },
591
+ getDeeplink: (dappUrl) => {
592
+ if (!dappUrl) return "";
593
+ return `imtokenv2://navigate?screen=DappView&url=${dappUrl}`;
594
+ }
517
595
  }
518
596
  });
519
597
 
@@ -544,6 +622,11 @@ var iopayWallet = () => ({
544
622
  ios: "https://apps.apple.com/us/app/iopay-multichain-crypto-wallet/id1478086371",
545
623
  qrCode: "https://iopay.me/",
546
624
  browserExtension: "https://iopay.me/"
625
+ },
626
+ mobile: {
627
+ getUri: (uri) => {
628
+ return isAndroid() ? uri : `iopay://wc?uri=${encodeURIComponent(uri)}`;
629
+ }
547
630
  }
548
631
  });
549
632
 
@@ -565,6 +648,11 @@ var kaiaWallet = () => {
565
648
  ios: "https://apps.apple.com/us/app/kaia-wallet/id6502896387",
566
649
  android: "https://play.google.com/store/apps/details?id=io.klutch.wallet",
567
650
  mobile: "https://app.kaiawallet.io"
651
+ },
652
+ mobile: {
653
+ getUri: (uri) => {
654
+ return `kaikas://walletconnect?uri=${encodeURIComponent(uri)}`;
655
+ }
568
656
  }
569
657
  };
570
658
  };
@@ -587,6 +675,11 @@ var kaikasWallet = () => {
587
675
  ios: "https://apps.apple.com/us/app/kaikas-mobile-crypto-wallet/id1626107061",
588
676
  android: "https://play.google.com/store/apps/details?id=io.klutch.wallet",
589
677
  mobile: "https://app.kaikas.io"
678
+ },
679
+ mobile: {
680
+ getUri: (uri) => {
681
+ return `kaikas://walletconnect?uri=${encodeURIComponent(uri)}`;
682
+ }
590
683
  }
591
684
  };
592
685
  };
@@ -605,6 +698,11 @@ var krakenWallet = () => ({
605
698
  ios: "https://apps.apple.com/us/app/kraken-wallet/id1626327149",
606
699
  mobile: "https://kraken.com/wallet",
607
700
  qrCode: "https://kraken.com/wallet"
701
+ },
702
+ mobile: {
703
+ getUri: (uri) => {
704
+ return `krakenwallet://wc?uri=${encodeURIComponent(uri)}`;
705
+ }
608
706
  }
609
707
  });
610
708
 
@@ -622,6 +720,9 @@ var kresusWallet = () => ({
622
720
  android: "https://play.google.com/store/apps/details?id=com.kresus.superapp",
623
721
  ios: "https://apps.apple.com/us/app/kresus-crypto-nft-superapp/id6444355152",
624
722
  qrCode: "https://kresusconnect.kresus.com/download"
723
+ },
724
+ mobile: {
725
+ getUri: (uri) => `com.kresus.superapp://wc?uri=${encodeURIComponent(uri)}`
625
726
  }
626
727
  });
627
728
 
@@ -645,6 +746,11 @@ var ledgerWallet = () => ({
645
746
  macos: "https://www.ledger.com/ledger-live/download",
646
747
  linux: "https://www.ledger.com/ledger-live/download",
647
748
  desktop: "https://www.ledger.com/ledger-live"
749
+ },
750
+ mobile: {
751
+ getUri: (uri) => {
752
+ return isAndroid() ? uri : `ledgerlive://wc?uri=${encodeURIComponent(uri)}`;
753
+ }
648
754
  }
649
755
  });
650
756
 
@@ -770,6 +876,19 @@ var metaMaskWallet = () => {
770
876
  firefox: "https://addons.mozilla.org/firefox/addon/ether-metamask",
771
877
  opera: "https://addons.opera.com/extensions/details/metamask-10",
772
878
  browserExtension: "https://metamask.io/download"
879
+ },
880
+ mobile: {
881
+ getUri: (uri) => {
882
+ return isAndroid() ? uri : isIOS() ? (
883
+ // currently broken in MetaMask v6.5.0 https://github.com/MetaMask/metamask-mobile/issues/6457
884
+ `metamask://wc?uri=${encodeURIComponent(uri)}`
885
+ ) : `https://metamask.app.link/wc?uri=${encodeURIComponent(uri)}`;
886
+ },
887
+ getDeeplink: (dappUrl) => {
888
+ if (!dappUrl) return "";
889
+ const urlWithoutProtocol = dappUrl.split("://")[1] || dappUrl;
890
+ return `https://metamask.app.link/dapp/${urlWithoutProtocol}`;
891
+ }
773
892
  }
774
893
  };
775
894
  };
@@ -855,6 +974,11 @@ var oktoWallet = () => ({
855
974
  ios: "https://apps.apple.com/in/app/okto-wallet/id6450688229",
856
975
  mobile: "https://okto.tech/",
857
976
  qrCode: "https://okto.tech/"
977
+ },
978
+ mobile: {
979
+ getUri: (uri) => {
980
+ return isAndroid() ? uri : `okto://wc?uri=${encodeURIComponent(uri)}`;
981
+ }
858
982
  }
859
983
  });
860
984
 
@@ -886,6 +1010,16 @@ var okxWallet = () => {
886
1010
  edge: "https://microsoftedge.microsoft.com/addons/detail/okx-wallet/pbpjkcldjiffchgbbndmhojiacbgflha",
887
1011
  firefox: "https://addons.mozilla.org/firefox/addon/okexwallet/",
888
1012
  browserExtension: "https://okx.com/download"
1013
+ },
1014
+ mobile: {
1015
+ getUri: (uri) => {
1016
+ return isAndroid() ? uri : `okex://main/wc?uri=${encodeURIComponent(uri)}`;
1017
+ },
1018
+ getDeeplink: (uri) => {
1019
+ const encodedDappUrl = encodeURIComponent(uri || "");
1020
+ const deepLink = `okx://wallet/dapp/url?dappUrl=${encodedDappUrl}`;
1021
+ return "https://www.okx.com/download?deeplink=" + encodeURIComponent(deepLink);
1022
+ }
889
1023
  }
890
1024
  };
891
1025
  };
@@ -905,6 +1039,11 @@ var omniWallet = () => ({
905
1039
  ios: "https://itunes.apple.com/us/app/id1569375204",
906
1040
  mobile: "https://omniwallet.app.link",
907
1041
  qrCode: "https://omniwallet.app.link"
1042
+ },
1043
+ mobile: {
1044
+ getUri: (uri) => {
1045
+ return isAndroid() ? uri : `omni://wc?uri=${encodeURIComponent(uri)}`;
1046
+ }
908
1047
  }
909
1048
  });
910
1049
 
@@ -923,6 +1062,9 @@ var oneInchWallet = () => ({
923
1062
  ios: "https://apps.apple.com/us/app/1inch-crypto-defi-wallet/id1546049391",
924
1063
  mobile: "https://1inch.io/wallet",
925
1064
  qrCode: "https://1inch.io/wallet"
1065
+ },
1066
+ mobile: {
1067
+ getUri: (uri) => `oneinch://wc?uri=${encodeURIComponent(uri)}`
926
1068
  }
927
1069
  });
928
1070
 
@@ -965,6 +1107,11 @@ var paraSwapWallet = () => ({
965
1107
  ios: "https://apps.apple.com/us/app/paraswap-multichain-wallet/id1584610690",
966
1108
  mobile: "https://paraswap.io",
967
1109
  qrCode: "https://paraswap.io"
1110
+ },
1111
+ mobile: {
1112
+ getUri: (uri) => {
1113
+ return `paraswap://wc?uri=${encodeURIComponent(uri)}`;
1114
+ }
968
1115
  }
969
1116
  });
970
1117
 
@@ -1019,6 +1166,13 @@ var phantomWallet = () => {
1019
1166
  chrome: "https://chrome.google.com/webstore/detail/phantom/bfnaelmomeimhlpmgjnjophhpkkoljpa",
1020
1167
  firefox: "https://addons.mozilla.org/firefox/addon/phantom-app/",
1021
1168
  browserExtension: "https://phantom.app/download"
1169
+ },
1170
+ mobile: {
1171
+ getDeeplink: (dappUrl, _chainId) => {
1172
+ if (!dappUrl) return "";
1173
+ const encodedDappUrl = encodeURIComponent(dappUrl);
1174
+ return `https://phantom.app/ul/v1/connect?app_url=${encodedDappUrl}`;
1175
+ }
1022
1176
  }
1023
1177
  };
1024
1178
  };
@@ -1060,6 +1214,11 @@ var rainbowWallet = () => {
1060
1214
  mobile: "https://rainbow.download?utm_source=rainbowkit",
1061
1215
  qrCode: "https://rainbow.download?utm_source=rainbowkit&utm_medium=qrcode",
1062
1216
  browserExtension: "https://rainbow.me/extension?utm_source=rainbowkit"
1217
+ },
1218
+ mobile: {
1219
+ getUri: (uri) => {
1220
+ return isAndroid() ? uri : isIOS() ? `rainbow://wc?uri=${encodeURIComponent(uri)}&connector=rainbowkit` : `https://rnbwapp.com/wc?uri=${encodeURIComponent(uri)}&connector=rainbowkit`;
1221
+ }
1063
1222
  }
1064
1223
  };
1065
1224
  };
@@ -1224,6 +1383,13 @@ var solflareWallet = () => {
1224
1383
  ios: "https://apps.apple.com/app/id1667469122",
1225
1384
  mobile: "https://solflare.com/",
1226
1385
  qrCode: "https://solflare.com/"
1386
+ },
1387
+ mobile: {
1388
+ getDeeplink: (dappUrl) => {
1389
+ if (!dappUrl) return "";
1390
+ const encodedDappUrl = encodeURIComponent(dappUrl);
1391
+ return `https://solflare.com/ul/v1/browse/${encodedDappUrl}?ref=${encodedDappUrl}`;
1392
+ }
1227
1393
  }
1228
1394
  };
1229
1395
  };
@@ -1313,6 +1479,12 @@ var tokenPocketWallet = () => {
1313
1479
  ios: "https://apps.apple.com/us/app/tp-global-wallet/id6444625622",
1314
1480
  qrCode: "https://tokenpocket.pro/en/download/app",
1315
1481
  mobile: "https://tokenpocket.pro/en/download/app"
1482
+ },
1483
+ mobile: {
1484
+ getDeeplink: (dappUrl) => {
1485
+ if (!dappUrl) return "";
1486
+ return `tpdapp://open?params={"url":"${dappUrl}"}`;
1487
+ }
1316
1488
  }
1317
1489
  };
1318
1490
  };
@@ -1378,6 +1550,12 @@ var trustWallet = () => {
1378
1550
  qrCode: "https://trustwallet.com/download",
1379
1551
  chrome: "https://chrome.google.com/webstore/detail/trust-wallet/egjidjbpglichdcondbcbdnbeeppgdph",
1380
1552
  browserExtension: "https://trustwallet.com/browser-extension"
1553
+ },
1554
+ mobile: {
1555
+ getDeeplink: (dappUrl) => {
1556
+ if (!dappUrl) return "";
1557
+ return `https://link.trustwallet.com/open_url?coin_id=60&url=${dappUrl}`;
1558
+ }
1381
1559
  }
1382
1560
  };
1383
1561
  };
@@ -1396,6 +1574,11 @@ var uniswapWallet = () => ({
1396
1574
  ios: "https://apps.apple.com/app/apple-store/id6443944476",
1397
1575
  mobile: "https://wallet.uniswap.org/",
1398
1576
  qrCode: "https://wallet.uniswap.org/"
1577
+ },
1578
+ mobile: {
1579
+ getUri: (uri) => {
1580
+ return `uniswap://wc?uri=${encodeURIComponent(uri)}`;
1581
+ }
1399
1582
  }
1400
1583
  });
1401
1584
 
@@ -1438,6 +1621,9 @@ var valoraWallet = () => ({
1438
1621
  android: "https://play.google.com/store/apps/details?id=co.clabs.valora",
1439
1622
  mobile: "https://valora.xyz",
1440
1623
  qrCode: "https://valora.xyz"
1624
+ },
1625
+ mobile: {
1626
+ getUri: (uri) => isAndroid() ? uri : `celo://wallet/wc?uri=${encodeURIComponent(uri)}`
1441
1627
  }
1442
1628
  });
1443
1629
 
@@ -1522,6 +1708,11 @@ var zealWallet = () => {
1522
1708
  ios: "https://testflight.apple.com/join/MP72Ytw8",
1523
1709
  mobile: "https://zeal.app",
1524
1710
  qrCode: "https://zeal.app"
1711
+ },
1712
+ mobile: {
1713
+ getUri: (uri) => {
1714
+ return `zeal://wc?uri=${encodeURIComponent(uri)}`;
1715
+ }
1525
1716
  }
1526
1717
  };
1527
1718
  };
@@ -1546,6 +1737,11 @@ var zerionWallet = () => {
1546
1737
  qrCode: "https://link.zerion.io/pt3gdRP0njb",
1547
1738
  chrome: "https://chrome.google.com/webstore/detail/klghhnkeealcohjjanjjdaeeggmfmlpl",
1548
1739
  browserExtension: "https://zerion.io/extension"
1740
+ },
1741
+ mobile: {
1742
+ getUri: (uri) => {
1743
+ return isIOS() ? `zerion://wc?uri=${encodeURIComponent(uri)}` : uri;
1744
+ }
1549
1745
  }
1550
1746
  };
1551
1747
  };
@@ -1659,22 +1855,31 @@ function connectorDector(wallet) {
1659
1855
  const isAptosExists = hasInjectedProvider(aptosNS);
1660
1856
  const isInstalled = isEvmExists || isSolanaExists || isAptosExists;
1661
1857
  const providers = {};
1662
- if (isEvmExists) {
1663
- providers.evm = {
1858
+ if (evmNS.namespace || evmNS.flag) {
1859
+ providers.evm = isEvmExists ? {
1664
1860
  provider: getInjectedProvider(evmNS),
1665
1861
  protocol: "eip6963" /* EIP6963 */
1862
+ } : {
1863
+ provider: void 0,
1864
+ protocol: void 0
1666
1865
  };
1667
1866
  }
1668
- if (isSolanaExists) {
1669
- providers.solana = {
1867
+ if (solanaNS.namespace) {
1868
+ providers.solana = isSolanaExists ? {
1670
1869
  provider: getInjectedProvider(solanaNS),
1671
1870
  protocol: "inject" /* INJECT */
1871
+ } : {
1872
+ provider: void 0,
1873
+ protocol: void 0
1672
1874
  };
1673
1875
  }
1674
- if (isAptosExists) {
1675
- providers.aptos = {
1876
+ if (aptosNS.namespace) {
1877
+ providers.aptos = isAptosExists ? {
1676
1878
  provider: getInjectedProvider(aptosNS),
1677
1879
  protocol: "inject" /* INJECT */
1880
+ } : {
1881
+ provider: void 0,
1882
+ protocol: void 0
1678
1883
  };
1679
1884
  }
1680
1885
  return {
@@ -1685,6 +1890,7 @@ function connectorDector(wallet) {
1685
1890
  iconBackground: wallet == null ? void 0 : wallet.iconBackground,
1686
1891
  rdns: wallet == null ? void 0 : wallet.rdns,
1687
1892
  deeplink: wallet == null ? void 0 : wallet.deeplink,
1893
+ mobile: wallet == null ? void 0 : wallet.mobile,
1688
1894
  links: {
1689
1895
  homepage: ((_c = wallet == null ? void 0 : wallet.downloadUrls) == null ? void 0 : _c.qrCode) || "",
1690
1896
  ios_install: ((_d = wallet == null ? void 0 : wallet.downloadUrls) == null ? void 0 : _d.ios) || "",
@@ -1995,7 +2201,7 @@ var WalletConnectProvider = class {
1995
2201
  if (sessions.length > 0) {
1996
2202
  this.session = sessions[0];
1997
2203
  this.updateAccountsFromSession();
1998
- this.emit("connect", { chainId: this.chainId });
2204
+ this.emit("connect", { chainId: this.chainId, accounts: this.accounts });
1999
2205
  }
2000
2206
  });
2001
2207
  this.client.on("session_delete", () => {
@@ -2069,6 +2275,7 @@ var WalletConnectProvider = class {
2069
2275
  return new Promise((resolve, reject) => {
2070
2276
  const timeout2 = setTimeout(() => {
2071
2277
  reject(new Error("Connection timeout"));
2278
+ this.emit("error", new Error("Connection timeout"));
2072
2279
  }, 3e5);
2073
2280
  const checkConnection = () => {
2074
2281
  const sessions = this.client.getActiveSessions();
@@ -2077,7 +2284,7 @@ var WalletConnectProvider = class {
2077
2284
  clearTimeout(timeout2);
2078
2285
  this.session = newSessions[0];
2079
2286
  this.updateAccountsFromSession();
2080
- this.emit("connect", { chainId: this.chainId });
2287
+ this.emit("connect", { chainId: this.chainId, accounts: this.accounts });
2081
2288
  resolve(true);
2082
2289
  } else {
2083
2290
  setTimeout(checkConnection, 500);
@@ -2322,40 +2529,31 @@ function createWalletConnectEVMProvider() {
2322
2529
  };
2323
2530
  }
2324
2531
 
2325
- // src/utils/isMobile.ts
2326
- function isAndroid() {
2327
- return typeof navigator !== "undefined" && /android/i.test(navigator.userAgent);
2328
- }
2329
- function isSmallIOS() {
2330
- return typeof navigator !== "undefined" && /iPhone|iPod/.test(navigator.userAgent);
2331
- }
2332
- function isLargeIOS() {
2333
- return typeof navigator !== "undefined" && (/iPad/.test(navigator.userAgent) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1);
2334
- }
2335
- function isIOS() {
2336
- return isSmallIOS() || isLargeIOS();
2337
- }
2338
- function isMobile() {
2339
- return isAndroid() || isIOS() || isLargeIOS();
2532
+ // src/utils/browsers.ts
2533
+ function openUri(uri) {
2534
+ if (uri.startsWith("http")) {
2535
+ const link = document.createElement("a");
2536
+ link.href = uri;
2537
+ link.target = "_blank";
2538
+ link.rel = "noreferrer noopener";
2539
+ link.click();
2540
+ } else {
2541
+ window.location.href = uri;
2542
+ }
2340
2543
  }
2341
2544
 
2342
2545
  // src/wallet-api/connect.ts
2343
2546
  var connect = async (connectParams, walletOptions) => {
2344
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
2345
- if (isMobile()) {
2346
- const deeplink = ((_a = walletOptions == null ? void 0 : walletOptions.walletInfo) == null ? void 0 : _a.deeplink) || "";
2347
- if (!deeplink) {
2348
- throw new Error("Deeplink not supported");
2349
- }
2350
- const dappLink = (connectParams == null ? void 0 : connectParams.dappLink) || "";
2351
- if (!dappLink) {
2352
- throw new Error("Dapp link is required");
2353
- }
2354
- const { hostname, pathname } = new URL(dappLink);
2355
- const link = `${deeplink}${hostname}${pathname}`;
2356
- window.location.href = link;
2547
+ var _a, _b, _c, _d, _e, _f, _g, _h;
2548
+ const { provider, chainType, walletInfo } = walletOptions;
2549
+ if (isMobile() && (walletInfo == null ? void 0 : walletInfo.uuid) !== "walletConnect" && !provider) {
2550
+ const res = await connectMobile({
2551
+ connectParams,
2552
+ walletOptions
2553
+ });
2554
+ const { address: address2, chainId: chainId2, network: network2, provider: mobileProvider } = res || {};
2555
+ return { address: address2, chainId: chainId2, network: network2, provider: mobileProvider };
2357
2556
  }
2358
- const { provider, chainType } = walletOptions;
2359
2557
  if (!provider) {
2360
2558
  throw new Error("Provider is required");
2361
2559
  }
@@ -2374,17 +2572,17 @@ var connect = async (connectParams, walletOptions) => {
2374
2572
  let res = null;
2375
2573
  if (provider == null ? void 0 : provider.connect) {
2376
2574
  res = await provider.connect();
2377
- address = ((_b = res == null ? void 0 : res.publicKey) == null ? void 0 : _b.toString()) || "";
2575
+ address = ((_a = res == null ? void 0 : res.publicKey) == null ? void 0 : _a.toString()) || "";
2378
2576
  }
2379
2577
  if (provider == null ? void 0 : provider.request) {
2380
2578
  res = await provider.request({
2381
2579
  method: "connect"
2382
2580
  });
2383
- address = ((_c = res == null ? void 0 : res.publicKey) == null ? void 0 : _c.toString()) || "";
2581
+ address = ((_b = res == null ? void 0 : res.publicKey) == null ? void 0 : _b.toString()) || "";
2384
2582
  }
2385
2583
  if (provider == null ? void 0 : provider["standard:connect"]) {
2386
- res = await ((_d = provider["standard:connect"]) == null ? void 0 : _d.connect());
2387
- address = ((_f = (_e = res == null ? void 0 : res.accounts) == null ? void 0 : _e[0]) == null ? void 0 : _f.address) || "";
2584
+ res = await ((_c = provider["standard:connect"]) == null ? void 0 : _c.connect());
2585
+ address = ((_e = (_d = res == null ? void 0 : res.accounts) == null ? void 0 : _d[0]) == null ? void 0 : _e.address) || "";
2388
2586
  }
2389
2587
  network = "mainnet-beta";
2390
2588
  }
@@ -2394,14 +2592,14 @@ var connect = async (connectParams, walletOptions) => {
2394
2592
  } else if (provider == null ? void 0 : provider.request) {
2395
2593
  await provider.request({ method: "connect" });
2396
2594
  } else if (provider == null ? void 0 : provider["aptos:connect"]) {
2397
- await ((_g = provider["aptos:connect"]) == null ? void 0 : _g.connect());
2595
+ await ((_f = provider["aptos:connect"]) == null ? void 0 : _f.connect());
2398
2596
  }
2399
2597
  if (provider == null ? void 0 : provider.account) {
2400
2598
  const account = await (provider == null ? void 0 : provider.account());
2401
2599
  address = (account == null ? void 0 : account.address) || "";
2402
2600
  } else if (provider == null ? void 0 : provider["aptos:account"]) {
2403
- const account = await ((_h = provider == null ? void 0 : provider["aptos:account"]) == null ? void 0 : _h.account());
2404
- const addressData = (_i = account == null ? void 0 : account.address) == null ? void 0 : _i.data;
2601
+ const account = await ((_g = provider == null ? void 0 : provider["aptos:account"]) == null ? void 0 : _g.account());
2602
+ const addressData = (_h = account == null ? void 0 : account.address) == null ? void 0 : _h.data;
2405
2603
  const hexString = addressData ? Array.from(addressData).map((b) => b.toString(16).padStart(2, "0")).join("") : null;
2406
2604
  address = `0x${hexString}`;
2407
2605
  }
@@ -2444,22 +2642,88 @@ var disconnect = async (walletOptions) => {
2444
2642
  }
2445
2643
  return false;
2446
2644
  };
2645
+ var connectMobile = async ({
2646
+ connectParams,
2647
+ walletOptions
2648
+ }) => {
2649
+ var _a, _b, _c;
2650
+ const { useWalletConnect, dappLink } = connectParams;
2651
+ const { mobile, links } = walletOptions.walletInfo;
2652
+ const connectWithWalletConnect = () => {
2653
+ return new Promise((resolve, reject) => {
2654
+ const { mobile: mobile2, uuid } = walletOptions.walletInfo || {};
2655
+ (async () => {
2656
+ var _a2;
2657
+ try {
2658
+ const wcInstance = createWalletConnectEVMProvider();
2659
+ const mobileProvider = await wcInstance.getProvider();
2660
+ const wcUri = wcInstance.connectUri;
2661
+ const mobileUri = await ((_a2 = mobile2 == null ? void 0 : mobile2.getUri) == null ? void 0 : _a2.call(mobile2, wcUri));
2662
+ if (!mobileUri) {
2663
+ resolve({ address: "", chainId: "" });
2664
+ return;
2665
+ }
2666
+ if (uuid !== "walletConnect") openUri(mobileUri);
2667
+ const res = await wcInstance.connect().catch((error) => {
2668
+ reject(error);
2669
+ });
2670
+ const address = (res == null ? void 0 : res[0]) || "";
2671
+ const chainId = await mobileProvider.request({ method: "eth_chainId" });
2672
+ resolve({ address, chainId, provider: mobileProvider });
2673
+ } catch (error) {
2674
+ reject(error);
2675
+ }
2676
+ })();
2677
+ });
2678
+ };
2679
+ if (useWalletConnect) {
2680
+ return connectWithWalletConnect();
2681
+ } else if (mobile == null ? void 0 : mobile.getDeeplink) {
2682
+ const deeplink = await ((_a = mobile == null ? void 0 : mobile.getDeeplink) == null ? void 0 : _a.call(mobile, dappLink));
2683
+ if (deeplink) {
2684
+ openUri(deeplink);
2685
+ }
2686
+ } else if (mobile == null ? void 0 : mobile.getUri) {
2687
+ return connectWithWalletConnect();
2688
+ } else if (links.android_install || links.ios_install || links.homepage) {
2689
+ if (isAndroid()) {
2690
+ openUri(links.android_install || links.homepage || "");
2691
+ } else if (isIOS()) {
2692
+ openUri(links.ios_install || links.homepage || "");
2693
+ } else {
2694
+ openUri(links.homepage || "");
2695
+ }
2696
+ throw new Error(`${(_b = walletOptions.walletInfo) == null ? void 0 : _b.name} not supported`);
2697
+ } else {
2698
+ throw new Error(`${(_c = walletOptions.walletInfo) == null ? void 0 : _c.name} not supported`);
2699
+ }
2700
+ return new Promise(() => {
2701
+ });
2702
+ };
2447
2703
 
2448
2704
  // src/wallet-api/sign-message.ts
2449
2705
  var signMessage = async (data, walletOptions) => {
2450
2706
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
2451
- const { chainType, account, provider } = walletOptions;
2707
+ const { chainType, account, provider, walletInfo, isInstalled } = walletOptions;
2452
2708
  const { message, nonce } = data;
2709
+ const isMobileDevice = isMobile();
2710
+ const isWalletConnect = (walletInfo == null ? void 0 : walletInfo.uuid) === "walletConnect";
2453
2711
  if (!provider) {
2454
2712
  throw new Error("Provider is required");
2455
2713
  }
2456
2714
  const { address } = account;
2457
2715
  if (chainType === "evm") {
2458
2716
  try {
2459
- const signature = await provider.request({
2717
+ const signaturePromise = provider.request({
2460
2718
  method: "personal_sign",
2461
2719
  params: [message, address]
2462
2720
  });
2721
+ if (isMobileDevice && !isWalletConnect && !isInstalled) {
2722
+ handleOpenMobileWalletDelayed(walletOptions, 100).catch((error) => {
2723
+ console.error("Failed to schedule mobile wallet open:", error);
2724
+ });
2725
+ }
2726
+ const signature = await signaturePromise;
2463
2727
  console.log("signMessage res:", chainType, provider, message, signature);
2464
2728
  return signature;
2465
2729
  } catch (error) {
@@ -2548,6 +2812,18 @@ function getAPTOSSignatureFromResponse(res) {
2548
2812
  }
2549
2813
  return signature;
2550
2814
  }
2815
+ async function handleOpenMobileWalletDelayed(walletOptions, delay = 100) {
2816
+ var _a, _b;
2817
+ const { mobile } = walletOptions.walletInfo || {};
2818
+ const dappUrl = typeof window !== "undefined" ? window.location.href : "";
2819
+ const chainId = ((_a = walletOptions.account) == null ? void 0 : _a.chainId) ? parseInt(walletOptions.account.chainId, 16) : void 0;
2820
+ const deeplink = await ((_b = mobile == null ? void 0 : mobile.getDeeplink) == null ? void 0 : _b.call(mobile, dappUrl, chainId));
2821
+ if (!deeplink) return;
2822
+ const actualDelay = deeplink && !deeplink.startsWith("http") ? Math.max(delay, 300) : delay;
2823
+ setTimeout(() => {
2824
+ openUri(deeplink);
2825
+ }, actualDelay);
2826
+ }
2551
2827
 
2552
2828
  // src/wallet-api/sign-in.ts
2553
2829
  var signInWithWallet = async (signInData, walletOptions) => {
@@ -2683,8 +2959,13 @@ var addChain = async (chainInfo, walletOptions) => {
2683
2959
  throw new Error("Chain type is required");
2684
2960
  }
2685
2961
  if (chainType === "evm") {
2686
- if (!(chainInfo == null ? void 0 : chainInfo.chainId) || !(chainInfo == null ? void 0 : chainInfo.chainId.startsWith("0x"))) {
2687
- throw new Error("Chain ID must starting with 0x");
2962
+ if (!(chainInfo == null ? void 0 : chainInfo.chainId)) {
2963
+ throw new Error("Chain ID is required");
2964
+ }
2965
+ if (!(chainInfo == null ? void 0 : chainInfo.chainId.startsWith("0x"))) {
2966
+ const chainId = Number(chainInfo.chainId);
2967
+ const chainIdHex = viem.toHex(chainId);
2968
+ chainInfo.chainId = chainIdHex;
2688
2969
  }
2689
2970
  try {
2690
2971
  await provider.request({
@@ -2831,6 +3112,7 @@ exports.coin98Wallet = coin98Wallet;
2831
3112
  exports.coinbaseWallet = coinbaseWallet;
2832
3113
  exports.compassWallet = compassWallet;
2833
3114
  exports.connect = connect;
3115
+ exports.connectMobile = connectMobile;
2834
3116
  exports.coreWallet = coreWallet;
2835
3117
  exports.ctrlWallet = ctrlWallet;
2836
3118
  exports.dawnWallet = dawnWallet;
@@ -2844,6 +3126,7 @@ exports.getBalance = getBalance;
2844
3126
  exports.imTokenWallet = imTokenWallet;
2845
3127
  exports.injectedWallet = injectedWallet;
2846
3128
  exports.iopayWallet = iopayWallet;
3129
+ exports.isMobile = isMobile;
2847
3130
  exports.kaiaWallet = kaiaWallet;
2848
3131
  exports.kaikasWallet = kaikasWallet;
2849
3132
  exports.krakenWallet = krakenWallet;