Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private onEdit(index: number) {
const t = (this.props.transactions.get(index) as Transaction);
this.props.navigation.navigate("Modify", {
editTransaction: {
index,
transaction: t,
},
isExpense: new Decimal(t.amount).isNegative(),
});
}
function createDailyTransaction(
day: moment.Moment,
incomeType: string,
income: Decimal): Transaction {
return {
amount: incomeType === "daily" ? income : new Decimal(income).div(new Decimal(day.daysInMonth())).toDecimalPlaces(2),
comment: "AUTOMATIC",
date: day.toDate().getTime(),
};
}
static fromCoins = (amount, currency) => {
currency = currency || {};
if (currency.precision === undefined)
throw new Error('A valid currency must be provided');
if (amount instanceof BigNumber)
amount = amount.toString();
amount = new Decimal(amount);
amount = amount.div(Math.pow(10, currency.precision));
return new Money(amount, currency);
};
const normalizePrice = (price, pair) => {
if (price instanceof BigNumber)
price = price.toString();
return new Decimal(price)
.div(MATCHER_SCALE)
.div(Math.pow(10, pair.priceAsset.precision - pair.amountAsset.precision));
};
onClick={e => {
let value = new Decimal(valueTrue).plus(step).valueOf()
if (isAddDisabled) {
return
}
if (step > 0) {
if (this.willReachMax) {
value = max
}
} else {
if (this.willReachMin) {
value = min
}
}
this.update(value)
}}
>
onClick={e => {
let value = new Decimal(this.getInputNumber()).minus(step).valueOf()
if (isMinusDisabled) {
return
}
if (step > 0) {
if (this.willReachMin) {
value = min
}
} else {
if (this.willReachMax) {
value = max
}
}
this.update(value)
}}
>
export const numberToString = (val1: string, val2: number): string => {
const amount = val1 ? val1 : '0'
const decimals = new Decimal(val2 ? val2 : 0)
const bigAmount = new Decimal(amount)
const bigMultiplier = new Decimal(10).pow(decimals)
return bigAmount.div(bigMultiplier).toFixed()
}
constructor(amount, currency) {
if (amount === undefined)
throw new Error('Amount is required');
if (currency === undefined)
throw new Error('Currency is required');
if (amount instanceof BigNumber)
amount = amount.toString();
this.amount = new Decimal(amount)
.toDecimalPlaces(currency.precision, Decimal.ROUND_FLOOR);
this.currency = currency;
}
totalTokens() {
const totalStaked = this.totalStakedToSelf().plus(this.totalStakedToOthers());
const totalBeingUnstaked = this.totalBeingUnstaked();
const totalTokens = this.tokens()[this.chainSymbol] || new Decimal(0);
return totalStaked.plus(totalBeingUnstaked).plus(totalTokens);
}