Files
TheGame/packages/utils/src/numbers.ts
Pacien Boisson d094e1c4ba Quest create handlers (#340)
* create quest handler

* Updating action schema and removing backend-only insert permissions

* Better handle auth bearer token

* Basic tests for creating quests

* Check if player has > 100 pSEED to allow creating a quest

* move quests actions into its own router

* create quest completion

* updateCompletion handler

* update types

* Improving handler input types

* Improve types and logic

* Removing types file and using autogenerated ones

* Reject other submissions when accepting a unique quest completion

* Fix linting errors

* Fix CreateQuestCompletionInput maybe

* error messages

* Puttin pSEED contractnaddress in config file

Co-authored-by: Hammad Jutt <jutt@ualberta.ca>
2021-02-22 12:58:31 +04:00

25 lines
552 B
TypeScript

import BN from 'bignumber.js';
export { BN };
export function amountToInt(amount: string, decimals: number): string {
return new BN(amount)
.times(10 ** decimals)
.dp(0)
.toFixed();
}
export function amountToDecimal(amount: string, decimals: number): string {
return new BN(amount).div(10 ** decimals).toFixed();
}
export function truncateNumber(
n: string,
sd: number = SIGNIFICANT_DIGITS,
roundingMode?: BN.RoundingMode,
): string {
return new BN(n).sd(sd, roundingMode).toFixed();
}
export const SIGNIFICANT_DIGITS = 7;