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