From 840920f922cb2ec327a95bbc3155028e956337b2 Mon Sep 17 00:00:00 2001 From: Emerick Rogul Date: Thu, 4 Jun 2020 11:19:01 -0400 Subject: [PATCH] Add contributions back into brave://rewards-internals page --- .../ui/webui/brave_rewards_internals_ui.cc | 66 +++++++++++-- browser/ui/webui/brave_webui_source.cc | 41 ++++---- .../browser/ads_service_impl_unittest.cc | 3 + components/brave_rewards/browser/BUILD.gn | 6 +- .../browser/contribution_info.cc | 16 +++ .../brave_rewards/browser/contribution_info.h | 34 +++++++ .../browser/contribution_publisher.cc | 17 ++++ .../browser/contribution_publisher.h | 26 +++++ .../brave_rewards/browser/reconcile_info.cc | 22 ----- .../brave_rewards/browser/reconcile_info.h | 41 -------- .../browser/rewards_internals_info.cc | 3 +- .../browser/rewards_internals_info.h | 4 - .../brave_rewards/browser/rewards_service.h | 7 ++ .../browser/rewards_service_impl.cc | 52 ++++++++-- .../browser/rewards_service_impl.h | 6 ++ .../actions/rewards_internals_actions.ts | 7 ++ .../internals/brave_rewards_internals.tsx | 5 + .../resources/internals/components/app.tsx | 6 +- .../internals/components/contribution.tsx | 97 +++++++++++++------ .../components/contributionPublisher.tsx | 24 +++++ .../components/contributionPublishers.tsx | 28 ++++++ .../internals/components/contributions.tsx | 13 +-- .../constants/rewards_internals_types.ts | 2 + .../reducers/rewards_internals_reducer.ts | 7 ++ .../resources/internals/storage.ts | 2 +- components/definitions/rewardsInternals.d.ts | 23 +++-- .../resources/brave_components_strings.grd | 59 +++++------ .../include/bat/ledger/ledger.h | 2 - .../include/bat/ledger/mojom_structs.h | 3 - .../bat/ledger/public/interfaces/ledger.mojom | 9 -- .../database/database_contribution_info.cc | 3 +- 31 files changed, 436 insertions(+), 198 deletions(-) create mode 100644 components/brave_rewards/browser/contribution_info.cc create mode 100644 components/brave_rewards/browser/contribution_info.h create mode 100644 components/brave_rewards/browser/contribution_publisher.cc create mode 100644 components/brave_rewards/browser/contribution_publisher.h delete mode 100644 components/brave_rewards/browser/reconcile_info.cc delete mode 100644 components/brave_rewards/browser/reconcile_info.h create mode 100644 components/brave_rewards/resources/internals/components/contributionPublisher.tsx create mode 100644 components/brave_rewards/resources/internals/components/contributionPublishers.tsx diff --git a/browser/ui/webui/brave_rewards_internals_ui.cc b/browser/ui/webui/brave_rewards_internals_ui.cc index 514da9943569..9a809395d00c 100644 --- a/browser/ui/webui/brave_rewards_internals_ui.cc +++ b/browser/ui/webui/brave_rewards_internals_ui.cc @@ -52,6 +52,9 @@ class RewardsInternalsDOMHandler : public content::WebUIMessageHandler { void OnGetBalance( int32_t result, std::unique_ptr balance); + void GetContributions(const base::ListValue* args); + void OnGetContributions( + const std::vector& list); void GetPromotions(const base::ListValue* args); void OnGetPromotions(const std::vector& list); void GetPartialLog(const base::ListValue* args); @@ -89,6 +92,11 @@ void RewardsInternalsDOMHandler::RegisterMessages() { base::BindRepeating( &RewardsInternalsDOMHandler::GetBalance, base::Unretained(this))); + web_ui()->RegisterMessageCallback( + "brave_rewards_internals.getContributions", + base::BindRepeating( + &RewardsInternalsDOMHandler::GetContributions, + base::Unretained(this))); web_ui()->RegisterMessageCallback( "brave_rewards_internals.getPromotions", base::BindRepeating( @@ -162,16 +170,6 @@ void RewardsInternalsDOMHandler::OnGetRewardsInternalsInfo( if (info) { info_dict.SetString("walletPaymentId", info->payment_id); info_dict.SetBoolean("isKeyInfoSeedValid", info->is_key_info_seed_valid); - auto current_reconciles = std::make_unique(); - for (const auto& item : info->current_reconciles) { - auto reconcile_info = std::make_unique(); - reconcile_info->SetString("viewingId", item.second.viewing_id_); - reconcile_info->SetString("amount", item.second.amount_); - reconcile_info->SetInteger("retryStep", item.second.retry_step_); - reconcile_info->SetInteger("retryLevel", item.second.retry_level_); - current_reconciles->Append(std::move(reconcile_info)); - } - info_dict.SetList("currentReconciles", std::move(current_reconciles)); info_dict.SetInteger("bootStamp", info->boot_stamp); } web_ui()->CallJavascriptFunctionUnsafe( @@ -211,6 +209,54 @@ void RewardsInternalsDOMHandler::OnGetBalance( std::move(balance_value)); } +void RewardsInternalsDOMHandler::GetContributions(const base::ListValue *args) { + if (!rewards_service_) { + return; + } + + rewards_service_->GetAllContributions(base::BindOnce( + &RewardsInternalsDOMHandler::OnGetContributions, + weak_ptr_factory_.GetWeakPtr())); +} + +void RewardsInternalsDOMHandler::OnGetContributions( + const std::vector& list) { + if (!web_ui()->CanCallJavascript()) { + return; + } + + base::Value contributions(base::Value::Type::LIST); + for (const auto & item : list) { + base::Value contribution(base::Value::Type::DICTIONARY); + contribution.SetStringKey("id", item.contribution_id); + contribution.SetDoubleKey("amount", item.amount); + contribution.SetIntKey("type", item.type); + contribution.SetIntKey("step", item.step); + contribution.SetIntKey("retryCount", item.retry_count); + contribution.SetIntKey("createdAt", item.created_at); + contribution.SetIntKey("processor", item.processor); + base::Value publishers(base::Value::Type::LIST); + for (const auto& publisher_item : item.publishers) { + base::Value publisher(base::Value::Type::DICTIONARY); + publisher.SetStringKey( + "contributionId", + publisher_item.contribution_id); + publisher.SetStringKey("publisherKey", publisher_item.publisher_key); + publisher.SetDoubleKey("totalAmount", publisher_item.total_amount); + publisher.SetDoubleKey( + "contributedAmount", + publisher_item.contributed_amount); + publishers.Append(std::move(publisher)); + } + contribution.SetPath("publishers", std::move(publishers)); + contributions.Append(std::move(contribution)); + } + + web_ui()->CallJavascriptFunctionUnsafe( + "brave_rewards_internals.contributions", + std::move(contributions)); +} + void RewardsInternalsDOMHandler::GetPromotions(const base::ListValue *args) { if (!rewards_service_) { return; diff --git a/browser/ui/webui/brave_webui_source.cc b/browser/ui/webui/brave_webui_source.cc index 8241b259da88..51899d6277e3 100644 --- a/browser/ui/webui/brave_webui_source.cc +++ b/browser/ui/webui/brave_webui_source.cc @@ -834,8 +834,26 @@ void CustomizeWebUIHTMLSource(const std::string &name, { "bat", IDS_BRAVE_UI_BAT_TEXT }, { "bootStamp", IDS_BRAVE_REWARDS_INTERNALS_BOOT_STAMP }, { "clearButton", IDS_BRAVE_REWARDS_INTERNALS_CLEAR_BUTTON }, - { "contributionsInProgress", IDS_BRAVE_REWARDS_INTERNALS_CONTRIBUTIONS_IN_PROGRESS }, // NOLINT - { "currentReconcile", IDS_BRAVE_REWARDS_INTERNALS_CURRENT_RECONCILE }, + { "contributedAmount", IDS_BRAVE_REWARDS_INTERNALS_CONTRIBUTED_AMOUNT }, + { "contribution", IDS_BRAVE_REWARDS_INTERNALS_CONTRIBUTION }, + { "contributionProcessor", IDS_BRAVE_REWARDS_INTERNALS_CONTRIBUTION_PROCESSOR }, // NOLINT + { "contributionStep", IDS_BRAVE_REWARDS_INTERNALS_CONTRIBUTION_STEP }, + { "contributionStepAutoContributeTableEmpty", IDS_BRAVE_REWARDS_INTERNALS_CONTRIBUTION_STEP_AUTO_CONTRIBUTE_TABLE_EMPTY }, // NOLINT + { "contributionStepNotEnoughFunds", IDS_BRAVE_REWARDS_INTERNALS_CONTRIBUTION_STEP_NOT_ENOUGH_FUNDS }, // NOLINT + { "contributionStepFailed", IDS_BRAVE_REWARDS_INTERNALS_CONTRIBUTION_STEP_FAILED }, // NOLINT + { "contributionStepCompleted", IDS_BRAVE_REWARDS_INTERNALS_CONTRIBUTION_STEP_COMPLETED },// NOLINT + { "contributionStepNo", IDS_BRAVE_REWARDS_INTERNALS_CONTRIBUTION_STEP_NO }, // NOLINT + { "contributionStepStart", IDS_BRAVE_REWARDS_INTERNALS_CONTRIBUTION_STEP_START }, // NOLINT + { "contributionStepPrepare", IDS_BRAVE_REWARDS_INTERNALS_CONTRIBUTION_STEP_PREPARE }, // NOLINT + { "contributionStepReserve", IDS_BRAVE_REWARDS_INTERNALS_CONTRIBUTION_STEP_RESERVE }, // NOLINT + { "contributionStepExternalTransaction", IDS_BRAVE_REWARDS_INTERNALS_CONTRIBUTION_STEP_EXTERNAL_TRANSACTION }, // NOLINT + { "contributionStepCreds", IDS_BRAVE_REWARDS_INTERNALS_CONTRIBUTION_STEP_CREDS }, // NOLINT + { "rewardsNotEnabled", IDS_BRAVE_REWARDS_INTERNALS_REWARDS_NOT_ENABLED }, // NOLINT + { "rewardsTypeAuto", IDS_BRAVE_REWARDS_INTERNALS_REWARDS_TYPE_AUTO }, // NOLINT + { "rewardsTypeOneTimeTip", IDS_BRAVE_REWARDS_INTERNALS_REWARDS_TYPE_ONE_TIME_TIP }, // NOLINT + { "rewardsTypeRecurringTip", IDS_BRAVE_REWARDS_INTERNALS_REWARDS_TYPE_RECURRING_TIP }, // NOLINT + { "contributionType", IDS_BRAVE_REWARDS_INTERNALS_CONTRIBUTION_TYPE }, + { "contributions", IDS_BRAVE_REWARDS_INTERNALS_CONTRIBUTIONS }, { "downloadButton", IDS_BRAVE_REWARDS_INTERNALS_DOWNLOAD_BUTTON }, { "invalid", IDS_BRAVE_REWARDS_INTERNALS_INVALID }, { "keyInfoSeed", IDS_BRAVE_REWARDS_INTERNALS_KEY_INFO_SEED }, @@ -847,7 +865,7 @@ void CustomizeWebUIHTMLSource(const std::string &name, { "processorBraveUserFunds", IDS_BRAVE_UI_PROCESSOR_BRAVE_USER_FUNDS }, { "promotionAds", IDS_BRAVE_REWARDS_INTERNALS_PROMOTION_ADS }, { "promotionAmount", IDS_BRAVE_REWARDS_INTERNALS_PROMOTION_AMOUNT }, - { "promotionClaimedAt", IDS_BRAVE_REWARDS_INTERNALS_PROMOTION_CLAIMED_AT }, // NOLINT + { "promotionClaimedAt", IDS_BRAVE_REWARDS_INTERNALS_PROMOTION_CLAIMED_AT }, // NOLINT { "promotionClaimId", IDS_BRAVE_REWARDS_INTERNALS_PROMOTION_CLAIM_ID }, { "promotionExpiresAt", IDS_BRAVE_REWARDS_INTERNALS_PROMOTION_EXPIRES_AT }, // NOLINT { "promotionId", IDS_BRAVE_REWARDS_INTERNALS_PROMOTION_ID }, @@ -864,28 +882,15 @@ void CustomizeWebUIHTMLSource(const std::string &name, { "promotionUGP", IDS_BRAVE_REWARDS_INTERNALS_PROMOTION_UGP }, { "promotionVersion", IDS_BRAVE_REWARDS_INTERNALS_PROMOTION_VERSION }, { "refreshButton", IDS_BRAVE_REWARDS_INTERNALS_REFRESH_BUTTON }, - { "retryLevel", IDS_BRAVE_REWARDS_INTERNALS_RETRY_LEVEL }, - { "retryStep", IDS_BRAVE_REWARDS_INTERNALS_RETRY_STEP }, - { "retryStepCurrent", IDS_BRAVE_REWARDS_INTERNALS_RETRY_STEP_CURRENT }, - { "retryStepFinal", IDS_BRAVE_REWARDS_INTERNALS_RETRY_STEP_FINAL }, - { "retryStepPayload", IDS_BRAVE_REWARDS_INTERNALS_RETRY_STEP_PAYLOAD }, - { "retryStepPrepare", IDS_BRAVE_REWARDS_INTERNALS_RETRY_STEP_PREPARE }, - { "retryStepProof", IDS_BRAVE_REWARDS_INTERNALS_RETRY_STEP_PROOF }, - { "retryStepReconcile", IDS_BRAVE_REWARDS_INTERNALS_RETRY_STEP_RECONCILE }, // NOLINT - { "retryStepRegister", IDS_BRAVE_REWARDS_INTERNALS_RETRY_STEP_REGISTER }, // NOLINT - { "retryStepUnknown", IDS_BRAVE_REWARDS_INTERNALS_RETRY_STEP_UNKNOWN }, - { "retryStepViewing", IDS_BRAVE_REWARDS_INTERNALS_RETRY_STEP_VIEWING }, - { "retryStepVote", IDS_BRAVE_REWARDS_INTERNALS_RETRY_STEP_VOTE }, - { "retryStepWinners", IDS_BRAVE_REWARDS_INTERNALS_RETRY_STEP_WINNERS }, - { "rewardsNotEnabled", IDS_BRAVE_REWARDS_INTERNALS_REWARDS_NOT_ENABLED }, // NOLINT + { "retryCount", IDS_BRAVE_REWARDS_INTERNALS_RETRY_COUNT }, { "tabGeneralInfo", IDS_BRAVE_REWARDS_INTERNALS_TAB_GENERAL_INFO }, { "tabLogs", IDS_BRAVE_REWARDS_INTERNALS_TAB_LOGS }, { "tabPromotions", IDS_BRAVE_REWARDS_INTERNALS_TAB_PROMOTIONS }, { "tabContributions", IDS_BRAVE_REWARDS_INTERNALS_TAB_CONTRIBUTIONS }, + { "totalAmount", IDS_BRAVE_REWARDS_INTERNALS_TOTAL_AMOUNT }, { "totalBalance", IDS_BRAVE_REWARDS_INTERNALS_TOTAL_BALANCE }, { "userId", IDS_BRAVE_REWARDS_INTERNALS_USER_ID }, { "valid", IDS_BRAVE_REWARDS_INTERNALS_VALID }, - { "viewingId", IDS_BRAVE_REWARDS_INTERNALS_VIEWING_ID }, { "walletInfo", IDS_BRAVE_REWARDS_INTERNALS_WALLET_INFO }, { "walletPaymentId", IDS_BRAVE_REWARDS_INTERNALS_WALLET_PAYMENT_ID }, } diff --git a/components/brave_ads/browser/ads_service_impl_unittest.cc b/components/brave_ads/browser/ads_service_impl_unittest.cc index cdf9717f8b6b..841c30a8b9b3 100644 --- a/components/brave_ads/browser/ads_service_impl_unittest.cc +++ b/components/brave_ads/browser/ads_service_impl_unittest.cc @@ -212,6 +212,9 @@ class MockRewardsService : public RewardsService { MOCK_METHOD1(GetAllMonthlyReportIds, void( brave_rewards::GetAllMonthlyReportIdsCallback callback)); + MOCK_METHOD1(GetAllContributions, void( + brave_rewards::GetAllContributionsCallback callback)); + MOCK_METHOD1(GetAllPromotions, void( brave_rewards::GetAllPromotionsCallback callback)); diff --git a/components/brave_rewards/browser/BUILD.gn b/components/brave_rewards/browser/BUILD.gn index 5374335363a3..4d64a163a133 100644 --- a/components/brave_rewards/browser/BUILD.gn +++ b/components/brave_rewards/browser/BUILD.gn @@ -20,6 +20,10 @@ source_set("browser") { "rewards_notification_service_observer.h", "content_site.cc", "content_site.h", + "contribution_info.cc", + "contribution_info.h", + "contribution_publisher.cc", + "contribution_publisher.h", "rewards_p3a.cc", "rewards_p3a.h", "rewards_parameters.cc", @@ -38,8 +42,6 @@ source_set("browser") { "pending_contribution.h", "publisher_banner.cc", "publisher_banner.h", - "reconcile_info.cc", - "reconcile_info.h", "rewards_internals_info.cc", "rewards_internals_info.h", "balance.cc", diff --git a/components/brave_rewards/browser/contribution_info.cc b/components/brave_rewards/browser/contribution_info.cc new file mode 100644 index 000000000000..0157ec777f25 --- /dev/null +++ b/components/brave_rewards/browser/contribution_info.cc @@ -0,0 +1,16 @@ +/* Copyright (c) 2020 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "brave/components/brave_rewards/browser/contribution_info.h" + +namespace brave_rewards { + +ContributionInfo::ContributionInfo() = default; + +ContributionInfo::~ContributionInfo() = default; + +ContributionInfo::ContributionInfo(const ContributionInfo& info) = default; + +} // namespace brave_rewards diff --git a/components/brave_rewards/browser/contribution_info.h b/components/brave_rewards/browser/contribution_info.h new file mode 100644 index 000000000000..3df79630f0f1 --- /dev/null +++ b/components/brave_rewards/browser/contribution_info.h @@ -0,0 +1,34 @@ +/* Copyright (c) 2020 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef BRAVE_COMPONENTS_BRAVE_REWARDS_BROWSER_CONTRIBUTION_INFO_H_ +#define BRAVE_COMPONENTS_BRAVE_REWARDS_BROWSER_CONTRIBUTION_INFO_H_ + +#include +#include + +#include "brave/components/brave_rewards/browser/contribution_publisher.h" + +namespace brave_rewards { + +struct ContributionInfo { + ContributionInfo(); + ~ContributionInfo(); + ContributionInfo(const ContributionInfo& info); + + std::string contribution_id; + double amount; + int type; + int step; + int retry_count; + uint64_t created_at; + int processor; + + std::vector publishers; +}; + +} // namespace brave_rewards + +#endif // BRAVE_COMPONENTS_BRAVE_REWARDS_BROWSER_CONTRIBUTION_INFO_H_ diff --git a/components/brave_rewards/browser/contribution_publisher.cc b/components/brave_rewards/browser/contribution_publisher.cc new file mode 100644 index 000000000000..573f4af1e105 --- /dev/null +++ b/components/brave_rewards/browser/contribution_publisher.cc @@ -0,0 +1,17 @@ +/* Copyright (c) 2020 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "brave/components/brave_rewards/browser/contribution_publisher.h" + +namespace brave_rewards { + +ContributionPublisher::ContributionPublisher() = default; + +ContributionPublisher::~ContributionPublisher() = default; + +ContributionPublisher::ContributionPublisher( + const ContributionPublisher& info) = default; + +} // namespace brave_rewards diff --git a/components/brave_rewards/browser/contribution_publisher.h b/components/brave_rewards/browser/contribution_publisher.h new file mode 100644 index 000000000000..3bf3a5815196 --- /dev/null +++ b/components/brave_rewards/browser/contribution_publisher.h @@ -0,0 +1,26 @@ +/* Copyright (c) 2020 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef BRAVE_COMPONENTS_BRAVE_REWARDS_BROWSER_CONTRIBUTION_PUBLISHER_H_ +#define BRAVE_COMPONENTS_BRAVE_REWARDS_BROWSER_CONTRIBUTION_PUBLISHER_H_ + +#include + +namespace brave_rewards { + +struct ContributionPublisher { + ContributionPublisher(); + ~ContributionPublisher(); + ContributionPublisher(const ContributionPublisher& info); + + std::string contribution_id; + std::string publisher_key; + double total_amount; + double contributed_amount; +}; + +} // namespace brave_rewards + +#endif // BRAVE_COMPONENTS_BRAVE_REWARDS_BROWSER_CONTRIBUTION_PUBLISHER_H_ diff --git a/components/brave_rewards/browser/reconcile_info.cc b/components/brave_rewards/browser/reconcile_info.cc deleted file mode 100644 index 3969c2668731..000000000000 --- a/components/brave_rewards/browser/reconcile_info.cc +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright (c) 2019 The Brave Authors. All rights reserved. - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "brave/components/brave_rewards/browser/reconcile_info.h" - -namespace brave_rewards { - -ReconcileInfo::ReconcileInfo() - : retry_step_(STEP_NO), retry_level_(0) {} - -ReconcileInfo::~ReconcileInfo() {} - -ReconcileInfo::ReconcileInfo(const ReconcileInfo& info) { - viewing_id_ = info.viewing_id_; - amount_ = info.amount_; - retry_step_ = info.retry_step_; - retry_level_ = info.retry_level_; -} - -} // namespace brave_rewards diff --git a/components/brave_rewards/browser/reconcile_info.h b/components/brave_rewards/browser/reconcile_info.h deleted file mode 100644 index 7a84f20d9b92..000000000000 --- a/components/brave_rewards/browser/reconcile_info.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (c) 2019 The Brave Authors. All rights reserved. - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef BRAVE_COMPONENTS_BRAVE_REWARDS_BROWSER_RECONCILE_INFO_H_ -#define BRAVE_COMPONENTS_BRAVE_REWARDS_BROWSER_RECONCILE_INFO_H_ - -#include -#include - -namespace brave_rewards { - -enum ContributionRetry { - STEP_NO = 0, - STEP_RECONCILE = 1, // Phase 1 - STEP_CURRENT = 2, // Phase 1 - STEP_PAYLOAD = 3, // Phase 1 - STEP_REGISTER = 4, // Phase 1 - STEP_VIEWING = 5, // Phase 1 - STEP_WINNERS = 6, // Phase 1 - STEP_PREPARE = 7, // Phase 2 - STEP_PROOF = 8, // Phase 2 - STEP_VOTE = 9, // Phase 2 - STEP_FINAL = 10 // Phase 2 -}; - -struct ReconcileInfo { - ReconcileInfo(); - ~ReconcileInfo(); - ReconcileInfo(const ReconcileInfo& info); - - std::string viewing_id_; - std::string amount_; - ContributionRetry retry_step_; - int retry_level_; -}; - -} // namespace brave_rewards - -#endif // BRAVE_COMPONENTS_BRAVE_REWARDS_BROWSER_RECONCILE_INFO_H_ diff --git a/components/brave_rewards/browser/rewards_internals_info.cc b/components/brave_rewards/browser/rewards_internals_info.cc index 2e94a9d0678f..b0e25c2d0dbb 100644 --- a/components/brave_rewards/browser/rewards_internals_info.cc +++ b/components/brave_rewards/browser/rewards_internals_info.cc @@ -11,8 +11,7 @@ RewardsInternalsInfo::RewardsInternalsInfo() {} RewardsInternalsInfo::RewardsInternalsInfo(const RewardsInternalsInfo& info) : payment_id(info.payment_id), - is_key_info_seed_valid(info.is_key_info_seed_valid), - current_reconciles(info.current_reconciles) { + is_key_info_seed_valid(info.is_key_info_seed_valid) { } RewardsInternalsInfo::~RewardsInternalsInfo() {} diff --git a/components/brave_rewards/browser/rewards_internals_info.h b/components/brave_rewards/browser/rewards_internals_info.h index 1f26662c62b3..bbc512ac0a45 100644 --- a/components/brave_rewards/browser/rewards_internals_info.h +++ b/components/brave_rewards/browser/rewards_internals_info.h @@ -9,8 +9,6 @@ #include #include -#include "brave/components/brave_rewards/browser/reconcile_info.h" - namespace brave_rewards { struct RewardsInternalsInfo { @@ -21,8 +19,6 @@ struct RewardsInternalsInfo { std::string payment_id; bool is_key_info_seed_valid; uint64_t boot_stamp; - - std::map current_reconciles; }; } // namespace brave_rewards diff --git a/components/brave_rewards/browser/rewards_service.h b/components/brave_rewards/browser/rewards_service.h index 7634173f4f1c..f10f12c252a7 100644 --- a/components/brave_rewards/browser/rewards_service.h +++ b/components/brave_rewards/browser/rewards_service.h @@ -17,6 +17,7 @@ #include "brave/components/brave_rewards/browser/balance.h" #include "brave/components/brave_rewards/browser/balance_report.h" #include "brave/components/brave_rewards/browser/content_site.h" +#include "brave/components/brave_rewards/browser/contribution_info.h" #include "brave/components/brave_rewards/browser/external_wallet.h" #include "brave/components/brave_rewards/browser/publisher_banner.h" #include "brave/components/brave_rewards/browser/pending_contribution.h" @@ -119,6 +120,9 @@ using GetMonthlyReportCallback = base::OnceCallback&)>; +using GetAllContributionsCallback = base::OnceCallback&)>; + using GetAllPromotionsCallback = base::OnceCallback&)>; @@ -327,6 +331,9 @@ class RewardsService : public KeyedService { virtual void GetAllMonthlyReportIds( GetAllMonthlyReportIdsCallback callback) = 0; + virtual void GetAllContributions( + GetAllContributionsCallback callback) = 0; + virtual void GetAllPromotions( GetAllPromotionsCallback callback) = 0; diff --git a/components/brave_rewards/browser/rewards_service_impl.cc b/components/brave_rewards/browser/rewards_service_impl.cc index 728f657483c5..6fbd17e3577c 100644 --- a/components/brave_rewards/browser/rewards_service_impl.cc +++ b/components/brave_rewards/browser/rewards_service_impl.cc @@ -20,9 +20,8 @@ #include "base/files/important_file_writer.h" #include "base/i18n/time_formatting.h" #include "base/json/json_reader.h" -#include "base/json/json_writer.h" #include "base/json/json_string_value_serializer.h" -#include "base/time/time.h" +#include "base/json/json_writer.h" #include "base/logging.h" #include "base/sequenced_task_runner.h" #include "base/strings/string_number_conversions.h" @@ -31,13 +30,14 @@ #include "base/task/post_task.h" #include "base/task_runner_util.h" #include "base/threading/sequenced_task_runner_handle.h" -#include "bat/ledger/ledger.h" +#include "base/time/time.h" #include "bat/ledger/global_constants.h" +#include "bat/ledger/ledger.h" #include "bat/ledger/mojom_structs.h" #include "bat/ledger/transactions_info.h" #include "brave/base/containers/utils.h" +#include "brave/browser/brave_rewards/rewards_service_factory.h" #include "brave/browser/ui/webui/brave_rewards_source.h" -#include "brave/components/brave_rewards/common/pref_names.h" #include "brave/common/brave_channel_info.h" #include "brave/components/brave_ads/browser/ads_service.h" #include "brave/components/brave_ads/browser/ads_service_factory.h" @@ -47,19 +47,20 @@ #include "brave/components/brave_rewards/browser/auto_contribution_props.h" #include "brave/components/brave_rewards/browser/balance_report.h" #include "brave/components/brave_rewards/browser/content_site.h" +#include "brave/components/brave_rewards/browser/contribution_info.h" #include "brave/components/brave_rewards/browser/file_util.h" -#include "brave/components/brave_rewards/browser/logging_util.h" #include "brave/components/brave_rewards/browser/logging.h" +#include "brave/components/brave_rewards/browser/logging_util.h" #include "brave/components/brave_rewards/browser/publisher_banner.h" #include "brave/components/brave_rewards/browser/rewards_database.h" #include "brave/components/brave_rewards/browser/rewards_notification_service.h" #include "brave/components/brave_rewards/browser/rewards_notification_service_impl.h" #include "brave/components/brave_rewards/browser/rewards_p3a.h" -#include "brave/browser/brave_rewards/rewards_service_factory.h" +#include "brave/components/brave_rewards/browser/rewards_parameters.h" #include "brave/components/brave_rewards/browser/rewards_service_observer.h" #include "brave/components/brave_rewards/browser/static_values.h" #include "brave/components/brave_rewards/browser/switches.h" -#include "brave/components/brave_rewards/browser/rewards_parameters.h" +#include "brave/components/brave_rewards/common/pref_names.h" #include "brave/components/services/bat_ledger/public/cpp/ledger_client_mojo_proxy.h" #include "chrome/browser/bitmap_fetcher/bitmap_fetcher_service_factory.h" #include "chrome/browser/browser_process_impl.h" @@ -848,9 +849,6 @@ void RewardsServiceImpl::OnGetRewardsInternalsInfo( rewards_internals_info->is_key_info_seed_valid = info->is_key_info_seed_valid; rewards_internals_info->boot_stamp = info->boot_stamp; - // TODO(https://github.com/brave/brave-browser/issues/8633) - // add active contributions - std::move(callback).Run(std::move(rewards_internals_info)); } @@ -3527,6 +3525,40 @@ void RewardsServiceImpl::OnGetAllMonthlyReportIds( std::move(callback).Run(ids); } +void RewardsServiceImpl::GetAllContributions( + GetAllContributionsCallback callback) { + bat_ledger_->GetAllContributions( + base::BindOnce(&RewardsServiceImpl::OnGetAllContributions, + AsWeakPtr(), + std::move(callback))); +} + +void RewardsServiceImpl::OnGetAllContributions( + GetAllContributionsCallback callback, + ledger::ContributionInfoList contributions) { + std::vector converted; + for (const auto& contribution_item : contributions) { + brave_rewards::ContributionInfo contribution; + contribution.contribution_id = contribution_item->contribution_id; + contribution.amount = contribution_item->amount; + contribution.type = static_cast(contribution_item->type); + contribution.step = static_cast(contribution_item->step); + contribution.retry_count = contribution_item->retry_count; + contribution.created_at = contribution_item->created_at; + contribution.processor = static_cast(contribution_item->processor); + for (const auto& publisher_item : contribution_item->publishers) { + brave_rewards::ContributionPublisher publisher; + publisher.contribution_id = publisher_item->contribution_id; + publisher.publisher_key = publisher_item->publisher_key; + publisher.total_amount = publisher_item->total_amount; + publisher.contributed_amount = publisher_item->contributed_amount; + contribution.publishers.push_back(std::move(publisher)); + } + converted.push_back(std::move(contribution)); + } + std::move(callback).Run(std::move(converted)); +} + void RewardsServiceImpl::GetAllPromotions(GetAllPromotionsCallback callback) { bat_ledger_->GetAllPromotions( base::BindOnce(&RewardsServiceImpl::OnGetAllPromotions, diff --git a/components/brave_rewards/browser/rewards_service_impl.h b/components/brave_rewards/browser/rewards_service_impl.h index e091f7973939..668a4ffb1fc7 100644 --- a/components/brave_rewards/browser/rewards_service_impl.h +++ b/components/brave_rewards/browser/rewards_service_impl.h @@ -311,6 +311,8 @@ class RewardsServiceImpl : public RewardsService, void GetAllMonthlyReportIds(GetAllMonthlyReportIdsCallback callback) override; + void GetAllContributions(GetAllContributionsCallback callback) override; + void GetAllPromotions(GetAllPromotionsCallback callback) override; // Testing methods @@ -683,6 +685,10 @@ class RewardsServiceImpl : public RewardsService, GetAllMonthlyReportIdsCallback callback, const std::vector& ids); + void OnGetAllContributions( + GetAllContributionsCallback callback, + ledger::ContributionInfoList contributions); + void OnGetAllPromotions( GetAllPromotionsCallback callback, base::flat_map promotions); diff --git a/components/brave_rewards/resources/internals/actions/rewards_internals_actions.ts b/components/brave_rewards/resources/internals/actions/rewards_internals_actions.ts index c25bee0907a6..772c5ca8e35e 100644 --- a/components/brave_rewards/resources/internals/actions/rewards_internals_actions.ts +++ b/components/brave_rewards/resources/internals/actions/rewards_internals_actions.ts @@ -28,6 +28,13 @@ export const onBalance = (balance: RewardsInternals.Balance) => balance }) +export const getContributions = () => action(types.GET_CONTRIBUTIONS) + +export const onContributions = (contributions: RewardsInternals.ContributionInfo[]) => + action(types.ON_CONTRIBUTIONS, { + contributions + }) + export const getPromotions = () => action(types.GET_PROMOTIONS) export const onPromotions = (promotions: RewardsInternals.Promotion[]) => diff --git a/components/brave_rewards/resources/internals/brave_rewards_internals.tsx b/components/brave_rewards/resources/internals/brave_rewards_internals.tsx index 0c139c8730b5..0cf3a228fba7 100644 --- a/components/brave_rewards/resources/internals/brave_rewards_internals.tsx +++ b/components/brave_rewards/resources/internals/brave_rewards_internals.tsx @@ -43,6 +43,10 @@ window.cr.define('brave_rewards_internals', function () { getActions().onBalance(balance) } + function contributions (contributions: RewardsInternals.ContributionInfo[]) { + getActions().onContributions(contributions) + } + function promotions (promotions: RewardsInternals.Promotion[]) { getActions().onPromotions(promotions) } @@ -72,6 +76,7 @@ window.cr.define('brave_rewards_internals', function () { onGetRewardsEnabled, onGetRewardsInternalsInfo, balance, + contributions, promotions, partialLog, fullLog diff --git a/components/brave_rewards/resources/internals/components/app.tsx b/components/brave_rewards/resources/internals/components/app.tsx index 559bcb735313..e08e63f84183 100644 --- a/components/brave_rewards/resources/internals/components/app.tsx +++ b/components/brave_rewards/resources/internals/components/app.tsx @@ -89,11 +89,11 @@ export class RewardsInternalsPage extends React.Component { } getContributions = () => { - // TODO(https://github.com/brave/brave-browser/issues/8633): implement + this.actions.getContributions() } render () { - const { isRewardsEnabled, info, promotions, log, fullLog } = this.props.rewardsInternalsData + const { isRewardsEnabled, contributions, promotions, log, fullLog } = this.props.rewardsInternalsData if (!isRewardsEnabled) { return ( @@ -129,7 +129,7 @@ export class RewardsInternalsPage extends React.Component {
- +
) diff --git a/components/brave_rewards/resources/internals/components/contribution.tsx b/components/brave_rewards/resources/internals/components/contribution.tsx index e1d1645dc297..a8f2eb578df5 100644 --- a/components/brave_rewards/resources/internals/components/contribution.tsx +++ b/components/brave_rewards/resources/internals/components/contribution.tsx @@ -4,49 +4,88 @@ import * as React from 'react' +import { ContributionPublishers } from './contributionPublishers' + interface Props { - reconcile: RewardsInternals.CurrentReconcile + contribution: RewardsInternals.ContributionInfo } // Utils import { getLocale } from '../../../../common/locale' -const getRetryStepString = (retryStep: number) => { - switch (retryStep) { +const getContributionTypeString = (contributionType: number) => { + switch (contributionType) { + case 2: + return getLocale('rewardsTypeAuto') + case 8: + return getLocale('rewardsTypeOneTimeTip') + case 16: + return getLocale('rewardsTypeRecurringTip') + } + + return getLocale('rewardsTypeUnknown') +} + +const getProcessorString = (processor: number) => { + switch (processor) { case 1: - return getLocale('retryStepReconcile') + return getLocale('processorBraveTokens') case 2: - return getLocale('retryStepCurrent') + return getLocale('processorUphold') case 3: - return getLocale('retryStepPayload') + return getLocale('processorBraveUserFunds') + } + + return '' +} + +const getContributionStepString = (step: number) => { + switch (step) { + case -4: + return getLocale('contributionAutoContributeTableEmpty') + case -3: + return getLocale('contributionStepNotEnoughFunds') + case -2: + return getLocale('contributionStepFailed') + case -1: + return getLocale('contributionStepCompleted') + case 0: + return getLocale('contributionStepNo') + case 1: + return getLocale('contributionStepStart') + case 2: + return getLocale('contributionStepPrepare') + case 3: + return getLocale('contributionStepReserve') case 4: - return getLocale('retryStepRegister') + return getLocale('contributionStepExternalTransaction') case 5: - return getLocale('retryStepViewing') - case 6: - return getLocale('retryStepWinners') - case 7: - return getLocale('retryStepPrepare') - case 8: - return getLocale('retryStepProof') - case 9: - return getLocale('retryStepVote') - case 10: - return getLocale('retryStepFinal') + return getLocale('contributionStepCreds') } - return getLocale('retryStepUnknown') + return getLocale('contributionStepNo') } export const Contribution = (props: Props) => ( - <> - {getLocale('viewingId')} {props.reconcile.viewingId || ''} -
- {getLocale('amount')} {props.reconcile.amount || ''} -
- {getLocale('retryStep')} {getRetryStepString(props.reconcile.retryStep) || ''} -
- {getLocale('retryLevel')} {props.reconcile.retryLevel || ''} -
- +
+

{props.contribution.id}

+
+ {getLocale('contributionType')} {getContributionTypeString(props.contribution.type)} +
+
+ {getLocale('amount')} {props.contribution.amount} {getLocale('bat')} +
+
+ {getLocale('contributionStep')} {getContributionStepString(props.contribution.step)} +
+
+ {getLocale('retryCount')} {props.contribution.retryCount} +
+
+ {getLocale('contributionProcessor')} {getProcessorString(props.contribution.processor)} +
+
+ +
+
) diff --git a/components/brave_rewards/resources/internals/components/contributionPublisher.tsx b/components/brave_rewards/resources/internals/components/contributionPublisher.tsx new file mode 100644 index 000000000000..05155f62b39a --- /dev/null +++ b/components/brave_rewards/resources/internals/components/contributionPublisher.tsx @@ -0,0 +1,24 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +import * as React from 'react' + +interface Props { + publisher: RewardsInternals.ContributionPublisher +} + +// Utils +import { getLocale } from '../../../../common/locale' + +export const ContributionPublisher = (props: Props) => ( +
+

{props.publisher.publisherKey}

+
+ {getLocale('totalAmount')} {props.publisher.totalAmount} {getLocale('bat')} +
+
+ {getLocale('contributedAmount')} {props.publisher.contributedAmount} {getLocale('bat')} +
+
+) diff --git a/components/brave_rewards/resources/internals/components/contributionPublishers.tsx b/components/brave_rewards/resources/internals/components/contributionPublishers.tsx new file mode 100644 index 000000000000..9e4db6b9afe1 --- /dev/null +++ b/components/brave_rewards/resources/internals/components/contributionPublishers.tsx @@ -0,0 +1,28 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +import * as React from 'react' + +import { ContributionPublisher } from './contributionPublisher' + +interface Props { + items: RewardsInternals.ContributionPublisher[] +} + +export const ContributionPublishers = (props: Props) => { + if (!props.items || props.items.length === 0) { + return null + } + + return ( + <> + {props.items.map((item, index) => ( +
+ + {(index !== props.items.length - 1) ?
: null} +
+ ))} + + ) +} diff --git a/components/brave_rewards/resources/internals/components/contributions.tsx b/components/brave_rewards/resources/internals/components/contributions.tsx index 1fee8da6a708..88b667a6f5a5 100644 --- a/components/brave_rewards/resources/internals/components/contributions.tsx +++ b/components/brave_rewards/resources/internals/components/contributions.tsx @@ -9,7 +9,7 @@ import { ButtonWrapper } from '../style' import { Button } from 'brave-ui/components' interface Props { - items: RewardsInternals.CurrentReconcile[] + items: RewardsInternals.ContributionInfo[] onGet: () => void } @@ -32,13 +32,10 @@ export const Contributions = (props: Props) => { /> {props.items.map((item, index) => ( - <> -
- {getLocale('currentReconcile')} {index + 1} - -
-
- +
+ + {(index !== props.items.length - 1) ?
: null} +
))} ) diff --git a/components/brave_rewards/resources/internals/constants/rewards_internals_types.ts b/components/brave_rewards/resources/internals/constants/rewards_internals_types.ts index f7aa672807dc..f2cac202f4bd 100644 --- a/components/brave_rewards/resources/internals/constants/rewards_internals_types.ts +++ b/components/brave_rewards/resources/internals/constants/rewards_internals_types.ts @@ -9,6 +9,8 @@ export const enum types { ON_GET_REWARDS_INTERNALS_INFO = '@@rewards_internals/ON_GET_REWARDS_INTERNALS_INFO', GET_BALANCE = '@@rewards_internals/GET_BALANCE', ON_BALANCE = '@@rewards_internals/ON_BALANCE', + GET_CONTRIBUTIONS = '@@rewards_internals/GET_CONTRIBUTIONS', + ON_CONTRIBUTIONS = '@@rewards_internals/ON_CONTRIBUTIONS', GET_PROMOTIONS = '@@rewards_internals/GET_PROMOTIONS', ON_PROMOTIONS = '@@rewards_internals/ON_PROMOTIONS', GET_PARTIAL_LOG = '@@rewards_internals/GET_PARTIAL_LOG', diff --git a/components/brave_rewards/resources/internals/reducers/rewards_internals_reducer.ts b/components/brave_rewards/resources/internals/reducers/rewards_internals_reducer.ts index 9d86a4d433c7..f412befde435 100644 --- a/components/brave_rewards/resources/internals/reducers/rewards_internals_reducer.ts +++ b/components/brave_rewards/resources/internals/reducers/rewards_internals_reducer.ts @@ -37,6 +37,13 @@ const rewardsInternalsReducer: Reducer = (st state = { ...state } state.balance = action.payload.balance break + case types.GET_CONTRIBUTIONS: + chrome.send('brave_rewards_internals.getContributions') + break + case types.ON_CONTRIBUTIONS: + state = { ...state } + state.contributions = action.payload.contributions + break case types.GET_PROMOTIONS: chrome.send('brave_rewards_internals.getPromotions') break diff --git a/components/brave_rewards/resources/internals/storage.ts b/components/brave_rewards/resources/internals/storage.ts index 0c7413bc812a..b34a3215ad52 100644 --- a/components/brave_rewards/resources/internals/storage.ts +++ b/components/brave_rewards/resources/internals/storage.ts @@ -11,9 +11,9 @@ const defaultState: RewardsInternals.State = { info: { isKeyInfoSeedValid: false, walletPaymentId: '', - currentReconciles: [], bootStamp: 0 }, + contributions: [], promotions: [], log: '', fullLog: '' diff --git a/components/definitions/rewardsInternals.d.ts b/components/definitions/rewardsInternals.d.ts index a6f8a2ee3790..57b6e98fc35a 100644 --- a/components/definitions/rewardsInternals.d.ts +++ b/components/definitions/rewardsInternals.d.ts @@ -9,19 +9,30 @@ declare namespace RewardsInternals { info: { isKeyInfoSeedValid: boolean walletPaymentId: string - currentReconciles: CurrentReconcile[] bootStamp: number } + contributions: ContributionInfo[] promotions: Promotion[] log: string fullLog: string } - export interface CurrentReconcile { - viewingId: string - amount: string - retryStep: number - retryLevel: number + export interface ContributionInfo { + id: string + amount: number + type: number + step: number + retryCount: number + createdAt: number + processor: number + publishers: ContributionPublisher[] + } + + export interface ContributionPublisher { + contributionId: string + publisherKey: string + totalAmount: number + contributedAmount: number } export interface Balance { diff --git a/components/resources/brave_components_strings.grd b/components/resources/brave_components_strings.grd index 5aa79a47068f..ebc3cb3b2884 100644 --- a/components/resources/brave_components_strings.grd +++ b/components/resources/brave_components_strings.grd @@ -348,37 +348,31 @@ Amount: Automatically refresh every 5 seconds + Balance info + Wallet created Clear - Current Reconcile + Contributed amount: + Contribution + Processor: + Step: + Auto Contribute table empty + Not enough funds + Failed + Completed + Unknown + Start + Prepare + Reserve + External transaction + Creds + Type: + Contributions Download full log Invalid Key Info Seed: We show the last {{numberOfLines}} lines of the log. If you want the whole log, you can download it above. - Refresh - Retry Level: - Retry Step: - Current - Final - Payload - Prepare - Proof - Reconcile - Register - Unknown - Viewing - Vote - Winners - Brave Rewards is not enabled. Enable it by visiting - Valid - Viewing ID: - Wallet Payment ID: + Rewards internals Persona ID - User ID - Wallet created - Total balance - Wallet info - Balance info - Contributions in progress Ads Amount Claimed at @@ -397,11 +391,22 @@ Type UGP Version - Rewards internals + Refresh + Retry Count: + Brave Rewards is not enabled. Enable it by visiting + Auto Contribute + One-time tip + Recurring tip + Contributions General info Logs Promotions - Contributions + Total amount: + Total balance + User ID + Valid + Wallet info + Wallet Payment ID: about diff --git a/vendor/bat-native-ledger/include/bat/ledger/ledger.h b/vendor/bat-native-ledger/include/bat/ledger/ledger.h index 5de092259bcf..51670e026140 100644 --- a/vendor/bat-native-ledger/include/bat/ledger/ledger.h +++ b/vendor/bat-native-ledger/include/bat/ledger/ledger.h @@ -265,8 +265,6 @@ class LEDGER_EXPORT Ledger { virtual void GetTransactionHistory( GetTransactionHistoryCallback callback) = 0; - // This uses a callback instead of returning directly so that - // GetCurrentReconciles() can be moved to the database later. virtual void GetRewardsInternalsInfo( ledger::RewardsInternalsInfoCallback callback) = 0; diff --git a/vendor/bat-native-ledger/include/bat/ledger/mojom_structs.h b/vendor/bat-native-ledger/include/bat/ledger/mojom_structs.h index 9dde9f5d3cac..6ee19b7cb8a5 100644 --- a/vendor/bat-native-ledger/include/bat/ledger/mojom_structs.h +++ b/vendor/bat-native-ledger/include/bat/ledger/mojom_structs.h @@ -122,9 +122,6 @@ using PublisherStatus = mojom::PublisherStatus; using PublisherExclude = mojom::PublisherExclude; -using ReconcileInfo = mojom::ReconcileInfo; -using ReconcileInfoPtr = mojom::ReconcileInfoPtr; - using RecurringTip = mojom::RecurringTip; using RecurringTipPtr = mojom::RecurringTipPtr; 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 b79422aad87a..8b917e5d9729 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 @@ -197,19 +197,10 @@ enum ContributionRetry { STEP_FINAL = 10 // Phase 2 }; -struct ReconcileInfo { - string viewing_id; - string amount; - ContributionRetry retry_step; - int32 retry_level; -}; - struct RewardsInternalsInfo { string payment_id; bool is_key_info_seed_valid; uint64 boot_stamp; - - map current_reconciles; }; enum Result { diff --git a/vendor/bat-native-ledger/src/bat/ledger/internal/database/database_contribution_info.cc b/vendor/bat-native-ledger/src/bat/ledger/internal/database/database_contribution_info.cc index 12c3f99183af..2ad28714f131 100644 --- a/vendor/bat-native-ledger/src/bat/ledger/internal/database/database_contribution_info.cc +++ b/vendor/bat-native-ledger/src/bat/ledger/internal/database/database_contribution_info.cc @@ -853,6 +853,7 @@ void DatabaseContributionInfo::OnGetList( GetIntColumn(record_pointer, 5)); contribution_ids.push_back(info->contribution_id); + list.push_back(std::move(info)); } auto publisher_callback = @@ -882,7 +883,7 @@ void DatabaseContributionInfo::OnGetListPublishers( continue; } - contribution->publishers.push_back(std::move(item)); + contribution->publishers.push_back(item->Clone()); } }