mirror of
https://github.com/MetaFam/TheGame.git
synced 2026-01-24 13:47:57 -05:00
* 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>
25 lines
552 B
TypeScript
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;
|