@ledgerhq/coin-tezos 10.2.0 → 10.2.2

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 (79) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/lib/api/index.d.ts +1 -1
  3. package/lib/api/index.d.ts.map +1 -1
  4. package/lib/api/index.js +1 -1
  5. package/lib/api/index.js.map +1 -1
  6. package/lib/logic/craftRawOperations.js +26 -17
  7. package/lib/logic/craftRawOperations.js.map +1 -1
  8. package/lib/logic/estimateFees.js +4 -4
  9. package/lib/logic/estimateFees.js.map +1 -1
  10. package/lib/logic/listOperations.d.ts.map +1 -1
  11. package/lib/logic/listOperations.js +9 -7
  12. package/lib/logic/listOperations.js.map +1 -1
  13. package/lib/logic/validateIntent.d.ts.map +1 -1
  14. package/lib/logic/validateIntent.js +26 -8
  15. package/lib/logic/validateIntent.js.map +1 -1
  16. package/lib/network/tzkt.js +1 -1
  17. package/lib/network/tzkt.js.map +1 -1
  18. package/lib/test/config.d.ts +2 -22
  19. package/lib/test/config.d.ts.map +1 -1
  20. package/lib/test/config.js.map +1 -1
  21. package/lib/utils.d.ts +0 -3
  22. package/lib/utils.d.ts.map +1 -1
  23. package/lib/utils.js +17 -3
  24. package/lib/utils.js.map +1 -1
  25. package/lib-es/api/index.d.ts +1 -1
  26. package/lib-es/api/index.d.ts.map +1 -1
  27. package/lib-es/api/index.js +1 -1
  28. package/lib-es/api/index.js.map +1 -1
  29. package/lib-es/logic/craftRawOperations.js +26 -17
  30. package/lib-es/logic/craftRawOperations.js.map +1 -1
  31. package/lib-es/logic/estimateFees.js +4 -4
  32. package/lib-es/logic/estimateFees.js.map +1 -1
  33. package/lib-es/logic/listOperations.d.ts.map +1 -1
  34. package/lib-es/logic/listOperations.js +9 -7
  35. package/lib-es/logic/listOperations.js.map +1 -1
  36. package/lib-es/logic/validateIntent.d.ts.map +1 -1
  37. package/lib-es/logic/validateIntent.js +27 -9
  38. package/lib-es/logic/validateIntent.js.map +1 -1
  39. package/lib-es/network/tzkt.js +1 -1
  40. package/lib-es/network/tzkt.js.map +1 -1
  41. package/lib-es/test/config.d.ts +2 -22
  42. package/lib-es/test/config.d.ts.map +1 -1
  43. package/lib-es/test/config.js.map +1 -1
  44. package/lib-es/utils.d.ts +0 -3
  45. package/lib-es/utils.d.ts.map +1 -1
  46. package/lib-es/utils.js +17 -3
  47. package/lib-es/utils.js.map +1 -1
  48. package/package.json +2 -2
  49. package/src/api/index-mainnet.integ.test.ts +40 -50
  50. package/src/api/index.integ.test.ts +60 -45
  51. package/src/api/index.test.ts +229 -180
  52. package/src/api/index.ts +5 -4
  53. package/src/logic/broadcast.integ.test.ts +2 -7
  54. package/src/logic/craftRawOperations.test.ts +11 -10
  55. package/src/logic/craftRawOperations.ts +35 -19
  56. package/src/logic/craftTransaction.integ.test.ts +2 -2
  57. package/src/logic/craftTransaction.test.ts +63 -95
  58. package/src/logic/estimateFees.integ.test.ts +19 -20
  59. package/src/logic/estimateFees.test.ts +30 -63
  60. package/src/logic/estimateFees.ts +4 -4
  61. package/src/logic/getBalance.test.ts +6 -6
  62. package/src/logic/getBlock.integ.test.ts +20 -21
  63. package/src/logic/getBlock.test.ts +44 -51
  64. package/src/logic/getBlockInfo.integ.test.ts +13 -14
  65. package/src/logic/getBlockInfo.test.ts +8 -7
  66. package/src/logic/getStakes.test.ts +17 -17
  67. package/src/logic/listOperations.integ.test.ts +40 -37
  68. package/src/logic/listOperations.test.ts +34 -31
  69. package/src/logic/listOperations.ts +19 -19
  70. package/src/logic/validateIntent.test.ts +145 -20
  71. package/src/logic/validateIntent.ts +32 -8
  72. package/src/network/bakers.integ.test.ts +1 -1
  73. package/src/network/bakers.test.ts +7 -15
  74. package/src/network/tzkt.integ.test.ts +13 -14
  75. package/src/network/tzkt.test.ts +194 -259
  76. package/src/network/tzkt.ts +1 -1
  77. package/src/test/config.ts +3 -1
  78. package/src/utils.ts +18 -3
  79. package/.oxlintrc.json +0 -20
@@ -1,22 +1,13 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import type { TezosCoinConfig, TezosConfig, TezosContext } from '../config'
5
- import type { SendTransactionIntent } from '@ledgerhq/coin-module-framework/api/types'
4
+ import type { TezosContext } from '../config'
5
+ import { createSendTransactionIntentMockData } from '@ledgerhq/coin-module-framework/test-utils'
6
6
  import { localForger } from '@taquito/local-forging'
7
7
  import { createApi } from '.'
8
8
 
9
- const defaultConfig: TezosConfig = {
10
- baker: { url: 'https://baker.example.com' },
11
- explorer: { url: 'https://api.shadownet.tzkt.io', maxTxQuery: 100 },
12
- node: { url: 'https://rpc.shadownet.teztnets.com' },
13
- fees: {
14
- minGasLimit: 600,
15
- minRevealGasLimit: 300,
16
- minStorageLimit: 0,
17
- minFees: 500,
18
- minEstimatedFees: 500,
19
- },
9
+ function assertHasFee(op: object): asserts op is { fee: string } {
10
+ if (!('fee' in op)) fail('expected fee field on op')
20
11
  }
21
12
 
22
13
  /**
@@ -27,7 +18,19 @@ const defaultConfig: TezosConfig = {
27
18
  describe('Tezos Api', () => {
28
19
  const module = createApi()
29
20
  const context: TezosContext = {
30
- config: async () => defaultConfig as TezosCoinConfig,
21
+ config: async () => ({
22
+ status: { type: 'active' },
23
+ baker: { url: 'https://baker.example.com' },
24
+ explorer: { url: 'https://api.shadownet.tzkt.io', maxTxQuery: 100 },
25
+ node: { url: 'https://rpc.shadownet.teztnets.com' },
26
+ fees: {
27
+ minGasLimit: 600,
28
+ minRevealGasLimit: 300,
29
+ minStorageLimit: 0,
30
+ minFees: 500,
31
+ minEstimatedFees: 500,
32
+ },
33
+ }),
31
34
  logger: () => undefined,
32
35
  }
33
36
  // Persistent Shadownet test account — see LIVE-28763 PR for chain-of-custody.
@@ -78,15 +81,16 @@ describe('Tezos Api', () => {
78
81
  'p2pk66gP3wq6k9QgNwAgaGLeXc3YFfrxgYdC7cdYuJWAHYBw4hExVHW',
79
82
  ],
80
83
  ])('does not fail when providing a %s sender with pub key', async (_, sender, pubKey) => {
81
- const result = await module.estimateFees(context, {
82
- intentType: 'transaction',
83
- asset: { type: 'native' },
84
- type: 'send',
85
- sender,
86
- senderPublicKey: pubKey,
87
- recipient: address,
88
- amount: BigInt(100),
89
- } as SendTransactionIntent)
84
+ const result = await module.estimateFees(
85
+ context,
86
+ createSendTransactionIntentMockData({
87
+ type: 'send',
88
+ sender,
89
+ senderPublicKey: pubKey,
90
+ recipient: address,
91
+ amount: BigInt(100),
92
+ })
93
+ )
90
94
 
91
95
  expect(result.value).toBeGreaterThanOrEqual(BigInt(0))
92
96
  expect(result.parameters?.gasLimit).toBeGreaterThanOrEqual(BigInt(0))
@@ -214,14 +218,17 @@ describe('Tezos Api', () => {
214
218
  expect(decodedTransaction.contents).toHaveLength(1)
215
219
 
216
220
  const operationContent = decodedTransaction.contents[0]
217
- expect(operationContent.source).toEqual(address)
218
- expect(BigInt(operationContent.fee)).toBeGreaterThan(0)
221
+ expect(operationContent).toMatchObject({ source: address })
222
+ assertHasFee(operationContent)
223
+ expect(BigInt(String(operationContent.fee))).toBeGreaterThan(0)
219
224
 
220
225
  if (type === 'send') {
221
- expect(BigInt(operationContent.amount)).toEqual(amount)
222
- expect(operationContent.destination).toEqual(recipient)
226
+ expect(operationContent).toMatchObject({
227
+ destination: recipient,
228
+ amount: amount.toString(),
229
+ })
223
230
  } else if (type === 'delegate') {
224
- expect(operationContent.delegate).toEqual(recipient)
231
+ expect(operationContent).toMatchObject({ delegate: recipient })
225
232
  }
226
233
  }
227
234
  )
@@ -237,7 +244,9 @@ describe('Tezos Api', () => {
237
244
  })
238
245
 
239
246
  const decodedTransaction = await decode(encodedTransaction)
240
- const transactionFee = BigInt(decodedTransaction.contents[0].fee)
247
+ const op0 = decodedTransaction.contents[0]
248
+ assertHasFee(op0)
249
+ const transactionFee = BigInt(String(op0.fee))
241
250
  expect(transactionFee).toBeGreaterThan(0)
242
251
  })
243
252
 
@@ -258,7 +267,7 @@ describe('Tezos Api', () => {
258
267
  )
259
268
 
260
269
  const decodedTransaction = await decode(encodedTransaction)
261
- expect(decodedTransaction.contents[0].fee).toEqual(customFees.toString())
270
+ expect(decodedTransaction.contents[0]).toMatchObject({ fee: customFees.toString() })
262
271
  }
263
272
  )
264
273
  })
@@ -268,17 +277,19 @@ describe('Tezos Api', () => {
268
277
  const minEstimatedFees = 550
269
278
 
270
279
  const contextCustomFees: TezosContext = {
271
- config: async () =>
272
- ({
273
- ...defaultConfig,
274
- fees: {
275
- minGasLimit: 600,
276
- minRevealGasLimit: 300,
277
- minStorageLimit: 0,
278
- minFees,
279
- minEstimatedFees,
280
- },
281
- }) as TezosCoinConfig,
280
+ config: async () => ({
281
+ status: { type: 'active' },
282
+ baker: { url: 'https://baker.example.com' },
283
+ explorer: { url: 'https://api.shadownet.tzkt.io', maxTxQuery: 100 },
284
+ node: { url: 'https://rpc.shadownet.teztnets.com' },
285
+ fees: {
286
+ minGasLimit: 600,
287
+ minRevealGasLimit: 300,
288
+ minStorageLimit: 0,
289
+ minFees,
290
+ minEstimatedFees,
291
+ },
292
+ }),
282
293
  logger: () => undefined,
283
294
  }
284
295
 
@@ -324,7 +335,9 @@ describe('Tezos Api', () => {
324
335
  }
325
336
  )
326
337
  const decoded = await localForger.parse(encodedTransaction.slice(2))
327
- const fee = BigInt(decoded.contents[0].fee ?? '0')
338
+ const op = decoded.contents[0]
339
+ assertHasFee(op)
340
+ const fee = BigInt(String(op.fee))
328
341
  expect(fee).toBeGreaterThanOrEqual(BigInt(minFees))
329
342
  })
330
343
 
@@ -341,7 +354,9 @@ describe('Tezos Api', () => {
341
354
  }
342
355
  )
343
356
  const decoded = await localForger.parse(encodedTransaction.slice(2))
344
- const fee = BigInt(decoded.contents[0].fee ?? '0')
357
+ const op = decoded.contents[0]
358
+ assertHasFee(op)
359
+ const fee = BigInt(String(op.fee))
345
360
  expect(fee).toBeGreaterThanOrEqual(BigInt(minFees))
346
361
  })
347
362
 
@@ -360,7 +375,7 @@ describe('Tezos Api', () => {
360
375
  { customFees: { value: customFee } }
361
376
  )
362
377
  const decoded = await localForger.parse(encodedTransaction.slice(2))
363
- expect(decoded.contents[0].fee).toBe(customFee.toString())
378
+ expect(decoded.contents[0]).toMatchObject({ fee: customFee.toString() })
364
379
  })
365
380
 
366
381
  it('craft transaction with customFee when default estimation is lesser than customFee', async () => {
@@ -378,7 +393,7 @@ describe('Tezos Api', () => {
378
393
  { customFees: { value: customFee } }
379
394
  )
380
395
  const decoded = await localForger.parse(encodedTransaction.slice(2))
381
- expect(decoded.contents[0].fee).toBe(customFee.toString())
396
+ expect(decoded.contents[0]).toMatchObject({ fee: customFee.toString() })
382
397
  })
383
398
  })
384
399
  })