@broxus/js-bridge-essentials
Version:
Bridge JavaScript Essentials library
74 lines (73 loc) • 2.58 kB
TypeScript
import { AbstractStore, type ObjectLiteral, type Syncable, type TokenLikeModel, type TokenRaw, type Watchable } from '@broxus/js-core';
import type Web3 from 'web3';
import { type PayableMethodObject } from 'web3-eth-contract';
import { type EvmTokenAllowanceParams, type EvmTokenApproveParams, EvmTokenUtils } from '../../models/evm-token/EvmTokenUtils';
export interface EvmTokenData extends Omit<TokenRaw<string>, 'tags'> {
baseChainId?: string;
tags?: Set<string>;
totalSupply?: string;
}
export interface EvmTokenState {
isSyncing?: boolean;
isSyncingBalance?: boolean;
}
export interface EvmTokenCreateOptions extends Syncable, Watchable {
}
export declare class EvmToken<T extends EvmTokenData | ObjectLiteral = EvmTokenData> extends AbstractStore<EvmTokenData & T, EvmTokenState> implements TokenLikeModel<string> {
protected readonly _connection: Web3;
protected readonly _provider?: Web3 | undefined;
static Utils: typeof EvmTokenUtils;
constructor(_connection: Web3, data: string | Readonly<T & EvmTokenData>, _provider?: Web3 | undefined);
static create<V extends EvmTokenData | ObjectLiteral = EvmTokenData>(connection: Web3, data: string | Readonly<V & EvmTokenData>, options?: EvmTokenCreateOptions, provider?: Web3): Promise<EvmToken<V>>;
approve(params: Omit<EvmTokenApproveParams, 'tokenAddress'>): Promise<ReturnType<PayableMethodObject['send']>>;
allowance(params: Omit<EvmTokenAllowanceParams, 'tokenAddress'>): Promise<string>;
/** @deprecated Use EvmToken.balance (this.balance) instead */
getBalance(ownerAddress: string): Promise<string>;
balance(ownerAddress: string): Promise<string>;
/**
* Returns token root address as instance of Address.
* @returns {EvmTokenData['address']}
*/
get address(): EvmTokenData['address'];
/**
*
*/
get chainId(): EvmTokenData['chainId'];
/**
*
*/
get decimals(): EvmTokenData['decimals'];
/**
*
*/
get icon(): EvmTokenData['logoURI'];
/**
*
*/
get name(): EvmTokenData['name'];
/**
*
*/
get root(): string;
/**
*
*/
get symbol(): EvmTokenData['symbol'];
/**
*
*/
get totalSupply(): EvmTokenData['totalSupply'];
/**
*
*/
get vendor(): EvmTokenData['vendor'];
/**
* Get value by the given key
* @param {K extends keyof T & string} key
*/
get<K extends keyof T & string>(key: K): T[K];
/**
* Returns copy of the current token
*/
clone(): EvmToken<T>;
}