Add eth_call, allowing JsonNode to be passed directly to the RPC server

This commit is contained in:
Eric 2023-09-26 17:34:38 +10:00
parent c09ac02dab
commit 68f07e96fc
No known key found for this signature in database
3 changed files with 5 additions and 3 deletions

View File

@ -1,3 +1,4 @@
import std/json
import pkg/chronicles
import ./basics
import ./transaction
@ -102,7 +103,7 @@ method getBlock*(provider: Provider, tag: BlockTag): Future[?Block] {.base, gcsa
doAssert false, "not implemented"
method call*(provider: Provider,
tx: PastTransaction,
tx: JsonNode,
blockTag = BlockTag.latest): Future[seq[byte]] {.base, gcsafe.} =
doAssert false, "not implemented"

View File

@ -139,14 +139,14 @@ method getBlock*(provider: JsonRpcProvider,
return await client.eth_getBlockByNumber(tag, false)
method call*(provider: JsonRpcProvider,
tx: Transaction,
tx: JsonNode,
blockTag = BlockTag.latest): Future[seq[byte]] {.async.} =
convertError:
let client = await provider.client
return await client.eth_call(tx, blockTag)
method call*(provider: JsonRpcProvider,
tx: PastTransaction,
tx: Transaction,
blockTag = BlockTag.latest): Future[seq[byte]] {.async.} =
convertError:
let client = await provider.client

View File

@ -3,6 +3,7 @@ proc eth_accounts: seq[Address]
proc eth_blockNumber: UInt256
proc eth_call(transaction: Transaction, blockTag: BlockTag): seq[byte]
proc eth_call(transaction: PastTransaction, blockTag: BlockTag): seq[byte]
proc eth_call(transaction: JsonNode, blockTag: BlockTag): seq[byte]
proc eth_gasPrice(): UInt256
proc eth_getBlockByNumber(blockTag: BlockTag, includeTransactions: bool): ?Block
proc eth_getLogs(filter: EventFilter | Filter | FilterByBlockHash): JsonNode