-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Show contract parameters in MethodDecoding #4024
Changes from 4 commits
c0da6cb
1740a9e
f472da6
03e36cc
f2b64d2
645a64d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,6 +60,7 @@ class AddressSelect extends Component { | |
// Optional props | ||
allowCopy: PropTypes.bool, | ||
allowInput: PropTypes.bool, | ||
className: PropTypes.string, | ||
disabled: PropTypes.bool, | ||
error: nodeOrStringProptype(), | ||
hint: nodeOrStringProptype(), | ||
|
@@ -123,13 +124,14 @@ class AddressSelect extends Component { | |
|
||
renderInput () { | ||
const { focused } = this.state; | ||
const { accountsInfo, allowCopy, disabled, error, hint, label, readOnly, value } = this.props; | ||
const { accountsInfo, allowCopy, className, disabled, error, hint, label, readOnly, value } = this.props; | ||
|
||
const input = ( | ||
<InputAddress | ||
accountsInfo={ accountsInfo } | ||
allowCopy={ allowCopy } | ||
disabled={ disabled } | ||
className={ className } | ||
disabled={ disabled || readOnly } | ||
error={ error } | ||
hint={ hint } | ||
focused={ focused } | ||
|
@@ -534,7 +536,7 @@ class AddressSelect extends Component { | |
}); | ||
} | ||
|
||
handleFocus = () => { | ||
handleFocus = (e) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need the (unused) variable here? Consider at least a description name - no There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Forgot to remove this one |
||
const { disabled, readOnly } = this.props; | ||
|
||
if (disabled || readOnly) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,7 @@ export default class TypedInput extends Component { | |
|
||
accounts: PropTypes.object, | ||
allowCopy: PropTypes.bool, | ||
className: PropTypes.string, | ||
error: PropTypes.any, | ||
hint: PropTypes.string, | ||
isEth: PropTypes.bool, | ||
|
@@ -91,7 +92,7 @@ export default class TypedInput extends Component { | |
const { type } = param; | ||
|
||
if (type === ABI_TYPES.ARRAY) { | ||
const { accounts, label, value = param.default } = this.props; | ||
const { accounts, className, label, value = param.default } = this.props; | ||
const { subtype, length } = param; | ||
|
||
const fixedLength = !!length; | ||
|
@@ -107,6 +108,7 @@ export default class TypedInput extends Component { | |
<TypedInput | ||
accounts={ accounts } | ||
allowCopy={ allowCopy } | ||
className={ className } | ||
key={ `${subtype.type}_${index}` } | ||
onChange={ onChange } | ||
param={ subtype } | ||
|
@@ -236,17 +238,30 @@ export default class TypedInput extends Component { | |
); | ||
} | ||
|
||
getNumberValue (value) { | ||
if (!value) { | ||
return value; | ||
} | ||
|
||
const rawValue = typeof value === 'string' | ||
? value.replace(/,/g, '') | ||
: value; | ||
|
||
return new BigNumber(rawValue); | ||
} | ||
|
||
renderInteger (value = this.props.value, onChange = this.onChange) { | ||
const { allowCopy, label, error, hint, min, max, readOnly } = this.props; | ||
const { allowCopy, className, label, error, hint, min, max, readOnly } = this.props; | ||
const param = this.getParam(); | ||
|
||
const realValue = value | ||
? (new BigNumber(value))[readOnly ? 'toFormat' : 'toNumber']() | ||
? this.getNumberValue(value)[readOnly ? 'toFormat' : 'toNumber']() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will probably break when There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well it checks if |
||
: value; | ||
|
||
return ( | ||
<Input | ||
allowCopy={ allowCopy } | ||
className={ className } | ||
label={ label } | ||
hint={ hint } | ||
value={ realValue } | ||
|
@@ -269,16 +284,17 @@ export default class TypedInput extends Component { | |
* @see https://github.com/facebook/react/issues/1549 | ||
*/ | ||
renderFloat (value = this.props.value, onChange = this.onChange) { | ||
const { allowCopy, label, error, hint, min, max, readOnly } = this.props; | ||
const { allowCopy, className, label, error, hint, min, max, readOnly } = this.props; | ||
const param = this.getParam(); | ||
|
||
const realValue = value | ||
? (new BigNumber(value))[readOnly ? 'toFormat' : 'toNumber']() | ||
? this.getNumberValue(value)[readOnly ? 'toFormat' : 'toNumber']() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same breakage comment here since the function may return something without toFormat/toNumber There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above |
||
: value; | ||
|
||
return ( | ||
<Input | ||
allowCopy={ allowCopy } | ||
className={ className } | ||
label={ label } | ||
hint={ hint } | ||
value={ realValue } | ||
|
@@ -293,11 +309,12 @@ export default class TypedInput extends Component { | |
} | ||
|
||
renderDefault () { | ||
const { allowCopy, label, value, error, hint, readOnly } = this.props; | ||
const { allowCopy, className, label, value, error, hint, readOnly } = this.props; | ||
|
||
return ( | ||
<Input | ||
allowCopy={ allowCopy } | ||
className={ className } | ||
label={ label } | ||
hint={ hint } | ||
value={ value } | ||
|
@@ -309,12 +326,13 @@ export default class TypedInput extends Component { | |
} | ||
|
||
renderAddress () { | ||
const { accounts, allowCopy, label, value, error, hint, readOnly } = this.props; | ||
const { accounts, allowCopy, className, label, value, error, hint, readOnly } = this.props; | ||
|
||
return ( | ||
<InputAddressSelect | ||
allowCopy={ allowCopy } | ||
accounts={ accounts } | ||
className={ className } | ||
error={ error } | ||
hint={ hint } | ||
label={ label } | ||
|
@@ -326,7 +344,7 @@ export default class TypedInput extends Component { | |
} | ||
|
||
renderBoolean () { | ||
const { allowCopy, label, value, error, hint, readOnly } = this.props; | ||
const { allowCopy, className, label, value, error, hint, readOnly } = this.props; | ||
|
||
if (readOnly) { | ||
return this.renderDefault(); | ||
|
@@ -346,6 +364,7 @@ export default class TypedInput extends Component { | |
return ( | ||
<Select | ||
allowCopy={ allowCopy } | ||
className={ className } | ||
error={ error } | ||
hint={ hint } | ||
label={ label } | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we just add a relevant test that verifies both behaviours? (these should be one that just verifies the original)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done