Skip to content

Commit 7ea4979

Browse files
fix(@desktop/wallet): Fix for freeze in Approval stage in SwapModal
noticed only on linux fixes #18627
1 parent 565e140 commit 7ea4979

File tree

7 files changed

+31
-7
lines changed

7 files changed

+31
-7
lines changed

src/app/modules/main/wallet_section/send/io_interface.nim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,6 @@ method getNetworkChainId*(self: AccessInterface, shortName: string): int {.base.
8787

8888
method reevaluateSwap*(self: AccessInterface, uuid: string, chainId: int, isApprovalTx: bool) {.base.} =
8989
raise newException(ValueError, "No implementation available")
90+
91+
method stopSuggestedRoutesAsyncCalculation*(self: AccessInterface) {.base.} =
92+
raise newException(ValueError, "No implementation available")

src/app/modules/main/wallet_section/send/module.nim

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,9 @@ method resetData*(self: Module) =
362362
self.controller.stopSuggestedRoutesAsyncCalculation()
363363
self.clearTmpData(keepPinPass = self.tmpClearLocalDataLater)
364364

365+
method stopSuggestedRoutesAsyncCalculation*(self: Module) =
366+
self.controller.stopSuggestedRoutesAsyncCalculation()
367+
365368
method filterChanged*(self: Module, addresses: seq[string], chainIds: seq[int], isDirty: bool) =
366369
if not isDirty or addresses.len == 0:
367370
return
@@ -420,4 +423,4 @@ method reevaluateSwap*(self: Module, uuid: string, chainId: int, isApprovalTx: b
420423
const pathName = "Paraswap"
421424
let err = self.controller.reevaluateRouterPath(uuid, pathName, chainId, isApprovalTx)
422425
if err.len > 0:
423-
error "reevaluateRouterPath failed: ", err=err
426+
error "reevaluateRouterPath failed: ", err=err

src/app/modules/main/wallet_section/send/view.nim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,9 @@ QtObject:
238238
self.selectedAssetKey = ""
239239
self.showUnPreferredChains = false
240240

241+
proc stopSuggestedRoutesAsyncCalculation*(self: View) {.slot.} =
242+
self.delegate.stopSuggestedRoutesAsyncCalculation()
243+
241244
proc splitAndFormatAddressPrefix(self: View, text : string, updateInStore: bool): string {.slot.} =
242245
return self.delegate.splitAndFormatAddressPrefix(text, updateInStore)
243246

ui/app/AppLayouts/Wallet/panels/SwapInputPanel.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Control {
2929
// input API
3030
required property CurrenciesStore currencyStore
3131
required property var flatNetworksModel
32-
required property var processedAssetsModel
32+
property var processedAssetsModel
3333
property var plainTokensBySymbolModel
3434

3535
property int selectedNetworkChainId: -1

ui/app/AppLayouts/Wallet/popups/swap/SwapModal.qml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,11 @@ StatusDialog {
211211

212212
currencyStore: root.swapAdaptor.currencyStore
213213
flatNetworksModel: root.swapAdaptor.networksStore.activeNetworks
214-
processedAssetsModel: root.swapAdaptor.walletAssetsStore.groupedAccountAssetsModel
215-
plainTokensBySymbolModel: root.swapAdaptor.walletAssetsStore.walletTokensStore.plainTokensBySymbolModel
214+
215+
Component.onCompleted: {
216+
processedAssetsModel = root.swapAdaptor.walletAssetsStore.groupedAccountAssetsModel
217+
plainTokensBySymbolModel = root.swapAdaptor.walletAssetsStore.walletTokensStore.plainTokensBySymbolModel
218+
}
216219

217220
tokenKey: root.swapInputParamsForm.fromTokensKey
218221
defaultTokenKey: root.swapInputParamsForm.defaultFromTokenKey
@@ -257,8 +260,15 @@ StatusDialog {
257260

258261
currencyStore: root.swapAdaptor.currencyStore
259262
flatNetworksModel: root.swapAdaptor.networksStore.activeNetworks
260-
processedAssetsModel: root.swapAdaptor.walletAssetsStore.groupedAccountAssetsModel
261-
plainTokensBySymbolModel: root.swapAdaptor.walletAssetsStore.walletTokensStore.plainTokensBySymbolModel
263+
264+
265+
Component.onCompleted: {
266+
processedAssetsModel = root.swapAdaptor.walletAssetsStore.groupedAccountAssetsModel
267+
plainTokensBySymbolModel = root.swapAdaptor.walletAssetsStore.walletTokensStore.plainTokensBySymbolModel
268+
}
269+
270+
// processedAssetsModel: root.swapAdaptor.walletAssetsStore.groupedAccountAssetsModel
271+
// plainTokensBySymbolModel: root.swapAdaptor.walletAssetsStore.walletTokensStore.plainTokensBySymbolModel
262272

263273
tokenKey: root.swapInputParamsForm.toTokenKey
264274
defaultTokenKey: root.swapInputParamsForm.defaultToTokenKey

ui/app/AppLayouts/Wallet/popups/swap/SwapModalAdaptor.qml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,10 @@ QObject {
171171
if(root.swapOutputData.approvalNeeded && !root.approvalSuccessful) {
172172
if (uuid !== d.uuid || !!error) {
173173
root.approvalPending = false
174-
root.approvalSuccessful = false
174+
root.approvalSuccessful = false
175175
return
176176
}
177+
root.swapStore.stopSuggestedRoutesAsyncCalculation()
177178
root.approvalPending = true
178179
d.txHash = txHash
179180
}

ui/app/AppLayouts/Wallet/stores/SwapStore.qml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ QtObject {
4343
root.walletSectionSendInst.resetData()
4444
}
4545

46+
function stopSuggestedRoutesAsyncCalculation() {
47+
root.walletSectionSendInst.stopSuggestedRoutesAsyncCalculation()
48+
}
49+
4650
function authenticateAndTransfer(uuid) {
4751
root.walletSectionSendInst.authenticateAndTransfer(uuid)
4852
}

0 commit comments

Comments
 (0)