diff options
author | Fabio Berger <me@fabioberger.com> | 2018-02-26 10:32:12 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-02-26 10:32:12 +0800 |
commit | fffaafe4c996ac0c458dd6cb9e3598b1d93b7aa4 (patch) | |
tree | 21f9398ba2975bda4706fb8f54c0c717b88ecfd4 /packages/deployer/src/deployer.ts | |
parent | 66b36f6d8f7c0f0487e53badb035ac50e1ec5669 (diff) | |
parent | 709fa9e02ec21cee9fc145b4a578742c8dd190aa (diff) | |
download | dexon-sol-tools-fffaafe4c996ac0c458dd6cb9e3598b1d93b7aa4.tar dexon-sol-tools-fffaafe4c996ac0c458dd6cb9e3598b1d93b7aa4.tar.gz dexon-sol-tools-fffaafe4c996ac0c458dd6cb9e3598b1d93b7aa4.tar.bz2 dexon-sol-tools-fffaafe4c996ac0c458dd6cb9e3598b1d93b7aa4.tar.lz dexon-sol-tools-fffaafe4c996ac0c458dd6cb9e3598b1d93b7aa4.tar.xz dexon-sol-tools-fffaafe4c996ac0c458dd6cb9e3598b1d93b7aa4.tar.zst dexon-sol-tools-fffaafe4c996ac0c458dd6cb9e3598b1d93b7aa4.zip |
Merge branch 'development' into moveOutDocGenerator
* development: (36 commits)
Fix english translations
Fix footer on mobile
re-add google analytics code
Fix Russian translation
Move all dependencies on @0xproject/types out of devDependencies
Slight improvement to footer
Fix a few Korean translations
Address feedback
Use source tree hash instead of compile flag
Fix race condition
Update CHANGELOG
Delete artifacts directory
Add generated contract artifacts to gitignore
Check dependencies when determining if should be recompiled
Update CHANGELOG
Remove unused CHANGELOG entry
Remove unused import
Change assert.doesConformToShema interface
Remove a type assertion
Publish
...
Diffstat (limited to 'packages/deployer/src/deployer.ts')
-rw-r--r-- | packages/deployer/src/deployer.ts | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/packages/deployer/src/deployer.ts b/packages/deployer/src/deployer.ts index 6f03581e8..021645fd1 100644 --- a/packages/deployer/src/deployer.ts +++ b/packages/deployer/src/deployer.ts @@ -6,7 +6,7 @@ import * as Web3 from 'web3'; import { Contract } from './utils/contract'; import { encoder } from './utils/encoder'; import { fsWrapper } from './utils/fs_wrapper'; -import { ContractArtifact, ContractData, DeployerOptions } from './utils/types'; +import { ContractArtifact, ContractNetworkData, DeployerOptions } from './utils/types'; import { utils } from './utils/utils'; // Gas added to gas estimate to make sure there is sufficient gas for deployment. @@ -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: ContractData = 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: ContractData = 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): ContractData { - 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. |