aboutsummaryrefslogtreecommitdiffstats
path: root/packages/deployer/src/deployer.ts
diff options
context:
space:
mode:
authorAmir Bandeali <abandeali1@gmail.com>2018-02-21 05:42:35 +0800
committerAmir Bandeali <abandeali1@gmail.com>2018-02-21 05:42:35 +0800
commit67f28645018244a0aeda6404b7fd4ea33c67110f (patch)
tree279762a8fd99743e2060769147abd4531252ac4d /packages/deployer/src/deployer.ts
parentc1bbcaba73b1798d5e336492acc00cfa300fc05f (diff)
downloaddexon-0x-contracts-67f28645018244a0aeda6404b7fd4ea33c67110f.tar.gz
dexon-0x-contracts-67f28645018244a0aeda6404b7fd4ea33c67110f.tar.zst
dexon-0x-contracts-67f28645018244a0aeda6404b7fd4ea33c67110f.zip
Address feedback
Diffstat (limited to 'packages/deployer/src/deployer.ts')
-rw-r--r--packages/deployer/src/deployer.ts32
1 files changed, 18 insertions, 14 deletions
diff --git a/packages/deployer/src/deployer.ts b/packages/deployer/src/deployer.ts
index b14401050..021645fd1 100644
--- a/packages/deployer/src/deployer.ts
+++ b/packages/deployer/src/deployer.ts
@@ -35,9 +35,11 @@ export class Deployer {
* @return Deployed contract instance.
*/
public async deployAsync(contractName: string, args: any[] = []): Promise<Web3.ContractInstance> {
- const contractArtifact: ContractArtifact = this._loadContractArtifactIfExists(contractName);
- const contractData: ContractNetworkData = this._getContractDataFromArtifactIfExists(contractArtifact);
- const data = contractData.unlinked_binary;
+ const contractArtifactIfExists: ContractArtifact = this._loadContractArtifactIfExists(contractName);
+ const contractNetworkDataIfExists: ContractNetworkData = this._getContractNetworkDataFromArtifactIfExists(
+ contractArtifactIfExists,
+ );
+ const data = contractNetworkDataIfExists.unlinked_binary;
const from = await this._getFromAddressAsync();
const gas = await this._getAllowableGasEstimateAsync(data);
const txData = {
@@ -46,7 +48,7 @@ export class Deployer {
data,
gas,
};
- const abi = contractData.abi;
+ const abi = contractNetworkDataIfExists.abi;
const web3ContractInstance = await this._deployFromAbiAsync(abi, args, txData);
utils.consoleLog(`${contractName}.sol successfully deployed at ${web3ContractInstance.address}`);
const contractInstance = new Contract(web3ContractInstance, this._defaults);
@@ -100,19 +102,21 @@ export class Deployer {
contractAddress: string,
args: any[],
): Promise<void> {
- const contractArtifact: ContractArtifact = this._loadContractArtifactIfExists(contractName);
- const contractData: ContractNetworkData = this._getContractDataFromArtifactIfExists(contractArtifact);
- const abi = contractData.abi;
+ const contractArtifactIfExists: ContractArtifact = this._loadContractArtifactIfExists(contractName);
+ const contractNetworkDataIfExists: ContractNetworkData = this._getContractNetworkDataFromArtifactIfExists(
+ contractArtifactIfExists,
+ );
+ const abi = contractNetworkDataIfExists.abi;
const encodedConstructorArgs = encoder.encodeConstructorArgsFromAbi(args, abi);
const newContractData = {
- ...contractData,
+ ...contractNetworkDataIfExists,
address: contractAddress,
constructor_args: encodedConstructorArgs,
};
const newArtifact = {
- ...contractArtifact,
+ ...contractArtifactIfExists,
networks: {
- ...contractArtifact.networks,
+ ...contractArtifactIfExists.networks,
[this._networkId]: newContractData,
},
};
@@ -139,12 +143,12 @@ export class Deployer {
* @param contractArtifact The contract artifact.
* @return Network specific contract data.
*/
- private _getContractDataFromArtifactIfExists(contractArtifact: ContractArtifact): ContractNetworkData {
- const contractData = contractArtifact.networks[this._networkId];
- if (_.isUndefined(contractData)) {
+ private _getContractNetworkDataFromArtifactIfExists(contractArtifact: ContractArtifact): ContractNetworkData {
+ const contractNetworkDataIfExists = contractArtifact.networks[this._networkId];
+ if (_.isUndefined(contractNetworkDataIfExists)) {
throw new Error(`Data not found in artifact for contract: ${contractArtifact.contract_name}`);
}
- return contractData;
+ return contractNetworkDataIfExists;
}
/**
* Gets the address to use for sending a transaction.