Merge pull request #47 from status-im/request-header-callback
request header callback
This commit is contained in:
commit
58b2e07830
8
web3.nim
8
web3.nim
|
@ -68,16 +68,18 @@ proc newWeb3*(provider: RpcClient): Web3 =
|
||||||
provider.setMethodHandler("eth_subscription") do(j: JsonNode):
|
provider.setMethodHandler("eth_subscription") do(j: JsonNode):
|
||||||
r.handleSubscriptionNotification(j)
|
r.handleSubscriptionNotification(j)
|
||||||
|
|
||||||
proc newWeb3*(uri: string): Future[Web3] {.async.} =
|
proc newWeb3*(
|
||||||
|
uri: string, getHeaders: GetJsonRpcRequestHeaders = nil):
|
||||||
|
Future[Web3] {.async.} =
|
||||||
let u = parseUri(uri)
|
let u = parseUri(uri)
|
||||||
var provider: RpcClient
|
var provider: RpcClient
|
||||||
case u.scheme
|
case u.scheme
|
||||||
of "http", "https":
|
of "http", "https":
|
||||||
let p = newRpcHttpClient()
|
let p = newRpcHttpClient(getHeaders = getHeaders)
|
||||||
await p.connect(uri)
|
await p.connect(uri)
|
||||||
provider = p
|
provider = p
|
||||||
of "ws", "wss":
|
of "ws", "wss":
|
||||||
let p = newRpcWebSocketClient()
|
let p = newRpcWebSocketClient(getHeaders = getHeaders)
|
||||||
await p.connect(uri)
|
await p.connect(uri)
|
||||||
provider = p
|
provider = p
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue