Merge pull request #94 from cosmos/improve-gasLimit

Check gasLimit validity and remove pointless conversion
This commit is contained in:
Simon Warta
2023-04-12 14:23:15 +02:00
committed by GitHub
2 changed files with 8 additions and 4 deletions
+4 -2
View File
@@ -27,7 +27,9 @@ const DelegationForm = (props: Props) => {
const [_processing, setProcessing] = useState(false);
const [addressError, setAddressError] = useState("");
const createTransaction = (txValidatorAddress: string, txAmount: string, txGas: number) => {
const createTransaction = (txValidatorAddress: string, txAmount: string, gasLimit: number) => {
assert(Number.isSafeInteger(gasLimit) && gasLimit > 0, "gas limit must be a positive integer");
const amountInAtomics = Decimal.fromUserInput(
txAmount,
Number(state.chain.displayDenomExponent),
@@ -45,7 +47,7 @@ const DelegationForm = (props: Props) => {
value: msgDelegate,
};
assert(gasPrice, "gasPrice missing");
const fee = calculateFee(Number(txGas), gasPrice);
const fee = calculateFee(gasLimit, gasPrice);
const { accountOnChain } = props;
assert(accountOnChain, "accountOnChain missing");
return {
+4 -2
View File
@@ -28,7 +28,9 @@ const TransactionForm = (props: Props) => {
const [_processing, setProcessing] = useState(false);
const [addressError, setAddressError] = useState("");
const createTransaction = (txToAddress: string, txAmount: string, txGas: number) => {
const createTransaction = (txToAddress: string, txAmount: string, gasLimit: number) => {
assert(Number.isSafeInteger(gasLimit) && gasLimit > 0, "gas limit must be a positive integer");
const amountInAtomics = Decimal.fromUserInput(
txAmount,
Number(state.chain.displayDenomExponent),
@@ -48,7 +50,7 @@ const TransactionForm = (props: Props) => {
value: msgSend,
};
assert(gasPrice, "gasPrice missing");
const fee = calculateFee(Number(txGas), gasPrice);
const fee = calculateFee(gasLimit, gasPrice);
const { accountOnChain } = props;
assert(accountOnChain, "accountOnChain missing");
return {