ABI can be empty and auto-fill contract name #3511

This commit is contained in:
Nicolas Gotchac 2016-11-18 17:54:25 +01:00
parent 55a3da8f0a
commit 8fc1506c57
2 changed files with 6 additions and 2 deletions

View File

@ -103,7 +103,7 @@ export default class DetailsStep extends Component {
label='contract name' label='contract name'
hint='a name for the deployed contract' hint='a name for the deployed contract'
error={ nameError } error={ nameError }
value={ name } value={ name || '' }
onChange={ this.onNameChange } /> onChange={ this.onNameChange } />
<Input <Input
@ -169,6 +169,10 @@ export default class DetailsStep extends Component {
const contractName = Object.keys(contracts)[index]; const contractName = Object.keys(contracts)[index];
const contract = contracts[contractName]; const contract = contracts[contractName];
if (!this.props.name || this.props.name.trim() === '') {
this.onNameChange(null, contractName);
}
const { abi, bin } = contract; const { abi, bin } = contract;
const code = /^0x/.test(bin) ? bin : `0x${bin}`; const code = /^0x/.test(bin) ? bin : `0x${bin}`;

View File

@ -37,7 +37,7 @@ export function validateAbi (abi, api) {
try { try {
abiParsed = JSON.parse(abi); abiParsed = JSON.parse(abi);
if (!api.util.isArray(abiParsed) || !abiParsed.length) { if (!api.util.isArray(abiParsed)) {
abiError = ERRORS.invalidAbi; abiError = ERRORS.invalidAbi;
return { abi, abiError, abiParsed }; return { abi, abiError, abiParsed };
} }