Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feeGranter property to BaseReq #15

Merged
merged 1 commit into from
Jan 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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")
}
}

}