@talken/talkenkit 2.4.30 → 2.5.1

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 (69) hide show
  1. package/dist/{AbcCredentialManager-DDHLW2IH.js → AbcCredentialManager-5W3B7GI4.js} +1 -1
  2. package/dist/{abcWallet-TLGPQAMU.js → abcWallet-O5IRLUXL.js} +2 -2
  3. package/dist/{chunk-ALBABQ53.js → chunk-PN6K4CMZ.js} +4 -1
  4. package/dist/{chunk-MI7TNBED.js → chunk-UHZL3WSM.js} +709 -86
  5. package/dist/components/TransactionResultModal/TransactionResultModal.css.d.ts +17 -0
  6. package/dist/components/TransactionResultModal/TransactionResultModal.d.ts +9 -0
  7. package/dist/index.css +138 -0
  8. package/dist/index.d.ts +2 -0
  9. package/dist/index.js +1344 -980
  10. package/dist/providers/TransactionResultProvider/TransactionResultContext.d.ts +6 -0
  11. package/dist/providers/TransactionResultProvider/TransactionResultProvider.d.ts +7 -0
  12. package/dist/providers/TransactionResultProvider/TransactionResultSingleton.d.ts +16 -0
  13. package/dist/providers/TransactionResultProvider/index.d.ts +4 -0
  14. package/dist/providers/TransactionResultProvider/types.d.ts +14 -0
  15. package/dist/wallets/walletConnectors/abcWallet/AbcCredentialManager.js +2 -2
  16. package/dist/wallets/walletConnectors/abcWallet/AbcEvmAutoConnector.js +2 -2
  17. package/dist/wallets/walletConnectors/abcWallet/abcAccessKeyProvider.d.ts +69 -0
  18. package/dist/wallets/walletConnectors/abcWallet/abcAccessKeyProvider.js +11 -0
  19. package/dist/wallets/walletConnectors/abcWallet/abcBitcoinConnector.js +3 -3
  20. package/dist/wallets/walletConnectors/abcWallet/abcBitcoinProvider.js +3 -3
  21. package/dist/wallets/walletConnectors/abcWallet/abcConnector.js +8 -6
  22. package/dist/wallets/walletConnectors/abcWallet/abcProvider.d.ts +8 -0
  23. package/dist/wallets/walletConnectors/abcWallet/abcProvider.js +5 -4
  24. package/dist/wallets/walletConnectors/abcWallet/abcSolanaProvider.d.ts +1 -0
  25. package/dist/wallets/walletConnectors/abcWallet/abcSolanaProvider.js +8 -8
  26. package/dist/wallets/walletConnectors/abcWallet/abcSolanaWalletAdapter.js +3 -3
  27. package/dist/wallets/walletConnectors/abcWallet/abcTronProvider.d.ts +1 -0
  28. package/dist/wallets/walletConnectors/abcWallet/abcTronProvider.js +3 -3
  29. package/dist/wallets/walletConnectors/abcWallet/abcWallet.d.ts +7 -0
  30. package/dist/wallets/walletConnectors/abcWallet/abcWallet.js +9 -7
  31. package/dist/wallets/walletConnectors/abcWallet/api/ConfigApi.js +2 -2
  32. package/dist/wallets/walletConnectors/abcWallet/api/TalkenApiClient.d.ts +25 -0
  33. package/dist/wallets/walletConnectors/abcWallet/api/TalkenApiClient.js +3 -3
  34. package/dist/wallets/walletConnectors/abcWallet/api/TokenApi.js +2 -2
  35. package/dist/wallets/walletConnectors/abcWallet/api/WalletscanApi.js +3 -3
  36. package/dist/wallets/walletConnectors/abcWallet/api/index.js +9 -9
  37. package/dist/wallets/walletConnectors/abcWallet/constants.d.ts +3 -0
  38. package/dist/wallets/walletConnectors/abcWallet/constants.js +1 -1
  39. package/dist/wallets/walletConnectors/abcWallet/index.d.ts +1 -1
  40. package/dist/wallets/walletConnectors/abcWallet/index.js +35 -33
  41. package/dist/wallets/walletConnectors/abcWallet/sessionUtils.js +2 -2
  42. package/dist/wallets/walletConnectors/abcWallet/types.d.ts +11 -0
  43. package/dist/wallets/walletConnectors/abcWallet/utils.js +2 -2
  44. package/dist/wallets/walletConnectors/abcWallet/walletGeneration.js +3 -3
  45. package/dist/wallets/walletConnectors/{chunk-VDWJ3NQ5.js → chunk-25ZDAJ3L.js} +1 -1
  46. package/dist/wallets/walletConnectors/chunk-4JZPP3S7.js +380 -0
  47. package/dist/wallets/walletConnectors/{chunk-HHZ3JZRH.js → chunk-4YEALKXG.js} +74 -14
  48. package/dist/wallets/walletConnectors/{chunk-IN3HEGZM.js → chunk-645DT4TS.js} +46 -5
  49. package/dist/wallets/walletConnectors/{chunk-XNA5NIFE.js → chunk-6TAU7OQK.js} +7 -4
  50. package/dist/wallets/walletConnectors/{chunk-MO2AXXLI.js → chunk-FKI5AZVH.js} +1 -1
  51. package/dist/wallets/walletConnectors/{chunk-JADQLTFW.js → chunk-H2AZTZMM.js} +1 -1
  52. package/dist/wallets/walletConnectors/{chunk-NULM3THX.js → chunk-HWRZGGGN.js} +1 -1
  53. package/dist/wallets/walletConnectors/{chunk-BHEVY4QY.js → chunk-KIYXONNH.js} +35 -2
  54. package/dist/wallets/walletConnectors/{chunk-NU3ITJNK.js → chunk-L6FCF3FH.js} +94 -736
  55. package/dist/wallets/walletConnectors/{chunk-ACLPF2UW.js → chunk-LIGH2LEU.js} +1 -1
  56. package/dist/wallets/walletConnectors/chunk-OASBABPG.js +746 -0
  57. package/dist/wallets/walletConnectors/{chunk-A66MTFML.js → chunk-PF65YS3T.js} +1 -1
  58. package/dist/wallets/walletConnectors/{chunk-6WF4SXLB.js → chunk-QKK3OPQA.js} +1 -1
  59. package/dist/wallets/walletConnectors/{chunk-3LF7FVL6.js → chunk-RGYZNNB6.js} +1 -1
  60. package/dist/wallets/walletConnectors/{chunk-DPTDOCWL.js → chunk-RX2VOIUB.js} +4 -1
  61. package/dist/wallets/walletConnectors/{chunk-YV6IZWGE.js → chunk-URS2KVYK.js} +45 -2
  62. package/dist/wallets/walletConnectors/{chunk-BXH3GDX5.js → chunk-YKFI6ZGM.js} +1 -1
  63. package/dist/wallets/walletConnectors/index.js +47 -45
  64. package/package.json +1 -1
  65. package/dist/wallets/walletConnectors/chunk-CABLJOMU.js +0 -194
  66. package/dist/wallets/walletConnectors/chunk-J3YPHDHM.js +0 -827
  67. package/dist/wallets/walletConnectors/chunk-J566FC7T.js +0 -54
  68. package/dist/wallets/walletConnectors/chunk-OHQXPSR6.js +0 -300
  69. package/dist/wallets/walletConnectors/chunk-OMOYFHBT.js +0 -1485
@@ -1,1485 +0,0 @@
1
- "use client";
2
- import {
3
- hexToNumber,
4
- numberToHex
5
- } from "./chunk-A66MTFML.js";
6
- import {
7
- TalkenApiError
8
- } from "./chunk-4P3SPC44.js";
9
- import {
10
- getCredentialManager
11
- } from "./chunk-6WF4SXLB.js";
12
-
13
- // src/wallets/walletConnectors/abcWallet/abcProvider.ts
14
- import { getTalkenApiClient } from "@talken/talkenkit";
15
- import { parseGwei } from "viem";
16
-
17
- // src/config/networks.ts
18
- var NETWORK_CONFIGS = {
19
- // Ethereum Mainnet
20
- 1: {
21
- chainId: 1,
22
- network: "ethereum",
23
- name: "Ethereum",
24
- type: "EVM" /* EVM */,
25
- isTestnet: false,
26
- explorer: "https://etherscan.io",
27
- website: "https://ethereum.org",
28
- nativeCurrency: {
29
- name: "Ether",
30
- symbol: "ETH",
31
- decimals: 18
32
- },
33
- apiSupport: { tokens: true, nft: true, transactions: true },
34
- signSupport: { legacy: true, eip1559: true }
35
- },
36
- // Ethereum Sepolia Testnet
37
- 11155111: {
38
- chainId: 11155111,
39
- network: "ethereum_sepolia",
40
- name: "Ethereum Sepolia",
41
- type: "EVM" /* EVM */,
42
- isTestnet: true,
43
- explorer: "https://sepolia.etherscan.io",
44
- website: "https://ethereum.org",
45
- nativeCurrency: {
46
- name: "Sepolia Ether",
47
- symbol: "ETH",
48
- decimals: 18
49
- },
50
- apiSupport: { tokens: true, nft: true, transactions: true },
51
- signSupport: { legacy: true, eip1559: true }
52
- },
53
- // Ethereum Holesky Testnet
54
- 17e3: {
55
- chainId: 17e3,
56
- network: "ethereum_holesky",
57
- name: "Ethereum Holesky",
58
- type: "EVM" /* EVM */,
59
- isTestnet: true,
60
- explorer: "https://holesky.etherscan.io",
61
- website: "https://ethereum.org",
62
- nativeCurrency: {
63
- name: "Holesky Ether",
64
- symbol: "ETH",
65
- decimals: 18
66
- },
67
- apiSupport: { tokens: true, nft: true, transactions: true },
68
- signSupport: { legacy: true, eip1559: true }
69
- },
70
- // Kaia Mainnet (formerly Klaytn)
71
- 8217: {
72
- chainId: 8217,
73
- network: "kaia",
74
- name: "Kaia Mainnet",
75
- type: "EVM" /* EVM */,
76
- isTestnet: false,
77
- explorer: "https://kaiascan.io",
78
- website: "https://kaia.io",
79
- nativeCurrency: {
80
- name: "Kaia",
81
- symbol: "KAIA",
82
- decimals: 18
83
- },
84
- apiSupport: { tokens: true, nft: true, transactions: true },
85
- signSupport: { legacy: true, eip1559: true }
86
- },
87
- // Kaia Kairos Testnet
88
- 1001: {
89
- chainId: 1001,
90
- network: "kaia_kairos",
91
- name: "Kaia Kairos Testnet",
92
- type: "EVM" /* EVM */,
93
- isTestnet: true,
94
- explorer: "https://kairos.kaiascan.io",
95
- website: "https://kaia.io",
96
- nativeCurrency: {
97
- name: "Kaia",
98
- symbol: "KAIA",
99
- decimals: 18
100
- },
101
- apiSupport: { tokens: true, nft: true, transactions: true },
102
- signSupport: { legacy: true, eip1559: true }
103
- },
104
- // Polygon Mainnet
105
- 137: {
106
- chainId: 137,
107
- network: "polygon",
108
- name: "Polygon",
109
- type: "EVM" /* EVM */,
110
- isTestnet: false,
111
- explorer: "https://polygonscan.com",
112
- website: "https://polygon.technology",
113
- nativeCurrency: {
114
- name: "MATIC",
115
- symbol: "MATIC",
116
- decimals: 18
117
- },
118
- apiSupport: { tokens: true, nft: true, transactions: true },
119
- signSupport: { legacy: true, eip1559: true }
120
- },
121
- // Polygon Amoy Testnet
122
- 80002: {
123
- chainId: 80002,
124
- network: "polygon_amoy",
125
- name: "Polygon Amoy Testnet",
126
- type: "EVM" /* EVM */,
127
- isTestnet: true,
128
- explorer: "https://amoy.polygonscan.com",
129
- website: "https://polygon.technology",
130
- nativeCurrency: {
131
- name: "MATIC",
132
- symbol: "MATIC",
133
- decimals: 18
134
- },
135
- apiSupport: { tokens: true, nft: true, transactions: true },
136
- signSupport: { legacy: true, eip1559: true }
137
- },
138
- // Binance Smart Chain Mainnet
139
- 56: {
140
- chainId: 56,
141
- network: "binance",
142
- name: "Binance Smart Chain Mainnet",
143
- type: "EVM" /* EVM */,
144
- isTestnet: false,
145
- explorer: "https://bscscan.com",
146
- website: "https://www.bnbchain.org/en/bnb-smart-chain",
147
- nativeCurrency: {
148
- name: "BNB",
149
- symbol: "BNB",
150
- decimals: 18
151
- },
152
- apiSupport: { tokens: true, nft: true, transactions: true },
153
- signSupport: { legacy: true, eip1559: true }
154
- },
155
- // Binance Smart Chain Testnet
156
- 97: {
157
- chainId: 97,
158
- network: "binance_testnet",
159
- name: "Binance Smart Chain Testnet",
160
- type: "EVM" /* EVM */,
161
- isTestnet: true,
162
- explorer: "https://testnet.bscscan.com",
163
- website: "https://www.bnbchain.org/en/bnb-smart-chain",
164
- nativeCurrency: {
165
- name: "BNB",
166
- symbol: "BNB",
167
- decimals: 18
168
- },
169
- apiSupport: { tokens: true, nft: true, transactions: true },
170
- signSupport: { legacy: true, eip1559: true }
171
- },
172
- // Arbitrum One
173
- 42161: {
174
- chainId: 42161,
175
- network: "arbitrum",
176
- name: "Arbitrum One",
177
- type: "EVM" /* EVM */,
178
- isTestnet: false,
179
- explorer: "https://arbiscan.io",
180
- website: "https://arbitrum.io",
181
- nativeCurrency: {
182
- name: "Ether",
183
- symbol: "ETH",
184
- decimals: 18
185
- },
186
- apiSupport: { tokens: true, nft: true, transactions: true },
187
- signSupport: { legacy: true, eip1559: true }
188
- },
189
- // Arbitrum Sepolia
190
- 421614: {
191
- chainId: 421614,
192
- network: "arbitrum_sepolia",
193
- name: "Arbitrum Sepolia",
194
- type: "EVM" /* EVM */,
195
- isTestnet: true,
196
- explorer: "https://sepolia.arbiscan.io",
197
- website: "https://arbitrum.io",
198
- nativeCurrency: {
199
- name: "Ether",
200
- symbol: "ETH",
201
- decimals: 18
202
- },
203
- apiSupport: { tokens: true, nft: true, transactions: true },
204
- signSupport: { legacy: true, eip1559: true }
205
- },
206
- // Optimism Mainnet
207
- 10: {
208
- chainId: 10,
209
- network: "optimism",
210
- name: "Optimism",
211
- type: "EVM" /* EVM */,
212
- isTestnet: false,
213
- explorer: "https://optimistic.etherscan.io",
214
- website: "https://optimism.io",
215
- nativeCurrency: {
216
- name: "Ether",
217
- symbol: "ETH",
218
- decimals: 18
219
- },
220
- apiSupport: { tokens: true, nft: true, transactions: true },
221
- signSupport: { legacy: true, eip1559: true }
222
- },
223
- // Optimism Sepolia
224
- 420: {
225
- chainId: 420,
226
- network: "optimism_sepolia",
227
- name: "Optimism Sepolia",
228
- type: "EVM" /* EVM */,
229
- isTestnet: true,
230
- explorer: "https://sepolia-optimism.etherscan.io",
231
- website: "https://optimism.io",
232
- nativeCurrency: {
233
- name: "Ether",
234
- symbol: "ETH",
235
- decimals: 18
236
- },
237
- apiSupport: { tokens: true, nft: true, transactions: true },
238
- signSupport: { legacy: true, eip1559: true }
239
- },
240
- // Avalanche C-Chain
241
- 43114: {
242
- chainId: 43114,
243
- network: "avalanche",
244
- name: "Avalanche C-Chain",
245
- type: "EVM" /* EVM */,
246
- isTestnet: false,
247
- explorer: "https://avascan.info/blockchain/c/home",
248
- website: "https://avax.network",
249
- nativeCurrency: {
250
- name: "Avalanche",
251
- symbol: "AVAX",
252
- decimals: 18
253
- },
254
- apiSupport: { tokens: true, nft: true, transactions: true },
255
- signSupport: { legacy: true, eip1559: true }
256
- },
257
- // Avalanche Fuji Testnet
258
- 43113: {
259
- chainId: 43113,
260
- network: "avalanche_fuji",
261
- name: "Avalanche Fuji Testnet",
262
- type: "EVM" /* EVM */,
263
- isTestnet: true,
264
- explorer: "https://testnet.avascan.info",
265
- website: "https://avax.network",
266
- nativeCurrency: {
267
- name: "Avalanche",
268
- symbol: "AVAX",
269
- decimals: 18
270
- },
271
- apiSupport: { tokens: false, nft: false, transactions: false },
272
- signSupport: { legacy: true, eip1559: true }
273
- },
274
- // Mantle Mainnet
275
- 5e3: {
276
- chainId: 5e3,
277
- network: "mantle",
278
- name: "Mantle Mainnet",
279
- type: "EVM" /* EVM */,
280
- isTestnet: false,
281
- explorer: "https://explorer.mantle.xyz",
282
- website: "https://www.mantle.xyz",
283
- nativeCurrency: {
284
- name: "Mantle",
285
- symbol: "MNT",
286
- decimals: 18
287
- },
288
- apiSupport: { tokens: true, nft: true, transactions: true },
289
- signSupport: { legacy: true, eip1559: true }
290
- },
291
- // Mantle Testnet
292
- 5001: {
293
- chainId: 5001,
294
- network: "mantle_testnet",
295
- name: "Mantle Testnet",
296
- type: "EVM" /* EVM */,
297
- isTestnet: true,
298
- explorer: "https://sepolia.mantlescan.xyz",
299
- website: "https://www.mantle.xyz",
300
- nativeCurrency: {
301
- name: "Mantle",
302
- symbol: "MNT",
303
- decimals: 18
304
- },
305
- apiSupport: { tokens: true, nft: true, transactions: true },
306
- signSupport: { legacy: true, eip1559: true }
307
- },
308
- // Moonbeam
309
- 1284: {
310
- chainId: 1284,
311
- network: "moonbeam",
312
- name: "Moonbeam",
313
- type: "EVM" /* EVM */,
314
- isTestnet: false,
315
- explorer: "https://moonbeam.moonscan.io",
316
- website: "https://moonbeam.network",
317
- nativeCurrency: {
318
- name: "Glimmer",
319
- symbol: "GLMR",
320
- decimals: 18
321
- },
322
- apiSupport: { tokens: true, nft: true, transactions: true },
323
- signSupport: { legacy: true, eip1559: true }
324
- },
325
- // Moonriver
326
- 1285: {
327
- chainId: 1285,
328
- network: "moonriver",
329
- name: "Moonriver",
330
- type: "EVM" /* EVM */,
331
- isTestnet: false,
332
- explorer: "https://moonriver.moonscan.io",
333
- website: "https://moonbeam.network/networks/moonriver",
334
- nativeCurrency: {
335
- name: "Moonriver",
336
- symbol: "MOVR",
337
- decimals: 18
338
- },
339
- apiSupport: { tokens: true, nft: true, transactions: true },
340
- signSupport: { legacy: true, eip1559: true }
341
- },
342
- // Scroll Mainnet
343
- 534352: {
344
- chainId: 534352,
345
- network: "scroll",
346
- name: "Scroll",
347
- type: "EVM" /* EVM */,
348
- isTestnet: false,
349
- explorer: "https://scrollscan.co",
350
- website: "https://scroll.io",
351
- nativeCurrency: {
352
- name: "Ether",
353
- symbol: "ETH",
354
- decimals: 18
355
- },
356
- apiSupport: { tokens: true, nft: true, transactions: true },
357
- signSupport: { legacy: true, eip1559: true }
358
- },
359
- // Scroll Testnet
360
- 534351: {
361
- chainId: 534351,
362
- network: "scroll_testnet",
363
- name: "Scroll Testnet",
364
- type: "EVM" /* EVM */,
365
- isTestnet: true,
366
- explorer: "https://sepolia.scrollscan.com",
367
- website: "https://scroll.io",
368
- nativeCurrency: {
369
- name: "Ether",
370
- symbol: "ETH",
371
- decimals: 18
372
- },
373
- apiSupport: { tokens: true, nft: true, transactions: true },
374
- signSupport: { legacy: true, eip1559: true }
375
- },
376
- // Silicon Mainnet
377
- 2355: {
378
- chainId: 2355,
379
- network: "silicon",
380
- name: "Silicon",
381
- type: "EVM" /* EVM */,
382
- isTestnet: false,
383
- explorer: "https://scope.silicon.network",
384
- website: "https://silicon.network",
385
- nativeCurrency: {
386
- name: "Ether",
387
- symbol: "ETH",
388
- decimals: 18
389
- },
390
- apiSupport: { tokens: true, nft: true, transactions: true },
391
- signSupport: { legacy: true, eip1559: true }
392
- },
393
- // Silicon Sepolia
394
- 1722641160: {
395
- chainId: 1722641160,
396
- network: "silicon_sepolia",
397
- name: "Silicon Sepolia",
398
- type: "EVM" /* EVM */,
399
- isTestnet: true,
400
- explorer: "https://scope-sepolia.silicon.network",
401
- website: "https://silicon.network",
402
- nativeCurrency: {
403
- name: "Ether",
404
- symbol: "ETH",
405
- decimals: 18
406
- },
407
- apiSupport: { tokens: true, nft: true, transactions: true },
408
- signSupport: { legacy: true, eip1559: true }
409
- },
410
- // Six Protocol
411
- 98: {
412
- chainId: 98,
413
- network: "six_evm",
414
- name: "Six Protocol",
415
- type: "EVM" /* EVM */,
416
- isTestnet: false,
417
- explorer: "https://v2.sixscan.io",
418
- website: "https://www.six.network",
419
- nativeCurrency: {
420
- name: "SIX",
421
- symbol: "SIX",
422
- decimals: 18
423
- },
424
- apiSupport: { tokens: true, nft: false, transactions: true },
425
- signSupport: { legacy: true, eip1559: false }
426
- },
427
- // Six Protocol Testnet
428
- 150: {
429
- chainId: 150,
430
- network: "six_evm_testnet",
431
- name: "Six Protocol Testnet",
432
- type: "EVM" /* EVM */,
433
- isTestnet: true,
434
- explorer: "https://v2.fivenet.sixscan.io",
435
- website: "https://www.six.network",
436
- nativeCurrency: {
437
- name: "SIX",
438
- symbol: "SIX",
439
- decimals: 18
440
- },
441
- apiSupport: { tokens: true, nft: false, transactions: true },
442
- signSupport: { legacy: true, eip1559: false }
443
- },
444
- // Wemix Mainnet
445
- 1111: {
446
- chainId: 1111,
447
- network: "wemix",
448
- name: "Wemix3.0 Mainnet",
449
- type: "EVM" /* EVM */,
450
- isTestnet: false,
451
- explorer: "https://explorer.wemix.com",
452
- website: "https://wemix.com",
453
- nativeCurrency: {
454
- name: "WEMIX",
455
- symbol: "WEMIX",
456
- decimals: 18
457
- },
458
- apiSupport: { tokens: true, nft: true, transactions: true },
459
- signSupport: { legacy: true, eip1559: true }
460
- },
461
- // Wemix Testnet
462
- 1112: {
463
- chainId: 1112,
464
- network: "wemix_testnet",
465
- name: "Wemix3.0 Testnet",
466
- type: "EVM" /* EVM */,
467
- isTestnet: true,
468
- explorer: "https://explorer.test.wemix.com",
469
- website: "https://wemix.com",
470
- nativeCurrency: {
471
- name: "WEMIX",
472
- symbol: "WEMIX",
473
- decimals: 18
474
- },
475
- apiSupport: { tokens: true, nft: true, transactions: true },
476
- signSupport: { legacy: true, eip1559: true }
477
- },
478
- // Taiko Mainnet
479
- 167e3: {
480
- chainId: 167e3,
481
- network: "taiko",
482
- name: "Taiko Mainnet",
483
- type: "EVM" /* EVM */,
484
- isTestnet: false,
485
- explorer: "https://taikoscan.io",
486
- website: "https://taiko.xyz",
487
- nativeCurrency: {
488
- name: "Ether",
489
- symbol: "ETH",
490
- decimals: 18
491
- },
492
- apiSupport: { tokens: true, nft: true, transactions: true },
493
- signSupport: { legacy: true, eip1559: true }
494
- },
495
- // Taiko Hekla Testnet
496
- 167009: {
497
- chainId: 167009,
498
- network: "taiko_hekla",
499
- name: "Taiko Hekla Testnet",
500
- type: "EVM" /* EVM */,
501
- isTestnet: true,
502
- explorer: "https://hekla.taikoscan.io",
503
- website: "https://taiko.xyz",
504
- nativeCurrency: {
505
- name: "Ether",
506
- symbol: "ETH",
507
- decimals: 18
508
- },
509
- apiSupport: { tokens: true, nft: true, transactions: true },
510
- signSupport: { legacy: true, eip1559: true }
511
- },
512
- // Base Mainnet
513
- 8453: {
514
- chainId: 8453,
515
- network: "base",
516
- name: "Base",
517
- type: "EVM" /* EVM */,
518
- isTestnet: false,
519
- explorer: "https://basescan.org",
520
- website: "https://base.org",
521
- nativeCurrency: {
522
- name: "Ether",
523
- symbol: "ETH",
524
- decimals: 18
525
- },
526
- apiSupport: { tokens: true, nft: true, transactions: true },
527
- signSupport: { legacy: true, eip1559: true }
528
- },
529
- // Base Sepolia Testnet
530
- 84532: {
531
- chainId: 84532,
532
- network: "base_sepolia",
533
- name: "Base Sepolia",
534
- type: "EVM" /* EVM */,
535
- isTestnet: true,
536
- explorer: "https://sepolia.basescan.org",
537
- website: "https://base.org",
538
- nativeCurrency: {
539
- name: "Ether",
540
- symbol: "ETH",
541
- decimals: 18
542
- },
543
- apiSupport: { tokens: true, nft: true, transactions: true },
544
- signSupport: { legacy: true, eip1559: true }
545
- },
546
- // ChainBounty Mainnet
547
- 51828: {
548
- chainId: 51828,
549
- network: "chainbounty",
550
- name: "ChainBounty Mainnet",
551
- type: "EVM" /* EVM */,
552
- isTestnet: false,
553
- explorer: "https://scan.chainbounty.io",
554
- website: "https://chainbounty.io",
555
- nativeCurrency: {
556
- name: "ChainBounty",
557
- symbol: "CBY",
558
- decimals: 18
559
- },
560
- apiSupport: { tokens: true, nft: true, transactions: true },
561
- signSupport: { legacy: true, eip1559: true }
562
- },
563
- // ChainBounty Testnet
564
- 56580: {
565
- chainId: 56580,
566
- network: "chainbounty_testnet",
567
- name: "ChainBounty Testnet",
568
- type: "EVM" /* EVM */,
569
- isTestnet: true,
570
- explorer: "https://test.scan.chainbounty.io",
571
- website: "https://chainbounty.io",
572
- nativeCurrency: {
573
- name: "ChainBounty",
574
- symbol: "CBY",
575
- decimals: 18
576
- },
577
- apiSupport: { tokens: true, nft: true, transactions: true },
578
- signSupport: { legacy: true, eip1559: true }
579
- },
580
- // Aptos Mainnet (Non-EVM)
581
- aptos: {
582
- chainId: null,
583
- network: "aptos",
584
- name: "Aptos",
585
- type: "Non-EVM" /* NON_EVM */,
586
- isTestnet: false,
587
- explorer: "https://explorer.aptoslabs.com/?network=mainnet",
588
- website: "https://aptos.dev",
589
- nativeCurrency: {
590
- name: "Aptos",
591
- symbol: "APT",
592
- decimals: 8
593
- },
594
- apiSupport: { tokens: true, nft: true, transactions: true },
595
- signSupport: { legacy: true, eip1559: false }
596
- },
597
- // Aptos Testnet (Non-EVM)
598
- aptos_testnet: {
599
- chainId: null,
600
- network: "aptos_testnet",
601
- name: "Aptos Testnet",
602
- type: "Non-EVM" /* NON_EVM */,
603
- isTestnet: true,
604
- explorer: "https://explorer.aptoslabs.com/?network=testnet",
605
- website: "https://aptos.dev",
606
- nativeCurrency: {
607
- name: "Aptos",
608
- symbol: "APT",
609
- decimals: 8
610
- },
611
- apiSupport: { tokens: true, nft: true, transactions: true },
612
- signSupport: { legacy: true, eip1559: false }
613
- },
614
- // Bitcoin Mainnet
615
- bitcoin: {
616
- chainId: null,
617
- network: "bitcoin",
618
- name: "Bitcoin Mainnet",
619
- type: "Bitcoin" /* BITCOIN */,
620
- isTestnet: false,
621
- explorer: "https://blockstream.info",
622
- website: "https://bitcoin.org",
623
- nativeCurrency: {
624
- name: "Bitcoin",
625
- symbol: "BTC",
626
- decimals: 8
627
- },
628
- apiSupport: { tokens: true, nft: false, transactions: true },
629
- signSupport: { legacy: true, eip1559: false }
630
- },
631
- // Bitcoin Testnet
632
- bitcoin_testnet: {
633
- chainId: null,
634
- network: "bitcoin_testnet",
635
- name: "Bitcoin Testnet",
636
- type: "Bitcoin" /* BITCOIN */,
637
- isTestnet: true,
638
- explorer: "https://blockstream.info/testnet",
639
- website: "https://bitcoin.org",
640
- nativeCurrency: {
641
- name: "Bitcoin",
642
- symbol: "BTC",
643
- decimals: 8
644
- },
645
- apiSupport: { tokens: true, nft: false, transactions: true },
646
- signSupport: { legacy: true, eip1559: false }
647
- },
648
- // Tron Mainnet
649
- tron: {
650
- chainId: null,
651
- network: "tron",
652
- name: "Tron Mainnet",
653
- type: "TRX" /* TRON */,
654
- isTestnet: false,
655
- explorer: "https://tronscan.org",
656
- website: "https://tron.network",
657
- nativeCurrency: {
658
- name: "Tronix",
659
- symbol: "TRX",
660
- decimals: 6
661
- },
662
- apiSupport: { tokens: true, nft: true, transactions: true },
663
- signSupport: { legacy: true, eip1559: true }
664
- },
665
- // Tron Nile Testnet
666
- tron_nile: {
667
- chainId: null,
668
- network: "tron_nile",
669
- name: "Tron Nile Testnet",
670
- type: "TRX" /* TRON */,
671
- isTestnet: true,
672
- explorer: "https://nile.tronscan.org",
673
- website: "https://tron.network",
674
- nativeCurrency: {
675
- name: "Tronix",
676
- symbol: "TRX",
677
- decimals: 6
678
- },
679
- apiSupport: { tokens: true, nft: true, transactions: true },
680
- signSupport: { legacy: true, eip1559: true }
681
- },
682
- // ICP Mainnet
683
- icp: {
684
- chainId: null,
685
- network: "icp",
686
- name: "Internet Computer",
687
- type: "ICP" /* ICP */,
688
- isTestnet: false,
689
- explorer: "https://dashboard.internetcomputer.org",
690
- website: "https://internetcomputer.org",
691
- nativeCurrency: {
692
- name: "ICP",
693
- symbol: "ICP",
694
- decimals: 8
695
- },
696
- apiSupport: { tokens: true, nft: true, transactions: true },
697
- signSupport: { legacy: true, eip1559: true }
698
- }
699
- };
700
- var NETWORK_BY_PARAM = Object.values(
701
- NETWORK_CONFIGS
702
- ).reduce(
703
- (acc, config) => {
704
- acc[config.network] = config;
705
- return acc;
706
- },
707
- {}
708
- );
709
- function getNetworkName(chainId, fallback = "ethereum") {
710
- return NETWORK_CONFIGS[chainId]?.network ?? fallback;
711
- }
712
- var CHAIN_ID_TO_KEY = {
713
- // Mainnet
714
- 1: "ethereum",
715
- 42161: "arbitrum",
716
- 8217: "kaia",
717
- 56: "bsc",
718
- 8453: "base",
719
- 137: "polygon",
720
- 43114: "avalanche",
721
- 5e3: "mantle",
722
- 51828: "chainbounty",
723
- // Testnet
724
- 11155111: "sepolia",
725
- 421614: "arbitrumSepolia",
726
- 1001: "kaiaKairos",
727
- 97: "bscTestnet",
728
- 84532: "baseSepolia",
729
- 80002: "polygonAmoy",
730
- 43113: "avalancheFuji",
731
- 5003: "mantleSepolia",
732
- 56580: "chainbountyTestnet",
733
- 998: "hyperevmTestnet"
734
- };
735
- function getChainKey(chainId) {
736
- const key = CHAIN_ID_TO_KEY[chainId];
737
- if (!key) {
738
- throw new Error(`Unsupported chainId for tx endpoint: ${chainId}`);
739
- }
740
- return key;
741
- }
742
-
743
- // src/wallets/walletConnectors/abcWallet/abcProvider.ts
744
- var EventEmitter = class {
745
- constructor() {
746
- this.events = /* @__PURE__ */ new Map();
747
- }
748
- on(event, listener) {
749
- if (!this.events.has(event)) {
750
- this.events.set(event, []);
751
- }
752
- this.events.get(event).push(listener);
753
- return this;
754
- }
755
- off(event, listener) {
756
- const listeners = this.events.get(event);
757
- if (listeners) {
758
- const index = listeners.indexOf(listener);
759
- if (index !== -1) {
760
- listeners.splice(index, 1);
761
- }
762
- }
763
- return this;
764
- }
765
- removeListener(event, listener) {
766
- return this.off(event, listener);
767
- }
768
- emit(event, ...args) {
769
- const listeners = this.events.get(event);
770
- if (listeners) {
771
- for (const listener of listeners) {
772
- listener(...args);
773
- }
774
- return true;
775
- }
776
- return false;
777
- }
778
- removeAllListeners(event) {
779
- if (event) {
780
- this.events.delete(event);
781
- } else {
782
- this.events.clear();
783
- }
784
- return this;
785
- }
786
- };
787
- var ProviderRpcError = class extends Error {
788
- constructor(code, message, data) {
789
- super(message);
790
- this.code = code;
791
- this.data = data;
792
- this.name = "ProviderRpcError";
793
- }
794
- };
795
- var ErrorCode = {
796
- USER_REJECTED: 4001,
797
- UNAUTHORIZED: 4100,
798
- UNSUPPORTED_METHOD: 4200,
799
- DISCONNECTED: 4900,
800
- CHAIN_DISCONNECTED: 4901,
801
- INVALID_PARAMS: -32602,
802
- INTERNAL_ERROR: -32603
803
- };
804
- var AbcEvmProvider = class extends EventEmitter {
805
- constructor(talkenApi) {
806
- super();
807
- this.wallet = null;
808
- this.chainId = 1;
809
- // Default to Ethereum mainnet
810
- this.connected = false;
811
- this.talkenApi = talkenApi;
812
- }
813
- getRecoveryEmail() {
814
- const walletEmail = this.wallet?.email?.trim();
815
- if (walletEmail) {
816
- return walletEmail;
817
- }
818
- return getCredentialManager().getEmail() || void 0;
819
- }
820
- /**
821
- * Set wallet information
822
- */
823
- setWallet(wallet) {
824
- const previousAddress = this.wallet?.address;
825
- const previousChainId = this.chainId;
826
- this.wallet = wallet;
827
- this.chainId = wallet.chainId;
828
- this.connected = true;
829
- if (previousAddress !== wallet.address) {
830
- this.emit("accountsChanged", [wallet.address]);
831
- }
832
- if (previousChainId !== wallet.chainId) {
833
- this.emit("chainChanged", numberToHex(wallet.chainId));
834
- }
835
- this.emit("connect", { chainId: numberToHex(wallet.chainId) });
836
- }
837
- /**
838
- * Clear wallet (disconnect)
839
- */
840
- clearWallet() {
841
- this.wallet = null;
842
- this.connected = false;
843
- this.emit("disconnect", {
844
- code: ErrorCode.DISCONNECTED,
845
- message: "User disconnected"
846
- });
847
- this.emit("accountsChanged", []);
848
- }
849
- /**
850
- * Set request interceptor for sign confirmation
851
- * The interceptor is called before signing operations to show confirmation UI
852
- */
853
- setRequestInterceptor(interceptor) {
854
- this.requestInterceptor = interceptor;
855
- }
856
- /**
857
- * Set TalkenApiClient for backend-proxied transaction flow
858
- * When set, transaction methods will use a single API call instead of multi-step WaaS
859
- */
860
- setTalkenApi(talkenApi) {
861
- this.talkenApi = talkenApi;
862
- }
863
- getTalkenApiClientOrThrow() {
864
- const api = this.talkenApi || getTalkenApiClient();
865
- if (!api) {
866
- throw new ProviderRpcError(
867
- ErrorCode.INTERNAL_ERROR,
868
- "TalkenApiClient not initialized"
869
- );
870
- }
871
- return api;
872
- }
873
- /**
874
- * Check if an error is a "Missing required wallet fields" 502 from the server.
875
- * When the server's in-memory signing credential cache is cold, it needs
876
- * a wallet.generate() call (idempotent create/recover) to repopulate.
877
- */
878
- isSigningCredentialError(error) {
879
- return error instanceof TalkenApiError && error.statusCode === 502 && error.message.includes("Missing required wallet fields");
880
- }
881
- /**
882
- * Refresh server-side signing credentials.
883
- *
884
- * Strategy (in priority order):
885
- * 1. PIN hash in memory → wallet.generate() to repopulate server cache
886
- * 2. Neither available → throw UNAUTHORIZED
887
- *
888
- * Note: sessionStorage-cached credentials (evmCreds) are automatically
889
- * attached to every signing request by TalkenApiClient, so the server
890
- * can use them as fallback without a separate refresh call.
891
- */
892
- async refreshSigningCredentials() {
893
- const credMgr = getCredentialManager();
894
- const pinHash = credMgr.getPinHash();
895
- const email = this.getRecoveryEmail();
896
- if (pinHash && email) {
897
- const api = this.getTalkenApiClientOrThrow();
898
- console.log(
899
- "[AbcProvider] Refreshing signing credentials via wallet.generate..."
900
- );
901
- await api.wallet.generate(pinHash, email);
902
- console.log("[AbcProvider] Signing credentials refreshed via PIN");
903
- return;
904
- }
905
- console.warn(
906
- "[AbcProvider] Cannot refresh signing credentials \u2014 PIN hash or email missing"
907
- );
908
- throw new ProviderRpcError(
909
- ErrorCode.UNAUTHORIZED,
910
- "Session expired. Please reconnect and verify your PIN."
911
- );
912
- }
913
- /**
914
- * Wrap a signing operation with auto-retry on "Missing required wallet fields" error.
915
- * On first failure, refreshes the server's signing credential cache and retries once.
916
- */
917
- async withSigningCredentialRetry(operation) {
918
- try {
919
- return await operation();
920
- } catch (error) {
921
- if (this.isSigningCredentialError(error)) {
922
- console.log(
923
- "[AbcProvider] Signing credentials missing on server \u2014 attempting refresh and retry"
924
- );
925
- await this.refreshSigningCredentials();
926
- return await operation();
927
- }
928
- throw error;
929
- }
930
- }
931
- /**
932
- * Call request interceptor if configured
933
- * Called by specific signing/transaction methods that need user confirmation
934
- * @returns Resolved transaction with user modifications if changed in confirmation modal
935
- */
936
- async callInterceptor(method, params) {
937
- if (!this.requestInterceptor) {
938
- return void 0;
939
- }
940
- const request = {
941
- method,
942
- params,
943
- chainId: this.chainId,
944
- address: this.wallet?.address || ""
945
- };
946
- return this.requestInterceptor(request);
947
- }
948
- /**
949
- * EIP-1193 request method
950
- */
951
- async request(args) {
952
- const { method, params } = args;
953
- switch (method) {
954
- case "eth_requestAccounts":
955
- return this.eth_requestAccounts();
956
- case "eth_accounts":
957
- return this.eth_accounts();
958
- case "eth_chainId":
959
- return this.eth_chainId();
960
- case "eth_sendTransaction":
961
- case "wallet_sendTransaction":
962
- return this.eth_sendTransaction(params);
963
- case "eth_signTransaction":
964
- return this.eth_signTransaction(params);
965
- case "personal_sign":
966
- return this.personal_sign(params);
967
- case "eth_sign":
968
- return this.eth_sign(params);
969
- case "eth_signTypedData":
970
- case "eth_signTypedData_v3":
971
- case "eth_signTypedData_v4":
972
- return this.eth_signTypedData(params);
973
- case "wallet_getCapabilities":
974
- return this.wallet_getCapabilities();
975
- case "eth_signAuthorization":
976
- return this.eth_signAuthorization(params);
977
- case "wallet_switchEthereumChain":
978
- return this.wallet_switchEthereumChain(params);
979
- case "wallet_addEthereumChain":
980
- return this.wallet_addEthereumChain(params);
981
- case "eth_estimateGas":
982
- return this.eth_estimateGas(params);
983
- case "eth_getTransactionCount":
984
- return this.eth_getTransactionCount(
985
- Array.isArray(params) ? params : []
986
- );
987
- case "eth_blockNumber":
988
- case "eth_call":
989
- case "eth_gasPrice":
990
- case "eth_getBalance":
991
- case "eth_getBlockByHash":
992
- case "eth_getBlockByNumber":
993
- case "eth_getCode":
994
- case "eth_getStorageAt":
995
- case "eth_getTransactionByHash":
996
- case "eth_getTransactionReceipt":
997
- throw new ProviderRpcError(
998
- ErrorCode.UNSUPPORTED_METHOD,
999
- `Method ${method} should be handled by RPC provider`
1000
- );
1001
- default:
1002
- throw new ProviderRpcError(
1003
- ErrorCode.UNSUPPORTED_METHOD,
1004
- `Method ${method} not supported`
1005
- );
1006
- }
1007
- }
1008
- /**
1009
- * Request accounts (EIP-1193)
1010
- */
1011
- async eth_requestAccounts() {
1012
- if (!this.wallet) {
1013
- throw new ProviderRpcError(
1014
- ErrorCode.UNAUTHORIZED,
1015
- "Wallet not connected"
1016
- );
1017
- }
1018
- return [this.wallet.address];
1019
- }
1020
- /**
1021
- * Get accounts
1022
- */
1023
- async eth_accounts() {
1024
- if (!this.wallet) {
1025
- return [];
1026
- }
1027
- return [this.wallet.address];
1028
- }
1029
- /**
1030
- * Get chain ID
1031
- */
1032
- async eth_chainId() {
1033
- return numberToHex(this.chainId);
1034
- }
1035
- /**
1036
- * Send transaction
1037
- */
1038
- async eth_sendTransaction(params) {
1039
- if (!this.wallet) {
1040
- throw new ProviderRpcError(
1041
- ErrorCode.UNAUTHORIZED,
1042
- "Wallet not connected"
1043
- );
1044
- }
1045
- if (!Array.isArray(params) || params.length === 0) {
1046
- throw new ProviderRpcError(
1047
- ErrorCode.INVALID_PARAMS,
1048
- "Invalid transaction params"
1049
- );
1050
- }
1051
- const resolved = await this.callInterceptor("eth_sendTransaction", params);
1052
- const tx = params[0];
1053
- console.log("[AbcProvider] eth_sendTransaction incoming gas params:", {
1054
- gas: tx.gas ?? tx.gasLimit,
1055
- gasPrice: tx.gasPrice,
1056
- maxFeePerGas: tx.maxFeePerGas,
1057
- maxPriorityFeePerGas: tx.maxPriorityFeePerGas
1058
- });
1059
- if (resolved) {
1060
- if (resolved.data) {
1061
- tx.data = resolved.data;
1062
- }
1063
- if (resolved.gasFee?.maxFeePerGas) {
1064
- try {
1065
- const maxFeeWei = parseGwei(resolved.gasFee.maxFeePerGas);
1066
- tx.maxFeePerGas = `0x${maxFeeWei.toString(16)}`;
1067
- } catch (error) {
1068
- console.error(
1069
- "[AbcProvider] \u274C Failed to parse maxFeePerGas:",
1070
- error
1071
- );
1072
- }
1073
- }
1074
- if (resolved.gasFee?.maxPriorityFeePerGas) {
1075
- try {
1076
- const priorityFeeWei = parseGwei(
1077
- resolved.gasFee.maxPriorityFeePerGas
1078
- );
1079
- tx.maxPriorityFeePerGas = `0x${priorityFeeWei.toString(16)}`;
1080
- } catch (error) {
1081
- console.error(
1082
- "[AbcProvider] \u274C Failed to parse maxPriorityFeePerGas:",
1083
- error
1084
- );
1085
- }
1086
- }
1087
- }
1088
- console.log("[AbcProvider] eth_sendTransaction final gas params:", {
1089
- gas: tx.gas ?? tx.gasLimit,
1090
- gasPrice: tx.gasPrice,
1091
- maxFeePerGas: tx.maxFeePerGas,
1092
- maxPriorityFeePerGas: tx.maxPriorityFeePerGas
1093
- });
1094
- const isContractDeployment = !tx.to || tx.to === "0x" || tx.to === "0x0" || tx.to === "0x0000000000000000000000000000000000000000";
1095
- if (isContractDeployment) {
1096
- tx.to = "0x";
1097
- } else if (!tx.to) {
1098
- throw new ProviderRpcError(
1099
- ErrorCode.INVALID_PARAMS,
1100
- 'Transaction must have "to" field'
1101
- );
1102
- }
1103
- const pinHash = getCredentialManager().getPinHash();
1104
- if (!pinHash) {
1105
- throw new ProviderRpcError(
1106
- ErrorCode.INTERNAL_ERROR,
1107
- "PIN hash not found. Please login again."
1108
- );
1109
- }
1110
- const hexValue = tx.value || "0x0";
1111
- const amountWei = BigInt(hexValue).toString();
1112
- const email = this.getRecoveryEmail();
1113
- const api = this.getTalkenApiClientOrThrow();
1114
- const result = await this.withSigningCredentialRetry(
1115
- () => api.evm.sendTransaction({
1116
- chainKey: getChainKey(this.chainId),
1117
- to: tx.to,
1118
- amountWei,
1119
- pin: pinHash,
1120
- data: tx.data || "0x",
1121
- gasLimit: tx.gas || tx.gasLimit,
1122
- maxFeePerGas: tx.maxFeePerGas,
1123
- maxPriorityFeePerGas: tx.maxPriorityFeePerGas,
1124
- ...email && { email }
1125
- })
1126
- );
1127
- return result.txHash;
1128
- }
1129
- /**
1130
- * Sign transaction (without sending)
1131
- */
1132
- async eth_signTransaction(params) {
1133
- if (!this.wallet) {
1134
- throw new ProviderRpcError(
1135
- ErrorCode.UNAUTHORIZED,
1136
- "Wallet not connected"
1137
- );
1138
- }
1139
- if (!Array.isArray(params) || params.length === 0) {
1140
- throw new ProviderRpcError(
1141
- ErrorCode.INVALID_PARAMS,
1142
- "Invalid transaction params"
1143
- );
1144
- }
1145
- const resolved = await this.callInterceptor("eth_signTransaction", params);
1146
- const tx = params[0];
1147
- if (resolved) {
1148
- if (resolved.data) {
1149
- tx.data = resolved.data;
1150
- }
1151
- if (resolved.gasFee?.maxFeePerGas) {
1152
- try {
1153
- const maxFeeWei = parseGwei(resolved.gasFee.maxFeePerGas);
1154
- tx.maxFeePerGas = `0x${maxFeeWei.toString(16)}`;
1155
- } catch (error) {
1156
- console.error(
1157
- "[AbcProvider] \u274C Failed to parse maxFeePerGas:",
1158
- error
1159
- );
1160
- }
1161
- }
1162
- if (resolved.gasFee?.maxPriorityFeePerGas) {
1163
- try {
1164
- const priorityFeeWei = parseGwei(
1165
- resolved.gasFee.maxPriorityFeePerGas
1166
- );
1167
- tx.maxPriorityFeePerGas = `0x${priorityFeeWei.toString(16)}`;
1168
- } catch (error) {
1169
- console.error(
1170
- "[AbcProvider] \u274C Failed to parse maxPriorityFeePerGas:",
1171
- error
1172
- );
1173
- }
1174
- }
1175
- }
1176
- const api = this.getTalkenApiClientOrThrow();
1177
- const pinHash = getCredentialManager().getPinHash() || void 0;
1178
- const email = this.getRecoveryEmail();
1179
- const result = await this.withSigningCredentialRetry(
1180
- () => api.evm.signTransaction({
1181
- network: getNetworkName(this.chainId),
1182
- to: tx.to,
1183
- value: tx.value || "0x0",
1184
- data: tx.data || "0x",
1185
- gasLimit: tx.gas || tx.gasLimit,
1186
- maxFeePerGas: tx.maxFeePerGas,
1187
- maxPriorityFeePerGas: tx.maxPriorityFeePerGas,
1188
- nonce: tx.nonce ? String(Number.parseInt(tx.nonce, 16)) : void 0,
1189
- ...pinHash && { pin: pinHash },
1190
- ...email && { email }
1191
- })
1192
- );
1193
- return result.signature;
1194
- }
1195
- /**
1196
- * Personal sign (EIP-191)
1197
- */
1198
- async personal_sign(params) {
1199
- if (!this.wallet) {
1200
- console.error("[AbcProvider] \u274C Wallet not connected");
1201
- throw new ProviderRpcError(
1202
- ErrorCode.UNAUTHORIZED,
1203
- "Wallet not connected"
1204
- );
1205
- }
1206
- if (!Array.isArray(params) || params.length < 2) {
1207
- console.error("[AbcProvider] \u274C Invalid params:", params);
1208
- throw new ProviderRpcError(
1209
- ErrorCode.INVALID_PARAMS,
1210
- "Invalid personal_sign params"
1211
- );
1212
- }
1213
- await this.callInterceptor("personal_sign", params);
1214
- const [message, address] = params;
1215
- if (address.toLowerCase() !== this.wallet.address.toLowerCase()) {
1216
- console.error("[AbcProvider] \u274C Address mismatch");
1217
- throw new ProviderRpcError(
1218
- ErrorCode.INVALID_PARAMS,
1219
- "Address does not match connected wallet"
1220
- );
1221
- }
1222
- const api = this.getTalkenApiClientOrThrow();
1223
- const network = getNetworkName(this.chainId);
1224
- const pinHash = getCredentialManager().getPinHash() || void 0;
1225
- const email = this.getRecoveryEmail();
1226
- const result = await this.withSigningCredentialRetry(
1227
- () => api.evm.signPersonal({
1228
- network,
1229
- message,
1230
- address,
1231
- pin: pinHash,
1232
- ...email && { email }
1233
- })
1234
- );
1235
- return result.signature;
1236
- }
1237
- /**
1238
- * Eth sign
1239
- */
1240
- async eth_sign(params) {
1241
- if (!Array.isArray(params) || params.length < 2) {
1242
- throw new ProviderRpcError(
1243
- ErrorCode.INVALID_PARAMS,
1244
- "Invalid eth_sign params"
1245
- );
1246
- }
1247
- const [address, message] = params;
1248
- return this.personal_sign([message, address]);
1249
- }
1250
- /**
1251
- * Sign typed data (EIP-712)
1252
- */
1253
- async eth_signTypedData(params) {
1254
- if (!this.wallet) {
1255
- throw new ProviderRpcError(
1256
- ErrorCode.UNAUTHORIZED,
1257
- "Wallet not connected"
1258
- );
1259
- }
1260
- if (!Array.isArray(params) || params.length < 2) {
1261
- throw new ProviderRpcError(
1262
- ErrorCode.INVALID_PARAMS,
1263
- "Invalid signTypedData params"
1264
- );
1265
- }
1266
- await this.callInterceptor("eth_signTypedData_v4", params);
1267
- const [address, typedData] = params;
1268
- if (address.toLowerCase() !== this.wallet.address.toLowerCase()) {
1269
- throw new ProviderRpcError(
1270
- ErrorCode.INVALID_PARAMS,
1271
- "Address does not match connected wallet"
1272
- );
1273
- }
1274
- const api = this.getTalkenApiClientOrThrow();
1275
- const network = getNetworkName(this.chainId);
1276
- const pinHash = getCredentialManager().getPinHash() || void 0;
1277
- const email = this.getRecoveryEmail();
1278
- const result = await this.withSigningCredentialRetry(
1279
- () => api.evm.signTypedData({
1280
- network,
1281
- typedData: typeof typedData === "string" ? typedData : JSON.stringify(typedData),
1282
- pin: pinHash,
1283
- ...email && { email }
1284
- })
1285
- );
1286
- return result.signature;
1287
- }
1288
- /**
1289
- * Return normalized wallet capabilities for ABC embedded wallets.
1290
- * ABC supports EIP-7702 authorization signing via talken-api.
1291
- */
1292
- async wallet_getCapabilities() {
1293
- return {
1294
- supportsTypedDataV4: true,
1295
- supports7702Authorization: true,
1296
- supports5792Batch: false,
1297
- supportsPaymasterService: false,
1298
- supportsPermit2RelayHints: true,
1299
- walletType: "abc-embedded"
1300
- };
1301
- }
1302
- /**
1303
- * Sign EIP-7702 authorization via Talken API.
1304
- */
1305
- async eth_signAuthorization(params) {
1306
- if (!this.wallet) {
1307
- throw new ProviderRpcError(
1308
- ErrorCode.UNAUTHORIZED,
1309
- "Wallet not connected"
1310
- );
1311
- }
1312
- if (!Array.isArray(params) || params.length < 2) {
1313
- throw new ProviderRpcError(
1314
- ErrorCode.INVALID_PARAMS,
1315
- "Invalid signAuthorization params"
1316
- );
1317
- }
1318
- const [address, authorization] = params;
1319
- if (address.toLowerCase() !== this.wallet.address.toLowerCase()) {
1320
- throw new ProviderRpcError(
1321
- ErrorCode.INVALID_PARAMS,
1322
- "Address does not match connected wallet"
1323
- );
1324
- }
1325
- if (!authorization?.address || authorization.chainId == null || authorization.nonce == null) {
1326
- throw new ProviderRpcError(
1327
- ErrorCode.INVALID_PARAMS,
1328
- "Authorization payload is incomplete"
1329
- );
1330
- }
1331
- await this.callInterceptor("eth_signAuthorization", params);
1332
- const api = this.getTalkenApiClientOrThrow();
1333
- const network = getNetworkName(this.chainId);
1334
- const pinHash = getCredentialManager().getPinHash() || void 0;
1335
- const email = this.getRecoveryEmail();
1336
- const chainIdValue = typeof authorization.chainId === "string" ? Number(BigInt(authorization.chainId)) : Number(authorization.chainId);
1337
- const nonceValue = typeof authorization.nonce === "string" ? BigInt(authorization.nonce).toString() : String(authorization.nonce);
1338
- const authAddress = authorization.address;
1339
- const result = await this.withSigningCredentialRetry(
1340
- () => api.evm.signAuthorization({
1341
- network,
1342
- authorization: {
1343
- chainId: chainIdValue,
1344
- address: authAddress,
1345
- nonce: nonceValue
1346
- },
1347
- pin: pinHash,
1348
- ...email && { email }
1349
- })
1350
- );
1351
- return result.authorization;
1352
- }
1353
- /**
1354
- * Switch Ethereum chain
1355
- */
1356
- async wallet_switchEthereumChain(params) {
1357
- if (!Array.isArray(params) || params.length === 0) {
1358
- throw new ProviderRpcError(
1359
- ErrorCode.INVALID_PARAMS,
1360
- "Invalid switchEthereumChain params"
1361
- );
1362
- }
1363
- const { chainId } = params[0];
1364
- const newChainId = hexToNumber(chainId);
1365
- if (this.chainId === newChainId) {
1366
- return null;
1367
- }
1368
- const _previousChainId = this.chainId;
1369
- this.chainId = newChainId;
1370
- if (this.wallet) {
1371
- this.wallet.chainId = newChainId;
1372
- }
1373
- this.emit("chainChanged", numberToHex(newChainId));
1374
- return null;
1375
- }
1376
- /**
1377
- * Add Ethereum chain
1378
- */
1379
- async wallet_addEthereumChain(params) {
1380
- return this.wallet_switchEthereumChain(params);
1381
- }
1382
- /**
1383
- * Get transaction count (nonce) using ABC WaaS API
1384
- */
1385
- async eth_getTransactionCount(params) {
1386
- const address = params[0]?.toLowerCase();
1387
- if (!address) {
1388
- throw new ProviderRpcError(
1389
- ErrorCode.INVALID_PARAMS,
1390
- "Missing address parameter"
1391
- );
1392
- }
1393
- const currentChainId = this.chainId;
1394
- try {
1395
- const api = this.getTalkenApiClientOrThrow();
1396
- const response = await api.evm.getNonce(
1397
- getNetworkName(currentChainId),
1398
- address
1399
- );
1400
- const nonce = response.result !== void 0 ? typeof response.result === "number" ? `0x${response.result.toString(16)}` : response.result : void 0;
1401
- if (!nonce) {
1402
- throw new Error("No result in nonce response");
1403
- }
1404
- return nonce;
1405
- } catch (error) {
1406
- console.error(
1407
- "[AbcEvmProvider] \u274C Failed to get transaction count from ABC WaaS:",
1408
- error
1409
- );
1410
- throw new ProviderRpcError(
1411
- ErrorCode.INTERNAL_ERROR,
1412
- `Failed to get transaction count: ${error instanceof Error ? error.message : String(error)}`
1413
- );
1414
- }
1415
- }
1416
- /**
1417
- * Estimate gas for transaction
1418
- * Uses ABC WaaS gas estimation API with fallback
1419
- */
1420
- async eth_estimateGas(params) {
1421
- if (!Array.isArray(params) || params.length === 0) {
1422
- throw new ProviderRpcError(
1423
- ErrorCode.INVALID_PARAMS,
1424
- "Invalid estimateGas params"
1425
- );
1426
- }
1427
- const tx = params[0];
1428
- if (!tx.to) {
1429
- throw new ProviderRpcError(
1430
- ErrorCode.INVALID_PARAMS,
1431
- 'Transaction must have "to" field'
1432
- );
1433
- }
1434
- try {
1435
- const response = await this.getTalkenApiClientOrThrow().evm.estimateGas({
1436
- network: getNetworkName(this.chainId),
1437
- from: tx.from || this.wallet?.address || "",
1438
- to: tx.to,
1439
- value: tx.value,
1440
- data: tx.data
1441
- });
1442
- if (!response.result) {
1443
- throw new Error("No result in gas estimate response");
1444
- }
1445
- return response.result;
1446
- } catch (error) {
1447
- console.warn(
1448
- "[AbcEvmProvider] Gas estimation failed, using fallback:",
1449
- error
1450
- );
1451
- if (tx.data && tx.data !== "0x") {
1452
- return "0x493e0";
1453
- }
1454
- return "0x5208";
1455
- }
1456
- }
1457
- /**
1458
- * Check if connected
1459
- */
1460
- isConnected() {
1461
- return this.connected;
1462
- }
1463
- /**
1464
- * Get current wallet
1465
- */
1466
- getWallet() {
1467
- return this.wallet;
1468
- }
1469
- /**
1470
- * Get current chain ID
1471
- */
1472
- getChainId() {
1473
- return this.chainId;
1474
- }
1475
- };
1476
- function createAbcEvmProvider(talkenApi) {
1477
- return new AbcEvmProvider(talkenApi);
1478
- }
1479
- var createAbcProvider = createAbcEvmProvider;
1480
-
1481
- export {
1482
- AbcEvmProvider,
1483
- createAbcEvmProvider,
1484
- createAbcProvider
1485
- };