UNPKG

@broxus/js-bridge-essentials

Version:

Bridge JavaScript Essentials library

34 lines (33 loc) 1.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TokenListContainer = void 0; const constants_1 = require("../../services/SolanaTokenListProvider/constants"); class TokenListContainer { tokenList; constructor(tokenList) { this.tokenList = tokenList; // } filterByTag(tag) { return new TokenListContainer(this.tokenList.filter(item => (item.tags || []).includes(tag))); } filterByChainId(chainId) { return new TokenListContainer(this.tokenList.filter(item => item.chainId === chainId)); } excludeByChainId(chainId) { return new TokenListContainer(this.tokenList.filter(item => item.chainId !== chainId)); } excludeByTag(tag) { return new TokenListContainer(this.tokenList.filter(item => !(item.tags || []).includes(tag))); } filterByClusterSlug(slug) { if (slug in constants_1.CLUSTER_SLUGS) { return this.filterByChainId(constants_1.CLUSTER_SLUGS[slug]); } throw new Error(`Unknown slug: ${slug}, please use one of ${Object.keys(constants_1.CLUSTER_SLUGS)}`); } getList() { return this.tokenList; } } exports.TokenListContainer = TokenListContainer;