Rename variables
This commit is contained in:
parent
003e5da00d
commit
060b02eaed
@ -14,7 +14,7 @@ const DEFAULT_ARTIFACTS_DIR = path.resolve('artifacts');
|
|||||||
const DEFAULT_NETWORK_ID = 50;
|
const DEFAULT_NETWORK_ID = 50;
|
||||||
const DEFAULT_JSONRPC_PORT = 8545;
|
const DEFAULT_JSONRPC_PORT = 8545;
|
||||||
const DEFAULT_GAS_PRICE = (10 ** 9 * 2).toString();
|
const DEFAULT_GAS_PRICE = (10 ** 9 * 2).toString();
|
||||||
const DEFAULT_COMPILE_CONTRACTS = '*';
|
const DEFAULT_CONTRACTS_LIST = '*';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compiles all contracts with options passed in through CLI.
|
* Compiles all contracts with options passed in through CLI.
|
||||||
@ -26,7 +26,7 @@ async function onCompileCommand(argv: CliOptions): Promise<void> {
|
|||||||
networkId: argv.networkId,
|
networkId: argv.networkId,
|
||||||
optimizerEnabled: argv.shouldOptimize ? 1 : 0,
|
optimizerEnabled: argv.shouldOptimize ? 1 : 0,
|
||||||
artifactsDir: argv.artifactsDir,
|
artifactsDir: argv.artifactsDir,
|
||||||
contractsToCompile: generateContractsToCompileSet(argv.contracts),
|
specifiedContracts: getContractsSetFromList(argv.contracts),
|
||||||
};
|
};
|
||||||
await commands.compileAsync(opts);
|
await commands.compileAsync(opts);
|
||||||
}
|
}
|
||||||
@ -45,7 +45,7 @@ async function onMigrateCommand(argv: CliOptions): Promise<void> {
|
|||||||
networkId,
|
networkId,
|
||||||
optimizerEnabled: argv.shouldOptimize ? 1 : 0,
|
optimizerEnabled: argv.shouldOptimize ? 1 : 0,
|
||||||
artifactsDir: argv.artifactsDir,
|
artifactsDir: argv.artifactsDir,
|
||||||
contractsToCompile: generateContractsToCompileSet(argv.contracts),
|
specifiedContracts: getContractsSetFromList(argv.contracts),
|
||||||
};
|
};
|
||||||
await commands.compileAsync(compilerOpts);
|
await commands.compileAsync(compilerOpts);
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ async function onDeployCommand(argv: CliOptions): Promise<void> {
|
|||||||
networkId,
|
networkId,
|
||||||
optimizerEnabled: argv.shouldOptimize ? 1 : 0,
|
optimizerEnabled: argv.shouldOptimize ? 1 : 0,
|
||||||
artifactsDir: argv.artifactsDir,
|
artifactsDir: argv.artifactsDir,
|
||||||
contractsToCompile: generateContractsToCompileSet(argv.contracts),
|
specifiedContracts: getContractsSetFromList(argv.contracts),
|
||||||
};
|
};
|
||||||
await commands.compileAsync(compilerOpts);
|
await commands.compileAsync(compilerOpts);
|
||||||
|
|
||||||
@ -97,13 +97,13 @@ async function onDeployCommand(argv: CliOptions): Promise<void> {
|
|||||||
* Creates a set of contracts to compile.
|
* Creates a set of contracts to compile.
|
||||||
* @param contracts Comma separated list of contracts to compile
|
* @param contracts Comma separated list of contracts to compile
|
||||||
*/
|
*/
|
||||||
function generateContractsToCompileSet(contracts: string): Set<string> {
|
function getContractsSetFromList(contracts: string): Set<string> {
|
||||||
const contractsToCompile = new Set();
|
const specifiedContracts = new Set();
|
||||||
const contractsArray = contracts.split(',');
|
const contractsArray = contracts.split(',');
|
||||||
_.forEach(contractsArray, contractName => {
|
_.forEach(contractsArray, contractName => {
|
||||||
contractsToCompile.add(contractName);
|
specifiedContracts.add(contractName);
|
||||||
});
|
});
|
||||||
return contractsToCompile;
|
return specifiedContracts;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Provides extra required options for deploy command.
|
* Provides extra required options for deploy command.
|
||||||
@ -162,7 +162,7 @@ function deployCommandBuilder(yargsInstance: any) {
|
|||||||
})
|
})
|
||||||
.option('contracts', {
|
.option('contracts', {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: DEFAULT_COMPILE_CONTRACTS,
|
default: DEFAULT_CONTRACTS_LIST,
|
||||||
description: 'comma separated list of contracts to compile',
|
description: 'comma separated list of contracts to compile',
|
||||||
})
|
})
|
||||||
.command('compile', 'compile contracts', identityCommandBuilder, onCompileCommand)
|
.command('compile', 'compile contracts', identityCommandBuilder, onCompileCommand)
|
||||||
|
@ -26,7 +26,7 @@ export class Compiler {
|
|||||||
private _artifactsDir: string;
|
private _artifactsDir: string;
|
||||||
private _contractSourcesIfExists?: ContractSources;
|
private _contractSourcesIfExists?: ContractSources;
|
||||||
private _solcErrors: Set<string>;
|
private _solcErrors: Set<string>;
|
||||||
private _contractsToCompile: Set<string>;
|
private _specifiedContracts: Set<string>;
|
||||||
/**
|
/**
|
||||||
* Recursively retrieves Solidity source code from directory.
|
* Recursively retrieves Solidity source code from directory.
|
||||||
* @param dirPath Directory to search.
|
* @param dirPath Directory to search.
|
||||||
@ -108,7 +108,7 @@ export class Compiler {
|
|||||||
this._optimizerEnabled = opts.optimizerEnabled;
|
this._optimizerEnabled = opts.optimizerEnabled;
|
||||||
this._artifactsDir = opts.artifactsDir;
|
this._artifactsDir = opts.artifactsDir;
|
||||||
this._solcErrors = new Set();
|
this._solcErrors = new Set();
|
||||||
this._contractsToCompile = opts.contractsToCompile;
|
this._specifiedContracts = opts.specifiedContracts;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Compiles all Solidity files found in contractsDir and writes JSON artifacts to artifactsDir.
|
* Compiles all Solidity files found in contractsDir and writes JSON artifacts to artifactsDir.
|
||||||
@ -140,7 +140,7 @@ export class Compiler {
|
|||||||
const currentArtifactPath = `${this._artifactsDir}/${contractName}.json`;
|
const currentArtifactPath = `${this._artifactsDir}/${contractName}.json`;
|
||||||
const sourceHash = `0x${ethUtil.sha3(source).toString('hex')}`;
|
const sourceHash = `0x${ethUtil.sha3(source).toString('hex')}`;
|
||||||
const isContractSpecified =
|
const isContractSpecified =
|
||||||
this._contractsToCompile.has(ALL_CONTRACTS_IDENTIFIER) || this._contractsToCompile.has(contractName);
|
this._specifiedContracts.has(ALL_CONTRACTS_IDENTIFIER) || this._specifiedContracts.has(contractName);
|
||||||
|
|
||||||
let currentArtifactString: string;
|
let currentArtifactString: string;
|
||||||
let currentArtifact: ContractArtifact;
|
let currentArtifact: ContractArtifact;
|
||||||
|
@ -50,7 +50,7 @@ export interface CompilerOptions {
|
|||||||
networkId: number;
|
networkId: number;
|
||||||
optimizerEnabled: number;
|
optimizerEnabled: number;
|
||||||
artifactsDir: string;
|
artifactsDir: string;
|
||||||
contractsToCompile: Set<string>;
|
specifiedContracts: Set<string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DeployerOptions {
|
export interface DeployerOptions {
|
||||||
|
@ -18,7 +18,7 @@ const compilerOpts: CompilerOptions = {
|
|||||||
contractsDir,
|
contractsDir,
|
||||||
networkId: constants.networkId,
|
networkId: constants.networkId,
|
||||||
optimizerEnabled: constants.optimizerEnabled,
|
optimizerEnabled: constants.optimizerEnabled,
|
||||||
contractsToCompile: new Set(constants.contractsToCompile),
|
specifiedContracts: new Set(constants.specifiedContracts),
|
||||||
};
|
};
|
||||||
const compiler = new Compiler(compilerOpts);
|
const compiler = new Compiler(compilerOpts);
|
||||||
const deployerOpts = {
|
const deployerOpts = {
|
||||||
|
@ -8,5 +8,5 @@ export const constants = {
|
|||||||
timeoutMs: 20000,
|
timeoutMs: 20000,
|
||||||
zrxTokenAddress: '0xe41d2489571d322189246dafa5ebde1f4699f498',
|
zrxTokenAddress: '0xe41d2489571d322189246dafa5ebde1f4699f498',
|
||||||
tokenTransferProxyAddress: '0x8da0d80f5007ef1e431dd2127178d224e32c2ef4',
|
tokenTransferProxyAddress: '0x8da0d80f5007ef1e431dd2127178d224e32c2ef4',
|
||||||
contractsToCompile: '*',
|
specifiedContracts: '*',
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user