Fix wrong transaction input for contract deployments (#4052)

* Fix mutable options in Contract API

* Add Swarm hash and meta data from Solidity

* Updates tests for contract deployment

* Add test for deploy without constructor Params
This commit is contained in:
Nicolas Gotchac
2017-01-06 10:39:18 +01:00
committed by Gav Wood
parent 1b93d79a90
commit 9ab9ff2381
3 changed files with 119 additions and 14 deletions

View File

@@ -458,23 +458,65 @@ class WriteContract extends Component {
const { bytecode } = contract;
const abi = contract.interface;
const metadata = contract.metadata
? (
<Input
allowCopy
label='Metadata'
readOnly
value={ contract.metadata }
/>
)
: null;
return (
<div>
<Input
allowCopy
label='ABI Interface'
readOnly
value={ abi }
label='ABI Interface'
/>
<Input
allowCopy
label='Bytecode'
readOnly
value={ `0x${bytecode}` }
label='Bytecode'
/>
{ metadata }
{ this.renderSwarmHash(contract) }
</div>
);
}
renderSwarmHash (contract) {
if (!contract || !contract.metadata) {
return null;
}
const { bytecode } = contract;
// @see https://solidity.readthedocs.io/en/develop/miscellaneous.html#encoding-of-the-metadata-hash-in-the-bytecode
const hashRegex = /a165627a7a72305820([a-f0-9]{64})0029$/;
if (!hashRegex.test(bytecode)) {
return null;
}
const hash = hashRegex.exec(bytecode)[1];
return (
<Input
allowCopy
label='Swarm Metadata Hash'
readOnly
value={ `${hash}` }
/>
);
}
renderErrors () {
const { annotations } = this.store;