@ledgerhq/coin-tezos 7.12.0 → 8.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.
Files changed (189) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/lib/api/index.d.ts +1 -2
  3. package/lib/api/index.d.ts.map +1 -1
  4. package/lib/api/index.js +45 -44
  5. package/lib/api/index.js.map +1 -1
  6. package/lib/api/types.d.ts +3 -2
  7. package/lib/api/types.d.ts.map +1 -1
  8. package/lib/config.d.ts +3 -1
  9. package/lib/config.d.ts.map +1 -1
  10. package/lib/config.js.map +1 -1
  11. package/lib/logic/broadcast.d.ts +2 -1
  12. package/lib/logic/broadcast.d.ts.map +1 -1
  13. package/lib/logic/broadcast.js +3 -2
  14. package/lib/logic/broadcast.js.map +1 -1
  15. package/lib/logic/craftRawOperations.d.ts +2 -1
  16. package/lib/logic/craftRawOperations.d.ts.map +1 -1
  17. package/lib/logic/craftRawOperations.js +5 -8
  18. package/lib/logic/craftRawOperations.js.map +1 -1
  19. package/lib/logic/craftTransaction.d.ts +3 -2
  20. package/lib/logic/craftTransaction.d.ts.map +1 -1
  21. package/lib/logic/craftTransaction.js +6 -9
  22. package/lib/logic/craftTransaction.js.map +1 -1
  23. package/lib/logic/estimateFees.d.ts +2 -1
  24. package/lib/logic/estimateFees.d.ts.map +1 -1
  25. package/lib/logic/estimateFees.js +24 -19
  26. package/lib/logic/estimateFees.js.map +1 -1
  27. package/lib/logic/getBalance.d.ts +2 -1
  28. package/lib/logic/getBalance.d.ts.map +1 -1
  29. package/lib/logic/getBalance.js +7 -8
  30. package/lib/logic/getBalance.js.map +1 -1
  31. package/lib/logic/getBlock.d.ts +2 -1
  32. package/lib/logic/getBlock.d.ts.map +1 -1
  33. package/lib/logic/getBlock.js +12 -10
  34. package/lib/logic/getBlock.js.map +1 -1
  35. package/lib/logic/getBlockInfo.d.ts +2 -1
  36. package/lib/logic/getBlockInfo.d.ts.map +1 -1
  37. package/lib/logic/getBlockInfo.js +5 -3
  38. package/lib/logic/getBlockInfo.js.map +1 -1
  39. package/lib/logic/getStakes.d.ts +3 -2
  40. package/lib/logic/getStakes.d.ts.map +1 -1
  41. package/lib/logic/getStakes.js +9 -9
  42. package/lib/logic/getStakes.js.map +1 -1
  43. package/lib/logic/lastBlock.d.ts +2 -1
  44. package/lib/logic/lastBlock.d.ts.map +1 -1
  45. package/lib/logic/lastBlock.js +4 -6
  46. package/lib/logic/lastBlock.js.map +1 -1
  47. package/lib/logic/listOperations.d.ts +2 -1
  48. package/lib/logic/listOperations.d.ts.map +1 -1
  49. package/lib/logic/listOperations.js +8 -6
  50. package/lib/logic/listOperations.js.map +1 -1
  51. package/lib/logic/tezosToolkit.d.ts +2 -1
  52. package/lib/logic/tezosToolkit.d.ts.map +1 -1
  53. package/lib/logic/tezosToolkit.js +2 -6
  54. package/lib/logic/tezosToolkit.js.map +1 -1
  55. package/lib/logic/validateIntent.d.ts +2 -1
  56. package/lib/logic/validateIntent.d.ts.map +1 -1
  57. package/lib/logic/validateIntent.js +12 -13
  58. package/lib/logic/validateIntent.js.map +1 -1
  59. package/lib/network/bakers.d.ts +5 -4
  60. package/lib/network/bakers.d.ts.map +1 -1
  61. package/lib/network/bakers.js +9 -10
  62. package/lib/network/bakers.js.map +1 -1
  63. package/lib/network/index.d.ts +1 -1
  64. package/lib/network/index.d.ts.map +1 -1
  65. package/lib/network/index.js +2 -5
  66. package/lib/network/index.js.map +1 -1
  67. package/lib/network/tzkt.d.ts +16 -9
  68. package/lib/network/tzkt.d.ts.map +1 -1
  69. package/lib/network/tzkt.js +341 -333
  70. package/lib/network/tzkt.js.map +1 -1
  71. package/lib/utils.d.ts +2 -1
  72. package/lib/utils.d.ts.map +1 -1
  73. package/lib/utils.js +1 -6
  74. package/lib/utils.js.map +1 -1
  75. package/lib-es/api/index.d.ts +1 -2
  76. package/lib-es/api/index.d.ts.map +1 -1
  77. package/lib-es/api/index.js +40 -36
  78. package/lib-es/api/index.js.map +1 -1
  79. package/lib-es/api/types.d.ts +3 -2
  80. package/lib-es/api/types.d.ts.map +1 -1
  81. package/lib-es/config.d.ts +3 -1
  82. package/lib-es/config.d.ts.map +1 -1
  83. package/lib-es/config.js.map +1 -1
  84. package/lib-es/logic/broadcast.d.ts +2 -1
  85. package/lib-es/logic/broadcast.d.ts.map +1 -1
  86. package/lib-es/logic/broadcast.js +3 -2
  87. package/lib-es/logic/broadcast.js.map +1 -1
  88. package/lib-es/logic/craftRawOperations.d.ts +2 -1
  89. package/lib-es/logic/craftRawOperations.d.ts.map +1 -1
  90. package/lib-es/logic/craftRawOperations.js +5 -5
  91. package/lib-es/logic/craftRawOperations.js.map +1 -1
  92. package/lib-es/logic/craftTransaction.d.ts +3 -2
  93. package/lib-es/logic/craftTransaction.d.ts.map +1 -1
  94. package/lib-es/logic/craftTransaction.js +6 -6
  95. package/lib-es/logic/craftTransaction.js.map +1 -1
  96. package/lib-es/logic/estimateFees.d.ts +2 -1
  97. package/lib-es/logic/estimateFees.d.ts.map +1 -1
  98. package/lib-es/logic/estimateFees.js +24 -16
  99. package/lib-es/logic/estimateFees.js.map +1 -1
  100. package/lib-es/logic/getBalance.d.ts +2 -1
  101. package/lib-es/logic/getBalance.d.ts.map +1 -1
  102. package/lib-es/logic/getBalance.js +5 -3
  103. package/lib-es/logic/getBalance.js.map +1 -1
  104. package/lib-es/logic/getBlock.d.ts +2 -1
  105. package/lib-es/logic/getBlock.d.ts.map +1 -1
  106. package/lib-es/logic/getBlock.js +10 -8
  107. package/lib-es/logic/getBlock.js.map +1 -1
  108. package/lib-es/logic/getBlockInfo.d.ts +2 -1
  109. package/lib-es/logic/getBlockInfo.d.ts.map +1 -1
  110. package/lib-es/logic/getBlockInfo.js +4 -2
  111. package/lib-es/logic/getBlockInfo.js.map +1 -1
  112. package/lib-es/logic/getStakes.d.ts +3 -2
  113. package/lib-es/logic/getStakes.d.ts.map +1 -1
  114. package/lib-es/logic/getStakes.js +9 -6
  115. package/lib-es/logic/getStakes.js.map +1 -1
  116. package/lib-es/logic/lastBlock.d.ts +2 -1
  117. package/lib-es/logic/lastBlock.d.ts.map +1 -1
  118. package/lib-es/logic/lastBlock.js +4 -3
  119. package/lib-es/logic/lastBlock.js.map +1 -1
  120. package/lib-es/logic/listOperations.d.ts +2 -1
  121. package/lib-es/logic/listOperations.d.ts.map +1 -1
  122. package/lib-es/logic/listOperations.js +7 -5
  123. package/lib-es/logic/listOperations.js.map +1 -1
  124. package/lib-es/logic/tezosToolkit.d.ts +2 -1
  125. package/lib-es/logic/tezosToolkit.d.ts.map +1 -1
  126. package/lib-es/logic/tezosToolkit.js +2 -3
  127. package/lib-es/logic/tezosToolkit.js.map +1 -1
  128. package/lib-es/logic/validateIntent.d.ts +2 -1
  129. package/lib-es/logic/validateIntent.d.ts.map +1 -1
  130. package/lib-es/logic/validateIntent.js +10 -8
  131. package/lib-es/logic/validateIntent.js.map +1 -1
  132. package/lib-es/network/bakers.d.ts +5 -4
  133. package/lib-es/network/bakers.d.ts.map +1 -1
  134. package/lib-es/network/bakers.js +9 -10
  135. package/lib-es/network/bakers.js.map +1 -1
  136. package/lib-es/network/index.d.ts +1 -1
  137. package/lib-es/network/index.d.ts.map +1 -1
  138. package/lib-es/network/index.js +1 -1
  139. package/lib-es/network/index.js.map +1 -1
  140. package/lib-es/network/tzkt.d.ts +16 -9
  141. package/lib-es/network/tzkt.d.ts.map +1 -1
  142. package/lib-es/network/tzkt.js +340 -333
  143. package/lib-es/network/tzkt.js.map +1 -1
  144. package/lib-es/utils.d.ts +2 -1
  145. package/lib-es/utils.d.ts.map +1 -1
  146. package/lib-es/utils.js +1 -3
  147. package/lib-es/utils.js.map +1 -1
  148. package/package.json +2 -2
  149. package/src/api/index-mainnet.integ.test.ts +34 -30
  150. package/src/api/index.integ.test.ts +69 -53
  151. package/src/api/index.test.ts +99 -60
  152. package/src/api/index.ts +52 -36
  153. package/src/api/types.ts +3 -2
  154. package/src/config.ts +4 -1
  155. package/src/logic/broadcast.integ.test.ts +12 -13
  156. package/src/logic/broadcast.ts +4 -2
  157. package/src/logic/craftRawOperations.test.ts +47 -33
  158. package/src/logic/craftRawOperations.ts +6 -4
  159. package/src/logic/craftTransaction.integ.test.ts +12 -5
  160. package/src/logic/craftTransaction.test.ts +39 -31
  161. package/src/logic/craftTransaction.ts +10 -5
  162. package/src/logic/estimateFees.integ.test.ts +7 -7
  163. package/src/logic/estimateFees.test.ts +52 -49
  164. package/src/logic/estimateFees.ts +34 -22
  165. package/src/logic/getBalance.test.ts +19 -17
  166. package/src/logic/getBalance.ts +6 -3
  167. package/src/logic/getBlock.integ.test.ts +8 -30
  168. package/src/logic/getBlock.test.ts +91 -81
  169. package/src/logic/getBlock.ts +11 -8
  170. package/src/logic/getBlockInfo.integ.test.ts +9 -18
  171. package/src/logic/getBlockInfo.test.ts +19 -9
  172. package/src/logic/getBlockInfo.ts +5 -2
  173. package/src/logic/getStakes.test.ts +46 -49
  174. package/src/logic/getStakes.ts +14 -5
  175. package/src/logic/lastBlock.ts +5 -3
  176. package/src/logic/listOperations.integ.test.ts +40 -67
  177. package/src/logic/listOperations.test.ts +65 -59
  178. package/src/logic/listOperations.ts +8 -3
  179. package/src/logic/tezosToolkit.ts +3 -3
  180. package/src/logic/validateIntent.test.ts +78 -74
  181. package/src/logic/validateIntent.ts +17 -7
  182. package/src/network/bakers.integ.test.ts +2 -5
  183. package/src/network/bakers.test.ts +5 -6
  184. package/src/network/bakers.ts +13 -10
  185. package/src/network/index.ts +2 -1
  186. package/src/network/tzkt.integ.test.ts +3 -14
  187. package/src/network/tzkt.test.ts +128 -96
  188. package/src/network/tzkt.ts +426 -393
  189. package/src/utils.ts +2 -3
@@ -1,9 +1,9 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
+ import type { TezosCoinConfig, TezosContext } from '../config'
4
5
  import { OpKind } from '@taquito/rpc'
5
6
  import { getRevealFee } from '@taquito/taquito'
6
- import coinConfig from '../config'
7
7
  import { craftTransaction, rawEncode } from './craftTransaction'
8
8
  import { getTezosToolkit } from './tezosToolkit'
9
9
 
@@ -17,9 +17,6 @@ type TransactionType =
17
17
  | 'finalize_unstake'
18
18
 
19
19
  jest.mock('./tezosToolkit')
20
- jest.mock('../config', () => ({
21
- getCoinConfig: jest.fn(),
22
- }))
23
20
 
24
21
  function setupFa2ContractMock(parameter: { entrypoint: string; value: unknown }) {
25
22
  const toTransferParams = jest.fn().mockReturnValue({
@@ -47,9 +44,16 @@ describe('craftTransaction', () => {
47
44
  setProvider: jest.fn(),
48
45
  }
49
46
 
47
+ let currentConfig: TezosCoinConfig
48
+ const context: TezosContext = {
49
+ config: async () => currentConfig,
50
+ logger: () => undefined,
51
+ }
52
+
50
53
  beforeEach(() => {
51
54
  jest.clearAllMocks()
52
55
  ;(getTezosToolkit as jest.Mock).mockReturnValue(mockTezosToolkit)
56
+ currentConfig = {} as unknown as TezosCoinConfig
53
57
  })
54
58
 
55
59
  it('should craft a send transaction', async () => {
@@ -63,7 +67,7 @@ describe('craftTransaction', () => {
63
67
  fee: { fees: '100', gasLimit: '200', storageLimit: '300' },
64
68
  }
65
69
 
66
- const result = await craftTransaction(account, transaction)
70
+ const result = await craftTransaction(context, account, transaction)
67
71
 
68
72
  expect(result.type).toBe('OUT')
69
73
  expect(result.contents).toEqual([
@@ -91,7 +95,7 @@ describe('craftTransaction', () => {
91
95
  fee: { fees: '100', gasLimit: '200', storageLimit: '300' },
92
96
  }
93
97
 
94
- const result = await craftTransaction(account, transaction)
98
+ const result = await craftTransaction(context, account, transaction)
95
99
 
96
100
  expect(result.type).toBe('DELEGATE')
97
101
  expect(result.contents).toEqual([
@@ -118,7 +122,7 @@ describe('craftTransaction', () => {
118
122
  fee: { fees: '100', gasLimit: '200', storageLimit: '300' },
119
123
  }
120
124
 
121
- const result = await craftTransaction(account, transaction)
125
+ const result = await craftTransaction(context, account, transaction)
122
126
 
123
127
  expect(result.type).toBe('UNDELEGATE')
124
128
  expect(result.contents).toEqual([
@@ -140,13 +144,13 @@ describe('craftTransaction', () => {
140
144
  storageLimit: 0,
141
145
  suggestedFeeMutez: getRevealFee('tz1...'),
142
146
  })
143
- ;(coinConfig.getCoinConfig as jest.Mock).mockReturnValue({
147
+ currentConfig = {
144
148
  fees: {
145
149
  minRevealGasLimit: 100,
146
150
  minFees: 0,
147
151
  minStorageLimit: 0,
148
152
  },
149
- })
153
+ } as unknown as TezosCoinConfig
150
154
 
151
155
  const account = { address: 'tz1...' }
152
156
  const transaction = {
@@ -157,7 +161,7 @@ describe('craftTransaction', () => {
157
161
  }
158
162
  const publicKey = { publicKey: 'publicKey', publicKeyHash: 'publicKeyHash' }
159
163
 
160
- const result = await craftTransaction(account, transaction, publicKey)
164
+ const result = await craftTransaction(context, account, transaction, publicKey)
161
165
 
162
166
  expect(result.contents).toEqual([
163
167
  {
@@ -192,13 +196,13 @@ describe('craftTransaction', () => {
192
196
  suggestedFeeMutez: suggestedRevealFee,
193
197
  })
194
198
  const minFees = 500
195
- ;(coinConfig.getCoinConfig as jest.Mock).mockReturnValue({
199
+ currentConfig = {
196
200
  fees: {
197
201
  minRevealGasLimit: 300,
198
202
  minFees,
199
203
  minStorageLimit: 0,
200
204
  },
201
- })
205
+ } as unknown as TezosCoinConfig
202
206
 
203
207
  const account = { address: 'tz2...' }
204
208
  const mainOpFee = 600
@@ -210,7 +214,7 @@ describe('craftTransaction', () => {
210
214
  }
211
215
  const publicKey = { publicKey: 'pk', publicKeyHash: 'pkh' }
212
216
 
213
- const result = await craftTransaction(account, transaction, publicKey)
217
+ const result = await craftTransaction(context, account, transaction, publicKey)
214
218
 
215
219
  const revealOp = result.contents[0]
216
220
  expect(revealOp.kind).toBe(OpKind.REVEAL)
@@ -227,13 +231,13 @@ describe('craftTransaction', () => {
227
231
  suggestedFeeMutez: 100,
228
232
  })
229
233
  const minFees = 500
230
- ;(coinConfig.getCoinConfig as jest.Mock).mockReturnValue({
234
+ currentConfig = {
231
235
  fees: {
232
236
  minRevealGasLimit: 300,
233
237
  minFees,
234
238
  minStorageLimit: 25,
235
239
  },
236
- })
240
+ } as unknown as TezosCoinConfig
237
241
 
238
242
  const account = { address: 'tz2...' }
239
243
  const transaction = {
@@ -244,7 +248,7 @@ describe('craftTransaction', () => {
244
248
  }
245
249
  const publicKey = { publicKey: 'pk', publicKeyHash: 'pkh' }
246
250
 
247
- const result = await craftTransaction(account, transaction, publicKey)
251
+ const result = await craftTransaction(context, account, transaction, publicKey)
248
252
 
249
253
  const revealOp = result.contents[0]
250
254
  expect(revealOp.kind).toBe(OpKind.REVEAL)
@@ -261,13 +265,13 @@ describe('craftTransaction', () => {
261
265
  suggestedFeeMutez: 100,
262
266
  })
263
267
  const minFees = 1000
264
- ;(coinConfig.getCoinConfig as jest.Mock).mockReturnValue({
268
+ currentConfig = {
265
269
  fees: {
266
270
  minRevealGasLimit: 300,
267
271
  minFees,
268
272
  minStorageLimit: 0,
269
273
  },
270
- })
274
+ } as unknown as TezosCoinConfig
271
275
 
272
276
  const account = { address: 'tz2TaTpo31sAiX2HBJUTLLdUnqVJR4QjLy1V' }
273
277
  const mainOpFee = 1000
@@ -279,7 +283,7 @@ describe('craftTransaction', () => {
279
283
  }
280
284
  const publicKey = { publicKey: 'pk', publicKeyHash: account.address }
281
285
 
282
- const result = await craftTransaction(account, transaction, publicKey)
286
+ const result = await craftTransaction(context, account, transaction, publicKey)
283
287
 
284
288
  expect(result.contents).toHaveLength(2)
285
289
  const revealFee = Number(result.contents[0].fee ?? 0)
@@ -308,7 +312,7 @@ describe('craftTransaction', () => {
308
312
  tokenId: 0,
309
313
  }
310
314
 
311
- const result = await craftTransaction(account, transaction)
315
+ const result = await craftTransaction(context, account, transaction)
312
316
 
313
317
  expect(result.type).toBe('OUT')
314
318
  expect(mockTezosToolkit.contract.at).toHaveBeenCalledWith(contractAddress)
@@ -343,13 +347,13 @@ describe('craftTransaction', () => {
343
347
  storageLimit: 0,
344
348
  suggestedFeeMutez: getRevealFee('tz1...'),
345
349
  })
346
- ;(coinConfig.getCoinConfig as jest.Mock).mockReturnValue({
350
+ currentConfig = {
347
351
  fees: {
348
352
  minRevealGasLimit: 100,
349
353
  minFees: 0,
350
354
  minStorageLimit: 0,
351
355
  },
352
- })
356
+ } as unknown as TezosCoinConfig
353
357
 
354
358
  const contractAddress = 'KT1CpeSQKdkhWi4pinYcseCFKmDhs5M74BkU'
355
359
  const account = { address: 'tz1...' }
@@ -363,7 +367,7 @@ describe('craftTransaction', () => {
363
367
  }
364
368
  const publicKey = { publicKey: 'publicKey', publicKeyHash: 'publicKeyHash' }
365
369
 
366
- const result = await craftTransaction(account, transaction, publicKey)
370
+ const result = await craftTransaction(context, account, transaction, publicKey)
367
371
 
368
372
  expect(result.contents).toHaveLength(2)
369
373
  expect(result.contents[0].kind).toBe(OpKind.REVEAL)
@@ -381,6 +385,7 @@ describe('craftTransaction', () => {
381
385
 
382
386
  await expect(
383
387
  craftTransaction(
388
+ context,
384
389
  { address: 'tz1...' },
385
390
  {
386
391
  type: 'send_token' as TransactionType,
@@ -393,6 +398,7 @@ describe('craftTransaction', () => {
393
398
 
394
399
  await expect(
395
400
  craftTransaction(
401
+ context,
396
402
  { address: 'tz1...' },
397
403
  {
398
404
  type: 'send_token' as TransactionType,
@@ -416,7 +422,7 @@ describe('craftTransaction', () => {
416
422
  fee: { fees: '100', gasLimit: '200', storageLimit: '300' },
417
423
  }
418
424
 
419
- const result = await craftTransaction(account, transaction)
425
+ const result = await craftTransaction(context, account, transaction)
420
426
 
421
427
  expect(result.type).toBe('STAKE')
422
428
  expect(result.contents).toEqual([
@@ -445,7 +451,7 @@ describe('craftTransaction', () => {
445
451
  fee: { fees: '100', gasLimit: '200', storageLimit: '300' },
446
452
  }
447
453
 
448
- const result = await craftTransaction(account, transaction)
454
+ const result = await craftTransaction(context, account, transaction)
449
455
 
450
456
  expect(result.type).toBe('UNSTAKE')
451
457
  expect(result.contents).toEqual([
@@ -475,7 +481,7 @@ describe('craftTransaction', () => {
475
481
  fee: { fees: '100', gasLimit: '200', storageLimit: '300' },
476
482
  }
477
483
 
478
- const result = await craftTransaction(account, transaction)
484
+ const result = await craftTransaction(context, account, transaction)
479
485
 
480
486
  expect(result.type).toBe('FINALIZE_UNSTAKE')
481
487
  expect(result.contents).toEqual([
@@ -500,13 +506,13 @@ describe('craftTransaction', () => {
500
506
  storageLimit: 0,
501
507
  suggestedFeeMutez: getRevealFee('tz1...'),
502
508
  })
503
- ;(coinConfig.getCoinConfig as jest.Mock).mockReturnValue({
509
+ currentConfig = {
504
510
  fees: {
505
511
  minRevealGasLimit: 100,
506
512
  minFees: 0,
507
513
  minStorageLimit: 0,
508
514
  },
509
- })
515
+ } as unknown as TezosCoinConfig
510
516
 
511
517
  const account = { address: 'tz1...' }
512
518
  const transaction = {
@@ -517,7 +523,7 @@ describe('craftTransaction', () => {
517
523
  }
518
524
  const publicKey = { publicKey: 'publicKey', publicKeyHash: 'publicKeyHash' }
519
525
 
520
- const result = await craftTransaction(account, transaction, publicKey)
526
+ const result = await craftTransaction(context, account, transaction, publicKey)
521
527
 
522
528
  expect(result.type).toBe('STAKE')
523
529
  expect(result.contents).toEqual([
@@ -553,14 +559,16 @@ describe('craftTransaction', () => {
553
559
  fee: { fees: '100', gasLimit: '200', storageLimit: '300' },
554
560
  }
555
561
 
556
- await expect(craftTransaction(account, transaction)).rejects.toThrow('unsupported mode')
562
+ await expect(craftTransaction(context, account, transaction)).rejects.toThrow(
563
+ 'unsupported mode'
564
+ )
557
565
  })
558
566
 
559
567
  it('should include leading watermark byte when using rawEncode', async () => {
560
568
  mockTezosToolkit.rpc.getBlock.mockResolvedValue({ hash: 'aaaa' })
561
569
  mockTezosToolkit.rpc.forgeOperations.mockResolvedValue('deadcafe')
562
570
 
563
- const rawTx = await rawEncode([])
571
+ const rawTx = await rawEncode(currentConfig, [])
564
572
 
565
573
  // 0x03 is a conventional prefix (aka a watermark) for tezos transactions
566
574
  expect(rawTx).toEqual('03deadcafe')
@@ -1,9 +1,9 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
+ import type { TezosCoinConfig, TezosContext } from '../config'
4
5
  import type { OperationContents } from '@taquito/rpc'
5
6
  import { OpKind } from '@taquito/rpc'
6
- import coinConfig from '../config'
7
7
  import { UnsupportedTransactionMode } from '../types/errors'
8
8
  import { createMockSigner } from '../utils'
9
9
  import { estimateRevealLimits } from './estimateRevealLimits'
@@ -23,6 +23,7 @@ export type TransactionType =
23
23
  | 'FINALIZE_UNSTAKE'
24
24
 
25
25
  export async function craftTransaction(
26
+ context: TezosContext,
26
27
  account: {
27
28
  address: string
28
29
  counter?: number
@@ -47,6 +48,7 @@ export async function craftTransaction(
47
48
  publicKeyHash: string
48
49
  }
49
50
  ): Promise<{ type: TransactionType; contents: OperationContents[] }> {
51
+ const config = await context.config()
50
52
  const { address } = account
51
53
 
52
54
  const transactionFees = {
@@ -55,7 +57,7 @@ export async function craftTransaction(
55
57
  storage_limit: transaction.fee.storageLimit ?? '0',
56
58
  }
57
59
 
58
- const tezosToolkit = getTezosToolkit()
60
+ const tezosToolkit = getTezosToolkit(config)
59
61
 
60
62
  // Configure signer for Taquito operations (same as in estimateFees)
61
63
  if (publicKey) {
@@ -70,7 +72,7 @@ export async function craftTransaction(
70
72
  const contents: OperationContents[] = []
71
73
 
72
74
  if (publicKey !== undefined) {
73
- const feesConfig = coinConfig.getCoinConfig().fees
75
+ const feesConfig = config.fees
74
76
  const reveal = await estimateRevealLimits(tezosToolkit, address, feesConfig)
75
77
 
76
78
  contents.push({
@@ -182,8 +184,11 @@ export async function craftTransaction(
182
184
  /**
183
185
  * Return transaction in raw encoded format (i.e. hexa)
184
186
  */
185
- export async function rawEncode(contents: OperationContents[]): Promise<string> {
186
- const tezosToolkit = getTezosToolkit()
187
+ export async function rawEncode(
188
+ config: TezosCoinConfig,
189
+ contents: OperationContents[]
190
+ ): Promise<string> {
191
+ const tezosToolkit = getTezosToolkit(config)
187
192
 
188
193
  const block = await tezosToolkit.rpc.getBlock()
189
194
  const forgedBytes = await tezosToolkit.rpc.forgeOperations({
@@ -1,16 +1,16 @@
1
1
  // SPDX-FileCopyrightText: © 2026 LEDGER SAS
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import type { TezosCoinConfig } from '../config'
4
+ import type { TezosCoinConfig, TezosContext } from '../config'
5
5
  import type { CoreTransactionInfo } from './estimateFees'
6
- import coinConfig from '../config'
7
6
  import { mockConfig } from '../test/config'
8
7
  import { estimateFees } from './estimateFees'
9
8
 
10
9
  describe('estimateFees', () => {
11
- beforeAll(() => {
12
- coinConfig.setCoinConfig((): TezosCoinConfig => mockConfig as TezosCoinConfig)
13
- })
10
+ const context: TezosContext = {
11
+ config: async () => mockConfig as TezosCoinConfig,
12
+ logger: () => undefined,
13
+ }
14
14
 
15
15
  const accounts = [
16
16
  {
@@ -39,7 +39,7 @@ describe('estimateFees', () => {
39
39
  } satisfies CoreTransactionInfo
40
40
 
41
41
  // When
42
- const result = await estimateFees({ account, transaction })
42
+ const result = await estimateFees(context, { account, transaction })
43
43
  // Then
44
44
  expect(result).toEqual({
45
45
  estimatedFees: BigInt('825'),
@@ -63,7 +63,7 @@ describe('estimateFees', () => {
63
63
  } satisfies CoreTransactionInfo
64
64
 
65
65
  // When
66
- const result = await estimateFees({ account, transaction })
66
+ const result = await estimateFees(context, { account, transaction })
67
67
 
68
68
  // Then
69
69
  expect(result).toEqual({