Your contract has been deployed at
);
}
}
onDescriptionChange = (description) => {
this.setState({ description, descriptionError: null });
}
onFromAddressChange = (fromAddress) => {
const { api } = this.context;
const fromAddressError = api.util.isAddressValid(fromAddress)
? null
: 'a valid account as the contract owner needs to be selected';
this.setState({ fromAddress, fromAddressError });
}
onNameChange = (name) => {
this.setState(validateName(name));
}
onParamsChange = (params) => {
this.setState({ params });
}
onAbiChange = (abi) => {
const { api } = this.context;
this.setState(validateAbi(abi, api));
}
onCodeChange = (code) => {
const { api } = this.context;
this.setState(validateCode(code, api));
}
onDeployStart = () => {
const { api, store } = this.context;
const { abiParsed, code, description, name, params, fromAddress } = this.state;
const options = {
data: code,
from: fromAddress
};
this.setState({ step: 1 });
api
.newContract(abiParsed)
.deploy(options, params, this.onDeploymentState)
.then((address) => {
return Promise.all([
api.parity.setAccountName(address, name),
api.parity.setAccountMeta(address, {
abi: abiParsed,
contract: true,
timestamp: Date.now(),
deleted: false,
description
})
])
.then(() => {
console.log(`contract deployed at ${address}`);
this.setState({ step: 2, address });
});
})
.catch((error) => {
console.error('error deploying contract', error);
this.setState({ deployError: error });
store.dispatch({ type: 'newError', error });
});
}
onDeploymentState = (error, data) => {
if (error) {
console.error('onDeploymentState', error);
return;
}
console.log('onDeploymentState', data);
switch (data.state) {
case 'estimateGas':
case 'postTransaction':
this.setState({ deployState: 'Preparing transaction for network transmission' });
return;
case 'checkRequest':
this.setState({ deployState: 'Waiting for confirmation of the transaction in the Parity Secure Signer' });
return;
case 'getTransactionReceipt':
this.setState({ deployState: 'Waiting for the contract deployment transaction receipt', txhash: data.txhash });
return;
case 'hasReceipt':
case 'getCode':
this.setState({ deployState: 'Validating the deployed contract code' });
return;
case 'completed':
this.setState({ deployState: 'The contract deployment has been completed' });
return;
default:
console.error('Unknow contract deployment state', data);
return;
}
}
onClose = () => {
this.props.onClose();
}
}