From ab614e529f6d3d798216dccc6e552bec4f089d2f Mon Sep 17 00:00:00 2001 From: Zachary Belford Date: Mon, 19 Nov 2018 08:08:45 -0800 Subject: [PATCH 1/3] contract deploy --- src/store/protocol/index.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/store/protocol/index.js b/src/store/protocol/index.js index b8a27bc8c..c941e2d9e 100644 --- a/src/store/protocol/index.js +++ b/src/store/protocol/index.js @@ -29,6 +29,12 @@ const protocolLinkHandler = (request, state, dispatch) => { }; } + const isContractConstructor = paymentParams.mode && paymentParams.mode === 'contract_constructor'; + if (isContractConstructor) { + // do constructory things + contractCallArgs.data = paymentParams.data; + } + const transaction = fromJS({ amount: paymentParams.value, gas: paymentParams.gas, From a1967519bc04856fdd9fd06138e7c59f933326c5 Mon Sep 17 00:00:00 2001 From: shanejonas Date: Tue, 27 Nov 2018 17:16:19 -0800 Subject: [PATCH 2/3] fix: pass deploy data through --- src/components/tx/SendTx/SignTx/SignTxForm.js | 24 ++++++++++++++++--- .../MultiCreateTransaction.js | 9 ++++--- src/containers/Screen/screen.js | 3 ++- src/store/protocol/index.js | 5 ++-- 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/src/components/tx/SendTx/SignTx/SignTxForm.js b/src/components/tx/SendTx/SignTx/SignTxForm.js index 6e6a04cdc..8bceea1c0 100644 --- a/src/components/tx/SendTx/SignTx/SignTxForm.js +++ b/src/components/tx/SendTx/SignTx/SignTxForm.js @@ -82,6 +82,24 @@ const TypedData = (props) => { ); }; + +const getTypedDataOrDeploy = (props) => { + if (props.mode === 'contract_function') { + return [ + , + , + + ] + } + + if (props.mode === 'contract_constructor') { + return [ +

Contract Deploy

, + + ] + } +} + const SignTx = muiThemeable()((props) => { const { value, fiatRate, fiatCurrency, txFee, tx } = props; const { onCancel, onChangePassword, onSubmit, useLedger, typedData } = props; @@ -112,9 +130,9 @@ const SignTx = muiThemeable()((props) => { Plus {txFee} ETC for {tx.gasLimit} GAS. - - - + { + getTypedDataOrDeploy(props) + }
{passwordFields({...props, onChange})} diff --git a/src/containers/MultiCreateTransaction/MultiCreateTransaction.js b/src/containers/MultiCreateTransaction/MultiCreateTransaction.js index 45fbc749b..39546fc10 100644 --- a/src/containers/MultiCreateTransaction/MultiCreateTransaction.js +++ b/src/containers/MultiCreateTransaction/MultiCreateTransaction.js @@ -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, }; @@ -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, }; } @@ -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, @@ -140,7 +141,8 @@ class MultiCreateTransaction extends React.Component { }); } - onSubmitSignTxForm() { + onSubmitSignTxForm() +{ this.props.signAndSend({ transaction: this.state.transaction, allTokens: this.props.allTokens, @@ -199,6 +201,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} /> ); diff --git a/src/containers/Screen/screen.js b/src/containers/Screen/screen.js index 6818e9c52..8e3fef6a3 100644 --- a/src/containers/Screen/screen.js +++ b/src/containers/Screen/screen.js @@ -59,7 +59,8 @@ const Screen = ({ screen, screenItem }) => { const gasLimit = transaction.get('gas'); const data = transaction.get('data'); const typedData = transaction.get('typedData'); - return ; + const mode = transaction.get('mode'); + return ; } else if (screen === 'landing-generate') { return ; } else if (screen === 'generate') { diff --git a/src/store/protocol/index.js b/src/store/protocol/index.js index c941e2d9e..5c629e708 100644 --- a/src/store/protocol/index.js +++ b/src/store/protocol/index.js @@ -25,19 +25,20 @@ const protocolLinkHandler = (request, state, dispatch) => { contractCallArgs.data = contract.functionToData(paymentParams.functionSignature.name, args) || undefined; contractCallArgs.typedData = { name: paymentParams.functionSignature.name, - argsDefaults: paymentParams.argsDefaults, + argsDefaults: paymentParams.argsDefaults }; } const isContractConstructor = paymentParams.mode && paymentParams.mode === 'contract_constructor'; + if (isContractConstructor) { - // do constructory things contractCallArgs.data = paymentParams.data; } const transaction = fromJS({ amount: paymentParams.value, gas: paymentParams.gas, + mode: paymentParams.mode, ...contractCallArgs, }); From cecb8196af0f6baa71dbe9a80a38cbf1f9bcbd00 Mon Sep 17 00:00:00 2001 From: shanejonas Date: Tue, 4 Dec 2018 14:57:14 -0800 Subject: [PATCH 3/3] fix: linting issues --- src/components/tx/SendTx/SignTx/SignTxForm.js | 26 +++++++++++-------- .../MultiCreateTransaction.js | 3 +-- src/store/protocol/index.js | 2 +- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/components/tx/SendTx/SignTx/SignTxForm.js b/src/components/tx/SendTx/SignTx/SignTxForm.js index 8bceea1c0..9f98a9996 100644 --- a/src/components/tx/SendTx/SignTx/SignTxForm.js +++ b/src/components/tx/SendTx/SignTx/SignTxForm.js @@ -85,20 +85,24 @@ const TypedData = (props) => { const getTypedDataOrDeploy = (props) => { if (props.mode === 'contract_function') { - return [ - , - , - - ] + return ( + + , + , + , + + ); } if (props.mode === 'contract_constructor') { - return [ -

Contract Deploy

, - - ] + return ( + +

Contract Deploy

, + , +
+ ); } -} +}; const SignTx = muiThemeable()((props) => { const { value, fiatRate, fiatCurrency, txFee, tx } = props; @@ -131,7 +135,7 @@ const SignTx = muiThemeable()((props) => { { - getTypedDataOrDeploy(props) + getTypedDataOrDeploy(props) } {passwordFields({...props, onChange})} diff --git a/src/containers/MultiCreateTransaction/MultiCreateTransaction.js b/src/containers/MultiCreateTransaction/MultiCreateTransaction.js index 39546fc10..ee86171f1 100644 --- a/src/containers/MultiCreateTransaction/MultiCreateTransaction.js +++ b/src/containers/MultiCreateTransaction/MultiCreateTransaction.js @@ -141,8 +141,7 @@ class MultiCreateTransaction extends React.Component { }); } - onSubmitSignTxForm() -{ + onSubmitSignTxForm() { this.props.signAndSend({ transaction: this.state.transaction, allTokens: this.props.allTokens, diff --git a/src/store/protocol/index.js b/src/store/protocol/index.js index 5c629e708..146dc7654 100644 --- a/src/store/protocol/index.js +++ b/src/store/protocol/index.js @@ -25,7 +25,7 @@ const protocolLinkHandler = (request, state, dispatch) => { contractCallArgs.data = contract.functionToData(paymentParams.functionSignature.name, args) || undefined; contractCallArgs.typedData = { name: paymentParams.functionSignature.name, - argsDefaults: paymentParams.argsDefaults + argsDefaults: paymentParams.argsDefaults, }; }