assembly/utils/create-token-utils.ts

16 lines
427 B
TypeScript
Raw Normal View History

2021-07-21 20:53:46 +00:00
export function createTokenUtils(tokens) {
const getTokenByAddress = address =>
tokens.find(token => token.address === address);
const getTokenByKey = key => tokens.find(token => token.key === key);
const tokenKeys = tokens.map(token => token.key);
const rootTokens = tokens.map(token => token.root);
return {
allTokens: tokens,
tokenKeys,
getTokenByAddress,
getTokenByKey,
rootTokens
};
}