Skip to content

Commit

Permalink
fix: add chainId when manually filling unsigned tx
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtificialPB committed Oct 16, 2024
1 parent d40edd2 commit ab516a6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ethers-core/src/main/kotlin/io/ethers/core/types/CallRequest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.JsonSerializer
import com.fasterxml.jackson.databind.SerializerProvider
import com.fasterxml.jackson.databind.annotation.JsonSerialize
import io.ethers.core.FastHex
import io.ethers.core.types.transaction.ChainId
import io.ethers.core.types.transaction.TransactionUnsigned
import io.ethers.core.types.transaction.TxAccessList
import io.ethers.core.types.transaction.TxBlob
Expand Down Expand Up @@ -117,7 +118,7 @@ class CallRequest() : IntoCallRequest {

when {
gasFeeCap != null && gasTipCap != null && blobVersionedHashes != null -> {
if (to == null || blobFeeCap == null) {
if (to == null || blobFeeCap == null || !ChainId.isValid(chainId)) {
return null
}

Expand All @@ -137,6 +138,10 @@ class CallRequest() : IntoCallRequest {
}

gasFeeCap != null && gasTipCap != null && blobVersionedHashes == null -> {
if (!ChainId.isValid(chainId)) {
return null
}

return TxDynamicFee(
to = to,
value = value ?: BigInteger.ZERO,
Expand All @@ -151,6 +156,10 @@ class CallRequest() : IntoCallRequest {
}

gasPrice != null && accessList.isNotEmpty() -> {
if (!ChainId.isValid(chainId)) {
return null
}

return TxAccessList(
to = to,
value = value ?: BigInteger.ZERO,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,9 @@ class Provider(override val client: JsonRpcClient, override val chainId: Long) :

private fun manuallyFillTransaction(original: CallRequest): Result<TransactionUnsigned, RpcError> {
val call = CallRequest(original)
if (call.chainId == -1L) {
call.chainId = provider.chainId
}

var unsigned = call.toUnsignedTransactionOrNull()
if (unsigned != null) {
Expand Down

0 comments on commit ab516a6

Please sign in to comment.