@toruslabs/ethereum-controllers 4.1.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 (88) hide show
  1. package/dist/ethereumControllers.cjs.js +6153 -0
  2. package/dist/ethereumControllers.cjs.js.map +1 -0
  3. package/dist/ethereumControllers.esm.js +5570 -0
  4. package/dist/ethereumControllers.esm.js.map +1 -0
  5. package/dist/ethereumControllers.umd.min.js +3 -0
  6. package/dist/ethereumControllers.umd.min.js.LICENSE.txt +38 -0
  7. package/dist/ethereumControllers.umd.min.js.map +1 -0
  8. package/dist/types/Account/AccountTrackerController.d.ts +35 -0
  9. package/dist/types/Block/PollingBlockTracker.d.ts +14 -0
  10. package/dist/types/Currency/CurrencyController.d.ts +30 -0
  11. package/dist/types/Gas/GasFeeController.d.ts +64 -0
  12. package/dist/types/Gas/IGasFeeController.d.ts +49 -0
  13. package/dist/types/Gas/gasUtil.d.ts +21 -0
  14. package/dist/types/Keyring/KeyringController.d.ts +20 -0
  15. package/dist/types/Message/AbstractMessageController.d.ts +36 -0
  16. package/dist/types/Message/DecryptMessageController.d.ts +20 -0
  17. package/dist/types/Message/EncryptionPublicKeyController.d.ts +20 -0
  18. package/dist/types/Message/MessageController.d.ts +20 -0
  19. package/dist/types/Message/PersonalMessageController.d.ts +20 -0
  20. package/dist/types/Message/TypedMessageController.d.ts +21 -0
  21. package/dist/types/Message/utils.d.ts +10 -0
  22. package/dist/types/Network/NetworkController.d.ts +40 -0
  23. package/dist/types/Network/createEthereumMiddleware.d.ts +66 -0
  24. package/dist/types/Network/createJsonRpcClient.d.ts +9 -0
  25. package/dist/types/Nfts/INftsController.d.ts +10 -0
  26. package/dist/types/Nfts/NftHandler.d.ts +35 -0
  27. package/dist/types/Nfts/NftsController.d.ts +40 -0
  28. package/dist/types/Preferences/PreferencesController.d.ts +53 -0
  29. package/dist/types/Tokens/ITokensController.d.ts +10 -0
  30. package/dist/types/Tokens/TokenHandler.d.ts +20 -0
  31. package/dist/types/Tokens/TokenRatesController.d.ts +42 -0
  32. package/dist/types/Tokens/TokensController.d.ts +42 -0
  33. package/dist/types/Transaction/NonceTracker.d.ts +37 -0
  34. package/dist/types/Transaction/PendingTransactionTracker.d.ts +32 -0
  35. package/dist/types/Transaction/TransactionController.d.ts +67 -0
  36. package/dist/types/Transaction/TransactionGasUtil.d.ts +21 -0
  37. package/dist/types/Transaction/TransactionStateHistoryHelper.d.ts +16 -0
  38. package/dist/types/Transaction/TransactionStateManager.d.ts +30 -0
  39. package/dist/types/Transaction/TransactionUtils.d.ts +70 -0
  40. package/dist/types/index.d.ts +43 -0
  41. package/dist/types/utils/abiDecoder.d.ts +17 -0
  42. package/dist/types/utils/abis.d.ts +84 -0
  43. package/dist/types/utils/constants.d.ts +81 -0
  44. package/dist/types/utils/contractAddresses.d.ts +1 -0
  45. package/dist/types/utils/conversionUtils.d.ts +42 -0
  46. package/dist/types/utils/helpers.d.ts +24 -0
  47. package/dist/types/utils/interfaces.d.ts +384 -0
  48. package/package.json +71 -0
  49. package/src/Account/AccountTrackerController.ts +157 -0
  50. package/src/Block/PollingBlockTracker.ts +89 -0
  51. package/src/Currency/CurrencyController.ts +117 -0
  52. package/src/Gas/GasFeeController.ts +254 -0
  53. package/src/Gas/IGasFeeController.ts +56 -0
  54. package/src/Gas/gasUtil.ts +163 -0
  55. package/src/Keyring/KeyringController.ts +118 -0
  56. package/src/Message/AbstractMessageController.ts +136 -0
  57. package/src/Message/DecryptMessageController.ts +81 -0
  58. package/src/Message/EncryptionPublicKeyController.ts +83 -0
  59. package/src/Message/MessageController.ts +74 -0
  60. package/src/Message/PersonalMessageController.ts +74 -0
  61. package/src/Message/TypedMessageController.ts +112 -0
  62. package/src/Message/utils.ts +107 -0
  63. package/src/Network/NetworkController.ts +184 -0
  64. package/src/Network/createEthereumMiddleware.ts +307 -0
  65. package/src/Network/createJsonRpcClient.ts +59 -0
  66. package/src/Nfts/INftsController.ts +13 -0
  67. package/src/Nfts/NftHandler.ts +191 -0
  68. package/src/Nfts/NftsController.ts +230 -0
  69. package/src/Preferences/PreferencesController.ts +409 -0
  70. package/src/Tokens/ITokensController.ts +13 -0
  71. package/src/Tokens/TokenHandler.ts +60 -0
  72. package/src/Tokens/TokenRatesController.ts +134 -0
  73. package/src/Tokens/TokensController.ts +278 -0
  74. package/src/Transaction/NonceTracker.ts +152 -0
  75. package/src/Transaction/PendingTransactionTracker.ts +235 -0
  76. package/src/Transaction/TransactionController.ts +558 -0
  77. package/src/Transaction/TransactionGasUtil.ts +74 -0
  78. package/src/Transaction/TransactionStateHistoryHelper.ts +41 -0
  79. package/src/Transaction/TransactionStateManager.ts +315 -0
  80. package/src/Transaction/TransactionUtils.ts +333 -0
  81. package/src/index.ts +45 -0
  82. package/src/utils/abiDecoder.ts +195 -0
  83. package/src/utils/abis.ts +677 -0
  84. package/src/utils/constants.ts +379 -0
  85. package/src/utils/contractAddresses.ts +21 -0
  86. package/src/utils/conversionUtils.ts +269 -0
  87. package/src/utils/helpers.ts +177 -0
  88. package/src/utils/interfaces.ts +454 -0
@@ -0,0 +1,677 @@
1
+ export const ecr20Abi = [
2
+ {
3
+ constant: true,
4
+ inputs: [],
5
+ name: "name",
6
+ outputs: [
7
+ {
8
+ name: "",
9
+ type: "string",
10
+ },
11
+ ],
12
+ payable: false,
13
+ type: "function",
14
+ },
15
+ {
16
+ constant: false,
17
+ inputs: [
18
+ {
19
+ name: "_spender",
20
+ type: "address",
21
+ },
22
+ {
23
+ name: "_value",
24
+ type: "uint256",
25
+ },
26
+ ],
27
+ name: "approve",
28
+ outputs: [
29
+ {
30
+ name: "success",
31
+ type: "bool",
32
+ },
33
+ ],
34
+ payable: false,
35
+ type: "function",
36
+ },
37
+ {
38
+ constant: true,
39
+ inputs: [],
40
+ name: "totalSupply",
41
+ outputs: [
42
+ {
43
+ name: "",
44
+ type: "uint256",
45
+ },
46
+ ],
47
+ payable: false,
48
+ type: "function",
49
+ },
50
+ {
51
+ constant: false,
52
+ inputs: [
53
+ {
54
+ name: "_from",
55
+ type: "address",
56
+ },
57
+ {
58
+ name: "_to",
59
+ type: "address",
60
+ },
61
+ {
62
+ name: "_value",
63
+ type: "uint256",
64
+ },
65
+ ],
66
+ name: "transferFrom",
67
+ outputs: [
68
+ {
69
+ name: "success",
70
+ type: "bool",
71
+ },
72
+ ],
73
+ payable: false,
74
+ type: "function",
75
+ },
76
+ {
77
+ constant: true,
78
+ inputs: [],
79
+ name: "decimals",
80
+ outputs: [
81
+ {
82
+ name: "",
83
+ type: "uint256",
84
+ },
85
+ ],
86
+ payable: false,
87
+ type: "function",
88
+ },
89
+ {
90
+ constant: true,
91
+ inputs: [
92
+ {
93
+ name: "_owner",
94
+ type: "address",
95
+ },
96
+ ],
97
+ name: "balanceOf",
98
+ outputs: [
99
+ {
100
+ name: "balance",
101
+ type: "uint256",
102
+ },
103
+ ],
104
+ payable: false,
105
+ type: "function",
106
+ },
107
+ {
108
+ constant: true,
109
+ inputs: [],
110
+ name: "symbol",
111
+ outputs: [
112
+ {
113
+ name: "",
114
+ type: "string",
115
+ },
116
+ ],
117
+ payable: false,
118
+ type: "function",
119
+ },
120
+ {
121
+ constant: false,
122
+ inputs: [
123
+ {
124
+ name: "_to",
125
+ type: "address",
126
+ },
127
+ {
128
+ name: "_value",
129
+ type: "uint256",
130
+ },
131
+ ],
132
+ name: "transfer",
133
+ outputs: [
134
+ {
135
+ name: "success",
136
+ type: "bool",
137
+ },
138
+ ],
139
+ payable: false,
140
+ type: "function",
141
+ },
142
+ {
143
+ constant: false,
144
+ inputs: [
145
+ {
146
+ name: "_spender",
147
+ type: "address",
148
+ },
149
+ {
150
+ name: "_value",
151
+ type: "uint256",
152
+ },
153
+ {
154
+ name: "_extraData",
155
+ type: "bytes",
156
+ },
157
+ ],
158
+ name: "approveAndCall",
159
+ outputs: [
160
+ {
161
+ name: "success",
162
+ type: "bool",
163
+ },
164
+ ],
165
+ payable: false,
166
+ type: "function",
167
+ },
168
+ {
169
+ constant: true,
170
+ inputs: [
171
+ {
172
+ name: "_owner",
173
+ type: "address",
174
+ },
175
+ {
176
+ name: "_spender",
177
+ type: "address",
178
+ },
179
+ ],
180
+ name: "allowance",
181
+ outputs: [
182
+ {
183
+ name: "remaining",
184
+ type: "uint256",
185
+ },
186
+ ],
187
+ payable: false,
188
+ type: "function",
189
+ },
190
+ {
191
+ inputs: [
192
+ {
193
+ name: "_initialAmount",
194
+ type: "uint256",
195
+ },
196
+ {
197
+ name: "_tokenName",
198
+ type: "string",
199
+ },
200
+ {
201
+ name: "_decimalUnits",
202
+ type: "uint8",
203
+ },
204
+ {
205
+ name: "_tokenSymbol",
206
+ type: "string",
207
+ },
208
+ ],
209
+ type: "constructor",
210
+ },
211
+ {
212
+ payable: false,
213
+ type: "fallback",
214
+ },
215
+ ];
216
+
217
+ export const erc721Abi = [
218
+ {
219
+ constant: true,
220
+ inputs: [
221
+ {
222
+ name: "interfaceID",
223
+ type: "bytes4",
224
+ },
225
+ ],
226
+ name: "supportsInterface",
227
+ outputs: [
228
+ {
229
+ name: "",
230
+ type: "bool",
231
+ },
232
+ ],
233
+ payable: false,
234
+ stateMutability: "view",
235
+ type: "function",
236
+ },
237
+ {
238
+ constant: true,
239
+ inputs: [],
240
+ name: "name",
241
+ outputs: [
242
+ {
243
+ name: "_name",
244
+ type: "string",
245
+ },
246
+ ],
247
+ payable: false,
248
+ stateMutability: "view",
249
+ type: "function",
250
+ },
251
+ {
252
+ constant: true,
253
+ inputs: [
254
+ {
255
+ name: "_tokenId",
256
+ type: "uint256",
257
+ },
258
+ ],
259
+ name: "getApproved",
260
+ outputs: [
261
+ {
262
+ name: "",
263
+ type: "address",
264
+ },
265
+ ],
266
+ payable: false,
267
+ stateMutability: "view",
268
+ type: "function",
269
+ },
270
+ {
271
+ constant: false,
272
+ inputs: [
273
+ {
274
+ name: "_approved",
275
+ type: "address",
276
+ },
277
+ {
278
+ name: "_tokenId",
279
+ type: "uint256",
280
+ },
281
+ ],
282
+ name: "approve",
283
+ outputs: [],
284
+ payable: true,
285
+ stateMutability: "payable",
286
+ type: "function",
287
+ },
288
+ {
289
+ constant: true,
290
+ inputs: [],
291
+ name: "totalSupply",
292
+ outputs: [
293
+ {
294
+ name: "",
295
+ type: "uint256",
296
+ },
297
+ ],
298
+ payable: false,
299
+ stateMutability: "view",
300
+ type: "function",
301
+ },
302
+ {
303
+ constant: false,
304
+ inputs: [
305
+ {
306
+ name: "_from",
307
+ type: "address",
308
+ },
309
+ {
310
+ name: "_to",
311
+ type: "address",
312
+ },
313
+ {
314
+ name: "_tokenId",
315
+ type: "uint256",
316
+ },
317
+ ],
318
+ name: "transferFrom",
319
+ outputs: [],
320
+ payable: true,
321
+ stateMutability: "payable",
322
+ type: "function",
323
+ },
324
+ {
325
+ constant: true,
326
+ inputs: [
327
+ {
328
+ name: "_owner",
329
+ type: "address",
330
+ },
331
+ {
332
+ name: "_index",
333
+ type: "uint256",
334
+ },
335
+ ],
336
+ name: "tokenOfOwnerByIndex",
337
+ outputs: [
338
+ {
339
+ name: "",
340
+ type: "uint256",
341
+ },
342
+ ],
343
+ payable: false,
344
+ stateMutability: "view",
345
+ type: "function",
346
+ },
347
+ {
348
+ constant: false,
349
+ inputs: [
350
+ {
351
+ name: "_from",
352
+ type: "address",
353
+ },
354
+ {
355
+ name: "_to",
356
+ type: "address",
357
+ },
358
+ {
359
+ name: "_tokenId",
360
+ type: "uint256",
361
+ },
362
+ ],
363
+ name: "safeTransferFrom",
364
+ outputs: [],
365
+ payable: true,
366
+ stateMutability: "payable",
367
+ type: "function",
368
+ },
369
+ {
370
+ constant: true,
371
+ inputs: [
372
+ {
373
+ name: "_index",
374
+ type: "uint256",
375
+ },
376
+ ],
377
+ name: "tokenByIndex",
378
+ outputs: [
379
+ {
380
+ name: "",
381
+ type: "uint256",
382
+ },
383
+ ],
384
+ payable: false,
385
+ stateMutability: "view",
386
+ type: "function",
387
+ },
388
+ {
389
+ constant: true,
390
+ inputs: [
391
+ {
392
+ name: "_tokenId",
393
+ type: "uint256",
394
+ },
395
+ ],
396
+ name: "ownerOf",
397
+ outputs: [
398
+ {
399
+ name: "",
400
+ type: "address",
401
+ },
402
+ ],
403
+ payable: false,
404
+ stateMutability: "view",
405
+ type: "function",
406
+ },
407
+ {
408
+ constant: true,
409
+ inputs: [
410
+ {
411
+ name: "_owner",
412
+ type: "address",
413
+ },
414
+ ],
415
+ name: "balanceOf",
416
+ outputs: [
417
+ {
418
+ name: "",
419
+ type: "uint256",
420
+ },
421
+ ],
422
+ payable: false,
423
+ stateMutability: "view",
424
+ type: "function",
425
+ },
426
+ {
427
+ constant: true,
428
+ inputs: [],
429
+ name: "symbol",
430
+ outputs: [
431
+ {
432
+ name: "_symbol",
433
+ type: "string",
434
+ },
435
+ ],
436
+ payable: false,
437
+ stateMutability: "view",
438
+ type: "function",
439
+ },
440
+ {
441
+ constant: true,
442
+ inputs: [
443
+ {
444
+ name: "_tokenId",
445
+ type: "uint256",
446
+ },
447
+ ],
448
+ name: "tokenURI",
449
+ outputs: [
450
+ {
451
+ name: "",
452
+ type: "string",
453
+ },
454
+ ],
455
+ payable: false,
456
+ stateMutability: "view",
457
+ type: "function",
458
+ },
459
+ ];
460
+
461
+ export const erc1155Abi = [
462
+ {
463
+ inputs: [
464
+ {
465
+ internalType: "address",
466
+ name: "_owner",
467
+ type: "address",
468
+ },
469
+ {
470
+ internalType: "uint256",
471
+ name: "_id",
472
+ type: "uint256",
473
+ },
474
+ ],
475
+ name: "balanceOf",
476
+ outputs: [
477
+ {
478
+ internalType: "uint256",
479
+ name: "",
480
+ type: "uint256",
481
+ },
482
+ ],
483
+ stateMutability: "view",
484
+ type: "function",
485
+ },
486
+ {
487
+ inputs: [
488
+ {
489
+ internalType: "address[]",
490
+ name: "_owners",
491
+ type: "address[]",
492
+ },
493
+ {
494
+ internalType: "uint256[]",
495
+ name: "_ids",
496
+ type: "uint256[]",
497
+ },
498
+ ],
499
+ name: "balanceOfBatch",
500
+ outputs: [
501
+ {
502
+ internalType: "uint256[]",
503
+ name: "",
504
+ type: "uint256[]",
505
+ },
506
+ ],
507
+ stateMutability: "view",
508
+ type: "function",
509
+ },
510
+ {
511
+ inputs: [
512
+ {
513
+ internalType: "address",
514
+ name: "_owner",
515
+ type: "address",
516
+ },
517
+ {
518
+ internalType: "address",
519
+ name: "_operator",
520
+ type: "address",
521
+ },
522
+ ],
523
+ name: "isApprovedForAll",
524
+ outputs: [
525
+ {
526
+ internalType: "bool",
527
+ name: "isOperator",
528
+ type: "bool",
529
+ },
530
+ ],
531
+ stateMutability: "view",
532
+ type: "function",
533
+ },
534
+ {
535
+ inputs: [
536
+ {
537
+ internalType: "address",
538
+ name: "_from",
539
+ type: "address",
540
+ },
541
+ {
542
+ internalType: "address",
543
+ name: "_to",
544
+ type: "address",
545
+ },
546
+ {
547
+ internalType: "uint256",
548
+ name: "_id",
549
+ type: "uint256",
550
+ },
551
+ {
552
+ internalType: "uint256",
553
+ name: "_amount",
554
+ type: "uint256",
555
+ },
556
+ {
557
+ internalType: "bytes",
558
+ name: "_data",
559
+ type: "bytes",
560
+ },
561
+ ],
562
+ name: "safeTransferFrom",
563
+ outputs: [],
564
+ stateMutability: "nonpayable",
565
+ type: "function",
566
+ },
567
+ {
568
+ inputs: [
569
+ {
570
+ internalType: "address",
571
+ name: "_operator",
572
+ type: "address",
573
+ },
574
+ {
575
+ internalType: "bool",
576
+ name: "_approved",
577
+ type: "bool",
578
+ },
579
+ ],
580
+ name: "setApprovalForAll",
581
+ outputs: [],
582
+ stateMutability: "nonpayable",
583
+ type: "function",
584
+ },
585
+ {
586
+ inputs: [
587
+ {
588
+ internalType: "bytes4",
589
+ name: "_interfaceID",
590
+ type: "bytes4",
591
+ },
592
+ ],
593
+ name: "supportsInterface",
594
+ outputs: [
595
+ {
596
+ internalType: "bool",
597
+ name: "",
598
+ type: "bool",
599
+ },
600
+ ],
601
+ stateMutability: "pure",
602
+ type: "function",
603
+ },
604
+ {
605
+ inputs: [
606
+ {
607
+ internalType: "uint256",
608
+ name: "_id",
609
+ type: "uint256",
610
+ },
611
+ ],
612
+ name: "uri",
613
+ outputs: [
614
+ {
615
+ internalType: "string",
616
+ name: "",
617
+ type: "string",
618
+ },
619
+ ],
620
+ stateMutability: "view",
621
+ type: "function",
622
+ },
623
+ ];
624
+
625
+ export const singleBalanceCheckerAbi = [
626
+ {
627
+ payable: true,
628
+ stateMutability: "payable",
629
+ type: "fallback",
630
+ },
631
+ {
632
+ constant: true,
633
+ inputs: [
634
+ {
635
+ name: "user",
636
+ type: "address",
637
+ },
638
+ {
639
+ name: "token",
640
+ type: "address",
641
+ },
642
+ ],
643
+ name: "tokenBalance",
644
+ outputs: [
645
+ {
646
+ name: "",
647
+ type: "uint256",
648
+ },
649
+ ],
650
+ payable: false,
651
+ stateMutability: "view",
652
+ type: "function",
653
+ },
654
+ {
655
+ constant: true,
656
+ inputs: [
657
+ {
658
+ name: "users",
659
+ type: "address[]",
660
+ },
661
+ {
662
+ name: "tokens",
663
+ type: "address[]",
664
+ },
665
+ ],
666
+ name: "balances",
667
+ outputs: [
668
+ {
669
+ name: "",
670
+ type: "uint256[]",
671
+ },
672
+ ],
673
+ payable: false,
674
+ stateMutability: "view",
675
+ type: "function",
676
+ },
677
+ ];