Skip to content

Commit d554220

Browse files
Uplift of #9669 (squashed) to beta
1 parent 56a2538 commit d554220

File tree

11 files changed

+104
-26
lines changed

11 files changed

+104
-26
lines changed

components/brave_rewards/resources/extension/brave_rewards/_locales/en_US/messages.json

+18
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,24 @@
219219
"message": "Please backup your Brave wallet.",
220220
"description": "Description for backup wallet notification"
221221
},
222+
"mismatchedProviderAccountsLearnMore": {
223+
"message": "Learn More",
224+
"description": "Notification button text to learn more about linking with a custodian account"
225+
},
226+
"mismatchedProviderAccountsTitle": {
227+
"message": "Error: Different account",
228+
"description": "Title for mismatched provider accounts notification"
229+
},
230+
"mismatchedProviderAccountsNotification": {
231+
"message": "Hmm, it looks like your Brave Rewards wallet has already been verified with another $name$ account. Please try verifying again using your previous account.",
232+
"description": "Description for mismatched provider accounts notification",
233+
"placeholders": {
234+
"name": {
235+
"content": "$1",
236+
"example": "Uphold"
237+
}
238+
}
239+
},
222240
"upholdBATNotAllowedForUserLearnMore": {
223241
"message": "Learn More",
224242
"description": "Notification button text to learn more about why BAT is not allowed for user"

components/brave_rewards/resources/extension/brave_rewards/background/api/locale_api.ts

+3
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ export const getUIMessages = (): Record<string, string> => {
6363
'includeInAuto',
6464
'insufficientFunds',
6565
'insufficientFundsNotification',
66+
'mismatchedProviderAccountsLearnMore',
67+
'mismatchedProviderAccountsNotification',
68+
'mismatchedProviderAccountsTitle',
6669
'monthApr',
6770
'monthAug',
6871
'monthDec',

components/brave_rewards/resources/extension/brave_rewards/components/panel.tsx

+23-14
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ export class Panel extends React.Component<Props, State> {
201201

202202
onDeviceLimitReached = this.onEvent('https://support.brave.com/hc/en-us/articles/360056508071')
203203

204+
onMismatchedProviderAccounts = this.onEvent('https://support.brave.com/hc/en-us/articles/360034841711-What-is-a-verified-wallet-')
205+
204206
onUpholdBATNotAllowedForUser = this.onEvent('https://support.uphold.com/hc/en-us/articles/360033020351-Brave-BAT-and-US-availability')
205207

206208
onUpholdBlockedUser = this.onEvent('https://support.uphold.com/hc/en-us/articles/360045765351-Why-we-block-or-restrict-accounts-and-how-to-reduce-the-risk')
@@ -348,11 +350,14 @@ export class Panel extends React.Component<Props, State> {
348350
case 'backupWallet':
349351
clickEvent = this.onBackupWallet.bind(this, id)
350352
break
353+
case 'deviceLimitReached':
354+
clickEvent = this.onDeviceLimitReached.bind(this, id)
355+
break
351356
case 'insufficientFunds':
352357
clickEvent = this.onAddFunds.bind(this, id)
353358
break
354-
case 'deviceLimitReached':
355-
clickEvent = this.onDeviceLimitReached.bind(this, id)
359+
case 'mismatchedProviderAccounts':
360+
clickEvent = this.onMismatchedProviderAccounts.bind(this, id)
356361
break
357362
case 'upholdBATNotAllowedForUser':
358363
clickEvent = this.onUpholdBATNotAllowedForUser.bind(this, id)
@@ -469,16 +474,10 @@ export class Panel extends React.Component<Props, State> {
469474
}
470475

471476
switch (args[0]) {
472-
case 'wallet_new_verified': {
473-
text = (
474-
<>
475-
<div><b>{getMessage('walletVerifiedNotification')}</b></div>
476-
{getMessage('walletVerifiedTextNotification', [args[1]])}
477-
</>
478-
)
479-
isAlert = 'success'
477+
case 'wallet_device_limit_reached':
478+
type = 'deviceLimitReached'
479+
text = getMessage('deviceLimitReachedNotification')
480480
break
481-
}
482481
case 'wallet_disconnected': {
483482
text = (
484483
<>
@@ -489,10 +488,20 @@ export class Panel extends React.Component<Props, State> {
489488
isAlert = 'error'
490489
break
491490
}
492-
case 'wallet_device_limit_reached':
493-
type = 'deviceLimitReached'
494-
text = getMessage('deviceLimitReachedNotification')
491+
case 'wallet_mismatched_provider_accounts':
492+
type = 'mismatchedProviderAccounts'
493+
text = getMessage('mismatchedProviderAccountsNotification', [args[1]])
495494
break
495+
case 'wallet_new_verified': {
496+
text = (
497+
<>
498+
<div><b>{getMessage('walletVerifiedNotification')}</b></div>
499+
{getMessage('walletVerifiedTextNotification', [args[1]])}
500+
</>
501+
)
502+
isAlert = 'success'
503+
break
504+
}
496505
case 'uphold_bat_not_allowed_for_user':
497506
type = 'upholdBATNotAllowedForUser'
498507
text = getMessage('upholdBATNotAllowedForUserNotification')

components/brave_rewards/resources/ui/components/walletWrapper/index.tsx

+4
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ export type NotificationType =
9797
'error' |
9898
'grant' |
9999
'insufficientFunds' |
100+
'mismatchedProviderAccounts' |
100101
'pendingContribution' |
101102
'tipsProcessed' |
102103
'upholdBATNotAllowedForUser' |
@@ -279,6 +280,7 @@ export default class WalletWrapper extends React.PureComponent<Props, State> {
279280
buttonAction = this.onNotificationClick
280281
break
281282
case 'deviceLimitReached':
283+
case 'mismatchedProviderAccounts':
282284
case 'upholdBATNotAllowedForUser':
283285
case 'upholdBlockedUser':
284286
case 'upholdPendingUser':
@@ -465,6 +467,7 @@ export default class WalletWrapper extends React.PureComponent<Props, State> {
465467
case 'backupWallet':
466468
case 'deviceLimitReached':
467469
case 'insufficientFunds':
470+
case 'mismatchedProviderAccounts':
468471
case 'upholdBATNotAllowedForUser':
469472
case 'upholdBlockedUser':
470473
case 'upholdPendingUser':
@@ -500,6 +503,7 @@ export default class WalletWrapper extends React.PureComponent<Props, State> {
500503
switch (notification.type) {
501504
case 'backupWallet':
502505
case 'deviceLimitReached':
506+
case 'mismatchedProviderAccounts':
503507
case 'pendingContribution':
504508
case 'upholdBATNotAllowedForUser':
505509
case 'upholdBlockedUser':

vendor/bat-native-ledger/src/bat/ledger/internal/endpoint/promotion/post_claim_uphold/post_claim_uphold.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ type::Result PostClaimUphold::CheckStatusCode(const int status_code) const {
121121

122122
if (status_code == net::HTTP_FORBIDDEN) {
123123
BLOG(0, "Forbidden");
124-
return type::Result::LEDGER_ERROR;
124+
return type::Result::TOO_MANY_RESULTS;
125125
}
126126

127127
if (status_code == net::HTTP_NOT_FOUND) {
@@ -130,7 +130,7 @@ type::Result PostClaimUphold::CheckStatusCode(const int status_code) const {
130130
}
131131

132132
if (status_code == net::HTTP_CONFLICT) {
133-
BLOG(0, "Not found");
133+
BLOG(0, "Conflict");
134134
return type::Result::ALREADY_EXISTS;
135135
}
136136

vendor/bat-native-ledger/src/bat/ledger/internal/endpoint/promotion/post_claim_uphold/post_claim_uphold_unittest.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ TEST_F(PostClaimUpholdTest, ServerError403) {
9292

9393
claim_->Request(30.0, "address",
9494
[](const type::Result result, const std::string& address) {
95-
EXPECT_EQ(result, type::Result::LEDGER_ERROR);
95+
EXPECT_EQ(result, type::Result::TOO_MANY_RESULTS);
9696
EXPECT_EQ(address, kExpectedAddress);
9797
});
9898
}

vendor/bat-native-ledger/src/bat/ledger/internal/logging/event_log_keys.h

+7-6
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,17 @@ namespace ledger {
1212
namespace log {
1313

1414
const char kACAddedToQueue[] = "ac_added_to_queue";
15-
const char kWalletConnected[] = "wallet_connected";
16-
const char kWalletVerified[] = "wallet_verified";
17-
const char kWalletDisconnected[] = "wallet_disconnected";
18-
const char kRecurringTipAdded[] = "recurring_tip_added";
19-
const char kRecurringTipRemoved[] = "recurring_tip_removed";
2015
const char kDatabaseMigrated[] = "database_migrated";
16+
const char kDeviceLimitReached[] = "device_limit_reached";
17+
const char kMismatchedProviderAccounts[] = "mismatched_provider_accounts";
2118
const char kPromotionsClaimed[] = "promotion_claimed";
19+
const char kRecurringTipAdded[] = "recurring_tip_added";
20+
const char kRecurringTipRemoved[] = "recurring_tip_removed";
21+
const char kWalletConnected[] = "wallet_connected";
22+
const char kWalletDisconnected[] = "wallet_disconnected";
2223
const char kWalletRecovered[] = "wallet_recovered";
23-
const char kDeviceLimitReached[] = "device_limit_reached";
2424
const char kWalletStatusChange[] = "wallet_status_change";
25+
const char kWalletVerified[] = "wallet_verified";
2526

2627
} // namespace log
2728
} // namespace ledger

vendor/bat-native-ledger/src/bat/ledger/internal/notifications/notification_keys.h

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ namespace ledger {
1010
namespace notifications {
1111

1212
const char kWalletDeviceLimitReached[] = "wallet_device_limit_reached";
13+
const char kWalletMismatchedProviderAccounts[] =
14+
"wallet_mismatched_provider_accounts";
1315
const char kWalletDisconnected[] = "wallet_disconnected";
1416
const char kWalletNewVerified[] = "wallet_new_verified";
1517

vendor/bat-native-ledger/src/bat/ledger/internal/uphold/uphold.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ void Uphold::DisconnectWallet(const std::string& notification) {
207207
const bool shutting_down = ledger_->IsShuttingDown();
208208

209209
if (!manual && !shutting_down) {
210-
ledger_->ledger_client()->ShowNotification(notification, {},
210+
ledger_->ledger_client()->ShowNotification(notification, {"Uphold"},
211211
[](type::Result _) {});
212212
}
213213

vendor/bat-native-ledger/src/bat/ledger/internal/uphold/uphold_unittest.cc

+31-2
Original file line numberDiff line numberDiff line change
@@ -1109,8 +1109,37 @@ INSTANTIATE_TEST_SUITE_P(
11091109
type::Result::ALREADY_EXISTS,
11101110
type::WalletStatus::NOT_CONNECTED
11111111
},
1112+
LinkWalletParamType{ // Mismatched provider accounts.
1113+
"01_mismatched_provider_accounts",
1114+
R"({ "status": 5, "token": "0047c2fd8f023e067354dbdb5639ee67acf77150" })",
1115+
type::UrlResponse{
1116+
{},
1117+
{},
1118+
net::HttpStatusCode::HTTP_OK,
1119+
R"({ "currencies": [ "BAT" ], "status": "ok", "memberAt": "2021-05-26T16:42:23.134Z" })",
1120+
{}
1121+
},
1122+
type::UrlResponse{
1123+
{},
1124+
{},
1125+
net::HttpStatusCode::HTTP_OK,
1126+
R"([ { "id": "962ef3b8-bc12-4619-a349-c8083931b795", "label": "Brave Browser" } ])",
1127+
{}
1128+
},
1129+
false,
1130+
R"({ "payment_id": "f375da3c-c206-4f09-9422-665b8e5952db", "recovery_seed": "OG2zYotDSeZ81qLtr/uq5k/GC6WE5/7BclT1lHi4l+w=" })",
1131+
type::UrlResponse{
1132+
{},
1133+
{},
1134+
net::HttpStatusCode::HTTP_FORBIDDEN,
1135+
{},
1136+
{}
1137+
},
1138+
type::Result::TOO_MANY_RESULTS,
1139+
type::WalletStatus::NOT_CONNECTED
1140+
},
11121141
LinkWalletParamType{ // Rewards Link (Claim) Wallet failed.
1113-
"01_link_wallet_failed",
1142+
"02_link_wallet_failed",
11141143
R"({ "status": 5, "token": "0047c2fd8f023e067354dbdb5639ee67acf77150" })",
11151144
type::UrlResponse{
11161145
{},
@@ -1139,7 +1168,7 @@ INSTANTIATE_TEST_SUITE_P(
11391168
type::WalletStatus::PENDING
11401169
},
11411170
LinkWalletParamType{ // Happy path.
1142-
"02_happy_path",
1171+
"03_happy_path",
11431172
R"({ "status": 5, "token": "0047c2fd8f023e067354dbdb5639ee67acf77150" })",
11441173
type::UrlResponse{
11451174
{},

vendor/bat-native-ledger/src/bat/ledger/internal/uphold/uphold_wallet.cc

+12
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,18 @@ void UpholdWallet::OnLinkWallet(const type::Result result,
272272
return callback(type::Result::ALREADY_EXISTS);
273273
}
274274

275+
if (result == type::Result::TOO_MANY_RESULTS) {
276+
// Entering NOT_CONNECTED.
277+
ledger_->uphold()->DisconnectWallet(
278+
ledger::notifications::kWalletMismatchedProviderAccounts);
279+
280+
ledger_->database()->SaveEventLog(
281+
log::kMismatchedProviderAccounts,
282+
constant::kWalletUphold + std::string("/") + id.substr(0, 5));
283+
284+
return callback(type::Result::TOO_MANY_RESULTS);
285+
}
286+
275287
if (result != type::Result::LEDGER_OK) {
276288
return callback(type::Result::CONTINUE);
277289
}

0 commit comments

Comments
 (0)