2021-10-05 22:50:22 +02:00
|
|
|
pragma Singleton
|
|
|
|
|
2024-10-15 21:26:12 +02:00
|
|
|
import QtQuick 2.15
|
2021-10-05 22:50:22 +02:00
|
|
|
|
2024-03-20 16:21:58 +02:00
|
|
|
// Aliasing not to conflict with the shared.stores.RootStore
|
2024-05-22 11:13:39 +03:00
|
|
|
import shared.stores 1.0 as SharedStores
|
2023-11-24 13:16:13 +01:00
|
|
|
|
2022-02-21 18:07:16 +01:00
|
|
|
import utils 1.0
|
2023-10-12 20:45:25 +03:00
|
|
|
|
2024-06-29 23:24:05 +03:00
|
|
|
import StatusQ 0.1
|
2023-02-20 13:57:45 +03:00
|
|
|
import SortFilterProxyModel 0.2
|
|
|
|
import StatusQ.Core.Theme 0.1
|
2023-10-12 20:45:25 +03:00
|
|
|
import StatusQ.Core.Utils 0.1 as SQUtils
|
2023-02-20 13:57:45 +03:00
|
|
|
|
2021-10-05 22:50:22 +02:00
|
|
|
QtObject {
|
|
|
|
id: root
|
2022-08-09 18:08:39 +03:00
|
|
|
|
2023-12-26 11:19:41 +01: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 23:11:20 +02:00
|
|
|
readonly property TokensStore tokensStore: TokensStore {}
|
2023-11-24 13:16:13 +01:00
|
|
|
readonly property WalletAssetsStore walletAssetsStore: WalletAssetsStore {
|
|
|
|
walletTokensStore: tokensStore
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This property holds address of currently selected account in Wallet Main layout */
|
2024-06-24 13:30:24 +03: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
|
|
|
|
|
2024-10-02 09:50:10 +02:00
|
|
|
readonly property var transactionActivityStatus: walletSectionInst.activityController.status
|
|
|
|
|
2023-11-24 13:16:13 +01:00
|
|
|
/* This property holds networks currently selected in the Wallet Main layout */
|
|
|
|
readonly property var networkFilters: networksModule.enabledChainIds
|
2024-07-15 18:56:50 +03:00
|
|
|
readonly property var networkFiltersArray: networkFilters.split(":").filter(Boolean).map(Number)
|
2023-10-26 23:11:20 +02:00
|
|
|
|
2022-10-27 11:26:34 +02:00
|
|
|
readonly property string defaultSelectedKeyUid: userProfile.keyUid
|
|
|
|
readonly property bool defaultSelectedKeyUidMigratedToKeycard: userProfile.isKeycardUser
|
|
|
|
|
2022-09-13 19:17:54 +03:00
|
|
|
property string backButtonName: ""
|
2023-04-13 11:59:17 +02:00
|
|
|
property var overview: walletSectionOverview
|
2023-11-24 13:16:13 +01:00
|
|
|
property bool balanceLoading: overview.balanceLoading
|
2024-07-03 05:55:05 +02:00
|
|
|
readonly property var accounts: walletSectionAccounts.accounts
|
2021-12-06 23:10:54 +02:00
|
|
|
property var appSettings: localAppSettings
|
|
|
|
property var accountSensitiveSettings: localAccountSensitiveSettings
|
|
|
|
property bool hideSignPhraseModal: accountSensitiveSettings.hideSignPhraseModal
|
2021-10-05 22:50:22 +02:00
|
|
|
|
2023-07-17 20:56:40 -03:00
|
|
|
property CollectiblesStore collectiblesStore: CollectiblesStore {}
|
2021-10-05 22:50:22 +02:00
|
|
|
|
2023-11-17 15:08:43 +01:00
|
|
|
readonly property bool areTestNetworksEnabled: networksModule.areTestNetworksEnabled
|
2023-07-03 11:23:26 +02:00
|
|
|
|
2023-02-20 13:57:45 +03:00
|
|
|
property var savedAddresses: SortFilterProxyModel {
|
|
|
|
sourceModel: walletSectionSavedAddresses.model
|
|
|
|
filters: [
|
|
|
|
ValueFilter {
|
|
|
|
roleName: "isTest"
|
|
|
|
value: networksModule.areTestNetworksEnabled
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2023-08-29 17:28:41 +02:00
|
|
|
property var nonWatchAccounts: SortFilterProxyModel {
|
2024-07-03 05:55:05 +02:00
|
|
|
sourceModel: accounts
|
2023-08-09 14:31:58 +02:00
|
|
|
proxyRoles: [
|
2024-06-29 23:24:05 +03:00
|
|
|
FastExpressionRole {
|
2023-08-09 14:31:58 +02: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 23:24:05 +03:00
|
|
|
expectedRoles: ["colorId"]
|
2023-08-09 14:31:58 +02:00
|
|
|
}
|
|
|
|
]
|
|
|
|
filters: ValueFilter {
|
2024-07-11 10:47:51 -04:00
|
|
|
roleName: "canSend"
|
|
|
|
value: true
|
2023-08-09 14:31:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-19 16:16:45 +02: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 13:30:24 +03: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-19 12:21:36 -07:00
|
|
|
readonly property var dappsConnectorController: walletSectionInst.dappsConnectorController
|
2024-06-24 13:30:24 +03:00
|
|
|
|
2024-07-03 02:31:34 +03:00
|
|
|
readonly property bool isAccountTokensReloading: walletSectionInst.isAccountTokensReloading
|
|
|
|
readonly property double lastReloadTimestamp: walletSectionInst.lastReloadTimestamp
|
|
|
|
|
2024-10-02 09:50:10 +02:00
|
|
|
readonly property var historyTransactions: walletSectionInst.activityController.model
|
|
|
|
readonly property bool loadingHistoryTransactions: walletSectionInst.activityController.status.loadingData
|
|
|
|
readonly property bool newDataAvailable: walletSectionInst.activityController.status.newDataAvailable
|
|
|
|
readonly property bool isNonArchivalNode: walletSectionInst.isNonArchivalNode
|
|
|
|
|
2024-06-24 13:30:24 +03:00
|
|
|
signal savedAddressAddedOrUpdated(added: bool, name: string, address: string, errorMsg: string)
|
|
|
|
signal savedAddressDeleted(name: string, address: string, errorMsg: string)
|
|
|
|
|
2023-02-20 13:57:45 +03:00
|
|
|
property QtObject _d: QtObject {
|
|
|
|
id: d
|
2023-07-19 16:16:45 +02:00
|
|
|
|
2024-06-24 13:30:24 +03:00
|
|
|
readonly property var mainModuleInst: mainModule
|
2024-06-25 21:17:48 +03:00
|
|
|
readonly property var walletSectionSavedAddressesInst: walletSectionSavedAddresses
|
2024-06-24 13:30:24 +03: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 16:16:45 +02:00
|
|
|
property var activityFiltersStoreDictionary: ({})
|
2024-01-24 16:35:53 +00:00
|
|
|
readonly property Component activityFilterStoreComponent: ActivityFiltersStore{
|
|
|
|
tokensList: walletAssetsStore.groupedAccountAssetsModel
|
|
|
|
}
|
2023-07-19 16:16:45 +02:00
|
|
|
|
2023-02-20 13:57:45 +03:00
|
|
|
property var chainColors: ({})
|
|
|
|
|
|
|
|
function initChainColors(model) {
|
|
|
|
for (let i = 0; i < model.count; i++) {
|
2024-05-20 14:18:44 +02:00
|
|
|
const item = SQUtils.ModelUtils.get(model, i)
|
|
|
|
chainColors[item.shortName] = item.chainColor
|
2023-02-20 13:57:45 +03:00
|
|
|
}
|
|
|
|
}
|
2023-07-19 16:16:45 +02: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 13:57:45 +03:00
|
|
|
}
|
|
|
|
|
2024-06-29 23:24:05 +03:00
|
|
|
readonly property var flatNetworks: networksModule.flatNetworks
|
|
|
|
readonly property SortFilterProxyModel filteredFlatModel: SortFilterProxyModel {
|
2024-03-13 18:38:16 +01:00
|
|
|
sourceModel: root.flatNetworks
|
|
|
|
filters: ValueFilter { roleName: "isTest"; value: root.areTestNetworksEnabled }
|
|
|
|
}
|
|
|
|
|
|
|
|
onFlatNetworksChanged: {
|
|
|
|
d.initChainColors(flatNetworks)
|
2023-02-20 13:57:45 +03:00
|
|
|
}
|
2022-02-17 10:15:37 +01:00
|
|
|
|
2023-11-07 23:45:47 +01:00
|
|
|
function resetCurrentViewedHolding(type) {
|
2024-05-13 19:23:01 +02:00
|
|
|
currentViewedHoldingTokensKey = ""
|
2023-09-11 07:20:36 -03:00
|
|
|
currentViewedHoldingID = ""
|
2024-08-02 11:24:40 +02:00
|
|
|
currentViewedHoldingCommunityId = ""
|
2023-11-07 23:45:47 +01:00
|
|
|
currentViewedHoldingType = type
|
2023-09-11 07:20:36 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
function setCurrentViewedHoldingType(type) {
|
2024-05-13 19:23:01 +02:00
|
|
|
currentViewedHoldingTokensKey = ""
|
2023-09-11 07:20:36 -03:00
|
|
|
currentViewedHoldingID = ""
|
2024-08-02 11:24:40 +02:00
|
|
|
currentViewedHoldingCommunityId = ""
|
2023-09-11 07:20:36 -03:00
|
|
|
currentViewedHoldingType = type
|
|
|
|
}
|
|
|
|
|
2024-08-02 11:24:40 +02:00
|
|
|
function setCurrentViewedHolding(id, tokensKey, type, communityId) {
|
2024-05-13 19:23:01 +02:00
|
|
|
currentViewedHoldingTokensKey = tokensKey
|
2023-09-11 07:20:36 -03:00
|
|
|
currentViewedHoldingID = id
|
|
|
|
currentViewedHoldingType = type
|
2024-08-02 11:24:40 +02:00
|
|
|
currentViewedHoldingCommunityId = communityId
|
2023-09-11 07:20:36 -03:00
|
|
|
}
|
|
|
|
|
2024-05-13 19:23:01 +02: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 07:20:36 -03:00
|
|
|
property string currentViewedHoldingID: ""
|
2023-09-12 16:26:38 +02:00
|
|
|
property int currentViewedHoldingType
|
2024-08-02 11:24:40 +02:00
|
|
|
property string currentViewedHoldingCommunityId: ""
|
2023-09-20 15:01:37 +02:00
|
|
|
readonly property var currentViewedCollectible: collectiblesStore.detailedCollectible
|
2023-09-11 07:20:36 -03:00
|
|
|
|
2024-03-19 09:41:41 +01:00
|
|
|
function canProfileProveOwnershipOfProvidedAddresses(addresses) {
|
|
|
|
return walletSection.canProfileProveOwnershipOfProvidedAddresses(JSON.stringify(addresses))
|
|
|
|
}
|
|
|
|
|
2022-01-21 15:18:43 +01:00
|
|
|
function setHideSignPhraseModal(value) {
|
2021-12-06 23:10:54 +02:00
|
|
|
localAccountSensitiveSettings.hideSignPhraseModal = value;
|
|
|
|
}
|
|
|
|
|
2023-05-24 08:22:29 +02:00
|
|
|
function getLatestBlockNumber(chainId) {
|
2023-09-11 10:08:53 +02:00
|
|
|
// NOTE returns hex
|
2023-06-29 14:35:18 -03:00
|
|
|
return walletSection.getLatestBlockNumber(chainId)
|
2021-12-13 15:24:21 +01:00
|
|
|
}
|
|
|
|
|
2023-09-11 10:08:53 +02:00
|
|
|
function getEstimatedLatestBlockNumber(chainId) {
|
|
|
|
// NOTE returns decimal
|
|
|
|
return walletSection.getEstimatedLatestBlockNumber(chainId)
|
|
|
|
}
|
|
|
|
|
2023-04-27 15:22:27 +02:00
|
|
|
function setFilterAddress(address) {
|
|
|
|
walletSection.setFilterAddress(address)
|
2023-02-28 16:00:10 +01:00
|
|
|
}
|
|
|
|
|
2024-04-10 11:44:15 +02:00
|
|
|
function setFilterAllAddresses() {
|
|
|
|
walletSectionInst.setFilterAllAddresses()
|
|
|
|
}
|
|
|
|
|
2023-05-04 16:34:00 +02:00
|
|
|
function deleteAccount(address) {
|
|
|
|
return walletSectionAccounts.deleteAccount(address)
|
2021-10-05 22:50:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function getQrCode(address) {
|
2022-01-24 12:41:55 +01:00
|
|
|
return globalUtils.qrCode(address)
|
2021-10-05 22:50:22 +02:00
|
|
|
}
|
|
|
|
|
2023-05-23 10:44:35 +02:00
|
|
|
function getNameForWalletAddress(address) {
|
|
|
|
return walletSectionAccounts.getNameByAddress(address)
|
|
|
|
}
|
|
|
|
|
2024-01-26 16:28:49 +01: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,
|
|
|
|
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 14:10:55 +01:00
|
|
|
function getSavedAddress(address) {
|
|
|
|
const defaultValue = {
|
|
|
|
name: "",
|
|
|
|
address: "",
|
|
|
|
ens: "",
|
|
|
|
colorId: Constants.walletAccountColors.primary,
|
|
|
|
isTest: false,
|
|
|
|
}
|
|
|
|
|
2024-06-25 21:17:48 +03:00
|
|
|
const jsonObj = d.walletSectionSavedAddressesInst.getSavedAddressAsJson(address)
|
2023-12-29 14:10:55 +01:00
|
|
|
|
|
|
|
try {
|
|
|
|
return JSON.parse(jsonObj)
|
|
|
|
}
|
|
|
|
catch (e) {
|
|
|
|
console.warn("error parsing saved address for address: ", address, " error: ", e.message)
|
|
|
|
return defaultValue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-07-30 15:00:20 +02:00
|
|
|
function isChecksumValidForAddress(address) {
|
|
|
|
return root.walletSectionInst.isChecksumValidForAddress(address)
|
|
|
|
}
|
|
|
|
|
2023-05-10 13:54:06 +02:00
|
|
|
function getNameForAddress(address) {
|
2023-07-18 16:59:35 +01:00
|
|
|
var name = getNameForWalletAddress(address)
|
2023-05-10 13:54:06 +02:00
|
|
|
if (name.length === 0) {
|
2023-12-29 14:10:55 +01:00
|
|
|
let savedAddress = getSavedAddress(address)
|
|
|
|
name = savedAddress.name
|
2023-05-10 13:54:06 +02:00
|
|
|
}
|
|
|
|
return name
|
2023-05-22 12:16:39 +02:00
|
|
|
}
|
|
|
|
|
2023-09-27 16:41:55 +03:00
|
|
|
function getAssetForSendTx(tx) {
|
|
|
|
if (tx.isNFT) {
|
2024-07-31 13:58:05 +02:00
|
|
|
return collectiblesStore.getUidForData(tx.tokenID, tx.tokenAddress, tx.chainId)
|
2023-09-27 16:41:55 +03:00
|
|
|
}
|
2024-07-31 13:58:05 +02:00
|
|
|
return tx.symbol
|
2023-09-27 16:41:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function isTxRepeatable(tx) {
|
2023-10-03 14:15:11 +02:00
|
|
|
if (!tx || tx.txType !== Constants.TransactionType.Send)
|
2023-09-27 16:41:55 +03:00
|
|
|
return false
|
|
|
|
|
2024-07-02 13:19:37 +02:00
|
|
|
let res = SQUtils.ModelUtils.getByKey(root.accounts, "address", tx.sender)
|
2024-07-17 20:53:11 +03:00
|
|
|
if (!res || res.walletType === Constants.watchWalletType)
|
2023-09-27 16:41:55 +03:00
|
|
|
return false
|
|
|
|
|
2024-07-31 13:58:05 +02:00
|
|
|
if (!tx.amount) {
|
|
|
|
// Ignore incorrect transactions
|
|
|
|
return false
|
2023-09-27 16:41:55 +03:00
|
|
|
}
|
|
|
|
|
2024-07-31 13:58:05 +02:00
|
|
|
if (tx.isNFT && !root.collectiblesStore.hasNFT(tx.sender, tx.chainId, tx.tokenID, tx.tokenAddress)) {
|
|
|
|
return false
|
|
|
|
}
|
2023-09-27 16:41:55 +03:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2023-08-02 06:36:54 +02:00
|
|
|
function isOwnedAccount(address) {
|
|
|
|
return walletSectionAccounts.isOwnedAccount(address)
|
|
|
|
}
|
|
|
|
|
2023-05-22 12:16:39 +02:00
|
|
|
function getEmojiForWalletAddress(address) {
|
|
|
|
return walletSectionAccounts.getEmojiByAddress(address)
|
|
|
|
}
|
|
|
|
|
|
|
|
function getColorForWalletAddress(address) {
|
|
|
|
return walletSectionAccounts.getColorByAddress(address)
|
2023-05-10 13:54:06 +02:00
|
|
|
}
|
|
|
|
|
2024-10-03 22:13:01 +02:00
|
|
|
function createOrUpdateSavedAddress(name, address, ens, colorId) {
|
2023-12-26 11:19:41 +01:00
|
|
|
root.addingSavedAddress = true
|
2024-10-03 22:13:01 +02:00
|
|
|
walletSectionSavedAddresses.createOrUpdateSavedAddress(name, address, ens, colorId)
|
2024-01-15 10:19:25 +01:00
|
|
|
}
|
|
|
|
|
2024-01-09 14:50:01 +01:00
|
|
|
function deleteSavedAddress(address) {
|
2023-12-26 11:19:41 +01:00
|
|
|
root.deletingSavedAddress = true
|
2024-01-09 14:50:01 +01:00
|
|
|
walletSectionSavedAddresses.deleteSavedAddress(address)
|
2021-12-15 11:08:47 +01:00
|
|
|
}
|
2022-02-17 10:15:37 +01:00
|
|
|
|
2023-12-29 14:10:55 +01:00
|
|
|
function savedAddressNameExists(name) {
|
|
|
|
return walletSectionSavedAddresses.savedAddressNameExists(name)
|
|
|
|
}
|
|
|
|
|
2024-08-05 10:18:17 +02:00
|
|
|
function remainingCapacityForSavedAddresses() {
|
|
|
|
return walletSectionSavedAddresses.remainingCapacityForSavedAddresses()
|
|
|
|
}
|
|
|
|
|
2022-02-17 10:15:37 +01:00
|
|
|
function toggleNetwork(chainId) {
|
|
|
|
networksModule.toggleNetwork(chainId)
|
|
|
|
}
|
2022-03-15 20:34:28 +01:00
|
|
|
|
2024-07-22 09:52:44 -04:00
|
|
|
function enableNetwork(chainId) {
|
|
|
|
networksModule.enableNetwork(chainId)
|
|
|
|
}
|
|
|
|
|
2023-03-22 16:48:44 +01:00
|
|
|
function runAddAccountPopup() {
|
2023-03-27 14:49:32 +02:00
|
|
|
walletSection.runAddAccountPopup(false)
|
|
|
|
}
|
|
|
|
|
|
|
|
function runAddWatchOnlyAccountPopup() {
|
|
|
|
walletSection.runAddAccountPopup(true)
|
2023-03-22 16:48:44 +01:00
|
|
|
}
|
2023-03-30 15:00:55 +02:00
|
|
|
|
|
|
|
function runEditAccountPopup(address) {
|
|
|
|
walletSection.runEditAccountPopup(address)
|
|
|
|
}
|
2023-04-24 20:35:34 +02:00
|
|
|
|
2023-05-12 09:11:44 +02:00
|
|
|
function toggleWatchOnlyAccounts() {
|
|
|
|
walletSection.toggleWatchOnlyAccounts()
|
|
|
|
}
|
2023-07-21 10:41:24 +02:00
|
|
|
|
2023-10-10 17:46:43 +02:00
|
|
|
function updateWatchAccountHiddenFromTotalBalance(address, hideFromTotalBalance) {
|
|
|
|
walletSectionAccounts.updateWatchAccountHiddenFromTotalBalance(address, hideFromTotalBalance)
|
|
|
|
}
|
2023-11-24 13:16:13 +01:00
|
|
|
|
2024-10-04 12:04:59 +02:00
|
|
|
property SharedStores.CurrenciesStore currencyStore: SharedStores.CurrenciesStore {} // FIXME pass it down from AppMain instead of recreating it here
|
2023-12-20 11:46:33 +01:00
|
|
|
|
|
|
|
function addressWasShown(address) {
|
2024-06-24 13:30:24 +03:00
|
|
|
return d.mainModuleInst.addressWasShown(address)
|
2023-12-20 11:46:33 +01:00
|
|
|
}
|
2024-03-11 11:08:40 +01:00
|
|
|
|
2024-03-26 16:00:16 +01:00
|
|
|
function getExplorerDomain(networkShortName) {
|
2024-03-11 11:08:40 +01:00
|
|
|
let link = Constants.networkExplorerLinks.etherscan
|
2024-03-19 10:49:09 +01:00
|
|
|
if (networkShortName === Constants.networkShortChainNames.mainnet) {
|
|
|
|
if (root.areTestNetworksEnabled) {
|
2024-10-16 22:28:32 +02:00
|
|
|
link = Constants.networkExplorerLinks.sepoliaEtherscan
|
2024-03-19 10:49:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (networkShortName === Constants.networkShortChainNames.arbitrum) {
|
|
|
|
link = Constants.networkExplorerLinks.arbiscan
|
|
|
|
if (root.areTestNetworksEnabled) {
|
2024-10-16 22:28:32 +02:00
|
|
|
link = Constants.networkExplorerLinks.sepoliaArbiscan
|
2024-03-19 10:49:09 +01:00
|
|
|
}
|
|
|
|
} else if (networkShortName === Constants.networkShortChainNames.optimism) {
|
|
|
|
link = Constants.networkExplorerLinks.optimism
|
|
|
|
if (root.areTestNetworksEnabled) {
|
2024-10-16 22:28:32 +02:00
|
|
|
link = Constants.networkExplorerLinks.sepoliaOptimism
|
2024-03-11 11:08:40 +01:00
|
|
|
}
|
2024-03-26 16:00:16 +01: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 10:49:09 +01:00
|
|
|
return "%1/token/%2?a=%3".arg(link).arg(contractAddress).arg(tokenId)
|
2024-03-11 11:08:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function getExplorerNameForNetwork(networkShortName) {
|
2024-03-15 18:43:12 +02:00
|
|
|
if (networkShortName === Constants.networkShortChainNames.arbitrum) {
|
2024-03-11 11:08:40 +01:00
|
|
|
return qsTr("Arbiscan Explorer")
|
|
|
|
}
|
|
|
|
if (networkShortName === Constants.networkShortChainNames.optimism) {
|
|
|
|
return qsTr("Optimism Explorer")
|
|
|
|
}
|
|
|
|
return qsTr("Etherscan Explorer")
|
|
|
|
}
|
2024-03-26 16:00:16 +01:00
|
|
|
|
|
|
|
function getOpenSeaNetworkName(networkShortName) {
|
|
|
|
let networkName = Constants.openseaExplorerLinks.ethereum
|
|
|
|
if (networkShortName === Constants.networkShortChainNames.mainnet) {
|
|
|
|
if (root.areTestNetworksEnabled) {
|
2024-10-16 22:28:32 +02:00
|
|
|
networkName = Constants.openseaExplorerLinks.sepoliaEthereum
|
2024-03-26 16:00:16 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (networkShortName === Constants.networkShortChainNames.arbitrum) {
|
|
|
|
networkName = Constants.openseaExplorerLinks.arbitrum
|
|
|
|
if (root.areTestNetworksEnabled) {
|
2024-10-16 22:28:32 +02:00
|
|
|
networkName = Constants.openseaExplorerLinks.sepoliaArbitrum
|
2024-03-26 16:00:16 +01:00
|
|
|
}
|
|
|
|
} else if (networkShortName === Constants.networkShortChainNames.optimism) {
|
|
|
|
networkName = Constants.openseaExplorerLinks.optimism
|
|
|
|
if (root.areTestNetworksEnabled) {
|
2024-10-16 22:28:32 +02:00
|
|
|
networkName = Constants.openseaExplorerLinks.sepoliaOptimism
|
2024-03-26 16:00:16 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
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 22:56:53 +02:00
|
|
|
|
|
|
|
function getTwitterLink(twitterHandle) {
|
|
|
|
const prefix = Constants.socialLinkPrefixesByType[Constants.socialLinkType.twitter]
|
|
|
|
return prefix + twitterHandle
|
|
|
|
}
|
2024-07-08 10:28:04 +02:00
|
|
|
|
|
|
|
function transactionType(transaction) {
|
2024-07-17 14:14:01 +02:00
|
|
|
if (!transaction)
|
|
|
|
return Constants.TransactionType.Send
|
|
|
|
|
2024-07-08 10:28:04 +02: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
|
|
|
|
}
|
2024-07-17 05:16:02 -03:00
|
|
|
|
2024-09-25 18:59:06 +02:00
|
|
|
function addressesEqual(address1, address2) {
|
|
|
|
return address1.toUpperCase() === address2.toUpperCase()
|
|
|
|
}
|
|
|
|
|
2024-07-17 05:16:02 -03:00
|
|
|
// TODO: https://github.com/status-im/status-desktop/issues/15329
|
|
|
|
// Get DApp data from the backend
|
|
|
|
function getDappDetails(chainId, contractAddress) {
|
|
|
|
switch (contractAddress) {
|
2024-07-24 13:25:43 -03:00
|
|
|
case Constants.swap.paraswapV5ApproveContractAddress:
|
|
|
|
case Constants.swap.paraswapV5SwapContractAddress:
|
2024-07-17 05:16:02 -03:00
|
|
|
return {
|
2024-10-15 21:26:12 +02:00
|
|
|
"icon": Theme.png("swap/%1".arg(Constants.swap.paraswapIcon)),
|
2024-08-08 15:52:19 +02:00
|
|
|
"url": Constants.swap.paraswapHostname,
|
2024-07-17 05:16:02 -03:00
|
|
|
"name": Constants.swap.paraswapName,
|
2024-07-24 13:25:43 -03:00
|
|
|
"approvalContractAddress": Constants.swap.paraswapV5ApproveContractAddress,
|
|
|
|
"swapContractAddress": Constants.swap.paraswapV5SwapContractAddress,
|
|
|
|
}
|
|
|
|
case Constants.swap.paraswapV6_2ContractAddress:
|
|
|
|
return {
|
2024-10-15 21:26:12 +02:00
|
|
|
"icon": Theme.png("swap/%1".arg(Constants.swap.paraswapIcon)),
|
2024-07-24 13:25:43 -03:00
|
|
|
"url": Constants.swap.paraswapUrl,
|
|
|
|
"name": Constants.swap.paraswapName,
|
|
|
|
"approvalContractAddress": Constants.swap.paraswapV6_2ContractAddress,
|
|
|
|
"swapContractAddress": Constants.swap.paraswapV6_2ContractAddress,
|
2024-07-17 05:16:02 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return undefined
|
|
|
|
}
|
2024-10-02 09:50:10 +02:00
|
|
|
|
|
|
|
function resetActivityData() {
|
|
|
|
root.walletSectionInst.activityController.resetActivityData()
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateTransactionFilterIfDirty() {
|
|
|
|
if (root.transactionActivityStatus.isFilterDirty)
|
|
|
|
root.walletSectionInst.activityController.updateFilter()
|
|
|
|
}
|
|
|
|
|
|
|
|
function getTxDetails() {
|
|
|
|
return root.walletSectionInst.activityDetailsController.activityDetails
|
|
|
|
}
|
|
|
|
|
|
|
|
function fetchTxDetails(txID) {
|
|
|
|
root.walletSectionInst.activityController.fetchTxDetails(txID)
|
|
|
|
root.walletSectionInst.activityDetailsController.fetchExtraTxDetails()
|
|
|
|
}
|
|
|
|
|
|
|
|
function fetchDecodedTxData(txHash, input) {
|
|
|
|
root.walletSectionInst.fetchDecodedTxData(txHash, input)
|
|
|
|
}
|
|
|
|
|
|
|
|
function fetchMoreTransactions() {
|
|
|
|
if (root.historyTransactions.count === 0
|
|
|
|
|| !root.historyTransactions.hasMore
|
|
|
|
|| root.loadingHistoryTransactions)
|
|
|
|
return
|
|
|
|
root.walletSectionInst.activityController.loadMoreItems()
|
|
|
|
}
|
|
|
|
|
|
|
|
function reloadAccountTokens() {
|
|
|
|
root.walletSectionInst.reloadAccountTokens()
|
|
|
|
}
|
2021-10-05 22:50:22 +02:00
|
|
|
}
|