2021-10-05 20:50:22 +00:00
|
|
|
pragma Singleton
|
|
|
|
|
|
|
|
import QtQuick 2.13
|
|
|
|
|
2024-03-20 14:21:58 +00:00
|
|
|
// Aliasing not to conflict with the shared.stores.RootStore
|
|
|
|
import shared.stores 1.0 as Stores
|
2023-11-24 12:16:13 +00:00
|
|
|
|
2022-02-21 17:07:16 +00:00
|
|
|
import utils 1.0
|
2023-10-12 17:45:25 +00:00
|
|
|
|
2024-06-29 20:24:05 +00:00
|
|
|
import StatusQ 0.1
|
2023-02-20 10:57:45 +00:00
|
|
|
import SortFilterProxyModel 0.2
|
|
|
|
import StatusQ.Core.Theme 0.1
|
2023-10-12 17:45:25 +00:00
|
|
|
import StatusQ.Core.Utils 0.1 as SQUtils
|
2023-02-20 10:57:45 +00:00
|
|
|
|
2021-10-05 20:50:22 +00:00
|
|
|
QtObject {
|
|
|
|
id: root
|
2022-08-09 15:08:39 +00:00
|
|
|
|
2023-12-26 10:19:41 +00:00
|
|
|
property bool showSavedAddresses: false
|
|
|
|
property string selectedAddress: ""
|
|
|
|
readonly property bool showAllAccounts: !root.showSavedAddresses && !root.selectedAddress
|
|
|
|
|
|
|
|
property var lastCreatedSavedAddress
|
|
|
|
property bool addingSavedAddress: false
|
|
|
|
property bool deletingSavedAddress: false
|
|
|
|
|
2023-10-26 21:11:20 +00:00
|
|
|
readonly property TokensStore tokensStore: TokensStore {}
|
2023-11-24 12:16:13 +00:00
|
|
|
readonly property WalletAssetsStore walletAssetsStore: WalletAssetsStore {
|
|
|
|
walletTokensStore: tokensStore
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This property holds address of currently selected account in Wallet Main layout */
|
2024-06-24 10:30:24 +00:00
|
|
|
readonly property var addressFilters: walletSectionInst.addressFilters
|
|
|
|
readonly property var keypairImportModule: walletSectionInst.keypairImportModule
|
|
|
|
readonly property string signingPhrase: walletSectionInst.signingPhrase
|
|
|
|
readonly property string mnemonicBackedUp: walletSectionInst.isMnemonicBackedUp
|
|
|
|
|
2023-11-24 12:16:13 +00:00
|
|
|
/* This property holds networks currently selected in the Wallet Main layout */
|
|
|
|
readonly property var networkFilters: networksModule.enabledChainIds
|
2023-10-26 21:11:20 +00:00
|
|
|
|
2022-10-27 09:26:34 +00:00
|
|
|
readonly property string defaultSelectedKeyUid: userProfile.keyUid
|
|
|
|
readonly property bool defaultSelectedKeyUidMigratedToKeycard: userProfile.isKeycardUser
|
|
|
|
|
2022-09-13 16:17:54 +00:00
|
|
|
property string backButtonName: ""
|
2023-04-13 09:59:17 +00:00
|
|
|
property var overview: walletSectionOverview
|
2023-11-24 12:16:13 +00:00
|
|
|
property bool balanceLoading: overview.balanceLoading
|
2024-07-03 03:55:05 +00:00
|
|
|
readonly property var accounts: walletSectionAccounts.accounts
|
2021-12-06 21:10:54 +00:00
|
|
|
property var appSettings: localAppSettings
|
|
|
|
property var accountSensitiveSettings: localAccountSensitiveSettings
|
|
|
|
property bool hideSignPhraseModal: accountSensitiveSettings.hideSignPhraseModal
|
2021-10-05 20:50:22 +00:00
|
|
|
|
2023-07-17 23:56:40 +00:00
|
|
|
property CollectiblesStore collectiblesStore: CollectiblesStore {}
|
2021-10-05 20:50:22 +00:00
|
|
|
|
2023-11-17 14:08:43 +00:00
|
|
|
readonly property bool areTestNetworksEnabled: networksModule.areTestNetworksEnabled
|
2024-03-19 09:49:09 +00:00
|
|
|
readonly property bool isGoerliEnabled: profileSectionModule.walletModule.networksModule.isGoerliEnabled
|
2023-07-03 09:23:26 +00:00
|
|
|
|
2023-02-20 10:57:45 +00:00
|
|
|
property var savedAddresses: SortFilterProxyModel {
|
|
|
|
sourceModel: walletSectionSavedAddresses.model
|
|
|
|
filters: [
|
|
|
|
ValueFilter {
|
|
|
|
roleName: "isTest"
|
|
|
|
value: networksModule.areTestNetworksEnabled
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2023-08-29 15:28:41 +00:00
|
|
|
property var nonWatchAccounts: SortFilterProxyModel {
|
2024-07-03 03:55:05 +00:00
|
|
|
sourceModel: accounts
|
2023-08-09 12:31:58 +00:00
|
|
|
proxyRoles: [
|
2024-06-29 20:24:05 +00:00
|
|
|
FastExpressionRole {
|
2023-08-09 12:31:58 +00:00
|
|
|
name: "color"
|
|
|
|
|
|
|
|
function getColor(colorId) {
|
|
|
|
return Utils.getColorForId(colorId)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Direct call for singleton function is not handled properly by
|
|
|
|
// SortFilterProxyModel that's why helper function is used instead.
|
|
|
|
expression: { return getColor(model.colorId) }
|
2024-06-29 20:24:05 +00:00
|
|
|
expectedRoles: ["colorId"]
|
2023-08-09 12:31:58 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
filters: ValueFilter {
|
2024-07-11 14:47:51 +00:00
|
|
|
roleName: "canSend"
|
|
|
|
value: true
|
2023-08-09 12:31:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-19 14:16:45 +00:00
|
|
|
readonly property var currentActivityFiltersStore: {
|
|
|
|
const address = root.overview.mixedcaseAddress
|
|
|
|
if (address in d.activityFiltersStoreDictionary) {
|
|
|
|
return d.activityFiltersStoreDictionary[address]
|
|
|
|
}
|
|
|
|
let store = d.activityFilterStoreComponent.createObject(root)
|
|
|
|
d.activityFiltersStoreDictionary[address] = store
|
|
|
|
return store
|
|
|
|
}
|
|
|
|
|
2024-06-24 10:30:24 +00:00
|
|
|
// "walletSection" is a context property slow to lookup, so we cache it here
|
|
|
|
readonly property var walletSectionInst: walletSection
|
|
|
|
readonly property var totalCurrencyBalance: walletSectionInst.totalCurrencyBalance
|
|
|
|
|
|
|
|
readonly property var activityController: walletSectionInst.activityController
|
|
|
|
readonly property var tmpActivityController0: walletSectionInst.tmpActivityController0
|
|
|
|
readonly property var tmpActivityController1: walletSectionInst.tmpActivityController1
|
|
|
|
readonly property var activityDetailsController: walletSectionInst.activityDetailsController
|
|
|
|
readonly property var walletConnectController: walletSectionInst.walletConnectController
|
|
|
|
|
2024-07-02 23:31:34 +00:00
|
|
|
readonly property bool isAccountTokensReloading: walletSectionInst.isAccountTokensReloading
|
|
|
|
readonly property double lastReloadTimestamp: walletSectionInst.lastReloadTimestamp
|
|
|
|
|
2024-06-24 10:30:24 +00:00
|
|
|
signal savedAddressAddedOrUpdated(added: bool, name: string, address: string, errorMsg: string)
|
|
|
|
signal savedAddressDeleted(name: string, address: string, errorMsg: string)
|
|
|
|
|
2023-02-20 10:57:45 +00:00
|
|
|
property QtObject _d: QtObject {
|
|
|
|
id: d
|
2023-07-19 14:16:45 +00:00
|
|
|
|
2024-06-24 10:30:24 +00:00
|
|
|
readonly property var mainModuleInst: mainModule
|
2024-06-25 18:17:48 +00:00
|
|
|
readonly property var walletSectionSavedAddressesInst: walletSectionSavedAddresses
|
2024-06-24 10:30:24 +00:00
|
|
|
|
|
|
|
readonly property Connections walletSectionSavedAddressesConnections: Connections{
|
|
|
|
target: walletSectionSavedAddresses
|
|
|
|
|
|
|
|
function onSavedAddressAddedOrUpdated(added: bool, name: string, address: string, errorMsg: string) {
|
|
|
|
root.savedAddressAddedOrUpdated(added, name, address , errorMsg);
|
|
|
|
}
|
|
|
|
function onSavedAddressDeleted(name: string, address: string, errorMsg: string) {
|
|
|
|
root.savedAddressDeleted(name, address, errorMsg)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-19 14:16:45 +00:00
|
|
|
property var activityFiltersStoreDictionary: ({})
|
2024-01-24 16:35:53 +00:00
|
|
|
readonly property Component activityFilterStoreComponent: ActivityFiltersStore{
|
|
|
|
tokensList: walletAssetsStore.groupedAccountAssetsModel
|
|
|
|
}
|
2023-07-19 14:16:45 +00:00
|
|
|
|
2023-02-20 10:57:45 +00:00
|
|
|
property var chainColors: ({})
|
|
|
|
|
|
|
|
function initChainColors(model) {
|
|
|
|
for (let i = 0; i < model.count; i++) {
|
2024-05-20 12:18:44 +00:00
|
|
|
const item = SQUtils.ModelUtils.get(model, i)
|
|
|
|
chainColors[item.shortName] = item.chainColor
|
2023-02-20 10:57:45 +00:00
|
|
|
}
|
|
|
|
}
|
2023-07-19 14:16:45 +00:00
|
|
|
|
|
|
|
readonly property Connections walletSectionConnections: Connections {
|
|
|
|
target: root.walletSectionInst
|
|
|
|
function onWalletAccountRemoved(address) {
|
|
|
|
address = address.toLowerCase();
|
|
|
|
for (var addressKey in d.activityFiltersStoreDictionary){
|
|
|
|
if (address === addressKey.toLowerCase()){
|
|
|
|
delete d.activityFiltersStoreDictionary[addressKey]
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-02-20 10:57:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function colorForChainShortName(chainShortName) {
|
|
|
|
return d.chainColors[chainShortName]
|
|
|
|
}
|
2021-10-05 20:50:22 +00:00
|
|
|
|
2024-06-29 20:24:05 +00:00
|
|
|
readonly property var flatNetworks: networksModule.flatNetworks
|
|
|
|
readonly property SortFilterProxyModel filteredFlatModel: SortFilterProxyModel {
|
2024-03-13 17:38:16 +00:00
|
|
|
sourceModel: root.flatNetworks
|
|
|
|
filters: ValueFilter { roleName: "isTest"; value: root.areTestNetworksEnabled }
|
|
|
|
}
|
|
|
|
|
|
|
|
onFlatNetworksChanged: {
|
|
|
|
d.initChainColors(flatNetworks)
|
2023-02-20 10:57:45 +00:00
|
|
|
}
|
2022-02-17 09:15:37 +00:00
|
|
|
|
2022-03-01 14:54:41 +00:00
|
|
|
property var cryptoRampServicesModel: walletSectionBuySellCrypto.model
|
|
|
|
|
2023-11-07 22:45:47 +00:00
|
|
|
function resetCurrentViewedHolding(type) {
|
2024-05-13 17:23:01 +00:00
|
|
|
currentViewedHoldingTokensKey = ""
|
2023-09-11 10:20:36 +00:00
|
|
|
currentViewedHoldingID = ""
|
2023-11-07 22:45:47 +00:00
|
|
|
currentViewedHoldingType = type
|
2023-09-11 10:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function setCurrentViewedHoldingType(type) {
|
2024-05-13 17:23:01 +00:00
|
|
|
currentViewedHoldingTokensKey = ""
|
2023-09-11 10:20:36 +00:00
|
|
|
currentViewedHoldingID = ""
|
|
|
|
currentViewedHoldingType = type
|
|
|
|
}
|
|
|
|
|
2024-05-13 17:23:01 +00:00
|
|
|
function setCurrentViewedHolding(id, tokensKey, type) {
|
|
|
|
currentViewedHoldingTokensKey = tokensKey
|
2023-09-11 10:20:36 +00:00
|
|
|
currentViewedHoldingID = id
|
|
|
|
currentViewedHoldingType = type
|
|
|
|
}
|
|
|
|
|
2024-05-13 17:23:01 +00:00
|
|
|
property string currentViewedHoldingTokensKey: ""
|
|
|
|
/* TODO: should get rid if this eventually, we shouldnt be using token symbols
|
|
|
|
everywhere. Adding a new one currentViewedHoldingTokensKey aboce to not impact send/bridge flows */
|
2023-09-11 10:20:36 +00:00
|
|
|
property string currentViewedHoldingID: ""
|
2023-09-12 14:26:38 +00:00
|
|
|
property int currentViewedHoldingType
|
2023-09-20 13:01:37 +00:00
|
|
|
readonly property var currentViewedCollectible: collectiblesStore.detailedCollectible
|
2023-09-11 10:20:36 +00:00
|
|
|
|
2024-03-19 08:41:41 +00:00
|
|
|
function canProfileProveOwnershipOfProvidedAddresses(addresses) {
|
|
|
|
return walletSection.canProfileProveOwnershipOfProvidedAddresses(JSON.stringify(addresses))
|
|
|
|
}
|
|
|
|
|
2022-01-21 14:18:43 +00:00
|
|
|
function setHideSignPhraseModal(value) {
|
2021-12-06 21:10:54 +00:00
|
|
|
localAccountSensitiveSettings.hideSignPhraseModal = value;
|
|
|
|
}
|
|
|
|
|
2023-05-24 06:22:29 +00:00
|
|
|
function getLatestBlockNumber(chainId) {
|
2023-09-11 08:08:53 +00:00
|
|
|
// NOTE returns hex
|
2023-06-29 17:35:18 +00:00
|
|
|
return walletSection.getLatestBlockNumber(chainId)
|
2021-12-13 14:24:21 +00:00
|
|
|
}
|
|
|
|
|
2023-09-11 08:08:53 +00:00
|
|
|
function getEstimatedLatestBlockNumber(chainId) {
|
|
|
|
// NOTE returns decimal
|
|
|
|
return walletSection.getEstimatedLatestBlockNumber(chainId)
|
|
|
|
}
|
|
|
|
|
2023-04-27 13:22:27 +00:00
|
|
|
function setFilterAddress(address) {
|
|
|
|
walletSection.setFilterAddress(address)
|
2023-02-28 15:00:10 +00:00
|
|
|
}
|
|
|
|
|
2024-04-10 09:44:15 +00:00
|
|
|
function setFilterAllAddresses() {
|
|
|
|
walletSectionInst.setFilterAllAddresses()
|
|
|
|
}
|
|
|
|
|
2023-05-04 14:34:00 +00:00
|
|
|
function deleteAccount(address) {
|
|
|
|
return walletSectionAccounts.deleteAccount(address)
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|
|
|
|
|
2021-10-21 08:22:05 +00:00
|
|
|
function updateCurrency(newCurrency) {
|
|
|
|
walletSection.updateCurrency(newCurrency)
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function getQrCode(address) {
|
2022-01-24 11:41:55 +00:00
|
|
|
return globalUtils.qrCode(address)
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|
|
|
|
|
2023-05-23 08:44:35 +00:00
|
|
|
function getNameForWalletAddress(address) {
|
|
|
|
return walletSectionAccounts.getNameByAddress(address)
|
|
|
|
}
|
|
|
|
|
2024-01-26 15:28:49 +00:00
|
|
|
function getWalletAccount(address) {
|
|
|
|
const defaultValue = {
|
|
|
|
name: "",
|
|
|
|
address: "",
|
|
|
|
mixedcaseAddress: "",
|
|
|
|
keyUid: "",
|
|
|
|
path: "",
|
|
|
|
colorId: Constants.walletAccountColors.primary,
|
|
|
|
publicKey: "",
|
|
|
|
walletType: "",
|
|
|
|
isWallet: false,
|
|
|
|
isChat: false,
|
|
|
|
emoji: "",
|
|
|
|
ens: "",
|
|
|
|
assetsLoading: false,
|
|
|
|
removed: "",
|
|
|
|
operable: "",
|
|
|
|
createdAt: -1,
|
|
|
|
position: -1,
|
|
|
|
prodPreferredChainIds: "",
|
|
|
|
testPreferredChainIds: "",
|
|
|
|
hideFromTotalBalance: false
|
|
|
|
}
|
|
|
|
|
|
|
|
const jsonObj = walletSectionAccounts.getWalletAccountAsJson(address)
|
|
|
|
|
|
|
|
try {
|
|
|
|
if (jsonObj === "null" || jsonObj === undefined) {
|
|
|
|
return defaultValue
|
|
|
|
}
|
|
|
|
return JSON.parse(jsonObj)
|
|
|
|
}
|
|
|
|
catch (e) {
|
|
|
|
console.warn("error parsing wallet account for address: ", address, " error: ", e.message)
|
|
|
|
return defaultValue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-29 13:10:55 +00:00
|
|
|
function getSavedAddress(address) {
|
|
|
|
const defaultValue = {
|
|
|
|
name: "",
|
|
|
|
address: "",
|
|
|
|
ens: "",
|
|
|
|
colorId: Constants.walletAccountColors.primary,
|
|
|
|
chainShortNames: "",
|
|
|
|
isTest: false,
|
|
|
|
}
|
|
|
|
|
2024-06-25 18:17:48 +00:00
|
|
|
const jsonObj = d.walletSectionSavedAddressesInst.getSavedAddressAsJson(address)
|
2023-12-29 13:10:55 +00:00
|
|
|
|
|
|
|
try {
|
|
|
|
return JSON.parse(jsonObj)
|
|
|
|
}
|
|
|
|
catch (e) {
|
|
|
|
console.warn("error parsing saved address for address: ", address, " error: ", e.message)
|
|
|
|
return defaultValue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-10 11:54:06 +00:00
|
|
|
function getNameForAddress(address) {
|
2023-07-18 15:59:35 +00:00
|
|
|
var name = getNameForWalletAddress(address)
|
2023-05-10 11:54:06 +00:00
|
|
|
if (name.length === 0) {
|
2023-12-29 13:10:55 +00:00
|
|
|
let savedAddress = getSavedAddress(address)
|
|
|
|
name = savedAddress.name
|
2023-05-10 11:54:06 +00:00
|
|
|
}
|
|
|
|
return name
|
2023-05-22 10:16:39 +00:00
|
|
|
}
|
|
|
|
|
2023-09-27 13:41:55 +00:00
|
|
|
function getAssetForSendTx(tx) {
|
|
|
|
if (tx.isNFT) {
|
|
|
|
return {
|
|
|
|
uid: tx.tokenID,
|
|
|
|
chainId: tx.chainId,
|
|
|
|
name: tx.nftName,
|
|
|
|
imageUrl: tx.nftImageUrl,
|
|
|
|
collectionUid: "",
|
|
|
|
collectionName: ""
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return tx.symbol
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function isTxRepeatable(tx) {
|
2023-10-03 12:15:11 +00:00
|
|
|
if (!tx || tx.txType !== Constants.TransactionType.Send)
|
2023-09-27 13:41:55 +00:00
|
|
|
return false
|
|
|
|
|
2024-07-02 11:19:37 +00:00
|
|
|
let res = SQUtils.ModelUtils.getByKey(root.accounts, "address", tx.sender)
|
|
|
|
if (!res || res.object.walletType === Constants.watchWalletType)
|
2023-09-27 13:41:55 +00:00
|
|
|
return false
|
|
|
|
|
|
|
|
if (tx.isNFT) {
|
|
|
|
// TODO #12275: check if account owns enough NFT
|
|
|
|
} else {
|
|
|
|
// TODO #12275: Check if account owns enough tokens
|
|
|
|
}
|
|
|
|
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2023-08-02 04:36:54 +00:00
|
|
|
function isOwnedAccount(address) {
|
|
|
|
return walletSectionAccounts.isOwnedAccount(address)
|
|
|
|
}
|
|
|
|
|
2023-05-22 10:16:39 +00:00
|
|
|
function getEmojiForWalletAddress(address) {
|
|
|
|
return walletSectionAccounts.getEmojiByAddress(address)
|
|
|
|
}
|
|
|
|
|
|
|
|
function getColorForWalletAddress(address) {
|
|
|
|
return walletSectionAccounts.getColorByAddress(address)
|
2023-05-10 11:54:06 +00:00
|
|
|
}
|
|
|
|
|
2024-01-09 13:49:07 +00:00
|
|
|
function createOrUpdateSavedAddress(name, address, ens, colorId, chainShortNames) {
|
2023-12-26 10:19:41 +00:00
|
|
|
root.addingSavedAddress = true
|
2024-01-09 13:49:07 +00:00
|
|
|
walletSectionSavedAddresses.createOrUpdateSavedAddress(name, address, ens, colorId, chainShortNames)
|
2021-12-15 10:08:47 +00:00
|
|
|
}
|
|
|
|
|
2024-01-15 09:19:25 +00:00
|
|
|
function updatePreferredChains(address, chainShortNames) {
|
|
|
|
walletSectionSavedAddresses.updatePreferredChains(address, chainShortNames)
|
|
|
|
}
|
|
|
|
|
2024-01-09 13:50:01 +00:00
|
|
|
function deleteSavedAddress(address) {
|
2023-12-26 10:19:41 +00:00
|
|
|
root.deletingSavedAddress = true
|
2024-01-09 13:50:01 +00:00
|
|
|
walletSectionSavedAddresses.deleteSavedAddress(address)
|
2021-12-15 10:08:47 +00:00
|
|
|
}
|
2022-02-17 09:15:37 +00:00
|
|
|
|
2023-12-29 13:10:55 +00:00
|
|
|
function savedAddressNameExists(name) {
|
|
|
|
return walletSectionSavedAddresses.savedAddressNameExists(name)
|
|
|
|
}
|
|
|
|
|
2022-02-17 09:15:37 +00:00
|
|
|
function toggleNetwork(chainId) {
|
|
|
|
networksModule.toggleNetwork(chainId)
|
|
|
|
}
|
2022-03-15 19:34:28 +00:00
|
|
|
|
|
|
|
function copyToClipboard(text) {
|
|
|
|
globalUtils.copyToClipboard(text)
|
|
|
|
}
|
2023-03-22 15:48:44 +00:00
|
|
|
|
|
|
|
function runAddAccountPopup() {
|
2023-03-27 12:49:32 +00:00
|
|
|
walletSection.runAddAccountPopup(false)
|
|
|
|
}
|
|
|
|
|
|
|
|
function runAddWatchOnlyAccountPopup() {
|
|
|
|
walletSection.runAddAccountPopup(true)
|
2023-03-22 15:48:44 +00:00
|
|
|
}
|
2023-03-30 13:00:55 +00:00
|
|
|
|
|
|
|
function runEditAccountPopup(address) {
|
|
|
|
walletSection.runEditAccountPopup(address)
|
|
|
|
}
|
2023-04-24 18:35:34 +00:00
|
|
|
|
2023-05-12 07:11:44 +00:00
|
|
|
function toggleWatchOnlyAccounts() {
|
|
|
|
walletSection.toggleWatchOnlyAccounts()
|
|
|
|
}
|
2023-07-21 08:41:24 +00:00
|
|
|
|
|
|
|
function getAllNetworksChainIds() {
|
2024-03-13 17:38:16 +00:00
|
|
|
let result = []
|
|
|
|
let chainIdsArray = SQUtils.ModelUtils.modelToFlatArray(root.filteredFlatModel, "chainId")
|
|
|
|
for(let i = 0; i< chainIdsArray.length; i++) {
|
|
|
|
result.push(chainIdsArray[i].toString())
|
|
|
|
}
|
|
|
|
return result
|
2023-07-21 08:41:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function getNetworkShortNames(chainIds) {
|
2023-09-20 13:01:37 +00:00
|
|
|
return networksModule.getNetworkShortNames(chainIds)
|
2023-07-21 08:41:24 +00:00
|
|
|
}
|
|
|
|
|
2024-01-15 09:19:25 +00:00
|
|
|
function getNetworkIds(shortNames) {
|
|
|
|
return networksModule.getNetworkIds(shortNames)
|
|
|
|
}
|
|
|
|
|
2023-07-21 08:41:24 +00:00
|
|
|
function updateWalletAccountPreferredChains(address, preferredChainIds) {
|
|
|
|
if(areTestNetworksEnabled) {
|
|
|
|
walletSectionAccounts.updateWalletAccountTestPreferredChains(address, preferredChainIds)
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
walletSectionAccounts.updateWalletAccountProdPreferredChains(address, preferredChainIds)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-10 15:46:43 +00:00
|
|
|
function updateWatchAccountHiddenFromTotalBalance(address, hideFromTotalBalance) {
|
|
|
|
walletSectionAccounts.updateWatchAccountHiddenFromTotalBalance(address, hideFromTotalBalance)
|
|
|
|
}
|
2023-11-24 12:16:13 +00:00
|
|
|
|
2024-03-20 14:21:58 +00:00
|
|
|
property Stores.CurrenciesStore currencyStore: Stores.CurrenciesStore {}
|
2023-12-20 10:46:33 +00:00
|
|
|
|
|
|
|
function addressWasShown(address) {
|
2024-06-24 10:30:24 +00:00
|
|
|
return d.mainModuleInst.addressWasShown(address)
|
2023-12-20 10:46:33 +00:00
|
|
|
}
|
2024-03-11 10:08:40 +00:00
|
|
|
|
2024-03-26 15:00:16 +00:00
|
|
|
function getExplorerDomain(networkShortName) {
|
2024-03-11 10:08:40 +00:00
|
|
|
let link = Constants.networkExplorerLinks.etherscan
|
2024-03-19 09:49:09 +00:00
|
|
|
if (networkShortName === Constants.networkShortChainNames.mainnet) {
|
|
|
|
if (root.areTestNetworksEnabled) {
|
|
|
|
if (!root.isGoerliEnabled) {
|
|
|
|
link = Constants.networkExplorerLinks.sepoliaEtherscan
|
|
|
|
} else {
|
|
|
|
link = Constants.networkExplorerLinks.goerliEtherscan
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (networkShortName === Constants.networkShortChainNames.arbitrum) {
|
|
|
|
link = Constants.networkExplorerLinks.arbiscan
|
|
|
|
if (root.areTestNetworksEnabled) {
|
|
|
|
if (!root.isGoerliEnabled) {
|
|
|
|
link = Constants.networkExplorerLinks.sepoliaArbiscan
|
|
|
|
} else {
|
|
|
|
link = Constants.networkExplorerLinks.goerliArbiscan
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (networkShortName === Constants.networkShortChainNames.optimism) {
|
|
|
|
link = Constants.networkExplorerLinks.optimism
|
|
|
|
if (root.areTestNetworksEnabled) {
|
|
|
|
if (!root.isGoerliEnabled) {
|
|
|
|
link = Constants.networkExplorerLinks.sepoliaOptimism
|
|
|
|
} else {
|
|
|
|
link = Constants.networkExplorerLinks.goerliOptimism
|
|
|
|
}
|
2024-03-11 10:08:40 +00:00
|
|
|
}
|
2024-03-26 15:00:16 +00:00
|
|
|
}
|
|
|
|
return link
|
|
|
|
}
|
|
|
|
|
|
|
|
function getExplorerUrl(networkShortName, contractAddress, tokenId) {
|
|
|
|
let link = getExplorerDomain(networkShortName)
|
|
|
|
if (networkShortName === Constants.networkShortChainNames.mainnet) {
|
|
|
|
return "%1/nft/%2/%3".arg(link).arg(contractAddress).arg(tokenId)
|
|
|
|
}
|
|
|
|
else {
|
2024-03-19 09:49:09 +00:00
|
|
|
return "%1/token/%2?a=%3".arg(link).arg(contractAddress).arg(tokenId)
|
2024-03-11 10:08:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function getExplorerNameForNetwork(networkShortName) {
|
2024-03-15 16:43:12 +00:00
|
|
|
if (networkShortName === Constants.networkShortChainNames.arbitrum) {
|
2024-03-11 10:08:40 +00:00
|
|
|
return qsTr("Arbiscan Explorer")
|
|
|
|
}
|
|
|
|
if (networkShortName === Constants.networkShortChainNames.optimism) {
|
|
|
|
return qsTr("Optimism Explorer")
|
|
|
|
}
|
|
|
|
return qsTr("Etherscan Explorer")
|
|
|
|
}
|
2024-03-26 15:00:16 +00:00
|
|
|
|
|
|
|
function getOpenSeaNetworkName(networkShortName) {
|
|
|
|
let networkName = Constants.openseaExplorerLinks.ethereum
|
|
|
|
if (networkShortName === Constants.networkShortChainNames.mainnet) {
|
|
|
|
if (root.areTestNetworksEnabled) {
|
|
|
|
if (!root.isGoerliEnabled) {
|
|
|
|
networkName = Constants.openseaExplorerLinks.sepoliaEthereum
|
|
|
|
} else {
|
|
|
|
networkName = Constants.openseaExplorerLinks.goerliEthereum
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (networkShortName === Constants.networkShortChainNames.arbitrum) {
|
|
|
|
networkName = Constants.openseaExplorerLinks.arbitrum
|
|
|
|
if (root.areTestNetworksEnabled) {
|
|
|
|
if (!root.isGoerliEnabled) {
|
|
|
|
networkName = Constants.openseaExplorerLinks.sepoliaArbitrum
|
|
|
|
} else {
|
|
|
|
networkName = Constants.openseaExplorerLinks.goerliArbitrum
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (networkShortName === Constants.networkShortChainNames.optimism) {
|
|
|
|
networkName = Constants.openseaExplorerLinks.optimism
|
|
|
|
if (root.areTestNetworksEnabled) {
|
|
|
|
if (!root.isGoerliEnabled) {
|
|
|
|
networkName = Constants.openseaExplorerLinks.sepoliaOptimism
|
|
|
|
} else {
|
|
|
|
networkName = Constants.openseaExplorerLinks.goerliOptimism
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return networkName
|
|
|
|
}
|
|
|
|
|
|
|
|
function getOpenseaDomainName() {
|
|
|
|
return root.areTestNetworksEnabled ? Constants.openseaExplorerLinks.testnetLink : Constants.openseaExplorerLinks.mainnetLink
|
|
|
|
}
|
|
|
|
|
|
|
|
function getOpenSeaCollectionUrl(networkShortName, contractAddress) {
|
|
|
|
let networkName = getOpenSeaNetworkName(networkShortName)
|
|
|
|
let baseLink = root.areTestNetworksEnabled ? Constants.openseaExplorerLinks.testnetLink : Constants.openseaExplorerLinks.mainnetLink
|
|
|
|
return "%1/assets/%2/%3".arg(baseLink).arg(networkName).arg(contractAddress)
|
|
|
|
}
|
|
|
|
|
|
|
|
function getOpenSeaCollectibleUrl(networkShortName, contractAddress, tokenId) {
|
|
|
|
let networkName = getOpenSeaNetworkName(networkShortName)
|
|
|
|
let baseLink = root.areTestNetworksEnabled ? Constants.openseaExplorerLinks.testnetLink : Constants.openseaExplorerLinks.mainnetLink
|
|
|
|
return "%1/assets/%2/%3/%4".arg(baseLink).arg(networkName).arg(contractAddress).arg(tokenId)
|
|
|
|
}
|
2024-04-02 20:56:53 +00:00
|
|
|
|
|
|
|
function getTwitterLink(twitterHandle) {
|
|
|
|
const prefix = Constants.socialLinkPrefixesByType[Constants.socialLinkType.twitter]
|
|
|
|
return prefix + twitterHandle
|
|
|
|
}
|
2024-07-08 08:28:04 +00:00
|
|
|
|
|
|
|
function transactionType(transaction) {
|
2024-07-17 12:14:01 +00:00
|
|
|
if (!transaction)
|
|
|
|
return Constants.TransactionType.Send
|
|
|
|
|
2024-07-08 08:28:04 +00:00
|
|
|
// Cross chain Send to another recipient is not a bridge, though involves bridging
|
|
|
|
if (transaction.txType == Constants.TransactionType.Bridge && transaction.sender !== transaction.recipient) {
|
|
|
|
if (root.showAllAccounts) {
|
|
|
|
const addresses = root.addressFilters
|
|
|
|
if (addresses.indexOf(transaction.sender) > -1)
|
|
|
|
return Constants.TransactionType.Send
|
|
|
|
|
|
|
|
return Constants.TransactionType.Receive
|
|
|
|
}
|
|
|
|
return addressesEqual(root.selectedAddress, transaction.sender) ? Constants.TransactionType.Send : Constants.TransactionType.Receive
|
|
|
|
}
|
|
|
|
|
|
|
|
return transaction.txType
|
|
|
|
}
|
2021-10-05 20:50:22 +00:00
|
|
|
}
|