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

Allow setting of minBlock on sending #3921

Merged
merged 9 commits into from
Dec 23, 2016
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Allow Contract execute to specify minBock
  • Loading branch information
jacogr committed Dec 20, 2016

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 2a64f7f49dfcc19f5ff26f2df51e687c3156fb05
57 changes: 57 additions & 0 deletions js/src/modals/ExecuteContract/AdvancedStep/advancedStep.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity.

// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

import React, { Component, PropTypes } from 'react';
import { FormattedMessage } from 'react-intl';

import { Input, GasPriceEditor } from '~/ui';

import styles from '../executeContract.css';

export default class AdvancedStep extends Component {
static propTypes = {
gasStore: PropTypes.object.isRequired,
minBlock: PropTypes.string,
Copy link
Contributor

@derhuerst derhuerst Dec 21, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[minor grumble] As the block number is an integer, why not use parseInt and make this a PropTypes.number?

minBlockError: PropTypes.string,
onMinBlockChange: PropTypes.func
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[minor grumble] Any reason not to make this isRequired?

};

render () {
const { gasStore, minBlock, minBlockError, onMinBlockChange } = this.props;

return (
<div>
<Input
error={ minBlockError }
hint={
<FormattedMessage
id='executeContract.advanced.minBlock.hint'
defaultMessage='Only post the transaction after this block' />
}
label={
<FormattedMessage
id='executeContract.advanced.minBlock.label'
defaultMessage='BlockNumber to send from' />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This indicates that the tx will definitely get mined at the specific block. I'd propose something that is better aligned with the hint above.

}
value={ minBlock }
onSubmit={ onMinBlockChange } />
<div className={ styles.gaseditor }>
<GasPriceEditor store={ gasStore } />
</div>
</div>
);
}
}
17 changes: 17 additions & 0 deletions js/src/modals/ExecuteContract/AdvancedStep/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity.

// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Parity is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

export default from './advancedStep';
68 changes: 48 additions & 20 deletions js/src/modals/ExecuteContract/DetailsStep/detailsStep.js
Original file line number Diff line number Diff line change
@@ -14,8 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

import React, { Component, PropTypes } from 'react';
import { Checkbox, MenuItem } from 'material-ui';
import React, { Component, PropTypes } from 'react';
import { FormattedMessage } from 'react-intl';

import { AddressSelect, Form, Input, Select, TypedInput } from '~/ui';

@@ -29,29 +30,28 @@ const CHECK_STYLE = {

export default class DetailsStep extends Component {
static propTypes = {
advancedOptions: PropTypes.bool,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[tiny grumble] Would prefer something that indicates that this is a boolean, e.g. showAdvancedOptions.

accounts: PropTypes.object.isRequired,
contract: PropTypes.object.isRequired,
onAmountChange: PropTypes.func.isRequired,
onFromAddressChange: PropTypes.func.isRequired,
onValueChange: PropTypes.func.isRequired,
values: PropTypes.array.isRequired,
valuesError: PropTypes.array.isRequired,

amount: PropTypes.string,
amountError: PropTypes.string,
balances: PropTypes.object,
contract: PropTypes.object.isRequired,
fromAddress: PropTypes.string,
fromAddressError: PropTypes.string,
func: PropTypes.object,
funcError: PropTypes.string,
gasEdit: PropTypes.bool,
onAdvancedClick: PropTypes.func,
onAmountChange: PropTypes.func.isRequired,
onFromAddressChange: PropTypes.func.isRequired,
onFuncChange: PropTypes.func,
onGasEditClick: PropTypes.func,
onValueChange: PropTypes.func.isRequired,
values: PropTypes.array.isRequired,
valuesError: PropTypes.array.isRequired,
warning: PropTypes.string
}

render () {
const { accounts, amount, amountError, balances, fromAddress, fromAddressError, gasEdit, onGasEditClick, onFromAddressChange, onAmountChange } = this.props;
const { accounts, advancedOptions, amount, amountError, balances, fromAddress, fromAddressError, onAdvancedClick, onAmountChange, onFromAddressChange } = this.props;

return (
<Form>
@@ -60,8 +60,16 @@ export default class DetailsStep extends Component {
accounts={ accounts }
balances={ balances }
error={ fromAddressError }
hint='the account to transact with'
label='from account'
hint={
<FormattedMessage
id='executeContract.details.address.label'
defaultMessage='the account to transact with' />
}
label={
<FormattedMessage
id='executeContract.details.address.hint'
defaultMessage='from account' />
}
onChange={ onFromAddressChange }
value={ fromAddress } />
{ this.renderFunctionSelect() }
@@ -70,16 +78,28 @@ export default class DetailsStep extends Component {
<div>
<Input
error={ amountError }
hint='the amount to send to with the transaction'
label='transaction value (in ETH)'
hint={
<FormattedMessage
id='executeContract.details.amount.hint'
defaultMessage='the amount to send to with the transaction' />
}
label={
<FormattedMessage
id='executeContract.details.amount.label'
defaultMessage='transaction value (in ETH)' />
}
onSubmit={ onAmountChange }
value={ amount } />
</div>
<div>
<Checkbox
checked={ gasEdit }
label='edit gas price or value'
onCheck={ onGasEditClick }
checked={ advancedOptions }
label={
<FormattedMessage
id='executeContract.details.advancedCheck.label'
defaultMessage='advanced sending options' />
}
onCheck={ onAdvancedClick }
style={ CHECK_STYLE } />
</div>
</div>
@@ -129,9 +149,17 @@ export default class DetailsStep extends Component {

return (
<Select
label='function to execute'
hint='the function to call on the contract'
error={ funcError }
hint={
<FormattedMessage
id='executeContract.details.function.hint'
defaultMessage='the function to call on the contract' />
}
label={
<FormattedMessage
id='executeContract.details.function.label'
defaultMessage='function to execute' />
}
onChange={ this.onFuncChange }
value={ func.signature }>
{ functions }
19 changes: 12 additions & 7 deletions js/src/modals/ExecuteContract/executeContract.css
Original file line number Diff line number Diff line change
@@ -14,22 +14,27 @@
/* You should have received a copy of the GNU General Public License
/* along with Parity. If not, see <http://www.gnu.org/licenses/>.
*/
.modalbody,
.modalcenter {
}

.modalcenter {
text-align: center;
}

.funcparams {
padding-left: 3em;
}

.gaseditor {
margin-top: 1em;
}

.paramname {
color: #aaa;
}

.modalbody,
.modalcenter {
}

.modalcenter {
text-align: center;
}

.txhash {
word-break: break-all;
}
Loading