mirror of https://github.com/waku-org/nwaku.git
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")
|
return err("Eligibility proof is empty")
|
||||||
let txHash = TxHash.fromHex(byteutils.toHex(eligibilityProof.proofOfPayment.get()))
|
let txHash = TxHash.fromHex(byteutils.toHex(eligibilityProof.proofOfPayment.get()))
|
||||||
let web3 = await newWeb3(ethClient)
|
let web3 = await newWeb3(ethClient)
|
||||||
|
var tx: TransactionObject
|
||||||
|
var txReceipt: ReceiptObject
|
||||||
try:
|
try:
|
||||||
# TODO: make requests in parallel (?)
|
# TODO: make requests in parallel (?)
|
||||||
let tx = await web3.provider.eth_getTransactionByHash(txHash)
|
tx = await web3.provider.eth_getTransactionByHash(txHash)
|
||||||
let txReceipt = await web3.getMinedTransactionReceipt(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
|
# check that it is not a contract creation tx
|
||||||
let toAddressOption = txReceipt.to
|
let toAddressOption = txReceipt.to
|
||||||
if toAddressOption.isNone:
|
if toAddressOption.isNone:
|
||||||
|
@ -44,7 +50,3 @@ proc isEligibleTxId*(
|
||||||
defer:
|
defer:
|
||||||
await web3.close()
|
await web3.close()
|
||||||
return ok()
|
return ok()
|
||||||
except ValueError:
|
|
||||||
let errorMsg = "Failed to fetch tx or tx receipt: " & getCurrentExceptionMsg()
|
|
||||||
error "exception in isEligibleTxId", error = $errorMsg
|
|
||||||
return err($errorMsg)
|
|
||||||
|
|
Loading…
Reference in New Issue