@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
package/src/adapters/ledger.ts
CHANGED
|
@@ -9,6 +9,7 @@ import type {
|
|
|
9
9
|
LedgerExplorerOperation,
|
|
10
10
|
} from '../types'
|
|
11
11
|
import type { MemoNotSupported, Operation } from '@ledgerhq/coin-module-framework/api/types'
|
|
12
|
+
import type { Logger } from '@ledgerhq/coin-module-framework/config'
|
|
12
13
|
import eip55 from 'eip55'
|
|
13
14
|
import { safeBigInt, safeEncodeEIP55 } from '../logic-public'
|
|
14
15
|
import { detectEvmStakingOperationType } from '../staking/detectOperationType'
|
|
@@ -20,11 +21,12 @@ import { detectEvmStakingOperationType } from '../staking/detectOperationType'
|
|
|
20
21
|
export const ledgerOperationToOperations = (
|
|
21
22
|
address: string,
|
|
22
23
|
currencyId: string,
|
|
23
|
-
ledgerOp: LedgerExplorerOperation
|
|
24
|
+
ledgerOp: LedgerExplorerOperation,
|
|
25
|
+
logger: Logger
|
|
24
26
|
): Array<Operation<MemoNotSupported>> => {
|
|
25
27
|
const checksummedAddress = eip55.encode(address)
|
|
26
|
-
const from = safeEncodeEIP55(ledgerOp.from)
|
|
27
|
-
const to = safeEncodeEIP55(ledgerOp.to)
|
|
28
|
+
const from = safeEncodeEIP55(ledgerOp.from, logger)
|
|
29
|
+
const to = safeEncodeEIP55(ledgerOp.to, logger)
|
|
28
30
|
const input = ledgerOp.input ?? undefined
|
|
29
31
|
const methodId = input ? input.slice(0, 10) : undefined // 0x + 4-byte selector
|
|
30
32
|
const failed = !ledgerOp.status
|
|
@@ -82,11 +84,12 @@ export const ledgerERC20EventToOperations = (
|
|
|
82
84
|
address: string,
|
|
83
85
|
coinOperation: Operation<MemoNotSupported>,
|
|
84
86
|
event: LedgerExplorerERC20TransferEvent,
|
|
85
|
-
index = 0
|
|
87
|
+
index = 0,
|
|
88
|
+
logger: Logger
|
|
86
89
|
): Array<Operation<MemoNotSupported>> => {
|
|
87
90
|
const checksummedAddress = eip55.encode(address)
|
|
88
|
-
const from = safeEncodeEIP55(event.from)
|
|
89
|
-
const to = safeEncodeEIP55(event.to)
|
|
91
|
+
const from = safeEncodeEIP55(event.from, logger)
|
|
92
|
+
const to = safeEncodeEIP55(event.to, logger)
|
|
90
93
|
const contract = eip55.encode(event.contract)
|
|
91
94
|
const types: string[] = []
|
|
92
95
|
|
|
@@ -122,11 +125,12 @@ export const ledgerERC721EventToOperations = (
|
|
|
122
125
|
address: string,
|
|
123
126
|
coinOperation: Operation<MemoNotSupported>,
|
|
124
127
|
event: LedgerExplorerER721TransferEvent,
|
|
125
|
-
index = 0
|
|
128
|
+
index = 0,
|
|
129
|
+
logger: Logger
|
|
126
130
|
): Array<Operation<MemoNotSupported>> => {
|
|
127
131
|
const checksummedAddress = eip55.encode(address)
|
|
128
|
-
const from = safeEncodeEIP55(event.sender)
|
|
129
|
-
const to = safeEncodeEIP55(event.receiver)
|
|
132
|
+
const from = safeEncodeEIP55(event.sender, logger)
|
|
133
|
+
const to = safeEncodeEIP55(event.receiver, logger)
|
|
130
134
|
const contract = eip55.encode(event.contract)
|
|
131
135
|
const types: string[] = []
|
|
132
136
|
|
|
@@ -163,11 +167,12 @@ export const ledgerERC1155EventToOperations = (
|
|
|
163
167
|
address: string,
|
|
164
168
|
coinOperation: Operation<MemoNotSupported>,
|
|
165
169
|
event: LedgerExplorerER1155TransferEvent,
|
|
166
|
-
index = 0
|
|
170
|
+
index = 0,
|
|
171
|
+
logger: Logger
|
|
167
172
|
): Array<Operation<MemoNotSupported>> => {
|
|
168
173
|
const checksummedAddress = eip55.encode(address)
|
|
169
|
-
const from = safeEncodeEIP55(event.sender)
|
|
170
|
-
const to = safeEncodeEIP55(event.receiver)
|
|
174
|
+
const from = safeEncodeEIP55(event.sender, logger)
|
|
175
|
+
const to = safeEncodeEIP55(event.receiver, logger)
|
|
171
176
|
const contract = eip55.encode(event.contract)
|
|
172
177
|
const types: string[] = []
|
|
173
178
|
|
|
@@ -208,13 +213,14 @@ export const ledgerInternalTransactionToOperations = (
|
|
|
208
213
|
address: string,
|
|
209
214
|
coinOperation: Operation<MemoNotSupported>,
|
|
210
215
|
action: LedgerExplorerInternalTransaction,
|
|
211
|
-
index = 0
|
|
216
|
+
index = 0,
|
|
217
|
+
logger: Logger
|
|
212
218
|
): Array<Operation<MemoNotSupported>> => {
|
|
213
219
|
if (coinOperation.tx.failed) return []
|
|
214
220
|
|
|
215
221
|
const checksummedAddress = eip55.encode(address)
|
|
216
|
-
const from = safeEncodeEIP55(action.from)
|
|
217
|
-
const to = safeEncodeEIP55(action.to)
|
|
222
|
+
const from = safeEncodeEIP55(action.from, logger)
|
|
223
|
+
const to = safeEncodeEIP55(action.to, logger)
|
|
218
224
|
const hasFailed = !!action.error // AFAIK this is not working, all actions contain error = null even when it reverted
|
|
219
225
|
const value = safeBigInt(action.value)
|
|
220
226
|
const types: string[] = []
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import type {
|
|
4
|
+
import type { EvmConfigInfo } from '../config'
|
|
5
5
|
import { createMockEvmContext } from '../fixtures/context.fixtures'
|
|
6
6
|
import { createApi } from './index'
|
|
7
7
|
|
|
@@ -25,9 +25,11 @@ describe('getBlock ERC20 transfers', () => {
|
|
|
25
25
|
|
|
26
26
|
let module: ReturnType<typeof createApi>
|
|
27
27
|
|
|
28
|
-
const velasEvmConfig:
|
|
28
|
+
const velasEvmConfig: EvmConfigInfo = {
|
|
29
|
+
status: { type: 'active' },
|
|
29
30
|
chainId: 111,
|
|
30
31
|
name: 'Velas EVM',
|
|
32
|
+
unit: { name: 'VLX', code: 'VLX', magnitude: 18 },
|
|
31
33
|
node: {
|
|
32
34
|
type: 'external',
|
|
33
35
|
uri: 'https://evmexplorer.velas.com/rpc',
|
|
@@ -87,9 +89,11 @@ describe('getBlock ERC20 transfers', () => {
|
|
|
87
89
|
|
|
88
90
|
let module: ReturnType<typeof createApi>
|
|
89
91
|
|
|
90
|
-
const bscConfig:
|
|
92
|
+
const bscConfig: EvmConfigInfo = {
|
|
93
|
+
status: { type: 'active' },
|
|
91
94
|
chainId: 56,
|
|
92
95
|
name: 'Binance Smart Chain',
|
|
96
|
+
unit: { name: 'BNB', code: 'BNB', magnitude: 18 },
|
|
93
97
|
node: {
|
|
94
98
|
type: 'ledger',
|
|
95
99
|
explorerId: 'bnb',
|
|
@@ -143,9 +147,11 @@ describe('getBlock ERC20 transfers', () => {
|
|
|
143
147
|
describe.skip('External RPC Node (zkSync)', () => {
|
|
144
148
|
let module: ReturnType<typeof createApi>
|
|
145
149
|
|
|
146
|
-
const zkSyncConfig:
|
|
150
|
+
const zkSyncConfig: EvmConfigInfo = {
|
|
151
|
+
status: { type: 'active' },
|
|
147
152
|
chainId: 324,
|
|
148
153
|
name: 'zkSync Era',
|
|
154
|
+
unit: { name: 'ETH', code: 'ETH', magnitude: 18 },
|
|
149
155
|
node: {
|
|
150
156
|
type: 'external',
|
|
151
157
|
uri: 'https://zksync.coin.ledger.com',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import type {
|
|
4
|
+
import type { EvmConfigInfo } from '../config'
|
|
5
5
|
import { createMockEvmContext } from '../fixtures/context.fixtures'
|
|
6
6
|
import { createApi } from './index'
|
|
7
7
|
|
|
@@ -9,9 +9,11 @@ describe('Flare (external node)', () => {
|
|
|
9
9
|
describe('getBlock', () => {
|
|
10
10
|
let module: ReturnType<typeof createApi>
|
|
11
11
|
|
|
12
|
-
const flareConfig:
|
|
12
|
+
const flareConfig: EvmConfigInfo = {
|
|
13
|
+
status: { type: 'active' },
|
|
13
14
|
chainId: 14,
|
|
14
15
|
name: 'Flare',
|
|
16
|
+
unit: { name: 'FLR', code: 'FLR', magnitude: 18 },
|
|
15
17
|
node: {
|
|
16
18
|
type: 'external',
|
|
17
19
|
uri: 'https://rpc.au.cc/flare',
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
mkLedgerExplorer,
|
|
12
12
|
mkLedgerNode,
|
|
13
13
|
} from '../fixtures/context.fixtures'
|
|
14
|
+
import { isNative } from '../types/assets'
|
|
14
15
|
import { createApi } from './index'
|
|
15
16
|
|
|
16
17
|
describe.each([
|
|
@@ -643,11 +644,11 @@ describe.each([
|
|
|
643
644
|
tx: { feesPayer: expect.any(String) },
|
|
644
645
|
})
|
|
645
646
|
const senderAsset = senderTxOps[0].asset
|
|
646
|
-
if (senderAsset
|
|
647
|
+
if (!isNative(senderAsset)) {
|
|
647
648
|
expect(senderAsset.assetReference?.toLowerCase()).toBe(contract.toLowerCase())
|
|
648
649
|
expectAddressEq(senderTxOps[0].senders[0], sender)
|
|
649
650
|
expectAddressEq(senderTxOps[0].recipients[0], recipient)
|
|
650
|
-
expectAddressEq(senderAsset.assetOwner
|
|
651
|
+
expectAddressEq(senderAsset.assetOwner!, sender)
|
|
651
652
|
}
|
|
652
653
|
expectAddressEq(senderTxOps[0].tx.feesPayer!, sender)
|
|
653
654
|
expect(senderTxOps[0].value).toBeGreaterThan(0n)
|
|
@@ -658,11 +659,11 @@ describe.each([
|
|
|
658
659
|
asset: { type: 'erc20' },
|
|
659
660
|
})
|
|
660
661
|
const recipientAsset = recipientTxOps[0].asset
|
|
661
|
-
if (recipientAsset
|
|
662
|
+
if (!isNative(recipientAsset)) {
|
|
662
663
|
expect(recipientAsset.assetReference?.toLowerCase()).toBe(contract.toLowerCase())
|
|
663
664
|
expectAddressEq(recipientTxOps[0].senders[0], sender)
|
|
664
665
|
expectAddressEq(recipientTxOps[0].recipients[0], recipient)
|
|
665
|
-
expectAddressEq(recipientAsset.assetOwner
|
|
666
|
+
expectAddressEq(recipientAsset.assetOwner!, recipient)
|
|
666
667
|
}
|
|
667
668
|
expect(recipientTxOps[0].value).toBe(senderTxOps[0].value)
|
|
668
669
|
})
|
|
@@ -705,9 +706,9 @@ describe.each([
|
|
|
705
706
|
tx: { feesPayer: expect.any(String) },
|
|
706
707
|
})
|
|
707
708
|
const tokenOpAsset = tokenOp!.asset
|
|
708
|
-
if (tokenOpAsset
|
|
709
|
+
if (!isNative(tokenOpAsset)) {
|
|
709
710
|
expect(tokenOpAsset.assetReference?.toLowerCase()).toBe(lidoContract.toLowerCase())
|
|
710
|
-
expectAddressEq(tokenOpAsset.assetOwner
|
|
711
|
+
expectAddressEq(tokenOpAsset.assetOwner!, sender)
|
|
711
712
|
}
|
|
712
713
|
expect(tokenOp!.senders[0].toLowerCase()).toBe(zeroAddress.toLowerCase())
|
|
713
714
|
expectAddressEq(tokenOp!.recipients[0], sender)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import type {
|
|
4
|
+
import type { EvmConfigInfo } from '../config'
|
|
5
5
|
import { createMockEvmContext } from '../fixtures/context.fixtures'
|
|
6
6
|
import { createApi } from './index'
|
|
7
7
|
|
|
@@ -25,9 +25,11 @@ describe('Linea (etherscan explorer)', () => {
|
|
|
25
25
|
const TO = '0x9F41fE989C556d8b312Ce398b7f7B5Ac90919a73'
|
|
26
26
|
|
|
27
27
|
let module: ReturnType<typeof createApi>
|
|
28
|
-
const lineaConfig:
|
|
28
|
+
const lineaConfig: EvmConfigInfo = {
|
|
29
|
+
status: { type: 'active' },
|
|
29
30
|
chainId: 59144,
|
|
30
31
|
name: 'Linea',
|
|
32
|
+
unit: { name: 'ETH', code: 'ETH', magnitude: 18 },
|
|
31
33
|
node: {
|
|
32
34
|
type: 'external',
|
|
33
35
|
uri: 'https://linea.coin.ledger.com',
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import type {
|
|
4
|
+
import type { EvmConfigInfo } from '../config'
|
|
5
5
|
import { fail } from 'assert'
|
|
6
6
|
import { createMockEvmContext } from '../fixtures/context.fixtures'
|
|
7
7
|
import { createApi } from './index'
|
|
8
8
|
|
|
9
9
|
describe('Shape (external node)', () => {
|
|
10
10
|
describe('getBlock', () => {
|
|
11
|
-
const shapeConfig:
|
|
11
|
+
const shapeConfig: EvmConfigInfo = {
|
|
12
|
+
status: { type: 'active' },
|
|
12
13
|
chainId: 360,
|
|
13
14
|
name: 'Shape',
|
|
15
|
+
unit: { name: 'ETH', code: 'ETH', magnitude: 18 },
|
|
14
16
|
node: {
|
|
15
17
|
type: 'external',
|
|
16
18
|
uri: 'https://mainnet.shape.network',
|
|
@@ -9,6 +9,7 @@ describe('EVM Api (Somnia)', () => {
|
|
|
9
9
|
let module: ReturnType<typeof createApi>
|
|
10
10
|
|
|
11
11
|
const config: Partial<EvmConfigInfo> = {
|
|
12
|
+
chainId: 5031,
|
|
12
13
|
node: { type: 'external', uri: 'https://api.infra.mainnet.somnia.network' },
|
|
13
14
|
explorer: { type: 'blockscout', uri: 'https://explorer.somnia.network/api/' },
|
|
14
15
|
}
|
package/src/api/index.test.ts
CHANGED
|
@@ -144,9 +144,9 @@ describe('staking support capability', () => {
|
|
|
144
144
|
const api = createApi('sei_evm')
|
|
145
145
|
|
|
146
146
|
await expect(api.getValidators(mockEvmContext)).resolves.toEqual(expectedPage)
|
|
147
|
-
expect(mockGetValidatorsPage).toHaveBeenCalledWith(
|
|
147
|
+
expect(mockGetValidatorsPage).toHaveBeenCalledWith(mockEvmContext, 'sei_evm', undefined)
|
|
148
148
|
|
|
149
149
|
await expect(api.getValidators(mockEvmContext, { cursor: '42' })).resolves.toEqual(expectedPage)
|
|
150
|
-
expect(mockGetValidatorsPage).toHaveBeenCalledWith(
|
|
150
|
+
expect(mockGetValidatorsPage).toHaveBeenCalledWith(mockEvmContext, 'sei_evm', '42')
|
|
151
151
|
})
|
|
152
152
|
})
|
package/src/api/index.ts
CHANGED
|
@@ -121,8 +121,7 @@ export function createApi(currencyId: string) {
|
|
|
121
121
|
context: EvmContext,
|
|
122
122
|
options?: { cursor?: Cursor }
|
|
123
123
|
): Promise<Page<Validator>> => {
|
|
124
|
-
|
|
125
|
-
return getValidatorsPage(config, currencyId, options?.cursor)
|
|
124
|
+
return getValidatorsPage(context, currencyId, options?.cursor)
|
|
126
125
|
},
|
|
127
126
|
getNextSequence: (context: EvmContext, address: string): Promise<bigint> =>
|
|
128
127
|
getNextSequence(context, currencyId, address),
|
package/src/config.ts
CHANGED
|
@@ -10,7 +10,6 @@ import type {
|
|
|
10
10
|
LedgerNodeConfig,
|
|
11
11
|
} from '../config'
|
|
12
12
|
import type { Logger } from '@ledgerhq/coin-module-framework/config'
|
|
13
|
-
import { log } from '@ledgerhq/logs'
|
|
14
13
|
|
|
15
14
|
/** Returns an external (JSON-RPC) node config for use in tests. */
|
|
16
15
|
export const mkExternalNode = (partial?: {
|
|
@@ -70,6 +69,7 @@ export const createMockEvmConfigInfo = (
|
|
|
70
69
|
): EvmConfigInfo => ({
|
|
71
70
|
status: { type: 'active' },
|
|
72
71
|
name: 'test',
|
|
72
|
+
unit: { name: 'test', code: 'TEST', magnitude: 18 },
|
|
73
73
|
explorer: { type: 'none' },
|
|
74
74
|
...config,
|
|
75
75
|
})
|
|
@@ -96,12 +96,12 @@ export const createMockEvmCoinConfig = (
|
|
|
96
96
|
*/
|
|
97
97
|
export const createMockEvmContext = (config?: Partial<EvmConfigInfo>): EvmContext => ({
|
|
98
98
|
config: async (_currencyId?: string): Promise<EvmConfigInfo> =>
|
|
99
|
-
({
|
|
100
|
-
logger:
|
|
99
|
+
createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode(), ...config }),
|
|
100
|
+
logger: jest.fn(),
|
|
101
101
|
})
|
|
102
102
|
|
|
103
103
|
/** A ready-to-use mock {@link EvmContext} for tests that don't need a custom config. */
|
|
104
104
|
export const mockEvmContext: EvmContext = createMockEvmContext()
|
|
105
105
|
|
|
106
|
-
/** A
|
|
107
|
-
export const testLogger: Logger =
|
|
106
|
+
/** A mock {@link Logger} for use in tests. */
|
|
107
|
+
export const testLogger: Logger = jest.fn()
|
package/src/logic/common.ts
CHANGED
|
@@ -167,7 +167,7 @@ export async function prepareUnsignedTxParams(
|
|
|
167
167
|
// Prepare staking intents once (can require async on-chain lookups). See: LIVE-32750
|
|
168
168
|
const preparedStakingIntent = isSend
|
|
169
169
|
? undefined
|
|
170
|
-
: await prepareStakingIntent(config, currencyId, transactionIntent)
|
|
170
|
+
: await prepareStakingIntent(config, currencyId, transactionIntent, logger)
|
|
171
171
|
|
|
172
172
|
const { to, data, value } = isSend
|
|
173
173
|
? buildSendTxParams(transactionIntent)
|
package/src/logic/getBalance.ts
CHANGED
|
@@ -81,16 +81,16 @@ async function getTokenBalances(
|
|
|
81
81
|
if (extractKnownValIds) {
|
|
82
82
|
const ops = await explorerApi.getOperations(
|
|
83
83
|
config,
|
|
84
|
+
context.logger,
|
|
84
85
|
currencyId,
|
|
85
86
|
address,
|
|
86
87
|
0,
|
|
87
88
|
undefined,
|
|
88
89
|
undefined,
|
|
89
90
|
undefined,
|
|
90
|
-
undefined
|
|
91
|
-
context.logger
|
|
91
|
+
undefined
|
|
92
92
|
)
|
|
93
|
-
knownValidatorIds = extractKnownValIds(currencyId, ops.lastCoinOperations)
|
|
93
|
+
knownValidatorIds = extractKnownValIds(currencyId, ops.lastCoinOperations, context.logger)
|
|
94
94
|
|
|
95
95
|
discoveredAssets = []
|
|
96
96
|
for (const operation of ops.lastTokenOperations) {
|
|
@@ -105,6 +105,7 @@ async function getTokenBalances(
|
|
|
105
105
|
|
|
106
106
|
discoveredAssets = await explorerApi.discoverTokenAssets(
|
|
107
107
|
config,
|
|
108
|
+
context.logger,
|
|
108
109
|
currencyId,
|
|
109
110
|
address,
|
|
110
111
|
scanMinHeight
|
package/src/logic/getBlock.ts
CHANGED
|
@@ -11,8 +11,8 @@ import type {
|
|
|
11
11
|
BlockTransaction,
|
|
12
12
|
TransferBlockOperation,
|
|
13
13
|
} from '@ledgerhq/coin-module-framework/api/index'
|
|
14
|
+
import type { Logger } from '@ledgerhq/coin-module-framework/config'
|
|
14
15
|
import { promiseAllBatched } from '@ledgerhq/coin-module-framework/promises'
|
|
15
|
-
import { log } from '@ledgerhq/logs'
|
|
16
16
|
import { rpcTransactionToBlockOperations } from '../adapters/blockOperations'
|
|
17
17
|
import { DEFAULT_INTERNAL_TX_SOURCES } from '../config'
|
|
18
18
|
import { UnsupportedRpcMethodError } from '../errors'
|
|
@@ -41,7 +41,8 @@ export async function getBlock(
|
|
|
41
41
|
config,
|
|
42
42
|
nodeApi,
|
|
43
43
|
currencyId,
|
|
44
|
-
internalTxSources
|
|
44
|
+
internalTxSources,
|
|
45
|
+
context.logger
|
|
45
46
|
)
|
|
46
47
|
|
|
47
48
|
const result = await nodeApi.getBlockByHeight(currencyId, height, true)
|
|
@@ -71,6 +72,7 @@ export async function getBlock(
|
|
|
71
72
|
transactionHashes,
|
|
72
73
|
nodeApi,
|
|
73
74
|
result.height,
|
|
75
|
+
context.logger,
|
|
74
76
|
result.transactions
|
|
75
77
|
),
|
|
76
78
|
transactionHashes.length === 0
|
|
@@ -127,6 +129,7 @@ async function getTransactionsFromNode(
|
|
|
127
129
|
transactionHashes: string[],
|
|
128
130
|
nodeApi: ReturnType<typeof getNodeApi>,
|
|
129
131
|
blockHeight: number,
|
|
132
|
+
logger: Logger,
|
|
130
133
|
prefetchedTransactions?: PrefetchedBlockTransaction[]
|
|
131
134
|
): Promise<BlockTransaction[]> {
|
|
132
135
|
if (transactionHashes.length === 0) return []
|
|
@@ -135,7 +138,8 @@ async function getTransactionsFromNode(
|
|
|
135
138
|
currencyId,
|
|
136
139
|
blockHeight,
|
|
137
140
|
prefetchedTransactions,
|
|
138
|
-
nodeApi
|
|
141
|
+
nodeApi,
|
|
142
|
+
logger
|
|
139
143
|
)
|
|
140
144
|
if (bulkTransactions) return bulkTransactions
|
|
141
145
|
|
|
@@ -150,7 +154,7 @@ async function getTransactionsFromNode(
|
|
|
150
154
|
const transactionResults = await promiseAllBatched(
|
|
151
155
|
MAX_CONCURRENCY,
|
|
152
156
|
transactionHashes,
|
|
153
|
-
(txHash: string) => getTransactionFromHash(currencyId, txHash, nodeApi)
|
|
157
|
+
(txHash: string) => getTransactionFromHash(currencyId, txHash, nodeApi, logger)
|
|
154
158
|
)
|
|
155
159
|
|
|
156
160
|
return transactionResults.filter((tx): tx is BlockTransaction => tx !== null)
|
|
@@ -160,7 +164,8 @@ async function getTransactionsFromPrefetchedData(
|
|
|
160
164
|
currencyId: string,
|
|
161
165
|
blockHeight: number,
|
|
162
166
|
prefetchedTransactions: PrefetchedBlockTransaction[] | undefined,
|
|
163
|
-
nodeApi: ReturnType<typeof getNodeApi
|
|
167
|
+
nodeApi: ReturnType<typeof getNodeApi>,
|
|
168
|
+
logger: Logger
|
|
164
169
|
): Promise<BlockTransaction[] | null> {
|
|
165
170
|
if (!prefetchedTransactions || prefetchedTransactions.length === 0 || !nodeApi.getBlockReceipts)
|
|
166
171
|
return null
|
|
@@ -173,10 +178,15 @@ async function getTransactionsFromPrefetchedData(
|
|
|
173
178
|
for (const tx of prefetchedTransactions) {
|
|
174
179
|
const receipt = receiptsByHash.get(tx.hash)
|
|
175
180
|
if (!receipt) return null
|
|
176
|
-
const blockTx = prefetchedTransactionToBlockTransaction(tx, receipt)
|
|
181
|
+
const blockTx = prefetchedTransactionToBlockTransaction(tx, receipt, logger)
|
|
177
182
|
transactions.push({
|
|
178
183
|
...blockTx,
|
|
179
|
-
operations: applyChainSpecificCorrections(
|
|
184
|
+
operations: applyChainSpecificCorrections(
|
|
185
|
+
currencyId,
|
|
186
|
+
blockTx.operations,
|
|
187
|
+
receipt.type,
|
|
188
|
+
logger
|
|
189
|
+
),
|
|
180
190
|
})
|
|
181
191
|
}
|
|
182
192
|
|
|
@@ -185,7 +195,7 @@ async function getTransactionsFromPrefetchedData(
|
|
|
185
195
|
if (!(error instanceof UnsupportedRpcMethodError) || error.method !== 'eth_getBlockReceipts')
|
|
186
196
|
throw error
|
|
187
197
|
|
|
188
|
-
|
|
198
|
+
logger('warn', 'EVM getBlock fallback: eth_getBlockReceipts unsupported', {
|
|
189
199
|
currencyId,
|
|
190
200
|
blockHeight,
|
|
191
201
|
error: error.rawError,
|
|
@@ -196,7 +206,8 @@ async function getTransactionsFromPrefetchedData(
|
|
|
196
206
|
|
|
197
207
|
function prefetchedTransactionToBlockTransaction(
|
|
198
208
|
tx: PrefetchedBlockTransaction,
|
|
199
|
-
receipt: BlockReceiptInfo
|
|
209
|
+
receipt: BlockReceiptInfo,
|
|
210
|
+
logger: Logger
|
|
200
211
|
): BlockTransaction {
|
|
201
212
|
const failed = receipt.status === 0
|
|
202
213
|
// Some EVM chains (e.g. Cronos) omit `gasPrice` from transaction
|
|
@@ -205,14 +216,17 @@ function prefetchedTransactionToBlockTransaction(
|
|
|
205
216
|
const receiptGasPrice = BigInt(receipt.gasPrice)
|
|
206
217
|
const gasPrice = receiptGasPrice > 0n ? receiptGasPrice : BigInt(tx.gasPrice)
|
|
207
218
|
const fees = BigInt(receipt.gasUsed) * gasPrice + (receipt.l1Fee ? BigInt(receipt.l1Fee) : 0n)
|
|
208
|
-
const operations = rpcTransactionToBlockOperations(
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
219
|
+
const operations = rpcTransactionToBlockOperations(
|
|
220
|
+
{
|
|
221
|
+
from: tx.from,
|
|
222
|
+
to: tx.to,
|
|
223
|
+
value: tx.value,
|
|
224
|
+
erc20Transfers: receipt.erc20Transfers,
|
|
225
|
+
},
|
|
226
|
+
logger
|
|
227
|
+
)
|
|
214
228
|
|
|
215
|
-
const details = buildSmartContractDetails(tx.to, tx.input, receipt.contractAddress)
|
|
229
|
+
const details = buildSmartContractDetails(tx.to, tx.input, logger, receipt.contractAddress)
|
|
216
230
|
|
|
217
231
|
return {
|
|
218
232
|
hash: tx.hash,
|
|
@@ -227,7 +241,8 @@ function prefetchedTransactionToBlockTransaction(
|
|
|
227
241
|
async function getTransactionFromHash(
|
|
228
242
|
currencyId: string,
|
|
229
243
|
txHash: string,
|
|
230
|
-
nodeApi: ReturnType<typeof getNodeApi
|
|
244
|
+
nodeApi: ReturnType<typeof getNodeApi>,
|
|
245
|
+
logger: Logger
|
|
231
246
|
): Promise<BlockTransaction | null> {
|
|
232
247
|
const txInfo = await nodeApi.getTransaction(currencyId, txHash)
|
|
233
248
|
|
|
@@ -235,10 +250,10 @@ async function getTransactionFromHash(
|
|
|
235
250
|
const fees =
|
|
236
251
|
BigInt(txInfo.gasUsed) * BigInt(txInfo.gasPrice) + (txInfo.l1Fee ? BigInt(txInfo.l1Fee) : 0n)
|
|
237
252
|
|
|
238
|
-
const rawOperations = rpcTransactionToBlockOperations(txInfo)
|
|
239
|
-
const operations = applyChainSpecificCorrections(currencyId, rawOperations, txInfo.type)
|
|
253
|
+
const rawOperations = rpcTransactionToBlockOperations(txInfo, logger)
|
|
254
|
+
const operations = applyChainSpecificCorrections(currencyId, rawOperations, txInfo.type, logger)
|
|
240
255
|
|
|
241
|
-
const details = buildSmartContractDetails(txInfo.to, txInfo.input, txInfo.contractAddress)
|
|
256
|
+
const details = buildSmartContractDetails(txInfo.to, txInfo.input, logger, txInfo.contractAddress)
|
|
242
257
|
|
|
243
258
|
return {
|
|
244
259
|
hash: txHash,
|
|
@@ -250,16 +265,15 @@ async function getTransactionFromHash(
|
|
|
250
265
|
}
|
|
251
266
|
}
|
|
252
267
|
|
|
253
|
-
const ZKSYNC_MINT_PEER = safeEncodeEIP55('0x0000000000000000000000000000000000000000')
|
|
254
|
-
|
|
255
268
|
function applyChainSpecificCorrections(
|
|
256
269
|
currencyId: string,
|
|
257
270
|
operations: BlockOperation[],
|
|
258
|
-
receiptType: number | undefined
|
|
271
|
+
receiptType: number | undefined,
|
|
272
|
+
logger: Logger
|
|
259
273
|
): BlockOperation[] {
|
|
260
274
|
switch (currencyId) {
|
|
261
275
|
case 'zksync':
|
|
262
|
-
return rewriteZkSyncL1ToL2DepositOps(operations, receiptType)
|
|
276
|
+
return rewriteZkSyncL1ToL2DepositOps(operations, receiptType, logger)
|
|
263
277
|
default:
|
|
264
278
|
return operations
|
|
265
279
|
}
|
|
@@ -272,11 +286,13 @@ function applyChainSpecificCorrections(
|
|
|
272
286
|
*/
|
|
273
287
|
function rewriteZkSyncL1ToL2DepositOps(
|
|
274
288
|
operations: BlockOperation[],
|
|
275
|
-
receiptType: number | undefined
|
|
289
|
+
receiptType: number | undefined,
|
|
290
|
+
logger: Logger
|
|
276
291
|
): BlockOperation[] {
|
|
277
292
|
if (receiptType !== 0xff) return operations
|
|
293
|
+
const zkSyncMintPeer = safeEncodeEIP55('0x0000000000000000000000000000000000000000', logger)
|
|
278
294
|
const withoutMintSource = operations.filter(
|
|
279
|
-
(op) => op.type !== 'transfer' || op.address.toLowerCase() !==
|
|
295
|
+
(op) => op.type !== 'transfer' || op.address.toLowerCase() !== zkSyncMintPeer.toLowerCase()
|
|
280
296
|
)
|
|
281
297
|
const nativeSelf = withoutMintSource.find(
|
|
282
298
|
(op): op is TransferBlockOperation =>
|
|
@@ -290,7 +306,7 @@ function rewriteZkSyncL1ToL2DepositOps(
|
|
|
290
306
|
const nativeCredit: TransferBlockOperation = {
|
|
291
307
|
type: 'transfer',
|
|
292
308
|
address: nativeSelf.address,
|
|
293
|
-
peer:
|
|
309
|
+
peer: zkSyncMintPeer,
|
|
294
310
|
asset: { type: 'native' },
|
|
295
311
|
amount: nativeSelf.amount,
|
|
296
312
|
}
|
package/src/logic/getStakes.ts
CHANGED
|
@@ -30,9 +30,10 @@ export const getStakes = async (
|
|
|
30
30
|
address,
|
|
31
31
|
contractConfig,
|
|
32
32
|
currencyId,
|
|
33
|
+
context.logger,
|
|
33
34
|
options?.knownValidatorIds
|
|
34
35
|
),
|
|
35
|
-
fetchUnbondings(config, currencyId, address).catch(() => []),
|
|
36
|
+
fetchUnbondings(config, currencyId, address, context.logger).catch(() => []),
|
|
36
37
|
])
|
|
37
38
|
return { items: [...stakes, ...unbondings] }
|
|
38
39
|
} catch {
|