@fun-xyz/fiat-contract 0.36.0-uda.2 → 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.
- package/dist/{chunk-7GDFZ5UR.mjs → chunk-ZB6TOPOA.mjs} +3 -3
- package/dist/index.js +112 -15
- package/dist/index.mjs +110 -13
- package/dist/providers/moonpay.d.ts +3 -2
- package/dist/routing.d.ts +20 -21
- package/dist/schemas.d.ts +3 -2
- package/dist/table.js +3 -3
- package/dist/table.mjs +1 -1
- package/dist/types.d.ts +72 -26
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// package.json
|
|
2
|
-
var version = "0.36.0-uda.
|
|
2
|
+
var version = "0.36.0-uda.3";
|
|
3
3
|
|
|
4
4
|
// src/table.ts
|
|
5
5
|
var TABLE_VERSION = version;
|
|
@@ -359,7 +359,7 @@ 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 delivery
|
|
362
|
+
when: "status is non-terminal, or no delivery stage is FAILED and one is PENDING",
|
|
363
363
|
note: "Documented giveUpAfterMs 300000 \u2014 on give-up the wizard exits and the durable order takes over."
|
|
364
364
|
},
|
|
365
365
|
{
|
|
@@ -390,7 +390,7 @@ var TRANSITION_TABLE = {
|
|
|
390
390
|
"A terminal status may still carry a recovery transition: FAILED + retryable failureReason emits it (FE doc Screen 14); non-retryable emits [].",
|
|
391
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.",
|
|
392
392
|
"CAPTURE_ORPHANED is non-terminal pending the backend rank map (added from review 2026-08-14).",
|
|
393
|
-
"SETTLED is terminal for the order
|
|
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.",
|
|
394
394
|
"TODO(open-decision): contract OQ7 \u2014 under/over-payment is the biggest unenumerated branch."
|
|
395
395
|
]
|
|
396
396
|
}
|
package/dist/index.js
CHANGED
|
@@ -41,12 +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,
|
|
48
50
|
FiatOrderDeliverySchema: () => FiatOrderDeliverySchema,
|
|
49
|
-
FiatOrderDeliveryStateSchema: () => FiatOrderDeliveryStateSchema,
|
|
50
51
|
FiatProviderSchema: () => FiatProviderSchema,
|
|
51
52
|
FiatRoutingQuoteErrorBodySchema: () => FiatRoutingQuoteErrorBodySchema,
|
|
52
53
|
FiatRoutingQuoteRequestSchema: () => FiatRoutingQuoteRequestSchema,
|
|
@@ -626,12 +627,15 @@ var $statusHistoryEntry = obj({ status: $orderStatus });
|
|
|
626
627
|
var StatusHistoryEntrySchema = $statusHistoryEntry;
|
|
627
628
|
var $tx = obj({ chainId: import_zod.z.number(), hash: import_zod.z.string() });
|
|
628
629
|
var TxSchema = $tx;
|
|
629
|
-
var $
|
|
630
|
-
var
|
|
631
|
-
var $
|
|
632
|
-
obj({
|
|
633
|
-
obj({
|
|
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") })
|
|
634
636
|
]);
|
|
637
|
+
var FiatDeliveryStageSchema = $deliveryStage;
|
|
638
|
+
var $orderDelivery = obj({ stages: import_zod.z.array($deliveryStage).min(1) });
|
|
635
639
|
var FiatOrderDeliverySchema = $orderDelivery;
|
|
636
640
|
var $refund = obj({
|
|
637
641
|
currency: import_zod.z.enum(FIAT_CURRENCY_CODES),
|
|
@@ -1065,13 +1069,43 @@ var $termsErrorBody = obj({
|
|
|
1065
1069
|
recovery: import_zod.z.enum(["RETRY", "REQUOTE", "NONE"])
|
|
1066
1070
|
});
|
|
1067
1071
|
var FiatTermsErrorBodySchema = $termsErrorBody;
|
|
1068
|
-
var $
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
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 })
|
|
1073
1106
|
])
|
|
1074
1107
|
});
|
|
1108
|
+
var $destination = import_zod.z.discriminatedUnion("vm", [$evmDestination, $solanaDestination]);
|
|
1075
1109
|
var FiatDestinationSchema = $destination;
|
|
1076
1110
|
var $decimalAmount = import_zod.z.string().regex(/^(?:0|[1-9]\d*)(?:\.\d+)?$/, "must be a decimal string");
|
|
1077
1111
|
var compareDecimals = (left, right) => {
|
|
@@ -1109,7 +1143,7 @@ var $routingTableProvider = obj({
|
|
|
1109
1143
|
visibility: import_zod.z.enum(["COMPLETE", "PARTIAL", "AUTH_GATED"]),
|
|
1110
1144
|
currentLimit: $decimalAmount.nullable(),
|
|
1111
1145
|
railAsset: $destination.optional(),
|
|
1112
|
-
|
|
1146
|
+
stages: import_zod.z.array($deliveryStageKind).min(1).optional()
|
|
1113
1147
|
});
|
|
1114
1148
|
var $routingTableInterval = obj({
|
|
1115
1149
|
min: $decimalAmount,
|
|
@@ -1265,7 +1299,7 @@ var $stepResponse = import_zod.z.union([$providerBoundStepResponse, $blockedStep
|
|
|
1265
1299
|
var FiatStepResponseSchema = $stepResponse;
|
|
1266
1300
|
|
|
1267
1301
|
// package.json
|
|
1268
|
-
var version = "0.36.0-uda.
|
|
1302
|
+
var version = "0.36.0-uda.3";
|
|
1269
1303
|
|
|
1270
1304
|
// src/table.ts
|
|
1271
1305
|
var TABLE_VERSION = version;
|
|
@@ -1625,7 +1659,7 @@ var TRANSITION_TABLE = {
|
|
|
1625
1659
|
id: "poll",
|
|
1626
1660
|
mode: "AWAIT",
|
|
1627
1661
|
endpoint: "GET /fiat/orders/:id",
|
|
1628
|
-
when: "status is non-terminal, or delivery
|
|
1662
|
+
when: "status is non-terminal, or no delivery stage is FAILED and one is PENDING",
|
|
1629
1663
|
note: "Documented giveUpAfterMs 300000 \u2014 on give-up the wizard exits and the durable order takes over."
|
|
1630
1664
|
},
|
|
1631
1665
|
{
|
|
@@ -1656,7 +1690,7 @@ var TRANSITION_TABLE = {
|
|
|
1656
1690
|
"A terminal status may still carry a recovery transition: FAILED + retryable failureReason emits it (FE doc Screen 14); non-retryable emits [].",
|
|
1657
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.",
|
|
1658
1692
|
"CAPTURE_ORPHANED is non-terminal pending the backend rank map (added from review 2026-08-14).",
|
|
1659
|
-
"SETTLED is terminal for the order
|
|
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.",
|
|
1660
1694
|
"TODO(open-decision): contract OQ7 \u2014 under/over-payment is the biggest unenumerated branch."
|
|
1661
1695
|
]
|
|
1662
1696
|
}
|
|
@@ -2304,6 +2338,58 @@ var FIXTURE_DATA = {
|
|
|
2304
2338
|
"provider": "TRANSAK",
|
|
2305
2339
|
"transitions": []
|
|
2306
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
|
+
},
|
|
2307
2393
|
"screen-14-order-failed": {
|
|
2308
2394
|
"state": {
|
|
2309
2395
|
"kind": "ORDER",
|
|
@@ -2611,6 +2697,17 @@ var FIXTURES = [
|
|
|
2611
2697
|
screen: 13,
|
|
2612
2698
|
stateKey: "ORDER/CREATED"
|
|
2613
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
|
+
},
|
|
2614
2711
|
{
|
|
2615
2712
|
id: "screen-14-order-failed",
|
|
2616
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-
|
|
15
|
+
} from "./chunk-ZB6TOPOA.mjs";
|
|
16
16
|
import {
|
|
17
17
|
MOONPAY_ENDPOINTS
|
|
18
18
|
} from "./chunk-TIEGTTFY.mjs";
|
|
@@ -475,12 +475,15 @@ 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 $
|
|
479
|
-
var
|
|
480
|
-
var $
|
|
481
|
-
obj({
|
|
482
|
-
obj({
|
|
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") })
|
|
483
484
|
]);
|
|
485
|
+
var FiatDeliveryStageSchema = $deliveryStage;
|
|
486
|
+
var $orderDelivery = obj({ stages: z.array($deliveryStage).min(1) });
|
|
484
487
|
var FiatOrderDeliverySchema = $orderDelivery;
|
|
485
488
|
var $refund = obj({
|
|
486
489
|
currency: z.enum(FIAT_CURRENCY_CODES),
|
|
@@ -914,13 +917,43 @@ var $termsErrorBody = obj({
|
|
|
914
917
|
recovery: z.enum(["RETRY", "REQUOTE", "NONE"])
|
|
915
918
|
});
|
|
916
919
|
var FiatTermsErrorBodySchema = $termsErrorBody;
|
|
917
|
-
var $
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
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 })
|
|
922
954
|
])
|
|
923
955
|
});
|
|
956
|
+
var $destination = z.discriminatedUnion("vm", [$evmDestination, $solanaDestination]);
|
|
924
957
|
var FiatDestinationSchema = $destination;
|
|
925
958
|
var $decimalAmount = z.string().regex(/^(?:0|[1-9]\d*)(?:\.\d+)?$/, "must be a decimal string");
|
|
926
959
|
var compareDecimals = (left, right) => {
|
|
@@ -958,7 +991,7 @@ var $routingTableProvider = obj({
|
|
|
958
991
|
visibility: z.enum(["COMPLETE", "PARTIAL", "AUTH_GATED"]),
|
|
959
992
|
currentLimit: $decimalAmount.nullable(),
|
|
960
993
|
railAsset: $destination.optional(),
|
|
961
|
-
|
|
994
|
+
stages: z.array($deliveryStageKind).min(1).optional()
|
|
962
995
|
});
|
|
963
996
|
var $routingTableInterval = obj({
|
|
964
997
|
min: $decimalAmount,
|
|
@@ -1650,6 +1683,58 @@ var FIXTURE_DATA = {
|
|
|
1650
1683
|
"provider": "TRANSAK",
|
|
1651
1684
|
"transitions": []
|
|
1652
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
|
+
},
|
|
1653
1738
|
"screen-14-order-failed": {
|
|
1654
1739
|
"state": {
|
|
1655
1740
|
"kind": "ORDER",
|
|
@@ -1957,6 +2042,17 @@ var FIXTURES = [
|
|
|
1957
2042
|
screen: 13,
|
|
1958
2043
|
stateKey: "ORDER/CREATED"
|
|
1959
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
|
+
},
|
|
1960
2056
|
{
|
|
1961
2057
|
id: "screen-14-order-failed",
|
|
1962
2058
|
file: "screen-14-order-failed.json",
|
|
@@ -2398,12 +2494,13 @@ export {
|
|
|
2398
2494
|
FeeLineSchema,
|
|
2399
2495
|
FiatAmountSchema,
|
|
2400
2496
|
FiatCurrencyCode,
|
|
2497
|
+
FiatDeliveryStageKindSchema,
|
|
2498
|
+
FiatDeliveryStageSchema,
|
|
2401
2499
|
FiatDestinationSchema,
|
|
2402
2500
|
FiatEndpointSchema,
|
|
2403
2501
|
FiatGeoSchema,
|
|
2404
2502
|
FiatNextRequestSchema,
|
|
2405
2503
|
FiatOrderDeliverySchema,
|
|
2406
|
-
FiatOrderDeliveryStateSchema,
|
|
2407
2504
|
FiatProviderSchema,
|
|
2408
2505
|
FiatRoutingQuoteErrorBodySchema,
|
|
2409
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
|
|
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;
|
|
@@ -252,7 +253,7 @@ export type MoonPayOrderRefusal = 'CUSTOMER_MISMATCH' | 'WALLET_MISMATCH' | 'UNR
|
|
|
252
253
|
export type MoonPayNextAction = MoonPayConsentNextAction | MoonPaySessionNextAction | MoonPayConnectNextAction | MoonPayKycNextAction | MoonPayPrepareCaptureNextAction | MoonPayCaptureNextAction | MoonPayWaitNextAction | MoonPayOrderNextAction;
|
|
253
254
|
/**
|
|
254
255
|
* The order is terminal. `order` is its body, which the shared order screen renders. Nothing is left to
|
|
255
|
-
* send to `/fiat/next`; a `
|
|
256
|
+
* send to `/fiat/next`; while a `delivery` stage is `PENDING`, the body keeps its `GET /fiat/orders/:id` poll.
|
|
256
257
|
*/
|
|
257
258
|
export type MoonPayDone = {
|
|
258
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,
|
|
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
|
-
/**
|
|
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,26 +84,19 @@ export interface RoutingTableProvider {
|
|
|
81
84
|
*/
|
|
82
85
|
currentLimit: string | null;
|
|
83
86
|
/**
|
|
84
|
-
* The asset this provider delivers on the order: the
|
|
85
|
-
*
|
|
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.
|
|
87
90
|
*/
|
|
88
|
-
railAsset?:
|
|
89
|
-
/**
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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 the
|
|
99
|
-
* order settles. `CONVERTED`: the provider pays a deposit address that converts `railAsset` into the
|
|
100
|
-
* request's `destination`, so the purchase is done when the order's `delivery.state` is `DELIVERED`.
|
|
101
|
-
* The same values as the order's `delivery.mode`.
|
|
102
|
-
*/
|
|
103
|
-
export type RoutingDeliveryMode = FiatOrderDelivery['mode'];
|
|
104
100
|
/**
|
|
105
101
|
* A `QuoteLimitRange` with two decimals (`"20.00"`) and the providers that serve it. The next
|
|
106
102
|
* interval starts one cent above `max`. Adjacent intervals always rank differently.
|
|
@@ -149,7 +145,10 @@ export interface FiatRoutingQuoteTerms {
|
|
|
149
145
|
routingOverrides?: {
|
|
150
146
|
providers: RoutingProvider[];
|
|
151
147
|
};
|
|
152
|
-
/**
|
|
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
|
+
*/
|
|
153
152
|
destination?: FiatDestination;
|
|
154
153
|
}
|
|
155
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, FiatOrderDelivery,
|
|
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,7 +54,8 @@ 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
|
|
57
|
+
export declare const FiatDeliveryStageKindSchema: z.ZodType<FiatDeliveryStageKind>;
|
|
58
|
+
export declare const FiatDeliveryStageSchema: z.ZodType<FiatDeliveryStage>;
|
|
58
59
|
export declare const FiatOrderDeliverySchema: z.ZodType<FiatOrderDelivery>;
|
|
59
60
|
export declare const RefundSchema: z.ZodType<Refund>;
|
|
60
61
|
export declare const SurfaceKindSchema: z.ZodType<SurfaceKind>;
|
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.
|
|
39
|
+
var version = "0.36.0-uda.3";
|
|
40
40
|
|
|
41
41
|
// src/table.ts
|
|
42
42
|
var TABLE_VERSION = version;
|
|
@@ -396,7 +396,7 @@ 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 delivery
|
|
399
|
+
when: "status is non-terminal, or no delivery stage is FAILED and one is PENDING",
|
|
400
400
|
note: "Documented giveUpAfterMs 300000 \u2014 on give-up the wizard exits and the durable order takes over."
|
|
401
401
|
},
|
|
402
402
|
{
|
|
@@ -427,7 +427,7 @@ var TRANSITION_TABLE = {
|
|
|
427
427
|
"A terminal status may still carry a recovery transition: FAILED + retryable failureReason emits it (FE doc Screen 14); non-retryable emits [].",
|
|
428
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.",
|
|
429
429
|
"CAPTURE_ORPHANED is non-terminal pending the backend rank map (added from review 2026-08-14).",
|
|
430
|
-
"SETTLED is terminal for the order
|
|
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.",
|
|
431
431
|
"TODO(open-decision): contract OQ7 \u2014 under/over-payment is the biggest unenumerated branch."
|
|
432
432
|
]
|
|
433
433
|
}
|
package/dist/table.mjs
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -77,8 +77,8 @@ export type FiatProvider = 'TRANSAK' | 'SWAPPED' | 'BANXA' | 'MOONPAY' | 'STRIPE
|
|
|
77
77
|
export type OrderStatus = 'CREATING' | 'AWAITING_PAYMENT' | 'PAYMENT_VERIFYING' | 'PROCESSING' | 'PENDING_DELIVERY' | 'ON_HOLD' | 'CRYPTO_SENT'
|
|
78
78
|
/**
|
|
79
79
|
* The provider's crypto reached the deposit address. Terminal for the order. When the order's
|
|
80
|
-
* `delivery`
|
|
81
|
-
* `delivery.
|
|
80
|
+
* `delivery` has a stage after `FIAT_PAYOUT`, that stage may still be running: read
|
|
81
|
+
* `delivery.stages`.
|
|
82
82
|
*/
|
|
83
83
|
| 'SETTLED' | 'EXPIRED' | 'CANCELLED' | 'FAILED' | 'REFUNDED'
|
|
84
84
|
/**
|
|
@@ -679,7 +679,7 @@ export type FlowState =
|
|
|
679
679
|
status: OrderStatus;
|
|
680
680
|
statusHistory?: StatusHistoryEntry[];
|
|
681
681
|
tx?: Tx;
|
|
682
|
-
/**
|
|
682
|
+
/** The stages that bring the asset to the user. Absent from a backend that predates it. */
|
|
683
683
|
delivery?: FiatOrderDelivery;
|
|
684
684
|
refund?: Refund;
|
|
685
685
|
failureReason?: FailureReason;
|
|
@@ -750,33 +750,79 @@ export type FiatStepResponse = (FiatStepResponseBase & {
|
|
|
750
750
|
};
|
|
751
751
|
});
|
|
752
752
|
/**
|
|
753
|
-
* The asset the user receives at the end of the purchase.
|
|
754
|
-
*
|
|
755
|
-
*
|
|
756
|
-
*
|
|
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.
|
|
757
762
|
*/
|
|
758
|
-
export
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
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
|
+
};
|
|
764
797
|
/**
|
|
765
|
-
*
|
|
766
|
-
*
|
|
767
|
-
*
|
|
768
|
-
* conversion: `SWAPPING` while it runs, `DELIVERED` once the destination asset reached the user's
|
|
769
|
-
* wallet, `FAILED` when it stopped without paying the user. `finalTxHash` is the transaction that paid
|
|
770
|
-
* the user, `null` until `DELIVERED`.
|
|
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.
|
|
771
801
|
*/
|
|
772
|
-
export type
|
|
773
|
-
|
|
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;
|
|
774
811
|
} | {
|
|
775
|
-
|
|
776
|
-
state:
|
|
777
|
-
|
|
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[];
|
|
778
825
|
};
|
|
779
|
-
export type FiatOrderDeliveryState = 'SWAPPING' | 'DELIVERED' | 'FAILED';
|
|
780
826
|
/** The geo endpoint's response, sent on every `/next` request. `alpha2` is ISO 3166-1 alpha-2. */
|
|
781
827
|
export type FiatGeo = {
|
|
782
828
|
alpha2: string;
|
|
@@ -784,7 +830,7 @@ export type FiatGeo = {
|
|
|
784
830
|
ip?: string;
|
|
785
831
|
};
|
|
786
832
|
/**
|
|
787
|
-
* The body of every `POST /fiat/next`: `provider`, `geo`, the
|
|
833
|
+
* The body of every `POST /fiat/next`: `provider`, `geo`, the `destination`, and the
|
|
788
834
|
* provider's own request, which names its `action`. Each provider defines its actions and their
|
|
789
835
|
* fields (`./moonpay`).
|
|
790
836
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fun-xyz/fiat-contract",
|
|
3
|
-
"version": "0.36.0-uda.
|
|
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": {
|