diff options
author | Leonid <logvinov.leon@gmail.com> | 2017-10-16 16:40:20 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-16 16:40:20 +0800 |
commit | a798f32cc89b61788856073265d20ad3812576ae (patch) | |
tree | 43a7ee4b5dab08091178b09985e180ab8de7f53f /src/contract_wrappers/token_wrapper.ts | |
parent | c8b54f3bac33f28c315c7018b3185f59e9a474dc (diff) | |
parent | df5fe4a84f3c5ee8946fa615428c5b9de8f8b06f (diff) | |
download | dexon-sol-tools-a798f32cc89b61788856073265d20ad3812576ae.tar dexon-sol-tools-a798f32cc89b61788856073265d20ad3812576ae.tar.gz dexon-sol-tools-a798f32cc89b61788856073265d20ad3812576ae.tar.bz2 dexon-sol-tools-a798f32cc89b61788856073265d20ad3812576ae.tar.lz dexon-sol-tools-a798f32cc89b61788856073265d20ad3812576ae.tar.xz dexon-sol-tools-a798f32cc89b61788856073265d20ad3812576ae.tar.zst dexon-sol-tools-a798f32cc89b61788856073265d20ad3812576ae.zip |
Merge branch 'development' into setFillOrKillToUseRequestInterface
Diffstat (limited to 'src/contract_wrappers/token_wrapper.ts')
-rw-r--r-- | src/contract_wrappers/token_wrapper.ts | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/contract_wrappers/token_wrapper.ts b/src/contract_wrappers/token_wrapper.ts index abd090f7e..8dc4e61c5 100644 --- a/src/contract_wrappers/token_wrapper.ts +++ b/src/contract_wrappers/token_wrapper.ts @@ -16,6 +16,7 @@ import { MethodOpts, LogWithDecodedArgs, EventCallback, + TokenContractEventArgs, } from '../types'; const ALLOWANCE_TO_ZERO_GAS_AMOUNT = 47155; @@ -251,13 +252,14 @@ export class TokenWrapper extends ContractWrapper { * @param callback Callback that gets called when a log is added/removed * @return Subscription token used later to unsubscribe */ - public subscribe(tokenAddress: string, eventName: TokenEvents, indexFilterValues: IndexedFilterValues, - callback: EventCallback): string { + public subscribe<ArgsType extends TokenContractEventArgs>( + tokenAddress: string, eventName: TokenEvents, indexFilterValues: IndexedFilterValues, + callback: EventCallback<ArgsType>): string { assert.isETHAddressHex('tokenAddress', tokenAddress); assert.doesBelongToStringEnum('eventName', eventName, TokenEvents); assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema); assert.isFunction('callback', callback); - const subscriptionToken = this._subscribe( + const subscriptionToken = this._subscribe<ArgsType>( tokenAddress, eventName, indexFilterValues, artifacts.TokenArtifact.abi, callback, ); this._activeSubscriptions.push(subscriptionToken); @@ -280,13 +282,14 @@ export class TokenWrapper extends ContractWrapper { * the value is the value you are interested in. E.g `{_from: aUserAddressHex}` * @return Array of logs that match the parameters */ - public async getLogsAsync(tokenAddress: string, eventName: TokenEvents, subscriptionOpts: SubscriptionOpts, - indexFilterValues: IndexedFilterValues): Promise<LogWithDecodedArgs[]> { + public async getLogsAsync<ArgsType extends TokenContractEventArgs>( + tokenAddress: string, eventName: TokenEvents, subscriptionOpts: SubscriptionOpts, + indexFilterValues: IndexedFilterValues): Promise<Array<LogWithDecodedArgs<ArgsType>>> { assert.isETHAddressHex('tokenAddress', tokenAddress); assert.doesBelongToStringEnum('eventName', eventName, TokenEvents); assert.doesConformToSchema('subscriptionOpts', subscriptionOpts, schemas.subscriptionOptsSchema); assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema); - const logs = await this._getLogsAsync( + const logs = await this._getLogsAsync<ArgsType>( tokenAddress, eventName, subscriptionOpts, indexFilterValues, artifacts.TokenArtifact.abi, ); return logs; |