diff options
Diffstat (limited to 'packages')
-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 |
8 files changed, 55 insertions, 23 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 36c3b8c8e..26f9273db 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/bintrees": "^1.0.2", "@types/jsonschema": "^1.1.1", "@types/lodash": "^4.14.64", @@ -83,8 +83,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", "bintrees": "^1.0.2", "bn.js": "4.11.8", diff --git a/packages/0x.js/src/web3_wrapper.ts b/packages/0x.js/src/web3_wrapper.ts index 12d7caaf8..7bd8ea093 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>; @@ -139,8 +150,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); @@ -151,7 +163,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; @@ -171,4 +183,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..1a7cb9e40 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.a('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": [ |