diff --git a/ethers/provider.nim b/ethers/provider.nim index 1bf2363..068439c 100644 --- a/ethers/provider.nim +++ b/ethers/provider.nim @@ -182,6 +182,9 @@ method unsubscribe*( doAssert false, "not implemented" +method isSyncing*(provider: Provider): Future[bool] {.base, async.} = + doAssert false, "not implemented" + proc replay*( provider: Provider, tx: Transaction, diff --git a/ethers/providers/jsonrpc.nim b/ethers/providers/jsonrpc.nim index 729bec5..95cca3f 100644 --- a/ethers/providers/jsonrpc.nim +++ b/ethers/providers/jsonrpc.nim @@ -268,6 +268,10 @@ method unsubscribe*( let id = subscription.id await subscriptions.unsubscribe(id) +method isSyncing*(provider: JsonRpcProvider): Future[bool] {.async.} = + let response = await provider.send("eth_syncing") + return response.getBool() + method close*( provider: JsonRpcProvider) {.async: (raises:[ProviderError]).} = diff --git a/testmodule/providers/jsonrpc/testJsonRpcProvider.nim b/testmodule/providers/jsonrpc/testJsonRpcProvider.nim index ccfc5e7..ec4fb8c 100644 --- a/testmodule/providers/jsonrpc/testJsonRpcProvider.nim +++ b/testmodule/providers/jsonrpc/testJsonRpcProvider.nim @@ -98,3 +98,8 @@ for url in ["ws://localhost:8545", "http://localhost:8545"]: discard await provider.subscribe(proc(_: Block) = discard) expect JsonRpcSignerError: discard await provider.getSigner().sendTransaction(Transaction.example) + + test "syncing": + let isSyncing = await provider.isSyncing() + check not isSyncing +