@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.
@@ -22,6 +22,7 @@ import { formatUnits as formatUnits$1, parseUnits as parseUnits$1 } from '@ether
22
22
  import { hexlify, hexZeroPad } from '@ethersproject/bytes';
23
23
  import { getAddress } from '@ethersproject/address';
24
24
  import bs58 from 'bs58';
25
+ import '@ethersproject/abi';
25
26
  import { PublicKey } from '@solana/web3.js';
26
27
  import 'bn.js';
27
28
  import '@coral-xyz/anchor';
@@ -2472,6 +2473,8 @@ class KitError extends Error {
2472
2473
  Blockchain["Celo_Alfajores_Testnet"] = "Celo_Alfajores_Testnet";
2473
2474
  Blockchain["Codex"] = "Codex";
2474
2475
  Blockchain["Codex_Testnet"] = "Codex_Testnet";
2476
+ Blockchain["Cronos"] = "Cronos";
2477
+ Blockchain["Cronos_Testnet"] = "Cronos_Testnet";
2475
2478
  Blockchain["Edge"] = "Edge";
2476
2479
  Blockchain["Edge_Testnet"] = "Edge_Testnet";
2477
2480
  Blockchain["Ethereum"] = "Ethereum";
@@ -2554,6 +2557,7 @@ var BridgeChain;
2554
2557
  BridgeChain["Avalanche"] = "Avalanche";
2555
2558
  BridgeChain["Base"] = "Base";
2556
2559
  BridgeChain["Codex"] = "Codex";
2560
+ BridgeChain["Cronos"] = "Cronos";
2557
2561
  BridgeChain["Edge"] = "Edge";
2558
2562
  BridgeChain["Ethereum"] = "Ethereum";
2559
2563
  BridgeChain["HyperEVM"] = "HyperEVM";
@@ -2578,6 +2582,7 @@ var BridgeChain;
2578
2582
  BridgeChain["Avalanche_Fuji"] = "Avalanche_Fuji";
2579
2583
  BridgeChain["Base_Sepolia"] = "Base_Sepolia";
2580
2584
  BridgeChain["Codex_Testnet"] = "Codex_Testnet";
2585
+ BridgeChain["Cronos_Testnet"] = "Cronos_Testnet";
2581
2586
  BridgeChain["Edge_Testnet"] = "Edge_Testnet";
2582
2587
  BridgeChain["Ethereum_Sepolia"] = "Ethereum_Sepolia";
2583
2588
  BridgeChain["HyperEVM_Testnet"] = "HyperEVM_Testnet";
@@ -3623,6 +3628,96 @@ var EarnChain;
3623
3628
  }
3624
3629
  });
3625
3630
 
3631
+ /**
3632
+ * Cronos Mainnet chain definition
3633
+ * @remarks
3634
+ * This represents the official production network for the Cronos blockchain.
3635
+ * Cronos is an EVM-compatible blockchain.
3636
+ */ const Cronos = defineChain({
3637
+ type: 'evm',
3638
+ chain: Blockchain.Cronos,
3639
+ name: 'Cronos',
3640
+ title: 'Cronos Mainnet',
3641
+ nativeCurrency: {
3642
+ name: 'Cronos',
3643
+ symbol: 'CRO',
3644
+ decimals: 18
3645
+ },
3646
+ chainId: 25,
3647
+ isTestnet: false,
3648
+ explorerUrl: 'https://cronoscan.com/tx/{hash}',
3649
+ rpcEndpoints: [
3650
+ 'https://evm.cronos.org'
3651
+ ],
3652
+ eurcAddress: '0xA6dE01a2d62C6B5f3525d768f34d276652C554c8',
3653
+ usdcAddress: '0x3D7F2C478aAfdB65542BCB44bCeeC05849999d2D',
3654
+ usdtAddress: null,
3655
+ cctp: {
3656
+ domain: 32,
3657
+ contracts: {
3658
+ v2: {
3659
+ type: 'split',
3660
+ tokenMessenger: '0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d',
3661
+ messageTransmitter: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',
3662
+ confirmations: 1,
3663
+ fastConfirmations: 1
3664
+ }
3665
+ },
3666
+ forwarderSupported: {
3667
+ source: false,
3668
+ destination: false
3669
+ }
3670
+ },
3671
+ kitContracts: {
3672
+ bridge: BRIDGE_CONTRACT_EVM_MAINNET
3673
+ }
3674
+ });
3675
+
3676
+ /**
3677
+ * Cronos Testnet chain definition
3678
+ * @remarks
3679
+ * This represents the official test network for the Cronos blockchain.
3680
+ * Cronos is an EVM-compatible blockchain.
3681
+ */ const CronosTestnet = defineChain({
3682
+ type: 'evm',
3683
+ chain: Blockchain.Cronos_Testnet,
3684
+ name: 'Cronos Testnet',
3685
+ title: 'Cronos Testnet',
3686
+ nativeCurrency: {
3687
+ name: 'CRO',
3688
+ symbol: 'tCRO',
3689
+ decimals: 18
3690
+ },
3691
+ chainId: 338,
3692
+ isTestnet: true,
3693
+ explorerUrl: 'https://explorer.cronos.org/testnet/tx/{hash}',
3694
+ rpcEndpoints: [
3695
+ 'https://evm-t3.cronos.org'
3696
+ ],
3697
+ eurcAddress: '0x31f7538adb53cF16350e6B0c89d03D91b7D12c46',
3698
+ usdcAddress: '0xEb33dc5fac03833e132593659e1dE7256aB59794',
3699
+ usdtAddress: null,
3700
+ cctp: {
3701
+ domain: 32,
3702
+ contracts: {
3703
+ v2: {
3704
+ type: 'split',
3705
+ tokenMessenger: '0x8FE6B999Dc680CcFDD5Bf7EB0974218be2542DAA',
3706
+ messageTransmitter: '0xE737e5cEBEEBa77EFE34D4aa090756590b1CE275',
3707
+ confirmations: 1,
3708
+ fastConfirmations: 1
3709
+ }
3710
+ },
3711
+ forwarderSupported: {
3712
+ source: false,
3713
+ destination: false
3714
+ }
3715
+ },
3716
+ kitContracts: {
3717
+ bridge: BRIDGE_CONTRACT_EVM_TESTNET
3718
+ }
3719
+ });
3720
+
3626
3721
  /**
3627
3722
  * Edge Mainnet chain definition
3628
3723
  * @remarks
@@ -5974,6 +6069,8 @@ var Chains = /*#__PURE__*/Object.freeze({
5974
6069
  CeloAlfajoresTestnet: CeloAlfajoresTestnet,
5975
6070
  Codex: Codex,
5976
6071
  CodexTestnet: CodexTestnet,
6072
+ Cronos: Cronos,
6073
+ CronosTestnet: CronosTestnet,
5977
6074
  Edge: Edge,
5978
6075
  EdgeTestnet: EdgeTestnet,
5979
6076
  Ethereum: Ethereum,
@@ -8039,6 +8136,7 @@ const swapTokenEnumSchema = z.enum([
8039
8136
  [Blockchain.Base]: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
8040
8137
  [Blockchain.Celo]: '0xcebA9300f2b948710d2653dD7B07f33A8B32118C',
8041
8138
  [Blockchain.Codex]: '0xd996633a415985DBd7D6D12f4A4343E31f5037cf',
8139
+ [Blockchain.Cronos]: '0x3D7F2C478aAfdB65542BCB44bCeeC05849999d2D',
8042
8140
  [Blockchain.Edge]: '0x98d2919b9A214E6Fa5384AC81E6864bA686Ad74c',
8043
8141
  [Blockchain.Ethereum]: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
8044
8142
  [Blockchain.Hedera]: '0.0.456858',
@@ -8072,6 +8170,7 @@ const swapTokenEnumSchema = z.enum([
8072
8170
  [Blockchain.Avalanche_Fuji]: '0x5425890298aed601595a70AB815c96711a31Bc65',
8073
8171
  [Blockchain.Base_Sepolia]: '0x036CbD53842c5426634e7929541eC2318f3dCF7e',
8074
8172
  [Blockchain.Codex_Testnet]: '0x6d7f141b6819C2c9CC2f818e6ad549E7Ca090F8f',
8173
+ [Blockchain.Cronos_Testnet]: '0xEb33dc5fac03833e132593659e1dE7256aB59794',
8075
8174
  [Blockchain.Edge_Testnet]: '0x2d9F7CAD728051AA35Ecdc472a14cf8cDF5CFD6B',
8076
8175
  [Blockchain.Ethereum_Sepolia]: '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238',
8077
8176
  [Blockchain.Hedera_Testnet]: '0.0.429274',
@@ -8139,13 +8238,22 @@ const swapTokenEnumSchema = z.enum([
8139
8238
  symbol: 'EURC',
8140
8239
  decimals: 6,
8141
8240
  locators: {
8241
+ // =========================================================================
8242
+ // Mainnets
8243
+ // =========================================================================
8142
8244
  [Blockchain.Avalanche]: '0xc891EB4cbdEFf6e073e859e987815Ed1505c2ACD',
8143
8245
  [Blockchain.Base]: '0x60a3E35Cc302bFA44Cb288Bc5a4F316Fdb1adb42',
8246
+ [Blockchain.Cronos]: '0xA6dE01a2d62C6B5f3525d768f34d276652C554c8',
8144
8247
  [Blockchain.Ethereum]: '0x1aBaEA1f7C830bD89Acc67eC4af516284b1bC33c',
8145
8248
  [Blockchain.Solana]: 'HzwqbKZw8HxMN6bF2yFZNrht3c2iXXzpKcFu7uBEDKtr',
8146
8249
  [Blockchain.World_Chain]: '0x1C60ba0A0eD1019e8Eb035E6daF4155A5cE2380B',
8250
+ // =========================================================================
8147
8251
  // Testnets
8148
- [Blockchain.Arc_Testnet]: '0x89B50855Aa3bE2F677cD6303Cec089B5F319D72a'
8252
+ // =========================================================================
8253
+ [Blockchain.Arc_Testnet]: '0x89B50855Aa3bE2F677cD6303Cec089B5F319D72a',
8254
+ [Blockchain.Base_Sepolia]: '0x808456652fdb597867f38412077A9182bf77359F',
8255
+ [Blockchain.Cronos_Testnet]: '0x31f7538adb53cF16350e6B0c89d03D91b7D12c46',
8256
+ [Blockchain.Ethereum_Sepolia]: '0x08210F9170F89Ab7658F0B5E3fF39b0E03C594D4'
8149
8257
  }
8150
8258
  };
8151
8259
 
@@ -8355,8 +8463,7 @@ const swapTokenEnumSchema = z.enum([
8355
8463
  * cirBTC (Circle Bitcoin) token definition with addresses and metadata.
8356
8464
  *
8357
8465
  * @remarks
8358
- * Built-in cirBTC definition for the TokenRegistry. Currently deployed
8359
- * on Arc Testnet.
8466
+ * Built-in cirBTC definition for the TokenRegistry.
8360
8467
  *
8361
8468
  * @example
8362
8469
  * ```typescript
@@ -8372,7 +8479,15 @@ const swapTokenEnumSchema = z.enum([
8372
8479
  symbol: 'cirBTC',
8373
8480
  decimals: 8,
8374
8481
  locators: {
8375
- [Blockchain.Arc_Testnet]: '0xf0C4a4CE82A5746AbAAd9425360Ab04fbBA432BF'
8482
+ // =========================================================================
8483
+ // Mainnets
8484
+ // =========================================================================
8485
+ [Blockchain.Ethereum]: '0x72DFB2E44f59C5AD2bAFE84314E5b99a7cd5075E',
8486
+ // =========================================================================
8487
+ // Testnets
8488
+ // =========================================================================
8489
+ [Blockchain.Arc_Testnet]: '0xf0C4a4CE82A5746AbAAd9425360Ab04fbBA432BF',
8490
+ [Blockchain.Ethereum_Sepolia]: '0x3a3fe695F684Bf9b9e43CF43C2b895Ea5e392bB3'
8376
8491
  }
8377
8492
  };
8378
8493
 
@@ -9488,7 +9603,7 @@ function resolveOptions(options) {
9488
9603
  }
9489
9604
 
9490
9605
  var name$2 = "@circle-fin/bridge-kit";
9491
- var version$3 = "1.11.0";
9606
+ var version$3 = "1.12.0";
9492
9607
  var pkg$3 = {
9493
9608
  name: name$2,
9494
9609
  version: version$3};
@@ -12148,6 +12263,15 @@ const CUSTOM_BURN_GAS_ESTIMATE_EVM = 201_525n // p99 and max are same here: 201_
12148
12263
  ;
12149
12264
  const RECEIVE_MESSAGE_GAS_ESTIMATE_EVM = 237_401n // (99p: 163_963n + max: 310_839n) / 2 = 237_401n
12150
12265
  ;
12266
+ // Hard execution caps: observed max + ~30% buffer, used as gasLimit overrides on
12267
+ // chains whose eth_estimateGas under-reports (e.g. Cronos EIP-7623 calldata floor).
12268
+ // Kept separate from the fee-estimate averages above.
12269
+ const APPROVE_GAS_LIMIT_EVM = 100_000n // ERC-20 approve observed max ~46k
12270
+ ;
12271
+ const DEPOSIT_FOR_BURN_GAS_LIMIT_EVM = 300_000n // observed max 226_506 + ~30%
12272
+ ;
12273
+ const RECEIVE_MESSAGE_GAS_LIMIT_EVM = 400_000n // observed max 310_839 + ~30%
12274
+ ;
12151
12275
  /**
12152
12276
  * The minimum finality threshold for CCTPv2 transfers.
12153
12277
  *
@@ -12176,6 +12300,27 @@ const RECEIVE_MESSAGE_GAS_ESTIMATE_EVM = 237_401n // (99p: 163_963n + max: 310_8
12176
12300
  'Content-Type': 'application/json'
12177
12301
  }
12178
12302
  };
12303
+ /**
12304
+ * Merges caller-provided polling overrides on top of {@link DEFAULT_CONFIG}.
12305
+ *
12306
+ * Headers are merged independently so caller-supplied headers augment the
12307
+ * defaults (such as `Content-Type`) rather than replacing them wholesale.
12308
+ *
12309
+ * @param config - Caller-provided polling configuration overrides
12310
+ * @param internalDefaults - Internal defaults applied before `config` (for example a
12311
+ * reduced `maxRetries` for one-shot requests); `config` still wins on conflict
12312
+ * @returns The effective polling configuration
12313
+ * @internal
12314
+ */ const mergeAttestationConfig = (config, internalDefaults = {})=>({
12315
+ ...DEFAULT_CONFIG,
12316
+ ...internalDefaults,
12317
+ ...config,
12318
+ headers: {
12319
+ ...DEFAULT_CONFIG.headers,
12320
+ ...internalDefaults.headers,
12321
+ ...config.headers
12322
+ }
12323
+ });
12179
12324
  /**
12180
12325
  * Type guard that verifies if an unknown value matches the AttestationMessage shape
12181
12326
  * and has all required properties.
@@ -12322,10 +12467,7 @@ const RECEIVE_MESSAGE_GAS_ESTIMATE_EVM = 237_401n // (99p: 163_963n + max: 310_8
12322
12467
  * ```
12323
12468
  */ const fetchAttestation = async (sourceDomainId, transactionHash, isTestnet, config = {})=>{
12324
12469
  const url = buildIrisUrl(sourceDomainId, transactionHash, isTestnet);
12325
- const effectiveConfig = {
12326
- ...DEFAULT_CONFIG,
12327
- ...config
12328
- };
12470
+ const effectiveConfig = mergeAttestationConfig(config);
12329
12471
  return await pollApiGet(url, isAttestationResponse, effectiveConfig);
12330
12472
  };
12331
12473
  /**
@@ -12368,11 +12510,9 @@ const RECEIVE_MESSAGE_GAS_ESTIMATE_EVM = 237_401n // (99p: 163_963n + max: 310_8
12368
12510
  */ const fetchAttestationWithoutStatusCheck = async (sourceDomainId, transactionHash, isTestnet, config = {})=>{
12369
12511
  const url = buildIrisUrl(sourceDomainId, transactionHash, isTestnet);
12370
12512
  // Use minimal retries since we're just fetching existing data
12371
- const effectiveConfig = {
12372
- ...DEFAULT_CONFIG,
12373
- maxRetries: 3,
12374
- ...config
12375
- };
12513
+ const effectiveConfig = mergeAttestationConfig(config, {
12514
+ maxRetries: 3
12515
+ });
12376
12516
  return await pollApiGet(url, isAttestationResponseWithoutStatusCheck, effectiveConfig);
12377
12517
  };
12378
12518
  /**
@@ -12432,10 +12572,7 @@ const RECEIVE_MESSAGE_GAS_ESTIMATE_EVM = 237_401n // (99p: 163_963n + max: 310_8
12432
12572
  * ```
12433
12573
  */ const fetchReAttestedAttestation = async (sourceDomainId, transactionHash, isTestnet, config = {})=>{
12434
12574
  const url = buildIrisUrl(sourceDomainId, transactionHash, isTestnet);
12435
- const effectiveConfig = {
12436
- ...DEFAULT_CONFIG,
12437
- ...config
12438
- };
12575
+ const effectiveConfig = mergeAttestationConfig(config);
12439
12576
  return await pollApiGet(url, isReAttestedAttestationResponse, effectiveConfig);
12440
12577
  };
12441
12578
  /**
@@ -12501,14 +12638,139 @@ const RECEIVE_MESSAGE_GAS_ESTIMATE_EVM = 237_401n // (99p: 163_963n + max: 310_8
12501
12638
  */ const requestReAttestation = async (nonce, isTestnet, config = {})=>{
12502
12639
  const url = buildReAttestUrl(nonce, isTestnet);
12503
12640
  // Use minimal retries since we're just submitting a request, not polling for state
12504
- const effectiveConfig = {
12505
- ...DEFAULT_CONFIG,
12506
- maxRetries: 3,
12507
- ...config
12508
- };
12641
+ const effectiveConfig = mergeAttestationConfig(config, {
12642
+ maxRetries: 3
12643
+ });
12509
12644
  return await pollApiPost(url, {}, isReAttestationResponse, effectiveConfig);
12510
12645
  };
12511
12646
 
12647
+ /**
12648
+ * Type guard that checks if the relayer has confirmed the mint transaction.
12649
+ *
12650
+ * This function validates that:
12651
+ * 1. The response has valid AttestationResponse structure
12652
+ * 2. At least one message has forwardState === 'CONFIRMED' (or 'COMPLETE') and a valid forwardTxHash
12653
+ *
12654
+ * If forwardState is 'FAILED', throws a non-retryable KitError.
12655
+ * If forwardState is 'PENDING' or not present, throws a RETRYABLE KitError to continue polling.
12656
+ *
12657
+ * @param obj - The value to check, typically a parsed JSON response
12658
+ * @returns True if the relayer has confirmed the mint
12659
+ * @throws {KitError} With FATAL recoverability if structure is invalid
12660
+ * @throws {KitError} With RESUMABLE recoverability if forwardState is 'FAILED'
12661
+ * @throws {KitError} With RETRYABLE recoverability if still pending
12662
+ * @internal
12663
+ */ const isRelayerMintConfirmed = (obj)=>{
12664
+ // First check if the structure is valid
12665
+ if (!hasValidAttestationStructure(obj)) {
12666
+ throw new KitError({
12667
+ ...InputError.VALIDATION_FAILED,
12668
+ recoverability: 'FATAL',
12669
+ message: 'Invalid attestation response structure from IRIS API.'
12670
+ });
12671
+ }
12672
+ // Find the first message (typically there's only one)
12673
+ const message = obj.messages[0];
12674
+ if (!message) {
12675
+ throw new KitError({
12676
+ ...InputError.VALIDATION_FAILED,
12677
+ recoverability: 'FATAL',
12678
+ message: 'No attestation messages found in IRIS API response.'
12679
+ });
12680
+ }
12681
+ // Check for FAILED state - this is a permanent failure
12682
+ if (message.forwardState === 'FAILED') {
12683
+ throw new KitError({
12684
+ ...NetworkError.RELAYER_FORWARD_FAILED,
12685
+ recoverability: 'RESUMABLE',
12686
+ 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.',
12687
+ cause: {
12688
+ trace: {
12689
+ eventNonce: message.eventNonce,
12690
+ attestation: message.attestation,
12691
+ message: message.message
12692
+ }
12693
+ }
12694
+ });
12695
+ }
12696
+ // Check if mint is confirmed (or complete) with a valid transaction hash
12697
+ // We accept both CONFIRMED and COMPLETE since COMPLETE implies CONFIRMED
12698
+ if ((message.forwardState === 'CONFIRMED' || message.forwardState === 'COMPLETE') && typeof message.forwardTxHash === 'string' && message.forwardTxHash.trim().length > 0) {
12699
+ return true;
12700
+ }
12701
+ // Still pending or not yet processed - throw RETRYABLE error to continue polling
12702
+ throw new KitError({
12703
+ ...NetworkError.RELAYER_PENDING,
12704
+ recoverability: 'RETRYABLE',
12705
+ message: 'Relayer mint not ready. Waiting for confirmation.'
12706
+ });
12707
+ };
12708
+ /**
12709
+ * Polls the attestation API until the relayer's mint transaction is confirmed.
12710
+ *
12711
+ * This function is used when `useForwarder` is enabled. Instead of the user
12712
+ * submitting the mint transaction, Circle's Orbit relayer handles it automatically.
12713
+ * This function polls until the relayer has submitted and confirmed the mint transaction.
12714
+ *
12715
+ * @remarks
12716
+ * - Uses a 20-minute timeout by default (600 retries × 2 seconds)
12717
+ * - Throws immediately if `forwardState` is 'FAILED'
12718
+ * - Waits for `forwardState` to be 'CONFIRMED' or 'COMPLETE' (COMPLETE implies CONFIRMED)
12719
+ * - Returns the attestation message with `forwardTxHash` populated
12720
+ *
12721
+ * @param sourceDomainId - The CCTP domain ID of the source chain
12722
+ * @param transactionHash - The transaction hash of the burn operation
12723
+ * @param isTestnet - Whether this is for a testnet chain (true) or mainnet (false)
12724
+ * @param config - Optional configuration overrides for polling behavior
12725
+ * @returns The attestation message with confirmed forwardTxHash
12726
+ * @throws {KitError} With code 'NETWORK_RELAYER_FORWARD_FAILED' if relayer failed
12727
+ * @throws {KitError} If timeout is reached while still pending
12728
+ *
12729
+ * @example
12730
+ * ```typescript
12731
+ * const attestation = await fetchRelayerMint(0, '0xabc...', false)
12732
+ * console.log('Relayer mint tx:', attestation.forwardTxHash)
12733
+ * ```
12734
+ */ const fetchRelayerMint = async (sourceDomainId, transactionHash, isTestnet, config = {})=>{
12735
+ const url = buildIrisUrl(sourceDomainId, transactionHash, isTestnet);
12736
+ const effectiveConfig = mergeAttestationConfig(config);
12737
+ let response;
12738
+ try {
12739
+ response = await pollApiGet(url, isRelayerMintConfirmed, effectiveConfig);
12740
+ } catch (error) {
12741
+ // Enrich RELAYER_FORWARD_FAILED errors with the burn transaction hash
12742
+ if (error instanceof KitError && error.name === 'NETWORK_RELAYER_FORWARD_FAILED') {
12743
+ throw new KitError({
12744
+ ...NetworkError.RELAYER_FORWARD_FAILED,
12745
+ recoverability: error.recoverability,
12746
+ message: error.message,
12747
+ cause: {
12748
+ ...error.cause,
12749
+ trace: {
12750
+ ...error.cause?.trace,
12751
+ burnTxHash: transactionHash
12752
+ }
12753
+ }
12754
+ });
12755
+ }
12756
+ throw error;
12757
+ }
12758
+ // Return the first message (which should have forwardTxHash)
12759
+ // Note: This check is needed for TypeScript type safety even though
12760
+ // isRelayerMintConfirmed validates messages[0] exists. The type guard
12761
+ // narrows the type at the call site, but TypeScript can't infer that
12762
+ // the array still has elements after pollApiGet returns.
12763
+ const message = response.messages[0];
12764
+ if (!message) {
12765
+ throw new KitError({
12766
+ ...InputError.VALIDATION_FAILED,
12767
+ recoverability: 'FATAL',
12768
+ message: 'No attestation messages found in response after polling.'
12769
+ });
12770
+ }
12771
+ return message;
12772
+ };
12773
+
12512
12774
  const assertCCTPv2WalletContextSymbol = Symbol('assertCCTPv2WalletContext');
12513
12775
  /**
12514
12776
  * Asserts that the provided parameters match the CCTPv2 wallet context interface.
@@ -13383,6 +13645,8 @@ function hasPendingState(analysis, result) {
13383
13645
  * - `adapter`: The adapter that will execute the transaction
13384
13646
  * - `confirmations`: The number of confirmations to wait for (defaults to 1)
13385
13647
  * - `timeout`: The timeout for the request in milliseconds
13648
+ * - `gasLimit`: Optional explicit gas limit (number) forwarded to EVM execute,
13649
+ * bypassing `eth_estimateGas`; ignored for non-EVM requests
13386
13650
  * @returns The bridge step with the transaction details and explorer URL
13387
13651
  * @throws If the transaction execution fails
13388
13652
  *
@@ -13397,7 +13661,7 @@ function hasPendingState(analysis, result) {
13397
13661
  * })
13398
13662
  * console.log('Transaction hash:', step.txHash)
13399
13663
  * ```
13400
- */ async function executePreparedChainRequest({ name, request, adapter, chain, confirmations = 1, timeout }) {
13664
+ */ async function executePreparedChainRequest({ name, request, adapter, chain, confirmations = 1, timeout, gasLimit }) {
13401
13665
  const step = {
13402
13666
  name,
13403
13667
  state: 'pending'
@@ -13410,7 +13674,9 @@ function hasPendingState(analysis, result) {
13410
13674
  step.state = 'noop';
13411
13675
  return step;
13412
13676
  }
13413
- const txHash = await request.execute();
13677
+ const txHash = request.type === 'evm' && gasLimit !== undefined ? await request.execute({
13678
+ gasLimit
13679
+ }) : await request.execute();
13414
13680
  step.txHash = txHash;
13415
13681
  const retryOptions = {
13416
13682
  isRetryable: (err)=>isRetryableError$1(parseBlockchainError(err, {
@@ -13482,7 +13748,8 @@ function hasPendingState(analysis, result) {
13482
13748
  name: 'approve',
13483
13749
  adapter: params.source.adapter,
13484
13750
  chain: params.source.chain,
13485
- request: await provider.approve(params.source, approvalAmount)
13751
+ request: await provider.approve(params.source, approvalAmount),
13752
+ gasLimit: Number(APPROVE_GAS_LIMIT_EVM)
13486
13753
  });
13487
13754
  }
13488
13755
 
@@ -13509,7 +13776,8 @@ function hasPendingState(analysis, result) {
13509
13776
  name: 'burn',
13510
13777
  adapter: params.source.adapter,
13511
13778
  chain: params.source.chain,
13512
- request: await provider.burn(params)
13779
+ request: await provider.burn(params),
13780
+ gasLimit: Number(DEPOSIT_FOR_BURN_GAS_LIMIT_EVM)
13513
13781
  });
13514
13782
  }
13515
13783
 
@@ -13595,11 +13863,18 @@ function hasPendingState(analysis, result) {
13595
13863
  */ async function bridgeMint({ params, provider }, attestation) {
13596
13864
  // Validate attestation message matches transfer params
13597
13865
  await assertCCTPv2AttestationParams(attestation, params);
13866
+ const mintRequest = await provider.mint(params.source, params.destination, attestation);
13598
13867
  const step = await executePreparedChainRequest({
13599
13868
  name: 'mint',
13600
13869
  adapter: params.destination.adapter,
13601
13870
  chain: params.destination.chain,
13602
- request: await provider.mint(params.source, params.destination, attestation)
13871
+ request: mintRequest,
13872
+ // Some chains (e.g. Cronos) enforce an EIP-7623 calldata gas floor that
13873
+ // eth_estimateGas does not account for, returning a below-floor value
13874
+ // without reverting. Pinning to a value above the observed execution max
13875
+ // (310_839) bypasses re-estimation and guarantees we clear both the floor
13876
+ // and the actual execution cost.
13877
+ gasLimit: Number(RECEIVE_MESSAGE_GAS_LIMIT_EVM)
13603
13878
  });
13604
13879
  // Add forwarded: false for non-relayer mints
13605
13880
  return {
@@ -13637,136 +13912,6 @@ const mockAttestationMessage = {
13637
13912
  delayReason: null
13638
13913
  };
13639
13914
 
13640
- /**
13641
- * Type guard that checks if the relayer has confirmed the mint transaction.
13642
- *
13643
- * This function validates that:
13644
- * 1. The response has valid AttestationResponse structure
13645
- * 2. At least one message has forwardState === 'CONFIRMED' (or 'COMPLETE') and a valid forwardTxHash
13646
- *
13647
- * If forwardState is 'FAILED', throws a non-retryable KitError.
13648
- * If forwardState is 'PENDING' or not present, throws a RETRYABLE KitError to continue polling.
13649
- *
13650
- * @param obj - The value to check, typically a parsed JSON response
13651
- * @returns True if the relayer has confirmed the mint
13652
- * @throws {KitError} With FATAL recoverability if structure is invalid
13653
- * @throws {KitError} With RESUMABLE recoverability if forwardState is 'FAILED'
13654
- * @throws {KitError} With RETRYABLE recoverability if still pending
13655
- * @internal
13656
- */ const isRelayerMintConfirmed = (obj)=>{
13657
- // First check if the structure is valid
13658
- if (!hasValidAttestationStructure(obj)) {
13659
- throw new KitError({
13660
- ...InputError.VALIDATION_FAILED,
13661
- recoverability: 'FATAL',
13662
- message: 'Invalid attestation response structure from IRIS API.'
13663
- });
13664
- }
13665
- // Find the first message (typically there's only one)
13666
- const message = obj.messages[0];
13667
- if (!message) {
13668
- throw new KitError({
13669
- ...InputError.VALIDATION_FAILED,
13670
- recoverability: 'FATAL',
13671
- message: 'No attestation messages found in IRIS API response.'
13672
- });
13673
- }
13674
- // Check for FAILED state - this is a permanent failure
13675
- if (message.forwardState === 'FAILED') {
13676
- throw new KitError({
13677
- ...NetworkError.RELAYER_FORWARD_FAILED,
13678
- recoverability: 'RESUMABLE',
13679
- 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.',
13680
- cause: {
13681
- trace: {
13682
- eventNonce: message.eventNonce,
13683
- attestation: message.attestation,
13684
- message: message.message
13685
- }
13686
- }
13687
- });
13688
- }
13689
- // Check if mint is confirmed (or complete) with a valid transaction hash
13690
- // We accept both CONFIRMED and COMPLETE since COMPLETE implies CONFIRMED
13691
- if ((message.forwardState === 'CONFIRMED' || message.forwardState === 'COMPLETE') && typeof message.forwardTxHash === 'string' && message.forwardTxHash.trim().length > 0) {
13692
- return true;
13693
- }
13694
- // Still pending or not yet processed - throw RETRYABLE error to continue polling
13695
- throw new KitError({
13696
- ...NetworkError.RELAYER_PENDING,
13697
- recoverability: 'RETRYABLE',
13698
- message: 'Relayer mint not ready. Waiting for confirmation.'
13699
- });
13700
- };
13701
- /**
13702
- * Polls the attestation API until the relayer's mint transaction is confirmed.
13703
- *
13704
- * This function is used when `useForwarder` is enabled. Instead of the user
13705
- * submitting the mint transaction, Circle's Orbit relayer handles it automatically.
13706
- * This function polls until the relayer has submitted and confirmed the mint transaction.
13707
- *
13708
- * @remarks
13709
- * - Uses a 20-minute timeout by default (600 retries × 2 seconds)
13710
- * - Throws immediately if `forwardState` is 'FAILED'
13711
- * - Waits for `forwardState` to be 'CONFIRMED' or 'COMPLETE' (COMPLETE implies CONFIRMED)
13712
- * - Returns the attestation message with `forwardTxHash` populated
13713
- *
13714
- * @param sourceDomainId - The CCTP domain ID of the source chain
13715
- * @param transactionHash - The transaction hash of the burn operation
13716
- * @param isTestnet - Whether this is for a testnet chain (true) or mainnet (false)
13717
- * @param config - Optional configuration overrides for polling behavior
13718
- * @returns The attestation message with confirmed forwardTxHash
13719
- * @throws {KitError} With code 'NETWORK_RELAYER_FORWARD_FAILED' if relayer failed
13720
- * @throws {KitError} If timeout is reached while still pending
13721
- *
13722
- * @example
13723
- * ```typescript
13724
- * const attestation = await fetchRelayerMint(0, '0xabc...', false)
13725
- * console.log('Relayer mint tx:', attestation.forwardTxHash)
13726
- * ```
13727
- */ const fetchRelayerMint = async (sourceDomainId, transactionHash, isTestnet, config = {})=>{
13728
- const url = buildIrisUrl(sourceDomainId, transactionHash, isTestnet);
13729
- const effectiveConfig = {
13730
- ...DEFAULT_CONFIG,
13731
- ...config
13732
- };
13733
- let response;
13734
- try {
13735
- response = await pollApiGet(url, isRelayerMintConfirmed, effectiveConfig);
13736
- } catch (error) {
13737
- // Enrich RELAYER_FORWARD_FAILED errors with the burn transaction hash
13738
- if (error instanceof KitError && error.name === 'NETWORK_RELAYER_FORWARD_FAILED') {
13739
- throw new KitError({
13740
- ...NetworkError.RELAYER_FORWARD_FAILED,
13741
- recoverability: error.recoverability,
13742
- message: error.message,
13743
- cause: {
13744
- ...error.cause,
13745
- trace: {
13746
- ...error.cause?.trace,
13747
- burnTxHash: transactionHash
13748
- }
13749
- }
13750
- });
13751
- }
13752
- throw error;
13753
- }
13754
- // Return the first message (which should have forwardTxHash)
13755
- // Note: This check is needed for TypeScript type safety even though
13756
- // isRelayerMintConfirmed validates messages[0] exists. The type guard
13757
- // narrows the type at the call site, but TypeScript can't infer that
13758
- // the array still has elements after pollApiGet returns.
13759
- const message = response.messages[0];
13760
- if (!message) {
13761
- throw new KitError({
13762
- ...InputError.VALIDATION_FAILED,
13763
- recoverability: 'FATAL',
13764
- message: 'No attestation messages found in response after polling.'
13765
- });
13766
- }
13767
- return message;
13768
- };
13769
-
13770
13915
  /**
13771
13916
  * Executes the mint step for forwarding mode where Circle's relayer handles the mint.
13772
13917
  *
@@ -13780,6 +13925,7 @@ const mockAttestationMessage = {
13780
13925
  * immediately after the API confirms the mint.
13781
13926
  *
13782
13927
  * @param params - The bridge parameters containing source, destination, amount and config
13928
+ * @param provider - The CCTP v2 bridging provider
13783
13929
  * @param context - The step context containing burnTxHash from the burn step
13784
13930
  * @returns Promise resolving to the bridge step with transaction details
13785
13931
  * @throws {KitError} If burnTxHash is not available in context
@@ -13788,10 +13934,13 @@ const mockAttestationMessage = {
13788
13934
  *
13789
13935
  * @example
13790
13936
  * ```typescript
13791
- * const step = await bridgeRelayerMint(params, { burnTxHash: '0x...' })
13937
+ * const step = await bridgeRelayerMint(
13938
+ * { params, provider },
13939
+ * { burnTxHash: '0x...' }
13940
+ * )
13792
13941
  * console.log('Relayer mint tx:', step.txHash)
13793
13942
  * ```
13794
- */ async function bridgeRelayerMint(params, context) {
13943
+ */ async function bridgeRelayerMint({ params, provider }, context) {
13795
13944
  const step = {
13796
13945
  name: 'mint',
13797
13946
  state: 'pending',
@@ -13807,7 +13956,7 @@ const mockAttestationMessage = {
13807
13956
  }
13808
13957
  try {
13809
13958
  // Poll attestation API until relayer confirms the mint
13810
- const attestation = await fetchRelayerMint(params.source.chain.cctp.domain, context.burnTxHash, params.source.chain.isTestnet ?? false);
13959
+ const attestation = await provider.fetchRelayerMint(params.source, context.burnTxHash);
13811
13960
  // Extract the relayer's mint transaction hash
13812
13961
  const forwardTxHash = attestation.forwardTxHash;
13813
13962
  if (!forwardTxHash) {
@@ -13901,7 +14050,7 @@ const mockAttestationMessage = {
13901
14050
  name: 'mint',
13902
14051
  // bridgeRelayerMint validates context.burnTxHash internally with a KitError
13903
14052
  // bridgeMint requires attestationData which is validated here
13904
- executor: useForwarder ? async (params, _provider, context)=>{
14053
+ executor: useForwarder ? async (params, provider, context)=>{
13905
14054
  if (!context) {
13906
14055
  throw new KitError({
13907
14056
  ...InputError.VALIDATION_FAILED,
@@ -13909,7 +14058,10 @@ const mockAttestationMessage = {
13909
14058
  message: 'Step context is required for relayer mint'
13910
14059
  });
13911
14060
  }
13912
- return bridgeRelayerMint(params, context);
14061
+ return bridgeRelayerMint({
14062
+ params,
14063
+ provider
14064
+ }, context);
13913
14065
  } : async (params, provider, context)=>{
13914
14066
  if (!context?.attestationData) {
13915
14067
  throw new KitError({
@@ -14240,7 +14392,7 @@ const mockAttestationMessage = {
14240
14392
  return step;
14241
14393
  }
14242
14394
 
14243
- var version$2 = "1.8.4";
14395
+ var version$2 = "1.9.0";
14244
14396
  var pkg$2 = {
14245
14397
  version: version$2};
14246
14398
 
@@ -14946,6 +15098,39 @@ var pkg$2 = {
14946
15098
  }
14947
15099
  }
14948
15100
 
15101
+ function isPlainObject(value) {
15102
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
15103
+ return false;
15104
+ }
15105
+ const prototype = Object.getPrototypeOf(value);
15106
+ return prototype === Object.prototype || prototype === null;
15107
+ }
15108
+ function assertHeadersConfig(headers, field) {
15109
+ if (headers === undefined) {
15110
+ return;
15111
+ }
15112
+ if (!isPlainObject(headers)) {
15113
+ throw createValidationFailedError$1(field, headers, `${field} must be a plain object with string header values when provided`);
15114
+ }
15115
+ for (const [name, value] of Object.entries(headers)){
15116
+ if (typeof value !== 'string') {
15117
+ throw createValidationFailedError$1(`${field}.${name}`, value, 'header values must be strings');
15118
+ }
15119
+ }
15120
+ }
15121
+ function assertCCTPV2Config(config) {
15122
+ if (!isPlainObject(config)) {
15123
+ throw createValidationFailedError$1('config', config, 'config must be a plain object when provided');
15124
+ }
15125
+ assertHeadersConfig(config['headers'], 'config.headers');
15126
+ const attestation = config['attestation'];
15127
+ if (attestation !== undefined) {
15128
+ if (!isPlainObject(attestation)) {
15129
+ throw createValidationFailedError$1('config.attestation', attestation, 'config.attestation must be a plain object when provided');
15130
+ }
15131
+ assertHeadersConfig(attestation['headers'], 'config.attestation.headers');
15132
+ }
15133
+ }
14949
15134
  /**
14950
15135
  * All chains that are supported by the CCTP v2 provider.
14951
15136
  *
@@ -15014,9 +15199,38 @@ var pkg$2 = {
15014
15199
  * @param config - Optional configuration overrides for the provider
15015
15200
  */ constructor(config = {}){
15016
15201
  super();
15202
+ assertCCTPV2Config(config);
15017
15203
  this.config = config;
15018
15204
  }
15019
15205
  /**
15206
+ * Resolves the effective polling configuration for an attestation request.
15207
+ *
15208
+ * Precedence (lowest to highest): provider `config.attestation`, then the
15209
+ * per-call `config`. Headers merge independently across
15210
+ * `config.attestation.headers`, the provider-level `config.headers`, and any
15211
+ * per-call `config.headers`, so a more specific header augments rather than
15212
+ * replaces the broader ones. The `headers` key is omitted entirely when no
15213
+ * headers are configured, leaving the attestation fetchers' defaults intact.
15214
+ *
15215
+ * @param config - Optional per-call polling configuration overrides
15216
+ * @returns The merged polling configuration passed to the attestation fetchers
15217
+ */ resolveAttestationConfig(config) {
15218
+ const headers = {
15219
+ ...this.config?.attestation?.headers,
15220
+ ...this.config?.headers,
15221
+ ...config?.headers
15222
+ };
15223
+ // Polling fields follow normal precedence; headers are merged separately
15224
+ // below so narrower config layers augment rather than replace broader ones.
15225
+ return {
15226
+ ...this.config?.attestation,
15227
+ ...config,
15228
+ ...Object.keys(headers).length > 0 ? {
15229
+ headers
15230
+ } : {}
15231
+ };
15232
+ }
15233
+ /**
15020
15234
  * Execute a cross-chain USDC bridge operation using the CCTP v2 protocol.
15021
15235
  *
15022
15236
  * This method orchestrates the complete CCTP v2 bridge flow including validation,
@@ -15442,11 +15656,7 @@ var pkg$2 = {
15442
15656
  */ async fetchAttestation(source, transactionHash, config) {
15443
15657
  assertCCTPv2WalletContext(source);
15444
15658
  try {
15445
- // Merge configs: defaults <- global config <- per-call config
15446
- const effectiveConfig = {
15447
- ...this.config?.attestation,
15448
- ...config
15449
- };
15659
+ const effectiveConfig = this.resolveAttestationConfig(config);
15450
15660
  const response = await fetchAttestation(source.chain.cctp.domain, transactionHash, source.chain.isTestnet, effectiveConfig);
15451
15661
  const message = response.messages[0];
15452
15662
  if (!message) {
@@ -15463,6 +15673,49 @@ var pkg$2 = {
15463
15673
  }
15464
15674
  }
15465
15675
  /**
15676
+ * Polls attestation data until Circle's relayer mint transaction is confirmed.
15677
+ *
15678
+ * This method is used by forwarded transfers. It polls the same Iris
15679
+ * attestation endpoint as {@link CCTPV2BridgingProvider.fetchAttestation},
15680
+ * but waits for a completed relayer forward state and returns the attestation
15681
+ * message containing `forwardTxHash`.
15682
+ *
15683
+ * @typeParam TFromAdapterCapabilities - The type representing the capabilities of the source adapter
15684
+ * @param source - The source wallet context containing the chain definition and wallet address
15685
+ * @param transactionHash - The transaction hash of the burn operation
15686
+ * @param config - Optional polling configuration overrides for timeout, retries, delay, and headers
15687
+ * @returns A promise that resolves to the attestation message with `forwardTxHash`
15688
+ * @throws KitError If the relayer forward fails, the response is invalid, or polling times out
15689
+ *
15690
+ * @example
15691
+ * ```typescript
15692
+ * import { CCTPV2BridgingProvider } from '@circle-fin/provider-cctp-v2'
15693
+ * import { Chains } from '@core/chains'
15694
+ *
15695
+ * const provider = new CCTPV2BridgingProvider({
15696
+ * headers: { 'X-Partner-UUID': '00000000-0000-0000-0000-000000000000' },
15697
+ * })
15698
+ *
15699
+ * const attestation = await provider.fetchRelayerMint(
15700
+ * {
15701
+ * adapter,
15702
+ * chain: Chains.EthereumSepolia,
15703
+ * address: '0x1234...',
15704
+ * },
15705
+ * '0xabc123...',
15706
+ * )
15707
+ *
15708
+ * console.log('Relayer mint tx:', attestation.forwardTxHash)
15709
+ * ```
15710
+ */ async fetchRelayerMint(source, transactionHash, config) {
15711
+ assertCCTPv2WalletContext(source);
15712
+ if (typeof transactionHash !== 'string' || transactionHash.trim() === '') {
15713
+ throw createValidationFailedError$1('transactionHash', transactionHash, 'transactionHash must be a non-empty string');
15714
+ }
15715
+ const effectiveConfig = this.resolveAttestationConfig(config);
15716
+ return await fetchRelayerMint(source.chain.cctp.domain, transactionHash, source.chain.isTestnet, effectiveConfig);
15717
+ }
15718
+ /**
15466
15719
  * Requests a fresh attestation for an expired attestation.
15467
15720
  *
15468
15721
  * This method is used when the original attestation has expired before the mint
@@ -15516,11 +15769,7 @@ var pkg$2 = {
15516
15769
  throw new Error('Failed to re-attest: Invalid transaction hash');
15517
15770
  }
15518
15771
  try {
15519
- // Merge configs: defaults <- global config <- per-call config
15520
- const effectiveConfig = {
15521
- ...this.config?.attestation,
15522
- ...config
15523
- };
15772
+ const effectiveConfig = this.resolveAttestationConfig(config);
15524
15773
  // Step 1: Get existing attestation data to extract nonce
15525
15774
  const existingAttestation = await fetchAttestationWithoutStatusCheck(source.chain.cctp.domain, transactionHash, source.chain.isTestnet, effectiveConfig);
15526
15775
  const nonce = existingAttestation.messages[0]?.eventNonce;
@@ -15805,8 +16054,13 @@ var pkg$2 = {
15805
16054
  /**
15806
16055
  * The default providers that will be used in addition to the providers provided
15807
16056
  * to the BridgeKit constructor.
15808
- */ const getDefaultProviders = ()=>[
15809
- new CCTPV2BridgingProvider()
16057
+ *
16058
+ * @param config - Optional configuration forwarded to the default providers
16059
+ * @returns The default bridging providers
16060
+ */ const getDefaultProviders = (config = {})=>[
16061
+ new CCTPV2BridgingProvider(config.headers ? {
16062
+ headers: config.headers
16063
+ } : {})
15810
16064
  ];
15811
16065
 
15812
16066
  /**
@@ -16049,7 +16303,9 @@ var pkg$2 = {
16049
16303
  * ```
16050
16304
  */ constructor(config = {}){
16051
16305
  // Handle provider configuration
16052
- const defaultProviders = getDefaultProviders();
16306
+ const defaultProviders = getDefaultProviders(config.headers ? {
16307
+ headers: config.headers
16308
+ } : {});
16053
16309
  this.providers = [
16054
16310
  ...defaultProviders,
16055
16311
  ...config.providers ?? []
@@ -16629,6 +16885,9 @@ registerKit(`${pkg$3.name}/${pkg$3.version}`);
16629
16885
  const kit = new BridgeKit({
16630
16886
  ...context.disableErrorReporting != null && {
16631
16887
  disableErrorReporting: context.disableErrorReporting
16888
+ },
16889
+ ...context.headers != null && {
16890
+ headers: context.headers
16632
16891
  }
16633
16892
  });
16634
16893
  if (hasBoth) {
@@ -16647,7 +16906,7 @@ registerKit(`${pkg$3.name}/${pkg$3.version}`);
16647
16906
  };
16648
16907
 
16649
16908
  var name$1 = "@circle-fin/swap-kit";
16650
- var version$1 = "1.3.0";
16909
+ var version$1 = "1.3.2";
16651
16910
  var pkg$1 = {
16652
16911
  name: name$1,
16653
16912
  version: version$1};
@@ -18575,7 +18834,7 @@ new Set(Object.values(Blockchain));
18575
18834
  registerKit(`${pkg$1.name}/${pkg$1.version}`);
18576
18835
 
18577
18836
  var name = "@circle-fin/earn-kit";
18578
- var version = "1.2.0";
18837
+ var version = "1.2.2";
18579
18838
  var pkg = {
18580
18839
  name: name,
18581
18840
  version: version};
@@ -18614,20 +18873,7 @@ var pkg = {
18614
18873
  */ ({
18615
18874
  [Blockchain.Arc_Testnet]: CHAIN_TO_API[Blockchain.Arc_Testnet]
18616
18875
  });
18617
- /**
18618
- * Expected EIP-712 domain of the ERC-3009 authorization token per source
18619
- * chain.
18620
- *
18621
- * Cross-chain Earn deposits are USDC-only, but USDC deployments differ on the
18622
- * EIP-712 domain name: newer deployments use `USDC` while older ones (for
18623
- * example Arbitrum Sepolia) kept `USD Coin` from the FiatToken V2 upgrade.
18624
- * These values mirror the bridge service's per-chain domain table and the
18625
- * on-chain `DOMAIN_SEPARATOR` inputs. Asserted before signing so a tampered
18626
- * prepare response cannot point the signature at another token. The
18627
- * `satisfies` check forces a domain entry whenever a source chain is added.
18628
- *
18629
- * @internal
18630
- */ ({
18876
+ ({
18631
18877
  [Blockchain.Arbitrum_Sepolia]: {
18632
18878
  },
18633
18879
  [Blockchain.Base_Sepolia]: {
@@ -18663,6 +18909,7 @@ const hexSignatureSchema = evmSignatureSchema;
18663
18909
  const hexAddressSchema = evmAddressSchema;
18664
18910
  // '0x' prefix + 32 bytes * 2 hex chars.
18665
18911
  const BYTES32_HEX_LENGTH = 66;
18912
+ const bridgeFeeTokenSchema = hexAddressSchema;
18666
18913
  /**
18667
18914
  * Zod schema for a non-negative uint256-like value.
18668
18915
  *
@@ -18949,14 +19196,12 @@ const eip712DomainSchema = eip712DomainSchema$1.extend({
18949
19196
  *
18950
19197
  * The bridge prepare path returns one item per collected source fee (e.g.
18951
19198
  * `PRE_FINALITY` for the fast-burn fee and `FORWARD` for the destination
18952
- * forward fee), all denominated in the shared `feeToken`. The signed
18953
- * authorization `value` is `principal + sum(items[].amount)`, so the pre-sign
18954
- * guard parses these to recompute the expected value. Each item's `amount` is
18955
- * a base-unit decimal string in `feeToken` units.
19199
+ * forward fee), all denominated in the shared `feeToken`. Each item's `amount`
19200
+ * is a base-unit decimal string in `feeToken` units.
18956
19201
  *
18957
19202
  * @internal
18958
19203
  */ const bridgeFeeQuoteSchema = z.object({
18959
- feeToken: hexAddressSchema,
19204
+ feeToken: bridgeFeeTokenSchema,
18960
19205
  items: z.array(z.object({
18961
19206
  type: z.string(),
18962
19207
  amount: uint256LikeSchema
@@ -18972,6 +19217,12 @@ const eip712DomainSchema = eip712DomainSchema$1.extend({
18972
19217
  erc3009TypedData: erc3009TypedDataSchema,
18973
19218
  feeQuote: bridgeFeeQuoteSchema
18974
19219
  }).passthrough();
19220
+ const bridgeDepositPrepareReviewSchema = z.object({
19221
+ sourceChain: z.string(),
19222
+ destinationChain: z.string(),
19223
+ amount: amountJsonSchema,
19224
+ vaultAddress: hexAddressSchema
19225
+ }).passthrough();
18975
19226
  /**
18976
19227
  * Zod schema for the bridge deposit prepare payload.
18977
19228
  *
@@ -18983,7 +19234,7 @@ const eip712DomainSchema = eip712DomainSchema$1.extend({
18983
19234
  execId: bridgeDepositExecIdSchema,
18984
19235
  erc3009TypedData: bridgeDepositPreparedBundleSchema,
18985
19236
  expiresAt: z.string().datetime(),
18986
- review: z.unknown().optional()
19237
+ review: bridgeDepositPrepareReviewSchema
18987
19238
  });
18988
19239
  /**
18989
19240
  * Zod schema for the `POST /v1/earnKit/bridge/deposit/prepare` API response.
@@ -19108,10 +19359,11 @@ const eip712DomainSchema = eip712DomainSchema$1.extend({
19108
19359
  * Zod schema for a fee entry in an EarnKit API response.
19109
19360
  *
19110
19361
  * Shared across deposit and withdrawal responses (and reusable for real
19111
- * charged fees, not just quote estimates). `type` identifies the fee category
19112
- * for cross-chain deposit quotes this is the kits-proxy fee-quote item type
19113
- * (e.g. `'FORWARD'`, `'PRE_FINALITY'`). `status` qualifies the fee (e.g.
19114
- * `'estimated'` for a pre-sign cross-chain fee). Both are omitted on plain fees.
19362
+ * charged fees, not just quote estimates). `type` identifies the fee category.
19363
+ * For cross-chain deposit quotes this is the kits-proxy fee-quote item type
19364
+ * (e.g. `'FORWARD'`, `'PRE_FINALITY'`). For withdrawal quotes, Circle fees use
19365
+ * `type: 'circle'`. `status` qualifies the fee (e.g. `'estimated'` for a
19366
+ * pre-sign cross-chain fee). Both are omitted on plain fees.
19115
19367
  *
19116
19368
  * @internal
19117
19369
  */ const feeSchema = z.object({
@@ -19262,6 +19514,10 @@ const eip712DomainSchema = eip712DomainSchema$1.extend({
19262
19514
  data: exploreVaultsPayloadSchema
19263
19515
  });
19264
19516
 
19517
+ // Intentionally built-ins-only: Earn bridge support is limited to SDK-known
19518
+ // token contracts plus the explicit ERC-3009 domain allowlist below.
19519
+ createTokenRegistry();
19520
+
19265
19521
  /**
19266
19522
  * Shared UTF-8 encoder for building the keccak input in
19267
19523
  * {@link isValidEip55Checksum}, hoisted to module scope to avoid allocating a
@@ -19384,10 +19640,9 @@ const sourceAdapterContextSchema = z.object({
19384
19640
  * Schema for validating human-readable decimal amount strings.
19385
19641
  *
19386
19642
  * Accept positive decimal strings like '100', '100.50', '0.001'. Reject
19387
- * zero, negative, non-numeric, and non-canonical strings. EarnKit
19388
- * same-chain amounts are USDC/EURC (6 decimals), so precision is capped at
19389
- * 6 to match the Earn Service and fail fast locally instead of leaking
19390
- * 7+ decimal-place inputs to the server.
19643
+ * zero, negative, non-numeric, and non-canonical strings. Same-chain
19644
+ * EarnKit vaults can use different asset precisions, so the service enforces
19645
+ * the vault-specific decimal cap after resolving the vault asset.
19391
19646
  *
19392
19647
  * @internal
19393
19648
  */ const amountSchema = z.string({
@@ -19396,32 +19651,15 @@ const sourceAdapterContextSchema = z.object({
19396
19651
  allowZero: false,
19397
19652
  regexMessage: AMOUNT_FORMAT_ERROR_MESSAGE,
19398
19653
  attributeName: 'amount',
19399
- maxDecimals: 6
19400
- })(z.string())).refine((value)=>CANONICAL_AMOUNT_REGEX.test(value), AMOUNT_FORMAT_ERROR_MESSAGE);
19401
- /**
19402
- * Schema for cross-chain deposit amount strings.
19403
- *
19404
- * Cross-chain Earn deposits are USDC-only, and the signed ERC-3009 value is
19405
- * denominated in USDC's 6 decimals. Reject more precise inputs up front so
19406
- * the signed value always equals the requested amount instead of a silent
19407
- * truncation. Non-canonical forms (leading dot, leading zeros) are rejected
19408
- * too, matching the Earn Service.
19409
- *
19410
- * @internal
19411
- */ const crossChainAmountSchema = z.string({
19412
- required_error: 'amount is required'
19413
- }).min(1, 'amount is required').pipe(createDecimalStringValidator({
19414
- allowZero: false,
19415
- regexMessage: AMOUNT_FORMAT_ERROR_MESSAGE,
19416
- attributeName: 'amount',
19417
- maxDecimals: 6
19654
+ maxDecimals: 18
19418
19655
  })(z.string())).refine((value)=>CANONICAL_AMOUNT_REGEX.test(value), AMOUNT_FORMAT_ERROR_MESSAGE);
19419
19656
  /**
19420
19657
  * Schema for cross-chain source fee caps.
19421
19658
  *
19422
- * Cross-chain source fees are denominated in USDC base units. Zero is valid
19423
- * when the quote contains no source-collected fees; otherwise the cap should be
19424
- * the caller-accepted total from a recent quote.
19659
+ * Cross-chain source fees are denominated in the quote's fee token. Zero is
19660
+ * valid when the quote contains no source-collected fees; otherwise the cap
19661
+ * should be the caller-accepted total from a recent quote. The provider
19662
+ * enforces the prepared bundle's fee-token precision before signing.
19425
19663
  *
19426
19664
  * @internal
19427
19665
  */ const crossChainMaxFeeSchema = z.string({
@@ -19430,7 +19668,7 @@ const sourceAdapterContextSchema = z.object({
19430
19668
  allowZero: true,
19431
19669
  regexMessage: AMOUNT_FORMAT_ERROR_MESSAGE,
19432
19670
  attributeName: 'maxFee',
19433
- maxDecimals: 6
19671
+ maxDecimals: 18
19434
19672
  })(z.string())).refine((value)=>CANONICAL_AMOUNT_REGEX.test(value), AMOUNT_FORMAT_ERROR_MESSAGE);
19435
19673
  /**
19436
19674
  * Build a schema for an optional non-negative decimal filter string.
@@ -19591,7 +19829,7 @@ const crossChainDepositDestinationSchema = z.object({
19591
19829
  from: sourceAdapterContextSchema,
19592
19830
  to: crossChainDepositDestinationSchema,
19593
19831
  vaultAddress: vaultAddressSchema,
19594
- amount: crossChainAmountSchema,
19832
+ amount: amountSchema,
19595
19833
  maxFee: crossChainMaxFeeSchema,
19596
19834
  transferSpeed: z.enum([
19597
19835
  'FAST',