aboutsummaryrefslogtreecommitdiffstats
path: root/packages/0x.js
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-02-06 19:07:19 +0800
committerAmir Bandeali <abandeali1@gmail.com>2018-02-07 09:27:47 +0800
commita7c51593e4e6bc514f4f975fdc6fb9207c52ac8e (patch)
tree65756c6c7d08abf1b1bf1c577fe97bde2bd5547a /packages/0x.js
parent218876ac196a1b1bf7eba096a7bc6a2b3b8556bf (diff)
downloaddexon-sol-tools-a7c51593e4e6bc514f4f975fdc6fb9207c52ac8e.tar
dexon-sol-tools-a7c51593e4e6bc514f4f975fdc6fb9207c52ac8e.tar.gz
dexon-sol-tools-a7c51593e4e6bc514f4f975fdc6fb9207c52ac8e.tar.bz2
dexon-sol-tools-a7c51593e4e6bc514f4f975fdc6fb9207c52ac8e.tar.lz
dexon-sol-tools-a7c51593e4e6bc514f4f975fdc6fb9207c52ac8e.tar.xz
dexon-sol-tools-a7c51593e4e6bc514f4f975fdc6fb9207c52ac8e.tar.zst
dexon-sol-tools-a7c51593e4e6bc514f4f975fdc6fb9207c52ac8e.zip
Use abi-gen for events in 0x.js
Diffstat (limited to 'packages/0x.js')
-rw-r--r--packages/0x.js/contract_templates/contract.handlebars20
-rw-r--r--packages/0x.js/contract_templates/partials/event.handlebars5
-rw-r--r--packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts12
-rw-r--r--packages/0x.js/src/contract_wrappers/exchange_wrapper.ts10
-rw-r--r--packages/0x.js/src/contract_wrappers/token_wrapper.ts13
-rw-r--r--packages/0x.js/src/index.ts35
-rw-r--r--packages/0x.js/src/order_watcher/order_state_watcher.ts25
-rw-r--r--packages/0x.js/src/types.ts76
8 files changed, 76 insertions, 120 deletions
diff --git a/packages/0x.js/contract_templates/contract.handlebars b/packages/0x.js/contract_templates/contract.handlebars
index d3fe1b8cc..227cfcc5a 100644
--- a/packages/0x.js/contract_templates/contract.handlebars
+++ b/packages/0x.js/contract_templates/contract.handlebars
@@ -1,6 +1,6 @@
/**
* This file is auto-generated using abi-gen. Don't edit directly.
- * Templates can be found at https://github.com/0xProject/0x.js/tree/development/packages/abi-gen-templates.
+ * Templates can be found at https://github.com/0xProject/0x.js/tree/development/packages/0x.js/contract_templates.
*/
// tslint:disable-next-line:no-unused-variable
import { TxData, TxDataPayable } from '@0xproject/types';
@@ -9,6 +9,24 @@ import * as Web3 from 'web3';
import {BaseContract} from './base_contract';
+{{#if events}}
+export type {{contractName}}ContractEventArgs =
+{{#each events}}
+ | {{name}}ContractEventArgs{{#if @last}};{{/if}}
+{{/each}}
+
+export enum {{contractName}}Events {
+ {{#each events}}
+ {{name}} = '{{name}}',
+ {{/each}}
+}
+
+{{#each events}}
+{{> event}}
+
+{{/each}}
+{{/if}}
+
export class {{contractName}}Contract extends BaseContract {
{{#each methods}}
{{#this.constant}}
diff --git a/packages/0x.js/contract_templates/partials/event.handlebars b/packages/0x.js/contract_templates/partials/event.handlebars
new file mode 100644
index 000000000..8f8676a4f
--- /dev/null
+++ b/packages/0x.js/contract_templates/partials/event.handlebars
@@ -0,0 +1,5 @@
+export interface {{name}}ContractEventArgs {
+ {{#each inputs}}
+ {{name}}: {{#returnType type}}{{/returnType}},
+ {{/each}}
+};
diff --git a/packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts b/packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts
index 32c9ae6a9..db7cdee43 100644
--- a/packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts
+++ b/packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts
@@ -5,19 +5,11 @@ import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
import { artifacts } from '../artifacts';
-import {
- BlockRange,
- EtherTokenContractEventArgs,
- EtherTokenEvents,
- EventCallback,
- IndexedFilterValues,
- TransactionOpts,
- ZeroExError,
-} from '../types';
+import { BlockRange, EventCallback, IndexedFilterValues, TransactionOpts, ZeroExError } from '../types';
import { assert } from '../utils/assert';
import { ContractWrapper } from './contract_wrapper';
-import { EtherTokenContract } from './generated/ether_token';
+import { EtherTokenContract, EtherTokenContractEventArgs, EtherTokenEvents } from './generated/ether_token';
import { TokenWrapper } from './token_wrapper';
/**
diff --git a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
index e0c85505c..c82b7ecf5 100644
--- a/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
+++ b/packages/0x.js/src/contract_wrappers/exchange_wrapper.ts
@@ -12,10 +12,7 @@ import {
EventCallback,
ExchangeContractErrCodes,
ExchangeContractErrs,
- ExchangeContractEventArgs,
- ExchangeEvents,
IndexedFilterValues,
- LogErrorContractEventArgs,
MethodOpts,
Order,
OrderAddresses,
@@ -33,7 +30,12 @@ import { OrderValidationUtils } from '../utils/order_validation_utils';
import { utils } from '../utils/utils';
import { ContractWrapper } from './contract_wrapper';
-import { ExchangeContract } from './generated/exchange';
+import {
+ ExchangeContract,
+ ExchangeContractEventArgs,
+ ExchangeEvents,
+ LogErrorContractEventArgs,
+} from './generated/exchange';
import { TokenWrapper } from './token_wrapper';
const SHOULD_VALIDATE_BY_DEFAULT = true;
diff --git a/packages/0x.js/src/contract_wrappers/token_wrapper.ts b/packages/0x.js/src/contract_wrappers/token_wrapper.ts
index 98c24d059..a018006b8 100644
--- a/packages/0x.js/src/contract_wrappers/token_wrapper.ts
+++ b/packages/0x.js/src/contract_wrappers/token_wrapper.ts
@@ -5,21 +5,12 @@ import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
import { artifacts } from '../artifacts';
-import {
- BlockRange,
- EventCallback,
- IndexedFilterValues,
- MethodOpts,
- TokenContractEventArgs,
- TokenEvents,
- TransactionOpts,
- ZeroExError,
-} from '../types';
+import { BlockRange, EventCallback, IndexedFilterValues, MethodOpts, TransactionOpts, ZeroExError } from '../types';
import { assert } from '../utils/assert';
import { constants } from '../utils/constants';
import { ContractWrapper } from './contract_wrapper';
-import { TokenContract } from './generated/token';
+import { TokenContract, TokenContractEventArgs, TokenEvents } from './generated/token';
import { TokenTransferProxyWrapper } from './token_transfer_proxy_wrapper';
/**
diff --git a/packages/0x.js/src/index.ts b/packages/0x.js/src/index.ts
index c3c8854da..161945443 100644
--- a/packages/0x.js/src/index.ts
+++ b/packages/0x.js/src/index.ts
@@ -9,26 +9,13 @@ export {
ExchangeContractErrs,
ContractEvent,
Token,
- ExchangeEvents,
- TokenEvents,
IndexedFilterValues,
BlockRange,
OrderCancellationRequest,
OrderFillRequest,
- LogErrorContractEventArgs,
- LogCancelContractEventArgs,
- LogFillContractEventArgs,
- ExchangeContractEventArgs,
- TransferContractEventArgs,
- ApprovalContractEventArgs,
- TokenContractEventArgs,
- EtherTokenContractEventArgs,
- WithdrawalContractEventArgs,
- DepositContractEventArgs,
ContractEventArgs,
Web3Provider,
ZeroExConfig,
- EtherTokenEvents,
MethodOpts,
OrderTransactionOpts,
TransactionOpts,
@@ -50,4 +37,26 @@ export {
TransactionReceiptWithDecodedLogs,
} from '@0xproject/types';
+export {
+ EtherTokenContractEventArgs,
+ WithdrawalContractEventArgs,
+ DepositContractEventArgs,
+ EtherTokenEvents,
+} from './contract_wrappers/generated/ether_token';
+
+export {
+ TransferContractEventArgs,
+ ApprovalContractEventArgs,
+ TokenContractEventArgs,
+ TokenEvents,
+} from './contract_wrappers/generated/token';
+
+export {
+ LogErrorContractEventArgs,
+ LogCancelContractEventArgs,
+ LogFillContractEventArgs,
+ ExchangeContractEventArgs,
+ ExchangeEvents,
+} from './contract_wrappers/generated/exchange';
+
export { TransactionReceipt } from '@0xproject/types';
diff --git a/packages/0x.js/src/order_watcher/order_state_watcher.ts b/packages/0x.js/src/order_watcher/order_state_watcher.ts
index a9b3eba68..9ff07b38d 100644
--- a/packages/0x.js/src/order_watcher/order_state_watcher.ts
+++ b/packages/0x.js/src/order_watcher/order_state_watcher.ts
@@ -6,26 +6,33 @@ import * as _ from 'lodash';
import { ZeroEx } from '../0x';
import { ExchangeWrapper } from '../contract_wrappers/exchange_wrapper';
+import {
+ DepositContractEventArgs,
+ EtherTokenEvents,
+ WithdrawalContractEventArgs,
+} from '../contract_wrappers/generated/ether_token';
+import {
+ ExchangeEvents,
+ LogCancelContractEventArgs,
+ LogFillContractEventArgs,
+} from '../contract_wrappers/generated/exchange';
+import {
+ ApprovalContractEventArgs,
+ TokenEvents,
+ TransferContractEventArgs,
+} from '../contract_wrappers/generated/token';
import { TokenWrapper } from '../contract_wrappers/token_wrapper';
import { BalanceAndProxyAllowanceLazyStore } from '../stores/balance_proxy_allowance_lazy_store';
import { OrderFilledCancelledLazyStore } from '../stores/order_filled_cancelled_lazy_store';
import {
- ApprovalContractEventArgs,
+ BlockParamLiteral,
ContractEventArgs,
- DepositContractEventArgs,
- EtherTokenEvents,
ExchangeContractErrs,
- ExchangeEvents,
- LogCancelContractEventArgs,
LogEvent,
- LogFillContractEventArgs,
OnOrderStateChangeCallback,
OrderState,
OrderStateWatcherConfig,
SignedOrder,
- TokenEvents,
- TransferContractEventArgs,
- WithdrawalContractEventArgs,
ZeroExError,
} from '../types';
import { assert } from '../utils/assert';
diff --git a/packages/0x.js/src/types.ts b/packages/0x.js/src/types.ts
index a2d1b9eb4..ab97f7775 100644
--- a/packages/0x.js/src/types.ts
+++ b/packages/0x.js/src/types.ts
@@ -4,6 +4,10 @@ import { BlockParam, BlockParamLiteral, ContractEventArg, LogWithDecodedArgs } f
import * as Web3 from 'web3';
+import { EtherTokenContractEventArgs, EtherTokenEvents } from './contract_wrappers/generated/ether_token';
+import { ExchangeContractEventArgs, ExchangeEvents } from './contract_wrappers/generated/exchange';
+import { TokenContractEventArgs, TokenEvents } from './contract_wrappers/generated/token';
+
export enum ZeroExError {
ExchangeContractDoesNotExist = 'EXCHANGE_CONTRACT_DOES_NOT_EXIST',
ZRXContractDoesNotExist = 'ZRX_CONTRACT_DOES_NOT_EXIST',
@@ -101,60 +105,6 @@ export interface ContractEvent {
args: ContractEventArgs;
}
-export interface LogFillContractEventArgs {
- maker: string;
- taker: string;
- feeRecipient: string;
- makerToken: string;
- takerToken: string;
- filledMakerTokenAmount: BigNumber;
- filledTakerTokenAmount: BigNumber;
- paidMakerFee: BigNumber;
- paidTakerFee: BigNumber;
- tokens: string;
- orderHash: string;
-}
-export interface LogCancelContractEventArgs {
- maker: string;
- feeRecipient: string;
- makerToken: string;
- takerToken: string;
- cancelledMakerTokenAmount: BigNumber;
- cancelledTakerTokenAmount: BigNumber;
- tokens: string;
- orderHash: string;
-}
-export interface LogErrorContractEventArgs {
- errorId: BigNumber;
- orderHash: string;
-}
-export type ExchangeContractEventArgs =
- | LogFillContractEventArgs
- | LogCancelContractEventArgs
- | LogErrorContractEventArgs;
-export interface TransferContractEventArgs {
- _from: string;
- _to: string;
- _value: BigNumber;
-}
-export interface ApprovalContractEventArgs {
- _owner: string;
- _spender: string;
- _value: BigNumber;
-}
-export interface DepositContractEventArgs {
- _owner: string;
- _value: BigNumber;
-}
-export interface WithdrawalContractEventArgs {
- _owner: string;
- _value: BigNumber;
-}
-export type TokenContractEventArgs = TransferContractEventArgs | ApprovalContractEventArgs;
-export type EtherTokenContractEventArgs =
- | TokenContractEventArgs
- | DepositContractEventArgs
- | WithdrawalContractEventArgs;
export type ContractEventArgs = ExchangeContractEventArgs | TokenContractEventArgs | EtherTokenContractEventArgs;
export interface Order {
@@ -197,24 +147,6 @@ export interface TokenAddressBySymbol {
[symbol: string]: string;
}
-export enum ExchangeEvents {
- LogFill = 'LogFill',
- LogCancel = 'LogCancel',
- LogError = 'LogError',
-}
-
-export enum TokenEvents {
- Transfer = 'Transfer',
- Approval = 'Approval',
-}
-
-export enum EtherTokenEvents {
- Transfer = 'Transfer',
- Approval = 'Approval',
- Deposit = 'Deposit',
- Withdrawal = 'Withdrawal',
-}
-
export type ContractEvents = TokenEvents | ExchangeEvents | EtherTokenEvents;
export interface IndexedFilterValues {