@skalenetwork/metaport
Version:
SKALE Metaport Widget
67 lines (66 loc) • 3.61 kB
TypeScript
/**
* @license
* SKALE Metaport
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* @file metaport.ts
* @copyright SKALE Labs 2023-Present
*/
import { Provider, Contract } from 'ethers';
import { MetaportConfig, TokenDataTypesMap, TokenContractsMap, TokenBalancesMap } from './interfaces';
import { TokenType, TokenData, CustomAbiTokenType } from './dataclasses';
import { MetaportState } from '../store/MetaportState';
import { MainnetChain, SChain } from '@skalenetwork/ima-js';
export declare const createTokenData: (tokenKeyname: string, chainName: string, tokenType: TokenType, config: MetaportConfig) => TokenData;
export declare const addTokenData: (tokenKeyname: string, chainName: string, tokenType: TokenType, config: MetaportConfig, tokens: TokenDataTypesMap) => void;
export declare const createTokensMap: (chainName1: string, chainName2: string | null, config: MetaportConfig) => TokenDataTypesMap;
export declare function createWrappedTokensMap(chainName1: string, config: MetaportConfig): TokenDataTypesMap;
export declare const findFirstWrapperChainName: (token: TokenData) => string | null;
export default class MetaportCore {
private _config;
constructor(config: MetaportConfig);
get config(): MetaportConfig;
/**
* Generates available tokens for a given chain or a pair of the chains.
*
* @param {string} from - Source chain name.
* @param {string | null} [to] - Destination chain name.
*
* @returns {TokenDataTypesMap} - Returns a map of token data types for the given chains.
*
* @example
*
* // To get tokens for 'a' -> 'b'
* const tokens = mpc.tokens('a', 'b');
*
* // To get all tokens from 'a'
* const tokens = mpc.tokens('a');
*/
tokens(from: string, to?: string | null): TokenDataTypesMap;
wrappedTokens(chainName: string): TokenDataTypesMap;
tokenBalance(tokenContract: Contract, address: string): Promise<bigint>;
tokenBalances(tokenContracts: TokenContractsMap, address: string): Promise<TokenBalancesMap>;
tokenContracts(tokens: TokenDataTypesMap, tokenType: TokenType, chainName: string, provider: Provider, customAbiTokenType?: CustomAbiTokenType): TokenContractsMap;
tokenContract(chainName: string, tokenKeyname: string, tokenType: TokenType, provider: Provider, customAbiTokenType?: CustomAbiTokenType, destChainName?: string): Contract | undefined;
originAddress(chainName1: string, chainName2: string, tokenKeyname: string, tokenType: TokenType): `0x${string}`;
endpoint(chainName: string): string;
ima(chainName: string): MainnetChain | SChain;
mainnet(): MainnetChain;
schain(chainName: string): SChain;
provider(chainName: string): Provider;
tokenChanged(chainName1: string, ima2: MainnetChain | SChain, token: TokenData | null | undefined, destChainName?: string): Partial<MetaportState>;
chainChanged(chainName1: string, chainName2: string, prevToken: TokenData): Partial<MetaportState>;
}