2023-09-27 13:41:55 +00:00
|
|
|
pragma Singleton
|
|
|
|
|
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQml 2.15
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
import shared.stores 1.0
|
|
|
|
import shared.stores.send 1.0
|
|
|
|
import AppLayouts.Wallet.stores 1.0 as WalletStores
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
|
|
|
|
import "./panels"
|
|
|
|
import "./controls"
|
|
|
|
import "./views"
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
function createSendModalRequirements() {
|
|
|
|
return {
|
|
|
|
preSelectedAccount: null,
|
|
|
|
preSelectedRecipientType: TabAddressSelectorView.Type.Address,
|
|
|
|
preSelectedRecipient: null,
|
2023-11-07 22:45:47 +00:00
|
|
|
preSelectedHoldingType: Constants.TokenType.Unknown,
|
2023-09-27 13:41:55 +00:00
|
|
|
preSelectedHolding: null,
|
|
|
|
preSelectedHoldingID: "",
|
|
|
|
preDefinedAmountToSend: "",
|
|
|
|
preSelectedSendType: Constants.SendType.Transfer
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// \c token is an collectible object in case of \c isCollectible == true otherwise a token code (e.g. "ETH")
|
|
|
|
function lookupAddressesForSendModal(senderAddress, recipientAddress, token, isCollectible, amount) {
|
|
|
|
let req = createSendModalRequirements()
|
|
|
|
|
|
|
|
req.preSelectedSendType = Constants.SendType.Transfer
|
|
|
|
let senderAccount = null
|
|
|
|
let resolvedAcc = WalletStores.RootStore.lookupAddressObject(senderAddress)
|
|
|
|
if (resolvedAcc && resolvedAcc.type == WalletStores.RootStore.LookupType.Account) {
|
|
|
|
req.preSelectedAccount = resolvedAcc.object
|
|
|
|
}
|
|
|
|
|
|
|
|
let res = WalletStores.RootStore.lookupAddressObject(recipientAddress)
|
|
|
|
if (res) {
|
|
|
|
if (res.type == WalletStores.RootStore.LookupType.Account) {
|
|
|
|
req.preSelectedRecipientType = TabAddressSelectorView.Type.Account
|
|
|
|
req.preSelectedRecipient = res.object
|
|
|
|
} else if (res.type == WalletStores.RootStore.LookupType.SavedAddress) {
|
|
|
|
req.preSelectedRecipientType = TabAddressSelectorView.Type.SavedAddress
|
|
|
|
req.preSelectedRecipient = res.object
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
req.preSelectedRecipientType = TabAddressSelectorView.Type.Address
|
|
|
|
req.preSelectedRecipient = recipientAddress
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isCollectible) {
|
2023-11-07 22:45:47 +00:00
|
|
|
req.preSelectedHoldingType = Constants.TokenType.ERC721
|
2023-09-27 13:41:55 +00:00
|
|
|
req.preSelectedHolding = token
|
|
|
|
} else {
|
2023-11-07 22:45:47 +00:00
|
|
|
req.preSelectedHoldingType = Constants.TokenType.ERC20
|
2023-09-27 13:41:55 +00:00
|
|
|
req.preSelectedHoldingID = token
|
|
|
|
}
|
|
|
|
|
|
|
|
req.preDefinedAmountToSend = LocaleUtils.numberToLocaleString(amount)
|
|
|
|
|
|
|
|
return req
|
|
|
|
}
|
2024-02-20 07:43:31 +00:00
|
|
|
|
|
|
|
function assetsSectionTitle(sectionNeeded, hasCommunityTokens, isInsideCollection, isERC20List) {
|
|
|
|
let title = ""
|
|
|
|
if (!isInsideCollection) {
|
|
|
|
if (sectionNeeded) {
|
|
|
|
title = qsTr("Community minted")
|
|
|
|
} else {
|
|
|
|
if (!isERC20List) {
|
|
|
|
// Show "Other" only if there are "Community minted" tokens on the list
|
|
|
|
if (hasCommunityTokens) {
|
|
|
|
title = qsTr("Other")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return title
|
|
|
|
}
|
|
|
|
|
|
|
|
function modelHasCommunityTokens(model, isERC20List) {
|
|
|
|
if (model.count > 0) {
|
|
|
|
let item
|
|
|
|
if (isERC20List) {
|
|
|
|
item = model.get(model.count - 1)
|
|
|
|
} else {
|
|
|
|
item = model.get(0)
|
|
|
|
}
|
|
|
|
return item.isCommunityAsset
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
2023-11-07 22:45:47 +00:00
|
|
|
}
|