@funkit/connect
Version:
Funkit Connect SDK elevates DeFi apps via web2 sign-ins and one-click checkouts.
324 lines (323 loc) • 12.5 kB
TypeScript
import type { WalletwithdrawquotequotationResponse as WithdrawalQuotation } from '@bluvo/sdk-ts';
import { BluvoExchangeStatus, type BluvoExchangeType } from '~/consts/bluvo';
import { type FunkitActiveCheckoutItem } from '~/providers/FunkitCheckoutContext';
import type { FunBrokerageItemProps } from '../components/FunSelectBrokerage/FunBrokerageItem';
type SupportedExchangeOption = FunBrokerageItemProps & {
exchange: BluvoExchangeType;
status: BluvoExchangeStatus;
};
type BluvoCheckoutQuoteParams = {
chainId: FunkitActiveCheckoutItem['selectedSourceAssetInfo']['chainId'];
symbol: FunkitActiveCheckoutItem['selectedSourceAssetInfo']['symbol'];
amount: string;
};
export type BluvoBrokerageQuote = WithdrawalQuotation & {
availableTokenAmount: number;
};
export declare const useBluvoExchangeBalance: ({ exchange, refetchOnMount, }: {
exchange: BluvoExchangeType | undefined;
refetchOnMount?: boolean;
}) => {
data: import("~/domains/wallet").AssetHoldingsMap<import("~/domains/wallet").BrokerageAssetHoldingsItem> | undefined;
totalBalance: number;
isLoading: boolean;
isError: boolean;
};
export declare const useBluvoCheckoutQuote: () => {
getBluvoCheckoutQuote: ({ amount, symbol, chainId, }: BluvoCheckoutQuoteParams) => Promise<BluvoBrokerageQuote | undefined>;
};
export declare const useBluvoSupportedExchanges: ({ fullInfo, iconSize, filterBy, }: {
fullInfo?: boolean;
iconSize?: number;
filterBy?: BluvoExchangeStatus[];
}) => {
exchangeOptions: ReadonlyArray<SupportedExchangeOption>;
};
export declare const useBluvo: () => {
exchangeType: BluvoExchangeType | undefined;
bluvoClient: {
listExchanges: (status?: "live" | "offline" | "maintenance" | "coming_soon") => Promise<any[] | null>;
startWithdrawalFlow: (flowOptions: import("@bluvo/sdk-ts").WithdrawalFlowOptions) => Promise<{
machine: import("@bluvo/sdk-ts").Machine<import("@bluvo/sdk-ts").FlowState, import("@bluvo/sdk-ts").FlowActionType>;
closeOAuthWindow: null;
} | {
machine: import("@bluvo/sdk-ts").Machine<import("@bluvo/sdk-ts").FlowState, import("@bluvo/sdk-ts").FlowActionType>;
closeOAuthWindow: () => void;
}>;
resumeWithdrawalFlow: (flowOptions: import("@bluvo/sdk-ts").ResumeWithdrawalFlowOptions) => Promise<{
machine: import("@bluvo/sdk-ts").Machine<import("@bluvo/sdk-ts").FlowState, import("@bluvo/sdk-ts").FlowActionType>;
closeOAuthWindow: null;
}>;
silentResumeWithdrawalFlow: (flowOptions: import("@bluvo/sdk-ts").SilentResumeWithdrawalFlowOptions) => Promise<{
machine: import("@bluvo/sdk-ts").Machine<import("@bluvo/sdk-ts").FlowState, import("@bluvo/sdk-ts").FlowActionType>;
} | null>;
requestQuote: (options: import("@bluvo/sdk-ts").QuoteRequestOptions) => Promise<{
success: boolean;
error: string;
type?: undefined;
rawQuote?: undefined;
quoteData?: undefined;
result?: undefined;
} | {
success: boolean;
error: string;
type: import("@bluvo/sdk-ts").TypeEnum2;
rawQuote?: undefined;
quoteData?: undefined;
result?: undefined;
} | {
rawQuote: {
id: string;
asset: string;
amountWithFee?: number | null;
amountNoFee?: number | null;
estimatedFee?: number | null;
amountWithFeeInFiat?: number | null;
amountNoFeeInFiat?: number | null;
estimatedFeeInFiat?: number | null;
destinationAddress: string;
network?: string | null;
tag?: string | null;
estimatedTotal?: number;
feeDetails?: Array<{
category: import("@bluvo/sdk-ts").CategoryEnum;
currency: string;
amount: number;
amountInFiat: number;
fiatCurrency: string;
}>;
expiresAt: string;
additionalInfo: {
minWithdrawal: string | null;
maxWithdrawal?: string | null;
};
};
quoteData: {
id: string;
asset: string;
amount: string;
estimatedFee: string;
estimatedTotal: string;
amountWithFeeInFiat: string;
amountNoFeeInFiat: string;
estimatedFeeInFiat: string;
additionalInfo: {
minWithdrawal: string | null;
maxWithdrawal?: string | null;
};
expiresAt: number;
};
success: boolean;
result: {
rawQuote: {
id: string;
asset: string;
amountWithFee?: number | null;
amountNoFee?: number | null;
estimatedFee?: number | null;
amountWithFeeInFiat?: number | null;
amountNoFeeInFiat?: number | null;
estimatedFeeInFiat?: number | null;
destinationAddress: string;
network?: string | null;
tag?: string | null;
estimatedTotal?: number;
feeDetails?: Array<{
category: import("@bluvo/sdk-ts").CategoryEnum;
currency: string;
amount: number;
amountInFiat: number;
fiatCurrency: string;
}>;
expiresAt: string;
additionalInfo: {
minWithdrawal: string | null;
maxWithdrawal?: string | null;
};
};
quoteData: {
id: string;
asset: string;
amount: string;
estimatedFee: string;
estimatedTotal: string;
amountWithFeeInFiat: string;
amountNoFeeInFiat: string;
estimatedFeeInFiat: string;
additionalInfo: {
minWithdrawal: string | null;
maxWithdrawal?: string | null;
};
expiresAt: number;
};
};
error?: undefined;
type?: undefined;
}>;
executeWithdrawal: (quoteId: string) => Promise<{
success: boolean;
error: string;
type?: undefined;
} | {
success: boolean;
error: any;
type: import("@bluvo/sdk-ts").TypeEnum2;
} | {
success: boolean;
result: {
success: boolean;
error?: string;
type?: import("@bluvo/sdk-ts").TypeEnum2;
result?: unknown;
} | null | undefined;
error?: string;
type?: import("@bluvo/sdk-ts").TypeEnum2;
}>;
submit2FA: (code: string) => Promise<{
success: boolean;
error: string;
type?: undefined;
} | {
success: boolean;
error: any;
type: import("@bluvo/sdk-ts").TypeEnum2;
} | {
success: boolean;
result: {
success: boolean;
error?: string;
type?: import("@bluvo/sdk-ts").TypeEnum2;
result?: unknown;
} | null | undefined;
error?: string;
type?: import("@bluvo/sdk-ts").TypeEnum2;
}>;
retryWithdrawal: () => Promise<{
success: boolean;
error: string;
type?: undefined;
} | {
success: boolean;
error: any;
type: import("@bluvo/sdk-ts").TypeEnum2;
} | {
success: boolean;
result: {
success: boolean;
error?: string;
type?: import("@bluvo/sdk-ts").TypeEnum2;
result?: unknown;
} | null | undefined;
error?: string;
type?: import("@bluvo/sdk-ts").TypeEnum2;
} | undefined>;
cancel: () => void;
testWithdrawalComplete: (transactionId?: string) => void;
isIdle: boolean;
isFlowCancelled: boolean;
isExchangesLoading: boolean;
isExchangesReady: boolean;
isExchangesError: boolean;
exchangesError: Error | null;
isOAuthPending: boolean;
isOAuthWaiting: boolean;
isOAuthProcessing: boolean;
isOAuthError: boolean;
isOAuthFatal: boolean;
isWalletConnectionInvalid: boolean;
isOAuthComplete: boolean;
isOAuthWindowBeenClosedByTheUser: boolean;
isWalletLoading: boolean;
isWalletError: boolean;
isWalletReady: boolean;
isQuoteLoading: boolean;
isQuoteReady: boolean;
isQuoteExpired: boolean;
isQuoteError: boolean;
isWithdrawing: boolean;
isWithdrawProcessing: boolean;
isWithdrawalComplete: boolean;
isWithdrawBlocked: boolean;
hasFatalError: boolean;
requires2FA: boolean;
requiresSMS: boolean;
requiresKYC: boolean;
requiresValid2FAMethod: boolean;
requiresEmailVerification: boolean;
hasInsufficientBalance: boolean;
canRetry: boolean;
hasAmountError: boolean;
hasAddressError: boolean;
hasNetworkError: boolean;
hasWalletNotFoundError: boolean;
hasInvalidCredentialsError: boolean;
invalid2FAAttempts: number;
retryAttempts: number;
maxRetryAttempts: number;
exchanges: {
id: string;
name: string;
logoUrl: string;
status: string;
}[];
walletBalances: {
asset: string;
balance: string;
balanceInFiat?: string;
networks?: Array<{
id: string;
name: string;
displayName: string;
minWithdrawal: string;
maxWithdrawal?: string;
assetName: string;
addressRegex?: string | null;
}>;
extra?: {
slug?: string;
assetId?: string;
};
}[];
quote: {
id: string;
asset: string;
amount: string;
estimatedFee: string;
estimatedTotal: string;
amountWithFeeInFiat: string;
amountNoFeeInFiat: string;
estimatedFeeInFiat: string;
additionalInfo: {
minWithdrawal: string | null;
maxWithdrawal?: string | null;
};
expiresAt: number;
} | undefined;
withdrawal: {
id: string;
status: string;
transactionId?: string;
} | undefined;
valid2FAMethods: string[] | undefined;
client: import("@bluvo/sdk-ts").BluvoFlowClient;
state: import("@bluvo/sdk-ts").FlowState | null;
send: (action: import("@bluvo/sdk-ts").FlowActionType) => void;
isInState: (stateType: import("@bluvo/sdk-ts").FlowState["type"]) => boolean;
hasError: boolean;
error: Error | null | undefined;
context: (Record<string, any> & import("@bluvo/sdk-ts").FlowContext) | undefined;
};
isConnected: boolean;
walletId: string | undefined;
authorizedConnections: Partial<Record<BluvoExchangeType, string>>;
handleStartWithdrawal: (brokerType: BluvoExchangeType) => Promise<{
machine: import("@bluvo/sdk-ts").Machine<import("@bluvo/sdk-ts").FlowState, import("@bluvo/sdk-ts").FlowActionType>;
closeOAuthWindow: null;
} | {
machine: import("@bluvo/sdk-ts").Machine<import("@bluvo/sdk-ts").FlowState, import("@bluvo/sdk-ts").FlowActionType>;
closeOAuthWindow: () => void;
} | undefined>;
quoteExpiresAt: number | undefined;
};
export declare const useUnlinkBluvo: () => () => void;
export {};