Use calculateFee from @cosmjs/stargate

This commit is contained in:
Simon Warta
2022-01-10 16:38:04 +01:00
parent 5950833352
commit 1fa2f1e755
+1 -13
View File
@@ -6,19 +6,7 @@ import { withRouter } from "next/router";
import Button from "../../components/inputs/Button";
import Input from "../../components/inputs/Input";
import StackableContainer from "../layout/StackableContainer";
import { GasPrice } from "@cosmjs/stargate";
import { Uint53 } from "@cosmjs/math";
// TODO: use `calculateFee` from @cosmjs/stargate after upgrading CosmJS to 0.26+
function calculateFee(gasLimit, gasPrice) {
const processedGasPrice = typeof gasPrice === "string" ? GasPrice.fromString(gasPrice) : gasPrice;
const { denom, amount: gasPriceAmount } = processedGasPrice;
const amount = Math.ceil(gasPriceAmount.multiply(new Uint53(gasLimit)).toFloatApproximation());
return {
amount: coins(amount, denom),
gas: gasLimit.toString(),
};
}
import { calculateFee } from "@cosmjs/stargate";
class TransactionForm extends React.Component {
constructor(props) {