fix(@desktop/wallet): Move selected recipient and send type to nim

fixes #12206
This commit is contained in:
Khushboo Mehta 2023-09-20 18:07:09 +02:00 committed by Khushboo-dev-cpp
parent c8c9c706d9
commit 76615b0bf7
17 changed files with 111 additions and 86 deletions

View File

@ -88,12 +88,12 @@ proc authenticateUser*(self: Controller, keyUid = "") =
keyUid: keyUid) keyUid: keyUid)
self.events.emit(SIGNAL_SHARED_KEYCARD_MODULE_AUTHENTICATE_USER, data) self.events.emit(SIGNAL_SHARED_KEYCARD_MODULE_AUTHENTICATE_USER, data)
proc suggestedRoutes*(self: Controller, account: string, amount: Uint256, token: string, disabledFromChainIDs, disabledToChainIDs, preferredChainIDs: seq[int], sendType: int, lockedInAmounts: string): string = proc suggestedRoutes*(self: Controller, account: string, amount: Uint256, token: string, disabledFromChainIDs, disabledToChainIDs, preferredChainIDs: seq[int], sendType: SendType, lockedInAmounts: string): string =
let suggestedRoutes = self.transactionService.suggestedRoutes(account, amount, token, disabledFromChainIDs, disabledToChainIDs, preferredChainIDs, sendType, lockedInAmounts) let suggestedRoutes = self.transactionService.suggestedRoutes(account, amount, token, disabledFromChainIDs, disabledToChainIDs, preferredChainIDs, sendType, lockedInAmounts)
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, sendType: int) = value: string, uuid: string, selectedRoutes: seq[TransactionPathDto], password: string, sendType: SendType) =
self.transactionService.transfer(from_addr, to_addr, tokenSymbol, value, uuid, selectedRoutes, password, sendType) self.transactionService.transfer(from_addr, to_addr, tokenSymbol, value, uuid, selectedRoutes, password, sendType)
proc areTestNetworksEnabled*(self: Controller): bool = proc areTestNetworksEnabled*(self: Controller): bool =

View File

@ -23,14 +23,14 @@ method refreshWalletAccounts*(self: AccessInterface) {.base.} =
method getTokenBalanceOnChain*(self: AccessInterface, address: string, chainId: int, symbol: string): CurrencyAmount {.base.} = method getTokenBalanceOnChain*(self: AccessInterface, address: string, chainId: int, symbol: string): CurrencyAmount {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
method suggestedRoutes*(self: AccessInterface, account: string, amount: UInt256, token: string, disabledFromChainIDs, disabledToChainIDs, preferredChainIDs: seq[int], sendType: int, lockedInAmounts: string): string {.base.} = method suggestedRoutes*(self: AccessInterface, account: string, amount: UInt256, token: string, disabledFromChainIDs, disabledToChainIDs, preferredChainIDs: seq[int], sendType: SendType, lockedInAmounts: string): string {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
method suggestedRoutesReady*(self: AccessInterface, suggestedRoutes: SuggestedRoutesDto) {.base.} = method suggestedRoutesReady*(self: AccessInterface, suggestedRoutes: SuggestedRoutesDto) {.base.} =
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, sendType: int) {.base.} = tokenSymbol: string, value: string, uuid: string, sendType: SendType) {.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,7 +30,7 @@ type TmpSendTransactionDetails = object
value: string value: string
paths: seq[TransactionPathDto] paths: seq[TransactionPathDto]
uuid: string uuid: string
sendType: int sendType: SendType
type type
Module* = ref object of io_interface.AccessInterface Module* = ref object of io_interface.AccessInterface
@ -242,7 +242,7 @@ 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, sendType: int) = method authenticateAndTransfer*(self: Module, from_addr: string, to_addr: string, tokenSymbol: string, value: string, uuid: string, sendType: SendType) =
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
@ -290,7 +290,7 @@ method onUserAuthenticated*(self: Module, password: string) =
method transactionWasSent*(self: Module, chainId: int, txHash, uuid, error: string) = method transactionWasSent*(self: Module, chainId: int, txHash, uuid, error: string) =
self.view.transactionWasSent(chainId, txHash, uuid, error) self.view.transactionWasSent(chainId, txHash, uuid, error)
method suggestedRoutes*(self: Module, account: string, amount: UInt256, token: string, disabledFromChainIDs, disabledToChainIDs, preferredChainIDs: seq[int], sendType: int, lockedInAmounts: string): string = method suggestedRoutes*(self: Module, account: string, amount: UInt256, token: string, disabledFromChainIDs, disabledToChainIDs, preferredChainIDs: seq[int], sendType: SendType, lockedInAmounts: string): string =
return self.controller.suggestedRoutes(account, amount, token, disabledFromChainIDs, disabledToChainIDs, preferredChainIDs, sendType, lockedInAmounts) return self.controller.suggestedRoutes(account, amount, token, disabledFromChainIDs, disabledToChainIDs, preferredChainIDs, sendType, lockedInAmounts)
method suggestedRoutesReady*(self: Module, suggestedRoutes: SuggestedRoutesDto) = method suggestedRoutesReady*(self: Module, suggestedRoutes: SuggestedRoutesDto) =

View File

@ -4,6 +4,7 @@ import ./io_interface, ./accounts_model, ./account_item, ./network_model, ./netw
import app/modules/shared_models/token_model import app/modules/shared_models/token_model
import app/modules/shared_models/collectibles_model as collectibles import app/modules/shared_models/collectibles_model as collectibles
import app/modules/shared_models/collectibles_nested_model as nested_collectibles import app/modules/shared_models/collectibles_nested_model as nested_collectibles
import app_service/service/transaction/dto as transaction_dto
QtObject: QtObject:
type type
@ -22,6 +23,8 @@ QtObject:
transactionRoutes: TransactionRoutes transactionRoutes: TransactionRoutes
selectedAssetSymbol: string selectedAssetSymbol: string
showUnPreferredChains: bool showUnPreferredChains: bool
sendType: transaction_dto.SendType
selectedRecipient: string
# for receive modal # for receive modal
selectedReceiveAccount: AccountItem selectedReceiveAccount: AccountItem
@ -143,6 +146,28 @@ QtObject:
read = getShowUnPreferredChains read = getShowUnPreferredChains
notify = showUnPreferredChainsChanged notify = showUnPreferredChainsChanged
proc sendTypeChanged*(self: View) {.signal.}
proc getSendType(self: View): int {.slot.} =
return ord(self.sendType)
proc setSendType(self: View, sendType: int) {.slot.} =
self.sendType = (SendType)sendType
self.sendTypeChanged()
QtProperty[int] sendType:
write = setSendType
read = getSendType
notify = sendTypeChanged
proc selectedRecipientChanged*(self: View) {.signal.}
proc getSelectedRecipient(self: View): string {.slot.} =
return self.selectedRecipient
proc setSelectedRecipient(self: View, selectedRecipient: string) {.slot.} =
self.selectedRecipient = selectedRecipient
self.selectedRecipientChanged()
QtProperty[string] selectedRecipient:
read = getSelectedRecipient
write = setSelectedRecipient
notify = selectedRecipientChanged
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:
@ -172,15 +197,14 @@ QtObject:
proc transactionWasSent*(self: View, chainId: int, txHash: string, uuid: string, error: string) {.slot} = proc transactionWasSent*(self: View, chainId: int, txHash: string, uuid: string, error: string) {.slot} =
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, value: string, uuid: string) {.slot.} =
value: string, uuid: string, sendType: int) {.slot.} = self.delegate.authenticateAndTransfer(self.selectedSenderAccount.address(), self.selectedRecipient, self.selectedAssetSymbol, value, uuid, self.sendType)
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) =
self.transactionRoutes = routes self.transactionRoutes = routes
self.suggestedRoutesReady(newQVariant(self.transactionRoutes)) self.suggestedRoutesReady(newQVariant(self.transactionRoutes))
proc suggestedRoutes*(self: View, amount: string, sendType: int): string {.slot.} = proc suggestedRoutes*(self: View, amount: string): string {.slot.} =
var parsedAmount = stint.u256(0) var parsedAmount = stint.u256(0)
try: try:
parsedAmount = amount.parse(Uint256) parsedAmount = amount.parse(Uint256)
@ -189,7 +213,7 @@ QtObject:
return self.delegate.suggestedRoutes(self.selectedSenderAccount.address(), return self.delegate.suggestedRoutes(self.selectedSenderAccount.address(),
parsedAmount, self.selectedAssetSymbol, self.fromNetworksModel.getRouteDisabledNetworkChainIds(), parsedAmount, self.selectedAssetSymbol, self.fromNetworksModel.getRouteDisabledNetworkChainIds(),
self.toNetworksModel.getRouteDisabledNetworkChainIds(), self.toNetworksModel.getRoutePreferredNetworkChainIds(), sendType, self.fromNetworksModel.getRouteLockedChainIds()) self.toNetworksModel.getRouteDisabledNetworkChainIds(), self.toNetworksModel.getRoutePreferredNetworkChainIds(), self.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)
@ -235,6 +259,8 @@ QtObject:
self.toNetworksModel.updateToNetworks(path) self.toNetworksModel.updateToNetworks(path)
proc resetStoredProperties*(self: View) {.slot.} = proc resetStoredProperties*(self: View) {.slot.} =
self.sendType = transaction_dto.SendType.Transfer
self.selectedRecipient = ""
self.fromNetworksModel.reset() self.fromNetworksModel.reset()
self.toNetworksModel.reset() self.toNetworksModel.reset()
self.transactionRoutes = newTransactionRoutes() self.transactionRoutes = newTransactionRoutes()

View File

@ -20,7 +20,7 @@ type
disabledFromChainIDs: seq[int] disabledFromChainIDs: seq[int]
disabledToChainIDs: seq[int] disabledToChainIDs: seq[int]
preferredChainIDs: seq[int] preferredChainIDs: seq[int]
sendType: int sendType: SendType
lockedInAmounts: string lockedInAmounts: string
proc getGasEthValue*(gweiValue: float, gasLimit: uint64): float = proc getGasEthValue*(gweiValue: float, gasLimit: uint64): float =
@ -88,12 +88,12 @@ const getSuggestedRoutesTask*: Task = proc(argEncoded: string) {.gcsafe, nimcall
except: except:
discard discard
let response = eth.suggestedRoutes(arg.account, amountAsHex, arg.token, arg.disabledFromChainIDs, arg.disabledToChainIDs, arg.preferredChainIDs, arg.sendType, lockedInAmounts).result let response = eth.suggestedRoutes(arg.account, amountAsHex, arg.token, arg.disabledFromChainIDs, arg.disabledToChainIDs, arg.preferredChainIDs, ord(arg.sendType), lockedInAmounts).result
var bestPaths = response["Best"].getElems().map(x => x.toTransactionPathDto()) var bestPaths = response["Best"].getElems().map(x => x.toTransactionPathDto())
# retry along with unpreferred chains incase no route is possible with preferred chains # retry along with unpreferred chains incase no route is possible with preferred chains
if(bestPaths.len == 0 and arg.preferredChainIDs.len > 0): if(bestPaths.len == 0 and arg.preferredChainIDs.len > 0):
let response = eth.suggestedRoutes(arg.account, amountAsHex, arg.token, arg.disabledFromChainIDs, arg.disabledToChainIDs, @[], arg.sendType, lockedInAmounts).result let response = eth.suggestedRoutes(arg.account, amountAsHex, arg.token, arg.disabledFromChainIDs, arg.disabledToChainIDs, @[], ord(arg.sendType), lockedInAmounts).result
bestPaths = response["Best"].getElems().map(x => x.toTransactionPathDto()) bestPaths = response["Best"].getElems().map(x => x.toTransactionPathDto())
bestPaths.sort(sortAsc[TransactionPathDto]) bestPaths.sort(sortAsc[TransactionPathDto])

View File

@ -310,10 +310,10 @@ QtObject:
uuid: string, uuid: string,
routes: seq[TransactionPathDto], routes: seq[TransactionPathDto],
password: string, password: string,
sendType: int sendType: SendType
) = ) =
try: try:
let isERC721Transfer = sendType == ord(ERC721Transfer) let isERC721Transfer = sendType == ERC721Transfer
var paths: seq[TransactionBridgeDto] = @[] var paths: seq[TransactionBridgeDto] = @[]
var chainID = 0 var chainID = 0
@ -387,7 +387,7 @@ QtObject:
uuid: string, uuid: string,
selectedRoutes: seq[TransactionPathDto], selectedRoutes: seq[TransactionPathDto],
password: string, password: string,
sendType: int sendType: SendType
) = ) =
try: try:
var chainID = 0 var chainID = 0
@ -424,7 +424,7 @@ QtObject:
error "error handling suggestedRoutesReady response", errDesription=e.msg error "error handling suggestedRoutesReady response", errDesription=e.msg
self.events.emit(SIGNAL_SUGGESTED_ROUTES_READY, SuggestedRoutesArgs(suggestedRoutes: suggestedRoutesDto)) self.events.emit(SIGNAL_SUGGESTED_ROUTES_READY, SuggestedRoutesArgs(suggestedRoutes: suggestedRoutesDto))
proc suggestedRoutes*(self: Service, account: string, amount: Uint256, token: string, disabledFromChainIDs, disabledToChainIDs, preferredChainIDs: seq[int], sendType: int, lockedInAmounts: string): SuggestedRoutesDto = proc suggestedRoutes*(self: Service, account: string, amount: Uint256, token: string, disabledFromChainIDs, disabledToChainIDs, preferredChainIDs: seq[int], sendType: SendType, lockedInAmounts: string): SuggestedRoutesDto =
let arg = GetSuggestedRoutesTaskArg( let arg = GetSuggestedRoutesTaskArg(
tptr: cast[ByteAddress](getSuggestedRoutesTask), tptr: cast[ByteAddress](getSuggestedRoutesTask),
vptr: cast[ByteAddress](self.vptr), vptr: cast[ByteAddress](self.vptr),

View File

@ -63,7 +63,6 @@ StatusSectionLayout {
property Component sendTransactionModalComponent: SendModal { property Component sendTransactionModalComponent: SendModal {
anchors.centerIn: parent anchors.centerIn: parent
selectedAccount: WalletStore.dappBrowserAccount
preSelectedHolding: store.getAsset(WalletStore.dappBrowserAccount.assets, "ETH") preSelectedHolding: store.getAsset(WalletStore.dappBrowserAccount.assets, "ETH")
preSelectedHoldingType: Constants.HoldingType.Asset preSelectedHoldingType: Constants.HoldingType.Asset
} }

View File

@ -118,7 +118,7 @@ Item {
id: releaseEnsModal id: releaseEnsModal
modalHeader: qsTr("Release your username") modalHeader: qsTr("Release your username")
interactive: false interactive: false
sendType: Constants.SendType.ENSRelease preSelectedSendType: Constants.SendType.ENSRelease
preSelectedRecipient: root.ensUsernamesStore.getEnsRegisteredAddress() preSelectedRecipient: root.ensUsernamesStore.getEnsRegisteredAddress()
preDefinedAmountToSend: LocaleUtils.numberToLocaleString(0) preDefinedAmountToSend: LocaleUtils.numberToLocaleString(0)
preSelectedHolding: store.getAsset(releaseEnsModal.store.assets, Constants.ethToken) preSelectedHolding: store.getAsset(releaseEnsModal.store.assets, Constants.ethToken)
@ -131,7 +131,7 @@ Item {
root.ensUsernamesStore.authenticateAndReleaseEns( root.ensUsernamesStore.authenticateAndReleaseEns(
root.chainId, root.chainId,
root.username, root.username,
selectedAccount.address, store.selectedSenderAccount.address,
path.gasAmount, path.gasAmount,
eip1559Enabled ? "" : path.gasFees.gasPrice, eip1559Enabled ? "" : path.gasFees.gasPrice,
eip1559Enabled ? path.gasFees.maxPriorityFeePerGas : "", eip1559Enabled ? path.gasFees.maxPriorityFeePerGas : "",

View File

@ -63,7 +63,7 @@ Item {
id: connectEnsModal id: connectEnsModal
modalHeader: qsTr("Connect username with your pubkey") modalHeader: qsTr("Connect username with your pubkey")
interactive: false interactive: false
sendType: Constants.SendType.ENSSetPubKey preSelectedSendType: Constants.SendType.ENSSetPubKey
preSelectedRecipient: root.ensUsernamesStore.getEnsRegisteredAddress() preSelectedRecipient: root.ensUsernamesStore.getEnsRegisteredAddress()
preDefinedAmountToSend: LocaleUtils.numberToLocaleString(0) preDefinedAmountToSend: LocaleUtils.numberToLocaleString(0)
preSelectedHolding: store.getAsset(connectEnsModal.store.assets, Constants.ethToken) preSelectedHolding: store.getAsset(connectEnsModal.store.assets, Constants.ethToken)
@ -75,7 +75,7 @@ Item {
root.ensUsernamesStore.authenticateAndSetPubKey( root.ensUsernamesStore.authenticateAndSetPubKey(
root.ensUsernamesStore.chainId, root.ensUsernamesStore.chainId,
ensUsername.text + (isStatus ? ".stateofus.eth" : "" ), ensUsername.text + (isStatus ? ".stateofus.eth" : "" ),
selectedAccount.address, store.selectedSenderAccount.address,
path.gasAmount, path.gasAmount,
eip1559Enabled ? "" : path.gasFees.gasPrice, eip1559Enabled ? "" : path.gasFees.gasPrice,
"", "",

View File

@ -48,7 +48,7 @@ Item {
sourceComponent: SendModal { sourceComponent: SendModal {
id: buyEnsModal id: buyEnsModal
interactive: false interactive: false
sendType: Constants.SendType.ENSRegister preSelectedSendType: Constants.SendType.ENSRegister
preSelectedRecipient: root.ensUsernamesStore.getEnsRegisteredAddress() preSelectedRecipient: root.ensUsernamesStore.getEnsRegisteredAddress()
preDefinedAmountToSend: LocaleUtils.numberToLocaleString(10) preDefinedAmountToSend: LocaleUtils.numberToLocaleString(10)
preSelectedHolding: store.getAsset(buyEnsModal.store.assets, JSON.parse(root.stickersStore.getStatusToken()).symbol) preSelectedHolding: store.getAsset(buyEnsModal.store.assets, JSON.parse(root.stickersStore.getStatusToken()).symbol)
@ -61,7 +61,7 @@ Item {
root.ensUsernamesStore.authenticateAndRegisterEns( root.ensUsernamesStore.authenticateAndRegisterEns(
root.ensUsernamesStore.chainId, root.ensUsernamesStore.chainId,
username, username,
selectedAccount.address, store.selectedSenderAccount.address,
path.gasAmount, path.gasAmount,
eip1559Enabled ? "" : path.gasFees.gasPrice, eip1559Enabled ? "" : path.gasFees.gasPrice,
eip1559Enabled ? path.gasFees.maxPriorityFeePerGas : "", eip1559Enabled ? path.gasFees.maxPriorityFeePerGas : "",

View File

@ -150,14 +150,14 @@ Item {
networkConnectionStore: root.networkConnectionStore networkConnectionStore: root.networkConnectionStore
onLaunchShareAddressModal: Global.openPopup(receiveModalComponent) onLaunchShareAddressModal: Global.openPopup(receiveModalComponent)
onLaunchSendModal: { onLaunchSendModal: {
root.sendModalPopup.sendType = Constants.SendType.Transfer root.sendModalPopup.preSelectedSendType = Constants.SendType.Transfer
root.sendModalPopup.preSelectedHoldingID = walletStore.currentViewedHoldingID root.sendModalPopup.preSelectedHoldingID = walletStore.currentViewedHoldingID
root.sendModalPopup.preSelectedHoldingType = walletStore.currentViewedHoldingType root.sendModalPopup.preSelectedHoldingType = walletStore.currentViewedHoldingType
root.sendModalPopup.onlyAssets = false root.sendModalPopup.onlyAssets = false
root.sendModalPopup.open() root.sendModalPopup.open()
} }
onLaunchBridgeModal: { onLaunchBridgeModal: {
root.sendModalPopup.sendType = Constants.SendType.Bridge root.sendModalPopup.preSelectedSendType = Constants.SendType.Bridge
root.sendModalPopup.preSelectedHoldingID = walletStore.currentViewedHoldingID root.sendModalPopup.preSelectedHoldingID = walletStore.currentViewedHoldingID
root.sendModalPopup.preSelectedHoldingType = walletStore.currentViewedHoldingType root.sendModalPopup.preSelectedHoldingType = walletStore.currentViewedHoldingType
root.sendModalPopup.onlyAssets = true root.sendModalPopup.onlyAssets = true

View File

@ -1328,38 +1328,32 @@ Item {
id: sendModal id: sendModal
active: false active: false
function open(address = "") { function open() {
this.active = true this.active = true
this.item.addressText = address;
this.item.open() this.item.open()
} }
function closed() { function closed() {
// this.sourceComponent = undefined // kill an opened instance // this.sourceComponent = undefined // kill an opened instance
this.active = false this.active = false
} }
property var selectedAccount
property var preSelectedHolding property var preSelectedHolding
property string preSelectedHoldingID property string preSelectedHoldingID
property int preSelectedHoldingType property int preSelectedHoldingType
property int sendType: -1 property int preSelectedSendType: Constants.SendType.Unknown
property bool onlyAssets: false property bool onlyAssets: false
sourceComponent: SendModal { sourceComponent: SendModal {
onlyAssets: sendModal.onlyAssets onlyAssets: sendModal.onlyAssets
onClosed: { onClosed: {
sendModal.closed() sendModal.closed()
sendModal.sendType = -1 sendModal.preSelectedSendType = Constants.SendType.Unknown
sendModal.preSelectedHoldingID = "" sendModal.preSelectedHoldingID = ""
sendModal.preSelectedHoldingType = Constants.HoldingType.Unknown sendModal.preSelectedHoldingType = Constants.HoldingType.Unknown
sendModal.preSelectedHolding = undefined sendModal.preSelectedHolding = undefined
sendModal.selectedAccount = undefined
} }
} }
onLoaded: { onLoaded: {
if (!!sendModal.selectedAccount) { if(sendModal.preSelectedSendType !== Constants.SendType.Unknown) {
item.selectedAccount = sendModal.selectedAccount item.preSelectedSendType = sendModal.preSelectedSendType
}
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

View File

@ -29,6 +29,7 @@ StatusDialog {
property var preSelectedHolding property var preSelectedHolding
property string preSelectedHoldingID property string preSelectedHoldingID
property int preSelectedHoldingType property int preSelectedHoldingType
property int preSelectedSendType
property bool interactive: true property bool interactive: true
property alias onlyAssets: holdingSelector.onlyAssets property alias onlyAssets: holdingSelector.onlyAssets
@ -36,13 +37,10 @@ StatusDialog {
property TransactionStore store: TransactionStore {} property TransactionStore store: TransactionStore {}
property CurrenciesStore currencyStore: store.currencyStore property CurrenciesStore currencyStore: store.currencyStore
property var selectedAccount: store.selectedSenderAccount
property var collectiblesModel: store.collectiblesModel property var collectiblesModel: store.collectiblesModel
property var nestedCollectiblesModel: store.nestedCollectiblesModel property var nestedCollectiblesModel: store.nestedCollectiblesModel
property var bestRoutes property var bestRoutes
property alias addressText: recipientLoader.addressText
property bool isLoading: false property bool isLoading: false
property int sendType: Constants.SendType.Transfer
property MessageDialog sendingError: MessageDialog { property MessageDialog sendingError: MessageDialog {
id: sendingError id: sendingError
@ -52,24 +50,15 @@ StatusDialog {
} }
property var sendTransaction: function() { property var sendTransaction: function() {
let recipientAddress = Utils.isValidAddress(popup.addressText) ? popup.addressText : recipientLoader.resolvedENSAddress
d.isPendingTx = true d.isPendingTx = true
popup.store.authenticateAndTransfer( popup.store.authenticateAndTransfer(amountToSendInput.cryptoValueToSend, d.uuid)
popup.selectedAccount.address,
recipientAddress,
d.selectedSymbol,
amountToSendInput.cryptoValueToSend,
d.uuid,
sendType)
} }
property var recalculateRoutesAndFees: Backpressure.debounce(popup, 600, function() { property var recalculateRoutesAndFees: Backpressure.debounce(popup, 600, function() {
if(!!popup.selectedAccount && !!holdingSelector.selectedItem if(!!store.selectedSenderAccount && !!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.isERC721Transfer ? "1" : amountToSendInput.cryptoValueToSend,
popup.sendType)
} }
}) })
@ -82,16 +71,15 @@ StatusDialog {
readonly property double maxFiatBalance: isSelectedHoldingValidAsset ? selectedHolding.totalCurrencyBalance.amount : 0 readonly property double maxFiatBalance: isSelectedHoldingValidAsset ? selectedHolding.totalCurrencyBalance.amount : 0
readonly property double maxCryptoBalance: isSelectedHoldingValidAsset ? selectedHolding.totalBalance.amount : 0 readonly property double maxCryptoBalance: isSelectedHoldingValidAsset ? selectedHolding.totalBalance.amount : 0
readonly property double maxInputBalance: amountToSendInput.inputIsFiat ? maxFiatBalance : maxCryptoBalance readonly property double maxInputBalance: amountToSendInput.inputIsFiat ? maxFiatBalance : maxCryptoBalance
readonly property string selectedSymbol: store.selectedAssetSymbol readonly property string inputSymbol: amountToSendInput.inputIsFiat ? popup.currencyStore.currentCurrency : store.selectedAssetSymbol
readonly property string inputSymbol: amountToSendInput.inputIsFiat ? popup.currencyStore.currentCurrency : selectedSymbol
readonly property bool errorMode: popup.isLoading || !recipientLoader.ready ? false : errorType !== Constants.NoError || networkSelector.errorMode || !amountToSendInput.inputNumberValid readonly property bool errorMode: popup.isLoading || !recipientLoader.ready ? false : errorType !== Constants.NoError || networkSelector.errorMode || !amountToSendInput.inputNumberValid
readonly property string uuid: Utils.uuid() readonly property string uuid: Utils.uuid()
property bool isPendingTx: false property bool isPendingTx: false
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 isBridgeTx: store.sendType === Constants.SendType.Bridge
readonly property bool isERC721Transfer: popup.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.HoldingType.Unknown
readonly property bool isSelectedHoldingValidAsset: !!selectedHolding && selectedHoldingType === Constants.HoldingType.Asset readonly property bool isSelectedHoldingValidAsset: !!selectedHolding && selectedHoldingType === Constants.HoldingType.Asset
@ -125,11 +113,11 @@ StatusDialog {
onSelectedHoldingChanged: { onSelectedHoldingChanged: {
if (d.selectedHoldingType === Constants.HoldingType.Asset) { if (d.selectedHoldingType === Constants.HoldingType.Asset) {
if(popup.sendType !== Constants.SendType.Bridge) if(store.sendType !== Constants.SendType.Bridge)
popup.sendType = 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.HoldingType.Collectible) {
popup.sendType = 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)
store.setRouteEnabledFromChains(selectedHolding.chainId) store.setRouteEnabledFromChains(selectedHolding.chainId)
@ -148,11 +136,13 @@ StatusDialog {
color: Theme.palette.baseColor3 color: Theme.palette.baseColor3
} }
onSelectedAccountChanged: popup.recalculateRoutesAndFees()
onOpened: { onOpened: {
amountToSendInput.input.input.edit.forceActiveFocus() amountToSendInput.input.input.edit.forceActiveFocus()
if(popup.preSelectedSendType !== Constants.SendType.Unknown) {
store.setSendType(popup.preSelectedSendType)
}
if (popup.preSelectedHoldingType !== Constants.HoldingType.Unknown) { if (popup.preSelectedHoldingType !== Constants.HoldingType.Unknown) {
tokenListRect.browsingHoldingType = popup.preSelectedHoldingType tokenListRect.browsingHoldingType = popup.preSelectedHoldingType
if(!!popup.preSelectedHolding) { if(!!popup.preSelectedHolding) {
@ -173,7 +163,7 @@ StatusDialog {
if(d.isBridgeTx) { if(d.isBridgeTx) {
recipientLoader.selectedRecipientType = TabAddressSelectorView.Type.Address recipientLoader.selectedRecipientType = TabAddressSelectorView.Type.Address
recipientLoader.selectedRecipient = {address: popup.selectedAccount.address} recipientLoader.selectedRecipient = {address: store.selectedSenderAccount.address}
} }
} }
@ -187,9 +177,13 @@ StatusDialog {
sorters: RoleSorter { roleName: "position"; sortOrder: Qt.AscendingOrder } sorters: RoleSorter { roleName: "position"; sortOrder: Qt.AscendingOrder }
} }
selectedAccount: !!popup.selectedAccount ? popup.selectedAccount: {} selectedAccount: !!store.selectedSenderAccount ? store.selectedSenderAccount: {}
getNetworkShortNames: function(chainIds) {return store.getNetworkShortNames(chainIds)} getNetworkShortNames: function(chainIds) {return store.getNetworkShortNames(chainIds)}
onSelectedIndexChanged: store.switchSenderAccount(selectedIndex) onSelectedIndexChanged: {
store.switchSenderAccount(selectedIndex)
d.setSelectedHoldingId(d.selectedHolding.symbol, d.selectedHoldingType)
popup.recalculateRoutesAndFees()
}
} }
@ -249,8 +243,8 @@ StatusDialog {
id: holdingSelector id: holdingSelector
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
assetsModel: popup.selectedAccount && popup.selectedAccount.assets ? popup.selectedAccount.assets : null assetsModel:store.selectedSenderAccount && store.selectedSenderAccount.assets ? store.selectedSenderAccount.assets : null
collectiblesModel: popup.selectedAccount ? popup.nestedCollectiblesModel : null collectiblesModel: store.selectedSenderAccount ? popup.nestedCollectiblesModel : null
currentCurrencySymbol: RootStore.currencyStore.currentCurrencySymbol currentCurrencySymbol: RootStore.currencyStore.currentCurrencySymbol
visible: (!!d.selectedHolding && d.selectedHoldingType !== Constants.HoldingType.Unknown) || visible: (!!d.selectedHolding && d.selectedHoldingType !== Constants.HoldingType.Unknown) ||
(!!d.hoveredHolding && d.hoveredHoldingType !== Constants.HoldingType.Unknown) (!!d.hoveredHolding && d.hoveredHoldingType !== Constants.HoldingType.Unknown)
@ -294,7 +288,7 @@ StatusDialog {
Layout.fillWidth: true Layout.fillWidth: true
isBridgeTx: d.isBridgeTx isBridgeTx: d.isBridgeTx
interactive: popup.interactive interactive: popup.interactive
selectedSymbol: d.selectedSymbol selectedSymbol: store.selectedAssetSymbol
maxInputBalance: d.maxInputBalance maxInputBalance: d.maxInputBalance
currentCurrency: popup.currencyStore.currentCurrency currentCurrency: popup.currencyStore.currentCurrency
@ -324,7 +318,7 @@ StatusDialog {
visible: !!popup.bestRoutes && popup.bestRoutes !== undefined && visible: !!popup.bestRoutes && popup.bestRoutes !== undefined &&
popup.bestRoutes.count > 0 && amountToSendInput.inputNumberValid popup.bestRoutes.count > 0 && amountToSendInput.inputNumberValid
isLoading: popup.isLoading isLoading: popup.isLoading
selectedSymbol: d.selectedSymbol selectedSymbol: store.selectedAssetSymbol
isBridgeTx: d.isBridgeTx isBridgeTx: d.isBridgeTx
cryptoValueToReceive: d.totalAmountToReceive cryptoValueToReceive: d.totalAmountToReceive
inputIsFiat: amountToSendInput.inputIsFiat inputIsFiat: amountToSendInput.inputIsFiat
@ -376,8 +370,8 @@ StatusDialog {
anchors.rightMargin: Style.current.bigPadding anchors.rightMargin: Style.current.bigPadding
visible: !d.selectedHolding visible: !d.selectedHolding
assets: popup.selectedAccount && popup.selectedAccount.assets ? popup.selectedAccount.assets : null assets: store.selectedSenderAccount && store.selectedSenderAccount.assets ? store.selectedSenderAccount.assets : null
collectibles: popup.selectedAccount ? popup.nestedCollectiblesModel : null collectibles: store.selectedSenderAccount ? popup.nestedCollectiblesModel : null
onlyAssets: holdingSelector.onlyAssets onlyAssets: holdingSelector.onlyAssets
searchTokenSymbolByAddressFn: function (address) { searchTokenSymbolByAddressFn: function (address) {
return store.findTokenSymbolByAddress(address) return store.findTokenSymbolByAddress(address)
@ -422,6 +416,7 @@ StatusDialog {
selectedAsset: d.selectedHolding selectedAsset: d.selectedHolding
onIsLoading: popup.isLoading = true onIsLoading: popup.isLoading = true
onRecalculateRoutesAndFees: popup.recalculateRoutesAndFees() onRecalculateRoutesAndFees: popup.recalculateRoutesAndFees()
onAddressTextChanged: store.setSelectedRecipient(addressText)
} }
} }
@ -432,7 +427,7 @@ StatusDialog {
anchors.leftMargin: Style.current.bigPadding anchors.leftMargin: Style.current.bigPadding
anchors.rightMargin: Style.current.bigPadding anchors.rightMargin: Style.current.bigPadding
store: popup.store store: popup.store
selectedAccount: popup.selectedAccount selectedAccount: store.selectedSenderAccount
onRecipientSelected: { onRecipientSelected: {
recipientLoader.selectedRecipientType = type recipientLoader.selectedRecipientType = type
recipientLoader.selectedRecipient = recipient recipientLoader.selectedRecipient = recipient
@ -449,7 +444,7 @@ StatusDialog {
anchors.rightMargin: Style.current.bigPadding anchors.rightMargin: Style.current.bigPadding
store: popup.store store: popup.store
interactive: popup.interactive interactive: popup.interactive
selectedAccount: popup.selectedAccount selectedAccount: store.selectedSenderAccount
ensAddressOrEmpty: recipientLoader.resolvedENSAddress ensAddressOrEmpty: recipientLoader.resolvedENSAddress
amountToSend: amountToSendInput.cryptoValueToSendFloat amountToSend: amountToSendInput.cryptoValueToSendFloat
minSendCryptoDecimals: amountToSendInput.minSendCryptoDecimals minSendCryptoDecimals: amountToSendInput.minSendCryptoDecimals
@ -470,7 +465,7 @@ StatusDialog {
anchors.leftMargin: Style.current.bigPadding anchors.leftMargin: Style.current.bigPadding
anchors.rightMargin: Style.current.bigPadding anchors.rightMargin: Style.current.bigPadding
visible: recipientLoader.ready && !!d.selectedHolding && networkSelector.advancedOrCustomMode && amountToSendInput.inputNumberValid visible: recipientLoader.ready && !!d.selectedHolding && networkSelector.advancedOrCustomMode && amountToSendInput.inputNumberValid
selectedTokenSymbol: d.selectedSymbol selectedTokenSymbol: store.selectedAssetSymbol
isLoading: popup.isLoading isLoading: popup.isLoading
bestRoutes: popup.bestRoutes bestRoutes: popup.bestRoutes
store: popup.store store: popup.store

View File

@ -200,7 +200,7 @@ Item {
required property string packId required property string packId
interactive: false interactive: false
sendType: Constants.SendType.StickersBuy preSelectedSendType: Constants.SendType.StickersBuy
preSelectedRecipient: root.store.stickersStore.getStickersMarketAddress() preSelectedRecipient: root.store.stickersStore.getStickersMarketAddress()
preDefinedAmountToSend: LocaleUtils.numberToLocaleString(parseFloat(price)) preDefinedAmountToSend: LocaleUtils.numberToLocaleString(parseFloat(price))
preSelectedHolding: store.getAsset(buyStickersModal.store.assets, JSON.parse(root.store.stickersStore.getStatusToken()).symbol) preSelectedHolding: store.getAsset(buyStickersModal.store.assets, JSON.parse(root.store.stickersStore.getStatusToken()).symbol)
@ -211,7 +211,7 @@ Item {
let eip1559Enabled = path.gasFees.eip1559Enabled let eip1559Enabled = path.gasFees.eip1559Enabled
let maxFeePerGas = path.gasFees.maxFeePerGasM let maxFeePerGas = path.gasFees.maxFeePerGasM
root.store.stickersStore.authenticateAndBuy(packId, root.store.stickersStore.authenticateAndBuy(packId,
selectedAccount.address, store.selectedSenderAccount.address,
path.gasAmount, path.gasAmount,
eip1559Enabled ? "" : path.gasFees.gasPrice, eip1559Enabled ? "" : path.gasFees.gasPrice,
eip1559Enabled ? path.gasFees.maxPriorityFeePerGas : "", eip1559Enabled ? path.gasFees.maxPriorityFeePerGas : "",

View File

@ -69,7 +69,7 @@ ModalPopup {
SendModal { SendModal {
id: buyStickersPackModal id: buyStickersPackModal
interactive: false interactive: false
sendType: Constants.SendType.StickersBuy preSelectedSendType: Constants.SendType.StickersBuy
preSelectedRecipient: stickerPackDetailsPopup.store.stickersStore.getStickersMarketAddress() preSelectedRecipient: stickerPackDetailsPopup.store.stickersStore.getStickersMarketAddress()
preDefinedAmountToSend: LocaleUtils.numberToLocaleString(parseFloat(price)) preDefinedAmountToSend: LocaleUtils.numberToLocaleString(parseFloat(price))
preSelectedHolding: store.getAsset(buyStickersPackModal.store.assets, JSON.parse(stickerPackDetailsPopup.store.stickersStore.getStatusToken()).symbol) preSelectedHolding: store.getAsset(buyStickersPackModal.store.assets, JSON.parse(stickerPackDetailsPopup.store.stickersStore.getStatusToken()).symbol)
@ -80,7 +80,7 @@ ModalPopup {
let eip1559Enabled = path.gasFees.eip1559Enabled let eip1559Enabled = path.gasFees.eip1559Enabled
let maxFeePerGas = path.gasFees.maxFeePerGasM let maxFeePerGas = path.gasFees.maxFeePerGasM
stickerPackDetailsPopup.store.stickersStore.authenticateAndBuy(packId, stickerPackDetailsPopup.store.stickersStore.authenticateAndBuy(packId,
selectedAccount.address, store.selectedSenderAccount.address,
path.gasAmount, path.gasAmount,
eip1559Enabled ? "" : path.gasFees.gasPrice, eip1559Enabled ? "" : path.gasFees.gasPrice,
eip1559Enabled ? path.gasFees.maxPriorityFeePerGas : "", eip1559Enabled ? path.gasFees.maxPriorityFeePerGas : "",

View File

@ -37,6 +37,16 @@ QtObject {
} }
property string selectedAssetSymbol: walletSectionSendInst.selectedAssetSymbol property string selectedAssetSymbol: walletSectionSendInst.selectedAssetSymbol
property bool showUnPreferredChains: walletSectionSendInst.showUnPreferredChains property bool showUnPreferredChains: walletSectionSendInst.showUnPreferredChains
property int sendType: walletSectionSendInst.sendType
property string selectedRecipient: walletSectionSendInst.selectedRecipient
function setSendType(sendType) {
walletSectionSendInst.setSendType(sendType)
}
function setSelectedRecipient(recipientAddress) {
walletSectionSendInst.setSelectedRecipient(recipientAddress)
}
function getEtherscanLink(chainID) { function getEtherscanLink(chainID) {
return networksModule.all.getBlockExplorerURL(chainID) return networksModule.all.getBlockExplorerURL(chainID)
@ -46,12 +56,12 @@ QtObject {
globalUtils.copyToClipboard(text) globalUtils.copyToClipboard(text)
} }
function authenticateAndTransfer(from, to, tokenSymbol, amount, uuid, sendType) { function authenticateAndTransfer(amount, uuid) {
walletSectionSendInst.authenticateAndTransfer(from, to, tokenSymbol, amount, uuid, sendType) walletSectionSendInst.authenticateAndTransfer(amount, uuid)
} }
function suggestedRoutes(amount, sendType) { function suggestedRoutes(amount) {
walletSectionSendInst.suggestedRoutes(amount, sendType) walletSectionSendInst.suggestedRoutes(amount)
} }
function resolveENS(value) { function resolveENS(value) {

View File

@ -984,7 +984,8 @@ QtObject {
ENSSetPubKey, ENSSetPubKey,
StickersBuy, StickersBuy,
Bridge, Bridge,
ERC721Transfer ERC721Transfer,
Unknown
} }
enum ErrorType { enum ErrorType {