Skip to content

Commit

Permalink
Merge pull request #5671 from brave/sku-tokens-contribution
Browse files Browse the repository at this point in the history
Fixes sku contribution flow for unblinded tokens
  • Loading branch information
NejcZdovc authored May 28, 2020
2 parents 8fec9f5 + 9e7a60b commit 8bf0692
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,13 @@ namespace braveledger_contribution {

Unblinded::Unblinded(bat_ledger::LedgerImpl* ledger) : ledger_(ledger) {
DCHECK(ledger_);
credentials_ = braveledger_credentials::CredentialsFactory::Create(
credentials_promotion_ = braveledger_credentials::CredentialsFactory::Create(
ledger_,
ledger::CredsBatchType::PROMOTION);
DCHECK(credentials_);
credentials_sku_ = braveledger_credentials::CredentialsFactory::Create(
ledger_,
ledger::CredsBatchType::SKU);
DCHECK(credentials_promotion_ && credentials_sku_);
}

Unblinded::~Unblinded() = default;
Expand Down Expand Up @@ -393,7 +396,13 @@ void Unblinded::OnProcessTokens(
redeem.token_list = token_list;
redeem.contribution_id = contribution->contribution_id;

credentials_->RedeemTokens(redeem, redeem_callback);
if (redeem.processor == ledger::ContributionProcessor::UPHOLD ||
redeem.processor == ledger::ContributionProcessor::BRAVE_USER_FUNDS) {
credentials_sku_->RedeemTokens(redeem, redeem_callback);
return;
}

credentials_promotion_->RedeemTokens(redeem, redeem_callback);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ class Unblinded {
ledger::ResultCallback callback);

bat_ledger::LedgerImpl* ledger_; // NOT OWNED
std::unique_ptr<braveledger_credentials::Credentials> credentials_;
std::unique_ptr<braveledger_credentials::Credentials> credentials_promotion_;
std::unique_ptr<braveledger_credentials::Credentials> credentials_sku_;
};

} // namespace braveledger_contribution
Expand Down

0 comments on commit 8bf0692

Please sign in to comment.