UNPKG

@enclavemoney/enclave-wallet-sdk

Version:

A simple enclave wallet SDK for React applications

400 lines (399 loc) 12 kB
declare const API_BASE_URL = "https://hyperapp.in"; 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[]; } export interface BTCRelaySwapQuoteParams { username: string; amount: number | string; outputToken: string; outputChainId: number; } 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; amount: number | string; outputToken: string; outputChainId: number; metadata: { inputToken: TokenURI; outputToken: TokenURI; }; } 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 getMultiFromBTCRelaySwapQuote: (params: BTCRelaySwapQuoteParams, 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) => 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; } export interface SocialLoginResponse { username: string; socialLoginDetails: { googleUser: { email: string; displayName: string; photoURL: string; uid: 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; } export declare const getSocialAccount: (params: SocialLoginParams, apiKey: string) => Promise<SocialLoginResponse>; export { API_BASE_URL };