aboutsummaryrefslogtreecommitdiffstats
path: root/packages/web3-wrapper/src
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-03-14 02:49:30 +0800
committerGitHub <noreply@github.com>2018-03-14 02:49:30 +0800
commitdb44a5bca7d2221709526986e305f7c4d916acb6 (patch)
tree84d28edbf25ad60ba2e310ed43cafe479339e928 /packages/web3-wrapper/src
parent95e2b37d62ab9e1771fd682226aa31e5a93dd041 (diff)
parent53e1815c1d428b93185e6f26201b3c6434c2a7fd (diff)
downloaddexon-sol-tools-db44a5bca7d2221709526986e305f7c4d916acb6.tar
dexon-sol-tools-db44a5bca7d2221709526986e305f7c4d916acb6.tar.gz
dexon-sol-tools-db44a5bca7d2221709526986e305f7c4d916acb6.tar.bz2
dexon-sol-tools-db44a5bca7d2221709526986e305f7c4d916acb6.tar.lz
dexon-sol-tools-db44a5bca7d2221709526986e305f7c4d916acb6.tar.xz
dexon-sol-tools-db44a5bca7d2221709526986e305f7c4d916acb6.tar.zst
dexon-sol-tools-db44a5bca7d2221709526986e305f7c4d916acb6.zip
Merge pull request #426 from 0xProject/feature/solcov
Sol-cover
Diffstat (limited to 'packages/web3-wrapper/src')
-rw-r--r--packages/web3-wrapper/src/index.ts18
1 files changed, 17 insertions, 1 deletions
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;