@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.
- package/CHANGELOG.md +28 -0
- package/lib/api/index.d.ts +1 -2
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +45 -44
- package/lib/api/index.js.map +1 -1
- package/lib/api/types.d.ts +3 -2
- package/lib/api/types.d.ts.map +1 -1
- package/lib/config.d.ts +3 -1
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js.map +1 -1
- package/lib/logic/broadcast.d.ts +2 -1
- package/lib/logic/broadcast.d.ts.map +1 -1
- package/lib/logic/broadcast.js +3 -2
- package/lib/logic/broadcast.js.map +1 -1
- package/lib/logic/craftRawOperations.d.ts +2 -1
- package/lib/logic/craftRawOperations.d.ts.map +1 -1
- package/lib/logic/craftRawOperations.js +5 -8
- package/lib/logic/craftRawOperations.js.map +1 -1
- package/lib/logic/craftTransaction.d.ts +3 -2
- package/lib/logic/craftTransaction.d.ts.map +1 -1
- package/lib/logic/craftTransaction.js +6 -9
- package/lib/logic/craftTransaction.js.map +1 -1
- package/lib/logic/estimateFees.d.ts +2 -1
- package/lib/logic/estimateFees.d.ts.map +1 -1
- package/lib/logic/estimateFees.js +24 -19
- package/lib/logic/estimateFees.js.map +1 -1
- package/lib/logic/getBalance.d.ts +2 -1
- package/lib/logic/getBalance.d.ts.map +1 -1
- package/lib/logic/getBalance.js +7 -8
- package/lib/logic/getBalance.js.map +1 -1
- package/lib/logic/getBlock.d.ts +2 -1
- package/lib/logic/getBlock.d.ts.map +1 -1
- package/lib/logic/getBlock.js +12 -10
- package/lib/logic/getBlock.js.map +1 -1
- package/lib/logic/getBlockInfo.d.ts +2 -1
- package/lib/logic/getBlockInfo.d.ts.map +1 -1
- package/lib/logic/getBlockInfo.js +5 -3
- package/lib/logic/getBlockInfo.js.map +1 -1
- package/lib/logic/getStakes.d.ts +3 -2
- package/lib/logic/getStakes.d.ts.map +1 -1
- package/lib/logic/getStakes.js +9 -9
- package/lib/logic/getStakes.js.map +1 -1
- package/lib/logic/lastBlock.d.ts +2 -1
- package/lib/logic/lastBlock.d.ts.map +1 -1
- package/lib/logic/lastBlock.js +4 -6
- package/lib/logic/lastBlock.js.map +1 -1
- package/lib/logic/listOperations.d.ts +2 -1
- package/lib/logic/listOperations.d.ts.map +1 -1
- package/lib/logic/listOperations.js +8 -6
- package/lib/logic/listOperations.js.map +1 -1
- package/lib/logic/tezosToolkit.d.ts +2 -1
- package/lib/logic/tezosToolkit.d.ts.map +1 -1
- package/lib/logic/tezosToolkit.js +2 -6
- package/lib/logic/tezosToolkit.js.map +1 -1
- package/lib/logic/validateIntent.d.ts +2 -1
- package/lib/logic/validateIntent.d.ts.map +1 -1
- package/lib/logic/validateIntent.js +12 -13
- package/lib/logic/validateIntent.js.map +1 -1
- package/lib/network/bakers.d.ts +5 -4
- package/lib/network/bakers.d.ts.map +1 -1
- package/lib/network/bakers.js +9 -10
- package/lib/network/bakers.js.map +1 -1
- package/lib/network/index.d.ts +1 -1
- package/lib/network/index.d.ts.map +1 -1
- package/lib/network/index.js +2 -5
- package/lib/network/index.js.map +1 -1
- package/lib/network/tzkt.d.ts +16 -9
- package/lib/network/tzkt.d.ts.map +1 -1
- package/lib/network/tzkt.js +341 -333
- package/lib/network/tzkt.js.map +1 -1
- package/lib/utils.d.ts +2 -1
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +1 -6
- package/lib/utils.js.map +1 -1
- package/lib-es/api/index.d.ts +1 -2
- package/lib-es/api/index.d.ts.map +1 -1
- package/lib-es/api/index.js +40 -36
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/api/types.d.ts +3 -2
- package/lib-es/api/types.d.ts.map +1 -1
- package/lib-es/config.d.ts +3 -1
- package/lib-es/config.d.ts.map +1 -1
- package/lib-es/config.js.map +1 -1
- package/lib-es/logic/broadcast.d.ts +2 -1
- package/lib-es/logic/broadcast.d.ts.map +1 -1
- package/lib-es/logic/broadcast.js +3 -2
- package/lib-es/logic/broadcast.js.map +1 -1
- package/lib-es/logic/craftRawOperations.d.ts +2 -1
- package/lib-es/logic/craftRawOperations.d.ts.map +1 -1
- package/lib-es/logic/craftRawOperations.js +5 -5
- package/lib-es/logic/craftRawOperations.js.map +1 -1
- package/lib-es/logic/craftTransaction.d.ts +3 -2
- package/lib-es/logic/craftTransaction.d.ts.map +1 -1
- package/lib-es/logic/craftTransaction.js +6 -6
- package/lib-es/logic/craftTransaction.js.map +1 -1
- package/lib-es/logic/estimateFees.d.ts +2 -1
- package/lib-es/logic/estimateFees.d.ts.map +1 -1
- package/lib-es/logic/estimateFees.js +24 -16
- package/lib-es/logic/estimateFees.js.map +1 -1
- package/lib-es/logic/getBalance.d.ts +2 -1
- package/lib-es/logic/getBalance.d.ts.map +1 -1
- package/lib-es/logic/getBalance.js +5 -3
- package/lib-es/logic/getBalance.js.map +1 -1
- package/lib-es/logic/getBlock.d.ts +2 -1
- package/lib-es/logic/getBlock.d.ts.map +1 -1
- package/lib-es/logic/getBlock.js +10 -8
- package/lib-es/logic/getBlock.js.map +1 -1
- package/lib-es/logic/getBlockInfo.d.ts +2 -1
- package/lib-es/logic/getBlockInfo.d.ts.map +1 -1
- package/lib-es/logic/getBlockInfo.js +4 -2
- package/lib-es/logic/getBlockInfo.js.map +1 -1
- package/lib-es/logic/getStakes.d.ts +3 -2
- package/lib-es/logic/getStakes.d.ts.map +1 -1
- package/lib-es/logic/getStakes.js +9 -6
- package/lib-es/logic/getStakes.js.map +1 -1
- package/lib-es/logic/lastBlock.d.ts +2 -1
- package/lib-es/logic/lastBlock.d.ts.map +1 -1
- package/lib-es/logic/lastBlock.js +4 -3
- package/lib-es/logic/lastBlock.js.map +1 -1
- package/lib-es/logic/listOperations.d.ts +2 -1
- package/lib-es/logic/listOperations.d.ts.map +1 -1
- package/lib-es/logic/listOperations.js +7 -5
- package/lib-es/logic/listOperations.js.map +1 -1
- package/lib-es/logic/tezosToolkit.d.ts +2 -1
- package/lib-es/logic/tezosToolkit.d.ts.map +1 -1
- package/lib-es/logic/tezosToolkit.js +2 -3
- package/lib-es/logic/tezosToolkit.js.map +1 -1
- package/lib-es/logic/validateIntent.d.ts +2 -1
- package/lib-es/logic/validateIntent.d.ts.map +1 -1
- package/lib-es/logic/validateIntent.js +10 -8
- package/lib-es/logic/validateIntent.js.map +1 -1
- package/lib-es/network/bakers.d.ts +5 -4
- package/lib-es/network/bakers.d.ts.map +1 -1
- package/lib-es/network/bakers.js +9 -10
- package/lib-es/network/bakers.js.map +1 -1
- package/lib-es/network/index.d.ts +1 -1
- package/lib-es/network/index.d.ts.map +1 -1
- package/lib-es/network/index.js +1 -1
- package/lib-es/network/index.js.map +1 -1
- package/lib-es/network/tzkt.d.ts +16 -9
- package/lib-es/network/tzkt.d.ts.map +1 -1
- package/lib-es/network/tzkt.js +340 -333
- package/lib-es/network/tzkt.js.map +1 -1
- package/lib-es/utils.d.ts +2 -1
- package/lib-es/utils.d.ts.map +1 -1
- package/lib-es/utils.js +1 -3
- package/lib-es/utils.js.map +1 -1
- package/package.json +2 -2
- package/src/api/index-mainnet.integ.test.ts +34 -30
- package/src/api/index.integ.test.ts +69 -53
- package/src/api/index.test.ts +99 -60
- package/src/api/index.ts +52 -36
- package/src/api/types.ts +3 -2
- package/src/config.ts +4 -1
- package/src/logic/broadcast.integ.test.ts +12 -13
- package/src/logic/broadcast.ts +4 -2
- package/src/logic/craftRawOperations.test.ts +47 -33
- package/src/logic/craftRawOperations.ts +6 -4
- package/src/logic/craftTransaction.integ.test.ts +12 -5
- package/src/logic/craftTransaction.test.ts +39 -31
- package/src/logic/craftTransaction.ts +10 -5
- package/src/logic/estimateFees.integ.test.ts +7 -7
- package/src/logic/estimateFees.test.ts +52 -49
- package/src/logic/estimateFees.ts +34 -22
- package/src/logic/getBalance.test.ts +19 -17
- package/src/logic/getBalance.ts +6 -3
- package/src/logic/getBlock.integ.test.ts +8 -30
- package/src/logic/getBlock.test.ts +91 -81
- package/src/logic/getBlock.ts +11 -8
- package/src/logic/getBlockInfo.integ.test.ts +9 -18
- package/src/logic/getBlockInfo.test.ts +19 -9
- package/src/logic/getBlockInfo.ts +5 -2
- package/src/logic/getStakes.test.ts +46 -49
- package/src/logic/getStakes.ts +14 -5
- package/src/logic/lastBlock.ts +5 -3
- package/src/logic/listOperations.integ.test.ts +40 -67
- package/src/logic/listOperations.test.ts +65 -59
- package/src/logic/listOperations.ts +8 -3
- package/src/logic/tezosToolkit.ts +3 -3
- package/src/logic/validateIntent.test.ts +78 -74
- package/src/logic/validateIntent.ts +17 -7
- package/src/network/bakers.integ.test.ts +2 -5
- package/src/network/bakers.test.ts +5 -6
- package/src/network/bakers.ts +13 -10
- package/src/network/index.ts +2 -1
- package/src/network/tzkt.integ.test.ts +3 -14
- package/src/network/tzkt.test.ts +128 -96
- package/src/network/tzkt.ts +426 -393
- 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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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(
|
|
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 =
|
|
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(
|
|
186
|
-
|
|
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
|
-
|
|
12
|
-
|
|
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({
|