aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/util
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-10-27 02:47:46 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-10-27 02:47:46 +0800
commit51da5311b54733540f44f938a0c953bb4ae42052 (patch)
treee879b72c5b02bbdef5f46bb1ecbe0016f3f3082a /packages/instant/src/util
parenta414dc9b83c14b277af90ce8397db3736a51a4d3 (diff)
downloaddexon-sol-tools-51da5311b54733540f44f938a0c953bb4ae42052.tar
dexon-sol-tools-51da5311b54733540f44f938a0c953bb4ae42052.tar.gz
dexon-sol-tools-51da5311b54733540f44f938a0c953bb4ae42052.tar.bz2
dexon-sol-tools-51da5311b54733540f44f938a0c953bb4ae42052.tar.lz
dexon-sol-tools-51da5311b54733540f44f938a0c953bb4ae42052.tar.xz
dexon-sol-tools-51da5311b54733540f44f938a0c953bb4ae42052.tar.zst
dexon-sol-tools-51da5311b54733540f44f938a0c953bb4ae42052.zip
fix: init BigNumberInput not BigNumber when initializing state
Diffstat (limited to 'packages/instant/src/util')
-rw-r--r--packages/instant/src/util/big_number_input.ts19
1 files changed, 12 insertions, 7 deletions
diff --git a/packages/instant/src/util/big_number_input.ts b/packages/instant/src/util/big_number_input.ts
index d2a9a8dc5..370d91a0a 100644
--- a/packages/instant/src/util/big_number_input.ts
+++ b/packages/instant/src/util/big_number_input.ts
@@ -10,14 +10,19 @@ import * as _ from 'lodash';
*/
export class BigNumberInput extends BigNumber {
private readonly _isEndingWithDecimal: boolean;
- constructor(bigNumberString: string) {
- const hasDecimalPeriod = _.endsWith(bigNumberString, '.');
- let internalString = bigNumberString;
- if (hasDecimalPeriod) {
- internalString = bigNumberString.slice(0, -1);
+ constructor(numberOrString: string | number) {
+ if (_.isString(numberOrString)) {
+ const hasDecimalPeriod = _.endsWith(numberOrString, '.');
+ let internalString = numberOrString;
+ if (hasDecimalPeriod) {
+ internalString = numberOrString.slice(0, -1);
+ }
+ super(internalString);
+ this._isEndingWithDecimal = hasDecimalPeriod;
+ } else {
+ super(numberOrString);
+ this._isEndingWithDecimal = false;
}
- super(internalString);
- this._isEndingWithDecimal = hasDecimalPeriod;
}
public toDisplayString(): string {
const internalString = super.toString();