2022-10-17 12:17:25 +02:00
|
|
|
import QtQuick 2.13
|
|
|
|
|
2023-08-15 20:21:51 +02:00
|
|
|
import SortFilterProxyModel 0.2
|
2022-10-17 12:17:25 +02:00
|
|
|
|
|
|
|
import shared.stores 1.0
|
2023-08-15 20:21:51 +02:00
|
|
|
|
|
|
|
import utils 1.0
|
2022-10-17 12:17:25 +02:00
|
|
|
|
2024-01-30 14:15:58 +01:00
|
|
|
import StatusQ 0.1
|
2023-09-11 07:20:36 -03:00
|
|
|
import StatusQ.Core.Utils 0.1
|
|
|
|
|
2023-11-28 20:16:18 +01:00
|
|
|
import AppLayouts.Wallet.stores 1.0
|
|
|
|
|
2022-10-17 12:17:25 +02:00
|
|
|
QtObject {
|
|
|
|
id: root
|
|
|
|
|
2024-05-28 19:39:41 +02:00
|
|
|
property CurrenciesStore currencyStore
|
2023-11-28 20:16:18 +01:00
|
|
|
property WalletAssetsStore walletAssetStore
|
2024-01-30 14:15:58 +01:00
|
|
|
property TokensStore tokensStore
|
2022-10-17 12:17:25 +02:00
|
|
|
|
|
|
|
property var mainModuleInst: mainModule
|
2023-04-20 10:41:45 +02:00
|
|
|
property var walletSectionSendInst: walletSectionSend
|
2022-10-17 12:17:25 +02:00
|
|
|
|
2024-07-03 05:55:05 +02:00
|
|
|
readonly property var accounts: walletSectionAccounts.accounts
|
|
|
|
|
2024-03-13 18:38:16 +01:00
|
|
|
property var flatNetworksModel: networksModule.flatNetworks
|
2024-07-03 10:51:15 +02:00
|
|
|
readonly property var fromNetworksRouteModel: walletSectionSendInst.fromNetworksRouteModel
|
|
|
|
readonly property var toNetworksRouteModel: walletSectionSendInst.toNetworksRouteModel
|
2024-07-03 05:55:05 +02:00
|
|
|
readonly property string selectedReceiverAccountAddress: walletSectionSendInst.selectedReceiveAccountAddress
|
|
|
|
readonly property string selectedSenderAccountAddress: walletSectionSendInst.selectedSenderAccountAddress
|
2023-07-21 10:41:24 +02:00
|
|
|
property bool areTestNetworksEnabled: networksModule.areTestNetworksEnabled
|
2024-02-25 23:32:59 -03:00
|
|
|
property var tmpActivityController0: walletSection.tmpActivityController0
|
2024-07-02 13:19:37 +02:00
|
|
|
readonly property var _tmpActivityController1: walletSection.tmpActivityController1
|
|
|
|
readonly property var tempActivityController1Model: _tmpActivityController1.model
|
2023-04-18 18:05:24 +02:00
|
|
|
property var savedAddressesModel: SortFilterProxyModel {
|
|
|
|
sourceModel: walletSectionSavedAddresses.model
|
|
|
|
filters: [
|
|
|
|
ValueFilter {
|
|
|
|
roleName: "isTest"
|
2023-07-21 10:41:24 +02:00
|
|
|
value: areTestNetworksEnabled
|
2023-04-18 18:05:24 +02:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
2024-02-05 17:44:49 +01:00
|
|
|
property string selectedAssetKey: walletSectionSendInst.selectedAssetKey
|
2023-08-15 20:21:51 +02:00
|
|
|
property bool showUnPreferredChains: walletSectionSendInst.showUnPreferredChains
|
2023-09-20 18:07:09 +02: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 12:17:25 +02:00
|
|
|
|
2024-10-30 09:14:52 +01:00
|
|
|
function getEtherscanTxLink(chainID) {
|
|
|
|
return networksModule.getBlockExplorerTxURL(chainID)
|
2022-10-17 12:17:25 +02:00
|
|
|
}
|
|
|
|
|
2024-09-13 13:39:12 +02:00
|
|
|
function authenticateAndTransfer(uuid, slippagePercentage = "") {
|
|
|
|
walletSectionSendInst.authenticateAndTransfer(uuid, slippagePercentage)
|
2022-10-17 12:17:25 +02:00
|
|
|
}
|
|
|
|
|
2024-09-13 13:39:12 +02:00
|
|
|
function suggestedRoutes(uuid, amountIn, amountOut = "0", extraParamsJson = "") {
|
2024-06-26 01:03:19 +02:00
|
|
|
const valueIn = AmountsArithmetic.fromNumber(amountIn)
|
|
|
|
const valueOut = AmountsArithmetic.fromNumber(amountOut)
|
2024-09-13 13:39:12 +02:00
|
|
|
walletSectionSendInst.suggestedRoutes(uuid, valueIn.toFixed(), valueOut.toFixed(), extraParamsJson)
|
2022-10-17 12:17:25 +02:00
|
|
|
}
|
|
|
|
|
2024-08-30 11:16:40 +02:00
|
|
|
function stopUpdatesForSuggestedRoute() {
|
|
|
|
walletSectionSendInst.stopUpdatesForSuggestedRoute()
|
|
|
|
}
|
|
|
|
|
2022-10-17 12:17:25 +02:00
|
|
|
function resolveENS(value) {
|
|
|
|
mainModuleInst.resolveENS(value, "")
|
|
|
|
}
|
|
|
|
|
2022-11-15 12:22:03 +01:00
|
|
|
function getWei2Eth(wei, decimals) {
|
|
|
|
return globalUtils.wei2Eth(wei, decimals)
|
2022-10-17 12:17:25 +02:00
|
|
|
}
|
|
|
|
|
2023-04-07 12:34:01 +02:00
|
|
|
function getAsset(assetsList, symbol) {
|
2023-11-28 20:16:18 +01:00
|
|
|
for(var i=0; i< assetsList.rowCount();i++) {
|
2024-01-30 14:15:58 +01:00
|
|
|
let asset = assetsList.get(i)
|
2023-11-28 20:16:18 +01:00
|
|
|
if(symbol === asset.symbol) {
|
2024-01-30 14:15:58 +01:00
|
|
|
return asset
|
2023-09-12 16:26:38 +02:00
|
|
|
}
|
2023-04-07 12:34:01 +02:00
|
|
|
}
|
|
|
|
return {}
|
|
|
|
}
|
2023-04-18 18:05:24 +02:00
|
|
|
|
2024-07-03 05:55:05 +02:00
|
|
|
function setSenderAccount(address) {
|
|
|
|
walletSectionSendInst.setSenderAccount(address)
|
|
|
|
}
|
|
|
|
|
|
|
|
function setReceiverAccount(address) {
|
|
|
|
walletSectionSendInst.setReceiverAccount(address)
|
2023-04-24 20:35:34 +02:00
|
|
|
}
|
2023-07-21 10:41:24 +02:00
|
|
|
|
2023-08-15 20:21:51 +02:00
|
|
|
function toggleFromDisabledChains(chainId) {
|
2024-07-03 10:51:15 +02:00
|
|
|
walletSectionSendInst.fromNetworksRouteModel.toggleRouteDisabledChains(chainId)
|
2023-08-15 20:21:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function toggleToDisabledChains(chainId) {
|
2024-07-03 10:51:15 +02:00
|
|
|
walletSectionSendInst.toNetworksRouteModel.toggleRouteDisabledChains(chainId)
|
2023-08-15 20:21:51 +02:00
|
|
|
}
|
|
|
|
|
2023-08-31 12:27:15 +02:00
|
|
|
function setRouteDisabledChains(chainId, disabled) {
|
2024-07-03 10:51:15 +02:00
|
|
|
walletSectionSendInst.toNetworksRouteModel.setRouteDisabledChains(chainId, disabled)
|
2023-08-31 12:27:15 +02:00
|
|
|
}
|
|
|
|
|
2023-11-24 09:48:50 +01:00
|
|
|
function setSelectedTokenName(tokenName) {
|
|
|
|
walletSectionSendInst.setSelectedTokenName(tokenName)
|
|
|
|
}
|
|
|
|
|
|
|
|
function setSelectedTokenIsOwnerToken(isOwnerToken) {
|
|
|
|
walletSectionSendInst.setSelectedTokenIsOwnerToken(isOwnerToken)
|
|
|
|
}
|
|
|
|
|
2023-08-31 12:27:15 +02:00
|
|
|
function setRouteEnabledFromChains(chainId) {
|
2024-07-03 10:51:15 +02:00
|
|
|
walletSectionSendInst.fromNetworksRouteModel.setRouteEnabledFromChains(chainId)
|
2023-08-15 20:21:51 +02:00
|
|
|
}
|
|
|
|
|
2024-02-05 17:44:49 +01:00
|
|
|
function setSelectedAssetKey(assetsKey) {
|
|
|
|
walletSectionSendInst.setSelectedAssetKey(assetsKey)
|
2023-08-15 20:21:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function getNetworkName(chainId) {
|
2024-07-03 10:51:15 +02:00
|
|
|
return ModelUtils.getByKey(root.flatNetworksModel, "chainId", chainId, "chainName")
|
2023-08-15 20:21:51 +02:00
|
|
|
}
|
|
|
|
|
2023-08-31 12:27:15 +02:00
|
|
|
function updateRoutePreferredChains(chainIds) {
|
2024-06-12 22:43:08 +02:00
|
|
|
walletSectionSendInst.updateRoutePreferredChains(chainIds)
|
2023-08-15 20:21:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function toggleShowUnPreferredChains() {
|
|
|
|
walletSectionSendInst.toggleShowUnPreferredChains()
|
|
|
|
}
|
|
|
|
|
2023-08-31 12:27:15 +02:00
|
|
|
function setAllNetworksAsRoutePreferredChains() {
|
2024-07-03 10:51:15 +02:00
|
|
|
walletSectionSendInst.toNetworksRouteModel.setAllNetworksAsRoutePreferredChains()
|
2023-08-15 20:21:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function lockCard(chainId, amount, lock) {
|
2024-07-03 10:51:15 +02:00
|
|
|
walletSectionSendInst.fromNetworksRouteModel.lockCard(chainId, amount, lock)
|
2023-08-15 20:21:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function resetStoredProperties() {
|
|
|
|
walletSectionSendInst.resetStoredProperties()
|
|
|
|
}
|
|
|
|
|
2023-08-31 12:27:15 +02:00
|
|
|
function splitAndFormatAddressPrefix(text, updateInStore) {
|
2023-08-15 20:21:51 +02:00
|
|
|
return {
|
2023-09-19 17:06:57 +02:00
|
|
|
formattedText: walletSectionSendInst.splitAndFormatAddressPrefix(text, updateInStore),
|
|
|
|
address: walletSectionSendInst.getAddressFromFormattedString(text)
|
2023-08-15 20:21:51 +02:00
|
|
|
}
|
|
|
|
}
|
2023-09-19 17:06:57 +02:00
|
|
|
|
2024-06-12 22:43:08 +02:00
|
|
|
function formatCurrencyAmountFromBigInt(balance, symbol, decimals, options = null) {
|
|
|
|
return currencyStore.formatCurrencyAmountFromBigInt(balance, symbol, decimals, options)
|
2024-01-30 14:15:58 +01:00
|
|
|
}
|
2024-07-02 13:19:37 +02:00
|
|
|
|
2024-07-17 17:49:42 +03:00
|
|
|
function updateRecentRecipientsActivity(accountAddress) {
|
|
|
|
if(!!accountAddress) {
|
|
|
|
_tmpActivityController1.setFilterAddressesJson(JSON.stringify([accountAddress]),
|
2024-07-02 13:19:37 +02:00
|
|
|
false)
|
|
|
|
}
|
|
|
|
_tmpActivityController1.updateFilter()
|
|
|
|
}
|
2022-10-17 12:17:25 +02:00
|
|
|
}
|