mirror of
https://github.com/waku-org/nwaku.git
synced 2025-01-16 09:55:07 +00:00
make try-block smaller
This commit is contained in:
parent
a92ffc7a42
commit
4b60383f39
@ -18,10 +18,16 @@ proc isEligibleTxId*(
|
||||
return err("Eligibility proof is empty")
|
||||
let txHash = TxHash.fromHex(byteutils.toHex(eligibilityProof.proofOfPayment.get()))
|
||||
let web3 = await newWeb3(ethClient)
|
||||
var tx: TransactionObject
|
||||
var txReceipt: ReceiptObject
|
||||
try:
|
||||
# TODO: make requests in parallel (?)
|
||||
let tx = await web3.provider.eth_getTransactionByHash(txHash)
|
||||
let txReceipt = await web3.getMinedTransactionReceipt(txHash)
|
||||
tx = await web3.provider.eth_getTransactionByHash(txHash)
|
||||
txReceipt = await web3.getMinedTransactionReceipt(txHash)
|
||||
except ValueError:
|
||||
let errorMsg = "Failed to fetch tx or tx receipt: " & getCurrentExceptionMsg()
|
||||
error "exception in isEligibleTxId", error = $errorMsg
|
||||
return err($errorMsg)
|
||||
# check that it is not a contract creation tx
|
||||
let toAddressOption = txReceipt.to
|
||||
if toAddressOption.isNone:
|
||||
@ -44,7 +50,3 @@ proc isEligibleTxId*(
|
||||
defer:
|
||||
await web3.close()
|
||||
return ok()
|
||||
except ValueError:
|
||||
let errorMsg = "Failed to fetch tx or tx receipt: " & getCurrentExceptionMsg()
|
||||
error "exception in isEligibleTxId", error = $errorMsg
|
||||
return err($errorMsg)
|
||||
|
Loading…
x
Reference in New Issue
Block a user