Add helper methods to parse gas, fees and gasPrice #29

Merged
nabarun merged 4 commits from deep-stack/registry-sdk:iv-update-util-method into main 2024-10-07 10:55:48 +00:00
Showing only changes of commit b5ccd8ae84 - Show all commits

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;
}
}