diff options
author | Fabio Berger <me@fabioberger.com> | 2017-11-22 04:03:26 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2017-11-22 04:03:26 +0800 |
commit | f7f1397e52d246426e4d7bbff89a0b770faed3ee (patch) | |
tree | fdf4e42d3b744a5ee97cab33017401215e8da55a | |
parent | 3660ba28d73d70d08bf14c33ef680e5ef3ec7f3b (diff) | |
parent | e3cc2834789ec5d4affceee2d03015085b24d907 (diff) | |
download | dexon-0x-contracts-f7f1397e52d246426e4d7bbff89a0b770faed3ee.tar.gz dexon-0x-contracts-f7f1397e52d246426e4d7bbff89a0b770faed3ee.tar.zst dexon-0x-contracts-f7f1397e52d246426e4d7bbff89a0b770faed3ee.zip |
Merge branch 'development' into addWebsite
* development:
Fix a typo in postpublish utils tags -> tag
Publish
Revert "Publish"
Publish
Add instanceOf assertion
Rename toDecimal to hexToDecimal
Add PR numbers
Add postFormatter for logs
-rw-r--r-- | packages/0x.js/CHANGELOG.md | 11 | ||||
-rw-r--r-- | packages/0x.js/package.json | 8 | ||||
-rw-r--r-- | packages/0x.js/src/web3_wrapper.ts | 34 | ||||
-rw-r--r-- | packages/0x.js/test/token_wrapper_test.ts | 3 | ||||
-rw-r--r-- | packages/assert/package.json | 6 | ||||
-rw-r--r-- | packages/connect/package.json | 10 | ||||
-rw-r--r-- | packages/json-schemas/package.json | 4 | ||||
-rw-r--r-- | packages/tslint-config/package.json | 2 | ||||
-rw-r--r-- | scripts/postpublish_utils.js | 2 |
9 files changed, 56 insertions, 24 deletions
diff --git a/packages/0x.js/CHANGELOG.md b/packages/0x.js/CHANGELOG.md index 6245308c3..26e5f528b 100644 --- a/packages/0x.js/CHANGELOG.md +++ b/packages/0x.js/CHANGELOG.md @@ -2,18 +2,19 @@ vx.x.x ------------------------ - * Remove support for Async callback types when used in Subscribe functions + * Add post-formatter for logs converting `blockNumber`, `logIndex`, `transactionIndex` from hexes to numbers (#231) + * Remove support for Async callback types when used in Subscribe functions (#222) * In OrderWatcher subscribe to ZRX Token Transfer and Approval events when maker token is different (#225) v0.25.1 - _November 13, 2017_ ------------------------ - * Standardise on Cancelled over Canceled - * Add missing `DecodedLogEvent` type to exported types - * Normalized the transactionReceipt status to be `null|0|1`, 1 meaning transaction execution successful, 0 unsuccessful and `null` if it is a pre-byzantinium transaction. + * Standardise on Cancelled over Canceled (#217) + * Add missing `DecodedLogEvent` type to exported types (#205) + * Normalized the transactionReceipt status to be `null|0|1`, 1 meaning transaction execution successful, 0 unsuccessful and `null` if it is a pre-byzantinium transaction. (#200) v0.23.0 - _November 12, 2017_ ------------------------ - * Fixed unhandled promise rejection error in subscribe methods (#209) + * Fixed unhandled promise rejection error in subscribe methods (#209) * Subscribe callbacks now receive an error object as their first argument v0.22.6 - _November 10, 2017_ diff --git a/packages/0x.js/package.json b/packages/0x.js/package.json index 7aa360954..b439a58ef 100644 --- a/packages/0x.js/package.json +++ b/packages/0x.js/package.json @@ -1,6 +1,6 @@ { "name": "0x.js", - "version": "0.25.1", + "version": "0.26.0", "description": "A javascript library for interacting with the 0x protocol", "keywords": [ "0x.js", @@ -44,7 +44,7 @@ "node": ">=6.0.0" }, "devDependencies": { - "@0xproject/tslint-config": "^0.1.0", + "@0xproject/tslint-config": "^0.1.1", "@types/jsonschema": "^1.1.1", "@types/lodash": "^4.14.64", "@types/mocha": "^2.2.41", @@ -82,8 +82,8 @@ "webpack": "^3.1.0" }, "dependencies": { - "@0xproject/assert": "^0.0.4", - "@0xproject/json-schemas": "^0.6.7", + "@0xproject/assert": "^0.0.5", + "@0xproject/json-schemas": "^0.6.8", "bignumber.js": "~4.1.0", "bn.js": "4.11.8", "compare-versions": "^3.0.1", diff --git a/packages/0x.js/src/web3_wrapper.ts b/packages/0x.js/src/web3_wrapper.ts index c937f9288..f6b6ca09a 100644 --- a/packages/0x.js/src/web3_wrapper.ts +++ b/packages/0x.js/src/web3_wrapper.ts @@ -5,6 +5,17 @@ import promisify = require('es6-promisify'); import {ZeroExError, Artifact, TransactionReceipt} from './types'; import {Contract} from './contract'; +interface RawLogEntry { + logIndex: string|null; + transactionIndex: string|null; + transactionHash: string; + blockHash: string|null; + blockNumber: string|null; + address: string; + data: string; + topics: string[]; +} + export class Web3Wrapper { private web3: Web3; private defaults: Partial<Web3.TxData>; @@ -137,8 +148,9 @@ export class Web3Wrapper { method: 'eth_getLogs', params: [serializedFilter], }; - const logs = await this.sendRawPayloadAsync(payload); - return logs; + const rawLogs = await this.sendRawPayloadAsync<RawLogEntry[]>(payload); + const formattedLogs = _.map(rawLogs, this.formatLog.bind(this)); + return formattedLogs; } private getContractInstance<A extends Web3.ContractInstance>(abi: Web3.ContractAbi, address: string): A { const web3ContractInstance = this.web3.eth.contract(abi).at(address); @@ -149,7 +161,7 @@ export class Web3Wrapper { const networkId = await promisify(this.web3.version.getNetwork)(); return networkId; } - private async sendRawPayloadAsync(payload: Web3.JSONRPCRequestPayload): Promise<any> { + private async sendRawPayloadAsync<A>(payload: Web3.JSONRPCRequestPayload): Promise<A> { const sendAsync = this.web3.currentProvider.sendAsync.bind(this.web3.currentProvider); const response = await promisify(sendAsync)(payload); const result = response.result; @@ -169,4 +181,20 @@ export class Web3Wrapper { return status; } } + private formatLog(rawLog: RawLogEntry): Web3.LogEntry { + const formattedLog = { + ...rawLog, + logIndex: this.hexToDecimal(rawLog.logIndex), + blockNumber: this.hexToDecimal(rawLog.blockNumber), + transactionIndex: this.hexToDecimal(rawLog.transactionIndex), + }; + return formattedLog; + } + private hexToDecimal(hex: string|null): number|null { + if (_.isNull(hex)) { + return null; + } + const decimal = this.web3.toDecimal(hex); + return decimal; + } } diff --git a/packages/0x.js/test/token_wrapper_test.ts b/packages/0x.js/test/token_wrapper_test.ts index b30762e8c..c32c528e6 100644 --- a/packages/0x.js/test/token_wrapper_test.ts +++ b/packages/0x.js/test/token_wrapper_test.ts @@ -361,6 +361,9 @@ describe('TokenWrapper', () => { (async () => { const callback = (err: Error, logEvent: DecodedLogEvent<TransferContractEventArgs>) => { expect(logEvent).to.not.be.undefined(); + expect(logEvent.logIndex).to.be.equal(0); + expect(logEvent.transactionIndex).to.be.equal(0); + expect(logEvent.blockNumber).to.be.instanceOf(Number); const args = logEvent.args; expect(args._from).to.be.equal(coinbase); expect(args._to).to.be.equal(addressWithoutFunds); diff --git a/packages/assert/package.json b/packages/assert/package.json index ed1d2a98b..d0f40c66e 100644 --- a/packages/assert/package.json +++ b/packages/assert/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/assert", - "version": "0.0.4", + "version": "0.0.5", "description": "Provides a standard way of performing type and schema validation across 0x projects", "main": "lib/src/index.js", "types": "lib/src/index.d.ts", @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/0xProject/0x.js/packages/assert/README.md", "devDependencies": { - "@0xproject/tslint-config": "^0.1.0", + "@0xproject/tslint-config": "^0.1.1", "@types/lodash": "^4.14.78", "@types/mocha": "^2.2.42", "@types/valid-url": "^1.0.2", @@ -37,7 +37,7 @@ "typescript": "^2.4.2" }, "dependencies": { - "@0xproject/json-schemas": "^0.6.7", + "@0xproject/json-schemas": "^0.6.8", "bignumber.js": "~4.1.0", "ethereum-address": "^0.0.4", "lodash": "^4.17.4", diff --git a/packages/connect/package.json b/packages/connect/package.json index d26594b5d..ff6253fb6 100644 --- a/packages/connect/package.json +++ b/packages/connect/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/connect", - "version": "0.0.0", + "version": "0.0.1", "description": "A javascript library for interacting with the standard relayer api", "keywords": [ "0x-connect", @@ -35,9 +35,9 @@ }, "homepage": "https://github.com/0xProject/0x.js/packages/connect/README.md", "dependencies": { - "@0xproject/assert": "0.0.4", - "@0xproject/json-schemas": "0.6.7", - "0x.js": "~0.25.1", + "0x.js": "^0.26.0", + "@0xproject/assert": "^0.0.5", + "@0xproject/json-schemas": "^0.6.8", "bignumber.js": "~4.1.0", "isomorphic-fetch": "^2.2.1", "lodash": "^4.17.4", @@ -45,7 +45,7 @@ "websocket": "^1.0.25" }, "devDependencies": { - "@0xproject/tslint-config": "0.1.0", + "@0xproject/tslint-config": "^0.1.1", "@types/fetch-mock": "^5.12.1", "@types/lodash": "^4.14.77", "@types/mocha": "^2.2.42", diff --git a/packages/json-schemas/package.json b/packages/json-schemas/package.json index 07ed20551..89c0d25f7 100644 --- a/packages/json-schemas/package.json +++ b/packages/json-schemas/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/json-schemas", - "version": "0.6.7", + "version": "0.6.8", "description": "0x-related json schemas", "main": "lib/src/index.js", "types": "lib/src/index.d.ts", @@ -28,7 +28,7 @@ "lodash.values": "^4.3.0" }, "devDependencies": { - "@0xproject/tslint-config": "^0.1.0", + "@0xproject/tslint-config": "^0.1.1", "@types/lodash.foreach": "^4.5.3", "@types/lodash.values": "^4.3.3", "@types/mocha": "^2.2.42", diff --git a/packages/tslint-config/package.json b/packages/tslint-config/package.json index ca46d63fc..7ee3f1f71 100644 --- a/packages/tslint-config/package.json +++ b/packages/tslint-config/package.json @@ -1,6 +1,6 @@ { "name": "@0xproject/tslint-config", - "version": "0.1.0", + "version": "0.1.1", "description": "Lint rules related to 0xProject for TSLint", "main": "tslint.json", "files": [ diff --git a/scripts/postpublish_utils.js b/scripts/postpublish_utils.js index 3fb079bad..4f9798e60 100644 --- a/scripts/postpublish_utils.js +++ b/scripts/postpublish_utils.js @@ -9,7 +9,7 @@ const githubPersonalAccessToken = process.env.GITHUB_PERSONAL_ACCESS_TOKEN_0X_JS module.exports = { getLatestTagAndVersionAsync: function(subPackageName) { const subPackagePrefix = subPackageName + '@'; - const gitTagsCommand = 'git tags -l "' + subPackagePrefix + '*"'; + const gitTagsCommand = 'git tag -l "' + subPackagePrefix + '*"'; return execAsync(gitTagsCommand) .then(function(result) { if (result.stderr !== '') { |