diff options
author | Fabio Berger <me@fabioberger.com> | 2018-04-02 03:28:29 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-04-02 03:28:29 +0800 |
commit | c6f85464ced3cecb2a4a5b3b79a19b6fd56c8a58 (patch) | |
tree | c5dbda13f35991df12dbc3bc36d9a985f3b6777e | |
parent | 0e33f45f3dbf7934692e3baa3daa90ddab0c184f (diff) | |
parent | a220b56736bcacfcce045329c99091af5932e723 (diff) | |
download | dexon-sol-tools-c6f85464ced3cecb2a4a5b3b79a19b6fd56c8a58.tar dexon-sol-tools-c6f85464ced3cecb2a4a5b3b79a19b6fd56c8a58.tar.gz dexon-sol-tools-c6f85464ced3cecb2a4a5b3b79a19b6fd56c8a58.tar.bz2 dexon-sol-tools-c6f85464ced3cecb2a4a5b3b79a19b6fd56c8a58.tar.lz dexon-sol-tools-c6f85464ced3cecb2a4a5b3b79a19b6fd56c8a58.tar.xz dexon-sol-tools-c6f85464ced3cecb2a4a5b3b79a19b6fd56c8a58.tar.zst dexon-sol-tools-c6f85464ced3cecb2a4a5b3b79a19b6fd56c8a58.zip |
Merge branch 'development' into refactor/publishProcess
* development:
Run prettier, update deployer CHANGELOG
Create solc_bin dir if does not exist before attempting to compile
Add missing type import
-rw-r--r-- | packages/0x.js/src/0x.ts | 10 | ||||
-rw-r--r-- | packages/0x.js/src/order_watcher/event_watcher.ts | 6 | ||||
-rw-r--r-- | packages/0x.js/src/order_watcher/order_state_watcher.ts | 10 | ||||
-rw-r--r-- | packages/0x.js/test/order_state_watcher_test.ts | 4 | ||||
-rw-r--r-- | packages/contracts/package.json | 3 | ||||
-rw-r--r-- | packages/deployer/CHANGELOG.md | 4 | ||||
-rw-r--r-- | packages/deployer/src/compiler.ts | 8 | ||||
-rw-r--r-- | packages/deployer/src/utils/compiler.ts | 12 | ||||
-rw-r--r-- | packages/deployer/test/compiler_utils_test.ts | 6 |
9 files changed, 31 insertions, 32 deletions
diff --git a/packages/0x.js/src/0x.ts b/packages/0x.js/src/0x.ts index 7627f1d6e..b82cc820f 100644 --- a/packages/0x.js/src/0x.ts +++ b/packages/0x.js/src/0x.ts @@ -15,7 +15,7 @@ import { OrderStateWatcher } from './order_watcher/order_state_watcher'; import { zeroExConfigSchema } from './schemas/zero_ex_config_schema'; import { zeroExPrivateNetworkConfigSchema } from './schemas/zero_ex_private_network_config_schema'; import { zeroExPublicNetworkConfigSchema } from './schemas/zero_ex_public_network_config_schema'; -import { OrderStateWatcherConfig, ZeroExConfig, ZeroExError } from './types'; +import { OrderStateWatcherConfig, Web3Provider, ZeroExConfig, ZeroExError } from './types'; import { assert } from './utils/assert'; import { constants } from './utils/constants'; import { decorators } from './utils/decorators'; @@ -331,13 +331,7 @@ export class ZeroEx { * @return An instance of the 0x.js OrderStateWatcher class. */ public createOrderStateWatcher(config?: OrderStateWatcherConfig) { - return new OrderStateWatcher( - this._web3Wrapper, - this._abiDecoder, - this.token, - this.exchange, - config, - ); + return new OrderStateWatcher(this._web3Wrapper, this._abiDecoder, this.token, this.exchange, config); } /* * HACK: `TokenWrapper` needs a token transfer proxy address. `TokenTransferProxy` address is fetched from diff --git a/packages/0x.js/src/order_watcher/event_watcher.ts b/packages/0x.js/src/order_watcher/event_watcher.ts index d01542a8c..47bbd5b2e 100644 --- a/packages/0x.js/src/order_watcher/event_watcher.ts +++ b/packages/0x.js/src/order_watcher/event_watcher.ts @@ -23,7 +23,11 @@ export class EventWatcher { private _intervalIdIfExists?: NodeJS.Timer; private _lastEvents: LogEntry[] = []; private _stateLayer: BlockParamLiteral; - constructor(web3Wrapper: Web3Wrapper, pollingIntervalIfExistsMs: undefined | number, stateLayer: BlockParamLiteral = BlockParamLiteral.Latest) { + constructor( + web3Wrapper: Web3Wrapper, + pollingIntervalIfExistsMs: undefined | number, + stateLayer: BlockParamLiteral = BlockParamLiteral.Latest, + ) { this._web3Wrapper = web3Wrapper; this._stateLayer = stateLayer; this._pollingIntervalMs = _.isUndefined(pollingIntervalIfExistsMs) diff --git a/packages/0x.js/src/order_watcher/order_state_watcher.ts b/packages/0x.js/src/order_watcher/order_state_watcher.ts index bfd250e21..cd6016c5a 100644 --- a/packages/0x.js/src/order_watcher/order_state_watcher.ts +++ b/packages/0x.js/src/order_watcher/order_state_watcher.ts @@ -86,14 +86,10 @@ export class OrderStateWatcher { this._abiDecoder = abiDecoder; this._web3Wrapper = web3Wrapper; const pollingIntervalIfExistsMs = _.isUndefined(config) ? undefined : config.eventPollingIntervalMs; - const stateLayer = _.isUndefined(config) || _.isUndefined(config.stateLayer) - ? BlockParamLiteral.Latest - : config.stateLayer; + const stateLayer = + _.isUndefined(config) || _.isUndefined(config.stateLayer) ? BlockParamLiteral.Latest : config.stateLayer; this._eventWatcher = new EventWatcher(web3Wrapper, pollingIntervalIfExistsMs, stateLayer); - this._balanceAndProxyAllowanceLazyStore = new BalanceAndProxyAllowanceLazyStore( - token, - stateLayer, - ); + this._balanceAndProxyAllowanceLazyStore = new BalanceAndProxyAllowanceLazyStore(token, stateLayer); this._orderFilledCancelledLazyStore = new OrderFilledCancelledLazyStore(exchange); this._orderStateUtils = new OrderStateUtils( this._balanceAndProxyAllowanceLazyStore, diff --git a/packages/0x.js/test/order_state_watcher_test.ts b/packages/0x.js/test/order_state_watcher_test.ts index 4f727d495..4210e013f 100644 --- a/packages/0x.js/test/order_state_watcher_test.ts +++ b/packages/0x.js/test/order_state_watcher_test.ts @@ -15,9 +15,7 @@ import { ZeroEx, ZeroExError, } from '../src'; -import { - OrderStateWatcher, -} from '../src/order_watcher/order_state_watcher'; +import { OrderStateWatcher } from '../src/order_watcher/order_state_watcher'; import { DoneCallback } from '../src/types'; import { chaiSetup } from './utils/chai_setup'; diff --git a/packages/contracts/package.json b/packages/contracts/package.json index 0c931344d..26e99e7b5 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -18,7 +18,7 @@ "compile:comment": "Yarn workspaces do not link binaries correctly so we need to reference them directly https://github.com/yarnpkg/yarn/issues/3846", "compile": "node ../deployer/lib/src/cli.js compile --contracts ${npm_package_config_contracts} --contracts-dir src/contracts --artifacts-dir src/artifacts", "clean": "shx rm -rf ./lib", - "generate_contract_wrappers": "node ../abi-gen/lib/index.js --abis 'src/artifacts/@(DummyToken|TokenTransferProxy|Exchange|TokenRegistry|MultiSigWallet|MultiSigWalletWithTimeLock|MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress|TokenRegistry|ZRXToken|Arbitrage|EtherDelta|AccountLevels).json' --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated --backend ethers && prettier --write 'src/contract_wrappers/generated/**.ts'", + "generate_contract_wrappers": "node ../abi-gen/lib/index.js --abis ${npm_package_config_abis} --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated --backend ethers && prettier --write 'src/contract_wrappers/generated/**.ts'", "migrate": "yarn build && yarn compile && node ./lib/migrations/index.js", "lint": "tslint --project . 'migrations/**/*.ts' 'test/**/*.ts' 'util/**/*.ts' 'deploy/**/*.ts'", "coverage:report:text": "istanbul report text", @@ -27,6 +27,7 @@ "test:circleci": "yarn test:coverage" }, "config": { + "abis": "src/artifacts/@(DummyToken|TokenTransferProxy|Exchange|TokenRegistry|MultiSigWallet|MultiSigWalletWithTimeLock|MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress|TokenRegistry|ZRXToken|Arbitrage|EtherDelta|AccountLevels).json", "contracts": "Exchange,DummyToken,ZRXToken,Token,WETH9,TokenTransferProxy,MultiSigWallet,MultiSigWalletWithTimeLock,MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress,MaliciousToken,TokenRegistry,Arbitrage,EtherDelta,AccountLevels" }, "repository": { diff --git a/packages/deployer/CHANGELOG.md b/packages/deployer/CHANGELOG.md index 7d2a0f5e8..ecc8867b9 100644 --- a/packages/deployer/CHANGELOG.md +++ b/packages/deployer/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## v0.3.2 - _TBD_ + + * Create solc_bin directory if does not exist before attempting to compile (#491) + ## v0.3.1 - _March 18, 2018_ * Add TS types for `yargs` diff --git a/packages/deployer/src/compiler.ts b/packages/deployer/src/compiler.ts index 4741a9086..219a55c32 100644 --- a/packages/deployer/src/compiler.ts +++ b/packages/deployer/src/compiler.ts @@ -11,7 +11,7 @@ import solc = require('solc'); import { binPaths } from './solc/bin_paths'; import { - createArtifactsDirIfDoesNotExistAsync, + createDirIfDoesNotExistAsync, findImportIfExist, getContractArtifactIfExistsAsync, getNormalizedErrMsg, @@ -32,6 +32,7 @@ import { import { utils } from './utils/utils'; const ALL_CONTRACTS_IDENTIFIER = '*'; +const SOLC_BIN_DIR = path.join(__dirname, '..', '..', 'solc_bin'); /** * The Compiler facilitates compiling Solidity smart contracts and saves the results @@ -103,7 +104,8 @@ export class Compiler { * Compiles selected Solidity files found in `contractsDir` and writes JSON artifacts to `artifactsDir`. */ public async compileAsync(): Promise<void> { - await createArtifactsDirIfDoesNotExistAsync(this._artifactsDir); + await createDirIfDoesNotExistAsync(this._artifactsDir); + await createDirIfDoesNotExistAsync(SOLC_BIN_DIR); this._contractSources = await Compiler._getContractSourcesAsync(this._contractsDir); _.forIn(this._contractSources, this._setContractSpecificSourceData.bind(this)); const fileNames = this._specifiedContracts.has(ALL_CONTRACTS_IDENTIFIER) @@ -147,7 +149,7 @@ export class Compiler { contractSpecificSourceData.solcVersionRange, ); const fullSolcVersion = binPaths[solcVersion]; - const compilerBinFilename = path.join(__dirname, '../../solc_bin', fullSolcVersion); + const compilerBinFilename = path.join(SOLC_BIN_DIR, fullSolcVersion); let solcjs: string; const isCompilerAvailableLocally = fs.existsSync(compilerBinFilename); if (isCompilerAvailableLocally) { diff --git a/packages/deployer/src/utils/compiler.ts b/packages/deployer/src/utils/compiler.ts index 9c8fef26d..d5137d394 100644 --- a/packages/deployer/src/utils/compiler.ts +++ b/packages/deployer/src/utils/compiler.ts @@ -34,13 +34,13 @@ export async function getContractArtifactIfExistsAsync( } /** - * Creates the artifacts directory if it does not already exist. - * @param artifactsDir Path to the artifacts directory. + * Creates a directory if it does not already exist. + * @param artifactsDir Path to the directory. */ -export async function createArtifactsDirIfDoesNotExistAsync(artifactsDir: string): Promise<void> { - if (!fsWrapper.doesPathExistSync(artifactsDir)) { - logUtils.log('Creating artifacts directory...'); - await fsWrapper.mkdirAsync(artifactsDir); +export async function createDirIfDoesNotExistAsync(dirPath: string): Promise<void> { + if (!fsWrapper.doesPathExistSync(dirPath)) { + logUtils.log(`Creating directory at ${dirPath}...`); + await fsWrapper.mkdirAsync(dirPath); } } diff --git a/packages/deployer/test/compiler_utils_test.ts b/packages/deployer/test/compiler_utils_test.ts index 1867177dc..246304858 100644 --- a/packages/deployer/test/compiler_utils_test.ts +++ b/packages/deployer/test/compiler_utils_test.ts @@ -3,7 +3,7 @@ import * as dirtyChai from 'dirty-chai'; import 'mocha'; import { - createArtifactsDirIfDoesNotExistAsync, + createDirIfDoesNotExistAsync, getNormalizedErrMsg, parseDependencies, parseSolidityVersionRange, @@ -21,11 +21,11 @@ describe('Compiler utils', () => { expect(normalizedErrMsg).to.be.equal('Token.sol:6:46: Warning: Unused local variable'); }); }); - describe('#createArtifactsDirIfDoesNotExistAsync', () => { + describe('#createDirIfDoesNotExistAsync', () => { it('creates artifacts dir', async () => { const artifactsDir = `${__dirname}/artifacts`; expect(fsWrapper.doesPathExistSync(artifactsDir)).to.be.false(); - await createArtifactsDirIfDoesNotExistAsync(artifactsDir); + await createDirIfDoesNotExistAsync(artifactsDir); expect(fsWrapper.doesPathExistSync(artifactsDir)).to.be.true(); fsWrapper.rmdirSync(artifactsDir); expect(fsWrapper.doesPathExistSync(artifactsDir)).to.be.false(); |