UNPKG

swype-sdk

Version:

Official SDK for integrating Swype payment and credit services

279 lines (261 loc) 9.16 kB
import { JSX, ReactNode } from 'react'; import * as zustand from 'zustand'; import * as react_jsx_runtime from 'react/jsx-runtime'; interface KycModalProps { eoaAddress: string; onClose?: () => void; onComplete?: () => void; } declare function KycModal({ eoaAddress, onClose, onComplete, }: KycModalProps): JSX.Element | null; interface KycStoreState { acceptedTerms: boolean; acceptedRainTerms: boolean; isKycModalOpen: boolean; isSumsubProfileVerified: boolean; setAcceptedTerms: (accepted: boolean) => void; setAcceptedRainTerms: (accepted: boolean) => void; setKycModalOpen: (open: boolean) => void; setIsSumsubProfileVerified: (verified: boolean) => void; } declare const useKycStore: zustand.UseBoundStore<zustand.StoreApi<KycStoreState>>; interface CardStatusResponse { data: "userNotExisting" | "initiated" | "review" | "pending" | "approved" | "rejected"; } interface SumSubTokenResponse { data: { token: string; userId: string; }; } interface CreditDelegationRequest { creditType: "aave-v3" | "euler"; from: string; creditLimit: number; } interface CreditDelegationResponse { to: string; callData: string; value: string; } interface LinkCardRequest { cardID: string; creditProviderAddress: string; chainID: number; signature: string; creditType: "aave-v3" | "euler"; } type CardStatus = "initiated" | "pending" | "approved" | "userNotExisting" | "review" | "rejected"; interface UserCard { cardID: string; holdingAddress: string; type: "virtual" | "physical"; status: "active" | "inactive" | "pending"; last4: string; creditType: "aave-v3" | "euler"; expirationMonth: string; expirationYear: string; } interface UserCardsResponse { data: UserCard[] | null; } interface SuppliedAsset { UsageAsCollateralEnabledOnUser: boolean; amount: number; amountUSD: number; collateralAmountBase: string; collateralAmountBig: number; supplyRate: number; underlyingAsset: string; } interface BorrowedAsset { amount: number; amountUSD: number; borrowRate: number; debtAmountBase: string; debtAmountBig: number; underlyingAsset: string; } interface CreditMetadata { availableBorrowsBase: number; borrowPower: number; borrowValue: number; eModeCategory: number; healthFactor: number; liquidationThreshold: number; ltv: number; netAPY: number; stableBorrowAPY: number; stableBorrowedAssets: any[]; suppliedAssets: SuppliedAsset[]; suppliedValue: number; supplyAPY: number; totalCollateralBase: number; totalDebtBase: number; variableBorrowAPY: number; variableBorrowedAssets: BorrowedAsset[]; } interface CreditInformationResponse { data: { metadata: CreditMetadata; availableLimit: number; amountDelegated: number; SupportedChainIDs: number[]; } | null; } interface SwypeSDKConfig { apiKey: string; baseUrl?: string; apiPath?: string; eoaAddress: string; signature: string; deadline: number; } interface AuthSignature { signature: string; deadline: number; } interface CardStatusState { status: CardStatus | null; userCard: UserCard | null; isUserCardDelegated: boolean; isLoading: boolean; error: string | null; _setCardStatus: (status: CardStatus, userCard: UserCard | null) => void; _setUserStatus: (status: CardStatus) => void; _setLoading: (loading: boolean) => void; _setError: (error: string | null) => void; _reset: () => void; } declare const useCardStatusStore: zustand.UseBoundStore<zustand.StoreApi<CardStatusState>>; type CreditType$1 = "card" | "aave" | "euler"; interface CreditState { creditInfo: Record<CreditType$1, CreditInformationResponse | null>; isLoading: boolean; error: string | null; _setCreditInfo: (type: CreditType$1, info: CreditInformationResponse) => void; _setLoading: (loading: boolean) => void; _setError: (error: string | null) => void; _reset: () => void; } declare const useCreditStore: zustand.UseBoundStore<zustand.StoreApi<CreditState>>; interface SDKConfigState { eoaAddress: string | null; apiKey: string | null; baseUrl: string | null; apiPath: string | null; isInitialized: boolean; setConfig: (config: { eoaAddress: string; apiKey: string; baseUrl?: string; apiPath?: string; }) => void; reset: () => void; } declare const useSDKConfigStore: zustand.UseBoundStore<zustand.StoreApi<SDKConfigState>>; declare const getCardStatus: (eoaAddress: string) => Promise<CardStatusResponse>; declare const getUserCards: (eoaAddress: string) => Promise<UserCardsResponse>; declare const getCreditInformation: (creditAddress: string, creditType: "aave-v3" | "euler") => Promise<CreditInformationResponse>; declare const getSumSubAccessToken: (userId: string, ipAddress?: string) => Promise<SumSubTokenResponse["data"] | undefined>; declare const getCreditDelegationTxData: (requestData: CreditDelegationRequest) => Promise<{ data: CreditDelegationResponse; }>; declare const linkCardToCreditAccount: (requestData: LinkCardRequest) => Promise<any>; declare const freezeCard: (userEoa: string, cardID: string, freeze: boolean) => Promise<{ success: boolean; message?: string; }>; interface DelegateCardParams { creditType: "aave-v3" | "euler"; creditLimit: number; sendTransactionAsync: (params: { to: string; value: bigint; data: string; }) => Promise<string>; signTypedDataAsync: (params: { domain: { chainId: number; }; types: Record<string, Array<{ name: string; type: string; }>>; primaryType: string; message: Record<string, any>; }) => Promise<string>; } /** * Complete card delegation process * Handles delegation transaction, signing, and linking in one flow */ declare function delegateCard(params: DelegateCardParams): Promise<void>; declare function initializeSwypeSDK(config: SwypeSDKConfig): Promise<void>; declare const generateAuthSign: (eoaAddress: string, signTypedData: (typedData: any) => Promise<string>) => Promise<{ signature: string; deadline: number; }>; interface ModalProps { title: string; children: ReactNode; onClose: () => void; onOutsideClick?: () => void; overlayOpacity?: string; topDistance?: string; open?: boolean; } declare function Modal({ title, children, onClose, onOutsideClick, overlayOpacity, topDistance, open, }: ModalProps): react_jsx_runtime.JSX.Element; interface SumSubWidgetProps { eoaAddress?: string; onApplicantIdChange?: (id: string) => void; onVerificationComplete?: () => void; } declare function SumSubWidget({ eoaAddress, onApplicantIdChange, onVerificationComplete, }: SumSubWidgetProps): react_jsx_runtime.JSX.Element; interface SumsubMessage { type: string; payload?: { applicantId?: string; reviewStatus?: string; [key: string]: unknown; }; } interface UseSumSubOptions { eoaAddress?: string; onApplicantIdChange?: (id: string) => void; onVerificationComplete?: () => void; } declare const useSumSub: ({ eoaAddress, onApplicantIdChange, onVerificationComplete, }: UseSumSubOptions) => { accessToken: string | null; isLoading: boolean; error: string | null; applicantId: string | null; handleMessage: (message: SumsubMessage) => void; handleError: (sdkError: Error) => void; handleTokenExpiration: () => Promise<void>; retry: () => void; }; interface UseCardDataReturn { status: CardStatus | null; userCard: UserCard | null; isUserCardDelegated: boolean; isLoading: boolean; error: string | null; } declare const useCardData: () => UseCardDataReturn; type CreditType = "card" | "aave" | "euler"; interface UseCreditDataReturn { creditInfo: Record<CreditType, CreditInformationResponse | null>; isLoading: boolean; error: string | null; } declare const useCreditData: () => UseCreditDataReturn; declare class DataFetcher { private static instance; private hasFetched; static getInstance(): DataFetcher; fetchAllData(): Promise<void>; fetchDataAfterAuth(): Promise<void>; reset(): void; } declare const dataFetcher: DataFetcher; export { type AuthSignature, type BorrowedAsset, type CardStatus, type CardStatusResponse, type CreditDelegationRequest, type CreditDelegationResponse, type CreditInformationResponse, type CreditMetadata, type DelegateCardParams, KycModal, type LinkCardRequest, Modal, type SumSubTokenResponse, SumSubWidget, type SumsubMessage, type SuppliedAsset, type SwypeSDKConfig, type UserCard, type UserCardsResponse, dataFetcher, delegateCard, freezeCard, generateAuthSign, getCardStatus, getCreditDelegationTxData, getCreditInformation, getSumSubAccessToken, getUserCards, initializeSwypeSDK, linkCardToCreditAccount, useCardData, useCardStatusStore, useCreditData, useCreditStore, useKycStore, useSDKConfigStore, useSumSub };