Skip to content

Commit

Permalink
fix: tx_builder warning on misconfiguration
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewWestberg committed Oct 17, 2024
1 parent 20c809d commit 4a973bc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ plugins {

allprojects {
group = "io.newm.server"
version = "0.4.2-SNAPSHOT"
version = "0.4.3-SNAPSHOT"
}

subprojects {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import kotlin.math.ceil
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.flow
import org.slf4j.LoggerFactory

/**
* A builder for cardano conway transactions.
Expand All @@ -53,7 +54,7 @@ class TransactionBuilder(
private val calculateReferenceScriptBytes: (suspend (Set<Utxo>) -> Long)? = null,
private val calculateReferenceScriptsVersions: (suspend (Set<Utxo>) -> Set<Int>)? = null,
) {
// private val log by lazy { LoggerFactory.getLogger("TransactionBuilder") }
private val log by lazy { LoggerFactory.getLogger("TransactionBuilder") }
private val secureRandom by lazy { SecureRandom() }

private val txFeeFixed by lazy {
Expand Down Expand Up @@ -460,11 +461,13 @@ class TransactionBuilder(
}

// Calculate referenceInputs fee
val referenceScriptBytes = if (!referenceInputs.isNullOrEmpty() && calculateReferenceScriptBytes != null) {
calculateReferenceScriptBytes.invoke(referenceInputs!!)
} else {
null
}
val referenceScriptBytes: Long? =
referenceInputs?.takeIf { it.isNotEmpty() }?.let { refInputs ->
calculateReferenceScriptBytes?.invoke(refInputs) ?: run {
log.warn("calculateReferenceScriptBytes is not defined, but referenceInputs exist!")
null
}
}

updateFeesAndCollateral(
cborByteSize = dummyTxCbor.size,
Expand Down

0 comments on commit 4a973bc

Please sign in to comment.