diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-06-02 21:24:11 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-06-02 21:24:11 +0800 |
commit | a07a9d8571928dbbe82d2cc0917dafe6b446f701 (patch) | |
tree | 64a8ba9eb122e2283dd1ee3bdd3d4a2797010dfd /test | |
parent | b983ce631291deb74cdeeb5cbb50956cfbd49027 (diff) | |
download | dexon-0x-contracts-a07a9d8571928dbbe82d2cc0917dafe6b446f701.tar dexon-0x-contracts-a07a9d8571928dbbe82d2cc0917dafe6b446f701.tar.gz dexon-0x-contracts-a07a9d8571928dbbe82d2cc0917dafe6b446f701.tar.bz2 dexon-0x-contracts-a07a9d8571928dbbe82d2cc0917dafe6b446f701.tar.lz dexon-0x-contracts-a07a9d8571928dbbe82d2cc0917dafe6b446f701.tar.xz dexon-0x-contracts-a07a9d8571928dbbe82d2cc0917dafe6b446f701.tar.zst dexon-0x-contracts-a07a9d8571928dbbe82d2cc0917dafe6b446f701.zip |
Add token utils
Diffstat (limited to 'test')
-rw-r--r-- | test/utils/token_utils.ts | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/utils/token_utils.ts b/test/utils/token_utils.ts new file mode 100644 index 000000000..11d334619 --- /dev/null +++ b/test/utils/token_utils.ts @@ -0,0 +1,23 @@ +import * as _ from 'lodash'; +import {Token, ZeroExError} from '../../src/types'; + +const PROTOCOL_TOKEN_SYMBOL = 'ZRX'; + +export class TokenUtils { + private tokens: Token[]; + constructor(tokens: Token[]) { + this.tokens = tokens; + } + public getProtocolTokenOrThrow(): Token { + const zrxToken = _.find(this.tokens, {symbol: PROTOCOL_TOKEN_SYMBOL}); + if (_.isUndefined(zrxToken)) { + throw new Error(ZeroExError.CONTRACT_NOT_DEPLOYED_ON_NETWORK); + } + return zrxToken; + } + public getNonProtocolTokens(): Token[] { + return _.filter(this.tokens, token => { + return token.symbol !== PROTOCOL_TOKEN_SYMBOL; + }); + } +} |