aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-06-15 22:21:27 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-06-15 22:21:27 +0800
commit76d6e6a7481a69c1c0100a90f30d5d28ec471e84 (patch)
treeea1fe12c633f02b8f25d75e9056764f84c7d0bff
parent424912040a7e68b6d07cd4ae40763d9bcd98de28 (diff)
downloaddexon-sol-tools-76d6e6a7481a69c1c0100a90f30d5d28ec471e84.tar
dexon-sol-tools-76d6e6a7481a69c1c0100a90f30d5d28ec471e84.tar.gz
dexon-sol-tools-76d6e6a7481a69c1c0100a90f30d5d28ec471e84.tar.bz2
dexon-sol-tools-76d6e6a7481a69c1c0100a90f30d5d28ec471e84.tar.lz
dexon-sol-tools-76d6e6a7481a69c1c0100a90f30d5d28ec471e84.tar.xz
dexon-sol-tools-76d6e6a7481a69c1c0100a90f30d5d28ec471e84.tar.zst
dexon-sol-tools-76d6e6a7481a69c1c0100a90f30d5d28ec471e84.zip
Add actual type for contract event arguments
-rw-r--r--src/contract_wrappers/exchange_wrapper.ts3
-rw-r--r--src/index.ts4
-rw-r--r--src/types.ts31
3 files changed, 36 insertions, 2 deletions
diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts
index 4698089eb..0b191ed93 100644
--- a/src/contract_wrappers/exchange_wrapper.ts
+++ b/src/contract_wrappers/exchange_wrapper.ts
@@ -22,6 +22,7 @@ import {
ContractResponse,
OrderCancellationRequest,
OrderFillRequest,
+ LogErrorArgs,
} from '../types';
import {assert} from '../utils/assert';
import {utils} from '../utils/utils';
@@ -712,7 +713,7 @@ export class ExchangeWrapper extends ContractWrapper {
private _throwErrorLogsAsErrors(logs: ContractEvent[]): void {
const errEvent = _.find(logs, {event: 'LogError'});
if (!_.isUndefined(errEvent)) {
- const errCode = errEvent.args.errorId.toNumber();
+ const errCode = (errEvent.args as LogErrorArgs).errorId.toNumber()
const errMessage = this._exchangeContractErrCodesToMsg[errCode];
throw new Error(errMessage);
}
diff --git a/src/index.ts b/src/index.ts
index 48e83fc19..041413994 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -19,4 +19,8 @@ export {
OrderCancellationRequest,
OrderFillRequest,
ContractEventEmitter,
+ LogErrorArgs,
+ LogCancelArgs,
+ LogFillArgs,
+ EventArgs,
} from './types';
diff --git a/src/types.ts b/src/types.ts
index 11d3182d8..742ac71ff 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -190,9 +190,38 @@ export interface ContractEvent {
address: string;
type: string;
event: string;
- args: any;
+ args: EventArgs;
}
+export interface LogFillArgs {
+ maker: string;
+ taker: string;
+ feeRecipient: string;
+ tokenM: string;
+ tokenT: string;
+ filledValueM: BigNumber.BigNumber;
+ filledValueT: BigNumber.BigNumber;
+ feeMPaid: BigNumber.BigNumber;
+ feeTPaid: BigNumber.BigNumber;
+ tokens: string;
+ orderHash: string;
+}
+export interface LogCancelArgs {
+ maker: string;
+ feeRecipient: string;
+ tokenM: string;
+ tokenT: string;
+ cancelledValueM: BigNumber.BigNumber;
+ cancelledValueT: BigNumber.BigNumber;
+ tokens: string;
+ orderHash: string;
+}
+export interface LogErrorArgs {
+ errorId: BigNumber.BigNumber;
+ orderHash: string;
+}
+export type EventArgs = LogFillArgs|LogCancelArgs|LogErrorArgs;
+
export interface Order {
maker: string;
taker: string;