UNPKG

@goequitize/rwa-token-sdk

Version:

SDK for creating and managing RWA token transactions with compliance features

184 lines (183 loc) 5.65 kB
import { ethers } from 'ethers'; import { UnsignedTransaction, TransactionResponse, GasInfo, TxBuildResult } from '../types'; /** * Abstract base class for RWA Token operations across different chains */ export declare abstract class RwaTokenBase { protected provider: ethers.JsonRpcProvider; protected chainId: number; private balanceCache; private decimalsCache; private symbolCache; /** * Create a new instance of the RwaTokenBase * @param provider The JSON-RPC provider instance * @param chainId The chain ID of the connected network */ constructor(provider: ethers.JsonRpcProvider, chainId: number); /** * Get the decimals of a token * @param tokenAddress The address of the token contract * @returns The number of decimals of the token */ getDecimals(tokenAddress: string): Promise<number>; /** * Get the symbol of a token * @param tokenAddress The address of the token contract * @returns The symbol of the token */ getSymbol(tokenAddress: string): Promise<string>; /** * Get the token balance of an address * @param tokenAddress The address of the token contract * @param walletAddress The address of the wallet to check the balance of * @returns The formatted token balance (e.g., 123.45) */ getTokenBalance(tokenAddress: string, walletAddress: string): Promise<string>; /** * Get information about current gas prices and estimated costs * @param txnType The type of transaction (used for gas estimation) * @returns Gas price information */ getGasInfo(txnType?: string): Promise<GasInfo>; /** * Sign a transaction using a private key * @param rawTx The unsigned transaction * @param privateKey The private key to sign with * @returns The signed transaction */ signTxn(rawTx: UnsignedTransaction, privateKey: string): Promise<string>; /** * Broadcast a signed transaction to the network * @param signedTxn The signed transaction hex string * @returns Transaction response information */ broadcast(signedTxn: string): Promise<TransactionResponse>; /** * Get the logs and status of a transaction * @param txHash The transaction hash * @returns The transaction logs and status */ getTxnLogs(txHash: string): Promise<{ status: 'success' | 'pending' | 'failed'; logs: any[]; }>; /** * Abstract method to build a mint transaction * Must be implemented by chain-specific classes */ abstract buildMintTxn(params: { to: string; amount: string; from: string; }): Promise<{ isError: boolean; errorMsg?: string; data?: { rawTx: UnsignedTransaction; gasCost: string; gasPrice: string; gasLimit: string; }; }>; /** * Abstract method to build a burn transaction * Must be implemented by chain-specific classes */ abstract buildBurnTxn(params: { from: string; amount: string; sender: string; }): Promise<{ isError: boolean; errorMsg?: string; data?: { rawTx: UnsignedTransaction; gasCost: string; gasPrice: string; gasLimit: string; }; }>; /** * Abstract method to build a transfer transaction * Must be implemented by chain-specific classes */ abstract buildTransferTxn(params: { to: string; amount: string; from: string; }): Promise<{ isError: boolean; errorMsg?: string; data?: { rawTx: UnsignedTransaction; gasCost: string; gasPrice: string; gasLimit: string; }; }>; /** * Abstract method to build a forced transfer transaction * Must be implemented by chain-specific classes */ abstract buildForcedTransferTxn(params: { from: string; to: string; amount: string; sender: string; }): Promise<{ isError: boolean; errorMsg?: string; data?: { rawTx: UnsignedTransaction; gasCost: string; gasPrice: string; gasLimit: string; }; }>; /** * Abstract method to build a pause transaction * Must be implemented by chain-specific classes */ abstract buildPauseTxn(params: { from: string; }): Promise<{ isError: boolean; errorMsg?: string; data?: { rawTx: UnsignedTransaction; gasCost: string; gasPrice: string; gasLimit: string; }; }>; /** * Abstract method to build an unpause transaction * Must be implemented by chain-specific classes */ abstract buildUnpauseTxn(params: { from: string; }): Promise<{ isError: boolean; errorMsg?: string; data?: { rawTx: UnsignedTransaction; gasCost: string; gasPrice: string; gasLimit: string; }; }>; /** * Build a cross-chain transfer transaction using LayerZero's OFT standard * @param params The parameters for the cross-chain transfer operation * @returns The transaction build result */ abstract buildCrossChainTransferTxn(params: { to: string; amount: string; destinationChainId: number; destinationAddress: string; adapterParams?: string; from: string; }): Promise<TxBuildResult>; }