@klappay/types 3.0.1 → 3.1.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/README.md +22 -2
- package/dist/chunk-KZ3646WX.mjs +109 -0
- package/dist/chunk-KZ3646WX.mjs.map +1 -0
- package/dist/constants-DQGVNS9O.d.mts +41 -0
- package/dist/constants-DQGVNS9O.d.ts +41 -0
- package/dist/constants.d.mts +2 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +143 -0
- package/dist/constants.js.map +1 -0
- package/dist/constants.mjs +23 -0
- package/dist/constants.mjs.map +1 -0
- package/dist/index.d.mts +46 -32
- package/dist/index.d.ts +46 -32
- package/dist/index.js +47 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -90
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
export { A as ALT_TOKEN_ADDRESSES, a as ALT_TOKEN_DECIMALS, b as AltToken, c as AltTokenSchema, C as CHAIN_IDS, E as EVM_NETWORKS, d as Environment, e as EnvironmentSchema, f as EvmNetwork, N as NETWORK_EXPLORERS, g as NETWORK_LABELS, h as Network, i as NetworkSchema, O as OPERATIONAL_NETWORKS, j as OperationalNetwork, S as SwapAlternative, k as SwapAlternativeSchema, T as TOKEN_ADDRESSES, l as TOKEN_DECIMALS, m as Token, n as TokenSchema, o as listSwapAlternatives } from './constants-DQGVNS9O.js';
|
|
2
3
|
|
|
3
4
|
declare const ErrorPayloadSchema: z.ZodObject<{
|
|
4
5
|
error: z.ZodObject<{
|
|
@@ -29,24 +30,12 @@ declare const ErrorPayloadSchema: z.ZodObject<{
|
|
|
29
30
|
}>;
|
|
30
31
|
type ErrorPayload = z.infer<typeof ErrorPayloadSchema>;
|
|
31
32
|
|
|
32
|
-
declare const EnvironmentSchema: z.ZodEnum<["live", "test"]>;
|
|
33
|
-
type Environment = z.infer<typeof EnvironmentSchema>;
|
|
34
|
-
|
|
35
33
|
declare const ApiKeyScopeSchema: z.ZodEnum<["charges:read", "charges:write", "webhooks:read", "webhooks:write", "webhooks:manage_secret", "metrics:read", "metrics:charges:read", "metrics:transactions:read", "metrics:distributions:read", "sandbox:trigger", "charges:split_write", "recipients:read", "recipients:write", "recipients:manage_payout"]>;
|
|
36
34
|
type ApiKeyScope = z.infer<typeof ApiKeyScopeSchema>;
|
|
37
35
|
declare const API_KEY_SCOPES: ["charges:read", "charges:write", "webhooks:read", "webhooks:write", "webhooks:manage_secret", "metrics:read", "metrics:charges:read", "metrics:transactions:read", "metrics:distributions:read", "sandbox:trigger", "charges:split_write", "recipients:read", "recipients:write", "recipients:manage_payout"];
|
|
38
36
|
declare const CONFLICTING_SCOPE_PAIRS: ReadonlyArray<readonly [ApiKeyScope, ApiKeyScope]>;
|
|
39
37
|
declare function findConflictingScopes(scopes: readonly ApiKeyScope[]): readonly [ApiKeyScope, ApiKeyScope] | null;
|
|
40
38
|
|
|
41
|
-
declare const NetworkSchema: z.ZodEnum<["base", "optimism", "polygon", "ethereum", "arbitrum", "avalanche", "bnb"]>;
|
|
42
|
-
type Network = z.infer<typeof NetworkSchema>;
|
|
43
|
-
declare const NETWORK_LABELS: Record<Network, string>;
|
|
44
|
-
declare const NETWORK_EXPLORERS: Record<Network, string>;
|
|
45
|
-
declare const EVM_NETWORKS: readonly ["base", "optimism", "polygon", "ethereum", "arbitrum", "avalanche", "bnb"];
|
|
46
|
-
type EvmNetwork = (typeof EVM_NETWORKS)[number];
|
|
47
|
-
declare const OPERATIONAL_NETWORKS: readonly ["base", "arbitrum", "optimism", "polygon", "ethereum", "avalanche", "bnb"];
|
|
48
|
-
type OperationalNetwork = (typeof OPERATIONAL_NETWORKS)[number];
|
|
49
|
-
|
|
50
39
|
declare const PAGINATION_LIMIT_MIN = 1;
|
|
51
40
|
declare const PAGINATION_LIMIT_MAX = 100;
|
|
52
41
|
declare const PAGINATION_LIMIT_DEFAULT = 20;
|
|
@@ -76,17 +65,6 @@ declare function paginatedSchema<T extends z.ZodTypeAny>(itemSchema: T): z.ZodOb
|
|
|
76
65
|
hasMore: boolean;
|
|
77
66
|
}>;
|
|
78
67
|
|
|
79
|
-
declare const TokenSchema: z.ZodEnum<["USDC", "USDT"]>;
|
|
80
|
-
type Token = z.infer<typeof TokenSchema>;
|
|
81
|
-
declare const TOKEN_DECIMALS = 6;
|
|
82
|
-
declare const TOKEN_ADDRESSES: Record<Token, Partial<Record<Network, Partial<Record<Environment, `0x${string}`>>>>>;
|
|
83
|
-
|
|
84
|
-
declare const AltTokenSchema: z.ZodEnum<["ETH", "BNB", "MATIC", "AVAX", "BTC"]>;
|
|
85
|
-
type AltToken = z.infer<typeof AltTokenSchema>;
|
|
86
|
-
declare const ALT_TOKEN_DECIMALS: Record<AltToken, number>;
|
|
87
|
-
declare const ALT_TOKEN_ADDRESSES: Record<Network, Partial<Record<AltToken, 'native' | `0x${string}`>>>;
|
|
88
|
-
declare function listAltTokensForNetworks(networks: readonly Network[]): AltToken[];
|
|
89
|
-
|
|
90
68
|
declare const ChargeStatusSchema: z.ZodEnum<["pending", "partially_paid", "confirmed", "expired", "underpaid"]>;
|
|
91
69
|
type ChargeStatus = z.infer<typeof ChargeStatusSchema>;
|
|
92
70
|
declare const SettlementStatusSchema: z.ZodEnum<["pending", "completed", "failed"]>;
|
|
@@ -386,7 +364,16 @@ declare const ChargeSchema: z.ZodObject<{
|
|
|
386
364
|
token: "USDC" | "USDT";
|
|
387
365
|
network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
|
|
388
366
|
}>, "many">;
|
|
389
|
-
swapAlternatives: z.ZodArray<z.
|
|
367
|
+
swapAlternatives: z.ZodArray<z.ZodObject<{
|
|
368
|
+
token: z.ZodEnum<["ETH", "BNB", "MATIC", "AVAX", "BTC"]>;
|
|
369
|
+
network: z.ZodEnum<["base", "optimism", "polygon", "ethereum", "arbitrum", "avalanche", "bnb"]>;
|
|
370
|
+
}, "strip", z.ZodTypeAny, {
|
|
371
|
+
token: "ETH" | "BNB" | "MATIC" | "AVAX" | "BTC";
|
|
372
|
+
network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
|
|
373
|
+
}, {
|
|
374
|
+
token: "ETH" | "BNB" | "MATIC" | "AVAX" | "BTC";
|
|
375
|
+
network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
|
|
376
|
+
}>, "many">;
|
|
390
377
|
address: z.ZodString;
|
|
391
378
|
status: z.ZodEnum<["pending", "partially_paid", "confirmed", "expired", "underpaid"]>;
|
|
392
379
|
settlementStatus: z.ZodNullable<z.ZodEnum<["pending", "completed", "failed"]>>;
|
|
@@ -553,7 +540,10 @@ declare const ChargeSchema: z.ZodObject<{
|
|
|
553
540
|
token: "USDC" | "USDT";
|
|
554
541
|
network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
|
|
555
542
|
}[];
|
|
556
|
-
swapAlternatives:
|
|
543
|
+
swapAlternatives: {
|
|
544
|
+
token: "ETH" | "BNB" | "MATIC" | "AVAX" | "BTC";
|
|
545
|
+
network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
|
|
546
|
+
}[];
|
|
557
547
|
settlementStatus: "pending" | "completed" | "failed" | null;
|
|
558
548
|
environment: "live" | "test";
|
|
559
549
|
apiKeyId: string | null;
|
|
@@ -617,7 +607,10 @@ declare const ChargeSchema: z.ZodObject<{
|
|
|
617
607
|
token: "USDC" | "USDT";
|
|
618
608
|
network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
|
|
619
609
|
}[];
|
|
620
|
-
swapAlternatives:
|
|
610
|
+
swapAlternatives: {
|
|
611
|
+
token: "ETH" | "BNB" | "MATIC" | "AVAX" | "BTC";
|
|
612
|
+
network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
|
|
613
|
+
}[];
|
|
621
614
|
settlementStatus: "pending" | "completed" | "failed" | null;
|
|
622
615
|
environment: "live" | "test";
|
|
623
616
|
apiKeyId: string | null;
|
|
@@ -688,7 +681,16 @@ declare const PaginatedChargesSchema: z.ZodObject<{
|
|
|
688
681
|
token: "USDC" | "USDT";
|
|
689
682
|
network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
|
|
690
683
|
}>, "many">;
|
|
691
|
-
swapAlternatives: z.ZodArray<z.
|
|
684
|
+
swapAlternatives: z.ZodArray<z.ZodObject<{
|
|
685
|
+
token: z.ZodEnum<["ETH", "BNB", "MATIC", "AVAX", "BTC"]>;
|
|
686
|
+
network: z.ZodEnum<["base", "optimism", "polygon", "ethereum", "arbitrum", "avalanche", "bnb"]>;
|
|
687
|
+
}, "strip", z.ZodTypeAny, {
|
|
688
|
+
token: "ETH" | "BNB" | "MATIC" | "AVAX" | "BTC";
|
|
689
|
+
network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
|
|
690
|
+
}, {
|
|
691
|
+
token: "ETH" | "BNB" | "MATIC" | "AVAX" | "BTC";
|
|
692
|
+
network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
|
|
693
|
+
}>, "many">;
|
|
692
694
|
address: z.ZodString;
|
|
693
695
|
status: z.ZodEnum<["pending", "partially_paid", "confirmed", "expired", "underpaid"]>;
|
|
694
696
|
settlementStatus: z.ZodNullable<z.ZodEnum<["pending", "completed", "failed"]>>;
|
|
@@ -855,7 +857,10 @@ declare const PaginatedChargesSchema: z.ZodObject<{
|
|
|
855
857
|
token: "USDC" | "USDT";
|
|
856
858
|
network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
|
|
857
859
|
}[];
|
|
858
|
-
swapAlternatives:
|
|
860
|
+
swapAlternatives: {
|
|
861
|
+
token: "ETH" | "BNB" | "MATIC" | "AVAX" | "BTC";
|
|
862
|
+
network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
|
|
863
|
+
}[];
|
|
859
864
|
settlementStatus: "pending" | "completed" | "failed" | null;
|
|
860
865
|
environment: "live" | "test";
|
|
861
866
|
apiKeyId: string | null;
|
|
@@ -919,7 +924,10 @@ declare const PaginatedChargesSchema: z.ZodObject<{
|
|
|
919
924
|
token: "USDC" | "USDT";
|
|
920
925
|
network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
|
|
921
926
|
}[];
|
|
922
|
-
swapAlternatives:
|
|
927
|
+
swapAlternatives: {
|
|
928
|
+
token: "ETH" | "BNB" | "MATIC" | "AVAX" | "BTC";
|
|
929
|
+
network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
|
|
930
|
+
}[];
|
|
923
931
|
settlementStatus: "pending" | "completed" | "failed" | null;
|
|
924
932
|
environment: "live" | "test";
|
|
925
933
|
apiKeyId: string | null;
|
|
@@ -987,7 +995,10 @@ declare const PaginatedChargesSchema: z.ZodObject<{
|
|
|
987
995
|
token: "USDC" | "USDT";
|
|
988
996
|
network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
|
|
989
997
|
}[];
|
|
990
|
-
swapAlternatives:
|
|
998
|
+
swapAlternatives: {
|
|
999
|
+
token: "ETH" | "BNB" | "MATIC" | "AVAX" | "BTC";
|
|
1000
|
+
network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
|
|
1001
|
+
}[];
|
|
991
1002
|
settlementStatus: "pending" | "completed" | "failed" | null;
|
|
992
1003
|
environment: "live" | "test";
|
|
993
1004
|
apiKeyId: string | null;
|
|
@@ -1055,7 +1066,10 @@ declare const PaginatedChargesSchema: z.ZodObject<{
|
|
|
1055
1066
|
token: "USDC" | "USDT";
|
|
1056
1067
|
network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
|
|
1057
1068
|
}[];
|
|
1058
|
-
swapAlternatives:
|
|
1069
|
+
swapAlternatives: {
|
|
1070
|
+
token: "ETH" | "BNB" | "MATIC" | "AVAX" | "BTC";
|
|
1071
|
+
network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
|
|
1072
|
+
}[];
|
|
1059
1073
|
settlementStatus: "pending" | "completed" | "failed" | null;
|
|
1060
1074
|
environment: "live" | "test";
|
|
1061
1075
|
apiKeyId: string | null;
|
|
@@ -2621,4 +2635,4 @@ declare const SwapQuoteSchema: z.ZodObject<{
|
|
|
2621
2635
|
}>;
|
|
2622
2636
|
type SwapQuote = z.infer<typeof SwapQuoteSchema>;
|
|
2623
2637
|
|
|
2624
|
-
export {
|
|
2638
|
+
export { API_KEY_SCOPES, type AcceptedPayment, AcceptedPaymentSchema, type ApiKeyScope, ApiKeyScopeSchema, CHARGE_ACCEPTED_PAYMENTS_MAX, CHARGE_AMOUNT_MAX, CHARGE_EXPIRES_IN_MAX_SECONDS, CHARGE_EXPIRES_IN_MIN_SECONDS, CHARGE_SPLIT_RECIPIENTS_MAX, CHECKOUT_PRODUCTS_MAX, CONFLICTING_SCOPE_PAIRS, type Capabilities, CapabilitiesSchema, type Charge, ChargeSchema, type ChargeStatus, ChargeStatusSchema, ChargeWebhookEventTypeSchema, type ChargesDateField, ChargesDateFieldSchema, type ChargesMetricField, ChargesMetricFieldSchema, type ChargesQueryField, ChargesQueryFieldSchema, type CheckoutProduct, CheckoutProductSchema, type CreateChargeInput, type CreateChargeRequest, CreateChargeSchema, type CreateRecipientInput, type CreateRecipientRequest, CreateRecipientSchema, type CreateSwapQuoteInput, CreateSwapQuoteSchema, type CreateWebhookInput, type CreateWebhookRequest, CreateWebhookSchema, type DistributionsDateField, DistributionsDateFieldSchema, type DistributionsMetricField, DistributionsMetricFieldSchema, type DistributionsQueryField, DistributionsQueryFieldSchema, EVENT_CATEGORY_MAP, type ErrorPayload, ErrorPayloadSchema, type GetChargeQrCodeQuery, type GetChargeQrCodeQueryRequest, GetChargeQrCodeQuerySchema, type Health, HealthSchema, type KlappayCheckoutMetadata, KlappayCheckoutMetadataSchema, type ListChargesInput, type ListChargesRequest, ListChargesSchema, type ListWebhookDeliveriesInput, type ListWebhookDeliveriesRequest, ListWebhookDeliveriesSchema, type ListenPendingDistributionsQuery, ListenPendingDistributionsQuerySchema, MAX_METRICS_QUERY_DATE_RANGE_DAYS, METRICS_QUERY_DEFAULT_ROW_LIMIT, METRICS_QUERY_MAX_FILTERS, METRICS_QUERY_MAX_GROUP_BY, METRICS_QUERY_MAX_METRICS, METRICS_QUERY_MAX_ROW_LIMIT, MetadataWithKlappaySchema, type MetricsAggregation, MetricsAggregationSchema, type MetricsDateGranularity, MetricsDateGranularitySchema, type MetricsFilterOperator, MetricsFilterOperatorSchema, type MetricsQuery, type MetricsQueryRequest, type MetricsQueryResult, type MetricsQueryResultRow, MetricsQueryResultRowSchema, MetricsQueryResultSchema, MetricsQuerySchema, type MetricsResource, MetricsResourceSchema, PAGINATION_LIMIT_DEFAULT, PAGINATION_LIMIT_MAX, PAGINATION_LIMIT_MIN, type PaginatedCharges, PaginatedChargesSchema, type PaginatedPendingDistributions, PaginatedPendingDistributionsSchema, type PaginatedWebhookDeliveries, PaginatedWebhookDeliveriesSchema, type PaginationQuery, type PaginationQueryRequest, PaginationQuerySchema, type PendingDistribution, type PendingDistributionEvent, PendingDistributionEventSchema, PendingDistributionRecipientSchema, PendingDistributionSchema, type Recipient, RecipientSchema, type SandboxTriggerInput, SandboxTriggerSchema, type SetRecipientPayoutInput, SetRecipientPayoutSchema, type SettlementStatus, SettlementStatusSchema, type SplitDistributionStatus, SplitDistributionStatusSchema, type SplitRecipient, type SplitRecipientInput, SplitRecipientInputSchema, SplitRecipientSchema, type SwapQuote, SwapQuoteSchema, type TimelineEvent, TimelineEventSchema, type TimelineEventType, TimelineEventTypeSchema, type TransactionSource, TransactionSourceSchema, type TransactionsDateField, TransactionsDateFieldSchema, type TransactionsMetricField, TransactionsMetricFieldSchema, type TransactionsQueryField, TransactionsQueryFieldSchema, type TriggerableChargeEvent, TriggerableChargeEventSchema, type TypedWebhookPayload, WEBHOOK_EVENTS_WILDCARD, WEBHOOK_EVENT_CATEGORIES, type Webhook, type WebhookCategory, WebhookCategorySchema, type WebhookDelivery, WebhookDeliveryEventTypeSchema, WebhookDeliverySchema, type WebhookDeliveryStatus, WebhookDeliveryStatusSchema, type WebhookEventDataMap, type WebhookEventType, WebhookEventTypeSchema, type WebhookHealthEventData, type WebhookListItem, WebhookListItemSchema, type WebhookPayload, WebhookPayloadSchema, WebhookSchema, findConflictingScopes, paginatedSchema };
|
package/dist/index.js
CHANGED
|
@@ -26,6 +26,7 @@ __export(index_exports, {
|
|
|
26
26
|
AcceptedPaymentSchema: () => AcceptedPaymentSchema,
|
|
27
27
|
AltTokenSchema: () => AltTokenSchema,
|
|
28
28
|
ApiKeyScopeSchema: () => ApiKeyScopeSchema,
|
|
29
|
+
CHAIN_IDS: () => CHAIN_IDS,
|
|
29
30
|
CHARGE_ACCEPTED_PAYMENTS_MAX: () => CHARGE_ACCEPTED_PAYMENTS_MAX,
|
|
30
31
|
CHARGE_AMOUNT_MAX: () => CHARGE_AMOUNT_MAX,
|
|
31
32
|
CHARGE_EXPIRES_IN_MAX_SECONDS: () => CHARGE_EXPIRES_IN_MAX_SECONDS,
|
|
@@ -93,6 +94,7 @@ __export(index_exports, {
|
|
|
93
94
|
SplitDistributionStatusSchema: () => SplitDistributionStatusSchema,
|
|
94
95
|
SplitRecipientInputSchema: () => SplitRecipientInputSchema,
|
|
95
96
|
SplitRecipientSchema: () => SplitRecipientSchema,
|
|
97
|
+
SwapAlternativeSchema: () => SwapAlternativeSchema,
|
|
96
98
|
SwapQuoteSchema: () => SwapQuoteSchema,
|
|
97
99
|
TOKEN_ADDRESSES: () => TOKEN_ADDRESSES,
|
|
98
100
|
TOKEN_DECIMALS: () => TOKEN_DECIMALS,
|
|
@@ -115,7 +117,7 @@ __export(index_exports, {
|
|
|
115
117
|
WebhookPayloadSchema: () => WebhookPayloadSchema,
|
|
116
118
|
WebhookSchema: () => WebhookSchema,
|
|
117
119
|
findConflictingScopes: () => findConflictingScopes,
|
|
118
|
-
|
|
120
|
+
listSwapAlternatives: () => listSwapAlternatives,
|
|
119
121
|
paginatedSchema: () => paginatedSchema
|
|
120
122
|
});
|
|
121
123
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -175,7 +177,8 @@ function findConflictingScopes(scopes) {
|
|
|
175
177
|
|
|
176
178
|
// src/networks.ts
|
|
177
179
|
var import_zod4 = require("zod");
|
|
178
|
-
|
|
180
|
+
|
|
181
|
+
// src/networks.constants.ts
|
|
179
182
|
var NETWORK_LABELS = {
|
|
180
183
|
base: "Base",
|
|
181
184
|
optimism: "Optimism",
|
|
@@ -212,6 +215,18 @@ var OPERATIONAL_NETWORKS = [
|
|
|
212
215
|
"avalanche",
|
|
213
216
|
"bnb"
|
|
214
217
|
];
|
|
218
|
+
var CHAIN_IDS = {
|
|
219
|
+
base: { live: 8453, test: 84532 },
|
|
220
|
+
optimism: { live: 10, test: 11155420 },
|
|
221
|
+
ethereum: { live: 1, test: 11155111 },
|
|
222
|
+
polygon: { live: 137 },
|
|
223
|
+
arbitrum: { live: 42161 },
|
|
224
|
+
avalanche: { live: 43114 },
|
|
225
|
+
bnb: { live: 56 }
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
// src/networks.ts
|
|
229
|
+
var NetworkSchema = import_zod4.z.enum(["base", "optimism", "polygon", "ethereum", "arbitrum", "avalanche", "bnb"]).describe("The blockchain a charge/payment is on.");
|
|
215
230
|
|
|
216
231
|
// src/pagination.ts
|
|
217
232
|
var import_zod5 = require("zod");
|
|
@@ -236,9 +251,8 @@ function paginatedSchema(itemSchema) {
|
|
|
236
251
|
|
|
237
252
|
// src/tokens.ts
|
|
238
253
|
var import_zod6 = require("zod");
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
);
|
|
254
|
+
|
|
255
|
+
// src/tokens.constants.ts
|
|
242
256
|
var TOKEN_DECIMALS = 6;
|
|
243
257
|
var TOKEN_ADDRESSES = {
|
|
244
258
|
USDC: {
|
|
@@ -270,11 +284,15 @@ var TOKEN_ADDRESSES = {
|
|
|
270
284
|
}
|
|
271
285
|
};
|
|
272
286
|
|
|
287
|
+
// src/tokens.ts
|
|
288
|
+
var TokenSchema = import_zod6.z.enum(["USDC", "USDT"]).describe(
|
|
289
|
+
`Which stablecoin the payer will send. Support depends on both \`network\` and \`environment\` \u2014 not every token/network/environment combination is deployed; today, both \`USDC\` and \`USDT\` are deployed on every operational network's \`live\` side except BNB Chain (\`${OPERATIONAL_NETWORKS.join(", ")}\`), but \`test\` coverage varies per network \u2014 Base, Optimism, and Ethereum each have a \`test\` environment (\`USDC\` only; none has an official Sepolia USDT), Arbitrum, Polygon, Avalanche, and BNB Chain have none yet (0xSplits hasn't deployed on Arbitrum Sepolia and has no Polygon, Avalanche Fuji, or BNB testnet support at all). An unconfigured combination is rejected with \`422 token_not_supported\`, not silently accepted. **BNB Chain's \`USDC\` address is Binance-Peg USDC, not an official Circle deployment** \u2014 Circle does not issue native USDC on BNB Chain at all; this is a Binance-custodied, 1:1-pegged BEP-20 token, a materially different trust model than every other \`TOKEN_ADDRESSES\` entry (all verified directly against their real issuer). Accepted at the payer's own risk \u2014 Klappay does not verify or guarantee Binance's collateral backing it. \`USDT\` on BNB Chain is Tether's own official issuance, same trust model as everywhere else. More tokens/networks are expected to be added over time \u2014 check \`TOKEN_ADDRESSES\` in \`@klappay/types\` (or a future \`GET /v1/networks\` capabilities endpoint) for the exact current matrix rather than assuming full coverage.`
|
|
290
|
+
);
|
|
291
|
+
|
|
273
292
|
// src/alt-tokens.ts
|
|
274
293
|
var import_zod7 = require("zod");
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
);
|
|
294
|
+
|
|
295
|
+
// src/alt-tokens.constants.ts
|
|
278
296
|
var ALT_TOKEN_DECIMALS = {
|
|
279
297
|
ETH: 18,
|
|
280
298
|
BNB: 18,
|
|
@@ -291,14 +309,25 @@ var ALT_TOKEN_ADDRESSES = {
|
|
|
291
309
|
avalanche: { AVAX: "native" },
|
|
292
310
|
bnb: { BNB: "native" }
|
|
293
311
|
};
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
312
|
+
|
|
313
|
+
// src/alt-tokens.ts
|
|
314
|
+
var AltTokenSchema = import_zod7.z.enum(["ETH", "BNB", "MATIC", "AVAX", "BTC"]).describe(
|
|
315
|
+
"A non-stablecoin cryptocurrency Klappay trusts as swap input for a charge, via the 0x Swap API \u2014 swapped to one of the charge's `acceptedPayments` tokens before it ever reaches the merchant, so the merchant always receives USDC/USDT regardless of what the payer sent. Only a network's own native currency, plus `BTC` (wrapped) on the networks with deep, reputably-custodied liquidity, is trusted today (see `ALT_TOKEN_ADDRESSES`) \u2014 never assume every value here is available on every network."
|
|
316
|
+
);
|
|
317
|
+
var SwapAlternativeSchema = import_zod7.z.object({
|
|
318
|
+
token: AltTokenSchema,
|
|
319
|
+
network: NetworkSchema.describe(
|
|
320
|
+
"Which network to send `token` on \u2014 pass both as `inputToken`/`inputNetwork` to `POST /v1/charges/{id}/quote`. The same token can appear more than once here, once per network that trusts it and that this charge accepts payment on."
|
|
321
|
+
)
|
|
322
|
+
});
|
|
323
|
+
function listSwapAlternatives(networks) {
|
|
324
|
+
const alternatives = [];
|
|
325
|
+
for (const network of new Set(networks)) {
|
|
297
326
|
for (const token of Object.keys(ALT_TOKEN_ADDRESSES[network] ?? {})) {
|
|
298
|
-
|
|
327
|
+
alternatives.push({ token, network });
|
|
299
328
|
}
|
|
300
329
|
}
|
|
301
|
-
return
|
|
330
|
+
return alternatives;
|
|
302
331
|
}
|
|
303
332
|
|
|
304
333
|
// src/charges.ts
|
|
@@ -439,8 +468,8 @@ var ChargeSchema = import_zod9.z.object({
|
|
|
439
468
|
paidWith: import_zod9.z.array(AcceptedPaymentSchema).describe(
|
|
440
469
|
"Every distinct `(token, network)` pair that has actually contributed a credited transfer so far \u2014 empty until the first one arrives. Can hold more than one entry: a charge accepting several pairs can be paid across a combination of them, and every entry here sums toward `amountReceived`."
|
|
441
470
|
),
|
|
442
|
-
swapAlternatives: import_zod9.z.array(
|
|
443
|
-
"
|
|
471
|
+
swapAlternatives: import_zod9.z.array(SwapAlternativeSchema).describe(
|
|
472
|
+
"Every `(token, network)` pair the payer can pay with instead, via `POST /v1/charges/{id}/quote` \u2014 derived from the networks in `acceptedPayments` (e.g. a charge accepting USDC on both Base and Optimism lists `ETH` on Base and `ETH` on Optimism separately, since they're different networks the payer has to choose between, not one merged option). Pass an entry's `token`/`network` straight through as `inputToken`/`inputNetwork`. Recomputed on every read against Klappay's current trusted list, not frozen at creation \u2014 empty if this charge's networks have no trusted alt-token, if swap-to-pay isn't configured on this deployment, or if `environment` is `test` (0x, who powers the swap, has no testnet support at all \u2014 `POST /v1/charges/{id}/quote` always rejects a test-environment charge with `422 swap_test_environment_unsupported`)."
|
|
444
473
|
),
|
|
445
474
|
address: import_zod9.z.string().describe(
|
|
446
475
|
"The on-chain address the payer must send funds to \u2014 identical across every accepted network (0xSplits addresses are chain-agnostic). Unique per charge, predicted at creation time \u2014 funds sent here go directly to the merchant, Klappay never custodies them."
|
|
@@ -1059,6 +1088,7 @@ var SwapQuoteSchema = import_zod19.z.object({
|
|
|
1059
1088
|
AcceptedPaymentSchema,
|
|
1060
1089
|
AltTokenSchema,
|
|
1061
1090
|
ApiKeyScopeSchema,
|
|
1091
|
+
CHAIN_IDS,
|
|
1062
1092
|
CHARGE_ACCEPTED_PAYMENTS_MAX,
|
|
1063
1093
|
CHARGE_AMOUNT_MAX,
|
|
1064
1094
|
CHARGE_EXPIRES_IN_MAX_SECONDS,
|
|
@@ -1126,6 +1156,7 @@ var SwapQuoteSchema = import_zod19.z.object({
|
|
|
1126
1156
|
SplitDistributionStatusSchema,
|
|
1127
1157
|
SplitRecipientInputSchema,
|
|
1128
1158
|
SplitRecipientSchema,
|
|
1159
|
+
SwapAlternativeSchema,
|
|
1129
1160
|
SwapQuoteSchema,
|
|
1130
1161
|
TOKEN_ADDRESSES,
|
|
1131
1162
|
TOKEN_DECIMALS,
|
|
@@ -1148,7 +1179,7 @@ var SwapQuoteSchema = import_zod19.z.object({
|
|
|
1148
1179
|
WebhookPayloadSchema,
|
|
1149
1180
|
WebhookSchema,
|
|
1150
1181
|
findConflictingScopes,
|
|
1151
|
-
|
|
1182
|
+
listSwapAlternatives,
|
|
1152
1183
|
paginatedSchema
|
|
1153
1184
|
});
|
|
1154
1185
|
//# sourceMappingURL=index.js.map
|