All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.provenance.client.common.gas.prices.GasPrices.kt Maven / Gradle / Ivy

The newest version!
package io.provenance.client.common.gas.prices

import cosmos.base.v1beta1.CoinOuterClass
import kotlin.time.Duration
import kotlin.time.Duration.Companion.hours

typealias GasPrices = () -> CoinOuterClass.Coin

fun gasPrices(block: () -> CoinOuterClass.Coin) = block

fun GasPrices.cached(ttl: Duration = 1.hours): GasPrices = cachedGasPrice(this, ttl)

fun GasPrices.withFallback(gasPrices: GasPrices): GasPrices {
    val parent = this
    return { runCatching { parent.invoke() }.getOrDefault(gasPrices()) }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy