diff options
author | Brandon Millman <brandon.millman@gmail.com> | 2018-03-16 00:57:27 +0800 |
---|---|---|
committer | Brandon Millman <brandon.millman@gmail.com> | 2018-03-16 00:57:27 +0800 |
commit | 76029cbf0915df36266bd5e51add07755297ddda (patch) | |
tree | e1692f8cc4ea4642292c61f65ba3911ded26de8e /packages/web3-wrapper | |
parent | b9c1653c1cf6984d56b7825d8747b48d797fa39e (diff) | |
parent | 4a27a7dc581fc6c8a3d4e212ca3712c249a5b417 (diff) | |
download | dexon-sol-tools-76029cbf0915df36266bd5e51add07755297ddda.tar dexon-sol-tools-76029cbf0915df36266bd5e51add07755297ddda.tar.gz dexon-sol-tools-76029cbf0915df36266bd5e51add07755297ddda.tar.bz2 dexon-sol-tools-76029cbf0915df36266bd5e51add07755297ddda.tar.lz dexon-sol-tools-76029cbf0915df36266bd5e51add07755297ddda.tar.xz dexon-sol-tools-76029cbf0915df36266bd5e51add07755297ddda.tar.zst dexon-sol-tools-76029cbf0915df36266bd5e51add07755297ddda.zip |
Merge branch 'development' into feature/sra-report/collection-tests
* development: (97 commits)
Keep console.log in monorepo-scripts
Enable coverage for all other packages with tests
Fix parallel coverage results reporting
Fix linter issuesx
Remove outdated comment
Add script copying to build command
Add postpublish script to sol-cov
Move configuration into package.json configs section
Transform input data before encoding for callAsync and getABIEncodedTransactionData
Update CHANGELOGs
Consolidate all console.log into the @0xproject/utils package
Update coverage badge to show development coverage
Configure post build hook
Notify coveralls after all tasks have finished
Address feedback
Revert "Report all coverage reports together"
Separate published packages and typescript typings on README
Consolidate docs generation and uploading logic
Use async/await instead of promise syntax
Move changelog entry
...
Diffstat (limited to 'packages/web3-wrapper')
-rw-r--r-- | packages/web3-wrapper/CHANGELOG.md | 4 | ||||
-rw-r--r-- | packages/web3-wrapper/package.json | 6 | ||||
-rw-r--r-- | packages/web3-wrapper/scripts/postpublish.js | 5 | ||||
-rw-r--r-- | packages/web3-wrapper/src/globals.d.ts | 6 | ||||
-rw-r--r-- | packages/web3-wrapper/src/index.ts | 18 | ||||
-rw-r--r-- | packages/web3-wrapper/src/monorepo_scripts/postpublish.ts | 8 |
6 files changed, 38 insertions, 9 deletions
diff --git a/packages/web3-wrapper/CHANGELOG.md b/packages/web3-wrapper/CHANGELOG.md index 6dabc7eb4..2b2fc7540 100644 --- a/packages/web3-wrapper/CHANGELOG.md +++ b/packages/web3-wrapper/CHANGELOG.md @@ -1,7 +1,9 @@ # CHANGELOG -## v0.2.1 _TBD_ +## v0.3.0 _TBD, 2018_ + * Add `web3Wrapper.takeSnapshotAsync`, `web3Wrapper.revertSnapshotAsync`, `web3Wrapper.mineBlockAsync`, `web3Wrapper.increaseTimeAsync` (#426) + * Add `web3Wrapper.isZeroExWeb3Wrapper` for runtime instanceOf checks (#426) * Add a `getProvider` method (#444) ## v0.2.0 _March 4, 2018_ diff --git a/packages/web3-wrapper/package.json b/packages/web3-wrapper/package.json index 2b545732e..6e569b993 100644 --- a/packages/web3-wrapper/package.json +++ b/packages/web3-wrapper/package.json @@ -6,8 +6,8 @@ "types": "lib/index.d.ts", "scripts": { "build:watch": "tsc -w", - "build": "tsc", - "clean": "shx rm -rf lib", + "build": "tsc && copyfiles -u 2 './lib/monorepo_scripts/**/*' ./scripts", + "clean": "shx rm -rf lib scripts", "lint": "tslint --project . 'src/**/*.ts'" }, "license": "Apache-2.0", @@ -20,8 +20,10 @@ }, "homepage": "https://github.com/0xProject/0x-monorepo/packages/web3-wrapper/README.md", "devDependencies": { + "@0xproject/monorepo-scripts": "^0.1.12", "@0xproject/tslint-config": "^0.4.10", "@types/lodash": "^4.14.86", + "copyfiles": "^1.2.0", "npm-run-all": "^4.1.2", "shx": "^0.2.2", "tslint": "5.8.0", diff --git a/packages/web3-wrapper/scripts/postpublish.js b/packages/web3-wrapper/scripts/postpublish.js deleted file mode 100644 index b3e5407c8..000000000 --- a/packages/web3-wrapper/scripts/postpublish.js +++ /dev/null @@ -1,5 +0,0 @@ -const postpublish_utils = require('../../../scripts/postpublish_utils'); -const packageJSON = require('../package.json'); - -const subPackageName = packageJSON.name; -postpublish_utils.standardPostPublishAsync(subPackageName);
\ No newline at end of file diff --git a/packages/web3-wrapper/src/globals.d.ts b/packages/web3-wrapper/src/globals.d.ts new file mode 100644 index 000000000..94e63a32d --- /dev/null +++ b/packages/web3-wrapper/src/globals.d.ts @@ -0,0 +1,6 @@ +declare module '*.json' { + const json: any; + /* tslint:disable */ + export default json; + /* tslint:enable */ +} diff --git a/packages/web3-wrapper/src/index.ts b/packages/web3-wrapper/src/index.ts index e14eb2914..02d5e4f7b 100644 --- a/packages/web3-wrapper/src/index.ts +++ b/packages/web3-wrapper/src/index.ts @@ -4,6 +4,8 @@ import * as _ from 'lodash'; import * as Web3 from 'web3'; export class Web3Wrapper { + // This is here purely to reliably distinguish it from other objects in runtime (like BigNumber.isBigNumber) + public isZeroExWeb3Wrapper = true; private _web3: Web3; private _defaults: Partial<TxData>; private _jsonRpcRequestId: number; @@ -92,6 +94,20 @@ export class Web3Wrapper { const normalizedAddresses = _.map(addresses, address => address.toLowerCase()); return normalizedAddresses; } + public async takeSnapshotAsync(): Promise<number> { + const snapshotId = Number(await this._sendRawPayloadAsync<string>({ method: 'evm_snapshot', params: [] })); + return snapshotId; + } + public async revertSnapshotAsync(snapshotId: number): Promise<boolean> { + const didRevert = await this._sendRawPayloadAsync<boolean>({ method: 'evm_revert', params: [snapshotId] }); + return didRevert; + } + public async mineBlockAsync(): Promise<void> { + await this._sendRawPayloadAsync<string>({ method: 'evm_mine', params: [] }); + } + public async increaseTimeAsync(timeDelta: number): Promise<void> { + await this._sendRawPayloadAsync<string>({ method: 'evm_increaseTime', params: [timeDelta] }); + } public async getLogsAsync(filter: Web3.FilterObject): Promise<Web3.LogEntry[]> { let fromBlock = filter.fromBlock; if (_.isNumber(fromBlock)) { @@ -132,7 +148,7 @@ export class Web3Wrapper { const txHash = await promisify<string>(this._web3.eth.sendTransaction)(txData); return txHash; } - private async _sendRawPayloadAsync<A>(payload: Web3.JSONRPCRequestPayload): Promise<A> { + private async _sendRawPayloadAsync<A>(payload: Partial<Web3.JSONRPCRequestPayload>): Promise<A> { const sendAsync = this._web3.currentProvider.sendAsync.bind(this._web3.currentProvider); const response = await promisify<Web3.JSONRPCResponsePayload>(sendAsync)(payload); const result = response.result; diff --git a/packages/web3-wrapper/src/monorepo_scripts/postpublish.ts b/packages/web3-wrapper/src/monorepo_scripts/postpublish.ts new file mode 100644 index 000000000..dcb99d0f7 --- /dev/null +++ b/packages/web3-wrapper/src/monorepo_scripts/postpublish.ts @@ -0,0 +1,8 @@ +import { postpublishUtils } from '@0xproject/monorepo-scripts'; + +import * as packageJSON from '../package.json'; +import * as tsConfigJSON from '../tsconfig.json'; + +const cwd = `${__dirname}/..`; +// tslint:disable-next-line:no-floating-promises +postpublishUtils.runAsync(packageJSON, tsConfigJSON, cwd); |