Skip to content
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): add squid to cross-chain swap providers #25676

Merged
merged 7 commits into from
Oct 14, 2024
Merged

Conversation

onyb
Copy link
Member

@onyb onyb commented Sep 20, 2024

Resolves brave/brave-browser#41049

Submitter Checklist:

  • I confirm that no security/privacy review is needed and no other type of reviews are needed, or that I have requested them
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Squashed any review feedback or "fixup" commits before merge, so that history is a record of what happened in the repo, not your PR
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally:
    • npm run test -- brave_browser_tests, npm run test -- brave_unit_tests wiki
    • npm run presubmit wiki, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

  1. Open Swap / Bridge
  2. Select Squid as the provider
  3. Select source and destination tokens
  4. Enter a "from" amount

User should be able to see a quote from Squid Router, create a transaction, and confirm it on the blockchain.

@onyb onyb self-assigned this Sep 20, 2024
@onyb onyb requested review from a team as code owners September 20, 2024 16:47
@github-actions github-actions bot added CI/storybook-url Deploy storybook and provide a unique URL for each build feature/web3/wallet feature/web3/wallet/core puLL-Merge labels Sep 20, 2024
Copy link
Contributor

@nuo-xu nuo-xu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iOS++
iOS build failed due to formatting errors.

Copy link
Collaborator

@supermassive supermassive left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wallet core lgtm

Copy link
Contributor

[puLL-Merge] - brave/brave-core@25676

Description

This pull request introduces support for the Squid swap provider in the Brave Wallet. It adds new functionality to handle Squid quotes and transactions, updates the UI to include Squid as a swap option, and modifies existing components to integrate Squid into the swap flow.

Changes

Changes

  1. components/brave_wallet/browser/brave_wallet_constants.h:

    • Added a constant for the Squid API base URL.
  2. components/brave_wallet/browser/eth_data_parser.cc:

    • Implemented parsing for Squid-specific function selectors and transaction data.
  3. components/brave_wallet/browser/swap_request_helper.cc and swap_request_helper.h:

    • Added functions to encode Squid quote and transaction parameters.
  4. components/brave_wallet/browser/swap_response_parser.cc and swap_response_parser.h:

    • Implemented parsing for Squid quote and transaction responses.
  5. components/brave_wallet/browser/swap_service.cc and swap_service.h:

    • Added support for Squid in the swap service, including quote and transaction handling.
  6. components/brave_wallet/common/brave_wallet.mojom:

    • Updated to include Squid-specific types and structures.
  7. components/brave_wallet_ui/:

    • Added Squid to the list of supported swap providers.
    • Implemented a new useSquid hook for handling Squid swaps.
    • Updated the swap UI to include Squid as an option.
    • Added Squid logo and updated metadata.

Possible Issues

  • The integration of a new swap provider might introduce complexity in maintaining consistency across different providers.
  • There might be edge cases in the Squid transaction parsing that are not fully covered.

Security Hotspots

  1. In eth_data_parser.cc, the parsing of Squid transaction data involves handling user input. Ensure proper validation and sanitization are in place to prevent potential injection attacks.
  2. The new API endpoint (kSquidBaseAPIURL) in brave_wallet_constants.h should be properly secured and use HTTPS.
  3. In swap_service.cc, ensure that the Squid transaction parameters are properly validated before sending to prevent potential manipulation of transaction data.

This PR significantly expands the swap capabilities of the Brave Wallet by adding support for the Squid protocol. It requires careful testing to ensure compatibility with existing swap providers and to verify the correctness of Squid-specific operations.

@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

Copy link
Contributor

@Douglashdaniel Douglashdaniel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++

@onyb onyb enabled auto-merge (squash) October 14, 2024 16:31
@onyb onyb merged commit 065115c into master Oct 14, 2024
17 checks passed
@onyb onyb deleted the f/wallet/squid branch October 14, 2024 20:58
@github-actions github-actions bot added this to the 1.73.x - Nightly milestone Oct 14, 2024
@brave-builds
Copy link
Collaborator

Released in v1.73.11

@bsclifton bsclifton removed this from the 1.73.x - Nightly milestone Nov 6, 2024
@bsclifton bsclifton added this to the 1.74.x - Nightly milestone Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI/storybook-url Deploy storybook and provide a unique URL for each build feature/web3/wallet/core feature/web3/wallet puLL-Merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integrate Squid Router to Swap and Bridge
6 participants