Skip to content

Commit

Permalink
feat: Allow specifying timeout height for any transaction (#135)
Browse files Browse the repository at this point in the history
  • Loading branch information
rpatel-figure authored Dec 8, 2023
1 parent e50babb commit 6c01bd4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[versions]
kotlin = "1.8.22"
kotlin_coroutines = "1.6.4"
assetClassification = "3.8.1"
assetClassification = "3.9.0"
bouncyCastle = "1.70"
detekt = "1.18.1"
grpc = "1.51.3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ data class ProvenanceConfig(
val gasAdjustment: Double? = 1.5,
val broadcastMode: ServiceOuterClass.BroadcastMode = ServiceOuterClass.BroadcastMode.BROADCAST_MODE_BLOCK,
val feeGranter: String? = null,
val timeoutHeight: Long? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class ProvenanceService : Provenance {
sequenceOffset = offset,
)

val tx = messages.toTxBody(pbClient)
val tx = config.timeoutHeight?.let { messages.toTxBody(timeoutHeight = it) } ?: messages.toTxBody(pbClient)

val result = pbClient.estimateAndBroadcastTx(
txBody = tx,
Expand Down Expand Up @@ -123,7 +123,8 @@ class ProvenanceService : Provenance {
options = BroadcastOptions(
broadcastMode = config.broadcastMode,
sequenceOffset = offset,
baseAccount = account
baseAccount = account,
timeoutHeight = config.timeoutHeight,
)
)
}.txResponse.toTxResponse()
Expand All @@ -142,7 +143,8 @@ class ProvenanceService : Provenance {
options = BroadcastOptions(
broadcastMode = config.broadcastMode,
sequenceOffset = offset,
baseAccount = account
baseAccount = account,
timeoutHeight = config.timeoutHeight,
)
)
}.txResponse.toTxResponse()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ fun Iterable<Any>.toTxBody(pbClient: PbClient) =
.addAllMessages(this)
.build()

internal fun Iterable<Any>.toTxBody(timeoutHeight: Long): TxOuterClass.TxBody =
TxOuterClass.TxBody.newBuilder()
.setTimeoutHeight(timeoutHeight)
.addAllMessages(this)
.build()

fun Any.toTxBody(pbClient: PbClient) =
TxOuterClass.TxBody.newBuilder()
.setTimeoutHeight(getCurrentHeight(pbClient) + 12L)
Expand Down

0 comments on commit 6c01bd4

Please sign in to comment.