-
Notifications
You must be signed in to change notification settings - Fork 879
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6063 from brave/migrate-anon-address
Migrates anon address to uphold wallet object
- Loading branch information
Showing
17 changed files
with
161 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
vendor/bat-native-ledger/src/bat/ledger/internal/state/state_migration_v3.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* 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 <utility> | ||
|
||
#include "bat/ledger/global_constants.h" | ||
#include "bat/ledger/internal/ledger_impl.h" | ||
#include "bat/ledger/internal/state/state_keys.h" | ||
#include "bat/ledger/internal/state/state_migration_v3.h" | ||
#include "bat/ledger/internal/state/state_util.h" | ||
#include "bat/ledger/internal/uphold/uphold_util.h" | ||
|
||
namespace braveledger_state { | ||
|
||
StateMigrationV3::StateMigrationV3(bat_ledger::LedgerImpl* ledger) : | ||
ledger_(ledger) { | ||
} | ||
|
||
StateMigrationV3::~StateMigrationV3() = default; | ||
|
||
void StateMigrationV3::Migrate(ledger::ResultCallback callback) { | ||
const std::string anon_address = | ||
ledger_->GetStringState(ledger::kStateUpholdAnonAddress); | ||
|
||
if (!anon_address.empty()) { | ||
auto wallets = ledger_->GetExternalWallets(); | ||
auto wallet = braveledger_uphold::GetWallet(std::move(wallets)); | ||
if (!wallet) { | ||
BLOG(0, "Wallet is null, but we can't recover"); | ||
callback(ledger::Result::LEDGER_OK); | ||
return; | ||
} | ||
|
||
wallet->anon_address = anon_address; | ||
ledger_->SaveExternalWallet(ledger::kWalletUphold, std::move(wallet)); | ||
ledger_->ClearState(ledger::kStateUpholdAnonAddress); | ||
} | ||
|
||
callback(ledger::Result::LEDGER_OK); | ||
} | ||
|
||
} // namespace braveledger_state |
33 changes: 33 additions & 0 deletions
33
vendor/bat-native-ledger/src/bat/ledger/internal/state/state_migration_v3.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* 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 BRAVELEDGER_BAT_STATE_STATE_MIGRATION_V3_H_ | ||
#define BRAVELEDGER_BAT_STATE_STATE_MIGRATION_V3_H_ | ||
|
||
#include <memory> | ||
#include <string> | ||
|
||
#include "bat/ledger/ledger.h" | ||
|
||
namespace bat_ledger { | ||
class LedgerImpl; | ||
} | ||
|
||
namespace braveledger_state { | ||
|
||
class StateMigrationV3 { | ||
public: | ||
explicit StateMigrationV3(bat_ledger::LedgerImpl* ledger); | ||
~StateMigrationV3(); | ||
|
||
void Migrate(ledger::ResultCallback callback); | ||
|
||
private: | ||
bat_ledger::LedgerImpl* ledger_; // NOT OWNED | ||
}; | ||
|
||
} // namespace braveledger_state | ||
|
||
#endif // BRAVELEDGER_BAT_STATE_STATE_MIGRATION_V3_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.