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
|
2023-02-20 10:57:45 +00:00
|
|
|
import SortFilterProxyModel 0.2
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
|
2023-03-22 15:48:44 +00:00
|
|
|
import "../addaccount/stores"
|
2022-10-27 09:26:34 +00:00
|
|
|
|
2021-10-05 20:50:22 +00:00
|
|
|
QtObject {
|
|
|
|
id: root
|
2022-08-09 15:08:39 +00:00
|
|
|
|
2022-10-27 09:26:34 +00:00
|
|
|
readonly property string defaultSelectedKeyUid: userProfile.keyUid
|
|
|
|
readonly property bool defaultSelectedKeyUidMigratedToKeycard: userProfile.isKeycardUser
|
|
|
|
|
|
|
|
property bool loggedInUserAuthenticated: false
|
|
|
|
|
2022-09-13 16:17:54 +00:00
|
|
|
property string backButtonName: ""
|
2023-04-13 09:59:17 +00:00
|
|
|
property var overview: walletSectionOverview
|
|
|
|
property var assets: walletSectionCurrent
|
|
|
|
property var 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 bool hideSignPhraseModal: accountSensitiveSettings.hideSignPhraseModal
|
2021-10-05 20:50:22 +00:00
|
|
|
|
2022-12-29 16:44:51 +00:00
|
|
|
property var totalCurrencyBalance: walletSection.totalCurrencyBalance
|
2021-10-21 08:22:05 +00:00
|
|
|
property string signingPhrase: walletSection.signingPhrase
|
|
|
|
property string mnemonicBackedUp: walletSection.isMnemonicBackedUp
|
2021-10-05 20:50:22 +00:00
|
|
|
|
2023-03-06 16:46:32 +00:00
|
|
|
property var flatCollectibles: walletSectionCollectibles.model
|
2022-12-16 12:05:19 +00:00
|
|
|
property var currentCollectible: walletSectionCurrentCollectible
|
2021-10-05 20:50:22 +00:00
|
|
|
|
2023-02-20 10:57:45 +00:00
|
|
|
property var savedAddresses: SortFilterProxyModel {
|
|
|
|
sourceModel: walletSectionSavedAddresses.model
|
|
|
|
filters: [
|
|
|
|
ValueFilter {
|
|
|
|
roleName: "isTest"
|
|
|
|
value: networksModule.areTestNetworksEnabled
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
property QtObject _d: QtObject {
|
|
|
|
id: d
|
|
|
|
property var chainColors: ({})
|
|
|
|
|
|
|
|
function initChainColors(model) {
|
|
|
|
for (let i = 0; i < model.count; i++) {
|
|
|
|
chainColors[model.rowData(i, "shortName")] = model.rowData(i, "chainColor")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function colorForChainShortName(chainShortName) {
|
|
|
|
return d.chainColors[chainShortName]
|
|
|
|
}
|
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-07-19 09:25:13 +00:00
|
|
|
property var allNetworks: networksModule.all
|
2023-02-20 10:57:45 +00:00
|
|
|
onAllNetworksChanged: {
|
|
|
|
d.initChainColors(allNetworks)
|
|
|
|
}
|
2022-11-12 09:18:18 +00:00
|
|
|
property var layer1NetworksProxy: networksModule.layer1Proxy
|
|
|
|
property var layer2NetworksProxy: networksModule.layer2Proxy
|
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-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
|
|
|
}
|
|
|
|
|
2023-02-28 15:00:10 +00:00
|
|
|
function switchAccountByAddress(address) {
|
|
|
|
walletSection.switchAccountByAddress(address)
|
|
|
|
}
|
|
|
|
|
2023-03-30 12:55:07 +00:00
|
|
|
function deleteAccount(keyUid, address) {
|
|
|
|
return walletSectionAccounts.deleteAccount(keyUid, 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
|
|
|
}
|
|
|
|
|
2021-10-21 08:22:05 +00:00
|
|
|
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
|
|
|
|
2023-03-06 16:46:32 +00:00
|
|
|
function selectCollectible(address, tokenId) {
|
|
|
|
walletSectionCurrentCollectible.update(address, tokenId)
|
2022-11-22 19:31:07 +00:00
|
|
|
}
|
|
|
|
|
2023-02-28 15:00:10 +00:00
|
|
|
function getNameForSavedWalletAddress(address) {
|
|
|
|
return walletSectionSavedAddresses.getNameByAddress(address)
|
|
|
|
}
|
|
|
|
|
2023-02-20 10:57:45 +00:00
|
|
|
function createOrUpdateSavedAddress(name, address, favourite, chainShortNames, ens) {
|
|
|
|
return walletSectionSavedAddresses.createOrUpdateSavedAddress(name, address, favourite, chainShortNames, ens)
|
2021-12-15 10:08:47 +00:00
|
|
|
}
|
|
|
|
|
2023-02-20 10:57:45 +00:00
|
|
|
function deleteSavedAddress(address, ens) {
|
|
|
|
return walletSectionSavedAddresses.deleteSavedAddress(address, ens)
|
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)
|
|
|
|
}
|
2023-03-22 15:48:44 +00:00
|
|
|
|
|
|
|
function runAddAccountPopup() {
|
2023-03-27 12:49:32 +00:00
|
|
|
walletSection.runAddAccountPopup(false)
|
|
|
|
}
|
|
|
|
|
|
|
|
function runAddWatchOnlyAccountPopup() {
|
|
|
|
walletSection.runAddAccountPopup(true)
|
2023-03-22 15:48:44 +00:00
|
|
|
}
|
2023-03-30 13:00:55 +00:00
|
|
|
|
|
|
|
function runEditAccountPopup(address) {
|
|
|
|
walletSection.runEditAccountPopup(address)
|
|
|
|
}
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|