@ledgerhq/coin-evm 15.0.0 → 16.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 +40 -0
- package/lib/adapters/etherscan.d.ts.map +1 -1
- package/lib/adapters/etherscan.js +14 -0
- package/lib/adapters/etherscan.js.map +1 -1
- package/lib/adapters/ledger.d.ts.map +1 -1
- package/lib/adapters/ledger.js +2 -0
- package/lib/adapters/ledger.js.map +1 -1
- package/lib/api/index.d.ts +1 -1
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +14 -15
- package/lib/api/index.js.map +1 -1
- package/lib/chains.d.ts +7 -0
- package/lib/chains.d.ts.map +1 -1
- package/lib/chains.js +17 -1
- package/lib/chains.js.map +1 -1
- package/lib/config.d.ts +1 -1
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +2 -1
- package/lib/config.js.map +1 -1
- package/lib/errors.d.ts +11 -0
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +17 -1
- package/lib/errors.js.map +1 -1
- package/lib/logic/broadcast.d.ts +1 -1
- package/lib/logic/broadcast.d.ts.map +1 -1
- package/lib/logic/broadcast.js +2 -2
- package/lib/logic/broadcast.js.map +1 -1
- package/lib/logic/craftTransaction.d.ts +1 -1
- package/lib/logic/craftTransaction.d.ts.map +1 -1
- package/lib/logic/craftTransaction.js +3 -3
- package/lib/logic/craftTransaction.js.map +1 -1
- package/lib/logic/estimateFees.d.ts +1 -1
- package/lib/logic/estimateFees.d.ts.map +1 -1
- package/lib/logic/estimateFees.js +19 -4
- package/lib/logic/estimateFees.js.map +1 -1
- package/lib/logic/getBalance.d.ts +1 -2
- package/lib/logic/getBalance.d.ts.map +1 -1
- package/lib/logic/getBalance.js +5 -6
- package/lib/logic/getBalance.js.map +1 -1
- package/lib/logic/getBlock.d.ts +1 -1
- package/lib/logic/getBlock.d.ts.map +1 -1
- package/lib/logic/getBlock.js +23 -6
- package/lib/logic/getBlock.js.map +1 -1
- package/lib/logic/getBlockInfo.d.ts +1 -1
- package/lib/logic/getBlockInfo.d.ts.map +1 -1
- package/lib/logic/getBlockInfo.js +2 -2
- package/lib/logic/getBlockInfo.js.map +1 -1
- package/lib/logic/getNextSequence.d.ts +1 -1
- package/lib/logic/getNextSequence.d.ts.map +1 -1
- package/lib/logic/getNextSequence.js +2 -2
- package/lib/logic/getNextSequence.js.map +1 -1
- package/lib/logic/getStakes.d.ts +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/lastBlock.d.ts +1 -1
- package/lib/logic/lastBlock.d.ts.map +1 -1
- package/lib/logic/lastBlock.js +2 -2
- package/lib/logic/lastBlock.js.map +1 -1
- package/lib/logic/listOperations.d.ts +1 -1
- package/lib/logic/listOperations.d.ts.map +1 -1
- package/lib/logic/listOperations.js +4 -2
- package/lib/logic/listOperations.js.map +1 -1
- package/lib/logic/validateIntent.d.ts +1 -1
- package/lib/logic/validateIntent.d.ts.map +1 -1
- package/lib/logic/validateIntent.js +3 -3
- package/lib/logic/validateIntent.js.map +1 -1
- package/lib/logic.d.ts.map +1 -1
- package/lib/logic.js +5 -10
- package/lib/logic.js.map +1 -1
- package/lib/network/node/explorerProxy.d.ts.map +1 -1
- package/lib/network/node/explorerProxy.js +2 -0
- package/lib/network/node/explorerProxy.js.map +1 -1
- package/lib/network/node/ledger.d.ts.map +1 -1
- package/lib/network/node/ledger.js +2 -9
- package/lib/network/node/ledger.js.map +1 -1
- package/lib/network/node/rpc.common.d.ts.map +1 -1
- package/lib/network/node/rpc.common.js +18 -9
- package/lib/network/node/rpc.common.js.map +1 -1
- package/lib/network/node/types.d.ts +3 -1
- package/lib/network/node/types.d.ts.map +1 -1
- package/lib/network/node/types.js.map +1 -1
- package/lib/staking/detectOperationType.js +1 -1
- package/lib/staking/validators/index.d.ts +1 -1
- package/lib/staking/validators/index.d.ts.map +1 -1
- package/lib/staking/validators/index.js +2 -2
- package/lib/staking/validators/index.js.map +1 -1
- package/lib/staking/validators/monadResolver.js +1 -1
- package/lib/staking/validators/monadResolver.js.map +1 -1
- package/lib-es/adapters/etherscan.d.ts.map +1 -1
- package/lib-es/adapters/etherscan.js +14 -0
- package/lib-es/adapters/etherscan.js.map +1 -1
- package/lib-es/adapters/ledger.d.ts.map +1 -1
- package/lib-es/adapters/ledger.js +2 -0
- package/lib-es/adapters/ledger.js.map +1 -1
- package/lib-es/api/index.d.ts +1 -1
- package/lib-es/api/index.d.ts.map +1 -1
- package/lib-es/api/index.js +14 -15
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/chains.d.ts +7 -0
- package/lib-es/chains.d.ts.map +1 -1
- package/lib-es/chains.js +16 -0
- package/lib-es/chains.js.map +1 -1
- package/lib-es/config.d.ts +1 -1
- package/lib-es/config.d.ts.map +1 -1
- package/lib-es/config.js +1 -1
- package/lib-es/config.js.map +1 -1
- package/lib-es/errors.d.ts +11 -0
- package/lib-es/errors.d.ts.map +1 -1
- package/lib-es/errors.js +15 -0
- package/lib-es/errors.js.map +1 -1
- package/lib-es/logic/broadcast.d.ts +1 -1
- package/lib-es/logic/broadcast.d.ts.map +1 -1
- package/lib-es/logic/broadcast.js +2 -2
- package/lib-es/logic/broadcast.js.map +1 -1
- package/lib-es/logic/craftTransaction.d.ts +1 -1
- package/lib-es/logic/craftTransaction.d.ts.map +1 -1
- package/lib-es/logic/craftTransaction.js +3 -3
- package/lib-es/logic/craftTransaction.js.map +1 -1
- package/lib-es/logic/estimateFees.d.ts +1 -1
- package/lib-es/logic/estimateFees.d.ts.map +1 -1
- package/lib-es/logic/estimateFees.js +19 -4
- package/lib-es/logic/estimateFees.js.map +1 -1
- package/lib-es/logic/getBalance.d.ts +1 -2
- package/lib-es/logic/getBalance.d.ts.map +1 -1
- package/lib-es/logic/getBalance.js +5 -6
- package/lib-es/logic/getBalance.js.map +1 -1
- package/lib-es/logic/getBlock.d.ts +1 -1
- package/lib-es/logic/getBlock.d.ts.map +1 -1
- package/lib-es/logic/getBlock.js +23 -6
- package/lib-es/logic/getBlock.js.map +1 -1
- package/lib-es/logic/getBlockInfo.d.ts +1 -1
- package/lib-es/logic/getBlockInfo.d.ts.map +1 -1
- package/lib-es/logic/getBlockInfo.js +2 -2
- package/lib-es/logic/getBlockInfo.js.map +1 -1
- package/lib-es/logic/getNextSequence.d.ts +1 -1
- package/lib-es/logic/getNextSequence.d.ts.map +1 -1
- package/lib-es/logic/getNextSequence.js +2 -2
- package/lib-es/logic/getNextSequence.js.map +1 -1
- package/lib-es/logic/getStakes.d.ts +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/lastBlock.d.ts +1 -1
- package/lib-es/logic/lastBlock.d.ts.map +1 -1
- package/lib-es/logic/lastBlock.js +2 -2
- package/lib-es/logic/lastBlock.js.map +1 -1
- package/lib-es/logic/listOperations.d.ts +1 -1
- package/lib-es/logic/listOperations.d.ts.map +1 -1
- package/lib-es/logic/listOperations.js +4 -2
- package/lib-es/logic/listOperations.js.map +1 -1
- package/lib-es/logic/validateIntent.d.ts +1 -1
- package/lib-es/logic/validateIntent.d.ts.map +1 -1
- package/lib-es/logic/validateIntent.js +3 -3
- package/lib-es/logic/validateIntent.js.map +1 -1
- package/lib-es/logic.d.ts.map +1 -1
- package/lib-es/logic.js +6 -11
- package/lib-es/logic.js.map +1 -1
- package/lib-es/network/node/explorerProxy.d.ts.map +1 -1
- package/lib-es/network/node/explorerProxy.js +2 -0
- package/lib-es/network/node/explorerProxy.js.map +1 -1
- package/lib-es/network/node/ledger.d.ts.map +1 -1
- package/lib-es/network/node/ledger.js +3 -10
- package/lib-es/network/node/ledger.js.map +1 -1
- package/lib-es/network/node/rpc.common.d.ts.map +1 -1
- package/lib-es/network/node/rpc.common.js +19 -10
- package/lib-es/network/node/rpc.common.js.map +1 -1
- package/lib-es/network/node/types.d.ts +3 -1
- package/lib-es/network/node/types.d.ts.map +1 -1
- package/lib-es/network/node/types.js.map +1 -1
- package/lib-es/staking/detectOperationType.js +1 -1
- package/lib-es/staking/validators/index.d.ts +1 -1
- package/lib-es/staking/validators/index.d.ts.map +1 -1
- package/lib-es/staking/validators/index.js +2 -2
- package/lib-es/staking/validators/index.js.map +1 -1
- package/lib-es/staking/validators/monadResolver.js +1 -1
- package/lib-es/staking/validators/monadResolver.js.map +1 -1
- package/package.json +2 -2
- package/src/adapters/etherscan.test.ts +57 -5
- package/src/adapters/etherscan.ts +15 -0
- package/src/adapters/ledger.test.ts +57 -9
- package/src/adapters/ledger.ts +2 -0
- package/src/api/index.ts +14 -17
- package/src/api/{getBlock.integ.test.ts → tests/getBlock.integ.test.ts} +7 -7
- package/src/api/{index.arbitrum.integ.test.ts → tests/index.arbitrum.integ.test.ts} +4 -4
- package/src/api/{index.arc.integ.test.ts → tests/index.arc.integ.test.ts} +4 -4
- package/src/api/{index.avalanche_c_chain_fuji.integ.test.ts → tests/index.avalanche_c_chain_fuji.integ.test.ts} +4 -4
- package/src/api/{index.cronos.integ.test.ts → tests/index.cronos.integ.test.ts} +4 -4
- package/src/api/{index.flare.integ.test.ts → tests/index.flare.integ.test.ts} +4 -4
- package/src/api/{index.integ.test.ts → tests/index.integ.test.ts} +8 -8
- package/src/api/{index.linea.integ.test.ts → tests/index.linea.integ.test.ts} +4 -4
- package/src/api/{index.monad_testnet.integ.test.ts → tests/index.monad_testnet.integ.test.ts} +5 -5
- package/src/api/{index.optimism.integ.test.ts → tests/index.optimism.integ.test.ts} +4 -4
- package/src/api/{index.rsk.integ.test.ts → tests/index.rsk.integ.test.ts} +4 -4
- package/src/api/{index.shape.integ.test.ts → tests/index.shape.integ.test.ts} +4 -4
- package/src/api/{index.somnia.integ.test.ts → tests/index.somnia.integ.test.ts} +4 -4
- package/src/api/{index.test.ts → tests/index.test.ts} +10 -10
- package/src/api/{index.zksync.integ.test.ts → tests/index.zksync.integ.test.ts} +3 -3
- package/src/chains.ts +17 -0
- package/src/config.ts +1 -1
- package/src/errors.ts +14 -0
- package/src/fixtures/context.fixtures.ts +2 -4
- package/src/logic/broadcast.ts +1 -2
- package/src/logic/craftTransaction.ts +2 -3
- package/src/logic/estimateFees.ts +22 -4
- package/src/logic/getBalance.ts +3 -6
- package/src/logic/getBlock.ts +39 -10
- package/src/logic/getBlockInfo.ts +2 -6
- package/src/logic/getNextSequence.ts +2 -6
- package/src/logic/getStakes.ts +1 -2
- package/src/logic/lastBlock.ts +2 -2
- package/src/logic/listOperations.ts +3 -2
- package/src/logic/tests/broadcast.integ.test.ts +1 -1
- package/src/logic/tests/broadcast.test.ts +5 -5
- package/src/logic/tests/broadcastSource.test.ts +4 -4
- package/src/logic/tests/common.test.ts +1 -1
- package/src/logic/tests/craftTransaction.test.ts +16 -21
- package/src/logic/tests/estimateFees.test.ts +40 -18
- package/src/logic/tests/getBalance.test.ts +20 -23
- package/src/logic/tests/getBlock.test.ts +159 -39
- package/src/logic/tests/getBlockInfo.test.ts +6 -6
- package/src/logic/tests/getNextSequence.test.ts +2 -2
- package/src/logic/tests/getStakes.test.ts +14 -14
- package/src/logic/tests/internalTransactionsFetcher.test.ts +1 -1
- package/src/logic/tests/lastBlock.test.ts +4 -4
- package/src/logic/tests/listOperations.test.ts +51 -55
- package/src/logic/tests/validateIntent.test.ts +39 -61
- package/src/logic/validateIntent.ts +2 -3
- package/src/logic.test.ts +24 -7
- package/src/logic.ts +6 -11
- package/src/network/node/explorerProxy.ts +2 -0
- package/src/network/node/ledger.ts +3 -10
- package/src/network/node/rpc.common.ts +23 -10
- package/src/network/node/types.ts +5 -2
- package/src/network/{explorer → tests/explorer}/etherscan.test.ts +8 -8
- package/src/network/{explorer → tests/explorer}/index.test.ts +11 -11
- package/src/network/{explorer → tests/explorer}/ledger.test.ts +11 -11
- package/src/network/{explorer → tests/explorer}/types.test.ts +1 -1
- package/src/network/{gasTracker → tests/gasTracker}/index.test.ts +3 -3
- package/src/network/{gasTracker → tests/gasTracker}/ledger.test.ts +4 -4
- package/src/network/{gasTracker → tests/gasTracker}/types.test.ts +1 -1
- package/src/network/{node → tests/node}/explorerProxy.test.ts +5 -2
- package/src/network/{node → tests/node}/gethCallTracerToTraceBlockItems.test.ts +4 -4
- package/src/network/{node → tests/node}/index.memoization.test.ts +3 -3
- package/src/network/{node → tests/node}/index.test.ts +3 -3
- package/src/network/{node → tests/node}/ledger.test.ts +9 -6
- package/src/network/{node → tests/node}/node.fixtures.ts +1 -1
- package/src/network/{node → tests/node}/rpc.errors.test.ts +1 -1
- package/src/network/{node → tests/node}/rpc.test.ts +57 -6
- package/src/network/{node → tests/node}/types.test.ts +1 -1
- package/src/network/{node → tests/node}/withNodeSources.test.ts +3 -3
- package/src/network/{withRetries.test.ts → tests/withRetries.test.ts} +2 -2
- package/src/staking/detectOperationType.ts +1 -1
- package/src/staking/redelegations.test.ts +3 -3
- package/src/staking/validators/index.ts +1 -2
- package/src/staking/validators/monadResolver.ts +1 -1
- package/src/staking/validators.integ.test.ts +1 -1
- package/src/staking/validators.test.ts +1 -1
|
@@ -9,7 +9,7 @@ import { CHAIN_ID } from '../../config'
|
|
|
9
9
|
import { createMockEvmContext } from '../../fixtures/context.fixtures'
|
|
10
10
|
import { getExplorerApi } from '../../network/explorer'
|
|
11
11
|
import { getNodeApi } from '../../network/node'
|
|
12
|
-
import { mockNodeApi } from '../../network/node/node.fixtures'
|
|
12
|
+
import { mockNodeApi } from '../../network/tests/node/node.fixtures'
|
|
13
13
|
import { getStakes } from '../getStakes'
|
|
14
14
|
import { getBalance } from '../index'
|
|
15
15
|
|
|
@@ -136,7 +136,7 @@ describe('getBalance', () => {
|
|
|
136
136
|
],
|
|
137
137
|
})
|
|
138
138
|
|
|
139
|
-
expect(await getBalance(context, '
|
|
139
|
+
expect(await getBalance(context, 'address')).toEqual(expected)
|
|
140
140
|
}
|
|
141
141
|
)
|
|
142
142
|
|
|
@@ -190,10 +190,9 @@ describe('getBalance', () => {
|
|
|
190
190
|
|
|
191
191
|
mockGetExplorerApi.mockReturnValue(explorerWithDiscovery(discoveredAssets))
|
|
192
192
|
|
|
193
|
-
const currency = ''
|
|
194
193
|
const userAddress = '0x000'
|
|
195
194
|
|
|
196
|
-
await getBalance(context,
|
|
195
|
+
await getBalance(context, userAddress, { includeAssets })
|
|
197
196
|
|
|
198
197
|
expect(nodeApiMock.getTokenBalance).toHaveBeenCalledTimes(expected.length)
|
|
199
198
|
for (const balance of expected) {
|
|
@@ -237,7 +236,7 @@ describe('getBalance', () => {
|
|
|
237
236
|
items: [],
|
|
238
237
|
})
|
|
239
238
|
|
|
240
|
-
const result = await getBalance(context, '
|
|
239
|
+
const result = await getBalance(context, 'address')
|
|
241
240
|
|
|
242
241
|
expect(result).toEqual([
|
|
243
242
|
{ asset: { type: 'native' }, value: 10n },
|
|
@@ -268,7 +267,7 @@ describe('getBalance', () => {
|
|
|
268
267
|
])
|
|
269
268
|
)
|
|
270
269
|
|
|
271
|
-
const result = await getBalance(context, '
|
|
270
|
+
const result = await getBalance(context, 'address')
|
|
272
271
|
|
|
273
272
|
expect(nodeApiMock.getTokenBalance).toHaveBeenCalledTimes(1)
|
|
274
273
|
expect(nodeApiMock.getTokenBalance).toHaveBeenCalledWith('address', REGULAR_CONTRACT)
|
|
@@ -293,7 +292,7 @@ describe('getBalance', () => {
|
|
|
293
292
|
explorerWithDiscovery([{ type: 'erc20', assetReference: NATIVE_CONTRACT.toLowerCase() }])
|
|
294
293
|
)
|
|
295
294
|
|
|
296
|
-
await getBalance(context, '
|
|
295
|
+
await getBalance(context, 'address')
|
|
297
296
|
|
|
298
297
|
expect(nodeApiMock.getTokenBalance).not.toHaveBeenCalled()
|
|
299
298
|
})
|
|
@@ -310,7 +309,7 @@ describe('getBalance', () => {
|
|
|
310
309
|
])
|
|
311
310
|
)
|
|
312
311
|
|
|
313
|
-
await getBalance(context, '
|
|
312
|
+
await getBalance(context, 'address')
|
|
314
313
|
|
|
315
314
|
expect(nodeApiMock.getTokenBalance).toHaveBeenCalledTimes(2)
|
|
316
315
|
})
|
|
@@ -325,7 +324,7 @@ describe('getBalance', () => {
|
|
|
325
324
|
items: [],
|
|
326
325
|
})
|
|
327
326
|
|
|
328
|
-
const result = await getBalance(context, '
|
|
327
|
+
const result = await getBalance(context, 'address')
|
|
329
328
|
expect(result[0]).toEqual({
|
|
330
329
|
value: BigInt('0'),
|
|
331
330
|
asset: { type: 'native' },
|
|
@@ -342,7 +341,7 @@ describe('getBalance', () => {
|
|
|
342
341
|
discoverTokenAssets: jest.fn().mockRejectedValue(explorerError),
|
|
343
342
|
})
|
|
344
343
|
|
|
345
|
-
await expect(getBalance(context, '
|
|
344
|
+
await expect(getBalance(context, 'address')).rejects.toThrow('explorer unavailable')
|
|
346
345
|
})
|
|
347
346
|
|
|
348
347
|
it('stays tolerant of a failed getStakes call while discovery succeeds', async () => {
|
|
@@ -350,7 +349,7 @@ describe('getBalance', () => {
|
|
|
350
349
|
mockGetStakes.mockRejectedValue(new Error('staking unavailable'))
|
|
351
350
|
mockGetExplorerApi.mockReturnValue(explorerWithDiscovery([]))
|
|
352
351
|
|
|
353
|
-
const result = await getBalance(context, '
|
|
352
|
+
const result = await getBalance(context, 'address')
|
|
354
353
|
|
|
355
354
|
expect(result).toEqual([{ asset: { type: 'native' }, value: 5n }])
|
|
356
355
|
})
|
|
@@ -365,7 +364,7 @@ describe('getBalance', () => {
|
|
|
365
364
|
|
|
366
365
|
const knownAssets: AssetInfo[] = [{ type: 'erc20', assetReference: '0xknown' }]
|
|
367
366
|
|
|
368
|
-
const result = await getBalance(context, '
|
|
367
|
+
const result = await getBalance(context, 'address', { knownAssets })
|
|
369
368
|
|
|
370
369
|
expect(nodeApiMock.getTokenBalance).toHaveBeenCalledWith('address', '0xknown')
|
|
371
370
|
expect(result).toEqual([
|
|
@@ -386,7 +385,7 @@ describe('getBalance', () => {
|
|
|
386
385
|
explorerWithDiscovery([{ type: 'erc20', assetReference: CHECKSUMMED }])
|
|
387
386
|
)
|
|
388
387
|
|
|
389
|
-
const result = await getBalance(context, '
|
|
388
|
+
const result = await getBalance(context, 'address', {
|
|
390
389
|
knownAssets: [{ type: 'erc20', assetReference: CHECKSUMMED.toLowerCase() }],
|
|
391
390
|
})
|
|
392
391
|
|
|
@@ -408,7 +407,7 @@ describe('getBalance', () => {
|
|
|
408
407
|
const discoverTokenAssets = jest.fn().mockResolvedValue([])
|
|
409
408
|
mockGetExplorerApi.mockReturnValue({ getOperations: jest.fn(), discoverTokenAssets })
|
|
410
409
|
|
|
411
|
-
await getBalance(context, '
|
|
410
|
+
await getBalance(context, 'address', {
|
|
412
411
|
scanAssetsMinHeight: 12345,
|
|
413
412
|
knownAssets: [{ type: 'erc20', assetReference: '0xknown' }],
|
|
414
413
|
})
|
|
@@ -427,7 +426,7 @@ describe('getBalance', () => {
|
|
|
427
426
|
const discoverTokenAssets = jest.fn().mockResolvedValue([])
|
|
428
427
|
mockGetExplorerApi.mockReturnValue({ getOperations: jest.fn(), discoverTokenAssets })
|
|
429
428
|
|
|
430
|
-
await getBalance(context, '
|
|
429
|
+
await getBalance(context, 'address', { scanAssetsMinHeight: 12345 })
|
|
431
430
|
|
|
432
431
|
// A resume without the known set drops every asset whose last transfer predates that
|
|
433
432
|
// height, and the framework reads a missing asset as a zero balance on a held token.
|
|
@@ -447,7 +446,7 @@ describe('getBalance', () => {
|
|
|
447
446
|
explorerWithDiscovery([{ type: 'erc20', assetReference: '0xdiscovered' }])
|
|
448
447
|
)
|
|
449
448
|
|
|
450
|
-
const result = await getBalance(context, '
|
|
449
|
+
const result = await getBalance(context, 'address', {
|
|
451
450
|
includeAssets: (asset: AssetInfo) =>
|
|
452
451
|
Promise.resolve('assetReference' in asset && asset.assetReference === '0xkept'),
|
|
453
452
|
knownAssets: [
|
|
@@ -472,7 +471,7 @@ describe('getBalance', () => {
|
|
|
472
471
|
explorerWithDiscovery([{ type: 'erc20', assetReference: '0xdup' }])
|
|
473
472
|
)
|
|
474
473
|
|
|
475
|
-
const result = await getBalance(context, '
|
|
474
|
+
const result = await getBalance(context, 'address', {
|
|
476
475
|
knownAssets: [{ type: 'erc20', assetReference: '0xdup' }],
|
|
477
476
|
})
|
|
478
477
|
|
|
@@ -491,7 +490,7 @@ describe('getBalance', () => {
|
|
|
491
490
|
explorerWithDiscovery([{ type: 'native' }, { type: 'erc20', assetReference: '0x123' }])
|
|
492
491
|
)
|
|
493
492
|
|
|
494
|
-
const result = await getBalance(context, '
|
|
493
|
+
const result = await getBalance(context, 'address', {
|
|
495
494
|
knownAssets: [{ type: 'native' }],
|
|
496
495
|
})
|
|
497
496
|
|
|
@@ -533,7 +532,7 @@ describe('getBalance', () => {
|
|
|
533
532
|
const discoverTokenAssets = jest.fn()
|
|
534
533
|
mockGetExplorerApi.mockReturnValue({ getOperations, discoverTokenAssets })
|
|
535
534
|
|
|
536
|
-
const result = await getBalance(monadContext, '
|
|
535
|
+
const result = await getBalance(monadContext, 'address')
|
|
537
536
|
|
|
538
537
|
// The explorer's `getOperations` takes the logger as its second argument; the walk this
|
|
539
538
|
// branch reuses passes it like every other caller.
|
|
@@ -566,7 +565,7 @@ describe('getBalance', () => {
|
|
|
566
565
|
discoverTokenAssets: jest.fn().mockResolvedValue([]),
|
|
567
566
|
})
|
|
568
567
|
|
|
569
|
-
await getBalance(context, '
|
|
568
|
+
await getBalance(context, 'address')
|
|
570
569
|
|
|
571
570
|
expect(getOperations).not.toHaveBeenCalled()
|
|
572
571
|
})
|
|
@@ -580,9 +579,7 @@ describe('getBalance', () => {
|
|
|
580
579
|
discoverTokenAssets: jest.fn(),
|
|
581
580
|
})
|
|
582
581
|
|
|
583
|
-
await expect(getBalance(monadContext, '
|
|
584
|
-
'explorer unavailable'
|
|
585
|
-
)
|
|
582
|
+
await expect(getBalance(monadContext, 'address')).rejects.toThrow('explorer unavailable')
|
|
586
583
|
})
|
|
587
584
|
})
|
|
588
585
|
})
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
import { safeEncodeEIP55 } from '../../logic-public'
|
|
27
27
|
import { getInternalTransactionsByBlock } from '../../network/explorer/etherscan'
|
|
28
28
|
import { getNodeApi } from '../../network/node'
|
|
29
|
-
import { mockNodeApi } from '../../network/node/node.fixtures'
|
|
29
|
+
import { mockNodeApi } from '../../network/tests/node/node.fixtures'
|
|
30
30
|
import { getBlock } from '../getBlock'
|
|
31
31
|
import { dropRootTraceDuplicates } from '../rootTraceDedup'
|
|
32
32
|
|
|
@@ -163,7 +163,7 @@ describe('getBlock', () => {
|
|
|
163
163
|
})
|
|
164
164
|
)
|
|
165
165
|
|
|
166
|
-
const result = await getBlock(context,
|
|
166
|
+
const result = await getBlock(context, 12345)
|
|
167
167
|
|
|
168
168
|
expect(result.transactions).toEqual([])
|
|
169
169
|
expect(jest.mocked(getInternalTransactionsByBlock)).not.toHaveBeenCalled()
|
|
@@ -191,7 +191,7 @@ describe('getBlock', () => {
|
|
|
191
191
|
})
|
|
192
192
|
)
|
|
193
193
|
|
|
194
|
-
await getBlock(context,
|
|
194
|
+
await getBlock(context, 12345)
|
|
195
195
|
|
|
196
196
|
expect(jest.mocked(getInternalTransactionsByBlock)).toHaveBeenCalledWith(
|
|
197
197
|
expect.anything(),
|
|
@@ -232,7 +232,7 @@ describe('getBlock', () => {
|
|
|
232
232
|
})
|
|
233
233
|
)
|
|
234
234
|
|
|
235
|
-
const result = await getBlock(context,
|
|
235
|
+
const result = await getBlock(context, 12345)
|
|
236
236
|
|
|
237
237
|
expect(result).toMatchObject({
|
|
238
238
|
info: {
|
|
@@ -318,7 +318,7 @@ describe('getBlock', () => {
|
|
|
318
318
|
})
|
|
319
319
|
)
|
|
320
320
|
|
|
321
|
-
const result = await getBlock(context,
|
|
321
|
+
const result = await getBlock(context, 12345)
|
|
322
322
|
|
|
323
323
|
expect(result.transactions[0]).toMatchObject({
|
|
324
324
|
hash: '0xtx1',
|
|
@@ -363,7 +363,7 @@ describe('getBlock', () => {
|
|
|
363
363
|
})
|
|
364
364
|
)
|
|
365
365
|
|
|
366
|
-
const result = await getBlock(context,
|
|
366
|
+
const result = await getBlock(context, 12345)
|
|
367
367
|
|
|
368
368
|
expect(result.transactions[0]).toMatchObject({
|
|
369
369
|
hash: '0xdeploy',
|
|
@@ -399,12 +399,133 @@ describe('getBlock', () => {
|
|
|
399
399
|
})
|
|
400
400
|
)
|
|
401
401
|
|
|
402
|
-
const result = await getBlock(context,
|
|
402
|
+
const result = await getBlock(context, 12345)
|
|
403
403
|
|
|
404
|
-
expect(
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
404
|
+
expect(result.transactions[0].details).not.toHaveProperty('contractInteraction')
|
|
405
|
+
})
|
|
406
|
+
|
|
407
|
+
it('adds the receipt gas price, the gas limit and the nonce to prefetched tx details', async () => {
|
|
408
|
+
const context = createMockEvmContext(
|
|
409
|
+
createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() })
|
|
410
|
+
)
|
|
411
|
+
|
|
412
|
+
mockGetBlockNodeApi(
|
|
413
|
+
mockNodeApi({
|
|
414
|
+
getBlockByHeight: jest.fn().mockResolvedValueOnce(
|
|
415
|
+
makeNodeBlock({
|
|
416
|
+
transactions: [
|
|
417
|
+
makeNodeBlockTx({
|
|
418
|
+
hash: '0xtx1',
|
|
419
|
+
gasPrice: '30000000000', // maxFeePerGas fallback of a type-2 tx: must NOT win
|
|
420
|
+
gasLimit: '73330',
|
|
421
|
+
nonce: 42,
|
|
422
|
+
}),
|
|
423
|
+
],
|
|
424
|
+
})
|
|
425
|
+
),
|
|
426
|
+
getBlockReceipts: jest
|
|
427
|
+
.fn()
|
|
428
|
+
.mockResolvedValueOnce([makeNodeBlockReceipt({ hash: '0xtx1', gasPrice: '1000000000' })]),
|
|
429
|
+
getTransaction: jest.fn(),
|
|
430
|
+
})
|
|
431
|
+
)
|
|
432
|
+
|
|
433
|
+
const result = await getBlock(context, 12345)
|
|
434
|
+
|
|
435
|
+
expect(result.transactions[0].details).toEqual({
|
|
436
|
+
gasPrice: '1000000000',
|
|
437
|
+
gasLimit: '73330',
|
|
438
|
+
sequence: 42,
|
|
439
|
+
})
|
|
440
|
+
})
|
|
441
|
+
|
|
442
|
+
it('adds the gas price, the gas limit and the nonce to contract details', async () => {
|
|
443
|
+
const context = createMockEvmContext(
|
|
444
|
+
createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() })
|
|
445
|
+
)
|
|
446
|
+
|
|
447
|
+
mockGetBlockNodeApi(
|
|
448
|
+
mockNodeApi({
|
|
449
|
+
getBlockByHeight: jest.fn().mockResolvedValueOnce(
|
|
450
|
+
makeNodeBlock({
|
|
451
|
+
transactions: [
|
|
452
|
+
makeNodeBlockTx({ hash: '0xtx1', input: '0xdeadbeef', gasLimit: '73330', nonce: 0 }),
|
|
453
|
+
],
|
|
454
|
+
})
|
|
455
|
+
),
|
|
456
|
+
getBlockReceipts: jest
|
|
457
|
+
.fn()
|
|
458
|
+
.mockResolvedValueOnce([makeNodeBlockReceipt({ hash: '0xtx1', gasPrice: '1000000000' })]),
|
|
459
|
+
getTransaction: jest.fn(),
|
|
460
|
+
})
|
|
461
|
+
)
|
|
462
|
+
|
|
463
|
+
const result = await getBlock(context, 12345)
|
|
464
|
+
|
|
465
|
+
expect(result.transactions[0].details).toEqual({
|
|
466
|
+
gasPrice: '1000000000',
|
|
467
|
+
gasLimit: '73330',
|
|
468
|
+
sequence: 0,
|
|
469
|
+
contractInteraction: 'SmartContractInteraction',
|
|
470
|
+
contractAddress: safeEncodeEIP55(address2, testLogger),
|
|
471
|
+
contractPayload: '0xdeadbeef',
|
|
472
|
+
})
|
|
473
|
+
})
|
|
474
|
+
|
|
475
|
+
it('omits the gas limit and the nonce when the prefetched tx does not report them', async () => {
|
|
476
|
+
const context = createMockEvmContext(
|
|
477
|
+
createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() })
|
|
478
|
+
)
|
|
479
|
+
|
|
480
|
+
mockGetBlockNodeApi(
|
|
481
|
+
mockNodeApi({
|
|
482
|
+
getBlockByHeight: jest
|
|
483
|
+
.fn()
|
|
484
|
+
.mockResolvedValueOnce(makeNodeBlock({ transactions: [makeNodeBlockTx()] })),
|
|
485
|
+
getBlockReceipts: jest.fn().mockResolvedValueOnce([makeNodeBlockReceipt()]),
|
|
486
|
+
getTransaction: jest.fn(),
|
|
487
|
+
})
|
|
488
|
+
)
|
|
489
|
+
|
|
490
|
+
const result = await getBlock(context, 12345)
|
|
491
|
+
|
|
492
|
+
expect(result.transactions[0].details).toEqual({ gasPrice: '20000000000' })
|
|
493
|
+
})
|
|
494
|
+
|
|
495
|
+
it('adds the gas price, the gas limit and the nonce when falling back to getTransaction', async () => {
|
|
496
|
+
const context = createMockEvmContext(
|
|
497
|
+
createMockEvmConfigInfo({ chainId: 1, node: mkExternalNode() })
|
|
498
|
+
)
|
|
499
|
+
|
|
500
|
+
mockGetBlockNodeApi(
|
|
501
|
+
mockNodeApi({
|
|
502
|
+
getBlockByHeight: jest
|
|
503
|
+
.fn()
|
|
504
|
+
.mockResolvedValueOnce(makeNodeBlock({ transactions: [makeNodeBlockTx()] })),
|
|
505
|
+
getBlockReceipts: jest.fn().mockRejectedValueOnce(
|
|
506
|
+
new UnsupportedRpcMethodError(
|
|
507
|
+
'eth_getBlockReceipts is not supported by this RPC provider',
|
|
508
|
+
{
|
|
509
|
+
method: 'eth_getBlockReceipts',
|
|
510
|
+
rawError: { code: -32601 },
|
|
511
|
+
}
|
|
512
|
+
)
|
|
513
|
+
),
|
|
514
|
+
getTransaction: jest
|
|
515
|
+
.fn()
|
|
516
|
+
.mockResolvedValueOnce(
|
|
517
|
+
makeNodeTxInfo({ gasPrice: '1000000000', gasLimit: '21000', nonce: 7 })
|
|
518
|
+
),
|
|
519
|
+
})
|
|
520
|
+
)
|
|
521
|
+
|
|
522
|
+
const result = await getBlock(context, 12345)
|
|
523
|
+
|
|
524
|
+
expect(result.transactions[0].details).toEqual({
|
|
525
|
+
gasPrice: '1000000000',
|
|
526
|
+
gasLimit: '21000',
|
|
527
|
+
sequence: 7,
|
|
528
|
+
})
|
|
408
529
|
})
|
|
409
530
|
|
|
410
531
|
it('adds contract details when falling back to getTransaction with non-trivial input', async () => {
|
|
@@ -442,7 +563,7 @@ describe('getBlock', () => {
|
|
|
442
563
|
})
|
|
443
564
|
)
|
|
444
565
|
|
|
445
|
-
const result = await getBlock(context,
|
|
566
|
+
const result = await getBlock(context, 12345)
|
|
446
567
|
|
|
447
568
|
expect(result.transactions[0]).toMatchObject({
|
|
448
569
|
hash: '0xtx1',
|
|
@@ -483,7 +604,7 @@ describe('getBlock', () => {
|
|
|
483
604
|
})
|
|
484
605
|
)
|
|
485
606
|
|
|
486
|
-
const result = await getBlock(context,
|
|
607
|
+
const result = await getBlock(context, 12345)
|
|
487
608
|
|
|
488
609
|
expect(result).toMatchObject({
|
|
489
610
|
info: {
|
|
@@ -518,7 +639,7 @@ describe('getBlock', () => {
|
|
|
518
639
|
})
|
|
519
640
|
)
|
|
520
641
|
|
|
521
|
-
const result = await getBlock(context,
|
|
642
|
+
const result = await getBlock(context, 12345)
|
|
522
643
|
|
|
523
644
|
expect(result).toMatchObject({
|
|
524
645
|
info: {
|
|
@@ -558,7 +679,7 @@ describe('getBlock', () => {
|
|
|
558
679
|
})
|
|
559
680
|
)
|
|
560
681
|
|
|
561
|
-
await expect(getBlock(context,
|
|
682
|
+
await expect(getBlock(context, 12345)).rejects.toThrow('timeout')
|
|
562
683
|
expect(mockGetTransaction).not.toHaveBeenCalled()
|
|
563
684
|
})
|
|
564
685
|
|
|
@@ -621,7 +742,7 @@ describe('getBlock', () => {
|
|
|
621
742
|
}),
|
|
622
743
|
])
|
|
623
744
|
|
|
624
|
-
const result = await getBlock(context,
|
|
745
|
+
const result = await getBlock(context, 12345)
|
|
625
746
|
|
|
626
747
|
const encodedFrom = safeEncodeEIP55(address1, testLogger)
|
|
627
748
|
const encodedTo = safeEncodeEIP55(address2, testLogger)
|
|
@@ -693,7 +814,7 @@ describe('getBlock', () => {
|
|
|
693
814
|
}),
|
|
694
815
|
])
|
|
695
816
|
|
|
696
|
-
const result = await getBlock(context,
|
|
817
|
+
const result = await getBlock(context, 12345)
|
|
697
818
|
|
|
698
819
|
// Only the two ops from the coin tx itself (sender + recipient side), no duplicates.
|
|
699
820
|
const nativeOps = result.transactions[0].operations.filter(
|
|
@@ -751,7 +872,7 @@ describe('getBlock', () => {
|
|
|
751
872
|
}),
|
|
752
873
|
])
|
|
753
874
|
|
|
754
|
-
const result = await getBlock(context,
|
|
875
|
+
const result = await getBlock(context, 12345)
|
|
755
876
|
|
|
756
877
|
const nativeOps = result.transactions[0].operations.filter(
|
|
757
878
|
(op) => op.type === 'transfer' && op.asset.type === 'native'
|
|
@@ -803,7 +924,7 @@ describe('getBlock', () => {
|
|
|
803
924
|
|
|
804
925
|
const mockGetInternalTransactionsByBlock = jest.mocked(getInternalTransactionsByBlock)
|
|
805
926
|
|
|
806
|
-
const result = await getBlock(context,
|
|
927
|
+
const result = await getBlock(context, 12345)
|
|
807
928
|
|
|
808
929
|
expect(mockGetInternalTransactionsByBlock).not.toHaveBeenCalled()
|
|
809
930
|
expect(mockTraceBlock).toHaveBeenCalledWith(12345)
|
|
@@ -864,7 +985,7 @@ describe('getBlock', () => {
|
|
|
864
985
|
)
|
|
865
986
|
const mockGetInternalTransactionsByBlock = jest.mocked(getInternalTransactionsByBlock)
|
|
866
987
|
|
|
867
|
-
await expect(getBlock(context,
|
|
988
|
+
await expect(getBlock(context, 12345)).rejects.toThrow(error)
|
|
868
989
|
|
|
869
990
|
expect(mockGetInternalTransactionsByBlock).not.toHaveBeenCalled()
|
|
870
991
|
expect(mockTraceBlock).toHaveBeenCalledWith(12345)
|
|
@@ -896,7 +1017,7 @@ describe('getBlock', () => {
|
|
|
896
1017
|
const mockGetInternalTransactionsByBlock = jest.mocked(getInternalTransactionsByBlock)
|
|
897
1018
|
mockGetInternalTransactionsByBlock.mockRejectedValueOnce(new Error('explorer error'))
|
|
898
1019
|
|
|
899
|
-
const result = await getBlock(context,
|
|
1020
|
+
const result = await getBlock(context, 12345)
|
|
900
1021
|
|
|
901
1022
|
expect(result).toMatchObject({
|
|
902
1023
|
info: {
|
|
@@ -945,7 +1066,7 @@ describe('getBlock', () => {
|
|
|
945
1066
|
const mockGetInternalTransactionsByBlock = jest.mocked(getInternalTransactionsByBlock)
|
|
946
1067
|
mockGetInternalTransactionsByBlock.mockRejectedValueOnce(new Error('explorer error'))
|
|
947
1068
|
|
|
948
|
-
const result = await getBlock(context,
|
|
1069
|
+
const result = await getBlock(context, 12345)
|
|
949
1070
|
|
|
950
1071
|
expect(mockTraceBlock).toHaveBeenCalledWith(12345)
|
|
951
1072
|
const encodedFrom = safeEncodeEIP55(address1, testLogger)
|
|
@@ -1015,7 +1136,7 @@ describe('getBlock', () => {
|
|
|
1015
1136
|
const mockGetInternalTransactionsByBlock = jest.mocked(getInternalTransactionsByBlock)
|
|
1016
1137
|
mockGetInternalTransactionsByBlock.mockRejectedValueOnce(new Error('explorer error'))
|
|
1017
1138
|
|
|
1018
|
-
await expect(getBlock(context,
|
|
1139
|
+
await expect(getBlock(context, 12345)).rejects.toThrow(error)
|
|
1019
1140
|
|
|
1020
1141
|
expect(mockGetInternalTransactionsByBlock).toHaveBeenCalledWith(expect.anything(), 12345)
|
|
1021
1142
|
expect(mockTraceBlock).toHaveBeenCalledWith(12345)
|
|
@@ -1060,7 +1181,7 @@ describe('getBlock', () => {
|
|
|
1060
1181
|
const mockGetInternalTransactionsByBlock = jest.mocked(getInternalTransactionsByBlock)
|
|
1061
1182
|
mockGetInternalTransactionsByBlock.mockRejectedValueOnce(new Error('explorer error'))
|
|
1062
1183
|
|
|
1063
|
-
await expect(getBlock(context,
|
|
1184
|
+
await expect(getBlock(context, 12345)).rejects.toMatchObject({
|
|
1064
1185
|
errors: [erigonError, gethError],
|
|
1065
1186
|
})
|
|
1066
1187
|
expect(mockTraceBlockErigon).toHaveBeenCalledWith(12345)
|
|
@@ -1102,7 +1223,7 @@ describe('getBlock', () => {
|
|
|
1102
1223
|
const mockGetInternalTransactionsByBlock = jest.mocked(getInternalTransactionsByBlock)
|
|
1103
1224
|
mockGetInternalTransactionsByBlock.mockRejectedValueOnce(new Error('explorer error'))
|
|
1104
1225
|
|
|
1105
|
-
const result = await getBlock(context,
|
|
1226
|
+
const result = await getBlock(context, 12345)
|
|
1106
1227
|
|
|
1107
1228
|
expect(mockTraceBlockErigon).toHaveBeenCalledWith(12345)
|
|
1108
1229
|
expect(mockTraceBlockGeth).toHaveBeenCalledWith(12345)
|
|
@@ -1161,7 +1282,7 @@ describe('getBlock', () => {
|
|
|
1161
1282
|
const mockGetInternalTransactionsByBlock = jest.mocked(getInternalTransactionsByBlock)
|
|
1162
1283
|
mockGetInternalTransactionsByBlock.mockRejectedValueOnce(new Error('explorer error'))
|
|
1163
1284
|
|
|
1164
|
-
await expect(getBlock(context,
|
|
1285
|
+
await expect(getBlock(context, 12345)).rejects.toThrow(erigonError)
|
|
1165
1286
|
expect(mockTraceBlockErigon).toHaveBeenCalledWith(12345)
|
|
1166
1287
|
})
|
|
1167
1288
|
|
|
@@ -1190,7 +1311,7 @@ describe('getBlock', () => {
|
|
|
1190
1311
|
getTransaction: jest.fn(),
|
|
1191
1312
|
})
|
|
1192
1313
|
)
|
|
1193
|
-
const result = await getBlock(context,
|
|
1314
|
+
const result = await getBlock(context, 12345)
|
|
1194
1315
|
expect(result.transactions[0].fees).toEqual(21000n * 568125000000n)
|
|
1195
1316
|
})
|
|
1196
1317
|
|
|
@@ -1220,7 +1341,7 @@ describe('getBlock', () => {
|
|
|
1220
1341
|
getTransaction: jest.fn(),
|
|
1221
1342
|
})
|
|
1222
1343
|
)
|
|
1223
|
-
const result = await getBlock(context,
|
|
1344
|
+
const result = await getBlock(context, 12345)
|
|
1224
1345
|
expect(result.transactions[0].fees).toEqual(21000n * 1000000000n)
|
|
1225
1346
|
})
|
|
1226
1347
|
|
|
@@ -1251,7 +1372,7 @@ describe('getBlock', () => {
|
|
|
1251
1372
|
getTransaction: jest.fn(),
|
|
1252
1373
|
})
|
|
1253
1374
|
)
|
|
1254
|
-
const result = await getBlock(context,
|
|
1375
|
+
const result = await getBlock(context, 12345)
|
|
1255
1376
|
expect(result.transactions[0].fees).toEqual(gasUsed * BigInt(gasPrice) + BigInt(l1Fee))
|
|
1256
1377
|
})
|
|
1257
1378
|
|
|
@@ -1273,7 +1394,7 @@ describe('getBlock', () => {
|
|
|
1273
1394
|
.mockResolvedValueOnce(makeNodeTxInfo({ hash: '0xtx1', gasUsed, gasPrice, l1Fee })),
|
|
1274
1395
|
})
|
|
1275
1396
|
)
|
|
1276
|
-
const result = await getBlock(context,
|
|
1397
|
+
const result = await getBlock(context, 12345)
|
|
1277
1398
|
expect(result.transactions[0].fees).toEqual(BigInt(gasUsed) * BigInt(gasPrice) + BigInt(l1Fee))
|
|
1278
1399
|
})
|
|
1279
1400
|
|
|
@@ -1281,7 +1402,6 @@ describe('getBlock', () => {
|
|
|
1281
1402
|
const USER = '0xbEB30f27e61eFFF46Aa27dcE18E23ee8D5A7c6a4'
|
|
1282
1403
|
const L2_BASE_TOKEN = '0x000000000000000000000000000000000000800A'
|
|
1283
1404
|
const MINT_PEER = '0x0000000000000000000000000000000000000000'
|
|
1284
|
-
const ZKSYNC = 'zksync'
|
|
1285
1405
|
|
|
1286
1406
|
function buildZksyncMocks(
|
|
1287
1407
|
txOverrides: Partial<PrefetchedBlockTransaction>,
|
|
@@ -1322,7 +1442,7 @@ describe('getBlock', () => {
|
|
|
1322
1442
|
],
|
|
1323
1443
|
}
|
|
1324
1444
|
)
|
|
1325
|
-
const result = await getBlock(context,
|
|
1445
|
+
const result = await getBlock(context, 12345)
|
|
1326
1446
|
expect(result.transactions[0].operations).toEqual([
|
|
1327
1447
|
{
|
|
1328
1448
|
type: 'transfer',
|
|
@@ -1360,7 +1480,7 @@ describe('getBlock', () => {
|
|
|
1360
1480
|
{ from: USER, to: USER, value: '270000000000000000' },
|
|
1361
1481
|
{ type: 2, erc20Transfers: [] }
|
|
1362
1482
|
)
|
|
1363
|
-
const result = await getBlock(context,
|
|
1483
|
+
const result = await getBlock(context, 12345)
|
|
1364
1484
|
expect(result.transactions[0].operations).toEqual([
|
|
1365
1485
|
{
|
|
1366
1486
|
type: 'transfer',
|
|
@@ -1402,7 +1522,7 @@ describe('getBlock', () => {
|
|
|
1402
1522
|
],
|
|
1403
1523
|
}
|
|
1404
1524
|
)
|
|
1405
|
-
const result = await getBlock(context,
|
|
1525
|
+
const result = await getBlock(context, 12345)
|
|
1406
1526
|
expect(result.transactions[0].operations).toEqual([
|
|
1407
1527
|
// native credit (synthesized, replaces the native self pair)
|
|
1408
1528
|
{
|
|
@@ -1443,7 +1563,7 @@ describe('getBlock', () => {
|
|
|
1443
1563
|
{ from: USER, to: USER, value: '270000000000000000' },
|
|
1444
1564
|
{ type: 0xff, erc20Transfers: [] }
|
|
1445
1565
|
)
|
|
1446
|
-
const result = await getBlock(context,
|
|
1566
|
+
const result = await getBlock(context, 12345)
|
|
1447
1567
|
expect(result.transactions[0].operations).toEqual([
|
|
1448
1568
|
{
|
|
1449
1569
|
type: 'transfer',
|
|
@@ -1471,7 +1591,7 @@ describe('getBlock', () => {
|
|
|
1471
1591
|
],
|
|
1472
1592
|
}
|
|
1473
1593
|
)
|
|
1474
|
-
const result = await getBlock(context,
|
|
1594
|
+
const result = await getBlock(context, 12345)
|
|
1475
1595
|
// Only the to-side (on user) remains; the from-side (on 0x0) is filtered out.
|
|
1476
1596
|
expect(result.transactions[0].operations).toEqual([
|
|
1477
1597
|
{
|
|
@@ -1500,7 +1620,7 @@ describe('getBlock', () => {
|
|
|
1500
1620
|
],
|
|
1501
1621
|
}
|
|
1502
1622
|
)
|
|
1503
|
-
const result = await getBlock(context,
|
|
1623
|
+
const result = await getBlock(context, 12345)
|
|
1504
1624
|
expect(result.transactions[0].operations).toEqual([
|
|
1505
1625
|
{
|
|
1506
1626
|
type: 'transfer',
|
|
@@ -1535,7 +1655,7 @@ describe('getBlock', () => {
|
|
|
1535
1655
|
],
|
|
1536
1656
|
}
|
|
1537
1657
|
)
|
|
1538
|
-
const result = await getBlock(context,
|
|
1658
|
+
const result = await getBlock(context, 12345)
|
|
1539
1659
|
expect(result.transactions[0].operations).toEqual([
|
|
1540
1660
|
{
|
|
1541
1661
|
type: 'transfer',
|
|
@@ -1570,7 +1690,7 @@ describe('getBlock', () => {
|
|
|
1570
1690
|
},
|
|
1571
1691
|
CHAIN_ID.ETHEREUM
|
|
1572
1692
|
)
|
|
1573
|
-
const result = await getBlock(context,
|
|
1693
|
+
const result = await getBlock(context, 12345)
|
|
1574
1694
|
expect(result.transactions[0].operations).toEqual([
|
|
1575
1695
|
{
|
|
1576
1696
|
type: 'transfer',
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import type { EvmConfigInfo } from '../../config'
|
|
5
5
|
import { createMockEvmContext, mkExternalNode, mkLedgerNode } from '../../fixtures/context.fixtures'
|
|
6
6
|
import { getNodeApi } from '../../network/node'
|
|
7
|
-
import { mockNodeApi } from '../../network/node/node.fixtures'
|
|
7
|
+
import { mockNodeApi } from '../../network/tests/node/node.fixtures'
|
|
8
8
|
import { getBlockInfo } from '../getBlockInfo'
|
|
9
9
|
|
|
10
10
|
jest.mock('../../network/node', () => ({
|
|
@@ -39,7 +39,7 @@ describe('getBlockInfo', () => {
|
|
|
39
39
|
parentHash: '0xparent123',
|
|
40
40
|
})
|
|
41
41
|
|
|
42
|
-
expect(await getBlockInfo(context,
|
|
42
|
+
expect(await getBlockInfo(context, 99999)).toEqual({
|
|
43
43
|
hash: '0xdef456',
|
|
44
44
|
height: 99999,
|
|
45
45
|
time: new Date('2025-02-20T15:45:00Z'),
|
|
@@ -58,7 +58,7 @@ describe('getBlockInfo', () => {
|
|
|
58
58
|
parentHash: '',
|
|
59
59
|
})
|
|
60
60
|
|
|
61
|
-
expect(await getBlockInfo(context,
|
|
61
|
+
expect(await getBlockInfo(context, 0)).toEqual({
|
|
62
62
|
hash: '0xgenesis',
|
|
63
63
|
height: 0,
|
|
64
64
|
time: new Date('2015-07-30T00:00:00Z'),
|
|
@@ -73,7 +73,7 @@ describe('getBlockInfo', () => {
|
|
|
73
73
|
parentHash: '0xgenesis',
|
|
74
74
|
})
|
|
75
75
|
|
|
76
|
-
const result = await getBlockInfo(context,
|
|
76
|
+
const result = await getBlockInfo(context, 1)
|
|
77
77
|
|
|
78
78
|
expect(result).toEqual({
|
|
79
79
|
hash: '0xblock1',
|
|
@@ -96,7 +96,7 @@ describe('getBlockInfo', () => {
|
|
|
96
96
|
parentHash: '0xparent',
|
|
97
97
|
})
|
|
98
98
|
|
|
99
|
-
const result = await getBlockInfo(context,
|
|
99
|
+
const result = await getBlockInfo(context, currentHeight)
|
|
100
100
|
|
|
101
101
|
expect(result.height).toBe(currentHeight)
|
|
102
102
|
expect(result.parent?.height).toBe(currentHeight - 1)
|
|
@@ -111,7 +111,7 @@ describe('getBlockInfo', () => {
|
|
|
111
111
|
parentHash: '0xparent',
|
|
112
112
|
})
|
|
113
113
|
|
|
114
|
-
const result = await getBlockInfo(context,
|
|
114
|
+
const result = await getBlockInfo(context, 100)
|
|
115
115
|
|
|
116
116
|
expect(result.time).toBeInstanceOf(Date)
|
|
117
117
|
expect(result.parent).toMatchObject({ height: 99, hash: '0xparent' })
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import type { EvmConfigInfo } from '../../config'
|
|
5
5
|
import { createMockEvmContext, mkExternalNode, mkLedgerNode } from '../../fixtures/context.fixtures'
|
|
6
6
|
import { getNodeApi } from '../../network/node'
|
|
7
|
-
import { mockNodeApi } from '../../network/node/node.fixtures'
|
|
7
|
+
import { mockNodeApi } from '../../network/tests/node/node.fixtures'
|
|
8
8
|
import { getNextSequence } from '../getNextSequence'
|
|
9
9
|
|
|
10
10
|
jest.mock('../../network/node', () => ({
|
|
@@ -32,6 +32,6 @@ describe('getNextSequence', () => {
|
|
|
32
32
|
const context = createMockEvmContext({ node })
|
|
33
33
|
nodeApiMock.getTransactionCount.mockResolvedValue(42)
|
|
34
34
|
|
|
35
|
-
expect(await getNextSequence(context, ''
|
|
35
|
+
expect(await getNextSequence(context, '')).toEqual(42n)
|
|
36
36
|
})
|
|
37
37
|
})
|