[LWDM] fix(coin-tezos): reserve the reported fee in send-max (LIVE-28506) - #20292
[LWDM] fix(coin-tezos): reserve the reported fee in send-max (LIVE-28506)#20292amaslakov wants to merge 2 commits into
Conversation
Web Tools Build Status
|
Rsdoctor Bundle Diff AnalysisFound 7 projects in monorepo, 3 projects with changes. 📊 Quick Summary
📋 Detailed Reports (Click to expand)📁 desktop-preloaderPath:
📁 desktop-rendererPath:
📦 Download Diff Report: desktop-renderer Bundle Diff 📁 mobilePath:
Generated by Rsdoctor GitHub Action |
c146f6a to
9a32a74
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Suppressed comments (6)
libs/coin-tester-modules/coin-tester-tezos/src/scenarii/tezos.ts:291
- Same as above: the comment mentions
DUST_MARGIN_MUTEZbut the assertion hardcodes500, which can drift from the real dust margin. Prefer a named constant (or import) to keep this resilient.
// Send-max leaves the dust margin behind (DUST_MARGIN_MUTEZ, less the fee-per-gas/op-size
// increment), independently of how the `minFees` floor compares to the suggested fee.
expect(account.balance.toNumber()).toBeLessThanOrEqual(500);
.changeset/lucky-otters-wander.md:2
- This changeset describes a bug fix (send-max validation when
minFeesexceeds the estimate). That should typically be a patch release for@ledgerhq/coin-tezos, consistent with other coin-tezos fixes (e.g..changeset/tezos-baker-delegate-account-support.md).
"@ledgerhq/coin-tezos": minor
libs/coin-modules/coin-tezos/src/logic/estimateFees.test.ts:831
- This test title uses
%iforbalance, butbalanceis a BigInt in the table. Using%savoids implicitNumber()coercion (and potential precision loss if larger balances get added later).
"useAllAmount send reserves the reported fee (balance=%i, minFees=%i, suggested=%i, burn=%i)",
libs/coin-modules/coin-tezos/src/logic/estimateFees.ts:210
- The new
log("tezos-send-max", ...)runs on every send-max estimation (happy path) and can create noisy/high-volume logs in production. Unless this is intentionally permanent telemetry, it should be removed or gated behind a debug flag.
log("tezos-send-max", "send-max fee inputs", {
minFees,
mainOpFee,
suggestedFeeMutez: estimate.suggestedFeeMutez,
burnFeeMutez: estimate.burnFeeMutez,
opSize: Number(estimate.opSize),
revealFee: Number(revealFee),
});
libs/coin-modules/coin-tezos/src/logic/estimateFees.ts:189
- This newly added block comment is quite detailed and risks going stale. Per repo comment guidance, prefer a concise comment that links to the ticket and let the code/tests carry the rest of the explanation.
// Reserve `mainOpFee`, not the raw taquito suggestion: `estimatedFees` below reports the
// `minFees` floor, so subtracting the (lower) suggestion here yields an amount whose
// `amount + estimatedFees` exceeds the spendable balance, and validateIntent then rejects
// the very max it was handed (LIVE-28506).
libs/coin-tester-modules/coin-tester-tezos/src/scenarii/tezos.ts:200
- This assertion references
DUST_MARGIN_MUTEZin the comment but hardcodes500in code. That makes the test brittle if the dust margin changes; consider naming the constant (or importing it) so the code and comment stay aligned.
This issue also appears on line 289 of the same file.
// Send-max leaves the dust margin behind (DUST_MARGIN_MUTEZ, less the fee-per-gas/op-size
// increment), independently of how the `minFees` floor compares to the suggested fee.
expect(account.balance.toNumber()).toBeLessThanOrEqual(500);
|



📝 Description
Previous behaviour: Use max on a Tezos account fails with "Sorry, insufficient funds" when the remote minFees config is ≥ 788 mutez, regardless of balance.
Root cause: estimateFees reports mainOpFee = max(minFees, suggestedFee) but the send-max path subtracted the raw (lower) suggestedFee when computing the amount, so amount + reportedFee > spendable and validateIntent rejects it.
Fix: use mainOpFee in the send-max totalFees expression. Unit test and coin-tester scenario added to cover the regression.
🔗 Context