-
Notifications
You must be signed in to change notification settings - Fork 869
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(wallet): migrate 0x Swap API to v2 #26231
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
++
@@ -448,74 +448,71 @@ union SwapTransactionParamsUnion { | |||
|
|||
union SwapQuoteUnion { | |||
JupiterQuote jupiter_quote; | |||
ZeroExQuote zero_ex_quote; | |||
ZeroExQuoteInfo zero_ex_quote; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we change this to zero_ex_quote_info
to distinguish from ZeroExQuote
? it seems ZeroExQuoteInfo
now contains an optional of ZeroExQuote
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The refactoring here should fix this.
// 0x specific validations | ||
if (quoteUnion?.zeroExQuote?.liquidityAvailable === false) { | ||
return 'insufficientLiquidity' | ||
} | ||
|
||
if (quoteErrorUnion?.zeroExError) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, shouldn't quoteErrorUnion.zeroExError. isInsufficientLiquidity == true
?
checking both QuoteUnion
and QuoteErrorUnion
for errors seems odd to me. Also the quoteErrorUnion.zeroExError.isInsufficientAllowance
case seems to be ignored.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was actually done because 0x API v2 now returns isInsufficientLiquidity
as part of the quote instead of an error response. But now that I think about it, retaining the old interface is cleaner. You can find this change here: review(nuo-xu): reuse ZeroExQuote and drop ZeroExQuoteInfo struct
Also the quoteErrorUnion.zeroExError.isInsufficientAllowance case seems to be ignored
Allowance checks are no longer returned as part of the error response from the API. If this changes in future, will add this back. Meanwhile, the desktop code already handles allowance checks just like LiFi and Squid.
1471c24
to
1bbee57
Compare
[puLL-Merge] - brave/brave-core@26231 DescriptionThis PR updates the implementation of the 0x (ZeroEx) swap functionality in the Brave Wallet. It adapts the code to use a new version of the 0x API, which includes changes in the request and response formats, as well as modifications to the supported networks and the way fees are handled. ChangesChanges
Possible Issues
Security Hotspots
These changes represent a significant update to the 0x integration in the Brave Wallet. Careful testing across all supported networks and with various token combinations is recommended to ensure the swap functionality works as expected with the new API version. |
A Storybook has been deployed to preview UI for the latest push |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wallet core lgtm
Resolves brave/brave-browser#41891
Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
wikinpm run presubmit
wiki,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan:
See STR in linked issue