feat: fees update integration after calculating the initial route

This commit is contained in:
Sale Djenic 2024-08-30 11:16:40 +02:00 committed by saledjenic
parent c515a963e3
commit c4363be418
10 changed files with 41 additions and 5 deletions

View File

@ -125,6 +125,9 @@ proc suggestedRoutes*(self: Controller,
self.transactionService.suggestedRoutes(uuid, sendType, accountFrom, accountTo, token, amountIn, toToken, amountOut, self.transactionService.suggestedRoutes(uuid, sendType, accountFrom, accountTo, token, amountIn, toToken, amountOut,
disabledFromChainIDs, disabledToChainIDs, lockedInAmounts, extraParamsTable) disabledFromChainIDs, disabledToChainIDs, lockedInAmounts, extraParamsTable)
proc stopSuggestedRoutesAsyncCalculation*(self: Controller) =
self.transactionService.stopSuggestedRoutesAsyncCalculation()
proc transfer*(self: Controller, from_addr: string, to_addr: string, assetKey: string, toAssetKey: string, proc transfer*(self: Controller, from_addr: string, to_addr: string, assetKey: string, toAssetKey: string,
uuid: string, selectedRoutes: seq[TransactionPathDto], password: string, sendType: SendType, uuid: string, selectedRoutes: seq[TransactionPathDto], password: string, sendType: SendType,
usePassword: bool, doHashing: bool, tokenName: string, isOwnerToken: bool, usePassword: bool, doHashing: bool, tokenName: string, isOwnerToken: bool,

View File

@ -37,6 +37,9 @@ method suggestedRoutes*(self: AccessInterface,
extraParamsTable: Table[string, string] = initTable[string, string]()) {.base.} = extraParamsTable: Table[string, string] = initTable[string, string]()) {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")
method stopUpdatesForSuggestedRoute*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method suggestedRoutesReady*(self: AccessInterface, uuid: string, suggestedRoutes: SuggestedRoutesDto, errCode: string, errDescription: string) {.base.} = method suggestedRoutesReady*(self: AccessInterface, uuid: string, suggestedRoutes: SuggestedRoutesDto, errCode: string, errDescription: string) {.base.} =
raise newException(ValueError, "No implementation available") raise newException(ValueError, "No implementation available")

View File

@ -109,7 +109,7 @@ proc convertSendToNetworkToNetworkItem(self: Module, network: SendToNetwork): Ne
proc convertNetworkDtoToNetworkRouteItem(self: Module, network: network_service_item.NetworkItem): NetworkRouteItem = proc convertNetworkDtoToNetworkRouteItem(self: Module, network: network_service_item.NetworkItem): NetworkRouteItem =
result = initNetworkRouteItem( result = initNetworkRouteItem(
network.chainId, network.chainId,
network.layer, network.layer,
true, true,
false, false,
@ -220,7 +220,7 @@ method authenticateAndTransferWithPaths*(self: Module, fromAddr: string, toAddr:
# Temporary until transaction service rework is completed # Temporary until transaction service rework is completed
let pathsV2 = rawPaths.toTransactionPathsDtoV2() let pathsV2 = rawPaths.toTransactionPathsDtoV2()
let pathsV1 = pathsV2.convertToOldRoute().addFirstSimpleBridgeTxFlag() let pathsV1 = pathsV2.convertToOldRoute().addFirstSimpleBridgeTxFlag()
self.tmpSendTransactionDetails.paths = pathsV1 self.tmpSendTransactionDetails.paths = pathsV1
self.tmpSendTransactionDetails.slippagePercentage = slippagePercentage self.tmpSendTransactionDetails.slippagePercentage = slippagePercentage
self.authenticateAndTransfer(fromAddr, toAddr, assetKey, toAssetKey, uuid, sendType, selectedTokenName, selectedTokenIsOwnerToken) self.authenticateAndTransfer(fromAddr, toAddr, assetKey, toAssetKey, uuid, sendType, selectedTokenName, selectedTokenIsOwnerToken)
@ -325,6 +325,9 @@ method suggestedRoutes*(self: Module,
extraParamsTable extraParamsTable
) )
method stopUpdatesForSuggestedRoute*(self: Module) =
self.controller.stopSuggestedRoutesAsyncCalculation()
method filterChanged*(self: Module, addresses: seq[string], chainIds: seq[int]) = method filterChanged*(self: Module, addresses: seq[string], chainIds: seq[int]) =
if addresses.len == 0: if addresses.len == 0:
return return

View File

@ -236,6 +236,9 @@ QtObject:
extraParamsTable extraParamsTable
) )
proc stopUpdatesForSuggestedRoute*(self: View) {.slot.} =
self.delegate.stopUpdatesForSuggestedRoute()
proc updateRoutePreferredChains*(self: View, chainIds: string) {.slot.} = proc updateRoutePreferredChains*(self: View, chainIds: string) {.slot.} =
self.toNetworksRouteModel.updateRoutePreferredChains(chainIds) self.toNetworksRouteModel.updateRoutePreferredChains(chainIds)
@ -325,7 +328,7 @@ QtObject:
proc transactionSendingComplete*(self: View, txHash: string, success: bool) {.signal.} proc transactionSendingComplete*(self: View, txHash: string, success: bool) {.signal.}
proc sendtransactionSendingCompleteSignal*(self: View, txHash: string, success: bool) = proc sendtransactionSendingCompleteSignal*(self: View, txHash: string, success: bool) =
self.transactionSendingComplete(txHash, success) self.transactionSendingComplete(txHash, success)
proc setSenderAccount*(self: View, address: string) {.slot.} = proc setSenderAccount*(self: View, address: string) {.slot.} =
self.setSelectedSenderAccountAddress(address) self.setSelectedSenderAccountAddress(address)
self.delegate.notifySelectedSenderAccountChanged() self.delegate.notifySelectedSenderAccountChanged()

View File

@ -702,6 +702,12 @@ QtObject:
except CatchableError as e: except CatchableError as e:
error "suggestedRoutes", exception=e.msg error "suggestedRoutes", exception=e.msg
proc stopSuggestedRoutesAsyncCalculation*(self: Service) =
try:
discard eth.stopSuggestedRoutesAsyncCalculation()
except CatchableError as e:
error "stopSuggestedRoutesAsyncCalculation", exception=e.msg
proc getEstimatedTime*(self: Service, chainId: int, maxFeePerGas: string): EstimatedTime = proc getEstimatedTime*(self: Service, chainId: int, maxFeePerGas: string): EstimatedTime =
try: try:
let response = backend.getTransactionEstimatedTime(chainId, maxFeePerGas).result.getInt let response = backend.getTransactionEstimatedTime(chainId, maxFeePerGas).result.getInt

View File

@ -112,7 +112,10 @@ StatusDialog {
} }
onOpened: payPanel.forceActiveFocus() onOpened: payPanel.forceActiveFocus()
onClosed: root.swapAdaptor.reset() onClosed: {
root.swapAdaptor.stopUpdatesForSuggestedRoute()
root.swapAdaptor.reset()
}
header: Item { header: Item {
implicitHeight: selector.implicitHeight implicitHeight: selector.implicitHeight

View File

@ -334,6 +334,10 @@ QObject {
} }
} }
function stopUpdatesForSuggestedRoute() {
root.swapStore.stopUpdatesForSuggestedRoute()
}
function sendApproveTx() { function sendApproveTx() {
root.approvalPending = true root.approvalPending = true
const accountAddress = root.swapFormData.selectedAccountAddress const accountAddress = root.swapFormData.selectedAccountAddress

View File

@ -41,6 +41,10 @@ QtObject {
tokenFrom, tokenTo, disabledFromChainIDs, disabledToChainIDs, sendType, lockedInAmounts) tokenFrom, tokenTo, disabledFromChainIDs, disabledToChainIDs, sendType, lockedInAmounts)
} }
function stopUpdatesForSuggestedRoute() {
root.walletSectionSendInst.stopUpdatesForSuggestedRoute()
}
function authenticateAndTransfer(uuid, accountFrom, accountTo, function authenticateAndTransfer(uuid, accountFrom, accountTo,
tokenFrom, tokenTo, sendType, tokenName, tokenIsOwnerToken, paths, slippagePercentage) { tokenFrom, tokenTo, sendType, tokenName, tokenIsOwnerToken, paths, slippagePercentage) {
root.walletSectionSendInst.authenticateAndTransferWithParameters(uuid, accountFrom, accountTo, root.walletSectionSendInst.authenticateAndTransferWithParameters(uuid, accountFrom, accountTo,

View File

@ -278,7 +278,10 @@ StatusDialog {
} }
} }
onClosed: popup.store.resetStoredProperties() onClosed: {
popup.store.stopUpdatesForSuggestedRoute()
popup.store.resetStoredProperties()
}
header: Item { header: Item {
implicitHeight: accountSelector.implicitHeight implicitHeight: accountSelector.implicitHeight

View File

@ -70,6 +70,10 @@ QtObject {
walletSectionSendInst.suggestedRoutes(valueIn.toFixed(), valueOut.toFixed(), extraParamsJson) walletSectionSendInst.suggestedRoutes(valueIn.toFixed(), valueOut.toFixed(), extraParamsJson)
} }
function stopUpdatesForSuggestedRoute() {
walletSectionSendInst.stopUpdatesForSuggestedRoute()
}
function resolveENS(value) { function resolveENS(value) {
mainModuleInst.resolveENS(value, "") mainModuleInst.resolveENS(value, "")
} }