diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-07-05 02:06:13 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-07-05 02:06:13 +0800 |
commit | 43bebf6d61be47ecab977ea328f580c4588b4804 (patch) | |
tree | ff91b31d44eaafa0c244232cd13d843d92e7681d /src/contract_wrappers | |
parent | 40d1d30b5816c9631fd4a0aa9824c6fea0d11bec (diff) | |
download | dexon-0x-contracts-43bebf6d61be47ecab977ea328f580c4588b4804.tar.gz dexon-0x-contracts-43bebf6d61be47ecab977ea328f580c4588b4804.tar.zst dexon-0x-contracts-43bebf6d61be47ecab977ea328f580c4588b4804.zip |
Add parameter validation for subscribeAsync
Diffstat (limited to 'src/contract_wrappers')
-rw-r--r-- | src/contract_wrappers/exchange_wrapper.ts | 6 | ||||
-rw-r--r-- | src/contract_wrappers/token_wrapper.ts | 4 |
2 files changed, 10 insertions, 0 deletions
diff --git a/src/contract_wrappers/exchange_wrapper.ts b/src/contract_wrappers/exchange_wrapper.ts index 6a85e2592..9d9428327 100644 --- a/src/contract_wrappers/exchange_wrapper.ts +++ b/src/contract_wrappers/exchange_wrapper.ts @@ -40,6 +40,8 @@ import {ProxyWrapper} from './proxy_wrapper'; import {ExchangeArtifactsByName} from '../exchange_artifacts_by_name'; import {ecSignatureSchema} from '../schemas/ec_signature_schema'; import {signedOrdersSchema} from '../schemas/signed_orders_schema'; +import {subscriptionOptsSchema} from '../schemas/subscription_opts_schema'; +import {indexFilterValuesSchema} from '../schemas/index_filter_values_schema'; import {orderFillRequestsSchema} from '../schemas/order_fill_requests_schema'; import {orderCancellationRequestsSchema} from '../schemas/order_cancel_schema'; import {orderFillOrKillRequestsSchema} from '../schemas/order_fill_or_kill_requests_schema'; @@ -585,6 +587,10 @@ export class ExchangeWrapper extends ContractWrapper { public async subscribeAsync(eventName: ExchangeEvents, subscriptionOpts: SubscriptionOpts, indexFilterValues: IndexedFilterValues, exchangeContractAddress: string): Promise<ContractEventEmitter> { + assert.isETHAddressHex('exchangeContractAddress', exchangeContractAddress); + assert.doesBelongToStringEnum('eventName', eventName, ExchangeEvents); + assert.doesConformToSchema('subscriptionOpts', subscriptionOpts, subscriptionOptsSchema); + assert.doesConformToSchema('indexFilterValues', indexFilterValues, indexFilterValuesSchema); const exchangeContract = await this._getExchangeContractAsync(exchangeContractAddress); let createLogEvent: CreateContractEvent; switch (eventName) { diff --git a/src/contract_wrappers/token_wrapper.ts b/src/contract_wrappers/token_wrapper.ts index d3ef5d6cf..1ad1cd9d6 100644 --- a/src/contract_wrappers/token_wrapper.ts +++ b/src/contract_wrappers/token_wrapper.ts @@ -205,6 +205,10 @@ export class TokenWrapper extends ContractWrapper { */ public async subscribeAsync(tokenAddress: string, eventName: TokenEvents, subscriptionOpts: SubscriptionOpts, indexFilterValues: IndexedFilterValues): Promise<ContractEventEmitter> { + assert.isETHAddressHex('tokenAddress', tokenAddress); + assert.doesBelongToStringEnum('eventName', eventName, TokenEvents); + assert.doesConformToSchema('subscriptionOpts', subscriptionOpts, subscriptionOptsSchema); + assert.doesConformToSchema('indexFilterValues', indexFilterValues, indexFilterValuesSchema); const tokenContract = await this._getTokenContractAsync(tokenAddress); let createLogEvent: CreateContractEvent; switch (eventName) { |