frontend/imports/utils/functions.js
/**
 * Best case scenario:
 *  - a valid contract address is passed and we have corresponding token symbol
 *  then we return the symbol for the token.
 *
 *  If the token is a valid address by not known to the market, default value will be returned
 *  If the token is a symbol already but know among allowedTokens ,default value will be returned
 *  If the token is not known, default value is returned
 *
 * @param token - of type <any>
 * @param allowedTokens - of type <array> - market supports only specific tokens which can be used as base or quote tokens.
 * @param symbolIfNothingIsPresented - of type <string> - used as value if token is invalid value
 *  (not an address, not an address known to the market, not a symbol, not a symbol known to market.
 *
 * @return symbol
 *
 * @throws error if the method is invoked with missing attributes or the types of the attributes are different than expected
 */
Best case scenario:
- a valid contract address is passed and we have corresponding token symbol
then we return the symbol for the token.

If the token is a valid address by not known to the market, default value will be returned
If the token is a symbol already but know among allowedTokens ,default value will be returned
If the token is not known, default value is returned

@param token - of type 
@param allowedTokens - of type  - market supports only specific tokens which can be used as base or quote tokens.
@param symbolIfNothingIsPresented - of type  - used as value if token is invalid value
(not an address, not an address known to the market, not a symbol, not a symbol known to market.

@return symbol

@throws error if the method is invoked with missing attributes or the types of the attributes are different than expected
Best case scenario : - a valid contract address is passed and we have corresponding token symbol then we return the symbol for the token . If the token is a valid address by not known to the market default value will be returned If the token is a symbol already but know among allowedTokens default value will be returned If the token is not known default value is returned @param token - of type @param allowedTokens - of type - market supports only specific tokens which can be used as base or quote tokens . @param symbolIfNothingIsPresented - of type - used as value if token is invalid value ( not an address not an address known to the market not a symbol not a symbol known to market . @return symbol @throws error if the method is invoked with missing attributes or the types of the attributes are different than expected
function addressToSymbol(token, allowedTokens, symbolIfNothingIsPresented) {
  if (!token || !allowedTokens || !symbolIfNothingIsPresented
    || !Array.isArray(allowedTokens)
    || typeof symbolIfNothingIsPresented !== 'string') {
    throw Error('Wrong usage of the API. Read documentation');
  }
  const isAnAddress = web3Obj.isAddress(token);
  let currency = symbolIfNothingIsPresented;
  if (isAnAddress) {
    currency = Dapple.getTokenByAddress(token).toUpperCase();
  }
  if (allowedTokens.includes(token)) {
    currency = token.toUpperCase();
  }
  return currency;
}
function addressToSymbol ( token , allowedTokens , symbolIfNothingIsPresented ) { if ( ! token || ! allowedTokens || ! symbolIfNothingIsPresented || ! Array . isArray ( allowedTokens ) || typeof symbolIfNothingIsPresented !== 'string' ) { throw Error ( 'Wrong usage of the API. Read documentation' ) ; } const isAnAddress = web3Obj . isAddress ( token ) ; let currency = symbolIfNothingIsPresented ; if ( isAnAddress ) { currency = Dapple . getTokenByAddress ( token ) . toUpperCase ( ) ; } if ( allowedTokens . includes ( token ) ) { currency = token . toUpperCase ( ) ; } return currency ; }
Best case scenario:
  - a valid contract address is passed and we have corresponding token symbol
  then we return the symbol for the token.
Best case scenario : - a valid contract address is passed and we have corresponding token symbol then we return the symbol for the token .