diff --git a/js/src/ui/CopyToClipboard/copyToClipboard.css b/js/src/ui/CopyToClipboard/copyToClipboard.css index 3b6db7843..4e2bb8cc4 100644 --- a/js/src/ui/CopyToClipboard/copyToClipboard.css +++ b/js/src/ui/CopyToClipboard/copyToClipboard.css @@ -28,6 +28,6 @@ text-overflow: ellipsis; } -.container { +.container > * { display: flex; } diff --git a/js/src/ui/Form/TypedInput/typedInput.css b/js/src/ui/Form/TypedInput/typedInput.css index 88b269da3..1281c203c 100644 --- a/js/src/ui/Form/TypedInput/typedInput.css +++ b/js/src/ui/Form/TypedInput/typedInput.css @@ -25,7 +25,6 @@ color: rgba(255, 255, 255, 0.498039); -webkit-user-select: none; font-size: 12px; - top: 11px; position: relative; } } diff --git a/js/src/ui/Form/TypedInput/typedInput.js b/js/src/ui/Form/TypedInput/typedInput.js index 16b3b0ca1..a6a84ad21 100644 --- a/js/src/ui/Form/TypedInput/typedInput.js +++ b/js/src/ui/Form/TypedInput/typedInput.js @@ -24,6 +24,7 @@ import AddIcon from 'material-ui/svg-icons/content/add'; import RemoveIcon from 'material-ui/svg-icons/content/remove'; import { fromWei, toWei } from '~/api/util/wei'; +import { bytesToHex } from '~/api/util/format'; import Input from '~/ui/Form/Input'; import InputAddressSelect from '~/ui/Form/InputAddressSelect'; import Select from '~/ui/Form/Select'; @@ -68,7 +69,8 @@ export default class TypedInput extends Component { }; componentWillMount () { - const { isEth, value } = this.props; + const { isEth } = this.props; + const value = this.getValue(); if (typeof isEth === 'boolean' && value) { // Remove formatting commas @@ -95,14 +97,15 @@ export default class TypedInput extends Component { const { type } = param; if (type === ABI_TYPES.ARRAY) { - const { accounts, className, label, value = param.default } = this.props; + const { accounts, className, label } = this.props; const { subtype, length } = param; + const value = this.getValue() || param.default; const fixedLength = !!length; const inputs = range(length || value.length).map((_, index) => { const onChange = (inputValue) => { - const newValues = [].concat(this.props.value); + const newValues = [].concat(value); newValues[index] = inputValue; this.props.onChange(newValues); @@ -191,7 +194,14 @@ export default class TypedInput extends Component { } if (type === ABI_TYPES.BYTES) { - return this.renderDefault(); + let value = this.getValue(); + + // Convert to hex if it's an array + if (Array.isArray(value)) { + value = bytesToHex(value); + } + + return this.renderDefault(value); } // If the `isEth` prop is present (true or false) @@ -260,7 +270,7 @@ export default class TypedInput extends Component { : bnValue.toFixed(); // we need a string representation, could be >15 digits } - renderInteger (value = this.props.value, onChange = this.onChange) { + renderInteger (value = this.getValue(), onChange = this.onChange) { const { allowCopy, className, label, error, hint, min, max, readOnly } = this.props; const param = this.getParam(); @@ -268,7 +278,7 @@ export default class TypedInput extends Component { return ( { + getParam () { const { param } = this.props; if (typeof param === 'string') { @@ -450,4 +462,15 @@ export default class TypedInput extends Component { return param; } + + /** + * If the value comes from `decodeMethodInput`, + * it can be an object of the shape: + * { value: Object, type: String } + */ + getValue (value = this.props.value) { + return value && value.value + ? value.value + : value; + } } diff --git a/js/src/ui/MethodDecoding/methodDecoding.js b/js/src/ui/MethodDecoding/methodDecoding.js index 0bf8cce74..0aa603bca 100644 --- a/js/src/ui/MethodDecoding/methodDecoding.js +++ b/js/src/ui/MethodDecoding/methodDecoding.js @@ -560,7 +560,7 @@ class MethodDecoding extends Component { key={ index } param={ input.type } readOnly - value={ this.renderValue(input.value) } + value={ input.value } /> ); }); @@ -568,16 +568,6 @@ class MethodDecoding extends Component { return inputs; } - renderValue (value) { - const { api } = this.context; - - if (api.util.isArray(value)) { - return api.util.bytesToHex(value); - } - - return value.toString(); - } - renderTokenValue (value) { const { token } = this.props; diff --git a/js/src/util/abi.js b/js/src/util/abi.js index 34f575bb0..e2670f387 100644 --- a/js/src/util/abi.js +++ b/js/src/util/abi.js @@ -101,7 +101,7 @@ export function parseAbiType (type) { }; } - if (type === 'bytes') { + if (type === 'bytes' || type === 'fixedBytes') { return { type: BYTES_TYPE, default: '0x' diff --git a/js/src/views/Contract/Events/Event/event.js b/js/src/views/Contract/Events/Event/event.js index 64e4cdd49..3c1572b51 100644 --- a/js/src/views/Contract/Events/Event/event.js +++ b/js/src/views/Contract/Events/Event/event.js @@ -19,7 +19,7 @@ import moment from 'moment'; import React, { Component, PropTypes } from 'react'; import { FormattedMessage } from 'react-intl'; -import { IdentityIcon, IdentityName, Input, InputAddress } from '~/ui'; +import { IdentityIcon, IdentityName, TypedInput } from '~/ui'; import ShortenedHash from '~/ui/ShortenedHash'; import { txLink } from '~/3rdparty/etherscan/links'; @@ -112,41 +112,16 @@ export default class Event extends Component { } renderParam (name, param) { - const { api } = this.context; - - switch (param.type) { - case 'address': - return ( - - ); - - default: - let value; - - if (api.util.isInstanceOf(param.value, BigNumber)) { - value = param.value.toFormat(0); - } else if (api.util.isArray(param.value)) { - value = api.util.bytesToHex(param.value); - } else { - value = param.value.toString(); - } - - return ( - - ); - } + return ( + + ); } formatBlockTimestamp (block) { diff --git a/js/src/views/Contract/Events/events.js b/js/src/views/Contract/Events/events.js index a709c137a..a15565757 100644 --- a/js/src/views/Contract/Events/events.js +++ b/js/src/views/Contract/Events/events.js @@ -46,6 +46,12 @@ export default class Events extends Component { events: [] }; + shouldComponentUpdate (nextProps) { + return (nextProps.events !== this.props.events) || + (nextProps.netVersion !== this.props.netVersion) || + (nextProps.isLoading !== this.props.isLoading); + } + render () { const { events, isLoading, netVersion } = this.props; diff --git a/js/src/views/Contract/Queries/inputQuery.js b/js/src/views/Contract/Queries/inputQuery.js index 8d4bddf02..7a75727f6 100644 --- a/js/src/views/Contract/Queries/inputQuery.js +++ b/js/src/views/Contract/Queries/inputQuery.js @@ -138,10 +138,8 @@ class InputQuery extends Component { .map((out, index) => ({ name: out.name, type: out.type, - value: results[index], - display: this.renderValue(results[index]) + value: results[index] })) - .sort((outA, outB) => outA.display.length - outB.display.length) .map((out, index) => { const input = ( ); @@ -195,25 +193,6 @@ class InputQuery extends Component { ); } - renderValue (token) { - const { api } = this.context; - const { type, value } = token; - - if (value === null || value === undefined) { - return 'no data'; - } - - if (type === 'array' || type === 'fixedArray') { - return value.map((tok) => this.renderValue(tok)); - } - - if (Array.isArray(value)) { - return api.util.bytesToHex(value); - } - - return value; - } - onClick = () => { const { inputs, values } = this.state; const { contract, name, outputs, signature } = this.props; diff --git a/js/src/views/Contract/Queries/queries.js b/js/src/views/Contract/Queries/queries.js index de939a93d..eef428eed 100644 --- a/js/src/views/Contract/Queries/queries.js +++ b/js/src/views/Contract/Queries/queries.js @@ -139,15 +139,14 @@ export default class Queries extends Component { ); } - renderValue (tokenValue, output, key) { - if (typeof tokenValue === 'undefined') { + renderValue (value, output, key) { + if (typeof value === 'undefined') { return null; } const { accountsInfo } = this.props; const { name, type } = output; const label = `${name ? `${name}: ` : ''}${type}`; - const value = this.getTokenValue(tokenValue); return ( this.getTokenValue(tok)); - } - - if (Array.isArray(value)) { - return api.util.bytesToHex(value); - } - - return value; - } - _sortEntries (a, b) { return a.name.localeCompare(b.name); } diff --git a/js/src/views/WriteContract/writeContract.js b/js/src/views/WriteContract/writeContract.js index c4b08e3dd..86262820d 100644 --- a/js/src/views/WriteContract/writeContract.js +++ b/js/src/views/WriteContract/writeContract.js @@ -578,6 +578,10 @@ class WriteContract extends Component { } renderContract (contract) { + if (!contract) { + return null; + } + const { bytecode } = contract; const abi = contract.interface;