diff --git a/ethers/providers/jsonrpc.nim b/ethers/providers/jsonrpc.nim index 2982625..0a180d0 100644 --- a/ethers/providers/jsonrpc.nim +++ b/ethers/providers/jsonrpc.nim @@ -26,6 +26,12 @@ proc connect(_: type RpcClient, url: string): Future[RpcClient] {.async.} = proc new*(_: type JsonRpcProvider, url=defaultUrl): JsonRpcProvider = JsonRpcProvider(client: RpcClient.connect(url)) +proc send*(provider: JsonRpcProvider, + call: string, + arguments = %(@[])): Future[JsonNode] {.async.} = + let client = await provider.client + return await client.call(call, arguments) + proc listAccounts*(provider: JsonRpcProvider): Future[seq[Address]] {.async.} = let client = await provider.client return await client.eth_accounts() diff --git a/testmodule/testJsonRpcProvider.nim b/testmodule/testJsonRpcProvider.nim index 9d625de..afce486 100644 --- a/testmodule/testJsonRpcProvider.nim +++ b/testmodule/testJsonRpcProvider.nim @@ -1,3 +1,4 @@ +import std/json import pkg/asynctest import pkg/chronos import pkg/ethers/providers/jsonrpc @@ -21,3 +22,7 @@ suite "JsonRpcProvider": test "lists all accounts": let accounts = await provider.listAccounts() check accounts.len > 0 + + test "sends raw messages to the provider": + let response = await provider.send("evm_mine") + check response == %"0x0"