@skalenetwork/ima-js
Version:
Simple TS/JS library to interact with SKALE IMA
68 lines (67 loc) • 3.36 kB
TypeScript
/**
* @license
* SKALE ima-js
*
* 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/>.
*/
import { type Contract, type TransactionResponse } from 'ethers';
import { BaseContract } from '../BaseContract';
import { type ContractsStringMap } from '../../BaseChain';
import type TxOpts from '../../TxOpts';
export declare abstract class TokenManager extends BaseContract {
abstract tokenMappingLenghtSlot: number | null;
tokens: ContractsStringMap;
addToken(tokenName: string, contract: Contract): void;
abstract getTokenCloneAddress(originTokenAddress: string, originChainName: string): Promise<string>;
enableAutomaticDeploy(opts: TxOpts): Promise<TransactionResponse>;
disableAutomaticDeploy(opts: TxOpts): Promise<TransactionResponse>;
automaticDeploy(): Promise<string>;
grantRole(role: any, address: string, opts: TxOpts): Promise<TransactionResponse>;
AUTOMATIC_DEPLOY_ROLE(): Promise<string>;
TOKEN_REGISTRAR_ROLE(): Promise<string>;
hasTokenManager(chainName: string): Promise<boolean>;
ownerOf(tokenName: string, tokenId: number | string): Promise<string>;
waitForTokenClone(originTokenAddress: string, originChainName: string, sleepInterval?: number, iterations?: number): Promise<any>;
/**
* Returns the solidityPackedKeccak256 hash of a concatenation of the chainHash and the
* tokenMappingLenghtSlot. Internal function.
* @param {string} chainName - The name of the chain to use in the hash.
* @returns {string} - The resulting hash.
*/
_getMappingLengthSlot(chainName: string): string;
/**
* Returns the number of token mappings for a given chain name by reading the storage at the
* corresponding mapping length slot.
* @param {string} chainName - The name of the chain for which to get the token mapping length.
* @returns {Promise<number>} - The number of token mappings.
*/
getTokenMappingsLength(chainName: string): Promise<number>;
/**
* Fetches an array of token addresses mapped to a specific chain.
*
* @param chainName The name of the chain to fetch token addresses for.
* @param from The starting index in the token mapping.
* @param to The ending index in the token mapping.
* @returns A Promise that resolves to an array of token addresses.
*/
getTokenMappings(chainName: string, from: number, to: number): Promise<string[]>;
/**
* Fetches a token address mapped to a specific chain at the given index.
*
* @param chainName The name of the chain to fetch the token address for.
* @param index The index in the token mapping.
* @returns A Promise that resolves to the token address.
*/
private getMappedTokenAddress;
}