mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-02 09:46:38 +00:00
parent
81fe8976dd
commit
4269b51ea6
@ -102,6 +102,9 @@ QtObject:
|
||||
self.balanceView.getAccountBalanceSuccess(jsonResponse)
|
||||
self.updateView()
|
||||
|
||||
proc getLatestBlockNumber*(self: WalletView): int {.slot.} =
|
||||
return self.status.wallet.getLatestBlockNumber()
|
||||
|
||||
proc getDefaultAddress*(self: WalletView): string {.slot.} =
|
||||
result = $self.status.wallet.getWalletAccounts()[0].address
|
||||
|
||||
|
@ -17,6 +17,7 @@ type
|
||||
From = UserRole + 12,
|
||||
To = UserRole + 13
|
||||
Contract = UserRole + 14
|
||||
Id = UserRole + 15
|
||||
|
||||
QtObject:
|
||||
type TransactionList* = ref object of QAbstractListModel
|
||||
@ -79,6 +80,7 @@ QtObject:
|
||||
of TransactionRoles.From: result = newQVariant(transaction.fromAddress)
|
||||
of TransactionRoles.To: result = newQVariant(transaction.to)
|
||||
of TransactionRoles.Contract: result = newQVariant(transaction.contract)
|
||||
of TransactionRoles.Id: result = newQVariant(transaction.id)
|
||||
|
||||
method roleNames(self: TransactionList): Table[int, string] =
|
||||
{ TransactionRoles.Type.int:"typeValue",
|
||||
@ -94,7 +96,8 @@ QtObject:
|
||||
TransactionRoles.Value.int:"value",
|
||||
TransactionRoles.From.int:"fromAddress",
|
||||
TransactionRoles.To.int:"to",
|
||||
TransactionRoles.Contract.int:"contract"}.toTable
|
||||
TransactionRoles.Contract.int:"contract",
|
||||
TransactionRoles.Id.int:"id",}.toTable
|
||||
|
||||
proc addTransactionToList*(self: TransactionList, transaction: Transaction) =
|
||||
self.beginInsertRows(newQModelIndex(), self.transactions.len, self.transactions.len)
|
||||
|
@ -98,14 +98,21 @@ proc confirmTransactionStatus(self: WalletModel, pendingTransactions: JsonNode,
|
||||
)
|
||||
self.events.emit(parseEnum[PendingTransactionType](trx["type"].getStr).confirmed, ev)
|
||||
|
||||
proc checkPendingTransactions*(self: WalletModel) =
|
||||
proc getLatestBlockNumber*(self: WalletModel): int =
|
||||
let response = getBlockByNumber("latest").parseJson()
|
||||
if response.hasKey("result"):
|
||||
let latestBlock = parseInt($fromHex(Stuint[256], response["result"]["number"].getStr))
|
||||
let pendingTransactions = status_wallet.getPendingTransactions()
|
||||
if (pendingTransactions != ""):
|
||||
self.confirmTransactionStatus(pendingTransactions.parseJson{"result"}, latestBlock)
|
||||
|
||||
if not response.hasKey("result"):
|
||||
return -1
|
||||
|
||||
return parseInt($fromHex(Stuint[256], response["result"]["number"].getStr))
|
||||
|
||||
proc checkPendingTransactions*(self: WalletModel) =
|
||||
let latestBlockNumber = self.getLatestBlockNumber()
|
||||
if latestBlockNumber == -1:
|
||||
return
|
||||
|
||||
let pendingTransactions = status_wallet.getPendingTransactions()
|
||||
if (pendingTransactions != ""):
|
||||
self.confirmTransactionStatus(pendingTransactions.parseJson{"result"}, latestBlockNumber)
|
||||
|
||||
proc checkPendingTransactions*(self: WalletModel, address: string, blockNumber: int) =
|
||||
self.confirmTransactionStatus(status_wallet.getPendingOutboundTransactionsByAddress(address).parseJson["result"], blockNumber)
|
||||
|
@ -20,9 +20,9 @@ ModalPopup {
|
||||
|
||||
StyledText {
|
||||
id: confirmationsCount
|
||||
// TODO get the right value
|
||||
//% "9999 Confirmations"
|
||||
text: qsTrId("9999-confirmations")
|
||||
text: {
|
||||
return walletModel.getLatestBlockNumber() - utilsModel.hex2Dec(blockNumber) + qsTrId(" confirmation(s)")
|
||||
}
|
||||
font.pixelSize: 14
|
||||
}
|
||||
|
||||
@ -97,7 +97,7 @@ ModalPopup {
|
||||
|
||||
Address {
|
||||
id: valueHash
|
||||
text: blockHash
|
||||
text: id
|
||||
width: 160
|
||||
maxWidth: parent.width - labelHash.width - Style.current.padding
|
||||
color: Style.current.textColor
|
||||
|
Loading…
x
Reference in New Issue
Block a user