Skip to content

Commit

Permalink
Merge pull request #849 from ETCDEVTeam/feature/contract-deploy
Browse files Browse the repository at this point in the history
contract deploy
  • Loading branch information
shanejonas authored Dec 5, 2018
2 parents 5599a82 + cecb819 commit 75d2124
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 6 deletions.
28 changes: 25 additions & 3 deletions src/components/tx/SendTx/SignTx/SignTxForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,28 @@ const TypedData = (props) => {
);
};


const getTypedDataOrDeploy = (props) => {
if (props.mode === 'contract_function') {
return (
<React.Fragment>
<Divider style={{ marginTop: '35px' }} />,
<TypedData typedData={props.typedData} />,
<Divider style={{ marginTop: '35px' }} />,
</React.Fragment>
);
}

if (props.mode === 'contract_constructor') {
return (
<React.Fragment>
<h3>Contract Deploy</h3>,
<Divider style={{ marginTop: '35px' }} />,
</React.Fragment>
);
}
};

const SignTx = muiThemeable()((props) => {
const { value, fiatRate, fiatCurrency, txFee, tx } = props;
const { onCancel, onChangePassword, onSubmit, useLedger, typedData } = props;
Expand Down Expand Up @@ -112,9 +134,9 @@ const SignTx = muiThemeable()((props) => {
Plus {txFee} ETC for {tx.gasLimit} GAS.
</span>
</div>
<Divider style={{ marginTop: '35px' }} />
<TypedData typedData={typedData} />
<Divider style={{ marginTop: '35px' }} />
{
getTypedDataOrDeploy(props)
}
<Form style={{ marginTop: '0' }}>
{passwordFields({...props, onChange})}
<Row>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class MultiCreateTransaction extends React.Component {
txFee: PropTypes.string.isRequired,
txFeeFiat: PropTypes.string.isRequired,
data: PropTypes.object,
mode: PropTypes.string,
typedData: PropTypes.object,
};

Expand All @@ -56,7 +57,7 @@ class MultiCreateTransaction extends React.Component {
this.onMaxClicked = this.onMaxClicked.bind(this);
this.state = {
transaction: {},
page: props.typedData ? PAGES.PASSWORD : PAGES.TX,
page: props.mode ? PAGES.PASSWORD : PAGES.TX,
};
}

Expand Down Expand Up @@ -102,7 +103,7 @@ class MultiCreateTransaction extends React.Component {
const props = this.props;
if (from !== props.from || to !== props.to || value !== props.value || data !== props.data) {
this.setState({
page: props.typedData ? PAGES.PASSWORD : PAGES.TX,
page: props.mode ? PAGES.PASSWORD : PAGES.TX,
transaction: {
...this.state.transaction,
from: this.props.selectedFromAccount,
Expand Down Expand Up @@ -199,6 +200,7 @@ class MultiCreateTransaction extends React.Component {
useLedger={this.props.useLedger}
typedData={this.state.transaction.typedData}
onSubmit={this.onSubmitSignTxForm}
mode={this.props.mode}
onCancel={this.props.onCancel}
/>
);
Expand Down
3 changes: 2 additions & 1 deletion src/containers/Screen/screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ const Screen = ({ screen, screenItem }) => {
const gasLimit = transaction.get('gas');
const data = transaction.get('data');
const typedData = transaction.get('typedData');
return <MultiCreateTransaction account={ fromAccount } to={to} amount={amount} gasLimit={gasLimit} data={data} typedData={typedData}/>;
const mode = transaction.get('mode');
return <MultiCreateTransaction account={ fromAccount } to={to} amount={amount} gasLimit={gasLimit} data={data} typedData={typedData} mode={mode}/>;
} else if (screen === 'landing-generate') {
return <GenerateAccount onBackScreen="landing" backLabel="Back"/>;
} else if (screen === 'generate') {
Expand Down
7 changes: 7 additions & 0 deletions src/store/protocol/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,16 @@ const protocolLinkHandler = (request, state, dispatch) => {
};
}

const isContractConstructor = paymentParams.mode && paymentParams.mode === 'contract_constructor';

if (isContractConstructor) {
contractCallArgs.data = paymentParams.data;
}

const transaction = fromJS({
amount: paymentParams.value,
gas: paymentParams.gas,
mode: paymentParams.mode,
...contractCallArgs,
});

Expand Down

0 comments on commit 75d2124

Please sign in to comment.