UNPKG

@goequitize/rwa-token-sdk

Version:

SDK for creating and managing RWA token transactions with compliance features

141 lines (140 loc) 5 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RwaTokenSDK = void 0; const ethers_1 = require("ethers"); const evm_1 = require("./chains/evm"); /** * @goequitize/rwa-token-sdk * SDK for RWA Token operations */ class RwaTokenSDK { /** * Create a new instance of the RwaTokenSDK * @param config The SDK configuration * @param tokenAddress The RWA token contract address * @param customChainConfig Optional custom chain configuration for EVM chains */ constructor(config, tokenAddress, customChainConfig) { this.config = config; this.provider = new ethers_1.ethers.JsonRpcProvider(config.rpcUrl); this.tokenAddress = tokenAddress; // All chains currently use the EVM implementation with appropriate configuration // In the future, for non-EVM chains, we would add other implementations here this.implementation = new evm_1.EvmRwaToken(this.provider, config.chainId, tokenAddress, customChainConfig); } /** * Get the token's decimals * @param tokenAddress Optional token address, defaults to the one provided in constructor * @returns The number of decimals of the token */ async getDecimals(tokenAddress) { return this.implementation.getDecimals(tokenAddress || this.tokenAddress); } /** * Get the token's symbol * @param tokenAddress Optional token address, defaults to the one provided in constructor * @returns The symbol of the token */ async getSymbol(tokenAddress) { return this.implementation.getSymbol(tokenAddress || this.tokenAddress); } /** * Get the token balance of an address * @param address The address to check * @param tokenAddress Optional token address, defaults to the one provided in constructor * @returns The formatted token balance */ async getTokenBalance(address, tokenAddress) { return this.implementation.getTokenBalance(tokenAddress || this.tokenAddress, address); } /** * Get gas price information * @param txnType Optional transaction type for gas estimation * @returns Gas price information */ async getGasInfo(txnType) { return this.implementation.getGasInfo(txnType); } /** * Build a mint transaction * @param params Parameters for the mint operation * @returns Transaction build result */ async buildMintTxn(params) { return this.implementation.buildMintTxn(params); } /** * Build a burn transaction * @param params Parameters for the burn operation * @returns Transaction build result */ async buildBurnTxn(params) { return this.implementation.buildBurnTxn(params); } /** * Build a transfer transaction * @param params Parameters for the transfer operation * @returns Transaction build result */ async buildTransferTxn(params) { return this.implementation.buildTransferTxn(params); } /** * Build a forced transfer transaction * @param params Parameters for the forced transfer operation * @returns Transaction build result */ async buildForcedTransferTxn(params) { return this.implementation.buildForcedTransferTxn(params); } /** * Build a pause transaction * @param params Parameters for the pause operation * @returns Transaction build result */ async buildPauseTxn(params) { return this.implementation.buildPauseTxn(params); } /** * Build an unpause transaction * @param params Parameters for the unpause operation * @returns Transaction build result */ async buildUnpauseTxn(params) { return this.implementation.buildUnpauseTxn(params); } /** * Sign a transaction using a private key * @param rawTx The unsigned transaction * @param privateKey The private key to sign with * @returns The signed transaction */ async signTxn(rawTx, privateKey) { return this.implementation.signTxn(rawTx, privateKey); } /** * Broadcast a signed transaction to the network * @param signedTxn The signed transaction * @returns Transaction response with hash and explorer URL */ async broadcast(signedTxn) { return this.implementation.broadcast(signedTxn); } /** * Get transaction logs and status * @param txHash The transaction hash * @returns Transaction logs and status */ async getTxnLogs(txHash) { return this.implementation.getTxnLogs(txHash); } /** * 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 */ async buildCrossChainTransferTxn(params) { return this.implementation.buildCrossChainTransferTxn(params); } } exports.RwaTokenSDK = RwaTokenSDK;