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 Khushboo-dev-cpp
parent 1a3b75fc9d
commit 8dc067e0c4
6 changed files with 20 additions and 3 deletions

View File

@ -1,4 +1,4 @@
import json, options, chronicles
import json, options, chronicles, Tables
import base
import signal_type
@ -24,6 +24,7 @@ type WalletSignal* = ref object of Signal
bestRoute*: seq[TransactionPathDtoV2]
error*: string
errorCode*: string
updatedPrices*: Table[string, float64]
proc fromEvent*(T: type WalletSignal, signalType: SignalType, jsonSignal: JsonNode): WalletSignal =
result = WalletSignal()
@ -67,6 +68,10 @@ proc fromEvent*(T: type WalletSignal, signalType: SignalType, jsonSignal: JsonNo
result.error = errorResponseJsonNode["details"].getStr
if errorResponseJsonNode.contains("code"):
result.errorCode = errorResponseJsonNode["code"].getStr
result.updatedPrices = initTable[string, float64]()
if event.contains("UpdatedPrices"):
for tokenSymbol, price in event["UpdatedPrices"].pairs():
result.updatedPrices[tokenSymbol] = price.getFloat
except:
error "Error parsing best route"
return

View File

@ -565,3 +565,8 @@ QtObject:
self.fetchTokenPreferences()
except Exception as e:
error "error: ", procName="updateTokenPreferences", errName=e.name, errDesription=e.msg
proc updateTokenPrices*(self: Service, updatedPrices: Table[string, float64]) =
for tokenSymbol, price in updatedPrices:
self.tokenPriceTable[tokenSymbol] = price
self.events.emit(SIGNAL_TOKENS_PRICES_UPDATED, Args())

View File

@ -181,6 +181,7 @@ QtObject:
self.events.on(SignalType.WalletSuggestedRoutes.event) do(e:Args):
var data = WalletSignal(e)
self.tokenService.updateTokenPrices(data.updatedPrices)
self.suggestedRoutesReady(data.uuid, data.bestRoute, data.bestRouteRaw, data.errorCode, data.error)
self.events.on(PendingTransactionTypeDto.WalletTransfer.event) do(e: Args):

View File

@ -156,7 +156,7 @@ Item {
// verfy input and output panels
verify(!payPanel.mainInputLoading)
verify(!payPanel.bottomTextLoading)
verify(payPanel.bottomTextLoading)
compare(payPanel.selectedHoldingId, root.swapFormData.fromTokensKey)
compare(payPanel.value, Number(root.swapFormData.fromTokenAmount))
compare(payPanel.rawValue, SQUtils.AmountsArithmetic.fromNumber(root.swapFormData.fromTokenAmount, root.swapAdaptor.fromToken.decimals).toString())
@ -808,6 +808,8 @@ Item {
// verfy input and output panels
waitForRendering(receivePanel)
verify(payPanel.valueValid)
verify(!payPanel.mainInputLoading)
verify(!payPanel.bottomTextLoading)
verify(!receivePanel.mainInputLoading)
verify(!receivePanel.bottomTextLoading)
verify(!receivePanel.interactive)
@ -858,6 +860,8 @@ Item {
// verfy input and output panels
waitForRendering(receivePanel)
verify(payPanel.valueValid)
verify(!payPanel.mainInputLoading)
verify(!payPanel.bottomTextLoading)
verify(!receivePanel.mainInputLoading)
verify(!receivePanel.bottomTextLoading)
verify(!receivePanel.interactive)

View File

@ -238,6 +238,8 @@ StatusDialog {
swapSide: SwapInputPanel.SwapSide.Pay
swapExchangeButtonWidth: swapExchangeButton.width
bottomTextLoading: root.swapAdaptor.swapProposalLoading
onSelectedHoldingIdChanged: root.swapInputParamsForm.fromTokensKey = selectedHoldingId
onRawValueChanged: {

2
vendor/status-go vendored

@ -1 +1 @@
Subproject commit 0235889e12bcd13e8e25fe1ee9a6d497ece57d01
Subproject commit 4816769506879b9877359bddb86d038c9501e865