Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Disable time conditions in Tx UI #6445
Browse files Browse the repository at this point in the history
  • Loading branch information
maciejhirsz committed Sep 25, 2017
1 parent b74065a commit 25f0f07
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 27 deletions.
4 changes: 4 additions & 0 deletions js/src/api/local/localAccountsMiddleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ export default class LocalAccountsMiddleware extends Middleware {
return [];
});

register('parity_lockedHardwareAccountsInfo', () => {
return [];
});

register('parity_hashContent', () => {
throw new Error('Functionality unavailable on a public wallet.');
});
Expand Down
6 changes: 5 additions & 1 deletion js/src/modals/DeployContract/deployContract.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class DeployContract extends Component {
};

static propTypes = {
availability: PropTypes.string.isRequired,
accounts: PropTypes.object.isRequired,
abi: PropTypes.string,
code: PropTypes.string,
Expand Down Expand Up @@ -331,6 +332,7 @@ class DeployContract extends Component {

return (
<Extras
availability={ this.props.availability }
gasStore={ this.gasStore }
hideData
isEth
Expand Down Expand Up @@ -490,9 +492,11 @@ class DeployContract extends Component {
}

function mapStateToProps (state) {
const { gasLimit } = state.nodeStatus;
const { gasLimit, nodeKind = {} } = state.nodeStatus;
const { availability = 'unknown' } = nodeKind;

return {
availability,
gasLimit
};
}
Expand Down
5 changes: 3 additions & 2 deletions js/src/modals/ExecuteContract/AdvancedStep/advancedStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@ import styles from '../executeContract.css';

export default class AdvancedStep extends Component {
static propTypes = {
availability: PropTypes.string.isRequired,
gasStore: PropTypes.object.isRequired
};

render () {
const { gasStore } = this.props;
const { availability, gasStore } = this.props;

return (
<div className={ styles.gaseditor }>
<GasPriceEditor store={ gasStore } />
<GasPriceEditor availability={ availability } store={ gasStore } />
</div>
);
}
Expand Down
15 changes: 11 additions & 4 deletions js/src/modals/ExecuteContract/executeContract.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class ExecuteContract extends Component {
};

static propTypes = {
availability: PropTypes.string.isRequired,
accounts: PropTypes.object,
contract: PropTypes.object.isRequired,
fromAddress: PropTypes.string,
Expand Down Expand Up @@ -198,7 +199,7 @@ class ExecuteContract extends Component {
}

renderStep () {
const { accounts, contract, fromAddress, onFromAddressChange } = this.props;
const { availability, accounts, contract, fromAddress, onFromAddressChange } = this.props;
const { step } = this.state;

if (step === STEP_DETAILS) {
Expand All @@ -218,7 +219,10 @@ class ExecuteContract extends Component {
}

return (
<AdvancedStep gasStore={ this.gasStore } />
<AdvancedStep
availability={ availability }
gasStore={ this.gasStore }
/>
);
}

Expand Down Expand Up @@ -337,9 +341,12 @@ class ExecuteContract extends Component {
}

function mapStateToProps (state) {
const { gasLimit } = state.nodeStatus;
console.log('>>>>ExecuteContract', state);

const { gasLimit, nodeKind = {} } = state.nodeStatus;
const { availability = 'unknown' } = nodeKind;

return { gasLimit };
return { availability, gasLimit };
}

export default connect(
Expand Down
4 changes: 3 additions & 1 deletion js/src/modals/Transfer/Extras/extras.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import styles from '../transfer.css';

export default class Extras extends Component {
static propTypes = {
availability: PropTypes.string.isRequired,
data: PropTypes.string,
dataError: PropTypes.string,
hideData: PropTypes.bool,
Expand All @@ -38,13 +39,14 @@ export default class Extras extends Component {
};

render () {
const { gasStore, onChange } = this.props;
const { availability, gasStore, onChange } = this.props;

return (
<Form>
{ this.renderData() }
<div className={ styles.gaseditor }>
<GasPriceEditor
availability={ availability }
store={ gasStore }
onChange={ onChange }
/>
Expand Down
7 changes: 5 additions & 2 deletions js/src/modals/Transfer/transfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class Transfer extends Component {
}

static propTypes = {
availability: PropTypes.string.isRequired,
newError: PropTypes.func.isRequired,
gasLimit: PropTypes.object.isRequired,

Expand Down Expand Up @@ -186,6 +187,7 @@ class Transfer extends Component {
onChange={ this.store.onUpdateDetails }
total={ total }
totalError={ totalError }
availability={ this.props.availability }
/>
);
}
Expand Down Expand Up @@ -291,13 +293,14 @@ function mapStateToProps (initState, initProps) {
: null;

return (state) => {
const { gasLimit } = state.nodeStatus;
const { gasLimit, nodeKind = {} } = state.nodeStatus;
const { balances } = state;
const { availability = 'unknown' } = nodeKind;

const balance = balances[address];
const sendersBalances = senders ? pick(balances, Object.keys(senders)) : null;

return { balance, gasLimit, senders, sendersBalances, tokens, wallet };
return { availability, balance, gasLimit, senders, sendersBalances, tokens, wallet };
};
}

Expand Down
45 changes: 30 additions & 15 deletions js/src/ui/GasPriceEditor/gasPriceEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,34 +64,24 @@ export default class GasPriceEditor extends Component {
static propTypes = {
children: PropTypes.node,
onChange: PropTypes.func,
store: PropTypes.object.isRequired
store: PropTypes.object.isRequired,
availability: PropTypes.string.isRequired
}

static Store = Store;

render () {
const { api } = this.context;
const { children, store } = this.props;
const { conditionType, errorGas, errorPrice, errorTotal, estimated, gas, histogram, price, priceDefault, totalValue } = store;
const { errorGas, errorPrice, errorTotal, estimated, gas, histogram, price, priceDefault, totalValue } = store;

const eth = api.util.fromWei(totalValue).toFormat();
const gasLabel = `gas (estimated: ${new BigNumber(estimated).toFormat()})`;
const priceLabel = `price (current: ${new BigNumber(priceDefault).toFormat()})`;

return (
<div className={ styles.container }>
<RadioButtons
className={ styles.conditionRadio }
label={
<FormattedMessage
id='txEditor.condition.label'
defaultMessage='Condition where transaction activates'
/>
}
onChange={ this.onChangeConditionType }
value={ conditionType }
values={ CONDITION_VALUES }
/>
{ this.renderConditionRadioButtons() }
{ this.renderConditions() }

<div className={ styles.graphContainer }>
Expand Down Expand Up @@ -148,10 +138,35 @@ export default class GasPriceEditor extends Component {
);
}

renderConditionRadioButtons () {
const { availability } = this.props;
const { conditionType } = this.props.store;

if (availability !== 'personal') {
return null;
}

return (
<RadioButtons
className={ styles.conditionRadio }
label={
<FormattedMessage
id='txEditor.condition.label'
defaultMessage='Condition where transaction activates'
/>
}
onChange={ this.onChangeConditionType }
value={ conditionType }
values={ CONDITION_VALUES }
/>
);
}

renderConditions () {
const { availability } = this.props;
const { conditionType, condition, conditionBlockError } = this.props.store;

if (conditionType === CONDITIONS.NONE) {
if (conditionType === CONDITIONS.NONE || availability !== 'personal') {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class TransactionPending extends Component {
};

static propTypes = {
availability: PropTypes.string.isRequired,
accounts: PropTypes.object.isRequired,
className: PropTypes.string,
date: PropTypes.instanceOf(Date).isRequired,
Expand Down Expand Up @@ -140,11 +141,11 @@ class TransactionPending extends Component {
}

renderTxEditor () {
const { className } = this.props;
const { availability, className } = this.props;

return (
<div className={ `${styles.container} ${className}` }>
<GasPriceEditor store={ this.gasStore }>
<GasPriceEditor availability={ availability } store={ this.gasStore }>
<Button
label={
<FormattedMessage
Expand Down Expand Up @@ -190,9 +191,12 @@ class TransactionPending extends Component {
}

function mapStateToProps (state) {
const { nodeKind = {} } = state.nodeStatus;
const { accounts } = state.personal;
const { availability = 'unknown' } = nodeKind;

return {
availability,
accounts
};
}
Expand Down

0 comments on commit 25f0f07

Please sign in to comment.