diff --git a/components/brave_rewards/resources/extension/brave_rewards/_locales/en_US/messages.json b/components/brave_rewards/resources/extension/brave_rewards/_locales/en_US/messages.json index 88ea42ddcdc6..026fcb36c1d1 100644 --- a/components/brave_rewards/resources/extension/brave_rewards/_locales/en_US/messages.json +++ b/components/brave_rewards/resources/extension/brave_rewards/_locales/en_US/messages.json @@ -219,6 +219,24 @@ "message": "Please backup your Brave wallet.", "description": "Description for backup wallet notification" }, + "mismatchedProviderAccountsLearnMore": { + "message": "Learn More", + "description": "Notification button text to learn more about linking with a custodian account" + }, + "mismatchedProviderAccountsTitle": { + "message": "Error: Different account", + "description": "Title for mismatched provider accounts notification" + }, + "mismatchedProviderAccountsNotification": { + "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.", + "description": "Description for mismatched provider accounts notification", + "placeholders": { + "name": { + "content": "$1", + "example": "Uphold" + } + } + }, "upholdBATNotAllowedForUserLearnMore": { "message": "Learn More", "description": "Notification button text to learn more about why BAT is not allowed for user" diff --git a/components/brave_rewards/resources/extension/brave_rewards/background/api/locale_api.ts b/components/brave_rewards/resources/extension/brave_rewards/background/api/locale_api.ts index f08df0b87556..67936be043d0 100644 --- a/components/brave_rewards/resources/extension/brave_rewards/background/api/locale_api.ts +++ b/components/brave_rewards/resources/extension/brave_rewards/background/api/locale_api.ts @@ -63,6 +63,9 @@ export const getUIMessages = (): Record => { 'includeInAuto', 'insufficientFunds', 'insufficientFundsNotification', + 'mismatchedProviderAccountsLearnMore', + 'mismatchedProviderAccountsNotification', + 'mismatchedProviderAccountsTitle', 'monthApr', 'monthAug', 'monthDec', diff --git a/components/brave_rewards/resources/extension/brave_rewards/components/panel.tsx b/components/brave_rewards/resources/extension/brave_rewards/components/panel.tsx index 6e321ea2cb4e..8b2198495874 100644 --- a/components/brave_rewards/resources/extension/brave_rewards/components/panel.tsx +++ b/components/brave_rewards/resources/extension/brave_rewards/components/panel.tsx @@ -201,6 +201,8 @@ export class Panel extends React.Component { onDeviceLimitReached = this.onEvent('https://support.brave.com/hc/en-us/articles/360056508071') + onMismatchedProviderAccounts = this.onEvent('https://support.brave.com/hc/en-us/articles/360034841711-What-is-a-verified-wallet-') + onUpholdBATNotAllowedForUser = this.onEvent('https://support.uphold.com/hc/en-us/articles/360033020351-Brave-BAT-and-US-availability') 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 { case 'backupWallet': clickEvent = this.onBackupWallet.bind(this, id) break + case 'deviceLimitReached': + clickEvent = this.onDeviceLimitReached.bind(this, id) + break case 'insufficientFunds': clickEvent = this.onAddFunds.bind(this, id) break - case 'deviceLimitReached': - clickEvent = this.onDeviceLimitReached.bind(this, id) + case 'mismatchedProviderAccounts': + clickEvent = this.onMismatchedProviderAccounts.bind(this, id) break case 'upholdBATNotAllowedForUser': clickEvent = this.onUpholdBATNotAllowedForUser.bind(this, id) @@ -469,16 +474,10 @@ export class Panel extends React.Component { } switch (args[0]) { - case 'wallet_new_verified': { - text = ( - <> -
{getMessage('walletVerifiedNotification')}
- {getMessage('walletVerifiedTextNotification', [args[1]])} - - ) - isAlert = 'success' + case 'wallet_device_limit_reached': + type = 'deviceLimitReached' + text = getMessage('deviceLimitReachedNotification') break - } case 'wallet_disconnected': { text = ( <> @@ -489,10 +488,20 @@ export class Panel extends React.Component { isAlert = 'error' break } - case 'wallet_device_limit_reached': - type = 'deviceLimitReached' - text = getMessage('deviceLimitReachedNotification') + case 'wallet_mismatched_provider_accounts': + type = 'mismatchedProviderAccounts' + text = getMessage('mismatchedProviderAccountsNotification', [args[1]]) break + case 'wallet_new_verified': { + text = ( + <> +
{getMessage('walletVerifiedNotification')}
+ {getMessage('walletVerifiedTextNotification', [args[1]])} + + ) + isAlert = 'success' + break + } case 'uphold_bat_not_allowed_for_user': type = 'upholdBATNotAllowedForUser' text = getMessage('upholdBATNotAllowedForUserNotification') diff --git a/components/brave_rewards/resources/ui/components/walletWrapper/index.tsx b/components/brave_rewards/resources/ui/components/walletWrapper/index.tsx index 196fd3aba273..bea846f9b8b8 100644 --- a/components/brave_rewards/resources/ui/components/walletWrapper/index.tsx +++ b/components/brave_rewards/resources/ui/components/walletWrapper/index.tsx @@ -97,6 +97,7 @@ export type NotificationType = 'error' | 'grant' | 'insufficientFunds' | + 'mismatchedProviderAccounts' | 'pendingContribution' | 'tipsProcessed' | 'upholdBATNotAllowedForUser' | @@ -279,6 +280,7 @@ export default class WalletWrapper extends React.PureComponent { buttonAction = this.onNotificationClick break case 'deviceLimitReached': + case 'mismatchedProviderAccounts': case 'upholdBATNotAllowedForUser': case 'upholdBlockedUser': case 'upholdPendingUser': @@ -465,6 +467,7 @@ export default class WalletWrapper extends React.PureComponent { case 'backupWallet': case 'deviceLimitReached': case 'insufficientFunds': + case 'mismatchedProviderAccounts': case 'upholdBATNotAllowedForUser': case 'upholdBlockedUser': case 'upholdPendingUser': @@ -500,6 +503,7 @@ export default class WalletWrapper extends React.PureComponent { switch (notification.type) { case 'backupWallet': case 'deviceLimitReached': + case 'mismatchedProviderAccounts': case 'pendingContribution': case 'upholdBATNotAllowedForUser': case 'upholdBlockedUser': diff --git a/vendor/bat-native-ledger/src/bat/ledger/internal/endpoint/promotion/post_claim_uphold/post_claim_uphold.cc b/vendor/bat-native-ledger/src/bat/ledger/internal/endpoint/promotion/post_claim_uphold/post_claim_uphold.cc index f0a59e0290c4..8374f78499d3 100644 --- a/vendor/bat-native-ledger/src/bat/ledger/internal/endpoint/promotion/post_claim_uphold/post_claim_uphold.cc +++ b/vendor/bat-native-ledger/src/bat/ledger/internal/endpoint/promotion/post_claim_uphold/post_claim_uphold.cc @@ -121,7 +121,7 @@ type::Result PostClaimUphold::CheckStatusCode(const int status_code) const { if (status_code == net::HTTP_FORBIDDEN) { BLOG(0, "Forbidden"); - return type::Result::LEDGER_ERROR; + return type::Result::TOO_MANY_RESULTS; } if (status_code == net::HTTP_NOT_FOUND) { @@ -130,7 +130,7 @@ type::Result PostClaimUphold::CheckStatusCode(const int status_code) const { } if (status_code == net::HTTP_CONFLICT) { - BLOG(0, "Not found"); + BLOG(0, "Conflict"); return type::Result::ALREADY_EXISTS; } diff --git a/vendor/bat-native-ledger/src/bat/ledger/internal/endpoint/promotion/post_claim_uphold/post_claim_uphold_unittest.cc b/vendor/bat-native-ledger/src/bat/ledger/internal/endpoint/promotion/post_claim_uphold/post_claim_uphold_unittest.cc index 867fc42e84e2..813874d7604d 100644 --- a/vendor/bat-native-ledger/src/bat/ledger/internal/endpoint/promotion/post_claim_uphold/post_claim_uphold_unittest.cc +++ b/vendor/bat-native-ledger/src/bat/ledger/internal/endpoint/promotion/post_claim_uphold/post_claim_uphold_unittest.cc @@ -92,7 +92,7 @@ TEST_F(PostClaimUpholdTest, ServerError403) { claim_->Request(30.0, "address", [](const type::Result result, const std::string& address) { - EXPECT_EQ(result, type::Result::LEDGER_ERROR); + EXPECT_EQ(result, type::Result::TOO_MANY_RESULTS); EXPECT_EQ(address, kExpectedAddress); }); } diff --git a/vendor/bat-native-ledger/src/bat/ledger/internal/logging/event_log_keys.h b/vendor/bat-native-ledger/src/bat/ledger/internal/logging/event_log_keys.h index 790dd0ed8330..c3043b289d4b 100644 --- a/vendor/bat-native-ledger/src/bat/ledger/internal/logging/event_log_keys.h +++ b/vendor/bat-native-ledger/src/bat/ledger/internal/logging/event_log_keys.h @@ -12,16 +12,17 @@ namespace ledger { namespace log { const char kACAddedToQueue[] = "ac_added_to_queue"; -const char kWalletConnected[] = "wallet_connected"; -const char kWalletVerified[] = "wallet_verified"; -const char kWalletDisconnected[] = "wallet_disconnected"; -const char kRecurringTipAdded[] = "recurring_tip_added"; -const char kRecurringTipRemoved[] = "recurring_tip_removed"; const char kDatabaseMigrated[] = "database_migrated"; +const char kDeviceLimitReached[] = "device_limit_reached"; +const char kMismatchedProviderAccounts[] = "mismatched_provider_accounts"; const char kPromotionsClaimed[] = "promotion_claimed"; +const char kRecurringTipAdded[] = "recurring_tip_added"; +const char kRecurringTipRemoved[] = "recurring_tip_removed"; +const char kWalletConnected[] = "wallet_connected"; +const char kWalletDisconnected[] = "wallet_disconnected"; const char kWalletRecovered[] = "wallet_recovered"; -const char kDeviceLimitReached[] = "device_limit_reached"; const char kWalletStatusChange[] = "wallet_status_change"; +const char kWalletVerified[] = "wallet_verified"; } // namespace log } // namespace ledger diff --git a/vendor/bat-native-ledger/src/bat/ledger/internal/notifications/notification_keys.h b/vendor/bat-native-ledger/src/bat/ledger/internal/notifications/notification_keys.h index 1570b0926e16..2418c237b0e7 100644 --- a/vendor/bat-native-ledger/src/bat/ledger/internal/notifications/notification_keys.h +++ b/vendor/bat-native-ledger/src/bat/ledger/internal/notifications/notification_keys.h @@ -10,6 +10,8 @@ namespace ledger { namespace notifications { const char kWalletDeviceLimitReached[] = "wallet_device_limit_reached"; +const char kWalletMismatchedProviderAccounts[] = + "wallet_mismatched_provider_accounts"; const char kWalletDisconnected[] = "wallet_disconnected"; const char kWalletNewVerified[] = "wallet_new_verified"; diff --git a/vendor/bat-native-ledger/src/bat/ledger/internal/uphold/uphold.cc b/vendor/bat-native-ledger/src/bat/ledger/internal/uphold/uphold.cc index 24d23a25671f..6233f3e35a98 100644 --- a/vendor/bat-native-ledger/src/bat/ledger/internal/uphold/uphold.cc +++ b/vendor/bat-native-ledger/src/bat/ledger/internal/uphold/uphold.cc @@ -207,7 +207,7 @@ void Uphold::DisconnectWallet(const std::string& notification) { const bool shutting_down = ledger_->IsShuttingDown(); if (!manual && !shutting_down) { - ledger_->ledger_client()->ShowNotification(notification, {}, + ledger_->ledger_client()->ShowNotification(notification, {"Uphold"}, [](type::Result _) {}); } diff --git a/vendor/bat-native-ledger/src/bat/ledger/internal/uphold/uphold_unittest.cc b/vendor/bat-native-ledger/src/bat/ledger/internal/uphold/uphold_unittest.cc index bc2a7f1fba64..ee5214fe27aa 100644 --- a/vendor/bat-native-ledger/src/bat/ledger/internal/uphold/uphold_unittest.cc +++ b/vendor/bat-native-ledger/src/bat/ledger/internal/uphold/uphold_unittest.cc @@ -1109,8 +1109,37 @@ INSTANTIATE_TEST_SUITE_P( type::Result::ALREADY_EXISTS, type::WalletStatus::NOT_CONNECTED }, + LinkWalletParamType{ // Mismatched provider accounts. + "01_mismatched_provider_accounts", + R"({ "status": 5, "token": "0047c2fd8f023e067354dbdb5639ee67acf77150" })", + type::UrlResponse{ + {}, + {}, + net::HttpStatusCode::HTTP_OK, + R"({ "currencies": [ "BAT" ], "status": "ok", "memberAt": "2021-05-26T16:42:23.134Z" })", + {} + }, + type::UrlResponse{ + {}, + {}, + net::HttpStatusCode::HTTP_OK, + R"([ { "id": "962ef3b8-bc12-4619-a349-c8083931b795", "label": "Brave Browser" } ])", + {} + }, + false, + R"({ "payment_id": "f375da3c-c206-4f09-9422-665b8e5952db", "recovery_seed": "OG2zYotDSeZ81qLtr/uq5k/GC6WE5/7BclT1lHi4l+w=" })", + type::UrlResponse{ + {}, + {}, + net::HttpStatusCode::HTTP_FORBIDDEN, + {}, + {} + }, + type::Result::TOO_MANY_RESULTS, + type::WalletStatus::NOT_CONNECTED + }, LinkWalletParamType{ // Rewards Link (Claim) Wallet failed. - "01_link_wallet_failed", + "02_link_wallet_failed", R"({ "status": 5, "token": "0047c2fd8f023e067354dbdb5639ee67acf77150" })", type::UrlResponse{ {}, @@ -1139,7 +1168,7 @@ INSTANTIATE_TEST_SUITE_P( type::WalletStatus::PENDING }, LinkWalletParamType{ // Happy path. - "02_happy_path", + "03_happy_path", R"({ "status": 5, "token": "0047c2fd8f023e067354dbdb5639ee67acf77150" })", type::UrlResponse{ {}, diff --git a/vendor/bat-native-ledger/src/bat/ledger/internal/uphold/uphold_wallet.cc b/vendor/bat-native-ledger/src/bat/ledger/internal/uphold/uphold_wallet.cc index b84830429eb9..32ff7a68e52c 100644 --- a/vendor/bat-native-ledger/src/bat/ledger/internal/uphold/uphold_wallet.cc +++ b/vendor/bat-native-ledger/src/bat/ledger/internal/uphold/uphold_wallet.cc @@ -272,6 +272,18 @@ void UpholdWallet::OnLinkWallet(const type::Result result, return callback(type::Result::ALREADY_EXISTS); } + if (result == type::Result::TOO_MANY_RESULTS) { + // Entering NOT_CONNECTED. + ledger_->uphold()->DisconnectWallet( + ledger::notifications::kWalletMismatchedProviderAccounts); + + ledger_->database()->SaveEventLog( + log::kMismatchedProviderAccounts, + constant::kWalletUphold + std::string("/") + id.substr(0, 5)); + + return callback(type::Result::TOO_MANY_RESULTS); + } + if (result != type::Result::LEDGER_OK) { return callback(type::Result::CONTINUE); }