@ledgerhq/coin-evm 8.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/CHANGELOG.md +19 -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 +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/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 +2 -3
- 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 +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 +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
|
@@ -14,6 +14,7 @@ import type {
|
|
|
14
14
|
LedgerExplorerInternalTransaction,
|
|
15
15
|
} from '../types'
|
|
16
16
|
import type { BlockOperation } from '@ledgerhq/coin-module-framework/api/index'
|
|
17
|
+
import { testLogger } from '../fixtures/context.fixtures'
|
|
17
18
|
import {
|
|
18
19
|
ledgerTransactionToBlockOperations,
|
|
19
20
|
rpcTransactionToBlockOperations,
|
|
@@ -25,12 +26,15 @@ describe('EVM Family', () => {
|
|
|
25
26
|
describe('blockOperations', () => {
|
|
26
27
|
describe('rpcTransactionToBlockOperations', () => {
|
|
27
28
|
it('should extract native ETH transfer operations from transaction with value', () => {
|
|
28
|
-
const operations = rpcTransactionToBlockOperations(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
const operations = rpcTransactionToBlockOperations(
|
|
30
|
+
{
|
|
31
|
+
from: '0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d',
|
|
32
|
+
value: '1000000000000000000',
|
|
33
|
+
to: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',
|
|
34
|
+
erc20Transfers: [],
|
|
35
|
+
},
|
|
36
|
+
testLogger
|
|
37
|
+
)
|
|
34
38
|
expect(operations).toEqual([
|
|
35
39
|
{
|
|
36
40
|
type: 'transfer',
|
|
@@ -50,23 +54,29 @@ describe('EVM Family', () => {
|
|
|
50
54
|
})
|
|
51
55
|
|
|
52
56
|
it('should return empty array for transaction with zero value', () => {
|
|
53
|
-
const operations = rpcTransactionToBlockOperations(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
const operations = rpcTransactionToBlockOperations(
|
|
58
|
+
{
|
|
59
|
+
from: '0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d',
|
|
60
|
+
value: '0',
|
|
61
|
+
to: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',
|
|
62
|
+
erc20Transfers: [],
|
|
63
|
+
},
|
|
64
|
+
testLogger
|
|
65
|
+
)
|
|
59
66
|
|
|
60
67
|
expect(operations).toHaveLength(0)
|
|
61
68
|
})
|
|
62
69
|
|
|
63
70
|
it('should handle transaction with undefined to address (contract creation)', () => {
|
|
64
|
-
const operations = rpcTransactionToBlockOperations(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
71
|
+
const operations = rpcTransactionToBlockOperations(
|
|
72
|
+
{
|
|
73
|
+
from: '0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d',
|
|
74
|
+
value: '500000000000000000',
|
|
75
|
+
to: undefined,
|
|
76
|
+
erc20Transfers: [],
|
|
77
|
+
},
|
|
78
|
+
testLogger
|
|
79
|
+
)
|
|
70
80
|
|
|
71
81
|
expect(operations).toHaveLength(1)
|
|
72
82
|
expect(operations[0]).toEqual({
|
|
@@ -79,12 +89,15 @@ describe('EVM Family', () => {
|
|
|
79
89
|
})
|
|
80
90
|
|
|
81
91
|
it('should handle transaction with empty from address', () => {
|
|
82
|
-
const operations = rpcTransactionToBlockOperations(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
92
|
+
const operations = rpcTransactionToBlockOperations(
|
|
93
|
+
{
|
|
94
|
+
from: '',
|
|
95
|
+
value: '2000000000000000000',
|
|
96
|
+
to: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',
|
|
97
|
+
erc20Transfers: [],
|
|
98
|
+
},
|
|
99
|
+
testLogger
|
|
100
|
+
)
|
|
88
101
|
|
|
89
102
|
expect(operations).toHaveLength(1)
|
|
90
103
|
expect(operations[0]).toEqual({
|
|
@@ -97,33 +110,39 @@ describe('EVM Family', () => {
|
|
|
97
110
|
})
|
|
98
111
|
|
|
99
112
|
it('should handle invalid addresses gracefully', () => {
|
|
100
|
-
const operations = rpcTransactionToBlockOperations(
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
113
|
+
const operations = rpcTransactionToBlockOperations(
|
|
114
|
+
{
|
|
115
|
+
from: '0x0',
|
|
116
|
+
value: '1000000000000000000',
|
|
117
|
+
to: '0x',
|
|
118
|
+
erc20Transfers: [],
|
|
119
|
+
},
|
|
120
|
+
testLogger
|
|
121
|
+
)
|
|
106
122
|
|
|
107
123
|
expect(operations).toHaveLength(0)
|
|
108
124
|
})
|
|
109
125
|
|
|
110
126
|
it('should extract ERC20 transfers from erc20Transfers', () => {
|
|
111
|
-
const operations = rpcTransactionToBlockOperations(
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
127
|
+
const operations = rpcTransactionToBlockOperations(
|
|
128
|
+
{
|
|
129
|
+
from: '0x6cbcd73cd8e8a42844662f0a0e76d7f79afd933d',
|
|
130
|
+
value: '0',
|
|
131
|
+
to: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',
|
|
132
|
+
erc20Transfers: [
|
|
133
|
+
{
|
|
134
|
+
asset: {
|
|
135
|
+
type: 'erc20',
|
|
136
|
+
assetReference: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
|
137
|
+
},
|
|
138
|
+
from: '0x6cBCD73CD8e8a42844662f0A0e76D7F79Afd933d',
|
|
139
|
+
to: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',
|
|
140
|
+
value: '1000000',
|
|
120
141
|
},
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
],
|
|
126
|
-
})
|
|
142
|
+
],
|
|
143
|
+
},
|
|
144
|
+
testLogger
|
|
145
|
+
)
|
|
127
146
|
|
|
128
147
|
expect(operations).toEqual([
|
|
129
148
|
{
|
|
@@ -203,7 +222,7 @@ describe('EVM Family', () => {
|
|
|
203
222
|
}),
|
|
204
223
|
]
|
|
205
224
|
|
|
206
|
-
const byHash = traceBlockItemsToOperationsByHash(items)
|
|
225
|
+
const byHash = traceBlockItemsToOperationsByHash(items, testLogger)
|
|
207
226
|
|
|
208
227
|
expect(byHash.size).toBe(2)
|
|
209
228
|
expect(byHash.get('0xhash1')).toEqual([
|
|
@@ -248,7 +267,7 @@ describe('EVM Family', () => {
|
|
|
248
267
|
}),
|
|
249
268
|
]
|
|
250
269
|
|
|
251
|
-
const byHash = traceBlockItemsToOperationsByHash(items)
|
|
270
|
+
const byHash = traceBlockItemsToOperationsByHash(items, testLogger)
|
|
252
271
|
|
|
253
272
|
expect(byHash.size).toBe(0)
|
|
254
273
|
})
|
|
@@ -261,7 +280,7 @@ describe('EVM Family', () => {
|
|
|
261
280
|
}),
|
|
262
281
|
]
|
|
263
282
|
|
|
264
|
-
const byHash = traceBlockItemsToOperationsByHash(items)
|
|
283
|
+
const byHash = traceBlockItemsToOperationsByHash(items, testLogger)
|
|
265
284
|
|
|
266
285
|
expect(byHash.size).toBe(0)
|
|
267
286
|
})
|
|
@@ -274,7 +293,7 @@ describe('EVM Family', () => {
|
|
|
274
293
|
}),
|
|
275
294
|
]
|
|
276
295
|
|
|
277
|
-
const byHash = traceBlockItemsToOperationsByHash(items)
|
|
296
|
+
const byHash = traceBlockItemsToOperationsByHash(items, testLogger)
|
|
278
297
|
|
|
279
298
|
expect(byHash.size).toBe(0)
|
|
280
299
|
})
|
|
@@ -288,7 +307,7 @@ describe('EVM Family', () => {
|
|
|
288
307
|
}),
|
|
289
308
|
]
|
|
290
309
|
|
|
291
|
-
const byHash = traceBlockItemsToOperationsByHash(items)
|
|
310
|
+
const byHash = traceBlockItemsToOperationsByHash(items, testLogger)
|
|
292
311
|
|
|
293
312
|
expect(byHash.size).toBe(1)
|
|
294
313
|
expect(byHash.get('0xsame')).toHaveLength(4)
|
|
@@ -297,7 +316,7 @@ describe('EVM Family', () => {
|
|
|
297
316
|
it('should skip reward traces', () => {
|
|
298
317
|
const items: TraceBlockItem[] = [makeRewardTraceItem()]
|
|
299
318
|
|
|
300
|
-
const byHash = traceBlockItemsToOperationsByHash(items)
|
|
319
|
+
const byHash = traceBlockItemsToOperationsByHash(items, testLogger)
|
|
301
320
|
|
|
302
321
|
expect(byHash.size).toBe(0)
|
|
303
322
|
})
|
|
@@ -308,7 +327,7 @@ describe('EVM Family', () => {
|
|
|
308
327
|
makeTraceItem({ transactionHash: '0xhash1' }),
|
|
309
328
|
]
|
|
310
329
|
|
|
311
|
-
const byHash = traceBlockItemsToOperationsByHash(items)
|
|
330
|
+
const byHash = traceBlockItemsToOperationsByHash(items, testLogger)
|
|
312
331
|
|
|
313
332
|
expect(byHash.size).toBe(1)
|
|
314
333
|
expect(byHash.get('0xhash1')).toHaveLength(2)
|
|
@@ -319,13 +338,13 @@ describe('EVM Family', () => {
|
|
|
319
338
|
makeTraceItem({ transactionHash: '0xhash1', traceAddress: [] }),
|
|
320
339
|
]
|
|
321
340
|
|
|
322
|
-
const byHash = traceBlockItemsToOperationsByHash(items)
|
|
341
|
+
const byHash = traceBlockItemsToOperationsByHash(items, testLogger)
|
|
323
342
|
|
|
324
343
|
expect(byHash.size).toBe(0)
|
|
325
344
|
})
|
|
326
345
|
|
|
327
346
|
it('should return empty map for empty input', () => {
|
|
328
|
-
const byHash = traceBlockItemsToOperationsByHash([])
|
|
347
|
+
const byHash = traceBlockItemsToOperationsByHash([], testLogger)
|
|
329
348
|
expect(byHash.size).toBe(0)
|
|
330
349
|
})
|
|
331
350
|
|
|
@@ -338,7 +357,7 @@ describe('EVM Family', () => {
|
|
|
338
357
|
action: makeAction({ callType }),
|
|
339
358
|
}),
|
|
340
359
|
]
|
|
341
|
-
const byHash = traceBlockItemsToOperationsByHash(items)
|
|
360
|
+
const byHash = traceBlockItemsToOperationsByHash(items, testLogger)
|
|
342
361
|
expect(byHash.size).toBe(0)
|
|
343
362
|
}
|
|
344
363
|
)
|
|
@@ -381,7 +400,7 @@ describe('EVM Family', () => {
|
|
|
381
400
|
value: '1000000000000000000', // 1 ETH
|
|
382
401
|
}
|
|
383
402
|
|
|
384
|
-
const operations = ledgerTransactionToBlockOperations(ledgerTx)
|
|
403
|
+
const operations = ledgerTransactionToBlockOperations(ledgerTx, testLogger)
|
|
385
404
|
|
|
386
405
|
expect(operations).toHaveLength(2)
|
|
387
406
|
expect(operations[0]).toEqual({
|
|
@@ -401,7 +420,7 @@ describe('EVM Family', () => {
|
|
|
401
420
|
})
|
|
402
421
|
|
|
403
422
|
it('should return empty array for transaction with zero value and no events', () => {
|
|
404
|
-
const operations = ledgerTransactionToBlockOperations(baseLedgerTx)
|
|
423
|
+
const operations = ledgerTransactionToBlockOperations(baseLedgerTx, testLogger)
|
|
405
424
|
|
|
406
425
|
expect(operations).toHaveLength(0)
|
|
407
426
|
})
|
|
@@ -419,7 +438,7 @@ describe('EVM Family', () => {
|
|
|
419
438
|
transfer_events: [erc20Event],
|
|
420
439
|
}
|
|
421
440
|
|
|
422
|
-
const operations = ledgerTransactionToBlockOperations(ledgerTx)
|
|
441
|
+
const operations = ledgerTransactionToBlockOperations(ledgerTx, testLogger)
|
|
423
442
|
|
|
424
443
|
expect(operations).toHaveLength(2)
|
|
425
444
|
expect(operations[0]).toEqual({
|
|
@@ -459,7 +478,7 @@ describe('EVM Family', () => {
|
|
|
459
478
|
transfer_events: erc20Events,
|
|
460
479
|
}
|
|
461
480
|
|
|
462
|
-
const operations = ledgerTransactionToBlockOperations(ledgerTx)
|
|
481
|
+
const operations = ledgerTransactionToBlockOperations(ledgerTx, testLogger)
|
|
463
482
|
|
|
464
483
|
expect(operations).toHaveLength(4)
|
|
465
484
|
expect(operations[0].asset).toEqual({
|
|
@@ -485,7 +504,7 @@ describe('EVM Family', () => {
|
|
|
485
504
|
erc721_transfer_events: [erc721Event],
|
|
486
505
|
}
|
|
487
506
|
|
|
488
|
-
const operations = ledgerTransactionToBlockOperations(ledgerTx)
|
|
507
|
+
const operations = ledgerTransactionToBlockOperations(ledgerTx, testLogger)
|
|
489
508
|
|
|
490
509
|
expect(operations).toHaveLength(2)
|
|
491
510
|
expect(operations[0]).toEqual({
|
|
@@ -521,7 +540,7 @@ describe('EVM Family', () => {
|
|
|
521
540
|
erc1155_transfer_events: [erc1155Event],
|
|
522
541
|
}
|
|
523
542
|
|
|
524
|
-
const operations = ledgerTransactionToBlockOperations(ledgerTx)
|
|
543
|
+
const operations = ledgerTransactionToBlockOperations(ledgerTx, testLogger)
|
|
525
544
|
|
|
526
545
|
expect(operations).toHaveLength(4) // 2 transfers × 2 addresses
|
|
527
546
|
expect(operations[0]).toEqual({
|
|
@@ -564,7 +583,7 @@ describe('EVM Family', () => {
|
|
|
564
583
|
actions: [internalTx],
|
|
565
584
|
}
|
|
566
585
|
|
|
567
|
-
const operations = ledgerTransactionToBlockOperations(ledgerTx)
|
|
586
|
+
const operations = ledgerTransactionToBlockOperations(ledgerTx, testLogger)
|
|
568
587
|
|
|
569
588
|
expect(operations).toHaveLength(2)
|
|
570
589
|
expect(operations[0]).toEqual({
|
|
@@ -599,7 +618,7 @@ describe('EVM Family', () => {
|
|
|
599
618
|
actions: [internalTx],
|
|
600
619
|
}
|
|
601
620
|
|
|
602
|
-
const operations = ledgerTransactionToBlockOperations(ledgerTx)
|
|
621
|
+
const operations = ledgerTransactionToBlockOperations(ledgerTx, testLogger)
|
|
603
622
|
|
|
604
623
|
expect(operations).toHaveLength(0)
|
|
605
624
|
})
|
|
@@ -620,7 +639,7 @@ describe('EVM Family', () => {
|
|
|
620
639
|
actions: [internalTx],
|
|
621
640
|
}
|
|
622
641
|
|
|
623
|
-
const operations = ledgerTransactionToBlockOperations(ledgerTx)
|
|
642
|
+
const operations = ledgerTransactionToBlockOperations(ledgerTx, testLogger)
|
|
624
643
|
|
|
625
644
|
expect(operations).toHaveLength(0)
|
|
626
645
|
})
|
|
@@ -667,7 +686,7 @@ describe('EVM Family', () => {
|
|
|
667
686
|
],
|
|
668
687
|
}
|
|
669
688
|
|
|
670
|
-
const operations = ledgerTransactionToBlockOperations(ledgerTx)
|
|
689
|
+
const operations = ledgerTransactionToBlockOperations(ledgerTx, testLogger)
|
|
671
690
|
|
|
672
691
|
// Native: 2, ERC20: 2, ERC721: 2, ERC1155: 2, Internal: 2 = 10 total
|
|
673
692
|
expect(operations).toHaveLength(10)
|
|
@@ -704,7 +723,7 @@ describe('EVM Family', () => {
|
|
|
704
723
|
to: '',
|
|
705
724
|
}
|
|
706
725
|
|
|
707
|
-
const operations = ledgerTransactionToBlockOperations(ledgerTx)
|
|
726
|
+
const operations = ledgerTransactionToBlockOperations(ledgerTx, testLogger)
|
|
708
727
|
|
|
709
728
|
expect(operations).toHaveLength(1)
|
|
710
729
|
expect(operations[0]).toEqual({
|
|
@@ -724,7 +743,7 @@ describe('EVM Family', () => {
|
|
|
724
743
|
to: '0x',
|
|
725
744
|
}
|
|
726
745
|
|
|
727
|
-
const operations = ledgerTransactionToBlockOperations(ledgerTx)
|
|
746
|
+
const operations = ledgerTransactionToBlockOperations(ledgerTx, testLogger)
|
|
728
747
|
|
|
729
748
|
expect(operations).toHaveLength(0)
|
|
730
749
|
})
|
|
@@ -8,6 +8,7 @@ import type {
|
|
|
8
8
|
BlockOperation,
|
|
9
9
|
TransferBlockOperation,
|
|
10
10
|
} from '@ledgerhq/coin-module-framework/api/index'
|
|
11
|
+
import type { Logger } from '@ledgerhq/coin-module-framework/config'
|
|
11
12
|
import { safeEncodeEIP55 } from '../logic-public'
|
|
12
13
|
import { isTraceBlockCallAction } from '../network/node/types'
|
|
13
14
|
import { NON_VALUE_TRANSFER_CALL_TYPES } from './nonValueTransferCallTypes'
|
|
@@ -21,10 +22,11 @@ function addTransferOperations(
|
|
|
21
22
|
from: string | null,
|
|
22
23
|
to: string | undefined,
|
|
23
24
|
asset: AssetInfo,
|
|
24
|
-
amount: bigint
|
|
25
|
+
amount: bigint,
|
|
26
|
+
logger: Logger
|
|
25
27
|
): void {
|
|
26
|
-
const encodedFrom = from ? safeEncodeEIP55(from) : ''
|
|
27
|
-
const encodedTo = to ? safeEncodeEIP55(to) : ''
|
|
28
|
+
const encodedFrom = from ? safeEncodeEIP55(from, logger) : ''
|
|
29
|
+
const encodedTo = to ? safeEncodeEIP55(to, logger) : ''
|
|
28
30
|
|
|
29
31
|
if (encodedFrom) {
|
|
30
32
|
const op: TransferBlockOperation = {
|
|
@@ -54,14 +56,15 @@ function addTransferOperations(
|
|
|
54
56
|
* This extracts native transfers from the transaction value field and ERC20 transfers from logs.
|
|
55
57
|
*/
|
|
56
58
|
export function rpcTransactionToBlockOperations(
|
|
57
|
-
tx: Pick<TransactionInfo, 'from' | 'value' | 'to' | 'erc20Transfers'
|
|
59
|
+
tx: Pick<TransactionInfo, 'from' | 'value' | 'to' | 'erc20Transfers'>,
|
|
60
|
+
logger: Logger
|
|
58
61
|
): BlockOperation[] {
|
|
59
62
|
const operations: BlockOperation[] = []
|
|
60
63
|
|
|
61
64
|
// Native value transfer
|
|
62
65
|
const value = BigInt(tx.value)
|
|
63
66
|
if (value > 0n) {
|
|
64
|
-
addTransferOperations(operations, tx.from, tx.to, { type: 'native' }, value)
|
|
67
|
+
addTransferOperations(operations, tx.from, tx.to, { type: 'native' }, value, logger)
|
|
65
68
|
}
|
|
66
69
|
|
|
67
70
|
// ERC20 transfers extracted from receipt logs
|
|
@@ -71,7 +74,8 @@ export function rpcTransactionToBlockOperations(
|
|
|
71
74
|
transfer.from,
|
|
72
75
|
transfer.to,
|
|
73
76
|
transfer.asset,
|
|
74
|
-
BigInt(transfer.value)
|
|
77
|
+
BigInt(transfer.value),
|
|
78
|
+
logger
|
|
75
79
|
)
|
|
76
80
|
}
|
|
77
81
|
|
|
@@ -112,7 +116,8 @@ function extractActionFields(
|
|
|
112
116
|
* Only includes internal calls with native value transfer (value > 0) and no error.
|
|
113
117
|
*/
|
|
114
118
|
export function traceBlockItemsToOperationsByHash(
|
|
115
|
-
items: TraceBlockItem[]
|
|
119
|
+
items: TraceBlockItem[],
|
|
120
|
+
logger: Logger
|
|
116
121
|
): Map<string, BlockOperation[]> {
|
|
117
122
|
const byHash = new Map<string, BlockOperation[]>()
|
|
118
123
|
|
|
@@ -125,7 +130,8 @@ export function traceBlockItemsToOperationsByHash(
|
|
|
125
130
|
actionFields.from,
|
|
126
131
|
actionFields.to,
|
|
127
132
|
{ type: 'native' },
|
|
128
|
-
actionFields.value
|
|
133
|
+
actionFields.value,
|
|
134
|
+
logger
|
|
129
135
|
)
|
|
130
136
|
const hash = actionFields.hash
|
|
131
137
|
let arr = byHash.get(hash)
|
|
@@ -141,7 +147,8 @@ export function traceBlockItemsToOperationsByHash(
|
|
|
141
147
|
}
|
|
142
148
|
|
|
143
149
|
export function ledgerTransactionToBlockOperations(
|
|
144
|
-
ledgerTx: LedgerExplorerOperation
|
|
150
|
+
ledgerTx: LedgerExplorerOperation,
|
|
151
|
+
logger: Logger
|
|
145
152
|
): BlockOperation[] {
|
|
146
153
|
const operations: BlockOperation[] = []
|
|
147
154
|
|
|
@@ -151,37 +158,40 @@ export function ledgerTransactionToBlockOperations(
|
|
|
151
158
|
ledgerTx.from,
|
|
152
159
|
ledgerTx.to,
|
|
153
160
|
{ type: 'native' },
|
|
154
|
-
BigInt(ledgerTx.value)
|
|
161
|
+
BigInt(ledgerTx.value),
|
|
162
|
+
logger
|
|
155
163
|
)
|
|
156
164
|
}
|
|
157
165
|
|
|
158
166
|
// Extract ERC20 token transfers
|
|
159
167
|
for (const event of ledgerTx.transfer_events) {
|
|
160
|
-
const contract = safeEncodeEIP55(event.contract)
|
|
168
|
+
const contract = safeEncodeEIP55(event.contract, logger)
|
|
161
169
|
addTransferOperations(
|
|
162
170
|
operations,
|
|
163
171
|
event.from,
|
|
164
172
|
event.to,
|
|
165
173
|
{ type: 'erc20', assetReference: contract },
|
|
166
|
-
BigInt(event.count)
|
|
174
|
+
BigInt(event.count),
|
|
175
|
+
logger
|
|
167
176
|
)
|
|
168
177
|
}
|
|
169
178
|
|
|
170
179
|
// Extract ERC721 NFT transfers
|
|
171
180
|
for (const event of ledgerTx.erc721_transfer_events) {
|
|
172
|
-
const contract = safeEncodeEIP55(event.contract)
|
|
181
|
+
const contract = safeEncodeEIP55(event.contract, logger)
|
|
173
182
|
addTransferOperations(
|
|
174
183
|
operations,
|
|
175
184
|
event.sender,
|
|
176
185
|
event.receiver,
|
|
177
186
|
{ type: 'erc721', assetReference: contract },
|
|
178
|
-
1n
|
|
187
|
+
1n,
|
|
188
|
+
logger
|
|
179
189
|
)
|
|
180
190
|
}
|
|
181
191
|
|
|
182
192
|
// Extract ERC1155 NFT transfers
|
|
183
193
|
for (const event of ledgerTx.erc1155_transfer_events) {
|
|
184
|
-
const contract = safeEncodeEIP55(event.contract)
|
|
194
|
+
const contract = safeEncodeEIP55(event.contract, logger)
|
|
185
195
|
|
|
186
196
|
for (const transfer of event.transfers) {
|
|
187
197
|
addTransferOperations(
|
|
@@ -189,7 +199,8 @@ export function ledgerTransactionToBlockOperations(
|
|
|
189
199
|
event.sender,
|
|
190
200
|
event.receiver,
|
|
191
201
|
{ type: 'erc1155', assetReference: contract },
|
|
192
|
-
BigInt(transfer.value)
|
|
202
|
+
BigInt(transfer.value),
|
|
203
|
+
logger
|
|
193
204
|
)
|
|
194
205
|
}
|
|
195
206
|
}
|
|
@@ -202,7 +213,7 @@ export function ledgerTransactionToBlockOperations(
|
|
|
202
213
|
|
|
203
214
|
const value = BigInt(action.value)
|
|
204
215
|
if (value > 0n) {
|
|
205
|
-
addTransferOperations(operations, action.from, action.to, { type: 'native' }, value)
|
|
216
|
+
addTransferOperations(operations, action.from, action.to, { type: 'native' }, value, logger)
|
|
206
217
|
}
|
|
207
218
|
}
|
|
208
219
|
|