diff --git a/DEPS b/DEPS index 4c76ebbb9e97..d598a5a38d66 100644 --- a/DEPS +++ b/DEPS @@ -10,7 +10,7 @@ deps = { "vendor/boto": "https://github.com/boto/boto@f7574aa6cc2c819430c1f05e9a1a1a666ef8169b", "vendor/python-patch": "https://github.com/svn2github/python-patch@a336a458016ced89aba90dfc3f4c8222ae3b1403", "vendor/sparkle": "https://github.com/brave/Sparkle.git@c0759cce415d7c0feae45005c8a013b1898711f0", - "vendor/bat-native-ledger": "https://github.com/brave-intl/bat-native-ledger@9a4d0e00d78343de8863d60657727ae4eb5d6321", + "vendor/bat-native-ledger": "https://github.com/brave-intl/bat-native-ledger@cb66ca61a15b3fe42783e322a5d02be6dae2d5b6", "vendor/bat-native-rapidjson": "https://github.com/brave-intl/bat-native-rapidjson.git@86aafe2ef89835ae71c9ed7c2527e3bb3000930e", "vendor/bip39wally-core-native": "https://github.com/brave-intl/bip39wally-core-native.git@9b119931c702d55be994117eb505d56310720b1d", "vendor/bat-native-anonize": "https://github.com/brave-intl/bat-native-anonize.git@adeff3254bb90ccdc9699040d5a4e1cd6b8393b7", diff --git a/browser/ui/webui/brave_webui_source.cc b/browser/ui/webui/brave_webui_source.cc index fc06aa2cf3bf..147dfe50340c 100644 --- a/browser/ui/webui/brave_webui_source.cc +++ b/browser/ui/webui/brave_webui_source.cc @@ -236,6 +236,12 @@ void CustomizeWebUIHTMLSource(const std::string &name, content::WebUIDataSource* { "proveHuman", IDS_BRAVE_REWARDS_LOCAL_PROVE_HUMAN }, { "serverNotResponding", IDS_BRAVE_REWARDS_LOCAL_SERVER_NOT_RESPONDING }, { "uhOh", IDS_BRAVE_REWARDS_LOCAL_UH_OH }, + { "grantGoneTitle", IDS_BRAVE_REWARDS_LOCAL_GRANT_GONE_TITLE }, + { "grantGoneButton", IDS_BRAVE_REWARDS_LOCAL_GRANT_GONE_BUTTON }, + { "grantGoneText", IDS_BRAVE_REWARDS_LOCAL_GRANT_GONE_TEXT }, + { "grantGeneralErrorTitle", IDS_BRAVE_REWARDS_LOCAL_GENERAL_GRANT_ERROR_TITLE }, + { "grantGeneralErrorButton", IDS_BRAVE_REWARDS_LOCAL_GENERAL_GRANT_ERROR_BUTTON }, + { "grantGeneralErrorText", IDS_BRAVE_REWARDS_LOCAL_GENERAL_GRANT_ERROR_TEXT }, { "about", IDS_BRAVE_UI_ABOUT }, { "accept", IDS_BRAVE_UI_ACCEPT }, diff --git a/components/brave_rewards/browser/rewards_service_impl.cc b/components/brave_rewards/browser/rewards_service_impl.cc index dfba29282e3a..e87020252c7d 100644 --- a/components/brave_rewards/browser/rewards_service_impl.cc +++ b/components/brave_rewards/browser/rewards_service_impl.cc @@ -551,10 +551,13 @@ void RewardsServiceImpl::OnGrantFinish(ledger::Result result, const ledger::Grant& grant) { ledger::BalanceReportInfo report_info; auto now = base::Time::Now(); - ledger_->SetBalanceReportItem(GetPublisherMonth(now), - GetPublisherYear(now), - ledger::ReportType::GRANT, - grant.probi); + if (result == ledger::Result::LEDGER_OK) { + ledger_->SetBalanceReportItem(GetPublisherMonth(now), + GetPublisherYear(now), + ledger::ReportType::GRANT, + grant.probi); + } + TriggerOnGrantFinish(result, grant); } diff --git a/components/brave_rewards/ui/components/grant.tsx b/components/brave_rewards/ui/components/grant.tsx index a8d6c3cf6a29..3180e07a0c62 100644 --- a/components/brave_rewards/ui/components/grant.tsx +++ b/components/brave_rewards/ui/components/grant.tsx @@ -18,6 +18,7 @@ import { import * as rewardsActions from '../actions/rewards_actions' import { getLocale } from '../../../common/locale' import { convertProbiToFixed } from '../utils' +import GrantError from 'brave-ui/features/rewards/grantError' interface State { grantShow: boolean @@ -47,7 +48,7 @@ class Grant extends React.Component { this.actions.onResetGrant() } - onSuccess = () => { + onFinish = () => { this.setState({ grantShow: false }) @@ -58,6 +59,65 @@ class Grant extends React.Component { this.actions.solveGrantCaptcha(x, y) } + grantCaptcha = () => { + const { grant } = this.props.rewardsData + + if (!grant) { + return + } + + if (grant.status === 'grantGone') { + return ( + + + + ) + } + + if (grant.status === 'generalError') { + return ( + + + + ) + } + + if (!grant.captcha || !grant.hint) { + return + } + + return ( + + + + ) + } + render () { const { grant } = this.props.rewardsData @@ -78,24 +138,18 @@ class Grant extends React.Component { : null } { - !grant.expiryTime && grant.captcha && grant.hint - ? - - + !grant.expiryTime + ? this.grantCaptcha() : null } { grant.expiryTime ? - + : null } diff --git a/components/brave_rewards/ui/reducers/grant_reducer.ts b/components/brave_rewards/ui/reducers/grant_reducer.ts index 3a4143e80a07..2e61f2b0aba1 100644 --- a/components/brave_rewards/ui/reducers/grant_reducer.ts +++ b/components/brave_rewards/ui/reducers/grant_reducer.ts @@ -102,7 +102,7 @@ const grantReducer: Reducer = (state: Rewards.State, } chrome.send('brave_rewards.getWalletProperties', []) } - } else { + } else if (properties.status === 6) { state = { ...state } if (state.grant) { let grant = state.grant @@ -114,6 +114,28 @@ const grantReducer: Reducer = (state: Rewards.State, } } chrome.send('brave_rewards.getGrantCaptcha', []) + } else if (properties.status === 13) { + state = { ...state } + if (state.grant) { + let grant = state.grant + grant.status = 'grantGone' + + state = { + ...state, + grant + } + } + } else { + state = { ...state } + if (state.grant) { + let grant = state.grant + grant.status = 'generalError' + + state = { + ...state, + grant + } + } } break } diff --git a/components/definitions/rewards.d.ts b/components/definitions/rewards.d.ts index 0da06d221465..55d009e891d4 100644 --- a/components/definitions/rewards.d.ts +++ b/components/definitions/rewards.d.ts @@ -4,13 +4,20 @@ declare namespace Rewards { } export enum Result { - OK = 0, - ERROR = 1, + LEDGER_OK = 0, + LEDGER_ERROR = 1, NO_PUBLISHER_STATE = 2, NO_LEDGER_STATE = 3, INVALID_PUBLISHER_STATE = 4, INVALID_LEDGER_STATE = 5, - CAPTCHA_FAILED = 6 + CAPTCHA_FAILED = 6, + NO_PUBLISHER_LIST = 7, + TOO_MANY_RESULTS = 8, + NOT_FOUND = 9, + REGISTRATION_VERIFICATION_FAILED = 10, + BAD_REGISTRATION_RESPONSE = 11, + WALLET_CREATED = 12, + GRANT_NOT_FOUND = 13 } export type AddressesType = 'BTC' | 'ETH' | 'BAT' | 'LTC' @@ -65,7 +72,7 @@ declare namespace Rewards { expiryTime: number captcha?: string hint?: string - status?: 'wrongPosition' | 'serverError' | number | null + status?: 'wrongPosition' | 'grantGone' | 'generalError' | number | null } export interface WalletProperties { diff --git a/components/resources/brave_components_resources.grd b/components/resources/brave_components_resources.grd index da2fa7ba0439..51c1d79c7714 100644 --- a/components/resources/brave_components_resources.grd +++ b/components/resources/brave_components_resources.grd @@ -264,6 +264,12 @@ Hmmm…not quite. The Brave Rewards server is not responding. We will fix this as soon as possible. Uh oh! + Grant gone! + OK + Sorry, but this grant is already expired. + Ups, something is wrong! + Ok + We detect some problem, please try again later. about diff --git a/package-lock.json b/package-lock.json index aaa946e5e799..96510f33c5d7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2206,9 +2206,9 @@ } }, "brave-ui": { - "version": "0.29.2", - "resolved": "https://registry.npmjs.org/brave-ui/-/brave-ui-0.29.2.tgz", - "integrity": "sha512-D8+Lm7bzZsRhTtLQzCeZb6e50DRmEw9xZvp+oeu9Bx8BnQVMEOW/zlFC6E5QD3IK7YBMZlnviNwN+T4gHZaHiQ==", + "version": "0.29.3", + "resolved": "https://registry.npmjs.org/brave-ui/-/brave-ui-0.29.3.tgz", + "integrity": "sha512-wDY8D4omAXB+xxDyxcvwLXSuW9tE0xS4SwvV2iIRlu3obbL0FVruK2Ah9A4Ad6IrLoubeGv4F04hfIWuWjXdYQ==", "dev": true, "requires": { "emptykit.css": "^1.0.1", diff --git a/package.json b/package.json index a62cd1d33db8..1f77b51e3056 100644 --- a/package.json +++ b/package.json @@ -270,7 +270,7 @@ "babel-preset-react": "^6.24.1", "babel-preset-react-optimize": "^1.0.1", "babel-preset-stage-0": "^6.24.1", - "brave-ui": "^0.29.2", + "brave-ui": "^0.29.3", "css-loader": "^0.28.9", "csstype": "^2.5.5", "emptykit.css": "^1.0.1",