diff options
author | Brandon Millman <brandon.millman@gmail.com> | 2018-02-08 02:27:22 +0800 |
---|---|---|
committer | Brandon Millman <brandon.millman@gmail.com> | 2018-02-08 02:27:22 +0800 |
commit | f3c6cce4559d096a2f3babfc7af670d078a6f0dd (patch) | |
tree | 580c59d474d52affc57593d25eb1d0acd480d4b0 /packages/0x.js | |
parent | d9b1d31e7310f7f554f1740f93e4ccd5b5db90f5 (diff) | |
parent | a26e77074fdf5ea7a754a7a676ebd752668d3c82 (diff) | |
download | dexon-sol-tools-f3c6cce4559d096a2f3babfc7af670d078a6f0dd.tar dexon-sol-tools-f3c6cce4559d096a2f3babfc7af670d078a6f0dd.tar.gz dexon-sol-tools-f3c6cce4559d096a2f3babfc7af670d078a6f0dd.tar.bz2 dexon-sol-tools-f3c6cce4559d096a2f3babfc7af670d078a6f0dd.tar.lz dexon-sol-tools-f3c6cce4559d096a2f3babfc7af670d078a6f0dd.tar.xz dexon-sol-tools-f3c6cce4559d096a2f3babfc7af670d078a6f0dd.tar.zst dexon-sol-tools-f3c6cce4559d096a2f3babfc7af670d078a6f0dd.zip |
Merge branch 'development' into feature/testnet-faucets/queue-by-network
* development: (24 commits)
Fix Remco's github name in CODEOWNERS
Fix ABI error message
Stop using definite assignment assertion cause prettier doesn't handle that
Special-case ZRXToken snake case conversion
Fix linter errors
Generate contract wrappers on pre-build
Add missing async
Remove noImplicitThis
Tslint disable no-consecutive-blank-lines in generated files
Change compiled sources in contracts
Change utils
Change tests
Add base_contract.ts
Remove generated files
.gitignore gemerated files
Change the list of generated wrappers
Change contract templates
Add indices for index parameters so that their names don't collide
Use abi-gen for events in 0x.js
Fix artifacts path
...
Diffstat (limited to 'packages/0x.js')
-rw-r--r-- | packages/0x.js/contract_templates/contract.handlebars | 21 | ||||
-rw-r--r-- | packages/0x.js/contract_templates/partials/event.handlebars | 5 | ||||
-rw-r--r-- | packages/0x.js/src/contract_wrappers/ether_token_wrapper.ts | 12 | ||||
-rw-r--r-- | packages/0x.js/src/contract_wrappers/exchange_wrapper.ts | 10 | ||||
-rw-r--r-- | packages/0x.js/src/contract_wrappers/token_wrapper.ts | 13 | ||||
-rw-r--r-- | packages/0x.js/src/index.ts | 35 | ||||
-rw-r--r-- | packages/0x.js/src/order_watcher/order_state_watcher.ts | 24 | ||||
-rw-r--r-- | packages/0x.js/src/types.ts | 76 |
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..33699b8a7 100644 --- a/packages/0x.js/contract_templates/contract.handlebars +++ b/packages/0x.js/contract_templates/contract.handlebars @@ -1,7 +1,8 @@ /** * 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:no-consecutive-blank-lines // tslint:disable-next-line:no-unused-variable import { TxData, TxDataPayable } from '@0xproject/types'; import { BigNumber, classUtils, promisify } from '@0xproject/utils'; @@ -9,6 +10,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..6d68d4c0f --- /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..e489dd5cc 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,32 @@ 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, 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 { |