@daimo/pay 1.8.3 → 1.8.5
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.
- package/build/index.d.ts +179 -67
- package/build/index.js +9345 -8875
- package/build/index.js.map +1 -1
- package/package.json +4 -4
package/build/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React$1, { ReactNode, ReactElement } from 'react';
|
|
2
2
|
export { version } from '../package.json';
|
|
3
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
3
|
import { CreateConfigParameters } from '@wagmi/core';
|
|
5
4
|
import { CreateConnectorFn } from 'wagmi';
|
|
6
5
|
import { CoinbaseWalletParameters } from 'wagmi/connectors';
|
|
7
|
-
import
|
|
6
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
7
|
+
import { DaimoPayOrderView, PaymentStartedEvent, PaymentCompletedEvent, PaymentBouncedEvent, ExternalPaymentOptionsString, DaimoPayUserMetadata, DaimoPayOrderWithOrg, DaimoPayHydratedOrderWithOrg, DaimoPayOrder, DaimoPayOrderID, SolanaPublicKey, DaimoPayIntentStatus, DaimoPayOrderMode, DepositAddressPaymentOptionMetadata, PlatformType, ExternalPaymentOptionMetadata, WalletPaymentOption, ExternalPaymentOptions, DepositAddressPaymentOptions, DepositAddressPaymentOptionData } from '@daimo/pay-common';
|
|
8
8
|
import { Address, Hex } from 'viem';
|
|
9
9
|
import { WalletName } from '@solana/wallet-adapter-base';
|
|
10
10
|
import { AppRouter } from '@daimo/pay-api';
|
|
@@ -69,6 +69,7 @@ type DaimoPayContextOptions = {
|
|
|
69
69
|
type DaimoPayModalOptions = {
|
|
70
70
|
closeOnSuccess?: boolean;
|
|
71
71
|
resetOnSuccess?: boolean;
|
|
72
|
+
connectedWalletOnly?: boolean;
|
|
72
73
|
};
|
|
73
74
|
|
|
74
75
|
type types_All = All;
|
|
@@ -83,6 +84,22 @@ declare namespace types {
|
|
|
83
84
|
export type { types_All as All, types_CustomAvatarProps as CustomAvatarProps, types_CustomTheme as CustomTheme, types_DaimoPayContextOptions as DaimoPayContextOptions, types_DaimoPayModalOptions as DaimoPayModalOptions, types_Languages as Languages, types_Mode as Mode, types_Theme as Theme };
|
|
84
85
|
}
|
|
85
86
|
|
|
87
|
+
type DefaultConfigProps = {
|
|
88
|
+
appName: string;
|
|
89
|
+
appIcon?: string;
|
|
90
|
+
appDescription?: string;
|
|
91
|
+
appUrl?: string;
|
|
92
|
+
/**
|
|
93
|
+
* WC 2.0 Project ID (get one here: https://cloud.walletconnect.com/sign-in),
|
|
94
|
+
* it doesn't do much besides tracking. If not provided, use Daimo's
|
|
95
|
+
* WalletConnect project ID by default. */
|
|
96
|
+
walletConnectProjectId?: string;
|
|
97
|
+
coinbaseWalletPreference?: CoinbaseWalletParameters<"4">["preference"];
|
|
98
|
+
additionalConnectors?: CreateConnectorFn[];
|
|
99
|
+
} & Partial<CreateConfigParameters>;
|
|
100
|
+
/** Daimo Pay recommended config, for use with wagmi's createConfig(). */
|
|
101
|
+
declare const defaultConfig: ({ appName, appIcon, appDescription, appUrl, walletConnectProjectId, coinbaseWalletPreference, additionalConnectors, chains, client, ...props }: DefaultConfigProps) => CreateConfigParameters;
|
|
102
|
+
|
|
86
103
|
type useConnectCallbackProps = {
|
|
87
104
|
onConnect?: ({ address, connectorId, }: {
|
|
88
105
|
address?: string;
|
|
@@ -112,22 +129,6 @@ type DaimoPayProviderProps = {
|
|
|
112
129
|
*/
|
|
113
130
|
declare const DaimoPayProvider: (props: DaimoPayProviderProps) => react_jsx_runtime.JSX.Element;
|
|
114
131
|
|
|
115
|
-
type DefaultConfigProps = {
|
|
116
|
-
appName: string;
|
|
117
|
-
appIcon?: string;
|
|
118
|
-
appDescription?: string;
|
|
119
|
-
appUrl?: string;
|
|
120
|
-
/**
|
|
121
|
-
* WC 2.0 Project ID (get one here: https://cloud.walletconnect.com/sign-in),
|
|
122
|
-
* it doesn't do much besides tracking. If not provided, use Daimo's
|
|
123
|
-
* WalletConnect project ID by default. */
|
|
124
|
-
walletConnectProjectId?: string;
|
|
125
|
-
coinbaseWalletPreference?: CoinbaseWalletParameters<"4">["preference"];
|
|
126
|
-
additionalConnectors?: CreateConnectorFn[];
|
|
127
|
-
} & Partial<CreateConfigParameters>;
|
|
128
|
-
/** Daimo Pay recommended config, for use with wagmi's createConfig(). */
|
|
129
|
-
declare const defaultConfig: ({ appName, appIcon, appDescription, appUrl, walletConnectProjectId, coinbaseWalletPreference, additionalConnectors, chains, client, ...props }: DefaultConfigProps) => CreateConfigParameters;
|
|
130
|
-
|
|
131
132
|
/** Payment details and status. */
|
|
132
133
|
type DaimoPayment = DaimoPayOrderView;
|
|
133
134
|
/** Props for DaimoPayButton. */
|
|
@@ -196,9 +197,7 @@ type PayButtonPaymentProps = {
|
|
|
196
197
|
} | {
|
|
197
198
|
/** The payment ID, generated via the Daimo Pay API. Replaces params above. */
|
|
198
199
|
payId: string;
|
|
199
|
-
/**
|
|
200
|
-
* Payment options. By default, all are enabled.
|
|
201
|
-
*/
|
|
200
|
+
/** Payment options. By default, all are enabled. */
|
|
202
201
|
paymentOptions?: ExternalPaymentOptionsString[];
|
|
203
202
|
};
|
|
204
203
|
type PayButtonCommonProps = PayButtonPaymentProps & {
|
|
@@ -212,12 +211,15 @@ type PayButtonCommonProps = PayButtonPaymentProps & {
|
|
|
212
211
|
onOpen?: () => void;
|
|
213
212
|
/** Called when the modal is closed. */
|
|
214
213
|
onClose?: () => void;
|
|
215
|
-
/** Automatically close the modal after a successful payment. */
|
|
216
|
-
closeOnSuccess?: boolean;
|
|
217
214
|
/** Open the modal by default. */
|
|
218
215
|
defaultOpen?: boolean;
|
|
216
|
+
/** Automatically close the modal after a successful payment. */
|
|
217
|
+
closeOnSuccess?: boolean;
|
|
219
218
|
/** Reset the payment after a successful payment. */
|
|
220
219
|
resetOnSuccess?: boolean;
|
|
220
|
+
/** Go directly to tokens in already-connected Ethereum and Solana wallet(s).
|
|
221
|
+
* Don't let the user pick any other payment method. Used in embedded flows.*/
|
|
222
|
+
connectedWalletOnly?: boolean;
|
|
221
223
|
/** Custom message to display on confirmation page. */
|
|
222
224
|
confirmationMessage?: string;
|
|
223
225
|
/** Redirect URL to return to the app. E.g. after Coinbase, Binance, RampNetwork. */
|
|
@@ -254,6 +256,155 @@ declare namespace DaimoPayButtonCustom {
|
|
|
254
256
|
var displayName: string;
|
|
255
257
|
}
|
|
256
258
|
|
|
259
|
+
/** Payment parameters. The payment is created only after user taps pay. */
|
|
260
|
+
interface PayParams {
|
|
261
|
+
/** App ID, for authentication. */
|
|
262
|
+
appId: string;
|
|
263
|
+
/** Destination chain ID. */
|
|
264
|
+
toChain: number;
|
|
265
|
+
/** The destination token to send. */
|
|
266
|
+
toToken: Address;
|
|
267
|
+
/**
|
|
268
|
+
* The amount of the token to send.
|
|
269
|
+
* If not provided, the user will be prompted to enter an amount.
|
|
270
|
+
*/
|
|
271
|
+
toUnits?: string;
|
|
272
|
+
/** The final address to transfer to or contract to call. */
|
|
273
|
+
toAddress: Address;
|
|
274
|
+
/** Calldata for final call, or empty data for transfer. */
|
|
275
|
+
toCallData?: Hex;
|
|
276
|
+
/** The intent verb, such as Pay, Deposit, or Purchase. Default: Pay */
|
|
277
|
+
intent?: string;
|
|
278
|
+
/** Payment options. By default, all are enabled. */
|
|
279
|
+
paymentOptions?: ExternalPaymentOptionsString[];
|
|
280
|
+
/** Preferred chain IDs. */
|
|
281
|
+
preferredChains?: number[];
|
|
282
|
+
/** Preferred tokens. These appear first in the token list. */
|
|
283
|
+
preferredTokens?: {
|
|
284
|
+
chain: number;
|
|
285
|
+
address: Address;
|
|
286
|
+
}[];
|
|
287
|
+
/** Only allow payments on these EVM chains. */
|
|
288
|
+
evmChains?: number[];
|
|
289
|
+
/** External ID. E.g. a correlation ID. */
|
|
290
|
+
externalId?: string;
|
|
291
|
+
/** Developer metadata. E.g. correlation ID. */
|
|
292
|
+
metadata?: DaimoPayUserMetadata;
|
|
293
|
+
/** The address to refund to if the payment bounces or a refund is requested. */
|
|
294
|
+
refundAddress?: Address;
|
|
295
|
+
}
|
|
296
|
+
type PaymentState$1 = {
|
|
297
|
+
type: "idle";
|
|
298
|
+
} | {
|
|
299
|
+
type: "preview";
|
|
300
|
+
order: DaimoPayOrderWithOrg;
|
|
301
|
+
payParamsData: PayParamsData;
|
|
302
|
+
} | {
|
|
303
|
+
type: "unhydrated";
|
|
304
|
+
order: DaimoPayOrderWithOrg;
|
|
305
|
+
} | {
|
|
306
|
+
type: "payment_unpaid";
|
|
307
|
+
order: DaimoPayHydratedOrderWithOrg;
|
|
308
|
+
} | {
|
|
309
|
+
type: "payment_started";
|
|
310
|
+
order: DaimoPayHydratedOrderWithOrg;
|
|
311
|
+
} | {
|
|
312
|
+
type: "payment_completed";
|
|
313
|
+
order: DaimoPayHydratedOrderWithOrg;
|
|
314
|
+
} | {
|
|
315
|
+
type: "payment_bounced";
|
|
316
|
+
order: DaimoPayHydratedOrderWithOrg;
|
|
317
|
+
} | {
|
|
318
|
+
type: "error";
|
|
319
|
+
order: DaimoPayOrder | undefined;
|
|
320
|
+
message: string;
|
|
321
|
+
};
|
|
322
|
+
type PayParamsData = {
|
|
323
|
+
appId: string;
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
type DaimoPayFunctions = {
|
|
327
|
+
/**
|
|
328
|
+
* Create a new Daimo Pay order preview with the given parameters.
|
|
329
|
+
* Call this to start a new payment flow.
|
|
330
|
+
*
|
|
331
|
+
* @param params - Parameters describing the payment to be created.
|
|
332
|
+
*/
|
|
333
|
+
createPreviewOrder: (params: PayParams) => Promise<Extract<PaymentState$1, {
|
|
334
|
+
type: "preview";
|
|
335
|
+
}>>;
|
|
336
|
+
/**
|
|
337
|
+
* Set the order ID to fetch and manage an existing Daimo Pay order.
|
|
338
|
+
* Useful for resuming or referencing a previously created order.
|
|
339
|
+
*
|
|
340
|
+
* @param id - The Daimo Pay order ID to set.
|
|
341
|
+
*/
|
|
342
|
+
setPayId: (id: DaimoPayOrderID) => Promise<Extract<PaymentState$1, {
|
|
343
|
+
type: "unhydrated" | "payment_unpaid" | "payment_started" | "payment_completed" | "payment_bounced";
|
|
344
|
+
}>>;
|
|
345
|
+
/**
|
|
346
|
+
* Hydrate the current order, locking in the payment intent details and
|
|
347
|
+
* token swap prices.
|
|
348
|
+
*/
|
|
349
|
+
hydrateOrder: (refundAddress?: Address) => Promise<Extract<PaymentState$1, {
|
|
350
|
+
type: "payment_unpaid";
|
|
351
|
+
}>>;
|
|
352
|
+
/**
|
|
353
|
+
* Register an Ethereum payment source for the current order.
|
|
354
|
+
* Call this after the user has submitted an Ethereum payment transaction.
|
|
355
|
+
*
|
|
356
|
+
* @param args - Details about the Ethereum payment transaction.
|
|
357
|
+
*/
|
|
358
|
+
payEthSource: (args: {
|
|
359
|
+
paymentTxHash: Hex;
|
|
360
|
+
sourceChainId: number;
|
|
361
|
+
payerAddress: Address;
|
|
362
|
+
sourceToken: Address;
|
|
363
|
+
sourceAmount: bigint;
|
|
364
|
+
}) => void;
|
|
365
|
+
/**
|
|
366
|
+
* Register a Solana payment source for the current order.
|
|
367
|
+
* Call this after the user has submitted a Solana payment transaction.
|
|
368
|
+
*
|
|
369
|
+
* @param args - Details about the Solana payment transaction.
|
|
370
|
+
*/
|
|
371
|
+
paySolanaSource: (args: {
|
|
372
|
+
paymentTxHash: string;
|
|
373
|
+
sourceToken: SolanaPublicKey;
|
|
374
|
+
}) => void;
|
|
375
|
+
/**
|
|
376
|
+
* Reset the current payment state and clear the active order.
|
|
377
|
+
* Call this to start a new payment flow.
|
|
378
|
+
*/
|
|
379
|
+
reset: () => void;
|
|
380
|
+
/**
|
|
381
|
+
* Update the user's chosen amount in USD. Applies only to deposit flow.
|
|
382
|
+
*
|
|
383
|
+
* @deprecated
|
|
384
|
+
*/
|
|
385
|
+
setChosenUsd: (usd: number) => void;
|
|
386
|
+
};
|
|
387
|
+
type DaimoPayState = {
|
|
388
|
+
[S in PaymentState$1 as S["type"]]: {
|
|
389
|
+
paymentState: S["type"];
|
|
390
|
+
order: S extends {
|
|
391
|
+
order: infer O;
|
|
392
|
+
} ? O : null;
|
|
393
|
+
};
|
|
394
|
+
}[PaymentState$1["type"]];
|
|
395
|
+
type UseDaimoPay = DaimoPayFunctions & DaimoPayState;
|
|
396
|
+
/**
|
|
397
|
+
* React hook for interacting with Daimo Pay orders and payments. Use this hook
|
|
398
|
+
* to manage the lifecycle of a Daimo Pay payment in your application.
|
|
399
|
+
*
|
|
400
|
+
* This hook provides a simple interface to create, hydrate, pay, and reset
|
|
401
|
+
* Daimo Pay orders.
|
|
402
|
+
*
|
|
403
|
+
* @returns {UseDaimoPay} An object with current payment state and methods to
|
|
404
|
+
* manage Daimo Pay orders and payments.
|
|
405
|
+
*/
|
|
406
|
+
declare function useDaimoPay(): UseDaimoPay;
|
|
407
|
+
|
|
257
408
|
/** Returns the current payment, or undefined if there is none.
|
|
258
409
|
*
|
|
259
410
|
* Status values:
|
|
@@ -302,7 +453,6 @@ declare enum ROUTES {
|
|
|
302
453
|
CONFIRMATION = "daimoPayConfirmation",
|
|
303
454
|
SOLANA_CONNECT = "daimoPaySolanaConnect",
|
|
304
455
|
SOLANA_CONNECTOR = "daimoPaySolanaConnector",
|
|
305
|
-
SOLANA_SELECT_TOKEN = "daimoPaySolanaSelectToken",
|
|
306
456
|
SOLANA_SELECT_AMOUNT = "daimoPaySolanaSelectAmount",
|
|
307
457
|
SOLANA_PAY_WITH_TOKEN = "daimoPaySolanaPayWithToken",
|
|
308
458
|
ONBOARDING = "onboarding",
|
|
@@ -394,53 +544,14 @@ declare function useWalletPaymentOptions({ trpc, address, usdRequired, destChain
|
|
|
394
544
|
isLoading: boolean;
|
|
395
545
|
};
|
|
396
546
|
|
|
397
|
-
/** Payment parameters. The payment is created only after user taps pay. */
|
|
398
|
-
interface PayParams {
|
|
399
|
-
/** App ID, for authentication. */
|
|
400
|
-
appId: string;
|
|
401
|
-
/** Destination chain ID. */
|
|
402
|
-
toChain: number;
|
|
403
|
-
/** The destination token to send. */
|
|
404
|
-
toToken: Address;
|
|
405
|
-
/**
|
|
406
|
-
* The amount of the token to send.
|
|
407
|
-
* If not provided, the user will be prompted to enter an amount.
|
|
408
|
-
*/
|
|
409
|
-
toUnits?: string;
|
|
410
|
-
/** The final address to transfer to or contract to call. */
|
|
411
|
-
toAddress: Address;
|
|
412
|
-
/** Calldata for final call, or empty data for transfer. */
|
|
413
|
-
toCallData?: Hex;
|
|
414
|
-
/** The intent verb, such as Pay, Deposit, or Purchase. Default: Pay */
|
|
415
|
-
intent?: string;
|
|
416
|
-
/** Payment options. By default, all are enabled. */
|
|
417
|
-
paymentOptions?: ExternalPaymentOptionsString[];
|
|
418
|
-
/** Preferred chain IDs. */
|
|
419
|
-
preferredChains?: number[];
|
|
420
|
-
/** Preferred tokens. These appear first in the token list. */
|
|
421
|
-
preferredTokens?: {
|
|
422
|
-
chain: number;
|
|
423
|
-
address: Address;
|
|
424
|
-
}[];
|
|
425
|
-
/** Only allow payments on these EVM chains. */
|
|
426
|
-
evmChains?: number[];
|
|
427
|
-
/** External ID. E.g. a correlation ID. */
|
|
428
|
-
externalId?: string;
|
|
429
|
-
/** Developer metadata. E.g. correlation ID. */
|
|
430
|
-
metadata?: DaimoPayUserMetadata;
|
|
431
|
-
/** The address to refund to if the payment bounces or a refund is requested. */
|
|
432
|
-
refundAddress?: Address;
|
|
433
|
-
}
|
|
434
547
|
/** Creates (or loads) a payment and manages the corresponding modal. */
|
|
435
548
|
interface PaymentState {
|
|
436
|
-
generatePreviewOrder: (
|
|
549
|
+
generatePreviewOrder: () => void;
|
|
437
550
|
resetOrder: () => void;
|
|
438
551
|
buttonProps: PayButtonPaymentProps | undefined;
|
|
439
552
|
setButtonProps: (props: PayButtonPaymentProps | undefined) => void;
|
|
440
553
|
setPayId: (id: string | undefined) => void;
|
|
441
|
-
payParams: PayParams | undefined;
|
|
442
554
|
setPayParams: (payParams: PayParams | undefined) => void;
|
|
443
|
-
daimoPayOrder: DaimoPayOrderWithOrg | undefined;
|
|
444
555
|
isDepositFlow: boolean;
|
|
445
556
|
paymentWaitingMessage: string | undefined;
|
|
446
557
|
externalPaymentOptions: ReturnType<typeof useExternalPaymentOptions>;
|
|
@@ -456,6 +567,8 @@ interface PaymentState {
|
|
|
456
567
|
selectedDepositAddressOption: DepositAddressPaymentOptionMetadata | undefined;
|
|
457
568
|
getOrderUsdLimit: () => number;
|
|
458
569
|
setPaymentWaitingMessage: (message: string | undefined) => void;
|
|
570
|
+
tokenMode: "evm" | "solana" | "all";
|
|
571
|
+
setTokenMode: (mode: "evm" | "solana" | "all") => void;
|
|
459
572
|
setSelectedWallet: (wallet: WalletConfigProps | undefined) => void;
|
|
460
573
|
setSelectedWalletDeepLink: (deepLink: string | undefined) => void;
|
|
461
574
|
setSelectedExternalOption: (option: ExternalPaymentOptionMetadata | undefined) => void;
|
|
@@ -467,8 +580,7 @@ interface PaymentState {
|
|
|
467
580
|
payWithExternal: (option: ExternalPaymentOptions) => Promise<string>;
|
|
468
581
|
payWithDepositAddress: (option: DepositAddressPaymentOptions) => Promise<DepositAddressPaymentOptionData | null>;
|
|
469
582
|
payWithSolanaToken: (inputToken: SolanaPublicKey) => Promise<string | undefined>;
|
|
470
|
-
|
|
471
|
-
refreshOrder: () => Promise<void>;
|
|
583
|
+
openInWalletBrowser: (wallet: WalletConfigProps, amountUsd?: number) => void;
|
|
472
584
|
senderEnsName: string | undefined;
|
|
473
585
|
}
|
|
474
586
|
|
|
@@ -527,5 +639,5 @@ type PayContextValue = {
|
|
|
527
639
|
setRedirectReturnUrl: React$1.Dispatch<React$1.SetStateAction<string | undefined>>;
|
|
528
640
|
} & useConnectCallbackProps;
|
|
529
641
|
|
|
530
|
-
export { Avatar, Chain as ChainIcon, DaimoPayButton, PayContext as DaimoPayContext, DaimoPayProvider, types as Types, daimoPayVersion, defaultConfig as getDefaultConfig, useDaimoPayStatus, usePayContext, wallets };
|
|
642
|
+
export { Avatar, Chain as ChainIcon, DaimoPayButton, PayContext as DaimoPayContext, DaimoPayProvider, types as Types, daimoPayVersion, defaultConfig as getDefaultConfig, useDaimoPay, useDaimoPayStatus, usePayContext, wallets };
|
|
531
643
|
export type { All, CustomAvatarProps, CustomTheme, DaimoPayButtonCustomProps, DaimoPayButtonProps, DaimoPayContextOptions, DaimoPayModalOptions, DaimoPayment, Languages, Mode, Theme };
|