Allow block to be passed with eth_estimageGas

This commit is contained in:
Eric 2023-09-26 17:36:24 +10:00
parent 68f07e96fc
commit 0d0a872ca0
No known key found for this signature in database
4 changed files with 8 additions and 5 deletions

View File

@ -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.} =

View File

@ -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:

View File

@ -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

View File

@ -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: