@circle-fin/app-kit 1.8.0 → 1.9.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.
@@ -24,6 +24,7 @@ var units = require('@ethersproject/units');
24
24
  var bytes = require('@ethersproject/bytes');
25
25
  var address = require('@ethersproject/address');
26
26
  var bs58 = require('bs58');
27
+ require('@ethersproject/abi');
27
28
  var web3_js = require('@solana/web3.js');
28
29
  require('bn.js');
29
30
  require('@coral-xyz/anchor');
@@ -2479,6 +2480,8 @@ class KitError extends Error {
2479
2480
  Blockchain["Celo_Alfajores_Testnet"] = "Celo_Alfajores_Testnet";
2480
2481
  Blockchain["Codex"] = "Codex";
2481
2482
  Blockchain["Codex_Testnet"] = "Codex_Testnet";
2483
+ Blockchain["Cronos"] = "Cronos";
2484
+ Blockchain["Cronos_Testnet"] = "Cronos_Testnet";
2482
2485
  Blockchain["Edge"] = "Edge";
2483
2486
  Blockchain["Edge_Testnet"] = "Edge_Testnet";
2484
2487
  Blockchain["Ethereum"] = "Ethereum";
@@ -2561,6 +2564,7 @@ var BridgeChain;
2561
2564
  BridgeChain["Avalanche"] = "Avalanche";
2562
2565
  BridgeChain["Base"] = "Base";
2563
2566
  BridgeChain["Codex"] = "Codex";
2567
+ BridgeChain["Cronos"] = "Cronos";
2564
2568
  BridgeChain["Edge"] = "Edge";
2565
2569
  BridgeChain["Ethereum"] = "Ethereum";
2566
2570
  BridgeChain["HyperEVM"] = "HyperEVM";
@@ -2585,6 +2589,7 @@ var BridgeChain;
2585
2589
  BridgeChain["Avalanche_Fuji"] = "Avalanche_Fuji";
2586
2590
  BridgeChain["Base_Sepolia"] = "Base_Sepolia";
2587
2591
  BridgeChain["Codex_Testnet"] = "Codex_Testnet";
2592
+ BridgeChain["Cronos_Testnet"] = "Cronos_Testnet";
2588
2593
  BridgeChain["Edge_Testnet"] = "Edge_Testnet";
2589
2594
  BridgeChain["Ethereum_Sepolia"] = "Ethereum_Sepolia";
2590
2595
  BridgeChain["HyperEVM_Testnet"] = "HyperEVM_Testnet";
@@ -3630,6 +3635,96 @@ var EarnChain;
3630
3635
  }
3631
3636
  });
3632
3637
 
3638
+ /**
3639
+ * Cronos Mainnet chain definition
3640
+ * @remarks
3641
+ * This represents the official production network for the Cronos blockchain.
3642
+ * Cronos is an EVM-compatible blockchain.
3643
+ */ const Cronos = defineChain({
3644
+ type: 'evm',
3645
+ chain: Blockchain.Cronos,
3646
+ name: 'Cronos',
3647
+ title: 'Cronos Mainnet',
3648
+ nativeCurrency: {
3649
+ name: 'Cronos',
3650
+ symbol: 'CRO',
3651
+ decimals: 18
3652
+ },
3653
+ chainId: 25,
3654
+ isTestnet: false,
3655
+ explorerUrl: 'https://cronoscan.com/tx/{hash}',
3656
+ rpcEndpoints: [
3657
+ 'https://evm.cronos.org'
3658
+ ],
3659
+ eurcAddress: '0xA6dE01a2d62C6B5f3525d768f34d276652C554c8',
3660
+ usdcAddress: '0x3D7F2C478aAfdB65542BCB44bCeeC05849999d2D',
3661
+ usdtAddress: null,
3662
+ cctp: {
3663
+ domain: 32,
3664
+ contracts: {
3665
+ v2: {
3666
+ type: 'split',
3667
+ tokenMessenger: '0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d',
3668
+ messageTransmitter: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',
3669
+ confirmations: 1,
3670
+ fastConfirmations: 1
3671
+ }
3672
+ },
3673
+ forwarderSupported: {
3674
+ source: false,
3675
+ destination: false
3676
+ }
3677
+ },
3678
+ kitContracts: {
3679
+ bridge: BRIDGE_CONTRACT_EVM_MAINNET
3680
+ }
3681
+ });
3682
+
3683
+ /**
3684
+ * Cronos Testnet chain definition
3685
+ * @remarks
3686
+ * This represents the official test network for the Cronos blockchain.
3687
+ * Cronos is an EVM-compatible blockchain.
3688
+ */ const CronosTestnet = defineChain({
3689
+ type: 'evm',
3690
+ chain: Blockchain.Cronos_Testnet,
3691
+ name: 'Cronos Testnet',
3692
+ title: 'Cronos Testnet',
3693
+ nativeCurrency: {
3694
+ name: 'CRO',
3695
+ symbol: 'tCRO',
3696
+ decimals: 18
3697
+ },
3698
+ chainId: 338,
3699
+ isTestnet: true,
3700
+ explorerUrl: 'https://explorer.cronos.org/testnet/tx/{hash}',
3701
+ rpcEndpoints: [
3702
+ 'https://evm-t3.cronos.org'
3703
+ ],
3704
+ eurcAddress: '0x31f7538adb53cF16350e6B0c89d03D91b7D12c46',
3705
+ usdcAddress: '0xEb33dc5fac03833e132593659e1dE7256aB59794',
3706
+ usdtAddress: null,
3707
+ cctp: {
3708
+ domain: 32,
3709
+ contracts: {
3710
+ v2: {
3711
+ type: 'split',
3712
+ tokenMessenger: '0x8FE6B999Dc680CcFDD5Bf7EB0974218be2542DAA',
3713
+ messageTransmitter: '0xE737e5cEBEEBa77EFE34D4aa090756590b1CE275',
3714
+ confirmations: 1,
3715
+ fastConfirmations: 1
3716
+ }
3717
+ },
3718
+ forwarderSupported: {
3719
+ source: false,
3720
+ destination: false
3721
+ }
3722
+ },
3723
+ kitContracts: {
3724
+ bridge: BRIDGE_CONTRACT_EVM_TESTNET
3725
+ }
3726
+ });
3727
+
3633
3728
  /**
3634
3729
  * Edge Mainnet chain definition
3635
3730
  * @remarks
@@ -5981,6 +6076,8 @@ var Chains = {
5981
6076
  CeloAlfajoresTestnet: CeloAlfajoresTestnet,
5982
6077
  Codex: Codex,
5983
6078
  CodexTestnet: CodexTestnet,
6079
+ Cronos: Cronos,
6080
+ CronosTestnet: CronosTestnet,
5984
6081
  Edge: Edge,
5985
6082
  EdgeTestnet: EdgeTestnet,
5986
6083
  Ethereum: Ethereum,
@@ -8046,6 +8143,7 @@ const swapTokenEnumSchema = zod.z.enum([
8046
8143
  [Blockchain.Base]: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
8047
8144
  [Blockchain.Celo]: '0xcebA9300f2b948710d2653dD7B07f33A8B32118C',
8048
8145
  [Blockchain.Codex]: '0xd996633a415985DBd7D6D12f4A4343E31f5037cf',
8146
+ [Blockchain.Cronos]: '0x3D7F2C478aAfdB65542BCB44bCeeC05849999d2D',
8049
8147
  [Blockchain.Edge]: '0x98d2919b9A214E6Fa5384AC81E6864bA686Ad74c',
8050
8148
  [Blockchain.Ethereum]: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
8051
8149
  [Blockchain.Hedera]: '0.0.456858',
@@ -8079,6 +8177,7 @@ const swapTokenEnumSchema = zod.z.enum([
8079
8177
  [Blockchain.Avalanche_Fuji]: '0x5425890298aed601595a70AB815c96711a31Bc65',
8080
8178
  [Blockchain.Base_Sepolia]: '0x036CbD53842c5426634e7929541eC2318f3dCF7e',
8081
8179
  [Blockchain.Codex_Testnet]: '0x6d7f141b6819C2c9CC2f818e6ad549E7Ca090F8f',
8180
+ [Blockchain.Cronos_Testnet]: '0xEb33dc5fac03833e132593659e1dE7256aB59794',
8082
8181
  [Blockchain.Edge_Testnet]: '0x2d9F7CAD728051AA35Ecdc472a14cf8cDF5CFD6B',
8083
8182
  [Blockchain.Ethereum_Sepolia]: '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238',
8084
8183
  [Blockchain.Hedera_Testnet]: '0.0.429274',
@@ -8146,13 +8245,22 @@ const swapTokenEnumSchema = zod.z.enum([
8146
8245
  symbol: 'EURC',
8147
8246
  decimals: 6,
8148
8247
  locators: {
8248
+ // =========================================================================
8249
+ // Mainnets
8250
+ // =========================================================================
8149
8251
  [Blockchain.Avalanche]: '0xc891EB4cbdEFf6e073e859e987815Ed1505c2ACD',
8150
8252
  [Blockchain.Base]: '0x60a3E35Cc302bFA44Cb288Bc5a4F316Fdb1adb42',
8253
+ [Blockchain.Cronos]: '0xA6dE01a2d62C6B5f3525d768f34d276652C554c8',
8151
8254
  [Blockchain.Ethereum]: '0x1aBaEA1f7C830bD89Acc67eC4af516284b1bC33c',
8152
8255
  [Blockchain.Solana]: 'HzwqbKZw8HxMN6bF2yFZNrht3c2iXXzpKcFu7uBEDKtr',
8153
8256
  [Blockchain.World_Chain]: '0x1C60ba0A0eD1019e8Eb035E6daF4155A5cE2380B',
8257
+ // =========================================================================
8154
8258
  // Testnets
8155
- [Blockchain.Arc_Testnet]: '0x89B50855Aa3bE2F677cD6303Cec089B5F319D72a'
8259
+ // =========================================================================
8260
+ [Blockchain.Arc_Testnet]: '0x89B50855Aa3bE2F677cD6303Cec089B5F319D72a',
8261
+ [Blockchain.Base_Sepolia]: '0x808456652fdb597867f38412077A9182bf77359F',
8262
+ [Blockchain.Cronos_Testnet]: '0x31f7538adb53cF16350e6B0c89d03D91b7D12c46',
8263
+ [Blockchain.Ethereum_Sepolia]: '0x08210F9170F89Ab7658F0B5E3fF39b0E03C594D4'
8156
8264
  }
8157
8265
  };
8158
8266
 
@@ -8362,8 +8470,7 @@ const swapTokenEnumSchema = zod.z.enum([
8362
8470
  * cirBTC (Circle Bitcoin) token definition with addresses and metadata.
8363
8471
  *
8364
8472
  * @remarks
8365
- * Built-in cirBTC definition for the TokenRegistry. Currently deployed
8366
- * on Arc Testnet.
8473
+ * Built-in cirBTC definition for the TokenRegistry.
8367
8474
  *
8368
8475
  * @example
8369
8476
  * ```typescript
@@ -8379,7 +8486,15 @@ const swapTokenEnumSchema = zod.z.enum([
8379
8486
  symbol: 'cirBTC',
8380
8487
  decimals: 8,
8381
8488
  locators: {
8382
- [Blockchain.Arc_Testnet]: '0xf0C4a4CE82A5746AbAAd9425360Ab04fbBA432BF'
8489
+ // =========================================================================
8490
+ // Mainnets
8491
+ // =========================================================================
8492
+ [Blockchain.Ethereum]: '0x72DFB2E44f59C5AD2bAFE84314E5b99a7cd5075E',
8493
+ // =========================================================================
8494
+ // Testnets
8495
+ // =========================================================================
8496
+ [Blockchain.Arc_Testnet]: '0xf0C4a4CE82A5746AbAAd9425360Ab04fbBA432BF',
8497
+ [Blockchain.Ethereum_Sepolia]: '0x3a3fe695F684Bf9b9e43CF43C2b895Ea5e392bB3'
8383
8498
  }
8384
8499
  };
8385
8500
 
@@ -9495,7 +9610,7 @@ function resolveOptions(options) {
9495
9610
  }
9496
9611
 
9497
9612
  var name$2 = "@circle-fin/bridge-kit";
9498
- var version$3 = "1.11.0";
9613
+ var version$3 = "1.12.0";
9499
9614
  var pkg$3 = {
9500
9615
  name: name$2,
9501
9616
  version: version$3};
@@ -12155,6 +12270,15 @@ const CUSTOM_BURN_GAS_ESTIMATE_EVM = 201_525n // p99 and max are same here: 201_
12155
12270
  ;
12156
12271
  const RECEIVE_MESSAGE_GAS_ESTIMATE_EVM = 237_401n // (99p: 163_963n + max: 310_839n) / 2 = 237_401n
12157
12272
  ;
12273
+ // Hard execution caps: observed max + ~30% buffer, used as gasLimit overrides on
12274
+ // chains whose eth_estimateGas under-reports (e.g. Cronos EIP-7623 calldata floor).
12275
+ // Kept separate from the fee-estimate averages above.
12276
+ const APPROVE_GAS_LIMIT_EVM = 100_000n // ERC-20 approve observed max ~46k
12277
+ ;
12278
+ const DEPOSIT_FOR_BURN_GAS_LIMIT_EVM = 300_000n // observed max 226_506 + ~30%
12279
+ ;
12280
+ const RECEIVE_MESSAGE_GAS_LIMIT_EVM = 400_000n // observed max 310_839 + ~30%
12281
+ ;
12158
12282
  /**
12159
12283
  * The minimum finality threshold for CCTPv2 transfers.
12160
12284
  *
@@ -12183,6 +12307,27 @@ const RECEIVE_MESSAGE_GAS_ESTIMATE_EVM = 237_401n // (99p: 163_963n + max: 310_8
12183
12307
  'Content-Type': 'application/json'
12184
12308
  }
12185
12309
  };
12310
+ /**
12311
+ * Merges caller-provided polling overrides on top of {@link DEFAULT_CONFIG}.
12312
+ *
12313
+ * Headers are merged independently so caller-supplied headers augment the
12314
+ * defaults (such as `Content-Type`) rather than replacing them wholesale.
12315
+ *
12316
+ * @param config - Caller-provided polling configuration overrides
12317
+ * @param internalDefaults - Internal defaults applied before `config` (for example a
12318
+ * reduced `maxRetries` for one-shot requests); `config` still wins on conflict
12319
+ * @returns The effective polling configuration
12320
+ * @internal
12321
+ */ const mergeAttestationConfig = (config, internalDefaults = {})=>({
12322
+ ...DEFAULT_CONFIG,
12323
+ ...internalDefaults,
12324
+ ...config,
12325
+ headers: {
12326
+ ...DEFAULT_CONFIG.headers,
12327
+ ...internalDefaults.headers,
12328
+ ...config.headers
12329
+ }
12330
+ });
12186
12331
  /**
12187
12332
  * Type guard that verifies if an unknown value matches the AttestationMessage shape
12188
12333
  * and has all required properties.
@@ -12329,10 +12474,7 @@ const RECEIVE_MESSAGE_GAS_ESTIMATE_EVM = 237_401n // (99p: 163_963n + max: 310_8
12329
12474
  * ```
12330
12475
  */ const fetchAttestation = async (sourceDomainId, transactionHash, isTestnet, config = {})=>{
12331
12476
  const url = buildIrisUrl(sourceDomainId, transactionHash, isTestnet);
12332
- const effectiveConfig = {
12333
- ...DEFAULT_CONFIG,
12334
- ...config
12335
- };
12477
+ const effectiveConfig = mergeAttestationConfig(config);
12336
12478
  return await pollApiGet(url, isAttestationResponse, effectiveConfig);
12337
12479
  };
12338
12480
  /**
@@ -12375,11 +12517,9 @@ const RECEIVE_MESSAGE_GAS_ESTIMATE_EVM = 237_401n // (99p: 163_963n + max: 310_8
12375
12517
  */ const fetchAttestationWithoutStatusCheck = async (sourceDomainId, transactionHash, isTestnet, config = {})=>{
12376
12518
  const url = buildIrisUrl(sourceDomainId, transactionHash, isTestnet);
12377
12519
  // Use minimal retries since we're just fetching existing data
12378
- const effectiveConfig = {
12379
- ...DEFAULT_CONFIG,
12380
- maxRetries: 3,
12381
- ...config
12382
- };
12520
+ const effectiveConfig = mergeAttestationConfig(config, {
12521
+ maxRetries: 3
12522
+ });
12383
12523
  return await pollApiGet(url, isAttestationResponseWithoutStatusCheck, effectiveConfig);
12384
12524
  };
12385
12525
  /**
@@ -12439,10 +12579,7 @@ const RECEIVE_MESSAGE_GAS_ESTIMATE_EVM = 237_401n // (99p: 163_963n + max: 310_8
12439
12579
  * ```
12440
12580
  */ const fetchReAttestedAttestation = async (sourceDomainId, transactionHash, isTestnet, config = {})=>{
12441
12581
  const url = buildIrisUrl(sourceDomainId, transactionHash, isTestnet);
12442
- const effectiveConfig = {
12443
- ...DEFAULT_CONFIG,
12444
- ...config
12445
- };
12582
+ const effectiveConfig = mergeAttestationConfig(config);
12446
12583
  return await pollApiGet(url, isReAttestedAttestationResponse, effectiveConfig);
12447
12584
  };
12448
12585
  /**
@@ -12508,14 +12645,139 @@ const RECEIVE_MESSAGE_GAS_ESTIMATE_EVM = 237_401n // (99p: 163_963n + max: 310_8
12508
12645
  */ const requestReAttestation = async (nonce, isTestnet, config = {})=>{
12509
12646
  const url = buildReAttestUrl(nonce, isTestnet);
12510
12647
  // Use minimal retries since we're just submitting a request, not polling for state
12511
- const effectiveConfig = {
12512
- ...DEFAULT_CONFIG,
12513
- maxRetries: 3,
12514
- ...config
12515
- };
12648
+ const effectiveConfig = mergeAttestationConfig(config, {
12649
+ maxRetries: 3
12650
+ });
12516
12651
  return await pollApiPost(url, {}, isReAttestationResponse, effectiveConfig);
12517
12652
  };
12518
12653
 
12654
+ /**
12655
+ * Type guard that checks if the relayer has confirmed the mint transaction.
12656
+ *
12657
+ * This function validates that:
12658
+ * 1. The response has valid AttestationResponse structure
12659
+ * 2. At least one message has forwardState === 'CONFIRMED' (or 'COMPLETE') and a valid forwardTxHash
12660
+ *
12661
+ * If forwardState is 'FAILED', throws a non-retryable KitError.
12662
+ * If forwardState is 'PENDING' or not present, throws a RETRYABLE KitError to continue polling.
12663
+ *
12664
+ * @param obj - The value to check, typically a parsed JSON response
12665
+ * @returns True if the relayer has confirmed the mint
12666
+ * @throws {KitError} With FATAL recoverability if structure is invalid
12667
+ * @throws {KitError} With RESUMABLE recoverability if forwardState is 'FAILED'
12668
+ * @throws {KitError} With RETRYABLE recoverability if still pending
12669
+ * @internal
12670
+ */ const isRelayerMintConfirmed = (obj)=>{
12671
+ // First check if the structure is valid
12672
+ if (!hasValidAttestationStructure(obj)) {
12673
+ throw new KitError({
12674
+ ...InputError.VALIDATION_FAILED,
12675
+ recoverability: 'FATAL',
12676
+ message: 'Invalid attestation response structure from IRIS API.'
12677
+ });
12678
+ }
12679
+ // Find the first message (typically there's only one)
12680
+ const message = obj.messages[0];
12681
+ if (!message) {
12682
+ throw new KitError({
12683
+ ...InputError.VALIDATION_FAILED,
12684
+ recoverability: 'FATAL',
12685
+ message: 'No attestation messages found in IRIS API response.'
12686
+ });
12687
+ }
12688
+ // Check for FAILED state - this is a permanent failure
12689
+ if (message.forwardState === 'FAILED') {
12690
+ throw new KitError({
12691
+ ...NetworkError.RELAYER_FORWARD_FAILED,
12692
+ recoverability: 'RESUMABLE',
12693
+ message: 'Circle relayer failed to forward the mint transaction. The mint may still have succeeded if another party submitted it. Check the recipient wallet balance before retrying. If the mint did not occur, you can manually submit it using the attestation data in the error cause.',
12694
+ cause: {
12695
+ trace: {
12696
+ eventNonce: message.eventNonce,
12697
+ attestation: message.attestation,
12698
+ message: message.message
12699
+ }
12700
+ }
12701
+ });
12702
+ }
12703
+ // Check if mint is confirmed (or complete) with a valid transaction hash
12704
+ // We accept both CONFIRMED and COMPLETE since COMPLETE implies CONFIRMED
12705
+ if ((message.forwardState === 'CONFIRMED' || message.forwardState === 'COMPLETE') && typeof message.forwardTxHash === 'string' && message.forwardTxHash.trim().length > 0) {
12706
+ return true;
12707
+ }
12708
+ // Still pending or not yet processed - throw RETRYABLE error to continue polling
12709
+ throw new KitError({
12710
+ ...NetworkError.RELAYER_PENDING,
12711
+ recoverability: 'RETRYABLE',
12712
+ message: 'Relayer mint not ready. Waiting for confirmation.'
12713
+ });
12714
+ };
12715
+ /**
12716
+ * Polls the attestation API until the relayer's mint transaction is confirmed.
12717
+ *
12718
+ * This function is used when `useForwarder` is enabled. Instead of the user
12719
+ * submitting the mint transaction, Circle's Orbit relayer handles it automatically.
12720
+ * This function polls until the relayer has submitted and confirmed the mint transaction.
12721
+ *
12722
+ * @remarks
12723
+ * - Uses a 20-minute timeout by default (600 retries × 2 seconds)
12724
+ * - Throws immediately if `forwardState` is 'FAILED'
12725
+ * - Waits for `forwardState` to be 'CONFIRMED' or 'COMPLETE' (COMPLETE implies CONFIRMED)
12726
+ * - Returns the attestation message with `forwardTxHash` populated
12727
+ *
12728
+ * @param sourceDomainId - The CCTP domain ID of the source chain
12729
+ * @param transactionHash - The transaction hash of the burn operation
12730
+ * @param isTestnet - Whether this is for a testnet chain (true) or mainnet (false)
12731
+ * @param config - Optional configuration overrides for polling behavior
12732
+ * @returns The attestation message with confirmed forwardTxHash
12733
+ * @throws {KitError} With code 'NETWORK_RELAYER_FORWARD_FAILED' if relayer failed
12734
+ * @throws {KitError} If timeout is reached while still pending
12735
+ *
12736
+ * @example
12737
+ * ```typescript
12738
+ * const attestation = await fetchRelayerMint(0, '0xabc...', false)
12739
+ * console.log('Relayer mint tx:', attestation.forwardTxHash)
12740
+ * ```
12741
+ */ const fetchRelayerMint = async (sourceDomainId, transactionHash, isTestnet, config = {})=>{
12742
+ const url = buildIrisUrl(sourceDomainId, transactionHash, isTestnet);
12743
+ const effectiveConfig = mergeAttestationConfig(config);
12744
+ let response;
12745
+ try {
12746
+ response = await pollApiGet(url, isRelayerMintConfirmed, effectiveConfig);
12747
+ } catch (error) {
12748
+ // Enrich RELAYER_FORWARD_FAILED errors with the burn transaction hash
12749
+ if (error instanceof KitError && error.name === 'NETWORK_RELAYER_FORWARD_FAILED') {
12750
+ throw new KitError({
12751
+ ...NetworkError.RELAYER_FORWARD_FAILED,
12752
+ recoverability: error.recoverability,
12753
+ message: error.message,
12754
+ cause: {
12755
+ ...error.cause,
12756
+ trace: {
12757
+ ...error.cause?.trace,
12758
+ burnTxHash: transactionHash
12759
+ }
12760
+ }
12761
+ });
12762
+ }
12763
+ throw error;
12764
+ }
12765
+ // Return the first message (which should have forwardTxHash)
12766
+ // Note: This check is needed for TypeScript type safety even though
12767
+ // isRelayerMintConfirmed validates messages[0] exists. The type guard
12768
+ // narrows the type at the call site, but TypeScript can't infer that
12769
+ // the array still has elements after pollApiGet returns.
12770
+ const message = response.messages[0];
12771
+ if (!message) {
12772
+ throw new KitError({
12773
+ ...InputError.VALIDATION_FAILED,
12774
+ recoverability: 'FATAL',
12775
+ message: 'No attestation messages found in response after polling.'
12776
+ });
12777
+ }
12778
+ return message;
12779
+ };
12780
+
12519
12781
  const assertCCTPv2WalletContextSymbol = Symbol('assertCCTPv2WalletContext');
12520
12782
  /**
12521
12783
  * Asserts that the provided parameters match the CCTPv2 wallet context interface.
@@ -13390,6 +13652,8 @@ function hasPendingState(analysis, result) {
13390
13652
  * - `adapter`: The adapter that will execute the transaction
13391
13653
  * - `confirmations`: The number of confirmations to wait for (defaults to 1)
13392
13654
  * - `timeout`: The timeout for the request in milliseconds
13655
+ * - `gasLimit`: Optional explicit gas limit (number) forwarded to EVM execute,
13656
+ * bypassing `eth_estimateGas`; ignored for non-EVM requests
13393
13657
  * @returns The bridge step with the transaction details and explorer URL
13394
13658
  * @throws If the transaction execution fails
13395
13659
  *
@@ -13404,7 +13668,7 @@ function hasPendingState(analysis, result) {
13404
13668
  * })
13405
13669
  * console.log('Transaction hash:', step.txHash)
13406
13670
  * ```
13407
- */ async function executePreparedChainRequest({ name, request, adapter, chain, confirmations = 1, timeout }) {
13671
+ */ async function executePreparedChainRequest({ name, request, adapter, chain, confirmations = 1, timeout, gasLimit }) {
13408
13672
  const step = {
13409
13673
  name,
13410
13674
  state: 'pending'
@@ -13417,7 +13681,9 @@ function hasPendingState(analysis, result) {
13417
13681
  step.state = 'noop';
13418
13682
  return step;
13419
13683
  }
13420
- const txHash = await request.execute();
13684
+ const txHash = request.type === 'evm' && gasLimit !== undefined ? await request.execute({
13685
+ gasLimit
13686
+ }) : await request.execute();
13421
13687
  step.txHash = txHash;
13422
13688
  const retryOptions = {
13423
13689
  isRetryable: (err)=>isRetryableError$1(parseBlockchainError(err, {
@@ -13489,7 +13755,8 @@ function hasPendingState(analysis, result) {
13489
13755
  name: 'approve',
13490
13756
  adapter: params.source.adapter,
13491
13757
  chain: params.source.chain,
13492
- request: await provider.approve(params.source, approvalAmount)
13758
+ request: await provider.approve(params.source, approvalAmount),
13759
+ gasLimit: Number(APPROVE_GAS_LIMIT_EVM)
13493
13760
  });
13494
13761
  }
13495
13762
 
@@ -13516,7 +13783,8 @@ function hasPendingState(analysis, result) {
13516
13783
  name: 'burn',
13517
13784
  adapter: params.source.adapter,
13518
13785
  chain: params.source.chain,
13519
- request: await provider.burn(params)
13786
+ request: await provider.burn(params),
13787
+ gasLimit: Number(DEPOSIT_FOR_BURN_GAS_LIMIT_EVM)
13520
13788
  });
13521
13789
  }
13522
13790
 
@@ -13602,11 +13870,18 @@ function hasPendingState(analysis, result) {
13602
13870
  */ async function bridgeMint({ params, provider }, attestation) {
13603
13871
  // Validate attestation message matches transfer params
13604
13872
  await assertCCTPv2AttestationParams(attestation, params);
13873
+ const mintRequest = await provider.mint(params.source, params.destination, attestation);
13605
13874
  const step = await executePreparedChainRequest({
13606
13875
  name: 'mint',
13607
13876
  adapter: params.destination.adapter,
13608
13877
  chain: params.destination.chain,
13609
- request: await provider.mint(params.source, params.destination, attestation)
13878
+ request: mintRequest,
13879
+ // Some chains (e.g. Cronos) enforce an EIP-7623 calldata gas floor that
13880
+ // eth_estimateGas does not account for, returning a below-floor value
13881
+ // without reverting. Pinning to a value above the observed execution max
13882
+ // (310_839) bypasses re-estimation and guarantees we clear both the floor
13883
+ // and the actual execution cost.
13884
+ gasLimit: Number(RECEIVE_MESSAGE_GAS_LIMIT_EVM)
13610
13885
  });
13611
13886
  // Add forwarded: false for non-relayer mints
13612
13887
  return {
@@ -13644,136 +13919,6 @@ const mockAttestationMessage = {
13644
13919
  delayReason: null
13645
13920
  };
13646
13921
 
13647
- /**
13648
- * Type guard that checks if the relayer has confirmed the mint transaction.
13649
- *
13650
- * This function validates that:
13651
- * 1. The response has valid AttestationResponse structure
13652
- * 2. At least one message has forwardState === 'CONFIRMED' (or 'COMPLETE') and a valid forwardTxHash
13653
- *
13654
- * If forwardState is 'FAILED', throws a non-retryable KitError.
13655
- * If forwardState is 'PENDING' or not present, throws a RETRYABLE KitError to continue polling.
13656
- *
13657
- * @param obj - The value to check, typically a parsed JSON response
13658
- * @returns True if the relayer has confirmed the mint
13659
- * @throws {KitError} With FATAL recoverability if structure is invalid
13660
- * @throws {KitError} With RESUMABLE recoverability if forwardState is 'FAILED'
13661
- * @throws {KitError} With RETRYABLE recoverability if still pending
13662
- * @internal
13663
- */ const isRelayerMintConfirmed = (obj)=>{
13664
- // First check if the structure is valid
13665
- if (!hasValidAttestationStructure(obj)) {
13666
- throw new KitError({
13667
- ...InputError.VALIDATION_FAILED,
13668
- recoverability: 'FATAL',
13669
- message: 'Invalid attestation response structure from IRIS API.'
13670
- });
13671
- }
13672
- // Find the first message (typically there's only one)
13673
- const message = obj.messages[0];
13674
- if (!message) {
13675
- throw new KitError({
13676
- ...InputError.VALIDATION_FAILED,
13677
- recoverability: 'FATAL',
13678
- message: 'No attestation messages found in IRIS API response.'
13679
- });
13680
- }
13681
- // Check for FAILED state - this is a permanent failure
13682
- if (message.forwardState === 'FAILED') {
13683
- throw new KitError({
13684
- ...NetworkError.RELAYER_FORWARD_FAILED,
13685
- recoverability: 'RESUMABLE',
13686
- message: 'Circle relayer failed to forward the mint transaction. The mint may still have succeeded if another party submitted it. Check the recipient wallet balance before retrying. If the mint did not occur, you can manually submit it using the attestation data in the error cause.',
13687
- cause: {
13688
- trace: {
13689
- eventNonce: message.eventNonce,
13690
- attestation: message.attestation,
13691
- message: message.message
13692
- }
13693
- }
13694
- });
13695
- }
13696
- // Check if mint is confirmed (or complete) with a valid transaction hash
13697
- // We accept both CONFIRMED and COMPLETE since COMPLETE implies CONFIRMED
13698
- if ((message.forwardState === 'CONFIRMED' || message.forwardState === 'COMPLETE') && typeof message.forwardTxHash === 'string' && message.forwardTxHash.trim().length > 0) {
13699
- return true;
13700
- }
13701
- // Still pending or not yet processed - throw RETRYABLE error to continue polling
13702
- throw new KitError({
13703
- ...NetworkError.RELAYER_PENDING,
13704
- recoverability: 'RETRYABLE',
13705
- message: 'Relayer mint not ready. Waiting for confirmation.'
13706
- });
13707
- };
13708
- /**
13709
- * Polls the attestation API until the relayer's mint transaction is confirmed.
13710
- *
13711
- * This function is used when `useForwarder` is enabled. Instead of the user
13712
- * submitting the mint transaction, Circle's Orbit relayer handles it automatically.
13713
- * This function polls until the relayer has submitted and confirmed the mint transaction.
13714
- *
13715
- * @remarks
13716
- * - Uses a 20-minute timeout by default (600 retries × 2 seconds)
13717
- * - Throws immediately if `forwardState` is 'FAILED'
13718
- * - Waits for `forwardState` to be 'CONFIRMED' or 'COMPLETE' (COMPLETE implies CONFIRMED)
13719
- * - Returns the attestation message with `forwardTxHash` populated
13720
- *
13721
- * @param sourceDomainId - The CCTP domain ID of the source chain
13722
- * @param transactionHash - The transaction hash of the burn operation
13723
- * @param isTestnet - Whether this is for a testnet chain (true) or mainnet (false)
13724
- * @param config - Optional configuration overrides for polling behavior
13725
- * @returns The attestation message with confirmed forwardTxHash
13726
- * @throws {KitError} With code 'NETWORK_RELAYER_FORWARD_FAILED' if relayer failed
13727
- * @throws {KitError} If timeout is reached while still pending
13728
- *
13729
- * @example
13730
- * ```typescript
13731
- * const attestation = await fetchRelayerMint(0, '0xabc...', false)
13732
- * console.log('Relayer mint tx:', attestation.forwardTxHash)
13733
- * ```
13734
- */ const fetchRelayerMint = async (sourceDomainId, transactionHash, isTestnet, config = {})=>{
13735
- const url = buildIrisUrl(sourceDomainId, transactionHash, isTestnet);
13736
- const effectiveConfig = {
13737
- ...DEFAULT_CONFIG,
13738
- ...config
13739
- };
13740
- let response;
13741
- try {
13742
- response = await pollApiGet(url, isRelayerMintConfirmed, effectiveConfig);
13743
- } catch (error) {
13744
- // Enrich RELAYER_FORWARD_FAILED errors with the burn transaction hash
13745
- if (error instanceof KitError && error.name === 'NETWORK_RELAYER_FORWARD_FAILED') {
13746
- throw new KitError({
13747
- ...NetworkError.RELAYER_FORWARD_FAILED,
13748
- recoverability: error.recoverability,
13749
- message: error.message,
13750
- cause: {
13751
- ...error.cause,
13752
- trace: {
13753
- ...error.cause?.trace,
13754
- burnTxHash: transactionHash
13755
- }
13756
- }
13757
- });
13758
- }
13759
- throw error;
13760
- }
13761
- // Return the first message (which should have forwardTxHash)
13762
- // Note: This check is needed for TypeScript type safety even though
13763
- // isRelayerMintConfirmed validates messages[0] exists. The type guard
13764
- // narrows the type at the call site, but TypeScript can't infer that
13765
- // the array still has elements after pollApiGet returns.
13766
- const message = response.messages[0];
13767
- if (!message) {
13768
- throw new KitError({
13769
- ...InputError.VALIDATION_FAILED,
13770
- recoverability: 'FATAL',
13771
- message: 'No attestation messages found in response after polling.'
13772
- });
13773
- }
13774
- return message;
13775
- };
13776
-
13777
13922
  /**
13778
13923
  * Executes the mint step for forwarding mode where Circle's relayer handles the mint.
13779
13924
  *
@@ -13787,6 +13932,7 @@ const mockAttestationMessage = {
13787
13932
  * immediately after the API confirms the mint.
13788
13933
  *
13789
13934
  * @param params - The bridge parameters containing source, destination, amount and config
13935
+ * @param provider - The CCTP v2 bridging provider
13790
13936
  * @param context - The step context containing burnTxHash from the burn step
13791
13937
  * @returns Promise resolving to the bridge step with transaction details
13792
13938
  * @throws {KitError} If burnTxHash is not available in context
@@ -13795,10 +13941,13 @@ const mockAttestationMessage = {
13795
13941
  *
13796
13942
  * @example
13797
13943
  * ```typescript
13798
- * const step = await bridgeRelayerMint(params, { burnTxHash: '0x...' })
13944
+ * const step = await bridgeRelayerMint(
13945
+ * { params, provider },
13946
+ * { burnTxHash: '0x...' }
13947
+ * )
13799
13948
  * console.log('Relayer mint tx:', step.txHash)
13800
13949
  * ```
13801
- */ async function bridgeRelayerMint(params, context) {
13950
+ */ async function bridgeRelayerMint({ params, provider }, context) {
13802
13951
  const step = {
13803
13952
  name: 'mint',
13804
13953
  state: 'pending',
@@ -13814,7 +13963,7 @@ const mockAttestationMessage = {
13814
13963
  }
13815
13964
  try {
13816
13965
  // Poll attestation API until relayer confirms the mint
13817
- const attestation = await fetchRelayerMint(params.source.chain.cctp.domain, context.burnTxHash, params.source.chain.isTestnet ?? false);
13966
+ const attestation = await provider.fetchRelayerMint(params.source, context.burnTxHash);
13818
13967
  // Extract the relayer's mint transaction hash
13819
13968
  const forwardTxHash = attestation.forwardTxHash;
13820
13969
  if (!forwardTxHash) {
@@ -13908,7 +14057,7 @@ const mockAttestationMessage = {
13908
14057
  name: 'mint',
13909
14058
  // bridgeRelayerMint validates context.burnTxHash internally with a KitError
13910
14059
  // bridgeMint requires attestationData which is validated here
13911
- executor: useForwarder ? async (params, _provider, context)=>{
14060
+ executor: useForwarder ? async (params, provider, context)=>{
13912
14061
  if (!context) {
13913
14062
  throw new KitError({
13914
14063
  ...InputError.VALIDATION_FAILED,
@@ -13916,7 +14065,10 @@ const mockAttestationMessage = {
13916
14065
  message: 'Step context is required for relayer mint'
13917
14066
  });
13918
14067
  }
13919
- return bridgeRelayerMint(params, context);
14068
+ return bridgeRelayerMint({
14069
+ params,
14070
+ provider
14071
+ }, context);
13920
14072
  } : async (params, provider, context)=>{
13921
14073
  if (!context?.attestationData) {
13922
14074
  throw new KitError({
@@ -14247,7 +14399,7 @@ const mockAttestationMessage = {
14247
14399
  return step;
14248
14400
  }
14249
14401
 
14250
- var version$2 = "1.8.4";
14402
+ var version$2 = "1.9.0";
14251
14403
  var pkg$2 = {
14252
14404
  version: version$2};
14253
14405
 
@@ -14953,6 +15105,39 @@ var pkg$2 = {
14953
15105
  }
14954
15106
  }
14955
15107
 
15108
+ function isPlainObject(value) {
15109
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
15110
+ return false;
15111
+ }
15112
+ const prototype = Object.getPrototypeOf(value);
15113
+ return prototype === Object.prototype || prototype === null;
15114
+ }
15115
+ function assertHeadersConfig(headers, field) {
15116
+ if (headers === undefined) {
15117
+ return;
15118
+ }
15119
+ if (!isPlainObject(headers)) {
15120
+ throw createValidationFailedError$1(field, headers, `${field} must be a plain object with string header values when provided`);
15121
+ }
15122
+ for (const [name, value] of Object.entries(headers)){
15123
+ if (typeof value !== 'string') {
15124
+ throw createValidationFailedError$1(`${field}.${name}`, value, 'header values must be strings');
15125
+ }
15126
+ }
15127
+ }
15128
+ function assertCCTPV2Config(config) {
15129
+ if (!isPlainObject(config)) {
15130
+ throw createValidationFailedError$1('config', config, 'config must be a plain object when provided');
15131
+ }
15132
+ assertHeadersConfig(config['headers'], 'config.headers');
15133
+ const attestation = config['attestation'];
15134
+ if (attestation !== undefined) {
15135
+ if (!isPlainObject(attestation)) {
15136
+ throw createValidationFailedError$1('config.attestation', attestation, 'config.attestation must be a plain object when provided');
15137
+ }
15138
+ assertHeadersConfig(attestation['headers'], 'config.attestation.headers');
15139
+ }
15140
+ }
14956
15141
  /**
14957
15142
  * All chains that are supported by the CCTP v2 provider.
14958
15143
  *
@@ -15021,9 +15206,38 @@ var pkg$2 = {
15021
15206
  * @param config - Optional configuration overrides for the provider
15022
15207
  */ constructor(config = {}){
15023
15208
  super();
15209
+ assertCCTPV2Config(config);
15024
15210
  this.config = config;
15025
15211
  }
15026
15212
  /**
15213
+ * Resolves the effective polling configuration for an attestation request.
15214
+ *
15215
+ * Precedence (lowest to highest): provider `config.attestation`, then the
15216
+ * per-call `config`. Headers merge independently across
15217
+ * `config.attestation.headers`, the provider-level `config.headers`, and any
15218
+ * per-call `config.headers`, so a more specific header augments rather than
15219
+ * replaces the broader ones. The `headers` key is omitted entirely when no
15220
+ * headers are configured, leaving the attestation fetchers' defaults intact.
15221
+ *
15222
+ * @param config - Optional per-call polling configuration overrides
15223
+ * @returns The merged polling configuration passed to the attestation fetchers
15224
+ */ resolveAttestationConfig(config) {
15225
+ const headers = {
15226
+ ...this.config?.attestation?.headers,
15227
+ ...this.config?.headers,
15228
+ ...config?.headers
15229
+ };
15230
+ // Polling fields follow normal precedence; headers are merged separately
15231
+ // below so narrower config layers augment rather than replace broader ones.
15232
+ return {
15233
+ ...this.config?.attestation,
15234
+ ...config,
15235
+ ...Object.keys(headers).length > 0 ? {
15236
+ headers
15237
+ } : {}
15238
+ };
15239
+ }
15240
+ /**
15027
15241
  * Execute a cross-chain USDC bridge operation using the CCTP v2 protocol.
15028
15242
  *
15029
15243
  * This method orchestrates the complete CCTP v2 bridge flow including validation,
@@ -15449,11 +15663,7 @@ var pkg$2 = {
15449
15663
  */ async fetchAttestation(source, transactionHash, config) {
15450
15664
  assertCCTPv2WalletContext(source);
15451
15665
  try {
15452
- // Merge configs: defaults <- global config <- per-call config
15453
- const effectiveConfig = {
15454
- ...this.config?.attestation,
15455
- ...config
15456
- };
15666
+ const effectiveConfig = this.resolveAttestationConfig(config);
15457
15667
  const response = await fetchAttestation(source.chain.cctp.domain, transactionHash, source.chain.isTestnet, effectiveConfig);
15458
15668
  const message = response.messages[0];
15459
15669
  if (!message) {
@@ -15470,6 +15680,49 @@ var pkg$2 = {
15470
15680
  }
15471
15681
  }
15472
15682
  /**
15683
+ * Polls attestation data until Circle's relayer mint transaction is confirmed.
15684
+ *
15685
+ * This method is used by forwarded transfers. It polls the same Iris
15686
+ * attestation endpoint as {@link CCTPV2BridgingProvider.fetchAttestation},
15687
+ * but waits for a completed relayer forward state and returns the attestation
15688
+ * message containing `forwardTxHash`.
15689
+ *
15690
+ * @typeParam TFromAdapterCapabilities - The type representing the capabilities of the source adapter
15691
+ * @param source - The source wallet context containing the chain definition and wallet address
15692
+ * @param transactionHash - The transaction hash of the burn operation
15693
+ * @param config - Optional polling configuration overrides for timeout, retries, delay, and headers
15694
+ * @returns A promise that resolves to the attestation message with `forwardTxHash`
15695
+ * @throws KitError If the relayer forward fails, the response is invalid, or polling times out
15696
+ *
15697
+ * @example
15698
+ * ```typescript
15699
+ * import { CCTPV2BridgingProvider } from '@circle-fin/provider-cctp-v2'
15700
+ * import { Chains } from '@core/chains'
15701
+ *
15702
+ * const provider = new CCTPV2BridgingProvider({
15703
+ * headers: { 'X-Partner-UUID': '00000000-0000-0000-0000-000000000000' },
15704
+ * })
15705
+ *
15706
+ * const attestation = await provider.fetchRelayerMint(
15707
+ * {
15708
+ * adapter,
15709
+ * chain: Chains.EthereumSepolia,
15710
+ * address: '0x1234...',
15711
+ * },
15712
+ * '0xabc123...',
15713
+ * )
15714
+ *
15715
+ * console.log('Relayer mint tx:', attestation.forwardTxHash)
15716
+ * ```
15717
+ */ async fetchRelayerMint(source, transactionHash, config) {
15718
+ assertCCTPv2WalletContext(source);
15719
+ if (typeof transactionHash !== 'string' || transactionHash.trim() === '') {
15720
+ throw createValidationFailedError$1('transactionHash', transactionHash, 'transactionHash must be a non-empty string');
15721
+ }
15722
+ const effectiveConfig = this.resolveAttestationConfig(config);
15723
+ return await fetchRelayerMint(source.chain.cctp.domain, transactionHash, source.chain.isTestnet, effectiveConfig);
15724
+ }
15725
+ /**
15473
15726
  * Requests a fresh attestation for an expired attestation.
15474
15727
  *
15475
15728
  * This method is used when the original attestation has expired before the mint
@@ -15523,11 +15776,7 @@ var pkg$2 = {
15523
15776
  throw new Error('Failed to re-attest: Invalid transaction hash');
15524
15777
  }
15525
15778
  try {
15526
- // Merge configs: defaults <- global config <- per-call config
15527
- const effectiveConfig = {
15528
- ...this.config?.attestation,
15529
- ...config
15530
- };
15779
+ const effectiveConfig = this.resolveAttestationConfig(config);
15531
15780
  // Step 1: Get existing attestation data to extract nonce
15532
15781
  const existingAttestation = await fetchAttestationWithoutStatusCheck(source.chain.cctp.domain, transactionHash, source.chain.isTestnet, effectiveConfig);
15533
15782
  const nonce = existingAttestation.messages[0]?.eventNonce;
@@ -15812,8 +16061,13 @@ var pkg$2 = {
15812
16061
  /**
15813
16062
  * The default providers that will be used in addition to the providers provided
15814
16063
  * to the BridgeKit constructor.
15815
- */ const getDefaultProviders = ()=>[
15816
- new CCTPV2BridgingProvider()
16064
+ *
16065
+ * @param config - Optional configuration forwarded to the default providers
16066
+ * @returns The default bridging providers
16067
+ */ const getDefaultProviders = (config = {})=>[
16068
+ new CCTPV2BridgingProvider(config.headers ? {
16069
+ headers: config.headers
16070
+ } : {})
15817
16071
  ];
15818
16072
 
15819
16073
  /**
@@ -16056,7 +16310,9 @@ var pkg$2 = {
16056
16310
  * ```
16057
16311
  */ constructor(config = {}){
16058
16312
  // Handle provider configuration
16059
- const defaultProviders = getDefaultProviders();
16313
+ const defaultProviders = getDefaultProviders(config.headers ? {
16314
+ headers: config.headers
16315
+ } : {});
16060
16316
  this.providers = [
16061
16317
  ...defaultProviders,
16062
16318
  ...config.providers ?? []
@@ -16636,6 +16892,9 @@ registerKit(`${pkg$3.name}/${pkg$3.version}`);
16636
16892
  const kit = new BridgeKit({
16637
16893
  ...context.disableErrorReporting != null && {
16638
16894
  disableErrorReporting: context.disableErrorReporting
16895
+ },
16896
+ ...context.headers != null && {
16897
+ headers: context.headers
16639
16898
  }
16640
16899
  });
16641
16900
  if (hasBoth) {
@@ -16654,7 +16913,7 @@ registerKit(`${pkg$3.name}/${pkg$3.version}`);
16654
16913
  };
16655
16914
 
16656
16915
  var name$1 = "@circle-fin/swap-kit";
16657
- var version$1 = "1.3.0";
16916
+ var version$1 = "1.3.2";
16658
16917
  var pkg$1 = {
16659
16918
  name: name$1,
16660
16919
  version: version$1};
@@ -18582,7 +18841,7 @@ new Set(Object.values(Blockchain));
18582
18841
  registerKit(`${pkg$1.name}/${pkg$1.version}`);
18583
18842
 
18584
18843
  var name = "@circle-fin/earn-kit";
18585
- var version = "1.2.0";
18844
+ var version = "1.2.2";
18586
18845
  var pkg = {
18587
18846
  name: name,
18588
18847
  version: version};
@@ -18621,20 +18880,7 @@ var pkg = {
18621
18880
  */ ({
18622
18881
  [Blockchain.Arc_Testnet]: CHAIN_TO_API[Blockchain.Arc_Testnet]
18623
18882
  });
18624
- /**
18625
- * Expected EIP-712 domain of the ERC-3009 authorization token per source
18626
- * chain.
18627
- *
18628
- * Cross-chain Earn deposits are USDC-only, but USDC deployments differ on the
18629
- * EIP-712 domain name: newer deployments use `USDC` while older ones (for
18630
- * example Arbitrum Sepolia) kept `USD Coin` from the FiatToken V2 upgrade.
18631
- * These values mirror the bridge service's per-chain domain table and the
18632
- * on-chain `DOMAIN_SEPARATOR` inputs. Asserted before signing so a tampered
18633
- * prepare response cannot point the signature at another token. The
18634
- * `satisfies` check forces a domain entry whenever a source chain is added.
18635
- *
18636
- * @internal
18637
- */ ({
18883
+ ({
18638
18884
  [Blockchain.Arbitrum_Sepolia]: {
18639
18885
  },
18640
18886
  [Blockchain.Base_Sepolia]: {
@@ -18670,6 +18916,7 @@ const hexSignatureSchema = evmSignatureSchema;
18670
18916
  const hexAddressSchema = evmAddressSchema;
18671
18917
  // '0x' prefix + 32 bytes * 2 hex chars.
18672
18918
  const BYTES32_HEX_LENGTH = 66;
18919
+ const bridgeFeeTokenSchema = hexAddressSchema;
18673
18920
  /**
18674
18921
  * Zod schema for a non-negative uint256-like value.
18675
18922
  *
@@ -18956,14 +19203,12 @@ const eip712DomainSchema = eip712DomainSchema$1.extend({
18956
19203
  *
18957
19204
  * The bridge prepare path returns one item per collected source fee (e.g.
18958
19205
  * `PRE_FINALITY` for the fast-burn fee and `FORWARD` for the destination
18959
- * forward fee), all denominated in the shared `feeToken`. The signed
18960
- * authorization `value` is `principal + sum(items[].amount)`, so the pre-sign
18961
- * guard parses these to recompute the expected value. Each item's `amount` is
18962
- * a base-unit decimal string in `feeToken` units.
19206
+ * forward fee), all denominated in the shared `feeToken`. Each item's `amount`
19207
+ * is a base-unit decimal string in `feeToken` units.
18963
19208
  *
18964
19209
  * @internal
18965
19210
  */ const bridgeFeeQuoteSchema = zod.z.object({
18966
- feeToken: hexAddressSchema,
19211
+ feeToken: bridgeFeeTokenSchema,
18967
19212
  items: zod.z.array(zod.z.object({
18968
19213
  type: zod.z.string(),
18969
19214
  amount: uint256LikeSchema
@@ -18979,6 +19224,12 @@ const eip712DomainSchema = eip712DomainSchema$1.extend({
18979
19224
  erc3009TypedData: erc3009TypedDataSchema,
18980
19225
  feeQuote: bridgeFeeQuoteSchema
18981
19226
  }).passthrough();
19227
+ const bridgeDepositPrepareReviewSchema = zod.z.object({
19228
+ sourceChain: zod.z.string(),
19229
+ destinationChain: zod.z.string(),
19230
+ amount: amountJsonSchema,
19231
+ vaultAddress: hexAddressSchema
19232
+ }).passthrough();
18982
19233
  /**
18983
19234
  * Zod schema for the bridge deposit prepare payload.
18984
19235
  *
@@ -18990,7 +19241,7 @@ const eip712DomainSchema = eip712DomainSchema$1.extend({
18990
19241
  execId: bridgeDepositExecIdSchema,
18991
19242
  erc3009TypedData: bridgeDepositPreparedBundleSchema,
18992
19243
  expiresAt: zod.z.string().datetime(),
18993
- review: zod.z.unknown().optional()
19244
+ review: bridgeDepositPrepareReviewSchema
18994
19245
  });
18995
19246
  /**
18996
19247
  * Zod schema for the `POST /v1/earnKit/bridge/deposit/prepare` API response.
@@ -19115,10 +19366,11 @@ const eip712DomainSchema = eip712DomainSchema$1.extend({
19115
19366
  * Zod schema for a fee entry in an EarnKit API response.
19116
19367
  *
19117
19368
  * Shared across deposit and withdrawal responses (and reusable for real
19118
- * charged fees, not just quote estimates). `type` identifies the fee category
19119
- * for cross-chain deposit quotes this is the kits-proxy fee-quote item type
19120
- * (e.g. `'FORWARD'`, `'PRE_FINALITY'`). `status` qualifies the fee (e.g.
19121
- * `'estimated'` for a pre-sign cross-chain fee). Both are omitted on plain fees.
19369
+ * charged fees, not just quote estimates). `type` identifies the fee category.
19370
+ * For cross-chain deposit quotes this is the kits-proxy fee-quote item type
19371
+ * (e.g. `'FORWARD'`, `'PRE_FINALITY'`). For withdrawal quotes, Circle fees use
19372
+ * `type: 'circle'`. `status` qualifies the fee (e.g. `'estimated'` for a
19373
+ * pre-sign cross-chain fee). Both are omitted on plain fees.
19122
19374
  *
19123
19375
  * @internal
19124
19376
  */ const feeSchema = zod.z.object({
@@ -19269,6 +19521,10 @@ const eip712DomainSchema = eip712DomainSchema$1.extend({
19269
19521
  data: exploreVaultsPayloadSchema
19270
19522
  });
19271
19523
 
19524
+ // Intentionally built-ins-only: Earn bridge support is limited to SDK-known
19525
+ // token contracts plus the explicit ERC-3009 domain allowlist below.
19526
+ createTokenRegistry();
19527
+
19272
19528
  /**
19273
19529
  * Shared UTF-8 encoder for building the keccak input in
19274
19530
  * {@link isValidEip55Checksum}, hoisted to module scope to avoid allocating a
@@ -19391,10 +19647,9 @@ const sourceAdapterContextSchema = zod.z.object({
19391
19647
  * Schema for validating human-readable decimal amount strings.
19392
19648
  *
19393
19649
  * Accept positive decimal strings like '100', '100.50', '0.001'. Reject
19394
- * zero, negative, non-numeric, and non-canonical strings. EarnKit
19395
- * same-chain amounts are USDC/EURC (6 decimals), so precision is capped at
19396
- * 6 to match the Earn Service and fail fast locally instead of leaking
19397
- * 7+ decimal-place inputs to the server.
19650
+ * zero, negative, non-numeric, and non-canonical strings. Same-chain
19651
+ * EarnKit vaults can use different asset precisions, so the service enforces
19652
+ * the vault-specific decimal cap after resolving the vault asset.
19398
19653
  *
19399
19654
  * @internal
19400
19655
  */ const amountSchema = zod.z.string({
@@ -19403,32 +19658,15 @@ const sourceAdapterContextSchema = zod.z.object({
19403
19658
  allowZero: false,
19404
19659
  regexMessage: AMOUNT_FORMAT_ERROR_MESSAGE,
19405
19660
  attributeName: 'amount',
19406
- maxDecimals: 6
19407
- })(zod.z.string())).refine((value)=>CANONICAL_AMOUNT_REGEX.test(value), AMOUNT_FORMAT_ERROR_MESSAGE);
19408
- /**
19409
- * Schema for cross-chain deposit amount strings.
19410
- *
19411
- * Cross-chain Earn deposits are USDC-only, and the signed ERC-3009 value is
19412
- * denominated in USDC's 6 decimals. Reject more precise inputs up front so
19413
- * the signed value always equals the requested amount instead of a silent
19414
- * truncation. Non-canonical forms (leading dot, leading zeros) are rejected
19415
- * too, matching the Earn Service.
19416
- *
19417
- * @internal
19418
- */ const crossChainAmountSchema = zod.z.string({
19419
- required_error: 'amount is required'
19420
- }).min(1, 'amount is required').pipe(createDecimalStringValidator({
19421
- allowZero: false,
19422
- regexMessage: AMOUNT_FORMAT_ERROR_MESSAGE,
19423
- attributeName: 'amount',
19424
- maxDecimals: 6
19661
+ maxDecimals: 18
19425
19662
  })(zod.z.string())).refine((value)=>CANONICAL_AMOUNT_REGEX.test(value), AMOUNT_FORMAT_ERROR_MESSAGE);
19426
19663
  /**
19427
19664
  * Schema for cross-chain source fee caps.
19428
19665
  *
19429
- * Cross-chain source fees are denominated in USDC base units. Zero is valid
19430
- * when the quote contains no source-collected fees; otherwise the cap should be
19431
- * the caller-accepted total from a recent quote.
19666
+ * Cross-chain source fees are denominated in the quote's fee token. Zero is
19667
+ * valid when the quote contains no source-collected fees; otherwise the cap
19668
+ * should be the caller-accepted total from a recent quote. The provider
19669
+ * enforces the prepared bundle's fee-token precision before signing.
19432
19670
  *
19433
19671
  * @internal
19434
19672
  */ const crossChainMaxFeeSchema = zod.z.string({
@@ -19437,7 +19675,7 @@ const sourceAdapterContextSchema = zod.z.object({
19437
19675
  allowZero: true,
19438
19676
  regexMessage: AMOUNT_FORMAT_ERROR_MESSAGE,
19439
19677
  attributeName: 'maxFee',
19440
- maxDecimals: 6
19678
+ maxDecimals: 18
19441
19679
  })(zod.z.string())).refine((value)=>CANONICAL_AMOUNT_REGEX.test(value), AMOUNT_FORMAT_ERROR_MESSAGE);
19442
19680
  /**
19443
19681
  * Build a schema for an optional non-negative decimal filter string.
@@ -19598,7 +19836,7 @@ const crossChainDepositDestinationSchema = zod.z.object({
19598
19836
  from: sourceAdapterContextSchema,
19599
19837
  to: crossChainDepositDestinationSchema,
19600
19838
  vaultAddress: vaultAddressSchema,
19601
- amount: crossChainAmountSchema,
19839
+ amount: amountSchema,
19602
19840
  maxFee: crossChainMaxFeeSchema,
19603
19841
  transferSpeed: zod.z.enum([
19604
19842
  'FAST',