UNPKG

wallets-wrapper

Version:

How to install

74 lines (73 loc) 2.8 kB
import { ethers, Transaction } from 'ethers'; import { BehaviorSubject } from 'rxjs'; import { AccountInfo, ApproveToken, GetContractBalance, IProviderRpcError, IStandardContract, SetApprovalForAll, TransferContractToken, WalletStateProps } from '../../../models'; import { ChainIds, ContractTypes, StandardContractProps } from '../models'; import { ERC20, ERC721, ERC1155 } from './simpleContracts'; /** * The client describes how to work with ERC20, ERC721, ERC1155 contracts . * @implements IStandardContract * @class */ export declare class StandardContract implements IStandardContract { private contract; errors$: BehaviorSubject<IProviderRpcError | null>; private signer; private sendSignedTransaction; address: string; name: string | undefined; symbol: string | undefined; network: ChainIds | undefined; decimals: number; type: ContractTypes | undefined; constructor({ address, signer, sendSignedTransaction, network, errors$, }: StandardContractProps & Partial<WalletStateProps>); /** * Gives access to contract methods, * if you don't call init client just won't know which contract to use * @async */ init(): Promise<void>; checkInitialization(): ERC20 | ERC721 | ERC1155; checkType(type: ContractTypes): boolean; getContract(): ethers.Contract; getName(): Promise<string | undefined>; getSymbol(): Promise<string | undefined>; /** * Check balance in contract * @param {GetContractBalance} object, * @return {Promise<number>} * @async */ getBalance(arg?: GetContractBalance): Promise<AccountInfo[]>; /** * Transfer token * @param {TransferContractToken} args * @return {Promise<Transaction>} * @async */ transfer(args: TransferContractToken): Promise<Transaction>; /** * Get token uri, only works when this.type === 'ERC721' * @param {string} tokenId * @return {Promise<string>} * @async */ getTokenUri(tokenId: string): Promise<string>; /** * Approve token for ERC20 and ERC721 * @param {ApproveToken} object * @return {Promise<ethers.providers.TransactionResponse>} * @async */ approve(args: ApproveToken): Promise<ethers.providers.TransactionResponse>; /** * setApprovalForAll token for ERC721 and ERC1155 * @param {SetApprovalForAll} object * @return {Promise<ethers.providers.TransactionResponse>} * @async */ setApprovalForAll(args: SetApprovalForAll): Promise<ethers.providers.TransactionResponse>; /** * Subscribe on transfer events in contract */ transferEvents(): BehaviorSubject<import("../../../models").TransferEvent | null>; }