Skip to content

Commit

Permalink
Merge pull request #23 from provenance-io/afremuth/undo-type-change
Browse files Browse the repository at this point in the history
undo type change to maintain compatability with pbc 1.7.x based versions
  • Loading branch information
afremuth-figure committed Feb 16, 2022
2 parents 8882685 + 88b0c09 commit 2d5531f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/main/kotlin/io/provenance/client/grpc/BaseReq.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ data class BaseReq(
val signers: List<BaseReqSigner>,
val body: TxBody,
val chainId: String,
val gasAdjustment: Float? = null,
val gasAdjustment: Double? = null,
val feeGranter: String? = null
) {

Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/io/provenance/client/grpc/GasEstimate.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ import cosmos.base.v1beta1.CoinOuterClass
data class GasEstimate(val limit: Long, val feesCalculated: List<CoinOuterClass.Coin> = emptyList()) {

companion object {
const val DEFAULT_FEE_ADJUSTMENT = 1.25f
const val DEFAULT_FEE_ADJUSTMENT = 1.25
}
}
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 @@ -87,7 +87,7 @@ open class PbClient(
fun baseRequest(
txBody: TxBody,
signers: List<BaseReqSigner>,
gasAdjustment: Float? = null,
gasAdjustment: Double? = null,
feeGranter: String? = null,
): BaseReq =
signers.map {
Expand Down Expand Up @@ -121,7 +121,7 @@ open class PbClient(
val msgFee = msgFeeClient.calculateTxFees(
CalculateTxFeesRequest.newBuilder()
.setTxBytes(txFinal.toByteString())
.setGasAdjustment(baseReq.gasAdjustment ?: GasEstimate.DEFAULT_FEE_ADJUSTMENT)
.setGasAdjustment((baseReq.gasAdjustment ?: GasEstimate.DEFAULT_FEE_ADJUSTMENT).toFloat())
.build()
)
GasEstimate(
Expand Down Expand Up @@ -159,7 +159,7 @@ open class PbClient(
txBody: TxBody,
signers: List<BaseReqSigner>,
mode: ServiceOuterClass.BroadcastMode = ServiceOuterClass.BroadcastMode.BROADCAST_MODE_SYNC,
gasAdjustment: Float? = null,
gasAdjustment: Double? = null,
feeGranter: String? = null
): ServiceOuterClass.BroadcastTxResponse = baseRequest(
txBody = txBody,
Expand Down Expand Up @@ -190,14 +190,14 @@ open class PbClient(
.setDenom("nhash")
.build()
).build()
val response = estimateAndBroadcastTx(submitProposal.toAny().toTxBody(), listOf(BaseReqSigner(walletSigner)), gasAdjustment = 1.5f)
val response = estimateAndBroadcastTx(submitProposal.toAny().toTxBody(), listOf(BaseReqSigner(walletSigner)), gasAdjustment = 1.5)
return response
}

fun voteOnProposal(walletSigner: WalletSigner, proposalId: Long): ServiceOuterClass.BroadcastTxResponse {
val vote = cosmos.gov.v1beta1.Tx.MsgVote.newBuilder().setProposalId(proposalId).setVoter(walletSigner.address())
.setOption(Gov.VoteOption.VOTE_OPTION_YES).build()
val response = estimateAndBroadcastTx(vote.toAny().toTxBody(), listOf(BaseReqSigner(walletSigner)), gasAdjustment = 1.5f)
val response = estimateAndBroadcastTx(vote.toAny().toTxBody(), listOf(BaseReqSigner(walletSigner)), gasAdjustment = 1.5)
return response
}

Expand All @@ -213,7 +213,7 @@ open class PbClient(
.setSender(walletSigner.address())
.setWasmByteCode(wasmContract)
.build().toAny().toTxBody(),
listOf(BaseReqSigner(walletSigner)), gasAdjustment = 1.5f, mode = ServiceOuterClass.BroadcastMode.BROADCAST_MODE_BLOCK
listOf(BaseReqSigner(walletSigner)), gasAdjustment = 1.5, mode = ServiceOuterClass.BroadcastMode.BROADCAST_MODE_BLOCK
)
}
}
8 changes: 4 additions & 4 deletions src/test/kotlin/io/provenance/client/PbClientTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class PbClientTest {
val baseRequest = pbClient.baseRequest(
txBody = txn,
signers = listOf(BaseReqSigner(wallet)),
1.5f
1.5
)
val estimate: GasEstimate = pbClient.estimateTx(baseRequest)

Expand All @@ -97,7 +97,7 @@ class PbClientTest {
val estimatedGwei = estimate.feesCalculated.firstOrNull { it.denom == "gwei" }
assertNotNull(estimatedGwei, "estimated gwei cannot be null")

val res = pbClient.estimateAndBroadcastTx(txn, listOf(BaseReqSigner(wallet)), gasAdjustment = 1.5f)
val res = pbClient.estimateAndBroadcastTx(txn, listOf(BaseReqSigner(wallet)), gasAdjustment = 1.5)
assertTrue(
res.txResponse.code == 0,
"Did not succeed."
Expand Down Expand Up @@ -143,7 +143,7 @@ class PbClientTest {
val baseRequest = pbClient.baseRequest(
txBody = listOf(txn, txn2).toTxBody(),
signers = listOf(BaseReqSigner(wallet)),
1.5f
1.5
)
val estimate: GasEstimate = pbClient.estimateTx(baseRequest)

Expand All @@ -153,7 +153,7 @@ class PbClientTest {
val estimatedGwei = estimate.feesCalculated.firstOrNull { it.denom == "gwei" }
assertNotNull(estimatedGwei, "estimated gwei cannot be null")

val res = pbClient.estimateAndBroadcastTx(listOf(txn, txn2).toTxBody(), listOf(BaseReqSigner(wallet)), gasAdjustment = 1.5f)
val res = pbClient.estimateAndBroadcastTx(listOf(txn, txn2).toTxBody(), listOf(BaseReqSigner(wallet)), gasAdjustment = 1.5)
assertTrue(
res.txResponse.code == 0,
"Did not succeed."
Expand Down

0 comments on commit 2d5531f

Please sign in to comment.