@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.
- package/CHANGELOG.md +25 -0
- package/lib/api/index.d.ts +1 -1
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +1 -1
- package/lib/api/index.js.map +1 -1
- package/lib/logic/craftRawOperations.js +26 -17
- package/lib/logic/craftRawOperations.js.map +1 -1
- package/lib/logic/estimateFees.js +4 -4
- package/lib/logic/estimateFees.js.map +1 -1
- package/lib/logic/listOperations.d.ts.map +1 -1
- package/lib/logic/listOperations.js +9 -7
- package/lib/logic/listOperations.js.map +1 -1
- package/lib/logic/validateIntent.d.ts.map +1 -1
- package/lib/logic/validateIntent.js +26 -8
- package/lib/logic/validateIntent.js.map +1 -1
- package/lib/network/tzkt.js +1 -1
- package/lib/network/tzkt.js.map +1 -1
- package/lib/test/config.d.ts +2 -22
- package/lib/test/config.d.ts.map +1 -1
- package/lib/test/config.js.map +1 -1
- package/lib/utils.d.ts +0 -3
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +17 -3
- package/lib/utils.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 +1 -1
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/logic/craftRawOperations.js +26 -17
- package/lib-es/logic/craftRawOperations.js.map +1 -1
- package/lib-es/logic/estimateFees.js +4 -4
- package/lib-es/logic/estimateFees.js.map +1 -1
- package/lib-es/logic/listOperations.d.ts.map +1 -1
- package/lib-es/logic/listOperations.js +9 -7
- package/lib-es/logic/listOperations.js.map +1 -1
- package/lib-es/logic/validateIntent.d.ts.map +1 -1
- package/lib-es/logic/validateIntent.js +27 -9
- package/lib-es/logic/validateIntent.js.map +1 -1
- package/lib-es/network/tzkt.js +1 -1
- package/lib-es/network/tzkt.js.map +1 -1
- package/lib-es/test/config.d.ts +2 -22
- package/lib-es/test/config.d.ts.map +1 -1
- package/lib-es/test/config.js.map +1 -1
- package/lib-es/utils.d.ts +0 -3
- package/lib-es/utils.d.ts.map +1 -1
- package/lib-es/utils.js +17 -3
- package/lib-es/utils.js.map +1 -1
- package/package.json +2 -2
- package/src/api/index-mainnet.integ.test.ts +40 -50
- package/src/api/index.integ.test.ts +60 -45
- package/src/api/index.test.ts +229 -180
- package/src/api/index.ts +5 -4
- package/src/logic/broadcast.integ.test.ts +2 -7
- package/src/logic/craftRawOperations.test.ts +11 -10
- package/src/logic/craftRawOperations.ts +35 -19
- package/src/logic/craftTransaction.integ.test.ts +2 -2
- package/src/logic/craftTransaction.test.ts +63 -95
- package/src/logic/estimateFees.integ.test.ts +19 -20
- package/src/logic/estimateFees.test.ts +30 -63
- package/src/logic/estimateFees.ts +4 -4
- package/src/logic/getBalance.test.ts +6 -6
- package/src/logic/getBlock.integ.test.ts +20 -21
- package/src/logic/getBlock.test.ts +44 -51
- package/src/logic/getBlockInfo.integ.test.ts +13 -14
- package/src/logic/getBlockInfo.test.ts +8 -7
- package/src/logic/getStakes.test.ts +17 -17
- package/src/logic/listOperations.integ.test.ts +40 -37
- package/src/logic/listOperations.test.ts +34 -31
- package/src/logic/listOperations.ts +19 -19
- package/src/logic/validateIntent.test.ts +145 -20
- package/src/logic/validateIntent.ts +32 -8
- package/src/network/bakers.integ.test.ts +1 -1
- package/src/network/bakers.test.ts +7 -15
- package/src/network/tzkt.integ.test.ts +13 -14
- package/src/network/tzkt.test.ts +194 -259
- package/src/network/tzkt.ts +1 -1
- package/src/test/config.ts +3 -1
- package/src/utils.ts +18 -3
- 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 {
|
|
5
|
-
import
|
|
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
|
-
|
|
10
|
-
|
|
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 () =>
|
|
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(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
|
218
|
-
|
|
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(
|
|
222
|
-
|
|
226
|
+
expect(operationContent).toMatchObject({
|
|
227
|
+
destination: recipient,
|
|
228
|
+
amount: amount.toString(),
|
|
229
|
+
})
|
|
223
230
|
} else if (type === 'delegate') {
|
|
224
|
-
expect(operationContent
|
|
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
|
|
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]
|
|
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
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
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
|
|
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
|
|
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]
|
|
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]
|
|
396
|
+
expect(decoded.contents[0]).toMatchObject({ fee: customFee.toString() })
|
|
382
397
|
})
|
|
383
398
|
})
|
|
384
399
|
})
|