* development: (29 commits) Move call to error reporter to end of handler so that even if reporting the error takes a while, it doesn't block the UI Update outdated WETH ranges Fix conditional Fix top-padding Publish Update CHANGELOGs Add slashes to base URLs Fix linter issue Fix WETH symbol Update snapshot and artifacts Replace our EtherTokens with WETH9 from maker Fix test description Fix a typo Add err==null assertions Add WETH9 tests Use the new snapshot including WETH9 and it's artifacts Add WETH9 and mirations Fix WETH events watching Fix a typo Init the _etherTokenContractsByAddress ...
		
			
				
	
	
		
			34 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| import * as _ from 'lodash';
 | |
| 
 | |
| import {InternalZeroExError, Token} from '../../src/types';
 | |
| 
 | |
| const PROTOCOL_TOKEN_SYMBOL = 'ZRX';
 | |
| const WETH_TOKEN_SYMBOL = 'WETH';
 | |
| 
 | |
| 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(InternalZeroExError.ZrxNotInTokenRegistry);
 | |
|         }
 | |
|         return zrxToken;
 | |
|     }
 | |
|     public getWethTokenOrThrow(): Token {
 | |
|         const wethToken = _.find(this.tokens, {symbol: WETH_TOKEN_SYMBOL});
 | |
|         if (_.isUndefined(wethToken)) {
 | |
|             throw new Error(InternalZeroExError.WethNotInTokenRegistry);
 | |
|         }
 | |
|         return wethToken;
 | |
|     }
 | |
|     public getDummyTokens(): Token[] {
 | |
|         const dummyTokens = _.filter(this._tokens, token => {
 | |
|             return !_.includes([PROTOCOL_TOKEN_SYMBOL, WETH_TOKEN_SYMBOL], token.symbol);
 | |
|         });
 | |
|         return dummyTokens;
 | |
|     }
 | |
| }
 |