Skip to content

Commit

Permalink
Fixes estimated Pending Rewards value decreased unexpectedly - follow…
Browse files Browse the repository at this point in the history
… up to #16678
  • Loading branch information
tmancey committed Jul 13, 2021
1 parent 597d5c9 commit 008d33e
Show file tree
Hide file tree
Showing 29 changed files with 156 additions and 1,058 deletions.
1 change: 0 additions & 1 deletion browser/extensions/api/brave_rewards_api.cc
Expand Up @@ -1103,7 +1103,6 @@ BraveRewardsGetAdsAccountStatementFunction::Run() {

void BraveRewardsGetAdsAccountStatementFunction::OnGetAdsAccountStatement(
const bool success,
const double estimated_pending_rewards,
const int64_t next_payment_date,
const int ads_received_this_month,
const double earnings_this_month,
Expand Down
1 change: 0 additions & 1 deletion browser/extensions/api/brave_rewards_api.h
Expand Up @@ -400,7 +400,6 @@ class BraveRewardsGetAdsAccountStatementFunction : public ExtensionFunction {

private:
void OnGetAdsAccountStatement(const bool success,
const double estimated_pending_rewards,
const int64_t next_payment_date,
const int ads_received_this_month,
const double earnings_this_month,
Expand Down
2 changes: 0 additions & 2 deletions browser/ui/webui/brave_rewards_page_ui.cc
Expand Up @@ -124,7 +124,6 @@ class RewardsDOMHandler : public WebUIMessageHandler,
void GetExcludedSites(const base::ListValue* args);

void OnGetStatement(const bool success,
const double estimated_pending_rewards,
const int64_t next_payment_date,
const int ads_received_this_month,
const double earnings_this_month,
Expand Down Expand Up @@ -1390,7 +1389,6 @@ void RewardsDOMHandler::GetStatement(
}

void RewardsDOMHandler::OnGetStatement(const bool success,
const double estimated_pending_rewards,
const int64_t next_payment_date,
const int ads_received_this_month,
const double earnings_this_month,
Expand Down
4 changes: 2 additions & 2 deletions build/rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion components/brave_ads/browser/ads_service.h
Expand Up @@ -54,7 +54,6 @@ using OnGetInlineContentAdCallback = base::OnceCallback<
void(const bool, const std::string&, const base::DictionaryValue&)>;

using GetAccountStatementCallback = base::OnceCallback<void(const bool,
const double,
const int64_t,
const int,
const double,
Expand Down
9 changes: 4 additions & 5 deletions components/brave_ads/browser/ads_service_impl.cc
Expand Up @@ -427,7 +427,7 @@ void AdsServiceImpl::GetAdsHistory(const uint64_t from_timestamp,

void AdsServiceImpl::GetAccountStatement(GetAccountStatementCallback callback) {
if (!connected()) {
std::move(callback).Run(/* success */ false, 0.0, 0, 0, 0.0, 0.0);
std::move(callback).Run(/* success */ false, 0, 0, 0.0, 0.0);
return;
}

Expand Down Expand Up @@ -1301,17 +1301,16 @@ void AdsServiceImpl::OnGetAccountStatement(GetAccountStatementCallback callback,
const bool success,
const std::string& json) {
if (!success) {
std::move(callback).Run(success, 0.0, 0, 0, 0.0, 0.0);
std::move(callback).Run(success, 0, 0, 0.0, 0.0);
return;
}

ads::StatementInfo statement;
statement.FromJson(json);

std::move(callback).Run(
success, statement.estimated_pending_rewards, statement.next_payment_date,
statement.ads_received_this_month, statement.earnings_this_month,
statement.earnings_last_month);
success, statement.next_payment_date, statement.ads_received_this_month,
statement.earnings_this_month, statement.earnings_last_month);
}

void AdsServiceImpl::OnRemoveAllHistory(const int32_t result) {
Expand Down
1 change: 0 additions & 1 deletion components/brave_ads/test/BUILD.gn
Expand Up @@ -14,7 +14,6 @@ source_set("brave_ads_unit_tests") {
sources = [
"//brave/components/brave_ads/browser/ads_service_impl_unittest.cc",
"//brave/vendor/bat-native-ads/src/bat/ads/ad_event_history_unittest.cc",
"//brave/vendor/bat-native-ads/src/bat/ads/internal/account/ad_rewards/ad_grants/ad_grants_unittest.cc",
"//brave/vendor/bat-native-ads/src/bat/ads/internal/account/ad_rewards/ad_rewards_delegate_mock.cc",
"//brave/vendor/bat-native-ads/src/bat/ads/internal/account/ad_rewards/ad_rewards_delegate_mock.h",
"//brave/vendor/bat-native-ads/src/bat/ads/internal/account/ad_rewards/ad_rewards_test.cc",
Expand Down
2 changes: 1 addition & 1 deletion ios/browser/api/ads/brave_ads.mm
Expand Up @@ -681,7 +681,7 @@ - (void)detailsForCurrentCycle:(void (^)(NSInteger adsReceived,
nextPaymentDate =
[NSDate dateWithTimeIntervalSince1970:list.next_payment_date];
}
completion(list.ads_received_this_month, list.estimated_pending_rewards,
completion(list.ads_received_this_month, list.earnings_this_month,
nextPaymentDate);
});
}
Expand Down
4 changes: 0 additions & 4 deletions vendor/bat-native-ads/BUILD.gn
Expand Up @@ -106,10 +106,6 @@ source_set("ads") {
"src/bat/ads/internal/account/account.cc",
"src/bat/ads/internal/account/account.h",
"src/bat/ads/internal/account/account_observer.h",
"src/bat/ads/internal/account/ad_rewards/ad_grants/ad_grants.cc",
"src/bat/ads/internal/account/ad_rewards/ad_grants/ad_grants.h",
"src/bat/ads/internal/account/ad_rewards/ad_grants/ad_grants_url_request_builder.cc",
"src/bat/ads/internal/account/ad_rewards/ad_grants/ad_grants_url_request_builder.h",
"src/bat/ads/internal/account/ad_rewards/ad_rewards.cc",
"src/bat/ads/internal/account/ad_rewards/ad_rewards.h",
"src/bat/ads/internal/account/ad_rewards/ad_rewards_delegate.h",
Expand Down
4 changes: 1 addition & 3 deletions vendor/bat-native-ads/data/test/confirmations.json
@@ -1,14 +1,12 @@
{
"ads_rewards": {
"grants_balance": 4.21,
"payments": [
{
"balance": 48.0,
"month": "2021-04",
"transaction_count": "16"
}
],
"unreconciled_estimated_pending_rewards": 0
]
},
"catalog_issuers": {
},
Expand Down
@@ -1,6 +1,5 @@
{
"ads_rewards": {
"grants_balance": 40.355,
"payments": [
{
"balance": 0.6075,
Expand Down Expand Up @@ -47,8 +46,7 @@
"month": "2020-09",
"transaction_count": "93"
}
],
"unreconciled_estimated_pending_rewards": 0.41750000000000015
]
},
"catalog_issuers": {
},
Expand Down
@@ -1,14 +1,12 @@
{
"ads_rewards": {
"grants_balance": 4.21,
"payments": [
{
"balance": 48.0,
"month": "2021-04",
"transaction_count": "16"
}
],
"unreconciled_estimated_pending_rewards": 0
]
},
"catalog_issuers": {
"issuers": [
Expand Down
6 changes: 3 additions & 3 deletions vendor/bat-native-ads/include/bat/ads/ads.h
Expand Up @@ -208,9 +208,9 @@ class ADS_EXPORT Ads {
const uint64_t to_timestamp) = 0;

// Should be called to get the statement of accounts. The callback takes one
// argument - |StatementInfo| which contains estimated pending rewards, next
// payment date, ads received this month, pending rewards, cleared
// transactions and uncleared transactions
// argument - |StatementInfo| which contains next payment date, ads received
// this month, earnings this month, earnings last month, cleared transactions
// and uncleared transactions
virtual void GetAccountStatement(GetAccountStatementCallback callback) = 0;

// Should be called to indicate interest in the specified ad. This is a
Expand Down
12 changes: 3 additions & 9 deletions vendor/bat-native-ads/include/bat/ads/statement_info.h
Expand Up @@ -26,18 +26,14 @@ struct ADS_EXPORT StatementInfo {
std::string ToJson() const;
bool FromJson(const std::string& json);

double estimated_pending_rewards = 0.0;
int64_t next_payment_date = 0;
int ads_received_this_month = 0;
double earnings_this_month = 0.0;
double earnings_last_month = 0.0;
TransactionList transactions;
TransactionList cleared_transactions;
TransactionList uncleared_transactions;

private:
double GetEstimatedPendingRewardsFromDictionary(
base::DictionaryValue* dictionary) const;

uint64_t GetNextPaymentDateFromDictionary(
base::DictionaryValue* dictionary) const;

Expand All @@ -46,14 +42,12 @@ struct ADS_EXPORT StatementInfo {

double GetEarningsThisMonthFromDictionary(
base::DictionaryValue* dictionary) const;

double GetEarningsLastMonthFromDictionary(
base::DictionaryValue* dictionary) const;

base::Value GetTransactionsAsList() const;
TransactionList GetTransactionsFromDictionary(
base::Value GetClearedTransactionsAsList() const;
TransactionList GetClearedTransactionsFromDictionary(
base::DictionaryValue* dictionary) const;

base::Value GetUnclearedTransactionsAsList() const;
TransactionList GetUnclearedTransactionsFromDictionary(
base::DictionaryValue* dictionary) const;
Expand Down
10 changes: 0 additions & 10 deletions vendor/bat-native-ads/src/bat/ads/internal/account/account.cc
Expand Up @@ -194,16 +194,6 @@ void Account::OnDidReconcileAdRewards() {
void Account::OnDidRedeemUnblindedPaymentTokens() {
BLOG(1, "Successfully redeemed unblinded payment tokens");

if (ConfirmationsState::Get()->get_unblinded_payment_tokens()->IsEmpty()) {
return;
}

const TransactionList transactions = transactions::GetUncleared();
ad_rewards_->SetUnreconciledTransactions(transactions);

ConfirmationsState::Get()->get_unblinded_payment_tokens()->RemoveAllTokens();
ConfirmationsState::Get()->Save();

Reconcile();
}

Expand Down

This file was deleted.

This file was deleted.

0 comments on commit 008d33e

Please sign in to comment.