Cleanup web3 api usage

This commit is contained in:
Yuriy Glukhov 2019-07-31 12:39:46 +03:00 committed by zah
parent 8540bd0345
commit 46c9e99754
3 changed files with 7 additions and 20 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
import conf, chronos, web3, json_rpc/rpcclient, json,
import conf, chronos, web3, json,
spec/[bitfield, datatypes, digest, crypto, beaconstate, helpers, validator], extras
contract(DepositContract):
@ -32,9 +32,7 @@ proc processDeposit(d: DepositCollector, web3: Web3): Future[BeaconState] {.asyn
return s
proc getGenesisFromEth1*(conf: BeaconNodeConf): Future[BeaconState] {.async.} =
let provider = newRpcWebSocketClient()
await provider.connect(conf.depositWeb3Url)
let web3 = newWeb3(provider)
let web3 = await newWeb3(conf.depositWeb3Url)
var contractAddress = Address.fromHex(conf.depositContractAddress)
var defaultAccount: Address

View File

@ -1,11 +1,9 @@
import
os, ospaths, strutils, strformat,
os, ospaths, strutils, strformat, json,
chronos, blscurve, nimcrypto, json_serialization, confutils, web3, stint,
spec/[datatypes, digest, crypto], conf, time, ssz,
../tests/testutil
import json_rpc/rpcclient
contract(DepositContract):
proc deposit(pubkey: Bytes48, withdrawalCredentials: Bytes32, signature: Bytes96)
@ -21,17 +19,13 @@ proc writeFile(filename: string, value: auto) =
proc ethToWei(eth: UInt256): UInt256 =
eth * 1000000000000000000.u256
import web3/stintjson, json
proc main(totalValidators: int, outputDir: string, generateFakeKeys: bool, depositWeb3Url, depositContractAddress: string) {.async.} =
var web3: Web3
var contractAddress: Address
var eth1Addresses: seq[Address]
if depositWeb3Url.len > 0:
let provider = newRpcWebSocketClient()
await provider.connect(depositWeb3Url)
web3 = newWeb3(provider)
web3 = await newWeb3(depositWeb3Url)
contractAddress = Address.fromHex(depositContractAddress)
eth1Addresses = await web3.provider.eth_accounts()