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
|
2022-07-22 14:42:21 +00:00
|
|
|
import shared.stores 1.0 as SharedStore
|
2022-02-21 17:07:16 +00:00
|
|
|
|
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
|
2022-03-28 08:19:57 +00:00
|
|
|
property var generatedAccounts: walletSectionAccounts.generated
|
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
|
2021-10-05 20:50:22 +00:00
|
|
|
|
2022-07-22 14:42:21 +00:00
|
|
|
property var currencyStore: SharedStore.RootStore.currencyStore
|
|
|
|
property string currentCurrency: currencyStore.currentCurrency
|
2021-10-21 08:22:05 +00:00
|
|
|
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-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-15 10:08:47 +00:00
|
|
|
property var savedAddresses: walletSectionSavedAddresses.model
|
2021-10-05 20:50:22 +00:00
|
|
|
|
2022-03-31 11:46:25 +00:00
|
|
|
// Used for new wallet account generation
|
|
|
|
property var generatedAccountsViewModel: walletSectionAccounts.generatedAccounts
|
|
|
|
property var derivedAddressesList: walletSectionAccounts.derivedAddresses
|
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-07-19 09:25:13 +00:00
|
|
|
property var allNetworks: networksModule.all
|
2022-02-17 09:15:37 +00:00
|
|
|
|
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-05-12 15:24:03 +00:00
|
|
|
property bool derivedAddressesLoading: walletSectionAccounts.derivedAddressesLoading
|
|
|
|
property string derivedAddressesError: walletSectionAccounts.derivedAddressesError
|
|
|
|
|
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-31 11:46:25 +00:00
|
|
|
function generateNewAccount(password, accountName, color, emoji, path, derivedFrom) {
|
|
|
|
return walletSectionAccounts.generateNewAccount(password, accountName, color, emoji, path, derivedFrom)
|
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-31 11:46:25 +00:00
|
|
|
function addAccountsFromSeed(seedPhrase, password, accountName, color, emoji, path) {
|
|
|
|
return walletSectionAccounts.addAccountsFromSeed(seedPhrase, password, accountName, color, emoji, path)
|
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 checkRecentHistory() {
|
2022-05-16 15:02:03 +00:00
|
|
|
walletSection.checkRecentHistory()
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|
|
|
|
|
2022-03-25 08:46:47 +00:00
|
|
|
function fetchCollectionCollectiblesList(slug) {
|
2021-10-21 08:22:05 +00:00
|
|
|
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)
|
|
|
|
}
|
2022-03-31 11:46:25 +00:00
|
|
|
|
|
|
|
function getDerivedAddressList(password, derivedFrom, path, pageSize , pageNumber) {
|
2022-05-12 15:24:03 +00:00
|
|
|
walletSectionAccounts.getDerivedAddressList(password, derivedFrom, path, pageSize , pageNumber)
|
2022-03-31 11:46:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function getDerivedAddressData(index) {
|
|
|
|
return walletSectionAccounts.getDerivedAddressAtIndex(index)
|
|
|
|
}
|
|
|
|
|
|
|
|
function getDerivedAddressPathData(index) {
|
|
|
|
return walletSectionAccounts.getDerivedAddressPathAtIndex(index)
|
|
|
|
}
|
|
|
|
|
|
|
|
function getDerivedAddressHasActivityData(index) {
|
|
|
|
return walletSectionAccounts.getDerivedAddressHasActivityAtIndex(index)
|
|
|
|
}
|
|
|
|
|
2022-04-13 12:58:42 +00:00
|
|
|
function getDerivedAddressAlreadyCreatedData(index) {
|
|
|
|
return walletSectionAccounts.getDerivedAddressAlreadyCreatedAtIndex(index)
|
|
|
|
}
|
|
|
|
|
2022-03-31 11:46:25 +00:00
|
|
|
function getDerivedAddressListForMnemonic(mnemonic, path, pageSize , pageNumber) {
|
2022-05-12 15:24:03 +00:00
|
|
|
walletSectionAccounts.getDerivedAddressListForMnemonic(mnemonic, path, pageSize , pageNumber)
|
|
|
|
}
|
|
|
|
|
|
|
|
function getDerivedAddressForPrivateKey(privateKey) {
|
|
|
|
walletSectionAccounts.getDerivedAddressForPrivateKey(privateKey)
|
2022-03-31 11:46:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function resetDerivedAddressModel() {
|
|
|
|
walletSectionAccounts.resetDerivedAddressModel()
|
|
|
|
}
|
|
|
|
|
|
|
|
function vaildateMnemonic(mnemonic) {
|
|
|
|
return onboardingModule.validateMnemonic(mnemonic)
|
|
|
|
}
|
2022-04-13 12:58:42 +00:00
|
|
|
|
|
|
|
function getNextSelectableDerivedAddressIndex() {
|
|
|
|
return walletSectionAccounts.getNextSelectableDerivedAddressIndex()
|
|
|
|
}
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|