diff options
author | Fabio Berger <me@fabioberger.com> | 2018-03-14 21:16:08 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-03-14 21:16:08 +0800 |
commit | 009b70f5b218a1ccb154034936256308131b7d9c (patch) | |
tree | cd9642a8d3323c9e80da54ac4e8fc40ade9f9020 /packages/dev-utils/src/rpc.ts | |
parent | f7c1e10b5ac112866ee55e7fededdb37c890d30f (diff) | |
parent | 3f3e8be004818ddaa1921b3dff12bdd46052278b (diff) | |
download | dexon-sol-tools-009b70f5b218a1ccb154034936256308131b7d9c.tar dexon-sol-tools-009b70f5b218a1ccb154034936256308131b7d9c.tar.gz dexon-sol-tools-009b70f5b218a1ccb154034936256308131b7d9c.tar.bz2 dexon-sol-tools-009b70f5b218a1ccb154034936256308131b7d9c.tar.lz dexon-sol-tools-009b70f5b218a1ccb154034936256308131b7d9c.tar.xz dexon-sol-tools-009b70f5b218a1ccb154034936256308131b7d9c.tar.zst dexon-sol-tools-009b70f5b218a1ccb154034936256308131b7d9c.zip |
Merge branch 'development' into convertScriptsToTs
* development: (71 commits)
Transform input data before encoding for callAsync and getABIEncodedTransactionData
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
Report all coverage reports together
Add other statement types
Properly and consistently parse ENV vars
Add forgotten file
Start using solidity-parser-antlr
Fix the default always overriding to address
Submit a TD PR
Add an explanatory comment for making ranges unique
Fix a typo in handling env variables
Introduce TESTRPC_FIRST_ADDRESS
Make BlockchainLifecycle accept only web3Wrapper
Fix comments
Fix deployer CHANGELOG
...
# Conflicts:
# README.md
# packages/deployer/package.json
# packages/subproviders/src/globals.d.ts
# yarn.lock
Diffstat (limited to 'packages/dev-utils/src/rpc.ts')
-rw-r--r-- | packages/dev-utils/src/rpc.ts | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/packages/dev-utils/src/rpc.ts b/packages/dev-utils/src/rpc.ts deleted file mode 100644 index 47a359263..000000000 --- a/packages/dev-utils/src/rpc.ts +++ /dev/null @@ -1,62 +0,0 @@ -import * as ethUtil from 'ethereumjs-util'; -import * as request from 'request-promise-native'; - -import { constants } from './constants'; - -export class RPC { - private _url: string; - private _id: number; - constructor() { - this._url = constants.RPC_URL; - this._id = 0; - } - public async takeSnapshotAsync(): Promise<number> { - const method = 'evm_snapshot'; - const params: any[] = []; - const payload = this._toPayload(method, params); - const snapshotIdHex = await this._sendAsync(payload); - const snapshotId = ethUtil.bufferToInt(ethUtil.toBuffer(snapshotIdHex)); - return snapshotId; - } - public async revertSnapshotAsync(snapshotId: number): Promise<boolean> { - const method = 'evm_revert'; - const params = [snapshotId]; - const payload = this._toPayload(method, params); - const didRevert = await this._sendAsync(payload); - return didRevert; - } - public async increaseTimeAsync(time: number) { - const method = 'evm_increaseTime'; - const params = [time]; - const payload = this._toPayload(method, params); - return this._sendAsync(payload); - } - public async mineBlockAsync(): Promise<void> { - const method = 'evm_mine'; - const params: any[] = []; - const payload = this._toPayload(method, params); - await this._sendAsync(payload); - } - private _toPayload(method: string, params: any[] = []): string { - const payload = JSON.stringify({ - id: this._id, - method, - params, - }); - this._id += 1; - return payload; - } - private async _sendAsync(payload: string): Promise<any> { - const opts = { - method: 'POST', - uri: this._url, - body: payload, - headers: { - 'content-type': 'application/json', - }, - }; - const bodyString = await request(opts); - const body = JSON.parse(bodyString); - return body.result; - } -} |