chore: update bee-js to 0.8.1 version (#78)
* chore: upgrade to bee-js 0.8.1 * refactor: removed toString on number types, Token now accepts numbers * test: removed fromBZZbaseUnit test, makeBigNumber accepts number now * chore: fix logic error when displaying Cashout button
This commit is contained in:
+5
-19
@@ -1,22 +1,5 @@
|
||||
import { BigNumber } from 'bignumber.js'
|
||||
|
||||
/**
|
||||
* @deprecated Should be removed in favour of Token class
|
||||
*/
|
||||
const BZZ_BASE_UNIT = 1e16
|
||||
|
||||
/**
|
||||
* Convert from base units of BZZ token to BZZ
|
||||
* @deprecated This should only be used for displaying values, it's unsafe and should be replaced with Token class
|
||||
*
|
||||
* @param amount Amount in base units of BZZ token
|
||||
*
|
||||
* @returns amount in BZZ
|
||||
*/
|
||||
export const fromBZZbaseUnit = (amount: number): number => {
|
||||
return amount / BZZ_BASE_UNIT
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if value is an integer
|
||||
*
|
||||
@@ -37,12 +20,15 @@ export function isInteger(value: unknown): value is BigNumber | bigint {
|
||||
*
|
||||
* @returns BigNumber - but it may still be NaN or Infinite
|
||||
*/
|
||||
export function makeBigNumber(value: BigNumber | bigint | string): BigNumber | never {
|
||||
export function makeBigNumber(value: BigNumber | BigInt | number | string): BigNumber | never {
|
||||
if (BigNumber.isBigNumber(value)) return value
|
||||
|
||||
if (typeof value === 'string') return new BigNumber(value)
|
||||
|
||||
if (typeof value === 'bigint') return new BigNumber(value.toString())
|
||||
|
||||
throw new TypeError('Not a BigNumber or BigNumber convertible value')
|
||||
// FIXME: bee-js still returns some values as numbers and even outside of SAFE INTEGER bounds
|
||||
if (typeof value === 'number' /* && Number.isSafeInteger(value)*/) return new BigNumber(value)
|
||||
|
||||
throw new TypeError(`Not a BigNumber or BigNumber convertible value. Type: ${typeof value} value: ${value}`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user