Your contract has been deployed at
);
}
}
onParametersStep = () => {
const { inputs } = this.state;
if (inputs.length) {
return this.setState({ step: 'CONTRACT_PARAMETERS' });
}
return this.onDeployStart();
}
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 });
}
onInputsChange = (inputs) => {
this.setState({ inputs });
}
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 { source } = this.props;
const { abiParsed, code, description, name, params, fromAddress } = this.state;
const options = {
data: code,
from: fromAddress
};
this.setState({ step: 'DEPLOYMENT' });
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,
source,
description
})
])
.then(() => {
console.log(`contract deployed at ${address}`);
this.setState({ step: 'DEPLOYMENT', address });
});
})
.catch((error) => {
if (error.code === ERROR_CODES.REQUEST_REJECTED) {
this.setState({ rejected: true });
return false;
}
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;
}
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();
}
}