Skip to content

Commit

Permalink
add ability to pass in chainId instead of making a rest call to get it
Browse files Browse the repository at this point in the history
log a warning if chainId isn't passed in (as it makes execution slower)
  • Loading branch information
luca992 committed Sep 30, 2022
1 parent 845acc9 commit d39bb1c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import kotlinx.serialization.json.jsonObject
open class CosmWasmClient protected constructor(
apiUrl: String,
encryptionUtils: EncryptionUtils,
broadcastMode: BroadcastMode = BroadcastMode.Block
broadcastMode: BroadcastMode = BroadcastMode.Block,
private var chainId: String? = null
) {
internal val restClient = RestClient(apiUrl, broadcastMode, encryptionUtils)

/** Any address the chain considers valid (valid bech32 with proper prefix) */
protected var anyValidAddress: String? = null
private var chainId: String? = null

suspend fun getCodeInfoByCodeId(codeId: String): CodeInfoResponse.CodeInfo =
restClient.getCodeInfoByCodeId(codeId)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.eqoty.secretk.client

import co.touchlab.kermit.Logger
import com.ionspin.kotlin.bignum.integer.toBigInteger
import io.eqoty.secretk.BroadcastMode
import io.eqoty.secretk.types.*
Expand All @@ -17,14 +18,24 @@ import okio.ByteString.Companion.decodeBase64
import okio.ByteString.Companion.decodeHex
import kotlin.math.ceil

class SigningCosmWasmClient//| OfflineSigner
class SigningCosmWasmClient
private constructor(
val apiUrl: String,
val senderAddress: String,
val wallet: Wallet,
encryptionUtils: EncryptionUtils,
broadcastMode: BroadcastMode = BroadcastMode.Block
) : CosmWasmClient(apiUrl, encryptionUtils, broadcastMode) {
broadcastMode: BroadcastMode = BroadcastMode.Block,
chainId: String? = null
) : CosmWasmClient(apiUrl, encryptionUtils, broadcastMode, chainId) {

init {
if (chainId.isNullOrBlank()) {
Logger.w(
"SigningCosmWasmClient was created without the \"chainId\" parameter. This is discouraged " +
"and will result in slower execution times for your app."
)
}
}

private fun encodePubkey(
pubkey: PubKey,
Expand Down

0 comments on commit d39bb1c

Please sign in to comment.