UNPKG

enclave-wallet-sdk

Version:

A simple enclave wallet SDK for React applications

207 lines (206 loc) 6 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: TokenBalance[]; } 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; proMode?: boolean; txsGasLimit?: number; } 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; 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[]; } /** * 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>; /** * 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>; export declare const executeTransferFlow: (params: TransferFlowParams, apiKey: string) => Promise<TransferResponse>; export declare const getMultiTransactionsList: (username: string, apiKey: string) => Promise<ActivityResponse | null>; export { API_BASE_URL };