@talken/talkenkit 2.4.29 → 2.5.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.
Files changed (562) hide show
  1. package/LICENSE +9 -0
  2. package/README.md +28 -8
  3. package/dist/{abcWallet-GFKDYN2Z.js → abcWallet-5GTT47V6.js} +1 -1
  4. package/dist/{chunk-MI7TNBED.js → chunk-REVMSQIO.js} +287 -71
  5. package/dist/index.css +13 -13
  6. package/dist/index.js +6 -6
  7. package/dist/wallets/walletConnectors/abcWallet/abcAccessKeyProvider.d.ts +43 -0
  8. package/dist/wallets/walletConnectors/abcWallet/abcAccessKeyProvider.js +11 -0
  9. package/dist/wallets/walletConnectors/abcWallet/abcConnector.js +5 -3
  10. package/dist/wallets/walletConnectors/abcWallet/abcProvider.js +2 -1
  11. package/dist/wallets/walletConnectors/abcWallet/abcSolanaProvider.js +1 -1
  12. package/dist/wallets/walletConnectors/abcWallet/abcWallet.d.ts +7 -0
  13. package/dist/wallets/walletConnectors/abcWallet/abcWallet.js +6 -4
  14. package/dist/wallets/walletConnectors/abcWallet/api/index.js +3 -3
  15. package/dist/wallets/walletConnectors/abcWallet/index.js +9 -7
  16. package/dist/wallets/walletConnectors/abcWallet/types.d.ts +2 -0
  17. package/dist/wallets/walletConnectors/{chunk-FBJ5H6PM.js → chunk-HWXOTEC3.js} +15 -5
  18. package/dist/wallets/walletConnectors/{chunk-7QHCSJDN.js → chunk-K66HU6GX.js} +8 -2
  19. package/dist/wallets/walletConnectors/{chunk-VMCIDCO5.js → chunk-QSP2A4LA.js} +5 -2
  20. package/dist/wallets/walletConnectors/chunk-S2SQYPGR.js +220 -0
  21. package/dist/wallets/walletConnectors/{chunk-4FKUVQCM.js → chunk-TQHS6APN.js} +174 -68
  22. package/dist/wallets/walletConnectors/index.js +40 -38
  23. package/dist/wallets/walletConnectors/klipWallet/klipWallet.d.ts +3 -0
  24. package/dist/wallets/walletConnectors/klipWallet/klipWallet.js +68 -0
  25. package/dist/wallets/walletConnectors/klipWallet-PPTYYB5G.js +7 -0
  26. package/package.json +11 -12
  27. package/dist/AbcCredentialManager-E723A55X.js +0 -7
  28. package/dist/AbcCredentialManager-GUV5JQ2V.js +0 -7
  29. package/dist/AbcCredentialManager-Z7GDJHYR.js +0 -7
  30. package/dist/Arc-ILTINY4C.js +0 -8
  31. package/dist/Brave-4L5B7JJR.js +0 -8
  32. package/dist/Browser-XMB4J5WD.js +0 -8
  33. package/dist/Chrome-6ZDQIHC5.js +0 -8
  34. package/dist/Edge-OAWCEU7H.js +0 -8
  35. package/dist/Firefox-O66FZK3V.js +0 -8
  36. package/dist/Linux-NUJF4EPC.js +0 -8
  37. package/dist/Macos-46EJ2NPK.js +0 -8
  38. package/dist/Opera-KTUB3UWN.js +0 -8
  39. package/dist/Safari-A3Q6PIT2.js +0 -8
  40. package/dist/Windows-NL32NG52.js +0 -8
  41. package/dist/abcWallet-3PWHJXWR.js +0 -181
  42. package/dist/abcWallet-3XPV7ATY.js +0 -185
  43. package/dist/abcWallet-3XSSUDLJ.js +0 -155
  44. package/dist/abcWallet-4RS3B4ZG.js +0 -188
  45. package/dist/abcWallet-53HAU4MH.js +0 -155
  46. package/dist/abcWallet-5B2YHZGY.js +0 -155
  47. package/dist/abcWallet-664AHBNM.js +0 -183
  48. package/dist/abcWallet-7XAGJUQT.js +0 -188
  49. package/dist/abcWallet-BV7HK3OX.js +0 -181
  50. package/dist/abcWallet-CRKQ3O6J.js +0 -155
  51. package/dist/abcWallet-EBOW2RJB.js +0 -188
  52. package/dist/abcWallet-ES4OPRSK.js +0 -8
  53. package/dist/abcWallet-FSUKHVIW.js +0 -188
  54. package/dist/abcWallet-GYSVK4YG.js +0 -188
  55. package/dist/abcWallet-H4JOSC4N.js +0 -155
  56. package/dist/abcWallet-HM7KZIMP.js +0 -155
  57. package/dist/abcWallet-I5DVALAS.js +0 -155
  58. package/dist/abcWallet-IF3EOKHC.js +0 -183
  59. package/dist/abcWallet-IUG22ZE3.js +0 -155
  60. package/dist/abcWallet-IYC3CKEO.js +0 -155
  61. package/dist/abcWallet-JE6UR4QF.js +0 -181
  62. package/dist/abcWallet-JWLGBJVW.js +0 -188
  63. package/dist/abcWallet-KPKVEGNP.js +0 -185
  64. package/dist/abcWallet-MWUFO3JQ.js +0 -161
  65. package/dist/abcWallet-MZAL5NXP.js +0 -181
  66. package/dist/abcWallet-N2UADRNR.js +0 -155
  67. package/dist/abcWallet-NRFXVTKK.js +0 -188
  68. package/dist/abcWallet-O4GH6RHS.js +0 -181
  69. package/dist/abcWallet-OGHORNUW.js +0 -181
  70. package/dist/abcWallet-OL47MLVO.js +0 -161
  71. package/dist/abcWallet-QSK6VJFU.js +0 -181
  72. package/dist/abcWallet-RKT3W3FX.js +0 -155
  73. package/dist/abcWallet-RS4EOJ4I.js +0 -188
  74. package/dist/abcWallet-SNEZVK7V.js +0 -188
  75. package/dist/abcWallet-TC7M2JYX.js +0 -188
  76. package/dist/abcWallet-TLGPQAMU.js +0 -161
  77. package/dist/abcWallet-VHXTAARP.js +0 -155
  78. package/dist/abcWallet-VPEWH5VC.js +0 -188
  79. package/dist/abcWallet-VYU3TEGJ.js +0 -161
  80. package/dist/abcWallet-VZMW2DR3.js +0 -188
  81. package/dist/abcWallet-WZGXGXUA.js +0 -161
  82. package/dist/abcWallet-XJ3WSUVI.js +0 -188
  83. package/dist/abcWallet-XNCBZAIQ.js +0 -188
  84. package/dist/abcWallet-YFYTW2JH.js +0 -155
  85. package/dist/abcWallet-ZC4B5742.js +0 -188
  86. package/dist/abcWallet-ZPVQY4XE.js +0 -155
  87. package/dist/ar_AR-YBBYUEGS.js +0 -8
  88. package/dist/arbitrum-D2TUFPZI.js +0 -8
  89. package/dist/argentWallet-A5HM5FRP.js +0 -8
  90. package/dist/assets-4NDWRKXE.js +0 -8
  91. package/dist/avalanche-BOOSH35S.js +0 -8
  92. package/dist/base-3JMRS35B.js +0 -8
  93. package/dist/berasigWallet-6IOU73YL.js +0 -8
  94. package/dist/bestWallet-6LJUU6OL.js +0 -8
  95. package/dist/bifrostWallet-SLPPXZ2K.js +0 -8
  96. package/dist/binanceWallet-Z67J7362.js +0 -8
  97. package/dist/bitgetWallet-DLLOWMCI.js +0 -8
  98. package/dist/bitskiWallet-CPOXGABT.js +0 -8
  99. package/dist/bitverseWallet-SAK4MIS6.js +0 -8
  100. package/dist/blast-4GF24NR7.js +0 -8
  101. package/dist/bloomWallet-YIRCNQZJ.js +0 -8
  102. package/dist/braveWallet-PNBKQKJC.js +0 -8
  103. package/dist/bsc-KU6MBOYR.js +0 -8
  104. package/dist/bybitWallet-GCDBAJKO.js +0 -8
  105. package/dist/celo-5A5VXMPX.js +0 -8
  106. package/dist/chunk-2OHX4KTB.js +0 -5382
  107. package/dist/chunk-3VPMUBCL.js +0 -5196
  108. package/dist/chunk-5IC2HV5I.js +0 -7110
  109. package/dist/chunk-5SDWPKKX.js +0 -5322
  110. package/dist/chunk-6FLQAAC4.js +0 -7213
  111. package/dist/chunk-6G2FPET7.js +0 -7123
  112. package/dist/chunk-6RBGFYAF.js +0 -5076
  113. package/dist/chunk-7GIIMIPN.js +0 -7213
  114. package/dist/chunk-7L2ANWBB.js +0 -5139
  115. package/dist/chunk-7VIEAJAM.js +0 -5172
  116. package/dist/chunk-BOURCK5E.js +0 -7121
  117. package/dist/chunk-BY6GTSWI.js +0 -5059
  118. package/dist/chunk-DWE3CZEL.js +0 -5171
  119. package/dist/chunk-GTFQJSXY.js +0 -7139
  120. package/dist/chunk-IBFA37SC.js +0 -7228
  121. package/dist/chunk-J6P2IT7Z.js +0 -5465
  122. package/dist/chunk-JIRBQUIB.js +0 -5348
  123. package/dist/chunk-K6CLOFGV.js +0 -5129
  124. package/dist/chunk-KYTIQ23P.js +0 -5390
  125. package/dist/chunk-MARFD3QV.js +0 -5164
  126. package/dist/chunk-MRRWKS2W.js +0 -348
  127. package/dist/chunk-N7AWNQBH.js +0 -5319
  128. package/dist/chunk-NQCUKFAV.js +0 -5381
  129. package/dist/chunk-O5ZOC4NJ.js +0 -7215
  130. package/dist/chunk-OPOAKGEX.js +0 -7216
  131. package/dist/chunk-OTIHVCVR.js +0 -7213
  132. package/dist/chunk-P77BVZZF.js +0 -7369
  133. package/dist/chunk-PILL2YTG.js +0 -5075
  134. package/dist/chunk-QW7D53VM.js +0 -5129
  135. package/dist/chunk-R4FDCYJX.js +0 -7110
  136. package/dist/chunk-RAWLCGOW.js +0 -5058
  137. package/dist/chunk-RFLXXSQH.js +0 -7139
  138. package/dist/chunk-RIEG3EJO.js +0 -5385
  139. package/dist/chunk-RKEFBYBO.js +0 -5402
  140. package/dist/chunk-SHUPSYR2.js +0 -5004
  141. package/dist/chunk-SUUJYVW2.js +0 -7089
  142. package/dist/chunk-TJX4M23U.js +0 -27
  143. package/dist/chunk-UIGQOSRS.js +0 -5174
  144. package/dist/chunk-UINIIZCG.js +0 -5098
  145. package/dist/chunk-UKIPSWEV.js +0 -5386
  146. package/dist/chunk-UX7ZGWNT.js +0 -7110
  147. package/dist/chunk-VOQSYTG3.js +0 -5419
  148. package/dist/chunk-VT5Q2XKZ.js +0 -5193
  149. package/dist/chunk-VXQYKPGQ.js +0 -5476
  150. package/dist/chunk-VYLJNEKY.js +0 -5129
  151. package/dist/chunk-X24B5DJR.js +0 -323
  152. package/dist/chunk-X3C73JWU.js +0 -5370
  153. package/dist/chunk-XIDK5P36.js +0 -288
  154. package/dist/chunk-ZHRI7SGC.js +0 -5359
  155. package/dist/clvWallet-R6YRCMZO.js +0 -8
  156. package/dist/coin98Wallet-4Y3ROAGP.js +0 -8
  157. package/dist/coinbaseWallet-L4QDZB5W.js +0 -8
  158. package/dist/compassWallet-NNBX35AV.js +0 -8
  159. package/dist/connect-Q2RLUT5B.js +0 -8
  160. package/dist/coreWallet-PN2LMNGN.js +0 -8
  161. package/dist/create-HQ4QXTKY.js +0 -8
  162. package/dist/cronos-KZAB32FC.js +0 -8
  163. package/dist/dawnWallet-AMO43DL3.js +0 -8
  164. package/dist/de_DE-RUWMVYCQ.js +0 -8
  165. package/dist/desigWallet-AD335WX5.js +0 -8
  166. package/dist/en_US-NQ25CUR4.js +0 -8
  167. package/dist/enkryptWallet-OOP27GE2.js +0 -8
  168. package/dist/es_419-HKJPYJRI.js +0 -8
  169. package/dist/ethereum-WAFT6DML.js +0 -8
  170. package/dist/flow-XANNOAPJ.js +0 -8
  171. package/dist/foxWallet-UDUWOW52.js +0 -8
  172. package/dist/fr_FR-2O5ZDLPQ.js +0 -1356
  173. package/dist/frameWallet-BEABTFIT.js +0 -8
  174. package/dist/frontierWallet-RG47M3C5.js +0 -8
  175. package/dist/gateWallet-XOP74BMB.js +0 -8
  176. package/dist/gnosis-7GFI4V27.js +0 -8
  177. package/dist/hardhat-6HKZWC4T.js +0 -8
  178. package/dist/hi_IN-XRZ4YIUW.js +0 -8
  179. package/dist/id_ID-REEY4CSS.js +0 -8
  180. package/dist/imTokenWallet-LTPKXYUD.js +0 -8
  181. package/dist/injectedWallet-YCFZTULL.js +0 -8
  182. package/dist/iopayWallet-XS37QAUO.js +0 -8
  183. package/dist/ja_JP-2OPCVN6X.js +0 -8
  184. package/dist/kaia-DQ3OSYXE.js +0 -8
  185. package/dist/kaiaWallet-2XZDQZ63.js +0 -8
  186. package/dist/kaikasWallet-V2GCFPEB.js +0 -8
  187. package/dist/ko_KR-DDXBZTYT.js +0 -8
  188. package/dist/krakenWallet-3VM7ZM2O.js +0 -8
  189. package/dist/kresusWallet-4MXFQP4P.js +0 -8
  190. package/dist/ledgerWallet-YC3HF3NJ.js +0 -8
  191. package/dist/login-DGIK764Z.js +0 -8
  192. package/dist/magicEden-BLYGUG47.js +0 -8
  193. package/dist/manta-OEF3QP66.js +0 -8
  194. package/dist/mantle-EYIH4GGM.js +0 -8
  195. package/dist/metaMaskWallet-ZZMFVM52.js +0 -8
  196. package/dist/mewWallet-D6JN37EZ.js +0 -8
  197. package/dist/ms_MY-PX7G4XTD.js +0 -8
  198. package/dist/nestWallet-X3CDHKNV.js +0 -8
  199. package/dist/oktoWallet-ZYLL2RLN.js +0 -8
  200. package/dist/okxWallet-FLICEG4S.js +0 -8
  201. package/dist/omniWallet-DAQHKHUN.js +0 -8
  202. package/dist/oneInchWallet-BRGGUXND.js +0 -8
  203. package/dist/oneKeyWallet-KDU2JIFD.js +0 -8
  204. package/dist/optimism-6GXRYJDW.js +0 -8
  205. package/dist/paraSwapWallet-7UHWT54G.js +0 -8
  206. package/dist/phantomWallet-BSCGZT6L.js +0 -8
  207. package/dist/polygon-YNJM552P.js +0 -8
  208. package/dist/pt_BR-A5R4SBSC.js +0 -8
  209. package/dist/rabbyWallet-RZIUL3YN.js +0 -8
  210. package/dist/rainbowWallet-4ALDT5ZL.js +0 -8
  211. package/dist/ramperWallet-IB3JRE2F.js +0 -8
  212. package/dist/refresh-R5NYTT3S.js +0 -8
  213. package/dist/ronin-LU7LZPWA.js +0 -8
  214. package/dist/roninWallet-BS7VDK7U.js +0 -8
  215. package/dist/ru_RU-4QDZLRSW.js +0 -1356
  216. package/dist/safeWallet-5NR62MJV.js +0 -8
  217. package/dist/safeheronWallet-7ELUSU44.js +0 -8
  218. package/dist/safepalWallet-CZJABQ5N.js +0 -8
  219. package/dist/scan-BVZ7DVJ4.js +0 -8
  220. package/dist/scroll-XRP46UTI.js +0 -8
  221. package/dist/seifWallet-XLBMTX4R.js +0 -8
  222. package/dist/sign-PREOQ4RR.js +0 -8
  223. package/dist/solana/ConfiguredWalletProvider.d.ts +0 -10
  224. package/dist/solana/LegacySolflareWalletAdapter.d.ts +0 -32
  225. package/dist/solana/isWalletReady.d.ts +0 -2
  226. package/dist/subWallet-47USA4OE.js +0 -8
  227. package/dist/tahoWallet-N3XXJ3NW.js +0 -8
  228. package/dist/talismanWallet-SV3B42TQ.js +0 -8
  229. package/dist/th_TH-4TWPYDKX.js +0 -1356
  230. package/dist/tokenPocketWallet-7IYW3MIL.js +0 -8
  231. package/dist/tokenaryWallet-7D2LN65X.js +0 -8
  232. package/dist/tr_TR-C37KIU7M.js +0 -1356
  233. package/dist/trustWallet-HJQBMBC6.js +0 -8
  234. package/dist/uk_UA-I77HS4GO.js +0 -1356
  235. package/dist/uniswapWallet-JZ2ULELN.js +0 -8
  236. package/dist/utils/abcWaasAdapter.d.ts +0 -75
  237. package/dist/utils/secureChannel.d.ts +0 -36
  238. package/dist/valoraWallet-PCTL6UBB.js +0 -8
  239. package/dist/vi_VN-KVPDLW26.js +0 -8
  240. package/dist/walletConnectWallet-AJ36XVBT.js +0 -8
  241. package/dist/wallets/walletConnectors/abcWallet/abcApi.d.ts +0 -238
  242. package/dist/wallets/walletConnectors/abcWallet/abcApi.js +0 -13
  243. package/dist/wallets/walletConnectors/abcWallet/api/AuthApi.d.ts +0 -75
  244. package/dist/wallets/walletConnectors/abcWallet/api/AuthApi.js +0 -11
  245. package/dist/wallets/walletConnectors/abcWallet/api/BaseApiClient.d.ts +0 -83
  246. package/dist/wallets/walletConnectors/abcWallet/api/BaseApiClient.js +0 -10
  247. package/dist/wallets/walletConnectors/abcWallet/api/BitcoinApi.d.ts +0 -65
  248. package/dist/wallets/walletConnectors/abcWallet/api/BitcoinApi.js +0 -11
  249. package/dist/wallets/walletConnectors/abcWallet/api/TransactionApi.d.ts +0 -45
  250. package/dist/wallets/walletConnectors/abcWallet/api/TransactionApi.js +0 -11
  251. package/dist/wallets/walletConnectors/abcWallet/api/TronApi.d.ts +0 -24
  252. package/dist/wallets/walletConnectors/abcWallet/api/TronApi.js +0 -11
  253. package/dist/wallets/walletConnectors/abcWallet/api/WalletApi.d.ts +0 -31
  254. package/dist/wallets/walletConnectors/abcWallet/api/WalletApi.js +0 -12
  255. package/dist/wallets/walletConnectors/abcWallet/backfillMissingWallets.d.ts +0 -3
  256. package/dist/wallets/walletConnectors/abcWallet/backfillMissingWallets.js +0 -16
  257. package/dist/wallets/walletConnectors/chunk-27346T3J.js +0 -134
  258. package/dist/wallets/walletConnectors/chunk-2IZBLAHI.js +0 -52
  259. package/dist/wallets/walletConnectors/chunk-2XX4LJSQ.js +0 -1387
  260. package/dist/wallets/walletConnectors/chunk-32IJ3ILH.js +0 -71
  261. package/dist/wallets/walletConnectors/chunk-35RTM3PL.js +0 -1
  262. package/dist/wallets/walletConnectors/chunk-37X7LFZU.js +0 -302
  263. package/dist/wallets/walletConnectors/chunk-3AX66UHT.js +0 -479
  264. package/dist/wallets/walletConnectors/chunk-3BUGPUMD.js +0 -151
  265. package/dist/wallets/walletConnectors/chunk-3BVPV64G.js +0 -36
  266. package/dist/wallets/walletConnectors/chunk-3DGFHWI3.js +0 -302
  267. package/dist/wallets/walletConnectors/chunk-3H7YKUJZ.js +0 -1407
  268. package/dist/wallets/walletConnectors/chunk-3OWQ6MEU.js +0 -54
  269. package/dist/wallets/walletConnectors/chunk-3SVPZCA6.js +0 -71
  270. package/dist/wallets/walletConnectors/chunk-3VDYWOS4.js +0 -300
  271. package/dist/wallets/walletConnectors/chunk-3XOXT4AM.js +0 -314
  272. package/dist/wallets/walletConnectors/chunk-42D2UPKR.js +0 -439
  273. package/dist/wallets/walletConnectors/chunk-42MF6LUP.js +0 -563
  274. package/dist/wallets/walletConnectors/chunk-4AINEBMQ.js +0 -52
  275. package/dist/wallets/walletConnectors/chunk-4LIJB776.js +0 -273
  276. package/dist/wallets/walletConnectors/chunk-4RZVAQQ4.js +0 -574
  277. package/dist/wallets/walletConnectors/chunk-53UTBIKF.js +0 -209
  278. package/dist/wallets/walletConnectors/chunk-54KVT46V.js +0 -1477
  279. package/dist/wallets/walletConnectors/chunk-56SF4VRC.js +0 -640
  280. package/dist/wallets/walletConnectors/chunk-5KOE7NJW.js +0 -52
  281. package/dist/wallets/walletConnectors/chunk-5QEUEPNY.js +0 -94
  282. package/dist/wallets/walletConnectors/chunk-5RDUTGDR.js +0 -54
  283. package/dist/wallets/walletConnectors/chunk-5UBUX5BT.js +0 -440
  284. package/dist/wallets/walletConnectors/chunk-5W7RBMPH.js +0 -351
  285. package/dist/wallets/walletConnectors/chunk-5ZBV5WE2.js +0 -94
  286. package/dist/wallets/walletConnectors/chunk-6BVNBUEI.js +0 -71
  287. package/dist/wallets/walletConnectors/chunk-6CVXZ3ZW.js +0 -771
  288. package/dist/wallets/walletConnectors/chunk-6EUOVOQK.js +0 -151
  289. package/dist/wallets/walletConnectors/chunk-6GCWEPU7.js +0 -643
  290. package/dist/wallets/walletConnectors/chunk-6HBDJDNH.js +0 -300
  291. package/dist/wallets/walletConnectors/chunk-6ICR4O35.js +0 -372
  292. package/dist/wallets/walletConnectors/chunk-6LH6ZME2.js +0 -479
  293. package/dist/wallets/walletConnectors/chunk-6YFP3Q2I.js +0 -118
  294. package/dist/wallets/walletConnectors/chunk-6YUJPIJ5.js +0 -351
  295. package/dist/wallets/walletConnectors/chunk-77YYMCMD.js +0 -273
  296. package/dist/wallets/walletConnectors/chunk-7DM6H5BJ.js +0 -54
  297. package/dist/wallets/walletConnectors/chunk-7EEPPULA.js +0 -118
  298. package/dist/wallets/walletConnectors/chunk-7EQNUYV2.js +0 -482
  299. package/dist/wallets/walletConnectors/chunk-7F5DVU5U.js +0 -300
  300. package/dist/wallets/walletConnectors/chunk-7K4BL7CY.js +0 -516
  301. package/dist/wallets/walletConnectors/chunk-7K77YGQN.js +0 -54
  302. package/dist/wallets/walletConnectors/chunk-7MDXHYMB.js +0 -151
  303. package/dist/wallets/walletConnectors/chunk-7MMVOEZF.js +0 -393
  304. package/dist/wallets/walletConnectors/chunk-7ORDZ6EQ.js +0 -1479
  305. package/dist/wallets/walletConnectors/chunk-7QL42XTB.js +0 -302
  306. package/dist/wallets/walletConnectors/chunk-7RDMH4SD.js +0 -54
  307. package/dist/wallets/walletConnectors/chunk-7RSNIMBB.js +0 -372
  308. package/dist/wallets/walletConnectors/chunk-7S4N4DRT.js +0 -306
  309. package/dist/wallets/walletConnectors/chunk-7SWRH3EI.js +0 -96
  310. package/dist/wallets/walletConnectors/chunk-7ZCM4DCC.js +0 -272
  311. package/dist/wallets/walletConnectors/chunk-A3OJZTDV.js +0 -54
  312. package/dist/wallets/walletConnectors/chunk-A7ZSPSFX.js +0 -577
  313. package/dist/wallets/walletConnectors/chunk-AFM6KHDP.js +0 -314
  314. package/dist/wallets/walletConnectors/chunk-AI3CT254.js +0 -302
  315. package/dist/wallets/walletConnectors/chunk-AJBRO3VA.js +0 -300
  316. package/dist/wallets/walletConnectors/chunk-AMNVH7CZ.js +0 -151
  317. package/dist/wallets/walletConnectors/chunk-AOREXGRM.js +0 -350
  318. package/dist/wallets/walletConnectors/chunk-AXMN57KP.js +0 -1387
  319. package/dist/wallets/walletConnectors/chunk-B6JLYR3I.js +0 -66
  320. package/dist/wallets/walletConnectors/chunk-BBD77PEX.js +0 -761
  321. package/dist/wallets/walletConnectors/chunk-BDM7TUVM.js +0 -874
  322. package/dist/wallets/walletConnectors/chunk-BKVGLYLI.js +0 -194
  323. package/dist/wallets/walletConnectors/chunk-BLO7E54F.js +0 -302
  324. package/dist/wallets/walletConnectors/chunk-BNRH5PYS.js +0 -52
  325. package/dist/wallets/walletConnectors/chunk-BOV5FXU6.js +0 -151
  326. package/dist/wallets/walletConnectors/chunk-BR25RFNF.js +0 -260
  327. package/dist/wallets/walletConnectors/chunk-BXQ2UWJ3.js +0 -91
  328. package/dist/wallets/walletConnectors/chunk-BYZ5QLMX.js +0 -436
  329. package/dist/wallets/walletConnectors/chunk-C3FPON5L.js +0 -213
  330. package/dist/wallets/walletConnectors/chunk-C4L5XI6N.js +0 -302
  331. package/dist/wallets/walletConnectors/chunk-C6G5FPD6.js +0 -286
  332. package/dist/wallets/walletConnectors/chunk-CABLJOMU.js +0 -194
  333. package/dist/wallets/walletConnectors/chunk-CAMPW7O2.js +0 -874
  334. package/dist/wallets/walletConnectors/chunk-CBIDNYV4.js +0 -1407
  335. package/dist/wallets/walletConnectors/chunk-CC6GTQBN.js +0 -148
  336. package/dist/wallets/walletConnectors/chunk-CE37VZAR.js +0 -300
  337. package/dist/wallets/walletConnectors/chunk-CJOFM6CV.js +0 -71
  338. package/dist/wallets/walletConnectors/chunk-CLMFCNP7.js +0 -52
  339. package/dist/wallets/walletConnectors/chunk-CN672ZCD.js +0 -52
  340. package/dist/wallets/walletConnectors/chunk-CPAYLZZL.js +0 -205
  341. package/dist/wallets/walletConnectors/chunk-D5EFTEOM.js +0 -56
  342. package/dist/wallets/walletConnectors/chunk-DD6KK4BR.js +0 -54
  343. package/dist/wallets/walletConnectors/chunk-DHHVIM22.js +0 -259
  344. package/dist/wallets/walletConnectors/chunk-DSNVWCPD.js +0 -131
  345. package/dist/wallets/walletConnectors/chunk-DSZOE65L.js +0 -107
  346. package/dist/wallets/walletConnectors/chunk-DU6RCLWT.js +0 -272
  347. package/dist/wallets/walletConnectors/chunk-DULGAYBU.js +0 -785
  348. package/dist/wallets/walletConnectors/chunk-DZUXOGSA.js +0 -54
  349. package/dist/wallets/walletConnectors/chunk-E7TDM6P6.js +0 -205
  350. package/dist/wallets/walletConnectors/chunk-EAKU7HN4.js +0 -302
  351. package/dist/wallets/walletConnectors/chunk-ENN6UGGA.js +0 -421
  352. package/dist/wallets/walletConnectors/chunk-EVJIFLSY.js +0 -93
  353. package/dist/wallets/walletConnectors/chunk-EVW3ZB3Q.js +0 -386
  354. package/dist/wallets/walletConnectors/chunk-EXLVQ5ES.js +0 -302
  355. package/dist/wallets/walletConnectors/chunk-EXWDLN5V.js +0 -204
  356. package/dist/wallets/walletConnectors/chunk-F2UWSAMX.js +0 -54
  357. package/dist/wallets/walletConnectors/chunk-F5C6OZYF.js +0 -577
  358. package/dist/wallets/walletConnectors/chunk-FAVNVTIA.js +0 -479
  359. package/dist/wallets/walletConnectors/chunk-FBVPR472.js +0 -314
  360. package/dist/wallets/walletConnectors/chunk-FFU26Y5Y.js +0 -272
  361. package/dist/wallets/walletConnectors/chunk-FGS2WHVA.js +0 -118
  362. package/dist/wallets/walletConnectors/chunk-FJJ3QI4R.js +0 -91
  363. package/dist/wallets/walletConnectors/chunk-FKS2YLVW.js +0 -273
  364. package/dist/wallets/walletConnectors/chunk-FOGNJZPY.js +0 -54
  365. package/dist/wallets/walletConnectors/chunk-FS2OOQYF.js +0 -204
  366. package/dist/wallets/walletConnectors/chunk-FSSV6JY3.js +0 -54
  367. package/dist/wallets/walletConnectors/chunk-G5X3COSW.js +0 -205
  368. package/dist/wallets/walletConnectors/chunk-GBMOX5JN.js +0 -54
  369. package/dist/wallets/walletConnectors/chunk-GFLJ2MAG.js +0 -54
  370. package/dist/wallets/walletConnectors/chunk-GGPJJ6KS.js +0 -1407
  371. package/dist/wallets/walletConnectors/chunk-GJOFP2FQ.js +0 -71
  372. package/dist/wallets/walletConnectors/chunk-GMAYKJEI.js +0 -508
  373. package/dist/wallets/walletConnectors/chunk-GRN6YAJC.js +0 -71
  374. package/dist/wallets/walletConnectors/chunk-GWYZ2IPP.js +0 -1479
  375. package/dist/wallets/walletConnectors/chunk-H2RCMAOR.js +0 -289
  376. package/dist/wallets/walletConnectors/chunk-H3OWNM73.js +0 -300
  377. package/dist/wallets/walletConnectors/chunk-H53R4SFZ.js +0 -204
  378. package/dist/wallets/walletConnectors/chunk-HF6GFAE5.js +0 -54
  379. package/dist/wallets/walletConnectors/chunk-HKWBR5B7.js +0 -102
  380. package/dist/wallets/walletConnectors/chunk-IM7DEERX.js +0 -585
  381. package/dist/wallets/walletConnectors/chunk-INFMRNND.js +0 -300
  382. package/dist/wallets/walletConnectors/chunk-INT6LGH7.js +0 -180
  383. package/dist/wallets/walletConnectors/chunk-ITZ42A33.js +0 -273
  384. package/dist/wallets/walletConnectors/chunk-IX6DQDRE.js +0 -107
  385. package/dist/wallets/walletConnectors/chunk-IXEXMODE.js +0 -272
  386. package/dist/wallets/walletConnectors/chunk-J3YPHDHM.js +0 -827
  387. package/dist/wallets/walletConnectors/chunk-J4IF6BFF.js +0 -300
  388. package/dist/wallets/walletConnectors/chunk-J4QGDATF.js +0 -71
  389. package/dist/wallets/walletConnectors/chunk-JAMJLNYQ.js +0 -54
  390. package/dist/wallets/walletConnectors/chunk-JDJUIRGF.js +0 -439
  391. package/dist/wallets/walletConnectors/chunk-JEWCPQJZ.js +0 -300
  392. package/dist/wallets/walletConnectors/chunk-JIJNCMJR.js +0 -874
  393. package/dist/wallets/walletConnectors/chunk-JK7LJ4B6.js +0 -1407
  394. package/dist/wallets/walletConnectors/chunk-JPOSJU2D.js +0 -594
  395. package/dist/wallets/walletConnectors/chunk-JSGZYU4A.js +0 -52
  396. package/dist/wallets/walletConnectors/chunk-JUFEPIO4.js +0 -1479
  397. package/dist/wallets/walletConnectors/chunk-JV4IC5Z7.js +0 -54
  398. package/dist/wallets/walletConnectors/chunk-JVT7R2GZ.js +0 -771
  399. package/dist/wallets/walletConnectors/chunk-K37GTJN7.js +0 -52
  400. package/dist/wallets/walletConnectors/chunk-K3JNN5UK.js +0 -71
  401. package/dist/wallets/walletConnectors/chunk-K3VHBOXQ.js +0 -32
  402. package/dist/wallets/walletConnectors/chunk-K4APJ4PE.js +0 -96
  403. package/dist/wallets/walletConnectors/chunk-KBHPY3NA.js +0 -302
  404. package/dist/wallets/walletConnectors/chunk-KBSO4UER.js +0 -372
  405. package/dist/wallets/walletConnectors/chunk-KEX6WS23.js +0 -640
  406. package/dist/wallets/walletConnectors/chunk-KHYKVVR7.js +0 -52
  407. package/dist/wallets/walletConnectors/chunk-KZS2C73S.js +0 -814
  408. package/dist/wallets/walletConnectors/chunk-L6EUMSX2.js +0 -54
  409. package/dist/wallets/walletConnectors/chunk-LJ2B47VF.js +0 -108
  410. package/dist/wallets/walletConnectors/chunk-LJNUFDGO.js +0 -205
  411. package/dist/wallets/walletConnectors/chunk-LOL7ZZ3S.js +0 -302
  412. package/dist/wallets/walletConnectors/chunk-LOSXI36Y.js +0 -479
  413. package/dist/wallets/walletConnectors/chunk-LXINMUQC.js +0 -186
  414. package/dist/wallets/walletConnectors/chunk-M2U5QGM7.js +0 -260
  415. package/dist/wallets/walletConnectors/chunk-M6KRNMD3.js +0 -71
  416. package/dist/wallets/walletConnectors/chunk-M73AWLIV.js +0 -107
  417. package/dist/wallets/walletConnectors/chunk-MAUC46AE.js +0 -302
  418. package/dist/wallets/walletConnectors/chunk-MBRXYEQC.js +0 -272
  419. package/dist/wallets/walletConnectors/chunk-MDDD4LG2.js +0 -874
  420. package/dist/wallets/walletConnectors/chunk-MEAJDFYT.js +0 -302
  421. package/dist/wallets/walletConnectors/chunk-MMR2QAEU.js +0 -642
  422. package/dist/wallets/walletConnectors/chunk-MNZZRFUC.js +0 -302
  423. package/dist/wallets/walletConnectors/chunk-MORUEOYX.js +0 -76
  424. package/dist/wallets/walletConnectors/chunk-MP3WVXPS.js +0 -273
  425. package/dist/wallets/walletConnectors/chunk-MQTXA63X.js +0 -27
  426. package/dist/wallets/walletConnectors/chunk-MRFTCMBN.js +0 -52
  427. package/dist/wallets/walletConnectors/chunk-MTC2HJPF.js +0 -96
  428. package/dist/wallets/walletConnectors/chunk-MTJF3SVB.js +0 -1487
  429. package/dist/wallets/walletConnectors/chunk-N7W4H2XZ.js +0 -71
  430. package/dist/wallets/walletConnectors/chunk-NBEDPUHX.js +0 -91
  431. package/dist/wallets/walletConnectors/chunk-NBVPVTJZ.js +0 -192
  432. package/dist/wallets/walletConnectors/chunk-NISMGNEE.js +0 -223
  433. package/dist/wallets/walletConnectors/chunk-NY5O2OBG.js +0 -1477
  434. package/dist/wallets/walletConnectors/chunk-NYDDRNUI.js +0 -445
  435. package/dist/wallets/walletConnectors/chunk-O47OQDRJ.js +0 -204
  436. package/dist/wallets/walletConnectors/chunk-O4DNG6JJ.js +0 -54
  437. package/dist/wallets/walletConnectors/chunk-OA57GKKV.js +0 -514
  438. package/dist/wallets/walletConnectors/chunk-OIRY24PH.js +0 -302
  439. package/dist/wallets/walletConnectors/chunk-OMOYFHBT.js +0 -1485
  440. package/dist/wallets/walletConnectors/chunk-ORBX4JE2.js +0 -52
  441. package/dist/wallets/walletConnectors/chunk-OTES5NGR.js +0 -286
  442. package/dist/wallets/walletConnectors/chunk-OXJFFDW7.js +0 -761
  443. package/dist/wallets/walletConnectors/chunk-OYF6AQOW.js +0 -194
  444. package/dist/wallets/walletConnectors/chunk-PBOCVGUC.js +0 -782
  445. package/dist/wallets/walletConnectors/chunk-PDXO6AOG.js +0 -300
  446. package/dist/wallets/walletConnectors/chunk-PGOYWXV2.js +0 -874
  447. package/dist/wallets/walletConnectors/chunk-PJSN4YRI.js +0 -1387
  448. package/dist/wallets/walletConnectors/chunk-PMZJGS7X.js +0 -73
  449. package/dist/wallets/walletConnectors/chunk-PVIO7FM7.js +0 -314
  450. package/dist/wallets/walletConnectors/chunk-PWJOXYDF.js +0 -54
  451. package/dist/wallets/walletConnectors/chunk-PYBSONED.js +0 -771
  452. package/dist/wallets/walletConnectors/chunk-PYKECUZ3.js +0 -54
  453. package/dist/wallets/walletConnectors/chunk-PYL7NUFJ.js +0 -52
  454. package/dist/wallets/walletConnectors/chunk-Q42NO7WB.js +0 -46
  455. package/dist/wallets/walletConnectors/chunk-Q7XBI5F6.js +0 -300
  456. package/dist/wallets/walletConnectors/chunk-QA3NATYL.js +0 -52
  457. package/dist/wallets/walletConnectors/chunk-QD3PPWTN.js +0 -272
  458. package/dist/wallets/walletConnectors/chunk-QHCLOJYA.js +0 -118
  459. package/dist/wallets/walletConnectors/chunk-QHUBLT7N.js +0 -156
  460. package/dist/wallets/walletConnectors/chunk-QP36UXD5.js +0 -54
  461. package/dist/wallets/walletConnectors/chunk-RCIABMG5.js +0 -259
  462. package/dist/wallets/walletConnectors/chunk-RHC4SVLB.js +0 -71
  463. package/dist/wallets/walletConnectors/chunk-RIJTOH57.js +0 -771
  464. package/dist/wallets/walletConnectors/chunk-RMV23JXO.js +0 -300
  465. package/dist/wallets/walletConnectors/chunk-RS36ZX4P.js +0 -36
  466. package/dist/wallets/walletConnectors/chunk-RY43MKRA.js +0 -552
  467. package/dist/wallets/walletConnectors/chunk-S2CB4KFC.js +0 -71
  468. package/dist/wallets/walletConnectors/chunk-S3L2SA4J.js +0 -300
  469. package/dist/wallets/walletConnectors/chunk-S466OQOC.js +0 -393
  470. package/dist/wallets/walletConnectors/chunk-S6HZD4XZ.js +0 -302
  471. package/dist/wallets/walletConnectors/chunk-S72LCNVX.js +0 -272
  472. package/dist/wallets/walletConnectors/chunk-SA7IXAFG.js +0 -54
  473. package/dist/wallets/walletConnectors/chunk-SCWE5EEX.js +0 -91
  474. package/dist/wallets/walletConnectors/chunk-SDB6BBHX.js +0 -585
  475. package/dist/wallets/walletConnectors/chunk-SFGVPX2G.js +0 -351
  476. package/dist/wallets/walletConnectors/chunk-SFQKJ6X6.js +0 -314
  477. package/dist/wallets/walletConnectors/chunk-SHJBMDP4.js +0 -278
  478. package/dist/wallets/walletConnectors/chunk-SKLRJRER.js +0 -1464
  479. package/dist/wallets/walletConnectors/chunk-SQVWIBWR.js +0 -351
  480. package/dist/wallets/walletConnectors/chunk-SSLHXCOX.js +0 -439
  481. package/dist/wallets/walletConnectors/chunk-SU6LV3EO.js +0 -314
  482. package/dist/wallets/walletConnectors/chunk-SU7IEZE2.js +0 -300
  483. package/dist/wallets/walletConnectors/chunk-TKEL4D4E.js +0 -151
  484. package/dist/wallets/walletConnectors/chunk-TKJEMEBZ.js +0 -71
  485. package/dist/wallets/walletConnectors/chunk-TMRB5SCL.js +0 -167
  486. package/dist/wallets/walletConnectors/chunk-TMUPUOQR.js +0 -54
  487. package/dist/wallets/walletConnectors/chunk-TNZ7QKXH.js +0 -771
  488. package/dist/wallets/walletConnectors/chunk-TQXCRSMS.js +0 -199
  489. package/dist/wallets/walletConnectors/chunk-TT2NLKIU.js +0 -1465
  490. package/dist/wallets/walletConnectors/chunk-TZ44ZREA.js +0 -302
  491. package/dist/wallets/walletConnectors/chunk-U3WGMWTH.js +0 -585
  492. package/dist/wallets/walletConnectors/chunk-UAV4SI4Y.js +0 -408
  493. package/dist/wallets/walletConnectors/chunk-UAWWPNS7.js +0 -54
  494. package/dist/wallets/walletConnectors/chunk-UGQSI3US.js +0 -547
  495. package/dist/wallets/walletConnectors/chunk-UPYPPBXD.js +0 -1485
  496. package/dist/wallets/walletConnectors/chunk-URFU24K7.js +0 -273
  497. package/dist/wallets/walletConnectors/chunk-USS5CPXQ.js +0 -54
  498. package/dist/wallets/walletConnectors/chunk-UU4JYY3C.js +0 -205
  499. package/dist/wallets/walletConnectors/chunk-UXRJASPW.js +0 -785
  500. package/dist/wallets/walletConnectors/chunk-UY5TAYLM.js +0 -54
  501. package/dist/wallets/walletConnectors/chunk-V5P5BL6Z.js +0 -302
  502. package/dist/wallets/walletConnectors/chunk-VB5IZDY7.js +0 -300
  503. package/dist/wallets/walletConnectors/chunk-VH6DIRPF.js +0 -71
  504. package/dist/wallets/walletConnectors/chunk-VIKJNKJZ.js +0 -219
  505. package/dist/wallets/walletConnectors/chunk-VKOPUEQG.js +0 -445
  506. package/dist/wallets/walletConnectors/chunk-VPNZAMW5.js +0 -205
  507. package/dist/wallets/walletConnectors/chunk-VQYS4NXP.js +0 -314
  508. package/dist/wallets/walletConnectors/chunk-VTOD7PXP.js +0 -817
  509. package/dist/wallets/walletConnectors/chunk-VVEXF6KG.js +0 -273
  510. package/dist/wallets/walletConnectors/chunk-W2YIRNMB.js +0 -300
  511. package/dist/wallets/walletConnectors/chunk-W6QN6QXO.js +0 -52
  512. package/dist/wallets/walletConnectors/chunk-W7EGSTIU.js +0 -71
  513. package/dist/wallets/walletConnectors/chunk-W7L2SBIG.js +0 -138
  514. package/dist/wallets/walletConnectors/chunk-WC7BGU5Z.js +0 -814
  515. package/dist/wallets/walletConnectors/chunk-WDULICVN.js +0 -302
  516. package/dist/wallets/walletConnectors/chunk-WGGHGODM.js +0 -272
  517. package/dist/wallets/walletConnectors/chunk-WS5FG53X.js +0 -54
  518. package/dist/wallets/walletConnectors/chunk-WVRGC2YL.js +0 -300
  519. package/dist/wallets/walletConnectors/chunk-WZZVA3LW.js +0 -101
  520. package/dist/wallets/walletConnectors/chunk-X33WL7R7.js +0 -300
  521. package/dist/wallets/walletConnectors/chunk-XG2R64B7.js +0 -785
  522. package/dist/wallets/walletConnectors/chunk-XOQNQKZE.js +0 -98
  523. package/dist/wallets/walletConnectors/chunk-XUCMTLM3.js +0 -52
  524. package/dist/wallets/walletConnectors/chunk-Y2BWF42Z.js +0 -54
  525. package/dist/wallets/walletConnectors/chunk-Y446VZWI.js +0 -585
  526. package/dist/wallets/walletConnectors/chunk-Y5WAX6WO.js +0 -52
  527. package/dist/wallets/walletConnectors/chunk-Y62PFBWE.js +0 -640
  528. package/dist/wallets/walletConnectors/chunk-YDSBY7NO.js +0 -54
  529. package/dist/wallets/walletConnectors/chunk-YRDNIP2H.js +0 -90
  530. package/dist/wallets/walletConnectors/chunk-YROAFC7Z.js +0 -54
  531. package/dist/wallets/walletConnectors/chunk-YWP2ASJM.js +0 -71
  532. package/dist/wallets/walletConnectors/chunk-Z3L3JJNU.js +0 -356
  533. package/dist/wallets/walletConnectors/chunk-Z4WVT3G2.js +0 -1416
  534. package/dist/wallets/walletConnectors/chunk-Z5SBGIWT.js +0 -300
  535. package/dist/wallets/walletConnectors/chunk-Z6ABK6G6.js +0 -107
  536. package/dist/wallets/walletConnectors/chunk-ZAZVSLZK.js +0 -52
  537. package/dist/wallets/walletConnectors/chunk-ZCA5QSIM.js +0 -71
  538. package/dist/wallets/walletConnectors/chunk-ZJ6OFFD5.js +0 -95
  539. package/dist/wallets/walletConnectors/chunk-ZJDZJW55.js +0 -479
  540. package/dist/wallets/walletConnectors/chunk-ZK3PZIAH.js +0 -300
  541. package/dist/wallets/walletConnectors/chunk-ZKCUYHBK.js +0 -300
  542. package/dist/wallets/walletConnectors/chunk-ZOF7ZDGU.js +0 -52
  543. package/dist/wallets/walletConnectors/chunk-ZPJLV3E7.js +0 -151
  544. package/dist/wallets/walletConnectors/chunk-ZQ3LCYGH.js +0 -408
  545. package/dist/wallets/walletConnectors/chunk-ZQJIAY3X.js +0 -286
  546. package/dist/wallets/walletConnectors/chunk-ZTNC64G5.js +0 -372
  547. package/dist/wallets/walletConnectors/chunk-ZUU57RHO.js +0 -36
  548. package/dist/wallets/walletConnectors/chunk-ZWFGRREM.js +0 -36
  549. package/dist/wallets/walletConnectors/chunk-ZX6HMX7N.js +0 -1468
  550. package/dist/wallets/walletConnectors/chunk-ZXN465CA.js +0 -209
  551. package/dist/wallets/walletConnectors/chunk-ZY5BCHP2.js +0 -302
  552. package/dist/wigwamWallet-D3MVGB5Z.js +0 -8
  553. package/dist/xdc-5NQHQJE5.js +0 -8
  554. package/dist/xdefiWallet-B4O6HAIP.js +0 -8
  555. package/dist/zealWallet-6SPNICRX.js +0 -8
  556. package/dist/zerionWallet-XZ3JCAOO.js +0 -8
  557. package/dist/zetachain-U6IILKZJ.js +0 -8
  558. package/dist/zh_CN-KGLAIP3N.js +0 -8
  559. package/dist/zh_HK-AEXEN6P6.js +0 -8
  560. package/dist/zh_TW-6C7R5V3K.js +0 -8
  561. package/dist/zkSync-TMPB52ZN.js +0 -8
  562. package/dist/zora-S46CHEOU.js +0 -8
@@ -1,5059 +0,0 @@
1
- "use client";
2
- import {
3
- ABC_WALLET_METADATA,
4
- DEFAULT_TALKEN_API_CONFIG,
5
- PIN_CONFIG,
6
- STORAGE_PREFIX,
7
- TALKEN_API_ENDPOINTS,
8
- TOKEN_EXPIRY,
9
- getCredentialManager
10
- } from "./chunk-XIDK5P36.js";
11
-
12
- // src/wallets/walletConnectors/abcWallet/abcWallet.ts
13
- import { setTalkenApiClient as setTalkenApiClient2 } from "@talken/talkenkit";
14
-
15
- // src/wallets/walletConnectors/abcWallet/abcConnector.ts
16
- import { getTalkenApiClient as getTalkenApiClient3 } from "@talken/talkenkit";
17
- import { createConnector } from "wagmi";
18
-
19
- // src/wallets/walletConnectors/abcWallet/abcProvider.ts
20
- import { getTalkenApiClient } from "@talken/talkenkit";
21
- import { parseGwei } from "viem";
22
-
23
- // src/config/networks.ts
24
- var NetworkType = /* @__PURE__ */ ((NetworkType2) => {
25
- NetworkType2["EVM"] = "EVM";
26
- NetworkType2["NON_EVM"] = "Non-EVM";
27
- NetworkType2["BITCOIN"] = "Bitcoin";
28
- NetworkType2["TRON"] = "TRX";
29
- NetworkType2["ICP"] = "ICP";
30
- NetworkType2["SOLANA"] = "Solana";
31
- return NetworkType2;
32
- })(NetworkType || {});
33
- var NETWORK_CONFIGS = {
34
- // Ethereum Mainnet
35
- 1: {
36
- chainId: 1,
37
- network: "ethereum",
38
- name: "Ethereum",
39
- type: "EVM" /* EVM */,
40
- isTestnet: false,
41
- explorer: "https://etherscan.io",
42
- website: "https://ethereum.org",
43
- nativeCurrency: {
44
- name: "Ether",
45
- symbol: "ETH",
46
- decimals: 18
47
- },
48
- apiSupport: { tokens: true, nft: true, transactions: true },
49
- signSupport: { legacy: true, eip1559: true }
50
- },
51
- // Ethereum Sepolia Testnet
52
- 11155111: {
53
- chainId: 11155111,
54
- network: "ethereum_sepolia",
55
- name: "Ethereum Sepolia",
56
- type: "EVM" /* EVM */,
57
- isTestnet: true,
58
- explorer: "https://sepolia.etherscan.io",
59
- website: "https://ethereum.org",
60
- nativeCurrency: {
61
- name: "Sepolia Ether",
62
- symbol: "ETH",
63
- decimals: 18
64
- },
65
- apiSupport: { tokens: true, nft: true, transactions: true },
66
- signSupport: { legacy: true, eip1559: true }
67
- },
68
- // Ethereum Holesky Testnet
69
- 17e3: {
70
- chainId: 17e3,
71
- network: "ethereum_holesky",
72
- name: "Ethereum Holesky",
73
- type: "EVM" /* EVM */,
74
- isTestnet: true,
75
- explorer: "https://holesky.etherscan.io",
76
- website: "https://ethereum.org",
77
- nativeCurrency: {
78
- name: "Holesky Ether",
79
- symbol: "ETH",
80
- decimals: 18
81
- },
82
- apiSupport: { tokens: true, nft: true, transactions: true },
83
- signSupport: { legacy: true, eip1559: true }
84
- },
85
- // Kaia Mainnet (formerly Klaytn)
86
- 8217: {
87
- chainId: 8217,
88
- network: "kaia",
89
- name: "Kaia Mainnet",
90
- type: "EVM" /* EVM */,
91
- isTestnet: false,
92
- explorer: "https://kaiascan.io",
93
- website: "https://kaia.io",
94
- nativeCurrency: {
95
- name: "Kaia",
96
- symbol: "KAIA",
97
- decimals: 18
98
- },
99
- apiSupport: { tokens: true, nft: true, transactions: true },
100
- signSupport: { legacy: true, eip1559: true }
101
- },
102
- // Kaia Kairos Testnet
103
- 1001: {
104
- chainId: 1001,
105
- network: "kaia_kairos",
106
- name: "Kaia Kairos Testnet",
107
- type: "EVM" /* EVM */,
108
- isTestnet: true,
109
- explorer: "https://kairos.kaiascan.io",
110
- website: "https://kaia.io",
111
- nativeCurrency: {
112
- name: "Kaia",
113
- symbol: "KAIA",
114
- decimals: 18
115
- },
116
- apiSupport: { tokens: true, nft: true, transactions: true },
117
- signSupport: { legacy: true, eip1559: true }
118
- },
119
- // Polygon Mainnet
120
- 137: {
121
- chainId: 137,
122
- network: "polygon",
123
- name: "Polygon",
124
- type: "EVM" /* EVM */,
125
- isTestnet: false,
126
- explorer: "https://polygonscan.com",
127
- website: "https://polygon.technology",
128
- nativeCurrency: {
129
- name: "MATIC",
130
- symbol: "MATIC",
131
- decimals: 18
132
- },
133
- apiSupport: { tokens: true, nft: true, transactions: true },
134
- signSupport: { legacy: true, eip1559: true }
135
- },
136
- // Polygon Amoy Testnet
137
- 80001: {
138
- chainId: 80001,
139
- network: "polygon_amoy",
140
- name: "Polygon Amoy Testnet",
141
- type: "EVM" /* EVM */,
142
- isTestnet: true,
143
- explorer: "https://amoy.polygonscan.com",
144
- website: "https://polygon.technology",
145
- nativeCurrency: {
146
- name: "MATIC",
147
- symbol: "MATIC",
148
- decimals: 18
149
- },
150
- apiSupport: { tokens: true, nft: true, transactions: true },
151
- signSupport: { legacy: true, eip1559: true }
152
- },
153
- // Binance Smart Chain Mainnet
154
- 56: {
155
- chainId: 56,
156
- network: "binance",
157
- name: "Binance Smart Chain Mainnet",
158
- type: "EVM" /* EVM */,
159
- isTestnet: false,
160
- explorer: "https://bscscan.com",
161
- website: "https://www.bnbchain.org/en/bnb-smart-chain",
162
- nativeCurrency: {
163
- name: "BNB",
164
- symbol: "BNB",
165
- decimals: 18
166
- },
167
- apiSupport: { tokens: true, nft: true, transactions: true },
168
- signSupport: { legacy: true, eip1559: true }
169
- },
170
- // Binance Smart Chain Testnet
171
- 97: {
172
- chainId: 97,
173
- network: "binance_testnet",
174
- name: "Binance Smart Chain Testnet",
175
- type: "EVM" /* EVM */,
176
- isTestnet: true,
177
- explorer: "https://testnet.bscscan.com",
178
- website: "https://www.bnbchain.org/en/bnb-smart-chain",
179
- nativeCurrency: {
180
- name: "BNB",
181
- symbol: "BNB",
182
- decimals: 18
183
- },
184
- apiSupport: { tokens: true, nft: true, transactions: true },
185
- signSupport: { legacy: true, eip1559: true }
186
- },
187
- // Arbitrum One
188
- 42161: {
189
- chainId: 42161,
190
- network: "arbitrum",
191
- name: "Arbitrum One",
192
- type: "EVM" /* EVM */,
193
- isTestnet: false,
194
- explorer: "https://arbiscan.io",
195
- website: "https://arbitrum.io",
196
- nativeCurrency: {
197
- name: "Ether",
198
- symbol: "ETH",
199
- decimals: 18
200
- },
201
- apiSupport: { tokens: true, nft: true, transactions: true },
202
- signSupport: { legacy: true, eip1559: true }
203
- },
204
- // Arbitrum Sepolia
205
- 421614: {
206
- chainId: 421614,
207
- network: "arbitrum_sepolia",
208
- name: "Arbitrum Sepolia",
209
- type: "EVM" /* EVM */,
210
- isTestnet: true,
211
- explorer: "https://sepolia.arbiscan.io",
212
- website: "https://arbitrum.io",
213
- nativeCurrency: {
214
- name: "Ether",
215
- symbol: "ETH",
216
- decimals: 18
217
- },
218
- apiSupport: { tokens: true, nft: true, transactions: true },
219
- signSupport: { legacy: true, eip1559: true }
220
- },
221
- // Optimism Mainnet
222
- 10: {
223
- chainId: 10,
224
- network: "optimism",
225
- name: "Optimism",
226
- type: "EVM" /* EVM */,
227
- isTestnet: false,
228
- explorer: "https://optimistic.etherscan.io",
229
- website: "https://optimism.io",
230
- nativeCurrency: {
231
- name: "Ether",
232
- symbol: "ETH",
233
- decimals: 18
234
- },
235
- apiSupport: { tokens: true, nft: true, transactions: true },
236
- signSupport: { legacy: true, eip1559: true }
237
- },
238
- // Optimism Sepolia
239
- 420: {
240
- chainId: 420,
241
- network: "optimism_sepolia",
242
- name: "Optimism Sepolia",
243
- type: "EVM" /* EVM */,
244
- isTestnet: true,
245
- explorer: "https://sepolia-optimism.etherscan.io",
246
- website: "https://optimism.io",
247
- nativeCurrency: {
248
- name: "Ether",
249
- symbol: "ETH",
250
- decimals: 18
251
- },
252
- apiSupport: { tokens: true, nft: true, transactions: true },
253
- signSupport: { legacy: true, eip1559: true }
254
- },
255
- // Avalanche C-Chain
256
- 43114: {
257
- chainId: 43114,
258
- network: "avalanche",
259
- name: "Avalanche C-Chain",
260
- type: "EVM" /* EVM */,
261
- isTestnet: false,
262
- explorer: "https://avascan.info/blockchain/c/home",
263
- website: "https://avax.network",
264
- nativeCurrency: {
265
- name: "Avalanche",
266
- symbol: "AVAX",
267
- decimals: 18
268
- },
269
- apiSupport: { tokens: true, nft: true, transactions: true },
270
- signSupport: { legacy: true, eip1559: true }
271
- },
272
- // Avalanche Fuji Testnet
273
- 43113: {
274
- chainId: 43113,
275
- network: "avalanche_fuji",
276
- name: "Avalanche Fuji Testnet",
277
- type: "EVM" /* EVM */,
278
- isTestnet: true,
279
- explorer: "https://testnet.avascan.info",
280
- website: "https://avax.network",
281
- nativeCurrency: {
282
- name: "Avalanche",
283
- symbol: "AVAX",
284
- decimals: 18
285
- },
286
- apiSupport: { tokens: false, nft: false, transactions: false },
287
- signSupport: { legacy: true, eip1559: true }
288
- },
289
- // Mantle Mainnet
290
- 5e3: {
291
- chainId: 5e3,
292
- network: "mantle",
293
- name: "Mantle Mainnet",
294
- type: "EVM" /* EVM */,
295
- isTestnet: false,
296
- explorer: "https://explorer.mantle.xyz",
297
- website: "https://www.mantle.xyz",
298
- nativeCurrency: {
299
- name: "Mantle",
300
- symbol: "MNT",
301
- decimals: 18
302
- },
303
- apiSupport: { tokens: true, nft: true, transactions: true },
304
- signSupport: { legacy: true, eip1559: true }
305
- },
306
- // Mantle Testnet
307
- 5001: {
308
- chainId: 5001,
309
- network: "mantle_testnet",
310
- name: "Mantle Testnet",
311
- type: "EVM" /* EVM */,
312
- isTestnet: true,
313
- explorer: "https://sepolia.mantlescan.xyz",
314
- website: "https://www.mantle.xyz",
315
- nativeCurrency: {
316
- name: "Mantle",
317
- symbol: "MNT",
318
- decimals: 18
319
- },
320
- apiSupport: { tokens: true, nft: true, transactions: true },
321
- signSupport: { legacy: true, eip1559: true }
322
- },
323
- // Moonbeam
324
- 1284: {
325
- chainId: 1284,
326
- network: "moonbeam",
327
- name: "Moonbeam",
328
- type: "EVM" /* EVM */,
329
- isTestnet: false,
330
- explorer: "https://moonbeam.moonscan.io",
331
- website: "https://moonbeam.network",
332
- nativeCurrency: {
333
- name: "Glimmer",
334
- symbol: "GLMR",
335
- decimals: 18
336
- },
337
- apiSupport: { tokens: true, nft: true, transactions: true },
338
- signSupport: { legacy: true, eip1559: true }
339
- },
340
- // Moonriver
341
- 1285: {
342
- chainId: 1285,
343
- network: "moonriver",
344
- name: "Moonriver",
345
- type: "EVM" /* EVM */,
346
- isTestnet: false,
347
- explorer: "https://moonriver.moonscan.io",
348
- website: "https://moonbeam.network/networks/moonriver",
349
- nativeCurrency: {
350
- name: "Moonriver",
351
- symbol: "MOVR",
352
- decimals: 18
353
- },
354
- apiSupport: { tokens: true, nft: true, transactions: true },
355
- signSupport: { legacy: true, eip1559: true }
356
- },
357
- // Scroll Mainnet
358
- 534352: {
359
- chainId: 534352,
360
- network: "scroll",
361
- name: "Scroll",
362
- type: "EVM" /* EVM */,
363
- isTestnet: false,
364
- explorer: "https://scrollscan.co",
365
- website: "https://scroll.io",
366
- nativeCurrency: {
367
- name: "Ether",
368
- symbol: "ETH",
369
- decimals: 18
370
- },
371
- apiSupport: { tokens: true, nft: true, transactions: true },
372
- signSupport: { legacy: true, eip1559: true }
373
- },
374
- // Scroll Testnet
375
- 534351: {
376
- chainId: 534351,
377
- network: "scroll_testnet",
378
- name: "Scroll Testnet",
379
- type: "EVM" /* EVM */,
380
- isTestnet: true,
381
- explorer: "https://sepolia.scrollscan.com",
382
- website: "https://scroll.io",
383
- nativeCurrency: {
384
- name: "Ether",
385
- symbol: "ETH",
386
- decimals: 18
387
- },
388
- apiSupport: { tokens: true, nft: true, transactions: true },
389
- signSupport: { legacy: true, eip1559: true }
390
- },
391
- // Silicon Mainnet
392
- 2355: {
393
- chainId: 2355,
394
- network: "silicon",
395
- name: "Silicon",
396
- type: "EVM" /* EVM */,
397
- isTestnet: false,
398
- explorer: "https://scope.silicon.network",
399
- website: "https://silicon.network",
400
- nativeCurrency: {
401
- name: "Ether",
402
- symbol: "ETH",
403
- decimals: 18
404
- },
405
- apiSupport: { tokens: true, nft: true, transactions: true },
406
- signSupport: { legacy: true, eip1559: true }
407
- },
408
- // Silicon Sepolia
409
- 1722641160: {
410
- chainId: 1722641160,
411
- network: "silicon_sepolia",
412
- name: "Silicon Sepolia",
413
- type: "EVM" /* EVM */,
414
- isTestnet: true,
415
- explorer: "https://scope-sepolia.silicon.network",
416
- website: "https://silicon.network",
417
- nativeCurrency: {
418
- name: "Ether",
419
- symbol: "ETH",
420
- decimals: 18
421
- },
422
- apiSupport: { tokens: true, nft: true, transactions: true },
423
- signSupport: { legacy: true, eip1559: true }
424
- },
425
- // Six Protocol
426
- 98: {
427
- chainId: 98,
428
- network: "six_evm",
429
- name: "Six Protocol",
430
- type: "EVM" /* EVM */,
431
- isTestnet: false,
432
- explorer: "https://v2.sixscan.io",
433
- website: "https://www.six.network",
434
- nativeCurrency: {
435
- name: "SIX",
436
- symbol: "SIX",
437
- decimals: 18
438
- },
439
- apiSupport: { tokens: true, nft: false, transactions: true },
440
- signSupport: { legacy: true, eip1559: false }
441
- },
442
- // Six Protocol Testnet
443
- 150: {
444
- chainId: 150,
445
- network: "six_evm_testnet",
446
- name: "Six Protocol Testnet",
447
- type: "EVM" /* EVM */,
448
- isTestnet: true,
449
- explorer: "https://v2.fivenet.sixscan.io",
450
- website: "https://www.six.network",
451
- nativeCurrency: {
452
- name: "SIX",
453
- symbol: "SIX",
454
- decimals: 18
455
- },
456
- apiSupport: { tokens: true, nft: false, transactions: true },
457
- signSupport: { legacy: true, eip1559: false }
458
- },
459
- // Wemix Mainnet
460
- 1111: {
461
- chainId: 1111,
462
- network: "wemix",
463
- name: "Wemix3.0 Mainnet",
464
- type: "EVM" /* EVM */,
465
- isTestnet: false,
466
- explorer: "https://explorer.wemix.com",
467
- website: "https://wemix.com",
468
- nativeCurrency: {
469
- name: "WEMIX",
470
- symbol: "WEMIX",
471
- decimals: 18
472
- },
473
- apiSupport: { tokens: true, nft: true, transactions: true },
474
- signSupport: { legacy: true, eip1559: true }
475
- },
476
- // Wemix Testnet
477
- 1112: {
478
- chainId: 1112,
479
- network: "wemix_testnet",
480
- name: "Wemix3.0 Testnet",
481
- type: "EVM" /* EVM */,
482
- isTestnet: true,
483
- explorer: "https://explorer.test.wemix.com",
484
- website: "https://wemix.com",
485
- nativeCurrency: {
486
- name: "WEMIX",
487
- symbol: "WEMIX",
488
- decimals: 18
489
- },
490
- apiSupport: { tokens: true, nft: true, transactions: true },
491
- signSupport: { legacy: true, eip1559: true }
492
- },
493
- // Taiko Mainnet
494
- 167e3: {
495
- chainId: 167e3,
496
- network: "taiko",
497
- name: "Taiko Mainnet",
498
- type: "EVM" /* EVM */,
499
- isTestnet: false,
500
- explorer: "https://taikoscan.io",
501
- website: "https://taiko.xyz",
502
- nativeCurrency: {
503
- name: "Ether",
504
- symbol: "ETH",
505
- decimals: 18
506
- },
507
- apiSupport: { tokens: true, nft: true, transactions: true },
508
- signSupport: { legacy: true, eip1559: true }
509
- },
510
- // Taiko Hekla Testnet
511
- 167009: {
512
- chainId: 167009,
513
- network: "taiko_hekla",
514
- name: "Taiko Hekla Testnet",
515
- type: "EVM" /* EVM */,
516
- isTestnet: true,
517
- explorer: "https://hekla.taikoscan.io",
518
- website: "https://taiko.xyz",
519
- nativeCurrency: {
520
- name: "Ether",
521
- symbol: "ETH",
522
- decimals: 18
523
- },
524
- apiSupport: { tokens: true, nft: true, transactions: true },
525
- signSupport: { legacy: true, eip1559: true }
526
- },
527
- // Base Mainnet
528
- 8453: {
529
- chainId: 8453,
530
- network: "base",
531
- name: "Base",
532
- type: "EVM" /* EVM */,
533
- isTestnet: false,
534
- explorer: "https://basescan.org",
535
- website: "https://base.org",
536
- nativeCurrency: {
537
- name: "Ether",
538
- symbol: "ETH",
539
- decimals: 18
540
- },
541
- apiSupport: { tokens: true, nft: true, transactions: true },
542
- signSupport: { legacy: true, eip1559: true }
543
- },
544
- // Base Sepolia Testnet
545
- 84532: {
546
- chainId: 84532,
547
- network: "base_sepolia",
548
- name: "Base Sepolia",
549
- type: "EVM" /* EVM */,
550
- isTestnet: true,
551
- explorer: "https://sepolia.basescan.org",
552
- website: "https://base.org",
553
- nativeCurrency: {
554
- name: "Ether",
555
- symbol: "ETH",
556
- decimals: 18
557
- },
558
- apiSupport: { tokens: true, nft: true, transactions: true },
559
- signSupport: { legacy: true, eip1559: true }
560
- },
561
- // ChainBounty Mainnet
562
- 51828: {
563
- chainId: 51828,
564
- network: "chainbounty",
565
- name: "ChainBounty Mainnet",
566
- type: "EVM" /* EVM */,
567
- isTestnet: false,
568
- explorer: "https://scan.chainbounty.io",
569
- website: "https://chainbounty.io",
570
- nativeCurrency: {
571
- name: "ChainBounty",
572
- symbol: "CBY",
573
- decimals: 18
574
- },
575
- apiSupport: { tokens: true, nft: true, transactions: true },
576
- signSupport: { legacy: true, eip1559: true }
577
- },
578
- // ChainBounty Testnet
579
- 56580: {
580
- chainId: 56580,
581
- network: "chainbounty_testnet",
582
- name: "ChainBounty Testnet",
583
- type: "EVM" /* EVM */,
584
- isTestnet: true,
585
- explorer: "https://test.scan.chainbounty.io",
586
- website: "https://chainbounty.io",
587
- nativeCurrency: {
588
- name: "ChainBounty",
589
- symbol: "CBY",
590
- decimals: 18
591
- },
592
- apiSupport: { tokens: true, nft: true, transactions: true },
593
- signSupport: { legacy: true, eip1559: true }
594
- },
595
- // Aptos Mainnet (Non-EVM)
596
- aptos: {
597
- chainId: null,
598
- network: "aptos",
599
- name: "Aptos",
600
- type: "Non-EVM" /* NON_EVM */,
601
- isTestnet: false,
602
- explorer: "https://explorer.aptoslabs.com/?network=mainnet",
603
- website: "https://aptos.dev",
604
- nativeCurrency: {
605
- name: "Aptos",
606
- symbol: "APT",
607
- decimals: 8
608
- },
609
- apiSupport: { tokens: true, nft: true, transactions: true },
610
- signSupport: { legacy: true, eip1559: false }
611
- },
612
- // Aptos Testnet (Non-EVM)
613
- aptos_testnet: {
614
- chainId: null,
615
- network: "aptos_testnet",
616
- name: "Aptos Testnet",
617
- type: "Non-EVM" /* NON_EVM */,
618
- isTestnet: true,
619
- explorer: "https://explorer.aptoslabs.com/?network=testnet",
620
- website: "https://aptos.dev",
621
- nativeCurrency: {
622
- name: "Aptos",
623
- symbol: "APT",
624
- decimals: 8
625
- },
626
- apiSupport: { tokens: true, nft: true, transactions: true },
627
- signSupport: { legacy: true, eip1559: false }
628
- },
629
- // Bitcoin Mainnet
630
- bitcoin: {
631
- chainId: null,
632
- network: "bitcoin",
633
- name: "Bitcoin Mainnet",
634
- type: "Bitcoin" /* BITCOIN */,
635
- isTestnet: false,
636
- explorer: "https://blockstream.info",
637
- website: "https://bitcoin.org",
638
- nativeCurrency: {
639
- name: "Bitcoin",
640
- symbol: "BTC",
641
- decimals: 8
642
- },
643
- apiSupport: { tokens: true, nft: false, transactions: true },
644
- signSupport: { legacy: true, eip1559: false }
645
- },
646
- // Bitcoin Testnet
647
- bitcoin_testnet: {
648
- chainId: null,
649
- network: "bitcoin_testnet",
650
- name: "Bitcoin Testnet",
651
- type: "Bitcoin" /* BITCOIN */,
652
- isTestnet: true,
653
- explorer: "https://blockstream.info/testnet",
654
- website: "https://bitcoin.org",
655
- nativeCurrency: {
656
- name: "Bitcoin",
657
- symbol: "BTC",
658
- decimals: 8
659
- },
660
- apiSupport: { tokens: true, nft: false, transactions: true },
661
- signSupport: { legacy: true, eip1559: false }
662
- },
663
- // Tron Mainnet
664
- tron: {
665
- chainId: null,
666
- network: "tron",
667
- name: "Tron Mainnet",
668
- type: "TRX" /* TRON */,
669
- isTestnet: false,
670
- explorer: "https://tronscan.org",
671
- website: "https://tron.network",
672
- nativeCurrency: {
673
- name: "Tronix",
674
- symbol: "TRX",
675
- decimals: 6
676
- },
677
- apiSupport: { tokens: true, nft: true, transactions: true },
678
- signSupport: { legacy: true, eip1559: true }
679
- },
680
- // Tron Nile Testnet
681
- tron_nile: {
682
- chainId: null,
683
- network: "tron_nile",
684
- name: "Tron Nile Testnet",
685
- type: "TRX" /* TRON */,
686
- isTestnet: true,
687
- explorer: "https://nile.tronscan.org",
688
- website: "https://tron.network",
689
- nativeCurrency: {
690
- name: "Tronix",
691
- symbol: "TRX",
692
- decimals: 6
693
- },
694
- apiSupport: { tokens: true, nft: true, transactions: true },
695
- signSupport: { legacy: true, eip1559: true }
696
- },
697
- // ICP Mainnet
698
- icp: {
699
- chainId: null,
700
- network: "icp",
701
- name: "Internet Computer",
702
- type: "ICP" /* ICP */,
703
- isTestnet: false,
704
- explorer: "https://dashboard.internetcomputer.org",
705
- website: "https://internetcomputer.org",
706
- nativeCurrency: {
707
- name: "ICP",
708
- symbol: "ICP",
709
- decimals: 8
710
- },
711
- apiSupport: { tokens: true, nft: true, transactions: true },
712
- signSupport: { legacy: true, eip1559: true }
713
- }
714
- };
715
- var NETWORK_BY_PARAM = Object.values(
716
- NETWORK_CONFIGS
717
- ).reduce(
718
- (acc, config) => {
719
- acc[config.network] = config;
720
- return acc;
721
- },
722
- {}
723
- );
724
- function getNetworkByChainId(chainId) {
725
- return NETWORK_CONFIGS[chainId];
726
- }
727
- function getNetworkByParam(network) {
728
- return NETWORK_BY_PARAM[network];
729
- }
730
- function chainIdToNetwork(chainId) {
731
- return NETWORK_CONFIGS[chainId]?.network;
732
- }
733
- function getNetworkName(chainId, fallback = "ethereum") {
734
- return NETWORK_CONFIGS[chainId]?.network ?? fallback;
735
- }
736
- var CHAIN_ID_TO_KEY = {
737
- // Mainnet
738
- 1: "ethereum",
739
- 42161: "arbitrum",
740
- 8217: "kaia",
741
- 56: "bsc",
742
- 8453: "base",
743
- 137: "polygon",
744
- // Testnet
745
- 11155111: "sepolia",
746
- 421614: "arbitrumSepolia",
747
- 1001: "kaiaKairos",
748
- 97: "bscTestnet",
749
- 84532: "baseSepolia",
750
- 80002: "polygonAmoy",
751
- 998: "hyperevmTestnet"
752
- };
753
- function getChainKey(chainId) {
754
- const key = CHAIN_ID_TO_KEY[chainId];
755
- if (!key) {
756
- throw new Error(`Unsupported chainId for tx endpoint: ${chainId}`);
757
- }
758
- return key;
759
- }
760
- function networkNameToChainKey(network) {
761
- const chainId = NETWORK_BY_PARAM[network]?.chainId;
762
- if (chainId == null)
763
- return network;
764
- return CHAIN_ID_TO_KEY[chainId] ?? network;
765
- }
766
- function networkToChainId(network) {
767
- return NETWORK_BY_PARAM[network]?.chainId;
768
- }
769
- function getExplorerTxUrl(chainIdOrNetwork, txHash) {
770
- const config = typeof chainIdOrNetwork === "number" ? getNetworkByChainId(chainIdOrNetwork) : getNetworkByParam(chainIdOrNetwork);
771
- if (!config) {
772
- throw new Error(`Unknown network: ${chainIdOrNetwork}`);
773
- }
774
- return `${config.explorer}/tx/${txHash}`;
775
- }
776
- function getExplorerAddressUrl(chainIdOrNetwork, address) {
777
- const config = typeof chainIdOrNetwork === "number" ? getNetworkByChainId(chainIdOrNetwork) : getNetworkByParam(chainIdOrNetwork);
778
- if (!config) {
779
- throw new Error(`Unknown network: ${chainIdOrNetwork}`);
780
- }
781
- return `${config.explorer}/address/${address}`;
782
- }
783
- function isEvmNetwork(chainIdOrNetwork) {
784
- const config = typeof chainIdOrNetwork === "number" ? getNetworkByChainId(chainIdOrNetwork) : getNetworkByParam(chainIdOrNetwork);
785
- return config?.type === "EVM" /* EVM */;
786
- }
787
- function isTestnet(chainIdOrNetwork) {
788
- const config = typeof chainIdOrNetwork === "number" ? getNetworkByChainId(chainIdOrNetwork) : getNetworkByParam(chainIdOrNetwork);
789
- return config?.isTestnet ?? false;
790
- }
791
- function getSupportedChainIds(includeTestnets = true) {
792
- return Object.values(NETWORK_CONFIGS).filter(
793
- (config) => config.chainId !== null && (includeTestnets || !config.isTestnet)
794
- ).map((config) => config.chainId);
795
- }
796
- function getSupportedNetworks(includeTestnets = true) {
797
- return Object.values(NETWORK_CONFIGS).filter((config) => includeTestnets || !config.isTestnet).map((config) => config.network);
798
- }
799
-
800
- // src/wallets/walletConnectors/abcWallet/types.ts
801
- var AbcStorageKey = /* @__PURE__ */ ((AbcStorageKey2) => {
802
- AbcStorageKey2["USER"] = "user";
803
- AbcStorageKey2["WALLET"] = "wallet";
804
- AbcStorageKey2["SOLANA_WALLET"] = "solana_wallet";
805
- AbcStorageKey2["BITCOIN_WALLET"] = "bitcoin_wallet";
806
- AbcStorageKey2["TRON_WALLET"] = "tron_wallet";
807
- AbcStorageKey2["ACCESS_TOKEN"] = "access_token";
808
- AbcStorageKey2["REFRESH_TOKEN"] = "refresh_token";
809
- AbcStorageKey2["EXPIRES_AT"] = "expires_at";
810
- AbcStorageKey2["AUTH_STATE"] = "auth_state";
811
- return AbcStorageKey2;
812
- })(AbcStorageKey || {});
813
- var AbcErrorCode = /* @__PURE__ */ ((AbcErrorCode3) => {
814
- AbcErrorCode3["INVALID_CREDENTIALS"] = "INVALID_CREDENTIALS";
815
- AbcErrorCode3["TOKEN_EXPIRED"] = "TOKEN_EXPIRED";
816
- AbcErrorCode3["WALLET_NOT_FOUND"] = "WALLET_NOT_FOUND";
817
- AbcErrorCode3["INVALID_PIN"] = "INVALID_PIN";
818
- AbcErrorCode3["NETWORK_ERROR"] = "NETWORK_ERROR";
819
- AbcErrorCode3["SIGNATURE_FAILED"] = "SIGNATURE_FAILED";
820
- AbcErrorCode3["USER_CANCELLED"] = "USER_CANCELLED";
821
- AbcErrorCode3["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
822
- return AbcErrorCode3;
823
- })(AbcErrorCode || {});
824
- var AbcError = class extends Error {
825
- constructor(code, message, details, statusCode) {
826
- super(message);
827
- this.name = "AbcError";
828
- this.code = code;
829
- this.details = details;
830
- this.statusCode = statusCode;
831
- }
832
- };
833
- var TalkenApiError = class extends Error {
834
- constructor(code, message, statusCode, details) {
835
- super(message);
836
- this.name = "TalkenApiError";
837
- this.code = code;
838
- this.statusCode = statusCode;
839
- this.details = details;
840
- }
841
- };
842
-
843
- // src/wallets/walletConnectors/abcWallet/utils.ts
844
- async function hashPin(pin) {
845
- if (typeof window === "undefined" || !window.crypto?.subtle) {
846
- return btoa(pin);
847
- }
848
- const encoder = new TextEncoder();
849
- const data = encoder.encode(pin);
850
- const hashBuffer = await window.crypto.subtle.digest("SHA-256", data);
851
- const hashArray = Array.from(new Uint8Array(hashBuffer));
852
- const hashHex = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
853
- return hashHex;
854
- }
855
- function validatePin(pin) {
856
- if (!pin || typeof pin !== "string") {
857
- return false;
858
- }
859
- const pinLength = pin.length;
860
- if (pinLength < PIN_CONFIG.MIN_LENGTH || pinLength > PIN_CONFIG.MAX_LENGTH) {
861
- return false;
862
- }
863
- return /^\d+$/.test(pin);
864
- }
865
- function validateEmail(email) {
866
- if (!email || typeof email !== "string") {
867
- return false;
868
- }
869
- const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
870
- return emailRegex.test(email);
871
- }
872
- function getStorageKey(key) {
873
- return `${STORAGE_PREFIX}${key}`;
874
- }
875
- function saveToStorage(key, value) {
876
- if (typeof window === "undefined")
877
- return;
878
- try {
879
- const storageKey = getStorageKey(key);
880
- const serialized = JSON.stringify(value);
881
- localStorage.setItem(storageKey, serialized);
882
- } catch (error) {
883
- console.error("Failed to save to storage:", error);
884
- }
885
- }
886
- function loadFromStorage(key) {
887
- if (typeof window === "undefined")
888
- return null;
889
- try {
890
- const storageKey = getStorageKey(key);
891
- const serialized = localStorage.getItem(storageKey);
892
- if (!serialized)
893
- return null;
894
- try {
895
- return JSON.parse(serialized);
896
- } catch {
897
- return serialized;
898
- }
899
- } catch (error) {
900
- console.error("Failed to load from storage:", error);
901
- return null;
902
- }
903
- }
904
- function removeFromStorage(key) {
905
- if (typeof window === "undefined")
906
- return;
907
- try {
908
- const storageKey = getStorageKey(key);
909
- localStorage.removeItem(storageKey);
910
- } catch (error) {
911
- console.error("Failed to remove from storage:", error);
912
- }
913
- }
914
- function clearStorage() {
915
- if (typeof window === "undefined")
916
- return;
917
- const keysToRemove = [];
918
- for (let i = 0; i < localStorage.length; i++) {
919
- const key = localStorage.key(i);
920
- if (key?.startsWith(STORAGE_PREFIX)) {
921
- keysToRemove.push(key);
922
- }
923
- }
924
- for (const key of keysToRemove) {
925
- localStorage.removeItem(key);
926
- }
927
- }
928
- function isTokenExpired(expiresAt) {
929
- if (!expiresAt)
930
- return true;
931
- return Date.now() >= expiresAt - TOKEN_EXPIRY.REFRESH_BUFFER;
932
- }
933
- function calculateExpiryTimestamp(expiresIn) {
934
- return Date.now() + expiresIn * 1e3;
935
- }
936
- function saveAuthState(state) {
937
- saveToStorage("auth_state" /* AUTH_STATE */, state);
938
- if (state.user) {
939
- saveToStorage("user" /* USER */, state.user);
940
- }
941
- if (state.wallet) {
942
- saveToStorage("wallet" /* WALLET */, state.wallet);
943
- }
944
- if (state.solanaWallet) {
945
- saveToStorage("solana_wallet" /* SOLANA_WALLET */, state.solanaWallet);
946
- }
947
- if (state.bitcoinWallet) {
948
- saveToStorage("bitcoin_wallet" /* BITCOIN_WALLET */, state.bitcoinWallet);
949
- }
950
- if (state.tronWallet) {
951
- saveToStorage("tron_wallet" /* TRON_WALLET */, state.tronWallet);
952
- }
953
- if (state.accessToken) {
954
- saveToStorage("access_token" /* ACCESS_TOKEN */, state.accessToken);
955
- }
956
- if (state.refreshToken) {
957
- saveToStorage("refresh_token" /* REFRESH_TOKEN */, state.refreshToken);
958
- }
959
- if (state.expiresAt) {
960
- saveToStorage("expires_at" /* EXPIRES_AT */, state.expiresAt);
961
- }
962
- }
963
- function hydrateAuthStateFromIndividualStorage(state) {
964
- const user = loadFromStorage("user" /* USER */);
965
- const wallet = loadFromStorage("wallet" /* WALLET */);
966
- const solanaWallet = loadFromStorage("solana_wallet" /* SOLANA_WALLET */);
967
- const bitcoinWallet = loadFromStorage("bitcoin_wallet" /* BITCOIN_WALLET */);
968
- const tronWallet = loadFromStorage("tron_wallet" /* TRON_WALLET */);
969
- const accessToken = loadFromStorage("access_token" /* ACCESS_TOKEN */);
970
- const refreshToken = loadFromStorage("refresh_token" /* REFRESH_TOKEN */);
971
- const expiresAt = loadFromStorage("expires_at" /* EXPIRES_AT */);
972
- const nextState = {
973
- ...state,
974
- user: state.user || user || null,
975
- wallet: state.wallet || wallet || null,
976
- solanaWallet: state.solanaWallet || solanaWallet || null,
977
- bitcoinWallet: state.bitcoinWallet || bitcoinWallet || null,
978
- tronWallet: state.tronWallet || tronWallet || null,
979
- accessToken: state.accessToken || accessToken || null,
980
- refreshToken: state.refreshToken || refreshToken || null,
981
- expiresAt: state.expiresAt || expiresAt || null
982
- };
983
- const wasHydrated = nextState.user !== state.user || nextState.wallet !== state.wallet || nextState.solanaWallet !== state.solanaWallet || nextState.bitcoinWallet !== state.bitcoinWallet || nextState.tronWallet !== state.tronWallet || nextState.accessToken !== state.accessToken || nextState.refreshToken !== state.refreshToken || nextState.expiresAt !== state.expiresAt;
984
- if (wasHydrated) {
985
- saveToStorage("auth_state" /* AUTH_STATE */, nextState);
986
- }
987
- return nextState;
988
- }
989
- function loadAuthState() {
990
- const state = loadFromStorage("auth_state" /* AUTH_STATE */);
991
- if (state) {
992
- if (state.accessToken && isTokenExpired(state.expiresAt)) {
993
- clearStorage();
994
- return null;
995
- }
996
- return hydrateAuthStateFromIndividualStorage(state);
997
- }
998
- const user = loadFromStorage("user" /* USER */);
999
- const wallet = loadFromStorage("wallet" /* WALLET */);
1000
- const solanaWallet = loadFromStorage("solana_wallet" /* SOLANA_WALLET */);
1001
- const accessToken = loadFromStorage("access_token" /* ACCESS_TOKEN */);
1002
- const refreshToken = loadFromStorage("refresh_token" /* REFRESH_TOKEN */);
1003
- const expiresAt = loadFromStorage("expires_at" /* EXPIRES_AT */);
1004
- if (!user || !accessToken) {
1005
- return null;
1006
- }
1007
- const bitcoinWallet = loadFromStorage("bitcoin_wallet" /* BITCOIN_WALLET */);
1008
- const tronWallet = loadFromStorage("tron_wallet" /* TRON_WALLET */);
1009
- return {
1010
- isAuthenticated: true,
1011
- user,
1012
- wallet,
1013
- solanaWallet,
1014
- bitcoinWallet,
1015
- tronWallet,
1016
- accessToken,
1017
- refreshToken,
1018
- expiresAt
1019
- };
1020
- }
1021
- function clearAuthState() {
1022
- clearStorage();
1023
- }
1024
- function createAbcError(code, message, details, statusCode) {
1025
- return new AbcError(code, message, details, statusCode);
1026
- }
1027
- function hexToNumber(hex) {
1028
- return Number.parseInt(hex, 16);
1029
- }
1030
- function numberToHex(num) {
1031
- return `0x${num.toString(16)}`;
1032
- }
1033
-
1034
- // src/wallets/walletConnectors/abcWallet/abcProvider.ts
1035
- var EventEmitter = class {
1036
- constructor() {
1037
- this.events = /* @__PURE__ */ new Map();
1038
- }
1039
- on(event, listener) {
1040
- if (!this.events.has(event)) {
1041
- this.events.set(event, []);
1042
- }
1043
- this.events.get(event).push(listener);
1044
- return this;
1045
- }
1046
- off(event, listener) {
1047
- const listeners = this.events.get(event);
1048
- if (listeners) {
1049
- const index = listeners.indexOf(listener);
1050
- if (index !== -1) {
1051
- listeners.splice(index, 1);
1052
- }
1053
- }
1054
- return this;
1055
- }
1056
- removeListener(event, listener) {
1057
- return this.off(event, listener);
1058
- }
1059
- emit(event, ...args) {
1060
- const listeners = this.events.get(event);
1061
- if (listeners) {
1062
- for (const listener of listeners) {
1063
- listener(...args);
1064
- }
1065
- return true;
1066
- }
1067
- return false;
1068
- }
1069
- removeAllListeners(event) {
1070
- if (event) {
1071
- this.events.delete(event);
1072
- } else {
1073
- this.events.clear();
1074
- }
1075
- return this;
1076
- }
1077
- };
1078
- var ProviderRpcError = class extends Error {
1079
- constructor(code, message, data) {
1080
- super(message);
1081
- this.code = code;
1082
- this.data = data;
1083
- this.name = "ProviderRpcError";
1084
- }
1085
- };
1086
- var ErrorCode = {
1087
- USER_REJECTED: 4001,
1088
- UNAUTHORIZED: 4100,
1089
- UNSUPPORTED_METHOD: 4200,
1090
- DISCONNECTED: 4900,
1091
- CHAIN_DISCONNECTED: 4901,
1092
- INVALID_PARAMS: -32602,
1093
- INTERNAL_ERROR: -32603
1094
- };
1095
- var AbcEvmProvider = class extends EventEmitter {
1096
- constructor(talkenApi) {
1097
- super();
1098
- this.wallet = null;
1099
- this.chainId = 1;
1100
- // Default to Ethereum mainnet
1101
- this.connected = false;
1102
- this.talkenApi = talkenApi;
1103
- }
1104
- getRecoveryEmail() {
1105
- const walletEmail = this.wallet?.email?.trim();
1106
- if (walletEmail) {
1107
- return walletEmail;
1108
- }
1109
- return getCredentialManager().getEmail() || void 0;
1110
- }
1111
- /**
1112
- * Set wallet information
1113
- */
1114
- setWallet(wallet) {
1115
- const previousAddress = this.wallet?.address;
1116
- const previousChainId = this.chainId;
1117
- this.wallet = wallet;
1118
- this.chainId = wallet.chainId;
1119
- this.connected = true;
1120
- if (previousAddress !== wallet.address) {
1121
- this.emit("accountsChanged", [wallet.address]);
1122
- }
1123
- if (previousChainId !== wallet.chainId) {
1124
- this.emit("chainChanged", numberToHex(wallet.chainId));
1125
- }
1126
- this.emit("connect", { chainId: numberToHex(wallet.chainId) });
1127
- }
1128
- /**
1129
- * Clear wallet (disconnect)
1130
- */
1131
- clearWallet() {
1132
- this.wallet = null;
1133
- this.connected = false;
1134
- this.emit("disconnect", {
1135
- code: ErrorCode.DISCONNECTED,
1136
- message: "User disconnected"
1137
- });
1138
- this.emit("accountsChanged", []);
1139
- }
1140
- /**
1141
- * Set request interceptor for sign confirmation
1142
- * The interceptor is called before signing operations to show confirmation UI
1143
- */
1144
- setRequestInterceptor(interceptor) {
1145
- this.requestInterceptor = interceptor;
1146
- }
1147
- /**
1148
- * Set TalkenApiClient for backend-proxied transaction flow
1149
- * When set, transaction methods will use a single API call instead of multi-step WaaS
1150
- */
1151
- setTalkenApi(talkenApi) {
1152
- this.talkenApi = talkenApi;
1153
- }
1154
- getTalkenApiClientOrThrow() {
1155
- const api = this.talkenApi || getTalkenApiClient();
1156
- if (!api) {
1157
- throw new ProviderRpcError(
1158
- ErrorCode.INTERNAL_ERROR,
1159
- "TalkenApiClient not initialized"
1160
- );
1161
- }
1162
- return api;
1163
- }
1164
- /**
1165
- * Check if an error is a "Missing required wallet fields" 502 from the server.
1166
- * When the server's in-memory signing credential cache is cold, it needs
1167
- * a wallet.generate() call (idempotent create/recover) to repopulate.
1168
- */
1169
- isSigningCredentialError(error) {
1170
- return error instanceof TalkenApiError && error.statusCode === 502 && error.message.includes("Missing required wallet fields");
1171
- }
1172
- /**
1173
- * Refresh server-side signing credentials by calling wallet.generate().
1174
- * This is idempotent — it recovers existing wallets, not creates new ones.
1175
- */
1176
- async refreshSigningCredentials() {
1177
- const pinHash = getCredentialManager().getPinHash();
1178
- const email = this.getRecoveryEmail();
1179
- if (!pinHash || !email) {
1180
- console.warn(
1181
- "[AbcProvider] Cannot refresh signing credentials \u2014 PIN hash or email missing"
1182
- );
1183
- return;
1184
- }
1185
- const api = this.getTalkenApiClientOrThrow();
1186
- console.log("[AbcProvider] Refreshing server-side signing credentials...");
1187
- await api.wallet.generate(pinHash, email);
1188
- console.log("[AbcProvider] Signing credentials refreshed");
1189
- }
1190
- /**
1191
- * Wrap a signing operation with auto-retry on "Missing required wallet fields" error.
1192
- * On first failure, refreshes the server's signing credential cache and retries once.
1193
- */
1194
- async withSigningCredentialRetry(operation) {
1195
- try {
1196
- return await operation();
1197
- } catch (error) {
1198
- if (this.isSigningCredentialError(error)) {
1199
- console.log(
1200
- "[AbcProvider] Signing credentials missing on server \u2014 attempting refresh and retry"
1201
- );
1202
- await this.refreshSigningCredentials();
1203
- return await operation();
1204
- }
1205
- throw error;
1206
- }
1207
- }
1208
- /**
1209
- * Call request interceptor if configured
1210
- * Called by specific signing/transaction methods that need user confirmation
1211
- * @returns Resolved transaction with user modifications if changed in confirmation modal
1212
- */
1213
- async callInterceptor(method, params) {
1214
- if (!this.requestInterceptor) {
1215
- return void 0;
1216
- }
1217
- const request = {
1218
- method,
1219
- params,
1220
- chainId: this.chainId,
1221
- address: this.wallet?.address || ""
1222
- };
1223
- return this.requestInterceptor(request);
1224
- }
1225
- /**
1226
- * EIP-1193 request method
1227
- */
1228
- async request(args) {
1229
- const { method, params } = args;
1230
- switch (method) {
1231
- case "eth_requestAccounts":
1232
- return this.eth_requestAccounts();
1233
- case "eth_accounts":
1234
- return this.eth_accounts();
1235
- case "eth_chainId":
1236
- return this.eth_chainId();
1237
- case "eth_sendTransaction":
1238
- case "wallet_sendTransaction":
1239
- return this.eth_sendTransaction(params);
1240
- case "eth_signTransaction":
1241
- return this.eth_signTransaction(params);
1242
- case "personal_sign":
1243
- return this.personal_sign(params);
1244
- case "eth_sign":
1245
- return this.eth_sign(params);
1246
- case "eth_signTypedData":
1247
- case "eth_signTypedData_v3":
1248
- case "eth_signTypedData_v4":
1249
- return this.eth_signTypedData(params);
1250
- case "wallet_getCapabilities":
1251
- return this.wallet_getCapabilities();
1252
- case "eth_signAuthorization":
1253
- return this.eth_signAuthorization(params);
1254
- case "wallet_switchEthereumChain":
1255
- return this.wallet_switchEthereumChain(params);
1256
- case "wallet_addEthereumChain":
1257
- return this.wallet_addEthereumChain(params);
1258
- case "eth_estimateGas":
1259
- return this.eth_estimateGas(params);
1260
- case "eth_getTransactionCount":
1261
- return this.eth_getTransactionCount(
1262
- Array.isArray(params) ? params : []
1263
- );
1264
- case "eth_blockNumber":
1265
- case "eth_call":
1266
- case "eth_gasPrice":
1267
- case "eth_getBalance":
1268
- case "eth_getBlockByHash":
1269
- case "eth_getBlockByNumber":
1270
- case "eth_getCode":
1271
- case "eth_getStorageAt":
1272
- case "eth_getTransactionByHash":
1273
- case "eth_getTransactionReceipt":
1274
- throw new ProviderRpcError(
1275
- ErrorCode.UNSUPPORTED_METHOD,
1276
- `Method ${method} should be handled by RPC provider`
1277
- );
1278
- default:
1279
- throw new ProviderRpcError(
1280
- ErrorCode.UNSUPPORTED_METHOD,
1281
- `Method ${method} not supported`
1282
- );
1283
- }
1284
- }
1285
- /**
1286
- * Request accounts (EIP-1193)
1287
- */
1288
- async eth_requestAccounts() {
1289
- if (!this.wallet) {
1290
- throw new ProviderRpcError(
1291
- ErrorCode.UNAUTHORIZED,
1292
- "Wallet not connected"
1293
- );
1294
- }
1295
- return [this.wallet.address];
1296
- }
1297
- /**
1298
- * Get accounts
1299
- */
1300
- async eth_accounts() {
1301
- if (!this.wallet) {
1302
- return [];
1303
- }
1304
- return [this.wallet.address];
1305
- }
1306
- /**
1307
- * Get chain ID
1308
- */
1309
- async eth_chainId() {
1310
- return numberToHex(this.chainId);
1311
- }
1312
- /**
1313
- * Send transaction
1314
- */
1315
- async eth_sendTransaction(params) {
1316
- if (!this.wallet) {
1317
- throw new ProviderRpcError(
1318
- ErrorCode.UNAUTHORIZED,
1319
- "Wallet not connected"
1320
- );
1321
- }
1322
- if (!Array.isArray(params) || params.length === 0) {
1323
- throw new ProviderRpcError(
1324
- ErrorCode.INVALID_PARAMS,
1325
- "Invalid transaction params"
1326
- );
1327
- }
1328
- const resolved = await this.callInterceptor("eth_sendTransaction", params);
1329
- const tx = params[0];
1330
- console.log("[AbcProvider] eth_sendTransaction incoming gas params:", {
1331
- gas: tx.gas ?? tx.gasLimit,
1332
- gasPrice: tx.gasPrice,
1333
- maxFeePerGas: tx.maxFeePerGas,
1334
- maxPriorityFeePerGas: tx.maxPriorityFeePerGas
1335
- });
1336
- if (resolved) {
1337
- if (resolved.data) {
1338
- tx.data = resolved.data;
1339
- }
1340
- if (resolved.gasFee?.maxFeePerGas) {
1341
- try {
1342
- const maxFeeWei = parseGwei(resolved.gasFee.maxFeePerGas);
1343
- tx.maxFeePerGas = `0x${maxFeeWei.toString(16)}`;
1344
- } catch (error) {
1345
- console.error(
1346
- "[AbcProvider] \u274C Failed to parse maxFeePerGas:",
1347
- error
1348
- );
1349
- }
1350
- }
1351
- if (resolved.gasFee?.maxPriorityFeePerGas) {
1352
- try {
1353
- const priorityFeeWei = parseGwei(
1354
- resolved.gasFee.maxPriorityFeePerGas
1355
- );
1356
- tx.maxPriorityFeePerGas = `0x${priorityFeeWei.toString(16)}`;
1357
- } catch (error) {
1358
- console.error(
1359
- "[AbcProvider] \u274C Failed to parse maxPriorityFeePerGas:",
1360
- error
1361
- );
1362
- }
1363
- }
1364
- }
1365
- console.log("[AbcProvider] eth_sendTransaction final gas params:", {
1366
- gas: tx.gas ?? tx.gasLimit,
1367
- gasPrice: tx.gasPrice,
1368
- maxFeePerGas: tx.maxFeePerGas,
1369
- maxPriorityFeePerGas: tx.maxPriorityFeePerGas
1370
- });
1371
- const isContractDeployment = !tx.to || tx.to === "0x" || tx.to === "0x0" || tx.to === "0x0000000000000000000000000000000000000000";
1372
- if (isContractDeployment) {
1373
- tx.to = "0x";
1374
- } else if (!tx.to) {
1375
- throw new ProviderRpcError(
1376
- ErrorCode.INVALID_PARAMS,
1377
- 'Transaction must have "to" field'
1378
- );
1379
- }
1380
- const pinHash = getCredentialManager().getPinHash();
1381
- if (!pinHash) {
1382
- throw new ProviderRpcError(
1383
- ErrorCode.INTERNAL_ERROR,
1384
- "PIN hash not found. Please login again."
1385
- );
1386
- }
1387
- const hexValue = tx.value || "0x0";
1388
- const amountWei = BigInt(hexValue).toString();
1389
- const email = this.getRecoveryEmail();
1390
- const api = this.getTalkenApiClientOrThrow();
1391
- const result = await this.withSigningCredentialRetry(
1392
- () => api.evm.sendTransaction({
1393
- chainKey: getChainKey(this.chainId),
1394
- to: tx.to,
1395
- amountWei,
1396
- pin: pinHash,
1397
- data: tx.data || "0x",
1398
- gasLimit: tx.gas || tx.gasLimit,
1399
- maxFeePerGas: tx.maxFeePerGas,
1400
- maxPriorityFeePerGas: tx.maxPriorityFeePerGas,
1401
- ...email && { email }
1402
- })
1403
- );
1404
- return result.txHash;
1405
- }
1406
- /**
1407
- * Sign transaction (without sending)
1408
- */
1409
- async eth_signTransaction(params) {
1410
- if (!this.wallet) {
1411
- throw new ProviderRpcError(
1412
- ErrorCode.UNAUTHORIZED,
1413
- "Wallet not connected"
1414
- );
1415
- }
1416
- if (!Array.isArray(params) || params.length === 0) {
1417
- throw new ProviderRpcError(
1418
- ErrorCode.INVALID_PARAMS,
1419
- "Invalid transaction params"
1420
- );
1421
- }
1422
- const resolved = await this.callInterceptor("eth_signTransaction", params);
1423
- const tx = params[0];
1424
- if (resolved) {
1425
- if (resolved.data) {
1426
- tx.data = resolved.data;
1427
- }
1428
- if (resolved.gasFee?.maxFeePerGas) {
1429
- try {
1430
- const maxFeeWei = parseGwei(resolved.gasFee.maxFeePerGas);
1431
- tx.maxFeePerGas = `0x${maxFeeWei.toString(16)}`;
1432
- } catch (error) {
1433
- console.error(
1434
- "[AbcProvider] \u274C Failed to parse maxFeePerGas:",
1435
- error
1436
- );
1437
- }
1438
- }
1439
- if (resolved.gasFee?.maxPriorityFeePerGas) {
1440
- try {
1441
- const priorityFeeWei = parseGwei(
1442
- resolved.gasFee.maxPriorityFeePerGas
1443
- );
1444
- tx.maxPriorityFeePerGas = `0x${priorityFeeWei.toString(16)}`;
1445
- } catch (error) {
1446
- console.error(
1447
- "[AbcProvider] \u274C Failed to parse maxPriorityFeePerGas:",
1448
- error
1449
- );
1450
- }
1451
- }
1452
- }
1453
- const api = this.getTalkenApiClientOrThrow();
1454
- const pinHash = getCredentialManager().getPinHash() || void 0;
1455
- const email = this.getRecoveryEmail();
1456
- const result = await this.withSigningCredentialRetry(
1457
- () => api.evm.signTransaction({
1458
- network: getNetworkName(this.chainId),
1459
- to: tx.to,
1460
- value: tx.value || "0x0",
1461
- data: tx.data || "0x",
1462
- gasLimit: tx.gas || tx.gasLimit,
1463
- maxFeePerGas: tx.maxFeePerGas,
1464
- maxPriorityFeePerGas: tx.maxPriorityFeePerGas,
1465
- nonce: tx.nonce ? String(Number.parseInt(tx.nonce, 16)) : void 0,
1466
- ...pinHash && { pin: pinHash },
1467
- ...email && { email }
1468
- })
1469
- );
1470
- return result.signature;
1471
- }
1472
- /**
1473
- * Personal sign (EIP-191)
1474
- */
1475
- async personal_sign(params) {
1476
- if (!this.wallet) {
1477
- console.error("[AbcProvider] \u274C Wallet not connected");
1478
- throw new ProviderRpcError(
1479
- ErrorCode.UNAUTHORIZED,
1480
- "Wallet not connected"
1481
- );
1482
- }
1483
- if (!Array.isArray(params) || params.length < 2) {
1484
- console.error("[AbcProvider] \u274C Invalid params:", params);
1485
- throw new ProviderRpcError(
1486
- ErrorCode.INVALID_PARAMS,
1487
- "Invalid personal_sign params"
1488
- );
1489
- }
1490
- await this.callInterceptor("personal_sign", params);
1491
- const [message, address] = params;
1492
- if (address.toLowerCase() !== this.wallet.address.toLowerCase()) {
1493
- console.error("[AbcProvider] \u274C Address mismatch");
1494
- throw new ProviderRpcError(
1495
- ErrorCode.INVALID_PARAMS,
1496
- "Address does not match connected wallet"
1497
- );
1498
- }
1499
- const api = this.getTalkenApiClientOrThrow();
1500
- const network = getNetworkName(this.chainId);
1501
- const pinHash = getCredentialManager().getPinHash() || void 0;
1502
- const email = this.getRecoveryEmail();
1503
- const result = await this.withSigningCredentialRetry(
1504
- () => api.evm.signPersonal({
1505
- network,
1506
- message,
1507
- address,
1508
- pin: pinHash,
1509
- ...email && { email }
1510
- })
1511
- );
1512
- return result.signature;
1513
- }
1514
- /**
1515
- * Eth sign
1516
- */
1517
- async eth_sign(params) {
1518
- if (!Array.isArray(params) || params.length < 2) {
1519
- throw new ProviderRpcError(
1520
- ErrorCode.INVALID_PARAMS,
1521
- "Invalid eth_sign params"
1522
- );
1523
- }
1524
- const [address, message] = params;
1525
- return this.personal_sign([message, address]);
1526
- }
1527
- /**
1528
- * Sign typed data (EIP-712)
1529
- */
1530
- async eth_signTypedData(params) {
1531
- if (!this.wallet) {
1532
- throw new ProviderRpcError(
1533
- ErrorCode.UNAUTHORIZED,
1534
- "Wallet not connected"
1535
- );
1536
- }
1537
- if (!Array.isArray(params) || params.length < 2) {
1538
- throw new ProviderRpcError(
1539
- ErrorCode.INVALID_PARAMS,
1540
- "Invalid signTypedData params"
1541
- );
1542
- }
1543
- await this.callInterceptor("eth_signTypedData_v4", params);
1544
- const [address, typedData] = params;
1545
- if (address.toLowerCase() !== this.wallet.address.toLowerCase()) {
1546
- throw new ProviderRpcError(
1547
- ErrorCode.INVALID_PARAMS,
1548
- "Address does not match connected wallet"
1549
- );
1550
- }
1551
- const api = this.getTalkenApiClientOrThrow();
1552
- const network = getNetworkName(this.chainId);
1553
- const pinHash = getCredentialManager().getPinHash() || void 0;
1554
- const email = this.getRecoveryEmail();
1555
- const result = await this.withSigningCredentialRetry(
1556
- () => api.evm.signTypedData({
1557
- network,
1558
- typedData: typeof typedData === "string" ? typedData : JSON.stringify(typedData),
1559
- pin: pinHash,
1560
- ...email && { email }
1561
- })
1562
- );
1563
- return result.signature;
1564
- }
1565
- /**
1566
- * Return normalized wallet capabilities for ABC embedded wallets.
1567
- * ABC supports EIP-7702 authorization signing via talken-api.
1568
- */
1569
- async wallet_getCapabilities() {
1570
- return {
1571
- supportsTypedDataV4: true,
1572
- supports7702Authorization: true,
1573
- supports5792Batch: false,
1574
- supportsPaymasterService: false,
1575
- supportsPermit2RelayHints: true,
1576
- walletType: "abc-embedded"
1577
- };
1578
- }
1579
- /**
1580
- * Sign EIP-7702 authorization via Talken API.
1581
- */
1582
- async eth_signAuthorization(params) {
1583
- if (!this.wallet) {
1584
- throw new ProviderRpcError(
1585
- ErrorCode.UNAUTHORIZED,
1586
- "Wallet not connected"
1587
- );
1588
- }
1589
- if (!Array.isArray(params) || params.length < 2) {
1590
- throw new ProviderRpcError(
1591
- ErrorCode.INVALID_PARAMS,
1592
- "Invalid signAuthorization params"
1593
- );
1594
- }
1595
- const [address, authorization] = params;
1596
- if (address.toLowerCase() !== this.wallet.address.toLowerCase()) {
1597
- throw new ProviderRpcError(
1598
- ErrorCode.INVALID_PARAMS,
1599
- "Address does not match connected wallet"
1600
- );
1601
- }
1602
- if (!authorization?.address || authorization.chainId == null || authorization.nonce == null) {
1603
- throw new ProviderRpcError(
1604
- ErrorCode.INVALID_PARAMS,
1605
- "Authorization payload is incomplete"
1606
- );
1607
- }
1608
- await this.callInterceptor("eth_signAuthorization", params);
1609
- const api = this.getTalkenApiClientOrThrow();
1610
- const network = getNetworkName(this.chainId);
1611
- const pinHash = getCredentialManager().getPinHash() || void 0;
1612
- const email = this.getRecoveryEmail();
1613
- const chainIdValue = typeof authorization.chainId === "string" ? Number(BigInt(authorization.chainId)) : Number(authorization.chainId);
1614
- const nonceValue = typeof authorization.nonce === "string" ? BigInt(authorization.nonce).toString() : String(authorization.nonce);
1615
- const authAddress = authorization.address;
1616
- const result = await this.withSigningCredentialRetry(
1617
- () => api.evm.signAuthorization({
1618
- network,
1619
- authorization: {
1620
- chainId: chainIdValue,
1621
- address: authAddress,
1622
- nonce: nonceValue
1623
- },
1624
- pin: pinHash,
1625
- ...email && { email }
1626
- })
1627
- );
1628
- return result.authorization;
1629
- }
1630
- /**
1631
- * Switch Ethereum chain
1632
- */
1633
- async wallet_switchEthereumChain(params) {
1634
- if (!Array.isArray(params) || params.length === 0) {
1635
- throw new ProviderRpcError(
1636
- ErrorCode.INVALID_PARAMS,
1637
- "Invalid switchEthereumChain params"
1638
- );
1639
- }
1640
- const { chainId } = params[0];
1641
- const newChainId = hexToNumber(chainId);
1642
- if (this.chainId === newChainId) {
1643
- return null;
1644
- }
1645
- const _previousChainId = this.chainId;
1646
- this.chainId = newChainId;
1647
- if (this.wallet) {
1648
- this.wallet.chainId = newChainId;
1649
- }
1650
- this.emit("chainChanged", numberToHex(newChainId));
1651
- return null;
1652
- }
1653
- /**
1654
- * Add Ethereum chain
1655
- */
1656
- async wallet_addEthereumChain(params) {
1657
- return this.wallet_switchEthereumChain(params);
1658
- }
1659
- /**
1660
- * Get transaction count (nonce) using ABC WaaS API
1661
- */
1662
- async eth_getTransactionCount(params) {
1663
- const address = params[0]?.toLowerCase();
1664
- if (!address) {
1665
- throw new ProviderRpcError(
1666
- ErrorCode.INVALID_PARAMS,
1667
- "Missing address parameter"
1668
- );
1669
- }
1670
- const currentChainId = this.chainId;
1671
- try {
1672
- const api = this.getTalkenApiClientOrThrow();
1673
- const response = await api.evm.getNonce(
1674
- getNetworkName(currentChainId),
1675
- address
1676
- );
1677
- const nonce = response.result !== void 0 ? typeof response.result === "number" ? `0x${response.result.toString(16)}` : response.result : void 0;
1678
- if (!nonce) {
1679
- throw new Error("No result in nonce response");
1680
- }
1681
- return nonce;
1682
- } catch (error) {
1683
- console.error(
1684
- "[AbcEvmProvider] \u274C Failed to get transaction count from ABC WaaS:",
1685
- error
1686
- );
1687
- throw new ProviderRpcError(
1688
- ErrorCode.INTERNAL_ERROR,
1689
- `Failed to get transaction count: ${error instanceof Error ? error.message : String(error)}`
1690
- );
1691
- }
1692
- }
1693
- /**
1694
- * Estimate gas for transaction
1695
- * Uses ABC WaaS gas estimation API with fallback
1696
- */
1697
- async eth_estimateGas(params) {
1698
- if (!Array.isArray(params) || params.length === 0) {
1699
- throw new ProviderRpcError(
1700
- ErrorCode.INVALID_PARAMS,
1701
- "Invalid estimateGas params"
1702
- );
1703
- }
1704
- const tx = params[0];
1705
- if (!tx.to) {
1706
- throw new ProviderRpcError(
1707
- ErrorCode.INVALID_PARAMS,
1708
- 'Transaction must have "to" field'
1709
- );
1710
- }
1711
- try {
1712
- const response = await this.getTalkenApiClientOrThrow().evm.estimateGas({
1713
- network: getNetworkName(this.chainId),
1714
- from: tx.from || this.wallet?.address || "",
1715
- to: tx.to,
1716
- value: tx.value,
1717
- data: tx.data
1718
- });
1719
- if (!response.result) {
1720
- throw new Error("No result in gas estimate response");
1721
- }
1722
- return response.result;
1723
- } catch (error) {
1724
- console.warn(
1725
- "[AbcEvmProvider] Gas estimation failed, using fallback:",
1726
- error
1727
- );
1728
- if (tx.data && tx.data !== "0x") {
1729
- return "0x493e0";
1730
- }
1731
- return "0x5208";
1732
- }
1733
- }
1734
- /**
1735
- * Check if connected
1736
- */
1737
- isConnected() {
1738
- return this.connected;
1739
- }
1740
- /**
1741
- * Get current wallet
1742
- */
1743
- getWallet() {
1744
- return this.wallet;
1745
- }
1746
- /**
1747
- * Get current chain ID
1748
- */
1749
- getChainId() {
1750
- return this.chainId;
1751
- }
1752
- };
1753
- function createAbcEvmProvider(talkenApi) {
1754
- return new AbcEvmProvider(talkenApi);
1755
- }
1756
- var createAbcProvider = createAbcEvmProvider;
1757
-
1758
- // src/wallets/walletConnectors/abcWallet/api/TalkenApiClient.ts
1759
- var STORAGE_KEY_PREFIX = "talken_api_";
1760
- function loadToken(key) {
1761
- if (typeof window === "undefined")
1762
- return null;
1763
- try {
1764
- return localStorage.getItem(`${STORAGE_KEY_PREFIX}${key}`);
1765
- } catch {
1766
- return null;
1767
- }
1768
- }
1769
- function saveToken(key, value) {
1770
- if (typeof window === "undefined")
1771
- return;
1772
- try {
1773
- localStorage.setItem(`${STORAGE_KEY_PREFIX}${key}`, value);
1774
- } catch {
1775
- }
1776
- }
1777
- function removeToken(key) {
1778
- if (typeof window === "undefined")
1779
- return;
1780
- try {
1781
- localStorage.removeItem(`${STORAGE_KEY_PREFIX}${key}`);
1782
- } catch {
1783
- }
1784
- }
1785
- function normalizeAuthResponse(raw) {
1786
- const d = raw.data || raw;
1787
- const loginData = d.login || d;
1788
- return {
1789
- accessToken: loginData.access_token || loginData.accessToken || "",
1790
- refreshToken: loginData.refresh_token || loginData.refreshToken || "",
1791
- expiresIn: loginData.expires_in || loginData.expire_in || loginData.expiresIn || 3600,
1792
- uid: d.uid || loginData.uid || "",
1793
- email: d.email || loginData.email || "",
1794
- isNewUser: d.isNewUser
1795
- };
1796
- }
1797
- var TalkenAuthModule = class {
1798
- constructor(client) {
1799
- this.client = client;
1800
- }
1801
- /**
1802
- * Login with email and password
1803
- * POST /wallet/auth { action: 'login', method: 'password', email, password }
1804
- */
1805
- async loginWithPassword(email, password) {
1806
- const raw = await this.client.post(
1807
- TALKEN_API_ENDPOINTS.AUTH,
1808
- { action: "login", method: "password", email, password },
1809
- { skipAuth: true }
1810
- );
1811
- const res = normalizeAuthResponse(raw);
1812
- this.client.handleAuthResponse(res);
1813
- return res;
1814
- }
1815
- /**
1816
- * Send OTP code to email
1817
- * POST /wallet/auth { action: 'otp.send', email }
1818
- */
1819
- async sendOtp(email) {
1820
- const raw = await this.client.post(
1821
- TALKEN_API_ENDPOINTS.AUTH,
1822
- { action: "otp.send", email },
1823
- { skipAuth: true }
1824
- );
1825
- return raw.data || raw;
1826
- }
1827
- /**
1828
- * Verify OTP code
1829
- * POST /wallet/auth { action: 'otp.verify', email, otpCode }
1830
- */
1831
- async verifyOtp(email, otpCode) {
1832
- const raw = await this.client.post(
1833
- TALKEN_API_ENDPOINTS.AUTH,
1834
- { action: "otp.verify", email, otpCode },
1835
- { skipAuth: true }
1836
- );
1837
- return raw.data || raw;
1838
- }
1839
- /**
1840
- * Check if email is already registered
1841
- * POST /wallet/auth { action: 'email.check', email }
1842
- * Returns code 606 if email exists
1843
- */
1844
- async checkEmail(email) {
1845
- const raw = await this.client.post(
1846
- TALKEN_API_ENDPOINTS.AUTH,
1847
- { action: "email.check", email },
1848
- { skipAuth: true }
1849
- );
1850
- const d = raw.data || raw;
1851
- return {
1852
- code: d.code,
1853
- message: d.message,
1854
- exists: d.code === 606
1855
- };
1856
- }
1857
- /**
1858
- * Register a new user (creates account + auto-login)
1859
- * POST /wallet/auth { action: 'register', email, otpCode, password, name? }
1860
- */
1861
- async register(params) {
1862
- const raw = await this.client.post(
1863
- TALKEN_API_ENDPOINTS.AUTH,
1864
- { action: "register", ...params },
1865
- { skipAuth: true }
1866
- );
1867
- const res = normalizeAuthResponse(raw);
1868
- this.client.handleAuthResponse(res);
1869
- return res;
1870
- }
1871
- /**
1872
- * Reset password for existing user
1873
- * POST /wallet/auth { action: 'password.reset', email, newPassword, emailCode }
1874
- */
1875
- async resetPassword(email, newPassword, emailCode) {
1876
- const raw = await this.client.post(
1877
- TALKEN_API_ENDPOINTS.AUTH,
1878
- { action: "password.reset", email, newPassword, emailCode },
1879
- { skipAuth: true }
1880
- );
1881
- return raw.data || raw;
1882
- }
1883
- /**
1884
- * Login with social provider (Google, Apple, Kakao, etc.)
1885
- * POST /wallet/auth { action: 'login', method: 'sns', token, service, audience? }
1886
- */
1887
- async loginWithSns(params) {
1888
- const raw = await this.client.post(
1889
- TALKEN_API_ENDPOINTS.AUTH,
1890
- {
1891
- action: "login",
1892
- method: "sns",
1893
- token: params.token,
1894
- service: params.service,
1895
- ...params.audience && { audience: params.audience }
1896
- },
1897
- { skipAuth: true }
1898
- );
1899
- const res = normalizeAuthResponse(raw);
1900
- this.client.handleAuthResponse(res);
1901
- return res;
1902
- }
1903
- /**
1904
- * Refresh access token
1905
- * POST /wallet/auth { action: 'token.refresh', refreshToken }
1906
- */
1907
- async refresh() {
1908
- const refreshToken = this.client.getRefreshToken();
1909
- if (!refreshToken) {
1910
- throw new TalkenApiError(
1911
- "TOKEN_EXPIRED",
1912
- "No refresh token available",
1913
- 401
1914
- );
1915
- }
1916
- const raw = await this.client.post(
1917
- TALKEN_API_ENDPOINTS.AUTH,
1918
- { action: "token.refresh", refreshToken },
1919
- { skipAuth: true }
1920
- );
1921
- const res = normalizeAuthResponse(raw);
1922
- this.client.handleAuthResponse(res);
1923
- return res;
1924
- }
1925
- /**
1926
- * Logout (clear local session only — no server endpoint)
1927
- */
1928
- logout() {
1929
- this.client.clearSession();
1930
- }
1931
- };
1932
- var TalkenWalletModule = class {
1933
- constructor(client) {
1934
- this.client = client;
1935
- }
1936
- /**
1937
- * Generate/recover MPC wallets (create = idempotent generate/recover)
1938
- * POST /wallet/mpc { action: 'create', email?, pin }
1939
- *
1940
- * @param pin - SHA-256 hashed PIN
1941
- * @param email - User email (optional; server resolves from bearer token if omitted)
1942
- */
1943
- async generate(pin, email) {
1944
- return this.client.post(TALKEN_API_ENDPOINTS.WALLET_MPC, {
1945
- action: "create",
1946
- ...email && { email },
1947
- pin
1948
- });
1949
- }
1950
- /**
1951
- * Recover is the same as generate (create is idempotent)
1952
- */
1953
- async recover(pin, email) {
1954
- return this.generate(pin, email);
1955
- }
1956
- /**
1957
- * Get wallet info
1958
- * POST /wallet/mpc { action: 'info' }
1959
- */
1960
- async getInfo() {
1961
- return this.client.post(TALKEN_API_ENDPOINTS.WALLET_MPC, {
1962
- action: "info"
1963
- });
1964
- }
1965
- /**
1966
- * Get addresses for all chains
1967
- * POST /wallet/address { chain: 'all' }
1968
- */
1969
- async getAddresses() {
1970
- return this.client.post(TALKEN_API_ENDPOINTS.WALLET_ADDRESS, {
1971
- chain: "all"
1972
- });
1973
- }
1974
- /**
1975
- * Get addresses for a specific chain
1976
- * POST /wallet/address { chain, publicKey?, pin? }
1977
- */
1978
- async getAddressForChain(chain, publicKey, pin) {
1979
- return this.client.post(TALKEN_API_ENDPOINTS.WALLET_ADDRESS, {
1980
- chain,
1981
- ...publicKey && { publicKey },
1982
- ...pin && { pin }
1983
- });
1984
- }
1985
- };
1986
- var TalkenEvmModule = class {
1987
- constructor(client) {
1988
- this.client = client;
1989
- }
1990
- /**
1991
- * Sign EVM transaction (sign only, no broadcast)
1992
- * POST /wallet/sign/evm { network, to, from?, value?, data?, ... }
1993
- * Server handles SecureChannel internally
1994
- */
1995
- async signTransaction(params) {
1996
- return this.client.post(
1997
- TALKEN_API_ENDPOINTS.SIGN_EVM,
1998
- params
1999
- );
2000
- }
2001
- /**
2002
- * Sign EIP-712 typed data
2003
- * POST /wallet/sign/evm/typed { network, typedData }
2004
- */
2005
- async signTypedData(params) {
2006
- return this.client.post(
2007
- TALKEN_API_ENDPOINTS.SIGN_TYPED,
2008
- params
2009
- );
2010
- }
2011
- /**
2012
- * Sign personal message (EIP-191)
2013
- * POST /wallet/sign/evm/personal { network, message, address? }
2014
- */
2015
- async signPersonal(params) {
2016
- const res = await this.client.post(
2017
- TALKEN_API_ENDPOINTS.SIGN_PERSONAL,
2018
- params
2019
- );
2020
- return {
2021
- signature: res?.signature ?? res?.serializedTx ?? "",
2022
- txHash: res?.txHash ?? res?.rawTx
2023
- };
2024
- }
2025
- /**
2026
- * Sign EIP-7702 authorization payload
2027
- * POST /wallet/sign/authorization { network, authorization, pin? }
2028
- */
2029
- async signAuthorization(params) {
2030
- return this.client.post(
2031
- TALKEN_API_ENDPOINTS.SIGN_AUTHORIZATION,
2032
- params
2033
- );
2034
- }
2035
- /**
2036
- * Broadcast signed transaction
2037
- * POST /wallet/tx/raw { network, signedSerializeTx }
2038
- */
2039
- async sendRawTransaction(params) {
2040
- return this.client.post(
2041
- TALKEN_API_ENDPOINTS.TX_RAW,
2042
- params
2043
- );
2044
- }
2045
- /**
2046
- * Integrated EVM transfer (sign + broadcast)
2047
- * POST /wallet/tx/evm { chainKey, to, amountWei, pin, ... }
2048
- */
2049
- async sendTransaction(params) {
2050
- return this.client.post(
2051
- TALKEN_API_ENDPOINTS.TX_EVM,
2052
- params
2053
- );
2054
- }
2055
- /**
2056
- * Get gas price
2057
- * GET /wallet/gas/price?network=
2058
- */
2059
- async getGasPrice(network) {
2060
- return this.client.get(
2061
- `${TALKEN_API_ENDPOINTS.GAS_PRICE}?network=${encodeURIComponent(network)}`
2062
- );
2063
- }
2064
- /**
2065
- * Get suggested gas fees (EIP-1559)
2066
- * GET /wallet/gas/suggested?network=
2067
- */
2068
- async getGasSuggested(network) {
2069
- return this.client.get(
2070
- `${TALKEN_API_ENDPOINTS.GAS_SUGGESTED}?network=${encodeURIComponent(network)}`
2071
- );
2072
- }
2073
- /**
2074
- * Estimate gas
2075
- * POST /wallet/gas/estimate { network, from, to, value?, data? }
2076
- */
2077
- async estimateGas(params) {
2078
- return this.client.post(
2079
- TALKEN_API_ENDPOINTS.GAS_ESTIMATE,
2080
- params
2081
- );
2082
- }
2083
- /**
2084
- * Get nonce for address
2085
- * GET /wallet/nonce?network=&address=
2086
- */
2087
- async getNonce(network, address) {
2088
- const qs = new URLSearchParams({ network, address }).toString();
2089
- return this.client.get(`${TALKEN_API_ENDPOINTS.NONCE}?${qs}`);
2090
- }
2091
- };
2092
- var TalkenSolanaModule = class {
2093
- constructor(client) {
2094
- this.client = client;
2095
- }
2096
- /**
2097
- * Transfer SOL or SPL token (integrated sign + broadcast)
2098
- * POST /wallet/tx/sol
2099
- * - kind='native': { toAddress, amountLamports, pin }
2100
- * - kind='spl': { toAddress, mintAddress, amount, decimals, network, pin }
2101
- */
2102
- async transfer(params) {
2103
- return this.client.post(
2104
- TALKEN_API_ENDPOINTS.TX_SOL,
2105
- params
2106
- );
2107
- }
2108
- /**
2109
- * Sign Solana transaction or message (sign-only, no broadcast)
2110
- * POST /wallet/sign/sol
2111
- *
2112
- * Two modes:
2113
- * - PIN mode: { message, pin } — server resolves signing material
2114
- * - Share mode: { message, keyId, encryptedShare } — no PIN required (for signMessage)
2115
- *
2116
- * @returns Ed25519 signature (hex) and optionally public key
2117
- */
2118
- async sign(params) {
2119
- return this.client.post(
2120
- TALKEN_API_ENDPOINTS.SIGN_SVM,
2121
- params
2122
- );
2123
- }
2124
- };
2125
- var TalkenBitcoinModule = class {
2126
- constructor(client) {
2127
- this.client = client;
2128
- }
2129
- /**
2130
- * BTC fee rate lookup
2131
- * GET /wallet/btc?mode=fee&network=&blocks=
2132
- */
2133
- async getFeeRate(network, blocks) {
2134
- const qs = new URLSearchParams({
2135
- mode: "fee",
2136
- network,
2137
- ...typeof blocks === "number" ? { blocks: String(blocks) } : {}
2138
- }).toString();
2139
- return this.client.get(
2140
- `${TALKEN_API_ENDPOINTS.WALLET_BTC}?${qs}`
2141
- );
2142
- }
2143
- /**
2144
- * BTC tx status by hash
2145
- * GET /wallet/btc?mode=txHash&network=&txHash=
2146
- */
2147
- async getTxByHash(txHash, network) {
2148
- const qs = new URLSearchParams({
2149
- mode: "txHash",
2150
- network,
2151
- txHash
2152
- }).toString();
2153
- return this.client.get(
2154
- `${TALKEN_API_ENDPOINTS.WALLET_BTC}?${qs}`
2155
- );
2156
- }
2157
- /**
2158
- * BTC UTXO list
2159
- * GET /wallet/btc?mode=utxos&network=&address=
2160
- */
2161
- async getUtxos(network, address) {
2162
- const qs = new URLSearchParams({
2163
- mode: "utxos",
2164
- network,
2165
- ...address ? { address } : {}
2166
- }).toString();
2167
- return this.client.get(
2168
- `${TALKEN_API_ENDPOINTS.WALLET_BTC}?${qs}`
2169
- );
2170
- }
2171
- /**
2172
- * BTC address validation
2173
- * GET /wallet/btc?mode=validateAddress&network=&address=
2174
- */
2175
- async validateAddress(address, network) {
2176
- const qs = new URLSearchParams({
2177
- mode: "validateAddress",
2178
- network,
2179
- address
2180
- }).toString();
2181
- return this.client.get(
2182
- `${TALKEN_API_ENDPOINTS.WALLET_BTC}?${qs}`
2183
- );
2184
- }
2185
- /**
2186
- * Send BTC (integrated sign + broadcast, action=transfer)
2187
- * POST /wallet/tx/btc
2188
- */
2189
- async sendTransaction(params) {
2190
- const payload = { action: "transfer", ...params };
2191
- return this.client.post(
2192
- TALKEN_API_ENDPOINTS.TX_BTC,
2193
- payload
2194
- );
2195
- }
2196
- /**
2197
- * Execute BTC action endpoint (transfer|generate|signHash|finalize)
2198
- * POST /wallet/tx/btc
2199
- */
2200
- async execute(params) {
2201
- return this.client.post(
2202
- TALKEN_API_ENDPOINTS.TX_BTC,
2203
- params
2204
- );
2205
- }
2206
- /**
2207
- * Sign raw hash via secp256k1 MPC (universal: EVM/BTC/TVM)
2208
- * POST /wallet/sign/hash { hash, pin, network? }
2209
- */
2210
- async signHash(params) {
2211
- return this.client.post(
2212
- TALKEN_API_ENDPOINTS.SIGN_HASH,
2213
- params
2214
- );
2215
- }
2216
- /**
2217
- * Broadcast raw BTC transaction
2218
- * POST /wallet/tx/raw { network, signedSerializeTx }
2219
- */
2220
- async broadcastRawTransaction(params) {
2221
- return this.client.post(TALKEN_API_ENDPOINTS.TX_RAW, {
2222
- network: params.network,
2223
- signedSerializeTx: params.rawTransaction
2224
- });
2225
- }
2226
- };
2227
- var TalkenTronModule = class {
2228
- constructor(client) {
2229
- this.client = client;
2230
- }
2231
- /**
2232
- * Execute TVM(TRON) transfer/call (integrated sign + broadcast)
2233
- * POST /wallet/tx/tvm
2234
- * - kind=native: TRX transfer (amountSun)
2235
- * - kind=trc20: TRC-20 transfer (contractAddress + amount)
2236
- * - kind=contract: arbitrary contract call (contractAddress + data)
2237
- */
2238
- async transferTrx(params) {
2239
- return this.client.post(
2240
- TALKEN_API_ENDPOINTS.TX_TVM,
2241
- params
2242
- );
2243
- }
2244
- };
2245
- var TalkenWalletscanModule = class {
2246
- constructor(client) {
2247
- this.client = client;
2248
- }
2249
- /**
2250
- * Get token metadata by contract address
2251
- * GET /wallet/scan?type=tokens&chainKeys=...&contractAddress=...
2252
- */
2253
- async getToken(params) {
2254
- const qs = new URLSearchParams({
2255
- type: "tokens",
2256
- chainKeys: params.chainKeys,
2257
- contractAddress: params.contractAddress
2258
- }).toString();
2259
- return this.client.get(
2260
- `${TALKEN_API_ENDPOINTS.WALLET_SCAN}?${qs}`
2261
- );
2262
- }
2263
- /**
2264
- * Get native coin balances
2265
- * GET /wallet/scan?type=natives&chainKeys=...&walletAddress=...
2266
- */
2267
- async getNativeTokens(params) {
2268
- const qs = new URLSearchParams({
2269
- type: "natives",
2270
- chainKeys: params.chainKeys,
2271
- walletAddress: params.walletAddress
2272
- }).toString();
2273
- return this.client.get(
2274
- `${TALKEN_API_ENDPOINTS.WALLET_SCAN}?${qs}`
2275
- );
2276
- }
2277
- /**
2278
- * Get NFT metadata
2279
- * GET /wallet/scan?type=nfts&chainKeys=...&walletAddress=...
2280
- */
2281
- async getNfts(params) {
2282
- const qs = new URLSearchParams({
2283
- type: "nfts",
2284
- chainKeys: params.chainKeys,
2285
- walletAddress: params.walletAddress
2286
- }).toString();
2287
- return this.client.get(
2288
- `${TALKEN_API_ENDPOINTS.WALLET_SCAN}?${qs}`
2289
- );
2290
- }
2291
- };
2292
- var TalkenApiClient = class {
2293
- constructor(config) {
2294
- this.accessToken = null;
2295
- this.refreshToken_ = null;
2296
- this.expiresAt = null;
2297
- this.isRefreshing = false;
2298
- this.refreshPromise = null;
2299
- this.config = {
2300
- baseUrl: config?.baseUrl || DEFAULT_TALKEN_API_CONFIG.baseUrl || "",
2301
- timeout: config?.timeout || DEFAULT_TALKEN_API_CONFIG.timeout,
2302
- environment: config?.environment || "development",
2303
- defaultChainId: config?.defaultChainId,
2304
- debug: config?.debug || false
2305
- };
2306
- this.auth = new TalkenAuthModule(this);
2307
- this.wallet = new TalkenWalletModule(this);
2308
- this.evm = new TalkenEvmModule(this);
2309
- this.solana = new TalkenSolanaModule(this);
2310
- this.bitcoin = new TalkenBitcoinModule(this);
2311
- this.tron = new TalkenTronModule(this);
2312
- this.walletscan = new TalkenWalletscanModule(this);
2313
- this.restoreSession();
2314
- }
2315
- // ── Session Management ──────────────────────────────────────────────
2316
- restoreSession() {
2317
- this.accessToken = loadToken("access_token");
2318
- this.refreshToken_ = loadToken("refresh_token");
2319
- const expiresAtStr = loadToken("expires_at");
2320
- this.expiresAt = expiresAtStr ? Number(expiresAtStr) : null;
2321
- }
2322
- /** @internal Called by auth module after successful login/register */
2323
- handleAuthResponse(response) {
2324
- this.accessToken = response.accessToken;
2325
- this.refreshToken_ = response.refreshToken;
2326
- this.expiresAt = Date.now() + response.expiresIn * 1e3;
2327
- saveToken("access_token", response.accessToken);
2328
- saveToken("refresh_token", response.refreshToken);
2329
- saveToken("expires_at", String(this.expiresAt));
2330
- }
2331
- /** @internal Clear all session data */
2332
- clearSession() {
2333
- this.accessToken = null;
2334
- this.refreshToken_ = null;
2335
- this.expiresAt = null;
2336
- removeToken("access_token");
2337
- removeToken("refresh_token");
2338
- removeToken("expires_at");
2339
- }
2340
- /**
2341
- * Check if user is authenticated (has valid access token)
2342
- */
2343
- isAuthenticated() {
2344
- return !!this.accessToken && !this.isTokenExpired();
2345
- }
2346
- /**
2347
- * Check if current access token is expired
2348
- */
2349
- isTokenExpired() {
2350
- if (!this.expiresAt)
2351
- return true;
2352
- return Date.now() >= this.expiresAt - TOKEN_EXPIRY.REFRESH_BUFFER;
2353
- }
2354
- /**
2355
- * Get current access token
2356
- */
2357
- getAccessToken() {
2358
- return this.accessToken;
2359
- }
2360
- /**
2361
- * Get current refresh token
2362
- * @internal Used by auth module for token refresh
2363
- */
2364
- getRefreshToken() {
2365
- return this.refreshToken_;
2366
- }
2367
- /**
2368
- * Get client configuration
2369
- */
2370
- getConfig() {
2371
- return { ...this.config };
2372
- }
2373
- /**
2374
- * Set tokens externally (useful for SSR or state management integration)
2375
- */
2376
- setTokens(accessToken, refreshToken, expiresAt) {
2377
- this.accessToken = accessToken;
2378
- this.refreshToken_ = refreshToken;
2379
- this.expiresAt = expiresAt;
2380
- saveToken("access_token", accessToken);
2381
- saveToken("refresh_token", refreshToken);
2382
- saveToken("expires_at", String(expiresAt));
2383
- }
2384
- // ── HTTP Methods (Internal) ─────────────────────────────────────────
2385
- /** @internal Make a GET request */
2386
- async get(endpoint, options) {
2387
- return this.request(endpoint, { method: "GET", ...options });
2388
- }
2389
- /** @internal Make a POST request */
2390
- async post(endpoint, body, options) {
2391
- return this.request(endpoint, { method: "POST", body, ...options });
2392
- }
2393
- /**
2394
- * Core HTTP request handler with automatic token refresh
2395
- * @internal
2396
- */
2397
- async request(endpoint, options) {
2398
- const { method, body, skipAuth = false } = options;
2399
- if (!skipAuth && this.isTokenExpired() && this.refreshToken_) {
2400
- await this.ensureTokenRefreshed();
2401
- }
2402
- const url = `${this.config.baseUrl}${endpoint}`;
2403
- const headers = {
2404
- "Content-Type": "application/json",
2405
- Accept: "application/json"
2406
- };
2407
- if (!skipAuth && this.accessToken) {
2408
- headers.Authorization = `Bearer ${this.accessToken}`;
2409
- }
2410
- if (this.config.debug) {
2411
- console.log(`[TalkenApiClient] ${method} ${url}`);
2412
- }
2413
- try {
2414
- const controller = new AbortController();
2415
- const timeoutId = setTimeout(
2416
- () => controller.abort(),
2417
- this.config.timeout || 3e4
2418
- );
2419
- const response = await fetch(url, {
2420
- method,
2421
- headers,
2422
- body: body ? JSON.stringify(body) : void 0,
2423
- signal: controller.signal,
2424
- credentials: "include"
2425
- });
2426
- clearTimeout(timeoutId);
2427
- const text = await response.text();
2428
- let data;
2429
- if (text) {
2430
- try {
2431
- data = JSON.parse(text);
2432
- } catch {
2433
- throw new TalkenApiError(
2434
- "PARSE_ERROR",
2435
- "Invalid JSON response from server",
2436
- response.status,
2437
- { text: text.substring(0, 200) }
2438
- );
2439
- }
2440
- } else {
2441
- data = { success: true };
2442
- }
2443
- if (response.status === 401 && !skipAuth && this.refreshToken_) {
2444
- try {
2445
- await this.forceTokenRefresh();
2446
- return this.request(endpoint, { ...options, skipAuth: true });
2447
- } catch {
2448
- this.clearSession();
2449
- throw new TalkenApiError(
2450
- "TOKEN_EXPIRED",
2451
- "Session expired. Please login again.",
2452
- 401
2453
- );
2454
- }
2455
- }
2456
- if (!response.ok) {
2457
- const errCode = data.error?.code || "UNKNOWN_ERROR";
2458
- const errMsg = data.error?.message || `Request failed with status ${response.status}`;
2459
- if (this.config.debug) {
2460
- console.error(`[TalkenApiClient] Error: ${errCode} - ${errMsg}`);
2461
- }
2462
- throw new TalkenApiError(
2463
- errCode,
2464
- errMsg,
2465
- response.status,
2466
- data.error?.details || data.details
2467
- );
2468
- }
2469
- return data.data ?? data;
2470
- } catch (error) {
2471
- if (error instanceof TalkenApiError) {
2472
- throw error;
2473
- }
2474
- if (error instanceof DOMException && error.name === "AbortError") {
2475
- throw new TalkenApiError("TIMEOUT", "Request timed out", 408);
2476
- }
2477
- const errorMessage = error instanceof Error ? error.message : "Network request failed";
2478
- throw new TalkenApiError("NETWORK_ERROR", errorMessage, 0);
2479
- }
2480
- }
2481
- /**
2482
- * Ensure token is refreshed (handles concurrent requests)
2483
- */
2484
- async ensureTokenRefreshed() {
2485
- if (this.isRefreshing && this.refreshPromise) {
2486
- await this.refreshPromise;
2487
- return;
2488
- }
2489
- await this.forceTokenRefresh();
2490
- }
2491
- /**
2492
- * Force a token refresh
2493
- */
2494
- async forceTokenRefresh() {
2495
- if (this.isRefreshing && this.refreshPromise) {
2496
- await this.refreshPromise;
2497
- return;
2498
- }
2499
- this.isRefreshing = true;
2500
- this.refreshPromise = (async () => {
2501
- try {
2502
- await this.auth.refresh();
2503
- } finally {
2504
- this.isRefreshing = false;
2505
- this.refreshPromise = null;
2506
- }
2507
- })();
2508
- await this.refreshPromise;
2509
- }
2510
- };
2511
- function createTalkenApiClient(config) {
2512
- return new TalkenApiClient(config);
2513
- }
2514
-
2515
- // src/wallets/walletConnectors/abcWallet/api/TalkenApiSingleton.ts
2516
- var _instance;
2517
- function setTalkenApiClient(client) {
2518
- _instance = client;
2519
- }
2520
- function getTalkenApiClient2() {
2521
- return _instance;
2522
- }
2523
-
2524
- // src/wallets/walletConnectors/abcWallet/networkConfig.ts
2525
- var SolanaNetwork = /* @__PURE__ */ ((SolanaNetwork2) => {
2526
- SolanaNetwork2["Mainnet"] = "solana";
2527
- SolanaNetwork2["Devnet"] = "solana_devnet";
2528
- SolanaNetwork2["Testnet"] = "solana_testnet";
2529
- return SolanaNetwork2;
2530
- })(SolanaNetwork || {});
2531
- var BitcoinNetwork = /* @__PURE__ */ ((BitcoinNetwork2) => {
2532
- BitcoinNetwork2["Mainnet"] = "bitcoin";
2533
- BitcoinNetwork2["Testnet"] = "bitcoin_testnet";
2534
- return BitcoinNetwork2;
2535
- })(BitcoinNetwork || {});
2536
- var TronNetwork = /* @__PURE__ */ ((TronNetwork2) => {
2537
- TronNetwork2["Mainnet"] = "tron";
2538
- TronNetwork2["Nile"] = "tron_nile";
2539
- return TronNetwork2;
2540
- })(TronNetwork || {});
2541
- var DEFAULT_NETWORK_CONFIG = {
2542
- evm: {
2543
- mainnet: 1,
2544
- // Ethereum Mainnet
2545
- testnet: 11155111
2546
- // Sepolia Testnet
2547
- },
2548
- solana: {
2549
- mainnet: "solana" /* Mainnet */,
2550
- devnet: "solana_devnet" /* Devnet */
2551
- },
2552
- bitcoin: {
2553
- mainnet: "bitcoin" /* Mainnet */,
2554
- testnet: "bitcoin_testnet" /* Testnet */
2555
- },
2556
- tron: {
2557
- mainnet: "tron" /* Mainnet */,
2558
- testnet: "tron_nile" /* Nile */
2559
- }
2560
- };
2561
- var globalDefaultChainId;
2562
- var globalDefaultSolanaNetwork;
2563
- var globalDefaultBitcoinNetwork;
2564
- var globalDefaultTronNetwork;
2565
- function setGlobalDefaultChainId(chainId) {
2566
- globalDefaultChainId = chainId;
2567
- }
2568
- function setGlobalDefaultSolanaNetwork(network) {
2569
- globalDefaultSolanaNetwork = network;
2570
- }
2571
- function setGlobalDefaultBitcoinNetwork(network) {
2572
- globalDefaultBitcoinNetwork = network;
2573
- }
2574
- function getEvmNetwork(customChainId) {
2575
- if (customChainId !== void 0) {
2576
- return customChainId;
2577
- }
2578
- if (globalDefaultChainId !== void 0) {
2579
- return globalDefaultChainId;
2580
- }
2581
- const isProduction = typeof process !== "undefined" && process.env.NEXT_PUBLIC_ENVIRONMENT === "production";
2582
- const fallbackChainId = isProduction ? DEFAULT_NETWORK_CONFIG.evm.mainnet : DEFAULT_NETWORK_CONFIG.evm.testnet;
2583
- return fallbackChainId;
2584
- }
2585
- function getSolanaNetwork() {
2586
- if (globalDefaultSolanaNetwork !== void 0) {
2587
- return globalDefaultSolanaNetwork;
2588
- }
2589
- const isProduction = typeof process !== "undefined" && process.env.NEXT_PUBLIC_ENVIRONMENT === "production";
2590
- return isProduction ? DEFAULT_NETWORK_CONFIG.solana.mainnet : DEFAULT_NETWORK_CONFIG.solana.devnet;
2591
- }
2592
- function getBitcoinNetwork() {
2593
- if (globalDefaultBitcoinNetwork !== void 0) {
2594
- return globalDefaultBitcoinNetwork;
2595
- }
2596
- const isProduction = typeof process !== "undefined" && process.env.NEXT_PUBLIC_ENVIRONMENT === "production";
2597
- return isProduction ? DEFAULT_NETWORK_CONFIG.bitcoin.mainnet : DEFAULT_NETWORK_CONFIG.bitcoin.testnet;
2598
- }
2599
- function getTronNetwork() {
2600
- if (globalDefaultTronNetwork !== void 0) {
2601
- return globalDefaultTronNetwork;
2602
- }
2603
- const isProduction = typeof process !== "undefined" && process.env.NEXT_PUBLIC_ENVIRONMENT === "production";
2604
- return isProduction ? DEFAULT_NETWORK_CONFIG.tron.mainnet : DEFAULT_NETWORK_CONFIG.tron.testnet;
2605
- }
2606
-
2607
- // src/wallets/walletConnectors/abcWallet/resolveTalkenApiUrl.ts
2608
- function resolveTalkenApiUrl(explicitUrl) {
2609
- const talkenApiUrl = explicitUrl || process.env.NEXT_PUBLIC_TALKEN_API_URL;
2610
- if (!talkenApiUrl) {
2611
- throw new Error(
2612
- "Talken API URL is required. Pass talkenApiUrl explicitly or set NEXT_PUBLIC_TALKEN_API_URL."
2613
- );
2614
- }
2615
- return talkenApiUrl;
2616
- }
2617
-
2618
- // src/wallets/walletConnectors/abcWallet/abcConnector.ts
2619
- function abcConnector(options) {
2620
- const { config } = options;
2621
- if (config.defaultChainId) {
2622
- setGlobalDefaultChainId(config.defaultChainId);
2623
- }
2624
- if (config.defaultSolanaNetwork) {
2625
- setGlobalDefaultSolanaNetwork(config.defaultSolanaNetwork);
2626
- }
2627
- if (config.defaultBitcoinNetwork) {
2628
- setGlobalDefaultBitcoinNetwork(config.defaultBitcoinNetwork);
2629
- }
2630
- return createConnector((wagmiConfig) => {
2631
- const talkenApi = getTalkenApiClient3() || createTalkenApiClient({
2632
- baseUrl: resolveTalkenApiUrl(config.talkenApiUrl),
2633
- environment: config.environment,
2634
- debug: config.environment === "development",
2635
- defaultChainId: config.defaultChainId
2636
- });
2637
- setTalkenApiClient(talkenApi);
2638
- const provider = createAbcEvmProvider(talkenApi);
2639
- let accountsChangedHandler;
2640
- let chainChangedHandler;
2641
- let disconnectHandler;
2642
- return {
2643
- id: "abc",
2644
- name: "ABC Wallet",
2645
- type: "abc",
2646
- /**
2647
- * Connect wallet
2648
- */
2649
- async connect() {
2650
- try {
2651
- const authState = loadAuthState();
2652
- if (!authState || !authState.isAuthenticated || !authState.wallet) {
2653
- throw new Error("ABC_LOGIN_REQUIRED");
2654
- }
2655
- provider.setWallet(authState.wallet);
2656
- if (authState.accessToken && authState.refreshToken && authState.expiresAt) {
2657
- talkenApi.setTokens(
2658
- authState.accessToken,
2659
- authState.refreshToken,
2660
- authState.expiresAt
2661
- );
2662
- }
2663
- const accounts = await provider.request({
2664
- method: "eth_requestAccounts"
2665
- });
2666
- let currentChainId = await provider.request({
2667
- method: "eth_chainId"
2668
- });
2669
- const currentChainIdNumber = Number(currentChainId);
2670
- const isChainSupported = wagmiConfig.chains.some(
2671
- (c) => c.id === currentChainIdNumber
2672
- );
2673
- if (!isChainSupported && wagmiConfig.chains.length > 0) {
2674
- const fallbackChainId = wagmiConfig.chains[0].id;
2675
- await provider.request({
2676
- method: "wallet_switchEthereumChain",
2677
- params: [{ chainId: `0x${fallbackChainId.toString(16)}` }]
2678
- });
2679
- currentChainId = `0x${fallbackChainId.toString(16)}`;
2680
- if (authState.wallet) {
2681
- authState.wallet.chainId = fallbackChainId;
2682
- saveAuthState(authState);
2683
- }
2684
- }
2685
- if (accountsChangedHandler) {
2686
- provider.removeListener("accountsChanged", accountsChangedHandler);
2687
- }
2688
- accountsChangedHandler = (accounts2) => {
2689
- wagmiConfig.emitter.emit("change", {
2690
- accounts: accounts2
2691
- });
2692
- };
2693
- provider.on("accountsChanged", accountsChangedHandler);
2694
- if (chainChangedHandler) {
2695
- provider.removeListener("chainChanged", chainChangedHandler);
2696
- }
2697
- chainChangedHandler = (chainId) => {
2698
- wagmiConfig.emitter.emit("change", {
2699
- chainId: Number(chainId)
2700
- });
2701
- };
2702
- provider.on("chainChanged", chainChangedHandler);
2703
- if (disconnectHandler) {
2704
- provider.removeListener("disconnect", disconnectHandler);
2705
- }
2706
- disconnectHandler = () => {
2707
- wagmiConfig.emitter.emit("disconnect");
2708
- this.onDisconnect();
2709
- };
2710
- provider.on("disconnect", disconnectHandler);
2711
- wagmiConfig.emitter.emit("connect", {
2712
- accounts,
2713
- chainId: Number(currentChainId)
2714
- });
2715
- return {
2716
- accounts,
2717
- chainId: Number(currentChainId)
2718
- };
2719
- } catch (error) {
2720
- console.error("\u274C ABC Connector connect() failed:", {
2721
- message: error.message,
2722
- code: error.code,
2723
- error
2724
- });
2725
- if (error.message === "ABC_LOGIN_REQUIRED") {
2726
- throw error;
2727
- }
2728
- throw error;
2729
- }
2730
- },
2731
- /**
2732
- * Disconnect wallet
2733
- */
2734
- async disconnect() {
2735
- if (accountsChangedHandler) {
2736
- provider.removeListener("accountsChanged", accountsChangedHandler);
2737
- accountsChangedHandler = void 0;
2738
- }
2739
- if (chainChangedHandler) {
2740
- provider.removeListener("chainChanged", chainChangedHandler);
2741
- chainChangedHandler = void 0;
2742
- }
2743
- if (disconnectHandler) {
2744
- provider.removeListener("disconnect", disconnectHandler);
2745
- disconnectHandler = void 0;
2746
- }
2747
- provider.clearWallet();
2748
- talkenApi.auth.logout();
2749
- clearAuthState();
2750
- getCredentialManager().clear();
2751
- },
2752
- /**
2753
- * Get accounts
2754
- */
2755
- async getAccounts() {
2756
- const accounts = await provider.request({
2757
- method: "eth_accounts"
2758
- });
2759
- return accounts.map((account) => account);
2760
- },
2761
- /**
2762
- * Get chain ID
2763
- */
2764
- async getChainId() {
2765
- const chainId = await provider.request({
2766
- method: "eth_chainId"
2767
- });
2768
- return Number(chainId);
2769
- },
2770
- /**
2771
- * Get provider
2772
- */
2773
- async getProvider() {
2774
- return provider;
2775
- },
2776
- /**
2777
- * Check if authorized (has valid session)
2778
- * Auto-refreshes access token if expired but refresh token is valid
2779
- */
2780
- async isAuthorized() {
2781
- try {
2782
- const authState = loadAuthState();
2783
- if (!authState || !authState.isAuthenticated) {
2784
- return false;
2785
- }
2786
- if (!authState.wallet) {
2787
- return false;
2788
- }
2789
- if (talkenApi.isAuthenticated()) {
2790
- return true;
2791
- }
2792
- const refreshToken = loadFromStorage(
2793
- "refresh_token" /* REFRESH_TOKEN */
2794
- );
2795
- if (!refreshToken) {
2796
- clearStorage();
2797
- return false;
2798
- }
2799
- try {
2800
- const api = getTalkenApiClient3();
2801
- if (!api) {
2802
- clearStorage();
2803
- return false;
2804
- }
2805
- const res = await api.auth.refresh();
2806
- talkenApi.setTokens(
2807
- res.accessToken,
2808
- res.refreshToken,
2809
- Date.now() + res.expiresIn * 1e3
2810
- );
2811
- const updatedState = loadAuthState();
2812
- return updatedState?.isAuthenticated ?? false;
2813
- } catch (error) {
2814
- console.error("[AbcConnector] Token refresh failed:", error);
2815
- clearStorage();
2816
- return false;
2817
- }
2818
- } catch (error) {
2819
- console.error(
2820
- "[AbcConnector] Unexpected error in isAuthorized:",
2821
- error
2822
- );
2823
- return false;
2824
- }
2825
- },
2826
- /**
2827
- * Switch chain
2828
- */
2829
- async switchChain({ chainId }) {
2830
- await provider.request({
2831
- method: "wallet_switchEthereumChain",
2832
- params: [{ chainId: `0x${chainId.toString(16)}` }]
2833
- });
2834
- const newChainId = await this.getChainId();
2835
- const authState = loadAuthState();
2836
- if (authState?.wallet) {
2837
- authState.wallet.chainId = newChainId;
2838
- saveAuthState(authState);
2839
- }
2840
- return wagmiConfig.chains.find((x) => x.id === chainId) ?? {
2841
- id: chainId,
2842
- name: `Chain ${chainId}`,
2843
- nativeCurrency: {
2844
- name: "Ether",
2845
- decimals: 18,
2846
- symbol: "ETH"
2847
- },
2848
- rpcUrls: {
2849
- default: { http: [""] }
2850
- }
2851
- };
2852
- },
2853
- /**
2854
- * Handle accounts changed
2855
- */
2856
- onAccountsChanged(accounts) {
2857
- if (accounts.length === 0) {
2858
- this.onDisconnect();
2859
- } else {
2860
- wagmiConfig.emitter.emit("change", {
2861
- accounts
2862
- });
2863
- }
2864
- },
2865
- /**
2866
- * Handle chain changed
2867
- */
2868
- onChainChanged(chain) {
2869
- const chainId = Number(chain);
2870
- wagmiConfig.emitter.emit("change", { chainId });
2871
- },
2872
- /**
2873
- * Handle disconnect
2874
- */
2875
- onDisconnect(_error) {
2876
- provider.clearWallet();
2877
- clearAuthState();
2878
- wagmiConfig.emitter.emit("disconnect");
2879
- }
2880
- };
2881
- });
2882
- }
2883
-
2884
- // src/wallets/walletConnectors/abcWallet/abcWallet.ts
2885
- var abcWallet = (specificOptions) => ({ projectId }) => {
2886
- const talkenApiUrl = resolveTalkenApiUrl(specificOptions?.talkenApiUrl);
2887
- const talkenApi = createTalkenApiClient({
2888
- baseUrl: talkenApiUrl,
2889
- debug: specificOptions?.environment === "development"
2890
- });
2891
- setTalkenApiClient2(talkenApi);
2892
- const config = {
2893
- talkenApiUrl,
2894
- apiKey: specificOptions?.apiKey,
2895
- plain: specificOptions?.plain || "",
2896
- // Deprecated - not used (secure.ts uses random generation)
2897
- environment: specificOptions?.environment || "development",
2898
- defaultChainId: specificOptions?.defaultChainId,
2899
- defaultSolanaNetwork: specificOptions?.defaultSolanaNetwork,
2900
- defaultBitcoinNetwork: specificOptions?.defaultBitcoinNetwork,
2901
- projectId
2902
- };
2903
- return {
2904
- id: ABC_WALLET_METADATA.id,
2905
- name: ABC_WALLET_METADATA.name,
2906
- rdns: ABC_WALLET_METADATA.rdns,
2907
- iconUrl: async () => (await import("./abcWallet-AYWSIGAG.js")).default,
2908
- iconBackground: ABC_WALLET_METADATA.iconBackground,
2909
- // Embedded wallet - no installation required
2910
- installed: void 0,
2911
- // No download URLs for embedded wallet
2912
- downloadUrls: void 0,
2913
- // Create connector - wrapper function required by Wallet type
2914
- createConnector: (_walletDetails) => abcConnector({ config }),
2915
- // Embedded wallet always available
2916
- hidden: () => false
2917
- };
2918
- };
2919
-
2920
- // src/wallets/walletConnectors/abcWallet/api/WalletscanApi.ts
2921
- import { getTalkenApiClient as getTalkenApiClient4, networkNameToChainKey as networkNameToChainKey2 } from "@talken/talkenkit";
2922
- var WalletscanApi = class {
2923
- /**
2924
- * Get token metadata via TalkenApiClient walletscan endpoint
2925
- *
2926
- * @param params - Contract address and networks
2927
- * @returns Token metadata or null if not found/failed
2928
- */
2929
- async getContractToken(params) {
2930
- const api = getTalkenApiClient4();
2931
- if (!api)
2932
- throw new Error("TalkenApiClient not initialized");
2933
- try {
2934
- const tokens = await api.walletscan.getToken({
2935
- contractAddress: params.contractAddress,
2936
- chainKeys: networkNameToChainKey2(params.networks)
2937
- });
2938
- return tokens.length > 0 ? tokens[0] : null;
2939
- } catch (error) {
2940
- console.warn(
2941
- "[WalletscanApi] TalkenApi getToken failed:",
2942
- params.contractAddress,
2943
- error
2944
- );
2945
- return null;
2946
- }
2947
- }
2948
- /**
2949
- * Get token metadata with timeout
2950
- *
2951
- * @param params - Contract address and networks
2952
- * @param timeoutMs - Timeout in milliseconds (default: 3000)
2953
- * @returns Token metadata or null if timeout/failed
2954
- */
2955
- async getContractTokenWithTimeout(params, timeoutMs = 3e3) {
2956
- try {
2957
- const result = await Promise.race([
2958
- this.getContractToken(params),
2959
- new Promise(
2960
- (resolve) => setTimeout(() => resolve(null), timeoutMs)
2961
- )
2962
- ]);
2963
- return result;
2964
- } catch (_error) {
2965
- console.warn(
2966
- "[WalletscanApi] Token metadata request timed out:",
2967
- params.contractAddress
2968
- );
2969
- return null;
2970
- }
2971
- }
2972
- /**
2973
- * Get native coin info via TalkenApiClient walletscan endpoint
2974
- *
2975
- * @param params - Wallet address and networks
2976
- * @returns Array of native coins or empty array if failed
2977
- */
2978
- async getNativeToken(params) {
2979
- const api = getTalkenApiClient4();
2980
- if (!api)
2981
- throw new Error("TalkenApiClient not initialized");
2982
- try {
2983
- return await api.walletscan.getNativeTokens({
2984
- walletAddress: params.walletAddress,
2985
- chainKeys: networkNameToChainKey2(params.networks)
2986
- });
2987
- } catch (error) {
2988
- console.warn("[WalletscanApi] TalkenApi getNativeTokens failed:", error);
2989
- return [];
2990
- }
2991
- }
2992
- /**
2993
- * Get native coin info with timeout
2994
- *
2995
- * @param params - Wallet address and networks
2996
- * @param timeoutMs - Timeout in milliseconds (default: 3000)
2997
- * @returns First native coin or null if timeout/failed
2998
- */
2999
- async getNativeTokenWithTimeout(params, timeoutMs = 3e3) {
3000
- try {
3001
- const natives = await Promise.race([
3002
- this.getNativeToken(params),
3003
- new Promise(
3004
- (resolve) => setTimeout(() => resolve([]), timeoutMs)
3005
- )
3006
- ]);
3007
- return natives.length > 0 ? natives[0] : null;
3008
- } catch (_error) {
3009
- console.warn("[WalletscanApi] Native coin request timed out");
3010
- return null;
3011
- }
3012
- }
3013
- /**
3014
- * Get NFT metadata via TalkenApiClient walletscan endpoint
3015
- *
3016
- * @param params - Contract address, wallet address, and networks
3017
- * @returns Array of NFT metadata or empty array if failed
3018
- */
3019
- async getNFT(params) {
3020
- const api = getTalkenApiClient4();
3021
- if (!api)
3022
- throw new Error("TalkenApiClient not initialized");
3023
- try {
3024
- return await api.walletscan.getNfts({
3025
- chainKeys: networkNameToChainKey2(params.networks),
3026
- walletAddress: params.walletAddress
3027
- });
3028
- } catch (error) {
3029
- console.warn(
3030
- "[WalletscanApi] TalkenApi getNfts failed:",
3031
- params.contractAddress,
3032
- error
3033
- );
3034
- return [];
3035
- }
3036
- }
3037
- /**
3038
- * Get NFT metadata with timeout
3039
- *
3040
- * @param params - Contract address, wallet address, and networks
3041
- * @param timeoutMs - Timeout in milliseconds (default: 3000)
3042
- * @returns First NFT or null if timeout/failed/empty
3043
- */
3044
- async getNFTWithTimeout(params, timeoutMs = 3e3) {
3045
- try {
3046
- const nfts = await Promise.race([
3047
- this.getNFT(params),
3048
- new Promise(
3049
- (resolve) => setTimeout(() => resolve([]), timeoutMs)
3050
- )
3051
- ]);
3052
- return nfts.length > 0 ? nfts[0] : null;
3053
- } catch (_error) {
3054
- console.warn(
3055
- "[WalletscanApi] NFT metadata request timed out:",
3056
- params.contractAddress
3057
- );
3058
- return null;
3059
- }
3060
- }
3061
- };
3062
-
3063
- // src/wallets/walletConnectors/abcWallet/api/GasApi.ts
3064
- import { getTalkenApiClient as getTalkenApiClient5 } from "@talken/talkenkit";
3065
- var GasApi = class {
3066
- parseGasFees(data) {
3067
- return {
3068
- ...data,
3069
- networkCongestion: data.networkCongestion != null ? Number(data.networkCongestion) : void 0
3070
- };
3071
- }
3072
- /**
3073
- * Get suggested gas fees for EIP-1559 transactions via TalkenApiClient
3074
- *
3075
- * @param network - Network name (ethereum, polygon, klaytn, etc.)
3076
- * @returns Suggested gas fees or null if failed
3077
- */
3078
- async getSuggestedGasFees(network) {
3079
- const api = getTalkenApiClient5();
3080
- if (!api)
3081
- throw new Error("TalkenApiClient not initialized");
3082
- try {
3083
- const gasFees = await api.evm.getGasSuggested(network);
3084
- return this.parseGasFees(gasFees);
3085
- } catch (error) {
3086
- console.warn(
3087
- "[GasApi] TalkenApi getGasSuggested failed:",
3088
- network,
3089
- error
3090
- );
3091
- return null;
3092
- }
3093
- }
3094
- /**
3095
- * Estimate gas limit for EIP-1559 transaction via TalkenApiClient
3096
- *
3097
- * @param params - Transaction parameters
3098
- * @returns Gas limit (hex string) or null if failed
3099
- */
3100
- async estimateGas(params) {
3101
- const api = getTalkenApiClient5();
3102
- if (!api)
3103
- throw new Error("TalkenApiClient not initialized");
3104
- try {
3105
- const response = await api.evm.estimateGas({
3106
- network: params.network,
3107
- from: params.from || "",
3108
- to: params.to,
3109
- value: params.value || "0x0",
3110
- data: params.data || "0x"
3111
- });
3112
- return response.result ?? null;
3113
- } catch (error) {
3114
- console.warn("[GasApi] TalkenApi estimateGas failed:", error);
3115
- return null;
3116
- }
3117
- }
3118
- /**
3119
- * Get suggested gas fees with timeout
3120
- *
3121
- * @param network - Network name
3122
- * @param timeoutMs - Timeout in milliseconds (default: 5000)
3123
- * @returns Suggested gas fees or null if timeout/failed
3124
- */
3125
- async getSuggestedGasFeesWithTimeout(network, timeoutMs = 5e3) {
3126
- try {
3127
- const result = await Promise.race([
3128
- this.getSuggestedGasFees(network),
3129
- new Promise(
3130
- (resolve) => setTimeout(() => resolve(null), timeoutMs)
3131
- )
3132
- ]);
3133
- return result;
3134
- } catch (_error) {
3135
- console.warn("[GasApi] Gas fees request timed out:", network);
3136
- return null;
3137
- }
3138
- }
3139
- /**
3140
- * Estimate gas with timeout
3141
- *
3142
- * @param params - Transaction parameters
3143
- * @param timeoutMs - Timeout in milliseconds (default: 5000)
3144
- * @returns Gas limit (hex string) or null if timeout/failed
3145
- */
3146
- async estimateGasWithTimeout(params, timeoutMs = 5e3) {
3147
- try {
3148
- const result = await Promise.race([
3149
- this.estimateGas(params),
3150
- new Promise(
3151
- (resolve) => setTimeout(() => resolve(null), timeoutMs)
3152
- )
3153
- ]);
3154
- return result;
3155
- } catch (_error) {
3156
- console.warn("[GasApi] Gas estimate request timed out");
3157
- return null;
3158
- }
3159
- }
3160
- };
3161
-
3162
- // src/wallets/walletConnectors/abcWallet/sessionUtils.ts
3163
- import { getTalkenApiClient as getTalkenApiClient6 } from "@talken/talkenkit";
3164
- var SessionExpiredError = class extends Error {
3165
- constructor(message = "Session expired. Please reconnect your wallet.") {
3166
- super(message);
3167
- this.name = "SessionExpiredError";
3168
- }
3169
- };
3170
- function dispatchSessionExpired() {
3171
- if (typeof window !== "undefined") {
3172
- console.warn("[SessionUtils] \u{1F6A8} dispatchSessionExpired called from:");
3173
- console.trace();
3174
- window.dispatchEvent(new CustomEvent("talkenkit:session_expired"));
3175
- }
3176
- }
3177
- function handleUnauthorizedResponse(response) {
3178
- if (response.status === 401) {
3179
- dispatchSessionExpired();
3180
- throw new SessionExpiredError(
3181
- "Session expired. Please reconnect your wallet."
3182
- );
3183
- }
3184
- }
3185
- async function fetchWithSessionCheck(url, options) {
3186
- const response = await fetch(url, options);
3187
- if (!response.ok && response.status === 401) {
3188
- const errorText = await response.text();
3189
- console.error("[ABC WaaS] \u274C Unauthorized (401):", errorText);
3190
- dispatchSessionExpired();
3191
- throw new SessionExpiredError(
3192
- "Session expired. Please reconnect your wallet."
3193
- );
3194
- }
3195
- return response;
3196
- }
3197
- async function refreshAccessToken(pinCallback) {
3198
- if (pinCallback) {
3199
- await pinCallback();
3200
- }
3201
- const refreshToken = localStorage.getItem(`${STORAGE_PREFIX}refresh_token`);
3202
- if (!refreshToken) {
3203
- console.warn("[SessionUtils] No refresh token - opening connect modal");
3204
- dispatchSessionExpired();
3205
- await new Promise((resolve) => setTimeout(resolve, 100));
3206
- throw new SessionExpiredError(
3207
- "Session expired. Please reconnect your wallet."
3208
- );
3209
- }
3210
- try {
3211
- const api = getTalkenApiClient6();
3212
- if (!api) {
3213
- throw new Error("TalkenApiClient not initialized");
3214
- }
3215
- api.setTokens(
3216
- localStorage.getItem(`${STORAGE_PREFIX}access_token`) || "",
3217
- refreshToken,
3218
- Number(localStorage.getItem(`${STORAGE_PREFIX}expires_at`) || "0")
3219
- );
3220
- const res = await api.auth.refresh();
3221
- const expiresAt = Date.now() + res.expiresIn * 1e3;
3222
- localStorage.setItem(`${STORAGE_PREFIX}access_token`, res.accessToken);
3223
- if (res.refreshToken) {
3224
- localStorage.setItem(`${STORAGE_PREFIX}refresh_token`, res.refreshToken);
3225
- }
3226
- localStorage.setItem(`${STORAGE_PREFIX}expires_at`, String(expiresAt));
3227
- console.log(
3228
- "[SessionUtils] \u2705 Token refreshed - expires in:",
3229
- (res.expiresIn / 60 / 60).toFixed(2),
3230
- "hours"
3231
- );
3232
- return res.accessToken;
3233
- } catch (error) {
3234
- console.error("[SessionUtils] Token refresh failed:", error);
3235
- dispatchSessionExpired();
3236
- await new Promise((resolve) => setTimeout(resolve, 100));
3237
- throw new SessionExpiredError(
3238
- "Session expired. Please reconnect your wallet."
3239
- );
3240
- }
3241
- }
3242
-
3243
- // src/wallets/walletConnectors/abcWallet/abcBitcoinProvider.ts
3244
- import { getTalkenApiClient as getTalkenApiClient7 } from "@talken/talkenkit";
3245
- function isTalkenApiClient(client) {
3246
- return typeof client?.bitcoin?.getUtxos === "function";
3247
- }
3248
- var EventEmitter2 = class {
3249
- constructor() {
3250
- this.events = /* @__PURE__ */ new Map();
3251
- }
3252
- on(event, listener) {
3253
- if (!this.events.has(event)) {
3254
- this.events.set(event, []);
3255
- }
3256
- this.events.get(event).push(listener);
3257
- return this;
3258
- }
3259
- off(event, listener) {
3260
- const listeners = this.events.get(event);
3261
- if (listeners) {
3262
- const index = listeners.indexOf(listener);
3263
- if (index !== -1) {
3264
- listeners.splice(index, 1);
3265
- }
3266
- }
3267
- return this;
3268
- }
3269
- removeListener(event, listener) {
3270
- return this.off(event, listener);
3271
- }
3272
- emit(event, ...args) {
3273
- const listeners = this.events.get(event);
3274
- if (listeners) {
3275
- for (const listener of listeners) {
3276
- listener(...args);
3277
- }
3278
- return true;
3279
- }
3280
- return false;
3281
- }
3282
- removeAllListeners(event) {
3283
- if (event) {
3284
- this.events.delete(event);
3285
- } else {
3286
- this.events.clear();
3287
- }
3288
- return this;
3289
- }
3290
- };
3291
- var BitcoinErrorCode = {
3292
- USER_REJECTED: 4001,
3293
- UNAUTHORIZED: 4100,
3294
- UNSUPPORTED_METHOD: 4200,
3295
- DISCONNECTED: 4900,
3296
- INVALID_PARAMS: -32602,
3297
- INTERNAL_ERROR: -32603,
3298
- INSUFFICIENT_FUNDS: 5001,
3299
- UTXO_NOT_FOUND: 5002
3300
- };
3301
- var BitcoinProviderError = class extends Error {
3302
- constructor(code, message, data) {
3303
- super(message);
3304
- this.code = code;
3305
- this.data = data;
3306
- this.name = "BitcoinProviderError";
3307
- }
3308
- };
3309
- var BITCOIN_NETWORKS = {
3310
- mainnet: {
3311
- name: "Bitcoin Mainnet",
3312
- type: "bitcoin",
3313
- explorer: "https://blockstream.info"
3314
- },
3315
- testnet: {
3316
- name: "Bitcoin Testnet",
3317
- type: "bitcoin_testnet",
3318
- explorer: "https://blockstream.info/testnet"
3319
- }
3320
- };
3321
- var AbcBitcoinProvider = class extends EventEmitter2 {
3322
- constructor(client) {
3323
- super();
3324
- this.wallet = null;
3325
- this.network = BITCOIN_NETWORKS.testnet;
3326
- this.connected = false;
3327
- this.utxoCache = /* @__PURE__ */ new Map();
3328
- this.cacheExpiry = /* @__PURE__ */ new Map();
3329
- this.CACHE_TTL = 6e4;
3330
- if (isTalkenApiClient(client)) {
3331
- this.talkenApi = client;
3332
- }
3333
- }
3334
- extractHashSignature(result) {
3335
- const data = result;
3336
- return data?.signatureHex || data?.signstr || data?.result?.signstr || data?.data?.signatureHex || data?.data?.signstr || data?.data?.result?.signstr || "";
3337
- }
3338
- getRecoveryEmail() {
3339
- return getCredentialManager().getEmail() || void 0;
3340
- }
3341
- /**
3342
- * Set request interceptor for sign/transfer confirmation modals
3343
- */
3344
- setRequestInterceptor(interceptor) {
3345
- this.requestInterceptor = interceptor;
3346
- }
3347
- /**
3348
- * Call request interceptor if set (throws on user cancel)
3349
- */
3350
- async callInterceptor(request) {
3351
- if (this.requestInterceptor) {
3352
- await this.requestInterceptor(request);
3353
- }
3354
- }
3355
- /**
3356
- * Set wallet information
3357
- */
3358
- setWallet(wallet) {
3359
- const previousAddress = this.wallet?.address;
3360
- this.wallet = wallet;
3361
- this.connected = true;
3362
- if (wallet.network === "bitcoin") {
3363
- this.network = BITCOIN_NETWORKS.mainnet;
3364
- } else {
3365
- this.network = BITCOIN_NETWORKS.testnet;
3366
- }
3367
- if (previousAddress !== wallet.address) {
3368
- this.emit("accountsChanged", [wallet.address]);
3369
- this.clearUtxoCache();
3370
- }
3371
- this.emit("connect", {
3372
- address: wallet.address,
3373
- network: this.network.type
3374
- });
3375
- console.log(
3376
- "[BitcoinProvider] \u2705 Wallet connected:",
3377
- `${wallet.address.substring(0, 6)}...${wallet.address.substring(wallet.address.length - 6)}`
3378
- );
3379
- }
3380
- /**
3381
- * Clear wallet (disconnect)
3382
- */
3383
- clearWallet() {
3384
- this.wallet = null;
3385
- this.connected = false;
3386
- this.clearUtxoCache();
3387
- this.emit("disconnect");
3388
- this.emit("accountsChanged", []);
3389
- console.log("[BitcoinProvider] \u{1F50C} Wallet disconnected");
3390
- }
3391
- /**
3392
- * Set TalkenApiClient for backend-proxied transaction flow
3393
- * When set, sendTransaction will use a single API call instead of multi-step WaaS
3394
- */
3395
- setTalkenApi(talkenApi) {
3396
- this.talkenApi = talkenApi;
3397
- }
3398
- /**
3399
- * Set network
3400
- */
3401
- setNetwork(networkKey) {
3402
- const newNetwork = BITCOIN_NETWORKS[networkKey];
3403
- if (!newNetwork) {
3404
- throw new BitcoinProviderError(
3405
- BitcoinErrorCode.INVALID_PARAMS,
3406
- `Unknown network: ${networkKey}`
3407
- );
3408
- }
3409
- const previousType = this.network.type;
3410
- this.network = newNetwork;
3411
- if (previousType !== newNetwork.type) {
3412
- this.emit("networkChanged", newNetwork.type);
3413
- this.clearUtxoCache();
3414
- }
3415
- }
3416
- /**
3417
- * Get current network
3418
- */
3419
- getNetwork() {
3420
- return this.network;
3421
- }
3422
- /**
3423
- * Check if connected
3424
- */
3425
- isConnected() {
3426
- return this.connected && this.wallet !== null;
3427
- }
3428
- /**
3429
- * Get Bitcoin address
3430
- */
3431
- async getAddress() {
3432
- if (!this.wallet) {
3433
- throw new BitcoinProviderError(
3434
- BitcoinErrorCode.DISCONNECTED,
3435
- "Wallet not connected"
3436
- );
3437
- }
3438
- return this.wallet.address;
3439
- }
3440
- /**
3441
- * Get compressed public key (33 bytes)
3442
- */
3443
- async getPublicKey() {
3444
- if (!this.wallet) {
3445
- throw new BitcoinProviderError(
3446
- BitcoinErrorCode.DISCONNECTED,
3447
- "Wallet not connected"
3448
- );
3449
- }
3450
- return this.wallet.publicKey;
3451
- }
3452
- /**
3453
- * Get address type (bech32, p2pkh, etc.)
3454
- */
3455
- getAddressType() {
3456
- if (!this.wallet) {
3457
- throw new BitcoinProviderError(
3458
- BitcoinErrorCode.DISCONNECTED,
3459
- "Wallet not connected"
3460
- );
3461
- }
3462
- return this.wallet.addressType;
3463
- }
3464
- /**
3465
- * Clear UTXO cache
3466
- */
3467
- clearUtxoCache() {
3468
- this.utxoCache.clear();
3469
- this.cacheExpiry.clear();
3470
- }
3471
- /**
3472
- * Check if cache is valid
3473
- */
3474
- isCacheValid(address) {
3475
- const expiry = this.cacheExpiry.get(address);
3476
- if (!expiry)
3477
- return false;
3478
- return Date.now() < expiry;
3479
- }
3480
- normalizeUtxos(rawUtxos) {
3481
- return rawUtxos.map((u) => ({
3482
- txid: String(u?.txid ?? u?.tx_hash ?? ""),
3483
- vout: Number(u?.vout ?? u?.output_index ?? 0),
3484
- value: Number(u?.value ?? u?.satoshis ?? 0),
3485
- scriptPubKey: String(
3486
- u?.scriptPubKey ?? u?.script_pub_key ?? u?.script ?? ""
3487
- ),
3488
- confirmations: Number(u?.confirmations ?? 0)
3489
- })).filter(
3490
- (u) => Boolean(u.txid) && Number.isFinite(u.vout) && Number.isFinite(u.value) && Number.isFinite(u.confirmations)
3491
- );
3492
- }
3493
- /**
3494
- * Get UTXOs for address (with caching)
3495
- */
3496
- async getUtxos(forceRefresh = false) {
3497
- if (!this.wallet) {
3498
- throw new BitcoinProviderError(
3499
- BitcoinErrorCode.DISCONNECTED,
3500
- "Wallet not connected"
3501
- );
3502
- }
3503
- const address = this.wallet.address;
3504
- if (!forceRefresh && this.isCacheValid(address)) {
3505
- const cached = this.utxoCache.get(address);
3506
- if (cached) {
3507
- console.log(
3508
- `[BitcoinProvider] \u{1F4E6} Using cached UTXOs (${cached.length} items)`
3509
- );
3510
- return cached;
3511
- }
3512
- }
3513
- try {
3514
- console.log("[BitcoinProvider] \u{1F50D} Fetching UTXOs from network...");
3515
- const api = this.talkenApi || getTalkenApiClient7();
3516
- const result = await api.bitcoin.getUtxos(this.network.type, address);
3517
- const utxos = this.normalizeUtxos(result.utxos || []);
3518
- this.utxoCache.set(address, utxos);
3519
- this.cacheExpiry.set(address, Date.now() + this.CACHE_TTL);
3520
- console.log(`[BitcoinProvider] \u2705 Fetched ${utxos.length} UTXOs`);
3521
- return utxos;
3522
- } catch (error) {
3523
- console.error(
3524
- "[BitcoinProvider] \u274C Failed to fetch UTXOs:",
3525
- error.message
3526
- );
3527
- throw new BitcoinProviderError(
3528
- BitcoinErrorCode.INTERNAL_ERROR,
3529
- "Failed to fetch UTXOs",
3530
- error
3531
- );
3532
- }
3533
- }
3534
- /**
3535
- * Get total balance (sum of all UTXOs)
3536
- * Returns balance in satoshis
3537
- */
3538
- async getBalance(forceRefresh = false) {
3539
- const utxos = await this.getUtxos(forceRefresh);
3540
- const balance = utxos.reduce((sum, utxo) => sum + utxo.value, 0);
3541
- console.log(
3542
- `[BitcoinProvider] \u{1F4B0} Balance: ${balance} satoshis (${balance / 1e8} BTC)`
3543
- );
3544
- return balance;
3545
- }
3546
- /**
3547
- * Estimate transaction fee
3548
- * Returns fee rate in satoshis per byte
3549
- */
3550
- async estimateFee(targetBlocks = 6) {
3551
- try {
3552
- const api = this.talkenApi || getTalkenApiClient7();
3553
- const result = await api.bitcoin.getFeeRate(
3554
- this.network.type,
3555
- targetBlocks
3556
- );
3557
- const feeRate = Number(result.feeRate);
3558
- if (!Number.isFinite(feeRate) || feeRate <= 0) {
3559
- throw new Error("Invalid fee rate");
3560
- }
3561
- console.log(`[BitcoinProvider] \u26FD Fee rate: ${feeRate} sat/byte`);
3562
- return feeRate;
3563
- } catch (_error) {
3564
- console.error("[BitcoinProvider] \u26A0\uFE0F Fee estimation failed, using default");
3565
- return 1;
3566
- }
3567
- }
3568
- /**
3569
- * Sign Bitcoin message (Bitcoin Signed Message format)
3570
- * Uses secp256k1 sign/hash endpoint with double-SHA256 of prefixed message.
3571
- *
3572
- * Format: SHA256(SHA256("\x18Bitcoin Signed Message:\n" + varint(len) + message))
3573
- *
3574
- * @param message - Message to sign (string)
3575
- * @returns Signature in hex format (compact: r + s + v)
3576
- */
3577
- async signMessage(message) {
3578
- if (!this.wallet) {
3579
- throw new BitcoinProviderError(
3580
- BitcoinErrorCode.DISCONNECTED,
3581
- "Wallet not connected"
3582
- );
3583
- }
3584
- await this.callInterceptor({
3585
- chain: "bitcoin",
3586
- method: "signMessage",
3587
- address: this.wallet.address,
3588
- network: this.network.type,
3589
- message
3590
- });
3591
- console.log("[BitcoinProvider] \u{1F4DD} Signing Bitcoin message...");
3592
- const prefix = "Bitcoin Signed Message:\n";
3593
- const msgBytes = new TextEncoder().encode(message);
3594
- const varint = this.encodeVarint(msgBytes.length);
3595
- const prefixBytes = new TextEncoder().encode(prefix);
3596
- const preimage = new Uint8Array(
3597
- prefixBytes.length + varint.length + msgBytes.length
3598
- );
3599
- preimage.set(prefixBytes, 0);
3600
- preimage.set(varint, prefixBytes.length);
3601
- preimage.set(msgBytes, prefixBytes.length + varint.length);
3602
- const hash1 = await crypto.subtle.digest("SHA-256", preimage);
3603
- const hash2 = await crypto.subtle.digest("SHA-256", hash1);
3604
- const hashHex = Array.from(new Uint8Array(hash2)).map((b) => b.toString(16).padStart(2, "0")).join("");
3605
- const api = getTalkenApiClient7();
3606
- if (!api) {
3607
- throw new BitcoinProviderError(
3608
- BitcoinErrorCode.INTERNAL_ERROR,
3609
- "TalkenApiClient not initialized"
3610
- );
3611
- }
3612
- const pinHash = getCredentialManager().getPinHash() || "";
3613
- const email = this.getRecoveryEmail();
3614
- let signstr = "";
3615
- try {
3616
- const result = await api.bitcoin.execute({
3617
- action: "signHash",
3618
- hash: hashHex,
3619
- pin: pinHash,
3620
- network: this.network.type,
3621
- ...email && { email }
3622
- });
3623
- signstr = this.extractHashSignature(result);
3624
- } catch (error) {
3625
- console.warn(
3626
- "[BitcoinProvider] BTC signHash endpoint failed, falling back to generic sign/hash:",
3627
- error
3628
- );
3629
- }
3630
- if (!signstr) {
3631
- signstr = this.extractHashSignature(
3632
- await api.bitcoin.signHash({
3633
- hash: hashHex,
3634
- pin: pinHash,
3635
- network: this.network.type,
3636
- ...email && { email }
3637
- })
3638
- );
3639
- }
3640
- if (!signstr) {
3641
- throw new BitcoinProviderError(
3642
- BitcoinErrorCode.INTERNAL_ERROR,
3643
- "Empty signature from sign/hash"
3644
- );
3645
- }
3646
- console.log("[BitcoinProvider] \u2705 Message signed successfully");
3647
- return signstr;
3648
- }
3649
- /** Encode integer as Bitcoin varint */
3650
- encodeVarint(n) {
3651
- if (n < 253)
3652
- return new Uint8Array([n]);
3653
- if (n <= 65535) {
3654
- const buf2 = new Uint8Array(3);
3655
- buf2[0] = 253;
3656
- buf2[1] = n & 255;
3657
- buf2[2] = n >> 8 & 255;
3658
- return buf2;
3659
- }
3660
- const buf = new Uint8Array(5);
3661
- buf[0] = 254;
3662
- buf[1] = n & 255;
3663
- buf[2] = n >> 8 & 255;
3664
- buf[3] = n >> 16 & 255;
3665
- buf[4] = n >> 24 & 255;
3666
- return buf;
3667
- }
3668
- /**
3669
- * High-level transaction sending (like Solana pattern)
3670
- * Creates, signs, and broadcasts transaction
3671
- *
3672
- * @param params - Transaction parameters
3673
- * @param params.toAddress - Recipient Bitcoin address
3674
- * @param params.amount - Amount in BTC (will be converted to satoshis)
3675
- * @returns Transaction hash
3676
- */
3677
- async sendTransaction(params) {
3678
- if (!this.wallet) {
3679
- throw new BitcoinProviderError(
3680
- BitcoinErrorCode.DISCONNECTED,
3681
- "Wallet not connected"
3682
- );
3683
- }
3684
- try {
3685
- await this.callInterceptor({
3686
- chain: "bitcoin",
3687
- method: "sendTransaction",
3688
- fromAddress: this.wallet.address,
3689
- toAddress: params.toAddress,
3690
- amount: String(params.amount),
3691
- symbol: "BTC",
3692
- network: this.network.type,
3693
- isNativeToken: true,
3694
- feeSymbol: "BTC"
3695
- });
3696
- console.log("[BitcoinProvider] \u{1F4B8} Starting high-level transaction...");
3697
- const pinHash = getCredentialManager().getPinHash();
3698
- if (!pinHash) {
3699
- throw new BitcoinProviderError(
3700
- BitcoinErrorCode.INTERNAL_ERROR,
3701
- "PIN hash not found. Please login again."
3702
- );
3703
- }
3704
- const email = this.getRecoveryEmail();
3705
- const satoshis = Math.floor(params.amount * 1e8);
3706
- const api = this.talkenApi || getTalkenApiClient7();
3707
- const result = await api.bitcoin.sendTransaction({
3708
- toAddress: params.toAddress,
3709
- amountSats: satoshis.toString(),
3710
- pin: pinHash,
3711
- ...email && { email }
3712
- });
3713
- console.log(
3714
- "[BitcoinProvider] \u2705 BTC transaction complete via TalkenApiClient:",
3715
- result.txHash
3716
- );
3717
- this.emit("transactionBroadcasted", {
3718
- txHash: result.txHash,
3719
- explorerUrl: `${this.network.explorer}/tx/${result.txHash}`
3720
- });
3721
- this.clearUtxoCache();
3722
- return result.txHash;
3723
- } catch (error) {
3724
- if (error.message?.includes("cancelled") || error.message?.includes("rejected")) {
3725
- console.log("[BitcoinProvider] \u2139\uFE0F User cancelled transaction");
3726
- throw new BitcoinProviderError(
3727
- BitcoinErrorCode.USER_REJECTED,
3728
- "User rejected transaction",
3729
- error
3730
- );
3731
- }
3732
- console.error("[BitcoinProvider] \u274C Transaction failed:", error.message);
3733
- if (error.message?.includes("insufficient")) {
3734
- throw new BitcoinProviderError(
3735
- BitcoinErrorCode.INSUFFICIENT_FUNDS,
3736
- "Insufficient BTC balance",
3737
- error
3738
- );
3739
- }
3740
- this.emit("error", error);
3741
- throw new BitcoinProviderError(
3742
- BitcoinErrorCode.INTERNAL_ERROR,
3743
- "Failed to send transaction",
3744
- error
3745
- );
3746
- }
3747
- }
3748
- /**
3749
- * Broadcast signed transaction to network
3750
- *
3751
- * @param rawTransaction - Raw transaction in hex format
3752
- * @param psbt - Optional finalized PSBT
3753
- * @returns Transaction hash
3754
- */
3755
- async broadcastTransaction(rawTransaction, psbt) {
3756
- if (!this.wallet) {
3757
- throw new BitcoinProviderError(
3758
- BitcoinErrorCode.DISCONNECTED,
3759
- "Wallet not connected"
3760
- );
3761
- }
3762
- try {
3763
- console.log("[BitcoinProvider] \u{1F4E1} Broadcasting transaction...");
3764
- if (psbt) {
3765
- console.log(
3766
- "[BitcoinProvider] \u2139\uFE0F PSBT argument provided; raw tx broadcast uses rawTransaction only via talken-api"
3767
- );
3768
- }
3769
- const api = this.talkenApi || getTalkenApiClient7();
3770
- const result = await api.bitcoin.broadcastRawTransaction({
3771
- network: this.network.type,
3772
- rawTransaction
3773
- });
3774
- console.log(
3775
- "[BitcoinProvider] \u2705 Transaction broadcasted:",
3776
- result.txHash
3777
- );
3778
- this.emit("transactionBroadcasted", {
3779
- txHash: result.txHash,
3780
- explorerUrl: `${this.network.explorer}/tx/${result.txHash}`
3781
- });
3782
- this.clearUtxoCache();
3783
- return result.txHash;
3784
- } catch (error) {
3785
- console.error(
3786
- "[BitcoinProvider] \u274C Transaction broadcast failed:",
3787
- error.message
3788
- );
3789
- this.emit("error", error);
3790
- throw new BitcoinProviderError(
3791
- BitcoinErrorCode.INTERNAL_ERROR,
3792
- "Failed to broadcast transaction",
3793
- error
3794
- );
3795
- }
3796
- }
3797
- /**
3798
- * Get wallet info
3799
- */
3800
- getWalletInfo() {
3801
- if (!this.wallet)
3802
- return null;
3803
- return {
3804
- address: this.wallet.address,
3805
- publicKey: this.wallet.publicKey,
3806
- addressType: this.wallet.addressType,
3807
- network: this.network.type
3808
- };
3809
- }
3810
- /**
3811
- * Refresh UTXO cache
3812
- */
3813
- async refreshUtxos() {
3814
- return this.getUtxos(true);
3815
- }
3816
- };
3817
-
3818
- // src/wallets/walletConnectors/abcWallet/abcBitcoinConnector.ts
3819
- import { getTalkenApiClient as getTalkenApiClient8 } from "@talken/talkenkit";
3820
- var AbcBitcoinConnector = class {
3821
- constructor(config) {
3822
- this.wallet = null;
3823
- this.connected = false;
3824
- // Event listeners
3825
- this.connectListeners = /* @__PURE__ */ new Set();
3826
- this.disconnectListeners = /* @__PURE__ */ new Set();
3827
- this.accountsChangedListeners = /* @__PURE__ */ new Set();
3828
- this.networkChangedListeners = /* @__PURE__ */ new Set();
3829
- this.provider = config.provider;
3830
- this.setupProviderListeners();
3831
- }
3832
- /**
3833
- * Setup provider event listeners
3834
- */
3835
- setupProviderListeners() {
3836
- this.provider.on("connect", () => {
3837
- this.connected = true;
3838
- if (this.wallet) {
3839
- for (const listener of this.connectListeners) {
3840
- listener(this.wallet);
3841
- }
3842
- }
3843
- });
3844
- this.provider.on("disconnect", () => {
3845
- this.connected = false;
3846
- this.wallet = null;
3847
- for (const listener of this.disconnectListeners) {
3848
- listener();
3849
- }
3850
- });
3851
- this.provider.on("accountsChanged", (accounts) => {
3852
- for (const listener of this.accountsChangedListeners) {
3853
- listener(accounts);
3854
- }
3855
- });
3856
- this.provider.on("networkChanged", (network) => {
3857
- for (const listener of this.networkChangedListeners) {
3858
- listener(network);
3859
- }
3860
- });
3861
- }
3862
- /**
3863
- * Connect Bitcoin wallet
3864
- */
3865
- async connect() {
3866
- try {
3867
- const authState = loadAuthState();
3868
- console.log("[BitcoinConnector] \u{1F527} connect() called:", {
3869
- hasAuthState: !!authState,
3870
- isAuthenticated: authState?.isAuthenticated,
3871
- hasBitcoinWallet: !!authState?.bitcoinWallet,
3872
- bitcoinAddress: authState?.bitcoinWallet?.address
3873
- });
3874
- if (!authState || !authState.isAuthenticated || !authState.bitcoinWallet) {
3875
- throw new Error("BITCOIN_LOGIN_REQUIRED");
3876
- }
3877
- this.wallet = authState.bitcoinWallet;
3878
- this.provider.setWallet(authState.bitcoinWallet);
3879
- console.log("[BitcoinConnector] \u2705 Wallet set:", {
3880
- address: authState.bitcoinWallet.address,
3881
- publicKey: authState.bitcoinWallet.publicKey,
3882
- addressType: authState.bitcoinWallet.addressType,
3883
- network: authState.bitcoinWallet.network
3884
- });
3885
- this.connected = true;
3886
- return {
3887
- address: authState.bitcoinWallet.address,
3888
- publicKey: authState.bitcoinWallet.publicKey,
3889
- network: authState.bitcoinWallet.network
3890
- };
3891
- } catch (error) {
3892
- if (error.message === "BITCOIN_LOGIN_REQUIRED") {
3893
- throw error;
3894
- }
3895
- console.error("[BitcoinConnector] \u274C connect error:", error);
3896
- throw error;
3897
- }
3898
- }
3899
- /**
3900
- * Disconnect Bitcoin wallet
3901
- */
3902
- async disconnect() {
3903
- try {
3904
- this.provider.clearWallet();
3905
- this.wallet = null;
3906
- this.connected = false;
3907
- console.log("[BitcoinConnector] \u2705 Wallet disconnected");
3908
- } catch (error) {
3909
- console.error("[BitcoinConnector] \u274C disconnect error:", error);
3910
- throw error;
3911
- }
3912
- }
3913
- /**
3914
- * Get Bitcoin address
3915
- */
3916
- async getAddress() {
3917
- return this.provider.getAddress();
3918
- }
3919
- /**
3920
- * Get compressed public key (33 bytes)
3921
- */
3922
- async getPublicKey() {
3923
- return this.provider.getPublicKey();
3924
- }
3925
- /**
3926
- * Get address type (bech32, p2pkh, etc.)
3927
- */
3928
- getAddressType() {
3929
- return this.provider.getAddressType();
3930
- }
3931
- /**
3932
- * Get UTXOs
3933
- */
3934
- async getUtxos(forceRefresh = false) {
3935
- return this.provider.getUtxos(forceRefresh);
3936
- }
3937
- /**
3938
- * Get balance (in satoshis)
3939
- */
3940
- async getBalance(forceRefresh = false) {
3941
- return this.provider.getBalance(forceRefresh);
3942
- }
3943
- /**
3944
- * Estimate transaction fee
3945
- */
3946
- async estimateFee(targetBlocks = 6) {
3947
- return this.provider.estimateFee(targetBlocks);
3948
- }
3949
- /**
3950
- * Sign Bitcoin message (BIP-322)
3951
- * NOTE: Currently not supported - Bitcoin uses v2 API which doesn't have message signing endpoint
3952
- */
3953
- async signMessage(message) {
3954
- return this.provider.signMessage(message);
3955
- }
3956
- /**
3957
- * Send Bitcoin transaction (high-level API)
3958
- * Creates, signs, and broadcasts transaction
3959
- */
3960
- async sendTransaction(params) {
3961
- return this.provider.sendTransaction(params);
3962
- }
3963
- /**
3964
- * Broadcast signed transaction to network (low-level API)
3965
- */
3966
- async broadcastTransaction(rawTransaction, psbt) {
3967
- return this.provider.broadcastTransaction(rawTransaction, psbt);
3968
- }
3969
- /**
3970
- * Check if authorized (has valid session)
3971
- */
3972
- async isAuthorized() {
3973
- try {
3974
- const authState = loadAuthState();
3975
- if (!authState || !authState.isAuthenticated) {
3976
- return false;
3977
- }
3978
- if (!authState.bitcoinWallet) {
3979
- return false;
3980
- }
3981
- const api = getTalkenApiClient8();
3982
- return !!api && !api.isTokenExpired();
3983
- } catch {
3984
- return false;
3985
- }
3986
- }
3987
- /**
3988
- * Check if connected
3989
- */
3990
- isConnected() {
3991
- return this.connected && this.provider.isConnected();
3992
- }
3993
- /**
3994
- * Get current wallet
3995
- */
3996
- getWallet() {
3997
- return this.wallet;
3998
- }
3999
- /**
4000
- * Get provider
4001
- */
4002
- getProvider() {
4003
- return this.provider;
4004
- }
4005
- /**
4006
- * Get wallet info
4007
- */
4008
- getWalletInfo() {
4009
- return this.provider.getWalletInfo();
4010
- }
4011
- /**
4012
- * Switch network
4013
- */
4014
- async switchNetwork(network) {
4015
- this.provider.setNetwork(network);
4016
- const authState = loadAuthState();
4017
- if (authState?.bitcoinWallet) {
4018
- authState.bitcoinWallet.network = network === "mainnet" ? "bitcoin" /* Mainnet */ : "bitcoin_testnet" /* Testnet */;
4019
- saveAuthState(authState);
4020
- }
4021
- console.log("[BitcoinConnector] \u{1F504} Network switched to:", network);
4022
- }
4023
- /**
4024
- * Get current network
4025
- */
4026
- getNetwork() {
4027
- return this.provider.getNetwork().type;
4028
- }
4029
- /**
4030
- * Refresh UTXO cache
4031
- */
4032
- async refreshUtxos() {
4033
- return this.provider.refreshUtxos();
4034
- }
4035
- on(event, listener) {
4036
- switch (event) {
4037
- case "connect":
4038
- this.connectListeners.add(listener);
4039
- break;
4040
- case "disconnect":
4041
- this.disconnectListeners.add(listener);
4042
- break;
4043
- case "accountsChanged":
4044
- this.accountsChangedListeners.add(listener);
4045
- break;
4046
- case "networkChanged":
4047
- this.networkChangedListeners.add(listener);
4048
- break;
4049
- }
4050
- }
4051
- off(event, listener) {
4052
- switch (event) {
4053
- case "connect":
4054
- this.connectListeners.delete(listener);
4055
- break;
4056
- case "disconnect":
4057
- this.disconnectListeners.delete(listener);
4058
- break;
4059
- case "accountsChanged":
4060
- this.accountsChangedListeners.delete(listener);
4061
- break;
4062
- case "networkChanged":
4063
- this.networkChangedListeners.delete(listener);
4064
- break;
4065
- }
4066
- }
4067
- /**
4068
- * Remove all listeners
4069
- */
4070
- removeAllListeners() {
4071
- this.connectListeners.clear();
4072
- this.disconnectListeners.clear();
4073
- this.accountsChangedListeners.clear();
4074
- this.networkChangedListeners.clear();
4075
- }
4076
- };
4077
- function createAbcBitcoinConnector(config) {
4078
- return new AbcBitcoinConnector(config);
4079
- }
4080
-
4081
- // src/wallets/walletConnectors/abcWallet/abcSolanaProvider.ts
4082
- import { getTalkenApiClient as getTalkenApiClient9 } from "@talken/talkenkit";
4083
- var EventEmitter3 = class {
4084
- constructor() {
4085
- this.events = /* @__PURE__ */ new Map();
4086
- }
4087
- on(event, listener) {
4088
- if (!this.events.has(event)) {
4089
- this.events.set(event, []);
4090
- }
4091
- this.events.get(event).push(listener);
4092
- return this;
4093
- }
4094
- off(event, listener) {
4095
- const listeners = this.events.get(event);
4096
- if (listeners) {
4097
- const index = listeners.indexOf(listener);
4098
- if (index !== -1) {
4099
- listeners.splice(index, 1);
4100
- }
4101
- }
4102
- return this;
4103
- }
4104
- removeListener(event, listener) {
4105
- return this.off(event, listener);
4106
- }
4107
- emit(event, ...args) {
4108
- const listeners = this.events.get(event);
4109
- if (listeners) {
4110
- for (const listener of listeners) {
4111
- listener(...args);
4112
- }
4113
- return true;
4114
- }
4115
- return false;
4116
- }
4117
- removeAllListeners(event) {
4118
- if (event) {
4119
- this.events.delete(event);
4120
- } else {
4121
- this.events.clear();
4122
- }
4123
- return this;
4124
- }
4125
- };
4126
- var SolanaErrorCode = {
4127
- USER_REJECTED: 4001,
4128
- UNAUTHORIZED: 4100,
4129
- UNSUPPORTED_METHOD: 4200,
4130
- DISCONNECTED: 4900,
4131
- INVALID_PARAMS: -32602,
4132
- INTERNAL_ERROR: -32603
4133
- };
4134
- var SolanaProviderError = class extends Error {
4135
- constructor(code, message, data) {
4136
- super(message);
4137
- this.code = code;
4138
- this.data = data;
4139
- this.name = "SolanaProviderError";
4140
- }
4141
- };
4142
- var AbcSolanaProvider = class extends EventEmitter3 {
4143
- constructor(talkenApi) {
4144
- super();
4145
- this.wallet = null;
4146
- this.connected = false;
4147
- this.talkenApi = talkenApi;
4148
- }
4149
- /**
4150
- * Set request interceptor for sign/transfer confirmation modals
4151
- */
4152
- setRequestInterceptor(interceptor) {
4153
- this.requestInterceptor = interceptor;
4154
- }
4155
- /**
4156
- * Call request interceptor if set (throws on user cancel)
4157
- */
4158
- async callInterceptor(request) {
4159
- if (this.requestInterceptor) {
4160
- await this.requestInterceptor(request);
4161
- }
4162
- }
4163
- /**
4164
- * Set wallet information
4165
- */
4166
- setWallet(wallet) {
4167
- const previousAddress = this.wallet?.address;
4168
- this.wallet = wallet;
4169
- this.connected = true;
4170
- if (previousAddress !== wallet.address) {
4171
- this.emit("accountsChanged", [wallet.address]);
4172
- }
4173
- this.emit("connect", {
4174
- address: wallet.address,
4175
- network: wallet.network
4176
- });
4177
- }
4178
- /**
4179
- * Clear wallet (disconnect)
4180
- */
4181
- clearWallet() {
4182
- this.wallet = null;
4183
- this.connected = false;
4184
- this.emit("disconnect");
4185
- this.emit("accountsChanged", []);
4186
- }
4187
- /**
4188
- * Set TalkenApiClient for backend-proxied transaction flow
4189
- * When set, native SOL transfers will use a single API call instead of multi-step WaaS
4190
- */
4191
- setTalkenApi(talkenApi) {
4192
- this.talkenApi = talkenApi;
4193
- }
4194
- getTalkenApiClientOrThrow() {
4195
- const api = this.talkenApi || getTalkenApiClient9();
4196
- if (!api) {
4197
- throw new SolanaProviderError(
4198
- SolanaErrorCode.INTERNAL_ERROR,
4199
- "TalkenApiClient not initialized"
4200
- );
4201
- }
4202
- return api;
4203
- }
4204
- getSigningNetwork() {
4205
- return this.wallet?.network === "solana" ? "solana" : "solana_devnet";
4206
- }
4207
- /**
4208
- * Check if connected
4209
- */
4210
- isConnected() {
4211
- return this.connected && this.wallet !== null;
4212
- }
4213
- /**
4214
- * Get Solana address
4215
- */
4216
- async getAddress() {
4217
- if (!this.wallet) {
4218
- throw new SolanaProviderError(
4219
- SolanaErrorCode.DISCONNECTED,
4220
- "Wallet not connected"
4221
- );
4222
- }
4223
- return this.wallet.address;
4224
- }
4225
- /**
4226
- * Get public key
4227
- */
4228
- async getPublicKey() {
4229
- if (!this.wallet) {
4230
- throw new SolanaProviderError(
4231
- SolanaErrorCode.DISCONNECTED,
4232
- "Wallet not connected"
4233
- );
4234
- }
4235
- return this.wallet.publicKey;
4236
- }
4237
- /**
4238
- * Sign Solana message (no PIN required)
4239
- * Uses encrypted_share which doesn't require PIN
4240
- */
4241
- async signMessage(encodedMessage, _display) {
4242
- if (!this.wallet) {
4243
- throw new SolanaProviderError(
4244
- SolanaErrorCode.DISCONNECTED,
4245
- "Wallet not connected"
4246
- );
4247
- }
4248
- try {
4249
- const decodedText = new TextDecoder().decode(encodedMessage);
4250
- await this.callInterceptor({
4251
- chain: "solana",
4252
- method: "signMessage",
4253
- address: this.wallet.address,
4254
- network: this.wallet.network,
4255
- message: decodedText
4256
- });
4257
- const messageHex = `0x${Array.from(encodedMessage).map((b) => b.toString(16).padStart(2, "0")).join("")}`;
4258
- const result = await this.getTalkenApiClientOrThrow().solana.sign({
4259
- message: messageHex,
4260
- encryptedShare: this.wallet.encryptedShare,
4261
- keyId: this.wallet.keyId,
4262
- secretStore: this.wallet.secretStore || "",
4263
- network: this.getSigningNetwork()
4264
- });
4265
- const signatureHex = result.signature.startsWith("0x") ? result.signature.slice(2) : result.signature;
4266
- const signatureBytes = new Uint8Array(
4267
- signatureHex.match(/.{1,2}/g)?.map((byte) => Number.parseInt(byte, 16)) || []
4268
- );
4269
- return { signature: signatureBytes };
4270
- } catch (error) {
4271
- this.emit("error", error);
4272
- throw new SolanaProviderError(
4273
- SolanaErrorCode.INTERNAL_ERROR,
4274
- "Failed to sign message",
4275
- error
4276
- );
4277
- }
4278
- }
4279
- /**
4280
- * Sign arbitrary Solana transaction (requires PIN)
4281
- * Supports both Legacy Transaction and VersionedTransaction
4282
- * Used for custom transactions, dApp interactions, and protocol integrations
4283
- */
4284
- async signTransaction(transaction) {
4285
- if (!this.wallet) {
4286
- throw new SolanaProviderError(
4287
- SolanaErrorCode.DISCONNECTED,
4288
- "Wallet not connected"
4289
- );
4290
- }
4291
- try {
4292
- let txMessage = "";
4293
- try {
4294
- txMessage = JSON.stringify(transaction, null, 2);
4295
- } catch {
4296
- txMessage = String(transaction);
4297
- }
4298
- await this.callInterceptor({
4299
- chain: "solana",
4300
- method: "signTransaction",
4301
- address: this.wallet.address,
4302
- network: this.wallet.network,
4303
- message: txMessage,
4304
- isTransaction: true
4305
- });
4306
- const { VersionedTransaction, PublicKey } = await import("@solana/web3.js");
4307
- const isVersioned = transaction instanceof VersionedTransaction;
4308
- let serialized;
4309
- if (isVersioned) {
4310
- serialized = transaction.message.serialize();
4311
- } else {
4312
- serialized = transaction.serializeMessage();
4313
- }
4314
- const messageHex = Buffer.from(serialized).toString("hex");
4315
- const signatureResponse = await this.getTalkenApiClientOrThrow().solana.sign({
4316
- keyId: this.wallet.keyId,
4317
- encryptedShare: this.wallet.encryptedShare,
4318
- secretStore: this.wallet.secretStore || "",
4319
- message: messageHex,
4320
- network: this.getSigningNetwork()
4321
- });
4322
- const signatureHex = signatureResponse.signature.startsWith("0x") ? signatureResponse.signature.slice(2) : signatureResponse.signature;
4323
- const signatureBytes = Buffer.from(signatureHex, "hex");
4324
- const publicKey = new PublicKey(this.wallet.address);
4325
- if (isVersioned) {
4326
- transaction.addSignature(publicKey, signatureBytes);
4327
- } else {
4328
- transaction.addSignature(publicKey, signatureBytes);
4329
- }
4330
- return transaction;
4331
- } catch (error) {
4332
- if (error.code === 4001 || error.cancelled) {
4333
- throw error;
4334
- }
4335
- this.emit("error", error);
4336
- throw new SolanaProviderError(
4337
- SolanaErrorCode.INTERNAL_ERROR,
4338
- "Failed to sign transaction",
4339
- error
4340
- );
4341
- }
4342
- }
4343
- /**
4344
- * Sign multiple transactions (batch signing)
4345
- */
4346
- async signAllTransactions(transactions) {
4347
- const signedTransactions = [];
4348
- for (const transaction of transactions) {
4349
- const signed = await this.signTransaction(transaction);
4350
- signedTransactions.push(signed);
4351
- }
4352
- return signedTransactions;
4353
- }
4354
- /**
4355
- * Unified transfer: SOL, SPL token, or NFT
4356
- * - No mintAddress → native SOL transfer (kind='native')
4357
- * - With mintAddress → SPL/NFT transfer (kind='spl')
4358
- * - NFT = transfer({ mintAddress, toAddress, amount: 1 })
4359
- */
4360
- async transfer(params) {
4361
- if (!this.wallet) {
4362
- throw new SolanaProviderError(
4363
- SolanaErrorCode.DISCONNECTED,
4364
- "Wallet not connected"
4365
- );
4366
- }
4367
- try {
4368
- const symbol = params.mintAddress ? "SPL" : "SOL";
4369
- await this.callInterceptor({
4370
- chain: "solana",
4371
- method: "transfer",
4372
- fromAddress: this.wallet.address,
4373
- toAddress: params.toAddress,
4374
- amount: String(params.amount),
4375
- symbol,
4376
- network: this.wallet.network,
4377
- tokenAddress: params.mintAddress,
4378
- isNativeToken: !params.mintAddress,
4379
- feeSymbol: "SOL"
4380
- });
4381
- const pinHash = getCredentialManager().getPinHash();
4382
- if (!pinHash) {
4383
- throw new SolanaProviderError(
4384
- SolanaErrorCode.INTERNAL_ERROR,
4385
- "PIN hash not found. Please login again."
4386
- );
4387
- }
4388
- console.log("[AbcSolanaProvider] transfer START", {
4389
- kind: params.mintAddress ? "spl" : "native",
4390
- toAddress: params.toAddress,
4391
- amount: params.amount,
4392
- mintAddress: params.mintAddress || null,
4393
- network: this.wallet.network,
4394
- hasPinHash: !!pinHash
4395
- });
4396
- const api = this.getTalkenApiClientOrThrow();
4397
- if (params.mintAddress) {
4398
- const apiNetwork = this.wallet.network === "solana" ? "solana_mainnet" : this.wallet.network;
4399
- const { PublicKey, Connection } = await import("@solana/web3.js");
4400
- const connection = new Connection(this.getRpcUrl(), "confirmed");
4401
- const mintPubkey = new PublicKey(params.mintAddress);
4402
- const mintInfo = await connection.getParsedAccountInfo(mintPubkey);
4403
- const decimals = mintInfo.value?.data?.parsed?.info?.decimals || 9;
4404
- const rawAmount = Math.floor(params.amount * 10 ** decimals);
4405
- const result2 = await api.solana.transfer({
4406
- kind: "spl",
4407
- toAddress: params.toAddress,
4408
- mintAddress: params.mintAddress,
4409
- amount: String(rawAmount),
4410
- decimals,
4411
- network: apiNetwork,
4412
- pin: pinHash
4413
- });
4414
- console.log("[AbcSolanaProvider] SPL transfer result:", result2);
4415
- return { signature: result2.txHash };
4416
- }
4417
- const { LAMPORTS_PER_SOL } = await import("@solana/web3.js");
4418
- const amountLamports = params.amount * LAMPORTS_PER_SOL;
4419
- console.log("[AbcSolanaProvider] native transfer request:", {
4420
- toAddress: params.toAddress,
4421
- amountLamports: String(amountLamports),
4422
- amountSOL: params.amount
4423
- });
4424
- const result = await api.solana.transfer({
4425
- kind: "native",
4426
- toAddress: params.toAddress,
4427
- amountLamports: String(amountLamports),
4428
- pin: pinHash
4429
- });
4430
- console.log("[AbcSolanaProvider] native transfer result:", result);
4431
- return { signature: result.txHash };
4432
- } catch (error) {
4433
- console.error("[AbcSolanaProvider] transfer FAILED:", {
4434
- message: error.message,
4435
- code: error.code,
4436
- status: error.status,
4437
- details: error.details || error.data
4438
- });
4439
- if (error.code === 4001 || error.cancelled) {
4440
- throw error;
4441
- }
4442
- this.emit("error", error);
4443
- throw new SolanaProviderError(
4444
- SolanaErrorCode.INTERNAL_ERROR,
4445
- "Failed to transfer",
4446
- error
4447
- );
4448
- }
4449
- }
4450
- /**
4451
- * Get wallet info
4452
- */
4453
- getWalletInfo() {
4454
- if (!this.wallet)
4455
- return null;
4456
- return {
4457
- address: this.wallet.address,
4458
- publicKey: this.wallet.publicKey,
4459
- network: this.wallet.network
4460
- };
4461
- }
4462
- /**
4463
- * Get SPL token balance
4464
- *
4465
- * @param mintAddress - Token mint address
4466
- * @returns Token balance information
4467
- */
4468
- async getTokenBalance(mintAddress) {
4469
- if (!this.wallet) {
4470
- throw new SolanaProviderError(
4471
- SolanaErrorCode.DISCONNECTED,
4472
- "Wallet not connected"
4473
- );
4474
- }
4475
- try {
4476
- const { PublicKey, Connection } = await import("@solana/web3.js");
4477
- const { getAssociatedTokenAddress, TOKEN_PROGRAM_ID } = await import("@solana/spl-token");
4478
- const connection = new Connection(this.getRpcUrl(), "confirmed");
4479
- const mintPubkey = new PublicKey(mintAddress);
4480
- const ownerPubkey = new PublicKey(this.wallet.address);
4481
- const tokenAccount = await getAssociatedTokenAddress(
4482
- mintPubkey,
4483
- ownerPubkey,
4484
- false,
4485
- TOKEN_PROGRAM_ID
4486
- );
4487
- const balance = await connection.getTokenAccountBalance(tokenAccount);
4488
- return {
4489
- amount: balance.value.amount,
4490
- decimals: balance.value.decimals,
4491
- uiAmount: balance.value.uiAmount || 0
4492
- };
4493
- } catch (error) {
4494
- this.emit("error", error);
4495
- throw new SolanaProviderError(
4496
- SolanaErrorCode.INTERNAL_ERROR,
4497
- "Failed to get token balance",
4498
- error
4499
- );
4500
- }
4501
- }
4502
- /**
4503
- * Get RPC URL based on network
4504
- */
4505
- getRpcUrl() {
4506
- const isMainnet = this.wallet?.network === "solana";
4507
- return isMainnet ? process.env.NEXT_PUBLIC_SOLANA_RPC_MAINNET || "https://api.mainnet-beta.solana.com" : process.env.NEXT_PUBLIC_SOLANA_RPC_DEVNET || "https://api.devnet.solana.com";
4508
- }
4509
- };
4510
-
4511
- // src/wallets/walletConnectors/abcWallet/abcTronProvider.ts
4512
- import { getTalkenApiClient as getTalkenApiClient10 } from "@talken/talkenkit";
4513
- function isTalkenApiClient2(client) {
4514
- return typeof client?.tron?.transferTrx === "function";
4515
- }
4516
- var TronErrorCode = {
4517
- USER_REJECTED: 4001,
4518
- UNAUTHORIZED: 4100,
4519
- UNSUPPORTED_METHOD: 4200,
4520
- DISCONNECTED: 4900,
4521
- INVALID_PARAMS: -32602,
4522
- INTERNAL_ERROR: -32603,
4523
- INSUFFICIENT_FUNDS: 5001
4524
- };
4525
- var TronProviderError = class extends Error {
4526
- constructor(code, message, data) {
4527
- super(message);
4528
- this.code = code;
4529
- this.data = data;
4530
- this.name = "TronProviderError";
4531
- }
4532
- };
4533
- var TRON_NETWORKS = {
4534
- mainnet: {
4535
- name: "TRON Mainnet",
4536
- type: "tron",
4537
- explorer: "https://tronscan.org"
4538
- },
4539
- nile: {
4540
- name: "TRON Nile Testnet",
4541
- type: "tron_nile",
4542
- explorer: "https://nile.tronscan.org"
4543
- }
4544
- };
4545
- var EventEmitter4 = class {
4546
- constructor() {
4547
- this.events = /* @__PURE__ */ new Map();
4548
- }
4549
- on(event, listener) {
4550
- if (!this.events.has(event)) {
4551
- this.events.set(event, []);
4552
- }
4553
- this.events.get(event).push(listener);
4554
- return this;
4555
- }
4556
- off(event, listener) {
4557
- const listeners = this.events.get(event);
4558
- if (listeners) {
4559
- const index = listeners.indexOf(listener);
4560
- if (index !== -1) {
4561
- listeners.splice(index, 1);
4562
- }
4563
- }
4564
- return this;
4565
- }
4566
- emit(event, ...args) {
4567
- const listeners = this.events.get(event);
4568
- if (listeners) {
4569
- for (const listener of listeners) {
4570
- listener(...args);
4571
- }
4572
- return true;
4573
- }
4574
- return false;
4575
- }
4576
- removeAllListeners(event) {
4577
- if (event) {
4578
- this.events.delete(event);
4579
- } else {
4580
- this.events.clear();
4581
- }
4582
- return this;
4583
- }
4584
- };
4585
- var AbcTronProvider = class extends EventEmitter4 {
4586
- constructor(client) {
4587
- super();
4588
- this.wallet = null;
4589
- this.network = TRON_NETWORKS.mainnet;
4590
- this.connected = false;
4591
- this.tokenMetadataCache = /* @__PURE__ */ new Map();
4592
- if (isTalkenApiClient2(client)) {
4593
- this.talkenApi = client;
4594
- }
4595
- }
4596
- /**
4597
- * Set request interceptor for transfer confirmation modals
4598
- */
4599
- setRequestInterceptor(interceptor) {
4600
- this.requestInterceptor = interceptor;
4601
- }
4602
- /**
4603
- * Call request interceptor if set (throws on user cancel)
4604
- */
4605
- async callInterceptor(request) {
4606
- if (this.requestInterceptor) {
4607
- await this.requestInterceptor(request);
4608
- }
4609
- }
4610
- /**
4611
- * Set wallet information
4612
- */
4613
- setWallet(wallet) {
4614
- const previousAddress = this.wallet?.address;
4615
- this.wallet = wallet;
4616
- this.connected = true;
4617
- if (wallet.network === "tron") {
4618
- this.network = TRON_NETWORKS.mainnet;
4619
- } else {
4620
- this.network = TRON_NETWORKS.nile;
4621
- }
4622
- if (previousAddress !== wallet.address) {
4623
- this.emit("accountsChanged", [wallet.address]);
4624
- }
4625
- this.emit("connect", {
4626
- address: wallet.address,
4627
- network: this.network.type
4628
- });
4629
- console.log(
4630
- "[TronProvider] \u2705 Wallet connected:",
4631
- `${wallet.address.substring(0, 6)}...${wallet.address.substring(wallet.address.length - 6)}`
4632
- );
4633
- }
4634
- /**
4635
- * Clear wallet (disconnect)
4636
- */
4637
- clearWallet() {
4638
- this.wallet = null;
4639
- this.connected = false;
4640
- this.emit("disconnect");
4641
- this.emit("accountsChanged", []);
4642
- console.log("[TronProvider] \u{1F50C} Wallet disconnected");
4643
- }
4644
- /**
4645
- * Set TalkenApiClient for backend-proxied transaction flow
4646
- * When set, sendTransaction will use a single API call instead of multi-step WaaS
4647
- */
4648
- setTalkenApi(talkenApi) {
4649
- this.talkenApi = talkenApi;
4650
- }
4651
- /**
4652
- * Fetch token metadata (symbol, logo) from walletscan API with caching.
4653
- * Falls back to 'TRX'/'TRC20' on failure.
4654
- */
4655
- async fetchTokenMetadata(contractAddress) {
4656
- const cacheKey = contractAddress || "__native__";
4657
- const cached = this.tokenMetadataCache.get(cacheKey);
4658
- if (cached)
4659
- return cached;
4660
- try {
4661
- const api = this.talkenApi || getTalkenApiClient10();
4662
- const chainKeys = this.network.type === "tron_nile" ? "tronNile" : "tron";
4663
- let tokens;
4664
- if (contractAddress) {
4665
- tokens = await api.walletscan.getToken({ chainKeys, contractAddress });
4666
- } else {
4667
- tokens = await api.walletscan.getNativeTokens({
4668
- chainKeys,
4669
- walletAddress: this.wallet.address
4670
- });
4671
- }
4672
- if (tokens.length > 0) {
4673
- const info = { symbol: tokens[0].symbol, logo: tokens[0].logo };
4674
- this.tokenMetadataCache.set(cacheKey, info);
4675
- return info;
4676
- }
4677
- } catch {
4678
- }
4679
- return { symbol: contractAddress ? "TRC20" : "TRX" };
4680
- }
4681
- /**
4682
- * Check if connected
4683
- */
4684
- isConnected() {
4685
- return this.connected && this.wallet !== null;
4686
- }
4687
- /**
4688
- * Get TRON address
4689
- */
4690
- async getAddress() {
4691
- if (!this.wallet) {
4692
- throw new TronProviderError(
4693
- TronErrorCode.DISCONNECTED,
4694
- "Wallet not connected"
4695
- );
4696
- }
4697
- return this.wallet.address;
4698
- }
4699
- /**
4700
- * Get public key
4701
- */
4702
- async getPublicKey() {
4703
- if (!this.wallet) {
4704
- throw new TronProviderError(
4705
- TronErrorCode.DISCONNECTED,
4706
- "Wallet not connected"
4707
- );
4708
- }
4709
- return this.wallet.publicKey;
4710
- }
4711
- /**
4712
- * Get current network
4713
- */
4714
- getNetwork() {
4715
- return this.network;
4716
- }
4717
- /**
4718
- * Sign TRON message (not supported)
4719
- */
4720
- async signMessage(_message) {
4721
- throw new TronProviderError(
4722
- TronErrorCode.UNSUPPORTED_METHOD,
4723
- "TRON message signing is not supported. Use sendTransaction() instead."
4724
- );
4725
- }
4726
- /**
4727
- * Send TRON transaction (TRX native or TRC20)
4728
- * Complete flow: create unsigned tx -> request PIN -> sign -> broadcast
4729
- *
4730
- * @param params - Transaction parameters
4731
- * @returns Transaction hash
4732
- */
4733
- async sendTransaction(params) {
4734
- if (!this.wallet) {
4735
- throw new TronProviderError(
4736
- TronErrorCode.DISCONNECTED,
4737
- "Wallet not connected"
4738
- );
4739
- }
4740
- try {
4741
- const tokenMetadata = await this.fetchTokenMetadata(
4742
- params.contractAddress
4743
- );
4744
- await this.callInterceptor({
4745
- chain: "tron",
4746
- method: "sendTransaction",
4747
- fromAddress: this.wallet.address,
4748
- toAddress: params.toAddress,
4749
- amount: params.amount,
4750
- symbol: tokenMetadata.symbol,
4751
- network: this.network.type,
4752
- tokenAddress: params.contractAddress,
4753
- isNativeToken: !params.contractAddress,
4754
- feeSymbol: "TRX",
4755
- tokenLogo: tokenMetadata.logo
4756
- });
4757
- console.log("[TronProvider] \u{1F4B8} Starting TRON transaction...");
4758
- const pinHash = getCredentialManager().getPinHash();
4759
- if (!pinHash) {
4760
- throw new TronProviderError(
4761
- TronErrorCode.INTERNAL_ERROR,
4762
- "PIN hash not found. Please login again."
4763
- );
4764
- }
4765
- const txType = params.contractAddress ? "TRC20" : "NATIVE";
4766
- let amountRaw;
4767
- if (txType === "NATIVE") {
4768
- amountRaw = Math.floor(
4769
- Number.parseFloat(params.amount) * 1e6
4770
- ).toString();
4771
- console.log(
4772
- `[TronProvider] Converting ${params.amount} TRX -> ${amountRaw} SUN`
4773
- );
4774
- } else {
4775
- const decimals = params.decimals ?? 6;
4776
- amountRaw = Math.floor(
4777
- Number.parseFloat(params.amount) * 10 ** decimals
4778
- ).toString();
4779
- console.log(
4780
- `[TronProvider] Converting ${params.amount} -> ${amountRaw} (decimals: ${decimals})`
4781
- );
4782
- }
4783
- const email = getCredentialManager().getEmail() || void 0;
4784
- const api = this.talkenApi || getTalkenApiClient10();
4785
- const request = txType === "NATIVE" ? {
4786
- kind: "native",
4787
- network: this.network.type,
4788
- toAddress: params.toAddress,
4789
- amountSun: amountRaw,
4790
- pin: pinHash,
4791
- ...email && { email }
4792
- } : {
4793
- kind: "trc20",
4794
- network: this.network.type,
4795
- toAddress: params.toAddress,
4796
- contractAddress: params.contractAddress,
4797
- amount: amountRaw,
4798
- feeLimit: params.feeLimit,
4799
- pin: pinHash,
4800
- ...email && { email }
4801
- };
4802
- const result = await api.tron.transferTrx(request);
4803
- const txHash = result.txHash;
4804
- console.log(
4805
- `[TronProvider] \u2705 ${txType === "NATIVE" ? "TRX" : "TRC-20"} transaction complete via TalkenApiClient:`,
4806
- txHash
4807
- );
4808
- this.emit("transactionBroadcasted", {
4809
- txHash,
4810
- explorerUrl: `${this.network.explorer}/#/transaction/${txHash}`
4811
- });
4812
- return txHash;
4813
- } catch (error) {
4814
- if (error.message?.includes("cancelled") || error.message?.includes("rejected")) {
4815
- console.log("[TronProvider] \u2139\uFE0F User cancelled transaction");
4816
- throw new TronProviderError(
4817
- TronErrorCode.USER_REJECTED,
4818
- "User rejected transaction",
4819
- error
4820
- );
4821
- }
4822
- console.error("[TronProvider] \u274C Transaction failed:", error.message);
4823
- if (error.message?.includes("insufficient")) {
4824
- throw new TronProviderError(
4825
- TronErrorCode.INSUFFICIENT_FUNDS,
4826
- "Insufficient TRX balance",
4827
- error
4828
- );
4829
- }
4830
- this.emit("error", error);
4831
- throw new TronProviderError(
4832
- TronErrorCode.INTERNAL_ERROR,
4833
- error.message || "Failed to send TRON transaction",
4834
- error
4835
- );
4836
- }
4837
- }
4838
- /**
4839
- * Get wallet info
4840
- */
4841
- getWalletInfo() {
4842
- if (!this.wallet)
4843
- return null;
4844
- return {
4845
- address: this.wallet.address,
4846
- publicKey: this.wallet.publicKey,
4847
- network: this.network.type
4848
- };
4849
- }
4850
- };
4851
-
4852
- // src/wallets/walletConnectors/abcWallet/walletGeneration.ts
4853
- import { getTalkenApiClient as getTalkenApiClient11 } from "@talken/talkenkit";
4854
- function mapApiResponseToWallets(genResponse, infoResponse, email) {
4855
- const accounts = infoResponse?.accounts || [];
4856
- const evmAccount = accounts[0] || infoResponse || {};
4857
- const uid = String(genResponse.uid || evmAccount.uid || "");
4858
- const wid = String(genResponse.wid || evmAccount.wid || "");
4859
- const sid = String(evmAccount.sid || evmAccount.ethAddress || genResponse.evmAddress || "");
4860
- const pubkey = String(evmAccount.pubkey || genResponse.pubkey || "");
4861
- const solMaterial = genResponse.solana || {};
4862
- const evmWallet = {
4863
- uid,
4864
- sessionId: sid,
4865
- keyId: wid,
4866
- encryptedShare: String(evmAccount.pvencstr || ""),
4867
- secretStore: String(evmAccount.encryptDevicePassword || ""),
4868
- address: genResponse.evmAddress || sid,
4869
- chainId: getEvmNetwork(),
4870
- sid,
4871
- type: "evm",
4872
- email,
4873
- pubkey
4874
- };
4875
- const solanaWallet = {
4876
- uid,
4877
- sessionId: String(solMaterial.shareId || ""),
4878
- keyId: String(solMaterial.keyId || ""),
4879
- encryptedShare: String(solMaterial.encryptedShare || ""),
4880
- secretStore: String(solMaterial.secretStore || ""),
4881
- shareId: String(solMaterial.shareId || ""),
4882
- publicKey: String(solMaterial.publicKey || ""),
4883
- address: genResponse.solAddress || solMaterial.address || "",
4884
- network: getSolanaNetwork()
4885
- };
4886
- const bitcoinWallet = {
4887
- uid,
4888
- sessionId: sid,
4889
- keyId: wid,
4890
- encryptedShare: String(evmAccount.pvencstr || ""),
4891
- shareId: sid,
4892
- publicKey: pubkey,
4893
- address: genResponse.btcAddress || "",
4894
- addressType: "bech32",
4895
- network: getBitcoinNetwork()
4896
- };
4897
- const tronWallet = {
4898
- uid,
4899
- sessionId: sid,
4900
- keyId: wid,
4901
- encryptedShare: String(evmAccount.pvencstr || ""),
4902
- shareId: sid,
4903
- publicKey: pubkey,
4904
- address: genResponse.trxAddress || "",
4905
- network: getTronNetwork()
4906
- };
4907
- return { evmWallet, solanaWallet, bitcoinWallet, tronWallet };
4908
- }
4909
- async function generateMpcWallets(hashedPin, email) {
4910
- const api = getTalkenApiClient11();
4911
- if (!api) {
4912
- throw new AbcError(
4913
- "WALLET_NOT_FOUND" /* WALLET_NOT_FOUND */,
4914
- "TalkenApiClient not initialized"
4915
- );
4916
- }
4917
- try {
4918
- const genResponse = await api.wallet.generate(hashedPin, email);
4919
- const infoResponse = await api.wallet.getInfo().catch(() => ({}));
4920
- return mapApiResponseToWallets(genResponse, infoResponse, email || "");
4921
- } catch (error) {
4922
- throw new AbcError(
4923
- "WALLET_NOT_FOUND" /* WALLET_NOT_FOUND */,
4924
- `Failed to generate MPC wallets: ${error.message}`,
4925
- { originalError: error }
4926
- );
4927
- }
4928
- }
4929
- async function recoverMpcWallets(hashedPin, email) {
4930
- const api = getTalkenApiClient11();
4931
- if (!api) {
4932
- throw new AbcError(
4933
- "WALLET_NOT_FOUND" /* WALLET_NOT_FOUND */,
4934
- "TalkenApiClient not initialized"
4935
- );
4936
- }
4937
- try {
4938
- const genResponse = await api.wallet.recover(hashedPin, email);
4939
- const infoResponse = await api.wallet.getInfo().catch(() => ({}));
4940
- return mapApiResponseToWallets(genResponse, infoResponse, email || "");
4941
- } catch (error) {
4942
- throw new AbcError(
4943
- "WALLET_NOT_FOUND" /* WALLET_NOT_FOUND */,
4944
- `Failed to recover MPC wallets: ${error.message}`,
4945
- { originalError: error }
4946
- );
4947
- }
4948
- }
4949
- function validateMpcWallets(result) {
4950
- const errors = [];
4951
- if (!result.evmWallet) {
4952
- errors.push("EVM wallet is missing");
4953
- } else {
4954
- if (!result.evmWallet.address || !result.evmWallet.address.startsWith("0x")) {
4955
- errors.push("Invalid EVM wallet address");
4956
- }
4957
- }
4958
- if (!result.solanaWallet) {
4959
- errors.push("Solana wallet is missing");
4960
- } else {
4961
- if (!result.solanaWallet.address) {
4962
- errors.push("Invalid Solana wallet address");
4963
- }
4964
- }
4965
- if (!result.bitcoinWallet) {
4966
- errors.push("Bitcoin wallet is missing");
4967
- } else {
4968
- if (!result.bitcoinWallet.address) {
4969
- errors.push("Invalid Bitcoin wallet address");
4970
- }
4971
- }
4972
- if (!result.tronWallet) {
4973
- errors.push("TRON wallet is missing");
4974
- } else {
4975
- if (!result.tronWallet.address) {
4976
- errors.push("Invalid TRON wallet address");
4977
- } else if (!result.tronWallet.address.startsWith("T")) {
4978
- errors.push("Invalid TRON address format (expected T prefix)");
4979
- }
4980
- }
4981
- return {
4982
- valid: errors.length === 0,
4983
- errors
4984
- };
4985
- }
4986
-
4987
- export {
4988
- AbcStorageKey,
4989
- AbcErrorCode,
4990
- AbcError,
4991
- hashPin,
4992
- validatePin,
4993
- validateEmail,
4994
- getStorageKey,
4995
- saveToStorage,
4996
- loadFromStorage,
4997
- removeFromStorage,
4998
- clearStorage,
4999
- isTokenExpired,
5000
- calculateExpiryTimestamp,
5001
- saveAuthState,
5002
- loadAuthState,
5003
- clearAuthState,
5004
- createAbcError,
5005
- hexToNumber,
5006
- numberToHex,
5007
- NetworkType,
5008
- NETWORK_CONFIGS,
5009
- NETWORK_BY_PARAM,
5010
- getNetworkByChainId,
5011
- getNetworkByParam,
5012
- chainIdToNetwork,
5013
- getNetworkName,
5014
- networkNameToChainKey,
5015
- networkToChainId,
5016
- getExplorerTxUrl,
5017
- getExplorerAddressUrl,
5018
- isEvmNetwork,
5019
- isTestnet,
5020
- getSupportedChainIds,
5021
- getSupportedNetworks,
5022
- AbcEvmProvider,
5023
- createAbcEvmProvider,
5024
- createAbcProvider,
5025
- TalkenApiClient,
5026
- createTalkenApiClient,
5027
- setTalkenApiClient,
5028
- getTalkenApiClient2 as getTalkenApiClient,
5029
- SolanaNetwork,
5030
- BitcoinNetwork,
5031
- TronNetwork,
5032
- getEvmNetwork,
5033
- getSolanaNetwork,
5034
- getBitcoinNetwork,
5035
- getTronNetwork,
5036
- resolveTalkenApiUrl,
5037
- abcConnector,
5038
- abcWallet,
5039
- WalletscanApi,
5040
- GasApi,
5041
- SessionExpiredError,
5042
- dispatchSessionExpired,
5043
- handleUnauthorizedResponse,
5044
- fetchWithSessionCheck,
5045
- refreshAccessToken,
5046
- BitcoinProviderError,
5047
- BITCOIN_NETWORKS,
5048
- AbcBitcoinProvider,
5049
- AbcBitcoinConnector,
5050
- createAbcBitcoinConnector,
5051
- SolanaProviderError,
5052
- AbcSolanaProvider,
5053
- TronProviderError,
5054
- TRON_NETWORKS,
5055
- AbcTronProvider,
5056
- generateMpcWallets,
5057
- recoverMpcWallets,
5058
- validateMpcWallets
5059
- };