diff options
author | Fabio Berger <me@fabioberger.com> | 2018-09-24 22:53:34 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-09-24 22:53:34 +0800 |
commit | 5e1a2bd972cab09d7e487cf80fa9c913e5c0696d (patch) | |
tree | ccb43389b3551e410bec00e77acf40e9a1f6575c /packages/contract-wrappers | |
parent | 45dc2be0832eefbf6f009b07abb7b7a435b19279 (diff) | |
parent | fc33eacd2cbcc088d238f5e1f34b50b06ea8d58f (diff) | |
download | dexon-sol-tools-5e1a2bd972cab09d7e487cf80fa9c913e5c0696d.tar.gz dexon-sol-tools-5e1a2bd972cab09d7e487cf80fa9c913e5c0696d.tar.zst dexon-sol-tools-5e1a2bd972cab09d7e487cf80fa9c913e5c0696d.zip |
Merge development
Diffstat (limited to 'packages/contract-wrappers')
-rw-r--r-- | packages/contract-wrappers/CHANGELOG.json | 9 | ||||
-rw-r--r-- | packages/contract-wrappers/CHANGELOG.md | 4 | ||||
-rw-r--r-- | packages/contract-wrappers/package.json | 32 | ||||
-rw-r--r-- | packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts | 18 | ||||
-rw-r--r-- | packages/contract-wrappers/test/subscription_test.ts | 2 |
5 files changed, 45 insertions, 20 deletions
diff --git a/packages/contract-wrappers/CHANGELOG.json b/packages/contract-wrappers/CHANGELOG.json index a8572e968..1c9af4971 100644 --- a/packages/contract-wrappers/CHANGELOG.json +++ b/packages/contract-wrappers/CHANGELOG.json @@ -9,6 +9,15 @@ ] }, { + "version": "1.0.4", + "changes": [ + { + "note": "Dependencies updated" + } + ], + "timestamp": 1537541580 + }, + { "version": "1.0.3", "changes": [ { diff --git a/packages/contract-wrappers/CHANGELOG.md b/packages/contract-wrappers/CHANGELOG.md index 69561213e..3757bd6ba 100644 --- a/packages/contract-wrappers/CHANGELOG.md +++ b/packages/contract-wrappers/CHANGELOG.md @@ -5,6 +5,10 @@ Edit the package's CHANGELOG.json file only. CHANGELOG +## v1.0.4 - _September 21, 2018_ + + * Dependencies updated + ## v1.0.3 - _September 19, 2018_ * Drastically reduce the bundle size by removing unused parts of included contract artifacts. diff --git a/packages/contract-wrappers/package.json b/packages/contract-wrappers/package.json index 4ec93928c..8f60759f6 100644 --- a/packages/contract-wrappers/package.json +++ b/packages/contract-wrappers/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/contract-wrappers", - "version": "1.0.3", + "version": "1.0.4", "description": "Smart TS wrappers for 0x smart contracts", "keywords": [ "0xproject", @@ -41,14 +41,14 @@ "node": ">=6.0.0" }, "devDependencies": { - "@0xproject/abi-gen": "^1.0.8", - "@0xproject/dev-utils": "^1.0.7", - "@0xproject/migrations": "^1.0.9", - "@0xproject/subproviders": "^2.0.2", + "@0xproject/abi-gen": "^1.0.9", + "@0xproject/dev-utils": "^1.0.8", + "@0xproject/migrations": "^1.0.10", + "@0xproject/subproviders": "^2.0.3", "@0xproject/tslint-config": "^1.0.7", "@types/lodash": "4.14.104", "@types/mocha": "^2.2.42", - "@types/node": "^8.0.53", + "@types/node": "*", "@types/sinon": "^2.2.2", "@types/uuid": "^3.4.2", "@types/web3-provider-engine": "^14.0.0", @@ -72,16 +72,16 @@ "web3-provider-engine": "14.0.6" }, "dependencies": { - "@0xproject/assert": "^1.0.8", - "@0xproject/base-contract": "^2.0.2", - "@0xproject/fill-scenarios": "^1.0.2", - "@0xproject/json-schemas": "^1.0.1", - "@0xproject/order-utils": "^1.0.2", - "@0xproject/types": "^1.0.1", - "@0xproject/typescript-typings": "^2.0.0", - "@0xproject/utils": "^1.0.8", - "@0xproject/web3-wrapper": "^2.0.2", - "ethereum-types": "^1.0.6", + "@0xproject/assert": "^1.0.9", + "@0xproject/base-contract": "^2.0.3", + "@0xproject/fill-scenarios": "^1.0.3", + "@0xproject/json-schemas": "^1.0.2", + "@0xproject/order-utils": "^1.0.3", + "@0xproject/types": "^1.0.2", + "@0xproject/typescript-typings": "^2.0.1", + "@0xproject/utils": "^1.0.9", + "@0xproject/web3-wrapper": "^2.0.3", + "ethereum-types": "^1.0.7", "ethereumjs-blockstream": "6.0.0", "ethereumjs-util": "^5.1.1", "ethers": "3.0.22", diff --git a/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts index 19de17c0a..19a882712 100644 --- a/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts +++ b/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts @@ -2,6 +2,7 @@ import { AbiDecoder, intervalUtils, logUtils } from '@0xproject/utils'; import { Web3Wrapper } from '@0xproject/web3-wrapper'; import { BlockParamLiteral, + BlockWithoutTransactionData, ContractAbi, ContractArtifact, FilterObject, @@ -174,7 +175,7 @@ export abstract class ContractWrapper { throw new Error(ContractWrappersError.SubscriptionAlreadyPresent); } this._blockAndLogStreamerIfExists = new BlockAndLogStreamer( - this._web3Wrapper.getBlockAsync.bind(this._web3Wrapper), + this._getBlockOrNullAsync.bind(this), this._web3Wrapper.getLogsAsync.bind(this._web3Wrapper), ContractWrapper._onBlockAndLogStreamerError.bind(this, isVerbose), ); @@ -194,6 +195,14 @@ export abstract class ContractWrapper { this._onLogStateChanged.bind(this, isRemoved), ); } + // This method only exists in order to comply with the expected interface of Blockstream's constructor + private async _getBlockOrNullAsync(): Promise<BlockWithoutTransactionData | null> { + const blockIfExists = await this._web3Wrapper.getBlockIfExistsAsync.bind(this._web3Wrapper); + if (_.isUndefined(blockIfExists)) { + return null; + } + return blockIfExists; + } // HACK: This should be a package-scoped method (which doesn't exist in TS) // We don't want this method available in the public interface for all classes // who inherit from ContractWrapper, and it is only used by the internal implementation @@ -212,11 +221,14 @@ export abstract class ContractWrapper { delete this._blockAndLogStreamerIfExists; } private async _reconcileBlockAsync(): Promise<void> { - const latestBlock = await this._web3Wrapper.getBlockAsync(BlockParamLiteral.Latest); + const latestBlockIfExists = await this._web3Wrapper.getBlockIfExistsAsync(BlockParamLiteral.Latest); + if (_.isUndefined(latestBlockIfExists)) { + return; // noop + } // We need to coerce to Block type cause Web3.Block includes types for mempool blocks if (!_.isUndefined(this._blockAndLogStreamerIfExists)) { // If we clear the interval while fetching the block - this._blockAndLogStreamer will be undefined - await this._blockAndLogStreamerIfExists.reconcileNewBlock((latestBlock as any) as Block); + await this._blockAndLogStreamerIfExists.reconcileNewBlock((latestBlockIfExists as any) as Block); } } } diff --git a/packages/contract-wrappers/test/subscription_test.ts b/packages/contract-wrappers/test/subscription_test.ts index 81b9012bd..68ef7225e 100644 --- a/packages/contract-wrappers/test/subscription_test.ts +++ b/packages/contract-wrappers/test/subscription_test.ts @@ -61,7 +61,7 @@ describe('SubscriptionTest', () => { callback, ); stubs = [ - Sinon.stub((contractWrappers as any)._web3Wrapper, 'getBlockAsync').throws( + Sinon.stub((contractWrappers as any)._web3Wrapper, 'getBlockIfExistsAsync').throws( new Error('JSON RPC error'), ), ]; |