Skip to content

Commit a4d7cc7

Browse files
committed
Adds isSyncing to provider
1 parent fd16d71 commit a4d7cc7

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

ethers/provider.nim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ method subscribe*(provider: Provider,
157157
method unsubscribe*(subscription: Subscription) {.base, async.} =
158158
doAssert false, "not implemented"
159159

160+
method isSyncing*(provider: Provider): Future[bool] {.base, async.} =
161+
doAssert false, "not implemented"
162+
160163
proc replay*(provider: Provider, tx: Transaction, blockNumber: UInt256) {.async.} =
161164
# Replay transaction at block. Useful for fetching revert reasons, which will
162165
# be present in the raised error message. The replayed block number should

ethers/providers/jsonrpc.nim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,10 @@ method unsubscribe(subscription: JsonRpcSubscription) {.async.} =
222222
let id = subscription.id
223223
await subscriptions.unsubscribe(id)
224224

225+
method isSyncing*(provider: JsonRpcProvider): Future[bool] {.async.} =
226+
let response = await provider.send("eth_syncing")
227+
return response.getBool()
228+
225229
method close*(provider: JsonRpcProvider) {.async.} =
226230
convertError:
227231
let client = await provider.client

testmodule/providers/jsonrpc/testJsonRpcProvider.nim

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,8 @@ for url in ["ws://localhost:8545", "http://localhost:8545"]:
9999
discard await provider.subscribe(proc(_: Block) = discard)
100100
expect JsonRpcProviderError:
101101
discard await provider.getSigner().sendTransaction(Transaction.example)
102+
103+
test "syncing":
104+
let isSyncing = await provider.isSyncing()
105+
check not isSyncing
106+

0 commit comments

Comments
 (0)