
commonMain.kr.jadekim.chameleon.injective.Injective.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of chameleon-injective-jvm Show documentation
Show all versions of chameleon-injective-jvm Show documentation
Crypto Wallet SDK for multiple blockchains
package kr.jadekim.chameleon.injective
import cosmos.tx.v1beta1.Tx
import kr.jadekim.chameleon.core.tool.SemaphoreProvider
import kr.jadekim.chameleon.core.type.BigDecimal
import kr.jadekim.chameleon.cosmos.tool.*
import kr.jadekim.chameleon.cosmos.tool.broadcaster.CosmosBroadcaster
import kr.jadekim.chameleon.cosmos.tool.broadcaster.SyncBroadcaster
import kr.jadekim.chameleon.injective.tool.InjectiveTransactionDirectSigner
import kr.jadekim.chameleon.injective.wallet.InjectiveWallet
import kr.jadekim.protobuf.type.ProtobufServiceClientOption
data class InjectiveOptions(
val chainId: String,
val client: CosmosClient,
val accountInfoProvider: AccountInfoProvider? = client.accountInfoProvider(),
val gasPriceProvider: CosmosGasPriceProvider? = StaticGasPriceProvider(mapOf("inj" to BigDecimal("160000000"))),
val feeEstimator: CosmosFeeEstimator? = gasPriceProvider?.let {
CosmosNodeFeeEstimator(client.transactionApi(), it)
},
val semaphoreProvider: SemaphoreProvider? = null,
val broadcaster: CosmosBroadcaster = SyncBroadcaster(
chainId,
client.transactionApi(),
feeEstimator,
accountInfoProvider?.let { InjectiveTransactionDirectSigner(it) },
semaphoreProvider?.let {
accountInfoProvider?.let {
CosmosBroadcastEventHandler(semaphoreProvider, accountInfoProvider)
}
}
),
)
class Injective(
val chainId: String,
val broadcaster: CosmosBroadcaster,
val client: CosmosClient,
) {
constructor(options: InjectiveOptions) : this(options.chainId, options.broadcaster, options.client)
fun broadcast(transaction: Tx, sender: InjectiveWallet) = broadcaster.broadcast(transaction, sender)
fun broadcast(
sender: InjectiveWallet,
buildTransaction: InjectiveTransactionBuilder.() -> Unit,
) = broadcast(InjectiveTransactionBuilder().apply(buildTransaction).build(), sender)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy