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