mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-10 14:26:34 +00:00
refactor: rename Asset.fiatValue -> Asset.fiatBalanceDisplay
This is done because `fiatValue` included the currency symbol
This commit is contained in:
parent
b6884a5170
commit
d62d8b3a92
@ -6,7 +6,7 @@ type
|
||||
Name = UserRole + 1,
|
||||
Symbol = UserRole + 2,
|
||||
Value = UserRole + 3,
|
||||
FiatValue = UserRole + 4
|
||||
FiatBalanceDisplay = UserRole + 4
|
||||
Address = UserRole + 5
|
||||
|
||||
QtObject:
|
||||
@ -32,7 +32,7 @@ QtObject:
|
||||
of "name": result = asset.name
|
||||
of "symbol": result = asset.symbol
|
||||
of "value": result = asset.value
|
||||
of "fiatValue": result = asset.fiatValue
|
||||
of "fiatBalanceDisplay": result = asset.fiatBalanceDisplay
|
||||
of "address": result = asset.address
|
||||
|
||||
method rowCount(self: AssetList, index: QModelIndex = nil): int =
|
||||
@ -49,14 +49,14 @@ QtObject:
|
||||
of AssetRoles.Name: result = newQVariant(asset.name)
|
||||
of AssetRoles.Symbol: result = newQVariant(asset.symbol)
|
||||
of AssetRoles.Value: result = newQVariant(asset.value)
|
||||
of AssetRoles.FiatValue: result = newQVariant(asset.fiatValue)
|
||||
of AssetRoles.FiatBalanceDisplay: result = newQVariant(asset.fiatBalanceDisplay)
|
||||
of AssetRoles.Address: result = newQVariant(asset.address)
|
||||
|
||||
method roleNames(self: AssetList): Table[int, string] =
|
||||
{ AssetRoles.Name.int:"name",
|
||||
AssetRoles.Symbol.int:"symbol",
|
||||
AssetRoles.Value.int:"value",
|
||||
AssetRoles.FiatValue.int:"fiatValue",
|
||||
AssetRoles.FiatBalanceDisplay.int:"fiatBalanceDisplay",
|
||||
AssetRoles.Address.int:"address" }.toTable
|
||||
|
||||
proc addAssetToList*(self: AssetList, asset: Asset) =
|
||||
|
@ -62,11 +62,11 @@ proc setDefaultCurrency*(self: WalletModel, currency: string) =
|
||||
|
||||
proc generateAccountConfiguredAssets*(self: WalletModel, accountAddress: string): seq[Asset] =
|
||||
var assets: seq[Asset] = @[]
|
||||
var asset = Asset(name:"Ethereum", symbol: "ETH", value: "0.0", fiatValue: "0.0", accountAddress: accountAddress)
|
||||
var asset = Asset(name:"Ethereum", symbol: "ETH", value: "0.0", fiatBalanceDisplay: "0.0", accountAddress: accountAddress)
|
||||
assets.add(asset)
|
||||
for token in self.tokens:
|
||||
var symbol = token["symbol"].getStr
|
||||
var existingToken = Asset(name: token["name"].getStr, symbol: symbol, value: fmt"0.0", fiatValue: "$0.0", accountAddress: accountAddress, address: token["address"].getStr)
|
||||
var existingToken = Asset(name: token["name"].getStr, symbol: symbol, value: fmt"0.0", fiatBalanceDisplay: "$0.0", accountAddress: accountAddress, address: token["address"].getStr)
|
||||
assets.add(existingToken)
|
||||
assets
|
||||
|
||||
|
@ -8,7 +8,7 @@ type CurrencyArgs* = ref object of Args
|
||||
currency*: string
|
||||
|
||||
type Asset* = ref object
|
||||
name*, symbol*, value*, fiatValue*, accountAddress*, address*: string
|
||||
name*, symbol*, value*, fiatBalanceDisplay*, accountAddress*, address*: string
|
||||
|
||||
type WalletAccount* = ref object
|
||||
name*, address*, iconColor*, balance*, path*, walletType*, publicKey*: string
|
||||
|
@ -63,7 +63,7 @@ proc updateBalance*(asset: Asset, currency: string) =
|
||||
var token_balance = getBalance(asset.symbol, asset.accountAddress, asset.address)
|
||||
let fiat_balance = getFiatValue(token_balance, asset.symbol, currency)
|
||||
asset.value = token_balance
|
||||
asset.fiatValue = fmt"{fiat_balance:.2f} {currency}"
|
||||
asset.fiatBalanceDisplay = fmt"{fiat_balance:.2f} {currency}"
|
||||
|
||||
proc updateBalance*(account: WalletAccount, currency: string) =
|
||||
try:
|
||||
|
@ -58,7 +58,7 @@ Item {
|
||||
StyledText {
|
||||
id: assetFiatValue
|
||||
color: Style.current.darkGrey
|
||||
text: fiatValue.toUpperCase()
|
||||
text: fiatBalanceDisplay.toUpperCase()
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 0
|
||||
anchors.bottom: parent.bottom
|
||||
@ -75,7 +75,7 @@ Item {
|
||||
value: "123 USD"
|
||||
symbol: "ETH"
|
||||
fullTokenName: "Ethereum"
|
||||
fiatValue: "3423 ETH"
|
||||
fiatBalanceDisplay: "3423 ETH"
|
||||
image: "../../img/token-icons/eth.svg"
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ Item {
|
||||
id: root
|
||||
property var assets
|
||||
property var selectedAsset: {
|
||||
"symbol": "snt", "name": "", "value": "", "fiatValue": "", "address": ""
|
||||
"symbol": "snt", "name": "", "value": "", "fiatBalanceDisplay": "", "address": ""
|
||||
}
|
||||
width: 86
|
||||
height: 24
|
||||
@ -61,7 +61,7 @@ Item {
|
||||
|
||||
Component.onCompleted: {
|
||||
if (root.selectedAsset.name === "") {
|
||||
root.selectedAsset = { address, name, value, symbol, fiatValue }
|
||||
root.selectedAsset = { address, name, value, symbol, fiatBalanceDisplay }
|
||||
}
|
||||
}
|
||||
width: parent.width
|
||||
@ -109,7 +109,7 @@ Item {
|
||||
font.pixelSize: 15
|
||||
anchors.right: parent.right
|
||||
height: 22
|
||||
text: fiatValue.toUpperCase()
|
||||
text: fiatBalanceDisplay.toUpperCase()
|
||||
color: Style.current.secondaryText
|
||||
}
|
||||
}
|
||||
@ -141,7 +141,7 @@ Item {
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
anchors.fill: itemContainer
|
||||
onClicked: {
|
||||
root.selectedAsset = { address, name, value, symbol, fiatValue }
|
||||
root.selectedAsset = { address, name, value, symbol, fiatBalanceDisplay }
|
||||
select.menu.close()
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user