chore(@desktop/wallet): Unifying the various "TokensTypes" across the app

fixes #12501
This commit is contained in:
Khushboo Mehta 2023-11-07 23:45:47 +01:00 committed by Khushboo-dev-cpp
parent 672800611d
commit 26f29a4fe6
43 changed files with 193 additions and 190 deletions

View File

@ -34,8 +34,6 @@ import ../../../../app_service/service/community_tokens/service as community_tok
import ../../../../app_service/service/shared_urls/service as shared_urls_service import ../../../../app_service/service/shared_urls/service as shared_urls_service
import ../../../../app_service/service/visual_identity/service as visual_identity import ../../../../app_service/service/visual_identity/service as visual_identity
import ../../../../app_service/service/contacts/dto/contacts as contacts_dto import ../../../../app_service/service/contacts/dto/contacts as contacts_dto
import ../../../../app_service/service/community/dto/community as community_dto
import ../../../../app_service/common/types
export io_interface export io_interface
@ -1307,11 +1305,11 @@ method createOrEditCommunityTokenPermission*(self: Module, communityId: string,
let viewAmount = tokenCriteria{"amount"}.getFloat let viewAmount = tokenCriteria{"amount"}.getFloat
var tokenCriteriaDto = tokenCriteria.toTokenCriteriaDto var tokenCriteriaDto = tokenCriteria.toTokenCriteriaDto
if tokenCriteriaDto.`type` == community_dto.TokenType.ERC20: if tokenCriteriaDto.`type` == TokenType.ERC20:
tokenCriteriaDto.decimals = self.controller.getTokenDecimals(tokenCriteriaDto.symbol) tokenCriteriaDto.decimals = self.controller.getTokenDecimals(tokenCriteriaDto.symbol)
let contractAddresses = self.controller.getContractAddressesForToken(tokenCriteriaDto.symbol) let contractAddresses = self.controller.getContractAddressesForToken(tokenCriteriaDto.symbol)
if contractAddresses.len == 0 and tokenCriteriaDto.`type` != community_dto.TokenType.ENS: if contractAddresses.len == 0 and tokenCriteriaDto.`type` != TokenType.ENS:
if permissionId == "": if permissionId == "":
self.onCommunityTokenPermissionCreationFailed(communityId) self.onCommunityTokenPermissionCreationFailed(communityId)
return return

View File

@ -582,7 +582,7 @@ proc buildTokensAndCollectiblesFromCommunities(self: Module, communityTokens: se
infiniteSupply, infiniteSupply,
) )
if tokenMetadata.tokenType == community_dto.TokenType.ERC20: if tokenMetadata.tokenType == TokenType.ERC20:
# Community ERC20 tokens # Community ERC20 tokens
tokenListItems.add(communityTokenItem) tokenListItems.add(communityTokenItem)
else: else:
@ -635,12 +635,12 @@ method onCommunityTokenMetadataAdded*(self: Module, communityId: string, tokenMe
infiniteSupply, infiniteSupply,
) )
if tokenMetadata.tokenType == community_dto.TokenType.ERC721 and if tokenMetadata.tokenType == TokenType.ERC721 and
not self.view.collectiblesListModel().hasItem(tokenMetadata.symbol): not self.view.collectiblesListModel().hasItem(tokenMetadata.symbol):
self.view.collectiblesListModel.addItems(@[tokenListItem]) self.view.collectiblesListModel.addItems(@[tokenListItem])
return return
if tokenMetadata.tokenType == community_dto.TokenType.ERC20 and if tokenMetadata.tokenType == TokenType.ERC20 and
not self.view.tokenListModel().hasItem(tokenMetadata.symbol): not self.view.tokenListModel().hasItem(tokenMetadata.symbol):
self.view.tokenListModel.addItems(@[tokenListItem]) self.view.tokenListModel.addItems(@[tokenListItem])

View File

@ -1,13 +1,13 @@
import stint import stint
import ./io_interface as community_tokens_module_interface import ./io_interface as community_tokens_module_interface
import ../../../../../app_service/service/community_tokens/service as community_tokens_service import app_service/service/community_tokens/service as community_tokens_service
import ../../../../../app_service/service/transaction/service as transaction_service import app_service/service/transaction/service as transaction_service
import ../../../../../app_service/service/network/service as networks_service import app_service/service/network/service as networks_service
import ../../../../../app_service/service/community/service as community_service import app_service/service/community/service as community_service
import ../../../../../app_service/service/community/dto/community import app_service/common/types
import ../../../../core/signals/types import app/core/signals/types
import ../../../../core/eventemitter import app/core/eventemitter
import ../../../shared_modules/keycard_popup/io_interface as keycard_shared_module import ../../../shared_modules/keycard_popup/io_interface as keycard_shared_module
@ -165,4 +165,4 @@ proc declineOwnership*(self: Controller, communityId: string) =
self.communityTokensService.declineOwnership(communityId) self.communityTokensService.declineOwnership(communityId)
proc asyncGetOwnerTokenOwnerAddress*(self: Controller, chainId: int, contractAddress: string) = proc asyncGetOwnerTokenOwnerAddress*(self: Controller, chainId: int, contractAddress: string) =
self.communityTokensService.asyncGetOwnerTokenOwnerAddress(chainId, contractAddress) self.communityTokensService.asyncGetOwnerTokenOwnerAddress(chainId, contractAddress)

View File

@ -4,7 +4,6 @@ import ../../../../../app_service/service/community_tokens/service as community_
import ../../../../../app_service/service/transaction/service as transaction_service import ../../../../../app_service/service/transaction/service as transaction_service
import ../../../../../app_service/service/network/service as networks_service import ../../../../../app_service/service/network/service as networks_service
import ../../../../../app_service/service/community/service as community_service import ../../../../../app_service/service/community/service as community_service
import ../../../../../app_service/service/community/dto/community
import ../../../../../app_service/service/accounts/utils as utl import ../../../../../app_service/service/accounts/utils as utl
import ../../../../../app_service/common/types import ../../../../../app_service/common/types
import ../../../../core/eventemitter import ../../../../core/eventemitter

View File

@ -1,9 +1,9 @@
import NimQml, json, strutils, sequtils import NimQml, json, strutils, sequtils
import ./io_interface as community_tokens_module_interface import ./io_interface as community_tokens_module_interface
import ../../../shared_models/currency_amount import app/modules/shared_models/currency_amount
import ../../../../../app_service/common/conversion import app_service/common/conversion
import ../../../../../app_service/service/community/dto/community import app_service/common/types
QtObject: QtObject:
type type
@ -133,4 +133,4 @@ QtObject:
QtProperty[string] ownerTokenDetails: QtProperty[string] ownerTokenDetails:
read = getOwnerTokenDetails read = getOwnerTokenDetails
notify = ownerTokenDetailsChanged notify = ownerTokenDetailsChanged

View File

@ -4,6 +4,7 @@ import logging
import ./collectibles_item import ./collectibles_item
import web3/ethtypes as eth import web3/ethtypes as eth
import backend/activity as backend_activity import backend/activity as backend_activity
import app_service/common/types
type type
CollectibleRole* {.pure.} = enum CollectibleRole* {.pure.} = enum
@ -187,7 +188,7 @@ QtObject:
proc getActivityToken*(self: CollectiblesModel, id: string): backend_activity.Token = proc getActivityToken*(self: CollectiblesModel, id: string): backend_activity.Token =
for item in self.items: for item in self.items:
if(cmpIgnoreCase(item.getId(), id) == 0): if(cmpIgnoreCase(item.getId(), id) == 0):
result.tokenType = backend_activity.TokenType.Erc721 result.tokenType = TokenType.ERC721
result.chainId = backend_activity.ChainId(item.getChainId()) result.chainId = backend_activity.ChainId(item.getChainId())
var contract = item.getContractAddress() var contract = item.getContractAddress()
if len(contract) > 0: if len(contract) > 0:
@ -216,4 +217,4 @@ QtObject:
# Fallback, create uid from data, because it still might not be fetched # Fallback, create uid from data, because it still might not be fetched
if chainId > 0 and len(tokenAddress) > 0 and len(tokenId) > 0: if chainId > 0 and len(tokenAddress) > 0 and len(tokenId) > 0:
return $chainId & "+" & tokenAddress & "+" & tokenId return $chainId & "+" & tokenAddress & "+" & tokenId
return "" return ""

View File

@ -16,9 +16,9 @@ import app/core/eventemitter
import app/core/signals/types import app/core/signals/types
import backend/activity as backend_activity import backend/activity as backend_activity
import backend/backend as backend
import app_service/common/conversion import app_service/common/conversion
import app_service/common/types
import app_service/service/currency/service as currency_service import app_service/service/currency/service as currency_service
import app_service/service/transaction/service as transaction_service import app_service/service/transaction/service as transaction_service
import app_service/service/token/service as token_service import app_service/service/token/service as token_service
@ -358,7 +358,7 @@ QtObject:
for chainId in self.chainIds: for chainId in self.chainIds:
let token = self.tokenService.findTokenBySymbol(chainId, tokenCode) let token = self.tokenService.findTokenBySymbol(chainId, tokenCode)
if token != nil: if token != nil:
let tokenType = if token.symbol == "ETH": backend_activity.TokenType.Native else: backend_activity.TokenType.Erc20 let tokenType = if token.symbol == "ETH": TokenType.Native else: TokenType.ERC20
assets.add(backend_activity.Token( assets.add(backend_activity.Token(
tokenType: tokenType, tokenType: tokenType,
chainId: backend_activity.ChainId(token.chainId), chainId: backend_activity.ChainId(token.chainId),

View File

@ -4,6 +4,8 @@ import logging
import ./collectibles_item import ./collectibles_item
import web3/ethtypes as eth import web3/ethtypes as eth
import backend/activity as backend_activity import backend/activity as backend_activity
import app_service/common/utils as common_utils
import app_service/common/types
type type
CollectibleRole* {.pure.} = enum CollectibleRole* {.pure.} = enum
@ -350,7 +352,7 @@ QtObject:
proc getActivityToken*(self: Model, id: string): backend_activity.Token = proc getActivityToken*(self: Model, id: string): backend_activity.Token =
for item in self.items: for item in self.items:
if(cmpIgnoreCase(item.getId(), id) == 0): if(cmpIgnoreCase(item.getId(), id) == 0):
result.tokenType = backend_activity.TokenType.Erc721 result.tokenType = TokenType.ERC721
result.chainId = backend_activity.ChainId(item.getChainId()) result.chainId = backend_activity.ChainId(item.getChainId())
var contract = item.getContractAddress() var contract = item.getContractAddress()
if len(contract) > 0: if len(contract) > 0:
@ -380,4 +382,3 @@ QtObject:
if chainId > 0 and len(tokenAddress) > 0 and len(tokenId) > 0: if chainId > 0 and len(tokenAddress) > 0 and len(tokenId) > 0:
return $chainId & "+" & tokenAddress & "+" & tokenId return $chainId & "+" & tokenAddress & "+" & tokenId
return "" return ""

View File

@ -1,6 +1,8 @@
import NimQml, Tables import NimQml, Tables
import app_service/common/types
import token_criteria_item import token_criteria_item
import ../../../app_service/service/community/dto/community
type type
ModelRole {.pure.} = enum ModelRole {.pure.} = enum

View File

@ -80,9 +80,10 @@ type Shard* = ref object
cluster*: int cluster*: int
index*: int index*: int
# ToDo: Will be streamlined to single TokenType under https://github.com/status-im/status-desktop/pull/12654/files type TokenType* {.pure.} = enum
type NewTokenType* {.pure.} = enum
Native = 0 Native = 0
ERC20 = 1, ERC20 = 1,
ERC721 = 2, ERC721 = 2,
ERC1155 ERC1155 = 3,
Unknown = 4,
ENS = 5

View File

@ -73,12 +73,6 @@ type TokenPermissionState* {.pure.}= enum
UpdatePending = 2, UpdatePending = 2,
RemovalPending = 3, RemovalPending = 3,
type TokenType* {.pure.}= enum
Unknown = 0,
ERC20 = 1,
ERC721 = 2,
ENS = 3 # ENS is also ERC721 but we want to distinguish without heuristics
type TokenCriteriaDto* = object type TokenCriteriaDto* = object
contractAddresses* {.serializedFieldName("contract_addresses").}: Table[int, string] contractAddresses* {.serializedFieldName("contract_addresses").}: Table[int, string]
`type`* {.serializedFieldName("type").}: TokenType `type`* {.serializedFieldName("type").}: TokenType

View File

@ -127,8 +127,8 @@ QtObject:
if flatTokensList.hasKey(unique_key): if flatTokensList.hasKey(unique_key):
flatTokensList[unique_key].sources.add(s.name) flatTokensList[unique_key].sources.add(s.name)
else: else:
let tokenType = if s.name == "native" : NewTokenType.Native let tokenType = if s.name == "native" : TokenType.Native
else: NewTokenType.ERC20 else: TokenType.ERC20
flatTokensList[unique_key] = TokenItem( flatTokensList[unique_key] = TokenItem(
key: unique_key, key: unique_key,
name: token.name, name: token.name,
@ -159,8 +159,8 @@ QtObject:
if not addedChains.contains(token.chainID): if not addedChains.contains(token.chainID):
tokenBySymbolList[token_by_symbol_key].addressPerChainId.add(AddressPerChain(chainId: token.chainID, address: token.address)) tokenBySymbolList[token_by_symbol_key].addressPerChainId.add(AddressPerChain(chainId: token.chainID, address: token.address))
else: else:
let tokenType = if s.name == "native": NewTokenType.Native let tokenType = if s.name == "native": TokenType.Native
else: NewTokenType.ERC20 else: TokenType.ERC20
tokenBySymbolList[token_by_symbol_key] = TokenBySymbolItem( tokenBySymbolList[token_by_symbol_key] = TokenBySymbolItem(
key: token_by_symbol_key, key: token_by_symbol_key,
name: token.name, name: token.name,

View File

@ -36,7 +36,7 @@ type
decimals*: int decimals*: int
# will remain empty until backend provides us this data # will remain empty until backend provides us this data
image*: string image*: string
`type`*: common_types.NewTokenType `type`*: common_types.TokenType
communityId*: string communityId*: string
proc `$`*(self: TokenItem): string = proc `$`*(self: TokenItem): string =

View File

@ -6,6 +6,7 @@ import stint
import web3/ethtypes as eth import web3/ethtypes as eth
import web3/conversions import web3/conversions
import app_service/common/types
from gen import rpc from gen import rpc
import backend import backend
@ -35,10 +36,6 @@ type
ActivityStatus* {.pure.} = enum ActivityStatus* {.pure.} = enum
Failed, Pending, Complete, Finalized Failed, Pending, Complete, Finalized
# see status-go/services/wallet/activity/filter.go TokenType
TokenType* {.pure.} = enum
Native, Erc20, Erc721, Erc1155
# see status-go/services/wallet/activity/filter.go TokenID # see status-go/services/wallet/activity/filter.go TokenID
TokenId* = distinct string TokenId* = distinct string
@ -94,14 +91,18 @@ proc `%`*(tt: TokenType): JsonNode {.inline.} =
proc `$`*(tt: TokenType): string {.inline.} = proc `$`*(tt: TokenType): string {.inline.} =
case tt: case tt:
of Native: of TokenType.Native:
return "ETH" return "ETH"
of Erc20: of TokenType.ERC20:
return "ERC-20" return "ERC-20"
of Erc721: of TokenType.ERC721:
return "ERC-721" return "ERC-721"
of Erc1155: of TokenType.ERC1155:
return "ERC-1155" return "ERC-1155"
of TokenType.Unknown:
return "Unknown"
of TokenType.ENS:
return "ENS"
proc fromJson*(jn: JsonNode, T: typedesc[TokenType]): TokenType {.inline.} = proc fromJson*(jn: JsonNode, T: typedesc[TokenType]): TokenType {.inline.} =
return cast[TokenType](jn.getInt()) return cast[TokenType](jn.getInt())
@ -593,4 +594,4 @@ rpc(getMultiTxDetails, "wallet"):
id: int id: int
rpc(getTxDetails, "wallet"): rpc(getTxDetails, "wallet"):
id: string id: string

View File

@ -3,6 +3,7 @@ import QtQuick.Controls 2.14
import QtQuick.Layouts 1.14 import QtQuick.Layouts 1.14
import AppLayouts.Communities.controls 1.0 import AppLayouts.Communities.controls 1.0
import utils 1.0
ColumnLayout { ColumnLayout {
id: root id: root
@ -17,12 +18,12 @@ ColumnLayout {
QtObject { QtObject {
id: d id: d
readonly property bool ensLayout: root.type === HoldingTypes.Type.Ens readonly property bool ensLayout: root.type === Constants.TokenType.ENS
readonly property var holdingTypesModel: [ readonly property var holdingTypesModel: [
{ value: HoldingTypes.Type.Asset, text: "Asset" }, { value: Constants.TokenType.ERC20, text: "Asset" },
{ value: HoldingTypes.Type.Collectible, text: "Collectible" }, { value: Constants.TokenType.ERC721, text: "Collectible" },
{ value: HoldingTypes.Type.Ens, text: "ENS" } { value: Constants.TokenType.ENS, text: "ENS" }
] ]
} }
@ -72,7 +73,7 @@ ColumnLayout {
Layout.fillWidth: true Layout.fillWidth: true
visible: !d.ensLayout visible: !d.ensLayout
model: root.type === HoldingTypes.Type.Asset model: root.type === Constants.TokenType.ERC20
? root.assetKeys : root.collectibleKeys ? root.assetKeys : root.collectibleKeys
onActivated: root.key = currentText onActivated: root.key = currentText

View File

@ -8,6 +8,8 @@ import AppLayouts.Communities.controls 1.0
import Models 1.0 import Models 1.0
import utils 1.0
Flickable { Flickable {
id: root id: root
@ -132,7 +134,7 @@ Flickable {
} }
Button { Button {
enabled: d.newKey && (d.newAmount || d.newType === HoldingTypes.Type.Ens) enabled: d.newKey && (d.newAmount || d.newType === Constants.TokenType.ENS)
Layout.fillWidth: true Layout.fillWidth: true
text: "Add new holding" text: "Add new holding"

View File

@ -40,7 +40,7 @@ SplitView {
text: "Update" text: "Update"
onClicked: { onClicked: {
holdingsDropdown.close() holdingsDropdown.close()
holdingsDropdown.setActiveTab(HoldingTypes.Type.Ens) holdingsDropdown.setActiveTab(Constants.TokenType.ENS)
holdingsDropdown.openUpdateFlow() holdingsDropdown.openUpdateFlow()
} }
} }

View File

@ -106,7 +106,7 @@ SplitView {
property var preSelectedAccount: txStore.selectedSenderAccount property var preSelectedAccount: txStore.selectedSenderAccount
property string preSelectedHoldingID property string preSelectedHoldingID
property int preSelectedHoldingType property int preSelectedHoldingType: Constants.TokenType.Unknown
property int preSelectedSendType: Constants.SendType.Unknown property int preSelectedSendType: Constants.SendType.Unknown
property bool onlyAssets: false property bool onlyAssets: false
property string preDefinedAmountToSend property string preDefinedAmountToSend
@ -204,13 +204,16 @@ SplitView {
} }
ComboBox { ComboBox {
id: tokenType id: tokenType
model: ["Unknown", "Asset", "Collectible"] model: ["Native", "Asset", "Collectible", "Fungible Token", "Unknown", "ENS"]
onCurrentIndexChanged: loader.preSelectedHoldingType = currentIndex currentIndex: 4
onCurrentIndexChanged: {
loader.preSelectedHoldingType = currentIndex
}
} }
} }
StatusInput { StatusInput {
enabled: tokenType.currentIndex !== 0 enabled: tokenType.currentIndex > 0 && tokenType.currentIndex < 3
label: "preSelectedHoldingID (case sensitive)" label: "preSelectedHoldingID (case sensitive)"
onTextChanged: loader.preSelectedHoldingID = text onTextChanged: loader.preSelectedHoldingID = text
} }

View File

@ -6,6 +6,8 @@ import Models 1.0
import StatusQ.Core.Utils 0.1 import StatusQ.Core.Utils 0.1
import AppLayouts.Communities.controls 1.0 import AppLayouts.Communities.controls 1.0
import utils 1.0
QtObject { QtObject {
id: root id: root
@ -584,7 +586,7 @@ QtObject {
function createHoldingsModel1() { function createHoldingsModel1() {
return [ return [
{ {
type: HoldingTypes.Type.Asset, type: Constants.TokenType.ERC20,
key: "zrx", key: "zrx",
amount: 15, amount: 15,
available: false available: false
@ -595,7 +597,7 @@ QtObject {
function createHoldingsModel1b() { function createHoldingsModel1b() {
return [ return [
{ {
type: HoldingTypes.Type.Ens, type: Constants.TokenType.ENS,
key: "*.eth", key: "*.eth",
amount: 1, amount: 1,
available: true available: true
@ -606,13 +608,13 @@ QtObject {
function createHoldingsModel2() { function createHoldingsModel2() {
return [ return [
{ {
type: HoldingTypes.Type.Collectible, type: Constants.TokenType.ERC721,
key: "Kitty6", key: "Kitty6",
amount: 50.25, amount: 50.25,
available: true available: true
}, },
{ {
type: HoldingTypes.Type.Asset, type: Constants.TokenType.ERC20,
key: "Dai", key: "Dai",
amount: 11, amount: 11,
available: true available: true
@ -623,13 +625,13 @@ QtObject {
function createHoldingsModel2b() { function createHoldingsModel2b() {
return [ return [
{ {
type: HoldingTypes.Type.Collectible, type: Constants.TokenType.ERC721,
key: "Anniversary2", key: "Anniversary2",
amount: 1, amount: 1,
available: true available: true
}, },
{ {
type: HoldingTypes.Type.Asset, type: Constants.TokenType.ERC20,
key: "snt", key: "snt",
amount: 666, amount: 666,
available: true available: true
@ -640,19 +642,19 @@ QtObject {
function createHoldingsModel3() { function createHoldingsModel3() {
return [ return [
{ {
type: HoldingTypes.Type.Asset, type: Constants.TokenType.ERC20,
key: "socks", key: "socks",
amount: 15, amount: 15,
available: true available: true
}, },
{ {
type: HoldingTypes.Type.Collectible, type: Constants.TokenType.ERC721,
key: "Kitty4", key: "Kitty4",
amount: 50.25, amount: 50.25,
available: true available: true
}, },
{ {
type: HoldingTypes.Type.Collectible, type: Constants.TokenType.ERC721,
key: "SuperRare", key: "SuperRare",
amount: 11, amount: 11,
available: false available: false
@ -663,25 +665,25 @@ QtObject {
function createHoldingsModel4() { function createHoldingsModel4() {
return [ return [
{ {
type: HoldingTypes.Type.Asset, type: Constants.TokenType.ERC20,
key: "socks", key: "socks",
amount: 15, amount: 15,
available: true available: true
}, },
{ {
type: HoldingTypes.Type.Asset, type: Constants.TokenType.ERC20,
key: "snt", key: "snt",
amount: 25000, amount: 25000,
available: true available: true
}, },
{ {
type: HoldingTypes.Type.Ens, type: Constants.TokenType.ENS,
key: "foo.bar.eth", key: "foo.bar.eth",
amount: 1, amount: 1,
available: false available: false
}, },
{ {
type: HoldingTypes.Type.Asset, type: Constants.TokenType.ERC20,
key: "Amp", key: "Amp",
amount: 2, amount: 2,
available: true available: true
@ -692,31 +694,31 @@ QtObject {
function createHoldingsModel5() { function createHoldingsModel5() {
return [ return [
{ {
type: HoldingTypes.Type.Asset, type: Constants.TokenType.ERC20,
key: "socks", key: "socks",
amount: 15, amount: 15,
available: true available: true
}, },
{ {
type: HoldingTypes.Type.Asset, type: Constants.TokenType.ERC20,
key: "zrx", key: "zrx",
amount: 10, amount: 10,
available: false available: false
}, },
{ {
type: HoldingTypes.Type.Asset, type: Constants.TokenType.ERC20,
key: "1inch", key: "1inch",
amount: 25000, amount: 25000,
available: true available: true
}, },
{ {
type: HoldingTypes.Type.Asset, type: Constants.TokenType.ERC20,
key: "Aave", key: "Aave",
amount: 100, amount: 100,
available: true available: true
}, },
{ {
type: HoldingTypes.Type.Asset, type: Constants.TokenType.ERC20,
key: "Amp", key: "Amp",
amount: 2, amount: 2,
available: true available: true

View File

@ -82,9 +82,9 @@ QtObject {
} }
function getHolding(holdingId, holdingType) { function getHolding(holdingId, holdingType) {
if (holdingType === Constants.HoldingType.Asset) { if (holdingType === Constants.TokenType.ERC20) {
return getAsset(selectedSenderAccount.assets, holdingId) return getAsset(selectedSenderAccount.assets, holdingId)
} else if (holdingType === Constants.HoldingType.Collectible) { } else if (holdingType === Constants.TokenType.ERC721) {
return getCollectible(holdingId) return getCollectible(holdingId)
} else { } else {
return {} return {}
@ -92,9 +92,9 @@ QtObject {
} }
function getSelectorHolding(holdingId, holdingType) { function getSelectorHolding(holdingId, holdingType) {
if (holdingType === Constants.HoldingType.Asset) { if (holdingType === Constants.TokenType.ERC20) {
return getAsset(selectedSenderAccount.assets, holdingId) return getAsset(selectedSenderAccount.assets, holdingId)
} else if (holdingType === Constants.HoldingType.Collectible) { } else if (holdingType === Constants.TokenType.ERC721) {
return getSelectorCollectible(holdingId) return getSelectorCollectible(holdingId)
} else { } else {
return {} return {}
@ -118,9 +118,9 @@ QtObject {
} }
function holdingToSelectorHolding(holding, holdingType) { function holdingToSelectorHolding(holding, holdingType) {
if (holdingType === Constants.HoldingType.Asset) { if (holdingType === Constants.TokenType.Asset) {
return assetToSelectorAsset(holding) return assetToSelectorAsset(holding)
} else if (holdingType === Constants.HoldingType.Collectible) { } else if (holdingType === Constants.TokenType.Collectible) {
return collectibleToSelectorCollectible(holding) return collectibleToSelectorCollectible(holding)
} else { } else {
return {} return {}

View File

@ -64,7 +64,7 @@ StatusSectionLayout {
property Component sendTransactionModalComponent: SendModal { property Component sendTransactionModalComponent: SendModal {
anchors.centerIn: parent anchors.centerIn: parent
preSelectedHoldingID: "ETH" preSelectedHoldingID: "ETH"
preSelectedHoldingType: Constants.HoldingType.Asset preSelectedHoldingType: Constants.TokenType.ERC20
} }
property Component signMessageModalComponent: SignMessageModal {} property Component signMessageModalComponent: SignMessageModal {}

View File

@ -1,10 +1,6 @@
import QtQml 2.14 import QtQml 2.14
QtObject { QtObject {
enum Type {
Unknown, Asset, Collectible, Ens
}
enum Mode { enum Mode {
Add, Update, UpdateOrRemove Add, Update, UpdateOrRemove
} }

View File

@ -8,6 +8,8 @@ import StatusQ.Internal 0.1 as Internal
import AppLayouts.Communities.controls 1.0 import AppLayouts.Communities.controls 1.0
import utils 1.0
QtObject { QtObject {
function getTokenByKey(model, key) { function getTokenByKey(model, key) {
if (!model) if (!model)
@ -81,13 +83,13 @@ QtObject {
amount = AmountsArithmetic.toNumber(AmountsArithmetic.fromString(amount)) amount = AmountsArithmetic.toNumber(AmountsArithmetic.fromString(amount))
switch (type) { switch (type) {
case HoldingTypes.Type.Asset: case Constants.TokenType.ERC20:
return `${LocaleUtils.numberToLocaleString(amount)} ${name}` return `${LocaleUtils.numberToLocaleString(amount)} ${name}`
case HoldingTypes.Type.Collectible: case Constants.TokenType.ERC721:
if (amount === 1) if (amount === 1)
return name return name
return `${LocaleUtils.numberToLocaleString(amount)} ${name}` return `${LocaleUtils.numberToLocaleString(amount)} ${name}`
case HoldingTypes.Type.Ens: case Constants.TokenType.ENS:
if (name === "*.eth") if (name === "*.eth")
return qsTr("Any ENS username") return qsTr("Any ENS username")
if (name.startsWith("*.")) if (name.startsWith("*."))

View File

@ -51,7 +51,7 @@ Control {
readonly property string memberchipRequestRejectedText: qsTr("Membership Request Rejected") readonly property string memberchipRequestRejectedText: qsTr("Membership Request Rejected")
function holdingsTextFormat(name, amount) { function holdingsTextFormat(name, amount) {
return PermissionsHelpers.setHoldingsTextFormat(HoldingTypes.Type.Asset, name, amount) return PermissionsHelpers.setHoldingsTextFormat(Constants.TokenType.ERC20, name, amount)
} }
function getInvitationPendingText() { function getInvitationPendingText() {

View File

@ -20,9 +20,9 @@ StatusDropdown {
property var collectiblesModel property var collectiblesModel
property bool isENSTab: true property bool isENSTab: true
property string noDataText: { property string noDataText: {
if(d.currentHoldingType === HoldingTypes.Type.Asset) if(d.currentHoldingType === Constants.TokenType.ERC20)
return noDataTextForAssets return noDataTextForAssets
if(d.currentHoldingType === HoldingTypes.Type.Collectible) if(d.currentHoldingType === Constants.TokenType.ERC721)
return noDataTextForCollectibles return noDataTextForCollectibles
return qsTr("No data found") return qsTr("No data found")
} }
@ -61,7 +61,7 @@ StatusDropdown {
function openUpdateFlow() { function openUpdateFlow() {
d.initialHoldingMode = HoldingTypes.Mode.UpdateOrRemove d.initialHoldingMode = HoldingTypes.Mode.UpdateOrRemove
if(d.currentHoldingType !== HoldingTypes.Type.Ens) { if(d.currentHoldingType !== Constants.TokenType.ENS) {
if(statesStack.size === 0) if(statesStack.size === 0)
statesStack.push(HoldingsDropdown.FlowType.List_Deep1) statesStack.push(HoldingsDropdown.FlowType.List_Deep1)
@ -75,7 +75,7 @@ StatusDropdown {
} }
function reset() { function reset() {
d.currentHoldingType = HoldingTypes.Type.Asset d.currentHoldingType = Constants.TokenType.ERC20
d.initialHoldingMode = HoldingTypes.Mode.Add d.initialHoldingMode = HoldingTypes.Mode.Add
root.assetKey = "" root.assetKey = ""
@ -91,7 +91,7 @@ StatusDropdown {
// Internal management properties and signals: // Internal management properties and signals:
readonly property var holdingTypes: [ readonly property var holdingTypes: [
HoldingTypes.Type.Asset, HoldingTypes.Type.Collectible, HoldingTypes.Type.Ens Constants.TokenType.ERC20, Constants.TokenType.ERC721, Constants.TokenType.ENS
] ]
readonly property var tabsModel: [qsTr("Assets"), qsTr("Collectibles"), qsTr("ENS")] readonly property var tabsModel: [qsTr("Assets"), qsTr("Collectibles"), qsTr("ENS")]
readonly property var tabsModelNoEns: [qsTr("Assets"), qsTr("Collectibles")] readonly property var tabsModelNoEns: [qsTr("Assets"), qsTr("Collectibles")]
@ -102,7 +102,7 @@ StatusDropdown {
readonly property bool ensReady: d.ensDomainNameValid readonly property bool ensReady: d.ensDomainNameValid
property int extendedDropdownType: ExtendedDropdownContent.Type.Assets property int extendedDropdownType: ExtendedDropdownContent.Type.Assets
property int currentHoldingType: HoldingTypes.Type.Asset property int currentHoldingType: Constants.TokenType.ERC20
property bool updateSelected: false property bool updateSelected: false
@ -133,7 +133,7 @@ StatusDropdown {
function setInitialFlow() { function setInitialFlow() {
statesStack.clear() statesStack.clear()
if(d.currentHoldingType !== HoldingTypes.Type.Ens) if(d.currentHoldingType !== Constants.TokenType.ENS)
statesStack.push(HoldingsDropdown.FlowType.List_Deep1) statesStack.push(HoldingsDropdown.FlowType.List_Deep1)
else else
statesStack.push(HoldingsDropdown.FlowType.Selected) statesStack.push(HoldingsDropdown.FlowType.Selected)
@ -197,17 +197,17 @@ StatusDropdown {
state: d.currentHoldingType state: d.currentHoldingType
states: [ states: [
State { State {
name: HoldingTypes.Type.Asset name: Constants.TokenType.ERC20
PropertyChanges {target: loader; sourceComponent: listLayout} PropertyChanges {target: loader; sourceComponent: listLayout}
PropertyChanges {target: d; extendedDropdownType: ExtendedDropdownContent.Type.Assets} PropertyChanges {target: d; extendedDropdownType: ExtendedDropdownContent.Type.Assets}
}, },
State { State {
name: HoldingTypes.Type.Collectible name: Constants.TokenType.ERC721
PropertyChanges {target: loader; sourceComponent: listLayout} PropertyChanges {target: loader; sourceComponent: listLayout}
PropertyChanges {target: d; extendedDropdownType: ExtendedDropdownContent.Type.Collectibles} PropertyChanges {target: d; extendedDropdownType: ExtendedDropdownContent.Type.Collectibles}
}, },
State { State {
name: HoldingTypes.Type.Ens name: Constants.TokenType.ENS
PropertyChanges {target: loader; sourceComponent: ensLayout} PropertyChanges {target: loader; sourceComponent: ensLayout}
} }
] ]
@ -245,9 +245,9 @@ StatusDropdown {
PropertyChanges { PropertyChanges {
target: loader target: loader
sourceComponent: { sourceComponent: {
if (d.currentHoldingType === HoldingTypes.Type.Asset) if (d.currentHoldingType === Constants.TokenType.ERC20)
return assetLayout return assetLayout
if (d.currentHoldingType === HoldingTypes.Type.Collectible) if (d.currentHoldingType === Constants.TokenType.ERC721)
return collectibleLayout return collectibleLayout
return ensLayout return ensLayout
} }

View File

@ -112,7 +112,7 @@ StatusDialog {
root.sendModalPopup.preSelectedSendType = Constants.SendType.Transfer root.sendModalPopup.preSelectedSendType = Constants.SendType.Transfer
root.sendModalPopup.preSelectedAccount = ModelUtils.getByKey(root.accounts, "address", token.accountAddress) root.sendModalPopup.preSelectedAccount = ModelUtils.getByKey(root.accounts, "address", token.accountAddress)
root.sendModalPopup.preSelectedHoldingID = token.key root.sendModalPopup.preSelectedHoldingID = token.key
root.sendModalPopup.preSelectedHoldingType = Constants.HoldingType.Collectible root.sendModalPopup.preSelectedHoldingType = Constants.TokenType.ERC721
root.sendModalPopup.open() root.sendModalPopup.open()
close() close()
} }

View File

@ -358,16 +358,16 @@ StatusScrollView {
const modelItem = selectedHoldingsModel.get(index) const modelItem = selectedHoldingsModel.get(index)
switch(modelItem.type) { switch(modelItem.type) {
case HoldingTypes.Type.Asset: case Constants.TokenType.ERC20:
dropdown.assetKey = modelItem.key dropdown.assetKey = modelItem.key
dropdown.assetAmount = modelItem.amount dropdown.assetAmount = modelItem.amount
dropdown.assetMultiplierIndex = modelItem.multiplierIndex dropdown.assetMultiplierIndex = modelItem.multiplierIndex
dropdown.setActiveTab(HoldingTypes.Type.Asset) dropdown.setActiveTab(Constants.TokenType.ERC20)
break break
case HoldingTypes.Type.Collectible: case Constants.TokenType.ERC721:
dropdown.collectibleKey = modelItem.key dropdown.collectibleKey = modelItem.key
dropdown.collectibleAmount = modelItem.amount dropdown.collectibleAmount = modelItem.amount
dropdown.setActiveTab(HoldingTypes.Type.Collectible) dropdown.setActiveTab(Constants.TokenType.ERC721)
break break
default: default:
console.warn("Unsupported token type.") console.warn("Unsupported token type.")

View File

@ -125,13 +125,13 @@ StatusScrollView {
function getTokenKeysAndAmounts() { function getTokenKeysAndAmounts() {
return ModelUtils.modelToArray(selectedHoldingsModel, ["type", "key", "amount"]) return ModelUtils.modelToArray(selectedHoldingsModel, ["type", "key", "amount"])
.filter(item => item.type !== HoldingTypes.Type.Ens) .filter(item => item.type !== Constants.TokenType.ENS)
.map(item => ({ key: item.key, amount: item.amount })) .map(item => ({ key: item.key, amount: item.amount }))
} }
function getEnsNames() { function getEnsNames() {
return ModelUtils.modelToArray(selectedHoldingsModel, ["type", "name"]) return ModelUtils.modelToArray(selectedHoldingsModel, ["type", "name"])
.filter(item => item.type === HoldingTypes.Type.Ens) .filter(item => item.type === Constants.TokenType.ENS)
.map(item => item.name) .map(item => item.name)
} }
} }
@ -271,7 +271,7 @@ StatusScrollView {
const modelItem = PermissionsHelpers.getTokenByKey( const modelItem = PermissionsHelpers.getTokenByKey(
root.assetsModel, key) root.assetsModel, key)
addItem(HoldingTypes.Type.Asset, modelItem, amount) addItem(Constants.TokenType.ERC20, modelItem, amount)
dropdown.close() dropdown.close()
} }
@ -279,13 +279,13 @@ StatusScrollView {
const modelItem = PermissionsHelpers.getTokenByKey( const modelItem = PermissionsHelpers.getTokenByKey(
root.collectiblesModel, key) root.collectiblesModel, key)
addItem(HoldingTypes.Type.Collectible, modelItem, amount) addItem(Constants.TokenType.ERC721, modelItem, amount)
dropdown.close() dropdown.close()
} }
onAddEns: { onAddEns: {
d.dirtyValues.selectedHoldingsModel.append( d.dirtyValues.selectedHoldingsModel.append(
{ type: HoldingTypes.Type.Ens, key: domain, amount: 1 }) { type: Constants.TokenType.ENS, key: domain, amount: 1 })
dropdown.close() dropdown.close()
} }
@ -294,7 +294,7 @@ StatusScrollView {
const modelItem = PermissionsHelpers.getTokenByKey(root.assetsModel, key) const modelItem = PermissionsHelpers.getTokenByKey(root.assetsModel, key)
d.dirtyValues.selectedHoldingsModel.set( d.dirtyValues.selectedHoldingsModel.set(
itemIndex, { type: HoldingTypes.Type.Asset, key, amount: parseFloat(amount) }) itemIndex, { type: Constants.TokenType.ERC20, key, amount: parseFloat(amount) })
dropdown.close() dropdown.close()
} }
@ -305,14 +305,14 @@ StatusScrollView {
d.dirtyValues.selectedHoldingsModel.set( d.dirtyValues.selectedHoldingsModel.set(
itemIndex, itemIndex,
{ type: HoldingTypes.Type.Collectible, key, amount: parseFloat(amount) }) { type: Constants.TokenType.ERC721, key, amount: parseFloat(amount) })
dropdown.close() dropdown.close()
} }
onUpdateEns: { onUpdateEns: {
d.dirtyValues.selectedHoldingsModel.set( d.dirtyValues.selectedHoldingsModel.set(
tokensSelector.editedIndex, tokensSelector.editedIndex,
{ type: HoldingTypes.Type.Ens, key: domain, amount: 1 }) { type: Constants.TokenType.ENS, key: domain, amount: 1 })
dropdown.close() dropdown.close()
} }
@ -347,15 +347,15 @@ StatusScrollView {
const modelItem = tokensSelector.model.get(index) const modelItem = tokensSelector.model.get(index)
switch(modelItem.type) { switch(modelItem.type) {
case HoldingTypes.Type.Asset: case Constants.TokenType.ERC20:
dropdown.assetKey = modelItem.key dropdown.assetKey = modelItem.key
dropdown.assetAmount = modelItem.amount dropdown.assetAmount = modelItem.amount
break break
case HoldingTypes.Type.Collectible: case Constants.TokenType.ERC721:
dropdown.collectibleKey = modelItem.key dropdown.collectibleKey = modelItem.key
dropdown.collectibleAmount = modelItem.amount dropdown.collectibleAmount = modelItem.amount
break break
case HoldingTypes.Type.Ens: case Constants.TokenType.ENS:
dropdown.ensDomainName = modelItem.key dropdown.ensDomainName = modelItem.key
break break
default: default:

View File

@ -25,10 +25,10 @@ SortFilterProxyModel {
name: "text" name: "text"
function getName(type, key) { function getName(type, key) {
if (type === HoldingTypes.Type.Ens) if (type === Constants.TokenType.ENS)
return key return key
const model = type === HoldingTypes.Type.Asset const model = type === Constants.TokenType.ERC20
? assetsModel ? assetsModel
: collectiblesModel : collectiblesModel
const item = PermissionsHelpers.getTokenByKey(model, key) const item = PermissionsHelpers.getTokenByKey(model, key)
@ -55,10 +55,10 @@ SortFilterProxyModel {
name: "imageSource" name: "imageSource"
function getIcon(type, key) { function getIcon(type, key) {
if (type === HoldingTypes.Type.Ens) if (type === Constants.TokenType.ENS)
return Style.png("tokens/ENS") return Style.png("tokens/ENS")
const model = type === HoldingTypes.Type.Asset const model = type === Constants.TokenType.ERC20
? assetsModel : collectiblesModel ? assetsModel : collectiblesModel
return PermissionsHelpers.getTokenIconByKey(model, key) return PermissionsHelpers.getTokenIconByKey(model, key)

View File

@ -122,7 +122,7 @@ Item {
preSelectedRecipient: root.ensUsernamesStore.getEnsRegisteredAddress() preSelectedRecipient: root.ensUsernamesStore.getEnsRegisteredAddress()
preDefinedAmountToSend: LocaleUtils.numberToLocaleString(0) preDefinedAmountToSend: LocaleUtils.numberToLocaleString(0)
preSelectedHoldingID: Constants.ethToken preSelectedHoldingID: Constants.ethToken
preSelectedHoldingType: Constants.HoldingType.Asset preSelectedHoldingType: Constants.TokenType.ERC20
sendTransaction: function() { sendTransaction: function() {
if(bestRoutes.count === 1) { if(bestRoutes.count === 1) {
let path = bestRoutes.firstItem() let path = bestRoutes.firstItem()

View File

@ -67,7 +67,7 @@ Item {
preSelectedRecipient: root.ensUsernamesStore.getEnsRegisteredAddress() preSelectedRecipient: root.ensUsernamesStore.getEnsRegisteredAddress()
preDefinedAmountToSend: LocaleUtils.numberToLocaleString(0) preDefinedAmountToSend: LocaleUtils.numberToLocaleString(0)
preSelectedHoldingID: Constants.ethToken preSelectedHoldingID: Constants.ethToken
preSelectedHoldingType: Constants.HoldingType.Asset preSelectedHoldingType: Constants.TokenType.ERC20
sendTransaction: function() { sendTransaction: function() {
if(bestRoutes.count === 1) { if(bestRoutes.count === 1) {
let path = bestRoutes.firstItem() let path = bestRoutes.firstItem()

View File

@ -52,7 +52,7 @@ Item {
preSelectedRecipient: root.ensUsernamesStore.getEnsRegisteredAddress() preSelectedRecipient: root.ensUsernamesStore.getEnsRegisteredAddress()
preDefinedAmountToSend: LocaleUtils.numberToLocaleString(10) preDefinedAmountToSend: LocaleUtils.numberToLocaleString(10)
preSelectedHoldingID: JSON.parse(root.stickersStore.getStatusToken()).symbol preSelectedHoldingID: JSON.parse(root.stickersStore.getStatusToken()).symbol
preSelectedHoldingType: Constants.HoldingType.Asset preSelectedHoldingType: Constants.TokenType.ERC20
sendTransaction: function() { sendTransaction: function() {
if(bestRoutes.count === 1) { if(bestRoutes.count === 1) {
let path = bestRoutes.firstItem() let path = bestRoutes.firstItem()

View File

@ -124,9 +124,9 @@ QtObject {
property var cryptoRampServicesModel: walletSectionBuySellCrypto.model property var cryptoRampServicesModel: walletSectionBuySellCrypto.model
function resetCurrentViewedHolding() { function resetCurrentViewedHolding(type) {
currentViewedHoldingID = "" currentViewedHoldingID = ""
currentViewedHoldingType = Constants.HoldingType.Unknown currentViewedHoldingType = type
} }
function setCurrentViewedHoldingType(type) { function setCurrentViewedHoldingType(type) {

View File

@ -113,7 +113,7 @@ Item {
text: qsTr("Activity") text: qsTr("Activity")
} }
onCurrentIndexChanged: { onCurrentIndexChanged: {
RootStore.setCurrentViewedHoldingType(walletTabBar.currentIndex === 1 ? Constants.HoldingType.Collectible : Constants.HoldingType.Asset) RootStore.setCurrentViewedHoldingType(walletTabBar.currentIndex === 1 ? Constants.TokenType.ERC721 : Constants.TokenType.ERC20)
} }
} }
StackLayout { StackLayout {
@ -129,7 +129,7 @@ Item {
assetDetailsLaunched: stack.currentIndex === 2 assetDetailsLaunched: stack.currentIndex === 2
onAssetClicked: { onAssetClicked: {
assetDetailView.token = token assetDetailView.token = token
RootStore.setCurrentViewedHolding(token.symbol, Constants.HoldingType.Asset) RootStore.setCurrentViewedHolding(token.symbol, Constants.TokenType.ERC20)
stack.currentIndex = 2 stack.currentIndex = 2
} }
} }
@ -137,7 +137,7 @@ Item {
collectiblesModel: RootStore.collectiblesStore.ownedCollectibles collectiblesModel: RootStore.collectiblesStore.ownedCollectibles
onCollectibleClicked: { onCollectibleClicked: {
RootStore.collectiblesStore.getDetailedCollectible(chainId, contractAddress, tokenId) RootStore.collectiblesStore.getDetailedCollectible(chainId, contractAddress, tokenId)
RootStore.setCurrentViewedHolding(uid, Constants.HoldingType.Collectible) RootStore.setCurrentViewedHolding(uid, Constants.TokenType.ERC721)
stack.currentIndex = 1 stack.currentIndex = 1
} }
} }
@ -163,7 +163,7 @@ Item {
onVisibleChanged: { onVisibleChanged: {
if (!visible) if (!visible)
RootStore.resetCurrentViewedHolding() RootStore.resetCurrentViewedHolding(Constants.TokenType.ERC721)
} }
} }
AssetsDetailView { AssetsDetailView {
@ -180,7 +180,7 @@ Item {
onVisibleChanged: { onVisibleChanged: {
if (!visible) if (!visible)
RootStore.resetCurrentViewedHolding() RootStore.resetCurrentViewedHolding(Constants.TokenType.ERC20)
} }
} }

View File

@ -1420,7 +1420,7 @@ Item {
property var preSelectedRecipient property var preSelectedRecipient
property int preSelectedRecipientType property int preSelectedRecipientType
property string preSelectedHoldingID property string preSelectedHoldingID
property int preSelectedHoldingType property int preSelectedHoldingType: Constants.TokenType.Unknown
property int preSelectedSendType: Constants.SendType.Unknown property int preSelectedSendType: Constants.SendType.Unknown
property string preDefinedAmountToSend property string preDefinedAmountToSend
property bool onlyAssets: false property bool onlyAssets: false
@ -1431,7 +1431,7 @@ Item {
sendModal.closed() sendModal.closed()
sendModal.preSelectedSendType = Constants.SendType.Unknown sendModal.preSelectedSendType = Constants.SendType.Unknown
sendModal.preSelectedHoldingID = "" sendModal.preSelectedHoldingID = ""
sendModal.preSelectedHoldingType = Constants.HoldingType.Unknown sendModal.preSelectedHoldingType = Constants.TokenType.Unknown
sendModal.preSelectedAccount = undefined sendModal.preSelectedAccount = undefined
sendModal.preSelectedRecipient = undefined sendModal.preSelectedRecipient = undefined
sendModal.preDefinedAmountToSend = "" sendModal.preDefinedAmountToSend = ""
@ -1448,7 +1448,7 @@ Item {
if(sendModal.preSelectedSendType !== Constants.SendType.Unknown) { if(sendModal.preSelectedSendType !== Constants.SendType.Unknown) {
item.preSelectedSendType = sendModal.preSelectedSendType item.preSelectedSendType = sendModal.preSelectedSendType
} }
if(preSelectedHoldingType !== Constants.HoldingType.Unknown) { if(preSelectedHoldingType !== Constants.TokenType.Unknown) {
item.preSelectedHoldingID = sendModal.preSelectedHoldingID item.preSelectedHoldingID = sendModal.preSelectedHoldingID
item.preSelectedHoldingType = sendModal.preSelectedHoldingType item.preSelectedHoldingType = sendModal.preSelectedHoldingType
} }

View File

@ -22,7 +22,7 @@ QtObject {
preSelectedAccount: null, preSelectedAccount: null,
preSelectedRecipientType: TabAddressSelectorView.Type.Address, preSelectedRecipientType: TabAddressSelectorView.Type.Address,
preSelectedRecipient: null, preSelectedRecipient: null,
preSelectedHoldingType: 0, preSelectedHoldingType: Constants.TokenType.Unknown,
preSelectedHolding: null, preSelectedHolding: null,
preSelectedHoldingID: "", preSelectedHoldingID: "",
preDefinedAmountToSend: "", preDefinedAmountToSend: "",
@ -56,10 +56,10 @@ QtObject {
} }
if (isCollectible) { if (isCollectible) {
req.preSelectedHoldingType = Constants.HoldingType.Collectible req.preSelectedHoldingType = Constants.TokenType.ERC721
req.preSelectedHolding = token req.preSelectedHolding = token
} else { } else {
req.preSelectedHoldingType = Constants.HoldingType.Asset req.preSelectedHoldingType = Constants.TokenType.ERC20
req.preSelectedHoldingID = token req.preSelectedHoldingID = token
} }
@ -67,4 +67,4 @@ QtObject {
return req return req
} }
} }

View File

@ -31,7 +31,7 @@ StatusDialog {
property string preDefinedAmountToSend property string preDefinedAmountToSend
// token symbol // token symbol
property string preSelectedHoldingID property string preSelectedHoldingID
property int preSelectedHoldingType property int preSelectedHoldingType: Constants.TokenType.Unknown
property int preSelectedSendType property int preSelectedSendType
property bool interactive: true property bool interactive: true
property alias onlyAssets: holdingSelector.onlyAssets property alias onlyAssets: holdingSelector.onlyAssets
@ -89,11 +89,11 @@ StatusDialog {
readonly property bool isBridgeTx: store.sendType === Constants.SendType.Bridge readonly property bool isBridgeTx: store.sendType === Constants.SendType.Bridge
readonly property bool isERC721Transfer: store.sendType === Constants.SendType.ERC721Transfer readonly property bool isERC721Transfer: store.sendType === Constants.SendType.ERC721Transfer
property var selectedHolding: null property var selectedHolding: null
property var selectedHoldingType: Constants.HoldingType.Unknown property var selectedHoldingType: Constants.TokenType.Unknown
readonly property bool isSelectedHoldingValidAsset: !!selectedHolding && selectedHoldingType === Constants.HoldingType.Asset readonly property bool isSelectedHoldingValidAsset: !!selectedHolding && selectedHoldingType === Constants.TokenType.ERC20
property var hoveredHolding: null property var hoveredHolding: null
property var hoveredHoldingType: Constants.HoldingType.Unknown property var hoveredHoldingType: Constants.TokenType.Unknown
readonly property bool isHoveredHoldingValidAsset: !!hoveredHolding && hoveredHoldingType === Constants.HoldingType.Asset readonly property bool isHoveredHoldingValidAsset: !!hoveredHolding && hoveredHoldingType === Constants.TokenType.ERC20
function setSelectedHoldingId(holdingId, holdingType) { function setSelectedHoldingId(holdingId, holdingType) {
let holding = store.getHolding(holdingId, holdingType) let holding = store.getHolding(holdingId, holdingType)
@ -120,11 +120,11 @@ StatusDialog {
} }
onSelectedHoldingChanged: { onSelectedHoldingChanged: {
if (d.selectedHoldingType === Constants.HoldingType.Asset) { if (d.selectedHoldingType === Constants.TokenType.ERC20) {
if(!d.ensOrStickersPurpose && store.sendType !== Constants.SendType.Bridge) if(!d.ensOrStickersPurpose && store.sendType !== Constants.SendType.Bridge)
store.setSendType(Constants.SendType.Transfer) store.setSendType(Constants.SendType.Transfer)
store.setSelectedAssetSymbol(selectedHolding.symbol) store.setSelectedAssetSymbol(selectedHolding.symbol)
} else if (d.selectedHoldingType === Constants.HoldingType.Collectible) { } else if (d.selectedHoldingType === Constants.TokenType.ERC721) {
store.setSendType(Constants.SendType.ERC721Transfer) store.setSendType(Constants.SendType.ERC721Transfer)
amountToSendInput.input.text = 1 amountToSendInput.input.text = 1
store.setSelectedAssetSymbol(selectedHolding.contractAddress+":"+selectedHolding.tokenId) store.setSelectedAssetSymbol(selectedHolding.contractAddress+":"+selectedHolding.tokenId)
@ -157,7 +157,8 @@ StatusDialog {
store.setSendType(popup.preSelectedSendType) store.setSendType(popup.preSelectedSendType)
} }
if (popup.preSelectedHoldingType !== Constants.HoldingType.Unknown) { if ((popup.preSelectedHoldingType > Constants.TokenType.Native) &&
(popup.preSelectedHoldingType < Constants.TokenType.ERC1155)) {
tokenListRect.browsingHoldingType = popup.preSelectedHoldingType tokenListRect.browsingHoldingType = popup.preSelectedHoldingType
if (!!popup.preSelectedHoldingID) { if (!!popup.preSelectedHoldingID) {
d.setSelectedHoldingId(popup.preSelectedHoldingID, popup.preSelectedHoldingType) d.setSelectedHoldingId(popup.preSelectedHoldingID, popup.preSelectedHoldingType)
@ -262,8 +263,8 @@ StatusDialog {
collectiblesModel: popup.preSelectedAccount ? popup.nestedCollectiblesModel : null collectiblesModel: popup.preSelectedAccount ? popup.nestedCollectiblesModel : null
networksModel: popup.store.allNetworksModel networksModel: popup.store.allNetworksModel
currentCurrencySymbol: d.currencyStore.currentCurrencySymbol currentCurrencySymbol: d.currencyStore.currentCurrencySymbol
visible: (!!d.selectedHolding && d.selectedHoldingType !== Constants.HoldingType.Unknown) || visible: (!!d.selectedHolding && d.selectedHoldingType !== Constants.TokenType.Unknown) ||
(!!d.hoveredHolding && d.hoveredHoldingType !== Constants.HoldingType.Unknown) (!!d.hoveredHolding && d.hoveredHoldingType !== Constants.TokenType.Unknown)
onItemSelected: { onItemSelected: {
d.setSelectedHoldingId(holdingId, holdingType) d.setSelectedHoldingId(holdingId, holdingType)
} }
@ -408,7 +409,7 @@ StatusDialog {
if(hovered) { if(hovered) {
d.setHoveredHoldingId(symbol, holdingType) d.setHoveredHoldingId(symbol, holdingType)
} else { } else {
d.setHoveredHoldingId("", Constants.HoldingType.Unknown) d.setHoveredHoldingId("", Constants.TokenType.Unknown)
} }
} }
} }

View File

@ -54,8 +54,8 @@ Item {
id: d id: d
// Internal management properties and signals: // Internal management properties and signals:
readonly property var holdingTypes: onlyAssets ? readonly property var holdingTypes: onlyAssets ?
[Constants.HoldingType.Asset] : [Constants.TokenType.ERC20] :
[Constants.HoldingType.Asset, Constants.HoldingType.Collectible] [Constants.TokenType.ERC20, Constants.TokenType.ERC721]
readonly property var tabsModel: onlyAssets ? readonly property var tabsModel: onlyAssets ?
[qsTr("Assets")] : [qsTr("Assets")] :
@ -66,15 +66,15 @@ Item {
}) })
function isAsset(type) { function isAsset(type) {
return type === Constants.HoldingType.Asset return type === Constants.TokenType.ERC20
} }
property int browsingHoldingType: Constants.HoldingType.Asset property int browsingHoldingType: Constants.TokenType.ERC20
readonly property bool isCurrentBrowsingTypeAsset: isAsset(browsingHoldingType) readonly property bool isCurrentBrowsingTypeAsset: isAsset(browsingHoldingType)
readonly property bool isBrowsingCollection: !isCurrentBrowsingTypeAsset && !!collectiblesModel && collectiblesModel.currentCollectionUid !== "" readonly property bool isBrowsingCollection: !isCurrentBrowsingTypeAsset && !!collectiblesModel && collectiblesModel.currentCollectionUid !== ""
property string currentBrowsingCollectionName property string currentBrowsingCollectionName
property var currentHoldingType: Constants.HoldingType.Unknown property var currentHoldingType: Constants.TokenType.Unknown
property string searchText property string searchText
readonly property string assetSymbolByAddress: isCurrentBrowsingTypeAsset ? "": root.searchAssetSymbolByAddressFn(searchText) readonly property string assetSymbolByAddress: isCurrentBrowsingTypeAsset ? "": root.searchAssetSymbolByAddressFn(searchText)
@ -298,8 +298,8 @@ Item {
} }
onTokenSelected: { onTokenSelected: {
holdingItemSelector.selectedItem = selectedToken holdingItemSelector.selectedItem = selectedToken
d.currentHoldingType = Constants.HoldingType.Asset d.currentHoldingType = Constants.TokenType.ERC20
root.itemSelected(selectedToken.symbol, Constants.HoldingType.Asset) root.itemSelected(selectedToken.symbol, Constants.TokenType.ERC20)
holdingItemSelector.comboBoxControl.popup.close() holdingItemSelector.comboBoxControl.popup.close()
} }
} }
@ -316,8 +316,8 @@ Item {
root.collectiblesModel.currentCollectionUid = collectionUid root.collectiblesModel.currentCollectionUid = collectionUid
} else { } else {
holdingItemSelector.selectedItem = selectedItem holdingItemSelector.selectedItem = selectedItem
d.currentHoldingType = Constants.HoldingType.Collectible d.currentHoldingType = Constants.TokenType.ERC721
root.itemSelected(selectedItem.uid, Constants.HoldingType.Collectible) root.itemSelected(selectedItem.uid, Constants.TokenType.ERC721)
holdingItemSelector.comboBoxControl.popup.close() holdingItemSelector.comboBoxControl.popup.close()
} }
} }

View File

@ -25,10 +25,10 @@ Item {
return "" return ""
} }
property bool onlyAssets: false property bool onlyAssets: false
property int browsingHoldingType: Constants.HoldingType.Asset property int browsingHoldingType: Constants.TokenType.ERC20
onVisibleChanged: { onVisibleChanged: {
if(!visible) if(!visible && root.collectibles)
root.collectibles.currentCollectionUid = "" root.collectibles.currentCollectionUid = ""
} }
@ -46,8 +46,8 @@ Item {
// Internal management properties and signals: // Internal management properties and signals:
readonly property var holdingTypes: onlyAssets ? readonly property var holdingTypes: onlyAssets ?
[Constants.HoldingType.Asset] : [Constants.TokenType.ERC20] :
[Constants.HoldingType.Asset, Constants.HoldingType.Collectible] [Constants.TokenType.ERC20, Constants.TokenType.ERC721]
readonly property var tabsModel: onlyAssets ? readonly property var tabsModel: onlyAssets ?
[qsTr("Assets")] : [qsTr("Assets")] :
@ -128,9 +128,9 @@ Item {
width: parent.width width: parent.width
height: tokenList.contentHeight height: tokenList.contentHeight
header: root.browsingHoldingType === Constants.HoldingType.Asset ? tokenHeader : collectibleHeader header: root.browsingHoldingType === Constants.TokenType.ERC20 ? tokenHeader : collectibleHeader
model: root.browsingHoldingType === Constants.HoldingType.Asset ? tokensModel : collectiblesModel model: root.browsingHoldingType === Constants.TokenType.ERC20 ? tokensModel : collectiblesModel
delegate: root.browsingHoldingType === Constants.HoldingType.Asset ? tokenDelegate : collectiblesDelegate delegate: root.browsingHoldingType === Constants.TokenType.ERC20 ? tokenDelegate : collectiblesDelegate
} }
} }
} }
@ -171,19 +171,19 @@ Item {
TokenBalancePerChainDelegate { TokenBalancePerChainDelegate {
width: ListView.view.width width: ListView.view.width
balancesModel: LeftJoinModel { balancesModel: LeftJoinModel {
leftModel: balances leftModel: model.balances
rightModel: root.networksModel rightModel: root.networksModel
joinRole: "chainId" joinRole: "chainId"
} }
onTokenSelected: root.tokenSelected(symbol, Constants.HoldingType.Asset) onTokenSelected: root.tokenSelected(symbol, Constants.TokenType.ERC20)
onTokenHovered: root.tokenHovered(symbol, Constants.HoldingType.Asset, hovered) onTokenHovered: root.tokenHovered(symbol, Constants.TokenType.ERC20, hovered)
} }
} }
Component { Component {
id: tokenHeader id: tokenHeader
SearchBoxWithRightIcon { SearchBoxWithRightIcon {
showTopBorder: !root.onlyAssets showTopBorder: !root.onlyAssets
width: parent.width width: ListView.view.width
placeholderText: qsTr("Search for token or enter token address") placeholderText: qsTr("Search for token or enter token address")
onTextChanged: Qt.callLater(d.updateAssetSearchText, text) onTextChanged: Qt.callLater(d.updateAssetSearchText, text)
} }
@ -192,13 +192,13 @@ Item {
id: collectiblesDelegate id: collectiblesDelegate
CollectibleNestedDelegate { CollectibleNestedDelegate {
width: ListView.view.width width: ListView.view.width
onItemHovered: root.tokenHovered(selectedItem.uid, Constants.HoldingType.Collectible, hovered) onItemHovered: root.tokenHovered(selectedItem.uid, Constants.TokenType.ERC721, hovered)
onItemSelected: { onItemSelected: {
if (isCollection) { if (isCollection) {
d.currentBrowsingCollectionName = collectionName d.currentBrowsingCollectionName = collectionName
root.collectibles.currentCollectionUid = collectionUid root.collectibles.currentCollectionUid = collectionUid
} else { } else {
root.tokenSelected(selectedItem.uid, Constants.HoldingType.Collectible) root.tokenSelected(selectedItem.uid, Constants.TokenType.ERC721)
} }
} }
} }

View File

@ -204,7 +204,7 @@ Item {
preSelectedRecipient: root.store.stickersStore.getStickersMarketAddress() preSelectedRecipient: root.store.stickersStore.getStickersMarketAddress()
preDefinedAmountToSend: LocaleUtils.numberToLocaleString(parseFloat(price)) preDefinedAmountToSend: LocaleUtils.numberToLocaleString(parseFloat(price))
preSelectedHoldingID: JSON.parse(root.store.stickersStore.getStatusToken()).symbol preSelectedHoldingID: JSON.parse(root.store.stickersStore.getStatusToken()).symbol
preSelectedHoldingType: Constants.HoldingType.Asset preSelectedHoldingType: Constants.TokenType.ERC20
sendTransaction: function() { sendTransaction: function() {
if(bestRoutes.count === 1) { if(bestRoutes.count === 1) {
let path = bestRoutes.firstItem() let path = bestRoutes.firstItem()

View File

@ -73,7 +73,7 @@ ModalPopup {
preSelectedRecipient: stickerPackDetailsPopup.store.stickersStore.getStickersMarketAddress() preSelectedRecipient: stickerPackDetailsPopup.store.stickersStore.getStickersMarketAddress()
preDefinedAmountToSend: LocaleUtils.numberToLocaleString(parseFloat(price)) preDefinedAmountToSend: LocaleUtils.numberToLocaleString(parseFloat(price))
preSelectedHoldingID: JSON.parse(stickerPackDetailsPopup.store.stickersStore.getStatusToken()).symbol preSelectedHoldingID: JSON.parse(stickerPackDetailsPopup.store.stickersStore.getStatusToken()).symbol
preSelectedHoldingType: Constants.HoldingType.Asset preSelectedHoldingType: Constants.TokenType.ERC20
sendTransaction: function() { sendTransaction: function() {
if(bestRoutes.count === 1) { if(bestRoutes.count === 1) {
let path = bestRoutes.firstItem() let path = bestRoutes.firstItem()

View File

@ -140,9 +140,9 @@ QtObject {
} }
function getHolding(holdingId, holdingType) { function getHolding(holdingId, holdingType) {
if (holdingType === Constants.HoldingType.Asset) { if (holdingType === Constants.TokenType.ERC20) {
return getAsset(selectedSenderAccount.assets, holdingId) return getAsset(selectedSenderAccount.assets, holdingId)
} else if (holdingType === Constants.HoldingType.Collectible) { } else if (holdingType === Constants.TokenType.ERC721) {
return getCollectible(holdingId) return getCollectible(holdingId)
} else { } else {
return {} return {}
@ -150,9 +150,9 @@ QtObject {
} }
function getSelectorHolding(holdingId, holdingType) { function getSelectorHolding(holdingId, holdingType) {
if (holdingType === Constants.HoldingType.Asset) { if (holdingType === Constants.TokenType.ERC20) {
return getAsset(selectedSenderAccount.assets, holdingId) return getAsset(selectedSenderAccount.assets, holdingId)
} else if (holdingType === Constants.HoldingType.Collectible) { } else if (holdingType === Constants.TokenType.ERC721) {
return getSelectorCollectible(holdingId) return getSelectorCollectible(holdingId)
} else { } else {
return {} return {}
@ -176,9 +176,9 @@ QtObject {
} }
function holdingToSelectorHolding(holding, holdingType) { function holdingToSelectorHolding(holding, holdingType) {
if (holdingType === Constants.HoldingType.Asset) { if (holdingType === Constants.TokenType.ERC20) {
return assetToSelectorAsset(holding) return assetToSelectorAsset(holding)
} else if (holdingType === Constants.HoldingType.Collectible) { } else if (holdingType === Constants.TokenType.ERC721) {
return collectibleToSelectorCollectible(holding) return collectibleToSelectorCollectible(holding)
} else { } else {
return {} return {}

View File

@ -1057,11 +1057,14 @@ QtObject {
Dismissed = 4 Dismissed = 4
} }
// these are in sync with app_service/common/types.nim
enum TokenType { enum TokenType {
Unknown = 0, Native = 0,
ERC20 = 1, // Asset ERC20 = 1, // Asset
ERC721 = 2, // Collectible ERC721 = 2, // Collectible
ENS = 3 ERC1155 = 3,
Unknown = 4,
ENS = 5
} }
enum TokenPrivilegesLevel { enum TokenPrivilegesLevel {
@ -1256,10 +1259,6 @@ QtObject {
Image = 1 Image = 1
} }
enum HoldingType {
Unknown, Asset, Collectible
}
enum UrlUnfurlingMode { enum UrlUnfurlingMode {
UrlUnfurlingModeAlwaysAsk = 1, UrlUnfurlingModeAlwaysAsk = 1,
UrlUnfurlingModeEnableAll = 2, UrlUnfurlingModeEnableAll = 2,