@quirks/core
Version:
26 lines (25 loc) • 870 B
JavaScript
import { assertIsDefined as l } from "./index8.js";
const m = async (s, c) => {
const r = await import("@cosmjs/stargate"), a = r.GasPrice ?? r.default.GasPrice;
let i;
if (s.fees && s.fees.fee_tokens.length > 0) {
let e;
e ? e = s.fees.fee_tokens.find(
(n) => n.denom === c
) : e = s.fees.fee_tokens[0];
const o = e == null ? void 0 : e.average_gas_price, t = e == null ? void 0 : e.denom;
o && t && !t.startsWith("ibc/") ? i = a.fromString(`${o}${t}`) : i = a.fromString(`1${t}`);
}
return i;
}, u = async (s, c, r, a, i, e = 1.4) => {
l(
a,
"Gas price must be set in the client options when auto gas is used."
);
const o = await s.simulate(c, r, i), t = await import("@cosmjs/stargate");
return (t.calculateFee ?? t.default.calculateFee)(Math.round(o * e), a);
};
export {
u as estimateFee,
m as getGasPrice
};