Skip to content

Commit 8f5e412

Browse files
author
Michal Mrozek
committed
[ETCM-202] PR remarks + update README
1 parent 9f20fd7 commit 8f5e412

File tree

4 files changed

+26
-9
lines changed

4 files changed

+26
-9
lines changed

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,9 @@ Possible networks: `etc`, `eth`, `mordor`, `testnet-internal`
4141
```
4242
./bin/mantis cli derive-address 00b11c32957057651d56cd83085ef3b259319057e0e887bd0fdaee657e6f75d0
4343
```
44-
- generate genesis allocs (using private keys or addresses)
44+
- generate genesis allocs (using private keys and/or addresses)
4545
```
46-
(private keys) `./bin/mantis cli generate-alloc --balance=42 00b11c32957057651d56cd83085ef3b259319057e0e887bd0fdaee657e6f75d0 00b11c32957057651d56cd83085ef3b259319057e0e887bd0fdaee657e6f75d1`
47-
(addresses) `./bin/mantis cli generate-alloc --balance=42 --useAddresses 8b196738d90cf3d9fc299e0ec28e15ebdcbb0bdcb281d9d5084182c9c66d5d12`
46+
`./bin/mantis cli generate-alloc --balance=42 --address=8b196738d90cf3d9fc299e0ec28e15ebdcbb0bdcb281d9d5084182c9c66d5d12 --key=00b11c32957057651d56cd83085ef3b259319057e0e887bd0fdaee657e6f75d1`
4847
```
4948

5049
### Building the client

src/main/scala/io/iohk/ethereum/App.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ object App extends Logger {
1818
val mallet = "mallet"
1919
val faucet = "faucet"
2020
val ecKeyGen = "eckeygen"
21-
val cli = "mantis-cli"
21+
val cli = "cli"
2222

2323
args.headOption match {
2424
case None => Mantis.main(args)

src/main/scala/io/iohk/ethereum/cli/CliCommands.scala

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package io.iohk.ethereum.cli
22

33
import cats.implicits._
4-
import cats.data.NonEmptyList
54
import com.monovore.decline.{Command, Opts}
65
import io.iohk.ethereum.crypto
76
import io.iohk.ethereum.crypto._
@@ -39,18 +38,20 @@ object CliCommands {
3938
private val GenerateAllocs: Command[String] =
4039
Command(name = generateAllocsCommand, header = "Generate genesis allocs") {
4140

42-
val keysOpt: Opts[NonEmptyList[String]] =
41+
val keysOpt: Opts[List[String]] =
4342
Opts
4443
.options[String](long = keyOption, help = "Private key")
4544
.map(_.map(key => privKeyToAddress(Hex.decode(key))))
45+
.orEmpty
4646

47-
val addressesOpt: Opts[NonEmptyList[String]] = Opts.options[String](long = addressOption, help = "Address")
47+
val addressesOpt: Opts[List[String]] =
48+
Opts.options[String](long = addressOption, help = "Address").orEmpty
4849

4950
val balanceOpt =
5051
Opts.option[BigInt](long = balanceOption, help = "Initial balance for account", metavar = "balance")
5152

52-
(keysOpt.orElse(addressesOpt), balanceOpt).mapN { (addresses, balance) =>
53-
allocs(addresses.toList, balance)
53+
(keysOpt, addressesOpt, balanceOpt).mapN { (addressesFromKeys, addresses, balance) =>
54+
allocs(addresses ++ addressesFromKeys, balance)
5455
}
5556
}
5657

src/test/scala/io/iohk/ethereum/cli/CliCommandsSpec.scala

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,21 @@ class CliCommandsSpec extends AnyFlatSpec with Matchers with EitherValues {
6565
.value shouldBe s""""alloc": {$address: { "balance": $requestedBalance }, $address2: { "balance": $requestedBalance }}"""
6666
}
6767

68+
it should "generate allocs using both keys and addresses" in {
69+
api
70+
.parse(
71+
Seq(
72+
generateAllocsCommand,
73+
argument(addressOption, Some(address)),
74+
argument(keyOption, Some(privateKey2)),
75+
argument(addressOption, Some(address3)),
76+
argument(balanceOption, Some(requestedBalance))
77+
)
78+
)
79+
.right
80+
.value shouldBe s""""alloc": {$address: { "balance": $requestedBalance }, $address3: { "balance": $requestedBalance }, $address2: { "balance": $requestedBalance }}"""
81+
}
82+
6883
}
6984

7085
object Fixture {
@@ -73,9 +88,11 @@ object Fixture {
7388

7489
val privateKey = "00b11c32957057651d56cd83085ef3b259319057e0e887bd0fdaee657e6f75d0"
7590
val privateKey2 = "00b11c32957057651d56cd83085ef3b259319057e0e887bd0fdaee657e6f75d1"
91+
val privateKey3 = "00b11c32957057651d56cd83085ef3b259319057e0e887bd0fdaee657e6f75d2"
7692

7793
val address = "8b196738d90cf3d9fc299e0ec28e15ebdcbb0bdcb281d9d5084182c9c66d5d12"
7894
val address2 = "add8c627e14480b36b30811758240d8acb282aae883043990d8a2d7e2e75cf3b"
95+
val address3 = "1e9cd60cf3b2c902e60f809e604542f9a9fb55d3e8004ff122f662f88eb32b4a"
7996

8097
val requestedBalance = 42
8198

0 commit comments

Comments
 (0)