aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/components/inputs
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2017-12-22 04:24:54 +0800
committerFabio Berger <me@fabioberger.com>2017-12-22 04:24:54 +0800
commite01c0f054d2dbb043aec8b4cb8e1c47f83bd5eb9 (patch)
tree241b630db5044974cc17130f149ca64728d9c619 /packages/website/ts/components/inputs
parentd725de72861c6a6218c7f4822a339175a2da7403 (diff)
parentcb3582289ff94857d5956bbd71dbf68ee3f42ecf (diff)
downloaddexon-sol-tools-e01c0f054d2dbb043aec8b4cb8e1c47f83bd5eb9.tar.gz
dexon-sol-tools-e01c0f054d2dbb043aec8b4cb8e1c47f83bd5eb9.tar.zst
dexon-sol-tools-e01c0f054d2dbb043aec8b4cb8e1c47f83bd5eb9.zip
Merge branch 'development' into fix/docLinks
* development: Update and standardize contracts README Add to CHANGELOG Refactor toBaseUnitAmount so that it throws if user supplies unitAmount with too many decimals Make assertion stricter so that one cannot submit invalid baseUnit amounts to `toUnitAmount` Add some missed underscores, update changelog and comments Add new underscore-privates rule to @0xproject/tslint-config and fix lint errors # Conflicts: # packages/website/ts/pages/documentation/documentation.tsx # packages/website/ts/pages/shared/nested_sidebar_menu.tsx
Diffstat (limited to 'packages/website/ts/components/inputs')
-rw-r--r--packages/website/ts/components/inputs/address_input.tsx4
-rw-r--r--packages/website/ts/components/inputs/allowance_toggle.tsx10
-rw-r--r--packages/website/ts/components/inputs/balance_bounded_input.tsx18
-rw-r--r--packages/website/ts/components/inputs/eth_amount_input.tsx4
-rw-r--r--packages/website/ts/components/inputs/expiration_input.tsx22
-rw-r--r--packages/website/ts/components/inputs/hash_input.tsx4
-rw-r--r--packages/website/ts/components/inputs/identicon_address_input.tsx4
-rw-r--r--packages/website/ts/components/inputs/token_amount_input.tsx8
-rw-r--r--packages/website/ts/components/inputs/token_input.tsx14
9 files changed, 44 insertions, 44 deletions
diff --git a/packages/website/ts/components/inputs/address_input.tsx b/packages/website/ts/components/inputs/address_input.tsx
index a17b6e3f5..343eecc42 100644
--- a/packages/website/ts/components/inputs/address_input.tsx
+++ b/packages/website/ts/components/inputs/address_input.tsx
@@ -54,12 +54,12 @@ export class AddressInput extends React.Component<AddressInputProps, AddressInpu
floatingLabelText={label}
errorText={this.state.errMsg}
value={this.state.address}
- onChange={this.onOrderTakerAddressUpdated.bind(this)}
+ onChange={this._onOrderTakerAddressUpdated.bind(this)}
/>
</div>
);
}
- private onOrderTakerAddressUpdated(e: any) {
+ private _onOrderTakerAddressUpdated(e: any) {
const address = e.target.value.toLowerCase();
const isValidAddress = addressUtils.isAddress(address) || address === '';
const errMsg = isValidAddress ? '' : 'Invalid ethereum address';
diff --git a/packages/website/ts/components/inputs/allowance_toggle.tsx b/packages/website/ts/components/inputs/allowance_toggle.tsx
index 1c39a37d7..2404a1e31 100644
--- a/packages/website/ts/components/inputs/allowance_toggle.tsx
+++ b/packages/website/ts/components/inputs/allowance_toggle.tsx
@@ -46,8 +46,8 @@ export class AllowanceToggle extends React.Component<AllowanceToggleProps, Allow
<div>
<Toggle
disabled={this.state.isSpinnerVisible}
- toggled={this.isAllowanceSet()}
- onToggle={this.onToggleAllowanceAsync.bind(this, this.props.token)}
+ toggled={this._isAllowanceSet()}
+ onToggle={this._onToggleAllowanceAsync.bind(this, this.props.token)}
/>
</div>
{this.state.isSpinnerVisible &&
@@ -58,7 +58,7 @@ export class AllowanceToggle extends React.Component<AllowanceToggleProps, Allow
</div>
);
}
- private async onToggleAllowanceAsync() {
+ private async _onToggleAllowanceAsync() {
if (this.props.userAddress === '') {
this.props.dispatcher.updateShouldBlockchainErrDialogBeOpen(true);
return false;
@@ -69,7 +69,7 @@ export class AllowanceToggle extends React.Component<AllowanceToggleProps, Allow
});
let newAllowanceAmountInBaseUnits = new BigNumber(0);
- if (!this.isAllowanceSet()) {
+ if (!this._isAllowanceSet()) {
newAllowanceAmountInBaseUnits = DEFAULT_ALLOWANCE_AMOUNT_IN_BASE_UNITS;
}
try {
@@ -88,7 +88,7 @@ export class AllowanceToggle extends React.Component<AllowanceToggleProps, Allow
await errorReporter.reportAsync(err);
}
}
- private isAllowanceSet() {
+ private _isAllowanceSet() {
return !this.props.tokenState.allowance.eq(0);
}
}
diff --git a/packages/website/ts/components/inputs/balance_bounded_input.tsx b/packages/website/ts/components/inputs/balance_bounded_input.tsx
index 61ab34f25..91cc36e0c 100644
--- a/packages/website/ts/components/inputs/balance_bounded_input.tsx
+++ b/packages/website/ts/components/inputs/balance_bounded_input.tsx
@@ -35,7 +35,7 @@ export class BalanceBoundedInput extends
super(props);
const amountString = this.props.amount ? this.props.amount.toString() : '';
this.state = {
- errMsg: this.validate(amountString, props.balance),
+ errMsg: this._validate(amountString, props.balance),
amountString,
};
}
@@ -57,14 +57,14 @@ export class BalanceBoundedInput extends
if (shouldResetState) {
const amountString = nextProps.amount.toString();
this.setState({
- errMsg: this.validate(amountString, nextProps.balance),
+ errMsg: this._validate(amountString, nextProps.balance),
amountString,
});
}
} else if (isCurrentAmountNumeric) {
const amountString = '';
this.setState({
- errMsg: this.validate(amountString, nextProps.balance),
+ errMsg: this._validate(amountString, nextProps.balance),
amountString,
});
}
@@ -87,13 +87,13 @@ export class BalanceBoundedInput extends
errorText={errorText}
value={this.state.amountString}
hintText={<span style={{textTransform: 'capitalize'}}>amount</span>}
- onChange={this.onValueChange.bind(this)}
+ onChange={this._onValueChange.bind(this)}
underlineStyle={{width: 'calc(100% + 50px)'}}
/>
);
}
- private onValueChange(e: any, amountString: string) {
- const errMsg = this.validate(amountString, this.props.balance);
+ private _onValueChange(e: any, amountString: string) {
+ const errMsg = this._validate(amountString, this.props.balance);
this.setState({
amountString,
errMsg,
@@ -106,7 +106,7 @@ export class BalanceBoundedInput extends
}
});
}
- private validate(amountString: string, balance: BigNumber): InputErrMsg {
+ private _validate(amountString: string, balance: BigNumber): InputErrMsg {
if (!utils.isNumeric(amountString)) {
return amountString !== '' ? 'Must be a number' : '';
}
@@ -118,14 +118,14 @@ export class BalanceBoundedInput extends
return (
<span>
Insufficient balance.{' '}
- {this.renderIncreaseBalanceLink()}
+ {this._renderIncreaseBalanceLink()}
</span>
);
}
const errMsg = _.isUndefined(this.props.validate) ? undefined : this.props.validate(amount);
return errMsg;
}
- private renderIncreaseBalanceLink() {
+ private _renderIncreaseBalanceLink() {
if (this.props.shouldHideVisitBalancesLink) {
return null;
}
diff --git a/packages/website/ts/components/inputs/eth_amount_input.tsx b/packages/website/ts/components/inputs/eth_amount_input.tsx
index 3dcd2b4f3..da5bc9805 100644
--- a/packages/website/ts/components/inputs/eth_amount_input.tsx
+++ b/packages/website/ts/components/inputs/eth_amount_input.tsx
@@ -30,7 +30,7 @@ export class EthAmountInput extends React.Component<EthAmountInputProps, EthAmou
label={this.props.label}
balance={this.props.balance}
amount={amount}
- onChange={this.onChange.bind(this)}
+ onChange={this._onChange.bind(this)}
shouldCheckBalance={this.props.shouldCheckBalance}
shouldShowIncompleteErrs={this.props.shouldShowIncompleteErrs}
onVisitBalancesPageClick={this.props.onVisitBalancesPageClick}
@@ -42,7 +42,7 @@ export class EthAmountInput extends React.Component<EthAmountInputProps, EthAmou
</div>
);
}
- private onChange(isValid: boolean, amount?: BigNumber) {
+ private _onChange(isValid: boolean, amount?: BigNumber) {
const baseUnitAmountIfExists = _.isUndefined(amount) ?
undefined :
ZeroEx.toBaseUnitAmount(amount, constants.DECIMAL_PLACES_ETH);
diff --git a/packages/website/ts/components/inputs/expiration_input.tsx b/packages/website/ts/components/inputs/expiration_input.tsx
index d3d3d258d..fe471e39b 100644
--- a/packages/website/ts/components/inputs/expiration_input.tsx
+++ b/packages/website/ts/components/inputs/expiration_input.tsx
@@ -17,11 +17,11 @@ interface ExpirationInputState {
}
export class ExpirationInput extends React.Component<ExpirationInputProps, ExpirationInputState> {
- private earliestPickableMoment: moment.Moment;
+ private _earliestPickableMoment: moment.Moment;
constructor(props: ExpirationInputProps) {
super(props);
// Set the earliest pickable date to today at 00:00, so users can only pick the current or later dates
- this.earliestPickableMoment = moment().startOf('day');
+ this._earliestPickableMoment = moment().startOf('day');
const expirationMoment = utils.convertToMomentFromUnixTimestamp(props.orderExpiryTimestamp);
const initialOrderExpiryTimestamp = utils.initialOrderExpiryUnixTimestampSec();
const didUserSetExpiry = !initialOrderExpiryTimestamp.eq(props.orderExpiryTimestamp);
@@ -42,8 +42,8 @@ export class ExpirationInput extends React.Component<ExpirationInputProps, Expir
mode="landscape"
autoOk={true}
value={date}
- onChange={this.onDateChanged.bind(this)}
- shouldDisableDate={this.shouldDisableDate.bind(this)}
+ onChange={this._onDateChanged.bind(this)}
+ shouldDisableDate={this._shouldDisableDate.bind(this)}
/>
<div
className="absolute"
@@ -58,7 +58,7 @@ export class ExpirationInput extends React.Component<ExpirationInputProps, Expir
hintText="Time"
autoOk={true}
value={time}
- onChange={this.onTimeChanged.bind(this)}
+ onChange={this._onTimeChanged.bind(this)}
/>
<div
className="absolute"
@@ -68,7 +68,7 @@ export class ExpirationInput extends React.Component<ExpirationInputProps, Expir
</div>
</div>
<div
- onClick={this.clearDates.bind(this)}
+ onClick={this._clearDates.bind(this)}
className="col col-1 pt2"
style={{textAlign: 'right'}}
>
@@ -77,10 +77,10 @@ export class ExpirationInput extends React.Component<ExpirationInputProps, Expir
</div>
);
}
- private shouldDisableDate(date: Date): boolean {
- return moment(date).startOf('day').isBefore(this.earliestPickableMoment);
+ private _shouldDisableDate(date: Date): boolean {
+ return moment(date).startOf('day').isBefore(this._earliestPickableMoment);
}
- private clearDates() {
+ private _clearDates() {
this.setState({
dateMoment: undefined,
timeMoment: undefined,
@@ -88,7 +88,7 @@ export class ExpirationInput extends React.Component<ExpirationInputProps, Expir
const defaultDateTime = utils.initialOrderExpiryUnixTimestampSec();
this.props.updateOrderExpiry(defaultDateTime);
}
- private onDateChanged(e: any, date: Date) {
+ private _onDateChanged(e: any, date: Date) {
const dateMoment = moment(date);
this.setState({
dateMoment,
@@ -96,7 +96,7 @@ export class ExpirationInput extends React.Component<ExpirationInputProps, Expir
const timestamp = utils.convertToUnixTimestampSeconds(dateMoment, this.state.timeMoment);
this.props.updateOrderExpiry(timestamp);
}
- private onTimeChanged(e: any, time: Date) {
+ private _onTimeChanged(e: any, time: Date) {
const timeMoment = moment(time);
this.setState({
timeMoment,
diff --git a/packages/website/ts/components/inputs/hash_input.tsx b/packages/website/ts/components/inputs/hash_input.tsx
index 25e7b5009..4dc96a062 100644
--- a/packages/website/ts/components/inputs/hash_input.tsx
+++ b/packages/website/ts/components/inputs/hash_input.tsx
@@ -27,7 +27,7 @@ interface HashInputState {}
export class HashInput extends React.Component<HashInputProps, HashInputState> {
public render() {
- const msgHashHex = this.props.blockchainIsLoaded ? this.generateMessageHashHex() : '';
+ const msgHashHex = this.props.blockchainIsLoaded ? this._generateMessageHashHex() : '';
return (
<div>
<FakeTextField label={this.props.label}>
@@ -43,7 +43,7 @@ export class HashInput extends React.Component<HashInputProps, HashInputState> {
</div>
);
}
- private generateMessageHashHex() {
+ private _generateMessageHashHex() {
const exchangeContractAddress = this.props.blockchain.getExchangeContractAddressIfExists();
const hashData = this.props.hashData;
const order: Order = {
diff --git a/packages/website/ts/components/inputs/identicon_address_input.tsx b/packages/website/ts/components/inputs/identicon_address_input.tsx
index 9e4bc58ea..0f220f955 100644
--- a/packages/website/ts/components/inputs/identicon_address_input.tsx
+++ b/packages/website/ts/components/inputs/identicon_address_input.tsx
@@ -38,14 +38,14 @@ export class IdenticonAddressInput extends React.Component<IdenticonAddressInput
hintText="e.g 0x75bE4F78AA3699B3A348c84bDB2a96c3Db..."
shouldHideLabel={true}
initialAddress={this.props.initialAddress}
- updateAddress={this.updateAddress.bind(this)}
+ updateAddress={this._updateAddress.bind(this)}
/>
</div>
</div>
</div>
);
}
- private updateAddress(address?: string): void {
+ private _updateAddress(address?: string): void {
this.setState({
address,
});
diff --git a/packages/website/ts/components/inputs/token_amount_input.tsx b/packages/website/ts/components/inputs/token_amount_input.tsx
index c9728dc5f..84117e843 100644
--- a/packages/website/ts/components/inputs/token_amount_input.tsx
+++ b/packages/website/ts/components/inputs/token_amount_input.tsx
@@ -33,8 +33,8 @@ export class TokenAmountInput extends React.Component<TokenAmountInputProps, Tok
label={this.props.label}
amount={amount}
balance={ZeroEx.toUnitAmount(this.props.tokenState.balance, this.props.token.decimals)}
- onChange={this.onChange.bind(this)}
- validate={this.validate.bind(this)}
+ onChange={this._onChange.bind(this)}
+ validate={this._validate.bind(this)}
shouldCheckBalance={this.props.shouldCheckBalance}
shouldShowIncompleteErrs={this.props.shouldShowIncompleteErrs}
onVisitBalancesPageClick={this.props.onVisitBalancesPageClick}
@@ -45,14 +45,14 @@ export class TokenAmountInput extends React.Component<TokenAmountInputProps, Tok
</div>
);
}
- private onChange(isValid: boolean, amount?: BigNumber) {
+ private _onChange(isValid: boolean, amount?: BigNumber) {
let baseUnitAmount;
if (!_.isUndefined(amount)) {
baseUnitAmount = ZeroEx.toBaseUnitAmount(amount, this.props.token.decimals);
}
this.props.onChange(isValid, baseUnitAmount);
}
- private validate(amount: BigNumber): InputErrMsg {
+ private _validate(amount: BigNumber): InputErrMsg {
if (this.props.shouldCheckAllowance && amount.gt(this.props.tokenState.allowance)) {
return (
<span>
diff --git a/packages/website/ts/components/inputs/token_input.tsx b/packages/website/ts/components/inputs/token_input.tsx
index 7008da12f..ba348dade 100644
--- a/packages/website/ts/components/inputs/token_input.tsx
+++ b/packages/website/ts/components/inputs/token_input.tsx
@@ -52,9 +52,9 @@ export class TokenInput extends React.Component<TokenInputProps, TokenInputState
<Paper
zDepth={1}
style={{cursor: 'pointer'}}
- onMouseEnter={this.onToggleHover.bind(this, true)}
- onMouseLeave={this.onToggleHover.bind(this, false)}
- onClick={this.onAssetClicked.bind(this)}
+ onMouseEnter={this._onToggleHover.bind(this, true)}
+ onMouseLeave={this._onToggleHover.bind(this, false)}
+ onClick={this._onAssetClicked.bind(this)}
>
<div
className="mx-auto pt2"
@@ -73,13 +73,13 @@ export class TokenInput extends React.Component<TokenInputProps, TokenInputState
dispatcher={this.props.dispatcher}
isOpen={this.state.isPickerOpen}
currentTokenAddress={this.props.assetToken.address}
- onTokenChosen={this.onTokenChosen.bind(this)}
+ onTokenChosen={this._onTokenChosen.bind(this)}
tokenByAddress={this.props.tokenByAddress}
/>
</div>
);
}
- private onTokenChosen(tokenAddress: string) {
+ private _onTokenChosen(tokenAddress: string) {
const assetToken: AssetToken = {
address: tokenAddress,
amount: this.props.assetToken.amount,
@@ -89,12 +89,12 @@ export class TokenInput extends React.Component<TokenInputProps, TokenInputState
isPickerOpen: false,
});
}
- private onToggleHover(isHoveringIcon: boolean) {
+ private _onToggleHover(isHoveringIcon: boolean) {
this.setState({
isHoveringIcon,
});
}
- private onAssetClicked() {
+ private _onAssetClicked() {
if (this.props.blockchainErr !== BlockchainErrs.NoError) {
this.props.dispatcher.updateShouldBlockchainErrDialogBeOpen(true);
return;