Add makeMaxSpend to ethereum and ton engines - #1061
Open
j0ntz wants to merge 1 commit into
Open
Conversation
Implement the makeMaxSpend engine method on EthereumEngine and TonEngine. It computes the maximum spendable amount and builds the transaction back-to-back inside the engine so network state and fee pricing stay consistent between the two steps, avoiding the race that affects separate getMaxSpendable and makeSpend calls.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CHANGELOG
Does this branch warrant an entry to the CHANGELOG?
Dependencies
Pairs with the new
EdgeCurrencyEngine.makeMaxSpendengine method in edge-core-js (EdgeApp/edge-core-js#727). The engine method is optional, so this PR is independent: the core only calls it once that change ships; until then the core fallback shim handles max spends.Description
Implement the
makeMaxSpendengine method onEthereumEngineandTonEngine. It computes the maximum spendable amount and builds the transaction back-to-back inside the engine, so network state and fee pricing stay consistent between the two steps. This avoids the race that affects separategetMaxSpendableandmakeSpendcalls (for Ethereum it also reuses the L1 fee pricinggetMaxSpendablecaches formakeSpend).Asana: https://app.asana.com/0/1215088146871429/1207967192999590
Testing
npm run types(tsc): the change introduces no new type errors (verified by comparing error counts on the base branch vs this branch — both 15, all pre-existing and unrelated, from the locally-installed olderedge-core-jsandreact-native-moneronot being present; CI installs fresh dependencies).makeMaxSpendwallet API (see Add makeMaxSpend wallet API with core fallback shim edge-core-js#727); the engine method here mirrors that already-testedgetMaxSpendable+makeSpendlogic.Note
Medium Risk
Touches core send paths for native max spends on Ethereum (fees, rollups, caching) and TON; behavior should match the prior two-step flow but any mismatch would affect full-balance sends.
Overview
Adds optional
makeMaxSpendonEthereumEngineandTonEngine, pairing with edge-core-js’s wallet API so max-send is one engine call instead of separategetMaxSpendable+makeSpend.Each implementation calls
getMaxSpendable, sets the first spend target’snativeAmountto that value, thenmakeSpendimmediately. On Ethereum the comment notes this keeps L1 fee pricing aligned vialastMaxSpendablecaching between the two steps; on TON it avoids balance/fee drift between queries.CHANGELOG Unreleased documents the addition for ethereum and ton.
Reviewed by Cursor Bugbot for commit 47e400d. Bugbot is set up for automated code reviews on this repo. Configure here.