ABI can be empty and auto-fill contract name #3511
This commit is contained in:
		
							parent
							
								
									55a3da8f0a
								
							
						
					
					
						commit
						8fc1506c57
					
				@ -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}`;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -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 };
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user