fix: specify raises for getAddress and sendTransaction

Fixes issue where getAddress and sendTransaction could not be found for MockSigner in tests. The problem was that the async: raises update had not been applied to the MockSigner.
This commit is contained in:
Eric 2024-02-02 16:31:01 +11:00
parent 502457633d
commit 69f90a3d67
No known key found for this signature in database
4 changed files with 18 additions and 10 deletions

View File

@ -301,7 +301,7 @@ method provider*(signer: JsonRpcSigner): Provider {.gcsafe, raises: [SignerError
signer.provider
method getAddress*(
signer: JsonRpcSigner): Future[Address] {.async.} =
signer: JsonRpcSigner): Future[Address] {.async: (raises:[SignerError]).} =
if address =? signer.address:
return address
@ -324,7 +324,8 @@ method signMessage*(
method sendTransaction*(
signer: JsonRpcSigner,
transaction: Transaction): Future[TransactionResponse] {.async.} =
transaction: Transaction): Future[TransactionResponse]
{.async: (raises:[SignerError]).} =
convertSignerError:
if nonce =? transaction.nonce:

View File

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

View File

@ -67,7 +67,9 @@ method provider*(wallet: Wallet): Provider {.gcsafe, raises: [SignerError].} =
raiseWalletError "Wallet has no provider"
provider
method getAddress*(wallet: Wallet): Future[Address] {.async.} =
method getAddress*(
wallet: Wallet): Future[Address] {.async: (raises:[SignerError]).} =
return wallet.address
proc signTransaction*(wallet: Wallet,
@ -79,7 +81,8 @@ proc signTransaction*(wallet: Wallet,
method sendTransaction*(
wallet: Wallet,
transaction: Transaction): Future[TransactionResponse] {.async.} =
transaction: Transaction): Future[TransactionResponse]
{.async: (raises:[SignerError]).} =
convertError:
let signed = await signTransaction(wallet, transaction)

View File

@ -11,10 +11,14 @@ func new*(_: type MockSigner, provider: Provider): MockSigner =
method provider*(signer: MockSigner): Provider =
signer.provider
method getAddress*(signer: MockSigner): Future[Address] {.async.} =
method getAddress*(
signer: MockSigner): Future[Address] {.async: (raises:[SignerError]).} =
return signer.address
method sendTransaction*(signer: MockSigner,
transaction: Transaction):
Future[TransactionResponse] {.async.} =
method sendTransaction*(
signer: MockSigner,
transaction: Transaction): Future[TransactionResponse]
{.async: (raises:[SignerError]).} =
signer.transactions.add(transaction)