@funkit/connect
Version:
Funkit Connect SDK elevates DeFi apps via web2 sign-ins and one-click checkouts.
58 lines (57 loc) • 2.56 kB
TypeScript
import type { WalletwithdrawbalancebalanceResponse } from '@bluvo/sdk-ts';
type WithdrawableBalance = WalletwithdrawbalancebalanceResponse['balances'][number];
import { type BluvoExecuteWithdrawalResponse, BluvoWithdrawalError } from '@funkit/api-base';
import type { BluvoExchangeType } from '~/consts/bluvo';
import type { AssetHoldingsItem, AssetHoldingsMap, BrokerageAssetHoldingsItem } from '~/domains/wallet';
export declare const isBrokerageAsset: (asset: AssetHoldingsItem) => asset is BrokerageAssetHoldingsItem & {
usdAmount: number;
};
/**
* Computes the minimum and maximum USD values for a brokerage asset.
* Combines brokerage exchange limits with QR Code/token transfer limits.
* @param asset The brokerage asset with min/max amounts
* @param minTransferLimits Chain-specific minimum transfer limits
* @returns Object with minUsd and maxUsd values
*/
export declare function getBrokerageMinMax(asset: BrokerageAssetHoldingsItem & {
usdAmount: number;
}, minTransferLimits: {
mainnet: number;
nonMainnet: number;
}, minDeposit?: number): {
minUsd: number;
maxUsd: number;
};
/**
* Transforms Bluvo wallet balances into the AssetHoldingsMap format
* used by the SelectAsset component.
*/
export declare function transformBluvoBalancesToAssetHoldings(balances: WithdrawableBalance[], preferredChainId?: string): AssetHoldingsMap<BrokerageAssetHoldingsItem>;
export declare function getWalletId(authorizedConnections: Partial<Record<BluvoExchangeType, string>>, exchange: BluvoExchangeType): string;
declare class BluvoError<ErrorCode extends string> extends Error {
readonly message: string;
readonly errorCode: ErrorCode;
constructor(message: string, errorCode: ErrorCode);
}
type ExtractErrorCode<OriginalBluvoError extends {
error: string;
type: string;
}> = OriginalBluvoError extends {
error: string;
type: infer ErrorCode;
} ? ErrorCode : never;
export declare function getBluvoError<OriginalBluvoError extends {
error: string;
type: string;
}, ErrorCode extends string = ExtractErrorCode<OriginalBluvoError>>(error: OriginalBluvoError): BluvoError<ErrorCode>;
/**
*
* @param response - The response from the Bluvo API
* @returns The normalized response
*
* @throws - {@link BluvoWithdrawalError} if the response is invalid or if the withdrawal fails
*
*/
export declare const normalizeWithdrawalResponse: (response: BluvoExecuteWithdrawalResponse) => unknown;
export declare const isBluvoWithdrawalError: (error: unknown) => error is BluvoWithdrawalError;
export {};