feat: beautify the hex values in transaction history

beautify nonce too

ammend the code to call conversion functions from qt instead

move to utils

var to let
This commit is contained in:
hydr063n 2020-09-28 08:58:55 +02:00 committed by Iuri Matias
parent d882bde5aa
commit 3229fc06e6
3 changed files with 21 additions and 6 deletions

View File

@ -59,3 +59,18 @@ QtObject:
QtProperty[QVariant] ensRegisterAddress:
read = getEnsRegisterAddress
proc stripTrailingZeroes(value: string): string =
var str = value.strip(leading = false, chars = {'0'})
if str[str.len - 1] == '.':
add(str, "0")
return str
proc hex2Eth*(self: UtilsView, value: string): string {.slot.} =
return stripTrailingZeroes(status_utils.wei2Eth(stint.fromHex(StUint[256], value)))
proc hex2Dec*(self: UtilsView, value: string): string {.slot.} =
# somehow this value crashes the app
if value == "0x0":
return "0"
return stripTrailingZeroes(stint.toString(stint.fromHex(StUint[256], value)))

View File

@ -131,7 +131,7 @@ Item {
anchors.top: parent.top
anchors.topMargin: Style.current.bigPadding
font.pixelSize: 15
text: value + " " + transactionListItem.symbol
text: utilsModel.hex2Eth(value) + " " + transactionListItem.symbol
}
}

View File

@ -69,7 +69,7 @@ ModalPopup {
StyledText {
id: valueBlock
text: blockNumber
text: utilsModel.hex2Dec(blockNumber)
font.pixelSize: 14
anchors.left: labelBlock.right
anchors.leftMargin: Style.current.padding
@ -182,7 +182,7 @@ ModalPopup {
StyledText {
id: valueGasLimit
text: gasLimit
text: utilsModel.hex2Dec(gasLimit)
font.pixelSize: 14
anchors.left: labelGasLimit.right
anchors.leftMargin: Style.current.padding
@ -208,7 +208,7 @@ ModalPopup {
StyledText {
id: valueGasPrice
text: gasPrice
text: utilsModel.hex2Eth(gasPrice)
font.pixelSize: 14
anchors.left: labelGasPrice.right
anchors.leftMargin: Style.current.padding
@ -234,7 +234,7 @@ ModalPopup {
StyledText {
id: valueGasUsed
text: gasUsed
text: utilsModel.hex2Dec(gasUsed)
font.pixelSize: 14
anchors.left: labelGasUsed.right
anchors.leftMargin: Style.current.padding
@ -260,7 +260,7 @@ ModalPopup {
StyledText {
id: valueNonce
text: nonce
text: utilsModel.hex2Dec(nonce)
font.pixelSize: 14
anchors.left: labelNonce.right
anchors.leftMargin: Style.current.padding