Skip to content

Commit

Permalink
staterecovery: resolve cyclic dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
jpnovais committed Jan 31, 2025
1 parent a5df91b commit 077ec9a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
1 change: 0 additions & 1 deletion jvm-libs/linea/core/domain-models/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ dependencies {
implementation project(":jvm-libs:generic:extensions:kotlin")
testFixturesApi "org.jetbrains.kotlinx:kotlinx-datetime:${libs.versions.kotlinxDatetime.get()}"
testFixturesApi project(":jvm-libs:linea:besu-libs")
testFixturesApi project(":jvm-libs:linea:besu-rlp-and-mappers")
}

jar {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package linea.domain

import linea.domain.MapperLineaDomainToBesu.toWei
import net.consensys.eth
import net.consensys.gwei
import net.consensys.toBigInteger
Expand All @@ -11,6 +10,7 @@ import org.hyperledger.besu.crypto.SECP256K1
import org.hyperledger.besu.crypto.SECPSignature
import org.hyperledger.besu.crypto.SignatureAlgorithm
import org.hyperledger.besu.datatypes.Address
import org.hyperledger.besu.datatypes.Wei
import java.math.BigInteger
import kotlin.random.Random

Expand Down Expand Up @@ -210,19 +210,6 @@ object TransactionFactory {
.signature
}

/**
* public BigInteger getV() {
* if (transactionType != null && transactionType != TransactionType.FRONTIER) {
* // EIP-2718 typed transaction, use yParity:
* return null;
* } else {
* final BigInteger recId = BigInteger.valueOf(signature.getRecId());
* return chainId
* .map(bigInteger -> recId.add(REPLAY_PROTECTED_V_BASE).add(TWO.multiply(bigInteger)))
* .orElseGet(() -> recId.add(REPLAY_UNPROTECTED_V_BASE));
* }
* }
*/
fun calcV(
transactionType: TransactionType,
signature: SECPSignature,
Expand All @@ -238,4 +225,16 @@ object TransactionFactory {
?: (recId + 27UL)
}
}

fun ULong.toWei(): Wei = Wei.of(this.toBigInteger())
fun BigInteger.toWei(): Wei = Wei.of(this)
fun TransactionType.toBesu(): org.hyperledger.besu.datatypes.TransactionType {
return when (this) {
linea.domain.TransactionType.FRONTIER -> org.hyperledger.besu.datatypes.TransactionType.FRONTIER
linea.domain.TransactionType.EIP1559 -> org.hyperledger.besu.datatypes.TransactionType.EIP1559
linea.domain.TransactionType.ACCESS_LIST -> org.hyperledger.besu.datatypes.TransactionType.ACCESS_LIST
linea.domain.TransactionType.BLOB -> org.hyperledger.besu.datatypes.TransactionType.BLOB
linea.domain.TransactionType.DELEGATE_CODE -> org.hyperledger.besu.datatypes.TransactionType.DELEGATE_CODE
}
}
}

0 comments on commit 077ec9a

Please sign in to comment.