@fun-xyz/fiat-contract 0.36.0-uda.3 → 0.36.0-uda.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.
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "0.36.0-uda.3";
2
+ var version = "0.36.0-uda.5";
3
3
 
4
4
  // src/table.ts
5
5
  var TABLE_VERSION = version;
@@ -359,9 +359,16 @@ var TRANSITION_TABLE = {
359
359
  id: "poll",
360
360
  mode: "AWAIT",
361
361
  endpoint: "GET /fiat/orders/:id",
362
- when: "status is non-terminal, or no delivery stage is FAILED and one is PENDING",
362
+ when: "status is non-terminal",
363
363
  note: "Documented giveUpAfterMs 300000 \u2014 on give-up the wizard exits and the durable order takes over."
364
364
  },
365
+ {
366
+ id: "delivery",
367
+ mode: "AWAIT",
368
+ endpoint: "GET /fiat/orders/:id/delivery",
369
+ when: "status is SETTLED and the order is converted: the provider paid a deposit address that converts into the destinationAsset",
370
+ note: "The backend decides; the client never infers a converted order. It follows this transition when offered, and otherwise treats SETTLED as done."
371
+ },
365
372
  {
366
373
  id: "retry_payment",
367
374
  mode: "SUBMIT",
@@ -382,7 +389,7 @@ var TRANSITION_TABLE = {
382
389
  note: "TODO(open-decision): cancel placement (FE doc open questions 1+2); per-rail eligibility is contract OQ7."
383
390
  }
384
391
  ],
385
- mayReturn: ["ORDER/CREATED"],
392
+ mayReturn: ["ORDER/CREATED", "DELIVERY:PENDING", "DELIVERY:SUCCEEDED", "DELIVERY:FAILED"],
386
393
  terminal: false,
387
394
  terminalStatuses: TERMINAL_ORDER_STATUSES,
388
395
  notes: [
@@ -390,9 +397,53 @@ var TRANSITION_TABLE = {
390
397
  "A terminal status may still carry a recovery transition: FAILED + retryable failureReason emits it (FE doc Screen 14); non-retryable emits [].",
391
398
  "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.",
392
399
  "CAPTURE_ORPHANED is non-terminal pending the backend rank map (added from review 2026-08-14).",
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.",
400
+ "SETTLED is terminal for the order and ends a direct purchase. On a converted order it carries the delivery transition, and the purchase continues in DELIVERY (GET /fiat/orders/:id/delivery). The order body itself never describes the conversion.",
394
401
  "TODO(open-decision): contract OQ7 \u2014 under/over-payment is the biggest unenumerated branch."
395
402
  ]
403
+ },
404
+ "DELIVERY:PENDING": {
405
+ key: "DELIVERY:PENDING",
406
+ kind: "DELIVERY",
407
+ state: "PENDING",
408
+ screens: [7],
409
+ docStatus: "SPECIFIED",
410
+ allowedTransitions: [
411
+ {
412
+ id: "poll",
413
+ mode: "AWAIT",
414
+ endpoint: "GET /fiat/orders/:id/delivery",
415
+ note: "Giving up the poll does not fail the purchase: the backend still finishes the delivery or raises it to support."
416
+ }
417
+ ],
418
+ mayReturn: ["DELIVERY:PENDING", "DELIVERY:SUCCEEDED", "DELIVERY:FAILED"],
419
+ terminal: false,
420
+ notes: [
421
+ "The fiat leg is SETTLED; a crypto asset provider is converting it into the destinationAsset and paying the user. The client shows a generic processing screen."
422
+ ]
423
+ },
424
+ "DELIVERY:SUCCEEDED": {
425
+ key: "DELIVERY:SUCCEEDED",
426
+ kind: "DELIVERY",
427
+ state: "SUCCEEDED",
428
+ screens: [13],
429
+ docStatus: "SPECIFIED",
430
+ allowedTransitions: [],
431
+ mayReturn: [],
432
+ terminal: true,
433
+ notes: ["The destinationAsset reached the user. txHash is the transaction that paid them."]
434
+ },
435
+ "DELIVERY:FAILED": {
436
+ key: "DELIVERY:FAILED",
437
+ kind: "DELIVERY",
438
+ state: "FAILED",
439
+ screens: [],
440
+ docStatus: "SPECIFIED",
441
+ allowedTransitions: [],
442
+ mayReturn: [],
443
+ terminal: true,
444
+ notes: [
445
+ "The buyer has paid and the asset did not arrive. Support recovers the funds, so the client shows a dedicated failure screen that offers no new payment."
446
+ ]
396
447
  }
397
448
  };
398
449
  var STATE_KEYS = Object.keys(TRANSITION_TABLE);
@@ -411,6 +462,7 @@ var DOCUMENTED_ENDPOINTS = [
411
462
  "POST /fiat/instruments",
412
463
  "POST /fiat/orders",
413
464
  "GET /fiat/orders/:id",
465
+ "GET /fiat/orders/:id/delivery",
414
466
  "GET /fiat/orders/:id/instructions",
415
467
  "POST /fiat/orders/:id/confirm-payment",
416
468
  "POST /fiat/orders/:id/reference",
@@ -486,6 +538,8 @@ function stateKey(state) {
486
538
  return state.phase === "CAPTURE" ? "PAYMENT/CAPTURE" : "PAYMENT/INSTRUCT";
487
539
  case "ORDER":
488
540
  return state.phase === "AWAITING_CONFIRMATION" ? "ORDER/AWAITING_CONFIRMATION" : "ORDER/CREATED";
541
+ case "DELIVERY":
542
+ return `DELIVERY:${state.state}`;
489
543
  default: {
490
544
  const exhaustive = state;
491
545
  throw new Error(`unknown FlowState: ${JSON.stringify(exhaustive)}`);
package/dist/index.js CHANGED
@@ -30,6 +30,8 @@ __export(index_exports, {
30
30
  CountryCode: () => CountryCode,
31
31
  CryptoAmountSchema: () => CryptoAmountSchema,
32
32
  DOCUMENTED_ENDPOINTS: () => DOCUMENTED_ENDPOINTS,
33
+ DeliveryStateSchema: () => DeliveryStateSchema,
34
+ DestinationAssetSchema: () => DestinationAssetSchema,
33
35
  ENDPOINT_PATTERN: () => ENDPOINT_PATTERN,
34
36
  FIAT_CURRENCY_NAMES: () => FIAT_CURRENCY_NAMES,
35
37
  FIAT_TERMS_ENDPOINT: () => FIAT_TERMS_ENDPOINT,
@@ -41,13 +43,9 @@ __export(index_exports, {
41
43
  FeeLineSchema: () => FeeLineSchema,
42
44
  FiatAmountSchema: () => FiatAmountSchema,
43
45
  FiatCurrencyCode: () => FiatCurrencyCode,
44
- FiatDeliveryStageKindSchema: () => FiatDeliveryStageKindSchema,
45
- FiatDeliveryStageSchema: () => FiatDeliveryStageSchema,
46
- FiatDestinationSchema: () => FiatDestinationSchema,
47
46
  FiatEndpointSchema: () => FiatEndpointSchema,
48
47
  FiatGeoSchema: () => FiatGeoSchema,
49
48
  FiatNextRequestSchema: () => FiatNextRequestSchema,
50
- FiatOrderDeliverySchema: () => FiatOrderDeliverySchema,
51
49
  FiatProviderSchema: () => FiatProviderSchema,
52
50
  FiatRoutingQuoteErrorBodySchema: () => FiatRoutingQuoteErrorBodySchema,
53
51
  FiatRoutingQuoteRequestSchema: () => FiatRoutingQuoteRequestSchema,
@@ -627,16 +625,6 @@ var $statusHistoryEntry = obj({ status: $orderStatus });
627
625
  var StatusHistoryEntrySchema = $statusHistoryEntry;
628
626
  var $tx = obj({ chainId: import_zod.z.number(), hash: import_zod.z.string() });
629
627
  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;
640
628
  var $refund = obj({
641
629
  currency: import_zod.z.enum(FIAT_CURRENCY_CODES),
642
630
  amount: import_zod.z.string(),
@@ -1013,12 +1001,17 @@ var $orderCreatedState = obj({
1013
1001
  status: $orderStatus,
1014
1002
  statusHistory: import_zod.z.array($statusHistoryEntry).optional(),
1015
1003
  tx: $tx.optional(),
1016
- delivery: $orderDelivery.optional(),
1017
1004
  refund: $refund.optional(),
1018
1005
  failureReason: $failureReason.optional(),
1019
1006
  error: $failureReason.optional()
1020
1007
  });
1021
1008
  var OrderCreatedStateSchema = $orderCreatedState;
1009
+ var $deliveryState = import_zod.z.discriminatedUnion("state", [
1010
+ obj({ kind: import_zod.z.literal("DELIVERY"), state: import_zod.z.literal("PENDING") }),
1011
+ obj({ kind: import_zod.z.literal("DELIVERY"), state: import_zod.z.literal("SUCCEEDED"), txHash: import_zod.z.string().min(1) }),
1012
+ obj({ kind: import_zod.z.literal("DELIVERY"), state: import_zod.z.literal("FAILED") })
1013
+ ]);
1014
+ var DeliveryStateSchema = $deliveryState;
1022
1015
  var $providerBoundFlowState = import_zod.z.union([
1023
1016
  $quoteState,
1024
1017
  $funAuthState,
@@ -1030,7 +1023,8 @@ var $providerBoundFlowState = import_zod.z.union([
1030
1023
  $paymentCaptureState,
1031
1024
  $paymentInstructState,
1032
1025
  $orderAwaitingConfirmationState,
1033
- $orderCreatedState
1026
+ $orderCreatedState,
1027
+ $deliveryState
1034
1028
  ]);
1035
1029
  var $flowState = import_zod.z.union([$providerBoundFlowState, $blockedState]);
1036
1030
  var FlowStateSchema = $flowState;
@@ -1074,7 +1068,7 @@ var $evmAddress = import_zod.z.custom(
1074
1068
  "must be an EVM address: 0x and 40 hex digits"
1075
1069
  );
1076
1070
  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({
1071
+ var $evmDestinationAsset = obj({
1078
1072
  vm: import_zod.z.literal("EVM"),
1079
1073
  chainId: import_zod.z.number().int().positive(),
1080
1074
  asset: import_zod.z.discriminatedUnion("kind", [
@@ -1092,7 +1086,7 @@ var $evmDestination = obj({
1092
1086
  })
1093
1087
  ])
1094
1088
  });
1095
- var $solanaDestination = obj({
1089
+ var $solanaDestinationAsset = obj({
1096
1090
  vm: import_zod.z.literal("SOLANA"),
1097
1091
  asset: import_zod.z.discriminatedUnion("kind", [
1098
1092
  obj({
@@ -1105,8 +1099,8 @@ var $solanaDestination = obj({
1105
1099
  obj({ kind: import_zod.z.literal("NON_FUNGIBLE"), mint: $solanaAddress })
1106
1100
  ])
1107
1101
  });
1108
- var $destination = import_zod.z.discriminatedUnion("vm", [$evmDestination, $solanaDestination]);
1109
- var FiatDestinationSchema = $destination;
1102
+ var $destinationAsset = import_zod.z.discriminatedUnion("vm", [$evmDestinationAsset, $solanaDestinationAsset]);
1103
+ var DestinationAssetSchema = $destinationAsset;
1110
1104
  var $decimalAmount = import_zod.z.string().regex(/^(?:0|[1-9]\d*)(?:\.\d+)?$/, "must be a decimal string");
1111
1105
  var compareDecimals = (left, right) => {
1112
1106
  const [leftWhole = "", leftFraction = ""] = left.split(".");
@@ -1134,16 +1128,14 @@ var $routingTableRequest = obj({
1134
1128
  // Duplicates are allowed; the response lists each method once.
1135
1129
  methods: import_zod.z.array(import_zod.z.enum(PAYMENT_METHOD_CATEGORIES)).min(1),
1136
1130
  providers: $routingTableProviderInputs.optional(),
1137
- destination: $destination.optional()
1131
+ destinationAsset: $destinationAsset.optional()
1138
1132
  }).refine((request) => hasUsRegion(request.country, request.region), { message: US_REGION_REQUIRED, path: ["region"] });
1139
1133
  var FiatRoutingTableRequestSchema = $routingTableRequest;
1140
1134
  var $routingTableProvider = obj({
1141
1135
  provider: $routingProvider,
1142
1136
  next: import_zod.z.enum(["READY", "AUTH", "DECLARATIVE_KYC", "DOCUMENTARY_KYC", "PENDING_REVIEW"]),
1143
1137
  visibility: import_zod.z.enum(["COMPLETE", "PARTIAL", "AUTH_GATED"]),
1144
- currentLimit: $decimalAmount.nullable(),
1145
- railAsset: $destination.optional(),
1146
- stages: import_zod.z.array($deliveryStageKind).min(1).optional()
1138
+ currentLimit: $decimalAmount.nullable()
1147
1139
  });
1148
1140
  var $routingTableInterval = obj({
1149
1141
  min: $decimalAmount,
@@ -1182,7 +1174,7 @@ var $routingQuoteTermsShape = {
1182
1174
  ),
1183
1175
  prepareSessionAuth: import_zod.z.boolean().optional(),
1184
1176
  routingOverrides: obj({ providers: import_zod.z.array($routingProvider) }).optional(),
1185
- destination: $destination.optional()
1177
+ destinationAsset: $destinationAsset.optional()
1186
1178
  };
1187
1179
  var $routingQuoteTerms = obj($routingQuoteTermsShape);
1188
1180
  var FiatRoutingQuoteTermsSchema = $routingQuoteTerms;
@@ -1238,7 +1230,7 @@ var $routingQuoteErrorBody = import_zod.z.union([$routingNoRouteErrorBody, $rout
1238
1230
  var FiatRoutingQuoteErrorBodySchema = $routingQuoteErrorBody;
1239
1231
  var $fiatGeo = obj({ alpha2: import_zod.z.string().regex(/^[A-Z]{2}$/), region: $nonBlank.optional(), ip: $nonBlank.optional() });
1240
1232
  var FiatGeoSchema = $fiatGeo;
1241
- var $nextRequest = import_zod.z.object({ provider: $provider, action: $nonBlank, geo: $fiatGeo, destination: $destination.optional() }).catchall(import_zod.z.unknown());
1233
+ var $nextRequest = import_zod.z.object({ provider: $provider, action: $nonBlank, geo: $fiatGeo, destinationAsset: $destinationAsset.optional() }).catchall(import_zod.z.unknown());
1242
1234
  var FiatNextRequestSchema = $nextRequest;
1243
1235
  var $providerBoundStepResponse = obj({
1244
1236
  state: $providerBoundFlowState,
@@ -1299,7 +1291,7 @@ var $stepResponse = import_zod.z.union([$providerBoundStepResponse, $blockedStep
1299
1291
  var FiatStepResponseSchema = $stepResponse;
1300
1292
 
1301
1293
  // package.json
1302
- var version = "0.36.0-uda.3";
1294
+ var version = "0.36.0-uda.5";
1303
1295
 
1304
1296
  // src/table.ts
1305
1297
  var TABLE_VERSION = version;
@@ -1659,9 +1651,16 @@ var TRANSITION_TABLE = {
1659
1651
  id: "poll",
1660
1652
  mode: "AWAIT",
1661
1653
  endpoint: "GET /fiat/orders/:id",
1662
- when: "status is non-terminal, or no delivery stage is FAILED and one is PENDING",
1654
+ when: "status is non-terminal",
1663
1655
  note: "Documented giveUpAfterMs 300000 \u2014 on give-up the wizard exits and the durable order takes over."
1664
1656
  },
1657
+ {
1658
+ id: "delivery",
1659
+ mode: "AWAIT",
1660
+ endpoint: "GET /fiat/orders/:id/delivery",
1661
+ when: "status is SETTLED and the order is converted: the provider paid a deposit address that converts into the destinationAsset",
1662
+ note: "The backend decides; the client never infers a converted order. It follows this transition when offered, and otherwise treats SETTLED as done."
1663
+ },
1665
1664
  {
1666
1665
  id: "retry_payment",
1667
1666
  mode: "SUBMIT",
@@ -1682,7 +1681,7 @@ var TRANSITION_TABLE = {
1682
1681
  note: "TODO(open-decision): cancel placement (FE doc open questions 1+2); per-rail eligibility is contract OQ7."
1683
1682
  }
1684
1683
  ],
1685
- mayReturn: ["ORDER/CREATED"],
1684
+ mayReturn: ["ORDER/CREATED", "DELIVERY:PENDING", "DELIVERY:SUCCEEDED", "DELIVERY:FAILED"],
1686
1685
  terminal: false,
1687
1686
  terminalStatuses: TERMINAL_ORDER_STATUSES,
1688
1687
  notes: [
@@ -1690,9 +1689,53 @@ var TRANSITION_TABLE = {
1690
1689
  "A terminal status may still carry a recovery transition: FAILED + retryable failureReason emits it (FE doc Screen 14); non-retryable emits [].",
1691
1690
  "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.",
1692
1691
  "CAPTURE_ORPHANED is non-terminal pending the backend rank map (added from review 2026-08-14).",
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.",
1692
+ "SETTLED is terminal for the order and ends a direct purchase. On a converted order it carries the delivery transition, and the purchase continues in DELIVERY (GET /fiat/orders/:id/delivery). The order body itself never describes the conversion.",
1694
1693
  "TODO(open-decision): contract OQ7 \u2014 under/over-payment is the biggest unenumerated branch."
1695
1694
  ]
1695
+ },
1696
+ "DELIVERY:PENDING": {
1697
+ key: "DELIVERY:PENDING",
1698
+ kind: "DELIVERY",
1699
+ state: "PENDING",
1700
+ screens: [7],
1701
+ docStatus: "SPECIFIED",
1702
+ allowedTransitions: [
1703
+ {
1704
+ id: "poll",
1705
+ mode: "AWAIT",
1706
+ endpoint: "GET /fiat/orders/:id/delivery",
1707
+ note: "Giving up the poll does not fail the purchase: the backend still finishes the delivery or raises it to support."
1708
+ }
1709
+ ],
1710
+ mayReturn: ["DELIVERY:PENDING", "DELIVERY:SUCCEEDED", "DELIVERY:FAILED"],
1711
+ terminal: false,
1712
+ notes: [
1713
+ "The fiat leg is SETTLED; a crypto asset provider is converting it into the destinationAsset and paying the user. The client shows a generic processing screen."
1714
+ ]
1715
+ },
1716
+ "DELIVERY:SUCCEEDED": {
1717
+ key: "DELIVERY:SUCCEEDED",
1718
+ kind: "DELIVERY",
1719
+ state: "SUCCEEDED",
1720
+ screens: [13],
1721
+ docStatus: "SPECIFIED",
1722
+ allowedTransitions: [],
1723
+ mayReturn: [],
1724
+ terminal: true,
1725
+ notes: ["The destinationAsset reached the user. txHash is the transaction that paid them."]
1726
+ },
1727
+ "DELIVERY:FAILED": {
1728
+ key: "DELIVERY:FAILED",
1729
+ kind: "DELIVERY",
1730
+ state: "FAILED",
1731
+ screens: [],
1732
+ docStatus: "SPECIFIED",
1733
+ allowedTransitions: [],
1734
+ mayReturn: [],
1735
+ terminal: true,
1736
+ notes: [
1737
+ "The buyer has paid and the asset did not arrive. Support recovers the funds, so the client shows a dedicated failure screen that offers no new payment."
1738
+ ]
1696
1739
  }
1697
1740
  };
1698
1741
  var STATE_KEYS = Object.keys(TRANSITION_TABLE);
@@ -1711,6 +1754,7 @@ var DOCUMENTED_ENDPOINTS = [
1711
1754
  "POST /fiat/instruments",
1712
1755
  "POST /fiat/orders",
1713
1756
  "GET /fiat/orders/:id",
1757
+ "GET /fiat/orders/:id/delivery",
1714
1758
  "GET /fiat/orders/:id/instructions",
1715
1759
  "POST /fiat/orders/:id/confirm-payment",
1716
1760
  "POST /fiat/orders/:id/reference",
@@ -1786,6 +1830,8 @@ function stateKey(state) {
1786
1830
  return state.phase === "CAPTURE" ? "PAYMENT/CAPTURE" : "PAYMENT/INSTRUCT";
1787
1831
  case "ORDER":
1788
1832
  return state.phase === "AWAITING_CONFIRMATION" ? "ORDER/AWAITING_CONFIRMATION" : "ORDER/CREATED";
1833
+ case "DELIVERY":
1834
+ return `DELIVERY:${state.state}`;
1789
1835
  default: {
1790
1836
  const exhaustive = state;
1791
1837
  throw new Error(`unknown FlowState: ${JSON.stringify(exhaustive)}`);
@@ -1803,6 +1849,43 @@ function isTerminal(state) {
1803
1849
 
1804
1850
  // src/fixtures/data.ts
1805
1851
  var FIXTURE_DATA = {
1852
+ "delivery-01-pending": {
1853
+ "state": {
1854
+ "kind": "DELIVERY",
1855
+ "state": "PENDING"
1856
+ },
1857
+ "provider": "MOONPAY",
1858
+ "transitions": [
1859
+ {
1860
+ "id": "poll",
1861
+ "mode": "AWAIT",
1862
+ "poll": {
1863
+ "endpoint": "GET /fiat/orders/o_31c/delivery",
1864
+ "intervalMs": 3e3,
1865
+ "backoffFactor": 1.5,
1866
+ "maxIntervalMs": 1e4,
1867
+ "giveUpAfterMs": 3e5
1868
+ }
1869
+ }
1870
+ ]
1871
+ },
1872
+ "delivery-02-succeeded": {
1873
+ "state": {
1874
+ "kind": "DELIVERY",
1875
+ "state": "SUCCEEDED",
1876
+ "txHash": "5VER\u2026"
1877
+ },
1878
+ "provider": "MOONPAY",
1879
+ "transitions": []
1880
+ },
1881
+ "delivery-03-failed": {
1882
+ "state": {
1883
+ "kind": "DELIVERY",
1884
+ "state": "FAILED"
1885
+ },
1886
+ "provider": "MOONPAY",
1887
+ "transitions": []
1888
+ },
1806
1889
  "screen-01-quote": {
1807
1890
  "state": {
1808
1891
  "kind": "QUOTE",
@@ -2338,7 +2421,7 @@ var FIXTURE_DATA = {
2338
2421
  "provider": "TRANSAK",
2339
2422
  "transitions": []
2340
2423
  },
2341
- "screen-13b-order-settled-swapping": {
2424
+ "screen-13b-order-settled-converted": {
2342
2425
  "state": {
2343
2426
  "kind": "ORDER",
2344
2427
  "phase": "CREATED",
@@ -2360,28 +2443,15 @@ var FIXTURE_DATA = {
2360
2443
  "tx": {
2361
2444
  "chainId": 8453,
2362
2445
  "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
2446
  }
2377
2447
  },
2378
2448
  "provider": "MOONPAY",
2379
2449
  "transitions": [
2380
2450
  {
2381
- "id": "poll",
2451
+ "id": "delivery",
2382
2452
  "mode": "AWAIT",
2383
2453
  "poll": {
2384
- "endpoint": "GET /fiat/orders/o_31c",
2454
+ "endpoint": "GET /fiat/orders/o_31c/delivery",
2385
2455
  "intervalMs": 3e3,
2386
2456
  "backoffFactor": 1.5,
2387
2457
  "maxIntervalMs": 1e4,
@@ -2698,14 +2768,14 @@ var FIXTURES = [
2698
2768
  stateKey: "ORDER/CREATED"
2699
2769
  },
2700
2770
  {
2701
- id: "screen-13b-order-settled-swapping",
2702
- file: "screen-13b-order-settled-swapping.json",
2771
+ id: "screen-13b-order-settled-converted",
2772
+ file: "screen-13b-order-settled-converted.json",
2703
2773
  source: "CONTRACT_DOC",
2704
- docRef: "Package README \xA7Destination \xB7 a long-tail token still swapping after SETTLED",
2774
+ docRef: "Package README \xA7Delivery \xB7 a converted order at SETTLED",
2705
2775
  screen: 13,
2706
2776
  stateKey: "ORDER/CREATED",
2707
2777
  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.'
2778
+ "The order body is the fiat leg only, as for a direct order. The backend offers the delivery transition because this order is converted; the client follows it instead of showing success."
2709
2779
  ]
2710
2780
  },
2711
2781
  {
@@ -2758,6 +2828,28 @@ var FIXTURES = [
2758
2828
  notes: [
2759
2829
  "The response-level `orderId` case. TODO(open-decision): orderId placement (beside `state` here vs inside it in the FE doc v0)."
2760
2830
  ]
2831
+ },
2832
+ {
2833
+ id: "delivery-01-pending",
2834
+ file: "delivery-01-pending.json",
2835
+ source: "CONTRACT_DOC",
2836
+ docRef: "Package README \xA7Delivery \xB7 the conversion is running",
2837
+ stateKey: "DELIVERY:PENDING"
2838
+ },
2839
+ {
2840
+ id: "delivery-02-succeeded",
2841
+ file: "delivery-02-succeeded.json",
2842
+ source: "CONTRACT_DOC",
2843
+ docRef: "Package README \xA7Delivery \xB7 the destination asset reached the user",
2844
+ stateKey: "DELIVERY:SUCCEEDED"
2845
+ },
2846
+ {
2847
+ id: "delivery-03-failed",
2848
+ file: "delivery-03-failed.json",
2849
+ source: "CONTRACT_DOC",
2850
+ docRef: "Package README \xA7Delivery \xB7 the conversion failed after payment",
2851
+ stateKey: "DELIVERY:FAILED",
2852
+ notes: ["No transition: the buyer has paid, so the client offers no new payment. Support recovers the funds."]
2761
2853
  }
2762
2854
  ];
2763
2855
  var FIXTURE_COVERAGE_GAPS = [
@@ -3019,7 +3111,7 @@ var $checkout = obj2({
3019
3111
  var MoonPayCheckoutSchema = $checkout;
3020
3112
  var $credentials = obj2({ customerId: $nonEmpty, accessToken: $nonEmpty });
3021
3113
  var MoonPaySdkCredentialsSchema = $credentials;
3022
- var $context = { checkout: $checkout, credentials: $credentials.optional(), destination: FiatDestinationSchema.optional() };
3114
+ var $context = { checkout: $checkout, credentials: $credentials.optional(), destinationAsset: DestinationAssetSchema.optional() };
3023
3115
  var $requestContext = obj2($context);
3024
3116
  var MoonPayRequestContextSchema = $requestContext;
3025
3117
  var $quoteInput = obj2({
package/dist/index.mjs CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  tableEntry,
13
13
  unofferedEndpoints,
14
14
  unreachableStates
15
- } from "./chunk-ZB6TOPOA.mjs";
15
+ } from "./chunk-S6CA2WGQ.mjs";
16
16
  import {
17
17
  MOONPAY_ENDPOINTS
18
18
  } from "./chunk-TIEGTTFY.mjs";
@@ -475,16 +475,6 @@ var $statusHistoryEntry = obj({ status: $orderStatus });
475
475
  var StatusHistoryEntrySchema = $statusHistoryEntry;
476
476
  var $tx = obj({ chainId: z.number(), hash: z.string() });
477
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;
488
478
  var $refund = obj({
489
479
  currency: z.enum(FIAT_CURRENCY_CODES),
490
480
  amount: z.string(),
@@ -861,12 +851,17 @@ var $orderCreatedState = obj({
861
851
  status: $orderStatus,
862
852
  statusHistory: z.array($statusHistoryEntry).optional(),
863
853
  tx: $tx.optional(),
864
- delivery: $orderDelivery.optional(),
865
854
  refund: $refund.optional(),
866
855
  failureReason: $failureReason.optional(),
867
856
  error: $failureReason.optional()
868
857
  });
869
858
  var OrderCreatedStateSchema = $orderCreatedState;
859
+ var $deliveryState = z.discriminatedUnion("state", [
860
+ obj({ kind: z.literal("DELIVERY"), state: z.literal("PENDING") }),
861
+ obj({ kind: z.literal("DELIVERY"), state: z.literal("SUCCEEDED"), txHash: z.string().min(1) }),
862
+ obj({ kind: z.literal("DELIVERY"), state: z.literal("FAILED") })
863
+ ]);
864
+ var DeliveryStateSchema = $deliveryState;
870
865
  var $providerBoundFlowState = z.union([
871
866
  $quoteState,
872
867
  $funAuthState,
@@ -878,7 +873,8 @@ var $providerBoundFlowState = z.union([
878
873
  $paymentCaptureState,
879
874
  $paymentInstructState,
880
875
  $orderAwaitingConfirmationState,
881
- $orderCreatedState
876
+ $orderCreatedState,
877
+ $deliveryState
882
878
  ]);
883
879
  var $flowState = z.union([$providerBoundFlowState, $blockedState]);
884
880
  var FlowStateSchema = $flowState;
@@ -922,7 +918,7 @@ var $evmAddress = z.custom(
922
918
  "must be an EVM address: 0x and 40 hex digits"
923
919
  );
924
920
  var $solanaAddress = z.string().regex(/^[1-9A-HJ-NP-Za-km-z]{32,44}$/, "must be a Solana base58 address");
925
- var $evmDestination = obj({
921
+ var $evmDestinationAsset = obj({
926
922
  vm: z.literal("EVM"),
927
923
  chainId: z.number().int().positive(),
928
924
  asset: z.discriminatedUnion("kind", [
@@ -940,7 +936,7 @@ var $evmDestination = obj({
940
936
  })
941
937
  ])
942
938
  });
943
- var $solanaDestination = obj({
939
+ var $solanaDestinationAsset = obj({
944
940
  vm: z.literal("SOLANA"),
945
941
  asset: z.discriminatedUnion("kind", [
946
942
  obj({
@@ -953,8 +949,8 @@ var $solanaDestination = obj({
953
949
  obj({ kind: z.literal("NON_FUNGIBLE"), mint: $solanaAddress })
954
950
  ])
955
951
  });
956
- var $destination = z.discriminatedUnion("vm", [$evmDestination, $solanaDestination]);
957
- var FiatDestinationSchema = $destination;
952
+ var $destinationAsset = z.discriminatedUnion("vm", [$evmDestinationAsset, $solanaDestinationAsset]);
953
+ var DestinationAssetSchema = $destinationAsset;
958
954
  var $decimalAmount = z.string().regex(/^(?:0|[1-9]\d*)(?:\.\d+)?$/, "must be a decimal string");
959
955
  var compareDecimals = (left, right) => {
960
956
  const [leftWhole = "", leftFraction = ""] = left.split(".");
@@ -982,16 +978,14 @@ var $routingTableRequest = obj({
982
978
  // Duplicates are allowed; the response lists each method once.
983
979
  methods: z.array(z.enum(PAYMENT_METHOD_CATEGORIES)).min(1),
984
980
  providers: $routingTableProviderInputs.optional(),
985
- destination: $destination.optional()
981
+ destinationAsset: $destinationAsset.optional()
986
982
  }).refine((request) => hasUsRegion(request.country, request.region), { message: US_REGION_REQUIRED, path: ["region"] });
987
983
  var FiatRoutingTableRequestSchema = $routingTableRequest;
988
984
  var $routingTableProvider = obj({
989
985
  provider: $routingProvider,
990
986
  next: z.enum(["READY", "AUTH", "DECLARATIVE_KYC", "DOCUMENTARY_KYC", "PENDING_REVIEW"]),
991
987
  visibility: z.enum(["COMPLETE", "PARTIAL", "AUTH_GATED"]),
992
- currentLimit: $decimalAmount.nullable(),
993
- railAsset: $destination.optional(),
994
- stages: z.array($deliveryStageKind).min(1).optional()
988
+ currentLimit: $decimalAmount.nullable()
995
989
  });
996
990
  var $routingTableInterval = obj({
997
991
  min: $decimalAmount,
@@ -1030,7 +1024,7 @@ var $routingQuoteTermsShape = {
1030
1024
  ),
1031
1025
  prepareSessionAuth: z.boolean().optional(),
1032
1026
  routingOverrides: obj({ providers: z.array($routingProvider) }).optional(),
1033
- destination: $destination.optional()
1027
+ destinationAsset: $destinationAsset.optional()
1034
1028
  };
1035
1029
  var $routingQuoteTerms = obj($routingQuoteTermsShape);
1036
1030
  var FiatRoutingQuoteTermsSchema = $routingQuoteTerms;
@@ -1086,7 +1080,7 @@ var $routingQuoteErrorBody = z.union([$routingNoRouteErrorBody, $routingAmountEr
1086
1080
  var FiatRoutingQuoteErrorBodySchema = $routingQuoteErrorBody;
1087
1081
  var $fiatGeo = obj({ alpha2: z.string().regex(/^[A-Z]{2}$/), region: $nonBlank.optional(), ip: $nonBlank.optional() });
1088
1082
  var FiatGeoSchema = $fiatGeo;
1089
- var $nextRequest = z.object({ provider: $provider, action: $nonBlank, geo: $fiatGeo, destination: $destination.optional() }).catchall(z.unknown());
1083
+ var $nextRequest = z.object({ provider: $provider, action: $nonBlank, geo: $fiatGeo, destinationAsset: $destinationAsset.optional() }).catchall(z.unknown());
1090
1084
  var FiatNextRequestSchema = $nextRequest;
1091
1085
  var $providerBoundStepResponse = obj({
1092
1086
  state: $providerBoundFlowState,
@@ -1148,6 +1142,43 @@ var FiatStepResponseSchema = $stepResponse;
1148
1142
 
1149
1143
  // src/fixtures/data.ts
1150
1144
  var FIXTURE_DATA = {
1145
+ "delivery-01-pending": {
1146
+ "state": {
1147
+ "kind": "DELIVERY",
1148
+ "state": "PENDING"
1149
+ },
1150
+ "provider": "MOONPAY",
1151
+ "transitions": [
1152
+ {
1153
+ "id": "poll",
1154
+ "mode": "AWAIT",
1155
+ "poll": {
1156
+ "endpoint": "GET /fiat/orders/o_31c/delivery",
1157
+ "intervalMs": 3e3,
1158
+ "backoffFactor": 1.5,
1159
+ "maxIntervalMs": 1e4,
1160
+ "giveUpAfterMs": 3e5
1161
+ }
1162
+ }
1163
+ ]
1164
+ },
1165
+ "delivery-02-succeeded": {
1166
+ "state": {
1167
+ "kind": "DELIVERY",
1168
+ "state": "SUCCEEDED",
1169
+ "txHash": "5VER\u2026"
1170
+ },
1171
+ "provider": "MOONPAY",
1172
+ "transitions": []
1173
+ },
1174
+ "delivery-03-failed": {
1175
+ "state": {
1176
+ "kind": "DELIVERY",
1177
+ "state": "FAILED"
1178
+ },
1179
+ "provider": "MOONPAY",
1180
+ "transitions": []
1181
+ },
1151
1182
  "screen-01-quote": {
1152
1183
  "state": {
1153
1184
  "kind": "QUOTE",
@@ -1683,7 +1714,7 @@ var FIXTURE_DATA = {
1683
1714
  "provider": "TRANSAK",
1684
1715
  "transitions": []
1685
1716
  },
1686
- "screen-13b-order-settled-swapping": {
1717
+ "screen-13b-order-settled-converted": {
1687
1718
  "state": {
1688
1719
  "kind": "ORDER",
1689
1720
  "phase": "CREATED",
@@ -1705,28 +1736,15 @@ var FIXTURE_DATA = {
1705
1736
  "tx": {
1706
1737
  "chainId": 8453,
1707
1738
  "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
1739
  }
1722
1740
  },
1723
1741
  "provider": "MOONPAY",
1724
1742
  "transitions": [
1725
1743
  {
1726
- "id": "poll",
1744
+ "id": "delivery",
1727
1745
  "mode": "AWAIT",
1728
1746
  "poll": {
1729
- "endpoint": "GET /fiat/orders/o_31c",
1747
+ "endpoint": "GET /fiat/orders/o_31c/delivery",
1730
1748
  "intervalMs": 3e3,
1731
1749
  "backoffFactor": 1.5,
1732
1750
  "maxIntervalMs": 1e4,
@@ -2043,14 +2061,14 @@ var FIXTURES = [
2043
2061
  stateKey: "ORDER/CREATED"
2044
2062
  },
2045
2063
  {
2046
- id: "screen-13b-order-settled-swapping",
2047
- file: "screen-13b-order-settled-swapping.json",
2064
+ id: "screen-13b-order-settled-converted",
2065
+ file: "screen-13b-order-settled-converted.json",
2048
2066
  source: "CONTRACT_DOC",
2049
- docRef: "Package README \xA7Destination \xB7 a long-tail token still swapping after SETTLED",
2067
+ docRef: "Package README \xA7Delivery \xB7 a converted order at SETTLED",
2050
2068
  screen: 13,
2051
2069
  stateKey: "ORDER/CREATED",
2052
2070
  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.'
2071
+ "The order body is the fiat leg only, as for a direct order. The backend offers the delivery transition because this order is converted; the client follows it instead of showing success."
2054
2072
  ]
2055
2073
  },
2056
2074
  {
@@ -2103,6 +2121,28 @@ var FIXTURES = [
2103
2121
  notes: [
2104
2122
  "The response-level `orderId` case. TODO(open-decision): orderId placement (beside `state` here vs inside it in the FE doc v0)."
2105
2123
  ]
2124
+ },
2125
+ {
2126
+ id: "delivery-01-pending",
2127
+ file: "delivery-01-pending.json",
2128
+ source: "CONTRACT_DOC",
2129
+ docRef: "Package README \xA7Delivery \xB7 the conversion is running",
2130
+ stateKey: "DELIVERY:PENDING"
2131
+ },
2132
+ {
2133
+ id: "delivery-02-succeeded",
2134
+ file: "delivery-02-succeeded.json",
2135
+ source: "CONTRACT_DOC",
2136
+ docRef: "Package README \xA7Delivery \xB7 the destination asset reached the user",
2137
+ stateKey: "DELIVERY:SUCCEEDED"
2138
+ },
2139
+ {
2140
+ id: "delivery-03-failed",
2141
+ file: "delivery-03-failed.json",
2142
+ source: "CONTRACT_DOC",
2143
+ docRef: "Package README \xA7Delivery \xB7 the conversion failed after payment",
2144
+ stateKey: "DELIVERY:FAILED",
2145
+ notes: ["No transition: the buyer has paid, so the client offers no new payment. Support recovers the funds."]
2106
2146
  }
2107
2147
  ];
2108
2148
  var FIXTURE_COVERAGE_GAPS = [
@@ -2288,7 +2328,7 @@ var $checkout = obj2({
2288
2328
  var MoonPayCheckoutSchema = $checkout;
2289
2329
  var $credentials = obj2({ customerId: $nonEmpty, accessToken: $nonEmpty });
2290
2330
  var MoonPaySdkCredentialsSchema = $credentials;
2291
- var $context = { checkout: $checkout, credentials: $credentials.optional(), destination: FiatDestinationSchema.optional() };
2331
+ var $context = { checkout: $checkout, credentials: $credentials.optional(), destinationAsset: DestinationAssetSchema.optional() };
2292
2332
  var $requestContext = obj2($context);
2293
2333
  var MoonPayRequestContextSchema = $requestContext;
2294
2334
  var $quoteInput = obj2({
@@ -2483,6 +2523,8 @@ export {
2483
2523
  CountryCode,
2484
2524
  CryptoAmountSchema,
2485
2525
  DOCUMENTED_ENDPOINTS,
2526
+ DeliveryStateSchema,
2527
+ DestinationAssetSchema,
2486
2528
  ENDPOINT_PATTERN,
2487
2529
  FIAT_CURRENCY_NAMES,
2488
2530
  FIAT_TERMS_ENDPOINT,
@@ -2494,13 +2536,9 @@ export {
2494
2536
  FeeLineSchema,
2495
2537
  FiatAmountSchema,
2496
2538
  FiatCurrencyCode,
2497
- FiatDeliveryStageKindSchema,
2498
- FiatDeliveryStageSchema,
2499
- FiatDestinationSchema,
2500
2539
  FiatEndpointSchema,
2501
2540
  FiatGeoSchema,
2502
2541
  FiatNextRequestSchema,
2503
- FiatOrderDeliverySchema,
2504
2542
  FiatProviderSchema,
2505
2543
  FiatRoutingQuoteErrorBodySchema,
2506
2544
  FiatRoutingQuoteRequestSchema,
@@ -21,7 +21,7 @@
21
21
  */
22
22
  import type { FiatCurrencyCode } from '../codes';
23
23
  import type { FiatTermsRequest, TermsDocument } from '../terms';
24
- import type { FiatAmount, FiatDestination, FiatGeo, FiatStepResponse, FormField, KYCProvider, KycFieldId, KycSdkResultReport } from '../types';
24
+ import type { FiatAmount, DestinationAsset, FiatGeo, FiatStepResponse, FormField, KYCProvider, KycFieldId, KycSdkResultReport } from '../types';
25
25
  export declare const MOONPAY_ENDPOINTS: {
26
26
  readonly next: "POST /fiat/next";
27
27
  };
@@ -43,13 +43,13 @@ 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 asset
47
- * MoonPay delivers (the row's `railAsset`).
46
+ * `destinationAsset` is the asset the user receives at the end; `checkout.destination` stays the quote's
47
+ * asset, which MoonPay delivers.
48
48
  */
49
49
  export type MoonPayRequestContext = {
50
50
  checkout: MoonPayCheckout;
51
51
  credentials?: MoonPaySdkCredentials;
52
- destination?: FiatDestination;
52
+ destinationAsset?: DestinationAsset;
53
53
  };
54
54
  /**
55
55
  * The parameters for the device `client.getQuote`, not a quote. The backend builds them because the
@@ -253,7 +253,7 @@ export type MoonPayOrderRefusal = 'CUSTOMER_MISMATCH' | 'WALLET_MISMATCH' | 'UNR
253
253
  export type MoonPayNextAction = MoonPayConsentNextAction | MoonPaySessionNextAction | MoonPayConnectNextAction | MoonPayKycNextAction | MoonPayPrepareCaptureNextAction | MoonPayCaptureNextAction | MoonPayWaitNextAction | MoonPayOrderNextAction;
254
254
  /**
255
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.
256
+ * send to `/fiat/next`. A converted order's `SETTLED` body offers the `delivery` transition: follow it.
257
257
  */
258
258
  export type MoonPayDone = {
259
259
  next: 'done';
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, FiatDeliveryStageKind, FiatDestination, FiatProvider, QuoteLimitRange } from './types';
24
+ import type { FiatAmount, DestinationAsset, 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. */
@@ -59,7 +59,7 @@ export interface FiatRoutingTableRequest {
59
59
  * The asset the user receives. Always sent; the backend adds a conversion only when it differs
60
60
  * from the partner's configured asset. Optional so an older client still parses.
61
61
  */
62
- destination?: FiatDestination;
62
+ destinationAsset?: DestinationAsset;
63
63
  }
64
64
  /** What a provider needs from this buyer before it can take the payment. */
65
65
  export type RoutingNextStep = 'READY' | 'AUTH' | 'DECLARATIVE_KYC' | 'DOCUMENTARY_KYC' | 'PENDING_REVIEW';
@@ -83,19 +83,6 @@ export interface RoutingTableProvider {
83
83
  * table's currency. `null` when unknown. The interval edges are the most after every step on offer.
84
84
  */
85
85
  currentLimit: string | null;
86
- /**
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.
90
- */
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[];
99
86
  }
100
87
  /**
101
88
  * A `QuoteLimitRange` with two decimals (`"20.00"`) and the providers that serve it. The next
@@ -149,7 +136,7 @@ export interface FiatRoutingQuoteTerms {
149
136
  * The asset the user receives. Always sent; the backend adds a conversion only when it differs
150
137
  * from the partner's configured asset. Optional so an older client still parses.
151
138
  */
152
- destination?: FiatDestination;
139
+ destinationAsset?: DestinationAsset;
153
140
  }
154
141
  /**
155
142
  * `POST /fiat/routing/quote`: the terms plus which providers to price, in one of two forms.
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, FiatDeliveryStage, FiatDeliveryStageKind, FiatDestination, FiatGeo, FiatOrderDelivery, 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, DestinationAsset, FiatGeo, 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,9 +54,6 @@ 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>;
60
57
  export declare const RefundSchema: z.ZodType<Refund>;
61
58
  export declare const SurfaceKindSchema: z.ZodType<SurfaceKind>;
62
59
  export declare const PreferredIdentityDocumentSchema: z.ZodType<PreferredIdentityDocument>;
@@ -110,13 +107,14 @@ export declare const PaymentCaptureStateSchema: z.ZodType<State<'PAYMENT', 'CAPT
110
107
  export declare const PaymentInstructStateSchema: z.ZodType<State<'PAYMENT', 'INSTRUCT'>>;
111
108
  export declare const OrderAwaitingConfirmationStateSchema: z.ZodType<State<'ORDER', 'AWAITING_CONFIRMATION'>>;
112
109
  export declare const OrderCreatedStateSchema: z.ZodType<State<'ORDER', 'CREATED'>>;
110
+ export declare const DeliveryStateSchema: z.ZodType<State<'DELIVERY'>>;
113
111
  export declare const FlowStateSchema: z.ZodType<FlowState>;
114
112
  export declare const TermsDocumentSchema: z.ZodType<TermsDocument>;
115
113
  export declare const TermsDocumentAcceptanceSchema: z.ZodType<TermsDocumentAcceptance>;
116
114
  export declare const FiatTermsRequestSchema: z.ZodType<FiatTermsRequest>;
117
115
  export declare const FiatTermsResponseSchema: z.ZodType<FiatTermsResponse>;
118
116
  export declare const FiatTermsErrorBodySchema: z.ZodType<FiatTermsErrorBody>;
119
- export declare const FiatDestinationSchema: z.ZodType<FiatDestination>;
117
+ export declare const DestinationAssetSchema: z.ZodType<DestinationAsset>;
120
118
  export declare const FiatRoutingTableRequestSchema: z.ZodType<FiatRoutingTableRequest>;
121
119
  export declare const FiatRoutingTableResponseSchema: z.ZodType<FiatRoutingTableResponse>;
122
120
  export declare const FiatRoutingQuoteTermsSchema: z.ZodType<FiatRoutingQuoteTerms>;
package/dist/table.d.ts CHANGED
@@ -12,12 +12,14 @@
12
12
  * - Terminality of `ORDER{CREATED}` rides `status`, because terminal outcomes are OrderStatus,
13
13
  * never kinds (contract §The fiat step response). The set is enumerated below as
14
14
  * `TERMINAL_ORDER_STATUSES` — clients read it, they never derive it.
15
+ * - `DELIVERY` is keyed by its `state`, like KYC by `reason`: its three states differ in
16
+ * terminality and in what they may carry.
15
17
  * - A terminal *state* carries no transitions. A terminal *status* still can: `FAILED` with a
16
18
  * retryable `failureReason` carries the recovery CTA (FE doc Screen 14).
17
19
  * - The stale rule means any call may return any state. `mayReturn` is the conformance
18
20
  * assertion on the *typical* server sequence — the client never uses it to gate rendering.
19
21
  */
20
- import type { FiatEndpoint, FlowState, OrderStatus, TransitionMode } from './types';
22
+ import type { DeliveryState, FiatEndpoint, FlowState, OrderStatus, TransitionMode } from './types';
21
23
  /**
22
24
  * The package version IS the capability handshake's table version (contract §Conformance
23
25
  * package → Versioning). Derived from `package.json#version` at build time so the two can
@@ -28,9 +30,9 @@ export declare const TABLE_VERSION: string;
28
30
  /**
29
31
  * State identity = kind + phase + the state's named discriminant (FE doc §Decisions).
30
32
  * The table keys on kind + phase (+ `reason` for KYC, whose three reasons differ in terminality
31
- * and in what they may carry).
33
+ * and in what they may carry; `DELIVERY` keys on its `state` for the same reason).
32
34
  */
33
- export type StateKey = 'QUOTE' | 'FUN_AUTH' | 'SESSION_AUTH' | 'KYC/CAPTURE' | 'KYC/INPUT_REQUIRED' | 'KYC/NO_ACTION_REQUIRED:IN_REVIEW' | 'KYC/NO_ACTION_REQUIRED:ON_HOLD' | 'KYC/NO_ACTION_REQUIRED:REJECTED' | 'PENDING_ORDER' | 'BLOCKED' | 'PAYMENT/CAPTURE' | 'PAYMENT/INSTRUCT' | 'ORDER/AWAITING_CONFIRMATION' | 'ORDER/CREATED';
35
+ export type StateKey = 'QUOTE' | 'FUN_AUTH' | 'SESSION_AUTH' | 'KYC/CAPTURE' | 'KYC/INPUT_REQUIRED' | 'KYC/NO_ACTION_REQUIRED:IN_REVIEW' | 'KYC/NO_ACTION_REQUIRED:ON_HOLD' | 'KYC/NO_ACTION_REQUIRED:REJECTED' | 'PENDING_ORDER' | 'BLOCKED' | 'PAYMENT/CAPTURE' | 'PAYMENT/INSTRUCT' | 'ORDER/AWAITING_CONFIRMATION' | 'ORDER/CREATED' | 'DELIVERY:PENDING' | 'DELIVERY:SUCCEEDED' | 'DELIVERY:FAILED';
34
36
  /**
35
37
  * Terminal per the OrderStatus machine's monotonic ranks (contract §The fiat step response).
36
38
  *
@@ -64,6 +66,8 @@ export interface TableEntry {
64
66
  phase?: string;
65
67
  /** KYC `NO_ACTION_REQUIRED` only. */
66
68
  reason?: 'IN_REVIEW' | 'ON_HOLD' | 'REJECTED';
69
+ /** `DELIVERY` only. */
70
+ state?: DeliveryState;
67
71
  /** FE doc screen numbers that render this state. */
68
72
  screens: readonly number[];
69
73
  /**
@@ -90,7 +94,7 @@ export declare const STATE_KEYS: StateKey[];
90
94
  * named by the table (QUOTE's capture-first entry) while the doc's endpoint table still lists no
91
95
  * session-minting call for that rail.
92
96
  */
93
- export declare const DOCUMENTED_ENDPOINTS: readonly ["GET /fiat/payment-methods", "POST /fiat/quote", "POST /fiat/auth", "POST /fiat/payment-session", "POST /fiat/session", "POST /fiat/session/verify", "GET /fiat/quotes/:quoteRef", "POST /fiat/kyc/form", "POST /fiat/kyc/capture", "POST /fiat/kyc/sdk-token", "POST /fiat/kyc/document", "POST /fiat/instruments", "POST /fiat/orders", "GET /fiat/orders/:id", "GET /fiat/orders/:id/instructions", "POST /fiat/orders/:id/confirm-payment", "POST /fiat/orders/:id/reference", "POST /fiat/orders/:id/cancel", "POST /fiat/orders/:id/surface-result"];
97
+ export declare const DOCUMENTED_ENDPOINTS: readonly ["GET /fiat/payment-methods", "POST /fiat/quote", "POST /fiat/auth", "POST /fiat/payment-session", "POST /fiat/session", "POST /fiat/session/verify", "GET /fiat/quotes/:quoteRef", "POST /fiat/kyc/form", "POST /fiat/kyc/capture", "POST /fiat/kyc/sdk-token", "POST /fiat/kyc/document", "POST /fiat/instruments", "POST /fiat/orders", "GET /fiat/orders/:id", "GET /fiat/orders/:id/delivery", "GET /fiat/orders/:id/instructions", "POST /fiat/orders/:id/confirm-payment", "POST /fiat/orders/:id/reference", "POST /fiat/orders/:id/cancel", "POST /fiat/orders/:id/surface-result"];
94
98
  /**
95
99
  * Documented endpoints no flow state offers, and why. Declared so an endpoint nothing can reach is
96
100
  * visible instead of silent — the table test asserts the unoffered set equals exactly these.
package/dist/table.js CHANGED
@@ -36,7 +36,7 @@ __export(table_exports, {
36
36
  module.exports = __toCommonJS(table_exports);
37
37
 
38
38
  // package.json
39
- var version = "0.36.0-uda.3";
39
+ var version = "0.36.0-uda.5";
40
40
 
41
41
  // src/table.ts
42
42
  var TABLE_VERSION = version;
@@ -396,9 +396,16 @@ var TRANSITION_TABLE = {
396
396
  id: "poll",
397
397
  mode: "AWAIT",
398
398
  endpoint: "GET /fiat/orders/:id",
399
- when: "status is non-terminal, or no delivery stage is FAILED and one is PENDING",
399
+ when: "status is non-terminal",
400
400
  note: "Documented giveUpAfterMs 300000 \u2014 on give-up the wizard exits and the durable order takes over."
401
401
  },
402
+ {
403
+ id: "delivery",
404
+ mode: "AWAIT",
405
+ endpoint: "GET /fiat/orders/:id/delivery",
406
+ when: "status is SETTLED and the order is converted: the provider paid a deposit address that converts into the destinationAsset",
407
+ note: "The backend decides; the client never infers a converted order. It follows this transition when offered, and otherwise treats SETTLED as done."
408
+ },
402
409
  {
403
410
  id: "retry_payment",
404
411
  mode: "SUBMIT",
@@ -419,7 +426,7 @@ var TRANSITION_TABLE = {
419
426
  note: "TODO(open-decision): cancel placement (FE doc open questions 1+2); per-rail eligibility is contract OQ7."
420
427
  }
421
428
  ],
422
- mayReturn: ["ORDER/CREATED"],
429
+ mayReturn: ["ORDER/CREATED", "DELIVERY:PENDING", "DELIVERY:SUCCEEDED", "DELIVERY:FAILED"],
423
430
  terminal: false,
424
431
  terminalStatuses: TERMINAL_ORDER_STATUSES,
425
432
  notes: [
@@ -427,9 +434,53 @@ var TRANSITION_TABLE = {
427
434
  "A terminal status may still carry a recovery transition: FAILED + retryable failureReason emits it (FE doc Screen 14); non-retryable emits [].",
428
435
  "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.",
429
436
  "CAPTURE_ORPHANED is non-terminal pending the backend rank map (added from review 2026-08-14).",
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.",
437
+ "SETTLED is terminal for the order and ends a direct purchase. On a converted order it carries the delivery transition, and the purchase continues in DELIVERY (GET /fiat/orders/:id/delivery). The order body itself never describes the conversion.",
431
438
  "TODO(open-decision): contract OQ7 \u2014 under/over-payment is the biggest unenumerated branch."
432
439
  ]
440
+ },
441
+ "DELIVERY:PENDING": {
442
+ key: "DELIVERY:PENDING",
443
+ kind: "DELIVERY",
444
+ state: "PENDING",
445
+ screens: [7],
446
+ docStatus: "SPECIFIED",
447
+ allowedTransitions: [
448
+ {
449
+ id: "poll",
450
+ mode: "AWAIT",
451
+ endpoint: "GET /fiat/orders/:id/delivery",
452
+ note: "Giving up the poll does not fail the purchase: the backend still finishes the delivery or raises it to support."
453
+ }
454
+ ],
455
+ mayReturn: ["DELIVERY:PENDING", "DELIVERY:SUCCEEDED", "DELIVERY:FAILED"],
456
+ terminal: false,
457
+ notes: [
458
+ "The fiat leg is SETTLED; a crypto asset provider is converting it into the destinationAsset and paying the user. The client shows a generic processing screen."
459
+ ]
460
+ },
461
+ "DELIVERY:SUCCEEDED": {
462
+ key: "DELIVERY:SUCCEEDED",
463
+ kind: "DELIVERY",
464
+ state: "SUCCEEDED",
465
+ screens: [13],
466
+ docStatus: "SPECIFIED",
467
+ allowedTransitions: [],
468
+ mayReturn: [],
469
+ terminal: true,
470
+ notes: ["The destinationAsset reached the user. txHash is the transaction that paid them."]
471
+ },
472
+ "DELIVERY:FAILED": {
473
+ key: "DELIVERY:FAILED",
474
+ kind: "DELIVERY",
475
+ state: "FAILED",
476
+ screens: [],
477
+ docStatus: "SPECIFIED",
478
+ allowedTransitions: [],
479
+ mayReturn: [],
480
+ terminal: true,
481
+ notes: [
482
+ "The buyer has paid and the asset did not arrive. Support recovers the funds, so the client shows a dedicated failure screen that offers no new payment."
483
+ ]
433
484
  }
434
485
  };
435
486
  var STATE_KEYS = Object.keys(TRANSITION_TABLE);
@@ -448,6 +499,7 @@ var DOCUMENTED_ENDPOINTS = [
448
499
  "POST /fiat/instruments",
449
500
  "POST /fiat/orders",
450
501
  "GET /fiat/orders/:id",
502
+ "GET /fiat/orders/:id/delivery",
451
503
  "GET /fiat/orders/:id/instructions",
452
504
  "POST /fiat/orders/:id/confirm-payment",
453
505
  "POST /fiat/orders/:id/reference",
@@ -523,6 +575,8 @@ function stateKey(state) {
523
575
  return state.phase === "CAPTURE" ? "PAYMENT/CAPTURE" : "PAYMENT/INSTRUCT";
524
576
  case "ORDER":
525
577
  return state.phase === "AWAITING_CONFIRMATION" ? "ORDER/AWAITING_CONFIRMATION" : "ORDER/CREATED";
578
+ case "DELIVERY":
579
+ return `DELIVERY:${state.state}`;
526
580
  default: {
527
581
  const exhaustive = state;
528
582
  throw new Error(`unknown FlowState: ${JSON.stringify(exhaustive)}`);
package/dist/table.mjs CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  tableEntry,
12
12
  unofferedEndpoints,
13
13
  unreachableStates
14
- } from "./chunk-ZB6TOPOA.mjs";
14
+ } from "./chunk-S6CA2WGQ.mjs";
15
15
  export {
16
16
  DOCUMENTED_ENDPOINTS,
17
17
  STATE_KEYS,
package/dist/types.d.ts CHANGED
@@ -56,7 +56,7 @@ export type HttpVerb = 'GET' | 'POST';
56
56
  * cannot express "no slash", so `GET /fiat/orders/${string}` also admits sub-paths. Precision at
57
57
  * that level is the table's job (`allowedTransitions` + `endpointMatches`), not the type's.
58
58
  */
59
- export type FiatEndpoint = 'GET /fiat/payment-methods' | 'POST /fiat/quote' | 'POST /fiat/auth' | 'POST /fiat/payment-session' | 'POST /fiat/session' | 'POST /fiat/session/verify' | `GET /fiat/quotes/${string}` | 'POST /fiat/kyc/form' | 'POST /fiat/kyc/capture' | 'POST /fiat/kyc/sdk-token' | 'POST /fiat/kyc/document' | 'POST /fiat/instruments' | 'POST /fiat/orders' | `GET /fiat/orders/${string}` | `GET /fiat/orders/${string}/instructions` | `POST /fiat/orders/${string}/confirm-payment` | `POST /fiat/orders/${string}/reference` | `POST /fiat/orders/${string}/cancel` | `POST /fiat/orders/${string}/surface-result`;
59
+ export type FiatEndpoint = 'GET /fiat/payment-methods' | 'POST /fiat/quote' | 'POST /fiat/auth' | 'POST /fiat/payment-session' | 'POST /fiat/session' | 'POST /fiat/session/verify' | `GET /fiat/quotes/${string}` | 'POST /fiat/kyc/form' | 'POST /fiat/kyc/capture' | 'POST /fiat/kyc/sdk-token' | 'POST /fiat/kyc/document' | 'POST /fiat/instruments' | 'POST /fiat/orders' | `GET /fiat/orders/${string}` | `GET /fiat/orders/${string}/delivery` | `GET /fiat/orders/${string}/instructions` | `POST /fiat/orders/${string}/confirm-payment` | `POST /fiat/orders/${string}/reference` | `POST /fiat/orders/${string}/cancel` | `POST /fiat/orders/${string}/surface-result`;
60
60
  /**
61
61
  * Routing metadata, not sequencing policy. Reserved values may be emitted only after their adapter
62
62
  * and conformance fixture land.
@@ -76,9 +76,9 @@ 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. 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`.
79
+ * The provider's crypto reached the deposit address. Terminal for the order. A converted order
80
+ * (the provider pays a deposit address that converts into the `destinationAsset`) offers the `delivery`
81
+ * transition here, and the purchase continues in `DELIVERY`.
82
82
  */
83
83
  | 'SETTLED' | 'EXPIRED' | 'CANCELLED' | 'FAILED' | 'REFUNDED'
84
84
  /**
@@ -560,7 +560,7 @@ export type KycReviewDuration = {
560
560
  /**
561
561
  * The semantic state. Three rules keep this union honest:
562
562
  * 1. sub-states are payload discriminants, never new kinds
563
- * 2. terminal outcomes are OrderStatus, never kinds
563
+ * 2. terminal outcomes are OrderStatus (after the order, the `DELIVERY` state), never kinds
564
564
  * 3. every fallible state carries `error?: FailureReason`
565
565
  */
566
566
  export type FlowState =
@@ -679,13 +679,32 @@ export type FlowState =
679
679
  status: OrderStatus;
680
680
  statusHistory?: StatusHistoryEntry[];
681
681
  tx?: Tx;
682
- /** The stages that bring the asset to the user. Absent from a backend that predates it. */
683
- delivery?: FiatOrderDelivery;
684
682
  refund?: Refund;
685
683
  failureReason?: FailureReason;
686
684
  error?: FailureReason;
685
+ }
686
+ /**
687
+ * The crypto delivery after the fiat provider's leg, from `GET /fiat/orders/:id/delivery`. Only a
688
+ * converted order has one: its `ORDER{CREATED, SETTLED}` offers the `delivery` transition here.
689
+ * `PENDING` polls itself. `SUCCEEDED` carries the transaction that paid the user. `FAILED` means the
690
+ * buyer has paid and the asset did not arrive: support recovers the funds, so the client never offers
691
+ * another payment from it.
692
+ */
693
+ | {
694
+ kind: 'DELIVERY';
695
+ state: 'PENDING';
696
+ } | {
697
+ kind: 'DELIVERY';
698
+ state: 'SUCCEEDED';
699
+ txHash: string;
700
+ } | {
701
+ kind: 'DELIVERY';
702
+ state: 'FAILED';
687
703
  };
688
704
  export type FlowStateKind = FlowState['kind'];
705
+ export type DeliveryState = Extract<FlowState, {
706
+ kind: 'DELIVERY';
707
+ }>['state'];
689
708
  export type BlockedReason = 'REGION_UNSUPPORTED' | 'ASSET_UNSUPPORTED' | 'ALL_PROVIDERS_DECLINED' | 'AMOUNT_UNSERVABLE'
690
709
  /** The installed client did not declare a capability required by every otherwise-viable route. */
691
710
  | 'CLIENT_UPGRADE_REQUIRED';
@@ -751,16 +770,17 @@ export type FiatStepResponse = (FiatStepResponseBase & {
751
770
  });
752
771
  /**
753
772
  * 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.
773
+ * compares it with the partner's configured asset and adds a conversion only when they differ,
774
+ * so its presence never turns a conversion on. Every request field that carries it is named
775
+ * `destinationAsset`, optional only so a client that predates it still parses; a missing
776
+ * `destinationAsset` means the partner's configured asset. The recipient always comes from the
777
+ * verified partner assertion, never from this field.
758
778
  *
759
779
  * Split by VM, then by asset kind. Solana carries no chain id: the backend maps each VM to its own
760
780
  * chain ids in one place. `NON_FUNGIBLE` is reserved: the backend does not serve it yet and answers
761
781
  * it as unservable.
762
782
  */
763
- export type FiatDestination = {
783
+ export type DestinationAsset = {
764
784
  vm: 'EVM';
765
785
  /** The EVM chain id: `8453` for Base. */
766
786
  chainId: number;
@@ -794,35 +814,6 @@ export type FiatDestination = {
794
814
  mint: string;
795
815
  };
796
816
  };
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
- };
826
817
  /** The geo endpoint's response, sent on every `/next` request. `alpha2` is ISO 3166-1 alpha-2. */
827
818
  export type FiatGeo = {
828
819
  alpha2: string;
@@ -830,7 +821,7 @@ export type FiatGeo = {
830
821
  ip?: string;
831
822
  };
832
823
  /**
833
- * The body of every `POST /fiat/next`: `provider`, `geo`, the `destination`, and the
824
+ * The body of every `POST /fiat/next`: `provider`, `geo`, the `destinationAsset`, and the
834
825
  * provider's own request, which names its `action`. Each provider defines its actions and their
835
826
  * fields (`./moonpay`).
836
827
  */
@@ -838,6 +829,6 @@ export type FiatNextRequest = {
838
829
  provider: FiatProvider;
839
830
  action: string;
840
831
  geo: FiatGeo;
841
- destination?: FiatDestination;
832
+ destinationAsset?: DestinationAsset;
842
833
  } & Record<string, unknown>;
843
834
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fun-xyz/fiat-contract",
3
- "version": "0.36.0-uda.3",
3
+ "version": "0.36.0-uda.5",
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": {