@toruslabs/ethereum-controllers 5.5.2 → 5.5.4

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 (51) hide show
  1. package/dist/ethereumControllers.cjs.js +22 -21
  2. package/dist/ethereumControllers.esm.js +22 -20
  3. package/dist/ethereumControllers.umd.min.js +1 -2
  4. package/dist/ethereumControllers.umd.min.js.LICENSE.txt +0 -2
  5. package/dist/types/Account/AccountTrackerController.d.ts +1 -1
  6. package/dist/types/utils/interfaces.d.ts +3 -0
  7. package/package.json +14 -15
  8. package/dist/ethereumControllers.cjs.js.map +0 -1
  9. package/dist/ethereumControllers.esm.js.map +0 -1
  10. package/dist/ethereumControllers.umd.min.js.map +0 -1
  11. package/src/Account/AccountTrackerController.ts +0 -172
  12. package/src/Block/PollingBlockTracker.ts +0 -89
  13. package/src/Currency/CurrencyController.ts +0 -117
  14. package/src/Gas/GasFeeController.ts +0 -261
  15. package/src/Gas/IGasFeeController.ts +0 -56
  16. package/src/Gas/gasUtil.ts +0 -163
  17. package/src/Keyring/KeyringController.ts +0 -117
  18. package/src/Message/AbstractMessageController.ts +0 -136
  19. package/src/Message/AddChainController.ts +0 -73
  20. package/src/Message/DecryptMessageController.ts +0 -76
  21. package/src/Message/EncryptionPublicKeyController.ts +0 -75
  22. package/src/Message/MessageController.ts +0 -74
  23. package/src/Message/PersonalMessageController.ts +0 -74
  24. package/src/Message/SwitchChainController.ts +0 -74
  25. package/src/Message/TypedMessageController.ts +0 -109
  26. package/src/Message/utils.ts +0 -155
  27. package/src/Network/NetworkController.ts +0 -184
  28. package/src/Network/createEthereumMiddleware.ts +0 -475
  29. package/src/Network/createJsonRpcClient.ts +0 -63
  30. package/src/Nfts/INftsController.ts +0 -13
  31. package/src/Nfts/NftHandler.ts +0 -191
  32. package/src/Nfts/NftsController.ts +0 -216
  33. package/src/Preferences/PreferencesController.ts +0 -473
  34. package/src/Tokens/ITokensController.ts +0 -13
  35. package/src/Tokens/TokenHandler.ts +0 -60
  36. package/src/Tokens/TokenRatesController.ts +0 -134
  37. package/src/Tokens/TokensController.ts +0 -273
  38. package/src/Transaction/NonceTracker.ts +0 -152
  39. package/src/Transaction/PendingTransactionTracker.ts +0 -235
  40. package/src/Transaction/TransactionController.ts +0 -558
  41. package/src/Transaction/TransactionGasUtil.ts +0 -74
  42. package/src/Transaction/TransactionStateHistoryHelper.ts +0 -41
  43. package/src/Transaction/TransactionStateManager.ts +0 -315
  44. package/src/Transaction/TransactionUtils.ts +0 -333
  45. package/src/index.ts +0 -49
  46. package/src/utils/abis.ts +0 -677
  47. package/src/utils/constants.ts +0 -438
  48. package/src/utils/contractAddresses.ts +0 -19
  49. package/src/utils/conversionUtils.ts +0 -269
  50. package/src/utils/helpers.ts +0 -234
  51. package/src/utils/interfaces.ts +0 -516
@@ -1,516 +0,0 @@
1
- import { AccessList } from "@ethereumjs/common";
2
- import { SignTypedDataVersion } from "@metamask/eth-sig-util";
3
- import {
4
- AddressPreferences,
5
- BaseBlockTrackerState,
6
- NetworkConfig,
7
- NetworkState,
8
- PaymentTransaction,
9
- PollingBlockTrackerConfig,
10
- PopupWhitelabelData,
11
- ProviderConfig,
12
- TRANSACTION_TYPE,
13
- TransactionMeta,
14
- TransactionStatus,
15
- User,
16
- } from "@toruslabs/base-controllers";
17
- import { Json } from "@toruslabs/openlogin-jrpc";
18
- import { MutexInterface } from "async-mutex";
19
-
20
- import { MessageStatus, METHOD_TYPES, TRANSACTION_ENVELOPE_TYPES } from "./constants";
21
-
22
- export type CustomTokenInfo = {
23
- tokenAddress: string;
24
- name: string;
25
- chainId: string;
26
- erc20: boolean;
27
- symbol: string;
28
- decimals: string;
29
- balance?: string;
30
- customTokenId?: string;
31
- isEtherScan?: boolean;
32
- logo?: string;
33
- };
34
-
35
- export type CustomNftItemInfo = {
36
- image: string;
37
- name: string;
38
- tokenBalance: string;
39
- description: string;
40
- tokenId: string;
41
- video?: string;
42
- decimals?: string;
43
- customNftId?: string;
44
- };
45
- export type NftStandardType = "erc721" | "erc1155";
46
-
47
- export type CustomNftInfo = {
48
- contractAddress: string;
49
- contractName: string;
50
- contractSymbol: string;
51
- contractImage?: string;
52
- contractSupply?: string;
53
- contractFallbackLogo?: string;
54
- nftStandard: NftStandardType;
55
- contractDescription?: string;
56
- chainId: string;
57
- assets: CustomNftItemInfo[];
58
- };
59
-
60
- export interface EthereumBlock {
61
- blockHash: string;
62
- idempotencyKey: string;
63
- timestamp: string;
64
- baseFeePerGas: string;
65
- gasLimit: string;
66
- }
67
-
68
- export interface UserRequestApprovalParams {
69
- windowId?: string;
70
- origin?: string;
71
- }
72
-
73
- export interface BaseRequestParams {
74
- /**
75
- * Unique id for each request
76
- */
77
- id?: string;
78
- /**
79
- * Address to send this transaction from.
80
- */
81
- from: string;
82
-
83
- /**
84
- * Domain requested from
85
- */
86
- origin?: string;
87
- }
88
-
89
- export interface MessageParams extends BaseRequestParams {
90
- data: string;
91
- }
92
-
93
- export type MessageStatusType = (typeof MessageStatus)[keyof typeof MessageStatus];
94
-
95
- export interface AbstractMessage {
96
- id: string;
97
- time: number;
98
- status: MessageStatusType;
99
- /**
100
- * JRPC method for which sig request is made
101
- */
102
- type: string;
103
- rawSig?: string;
104
- metadata?: Json;
105
- error?: string;
106
- }
107
-
108
- export interface Message extends AbstractMessage {
109
- messageParams: MessageParams;
110
- }
111
-
112
- export type SignTypedDataMessageV3V4 = {
113
- types: Record<string, unknown>;
114
- domain: Record<string, unknown>;
115
- primaryType: string;
116
- message: unknown;
117
- };
118
-
119
- export interface SwitchChainMessageParams extends BaseRequestParams {
120
- chainId: string;
121
- displayName?: string;
122
- }
123
-
124
- export interface SwitchChainMessage extends AbstractMessage {
125
- messageParams: SwitchChainMessageParams;
126
- }
127
-
128
- export interface AddChainMessageParams extends BaseRequestParams {
129
- chainId: string;
130
- chainName: string;
131
- nativeCurrency: {
132
- name: string;
133
- symbol: string;
134
- decimals: number;
135
- };
136
- rpcUrls: string[];
137
- blockExplorerUrls?: string[];
138
- }
139
-
140
- export interface AddChainMessage extends AbstractMessage {
141
- messageParams: AddChainMessageParams;
142
- }
143
-
144
- export interface TypedMessageParams extends BaseRequestParams {
145
- data: Record<string, unknown>[] | string | SignTypedDataMessageV3V4;
146
- version?: SignTypedDataVersion;
147
- }
148
-
149
- export interface TypedMessage extends AbstractMessage {
150
- messageParams: TypedMessageParams;
151
- }
152
- export type TRANSACTION_ENVELOPE_TYPES_TYPE = (typeof TRANSACTION_ENVELOPE_TYPES)[keyof typeof TRANSACTION_ENVELOPE_TYPES];
153
-
154
- export interface TransactionParams extends BaseRequestParams {
155
- /**
156
- * Network ID as per EIP-155.
157
- */
158
- chainId?: string;
159
-
160
- /**
161
- * Data to pass with this transaction.
162
- */
163
- data?: string;
164
-
165
- /**
166
- * Error message for gas estimation failure.
167
- */
168
- estimateGasError?: string;
169
-
170
- /**
171
- * Estimated base fee for this transaction.
172
- */
173
- estimatedBaseFee?: string;
174
-
175
- /**
176
- * Gas to send with this transaction.
177
- */
178
- gas?: string;
179
-
180
- /**
181
- * Price of gas with this transaction.
182
- */
183
- gasPrice?: string;
184
-
185
- /**
186
- * Gas used in the transaction.
187
- */
188
- gasUsed?: string;
189
-
190
- /**
191
- * Maximum fee per gas for this transaction.
192
- */
193
- maxFeePerGas?: string;
194
-
195
- /**
196
- * Maximum priority fee per gas for this transaction.
197
- */
198
- maxPriorityFeePerGas?: string;
199
-
200
- /**
201
- * Unique number to prevent replay attacks.
202
- */
203
- nonce?: string;
204
-
205
- /**
206
- * Address to send this transaction to.
207
- */
208
- to?: string;
209
-
210
- /**
211
- * Value associated with this transaction.
212
- */
213
- value?: string;
214
-
215
- /**
216
- * EIP 2930
217
- */
218
- accessList?: AccessList;
219
- /**
220
- * Custom Nonce passed by the user
221
- */
222
- customNonceValue?: string;
223
- /**
224
- * Transaction envelope type
225
- */
226
- type?: TRANSACTION_ENVELOPE_TYPES_TYPE;
227
-
228
- /**
229
- * Max Gas to send with this transaction.
230
- */
231
- gasLimit?: string;
232
- }
233
-
234
- export type Nonce = {
235
- name: string;
236
- nonce: number;
237
- details: {
238
- startPoint?: number;
239
- highest?: number;
240
- block?: EthereumBlock;
241
- baseCount?: number;
242
- };
243
- };
244
-
245
- export type NonceDetails = {
246
- params: {
247
- highestLocallyConfirmed: number; // A hex string of the highest nonce on a confirmed transaction.
248
- nextNetworkNonce: number; // The next nonce suggested by the eth_getTransactionCount method.
249
- highestSuggested: number; // The maximum between the other two, the number returned.
250
- };
251
- local: Nonce;
252
- network: Nonce;
253
- };
254
-
255
- /**
256
- * Ref - https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_gettransactionreceipt
257
- */
258
- export interface TransactionReceipt {
259
- transactionHash: string;
260
- transactionIndex: string;
261
- blockNumber: string;
262
- blockHash: string;
263
- from: string;
264
- to: string | null;
265
- cumulativeGasUsed: string;
266
- effectiveGasPrice: string;
267
- gasUsed: string;
268
- contractAddress: string | null;
269
- logs: unknown[];
270
- logsBloom: string;
271
- type: TRANSACTION_ENVELOPE_TYPES_TYPE;
272
- root?: string;
273
- status?: "0x0" | "0x1";
274
- }
275
-
276
- export type BlockTag = "earliest" | "finalized" | "safe" | "latest" | "pending";
277
- export type BlockParams = string | BlockTag;
278
-
279
- export interface TransactionRPCMeta {
280
- v: string;
281
- r: string;
282
- s: string;
283
- to: string | null;
284
- gas: string;
285
- from: string;
286
- hash: string;
287
- nonce: string;
288
- input: string;
289
- value: string;
290
- accessList?: string[];
291
- blockHash: string | null;
292
- blockNumber: string | null;
293
- transactionIndex: string | null;
294
- maxFeePerGas?: string;
295
- maxPriorityFeePerGas?: string;
296
- gasPrice?: string;
297
- type: TRANSACTION_ENVELOPE_TYPES_TYPE;
298
- chainID?: string;
299
- }
300
-
301
- export type PollingBlockTrackerState = BaseBlockTrackerState<EthereumBlock>;
302
-
303
- export interface EthereumProviderConfig extends ProviderConfig {
304
- isErc20?: boolean;
305
- tokenAddress?: string;
306
- // infuraKey?: string;
307
- }
308
-
309
- export interface EthereumNetworkState extends NetworkState {
310
- providerConfig: EthereumProviderConfig;
311
- }
312
-
313
- export interface EthereumNetworkConfig extends NetworkConfig, Partial<PollingBlockTrackerConfig> {
314
- providerConfig: EthereumProviderConfig;
315
- }
316
-
317
- export type CustomNetworkPayload = Partial<EthereumProviderConfig> & Pick<EthereumProviderConfig, "chainId" | "displayName" | "rpcTarget" | "ticker">;
318
-
319
- export interface CustomNetworks {
320
- id: number;
321
- created_at: Date;
322
- updated_at: Date;
323
- network_name: string;
324
- public_address: string;
325
- chain_id: string;
326
- rpc_url: string;
327
- symbol?: string;
328
- symbol_name?: string;
329
- decimals?: string;
330
- logo?: string;
331
- block_explorer_url?: string;
332
- is_testnet?: boolean;
333
- }
334
-
335
- export interface EthereumUser extends User {
336
- customNetworks: CustomNetworks[];
337
- }
338
-
339
- export interface ContractParams {
340
- erc20?: boolean;
341
- erc721?: boolean;
342
- erc1155?: boolean;
343
- isSpecial?: boolean;
344
- symbol?: string;
345
- logo?: string;
346
- decimals?: number;
347
- }
348
-
349
- export interface DappSuggestedGasFees {
350
- gasPrice?: string;
351
- maxPriorityFeePerGas?: string;
352
- maxFeePerGas?: string;
353
- gas?: string;
354
- }
355
-
356
- export interface EthereumTransactionMeta extends TransactionMeta<TransactionParams> {
357
- r?: string;
358
- s?: string;
359
- v?: string;
360
- type: string;
361
- txReceipt?: TransactionReceipt;
362
- history: Record<string, unknown>[];
363
- accessList?: string[];
364
- firstRetryBlockNumber?: string;
365
- retryCount?: number;
366
- simulationFails?: Record<string, unknown>;
367
- loadingDefaults?: boolean;
368
- transactionCategory?: TRANSACTION_TYPE;
369
- contractType?: string;
370
- nonceDetails?: NonceDetails;
371
- methodParams?: unknown[];
372
- dappSuggestedGasFees?: DappSuggestedGasFees;
373
- }
374
-
375
- // TODO:// mark fields which will be optional.
376
- export interface TransactionPayload {
377
- created_at: Date;
378
- from: string;
379
- to: string;
380
- total_amount: string;
381
- currency_amount: string;
382
- selected_currency: string;
383
- status?: TransactionStatus;
384
- chain_id: string;
385
- transaction_hash: string;
386
- transaction_category: string;
387
- gas: string;
388
- gasPrice: string;
389
- nonce: string;
390
- type: string;
391
- type_name: string;
392
- type_image_link: string;
393
- symbol: string;
394
- is_cancel: boolean;
395
- contract_address?: string;
396
- from_aa_address?: string;
397
- isEtherscan?: boolean;
398
- token_id?: string;
399
- input?: string;
400
- etherscanLink?: string;
401
- }
402
-
403
- export interface FetchedTransaction extends TransactionPayload {
404
- id: string;
405
- }
406
-
407
- export interface FetchCommonTransaction extends PaymentTransaction {
408
- etherscanLink?: string | null;
409
- }
410
-
411
- export interface FormattedTransactionActivity {
412
- id: string;
413
- date: string;
414
- from: string;
415
- from_aa_address?: string;
416
- slicedFrom: string;
417
- to: string;
418
- slicedTo: string;
419
- action: string;
420
- totalAmount: string;
421
- totalAmountString: string;
422
- currencyAmount: string;
423
- currencyAmountString: string;
424
- amount: string;
425
- status: TransactionStatus;
426
- etherscanLink: string;
427
- ethRate: string;
428
- currencyUsed: string;
429
- chainId: string;
430
- type: string;
431
- type_name: string;
432
- type_image_link: string;
433
- transaction_hash: string;
434
- isEtherscan?: boolean;
435
- transaction_category: string;
436
- input?: string;
437
- contract_address?: string;
438
- token_id?: string;
439
- nonce: string;
440
- is_cancel: boolean;
441
- gas: string;
442
- gasPrice: string;
443
- hasCancel?: boolean;
444
- cancelDateInitiated?: string;
445
- cancelGas?: string;
446
- cancelGasPrice?: string;
447
- }
448
-
449
- export interface ExtendedAddressPreferences extends AddressPreferences {
450
- fetchedPastTx?: FetchedTransaction[];
451
- formattedPastTransactions?: FormattedTransactionActivity[];
452
- paymentTx: FetchCommonTransaction[];
453
- customNetworks: CustomNetworks[];
454
- etherscanTransactions?: FormattedTransactionActivity[];
455
- }
456
-
457
- export interface ProviderChangeChannelEventData {
458
- newNetwork: EthereumProviderConfig;
459
- whitelabelData: PopupWhitelabelData;
460
- origin: string;
461
- currentChainId: string;
462
- }
463
-
464
- export interface NonceLockRes {
465
- nextNonce: number;
466
- nonceDetails: NonceDetails;
467
- releaseLock: MutexInterface.Releaser;
468
- }
469
-
470
- export type METHOD_TYPES_TYPE = (typeof METHOD_TYPES)[keyof typeof METHOD_TYPES];
471
-
472
- export interface EncryptionPublicKeyParams extends BaseRequestParams {
473
- data: string;
474
- }
475
-
476
- export interface EncryptionPublicKey extends AbstractMessage {
477
- messageParams: EncryptionPublicKeyParams;
478
- }
479
-
480
- export interface DecryptMessageParams extends BaseRequestParams {
481
- data: string;
482
- }
483
-
484
- export interface DecryptMessage extends AbstractMessage {
485
- messageParams: DecryptMessageParams;
486
- }
487
-
488
- export interface EtherscanTransaction {
489
- blockNumber: string;
490
- timeStamp: string;
491
- hash: string;
492
- nonce: string;
493
- blockHash: string;
494
- transactionIndex: string;
495
- from: string;
496
- to: string;
497
- value: string;
498
- gas: string;
499
- gasPrice: string;
500
- isError: string;
501
- txreceipt_status: string;
502
- input: string;
503
- contractAddress: string;
504
- cumulativeGasUsed: string;
505
- gasUsed: string;
506
- confirmations: string;
507
- methodId: string;
508
- functionName: string;
509
- transaction_category: string;
510
- type_name: string;
511
- type: string;
512
- type_image_link: string;
513
- chainId: string;
514
- tokenSymbol: string;
515
- tokenID: string;
516
- }