Add helper methods to parse gas, fees and gasPrice #29
@ -588,4 +588,4 @@ export { LaconicClient };
|
||||
export * from './constants';
|
||||
export * from './types/cerc/bond/message';
|
||||
export * from './types/cerc/onboarding/message';
|
||||
export * from './util';
|
||||
export { getGasPrice, parseGasAndFees } from './util';
|
||||
|
13
src/util.ts
13
src/util.ts
@ -120,11 +120,12 @@ export class Util {
|
||||
|
||||
return block.cid.toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get gas in proper format
|
||||
*/
|
||||
static parseGasAndFees (gas?: string, fees?: string): StdFee | undefined | number {
|
||||
export const parseGasAndFees = (gas?: string, fees?: string): StdFee | undefined | number => {
|
||||
// If fees is not given or a number, treat it as a gas estimation multiplier
|
||||
if (fees === null || fees === undefined) {
|
||||
return undefined;
|
||||
@ -142,13 +143,11 @@ export class Util {
|
||||
amount: parseCoins(String(fees)),
|
||||
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;
|
||||
}
|
||||
}
|
||||
export const getGasPrice = (gasPrice: string | null): GasPrice | undefined => {
|
||||
return gasPrice != null ? GasPrice.fromString(String(gasPrice)) : undefined;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user