@toruslabs/ethereum-controllers 5.5.3 → 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 (50) hide show
  1. package/dist/ethereumControllers.cjs.js +3 -12
  2. package/dist/ethereumControllers.esm.js +2 -11
  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/package.json +14 -15
  7. package/dist/ethereumControllers.cjs.js.map +0 -1
  8. package/dist/ethereumControllers.esm.js.map +0 -1
  9. package/dist/ethereumControllers.umd.min.js.map +0 -1
  10. package/src/Account/AccountTrackerController.ts +0 -172
  11. package/src/Block/PollingBlockTracker.ts +0 -89
  12. package/src/Currency/CurrencyController.ts +0 -117
  13. package/src/Gas/GasFeeController.ts +0 -261
  14. package/src/Gas/IGasFeeController.ts +0 -56
  15. package/src/Gas/gasUtil.ts +0 -163
  16. package/src/Keyring/KeyringController.ts +0 -117
  17. package/src/Message/AbstractMessageController.ts +0 -136
  18. package/src/Message/AddChainController.ts +0 -73
  19. package/src/Message/DecryptMessageController.ts +0 -76
  20. package/src/Message/EncryptionPublicKeyController.ts +0 -75
  21. package/src/Message/MessageController.ts +0 -74
  22. package/src/Message/PersonalMessageController.ts +0 -74
  23. package/src/Message/SwitchChainController.ts +0 -74
  24. package/src/Message/TypedMessageController.ts +0 -109
  25. package/src/Message/utils.ts +0 -155
  26. package/src/Network/NetworkController.ts +0 -184
  27. package/src/Network/createEthereumMiddleware.ts +0 -475
  28. package/src/Network/createJsonRpcClient.ts +0 -63
  29. package/src/Nfts/INftsController.ts +0 -13
  30. package/src/Nfts/NftHandler.ts +0 -191
  31. package/src/Nfts/NftsController.ts +0 -216
  32. package/src/Preferences/PreferencesController.ts +0 -473
  33. package/src/Tokens/ITokensController.ts +0 -13
  34. package/src/Tokens/TokenHandler.ts +0 -60
  35. package/src/Tokens/TokenRatesController.ts +0 -134
  36. package/src/Tokens/TokensController.ts +0 -273
  37. package/src/Transaction/NonceTracker.ts +0 -152
  38. package/src/Transaction/PendingTransactionTracker.ts +0 -235
  39. package/src/Transaction/TransactionController.ts +0 -558
  40. package/src/Transaction/TransactionGasUtil.ts +0 -74
  41. package/src/Transaction/TransactionStateHistoryHelper.ts +0 -41
  42. package/src/Transaction/TransactionStateManager.ts +0 -315
  43. package/src/Transaction/TransactionUtils.ts +0 -333
  44. package/src/index.ts +0 -49
  45. package/src/utils/abis.ts +0 -677
  46. package/src/utils/constants.ts +0 -438
  47. package/src/utils/contractAddresses.ts +0 -19
  48. package/src/utils/conversionUtils.ts +0 -269
  49. package/src/utils/helpers.ts +0 -245
  50. package/src/utils/interfaces.ts +0 -519
@@ -1,269 +0,0 @@
1
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
- // @ts-nocheck
3
- /* Currency Conversion Utility
4
- * This utility function can be used for converting currency related values within metamask.
5
- * The caller should be able to pass it a value, along with information about the value's
6
- * numeric base, denomination and currency, and the desired numeric base, denomination and
7
- * currency. It should return a single value.
8
- *
9
- * @param {(number | string | BN)} value - The value to convert.
10
- * @param {Object} [options] - Options to specify details of the conversion
11
- * @param {string} [options.fromCurrency = 'ETH' | 'USD'] - The currency of the passed value
12
- * @param {string} [options.toCurrency = 'ETH' | 'USD'] - The desired currency of the result
13
- * @param {string} [options.fromNumericBase = 'hex' | 'dec' | 'BN'] - The numeric basic of the passed value.
14
- * @param {string} [options.toNumericBase = 'hex' | 'dec' | 'BN'] - The desired numeric basic of the result.
15
- * @param {string} [options.fromDenomination = 'WEI'] - The denomination of the passed value
16
- * @param {string} [options.numberOfDecimals] - The desired number of decimals in the result
17
- * @param {string} [options.roundDown] - The desired number of decimals to round down to
18
- * @param {number} [options.conversionRate] - The rate to use to make the fromCurrency -> toCurrency conversion
19
- * @returns {(number | string | BN)}
20
- *
21
- * The utility passes value along with the options as a single object to the `converter` function.
22
- * `converter` conditional modifies the supplied `value` property, depending
23
- * on the accompanying options.
24
- */
25
-
26
- import { stripHexPrefix } from "@ethereumjs/util";
27
- import BigNumber from "bignumber.js";
28
- import BN from "bn.js";
29
-
30
- // Big Number Constants
31
- const BIG_NUMBER_WEI_MULTIPLIER = new BigNumber("1000000000000000000");
32
- const BIG_NUMBER_GWEI_MULTIPLIER = new BigNumber("1000000000");
33
- const BIG_NUMBER_ETH_MULTIPLIER = new BigNumber("1");
34
-
35
- type NumericBase = "hex" | "dec" | "BN";
36
-
37
- type EthDenomination = "WEI" | "GWEI" | "ETH";
38
-
39
- type ConverterOptions = {
40
- value: BigNumber | string;
41
- fromNumericBase: NumericBase;
42
- fromDenomination: EthDenomination;
43
- fromCurrency: string;
44
- toNumericBase: NumericBase;
45
- toDenomination: EthDenomination;
46
- toCurrency: string;
47
- numberOfDecimals: number;
48
- conversionRate: number;
49
- invertConversionRate: boolean;
50
- roundDown?: number;
51
- };
52
-
53
- // Setter Maps
54
- const toBigNumber = {
55
- hex: (n) => new BigNumber(stripHexPrefix(n), 16),
56
- dec: (n) => new BigNumber(String(n), 10),
57
- BN: (n) => new BigNumber(n.toString(16), 16),
58
- };
59
- const toNormalizedDenomination = {
60
- WEI: (bigNumber) => bigNumber.div(BIG_NUMBER_WEI_MULTIPLIER),
61
- GWEI: (bigNumber) => bigNumber.div(BIG_NUMBER_GWEI_MULTIPLIER),
62
- ETH: (bigNumber) => bigNumber.div(BIG_NUMBER_ETH_MULTIPLIER),
63
- };
64
- const toSpecifiedDenomination = {
65
- WEI: (bigNumber) => bigNumber.times(BIG_NUMBER_WEI_MULTIPLIER).dp(0, BigNumber.ROUND_HALF_UP),
66
- GWEI: (bigNumber) => bigNumber.times(BIG_NUMBER_GWEI_MULTIPLIER).dp(9, BigNumber.ROUND_HALF_UP),
67
- ETH: (bigNumber) => bigNumber.times(BIG_NUMBER_ETH_MULTIPLIER).dp(9, BigNumber.ROUND_HALF_UP),
68
- };
69
- const baseChange = {
70
- hex: (n) => n.toString(16),
71
- dec: (n) => new BigNumber(n).toString(10),
72
- BN: (n) => new BN(n.toString(16)),
73
- };
74
-
75
- // Utility function for checking base types
76
- const isValidBase = (base) => Number.isInteger(base) && base > 1;
77
-
78
- /**
79
- * Utility method to convert a value between denominations, formats and currencies.
80
- */
81
- const converter = ({
82
- value,
83
- fromNumericBase,
84
- fromDenomination,
85
- fromCurrency,
86
- toNumericBase,
87
- toDenomination,
88
- toCurrency,
89
- numberOfDecimals,
90
- conversionRate,
91
- invertConversionRate,
92
- roundDown,
93
- }: ConverterOptions) => {
94
- let convertedValue = fromNumericBase ? toBigNumber[fromNumericBase](value) : value;
95
-
96
- if (fromDenomination) {
97
- convertedValue = toNormalizedDenomination[fromDenomination](convertedValue);
98
- }
99
-
100
- if (fromCurrency !== toCurrency) {
101
- if (conversionRate === null || conversionRate === undefined) {
102
- throw new Error(`Converting from ${fromCurrency} to ${toCurrency} requires a conversionRate, but one was not provided`);
103
- }
104
- let rate = toBigNumber.dec(conversionRate);
105
- if (invertConversionRate) {
106
- rate = new BigNumber(1).div(conversionRate);
107
- }
108
- convertedValue = convertedValue.times(rate);
109
- }
110
-
111
- if (toDenomination) {
112
- convertedValue = toSpecifiedDenomination[toDenomination](convertedValue);
113
- }
114
-
115
- if (numberOfDecimals) {
116
- convertedValue = convertedValue.dp(numberOfDecimals, BigNumber.ROUND_HALF_DOWN);
117
- }
118
-
119
- if (roundDown) {
120
- convertedValue = convertedValue.dp(roundDown, BigNumber.ROUND_DOWN);
121
- }
122
-
123
- if (toNumericBase) {
124
- convertedValue = baseChange[toNumericBase](convertedValue);
125
- }
126
- return convertedValue;
127
- };
128
-
129
- export const conversionUtil = (
130
- value: BigNumber | string,
131
- {
132
- fromCurrency = null,
133
- toCurrency = fromCurrency,
134
- fromNumericBase,
135
- toNumericBase,
136
- fromDenomination,
137
- toDenomination,
138
- numberOfDecimals,
139
- conversionRate,
140
- invertConversionRate,
141
- }: Omit<ConverterOptions, "value">
142
- ) => {
143
- if (fromCurrency !== toCurrency && !conversionRate) {
144
- return 0;
145
- }
146
- return converter({
147
- fromCurrency,
148
- toCurrency,
149
- fromNumericBase,
150
- toNumericBase,
151
- fromDenomination,
152
- toDenomination,
153
- numberOfDecimals,
154
- conversionRate,
155
- invertConversionRate,
156
- value,
157
- });
158
- };
159
-
160
- export const getBigNumber = (value, base) => {
161
- if (!isValidBase(base)) {
162
- throw new Error("Must specificy valid base");
163
- }
164
-
165
- // We don't include 'number' here, because BigNumber will throw if passed
166
- // a number primitive it considers unsafe.
167
- if (typeof value === "string" || value instanceof BigNumber) {
168
- return new BigNumber(value, base);
169
- }
170
-
171
- return new BigNumber(String(value), base);
172
- };
173
-
174
- export const addCurrencies = (a, b, options: Record<string, unknown> = {}) => {
175
- const { aBase, bBase, ...conversionOptions } = options;
176
-
177
- if (!isValidBase(aBase) || !isValidBase(bBase)) {
178
- throw new Error("Must specify valid aBase and bBase");
179
- }
180
-
181
- const value = getBigNumber(a, aBase).plus(getBigNumber(b, bBase));
182
-
183
- return converter({
184
- value,
185
- ...conversionOptions,
186
- } as ConverterOptions);
187
- };
188
-
189
- export const subtractCurrencies = (a, b, options: Record<string, unknown> = {}) => {
190
- const { aBase, bBase, ...conversionOptions } = options;
191
-
192
- if (!isValidBase(aBase) || !isValidBase(bBase)) {
193
- throw new Error("Must specify valid aBase and bBase");
194
- }
195
-
196
- const value = getBigNumber(a, aBase).minus(getBigNumber(b, bBase));
197
-
198
- return converter({
199
- value,
200
- ...conversionOptions,
201
- } as ConverterOptions);
202
- };
203
-
204
- export const multiplyCurrencies = (a, b, options: Record<string, unknown> = {}) => {
205
- const { multiplicandBase, multiplierBase, ...conversionOptions } = options;
206
-
207
- if (!isValidBase(multiplicandBase) || !isValidBase(multiplierBase)) {
208
- throw new Error("Must specify valid multiplicandBase and multiplierBase");
209
- }
210
-
211
- const value = getBigNumber(a, multiplicandBase).times(getBigNumber(b, multiplierBase));
212
-
213
- return converter({
214
- value,
215
- ...conversionOptions,
216
- } as ConverterOptions);
217
- };
218
-
219
- export const conversionGreaterThan = ({ ...firstProps }: ConverterOptions, { ...secondProps }: ConverterOptions) => {
220
- const firstValue = converter({ ...firstProps });
221
- const secondValue = converter({ ...secondProps });
222
-
223
- return firstValue.gt(secondValue);
224
- };
225
-
226
- export const conversionLessThan = ({ ...firstProps }: ConverterOptions, { ...secondProps }: ConverterOptions) => {
227
- const firstValue = converter({ ...firstProps });
228
- const secondValue = converter({ ...secondProps });
229
-
230
- return firstValue.lt(secondValue);
231
- };
232
-
233
- export const conversionMax = ({ ...firstProps }, { ...secondProps }) => {
234
- const firstIsGreater = conversionGreaterThan({ ...firstProps }, { ...secondProps });
235
-
236
- return firstIsGreater ? firstProps.value : secondProps.value;
237
- };
238
-
239
- export const conversionGTE = ({ ...firstProps }, { ...secondProps }) => {
240
- const firstValue = converter({ ...firstProps } as ConverterOptions);
241
- const secondValue = converter({ ...secondProps } as ConverterOptions);
242
- return firstValue.isGreaterThanOrEqualTo(secondValue);
243
- };
244
-
245
- export const conversionLTE = ({ ...firstProps }, { ...secondProps }) => {
246
- const firstValue = converter({ ...firstProps } as ConverterOptions);
247
- const secondValue = converter({ ...secondProps } as ConverterOptions);
248
- return firstValue.isLessThanOrEqualTo(secondValue);
249
- };
250
-
251
- export const toNegative = (n, options = {}) => multiplyCurrencies(n, -1, options);
252
-
253
- export const decGWEIToHexWEI = (decGWEI: BigNumber): BigNumber => {
254
- return conversionUtil(decGWEI, {
255
- fromNumericBase: "dec",
256
- toNumericBase: "hex",
257
- fromDenomination: "GWEI",
258
- toDenomination: "WEI",
259
- } as ConverterOptions);
260
- };
261
-
262
- export const hexWEIToDecGWEI = (decGWEI: BigNumber | string): BigNumber => {
263
- return conversionUtil(decGWEI, {
264
- fromNumericBase: "hex",
265
- toNumericBase: "dec",
266
- fromDenomination: "WEI",
267
- toDenomination: "GWEI",
268
- } as ConverterOptions);
269
- };
@@ -1,245 +0,0 @@
1
- import { addHexPrefix, isValidAddress, toChecksumAddress } from "@ethereumjs/util";
2
- import {
3
- ACTIVITY_ACTION_RECEIVE,
4
- ACTIVITY_ACTION_SEND,
5
- addressSlicer,
6
- formatSmallNumbers,
7
- significantDigits,
8
- TransactionStatus,
9
- } from "@toruslabs/base-controllers";
10
- import { SafeEventEmitterProvider } from "@toruslabs/openlogin-jrpc";
11
- import BigNumber from "bignumber.js";
12
- import log from "loglevel";
13
-
14
- import { determineTransactionType } from "../Transaction/TransactionUtils";
15
- import {
16
- CONTRACT_TYPE_ERC20,
17
- CONTRACT_TYPE_ERC721,
18
- CONTRACT_TYPE_ERC1155,
19
- CONTRACT_TYPE_ETH,
20
- MAINNET_CHAIN_ID,
21
- METHOD_TYPES,
22
- SUPPORTED_NETWORKS,
23
- TEST_CHAINS,
24
- } from "./constants";
25
- import { EtherscanTransaction, FormattedTransactionActivity, TransactionParams, TransactionPayload, TransactionReceipt } from "./interfaces";
26
-
27
- export function getEtherScanHashLink(txHash: string, chainId: string) {
28
- if (!SUPPORTED_NETWORKS[chainId]) return "";
29
- return `${SUPPORTED_NETWORKS[chainId].blockExplorerUrl}/tx/${txHash}`;
30
- }
31
-
32
- export const formatPastTx = (x: TransactionPayload, lowerCaseSelectedAddress?: string): FormattedTransactionActivity => {
33
- let totalAmountString = "";
34
- if (x.type === CONTRACT_TYPE_ERC721 || x.type === CONTRACT_TYPE_ERC1155) totalAmountString = x.symbol;
35
- else if (x.type === CONTRACT_TYPE_ERC20) totalAmountString = formatSmallNumbers(Number.parseFloat(x.total_amount), x.symbol, true);
36
- else totalAmountString = formatSmallNumbers(Number.parseFloat(x.total_amount), x.type_name, true);
37
- const currencyAmountString =
38
- x.type === CONTRACT_TYPE_ERC721 || x.type === CONTRACT_TYPE_ERC1155 || x.isEtherscan
39
- ? ""
40
- : formatSmallNumbers(Number.parseFloat(x.currency_amount), x.selected_currency, true);
41
- const finalObject: FormattedTransactionActivity = {
42
- id: x.created_at.toString(),
43
- date: new Date(x.created_at).toString(),
44
- from: x.from,
45
- from_aa_address: x.from_aa_address,
46
- slicedFrom: typeof x.from === "string" ? addressSlicer(x.from) : "",
47
- to: x.to,
48
- slicedTo: typeof x.to === "string" ? addressSlicer(x.to) : "",
49
- action: lowerCaseSelectedAddress === x.to?.toLowerCase() || "" ? ACTIVITY_ACTION_RECEIVE : ACTIVITY_ACTION_SEND,
50
- totalAmount: x.total_amount,
51
- totalAmountString,
52
- currencyAmount: x.currency_amount,
53
- currencyAmountString,
54
- amount: `${totalAmountString} / ${currencyAmountString}`,
55
- status: x.status,
56
- etherscanLink: getEtherScanHashLink(x.transaction_hash, x.chain_id || MAINNET_CHAIN_ID),
57
- chainId: x.chain_id,
58
- ethRate:
59
- Number.parseFloat(x?.total_amount) && Number.parseFloat(x?.currency_amount)
60
- ? `1 ${x.symbol} = ${significantDigits(Number.parseFloat(x.currency_amount) / Number.parseFloat(x.total_amount))}`
61
- : "",
62
- currencyUsed: x.selected_currency,
63
- type: x.type,
64
- type_name: x.type_name,
65
- type_image_link: x.type_image_link,
66
- transaction_hash: x.transaction_hash,
67
- transaction_category: x.transaction_category,
68
- isEtherscan: x.isEtherscan,
69
- input: x.input || "",
70
- token_id: x.token_id || "",
71
- contract_address: x.contract_address || "",
72
- nonce: x.nonce || "",
73
- is_cancel: !!x.is_cancel || false,
74
- gas: x.gas || "",
75
- gasPrice: x.gasPrice || "",
76
- };
77
- return finalObject;
78
- };
79
-
80
- /**
81
- * Ref - https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_gettransactionreceipt
82
- */
83
- export const getEthTxStatus = async (hash: string, provider: SafeEventEmitterProvider): Promise<TransactionStatus | undefined> => {
84
- try {
85
- const result = await provider.request<[string], TransactionReceipt>({ method: METHOD_TYPES.ETH_GET_TRANSACTION_RECEIPT, params: [hash] });
86
- if (result === null) return TransactionStatus.submitted;
87
- if (result && result.status === "0x1") return TransactionStatus.confirmed;
88
- if (result && result.status === "0x0") return TransactionStatus.rejected;
89
- return undefined;
90
- } catch (err) {
91
- log.warn("unable to fetch transaction status", err);
92
- return undefined;
93
- }
94
- };
95
-
96
- export function formatDate(inputDate: string) {
97
- const monthList = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
98
- const date = new Date(inputDate);
99
- const day = date.getDate();
100
- const month = monthList[date.getMonth()];
101
- const year = date.getFullYear();
102
- return `${day} ${month} ${year}`;
103
- }
104
-
105
- export function formatTime(time: number) {
106
- return new Date(time).toTimeString().slice(0, 8);
107
- }
108
-
109
- export const idleTimeTracker = ((activityThresholdTime: number): { checkIfIdle: () => boolean } => {
110
- let isIdle = false;
111
- let idleTimeout: number = null;
112
-
113
- const resetTimer = () => {
114
- if (idleTimeout) {
115
- window.clearTimeout(idleTimeout);
116
- }
117
- isIdle = false;
118
- idleTimeout = window.setTimeout(() => {
119
- isIdle = true;
120
- }, activityThresholdTime * 1000);
121
- };
122
-
123
- if (typeof window !== "undefined" && typeof document !== "undefined") {
124
- window.addEventListener("load", resetTimer);
125
- document.addEventListener("mousemove", resetTimer);
126
- document.addEventListener("keydown", resetTimer);
127
- }
128
-
129
- function checkIfIdle() {
130
- return isIdle;
131
- }
132
- return {
133
- checkIfIdle,
134
- };
135
- })(60 * 3);
136
-
137
- export function isAddressByChainId(address: string, _chainId: string) {
138
- // TOOD: add rsk network checks.
139
- return isValidAddress(address);
140
- }
141
-
142
- export function toChecksumAddressByChainId(address: string, chainId: string) {
143
- // TOOD: add rsk network checks.
144
- if (!isAddressByChainId(address, chainId)) return address;
145
- return toChecksumAddress(address);
146
- }
147
-
148
- export const GAS_LIMITS = {
149
- // maximum gasLimit of a simple send
150
- SIMPLE: addHexPrefix((21_000).toString(16)),
151
- // a base estimate for token transfers.
152
- BASE_TOKEN_ESTIMATE: addHexPrefix((100_000).toString(16)),
153
- };
154
-
155
- export function bnLessThan(a: string | number, b: string | number) {
156
- if (a === null || a === undefined || b === null || b === undefined) {
157
- return null;
158
- }
159
- return new BigNumber(a, 10).lt(b, 10);
160
- }
161
-
162
- export const getIpfsEndpoint = (path: string) => `https://infura-ipfs.io/${path}`;
163
-
164
- export function sanitizeNftMetdataUrl(url: string): string {
165
- let finalUri = url;
166
- if (url?.startsWith("ipfs")) {
167
- const ipfsPath = url.split("ipfs://")[1];
168
- finalUri = getIpfsEndpoint(ipfsPath);
169
- }
170
- return finalUri;
171
- }
172
-
173
- export function getChainType(chainId: string) {
174
- if (chainId === MAINNET_CHAIN_ID) {
175
- return "mainnet";
176
- } else if ((TEST_CHAINS as string[]).includes(chainId)) {
177
- return "testnet";
178
- }
179
- return "custom";
180
- }
181
-
182
- export const addEtherscanTransactions = async (
183
- txn: EtherscanTransaction[],
184
- lowerCaseSelectedAddress: string,
185
- provider: SafeEventEmitterProvider,
186
- chainId: string
187
- ) => {
188
- const transactionPromises = await Promise.all(
189
- txn.map(async (tx: EtherscanTransaction) => {
190
- const { category, type } = await determineTransactionType({ ...tx, data: tx.input } as TransactionParams, provider);
191
- tx.transaction_category = tx.transaction_category || category;
192
- tx.type_image_link = SUPPORTED_NETWORKS[chainId]?.logo || "";
193
- tx.type_name = SUPPORTED_NETWORKS[chainId]?.ticker;
194
- tx.type = type;
195
- return tx;
196
- })
197
- );
198
-
199
- const finalTxs = transactionPromises.reduce((accumulator, x) => {
200
- let totalAmountString = x.value ? new BigNumber(x.value).div(new BigNumber(10).pow(new BigNumber(x.tokenDecimal || 18))).toString() : "";
201
- let type = CONTRACT_TYPE_ETH;
202
- if (x.contractAddress !== "") {
203
- if (x.tokenID) {
204
- type = x.tokenValue ? CONTRACT_TYPE_ERC1155 : CONTRACT_TYPE_ERC721;
205
- } else {
206
- type = CONTRACT_TYPE_ERC20;
207
- }
208
- }
209
-
210
- if (type === CONTRACT_TYPE_ERC1155) {
211
- totalAmountString = x.tokenValue;
212
- }
213
-
214
- const etherscanTransaction: TransactionPayload = {
215
- etherscanLink: getEtherScanHashLink(x.hash, chainId),
216
- type,
217
- type_image_link: x.type_image_link || "n/a",
218
- type_name: x.tokenName || SUPPORTED_NETWORKS[chainId]?.ticker || "n/a",
219
- symbol: x.tokenSymbol || SUPPORTED_NETWORKS[chainId]?.ticker,
220
- token_id: x.tokenID || "",
221
- total_amount: totalAmountString,
222
- created_at: new Date(Number(x.timeStamp) * 1000),
223
- from: x.from,
224
- to: x.to,
225
- transaction_hash: x.hash,
226
- status: x.txreceipt_status && x.txreceipt_status === "0" ? TransactionStatus.failed : TransactionStatus.confirmed,
227
- isEtherscan: true,
228
- input: x.input,
229
- contract_address: x.contractAddress,
230
- transaction_category: x.transaction_category,
231
- gas: `0x${new BigNumber(x.gasUsed || 0, 10).toString(16)}`,
232
- gasPrice: `0x${new BigNumber(x.gasPrice || 0, 10).toString(16)}`,
233
- chain_id: chainId,
234
- currency_amount: "",
235
- nonce: x.nonce,
236
- from_aa_address: "",
237
- is_cancel: false,
238
- selected_currency: "",
239
- };
240
- accumulator.push(formatPastTx(etherscanTransaction, lowerCaseSelectedAddress));
241
- return accumulator;
242
- }, []);
243
-
244
- return finalTxs;
245
- };