aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/instant/src')
-rw-r--r--packages/instant/src/components/scaling_amount_input.tsx7
-rw-r--r--packages/instant/src/types.ts2
-rw-r--r--packages/instant/src/util/maybe_big_number.ts8
3 files changed, 9 insertions, 8 deletions
diff --git a/packages/instant/src/components/scaling_amount_input.tsx b/packages/instant/src/components/scaling_amount_input.tsx
index ca8ccbe31..5dc719293 100644
--- a/packages/instant/src/components/scaling_amount_input.tsx
+++ b/packages/instant/src/components/scaling_amount_input.tsx
@@ -2,8 +2,9 @@ import { BigNumber } from '@0x/utils';
import * as _ from 'lodash';
import * as React from 'react';
+import { Maybe } from '../types';
+
import { ColorOption } from '../style/theme';
-import { MaybeBigNumber } from '../types';
import { maybeBigNumberUtil } from '../util/maybe_big_number';
import { util } from '../util/util';
@@ -35,7 +36,7 @@ export class ScalingAmountInput extends React.Component<ScalingAmountInputProps,
stringValue: _.isUndefined(props.value) ? '' : props.value.toString(),
};
}
- public componentDidUpdate(prevProps: ScalingAmountInputProps): void {
+ public componentDidUpdate(): void {
const parsedStateValue = stringToMaybeBigNumber(this.state.stringValue);
const currentValue = this.props.value;
@@ -73,7 +74,7 @@ export class ScalingAmountInput extends React.Component<ScalingAmountInputProps,
});
// Trigger onAmountChange with a valid BigNumber, or undefined if the sanitizedValue is invalid or empty
- const bigNumberValue: MaybeBigNumber = _.isEmpty(sanitizedValue)
+ const bigNumberValue: Maybe<BigNumber> = _.isEmpty(sanitizedValue)
? undefined
: stringToMaybeBigNumber(sanitizedValue);
diff --git a/packages/instant/src/types.ts b/packages/instant/src/types.ts
index 739556801..c03d269f5 100644
--- a/packages/instant/src/types.ts
+++ b/packages/instant/src/types.ts
@@ -2,7 +2,7 @@ import { AssetProxyId, ObjectMap } from '@0x/types';
import { BigNumber } from '@0x/utils';
// Reusable
-export type MaybeBigNumber = BigNumber | undefined;
+export type Maybe<T> = T | undefined;
export enum AsyncProcessState {
NONE = 'None',
PENDING = 'Pending',
diff --git a/packages/instant/src/util/maybe_big_number.ts b/packages/instant/src/util/maybe_big_number.ts
index 113ba552f..9d3746e10 100644
--- a/packages/instant/src/util/maybe_big_number.ts
+++ b/packages/instant/src/util/maybe_big_number.ts
@@ -1,12 +1,12 @@
import { BigNumber } from '@0x/utils';
import * as _ from 'lodash';
-import { MaybeBigNumber } from '../types';
+import { Maybe } from '../types';
export const maybeBigNumberUtil = {
- // converts a string to a MaybeBigNumber
+ // converts a string to a Maybe<BigNumber>
// if string is a NaN, considered undefined
- stringToMaybeBigNumber: (stringValue: string): MaybeBigNumber => {
+ stringToMaybeBigNumber: (stringValue: string): Maybe<BigNumber> => {
let validBigNumber: BigNumber;
try {
validBigNumber = new BigNumber(stringValue);
@@ -16,7 +16,7 @@ export const maybeBigNumberUtil = {
return validBigNumber.isNaN() ? undefined : validBigNumber;
},
- areMaybeBigNumbersEqual: (val1: MaybeBigNumber, val2: MaybeBigNumber): boolean => {
+ areMaybeBigNumbersEqual: (val1: Maybe<BigNumber>, val2: Maybe<BigNumber>): boolean => {
if (!_.isUndefined(val1) && !_.isUndefined(val2)) {
return val1.equals(val2);
}