Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove addProperties helper #318

Merged
merged 2 commits into from
Oct 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions common/containers/Tabs/Contracts/components/Deploy/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { deployHOC } from './components/DeployHoc';
import { TTxCompare } from '../TxCompare';
import { TTxModal } from '../TxModal';
import classnames from 'classnames';
import { addProperties } from 'utils/helpers';
import { isValidGasPrice, isValidByteCode } from 'libs/validators';

export interface Props {
Expand Down Expand Up @@ -72,7 +71,7 @@ const Deploy = (props: Props) => {
<button
className="Sign-submit btn btn-primary"
disabled={!showSignTxButton}
{...addProperties(showSignTxButton, { onClick: handleSignTx })}
onClick={handleSignTx}
>
{translate('DEP_signtx')}
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import WalletDecrypt from 'components/WalletDecrypt';
import { TShowNotification } from 'actions/notifications';
import classnames from 'classnames';
import { isValidGasPrice, isValidValue } from 'libs/validators';
import { addProperties } from 'utils/helpers';

export interface Props {
contractFunctions: any;
Expand Down Expand Up @@ -157,7 +156,9 @@ export default class InteractExplorer extends Component<Props, State> {
className={classnames(
'InteractExplorer-field-input',
'form-control',
{ 'is-invalid': !validGasLimit }
{
'is-invalid': !validGasLimit
}
)}
/>
</label>
Expand All @@ -171,16 +172,16 @@ export default class InteractExplorer extends Component<Props, State> {
className={classnames(
'InteractExplorer-field-input',
'form-control',
{ 'is-invalid': !validValue }
{
'is-invalid': !validValue
}
)}
/>
</label>
<button
className="InteractExplorer-func-submit btn btn-primary"
disabled={!showContractWrite}
{...addProperties(showContractWrite, {
onClick: handleFunctionSend(selectedFunction, inputs)
})}
onClick={handleFunctionSend(selectedFunction, inputs)}
>
{translate('CONTRACT_Write')}
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { getNetworkContracts } from 'selectors/config';
import { connect } from 'react-redux';
import { AppState } from 'reducers';
import { isValidETHAddress, isValidAbiJson } from 'libs/validators';
import { addProperties } from 'utils/helpers';
import classnames from 'classnames';

interface Props {
Expand Down Expand Up @@ -77,7 +76,9 @@ e":"a", "type":"uint256"}], "name":"foo", "outputs": [] }]';
className={classnames(
'InteractForm-address-field-input',
'form-control',
{ 'is-invalid': !validEthAddress }
{
'is-invalid': !validEthAddress
}
)}
onChange={this.handleInput('address')}
/>
Expand Down Expand Up @@ -110,7 +111,9 @@ e":"a", "type":"uint256"}], "name":"foo", "outputs": [] }]';
className={classnames(
'InteractForm-interface-field-input',
'form-control',
{ 'is-invalid': !validAbiJson }
{
'is-invalid': !validAbiJson
}
)}
onChange={this.handleInput('abiJson')}
value={abiJson}
Expand All @@ -122,9 +125,7 @@ e":"a", "type":"uint256"}], "name":"foo", "outputs": [] }]';
<button
className="InteractForm-submit btn btn-primary"
disabled={!showContractAccessButton}
{...addProperties(showContractAccessButton, {
onClick: accessContract(abiJson, address)
})}
onClick={accessContract(abiJson, address)}
>
{translate('x_Access')}
</button>
Expand Down
7 changes: 0 additions & 7 deletions common/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@ export function getKeyByValue(object, value) {
return Object.keys(object).find(key => object[key] === value);
}

interface IKeyedObj {
[key: string]: any;
}
export const addProperties = (
truthy,
propertiesToAdd: IKeyedObj
): {} | IKeyedObj => (truthy ? propertiesToAdd : {});
export function getParam(query: { [key: string]: string }, key: string) {
const keys = Object.keys(query);
const index = keys.findIndex(k => k.toLowerCase() === key.toLowerCase());
Expand Down