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

Introduces FetchBalanceResult. #17480

Merged

Conversation

szilardszaloki
Copy link
Collaborator

@szilardszaloki szilardszaloki commented Mar 6, 2023

Resolves brave/brave-browser#28793.

This PR introduces the base::expected<>-style API for the fetch balance flow, which makes it easier to add new error conditions on the backend (or fine-tune any existing ones), and to reflect them in the UI.

The rest of the external wallet provider flows (connect external wallet, get external wallet) already leverage base::expected<>-style APIs, except for external wallet transactions (BitFlyerTransfer, GeminiTransfer, UpholdTransfer), which go through the contribution engine.

Submitter Checklist:

  • I confirm that no security/privacy review is needed, or that I have requested one
  • 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 lint, 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:

Before enabling Rewards, there's no balance info displayed on Rewards Internals anymore:
image
After enabling Rewards but before connecting a custodial wallet service, we only display vBAT balance on Rewards Internals (and the Connect account UI on the Rewards page/Rewards panel/Rewards NTP widget):
image
After connecting a custodial wallet service, we display both the vBAT/external wallet balance on Rewards Internals (and show the total balance on the Rewards page/Rewards panel/Rewards NTP widget):
image
In the logged out state, we only show vBAT balance on Rewards Internals (and the Logged out UI on the Rewards page/Rewards panel/Rewards NTP widget, including the tipping banner — :( You are currently logged out.):
image
On an error coming from a custodial wallet service balance endpoint, we show a spinner for both the vBAT/external wallet balance on Rewards Internals (and a spinner on the Rewards page/Rewards panel/Rewards NTP widget, except for the tipping banner, where we show the Server connection error UI):
image

@szilardszaloki szilardszaloki requested a review from a team as a code owner March 6, 2023 05:29
@github-actions github-actions bot added the CI/storybook-url Deploy storybook and provide a unique URL for each build label Mar 6, 2023
@szilardszaloki szilardszaloki force-pushed the sszaloki-28793-audit-network-errors-and-their-ui-effects branch 2 times, most recently from 9ba926d to 67339ce Compare March 6, 2023 20:50
Copy link
Contributor

@emerick emerick left a comment

Choose a reason for hiding this comment

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

LGTM

@szilardszaloki szilardszaloki force-pushed the sszaloki-28793-audit-network-errors-and-their-ui-effects branch 6 times, most recently from 018c059 to 8f15a41 Compare March 7, 2023 18:10
@brave-builds
Copy link
Collaborator

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

@szilardszaloki szilardszaloki force-pushed the sszaloki-28793-audit-network-errors-and-their-ui-effects branch 2 times, most recently from cf4fbea to 1018d93 Compare March 7, 2023 20:12
@brave-builds
Copy link
Collaborator

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

@kylehickinson kylehickinson requested a review from a team as a code owner March 7, 2023 21:13
@brave-builds
Copy link
Collaborator

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

Copy link
Contributor

@deeppandya deeppandya left a comment

Choose a reason for hiding this comment

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

Android changes LGTM

@szilardszaloki szilardszaloki force-pushed the sszaloki-28793-audit-network-errors-and-their-ui-effects branch from fc00389 to 59f4e1e Compare March 9, 2023 21:06
@szilardszaloki szilardszaloki changed the title [WIP] Introduces FetchBalanceResult. Introduces FetchBalanceResult. Mar 9, 2023
@brave-builds
Copy link
Collaborator

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

@brave-builds
Copy link
Collaborator

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

@wknapik wknapik merged commit b528d94 into master Mar 10, 2023
@wknapik wknapik deleted the sszaloki-28793-audit-network-errors-and-their-ui-effects branch March 10, 2023 21:44
@github-actions github-actions bot added this to the 1.51.x - Nightly milestone Mar 10, 2023
brave-builds added a commit that referenced this pull request Mar 10, 2023
@GeetaSarvadnya
Copy link

GeetaSarvadnya commented Mar 14, 2023

Verification PASSED on

Brave | 1.51.30 Chromium: 111.0.5563.64 (Official Build) nightly (64-bit)
-- | --
Revision | c710e93d5b63b7095afe8c2c17df34408078439d-refs/branch-heads/5563@{#995}
OS | Windows 10 Version 21H2 (Build 19044.2604)

1. Before enabling rewards
  • Confirmed that there is no Balance info displayed on the brave://rewards-internals page before enabling the rewards
    image
2. After enabling rewards
  • Confirmed that after enabling the rewards the vBAT balance is shown on the Rewards Internals page
  • Confirmed that the Connect account is shown on the brave://rewards settings page, BR panel and rewards NTP widget
    image
3. After connecting a custodial wallet
  • Confirmed that after connecting custodian wallet, both the vBAT/external wallet balance is displayed on the Rewards Internals page
  • Confirmed that after connecting custodian wallet, total balance is displayed on the Rewards page, Rewards panel and Rewards NTP widget
brave://settings BR panel rewards NTP widget brave://rewards-internals
image image image image
4. Logged out state
  • Confirmed that in the logged out state,the vBAT balanceis shown only on the Rewards Internals page
  • Confirmed that Logged out UI is shown on the brave://rewards, BR panel, Rewards NTP and Tipping banner
  • Confirmed that : ( You are currently logged out text message is shown on the tipping banner
brave://settings BR panel rewards NTP widget Tipping banner brave://rewards-internals
image image image image image
5. Fail the fetch balance request
  • Uphold wallet (pre-req: have Charles Proxy set up to return 500 error for the endpoint (https://api-sandbox.uphold.com/v0/me/cards/*)
  • Confirmed that spinner animation is shown for both the Rewards BAT (vBAT) and external wallet balance on brave://rewards-internals page
brave://settings BR panel rewards NTP widget Tipping banner brave://rewards-internals
image image image image image
  • Confirmed that the rewards NTP widget Log in to Uphold to see your balance padding issue is been resolved in 1.51.x
1.50.x 1.51.x
image image
6. Reset rewards
  • Confirmed that after Reset rewards the wallet balance info is not displayed on the brave://rewards-internals page
    image

@kylehickinson
Copy link
Collaborator

If uplifted also uplift #17628

@szilardszaloki
Copy link
Collaborator Author

szilardszaloki commented Mar 16, 2023

If uplifted also uplift #17456
cc: @kjozwiak

kjozwiak pushed a commit that referenced this pull request Mar 16, 2023
* Uplift of #17480 (squashed) to beta

* [iOS] Add flag to control namespace generation for Obj-C mojom wrappers

* Remove note from Reset Rewards modal

---------

Co-authored-by: Kyle Hickinson <[email protected]>
Co-authored-by: Emerick Rogul <[email protected]>
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add base::expected<>-style API to the "fetch balance" flow
9 participants