Add method to get gas price in util

This commit is contained in:
IshaVenikar 2024-10-04 14:21:22 +05:30
parent 186d9b9b2e
commit b5ccd8ae84

View File

@ -2,7 +2,7 @@ import * as Block from 'multiformats/block';
import { sha256 as hasher } from 'multiformats/hashes/sha2';
import assert from 'assert';
import { StdFee, parseCoins } from '@cosmjs/stargate';
import { GasPrice, StdFee, parseCoins } from '@cosmjs/stargate';
import * as dagCBOR from '@ipld/dag-cbor';
import * as dagJSON from '@ipld/dag-json';
@ -143,4 +143,12 @@ export class Util {
gas: String(gas)
};
}
/**
* Get gas price in proper format
*/
static getGasPrice (gasPrice: string | null): GasPrice | undefined {
const gasPriceString = gasPrice;
return gasPriceString != null ? GasPrice.fromString(String(gasPriceString)) : undefined;
}
}