@toruslabs/ethereum-controllers 5.2.14 → 5.3.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.
@@ -316,7 +316,7 @@ export interface TransactionPayload {
316
316
  currency_amount: string;
317
317
  selected_currency: string;
318
318
  status?: TransactionStatus;
319
- network: string;
319
+ chain_id: string;
320
320
  transaction_hash: string;
321
321
  transaction_category: string;
322
322
  gas: string;
@@ -354,7 +354,7 @@ export interface FormattedTransactionActivity {
354
354
  etherscanLink: string;
355
355
  ethRate: string;
356
356
  currencyUsed: string;
357
- networkType: string;
357
+ chainId: string;
358
358
  type: string;
359
359
  type_name: string;
360
360
  type_image_link: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toruslabs/ethereum-controllers",
3
- "version": "5.2.14",
3
+ "version": "5.3.0",
4
4
  "homepage": "https://github.com/torusresearch/controllers#readme",
5
5
  "license": "ISC",
6
6
  "main": "dist/ethereumControllers.cjs.js",
@@ -24,7 +24,7 @@
24
24
  "@ethereumjs/util": "^9.0.1",
25
25
  "@metamask/eth-sig-util": "^7.0.1",
26
26
  "@metamask/rpc-errors": "^6.1.0",
27
- "@toruslabs/base-controllers": "^5.2.14",
27
+ "@toruslabs/base-controllers": "^5.3.0",
28
28
  "@toruslabs/http-helpers": "^6.0.0",
29
29
  "@toruslabs/openlogin-jrpc": "^6.2.4",
30
30
  "async-mutex": "^0.4.1",
@@ -64,7 +64,7 @@
64
64
  "publishConfig": {
65
65
  "access": "public"
66
66
  },
67
- "gitHead": "eeb6a3bcd6b2c3005451e817975b97adae8b1f60",
67
+ "gitHead": "d55cc8b2f3322c082e6108778a5bc8d99621a29f",
68
68
  "devDependencies": {
69
69
  "@nomicfoundation/hardhat-toolbox": "^4.0.0",
70
70
  "hardhat": "^2.19.4"
@@ -170,7 +170,7 @@ export default class PreferencesController
170
170
  public async patchNewTx(tx: TransactionPayload, address: string): Promise<void> {
171
171
  const formattedTx = formatPastTx(tx);
172
172
  const storePastTx = this.getAddressState(address)?.formattedPastTransactions;
173
- const duplicateIndex = storePastTx.findIndex((x) => x.transaction_hash === tx.transaction_hash && x.networkType === tx.network);
173
+ const duplicateIndex = storePastTx.findIndex((x) => x.transaction_hash === tx.transaction_hash && x.chainId === tx.chain_id);
174
174
  if (tx.status === TransactionStatus.submitted || tx.status === TransactionStatus.confirmed) {
175
175
  if (duplicateIndex === -1) {
176
176
  // No duplicate found
@@ -385,7 +385,7 @@ export default class PreferencesController
385
385
  const lowerCaseSelectedAddress = address.toLowerCase();
386
386
  for (const x of txs) {
387
387
  if (
388
- x.network === SUPPORTED_NETWORKS[this.getProviderConfig().chainId].chainId &&
388
+ x.chain_id === SUPPORTED_NETWORKS[this.getProviderConfig().chainId].chainId &&
389
389
  x.to &&
390
390
  x.from &&
391
391
  (lowerCaseSelectedAddress === x.from.toLowerCase() || lowerCaseSelectedAddress === x.to.toLowerCase())
@@ -405,7 +405,7 @@ export default class PreferencesController
405
405
  finalObject.status = resolvedTxStatuses[index] || TransactionStatus.submitted;
406
406
  pastTx.push(finalObject);
407
407
  if (lowerCaseSelectedAddress === element.from.toLowerCase() && finalObject.status && finalObject.status !== element.status)
408
- this.patchPastTx({ id: element.id, status: finalObject.status, updated_at: new Date().toISOString() }, address);
408
+ this.patchPastTx({ id: element.id, status: finalObject.status }, address);
409
409
  }
410
410
 
411
411
  const finalTx = this.cancelTxCalculate(pastTx);
@@ -1,3 +1,5 @@
1
+ import { CHAIN_NAMESPACES } from "@toruslabs/base-controllers";
2
+
1
3
  import { EthereumProviderConfig } from "./interfaces";
2
4
 
3
5
  export const LOCALHOST = "localhost";
@@ -34,6 +36,8 @@ const INFURA_KEY = process.env.VITE_APP_INFURA_PROJECT_KEY;
34
36
 
35
37
  export const SUPPORTED_NETWORKS: Record<string, EthereumProviderConfig> = {
36
38
  [MAINNET_CHAIN_ID]: {
39
+ chainNamespace: CHAIN_NAMESPACES.EIP155,
40
+ decimals: 18,
37
41
  blockExplorerUrl: "https://etherscan.io",
38
42
  chainId: MAINNET_CHAIN_ID,
39
43
  displayName: "Ethereum",
@@ -43,6 +47,8 @@ export const SUPPORTED_NETWORKS: Record<string, EthereumProviderConfig> = {
43
47
  tickerName: "Ethereum",
44
48
  },
45
49
  [POLYGON_CHAIN_ID]: {
50
+ chainNamespace: CHAIN_NAMESPACES.EIP155,
51
+ decimals: 18,
46
52
  blockExplorerUrl: "https://polygonscan.com",
47
53
  chainId: POLYGON_CHAIN_ID,
48
54
  displayName: "Polygon",
@@ -52,6 +58,8 @@ export const SUPPORTED_NETWORKS: Record<string, EthereumProviderConfig> = {
52
58
  tickerName: "Matic Network Token",
53
59
  },
54
60
  [BSC_MAINNET_CHAIN_ID]: {
61
+ chainNamespace: CHAIN_NAMESPACES.EIP155,
62
+ decimals: 18,
55
63
  blockExplorerUrl: "https://bscscan.com",
56
64
  chainId: BSC_MAINNET_CHAIN_ID,
57
65
  displayName: "Binance Smart Chain (BSC)",
@@ -61,6 +69,8 @@ export const SUPPORTED_NETWORKS: Record<string, EthereumProviderConfig> = {
61
69
  tickerName: "Binance Coin",
62
70
  },
63
71
  [AVALANCHE_MAINNET_CHAIN_ID]: {
72
+ chainNamespace: CHAIN_NAMESPACES.EIP155,
73
+ decimals: 18,
64
74
  blockExplorerUrl: "https://snowtrace.io",
65
75
  chainId: AVALANCHE_MAINNET_CHAIN_ID,
66
76
  displayName: "Avalanche",
@@ -70,6 +80,8 @@ export const SUPPORTED_NETWORKS: Record<string, EthereumProviderConfig> = {
70
80
  tickerName: "Avalanche",
71
81
  },
72
82
  [OPTIMISM_MAINNET_CHAIN_ID]: {
83
+ chainNamespace: CHAIN_NAMESPACES.EIP155,
84
+ decimals: 18,
73
85
  blockExplorerUrl: "https://optimistic.etherscan.io",
74
86
  chainId: OPTIMISM_MAINNET_CHAIN_ID,
75
87
  displayName: "Optimism",
@@ -79,6 +91,8 @@ export const SUPPORTED_NETWORKS: Record<string, EthereumProviderConfig> = {
79
91
  tickerName: "Ethereum",
80
92
  },
81
93
  [CELO_MAINNET_CHAIN_ID]: {
94
+ chainNamespace: CHAIN_NAMESPACES.EIP155,
95
+ decimals: 18,
82
96
  blockExplorerUrl: "https://explorer.celo.org",
83
97
  chainId: CELO_MAINNET_CHAIN_ID,
84
98
  displayName: "Celo Mainnet",
@@ -88,6 +102,8 @@ export const SUPPORTED_NETWORKS: Record<string, EthereumProviderConfig> = {
88
102
  tickerName: "Celo",
89
103
  },
90
104
  [ARBITRUM_MAINNET_CHAIN_ID]: {
105
+ chainNamespace: CHAIN_NAMESPACES.EIP155,
106
+ decimals: 18,
91
107
  blockExplorerUrl: "https://arbiscan.io",
92
108
  chainId: ARBITRUM_MAINNET_CHAIN_ID,
93
109
  displayName: "Arbitrum One",
@@ -97,6 +113,8 @@ export const SUPPORTED_NETWORKS: Record<string, EthereumProviderConfig> = {
97
113
  tickerName: "Ethereum",
98
114
  },
99
115
  [XDAI_CHAIN_ID]: {
116
+ chainNamespace: CHAIN_NAMESPACES.EIP155,
117
+ decimals: 18,
100
118
  blockExplorerUrl: "https://gnosis.blockscout.com",
101
119
  chainId: XDAI_CHAIN_ID,
102
120
  displayName: "xDai",
@@ -106,6 +124,8 @@ export const SUPPORTED_NETWORKS: Record<string, EthereumProviderConfig> = {
106
124
  tickerName: "xDai Token",
107
125
  },
108
126
  [BASE_CHAIN_ID]: {
127
+ chainNamespace: CHAIN_NAMESPACES.EIP155,
128
+ decimals: 18,
109
129
  blockExplorerUrl: "https://basescan.org",
110
130
  chainId: BASE_CHAIN_ID,
111
131
  displayName: "Base",
@@ -115,6 +135,8 @@ export const SUPPORTED_NETWORKS: Record<string, EthereumProviderConfig> = {
115
135
  tickerName: "Ethereum",
116
136
  },
117
137
  [SEPOLIA_CHAIN_ID]: {
138
+ chainNamespace: CHAIN_NAMESPACES.EIP155,
139
+ decimals: 18,
118
140
  blockExplorerUrl: "https://sepolia.etherscan.io",
119
141
  chainId: SEPOLIA_CHAIN_ID,
120
142
  displayName: "Sepolia Test Network",
@@ -125,6 +147,8 @@ export const SUPPORTED_NETWORKS: Record<string, EthereumProviderConfig> = {
125
147
  isTestnet: true,
126
148
  },
127
149
  [POLYGON_MUMBAI_CHAIN_ID]: {
150
+ chainNamespace: CHAIN_NAMESPACES.EIP155,
151
+ decimals: 18,
128
152
  blockExplorerUrl: "https://mumbai.polygonscan.com",
129
153
  chainId: POLYGON_MUMBAI_CHAIN_ID,
130
154
  displayName: "Polygon Mumbai",
@@ -135,6 +159,8 @@ export const SUPPORTED_NETWORKS: Record<string, EthereumProviderConfig> = {
135
159
  isTestnet: true,
136
160
  },
137
161
  [BSC_TESTNET_CHAIN_ID]: {
162
+ chainNamespace: CHAIN_NAMESPACES.EIP155,
163
+ decimals: 18,
138
164
  blockExplorerUrl: "https://testnet.bscscan.com",
139
165
  chainId: BSC_TESTNET_CHAIN_ID,
140
166
  displayName: "Binance Smart Chain Testnet",
@@ -145,6 +171,8 @@ export const SUPPORTED_NETWORKS: Record<string, EthereumProviderConfig> = {
145
171
  isTestnet: true,
146
172
  },
147
173
  [AVALANCHE_TESTNET_CHAIN_ID]: {
174
+ chainNamespace: CHAIN_NAMESPACES.EIP155,
175
+ decimals: 18,
148
176
  blockExplorerUrl: "https://testnet.snowtrace.io",
149
177
  chainId: AVALANCHE_TESTNET_CHAIN_ID,
150
178
  displayName: "Avalanche Testnet C-Chain",
@@ -155,6 +183,8 @@ export const SUPPORTED_NETWORKS: Record<string, EthereumProviderConfig> = {
155
183
  isTestnet: true,
156
184
  },
157
185
  [ARBITRUM_TESTNET_CHAIN_ID]: {
186
+ chainNamespace: CHAIN_NAMESPACES.EIP155,
187
+ decimals: 18,
158
188
  blockExplorerUrl: "https://sepolia.arbiscan.io",
159
189
  chainId: ARBITRUM_TESTNET_CHAIN_ID,
160
190
  displayName: "Arbitrum Sepolia",
@@ -165,6 +195,8 @@ export const SUPPORTED_NETWORKS: Record<string, EthereumProviderConfig> = {
165
195
  isTestnet: true,
166
196
  },
167
197
  [OPTIMISM_TESTNET_CHAIN_ID]: {
198
+ chainNamespace: CHAIN_NAMESPACES.EIP155,
199
+ decimals: 18,
168
200
  blockExplorerUrl: "https://sepolia-optimistic.etherscan.io",
169
201
  chainId: OPTIMISM_TESTNET_CHAIN_ID,
170
202
  displayName: "Optimism Sepolia",
@@ -175,6 +207,8 @@ export const SUPPORTED_NETWORKS: Record<string, EthereumProviderConfig> = {
175
207
  isTestnet: true,
176
208
  },
177
209
  [BASE_TESTNET_CHAIN_ID]: {
210
+ chainNamespace: CHAIN_NAMESPACES.EIP155,
211
+ decimals: 18,
178
212
  blockExplorerUrl: "https://sepolia.basescan.org",
179
213
  chainId: BASE_TESTNET_CHAIN_ID,
180
214
  displayName: "Base Sepolia",
@@ -51,8 +51,8 @@ export const formatPastTx = (x: TransactionPayload, lowerCaseSelectedAddress?: s
51
51
  currencyAmountString,
52
52
  amount: `${totalAmountString} / ${currencyAmountString}`,
53
53
  status: x.status,
54
- etherscanLink: getEtherScanHashLink(x.transaction_hash, x.network || MAINNET_CHAIN_ID),
55
- networkType: x.network,
54
+ etherscanLink: getEtherScanHashLink(x.transaction_hash, x.chain_id || MAINNET_CHAIN_ID),
55
+ chainId: x.chain_id,
56
56
  ethRate:
57
57
  Number.parseFloat(x?.total_amount) && Number.parseFloat(x?.currency_amount)
58
58
  ? `1 ${x.symbol} = ${significantDigits(Number.parseFloat(x.currency_amount) / Number.parseFloat(x.total_amount))}`
@@ -380,7 +380,7 @@ export interface TransactionPayload {
380
380
  currency_amount: string;
381
381
  selected_currency: string;
382
382
  status?: TransactionStatus;
383
- network: string;
383
+ chain_id: string;
384
384
  transaction_hash: string;
385
385
  transaction_category: string;
386
386
  gas: string;
@@ -421,7 +421,7 @@ export interface FormattedTransactionActivity {
421
421
  etherscanLink: string;
422
422
  ethRate: string;
423
423
  currencyUsed: string;
424
- networkType: string;
424
+ chainId: string;
425
425
  type: string;
426
426
  type_name: string;
427
427
  type_image_link: string;