aboutsummaryrefslogtreecommitdiffstats
path: root/packages/0x.js
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2017-11-24 05:24:32 +0800
committerFabio Berger <me@fabioberger.com>2017-11-24 05:24:32 +0800
commit8dea47f03852d4da96d048e28023ab0bec90ca77 (patch)
tree102b6c1f5f46df0fe6e53f296b46a90d977545fb /packages/0x.js
parentb7b1721145f3894ade757a2ad4c366e2b6eadbe9 (diff)
parent17e41f2391a73656cce2ddf43c27acd2ae6260fd (diff)
downloaddexon-sol-tools-8dea47f03852d4da96d048e28023ab0bec90ca77.tar
dexon-sol-tools-8dea47f03852d4da96d048e28023ab0bec90ca77.tar.gz
dexon-sol-tools-8dea47f03852d4da96d048e28023ab0bec90ca77.tar.bz2
dexon-sol-tools-8dea47f03852d4da96d048e28023ab0bec90ca77.tar.lz
dexon-sol-tools-8dea47f03852d4da96d048e28023ab0bec90ca77.tar.xz
dexon-sol-tools-8dea47f03852d4da96d048e28023ab0bec90ca77.tar.zst
dexon-sol-tools-8dea47f03852d4da96d048e28023ab0bec90ca77.zip
Merge branch 'development' into validateOrdersAgainstLatestBlock
* development: Rename removed to isRemoved Add CHANGELOG entry Make DecodedLogEvent contain web3 log under a log subkey
Diffstat (limited to 'packages/0x.js')
-rw-r--r--packages/0x.js/CHANGELOG.md4
-rw-r--r--packages/0x.js/src/contract_wrappers/contract_wrapper.ts14
-rw-r--r--packages/0x.js/src/types.ts5
-rw-r--r--packages/0x.js/test/exchange_wrapper_test.ts6
-rw-r--r--packages/0x.js/test/token_wrapper_test.ts12
5 files changed, 25 insertions, 16 deletions
diff --git a/packages/0x.js/CHANGELOG.md b/packages/0x.js/CHANGELOG.md
index 235a6eedb..f33eab94e 100644
--- a/packages/0x.js/CHANGELOG.md
+++ b/packages/0x.js/CHANGELOG.md
@@ -1,5 +1,9 @@
# CHANGELOG
+vx.x.x
+------------------------
+ * Make `DecodedLogEvent<A>` contain `LogWithDecodedArgs<A>` under log key instead of merging it in like web3 does (#234)
+
v0.26.0
------------------------
* Add post-formatter for logs converting `blockNumber`, `logIndex`, `transactionIndex` from hexes to numbers (#231)
diff --git a/packages/0x.js/src/contract_wrappers/contract_wrapper.ts b/packages/0x.js/src/contract_wrappers/contract_wrapper.ts
index 7997b1647..c1c95c6db 100644
--- a/packages/0x.js/src/contract_wrappers/contract_wrapper.ts
+++ b/packages/0x.js/src/contract_wrappers/contract_wrapper.ts
@@ -95,13 +95,13 @@ export class ContractWrapper {
await this._web3Wrapper.getContractInstanceFromArtifactAsync<ContractType>(artifact, addressIfExists);
return contractInstance;
}
- private _onLogStateChanged<ArgsType extends ContractEventArgs>(removed: boolean, log: Web3.LogEntry): void {
+ private _onLogStateChanged<ArgsType extends ContractEventArgs>(isRemoved: boolean, log: Web3.LogEntry): void {
_.forEach(this._filters, (filter: Web3.FilterObject, filterToken: string) => {
if (filterUtils.matchesFilter(log, filter)) {
const decodedLog = this._tryToDecodeLogOrNoop(log) as LogWithDecodedArgs<ArgsType>;
const logEvent = {
- ...decodedLog,
- removed,
+ log: decodedLog,
+ isRemoved,
};
this._filterCallbacks[filterToken](null, logEvent);
}
@@ -117,13 +117,13 @@ export class ContractWrapper {
this._blockAndLogStreamInterval = intervalUtils.setAsyncExcludingInterval(
this._reconcileBlockAsync.bind(this), constants.DEFAULT_BLOCK_POLLING_INTERVAL,
);
- let removed = false;
+ let isRemoved = false;
this._onLogAddedSubscriptionToken = this._blockAndLogStreamer.subscribeToOnLogAdded(
- this._onLogStateChanged.bind(this, removed),
+ this._onLogStateChanged.bind(this, isRemoved),
);
- removed = true;
+ isRemoved = true;
this._onLogRemovedSubscriptionToken = this._blockAndLogStreamer.subscribeToOnLogRemoved(
- this._onLogStateChanged.bind(this, removed),
+ this._onLogStateChanged.bind(this, isRemoved),
);
}
private _stopBlockAndLogStream(): void {
diff --git a/packages/0x.js/src/types.ts b/packages/0x.js/src/types.ts
index 595b90482..7d85a54ca 100644
--- a/packages/0x.js/src/types.ts
+++ b/packages/0x.js/src/types.ts
@@ -40,7 +40,10 @@ export type OrderValues = [BigNumber, BigNumber, BigNumber,
BigNumber, BigNumber, BigNumber];
export type LogEvent = Web3.LogEntryEvent;
-export type DecodedLogEvent<ArgsType> = Web3.DecodedLogEntryEvent<ArgsType>;
+export interface DecodedLogEvent<ArgsType> {
+ isRemoved: boolean;
+ log: LogWithDecodedArgs<ArgsType>;
+}
export type EventCallback<ArgsType> = (err: null|Error, log?: DecodedLogEvent<ArgsType>) => void;
export type EventWatcherCallback = (log: LogEvent) => void;
diff --git a/packages/0x.js/test/exchange_wrapper_test.ts b/packages/0x.js/test/exchange_wrapper_test.ts
index b5fa47f8b..13ac4c1d3 100644
--- a/packages/0x.js/test/exchange_wrapper_test.ts
+++ b/packages/0x.js/test/exchange_wrapper_test.ts
@@ -649,7 +649,7 @@ describe('ExchangeWrapper', () => {
(async () => {
const callback = (err: Error, logEvent: DecodedLogEvent<LogFillContractEventArgs>) => {
- expect(logEvent.event).to.be.equal(ExchangeEvents.LogFill);
+ expect(logEvent.log.event).to.be.equal(ExchangeEvents.LogFill);
done();
};
await zeroEx.exchange.subscribeAsync(
@@ -665,7 +665,7 @@ describe('ExchangeWrapper', () => {
(async () => {
const callback = (err: Error, logEvent: DecodedLogEvent<LogCancelContractEventArgs>) => {
- expect(logEvent.event).to.be.equal(ExchangeEvents.LogCancel);
+ expect(logEvent.log.event).to.be.equal(ExchangeEvents.LogCancel);
done();
};
await zeroEx.exchange.subscribeAsync(
@@ -688,7 +688,7 @@ describe('ExchangeWrapper', () => {
await zeroEx.setProviderAsync(newProvider);
const callback = (err: Error, logEvent: DecodedLogEvent<LogFillContractEventArgs>) => {
- expect(logEvent.event).to.be.equal(ExchangeEvents.LogFill);
+ expect(logEvent.log.event).to.be.equal(ExchangeEvents.LogFill);
done();
};
await zeroEx.exchange.subscribeAsync(
diff --git a/packages/0x.js/test/token_wrapper_test.ts b/packages/0x.js/test/token_wrapper_test.ts
index 27fe63590..b3c8edcc4 100644
--- a/packages/0x.js/test/token_wrapper_test.ts
+++ b/packages/0x.js/test/token_wrapper_test.ts
@@ -361,10 +361,11 @@ 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(logEvent.isRemoved).to.be.false();
+ expect(logEvent.log.logIndex).to.be.equal(0);
+ expect(logEvent.log.transactionIndex).to.be.equal(0);
+ expect(logEvent.log.blockNumber).to.be.a('number');
+ const args = logEvent.log.args;
expect(args._from).to.be.equal(coinbase);
expect(args._to).to.be.equal(addressWithoutFunds);
expect(args._value).to.be.bignumber.equal(transferAmount);
@@ -379,7 +380,8 @@ describe('TokenWrapper', () => {
(async () => {
const callback = (err: Error, logEvent: DecodedLogEvent<ApprovalContractEventArgs>) => {
expect(logEvent).to.not.be.undefined();
- const args = logEvent.args;
+ expect(logEvent.isRemoved).to.be.false();
+ const args = logEvent.log.args;
expect(args._owner).to.be.equal(coinbase);
expect(args._spender).to.be.equal(addressWithoutFunds);
expect(args._value).to.be.bignumber.equal(allowanceAmount);