2021-12-08 21:20:43 +00:00
|
|
|
pragma Singleton
|
|
|
|
|
|
|
|
import QtQuick 2.12
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: root
|
2022-01-11 23:16:17 +00:00
|
|
|
// property var utilsModelInst: !!utilsModel ? utilsModel : null
|
|
|
|
// property var chatsModelInst: !!chatsModel ?chatsModel : null
|
|
|
|
// property var walletModelInst: !!walletModel ? walletModel : null
|
|
|
|
// property var profileModelInst: !!profileModel ? profileModel : null
|
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
|
2022-01-26 10:36:37 +00:00
|
|
|
property var userProfileInst: !!userProfile ? userProfile : null
|
2021-12-08 21:20:43 +00:00
|
|
|
property var walletSectionInst: !!walletSection ? walletSection : null
|
|
|
|
property var appSettings: !!localAppSettings ? localAppSettings : null
|
|
|
|
property var accountSensitiveSettings: !!localAccountSensitiveSettings ? localAccountSensitiveSettings : null
|
2022-02-09 17:35:59 +00:00
|
|
|
property real volume: !!accountSensitiveSettings ? accountSensitiveSettings.volume * 0.1 : 0.2
|
2021-12-08 21:20:43 +00:00
|
|
|
property bool isWalletEnabled: !!accountSensitiveSettings ? accountSensitiveSettings.isWalletEnabled : false
|
|
|
|
property bool notificationSoundsEnabled: !!accountSensitiveSettings ? accountSensitiveSettings.notificationSoundsEnabled : false
|
|
|
|
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
|
|
|
|
|
|
|
|
property string locale: !!appSettings ? appSettings.locale : ""
|
2022-01-11 23:16:17 +00:00
|
|
|
// property string signingPhrase: !!walletModelInst ? walletModelInst.utilsView.signingPhrase : ""
|
|
|
|
// property string gasPrice: !!walletModelInst ? walletModelInst.gasView.gasPrice : "0"
|
|
|
|
// property string gasEthValue: !!walletModelInst ? walletModelInst.gasView.getGasEthValue : "0"
|
2022-07-22 14:42:21 +00:00
|
|
|
|
|
|
|
property CurrenciesStore currencyStore: CurrenciesStore { }
|
2022-03-25 08:46:47 +00:00
|
|
|
property string currentCurrency: walletSection.currentCurrency
|
2022-01-11 23:16:17 +00:00
|
|
|
// property string defaultCurrency: !!walletModelInst ? walletModelInst.balanceView.defaultCurrency : "0"
|
|
|
|
// property string fiatValue: !!walletModelInst ? walletModelInst.balanceView.getFiatValue : "0"
|
|
|
|
// property string cryptoValue: !!walletModelInst ? walletModelInst.balanceView.getCryptoValue : "0"
|
2022-03-25 08:46:47 +00:00
|
|
|
|
|
|
|
property var history: walletSectionTransactions
|
|
|
|
property var historyTransactions: walletSectionTransactions.model
|
|
|
|
property bool isNonArchivalNode: history.isNonArchivalNode
|
|
|
|
|
2022-09-05 09:15:47 +00:00
|
|
|
property var currentAccount: walletSectionCurrent
|
2022-03-25 08:46:47 +00:00
|
|
|
property var walletTokensModule: walletSectionAllTokens
|
|
|
|
property var tokens: walletSectionAllTokens.all
|
2022-08-08 21:12:12 +00:00
|
|
|
property var accounts: walletSectionAccounts.model
|
|
|
|
|
2022-09-27 08:30:18 +00:00
|
|
|
property var marketValueStore: TokenMarketValuesStore{}
|
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
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 getFiatValue(balance, cryptoSymbol, fiatSymbol) {
|
|
|
|
return profileSectionModule.ensUsernamesModule.getFiatValue(balance, cryptoSymbol, fiatSymbol)
|
|
|
|
}
|
|
|
|
|
|
|
|
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 enableWallet() {
|
|
|
|
localAccountSensitiveSettings.isWalletEnabled = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
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-02-09 09:43:23 +00:00
|
|
|
property var gifColumnA: chatSectionChatContentInputArea.gifColumnA
|
2022-01-13 08:58:42 +00:00
|
|
|
property var gifColumnB: chatSectionChatContentInputArea.gifColumnB
|
|
|
|
property var gifColumnC: chatSectionChatContentInputArea.gifColumnC
|
|
|
|
|
|
|
|
function searchGifs(query) {
|
|
|
|
chatSectionChatContentInputArea.searchGifs(query)
|
|
|
|
}
|
|
|
|
|
|
|
|
function getTrendingsGifs() {
|
|
|
|
chatSectionChatContentInputArea.getTrendingsGifs()
|
|
|
|
}
|
|
|
|
|
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() {
|
|
|
|
chatSectionChatContentInputArea.getRecentsGifs()
|
|
|
|
}
|
|
|
|
|
|
|
|
function getFavoritesGifs() {
|
|
|
|
return chatSectionChatContentInputArea.getFavoritesGifs()
|
|
|
|
}
|
|
|
|
|
|
|
|
function isFavorite(id) {
|
|
|
|
return chatSectionChatContentInputArea.isFavorite(id)
|
|
|
|
}
|
|
|
|
|
|
|
|
function toggleFavoriteGif(id, reload) {
|
|
|
|
chatSectionChatContentInputArea.toggleFavoriteGif(id, reload)
|
|
|
|
}
|
|
|
|
|
|
|
|
function addToRecentsGif(id) {
|
|
|
|
chatSectionChatContentInputArea.addToRecentsGif(id)
|
|
|
|
}
|
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
|
|
|
|
|
|
|
function isFetchingHistory(address) {
|
|
|
|
return history.isFetchingHistory(address)
|
|
|
|
}
|
|
|
|
|
|
|
|
function loadTransactionsForAccount(address, pageSize) {
|
|
|
|
history.loadTransactionsForAccount(address, historyTransactions.getLastTxBlockNumber(), pageSize, true)
|
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
|
|
|
return walletSectionAllTokens.findTokenSymbolByAddress(address)
|
|
|
|
}
|
|
|
|
|
|
|
|
function getNameForSavedWalletAddress(address) {
|
|
|
|
return walletSectionSavedAddresses.getNameByAddress(address)
|
|
|
|
}
|
2022-09-05 09:15:47 +00:00
|
|
|
|
2022-08-18 14:44:48 +00:00
|
|
|
function createOrUpdateSavedAddress(name, address, favourite) {
|
|
|
|
return walletSectionSavedAddresses.createOrUpdateSavedAddress(name, address, favourite)
|
2022-09-05 09:15:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function deleteSavedAddress(address) {
|
|
|
|
return walletSectionSavedAddresses.deleteSavedAddress(address)
|
|
|
|
}
|
|
|
|
|
|
|
|
function getLatestBlockNumber() {
|
|
|
|
return walletSectionTransactions.getLastTxBlockNumber()
|
|
|
|
}
|
|
|
|
|
|
|
|
function getGasEthValue(gweiValue, gasLimit) {
|
|
|
|
return profileSectionModule.ensUsernamesModule.getGasEthValue(gweiValue, gasLimit)
|
|
|
|
}
|
2022-09-27 08:30:18 +00:00
|
|
|
|
|
|
|
function getHistoricalDataForToken(symbol, currency) {
|
|
|
|
walletSectionAllTokens.getHistoricalDataForToken(symbol,currency)
|
|
|
|
}
|
2022-10-28 17:17:16 +00:00
|
|
|
|
|
|
|
// TODO: range until we optimize to cache the data and abuse the requests
|
|
|
|
function fetchHistoricalBalanceForTokenAsJson(address, symbol, timeIntervalEnum) {
|
|
|
|
walletSectionAllTokens.fetchHistoricalBalanceForTokenAsJson(address, symbol, timeIntervalEnum)
|
|
|
|
}
|
2021-12-08 21:20:43 +00:00
|
|
|
}
|