diff --git a/components/brave_rewards/browser/rewards_p3a.cc b/components/brave_rewards/browser/rewards_p3a.cc index 5b19a420f58b..191d048f33b0 100644 --- a/components/brave_rewards/browser/rewards_p3a.cc +++ b/components/brave_rewards/browser/rewards_p3a.cc @@ -154,7 +154,7 @@ void RecordRewardsDisabledForSomeMetrics() { double CalcWalletBalanceForP3A(base::flat_map wallets, - std::string user_funds) { + double user_funds) { double balance_minus_grant = 0.0; for (const auto& wallet : wallets) { // Skip anonymous wallet, since it can contain grants. @@ -166,9 +166,7 @@ double CalcWalletBalanceForP3A(base::flat_map wallets, // `user_funds` is the amount of user-funded BAT // in the anonymous wallet (ex: not grants). - double user_funds_value; - balance_minus_grant += - base::StringToDouble(user_funds, &user_funds_value); + balance_minus_grant += user_funds; return balance_minus_grant; } diff --git a/components/brave_rewards/browser/rewards_p3a.h b/components/brave_rewards/browser/rewards_p3a.h index 5ab8c075c5d3..f726404addf9 100644 --- a/components/brave_rewards/browser/rewards_p3a.h +++ b/components/brave_rewards/browser/rewards_p3a.h @@ -63,7 +63,7 @@ void RecordNoWalletCreatedForAllMetrics(); void RecordRewardsDisabledForSomeMetrics(); double CalcWalletBalanceForP3A(base::flat_map wallets, - std::string user_funds); + double user_funds); uint64_t RoundProbiToUint64(base::StringPiece probi); diff --git a/vendor/bat-native-ledger/include/bat/ledger/public/interfaces/ledger.mojom b/vendor/bat-native-ledger/include/bat/ledger/public/interfaces/ledger.mojom index d456a6540000..1ac24342dab0 100644 --- a/vendor/bat-native-ledger/include/bat/ledger/public/interfaces/ledger.mojom +++ b/vendor/bat-native-ledger/include/bat/ledger/public/interfaces/ledger.mojom @@ -122,7 +122,7 @@ struct RewardsParameters { struct Balance { double total; - string user_funds; + double user_funds; map wallets; }; 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 07141fb07a18..28ebcf111639 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 @@ -10,6 +10,7 @@ #include "base/base64.h" #include "base/json/json_writer.h" +#include "base/strings/string_number_conversions.h" #include "base/strings/stringprintf.h" #include "bat/ledger/internal/common/security_helper.h" #include "bat/ledger/internal/endpoint/promotion/promotions_util.h" @@ -60,7 +61,7 @@ std::string PostClaimUphold::GetUrl() { return GetServerUrl(path); } -std::string PostClaimUphold::GeneratePayload(const std::string& user_funds) { +std::string PostClaimUphold::GeneratePayload(const double user_funds) { auto wallets = ledger_->ledger_client()->GetExternalWallets(); auto wallet_ptr = braveledger_uphold::GetWallet(std::move(wallets)); if (!wallet_ptr) { @@ -68,10 +69,8 @@ std::string PostClaimUphold::GeneratePayload(const std::string& user_funds) { return ""; } - const std::string amount = user_funds.empty() ? "0" : user_funds; - base::Value denomination(base::Value::Type::DICTIONARY); - denomination.SetStringKey("amount", amount); + denomination.SetStringKey("amount", base::NumberToString(user_funds)); denomination.SetStringKey("currency", "BAT"); base::Value octets(base::Value::Type::DICTIONARY); @@ -148,7 +147,7 @@ ledger::Result PostClaimUphold::CheckStatusCode(const int status_code) { } void PostClaimUphold::Request( - const std::string& user_funds, + const double user_funds, PostClaimUpholdCallback callback) { auto url_callback = std::bind(&PostClaimUphold::OnRequest, this, diff --git a/vendor/bat-native-ledger/src/bat/ledger/internal/endpoint/promotion/post_claim_uphold/post_claim_uphold.h b/vendor/bat-native-ledger/src/bat/ledger/internal/endpoint/promotion/post_claim_uphold/post_claim_uphold.h index 1d7947f75c26..77941b0b7166 100644 --- a/vendor/bat-native-ledger/src/bat/ledger/internal/endpoint/promotion/post_claim_uphold/post_claim_uphold.h +++ b/vendor/bat-native-ledger/src/bat/ledger/internal/endpoint/promotion/post_claim_uphold/post_claim_uphold.h @@ -27,13 +27,13 @@ class PostClaimUphold { ~PostClaimUphold(); void Request( - const std::string& user_funds, + const double user_funds, PostClaimUpholdCallback callback); private: std::string GetUrl(); - std::string GeneratePayload(const std::string& user_funds); + std::string GeneratePayload(const double user_funds); ledger::Result CheckStatusCode(const int status_code); 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 2fd95f7d8f99..34e927155667 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 @@ -59,7 +59,7 @@ TEST_F(PostClaimUpholdTest, ServerOK) { })); claim_->Request( - "30.0", + 30.0, [](const ledger::Result result) { EXPECT_EQ(result, ledger::Result::LEDGER_OK); }); @@ -83,7 +83,7 @@ TEST_F(PostClaimUpholdTest, ServerError400) { })); claim_->Request( - "30.0", + 30.0, [](const ledger::Result result) { EXPECT_EQ(result, ledger::Result::LEDGER_ERROR); }); @@ -107,7 +107,7 @@ TEST_F(PostClaimUpholdTest, ServerError403) { })); claim_->Request( - "30.0", + 30.0, [](const ledger::Result result) { EXPECT_EQ(result, ledger::Result::LEDGER_ERROR); }); @@ -131,7 +131,7 @@ TEST_F(PostClaimUpholdTest, ServerError404) { })); claim_->Request( - "30.0", + 30.0, [](const ledger::Result result) { EXPECT_EQ(result, ledger::Result::NOT_FOUND); }); @@ -155,7 +155,7 @@ TEST_F(PostClaimUpholdTest, ServerError409) { })); claim_->Request( - "30.0", + 30.0, [](const ledger::Result result) { EXPECT_EQ(result, ledger::Result::ALREADY_EXISTS); }); @@ -179,7 +179,7 @@ TEST_F(PostClaimUpholdTest, ServerError500) { })); claim_->Request( - "30.0", + 30.0, [](const ledger::Result result) { EXPECT_EQ(result, ledger::Result::LEDGER_ERROR); }); @@ -203,7 +203,7 @@ TEST_F(PostClaimUpholdTest, ServerErrorRandom) { })); claim_->Request( - "30.0", + 30.0, [](const ledger::Result result) { EXPECT_EQ(result, ledger::Result::LEDGER_ERROR); }); diff --git a/vendor/bat-native-ledger/src/bat/ledger/internal/wallet/wallet_balance.cc b/vendor/bat-native-ledger/src/bat/ledger/internal/wallet/wallet_balance.cc index 5af96c30aed8..6ae394a61ecd 100644 --- a/vendor/bat-native-ledger/src/bat/ledger/internal/wallet/wallet_balance.cc +++ b/vendor/bat-native-ledger/src/bat/ledger/internal/wallet/wallet_balance.cc @@ -33,7 +33,6 @@ void WalletBalance::Fetch(ledger::FetchBalanceCallback callback) { // we can skip balance server ping if (!ledger_->state()->GetFetchOldBalanceEnabled()) { auto balance = ledger::Balance::New(); - balance->user_funds = "0"; GetUnblindedTokens(std::move(balance), callback); return; } diff --git a/vendor/bat-native-ledger/src/bat/ledger/internal/wallet/wallet_claim.cc b/vendor/bat-native-ledger/src/bat/ledger/internal/wallet/wallet_claim.cc index 366e9299a6a1..7af6e2c427cc 100644 --- a/vendor/bat-native-ledger/src/bat/ledger/internal/wallet/wallet_claim.cc +++ b/vendor/bat-native-ledger/src/bat/ledger/internal/wallet/wallet_claim.cc @@ -53,7 +53,7 @@ void WalletClaim::OnBalance( } if (ledger_->state()->GetAnonTransferChecked() && - balance->user_funds == "0") { + balance->user_funds == 0) { BLOG(1, "Second ping with zero balance"); callback(ledger::Result::LEDGER_OK); return;