mirror of
https://github.com/logos-storage/nim-ethers.git
synced 2026-01-02 13:43:06 +00:00
Define raises for async pragma
This commit is contained in:
parent
b505ef1ab8
commit
5d07b5dbcf
@ -321,7 +321,7 @@ proc subscribe*[E: Event](contract: Contract,
|
||||
contract.provider.subscribe(filter, logHandler)
|
||||
|
||||
proc confirm(tx: Confirmable, confirmations, timeout: int):
|
||||
Future[TransactionReceipt] {.async.} =
|
||||
Future[TransactionReceipt] {.async: (raises: [CancelledError, EthersError]).} =
|
||||
|
||||
without response =? tx.response:
|
||||
raise newException(
|
||||
@ -338,13 +338,23 @@ proc confirm(tx: Confirmable, confirmations, timeout: int):
|
||||
proc confirm*(tx: Future[Confirmable],
|
||||
confirmations: int = EthersDefaultConfirmations,
|
||||
timeout: int = EthersReceiptTimeoutBlks):
|
||||
Future[TransactionReceipt] {.async.} =
|
||||
Future[TransactionReceipt] {.async: (raises: [CancelledError, EthersError]).} =
|
||||
## Convenience method that allows confirm to be chained to a contract
|
||||
## transaction, eg:
|
||||
## `await token.connect(signer0)
|
||||
## .mint(accounts[1], 100.u256)
|
||||
## .confirm(3)`
|
||||
return await (await tx).confirm(confirmations, timeout)
|
||||
try:
|
||||
return await (await tx).confirm(confirmations, timeout)
|
||||
except CancelledError as e:
|
||||
raise e
|
||||
except EthersError as e:
|
||||
raise e
|
||||
except CatchableError as e:
|
||||
raise newException(
|
||||
EthersError,
|
||||
"Error when trying to confirm the contract transaction: " & e.msg
|
||||
)
|
||||
|
||||
proc queryFilter[E: Event](contract: Contract,
|
||||
_: type E,
|
||||
|
||||
@ -293,13 +293,22 @@ proc confirm*(
|
||||
proc confirm*(
|
||||
tx: Future[TransactionResponse],
|
||||
confirmations: int = EthersDefaultConfirmations,
|
||||
timeout: int = EthersReceiptTimeoutBlks): Future[TransactionReceipt] {.async.} =
|
||||
timeout: int = EthersReceiptTimeoutBlks): Future[TransactionReceipt] {.async: (raises: [CancelledError, EthersError]).} =
|
||||
## Convenience method that allows wait to be chained to a sendTransaction
|
||||
## call, eg:
|
||||
## `await signer.sendTransaction(populated).confirm(3)`
|
||||
|
||||
let txResp = await tx
|
||||
return await txResp.confirm(confirmations, timeout)
|
||||
try:
|
||||
let txResp = await tx
|
||||
return await txResp.confirm(confirmations, timeout)
|
||||
except CancelledError as e:
|
||||
raise e
|
||||
except EthersError as e:
|
||||
raise e
|
||||
except CatchableError as e:
|
||||
raise newException(
|
||||
EthersError,
|
||||
"Error when trying to confirm the provider transaction: " & e.msg
|
||||
)
|
||||
|
||||
method close*(
|
||||
provider: Provider
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user