@ledgerhq/coin-tezos 10.2.2 → 10.2.4
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 -3
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +4 -9
- package/lib/api/index.js.map +1 -1
- package/lib/logic/craftRawOperations.js +1 -1
- package/lib/logic/craftRawOperations.js.map +1 -1
- package/lib/logic/craftTransaction.d.ts.map +1 -1
- package/lib/logic/craftTransaction.js +1 -2
- package/lib/logic/craftTransaction.js.map +1 -1
- package/lib/logic/estimateFees.d.ts.map +1 -1
- package/lib/logic/estimateFees.js +51 -6
- package/lib/logic/estimateFees.js.map +1 -1
- package/lib/logic/estimateRevealLimits.d.ts +2 -2
- package/lib/logic/estimateRevealLimits.d.ts.map +1 -1
- package/lib/logic/estimateRevealLimits.js +3 -3
- package/lib/logic/estimateRevealLimits.js.map +1 -1
- package/lib/logic/getBalance.d.ts.map +1 -1
- package/lib/logic/getBalance.js +2 -3
- package/lib/logic/getBalance.js.map +1 -1
- package/lib/logic/getBlock.js +6 -6
- package/lib/logic/getBlock.js.map +1 -1
- package/lib/logic/getStakes.d.ts +2 -1
- package/lib/logic/getStakes.d.ts.map +1 -1
- package/lib/logic/getStakes.js +8 -9
- package/lib/logic/getStakes.js.map +1 -1
- package/lib/logic/listOperations.d.ts.map +1 -1
- package/lib/logic/listOperations.js +16 -16
- package/lib/logic/listOperations.js.map +1 -1
- package/lib/logic/validateIntent.d.ts.map +1 -1
- package/lib/logic/validateIntent.js +14 -2
- package/lib/logic/validateIntent.js.map +1 -1
- package/lib/network/bakers.d.ts +6 -5
- package/lib/network/bakers.d.ts.map +1 -1
- package/lib/network/bakers.js +13 -12
- package/lib/network/bakers.js.map +1 -1
- package/lib/network/tzkt.d.ts +8 -8
- package/lib/network/tzkt.d.ts.map +1 -1
- package/lib/network/tzkt.js +13 -11
- package/lib/network/tzkt.js.map +1 -1
- package/lib/types/errors.d.ts +3 -0
- package/lib/types/errors.d.ts.map +1 -1
- package/lib/types/errors.js +8 -1
- package/lib/types/errors.js.map +1 -1
- package/lib/utils.d.ts +17 -0
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +31 -1
- package/lib/utils.js.map +1 -1
- package/lib-es/api/index.d.ts +1 -3
- package/lib-es/api/index.d.ts.map +1 -1
- package/lib-es/api/index.js +5 -10
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/logic/craftRawOperations.js +1 -1
- package/lib-es/logic/craftRawOperations.js.map +1 -1
- package/lib-es/logic/craftTransaction.d.ts.map +1 -1
- package/lib-es/logic/craftTransaction.js +1 -2
- package/lib-es/logic/craftTransaction.js.map +1 -1
- package/lib-es/logic/estimateFees.d.ts.map +1 -1
- package/lib-es/logic/estimateFees.js +52 -7
- package/lib-es/logic/estimateFees.js.map +1 -1
- package/lib-es/logic/estimateRevealLimits.d.ts +2 -2
- package/lib-es/logic/estimateRevealLimits.d.ts.map +1 -1
- package/lib-es/logic/estimateRevealLimits.js +3 -3
- package/lib-es/logic/estimateRevealLimits.js.map +1 -1
- package/lib-es/logic/getBalance.d.ts.map +1 -1
- package/lib-es/logic/getBalance.js +2 -3
- package/lib-es/logic/getBalance.js.map +1 -1
- package/lib-es/logic/getBlock.js +6 -6
- package/lib-es/logic/getBlock.js.map +1 -1
- package/lib-es/logic/getStakes.d.ts +2 -1
- package/lib-es/logic/getStakes.d.ts.map +1 -1
- package/lib-es/logic/getStakes.js +8 -9
- package/lib-es/logic/getStakes.js.map +1 -1
- package/lib-es/logic/listOperations.d.ts.map +1 -1
- package/lib-es/logic/listOperations.js +16 -16
- 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 +16 -4
- package/lib-es/logic/validateIntent.js.map +1 -1
- package/lib-es/network/bakers.d.ts +6 -5
- package/lib-es/network/bakers.d.ts.map +1 -1
- package/lib-es/network/bakers.js +13 -12
- package/lib-es/network/bakers.js.map +1 -1
- package/lib-es/network/tzkt.d.ts +8 -8
- package/lib-es/network/tzkt.d.ts.map +1 -1
- package/lib-es/network/tzkt.js +13 -11
- package/lib-es/network/tzkt.js.map +1 -1
- package/lib-es/types/errors.d.ts +3 -0
- package/lib-es/types/errors.d.ts.map +1 -1
- package/lib-es/types/errors.js +6 -0
- package/lib-es/types/errors.js.map +1 -1
- package/lib-es/utils.d.ts +17 -0
- package/lib-es/utils.d.ts.map +1 -1
- package/lib-es/utils.js +29 -0
- package/lib-es/utils.js.map +1 -1
- package/package.json +3 -4
- package/src/api/index.test.ts +32 -0
- package/src/api/index.ts +5 -13
- package/src/logic/craftRawOperations.ts +1 -1
- package/src/logic/craftTransaction.ts +1 -2
- package/src/logic/estimateFees.test.ts +124 -2
- package/src/logic/estimateFees.ts +59 -6
- package/src/logic/estimateRevealLimits.ts +11 -7
- package/src/logic/getBalance.ts +9 -6
- package/src/logic/getBlock.ts +6 -6
- package/src/logic/getStakes.ts +13 -8
- package/src/logic/listOperations.ts +23 -13
- package/src/logic/validateIntent.test.ts +90 -1
- package/src/logic/validateIntent.ts +18 -2
- package/src/network/bakers.integ.test.ts +3 -2
- package/src/network/bakers.test.ts +2 -1
- package/src/network/bakers.ts +15 -13
- package/src/network/tzkt.test.ts +29 -30
- package/src/network/tzkt.ts +38 -23
- package/src/types/errors.ts +7 -0
- package/src/utils.ts +32 -0
package/lib-es/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,sCAAsC;AAKtC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAA;AACzE,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,gBAAg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AI,OAAO,CAAC,IAAI,KAAK,OAAO,CAAA;AACtF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/coin-tezos",
|
|
3
|
-
"version": "10.2.
|
|
3
|
+
"version": "10.2.4",
|
|
4
4
|
"description": "Tezos Coin integration",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ledger",
|
|
@@ -61,11 +61,10 @@
|
|
|
61
61
|
"@taquito/rpc": "^23.0.0-RC.0",
|
|
62
62
|
"@taquito/taquito": "^23.0.0-RC.0",
|
|
63
63
|
"@taquito/utils": "^23.0.0-RC.0",
|
|
64
|
-
"@ledgerhq/coin-module-framework": "^8.
|
|
64
|
+
"@ledgerhq/coin-module-framework": "^8.5.0"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
|
-
"@ledgerhq/live-network": "^3.0.0"
|
|
68
|
-
"@ledgerhq/logs": "^6.17.0"
|
|
67
|
+
"@ledgerhq/live-network": "^3.0.0"
|
|
69
68
|
},
|
|
70
69
|
"devDependencies": {
|
|
71
70
|
"@swc/core": "1.15.11",
|
package/src/api/index.test.ts
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
createSendTransactionIntentMockData,
|
|
9
9
|
createStakingTransactionIntentMockData,
|
|
10
10
|
} from '@ledgerhq/coin-module-framework/test-utils'
|
|
11
|
+
import { MAPPED_TAQUITO_ERRORS } from '../utils'
|
|
11
12
|
import { createApi } from './index'
|
|
12
13
|
|
|
13
14
|
// The tzkt factory `createTzktApi(config)` builds a fresh object on every call, so a spy on a
|
|
@@ -641,6 +642,37 @@ describe('estimateFees', () => {
|
|
|
641
642
|
})
|
|
642
643
|
})
|
|
643
644
|
|
|
645
|
+
it.each(MAPPED_TAQUITO_ERRORS)(
|
|
646
|
+
'should not throw for %s, which validateIntent maps',
|
|
647
|
+
async (id) => {
|
|
648
|
+
logicEstimateFees.mockResolvedValue({
|
|
649
|
+
estimatedFees: DEFAULT_ESTIMATED_FEES,
|
|
650
|
+
gasLimit: DEFAULT_GAS_LIMIT,
|
|
651
|
+
storageLimit: DEFAULT_STORAGE_LIMIT,
|
|
652
|
+
taquitoError: `proto.025-PsUshuai.${id}`,
|
|
653
|
+
})
|
|
654
|
+
const result = await api.estimateFees(
|
|
655
|
+
context,
|
|
656
|
+
createStakingTransactionIntentMockData({
|
|
657
|
+
type: 'stake',
|
|
658
|
+
mode: 'delegate',
|
|
659
|
+
sender: 'tz1test',
|
|
660
|
+
recipient: 'tz1validator',
|
|
661
|
+
amount: 1n,
|
|
662
|
+
valAddress: 'tz1validator',
|
|
663
|
+
})
|
|
664
|
+
)
|
|
665
|
+
|
|
666
|
+
expect(result).toEqual({
|
|
667
|
+
value: DEFAULT_ESTIMATED_FEES,
|
|
668
|
+
parameters: {
|
|
669
|
+
gasLimit: DEFAULT_GAS_LIMIT,
|
|
670
|
+
storageLimit: DEFAULT_STORAGE_LIMIT,
|
|
671
|
+
},
|
|
672
|
+
})
|
|
673
|
+
}
|
|
674
|
+
)
|
|
675
|
+
|
|
644
676
|
it('returns total estimation for unrevealed delegate when minFees applied (composite)', async () => {
|
|
645
677
|
const unrevealedSender = 'tz2TaTpo31sAiX2HBJUTLLdUnqVJR4QjLy1V'
|
|
646
678
|
mockGetAccountByAddress.mockResolvedValueOnce({
|
package/src/api/index.ts
CHANGED
|
@@ -20,7 +20,6 @@ import type {
|
|
|
20
20
|
import { rejectBalanceOptions } from '@ledgerhq/coin-module-framework/api/getBalance/rejectBalanceOptions'
|
|
21
21
|
import { IncorrectTypeError } from '@ledgerhq/coin-module-framework/api/index'
|
|
22
22
|
import { craftTransactionData } from '@ledgerhq/coin-module-framework/logic/craftTransactionData'
|
|
23
|
-
import { log } from '@ledgerhq/logs'
|
|
24
23
|
import { getRevealFee } from '@taquito/taquito'
|
|
25
24
|
import { getPkhfromPk, validatePublicKey, ValidationResult } from '@taquito/utils'
|
|
26
25
|
import {
|
|
@@ -45,6 +44,7 @@ import { createTzktApi } from '../network/tzkt'
|
|
|
45
44
|
import {
|
|
46
45
|
DUST_MARGIN_MUTEZ,
|
|
47
46
|
hasEmptyBalance,
|
|
47
|
+
isMappedTaquitoError,
|
|
48
48
|
normalizePublicKeyForAddress,
|
|
49
49
|
parseTezosTokenAsset,
|
|
50
50
|
resolveTezosOperationMode,
|
|
@@ -304,21 +304,13 @@ async function estimate(
|
|
|
304
304
|
// it's not clear why this happens, it couldn't be further investigated
|
|
305
305
|
// so we fallback to make an estimation without the public key
|
|
306
306
|
// there is a test that covers this, see "fallback to an estimation without the public key" index-mainnet.integ.test.ts
|
|
307
|
-
|
|
307
|
+
context.logger('estimate-error', 'error estimating fees, trying without pubkey', { error })
|
|
308
308
|
estimation = await logicEstimate()
|
|
309
309
|
}
|
|
310
310
|
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
!estimation.taquitoError.includes('subtraction_underflow') &&
|
|
315
|
-
!estimation.taquitoError.includes('balance_too_low') &&
|
|
316
|
-
!estimation.taquitoError.includes('script_rejected') &&
|
|
317
|
-
!estimation.taquitoError.includes(
|
|
318
|
-
'cannot_stake_with_unfinalizable_unstake_requests_to_another_delegate'
|
|
319
|
-
)
|
|
320
|
-
) {
|
|
321
|
-
throw new Error(`Fees estimation failed: ${estimation.taquitoError}`)
|
|
311
|
+
const { taquitoError } = estimation
|
|
312
|
+
if (taquitoError && !isMappedTaquitoError(taquitoError)) {
|
|
313
|
+
throw new Error(`Fees estimation failed: ${taquitoError}`)
|
|
322
314
|
}
|
|
323
315
|
|
|
324
316
|
return {
|
|
@@ -98,7 +98,7 @@ export async function craftRawOperations(
|
|
|
98
98
|
if (getPkhfromPk(normalizedPk) !== sender) {
|
|
99
99
|
throw new Error('craftRawOperations: public key does not match the sender address')
|
|
100
100
|
}
|
|
101
|
-
const reveal = await estimateRevealLimits(tezosToolkit, sender
|
|
101
|
+
const reveal = await estimateRevealLimits(context, tezosToolkit, sender)
|
|
102
102
|
contents.push({
|
|
103
103
|
kind: OpKind.REVEAL,
|
|
104
104
|
source: sender,
|
|
@@ -72,8 +72,7 @@ export async function craftTransaction(
|
|
|
72
72
|
const contents: OperationContents[] = []
|
|
73
73
|
|
|
74
74
|
if (publicKey !== undefined) {
|
|
75
|
-
const
|
|
76
|
-
const reveal = await estimateRevealLimits(tezosToolkit, address, feesConfig)
|
|
75
|
+
const reveal = await estimateRevealLimits(context, tezosToolkit, address)
|
|
77
76
|
|
|
78
77
|
contents.push({
|
|
79
78
|
kind: OpKind.REVEAL,
|
|
@@ -312,7 +312,7 @@ describe('estimateFees', () => {
|
|
|
312
312
|
expect(result.amount).toBe(5000n)
|
|
313
313
|
})
|
|
314
314
|
|
|
315
|
-
it('useAllAmount stake
|
|
315
|
+
it('useAllAmount stake probes above the pseudotoken rate and resolves max to balance minus fees and reserve', async () => {
|
|
316
316
|
const suggestedFee = 700
|
|
317
317
|
const balance = 1_000_000n
|
|
318
318
|
mockTezosToolkit.estimate.stake.mockResolvedValue({
|
|
@@ -334,13 +334,48 @@ describe('estimateFees', () => {
|
|
|
334
334
|
})
|
|
335
335
|
|
|
336
336
|
expect(mockTezosToolkit.estimate.stake).toHaveBeenCalledWith({
|
|
337
|
-
amount:
|
|
337
|
+
amount: 1000,
|
|
338
338
|
mutez: true,
|
|
339
339
|
})
|
|
340
340
|
expect(result.fees).toBe(BigInt(suggestedFee))
|
|
341
341
|
expect(result.amount).toBe(balance - BigInt(suggestedFee) - 10_000n)
|
|
342
342
|
})
|
|
343
343
|
|
|
344
|
+
it('stake with no amount yet returns the fallback estimation without simulating', async () => {
|
|
345
|
+
const result = await estimateFees(context, {
|
|
346
|
+
account: revealedAccount,
|
|
347
|
+
transaction: {
|
|
348
|
+
mode: 'stake',
|
|
349
|
+
recipient: '',
|
|
350
|
+
amount: 0n,
|
|
351
|
+
},
|
|
352
|
+
})
|
|
353
|
+
|
|
354
|
+
expect(mockTezosToolkit.estimate.stake).not.toHaveBeenCalled()
|
|
355
|
+
expect(result.fees).toBe(BigInt(defaultFeesConfig.minEstimatedFees))
|
|
356
|
+
expect(result.estimatedFees).toBe(BigInt(defaultFeesConfig.minEstimatedFees))
|
|
357
|
+
expect(result.gasLimit).toBe(BigInt(defaultFeesConfig.minGasLimit))
|
|
358
|
+
expect(result.storageLimit).toBe(BigInt(defaultFeesConfig.minStorageLimit))
|
|
359
|
+
})
|
|
360
|
+
|
|
361
|
+
it('stake with no amount yet adds the reveal fee to the fallback on unrevealed accounts', async () => {
|
|
362
|
+
const result = await estimateFees(context, {
|
|
363
|
+
account: unrevealedAccount,
|
|
364
|
+
transaction: {
|
|
365
|
+
mode: 'stake',
|
|
366
|
+
recipient: '',
|
|
367
|
+
amount: 0n,
|
|
368
|
+
},
|
|
369
|
+
})
|
|
370
|
+
|
|
371
|
+
expect(mockTezosToolkit.estimate.stake).not.toHaveBeenCalled()
|
|
372
|
+
const expectedRevealFee = BigInt(getRevealFee(unrevealedAccount.address))
|
|
373
|
+
expect(result.fees).toBe(BigInt(defaultFeesConfig.minEstimatedFees))
|
|
374
|
+
expect(result.estimatedFees).toBe(
|
|
375
|
+
BigInt(defaultFeesConfig.minEstimatedFees) + expectedRevealFee
|
|
376
|
+
)
|
|
377
|
+
})
|
|
378
|
+
|
|
344
379
|
it('useAllAmount stake subtracts reveal fee from maxStakable on unrevealed accounts', async () => {
|
|
345
380
|
const suggestedFee = 700
|
|
346
381
|
const balance = 1_000_000n
|
|
@@ -620,6 +655,93 @@ describe('estimateFees', () => {
|
|
|
620
655
|
expect(result.estimatedFees).toBe(BigInt(400 + expectedRevealFee))
|
|
621
656
|
})
|
|
622
657
|
|
|
658
|
+
it('reports a validation-time protocol error as taquitoError instead of throwing', async () => {
|
|
659
|
+
const stakeAmountTooSmall = 'proto.025-PsUshuai.block_validation_plugin.stake_amount_too_small'
|
|
660
|
+
mockTezosToolkit.estimate.stake.mockRejectedValue(
|
|
661
|
+
Object.assign(new Error('Http error response: (500)'), {
|
|
662
|
+
status: 500,
|
|
663
|
+
body: `[{"kind":"permanent","id":"${stakeAmountTooSmall}","amount":"1"}]`,
|
|
664
|
+
})
|
|
665
|
+
)
|
|
666
|
+
|
|
667
|
+
const result = await estimateFees(context, {
|
|
668
|
+
account: revealedAccount,
|
|
669
|
+
transaction: {
|
|
670
|
+
mode: 'stake',
|
|
671
|
+
recipient: '',
|
|
672
|
+
amount: 1n,
|
|
673
|
+
},
|
|
674
|
+
})
|
|
675
|
+
|
|
676
|
+
expect(result.taquitoError).toBe(stakeAmountTooSmall)
|
|
677
|
+
expect(result.fees).toBe(0n)
|
|
678
|
+
})
|
|
679
|
+
|
|
680
|
+
it('picks the mapped id out of a multi-error trace, not the generic one leading it', async () => {
|
|
681
|
+
const scriptRejected = 'proto.025-PsUshuai.michelson_v1.script_rejected'
|
|
682
|
+
mockTezosToolkit.estimate.transfer.mockRejectedValue(
|
|
683
|
+
Object.assign(new Error('Http error response: (500)'), {
|
|
684
|
+
status: 500,
|
|
685
|
+
body: JSON.stringify([
|
|
686
|
+
{ kind: 'temporary', id: 'proto.025-PsUshuai.michelson_v1.runtime_error' },
|
|
687
|
+
{ kind: 'temporary', id: scriptRejected, with: { string: 'nope' } },
|
|
688
|
+
]),
|
|
689
|
+
})
|
|
690
|
+
)
|
|
691
|
+
|
|
692
|
+
const result = await estimateFees(context, {
|
|
693
|
+
account: revealedAccount,
|
|
694
|
+
transaction: {
|
|
695
|
+
mode: 'send',
|
|
696
|
+
recipient: 'tz3Vq38qYD3GEbWcXHMLt5PaASZrkDtEiA8D',
|
|
697
|
+
amount: 1000n,
|
|
698
|
+
},
|
|
699
|
+
})
|
|
700
|
+
|
|
701
|
+
expect(result.taquitoError).toBe(scriptRejected)
|
|
702
|
+
})
|
|
703
|
+
|
|
704
|
+
it('still finds the id when the body is not valid JSON', async () => {
|
|
705
|
+
const stakeAmountTooSmall = 'proto.025-PsUshuai.block_validation_plugin.stake_amount_too_small'
|
|
706
|
+
mockTezosToolkit.estimate.stake.mockRejectedValue(
|
|
707
|
+
Object.assign(new Error('Http error response: (500)'), {
|
|
708
|
+
status: 500,
|
|
709
|
+
body: `[{"kind":"permanent","id":"${stakeAmountTooSmall}","amount":"1"`,
|
|
710
|
+
})
|
|
711
|
+
)
|
|
712
|
+
|
|
713
|
+
const result = await estimateFees(context, {
|
|
714
|
+
account: revealedAccount,
|
|
715
|
+
transaction: {
|
|
716
|
+
mode: 'stake',
|
|
717
|
+
recipient: '',
|
|
718
|
+
amount: 1n,
|
|
719
|
+
},
|
|
720
|
+
})
|
|
721
|
+
|
|
722
|
+
expect(result.taquitoError).toBe(stakeAmountTooSmall)
|
|
723
|
+
})
|
|
724
|
+
|
|
725
|
+
it('rethrows a protocol error the mapping does not cover, so callers can still retry', async () => {
|
|
726
|
+
mockTezosToolkit.estimate.setDelegate.mockRejectedValue(
|
|
727
|
+
Object.assign(new Error('Http error response: (500)'), {
|
|
728
|
+
status: 500,
|
|
729
|
+
body: '[{"kind":"permanent","id":"proto.025-PsUshuai.gas_limit_too_high"}]',
|
|
730
|
+
})
|
|
731
|
+
)
|
|
732
|
+
|
|
733
|
+
await expect(
|
|
734
|
+
estimateFees(context, {
|
|
735
|
+
account: revealedAccount,
|
|
736
|
+
transaction: {
|
|
737
|
+
mode: 'delegate',
|
|
738
|
+
recipient: 'tz1validator',
|
|
739
|
+
amount: 0n,
|
|
740
|
+
},
|
|
741
|
+
})
|
|
742
|
+
).rejects.toThrow('Http error response: (500)')
|
|
743
|
+
})
|
|
744
|
+
|
|
623
745
|
it('send_token (FA2) revealed applies estimation from contract transfer', async () => {
|
|
624
746
|
const { transfer } = setupFa2ContractMock()
|
|
625
747
|
mockTezosToolkit.contract.at.mockResolvedValue({ methods: { transfer } })
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
import type { TezosCoinConfig, TezosContext } from '../config'
|
|
5
5
|
import type { TezosOperationMode } from '../types/model'
|
|
6
6
|
import type { Estimate } from '@taquito/taquito'
|
|
7
|
-
import { log } from '@ledgerhq/logs'
|
|
8
7
|
import { COST_PER_BYTE, getRevealFee, ORIGINATION_SIZE } from '@taquito/taquito'
|
|
9
8
|
import { validatePublicKey, ValidationResult } from '@taquito/utils'
|
|
10
9
|
import { UnsupportedTransactionMode } from '../types/errors'
|
|
@@ -13,10 +12,12 @@ import {
|
|
|
13
12
|
createFallbackEstimation,
|
|
14
13
|
createMockSigner,
|
|
15
14
|
DUST_MARGIN_MUTEZ,
|
|
15
|
+
isMappedTaquitoError,
|
|
16
16
|
MIN_SUGGESTED_FEE_SMALL_TRANSFER,
|
|
17
17
|
OP_SIZE_XTZ_TRANSFER,
|
|
18
18
|
normalizePublicKeyForAddress,
|
|
19
19
|
partitionNativeBalance,
|
|
20
|
+
STAKE_ESTIMATION_PROBE_MUTEZ,
|
|
20
21
|
} from '../utils'
|
|
21
22
|
import { getTezosToolkit } from './tezosToolkit'
|
|
22
23
|
|
|
@@ -106,7 +107,8 @@ export async function estimateFees(
|
|
|
106
107
|
transaction.mode === 'unstake')) ||
|
|
107
108
|
(amount === 0n && transaction.mode !== 'send_token')
|
|
108
109
|
if (coerceMinAmountForEstimation) {
|
|
109
|
-
|
|
110
|
+
// send/stake max or zero-amount pre-estimation (taquito refuses 0); not used for FA2 send_token
|
|
111
|
+
amount = transaction.mode === 'stake' ? STAKE_ESTIMATION_PROBE_MUTEZ : 1n
|
|
110
112
|
}
|
|
111
113
|
|
|
112
114
|
try {
|
|
@@ -119,6 +121,19 @@ export async function estimateFees(
|
|
|
119
121
|
...createFallbackEstimation(config),
|
|
120
122
|
}
|
|
121
123
|
}
|
|
124
|
+
const isStakeWithNoAmountYet =
|
|
125
|
+
transaction.mode === 'stake' && transaction.amount === 0n && !transaction.useAllAmount
|
|
126
|
+
if (isStakeWithNoAmountYet) {
|
|
127
|
+
const fallback = createFallbackEstimation(config)
|
|
128
|
+
const revealFee = account.revealed
|
|
129
|
+
? 0n
|
|
130
|
+
: BigInt(getRevealFeeForEstimation(config, account.address))
|
|
131
|
+
return {
|
|
132
|
+
...estimation,
|
|
133
|
+
...fallback,
|
|
134
|
+
estimatedFees: fallback.estimatedFees + revealFee,
|
|
135
|
+
}
|
|
136
|
+
}
|
|
122
137
|
let estimate: Estimate
|
|
123
138
|
switch (transaction.mode) {
|
|
124
139
|
case 'send':
|
|
@@ -210,7 +225,7 @@ export async function estimateFees(
|
|
|
210
225
|
const incr = DUST_MARGIN_MUTEZ * MINIMAL_FEE_PER_GAS_MUTEZ + Number(estimate.opSize)
|
|
211
226
|
const maxMinusBuff = maxAmount - (DUST_MARGIN_MUTEZ - incr)
|
|
212
227
|
estimation.amount = maxMinusBuff > 0 ? BigInt(maxMinusBuff) : 0n
|
|
213
|
-
|
|
228
|
+
context.logger('tezos-send-max', 'send-max fee inputs', {
|
|
214
229
|
minFees,
|
|
215
230
|
mainOpFee,
|
|
216
231
|
suggestedFeeMutez: estimate.suggestedFeeMutez,
|
|
@@ -240,14 +255,15 @@ export async function estimateFees(
|
|
|
240
255
|
if (typeof e !== 'object' || !e) throw e
|
|
241
256
|
if ('id' in e) {
|
|
242
257
|
estimation.taquitoError = String(e.id)
|
|
243
|
-
|
|
258
|
+
context.logger('taquito-error', 'taquito got error ' + String(e.id))
|
|
244
259
|
} else if ('status' in e) {
|
|
245
260
|
const errorMessage = 'message' in e ? String(e.message) : ''
|
|
261
|
+
const protocolErrorId = mappedProtocolErrorId(e)
|
|
246
262
|
if (
|
|
247
263
|
errorMessage.includes('Public key not found') ||
|
|
248
264
|
errorMessage.includes('wallet or contract API')
|
|
249
265
|
) {
|
|
250
|
-
|
|
266
|
+
context.logger(
|
|
251
267
|
'taquito-network-error',
|
|
252
268
|
'Recipient address not found (new account), using default fees',
|
|
253
269
|
{
|
|
@@ -297,8 +313,14 @@ export async function estimateFees(
|
|
|
297
313
|
// preserve input amount in fallback for readability/tests
|
|
298
314
|
estimation.amount = transaction.amount
|
|
299
315
|
}
|
|
316
|
+
} else if (protocolErrorId) {
|
|
317
|
+
estimation.taquitoError = protocolErrorId
|
|
318
|
+
context.logger(
|
|
319
|
+
'taquito-error',
|
|
320
|
+
'node refused the operation before applying it ' + protocolErrorId
|
|
321
|
+
)
|
|
300
322
|
} else {
|
|
301
|
-
|
|
323
|
+
context.logger('taquito-network-error', errorMessage, {
|
|
302
324
|
transaction: transaction,
|
|
303
325
|
})
|
|
304
326
|
throw e
|
|
@@ -352,6 +374,37 @@ export async function estimateFees(
|
|
|
352
374
|
return estimation
|
|
353
375
|
}
|
|
354
376
|
|
|
377
|
+
/**
|
|
378
|
+
* A protocol error raised while validating an operation comes back as an HTTP error whose body is
|
|
379
|
+
* the raw error array, so Taquito exposes no `id` of its own for `mapTaquitoErrors` to match.
|
|
380
|
+
*
|
|
381
|
+
* Only the ids that mapping covers are reported: any other has to keep propagating, because
|
|
382
|
+
* callers retry on a thrown estimation (see the without-public-key retry in `api/index.ts`).
|
|
383
|
+
*/
|
|
384
|
+
function mappedProtocolErrorId(error: object): string | undefined {
|
|
385
|
+
const body = 'body' in error && typeof error.body === 'string' ? error.body : ''
|
|
386
|
+
const message = 'message' in error ? String(error.message) : ''
|
|
387
|
+
// A trace lists the generic error first and the specific one last, the convention Taquito's
|
|
388
|
+
// own `TezosOperationError.lastError` relies on.
|
|
389
|
+
return protocolErrorIds(body || message)
|
|
390
|
+
.filter(isMappedTaquitoError)
|
|
391
|
+
.at(-1)
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
function protocolErrorIds(text: string): string[] {
|
|
395
|
+
try {
|
|
396
|
+
const parsed: unknown = JSON.parse(text)
|
|
397
|
+
const errors: unknown[] = Array.isArray(parsed) ? parsed : [parsed]
|
|
398
|
+
return errors.flatMap((error) =>
|
|
399
|
+
typeof error === 'object' && error !== null && 'id' in error && typeof error.id === 'string'
|
|
400
|
+
? [error.id]
|
|
401
|
+
: []
|
|
402
|
+
)
|
|
403
|
+
} catch {
|
|
404
|
+
return Array.from(text.matchAll(/"id"\s*:\s*"([^"]+)"/g), (match) => match[1])
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
355
408
|
function getRevealFeeForEstimation(config: TezosCoinConfig, address: string): number {
|
|
356
409
|
const minFees = config.fees.minFees ?? 0
|
|
357
410
|
return Math.max(minFees, getRevealFee(address))
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: © 2026 LEDGER SAS
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import type {
|
|
4
|
+
import type { TezosContext } from '../config'
|
|
5
5
|
import type { getTezosToolkit } from './tezosToolkit'
|
|
6
|
-
import { log } from '@ledgerhq/logs'
|
|
7
6
|
import { getRevealFee, getRevealGasLimit } from '@taquito/taquito'
|
|
8
7
|
|
|
9
8
|
type RevealLimits = { fee: number; gasLimit: number; storageLimit: number }
|
|
@@ -14,19 +13,24 @@ type RevealLimits = { fee: number; gasLimit: number; storageLimit: number }
|
|
|
14
13
|
* (some addresses error with "inconsistent_hash").
|
|
15
14
|
*/
|
|
16
15
|
export async function estimateRevealLimits(
|
|
16
|
+
context: TezosContext,
|
|
17
17
|
tezosToolkit: ReturnType<typeof getTezosToolkit>,
|
|
18
|
-
address: string
|
|
19
|
-
feesConfig: TezosConfig['fees']
|
|
18
|
+
address: string
|
|
20
19
|
): Promise<RevealLimits> {
|
|
20
|
+
const { fees: feesConfig } = await context.config()
|
|
21
21
|
type RevealEstimate = { gasLimit?: number; storageLimit?: number; suggestedFeeMutez?: number }
|
|
22
22
|
let revealEstimate: RevealEstimate | undefined
|
|
23
23
|
try {
|
|
24
24
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
25
25
|
revealEstimate = (await tezosToolkit.estimate.reveal()) as RevealEstimate | undefined
|
|
26
26
|
} catch (error) {
|
|
27
|
-
|
|
28
|
-
error,
|
|
29
|
-
|
|
27
|
+
context.logger(
|
|
28
|
+
'estimate-error',
|
|
29
|
+
'error estimating reveal fees, trying to use getRevealGasLimit',
|
|
30
|
+
{
|
|
31
|
+
error,
|
|
32
|
+
}
|
|
33
|
+
)
|
|
30
34
|
revealEstimate = {
|
|
31
35
|
gasLimit: getRevealGasLimit(address),
|
|
32
36
|
suggestedFeeMutez: getRevealFee(address),
|
package/src/logic/getBalance.ts
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
import type { TezosContext } from '../config'
|
|
5
5
|
import type { Balance } from '@ledgerhq/coin-module-framework/api/index'
|
|
6
|
-
import { log } from '@ledgerhq/logs'
|
|
7
6
|
import { hasManagerKey } from '../network/types'
|
|
8
7
|
import { createTzktApi } from '../network/tzkt'
|
|
9
8
|
import { partitionNativeBalance } from '../utils'
|
|
@@ -60,14 +59,18 @@ export async function getBalance(context: TezosContext, address: string): Promis
|
|
|
60
59
|
const normalized = BigInt(apiAccount.balance)
|
|
61
60
|
|
|
62
61
|
const unstakeRequests = await fetchUnstakeRequests(config, address, apiAccount).catch((error) => {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
context.logger(
|
|
63
|
+
'coin:tezos',
|
|
64
|
+
'getBalance: fetchUnstakeRequests failed; degrading stakes to []',
|
|
65
|
+
{
|
|
66
|
+
error,
|
|
67
|
+
address,
|
|
68
|
+
}
|
|
69
|
+
)
|
|
67
70
|
return []
|
|
68
71
|
})
|
|
69
72
|
|
|
70
|
-
const stakes = buildStakesForAccount(address, apiAccount, unstakeRequests)
|
|
73
|
+
const stakes = buildStakesForAccount(context.logger, address, apiAccount, unstakeRequests)
|
|
71
74
|
const stakedBalance = BigInt(apiAccount.stakedBalance ?? 0)
|
|
72
75
|
const unstakedBalance = BigInt(apiAccount.unstakedBalance ?? 0)
|
|
73
76
|
const { locked } = partitionNativeBalance(normalized, stakedBalance, unstakedBalance)
|
package/src/logic/getBlock.ts
CHANGED
|
@@ -534,12 +534,12 @@ export async function getBlock(context: TezosContext, height: number): Promise<B
|
|
|
534
534
|
] = await Promise.all([
|
|
535
535
|
tzkt.getBlockByLevel(height),
|
|
536
536
|
tzkt.getBlockByLevel(height - 1),
|
|
537
|
-
fetchBlockTransactions(
|
|
538
|
-
fetchBlockTokenTransfers(
|
|
539
|
-
fetchBlockDelegations(
|
|
540
|
-
fetchBlockStaking(
|
|
541
|
-
fetchBlockOriginations(
|
|
542
|
-
fetchBlockReveals(
|
|
537
|
+
fetchBlockTransactions(context, height),
|
|
538
|
+
fetchBlockTokenTransfers(context, height),
|
|
539
|
+
fetchBlockDelegations(context, height),
|
|
540
|
+
fetchBlockStaking(context, height),
|
|
541
|
+
fetchBlockOriginations(context, height),
|
|
542
|
+
fetchBlockReveals(context, height),
|
|
543
543
|
])
|
|
544
544
|
|
|
545
545
|
// Token transfers triggered by originations from other blocks carry an
|
package/src/logic/getStakes.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import type { TezosCoinConfig, TezosContext } from '../config'
|
|
5
5
|
import type { APIAccount, APIManagerAccount, APIUnstakeRequest } from '../network/types'
|
|
6
6
|
import type { Cursor, Page, Stake } from '@ledgerhq/coin-module-framework/api/types'
|
|
7
|
-
import {
|
|
7
|
+
import type { Logger } from '@ledgerhq/coin-module-framework/config'
|
|
8
8
|
import { hasManagerKey } from '../network/types'
|
|
9
9
|
import { createTzktApi } from '../network/tzkt'
|
|
10
10
|
import { partitionNativeBalance } from '../utils'
|
|
@@ -28,17 +28,21 @@ export function fetchUnstakeRequests(
|
|
|
28
28
|
: Promise.resolve([])
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
function unstakeRequestToStake(
|
|
31
|
+
function unstakeRequestToStake(
|
|
32
|
+
logger: Logger,
|
|
33
|
+
address: string,
|
|
34
|
+
req: APIUnstakeRequest
|
|
35
|
+
): Stake | null {
|
|
32
36
|
// TzKT's status filter is unreliable; never build a position for a finalized request.
|
|
33
37
|
if (req.status !== 'pending' && req.status !== 'finalizable') {
|
|
34
|
-
|
|
38
|
+
logger('coin:tezos', 'unstakeRequestToStake: dropping non-active unstake request', {
|
|
35
39
|
requestId: req.id,
|
|
36
40
|
status: req.status,
|
|
37
41
|
})
|
|
38
42
|
return null
|
|
39
43
|
}
|
|
40
44
|
if (req.actualAmount <= 0) {
|
|
41
|
-
|
|
45
|
+
logger('coin:tezos', 'unstakeRequestToStake: dropping non-positive unstake request', {
|
|
42
46
|
requestId: req.id,
|
|
43
47
|
actualAmount: req.actualAmount,
|
|
44
48
|
})
|
|
@@ -46,7 +50,7 @@ function unstakeRequestToStake(address: string, req: APIUnstakeRequest): Stake |
|
|
|
46
50
|
}
|
|
47
51
|
const createdAt = new Date(req.firstTime)
|
|
48
52
|
if (!Number.isFinite(createdAt.getTime())) {
|
|
49
|
-
|
|
53
|
+
logger('coin:tezos', 'unstakeRequestToStake: dropping unstake request with invalid firstTime', {
|
|
50
54
|
requestId: req.id,
|
|
51
55
|
firstTime: req.firstTime,
|
|
52
56
|
})
|
|
@@ -67,6 +71,7 @@ function unstakeRequestToStake(address: string, req: APIUnstakeRequest): Stake |
|
|
|
67
71
|
}
|
|
68
72
|
|
|
69
73
|
export function buildStakesForAccount(
|
|
74
|
+
logger: Logger,
|
|
70
75
|
address: string,
|
|
71
76
|
account: APIManagerAccount,
|
|
72
77
|
unstakeRequests: APIUnstakeRequest[]
|
|
@@ -80,7 +85,7 @@ export function buildStakesForAccount(
|
|
|
80
85
|
|
|
81
86
|
const unstakeStakes: Stake[] = []
|
|
82
87
|
for (const req of unstakeRequests) {
|
|
83
|
-
const stake = unstakeRequestToStake(address, req)
|
|
88
|
+
const stake = unstakeRequestToStake(logger, address, req)
|
|
84
89
|
if (stake) unstakeStakes.push(stake)
|
|
85
90
|
}
|
|
86
91
|
|
|
@@ -93,7 +98,7 @@ export function buildStakesForAccount(
|
|
|
93
98
|
unstakedBalance
|
|
94
99
|
)
|
|
95
100
|
if (locked < stakedBalance + unstakedBalance) {
|
|
96
|
-
|
|
101
|
+
logger('coin:tezos', 'buildStakesForAccount: balance < staked + unstaked, clamping to 0', {
|
|
97
102
|
address,
|
|
98
103
|
balance: balance.toString(),
|
|
99
104
|
stakedBalance: stakedBalance.toString(),
|
|
@@ -137,5 +142,5 @@ export async function getStakes(
|
|
|
137
142
|
const accountInfo = await createTzktApi(config).getAccountByAddress(address)
|
|
138
143
|
if (!hasManagerKey(accountInfo)) return { items: [] }
|
|
139
144
|
const unstakeRequests = await fetchUnstakeRequests(config, address, accountInfo)
|
|
140
|
-
return { items: buildStakesForAccount(address, accountInfo, unstakeRequests) }
|
|
145
|
+
return { items: buildStakesForAccount(context.logger, address, accountInfo, unstakeRequests) }
|
|
141
146
|
}
|