Adds 25 BAT limit for uphold
Resolves https://github.com/brave/brave-browser/issues/9723
This commit is contained in:
@@ -1014,6 +1014,7 @@ void BraveRewardsGetExternalWalletFunction::OnExternalWalet(
|
||||
data->SetStringKey("withdrawUrl", wallet->withdraw_url);
|
||||
data->SetStringKey("userName", wallet->user_name);
|
||||
data->SetStringKey("accountUrl", wallet->account_url);
|
||||
data->SetStringKey("loginUrl", wallet->login_url);
|
||||
}
|
||||
|
||||
Respond(TwoArguments(
|
||||
|
||||
@@ -1647,6 +1647,7 @@ void RewardsDOMHandler::OnGetExternalWallet(
|
||||
wallet_dict.SetStringKey("withdrawUrl", wallet->withdraw_url);
|
||||
wallet_dict.SetStringKey("userName", wallet->user_name);
|
||||
wallet_dict.SetStringKey("accountUrl", wallet->account_url);
|
||||
wallet_dict.SetStringKey("loginUrl", wallet->login_url);
|
||||
}
|
||||
|
||||
data.SetKey("wallet", std::move(wallet_dict));
|
||||
|
||||
@@ -463,6 +463,7 @@ void RewardsTipDOMHandler::OnExternalWallet(
|
||||
data.SetString("withdrawUrl", wallet->withdraw_url);
|
||||
data.SetString("userName", wallet->user_name);
|
||||
data.SetString("accountUrl", wallet->account_url);
|
||||
data.SetString("loginUrl", wallet->login_url);
|
||||
data.SetInteger("status", static_cast<int>(wallet->status));
|
||||
}
|
||||
|
||||
|
||||
@@ -411,6 +411,8 @@ void CustomizeWebUIHTMLSource(const std::string &name,
|
||||
{ "redirectModalError", IDS_BRAVE_REWARDS_LOCAL_REDIRECT_MODAL_ERROR },
|
||||
{ "redirectModalClose", IDS_BRAVE_REWARDS_LOCAL_REDIRECT_MODAL_CLOSE },
|
||||
{ "redirectModalErrorWallet", IDS_BRAVE_REWARDS_LOCAL_REDIRECT_MODAL_ERROR_WALLET }, // NOLINT
|
||||
{ "redirectModalBatLimitTitle", IDS_BRAVE_REWARDS_LOCAL_REDIRECT_MODAL_BAT_LIMIT_TITLE }, // NOLINT
|
||||
{ "redirectModalBatLimitText", IDS_BRAVE_REWARDS_LOCAL_REDIRECT_MODAL_BAT_LIMIT_TEXT }, // NOLINT
|
||||
|
||||
{ "click", IDS_BRAVE_REWARDS_LOCAL_ADS_CONFIRMATION_TYPE_CLICK },
|
||||
{ "dismiss", IDS_BRAVE_REWARDS_LOCAL_ADS_CONFIRMATION_TYPE_DISMISS },
|
||||
@@ -510,6 +512,9 @@ void CustomizeWebUIHTMLSource(const std::string &name,
|
||||
{ "import", IDS_BRAVE_UI_IMPORT },
|
||||
{ "includeInAuto", IDS_BRAVE_UI_INCLUDE_IN_AUTO },
|
||||
{ "learnMore", IDS_BRAVE_UI_LEARN_MORE },
|
||||
{ "login", IDS_BRAVE_UI_LOGIN },
|
||||
{ "loginMessageTitle", IDS_BRAVE_UI_LOGIN_MESSAGE_TITLE },
|
||||
{ "loginMessageText", IDS_BRAVE_UI_LOGIN_MESSAGE_TEXT },
|
||||
{ "makeMonthly", IDS_BRAVE_UI_MAKE_MONTHLY },
|
||||
{ "manageWallet", IDS_BRAVE_UI_MANAGE_WALLET },
|
||||
{ "markAsInappropriate", IDS_BRAVE_UI_ADS_MARK_AS_INAPPROPRIATE },
|
||||
|
||||
@@ -1049,6 +1049,9 @@
|
||||
},
|
||||
"accountUrl": {
|
||||
"type": "any"
|
||||
},
|
||||
"loginUrl": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace brave_rewards {
|
||||
withdraw_url = properties.withdraw_url;
|
||||
user_name = properties.user_name;
|
||||
account_url = properties.account_url;
|
||||
login_url = properties.login_url;
|
||||
}
|
||||
|
||||
std::string ExternalWallet::toJson() {
|
||||
@@ -41,6 +42,7 @@ namespace brave_rewards {
|
||||
dict.SetStringKey("withdraw_url", withdraw_url);
|
||||
dict.SetStringKey("user_name", user_name);
|
||||
dict.SetStringKey("account_url", account_url);
|
||||
dict.SetStringKey("login_url", login_url);
|
||||
base::JSONWriter::Write(dict, &json_wallet);
|
||||
return json_wallet;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ struct ExternalWallet {
|
||||
std::string withdraw_url;
|
||||
std::string user_name;
|
||||
std::string account_url;
|
||||
std::string login_url;
|
||||
};
|
||||
|
||||
} // namespace brave_rewards
|
||||
|
||||
@@ -3151,6 +3151,7 @@ void RewardsServiceImpl::SaveExternalWallet(const std::string& wallet_type,
|
||||
new_wallet.SetStringKey("add_url", wallet->add_url);
|
||||
new_wallet.SetStringKey("withdraw_url", wallet->withdraw_url);
|
||||
new_wallet.SetStringKey("account_url", wallet->account_url);
|
||||
new_wallet.SetStringKey("login_url", wallet->login_url);
|
||||
|
||||
new_wallets.SetKey(wallet_type, std::move(new_wallet));
|
||||
|
||||
@@ -3219,6 +3220,11 @@ RewardsServiceImpl::GetExternalWallets() {
|
||||
wallet->account_url = *account_url;
|
||||
}
|
||||
|
||||
auto* login_url = it.second.FindStringKey("login_url");
|
||||
if (login_url) {
|
||||
wallet->login_url = *login_url;
|
||||
}
|
||||
|
||||
wallets.insert(std::make_pair(it.first, std::move(wallet)));
|
||||
}
|
||||
|
||||
@@ -3243,6 +3249,7 @@ void RewardsServiceImpl::OnGetExternalWallet(
|
||||
external->withdraw_url = wallet->withdraw_url;
|
||||
external->user_name = wallet->user_name;
|
||||
external->account_url = wallet->account_url;
|
||||
external->login_url = wallet->login_url;
|
||||
}
|
||||
|
||||
std::move(callback).Run(static_cast<int>(result), std::move(external));
|
||||
|
||||
@@ -67,6 +67,23 @@ void RewardsBrowserTestPromotion::OnPromotionFinished(
|
||||
}
|
||||
}
|
||||
|
||||
void RewardsBrowserTestPromotion::WaitForUnblindedTokensReady() {
|
||||
if (unblinded_tokens_) {
|
||||
return;
|
||||
}
|
||||
|
||||
wait_for_unblinded_tokens_loop_.reset(new base::RunLoop);
|
||||
wait_for_unblinded_tokens_loop_->Run();
|
||||
}
|
||||
|
||||
void RewardsBrowserTestPromotion::OnUnblindedTokensReady(
|
||||
brave_rewards::RewardsService* rewards_service) {
|
||||
unblinded_tokens_ = true;
|
||||
if (wait_for_unblinded_tokens_loop_) {
|
||||
wait_for_unblinded_tokens_loop_->Quit();
|
||||
}
|
||||
}
|
||||
|
||||
brave_rewards::Promotion RewardsBrowserTestPromotion::GetPromotion() {
|
||||
return promotion_;
|
||||
}
|
||||
@@ -90,6 +107,7 @@ double RewardsBrowserTestPromotion::ClaimPromotionViaCode() {
|
||||
solution,
|
||||
base::DoNothing());
|
||||
WaitForPromotionFinished();
|
||||
WaitForUnblindedTokensReady();
|
||||
return 30;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,8 @@ class RewardsBrowserTestPromotion
|
||||
|
||||
void WaitForPromotionFinished();
|
||||
|
||||
void WaitForUnblindedTokensReady();
|
||||
|
||||
brave_rewards::Promotion GetPromotion();
|
||||
|
||||
std::string GetPromotionId();
|
||||
@@ -49,10 +51,15 @@ class RewardsBrowserTestPromotion
|
||||
const uint32_t result,
|
||||
brave_rewards::Promotion promotion) override;
|
||||
|
||||
void OnUnblindedTokensReady(
|
||||
brave_rewards::RewardsService* rewards_service) override;
|
||||
|
||||
std::unique_ptr<base::RunLoop> wait_for_initialization_loop_;
|
||||
bool initialized_ = false;
|
||||
std::unique_ptr<base::RunLoop> wait_for_finished_loop_;
|
||||
bool finished_ = false;
|
||||
std::unique_ptr<base::RunLoop> wait_for_unblinded_tokens_loop_;
|
||||
bool unblinded_tokens_ = false;
|
||||
|
||||
brave_rewards::Promotion promotion_;
|
||||
Browser* browser_; // NOT OWNED
|
||||
|
||||
@@ -240,6 +240,8 @@ IN_PROC_BROWSER_TEST_F(
|
||||
|
||||
IN_PROC_BROWSER_TEST_F(RewardsBrowserTest, NotVerifiedWallet) {
|
||||
rewards_browsertest_helper::EnableRewards(browser());
|
||||
contribution_->AddBalance(promotion_->ClaimPromotionViaCode());
|
||||
contribution_->IsBalanceCorrect();
|
||||
|
||||
// Click on verify button
|
||||
rewards_browsertest_util::WaitForElementThenClick(
|
||||
@@ -452,4 +454,32 @@ IN_PROC_BROWSER_TEST_F(RewardsBrowserTest, ResetRewardsWithBAT) {
|
||||
"Your 30 BATs and other Rewards");
|
||||
}
|
||||
|
||||
IN_PROC_BROWSER_TEST_F(RewardsBrowserTest, UpholdLimitNoBAT) {
|
||||
rewards_browsertest_helper::EnableRewards(browser());
|
||||
|
||||
rewards_browsertest_util::WaitForElementThenClick(
|
||||
contents(),
|
||||
"#verify-wallet-button");
|
||||
|
||||
rewards_browsertest_util::WaitForElementThenClick(
|
||||
contents(),
|
||||
"#cancel-login-button");
|
||||
|
||||
rewards_browsertest_util::WaitForElementThenClick(
|
||||
contents(),
|
||||
"#verify-wallet-button");
|
||||
|
||||
rewards_browsertest_util::WaitForElementThenClick(
|
||||
contents(),
|
||||
"#login-button");
|
||||
|
||||
// Check if we are redirected to uphold
|
||||
{
|
||||
const GURL current_url = contents()->GetURL();
|
||||
|
||||
auto found = current_url.spec().find("intention=login");
|
||||
ASSERT_TRUE(found != std::string::npos);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace rewards_browsertest
|
||||
|
||||
+16
@@ -598,5 +598,21 @@
|
||||
"example": "John"
|
||||
}
|
||||
}
|
||||
},
|
||||
"cancel": {
|
||||
"message": "Cancel",
|
||||
"description": "Text for cancel button"
|
||||
},
|
||||
"login": {
|
||||
"message": "Login",
|
||||
"description": "Text for login button"
|
||||
},
|
||||
"loginMessageTitle": {
|
||||
"message": "Verifying wallet allows you to manage your funds more efficiently.",
|
||||
"description": "Text for login button"
|
||||
},
|
||||
"loginMessageText": {
|
||||
"message": "You need to have minimum 25 BAT to create an Uphold account. Please try again later. <br/> If you already have a verified Uphold account, continue to login.",
|
||||
"description": "Text for login button"
|
||||
}
|
||||
}
|
||||
|
||||
+5
-1
@@ -143,7 +143,11 @@ export const getUIMessages = (): Record<string, string> => {
|
||||
'walletVerificationListHeader',
|
||||
'walletVerificationTitle1',
|
||||
'walletVerified',
|
||||
'yourBalance'
|
||||
'yourBalance',
|
||||
'cancel',
|
||||
'login',
|
||||
'loginMessageTitle',
|
||||
'loginMessageText'
|
||||
]
|
||||
|
||||
let translations = {}
|
||||
|
||||
@@ -241,7 +241,7 @@ export class RewardsPanel extends React.Component<Props, State> {
|
||||
}
|
||||
|
||||
openRewardsAddFunds = () => {
|
||||
const { externalWallet } = this.props.rewardsPanelData
|
||||
const { externalWallet, balance } = this.props.rewardsPanelData
|
||||
|
||||
if (!externalWallet) {
|
||||
return
|
||||
@@ -254,10 +254,7 @@ export class RewardsPanel extends React.Component<Props, State> {
|
||||
return
|
||||
}
|
||||
|
||||
if (externalWallet.verifyUrl) {
|
||||
utils.handleUpholdLink(externalWallet.verifyUrl, externalWallet)
|
||||
return
|
||||
}
|
||||
utils.handleUpholdLink(balance, externalWallet)
|
||||
}
|
||||
|
||||
openTOS () {
|
||||
@@ -331,7 +328,7 @@ export class RewardsPanel extends React.Component<Props, State> {
|
||||
let onVerifyClick = undefined
|
||||
if (!this.state.onlyAnonWallet) {
|
||||
walletStatus = utils.getWalletStatus(externalWallet)
|
||||
onVerifyClick = utils.onVerifyClick.bind(this, this.actions)
|
||||
onVerifyClick = utils.handleUpholdLink.bind(this, balance, externalWallet)
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -253,7 +253,7 @@ export class Panel extends React.Component<Props, State> {
|
||||
}
|
||||
|
||||
onAddFunds = (notificationId?: string) => {
|
||||
const { externalWallet } = this.props.rewardsPanelData
|
||||
const { externalWallet, balance } = this.props.rewardsPanelData
|
||||
|
||||
if (notificationId) {
|
||||
this.actions.deleteNotification(notificationId)
|
||||
@@ -270,10 +270,7 @@ export class Panel extends React.Component<Props, State> {
|
||||
return
|
||||
}
|
||||
|
||||
if (externalWallet.verifyUrl) {
|
||||
utils.handleUpholdLink(externalWallet.verifyUrl, externalWallet)
|
||||
return
|
||||
}
|
||||
utils.handleUpholdLink(balance, externalWallet)
|
||||
}
|
||||
|
||||
showTipSiteDetail = (monthly: boolean) => {
|
||||
@@ -720,7 +717,7 @@ export class Panel extends React.Component<Props, State> {
|
||||
let onVerifyClick = undefined
|
||||
if (!this.props.onlyAnonWallet) {
|
||||
walletStatus = utils.getWalletStatus(externalWallet)
|
||||
onVerifyClick = utils.onVerifyClick.bind(this, this.actions)
|
||||
onVerifyClick = utils.handleUpholdLink.bind(this, balance, externalWallet)
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -745,6 +742,7 @@ export class Panel extends React.Component<Props, State> {
|
||||
goToUphold={this.goToUphold}
|
||||
greetings={utils.getGreetings(externalWallet)}
|
||||
onlyAnonWallet={this.props.onlyAnonWallet}
|
||||
showLoginMessage={balance.total < 25}
|
||||
{...notification}
|
||||
>
|
||||
<WalletSummarySlider
|
||||
|
||||
@@ -147,41 +147,38 @@ export const getGreetings = (externalWallet?: RewardsExtension.ExternalWallet) =
|
||||
return getMessage('greetingsVerified', [externalWallet.userName])
|
||||
}
|
||||
|
||||
export const handleUpholdLink = (link: string, externalWallet?: RewardsExtension.ExternalWallet) => {
|
||||
export const handleUpholdLink = (balance: RewardsExtension.Balance, externalWallet?: RewardsExtension.ExternalWallet) => {
|
||||
if (!externalWallet) {
|
||||
return
|
||||
}
|
||||
|
||||
let link = externalWallet.verifyUrl
|
||||
|
||||
if (!externalWallet || (externalWallet && externalWallet.status === 0)) {
|
||||
link = 'brave://rewards/#verify'
|
||||
}
|
||||
|
||||
if (balance.total < 25) {
|
||||
link = externalWallet.loginUrl
|
||||
}
|
||||
|
||||
chrome.tabs.create({
|
||||
url: link
|
||||
})
|
||||
}
|
||||
|
||||
export const getExternalWallet = (actions: any, externalWallet?: RewardsExtension.ExternalWallet, open: boolean = false) => {
|
||||
export const getExternalWallet = (actions: any, externalWallet?: RewardsExtension.ExternalWallet) => {
|
||||
chrome.braveRewards.getExternalWallet('uphold', (result: number, wallet: RewardsExtension.ExternalWallet) => {
|
||||
// EXPIRED TOKEN
|
||||
if (result === 24) {
|
||||
getExternalWallet(actions, externalWallet, open)
|
||||
getExternalWallet(actions, externalWallet)
|
||||
return
|
||||
}
|
||||
|
||||
actions.onExternalWallet(wallet)
|
||||
|
||||
if (open && wallet.verifyUrl) {
|
||||
handleUpholdLink(wallet.verifyUrl)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export const onVerifyClick = (actions: any, externalWallet?: RewardsExtension.ExternalWallet) => {
|
||||
if (!externalWallet || externalWallet.verifyUrl) {
|
||||
getExternalWallet(actions, externalWallet, true)
|
||||
return
|
||||
}
|
||||
|
||||
handleUpholdLink(externalWallet.verifyUrl)
|
||||
}
|
||||
|
||||
export const getClaimedPromotions = (promotions: RewardsExtension.Promotion[]) => {
|
||||
return promotions.filter((promotion: RewardsExtension.Promotion) => {
|
||||
return promotion.status === 4 // PromotionStatus::FINISHED
|
||||
|
||||
@@ -360,15 +360,24 @@ class PageWallet extends React.Component<Props, State> {
|
||||
this.actions.removeAllPendingContribution()
|
||||
}
|
||||
|
||||
handleUpholdLink = (link: string) => {
|
||||
const { ui, externalWallet } = this.props.rewardsData
|
||||
if (!ui.onBoardingDisplayed &&
|
||||
(!externalWallet || (externalWallet && externalWallet.status === 0))) {
|
||||
handleUpholdLink = () => {
|
||||
const { ui, externalWallet, balance } = this.props.rewardsData
|
||||
|
||||
if (!externalWallet) {
|
||||
return
|
||||
}
|
||||
|
||||
if (balance.total < 25) {
|
||||
window.open(externalWallet.loginUrl, '_self')
|
||||
return
|
||||
}
|
||||
|
||||
if (!ui.onBoardingDisplayed && externalWallet.status === 0) {
|
||||
this.toggleVerifyModal()
|
||||
return
|
||||
}
|
||||
|
||||
window.open(link, '_self')
|
||||
window.open(externalWallet.verifyUrl, '_self')
|
||||
}
|
||||
|
||||
onVerifyClick = (hideVerify: boolean) => {
|
||||
@@ -383,7 +392,7 @@ class PageWallet extends React.Component<Props, State> {
|
||||
this.actions.onOnBoardingDisplayed()
|
||||
}
|
||||
|
||||
this.handleUpholdLink(externalWallet.verifyUrl)
|
||||
this.handleUpholdLink()
|
||||
}
|
||||
|
||||
getWalletStatus = (): WalletState | undefined => {
|
||||
@@ -436,7 +445,7 @@ class PageWallet extends React.Component<Props, State> {
|
||||
}
|
||||
|
||||
if (externalWallet.verifyUrl) {
|
||||
this.handleUpholdLink(externalWallet.verifyUrl)
|
||||
this.handleUpholdLink()
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -793,6 +802,7 @@ class PageWallet extends React.Component<Props, State> {
|
||||
goToUphold={this.goToUphold}
|
||||
greetings={this.getGreetings()}
|
||||
onlyAnonWallet={onlyAnonWallet}
|
||||
showLoginMessage={balance.total < 25}
|
||||
>
|
||||
{
|
||||
enabledMain
|
||||
|
||||
@@ -240,6 +240,18 @@ class SettingsPage extends React.Component<Props, State> {
|
||||
)
|
||||
}
|
||||
|
||||
if (ui.modalRedirect === 'batLimit') {
|
||||
return (
|
||||
<ModalRedirect
|
||||
id={'redirect-modal-bat-limit'}
|
||||
titleText={getLocale('redirectModalBatLimitTitle')}
|
||||
errorText={{ __html: getLocale('redirectModalBatLimitText') }}
|
||||
buttonText={getLocale('redirectModalClose')}
|
||||
onClick={this.actions.hideRedirectModal}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
if (ui.modalRedirect === 'error') {
|
||||
return (
|
||||
<ModalRedirect
|
||||
|
||||
@@ -342,6 +342,12 @@ const rewardsReducer: Reducer<Rewards.State | undefined> = (state: Rewards.State
|
||||
break
|
||||
}
|
||||
|
||||
// NOT_FOUND
|
||||
if (data.result === 9) {
|
||||
ui.modalRedirect = 'batLimit'
|
||||
break
|
||||
}
|
||||
|
||||
if (data.result !== 0) {
|
||||
ui.modalRedirect = 'error'
|
||||
break
|
||||
|
||||
@@ -41,7 +41,10 @@ import {
|
||||
StyledVerifiedButtonIcon,
|
||||
StyledVerifiedButtonText,
|
||||
StyledDialogList,
|
||||
StyledLink
|
||||
StyledLink,
|
||||
LoginMessage,
|
||||
LoginMessageButtons,
|
||||
LoginMessageText
|
||||
} from './style'
|
||||
import { getLocale } from 'brave-ui/helpers'
|
||||
import { GrantCaptcha, GrantComplete, GrantError, GrantWrapper, WalletPopup } from '../'
|
||||
@@ -151,6 +154,7 @@ export interface Props {
|
||||
goToUphold?: () => void
|
||||
greetings?: string
|
||||
onlyAnonWallet?: boolean
|
||||
showLoginMessage?: boolean
|
||||
}
|
||||
|
||||
export type Step = '' | 'captcha' | 'complete'
|
||||
@@ -158,6 +162,7 @@ export type Step = '' | 'captcha' | 'complete'
|
||||
interface State {
|
||||
grantDetails: boolean,
|
||||
verificationDetails: boolean
|
||||
showLoginMessage: boolean
|
||||
}
|
||||
|
||||
export default class WalletWrapper extends React.PureComponent<Props, State> {
|
||||
@@ -165,7 +170,8 @@ export default class WalletWrapper extends React.PureComponent<Props, State> {
|
||||
super(props)
|
||||
this.state = {
|
||||
grantDetails: false,
|
||||
verificationDetails: false
|
||||
verificationDetails: false,
|
||||
showLoginMessage: false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -317,12 +323,27 @@ export default class WalletWrapper extends React.PureComponent<Props, State> {
|
||||
)
|
||||
}
|
||||
|
||||
walletButtonClicked = () => {
|
||||
if (!this.props.onVerifyClick) {
|
||||
return
|
||||
}
|
||||
|
||||
if (!this.props.showLoginMessage) {
|
||||
this.props.onVerifyClick()
|
||||
return
|
||||
}
|
||||
|
||||
this.setState({
|
||||
showLoginMessage: true
|
||||
})
|
||||
}
|
||||
|
||||
generateWalletButton = (walletState: WalletState) => {
|
||||
const buttonProps: Partial<ButtonProps> = {
|
||||
size: 'small',
|
||||
level: 'primary',
|
||||
brand: 'rewards',
|
||||
onClick: this.props.onVerifyClick
|
||||
onClick: this.walletButtonClicked
|
||||
}
|
||||
|
||||
switch (walletState) {
|
||||
@@ -531,6 +552,12 @@ export default class WalletWrapper extends React.PureComponent<Props, State> {
|
||||
)
|
||||
}
|
||||
|
||||
toggleLoginMessage = () => {
|
||||
this.setState({
|
||||
showLoginMessage: false
|
||||
})
|
||||
}
|
||||
|
||||
render () {
|
||||
const {
|
||||
id,
|
||||
@@ -695,6 +722,32 @@ export default class WalletWrapper extends React.PureComponent<Props, State> {
|
||||
: this.generateNotification(notification)
|
||||
}
|
||||
<StyledCurve background={gradientTop} />
|
||||
{
|
||||
this.state.showLoginMessage
|
||||
? <LoginMessage>
|
||||
<LoginMessageText>
|
||||
<b>{getLocale('loginMessageTitle')}</b>
|
||||
<p dangerouslySetInnerHTML={{ __html: getLocale('loginMessageText') }} />
|
||||
</LoginMessageText>
|
||||
<LoginMessageButtons>
|
||||
<Button
|
||||
level={'secondary'}
|
||||
type={'accent'}
|
||||
text={getLocale('cancel')}
|
||||
onClick={this.toggleLoginMessage}
|
||||
id={'cancel-login-button'}
|
||||
/>
|
||||
<Button
|
||||
level={'primary'}
|
||||
type={'accent'}
|
||||
text={getLocale('login')}
|
||||
onClick={this.props.onVerifyClick}
|
||||
id={'login-button'}
|
||||
/>
|
||||
</LoginMessageButtons>
|
||||
</LoginMessage>
|
||||
: null
|
||||
}
|
||||
</StyledHeader>
|
||||
<StyledContent
|
||||
contentPadding={contentPadding}
|
||||
|
||||
@@ -387,3 +387,32 @@ export const StyledLink = styled<{}, 'a'>('a')`
|
||||
display: inline-block;
|
||||
cursor: pointer;
|
||||
`
|
||||
|
||||
export const LoginMessage = styled<{}, 'div'>('div')`
|
||||
position: absolute;
|
||||
background: ${palette.white};
|
||||
top: 50px;
|
||||
left: 0;
|
||||
right: 0;
|
||||
margin: 0 auto;
|
||||
border-radius: 6px;
|
||||
width: 95%;
|
||||
box-shadow: 0 0 12px 0 rgba(12, 13, 33, 0.44);
|
||||
z-index: 5;
|
||||
`
|
||||
|
||||
export const LoginMessageText = styled<{}, 'div'>('div')`
|
||||
margin: 0;
|
||||
padding: 15px;
|
||||
line-height: 1.3;
|
||||
`
|
||||
|
||||
export const LoginMessageButtons = styled<{}, 'div'>('div')`
|
||||
display: flex;
|
||||
margin: 0 0 15px;
|
||||
justify-content: center;
|
||||
|
||||
> button {
|
||||
margin: 0 5px;
|
||||
}
|
||||
`
|
||||
|
||||
Vendored
+2
-1
@@ -68,7 +68,7 @@ declare namespace Rewards {
|
||||
ui: {
|
||||
emptyWallet: boolean
|
||||
modalBackup: boolean
|
||||
modalRedirect: 'show' | 'hide' | 'error' | 'notAllowed'
|
||||
modalRedirect: 'show' | 'hide' | 'error' | 'notAllowed' | 'batLimit'
|
||||
paymentIdCheck: boolean
|
||||
promosDismissed?: {
|
||||
[key: string]: boolean
|
||||
@@ -288,6 +288,7 @@ declare namespace Rewards {
|
||||
withdrawUrl: string
|
||||
userName?: string
|
||||
accountUrl: string
|
||||
loginUrl: string
|
||||
}
|
||||
|
||||
export interface ProcessRewardsPageUrl {
|
||||
|
||||
@@ -183,5 +183,6 @@ declare namespace RewardsExtension {
|
||||
withdrawUrl: string
|
||||
userName: string
|
||||
accountUrl: string
|
||||
loginUrl: string
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -115,5 +115,6 @@ declare namespace RewardsTip {
|
||||
withdrawUrl: string
|
||||
userName: string
|
||||
accountUrl: string
|
||||
loginUrl: string
|
||||
}
|
||||
}
|
||||
|
||||
@@ -364,6 +364,8 @@
|
||||
<message name="IDS_BRAVE_REWARDS_LOCAL_REDIRECT_MODAL_NOT_ALLOWED" desc="">BAT is not currently supported in your region. Please refer <ph name="BEGIN_LINK_REGION_TEXT"><a target="_blank" href="$1"></ph>here<ph name="END_LINK_REGION_TEXT"></a></ph> for updates.</message>
|
||||
<message name="IDS_BRAVE_REWARDS_LOCAL_REDIRECT_MODAL_CLOSE" desc="">Close</message>
|
||||
<message name="IDS_BRAVE_REWARDS_LOCAL_REDIRECT_MODAL_ERROR_WALLET" desc="">Error creating Brave Browser BAT card</message>
|
||||
<message name="IDS_BRAVE_REWARDS_LOCAL_REDIRECT_MODAL_BAT_LIMIT_TITLE" desc="">You need a verified wallet to Login</message>
|
||||
<message name="IDS_BRAVE_REWARDS_LOCAL_REDIRECT_MODAL_BAT_LIMIT_TEXT" desc="">You need a minimum of 25 BAT to create an Uphold wallet. Please try again after you have verified your wallet with Uphold.</message>
|
||||
|
||||
<!-- WebUI rewards internals resources -->
|
||||
<message name="IDS_BRAVE_REWARDS_INTERNALS_AMOUNT" desc="Amount">Amount:</message>
|
||||
@@ -527,6 +529,9 @@
|
||||
<message name="IDS_BRAVE_UI_IMPORT" desc="">import</message>
|
||||
<message name="IDS_BRAVE_UI_INCLUDE_IN_AUTO" desc="">Include in Auto-Contribute</message>
|
||||
<message name="IDS_BRAVE_UI_LEARN_MORE" desc="">Learn More</message>
|
||||
<message name="IDS_BRAVE_UI_LOGIN" desc="">Login</message>
|
||||
<message name="IDS_BRAVE_UI_LOGIN_MESSAGE_TITLE" desc="">Verifying wallet allows you to manage your funds more efficiently.</message>
|
||||
<message name="IDS_BRAVE_UI_LOGIN_MESSAGE_TEXT" desc="">You need to have minimum 25 BAT to create an Uphold account. Please try again later. <ph name="BREAK"><br/></ph>If you already have a verified Uphold account, continue to login.</message>
|
||||
<message name="IDS_BRAVE_UI_MAKE_MONTHLY" desc="">Make this monthly</message>
|
||||
<message name="IDS_BRAVE_UI_MANAGE_WALLET" desc="">Manage Your Wallet</message>
|
||||
<message name="IDS_BRAVE_UI_MONTH_APR" desc="">Apr</message>
|
||||
|
||||
@@ -152,6 +152,7 @@ struct ExternalWallet {
|
||||
string one_time_string;
|
||||
string user_name;
|
||||
string account_url;
|
||||
string login_url;
|
||||
bool transferred;
|
||||
};
|
||||
|
||||
|
||||
+14
-2
@@ -38,13 +38,25 @@ void UpholdAuthorization::Authorize(
|
||||
callback(ledger::Result::LEDGER_ERROR, {});
|
||||
return;
|
||||
}
|
||||
|
||||
const auto current_one_time = wallet->one_time_string;
|
||||
|
||||
// we need to generate new string as soon as authorization is triggered
|
||||
wallet->one_time_string = GenerateRandomString(ledger::is_testing);
|
||||
ledger_->SaveExternalWallet(ledger::kWalletUphold, wallet->Clone());
|
||||
|
||||
auto it = args.find("error_description");
|
||||
if (it != args.end()) {
|
||||
const std::string message = args.at("error_description");
|
||||
BLOG(1, message);
|
||||
if (message == "User does not meet minimum requirements") {
|
||||
callback(ledger::Result::NOT_FOUND, {});
|
||||
return;
|
||||
}
|
||||
|
||||
callback(ledger::Result::LEDGER_ERROR, {});
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.empty()) {
|
||||
BLOG(0, "Arguments are empty");
|
||||
callback(ledger::Result::LEDGER_ERROR, {});
|
||||
@@ -52,7 +64,7 @@ void UpholdAuthorization::Authorize(
|
||||
}
|
||||
|
||||
std::string code;
|
||||
auto it = args.find("code");
|
||||
it = args.find("code");
|
||||
if (it != args.end()) {
|
||||
code = args.at("code");
|
||||
}
|
||||
|
||||
@@ -56,9 +56,9 @@ std::string GetACAddress() {
|
||||
: kACAddressStaging;
|
||||
}
|
||||
|
||||
std::string GetVerifyUrl(const std::string& state) {
|
||||
std::string GetAuthorizeUrl(const std::string& state, const bool kyc_flow) {
|
||||
const std::string id = GetClientId();
|
||||
|
||||
const std::string intention = kyc_flow ? "kyc" : "login";
|
||||
const std::string url = GetUrl();
|
||||
|
||||
return base::StringPrintf(
|
||||
@@ -73,10 +73,11 @@ std::string GetVerifyUrl(const std::string& state) {
|
||||
"transactions:read "
|
||||
"transactions:transfer:application "
|
||||
"transactions:transfer:others"
|
||||
"&intention=kyc&"
|
||||
"&intention=%s&"
|
||||
"state=%s",
|
||||
url.c_str(),
|
||||
id.c_str(),
|
||||
intention.c_str(),
|
||||
state.c_str());
|
||||
}
|
||||
|
||||
@@ -203,6 +204,7 @@ ledger::ExternalWalletPtr GenerateLinks(ledger::ExternalWalletPtr wallet) {
|
||||
|
||||
wallet->verify_url = GenerateVerifyLink(wallet->Clone());
|
||||
wallet->account_url = GetAccountUrl();
|
||||
wallet->login_url = GetAuthorizeUrl(wallet->one_time_string, false);
|
||||
|
||||
return wallet;
|
||||
}
|
||||
@@ -225,7 +227,7 @@ std::string GenerateVerifyLink(ledger::ExternalWalletPtr wallet) {
|
||||
case ledger::WalletStatus::NOT_CONNECTED:
|
||||
case ledger::WalletStatus::DISCONNECTED_VERIFIED:
|
||||
case ledger::WalletStatus::DISCONNECTED_NOT_VERIFIED: {
|
||||
url = GetVerifyUrl(wallet->one_time_string);
|
||||
url = GetAuthorizeUrl(wallet->one_time_string, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ std::string GetFeeAddress();
|
||||
|
||||
std::string GetACAddress();
|
||||
|
||||
std::string GetVerifyUrl(const std::string& state);
|
||||
std::string GetAuthorizeUrl(const std::string& state, const bool kyc_flow);
|
||||
|
||||
std::string GetAddUrl(const std::string& address);
|
||||
|
||||
|
||||
+26
-3
@@ -71,10 +71,11 @@ TEST(UpholdUtilTest, GetFeeAddress) {
|
||||
ASSERT_EQ(result, kFeeAddressStaging);
|
||||
}
|
||||
|
||||
TEST(UpholdUtilTest, GetVerifyUrl) {
|
||||
TEST(UpholdUtilTest, GetAuthorizeUrl) {
|
||||
// production
|
||||
ledger::_environment = ledger::Environment::PRODUCTION;
|
||||
std::string result = braveledger_uphold::GetVerifyUrl("rdfdsfsdfsdf");
|
||||
std::string result =
|
||||
braveledger_uphold::GetAuthorizeUrl("rdfdsfsdfsdf", true);
|
||||
ASSERT_EQ(result,
|
||||
"https://uphold.com/authorize/"
|
||||
"6d8d9473ed20be627f71ed46e207f40c004c5b1a?scope=accounts:read "
|
||||
@@ -85,7 +86,7 @@ TEST(UpholdUtilTest, GetVerifyUrl) {
|
||||
|
||||
// staging
|
||||
ledger::_environment = ledger::Environment::STAGING;
|
||||
result = braveledger_uphold::GetVerifyUrl("rdfdsfsdfsdf");
|
||||
result = braveledger_uphold::GetAuthorizeUrl("rdfdsfsdfsdf", true);
|
||||
ASSERT_EQ(result,
|
||||
"https://sandbox.uphold.com/authorize/"
|
||||
"4c2b665ca060d912fec5c735c734859a06118cc8?scope=accounts:read "
|
||||
@@ -93,6 +94,28 @@ TEST(UpholdUtilTest, GetVerifyUrl) {
|
||||
"transactions:deposit transactions:read "
|
||||
"transactions:transfer:application transactions:transfer:others"
|
||||
"&intention=kyc&state=rdfdsfsdfsdf");
|
||||
// production
|
||||
ledger::_environment = ledger::Environment::PRODUCTION;
|
||||
result =
|
||||
braveledger_uphold::GetAuthorizeUrl("rdfdsfsdfsdf", false);
|
||||
ASSERT_EQ(result,
|
||||
"https://uphold.com/authorize/"
|
||||
"6d8d9473ed20be627f71ed46e207f40c004c5b1a?scope=accounts:read "
|
||||
"accounts:write cards:read cards:write user:read "
|
||||
"transactions:deposit transactions:read "
|
||||
"transactions:transfer:application transactions:transfer:others"
|
||||
"&intention=login&state=rdfdsfsdfsdf");
|
||||
|
||||
// staging
|
||||
ledger::_environment = ledger::Environment::STAGING;
|
||||
result = braveledger_uphold::GetAuthorizeUrl("rdfdsfsdfsdf", false);
|
||||
ASSERT_EQ(result,
|
||||
"https://sandbox.uphold.com/authorize/"
|
||||
"4c2b665ca060d912fec5c735c734859a06118cc8?scope=accounts:read "
|
||||
"accounts:write cards:read cards:write user:read "
|
||||
"transactions:deposit transactions:read "
|
||||
"transactions:transfer:application transactions:transfer:others"
|
||||
"&intention=login&state=rdfdsfsdfsdf");
|
||||
}
|
||||
|
||||
TEST(UpholdUtilTest, GetAddUrl) {
|
||||
|
||||
Reference in New Issue
Block a user