UNPKG

@enclavemoney/enclave-wallet-sdk

Version:

A simple enclave wallet SDK for React applications

609 lines (608 loc) 17.6 kB
declare const API_BASE_URL: string; import { IMultiTransaction, TokenURI } from "../types/activity"; export interface OutputDetails { amount: string; amountFormatted: string; amountUsd: string; minimumAmount: string; } export interface MultiRelayBuyQuoteParams { username: string; amount: number; outputToken: string; outputChainId: number; } export interface TokenBalance { symbol: string; balance: string; balanceInUsd: string; } export interface BalanceResponse { success: boolean; data: any; portfolioSummary?: any; } export interface MultiRelaySellQuoteParams { username: string; amount: number; inputToken: string; chainId: number; } export interface MultiRelaySwapQuoteParams { username: string; userBalance: any[] | undefined; outputToken: string; outputChainId: number; inputAmount?: number | string; proMode?: boolean; txsGasLimit?: number; metadata?: { inputToken: TokenURI; outputToken: TokenURI; }; } export interface BuyFlowParams { username: string; amount: number; outputToken: string; outputChainId: number; txGasLimit: number; } export interface SellFlowParams { username: string; amount: number; inputToken: string; chainId: number; } export interface SwapInput { chainId: number; tokenAddress: string; amount: string; } export interface SwapFlowParams { username: string; userBalance: any[] | undefined; outputToken: string | undefined; outputChainId: number | undefined; metadata: { inputToken: TokenURI; outputToken: TokenURI; }; inputAmount?: number | string; proMode?: boolean; txsGasLimit?: number; } export interface TransactionResult { chainId: number; success: boolean; txnHash: string; requestId?: string; } export interface TransferFlowParams { username: string; inputAmount: string; outputToken: string; outputDecimals: number; outputChainId: number; recipient: string; userBalance: any[]; metadata?: any; } export interface TransferResponse { spendPlan: { total_withdrawn: string; spend_distribution: { [key: string]: string; }; remaining_balance: string; }; onChainTransfer?: { chainId: number; txHash: string; }; relayTransfer?: { type: string; success: boolean; evmTransactions: TransactionResult[]; solanaTransactions: TransactionResult[]; }; outputDetails: { amount: string; minimumAmount: string; amountFormatted: string; }; } export interface User { username: string; walletAddress: string; solana_program_wallet: string; ens: string; } export interface TokenDetail { amount: string; amountFormatted: string; tokenAddress: string; tokenName: string; tokenSymbol: string; receiver?: User; } export interface ChainTokenDetails { [chainId: string]: TokenDetail[]; } export interface ChainTransactions { [chainId: string]: { [txHash: string]: string; }; } export interface TransactionMetadata { senderDetails: User; receiverDetails: User[]; inputAmounts: ChainTokenDetails; destinationAmounts: ChainTokenDetails; status: string; lastUpdatedTimestamp: number; transactions: ChainTransactions; requestIdsMap?: { [chainId: string]: string; }; } export interface ActivityItem { _id: string; multiTransactionId: string; sender: User; transactionType: string; transactionDescription: string; receivers: User[]; sourceChains: number[]; destinationChains: number[]; inputTokens: ChainTokenDetails; outputTokens: ChainTokenDetails; transactions: ChainTransactions; overallStatus: string; metadata: TransactionMetadata; createdTimestamp: number; lastUpdatedTimestamp: number; updatedAt: string; __v: number; } export interface ActivityResponse { success: boolean; data: IMultiTransaction[]; pagination?: { currentPage: number; totalPages: number; totalCount: number; limit: number; hasNextPage: boolean; hasPreviousPage: boolean; nextPage: number | null; previousPage: number | null; }; } export interface BTCLifiSwapQuoteParams { username: string; inputAmount: number | string; outputToken: string; outputChainId: number; metadata: { inputToken: TokenURI; outputToken: TokenURI; }; proMode?: boolean; userBalance: any[] | undefined; } export interface ToBTCRelaySwapQuoteParams { username: string; userBalance: any[] | undefined; inputAmount?: number | string; proMode?: boolean; txsGasLimit?: number; } export interface ToBTCSwapFlowParams { username: string; userBalance: any[] | undefined; inputAmount?: number | string; proMode: boolean; metadata: { inputToken: TokenURI; outputToken: TokenURI; }; } export interface FromBTCSwapFlowParams { username: string; inputAmount: number | string; outputToken: string; outputChainId: number; metadata: { inputToken: TokenURI; outputToken: TokenURI; }; proMode?: boolean; userBalance: any[] | undefined; } export interface BitcoinTransferParams { username: string; inputAmount: string; recipient: string; outputChainId: number; metadata?: { token: { tokenSymbol: string; tokenName: string; decimals: number; logoURI?: string; }; receiver: { username?: string; walletAddress?: string; solanaWalletAddress?: string; ensName?: string; sns?: string; }; }; } export interface BitcoinTransferResponse { success: boolean; transactionDetails: { multiTransactionId: string; txHash?: string; }; } /** * Fetches a buy quote from the multi-relay endpoint * @param params Request parameters for the quote * @param apiKey The wallet SDK key for authorization * @returns The output details from the quote response */ export declare const getMultiRelayBuyQuote: (params: MultiRelayBuyQuoteParams, apiKey: string) => Promise<OutputDetails | string>; export declare const getMultiRelaySellQuote: (params: MultiRelaySellQuoteParams, apiKey: string) => Promise<OutputDetails | string>; export declare const getMultiRelaySwapQuote: (params: MultiRelaySwapQuoteParams, apiKey: string) => Promise<OutputDetails | any>; export declare const getMultiFromBTCLifiSwapQuote: (params: BTCLifiSwapQuoteParams, apiKey: string) => Promise<OutputDetails | any>; export declare const getMultiToBTCRelaySwapQuote: (params: ToBTCRelaySwapQuoteParams, apiKey: string) => Promise<OutputDetails | any>; /** * Fetches the user's crypto balance * @param username The user's username * @param apiKey The wallet SDK key for authorization * @returns The user's crypto balance data */ export declare const getUserCryptoBalance: (username: string, apiKey: string) => Promise<BalanceResponse | null>; /** * Executes a buy flow transaction * @param params The buy flow parameters * @param apiKey The wallet SDK key for authorization * @returns The transaction response */ export declare const executeBuyFlow: (params: BuyFlowParams, apiKey: string) => Promise<any>; /** * Executes a sell flow transaction * @param params The sell flow parameters * @param apiKey The wallet SDK key for authorization * @returns The transaction response */ export declare const executeSellFlow: (params: SellFlowParams, apiKey: string) => Promise<any>; /** * Executes a swap flow transaction * @param params The swap flow parameters * @param apiKey The wallet SDK key for authorization * @returns The transaction response */ export declare const executeSwapFlow: (params: SwapFlowParams, apiKey: string) => Promise<any>; /** * Executes a bungee swap flow transaction * @param params The swap flow parameters * @param apiKey The wallet SDK key for authorization * @returns The transaction response */ export declare const executeBungeeSwapFlow: (params: SwapFlowParams, apiKey: string) => Promise<any>; /** * Executes a CCTP swap flow transaction for USDC to USDC transfers * @param params The swap flow parameters * @param apiKey The wallet SDK key for authorization * @returns The transaction response */ export declare const executeCCTPSwapFlow: (params: SwapFlowParams, apiKey: string) => Promise<any>; /** * Executes a LiFi swap flow transaction * @param params The swap flow parameters * @param apiKey The wallet SDK key for authorization * @returns The transaction response */ export declare const executeLiFiSwapFlow: (params: SwapFlowParams, apiKey: string) => Promise<any>; export declare const executeCCTPV2SwapFlow: (params: SwapFlowParams, apiKey: string) => Promise<any>; export declare const executeTransferFlow: (params: TransferFlowParams, apiKey: string) => Promise<TransferResponse>; export declare const getMultiTransactionsList: (username: string, apiKey: string, page?: number) => Promise<ActivityResponse | null>; export interface TxnInfoResponse { transaction: IMultiTransaction; } export declare const getTransactionInfo: (multiTransactionId: string, apiKey: string) => Promise<IMultiTransaction | null>; export interface TokenInfo { symbol: string; name: string; logoURI?: string; icon?: string; address: string; chainId: number; chainIds?: Array<{ chainId: number; address: string; }>; decimals: number; balance?: string; amount?: number; priceUsd?: number; price?: number; } export interface AllTokensResponse { success: boolean; tokens: TokenInfo[]; } export declare const getAllTokens: (apiKey: string) => Promise<AllTokensResponse | null>; export interface SearchTokenResponse { success: boolean; data: { name: string; symbol: string; decimals: number; logoURI: string; chainIds: Array<{ chainId: string; address: string; }>; price: number; }; } export declare const searchToken: (tokenAddress: string, chainId: number, apiKey: string) => Promise<SearchTokenResponse | null>; export interface TokenSearchResponse { success: boolean; data: TokenInfo[]; } export declare const searchTokensByQuery: (query: string, apiKey: string) => Promise<TokenSearchResponse | null>; /** * Executes a swap to BTC flow transaction * @param params The swap to BTC flow parameters * @param apiKey The wallet SDK key for authorization * @returns The transaction response */ export declare const executeToBTCSwapFlow: (params: ToBTCSwapFlowParams, apiKey: string) => Promise<any>; /** * Executes a swap from BTC flow transaction * @param params The swap from BTC flow parameters * @param apiKey The wallet SDK key for authorization * @returns The transaction response */ export declare const executeFromBTCSwapFlow: (params: FromBTCSwapFlowParams, apiKey: string) => Promise<any>; export declare const executeBitcoinTransfer: (params: BitcoinTransferParams, apiKey: string) => Promise<BitcoinTransferResponse>; export interface SocialLoginParams { googleUser?: any; twitterUser?: any; } export interface SocialLoginResponse { username: string; socialLoginDetails: { googleUser?: { email: string; displayName: string; photoURL: string; uid: string; }; twitterUser?: { uid: string; username?: string; name?: string; profile_image_url?: string; email?: string; }; }; verified: boolean; multiUserOps: any; wallet: { scw_address: string; type: string; multi_scw: Array<{ network: number; address: string; deployed: boolean; }>; eoa_address: string; solana_public_key: string; solana_program_wallet: string; bitcoin_wallet: { legacy_address: string; segwit_address: string; native_segwit_address: string; taproot_address: string; }; }; orgId: string; addedOn: number; updatedOn: number; version: number; smartBalanceEnabled: boolean; _id: string; __v: number; token: string; } export declare const getSocialAccount: (params: SocialLoginParams, apiKey: string) => Promise<SocialLoginResponse>; export interface OptimalSourceTokenDistributionParams { username: string; inputAmount: number; tokenIdentifier: { chainId: number; tokenAddress: string; }; } export interface OptimalSourceTokenDistributionInput { inputAmount: number; tokenIdentifier: { chainId: number; tokenAddress: string; }; } export declare enum QuoteType { AMOUNT_IN = "AMOUNT_IN", AMOUNT_OUT = "AMOUNT_OUT" } export declare enum QuoteChoice { BEST_QUOTE = "BEST_QUOTE", FAST_QUOTE = "FAST_QUOTE" } export interface ComputeQuoteInput { fromTokens: { chainId: number; address: string; balance: string; }[]; toToken: { tokenAddress: string; chainId: number; }; quoteType: QuoteType; } export interface ComputeQuoteParams { username: string; fromTokens: { chainId: number; address: string; balance: string; }[]; toToken: { tokenAddress: string; chainId: number; }; quoteType: QuoteType; } export interface QuoteDetails { success: boolean; provider: string; fees: string; estimatedTime: number; inputDetails: { amount?: string; amountUsd: string; }; outputDetails: { amount: string; amountFormatted: string; amountUsd: string; minimumAmount: string; }; rate: string; } export interface ComputeQuoteResponse { success: boolean; bestQuote: QuoteDetails; fastestQuote: QuoteDetails; } export interface SourceTokensInput { tokenAddress: string; chainId: number; } export interface TokenChainInfo { chainId: number; address: string; } export interface SourceTokensResponse { success: boolean; data: { name: string; symbol: string; decimals: number; logoURI?: string; chainIds: TokenChainInfo[]; }; } export interface User { username: string; walletAddress: string; solana_program_wallet: string; bitcoin_native_segwit_address: string; ens: string; } export interface TokenDetails { tokenName: string; tokenSymbol: string; decimals: number; logoURI: string; } export interface SwapTransactionDetails { multiTransactionId: string; provider: string; orgId: string; transactionType: string; sender: User; receivers: User[]; sourceChains: number[]; destinationChains: number[]; inputTokens: Record<string, any>; outputTokens: Record<string, any>; inputTransactions: Record<string, any>; outputTransactions: Record<string, any>; overallStatus: string; metadata: { senderDetails: User; receiverDetails: User[]; inputAmounts: Record<string, any>; destinationAmounts: Record<string, any>; lastUpdatedTimestamp: number; tokenDetails: { inputToken: TokenDetails; outputToken: TokenDetails; }; totalInputAmount: string; totalOutputAmount: string; enclaveFee: string; enclaveFeeUsd: string; partnerFee: string; partnerFeeUsd: string; }; estimatedTime: number; createdTimestamp: number; lastUpdatedTimestamp: number; } export interface SwapResult { success: boolean; estimatedTime: number; outputDetails: { amount: string; amountFormatted: string; amountUsd: string; minimumAmount: string; }; lifiSwap: Array<{ chainId: number; success: boolean; txnHash: string; requestId: string; }>; transactionDetails: SwapTransactionDetails; } export interface ExecuteSwapResponse { success: boolean; result: SwapResult; } export interface OptimalSourceTokenDistributionResponse { success: boolean; data: any; } /** * Gets optimal source token distribution * @param params The request parameters * @param apiKey The wallet SDK key for authorization * @returns The optimal distribution response */ export declare const getOptimalSourceTokenDistribution: (params: OptimalSourceTokenDistributionParams, apiKey: string) => Promise<OptimalSourceTokenDistributionResponse | null>; /** * Computes quote for token swap * @param params The request parameters * @param apiKey The wallet SDK key for authorization * @returns The compute quote response */ export declare const computeQuote: (params: ComputeQuoteParams, apiKey: string) => Promise<ComputeQuoteResponse | null>; /** * Gets source tokens from token identifier * @param params The request parameters (tokenAddress and chainId) * @param apiKey The wallet SDK key for authorization * @returns The source tokens response */ export declare const getSourceTokensFromTokenIdentifier: (params: SourceTokensInput, apiKey: string) => Promise<SourceTokensResponse | null>; export { API_BASE_URL };