From 09334ca3bd5ac999147cd9abf28d03961240c806 Mon Sep 17 00:00:00 2001 From: Nicolas Gotchac Date: Fri, 9 Dec 2016 01:21:51 +0100 Subject: [PATCH] Small fixes to contract (#3751) * Fix contracts execution will fallback function * Fix contract execute modal * Working execute from Contract * Don't dupliacet events * Gas * 1.2 in wallet confirmations --- .../DetailsStep/detailsStep.js | 65 +++++-------------- .../modals/ExecuteContract/executeContract.js | 25 ++----- js/src/redux/providers/compilerWorker.js | 4 +- js/src/redux/providers/walletActions.js | 2 +- js/src/views/Contract/Events/events.js | 6 +- 5 files changed, 30 insertions(+), 72 deletions(-) diff --git a/js/src/modals/ExecuteContract/DetailsStep/detailsStep.js b/js/src/modals/ExecuteContract/DetailsStep/detailsStep.js index 082fac6a7..b4488729a 100644 --- a/js/src/modals/ExecuteContract/DetailsStep/detailsStep.js +++ b/js/src/modals/ExecuteContract/DetailsStep/detailsStep.js @@ -17,7 +17,8 @@ import React, { Component, PropTypes } from 'react'; import { MenuItem } from 'material-ui'; -import { AddressSelect, Form, Input, InputAddressSelect, Select } from '~/ui'; +import { AddressSelect, Form, Input, Select, TypedInput } from '~/ui'; +import { parseAbiType } from '~/util/abi'; import styles from '../executeContract.css'; @@ -74,7 +75,7 @@ export default class DetailsStep extends Component { const functions = contract.functions .filter((func) => !func.constant) - .sort((a, b) => a.name.localeCompare(b.name)) + .sort((a, b) => (a.name || '').localeCompare(b.name || '')) .map((func) => { const params = (func.abi.inputs || []) .map((input, index) => { @@ -125,56 +126,22 @@ export default class DetailsStep extends Component { } return (func.abi.inputs || []).map((input, index) => { - const onChange = (event, value) => onValueChange(event, index, value); - const onSelect = (event, _index, value) => onValueChange(event, index, value); - const onSubmit = (value) => onValueChange(null, index, value); + const onChange = (value) => onValueChange(null, index, value); const label = `${input.name}: ${input.type}`; - let inputbox; - - switch (input.type) { - case 'address': - inputbox = ( - - ); - break; - - case 'bool': - const boolitems = ['false', 'true'].map((bool) => { - return ( - { bool } - ); - }); - inputbox = ( - - ); - break; - - default: - inputbox = ( - - ); - } return ( -
- { inputbox } +
+
); }); diff --git a/js/src/modals/ExecuteContract/executeContract.js b/js/src/modals/ExecuteContract/executeContract.js index c3b64d738..4a708d17a 100644 --- a/js/src/modals/ExecuteContract/executeContract.js +++ b/js/src/modals/ExecuteContract/executeContract.js @@ -23,6 +23,7 @@ import ContentClear from 'material-ui/svg-icons/content/clear'; import { BusyStep, CompletedStep, Button, IdentityIcon, Modal, TxHash } from '~/ui'; import { MAX_GAS_ESTIMATION } from '../../util/constants'; import { validateAddress, validateUint } from '../../util/validation'; +import { parseAbiType } from '~/util/abi'; import DetailsStep from './DetailsStep'; @@ -66,7 +67,7 @@ class ExecuteContract extends Component { const { contract } = this.props; const functions = contract.functions .filter((func) => !func.constant) - .sort((a, b) => a.name.localeCompare(b.name)); + .sort((a, b) => (a.name || '').localeCompare(b.name || '')); this.onFuncChange(null, functions[0]); } @@ -111,7 +112,7 @@ class ExecuteContract extends Component {