-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Fix Wallet Settings Modal #3856
Changes from all commits
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 |
---|---|---|
|
@@ -26,30 +26,33 @@ import { fromWei, toWei } from '~/api/util/wei'; | |
import Input from '~/ui/Form/Input'; | ||
import InputAddressSelect from '~/ui/Form/InputAddressSelect'; | ||
import Select from '~/ui/Form/Select'; | ||
import { ABI_TYPES } from '~/util/abi'; | ||
import { ABI_TYPES, parseAbiType } from '~/util/abi'; | ||
|
||
import styles from './typedInput.css'; | ||
|
||
export default class TypedInput extends Component { | ||
|
||
static propTypes = { | ||
onChange: PropTypes.func.isRequired, | ||
param: PropTypes.object.isRequired, | ||
|
||
accounts: PropTypes.object, | ||
error: PropTypes.any, | ||
value: PropTypes.any, | ||
label: PropTypes.string, | ||
hint: PropTypes.string, | ||
min: PropTypes.number, | ||
isEth: PropTypes.bool, | ||
label: PropTypes.string, | ||
max: PropTypes.number, | ||
isEth: PropTypes.bool | ||
min: PropTypes.number, | ||
param: PropTypes.oneOfType([ | ||
PropTypes.object, | ||
PropTypes.string | ||
]).isRequired, | ||
value: PropTypes.any | ||
}; | ||
|
||
static defaultProps = { | ||
min: null, | ||
max: null, | ||
isEth: false | ||
isEth: null | ||
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. Null for bool? Going to run into issues again, need to stop doing tri-states. 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. Alternatively just fix the PropTypes to be explicit on what it required, null or bool 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. Ah yes missed that one. The idea is just that by default it's using the given param, but if |
||
}; | ||
|
||
state = { | ||
|
@@ -64,7 +67,26 @@ export default class TypedInput extends Component { | |
} | ||
|
||
render () { | ||
const { param, isEth } = this.props; | ||
const { param } = this.props; | ||
|
||
if (typeof param === 'string') { | ||
const parsedParam = parseAbiType(param); | ||
|
||
if (parsedParam) { | ||
return this.renderParam(parsedParam); | ||
} | ||
} | ||
|
||
if (param) { | ||
return this.renderParam(param); | ||
} | ||
|
||
console.error('<TypedInput>', `unkown "${param}" param passed to props`); | ||
return null; | ||
} | ||
|
||
renderParam (param) { | ||
const { isEth } = this.props; | ||
const { type } = param; | ||
|
||
if (type === ABI_TYPES.ARRAY) { | ||
|
@@ -163,7 +185,16 @@ export default class TypedInput extends Component { | |
return this.renderDefault(); | ||
} | ||
|
||
// If the `isEth` prop is present (true or false) | ||
// then render the ETH toggle (usefull for contract execution) | ||
// Don't by default | ||
if (type === ABI_TYPES.INT) { | ||
const { isEth } = this.props; | ||
|
||
if (typeof isEth !== 'boolean') { | ||
return this.renderInteger(); | ||
} | ||
|
||
return this.renderEth(); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,4 +143,7 @@ export function parseAbiType (type) { | |
signed: true | ||
}; | ||
} | ||
|
||
// If no matches, return null | ||
return null; | ||
} |
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.
Would have been good to just order here, however not a crisis.