File tree Expand file tree Collapse file tree 2 files changed +56
-0
lines changed
src/main/scala/io/iohk/ethereum/signer Expand file tree Collapse file tree 2 files changed +56
-0
lines changed Original file line number Diff line number Diff line change 1+ package io .iohk .ethereum .signer
2+
3+ import akka .util .ByteString
4+
5+ import io .iohk .ethereum .crypto .ECDSASignature
6+ import io .iohk .ethereum .domain .Address
7+ import io .iohk .ethereum .domain .LegacyTransaction
8+ import io .iohk .ethereum .domain .SignedTransaction
9+ import io .iohk .ethereum .domain .Transaction
10+
11+ class HomesteadLegacyTransactionSigner extends TransactionSigner [LegacyTransaction ] {
12+ override def chainId : BigInt = ???
13+
14+ override def signatureFromBytes (bytes65 : ByteString ): Option [ECDSASignature ] = ???
15+
16+ override def getRAWSignature (signedTransaction : SignedTransaction ): Either [SignerError , ECDSASignature ] = ???
17+
18+ override def payloadToSign (tx : LegacyTransaction ): Either [SignerError , Array [Byte ]] = ???
19+
20+ override def calculateSender (signedTransaction : SignedTransaction ): Option [Address ] = ???
21+ }
Original file line number Diff line number Diff line change 1+ package io .iohk .ethereum .signer
2+
3+ import akka .util .ByteString
4+
5+ import io .iohk .ethereum .crypto .ECDSASignature
6+ import io .iohk .ethereum .domain .Address
7+ import io .iohk .ethereum .domain .SignedTransaction
8+ import io .iohk .ethereum .domain .Transaction
9+ import io .iohk .ethereum .utils .BlockchainConfig
10+
11+ trait TransactionSigner [T <: Transaction ] {
12+ def chainId : BigInt
13+ def signatureFromBytes (bytes65 : ByteString ): Option [ECDSASignature ]
14+ def getRAWSignature (signedTransaction : SignedTransaction ): Either [SignerError , ECDSASignature ]
15+ def payloadToSign (transaction : T ): Either [SignerError , Array [Byte ]]
16+ def calculateSender (signedTransaction : SignedTransaction ): Option [Address ]
17+ }
18+
19+ object TransactionSigner {
20+
21+ /** @param blockchainConfig
22+ * @param blockNumber
23+ * @return the proper signer corresponding to the block number
24+ */
25+ def get (blockchainConfig : BlockchainConfig , blockNumber : BigInt ): Signer =
26+ // TODO should we explicitely handle berlin fork ?
27+ if (blockNumber >= blockchainConfig.forkBlockNumbers.magnetoBlockNumber) {
28+ new EIP2930Signer (blockchainConfig.chainId)
29+ } else if (blockNumber >= blockchainConfig.forkBlockNumbers.eip155BlockNumber) {
30+ new EIP155Signer (blockchainConfig.chainId)
31+ } else {
32+ new HomesteadSigner
33+ }
34+
35+ }
You can’t perform that action at this time.
0 commit comments