@goequitize/rwa-token-sdk
Version:
SDK for creating and managing RWA token transactions with compliance features
170 lines (169 loc) • 5.61 kB
TypeScript
import { ethers } from 'ethers';
import { RwaTokenBase } from '../base/RwaTokenBase';
import { TxBuildResult } from '../types';
/**
* Chain-specific configuration
*/
export interface EvmChainConfig {
/**
* Chain-specific explorer URL template (${txHash} will be replaced)
*/
explorerUrl: string;
/**
* Chain name for logging and error messages
*/
chainName: string;
/**
* Chain-specific gas pricing model ('legacy', 'eip1559' or 'custom')
*/
gasModel: 'legacy' | 'eip1559' | 'custom';
/**
* Function names that might differ across implementations
*/
functionNames?: {
/**
* Force transfer function name (defaults to 'forceTransfer')
*/
forceTransfer?: string;
/**
* Whitelist check function name (defaults to 'isWhitelisted')
*/
isWhitelisted?: string;
/**
* Pause check function name (defaults to 'paused')
*/
paused?: string;
};
}
/**
* EVM-compatible implementation of RWA Token operations
* Works across any EVM-compatible chain
*/
export declare class EvmRwaToken extends RwaTokenBase {
private tokenAddress;
private chainConfig;
/**
* Create a new instance of the EVM RWA Token module
* @param provider The JSON-RPC provider instance
* @param chainId The chain ID of the connected network
* @param tokenAddress The address of the RWA token contract
* @param customChainConfig Optional custom chain configuration
*/
constructor(provider: ethers.JsonRpcProvider, chainId: number, tokenAddress: string, customChainConfig?: Partial<EvmChainConfig>);
/**
* Get the explorer URL for a transaction
* @param txHash The transaction hash
* @returns The explorer URL or empty string if not available
*/
getExplorerUrl(txHash: string): string;
/**
* Validate if an address is whitelisted for token transfers
* @param address The address to check
* @returns True if the address is whitelisted, false otherwise
*/
isWhitelisted(address: string): Promise<boolean>;
/**
* Check if the token is currently paused
* @returns True if the token is paused, false otherwise
*/
isPaused(): Promise<boolean>;
/**
* Check if an address has a specific role
* @param address The address to check
* @param role The role to check for (e.g., 'MINTER_ROLE', 'BURNER_ROLE', 'ADMIN_ROLE')
* @returns True if the address has the role, false otherwise
*/
hasRole(address: string, role: string): Promise<boolean>;
/**
* Create an unsigned transaction with appropriate gas settings based on chain
* @param to Destination address
* @param data Transaction data
* @param value Native token value (optional)
* @param gasLimit Gas limit (optional)
* @param gasInfo Gas price information
* @returns Unsigned transaction object
*/
private createUnsignedTransaction;
/**
* Calculate gas cost for transaction display
* @param gasLimit Gas limit
* @param gasInfo Gas price information
* @returns Formatted gas cost
*/
private calculateGasCost;
/**
* Build a mint transaction
* @param params The parameters for the mint operation
* @returns The transaction build result
*/
buildMintTxn(params: {
to: string;
amount: string;
from: string;
}): Promise<TxBuildResult>;
/**
* Build a burn transaction
* @param params The parameters for the burn operation
* @returns The transaction build result
*/
buildBurnTxn(params: {
from: string;
amount: string;
sender: string;
}): Promise<TxBuildResult>;
/**
* Build a transfer transaction
* @param params The parameters for the transfer operation
* @returns The transaction build result
*/
buildTransferTxn(params: {
to: string;
amount: string;
from: string;
}): Promise<TxBuildResult>;
/**
* Build a forced transfer transaction (admin override)
* @param params The parameters for the forced transfer operation
* @returns The transaction build result
*/
buildForcedTransferTxn(params: {
from: string;
to: string;
amount: string;
}): Promise<TxBuildResult>;
/**
* Build a pause transaction
* @param params Parameters for the pause operation
* @returns The transaction build result
*/
buildPauseTxn(params: {
from: string;
}): Promise<TxBuildResult>;
/**
* Build an unpause transaction
* @param params Parameters for the unpause operation
* @returns The transaction build result
*/
buildUnpauseTxn(params: {
from: string;
}): Promise<TxBuildResult>;
/**
* 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
*/
buildCrossChainTransferTxn(params: {
to: string;
amount: string;
destinationChainId: number;
destinationAddress: string;
adapterParams?: string;
from: string;
}): Promise<TxBuildResult>;
/**
* Override the broadcast method to include chain-specific explorer URLs
* @param signedTxn The signed transaction hex string
* @returns Transaction response information
*/
broadcast(signedTxn: string): Promise<import("../types").TransactionResponse>;
}