@klappay/types 4.1.0 → 5.0.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/index.d.ts CHANGED
@@ -1,5 +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_DEPLOYMENTS, n as Token, o as TokenDeployment, p as TokenSchema, q as getTokenDeployment, r as isPaymentDeploymentEnabled, s as listSwapAlternatives } from './constants-021Ybu31.js';
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_DEPLOYMENTS, n as Token, o as TokenDeployment, p as TokenSchema, q as getTokenDeployment, r as isPaymentDeploymentEnabled, s as listSwapAlternatives } from './constants-Di4Qr6af.js';
3
3
 
4
4
  declare const ErrorPayloadSchema: z.ZodObject<{
5
5
  error: z.ZodObject<{
@@ -390,13 +390,13 @@ declare const ChargeSchema: z.ZodObject<{
390
390
  network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
391
391
  }>, "many">;
392
392
  swapAlternatives: z.ZodArray<z.ZodObject<{
393
- token: z.ZodEnum<["ETH", "BNB", "MATIC", "AVAX", "BTC"]>;
393
+ token: z.ZodEnum<["ETH", "BNB", "POL", "AVAX", "BTC", "LINK", "ARB", "OP", "CBETH"]>;
394
394
  network: z.ZodEnum<["base", "optimism", "polygon", "ethereum", "arbitrum", "avalanche", "bnb"]>;
395
395
  }, "strip", z.ZodTypeAny, {
396
- token: "ETH" | "BNB" | "MATIC" | "AVAX" | "BTC";
396
+ token: "ETH" | "BNB" | "POL" | "AVAX" | "BTC" | "LINK" | "ARB" | "OP" | "CBETH";
397
397
  network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
398
398
  }, {
399
- token: "ETH" | "BNB" | "MATIC" | "AVAX" | "BTC";
399
+ token: "ETH" | "BNB" | "POL" | "AVAX" | "BTC" | "LINK" | "ARB" | "OP" | "CBETH";
400
400
  network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
401
401
  }>, "many">;
402
402
  address: z.ZodString;
@@ -588,7 +588,7 @@ declare const ChargeSchema: z.ZodObject<{
588
588
  network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
589
589
  }[];
590
590
  swapAlternatives: {
591
- token: "ETH" | "BNB" | "MATIC" | "AVAX" | "BTC";
591
+ token: "ETH" | "BNB" | "POL" | "AVAX" | "BTC" | "LINK" | "ARB" | "OP" | "CBETH";
592
592
  network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
593
593
  }[];
594
594
  settlementStatus: "pending" | "completed" | "failed" | null;
@@ -667,7 +667,7 @@ declare const ChargeSchema: z.ZodObject<{
667
667
  network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
668
668
  }[];
669
669
  swapAlternatives: {
670
- token: "ETH" | "BNB" | "MATIC" | "AVAX" | "BTC";
670
+ token: "ETH" | "BNB" | "POL" | "AVAX" | "BTC" | "LINK" | "ARB" | "OP" | "CBETH";
671
671
  network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
672
672
  }[];
673
673
  settlementStatus: "pending" | "completed" | "failed" | null;
@@ -751,13 +751,13 @@ declare const PaginatedChargesSchema: z.ZodObject<{
751
751
  network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
752
752
  }>, "many">;
753
753
  swapAlternatives: z.ZodArray<z.ZodObject<{
754
- token: z.ZodEnum<["ETH", "BNB", "MATIC", "AVAX", "BTC"]>;
754
+ token: z.ZodEnum<["ETH", "BNB", "POL", "AVAX", "BTC", "LINK", "ARB", "OP", "CBETH"]>;
755
755
  network: z.ZodEnum<["base", "optimism", "polygon", "ethereum", "arbitrum", "avalanche", "bnb"]>;
756
756
  }, "strip", z.ZodTypeAny, {
757
- token: "ETH" | "BNB" | "MATIC" | "AVAX" | "BTC";
757
+ token: "ETH" | "BNB" | "POL" | "AVAX" | "BTC" | "LINK" | "ARB" | "OP" | "CBETH";
758
758
  network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
759
759
  }, {
760
- token: "ETH" | "BNB" | "MATIC" | "AVAX" | "BTC";
760
+ token: "ETH" | "BNB" | "POL" | "AVAX" | "BTC" | "LINK" | "ARB" | "OP" | "CBETH";
761
761
  network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
762
762
  }>, "many">;
763
763
  address: z.ZodString;
@@ -949,7 +949,7 @@ declare const PaginatedChargesSchema: z.ZodObject<{
949
949
  network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
950
950
  }[];
951
951
  swapAlternatives: {
952
- token: "ETH" | "BNB" | "MATIC" | "AVAX" | "BTC";
952
+ token: "ETH" | "BNB" | "POL" | "AVAX" | "BTC" | "LINK" | "ARB" | "OP" | "CBETH";
953
953
  network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
954
954
  }[];
955
955
  settlementStatus: "pending" | "completed" | "failed" | null;
@@ -1028,7 +1028,7 @@ declare const PaginatedChargesSchema: z.ZodObject<{
1028
1028
  network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
1029
1029
  }[];
1030
1030
  swapAlternatives: {
1031
- token: "ETH" | "BNB" | "MATIC" | "AVAX" | "BTC";
1031
+ token: "ETH" | "BNB" | "POL" | "AVAX" | "BTC" | "LINK" | "ARB" | "OP" | "CBETH";
1032
1032
  network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
1033
1033
  }[];
1034
1034
  settlementStatus: "pending" | "completed" | "failed" | null;
@@ -1111,7 +1111,7 @@ declare const PaginatedChargesSchema: z.ZodObject<{
1111
1111
  network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
1112
1112
  }[];
1113
1113
  swapAlternatives: {
1114
- token: "ETH" | "BNB" | "MATIC" | "AVAX" | "BTC";
1114
+ token: "ETH" | "BNB" | "POL" | "AVAX" | "BTC" | "LINK" | "ARB" | "OP" | "CBETH";
1115
1115
  network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
1116
1116
  }[];
1117
1117
  settlementStatus: "pending" | "completed" | "failed" | null;
@@ -1194,7 +1194,7 @@ declare const PaginatedChargesSchema: z.ZodObject<{
1194
1194
  network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
1195
1195
  }[];
1196
1196
  swapAlternatives: {
1197
- token: "ETH" | "BNB" | "MATIC" | "AVAX" | "BTC";
1197
+ token: "ETH" | "BNB" | "POL" | "AVAX" | "BTC" | "LINK" | "ARB" | "OP" | "CBETH";
1198
1198
  network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
1199
1199
  }[];
1200
1200
  settlementStatus: "pending" | "completed" | "failed" | null;
@@ -1279,13 +1279,13 @@ declare const CheckChargeResponseSchema: z.ZodObject<{
1279
1279
  network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
1280
1280
  }>, "many">;
1281
1281
  swapAlternatives: z.ZodArray<z.ZodObject<{
1282
- token: z.ZodEnum<["ETH", "BNB", "MATIC", "AVAX", "BTC"]>;
1282
+ token: z.ZodEnum<["ETH", "BNB", "POL", "AVAX", "BTC", "LINK", "ARB", "OP", "CBETH"]>;
1283
1283
  network: z.ZodEnum<["base", "optimism", "polygon", "ethereum", "arbitrum", "avalanche", "bnb"]>;
1284
1284
  }, "strip", z.ZodTypeAny, {
1285
- token: "ETH" | "BNB" | "MATIC" | "AVAX" | "BTC";
1285
+ token: "ETH" | "BNB" | "POL" | "AVAX" | "BTC" | "LINK" | "ARB" | "OP" | "CBETH";
1286
1286
  network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
1287
1287
  }, {
1288
- token: "ETH" | "BNB" | "MATIC" | "AVAX" | "BTC";
1288
+ token: "ETH" | "BNB" | "POL" | "AVAX" | "BTC" | "LINK" | "ARB" | "OP" | "CBETH";
1289
1289
  network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
1290
1290
  }>, "many">;
1291
1291
  address: z.ZodString;
@@ -1495,7 +1495,7 @@ declare const CheckChargeResponseSchema: z.ZodObject<{
1495
1495
  network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
1496
1496
  }[];
1497
1497
  swapAlternatives: {
1498
- token: "ETH" | "BNB" | "MATIC" | "AVAX" | "BTC";
1498
+ token: "ETH" | "BNB" | "POL" | "AVAX" | "BTC" | "LINK" | "ARB" | "OP" | "CBETH";
1499
1499
  network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
1500
1500
  }[];
1501
1501
  settlementStatus: "pending" | "completed" | "failed" | null;
@@ -1581,7 +1581,7 @@ declare const CheckChargeResponseSchema: z.ZodObject<{
1581
1581
  network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
1582
1582
  }[];
1583
1583
  swapAlternatives: {
1584
- token: "ETH" | "BNB" | "MATIC" | "AVAX" | "BTC";
1584
+ token: "ETH" | "BNB" | "POL" | "AVAX" | "BTC" | "LINK" | "ARB" | "OP" | "CBETH";
1585
1585
  network: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
1586
1586
  }[];
1587
1587
  settlementStatus: "pending" | "completed" | "failed" | null;
@@ -3095,21 +3095,21 @@ declare const CapabilitiesSchema: z.ZodObject<{
3095
3095
  type Capabilities = z.infer<typeof CapabilitiesSchema>;
3096
3096
 
3097
3097
  declare const CreateSwapQuoteSchema: z.ZodObject<{
3098
- inputToken: z.ZodEnum<["ETH", "BNB", "MATIC", "AVAX", "BTC"]>;
3098
+ inputToken: z.ZodEnum<["ETH", "BNB", "POL", "AVAX", "BTC", "LINK", "ARB", "OP", "CBETH"]>;
3099
3099
  inputNetwork: z.ZodEnum<["base", "optimism", "polygon", "ethereum", "arbitrum", "avalanche", "bnb"]>;
3100
3100
  takerAddress: z.ZodString;
3101
3101
  }, "strip", z.ZodTypeAny, {
3102
- inputToken: "ETH" | "BNB" | "MATIC" | "AVAX" | "BTC";
3102
+ inputToken: "ETH" | "BNB" | "POL" | "AVAX" | "BTC" | "LINK" | "ARB" | "OP" | "CBETH";
3103
3103
  inputNetwork: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
3104
3104
  takerAddress: string;
3105
3105
  }, {
3106
- inputToken: "ETH" | "BNB" | "MATIC" | "AVAX" | "BTC";
3106
+ inputToken: "ETH" | "BNB" | "POL" | "AVAX" | "BTC" | "LINK" | "ARB" | "OP" | "CBETH";
3107
3107
  inputNetwork: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
3108
3108
  takerAddress: string;
3109
3109
  }>;
3110
3110
  type CreateSwapQuoteInput = z.infer<typeof CreateSwapQuoteSchema>;
3111
3111
  declare const SwapQuoteSchema: z.ZodObject<{
3112
- inputToken: z.ZodEnum<["ETH", "BNB", "MATIC", "AVAX", "BTC"]>;
3112
+ inputToken: z.ZodEnum<["ETH", "BNB", "POL", "AVAX", "BTC", "LINK", "ARB", "OP", "CBETH"]>;
3113
3113
  inputNetwork: z.ZodEnum<["base", "optimism", "polygon", "ethereum", "arbitrum", "avalanche", "bnb"]>;
3114
3114
  inputAmount: z.ZodNumber;
3115
3115
  inputAmountExact: z.ZodOptional<z.ZodString>;
@@ -3156,7 +3156,7 @@ declare const SwapQuoteSchema: z.ZodObject<{
3156
3156
  }>>>;
3157
3157
  }, "strip", z.ZodTypeAny, {
3158
3158
  expiresAt: string;
3159
- inputToken: "ETH" | "BNB" | "MATIC" | "AVAX" | "BTC";
3159
+ inputToken: "ETH" | "BNB" | "POL" | "AVAX" | "BTC" | "LINK" | "ARB" | "OP" | "CBETH";
3160
3160
  inputNetwork: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
3161
3161
  inputAmount: number;
3162
3162
  outputToken: "USDC" | "USDT";
@@ -3180,7 +3180,7 @@ declare const SwapQuoteSchema: z.ZodObject<{
3180
3180
  } | null | undefined;
3181
3181
  }, {
3182
3182
  expiresAt: string;
3183
- inputToken: "ETH" | "BNB" | "MATIC" | "AVAX" | "BTC";
3183
+ inputToken: "ETH" | "BNB" | "POL" | "AVAX" | "BTC" | "LINK" | "ARB" | "OP" | "CBETH";
3184
3184
  inputNetwork: "base" | "optimism" | "polygon" | "ethereum" | "arbitrum" | "avalanche" | "bnb";
3185
3185
  inputAmount: number;
3186
3186
  outputToken: "USDC" | "USDT";
package/dist/index.js CHANGED
@@ -331,23 +331,54 @@ var import_zod7 = require("zod");
331
331
  var ALT_TOKEN_DECIMALS = {
332
332
  ETH: 18,
333
333
  BNB: 18,
334
- MATIC: 18,
334
+ POL: 18,
335
335
  AVAX: 18,
336
- BTC: 8
336
+ BTC: 8,
337
+ LINK: 18,
338
+ ARB: 18,
339
+ OP: 18,
340
+ CBETH: 18
337
341
  };
338
342
  var ALT_TOKEN_ADDRESSES = {
339
- base: { ETH: "native", BTC: "0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf" },
340
- optimism: { ETH: "native", BTC: "0x68f180fcCe6836688e9084f035309E29Bf0A2095" },
341
- ethereum: { ETH: "native", BTC: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599" },
342
- arbitrum: { ETH: "native", BTC: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f" },
343
- polygon: { MATIC: "native", BTC: "0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6" },
344
- avalanche: { AVAX: "native" },
343
+ base: {
344
+ ETH: "native",
345
+ BTC: "0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf",
346
+ LINK: "0x88Fb150BDc53A65fe94Dea0c9BA0a6dAf8C6e196",
347
+ CBETH: "0x2Ae3F1Ec7F1F5012CFEab0185bfc7aa3cf0DEc22"
348
+ },
349
+ optimism: {
350
+ ETH: "native",
351
+ BTC: "0x68f180fcCe6836688e9084f035309E29Bf0A2095",
352
+ LINK: "0x350a791Bfc2C21F9Ed5d10980Dad2e2638ffa7f6",
353
+ OP: "0x4200000000000000000000000000000000000042"
354
+ },
355
+ ethereum: {
356
+ ETH: "native",
357
+ BTC: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
358
+ LINK: "0x514910771AF9Ca656af840dff83E8264EcF986CA"
359
+ },
360
+ arbitrum: {
361
+ ETH: "native",
362
+ BTC: "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",
363
+ LINK: "0xf97f4df75117a78c1A5a0DBb814Af92458539FB4",
364
+ ARB: "0x912CE59144191C1204E64559FE8253a0e49E6548"
365
+ },
366
+ polygon: {
367
+ POL: "native",
368
+ BTC: "0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6",
369
+ LINK: "0xb0897686c545045aFc77CF20eC7A532E3120E0F1"
370
+ },
371
+ avalanche: {
372
+ AVAX: "native",
373
+ BTC: "0x2297aebd383787a160dd0d9f71508148769342e3",
374
+ LINK: "0x5947BB275c521040051D82396192181b413227A3"
375
+ },
345
376
  bnb: { BNB: "native" }
346
377
  };
347
378
 
348
379
  // src/alt-tokens.ts
349
- var AltTokenSchema = import_zod7.z.enum(["ETH", "BNB", "MATIC", "AVAX", "BTC"]).describe(
350
- "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."
380
+ var AltTokenSchema = import_zod7.z.enum(["ETH", "BNB", "POL", "AVAX", "BTC", "LINK", "ARB", "OP", "CBETH"]).describe(
381
+ "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. Trusted on a given network only when it has deep, reputably-issued/custodied liquidity there: each network's own native currency, `BTC` (wrapped) on the networks with a trusted deployment, `LINK` (Chainlink's own official per-chain deployment, except Avalanche's bridged `LINK.e`), and a small set of chain-specific blue chips (`ARB` on Arbitrum, `OP` on Optimism, `CBETH` on Base) \u2014 see `ALT_TOKEN_ADDRESSES` for the authoritative per-network list, never assume every value here is available on every network. `POL` replaced `MATIC` as Polygon's native currency name (Polygon's own token migration, 2024) \u2014 this schema tracks the network's current native asset, not the deprecated ticker."
351
382
  );
352
383
  var SwapAlternativeSchema = import_zod7.z.object({
353
384
  token: AltTokenSchema,
@@ -1232,13 +1263,13 @@ var SwapQuoteSchema = import_zod23.z.object({
1232
1263
  to: import_zod23.z.string().describe("Contract address the payer's wallet must send this transaction to."),
1233
1264
  data: import_zod23.z.string().describe("Calldata \u2014 opaque, must be sent unmodified."),
1234
1265
  value: import_zod23.z.string().describe(
1235
- "Native currency (ETH/BNB/MATIC/AVAX) to attach, in wei \u2014 `\"0\"` when `inputToken` isn't this network's native currency."
1266
+ "Native currency (ETH/BNB/POL/AVAX) to attach, in wei \u2014 `\"0\"` when `inputToken` isn't this network's native currency."
1236
1267
  )
1237
1268
  }).describe(
1238
1269
  "Pass this directly to the payer's wallet (e.g. viem/ethers `sendTransaction`) \u2014 Klappay never touches the payer's private key or submits anything on their behalf. If `permit2` is present on this response, sign that first and append the signature to this `data` before sending; if `permit2` is absent, send `transaction` as-is with no extra step."
1239
1270
  ),
1240
1271
  permit2: import_zod23.z.object({ eip712: import_zod23.z.record(import_zod23.z.unknown()) }).nullish().describe(
1241
- "Present only when `inputToken` is an ERC-20 (today, only `BTC`) \u2014 the payer's wallet must sign this EIP-712 message and append the signature to `transaction.data` before sending, since an ERC-20 sell needs a Permit2 allowance signature that a native-currency sell doesn't. `null` (never omitted, in a genuine 0x-backed quote) when `inputToken` is a network's own native currency (ETH/BNB/MATIC/AVAX) \u2014 `transaction` is then ready to sign and send directly, no extra step."
1272
+ "Present only when `inputToken` is an ERC-20 (BTC, LINK, or a chain-specific blue chip like ARB/OP/CBETH) \u2014 the payer's wallet must sign this EIP-712 message and append the signature to `transaction.data` before sending, since an ERC-20 sell needs a Permit2 allowance signature that a native-currency sell doesn't. `null` (never omitted, in a genuine 0x-backed quote) when `inputToken` is a network's own native currency (ETH/BNB/POL/AVAX) \u2014 `transaction` is then ready to sign and send directly, no extra step."
1242
1273
  )
1243
1274
  });
1244
1275
  // Annotate the CommonJS export names for ESM import in node: