Merge branch 'development' into feature/orderExpired
This commit is contained in:
@@ -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_
|
||||
|
@@ -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",
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user