2022-10-17 10:17:25 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
import shared.stores 1.0
|
|
|
|
import "../../../app/AppLayouts/Profile/stores"
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
property CurrenciesStore currencyStore: CurrenciesStore { }
|
|
|
|
property ProfileSectionStore profileSectionStore: ProfileSectionStore {}
|
|
|
|
property var contactStore: profileSectionStore.contactsStore
|
|
|
|
|
|
|
|
property var mainModuleInst: mainModule
|
|
|
|
property var walletSectionTransactionsInst: walletSectionTransactions
|
|
|
|
|
|
|
|
property string locale: localAppSettings.language
|
|
|
|
property string currentCurrency: walletSection.currentCurrency
|
|
|
|
property var allNetworks: networksModule.all
|
|
|
|
property var accounts: walletSectionAccounts.model
|
|
|
|
property var currentAccount: walletSectionCurrent
|
|
|
|
property string signingPhrase: walletSection.signingPhrase
|
|
|
|
property var savedAddressesModel: walletSectionSavedAddresses.model
|
|
|
|
property var disabledChainIdsFromList: []
|
|
|
|
property var disabledChainIdsToList: []
|
|
|
|
|
|
|
|
function addRemoveDisabledFromChain(chainID, isDisabled) {
|
|
|
|
if(isDisabled) {
|
2022-11-23 17:58:22 +00:00
|
|
|
disabledChainIdsFromList.push(chainID)
|
2022-10-17 10:17:25 +00:00
|
|
|
}
|
|
|
|
else {
|
2022-11-23 17:58:22 +00:00
|
|
|
for(var i = 0; i < disabledChainIdsFromList.length;i++) {
|
|
|
|
if(disabledChainIdsFromList[i] === chainID) {
|
|
|
|
disabledChainIdsFromList.splice(i, 1)
|
2022-10-17 10:17:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function addRemoveDisabledToChain(chainID, isDisabled) {
|
|
|
|
if(isDisabled) {
|
2022-11-23 17:58:22 +00:00
|
|
|
root.disabledChainIdsToList.push(chainID)
|
2022-10-17 10:17:25 +00:00
|
|
|
}
|
|
|
|
else {
|
2022-11-23 17:58:22 +00:00
|
|
|
for(var i = 0; i < root.disabledChainIdsToList.length;i++) {
|
|
|
|
if(root.disabledChainIdsToList[i] === chainID) {
|
|
|
|
root.disabledChainIdsToList.splice(i, 1)
|
2022-10-17 10:17:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function getEtherscanLink() {
|
|
|
|
return profileSectionModule.ensUsernamesModule.getEtherscanLink()
|
|
|
|
}
|
|
|
|
|
|
|
|
function copyToClipboard(text) {
|
|
|
|
globalUtils.copyToClipboard(text)
|
|
|
|
}
|
|
|
|
|
|
|
|
function estimateGas(from_addr, to, assetSymbol, value, chainId, data) {
|
|
|
|
return walletSectionTransactions.estimateGas(from_addr, to, assetSymbol, value, chainId, data)
|
|
|
|
}
|
|
|
|
|
|
|
|
function getFiatValue(balance, cryptoSymbol, fiatSymbol) {
|
|
|
|
return profileSectionStore.ensUsernamesStore.getFiatValue(balance, cryptoSymbol, fiatSymbol)
|
|
|
|
}
|
|
|
|
|
|
|
|
function getGasEthValue(gweiValue, gasLimit) {
|
|
|
|
return profileSectionStore.ensUsernamesStore.getGasEthValue(gweiValue, gasLimit)
|
|
|
|
}
|
|
|
|
|
|
|
|
function authenticateAndTransfer(from, to, tokenSymbol, amount, uuid, priority, selectedRoutes) {
|
|
|
|
walletSectionTransactions.authenticateAndTransfer(from, to, tokenSymbol, amount, uuid, priority, selectedRoutes)
|
|
|
|
}
|
|
|
|
|
|
|
|
function suggestedFees(chainId) {
|
|
|
|
return JSON.parse(walletSectionTransactions.suggestedFees(chainId))
|
|
|
|
}
|
|
|
|
|
|
|
|
function getEstimatedTime(chainId, maxFeePerGas) {
|
|
|
|
return walletSectionTransactions.getEstimatedTime(chainId, maxFeePerGas)
|
|
|
|
}
|
|
|
|
|
|
|
|
function getChainIdForChat() {
|
|
|
|
return walletSectionTransactions.getChainIdForChat()
|
|
|
|
}
|
|
|
|
|
|
|
|
function getChainIdForBrowser() {
|
|
|
|
return walletSectionTransactions.getChainIdForBrowser()
|
|
|
|
}
|
|
|
|
|
|
|
|
function suggestedRoutes(account, amount, token, disabledFromChainIDs, disabledToChainIDs, preferredChainIds, priority, sendType) {
|
|
|
|
walletSectionTransactions.suggestedRoutes(account, amount, token, disabledFromChainIDs, disabledToChainIDs, preferredChainIds, priority, sendType)
|
|
|
|
}
|
|
|
|
|
|
|
|
function hex2Eth(value) {
|
|
|
|
return globalUtils.hex2Eth(value)
|
|
|
|
}
|
|
|
|
|
|
|
|
function switchAccount(newIndex) {
|
|
|
|
if(Constants.isCppApp)
|
|
|
|
walletSectionAccounts.switchAccount(newIndex)
|
|
|
|
else
|
|
|
|
walletSection.switchAccount(newIndex)
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2022-11-15 11:22:03 +00:00
|
|
|
function getEth2Wei(eth, decimals) {
|
|
|
|
return globalUtils.eth2Wei(eth, decimals)
|
2022-10-17 10:17:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function plainText(text) {
|
|
|
|
return globalUtils.plainText(text)
|
|
|
|
}
|
2022-12-01 15:48:44 +00:00
|
|
|
|
|
|
|
property var preferredChainIds: []
|
|
|
|
|
|
|
|
function addPreferredChain(chainID) {
|
|
|
|
if(!chainID)
|
|
|
|
return
|
|
|
|
|
|
|
|
if(preferredChainIds.includes(chainID))
|
|
|
|
return
|
|
|
|
|
|
|
|
preferredChainIds.push(chainID)
|
|
|
|
}
|
|
|
|
|
|
|
|
function getMainnetChainId() {
|
|
|
|
return networksModule.getMainnetChainId()
|
|
|
|
}
|
|
|
|
|
|
|
|
function addUnpreferredChainsToDisabledChains() {
|
|
|
|
let mainnetChainId = getMainnetChainId()
|
|
|
|
for(var i = 0; i < allNetworks.count; i++) {
|
|
|
|
let chainId = allNetworks.rowData(i, "chainId") * 1
|
|
|
|
if(mainnetChainId !== chainId) {
|
|
|
|
addRemoveDisabledToChain(chainId, true)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-10-17 10:17:25 +00:00
|
|
|
}
|