Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
mounted() {
this.upadteAllState();
this.gasPrice = units.fromQa(
new BN(this.CONFIRM_TX.gasPrice),
units.Units.Li
).toString();
this.gasLimit = this.CONFIRM_TX.gasLimit;
}
}
export const formatSendAmountInZil = (
amountInZil: string,
balanceInZil: string,
minGasPriceInZil: string
): string => {
const amountInQaBN: BN = units.toQa(amountInZil, units.Units.Zil);
const balanceInQaBN: BN = units.toQa(balanceInZil, units.Units.Zil);
const minGasPriceInQaBN: BN = units.toQa(minGasPriceInZil, units.Units.Zil);
const maxAmountInQaBN = balanceInQaBN.sub(minGasPriceInQaBN);
if (amountInQaBN.lte(minGasPriceInQaBN)) {
return units.fromQa(minGasPriceInQaBN, units.Units.Zil).toString();
} else if (amountInQaBN.gt(maxAmountInQaBN)) {
return units.fromQa(maxAmountInQaBN, units.Units.Zil).toString();
} else {
return units.fromQa(amountInQaBN, units.Units.Zil).toString();
}
};