From df535d324cb41e74faca5c0b4d94874af7b9b4d1 Mon Sep 17 00:00:00 2001 From: NejcZdovc Date: Mon, 2 Mar 2020 11:40:23 +0100 Subject: [PATCH] Zero balance check is not needed in uphold flow anymore --- .../src/bat/ledger/internal/ledger_impl.cc | 4 ++-- .../src/bat/ledger/internal/ledger_impl.h | 4 ++-- .../bat/ledger/internal/ledger_impl_mock.h | 4 ++-- .../internal/promotion/promotion_transfer.cc | 4 ++-- .../src/bat/ledger/internal/uphold/uphold.cc | 6 +---- .../src/bat/ledger/internal/uphold/uphold.h | 1 - .../ledger/internal/uphold/uphold_wallet.cc | 23 ++----------------- .../ledger/internal/uphold/uphold_wallet.h | 1 - 8 files changed, 11 insertions(+), 36 deletions(-) diff --git a/vendor/bat-native-ledger/src/bat/ledger/internal/ledger_impl.cc b/vendor/bat-native-ledger/src/bat/ledger/internal/ledger_impl.cc index ba3c207859a1..4c43d39f2094 100644 --- a/vendor/bat-native-ledger/src/bat/ledger/internal/ledger_impl.cc +++ b/vendor/bat-native-ledger/src/bat/ledger/internal/ledger_impl.cc @@ -1442,8 +1442,8 @@ void LedgerImpl::DisconnectWallet( void LedgerImpl::TransferAnonToExternalWallet( ledger::ExternalWalletPtr wallet, - const bool allow_zero_balance, - ledger::TransferAnonToExternalWalletCallback callback) { + ledger::TransferAnonToExternalWalletCallback callback, + const bool allow_zero_balance) { bat_wallet_->TransferAnonToExternalWallet( std::move(wallet), allow_zero_balance, diff --git a/vendor/bat-native-ledger/src/bat/ledger/internal/ledger_impl.h b/vendor/bat-native-ledger/src/bat/ledger/internal/ledger_impl.h index c4244acf5a3b..29146ffe7646 100644 --- a/vendor/bat-native-ledger/src/bat/ledger/internal/ledger_impl.h +++ b/vendor/bat-native-ledger/src/bat/ledger/internal/ledger_impl.h @@ -512,8 +512,8 @@ class LedgerImpl : public ledger::Ledger, void TransferAnonToExternalWallet( ledger::ExternalWalletPtr wallet, - const bool allow_zero_balance, - ledger::TransferAnonToExternalWalletCallback callback); + ledger::TransferAnonToExternalWalletCallback callback, + const bool allow_zero_balance = false); void ShowNotification( const std::string& type, diff --git a/vendor/bat-native-ledger/src/bat/ledger/internal/ledger_impl_mock.h b/vendor/bat-native-ledger/src/bat/ledger/internal/ledger_impl_mock.h index 82278cea2da8..dc90d2eb4c43 100644 --- a/vendor/bat-native-ledger/src/bat/ledger/internal/ledger_impl_mock.h +++ b/vendor/bat-native-ledger/src/bat/ledger/internal/ledger_impl_mock.h @@ -480,8 +480,8 @@ class MockLedgerImpl : public LedgerImpl { MOCK_METHOD3(TransferAnonToExternalWallet, void(ledger::ExternalWalletPtr, - const bool, - ledger::TransferAnonToExternalWalletCallback)); + ledger::TransferAnonToExternalWalletCallback, + const bool)); MOCK_METHOD3(ShowNotification, void(const std::string&, diff --git a/vendor/bat-native-ledger/src/bat/ledger/internal/promotion/promotion_transfer.cc b/vendor/bat-native-ledger/src/bat/ledger/internal/promotion/promotion_transfer.cc index d247306c65a7..701bca039f4c 100644 --- a/vendor/bat-native-ledger/src/bat/ledger/internal/promotion/promotion_transfer.cc +++ b/vendor/bat-native-ledger/src/bat/ledger/internal/promotion/promotion_transfer.cc @@ -69,8 +69,8 @@ void PromotionTransfer::TransferExternalWallet( ledger_->TransferAnonToExternalWallet( std::move(wallet), - true, - transfer_callback); + transfer_callback, + true); } void PromotionTransfer::OnAnonExternalWallet( diff --git a/vendor/bat-native-ledger/src/bat/ledger/internal/uphold/uphold.cc b/vendor/bat-native-ledger/src/bat/ledger/internal/uphold/uphold.cc index aa3298487b35..ced7ea74cb91 100644 --- a/vendor/bat-native-ledger/src/bat/ledger/internal/uphold/uphold.cc +++ b/vendor/bat-native-ledger/src/bat/ledger/internal/uphold/uphold.cc @@ -203,7 +203,6 @@ void Uphold::WalletAuthorization( void Uphold::TransferAnonToExternalWallet( ledger::ExternalWalletPtr wallet, - const bool allow_zero_balance, ledger::ExternalWalletCallback callback) { auto transfer_callback = std::bind( &Uphold::OnTransferAnonToExternalWalletCallback, @@ -213,10 +212,7 @@ void Uphold::TransferAnonToExternalWallet( _1); // transfer funds from anon wallet to uphold - ledger_->TransferAnonToExternalWallet( - std::move(wallet), - allow_zero_balance, - transfer_callback); + ledger_->TransferAnonToExternalWallet(std::move(wallet), transfer_callback); } void Uphold::GenerateExternalWallet( diff --git a/vendor/bat-native-ledger/src/bat/ledger/internal/uphold/uphold.h b/vendor/bat-native-ledger/src/bat/ledger/internal/uphold/uphold.h index 51f1dba9aebf..9e999cad6f22 100644 --- a/vendor/bat-native-ledger/src/bat/ledger/internal/uphold/uphold.h +++ b/vendor/bat-native-ledger/src/bat/ledger/internal/uphold/uphold.h @@ -68,7 +68,6 @@ class Uphold { void TransferAnonToExternalWallet( ledger::ExternalWalletPtr wallet, - const bool allow_zero_balance, ledger::ExternalWalletCallback callback); void GenerateExternalWallet( diff --git a/vendor/bat-native-ledger/src/bat/ledger/internal/uphold/uphold_wallet.cc b/vendor/bat-native-ledger/src/bat/ledger/internal/uphold/uphold_wallet.cc index c44257ac38fc..4f02c745e45c 100644 --- a/vendor/bat-native-ledger/src/bat/ledger/internal/uphold/uphold_wallet.cc +++ b/vendor/bat-native-ledger/src/bat/ledger/internal/uphold/uphold_wallet.cc @@ -96,8 +96,6 @@ void UpholdWallet::OnGenerate( wallet_ptr->user_name = user.name; - bool allow_zero_balance = false; - if (user.status != UserStatus::OK) { wallet_ptr->status = ledger::WalletStatus::PENDING; } @@ -107,23 +105,13 @@ void UpholdWallet::OnGenerate( if (current_status == ledger::WalletStatus::CONNECTED && wallet_ptr->status == ledger::WalletStatus::VERIFIED) { - allow_zero_balance = true; ledger_->TransferTokens(ledger::kWalletUphold, [](const ledger::Result){}); } - // if we don't have anon address we need to force claim so that server - // can save it - const std::string anon_address = - ledger_->GetStringState(ledger::kStateUpholdAnonAddress); - if (anon_address.empty()) { - allow_zero_balance = true; - } - if (wallet_ptr->address.empty()) { auto card_callback = std::bind( &UpholdWallet::OnCreateCard, this, - allow_zero_balance, *wallet_ptr, callback, _1, @@ -134,10 +122,7 @@ void UpholdWallet::OnGenerate( if (user.verified) { ledger_->TransferTokens(ledger::kWalletUphold, [](const ledger::Result){}); - uphold_->TransferAnonToExternalWallet( - std::move(wallet_ptr), - allow_zero_balance, - callback); + uphold_->TransferAnonToExternalWallet(std::move(wallet_ptr), callback); return; } @@ -146,7 +131,6 @@ void UpholdWallet::OnGenerate( } void UpholdWallet::OnCreateCard( - const bool allow_zero_balance, const ledger::ExternalWallet& wallet, ledger::ExternalWalletCallback callback, const ledger::Result result, @@ -161,10 +145,7 @@ void UpholdWallet::OnCreateCard( wallet_ptr = GenerateLinks(std::move(wallet_ptr)); if (wallet_ptr->status == ledger::WalletStatus::VERIFIED) { - uphold_->TransferAnonToExternalWallet( - std::move(wallet_ptr), - allow_zero_balance, - callback); + uphold_->TransferAnonToExternalWallet(std::move(wallet_ptr), callback); return; } diff --git a/vendor/bat-native-ledger/src/bat/ledger/internal/uphold/uphold_wallet.h b/vendor/bat-native-ledger/src/bat/ledger/internal/uphold/uphold_wallet.h index 54c167d9de38..dd79f25a09dd 100644 --- a/vendor/bat-native-ledger/src/bat/ledger/internal/uphold/uphold_wallet.h +++ b/vendor/bat-native-ledger/src/bat/ledger/internal/uphold/uphold_wallet.h @@ -36,7 +36,6 @@ class UpholdWallet { ledger::ExternalWalletCallback callback); void OnCreateCard( - const bool allow_zero_balance, const ledger::ExternalWallet& wallet, ledger::ExternalWalletCallback callback, const ledger::Result result,