chore(wallet) move totalFees to details

Updates #11597
This commit is contained in:
Stefan 2023-08-29 18:27:04 +01:00 committed by Stefan Dunca
parent 600793e0de
commit 6b56bbe01f
4 changed files with 18 additions and 17 deletions

View File

@ -42,7 +42,6 @@ QtObject:
metadata: backend.ActivityEntry
extradata: ExtraData
totalFees: CurrencyAmount
amountCurrency: CurrencyAmount
noAmount: CurrencyAmount
@ -79,7 +78,6 @@ QtObject:
result.metadata = metadata
result.extradata = extradata
result.totalFees = valueConvertor(stint.fromHex(UInt256, tr.totalFees), "Gwei")
result.amountCurrency = valueConvertor(
if metadata.activityType == backend.ActivityType.Receive: metadata.amountIn else: metadata.amountOut,
tr.symbol
@ -229,16 +227,6 @@ QtObject:
write = setNftImageUrl
notify = nftImageUrlChanged
proc getTotalFees*(self: ActivityEntry): QVariant {.slot.} =
if self.transaction == nil:
error "getTotalFees: ActivityEntry is not an transaction entry"
return newQVariant(self.noAmount)
return newQVariant(self.totalFees)
# TODO: lazy load this in activity history service. See #11597
QtProperty[QVariant] totalFees:
read = getTotalFees
proc getTxType*(self: ActivityEntry): int {.slot.} =
return self.metadata.activityType.int

View File

@ -22,6 +22,7 @@ QtObject:
input*: string
contractAddress: Option[eth.Address]
maxTotalFees: CurrencyAmount
totalFees: CurrencyAmount
proc setup(self: ActivityDetails) =
self.QObject.setup
@ -39,6 +40,7 @@ QtObject:
else:
result.id = id
result.maxTotalFees = newCurrencyAmount()
result.totalFees = newCurrencyAmount()
result.setup()
proc newActivityDetails*(e: JsonNode, valueConvertor: AmountToCurrencyConvertor): ActivityDetails =
@ -47,6 +49,7 @@ QtObject:
const hashField = "hash"
const contractAddressField = "contractAddress"
const inputField = "input"
const totalFeesField = "totalFees"
result = ActivityDetails(
id: e["id"].getStr(),
@ -62,6 +65,10 @@ QtObject:
else:
result.maxTotalFees = newCurrencyAmount()
if e.hasKey(totalFeesField) and e[totalFeesField].kind != JNull:
let totalFees = e[totalFeesField].getStr()
result.totalFees = valueConvertor(stint.fromHex(UInt256, totalFees), "Gwei")
if e.hasKey(hashField) and e[hashField].kind != JNull:
result.txHash = e[hashField].getStr()
if e.hasKey(protocolTypeField) and e[protocolTypeField].kind != JNull:
@ -117,4 +124,10 @@ QtObject:
return newQVariant(self.maxTotalFees)
QtProperty[QVariant] maxTotalFees:
read = getMaxTotalFees
read = getMaxTotalFees
proc getTotalFees*(self: ActivityDetails): QVariant {.slot.} =
return newQVariant(self.totalFees)
QtProperty[QVariant] totalFees:
read = getTotalFees

View File

@ -83,7 +83,7 @@ Item {
const formatted = RootStore.formatCurrencyAmount(transaction.outAmount, transaction.outSymbol)
return outSymbol || !transaction.tokenOutAddress ? formatted : "%1 (%2)".arg(formatted).arg(Utils.compactAddress(transaction.tokenOutAddress, 4))
}
readonly property real feeEthValue: root.isTransactionValid ? RootStore.getFeeEthValue(transaction.totalFees) : 0
readonly property real feeEthValue: root.isTransactionValid ? RootStore.getFeeEthValue(d.details.totalFees) : 0
readonly property real feeFiatValue: root.isTransactionValid ? RootStore.getFiatValue(d.feeEthValue, Constants.ethToken, RootStore.currentCurrency) : 0 // TODO use directly?
readonly property int transactionType: root.isTransactionValid ? transaction.txType : Constants.TransactionType.Send
readonly property bool isBridge: d.transactionType === Constants.TransactionType.Bridge
@ -634,7 +634,7 @@ Item {
case Constants.TransactionType.Send:
case Constants.TransactionType.Swap:
case Constants.TransactionType.Bridge:
return LocaleUtils.currencyAmountToLocaleString(root.transaction.totalFees)
return LocaleUtils.currencyAmountToLocaleString(d.details.totalFees)
default:
return ""
}

View File

@ -178,7 +178,7 @@ StatusListItem {
const endl = "\n"
const endl2 = endl + endl
const type = modelData.txType
const feeEthValue = rootStore.getGasEthValue(modelData.totalFees.amount, 1)
const feeEthValue = rootStore.getGasEthValue(detailsObj.totalFees.amount, 1)
// TITLE
switch (type) {
@ -401,7 +401,7 @@ StatusListItem {
case Constants.TransactionType.Send:
case Constants.TransactionType.Swap:
case Constants.TransactionType.Bridge:
const feeValue = LocaleUtils.currencyAmountToLocaleString(modelData.totalFees)
const feeValue = LocaleUtils.currencyAmountToLocaleString(detailsObj.totalFees)
const feeFiat = rootStore.formatCurrencyAmount(feeFiatValue, root.currentCurrency)
valuesString += qsTr("Fees %1 (%2)").arg(feeValue).arg(feeFiat) + endl2
break