@toruslabs/ethereum-controllers 7.1.2 → 7.2.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 (38) hide show
  1. package/dist/ethereumControllers.cjs.js +76 -46
  2. package/dist/ethereumControllers.esm.js +36 -7
  3. package/dist/ethereumControllers.umd.min.js +1 -1
  4. package/dist/lib.cjs/Gas/gasUtil.js +15 -15
  5. package/dist/lib.cjs/Message/utils.js +11 -4
  6. package/dist/lib.cjs/Network/createEthereumMiddleware.js +23 -0
  7. package/dist/lib.cjs/Preferences/PreferencesController.js +1 -0
  8. package/dist/lib.cjs/Tokens/TokensController.js +1 -2
  9. package/dist/lib.cjs/Transaction/TransactionController.js +5 -5
  10. package/dist/lib.cjs/index.js +1 -0
  11. package/dist/lib.cjs/utils/conversionUtils.js +17 -17
  12. package/dist/lib.cjs/utils/helpers.js +6 -6
  13. package/dist/lib.esm/Gas/gasUtil.js +1 -1
  14. package/dist/lib.esm/Message/utils.js +11 -4
  15. package/dist/lib.esm/Network/createEthereumMiddleware.js +23 -1
  16. package/dist/lib.esm/Preferences/PreferencesController.js +2 -1
  17. package/dist/lib.esm/Tokens/TokensController.js +1 -2
  18. package/dist/lib.esm/Transaction/TransactionController.js +1 -1
  19. package/dist/lib.esm/index.js +1 -1
  20. package/dist/lib.esm/utils/conversionUtils.js +1 -1
  21. package/dist/lib.esm/utils/helpers.js +1 -1
  22. package/dist/types/Account/AccountTrackerController.d.ts +2 -1
  23. package/dist/types/Gas/gasUtil.d.ts +1 -1
  24. package/dist/types/Message/SwitchChainController.d.ts +1 -2
  25. package/dist/types/Message/utils.d.ts +2 -2
  26. package/dist/types/Network/createEthereumMiddleware.d.ts +6 -2
  27. package/dist/types/Nfts/INftsController.d.ts +8 -8
  28. package/dist/types/Nfts/NftHandler.d.ts +2 -1
  29. package/dist/types/Nfts/NftsController.d.ts +6 -5
  30. package/dist/types/Preferences/IPreferencesController.d.ts +10 -0
  31. package/dist/types/Preferences/PreferencesController.d.ts +4 -1
  32. package/dist/types/Tokens/TokenRatesController.d.ts +2 -1
  33. package/dist/types/Tokens/TokensController.d.ts +2 -1
  34. package/dist/types/index.d.ts +1 -0
  35. package/dist/types/utils/conversionUtils.d.ts +1 -1
  36. package/dist/types/utils/helpers.d.ts +1 -1
  37. package/dist/types/utils/interfaces.d.ts +11 -74
  38. package/package.json +4 -4
@@ -0,0 +1,10 @@
1
+ import { AddressPreferences } from "@toruslabs/base-controllers";
2
+ import { CustomNetworks, FetchCommonTransaction, FetchedTransaction, FormattedTransactionActivity } from "../utils/interfaces";
3
+ export interface ExtendedAddressPreferences extends AddressPreferences {
4
+ eoaAddress?: string;
5
+ fetchedPastTx?: FetchedTransaction[];
6
+ formattedPastTransactions?: FormattedTransactionActivity[];
7
+ paymentTx: FetchCommonTransaction[];
8
+ customNetworks: CustomNetworks[];
9
+ etherscanTransactions?: FormattedTransactionActivity[];
10
+ }
@@ -2,7 +2,9 @@ import { BasePreferencesController, CustomNft, CustomToken, InitPreferencesParam
2
2
  import { SafeEventEmitterProvider } from "@web3auth/auth";
3
3
  import { KeyringController } from "../Keyring/KeyringController";
4
4
  import { NetworkController } from "../Network/NetworkController";
5
- import type { AddChainMessageParams, CustomNetworkPayload, CustomNftInfo, CustomTokenInfo, EtherscanTransaction, ExtendedAddressPreferences, TransactionPayload } from "../utils/interfaces";
5
+ import { EthereumNftInfo as CustomNftInfo } from "../Nfts/INftsController";
6
+ import type { AddChainMessageParams, CustomNetworkPayload, CustomTokenInfo, EtherscanTransaction, TransactionPayload } from "../utils/interfaces";
7
+ import { ExtendedAddressPreferences } from "./IPreferencesController";
6
8
  export interface IPreferencesControllerOptions {
7
9
  config?: Partial<PreferencesConfig> & Pick<PreferencesConfig, "api" | "commonApiHost">;
8
10
  state?: Partial<PreferencesState<ExtendedAddressPreferences>>;
@@ -13,6 +15,7 @@ export interface IPreferencesControllerOptions {
13
15
  validateSignMessage: (message: string) => Promise<void>;
14
16
  }
15
17
  export declare class PreferencesController extends BasePreferencesController<ExtendedAddressPreferences, PreferencesConfig, PreferencesState<ExtendedAddressPreferences>> implements IPreferencesController<ExtendedAddressPreferences, PreferencesConfig, PreferencesState<ExtendedAddressPreferences>> {
18
+ protected chainNamespace: "eip155";
16
19
  private _handle?;
17
20
  private _mutex;
18
21
  private getProviderConfig;
@@ -1,5 +1,6 @@
1
1
  import { BaseController, BaseTokenRatesControllerConfig, BaseTokenRatesControllerState, ITokenRatesController, PreferencesState } from "@toruslabs/base-controllers";
2
- import { CustomTokenInfo, EthereumNetworkState, ExtendedAddressPreferences } from "../utils/interfaces";
2
+ import { ExtendedAddressPreferences } from "../Preferences/IPreferencesController";
3
+ import { CustomTokenInfo, EthereumNetworkState } from "../utils/interfaces";
3
4
  import { EthereumTokensControllerState } from "./ITokensController";
4
5
  export interface CoinGeckoResponse {
5
6
  [address: string]: {
@@ -1,8 +1,9 @@
1
1
  import { BaseController, ITokensController, PreferencesState, UserAddress } from "@toruslabs/base-controllers";
2
2
  import { SafeEventEmitterProvider } from "@web3auth/auth";
3
3
  import { NetworkController } from "../Network/NetworkController";
4
+ import { ExtendedAddressPreferences } from "../Preferences/IPreferencesController";
4
5
  import { PreferencesController } from "../Preferences/PreferencesController";
5
- import { CustomTokenInfo, EthereumNetworkState, ExtendedAddressPreferences } from "../utils/interfaces";
6
+ import { CustomTokenInfo, EthereumNetworkState } from "../utils/interfaces";
6
7
  import { EthereumTokensControllerConfig, EthereumTokensControllerState } from "./ITokensController";
7
8
  export interface ITokensControllerOptions {
8
9
  config?: Partial<EthereumTokensControllerConfig>;
@@ -19,6 +19,7 @@ export { NetworkController } from "./Network/NetworkController";
19
19
  export * from "./Nfts/INftsController";
20
20
  export * from "./Nfts/NftHandler";
21
21
  export * from "./Nfts/NftsController";
22
+ export * from "./Preferences/IPreferencesController";
22
23
  export { PreferencesController } from "./Preferences/PreferencesController";
23
24
  export * from "./Tokens/ITokensController";
24
25
  export * from "./Tokens/TokenHandler";
@@ -1,4 +1,4 @@
1
- import BigNumber from "bignumber.js";
1
+ import { BigNumber } from "bignumber.js";
2
2
  type NumericBase = "hex" | "dec" | "BN";
3
3
  type EthDenomination = "WEI" | "GWEI" | "ETH";
4
4
  type ConverterOptions = {
@@ -1,6 +1,6 @@
1
1
  import { TransactionStatus } from "@toruslabs/base-controllers";
2
2
  import { SafeEventEmitterProvider } from "@web3auth/auth";
3
- import BigNumber from "bignumber.js";
3
+ import { BigNumber } from "bignumber.js";
4
4
  import { EtherscanTransaction, FormattedTransactionActivity, TransactionPayload } from "./interfaces";
5
5
  export declare function hexToBn(hex: string): BigNumber;
6
6
  export declare function BNToHex(bn: BigNumber): string;
@@ -1,4 +1,4 @@
1
- import { AddressPreferences, BASE_TX_EVENT_TYPE, BaseBlockTrackerState, BaseControllerEvents, BaseTransactionEvents, MESSAGE_EVENTS, MessageStatus, NetworkConfig, NetworkState, PaymentTransaction, PollingBlockTrackerConfig, PopupWhitelabelData, ProviderConfig, TRANSACTION_TYPE, TransactionMeta, TransactionState, TransactionStatus, TX_CONFIRMED_EVENT_TYPE, TX_DROPPED_EVENT_TYPE, TX_EVENTS, TX_FAILED_EVENT_TYPE, TX_WARNING_EVENT_TYPE, User } from "@toruslabs/base-controllers";
1
+ import { BASE_TX_EVENT_TYPE, BaseBlockTrackerState, BaseControllerEvents, BaseFormattedTransactionActivity, BaseTokenInfo, BaseTransactionEvents, MESSAGE_EVENTS, MessageStatus, NetworkConfig, NetworkState, PaymentTransaction, PollingBlockTrackerConfig, PopupWhitelabelData, ProviderConfig, TRANSACTION_TYPE, TransactionMeta, TransactionState, TransactionStatus, TX_CONFIRMED_EVENT_TYPE, TX_DROPPED_EVENT_TYPE, TX_EVENTS, TX_FAILED_EVENT_TYPE, TX_WARNING_EVENT_TYPE, User } from "@toruslabs/base-controllers";
2
2
  import { JRPCRequest, Json } from "@web3auth/auth";
3
3
  import { MutexInterface } from "async-mutex";
4
4
  import { AccessList, TypedDataDomain, TypedDataField } from "ethers";
@@ -6,40 +6,10 @@ import { ToBiconomySmartAccountParameters, toEcdsaKernelSmartAccount, ToLightSma
6
6
  import { Client, EIP1193Provider } from "viem";
7
7
  import { createBundlerClient, createPaymasterClient, SmartAccount, UserOperationReceipt } from "viem/account-abstraction";
8
8
  import { METHOD_TYPES, SMART_ACCOUNT, TRANSACTION_ENVELOPE_TYPES } from "./constants";
9
- export type CustomTokenInfo = {
10
- tokenAddress: string;
11
- name: string;
12
- chainId: string;
9
+ export type CustomTokenInfo = BaseTokenInfo & {
13
10
  erc20: boolean;
14
- symbol: string;
15
- decimals: string;
16
- balance?: string;
17
11
  customTokenId?: string;
18
12
  isEtherScan?: boolean;
19
- logo?: string;
20
- };
21
- export type CustomNftItemInfo = {
22
- image: string;
23
- name: string;
24
- tokenBalance: string;
25
- description: string;
26
- tokenId: string;
27
- video?: string;
28
- decimals?: string;
29
- customNftId?: string;
30
- };
31
- export type NftStandardType = "erc721" | "erc1155";
32
- export type CustomNftInfo = {
33
- contractAddress: string;
34
- contractName: string;
35
- contractSymbol: string;
36
- contractImage?: string;
37
- contractSupply?: string;
38
- contractFallbackLogo?: string;
39
- nftStandard: NftStandardType;
40
- contractDescription?: string;
41
- chainId: string;
42
- assets: CustomNftItemInfo[];
43
13
  };
44
14
  export interface EthereumBlock {
45
15
  blockHash: string;
@@ -90,13 +60,6 @@ export type SignTypedDataMessageV4 = {
90
60
  domain: TypedDataDomain;
91
61
  message: Record<string, unknown>;
92
62
  };
93
- export interface SwitchChainMessageParams extends BaseRequestParams {
94
- chainId: string;
95
- displayName?: string;
96
- }
97
- export interface SwitchChainMessage extends AbstractMessage {
98
- messageParams: SwitchChainMessageParams;
99
- }
100
63
  export interface AddChainMessageParams extends BaseRequestParams {
101
64
  chainId: string;
102
65
  chainName: string;
@@ -364,51 +327,17 @@ export interface FetchedTransaction extends TransactionPayload {
364
327
  export interface FetchCommonTransaction extends PaymentTransaction {
365
328
  etherscanLink?: string | null;
366
329
  }
367
- export interface FormattedTransactionActivity {
368
- id: string;
369
- date: string;
370
- from: string;
330
+ export interface FormattedTransactionActivity extends BaseFormattedTransactionActivity {
371
331
  from_aa_address?: string;
372
- slicedFrom: string;
373
- to: string;
374
- slicedTo: string;
375
- action: string;
376
- totalAmount: string;
377
- totalAmountString: string;
378
- currencyAmount: string;
379
- currencyAmountString: string;
380
- amount: string;
381
- status: TransactionStatus;
382
332
  etherscanLink: string;
383
333
  ethRate: string;
384
- currencyUsed: string;
385
- chainId: string;
386
- type: string;
387
- type_name: string;
388
- type_image_link: string;
389
- transaction_hash: string;
390
334
  isEtherscan?: boolean;
391
- transaction_category: string;
392
- input?: string;
393
- contract_address?: string;
394
- token_id?: string;
395
335
  nonce: string;
396
- is_cancel: boolean;
397
336
  gas: string;
398
337
  gasPrice: string;
399
- hasCancel?: boolean;
400
- cancelDateInitiated?: string;
401
338
  cancelGas?: string;
402
339
  cancelGasPrice?: string;
403
340
  }
404
- export interface ExtendedAddressPreferences extends AddressPreferences {
405
- eoaAddress?: string;
406
- fetchedPastTx?: FetchedTransaction[];
407
- formattedPastTransactions?: FormattedTransactionActivity[];
408
- paymentTx: FetchCommonTransaction[];
409
- customNetworks: CustomNetworks[];
410
- etherscanTransactions?: FormattedTransactionActivity[];
411
- }
412
341
  export interface ProviderChangeChannelEventData {
413
342
  newNetwork: EthereumProviderConfig;
414
343
  whitelabelData: PopupWhitelabelData;
@@ -520,6 +449,14 @@ export interface ISmartAccount {
520
449
  }): Promise<SmartAccount>;
521
450
  }
522
451
  export type SmartAccountType = (typeof SMART_ACCOUNT)[keyof typeof SMART_ACCOUNT];
452
+ export type SmartAccountConfig = BiconomySmartAccountConfig | KernelSmartAccountConfig | NexusSmartAccountConfig | SafeSmartAccountConfig | TrustSmartAccountConfig;
453
+ export interface AccountAbstractionConfig {
454
+ smartAccountType: SmartAccountType;
455
+ smartAccountAddress?: string;
456
+ bundlerConfig: BundlerConfig;
457
+ paymasterConfig?: PaymasterConfig;
458
+ smartAccountConfig?: SmartAccountConfig;
459
+ }
523
460
  export interface UserOperationGas {
524
461
  callGasLimit: string;
525
462
  preVerificationGas: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toruslabs/ethereum-controllers",
3
- "version": "7.1.2",
3
+ "version": "7.2.0",
4
4
  "homepage": "https://github.com/torusresearch/controllers#readme",
5
5
  "license": "ISC",
6
6
  "sideEffects": false,
@@ -21,9 +21,9 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@ethereumjs/util": "^9.1.0",
24
- "@toruslabs/base-controllers": "^7.1.1",
24
+ "@toruslabs/base-controllers": "^7.2.0",
25
25
  "@toruslabs/http-helpers": "^7.0.0",
26
- "@web3auth/auth": "^9.6.2",
26
+ "@web3auth/auth": "^9.6.4",
27
27
  "async-mutex": "^0.5.0",
28
28
  "bignumber.js": "^9.1.2",
29
29
  "bn.js": "^5.2.1",
@@ -63,7 +63,7 @@
63
63
  "publishConfig": {
64
64
  "access": "public"
65
65
  },
66
- "gitHead": "29f28e52b7daf293faa4e88cb81df7ffd879110f",
66
+ "gitHead": "4ff78b7a1aa5861366d0ce28ab48fe178f776f15",
67
67
  "devDependencies": {
68
68
  "@nomicfoundation/hardhat-chai-matchers": "^2.0.8",
69
69
  "@nomicfoundation/hardhat-ethers": "^3.0.8",