Skip to content

Commit

Permalink
Merge pull request #15 from provenance-io/mwoods-figure/add-fee-grant…
Browse files Browse the repository at this point in the history
…er-to-base-req

Add feeGranter property to BaseReq
  • Loading branch information
mwoods-figure committed Jan 20, 2022
2 parents 92b8d06 + 67ab23b commit 4ca182d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
8 changes: 7 additions & 1 deletion src/main/kotlin/io/provenance/client/grpc/BaseReq.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ data class BaseReq(
val signers: List<BaseReqSigner>,
val body: TxBody,
val chainId: String,
val gasAdjustment: Double? = null
val gasAdjustment: Double? = null,
val feeGranter: String? = null
) {

fun buildAuthInfo(gasEstimate: GasEstimate = GasEstimate(0)): AuthInfo =
Expand All @@ -44,6 +45,11 @@ data class BaseReq(
)
)
.setGasLimit(gasEstimate.limit)
.also {
if (feeGranter != null) {
it.granter = feeGranter
}
}
)
.addAllSignerInfos(
signers.map {
Expand Down
12 changes: 6 additions & 6 deletions src/main/kotlin/io/provenance/client/grpc/PbClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit


data class ChannelOpts(
val inboundMessageSize: Int = 40 * 1024 * 1024, // ~ 20 MB
val idleTimeout: Pair<Long, TimeUnit> = 5L to TimeUnit.MINUTES,
Expand All @@ -32,7 +31,6 @@ class PbClient(
channelConfigLambda: (NettyChannelBuilder) -> Unit = { }
) : Closeable {


val channel = NettyChannelBuilder.forAddress(channelUri.host, channelUri.port)
.apply {
if (channelUri.scheme == "grpcs") {
Expand Down Expand Up @@ -84,6 +82,7 @@ class PbClient(
txBody: TxBody,
signers: List<BaseReqSigner>,
gasAdjustment: Double? = null,
feeGranter: String? = null,
): BaseReq =
signers.map {
BaseReqSigner(
Expand All @@ -96,7 +95,8 @@ class PbClient(
signers = it,
body = txBody,
chainId = chainId,
gasAdjustment = gasAdjustment
gasAdjustment = gasAdjustment,
feeGranter = feeGranter
)
}

Expand Down Expand Up @@ -151,10 +151,12 @@ class PbClient(
signers: List<BaseReqSigner>,
mode: ServiceOuterClass.BroadcastMode = ServiceOuterClass.BroadcastMode.BROADCAST_MODE_SYNC,
gasAdjustment: Double? = null,
feeGranter: String? = null
): ServiceOuterClass.BroadcastTxResponse = baseRequest(
txBody = txBody,
signers = signers,
gasAdjustment = gasAdjustment
gasAdjustment = gasAdjustment,
feeGranter = feeGranter
).let { baseReq -> broadcastTx(baseReq, estimateTx(baseReq), mode) }

fun getBaseAccount(bech32Address: String): Auth.BaseAccount =
Expand All @@ -166,6 +168,4 @@ class PbClient(
else -> throw IllegalArgumentException("Account type not handled:$typeUrl")
}
}

}

0 comments on commit 4ca182d

Please sign in to comment.