Adds isSyncing to provider (#62)

This commit is contained in:
Ben Bierens 2024-02-20 16:25:23 +01:00 committed by GitHub
parent 43500c63d7
commit e8196b3c82
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 0 deletions

View File

@ -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,

View File

@ -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]).} =

View File

@ -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