import { Address } from '@safeblock/blockchain-utils'; import { Network } from 'ethers'; import { default as SafeBlock } from '../sdk'; import { default as SdkExtension, PartialEventBus } from '../sdk/sdk-extension'; import { BasicToken } from '../types'; declare const events: { /** Fired after a token is added to the list */ onTokenAdded: (token: BasicToken) => null; /** Fired after a token is removed from the list */ onTokenRemoved: (token: BasicToken) => null; }; /** * SDK extension that stores and manages token lists. */ export default class TokensListExtension extends SdkExtension { private readonly sdk; private readonly eventBus; static name: string; readonly events: { /** Fired after a token is added to the list */ onTokenAdded: (token: BasicToken) => null; /** Fired after a token is removed from the list */ onTokenRemoved: (token: BasicToken) => null; }; private readonly _tokensList; onInitialize(): void; /** * SDK extension that stores and manages token lists. * * @param {SafeBlock} sdk SDK instance * @param {PartialEventBus} eventBus partial event bus * @param {Record | * Map | * [string, BasicToken[]][]} tokensList initial token list */ constructor(sdk: SafeBlock, eventBus: PartialEventBus, tokensList?: Record | Map | [string, BasicToken[]][]); private static toConsistent; /** * Check whether a token is present in the list. * * @param {BasicToken} token token to look for * @returns {boolean} `true` if the token exists */ exist(token: BasicToken): boolean; /** * Retrieve a token from the list. * * @param {Network} network network of the token * @param {Address} address token address * @returns the `BasicToken` if found, otherwise `null` */ get(network: Network, address: Address): BasicToken | null; /** * Add a token to the list. * * @param {BasicToken} token token to add */ add(token: BasicToken): this; /** * Remove a token from the list. * * @param {BasicToken} token token to remove */ remove(token: BasicToken): this; /** * Get a flat array of all registered tokens. * * @returns {BasicToken[]} list of all tokens */ get tokensList(): BasicToken[]; /** * List tokens of specific network * * @param {Network} network network * @returns {BasicToken[]} */ list(network: Network): BasicToken[]; /** * Get a list of networks represented by the registered tokens. * * @returns {Network[]} array of networks */ get networks(): Network[]; } export {};