fix: pending transactions crashing on infura issues
This commit is contained in:
parent
c8a1de695c
commit
e747ed8f1b
|
@ -103,11 +103,12 @@ QtObject:
|
|||
purchasedStickerPacks = self.status.stickers.getPurchasedStickerPacks(address)
|
||||
let availableStickers = JSON.decode($availableStickersJSON, seq[StickerPack])
|
||||
|
||||
let pendingTransactions = status_wallet.getPendingTransactions().parseJson["result"]
|
||||
let pendingTransactions = status_wallet.getPendingTransactions()
|
||||
var pendingStickerPacks = initHashSet[int]()
|
||||
for trx in pendingTransactions.getElems():
|
||||
if trx["type"].getStr == $PendingTransactionType.BuyStickerPack:
|
||||
pendingStickerPacks.incl(trx["data"].getStr.parseInt)
|
||||
if (pendingTransactions != ""):
|
||||
for trx in pendingTransactions.parseJson["result"].getElems():
|
||||
if trx["type"].getStr == $PendingTransactionType.BuyStickerPack:
|
||||
pendingStickerPacks.incl(trx["data"].getStr.parseInt)
|
||||
|
||||
for stickerPack in availableStickers:
|
||||
let isInstalled = installedStickerPacks.hasKey(stickerPack.id)
|
||||
|
|
|
@ -43,8 +43,10 @@ QtObject:
|
|||
self.usernames = status_settings.getSetting[seq[string]](Setting.Usernames, @[])
|
||||
|
||||
# Get pending ens names
|
||||
let pendingTransactions = status_wallet.getPendingTransactions().parseJson["result"]
|
||||
for trx in pendingTransactions.getElems():
|
||||
let pendingTransactions = status_wallet.getPendingTransactions()
|
||||
if (pendingTransactions == ""):
|
||||
return
|
||||
for trx in pendingTransactions.parseJson["result"].getElems():
|
||||
if trx["type"].getStr == $PendingTransactionType.RegisterENS:
|
||||
self.usernames.add trx["data"].getStr
|
||||
self.pendingUsernames.incl trx["data"].getStr
|
||||
|
|
|
@ -103,7 +103,12 @@ proc trackPendingTransaction*(transactionHash: string, fromAddress: string, toAd
|
|||
|
||||
proc getPendingTransactions*(): string =
|
||||
let payload = %* []
|
||||
result = callPrivateRPC("wallet_getPendingTransactions", payload)
|
||||
try:
|
||||
result = callPrivateRPC("wallet_getPendingTransactions", payload)
|
||||
except Exception as e:
|
||||
error "Error getting pending transactions (possible dev Infura key)", msg = e.msg
|
||||
result = ""
|
||||
|
||||
|
||||
proc getPendingOutboundTransactionsByAddress*(address: string): string =
|
||||
let payload = %* [address]
|
||||
|
|
|
@ -3,7 +3,7 @@ import types
|
|||
|
||||
proc fromEvent*(jsonSignal: JsonNode): Signal =
|
||||
var signal:WalletSignal = WalletSignal()
|
||||
if jsonSignal["event"].kind != JNull:
|
||||
if jsonSignal["event"].kind != JNull and jsonSignal["event"]{"blockNumber"}.kind != JNull:
|
||||
signal.eventType = jsonSignal["event"]["type"].getStr
|
||||
signal.blockNumber = jsonSignal["event"]["blockNumber"].getInt
|
||||
signal.erc20 = jsonSignal["event"]["erc20"].getBool
|
||||
|
|
|
@ -102,7 +102,10 @@ proc checkPendingTransactions*(self: WalletModel) =
|
|||
let response = getBlockByNumber("latest").parseJson()
|
||||
if response.hasKey("result"):
|
||||
let latestBlock = parseInt($fromHex(Stuint[256], response["result"]["number"].getStr))
|
||||
self.confirmTransactionStatus(status_wallet.getPendingTransactions().parseJson["result"], latestBlock)
|
||||
let pendingTransactions = status_wallet.getPendingTransactions()
|
||||
if (pendingTransactions != ""):
|
||||
self.confirmTransactionStatus(pendingTransactions.parseJson["result"], latestBlock)
|
||||
|
||||
|
||||
proc checkPendingTransactions*(self: WalletModel, address: string, blockNumber: int) =
|
||||
self.confirmTransactionStatus(status_wallet.getPendingOutboundTransactionsByAddress(address).parseJson["result"], blockNumber)
|
||||
|
|
Loading…
Reference in New Issue