UNPKG

@meshconnect/react-native-link-sdk

Version:
197 lines (196 loc) 6.55 kB
export type LinkEventType = IntegrationConnected | IntegrationConnectionError | TransferCompleted | IntegrationSelected | CredentialsEntered | TransferStarted | TransferPreviewed | TransferPreviewError | TransferExecutionError | TransferInitiated | TransferExecuted | TransferNoEligibleAssets | WalletMessageSigned | PageLoaded | VerifyDonePage | VerifyWalletRejected; declare const LINK_EVENT_TYPE_KEYS: readonly ["integrationConnected", "integrationConnectionError", "transferCompleted", "integrationSelected", "credentialsEntered", "transferStarted", "transferPreviewed", "transferPreviewError", "transferExecutionError", "transferExecuted", "transferInitiated", "transferNoEligibleAssets", "pageLoaded", "walletMessageSigned", "verifyDonePage", "verifyWalletRejected", "integrationMfaRequired", "integrationMfaEntered", "integrationOAuthStarted", "integrationAccountSelectionRequired", "transferAssetSelected", "transferNetworkSelected", "transferAmountEntered", "transferMfaRequired", "transferMfaEntered", "transferKycRequired", "connectionDeclined", "transferConfigureError", "connectionUnavailable", "transferDeclined"]; export declare const mappedLinkEvents: Record<string, string>; export type LinkEventTypeKeys = (typeof LINK_EVENT_TYPE_KEYS)[number]; export declare function isLinkEventTypeKey(key: string): key is LinkEventTypeKeys; interface LinkEventBase { type: LinkEventTypeKeys; } export interface PageLoaded { type: 'pageLoaded'; } export interface IntegrationConnected extends LinkEventBase { type: 'integrationConnected'; payload: LinkPayload; } export interface IntegrationConnectionError extends LinkEventBase { type: 'integrationConnectionError'; payload: { errorMessage: string; }; } export interface TransferCompleted extends LinkEventBase { type: 'transferCompleted'; payload: TransferFinishedPayload; } export interface IntegrationSelected extends LinkEventBase { type: 'integrationSelected'; payload: { integrationType: string; integrationName: string; }; } export interface CredentialsEntered extends LinkEventBase { type: 'credentialsEntered'; } export interface TransferStarted extends LinkEventBase { type: 'transferStarted'; } export interface TransferPreviewed extends LinkEventBase { type: 'transferPreviewed'; payload: { amount: number; symbol: string; toAddress: string; networkId: string; previewId: string; networkName?: string; amountInFiat?: number; estimatedNetworkGasFee?: { fee?: number; feeCurrency?: string; feeInFiat?: number; }; }; } export interface TransferPreviewError extends LinkEventBase { type: 'transferPreviewError'; payload: { errorMessage: string; }; } export interface TransferExecutionError extends LinkEventBase { type: 'transferExecutionError'; payload: { errorMessage: string; }; } export interface TransferInitiated extends LinkEventBase { type: 'transferInitiated'; payload: { integrationType?: string; integrationName: string; status: 'pending'; }; } export interface TransferExecuted extends LinkEventBase { type: 'transferExecuted'; payload: { status: 'success' | 'pending'; txId: string; fromAddress: string; toAddress: string; symbol: string; amount: number; networkId: string; }; } export interface TransferNoEligibleAssets extends LinkEventBase { type: 'transferNoEligibleAssets'; payload: { integrationType?: string; integrationName: string; noAssetsType?: string; arrayOfTokensHeld: { symbol: string; amount: number; amountInFiat?: number; ineligibilityReason?: string; }[]; }; } export interface AccountToken { account: Account; accessToken: string; refreshToken?: string; } export interface Account { accountId: string; accountName: string; fund?: number; cash?: number; isReconnected?: boolean; } export interface BrandInfo { brokerLogo: string; brokerPrimaryColor?: string; } export interface LinkPayload { accessToken?: AccessTokenPayload; delayedAuth?: DelayedAuthPayload; } export interface AccessTokenPayload { accountTokens: AccountToken[]; brokerBrandInfo: BrandInfo; expiresInSeconds?: number; refreshTokenExpiresInSeconds?: number; brokerType: string; brokerName: string; } export interface DelayedAuthPayload { refreshTokenExpiresInSeconds?: number; brokerType: string; refreshToken: string; brokerName: string; brokerBrandInfo: BrandInfo; } export interface TransferFinishedSuccessPayload { status: 'success'; txId: string; fromAddress: string; toAddress: string; symbol: string; amount: number; networkId: string; amountInFiat?: number; totalAmountInFiat?: number; networkName?: string; txHash?: string; transferId?: string; refundAddress?: string; } export interface TransferFinishedErrorPayload { status: 'error'; errorMessage: string; } export interface IntegrationAccessToken { accountId: string; accountName: string; accessToken: string; brokerType: string; brokerName: string; } export type Language = 'en' | 'ru'; export interface LinkSettings { accessTokens?: IntegrationAccessToken[]; transferDestinationTokens?: IntegrationAccessToken[]; language?: Language; } export interface LinkConfiguration { linkToken: string; settings?: LinkSettings; renderViewContainer?: boolean; disableDomainWhiteList?: boolean; onIntegrationConnected?: (payload: LinkPayload) => void; onTransferFinished?: (payload: TransferFinishedPayload) => void; onEvent?: (event: LinkEventType) => void; onExit?: (err?: string) => void; } export type TransferFinishedPayload = TransferFinishedSuccessPayload | TransferFinishedErrorPayload; export interface WalletMessageSigned extends LinkEventBase { type: 'walletMessageSigned'; payload: { signedMessageHash: string | undefined; message: string | undefined; address: string; timeStamp: number; isVerified: boolean; }; } export interface VerifyDonePage extends LinkEventBase { type: 'verifyDonePage'; } export interface VerifyWalletRejected extends LinkEventBase { type: 'verifyWalletRejected'; } export {};