2022-10-17 10:17:25 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
|
2023-08-15 18:21:51 +00:00
|
|
|
import SortFilterProxyModel 0.2
|
2022-10-17 10:17:25 +00:00
|
|
|
|
|
|
|
import shared.stores 1.0
|
2023-08-15 18:21:51 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2022-10-17 10:17:25 +00:00
|
|
|
|
2023-09-11 10:20:36 +00:00
|
|
|
import StatusQ.Core.Utils 0.1
|
|
|
|
|
2022-10-17 10:17:25 +00:00
|
|
|
QtObject {
|
|
|
|
id: root
|
|
|
|
|
2022-12-29 16:44:51 +00:00
|
|
|
property CurrenciesStore currencyStore: CurrenciesStore {}
|
2022-10-17 10:17:25 +00:00
|
|
|
|
|
|
|
property var mainModuleInst: mainModule
|
2023-04-20 08:41:45 +00:00
|
|
|
property var walletSectionSendInst: walletSectionSend
|
2022-10-17 10:17:25 +00:00
|
|
|
|
2023-09-12 14:26:38 +00:00
|
|
|
property var assets: walletSectionAssets.assets
|
2023-08-15 18:21:51 +00:00
|
|
|
property var fromNetworksModel: walletSectionSendInst.fromNetworksModel
|
|
|
|
property var toNetworksModel: walletSectionSendInst.toNetworksModel
|
2023-05-04 12:55:39 +00:00
|
|
|
property var senderAccounts: walletSectionSendInst.senderAccounts
|
|
|
|
property var selectedSenderAccount: walletSectionSendInst.selectedSenderAccount
|
2023-08-15 18:21:51 +00:00
|
|
|
property var accounts: walletSectionSendInst.accounts
|
2023-09-11 10:20:36 +00:00
|
|
|
property var collectiblesModel: walletSectionSendInst.collectiblesModel
|
|
|
|
property var nestedCollectiblesModel: walletSectionSendInst.nestedCollectiblesModel
|
2023-07-21 08:41:24 +00:00
|
|
|
property bool areTestNetworksEnabled: networksModule.areTestNetworksEnabled
|
2023-08-15 18:21:51 +00:00
|
|
|
property var tmpActivityController: walletSection.tmpActivityController
|
2023-04-18 16:05:24 +00:00
|
|
|
property var savedAddressesModel: SortFilterProxyModel {
|
|
|
|
sourceModel: walletSectionSavedAddresses.model
|
|
|
|
filters: [
|
|
|
|
ValueFilter {
|
|
|
|
roleName: "isTest"
|
2023-07-21 08:41:24 +00:00
|
|
|
value: areTestNetworksEnabled
|
2023-04-18 16:05:24 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
2023-08-15 18:21:51 +00:00
|
|
|
property string selectedAssetSymbol: walletSectionSendInst.selectedAssetSymbol
|
|
|
|
property bool showUnPreferredChains: walletSectionSendInst.showUnPreferredChains
|
2023-09-20 16:07:09 +00:00
|
|
|
property int sendType: walletSectionSendInst.sendType
|
|
|
|
property string selectedRecipient: walletSectionSendInst.selectedRecipient
|
|
|
|
|
|
|
|
function setSendType(sendType) {
|
|
|
|
walletSectionSendInst.setSendType(sendType)
|
|
|
|
}
|
|
|
|
|
|
|
|
function setSelectedRecipient(recipientAddress) {
|
|
|
|
walletSectionSendInst.setSelectedRecipient(recipientAddress)
|
|
|
|
}
|
2022-10-17 10:17:25 +00:00
|
|
|
|
2022-12-08 15:56:02 +00:00
|
|
|
function getEtherscanLink(chainID) {
|
|
|
|
return networksModule.all.getBlockExplorerURL(chainID)
|
2022-10-17 10:17:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function copyToClipboard(text) {
|
|
|
|
globalUtils.copyToClipboard(text)
|
|
|
|
}
|
|
|
|
|
2023-09-20 16:07:09 +00:00
|
|
|
function authenticateAndTransfer(amount, uuid) {
|
|
|
|
walletSectionSendInst.authenticateAndTransfer(amount, uuid)
|
2022-10-17 10:17:25 +00:00
|
|
|
}
|
|
|
|
|
2023-09-20 16:07:09 +00:00
|
|
|
function suggestedRoutes(amount) {
|
|
|
|
walletSectionSendInst.suggestedRoutes(amount)
|
2022-10-17 10:17:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function resolveENS(value) {
|
|
|
|
mainModuleInst.resolveENS(value, "")
|
|
|
|
}
|
|
|
|
|
2022-11-15 11:22:03 +00:00
|
|
|
function getWei2Eth(wei, decimals) {
|
|
|
|
return globalUtils.wei2Eth(wei, decimals)
|
2022-10-17 10:17:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function plainText(text) {
|
|
|
|
return globalUtils.plainText(text)
|
|
|
|
}
|
2022-12-01 15:48:44 +00:00
|
|
|
|
2022-11-30 12:59:21 +00:00
|
|
|
enum EstimatedTime {
|
|
|
|
Unknown = 0,
|
|
|
|
LessThanOneMin,
|
|
|
|
LessThanThreeMins,
|
|
|
|
LessThanFiveMins,
|
|
|
|
MoreThanFiveMins
|
|
|
|
}
|
|
|
|
|
|
|
|
function getLabelForEstimatedTxTime(estimatedFlag) {
|
|
|
|
switch(estimatedFlag) {
|
|
|
|
case TransactionStore.EstimatedTime.Unknown:
|
|
|
|
return qsTr("~ Unknown")
|
|
|
|
case TransactionStore.EstimatedTime.LessThanOneMin :
|
|
|
|
return qsTr("< 1 minute")
|
|
|
|
case TransactionStore.EstimatedTime.LessThanThreeMins :
|
|
|
|
return qsTr("< 3 minutes")
|
|
|
|
case TransactionStore.EstimatedTime.LessThanFiveMins:
|
|
|
|
return qsTr("< 5 minutes")
|
|
|
|
default:
|
|
|
|
return qsTr("> 5 minutes")
|
|
|
|
}
|
|
|
|
}
|
2022-11-25 09:13:02 +00:00
|
|
|
|
2023-04-06 12:59:24 +00:00
|
|
|
function findTokenSymbolByAddress(address) {
|
|
|
|
if (Global.appIsReady)
|
|
|
|
return walletSectionAllTokens.findTokenSymbolByAddress(address)
|
|
|
|
return ""
|
|
|
|
}
|
2023-04-07 10:34:01 +00:00
|
|
|
|
|
|
|
function getAsset(assetsList, symbol) {
|
|
|
|
for(var i=0; i< assetsList.count;i++) {
|
2023-09-12 14:26:38 +00:00
|
|
|
if(symbol === assetsList.rowData(i, "symbol")) {
|
2023-04-07 10:34:01 +00:00
|
|
|
return {
|
|
|
|
name: assetsList.rowData(i, "name"),
|
|
|
|
symbol: assetsList.rowData(i, "symbol"),
|
|
|
|
totalBalance: JSON.parse(assetsList.rowData(i, "totalBalance")),
|
|
|
|
totalCurrencyBalance: JSON.parse(assetsList.rowData(i, "totalCurrencyBalance")),
|
|
|
|
balances: assetsList.rowData(i, "balances"),
|
|
|
|
decimals: assetsList.rowData(i, "decimals")
|
|
|
|
}
|
2023-09-12 14:26:38 +00:00
|
|
|
}
|
2023-04-07 10:34:01 +00:00
|
|
|
}
|
|
|
|
return {}
|
|
|
|
}
|
2023-04-18 16:05:24 +00:00
|
|
|
|
2023-09-11 10:20:36 +00:00
|
|
|
function getCollectible(uid) {
|
|
|
|
const idx = ModelUtils.indexOf(collectiblesModel, "uid", uid)
|
|
|
|
if (idx < 0) {
|
|
|
|
return {}
|
|
|
|
}
|
|
|
|
return ModelUtils.get(collectiblesModel, idx)
|
|
|
|
}
|
|
|
|
|
|
|
|
function getSelectorCollectible(uid) {
|
|
|
|
const idx = ModelUtils.indexOf(nestedCollectiblesModel, "uid", uid)
|
|
|
|
if (idx < 0) {
|
|
|
|
return {}
|
|
|
|
}
|
|
|
|
return ModelUtils.get(nestedCollectiblesModel, idx)
|
|
|
|
}
|
|
|
|
|
|
|
|
function getHolding(holdingId, holdingType) {
|
|
|
|
if (holdingType === Constants.HoldingType.Asset) {
|
|
|
|
return getAsset(selectedSenderAccount.assets, holdingId)
|
|
|
|
} else if (holdingType === Constants.HoldingType.Collectible) {
|
|
|
|
return getCollectible(holdingId)
|
|
|
|
} else {
|
|
|
|
return {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function getSelectorHolding(holdingId, holdingType) {
|
|
|
|
if (holdingType === Constants.HoldingType.Asset) {
|
|
|
|
return getAsset(selectedSenderAccount.assets, holdingId)
|
|
|
|
} else if (holdingType === Constants.HoldingType.Collectible) {
|
|
|
|
return getSelectorCollectible(holdingId)
|
|
|
|
} else {
|
|
|
|
return {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function assetToSelectorAsset(asset) {
|
|
|
|
return asset
|
|
|
|
}
|
|
|
|
|
|
|
|
function collectibleToSelectorCollectible(collectible) {
|
|
|
|
return {
|
|
|
|
uid: collectible.uid,
|
|
|
|
chainId: collectible.chainId,
|
|
|
|
name: collectible.name,
|
|
|
|
iconUrl: collectible.imageUrl,
|
|
|
|
collectionUid: collectible.collectionUid,
|
|
|
|
collectionName: collectible.collectionName,
|
|
|
|
isCollection: false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function holdingToSelectorHolding(holding, holdingType) {
|
|
|
|
if (holdingType === Constants.HoldingType.Asset) {
|
|
|
|
return assetToSelectorAsset(holding)
|
|
|
|
} else if (holdingType === Constants.HoldingType.Collectible) {
|
|
|
|
return collectibleToSelectorCollectible(holding)
|
|
|
|
} else {
|
|
|
|
return {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-04 12:55:39 +00:00
|
|
|
function switchSenderAccount(index) {
|
|
|
|
walletSectionSendInst.switchSenderAccount(index)
|
2023-04-24 18:35:34 +00:00
|
|
|
}
|
2023-07-21 08:41:24 +00:00
|
|
|
|
|
|
|
function getNetworkShortNames(chainIds) {
|
|
|
|
return networksModule.getNetworkShortNames(chainIds)
|
|
|
|
}
|
2023-08-15 18:21:51 +00:00
|
|
|
|
|
|
|
function toggleFromDisabledChains(chainId) {
|
2023-08-31 10:27:15 +00:00
|
|
|
fromNetworksModel.toggleRouteDisabledChains(chainId)
|
2023-08-15 18:21:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function toggleToDisabledChains(chainId) {
|
2023-08-31 10:27:15 +00:00
|
|
|
toNetworksModel.toggleRouteDisabledChains(chainId)
|
2023-08-15 18:21:51 +00:00
|
|
|
}
|
|
|
|
|
2023-08-31 10:27:15 +00:00
|
|
|
function setRouteDisabledChains(chainId, disabled) {
|
|
|
|
toNetworksModel.setRouteDisabledChains(chainId, disabled)
|
|
|
|
}
|
|
|
|
|
|
|
|
function setRouteEnabledFromChains(chainId) {
|
|
|
|
fromNetworksModel.setRouteEnabledFromChains(chainId)
|
2023-08-15 18:21:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function setSelectedAssetSymbol(symbol) {
|
|
|
|
walletSectionSendInst.setSelectedAssetSymbol(symbol)
|
|
|
|
}
|
|
|
|
|
|
|
|
function getNetworkName(chainId) {
|
|
|
|
return fromNetworksModel.getNetworkName(chainId)
|
|
|
|
}
|
|
|
|
|
2023-08-31 10:27:15 +00:00
|
|
|
function updateRoutePreferredChains(chainIds) {
|
|
|
|
walletSectionSendInst.updateRoutePreferredChains(chainIds)
|
2023-08-15 18:21:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function toggleShowUnPreferredChains() {
|
|
|
|
walletSectionSendInst.toggleShowUnPreferredChains()
|
|
|
|
}
|
|
|
|
|
2023-08-31 10:27:15 +00:00
|
|
|
function setAllNetworksAsRoutePreferredChains() {
|
|
|
|
toNetworksModel.setAllNetworksAsRoutePreferredChains()
|
2023-08-15 18:21:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function lockCard(chainId, amount, lock) {
|
|
|
|
fromNetworksModel.lockCard(chainId, amount, lock)
|
|
|
|
}
|
|
|
|
|
|
|
|
function resetStoredProperties() {
|
|
|
|
walletSectionSendInst.resetStoredProperties()
|
2023-09-12 14:26:38 +00:00
|
|
|
nestedCollectiblesModel.currentCollectionUid = ""
|
2023-08-15 18:21:51 +00:00
|
|
|
}
|
|
|
|
|
2023-08-31 10:27:15 +00:00
|
|
|
function splitAndFormatAddressPrefix(text, updateInStore) {
|
2023-08-15 18:21:51 +00:00
|
|
|
return {
|
2023-09-19 15:06:57 +00:00
|
|
|
formattedText: walletSectionSendInst.splitAndFormatAddressPrefix(text, updateInStore),
|
|
|
|
address: walletSectionSendInst.getAddressFromFormattedString(text)
|
2023-08-15 18:21:51 +00:00
|
|
|
}
|
|
|
|
}
|
2023-09-19 15:06:57 +00:00
|
|
|
|
|
|
|
function getShortChainIds(chainShortNames) {
|
|
|
|
return walletSectionSendInst.getShortChainIds(chainShortNames)
|
|
|
|
}
|
2023-09-26 13:45:44 +00:00
|
|
|
|
|
|
|
function getNetworkIcon(chainId) {
|
|
|
|
return walletSectionSendInst.getIconUrl(chainId)
|
|
|
|
}
|
2022-10-17 10:17:25 +00:00
|
|
|
}
|