Skip to content

Commit 761caf7

Browse files
committed
Removes annon address from external wallet flow
Resolves brave/brave-browser#11150
1 parent a859dd8 commit 761caf7

File tree

17 files changed

+9
-295
lines changed

17 files changed

+9
-295
lines changed

components/brave_rewards/browser/external_wallet.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ namespace brave_rewards {
2222
base::Value dict(base::Value::Type::DICTIONARY);
2323
dict.SetStringKey("token", token);
2424
dict.SetStringKey("address", address);
25-
dict.SetStringKey("anon_address", anon_address);
2625

2726
// enum class WalletStatus : int32_t
2827
dict.SetIntKey("status", static_cast<int32_t>(status));

components/brave_rewards/browser/external_wallet.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ struct ExternalWallet {
1818

1919
std::string token;
2020
std::string address;
21-
std::string anon_address;
2221
uint32_t status;
2322
std::string type;
2423
std::string verify_url;

components/brave_rewards/browser/rewards_service_impl.cc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3186,7 +3186,6 @@ void RewardsServiceImpl::SaveExternalWallet(const std::string& wallet_type,
31863186
new_wallet.SetStringKey("withdraw_url", wallet->withdraw_url);
31873187
new_wallet.SetStringKey("account_url", wallet->account_url);
31883188
new_wallet.SetStringKey("login_url", wallet->login_url);
3189-
new_wallet.SetStringKey("anon_address", wallet->anon_address);
31903189

31913190
new_wallets.SetKey(wallet_type, std::move(new_wallet));
31923191

@@ -3255,11 +3254,6 @@ RewardsServiceImpl::GetExternalWallets() {
32553254
wallet->login_url = *login_url;
32563255
}
32573256

3258-
auto* anon_address = it.second.FindStringKey("anon_address");
3259-
if (anon_address) {
3260-
wallet->anon_address = *anon_address;
3261-
}
3262-
32633257
wallets.insert(std::make_pair(it.first, std::move(wallet)));
32643258
}
32653259

@@ -3285,7 +3279,6 @@ void RewardsServiceImpl::OnGetExternalWallet(
32853279
external->user_name = wallet->user_name;
32863280
external->account_url = wallet->account_url;
32873281
external->login_url = wallet->login_url;
3288-
external->anon_address = wallet->anon_address;
32893282
}
32903283

32913284
std::move(callback).Run(static_cast<int>(result), std::move(external));

components/brave_rewards/browser/test/common/rewards_browsertest_response.cc

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,6 @@ void RewardsBrowserTestResponse::LoadMocks() {
198198
path.AppendASCII("uphold_commit_resp.json"),
199199
&uphold_commit_resp_));
200200

201-
ASSERT_TRUE(base::ReadFileToString(
202-
path.AppendASCII("uphold_addresses_resp.json"),
203-
&uphold_addresses_resp_));
204-
205201
std::vector<std::string> publisher_keys {
206202
"bumpsmack.com",
207203
"duckduckgo.com",
@@ -340,11 +336,6 @@ void RewardsBrowserTestResponse::Get(
340336
"commit",
341337
base::CompareCase::INSENSITIVE_ASCII)) {
342338
*response = uphold_commit_resp_;
343-
} else if (base::EndsWith(
344-
url,
345-
"addresses",
346-
base::CompareCase::INSENSITIVE_ASCII)) {
347-
*response = uphold_addresses_resp_;
348339
} else {
349340
*response = rewards_browsertest_util::GetUpholdCard(
350341
external_balance_,

components/brave_rewards/browser/test/common/rewards_browsertest_response.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ class RewardsBrowserTestResponse {
6767
std::string uphold_auth_resp_;
6868
std::string uphold_transactions_resp_;
6969
std::string uphold_commit_resp_;
70-
std::string uphold_addresses_resp_;
7170
std::string user_funds_balance_resp_;
7271

7372
std::vector<Request> requests_;

test/data/rewards-data/uphold_addresses_resp.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

vendor/bat-native-ledger/include/bat/ledger/public/interfaces/ledger.mojom

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ struct ExternalWallet {
145145
string type;
146146
string token;
147147
string address;
148-
string anon_address;
149148
WalletStatus status;
150149
string verify_url;
151150
string add_url;

vendor/bat-native-ledger/src/bat/ledger/internal/state/state_migration.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace braveledger_state {
2222
StateMigration::StateMigration(bat_ledger::LedgerImpl* ledger) :
2323
v1_(std::make_unique<StateMigrationV1>(ledger)),
2424
v2_(std::make_unique<StateMigrationV2>(ledger)),
25-
v3_(std::make_unique<StateMigrationV3>(ledger)),
25+
v3_(std::make_unique<StateMigrationV3>()),
2626
v4_(std::make_unique<StateMigrationV4>(ledger)),
2727
ledger_(ledger) {
2828
DCHECK(v1_ && v2_ && v3_ && v4_);

vendor/bat-native-ledger/src/bat/ledger/internal/state/state_migration_v3.cc

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,18 @@
33
* License, v. 2.0. If a copy of the MPL was not distributed with this
44
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
55

6-
#include <utility>
7-
8-
#include "bat/ledger/global_constants.h"
9-
#include "bat/ledger/internal/ledger_impl.h"
10-
#include "bat/ledger/internal/state/state_keys.h"
116
#include "bat/ledger/internal/state/state_migration_v3.h"
12-
#include "bat/ledger/internal/state/state_util.h"
13-
#include "bat/ledger/internal/uphold/uphold_util.h"
147

158
namespace braveledger_state {
169

17-
StateMigrationV3::StateMigrationV3(bat_ledger::LedgerImpl* ledger) :
18-
ledger_(ledger) {
19-
}
10+
StateMigrationV3::StateMigrationV3() = default;
2011

2112
StateMigrationV3::~StateMigrationV3() = default;
2213

2314
void StateMigrationV3::Migrate(ledger::ResultCallback callback) {
24-
const std::string anon_address =
25-
ledger_->GetStringState(ledger::kStateUpholdAnonAddress);
26-
27-
if (!anon_address.empty()) {
28-
auto wallets = ledger_->GetExternalWallets();
29-
auto wallet = braveledger_uphold::GetWallet(std::move(wallets));
30-
if (!wallet) {
31-
BLOG(0, "Wallet is null, but we can't recover");
32-
callback(ledger::Result::LEDGER_OK);
33-
return;
34-
}
35-
36-
wallet->anon_address = anon_address;
37-
ledger_->SaveExternalWallet(ledger::kWalletUphold, std::move(wallet));
38-
ledger_->ClearState(ledger::kStateUpholdAnonAddress);
39-
}
40-
15+
// In this migration we migrated anon address to uphold wallet in preferences
16+
// because anon address was removed we can also remove this step
17+
// Ref: https://github.com/brave/brave-browser/issues/11150
4118
callback(ledger::Result::LEDGER_OK);
4219
}
4320

vendor/bat-native-ledger/src/bat/ledger/internal/state/state_migration_v3.h

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,16 @@
66
#ifndef BRAVELEDGER_BAT_STATE_STATE_MIGRATION_V3_H_
77
#define BRAVELEDGER_BAT_STATE_STATE_MIGRATION_V3_H_
88

9-
#include <memory>
10-
#include <string>
11-
129
#include "bat/ledger/ledger.h"
1310

14-
namespace bat_ledger {
15-
class LedgerImpl;
16-
}
17-
1811
namespace braveledger_state {
1912

2013
class StateMigrationV3 {
2114
public:
22-
explicit StateMigrationV3(bat_ledger::LedgerImpl* ledger);
15+
StateMigrationV3();
2316
~StateMigrationV3();
2417

2518
void Migrate(ledger::ResultCallback callback);
26-
27-
private:
28-
bat_ledger::LedgerImpl* ledger_; // NOT OWNED
2919
};
3020

3121
} // namespace braveledger_state

0 commit comments

Comments
 (0)