@fun-xyz/fiat-contract 0.33.0 → 0.36.0-uda.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-4ROPH56R.mjs → chunk-PWC3WN74.mjs} +3 -1
- package/dist/index.js +64 -11
- package/dist/index.mjs +62 -11
- package/dist/providers/moonpay.d.ts +50 -9
- package/dist/providers/moonpay.schemas.d.ts +6 -1
- package/dist/routing.d.ts +5 -1
- package/dist/schemas.d.ts +2 -1
- package/dist/table.d.ts +1 -1
- package/dist/table.js +3 -1
- package/dist/table.mjs +1 -1
- package/dist/types.d.ts +27 -3
- package/package.json +1 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// package.json
|
|
2
|
-
var version = "0.
|
|
2
|
+
var version = "0.36.0-uda.0";
|
|
3
3
|
|
|
4
4
|
// src/table.ts
|
|
5
5
|
var TABLE_VERSION = version;
|
|
6
6
|
var TERMINAL_ORDER_STATUSES = [
|
|
7
7
|
"SETTLED",
|
|
8
|
+
"FINAL_ASSET_DELIVERED",
|
|
8
9
|
"EXPIRED",
|
|
9
10
|
"CANCELLED",
|
|
10
11
|
"FAILED",
|
|
@@ -390,6 +391,7 @@ var TRANSITION_TABLE = {
|
|
|
390
391
|
"A terminal status may still carry a recovery transition: FAILED + retryable failureReason emits it (FE doc Screen 14); non-retryable emits [].",
|
|
391
392
|
"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
393
|
"CAPTURE_ORPHANED is non-terminal pending the backend rank map (added from review 2026-08-14).",
|
|
394
|
+
"FINAL_ASSET_DELIVERED ends only an order whose request carried a destination. SETTLED stays in terminalStatuses for every other order, so a client that sent a destination keeps polling past SETTLED.",
|
|
393
395
|
"TODO(open-decision): contract OQ7 \u2014 under/over-payment is the biggest unenumerated branch."
|
|
394
396
|
]
|
|
395
397
|
}
|
package/dist/index.js
CHANGED
|
@@ -41,6 +41,7 @@ __export(index_exports, {
|
|
|
41
41
|
FeeLineSchema: () => FeeLineSchema,
|
|
42
42
|
FiatAmountSchema: () => FiatAmountSchema,
|
|
43
43
|
FiatCurrencyCode: () => FiatCurrencyCode,
|
|
44
|
+
FiatDestinationSchema: () => FiatDestinationSchema,
|
|
44
45
|
FiatEndpointSchema: () => FiatEndpointSchema,
|
|
45
46
|
FiatGeoSchema: () => FiatGeoSchema,
|
|
46
47
|
FiatNextRequestSchema: () => FiatNextRequestSchema,
|
|
@@ -75,6 +76,7 @@ __export(index_exports, {
|
|
|
75
76
|
KycReviewDurationSchema: () => KycReviewDurationSchema,
|
|
76
77
|
KycSdkResultReportSchema: () => KycSdkResultReportSchema,
|
|
77
78
|
MOONPAY_ENDPOINTS: () => MOONPAY_ENDPOINTS,
|
|
79
|
+
MoonPayCaptureDocumentSchema: () => MoonPayCaptureDocumentSchema,
|
|
78
80
|
MoonPayCaptureNextActionSchema: () => MoonPayCaptureNextActionSchema,
|
|
79
81
|
MoonPayCaptureRequestSchema: () => MoonPayCaptureRequestSchema,
|
|
80
82
|
MoonPayCheckoutSchema: () => MoonPayCheckoutSchema,
|
|
@@ -91,11 +93,15 @@ __export(index_exports, {
|
|
|
91
93
|
MoonPayNextRequestSchema: () => MoonPayNextRequestSchema,
|
|
92
94
|
MoonPayObserveRequestSchema: () => MoonPayObserveRequestSchema,
|
|
93
95
|
MoonPayOrderNextActionSchema: () => MoonPayOrderNextActionSchema,
|
|
96
|
+
MoonPayOrderPendingNextActionSchema: () => MoonPayOrderPendingNextActionSchema,
|
|
94
97
|
MoonPayOrderRequestSchema: () => MoonPayOrderRequestSchema,
|
|
95
98
|
MoonPayOrderResponseSchema: () => MoonPayOrderResponseSchema,
|
|
96
99
|
MoonPayPrepareCaptureNextActionSchema: () => MoonPayPrepareCaptureNextActionSchema,
|
|
97
100
|
MoonPayPrepareCaptureRequestSchema: () => MoonPayPrepareCaptureRequestSchema,
|
|
98
101
|
MoonPayQuoteInputSchema: () => MoonPayQuoteInputSchema,
|
|
102
|
+
MoonPayReaskReasonSchema: () => MoonPayReaskReasonSchema,
|
|
103
|
+
MoonPayReaskRequirementSchema: () => MoonPayReaskRequirementSchema,
|
|
104
|
+
MoonPayReaskSchema: () => MoonPayReaskSchema,
|
|
99
105
|
MoonPayRequestContextSchema: () => MoonPayRequestContextSchema,
|
|
100
106
|
MoonPayRequestSchema: () => MoonPayRequestSchema,
|
|
101
107
|
MoonPayResponseSchemaFor: () => MoonPayResponseSchemaFor,
|
|
@@ -533,6 +539,7 @@ var $orderStatus = import_zod.z.enum([
|
|
|
533
539
|
"ON_HOLD",
|
|
534
540
|
"CRYPTO_SENT",
|
|
535
541
|
"SETTLED",
|
|
542
|
+
"FINAL_ASSET_DELIVERED",
|
|
536
543
|
"EXPIRED",
|
|
537
544
|
"CANCELLED",
|
|
538
545
|
"FAILED",
|
|
@@ -1049,6 +1056,14 @@ var $termsErrorBody = obj({
|
|
|
1049
1056
|
recovery: import_zod.z.enum(["RETRY", "REQUOTE", "NONE"])
|
|
1050
1057
|
});
|
|
1051
1058
|
var FiatTermsErrorBodySchema = $termsErrorBody;
|
|
1059
|
+
var $destination = obj({
|
|
1060
|
+
chainId: import_zod.z.string().regex(/^[1-9]\d*$/, "must be a decimal chain id"),
|
|
1061
|
+
tokenAddress: import_zod.z.union([
|
|
1062
|
+
import_zod.z.string().regex(/^0x[0-9a-fA-F]{40}$/, "must be an EVM address"),
|
|
1063
|
+
import_zod.z.string().regex(/^[1-9A-HJ-NP-Za-km-z]{32,44}$/, "must be a Solana base58 address")
|
|
1064
|
+
])
|
|
1065
|
+
});
|
|
1066
|
+
var FiatDestinationSchema = $destination;
|
|
1052
1067
|
var $decimalAmount = import_zod.z.string().regex(/^(?:0|[1-9]\d*)(?:\.\d+)?$/, "must be a decimal string");
|
|
1053
1068
|
var compareDecimals = (left, right) => {
|
|
1054
1069
|
const [leftWhole = "", leftFraction = ""] = left.split(".");
|
|
@@ -1075,7 +1090,8 @@ var $routingTableRequest = obj({
|
|
|
1075
1090
|
region: $optionalGeoField,
|
|
1076
1091
|
// Duplicates are allowed; the response lists each method once.
|
|
1077
1092
|
methods: import_zod.z.array(import_zod.z.enum(PAYMENT_METHOD_CATEGORIES)).min(1),
|
|
1078
|
-
providers: $routingTableProviderInputs.optional()
|
|
1093
|
+
providers: $routingTableProviderInputs.optional(),
|
|
1094
|
+
destination: $destination.optional()
|
|
1079
1095
|
}).refine((request) => hasUsRegion(request.country, request.region), { message: US_REGION_REQUIRED, path: ["region"] });
|
|
1080
1096
|
var FiatRoutingTableRequestSchema = $routingTableRequest;
|
|
1081
1097
|
var $routingTableProvider = obj({
|
|
@@ -1120,7 +1136,8 @@ var $routingQuoteTermsShape = {
|
|
|
1120
1136
|
{ message: US_REGION_REQUIRED, path: ["region"] }
|
|
1121
1137
|
),
|
|
1122
1138
|
prepareSessionAuth: import_zod.z.boolean().optional(),
|
|
1123
|
-
routingOverrides: obj({ providers: import_zod.z.array($routingProvider) }).optional()
|
|
1139
|
+
routingOverrides: obj({ providers: import_zod.z.array($routingProvider) }).optional(),
|
|
1140
|
+
destination: $destination.optional()
|
|
1124
1141
|
};
|
|
1125
1142
|
var $routingQuoteTerms = obj($routingQuoteTermsShape);
|
|
1126
1143
|
var FiatRoutingQuoteTermsSchema = $routingQuoteTerms;
|
|
@@ -1176,7 +1193,7 @@ var $routingQuoteErrorBody = import_zod.z.union([$routingNoRouteErrorBody, $rout
|
|
|
1176
1193
|
var FiatRoutingQuoteErrorBodySchema = $routingQuoteErrorBody;
|
|
1177
1194
|
var $fiatGeo = obj({ alpha2: import_zod.z.string().regex(/^[A-Z]{2}$/), region: $nonBlank.optional(), ip: $nonBlank.optional() });
|
|
1178
1195
|
var FiatGeoSchema = $fiatGeo;
|
|
1179
|
-
var $nextRequest = import_zod.z.object({ provider: $provider, action: $nonBlank, geo: $fiatGeo }).catchall(import_zod.z.unknown());
|
|
1196
|
+
var $nextRequest = import_zod.z.object({ provider: $provider, action: $nonBlank, geo: $fiatGeo, destination: $destination.optional() }).catchall(import_zod.z.unknown());
|
|
1180
1197
|
var FiatNextRequestSchema = $nextRequest;
|
|
1181
1198
|
var $providerBoundStepResponse = obj({
|
|
1182
1199
|
state: $providerBoundFlowState,
|
|
@@ -1237,12 +1254,13 @@ var $stepResponse = import_zod.z.union([$providerBoundStepResponse, $blockedStep
|
|
|
1237
1254
|
var FiatStepResponseSchema = $stepResponse;
|
|
1238
1255
|
|
|
1239
1256
|
// package.json
|
|
1240
|
-
var version = "0.
|
|
1257
|
+
var version = "0.36.0-uda.0";
|
|
1241
1258
|
|
|
1242
1259
|
// src/table.ts
|
|
1243
1260
|
var TABLE_VERSION = version;
|
|
1244
1261
|
var TERMINAL_ORDER_STATUSES = [
|
|
1245
1262
|
"SETTLED",
|
|
1263
|
+
"FINAL_ASSET_DELIVERED",
|
|
1246
1264
|
"EXPIRED",
|
|
1247
1265
|
"CANCELLED",
|
|
1248
1266
|
"FAILED",
|
|
@@ -1628,6 +1646,7 @@ var TRANSITION_TABLE = {
|
|
|
1628
1646
|
"A terminal status may still carry a recovery transition: FAILED + retryable failureReason emits it (FE doc Screen 14); non-retryable emits [].",
|
|
1629
1647
|
"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.",
|
|
1630
1648
|
"CAPTURE_ORPHANED is non-terminal pending the backend rank map (added from review 2026-08-14).",
|
|
1649
|
+
"FINAL_ASSET_DELIVERED ends only an order whose request carried a destination. SETTLED stays in terminalStatuses for every other order, so a client that sent a destination keeps polling past SETTLED.",
|
|
1631
1650
|
"TODO(open-decision): contract OQ7 \u2014 under/over-payment is the biggest unenumerated branch."
|
|
1632
1651
|
]
|
|
1633
1652
|
}
|
|
@@ -2893,7 +2912,7 @@ var $checkout = obj2({
|
|
|
2893
2912
|
var MoonPayCheckoutSchema = $checkout;
|
|
2894
2913
|
var $credentials = obj2({ customerId: $nonEmpty, accessToken: $nonEmpty });
|
|
2895
2914
|
var MoonPaySdkCredentialsSchema = $credentials;
|
|
2896
|
-
var $context = { checkout: $checkout, credentials: $credentials.optional() };
|
|
2915
|
+
var $context = { checkout: $checkout, credentials: $credentials.optional(), destination: FiatDestinationSchema.optional() };
|
|
2897
2916
|
var $requestContext = obj2($context);
|
|
2898
2917
|
var MoonPayRequestContextSchema = $requestContext;
|
|
2899
2918
|
var $quoteInput = obj2({
|
|
@@ -2959,17 +2978,36 @@ var $connectNextAction = obj2({
|
|
|
2959
2978
|
quoteInput: $quoteInput,
|
|
2960
2979
|
resetConnection: import_zod2.z.literal(true).optional()
|
|
2961
2980
|
});
|
|
2962
|
-
var
|
|
2981
|
+
var CAPTURE_DOCUMENTS = ["IDENTITY_DOCUMENT", "SELFIE", "PROOF_OF_ADDRESS", "PROOF_OF_INCOME"];
|
|
2982
|
+
var $captureDocument = import_zod2.z.enum(CAPTURE_DOCUMENTS);
|
|
2983
|
+
var $reaskRequirement = import_zod2.z.union([KycFieldIdSchema, $captureDocument]);
|
|
2984
|
+
var $reaskReason = import_zod2.z.enum(["EXPIRED", "POOR_QUALITY", "MISMATCH", "REJECTED"]);
|
|
2985
|
+
var $reask = obj2({
|
|
2986
|
+
requirements: import_zod2.z.array($reaskRequirement).min(1).refine(hasUniqueIds2, "requirements must be unique"),
|
|
2987
|
+
reason: $reaskReason.nullable()
|
|
2988
|
+
});
|
|
2989
|
+
var $kycShape = obj2({
|
|
2990
|
+
next: import_zod2.z.literal("kyc"),
|
|
2991
|
+
fields: import_zod2.z.array(FormFieldSchema),
|
|
2992
|
+
fieldErrors: import_zod2.z.array($fieldError).min(1).optional(),
|
|
2993
|
+
reask: $reask.nullable()
|
|
2994
|
+
});
|
|
2963
2995
|
var $prepareCaptureNextAction = obj2({ next: import_zod2.z.literal("prepareCapture") });
|
|
2964
|
-
var $
|
|
2996
|
+
var $captureShape = obj2({
|
|
2965
2997
|
next: import_zod2.z.literal("capture"),
|
|
2966
2998
|
kycProvider: KYCProviderSchema,
|
|
2967
2999
|
accessToken: $nonEmpty,
|
|
2968
3000
|
expiresAt: import_zod2.z.string().datetime({ offset: true }),
|
|
2969
|
-
|
|
3001
|
+
reask: $reask.nullable()
|
|
2970
3002
|
});
|
|
2971
3003
|
var $waitNextAction = obj2({ next: import_zod2.z.literal("wait"), retryAfterMs: import_zod2.z.number().int().positive().max(6e4) });
|
|
2972
3004
|
var $orderNextAction = obj2({ next: import_zod2.z.literal("order"), orderId: $nonEmpty, quoteInput: $quoteInput });
|
|
3005
|
+
var $orderPendingNextAction = obj2({
|
|
3006
|
+
next: import_zod2.z.literal("orderPending"),
|
|
3007
|
+
orderId: $nonEmpty,
|
|
3008
|
+
retryAfterMs: import_zod2.z.number().int().positive().max(6e4),
|
|
3009
|
+
order: FiatStepResponseSchema.nullable()
|
|
3010
|
+
});
|
|
2973
3011
|
var checkConsent = (nextAction, context) => {
|
|
2974
3012
|
if (!hasUniqueIds2(nextAction.documents.map((document) => document.id))) {
|
|
2975
3013
|
context.addIssue({ code: "custom", path: ["documents"], message: "document ids must be unique" });
|
|
@@ -2986,20 +3024,35 @@ var checkKyc = (nextAction, context) => {
|
|
|
2986
3024
|
if (nextAction.fieldErrors?.some((error) => error.code && FIELD_OF_CODE[error.code] !== error.fieldId)) {
|
|
2987
3025
|
context.addIssue({ code: "custom", path: ["fieldErrors"], message: "a field error code must match its field" });
|
|
2988
3026
|
}
|
|
3027
|
+
if (nextAction.reask?.requirements.some((requirement) => !fieldIds.includes(requirement))) {
|
|
3028
|
+
context.addIssue({ code: "custom", path: ["reask"], message: "a kyc reask must name fields in this next action" });
|
|
3029
|
+
}
|
|
3030
|
+
};
|
|
3031
|
+
var isCaptureDocument = (requirement) => CAPTURE_DOCUMENTS.includes(requirement);
|
|
3032
|
+
var checkCapture = (nextAction, context) => {
|
|
3033
|
+
if (nextAction.reask?.requirements.some((requirement) => !isCaptureDocument(requirement))) {
|
|
3034
|
+
context.addIssue({ code: "custom", path: ["reask"], message: "a capture reask must name documents only" });
|
|
3035
|
+
}
|
|
2989
3036
|
};
|
|
2990
3037
|
var MoonPayConsentNextActionSchema = $consentShape.superRefine(checkConsent);
|
|
2991
3038
|
var MoonPaySessionNextActionSchema = $sessionNextAction;
|
|
2992
3039
|
var MoonPayConnectNextActionSchema = $connectNextAction;
|
|
2993
3040
|
var MoonPayKycNextActionSchema = $kycShape.superRefine(checkKyc);
|
|
2994
3041
|
var MoonPayPrepareCaptureNextActionSchema = $prepareCaptureNextAction;
|
|
2995
|
-
var
|
|
3042
|
+
var MoonPayCaptureDocumentSchema = $captureDocument;
|
|
3043
|
+
var MoonPayReaskRequirementSchema = $reaskRequirement;
|
|
3044
|
+
var MoonPayReaskReasonSchema = $reaskReason;
|
|
3045
|
+
var MoonPayReaskSchema = $reask;
|
|
3046
|
+
var MoonPayCaptureNextActionSchema = $captureShape.superRefine(checkCapture);
|
|
2996
3047
|
var MoonPayWaitNextActionSchema = $waitNextAction;
|
|
2997
3048
|
var MoonPayOrderNextActionSchema = $orderNextAction;
|
|
3049
|
+
var MoonPayOrderPendingNextActionSchema = $orderPendingNextAction;
|
|
2998
3050
|
var checkNextAction = (response, context) => {
|
|
2999
3051
|
if (response.next === "consent") checkConsent(response, context);
|
|
3000
3052
|
if (response.next === "kyc") checkKyc(response, context);
|
|
3053
|
+
if (response.next === "capture") checkCapture(response, context);
|
|
3001
3054
|
};
|
|
3002
|
-
var $nextActionOptions = [$consentShape, $sessionNextAction, $connectNextAction, $kycShape, $prepareCaptureNextAction, $
|
|
3055
|
+
var $nextActionOptions = [$consentShape, $sessionNextAction, $connectNextAction, $kycShape, $prepareCaptureNextAction, $captureShape, $waitNextAction, $orderNextAction];
|
|
3003
3056
|
var $nextAction = import_zod2.z.discriminatedUnion("next", [...$nextActionOptions]).superRefine(checkNextAction);
|
|
3004
3057
|
var MoonPayNextActionSchema = $nextAction;
|
|
3005
3058
|
var $done = obj2({ next: import_zod2.z.literal("done"), order: FiatStepResponseSchema });
|
|
@@ -3016,7 +3069,7 @@ var $orderRefused = obj2({
|
|
|
3016
3069
|
});
|
|
3017
3070
|
var $stepResponse2 = import_zod2.z.discriminatedUnion("next", [...$nextActionOptions, $stepRefused]).superRefine(checkNextAction);
|
|
3018
3071
|
var MoonPayStepResponseSchema = $stepResponse2;
|
|
3019
|
-
var $orderResponse = import_zod2.z.discriminatedUnion("next", [$done, $orderNextAction, $orderRefused]);
|
|
3072
|
+
var $orderResponse = import_zod2.z.discriminatedUnion("next", [$done, $orderNextAction, $orderPendingNextAction, $orderRefused]);
|
|
3020
3073
|
var MoonPayOrderResponseSchema = $orderResponse;
|
|
3021
3074
|
var MoonPayResponseSchemaFor = {
|
|
3022
3075
|
observe: MoonPayStepResponseSchema,
|
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-PWC3WN74.mjs";
|
|
16
16
|
import {
|
|
17
17
|
MOONPAY_ENDPOINTS
|
|
18
18
|
} from "./chunk-TIEGTTFY.mjs";
|
|
@@ -390,6 +390,7 @@ var $orderStatus = z.enum([
|
|
|
390
390
|
"ON_HOLD",
|
|
391
391
|
"CRYPTO_SENT",
|
|
392
392
|
"SETTLED",
|
|
393
|
+
"FINAL_ASSET_DELIVERED",
|
|
393
394
|
"EXPIRED",
|
|
394
395
|
"CANCELLED",
|
|
395
396
|
"FAILED",
|
|
@@ -906,6 +907,14 @@ var $termsErrorBody = obj({
|
|
|
906
907
|
recovery: z.enum(["RETRY", "REQUOTE", "NONE"])
|
|
907
908
|
});
|
|
908
909
|
var FiatTermsErrorBodySchema = $termsErrorBody;
|
|
910
|
+
var $destination = obj({
|
|
911
|
+
chainId: z.string().regex(/^[1-9]\d*$/, "must be a decimal chain id"),
|
|
912
|
+
tokenAddress: z.union([
|
|
913
|
+
z.string().regex(/^0x[0-9a-fA-F]{40}$/, "must be an EVM address"),
|
|
914
|
+
z.string().regex(/^[1-9A-HJ-NP-Za-km-z]{32,44}$/, "must be a Solana base58 address")
|
|
915
|
+
])
|
|
916
|
+
});
|
|
917
|
+
var FiatDestinationSchema = $destination;
|
|
909
918
|
var $decimalAmount = z.string().regex(/^(?:0|[1-9]\d*)(?:\.\d+)?$/, "must be a decimal string");
|
|
910
919
|
var compareDecimals = (left, right) => {
|
|
911
920
|
const [leftWhole = "", leftFraction = ""] = left.split(".");
|
|
@@ -932,7 +941,8 @@ var $routingTableRequest = obj({
|
|
|
932
941
|
region: $optionalGeoField,
|
|
933
942
|
// Duplicates are allowed; the response lists each method once.
|
|
934
943
|
methods: z.array(z.enum(PAYMENT_METHOD_CATEGORIES)).min(1),
|
|
935
|
-
providers: $routingTableProviderInputs.optional()
|
|
944
|
+
providers: $routingTableProviderInputs.optional(),
|
|
945
|
+
destination: $destination.optional()
|
|
936
946
|
}).refine((request) => hasUsRegion(request.country, request.region), { message: US_REGION_REQUIRED, path: ["region"] });
|
|
937
947
|
var FiatRoutingTableRequestSchema = $routingTableRequest;
|
|
938
948
|
var $routingTableProvider = obj({
|
|
@@ -977,7 +987,8 @@ var $routingQuoteTermsShape = {
|
|
|
977
987
|
{ message: US_REGION_REQUIRED, path: ["region"] }
|
|
978
988
|
),
|
|
979
989
|
prepareSessionAuth: z.boolean().optional(),
|
|
980
|
-
routingOverrides: obj({ providers: z.array($routingProvider) }).optional()
|
|
990
|
+
routingOverrides: obj({ providers: z.array($routingProvider) }).optional(),
|
|
991
|
+
destination: $destination.optional()
|
|
981
992
|
};
|
|
982
993
|
var $routingQuoteTerms = obj($routingQuoteTermsShape);
|
|
983
994
|
var FiatRoutingQuoteTermsSchema = $routingQuoteTerms;
|
|
@@ -1033,7 +1044,7 @@ var $routingQuoteErrorBody = z.union([$routingNoRouteErrorBody, $routingAmountEr
|
|
|
1033
1044
|
var FiatRoutingQuoteErrorBodySchema = $routingQuoteErrorBody;
|
|
1034
1045
|
var $fiatGeo = obj({ alpha2: z.string().regex(/^[A-Z]{2}$/), region: $nonBlank.optional(), ip: $nonBlank.optional() });
|
|
1035
1046
|
var FiatGeoSchema = $fiatGeo;
|
|
1036
|
-
var $nextRequest = z.object({ provider: $provider, action: $nonBlank, geo: $fiatGeo }).catchall(z.unknown());
|
|
1047
|
+
var $nextRequest = z.object({ provider: $provider, action: $nonBlank, geo: $fiatGeo, destination: $destination.optional() }).catchall(z.unknown());
|
|
1037
1048
|
var FiatNextRequestSchema = $nextRequest;
|
|
1038
1049
|
var $providerBoundStepResponse = obj({
|
|
1039
1050
|
state: $providerBoundFlowState,
|
|
@@ -2172,7 +2183,7 @@ var $checkout = obj2({
|
|
|
2172
2183
|
var MoonPayCheckoutSchema = $checkout;
|
|
2173
2184
|
var $credentials = obj2({ customerId: $nonEmpty, accessToken: $nonEmpty });
|
|
2174
2185
|
var MoonPaySdkCredentialsSchema = $credentials;
|
|
2175
|
-
var $context = { checkout: $checkout, credentials: $credentials.optional() };
|
|
2186
|
+
var $context = { checkout: $checkout, credentials: $credentials.optional(), destination: FiatDestinationSchema.optional() };
|
|
2176
2187
|
var $requestContext = obj2($context);
|
|
2177
2188
|
var MoonPayRequestContextSchema = $requestContext;
|
|
2178
2189
|
var $quoteInput = obj2({
|
|
@@ -2238,17 +2249,36 @@ var $connectNextAction = obj2({
|
|
|
2238
2249
|
quoteInput: $quoteInput,
|
|
2239
2250
|
resetConnection: z2.literal(true).optional()
|
|
2240
2251
|
});
|
|
2241
|
-
var
|
|
2252
|
+
var CAPTURE_DOCUMENTS = ["IDENTITY_DOCUMENT", "SELFIE", "PROOF_OF_ADDRESS", "PROOF_OF_INCOME"];
|
|
2253
|
+
var $captureDocument = z2.enum(CAPTURE_DOCUMENTS);
|
|
2254
|
+
var $reaskRequirement = z2.union([KycFieldIdSchema, $captureDocument]);
|
|
2255
|
+
var $reaskReason = z2.enum(["EXPIRED", "POOR_QUALITY", "MISMATCH", "REJECTED"]);
|
|
2256
|
+
var $reask = obj2({
|
|
2257
|
+
requirements: z2.array($reaskRequirement).min(1).refine(hasUniqueIds2, "requirements must be unique"),
|
|
2258
|
+
reason: $reaskReason.nullable()
|
|
2259
|
+
});
|
|
2260
|
+
var $kycShape = obj2({
|
|
2261
|
+
next: z2.literal("kyc"),
|
|
2262
|
+
fields: z2.array(FormFieldSchema),
|
|
2263
|
+
fieldErrors: z2.array($fieldError).min(1).optional(),
|
|
2264
|
+
reask: $reask.nullable()
|
|
2265
|
+
});
|
|
2242
2266
|
var $prepareCaptureNextAction = obj2({ next: z2.literal("prepareCapture") });
|
|
2243
|
-
var $
|
|
2267
|
+
var $captureShape = obj2({
|
|
2244
2268
|
next: z2.literal("capture"),
|
|
2245
2269
|
kycProvider: KYCProviderSchema,
|
|
2246
2270
|
accessToken: $nonEmpty,
|
|
2247
2271
|
expiresAt: z2.string().datetime({ offset: true }),
|
|
2248
|
-
|
|
2272
|
+
reask: $reask.nullable()
|
|
2249
2273
|
});
|
|
2250
2274
|
var $waitNextAction = obj2({ next: z2.literal("wait"), retryAfterMs: z2.number().int().positive().max(6e4) });
|
|
2251
2275
|
var $orderNextAction = obj2({ next: z2.literal("order"), orderId: $nonEmpty, quoteInput: $quoteInput });
|
|
2276
|
+
var $orderPendingNextAction = obj2({
|
|
2277
|
+
next: z2.literal("orderPending"),
|
|
2278
|
+
orderId: $nonEmpty,
|
|
2279
|
+
retryAfterMs: z2.number().int().positive().max(6e4),
|
|
2280
|
+
order: FiatStepResponseSchema.nullable()
|
|
2281
|
+
});
|
|
2252
2282
|
var checkConsent = (nextAction, context) => {
|
|
2253
2283
|
if (!hasUniqueIds2(nextAction.documents.map((document) => document.id))) {
|
|
2254
2284
|
context.addIssue({ code: "custom", path: ["documents"], message: "document ids must be unique" });
|
|
@@ -2265,20 +2295,35 @@ var checkKyc = (nextAction, context) => {
|
|
|
2265
2295
|
if (nextAction.fieldErrors?.some((error) => error.code && FIELD_OF_CODE[error.code] !== error.fieldId)) {
|
|
2266
2296
|
context.addIssue({ code: "custom", path: ["fieldErrors"], message: "a field error code must match its field" });
|
|
2267
2297
|
}
|
|
2298
|
+
if (nextAction.reask?.requirements.some((requirement) => !fieldIds.includes(requirement))) {
|
|
2299
|
+
context.addIssue({ code: "custom", path: ["reask"], message: "a kyc reask must name fields in this next action" });
|
|
2300
|
+
}
|
|
2301
|
+
};
|
|
2302
|
+
var isCaptureDocument = (requirement) => CAPTURE_DOCUMENTS.includes(requirement);
|
|
2303
|
+
var checkCapture = (nextAction, context) => {
|
|
2304
|
+
if (nextAction.reask?.requirements.some((requirement) => !isCaptureDocument(requirement))) {
|
|
2305
|
+
context.addIssue({ code: "custom", path: ["reask"], message: "a capture reask must name documents only" });
|
|
2306
|
+
}
|
|
2268
2307
|
};
|
|
2269
2308
|
var MoonPayConsentNextActionSchema = $consentShape.superRefine(checkConsent);
|
|
2270
2309
|
var MoonPaySessionNextActionSchema = $sessionNextAction;
|
|
2271
2310
|
var MoonPayConnectNextActionSchema = $connectNextAction;
|
|
2272
2311
|
var MoonPayKycNextActionSchema = $kycShape.superRefine(checkKyc);
|
|
2273
2312
|
var MoonPayPrepareCaptureNextActionSchema = $prepareCaptureNextAction;
|
|
2274
|
-
var
|
|
2313
|
+
var MoonPayCaptureDocumentSchema = $captureDocument;
|
|
2314
|
+
var MoonPayReaskRequirementSchema = $reaskRequirement;
|
|
2315
|
+
var MoonPayReaskReasonSchema = $reaskReason;
|
|
2316
|
+
var MoonPayReaskSchema = $reask;
|
|
2317
|
+
var MoonPayCaptureNextActionSchema = $captureShape.superRefine(checkCapture);
|
|
2275
2318
|
var MoonPayWaitNextActionSchema = $waitNextAction;
|
|
2276
2319
|
var MoonPayOrderNextActionSchema = $orderNextAction;
|
|
2320
|
+
var MoonPayOrderPendingNextActionSchema = $orderPendingNextAction;
|
|
2277
2321
|
var checkNextAction = (response, context) => {
|
|
2278
2322
|
if (response.next === "consent") checkConsent(response, context);
|
|
2279
2323
|
if (response.next === "kyc") checkKyc(response, context);
|
|
2324
|
+
if (response.next === "capture") checkCapture(response, context);
|
|
2280
2325
|
};
|
|
2281
|
-
var $nextActionOptions = [$consentShape, $sessionNextAction, $connectNextAction, $kycShape, $prepareCaptureNextAction, $
|
|
2326
|
+
var $nextActionOptions = [$consentShape, $sessionNextAction, $connectNextAction, $kycShape, $prepareCaptureNextAction, $captureShape, $waitNextAction, $orderNextAction];
|
|
2282
2327
|
var $nextAction = z2.discriminatedUnion("next", [...$nextActionOptions]).superRefine(checkNextAction);
|
|
2283
2328
|
var MoonPayNextActionSchema = $nextAction;
|
|
2284
2329
|
var $done = obj2({ next: z2.literal("done"), order: FiatStepResponseSchema });
|
|
@@ -2295,7 +2340,7 @@ var $orderRefused = obj2({
|
|
|
2295
2340
|
});
|
|
2296
2341
|
var $stepResponse2 = z2.discriminatedUnion("next", [...$nextActionOptions, $stepRefused]).superRefine(checkNextAction);
|
|
2297
2342
|
var MoonPayStepResponseSchema = $stepResponse2;
|
|
2298
|
-
var $orderResponse = z2.discriminatedUnion("next", [$done, $orderNextAction, $orderRefused]);
|
|
2343
|
+
var $orderResponse = z2.discriminatedUnion("next", [$done, $orderNextAction, $orderPendingNextAction, $orderRefused]);
|
|
2299
2344
|
var MoonPayOrderResponseSchema = $orderResponse;
|
|
2300
2345
|
var MoonPayResponseSchemaFor = {
|
|
2301
2346
|
observe: MoonPayStepResponseSchema,
|
|
@@ -2344,6 +2389,7 @@ export {
|
|
|
2344
2389
|
FeeLineSchema,
|
|
2345
2390
|
FiatAmountSchema,
|
|
2346
2391
|
FiatCurrencyCode,
|
|
2392
|
+
FiatDestinationSchema,
|
|
2347
2393
|
FiatEndpointSchema,
|
|
2348
2394
|
FiatGeoSchema,
|
|
2349
2395
|
FiatNextRequestSchema,
|
|
@@ -2378,6 +2424,7 @@ export {
|
|
|
2378
2424
|
KycReviewDurationSchema,
|
|
2379
2425
|
KycSdkResultReportSchema,
|
|
2380
2426
|
MOONPAY_ENDPOINTS,
|
|
2427
|
+
MoonPayCaptureDocumentSchema,
|
|
2381
2428
|
MoonPayCaptureNextActionSchema,
|
|
2382
2429
|
MoonPayCaptureRequestSchema,
|
|
2383
2430
|
MoonPayCheckoutSchema,
|
|
@@ -2394,11 +2441,15 @@ export {
|
|
|
2394
2441
|
MoonPayNextRequestSchema,
|
|
2395
2442
|
MoonPayObserveRequestSchema,
|
|
2396
2443
|
MoonPayOrderNextActionSchema,
|
|
2444
|
+
MoonPayOrderPendingNextActionSchema,
|
|
2397
2445
|
MoonPayOrderRequestSchema,
|
|
2398
2446
|
MoonPayOrderResponseSchema,
|
|
2399
2447
|
MoonPayPrepareCaptureNextActionSchema,
|
|
2400
2448
|
MoonPayPrepareCaptureRequestSchema,
|
|
2401
2449
|
MoonPayQuoteInputSchema,
|
|
2450
|
+
MoonPayReaskReasonSchema,
|
|
2451
|
+
MoonPayReaskRequirementSchema,
|
|
2452
|
+
MoonPayReaskSchema,
|
|
2402
2453
|
MoonPayRequestContextSchema,
|
|
2403
2454
|
MoonPayRequestSchema,
|
|
2404
2455
|
MoonPayResponseSchemaFor,
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* the client needs to do it. The client's request names it in `action` and carries the result. Every
|
|
6
6
|
* response is the next action, `done`, or `refused` (`MoonPayResponseFor`). `observe` carries no
|
|
7
7
|
* result and answers the current next action. `wait` has no request: the client sends `observe` after it.
|
|
8
|
+
* `orderPending` answers only `order` and has no request either: the client sends the same `order` after it.
|
|
8
9
|
*
|
|
9
10
|
* The body is `MoonPayNextRequest`: `provider`, the shared `geo`, the context (`checkout`, and
|
|
10
11
|
* `credentials` after `connect`), and the action's result. Identity and the deposit wallet always
|
|
@@ -20,7 +21,7 @@
|
|
|
20
21
|
*/
|
|
21
22
|
import type { FiatCurrencyCode } from '../codes';
|
|
22
23
|
import type { FiatTermsRequest, TermsDocument } from '../terms';
|
|
23
|
-
import type { FiatAmount, FiatGeo, FiatStepResponse, FormField, KYCProvider, KycFieldId, KycSdkResultReport } from '../types';
|
|
24
|
+
import type { FiatAmount, FiatDestination, FiatGeo, FiatStepResponse, FormField, KYCProvider, KycFieldId, KycSdkResultReport } from '../types';
|
|
24
25
|
export declare const MOONPAY_ENDPOINTS: {
|
|
25
26
|
readonly next: "POST /fiat/next";
|
|
26
27
|
};
|
|
@@ -40,10 +41,14 @@ export interface MoonPaySdkCredentials {
|
|
|
40
41
|
customerId: string;
|
|
41
42
|
accessToken: string;
|
|
42
43
|
}
|
|
43
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* On every request, not part of the result. `credentials` is present after `connect`.
|
|
46
|
+
* `destination` is the asset the user receives at the end; `checkout.destination` stays the quote's.
|
|
47
|
+
*/
|
|
44
48
|
export type MoonPayRequestContext = {
|
|
45
49
|
checkout: MoonPayCheckout;
|
|
46
50
|
credentials?: MoonPaySdkCredentials;
|
|
51
|
+
destination?: FiatDestination;
|
|
47
52
|
};
|
|
48
53
|
/**
|
|
49
54
|
* The parameters for the device `client.getQuote`, not a quote. The backend builds them because the
|
|
@@ -124,11 +129,13 @@ export interface MoonPayFieldError {
|
|
|
124
129
|
/**
|
|
125
130
|
* Show the shared form. Empty `fields` means nothing for the buyer to type: the client sends
|
|
126
131
|
* `{ action: 'kyc', values: {} }` at once and the backend shares the KYC data it already holds.
|
|
132
|
+
* `reask` names fields of this form the buyer gave before and MoonPay asks for again; `null` otherwise.
|
|
127
133
|
*/
|
|
128
134
|
export type MoonPayKycNextAction = {
|
|
129
135
|
next: 'kyc';
|
|
130
136
|
fields: FormField[];
|
|
131
137
|
fieldErrors?: MoonPayFieldError[];
|
|
138
|
+
reask: MoonPayReask | null;
|
|
132
139
|
};
|
|
133
140
|
/**
|
|
134
141
|
* Keyed by the ids of the next action's fields; there is no form id. `values` is empty when the next
|
|
@@ -151,9 +158,29 @@ export type MoonPayPrepareCaptureRequest = {
|
|
|
151
158
|
action: 'prepareCapture';
|
|
152
159
|
credentials: MoonPaySdkCredentials;
|
|
153
160
|
};
|
|
161
|
+
/** A document the Sumsub SDK captures for MoonPay. No shared type names documents, so this one does. */
|
|
162
|
+
export type MoonPayCaptureDocument = 'IDENTITY_DOCUMENT' | 'SELFIE' | 'PROOF_OF_ADDRESS' | 'PROOF_OF_INCOME';
|
|
163
|
+
/** What a re-ask names: a declarative value by its `KycFieldId`, or a captured document. */
|
|
164
|
+
export type MoonPayReaskRequirement = KycFieldId | MoonPayCaptureDocument;
|
|
165
|
+
/**
|
|
166
|
+
* Why a re-ask asks again, as a code: the backend sends no display text, and the client owns every word.
|
|
167
|
+
* `EXPIRED`: the document on file is too old. `POOR_QUALITY`: the upload could not be read. `MISMATCH`: the
|
|
168
|
+
* data or the selfie does not match. `REJECTED`: any other retryable rejection. Treat an unknown code like
|
|
169
|
+
* `null`: adding a code is a minor contract change.
|
|
170
|
+
*/
|
|
171
|
+
export type MoonPayReaskReason = 'EXPIRED' | 'POOR_QUALITY' | 'MISMATCH' | 'REJECTED';
|
|
172
|
+
/**
|
|
173
|
+
* Something the buyer gave before is asked again: `requirements`, never empty, on the `kyc` form or in the
|
|
174
|
+
* `capture`. One shape for every cause, so the client shows each the same way and may ignore `reason`
|
|
175
|
+
* (`null` when there is no code). Not `fieldErrors`: those check the value this request just submitted.
|
|
176
|
+
*/
|
|
177
|
+
export type MoonPayReask = {
|
|
178
|
+
requirements: MoonPayReaskRequirement[];
|
|
179
|
+
reason: MoonPayReaskReason | null;
|
|
180
|
+
};
|
|
154
181
|
/**
|
|
155
182
|
* Open the Sumsub SDK with `accessToken` to capture what MoonPay still needs (an ID, a selfie, a
|
|
156
|
-
* proof of address). `
|
|
183
|
+
* proof of address). `reask` is `null` on a first capture; on a retake it names documents only. To refresh
|
|
157
184
|
* an expired token, send `observe`.
|
|
158
185
|
*/
|
|
159
186
|
export type MoonPayCaptureNextAction = {
|
|
@@ -162,7 +189,7 @@ export type MoonPayCaptureNextAction = {
|
|
|
162
189
|
accessToken: string;
|
|
163
190
|
/** ISO-8601. */
|
|
164
191
|
expiresAt: string;
|
|
165
|
-
|
|
192
|
+
reask: MoonPayReask | null;
|
|
166
193
|
};
|
|
167
194
|
/** When the SDK closes. A report only: the backend reads Sumsub itself. */
|
|
168
195
|
export type MoonPayCaptureRequest = {
|
|
@@ -192,6 +219,18 @@ export type MoonPayOrderRequest = {
|
|
|
192
219
|
quotedAmount: FiatAmount;
|
|
193
220
|
transactionId?: string;
|
|
194
221
|
};
|
|
222
|
+
/**
|
|
223
|
+
* The charge is made or in flight and its order is not terminal yet. `order` is the order's current body
|
|
224
|
+
* (status, and the settlement transaction once observed) for the client to show, or `null` while MoonPay
|
|
225
|
+
* does not list or price the charge and no order exists yet. Do not mount Apple Pay. After `retryAfterMs`,
|
|
226
|
+
* send the same `order` request again: each one reads MoonPay and moves the order forward.
|
|
227
|
+
*/
|
|
228
|
+
export type MoonPayOrderPendingNextAction = {
|
|
229
|
+
next: 'orderPending';
|
|
230
|
+
orderId: string;
|
|
231
|
+
retryAfterMs: number;
|
|
232
|
+
order: FiatStepResponse | null;
|
|
233
|
+
};
|
|
195
234
|
export type MoonPayRequest = MoonPayRequestContext & (MoonPayObserveRequest | MoonPayConsentRequest | MoonPaySessionRequest | MoonPayConnectRequest | MoonPayKycRequest | MoonPayPrepareCaptureRequest | MoonPayCaptureRequest | MoonPayOrderRequest);
|
|
196
235
|
/** The wire body. The orchestrator reads `provider` and `geo`; MoonPay's action schemas read the rest. */
|
|
197
236
|
export type MoonPayNextRequest = {
|
|
@@ -211,7 +250,7 @@ export type MoonPayStepRefusal = 'NOT_ELIGIBLE' | 'DOCUMENTS_REQUIRED' | 'FINAL_
|
|
|
211
250
|
*/
|
|
212
251
|
export type MoonPayOrderRefusal = 'CUSTOMER_MISMATCH' | 'WALLET_MISMATCH' | 'UNRECORDABLE';
|
|
213
252
|
export type MoonPayNextAction = MoonPayConsentNextAction | MoonPaySessionNextAction | MoonPayConnectNextAction | MoonPayKycNextAction | MoonPayPrepareCaptureNextAction | MoonPayCaptureNextAction | MoonPayWaitNextAction | MoonPayOrderNextAction;
|
|
214
|
-
/**
|
|
253
|
+
/** The order is terminal. `order` is its body, which the shared order screen renders; nothing is left to poll. */
|
|
215
254
|
export type MoonPayDone = {
|
|
216
255
|
next: 'done';
|
|
217
256
|
order: FiatStepResponse;
|
|
@@ -225,11 +264,13 @@ export type MoonPayRefused<R, V> = {
|
|
|
225
264
|
/** The answer to `observe`, `consent`, `session`, `connect`, `kyc`, `prepareCapture` and `capture`. */
|
|
226
265
|
export type MoonPayStepResponse = MoonPayNextAction | MoonPayRefused<MoonPayStepRefusal, 'REQUOTE' | 'NONE'>;
|
|
227
266
|
/**
|
|
228
|
-
* The answer to `order`. A failed charge is recorded too: `done` with
|
|
229
|
-
* client requotes for a new `orderId`. `
|
|
230
|
-
*
|
|
267
|
+
* The answer to `order`. `done` once the order is terminal. A failed charge is recorded too: `done` with
|
|
268
|
+
* the order in `FAILED`, and the client requotes for a new `orderId`. `orderPending` while the order is
|
|
269
|
+
* not terminal, or MoonPay does not list or price the transaction yet: the client polls by sending the
|
|
270
|
+
* same `order` request, never `GET /fiat/orders/:orderId`. A refusal after a charge never requotes:
|
|
271
|
+
* that would start a second payment.
|
|
231
272
|
*/
|
|
232
|
-
export type MoonPayOrderResponse = MoonPayDone | MoonPayOrderNextAction | MoonPayRefused<MoonPayOrderRefusal, 'NONE'>;
|
|
273
|
+
export type MoonPayOrderResponse = MoonPayDone | MoonPayOrderNextAction | MoonPayOrderPendingNextAction | MoonPayRefused<MoonPayOrderRefusal, 'NONE'>;
|
|
233
274
|
export type MoonPayResponseFor = {
|
|
234
275
|
observe: MoonPayStepResponse;
|
|
235
276
|
consent: MoonPayStepResponse;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* exported from the package root, never from `./moonpay`, so the production entry stays free of zod.
|
|
4
4
|
*/
|
|
5
5
|
import { z } from 'zod';
|
|
6
|
-
import type { MoonPayCaptureNextAction, MoonPayCaptureRequest, MoonPayCheckout, MoonPayConnectNextAction, MoonPayConnectRequest, MoonPayConsentNextAction, MoonPayConsentRequest, MoonPayDone, MoonPayErrorBody, MoonPayFault, MoonPayKycNextAction, MoonPayKycRequest, MoonPayNextRequest, MoonPayObserveRequest, MoonPayOrderNextAction, MoonPayOrderRequest, MoonPayOrderResponse, MoonPayPrepareCaptureNextAction, MoonPayPrepareCaptureRequest, MoonPayNextAction, MoonPayQuoteInput, MoonPayRequest, MoonPayRequestContext, MoonPayResponseFor, MoonPaySdkCredentials, MoonPaySessionNextAction, MoonPaySessionRequest, MoonPayStepResponse, MoonPayWaitNextAction } from './moonpay';
|
|
6
|
+
import type { MoonPayCaptureDocument, MoonPayCaptureNextAction, MoonPayCaptureRequest, MoonPayCheckout, MoonPayConnectNextAction, MoonPayConnectRequest, MoonPayConsentNextAction, MoonPayConsentRequest, MoonPayDone, MoonPayErrorBody, MoonPayFault, MoonPayKycNextAction, MoonPayKycRequest, MoonPayNextRequest, MoonPayObserveRequest, MoonPayOrderNextAction, MoonPayOrderPendingNextAction, MoonPayOrderRequest, MoonPayOrderResponse, MoonPayPrepareCaptureNextAction, MoonPayPrepareCaptureRequest, MoonPayReask, MoonPayReaskReason, MoonPayReaskRequirement, MoonPayNextAction, MoonPayQuoteInput, MoonPayRequest, MoonPayRequestContext, MoonPayResponseFor, MoonPaySdkCredentials, MoonPaySessionNextAction, MoonPaySessionRequest, MoonPayStepResponse, MoonPayWaitNextAction } from './moonpay';
|
|
7
7
|
export declare const MoonPayCheckoutSchema: z.ZodType<MoonPayCheckout>;
|
|
8
8
|
export declare const MoonPaySdkCredentialsSchema: z.ZodType<MoonPaySdkCredentials>;
|
|
9
9
|
export declare const MoonPayRequestContextSchema: z.ZodType<MoonPayRequestContext>;
|
|
@@ -23,9 +23,14 @@ export declare const MoonPaySessionNextActionSchema: z.ZodType<MoonPaySessionNex
|
|
|
23
23
|
export declare const MoonPayConnectNextActionSchema: z.ZodType<MoonPayConnectNextAction>;
|
|
24
24
|
export declare const MoonPayKycNextActionSchema: z.ZodType<MoonPayKycNextAction>;
|
|
25
25
|
export declare const MoonPayPrepareCaptureNextActionSchema: z.ZodType<MoonPayPrepareCaptureNextAction>;
|
|
26
|
+
export declare const MoonPayCaptureDocumentSchema: z.ZodType<MoonPayCaptureDocument>;
|
|
27
|
+
export declare const MoonPayReaskRequirementSchema: z.ZodType<MoonPayReaskRequirement>;
|
|
28
|
+
export declare const MoonPayReaskReasonSchema: z.ZodType<MoonPayReaskReason>;
|
|
29
|
+
export declare const MoonPayReaskSchema: z.ZodType<MoonPayReask>;
|
|
26
30
|
export declare const MoonPayCaptureNextActionSchema: z.ZodType<MoonPayCaptureNextAction>;
|
|
27
31
|
export declare const MoonPayWaitNextActionSchema: z.ZodType<MoonPayWaitNextAction>;
|
|
28
32
|
export declare const MoonPayOrderNextActionSchema: z.ZodType<MoonPayOrderNextAction>;
|
|
33
|
+
export declare const MoonPayOrderPendingNextActionSchema: z.ZodType<MoonPayOrderPendingNextAction>;
|
|
29
34
|
export declare const MoonPayNextActionSchema: z.ZodType<MoonPayNextAction>;
|
|
30
35
|
export declare const MoonPayDoneSchema: z.ZodType<MoonPayDone>;
|
|
31
36
|
export declare const MoonPayStepResponseSchema: z.ZodType<MoonPayStepResponse>;
|
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, FiatProvider, QuoteLimitRange } from './types';
|
|
24
|
+
import type { FiatAmount, 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,6 +55,8 @@ export interface FiatRoutingTableRequest {
|
|
|
55
55
|
methods: PaymentMethodCategory[];
|
|
56
56
|
/** Optional provider-specific inputs. */
|
|
57
57
|
providers?: FiatRoutingTableProviderInputs;
|
|
58
|
+
/** The asset the user receives, when it differs from `cryptoCurrencyCode` on `chainId`. */
|
|
59
|
+
destination?: FiatDestination;
|
|
58
60
|
}
|
|
59
61
|
/** What a provider needs from this buyer before it can take the payment. */
|
|
60
62
|
export type RoutingNextStep = 'READY' | 'AUTH' | 'DECLARATIVE_KYC' | 'DOCUMENTARY_KYC' | 'PENDING_REVIEW';
|
|
@@ -127,6 +129,8 @@ export interface FiatRoutingQuoteTerms {
|
|
|
127
129
|
routingOverrides?: {
|
|
128
130
|
providers: RoutingProvider[];
|
|
129
131
|
};
|
|
132
|
+
/** The asset the user receives, when it differs from `cryptoCurrencyCode` on `chainId`. */
|
|
133
|
+
destination?: FiatDestination;
|
|
130
134
|
}
|
|
131
135
|
/**
|
|
132
136
|
* `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, FiatGeo, FiatNextRequest } from './types';
|
|
31
|
+
import type { BlockedReason, CryptoAmount, FailureReason, FeeLine, FiatAmount, FiatEndpoint, FiatProvider, FiatStepResponse, FieldSpec, FlowState, FormDescriptor, FormField, FormFieldType, InstructionField, Instructions, Instrument, JsonValue, KYCProvider, KycReviewDuration, OrderRef, OrderStatus, OrderSummary, PollSpec, PreparedPayment, PaymentSurface, Quote, QuoteLimitRange, QuoteLimits, Recovery, Refund, ReportSpec, SelectOption, StatusHistoryEntry, Surface, PreferredIdentityDocument, KycFieldId, ClientExecutedDelivery, KycSdkResultReport, SurfaceKind, SurfaceProvider, TermsAcceptance, Transition, TransitionInputs, TransitionParams, Tx, FiatDestination, 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>;
|
|
@@ -113,6 +113,7 @@ export declare const TermsDocumentAcceptanceSchema: z.ZodType<TermsDocumentAccep
|
|
|
113
113
|
export declare const FiatTermsRequestSchema: z.ZodType<FiatTermsRequest>;
|
|
114
114
|
export declare const FiatTermsResponseSchema: z.ZodType<FiatTermsResponse>;
|
|
115
115
|
export declare const FiatTermsErrorBodySchema: z.ZodType<FiatTermsErrorBody>;
|
|
116
|
+
export declare const FiatDestinationSchema: z.ZodType<FiatDestination>;
|
|
116
117
|
export declare const FiatRoutingTableRequestSchema: z.ZodType<FiatRoutingTableRequest>;
|
|
117
118
|
export declare const FiatRoutingTableResponseSchema: z.ZodType<FiatRoutingTableResponse>;
|
|
118
119
|
export declare const FiatRoutingQuoteTermsSchema: z.ZodType<FiatRoutingQuoteTerms>;
|
package/dist/table.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ export type StateKey = 'QUOTE' | 'FUN_AUTH' | 'SESSION_AUTH' | 'KYC/CAPTURE' | '
|
|
|
39
39
|
* is over stops polling and the order silently strands, whereas one that keeps polling lets the
|
|
40
40
|
* reconciler resolve it. Revisit when the backend publishes its rank map.
|
|
41
41
|
*/
|
|
42
|
-
export declare const TERMINAL_ORDER_STATUSES: readonly ["SETTLED", "EXPIRED", "CANCELLED", "FAILED", "REFUNDED"];
|
|
42
|
+
export declare const TERMINAL_ORDER_STATUSES: readonly ["SETTLED", "FINAL_ASSET_DELIVERED", "EXPIRED", "CANCELLED", "FAILED", "REFUNDED"];
|
|
43
43
|
export type TerminalOrderStatus = (typeof TERMINAL_ORDER_STATUSES)[number];
|
|
44
44
|
/**
|
|
45
45
|
* Endpoint template as written in the docs. Named `:` segments match one emitted path segment.
|
package/dist/table.js
CHANGED
|
@@ -36,12 +36,13 @@ __export(table_exports, {
|
|
|
36
36
|
module.exports = __toCommonJS(table_exports);
|
|
37
37
|
|
|
38
38
|
// package.json
|
|
39
|
-
var version = "0.
|
|
39
|
+
var version = "0.36.0-uda.0";
|
|
40
40
|
|
|
41
41
|
// src/table.ts
|
|
42
42
|
var TABLE_VERSION = version;
|
|
43
43
|
var TERMINAL_ORDER_STATUSES = [
|
|
44
44
|
"SETTLED",
|
|
45
|
+
"FINAL_ASSET_DELIVERED",
|
|
45
46
|
"EXPIRED",
|
|
46
47
|
"CANCELLED",
|
|
47
48
|
"FAILED",
|
|
@@ -427,6 +428,7 @@ var TRANSITION_TABLE = {
|
|
|
427
428
|
"A terminal status may still carry a recovery transition: FAILED + retryable failureReason emits it (FE doc Screen 14); non-retryable emits [].",
|
|
428
429
|
"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
430
|
"CAPTURE_ORPHANED is non-terminal pending the backend rank map (added from review 2026-08-14).",
|
|
431
|
+
"FINAL_ASSET_DELIVERED ends only an order whose request carried a destination. SETTLED stays in terminalStatuses for every other order, so a client that sent a destination keeps polling past SETTLED.",
|
|
430
432
|
"TODO(open-decision): contract OQ7 \u2014 under/over-payment is the biggest unenumerated branch."
|
|
431
433
|
]
|
|
432
434
|
}
|
package/dist/table.mjs
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -74,7 +74,17 @@ export type FiatProvider = 'TRANSAK' | 'SWAPPED' | 'BANXA' | 'MOONPAY' | 'STRIPE
|
|
|
74
74
|
* client's job (Jeremy, same thread) — the FE may collapse several of these into one visual state,
|
|
75
75
|
* but the contract does not pre-collapse them.
|
|
76
76
|
*/
|
|
77
|
-
export type OrderStatus = 'CREATING' | 'AWAITING_PAYMENT' | 'PAYMENT_VERIFYING' | 'PROCESSING' | 'PENDING_DELIVERY' | 'ON_HOLD' | 'CRYPTO_SENT'
|
|
77
|
+
export type OrderStatus = 'CREATING' | 'AWAITING_PAYMENT' | 'PAYMENT_VERIFYING' | 'PROCESSING' | 'PENDING_DELIVERY' | 'ON_HOLD' | 'CRYPTO_SENT'
|
|
78
|
+
/**
|
|
79
|
+
* The provider's crypto reached the deposit address. Final for an order whose request carried no
|
|
80
|
+
* `destination`. With a `destination`, the swap into it is still running.
|
|
81
|
+
*/
|
|
82
|
+
| 'SETTLED'
|
|
83
|
+
/**
|
|
84
|
+
* The destination asset reached the user's wallet. Only an order whose request carried a
|
|
85
|
+
* `destination` shows it; every other order ends at `SETTLED`, as before.
|
|
86
|
+
*/
|
|
87
|
+
| 'FINAL_ASSET_DELIVERED' | 'EXPIRED' | 'CANCELLED' | 'FAILED' | 'REFUNDED'
|
|
78
88
|
/**
|
|
79
89
|
* A capture that never became an order — the pull-rail orphan (contract Flow A's
|
|
80
90
|
* capture-then-order topology: the component yields a `requestId`, then `createOrder` runs).
|
|
@@ -741,6 +751,18 @@ export type FiatStepResponse = (FiatStepResponseBase & {
|
|
|
741
751
|
provider: FiatProvider;
|
|
742
752
|
};
|
|
743
753
|
});
|
|
754
|
+
/**
|
|
755
|
+
* The asset the user receives at the end of the purchase. Optional on every request that can lead
|
|
756
|
+
* the backend to pick a deposit address. When it differs from the asset the provider delivers, the
|
|
757
|
+
* backend pays a deposit address that swaps into it. The recipient always comes from the verified
|
|
758
|
+
* partner assertion, never from this field.
|
|
759
|
+
*/
|
|
760
|
+
export interface FiatDestination {
|
|
761
|
+
/** Decimal, as the routing requests send it: `"8453"`, Solana `"1151111081099710"`. */
|
|
762
|
+
chainId: string;
|
|
763
|
+
/** An EVM `0x` address (40 hex digits) or a Solana base58 mint. */
|
|
764
|
+
tokenAddress: string;
|
|
765
|
+
}
|
|
744
766
|
/** The geo endpoint's response, sent on every `/next` request. `alpha2` is ISO 3166-1 alpha-2. */
|
|
745
767
|
export type FiatGeo = {
|
|
746
768
|
alpha2: string;
|
|
@@ -748,12 +770,14 @@ export type FiatGeo = {
|
|
|
748
770
|
ip?: string;
|
|
749
771
|
};
|
|
750
772
|
/**
|
|
751
|
-
* The body of every `POST /fiat/next`: `provider`, `geo`,
|
|
752
|
-
* names its `action`. Each provider defines its actions and their
|
|
773
|
+
* The body of every `POST /fiat/next`: `provider`, `geo`, the optional `destination`, and the
|
|
774
|
+
* provider's own request, which names its `action`. Each provider defines its actions and their
|
|
775
|
+
* fields (`./moonpay`).
|
|
753
776
|
*/
|
|
754
777
|
export type FiatNextRequest = {
|
|
755
778
|
provider: FiatProvider;
|
|
756
779
|
action: string;
|
|
757
780
|
geo: FiatGeo;
|
|
781
|
+
destination?: FiatDestination;
|
|
758
782
|
} & Record<string, unknown>;
|
|
759
783
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fun-xyz/fiat-contract",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.36.0-uda.0",
|
|
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": {
|