Skip to content

Commit dabf655

Browse files
author
Łukasz Gąsior
committed
Merge remote-tracking branch 'origin/phase/iele_testnet' into feature/faucet
2 parents 81daf1a + ad6040e commit dabf655

File tree

6 files changed

+45
-31
lines changed

6 files changed

+45
-31
lines changed

build.sbt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ scalacOptions := Seq(
9797
"-unchecked",
9898
"-deprecation",
9999
"-feature",
100+
"-Xfatal-warnings",
100101
"-Xlint:unsound-match",
101102
"-Ywarn-inaccessible",
102103
"-Ywarn-unused-import",

src/main/scala/io/iohk/ethereum/mallet/interpreter/Commands.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ object Commands {
244244
}
245245
}
246246

247-
val helpHeader = "fetch the receipt for a know transaction hash"
247+
val helpHeader = "fetch the receipt for a known transaction hash"
248248
val helpDetail =
249249
"""|Shows the receipt of a transaction given its [hash]. The transaction must be already mined on the blockchain
250250
""".stripMargin

src/main/scala/io/iohk/ethereum/mallet/main/ConstPasswordReader.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package io.iohk.ethereum.mallet.main
33
import io.iohk.ethereum.mallet.service.PasswordReader
44

55
/**
6-
* This implementation of [[PasswordReader]] is in non-interactive mode when the password is
7-
* provided as a command line option
6+
* This implementation of [[io.iohk.ethereum.mallet.service.PasswordReader PasswordReader]] is used in
7+
* non-interactive mode when the password is provided as a command line option
88
*/
99
class ConstPasswordReader(password: String) extends PasswordReader {
1010
def readPassword(): Option[String] =

src/main/scala/io/iohk/ethereum/mallet/main/Mallet.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ object Mallet extends App {
2222
private val initialState = {
2323
new State(
2424
shell,
25-
new RpcClient(clOptions.node),
25+
RpcClient(clOptions.node),
2626
new KeyStoreImpl(clOptions.dataDir, new SecureRandom()),
2727
clOptions.account,
2828
None,
@@ -35,7 +35,7 @@ object Mallet extends App {
3535
val result = Interpreter(cmd, state)
3636
shell.printLine(result.msg)
3737

38-
RpcClient.actorSystem.terminate()
38+
state.rpcClient.shutdown()
3939
val exitCode = if (result.error) 1 else 0
4040
sys.exit(exitCode)
4141
}
@@ -51,7 +51,7 @@ object Mallet extends App {
5151
loop(result.state)
5252

5353
case None =>
54-
RpcClient.actorSystem.terminate()
54+
state.rpcClient.shutdown()
5555
}
5656
}
5757

src/main/scala/io/iohk/ethereum/mallet/service/RpcClient.scala

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,41 @@ import io.iohk.ethereum.jsonrpc.{JsonRpcError, TransactionReceiptResponse}
1818
import io.iohk.ethereum.mallet.common.{Constants, Err, RpcClientError, Util}
1919

2020
import scala.concurrent.duration._
21-
import scala.concurrent.{Await, Future}
21+
import scala.concurrent.{Await, ExecutionContext, Future}
2222
import scala.util.{Failure, Success, Try}
2323

2424
object RpcClient {
25-
// TODO: CL option to enable akka logging
26-
private val akkaConfig = ConfigFactory.load("mallet")
2725

28-
implicit val actorSystem = ActorSystem("mallet_rpc", akkaConfig)
29-
implicit val materializer = ActorMaterializer()
26+
/**
27+
* This factory method is defining an ActorSystem, ActorMaterializer and ExecutionContext for
28+
* the [[RpcClient]]. To customize these dependencies use [[RpcClient]]'s constructor
29+
*/
30+
def apply(node: Uri): RpcClient = {
31+
// TODO: CL option to enable akka logging
32+
val akkaConfig = ConfigFactory.load("mallet")
33+
34+
implicit val system = ActorSystem("mallet_rpc", akkaConfig)
35+
implicit val mat = ActorMaterializer()
36+
implicit val ec = scala.concurrent.ExecutionContext.Implicits.global
37+
38+
new RpcClient(node)
39+
}
3040
}
3141

3242
/**
3343
* Talks to a node over HTTP(S) JSON-RPC
34-
* Note: the URI schema determins whether HTTP or HTTPS is used
44+
* Note: the URI schema determines whether HTTP or HTTPS is used
3545
*/
36-
class RpcClient(node: Uri) {
46+
class RpcClient(node: Uri)(implicit system: ActorSystem, mat: ActorMaterializer, ec: ExecutionContext) {
3747
import CommonJsonCodecs._
38-
import RpcClient._
39-
import actorSystem.dispatcher
40-
4148

4249
//TODO: CL option
4350
private val httpTimeout = 5.seconds
4451

52+
def shutdown(): Unit = {
53+
Await.ready(system.terminate(), 5.seconds)
54+
}
55+
4556
def sendTransaction(rawTx: ByteString): Either[Err, ByteString] =
4657
doRequest[ByteString]("eth_sendRawTransaction", List(rawTx.asJson))
4758

src/universal/conf/private-testnet.conf

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,23 @@ mantis {
4848
}
4949

5050
rpc {
51-
# JSON-RPC mode
52-
# Available modes are: http, https
53-
# Choosing https requires creating a certificate and setting up 'certificate-keystore-path' and
54-
# 'certificate-password-file'
55-
# See: https://github.com/input-output-hk/mantis/wiki/Creating-self-signed-certificate-for-using-JSON-RPC-with-HTTPS
56-
mode = "http"
57-
58-
# Listening address of JSON-RPC HTTP/HTTPS endpoint
59-
interface = ${mantis.network.server-address.interface}
60-
61-
# Listening port of JSON-RPC HTTP/HTTPS endpoint
62-
# port = 8546
63-
64-
# Domains allowed to query RPC endpoint. Use "*" to enable requests from any domain.
65-
cors-allowed-origins = "*"
51+
http {
52+
# JSON-RPC mode
53+
# Available modes are: http, https
54+
# Choosing https requires creating a certificate and setting up 'certificate-keystore-path' and
55+
# 'certificate-password-file'
56+
# See: https://github.com/input-output-hk/mantis/wiki/Creating-self-signed-certificate-for-using-JSON-RPC-with-HTTPS
57+
mode = "http"
58+
59+
# Listening address of JSON-RPC HTTP/HTTPS endpoint
60+
interface = ${mantis.network.server-address.interface}
61+
62+
# Listening port of JSON-RPC HTTP/HTTPS endpoint
63+
# port = 8546
64+
65+
# Domains allowed to query RPC endpoint. Use "*" to enable requests from any domain.
66+
cors-allowed-origins = "*"
67+
}
6668
}
6769
}
6870

0 commit comments

Comments
 (0)