brave-core icon indicating copy to clipboard operation
brave-core copied to clipboard

Buy & Sell Meld Core Integration

Open vadimstruts opened this issue 2 years ago • 19 comments

Resolves https://github.com/brave/brave-browser/issues/37312

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:

  • [ ] The associated issue milestone is set to the smallest version that the changes has landed on
  • [ ] All relevant documentation has been updated, for instance:
    • [ ] https://github.com/brave/brave-browser/wiki/Deviations-from-Chromium-(features-we-disable-or-remove)
    • [ ] https://github.com/brave/brave-browser/wiki/Proxy-redirected-URLs
    • [ ] https://github.com/brave/brave-browser/wiki/Fingerprinting-Protections
    • [ ] https://github.com/brave/brave-browser/wiki/Brave%E2%80%99s-Use-of-Referral-Codes
    • [ ] https://github.com/brave/brave-browser/wiki/Web-Compatibility-Exceptions-in-Brave
    • [ ] https://github.com/brave/brave-browser/wiki/QA-Guide
    • [ ] https://github.com/brave/brave-browser/wiki/P3A

Test Plan:

vadimstruts avatar Apr 09 '24 08:04 vadimstruts

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

brave-builds avatar Apr 10 '24 00:04 brave-builds

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

brave-builds avatar Apr 10 '24 11:04 brave-builds

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

brave-builds avatar Apr 10 '24 21:04 brave-builds

This PR needs S/P review

supermassive avatar Apr 11 '24 03:04 supermassive

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

brave-builds avatar Apr 22 '24 15:04 brave-builds

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

brave-builds avatar Apr 22 '24 17:04 brave-builds

@vadimstruts Looks like the PR does a lot of work on UI thread (parsing the data from APIRequestHelper, processing data in Rust) Are there any reasonable limits for the data size and the elapsed time? Otherwise it could hangs UI thread ..

atuchin-m avatar Apr 22 '24 18:04 atuchin-m

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

brave-builds avatar Apr 22 '24 19:04 brave-builds

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

brave-builds avatar Apr 23 '24 18:04 brave-builds

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

brave-builds avatar Apr 25 '24 13:04 brave-builds

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

brave-builds avatar Apr 25 '24 20:04 brave-builds

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

brave-builds avatar Apr 26 '24 08:04 brave-builds

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

brave-builds avatar Apr 26 '24 11:04 brave-builds

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

brave-builds avatar Apr 29 '24 23:04 brave-builds

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

brave-builds avatar Apr 30 '24 13:04 brave-builds

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

brave-builds avatar May 01 '24 17:05 brave-builds

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

brave-builds avatar May 09 '24 23:05 brave-builds

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

brave-builds avatar May 10 '24 09:05 brave-builds

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

Here is my review of the pull request:

Description

This PR adds a new MeldIntegrationService to the Brave wallet. The service integrates with the Meld API to provide functionality like getting supported service providers, crypto quotes, payment methods, fiat/crypto currencies, and countries. It adds the necessary factory, service, and parser classes to interact with the Meld API.

The motivation appears to be integrating the Brave wallet with the Meld crypto onramp service to allow purchasing crypto directly from the wallet.

Changes

Changes

  • Adds MeldIntegrationService class to handle communication with Meld API
  • Adds MeldIntegrationServiceFactory to manage the service lifetime
  • Adds MeldIntegrationResponseParser to parse the JSON responses from the API
  • Defines new Mojo interfaces in meld_integration.mojom for the Meld service
  • Hooks up the service in the wallet UI code and on iOS
  • Adds comprehensive unit tests for the new service and parser
  • Enables removing null values when sanitizing JSON responses

The main changes are well organized by the new files added for the Meld service. The parsing logic is separated out well. Mojo is used appropriately to communicate between the UI and browser process.

Possible Issues

No major issues noted. The PR adds a substantial amount of new code but it is structured logically and has good test coverage. Some possible nits:

  • Some of the parsing code in MeldIntegrationResponseParser has a decent amount of duplication that could potentially be refactored
  • A few of the API response fields are defined as optional but it's unclear if that matches the API spec or if they should always be required
  • Some longer lines could be wrapped to stay under 80 chars for consistency

But overall the code looks thought-out and robust. The use of optional fields and error handling shows good attention to dealing with unexpected API responses.

Security Hotspots

None found. The network requests are simple GETs and POSTs of non-sensitive data. Responses are parsed cautiously with error handling. No user input is used in the requests besides simple identifiers. HTTPS is used for all requests.

github-actions[bot] avatar May 15 '24 21:05 github-actions[bot]

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

brave-builds avatar May 15 '24 22:05 brave-builds