mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-10 22:36:01 +00:00
web3 fixes suggested by @yglukhov [skip ci]
This commit is contained in:
parent
afc0686b36
commit
a1198e5532
@ -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()),
|
||||
|
Loading…
x
Reference in New Issue
Block a user