web3 fixes suggested by @yglukhov [skip ci]

This commit is contained in:
Zahary Karadjov 2019-12-03 14:10:47 +02:00
parent afc0686b36
commit a1198e5532
No known key found for this signature in database
GPG Key ID: C8936F8A3073D609

View File

@ -52,19 +52,20 @@ proc generateDeposits*(totalValidators: int,
proc sendDeposits*(
deposits: seq[Deposit],
depositWeb3Url, depositContractAddress, privateKey: string) {.async.} =
var web3 = await newWeb3(depositWeb3Url)
if privateKey.len != 0:
web3.privateKey = initPrivateKey(privateKey)
let eth1Addresses = await web3.provider.eth_accounts()
if eth1Addresses.len == 0:
error "Eth1 account rejected"
return
else:
let accounts = await web3.provider.eth_accounts()
if accounts.len == 0:
error "No account offered by the web3 provider", web3url = depositWeb3Url
return
web3.defaultAccount = accounts[0]
let contractAddress = Address.fromHex(depositContractAddress)
for i, dp in deposits:
web3.defaultAccount = eth1Addresses[0]
let depositContract = web3.contractSender(DepositContract, contractAddress)
discard await depositContract.deposit(
Bytes48(dp.data.pubKey.getBytes()),