aboutsummaryrefslogtreecommitdiffstats
path: root/test/utils/token_utils.ts
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2017-06-03 01:45:57 +0800
committerFabio Berger <me@fabioberger.com>2017-06-03 01:45:57 +0800
commit1443c0838cbd795ae8e6273b1d7659c8e449f2eb (patch)
tree531df9d489dd4c5ce15623bee0beeae3ad58ccd4 /test/utils/token_utils.ts
parent3de655954743db4e2b9d02f5ac1243855b909236 (diff)
parentd4320fec724c5bf34e7dcd006cba8ffe7a3c76d1 (diff)
downloaddexon-sol-tools-1443c0838cbd795ae8e6273b1d7659c8e449f2eb.tar
dexon-sol-tools-1443c0838cbd795ae8e6273b1d7659c8e449f2eb.tar.gz
dexon-sol-tools-1443c0838cbd795ae8e6273b1d7659c8e449f2eb.tar.bz2
dexon-sol-tools-1443c0838cbd795ae8e6273b1d7659c8e449f2eb.tar.lz
dexon-sol-tools-1443c0838cbd795ae8e6273b1d7659c8e449f2eb.tar.xz
dexon-sol-tools-1443c0838cbd795ae8e6273b1d7659c8e449f2eb.tar.zst
dexon-sol-tools-1443c0838cbd795ae8e6273b1d7659c8e449f2eb.zip
Merge branch 'master' into remainingTokenMethods
# Conflicts: # src/types.ts # src/web3_wrapper.ts
Diffstat (limited to 'test/utils/token_utils.ts')
-rw-r--r--test/utils/token_utils.ts24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/utils/token_utils.ts b/test/utils/token_utils.ts
new file mode 100644
index 000000000..14788b299
--- /dev/null
+++ b/test/utils/token_utils.ts
@@ -0,0 +1,24 @@
+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.ZRX_NOT_IN_TOKEN_REGISTRY);
+ }
+ return zrxToken;
+ }
+ public getNonProtocolTokens(): Token[] {
+ const nonProtocolTokens = _.filter(this.tokens, token => {
+ return token.symbol !== PROTOCOL_TOKEN_SYMBOL;
+ });
+ return nonProtocolTokens;
+ }
+}