@lydianpay/sdk-web 3.0.1 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/README.md +9 -8
  2. package/dist/chunks/index-BhtU_AAG.js +740 -0
  3. package/dist/chunks/{index-YAGlsS0s.js → index-CVTOXcSY.js} +13 -14
  4. package/dist/chunks/{metamask-sdk-CFm2IK48.js → metamask-sdk-BwVxHW1_.js} +1 -1
  5. package/dist/chunks/mountEngine-P1Ws89oo.js +34936 -0
  6. package/dist/lydian.js +1 -1
  7. package/dist/types/.tsbuildinfo +1 -1
  8. package/dist/types/constants.d.ts +6 -0
  9. package/dist/types/types.d.ts +1 -0
  10. package/dist/types/ui/Checkout.d.ts +11 -143
  11. package/dist/types/ui/checkoutCallbacks.d.ts +26 -0
  12. package/dist/types/ui/checkoutEngine.d.ts +28 -0
  13. package/dist/types/ui/checkoutPresentation.d.ts +24 -0
  14. package/dist/types/ui/checkoutSelection.d.ts +30 -0
  15. package/dist/types/ui/components/icons.d.ts +0 -1
  16. package/dist/types/ui/copyFields.d.ts +13 -0
  17. package/dist/types/ui/countdownClock.d.ts +5 -0
  18. package/dist/types/ui/dialogController.d.ts +35 -0
  19. package/dist/types/ui/failureReport.d.ts +13 -0
  20. package/dist/types/ui/flowConfig.d.ts +3 -2
  21. package/dist/types/ui/hostCallbacks.d.ts +10 -0
  22. package/dist/types/ui/kycFlow.d.ts +44 -0
  23. package/dist/types/ui/kycVerificationRequest.d.ts +17 -0
  24. package/dist/types/ui/networkListHelpers.d.ts +9 -1
  25. package/dist/types/ui/paymentFlow.d.ts +49 -0
  26. package/dist/types/ui/pollTick.d.ts +15 -0
  27. package/dist/types/ui/react/AssetSelectScreen.d.ts +1 -5
  28. package/dist/types/ui/react/CheckoutApp.d.ts +1 -4
  29. package/dist/types/ui/react/CloseTransactionDialogBody.d.ts +1 -6
  30. package/dist/types/ui/react/ConnectWithQrScreen.d.ts +1 -5
  31. package/dist/types/ui/react/ConnectingWalletScreen.d.ts +1 -5
  32. package/dist/types/ui/react/KycScreen.d.ts +1 -5
  33. package/dist/types/ui/react/LoadingScreen.d.ts +1 -8
  34. package/dist/types/ui/react/NetworkSelectScreen.d.ts +1 -5
  35. package/dist/types/ui/react/PaymentFailureScreen.d.ts +1 -5
  36. package/dist/types/ui/react/PaymentHeaderSection.d.ts +1 -12
  37. package/dist/types/ui/react/PaymentSuccessScreen.d.ts +1 -5
  38. package/dist/types/ui/react/RestoreDetailsDialogBody.d.ts +1 -4
  39. package/dist/types/ui/react/ScanToPayScreen.d.ts +1 -5
  40. package/dist/types/ui/react/TimerBanner/TimerBanner.d.ts +2 -0
  41. package/dist/types/ui/react/TimerBanner/timerBannerHelpers.d.ts +13 -0
  42. package/dist/types/ui/react/WalletSelectScreen.d.ts +1 -5
  43. package/dist/types/ui/react/checkoutActions.d.ts +107 -0
  44. package/dist/types/ui/react/checkoutContext.d.ts +9 -0
  45. package/dist/types/ui/react/checkoutReducer.d.ts +11 -0
  46. package/dist/types/ui/react/checkoutStore.d.ts +19 -11
  47. package/dist/types/ui/react/engine/CheckoutEngine.d.ts +30 -0
  48. package/dist/types/ui/react/engine/checkoutShell.d.ts +3 -0
  49. package/dist/types/ui/react/engine/mountEngine.d.ts +10 -0
  50. package/dist/types/ui/react/engine/useBranding.d.ts +1 -0
  51. package/dist/types/ui/react/engine/useCopyFields.d.ts +1 -0
  52. package/dist/types/ui/react/engine/useHostCallbacks.d.ts +2 -0
  53. package/dist/types/ui/react/engine/useProcessingOverlay.d.ts +1 -0
  54. package/dist/types/ui/react/engine/useScreenNavigator.d.ts +3 -0
  55. package/dist/types/ui/react/mount.d.ts +7 -5
  56. package/dist/types/ui/react/useQrCanvas.d.ts +9 -0
  57. package/dist/types/ui/screenNavigator.d.ts +13 -0
  58. package/dist/types/ui/sessionBootstrap.d.ts +36 -0
  59. package/dist/types/ui/sessionHelpers.d.ts +1 -2
  60. package/dist/types/ui/sessionLifecycle.d.ts +37 -0
  61. package/dist/types/ui/sessionQuoteWatcher.d.ts +7 -8
  62. package/dist/types/ui/settledOutcome.d.ts +14 -0
  63. package/dist/types/ui/transactionOutcome.d.ts +2 -0
  64. package/dist/types/ui/transactionPoller.d.ts +16 -0
  65. package/dist/types/ui/walletConnection.d.ts +48 -0
  66. package/package.json +2 -1
  67. package/dist/chunks/index-NI3RoQG3.js +0 -22485
  68. package/dist/chunks/mount-bhuHFGLm.js +0 -12914
  69. package/dist/types/ui/countdownBanner.d.ts +0 -33
  70. package/dist/types/ui/react/DownloadWalletScreen.d.ts +0 -4
  71. package/dist/types/ui/react/TimerBanner.d.ts +0 -4
  72. package/dist/types/ui/react/callbacksFixture.d.ts +0 -6
@@ -56,6 +56,12 @@ export type CheckoutNetwork = {
56
56
  export declare const CheckoutNetworks: Record<string, CheckoutNetwork>;
57
57
  export declare const NetworkAssetContracts: Record<string, Record<string, string>>;
58
58
  export declare const SupportedCheckoutNetworks: string[];
59
+ export type NetworkDisplayEntry = {
60
+ name: string;
61
+ logo: string;
62
+ };
63
+ export declare const NetworkDisplay: Record<string, NetworkDisplayEntry>;
64
+ export declare function getNetworkDisplay(code: string | null | undefined): NetworkDisplayEntry | undefined;
59
65
  export declare const CheckoutNativeAssets: Record<string, string>;
60
66
  /** The onchain contract for an asset on a network, or undefined for a native coin. */
61
67
  export declare function tokenContract(networkCode: string, assetCode: string): string | undefined;
@@ -9,6 +9,7 @@ export type Transaction = {
9
9
  };
10
10
  export type InitFlowOptions = {
11
11
  walletConnect?: boolean;
12
+ assetFirst?: boolean;
12
13
  };
13
14
  /**
14
15
  * Every `redirectURL` below is the merchant's own URL from the session, and is only
@@ -1,150 +1,18 @@
1
- import { CheckoutInitOptions, Transaction } from '../types';
1
+ import type { CheckoutInitOptions, Transaction } from '../types';
2
2
  export declare class Checkout extends HTMLElement {
3
3
  private shadow;
4
- private initOptions;
5
- private API;
6
- private get session();
7
- private set session(value);
8
- private sessionPromoted;
9
- private reactChunkReady;
10
- private uiUnavailable;
11
- private get cryptoTransaction();
12
- private set cryptoTransaction(value);
13
- private linkedTransaction;
14
- private consecutivePollFailures;
15
- private pollInFlight;
16
- private walletChainWarned;
17
- private getCryptoTransactionIntervalID;
18
- private readonly sessionQuoteWatcher;
19
- private paymentHeaderWasVisible;
20
- private connectQrElement;
21
- private pairingQrStyling;
22
- private lydianConnect;
23
- private walletConnection;
24
- private connectedAccount;
25
- private connectAbort;
26
- private get pendingPairingUri();
27
- private set pendingPairingUri(value);
28
- private connecting;
29
- private headerBackAction;
30
- private logoHeaderWasVisible;
31
- private readonly checkoutStore;
32
- private checkoutApp;
33
- private kycDraftSource;
34
- private canvasQRCode;
35
- private scanQrPanel;
36
- private qrCodeStyling;
37
- private pendingWalletSend;
38
- private countdownBanner;
39
- private get isCheckoutSettled();
40
- private set isCheckoutSettled(value);
41
- private get selectedAsset();
42
- private set selectedAsset(value);
43
- private get selectedNetwork();
44
- private set selectedNetwork(value);
45
- private get selectedWallet();
46
- private set selectedWallet(value);
47
- private modal;
48
- private modalCloseTransactionModal;
49
- private closeTransactionModalBody;
50
- private modalRestoreDetails;
51
- private get restoreContext();
52
- private set restoreContext(value);
53
- private brandFontLink;
4
+ private engine;
5
+ private engineLoadPromise;
6
+ private isTornDown;
54
7
  constructor();
8
+ connectedCallback(): void;
55
9
  initialize(options: CheckoutInitOptions): Promise<void>;
56
- private initializeWalletConnect;
10
+ private loadEngine;
57
11
  updateTransaction(transaction: Transaction): Promise<void>;
58
- private amountForDisplay;
59
- private loadOrCreateSession;
60
- private createSession;
61
- private loadSession;
62
- private fetchLinkedTransaction;
63
12
  disconnectedCallback(): void;
64
- private renewExpiredQuote;
65
- private ensureFreshSession;
66
- private markPromotedFrom;
67
- private loadInitialState;
68
- private setSelectedAsset;
69
- private setSelectedNetwork;
70
- private setSelectedWallet;
71
- private showPaymentSuccess;
72
- private hidePaymentHeader;
73
- private showUnderpaid;
74
- private reportFailure;
75
- private showErrorBanner;
76
- private clearErrorBanner;
77
- private showPaymentFailure;
78
- private confirmCloseTransaction;
79
- private setProcessingMessage;
80
- private showProcessing;
81
- private hideProcessing;
82
- private enterCryptoFlow;
83
- private emit;
84
- private handleWalletChainChanged;
85
- private expectedChains;
86
- private warnWrongChain;
87
- private showButtons;
88
- private hideButtons;
89
- private showQRCode;
90
- private refreshExpirationCountdown;
91
- private endCheckout;
92
- private returnToCoinSelection;
93
- private drawPendingQrCode;
94
- private hideQRCode;
95
- private render;
96
- private initializeComponents;
97
- private wireCopyFields;
98
- private copyAndFlash;
99
- private flashCopyFeedback;
100
- private scanToPayCallbacks;
101
- private resolveAppTargets;
102
- private clearSelection;
103
- private chooseNetwork;
104
- private chooseAsset;
105
- private attachListeners;
106
- private requireApi;
107
- private openRestoreDetails;
108
- private startListeningCryptoTransaction;
109
- private readTransactionOnce;
110
- private collectUnderpaidBalance;
111
- private clearInterval;
112
- private settleTerminalTransaction;
113
- private updatePaymentHeader;
114
- private setAssetButtons;
115
- private setWalletButtons;
116
- private chooseWallet;
117
- private flowSettings;
118
- private syncFlowSettings;
119
- private hasConnectableWallet;
120
- private connectSelectedWallet;
121
- private releaseTopLayer;
122
- private reclaimTopLayer;
123
- private failWalletConnect;
124
- private syncChangeMethodButton;
125
- private setHeaderBack;
126
- private hideWalletFlowScreens;
127
- private buildConnectedWalletSend;
128
- private showConnectingWallet;
129
- private showOpenWalletButton;
130
- private showWalletOpenFailed;
131
- private openSelectedWallet;
132
- private cancelConnect;
133
- private showConnectWithQr;
134
- private drawPendingPairingQr;
135
- private showDownloadWallet;
136
- private showWalletSelectFromDownload;
137
- private setNetworkButtons;
138
- private applyBranding;
139
- private beginPayment;
140
- private beginTransaction;
141
- private handleCreatedTransactionAndStartListening;
142
- private walletSendForSigning;
143
- private signAndSubmit;
144
- private showKycScreen;
145
- private showScreen;
146
- private stashKycDraft;
147
- private submitKycVerification;
148
- private showDocumentOnlyKycScreen;
149
- private restoreWithCustomerUUID;
13
+ private getOrLoadEngine;
14
+ private handleEngineLoadFailure;
15
+ private get isDismissedByHost();
16
+ private reportEngineFailure;
17
+ private releaseEngine;
150
18
  }
@@ -0,0 +1,26 @@
1
+ import type { API } from '../network';
2
+ import type { CheckoutCallbacks, CheckoutStore } from './react/checkoutStore';
3
+ import type { CheckoutSelection } from './checkoutSelection';
4
+ import type { DialogController } from './dialogController';
5
+ import type { KycFlow } from './kycFlow';
6
+ import type { ScreenNavigator } from './screenNavigator';
7
+ import type { WalletConnection } from './walletConnection';
8
+ /** The few exits that belong to the checkout as a whole rather than to one flow. */
9
+ export interface CheckoutCallbackSeams {
10
+ confirmCloseTransaction(): void;
11
+ endCheckout(): void;
12
+ resetCheckout(): void;
13
+ openRestoreDetails(): void;
14
+ notifyCountdownLapsed(): void;
15
+ requireApi(): API;
16
+ }
17
+ export declare function createCheckoutCallbacks({ store, shadowRoot, screenNavigator, selection, kycFlow, wallet, dialogs, seams, }: {
18
+ store: CheckoutStore;
19
+ shadowRoot: ShadowRoot;
20
+ screenNavigator: ScreenNavigator;
21
+ selection: CheckoutSelection;
22
+ kycFlow: KycFlow;
23
+ wallet: WalletConnection;
24
+ dialogs: DialogController;
25
+ seams: CheckoutCallbackSeams;
26
+ }): CheckoutCallbacks;
@@ -0,0 +1,28 @@
1
+ import { type CheckoutCallbacks, type CheckoutStore } from './react/checkoutStore';
2
+ import { type DialogController } from './dialogController';
3
+ import type { API } from '../network';
4
+ import type { HostCallbacks } from './hostCallbacks';
5
+ import type { ScreenNavigator } from './screenNavigator';
6
+ import type { SessionBootstrapResult } from './sessionBootstrap';
7
+ import type { CheckoutInitOptions, Transaction } from '../types';
8
+ export type CheckoutHost = Pick<HTMLElement, 'classList' | 'isConnected' | 'style'>;
9
+ export type CheckoutStartup = {
10
+ api: API;
11
+ sessionLoad: Promise<SessionBootstrapResult>;
12
+ };
13
+ export interface CheckoutEngine {
14
+ initialize(options: CheckoutInitOptions, startup: CheckoutStartup): Promise<void>;
15
+ updateTransaction(transaction: Transaction): Promise<void>;
16
+ teardown(): void;
17
+ readonly callbacks: CheckoutCallbacks;
18
+ readonly dialogs: DialogController;
19
+ }
20
+ export declare function createCheckoutEngine({ shadowRoot, hostCallbacks, store, screenNavigator, }: {
21
+ shadowRoot: ShadowRoot;
22
+ /** Everything the merchant hears. Built by useHostCallbacks and handed in. */
23
+ hostCallbacks: HostCallbacks;
24
+ /** Built by the tree, so the navigator can be built over it before this exists. */
25
+ store: CheckoutStore;
26
+ /** Where the customer is, and what back means. Built by useScreenNavigator. */
27
+ screenNavigator: ScreenNavigator;
28
+ }): CheckoutEngine;
@@ -0,0 +1,24 @@
1
+ import { type CheckoutStore } from './react/checkoutStore';
2
+ import type { ScreenNavigator } from './screenNavigator';
3
+ import type { SessionLifecycle } from './sessionLifecycle';
4
+ import type { GetTransactionResponse } from '../types';
5
+ export interface CheckoutPresentation {
6
+ showProcessing(): void;
7
+ hideProcessing(): void;
8
+ showErrorBanner(message: string, options?: {
9
+ wrongChain?: boolean;
10
+ }): void;
11
+ clearErrorBanner(): void;
12
+ updatePaymentHeader(): void;
13
+ hidePaymentHeader(): void;
14
+ /** Clears the scan card's underpaid state. */
15
+ hideQRCode(): void;
16
+ showSuccess(transaction: GetTransactionResponse | undefined, overpaidUSD: number): void;
17
+ showUnderpaid(transaction: GetTransactionResponse): void;
18
+ showFailure(message: string): void;
19
+ }
20
+ export declare function createCheckoutPresentation({ store, screenNavigator, sessionLifecycle, }: {
21
+ store: CheckoutStore;
22
+ screenNavigator: ScreenNavigator;
23
+ sessionLifecycle: SessionLifecycle;
24
+ }): CheckoutPresentation;
@@ -0,0 +1,30 @@
1
+ import { type CheckoutStore } from './react/checkoutStore';
2
+ import type { CheckoutPresentation } from './checkoutPresentation';
3
+ import type { DialogController } from './dialogController';
4
+ import type { PaymentFlow } from './paymentFlow';
5
+ import type { ScreenNavigator } from './screenNavigator';
6
+ import type { TransactionPoller } from './transactionPoller';
7
+ import type { WalletConnection } from './walletConnection';
8
+ import type { CheckoutEventName, CheckoutInitOptions, WalletConnectWallet } from '../types';
9
+ export interface CheckoutSelection {
10
+ setAsset(code: string | null): void;
11
+ setNetwork(network: string | null): void;
12
+ setWallet(wallet: WalletConnectWallet): void;
13
+ clear(): void;
14
+ chooseNetwork(networkCode: string): void;
15
+ chooseAsset(assetCode: string): Promise<void>;
16
+ /** Opens the checkout and starts the flow at its first step. */
17
+ enterCryptoFlow(): void;
18
+ returnToCoinSelection(): void;
19
+ }
20
+ export declare function createCheckoutSelection({ store, screenNavigator, paymentFlow, wallet, poller, getDialogs, getOptions, emit, }: {
21
+ store: CheckoutStore;
22
+ screenNavigator: ScreenNavigator;
23
+ paymentFlow: PaymentFlow;
24
+ wallet: WalletConnection;
25
+ poller: TransactionPoller;
26
+ getDialogs: () => DialogController | null;
27
+ getOptions: () => CheckoutInitOptions | null;
28
+ emit: (name: CheckoutEventName, data?: Record<string, unknown>) => void;
29
+ presentation?: CheckoutPresentation;
30
+ }): CheckoutSelection;
@@ -15,5 +15,4 @@ export declare const checkSmallIconSvg = "<svg width=\"22\" height=\"22\" viewBo
15
15
  export declare const checkMarkIconSvg = "<svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M5 12.5 10 17.5 19 7\" stroke=\"currentColor\" stroke-width=\"4\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>";
16
16
  export declare const xCircleIconSvg = "<svg width=\"22\" height=\"22\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <circle cx=\"12\" cy=\"12\" r=\"11\" stroke=\"currentColor\" stroke-width=\"1.6\"/>\n <path d=\"M9 9l6 6M15 9l-6 6\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\"/>\n</svg>";
17
17
  export declare const alertCircleOutlineIconSvg = "<svg width=\"40\" height=\"40\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <circle cx=\"12\" cy=\"12\" r=\"10\" stroke=\"currentColor\" stroke-width=\"1.6\"/>\n <path d=\"M12 7v6\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\"/>\n <circle cx=\"12\" cy=\"16.5\" r=\"1.1\" fill=\"currentColor\"/>\n</svg>";
18
- export declare const walletIconSvg = "<svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M18 7V5.5A1.5 1.5 0 0 0 16.5 4H5a2 2 0 0 0 0 4h13a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n <circle cx=\"16.5\" cy=\"13.5\" r=\"1.25\" fill=\"currentColor\"/>\n</svg>";
19
18
  export declare const otherWalletsIconSvg = "<svg width=\"32\" height=\"32\" viewBox=\"0 0 32 32\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <circle cx=\"8\" cy=\"16\" r=\"2.5\" fill=\"currentColor\"/>\n <circle cx=\"16\" cy=\"16\" r=\"2.5\" fill=\"currentColor\"/>\n <circle cx=\"24\" cy=\"16\" r=\"2.5\" fill=\"currentColor\"/>\n</svg>";
@@ -0,0 +1,13 @@
1
+ export interface CopyFeedbackElement {
2
+ innerText: string;
3
+ classList: {
4
+ add(token: string): void;
5
+ remove(token: string): void;
6
+ };
7
+ }
8
+ export declare function flashCopyFeedback(bubble: CopyFeedbackElement | null, text: string): void;
9
+ export declare function copyAndFlash({ value, bubble, copiedText, }: {
10
+ value: string;
11
+ bubble: CopyFeedbackElement | null;
12
+ copiedText?: string;
13
+ }): Promise<void>;
@@ -0,0 +1,5 @@
1
+ import { type ActiveScreen } from './react/checkoutStore';
2
+ /** Time left until `expiry` clamped at zero; null means nothing to count. */
3
+ export declare function getRemainingTimeMs(expiry: number | null, now?: number): number | null;
4
+ export declare function formatCountdownClock(msRemaining: number): string;
5
+ export declare function isCountdownScreen(activeScreen: ActiveScreen | null): boolean;
@@ -0,0 +1,35 @@
1
+ export type DialogName = 'checkout' | 'closeTransaction' | 'restoreDetails';
2
+ export interface DialogElement {
3
+ readonly open: boolean;
4
+ show(): void;
5
+ showModal(): void;
6
+ close(): void;
7
+ classList: {
8
+ add(token: string): void;
9
+ remove(token: string): void;
10
+ };
11
+ setAttribute(name: string, value: string): void;
12
+ addEventListener(type: string, listener: (event: {
13
+ target: unknown;
14
+ }) => void): void;
15
+ querySelector(selectors: string): {
16
+ childElementCount: number;
17
+ } | null;
18
+ }
19
+ export type DialogElements = Partial<Record<DialogName, DialogElement | null>>;
20
+ export interface DialogController {
21
+ open(name: DialogName): void;
22
+ close(name: DialogName): void;
23
+ /** Whether React has rendered anything into this dialog's body yet. */
24
+ hasBody(name: DialogName): boolean;
25
+ /** Drop the checkout out of the top layer so a wallet's own overlay can win. */
26
+ releaseTopLayer(): void;
27
+ /** Take it back — deferred while any other dialog is still up. */
28
+ reclaimTopLayer(): void;
29
+ /** Back to a fresh init: everything closed, nothing pending. */
30
+ reset(): void;
31
+ setNarrow(narrow: boolean): void;
32
+ setLabel(name: DialogName, label: string): void;
33
+ onBackdropClick(name: DialogName, listener: () => void): void;
34
+ }
35
+ export declare function createDialogController(elements: DialogElements): DialogController;
@@ -0,0 +1,13 @@
1
+ import type { GetSessionResponse, PaymentFailure, PaymentFailureReason } from '../types';
2
+ export interface FailureReport {
3
+ event: Record<string, unknown>;
4
+ failure: PaymentFailure;
5
+ }
6
+ export declare function failureReport({ message, reason, shouldEndCheckout, transactionID, session, }: {
7
+ message: string;
8
+ reason: PaymentFailureReason;
9
+ shouldEndCheckout: boolean;
10
+ /** The transaction the failure is about, when there is one. */
11
+ transactionID?: string;
12
+ session: GetSessionResponse | null;
13
+ }): FailureReport;
@@ -1,7 +1,8 @@
1
1
  import { CheckoutFlow, InitFlowOptions } from '../types';
2
2
  export type CheckoutFlowSettings = {
3
3
  walletConnect: boolean;
4
- skipConfirmationPage: boolean;
5
- hideNoWalletOption: boolean;
4
+ assetFirst: boolean;
5
+ showApprovalPage: boolean;
6
+ hideOtherWallets: boolean;
6
7
  };
7
8
  export declare function resolveFlow(accountFlow?: CheckoutFlow, embedFlow?: InitFlowOptions): CheckoutFlowSettings;
@@ -0,0 +1,10 @@
1
+ import type { CheckoutEventName, CheckoutInitOptions, PaymentCancellation, PaymentFailure, PaymentResult } from '../types';
2
+ export interface HostCallbacks {
3
+ /** The options arrive at init(), not at construction, and can be replaced. */
4
+ setOptions(options: CheckoutInitOptions | null): void;
5
+ emit(name: CheckoutEventName, data?: Record<string, unknown>): void;
6
+ paymentFailed(message: string, failure: PaymentFailure): void;
7
+ paymentSucceeded(result: PaymentResult): void;
8
+ paymentCanceled(cancellation: PaymentCancellation): void;
9
+ }
10
+ export declare function createHostCallbacks(): HostCallbacks;
@@ -0,0 +1,44 @@
1
+ import { type CheckoutStore } from './react/checkoutStore';
2
+ import type { API } from '../network';
3
+ import type { CheckoutPresentation } from './checkoutPresentation';
4
+ import type { KycFieldValues } from './kycValidation';
5
+ import type { PaymentFlow } from './paymentFlow';
6
+ import type { ScreenNavigator } from './screenNavigator';
7
+ import type { SessionLifecycle } from './sessionLifecycle';
8
+ import type { SessionQuoteWatcher } from './sessionQuoteWatcher';
9
+ import type { TransactionPoller } from './transactionPoller';
10
+ import type { CheckoutEventName, CheckoutInitOptions, PaymentFailureReason } from '../types';
11
+ export interface KycFlow {
12
+ /** The -3 screen. No-op without a transaction to attach the details to. */
13
+ showScreen(): void;
14
+ submit(submission: {
15
+ values: KycFieldValues;
16
+ documentFront: File | null;
17
+ documentBack: File | null;
18
+ storeKyc: boolean;
19
+ }): Promise<void>;
20
+ /** A recognised customer needs only documents; the form never renders. */
21
+ showDocumentOnlyScreen(customerUUID: string, country: string): void;
22
+ /** Re-promote the same session against a stored customer record. */
23
+ restoreWithCustomerUUID(customerUUID: string): Promise<void>;
24
+ }
25
+ export interface KycFlowSeams {
26
+ reportFailure(message: string, reason: PaymentFailureReason, options?: {
27
+ shouldEndCheckout?: boolean;
28
+ transactionID?: string;
29
+ }): void;
30
+ closeRestoreDialog(): void;
31
+ }
32
+ export declare function createKycFlow({ store, presentation, screenNavigator, sessionLifecycle, paymentFlow, poller, quoteWatcher, getApi, getOptions, emit, seams, }: {
33
+ store: CheckoutStore;
34
+ presentation: CheckoutPresentation;
35
+ screenNavigator: ScreenNavigator;
36
+ sessionLifecycle: SessionLifecycle;
37
+ paymentFlow: PaymentFlow;
38
+ poller: TransactionPoller;
39
+ quoteWatcher: SessionQuoteWatcher;
40
+ getApi: () => API | null;
41
+ getOptions: () => CheckoutInitOptions | null;
42
+ emit: (name: CheckoutEventName, data?: Record<string, unknown>) => void;
43
+ seams: KycFlowSeams;
44
+ }): KycFlow;
@@ -0,0 +1,17 @@
1
+ import type { KycFieldValues } from './kycValidation';
2
+ import type { KYCVerificationRequest } from '../types';
3
+ export declare function kycVerificationRequest({ values, asset, network, storeKyc, documentFront, documentBack, supportsDocuments, restoring, }: {
4
+ values: KycFieldValues;
5
+ asset: string;
6
+ network: string;
7
+ storeKyc: boolean;
8
+ documentFront: File | null;
9
+ documentBack: File | null;
10
+ /** False when the transaction names no document types; nothing is attached. */
11
+ supportsDocuments: boolean;
12
+ /** Non-null only while finishing a recognised customer's KYC — see restoreContextFor. */
13
+ restoring: {
14
+ customerUUID: string;
15
+ country: string;
16
+ } | null;
17
+ }): KYCVerificationRequest;
@@ -6,13 +6,21 @@ export declare function hoistRecommendedNetwork({ networks, recommendedNetwork,
6
6
  recommendedNetwork: string | null | undefined;
7
7
  }): string[];
8
8
  export declare function filterAssetsByNetwork(allowedAssets: Asset[], networkCode: string): Asset[];
9
+ export declare function filterNetworksByAsset(allowedAssets: Asset[], assetCode: string): string[];
9
10
  type NetworkFeeSource = Pick<GetSessionResponse, 'customFlatFeePerNetwork' | 'customFeePercentagePerNetwork'>;
10
11
  type CryptoTotalSource = Pick<GetSessionResponse, 'calculatedCryptoTotals' | 'calculatedCryptoTotalsPerNetwork'>;
11
12
  export declare function getNetworkFeeLabel(session: NetworkFeeSource | undefined, networkName: string): string | null;
12
- export declare function getAssetCryptoTotal(session: CryptoTotalSource | undefined, networkName: string, assetCode: string): number | null;
13
+ export declare function getAssetCryptoTotal(session: CryptoTotalSource | undefined, networkName: string | null, assetCode: string): number | null;
13
14
  export declare function filterAllowedWallets<T extends {
14
15
  id: string;
15
16
  }>(wallets: T[], allowedWalletsConfig: AllowedWalletConfig[] | null | undefined): T[];
17
+ export declare function filterNetworksByWalletSupport({ networkCodes, walletId, }: {
18
+ networkCodes: string[];
19
+ walletId: string | null;
20
+ }): {
21
+ networkCodes: string[];
22
+ isWalletSupportKnown: boolean;
23
+ };
16
24
  export declare function matchesExpectedChain(reported: string, expected: readonly string[]): boolean;
17
25
  export declare function shouldWarnWrongChain({ connected, reported, expected, }: {
18
26
  connected: boolean;
@@ -0,0 +1,49 @@
1
+ import { type CheckoutStore } from './react/checkoutStore';
2
+ import type { API } from '../network';
3
+ import type { CheckoutPresentation } from './checkoutPresentation';
4
+ import type { HostCallbacks } from './hostCallbacks';
5
+ import type { ScreenNavigator } from './screenNavigator';
6
+ import type { SessionLifecycle } from './sessionLifecycle';
7
+ import type { SessionQuoteWatcher } from './sessionQuoteWatcher';
8
+ import type { TransactionPoller } from './transactionPoller';
9
+ import type { BuiltSend } from '../chains/adapters';
10
+ import type { CheckoutEventName, CheckoutInitOptions, GetTransactionResponse, PaymentFailureReason } from '../types';
11
+ export interface PaymentFlow {
12
+ begin(): Promise<void>;
13
+ beginTransaction(): Promise<void>;
14
+ /**
15
+ * Shows the success or failure screen and notifies the host if the
16
+ * transaction has settled; false leaves a still-active one untouched.
17
+ * Reached from the poll, a resumed session, and the promote-failure recovery.
18
+ */
19
+ endCheckoutIfSettled(transaction: GetTransactionResponse, overpaidUSD?: number): boolean;
20
+ continueAfterCreate(): Promise<void>;
21
+ startPolling(): void;
22
+ pollOnce(): Promise<void>;
23
+ showQRCode(): void;
24
+ }
25
+ export interface PaymentFlowSeams {
26
+ reportFailure(message: string, reason: PaymentFailureReason, options?: {
27
+ shouldEndCheckout?: boolean;
28
+ transactionID?: string;
29
+ }): void;
30
+ showKycScreen(): void;
31
+ buildConnectedWalletSend(): BuiltSend | null;
32
+ signAndSubmit(built: BuiltSend): Promise<void>;
33
+ setPendingWalletSend(built: BuiltSend | null): void;
34
+ hasPendingWalletSend(): boolean;
35
+ resetCheckout(): void;
36
+ }
37
+ export declare function createPaymentFlow({ store, presentation, screenNavigator, sessionLifecycle, hostCallbacks, poller, quoteWatcher, getApi, getOptions, emit, seams, }: {
38
+ store: CheckoutStore;
39
+ presentation: CheckoutPresentation;
40
+ screenNavigator: ScreenNavigator;
41
+ sessionLifecycle: SessionLifecycle;
42
+ hostCallbacks: HostCallbacks;
43
+ poller: TransactionPoller;
44
+ quoteWatcher: SessionQuoteWatcher;
45
+ getApi: () => API | null;
46
+ getOptions: () => CheckoutInitOptions | null;
47
+ emit: (name: CheckoutEventName, data?: Record<string, unknown>) => void;
48
+ seams: PaymentFlowSeams;
49
+ }): PaymentFlow;
@@ -0,0 +1,15 @@
1
+ import type { GetTransactionResponse } from '../types';
2
+ export type PollTick = {
3
+ kind: 'settled';
4
+ overpaidUSD: number;
5
+ } | {
6
+ kind: 'underpaid';
7
+ } | {
8
+ kind: 'expired';
9
+ } | {
10
+ kind: 'pending';
11
+ };
12
+ export declare function classifyPollTick({ transaction, now, }: {
13
+ transaction: GetTransactionResponse;
14
+ now?: number;
15
+ }): PollTick;
@@ -1,6 +1,2 @@
1
1
  import * as React from 'react';
2
- import type { CheckoutCallbacks, CheckoutState } from './checkoutStore';
3
- export default function AssetSelectScreen({ state, callbacks, }: {
4
- state: CheckoutState;
5
- callbacks: CheckoutCallbacks;
6
- }): React.JSX.Element;
2
+ export default function AssetSelectScreen(): React.JSX.Element;
@@ -1,9 +1,6 @@
1
1
  import * as React from 'react';
2
- import type { CheckoutCallbacks, CheckoutStore } from './checkoutStore';
3
2
  import type { CheckoutAppTargets } from './checkoutTargets';
4
3
  export type { CheckoutAppTargets };
5
- export default function CheckoutApp({ store, callbacks, targets, }: {
6
- store: CheckoutStore;
7
- callbacks: CheckoutCallbacks;
4
+ export default function CheckoutApp({ targets }: {
8
5
  targets: CheckoutAppTargets;
9
6
  }): React.JSX.Element;
@@ -1,7 +1,2 @@
1
1
  import * as React from 'react';
2
- import type { CloseDialogVariant } from './checkoutStore';
3
- export default function CloseTransactionDialogBody({ variant, onAccept, onReject, }: {
4
- variant: CloseDialogVariant;
5
- onAccept: () => void;
6
- onReject: () => void;
7
- }): React.JSX.Element;
2
+ export default function CloseTransactionDialogBody(): React.JSX.Element;
@@ -1,6 +1,2 @@
1
1
  import * as React from 'react';
2
- import type { CheckoutCallbacks, CheckoutState } from './checkoutStore';
3
- export default function ConnectWithQrScreen({ state, callbacks, }: {
4
- state: CheckoutState;
5
- callbacks: CheckoutCallbacks;
6
- }): React.JSX.Element;
2
+ export default function ConnectWithQrScreen(): React.JSX.Element;
@@ -1,6 +1,2 @@
1
1
  import * as React from 'react';
2
- import type { CheckoutCallbacks, CheckoutState } from './checkoutStore';
3
- export default function ConnectingWalletScreen({ state, callbacks, }: {
4
- state: CheckoutState;
5
- callbacks: CheckoutCallbacks;
6
- }): React.JSX.Element | null;
2
+ export default function ConnectingWalletScreen(): React.JSX.Element | null;
@@ -1,6 +1,2 @@
1
1
  import * as React from 'react';
2
- import type { CheckoutCallbacks, CheckoutState } from './checkoutStore';
3
- export default function KycScreen({ state, callbacks, }: {
4
- state: CheckoutState;
5
- callbacks: CheckoutCallbacks;
6
- }): React.JSX.Element;
2
+ export default function KycScreen(): React.JSX.Element;
@@ -1,9 +1,2 @@
1
1
  import * as React from 'react';
2
- export default function LoadingScreen({ message, subMessage, cancellable, logoUrl, logoAlt, onCancel, }: {
3
- message: string | null;
4
- subMessage: string | null;
5
- cancellable: boolean;
6
- logoUrl: string | null;
7
- logoAlt: string;
8
- onCancel: () => void;
9
- }): React.JSX.Element;
2
+ export default function LoadingScreen(): React.JSX.Element;
@@ -1,6 +1,2 @@
1
1
  import * as React from 'react';
2
- import type { CheckoutCallbacks, CheckoutState } from './checkoutStore';
3
- export default function NetworkSelectScreen({ state, callbacks, }: {
4
- state: CheckoutState;
5
- callbacks: CheckoutCallbacks;
6
- }): React.JSX.Element;
2
+ export default function NetworkSelectScreen(): React.JSX.Element;
@@ -1,6 +1,2 @@
1
1
  import * as React from 'react';
2
- export default function PaymentFailureScreen({ message, paymentId, onClose, }: {
3
- message: string;
4
- paymentId: string;
5
- onClose: () => void;
6
- }): React.JSX.Element;
2
+ export default function PaymentFailureScreen(): React.JSX.Element;