@0xcert/ethereum-generic-provider
Advanced tools
Comparing version 1.6.0 to 1.7.0
@@ -5,2 +5,8 @@ { | ||
{ | ||
"version": "1.7.0", | ||
"tag": "@0xcert/ethereum-generic-provider_v1.7.0", | ||
"date": "Wed, 29 May 2019 13:47:23 GMT", | ||
"comments": {} | ||
}, | ||
{ | ||
"version": "1.6.0", | ||
@@ -7,0 +13,0 @@ "tag": "@0xcert/ethereum-generic-provider_v1.6.0", |
# Change Log - @0xcert/ethereum-generic-provider | ||
This log was last generated on Thu, 16 May 2019 16:19:39 GMT and should not be manually modified. | ||
This log was last generated on Wed, 29 May 2019 13:47:23 GMT and should not be manually modified. | ||
## 1.7.0 | ||
Wed, 29 May 2019 13:47:23 GMT | ||
*Version update only* | ||
## 1.6.0 | ||
@@ -6,0 +11,0 @@ Thu, 16 May 2019 16:19:39 GMT |
@@ -28,2 +28,5 @@ "use strict"; | ||
this._provider = provider; | ||
if (this._provider.sandbox) { | ||
this._status = MutationStatus.COMPLETED; | ||
} | ||
} | ||
@@ -30,0 +33,0 @@ get id() { |
@@ -17,2 +17,4 @@ /// <reference types="node" /> | ||
encoder?: Encode; | ||
gasPriceMultiplier?: number; | ||
sandbox?: Boolean; | ||
} | ||
@@ -26,2 +28,4 @@ export declare class GenericProvider extends EventEmitter implements ProviderBase { | ||
encoder: Encode; | ||
gasPriceMultiplier?: number; | ||
sandbox: Boolean; | ||
protected _orderGatewayId: string; | ||
@@ -28,0 +32,0 @@ protected _accountId: string; |
@@ -29,2 +29,4 @@ "use strict"; | ||
this.mutationTimeout = typeof options.mutationTimeout !== 'undefined' ? options.mutationTimeout : 3600000; | ||
this.gasPriceMultiplier = typeof options.gasPriceMultiplier !== 'undefined' ? options.gasPriceMultiplier : 1.1; | ||
this.sandbox = typeof options.sandbox !== 'undefined' ? options.sandbox : false; | ||
this._client = options.client && options.client.currentProvider | ||
@@ -106,9 +108,12 @@ ? options.client.currentProvider | ||
if (payload.method === 'eth_sendTransaction' && payload.params.length) { | ||
if (typeof payload.params[0].gas === 'undefined') { | ||
if (this.sandbox || typeof payload.params[0].gas === 'undefined') { | ||
const res = yield this.request(Object.assign({}, payload, { method: 'eth_estimateGas' })); | ||
payload.params[0].gas = `0x${Math.ceil(res.result * 1.1).toString(16)}`; | ||
} | ||
if (this.sandbox) { | ||
return { id: null, jsonrpc: null, result: payload.params[0].gas }; | ||
} | ||
if (typeof payload.params[0].gasPrice === 'undefined') { | ||
const res = yield this.request(Object.assign({}, payload, { method: 'eth_gasPrice', params: [] })); | ||
payload.params[0].gasPrice = `0x${Math.ceil(res.result * 1.1).toString(16)}`; | ||
payload.params[0].gasPrice = `0x${Math.ceil(res.result * this.gasPriceMultiplier).toString(16)}`; | ||
} | ||
@@ -115,0 +120,0 @@ } |
@@ -53,2 +53,12 @@ "use strict"; | ||
})); | ||
spec.test('resolves mutation in sandbox mode', (ctx) => __awaiter(this, void 0, void 0, function* () { | ||
const provider = ctx.get('provider'); | ||
provider.sandbox = true; | ||
const coinbase = ctx.get('coinbase'); | ||
const bob = ctx.get('bob'); | ||
const transactionHash = yield ctx.web3.eth.sendTransaction({ from: coinbase, to: bob, value: 0 }).then((t) => t.transactionHash); | ||
const mutation = new __1.Mutation(provider, transactionHash); | ||
ctx.true(mutation.isCompleted()); | ||
provider.sandbox = false; | ||
})); | ||
spec.test('times out when valid timeout value', (ctx) => __awaiter(this, void 0, void 0, function* () { | ||
@@ -55,0 +65,0 @@ const provider = ctx.get('provider'); |
{ | ||
"files": { | ||
"packages/0xcert-ethereum-generic-provider/CHANGELOG.json": "e4fe47289cfe8c66c4b99137feaaed872daabf77", | ||
"packages/0xcert-ethereum-generic-provider/CHANGELOG.md": "55909b4a0a8382517055f9d5477e2550f17791e9", | ||
"packages/0xcert-ethereum-generic-provider/CHANGELOG.json": "cbf30bad00f576b93cb7a6ea31c323dbae3e08bb", | ||
"packages/0xcert-ethereum-generic-provider/CHANGELOG.md": "0693c7d75bb387a5975cc74323381d675f3bb5ab", | ||
"packages/0xcert-ethereum-generic-provider/README.md": "22522c3dc727189e74e28372635710c1bdc9bfb2", | ||
"packages/0xcert-ethereum-generic-provider/nodemon.json": "82b893373db9861f1df4b55d8ea68a5d37b118de", | ||
"packages/0xcert-ethereum-generic-provider/package.json": "f74a91d92cbe9d0ecb71fe7a1f8de0375f1e7e2c", | ||
"packages/0xcert-ethereum-generic-provider/package.json": "ac6c6b368394697c866bbf651eb8bb2deb8cc6f2", | ||
"packages/0xcert-ethereum-generic-provider/src/core/errors.ts": "b232b31b2020e1dd06dbe71b1c4b15e274e5ae55", | ||
"packages/0xcert-ethereum-generic-provider/src/core/mutation.ts": "0cc2b065311c30c0635fc44346407ea210cbef29", | ||
"packages/0xcert-ethereum-generic-provider/src/core/provider.ts": "3597be82dd2c0801670d23f9ea047fb308814ab5", | ||
"packages/0xcert-ethereum-generic-provider/src/core/mutation.ts": "e28431081a54f9519fbfb8e79f645af2df5342b7", | ||
"packages/0xcert-ethereum-generic-provider/src/core/provider.ts": "3eaf1fd8b88b69e37a1b659c9663b6dd77823eb7", | ||
"packages/0xcert-ethereum-generic-provider/src/core/types.ts": "c748d034440f2deae97bd4ff414ffd3f9f67f3dd", | ||
"packages/0xcert-ethereum-generic-provider/src/index.ts": "49830327483689a5269acd70592210766e8f167b", | ||
"packages/0xcert-ethereum-generic-provider/src/tests/core/mutation/complete-instance-method.test.ts": "bb7b365b20430d254e7c114c7f2bd8117c0938d2", | ||
"packages/0xcert-ethereum-generic-provider/src/tests/core/mutation/complete-instance-method.test.ts": "11369cbfa2f6686a333a8dc5b86a9bd709381982", | ||
"packages/0xcert-ethereum-generic-provider/src/tests/core/provider/account-change-event.test.ts": "a18113ecbfabcedfee471cb5906945ee9e4e78bd", | ||
@@ -26,5 +26,5 @@ "packages/0xcert-ethereum-generic-provider/src/tests/core/provider/account-id-instance-variable.test.ts": "edbb6abad2093a0fad7dffc072cbec0b1f9f6749", | ||
"packages/0xcert-ethereum-generic-provider/tslint.json": "c57b3f0cdb7aa74ab2ab02888380f613589cbe66", | ||
"common/config/rush/npm-shrinkwrap.json": "2c64cd5ca36ff123b68ee15f70d1af61596d9aab" | ||
"common/config/rush/npm-shrinkwrap.json": "023ff7e099bf4e74a4eb7d2305acc0acc10727c5" | ||
}, | ||
"arguments": "npm run clean && npx tsc " | ||
} |
{ | ||
"name": "@0xcert/ethereum-generic-provider", | ||
"version": "1.6.0", | ||
"version": "1.7.0", | ||
"description": "Basic implementation of communication provider for the Ethereum blockchain.", | ||
@@ -70,3 +70,3 @@ "main": "./dist/index.js", | ||
"devDependencies": { | ||
"@0xcert/ethereum-sandbox": "1.6.0", | ||
"@0xcert/ethereum-sandbox": "1.7.0", | ||
"@types/node": "^10.12.24", | ||
@@ -84,6 +84,6 @@ "@specron/cli": "^0.5.6", | ||
"dependencies": { | ||
"@0xcert/ethereum-utils": "1.6.0", | ||
"@0xcert/scaffold": "1.6.0", | ||
"@0xcert/ethereum-utils": "1.7.0", | ||
"@0xcert/scaffold": "1.7.0", | ||
"events": "^3.0.0" | ||
} | ||
} |
@@ -74,2 +74,5 @@ import { normalizeAddress } from '@0xcert/ethereum-utils/dist/lib/normalize-address'; | ||
this._provider = provider; | ||
if (this._provider.sandbox) { | ||
this._status = MutationStatus.COMPLETED; | ||
} | ||
} | ||
@@ -76,0 +79,0 @@ |
@@ -61,2 +61,12 @@ import { Encode, Encoder } from '@0xcert/ethereum-utils'; | ||
encoder?: Encode; | ||
/** | ||
* Gas price multiplier. Defaults to 1.1. | ||
*/ | ||
gasPriceMultiplier?: number; | ||
/** | ||
* Sandbox mode. False by default. | ||
*/ | ||
sandbox?: Boolean; | ||
} | ||
@@ -100,2 +110,12 @@ | ||
/** | ||
* Gas price multiplier. Defaults to 1.1. | ||
*/ | ||
public gasPriceMultiplier?: number; | ||
/** | ||
* Sandbox mode. False by default. | ||
*/ | ||
public sandbox: Boolean; | ||
/** | ||
* Id (address) of order gateway. | ||
@@ -141,2 +161,4 @@ */ | ||
this.mutationTimeout = typeof options.mutationTimeout !== 'undefined' ? options.mutationTimeout : 3600000; // 1 h | ||
this.gasPriceMultiplier = typeof options.gasPriceMultiplier !== 'undefined' ? options.gasPriceMultiplier : 1.1; | ||
this.sandbox = typeof options.sandbox !== 'undefined' ? options.sandbox : false; | ||
@@ -289,7 +311,5 @@ this._client = options.client && options.client.currentProvider | ||
// TODO: test if error throwing works on ropsten or do we need to check if | ||
// the resulting gas amount is the same as block gas amount => revert. | ||
if (payload.method === 'eth_sendTransaction' && payload.params.length) { | ||
if (typeof payload.params[0].gas === 'undefined') { | ||
if (this.sandbox || typeof payload.params[0].gas === 'undefined') { | ||
const res = await this.request({ | ||
@@ -304,2 +324,6 @@ ...payload, | ||
if (this.sandbox) { | ||
return { id: null, jsonrpc: null, result: payload.params[0].gas }; | ||
} | ||
if (typeof payload.params[0].gasPrice === 'undefined') { | ||
@@ -311,4 +335,3 @@ const res = await this.request({ | ||
}); | ||
// TODO: get multiplyer from provider settings | ||
payload.params[0].gasPrice = `0x${Math.ceil(res.result * 1.1).toString(16)}`; | ||
payload.params[0].gasPrice = `0x${Math.ceil(res.result * this.gasPriceMultiplier).toString(16)}`; | ||
} | ||
@@ -315,0 +338,0 @@ } |
@@ -59,2 +59,14 @@ import { Protocol } from '@0xcert/ethereum-sandbox'; | ||
spec.test('resolves mutation in sandbox mode', async (ctx) => { | ||
const provider = ctx.get('provider'); | ||
provider.sandbox = true; | ||
const coinbase = ctx.get('coinbase'); | ||
const bob = ctx.get('bob'); | ||
const transactionHash = await ctx.web3.eth.sendTransaction({ from: coinbase, to: bob, value: 0 }).then((t) => t.transactionHash); | ||
const mutation = new Mutation(provider, transactionHash); | ||
ctx.true(mutation.isCompleted()); | ||
provider.sandbox = false; | ||
}); | ||
spec.test('times out when valid timeout value', async (ctx) => { | ||
@@ -61,0 +73,0 @@ const provider = ctx.get('provider'); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
148746
2141
+ Added@0xcert/ethereum-utils@1.7.0(transitive)
+ Added@0xcert/scaffold@1.7.0(transitive)
- Removed@0xcert/ethereum-utils@1.6.0(transitive)
- Removed@0xcert/scaffold@1.6.0(transitive)
Updated@0xcert/ethereum-utils@1.7.0
Updated@0xcert/scaffold@1.7.0