2021-10-05 20:50:22 +00:00
|
|
|
pragma Singleton
|
|
|
|
|
|
|
|
import QtQuick 2.13
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: root
|
|
|
|
|
2021-10-21 08:22:05 +00:00
|
|
|
property var currentAccount: walletSectionCurrent
|
2021-10-20 13:17:49 +00:00
|
|
|
property var accounts: walletSectionAccounts.model
|
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-10-20 12:37:44 +00:00
|
|
|
property var defaultTokenList: walletSectionAllTokens.default
|
|
|
|
property var customTokenList: walletSectionAllTokens.custom
|
|
|
|
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-10-21 08:22:05 +00:00
|
|
|
property var history: walletSectionTransactions
|
|
|
|
property var historyTransactions: walletSectionTransactions.model
|
|
|
|
// property var transactions: walletModel.transactionsView.transactions
|
|
|
|
// property var historyView: walletModel.historyView
|
2021-10-05 20:50:22 +00:00
|
|
|
|
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 {
|
|
|
|
value: "123 USD"
|
|
|
|
symbol: "ETH"
|
|
|
|
fullTokenName: "Ethereum"
|
|
|
|
fiatBalanceDisplay: "3423 ETH"
|
|
|
|
image: "token-icons/eth"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function getLatestBlockNumber() {
|
2021-10-21 08:22:05 +00:00
|
|
|
// TODO: Move to transaction root module and not wallet
|
2021-10-05 20:50:22 +00:00
|
|
|
return walletModel.getLatestBlockNumber()
|
|
|
|
}
|
|
|
|
|
|
|
|
function isNonArchivalNode() {
|
|
|
|
return walletModel.isNonArchivalNode
|
|
|
|
}
|
|
|
|
|
|
|
|
function setInitialRange() {
|
|
|
|
walletModel.setInitialRange()
|
|
|
|
}
|
|
|
|
|
2021-10-21 08:22:05 +00:00
|
|
|
function switchAccount(newIndex) {
|
|
|
|
walletSection.switchAccount(newIndex)
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|
|
|
|
|
2021-10-21 08:22:05 +00:00
|
|
|
function generateNewAccount(password, accountName, color) {
|
|
|
|
return walletSectionAccounts.generateNewAccount(password, accountName, color)
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function addAccountsFromPrivateKey(privateKey, password, accountName, color) {
|
2021-10-21 08:22:05 +00:00
|
|
|
return walletSectionAccounts.addAccountsFromPrivateKey(privateKey, password, accountName, color)
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function addAccountsFromSeed(seedPhrase, password, accountName, color) {
|
2021-10-21 08:22:05 +00:00
|
|
|
return walletSectionAccounts.addAccountsFromSeed(seedPhrase, password, accountName, color)
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function addWatchOnlyAccount(address, accountName, color) {
|
2021-10-21 08:22:05 +00:00
|
|
|
return walletSectionAccounts.addWatchOnlyAccount(address, accountName, color)
|
|
|
|
}
|
|
|
|
|
|
|
|
function deleteAccount(address) {
|
|
|
|
return walletSectionAccounts.deleteAccount(address)
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|
|
|
|
|
2021-10-21 08:22:05 +00:00
|
|
|
function updateCurrentAccount(address, accountName, color) {
|
|
|
|
return walletSectionCurrent.update(address, accountName, color)
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateCurrency(newCurrency) {
|
|
|
|
walletSection.updateCurrency(newCurrency)
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function addCustomToken(address, name, symbol, decimals) {
|
2021-10-21 08:22:05 +00:00
|
|
|
return walletSectionAllTokens.addCustomToken(address, name, symbol, decimals)
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|
|
|
|
|
2021-10-21 08:22:05 +00:00
|
|
|
function toggleVisible(symbol) {
|
|
|
|
walletSectionAllTokens.toggleVisible(symbol)
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function removeCustomToken(address) {
|
2021-10-21 08:22:05 +00:00
|
|
|
walletSectionAllTokens.removeCustomToken(address)
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function getQrCode(address) {
|
2021-10-21 08:22:05 +00:00
|
|
|
// TODO: Move to transaction root module and not wallet
|
2021-10-05 20:50:22 +00:00
|
|
|
return profileModel.qrCode(address)
|
|
|
|
}
|
|
|
|
|
|
|
|
function hex2Dec(value) {
|
2021-10-21 08:22:05 +00:00
|
|
|
// TODO: Move to transaction root module and not wallet
|
2021-10-05 20:50:22 +00:00
|
|
|
return utilsModel.hex2Dec(value)
|
|
|
|
}
|
|
|
|
|
|
|
|
function hex2Eth(value) {
|
2021-10-21 08:22:05 +00:00
|
|
|
// TODO: Move to transaction module
|
2021-10-05 20:50:22 +00:00
|
|
|
return utilsModel.hex2Eth(value)
|
|
|
|
}
|
|
|
|
|
|
|
|
function checkRecentHistory() {
|
2021-10-21 08:22:05 +00:00
|
|
|
history.checkRecentHistory()
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function isFetchingHistory() {
|
2021-10-21 08:22:05 +00:00
|
|
|
return history.isFetchingHistory(walletModel.accountsView.currentAccount.address)
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function loadTransactionsForAccount(pageSize) {
|
2021-10-21 08:22:05 +00:00
|
|
|
history.loadTransactionsForAccount(walletModel.accountsView.currentAccount.address,
|
|
|
|
historyTransactions.getLastTxBlockNumber(),
|
2021-10-05 20:50:22 +00:00
|
|
|
pageSize, true)
|
|
|
|
}
|
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) {
|
|
|
|
if(maxValue !== "")
|
|
|
|
return parseInt(value) + qsTr(" of ") + maxValue;
|
|
|
|
else
|
|
|
|
return parseInt(value) + qsTr(" of ") +
|
|
|
|
walletModelV2Inst.collectiblesView.collections.getCollectionTraitMaxValue(collectionIndex, traitType).toString();
|
|
|
|
}
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|