Skip to content

Commit

Permalink
Allow Numeric type for decimals in FixedNumber (#4141).
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed Jun 13, 2023
1 parent 026c5bb commit 9055ef6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src.ts/utils/fixednumber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
import { getBytes } from "./data.js";
import { assert, assertArgument, assertPrivate } from "./errors.js";
import {
getBigInt, fromTwos, mask, toBigInt
getBigInt, getNumber, fromTwos, mask, toBigInt
} from "./maths.js";
import { defineProperties } from "./properties.js";

import type { BigNumberish, BytesLike } from "./index.js";
import type { BigNumberish, BytesLike, Numeric } from "./index.js";

const BN_N1 = BigInt(-1);
const BN_0 = BigInt(0);
Expand Down Expand Up @@ -565,8 +565,8 @@ export class FixedNumber {
* for %%decimals%%) cannot fit in %%format%%, either due to overflow
* or underflow (precision loss).
*/
static fromValue(_value: BigNumberish, decimals?: number, _format?: FixedFormat): FixedNumber {
if (decimals == null) { decimals = 0; }
static fromValue(_value: BigNumberish, _decimals?: Numeric, _format?: FixedFormat): FixedNumber {
const decimals = (_decimals == null) ? 0: getNumber(_decimals);
const format = getFormat(_format);

let value = getBigInt(_value, "value");
Expand Down

0 comments on commit 9055ef6

Please # to comment.