sendTransaction raises ProviderError instead of SignerError

Allows it to contain error data.
It is not the signing that fails, so it makes sense to
use an error type that indicates that the provider failed.
This commit is contained in:
Mark Spanbroek 2024-03-20 15:01:48 +01:00 committed by markspanbroek
parent 1ce9824738
commit 241ce6e8f3
5 changed files with 10 additions and 11 deletions

View File

@ -324,9 +324,9 @@ method signMessage*(
method sendTransaction*(
signer: JsonRpcSigner,
transaction: Transaction): Future[TransactionResponse]
{.async: (raises:[SignerError]).} =
{.async: (raises:[SignerError, ProviderError]).} =
convertSignerError:
convertError:
if nonce =? transaction.nonce:
signer.updateNonce(nonce)
let

View File

@ -43,7 +43,7 @@ method signMessage*(
method sendTransaction*(
signer: Signer,
transaction: Transaction): Future[TransactionResponse]
{.base, async: (raises:[SignerError]).} =
{.base, async: (raises:[SignerError, ProviderError]).} =
doAssert false, "not implemented"

View File

@ -83,10 +83,9 @@ proc signTransaction*(wallet: Wallet,
method sendTransaction*(
wallet: Wallet,
transaction: Transaction): Future[TransactionResponse]
{.async: (raises:[SignerError]).} =
{.async: (raises:[SignerError, ProviderError]).} =
convertError:
let signed = await signTransaction(wallet, transaction)
if nonce =? transaction.nonce:
wallet.updateNonce(nonce)
return await provider(wallet).sendTransaction(signed)
let signed = await signTransaction(wallet, transaction)
if nonce =? transaction.nonce:
wallet.updateNonce(nonce)
return await provider(wallet).sendTransaction(signed)

View File

@ -20,6 +20,6 @@ method getAddress*(
method sendTransaction*(
signer: MockSigner,
transaction: Transaction): Future[TransactionResponse]
{.async: (raises:[SignerError]).} =
{.async: (raises:[SignerError, ProviderError]).} =
signer.transactions.add(transaction)

View File

@ -97,7 +97,7 @@ for url in ["ws://localhost:8545", "http://localhost:8545"]:
discard await provider.getBlock(BlockTag.latest)
expect JsonRpcProviderError:
discard await provider.subscribe(proc(_: Block) = discard)
expect JsonRpcSignerError:
expect JsonRpcProviderError:
discard await provider.getSigner().sendTransaction(Transaction.example)
test "syncing":