@ledgerhq/coin-evm 8.0.0 → 9.0.1
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.
- package/CHANGELOG.md +25 -0
- package/docs/getBlock-internal-txs-schema.md +1 -1
- package/docs/network/node/index.md +3 -1
- package/lib/adapters/blockOperations.d.ts +4 -3
- package/lib/adapters/blockOperations.d.ts.map +1 -1
- package/lib/adapters/blockOperations.js +17 -17
- package/lib/adapters/blockOperations.js.map +1 -1
- package/lib/adapters/etherscan.d.ts +7 -6
- package/lib/adapters/etherscan.d.ts.map +1 -1
- package/lib/adapters/etherscan.js +19 -19
- package/lib/adapters/etherscan.js.map +1 -1
- package/lib/adapters/ledger.d.ts +6 -5
- package/lib/adapters/ledger.d.ts.map +1 -1
- package/lib/adapters/ledger.js +15 -15
- package/lib/adapters/ledger.js.map +1 -1
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +1 -2
- package/lib/api/index.js.map +1 -1
- package/lib/logic/common.js +1 -1
- package/lib/logic/common.js.map +1 -1
- package/lib/logic/getBalance.d.ts.map +1 -1
- package/lib/logic/getBalance.js +3 -3
- package/lib/logic/getBalance.js.map +1 -1
- package/lib/logic/getBlock.d.ts.map +1 -1
- package/lib/logic/getBlock.js +22 -23
- package/lib/logic/getBlock.js.map +1 -1
- package/lib/logic/getStakes.d.ts.map +1 -1
- package/lib/logic/getStakes.js +2 -2
- package/lib/logic/getStakes.js.map +1 -1
- package/lib/logic/internalTransactionsFetcher.d.ts +3 -2
- package/lib/logic/internalTransactionsFetcher.d.ts.map +1 -1
- package/lib/logic/internalTransactionsFetcher.js +13 -10
- package/lib/logic/internalTransactionsFetcher.js.map +1 -1
- package/lib/logic/listOperations.js +1 -1
- package/lib/logic/listOperations.js.map +1 -1
- package/lib/logic-public/utils.d.ts +3 -2
- package/lib/logic-public/utils.d.ts.map +1 -1
- package/lib/logic-public/utils.js +7 -6
- package/lib/logic-public/utils.js.map +1 -1
- package/lib/network/explorer/etherscan.d.ts +3 -2
- package/lib/network/explorer/etherscan.d.ts.map +1 -1
- package/lib/network/explorer/etherscan.js +13 -12
- package/lib/network/explorer/etherscan.js.map +1 -1
- package/lib/network/explorer/ledger.d.ts.map +1 -1
- package/lib/network/explorer/ledger.js +11 -11
- package/lib/network/explorer/ledger.js.map +1 -1
- package/lib/network/explorer/types.d.ts +2 -2
- package/lib/network/explorer/types.d.ts.map +1 -1
- package/lib/network/explorer/types.js.map +1 -1
- package/lib/network/node/explorerProxy.js +3 -3
- package/lib/network/node/explorerProxy.js.map +1 -1
- package/lib/network/node/index.d.ts.map +1 -1
- package/lib/network/node/index.js +2 -2
- package/lib/network/node/index.js.map +1 -1
- package/lib/network/node/ledger.d.ts +2 -1
- package/lib/network/node/ledger.d.ts.map +1 -1
- package/lib/network/node/ledger.js +9 -10
- package/lib/network/node/ledger.js.map +1 -1
- package/lib/network/node/rpc.common.d.ts +3 -2
- package/lib/network/node/rpc.common.d.ts.map +1 -1
- package/lib/network/node/rpc.common.js +52 -31
- package/lib/network/node/rpc.common.js.map +1 -1
- package/lib/network/node/rpc.errors.d.ts +1 -3
- package/lib/network/node/rpc.errors.d.ts.map +1 -1
- package/lib/network/node/rpc.errors.js +21 -2
- package/lib/network/node/rpc.errors.js.map +1 -1
- package/lib/staking/contracts.js +2 -2
- package/lib/staking/contracts.js.map +1 -1
- package/lib/staking/fetchers.d.ts.map +1 -1
- package/lib/staking/fetchers.js +7 -7
- package/lib/staking/fetchers.js.map +1 -1
- package/lib/staking/prepareIntents.d.ts +2 -1
- package/lib/staking/prepareIntents.d.ts.map +1 -1
- package/lib/staking/prepareIntents.js +4 -4
- package/lib/staking/prepareIntents.js.map +1 -1
- package/lib/staking/redelegations.d.ts +5 -4
- package/lib/staking/redelegations.d.ts.map +1 -1
- package/lib/staking/redelegations.js +13 -14
- package/lib/staking/redelegations.js.map +1 -1
- package/lib/staking/rewards.d.ts +2 -1
- package/lib/staking/rewards.d.ts.map +1 -1
- package/lib/staking/rewards.js +4 -5
- package/lib/staking/rewards.js.map +1 -1
- package/lib/staking/rewardsFromReceipt.d.ts +2 -1
- package/lib/staking/rewardsFromReceipt.d.ts.map +1 -1
- package/lib/staking/rewardsFromReceipt.js +2 -3
- package/lib/staking/rewardsFromReceipt.js.map +1 -1
- package/lib/staking/unbondings.d.ts +2 -1
- package/lib/staking/unbondings.d.ts.map +1 -1
- package/lib/staking/unbondings.js +4 -5
- package/lib/staking/unbondings.js.map +1 -1
- package/lib/staking/validators/index.d.ts +9 -4
- package/lib/staking/validators/index.d.ts.map +1 -1
- package/lib/staking/validators/index.js +19 -10
- package/lib/staking/validators/index.js.map +1 -1
- package/lib/staking/validators/monad.d.ts +6 -5
- package/lib/staking/validators/monad.d.ts.map +1 -1
- package/lib/staking/validators/monad.js +33 -29
- package/lib/staking/validators/monad.js.map +1 -1
- package/lib/staking/validators/monadResolver.d.ts +2 -1
- package/lib/staking/validators/monadResolver.d.ts.map +1 -1
- package/lib/staking/validators/monadResolver.js +2 -3
- package/lib/staking/validators/monadResolver.js.map +1 -1
- package/lib/staking/validators/somnia.d.ts +3 -2
- package/lib/staking/validators/somnia.d.ts.map +1 -1
- package/lib/staking/validators/somnia.js +16 -15
- package/lib/staking/validators/somnia.js.map +1 -1
- package/lib/staking/validators/types.d.ts +2 -1
- package/lib/staking/validators/types.d.ts.map +1 -1
- package/lib/staking/validators/zero_gravity.d.ts +2 -1
- package/lib/staking/validators/zero_gravity.d.ts.map +1 -1
- package/lib/staking/validators/zero_gravity.js +7 -8
- package/lib/staking/validators/zero_gravity.js.map +1 -1
- package/lib/types/staking.d.ts +4 -3
- package/lib/types/staking.d.ts.map +1 -1
- package/lib-es/adapters/blockOperations.d.ts +4 -3
- package/lib-es/adapters/blockOperations.d.ts.map +1 -1
- package/lib-es/adapters/blockOperations.js +17 -17
- package/lib-es/adapters/blockOperations.js.map +1 -1
- package/lib-es/adapters/etherscan.d.ts +7 -6
- package/lib-es/adapters/etherscan.d.ts.map +1 -1
- package/lib-es/adapters/etherscan.js +19 -19
- package/lib-es/adapters/etherscan.js.map +1 -1
- package/lib-es/adapters/ledger.d.ts +6 -5
- package/lib-es/adapters/ledger.d.ts.map +1 -1
- package/lib-es/adapters/ledger.js +15 -15
- package/lib-es/adapters/ledger.js.map +1 -1
- package/lib-es/api/index.d.ts.map +1 -1
- package/lib-es/api/index.js +1 -2
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/logic/common.js +1 -1
- package/lib-es/logic/common.js.map +1 -1
- package/lib-es/logic/getBalance.d.ts.map +1 -1
- package/lib-es/logic/getBalance.js +3 -3
- package/lib-es/logic/getBalance.js.map +1 -1
- package/lib-es/logic/getBlock.d.ts.map +1 -1
- package/lib-es/logic/getBlock.js +22 -23
- package/lib-es/logic/getBlock.js.map +1 -1
- package/lib-es/logic/getStakes.d.ts.map +1 -1
- package/lib-es/logic/getStakes.js +2 -2
- package/lib-es/logic/getStakes.js.map +1 -1
- package/lib-es/logic/internalTransactionsFetcher.d.ts +3 -2
- package/lib-es/logic/internalTransactionsFetcher.d.ts.map +1 -1
- package/lib-es/logic/internalTransactionsFetcher.js +13 -10
- package/lib-es/logic/internalTransactionsFetcher.js.map +1 -1
- package/lib-es/logic/listOperations.js +1 -1
- package/lib-es/logic/listOperations.js.map +1 -1
- package/lib-es/logic-public/utils.d.ts +3 -2
- package/lib-es/logic-public/utils.d.ts.map +1 -1
- package/lib-es/logic-public/utils.js +7 -6
- package/lib-es/logic-public/utils.js.map +1 -1
- package/lib-es/network/explorer/etherscan.d.ts +3 -2
- package/lib-es/network/explorer/etherscan.d.ts.map +1 -1
- package/lib-es/network/explorer/etherscan.js +13 -12
- package/lib-es/network/explorer/etherscan.js.map +1 -1
- package/lib-es/network/explorer/ledger.d.ts.map +1 -1
- package/lib-es/network/explorer/ledger.js +11 -11
- package/lib-es/network/explorer/ledger.js.map +1 -1
- package/lib-es/network/explorer/types.d.ts +2 -2
- package/lib-es/network/explorer/types.d.ts.map +1 -1
- package/lib-es/network/explorer/types.js.map +1 -1
- package/lib-es/network/node/explorerProxy.js +3 -3
- package/lib-es/network/node/explorerProxy.js.map +1 -1
- package/lib-es/network/node/index.d.ts.map +1 -1
- package/lib-es/network/node/index.js +2 -2
- package/lib-es/network/node/index.js.map +1 -1
- package/lib-es/network/node/ledger.d.ts +2 -1
- package/lib-es/network/node/ledger.d.ts.map +1 -1
- package/lib-es/network/node/ledger.js +9 -10
- package/lib-es/network/node/ledger.js.map +1 -1
- package/lib-es/network/node/rpc.common.d.ts +3 -2
- package/lib-es/network/node/rpc.common.d.ts.map +1 -1
- package/lib-es/network/node/rpc.common.js +53 -32
- package/lib-es/network/node/rpc.common.js.map +1 -1
- package/lib-es/network/node/rpc.errors.d.ts +1 -3
- package/lib-es/network/node/rpc.errors.d.ts.map +1 -1
- package/lib-es/network/node/rpc.errors.js +20 -2
- package/lib-es/network/node/rpc.errors.js.map +1 -1
- package/lib-es/staking/contracts.js +2 -2
- package/lib-es/staking/contracts.js.map +1 -1
- package/lib-es/staking/fetchers.d.ts.map +1 -1
- package/lib-es/staking/fetchers.js +7 -7
- package/lib-es/staking/fetchers.js.map +1 -1
- package/lib-es/staking/prepareIntents.d.ts +2 -1
- package/lib-es/staking/prepareIntents.d.ts.map +1 -1
- package/lib-es/staking/prepareIntents.js +4 -4
- package/lib-es/staking/prepareIntents.js.map +1 -1
- package/lib-es/staking/redelegations.d.ts +5 -4
- package/lib-es/staking/redelegations.d.ts.map +1 -1
- package/lib-es/staking/redelegations.js +13 -14
- package/lib-es/staking/redelegations.js.map +1 -1
- package/lib-es/staking/rewards.d.ts +2 -1
- package/lib-es/staking/rewards.d.ts.map +1 -1
- package/lib-es/staking/rewards.js +4 -5
- package/lib-es/staking/rewards.js.map +1 -1
- package/lib-es/staking/rewardsFromReceipt.d.ts +2 -1
- package/lib-es/staking/rewardsFromReceipt.d.ts.map +1 -1
- package/lib-es/staking/rewardsFromReceipt.js +2 -3
- package/lib-es/staking/rewardsFromReceipt.js.map +1 -1
- package/lib-es/staking/unbondings.d.ts +2 -1
- package/lib-es/staking/unbondings.d.ts.map +1 -1
- package/lib-es/staking/unbondings.js +4 -5
- package/lib-es/staking/unbondings.js.map +1 -1
- package/lib-es/staking/validators/index.d.ts +9 -4
- package/lib-es/staking/validators/index.d.ts.map +1 -1
- package/lib-es/staking/validators/index.js +18 -10
- package/lib-es/staking/validators/index.js.map +1 -1
- package/lib-es/staking/validators/monad.d.ts +6 -5
- package/lib-es/staking/validators/monad.d.ts.map +1 -1
- package/lib-es/staking/validators/monad.js +33 -29
- package/lib-es/staking/validators/monad.js.map +1 -1
- package/lib-es/staking/validators/monadResolver.d.ts +2 -1
- package/lib-es/staking/validators/monadResolver.d.ts.map +1 -1
- package/lib-es/staking/validators/monadResolver.js +2 -3
- package/lib-es/staking/validators/monadResolver.js.map +1 -1
- package/lib-es/staking/validators/somnia.d.ts +3 -2
- package/lib-es/staking/validators/somnia.d.ts.map +1 -1
- package/lib-es/staking/validators/somnia.js +16 -15
- package/lib-es/staking/validators/somnia.js.map +1 -1
- package/lib-es/staking/validators/types.d.ts +2 -1
- package/lib-es/staking/validators/types.d.ts.map +1 -1
- package/lib-es/staking/validators/zero_gravity.d.ts +2 -1
- package/lib-es/staking/validators/zero_gravity.d.ts.map +1 -1
- package/lib-es/staking/validators/zero_gravity.js +7 -8
- package/lib-es/staking/validators/zero_gravity.js.map +1 -1
- package/lib-es/types/staking.d.ts +4 -3
- package/lib-es/types/staking.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/adapters/blockOperations.test.ts +86 -67
- package/src/adapters/blockOperations.ts +28 -17
- package/src/adapters/etherscan.test.ts +151 -85
- package/src/adapters/etherscan.ts +27 -18
- package/src/adapters/ledger.test.ts +210 -83
- package/src/adapters/ledger.ts +21 -15
- package/src/api/index.integ.test.ts +7 -6
- package/src/api/index.test.ts +2 -2
- package/src/api/index.ts +1 -2
- package/src/logic/common.ts +1 -1
- package/src/logic/getBalance.ts +4 -3
- package/src/logic/getBlock.ts +43 -27
- package/src/logic/getStakes.ts +2 -1
- package/src/logic/internalTransactionsFetcher.ts +16 -10
- package/src/logic/listOperations.ts +2 -2
- package/src/logic/tests/getBalance.test.ts +5 -3
- package/src/logic/tests/getBlock.test.ts +16 -15
- package/src/logic/tests/internalTransactionsFetcher.test.ts +6 -5
- package/src/logic/tests/listOperations.test.ts +4 -4
- package/src/logic-public/tests/utils.test.ts +6 -5
- package/src/logic-public/utils.ts +8 -5
- package/src/logic.test.ts +5 -5
- package/src/network/explorer/etherscan.test.ts +169 -55
- package/src/network/explorer/etherscan.ts +27 -16
- package/src/network/explorer/index.test.ts +2 -1
- package/src/network/explorer/ledger.test.ts +207 -35
- package/src/network/explorer/ledger.ts +12 -8
- package/src/network/explorer/types.ts +3 -2
- package/src/network/node/explorerProxy.ts +3 -3
- package/src/network/node/index.ts +3 -2
- package/src/network/node/ledger.test.ts +25 -25
- package/src/network/node/ledger.ts +13 -10
- package/src/network/node/rpc.common.ts +107 -30
- package/src/network/node/rpc.errors.test.ts +53 -1
- package/src/network/node/rpc.errors.ts +25 -2
- package/src/network/node/rpc.test.ts +106 -47
- package/src/staking/contracts.ts +2 -2
- package/src/staking/fetchers.ts +20 -8
- package/src/staking/prepareIntents.test.ts +33 -12
- package/src/staking/prepareIntents.ts +9 -5
- package/src/staking/redelegations.test.ts +96 -35
- package/src/staking/redelegations.ts +20 -12
- package/src/staking/rewards.test.ts +15 -10
- package/src/staking/rewards.ts +8 -5
- package/src/staking/rewardsFromReceipt.test.ts +5 -4
- package/src/staking/rewardsFromReceipt.ts +4 -3
- package/src/staking/unbondings.test.ts +15 -12
- package/src/staking/unbondings.ts +7 -5
- package/src/staking/validators/index.ts +30 -10
- package/src/staking/validators/monad.test.ts +57 -43
- package/src/staking/validators/monad.ts +55 -32
- package/src/staking/validators/monadResolver.ts +4 -3
- package/src/staking/validators/somnia.test.ts +14 -13
- package/src/staking/validators/somnia.ts +35 -19
- package/src/staking/validators/types.ts +2 -0
- package/src/staking/validators/zero_gravity.test.ts +48 -26
- package/src/staking/validators/zero_gravity.ts +14 -8
- package/src/staking/validators.integ.test.ts +2 -2
- package/src/staking/validators.test.ts +30 -26
- package/src/types/staking.ts +9 -2
|
@@ -19,7 +19,6 @@ import type { Logger } from '@ledgerhq/coin-module-framework/config'
|
|
|
19
19
|
import type { AxiosRequestConfig } from 'axios'
|
|
20
20
|
import { delay } from '@ledgerhq/coin-module-framework/promises'
|
|
21
21
|
import { makeLRUCache } from '@ledgerhq/live-network/cache'
|
|
22
|
-
import { log } from '@ledgerhq/logs'
|
|
23
22
|
import axios from 'axios'
|
|
24
23
|
import {
|
|
25
24
|
etherscanOperationToOperations,
|
|
@@ -74,6 +73,8 @@ function getMaxBoundaryExhaustionPages(config: EvmConfigInfo): number {
|
|
|
74
73
|
export type FetchOperationsParams = {
|
|
75
74
|
currencyId: string
|
|
76
75
|
config: EvmConfigInfo
|
|
76
|
+
// Instance-scoped logger threaded from the caller's context (set by `getOperations`).
|
|
77
|
+
logger: Logger
|
|
77
78
|
address: string
|
|
78
79
|
// Inclusive lower bound of the block range. fromBlock <= toBlock whatever the sort order is.
|
|
79
80
|
fromBlock: number
|
|
@@ -307,7 +308,7 @@ export const getCoinOperations = async (params: FetchOperationsParams): Promise<
|
|
|
307
308
|
const ops = Array.isArray(raw) ? raw : []
|
|
308
309
|
|
|
309
310
|
const operations = ops.flatMap((tx) =>
|
|
310
|
-
etherscanOperationToOperations(params.address, params.currencyId, tx)
|
|
311
|
+
etherscanOperationToOperations(params.address, params.currencyId, tx, params.logger)
|
|
311
312
|
)
|
|
312
313
|
|
|
313
314
|
// Recover REWARD op amounts (claim/compound) from receipt logs — these txs send 0 native
|
|
@@ -322,8 +323,11 @@ export const getCoinOperations = async (params: FetchOperationsParams): Promise<
|
|
|
322
323
|
params.config,
|
|
323
324
|
params.currencyId,
|
|
324
325
|
(api) =>
|
|
325
|
-
enrichRewardOperationsValue(
|
|
326
|
-
|
|
326
|
+
enrichRewardOperationsValue(
|
|
327
|
+
params.currencyId,
|
|
328
|
+
operations,
|
|
329
|
+
(hash) => api.getTransactionReceipt(hash),
|
|
330
|
+
params.logger
|
|
327
331
|
),
|
|
328
332
|
node
|
|
329
333
|
)
|
|
@@ -331,7 +335,7 @@ export const getCoinOperations = async (params: FetchOperationsParams): Promise<
|
|
|
331
335
|
// Enrichment is best-effort, but a rate limit must not be downgraded into a successful
|
|
332
336
|
// response reporting 0-value rewards.
|
|
333
337
|
if (e instanceof RateLimitError) throw e
|
|
334
|
-
|
|
338
|
+
params.logger('EVM getOperations', 'reward amount enrichment failed', e)
|
|
335
339
|
}
|
|
336
340
|
}
|
|
337
341
|
|
|
@@ -387,7 +391,9 @@ export const getTokenOperations = async (
|
|
|
387
391
|
const opsByHash = groupByHash(filteredOps)
|
|
388
392
|
|
|
389
393
|
const operations = Object.values(opsByHash).flatMap((events) =>
|
|
390
|
-
events.flatMap((event, index) =>
|
|
394
|
+
events.flatMap((event, index) =>
|
|
395
|
+
etherscanERC20EventToOperations(params.address, event, index, params.logger)
|
|
396
|
+
)
|
|
391
397
|
)
|
|
392
398
|
const maxBlock = boundBlockFromOperations(operations)
|
|
393
399
|
|
|
@@ -434,7 +440,9 @@ export const getERC721Operations = async (
|
|
|
434
440
|
const opsByHash = groupByHash(ops)
|
|
435
441
|
|
|
436
442
|
const operations = Object.values(opsByHash).flatMap((events) =>
|
|
437
|
-
events.flatMap((event, index) =>
|
|
443
|
+
events.flatMap((event, index) =>
|
|
444
|
+
etherscanERC721EventToOperations(params.address, event, index, params.logger)
|
|
445
|
+
)
|
|
438
446
|
)
|
|
439
447
|
const maxBlock = boundBlockFromOperations(operations)
|
|
440
448
|
|
|
@@ -486,7 +494,7 @@ export const getERC1155Operations = async (
|
|
|
486
494
|
|
|
487
495
|
const operations = Object.values(opsByHash).flatMap((events) =>
|
|
488
496
|
events.flatMap((event, index) =>
|
|
489
|
-
etherscanERC1155EventToOperations(params.address, event, index)
|
|
497
|
+
etherscanERC1155EventToOperations(params.address, event, index, params.logger)
|
|
490
498
|
)
|
|
491
499
|
)
|
|
492
500
|
const maxBlock = boundBlockFromOperations(operations)
|
|
@@ -574,7 +582,7 @@ export const getInternalOperations = async (
|
|
|
574
582
|
|
|
575
583
|
const operations = Object.values(opsByHash).flatMap((internalTxs) =>
|
|
576
584
|
internalTxs.flatMap((internalTx, index) =>
|
|
577
|
-
etherscanInternalTransactionToOperations(params.address, internalTx, index)
|
|
585
|
+
etherscanInternalTransactionToOperations(params.address, internalTx, index, params.logger)
|
|
578
586
|
)
|
|
579
587
|
)
|
|
580
588
|
const maxBlock = boundBlockFromOperations(operations)
|
|
@@ -774,6 +782,7 @@ export async function exhaustEndpoint(
|
|
|
774
782
|
export const getOperations = makeLRUCache<
|
|
775
783
|
[
|
|
776
784
|
config: EvmConfigInfo,
|
|
785
|
+
logger: Logger,
|
|
777
786
|
currencyId: string,
|
|
778
787
|
address: string,
|
|
779
788
|
fromBlock: number,
|
|
@@ -781,7 +790,6 @@ export const getOperations = makeLRUCache<
|
|
|
781
790
|
pagingToken: string | undefined,
|
|
782
791
|
limit: number | undefined,
|
|
783
792
|
order: 'asc' | 'desc' | undefined,
|
|
784
|
-
logger: Logger,
|
|
785
793
|
],
|
|
786
794
|
{
|
|
787
795
|
lastCoinOperations: Array<Operation<MemoNotSupported>>
|
|
@@ -793,14 +801,14 @@ export const getOperations = makeLRUCache<
|
|
|
793
801
|
>(
|
|
794
802
|
async (
|
|
795
803
|
config,
|
|
804
|
+
logger,
|
|
796
805
|
currencyId,
|
|
797
806
|
address,
|
|
798
807
|
fromBlock,
|
|
799
808
|
toBlock,
|
|
800
809
|
pagingToken,
|
|
801
810
|
limit,
|
|
802
|
-
order = 'desc'
|
|
803
|
-
logger
|
|
811
|
+
order = 'desc'
|
|
804
812
|
) => {
|
|
805
813
|
try {
|
|
806
814
|
const configuredMaxLimit = getConfiguredMaxLimit(config)
|
|
@@ -822,6 +830,7 @@ export const getOperations = makeLRUCache<
|
|
|
822
830
|
...(toBlock !== undefined && { toBlock }),
|
|
823
831
|
...(effectiveLimit !== undefined && { limit: effectiveLimit }),
|
|
824
832
|
sort: order,
|
|
833
|
+
logger,
|
|
825
834
|
}
|
|
826
835
|
|
|
827
836
|
async function callEndpoint(
|
|
@@ -958,7 +967,7 @@ export const getOperations = makeLRUCache<
|
|
|
958
967
|
)
|
|
959
968
|
}
|
|
960
969
|
},
|
|
961
|
-
(_config, currencyId, address, fromBlock, toBlock, pagingToken, limit, order) =>
|
|
970
|
+
(_config, _logger, currencyId, address, fromBlock, toBlock, pagingToken, limit, order) =>
|
|
962
971
|
`${currencyId}:${address}:${fromBlock}:${toBlock ?? ''}:${pagingToken ?? ''}:${limit ?? ''}:${order ?? 'desc'}`,
|
|
963
972
|
{ ttl: ETHERSCAN_TIMEOUT }
|
|
964
973
|
)
|
|
@@ -974,16 +983,17 @@ export const getOperations = makeLRUCache<
|
|
|
974
983
|
* and NFT endpoints, which this arm never needed to discover tokens.
|
|
975
984
|
*/
|
|
976
985
|
export const discoverTokenAssets = makeLRUCache<
|
|
977
|
-
[config: EvmConfigInfo, currencyId: string, address: string, fromBlock?: number],
|
|
986
|
+
[config: EvmConfigInfo, logger: Logger, currencyId: string, address: string, fromBlock?: number],
|
|
978
987
|
AssetInfo[]
|
|
979
988
|
>(
|
|
980
|
-
async (config, currencyId, address, fromBlock = 0) => {
|
|
989
|
+
async (config, logger, currencyId, address, fromBlock = 0) => {
|
|
981
990
|
const { operations } = await getTokenOperations({
|
|
982
991
|
currencyId,
|
|
983
992
|
config,
|
|
984
993
|
address,
|
|
985
994
|
fromBlock,
|
|
986
995
|
sort: 'desc',
|
|
996
|
+
logger,
|
|
987
997
|
})
|
|
988
998
|
|
|
989
999
|
const assets = new Map<string, AssetInfo>()
|
|
@@ -994,7 +1004,8 @@ export const discoverTokenAssets = makeLRUCache<
|
|
|
994
1004
|
|
|
995
1005
|
return Array.from(assets.values())
|
|
996
1006
|
},
|
|
997
|
-
(_config, currencyId, address, fromBlock) =>
|
|
1007
|
+
(_config, _logger, currencyId, address, fromBlock) =>
|
|
1008
|
+
`${currencyId}:${address}:${fromBlock ?? 0}`,
|
|
998
1009
|
{ ttl: ETHERSCAN_TIMEOUT }
|
|
999
1010
|
)
|
|
1000
1011
|
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
mkEtherscanExplorer,
|
|
10
10
|
mkExternalNode,
|
|
11
11
|
mkLedgerExplorer,
|
|
12
|
+
testLogger,
|
|
12
13
|
} from '../../fixtures/context.fixtures'
|
|
13
14
|
import etherscanLikeApi from './etherscan'
|
|
14
15
|
import ledgerExplorerApi from './ledger'
|
|
@@ -125,7 +126,7 @@ describe('EVM Family', () => {
|
|
|
125
126
|
const explorer = getExplorerApi(configFor('none-coin'), 'none-coin')
|
|
126
127
|
|
|
127
128
|
await expect(
|
|
128
|
-
explorer.discoverTokenAssets(configFor('none-coin'), 'none-coin', '0xaddress')
|
|
129
|
+
explorer.discoverTokenAssets(configFor('none-coin'), testLogger, 'none-coin', '0xaddress')
|
|
129
130
|
).resolves.toEqual([])
|
|
130
131
|
})
|
|
131
132
|
})
|