fest(@desktop/wallet): Update Desktop UI to correctly call the router and send

fixes #13797
This commit is contained in:
Khushboo Mehta 2024-03-05 10:27:40 +01:00 committed by Khushboo-dev-cpp
parent da226b75aa
commit 3118931ab8
20 changed files with 141 additions and 48 deletions

View File

@ -4,7 +4,8 @@ import options
import backend/collectibles as backend import backend/collectibles as backend
import collectible_trait_model import collectible_trait_model
import collectible_ownership_model import collectible_ownership_model
import ../../../app_service/service/community_tokens/dto/community_token import app_service/service/community_tokens/dto/community_token
import app_service/common/types
const invalidTimestamp* = high(int) const invalidTimestamp* = high(int)
@ -28,7 +29,7 @@ QtObject:
ownership: OwnershipModel ownership: OwnershipModel
generatedId: string generatedId: string
generatedCollectionId: string generatedCollectionId: string
tokenType: TokenType
proc setup(self: CollectiblesEntry) = proc setup(self: CollectiblesEntry) =
self.QObject.setup self.QObject.setup
@ -56,7 +57,8 @@ QtObject:
traits:{self.traits}, traits:{self.traits},
ownership:{self.ownership}, ownership:{self.ownership},
generatedId:{self.generatedId}, generatedId:{self.generatedId},
generatedCollectionId:{self.generatedCollectionId} generatedCollectionId:{self.generatedCollectionId},
tokenType:{self.tokenType}
)""" )"""
proc hasCollectibleData(self: CollectiblesEntry): bool = proc hasCollectibleData(self: CollectiblesEntry): bool =
@ -308,6 +310,14 @@ QtObject:
QtProperty[string] networkIconUrl: QtProperty[string] networkIconUrl:
read = getNetworkIconURL read = getNetworkIconURL
proc tokenTypeChanged*(self: CollectiblesEntry) {.signal.}
proc getTokenType*(self: CollectiblesEntry): int {.slot.} =
return self.tokenType.int
QtProperty[int] tokenType:
read = getTokenType
notify = tokenTypeChanged
proc updateDataIfSameID*(self: CollectiblesEntry, update: backend.Collectible): bool = proc updateDataIfSameID*(self: CollectiblesEntry, update: backend.Collectible): bool =
if self.id != update.id: if self.id != update.id:
return false return false
@ -333,6 +343,14 @@ QtObject:
self.communityImageChanged() self.communityImageChanged()
return true return true
proc contractTypeToTokenType(contractType : ContractType): TokenType =
case contractType:
of ContractType.ContractTypeUnknown: return TokenType.Unknown
of ContractType.ContractTypeERC20: return TokenType.ERC20
of ContractType.ContractTypeERC721: return TokenType.ERC721
of ContractType.ContractTypeERC1155: return TokenType.ERC1155
else: return TokenType.Unknown
proc newCollectibleDetailsFullEntry*(data: backend.Collectible, extradata: ExtraData): CollectiblesEntry = proc newCollectibleDetailsFullEntry*(data: backend.Collectible, extradata: ExtraData): CollectiblesEntry =
new(result, delete) new(result, delete)
result.id = data.id result.id = data.id
@ -340,6 +358,7 @@ QtObject:
result.extradata = extradata result.extradata = extradata
result.generatedId = result.id.toString() result.generatedId = result.id.toString()
result.generatedCollectionId = result.id.contractID.toString() result.generatedCollectionId = result.id.contractID.toString()
result.tokenType = contractTypeToTokenType(data.contractType.get())
result.setup() result.setup()
proc newCollectibleDetailsBasicEntry*(id: backend.CollectibleUniqueID, extradata: ExtraData): CollectiblesEntry = proc newCollectibleDetailsBasicEntry*(id: backend.CollectibleUniqueID, extradata: ExtraData): CollectiblesEntry =

View File

@ -27,6 +27,7 @@ type
CommunityName CommunityName
CommunityColor CommunityColor
CommunityPrivilegesLevel CommunityPrivilegesLevel
TokenType
QtObject: QtObject:
type type
@ -147,6 +148,7 @@ QtObject:
CollectibleRole.CommunityName.int:"communityName", CollectibleRole.CommunityName.int:"communityName",
CollectibleRole.CommunityColor.int:"communityColor", CollectibleRole.CommunityColor.int:"communityColor",
CollectibleRole.CommunityPrivilegesLevel.int:"communityPrivilegesLevel", CollectibleRole.CommunityPrivilegesLevel.int:"communityPrivilegesLevel",
CollectibleRole.TokenType.int:"tokenType",
}.toTable }.toTable
method data(self: Model, index: QModelIndex, role: int): QVariant = method data(self: Model, index: QModelIndex, role: int): QVariant =
@ -197,6 +199,8 @@ QtObject:
result = newQVariant(item.getCommunityColor()) result = newQVariant(item.getCommunityColor())
of CollectibleRole.CommunityPrivilegesLevel: of CollectibleRole.CommunityPrivilegesLevel:
result = newQVariant(item.getCommunityPrivilegesLevel()) result = newQVariant(item.getCommunityPrivilegesLevel())
of CollectibleRole.TokenType:
result = newQVariant(item.getTokenType())
proc rowData(self: Model, index: int, column: string): string {.slot.} = proc rowData(self: Model, index: int, column: string): string {.slot.} =
if (index >= self.items.len): if (index >= self.items.len):

View File

@ -1,4 +1,5 @@
import strformat import strformat
import app_service/common/types
type type
Item* = object Item* = object
@ -10,6 +11,7 @@ type
collectionName: string collectionName: string
isCollection: bool isCollection: bool
communityId: string communityId: string
tokenType: TokenType
proc initItem*( proc initItem*(
id: string, id: string,
@ -20,6 +22,7 @@ proc initItem*(
collectionName: string, collectionName: string,
isCollection: bool, isCollection: bool,
communityId: string, communityId: string,
tokenType: TokenType
): Item = ): Item =
result.id = id result.id = id
result.chainId = chainId result.chainId = chainId
@ -28,7 +31,7 @@ proc initItem*(
result.collectionId = collectionId result.collectionId = collectionId
result.collectionName = collectionName result.collectionName = collectionName
result.isCollection = isCollection result.isCollection = isCollection
result.communityId = communityId result.tokenType = tokenType
proc `$`*(self: Item): string = proc `$`*(self: Item): string =
result = fmt"""CollectiblesNestedEntry( result = fmt"""CollectiblesNestedEntry(
@ -40,6 +43,7 @@ proc `$`*(self: Item): string =
collectionName: {self.collectionName}, collectionName: {self.collectionName},
isCollection: {self.isCollection}, isCollection: {self.isCollection},
communityId: {self.communityId}, communityId: {self.communityId},
tokenType: {self.tokenType},
]""" ]"""
proc getId*(self: Item): string = proc getId*(self: Item): string =
@ -65,3 +69,6 @@ proc getIsCollection*(self: Item): bool =
proc getCommunityId*(self: Item): string = proc getCommunityId*(self: Item): string =
return self.communityId return self.communityId
proc getTokenType*(self: Item): int =
return self.tokenType.int

View File

@ -16,6 +16,7 @@ type
CollectionName CollectionName
IsCollection IsCollection
CommunityId CommunityId
TokenType
QtObject: QtObject:
type type
@ -82,6 +83,7 @@ QtObject:
CollectiblesNestedRole.CollectionName.int:"collectionName", CollectiblesNestedRole.CollectionName.int:"collectionName",
CollectiblesNestedRole.IsCollection.int:"isCollection", CollectiblesNestedRole.IsCollection.int:"isCollection",
CollectiblesNestedRole.CommunityId.int:"communityId", CollectiblesNestedRole.CommunityId.int:"communityId",
CollectiblesNestedRole.TokenType.int:"tokenType",
}.toTable }.toTable
method data(self: Model, index: QModelIndex, role: int): QVariant = method data(self: Model, index: QModelIndex, role: int): QVariant =
@ -111,6 +113,8 @@ QtObject:
result = newQVariant(item.getIsCollection()) result = newQVariant(item.getIsCollection())
of CollectiblesNestedRole.CommunityId: of CollectiblesNestedRole.CommunityId:
result = newQVariant(item.getCommunityId()) result = newQVariant(item.getCommunityId())
of CollectiblesNestedRole.TokenType:
result = newQVariant(item.getTokenType())
proc rowData(self: Model, index: int, column: string): string {.slot.} = proc rowData(self: Model, index: int, column: string): string {.slot.} =
if (index >= self.items.len): if (index >= self.items.len):

View File

@ -1,5 +1,6 @@
import ./collectibles_entry as flat_item import ./collectibles_entry as flat_item
import ./collectibles_nested_item as nested_item import ./collectibles_nested_item as nested_item
import app_service/common/types
proc collectibleToCollectibleNestedItem*(flatItem: flat_item.CollectiblesEntry): nested_item.Item = proc collectibleToCollectibleNestedItem*(flatItem: flat_item.CollectiblesEntry): nested_item.Item =
return nested_item.initItem( return nested_item.initItem(
@ -10,7 +11,8 @@ proc collectibleToCollectibleNestedItem*(flatItem: flat_item.CollectiblesEntry):
flatItem.getCollectionIDAsString(), flatItem.getCollectionIDAsString(),
flatItem.getCollectionName(), flatItem.getCollectionName(),
false, false,
flatItem.getCommunityID() flatItem.getCommunityID(),
TokenType(flatItem.getTokenType())
) )
proc collectibleToCollectionNestedItem*(flatItem: flat_item.CollectiblesEntry): nested_item.Item = proc collectibleToCollectionNestedItem*(flatItem: flat_item.CollectiblesEntry): nested_item.Item =
@ -22,5 +24,6 @@ proc collectibleToCollectionNestedItem*(flatItem: flat_item.CollectiblesEntry):
flatItem.getCollectionIDAsString(), flatItem.getCollectionIDAsString(),
flatItem.getCollectionName(), flatItem.getCollectionName(),
true, true,
flatItem.getCommunityID() flatItem.getCommunityID(),
TokenType(flatItem.getTokenType())
) )

View File

@ -67,6 +67,7 @@ type TransactionBridgeDto* = object
hopTx*: TransactionDataDto hopTx*: TransactionDataDto
cbridgeTx*: TransactionDataDto cbridgeTx*: TransactionDataDto
eRC721TransferTx*: TransactionDataDto eRC721TransferTx*: TransactionDataDto
eRC1155TransferTx*: TransactionDataDto
proc `%`*(x: TransactionBridgeDto): JsonNode = proc `%`*(x: TransactionBridgeDto): JsonNode =
result = newJobject() result = newJobject()
@ -76,3 +77,4 @@ proc `%`*(x: TransactionBridgeDto): JsonNode =
result["hopTx"] = %x.hopTx result["hopTx"] = %x.hopTx
result["cbridgeTx"] = %x.cbridgeTx result["cbridgeTx"] = %x.cbridgeTx
result["eRC721TransferTx"] = %x.eRC721TransferTx result["eRC721TransferTx"] = %x.eRC721TransferTx
result["eRC1155TransferTx"] = %x.eRC1155TransferTx

View File

@ -312,6 +312,13 @@ type
totalTokenFees*: float totalTokenFees*: float
totalTime*: int totalTime*: int
proc `$`*(self: FeesDto): string =
return fmt"""FeesDto(
totalFeesInEth:{self.totalFeesInEth},
totalTokenFees:{self.totalTokenFees},
totalTime:{self.totalTime},
)"""
proc convertToFeesDto*(jsonObj: JsonNode): FeesDto = proc convertToFeesDto*(jsonObj: JsonNode): FeesDto =
result = FeesDto() result = FeesDto()
discard jsonObj.getProp("totalFeesInEth", result.totalFeesInEth) discard jsonObj.getProp("totalFeesInEth", result.totalFeesInEth)
@ -325,6 +332,14 @@ type
iconUrl*: string iconUrl*: string
amountOut*: UInt256 amountOut*: UInt256
proc `$`*(self: SendToNetwork): string =
return fmt"""SendToNetwork(
chainId:{self.chainId},
chainName:{self.chainName},
iconUrl:{self.iconUrl},
amountOut:{self.amountOut},
)"""
proc convertSendToNetwork*(jsonObj: JsonNode): SendToNetwork = proc convertSendToNetwork*(jsonObj: JsonNode): SendToNetwork =
result = SendToNetwork() result = SendToNetwork()
discard jsonObj.getProp("chainId", result.chainId) discard jsonObj.getProp("chainId", result.chainId)
@ -339,6 +354,14 @@ type
amountToReceive*: UInt256 amountToReceive*: UInt256
toNetworks*: seq[SendToNetwork] toNetworks*: seq[SendToNetwork]
proc `$`*(self: SuggestedRoutesDto): string =
return fmt"""SuggestedRoutesDto(
best:{self.best},
gasTimeEstimate:{self.gasTimeEstimate},
amountToReceive:{self.amountToReceive},
toNetworks:{self.toNetworks},
)"""
proc convertToSuggestedRoutesDto*(jsonObj: JsonNode): SuggestedRoutesDto = proc convertToSuggestedRoutesDto*(jsonObj: JsonNode): SuggestedRoutesDto =
result = SuggestedRoutesDto() result = SuggestedRoutesDto()
result.best = jsonObj["suggestedRoutes"]["best"].getElems().map(x => x.convertToTransactionPathDto()) result.best = jsonObj["suggestedRoutes"]["best"].getElems().map(x => x.convertToTransactionPathDto())

View File

@ -52,6 +52,7 @@ const SIGNAL_OWNER_TOKEN_SENT* = "ownerTokenSent"
const SIMPLE_TX_BRIDGE_NAME = "Transfer" const SIMPLE_TX_BRIDGE_NAME = "Transfer"
const HOP_TX_BRIDGE_NAME = "Hop" const HOP_TX_BRIDGE_NAME = "Hop"
const ERC721_TRANSFER_NAME = "ERC721Transfer" const ERC721_TRANSFER_NAME = "ERC721Transfer"
const ERC1155_TRANSFER_NAME = "ERC1155Transfer"
type TokenTransferMetadata* = object type TokenTransferMetadata* = object
tokenName*: string tokenName*: string
@ -264,6 +265,7 @@ QtObject:
var hopTx = TransactionDataDto() var hopTx = TransactionDataDto()
var cbridgeTx = TransactionDataDto() var cbridgeTx = TransactionDataDto()
var eRC721TransferTx = TransactionDataDto() var eRC721TransferTx = TransactionDataDto()
var eRC1155TransferTx = TransactionDataDto()
if(route.bridgeName == SIMPLE_TX_BRIDGE_NAME): if(route.bridgeName == SIMPLE_TX_BRIDGE_NAME):
path.transferTx = txData path.transferTx = txData
@ -281,6 +283,13 @@ QtObject:
eRC721TransferTx.recipient = parseAddress(to_addr).some eRC721TransferTx.recipient = parseAddress(to_addr).some
eRC721TransferTx.tokenID = stint.u256(tokenSymbol).some eRC721TransferTx.tokenID = stint.u256(tokenSymbol).some
path.eRC721TransferTx = eRC721TransferTx path.eRC721TransferTx = eRC721TransferTx
elif(route.bridgeName == ERC1155_TRANSFER_NAME):
eRC1155TransferTx = txData
eRC1155TransferTx.chainID = route.toNetwork.chainId.some
eRC1155TransferTx.recipient = parseAddress(to_addr).some
eRC1155TransferTx.tokenID = stint.u256(tokenSymbol).some
eRC1155TransferTx.amount = route.amountIn.some
path.eRC1155TransferTx = eRC1155TransferTx
else: else:
cbridgeTx = txData cbridgeTx = txData
cbridgeTx.chainID = route.toNetwork.chainId.some cbridgeTx.chainID = route.toNetwork.chainId.some
@ -310,6 +319,8 @@ QtObject:
let metadata = TokenTransferMetadata(tokenName: tokenName, isOwnerToken: isOwnerToken) let metadata = TokenTransferMetadata(tokenName: tokenName, isOwnerToken: isOwnerToken)
self.watchTransaction(hash.getStr, fromAddr, toAddr, $PendingTransactionTypeDto.WalletTransfer, $(%metadata), route.fromNetwork.chainID, track = false) self.watchTransaction(hash.getStr, fromAddr, toAddr, $PendingTransactionTypeDto.WalletTransfer, $(%metadata), route.fromNetwork.chainID, track = false)
proc isCollectiblesTransfer(self: Service, sendType: SendType): bool =
return sendType == ERC721Transfer or sendType == ERC1155Transfer
proc transferEth( proc transferEth(
self: Service, self: Service,
@ -374,7 +385,6 @@ QtObject:
isOwnerToken: bool isOwnerToken: bool
) = ) =
try: try:
let isERC721Transfer = sendType == ERC721Transfer
var paths: seq[TransactionBridgeDto] = @[] var paths: seq[TransactionBridgeDto] = @[]
var chainID = 0 var chainID = 0
@ -385,7 +395,7 @@ QtObject:
var tokenSym = tokenSymbol var tokenSym = tokenSymbol
let amountToSend = value.parse(Uint256) let amountToSend = value.parse(Uint256)
if isERC721Transfer: if self.isCollectiblesTransfer(sendType):
let contract_tokenId = tokenSym.split(":") let contract_tokenId = tokenSym.split(":")
if contract_tokenId.len == 2: if contract_tokenId.len == 2:
toAddress = parseAddress(contract_tokenId[0]) toAddress = parseAddress(contract_tokenId[0])
@ -468,7 +478,7 @@ QtObject:
chainID = selectedRoutes[0].fromNetwork.chainID chainID = selectedRoutes[0].fromNetwork.chainID
var tokenSymbol = "" var tokenSymbol = ""
if sendType == ERC721Transfer or sendType == ERC1155Transfer: if self.isCollectiblesTransfer(sendType):
tokenSymbol = assetKey tokenSymbol = assetKey
else: else:
let token = self.tokenService.getTokenBySymbolByTokensKey(assetKey) let token = self.tokenService.getTokenBySymbolByTokensKey(assetKey)
@ -514,7 +524,7 @@ QtObject:
proc suggestedRoutes*(self: Service, accountFrom: string, accountTo: string, amount: Uint256, token: string, disabledFromChainIDs, proc suggestedRoutes*(self: Service, accountFrom: string, accountTo: string, amount: Uint256, token: string, disabledFromChainIDs,
disabledToChainIDs, preferredChainIDs: seq[int], sendType: SendType, lockedInAmounts: string): SuggestedRoutesDto = disabledToChainIDs, preferredChainIDs: seq[int], sendType: SendType, lockedInAmounts: string): SuggestedRoutesDto =
var tokenId: string = "" var tokenId: string = ""
if sendType == ERC721Transfer: if self.isCollectiblesTransfer(sendType):
tokenId = token tokenId = token
else: else:
let token = self.tokenService.getTokenBySymbolByTokensKey(token) let token = self.tokenService.getTokenBySymbolByTokensKey(token)

View File

@ -4,6 +4,13 @@ import community_tokens_types
include app_service/common/json_utils include app_service/common/json_utils
# follows the ContractType declared in status go status-go/services/wallet/common/const.go
type ContractType* {.pure.} = enum
ContractTypeUnknown = 0,
ContractTypeERC20 = 1,
ContractTypeERC721 = 2,
ContractTypeERC1155 = 3
type type
# Mirrors services/wallet/thirdparty/collectible_types.go ContractID # Mirrors services/wallet/thirdparty/collectible_types.go ContractID
ContractID* = ref object of RootObj ContractID* = ref object of RootObj
@ -63,6 +70,7 @@ type
isFirst*: Option[bool] isFirst*: Option[bool]
latestTxHash*: Option[string] latestTxHash*: Option[string]
receivedAmount*: Option[float64] receivedAmount*: Option[float64]
contractType*: Option[ContractType]
# Mirrors services/wallet/thirdparty/collectible_types.go TokenBalance # Mirrors services/wallet/thirdparty/collectible_types.go TokenBalance
CollectibleBalance* = ref object CollectibleBalance* = ref object
@ -364,6 +372,11 @@ proc fromJson*(t: JsonNode, T: typedesc[Collectible]): Collectible {.inline.} =
result.receivedAmount = some(receivedAmountNode.getFloat()) result.receivedAmount = some(receivedAmountNode.getFloat())
else: else:
result.receivedAmount = none(float64) result.receivedAmount = none(float64)
let contractTypeNode = t{"contract_type"}
if contractTypeNode != nil and contractTypeNode.kind != JNull:
result.contractType = some(ContractType(contractTypeNode.getInt()))
else:
result.contractType = none(ContractType)
proc toIds(self: seq[Collectible]): seq[CollectibleUniqueID] = proc toIds(self: seq[Collectible]): seq[CollectibleUniqueID] =
result = @[] result = @[]

View File

@ -38,8 +38,8 @@ ColumnLayout {
property bool isUpdating: false // Indicates if the collectibles list is being updated property bool isUpdating: false // Indicates if the collectibles list is being updated
property bool isError: false // Indicates an error occurred while updating/fetching the collectibles list property bool isError: false // Indicates an error occurred while updating/fetching the collectibles list
signal collectibleClicked(int chainId, string contractAddress, string tokenId, string uid) signal collectibleClicked(int chainId, string contractAddress, string tokenId, string uid, int tokenType)
signal sendRequested(string symbol) signal sendRequested(string symbol, int tokenType)
signal receiveRequested(string symbol) signal receiveRequested(string symbol)
signal switchToCommunityRequested(string communityId) signal switchToCommunityRequested(string communityId)
signal manageTokensRequested() signal manageTokensRequested()
@ -462,11 +462,12 @@ ColumnLayout {
communityName: model.communityName ?? "" communityName: model.communityName ?? ""
communityImage: model.communityImage ?? "" communityImage: model.communityImage ?? ""
onClicked: root.collectibleClicked(model.chainId, model.contractAddress, model.tokenId, model.symbol) onClicked: root.collectibleClicked(model.chainId, model.contractAddress, model.tokenId, model.symbol, model.tokenType)
onRightClicked: { onRightClicked: {
Global.openMenu(tokenContextMenu, this, Global.openMenu(tokenContextMenu, this,
{symbol: model.symbol, tokenName: model.name, tokenImage: model.imageUrl, {symbol: model.symbol, tokenName: model.name, tokenImage: model.imageUrl,
communityId: model.communityId, communityName: model.communityName, communityImage: model.communityImage}) communityId: model.communityId, communityName: model.communityName,
communityImage: model.communityImage, tokenType: model.tokenType})
} }
onSwitchToCommunityRequested: (communityId) => root.switchToCommunityRequested(communityId) onSwitchToCommunityRequested: (communityId) => root.switchToCommunityRequested(communityId)
} }
@ -483,13 +484,14 @@ ColumnLayout {
property string communityId property string communityId
property string communityName property string communityName
property string communityImage property string communityImage
property int tokenType
StatusAction { StatusAction {
enabled: root.sendEnabled enabled: root.sendEnabled
visibleOnDisabled: true visibleOnDisabled: true
icon.name: "send" icon.name: "send"
text: qsTr("Send") text: qsTr("Send")
onTriggered: root.sendRequested(symbol) onTriggered: root.sendRequested(symbol, tokenType)
} }
StatusAction { StatusAction {
icon.name: "receive" icon.name: "receive"

View File

@ -175,7 +175,7 @@ RightTabBaseView {
filterVisible: filterButton.checked filterVisible: filterButton.checked
onCollectibleClicked: { onCollectibleClicked: {
RootStore.collectiblesStore.getDetailedCollectible(chainId, contractAddress, tokenId) RootStore.collectiblesStore.getDetailedCollectible(chainId, contractAddress, tokenId)
RootStore.setCurrentViewedHolding(uid, Constants.TokenType.ERC721) RootStore.setCurrentViewedHolding(uid, tokenType)
d.detailedCollectibleActivityController.resetFilter() d.detailedCollectibleActivityController.resetFilter()
d.detailedCollectibleActivityController.setFilterAddressesJson(JSON.stringify(RootStore.addressFilters.split(":")), RootStore.showAllAccounts) d.detailedCollectibleActivityController.setFilterAddressesJson(JSON.stringify(RootStore.addressFilters.split(":")), RootStore.showAllAccounts)
d.detailedCollectibleActivityController.setFilterChainsJson(JSON.stringify([chainId]), false) d.detailedCollectibleActivityController.setFilterChainsJson(JSON.stringify([chainId]), false)
@ -184,10 +184,12 @@ RightTabBaseView {
stack.currentIndex = 1 stack.currentIndex = 1
} }
onSendRequested: (symbol) => { onSendRequested: (symbol, tokenType) => {
root.sendModal.preSelectedSendType = Constants.SendType.Transfer
root.sendModal.preSelectedHoldingID = symbol root.sendModal.preSelectedHoldingID = symbol
root.sendModal.preSelectedHoldingType = Constants.TokenType.ERC721 root.sendModal.preSelectedHoldingType = tokenType
root.sendModal.preSelectedSendType = tokenType === Constants.TokenType.ERC721 ?
Constants.SendType.ERC721Transfer:
Constants.SendType.ERC1155Transfer
root.sendModal.onlyAssets = false root.sendModal.onlyAssets = false
root.sendModal.open() root.sendModal.open()
} }

View File

@ -60,7 +60,7 @@ StatusDialog {
if(!!popup.preSelectedAccount && !!holdingSelector.selectedItem if(!!popup.preSelectedAccount && !!holdingSelector.selectedItem
&& recipientLoader.ready && amountToSendInput.inputNumberValid) { && recipientLoader.ready && amountToSendInput.inputNumberValid) {
popup.isLoading = true popup.isLoading = true
popup.store.suggestedRoutes(d.isERC721Transfer ? "1" : amountToSendInput.cryptoValueToSend) popup.store.suggestedRoutes(d.isCollectiblesTransfer ? "1" : amountToSendInput.cryptoValueToSend)
} }
}) })
@ -73,7 +73,7 @@ StatusDialog {
popup.preSelectedSendType === Constants.SendType.StickersBuy popup.preSelectedSendType === Constants.SendType.StickersBuy
readonly property var currencyStore: store.currencyStore readonly property var currencyStore: store.currencyStore
readonly property int errorType: !amountToSendInput.input.valid && !isERC721Transfer ? Constants.SendAmountExceedsBalance : readonly property int errorType: !amountToSendInput.input.valid && (!isCollectiblesTransfer) ? Constants.SendAmountExceedsBalance :
(popup.bestRoutes && popup.bestRoutes.count === 0 && (popup.bestRoutes && popup.bestRoutes.count === 0 &&
!!amountToSendInput.input.text && recipientLoader.ready && !popup.isLoading) ? !!amountToSendInput.input.text && recipientLoader.ready && !popup.isLoading) ?
Constants.NoRoute : Constants.NoError Constants.NoRoute : Constants.NoError
@ -88,7 +88,8 @@ StatusDialog {
property double totalFeesInFiat property double totalFeesInFiat
property double totalAmountToReceive property double totalAmountToReceive
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 isCollectiblesTransfer: store.sendType === Constants.SendType.ERC721Transfer ||
store.sendType === Constants.SendType.ERC1155Transfer
property var selectedHolding: null property var selectedHolding: null
property var selectedHoldingType: Constants.TokenType.Unknown property var selectedHoldingType: Constants.TokenType.Unknown
readonly property bool isSelectedHoldingValidAsset: !!selectedHolding && selectedHoldingType === Constants.TokenType.ERC20 readonly property bool isSelectedHoldingValidAsset: !!selectedHolding && selectedHoldingType === Constants.TokenType.ERC20
@ -126,8 +127,10 @@ StatusDialog {
store.setSendType(Constants.SendType.Transfer) store.setSendType(Constants.SendType.Transfer)
store.setSelectedAssetKey(selectedHolding.tokensKey) store.setSelectedAssetKey(selectedHolding.tokensKey)
store.setSelectedTokenIsOwnerToken(false) store.setSelectedTokenIsOwnerToken(false)
} else if (d.selectedHoldingType === Constants.TokenType.ERC721) { } else if (d.selectedHoldingType === Constants.TokenType.ERC721 ||
store.setSendType(Constants.SendType.ERC721Transfer) d.selectedHoldingType === Constants.TokenType.ERC1155) {
let sendType = d.selectedHoldingType === Constants.TokenType.ERC721 ? Constants.SendType.ERC721Transfer : Constants.SendType.ERC1155Transfer
store.setSendType(sendType)
amountToSendInput.input.text = 1 amountToSendInput.input.text = 1
store.setSelectedAssetKey(selectedHolding.contractAddress+":"+selectedHolding.tokenId) store.setSelectedAssetKey(selectedHolding.contractAddress+":"+selectedHolding.tokenId)
store.setRouteEnabledFromChains(selectedHolding.chainId) store.setRouteEnabledFromChains(selectedHolding.chainId)
@ -163,7 +166,7 @@ StatusDialog {
store.setSendType(popup.preSelectedSendType) store.setSendType(popup.preSelectedSendType)
} }
if ((popup.preSelectedHoldingType > Constants.TokenType.Native) && if ((popup.preSelectedHoldingType > Constants.TokenType.Native) &&
(popup.preSelectedHoldingType < Constants.TokenType.ERC1155)) { (popup.preSelectedHoldingType < Constants.TokenType.Unknown)) {
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)
@ -285,7 +288,7 @@ StatusDialog {
Layout.maximumWidth: 300 Layout.maximumWidth: 300
Layout.alignment: Qt.AlignVCenter | Qt.AlignRight Layout.alignment: Qt.AlignVCenter | Qt.AlignRight
Layout.preferredHeight: 22 Layout.preferredHeight: 22
visible: d.isSelectedHoldingValidAsset || d.isHoveredHoldingValidAsset && !d.isERC721Transfer visible: d.isSelectedHoldingValidAsset || d.isHoveredHoldingValidAsset && !d.isCollectiblesTransfer
title: { title: {
if(d.isHoveredHoldingValidAsset && !!d.hoveredHolding.symbol) { if(d.isHoveredHoldingValidAsset && !!d.hoveredHolding.symbol) {
const input = amountToSendInput.inputIsFiat ? d.hoveredHolding.currentCurrencyBalance : d.hoveredHolding.currentBalance const input = amountToSendInput.inputIsFiat ? d.hoveredHolding.currentCurrencyBalance : d.hoveredHolding.currentBalance
@ -314,7 +317,7 @@ StatusDialog {
} }
} }
RowLayout { RowLayout {
visible: d.isSelectedHoldingValidAsset && !d.isERC721Transfer visible: d.isSelectedHoldingValidAsset && !d.isCollectiblesTransfer
AmountToSend { AmountToSend {
id: amountToSendInput id: amountToSendInput
@ -372,7 +375,7 @@ StatusDialog {
id: recipientLoader id: recipientLoader
Layout.fillWidth: true Layout.fillWidth: true
store: popup.store store: popup.store
isERC721Transfer: d.isERC721Transfer isCollectiblesTransfer: d.isCollectiblesTransfer
isBridgeTx: d.isBridgeTx isBridgeTx: d.isBridgeTx
interactive: popup.interactive interactive: popup.interactive
selectedAsset: d.selectedHolding selectedAsset: d.selectedHolding
@ -472,7 +475,7 @@ StatusDialog {
errorType: d.errorType errorType: d.errorType
isLoading: popup.isLoading isLoading: popup.isLoading
isBridgeTx: d.isBridgeTx isBridgeTx: d.isBridgeTx
isERC721Transfer: d.isERC721Transfer isCollectiblesTransfer: d.isCollectiblesTransfer
bestRoutes: popup.bestRoutes bestRoutes: popup.bestRoutes
totalFeesInFiat: d.totalFeesInFiat totalFeesInFiat: d.totalFeesInFiat
} }

View File

@ -355,8 +355,8 @@ Item {
root.collectiblesModel.currentCollectionUid = collectionUid root.collectiblesModel.currentCollectionUid = collectionUid
} else { } else {
holdingItemSelector.selectedItem = selectedItem holdingItemSelector.selectedItem = selectedItem
d.currentHoldingType = Constants.TokenType.ERC721 d.currentHoldingType = tokenType
root.itemSelected(selectedItem.uid, Constants.TokenType.ERC721) root.itemSelected(selectedItem.uid, tokenType)
holdingItemSelector.comboBoxControl.popup.close() holdingItemSelector.comboBoxControl.popup.close()
} }
} }

View File

@ -28,7 +28,7 @@ Item {
property bool errorMode: advancedNetworkRoutingPage.errorMode property bool errorMode: advancedNetworkRoutingPage.errorMode
property bool interactive: true property bool interactive: true
property bool isBridgeTx: false property bool isBridgeTx: false
property bool isERC721Transfer: false property bool isCollectiblesTransfer: false
property var toNetworksList property var toNetworksList
property int errorType: Constants.NoError property int errorType: Constants.NoError
property var bestRoutes property var bestRoutes
@ -48,7 +48,7 @@ Item {
id: tabBar id: tabBar
anchors.top: parent.top anchors.top: parent.top
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
visible: !root.isERC721Transfer visible: !root.isCollectiblesTransfer
StatusSwitchTabButton { StatusSwitchTabButton {
text: qsTr("Simple") text: qsTr("Simple")
} }
@ -62,12 +62,12 @@ Item {
StackLayout { StackLayout {
id: stackLayout id: stackLayout
anchors.top: !root.isERC721Transfer ? tabBar.bottom: parent.top anchors.top: !root.isCollectiblesTransfer ? tabBar.bottom: parent.top
anchors.topMargin: !root.isERC721Transfer ? Style.current.bigPadding: 0 anchors.topMargin: !root.isCollectiblesTransfer ? Style.current.bigPadding: 0
height: currentIndex == 0 ? networksSimpleRoutingPage.height + networksSimpleRoutingPage.anchors.margins + Style.current.bigPadding: height: currentIndex == 0 ? networksSimpleRoutingPage.height + networksSimpleRoutingPage.anchors.margins + Style.current.bigPadding:
advancedNetworkRoutingPage.height + advancedNetworkRoutingPage.anchors.margins + Style.current.bigPadding advancedNetworkRoutingPage.height + advancedNetworkRoutingPage.anchors.margins + Style.current.bigPadding
width: parent.width width: parent.width
currentIndex: root.isERC721Transfer ? 0: tabBar.currentIndex === 0 ? 0 : 1 currentIndex: root.isCollectiblesTransfer ? 0: tabBar.currentIndex === 0 ? 0 : 1
Rectangle { Rectangle {
id: simple id: simple
@ -80,7 +80,7 @@ Item {
anchors.right: parent.right anchors.right: parent.right
anchors.margins: Style.current.padding anchors.margins: Style.current.padding
isBridgeTx: root.isBridgeTx isBridgeTx: root.isBridgeTx
isERC721Transfer: root.isERC721Transfer isCollectiblesTransfer: root.isCollectiblesTransfer
minReceiveCryptoDecimals: root.minReceiveCryptoDecimals minReceiveCryptoDecimals: root.minReceiveCryptoDecimals
isLoading: root.isLoading isLoading: root.isLoading
store: root.store store: root.store

View File

@ -19,7 +19,7 @@ RowLayout {
property int minReceiveCryptoDecimals: 0 property int minReceiveCryptoDecimals: 0
property bool isLoading: false property bool isLoading: false
property bool isBridgeTx: false property bool isBridgeTx: false
property bool isERC721Transfer: false property bool isCollectiblesTransfer: false
property var selectedAccount property var selectedAccount
property var toNetworksList property var toNetworksList
property var weiToEth: function(wei) {} property var weiToEth: function(wei) {}
@ -99,7 +99,7 @@ RowLayout {
implicitWidth: 410 implicitWidth: 410
title: model.chainName title: model.chainName
subTitle: { subTitle: {
if(root.isERC721Transfer) if(root.isCollectiblesTransfer)
return "" return ""
let amountOut = root.weiToEth(model.amountOut) let amountOut = root.weiToEth(model.amountOut)
return root.formatCurrencyAmount(amountOut, root.selectedSymbol, {"minDecimals": root.minReceiveCryptoDecimals}) return root.formatCurrencyAmount(amountOut, root.selectedSymbol, {"minDecimals": root.minReceiveCryptoDecimals})

View File

@ -16,7 +16,7 @@ Loader {
id: root id: root
property var store property var store
property bool isERC721Transfer property bool isCollectiblesTransfer
property bool isBridgeTx: false property bool isBridgeTx: false
property bool interactive: true property bool interactive: true
property var selectedAsset property var selectedAsset
@ -67,7 +67,7 @@ Loader {
} }
// set preferred chains // set preferred chains
if(!isERC721Transfer) { if(!isCollectiblesTransfer) {
if(root.isBridgeTx) if(root.isBridgeTx)
root.store.setAllNetworksAsRoutePreferredChains() root.store.setAllNetworksAsRoutePreferredChains()
else else
@ -98,7 +98,7 @@ Loader {
function evaluateAndSetPreferredChains() { function evaluateAndSetPreferredChains() {
let address = !!root.item.input && !!root.store.plainText(root.item.input.text) ? root.store.plainText(root.item.input.text): "" let address = !!root.item.input && !!root.store.plainText(root.item.input.text) ? root.store.plainText(root.item.input.text): ""
let result = store.splitAndFormatAddressPrefix(address, !root.isBridgeTx && !isERC721Transfer) let result = store.splitAndFormatAddressPrefix(address, !root.isBridgeTx && !isCollectiblesTransfer)
if(!!result.address) { if(!!result.address) {
root.addressText = result.address root.addressText = result.address
if(!!root.item.input) if(!!root.item.input)

View File

@ -224,7 +224,7 @@ Item {
numItems: isCollection ? (!!communityId ? numItems: isCollection ? (!!communityId ?
root.collectibles.getNumberOfCollectiblesInCommunity(communityId) : root.collectibles.getNumberOfCollectiblesInCommunity(communityId) :
root.collectibles.getNumberOfCollectiblesInCollection(collectionUid)) : 0 root.collectibles.getNumberOfCollectiblesInCollection(collectionUid)) : 0
onItemHovered: root.tokenHovered(selectedItem.uid, Constants.TokenType.ERC721, hovered) onItemHovered: root.tokenHovered(selectedItem.uid, tokenType, hovered)
onItemSelected: { onItemSelected: {
if (isCollection) { if (isCollection) {
d.currentBrowsingCollectionName = collectionName d.currentBrowsingCollectionName = collectionName
@ -233,7 +233,7 @@ Item {
else else
root.collectibles.currentCollectionUid = collectionUid root.collectibles.currentCollectionUid = collectionUid
} else { } else {
root.tokenSelected(selectedItem.uid, Constants.TokenType.ERC721) root.tokenSelected(selectedItem.uid, tokenType)
} }
} }
} }

View File

@ -135,7 +135,7 @@ QtObject {
function getHolding(holdingId, holdingType) { function getHolding(holdingId, holdingType) {
if (holdingType === Constants.TokenType.ERC20) { if (holdingType === Constants.TokenType.ERC20) {
return getAsset(processedAssetsModel, holdingId) return getAsset(processedAssetsModel, holdingId)
} else if (holdingType === Constants.TokenType.ERC721) { } else if (holdingType === Constants.TokenType.ERC721 || holdingType === Constants.TokenType.ERC1155) {
return getCollectible(holdingId) return getCollectible(holdingId)
} else { } else {
return {} return {}
@ -145,7 +145,7 @@ QtObject {
function getSelectorHolding(holdingId, holdingType) { function getSelectorHolding(holdingId, holdingType) {
if (holdingType === Constants.TokenType.ERC20) { if (holdingType === Constants.TokenType.ERC20) {
return getAsset(processedAssetsModel, holdingId) return getAsset(processedAssetsModel, holdingId)
} else if (holdingType === Constants.TokenType.ERC721) { } else if (holdingType === Constants.TokenType.ERC721 || holdingType === Constants.TokenType.ERC1155) {
return getSelectorCollectible(holdingId) return getSelectorCollectible(holdingId)
} else { } else {
return {} return {}
@ -171,7 +171,7 @@ QtObject {
function holdingToSelectorHolding(holding, holdingType) { function holdingToSelectorHolding(holding, holdingType) {
if (holdingType === Constants.TokenType.ERC20) { if (holdingType === Constants.TokenType.ERC20) {
return assetToSelectorAsset(holding) return assetToSelectorAsset(holding)
} else if (holdingType === Constants.TokenType.ERC721) { } else if (holdingType === Constants.TokenType.ERC721 || holdingType === Constants.TokenType.ERC1155) {
return collectibleToSelectorCollectible(holding) return collectibleToSelectorCollectible(holding)
} else { } else {
return {} return {}

View File

@ -1009,6 +1009,7 @@ QtObject {
StickersBuy, StickersBuy,
Bridge, Bridge,
ERC721Transfer, ERC721Transfer,
ERC1155Transfer,
Unknown Unknown
} }

2
vendor/status-go vendored

@ -1 +1 @@
Subproject commit 571f30777ebe32501df0d25f5eb79dbcbbb277c0 Subproject commit 580f697f57757daa2ad0671bf8590fb26381342e