Use Address type in RPC call signature
This commit is contained in:
parent
97d509571e
commit
8dd84b0622
|
@ -28,8 +28,4 @@ proc new*(_: type JsonRpcProvider, url=defaultUrl): JsonRpcProvider =
|
|||
|
||||
proc listAccounts*(provider: JsonRpcProvider): Future[seq[Address]] {.async.} =
|
||||
let client = await provider.client
|
||||
var addresses: seq[Address]
|
||||
for address in await client.eth_accounts():
|
||||
if address =? Address.init(address):
|
||||
addresses.add(address)
|
||||
return addresses
|
||||
return await client.eth_accounts()
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import std/os
|
||||
import pkg/json_rpc/rpcclient
|
||||
import ../basics
|
||||
import ./rpccalls/conversions
|
||||
|
||||
const file = currentSourcePath.parentDir / "rpccalls" / "signatures.nim"
|
||||
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
import std/json
|
||||
import ../../basics
|
||||
|
||||
func `%`*(address: Address): JsonNode =
|
||||
%($address)
|
||||
|
||||
func fromJson*(json: JsonNode, argname: string, result: var Address) =
|
||||
if address =? Address.init(json.getStr()):
|
||||
result = address
|
||||
else:
|
||||
raise newException(ValueError, "\"" & argname & "\"is not an Address")
|
|
@ -1 +1 @@
|
|||
proc eth_accounts: seq[string]
|
||||
proc eth_accounts: seq[Address]
|
||||
|
|
Loading…
Reference in New Issue