@ledgerhq/coin-evm 7.0.0 → 9.0.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.
- package/.oxlintrc.json +1 -1
- package/CHANGELOG.md +62 -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/config.d.ts +0 -1
- package/lib/config.d.ts.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 +37 -29
- package/lib/network/node/rpc.common.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/config.d.ts +0 -1
- package/lib-es/config.d.ts.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 +37 -29
- package/lib-es/network/node/rpc.common.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/getBlock.integ.test.ts +10 -4
- package/src/api/index.arbitrum.integ.test.ts +1 -0
- package/src/api/index.arc.integ.test.ts +1 -0
- package/src/api/index.avalanche_c_chain_fuji.integ.test.ts +1 -0
- package/src/api/index.cronos.integ.test.ts +1 -0
- package/src/api/index.flare.integ.test.ts +4 -2
- package/src/api/index.integ.test.ts +7 -6
- package/src/api/index.linea.integ.test.ts +4 -2
- package/src/api/index.optimism.integ.test.ts +1 -0
- package/src/api/index.rsk.integ.test.ts +1 -0
- package/src/api/index.shape.integ.test.ts +4 -2
- package/src/api/index.somnia.integ.test.ts +1 -0
- package/src/api/index.test.ts +2 -2
- package/src/api/index.ts +1 -2
- package/src/config.ts +0 -1
- package/src/fixtures/context.fixtures.ts +5 -5
- 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 +208 -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/node.fixtures.ts +2 -1
- package/src/network/node/rpc.common.ts +84 -28
- package/src/network/node/rpc.test.ts +45 -31
- 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 +98 -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 +16 -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 +31 -26
- package/src/types/staking.ts +9 -2
|
@@ -13,10 +13,10 @@ import type {
|
|
|
13
13
|
StakeState,
|
|
14
14
|
Validator,
|
|
15
15
|
} from '@ledgerhq/coin-module-framework/api/types'
|
|
16
|
+
import type { Logger } from '@ledgerhq/coin-module-framework/config'
|
|
16
17
|
import type { JsonRpcProvider } from 'ethers'
|
|
17
18
|
import network from '@ledgerhq/live-network'
|
|
18
19
|
import { makeLRUCache } from '@ledgerhq/live-network/cache'
|
|
19
|
-
import { log } from '@ledgerhq/logs'
|
|
20
20
|
import { ethers } from 'ethers'
|
|
21
21
|
import { evmUnit } from '../../logic/evmUnit'
|
|
22
22
|
import { withApi } from '../../network/node/rpc.common'
|
|
@@ -55,7 +55,11 @@ type ValidatorInfo = { name: string }
|
|
|
55
55
|
* The resolved promise is cached, so a miss is not re-requested; only transient/non-404
|
|
56
56
|
* errors are rethrown so the cache evicts and a later call retries.
|
|
57
57
|
*/
|
|
58
|
-
const fetchValidatorName = async (
|
|
58
|
+
const fetchValidatorName = async (
|
|
59
|
+
currencyId: string,
|
|
60
|
+
secp: string,
|
|
61
|
+
logger: Logger
|
|
62
|
+
): Promise<string | null> => {
|
|
59
63
|
const baseUrl = STAKING_CONTRACTS[currencyId]?.validatorNameSource?.baseUrl
|
|
60
64
|
if (!baseUrl) return null
|
|
61
65
|
|
|
@@ -69,7 +73,7 @@ const fetchValidatorName = async (currencyId: string, secp: string): Promise<str
|
|
|
69
73
|
// A 404 just means this validator hasn't published info — cache the miss.
|
|
70
74
|
if (status === 404) return null
|
|
71
75
|
// Anything else is transient: log and rethrow so the cache doesn't pin a miss.
|
|
72
|
-
|
|
76
|
+
logger('coin-evm/staking', 'fetchValidatorName: validator-info lookup failed', {
|
|
73
77
|
currencyId,
|
|
74
78
|
secp,
|
|
75
79
|
error: error instanceof Error ? error.message : String(error),
|
|
@@ -81,7 +85,8 @@ const fetchValidatorName = async (currencyId: string, secp: string): Promise<str
|
|
|
81
85
|
// Concurrent calls for the same (currencyId, secp) share one in-flight request.
|
|
82
86
|
const validatorNameCache = makeLRUCache(
|
|
83
87
|
fetchValidatorName,
|
|
84
|
-
|
|
88
|
+
// logger is a side-channel arg, excluded from the cache key.
|
|
89
|
+
(currencyId: string, secp: string, _logger: Logger) => `${currencyId}-${secp}`,
|
|
85
90
|
{ max: 1000, ttl: NAME_CACHE_MAX_AGE_MS }
|
|
86
91
|
)
|
|
87
92
|
|
|
@@ -154,7 +159,8 @@ const fetchValidatorDetails = async (
|
|
|
154
159
|
provider: JsonRpcProvider,
|
|
155
160
|
iface: ethers.Interface,
|
|
156
161
|
contractAddress: string,
|
|
157
|
-
valIds: bigint[]
|
|
162
|
+
valIds: bigint[],
|
|
163
|
+
logger: Logger
|
|
158
164
|
): Promise<Validator[]> => {
|
|
159
165
|
const items: Validator[] = []
|
|
160
166
|
|
|
@@ -168,7 +174,9 @@ const fetchValidatorDetails = async (
|
|
|
168
174
|
const [, , stake, , commission, , , , , , secpPubkey] = decoded
|
|
169
175
|
const secp = secpPubkey.toLowerCase().replace(/^0x/, '')
|
|
170
176
|
const name =
|
|
171
|
-
secp.length > 0
|
|
177
|
+
secp.length > 0
|
|
178
|
+
? await validatorNameCache(currencyId, secp, logger).catch(() => null)
|
|
179
|
+
: null
|
|
172
180
|
|
|
173
181
|
return {
|
|
174
182
|
id: valId.toString(),
|
|
@@ -183,7 +191,7 @@ const fetchValidatorDetails = async (
|
|
|
183
191
|
|
|
184
192
|
settled.forEach((res, idx) => {
|
|
185
193
|
if (res.status === 'rejected') {
|
|
186
|
-
|
|
194
|
+
logger('coin-evm/staking', 'fetchValidatorDetails: getValidator call failed', {
|
|
187
195
|
valId: chunk[idx].toString(),
|
|
188
196
|
error: res.reason instanceof Error ? res.reason.message : String(res.reason),
|
|
189
197
|
})
|
|
@@ -204,7 +212,8 @@ const fetchPage = async (
|
|
|
204
212
|
provider: JsonRpcProvider,
|
|
205
213
|
iface: ethers.Interface,
|
|
206
214
|
contractAddress: string,
|
|
207
|
-
startIndex: bigint
|
|
215
|
+
startIndex: bigint,
|
|
216
|
+
logger: Logger
|
|
208
217
|
): Promise<Page<Validator>> => {
|
|
209
218
|
const data = iface.encodeFunctionData('getExecutionValidatorSet', [startIndex])
|
|
210
219
|
const raw = await provider.call({ to: contractAddress, data })
|
|
@@ -216,7 +225,7 @@ const fetchPage = async (
|
|
|
216
225
|
const items =
|
|
217
226
|
pageIds.length === 0
|
|
218
227
|
? []
|
|
219
|
-
: await fetchValidatorDetails(currencyId, provider, iface, contractAddress, pageIds)
|
|
228
|
+
: await fetchValidatorDetails(currencyId, provider, iface, contractAddress, pageIds, logger)
|
|
220
229
|
|
|
221
230
|
const exhausted = isDone || pageIds.length === 0 || nextIndex <= startIndex
|
|
222
231
|
return { items, next: exhausted ? undefined : nextIndex.toString() }
|
|
@@ -225,6 +234,7 @@ const fetchPage = async (
|
|
|
225
234
|
const fetchValidators = async (
|
|
226
235
|
evmConfig: EvmConfigInfo,
|
|
227
236
|
currencyId: string,
|
|
237
|
+
logger: Logger,
|
|
228
238
|
cursor?: Cursor
|
|
229
239
|
): Promise<Page<Validator>> => {
|
|
230
240
|
const ctx = resolveContext(evmConfig, currencyId)
|
|
@@ -238,12 +248,12 @@ const fetchValidators = async (
|
|
|
238
248
|
currencyId,
|
|
239
249
|
async (provider) => {
|
|
240
250
|
const iface = new ethers.Interface(ctx.abi)
|
|
241
|
-
return fetchPage(currencyId, provider, iface, ctx.contractAddress, startIndex)
|
|
251
|
+
return fetchPage(currencyId, provider, iface, ctx.contractAddress, startIndex, logger)
|
|
242
252
|
},
|
|
243
253
|
ctx.node
|
|
244
254
|
)
|
|
245
255
|
} catch (error) {
|
|
246
|
-
|
|
256
|
+
logger('coin-evm/staking', 'fetchValidators: Monad validators page fetch failed', {
|
|
247
257
|
error: error instanceof Error ? error.message : String(error),
|
|
248
258
|
currencyId,
|
|
249
259
|
cursor,
|
|
@@ -287,7 +297,8 @@ const fetchStakeForValId = async (
|
|
|
287
297
|
contractAddress: string,
|
|
288
298
|
delegator: string,
|
|
289
299
|
valId: bigint,
|
|
290
|
-
currentEpoch: bigint | null
|
|
300
|
+
currentEpoch: bigint | null,
|
|
301
|
+
logger: Logger
|
|
291
302
|
): Promise<Stake[]> => {
|
|
292
303
|
const data = iface.encodeFunctionData('getDelegator', [valId, delegator])
|
|
293
304
|
const raw = await provider.call({ to: contractAddress, data })
|
|
@@ -302,7 +313,8 @@ const fetchStakeForValId = async (
|
|
|
302
313
|
iface,
|
|
303
314
|
contractAddress,
|
|
304
315
|
valId,
|
|
305
|
-
delegator
|
|
316
|
+
delegator,
|
|
317
|
+
logger
|
|
306
318
|
)
|
|
307
319
|
|
|
308
320
|
if (
|
|
@@ -323,7 +335,8 @@ const fetchStakeForValId = async (
|
|
|
323
335
|
validatorAddress = ethers.computeAddress(secpPubkey)
|
|
324
336
|
const secp = secpPubkey.toLowerCase().replace(/^0x/, '')
|
|
325
337
|
if (secp.length > 0) {
|
|
326
|
-
validatorName =
|
|
338
|
+
validatorName =
|
|
339
|
+
(await validatorNameCache(currencyId, secp, logger).catch(() => null)) ?? undefined
|
|
327
340
|
}
|
|
328
341
|
}
|
|
329
342
|
|
|
@@ -378,7 +391,8 @@ const fetchStakeForValId = async (
|
|
|
378
391
|
|
|
379
392
|
export const extractMonadKnownValIds = (
|
|
380
393
|
currencyId: string,
|
|
381
|
-
ops: Array<Operation<MemoNotSupported
|
|
394
|
+
ops: Array<Operation<MemoNotSupported>>,
|
|
395
|
+
logger: Logger
|
|
382
396
|
): string[] => {
|
|
383
397
|
const fnNames: Record<string, string> = {
|
|
384
398
|
DELEGATE: 'delegate',
|
|
@@ -401,7 +415,7 @@ export const extractMonadKnownValIds = (
|
|
|
401
415
|
const d = iface.decodeFunctionData(fnName, payload)
|
|
402
416
|
if (typeof d[0] === 'bigint') valIds.add(d[0].toString())
|
|
403
417
|
} catch (err) {
|
|
404
|
-
|
|
418
|
+
logger('coin-evm/staking', 'extractMonadKnownValIds: failed to decode payload', {
|
|
405
419
|
type: op.type,
|
|
406
420
|
error: err instanceof Error ? err.message : String(err),
|
|
407
421
|
})
|
|
@@ -416,6 +430,7 @@ export const fetchMonadStakes = async (
|
|
|
416
430
|
address: string,
|
|
417
431
|
_config: StakingContractConfig,
|
|
418
432
|
currencyId: string,
|
|
433
|
+
logger: Logger,
|
|
419
434
|
knownValIds?: string[]
|
|
420
435
|
): Promise<Stake[]> => {
|
|
421
436
|
const ctx = resolveContext(evmConfig, currencyId)
|
|
@@ -440,7 +455,7 @@ export const fetchMonadStakes = async (
|
|
|
440
455
|
const valIds = [...valIdSet]
|
|
441
456
|
if (valIds.length === 0) return []
|
|
442
457
|
|
|
443
|
-
const currentEpoch = await callGetEpoch(provider, iface, ctx.contractAddress)
|
|
458
|
+
const currentEpoch = await callGetEpoch(provider, iface, ctx.contractAddress, logger)
|
|
444
459
|
|
|
445
460
|
const stakes: Stake[] = []
|
|
446
461
|
for (let i = 0; i < valIds.length; i += DETAILS_BATCH_SIZE) {
|
|
@@ -455,14 +470,15 @@ export const fetchMonadStakes = async (
|
|
|
455
470
|
ctx.contractAddress,
|
|
456
471
|
address,
|
|
457
472
|
valId,
|
|
458
|
-
currentEpoch
|
|
473
|
+
currentEpoch,
|
|
474
|
+
logger
|
|
459
475
|
)
|
|
460
476
|
)
|
|
461
477
|
)
|
|
462
478
|
|
|
463
479
|
settled.forEach((res, idx) => {
|
|
464
480
|
if (res.status === 'rejected') {
|
|
465
|
-
|
|
481
|
+
logger('coin-evm/staking', 'fetchMonadStakes: getDelegator call failed', {
|
|
466
482
|
valId: chunk[idx].toString(),
|
|
467
483
|
error: res.reason instanceof Error ? res.reason.message : String(res.reason),
|
|
468
484
|
})
|
|
@@ -477,7 +493,7 @@ export const fetchMonadStakes = async (
|
|
|
477
493
|
ctx.node
|
|
478
494
|
)
|
|
479
495
|
} catch (error) {
|
|
480
|
-
|
|
496
|
+
logger('coin-evm/staking', 'fetchMonadStakes: delegations fetch failed', {
|
|
481
497
|
currencyId,
|
|
482
498
|
error: error instanceof Error ? error.message : String(error),
|
|
483
499
|
})
|
|
@@ -528,7 +544,8 @@ const fetchWithdrawalRequests = async (
|
|
|
528
544
|
iface: ethers.Interface,
|
|
529
545
|
contractAddress: string,
|
|
530
546
|
valId: bigint,
|
|
531
|
-
delegator: string
|
|
547
|
+
delegator: string,
|
|
548
|
+
logger: Logger
|
|
532
549
|
): Promise<OccupiedWithdrawal[]> => {
|
|
533
550
|
const occupied: OccupiedWithdrawal[] = []
|
|
534
551
|
|
|
@@ -545,7 +562,7 @@ const fetchWithdrawalRequests = async (
|
|
|
545
562
|
settled.forEach((res, i) => {
|
|
546
563
|
const withdrawId = ids[i]
|
|
547
564
|
if (res.status === 'rejected') {
|
|
548
|
-
|
|
565
|
+
logger('coin-evm/staking', 'fetchWithdrawalRequests: getWithdrawalRequest call failed', {
|
|
549
566
|
valId: valId.toString(),
|
|
550
567
|
withdrawId,
|
|
551
568
|
error: res.reason instanceof Error ? res.reason.message : String(res.reason),
|
|
@@ -566,7 +583,8 @@ export const findFirstFreeWithdrawId = async (
|
|
|
566
583
|
evmConfig: EvmConfigInfo,
|
|
567
584
|
currencyId: string,
|
|
568
585
|
valId: bigint,
|
|
569
|
-
delegator: string
|
|
586
|
+
delegator: string,
|
|
587
|
+
logger: Logger
|
|
570
588
|
): Promise<number | null> => {
|
|
571
589
|
const ctx = resolveContext(evmConfig, currencyId)
|
|
572
590
|
if (!ctx) return null
|
|
@@ -598,12 +616,16 @@ export const findFirstFreeWithdrawId = async (
|
|
|
598
616
|
for (let i = 0; i < settled.length; i++) {
|
|
599
617
|
const res = settled[i]
|
|
600
618
|
if (res.status === 'rejected') {
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
619
|
+
logger(
|
|
620
|
+
'coin-evm/staking',
|
|
621
|
+
'findFirstFreeWithdrawId: getWithdrawalRequest call failed',
|
|
622
|
+
{
|
|
623
|
+
currencyId,
|
|
624
|
+
valId: valId.toString(),
|
|
625
|
+
withdrawId: ids[i],
|
|
626
|
+
error: res.reason instanceof Error ? res.reason.message : String(res.reason),
|
|
627
|
+
}
|
|
628
|
+
)
|
|
607
629
|
continue
|
|
608
630
|
}
|
|
609
631
|
if (res.value && !isWithdrawIdInUse(res.value)) return ids[i]
|
|
@@ -615,7 +637,7 @@ export const findFirstFreeWithdrawId = async (
|
|
|
615
637
|
ctx.node
|
|
616
638
|
)
|
|
617
639
|
} catch (error) {
|
|
618
|
-
|
|
640
|
+
logger('coin-evm/staking', 'findFirstFreeWithdrawId: lookup failed', {
|
|
619
641
|
currencyId,
|
|
620
642
|
valId: valId.toString(),
|
|
621
643
|
error: error instanceof Error ? error.message : String(error),
|
|
@@ -641,7 +663,8 @@ const callGetWithdrawalRequest = async (
|
|
|
641
663
|
export const callGetEpoch = async (
|
|
642
664
|
provider: JsonRpcProvider,
|
|
643
665
|
iface: ethers.Interface,
|
|
644
|
-
contractAddress: string
|
|
666
|
+
contractAddress: string,
|
|
667
|
+
logger: Logger
|
|
645
668
|
): Promise<bigint | null> => {
|
|
646
669
|
try {
|
|
647
670
|
const data = iface.encodeFunctionData('getEpoch', [])
|
|
@@ -649,7 +672,7 @@ export const callGetEpoch = async (
|
|
|
649
672
|
const decoded = iface.decodeFunctionResult('getEpoch', raw)
|
|
650
673
|
return Array.isArray(decoded) && typeof decoded[0] === 'bigint' ? decoded[0] : null
|
|
651
674
|
} catch (error) {
|
|
652
|
-
|
|
675
|
+
logger('coin-evm/staking', 'callGetEpoch: getEpoch call failed', {
|
|
653
676
|
error: error instanceof Error ? error.message : String(error),
|
|
654
677
|
})
|
|
655
678
|
return null
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import type { EvmConfigInfo } from '../../config'
|
|
5
|
+
import type { Logger } from '@ledgerhq/coin-module-framework/config'
|
|
5
6
|
import type { JsonRpcProvider } from 'ethers'
|
|
6
|
-
import { log } from '@ledgerhq/logs'
|
|
7
7
|
import { ethers } from 'ethers'
|
|
8
8
|
import { withApi } from '../../network/node/rpc.common'
|
|
9
9
|
import { isExternalNodeConfig } from '../../network/node/types'
|
|
@@ -54,7 +54,8 @@ export const callGetValidator = async (
|
|
|
54
54
|
export const getValidatorAddressById = async (
|
|
55
55
|
config: EvmConfigInfo,
|
|
56
56
|
currencyId: string,
|
|
57
|
-
valId: bigint
|
|
57
|
+
valId: bigint,
|
|
58
|
+
logger: Logger
|
|
58
59
|
): Promise<string | null> => {
|
|
59
60
|
const abi = getStakingABI(currencyId)
|
|
60
61
|
if (!abi) return null
|
|
@@ -76,7 +77,7 @@ export const getValidatorAddressById = async (
|
|
|
76
77
|
node
|
|
77
78
|
)
|
|
78
79
|
} catch (error) {
|
|
79
|
-
|
|
80
|
+
logger('coin-evm/staking', 'getValidatorAddressById: getValidator call failed', {
|
|
80
81
|
currencyId,
|
|
81
82
|
valId: valId.toString(),
|
|
82
83
|
error: error instanceof Error ? error.message : String(error),
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
createMockEvmConfigInfo,
|
|
12
12
|
mkExternalNode,
|
|
13
13
|
mkLedgerNode,
|
|
14
|
+
testLogger,
|
|
14
15
|
} from '../../fixtures/context.fixtures'
|
|
15
16
|
import { withApi } from '../../network/node/rpc.common'
|
|
16
17
|
import { STAKING_CONTRACTS } from '../contracts'
|
|
@@ -137,7 +138,7 @@ describe('staking/validators/somnia', () => {
|
|
|
137
138
|
})
|
|
138
139
|
)
|
|
139
140
|
|
|
140
|
-
const page = await getValidators(mockConfig, 'somnia')
|
|
141
|
+
const page = await getValidators(mockConfig, 'somnia', testLogger)
|
|
141
142
|
|
|
142
143
|
expect(page.next).toBeUndefined()
|
|
143
144
|
expect(page.items).toHaveLength(2)
|
|
@@ -170,7 +171,7 @@ describe('staking/validators/somnia', () => {
|
|
|
170
171
|
})
|
|
171
172
|
)
|
|
172
173
|
|
|
173
|
-
const page = await getValidators(mockConfig, 'somnia')
|
|
174
|
+
const page = await getValidators(mockConfig, 'somnia', testLogger)
|
|
174
175
|
|
|
175
176
|
expect(page.items).toHaveLength(1)
|
|
176
177
|
expect(page.items[0].address).toBe(VALIDATOR_B)
|
|
@@ -183,14 +184,14 @@ describe('staking/validators/somnia', () => {
|
|
|
183
184
|
})
|
|
184
185
|
)
|
|
185
186
|
|
|
186
|
-
const page = await getValidators(mockConfig, 'somnia')
|
|
187
|
+
const page = await getValidators(mockConfig, 'somnia', testLogger)
|
|
187
188
|
|
|
188
189
|
expect(page.items).toStrictEqual([])
|
|
189
190
|
expect(page.next).toBeUndefined()
|
|
190
191
|
})
|
|
191
192
|
|
|
192
193
|
it('returns empty when the node config is not external', async () => {
|
|
193
|
-
const page = await getValidators(ledgerConfig, 'somnia')
|
|
194
|
+
const page = await getValidators(ledgerConfig, 'somnia', testLogger)
|
|
194
195
|
|
|
195
196
|
expect(page.items).toStrictEqual([])
|
|
196
197
|
expect(mockedWithApi).not.toHaveBeenCalled()
|
|
@@ -199,7 +200,7 @@ describe('staking/validators/somnia', () => {
|
|
|
199
200
|
it('returns empty on getCommitteeValidators failure', async () => {
|
|
200
201
|
setupRpc(routeByName({ getCommitteeValidators: () => new Error('network error') }))
|
|
201
202
|
|
|
202
|
-
const page = await getValidators(mockConfig, 'somnia')
|
|
203
|
+
const page = await getValidators(mockConfig, 'somnia', testLogger)
|
|
203
204
|
|
|
204
205
|
expect(page.items).toStrictEqual([])
|
|
205
206
|
})
|
|
@@ -214,7 +215,7 @@ describe('staking/validators/somnia', () => {
|
|
|
214
215
|
[VALIDATOR_B.toLowerCase()]: 'Kiln',
|
|
215
216
|
})
|
|
216
217
|
|
|
217
|
-
const names = await fetchValidatorNames('somnia')
|
|
218
|
+
const names = await fetchValidatorNames('somnia', testLogger)
|
|
218
219
|
|
|
219
220
|
expect(names).toStrictEqual({
|
|
220
221
|
[VALIDATOR_A.toLowerCase()]: 'BitGo',
|
|
@@ -229,7 +230,7 @@ describe('staking/validators/somnia', () => {
|
|
|
229
230
|
'0x1234': 'Too short',
|
|
230
231
|
})
|
|
231
232
|
|
|
232
|
-
const names = await fetchValidatorNames('somnia')
|
|
233
|
+
const names = await fetchValidatorNames('somnia', testLogger)
|
|
233
234
|
|
|
234
235
|
expect(names).toStrictEqual({ [VALIDATOR_A.toLowerCase()]: 'Everstake' })
|
|
235
236
|
})
|
|
@@ -243,7 +244,7 @@ describe('staking/validators/somnia', () => {
|
|
|
243
244
|
'0x4444444444444444444444444444444444444444': null,
|
|
244
245
|
})
|
|
245
246
|
|
|
246
|
-
const names = await fetchValidatorNames('somnia')
|
|
247
|
+
const names = await fetchValidatorNames('somnia', testLogger)
|
|
247
248
|
|
|
248
249
|
expect(names).toStrictEqual({ [VALIDATOR_A.toLowerCase()]: 'Everstake' })
|
|
249
250
|
})
|
|
@@ -255,7 +256,7 @@ describe('staking/validators/somnia', () => {
|
|
|
255
256
|
error: { code: -32600, message: 'invalid request' },
|
|
256
257
|
})
|
|
257
258
|
|
|
258
|
-
const names = await fetchValidatorNames('somnia')
|
|
259
|
+
const names = await fetchValidatorNames('somnia', testLogger)
|
|
259
260
|
|
|
260
261
|
expect(names).toStrictEqual({})
|
|
261
262
|
})
|
|
@@ -263,7 +264,7 @@ describe('staking/validators/somnia', () => {
|
|
|
263
264
|
it('returns {} when the payload is an array', async () => {
|
|
264
265
|
mockNamesResponse([{ addr: VALIDATOR_A, name: 'BitGo' }])
|
|
265
266
|
|
|
266
|
-
const names = await fetchValidatorNames('somnia')
|
|
267
|
+
const names = await fetchValidatorNames('somnia', testLogger)
|
|
267
268
|
|
|
268
269
|
expect(names).toStrictEqual({})
|
|
269
270
|
})
|
|
@@ -271,7 +272,7 @@ describe('staking/validators/somnia', () => {
|
|
|
271
272
|
it('returns {} when the payload is null', async () => {
|
|
272
273
|
mockNamesResponse(null)
|
|
273
274
|
|
|
274
|
-
const names = await fetchValidatorNames('somnia')
|
|
275
|
+
const names = await fetchValidatorNames('somnia', testLogger)
|
|
275
276
|
|
|
276
277
|
expect(names).toStrictEqual({})
|
|
277
278
|
})
|
|
@@ -279,13 +280,13 @@ describe('staking/validators/somnia', () => {
|
|
|
279
280
|
it('rethrows on network error so makeLRUCache evicts (callers stay best-effort)', async () => {
|
|
280
281
|
mockedNetwork.mockRejectedValue(new Error('network down'))
|
|
281
282
|
|
|
282
|
-
await expect(fetchValidatorNames('somnia')).rejects.toThrow('network down')
|
|
283
|
+
await expect(fetchValidatorNames('somnia', testLogger)).rejects.toThrow('network down')
|
|
283
284
|
})
|
|
284
285
|
})
|
|
285
286
|
|
|
286
287
|
describe('fetchSomniaStakes', () => {
|
|
287
288
|
const fetchStakes = (config: EvmConfigInfo = mockConfig) =>
|
|
288
|
-
fetchSomniaStakes(config, DELEGATOR, STAKING_CONTRACTS['somnia'], 'somnia')
|
|
289
|
+
fetchSomniaStakes(config, DELEGATOR, STAKING_CONTRACTS['somnia'], 'somnia', testLogger)
|
|
289
290
|
|
|
290
291
|
const defaultStakeHandlers = (
|
|
291
292
|
overrides: {
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
import type { EvmConfigInfo } from '../../config'
|
|
5
5
|
import type { StakingContractConfig } from '../../types/staking'
|
|
6
6
|
import type { ValidatorApi } from './types'
|
|
7
|
-
import type { Page } from '@ledgerhq/coin-module-framework/api/index'
|
|
7
|
+
import type { Cursor, Page } from '@ledgerhq/coin-module-framework/api/index'
|
|
8
8
|
import type { AssetInfo, Stake, Validator } from '@ledgerhq/coin-module-framework/api/types'
|
|
9
|
+
import type { Logger } from '@ledgerhq/coin-module-framework/config'
|
|
9
10
|
import type { JsonRpcProvider } from 'ethers'
|
|
10
11
|
import network from '@ledgerhq/live-network'
|
|
11
12
|
import { makeLRUCache } from '@ledgerhq/live-network/cache'
|
|
12
|
-
import { log } from '@ledgerhq/logs'
|
|
13
13
|
import { ethers } from 'ethers'
|
|
14
14
|
import { evmUnit } from '../../logic/evmUnit'
|
|
15
15
|
import { withApi } from '../../network/node/rpc.common'
|
|
@@ -94,7 +94,10 @@ const resolveContext = (
|
|
|
94
94
|
* Returns `{}` when unconfigured/malformed; rethrows on transient network errors so the cache evicts.
|
|
95
95
|
* Callers should treat it as best-effort and fall back to the on-chain address as the display name.
|
|
96
96
|
*/
|
|
97
|
-
export const fetchValidatorNames = async (
|
|
97
|
+
export const fetchValidatorNames = async (
|
|
98
|
+
currencyId: string,
|
|
99
|
+
logger: Logger
|
|
100
|
+
): Promise<ValidatorNamesMap> => {
|
|
98
101
|
const baseUrl = STAKING_CONTRACTS[currencyId]?.validatorNameSource?.baseUrl
|
|
99
102
|
if (!baseUrl) return {}
|
|
100
103
|
|
|
@@ -112,7 +115,7 @@ export const fetchValidatorNames = async (currencyId: string): Promise<Validator
|
|
|
112
115
|
}
|
|
113
116
|
return out
|
|
114
117
|
} catch (error) {
|
|
115
|
-
|
|
118
|
+
logger('coin-evm/staking', 'fetchValidatorNames: validator-names lookup failed', {
|
|
116
119
|
currencyId,
|
|
117
120
|
error: error instanceof Error ? error.message : String(error),
|
|
118
121
|
})
|
|
@@ -120,10 +123,15 @@ export const fetchValidatorNames = async (currencyId: string): Promise<Validator
|
|
|
120
123
|
}
|
|
121
124
|
}
|
|
122
125
|
|
|
123
|
-
const validatorNamesCache = makeLRUCache(
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
126
|
+
const validatorNamesCache = makeLRUCache(
|
|
127
|
+
fetchValidatorNames,
|
|
128
|
+
// logger is a side-channel arg, excluded from the cache key.
|
|
129
|
+
(currencyId: string, _logger: Logger) => currencyId,
|
|
130
|
+
{
|
|
131
|
+
max: 10,
|
|
132
|
+
ttl: NAME_CACHE_MAX_AGE_MS,
|
|
133
|
+
}
|
|
134
|
+
)
|
|
127
135
|
|
|
128
136
|
// Drop the cached validator-names overlay for a currency (primarily to keep tests deterministic,
|
|
129
137
|
// since the cache is module-level and keyed only by currencyId).
|
|
@@ -135,9 +143,10 @@ const fetchValidatorDetails = async (
|
|
|
135
143
|
provider: JsonRpcProvider,
|
|
136
144
|
iface: ethers.Interface,
|
|
137
145
|
contractAddress: string,
|
|
138
|
-
addresses: string[]
|
|
146
|
+
addresses: string[],
|
|
147
|
+
logger: Logger
|
|
139
148
|
): Promise<Validator[]> => {
|
|
140
|
-
const names = await validatorNamesCache(currencyId).catch(() => ({}) as ValidatorNamesMap)
|
|
149
|
+
const names = await validatorNamesCache(currencyId, logger).catch(() => ({}) as ValidatorNamesMap)
|
|
141
150
|
|
|
142
151
|
const items: Validator[] = []
|
|
143
152
|
|
|
@@ -170,7 +179,7 @@ const fetchValidatorDetails = async (
|
|
|
170
179
|
|
|
171
180
|
settled.forEach((res, idx) => {
|
|
172
181
|
if (res.status === 'rejected') {
|
|
173
|
-
|
|
182
|
+
logger('coin-evm/staking', 'fetchSomniaValidatorDetails: getStake call failed', {
|
|
174
183
|
address: chunk[idx],
|
|
175
184
|
error: res.reason instanceof Error ? res.reason.message : String(res.reason),
|
|
176
185
|
})
|
|
@@ -186,7 +195,9 @@ const fetchValidatorDetails = async (
|
|
|
186
195
|
|
|
187
196
|
const fetchValidators = async (
|
|
188
197
|
evmConfig: EvmConfigInfo,
|
|
189
|
-
currencyId: string
|
|
198
|
+
currencyId: string,
|
|
199
|
+
logger: Logger,
|
|
200
|
+
_cursor?: Cursor
|
|
190
201
|
): Promise<Page<Validator>> => {
|
|
191
202
|
const ctx = resolveContext(evmConfig, currencyId)
|
|
192
203
|
if (!ctx) return { items: [], next: undefined }
|
|
@@ -211,14 +222,15 @@ const fetchValidators = async (
|
|
|
211
222
|
provider,
|
|
212
223
|
iface,
|
|
213
224
|
ctx.contractAddress,
|
|
214
|
-
addresses
|
|
225
|
+
addresses,
|
|
226
|
+
logger
|
|
215
227
|
)
|
|
216
228
|
return { items, next: undefined }
|
|
217
229
|
},
|
|
218
230
|
ctx.node
|
|
219
231
|
)
|
|
220
232
|
} catch (error) {
|
|
221
|
-
|
|
233
|
+
logger('coin-evm/staking', 'fetchSomniaValidators: fetch failed', {
|
|
222
234
|
currencyId,
|
|
223
235
|
error: error instanceof Error ? error.message : String(error),
|
|
224
236
|
})
|
|
@@ -288,7 +300,9 @@ export const fetchSomniaStakes = async (
|
|
|
288
300
|
evmConfig: EvmConfigInfo,
|
|
289
301
|
address: string,
|
|
290
302
|
_config: StakingContractConfig,
|
|
291
|
-
currencyId: string
|
|
303
|
+
currencyId: string,
|
|
304
|
+
logger: Logger,
|
|
305
|
+
_knownValIds?: string[]
|
|
292
306
|
): Promise<Stake[]> => {
|
|
293
307
|
const ctx = resolveContext(evmConfig, currencyId)
|
|
294
308
|
if (!ctx) return []
|
|
@@ -313,7 +327,9 @@ export const fetchSomniaStakes = async (
|
|
|
313
327
|
|
|
314
328
|
// Display-name overlay, keyed by lowercased operator address. Best-effort: on failure
|
|
315
329
|
// the delegation still shows, falling back to the raw address as its name.
|
|
316
|
-
const names = await validatorNamesCache(currencyId).catch(
|
|
330
|
+
const names = await validatorNamesCache(currencyId, logger).catch(
|
|
331
|
+
() => ({}) as ValidatorNamesMap
|
|
332
|
+
)
|
|
317
333
|
|
|
318
334
|
const asset: AssetInfo = {
|
|
319
335
|
type: 'native',
|
|
@@ -339,7 +355,7 @@ export const fetchSomniaStakes = async (
|
|
|
339
355
|
settled.forEach((res, idx) => {
|
|
340
356
|
const validatorAddress = chunk[idx]
|
|
341
357
|
if (res.status === 'rejected') {
|
|
342
|
-
|
|
358
|
+
logger('coin-evm/staking', 'fetchSomniaStakes: stake fetch failed', {
|
|
343
359
|
validator: validatorAddress,
|
|
344
360
|
error: res.reason instanceof Error ? res.reason.message : String(res.reason),
|
|
345
361
|
})
|
|
@@ -358,7 +374,7 @@ export const fetchSomniaStakes = async (
|
|
|
358
374
|
} catch (error) {
|
|
359
375
|
// A malformed validator address (or other toStake failure) shouldn't drop the
|
|
360
376
|
// rest of the batch — skip this one and keep the valid stakes.
|
|
361
|
-
|
|
377
|
+
logger('coin-evm/staking', 'fetchSomniaStakes: toStake failed', {
|
|
362
378
|
validator: validatorAddress,
|
|
363
379
|
error: error instanceof Error ? error.message : String(error),
|
|
364
380
|
})
|
|
@@ -370,7 +386,7 @@ export const fetchSomniaStakes = async (
|
|
|
370
386
|
ctx.node
|
|
371
387
|
)
|
|
372
388
|
} catch (error) {
|
|
373
|
-
|
|
389
|
+
logger('coin-evm/staking', 'fetchSomniaStakes: delegations fetch failed', {
|
|
374
390
|
currencyId,
|
|
375
391
|
error: error instanceof Error ? error.message : String(error),
|
|
376
392
|
})
|
|
@@ -4,11 +4,13 @@
|
|
|
4
4
|
import type { EvmConfigInfo } from '../../config'
|
|
5
5
|
import type { Cursor, Page } from '@ledgerhq/coin-module-framework/api/index'
|
|
6
6
|
import type { Validator } from '@ledgerhq/coin-module-framework/api/types'
|
|
7
|
+
import type { Logger } from '@ledgerhq/coin-module-framework/config'
|
|
7
8
|
|
|
8
9
|
export type ValidatorApi = {
|
|
9
10
|
fetchValidators: (
|
|
10
11
|
config: EvmConfigInfo,
|
|
11
12
|
currencyId: string,
|
|
13
|
+
logger: Logger,
|
|
12
14
|
cursor?: Cursor
|
|
13
15
|
) => Promise<Page<Validator>>
|
|
14
16
|
}
|