2021-10-05 20:50:22 +00:00
|
|
|
pragma Singleton
|
|
|
|
|
|
|
|
import QtQuick 2.13
|
|
|
|
|
2022-02-21 17:07:16 +00:00
|
|
|
import utils 1.0
|
|
|
|
|
2021-10-05 20:50:22 +00:00
|
|
|
QtObject {
|
|
|
|
id: root
|
2022-02-21 17:07:16 +00:00
|
|
|
property var currentAccount: Constants.isCppApp ? walletSectionAccounts.currentAccount: walletSectionCurrent
|
2021-10-20 13:17:49 +00:00
|
|
|
property var accounts: walletSectionAccounts.model
|
2021-12-06 21:10:54 +00:00
|
|
|
property var appSettings: localAppSettings
|
|
|
|
property var accountSensitiveSettings: localAccountSensitiveSettings
|
|
|
|
property string locale: appSettings.locale
|
|
|
|
property bool hideSignPhraseModal: accountSensitiveSettings.hideSignPhraseModal
|
2022-02-15 13:19:45 +00:00
|
|
|
property bool isMultiNetworkEnabled: accountSensitiveSettings.isMultiNetworkEnabled
|
2021-10-05 20:50:22 +00:00
|
|
|
|
2021-10-21 08:22:05 +00:00
|
|
|
property string currentCurrency: walletSection.currentCurrency
|
|
|
|
property string totalCurrencyBalance: walletSection.totalCurrencyBalance
|
|
|
|
property string signingPhrase: walletSection.signingPhrase
|
|
|
|
property string mnemonicBackedUp: walletSection.isMnemonicBackedUp
|
2021-10-05 20:50:22 +00:00
|
|
|
|
2021-11-09 19:40:09 +00:00
|
|
|
property var walletTokensModule: walletSectionAllTokens
|
2021-10-20 12:37:44 +00:00
|
|
|
property var tokens: walletSectionAllTokens.all
|
|
|
|
|
2021-10-20 14:05:59 +00:00
|
|
|
property var assets: walletSectionAccountTokens.model
|
2021-10-05 20:50:22 +00:00
|
|
|
|
2021-10-21 08:22:05 +00:00
|
|
|
property CollectiblesStore collectiblesStore: CollectiblesStore { }
|
|
|
|
property var collectionList: walletSectionCollectiblesCollections.model
|
2021-10-05 20:50:22 +00:00
|
|
|
|
2021-12-13 14:24:21 +00:00
|
|
|
property var history: walletSectionTransactions
|
2021-10-21 08:22:05 +00:00
|
|
|
property var historyTransactions: walletSectionTransactions.model
|
2022-02-04 20:06:50 +00:00
|
|
|
property bool isNonArchivalNode: history.isNonArchivalNode
|
2021-12-15 10:08:47 +00:00
|
|
|
|
|
|
|
property var savedAddresses: walletSectionSavedAddresses.model
|
2021-10-05 20:50:22 +00:00
|
|
|
|
2022-02-17 09:15:37 +00:00
|
|
|
|
|
|
|
property var layer1Networks: networksModule.layer1
|
|
|
|
property var layer2Networks: networksModule.layer2
|
|
|
|
property var testNetworks: networksModule.test
|
|
|
|
property var enabledNetworks: networksModule.enabled
|
|
|
|
|
2022-03-01 14:54:41 +00:00
|
|
|
property var cryptoRampServicesModel: walletSectionBuySellCrypto.model
|
|
|
|
|
2021-10-14 08:04:15 +00:00
|
|
|
// This should be exposed to the UI via "walletModule", WalletModule should use
|
2021-10-17 11:41:12 +00:00
|
|
|
// Accounts Service which keeps the info about that (isFirstTimeAccountLogin).
|
|
|
|
// Then in the View of WalletModule we may have either QtProperty or
|
|
|
|
// Q_INVOKABLE function (proc marked as slot) depends on logic/need.
|
|
|
|
// The only need for onboardingModel here is actually to check if an account
|
|
|
|
// has been just created or an old one.
|
2021-10-14 08:04:15 +00:00
|
|
|
|
2021-10-17 11:41:12 +00:00
|
|
|
//property bool firstTimeLogin: onboardingModel.isFirstTimeLogin
|
2021-10-05 20:50:22 +00:00
|
|
|
|
|
|
|
// example wallet model
|
|
|
|
property ListModel exampleWalletModel: ListModel {
|
|
|
|
ListElement {
|
|
|
|
name: "Status account"
|
|
|
|
address: "0xcfc9f08bbcbcb80760e8cb9a3c1232d19662fc6f"
|
|
|
|
balance: "12.00 USD"
|
2021-10-21 08:22:05 +00:00
|
|
|
color: "#7CDA00"
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ListElement {
|
|
|
|
name: "Test account 1"
|
|
|
|
address: "0x2Ef1...E0Ba"
|
|
|
|
balance: "12.00 USD"
|
2021-10-21 08:22:05 +00:00
|
|
|
color: "#FA6565"
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|
|
|
|
ListElement {
|
|
|
|
name: "Status account"
|
|
|
|
address: "0x2Ef1...E0Ba"
|
|
|
|
balance: "12.00 USD"
|
2021-10-21 08:22:05 +00:00
|
|
|
color: "#7CDA00"
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
property ListModel exampleAssetModel: ListModel {
|
|
|
|
ListElement {
|
2021-12-06 21:10:54 +00:00
|
|
|
name: "Ethereum"
|
2021-10-05 20:50:22 +00:00
|
|
|
symbol: "ETH"
|
2021-12-06 21:10:54 +00:00
|
|
|
balance: "3423 ETH"
|
|
|
|
address: "token-icons/eth"
|
|
|
|
currencyBalance: "123 USD"
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-21 14:18:43 +00:00
|
|
|
function setHideSignPhraseModal(value) {
|
2021-12-06 21:10:54 +00:00
|
|
|
localAccountSensitiveSettings.hideSignPhraseModal = value;
|
|
|
|
}
|
|
|
|
|
2021-10-05 20:50:22 +00:00
|
|
|
function getLatestBlockNumber() {
|
2021-10-21 08:22:05 +00:00
|
|
|
// TODO: Move to transaction root module and not wallet
|
2021-12-13 14:24:21 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
// return walletModel.getLatestBlockNumber()
|
|
|
|
}
|
|
|
|
|
2021-10-05 20:50:22 +00:00
|
|
|
function setInitialRange() {
|
2021-12-13 14:24:21 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
// walletModel.setInitialRange()
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|
|
|
|
|
2021-10-21 08:22:05 +00:00
|
|
|
function switchAccount(newIndex) {
|
2022-02-21 17:07:16 +00:00
|
|
|
if(Constants.isCppApp)
|
|
|
|
walletSectionAccounts.switchAccount(newIndex)
|
|
|
|
else
|
|
|
|
walletSection.switchAccount(newIndex)
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|
|
|
|
|
2022-03-10 17:01:17 +00:00
|
|
|
function generateNewAccount(password, accountName, color, emoji) {
|
|
|
|
return walletSectionAccounts.generateNewAccount(password, accountName, color, emoji)
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|
|
|
|
|
2022-03-10 17:01:17 +00:00
|
|
|
function addAccountsFromPrivateKey(privateKey, password, accountName, color, emoji) {
|
|
|
|
return walletSectionAccounts.addAccountsFromPrivateKey(privateKey, password, accountName, color, emoji)
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|
|
|
|
|
2022-03-10 17:01:17 +00:00
|
|
|
function addAccountsFromSeed(seedPhrase, password, accountName, color, emoji) {
|
|
|
|
return walletSectionAccounts.addAccountsFromSeed(seedPhrase, password, accountName, color, emoji)
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|
|
|
|
|
2022-03-10 17:01:17 +00:00
|
|
|
function addWatchOnlyAccount(address, accountName,color, emoji) {
|
|
|
|
return walletSectionAccounts.addWatchOnlyAccount(address, accountName, color, emoji)
|
2021-10-21 08:22:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function deleteAccount(address) {
|
|
|
|
return walletSectionAccounts.deleteAccount(address)
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|
|
|
|
|
2022-03-10 17:01:17 +00:00
|
|
|
function updateCurrentAccount(address, accountName, color, emoji) {
|
|
|
|
return walletSectionCurrent.update(address, accountName, color, emoji)
|
2021-10-21 08:22:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function updateCurrency(newCurrency) {
|
|
|
|
walletSection.updateCurrency(newCurrency)
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function getQrCode(address) {
|
2022-01-24 11:41:55 +00:00
|
|
|
return globalUtils.qrCode(address)
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function hex2Dec(value) {
|
2021-12-14 16:11:31 +00:00
|
|
|
return globalUtils.hex2Dec(value)
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function hex2Eth(value) {
|
2021-12-14 16:11:31 +00:00
|
|
|
return globalUtils.hex2Eth(value)
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function checkRecentHistory() {
|
2021-12-13 14:24:21 +00:00
|
|
|
history.checkRecentHistory()
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function isFetchingHistory() {
|
2022-02-04 20:06:50 +00:00
|
|
|
return history.isFetchingHistory(currentAccount.address)
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function loadTransactionsForAccount(pageSize) {
|
2022-02-04 20:06:50 +00:00
|
|
|
history.loadTransactionsForAccount(currentAccount.address,
|
|
|
|
historyTransactions.getLastTxBlockNumber(),
|
|
|
|
pageSize, true)
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|
2021-10-21 08:22:05 +00:00
|
|
|
|
|
|
|
function fetchCollectionCollectiblesList(slug) {
|
|
|
|
walletSectionCollectiblesCollectibles.fetch(slug)
|
|
|
|
}
|
|
|
|
|
|
|
|
function getCollectionCollectiblesList(slug) {
|
|
|
|
return walletSectionCollectiblesCollectibles.getModelForCollection(slug)
|
|
|
|
}
|
|
|
|
|
|
|
|
function getCollectionMaxValue(traitType, value, maxValue, collectionIndex) {
|
2021-12-13 14:24:21 +00:00
|
|
|
// Not Refactored Yet
|
|
|
|
// if(maxValue !== "")
|
|
|
|
// return parseInt(value) + qsTr(" of ") + maxValue;
|
|
|
|
// else
|
|
|
|
// return parseInt(value) + qsTr(" of ") +
|
|
|
|
// walletModelV2Inst.collectiblesView.collections.getCollectionTraitMaxValue(collectionIndex, traitType).toString();
|
2021-10-21 08:22:05 +00:00
|
|
|
}
|
2021-12-15 10:08:47 +00:00
|
|
|
|
|
|
|
function createOrUpdateSavedAddress(name, address) {
|
2022-03-01 10:14:13 +00:00
|
|
|
return walletSectionSavedAddresses.createOrUpdateSavedAddress(name, address)
|
2021-12-15 10:08:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function deleteSavedAddress(address) {
|
2022-03-01 10:14:13 +00:00
|
|
|
return walletSectionSavedAddresses.deleteSavedAddress(address)
|
2021-12-15 10:08:47 +00:00
|
|
|
}
|
2022-02-17 09:15:37 +00:00
|
|
|
|
|
|
|
function toggleNetwork(chainId) {
|
|
|
|
networksModule.toggleNetwork(chainId)
|
|
|
|
}
|
2022-03-15 19:34:28 +00:00
|
|
|
|
|
|
|
function copyToClipboard(text) {
|
|
|
|
globalUtils.copyToClipboard(text)
|
|
|
|
}
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|