mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-22 20:42:13 +00:00
Eliminate toWei changes.
This commit is contained in:
parent
d990a76d33
commit
ba606292ab
@ -14,7 +14,7 @@ import
|
|||||||
../networking/network_metadata,
|
../networking/network_metadata,
|
||||||
web3, web3/confutils_defs, eth/keys, eth/p2p/discoveryv5/random2,
|
web3, web3/confutils_defs, eth/keys, eth/p2p/discoveryv5/random2,
|
||||||
stew/[io2, byteutils],
|
stew/[io2, byteutils],
|
||||||
../spec/[eth2_merkleization, helpers],
|
../spec/eth2_merkleization,
|
||||||
../spec/datatypes/base,
|
../spec/datatypes/base,
|
||||||
../validators/keystore_management
|
../validators/keystore_management
|
||||||
|
|
||||||
@ -136,13 +136,16 @@ proc sendEth(web3: Web3, to: Eth1Address, valueEth: int): Future[TxHash] =
|
|||||||
`from`: web3.defaultAccount,
|
`from`: web3.defaultAccount,
|
||||||
gas: Quantity(3000000).some,
|
gas: Quantity(3000000).some,
|
||||||
gasPrice: Quantity(1).some,
|
gasPrice: Quantity(1).some,
|
||||||
value: some(valueEth.toWei),
|
value: some(valueEth.u256 * 1000000000000000000.u256),
|
||||||
to: some(to))
|
to: some(to))
|
||||||
web3.send(tr)
|
web3.send(tr)
|
||||||
|
|
||||||
type
|
type
|
||||||
DelayGenerator* = proc(): chronos.Duration {.gcsafe, raises: [].}
|
DelayGenerator* = proc(): chronos.Duration {.gcsafe, raises: [].}
|
||||||
|
|
||||||
|
proc ethToWei(eth: UInt256): UInt256 =
|
||||||
|
eth * 1000000000000000000.u256
|
||||||
|
|
||||||
proc initWeb3(web3Url, privateKey: string): Future[Web3] {.async.} =
|
proc initWeb3(web3Url, privateKey: string): Future[Web3] {.async.} =
|
||||||
result = await newWeb3(web3Url)
|
result = await newWeb3(web3Url)
|
||||||
if privateKey.len != 0:
|
if privateKey.len != 0:
|
||||||
@ -177,7 +180,7 @@ proc sendDeposits*(deposits: seq[LaunchPadDeposit],
|
|||||||
SignatureBytes(@(dp.signature.toRaw())),
|
SignatureBytes(@(dp.signature.toRaw())),
|
||||||
FixedBytes[32](hash_tree_root(dp).data))
|
FixedBytes[32](hash_tree_root(dp).data))
|
||||||
|
|
||||||
let status = await tx.send(value = 32.toWei, gasPrice = gasPrice)
|
let status = await tx.send(value = 32.u256.ethToWei, gasPrice = gasPrice)
|
||||||
|
|
||||||
info "Deposit sent", tx = $status
|
info "Deposit sent", tx = $status
|
||||||
|
|
||||||
|
@ -523,9 +523,3 @@ proc blockToBlockHeader*(blck: ForkyBeaconBlock): ExecutionBlockHeader =
|
|||||||
|
|
||||||
proc compute_execution_block_hash*(blck: ForkyBeaconBlock): Eth2Digest =
|
proc compute_execution_block_hash*(blck: ForkyBeaconBlock): Eth2Digest =
|
||||||
rlpHash blockToBlockHeader(blck)
|
rlpHash blockToBlockHeader(blck)
|
||||||
|
|
||||||
func toWei*(eth: SomeInteger): UInt256 =
|
|
||||||
eth.u256 * 1000000000000000000.u256
|
|
||||||
|
|
||||||
func toWei*(eth: UInt256): UInt256 =
|
|
||||||
eth * 1000000000000000000.u256
|
|
||||||
|
@ -15,7 +15,7 @@ import
|
|||||||
../beacon_chain/conf,
|
../beacon_chain/conf,
|
||||||
../beacon_chain/el/el_manager,
|
../beacon_chain/el/el_manager,
|
||||||
../beacon_chain/networking/eth2_network,
|
../beacon_chain/networking/eth2_network,
|
||||||
../beacon_chain/spec/[eth2_merkleization, helpers],
|
../beacon_chain/spec/eth2_merkleization,
|
||||||
../beacon_chain/spec/datatypes/base,
|
../beacon_chain/spec/datatypes/base,
|
||||||
../beacon_chain/spec/eth2_apis/eth2_rest_serialization,
|
../beacon_chain/spec/eth2_apis/eth2_rest_serialization,
|
||||||
../beacon_chain/validators/keystore_management,
|
../beacon_chain/validators/keystore_management,
|
||||||
@ -518,13 +518,16 @@ proc sendEth(web3: Web3, to: Eth1Address, valueEth: int): Future[TxHash] =
|
|||||||
`from`: web3.defaultAccount,
|
`from`: web3.defaultAccount,
|
||||||
gas: Quantity(3000000).some,
|
gas: Quantity(3000000).some,
|
||||||
gasPrice: Quantity(1).some,
|
gasPrice: Quantity(1).some,
|
||||||
value: some(valueEth.toWei),
|
value: some(valueEth.u256 * 1000000000000000000.u256),
|
||||||
to: some(to))
|
to: some(to))
|
||||||
web3.send(tr)
|
web3.send(tr)
|
||||||
|
|
||||||
type
|
type
|
||||||
DelayGenerator = proc(): chronos.Duration {.gcsafe, raises: [].}
|
DelayGenerator = proc(): chronos.Duration {.gcsafe, raises: [].}
|
||||||
|
|
||||||
|
func ethToWei(eth: UInt256): UInt256 =
|
||||||
|
eth * 1000000000000000000.u256
|
||||||
|
|
||||||
proc initWeb3(web3Url, privateKey: string): Future[Web3] {.async.} =
|
proc initWeb3(web3Url, privateKey: string): Future[Web3] {.async.} =
|
||||||
result = await newWeb3(web3Url)
|
result = await newWeb3(web3Url)
|
||||||
if privateKey.len != 0:
|
if privateKey.len != 0:
|
||||||
@ -559,7 +562,7 @@ proc sendDeposits(deposits: seq[LaunchPadDeposit],
|
|||||||
SignatureBytes(@(dp.signature.toRaw())),
|
SignatureBytes(@(dp.signature.toRaw())),
|
||||||
FixedBytes[32](hash_tree_root(dp).data))
|
FixedBytes[32](hash_tree_root(dp).data))
|
||||||
|
|
||||||
let status = await tx.send(value = 32.toWei, gasPrice = gasPrice)
|
let status = await tx.send(value = 32.u256.ethToWei, gasPrice = gasPrice)
|
||||||
|
|
||||||
info "Deposit sent", tx = $status
|
info "Deposit sent", tx = $status
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user