diff options
author | Fabio Berger <me@fabioberger.com> | 2018-05-10 23:08:07 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-05-10 23:08:07 +0800 |
commit | cd5f00ac4d41221c99eb8ce767e63e09a6de6a11 (patch) | |
tree | 2b1865b5fa6ef86965ea753c032ffaba48403921 /packages/deployer/src/deployer.ts | |
parent | 23c4027c83b9f30fad352615386b988084f8b39f (diff) | |
parent | c64ad1af28ef116e210aafb3ea6ad2138361cd7c (diff) | |
download | dexon-sol-tools-cd5f00ac4d41221c99eb8ce767e63e09a6de6a11.tar dexon-sol-tools-cd5f00ac4d41221c99eb8ce767e63e09a6de6a11.tar.gz dexon-sol-tools-cd5f00ac4d41221c99eb8ce767e63e09a6de6a11.tar.bz2 dexon-sol-tools-cd5f00ac4d41221c99eb8ce767e63e09a6de6a11.tar.lz dexon-sol-tools-cd5f00ac4d41221c99eb8ce767e63e09a6de6a11.tar.xz dexon-sol-tools-cd5f00ac4d41221c99eb8ce767e63e09a6de6a11.tar.zst dexon-sol-tools-cd5f00ac4d41221c99eb8ce767e63e09a6de6a11.zip |
Merge branch 'development' into breakUp0xjs
* development: (38 commits)
Add fallback image support to relayer grid tile
Clear relayer grid state when fetching
Configure the compiler to generate artifacts with deployedBytecode
Implement loading and error state for relayer grid
Fallback image for relayer grid tile
Change relayer grid tile to link on header
Display top tokens from backend
Remove overflowZ property from portal
Suggestions and fix bad merge
Fix typo
Only show untracked tokens
Make wallet scrollable
Add token flow
Update The Ocean logo
Fix artifacts paths
Create an artifacts folder
Introduce a var
Add removeHexPrefix util method
CHeck if ABI exists
Improve the readability of the check for should compile
...
# Conflicts:
# .gitignore
# packages/contracts/test/multi_sig_with_time_lock.ts
# packages/contracts/test/multi_sig_with_time_lock_except_remove_auth_addr.ts
# packages/contracts/util/artifacts.ts
Diffstat (limited to 'packages/deployer/src/deployer.ts')
-rw-r--r-- | packages/deployer/src/deployer.ts | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/packages/deployer/src/deployer.ts b/packages/deployer/src/deployer.ts index ad05417b1..c8c3a9a06 100644 --- a/packages/deployer/src/deployer.ts +++ b/packages/deployer/src/deployer.ts @@ -2,6 +2,7 @@ import { AbiType, ConstructorAbi, ContractAbi, Provider, TxData } from '@0xproje import { logUtils } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import * as _ from 'lodash'; +import * as solc from 'solc'; import * as Web3 from 'web3'; import { Contract } from './utils/contract'; @@ -28,7 +29,20 @@ export class Deployer { private _artifactsDir: string; private _networkId: number; private _defaults: Partial<TxData>; - + /** + * Gets data for current version stored in artifact. + * @param contractArtifact The contract artifact. + * @return Version specific contract data. + */ + private static _getContractCompilerOutputFromArtifactIfExists( + contractArtifact: ContractArtifact, + ): solc.StandardContractOutput { + const compilerOutputIfExists = contractArtifact.compilerOutput; + if (_.isUndefined(compilerOutputIfExists)) { + throw new Error(`Compiler output not found in artifact for contract: ${contractArtifact.contractName}`); + } + return compilerOutputIfExists; + } /** * Instantiate a new instance of the Deployer class. * @param opts Deployer options, including either an RPC url or Provider instance. @@ -58,10 +72,8 @@ export class Deployer { */ public async deployAsync(contractName: string, args: any[] = []): Promise<Web3.ContractInstance> { const contractArtifactIfExists: ContractArtifact = this._loadContractArtifactIfExists(contractName); - const contractNetworkDataIfExists: ContractNetworkData = this._getContractNetworkDataFromArtifactIfExists( - contractArtifactIfExists, - ); - const data = contractNetworkDataIfExists.bytecode; + const compilerOutput = Deployer._getContractCompilerOutputFromArtifactIfExists(contractArtifactIfExists); + const data = compilerOutput.evm.bytecode.object; const from = await this._getFromAddressAsync(); const gas = await this._getAllowableGasEstimateAsync(data); const txData = { @@ -70,7 +82,10 @@ export class Deployer { data, gas, }; - const abi = contractNetworkDataIfExists.abi; + if (_.isUndefined(compilerOutput.abi)) { + throw new Error(`ABI not found in ${contractName} artifacts`); + } + const abi = compilerOutput.abi; const constructorAbi = _.find(abi, { type: AbiType.Constructor }) as ConstructorAbi; const constructorArgs = _.isUndefined(constructorAbi) ? [] : constructorAbi.inputs; if (constructorArgs.length !== args.length) { @@ -138,15 +153,16 @@ export class Deployer { args: any[], ): Promise<void> { const contractArtifactIfExists: ContractArtifact = this._loadContractArtifactIfExists(contractName); - const contractNetworkDataIfExists: ContractNetworkData = this._getContractNetworkDataFromArtifactIfExists( - contractArtifactIfExists, - ); - const abi = contractNetworkDataIfExists.abi; + const compilerOutput = Deployer._getContractCompilerOutputFromArtifactIfExists(contractArtifactIfExists); + if (_.isUndefined(compilerOutput.abi)) { + throw new Error(`ABI not found in ${contractName} artifacts`); + } + const abi = compilerOutput.abi; const encodedConstructorArgs = encoder.encodeConstructorArgsFromAbi(args, abi); - const newContractData = { - ...contractNetworkDataIfExists, + const newContractData: ContractNetworkData = { address: contractAddress, - constructor_args: encodedConstructorArgs, + links: {}, + constructorArgs: encodedConstructorArgs, }; const newArtifact = { ...contractArtifactIfExists, @@ -174,18 +190,6 @@ export class Deployer { } } /** - * Gets data for current networkId stored in artifact. - * @param contractArtifact The contract artifact. - * @return Network specific contract data. - */ - 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 contractNetworkDataIfExists; - } - /** * Gets the address to use for sending a transaction. * @return The default from address. If not specified, returns the first address accessible by web3. */ |