UNPKG

@meshconnect/react-native-link-sdk

Version:
244 lines (243 loc) 8.1 kB
export type LinkEventType = IntegrationConnected | IntegrationConnectionError | TransferCompleted | IntegrationSelected | CredentialsEntered | TransferStarted | TransferPreviewed | TransferPreviewError | TransferExecutionError | TransferInitiated | TransferExecuted | TransferNoEligibleAssets | WalletMessageSigned | PageLoaded | VerifyDonePage | VerifyWalletRejected | LegalTermsViewed | SeeWhatHappenedClicked | FundingOptionsUpdated | FundingOptionsViewed | GasIncreaseWarning | ExecuteFundingStep | LinkTransferQrGenerated | HomePageMethodSelected; 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", "legalTermsViewed", "seeWhatHappenedClicked", "executeFundingStep", "fundingOptionsUpdated", "fundingOptionsViewed", "gasIncreaseWarning", "linkTransferQRGenerated", "methodSelected"]; 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; logoLightUrl?: string; logoDarkUrl?: string; iconLightUrl?: string; iconDarkUrl?: 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 LinkTheme = 'light' | 'dark' | 'system'; export interface LinkSettings { accessTokens?: IntegrationAccessToken[]; language?: string; displayFiatCurrency?: string; /** * Colour theme applied to the Link UI. * Use `'system'` to automatically follow the device's current colour scheme. */ theme?: LinkTheme; } 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 interface LegalTermsViewed { type: 'legalTermsViewed'; } export interface SeeWhatHappenedClicked { type: 'seeWhatHappenedClicked'; } export interface FundingOptionsUpdated { type: 'fundingOptionsUpdated'; } export interface FundingOptionsViewed { type: 'fundingOptionsViewed'; } export interface GasIncreaseWarning { type: 'gasIncreaseWarning'; } export interface ExecuteFundingStep { type: 'executeFundingStep'; payload: { cryptocurrencyFundingOptionType: string; status: string; errorMessage?: string; }; } export interface LinkTransferQrGenerated { type: 'linkTransferQRGenerated'; payload: { token?: string; network?: string; toAddress?: string; qrUrl?: string; }; } export interface HomePageMethodSelected { type: 'methodSelected'; payload: { method: 'embedded' | 'manual' | 'buy'; }; } export {};