Add core-side synthetic destination for swap-to-address#724
Open
j0ntz wants to merge 1 commit into
Open
Conversation
Contributor
Author
2f9a0fa to
0a8c8b9
Compare
Contributor
Author
|
Both addressed in 0a8c8b9:
|
0a8c8b9 to
5ee8085
Compare
Contributor
Author
|
Both addressed in 5ee8085:
|
6 tasks
Let account.fetchSwapQuotes accept an optional toAddressInfo descriptor (toPluginId, toTokenId, toAddress) as an alternative to a destination toWallet. The core validates exactly one of the two, then builds a synthetic, bridgified EdgeCurrencyWallet from the descriptor, backed by the real currencyConfig it already holds. getAddresses and getReceiveAddress return the pasted address; currencyInfo and currencyConfig.allTokens come from the real plugin config. Swap plugins receive an EdgeCurrencyWallet unchanged. Make EdgeTxActionSwap.payoutWalletId optional, since a swap-to-address destination has no payout wallet. A bridge-crossing proof test stands up the production yaob wire format (makeLocalBridge with a JSON cloneMessage): the GUI passes only the descriptor, the core builds the synthetic destination, and a plugin-faithful consumer reads a working address, token, and currency info through the bridge. This inverts the Phase 1 failure where a GUI-built fake wallet could not cross the bridge.
5ee8085 to
bfcfcbb
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit bfcfcbb. Configure here.
| return { | ||
| ...request, | ||
| toWallet: makeSyntheticDestinationWallet(currencyConfig, toAddress) | ||
| } |
There was a problem hiding this comment.
Resolved swap request breaks re-quote
Medium Severity
When toAddressInfo is resolved, the core adds a synthetic toWallet but leaves toAddressInfo on the same EdgeSwapRequest. Quotes that echo that request then carry both fields, so a later fetchSwapQuotes call with quote.request fails the “exactly one of toWallet or toAddressInfo” check.
Reviewed by Cursor Bugbot for commit bfcfcbb. Configure here.
6 tasks
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
none
Description
Phase A of swap-to-address ("private send"): let a swap target a pasted destination address instead of a destination wallet, without touching swap plugins.
account.fetchSwapQuotesnow accepts an optionaltoAddressInfodescriptor (toPluginId,toTokenId,toAddress) onEdgeSwapRequestas an alternative totoWallet. Exactly one of the two is required. WhentoAddressInfois supplied, the core builds a synthetic, bridgifiedEdgeCurrencyWallet-shaped destination from it, backed by the realcurrencyConfigthe core already holds:currencyInfoandcurrencyConfig.allTokensare authentic, andgetAddresses/getReceiveAddressreturn the pasted address. Plugins receive anEdgeCurrencyWalletunchanged.Building the destination core-side and bridgifying it there is what makes this work. A GUI-built fake wallet cannot cross the yaob bridge (its function properties pack as
'?'and the receiver throws on argument unpack), which the Phase 1 spike proved. A plain-data descriptor crosses fine, and the synthetic, bridgified core-side, survives the wire format both ways.EdgeTxActionSwap.payoutWalletIdbecomes optional, since a swap-to-address destination has no payout wallet (payoutAddressalready carries the destination).The mechanism is provider-agnostic; nothing here is Houdini-specific.
Test
test/core/synthetic-wallet.test.tsis the core acceptance: it stands up the production yaob wire format (makeLocalBridgewith a JSONcloneMessage), has the GUI side pass only the descriptor, builds the synthetic destination core-side, and a plugin-faithful consumer reads a working address, token, and currency info through the bridge. It also calls the returned synthetic back across the bridge, the direct inverse of the Phase 1 failure.tscclean,mocha164 passing.edge-exchange-pluginsPR Loosen constraint for checking tx confirmation status #461 (jon/houdini-swap), a BTC to ETH quote and exchange order drives through the actual HoudiniSwap plugin with an address-only synthetic destination (replayed from cached fixtures, no live API). The pasted address flows through topayoutAddress, withpayoutWalletIdset to the synthetic id.edge-react-gui, a real BTC to ETH swap to a pasted ETH address (~60 USD) was driven through the address-only path (toAddressInfo, no destination wallet). The core built the synthetic destination, HoudiniSwap quoted it, and the swap executed to the in-app success scene. Proof screenshots attached.Follow-ups for a GUI integration
payoutWalletIdbecoming optional touchessavedActionconsumers inedge-react-gui; sweep those before relying on it in production.toWalletbefore enabling the synthetic destination for that provider.parseUrionEdgeCurrencyConfigis the post-MVP generalization).Asana: https://app.asana.com/0/1215088146871429/1215645666041229
Note
Medium Risk
Changes the swap request contract and quote path; plugins still receive
toWallet, but GUI andsavedActioncode must handle optionalpayoutWalletIdand synthetic wallet ids.Overview
Adds swap-to-address (e.g. private send):
EdgeSwapRequestcan usetoAddressInfo(toPluginId,toAddress) instead oftoWallet, with exactly one required.fetchSwapQuotesresolves the destination throughresolveSwapRequest, which validates the plugin/token and substitutes a core-built, bridgified syntheticEdgeCurrencyWalletso existing swap plugins still see a normaltoWallet.New
makeSyntheticDestinationWalletuses realcurrencyConfig, synthetic ids undersynthetic://, and address-onlygetAddresses/getReceiveAddress. Swap logging redacts pasted destination addresses.EdgeTxActionSwap.payoutWalletIdis optional (cleaner updated);SwapCurrencyErrorresolves the destination plugin fromtoWalletortoAddressInfo. Tests cover bridge round-trip behavior for the synthetic wallet.Reviewed by Cursor Bugbot for commit bfcfcbb. Bugbot is set up for automated code reviews on this repo. Configure here.