@ledgerhq/coin-evm 16.8.1 → 17.1.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.
Files changed (101) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/lib/adapters/etherscan.d.ts.map +1 -1
  3. package/lib/adapters/etherscan.js +5 -0
  4. package/lib/adapters/etherscan.js.map +1 -1
  5. package/lib/adapters/ledger.d.ts.map +1 -1
  6. package/lib/adapters/ledger.js +1 -0
  7. package/lib/adapters/ledger.js.map +1 -1
  8. package/lib/api/index.d.ts +2 -5
  9. package/lib/api/index.d.ts.map +1 -1
  10. package/lib/api/index.js +1 -2
  11. package/lib/api/index.js.map +1 -1
  12. package/lib/logic/cip64Fees.d.ts +25 -3
  13. package/lib/logic/cip64Fees.d.ts.map +1 -1
  14. package/lib/logic/cip64Fees.js +78 -24
  15. package/lib/logic/cip64Fees.js.map +1 -1
  16. package/lib/logic/feeCollectorOperations.d.ts +3 -3
  17. package/lib/logic/feeCollectorOperations.js +3 -3
  18. package/lib/logic/getBlock.d.ts +2 -2
  19. package/lib/logic/getBlock.d.ts.map +1 -1
  20. package/lib/logic/getBlock.js +5 -11
  21. package/lib/logic/getBlock.js.map +1 -1
  22. package/lib/logic/listOperations.d.ts.map +1 -1
  23. package/lib/logic/listOperations.js +21 -3
  24. package/lib/logic/listOperations.js.map +1 -1
  25. package/lib/logic/tokenFeeOperations.d.ts +61 -0
  26. package/lib/logic/tokenFeeOperations.d.ts.map +1 -0
  27. package/lib/logic/tokenFeeOperations.js +128 -0
  28. package/lib/logic/tokenFeeOperations.js.map +1 -0
  29. package/lib/network/node/rpc.common.d.ts.map +1 -1
  30. package/lib/network/node/rpc.common.js +18 -0
  31. package/lib/network/node/rpc.common.js.map +1 -1
  32. package/lib/network/node/types.d.ts +2 -0
  33. package/lib/network/node/types.d.ts.map +1 -1
  34. package/lib/network/node/types.js.map +1 -1
  35. package/lib/network/node/withNodeSources.d.ts.map +1 -1
  36. package/lib/network/node/withNodeSources.js +2 -0
  37. package/lib/network/node/withNodeSources.js.map +1 -1
  38. package/lib-es/adapters/etherscan.d.ts.map +1 -1
  39. package/lib-es/adapters/etherscan.js +5 -0
  40. package/lib-es/adapters/etherscan.js.map +1 -1
  41. package/lib-es/adapters/ledger.d.ts.map +1 -1
  42. package/lib-es/adapters/ledger.js +1 -0
  43. package/lib-es/adapters/ledger.js.map +1 -1
  44. package/lib-es/api/index.d.ts +2 -5
  45. package/lib-es/api/index.d.ts.map +1 -1
  46. package/lib-es/api/index.js +1 -2
  47. package/lib-es/api/index.js.map +1 -1
  48. package/lib-es/logic/cip64Fees.d.ts +25 -3
  49. package/lib-es/logic/cip64Fees.d.ts.map +1 -1
  50. package/lib-es/logic/cip64Fees.js +77 -24
  51. package/lib-es/logic/cip64Fees.js.map +1 -1
  52. package/lib-es/logic/feeCollectorOperations.d.ts +3 -3
  53. package/lib-es/logic/feeCollectorOperations.js +3 -3
  54. package/lib-es/logic/getBlock.d.ts +2 -2
  55. package/lib-es/logic/getBlock.d.ts.map +1 -1
  56. package/lib-es/logic/getBlock.js +5 -11
  57. package/lib-es/logic/getBlock.js.map +1 -1
  58. package/lib-es/logic/listOperations.d.ts.map +1 -1
  59. package/lib-es/logic/listOperations.js +21 -3
  60. package/lib-es/logic/listOperations.js.map +1 -1
  61. package/lib-es/logic/tokenFeeOperations.d.ts +61 -0
  62. package/lib-es/logic/tokenFeeOperations.d.ts.map +1 -0
  63. package/lib-es/logic/tokenFeeOperations.js +122 -0
  64. package/lib-es/logic/tokenFeeOperations.js.map +1 -0
  65. package/lib-es/network/node/rpc.common.d.ts.map +1 -1
  66. package/lib-es/network/node/rpc.common.js +18 -0
  67. package/lib-es/network/node/rpc.common.js.map +1 -1
  68. package/lib-es/network/node/types.d.ts +2 -0
  69. package/lib-es/network/node/types.d.ts.map +1 -1
  70. package/lib-es/network/node/types.js.map +1 -1
  71. package/lib-es/network/node/withNodeSources.d.ts.map +1 -1
  72. package/lib-es/network/node/withNodeSources.js +2 -0
  73. package/lib-es/network/node/withNodeSources.js.map +1 -1
  74. package/package.json +2 -2
  75. package/src/adapters/blockscoutV2.test.ts +2 -0
  76. package/src/adapters/etherscan.test.ts +21 -0
  77. package/src/adapters/etherscan.ts +5 -0
  78. package/src/adapters/ledger.test.ts +8 -0
  79. package/src/adapters/ledger.ts +1 -0
  80. package/src/api/index.ts +1 -4
  81. package/src/api/tests/index.celo.integ.test.ts +144 -3
  82. package/src/api/tests/index.optimism.integ.test.ts +1 -0
  83. package/src/api/tests/index.test.ts +0 -9
  84. package/src/logic/cip64Fees.ts +99 -26
  85. package/src/logic/feeCollectorOperations.ts +3 -3
  86. package/src/logic/getBlock.ts +6 -17
  87. package/src/logic/listOperations.ts +32 -2
  88. package/src/logic/tests/cip64Fees.test.ts +128 -4
  89. package/src/logic/tests/getBlock.test.ts +10 -23
  90. package/src/logic/tests/listOperations.test.ts +522 -2
  91. package/src/logic/tests/validateIntent.test.ts +4 -0
  92. package/src/logic/tokenFeeOperations.ts +169 -0
  93. package/src/network/node/rpc.common.ts +19 -0
  94. package/src/network/node/types.ts +2 -0
  95. package/src/network/node/withNodeSources.ts +3 -0
  96. package/src/network/tests/explorer/etherscan.test.ts +1 -0
  97. package/src/network/tests/explorer/ledger.test.ts +4 -0
  98. package/src/network/tests/node/rpc.test.ts +36 -0
  99. package/src/network/tests/node/withNodeSources.test.ts +17 -0
  100. package/src/staking/rewardsFromReceipt.test.ts +1 -0
  101. package/src/staking/validators/monad.test.ts +1 -0
@@ -2,6 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import type { EvmContext } from '../config'
5
+ import type { TransactionTokenFee } from './tokenFeeOperations'
5
6
  import type {
6
7
  Page,
7
8
  MemoNotSupported,
@@ -9,11 +10,13 @@ import type {
9
10
  ListOperationsOptions,
10
11
  } from '@ledgerhq/coin-module-framework/api/types'
11
12
  import { InvalidParameterError } from '@ledgerhq/coin-module-framework/errors'
13
+ import { CHAIN_ID } from '../config'
12
14
  import { getExplorerApi } from '../network/explorer'
13
15
  import {
14
16
  attributeFeeCollectorPayments,
15
17
  findTransactionsPaidByOthers,
16
18
  } from './feeCollectorOperations'
19
+ import { readCeloTokenFees, removeFeeTransfers, withTokenFee } from './tokenFeeOperations'
17
20
 
18
21
  // the sort parameter has a double meaning:
19
22
  // - legacy (for the bridge): it's used to sort the operations in the result list. Explorer always queried in "desc" order.
@@ -67,7 +70,7 @@ export async function listOperations(
67
70
  const explorerOrder = options.limit === undefined ? 'desc' : (options.order ?? 'desc')
68
71
  const {
69
72
  lastCoinOperations,
70
- lastTokenOperations,
73
+ lastTokenOperations: explorerTokenOperations,
71
74
  lastNftOperations,
72
75
  lastInternalOperations,
73
76
  nextPagingToken,
@@ -82,6 +85,31 @@ export async function listOperations(
82
85
  explorerOrder
83
86
  )
84
87
 
88
+ const addressLower = address.toLowerCase()
89
+
90
+ // A Celo CIP-64 transaction can pay its fee in a token. The fee transfers are removed before the
91
+ // parent suppression below, so that the native operation stays as the fee carrier.
92
+ const tokenFees =
93
+ config.chainId === CHAIN_ID.CELO
94
+ ? await readCeloTokenFees(
95
+ config,
96
+ context.logger,
97
+ address,
98
+ [
99
+ ...lastCoinOperations,
100
+ ...explorerTokenOperations,
101
+ ...lastNftOperations,
102
+ ...lastInternalOperations,
103
+ ].map((op) => op.tx.hash),
104
+ new Set(
105
+ lastCoinOperations
106
+ .filter((op) => op.senders.some((sender) => sender.toLowerCase() === addressLower))
107
+ .map((op) => op.tx.hash.toLowerCase())
108
+ )
109
+ )
110
+ : new Map<string, TransactionTokenFee>()
111
+ const lastTokenOperations = removeFeeTransfers(explorerTokenOperations, tokenFees)
112
+
85
113
  const tokenOrNftHashes = new Set(
86
114
  [...lastTokenOperations, ...lastNftOperations].map((op) => op.tx.hash)
87
115
  )
@@ -91,7 +119,6 @@ export async function listOperations(
91
119
  )
92
120
  )
93
121
 
94
- const addressLower = address.toLowerCase()
95
122
  const isAddressInOp = (op: Operation<MemoNotSupported>): boolean =>
96
123
  op.senders.some((s) => s.toLowerCase() === addressLower) ||
97
124
  op.recipients.some((r) => r.toLowerCase() === addressLower)
@@ -143,6 +170,7 @@ export async function listOperations(
143
170
  ...op.tx,
144
171
  block: { ...op.tx.block, hash: op.tx.block.hash || parent.tx.block.hash },
145
172
  fees: parent.tx.fees,
173
+ ...(parent.tx.feesAsset ? { feesAsset: parent.tx.feesAsset } : {}),
146
174
  failed: parent.tx.failed,
147
175
  ...(parent.tx.feesPayer ? { feesPayer: parent.tx.feesPayer } : {}),
148
176
  },
@@ -192,6 +220,7 @@ export async function listOperations(
192
220
  ...op.tx,
193
221
  block: { ...op.tx.block, hash: parent.tx.block.hash },
194
222
  fees: parent.tx.fees,
223
+ ...(parent.tx.feesAsset ? { feesAsset: parent.tx.feesAsset } : {}),
195
224
  ...(parent.tx.feesPayer ? { feesPayer: parent.tx.feesPayer } : {}),
196
225
  },
197
226
  }
@@ -286,6 +315,7 @@ export async function listOperations(
286
315
  .concat(internalOperations)
287
316
  .filter(hasValidType)
288
317
  .filter(isAddressInvolved)
318
+ .map((op) => withTokenFee(op, tokenFees))
289
319
  const feeEvidence = [...lastTokenOperations, ...lastNftOperations, ...lastInternalOperations]
290
320
  const operations = attributeFeeCollectorPayments(
291
321
  accountOperations,
@@ -8,7 +8,7 @@ import {
8
8
  UnsupportedFeeCurrencyError,
9
9
  } from '../../errors'
10
10
  import { mockNodeApi } from '../../network/tests/node/node.fixtures'
11
- import { createCeloTokenFeeReader, splitTokenFee } from '../cip64Fees'
11
+ import { createCeloTokenFeeReader, readCeloTransactionFee, splitTokenFee } from '../cip64Fees'
12
12
 
13
13
  const USDT = '0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e'
14
14
  const USDT_ADAPTER = '0x0E2A3e05bc9A16F5292A6170456A710cb89C6f72'
@@ -17,6 +17,9 @@ const USDC = '0xcebA9300f2b948710d2653dD7B07f33A8B32118C'
17
17
  const USDC_ADAPTER = '0x2F25deB3848C207fc8E0c34035B3Ba7fC157602B'
18
18
  const CUSD = '0x765DE816845861e75A25fCA122bb6898B8B1282a'
19
19
  const CEUR = '0xD8763CBa276a3738E6DE85b4b3bF5FDed6D6cA73'
20
+ const KESM = '0x456a3D042C0DbD3db53D5489e98dFb038553B0d0'
21
+ const USAT = '0xD2ab3C9A02DBBAB236BfEC45D1d755DF4267F771'
22
+ const USAT_ADAPTER = '0x0357EE22278c922e1D36cFe6b899269b161880C4'
20
23
  const ZERO = '0x0000000000000000000000000000000000000000'
21
24
  const SEQUENCER_VAULT = '0x4200000000000000000000000000000000000011'
22
25
  const FEE_HANDLER = '0xcD437749E43A154C07F3553504c68fBfD56B8778'
@@ -58,6 +61,7 @@ describe('splitTokenFee', () => {
58
61
  expect(splitTokenFee(USDT_ADAPTER, PAYER, [usdtDebit, userTransfer, ...usdtCredits])).toEqual({
59
62
  fees: 3176n,
60
63
  feesAsset: { type: 'erc20', assetReference: USDT },
64
+ feeTransfers: [usdtDebit, ...usdtCredits],
61
65
  transfers: [userTransfer],
62
66
  })
63
67
  })
@@ -66,6 +70,7 @@ describe('splitTokenFee', () => {
66
70
  expect(splitTokenFee(USDC_ADAPTER, PAYER, [usdcDebit, userTransfer, ...usdcCredits])).toEqual({
67
71
  fees: 4072n,
68
72
  feesAsset: { type: 'erc20', assetReference: USDC },
73
+ feeTransfers: [usdcDebit, ...usdcCredits],
69
74
  transfers: [userTransfer],
70
75
  })
71
76
  })
@@ -74,6 +79,7 @@ describe('splitTokenFee', () => {
74
79
  expect(splitTokenFee(CUSD, PAYER, [cusdDebit, ...cusdCredits])).toEqual({
75
80
  fees: 12404402010n + 2255345820000000n,
76
81
  feesAsset: { type: 'erc20', assetReference: CUSD },
82
+ feeTransfers: [cusdDebit, ...cusdCredits],
77
83
  transfers: [],
78
84
  })
79
85
  })
@@ -90,6 +96,7 @@ describe('splitTokenFee', () => {
90
96
  expect(splitTokenFee(CEUR, PAYER, transfers)).toEqual({
91
97
  fees: 2623801530470940n,
92
98
  feesAsset: { type: 'erc20', assetReference: CEUR },
99
+ feeTransfers: transfers,
93
100
  transfers: [],
94
101
  })
95
102
  })
@@ -106,6 +113,7 @@ describe('splitTokenFee', () => {
106
113
  expect(splitTokenFee(USDT_ADAPTER, PAYER, transfers)).toEqual({
107
114
  fees: 2816n,
108
115
  feesAsset: { type: 'erc20', assetReference: USDT },
116
+ feeTransfers: transfers,
109
117
  transfers: [],
110
118
  })
111
119
  })
@@ -154,9 +162,63 @@ describe('splitTokenFee', () => {
154
162
  ).toBe(3176n)
155
163
  })
156
164
 
157
- it('rejects an unsupported fee currency', () => {
158
- expect(() => splitTokenFee(OTHER, PAYER, [usdtDebit, ...usdtCredits])).toThrow(
159
- UnsupportedFeeCurrencyError
165
+ it.each([
166
+ {
167
+ // Fee logs of tx 0x437cfcbf162770f8586be4e263383653e0ccac33949d4fe1fc04e628b208ef80
168
+ name: 'USAT, through a holder',
169
+ feeCurrency: USAT_ADAPTER,
170
+ token: USAT,
171
+ transfers: [
172
+ transfer(USAT, PAYER, USDT_HOLDER, 2032n),
173
+ transfer(USAT, USDT_HOLDER, SEQUENCER_VAULT, 0n),
174
+ transfer(USAT, USDT_HOLDER, FEE_HANDLER, 1601n),
175
+ transfer(USAT, USDT_HOLDER, PAYER, 431n),
176
+ ],
177
+ fees: 1601n,
178
+ },
179
+ {
180
+ // Fee logs of tx 0x0cc6b0258288a498b7836808f107af9591b27c8b05f28ded56c2960a1e254074
181
+ name: 'KESm, from the burn, the re-mint and the payments',
182
+ feeCurrency: KESM,
183
+ token: KESM,
184
+ transfers: [
185
+ transfer(KESM, PAYER, ZERO, 157008136848681234n),
186
+ transfer(KESM, ZERO, PAYER, 157008136848681234n),
187
+ transfer(KESM, PAYER, SEQUENCER_VAULT, 742929512920n),
188
+ transfer(KESM, PAYER, FEE_HANDLER, 148585907422703224n),
189
+ ],
190
+ fees: 148586650352216144n,
191
+ },
192
+ {
193
+ // Fee logs of tx 0x870ee46734ffd61acb692f6b2c338c791178aa3ea82e0334136840ec4696e49d
194
+ name: 'cUSD, from before cUSD minted its credits',
195
+ feeCurrency: CUSD,
196
+ token: CUSD,
197
+ transfers: [
198
+ transfer(CUSD, PAYER, ZERO, 775085251046848n),
199
+ transfer(CUSD, ZERO, PAYER, 775085251046848n),
200
+ transfer(CUSD, PAYER, SEQUENCER_VAULT, 26611431540n),
201
+ transfer(CUSD, PAYER, FEE_HANDLER, 604807385242500n),
202
+ ],
203
+ fees: 604833996674040n,
204
+ },
205
+ ])('reads a $name fee', ({ feeCurrency, token, transfers, fees }) => {
206
+ expect(splitTokenFee(feeCurrency, PAYER, transfers)).toEqual({
207
+ fees,
208
+ feesAsset: { type: 'erc20', assetReference: token },
209
+ feeTransfers: transfers,
210
+ transfers: [],
211
+ })
212
+ })
213
+
214
+ it('rejects an unsupported fee currency, with the transaction in the error', () => {
215
+ expect(() => splitTokenFee(OTHER, PAYER, [usdtDebit, ...usdtCredits], '0xabc')).toThrow(
216
+ expect.objectContaining({
217
+ name: UnsupportedFeeCurrencyError.name,
218
+ feeCurrency: OTHER,
219
+ payer: PAYER,
220
+ hash: '0xabc',
221
+ })
160
222
  )
161
223
  })
162
224
 
@@ -275,3 +337,65 @@ describe('createCeloTokenFeeReader', () => {
275
337
  )
276
338
  })
277
339
  })
340
+
341
+ function nodeWithFeeCurrency(feeCurrency: string | null): NodeApi {
342
+ return mockNodeApi({ getFeeCurrency: jest.fn().mockResolvedValue(feeCurrency) })
343
+ }
344
+
345
+ describe('readCeloTransactionFee', () => {
346
+ const cip64Tx = {
347
+ hash: '0xabc',
348
+ from: PAYER,
349
+ type: 0x7b,
350
+ erc20Transfers: [usdtDebit, ...usdtCredits],
351
+ }
352
+
353
+ it('reads a native fee for a transaction that is not CIP-64', async () => {
354
+ const nodeApi = nodeWithFeeCurrency(USDT_ADAPTER)
355
+
356
+ await expect(readCeloTransactionFee(nodeApi, { ...cip64Tx, type: 2 })).resolves.toEqual({
357
+ kind: 'native',
358
+ })
359
+ expect(nodeApi.getFeeCurrency).not.toHaveBeenCalled()
360
+ })
361
+
362
+ it('reads a native fee for a CIP-64 transaction that pays in the native coin', async () => {
363
+ await expect(readCeloTransactionFee(nodeWithFeeCurrency(null), cip64Tx)).resolves.toEqual({
364
+ kind: 'native',
365
+ })
366
+ })
367
+
368
+ it('reads the token fee of a transaction, also when its receipt has no type', async () => {
369
+ const nodeApi = nodeWithFeeCurrency(USDT_ADAPTER)
370
+
371
+ await expect(
372
+ readCeloTransactionFee(nodeApi, { ...cip64Tx, type: undefined })
373
+ ).resolves.toMatchObject({
374
+ kind: 'token',
375
+ tokenFee: { fees: 3176n, feesAsset: { type: 'erc20', assetReference: USDT } },
376
+ })
377
+ expect(nodeApi.getFeeCurrency).toHaveBeenCalledWith('0xabc')
378
+ })
379
+
380
+ it('reports a fee currency whose fee logs are not known', async () => {
381
+ await expect(readCeloTransactionFee(nodeWithFeeCurrency(OTHER), cip64Tx)).resolves.toEqual({
382
+ kind: 'unsupported',
383
+ feeCurrency: OTHER,
384
+ })
385
+ })
386
+
387
+ it('rejects fee logs that do not match a supported fee currency', async () => {
388
+ await expect(
389
+ readCeloTransactionFee(nodeWithFeeCurrency(USDT_ADAPTER), {
390
+ ...cip64Tx,
391
+ erc20Transfers: usdtCredits,
392
+ })
393
+ ).rejects.toThrow(expect.objectContaining({ name: UnexpectedFeeLogsError.name, hash: '0xabc' }))
394
+ })
395
+
396
+ it('rejects a CIP-64 transaction when the node cannot report its fee currency', async () => {
397
+ await expect(readCeloTransactionFee(mockNodeApi(), cip64Tx)).rejects.toThrow(
398
+ FeeCurrencyUnavailableError
399
+ )
400
+ })
401
+ })
@@ -1336,7 +1336,7 @@ describe('getBlock', () => {
1336
1336
  expect(userNativeDelta(tx.operations)).toBe(-PREPAYMENT)
1337
1337
  })
1338
1338
 
1339
- it('drops the base-token fee legs too when the caller asks for the fee asset', async () => {
1339
+ it('drops the base-token fee legs when the network lists the base token', async () => {
1340
1340
  const otherTransfer = makeNodeErc20Transfer({
1341
1341
  asset: { type: 'erc20', assetReference: L2_BASE_TOKEN },
1342
1342
  from: USER,
@@ -1359,7 +1359,7 @@ describe('getBlock', () => {
1359
1359
  }),
1360
1360
  ])
1361
1361
 
1362
- const [tx] = (await getBlock(context, 12345, { feesAsset: true })).transactions
1362
+ const [tx] = (await getBlock(context, 12345)).transactions
1363
1363
 
1364
1364
  expect(tx.operations).toEqual([
1365
1365
  {
@@ -1379,7 +1379,7 @@ describe('getBlock', () => {
1379
1379
  ])
1380
1380
  expect(tx.fees).toBe(FEE)
1381
1381
  expect(tx.feesPayer).toBe(USER)
1382
- expect(tx).not.toHaveProperty('feesAsset')
1382
+ expect(tx.feesAsset).toEqual({ type: 'native' })
1383
1383
  })
1384
1384
 
1385
1385
  it.each([
@@ -1433,7 +1433,7 @@ describe('getBlock', () => {
1433
1433
  })
1434
1434
  )
1435
1435
 
1436
- const [tx] = (await getBlock(context, 12345, { feesAsset: true })).transactions
1436
+ const [tx] = (await getBlock(context, 12345)).transactions
1437
1437
 
1438
1438
  expect(tx.feesPayer).toBe(PAYMASTER)
1439
1439
  expect(tx.operations).toEqual([])
@@ -2393,7 +2393,7 @@ describe('getBlock', () => {
2393
2393
  async (_, prefetched, receiptType) => {
2394
2394
  const { context, nodeApi } = mockCeloBlock({ prefetched, receiptType })
2395
2395
 
2396
- const [tx] = (await getBlock(context, 12345, { feesAsset: true })).transactions
2396
+ const [tx] = (await getBlock(context, 12345)).transactions
2397
2397
 
2398
2398
  expect(tx.fees).toBe(3176n)
2399
2399
  expect(tx.feesAsset).toEqual({ type: 'erc20', assetReference: USDT })
@@ -2403,43 +2403,30 @@ describe('getBlock', () => {
2403
2403
  }
2404
2404
  )
2405
2405
 
2406
- it('keeps the native fee and the fee logs when the caller does not ask for the fee asset', async () => {
2407
- const { context, nodeApi } = mockCeloBlock()
2408
-
2409
- const [tx] = (await getBlock(context, 12345)).transactions
2410
-
2411
- expect(tx.fees).toBe(NATIVE_FEES)
2412
- expect(tx).not.toHaveProperty('feesAsset')
2413
- expect(tx.operations).toHaveLength(transfers.length * 2)
2414
- expect(nodeApi.getFeeCurrencies).not.toHaveBeenCalled()
2415
- })
2416
-
2417
2406
  it('keeps the native fee of a CIP-64 transaction that pays in the native coin', async () => {
2418
2407
  const { context } = mockCeloBlock({ feeCurrency: null })
2419
2408
 
2420
- const [tx] = (await getBlock(context, 12345, { feesAsset: true })).transactions
2409
+ const [tx] = (await getBlock(context, 12345)).transactions
2421
2410
 
2422
2411
  expect(tx.fees).toBe(NATIVE_FEES)
2423
- expect(tx).not.toHaveProperty('feesAsset')
2412
+ expect(tx.feesAsset).toEqual({ type: 'native' })
2424
2413
  expect(tx.operations).toHaveLength(transfers.length * 2)
2425
2414
  })
2426
2415
 
2427
2416
  it('does not read fee currencies on another chain', async () => {
2428
2417
  const { context, nodeApi } = mockCeloBlock({ chainId: CHAIN_ID.ETHEREUM })
2429
2418
 
2430
- const [tx] = (await getBlock(context, 12345, { feesAsset: true })).transactions
2419
+ const [tx] = (await getBlock(context, 12345)).transactions
2431
2420
 
2432
2421
  expect(tx.fees).toBe(NATIVE_FEES)
2433
- expect(tx).not.toHaveProperty('feesAsset')
2422
+ expect(tx.feesAsset).toEqual({ type: 'native' })
2434
2423
  expect(nodeApi.getFeeCurrencies).not.toHaveBeenCalled()
2435
2424
  })
2436
2425
 
2437
2426
  it('rejects a block with a transaction paid in an unsupported fee currency', async () => {
2438
2427
  const { context } = mockCeloBlock({ feeCurrency: address2 })
2439
2428
 
2440
- await expect(getBlock(context, 12345, { feesAsset: true })).rejects.toThrow(
2441
- UnsupportedFeeCurrencyError
2442
- )
2429
+ await expect(getBlock(context, 12345)).rejects.toThrow(UnsupportedFeeCurrencyError)
2443
2430
  })
2444
2431
  })
2445
2432
  })