From 0d0a872ca00c64e205447502f622b26b445cd62e Mon Sep 17 00:00:00 2001 From: Eric <5089238+emizzle@users.noreply.github.com> Date: Tue, 26 Sep 2023 17:36:24 +1000 Subject: [PATCH] Allow block to be passed with eth_estimageGas --- ethers/provider.nim | 3 ++- ethers/providers/jsonrpc.nim | 5 +++-- ethers/providers/jsonrpc/signatures.nim | 2 +- ethers/signer.nim | 3 ++- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ethers/provider.nim b/ethers/provider.nim index 0a983c7..0e07da6 100644 --- a/ethers/provider.nim +++ b/ethers/provider.nim @@ -141,7 +141,8 @@ method getLogs*(provider: Provider, doAssert false, "not implemented" method estimateGas*(provider: Provider, - transaction: Transaction): Future[UInt256] {.base, gcsafe.} = + transaction: Transaction, + blockTag = BlockTag.latest): Future[UInt256] {.base, gcsafe.} = doAssert false, "not implemented" method getChainId*(provider: Provider): Future[UInt256] {.base, gcsafe.} = diff --git a/ethers/providers/jsonrpc.nim b/ethers/providers/jsonrpc.nim index 7068c1e..4b76ebb 100644 --- a/ethers/providers/jsonrpc.nim +++ b/ethers/providers/jsonrpc.nim @@ -199,10 +199,11 @@ method getLogs*(provider: JsonRpcProvider, return logs method estimateGas*(provider: JsonRpcProvider, - transaction: Transaction): Future[UInt256] {.async.} = + transaction: Transaction, + blockTag = BlockTag.latest): Future[UInt256] {.async.} = convertError: let client = await provider.client - return await client.eth_estimateGas(transaction) + return await client.eth_estimateGas(transaction, blockTag) method getChainId*(provider: JsonRpcProvider): Future[UInt256] {.async.} = convertError: diff --git a/ethers/providers/jsonrpc/signatures.nim b/ethers/providers/jsonrpc/signatures.nim index 688b632..d621cdd 100644 --- a/ethers/providers/jsonrpc/signatures.nim +++ b/ethers/providers/jsonrpc/signatures.nim @@ -10,7 +10,7 @@ proc eth_getLogs(filter: EventFilter | Filter | FilterByBlockHash): JsonNode proc eth_getTransactionByHash(hash: TransactionHash): ?PastTransaction proc eth_getBlockByHash(hash: BlockHash, includeTransactions: bool): ?Block proc eth_getTransactionCount(address: Address, blockTag: BlockTag): UInt256 -proc eth_estimateGas(transaction: Transaction): UInt256 +proc eth_estimateGas(transaction: Transaction, blockTag: BlockTag): UInt256 proc eth_chainId(): UInt256 proc eth_sendTransaction(transaction: Transaction): TransactionHash proc eth_sendRawTransaction(data: seq[byte]): TransactionHash diff --git a/ethers/signer.nim b/ethers/signer.nim index 021f329..c86f182 100644 --- a/ethers/signer.nim +++ b/ethers/signer.nim @@ -50,7 +50,8 @@ method getTransactionCount*(signer: Signer, return await signer.provider.getTransactionCount(address, blockTag) method estimateGas*(signer: Signer, - transaction: Transaction): Future[UInt256] {.base, async.} = + transaction: Transaction, + blockTag = BlockTag.latest): Future[UInt256] {.base, async.} = var transaction = transaction transaction.sender = some(await signer.getAddress) try: