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

Added notifications for Confirmed, Error and Dropped status changes #13330

Merged
merged 1 commit into from
May 20, 2022

Conversation

spylogsster
Copy link
Contributor

@spylogsster spylogsster commented May 13, 2022

Resolves brave/brave-browser#19885

Added WalletNotificationService to show notifications about transactions on UI level.

demo.mp4

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, npm run lint, 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:

  • Make transaction and check notification for Confirmed and Error statuses

@spylogsster spylogsster added this to the 1.40.x - Nightly milestone May 13, 2022
@spylogsster spylogsster requested a review from yrliou May 13, 2022 12:46
@spylogsster spylogsster requested a review from a team as a code owner May 13, 2022 12:46
@spylogsster spylogsster self-assigned this May 13, 2022
@spylogsster spylogsster marked this pull request as draft May 15, 2022 21:07
@spylogsster spylogsster changed the title Added notifications for Confirmed and Error status changes wip: Added notifications for Confirmed and Error status changes May 15, 2022
@spylogsster spylogsster force-pushed the notification branch 3 times, most recently from 0636bb1 to e8dd2ee Compare May 15, 2022 21:55
@spylogsster spylogsster force-pushed the notification branch 7 times, most recently from ca21ac7 to c740887 Compare May 16, 2022 15:03
@spylogsster spylogsster changed the title wip: Added notifications for Confirmed and Error status changes Added notifications for Confirmed and Error status changes May 16, 2022
@spylogsster spylogsster marked this pull request as ready for review May 16, 2022 15:03
@spylogsster spylogsster force-pushed the notification branch 4 times, most recently from 393d7a0 to 7654dfc Compare May 16, 2022 20:43
@@ -36,7 +38,6 @@ source_set("brave_wallet") {
"//services/network/public/cpp",
"//third_party/abseil-cpp:absl",
]

Copy link
Member

Choose a reason for hiding this comment

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

Please remove this unrelated change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -14,7 +14,7 @@

namespace {

base::OnceCallback<void()> g_NewSetupNeededForTestingCallback;
absl::optional<bool> g_NewSetupNeededForTesting;
Copy link
Member

Choose a reason for hiding this comment

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

What's the reason of not just using boolean here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

there is condition of existance on 39th line, replaced by optional to keep same logic

Copy link
Member

Choose a reason for hiding this comment

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

Seems unnecessary, I think a boolean value initialized as false and just check the boolean value is what we needed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

this variable name also needs to be underscore

browser/brave_wallet/sources.gni Outdated Show resolved Hide resolved
@@ -102,8 +103,8 @@ brave_chrome_browser_deps = [
"//brave/browser:browser_process",
"//brave/browser/brave_federated",
"//brave/browser/brave_wallet",
"//brave/browser/brave_wallet",
Copy link
Member

Choose a reason for hiding this comment

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

duplicate entry

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

test/BUILD.gn Outdated
@@ -88,6 +88,7 @@ test("brave_unit_tests") {
"../../components/domain_reliability/test_util.h",
"//brave/browser/brave_content_browser_client_unittest.cc",
"//brave/browser/brave_resources_util_unittest.cc",
"//brave/browser/brave_wallet/wallet_notification_service_unittest.cc",
Copy link
Member

Choose a reason for hiding this comment

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

Any reasons that it has to be added to this target instead of some wallet test target? In general we don't want to add to this huge target seems it's hard to manage.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I couldn't find any mention of unittests in underlaying sources.gni files, seems this is only way now to add test for this on UI level

Comment on lines 28 to 29
explicit WalletNotificationService(content::BrowserContext* context,
TxService* tx_state_manager);
Copy link
Member

Choose a reason for hiding this comment

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

s/tx_state_manager/tx_service

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

content::BrowserContext* context,
TxService* tx_service)
: tx_service_(tx_service), context_(context) {
tx_service_->AddObserver(tx_observer_receiver_.BindNewPipeAndPassRemote());
Copy link
Member

Choose a reason for hiding this comment

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

This raw_ptr doesn't seem to be needed to be stored if all we need is the AddObserver call here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Comment on lines 14 to 15
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/remote.h"
Copy link
Member

Choose a reason for hiding this comment

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

These two seems not needed in this header file, and the include for mojo::Receiver is missing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

browser/brave_wallet/wallet_notification_service.cc Outdated Show resolved Hide resolved
Comment on lines 28 to 30
brave_wallet::WalletNotificationServiceFactory::GetServiceForContext(
web_contents->GetBrowserContext());
Copy link
Member

Choose a reason for hiding this comment

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

I'm a bit confused about this. Could you explain what's this for? Triggering service creation? How is it related to the tab helper?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, this is only to trigger service creation, it needs to be done on UI level for browser context

@spylogsster spylogsster changed the title Added notifications for Confirmed and Error status changes Added notifications for Confirmed, Error and Dropped status changes May 17, 2022
@spylogsster spylogsster force-pushed the notification branch 4 times, most recently from 59e6ff2 to acab33c Compare May 18, 2022 09:10
@spylogsster spylogsster force-pushed the notification branch 3 times, most recently from 3e836ff to 414a2c2 Compare May 18, 2022 11:28
namespace brave_wallet {

WalletNotificationService::WalletNotificationService(
content::BrowserContext* context,
Copy link
Collaborator

Choose a reason for hiding this comment

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

do not pass in the BrowserContext, pass in NotificationDisplayService from WalletNotificationServiceFactory

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I need BrowserContext inside WalletNotificationService

# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.

brave_browser_brave_wallet_sources = [
Copy link
Collaborator

Choose a reason for hiding this comment

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

so based on dm discussion brave_wallet_tab_helper shouldn't need to be in sources.gni anymore so I would move it back to BUILD.gn and then create a subdir for notifications so we don't have sources.gni and BUILD.gn in the same directory

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@spylogsster spylogsster force-pushed the notification branch 3 times, most recently from adb4682 to 6440f59 Compare May 19, 2022 15:23
test/BUILD.gn Outdated
@@ -312,6 +313,7 @@ test("brave_unit_tests") {
sources += [
"../utility/importer/chrome_importer_unittest.cc",
"//brave/app/brave_command_line_helper_unittest.cc",
"//brave/browser/brave_wallet/notifications/wallet_notification_service_unittest.cc",
Copy link
Member

Choose a reason for hiding this comment

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

This should not be added to this huge target, should be added to a wallet test target.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Member

@yrliou yrliou left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Add notifications for successful / failed transactions
3 participants