-
Notifications
You must be signed in to change notification settings - Fork 862
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
use mojo for wallet controllers #9527
Conversation
#if BUILDFLAG(BRAVE_WALLET_ENABLED) | ||
#include "brave/ios/browser/api/wallet/brave_wallet_service_factory.h" | ||
#endif | ||
// #if BUILDFLAG(BRAVE_WALLET_ENABLED) |
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 is all intentional per conversation with @kylehickinson
auto callback = base::BindOnce([](const std::string& mnemonic) {}); | ||
keyring_controller_->GetMnemonicForDefaultKeyring(std::move(callback)); | ||
|
||
// TODO(bridiver) - convert this to callback |
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.
same as ios these will be fixed in the follow-up. The current handling for callbacks in JNI is subject to multiple race conditions so not much point in fixing this now and @SergeyZhukovsky agrees
mojo::Remote<brave_wallet::mojom::KeyringController> keyring_controller_; | ||
mojo::Remote<brave_wallet::mojom::AssetRatioController> | ||
asset_ratio_controller_; | ||
mojo::Remote<brave_wallet::mojom::SwapController> swap_controller_; |
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.
swap_controller_
is unused in android right now
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.
iOS++ will have a follow up PR re-adding the keyring controller as a keyed service
EXPECT_EQ(controller.GetMnemonicForDefaultKeyring(), mnemonic); | ||
controller.Unlock("brave", GetIgnoreResultCallback()); | ||
EXPECT_FALSE(controller.IsLocked()); | ||
// EXPECT_EQ(controller.GetMnemonicForDefaultKeyring(), mnemonic); |
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.
we can check the result using base::BindLambdaForTesting
and capture a variable to make sure the callback is called instead of commenting these all out.
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.
oh, that was a mistake, I forgot to get back to these
|
||
// unlock with wrong password | ||
EXPECT_FALSE(controller.Unlock("brave123")); | ||
EXPECT_TRUE(controller.GetMnemonicForDefaultKeyring().empty()); | ||
controller.Unlock("brave123", GetIgnoreResultCallback()); |
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.
shouldn't we check the callback to make sure it is called with false that indicate unlock failure?
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.
yea, this is a mistake I missed
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.
lgtm!
7adde67
to
eb54ec6
Compare
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.
++
} | ||
|
||
void KeyringController::NotifyWalletBackupComplete() { | ||
prefs_->SetBoolean(kBraveWalletBackupComplete, true); |
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.
I think this need to be cleared in KeyringController::Reset
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.
I didn't change any logic here, if that's a problem, it's a bug in the original code
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.
and it certainly does seem like a bug, just not one introduced in this PR
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.
can you file an issue for it? Lots of people are waiting on this so I don't want to push it back any further for pre-existing issues and also my intention was not to change any logic so I didn't introduce any problems
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.
I will take care of it in this issue
brave/brave-browser#17137
// Must unlock before using this API otherwise it will return nullptr | ||
HDKeyring* GetDefaultKeyring(); | ||
bool IsDefaultKeyringCreated(); | ||
|
||
bool IsLocked() const; | ||
void Lock(); | ||
bool Unlock(const std::string& password); | ||
// bool Unlock(const std::string& password); |
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 comment can be removed
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.
I'll remove in the follow-up so I don't trigger another CI run with the change
linux test failures are unrelated |
Resolves brave/brave-browser#17105
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
,npm run lint
,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan: