diff --git a/app/qml/Status/Application/MainView/MainView.qml b/app/qml/Status/Application/MainView/MainView.qml index ebbd77c003..4a30f2c599 100644 --- a/app/qml/Status/Application/MainView/MainView.qml +++ b/app/qml/Status/Application/MainView/MainView.qml @@ -34,6 +34,7 @@ Item { Layout.fillHeight: true sections: appSections.sections + currentIndex: 1 } ColumnLayout { @@ -59,6 +60,7 @@ Item { delegate: Loader { Layout.fillWidth: true Layout.fillHeight: true + active: navBar.currentIndex === index sourceComponent: modelData.content } diff --git a/libs/ApplicationCore/src/ApplicationCore/UserConfiguration.cpp b/libs/ApplicationCore/src/ApplicationCore/UserConfiguration.cpp index d988cea803..6976ef44d6 100644 --- a/libs/ApplicationCore/src/ApplicationCore/UserConfiguration.cpp +++ b/libs/ApplicationCore/src/ApplicationCore/UserConfiguration.cpp @@ -2,6 +2,8 @@ #include "Helpers/conversions.h" +#include + #include namespace fs = std::filesystem; @@ -40,8 +42,25 @@ void UserConfiguration::setUserDataFolder(const QString &newUserDataFolder) void UserConfiguration::generateReleaseConfiguration() { - m_userDataFolder = toPath(QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation))/statusFolder/dataSubfolder; + if(!parseFromCommandLineAndReturnTrueIfSet()) + m_userDataFolder = toPath(QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation))/statusFolder/dataSubfolder; emit userDataFolderChanged(); } +bool UserConfiguration::parseFromCommandLineAndReturnTrueIfSet() +{ + QCommandLineParser parser; + parser.addHelpOption(); + parser.addVersionOption(); + parser.addPositionalArgument("dataDir", "Data folder"); + parser.process(*QCoreApplication::instance()); + auto args = parser.positionalArguments(); + if (args.size() > 0) { + m_userDataFolder = toPath(args[0]); + emit userDataFolderChanged(); + return true; + } + return false; +} + } diff --git a/libs/ApplicationCore/src/ApplicationCore/UserConfiguration.h b/libs/ApplicationCore/src/ApplicationCore/UserConfiguration.h index 79ebef37f4..964a7eed8e 100644 --- a/libs/ApplicationCore/src/ApplicationCore/UserConfiguration.h +++ b/libs/ApplicationCore/src/ApplicationCore/UserConfiguration.h @@ -9,14 +9,13 @@ namespace Status::ApplicationCore { namespace fs = std::filesystem; +/// Contains necessary data for each created account hence this will be the same path for all accounts class UserConfiguration: public QObject { Q_OBJECT QML_ELEMENT - // Not sure why `qmlUserDataFolder` is writable??? We should not change it from the qml side. - // Even from the backend side this will be set only on the app start, and it will contain - // necessary data for each created account, so even we're switching accounts, this will be the same path. + /// @note userFolder is writable in order to allow changing it in tests until a proper abstraction is in place Q_PROPERTY(QString userDataFolder READ qmlUserDataFolder WRITE setUserDataFolder NOTIFY userDataFolderChanged) public: @@ -31,6 +30,7 @@ signals: private: void generateReleaseConfiguration(); + bool parseFromCommandLineAndReturnTrueIfSet(); fs::path m_userDataFolder; }; diff --git a/libs/StatusGoQt/src/StatusGo/Wallet/SavedAddress.h b/libs/StatusGoQt/src/StatusGo/Wallet/SavedAddress.h index 2593ae6585..ec6d1bfdef 100644 --- a/libs/StatusGoQt/src/StatusGo/Wallet/SavedAddress.h +++ b/libs/StatusGoQt/src/StatusGo/Wallet/SavedAddress.h @@ -20,10 +20,12 @@ struct SavedAddress { Accounts::EOAddress address; QString name; + bool favourite; + ChainID chainId; }; using SavedAddresses = std::vector; -NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(SavedAddress, address, name); +NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(SavedAddress, address, name, favourite, chainId); } diff --git a/libs/StatusGoQt/src/StatusGo/Wallet/WalletApi.cpp b/libs/StatusGoQt/src/StatusGo/Wallet/WalletApi.cpp index e81f6b2044..bf926e5c39 100644 --- a/libs/StatusGoQt/src/StatusGo/Wallet/WalletApi.cpp +++ b/libs/StatusGoQt/src/StatusGo/Wallet/WalletApi.cpp @@ -46,7 +46,7 @@ SavedAddresses getSavedAddresses() checkPrivateRpcCallResultAndReportError(resultJson); const auto &data = resultJson.get().result; - return data.is_null() ? nlohmann::json() : data; + return data.is_null() ? json::array() : data; } void saveAddress(const SavedAddress &address) @@ -77,7 +77,7 @@ NetworkConfigurations getEthereumChains(bool onlyEnabled) checkPrivateRpcCallResultAndReportError(resultJson); const auto &data = resultJson.get().result; - return data.is_null() ? nlohmann::json() : data; + return data.is_null() ? json::array() : data; } Tokens getTokens(const ChainID &chainId) @@ -94,7 +94,7 @@ Tokens getTokens(const ChainID &chainId) checkPrivateRpcCallResultAndReportError(resultJson); const auto &data = resultJson.get().result; - return data.is_null() ? nlohmann::json() : data; + return data.is_null() ? json::array() : data; } TokenBalances getTokensBalancesForChainIDs(const std::vector &chainIds, diff --git a/libs/Wallet/src/SavedAddressesController.cpp b/libs/Wallet/src/SavedAddressesController.cpp index ca1b0e2b50..8cf2e19ed3 100644 --- a/libs/Wallet/src/SavedAddressesController.cpp +++ b/libs/Wallet/src/SavedAddressesController.cpp @@ -18,12 +18,13 @@ QAbstractListModel *SavedAddressesController::savedAddresses() const return m_savedAddresses.get(); } +// TODO: extend with favourite and chain ID void SavedAddressesController::saveAddress(const QString &address, const QString &name) { try { StatusGo::Wallet::saveAddress(StatusGo::Wallet::SavedAddress( - { StatusGo::Accounts::EOAddress(address), name })); + { StatusGo::Accounts::EOAddress(address), name, false, StatusGo::Wallet::ChainID(0) })); } catch(const StatusGo::CallPrivateRpcError& rpcError) { diff --git a/resources/default-networks.json b/resources/default-networks.json index 63cccdac68..6ec815dd63 100644 --- a/resources/default-networks.json +++ b/resources/default-networks.json @@ -27,7 +27,7 @@ "nativeCurrencyDecimals": 18, "isTest": true, "layer": 1, - "enabled": true + "enabled": false }, { "chainId": 4, @@ -57,7 +57,7 @@ "nativeCurrencyDecimals": 18, "isTest": true, "layer": 1, - "enabled": false + "enabled": true }, { "chainId": 10,