aboutsummaryrefslogtreecommitdiffstats
path: root/test/utils/token_utils.ts
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2017-06-03 01:14:20 +0800
committerFabio Berger <me@fabioberger.com>2017-06-03 01:14:20 +0800
commitae15425f0b2d3f79b6f6b47d351cf51f8f68d2c0 (patch)
tree975320862a2eb0e8f97091bce95b0d901a5c587b /test/utils/token_utils.ts
parent6f98d8328419962e257c570e3fcb5cb4246162a3 (diff)
parentc83587a16d016d1efafaf31abb9b39eb54128568 (diff)
downloaddexon-sol-tools-ae15425f0b2d3f79b6f6b47d351cf51f8f68d2c0.tar
dexon-sol-tools-ae15425f0b2d3f79b6f6b47d351cf51f8f68d2c0.tar.gz
dexon-sol-tools-ae15425f0b2d3f79b6f6b47d351cf51f8f68d2c0.tar.bz2
dexon-sol-tools-ae15425f0b2d3f79b6f6b47d351cf51f8f68d2c0.tar.lz
dexon-sol-tools-ae15425f0b2d3f79b6f6b47d351cf51f8f68d2c0.tar.xz
dexon-sol-tools-ae15425f0b2d3f79b6f6b47d351cf51f8f68d2c0.tar.zst
dexon-sol-tools-ae15425f0b2d3f79b6f6b47d351cf51f8f68d2c0.zip
Merge branch 'master' into addEventSubscriptions
# Conflicts: # src/contract_wrappers/exchange_wrapper.ts # src/types.ts # test/exchange_wrapper_test.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;
+ }
+}