Skip to content

Commit

Permalink
Migrate to testnet2.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Nov 15, 2019
1 parent 85d4f52 commit d1fd82f
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Wallet/Resources/config-test-default.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"workchain": -1,
"shard": -9223372036854775808,
"seqno": 0,
"root_hash": "VCSXxDHhTALFxReyTZRd8E4Ya3ySOmpOWAS4rBX9XBY=",
"file_hash": "eh9yveSz1qMdJ7mOsO+I+H77jkLr9NpAuEkoJuseXBo="
"root_hash": "F6OpKZKqvqeFp6CQmFomXNMfMj2EnaUSOXN+Mh+wVWk=",
"file_hash": "XplPz01CXAps5qeSWUtxcyBfdAo5zVb1N979KLSKD24="
}
}
}
9 changes: 9 additions & 0 deletions Wallet/SourceFiles/wallet/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//
#include "wallet/application.h"

#include "wallet/config_upgrade_checker.h"
#include "wallet/wallet_window.h"
#include "wallet/wallet_log.h"
#include "wallet/ton_default_settings.h"
Expand Down Expand Up @@ -126,6 +127,11 @@ void Application::openWallet() {
_window = std::make_unique<Wallet::Window>(
_wallet.get(),
walletUpdateInfo());

const auto upgrades = base::take(_upgradeChecker)->takeUpgrades();
for (const auto upgrade : upgrades) {
_window->showConfigUpgrade(upgrade);
}
handleLaunchCommand();
};
auto opened = [=](Ton::Result<> result) {
Expand All @@ -140,6 +146,9 @@ void Application::openWallet() {
}
_wallet->start(started);
};

_upgradeChecker = std::make_unique<ConfigUpgradeChecker>(_wallet.get());

_wallet->open(QByteArray(), GetDefaultSettings(), std::move(opened));
}

Expand Down
6 changes: 4 additions & 2 deletions Wallet/SourceFiles/wallet/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class Window;
class Intro;
class Info;
class UpdateInfo;
class ConfigUpgradeChecker;

class Application final : public base::has_weak_ptr {
public:
Expand All @@ -49,8 +50,9 @@ class Application final : public base::has_weak_ptr {

const QString _path;
const std::unique_ptr<Ton::Wallet> _wallet;
std::unique_ptr<Wallet::Window> _window;
std::unique_ptr<Wallet::UpdateInfo> _updateInfo;
std::unique_ptr<Window> _window;
std::unique_ptr<UpdateInfo> _updateInfo;
std::unique_ptr<ConfigUpgradeChecker> _upgradeChecker;
QByteArray _launchCommand;

rpl::lifetime _lifetime;
Expand Down
27 changes: 27 additions & 0 deletions Wallet/SourceFiles/wallet/config_upgrade_checker.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// This file is part of Gram Wallet Desktop,
// a desktop application for the TON Blockchain project.
//
// For license and copyright information please follow this link:
// https://github.com/ton-blockchain/wallet-desktop/blob/master/LEGAL
//
#include "wallet/config_upgrade_checker.h"

#include "ton/ton_wallet.h"
#include "ton/ton_state.h"

namespace Wallet {

ConfigUpgradeChecker::ConfigUpgradeChecker(not_null<Ton::Wallet*> wallet) {
wallet->updates(
) | rpl::filter([](const Ton::Update &update) {
return update.data.is<Ton::ConfigUpgrade>();
}) | rpl::start_with_next([=](const Ton::Update &update) {
_upgrades.push_back(update.data.get<Ton::ConfigUpgrade>());
}, _lifetime);
}

std::vector<Ton::ConfigUpgrade> ConfigUpgradeChecker::takeUpgrades() {
return std::move(_upgrades);
}

} // namespace Wallet
28 changes: 28 additions & 0 deletions Wallet/SourceFiles/wallet/config_upgrade_checker.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// This file is part of Gram Wallet Desktop,
// a desktop application for the TON Blockchain project.
//
// For license and copyright information please follow this link:
// https://github.com/ton-blockchain/wallet-desktop/blob/master/LEGAL
//
#pragma once

namespace Ton {
class Wallet;
enum class ConfigUpgrade;
} // namespace Ton

namespace Wallet {

class ConfigUpgradeChecker final {
public:
ConfigUpgradeChecker(not_null<Ton::Wallet*> wallet);

std::vector<Ton::ConfigUpgrade> takeUpgrades();

private:
std::vector<Ton::ConfigUpgrade> _upgrades;
rpl::lifetime _lifetime;

};

} // namespace Wallet
3 changes: 2 additions & 1 deletion Wallet/SourceFiles/wallet/ton_default_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ Ton::Settings GetDefaultSettings() {
file.open(QIODevice::ReadOnly);
result.config = file.readAll();
result.useNetworkCallbacks = false;
result.blockchainName = "testnet";
result.blockchainName = "testnet2";
result.configUrl = "https://test.ton.org/config.json";
result.version = 2;
return result;
}

Expand Down
2 changes: 2 additions & 0 deletions Wallet/gyp/wallet/sources.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<(src_loc)/core/version.h
<(src_loc)/wallet/application.cpp
<(src_loc)/wallet/application.h
<(src_loc)/wallet/config_upgrade_checker.cpp
<(src_loc)/wallet/config_upgrade_checker.h
<(src_loc)/wallet/phrases.cpp
<(src_loc)/wallet/phrases.h
<(src_loc)/wallet/ton_default_settings.cpp
Expand Down
2 changes: 1 addition & 1 deletion Wallet/lib_wallet

0 comments on commit d1fd82f

Please sign in to comment.