From d1fd82faf083bb0b70731e80c82c87bf8092a777 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 15 Nov 2019 18:17:59 +0300 Subject: [PATCH] Migrate to testnet2. --- Wallet/Resources/config-test-default.json | 4 +-- Wallet/SourceFiles/wallet/application.cpp | 9 ++++++ Wallet/SourceFiles/wallet/application.h | 6 ++-- .../wallet/config_upgrade_checker.cpp | 27 ++++++++++++++++++ .../wallet/config_upgrade_checker.h | 28 +++++++++++++++++++ .../wallet/ton_default_settings.cpp | 3 +- Wallet/gyp/wallet/sources.txt | 2 ++ Wallet/lib_ton | 2 +- Wallet/lib_wallet | 2 +- 9 files changed, 76 insertions(+), 7 deletions(-) create mode 100644 Wallet/SourceFiles/wallet/config_upgrade_checker.cpp create mode 100644 Wallet/SourceFiles/wallet/config_upgrade_checker.h diff --git a/Wallet/Resources/config-test-default.json b/Wallet/Resources/config-test-default.json index 054b168..47ecdb0 100644 --- a/Wallet/Resources/config-test-default.json +++ b/Wallet/Resources/config-test-default.json @@ -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=" } } } diff --git a/Wallet/SourceFiles/wallet/application.cpp b/Wallet/SourceFiles/wallet/application.cpp index 16dc67e..cf31eda 100644 --- a/Wallet/SourceFiles/wallet/application.cpp +++ b/Wallet/SourceFiles/wallet/application.cpp @@ -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" @@ -126,6 +127,11 @@ void Application::openWallet() { _window = std::make_unique( _wallet.get(), walletUpdateInfo()); + + const auto upgrades = base::take(_upgradeChecker)->takeUpgrades(); + for (const auto upgrade : upgrades) { + _window->showConfigUpgrade(upgrade); + } handleLaunchCommand(); }; auto opened = [=](Ton::Result<> result) { @@ -140,6 +146,9 @@ void Application::openWallet() { } _wallet->start(started); }; + + _upgradeChecker = std::make_unique(_wallet.get()); + _wallet->open(QByteArray(), GetDefaultSettings(), std::move(opened)); } diff --git a/Wallet/SourceFiles/wallet/application.h b/Wallet/SourceFiles/wallet/application.h index 4b5750f..89c9c8f 100644 --- a/Wallet/SourceFiles/wallet/application.h +++ b/Wallet/SourceFiles/wallet/application.h @@ -28,6 +28,7 @@ class Window; class Intro; class Info; class UpdateInfo; +class ConfigUpgradeChecker; class Application final : public base::has_weak_ptr { public: @@ -49,8 +50,9 @@ class Application final : public base::has_weak_ptr { const QString _path; const std::unique_ptr _wallet; - std::unique_ptr _window; - std::unique_ptr _updateInfo; + std::unique_ptr _window; + std::unique_ptr _updateInfo; + std::unique_ptr _upgradeChecker; QByteArray _launchCommand; rpl::lifetime _lifetime; diff --git a/Wallet/SourceFiles/wallet/config_upgrade_checker.cpp b/Wallet/SourceFiles/wallet/config_upgrade_checker.cpp new file mode 100644 index 0000000..7f8355c --- /dev/null +++ b/Wallet/SourceFiles/wallet/config_upgrade_checker.cpp @@ -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 wallet) { + wallet->updates( + ) | rpl::filter([](const Ton::Update &update) { + return update.data.is(); + }) | rpl::start_with_next([=](const Ton::Update &update) { + _upgrades.push_back(update.data.get()); + }, _lifetime); +} + +std::vector ConfigUpgradeChecker::takeUpgrades() { + return std::move(_upgrades); +} + +} // namespace Wallet diff --git a/Wallet/SourceFiles/wallet/config_upgrade_checker.h b/Wallet/SourceFiles/wallet/config_upgrade_checker.h new file mode 100644 index 0000000..a843136 --- /dev/null +++ b/Wallet/SourceFiles/wallet/config_upgrade_checker.h @@ -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 wallet); + + std::vector takeUpgrades(); + +private: + std::vector _upgrades; + rpl::lifetime _lifetime; + +}; + +} // namespace Wallet diff --git a/Wallet/SourceFiles/wallet/ton_default_settings.cpp b/Wallet/SourceFiles/wallet/ton_default_settings.cpp index 2b7b1aa..a2a6cab 100644 --- a/Wallet/SourceFiles/wallet/ton_default_settings.cpp +++ b/Wallet/SourceFiles/wallet/ton_default_settings.cpp @@ -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; } diff --git a/Wallet/gyp/wallet/sources.txt b/Wallet/gyp/wallet/sources.txt index 93cc49c..abe1239 100644 --- a/Wallet/gyp/wallet/sources.txt +++ b/Wallet/gyp/wallet/sources.txt @@ -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 diff --git a/Wallet/lib_ton b/Wallet/lib_ton index 82bb50c..ce4ed54 160000 --- a/Wallet/lib_ton +++ b/Wallet/lib_ton @@ -1 +1 @@ -Subproject commit 82bb50c968b56b6cc006c08c9860ae70ee491dcc +Subproject commit ce4ed542272df1c6fce5cab0494ced20e2602008 diff --git a/Wallet/lib_wallet b/Wallet/lib_wallet index 0a573a1..07d05dc 160000 --- a/Wallet/lib_wallet +++ b/Wallet/lib_wallet @@ -1 +1 @@ -Subproject commit 0a573a1f95ff2512c6fd184c9992efb986437b61 +Subproject commit 07d05dccde92b69900d425326e38ff0607ea5f42