TransactionDetailView: RootStore and CurrenciesStore decoupled

This commit is contained in:
Michał Cieślak 2024-09-24 13:51:22 +02:00 committed by Michał
parent afe1cd59c0
commit 47f75c1ae2
8 changed files with 82 additions and 73 deletions

View File

@ -76,7 +76,7 @@ SplitView {
id: delegate id: delegate
Layout.fillWidth: true Layout.fillWidth: true
modelData: root.mockupModelData modelData: root.mockupModelData
rootStore: SharedStores.RootStore { currenciesStore: SharedStores.CurrenciesStore {
readonly property string currentCurrency: "EUR" readonly property string currentCurrency: "EUR"
function getFiatValue(cryptoValue, symbol) { function getFiatValue(cryptoValue, symbol) {
@ -86,9 +86,8 @@ SplitView {
function formatCurrencyAmount(cryptoValue, symbol) { function formatCurrencyAmount(cryptoValue, symbol) {
return "%L1 %2".arg(cryptoValue).arg(symbol) return "%L1 %2".arg(cryptoValue).arg(symbol)
} }
property var flatNetworks: NetworksModel.flatNetworks
} }
flatNetworks: NetworksModel.flatNetworks
walletRootStore: WalletStores.RootStore walletRootStore: WalletStores.RootStore
} }
} }

View File

@ -228,6 +228,7 @@ SplitView {
active: root.globalUtilsReady && root.mainModuleReady active: root.globalUtilsReady && root.mainModuleReady
sourceComponent: TransactionDetailView { sourceComponent: TransactionDetailView {
rootStore: rootStoreMock rootStore: rootStoreMock
currenciesStore: CurrenciesStore {}
contactsStore: contactsStoreMockup contactsStore: contactsStoreMockup
controller: controllerMockup controller: controllerMockup
overview: overviewMockup overview: overviewMockup

View File

@ -502,6 +502,7 @@ RightTabBaseView {
communitiesStore: root.communitiesStore communitiesStore: root.communitiesStore
sendModal: root.sendModal sendModal: root.sendModal
rootStore: SharedStores.RootStore rootStore: SharedStores.RootStore
currenciesStore: SharedStores.RootStore.currencyStore
contactsStore: root.contactsStore contactsStore: root.contactsStore
networkConnectionStore: root.networkConnectionStore networkConnectionStore: root.networkConnectionStore
visible: (stack.currentIndex === 3) visible: (stack.currentIndex === 3)

View File

@ -32,6 +32,7 @@ Item {
property var overview: WalletStores.RootStore.overview property var overview: WalletStores.RootStore.overview
property RootStore rootStore property RootStore rootStore
property CurrenciesStore currenciesStore
property ProfileStores.ContactsStore contactsStore property ProfileStores.ContactsStore contactsStore
property CommunitiesStore communitiesStore property CommunitiesStore communitiesStore
property NetworkConnectionStore networkConnectionStore property NetworkConnectionStore networkConnectionStore
@ -86,27 +87,27 @@ Item {
readonly property string fiatValueFormatted: { readonly property string fiatValueFormatted: {
if (!d.isTransactionValid || transactionHeader.isMultiTransaction || !symbol) if (!d.isTransactionValid || transactionHeader.isMultiTransaction || !symbol)
return "" return ""
return root.rootStore.currencyStore.formatCurrencyAmount(transactionHeader.fiatValue, root.rootStore.currentCurrency) return root.currenciesStore.formatCurrencyAmount(transactionHeader.fiatValue, root.currenciesStore.currentCurrency)
} }
readonly property string cryptoValueFormatted: { readonly property string cryptoValueFormatted: {
if (!d.isTransactionValid || transactionHeader.isMultiTransaction) if (!d.isTransactionValid || transactionHeader.isMultiTransaction)
return "" return ""
const formatted = root.rootStore.currencyStore.formatCurrencyAmount(transaction.amount, transaction.symbol) const formatted = root.currenciesStore.formatCurrencyAmount(transaction.amount, transaction.symbol)
return symbol || (!d.isDetailsValid || !d.details.contract) ? formatted : "%1 (%2)".arg(formatted).arg(Utils.compactAddress(transaction.tokenAddress, 4)) return symbol || (!d.isDetailsValid || !d.details.contract) ? formatted : "%1 (%2)".arg(formatted).arg(Utils.compactAddress(transaction.tokenAddress, 4))
} }
readonly property string outFiatValueFormatted: { readonly property string outFiatValueFormatted: {
if (!d.isTransactionValid || !transactionHeader.isMultiTransaction || !outSymbol) if (!d.isTransactionValid || !transactionHeader.isMultiTransaction || !outSymbol)
return "" return ""
return root.rootStore.currencyStore.formatCurrencyAmount(transactionHeader.outFiatValue, root.rootStore.currentCurrency) return root.currenciesStore.formatCurrencyAmount(transactionHeader.outFiatValue, root.currenciesStore.currentCurrency)
} }
readonly property string outCryptoValueFormatted: { readonly property string outCryptoValueFormatted: {
if (!d.isTransactionValid || !transactionHeader.isMultiTransaction) if (!d.isTransactionValid || !transactionHeader.isMultiTransaction)
return "" return ""
const formatted = root.rootStore.currencyStore.formatCurrencyAmount(transaction.outAmount, transaction.outSymbol) const formatted = root.currenciesStore.formatCurrencyAmount(transaction.outAmount, transaction.outSymbol)
return outSymbol || !transaction.tokenOutAddress ? formatted : "%1 (%2)".arg(formatted).arg(Utils.compactAddress(transaction.tokenOutAddress, 4)) return outSymbol || !transaction.tokenOutAddress ? formatted : "%1 (%2)".arg(formatted).arg(Utils.compactAddress(transaction.tokenOutAddress, 4))
} }
readonly property real feeEthValue: d.details ? root.rootStore.currencyStore.getFeeEthValue(d.details.totalFees) : 0 readonly property real feeEthValue: d.details ? root.currenciesStore.getFeeEthValue(d.details.totalFees) : 0
readonly property real feeFiatValue: root.rootStore.currencyStore.getFiatValue(d.feeEthValue, Constants.ethToken) readonly property real feeFiatValue: root.currenciesStore.getFiatValue(d.feeEthValue, Constants.ethToken)
readonly property int transactionType: d.isTransactionValid ? WalletStores.RootStore.transactionType(transaction) : Constants.TransactionType.Send readonly property int transactionType: d.isTransactionValid ? WalletStores.RootStore.transactionType(transaction) : Constants.TransactionType.Send
readonly property bool isBridge: d.transactionType === Constants.TransactionType.Bridge readonly property bool isBridge: d.transactionType === Constants.TransactionType.Bridge
@ -177,7 +178,8 @@ Item {
showAllAccounts: root.showAllAccounts showAllAccounts: root.showAllAccounts
modelData: transaction modelData: transaction
timeStampText: d.isTransactionValid ? qsTr("Signed at %1").arg(LocaleUtils.formatDateTime(transaction.timestamp * 1000, Locale.LongFormat)): "" timeStampText: d.isTransactionValid ? qsTr("Signed at %1").arg(LocaleUtils.formatDateTime(transaction.timestamp * 1000, Locale.LongFormat)): ""
rootStore: root.rootStore flatNetworks: root.rootStore.flatNetworks
currenciesStore: root.currenciesStore
walletRootStore: WalletStores.RootStore walletRootStore: WalletStores.RootStore
community: isModelDataValid && communityId && communitiesStore ? communitiesStore.getCommunityDetailsAsJson(communityId) : null community: isModelDataValid && communityId && communitiesStore ? communitiesStore.getCommunityDetailsAsJson(communityId) : null
@ -649,20 +651,20 @@ Item {
return "" return ""
const type = d.transactionType const type = d.transactionType
if (type === Constants.TransactionType.Swap) { if (type === Constants.TransactionType.Swap) {
return root.rootStore.currencyStore.formatCurrencyAmount(transactionHeader.inCryptoValue, d.inSymbol) return root.currenciesStore.formatCurrencyAmount(transactionHeader.inCryptoValue, d.inSymbol)
} else if (type === Constants.TransactionType.Bridge) { } else if (type === Constants.TransactionType.Bridge) {
// Reduce crypto value by fee value // Reduce crypto value by fee value
const valueInCrypto = root.rootStore.currencyStore.getCryptoValue(transactionHeader.outFiatValue - d.feeFiatValue, d.inSymbol) const valueInCrypto = root.currenciesStore.getCryptoValue(transactionHeader.outFiatValue - d.feeFiatValue, d.inSymbol)
return root.rootStore.currencyStore.formatCurrencyAmount(valueInCrypto, d.inSymbol) return root.currenciesStore.formatCurrencyAmount(valueInCrypto, d.inSymbol)
} }
return "" return ""
} }
tertiaryTitle: { tertiaryTitle: {
const type = d.transactionType const type = d.transactionType
if (type === Constants.TransactionType.Swap) { if (type === Constants.TransactionType.Swap) {
return root.rootStore.currencyStore.formatCurrencyAmount(transactionHeader.inFiatValue, root.rootStore.currentCurrency) return root.currenciesStore.formatCurrencyAmount(transactionHeader.inFiatValue, root.currenciesStore.currentCurrency)
} else if (type === Constants.TransactionType.Bridge) { } else if (type === Constants.TransactionType.Bridge) {
return root.rootStore.currencyStore.formatCurrencyAmount(transactionHeader.outFiatValue - d.feeFiatValue, root.rootStore.currentCurrency) return root.currenciesStore.formatCurrencyAmount(transactionHeader.outFiatValue - d.feeFiatValue, root.currenciesStore.currentCurrency)
} }
return "" return ""
} }
@ -676,8 +678,8 @@ Item {
if (!d.isTransactionValid || transactionHeader.isNFT || !d.isDetailsValid) if (!d.isTransactionValid || transactionHeader.isNFT || !d.isDetailsValid)
return "" return ""
if (!d.symbol) { if (!d.symbol) {
const maxFeeEth = root.rootStore.currencyStore.getFeeEthValue(d.details.maxTotalFees) const maxFeeEth = root.currenciesStore.getFeeEthValue(d.details.maxTotalFees)
return root.rootStore.currencyStore.formatCurrencyAmount(maxFeeEth, Constants.ethToken) return root.currenciesStore.formatCurrencyAmount(maxFeeEth, Constants.ethToken)
} }
switch(d.transactionType) { switch(d.transactionType) {
@ -694,12 +696,12 @@ Item {
return "" return ""
let fiatValue let fiatValue
if (!d.symbol) { if (!d.symbol) {
const maxFeeEth = root.rootStore.currencyStore.getFeeEthValue(d.details.maxTotalFees) const maxFeeEth = root.currenciesStore.getFeeEthValue(d.details.maxTotalFees)
fiatValue = root.rootStore.currencyStore.getFiatValue(maxFeeEth, Constants.ethToken) fiatValue = root.currenciesStore.getFiatValue(maxFeeEth, Constants.ethToken)
} else { } else {
fiatValue = d.feeFiatValue fiatValue = d.feeFiatValue
} }
return root.rootStore.currencyStore.formatCurrencyAmount(fiatValue, root.rootStore.currentCurrency) return root.currenciesStore.formatCurrencyAmount(fiatValue, root.currenciesStore.currentCurrency)
} }
visible: !!subTitle visible: !!subTitle
} }
@ -723,30 +725,30 @@ Item {
if (fieldIsHidden) if (fieldIsHidden)
return "" return ""
if (showMaxFee) { if (showMaxFee) {
const maxFeeEth = root.rootStore.currencyStore.getFeeEthValue(d.details.maxTotalFees) const maxFeeEth = root.currenciesStore.getFeeEthValue(d.details.maxTotalFees)
return root.rootStore.currencyStore.formatCurrencyAmount(maxFeeEth, Constants.ethToken) return root.currenciesStore.formatCurrencyAmount(maxFeeEth, Constants.ethToken)
} else if (showFee) { } else if (showFee) {
return root.rootStore.currencyStore.formatCurrencyAmount(d.feeEthValue, Constants.ethToken) return root.currenciesStore.formatCurrencyAmount(d.feeEthValue, Constants.ethToken)
} else if (showValue) { } else if (showValue) {
return d.cryptoValueFormatted return d.cryptoValueFormatted
} }
const cryptoValue = transactionHeader.isMultiTransaction ? d.outCryptoValueFormatted : d.cryptoValueFormatted const cryptoValue = transactionHeader.isMultiTransaction ? d.outCryptoValueFormatted : d.cryptoValueFormatted
return "%1 + %2".arg(cryptoValue).arg(root.rootStore.currencyStore.formatCurrencyAmount(d.feeEthValue, Constants.ethToken)) return "%1 + %2".arg(cryptoValue).arg(root.currenciesStore.formatCurrencyAmount(d.feeEthValue, Constants.ethToken))
} }
tertiaryTitle: { tertiaryTitle: {
if (fieldIsHidden) if (fieldIsHidden)
return "" return ""
if (showMaxFee) { if (showMaxFee) {
const maxFeeEth = root.rootStore.currencyStore.getFeeEthValue(d.details.maxTotalFees) const maxFeeEth = root.currenciesStore.getFeeEthValue(d.details.maxTotalFees)
const maxFeeFiat = root.rootStore.currencyStore.getFiatValue(d.feeEthValue, Constants.ethToken) const maxFeeFiat = root.currenciesStore.getFiatValue(d.feeEthValue, Constants.ethToken)
return root.rootStore.currencyStore.formatCurrencyAmount(maxFeeFiat, root.rootStore.currentCurrency) return root.currenciesStore.formatCurrencyAmount(maxFeeFiat, root.currenciesStore.currentCurrency)
} else if (showFee) { } else if (showFee) {
return root.rootStore.currencyStore.formatCurrencyAmount(d.feeFiatValue, root.rootStore.currentCurrency) return root.currenciesStore.formatCurrencyAmount(d.feeFiatValue, root.currenciesStore.currentCurrency)
} else if (showValue) { } else if (showValue) {
return d.fiatValueFormatted return d.fiatValueFormatted
} }
const fiatValue = transactionHeader.isMultiTransaction ? transactionHeader.outFiatValue : transactionHeader.fiatValue const fiatValue = transactionHeader.isMultiTransaction ? transactionHeader.outFiatValue : transactionHeader.fiatValue
return root.rootStore.currencyStore.formatCurrencyAmount(fiatValue + d.feeFiatValue, root.rootStore.currentCurrency) return root.currenciesStore.formatCurrencyAmount(fiatValue + d.feeFiatValue, root.currenciesStore.currentCurrency)
} }
visible: !!subTitle visible: !!subTitle
highlighted: true highlighted: true

View File

@ -299,7 +299,8 @@ Item {
width: parent.width width: parent.width
modelData: model.activityEntry modelData: model.activityEntry
timeStampText: isModelDataValid ? LocaleUtils.formatRelativeTimestamp(modelData.timestamp * 1000, true) : "" timeStampText: isModelDataValid ? LocaleUtils.formatRelativeTimestamp(modelData.timestamp * 1000, true) : ""
rootStore: root.rootStore flatNetworks: root.rootStore.flatNetworks
currenciesStore: root.rootStore.currencyStore
walletRootStore: root.walletRootStore walletRootStore: root.walletRootStore
showAllAccounts: root.walletRootStore.showAllAccounts showAllAccounts: root.walletRootStore.showAllAccounts
displayValues: true displayValues: true

View File

@ -29,7 +29,8 @@ import shared.stores 1.0 as SharedStores
id: delegate id: delegate
width: ListView.view.width width: ListView.view.width
modelData: model.activityEntry modelData: model.activityEntry
rootStore: RootStore flatNetworks: root.flatNetworks
currenciesStore: root.currencyStore
walletRootStore: WalletStores.RootStore walletRootStore: WalletStores.RootStore
loading: isModelDataValid loading: isModelDataValid
} }
@ -48,7 +49,9 @@ StatusListItem {
property bool showAllAccounts: false property bool showAllAccounts: false
property bool displayValues: true property bool displayValues: true
required property SharedStores.RootStore rootStore required property var flatNetworks
required property SharedStores.CurrenciesStore currenciesStore
required property WalletStores.RootStore walletRootStore required property WalletStores.RootStore walletRootStore
readonly property bool isModelDataValid: modelData !== undefined && !!modelData readonly property bool isModelDataValid: modelData !== undefined && !!modelData
@ -56,17 +59,17 @@ StatusListItem {
readonly property string txID: isModelDataValid ? modelData.id : "INVALID" readonly property string txID: isModelDataValid ? modelData.id : "INVALID"
readonly property int transactionStatus: isModelDataValid ? modelData.status : Constants.TransactionStatus.Pending readonly property int transactionStatus: isModelDataValid ? modelData.status : Constants.TransactionStatus.Pending
readonly property bool isMultiTransaction: isModelDataValid && modelData.isMultiTransaction readonly property bool isMultiTransaction: isModelDataValid && modelData.isMultiTransaction
readonly property string currentCurrency: rootStore.currentCurrency readonly property string currentCurrency: currenciesStore.currentCurrency
readonly property double cryptoValue: isModelDataValid ? modelData.amount : 0.0 readonly property double cryptoValue: isModelDataValid ? modelData.amount : 0.0
readonly property double fiatValue: isModelDataValid && !isMultiTransaction ? rootStore.currencyStore.getFiatValue(cryptoValue, modelData.symbol) : 0.0 readonly property double fiatValue: isModelDataValid && !isMultiTransaction ? currenciesStore.getFiatValue(cryptoValue, modelData.symbol) : 0.0
readonly property double inCryptoValue: isModelDataValid ? modelData.inAmount : 0.0 readonly property double inCryptoValue: isModelDataValid ? modelData.inAmount : 0.0
readonly property double inFiatValue: isModelDataValid && isMultiTransaction ? rootStore.currencyStore.getFiatValue(inCryptoValue, modelData.inSymbol): 0.0 readonly property double inFiatValue: isModelDataValid && isMultiTransaction ? currenciesStore.getFiatValue(inCryptoValue, modelData.inSymbol): 0.0
readonly property double outCryptoValue: isModelDataValid ? modelData.outAmount : 0.0 readonly property double outCryptoValue: isModelDataValid ? modelData.outAmount : 0.0
readonly property double outFiatValue: isModelDataValid && isMultiTransaction ? rootStore.currencyStore.getFiatValue(outCryptoValue, modelData.outSymbol): 0.0 readonly property double outFiatValue: isModelDataValid && isMultiTransaction ? currenciesStore.getFiatValue(outCryptoValue, modelData.outSymbol): 0.0
readonly property string networkColor: isModelDataValid ? SQUtils.ModelUtils.getByKey(rootStore.flatNetworks, "chainId", modelData.chainId, "chainColor") : "" readonly property string networkColor: isModelDataValid ? SQUtils.ModelUtils.getByKey(flatNetworks, "chainId", modelData.chainId, "chainColor") : ""
readonly property string networkName: isModelDataValid ? SQUtils.ModelUtils.getByKey(rootStore.flatNetworks, "chainId", modelData.chainId, "chainName") : "" readonly property string networkName: isModelDataValid ? SQUtils.ModelUtils.getByKey(flatNetworks, "chainId", modelData.chainId, "chainName") : ""
readonly property string networkNameIn: isMultiTransaction ? SQUtils.ModelUtils.getByKey(rootStore.flatNetworks, "chainId", modelData.chainIdIn, "chainName") : "" readonly property string networkNameIn: isMultiTransaction ? SQUtils.ModelUtils.getByKey(flatNetworks, "chainId", modelData.chainIdIn, "chainName") : ""
readonly property string networkNameOut: isMultiTransaction ? SQUtils.ModelUtils.getByKey(rootStore.flatNetworks, "chainId", modelData.chainIdOut, "chainName") : "" readonly property string networkNameOut: isMultiTransaction ? SQUtils.ModelUtils.getByKey(flatNetworks, "chainId", modelData.chainIdOut, "chainName") : ""
readonly property string addressNameTo: isModelDataValid ? walletRootStore.getNameForAddress(modelData.recipient) : "" readonly property string addressNameTo: isModelDataValid ? walletRootStore.getNameForAddress(modelData.recipient) : ""
readonly property string addressNameFrom: isModelDataValid ? walletRootStore.getNameForAddress(modelData.sender) : "" readonly property string addressNameFrom: isModelDataValid ? walletRootStore.getNameForAddress(modelData.sender) : ""
readonly property bool isNFT: isModelDataValid && modelData.isNFT readonly property bool isNFT: isModelDataValid && modelData.isNFT
@ -105,26 +108,26 @@ StatusListItem {
value += (modelData.nftName ? modelData.nftName : "#" + modelData.tokenID) value += (modelData.nftName ? modelData.nftName : "#" + modelData.tokenID)
return value return value
} else if (!modelData.symbol && !!modelData.tokenAddress) { } else if (!modelData.symbol && !!modelData.tokenAddress) {
return "%1 (%2)".arg(root.rootStore.currencyStore.formatCurrencyAmount(cryptoValue, "")).arg(Utils.compactAddress(modelData.tokenAddress, 4)) return "%1 (%2)".arg(root.currenciesStore.formatCurrencyAmount(cryptoValue, "")).arg(Utils.compactAddress(modelData.tokenAddress, 4))
} }
return root.rootStore.currencyStore.formatCurrencyAmount(cryptoValue, modelData.symbol) return root.currenciesStore.formatCurrencyAmount(cryptoValue, modelData.symbol)
} }
readonly property string inTransactionValue: { readonly property string inTransactionValue: {
if (!isModelDataValid || !isMultiTransaction) { if (!isModelDataValid || !isMultiTransaction) {
return qsTr("N/A") return qsTr("N/A")
} else if (!modelData.inSymbol && !!modelData.tokenInAddress) { } else if (!modelData.inSymbol && !!modelData.tokenInAddress) {
return "%1 (%2)".arg(root.rootStore.currencyStore.formatCurrencyAmount(inCryptoValue, "")).arg(Utils.compactAddress(modelData.tokenInAddress, 4)) return "%1 (%2)".arg(root.currenciesStore.formatCurrencyAmount(inCryptoValue, "")).arg(Utils.compactAddress(modelData.tokenInAddress, 4))
} }
return rootStore.currencyStore.formatCurrencyAmount(inCryptoValue, modelData.inSymbol) return currenciesStore.formatCurrencyAmount(inCryptoValue, modelData.inSymbol)
} }
readonly property string outTransactionValue: { readonly property string outTransactionValue: {
if (!isModelDataValid || !isMultiTransaction) { if (!isModelDataValid || !isMultiTransaction) {
return qsTr("N/A") return qsTr("N/A")
} else if (!modelData.outSymbol && !!modelData.tokenOutAddress) { } else if (!modelData.outSymbol && !!modelData.tokenOutAddress) {
return "%1 (%2)".arg(root.rootStore.currencyStore.formatCurrencyAmount(outCryptoValue, "")).arg(Utils.compactAddress(modelData.tokenOutAddress, 4)) return "%1 (%2)".arg(root.currenciesStore.formatCurrencyAmount(outCryptoValue, "")).arg(Utils.compactAddress(modelData.tokenOutAddress, 4))
} }
return rootStore.currencyStore.formatCurrencyAmount(outCryptoValue, modelData.outSymbol) return currenciesStore.formatCurrencyAmount(outCryptoValue, modelData.outSymbol)
} }
readonly property string tokenImage: { readonly property string tokenImage: {
@ -235,7 +238,7 @@ StatusListItem {
const endl = "\n" const endl = "\n"
const endl2 = endl + endl const endl2 = endl + endl
const type = d.txType const type = d.txType
const feeEthValue = rootStore.currencyStore.getGasEthValue(detailsObj.totalFees.amount, 1) const feeEthValue = currenciesStore.getGasEthValue(detailsObj.totalFees.amount, 1)
// TITLE // TITLE
switch (type) { switch (type) {
@ -305,7 +308,7 @@ StatusListItem {
} }
// PROGRESS // PROGRESS
const networkLayer = SQUtils.ModelUtils.getByKey(rootStore.flatNetworks, "chainId", modelData.chainId, "layer") const networkLayer = SQUtils.ModelUtils.getByKey(flatNetworks, "chainId", modelData.chainId, "layer")
const isBridge = type === Constants.TransactionType.Bridge const isBridge = type === Constants.TransactionType.Bridge
switch(transactionStatus) { switch(transactionStatus) {
@ -331,7 +334,7 @@ StatusListItem {
details += qsTr("Confirmed on %1").arg(root.networkName) + endl details += qsTr("Confirmed on %1").arg(root.networkName) + endl
details += LocaleUtils.formatDateTime(confirmationTimeStamp * 1000, Locale.LongFormat) + endl2 details += LocaleUtils.formatDateTime(confirmationTimeStamp * 1000, Locale.LongFormat) + endl2
if (isBridge) { if (isBridge) {
const networkInLayer = SQUtils.ModelUtils.getByKey(rootStore.flatNetworks, "chainId", modelData.chainIdIn, "layer") const networkInLayer = SQUtils.ModelUtils.getByKey(flatNetworks, "chainId", modelData.chainIdIn, "layer")
const confirmationTimeStampIn = WalletUtils.calculateConfirmationTimestamp(networkInLayer, modelData.timestamp) const confirmationTimeStampIn = WalletUtils.calculateConfirmationTimestamp(networkInLayer, modelData.timestamp)
details += qsTr("Signed on %1").arg(root.networkNameIn) + endl + timestampString + endl2 details += qsTr("Signed on %1").arg(root.networkNameIn) + endl + timestampString + endl2
details += qsTr("Confirmed on %1").arg(root.networkNameIn) + endl details += qsTr("Confirmed on %1").arg(root.networkNameIn) + endl
@ -352,7 +355,7 @@ StatusListItem {
details += qsTr("Finalised on %1").arg(root.networkName) + endl details += qsTr("Finalised on %1").arg(root.networkName) + endl
details += LocaleUtils.formatDateTime(finalisationTimeStamp * 1000, Locale.LongFormat) + endl2 details += LocaleUtils.formatDateTime(finalisationTimeStamp * 1000, Locale.LongFormat) + endl2
if (isBridge) { if (isBridge) {
const networkInLayer = SQUtils.ModelUtils.getByKey(rootStore.flatNetworks, "chainId", modelData.chainIdIn, "layer") const networkInLayer = SQUtils.ModelUtils.getByKey(flatNetworks, "chainId", modelData.chainIdIn, "layer")
const confirmationTimeStampIn = WalletUtils.calculateConfirmationTimestamp(networkInLayer, modelData.timestamp) const confirmationTimeStampIn = WalletUtils.calculateConfirmationTimestamp(networkInLayer, modelData.timestamp)
const finalisationTimeStampIn = WalletUtils.calculateFinalisationTimestamp(networkInLayer, modelData.timestamp) const finalisationTimeStampIn = WalletUtils.calculateFinalisationTimestamp(networkInLayer, modelData.timestamp)
const epochIn = Math.abs(walletRootStore.getEstimatedLatestBlockNumber(modelData.chainIdIn) - detailsObj.blockNumberIn) const epochIn = Math.abs(walletRootStore.getEstimatedLatestBlockNumber(modelData.chainIdIn) - detailsObj.blockNumberIn)
@ -465,8 +468,8 @@ StatusListItem {
} }
// VALUES // VALUES
const fiatTransactionValue = rootStore.currencyStore.formatCurrencyAmount(isMultiTransaction ? root.outFiatValue : root.fiatValue, root.currentCurrency) const fiatTransactionValue = currenciesStore.formatCurrencyAmount(isMultiTransaction ? root.outFiatValue : root.fiatValue, root.currentCurrency)
const feeFiatValue = rootStore.currencyStore.getFiatValue(feeEthValue, Constants.ethToken) const feeFiatValue = currenciesStore.getFiatValue(feeEthValue, Constants.ethToken)
let valuesString = "" let valuesString = ""
if (!root.isNFT) { if (!root.isNFT) {
switch(type) { switch(type) {
@ -481,14 +484,14 @@ StatusListItem {
break break
} }
if (type === Constants.TransactionType.Swap) { if (type === Constants.TransactionType.Swap) {
const crypto = rootStore.currencyStore.formatCurrencyAmount(root.inCryptoValue, modelData.inSymbol) const crypto = currenciesStore.formatCurrencyAmount(root.inCryptoValue, modelData.inSymbol)
const fiat = rootStore.currencyStore.formatCurrencyAmount(root.inCryptoValue, modelData.inSymbol) const fiat = currenciesStore.formatCurrencyAmount(root.inCryptoValue, modelData.inSymbol)
valuesString += qsTr("Amount received %1 (%2)").arg(crypto).arg(fiat) + endl2 valuesString += qsTr("Amount received %1 (%2)").arg(crypto).arg(fiat) + endl2
} else if (type === Constants.TransactionType.Bridge) { } else if (type === Constants.TransactionType.Bridge) {
// Reduce crypto value by fee value // Reduce crypto value by fee value
const valueInCrypto = rootStore.currencyStore.getCryptoValue(root.fiatValue - feeFiatValue, modelData.inSymbol) const valueInCrypto = currenciesStore.getCryptoValue(root.fiatValue - feeFiatValue, modelData.inSymbol)
const crypto = rootStore.currencyStore.formatCurrencyAmount(valueInCrypto, modelData.inSymbol) const crypto = currenciesStore.formatCurrencyAmount(valueInCrypto, modelData.inSymbol)
const fiat = rootStore.currencyStore.formatCurrencyAmount(root.fiatValue - feeFiatValue, root.currentCurrency) const fiat = currenciesStore.formatCurrencyAmount(root.fiatValue - feeFiatValue, root.currentCurrency)
valuesString += qsTr("Amount received %1 (%2)").arg(crypto).arg(fiat) + endl2 valuesString += qsTr("Amount received %1 (%2)").arg(crypto).arg(fiat) + endl2
} }
switch(type) { switch(type) {
@ -496,7 +499,7 @@ StatusListItem {
case Constants.TransactionType.Swap: case Constants.TransactionType.Swap:
case Constants.TransactionType.Bridge: case Constants.TransactionType.Bridge:
const feeValue = LocaleUtils.currencyAmountToLocaleString(detailsObj.totalFees) const feeValue = LocaleUtils.currencyAmountToLocaleString(detailsObj.totalFees)
const feeFiat = rootStore.currencyStore.formatCurrencyAmount(feeFiatValue, root.currentCurrency) const feeFiat = currenciesStore.formatCurrencyAmount(feeFiatValue, root.currentCurrency)
valuesString += qsTr("Fees %1 (%2)").arg(feeValue).arg(feeFiat) + endl2 valuesString += qsTr("Fees %1 (%2)").arg(feeValue).arg(feeFiat) + endl2
break break
default: default:
@ -506,25 +509,25 @@ StatusListItem {
if (!root.isNFT || type !== Constants.TransactionType.Receive) { if (!root.isNFT || type !== Constants.TransactionType.Receive) {
if (type === Constants.TransactionType.Destroy || root.isNFT) { if (type === Constants.TransactionType.Destroy || root.isNFT) {
const feeCrypto = rootStore.currencyStore.formatCurrencyAmount(feeEthValue, "ETH") const feeCrypto = currenciesStore.formatCurrencyAmount(feeEthValue, "ETH")
const feeFiat = rootStore.currencyStore.formatCurrencyAmount(feeFiatValue, root.currentCurrency) const feeFiat = currenciesStore.formatCurrencyAmount(feeFiatValue, root.currentCurrency)
valuesString += qsTr("Fees %1 (%2)").arg(feeCrypto).arg(feeFiat) + endl2 valuesString += qsTr("Fees %1 (%2)").arg(feeCrypto).arg(feeFiat) + endl2
} else if (type === Constants.TransactionType.Receive || (type === Constants.TransactionType.Buy && networkLayer === 1)) { } else if (type === Constants.TransactionType.Receive || (type === Constants.TransactionType.Buy && networkLayer === 1)) {
valuesString += qsTr("Total %1 (%2)").arg(root.transactionValue).arg(fiatTransactionValue) + endl2 valuesString += qsTr("Total %1 (%2)").arg(root.transactionValue).arg(fiatTransactionValue) + endl2
} else if (type === Constants.TransactionType.ContractDeployment) { } else if (type === Constants.TransactionType.ContractDeployment) {
const isPending = root.transactionStatus === Constants.TransactionStatus.Pending const isPending = root.transactionStatus === Constants.TransactionStatus.Pending
if (isPending) { if (isPending) {
const maxFeeEthValue = rootStore.currencyStore.getFeeEthValue(detailsObj.maxTotalFees.amount) const maxFeeEthValue = currenciesStore.getFeeEthValue(detailsObj.maxTotalFees.amount)
const maxFeeCrypto = rootStore.currencyStore.formatCurrencyAmount(maxFeeEthValue, "ETH") const maxFeeCrypto = currenciesStore.formatCurrencyAmount(maxFeeEthValue, "ETH")
const maxFeeFiat = rootStore.currencyStore.formatCurrencyAmount(maxFeeCrypto, root.currentCurrency) const maxFeeFiat = currenciesStore.formatCurrencyAmount(maxFeeCrypto, root.currentCurrency)
valuesString += qsTr("Estimated max fee %1 (%2)").arg(maxFeeCrypto).arg(maxFeeFiat) + endl2 valuesString += qsTr("Estimated max fee %1 (%2)").arg(maxFeeCrypto).arg(maxFeeFiat) + endl2
} else { } else {
const feeCrypto = rootStore.currencyStore.formatCurrencyAmount(feeEthValue, "ETH") const feeCrypto = currenciesStore.formatCurrencyAmount(feeEthValue, "ETH")
const feeFiat = rootStore.currencyStore.formatCurrencyAmount(feeFiatValue, root.currentCurrency) const feeFiat = currenciesStore.formatCurrencyAmount(feeFiatValue, root.currentCurrency)
valuesString += qsTr("Fees %1 (%2)").arg(feeCrypto).arg(feeFiat) + endl2 valuesString += qsTr("Fees %1 (%2)").arg(feeCrypto).arg(feeFiat) + endl2
} }
} else { } else {
const feeEth = rootStore.currencyStore.formatCurrencyAmount(feeEthValue, "ETH") const feeEth = currenciesStore.formatCurrencyAmount(feeEthValue, "ETH")
const txValue = isMultiTransaction ? root.inTransactionValue : root.transactionValue const txValue = isMultiTransaction ? root.inTransactionValue : root.transactionValue
valuesString += qsTr("Total %1 + %2 (%3)").arg(txValue).arg(feeEth).arg(fiatTransactionValue) + endl2 valuesString += qsTr("Total %1 + %2 (%3)").arg(txValue).arg(feeEth).arg(fiatTransactionValue) + endl2
} }
@ -841,12 +844,12 @@ StatusListItem {
case Constants.TransactionType.Send: case Constants.TransactionType.Send:
case Constants.TransactionType.Sell: case Constants.TransactionType.Sell:
case Constants.TransactionType.Buy: case Constants.TransactionType.Buy:
return "" + root.rootStore.currencyStore.formatCurrencyAmount(root.fiatValue, root.currentCurrency) return "" + root.currenciesStore.formatCurrencyAmount(root.fiatValue, root.currentCurrency)
case Constants.TransactionType.Receive: case Constants.TransactionType.Receive:
return "+" + root.rootStore.currencyStore.formatCurrencyAmount(root.fiatValue, root.currentCurrency) return "+" + root.currenciesStore.formatCurrencyAmount(root.fiatValue, root.currentCurrency)
case Constants.TransactionType.Swap: case Constants.TransactionType.Swap:
return "-%1 / +%2".arg(root.rootStore.currencyStore.formatCurrencyAmount(root.outFiatValue, root.currentCurrency)) return "-%1 / +%2".arg(root.currenciesStore.formatCurrencyAmount(root.outFiatValue, root.currentCurrency))
.arg(root.rootStore.currencyStore.formatCurrencyAmount(root.inFiatValue, root.currentCurrency)) .arg(root.currenciesStore.formatCurrencyAmount(root.inFiatValue, root.currentCurrency))
case Constants.TransactionType.Bridge: case Constants.TransactionType.Bridge:
case Constants.TransactionType.Approve: case Constants.TransactionType.Approve:
default: default:

View File

@ -22,7 +22,6 @@ QtObject {
property bool gifUnfurlingEnabled: !!accountSensitiveSettings ? accountSensitiveSettings.gifUnfurlingEnabled : false property bool gifUnfurlingEnabled: !!accountSensitiveSettings ? accountSensitiveSettings.gifUnfurlingEnabled : false
property CurrenciesStore currencyStore: CurrenciesStore {} property CurrenciesStore currencyStore: CurrenciesStore {}
property string currentCurrency: Global.appIsReady? walletSectionInst.currentCurrency : ""
readonly property var transactionActivityStatus: Global.appIsReady ? walletSectionInst.activityController.status : null readonly property var transactionActivityStatus: Global.appIsReady ? walletSectionInst.activityController.status : null

View File

@ -486,7 +486,8 @@ ColumnLayout {
Layout.fillWidth: true Layout.fillWidth: true
modelData: transactionDelegate.model.activityEntry modelData: transactionDelegate.model.activityEntry
timeStampText: isModelDataValid ? LocaleUtils.formatRelativeTimestamp(modelData.timestamp * 1000, true) : "" timeStampText: isModelDataValid ? LocaleUtils.formatRelativeTimestamp(modelData.timestamp * 1000, true) : ""
rootStore: RootStore flatNetworks: RootStore.flatNetworks
currenciesStore: RootStore.currencyStore
walletRootStore: WalletStores.RootStore walletRootStore: WalletStores.RootStore
showAllAccounts: root.showAllAccounts showAllAccounts: root.showAllAccounts
displayValues: root.displayValues displayValues: root.displayValues
@ -549,7 +550,9 @@ ColumnLayout {
} }
TransactionDelegate { TransactionDelegate {
Layout.fillWidth: true Layout.fillWidth: true
rootStore: RootStore
flatNetworks: RootStore.flatNetworks
currenciesStore: RootStore.currencyStore
walletRootStore: WalletStores.RootStore walletRootStore: WalletStores.RootStore
loading: true loading: true
} }