diff options
-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; + }); + } +} |