2021-12-08 21:20:43 +00:00
|
|
|
pragma Singleton
|
|
|
|
|
|
|
|
import QtQuick 2.12
|
2023-02-14 09:20:53 +00:00
|
|
|
import utils 1.0
|
2021-12-08 21:20:43 +00:00
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: root
|
2022-01-26 10:36:37 +00:00
|
|
|
|
2022-03-07 22:59:38 +00:00
|
|
|
property var profileSectionModuleInst: profileSectionModule
|
|
|
|
property var privacyModule: profileSectionModuleInst.privacyModule
|
2023-02-14 09:20:53 +00:00
|
|
|
property var userProfileInst: !!Global.userProfile? Global.userProfile : null
|
|
|
|
property var walletSectionInst: Global.appIsReady && !!walletSection? walletSection : null
|
|
|
|
property var appSettingsInst: Global.appIsReady && !!appSettings? appSettings : null
|
|
|
|
property var accountSensitiveSettings: Global.appIsReady && !!localAccountSensitiveSettings? localAccountSensitiveSettings : null
|
2022-12-08 15:49:14 +00:00
|
|
|
property real volume: !!appSettingsInst ? appSettingsInst.volume * 0.01 : 0.5
|
2023-03-17 11:39:50 +00:00
|
|
|
property bool isWalletEnabled: Global.appIsReady? mainModule.sectionsModel.getItemEnabledBySectionType(Constants.appSection.wallet) : true
|
2023-03-15 13:35:03 +00:00
|
|
|
|
2022-12-08 15:49:14 +00:00
|
|
|
property bool notificationSoundsEnabled: !!appSettingsInst ? appSettingsInst.notificationSoundsEnabled : true
|
2021-12-08 21:20:43 +00:00
|
|
|
property bool neverAskAboutUnfurlingAgain: !!accountSensitiveSettings ? accountSensitiveSettings.neverAskAboutUnfurlingAgain : false
|
|
|
|
property bool isGifWidgetEnabled: !!accountSensitiveSettings ? accountSensitiveSettings.isGifWidgetEnabled : false
|
|
|
|
property bool isTenorWarningAccepted: !!accountSensitiveSettings ? accountSensitiveSettings.isTenorWarningAccepted : false
|
|
|
|
property bool displayChatImages: !!accountSensitiveSettings ? accountSensitiveSettings.displayChatImages : false
|
|
|
|
|
2022-12-29 16:44:51 +00:00
|
|
|
property CurrenciesStore currencyStore: CurrenciesStore {}
|
2023-06-29 17:35:18 +00:00
|
|
|
property string currentCurrency: Global.appIsReady? walletSectionInst.currentCurrency : ""
|
|
|
|
|
|
|
|
readonly property var transactionActivityStatus: Global.appIsReady ? walletSectionInst.activityController.status : null
|
|
|
|
|
|
|
|
property var historyTransactions: Global.appIsReady? walletSectionInst.activityController.model : null
|
|
|
|
readonly property bool loadingHistoryTransactions: Global.appIsReady && walletSectionInst.activityController.status.loadingData
|
|
|
|
readonly property bool newDataAvailable: Global.appIsReady && walletSectionInst.activityController.status.newDataAvailable
|
|
|
|
property bool isNonArchivalNode: Global.appIsReady && walletSectionInst.isNonArchivalNode
|
|
|
|
|
2022-09-27 08:30:18 +00:00
|
|
|
property var marketValueStore: TokenMarketValuesStore{}
|
|
|
|
|
2023-07-04 22:29:34 +00:00
|
|
|
function resetFilter() {
|
2023-06-29 17:35:18 +00:00
|
|
|
walletSectionInst.activityController.updateFilter()
|
2023-07-04 22:29:34 +00:00
|
|
|
}
|
|
|
|
|
2022-08-08 21:12:12 +00:00
|
|
|
function getNetworkColor(chainId) {
|
|
|
|
return networksModule.all.getChainColor(chainId)
|
|
|
|
}
|
|
|
|
|
|
|
|
function getNetworkIcon(chainId) {
|
|
|
|
return networksModule.all.getIconUrl(chainId)
|
|
|
|
}
|
|
|
|
|
2022-09-01 15:34:27 +00:00
|
|
|
function getNetworkShortName(chainId) {
|
|
|
|
return networksModule.all.getNetworkShortName(chainId)
|
|
|
|
}
|
|
|
|
|
2023-05-10 11:54:06 +00:00
|
|
|
function getNetworkFullName(chainId) {
|
|
|
|
return networksModule.all.getNetworkFullName(chainId)
|
|
|
|
}
|
|
|
|
|
2023-05-24 06:22:29 +00:00
|
|
|
function getNetworkLayer(chainId) {
|
|
|
|
return networksModule.all.getNetworkLayer(chainId)
|
|
|
|
}
|
|
|
|
|
2022-08-08 21:12:12 +00:00
|
|
|
function getNetworkIconUrl(symbol) {
|
|
|
|
return networksModule.all.getNetworkIconUrl(symbol)
|
|
|
|
}
|
|
|
|
|
|
|
|
function getNetworkName(symbol) {
|
|
|
|
return networksModule.all.getNetworkName(symbol)
|
|
|
|
}
|
2022-03-25 08:46:47 +00:00
|
|
|
|
2022-09-01 15:34:27 +00:00
|
|
|
function hex2Dec(value) {
|
|
|
|
return globalUtils.hex2Dec(value)
|
|
|
|
}
|
|
|
|
|
2021-12-08 21:20:43 +00:00
|
|
|
readonly property var formationChars: (["*", "`", "~"])
|
|
|
|
function getSelectedTextWithFormationChars(messageInputField) {
|
|
|
|
let i = 1
|
|
|
|
let text = ""
|
|
|
|
while (true) {
|
|
|
|
if (messageInputField.selectionStart - i < 0 && messageInputField.selectionEnd + i > messageInputField.length) {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
|
|
|
|
text = messageInputField.getText(messageInputField.selectionStart - i, messageInputField.selectionEnd + i)
|
|
|
|
|
|
|
|
if (!formationChars.includes(text.charAt(0)) ||
|
|
|
|
!formationChars.includes(text.charAt(text.length - 1))) {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
i++
|
|
|
|
}
|
|
|
|
return text
|
|
|
|
}
|
|
|
|
|
|
|
|
function setNeverAskAboutUnfurlingAgain(value) {
|
|
|
|
localAccountSensitiveSettings.neverAskAboutUnfurlingAgain = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
function setIsTenorWarningAccepted(value) {
|
|
|
|
localAccountSensitiveSettings.isTenorWarningAccepted = value;
|
|
|
|
}
|
|
|
|
|
2022-01-24 11:41:55 +00:00
|
|
|
function copyToClipboard(text) {
|
|
|
|
globalUtils.copyToClipboard(text)
|
2021-12-21 20:52:17 +00:00
|
|
|
}
|
2022-01-13 08:58:42 +00:00
|
|
|
|
2022-12-12 20:46:21 +00:00
|
|
|
property var chatSectionChatContentInputAreaInst: typeof chatSectionChatContentInputArea !== "undefined" ? chatSectionChatContentInputArea
|
|
|
|
: null
|
|
|
|
property var gifColumnA: chatSectionChatContentInputAreaInst ? chatSectionChatContentInputArea.gifColumnA
|
|
|
|
: null
|
|
|
|
property var gifColumnB: chatSectionChatContentInputAreaInst ? chatSectionChatContentInputArea.gifColumnB
|
|
|
|
: null
|
|
|
|
property var gifColumnC: chatSectionChatContentInputAreaInst ? chatSectionChatContentInputArea.gifColumnC
|
|
|
|
: null
|
2023-03-20 18:58:20 +00:00
|
|
|
property bool gifLoading: chatSectionChatContentInputAreaInst ? chatSectionChatContentInputArea.gifLoading
|
|
|
|
: false
|
2022-01-13 08:58:42 +00:00
|
|
|
|
|
|
|
function searchGifs(query) {
|
2022-12-12 20:46:21 +00:00
|
|
|
if (chatSectionChatContentInputAreaInst)
|
|
|
|
chatSectionChatContentInputAreaInst.searchGifs(query)
|
2022-01-13 08:58:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function getTrendingsGifs() {
|
2022-12-12 20:46:21 +00:00
|
|
|
if (chatSectionChatContentInputAreaInst)
|
|
|
|
chatSectionChatContentInputAreaInst.getTrendingsGifs()
|
2022-01-13 08:58:42 +00:00
|
|
|
}
|
|
|
|
|
2022-08-31 08:32:08 +00:00
|
|
|
function updateWhitelistedUnfurlingSites(hostname, whitelisted) {
|
|
|
|
// no way to send update notification for individual array entries
|
|
|
|
let settings = localAccountSensitiveSettings.whitelistedUnfurlingSites
|
|
|
|
|
|
|
|
if (!settings)
|
|
|
|
settings = {}
|
|
|
|
|
|
|
|
if (settings[hostname] === whitelisted)
|
|
|
|
return
|
|
|
|
|
|
|
|
settings[hostname] = whitelisted
|
|
|
|
localAccountSensitiveSettings.whitelistedUnfurlingSites = settings
|
|
|
|
if(hostname === "media.tenor.com" && whitelisted === false)
|
|
|
|
RootStore.setIsTenorWarningAccepted(false)
|
|
|
|
}
|
|
|
|
|
2022-01-13 08:58:42 +00:00
|
|
|
function getRecentsGifs() {
|
2022-12-12 20:46:21 +00:00
|
|
|
if (chatSectionChatContentInputAreaInst)
|
|
|
|
chatSectionChatContentInputAreaInst.getRecentsGifs()
|
2022-01-13 08:58:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function getFavoritesGifs() {
|
2022-12-12 20:46:21 +00:00
|
|
|
return chatSectionChatContentInputAreaInst ? chatSectionChatContentInputAreaInst.getFavoritesGifs()
|
|
|
|
: null
|
2022-01-13 08:58:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function isFavorite(id) {
|
2022-12-12 20:46:21 +00:00
|
|
|
return chatSectionChatContentInputAreaInst ? chatSectionChatContentInputAreaInst.isFavorite(id)
|
|
|
|
: null
|
2022-01-13 08:58:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function toggleFavoriteGif(id, reload) {
|
2022-12-12 20:46:21 +00:00
|
|
|
if (chatSectionChatContentInputAreaInst)
|
|
|
|
chatSectionChatContentInputAreaInst.toggleFavoriteGif(id, reload)
|
2022-01-13 08:58:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function addToRecentsGif(id) {
|
2022-12-12 20:46:21 +00:00
|
|
|
if (chatSectionChatContentInputAreaInst)
|
|
|
|
chatSectionChatContentInputAreaInst.addToRecentsGif(id)
|
2022-01-13 08:58:42 +00:00
|
|
|
}
|
2022-03-07 22:59:38 +00:00
|
|
|
|
2022-07-20 12:34:44 +00:00
|
|
|
function getPasswordStrengthScore(password) {
|
|
|
|
return root.privacyModule.getPasswordStrengthScore(password);
|
2022-03-07 22:59:38 +00:00
|
|
|
}
|
2022-03-25 08:46:47 +00:00
|
|
|
|
2023-06-15 13:09:35 +00:00
|
|
|
function fetchMoreTransactions() {
|
|
|
|
if (RootStore.historyTransactions.count === 0
|
|
|
|
|| !RootStore.historyTransactions.hasMore
|
2023-06-30 13:50:06 +00:00
|
|
|
|| loadingHistoryTransactions)
|
2023-06-15 13:09:35 +00:00
|
|
|
return
|
2023-06-29 17:35:18 +00:00
|
|
|
walletSectionInst.activityController.loadMoreItems()
|
2022-03-25 08:46:47 +00:00
|
|
|
}
|
|
|
|
|
2023-07-07 10:00:19 +00:00
|
|
|
function updateTransactionFilter() {
|
2023-07-21 10:55:36 +00:00
|
|
|
if (transactionActivityStatus.isFilterDirty)
|
2023-06-29 17:35:18 +00:00
|
|
|
walletSectionInst.activityController.updateFilter()
|
2023-07-07 10:00:19 +00:00
|
|
|
}
|
|
|
|
|
2022-03-25 08:46:47 +00:00
|
|
|
function hex2Eth(value) {
|
|
|
|
return globalUtils.hex2Eth(value)
|
|
|
|
}
|
2022-09-01 15:34:27 +00:00
|
|
|
|
2022-09-05 09:15:47 +00:00
|
|
|
function hex2Gwei(value) {
|
|
|
|
return globalUtils.hex2Gwei(value)
|
|
|
|
}
|
|
|
|
|
2022-09-01 15:34:27 +00:00
|
|
|
function findTokenSymbolByAddress(address) {
|
2023-02-14 09:20:53 +00:00
|
|
|
if (Global.appIsReady)
|
|
|
|
return walletSectionAllTokens.findTokenSymbolByAddress(address)
|
|
|
|
return ""
|
2022-09-01 15:34:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function getNameForSavedWalletAddress(address) {
|
|
|
|
return walletSectionSavedAddresses.getNameByAddress(address)
|
|
|
|
}
|
2022-09-05 09:15:47 +00:00
|
|
|
|
2023-02-20 10:57:45 +00:00
|
|
|
function getChainShortNamesForSavedWalletAddress(address) {
|
|
|
|
return walletSectionSavedAddresses.getChainShortNamesForAddress(address)
|
2022-09-05 09:15:47 +00:00
|
|
|
}
|
|
|
|
|
2023-02-20 10:57:45 +00:00
|
|
|
function getEnsForSavedWalletAddress(address) {
|
|
|
|
return walletSectionSavedAddresses.getEnsForAddress(address)
|
|
|
|
}
|
|
|
|
|
|
|
|
function createOrUpdateSavedAddress(name, address, favourite, chainShortNames, ens) {
|
|
|
|
return walletSectionSavedAddresses.createOrUpdateSavedAddress(name, address, favourite, chainShortNames, ens)
|
|
|
|
}
|
|
|
|
|
|
|
|
function deleteSavedAddress(addresse, ens) {
|
|
|
|
return walletSectionSavedAddresses.deleteSavedAddress(address, ens)
|
2022-09-05 09:15:47 +00:00
|
|
|
}
|
|
|
|
|
2023-01-08 22:23:51 +00:00
|
|
|
function getCurrencyAmount(amount, symbol) {
|
|
|
|
return currencyStore.getCurrencyAmount(amount, symbol)
|
|
|
|
}
|
|
|
|
|
|
|
|
function getFiatValue(balance, cryptoSymbol, fiatSymbol) {
|
|
|
|
return currencyStore.getFiatValue(balance, cryptoSymbol, fiatSymbol)
|
|
|
|
}
|
|
|
|
|
|
|
|
function getCryptoValue(balance, cryptoSymbol, fiatSymbol) {
|
|
|
|
return currencyStore.getCryptoValue(balance, cryptoSymbol, fiatSymbol)
|
|
|
|
}
|
|
|
|
|
2022-09-05 09:15:47 +00:00
|
|
|
function getGasEthValue(gweiValue, gasLimit) {
|
2023-01-08 22:23:51 +00:00
|
|
|
return currencyStore.getGasEthValue(gweiValue, gasLimit)
|
|
|
|
}
|
|
|
|
|
2023-08-30 12:10:59 +00:00
|
|
|
function getFeeEthValue(feeCurrency) {
|
2023-09-11 10:08:21 +00:00
|
|
|
if (!feeCurrency || feeCurrency.symbol !== "Gwei")
|
|
|
|
return qsTr("N/A")
|
2023-08-30 12:10:59 +00:00
|
|
|
return currencyStore.getGasEthValue(feeCurrency.amount / Math.pow(10, feeCurrency.displayDecimals), 1)
|
|
|
|
}
|
|
|
|
|
2023-02-17 12:56:31 +00:00
|
|
|
function formatCurrencyAmount(amount, symbol, options = null, locale = null) {
|
|
|
|
return currencyStore.formatCurrencyAmount(amount, symbol, options, locale)
|
2022-09-05 09:15:47 +00:00
|
|
|
}
|
2022-09-27 08:30:18 +00:00
|
|
|
|
|
|
|
function getHistoricalDataForToken(symbol, currency) {
|
2023-02-14 09:20:53 +00:00
|
|
|
if (Global.appIsReady)
|
|
|
|
walletSectionAllTokens.getHistoricalDataForToken(symbol,currency)
|
2022-09-27 08:30:18 +00:00
|
|
|
}
|
2022-10-28 17:17:16 +00:00
|
|
|
|
2023-08-02 04:36:54 +00:00
|
|
|
function fetchDecodedTxData(txHash, input) {
|
|
|
|
walletSectionInst.fetchDecodedTxData(txHash, input)
|
|
|
|
}
|
|
|
|
|
2023-08-29 18:57:38 +00:00
|
|
|
function fetchTxDetails(modelIndex) {
|
|
|
|
walletSectionInst.activityController.fetchTxDetails(modelIndex)
|
2023-08-30 12:10:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function getTxDetails() {
|
|
|
|
return walletSectionInst.activityController.activityDetails
|
|
|
|
}
|
|
|
|
|
2023-02-14 09:20:53 +00:00
|
|
|
property bool marketHistoryIsLoading: Global.appIsReady? walletSectionAllTokens.marketHistoryIsLoading : false
|
2023-01-10 13:04:23 +00:00
|
|
|
|
2022-11-15 21:48:59 +00:00
|
|
|
function fetchHistoricalBalanceForTokenAsJson(address, tokenSymbol, currencySymbol, timeIntervalEnum) {
|
2023-02-14 09:20:53 +00:00
|
|
|
if (Global.appIsReady)
|
|
|
|
walletSectionAllTokens.fetchHistoricalBalanceForTokenAsJson(address, tokenSymbol, currencySymbol, timeIntervalEnum)
|
2022-10-28 17:17:16 +00:00
|
|
|
}
|
2023-01-10 13:04:23 +00:00
|
|
|
|
2023-02-14 09:20:53 +00:00
|
|
|
property bool balanceHistoryIsLoading: Global.appIsReady? walletSectionAllTokens.balanceHistoryIsLoading : false
|
2023-01-10 13:04:23 +00:00
|
|
|
|
2021-12-08 21:20:43 +00:00
|
|
|
}
|