Send raw messages to the provider
This commit is contained in:
parent
8dd84b0622
commit
bd20199f87
|
@ -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()
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue