fix(@desktop/wallet): Remove gas selector for slow, optimal and fast

fixes #8516
This commit is contained in:
Khushboo Mehta 2022-11-30 13:59:21 +01:00 committed by Khushboo-dev-cpp
parent 8fd5e9d1af
commit 779df7628b
19 changed files with 88 additions and 212 deletions

View File

@ -107,15 +107,15 @@ proc estimateGas*(self: Controller, from_addr: string, to: string, assetSymbol:
result = "0"
proc transfer*(self: Controller, from_addr: string, to_addr: string, tokenSymbol: string,
value: string, uuid: string, priority: int, selectedRoutes: string, password: string) =
self.transactionService.transfer(from_addr, to_addr, tokenSymbol, value, uuid, priority, selectedRoutes, password)
value: string, uuid: string, selectedRoutes: string, password: string) =
self.transactionService.transfer(from_addr, to_addr, tokenSymbol, value, uuid, selectedRoutes, password)
proc suggestedFees*(self: Controller, chainId: int): string =
let suggestedFees = self.transactionService.suggestedFees(chainId)
return suggestedFees.toJson()
proc suggestedRoutes*(self: Controller, account: string, amount: Uint256, token: string, disabledFromChainIDs, disabledToChainIDs, preferredChainIDs: seq[uint64], priority: int, sendType: int): string =
let suggestedRoutes = self.transactionService.suggestedRoutes(account, amount, token, disabledFromChainIDs, disabledToChainIDs, preferredChainIDs, priority, sendType)
proc suggestedRoutes*(self: Controller, account: string, amount: Uint256, token: string, disabledFromChainIDs, disabledToChainIDs, preferredChainIDs: seq[uint64], sendType: int): string =
let suggestedRoutes = self.transactionService.suggestedRoutes(account, amount, token, disabledFromChainIDs, disabledToChainIDs, preferredChainIDs, sendType)
return suggestedRoutes.toJson()
proc getChainIdForChat*(self: Controller): int =

View File

@ -44,8 +44,7 @@ method onUserAuthenticated*(self: AccessInterface, password: string) {.base.} =
raise newException(ValueError, "No implementation available")
method authenticateAndTransfer*(self: AccessInterface, from_addr: string, to_addr: string,
tokenSymbol: string, value: string, uuid: string,
priority: int, selectedRoutes: string) {.base.} =
tokenSymbol: string, value: string, uuid: string, selectedRoutes: string) {.base.} =
raise newException(ValueError, "No implementation available")
method transactionWasSent*(self: AccessInterface, result: string) {.base.} =
@ -54,7 +53,7 @@ method transactionWasSent*(self: AccessInterface, result: string) {.base.} =
method suggestedFees*(self: AccessInterface, chainId: int): string {.base.} =
raise newException(ValueError, "No implementation available")
method suggestedRoutes*(self: AccessInterface, account: string, amount: UInt256, token: string, disabledFromChainIDs, disabledToChainIDs, preferredChainIDs: seq[uint64], priority: int, sendType: int): string {.base.} =
method suggestedRoutes*(self: AccessInterface, account: string, amount: UInt256, token: string, disabledFromChainIDs, disabledToChainIDs, preferredChainIDs: seq[uint64], sendType: int): string {.base.} =
raise newException(ValueError, "No implementation available")
method getChainIdForChat*(self: AccessInterface): int =

View File

@ -19,7 +19,6 @@ type TmpSendTransactionDetails = object
tokenSymbol: string
value: string
uuid: string
priority: int
selectedRoutes: string
type
@ -99,14 +98,12 @@ method setIsNonArchivalNode*(self: Module, isNonArchivalNode: bool) =
self.view.setIsNonArchivalNode(isNonArchivalNode)
method authenticateAndTransfer*(self: Module, from_addr: string, to_addr: string,
tokenSymbol: string, value: string, uuid: string,
priority: int, selectedRoutes: string) =
tokenSymbol: string, value: string, uuid: string, selectedRoutes: string) =
self.tmpSendTransactionDetails.fromAddr = from_addr
self.tmpSendTransactionDetails.toAddr = to_addr
self.tmpSendTransactionDetails.tokenSymbol = tokenSymbol
self.tmpSendTransactionDetails.value = value
self.tmpSendTransactionDetails.uuid = uuid
self.tmpSendTransactionDetails.priority = priority
self.tmpSendTransactionDetails.selectedRoutes = selectedRoutes
if singletonInstance.userProfile.getIsKeycardUser():
@ -142,8 +139,8 @@ method onUserAuthenticated*(self: Module, password: string) =
self.view.transactionWasSent($response)
else:
self.controller.transfer(self.tmpSendTransactionDetails.fromAddr, self.tmpSendTransactionDetails.toAddr,
self.tmpSendTransactionDetails.tokenSymbol, self.tmpSendTransactionDetails.value, self.tmpSendTransactionDetails.uuid,
self.tmpSendTransactionDetails.priority, self.tmpSendTransactionDetails.selectedRoutes, password)
self.tmpSendTransactionDetails.tokenSymbol, self.tmpSendTransactionDetails.value, self.tmpSendTransactionDetails.uuid,
self.tmpSendTransactionDetails.selectedRoutes, password)
method transactionWasSent*(self: Module, result: string) =
self.view.transactionWasSent(result)
@ -152,8 +149,8 @@ method transactionWasSent*(self: Module, result: string) =
method suggestedFees*(self: Module, chainId: int): string =
return self.controller.suggestedFees(chainId)
method suggestedRoutes*(self: Module, account: string, amount: UInt256, token: string, disabledFromChainIDs, disabledToChainIDs, preferredChainIDs: seq[uint64], priority: int, sendType: int): string =
return self.controller.suggestedRoutes(account, amount, token, disabledFromChainIDs, disabledToChainIDs, preferredChainIDs, priority, sendType)
method suggestedRoutes*(self: Module, account: string, amount: UInt256, token: string, disabledFromChainIDs, disabledToChainIDs, preferredChainIDs: seq[uint64], sendType: int): string =
return self.controller.suggestedRoutes(account, amount, token, disabledFromChainIDs, disabledToChainIDs, preferredChainIDs, sendType)
method getChainIdForChat*(self: Module): int =
return self.controller.getChainIdForChat()

View File

@ -114,13 +114,13 @@ QtObject:
self.transactionSent(txResult)
proc authenticateAndTransfer*(self: View, from_addr: string, to_addr: string, tokenSymbol: string,
value: string, uuid: string, priority: int, selectedRoutes: string) {.slot.} =
self.delegate.authenticateAndTransfer(from_addr, to_addr, tokenSymbol, value, uuid, priority, selectedRoutes)
value: string, uuid: string, selectedRoutes: string) {.slot.} =
self.delegate.authenticateAndTransfer(from_addr, to_addr, tokenSymbol, value, uuid, selectedRoutes)
proc suggestedFees*(self: View, chainId: int): string {.slot.} =
return self.delegate.suggestedFees(chainId)
proc suggestedRoutes*(self: View, account: string, amount: string, token: string, disabledFromChainIDs: string, disabledToChainIDs: string, preferredChainIDs: string, priority: int, sendType: int): string {.slot.} =
proc suggestedRoutes*(self: View, account: string, amount: string, token: string, disabledFromChainIDs: string, disabledToChainIDs: string, preferredChainIDs: string, sendType: int): string {.slot.} =
var parsedAmount = stint.u256("0")
var seqPreferredChainIDs = seq[uint64] : @[]
var seqDisabledFromChainIDs = seq[uint64] : @[]
@ -149,7 +149,7 @@ QtObject:
except Exception as e:
discard
return self.delegate.suggestedRoutes(account, parsedAmount, token, seqDisabledFromChainIDs, seqDisabledToChainIDs, seqPreferredChainIDs, priority, sendType)
return self.delegate.suggestedRoutes(account, parsedAmount, token, seqDisabledFromChainIDs, seqDisabledToChainIDs, seqPreferredChainIDs, sendType)
proc getChainIdForChat*(self: View): int {.slot.} =
return self.delegate.getChainIdForChat()

View File

@ -39,7 +39,6 @@ type
disabledFromChainIDs: seq[uint64]
disabledToChainIDs: seq[uint64]
preferredChainIDs: seq[uint64]
priority: int
sendType: int
proc getGasEthValue*(gweiValue: float, gasLimit: uint64): float =
@ -47,32 +46,19 @@ proc getGasEthValue*(gweiValue: float, gasLimit: uint64): float =
let ethValue = parseFloat(service_conversion.wei2Eth(weiValue))
return ethValue
proc getFeesTotal*(paths: seq[TransactionPathDto]): seq[Fees] =
proc getFeesTotal*(paths: seq[TransactionPathDto]): Fees =
var fees: Fees = Fees()
if(paths.len == 0):
return @[]
return fees
var fees: seq[Fees] = @[Fees(), Fees(), Fees()]
for path in paths:
var slowPrice = path.gasFees.gasPrice
var optimalPrice = path.gasFees.gasPrice
var fastPrice = path.gasFees.gasPrice
if path.gasFees.eip1559Enabled:
slowPrice = path.gasFees.maxFeePerGasL
optimalPrice = path.gasFees.maxFeePerGasM
fastPrice = path.gasFees.maxFeePerGasH
fees[0].totalFeesInEth += getGasEthValue(slowPrice, path.gasAmount)
fees[1].totalFeesInEth += getGasEthValue(optimalPrice, path.gasAmount)
fees[2].totalFeesInEth += getGasEthValue(fastPrice, path.gasAmount)
fees[0].totalTokenFees += path.tokenFees
fees[1].totalTokenFees += path.tokenFees
fees[2].totalTokenFees += path.tokenFees
# keeping it same for all as path will change when priority changes changing the time needed and so on
fees[0].totalTime += path.estimatedTime
fees[1].totalTime += path.estimatedTime
fees[2].totalTime += path.estimatedTime
fees.totalFeesInEth += getGasEthValue(optimalPrice, path.gasAmount)
fees.totalTokenFees += path.tokenFees
fees.totalTime += path.estimatedTime
return fees
const getSuggestedRoutesTask*: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
@ -80,13 +66,13 @@ const getSuggestedRoutesTask*: Task = proc(argEncoded: string) {.gcsafe, nimcall
try:
let amountAsHex = "0x" & eth_utils.stripLeadingZeros(arg.amount.toHex)
let response = eth.suggestedRoutes(arg.account, amountAsHex, arg.token, arg.disabledFromChainIDs, arg.disabledToChainIDs, arg.preferredChainIDs, arg.priority, arg.sendType).result
let response = eth.suggestedRoutes(arg.account, amountAsHex, arg.token, arg.disabledFromChainIDs, arg.disabledToChainIDs, arg.preferredChainIDs, arg.sendType).result
var bestPaths = response["Best"].getElems().map(x => x.toTransactionPathDto())
# retry along with unpreferred chains incase no route is possible with preferred chains
if(bestPaths.len == 0 and arg.preferredChainIDs.len > 0):
let response = eth.suggestedRoutes(arg.account, amountAsHex, arg.token, arg.disabledFromChainIDs, arg.disabledToChainIDs, @[], arg.priority, arg.sendType).result
let response = eth.suggestedRoutes(arg.account, amountAsHex, arg.token, arg.disabledFromChainIDs, arg.disabledToChainIDs, @[], arg.sendType).result
bestPaths = response["Best"].getElems().map(x => x.toTransactionPathDto())
bestPaths.sort(sortAsc[TransactionPathDto])
@ -94,14 +80,14 @@ const getSuggestedRoutesTask*: Task = proc(argEncoded: string) {.gcsafe, nimcall
"suggestedRoutes": SuggestedRoutesDto(
best: bestPaths,
candidates: response["Candidates"].getElems().map(x => x.toTransactionPathDto()),
gasTimeEstimates: getFeesTotal(bestPaths)),
gasTimeEstimate: getFeesTotal(bestPaths)),
"error": ""
}
arg.finish(output)
except Exception as e:
let output = %* {
"suggestedRoutes": SuggestedRoutesDto(best: @[], candidates: @[],gasTimeEstimates: @[]),
"suggestedRoutes": SuggestedRoutesDto(best: @[], candidates: @[], gasTimeEstimate: Fees()),
"error": fmt"Error getting suggested routes: {e.msg}"
}
arg.finish(output)

View File

@ -219,4 +219,4 @@ type
SuggestedRoutesDto* = ref object
best*: seq[TransactionPathDto]
candidates*: seq[TransactionPathDto]
gasTimeEstimates*: seq[Fees]
gasTimeEstimate*: Fees

View File

@ -279,7 +279,6 @@ QtObject:
tokenSymbol: string,
value: string,
uuid: string,
priority: int,
selectedRoutes: string,
password: string,
) =
@ -317,25 +316,18 @@ QtObject:
var simpleTx = TransactionDataDto()
var hopTx = TransactionDataDto()
var txData = TransactionDataDto()
var maxFees: float = 0
var gasFees: string = ""
case(priority):
of 0: maxFees = route.gasFees.maxFeePerGasL
of 1: maxFees = route.gasFees.maxFeePerGasM
of 2: maxFees = route.gasFees.maxFeePerGasH
else: maxFees = 0
if( not route.gasFees.eip1559Enabled):
gasFees = $route.gasFees.gasPrice
if(isEthTx) :
txData = ens_utils.buildTransaction(parseAddress(from_addr), eth2Wei(parseFloat(value), 18),
$route.gasAmount, gasFees, route.gasFees.eip1559Enabled, $route.gasFees.maxPriorityFeePerGas, $maxFees)
$route.gasAmount, gasFees, route.gasFees.eip1559Enabled, $route.gasFees.maxPriorityFeePerGas, $route.gasFees.maxFeePerGasM)
txData.to = parseAddress(to_addr).some
else:
txData = ens_utils.buildTokenTransaction(parseAddress(from_addr), toAddress,
$route.gasAmount, gasFees, route.gasFees.eip1559Enabled, $route.gasFees.maxPriorityFeePerGas, $maxFees)
$route.gasAmount, gasFees, route.gasFees.eip1559Enabled, $route.gasFees.maxPriorityFeePerGas, $route.gasFees.maxFeePerGasM)
txData.data = data
var path = TransactionBridgeDto(bridgeName: route.bridgeName, chainID: route.fromNetwork.chainId)
@ -387,7 +379,7 @@ QtObject:
proc suggestedRoutesReady*(self: Service, suggestedRoutes: string) {.slot.} =
self.events.emit(SIGNAL_SUGGESTED_ROUTES_READY, SuggestedRoutesArgs(suggestedRoutes: suggestedRoutes))
proc suggestedRoutes*(self: Service, account: string, amount: Uint256, token: string, disabledFromChainIDs, disabledToChainIDs, preferredChainIDs: seq[uint64], priority: int, sendType: int): SuggestedRoutesDto =
proc suggestedRoutes*(self: Service, account: string, amount: Uint256, token: string, disabledFromChainIDs, disabledToChainIDs, preferredChainIDs: seq[uint64], sendType: int): SuggestedRoutesDto =
let arg = GetSuggestedRoutesTaskArg(
tptr: cast[ByteAddress](getSuggestedRoutesTask),
vptr: cast[ByteAddress](self.vptr),
@ -398,7 +390,6 @@ QtObject:
disabledFromChainIDs: disabledFromChainIDs,
disabledToChainIDs: disabledToChainIDs,
preferredChainIDs: preferredChainIDs,
priority: priority,
sendType: sendType
)
self.threadpool.start(arg)

View File

@ -28,6 +28,6 @@ proc suggestedFees*(chainId: int): RpcResponse[JsonNode] {.raises: [Exception].}
let payload = %* [chainId]
return core.callPrivateRPC("wallet_getSuggestedFees", payload)
proc suggestedRoutes*(account: string, amount: string, token: string, disabledFromChainIDs, disabledToChainIDs, preferredChainIDs: seq[uint64], priority: int, sendType: int): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [sendType, account, amount, token, disabledFromChainIDs, disabledToChainIDs, preferredChainIDs, priority]
proc suggestedRoutes*(account: string, amount: string, token: string, disabledFromChainIDs, disabledToChainIDs, preferredChainIDs: seq[uint64], sendType: int): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [sendType, account, amount, token, disabledFromChainIDs, disabledToChainIDs, preferredChainIDs, 1]
return core.callPrivateRPC("wallet_getSuggestedRoutes", payload)

View File

@ -97,9 +97,7 @@ QtObject {
if(sendDialog.bestRoutes.length === 1) {
let path = sendDialog.bestRoutes[0]
let eip1559Enabled = path.gasFees.eip1559Enabled
let maxFeePerGas = (sendDialog.selectedPriority === 0) ? path.gasFees.maxFeePerGasL:
(sendDialog.selectedPriority === 1) ? path.gasFees.maxFeePerGasM:
path.gasFees.maxFeePerGasH
let maxFeePerGas = path.gasFees.maxFeePerGasM
let trx = request.payload.params[0]
// TODO: use bignumber instead of floats
trx.value = RootStore.getEth2Hex(parseFloat(value))

View File

@ -519,8 +519,8 @@ QtObject {
return walletSectionTransactions.estimateGas(from_addr, to, assetSymbol, value === "" ? "0.00" : value, chainId, data)
}
function authenticateAndTransfer(from, to, tokenSymbol, amount, uuid, priority, selectedRoutes) {
walletSectionTransactions.authenticateAndTransfer(from, to, tokenSymbol, amount, uuid, priority, selectedRoutes)
function authenticateAndTransfer(from, to, tokenSymbol, amount, uuid, selectedRoutes) {
walletSectionTransactions.authenticateAndTransfer(from, to, tokenSymbol, amount, uuid, selectedRoutes)
}
function getAccountNameByAddress(address) {
@ -540,8 +540,8 @@ QtObject {
return JSON.parse(walletSectionTransactions.suggestedFees(chainId))
}
function suggestedRoutes(account, amount, token, disabledFromChainIDs, disabledToChainIDs, preferredChainIds, priority, sendType) {
walletSectionTransactions.suggestedRoutes(account, amount, token, disabledFromChainIDs, disabledToChainIDs, preferredChainIds, priority, sendType)
function suggestedRoutes(account, amount, token, disabledFromChainIDs, disabledToChainIDs, preferredChainIds, sendType) {
walletSectionTransactions.suggestedRoutes(account, amount, token, disabledFromChainIDs, disabledToChainIDs, preferredChainIds, sendType)
}
function resolveENS(value) {

View File

@ -130,9 +130,7 @@ Item {
if(bestRoutes.length === 1) {
let path = bestRoutes[0]
let eip1559Enabled = path.gasFees.eip1559Enabled
let maxFeePerGas = (selectedPriority === 0) ? path.gasFees.maxFeePerGasL:
(selectedPriority === 1) ? path.gasFees.maxFeePerGasM:
path.gasFees.maxFeePerGasH
let maxFeePerGas = path.gasFees.maxFeePerGasM
root.ensUsernamesStore.authenticateAndReleaseEns(
root.username,
selectedAccount.address,

View File

@ -70,9 +70,7 @@ Item {
if(bestRoutes.length === 1) {
let path = bestRoutes[0]
let eip1559Enabled = path.gasFees.eip1559Enabled
let maxFeePerGas = (selectedPriority === 0) ? path.gasFees.maxFeePerGasL:
(selectedPriority === 1) ? path.gasFees.maxFeePerGasM:
path.gasFees.maxFeePerGasH
let maxFeePerGas = path.gasFees.maxFeePerGasM
root.ensUsernamesStore.authenticateAndRegisterEns(
username,
selectedAccount.address,

View File

@ -17,89 +17,13 @@ Item {
property string selectedTokenSymbol
property string currentCurrency
property string currentCurrencySymbol
property bool advancedOrCustomMode: false
property var bestRoutes: []
property var estimatedGasFeesTime: []
property int selectedPriority: 1
property double selectedGasEthValue
property string selectedGasFiatValue
property string selectedTimeEstimate
property var getGasEthValue: function () {}
property var getFiatValue: function () {}
enum Priority {
SLOW, // 0
OPTIMAL, // 1
FAST // 2
}
enum EstimatedTime {
Unknown = 0,
LessThanOneMin,
LessThanThreeMins,
LessThanFiveMins,
MoreThanFiveMins
}
QtObject {
id: d
function getLabelForEstimatedTxTime(estimatedFlag) {
switch(estimatedFlag) {
case GasSelector.EstimatedTime.Unknown:
return qsTr("~ Unknown")
case GasSelector.EstimatedTime.LessThanOneMin :
return qsTr("< 1 minute")
case GasSelector.EstimatedTime.LessThanThreeMins :
return qsTr("< 3 minutes")
case GasSelector.EstimatedTime.LessThanFiveMins:
return qsTr("< 5 minutes")
default:
return qsTr("> 5 minutes")
}
}
}
width: parent.width
height: visible ? (!advancedOrCustomMode ? selectorButtons.height : advancedGasSelector.height) + Style.current.halfPadding : 0
Row {
id: selectorButtons
visible: !root.advancedOrCustomMode
anchors.top: parent.top
anchors.topMargin: Style.current.halfPadding
spacing: 11
ButtonGroup {
buttons: gasPrioRepeater.children
}
Repeater {
id: gasPrioRepeater
model: root.estimatedGasFeesTime
GasSelectorButton {
objectName: "GasSelector_slowGasButton"
property double totalFeesInFiat: parseFloat(root.getFiatValue(modelData.totalFeesInEth, "ETH", currentCurrency)) +
parseFloat(root.getFiatValue(modelData.totalTokenFees, root.selectedTokenSymbol, currentCurrency))
primaryText: index === 0 ? qsTr("Slow") : index === 1 ? qsTr("Optimal"): qsTr("Fast")
timeText: index === selectedPriority ? d.getLabelForEstimatedTxTime(modelData.totalTime): qsTr("~ Unknown")
totalGasEthValue: modelData.totalFeesInEth
totalGasFiatValue: index === selectedPriority ? "%1 %2".arg(LocaleUtils.numberToLocaleString(totalFeesInFiat)).arg(root.currentCurrency.toUpperCase()): qsTr("...")
checked: index === selectedPriority
onCheckedChanged: {
if(checked) {
root.selectedPriority = index
root.selectedGasEthValue = totalGasEthValue
root.selectedGasFiatValue = totalGasFiatValue
root.selectedTimeEstimate = timeText
}
}
}
}
}
height: visible ? advancedGasSelector.height + Style.current.halfPadding : 0
Column {
id: advancedGasSelector
@ -109,37 +33,9 @@ Item {
anchors.left: parent.left
anchors.right: parent.right
anchors.rightMargin: 10
visible: root.advancedOrCustomMode
spacing: Style.current.halfPadding
StatusSwitchTabBar {
id: tabBar
width: parent.width
anchors.horizontalCenter: parent.horizontalCenter
visible: root.advancedOrCustomMode
StatusSwitchTabButton {
text: qsTr("Slow")
}
StatusSwitchTabButton {
text: qsTr("Optimal")
}
StatusSwitchTabButton {
text: qsTr("Fast")
}
currentIndex: GasSelector.Priority.OPTIMAL
onCurrentIndexChanged: {
root.selectedPriority = currentIndex
if(gasPrioRepeater.count === 3) {
root.selectedGasFiatValue = gasPrioRepeater.itemAt(currentIndex).totalGasFiatValue
root.selectedGasEthValue = gasPrioRepeater.itemAt(currentIndex).totalGasEthValue
root.selectedTimeEstimate = gasPrioRepeater.itemAt(currentIndex).timeText
}
}
}
// Normal transaction
Repeater {
model: root.bestRoutes
@ -151,9 +47,7 @@ Item {
title: qsTr("%1 transaction fee").arg(modelData.fromNetwork.chainName)
subTitle: "%1 eth".arg(LocaleUtils.numberToLocaleString(parseFloat(totalGasAmount)))
property string totalGasAmount : {
let maxFees = (tabBar.currentIndex === GasSelector.Priority.SLOW) ? modelData.gasFees.maxFeePerGasL :
(tabBar.currentIndex === GasSelector.Priority.OPTIMAL) ?
modelData.gasFees.maxFeePerGasM : modelData.gasFees.maxFeePerGasH
let maxFees = modelData.gasFees.maxFeePerGasM
let gasPrice = modelData.gasFees.eip1559Enabled ? maxFees : modelData.gasFees.gasPrice
return root.getGasEthValue(gasPrice , modelData.gasAmount)
}
@ -184,7 +78,7 @@ Item {
title: qsTr("%1 -> %2 bridge").arg(modelData.fromNetwork.chainName).arg(modelData.toNetwork.chainName)
subTitle: "%1 %2".arg(LocaleUtils.numberToLocaleString(modelData.tokenFees)).arg(root.selectedTokenSymbol)
visible: modelData.bridgeName !== "Simple"
statusListItemSubTitle.width: 100//parent.width - Style.current.smallPadding
statusListItemSubTitle.width: 100
statusListItemSubTitle.elide: Text.ElideMiddle
components: [
StatusBaseText {

View File

@ -31,7 +31,6 @@ StatusDialog {
property alias modalHeader: modalHeader.text
property alias selectedPriority: fees.selectedPriority
property var store: TransactionStore{}
property var contactsStore: store.contactStore
property var selectedAccount: store.currentAccount
@ -63,7 +62,6 @@ StatusDialog {
assetSelector.selectedAsset.symbol,
amountToSendInput.text,
d.uuid,
fees.selectedPriority,
JSON.stringify(popup.bestRoutes)
)
}
@ -74,7 +72,7 @@ StatusDialog {
let amount = parseFloat(amountToSendInput.text) * Math.pow(10, assetSelector.selectedAsset.decimals)
popup.store.suggestedRoutes(popup.selectedAccount.address, amount.toString(16), assetSelector.selectedAsset.symbol,
store.disabledChainIdsFromList, store.disabledChainIdsToList,
store.preferredChainIds, fees.selectedPriority, popup.sendType)
store.preferredChainIds, popup.sendType)
}
})
@ -97,6 +95,9 @@ StatusDialog {
readonly property string uuid: Utils.uuid()
property bool isPendingTx: false
property var preferredChainIds: []
property string totalTimeEstimate
property string totalFeesInEth
property string totalFeesInFiat
property Timer waitTimer: Timer {
interval: 1000
@ -459,7 +460,7 @@ StatusDialog {
interactive: popup.interactive
selectedAccount: popup.selectedAccount
amountToSend: isNaN(parseFloat(amountToSendInput.text)) ? 0 : parseFloat(amountToSendInput.text)
requiredGasInEth: fees.selectedGasEthValue
requiredGasInEth:d.totalFeesInEth
selectedAsset: assetSelector.selectedAsset
onReCalculateSuggestedRoute: popup.recalculateRoutesAndFees()
visible: d.recipientReady && !!assetSelector.selectedAsset
@ -476,13 +477,12 @@ StatusDialog {
anchors.right: parent.right
anchors.leftMargin: Style.current.bigPadding
anchors.rightMargin: Style.current.bigPadding
visible: d.recipientReady && !!assetSelector.selectedAsset
visible: d.recipientReady && !!assetSelector.selectedAsset && networkSelector.advancedOrCustomMode
selectedTokenSymbol: assetSelector.selectedAsset ? assetSelector.selectedAsset.symbol: ""
advancedOrCustomMode: networkSelector.advancedOrCustomMode
isLoading: popup.isLoading
bestRoutes: popup.bestRoutes
store: popup.store
onPriorityChanged: popup.recalculateRoutesAndFees()
gasFiatAmount: d.totalFeesInFiat
}
}
}
@ -491,8 +491,8 @@ StatusDialog {
footer: SendModalFooter {
nextButtonText: popup.isBridgeTx ? qsTr("Bridge") : qsTr("Send")
maxFiatFees: popup.isLoading ? "..." : fees.selectedGasFiatValue
selectedTimeEstimate: popup.isLoading? "..." : fees.selectedTimeEstimate
maxFiatFees: popup.isLoading ? "..." : "%1 %2".arg(LocaleUtils.numberToLocaleString(d.totalFeesInFiat)).arg(popup.store.currentCurrency.toUpperCase())
totalTimeEstimate: popup.isLoading? "..." : d.totalTimeEstimate
pending: d.isPendingTx || popup.isLoading
visible: d.isReady && !isNaN(amountToSendInput.text) && fees.isValid && !d.errorMode
onNextButtonClicked: popup.sendTransaction()
@ -512,7 +512,11 @@ StatusDialog {
return
}
popup.bestRoutes = response.suggestedRoutes.best
fees.estimatedGasFeesTime = response.suggestedRoutes.gasTimeEstimates
let gasTimeEstimate = response.suggestedRoutes.gasTimeEstimate
d.totalTimeEstimate = popup.store.getLabelForEstimatedTxTime(gasTimeEstimate.totalTime)
d.totalFeesInEth = gasTimeEstimate.totalFeesInEth
d.totalFeesInFiat = parseFloat(popup.store.getFiatValue( gasTimeEstimate.totalFeesInEth, "ETH", popup.store.currentCurrency)) +
parseFloat(popup.store.getFiatValue(gasTimeEstimate.totalTokenFees, fees.selectedTokenSymbol, popup.store.currentCurrency))
popup.isLoading = false
}
}

View File

@ -175,9 +175,7 @@ Item {
if(bestRoutes.length === 1) {
let path = bestRoutes[0]
let eip1559Enabled = path.gasFees.eip1559Enabled
let maxFeePerGas = (selectedPriority === 0) ? path.gasFees.maxFeePerGasL:
(selectedPriority === 1) ? path.gasFees.maxFeePerGasM:
path.gasFees.maxFeePerGasH
let maxFeePerGas = path.gasFees.maxFeePerGasM
root.store.stickersStore.authenticateAndBuy(packId,
selectedAccount.address,
path.gasAmount,

View File

@ -88,9 +88,7 @@ ModalPopup {
if(bestRoutes.length === 1) {
let path = bestRoutes[0]
let eip1559Enabled = path.gasFees.eip1559Enabled
let maxFeePerGas = (selectedPriority === 0) ? path.gasFees.maxFeePerGasL:
(selectedPriority === 1) ? path.gasFees.maxFeePerGasM:
path.gasFees.maxFeePerGasH
let maxFeePerGas = path.gasFees.maxFeePerGasM
stickerPackDetailsPopup.store.stickersStore.authenticateAndBuy(packId,
selectedAccount.address,
path.gasAmount,

View File

@ -71,8 +71,8 @@ QtObject {
return profileSectionStore.ensUsernamesStore.getGasEthValue(gweiValue, gasLimit)
}
function authenticateAndTransfer(from, to, tokenSymbol, amount, uuid, priority, selectedRoutes) {
walletSectionTransactions.authenticateAndTransfer(from, to, tokenSymbol, amount, uuid, priority, selectedRoutes)
function authenticateAndTransfer(from, to, tokenSymbol, amount, uuid, selectedRoutes) {
walletSectionTransactions.authenticateAndTransfer(from, to, tokenSymbol, amount, uuid, selectedRoutes)
}
function suggestedFees(chainId) {
@ -91,8 +91,8 @@ QtObject {
return walletSectionTransactions.getChainIdForBrowser()
}
function suggestedRoutes(account, amount, token, disabledFromChainIDs, disabledToChainIDs, preferredChainIds, priority, sendType) {
walletSectionTransactions.suggestedRoutes(account, amount, token, disabledFromChainIDs, disabledToChainIDs, preferredChainIds, priority, sendType)
function suggestedRoutes(account, amount, token, disabledFromChainIDs, disabledToChainIDs, preferredChainIds, sendType) {
walletSectionTransactions.suggestedRoutes(account, amount, token, disabledFromChainIDs, disabledToChainIDs, preferredChainIds, sendType)
}
function hex2Eth(value) {
@ -147,4 +147,27 @@ QtObject {
}
}
}
enum EstimatedTime {
Unknown = 0,
LessThanOneMin,
LessThanThreeMins,
LessThanFiveMins,
MoreThanFiveMins
}
function getLabelForEstimatedTxTime(estimatedFlag) {
switch(estimatedFlag) {
case TransactionStore.EstimatedTime.Unknown:
return qsTr("~ Unknown")
case TransactionStore.EstimatedTime.LessThanOneMin :
return qsTr("< 1 minute")
case TransactionStore.EstimatedTime.LessThanThreeMins :
return qsTr("< 3 minutes")
case TransactionStore.EstimatedTime.LessThanFiveMins:
return qsTr("< 5 minutes")
default:
return qsTr("> 5 minutes")
}
}
}

View File

@ -12,19 +12,13 @@ import "../controls"
Rectangle {
id: root
property alias selectedPriority: gasSelector.selectedPriority
property alias selectedGasEthValue: gasSelector.selectedGasEthValue
property alias selectedGasFiatValue: gasSelector.selectedGasFiatValue
property alias selectedTimeEstimate: gasSelector.selectedTimeEstimate
property alias estimatedGasFeesTime: gasSelector.estimatedGasFeesTime
property alias isValid: gasValidator.isValid
property string gasFiatAmount
property bool isLoading: false
property var bestRoutes
property var store
property var selectedTokenSymbol
property bool advancedOrCustomMode
signal priorityChanged()
radius: 13
color: Theme.palette.indirectColor1
@ -62,10 +56,10 @@ Rectangle {
anchors.right: parent.right
anchors.rightMargin: Style.current.padding
id: totalFeesAdvanced
text: root.isLoading ? "..." : gasSelector.selectedGasFiatValue
text: root.isLoading ? "..." : root.gasFiatAmount
font.pixelSize: 15
color: Theme.palette.directColor1
visible: root.advancedOrCustomMode && root.bestRoutes.length > 0
visible: !!root.bestRoutes && root.bestRoutes !== undefined && root.bestRoutes.length > 0
}
}
GasSelector {
@ -76,10 +70,8 @@ Rectangle {
currentCurrency: root.store.currencyStore.currentCurrency
currentCurrencySymbol: root.store.currencyStore.currentCurrencySymbol
visible: gasValidator.isValid && !root.isLoading
advancedOrCustomMode: root.advancedOrCustomMode
bestRoutes: root.bestRoutes
selectedTokenSymbol: root.selectedTokenSymbol
onSelectedPriorityChanged: root.priorityChanged()
}
GasValidator {
id: gasValidator

View File

@ -14,7 +14,7 @@ Rectangle {
id: footer
property string maxFiatFees: "..."
property alias selectedTimeEstimate: estimatedTime.text
property alias totalTimeEstimate: estimatedTime.text
property bool pending: true
property alias nextButtonText: nextButton.text