@fun-xyz/fiat-contract 0.36.0-uda.1 → 0.36.0-uda.3

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.
@@ -1,11 +1,10 @@
1
1
  // package.json
2
- var version = "0.36.0-uda.1";
2
+ var version = "0.36.0-uda.3";
3
3
 
4
4
  // src/table.ts
5
5
  var TABLE_VERSION = version;
6
6
  var TERMINAL_ORDER_STATUSES = [
7
7
  "SETTLED",
8
- "FINAL_ASSET_DELIVERED",
9
8
  "EXPIRED",
10
9
  "CANCELLED",
11
10
  "FAILED",
@@ -360,7 +359,7 @@ var TRANSITION_TABLE = {
360
359
  id: "poll",
361
360
  mode: "AWAIT",
362
361
  endpoint: "GET /fiat/orders/:id",
363
- when: "status is non-terminal",
362
+ when: "status is non-terminal, or no delivery stage is FAILED and one is PENDING",
364
363
  note: "Documented giveUpAfterMs 300000 \u2014 on give-up the wizard exits and the durable order takes over."
365
364
  },
366
365
  {
@@ -391,7 +390,7 @@ var TRANSITION_TABLE = {
391
390
  "A terminal status may still carry a recovery transition: FAILED + retryable failureReason emits it (FE doc Screen 14); non-retryable emits [].",
392
391
  "ON_HOLD is a non-terminal status (resolves to PROCESSING or REFUNDED) \u2014 and is NOT the same thing as the KYC ON_HOLD reason; see the note on that field.",
393
392
  "CAPTURE_ORPHANED is non-terminal pending the backend rank map (added from review 2026-08-14).",
394
- "FINAL_ASSET_DELIVERED ends only an order whose request carried a destination. SETTLED stays in terminalStatuses for every other order, so a client that sent a destination keeps polling past SETTLED.",
393
+ "SETTLED is terminal for the order, and marks the FIAT_PAYOUT delivery stage DONE. A later stage (CRYPTO_SWAP) may still run after SETTLED: the backend keeps offering the AWAIT poll while no stage is FAILED and one is PENDING, and the client keeps polling until every stage is DONE or one is FAILED.",
395
394
  "TODO(open-decision): contract OQ7 \u2014 under/over-payment is the biggest unenumerated branch."
396
395
  ]
397
396
  }
package/dist/index.js CHANGED
@@ -41,10 +41,13 @@ __export(index_exports, {
41
41
  FeeLineSchema: () => FeeLineSchema,
42
42
  FiatAmountSchema: () => FiatAmountSchema,
43
43
  FiatCurrencyCode: () => FiatCurrencyCode,
44
+ FiatDeliveryStageKindSchema: () => FiatDeliveryStageKindSchema,
45
+ FiatDeliveryStageSchema: () => FiatDeliveryStageSchema,
44
46
  FiatDestinationSchema: () => FiatDestinationSchema,
45
47
  FiatEndpointSchema: () => FiatEndpointSchema,
46
48
  FiatGeoSchema: () => FiatGeoSchema,
47
49
  FiatNextRequestSchema: () => FiatNextRequestSchema,
50
+ FiatOrderDeliverySchema: () => FiatOrderDeliverySchema,
48
51
  FiatProviderSchema: () => FiatProviderSchema,
49
52
  FiatRoutingQuoteErrorBodySchema: () => FiatRoutingQuoteErrorBodySchema,
50
53
  FiatRoutingQuoteRequestSchema: () => FiatRoutingQuoteRequestSchema,
@@ -539,7 +542,6 @@ var $orderStatus = import_zod.z.enum([
539
542
  "ON_HOLD",
540
543
  "CRYPTO_SENT",
541
544
  "SETTLED",
542
- "FINAL_ASSET_DELIVERED",
543
545
  "EXPIRED",
544
546
  "CANCELLED",
545
547
  "FAILED",
@@ -625,6 +627,16 @@ var $statusHistoryEntry = obj({ status: $orderStatus });
625
627
  var StatusHistoryEntrySchema = $statusHistoryEntry;
626
628
  var $tx = obj({ chainId: import_zod.z.number(), hash: import_zod.z.string() });
627
629
  var TxSchema = $tx;
630
+ var $deliveryStageKind = import_zod.z.enum(["FIAT_PAYOUT", "CRYPTO_SWAP"]);
631
+ var FiatDeliveryStageKindSchema = $deliveryStageKind;
632
+ var $deliveryStage = import_zod.z.discriminatedUnion("state", [
633
+ obj({ kind: $deliveryStageKind, state: import_zod.z.literal("PENDING") }),
634
+ obj({ kind: $deliveryStageKind, state: import_zod.z.literal("DONE"), txHash: import_zod.z.string().min(1) }),
635
+ obj({ kind: $deliveryStageKind, state: import_zod.z.literal("FAILED") })
636
+ ]);
637
+ var FiatDeliveryStageSchema = $deliveryStage;
638
+ var $orderDelivery = obj({ stages: import_zod.z.array($deliveryStage).min(1) });
639
+ var FiatOrderDeliverySchema = $orderDelivery;
628
640
  var $refund = obj({
629
641
  currency: import_zod.z.enum(FIAT_CURRENCY_CODES),
630
642
  amount: import_zod.z.string(),
@@ -1001,6 +1013,7 @@ var $orderCreatedState = obj({
1001
1013
  status: $orderStatus,
1002
1014
  statusHistory: import_zod.z.array($statusHistoryEntry).optional(),
1003
1015
  tx: $tx.optional(),
1016
+ delivery: $orderDelivery.optional(),
1004
1017
  refund: $refund.optional(),
1005
1018
  failureReason: $failureReason.optional(),
1006
1019
  error: $failureReason.optional()
@@ -1056,13 +1069,43 @@ var $termsErrorBody = obj({
1056
1069
  recovery: import_zod.z.enum(["RETRY", "REQUOTE", "NONE"])
1057
1070
  });
1058
1071
  var FiatTermsErrorBodySchema = $termsErrorBody;
1059
- var $destination = obj({
1060
- chainId: import_zod.z.string().regex(/^[1-9]\d*$/, "must be a decimal chain id"),
1061
- tokenAddress: import_zod.z.union([
1062
- import_zod.z.string().regex(/^0x[0-9a-fA-F]{40}$/, "must be an EVM address"),
1063
- import_zod.z.string().regex(/^[1-9A-HJ-NP-Za-km-z]{32,44}$/, "must be a Solana base58 address")
1072
+ var $evmAddress = import_zod.z.custom(
1073
+ (value) => typeof value === "string" && /^0x[0-9a-fA-F]{40}$/.test(value),
1074
+ "must be an EVM address: 0x and 40 hex digits"
1075
+ );
1076
+ var $solanaAddress = import_zod.z.string().regex(/^[1-9A-HJ-NP-Za-km-z]{32,44}$/, "must be a Solana base58 address");
1077
+ var $evmDestination = obj({
1078
+ vm: import_zod.z.literal("EVM"),
1079
+ chainId: import_zod.z.number().int().positive(),
1080
+ asset: import_zod.z.discriminatedUnion("kind", [
1081
+ obj({
1082
+ kind: import_zod.z.literal("FUNGIBLE"),
1083
+ token: import_zod.z.discriminatedUnion("type", [
1084
+ obj({ type: import_zod.z.literal("NATIVE") }),
1085
+ obj({ type: import_zod.z.literal("ERC20"), address: $evmAddress })
1086
+ ])
1087
+ }),
1088
+ obj({
1089
+ kind: import_zod.z.literal("NON_FUNGIBLE"),
1090
+ contractAddress: $evmAddress,
1091
+ tokenId: import_zod.z.string().regex(/^(0|[1-9]\d*)$/, "must be a decimal integer")
1092
+ })
1093
+ ])
1094
+ });
1095
+ var $solanaDestination = obj({
1096
+ vm: import_zod.z.literal("SOLANA"),
1097
+ asset: import_zod.z.discriminatedUnion("kind", [
1098
+ obj({
1099
+ kind: import_zod.z.literal("FUNGIBLE"),
1100
+ token: import_zod.z.discriminatedUnion("type", [
1101
+ obj({ type: import_zod.z.literal("NATIVE") }),
1102
+ obj({ type: import_zod.z.literal("SPL"), mint: $solanaAddress })
1103
+ ])
1104
+ }),
1105
+ obj({ kind: import_zod.z.literal("NON_FUNGIBLE"), mint: $solanaAddress })
1064
1106
  ])
1065
1107
  });
1108
+ var $destination = import_zod.z.discriminatedUnion("vm", [$evmDestination, $solanaDestination]);
1066
1109
  var FiatDestinationSchema = $destination;
1067
1110
  var $decimalAmount = import_zod.z.string().regex(/^(?:0|[1-9]\d*)(?:\.\d+)?$/, "must be a decimal string");
1068
1111
  var compareDecimals = (left, right) => {
@@ -1100,7 +1143,7 @@ var $routingTableProvider = obj({
1100
1143
  visibility: import_zod.z.enum(["COMPLETE", "PARTIAL", "AUTH_GATED"]),
1101
1144
  currentLimit: $decimalAmount.nullable(),
1102
1145
  railAsset: $destination.optional(),
1103
- deliveryMode: import_zod.z.enum(["DIRECT", "UDA"]).optional()
1146
+ stages: import_zod.z.array($deliveryStageKind).min(1).optional()
1104
1147
  });
1105
1148
  var $routingTableInterval = obj({
1106
1149
  min: $decimalAmount,
@@ -1256,13 +1299,12 @@ var $stepResponse = import_zod.z.union([$providerBoundStepResponse, $blockedStep
1256
1299
  var FiatStepResponseSchema = $stepResponse;
1257
1300
 
1258
1301
  // package.json
1259
- var version = "0.36.0-uda.1";
1302
+ var version = "0.36.0-uda.3";
1260
1303
 
1261
1304
  // src/table.ts
1262
1305
  var TABLE_VERSION = version;
1263
1306
  var TERMINAL_ORDER_STATUSES = [
1264
1307
  "SETTLED",
1265
- "FINAL_ASSET_DELIVERED",
1266
1308
  "EXPIRED",
1267
1309
  "CANCELLED",
1268
1310
  "FAILED",
@@ -1617,7 +1659,7 @@ var TRANSITION_TABLE = {
1617
1659
  id: "poll",
1618
1660
  mode: "AWAIT",
1619
1661
  endpoint: "GET /fiat/orders/:id",
1620
- when: "status is non-terminal",
1662
+ when: "status is non-terminal, or no delivery stage is FAILED and one is PENDING",
1621
1663
  note: "Documented giveUpAfterMs 300000 \u2014 on give-up the wizard exits and the durable order takes over."
1622
1664
  },
1623
1665
  {
@@ -1648,7 +1690,7 @@ var TRANSITION_TABLE = {
1648
1690
  "A terminal status may still carry a recovery transition: FAILED + retryable failureReason emits it (FE doc Screen 14); non-retryable emits [].",
1649
1691
  "ON_HOLD is a non-terminal status (resolves to PROCESSING or REFUNDED) \u2014 and is NOT the same thing as the KYC ON_HOLD reason; see the note on that field.",
1650
1692
  "CAPTURE_ORPHANED is non-terminal pending the backend rank map (added from review 2026-08-14).",
1651
- "FINAL_ASSET_DELIVERED ends only an order whose request carried a destination. SETTLED stays in terminalStatuses for every other order, so a client that sent a destination keeps polling past SETTLED.",
1693
+ "SETTLED is terminal for the order, and marks the FIAT_PAYOUT delivery stage DONE. A later stage (CRYPTO_SWAP) may still run after SETTLED: the backend keeps offering the AWAIT poll while no stage is FAILED and one is PENDING, and the client keeps polling until every stage is DONE or one is FAILED.",
1652
1694
  "TODO(open-decision): contract OQ7 \u2014 under/over-payment is the biggest unenumerated branch."
1653
1695
  ]
1654
1696
  }
@@ -2296,6 +2338,58 @@ var FIXTURE_DATA = {
2296
2338
  "provider": "TRANSAK",
2297
2339
  "transitions": []
2298
2340
  },
2341
+ "screen-13b-order-settled-swapping": {
2342
+ "state": {
2343
+ "kind": "ORDER",
2344
+ "phase": "CREATED",
2345
+ "order": {
2346
+ "orderId": "o_31c",
2347
+ "fiat": {
2348
+ "currency": "USD",
2349
+ "amount": "50.00"
2350
+ },
2351
+ "crypto": {
2352
+ "currency": "USDC",
2353
+ "network": "base",
2354
+ "amount": "48.73"
2355
+ },
2356
+ "method": "apple_pay",
2357
+ "createdAt": "\u2026"
2358
+ },
2359
+ "status": "SETTLED",
2360
+ "tx": {
2361
+ "chainId": 8453,
2362
+ "hash": "0x\u2026"
2363
+ },
2364
+ "delivery": {
2365
+ "stages": [
2366
+ {
2367
+ "kind": "FIAT_PAYOUT",
2368
+ "state": "DONE",
2369
+ "txHash": "0x\u2026"
2370
+ },
2371
+ {
2372
+ "kind": "CRYPTO_SWAP",
2373
+ "state": "PENDING"
2374
+ }
2375
+ ]
2376
+ }
2377
+ },
2378
+ "provider": "MOONPAY",
2379
+ "transitions": [
2380
+ {
2381
+ "id": "poll",
2382
+ "mode": "AWAIT",
2383
+ "poll": {
2384
+ "endpoint": "GET /fiat/orders/o_31c",
2385
+ "intervalMs": 3e3,
2386
+ "backoffFactor": 1.5,
2387
+ "maxIntervalMs": 1e4,
2388
+ "giveUpAfterMs": 3e5
2389
+ }
2390
+ }
2391
+ ]
2392
+ },
2299
2393
  "screen-14-order-failed": {
2300
2394
  "state": {
2301
2395
  "kind": "ORDER",
@@ -2603,6 +2697,17 @@ var FIXTURES = [
2603
2697
  screen: 13,
2604
2698
  stateKey: "ORDER/CREATED"
2605
2699
  },
2700
+ {
2701
+ id: "screen-13b-order-settled-swapping",
2702
+ file: "screen-13b-order-settled-swapping.json",
2703
+ source: "CONTRACT_DOC",
2704
+ docRef: "Package README \xA7Destination \xB7 a long-tail token still swapping after SETTLED",
2705
+ screen: 13,
2706
+ stateKey: "ORDER/CREATED",
2707
+ notes: [
2708
+ 'SETTLED is terminal for the order, yet the AWAIT poll stays: CRYPTO_SWAP is PENDING, so the purchase is not done. The client shows "Buying your token" until every stage is DONE or one is FAILED.'
2709
+ ]
2710
+ },
2606
2711
  {
2607
2712
  id: "screen-14-order-failed",
2608
2713
  file: "screen-14-order-failed.json",
package/dist/index.mjs CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  tableEntry,
13
13
  unofferedEndpoints,
14
14
  unreachableStates
15
- } from "./chunk-KZZ4JA33.mjs";
15
+ } from "./chunk-ZB6TOPOA.mjs";
16
16
  import {
17
17
  MOONPAY_ENDPOINTS
18
18
  } from "./chunk-TIEGTTFY.mjs";
@@ -390,7 +390,6 @@ var $orderStatus = z.enum([
390
390
  "ON_HOLD",
391
391
  "CRYPTO_SENT",
392
392
  "SETTLED",
393
- "FINAL_ASSET_DELIVERED",
394
393
  "EXPIRED",
395
394
  "CANCELLED",
396
395
  "FAILED",
@@ -476,6 +475,16 @@ var $statusHistoryEntry = obj({ status: $orderStatus });
476
475
  var StatusHistoryEntrySchema = $statusHistoryEntry;
477
476
  var $tx = obj({ chainId: z.number(), hash: z.string() });
478
477
  var TxSchema = $tx;
478
+ var $deliveryStageKind = z.enum(["FIAT_PAYOUT", "CRYPTO_SWAP"]);
479
+ var FiatDeliveryStageKindSchema = $deliveryStageKind;
480
+ var $deliveryStage = z.discriminatedUnion("state", [
481
+ obj({ kind: $deliveryStageKind, state: z.literal("PENDING") }),
482
+ obj({ kind: $deliveryStageKind, state: z.literal("DONE"), txHash: z.string().min(1) }),
483
+ obj({ kind: $deliveryStageKind, state: z.literal("FAILED") })
484
+ ]);
485
+ var FiatDeliveryStageSchema = $deliveryStage;
486
+ var $orderDelivery = obj({ stages: z.array($deliveryStage).min(1) });
487
+ var FiatOrderDeliverySchema = $orderDelivery;
479
488
  var $refund = obj({
480
489
  currency: z.enum(FIAT_CURRENCY_CODES),
481
490
  amount: z.string(),
@@ -852,6 +861,7 @@ var $orderCreatedState = obj({
852
861
  status: $orderStatus,
853
862
  statusHistory: z.array($statusHistoryEntry).optional(),
854
863
  tx: $tx.optional(),
864
+ delivery: $orderDelivery.optional(),
855
865
  refund: $refund.optional(),
856
866
  failureReason: $failureReason.optional(),
857
867
  error: $failureReason.optional()
@@ -907,13 +917,43 @@ var $termsErrorBody = obj({
907
917
  recovery: z.enum(["RETRY", "REQUOTE", "NONE"])
908
918
  });
909
919
  var FiatTermsErrorBodySchema = $termsErrorBody;
910
- var $destination = obj({
911
- chainId: z.string().regex(/^[1-9]\d*$/, "must be a decimal chain id"),
912
- tokenAddress: z.union([
913
- z.string().regex(/^0x[0-9a-fA-F]{40}$/, "must be an EVM address"),
914
- z.string().regex(/^[1-9A-HJ-NP-Za-km-z]{32,44}$/, "must be a Solana base58 address")
920
+ var $evmAddress = z.custom(
921
+ (value) => typeof value === "string" && /^0x[0-9a-fA-F]{40}$/.test(value),
922
+ "must be an EVM address: 0x and 40 hex digits"
923
+ );
924
+ var $solanaAddress = z.string().regex(/^[1-9A-HJ-NP-Za-km-z]{32,44}$/, "must be a Solana base58 address");
925
+ var $evmDestination = obj({
926
+ vm: z.literal("EVM"),
927
+ chainId: z.number().int().positive(),
928
+ asset: z.discriminatedUnion("kind", [
929
+ obj({
930
+ kind: z.literal("FUNGIBLE"),
931
+ token: z.discriminatedUnion("type", [
932
+ obj({ type: z.literal("NATIVE") }),
933
+ obj({ type: z.literal("ERC20"), address: $evmAddress })
934
+ ])
935
+ }),
936
+ obj({
937
+ kind: z.literal("NON_FUNGIBLE"),
938
+ contractAddress: $evmAddress,
939
+ tokenId: z.string().regex(/^(0|[1-9]\d*)$/, "must be a decimal integer")
940
+ })
941
+ ])
942
+ });
943
+ var $solanaDestination = obj({
944
+ vm: z.literal("SOLANA"),
945
+ asset: z.discriminatedUnion("kind", [
946
+ obj({
947
+ kind: z.literal("FUNGIBLE"),
948
+ token: z.discriminatedUnion("type", [
949
+ obj({ type: z.literal("NATIVE") }),
950
+ obj({ type: z.literal("SPL"), mint: $solanaAddress })
951
+ ])
952
+ }),
953
+ obj({ kind: z.literal("NON_FUNGIBLE"), mint: $solanaAddress })
915
954
  ])
916
955
  });
956
+ var $destination = z.discriminatedUnion("vm", [$evmDestination, $solanaDestination]);
917
957
  var FiatDestinationSchema = $destination;
918
958
  var $decimalAmount = z.string().regex(/^(?:0|[1-9]\d*)(?:\.\d+)?$/, "must be a decimal string");
919
959
  var compareDecimals = (left, right) => {
@@ -951,7 +991,7 @@ var $routingTableProvider = obj({
951
991
  visibility: z.enum(["COMPLETE", "PARTIAL", "AUTH_GATED"]),
952
992
  currentLimit: $decimalAmount.nullable(),
953
993
  railAsset: $destination.optional(),
954
- deliveryMode: z.enum(["DIRECT", "UDA"]).optional()
994
+ stages: z.array($deliveryStageKind).min(1).optional()
955
995
  });
956
996
  var $routingTableInterval = obj({
957
997
  min: $decimalAmount,
@@ -1643,6 +1683,58 @@ var FIXTURE_DATA = {
1643
1683
  "provider": "TRANSAK",
1644
1684
  "transitions": []
1645
1685
  },
1686
+ "screen-13b-order-settled-swapping": {
1687
+ "state": {
1688
+ "kind": "ORDER",
1689
+ "phase": "CREATED",
1690
+ "order": {
1691
+ "orderId": "o_31c",
1692
+ "fiat": {
1693
+ "currency": "USD",
1694
+ "amount": "50.00"
1695
+ },
1696
+ "crypto": {
1697
+ "currency": "USDC",
1698
+ "network": "base",
1699
+ "amount": "48.73"
1700
+ },
1701
+ "method": "apple_pay",
1702
+ "createdAt": "\u2026"
1703
+ },
1704
+ "status": "SETTLED",
1705
+ "tx": {
1706
+ "chainId": 8453,
1707
+ "hash": "0x\u2026"
1708
+ },
1709
+ "delivery": {
1710
+ "stages": [
1711
+ {
1712
+ "kind": "FIAT_PAYOUT",
1713
+ "state": "DONE",
1714
+ "txHash": "0x\u2026"
1715
+ },
1716
+ {
1717
+ "kind": "CRYPTO_SWAP",
1718
+ "state": "PENDING"
1719
+ }
1720
+ ]
1721
+ }
1722
+ },
1723
+ "provider": "MOONPAY",
1724
+ "transitions": [
1725
+ {
1726
+ "id": "poll",
1727
+ "mode": "AWAIT",
1728
+ "poll": {
1729
+ "endpoint": "GET /fiat/orders/o_31c",
1730
+ "intervalMs": 3e3,
1731
+ "backoffFactor": 1.5,
1732
+ "maxIntervalMs": 1e4,
1733
+ "giveUpAfterMs": 3e5
1734
+ }
1735
+ }
1736
+ ]
1737
+ },
1646
1738
  "screen-14-order-failed": {
1647
1739
  "state": {
1648
1740
  "kind": "ORDER",
@@ -1950,6 +2042,17 @@ var FIXTURES = [
1950
2042
  screen: 13,
1951
2043
  stateKey: "ORDER/CREATED"
1952
2044
  },
2045
+ {
2046
+ id: "screen-13b-order-settled-swapping",
2047
+ file: "screen-13b-order-settled-swapping.json",
2048
+ source: "CONTRACT_DOC",
2049
+ docRef: "Package README \xA7Destination \xB7 a long-tail token still swapping after SETTLED",
2050
+ screen: 13,
2051
+ stateKey: "ORDER/CREATED",
2052
+ notes: [
2053
+ 'SETTLED is terminal for the order, yet the AWAIT poll stays: CRYPTO_SWAP is PENDING, so the purchase is not done. The client shows "Buying your token" until every stage is DONE or one is FAILED.'
2054
+ ]
2055
+ },
1953
2056
  {
1954
2057
  id: "screen-14-order-failed",
1955
2058
  file: "screen-14-order-failed.json",
@@ -2391,10 +2494,13 @@ export {
2391
2494
  FeeLineSchema,
2392
2495
  FiatAmountSchema,
2393
2496
  FiatCurrencyCode,
2497
+ FiatDeliveryStageKindSchema,
2498
+ FiatDeliveryStageSchema,
2394
2499
  FiatDestinationSchema,
2395
2500
  FiatEndpointSchema,
2396
2501
  FiatGeoSchema,
2397
2502
  FiatNextRequestSchema,
2503
+ FiatOrderDeliverySchema,
2398
2504
  FiatProviderSchema,
2399
2505
  FiatRoutingQuoteErrorBodySchema,
2400
2506
  FiatRoutingQuoteRequestSchema,
@@ -43,7 +43,8 @@ export interface MoonPaySdkCredentials {
43
43
  }
44
44
  /**
45
45
  * On every request, not part of the result. `credentials` is present after `connect`.
46
- * `destination` is the asset the user receives at the end; `checkout.destination` stays the quote's.
46
+ * `destination` is the asset the user receives at the end; `checkout.destination` stays the asset
47
+ * MoonPay delivers (the row's `railAsset`).
47
48
  */
48
49
  export type MoonPayRequestContext = {
49
50
  checkout: MoonPayCheckout;
@@ -250,7 +251,10 @@ export type MoonPayStepRefusal = 'NOT_ELIGIBLE' | 'DOCUMENTS_REQUIRED' | 'FINAL_
250
251
  */
251
252
  export type MoonPayOrderRefusal = 'CUSTOMER_MISMATCH' | 'WALLET_MISMATCH' | 'UNRECORDABLE';
252
253
  export type MoonPayNextAction = MoonPayConsentNextAction | MoonPaySessionNextAction | MoonPayConnectNextAction | MoonPayKycNextAction | MoonPayPrepareCaptureNextAction | MoonPayCaptureNextAction | MoonPayWaitNextAction | MoonPayOrderNextAction;
253
- /** The order is terminal. `order` is its body, which the shared order screen renders; nothing is left to poll. */
254
+ /**
255
+ * The order is terminal. `order` is its body, which the shared order screen renders. Nothing is left to
256
+ * send to `/fiat/next`; while a `delivery` stage is `PENDING`, the body keeps its `GET /fiat/orders/:id` poll.
257
+ */
254
258
  export type MoonPayDone = {
255
259
  next: 'done';
256
260
  order: FiatStepResponse;
package/dist/routing.d.ts CHANGED
@@ -21,7 +21,7 @@
21
21
  * an extra key or a blank string fails them, so send only the declared fields.
22
22
  */
23
23
  import type { CountryCode, FiatCurrencyCode, PaymentMethodCategory } from './codes';
24
- import type { FiatAmount, FiatDestination, FiatProvider, QuoteLimitRange } from './types';
24
+ import type { FiatAmount, FiatDeliveryStageKind, FiatDestination, FiatProvider, QuoteLimitRange } from './types';
25
25
  export declare const ROUTING_ENDPOINTS: {
26
26
  readonly table: "POST /fiat/routing/table";
27
27
  /** Temporary: `POST /fiat/next` replaces it for each provider that moves there. */
@@ -55,7 +55,10 @@ export interface FiatRoutingTableRequest {
55
55
  methods: PaymentMethodCategory[];
56
56
  /** Optional provider-specific inputs. */
57
57
  providers?: FiatRoutingTableProviderInputs;
58
- /** The asset the user receives, when it differs from `cryptoCurrencyCode` on `chainId`. */
58
+ /**
59
+ * The asset the user receives. Always sent; the backend adds a conversion only when it differs
60
+ * from the partner's configured asset. Optional so an older client still parses.
61
+ */
59
62
  destination?: FiatDestination;
60
63
  }
61
64
  /** What a provider needs from this buyer before it can take the payment. */
@@ -81,25 +84,19 @@ export interface RoutingTableProvider {
81
84
  */
82
85
  currentLimit: string | null;
83
86
  /**
84
- * The asset this provider delivers on the order: the request's `cryptoCurrencyCode` on `chainId`,
85
- * or, when the request names a `destination`, the asset the backend chose to buy for it. Quote this
86
- * asset. Absent from a backend that predates it.
87
+ * The asset this provider delivers on the order: the partner's configured asset on the
88
+ * destination's chain, else its first configured asset. Quote this asset, not the destination.
89
+ * Absent from a backend that predates it.
87
90
  */
88
- railAsset?: RoutingTableRailAsset;
89
- /** How the order reaches the user. Absent from a backend that predates it. */
90
- deliveryMode?: RoutingDeliveryMode;
91
- }
92
- /** An asset by chain and token address, in `FiatDestination`'s format. */
93
- export interface RoutingTableRailAsset {
94
- chainId: string;
95
- tokenAddress: string;
91
+ railAsset?: FiatDestination;
92
+ /**
93
+ * The delivery stages an order through this provider will run, in order: `[FIAT_PAYOUT]` when the
94
+ * provider pays the user's wallet, `[FIAT_PAYOUT, CRYPTO_SWAP]` when it pays a deposit address that
95
+ * swaps `railAsset` into the destination. The order's `delivery.stages` reports the same kinds.
96
+ * Absent from a backend that predates it.
97
+ */
98
+ stages?: FiatDeliveryStageKind[];
96
99
  }
97
- /**
98
- * `DIRECT`: the provider pays `railAsset` to the user's wallet, so the purchase is done when it
99
- * settles. `UDA`: the provider pays a deposit address that swaps `railAsset` into the request's
100
- * `destination`, so the purchase is done only at `FINAL_ASSET_DELIVERED`.
101
- */
102
- export type RoutingDeliveryMode = 'DIRECT' | 'UDA';
103
100
  /**
104
101
  * A `QuoteLimitRange` with two decimals (`"20.00"`) and the providers that serve it. The next
105
102
  * interval starts one cent above `max`. Adjacent intervals always rank differently.
@@ -148,7 +145,10 @@ export interface FiatRoutingQuoteTerms {
148
145
  routingOverrides?: {
149
146
  providers: RoutingProvider[];
150
147
  };
151
- /** The asset the user receives, when it differs from `cryptoCurrencyCode` on `chainId`. */
148
+ /**
149
+ * The asset the user receives. Always sent; the backend adds a conversion only when it differs
150
+ * from the partner's configured asset. Optional so an older client still parses.
151
+ */
152
152
  destination?: FiatDestination;
153
153
  }
154
154
  /**
package/dist/schemas.d.ts CHANGED
@@ -28,7 +28,7 @@
28
28
  */
29
29
  import { z } from 'zod';
30
30
  import type { UsStateCode } from './codes';
31
- import type { BlockedReason, CryptoAmount, FailureReason, FeeLine, FiatAmount, FiatEndpoint, FiatProvider, FiatStepResponse, FieldSpec, FlowState, FormDescriptor, FormField, FormFieldType, InstructionField, Instructions, Instrument, JsonValue, KYCProvider, KycReviewDuration, OrderRef, OrderStatus, OrderSummary, PollSpec, PreparedPayment, PaymentSurface, Quote, QuoteLimitRange, QuoteLimits, Recovery, Refund, ReportSpec, SelectOption, StatusHistoryEntry, Surface, PreferredIdentityDocument, KycFieldId, ClientExecutedDelivery, KycSdkResultReport, SurfaceKind, SurfaceProvider, TermsAcceptance, Transition, TransitionInputs, TransitionParams, Tx, FiatDestination, FiatGeo, FiatNextRequest } from './types';
31
+ import type { BlockedReason, CryptoAmount, FailureReason, FeeLine, FiatAmount, FiatEndpoint, FiatProvider, FiatStepResponse, FieldSpec, FlowState, FormDescriptor, FormField, FormFieldType, InstructionField, Instructions, Instrument, JsonValue, KYCProvider, KycReviewDuration, OrderRef, OrderStatus, OrderSummary, PollSpec, PreparedPayment, PaymentSurface, Quote, QuoteLimitRange, QuoteLimits, Recovery, Refund, ReportSpec, SelectOption, StatusHistoryEntry, Surface, PreferredIdentityDocument, KycFieldId, ClientExecutedDelivery, KycSdkResultReport, SurfaceKind, SurfaceProvider, TermsAcceptance, Transition, TransitionInputs, TransitionParams, Tx, FiatDeliveryStage, FiatDeliveryStageKind, FiatDestination, FiatGeo, FiatOrderDelivery, FiatNextRequest } from './types';
32
32
  import type { FiatTermsErrorBody, FiatTermsRequest, FiatTermsResponse, TermsDocument, TermsDocumentAcceptance } from './terms';
33
33
  import type { FiatRoutingQuoteErrorBody, FiatRoutingQuoteRequest, FiatRoutingQuoteTerms, FiatRoutingTableErrorBody, FiatRoutingTableRequest, FiatRoutingTableResponse } from './routing';
34
34
  export declare const JsonSchema: z.ZodType<JsonValue>;
@@ -54,6 +54,9 @@ export declare const OrderRefSchema: z.ZodType<OrderRef>;
54
54
  export declare const OrderSummarySchema: z.ZodType<OrderSummary>;
55
55
  export declare const StatusHistoryEntrySchema: z.ZodType<StatusHistoryEntry>;
56
56
  export declare const TxSchema: z.ZodType<Tx>;
57
+ export declare const FiatDeliveryStageKindSchema: z.ZodType<FiatDeliveryStageKind>;
58
+ export declare const FiatDeliveryStageSchema: z.ZodType<FiatDeliveryStage>;
59
+ export declare const FiatOrderDeliverySchema: z.ZodType<FiatOrderDelivery>;
57
60
  export declare const RefundSchema: z.ZodType<Refund>;
58
61
  export declare const SurfaceKindSchema: z.ZodType<SurfaceKind>;
59
62
  export declare const PreferredIdentityDocumentSchema: z.ZodType<PreferredIdentityDocument>;
package/dist/table.d.ts CHANGED
@@ -39,7 +39,7 @@ export type StateKey = 'QUOTE' | 'FUN_AUTH' | 'SESSION_AUTH' | 'KYC/CAPTURE' | '
39
39
  * is over stops polling and the order silently strands, whereas one that keeps polling lets the
40
40
  * reconciler resolve it. Revisit when the backend publishes its rank map.
41
41
  */
42
- export declare const TERMINAL_ORDER_STATUSES: readonly ["SETTLED", "FINAL_ASSET_DELIVERED", "EXPIRED", "CANCELLED", "FAILED", "REFUNDED"];
42
+ export declare const TERMINAL_ORDER_STATUSES: readonly ["SETTLED", "EXPIRED", "CANCELLED", "FAILED", "REFUNDED"];
43
43
  export type TerminalOrderStatus = (typeof TERMINAL_ORDER_STATUSES)[number];
44
44
  /**
45
45
  * Endpoint template as written in the docs. Named `:` segments match one emitted path segment.
package/dist/table.js CHANGED
@@ -36,13 +36,12 @@ __export(table_exports, {
36
36
  module.exports = __toCommonJS(table_exports);
37
37
 
38
38
  // package.json
39
- var version = "0.36.0-uda.1";
39
+ var version = "0.36.0-uda.3";
40
40
 
41
41
  // src/table.ts
42
42
  var TABLE_VERSION = version;
43
43
  var TERMINAL_ORDER_STATUSES = [
44
44
  "SETTLED",
45
- "FINAL_ASSET_DELIVERED",
46
45
  "EXPIRED",
47
46
  "CANCELLED",
48
47
  "FAILED",
@@ -397,7 +396,7 @@ var TRANSITION_TABLE = {
397
396
  id: "poll",
398
397
  mode: "AWAIT",
399
398
  endpoint: "GET /fiat/orders/:id",
400
- when: "status is non-terminal",
399
+ when: "status is non-terminal, or no delivery stage is FAILED and one is PENDING",
401
400
  note: "Documented giveUpAfterMs 300000 \u2014 on give-up the wizard exits and the durable order takes over."
402
401
  },
403
402
  {
@@ -428,7 +427,7 @@ var TRANSITION_TABLE = {
428
427
  "A terminal status may still carry a recovery transition: FAILED + retryable failureReason emits it (FE doc Screen 14); non-retryable emits [].",
429
428
  "ON_HOLD is a non-terminal status (resolves to PROCESSING or REFUNDED) \u2014 and is NOT the same thing as the KYC ON_HOLD reason; see the note on that field.",
430
429
  "CAPTURE_ORPHANED is non-terminal pending the backend rank map (added from review 2026-08-14).",
431
- "FINAL_ASSET_DELIVERED ends only an order whose request carried a destination. SETTLED stays in terminalStatuses for every other order, so a client that sent a destination keeps polling past SETTLED.",
430
+ "SETTLED is terminal for the order, and marks the FIAT_PAYOUT delivery stage DONE. A later stage (CRYPTO_SWAP) may still run after SETTLED: the backend keeps offering the AWAIT poll while no stage is FAILED and one is PENDING, and the client keeps polling until every stage is DONE or one is FAILED.",
432
431
  "TODO(open-decision): contract OQ7 \u2014 under/over-payment is the biggest unenumerated branch."
433
432
  ]
434
433
  }
package/dist/table.mjs CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  tableEntry,
12
12
  unofferedEndpoints,
13
13
  unreachableStates
14
- } from "./chunk-KZZ4JA33.mjs";
14
+ } from "./chunk-ZB6TOPOA.mjs";
15
15
  export {
16
16
  DOCUMENTED_ENDPOINTS,
17
17
  STATE_KEYS,
package/dist/types.d.ts CHANGED
@@ -76,15 +76,11 @@ export type FiatProvider = 'TRANSAK' | 'SWAPPED' | 'BANXA' | 'MOONPAY' | 'STRIPE
76
76
  */
77
77
  export type OrderStatus = 'CREATING' | 'AWAITING_PAYMENT' | 'PAYMENT_VERIFYING' | 'PROCESSING' | 'PENDING_DELIVERY' | 'ON_HOLD' | 'CRYPTO_SENT'
78
78
  /**
79
- * The provider's crypto reached the deposit address. Final for an order whose request carried no
80
- * `destination`. With a `destination`, the swap into it is still running.
79
+ * The provider's crypto reached the deposit address. Terminal for the order. When the order's
80
+ * `delivery` has a stage after `FIAT_PAYOUT`, that stage may still be running: read
81
+ * `delivery.stages`.
81
82
  */
82
- | 'SETTLED'
83
- /**
84
- * The destination asset reached the user's wallet. Only an order whose request carried a
85
- * `destination` shows it; every other order ends at `SETTLED`, as before.
86
- */
87
- | 'FINAL_ASSET_DELIVERED' | 'EXPIRED' | 'CANCELLED' | 'FAILED' | 'REFUNDED'
83
+ | 'SETTLED' | 'EXPIRED' | 'CANCELLED' | 'FAILED' | 'REFUNDED'
88
84
  /**
89
85
  * A capture that never became an order — the pull-rail orphan (contract Flow A's
90
86
  * capture-then-order topology: the component yields a `requestId`, then `createOrder` runs).
@@ -683,6 +679,8 @@ export type FlowState =
683
679
  status: OrderStatus;
684
680
  statusHistory?: StatusHistoryEntry[];
685
681
  tx?: Tx;
682
+ /** The stages that bring the asset to the user. Absent from a backend that predates it. */
683
+ delivery?: FiatOrderDelivery;
686
684
  refund?: Refund;
687
685
  failureReason?: FailureReason;
688
686
  error?: FailureReason;
@@ -752,17 +750,79 @@ export type FiatStepResponse = (FiatStepResponseBase & {
752
750
  };
753
751
  });
754
752
  /**
755
- * The asset the user receives at the end of the purchase. Optional on every request that can lead
756
- * the backend to pick a deposit address. When it differs from the asset the provider delivers, the
757
- * backend pays a deposit address that swaps into it. The recipient always comes from the verified
758
- * partner assertion, never from this field.
753
+ * The asset the user receives at the end of the purchase. The client always sends it. The backend
754
+ * compares it with the partner's configured asset and adds a conversion stage only when they differ,
755
+ * so its presence never turns a conversion on. The fields that carry it are optional only so a client
756
+ * that predates it still parses; a missing destination means the partner's configured asset. The
757
+ * recipient always comes from the verified partner assertion, never from this field.
758
+ *
759
+ * Split by VM, then by asset kind. Solana carries no chain id: the backend maps each VM to its own
760
+ * chain ids in one place. `NON_FUNGIBLE` is reserved: the backend does not serve it yet and answers
761
+ * it as unservable.
759
762
  */
760
- export interface FiatDestination {
761
- /** Decimal, as the routing requests send it: `"8453"`, Solana `"1151111081099710"`. */
762
- chainId: string;
763
- /** An EVM `0x` address (40 hex digits) or a Solana base58 mint. */
764
- tokenAddress: string;
765
- }
763
+ export type FiatDestination = {
764
+ vm: 'EVM';
765
+ /** The EVM chain id: `8453` for Base. */
766
+ chainId: number;
767
+ asset: {
768
+ kind: 'FUNGIBLE';
769
+ token: {
770
+ type: 'NATIVE';
771
+ } | {
772
+ type: 'ERC20';
773
+ address: `0x${string}`;
774
+ };
775
+ } | {
776
+ kind: 'NON_FUNGIBLE';
777
+ contractAddress: `0x${string}`;
778
+ /** A decimal integer string, so a uint256 id keeps its precision. */
779
+ tokenId: string;
780
+ };
781
+ } | {
782
+ vm: 'SOLANA';
783
+ /** Every `mint` is a base58 address. */
784
+ asset: {
785
+ kind: 'FUNGIBLE';
786
+ token: {
787
+ type: 'NATIVE';
788
+ } | {
789
+ type: 'SPL';
790
+ mint: string;
791
+ };
792
+ } | {
793
+ kind: 'NON_FUNGIBLE';
794
+ mint: string;
795
+ };
796
+ };
797
+ /**
798
+ * One step that moves value toward the user. `FIAT_PAYOUT`: the fiat provider pays an address (the
799
+ * user's wallet, or a deposit address that a later stage spends). `CRYPTO_SWAP`: a crypto asset
800
+ * provider converts what it received and pays the user the destination asset.
801
+ */
802
+ export type FiatDeliveryStageKind = 'FIAT_PAYOUT' | 'CRYPTO_SWAP';
803
+ /** A stage's progress. `txHash` is the transaction that finished the stage, present only once it is `DONE`. */
804
+ export type FiatDeliveryStage = {
805
+ kind: FiatDeliveryStageKind;
806
+ state: 'PENDING';
807
+ } | {
808
+ kind: FiatDeliveryStageKind;
809
+ state: 'DONE';
810
+ txHash: string;
811
+ } | {
812
+ kind: FiatDeliveryStageKind;
813
+ state: 'FAILED';
814
+ };
815
+ export type FiatDeliveryStageState = FiatDeliveryStage['state'];
816
+ /**
817
+ * How the order reaches the user, as stages in the order they run: `[FIAT_PAYOUT]` when the provider
818
+ * pays the user's wallet, `[FIAT_PAYOUT, CRYPTO_SWAP]` when it pays a deposit address that swaps into
819
+ * the destination. The purchase is done when every stage is `DONE`, and has failed when any stage is
820
+ * `FAILED`. `FIAT_PAYOUT` follows the order status (`SETTLED` is `DONE`, carrying the settlement
821
+ * transaction).
822
+ */
823
+ export type FiatOrderDelivery = {
824
+ stages: FiatDeliveryStage[];
825
+ };
766
826
  /** The geo endpoint's response, sent on every `/next` request. `alpha2` is ISO 3166-1 alpha-2. */
767
827
  export type FiatGeo = {
768
828
  alpha2: string;
@@ -770,7 +830,7 @@ export type FiatGeo = {
770
830
  ip?: string;
771
831
  };
772
832
  /**
773
- * The body of every `POST /fiat/next`: `provider`, `geo`, the optional `destination`, and the
833
+ * The body of every `POST /fiat/next`: `provider`, `geo`, the `destination`, and the
774
834
  * provider's own request, which names its `action`. Each provider defines its actions and their
775
835
  * fields (`./moonpay`).
776
836
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fun-xyz/fiat-contract",
3
- "version": "0.36.0-uda.1",
3
+ "version": "0.36.0-uda.3",
4
4
  "description": "Published conformance contract for Fun's headless fiat onramp: FlowState/Transition types, zod schemas, the transition table as data, recorded fixtures, assertion helpers.",
5
5
  "license": "MIT",
6
6
  "repository": {