Skip to content

Commit

Permalink
Addresses the review
Browse files Browse the repository at this point in the history
  • Loading branch information
NejcZdovc committed Aug 17, 2018
1 parent e90f72b commit 14391e1
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion include/bat/ledger/grant.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ LEDGER_EXPORT struct Grant {
std::string altcurrency;
std::string probi;
std::string promotionId;
unsigned int expiryTime;
uint64_t expiryTime;
};

} // namespace ledger
Expand Down
6 changes: 3 additions & 3 deletions include/bat/ledger/ledger_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ class LEDGER_EXPORT LedgerClient {
GetPublisherInfoListCallback callback) = 0;

virtual void GetGrant(const std::string& lang, const std::string& paymentId) = 0;
virtual void OnGrant(ledger::Result result, ledger::Grant) = 0;
virtual void OnGrant(ledger::Result result, const ledger::Grant& grant) = 0;
virtual void GetGrantCaptcha() = 0;
virtual void OnGrantCaptcha(const std::string& image) = 0;
virtual void OnRecoverWallet(Result result, double balance, std::vector<ledger::Grant> grants) = 0;
virtual void OnGrantFinish(ledger::Result result, ledger::Grant grant) = 0;
virtual void OnRecoverWallet(Result result, double balance, const std::vector<ledger::Grant>& grants) = 0;
virtual void OnGrantFinish(ledger::Result result, const ledger::Grant& grant) = 0;

virtual std::string URIEncode(const std::string& value) = 0;

Expand Down
9 changes: 6 additions & 3 deletions src/bat_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,8 @@ void BatClient::recoverWallet(const std::string& passPhrase) {
int result = bip39_mnemonic_to_bytes(nullptr, passPhrase.c_str(), &newSeed.front(), newSeed.size(), &written);
LOG(ERROR) << "!!!recoverWallet result == " << result << "!!!result size == " << written;
if (0 != result || 0 == written) {
ledger_->OnRecoverWallet(ledger::Result::ERROR, 0, std::vector<braveledger_bat_helper::GRANT>());
std::vector<braveledger_bat_helper::GRANT> empty;
ledger_->OnRecoverWallet(ledger::Result::ERROR, 0, empty);
return;
}
state_->walletInfo_.keyInfoSeed_ = newSeed;
Expand All @@ -921,7 +922,8 @@ void BatClient::recoverWalletPublicKeyCallback(bool result, const std::string& r
LOG(ERROR) << "!!!recoverWalletPublicKeyCallback == " << response;

if (!result) {
ledger_->OnRecoverWallet(ledger::Result::ERROR, 0, std::vector<braveledger_bat_helper::GRANT>());
std::vector<braveledger_bat_helper::GRANT> empty;
ledger_->OnRecoverWallet(ledger::Result::ERROR, 0, empty);
return;
}
std::string recoveryId;
Expand All @@ -941,7 +943,8 @@ void BatClient::recoverWalletCallback(bool result, const std::string& response,
LOG(ERROR) << "!!!recoverWalletCallback == " << response;

if (!result) {
ledger_->OnRecoverWallet(ledger::Result::ERROR, 0, std::vector<braveledger_bat_helper::GRANT>());
std::vector<braveledger_bat_helper::GRANT> empty;
ledger_->OnRecoverWallet(ledger::Result::ERROR, 0, empty);
return;
}

Expand Down
4 changes: 2 additions & 2 deletions src/ledger_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ void LedgerImpl::RecoverWallet(const std::string& passPhrase) const {
bat_client_->recoverWallet(passPhrase);
}

void LedgerImpl::OnRecoverWallet(ledger::Result result, double balance, std::vector<braveledger_bat_helper::GRANT> grants) {
void LedgerImpl::OnRecoverWallet(ledger::Result result, double balance, const std::vector<braveledger_bat_helper::GRANT>& grants) {
std::vector<ledger::Grant> ledgerGrants;

for (size_t i = 0; i < grants.size(); i ++) {
Expand All @@ -441,7 +441,7 @@ void LedgerImpl::SolveGrantCaptcha(const std::string& solution) const {
bat_client_->setGrant(solution, "");
}

void LedgerImpl::OnGrantFinish(ledger::Result result, braveledger_bat_helper::GRANT grant) {
void LedgerImpl::OnGrantFinish(ledger::Result result, const braveledger_bat_helper::GRANT& grant) {
ledger::Grant newGrant;

newGrant.altcurrency = grant.altcurrency;
Expand Down
6 changes: 3 additions & 3 deletions src/ledger_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,17 @@ class LedgerImpl : public ledger::Ledger,
void GetWalletProperties() const override;

void GetGrant(const std::string& lang, const std::string& paymentId) const override;
void OnGrant(ledger::Result result, const braveledger_bat_helper::GRANT&);
void OnGrant(ledger::Result result, const braveledger_bat_helper::GRANT& grant);

void GetGrantCaptcha() const override;
void OnGrantCaptcha(const std::string& image);

void SolveGrantCaptcha(const std::string& solution) const override;
void OnGrantFinish(ledger::Result result, braveledger_bat_helper::GRANT grant);
void OnGrantFinish(ledger::Result result, const braveledger_bat_helper::GRANT& grant);

std::string GetWalletPassphrase() const override;
void RecoverWallet(const std::string& passPhrase) const override;
void OnRecoverWallet(ledger::Result result, double balance, std::vector<braveledger_bat_helper::GRANT> grants);
void OnRecoverWallet(ledger::Result result, double balance, const std::vector<braveledger_bat_helper::GRANT>& grants);

std::unique_ptr<ledger::LedgerURLLoader> LoadURL(const std::string& url,
const std::vector<std::string>& headers,
Expand Down

0 comments on commit 14391e1

Please sign in to comment.