@circle-fin/app-kit 1.16.0 → 1.17.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/index.mjs CHANGED
@@ -2804,22 +2804,96 @@ let activeRedactor = defaultMessageRedactor;
2804
2804
  '0x9147d463': 'Final balance is less than the initial balance',
2805
2805
  '0xf4b3b1bc': 'Native token transfer to the beneficiary failed'
2806
2806
  };
2807
+ /**
2808
+ * Matches revert data: a 4-byte selector followed by whole ABI-encoded bytes.
2809
+ */ const REVERT_DATA_PATTERN = /^0x[0-9a-f]{8}(?:[0-9a-f]{2})*$/i;
2810
+ /**
2811
+ * Returns the revert data held by one error in a `cause` chain.
2812
+ *
2813
+ * Browser wallets (EIP-1193) wrap the node's error, so the revert data sits
2814
+ * one level down as `data.data`. viem's `getContractError` reads it the same
2815
+ * way, then keeps it on `ContractFunctionRevertedError.raw` and drops the
2816
+ * node's error from the chain.
2817
+ *
2818
+ * @param link - One error in the `cause` chain
2819
+ * @returns The `raw` or `data` string, or undefined if there is none
2820
+ */ function getRevertData(link) {
2821
+ if ('raw' in link && typeof link.raw === 'string' && REVERT_DATA_PATTERN.test(link.raw)) {
2822
+ return link.raw;
2823
+ }
2824
+ if (!('data' in link)) {
2825
+ return undefined;
2826
+ }
2827
+ const { data } = link;
2828
+ if (typeof data === 'string') {
2829
+ return data;
2830
+ }
2831
+ if (data !== null && typeof data === 'object' && 'data' in data && typeof data.data === 'string') {
2832
+ return data.data;
2833
+ }
2834
+ return undefined;
2835
+ }
2836
+ /**
2837
+ * Finds the first revert data on the error or in its `cause` chain that
2838
+ * `accept` takes.
2839
+ *
2840
+ * viem keeps the node's revert data on an inner `RpcRequestError`, not on
2841
+ * the error it throws. The `seen` set stops a self-referencing `cause` chain.
2842
+ *
2843
+ * @param error - The error object
2844
+ * @param accept - Returns true for the data shape the caller wants
2845
+ * @returns The data as written on the error, or undefined if not found
2846
+ */ function findRevertData(error, accept) {
2847
+ const seen = new Set();
2848
+ let current = error;
2849
+ while(current !== null && typeof current === 'object' && !seen.has(current)){
2850
+ seen.add(current);
2851
+ const data = getRevertData(current);
2852
+ if (data !== undefined && accept(data)) {
2853
+ return data;
2854
+ }
2855
+ current = 'cause' in current ? current.cause : undefined;
2856
+ }
2857
+ return undefined;
2858
+ }
2859
+ /**
2860
+ * Finds the raw revert data on an error or anywhere in its `cause` chain.
2861
+ *
2862
+ * Reads `data`, the nested `data.data` from browser wallets, and viem's
2863
+ * `raw`. Only hex of at least 4 bytes counts, so decoded `data` objects and
2864
+ * empty `0x` data are skipped.
2865
+ *
2866
+ * Revert data is public: it is what the contract returned. Keep it when the
2867
+ * rest of a raw error is redacted, so callers can still decode the revert.
2868
+ *
2869
+ * @param error - The raw error from the blockchain library
2870
+ * @returns The revert data in lowercase, or undefined if there is none
2871
+ *
2872
+ * @example
2873
+ * ```typescript
2874
+ * import { extractRevertData } from '@core/errors'
2875
+ *
2876
+ * extractRevertData({ cause: { data: { data: '0xF64059DB' } } })
2877
+ * // Returns: '0xf64059db'
2878
+ * ```
2879
+ */ function extractRevertData(error) {
2880
+ return findRevertData(error, (data)=>REVERT_DATA_PATTERN.test(data))?.toLowerCase();
2881
+ }
2807
2882
  /**
2808
2883
  * Attempts to extract an error selector from an error object or message.
2809
2884
  *
2810
2885
  * Checks multiple sources in priority order:
2811
- * 1. `error.data` field
2886
+ * 1. `raw` or `data` field (or nested `data.data`) on the error or anywhere
2887
+ * in its `cause` chain
2812
2888
  * 2. Message pattern: "custom error 0x8baa579f"
2813
2889
  *
2814
2890
  * @param msg - The error message
2815
2891
  * @param error - The error object (optional)
2816
2892
  * @returns The 4 bytes selector , or undefined if not found
2817
2893
  */ function extractErrorSelector(msg, error) {
2818
- // Check error.data field
2819
- if (error !== null && typeof error === 'object' && 'data' in error) {
2820
- if (typeof error.data === 'string' && /^0x[0-9a-f]{8}$/i.test(error.data)) {
2821
- return error.data.toLowerCase();
2822
- }
2894
+ const data = findRevertData(error, (value)=>/^0x[0-9a-f]{8}$/i.test(value));
2895
+ if (data !== undefined) {
2896
+ return data.toLowerCase();
2823
2897
  }
2824
2898
  // Check for "custom error 0x8baa579f" in the message
2825
2899
  const match = /custom error (0x[0-9a-f]{8})\b/i.exec(msg);
@@ -4356,7 +4430,7 @@ let activeRedactor = defaultMessageRedactor;
4356
4430
  * between input errors (fix your request) and service errors (retry later).
4357
4431
  *
4358
4432
  * Error code ranges:
4359
- * - 1100-1106: INPUT errors — invalid, unsupported, or stale request state
4433
+ * - 1100-1107: INPUT errors — invalid, unsupported, or stale request state
4360
4434
  * - 8100-8105: SERVICE errors — retryable backend/provider failures
4361
4435
  *
4362
4436
  * @example
@@ -4417,6 +4491,15 @@ let activeRedactor = defaultMessageRedactor;
4417
4491
  name: 'EARN_BRIDGE_QUOTE_EXPIRED',
4418
4492
  type: 'INPUT'
4419
4493
  },
4494
+ /**
4495
+ * The wallet's vault shares are inside the vault's share lock period, which
4496
+ * starts at deposit. Surfaced as FATAL rather than RETRYABLE because the
4497
+ * lock can last hours, so an immediate retry fails the same way.
4498
+ */ SHARES_LOCKED: {
4499
+ code: 1107,
4500
+ name: 'EARN_SHARES_LOCKED',
4501
+ type: 'INPUT'
4502
+ },
4420
4503
  /** The proxy signing call failed — retryable. */ SIGNING_FAILED: {
4421
4504
  code: 8100,
4422
4505
  name: 'EARN_SIGNING_FAILED',
@@ -5563,6 +5646,8 @@ var SwapChain;
5563
5646
  SwapChain["HyperEVM"] = "HyperEVM";
5564
5647
  SwapChain["Monad"] = "Monad";
5565
5648
  SwapChain["Arc"] = "Arc";
5649
+ SwapChain["Cronos"] = "Cronos";
5650
+ SwapChain["Morph"] = "Morph";
5566
5651
  // Testnet chains with swap support
5567
5652
  SwapChain["Arc_Testnet"] = "Arc_Testnet";
5568
5653
  })(SwapChain || (SwapChain = {}));
@@ -6916,7 +7001,8 @@ var BorrowChain;
6916
7001
  }
6917
7002
  },
6918
7003
  kitContracts: {
6919
- bridge: BRIDGE_CONTRACT_EVM_MAINNET
7004
+ bridge: BRIDGE_CONTRACT_EVM_MAINNET,
7005
+ adapter: ADAPTER_CONTRACT_EVM_MAINNET
6920
7006
  }
6921
7007
  });
6922
7008
 
@@ -7785,7 +7871,8 @@ var BorrowChain;
7785
7871
  }
7786
7872
  },
7787
7873
  kitContracts: {
7788
- bridge: BRIDGE_CONTRACT_EVM_MAINNET
7874
+ bridge: BRIDGE_CONTRACT_EVM_MAINNET,
7875
+ adapter: ADAPTER_CONTRACT_EVM_MAINNET
7789
7876
  }
7790
7877
  });
7791
7878
 
@@ -10156,8 +10243,8 @@ var Chains = /*#__PURE__*/Object.freeze({
10156
10243
  * Zod schema for validating swap-specific chain identifiers.
10157
10244
  *
10158
10245
  * Validates chains based on:
10159
- * - CCTPv2 support (adapter contract deployed)
10160
- * - Mainnet only (no testnets)
10246
+ * - Membership in the SwapChain enum
10247
+ * - Mainnet or explicitly allowlisted testnet
10161
10248
  * - At least one supported token available
10162
10249
  *
10163
10250
  */ const swapChainIdentifierSchema = z.union([
@@ -10799,7 +10886,7 @@ const swapTokenEnumSchema = z.enum([
10799
10886
  *
10800
10887
  * A chain supports swaps if ALL conditions are met:
10801
10888
  * 1. Is a member of the {@link SwapChain} enum
10802
- * 2. Has CCTPv2 support (adapter contract deployed)
10889
+ * 2. Has an Adapter contract configured directly or through CCTP v2
10803
10890
  *
10804
10891
  * Testnets are allowed only when explicitly listed in the
10805
10892
  * {@link SwapChain} enum (e.g., Arc_Testnet).
@@ -10820,14 +10907,14 @@ const swapTokenEnumSchema = z.enum([
10820
10907
  * @remarks
10821
10908
  * Chains automatically become swap-enabled when:
10822
10909
  * - Added to the {@link SwapChain} enum
10823
- * - Adapter contract is deployed (CCTPv2)
10910
+ * - An Adapter contract is deployed and configured
10824
10911
  *
10825
10912
  * No code changes needed when new chains are added!
10826
10913
  */ function isSwapSupportedChain(chain) {
10827
10914
  if (!(chain.chain in SwapChain)) {
10828
10915
  return false;
10829
10916
  }
10830
- if (!isCCTPV2Supported(chain)) {
10917
+ if (!isCCTPV2Supported(chain) && !hasCustomContractSupport(chain, 'adapter')) {
10831
10918
  return false;
10832
10919
  }
10833
10920
  return true;
@@ -10838,7 +10925,7 @@ const swapTokenEnumSchema = z.enum([
10838
10925
  *
10839
10926
  * Dynamically filter chain definitions to include only those that:
10840
10927
  * - Are members of the {@link SwapChain} enum
10841
- * - Have CCTPv2 support
10928
+ * - Have an Adapter contract configured directly or through CCTP v2
10842
10929
  *
10843
10930
  * This function is pure and accepts chains as parameter to avoid
10844
10931
  * circular dependencies.
@@ -12363,11 +12450,13 @@ function parseOrThrow(value, schema, context) {
12363
12450
  [Blockchain.Arbitrum]: '0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9',
12364
12451
  [Blockchain.Avalanche]: '0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7',
12365
12452
  [Blockchain.Celo]: '0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e',
12453
+ [Blockchain.Cronos]: '0x66e428c3f67a68878562e79A0234c1F83c208770',
12366
12454
  [Blockchain.Ethereum]: '0xdAC17F958D2ee523a2206206994597C13D831ec7',
12367
12455
  [Blockchain.HyperEVM]: '0xb8ce59fc3717ada4c02eadf9682a9e934f625ebb',
12368
12456
  [Blockchain.Ink]: '0x0200C29006150606B650577BBE7B6248F58470c1',
12369
12457
  [Blockchain.Linea]: '0xA219439258ca9da29E9Cc4cE5596924745e12B93',
12370
12458
  [Blockchain.Monad]: '0xe7cd86e13AC4309349F30B3435a9d337750fC82D',
12459
+ [Blockchain.Morph]: '0xe7cd86e13AC4309349F30B3435a9d337750fC82D',
12371
12460
  [Blockchain.NEAR]: 'usdt.tether-token.near',
12372
12461
  [Blockchain.Optimism]: '0x94b008aA00579c1307B0EF2c499aD98a8ce58e58',
12373
12462
  [Blockchain.Polkadot_Asset_Hub]: '1984',
@@ -12426,6 +12515,7 @@ function parseOrThrow(value, schema, context) {
12426
12515
  [Blockchain.Arbitrum]: '0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1',
12427
12516
  [Blockchain.Avalanche]: '0xd586E7F844cEa2F87f50152665BCbc2C279D8d70',
12428
12517
  [Blockchain.Base]: '0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb',
12518
+ [Blockchain.Cronos]: '0xF2001B145b43032AAF5Ee2884e456CCd805F677D',
12429
12519
  [Blockchain.Ethereum]: '0x6B175474E89094C44Da98b954EedeAC495271d0F',
12430
12520
  [Blockchain.Linea]: '0x4AF15ec2A0BD43Db75dd04E62FAA3B8EF36b00d5',
12431
12521
  [Blockchain.Optimism]: '0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1',
@@ -12488,7 +12578,9 @@ function parseOrThrow(value, schema, context) {
12488
12578
  [Blockchain.Arbitrum]: '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1',
12489
12579
  [Blockchain.Avalanche]: '0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB',
12490
12580
  [Blockchain.Base]: '0x4200000000000000000000000000000000000006',
12581
+ [Blockchain.Cronos]: '0xe44Fd7fCb2b1581822D0c862B68222998a0c299a',
12491
12582
  [Blockchain.Ethereum]: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
12583
+ [Blockchain.Morph]: '0x5300000000000000000000000000000000000011',
12492
12584
  [Blockchain.Optimism]: '0x4200000000000000000000000000000000000006',
12493
12585
  [Blockchain.Polygon]: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',
12494
12586
  [Blockchain.Solana]: '7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs'
@@ -12507,6 +12599,7 @@ function parseOrThrow(value, schema, context) {
12507
12599
  locators: {
12508
12600
  [Blockchain.Ethereum]: '0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599',
12509
12601
  [Blockchain.Arbitrum]: '0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f',
12602
+ [Blockchain.Cronos]: '0x062E66477Faf219F25D27dCED647BF57C3107d52',
12510
12603
  [Blockchain.Avalanche]: '0x50b7545627a5162F82A992c33b87aDc75187B218'
12511
12604
  }
12512
12605
  };
@@ -14581,7 +14674,7 @@ function resolveOptions(options) {
14581
14674
  }
14582
14675
 
14583
14676
  var name$5 = "@circle-fin/bridge-kit";
14584
- var version$6 = "1.15.2";
14677
+ var version$6 = "1.15.3";
14585
14678
  var pkg$6 = {
14586
14679
  name: name$5,
14587
14680
  version: version$6};
@@ -17646,7 +17739,11 @@ function createNoopLogger() {
17646
17739
  tokenId: bytes32Hex,
17647
17740
  domainId: nonNegativeInteger,
17648
17741
  tokenAddress: z.string(),
17649
- tokenManagerAddress: z.string()
17742
+ tokenManagerAddress: z.string(),
17743
+ // Operator-controlled per-chain kill switch (CCTPE-3979). Optional for
17744
+ // back-compat with older IRIS versions that do not surface it. Downstream
17745
+ // consumers in `findCCTPXDeployment` treat a missing value as `true`.
17746
+ enabled: z.boolean().optional()
17650
17747
  });
17651
17748
  /**
17652
17749
  * Schema for one token entry in the token registry response.
@@ -18130,17 +18227,23 @@ function createNoopLogger() {
18130
18227
  /**
18131
18228
  * Find a token's deployment on the given CCTP domain.
18132
18229
  *
18230
+ * A deployment row with `enabled === false` is treated as missing: an IRIS
18231
+ * operator has flipped the per-chain kill switch (CCTPE-3979), so the SDK must
18232
+ * not route through it even though the row still exists in the registry. A
18233
+ * missing or `true` `enabled` value remains routable — the field is optional on
18234
+ * older IRIS versions and absence is read as "allowed".
18235
+ *
18133
18236
  * @param token - The registry token whose deployments are searched.
18134
18237
  * @param domain - The CCTP domain id to match.
18135
18238
  * @returns The matching {@link CCTPXTokenDeployment}, or `undefined` when the
18136
- * token has no deployment on that domain.
18239
+ * token has no deployment on that domain or the deployment is disabled.
18137
18240
  *
18138
18241
  * @example
18139
18242
  * ```typescript
18140
18243
  * const deployment = findCCTPXDeployment(token, 0)
18141
18244
  * ```
18142
18245
  */ function findCCTPXDeployment(token, domain) {
18143
- return token.deployments.find((deployment)=>deployment.domainId === domain);
18246
+ return token.deployments.find((deployment)=>deployment.domainId === domain && deployment.enabled !== false);
18144
18247
  }
18145
18248
 
18146
18249
  /**
@@ -18242,6 +18345,24 @@ function createNoopLogger() {
18242
18345
  }
18243
18346
  }
18244
18347
  })
18348
+ ],
18349
+ // The token is not deployed on one of the route chains, or an operator has
18350
+ // flipped the per-chain `enabled` kill switch on the IRIS deployment row.
18351
+ // Either way the route is permanently unavailable until the operator intervenes;
18352
+ // a retry at the same source/destination will keep returning this error.
18353
+ [
18354
+ 'TOKEN_NOT_SUPPORTED_ON_ROUTE',
18355
+ ({ sourceDomain, destinationDomain })=>new KitError({
18356
+ ...InputError.UNSUPPORTED_ROUTE,
18357
+ recoverability: 'FATAL',
18358
+ message: 'CCTPx fee quote rejected the route: the token is not supported on ' + 'the source or destination chain (missing deployment or operator-disabled).',
18359
+ cause: {
18360
+ trace: {
18361
+ sourceDomain,
18362
+ destinationDomain
18363
+ }
18364
+ }
18365
+ })
18245
18366
  ]
18246
18367
  ]);
18247
18368
  /**
@@ -26252,7 +26373,7 @@ const mockAttestationMessage = {
26252
26373
  return step;
26253
26374
  }
26254
26375
 
26255
- var version$5 = "1.14.1";
26376
+ var version$5 = "1.14.2";
26256
26377
  var pkg$5 = {
26257
26378
  version: version$5};
26258
26379
 
@@ -30472,7 +30593,7 @@ async function resolveExecutionQuote(binding, suppliedQuote, refundAddress) {
30472
30593
  registerKit(`${pkg$6.name}/${pkg$6.version}`);
30473
30594
 
30474
30595
  var name$4 = "@circle-fin/swap-kit";
30475
- var version$4 = "1.7.1";
30596
+ var version$4 = "1.8.0";
30476
30597
  var pkg$4 = {
30477
30598
  name: name$4,
30478
30599
  version: version$4};
@@ -30932,6 +31053,64 @@ const optionalChainIdentifierField = chainIdentifierField.optional();
30932
31053
  }, {
30933
31054
  message: 'fee amount must be non-negative (>= 0)'
30934
31055
  });
31056
+ /**
31057
+ * Parses a display-only field leniently: a value `schema` rejects is replaced
31058
+ * with `fallback` instead of failing the response that carries it.
31059
+ * Implemented with `preprocess` rather than Zod's `.catch()` because static
31060
+ * analysis misreads `.catch` on the schema chain as an unhandled Promise
31061
+ * (S7785).
31062
+ */ const withFallback = (schema, fallback)=>z.preprocess((value)=>schema.safeParse(value).success ? value : fallback, schema);
31063
+ const swapRouteTokenSchema = z.object({
31064
+ symbol: z.string(),
31065
+ address: z.string(),
31066
+ decimals: z.number()
31067
+ });
31068
+ const swapRouteMetadataSchema = z.record(z.unknown()).optional();
31069
+ const swapRouteStepSchema = z.object({
31070
+ type: z.string(),
31071
+ tool: z.string(),
31072
+ toolName: z.string(),
31073
+ fromToken: swapRouteTokenSchema,
31074
+ toToken: swapRouteTokenSchema,
31075
+ estimate: z.object({
31076
+ fromAmount: z.string(),
31077
+ toAmount: z.string(),
31078
+ gasCostUSD: z.string().optional()
31079
+ }),
31080
+ metadata: swapRouteMetadataSchema
31081
+ });
31082
+ /**
31083
+ * Strict schema for a `SwapRoute`. Module-private: service responses
31084
+ * parse routes leniently through {@link responseSwapRouteSchema}.
31085
+ */ const swapRouteSchema = z.object({
31086
+ provider: z.string().min(1, 'provider must be a non-empty string'),
31087
+ steps: z.array(swapRouteStepSchema),
31088
+ metadata: swapRouteMetadataSchema
31089
+ });
31090
+ /**
31091
+ * Route details are display-only, so service responses parse them leniently:
31092
+ * steps or metadata in a shape the SDK does not know are dropped rather than
31093
+ * failing the quote or swap they describe. Steps are all-or-nothing: if any
31094
+ * step is malformed, `steps` is empty, so a route never silently loses a hop.
31095
+ */ const responseSwapRouteSchema = swapRouteSchema.extend({
31096
+ steps: withFallback(swapRouteSchema.shape.steps, []),
31097
+ metadata: withFallback(swapRouteMetadataSchema, undefined)
31098
+ });
31099
+ const createSwapFeeItemSchema = z.object({
31100
+ token: z.string({
31101
+ required_error: 'fee token is required',
31102
+ invalid_type_error: 'fee token must be a string'
31103
+ }).min(1, 'fee token must be a non-empty string'),
31104
+ amount: feeAmountSchema,
31105
+ decimals: z.number().int('fee token decimals must be an integer').nonnegative('fee token decimals must be a non-negative integer').optional(),
31106
+ symbol: z.string({
31107
+ invalid_type_error: 'fee token symbol must be a string'
31108
+ }).min(1, 'fee token symbol must be a non-empty string').optional(),
31109
+ // Descriptive metadata: a value the SDK cannot use is dropped rather than
31110
+ // failing the response that carries the fee.
31111
+ type: withFallback(z.string().min(1).optional(), undefined),
31112
+ chain: withFallback(z.string().min(1).optional(), undefined)
31113
+ });
30935
31114
  /**
30936
31115
  * Zod schema for validating API keys.
30937
31116
  *
@@ -31017,10 +31196,7 @@ const optionalChainIdentifierField = chainIdentifierField.optional();
31017
31196
  /** Quote information with estimated amounts and route */ quote: z.object({
31018
31197
  /** Estimated output amount (base units) */ estimatedAmount: z.string().min(1, 'estimatedAmount must be a non-empty string').regex(/^\d+$/, 'estimatedAmount must be a numeric string'),
31019
31198
  /** Guaranteed minimum output amount (base units) */ minAmount: z.string().min(1, 'minAmount must be a non-empty string').regex(/^\d+$/, 'minAmount must be a numeric string'),
31020
- /** Route information from DEX aggregator */ route: z.object({
31021
- provider: z.string().min(1, 'provider must be a non-empty string'),
31022
- steps: z.array(z.unknown())
31023
- })
31199
+ /** Route information from DEX aggregator */ route: responseSwapRouteSchema
31024
31200
  }),
31025
31201
  /** Fee context indicating where fees should be collected */ feeContext: quoteFeeContextSchema
31026
31202
  });
@@ -31236,19 +31412,6 @@ getQuoteRequestBaseSchema.superRefine(requireCrossChainQuoteToAddress);
31236
31412
  }).min(1, 'toChain must be a non-empty string if provided').optional(),
31237
31413
  apiKey: apiKeySchema.optional()
31238
31414
  });
31239
- /**
31240
- * Zod schema for validating CreateSwapResponse payloads.
31241
- */ const createSwapFeeItemSchema = z.object({
31242
- token: z.string({
31243
- required_error: 'fee token is required',
31244
- invalid_type_error: 'fee token must be a string'
31245
- }).min(1, 'fee token must be a non-empty string'),
31246
- amount: feeAmountSchema,
31247
- decimals: z.number().int('fee token decimals must be an integer').nonnegative('fee token decimals must be a non-negative integer').optional(),
31248
- symbol: z.string({
31249
- invalid_type_error: 'fee token symbol must be a string'
31250
- }).min(1, 'fee token symbol must be a non-empty string').optional()
31251
- });
31252
31415
  /**
31253
31416
  * Developer fee item schema with basis field.
31254
31417
  */ const createSwapDeveloperFeeItemSchema = createSwapFeeItemSchema.extend({
@@ -31386,6 +31549,8 @@ getQuoteRequestBaseSchema.superRefine(requireCrossChainQuoteToAddress);
31386
31549
  correlationId: z.preprocess((value)=>z.string().uuid().safeParse(value).success ? value : undefined, z.string().optional()),
31387
31550
  config: createSwapRequestBaseSchema.shape.config.optional(),
31388
31551
  fees: createSwapFeesSchema.optional(),
31552
+ // A route the SDK cannot parse is dropped instead of failing the swap.
31553
+ route: withFallback(responseSwapRouteSchema.optional(), undefined),
31389
31554
  transaction: createSwapTransactionSchema
31390
31555
  });
31391
31556
 
@@ -31413,6 +31578,25 @@ getQuoteRequestBaseSchema.superRefine(requireCrossChainQuoteToAddress);
31413
31578
  * }
31414
31579
  * ```
31415
31580
  */ const isGetQuoteResponse = (obj)=>getQuoteResponseSchema.safeParse(obj).success;
31581
+ /**
31582
+ * Parse and transform a GetQuoteResponse object.
31583
+ *
31584
+ * Applies the schema's lenient route and fee parsing: entries the SDK does
31585
+ * not recognise are dropped and undeclared fields are stripped, rather than
31586
+ * passed through to callers as the type guard alone would.
31587
+ *
31588
+ * @param obj - The raw API response object to parse.
31589
+ * @returns The validated and transformed GetQuoteResponse.
31590
+ * @throws If validation fails.
31591
+ *
31592
+ * @example
31593
+ * ```typescript
31594
+ * import { parseGetQuoteResponse } from '@core/service-client'
31595
+ *
31596
+ * const quote = parseGetQuoteResponse(await response.json())
31597
+ * console.log(quote.quote.route.steps.length)
31598
+ * ```
31599
+ */ const parseGetQuoteResponse = (obj)=>getQuoteResponseSchema.parse(obj);
31416
31600
  /**
31417
31601
  * Type guard to validate CreateSwapResponse objects.
31418
31602
  *
@@ -31818,7 +32002,9 @@ getQuoteRequestBaseSchema.superRefine(requireCrossChainQuoteToAddress);
31818
32002
  }
31819
32003
  }
31820
32004
  };
31821
- return pollApiGet(url, isGetQuoteResponse, effectiveConfig);
32005
+ // Use type guard for validation in polling, then parse for transformation
32006
+ const rawResponse = await pollApiGet(url, isGetQuoteResponse, effectiveConfig);
32007
+ return parseGetQuoteResponse(rawResponse);
31822
32008
  };
31823
32009
 
31824
32010
  /**
@@ -40742,6 +40928,16 @@ function resolveFeePayoutChain(tokenIn, tokenOut, sourceChain, destinationChain)
40742
40928
  name: 'USDC',
40743
40929
  version: '2'
40744
40930
  },
40931
+ Cronos: {
40932
+ chainId: Cronos.chainId,
40933
+ name: 'USDC',
40934
+ version: '2'
40935
+ },
40936
+ Morph: {
40937
+ chainId: Morph.chainId,
40938
+ name: 'USDC',
40939
+ version: '2'
40940
+ },
40745
40941
  Arc_Testnet: {
40746
40942
  chainId: ArcTestnet.chainId,
40747
40943
  name: 'USDC',
@@ -42310,6 +42506,12 @@ const TOKEN_REGISTRY$2 = createTokenRegistry();
42310
42506
  * i.e. 1 + 0.2 + 0.1 = 1.3. Use the greater of (local estimate × this multiplier)
42311
42507
  * or the proxy's gasLimit.
42312
42508
  */ const GAS_SAFETY_MULTIPLIER = 1.3;
42509
+ /**
42510
+ * Gas units used to estimate the displayed gas fee when the service returns an
42511
+ * EVM route without a gasLimit, as direct Circle CCTP plans do. Sized from
42512
+ * observed Adapter executions of those plans. Display-only: it never becomes an
42513
+ * execution gas limit.
42514
+ */ const DEFAULT_EVM_SWAP_GAS_LIMIT = 500_000n;
42313
42515
  const TOKEN_REGISTRY$1 = createTokenRegistry();
42314
42516
  /**
42315
42517
  * Enhances a KitError with transaction details (txHash and explorerUrl).
@@ -42826,9 +43028,9 @@ async function fetchSameChainStatusSnapshot({ isCrossChainSwap, txHash, chain, a
42826
43028
  // Calculate estimated gas/transaction fee based on chain type
42827
43029
  let estimatedGasFee = '0';
42828
43030
  const evmGasLimit = 'gasLimit' in serviceResponse.transaction ? serviceResponse.transaction.gasLimit : undefined;
42829
- if (chain.type === 'evm' && evmGasLimit !== undefined) {
43031
+ if (chain.type === 'evm') {
42830
43032
  // EVM: gasLimit (units) × gasPrice (wei/unit) = estimated gas fee (wei)
42831
- const gasLimitUnits = BigInt(evmGasLimit);
43033
+ const gasLimitUnits = evmGasLimit === undefined ? DEFAULT_EVM_SWAP_GAS_LIMIT : BigInt(evmGasLimit);
42832
43034
  // Use calculateTransactionFee which fetches current gas price and applies buffer
42833
43035
  const gasEstimate = await params.from.adapter.calculateTransactionFee(gasLimitUnits, undefined, chain);
42834
43036
  // Format the fee from wei to human-readable native currency amount
@@ -42872,7 +43074,10 @@ async function fetchSameChainStatusSnapshot({ isCrossChainSwap, txHash, chain, a
42872
43074
  const estimateResult = {
42873
43075
  stopLimit: formattedStopLimit,
42874
43076
  estimatedOutput: formattedEstimatedOutput,
42875
- fees
43077
+ fees,
43078
+ ...serviceResponse.route !== undefined && {
43079
+ route: serviceResponse.route
43080
+ }
42876
43081
  };
42877
43082
  return estimateResult;
42878
43083
  }
@@ -43257,7 +43462,7 @@ async function fetchSameChainStatusSnapshot({ isCrossChainSwap, txHash, chain, a
43257
43462
  * }
43258
43463
  * ```
43259
43464
  */ async swap(params) {
43260
- // Extract wallet context & validate
43465
+ validateServiceSwapParams(params);
43261
43466
  const { from, tokenIn, tokenOut, config } = params;
43262
43467
  const { adapter, chain } = from;
43263
43468
  const destinationChain = params.toChain ?? chain;
@@ -43394,6 +43599,9 @@ async function fetchSameChainStatusSnapshot({ isCrossChainSwap, txHash, chain, a
43394
43599
  ...swapResultFees !== undefined && {
43395
43600
  fees: swapResultFees
43396
43601
  },
43602
+ ...serviceResponse.route !== undefined && {
43603
+ route: serviceResponse.route
43604
+ },
43397
43605
  progress: statusSnapshot.progress,
43398
43606
  ...statusSnapshot.amountOut !== undefined && {
43399
43607
  amountOut: statusSnapshot.amountOut
@@ -43594,7 +43802,13 @@ async function fetchSameChainStatusSnapshot({ isCrossChainSwap, txHash, chain, a
43594
43802
  return {
43595
43803
  token: formatted.token,
43596
43804
  amount: formatted.amount,
43597
- type
43805
+ type,
43806
+ ...fee.type !== undefined && {
43807
+ component: fee.type
43808
+ },
43809
+ ...fee.chain !== undefined && {
43810
+ chain: fee.chain
43811
+ }
43598
43812
  };
43599
43813
  }));
43600
43814
  }
@@ -43615,7 +43829,13 @@ async function fetchSameChainStatusSnapshot({ isCrossChainSwap, txHash, chain, a
43615
43829
  token: formatted.token,
43616
43830
  amount: formatted.amount,
43617
43831
  type: 'developer',
43618
- recipientAddress
43832
+ recipientAddress,
43833
+ ...fee.type !== undefined && {
43834
+ component: fee.type
43835
+ },
43836
+ ...fee.chain !== undefined && {
43837
+ chain: fee.chain
43838
+ }
43619
43839
  };
43620
43840
  }));
43621
43841
  }
@@ -43672,6 +43892,7 @@ const optionalSwapChainIdentifierField = swapChainIdentifierField.optional();
43672
43892
  * - customFee: Optional fee configuration
43673
43893
  * - apiKey: Optional credential string
43674
43894
  * - kitKey: Optional credential string (deprecated alias for apiKey)
43895
+ * - batchTransactions: Optional boolean to opt out of atomic batching
43675
43896
  */ const swapConfigSchema = z.object({
43676
43897
  allowanceStrategy: allowanceStrategySchema$1.optional(),
43677
43898
  slippageBps: z.number().int().min(0).optional(),
@@ -43682,7 +43903,10 @@ const optionalSwapChainIdentifierField = swapChainIdentifierField.optional();
43682
43903
  })(z.string())).optional(),
43683
43904
  customFee: swapCustomFeeSchema.optional(),
43684
43905
  apiKey: z.string().optional(),
43685
- kitKey: z.string().optional()
43906
+ kitKey: z.string().optional(),
43907
+ batchTransactions: z.boolean({
43908
+ invalid_type_error: 'batchTransactions must be a boolean'
43909
+ }).optional()
43686
43910
  });
43687
43911
  const swapDestinationSchema = z.object({
43688
43912
  chain: optionalSwapChainIdentifierField,
@@ -44657,6 +44881,9 @@ const transformAmount = (value, direction, decimals)=>formatUnits(value, decimal
44657
44881
  ...formattedFees && {
44658
44882
  fees: formattedFees
44659
44883
  },
44884
+ ...result.route !== undefined && {
44885
+ route: result.route
44886
+ },
44660
44887
  ...formattedConfig && {
44661
44888
  config: formattedConfig
44662
44889
  },
@@ -44918,6 +45145,9 @@ const transformAmount = (value, direction, decimals)=>formatUnits(value, decimal
44918
45145
  estimatedOutput: providerEstimate.estimatedOutput,
44919
45146
  ...providerEstimate.fees !== undefined && {
44920
45147
  fees: providerEstimate.fees
45148
+ },
45149
+ ...providerEstimate.route !== undefined && {
45150
+ route: providerEstimate.route
44921
45151
  }
44922
45152
  };
44923
45153
  }
@@ -46717,7 +46947,7 @@ registerKit(`${pkg$4.name}/${pkg$4.version}`);
46717
46947
  };
46718
46948
 
46719
46949
  var name$3 = "@circle-fin/earn-kit";
46720
- var version$3 = "1.8.1";
46950
+ var version$3 = "1.9.0";
46721
46951
  var pkg$3 = {
46722
46952
  name: name$3,
46723
46953
  version: version$3};
@@ -48505,6 +48735,187 @@ function isCrossChainDepositStatusStep(step) {
48505
48735
  return step.name === 'status';
48506
48736
  }
48507
48737
 
48738
+ /**
48739
+ * Selector of `TellerWithMultiAssetSupport__SharesAreLocked()`.
48740
+ */ const SHARES_LOCKED_SELECTOR = '0xf64059db';
48741
+ /**
48742
+ * Readable reasons for Veda BoringVault Teller and Accountant reverts.
48743
+ */ const VEDA_REVERT_REASONS = {
48744
+ '0xe0f9e71d': 'The vault is paused',
48745
+ '0x3b3132f6': 'The vault exchange rate is paused',
48746
+ '0xc8bfa33e': 'The vault does not support this asset for this operation',
48747
+ '0x4b37cd2a': 'The asset amount must be greater than zero',
48748
+ '0x3a8c54c4': 'The share amount must be greater than zero',
48749
+ '0x4bd956a8': 'The deposit would mint fewer vault shares than the signed minimum',
48750
+ '0x9883d840': 'The withdrawal would pay out fewer assets than the signed minimum',
48751
+ '0xed32f3bb': 'The deposit would exceed the vault deposit cap',
48752
+ '0x1b8851f0': 'The permit failed and the token allowance is too low',
48753
+ '0x2821264f': 'The vault denied the share transfer'
48754
+ };
48755
+ /**
48756
+ * Matches a 4-byte selector in a message. The lookarounds stop a longer hex
48757
+ * value, such as an address or a hash, from matching.
48758
+ */ const SELECTOR_IN_TEXT = /(?<![0-9a-fx])0x[0-9a-f]{8}(?![0-9a-f])/gi;
48759
+ function toRecord(value) {
48760
+ return typeof value === 'object' && value !== null ? value : {};
48761
+ }
48762
+ function isVedaSelector(selector) {
48763
+ return selector === SHARES_LOCKED_SELECTOR || selector in VEDA_REVERT_REASONS;
48764
+ }
48765
+ /**
48766
+ * Reads the selector from the revert data on a trace. The `/next` adapters
48767
+ * keep it on `revertData`. The default adapters keep the whole raw error on
48768
+ * `rawError`.
48769
+ */ function selectorFromData(trace) {
48770
+ const data = typeof trace['revertData'] === 'string' ? trace['revertData'] : extractRevertData(trace['rawError']);
48771
+ const selector = data?.slice(0, 10).toLowerCase();
48772
+ return selector !== undefined && isVedaSelector(selector) ? selector : undefined;
48773
+ }
48774
+ /**
48775
+ * Reads the selector from error text, for wallets that return no revert
48776
+ * data and put the selector or the decoded error name in the message.
48777
+ */ function selectorFromText(texts) {
48778
+ for (const text of texts){
48779
+ if (typeof text !== 'string') {
48780
+ continue;
48781
+ }
48782
+ if (/SharesAreLocked/i.test(text)) {
48783
+ return SHARES_LOCKED_SELECTOR;
48784
+ }
48785
+ const selector = text.match(SELECTOR_IN_TEXT)?.map((match)=>match.toLowerCase()).find(isVedaSelector);
48786
+ if (selector !== undefined) {
48787
+ return selector;
48788
+ }
48789
+ }
48790
+ return undefined;
48791
+ }
48792
+ /**
48793
+ * Reads a Veda revert from one error, without looking at nested errors.
48794
+ */ function readVedaRevert(error) {
48795
+ const trace = toRecord(error.cause?.trace);
48796
+ const selector = selectorFromData(trace) ?? selectorFromText([
48797
+ error.message,
48798
+ trace['reason']
48799
+ ]);
48800
+ if (selector === undefined) {
48801
+ return undefined;
48802
+ }
48803
+ const chain = trace['chain'];
48804
+ return {
48805
+ selector,
48806
+ chain: typeof chain === 'string' ? chain : undefined
48807
+ };
48808
+ }
48809
+ /**
48810
+ * Returns the errors that a failed batch nests under `trace.cause` or
48811
+ * `trace.error`.
48812
+ */ function nestedErrors(error) {
48813
+ const trace = toRecord(error.cause?.trace);
48814
+ return [
48815
+ trace['cause'],
48816
+ trace['error']
48817
+ ].filter(isKitError);
48818
+ }
48819
+ /**
48820
+ * Finds a Veda revert on the error or on an error nested in its trace.
48821
+ */ function findVedaRevert(error) {
48822
+ const seen = new Set();
48823
+ const pending = [
48824
+ error
48825
+ ];
48826
+ let current = pending.pop();
48827
+ while(current !== undefined){
48828
+ if (!seen.has(current)) {
48829
+ seen.add(current);
48830
+ const revert = readVedaRevert(current);
48831
+ if (revert !== undefined) {
48832
+ return {
48833
+ ...revert,
48834
+ nested: current !== error
48835
+ };
48836
+ }
48837
+ pending.push(...nestedErrors(current));
48838
+ }
48839
+ current = pending.pop();
48840
+ }
48841
+ return undefined;
48842
+ }
48843
+ /**
48844
+ * Map a Veda vault revert to an Earn error.
48845
+ *
48846
+ * A Teller `SharesAreLocked()` revert becomes `EARN_SHARES_LOCKED`. Other
48847
+ * known Veda reverts keep their simulation failed or transaction reverted
48848
+ * code and get a readable reason. A failed batch that wraps a Veda revert
48849
+ * keeps its code, and the reason is added to its message. A timed out batch
48850
+ * is returned unchanged, because its outcome is unknown. Any other error is
48851
+ * returned unchanged.
48852
+ *
48853
+ * @param error - The error caught from an earn operation.
48854
+ * @returns The mapped error, or `error` when it is not a Veda revert.
48855
+ *
48856
+ * @example
48857
+ * ```typescript
48858
+ * import { mapVedaRevert } from './vedaRevert'
48859
+ *
48860
+ * const mapped = mapVedaRevert(error)
48861
+ * console.log(mapped.name) // 'EARN_SHARES_LOCKED' for a share lock revert
48862
+ * ```
48863
+ *
48864
+ * @internal
48865
+ */ function mapVedaRevert(error) {
48866
+ if (error.name === NetworkError.TIMEOUT.name) {
48867
+ return error;
48868
+ }
48869
+ const revert = findVedaRevert(error);
48870
+ if (revert === undefined) {
48871
+ return error;
48872
+ }
48873
+ const trace = toRecord(error.cause?.trace);
48874
+ const chain = typeof trace['chain'] === 'string' ? trace['chain'] : revert.chain ?? 'EVM';
48875
+ if (revert.selector === SHARES_LOCKED_SELECTOR) {
48876
+ return new KitError({
48877
+ ...EarnError.SHARES_LOCKED,
48878
+ // The lock can last hours, so an immediate retry fails the same way.
48879
+ recoverability: 'FATAL',
48880
+ message: `Vault shares on ${chain} are still locked after a recent deposit. Wait for the vault's share lock period to end, then try again.`,
48881
+ cause: {
48882
+ trace: {
48883
+ ...trace,
48884
+ selector: revert.selector,
48885
+ chain
48886
+ }
48887
+ }
48888
+ });
48889
+ }
48890
+ const readable = VEDA_REVERT_REASONS[revert.selector];
48891
+ if (readable === undefined) {
48892
+ return error;
48893
+ }
48894
+ const reason = `${readable} (${revert.selector})`;
48895
+ if (error.name === OnchainError.SIMULATION_FAILED.name) {
48896
+ return createSimulationFailedError(chain, reason, trace);
48897
+ }
48898
+ if (error.name === OnchainError.TRANSACTION_REVERTED.name) {
48899
+ return createTransactionRevertedError(chain, reason, trace);
48900
+ }
48901
+ if (!revert.nested) {
48902
+ return error;
48903
+ }
48904
+ return new KitError({
48905
+ code: error.code,
48906
+ name: error.name,
48907
+ type: error.type,
48908
+ recoverability: error.recoverability,
48909
+ message: `${error.message} Reason: ${reason}.`,
48910
+ cause: {
48911
+ trace: {
48912
+ ...trace,
48913
+ reason
48914
+ }
48915
+ }
48916
+ });
48917
+ }
48918
+
48508
48919
  const EARN_OPERATIONS = new Set([
48509
48920
  'deposit',
48510
48921
  'withdraw',
@@ -48550,6 +48961,10 @@ const EARN_OPERATIONS = new Set([
48550
48961
  * `RESUMABLE` so callers know `retry()` can resume from the failed phase. A
48551
48962
  * fatal underlying error stays fatal — it cannot be resumed.
48552
48963
  *
48964
+ * A Veda vault revert is mapped first (see {@link mapVedaRevert}): a share
48965
+ * lock becomes `EARN_SHARES_LOCKED`, and other known Veda reverts get a
48966
+ * readable reason.
48967
+ *
48553
48968
  * Non-{@link KitError} inputs (which should not occur on provider code paths)
48554
48969
  * are normalized to a retryable {@link ServiceError.INTERNAL_ERROR}.
48555
48970
  *
@@ -48571,7 +48986,7 @@ const EARN_OPERATIONS = new Set([
48571
48986
  * }
48572
48987
  * ```
48573
48988
  */ function augmentEarnError(error, context) {
48574
- const base = isKitError(error) ? error : new KitError({
48989
+ const base = isKitError(error) ? mapVedaRevert(error) : new KitError({
48575
48990
  ...ServiceError.INTERNAL_ERROR,
48576
48991
  recoverability: 'RETRYABLE',
48577
48992
  message: getErrorMessage(error)
@@ -49514,7 +49929,7 @@ const bridgeDepositPrepareReviewSchema = z.object({
49514
49929
  }
49515
49930
 
49516
49931
  var name$2 = "@circle-fin/provider-earn-service";
49517
- var version$2 = "1.7.1";
49932
+ var version$2 = "1.7.2";
49518
49933
  var pkg$2 = {
49519
49934
  name: name$2,
49520
49935
  version: version$2};
@@ -50775,7 +51190,7 @@ function reportTransactionFailure(reportContext, action, error) {
50775
51190
  }
50776
51191
  function transactionReportErrorCode(error) {
50777
51192
  if (isKitError(error)) {
50778
- return error.name;
51193
+ return mapVedaRevert(error).name;
50779
51194
  }
50780
51195
  const message = getErrorMessage(error);
50781
51196
  if (/user (rejected|denied)|rejected by user/i.test(message)) {
@@ -54144,7 +54559,7 @@ registerKit(`${pkg$3.name}/${pkg$3.version}`);
54144
54559
  };
54145
54560
 
54146
54561
  var name$1 = "@circle-fin/borrow-kit";
54147
- var version$1 = "1.0.0";
54562
+ var version$1 = "1.1.0";
54148
54563
  var pkg$1 = {
54149
54564
  name: name$1,
54150
54565
  version: version$1};
@@ -64868,7 +65283,7 @@ function normaliseLoadTimeout(value) {
64868
65283
  currency: z.string().min(1).optional(),
64869
65284
  email: z.string().email().optional(),
64870
65285
  assets: onrampAssetSelectionSchema.optional(),
64871
- metadata: z.record(z.string(), z.unknown()).optional()
65286
+ metadata: z.record(z.string(), z.string()).optional()
64872
65287
  });
64873
65288
 
64874
65289
  /**
@@ -67053,7 +67468,7 @@ async function deposit$2(context, params) {
67053
67468
  }
67054
67469
 
67055
67470
  var name = "@circle-fin/unified-balance-kit";
67056
- var version = "1.8.0";
67471
+ var version = "1.8.1";
67057
67472
  var pkg = {
67058
67473
  name: name,
67059
67474
  version: version};