feat(@desktop/wallet): Glue for sending nft

fixed #12128
This commit is contained in:
Khushboo Mehta 2023-08-31 12:27:15 +02:00 committed by Khushboo-dev-cpp
parent 29665956f1
commit f597ef4e6a
20 changed files with 197 additions and 108 deletions

View File

@ -93,8 +93,8 @@ proc suggestedRoutes*(self: Controller, account: string, amount: Uint256, token:
return suggestedRoutes.toJson() return suggestedRoutes.toJson()
proc transfer*(self: Controller, from_addr: string, to_addr: string, tokenSymbol: string, proc transfer*(self: Controller, from_addr: string, to_addr: string, tokenSymbol: string,
value: string, uuid: string, selectedRoutes: seq[TransactionPathDto], password: string) = value: string, uuid: string, selectedRoutes: seq[TransactionPathDto], password: string, sendType: int) =
self.transactionService.transfer(from_addr, to_addr, tokenSymbol, value, uuid, selectedRoutes, password) self.transactionService.transfer(from_addr, to_addr, tokenSymbol, value, uuid, selectedRoutes, password, sendType)
proc areTestNetworksEnabled*(self: Controller): bool = proc areTestNetworksEnabled*(self: Controller): bool =
return self.walletAccountService.areTestNetworksEnabled() return self.walletAccountService.areTestNetworksEnabled()

View File

@ -30,7 +30,7 @@ method suggestedRoutesReady*(self: AccessInterface, suggestedRoutes: SuggestedRo
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
method authenticateAndTransfer*(self: AccessInterface, from_addr: string, to_addr: string, method authenticateAndTransfer*(self: AccessInterface, from_addr: string, to_addr: string,
tokenSymbol: string, value: string, uuid: string) {.base.} = tokenSymbol: string, value: string, uuid: string, sendType: int) {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
method onUserAuthenticated*(self: AccessInterface, password: string) {.base.} = method onUserAuthenticated*(self: AccessInterface, password: string) {.base.} =

View File

@ -30,6 +30,7 @@ type TmpSendTransactionDetails = object
value: string value: string
paths: seq[TransactionPathDto] paths: seq[TransactionPathDto]
uuid: string uuid: string
sendType: int
type type
Module* = ref object of io_interface.AccessInterface Module* = ref object of io_interface.AccessInterface
@ -241,12 +242,13 @@ method viewDidLoad*(self: Module) =
method getTokenBalanceOnChain*(self: Module, address: string, chainId: int, symbol: string): CurrencyAmount = method getTokenBalanceOnChain*(self: Module, address: string, chainId: int, symbol: string): CurrencyAmount =
return self.controller.getTokenBalanceOnChain(address, chainId, symbol) return self.controller.getTokenBalanceOnChain(address, chainId, symbol)
method authenticateAndTransfer*(self: Module, from_addr: string, to_addr: string, tokenSymbol: string, value: string, uuid: string) = method authenticateAndTransfer*(self: Module, from_addr: string, to_addr: string, tokenSymbol: string, value: string, uuid: string, sendType: int) =
self.tmpSendTransactionDetails.fromAddr = from_addr self.tmpSendTransactionDetails.fromAddr = from_addr
self.tmpSendTransactionDetails.toAddr = to_addr self.tmpSendTransactionDetails.toAddr = to_addr
self.tmpSendTransactionDetails.tokenSymbol = tokenSymbol self.tmpSendTransactionDetails.tokenSymbol = tokenSymbol
self.tmpSendTransactionDetails.value = value self.tmpSendTransactionDetails.value = value
self.tmpSendTransactionDetails.uuid = uuid self.tmpSendTransactionDetails.uuid = uuid
self.tmpSendTransactionDetails.sendType = sendType
if singletonInstance.userProfile.getIsKeycardUser(): if singletonInstance.userProfile.getIsKeycardUser():
let keyUid = singletonInstance.userProfile.getKeyUid() let keyUid = singletonInstance.userProfile.getKeyUid()
@ -282,7 +284,7 @@ method onUserAuthenticated*(self: Module, password: string) =
self.controller.transfer( self.controller.transfer(
self.tmpSendTransactionDetails.fromAddr, self.tmpSendTransactionDetails.toAddr, self.tmpSendTransactionDetails.fromAddr, self.tmpSendTransactionDetails.toAddr,
self.tmpSendTransactionDetails.tokenSymbol, self.tmpSendTransactionDetails.value, self.tmpSendTransactionDetails.uuid, self.tmpSendTransactionDetails.tokenSymbol, self.tmpSendTransactionDetails.value, self.tmpSendTransactionDetails.uuid,
self.tmpSendTransactionDetails.paths, password self.tmpSendTransactionDetails.paths, password, self.tmpSendTransactionDetails.sendType
) )
method transactionWasSent*(self: Module, chainId: int, txHash, uuid, error: string) = method transactionWasSent*(self: Module, chainId: int, txHash, uuid, error: string) =

View File

@ -178,21 +178,21 @@ QtObject:
self.items[i].amountOut = path.getAmountOut() self.items[i].amountOut = path.getAmountOut()
self.dataChanged(index, index, @[ModelRole.AmountOut.int]) self.dataChanged(index, index, @[ModelRole.AmountOut.int])
proc getDisabledNetworkChainIds*(self: NetworkModel): seq[int] = proc getRouteDisabledNetworkChainIds*(self: NetworkModel): seq[int] =
var disbaledChains: seq[int] = @[] var disbaledChains: seq[int] = @[]
for item in self.items: for item in self.items:
if not item.getIsEnabled(): if not item.getIsEnabled():
disbaledChains.add(item.getChainId()) disbaledChains.add(item.getChainId())
return disbaledChains return disbaledChains
proc getLockedChainIds*(self: NetworkModel): string = proc getRouteLockedChainIds*(self: NetworkModel): string =
var jsonObject = newJObject() var jsonObject = newJObject()
for item in self.items: for item in self.items:
if item.getLocked(): if item.getLocked():
jsonObject[$item.getChainId()] = %* ("0x" & item.getLockedAmount()) jsonObject[$item.getChainId()] = %* ("0x" & item.getLockedAmount())
return $jsonObject return $jsonObject
proc updatePreferredChains*(self: NetworkModel, chainIds: string) = proc updateRoutePreferredChains*(self: NetworkModel, chainIds: string) =
try: try:
for i in 0 ..< self.items.len: for i in 0 ..< self.items.len:
let index = self.createIndex(i, 0, nil) let index = self.createIndex(i, 0, nil)
@ -211,28 +211,28 @@ QtObject:
except: except:
discard discard
proc getPreferredNetworkChainIds*(self: NetworkModel): seq[int] = proc getRoutePreferredNetworkChainIds*(self: NetworkModel): seq[int] =
var preferredChains: seq[int] = @[] var preferredChains: seq[int] = @[]
for item in self.items: for item in self.items:
if item.getIsPreferred(): if item.getIsPreferred():
preferredChains.add(item.getChainId()) preferredChains.add(item.getChainId())
return preferredChains return preferredChains
proc disableUnpreferredChains*(self: NetworkModel) = proc disableRouteUnpreferredChains*(self: NetworkModel) =
for i in 0 ..< self.items.len: for i in 0 ..< self.items.len:
if not self.items[i].getIsPreferred(): if not self.items[i].getIsPreferred():
let index = self.createIndex(i, 0, nil) let index = self.createIndex(i, 0, nil)
self.items[i].isEnabled = false self.items[i].isEnabled = false
self.dataChanged(index, index, @[ModelRole.IsEnabled.int]) self.dataChanged(index, index, @[ModelRole.IsEnabled.int])
proc enableUnpreferredChains*(self: NetworkModel) = proc enableRouteUnpreferredChains*(self: NetworkModel) =
for i in 0 ..< self.items.len: for i in 0 ..< self.items.len:
if not self.items[i].getIsPreferred(): if not self.items[i].getIsPreferred():
let index = self.createIndex(i, 0, nil) let index = self.createIndex(i, 0, nil)
self.items[i].isEnabled = true self.items[i].isEnabled = true
self.dataChanged(index, index, @[ModelRole.IsEnabled.int]) self.dataChanged(index, index, @[ModelRole.IsEnabled.int])
proc setAllNetworksAsPreferredChains*(self: NetworkModel) {.slot.} = proc setAllNetworksAsRoutePreferredChains*(self: NetworkModel) {.slot.} =
for i in 0 ..< self.items.len: for i in 0 ..< self.items.len:
let index = self.createIndex(i, 0, nil) let index = self.createIndex(i, 0, nil)
self.items[i].isPreferred = true self.items[i].isPreferred = true
@ -256,20 +256,28 @@ QtObject:
return item.getChainName() return item.getChainName()
return "" return ""
proc toggleDisabledChains*(self: NetworkModel, chainId: int) {.slot.} = proc toggleRouteDisabledChains*(self: NetworkModel, chainId: int) {.slot.} =
for i in 0 ..< self.items.len: for i in 0 ..< self.items.len:
if(self.items[i].getChainId() == chainId): if(self.items[i].getChainId() == chainId):
let index = self.createIndex(i, 0, nil) let index = self.createIndex(i, 0, nil)
self.items[i].isEnabled = not self.items[i].getIsEnabled() self.items[i].isEnabled = not self.items[i].getIsEnabled()
self.dataChanged(index, index, @[ModelRole.IsEnabled.int]) self.dataChanged(index, index, @[ModelRole.IsEnabled.int])
proc setDisabledChains*(self: NetworkModel, chainId: int, disabled: bool) {.slot.} = proc setRouteDisabledChains*(self: NetworkModel, chainId: int, disabled: bool) {.slot.} =
for i in 0 ..< self.items.len: for i in 0 ..< self.items.len:
if(self.items[i].getChainId() == chainId): if(self.items[i].getChainId() == chainId):
let index = self.createIndex(i, 0, nil) let index = self.createIndex(i, 0, nil)
self.items[i].isEnabled = not disabled self.items[i].isEnabled = not disabled
self.dataChanged(index, index, @[ModelRole.IsEnabled.int]) self.dataChanged(index, index, @[ModelRole.IsEnabled.int])
proc setRouteEnabledFromChains*(self: NetworkModel, chainId: int) {.slot.} =
for i in 0 ..< self.items.len:
let index = self.createIndex(i, 0, nil)
self.items[i].isEnabled = false
if(self.items[i].getChainId() == chainId):
self.items[i].isEnabled = true
self.dataChanged(index, index, @[ModelRole.IsEnabled.int])
proc lockCard*(self: NetworkModel, chainId: int, amount: string, lock: bool) {.slot.} = proc lockCard*(self: NetworkModel, chainId: int, amount: string, lock: bool) {.slot.} =
for i in 0 ..< self.items.len: for i in 0 ..< self.items.len:
if(self.items[i].getChainId() == chainId): if(self.items[i].getChainId() == chainId):

View File

@ -146,9 +146,9 @@ QtObject:
proc updateNetworksDisabledChains(self: View) = proc updateNetworksDisabledChains(self: View) =
# if the setting to show unpreferred chains is toggled, add all unpreferred chains to disabled chains list # if the setting to show unpreferred chains is toggled, add all unpreferred chains to disabled chains list
if not self.showUnPreferredChains: if not self.showUnPreferredChains:
self.toNetworksModel.disableUnpreferredChains() self.toNetworksModel.disableRouteUnpreferredChains()
else: else:
self.toNetworksModel.enableUnpreferredChains() self.toNetworksModel.enableRouteUnpreferredChains()
proc updateNetworksTokenBalance(self: View) = proc updateNetworksTokenBalance(self: View) =
for chainId in self.toNetworksModel.getAllNetworksChainIds(): for chainId in self.toNetworksModel.getAllNetworksChainIds():
@ -173,8 +173,8 @@ QtObject:
self.transactionSent(chainId, txHash, uuid, error) self.transactionSent(chainId, txHash, uuid, error)
proc authenticateAndTransfer*(self: View, from_addr: string, to_addr: string, tokenSymbol: string, proc authenticateAndTransfer*(self: View, from_addr: string, to_addr: string, tokenSymbol: string,
value: string, uuid: string) {.slot.} = value: string, uuid: string, sendType: int) {.slot.} =
self.delegate.authenticateAndTransfer(from_addr, to_addr, tokenSymbol, value, uuid) self.delegate.authenticateAndTransfer(from_addr, to_addr, tokenSymbol, value, uuid, sendType)
proc suggestedRoutesReady*(self: View, suggestedRoutes: QVariant) {.signal.} proc suggestedRoutesReady*(self: View, suggestedRoutes: QVariant) {.signal.}
proc setTransactionRoute*(self: View, routes: TransactionRoutes) = proc setTransactionRoute*(self: View, routes: TransactionRoutes) =
@ -190,8 +190,8 @@ QtObject:
discard discard
return self.delegate.suggestedRoutes(self.selectedSenderAccount.address(), return self.delegate.suggestedRoutes(self.selectedSenderAccount.address(),
parsedAmount, self.selectedAssetSymbol, self.fromNetworksModel.getDisabledNetworkChainIds(), parsedAmount, self.selectedAssetSymbol, self.fromNetworksModel.getRouteDisabledNetworkChainIds(),
self.toNetworksModel.getDisabledNetworkChainIds(), self.toNetworksModel.getPreferredNetworkChainIds(), sendType, self.fromNetworksModel.getLockedChainIds()) self.toNetworksModel.getRouteDisabledNetworkChainIds(), self.toNetworksModel.getRoutePreferredNetworkChainIds(), sendType, self.fromNetworksModel.getRouteLockedChainIds())
proc switchSenderAccountByAddress*(self: View, address: string) = proc switchSenderAccountByAddress*(self: View, address: string) =
let (account, index) = self.senderAccounts.getItemByAddress(address) let (account, index) = self.senderAccounts.getItemByAddress(address)
@ -223,8 +223,8 @@ QtObject:
self.setSelectetReceiveAccount(account) self.setSelectetReceiveAccount(account)
self.delegate.setSelectedReceiveAccountIndex(idx) self.delegate.setSelectedReceiveAccountIndex(idx)
proc updatePreferredChains*(self: View, chainIds: string) {.slot.} = proc updateRoutePreferredChains*(self: View, chainIds: string) {.slot.} =
self.toNetworksModel.updatePreferredChains(chainIds) self.toNetworksModel.updateRoutePreferredChains(chainIds)
proc getSelectedSenderAccountAddress*(self: View): string = proc getSelectedSenderAccountAddress*(self: View): string =
return self.selectedSenderAccount.address() return self.selectedSenderAccount.address()

View File

@ -23,6 +23,8 @@ type
amountOutMin*: Option[UInt256] # (optional) amountOutMin in case of a bridge hop transaction amountOutMin*: Option[UInt256] # (optional) amountOutMin in case of a bridge hop transaction
bonderFee*: Option[string] # (optional) bonderFee in case of a bridge hop transaction bonderFee*: Option[string] # (optional) bonderFee in case of a bridge hop transaction
tokenID*: Option[UInt256] # (optional) chainID in case of a ERC721 transaction
proc `%`*(x: TransactionDataDto): JsonNode = proc `%`*(x: TransactionDataDto): JsonNode =
result = newJobject() result = newJobject()
result["from"] = %x.source result["from"] = %x.source
@ -55,18 +57,22 @@ proc `%`*(x: TransactionDataDto): JsonNode =
result["amountOutMin"] = %x.amountOutMin.unsafeGet result["amountOutMin"] = %x.amountOutMin.unsafeGet
if x.bonderFee.isSome: if x.bonderFee.isSome:
result["bonderFee"] = %x.bonderFee.unsafeGet result["bonderFee"] = %x.bonderFee.unsafeGet
if x.tokenID.isSome:
result["tokenID"] = %x.tokenID.unsafeGet
type TransactionBridgeDto* = object type TransactionBridgeDto* = object
bridgeName*: string bridgeName*: string
chainID*: int chainID*: int
simpleTx*: TransactionDataDto transferTx*: TransactionDataDto
hopTx*: TransactionDataDto hopTx*: TransactionDataDto
cbridgeTx*: TransactionDataDto cbridgeTx*: TransactionDataDto
eRC721TransferTx*: TransactionDataDto
proc `%`*(x: TransactionBridgeDto): JsonNode = proc `%`*(x: TransactionBridgeDto): JsonNode =
result = newJobject() result = newJobject()
result["bridgeName"] = %x.bridgeName result["bridgeName"] = %x.bridgeName
result["chainID"] = %x.chainID result["chainID"] = %x.chainID
result["simpleTx"] = %x.simpleTx result["transferTx"] = %x.transferTx
result["hopTx"] = %x.hopTx result["hopTx"] = %x.hopTx
result["cbridgeTx"] = %x.cbridgeTx result["cbridgeTx"] = %x.cbridgeTx
result["eRC721TransferTx"] = %x.eRC721TransferTx

View File

@ -68,7 +68,7 @@ proc addFirstSimpleBridgeTxFlag(paths: seq[TransactionPathDto]) : seq[Transactio
if not firstSimplePath: if not firstSimplePath:
firstSimplePath = true firstSimplePath = true
path.isFirstSimpleTx = true path.isFirstSimpleTx = true
if path.bridgeName != "Simple": if path.bridgeName != "Transfer":
if not firstBridgePath: if not firstBridgePath:
firstBridgePath = false firstBridgePath = false
path.isFirstBridgeTx = true path.isFirstBridgeTx = true

View File

@ -9,6 +9,16 @@ import ../../common/conversion as service_conversion
import ./backend/transactions import ./backend/transactions
type
SendType* {.pure.} = enum
Transfer
ENSRegister
ENSRelease
ENSSetPubKey
StickersBuy
Bridge
ERC721Transfer
type type
PendingTransactionTypeDto* {.pure.} = enum PendingTransactionTypeDto* {.pure.} = enum
RegisterENS = "RegisterENS", RegisterENS = "RegisterENS",

View File

@ -44,8 +44,9 @@ const SIGNAL_HISTORY_ERROR* = "historyError"
const SIGNAL_CRYPTO_SERVICES_READY* = "cryptoServicesReady" const SIGNAL_CRYPTO_SERVICES_READY* = "cryptoServicesReady"
const SIGNAL_TRANSACTION_DECODED* = "transactionDecoded" const SIGNAL_TRANSACTION_DECODED* = "transactionDecoded"
const SIMPLE_TX_BRIDGE_NAME = "Simple" const SIMPLE_TX_BRIDGE_NAME = "Transfer"
const HOP_TX_BRIDGE_NAME = "Hop" const HOP_TX_BRIDGE_NAME = "Hop"
const ERC721_TRANSFER_NAME = "ERC721Transfer"
type type
EstimatedTime* {.pure.} = enum EstimatedTime* {.pure.} = enum
@ -214,16 +215,17 @@ QtObject:
txData.data = data txData.data = data
var path = TransactionBridgeDto(bridgeName: SIMPLE_TX_BRIDGE_NAME, chainID: route.fromNetwork.chainId) var path = TransactionBridgeDto(bridgeName: SIMPLE_TX_BRIDGE_NAME, chainID: route.fromNetwork.chainId)
path.simpleTx = txData path.transferTx = txData
return path return path
proc createPath*(self: Service, route: TransactionPathDto, txData: TransactionDataDto, tokenSymbol: string, to_addr: string): TransactionBridgeDto = proc createPath*(self: Service, route: TransactionPathDto, txData: TransactionDataDto, tokenSymbol: string, to_addr: string): TransactionBridgeDto =
var path = TransactionBridgeDto(bridgeName: route.bridgeName, chainID: route.fromNetwork.chainId) var path = TransactionBridgeDto(bridgeName: route.bridgeName, chainID: route.fromNetwork.chainId)
var hopTx = TransactionDataDto() var hopTx = TransactionDataDto()
var cbridgeTx = TransactionDataDto() var cbridgeTx = TransactionDataDto()
var eRC721TransferTx = TransactionDataDto()
if(route.bridgeName == SIMPLE_TX_BRIDGE_NAME): if(route.bridgeName == SIMPLE_TX_BRIDGE_NAME):
path.simpleTx = txData path.transferTx = txData
elif(route.bridgeName == HOP_TX_BRIDGE_NAME): elif(route.bridgeName == HOP_TX_BRIDGE_NAME):
hopTx = txData hopTx = txData
hopTx.chainID = route.toNetwork.chainId.some hopTx.chainID = route.toNetwork.chainId.some
@ -232,6 +234,12 @@ QtObject:
hopTx.amount = route.amountIn.some hopTx.amount = route.amountIn.some
hopTx.bonderFee = route.bonderFees.some hopTx.bonderFee = route.bonderFees.some
path.hopTx = hopTx path.hopTx = hopTx
elif(route.bridgeName == ERC721_TRANSFER_NAME):
eRC721TransferTx = txData
eRC721TransferTx.chainID = route.toNetwork.chainId.some
eRC721TransferTx.recipient = parseAddress(to_addr).some
eRC721TransferTx.tokenID = stint.u256(tokenSymbol).some
path.eRC721TransferTx = eRC721TransferTx
else: else:
cbridgeTx = txData cbridgeTx = txData
cbridgeTx.chainID = route.toNetwork.chainId.some cbridgeTx.chainID = route.toNetwork.chainId.some
@ -239,7 +247,6 @@ QtObject:
cbridgeTx.recipient = parseAddress(to_addr).some cbridgeTx.recipient = parseAddress(to_addr).some
cbridgeTx.amount = route.amountIn.some cbridgeTx.amount = route.amountIn.some
path.cbridgeTx = cbridgeTx path.cbridgeTx = cbridgeTx
return path return path
proc transferEth*( proc transferEth*(
@ -303,19 +310,31 @@ QtObject:
uuid: string, uuid: string,
routes: seq[TransactionPathDto], routes: seq[TransactionPathDto],
password: string, password: string,
sendType: int
) = ) =
try: try:
let isERC721Transfer = sendType == ord(ERC721Transfer)
var paths: seq[TransactionBridgeDto] = @[] var paths: seq[TransactionBridgeDto] = @[]
var chainID = 0 var chainID = 0
if(routes.len > 0): if(routes.len > 0):
chainID = routes[0].fromNetwork.chainID chainID = routes[0].fromNetwork.chainID
let network = self.networkService.getNetwork(chainID) var amountToSend: Stuint[256]
var toAddress: Address
var tokenSym = tokenSymbol
if isERC721Transfer:
amountToSend = value.parse(Stuint[256])
let contract_tokenId = tokenSym.split(":")
if contract_tokenId.len == 2:
toAddress = parseAddress(contract_tokenId[0])
tokenSym = contract_tokenId[1]
else:
let network = self.networkService.getNetwork(chainID)
let token = self.tokenService.findTokenBySymbol(network.chainId, tokenSym)
amountToSend = conversion.eth2Wei(parseFloat(value), token.decimals)
toAddress = token.address
let token = self.tokenService.findTokenBySymbol(network.chainId, tokenSymbol)
let amountToSend = conversion.eth2Wei(parseFloat(value), token.decimals)
let toAddress = token.address
let transfer = Transfer( let transfer = Transfer(
to: parseAddress(to_addr), to: parseAddress(to_addr),
value: amountToSend, value: amountToSend,
@ -336,14 +355,15 @@ QtObject:
$route.gasAmount, gasFees, route.gasFees.eip1559Enabled, $route.gasFees.maxPriorityFeePerGas, $route.gasFees.maxFeePerGasM) $route.gasAmount, gasFees, route.gasFees.eip1559Enabled, $route.gasFees.maxPriorityFeePerGas, $route.gasFees.maxFeePerGasM)
txData.data = data txData.data = data
paths.add(self.createPath(route, txData, tokenSymbol, to_addr)) paths.add(self.createPath(route, txData, tokenSym, to_addr))
let response = transactions.createMultiTransaction( var response: RpcResponse[JsonNode]
response = transactions.createMultiTransaction(
MultiTransactionCommandDto( MultiTransactionCommandDto(
fromAddress: from_addr, fromAddress: from_addr,
toAddress: to_addr, toAddress: to_addr,
fromAsset: tokenSymbol, fromAsset: tokenSym,
toAsset: tokenSymbol, toAsset: tokenSym,
fromAmount: "0x" & amountToSend.toHex, fromAmount: "0x" & amountToSend.toHex,
multiTxType: transactions.MultiTransactionType.MultiTransactionSend, multiTxType: transactions.MultiTransactionType.MultiTransactionSend,
), ),
@ -368,6 +388,7 @@ QtObject:
uuid: string, uuid: string,
selectedRoutes: seq[TransactionPathDto], selectedRoutes: seq[TransactionPathDto],
password: string, password: string,
sendType: int
) = ) =
try: try:
var chainID = 0 var chainID = 0
@ -383,7 +404,7 @@ QtObject:
if(isEthTx): if(isEthTx):
self.transferEth(from_addr, to_addr, tokenSymbol, value, uuid, selectedRoutes, password) self.transferEth(from_addr, to_addr, tokenSymbol, value, uuid, selectedRoutes, password)
else: else:
self.transferToken(from_addr, to_addr, tokenSymbol, value, uuid, selectedRoutes, password) self.transferToken(from_addr, to_addr, tokenSymbol, value, uuid, selectedRoutes, password, sendType)
except Exception as e: except Exception as e:
self.events.emit(SIGNAL_TRANSACTION_SENT, TransactionSentArgs(chainId: 0, txHash: "", uuid: uuid, error: fmt"Error sending token transfer transaction: {e.msg}")) self.events.emit(SIGNAL_TRANSACTION_SENT, TransactionSentArgs(chainId: 0, txHash: "", uuid: uuid, error: fmt"Error sending token transfer transaction: {e.msg}"))

View File

@ -144,12 +144,24 @@ Item {
footer: WalletFooter { footer: WalletFooter {
visible: !root.showAllAccounts visible: !root.showAllAccounts
sendModal: root.sendModalPopup
width: parent.width width: parent.width
height: root.showAllAccounts ? implicitHeight : 61 height: root.showAllAccounts ? implicitHeight : 61
walletStore: RootStore walletStore: RootStore
networkConnectionStore: root.networkConnectionStore networkConnectionStore: root.networkConnectionStore
onLaunchShareAddressModal: Global.openPopup(receiveModalComponent) onLaunchShareAddressModal: Global.openPopup(receiveModalComponent)
onLaunchSendModal: {
root.sendModalPopup.sendType = Constants.SendType.Transfer
root.sendModalPopup.preSelectedHoldingID = walletStore.currentViewedHoldingID
root.sendModalPopup.preSelectedHoldingType = walletStore.currentViewedHoldingType
root.sendModalPopup.open()
}
onLaunchBridgeModal: {
root.sendModalPopup.isBridgeTx = true
root.sendModalPopup.sendType = Constants.SendType.Bridge
root.sendModalPopup.preSelectedHoldingID = walletStore.currentViewedHoldingID
root.sendModalPopup.preSelectedHoldingType = walletStore.currentViewedHoldingType
root.sendModalPopup.open()
}
} }
} }

View File

@ -15,11 +15,12 @@ import "../popups"
Rectangle { Rectangle {
id: root id: root
property var sendModal
property var walletStore property var walletStore
property var networkConnectionStore property var networkConnectionStore
signal launchShareAddressModal() signal launchShareAddressModal()
signal launchSendModal()
signal launchBridgeModal()
color: Theme.palette.statusAppLayout.rightPanelBackgroundColor color: Theme.palette.statusAppLayout.rightPanelBackgroundColor
@ -39,11 +40,7 @@ Rectangle {
icon: "send" icon: "send"
text: qsTr("Send") text: qsTr("Send")
interactive: networkConnectionStore.sendBuyBridgeEnabled interactive: networkConnectionStore.sendBuyBridgeEnabled
onClicked: function() { onClicked: root.launchSendModal()
sendModal.preSelectedHoldingID = walletStore.currentViewedHoldingID
sendModal.preSelectedHoldingType = walletStore.currentViewedHoldingType
sendModal.open()
}
tooltipText: networkConnectionStore.sendBuyBridgeToolTipText tooltipText: networkConnectionStore.sendBuyBridgeToolTipText
visible: !walletStore.overview.isWatchOnlyAccount visible: !walletStore.overview.isWatchOnlyAccount
} }
@ -61,12 +58,7 @@ Rectangle {
buttonType: DisabledTooltipButton.Flat buttonType: DisabledTooltipButton.Flat
text: qsTr("Bridge") text: qsTr("Bridge")
interactive: networkConnectionStore.sendBuyBridgeEnabled interactive: networkConnectionStore.sendBuyBridgeEnabled
onClicked: function() { onClicked: root.launchBridgeModal()
sendModal.isBridgeTx = true
sendModal.preSelectedHoldingID = walletStore.currentViewedHoldingID
sendModal.preSelectedHoldingType = walletStore.currentViewedHoldingType
sendModal.open()
}
tooltipText: networkConnectionStore.sendBuyBridgeToolTipText tooltipText: networkConnectionStore.sendBuyBridgeToolTipText
visible: !walletStore.overview.isWatchOnlyAccount visible: !walletStore.overview.isWatchOnlyAccount
} }

View File

@ -1348,12 +1348,13 @@ Item {
property bool isBridgeTx property bool isBridgeTx
property string preSelectedHoldingID property string preSelectedHoldingID
property var preSelectedHoldingType property var preSelectedHoldingType
property int sendType: -1
sourceComponent: SendModal { sourceComponent: SendModal {
onlyAssets: false onlyAssets: false
onClosed: { onClosed: {
sendModal.closed() sendModal.closed()
sendModal.isBridgeTx = false sendModal.isBridgeTx = false
sendModal.sendType = -1
sendModal.preSelectedHoldingID = "" sendModal.preSelectedHoldingID = ""
sendModal.preSelectedHoldingType = Constants.HoldingType.Unknown sendModal.preSelectedHoldingType = Constants.HoldingType.Unknown
} }
@ -1365,6 +1366,9 @@ Item {
if(isBridgeTx) { if(isBridgeTx) {
item.isBridgeTx = sendModal.isBridgeTx item.isBridgeTx = sendModal.isBridgeTx
} }
if(sendModal.sendType >= 0) {
item.sendType = sendModal.sendType
}
if(preSelectedHoldingType !== Constants.HoldingType.Unknown) { if(preSelectedHoldingType !== Constants.HoldingType.Unknown) {
item.preSelectedHoldingID = sendModal.preSelectedHoldingID item.preSelectedHoldingID = sendModal.preSelectedHoldingID
item.preSelectedHoldingType = sendModal.preSelectedHoldingType item.preSelectedHoldingType = sendModal.preSelectedHoldingType

View File

@ -117,7 +117,7 @@ Item {
property double tokenFees: modelData.tokenFees property double tokenFees: modelData.tokenFees
property double tokenFeesFiat: root.getFiatValue(tokenFees, root.selectedTokenSymbol, root.currentCurrency) property double tokenFeesFiat: root.getFiatValue(tokenFees, root.selectedTokenSymbol, root.currentCurrency)
subTitle: root.formatCurrencyAmount(tokenFees, root.selectedTokenSymbol) subTitle: root.formatCurrencyAmount(tokenFees, root.selectedTokenSymbol)
visible: modelData.bridgeName !== "Simple" visible: modelData.bridgeName !== "Transfer"
statusListItemSubTitle.width: 100 statusListItemSubTitle.width: 100
statusListItemSubTitle.elide: Text.ElideMiddle statusListItemSubTitle.elide: Text.ElideMiddle
components: [ components: [

View File

@ -24,8 +24,6 @@ import "../views"
StatusDialog { StatusDialog {
id: popup id: popup
property bool isBridgeTx: false
property string preSelectedRecipient property string preSelectedRecipient
property string preDefinedAmountToSend property string preDefinedAmountToSend
property var preSelectedHolding property var preSelectedHolding
@ -44,7 +42,8 @@ StatusDialog {
property var bestRoutes property var bestRoutes
property alias addressText: recipientLoader.addressText property alias addressText: recipientLoader.addressText
property bool isLoading: false property bool isLoading: false
property int sendType: isBridgeTx ? Constants.SendType.Bridge : Constants.SendType.Transfer property int sendType: Constants.SendType.Transfer
property MessageDialog sendingError: MessageDialog { property MessageDialog sendingError: MessageDialog {
id: sendingError id: sendingError
title: qsTr("Error sending the transaction") title: qsTr("Error sending the transaction")
@ -60,20 +59,21 @@ StatusDialog {
recipientAddress, recipientAddress,
d.selectedSymbol, d.selectedSymbol,
amountToSendInput.cryptoValueToSend, amountToSendInput.cryptoValueToSend,
d.uuid) d.uuid,
sendType)
} }
property var recalculateRoutesAndFees: Backpressure.debounce(popup, 600, function() { property var recalculateRoutesAndFees: Backpressure.debounce(popup, 600, function() {
if(!!popup.selectedAccount && d.isSelectedHoldingValidAsset && recipientLoader.ready && amountToSendInput.inputNumberValid) { if(!!popup.selectedAccount && !!d.selectedHolding && recipientLoader.ready && amountToSendInput.inputNumberValid) {
popup.isLoading = true popup.isLoading = true
let amount = Math.round(amountToSendInput.cryptoValueToSend * Math.pow(10, d.selectedHolding.decimals)) let amount = d.isERC721Transfer ? 1: Math.round(amountToSendInput.cryptoValueToSend * Math.pow(10, d.selectedHolding.decimals))
popup.store.suggestedRoutes(amount.toString(16), popup.sendType) popup.store.suggestedRoutes(amount.toString(16), popup.sendType)
} }
}) })
QtObject { QtObject {
id: d id: d
readonly property int errorType: !amountToSendInput.input.valid ? Constants.SendAmountExceedsBalance : readonly property int errorType: !amountToSendInput.input.valid && !isERC721Transfer ? 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 string totalTimeEstimate property string totalTimeEstimate
property double totalFeesInFiat property double totalFeesInFiat
property double totalAmountToReceive property double totalAmountToReceive
readonly property bool isBridgeTx: popup.sendType === Constants.SendType.Bridge
readonly property bool isERC721Transfer: popup.sendType === Constants.SendType.ERC721Transfer
property var selectedHolding: null property var selectedHolding: null
property var selectedHoldingType: Constants.HoldingType.Unknown property var selectedHoldingType: Constants.HoldingType.Unknown
readonly property bool isSelectedHoldingValidAsset: !!selectedHolding && selectedHoldingType === Constants.HoldingType.Asset readonly property bool isSelectedHoldingValidAsset: !!selectedHolding && selectedHoldingType === Constants.HoldingType.Asset
@ -102,8 +103,8 @@ StatusDialog {
} }
function setSelectedHolding(holding, holdingType) { function setSelectedHolding(holding, holdingType) {
d.selectedHolding = holding
d.selectedHoldingType = holdingType d.selectedHoldingType = holdingType
d.selectedHolding = holding
let selectorHolding = store.holdingToSelectorHolding(holding, holdingType) let selectorHolding = store.holdingToSelectorHolding(holding, holdingType)
holdingSelector.setSelectedItem(selectorHolding, holdingType) holdingSelector.setSelectedItem(selectorHolding, holdingType)
} }
@ -114,11 +115,25 @@ StatusDialog {
} }
function setHoveredHolding(holding, holdingType) { function setHoveredHolding(holding, holdingType) {
d.hoveredHolding = holding
d.hoveredHoldingType = holdingType d.hoveredHoldingType = holdingType
d.hoveredHolding = holding
let selectorHolding = store.holdingToSelectorHolding(holding, holdingType) let selectorHolding = store.holdingToSelectorHolding(holding, holdingType)
holdingSelector.setHoveredItem(selectorHolding, holdingType) holdingSelector.setHoveredItem(selectorHolding, holdingType)
} }
onSelectedHoldingChanged: {
if (d.selectedHoldingType === Constants.HoldingType.Asset) {
popup.sendType = Constants.SendType.Transfer
store.setSelectedAssetSymbol(selectedHolding.symbol)
} else if (d.selectedHoldingType === Constants.HoldingType.Collectible) {
popup.sendType = Constants.SendType.ERC721Transfer
amountToSendInput.input.text = 1
store.setSelectedAssetSymbol(selectedHolding.contractAddress+":"+selectedHolding.tokenId)
store.setRouteEnabledFromChains(selectedHolding.chainId)
store.updateRoutePreferredChains(selectedHolding.chainId)
}
recalculateRoutesAndFees()
}
} }
width: 556 width: 556
@ -152,12 +167,14 @@ StatusDialog {
recipientLoader.selectedRecipient = {address: popup.preSelectedRecipient} recipientLoader.selectedRecipient = {address: popup.preSelectedRecipient}
} }
if(popup.isBridgeTx) { if(d.isBridgeTx) {
recipientLoader.selectedRecipientType = TabAddressSelectorView.Type.Address recipientLoader.selectedRecipientType = TabAddressSelectorView.Type.Address
recipientLoader.selectedRecipient = {address: popup.selectedAccount.address} recipientLoader.selectedRecipient = {address: popup.selectedAccount.address}
} }
} }
onClosed: popup.store.resetStoredProperties()
header: AccountsModalHeader { header: AccountsModalHeader {
anchors.top: parent.top anchors.top: parent.top
anchors.topMargin: -height - 18 anchors.topMargin: -height - 18
@ -215,7 +232,7 @@ StatusDialog {
id: modalHeader id: modalHeader
Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft Layout.alignment: Qt.AlignVCenter | Qt.AlignLeft
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
text: popup.isBridgeTx ? qsTr("Bridge") : qsTr("Send") text: d.isBridgeTx ? qsTr("Bridge") : qsTr("Send")
font.pixelSize: 28 font.pixelSize: 28
lineHeight: 38 lineHeight: 38
lineHeightMode: Text.FixedHeight lineHeightMode: Text.FixedHeight
@ -230,7 +247,8 @@ StatusDialog {
assetsModel: popup.selectedAccount && popup.selectedAccount.assets ? popup.selectedAccount.assets : null assetsModel: popup.selectedAccount && popup.selectedAccount.assets ? popup.selectedAccount.assets : null
collectiblesModel: popup.selectedAccount ? popup.nestedCollectiblesModel : null collectiblesModel: popup.selectedAccount ? popup.nestedCollectiblesModel : null
currentCurrencySymbol: RootStore.currencyStore.currentCurrencySymbol currentCurrencySymbol: RootStore.currencyStore.currentCurrencySymbol
visible: !!d.selectedHolding || !!d.hoveredHolding visible: (!!d.selectedHolding && d.selectedHoldingType !== Constants.HoldingType.Unknown) ||
(!!d.hoveredHolding && d.hoveredHoldingType !== Constants.HoldingType.Unknown)
getNetworkIcon: function(chainId){ getNetworkIcon: function(chainId){
return RootStore.getNetworkIcon(chainId) return RootStore.getNetworkIcon(chainId)
} }
@ -242,9 +260,9 @@ StatusDialog {
StatusListItemTag { StatusListItemTag {
Layout.alignment: Qt.AlignVCenter | Qt.AlignRight Layout.alignment: Qt.AlignVCenter | Qt.AlignRight
Layout.preferredHeight: 22 Layout.preferredHeight: 22
visible: d.isSelectedHoldingValidAsset || d.isHoveredHoldingValidAsset visible: d.isSelectedHoldingValidAsset || d.isHoveredHoldingValidAsset && !d.isERC721Transfer
title: { title: {
if(d.isHoveredHoldingValidAsset) { if(d.isHoveredHoldingValidAsset && !!d.hoveredHolding.symbol) {
const balance = popup.currencyStore.formatCurrencyAmount((amountToSendInput.inputIsFiat ? d.hoveredHolding.totalCurrencyBalance.amount : d.hoveredHolding.totalBalance.amount) , d.hoveredHolding.symbol) const balance = popup.currencyStore.formatCurrencyAmount((amountToSendInput.inputIsFiat ? d.hoveredHolding.totalCurrencyBalance.amount : d.hoveredHolding.totalBalance.amount) , d.hoveredHolding.symbol)
return qsTr("Max: %1").arg(balance) return qsTr("Max: %1").arg(balance)
} }
@ -288,11 +306,11 @@ StatusDialog {
} }
} }
RowLayout { RowLayout {
visible: d.isSelectedHoldingValidAsset visible: d.isSelectedHoldingValidAsset && !d.isERC721Transfer
AmountToSend { AmountToSend {
id: amountToSendInput id: amountToSendInput
Layout.fillWidth:true Layout.fillWidth:true
isBridgeTx: popup.isBridgeTx isBridgeTx: d.isBridgeTx
interactive: popup.interactive interactive: popup.interactive
selectedSymbol: d.selectedSymbol selectedSymbol: d.selectedSymbol
maxInputBalance: d.maxInputBalance maxInputBalance: d.maxInputBalance
@ -314,10 +332,11 @@ StatusDialog {
id: amountToReceive id: amountToReceive
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
Layout.fillWidth:true Layout.fillWidth:true
visible: !!popup.bestRoutes && popup.bestRoutes !== undefined && popup.bestRoutes.count > 0 && amountToSendInput.inputNumberValid visible: !!popup.bestRoutes && popup.bestRoutes !== undefined &&
popup.bestRoutes.count > 0 && amountToSendInput.inputNumberValid
isLoading: popup.isLoading isLoading: popup.isLoading
selectedSymbol: d.selectedSymbol selectedSymbol: d.selectedSymbol
isBridgeTx: popup.isBridgeTx isBridgeTx: d.isBridgeTx
cryptoValueToReceive: d.totalAmountToReceive cryptoValueToReceive: d.totalAmountToReceive
inputIsFiat: amountToSendInput.inputIsFiat inputIsFiat: amountToSendInput.inputIsFiat
minCryptoDecimals: amountToSendInput.minReceiveCryptoDecimals minCryptoDecimals: amountToSendInput.minReceiveCryptoDecimals
@ -366,7 +385,7 @@ StatusDialog {
anchors.right: parent.right anchors.right: parent.right
anchors.leftMargin: Style.current.bigPadding anchors.leftMargin: Style.current.bigPadding
anchors.rightMargin: Style.current.bigPadding anchors.rightMargin: Style.current.bigPadding
visible: !isBridgeTx && !!d.selectedHolding visible: !d.isBridgeTx && !!d.selectedHolding
StatusBaseText { StatusBaseText {
id: label id: label
elide: Text.ElideRight elide: Text.ElideRight
@ -378,7 +397,8 @@ StatusDialog {
id: recipientLoader id: recipientLoader
Layout.fillWidth: true Layout.fillWidth: true
store: popup.store store: popup.store
isBridgeTx: popup.isBridgeTx isERC721Transfer: d.isERC721Transfer
isBridgeTx: d.isBridgeTx
interactive: popup.interactive interactive: popup.interactive
selectedAsset: d.selectedHolding selectedAsset: d.selectedHolding
onIsLoading: popup.isLoading = true onIsLoading: popup.isLoading = true
@ -398,7 +418,7 @@ StatusDialog {
recipientLoader.selectedRecipientType = type recipientLoader.selectedRecipientType = type
recipientLoader.selectedRecipient = recipient recipientLoader.selectedRecipient = recipient
} }
visible: !recipientLoader.ready && !isBridgeTx && !!d.selectedHolding visible: !recipientLoader.ready && !d.isBridgeTx && !!d.selectedHolding
} }
NetworkSelector { NetworkSelector {
@ -419,7 +439,8 @@ StatusDialog {
visible: recipientLoader.ready && !!d.selectedHolding && amountToSendInput.inputNumberValid visible: recipientLoader.ready && !!d.selectedHolding && amountToSendInput.inputNumberValid
errorType: d.errorType errorType: d.errorType
isLoading: popup.isLoading isLoading: popup.isLoading
isBridgeTx: popup.isBridgeTx isBridgeTx: d.isBridgeTx
isERC721Transfer: d.isERC721Transfer
} }
FeesView { FeesView {
@ -442,7 +463,7 @@ StatusDialog {
} }
footer: SendModalFooter { footer: SendModalFooter {
nextButtonText: popup.isBridgeTx ? qsTr("Bridge") : qsTr("Send") nextButtonText: d.isBridgeTx ? qsTr("Bridge") : qsTr("Send")
maxFiatFees: popup.isLoading ? "..." : popup.currencyStore.formatCurrencyAmount(d.totalFeesInFiat, popup.currencyStore.currentCurrency) maxFiatFees: popup.isLoading ? "..." : popup.currencyStore.formatCurrencyAmount(d.totalFeesInFiat, popup.currencyStore.currentCurrency)
totalTimeEstimate: popup.isLoading? "..." : d.totalTimeEstimate totalTimeEstimate: popup.isLoading? "..." : d.totalTimeEstimate
pending: d.isPendingTx || popup.isLoading pending: d.isPendingTx || popup.isLoading

View File

@ -45,8 +45,8 @@ QtObject {
globalUtils.copyToClipboard(text) globalUtils.copyToClipboard(text)
} }
function authenticateAndTransfer(from, to, tokenSymbol, amount, uuid) { function authenticateAndTransfer(from, to, tokenSymbol, amount, uuid, sendType) {
walletSectionSendInst.authenticateAndTransfer(from, to, tokenSymbol, amount, uuid) walletSectionSendInst.authenticateAndTransfer(from, to, tokenSymbol, amount, uuid, sendType)
} }
function suggestedRoutes(amount, sendType) { function suggestedRoutes(amount, sendType) {
@ -180,15 +180,19 @@ QtObject {
} }
function toggleFromDisabledChains(chainId) { function toggleFromDisabledChains(chainId) {
fromNetworksModel.toggleDisabledChains(chainId) fromNetworksModel.toggleRouteDisabledChains(chainId)
} }
function toggleToDisabledChains(chainId) { function toggleToDisabledChains(chainId) {
toNetworksModel.toggleDisabledChains(chainId) toNetworksModel.toggleRouteDisabledChains(chainId)
} }
function setDisabledChains(chainId, disabled) { function setRouteDisabledChains(chainId, disabled) {
toNetworksModel.setDisabledChains(chainId, disabled) toNetworksModel.setRouteDisabledChains(chainId, disabled)
}
function setRouteEnabledFromChains(chainId) {
fromNetworksModel.setRouteEnabledFromChains(chainId)
} }
function setSelectedAssetSymbol(symbol) { function setSelectedAssetSymbol(symbol) {
@ -199,16 +203,16 @@ QtObject {
return fromNetworksModel.getNetworkName(chainId) return fromNetworksModel.getNetworkName(chainId)
} }
function updatePreferredChains(chainIds) { function updateRoutePreferredChains(chainIds) {
walletSectionSendInst.updatePreferredChains(chainIds) walletSectionSendInst.updateRoutePreferredChains(chainIds)
} }
function toggleShowUnPreferredChains() { function toggleShowUnPreferredChains() {
walletSectionSendInst.toggleShowUnPreferredChains() walletSectionSendInst.toggleShowUnPreferredChains()
} }
function setAllNetworksAsPreferredChains() { function setAllNetworksAsRoutePreferredChains() {
toNetworksModel.setAllNetworksAsPreferredChains() toNetworksModel.setAllNetworksAsRoutePreferredChains()
} }
function lockCard(chainId, amount, lock) { function lockCard(chainId, amount, lock) {
@ -220,7 +224,7 @@ QtObject {
} }
// TODO: move to nim // TODO: move to nim
function splitAndFormatAddressPrefix(text, isBridgeTx) { function splitAndFormatAddressPrefix(text, updateInStore) {
let address = "" let address = ""
let tempPreferredChains = [] let tempPreferredChains = []
let chainFound = false let chainFound = false
@ -236,18 +240,17 @@ QtObject {
let chainColor = fromNetworksModel.getNetworkColor(word) let chainColor = fromNetworksModel.getNetworkColor(word)
if(!!chainColor) { if(!!chainColor) {
chainFound = true chainFound = true
if(!isBridgeTx) tempPreferredChains.push(fromNetworksModel.getNetworkChainId(word))
tempPreferredChains.push(fromNetworksModel.getNetworkChainId(word))
editedText += `<span style='color: %1'>%2</span>`.arg(chainColor).arg(word)+':' editedText += `<span style='color: %1'>%2</span>`.arg(chainColor).arg(word)+':'
} }
} }
} }
if(!isBridgeTx) { if(updateInStore) {
if(!chainFound) if(!chainFound)
updatePreferredChains(networksModule.getMainnetChainId()) updateRoutePreferredChains(networksModule.getMainnetChainId())
else else
updatePreferredChains(tempPreferredChains.join(":")) updateRoutePreferredChains(tempPreferredChains.join(":"))
} }
editedText +="</a></p>" editedText +="</a></p>"

View File

@ -30,6 +30,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 var toNetworksList property var toNetworksList
property int errorType: Constants.NoError property int errorType: Constants.NoError
@ -45,6 +46,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
StatusSwitchTabButton { StatusSwitchTabButton {
text: qsTr("Simple") text: qsTr("Simple")
} }
@ -58,12 +60,12 @@ Item {
StackLayout { StackLayout {
id: stackLayout id: stackLayout
anchors.top: tabBar.bottom anchors.top: !root.isERC721Transfer ? tabBar.bottom: parent.top
anchors.topMargin: Style.current.bigPadding anchors.topMargin: !root.isERC721Transfer ? 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: tabBar.currentIndex === 0 ? 0 : 1 currentIndex: root.isERC721Transfer ? 0: tabBar.currentIndex === 0 ? 0 : 1
Rectangle { Rectangle {
id: simple id: simple
@ -76,6 +78,7 @@ Item {
anchors.margins: Style.current.padding anchors.margins: Style.current.padding
width: stackLayout.width - Style.current.bigPadding width: stackLayout.width - Style.current.bigPadding
isBridgeTx: root.isBridgeTx isBridgeTx: root.isBridgeTx
isERC721Transfer: root.isERC721Transfer
amountToSend: root.amountToSend amountToSend: root.amountToSend
minReceiveCryptoDecimals: root.minReceiveCryptoDecimals minReceiveCryptoDecimals: root.minReceiveCryptoDecimals
isLoading: root.isLoading isLoading: root.isLoading
@ -85,7 +88,7 @@ Item {
errorType: root.errorType errorType: root.errorType
toNetworksList: root.toNetworksList toNetworksList: root.toNetworksList
weiToEth: function(wei) { weiToEth: function(wei) {
if(root.selectedAsset !== undefined) if(!!selectedAsset && root.selectedAsset !== undefined)
return parseFloat(store.getWei2Eth(wei, root.selectedAsset.decimals)) return parseFloat(store.getWei2Eth(wei, root.selectedAsset.decimals))
} }
formatCurrencyAmount: root.currencyStore.formatCurrencyAmount formatCurrencyAmount: root.currencyStore.formatCurrencyAmount
@ -119,7 +122,7 @@ Item {
isBridgeTx: root.isBridgeTx isBridgeTx: root.isBridgeTx
errorType: root.errorType errorType: root.errorType
weiToEth: function(wei) { weiToEth: function(wei) {
if(selectedAsset !== undefined) if(!!selectedAsset && selectedAsset !== undefined)
return parseFloat(store.getWei2Eth(wei, selectedAsset.decimals)) return parseFloat(store.getWei2Eth(wei, selectedAsset.decimals))
} }
} }

View File

@ -20,6 +20,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 var selectedAccount property var selectedAccount
property var toNetworksList property var toNetworksList
property var weiToEth: function(wei) {} property var weiToEth: function(wei) {}
@ -100,6 +101,8 @@ RowLayout {
implicitWidth: 410 implicitWidth: 410
title: model.chainName title: model.chainName
subTitle: { subTitle: {
if(root.isERC721Transfer)
return ""
let amountOut = root.weiToEth(model.amountOut) let amountOut = root.weiToEth(model.amountOut)
return root.formatCurrencyAmount(amountOut, store.selectedAssetSymbol, {"minDecimals": root.minReceiveCryptoDecimals}) return root.formatCurrencyAmount(amountOut, store.selectedAssetSymbol, {"minDecimals": root.minReceiveCryptoDecimals})
} }
@ -140,7 +143,7 @@ RowLayout {
onClicked: gasRectangle.toggle() onClicked: gasRectangle.toggle()
} }
onCheckedChanged: { onCheckedChanged: {
store.setDisabledChains(chainId, !gasRectangle.checked) store.setRouteDisabledChains(chainId, !gasRectangle.checked)
if(checked) if(checked)
root.reCalculateSuggestedRoute() root.reCalculateSuggestedRoute()
} }
@ -150,7 +153,7 @@ RowLayout {
height: card.height height: card.height
} }
Component.onCompleted: { Component.onCompleted: {
store.setDisabledChains(chainId, !gasRectangle.checked) store.setRouteDisabledChains(chainId, !gasRectangle.checked)
if(index === (repeater.count -1)) if(index === (repeater.count -1))
root.reCalculateSuggestedRoute() root.reCalculateSuggestedRoute()
} }

View File

@ -16,6 +16,7 @@ Loader {
id: root id: root
property var store property var store
property bool isERC721Transfer
property bool isBridgeTx: false property bool isBridgeTx: false
property bool interactive: true property bool interactive: true
property var selectedAsset property var selectedAsset
@ -35,10 +36,12 @@ Loader {
onSelectedRecipientChanged: { onSelectedRecipientChanged: {
root.isLoading() root.isLoading()
d.waitTimer.restart() d.waitTimer.restart()
if(!root.isBridgeTx) if(!isERC721Transfer) {
root.store.updatePreferredChains(root.selectedRecipient.preferredSharingChainIds) if(!root.isBridgeTx)
else root.store.updateRoutePreferredChains(root.selectedRecipient.preferredSharingChainIds)
root.store.setAllNetworksAsPreferredChains() else
root.store.setAllNetworksAsRoutePreferredChains()
}
if(!!root.selectedRecipient && root.selectedRecipientType !== TabAddressSelectorView.Type.None) { if(!!root.selectedRecipient && root.selectedRecipientType !== TabAddressSelectorView.Type.None) {
switch(root.selectedRecipientType) { switch(root.selectedRecipientType) {
case TabAddressSelectorView.Type.SavedAddress: { case TabAddressSelectorView.Type.SavedAddress: {
@ -88,10 +91,10 @@ Loader {
if(!!root.item.input) if(!!root.item.input)
root.item.input.text = root.resolvedENSAddress root.item.input.text = root.resolvedENSAddress
root.addressText = root.resolvedENSAddress root.addressText = root.resolvedENSAddress
store.splitAndFormatAddressPrefix(root.address, root.isBridgeTx) store.splitAndFormatAddressPrefix(root.address, !root.isBridgeTx && !isERC721Transfer)
} else { } else {
let address = d.getAddress() let address = d.getAddress()
let result = store.splitAndFormatAddressPrefix(address, root.isBridgeTx) let result = store.splitAndFormatAddressPrefix(address, !root.isBridgeTx && !isERC721Transfer)
if(!!result.address) { if(!!result.address) {
root.addressText = result.address root.addressText = result.address
if(!!root.item.input) if(!!root.item.input)

View File

@ -983,7 +983,8 @@ QtObject {
ENSRelease, ENSRelease,
ENSSetPubKey, ENSSetPubKey,
StickersBuy, StickersBuy,
Bridge Bridge,
ERC721Transfer
} }
enum ErrorType { enum ErrorType {

2
vendor/status-go vendored

@ -1 +1 @@
Subproject commit 83d13548458c60d14eba6efdd92a928f9f0050a1 Subproject commit ea29c034658d8b82c24fde0e369060642b38d4c3