@daimo/pay-common 1.19.11 → 2.0.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.
package/src/daimoPay.ts DELETED
@@ -1,761 +0,0 @@
1
- // TODO: this file defines types that shouldn't be exposed to the client.
2
- // Clean this up to only expose the types that are needed by the client.
3
-
4
- import { base58 } from "@scure/base";
5
- import {
6
- Address,
7
- bytesToBigInt,
8
- formatUnits,
9
- getAddress,
10
- Hex,
11
- numberToBytes,
12
- zeroAddress,
13
- } from "viem";
14
- import z from "zod";
15
- import { Token } from "./token";
16
-
17
- import { assertNotNull } from "./assert";
18
- import {
19
- BigIntStr,
20
- SolanaPublicKey,
21
- UUID,
22
- zAddress,
23
- zBigIntStr,
24
- } from "./primitiveTypes";
25
-
26
- // lifecycle: waiting payment -> pending processing -> start submitted -> processed (onchain tx was successful)
27
- export enum DaimoPayOrderStatusSource {
28
- WAITING_PAYMENT = "waiting_payment",
29
- PENDING_PROCESSING = "pending_processing",
30
- START_SUBMITTED = "start_submitted",
31
- /* Start transaction receipt confirmed. */
32
- PROCESSED = "processed",
33
- }
34
-
35
- // lifecycle: pending -> fast-finish-submitted (onchain tx submitted) -> fast-finished (onchain tx was successful) -> claimed (onchain tx was successful)
36
- export enum DaimoPayOrderStatusDest {
37
- PENDING = "pending",
38
- FAST_FINISH_SUBMITTED = "fast_finish_submitted",
39
- /* Fast finish transaction receipt confirmed. */
40
- FAST_FINISHED = "fast_finished",
41
- CLAIM_SUCCESSFUL = "claimed",
42
- }
43
-
44
- export enum DaimoPayOrderMode {
45
- SALE = "sale", // product or item sale
46
- CHOOSE_AMOUNT = "choose_amount", // let the user specify the amount to pay
47
- HYDRATED = "hydrated", // once hydrated, the order is final and all parameters are known and immutable
48
- }
49
-
50
- /**
51
- * Status values:
52
- * - `payment_unpaid` - the user has not paid yet
53
- * - `payment_started` - the user has paid & payment is in progress. This status
54
- * typically lasts a few seconds.
55
- * - `payment_completed` - the final call or transfer succeeded
56
- * - `payment_bounced` - the final call or transfer reverted. Funds were sent
57
- * to the payment's configured refund address on the destination chain.
58
- */
59
- export enum DaimoPayIntentStatus {
60
- UNPAID = "payment_unpaid",
61
- STARTED = "payment_started",
62
- COMPLETED = "payment_completed",
63
- BOUNCED = "payment_bounced",
64
- REFUNDED = "payment_refunded",
65
- }
66
-
67
- /**
68
- * Source screening status.
69
- */
70
- export enum DaimoPaySourceCheck {
71
- OK = "ok",
72
- BLOCKED = "blocked",
73
- }
74
-
75
- export interface DaimoPayOrderItem {
76
- name: string;
77
- description: string;
78
- image?: string;
79
- }
80
-
81
- export const zBridgeTokenOutOptions = z.array(
82
- z.object({
83
- token: zAddress,
84
- amount: zBigIntStr.transform((a) => BigInt(a)),
85
- }),
86
- );
87
-
88
- export type BridgeTokenOutOptions = z.infer<typeof zBridgeTokenOutOptions>;
89
-
90
- // NOTE: be careful to modify this type only in backward-compatible ways.
91
- // Add OPTIONAL fields, etc. Anything else requires a migration.
92
- export const zDaimoPayOrderMetadata = z.object({
93
- style: z
94
- .object({
95
- background: z.string().optional().describe("Background color."),
96
- })
97
- .optional()
98
- .describe("Style of the checkout page."),
99
- orgLogo: z.string().optional().describe("Logo of the organization."),
100
- intent: z
101
- .string()
102
- .describe("Title verb, eg 'Preorder', 'Check out', 'Deposit'."),
103
- items: z
104
- .array(
105
- z.object({
106
- name: z.string(),
107
- description: z.string(),
108
- image: z.string().optional(),
109
- price: z.string().optional(),
110
- priceDetails: z.string().optional(),
111
- }),
112
- )
113
- .describe("Details about what's being ordered, donated, deposited, etc."),
114
- payer: z
115
- .object({
116
- preferredChains: z
117
- .array(z.number())
118
- .optional()
119
- .describe(
120
- "Preferred chain IDs, in descending order. Any assets the user owns on preferred chains will appear first. Defaults to destination chain.",
121
- ),
122
- preferredTokens: z
123
- .array(
124
- z.object({
125
- chain: z.number(),
126
- address: zAddress.transform((a) => getAddress(a)),
127
- }),
128
- )
129
- .optional()
130
- .describe(
131
- "Preferred tokens, in descending order. Any preferred assets the user owns will appear first. Defaults to destination token.",
132
- ),
133
- // Filter to only allow payments on these chains. Keep this
134
- // parameter undocumented. Only for specific customers.
135
- evmChains: z
136
- .array(z.number())
137
- .optional()
138
- .describe(
139
- "Filter to only allow payments on these EVM chains. Defaults to all chains.",
140
- ),
141
- paymentOptions: z
142
- .array(z.union([z.string(), z.array(z.string())]))
143
- .optional()
144
- .describe(
145
- "Payment options like Coinbase, Binance, etc. Supports nested arrays for mobile wallet filtering. Defaults to all available options.",
146
- ),
147
- passthroughTokens: z
148
- .array(
149
- z.object({
150
- chain: z.number(),
151
- address: zAddress.transform((a) => getAddress(a)),
152
- }),
153
- )
154
- .optional()
155
- .describe(
156
- "Pass-through tokens. If the user pays via these tokens, they're sent directly to the destination address without swapping or bridging.",
157
- ),
158
- })
159
- .optional()
160
- .describe(""),
161
- finalRefundUrl: z
162
- .string()
163
- .optional()
164
- .describe("URL of the final refund transaction, if manually refunded."),
165
- });
166
-
167
- export type DaimoPayOrderMetadata = z.infer<typeof zDaimoPayOrderMetadata>;
168
-
169
- /**
170
- * The user-passed metadata must meet these criteria:
171
- * - All keys must be strings
172
- * - All values must be strings
173
- * - At most 50 key-value pairs
174
- * - Maximum of 40 characters per key
175
- * - Maximum of 500 characters per value
176
- */
177
- export const zDaimoPayUserMetadata = z
178
- .record(
179
- z.string().max(40, "Metadata keys cannot be longer than 40 characters"),
180
- z.string().max(500, "Metadata values cannot be longer than 500 characters"),
181
- )
182
- .nullable()
183
- .refine(
184
- (obj) => !obj || Object.keys(obj).length <= 50,
185
- "Metadata cannot have more than 50 key-value pairs",
186
- );
187
-
188
- export type DaimoPayUserMetadata = z.infer<typeof zDaimoPayUserMetadata>;
189
-
190
- export type DaimoPayDehydratedOrder = {
191
- mode: DaimoPayOrderMode.SALE | DaimoPayOrderMode.CHOOSE_AMOUNT;
192
- id: bigint;
193
- destFinalCallTokenAmount: DaimoPayTokenAmount;
194
- destFinalCall: OnChainCall;
195
- nonce: bigint;
196
- redirectUri: string | null;
197
- orgId: string | null;
198
- createdAt: number | null;
199
- lastUpdatedAt: number | null;
200
- intentStatus: DaimoPayIntentStatus;
201
- metadata: DaimoPayOrderMetadata;
202
- externalId: string | null;
203
- userMetadata: DaimoPayUserMetadata | null;
204
- refundAddr: Address | null;
205
- };
206
-
207
- export type DaimoPayHydratedOrder = {
208
- mode: DaimoPayOrderMode.HYDRATED;
209
- id: bigint;
210
- intentAddr: Address;
211
- /** Nullable because old intents don't record escrow address. */
212
- escrowContractAddress: Address | null;
213
- /** Nullable because old intents don't record bridger address. */
214
- bridgerContractAddress: Address | null;
215
- /** @deprecated included for backcompat with old versions. Remove soon. */
216
- handoffAddr: Address;
217
- bridgeTokenOutOptions: DaimoPayTokenAmount[];
218
- selectedBridgeTokenOutAddr: Address | null;
219
- selectedBridgeTokenOutAmount: bigint | null;
220
- destFinalCallTokenAmount: DaimoPayTokenAmount;
221
- destFinalCall: OnChainCall;
222
- usdValue: number;
223
- refundAddr: Address;
224
- nonce: bigint;
225
- sourceFulfillerAddr: Address | SolanaPublicKey | null;
226
- sourceTokenAmount: DaimoPayTokenAmount | null;
227
- sourceInitiateTxHash: Hex | null;
228
- sourceStartTxHash: Hex | null;
229
- sourceStatus: DaimoPayOrderStatusSource;
230
- sourceCheck: DaimoPaySourceCheck | null;
231
- destStatus: DaimoPayOrderStatusDest;
232
- destFastFinishTxHash: Hex | null;
233
- destClaimTxHash: Hex | null;
234
- passedToAddress: Address | null;
235
- redirectUri: string | null;
236
- orgId: string | null;
237
- sourceInitiateUpdatedAt: number | null;
238
- createdAt: number | null;
239
- lastUpdatedAt: number | null;
240
- intentStatus: DaimoPayIntentStatus;
241
- metadata: DaimoPayOrderMetadata;
242
- externalId: string | null;
243
- userMetadata: DaimoPayUserMetadata | null;
244
- /** Nullable because old intents don't have expiration time. */
245
- expirationTs: bigint | null;
246
- /** External source type, or null. EG "untron". */
247
- extSourceType: string | null;
248
- /** External source ID. Set when extSourceType is set. */
249
- extSourceId: string | null;
250
- /** Chain ID for hop transactions */
251
- hopChainId: number | null;
252
- /** Transaction hash for hop start */
253
- hopStartTxHash: Hex | null;
254
- /** If set, indicates slow finish with estimated completion time. Unix timestamp. */
255
- finishSlowEta: number | null;
256
- /** Next time this fulfillment can be retried for processing. Unix timestamp. */
257
- retryProcessingAt: number | null;
258
- /** Number of retry attempts for this fulfillment. */
259
- retryCount: number;
260
- };
261
-
262
- export type DaimoPayOrderWithOrg = DaimoPayOrder & {
263
- org: DaimoPayOrgPublicInfo;
264
- };
265
-
266
- export type DaimoPayHydratedOrderWithOrg = DaimoPayHydratedOrder & {
267
- org: DaimoPayOrgPublicInfo;
268
- };
269
-
270
- export type DaimoPayOrgPublicInfo = {
271
- orgId: string;
272
- name: string;
273
- logoURI?: string;
274
- };
275
-
276
- export type DaimoPayHydratedOrderWithoutIntentAddr = Omit<
277
- DaimoPayHydratedOrder,
278
- "intentAddr" | "handoffAddr"
279
- >;
280
-
281
- export type DaimoPayOrder = DaimoPayDehydratedOrder | DaimoPayHydratedOrder;
282
-
283
- export function isHydrated(
284
- order: DaimoPayOrder,
285
- ): order is DaimoPayHydratedOrder {
286
- return order.mode === DaimoPayOrderMode.HYDRATED;
287
- }
288
-
289
- export function isDehydrated(
290
- order: DaimoPayOrder,
291
- ): order is DaimoPayDehydratedOrder {
292
- return (
293
- order.mode === DaimoPayOrderMode.CHOOSE_AMOUNT ||
294
- order.mode === DaimoPayOrderMode.SALE
295
- );
296
- }
297
-
298
- export type DaimoPayOrderView = {
299
- id: DaimoPayOrderID;
300
- status: DaimoPayIntentStatus;
301
- createdAt: string; // Seconds since epoch
302
- display: {
303
- intent: string;
304
- paymentValue: string;
305
- currency: "USD";
306
- };
307
- source: {
308
- payerAddress: Address | SolanaPublicKey | null;
309
- txHash: Hex | string | null;
310
- chainId: string;
311
- amountUnits: string;
312
- tokenSymbol: string;
313
- tokenAddress: Address | string;
314
- } | null;
315
- destination: {
316
- destinationAddress: Address;
317
- txHash: Hex | null;
318
- chainId: string;
319
- amountUnits: string;
320
- tokenSymbol: string;
321
- tokenAddress: Address;
322
- callData: Hex | null;
323
- };
324
- externalId: string | null;
325
- metadata: DaimoPayUserMetadata | null;
326
- };
327
-
328
- export function getOrderSourceChainId(
329
- order: DaimoPayHydratedOrder,
330
- ): number | null {
331
- if (order.sourceTokenAmount == null) {
332
- return null;
333
- }
334
- return order.sourceTokenAmount.token.chainId;
335
- }
336
-
337
- export function getOrderDestChainId(
338
- order: DaimoPayOrder | DaimoPayHydratedOrderWithoutIntentAddr,
339
- ): number {
340
- return order.destFinalCallTokenAmount.token.chainId;
341
- }
342
-
343
- export function getDaimoPayOrderView(order: DaimoPayOrder): DaimoPayOrderView {
344
- return {
345
- id: writeDaimoPayOrderID(order.id),
346
- status: order.intentStatus,
347
- createdAt: assertNotNull(
348
- order.createdAt,
349
- `createdAt is null for order with id: ${order.id}`,
350
- ).toString(),
351
- display: {
352
- intent: order.metadata.intent,
353
- // Show 2 decimal places for USD
354
- paymentValue: order.destFinalCallTokenAmount.usd.toFixed(2),
355
- currency: "USD",
356
- },
357
- source:
358
- order.mode === DaimoPayOrderMode.HYDRATED &&
359
- order.sourceTokenAmount != null
360
- ? {
361
- payerAddress: order.sourceFulfillerAddr,
362
- txHash: order.sourceInitiateTxHash,
363
- chainId: assertNotNull(
364
- getOrderSourceChainId(order),
365
- `source chain id is null for order with source token: ${order.id}`,
366
- ).toString(),
367
- amountUnits: formatUnits(
368
- BigInt(order.sourceTokenAmount.amount),
369
- order.sourceTokenAmount.token.decimals,
370
- ),
371
- tokenSymbol: order.sourceTokenAmount.token.symbol,
372
- tokenAddress: order.sourceTokenAmount.token.token,
373
- }
374
- : null,
375
- destination: {
376
- destinationAddress: order.destFinalCall.to,
377
- txHash:
378
- order.mode === DaimoPayOrderMode.HYDRATED
379
- ? (order.destFastFinishTxHash ?? order.destClaimTxHash)
380
- : null,
381
- chainId: getOrderDestChainId(order).toString(),
382
- amountUnits: formatUnits(
383
- BigInt(order.destFinalCallTokenAmount.amount),
384
- order.destFinalCallTokenAmount.token.decimals,
385
- ),
386
- tokenSymbol: order.destFinalCallTokenAmount.token.symbol,
387
- tokenAddress: getAddress(order.destFinalCallTokenAmount.token.token),
388
- callData: order.destFinalCall.data,
389
- },
390
- externalId: order.externalId,
391
- metadata: order.userMetadata,
392
- };
393
- }
394
-
395
- export type WalletPaymentOption = {
396
- /** The user's balance of this token. */
397
- balance: DaimoPayTokenAmount;
398
-
399
- // TODO: deprecate, replace with requiredUsd / minRequiredUsd / feesUsd
400
- // These are overly large objects that duplicate DaimoPayToken
401
- required: DaimoPayTokenAmount;
402
- minimumRequired: DaimoPayTokenAmount;
403
- fees: DaimoPayTokenAmount;
404
-
405
- /** If present, the option is disabled. */
406
- disabledReason?: string;
407
-
408
- /** If present, send directly to passthroughAddress, no swap or bridge. */
409
- passthroughAddress?: Address;
410
- };
411
-
412
- export type ExternalPaymentOptionMetadata = {
413
- id: ExternalPaymentOptions;
414
- optionType: "external" | "exchange";
415
- cta: string;
416
- logoURI: string;
417
- logoShape: "circle" | "squircle";
418
- paymentToken: DaimoPayToken;
419
- disabled: boolean;
420
- message?: string;
421
- minimumUsd?: number;
422
- };
423
-
424
- export enum ExternalPaymentOptions {
425
- // Wallets options
426
- AllWallets = "AllWallets",
427
- Metamask = "MetaMask",
428
- Trust = "Trust",
429
- Rainbow = "Rainbow",
430
- BaseApp = "Base App",
431
- Backpack = "Backpack",
432
- Bitget = "Bitget",
433
- Family = "Family",
434
- Farcaster = "Farcaster",
435
- Phantom = "Phantom",
436
- MiniPay = "MiniPay",
437
- OKX = "OKX",
438
- Solflare = "Solflare",
439
- World = "World",
440
- Zerion = "Zerion",
441
- //Exchange options
442
- AllExchanges = "AllExchanges",
443
- Coinbase = "Coinbase",
444
- Binance = "Binance",
445
- Lemon = "Lemon",
446
- // Pay to Address options
447
- AllAddresses = "AllAddresses",
448
- Tron = "Tron",
449
- Base = "Base",
450
- Arbitrum = "Arbitrum",
451
- Optimism = "Optimism",
452
- Polygon = "Polygon",
453
- Ethereum = "Ethereum",
454
- /** @deprecated - ZKP2P payment apps no longer supported */
455
- AllPaymentApps = "AllPaymentApps",
456
- /** @deprecated - ZKP2P payment apps no longer supported */
457
- Venmo = "Venmo",
458
- /** @deprecated - ZKP2P payment apps no longer supported */
459
- CashApp = "CashApp",
460
- /** @deprecated - ZKP2P payment apps no longer supported */
461
- MercadoPago = "MercadoPago",
462
- /** @deprecated - ZKP2P payment apps no longer supported */
463
- Revolut = "Revolut",
464
- /** @deprecated - ZKP2P payment apps no longer supported */
465
- Wise = "Wise",
466
- /** @deprecated - ZKP2P payment apps no longer supported */
467
- Zelle = "Zelle",
468
- /** @deprecated - kept for backwards compatibility with old SDK versions */
469
- Daimo = "Daimo",
470
- /** @deprecated - kept for backwards compatibility with old SDK versions */
471
- ExternalChains = "ExternalChains",
472
- }
473
-
474
- export type ExternalPaymentOptionsString = `${ExternalPaymentOptions}`;
475
-
476
- export function shouldShowExternalQRCodeOnDesktop(
477
- externalOption: ExternalPaymentOptions,
478
- ): boolean {
479
- return (
480
- externalOption === ExternalPaymentOptions.Lemon ||
481
- externalOption === ExternalPaymentOptions.Binance
482
- );
483
- }
484
-
485
- export type ExternalPaymentOptionData = {
486
- url: string;
487
- waitingMessage: string;
488
- };
489
-
490
- export enum DepositAddressPaymentOptions {
491
- TRON_USDT = "USDT on Tron",
492
- BASE = "Base",
493
- ARBITRUM = "Arbitrum",
494
- OP_MAINNET = "Optimism",
495
- POLYGON = "Polygon",
496
- ETH_L1 = "Ethereum",
497
-
498
- /** @deprecated */
499
- BITCOIN = "Bitcoin",
500
- /** @deprecated */
501
- TON = "TON",
502
- /** @deprecated */
503
- MONERO = "Monero",
504
- /** @deprecated */
505
- DOGE = "Doge",
506
- /** @deprecated */
507
- LITECOIN = "Litecoin",
508
- /** @deprecated */
509
- ZCASH = "Zcash",
510
- /** @deprecated */
511
- DASH = "Dash",
512
- }
513
-
514
- export type DepositAddressPaymentOptionMetadata = {
515
- id: DepositAddressPaymentOptions;
516
- logoURI: string;
517
- minimumUsd: number;
518
- };
519
-
520
- export type DepositAddressPaymentOptionData = {
521
- address: string;
522
- uri: string;
523
- amount: string;
524
- suffix: string;
525
- expirationS: number;
526
- };
527
-
528
- export interface DaimoPayToken extends Token {
529
- token: Address | SolanaPublicKey;
530
- /** Price to convert 1.0 of this token to a USD stablecoin. */
531
- usd: number;
532
- /** Price to convert $1 to this token T. If 2.00, then we receive 0.5 T. */
533
- priceFromUsd: number;
534
- /** Max payment accepted in this token, based on liquidity & mode. */
535
- maxAcceptUsd: number;
536
- /** Max payment we can send from this token, based on liquidity & mode. */
537
- maxSendUsd: number;
538
- /** Display decimals, separate from token decimals. Eg: 2 for USDC. */
539
- displayDecimals: number;
540
- /** Symbol for fiat currency, eg: "$" */
541
- fiatSymbol?: string;
542
- }
543
-
544
- export interface DaimoPayTokenAmount {
545
- token: DaimoPayToken;
546
- amount: BigIntStr;
547
- usd: number; // amount in dollars
548
- }
549
-
550
- export type OnChainCall = {
551
- to: Address;
552
- data: Hex;
553
- value: bigint;
554
- };
555
-
556
- export const emptyOnChainCall: OnChainCall = {
557
- to: zeroAddress,
558
- data: "0x",
559
- value: 0n,
560
- };
561
-
562
- // base58 encoded bigint
563
- const zDaimoPayOrderID = z.string().regex(/^[1-9A-HJ-NP-Za-km-z]+$/);
564
-
565
- export type DaimoPayOrderID = z.infer<typeof zDaimoPayOrderID>;
566
-
567
- /**
568
- * Read a base58-encoded id into a bigint.
569
- */
570
- export function readDaimoPayOrderID(id: string): bigint {
571
- return bytesToBigInt(base58.decode(id));
572
- }
573
-
574
- /**
575
- * Write a bigint into a base58-encoded id.
576
- */
577
- export function writeDaimoPayOrderID(id: bigint): string {
578
- return base58.encode(numberToBytes(id));
579
- }
580
-
581
- export enum DaimoPayEventType {
582
- PaymentStarted = "payment_started",
583
- PaymentCompleted = "payment_completed",
584
- PaymentBounced = "payment_bounced",
585
- PaymentRefunded = "payment_refunded",
586
- }
587
-
588
- export type PaymentStartedEvent = {
589
- type: DaimoPayEventType.PaymentStarted;
590
- isTestEvent?: boolean;
591
- /** Order ID (base58) for order flows, session ID for DA flows */
592
- paymentId: DaimoPayOrderID;
593
- /** Session ID (always present) */
594
- sessionId: string;
595
- chainId: number;
596
- txHash: Hex | string | null;
597
- payment: DaimoPayOrderView;
598
- };
599
-
600
- export type PaymentCompletedEvent = {
601
- type: DaimoPayEventType.PaymentCompleted;
602
- isTestEvent?: boolean;
603
- /** Order ID (base58) for order flows, session ID for DA flows */
604
- paymentId: DaimoPayOrderID;
605
- /** Session ID (always present) */
606
- sessionId: string;
607
- chainId: number;
608
- txHash: Hex;
609
- payment: DaimoPayOrderView;
610
- };
611
-
612
- export type PaymentBouncedEvent = {
613
- type: DaimoPayEventType.PaymentBounced;
614
- isTestEvent?: boolean;
615
- /** Order ID (base58) for order flows, session ID for DA flows */
616
- paymentId: DaimoPayOrderID;
617
- /** Session ID (always present) */
618
- sessionId: string;
619
- chainId: number;
620
- txHash: Hex;
621
- payment: DaimoPayOrderView;
622
- };
623
-
624
- export type PaymentRefundedEvent = {
625
- type: DaimoPayEventType.PaymentRefunded;
626
- isTestEvent?: boolean;
627
- /** Order ID (base58) for order flows, session ID for DA flows */
628
- paymentId: DaimoPayOrderID;
629
- /** Session ID (always present) */
630
- sessionId: string;
631
- refundAddress: Address;
632
- chainId: number;
633
- tokenAddress: Address;
634
- txHash: Hex;
635
- amountUnits: string;
636
- payment: DaimoPayOrderView;
637
- };
638
-
639
- export type DaimoPayEvent =
640
- | PaymentStartedEvent
641
- | PaymentCompletedEvent
642
- | PaymentBouncedEvent
643
- | PaymentRefundedEvent;
644
-
645
- export enum DAFulfillmentStatus {
646
- STARTED = "deposit_started",
647
- COMPLETED = "deposit_completed",
648
- BOUNCED = "deposit_bounced",
649
- }
650
-
651
- export type DAFulfillment = {
652
- id: UUID;
653
- daAddr: Address;
654
- status: DAFulfillmentStatus;
655
- createdAt: string; // Seconds since epoch
656
- source: {
657
- payerAddress: Address | SolanaPublicKey | null;
658
- txHash: Hex | string | null;
659
- chainId: string;
660
- tokenAddress: Address | SolanaPublicKey;
661
- tokenSymbol: string;
662
- amountUnits: string;
663
- usdValue: string;
664
- };
665
- destination: {
666
- destinationAddress: Address;
667
- chainId: string;
668
- tokenAddress: Address;
669
- tokenSymbol: string;
670
- amountUnits: string | null;
671
- txHash: Hex | null;
672
- };
673
- };
674
-
675
- export type DA = {
676
- daAddr: Address;
677
- org: DaimoPayOrgPublicInfo;
678
- destinationChainId: string;
679
- destinationAddress: Address;
680
- destinationTokenAddress: Address;
681
- destinationTokenSymbol: string;
682
- refundAddress: Address;
683
- expiresAt: string; // Seconds since epoch
684
- createdAt: string; // Seconds since epoch
685
- fulfillments: DAFulfillment[];
686
- };
687
-
688
- // Session types for the new modal flow
689
-
690
- export type SessionState =
691
- | "pending"
692
- | "processing"
693
- | "completed"
694
- | "bounced"
695
- | "expired";
696
-
697
- /** Common fields for all navigation nodes */
698
- type NavNodeCommon = {
699
- id: string;
700
- /** Page header title when this node is active */
701
- title: string;
702
- /** Button label when shown as option in parent (defaults to title) */
703
- label?: string;
704
- /** Icons to display on option button (defaults to child icons or node icon) */
705
- icons?: string[];
706
- };
707
-
708
- export type NavNodeChooseOption = NavNodeCommon & {
709
- type: "ChooseOption";
710
- options: NavNode[];
711
- /** Layout for displaying options. Defaults to "list". */
712
- layout?: "list" | "grid";
713
- };
714
-
715
- export type NavNodeDepositAddress = NavNodeCommon & {
716
- type: "DepositAddress";
717
- address: Address;
718
- chainId: number;
719
- icon?: string;
720
- minimumUsd: number;
721
- maximumUsd: number;
722
- expiresAt: number; // Unix timestamp (createdAt + 1 hour)
723
- tokenSuffix: string; // e.g., "USDT or USDC"
724
- };
725
-
726
- export type NavNodeDeeplink = NavNodeCommon & {
727
- type: "Deeplink";
728
- url: string;
729
- icon?: string;
730
- };
731
-
732
- export type NavNodeExchange = NavNodeCommon & {
733
- type: "Exchange";
734
- exchangeId: "Coinbase" | "Binance" | "Lemon";
735
- icon?: string;
736
- minimumUsd: number;
737
- maximumUsd: number;
738
- };
739
-
740
- export type NavNodeTronDeposit = NavNodeCommon & {
741
- type: "TronDeposit";
742
- icon?: string;
743
- minimumUsd: number;
744
- maximumUsd: number;
745
- };
746
-
747
- export type NavNode =
748
- | NavNodeChooseOption
749
- | NavNodeDepositAddress
750
- | NavNodeDeeplink
751
- | NavNodeExchange
752
- | NavNodeTronDeposit;
753
-
754
- export type Session = {
755
- sessionId: UUID;
756
- state: SessionState;
757
- da: DA;
758
- navTree: NavNode[];
759
- /** Custom theme CSS URL, overrides default theme */
760
- themeCssUrl?: string;
761
- };