@circle-fin/bridge-kit 1.0.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
package/index.d.ts CHANGED
@@ -19,7 +19,7 @@
19
19
  import { Abi } from 'abitype';
20
20
  import { TransactionInstruction, Signer } from '@solana/web3.js';
21
21
  import { CCTPV2BridgingProvider } from '@circle-fin/provider-cctp-v2';
22
- import { z } from '/home/runner/_work/stablecoin-kits-private/stablecoin-kits-private/node_modules/zod/dist/types/index.d.ts';
22
+ import { z } from '/home/runner/_work/stablecoin-kits-private/stablecoin-kits-private/kits/bridge-kit/node_modules/zod/dist/types/index.d.ts';
23
23
 
24
24
  /**
25
25
  * @packageDocumentation
@@ -410,6 +410,7 @@ declare enum Blockchain {
410
410
  Algorand_Testnet = "Algorand_Testnet",
411
411
  Aptos = "Aptos",
412
412
  Aptos_Testnet = "Aptos_Testnet",
413
+ Arc_Testnet = "Arc_Testnet",
413
414
  Arbitrum = "Arbitrum",
414
415
  Arbitrum_Sepolia = "Arbitrum_Sepolia",
415
416
  Avalanche = "Avalanche",
@@ -595,10 +596,11 @@ interface EvmPreparedChainRequest {
595
596
  * Estimate the gas cost for the contract execution.
596
597
  *
597
598
  * @param overrides - Optional parameters to override the default estimation behavior
599
+ * @param fallback - Optional fallback gas information to use if the estimation fails
598
600
  * @returns A promise that resolves to the estimated gas information
599
601
  * @throws If the estimation fails
600
602
  */
601
- estimate(overrides?: EvmEstimateOverrides): Promise<EstimatedGas>;
603
+ estimate(overrides?: EvmEstimateOverrides, fallback?: EstimatedGas): Promise<EstimatedGas>;
602
604
  /**
603
605
  * Execute the prepared contract call.
604
606
  *
@@ -676,7 +678,7 @@ interface SolanaPreparedChainRequest {
676
678
  /** The type of the chain request. */
677
679
  type: 'solana';
678
680
  /** Estimate the compute units and fee for the transaction. */
679
- estimate(overrides?: SolanaEstimateOverrides): Promise<EstimatedGas>;
681
+ estimate(overrides?: SolanaEstimateOverrides, fallback?: EstimatedGas): Promise<EstimatedGas>;
680
682
  /** Execute the prepared transaction. */
681
683
  execute(overrides?: SolanaExecuteOverrides): Promise<string>;
682
684
  }
@@ -708,7 +710,7 @@ interface NoopPreparedChainRequest {
708
710
  * Placeholder for the estimate method.
709
711
  * @returns The estimated gas cost.
710
712
  */
711
- estimate: () => Promise<EstimatedGas>;
713
+ estimate: (overrides?: EvmEstimateOverrides | SolanaEstimateOverrides, fallback?: EstimatedGas) => Promise<EstimatedGas>;
712
714
  /**
713
715
  * Placeholder for the execute method.
714
716
  * @returns The transaction hash.
@@ -1966,10 +1968,23 @@ interface AdapterCapabilities {
1966
1968
  */
1967
1969
  declare abstract class Adapter<TAdapterCapabilities extends AdapterCapabilities = AdapterCapabilities> {
1968
1970
  /**
1969
- * The type of the chain.
1970
- * @example 'evm', 'solana'
1971
+ * The type of the chain for this adapter.
1972
+ *
1973
+ * - For concrete adapters, this should be a real chain type (e.g., `'evm'`, `'solana'`, etc.) from the ChainType union.
1974
+ * - For hybrid adapters (adapters that route to concrete adapters supporting multiple ecosystems),
1975
+ * set this property to the string literal `'hybrid'`.
1976
+ *
1977
+ * Note: `'hybrid'` is not a legal ChainType and should only be used as a marker for multi-ecosystem adapters.
1978
+ * Hybrid adapters do not interact directly with any chain, but instead route requests to a concrete underlying adapter.
1979
+ *
1980
+ * @example
1981
+ * // For an EVM-only adapter:
1982
+ * chainType = 'evm'
1983
+ *
1984
+ * // For a hybrid adapter:
1985
+ * chainType = 'hybrid'
1971
1986
  */
1972
- abstract chainType: ChainType;
1987
+ abstract chainType: ChainType | 'hybrid';
1973
1988
  /**
1974
1989
  * Capabilities of this adapter, defining address control model and supported chains.
1975
1990
  *
@@ -2051,7 +2066,7 @@ declare abstract class Adapter<TAdapterCapabilities extends AdapterCapabilities
2051
2066
  * })
2052
2067
  * ```
2053
2068
  */
2054
- prepareAction<TActionKey extends ActionKeys>(action: TActionKey, params: ActionPayload<TActionKey>, ctx?: OperationContext<TAdapterCapabilities>): Promise<PreparedChainRequest>;
2069
+ prepareAction<TActionKey extends ActionKeys>(action: TActionKey, params: ActionPayload<TActionKey>, ctx: OperationContext<TAdapterCapabilities>): Promise<PreparedChainRequest>;
2055
2070
  /**
2056
2071
  * Prepares a transaction for future gas estimation and execution.
2057
2072
  *
@@ -2349,6 +2364,24 @@ declare class Actionable<AllActions> {
2349
2364
  dispatch<K extends keyof AllActions>(action: K, payload: AllActions[K]): void;
2350
2365
  }
2351
2366
 
2367
+ /**
2368
+ * Set an application-level identifier prefix for all HTTP requests.
2369
+ *
2370
+ * This allows applications to identify themselves in the user agent string,
2371
+ * which is useful for tracking and analytics at the application level.
2372
+ *
2373
+ * @param prefix - Application identifier with version, e.g., "my-app/1.0.0"
2374
+ *
2375
+ * @example
2376
+ * ```typescript
2377
+ * import { setExternalPrefix } from '\@circle-fin/bridge-kit'
2378
+ *
2379
+ * setExternalPrefix('my-dapp/2.1.0')
2380
+ * // All subsequent HTTP requests will include this prefix
2381
+ * ```
2382
+ */
2383
+ declare const setExternalPrefix: (prefix: string) => void;
2384
+
2352
2385
  /**
2353
2386
  * Transfer speed options for cross-chain operations.
2354
2387
  *
@@ -2415,6 +2448,49 @@ TChainDefinition extends ChainDefinition = ChainDefinition> {
2415
2448
  */
2416
2449
  chain: TChainDefinition;
2417
2450
  }
2451
+ /**
2452
+ * Wallet context for bridge destinations with optional custom recipient.
2453
+ *
2454
+ * Extends WalletContext to support scenarios where the recipient address
2455
+ * differs from the signer address (e.g., bridging to a third-party wallet).
2456
+ * The signer address is used for transaction authorization, while the
2457
+ * recipient address specifies where the minted funds should be sent.
2458
+ *
2459
+ * @typeParam TAdapterCapabilities - The adapter capabilities type to use for the wallet context.
2460
+ * @typeParam TChainDefinition - The chain definition type to use for the wallet context.
2461
+ *
2462
+ * @example
2463
+ * ```typescript
2464
+ * import type { DestinationWalletContext } from '@core/provider'
2465
+ * import { adapter, blockchain } from './setup'
2466
+ *
2467
+ * // Bridge to a custom recipient address
2468
+ * const destination: DestinationWalletContext = {
2469
+ * adapter,
2470
+ * address: '0x1234...abcd', // Signer address
2471
+ * chain: blockchain,
2472
+ * recipientAddress: '0x9876...fedc' // Custom recipient
2473
+ * }
2474
+ * ```
2475
+ */
2476
+ interface DestinationWalletContext<TAdapterCapabilities extends AdapterCapabilities = AdapterCapabilities,
2477
+ /**
2478
+ * The chain definition type to use for the wallet context.
2479
+ *
2480
+ * @defaultValue ChainDefinition
2481
+ */
2482
+ TChainDefinition extends ChainDefinition = ChainDefinition> extends WalletContext<TAdapterCapabilities, TChainDefinition> {
2483
+ /**
2484
+ * Optional custom recipient address for minted funds.
2485
+ *
2486
+ * When provided, minted tokens will be sent to this address instead of
2487
+ * the address specified in the wallet context. The wallet context address
2488
+ * is still used for transaction signing and authorization.
2489
+ *
2490
+ * Must be a valid address format for the specified blockchain.
2491
+ */
2492
+ recipientAddress?: string;
2493
+ }
2418
2494
  /**
2419
2495
  * Parameters for executing a cross-chain bridge operation.
2420
2496
  */
@@ -2428,7 +2504,7 @@ TChainDefinition extends ChainDefinition = ChainDefinition> {
2428
2504
  /** The source adapter containing wallet and chain information */
2429
2505
  source: WalletContext<TFromCapabilities, TChainDefinition>;
2430
2506
  /** The destination adapter containing wallet and chain information */
2431
- destination: WalletContext<TToCapabilities, TChainDefinition>;
2507
+ destination: DestinationWalletContext<TToCapabilities, TChainDefinition>;
2432
2508
  /** The amount to transfer (as a string to avoid precision issues) */
2433
2509
  amount: string;
2434
2510
  /** The token to transfer (currently only USDC is supported) */
@@ -2572,7 +2648,26 @@ interface BridgeConfig {
2572
2648
  /**
2573
2649
  * The maximum fee to pay for the burn operation.
2574
2650
  *
2575
- * @defaultValue 0
2651
+ * Provide the amount as a base-10 numeric string representing the
2652
+ * token amount in human-readable format. For example: to set a maximum
2653
+ * fee of 1 USDC, pass `"1"`. Decimal values are supported (e.g., `"0.5"`
2654
+ * for half a USDC).
2655
+ *
2656
+ * @defaultValue `"0"`
2657
+ *
2658
+ * @example
2659
+ * ```typescript
2660
+ * import type { BridgeConfig, TransferSpeed } from '@core/provider'
2661
+ *
2662
+ * const config: BridgeConfig = {
2663
+ * transferSpeed: TransferSpeed.FAST,
2664
+ * maxFee: "1", // 1 USDC maximum fee
2665
+ * customFee: {
2666
+ * value: "0.5", // 0.5 USDC developer fee
2667
+ * recipientAddress: "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb0"
2668
+ * }
2669
+ * }
2670
+ * ```
2576
2671
  */
2577
2672
  maxFee?: string;
2578
2673
  /**
@@ -2583,8 +2678,8 @@ interface BridgeConfig {
2583
2678
  /**
2584
2679
  * Custom fee configuration charged by the integrator.
2585
2680
  *
2586
- * Use to charge an absolute fee on the source chain, in the token's
2587
- * smallest unit.
2681
+ * Use to charge an absolute fee on the source chain in human-readable
2682
+ * token amounts.
2588
2683
  *
2589
2684
  * @remarks
2590
2685
  * This is an absolute amount, not a percentage. The `recipientAddress` must be
@@ -2595,7 +2690,7 @@ interface BridgeConfig {
2595
2690
  * import type { CustomFee } from '@core/provider'
2596
2691
  *
2597
2692
  * const config: CustomFee = {
2598
- * value: '1000000', // 1 USDC in base units (6 decimals)
2693
+ * value: '1', // 1 USDC
2599
2694
  * recipientAddress: '0x1234567890123456789012345678901234567890',
2600
2695
  * }
2601
2696
  * ```
@@ -2603,20 +2698,25 @@ interface BridgeConfig {
2603
2698
  interface CustomFee {
2604
2699
  /**
2605
2700
  * The absolute fee to charge for the transfer.
2606
- * Provide the amount as a base-10 numeric string representing the integer amount of the token (not in smallest units).
2607
- * For example: to charge 1 USDC or 1 USDC, pass `'1'`.
2701
+ *
2702
+ * Provide the amount as a base-10 numeric string representing the token
2703
+ * amount in human-readable format. For example: to charge 1 USDC, pass
2704
+ * `"1"`. Decimal values are supported (e.g., `"0.5"` for half a USDC).
2608
2705
  * This is not a percentage.
2609
2706
  *
2610
- * Note: passing `'0'` results in no fee being charged.
2707
+ * Note: passing `"0"` results in no fee being charged.
2611
2708
  */
2612
2709
  value?: string | undefined;
2613
2710
  /**
2614
2711
  * The fee recipient for the bridge transfer.
2615
- * This is the address that will receive the fee on the source chain of the bridge transfer.
2616
- * The fee recipient address **must be a valid address for the source chain** of the bridge transfer.
2712
+ *
2713
+ * This is the address that will receive the fee on the source chain of the
2714
+ * bridge transfer. The fee recipient address **must be a valid address for
2715
+ * the source chain** of the bridge transfer.
2617
2716
  *
2618
2717
  * For example: if bridging from Ethereum to Solana, pass an EVM address like
2619
- * `'0x1234567890123456789012345678901234567890'` because the source chain is Ethereum.
2718
+ * `"0x1234567890123456789012345678901234567890"` because the source chain
2719
+ * is Ethereum.
2620
2720
  */
2621
2721
  recipientAddress?: string | undefined;
2622
2722
  }
@@ -3732,13 +3832,15 @@ declare const bridgeParamsWithChainIdentifierSchema: z.ZodObject<{
3732
3832
  getAddress: (...args: unknown[]) => unknown;
3733
3833
  }>;
3734
3834
  chain: never;
3735
- }, "strip", z.ZodTypeAny, {
3835
+ address: z.ZodOptional<z.ZodString>;
3836
+ }, "strict", z.ZodTypeAny, {
3736
3837
  adapter: {
3737
3838
  prepare: (...args: unknown[]) => unknown;
3738
3839
  waitForTransaction: (...args: unknown[]) => unknown;
3739
3840
  getAddress: (...args: unknown[]) => unknown;
3740
3841
  };
3741
3842
  chain: never;
3843
+ address?: string | undefined;
3742
3844
  }, {
3743
3845
  adapter: {
3744
3846
  prepare: (...args: unknown[]) => unknown;
@@ -3746,6 +3848,7 @@ declare const bridgeParamsWithChainIdentifierSchema: z.ZodObject<{
3746
3848
  getAddress: (...args: unknown[]) => unknown;
3747
3849
  };
3748
3850
  chain: never;
3851
+ address?: string | undefined;
3749
3852
  }>;
3750
3853
  to: z.ZodUnion<[z.ZodEffects<z.ZodObject<{
3751
3854
  adapter: z.ZodObject<{
@@ -3762,6 +3865,7 @@ declare const bridgeParamsWithChainIdentifierSchema: z.ZodObject<{
3762
3865
  getAddress: (...args: unknown[]) => unknown;
3763
3866
  }>;
3764
3867
  chain: never;
3868
+ address: z.ZodOptional<z.ZodString>;
3765
3869
  } & {
3766
3870
  recipientAddress: z.ZodString;
3767
3871
  }, "strip", z.ZodTypeAny, {
@@ -3772,6 +3876,7 @@ declare const bridgeParamsWithChainIdentifierSchema: z.ZodObject<{
3772
3876
  };
3773
3877
  chain: never;
3774
3878
  recipientAddress: string;
3879
+ address?: string | undefined;
3775
3880
  }, {
3776
3881
  adapter: {
3777
3882
  prepare: (...args: unknown[]) => unknown;
@@ -3780,6 +3885,7 @@ declare const bridgeParamsWithChainIdentifierSchema: z.ZodObject<{
3780
3885
  };
3781
3886
  chain: never;
3782
3887
  recipientAddress: string;
3888
+ address?: string | undefined;
3783
3889
  }>, {
3784
3890
  adapter: {
3785
3891
  prepare: (...args: unknown[]) => unknown;
@@ -3788,6 +3894,7 @@ declare const bridgeParamsWithChainIdentifierSchema: z.ZodObject<{
3788
3894
  };
3789
3895
  chain: never;
3790
3896
  recipientAddress: string;
3897
+ address?: string | undefined;
3791
3898
  }, {
3792
3899
  adapter: {
3793
3900
  prepare: (...args: unknown[]) => unknown;
@@ -3796,6 +3903,7 @@ declare const bridgeParamsWithChainIdentifierSchema: z.ZodObject<{
3796
3903
  };
3797
3904
  chain: never;
3798
3905
  recipientAddress: string;
3906
+ address?: string | undefined;
3799
3907
  }>, z.ZodObject<{
3800
3908
  adapter: z.ZodObject<{
3801
3909
  prepare: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>;
@@ -3811,6 +3919,7 @@ declare const bridgeParamsWithChainIdentifierSchema: z.ZodObject<{
3811
3919
  getAddress: (...args: unknown[]) => unknown;
3812
3920
  }>;
3813
3921
  chain: never;
3922
+ address: z.ZodOptional<z.ZodString>;
3814
3923
  }, "strict", z.ZodTypeAny, {
3815
3924
  adapter: {
3816
3925
  prepare: (...args: unknown[]) => unknown;
@@ -3818,6 +3927,7 @@ declare const bridgeParamsWithChainIdentifierSchema: z.ZodObject<{
3818
3927
  getAddress: (...args: unknown[]) => unknown;
3819
3928
  };
3820
3929
  chain: never;
3930
+ address?: string | undefined;
3821
3931
  }, {
3822
3932
  adapter: {
3823
3933
  prepare: (...args: unknown[]) => unknown;
@@ -3825,12 +3935,13 @@ declare const bridgeParamsWithChainIdentifierSchema: z.ZodObject<{
3825
3935
  getAddress: (...args: unknown[]) => unknown;
3826
3936
  };
3827
3937
  chain: never;
3938
+ address?: string | undefined;
3828
3939
  }>]>;
3829
3940
  amount: z.ZodPipeline<z.ZodString, z.ZodType<string, z.ZodTypeDef, string>>;
3830
3941
  token: z.ZodOptional<z.ZodLiteral<"USDC">>;
3831
3942
  config: z.ZodOptional<z.ZodObject<{
3832
3943
  transferSpeed: z.ZodOptional<z.ZodNativeEnum<typeof TransferSpeed>>;
3833
- maxFee: z.ZodOptional<z.ZodString>;
3944
+ maxFee: z.ZodOptional<z.ZodPipeline<z.ZodString, z.ZodType<string, z.ZodTypeDef, string>>>;
3834
3945
  customFee: z.ZodOptional<z.ZodObject<{
3835
3946
  value: z.ZodOptional<z.ZodType<string, z.ZodTypeDef, string>>;
3836
3947
  recipientAddress: z.ZodOptional<z.ZodString>;
@@ -3864,6 +3975,7 @@ declare const bridgeParamsWithChainIdentifierSchema: z.ZodObject<{
3864
3975
  getAddress: (...args: unknown[]) => unknown;
3865
3976
  };
3866
3977
  chain: never;
3978
+ address?: string | undefined;
3867
3979
  };
3868
3980
  to: {
3869
3981
  adapter: {
@@ -3872,6 +3984,7 @@ declare const bridgeParamsWithChainIdentifierSchema: z.ZodObject<{
3872
3984
  getAddress: (...args: unknown[]) => unknown;
3873
3985
  };
3874
3986
  chain: never;
3987
+ address?: string | undefined;
3875
3988
  } | {
3876
3989
  adapter: {
3877
3990
  prepare: (...args: unknown[]) => unknown;
@@ -3880,6 +3993,7 @@ declare const bridgeParamsWithChainIdentifierSchema: z.ZodObject<{
3880
3993
  };
3881
3994
  chain: never;
3882
3995
  recipientAddress: string;
3996
+ address?: string | undefined;
3883
3997
  };
3884
3998
  amount: string;
3885
3999
  token?: "USDC" | undefined;
@@ -3899,6 +4013,7 @@ declare const bridgeParamsWithChainIdentifierSchema: z.ZodObject<{
3899
4013
  getAddress: (...args: unknown[]) => unknown;
3900
4014
  };
3901
4015
  chain: never;
4016
+ address?: string | undefined;
3902
4017
  };
3903
4018
  to: {
3904
4019
  adapter: {
@@ -3907,6 +4022,7 @@ declare const bridgeParamsWithChainIdentifierSchema: z.ZodObject<{
3907
4022
  getAddress: (...args: unknown[]) => unknown;
3908
4023
  };
3909
4024
  chain: never;
4025
+ address?: string | undefined;
3910
4026
  } | {
3911
4027
  adapter: {
3912
4028
  prepare: (...args: unknown[]) => unknown;
@@ -3915,6 +4031,7 @@ declare const bridgeParamsWithChainIdentifierSchema: z.ZodObject<{
3915
4031
  };
3916
4032
  chain: never;
3917
4033
  recipientAddress: string;
4034
+ address?: string | undefined;
3918
4035
  };
3919
4036
  amount: string;
3920
4037
  token?: "USDC" | undefined;
@@ -4044,5 +4161,164 @@ declare class KitError extends Error implements ErrorDetails {
4044
4161
  constructor(details: ErrorDetails);
4045
4162
  }
4046
4163
 
4047
- export { Blockchain, BridgeKit, KitError, bridgeParamsWithChainIdentifierSchema };
4048
- export type { ActionHandler, BridgeKitConfig, BridgeParams, BridgeResult, ChainDefinition, ChainIdentifier, ErrorDetails, Recoverability };
4164
+ /**
4165
+ * Type guard to check if an error is a KitError instance.
4166
+ *
4167
+ * This guard enables TypeScript to narrow the type from `unknown` to
4168
+ * `KitError`, providing access to structured error properties like
4169
+ * code, name, and recoverability.
4170
+ *
4171
+ * @param error - Unknown error to check
4172
+ * @returns True if error is KitError with proper type narrowing
4173
+ *
4174
+ * @example
4175
+ * ```typescript
4176
+ * import { isKitError } from '@core/errors'
4177
+ *
4178
+ * try {
4179
+ * await kit.bridge(params)
4180
+ * } catch (error) {
4181
+ * if (isKitError(error)) {
4182
+ * // TypeScript knows this is KitError
4183
+ * console.log(`Structured error: ${error.name} (${error.code})`)
4184
+ * } else {
4185
+ * console.log('Regular error:', error)
4186
+ * }
4187
+ * }
4188
+ * ```
4189
+ */
4190
+ declare function isKitError(error: unknown): error is KitError;
4191
+ /**
4192
+ * Checks if an error is a KitError with FATAL recoverability.
4193
+ *
4194
+ * FATAL errors indicate issues that cannot be resolved through retries,
4195
+ * such as invalid inputs, configuration problems, or business rule
4196
+ * violations. These errors require user intervention to fix.
4197
+ *
4198
+ * @param error - Unknown error to check
4199
+ * @returns True if error is a KitError with FATAL recoverability
4200
+ *
4201
+ * @example
4202
+ * ```typescript
4203
+ * import { isFatalError } from '@core/errors'
4204
+ *
4205
+ * try {
4206
+ * await kit.bridge(params)
4207
+ * } catch (error) {
4208
+ * if (isFatalError(error)) {
4209
+ * // Show user-friendly error message - don't retry
4210
+ * showUserError(error.message)
4211
+ * }
4212
+ * }
4213
+ * ```
4214
+ */
4215
+ declare function isFatalError(error: unknown): boolean;
4216
+ /**
4217
+ * Checks if an error is a KitError with RETRYABLE recoverability.
4218
+ *
4219
+ * RETRYABLE errors indicate transient failures that may succeed on
4220
+ * subsequent attempts, such as network timeouts or temporary service
4221
+ * unavailability. These errors are safe to retry after a delay.
4222
+ *
4223
+ * @param error - Unknown error to check
4224
+ * @returns True if error is a KitError with RETRYABLE recoverability
4225
+ *
4226
+ * @example
4227
+ * ```typescript
4228
+ * import { isRetryableError } from '@core/errors'
4229
+ *
4230
+ * try {
4231
+ * await kit.bridge(params)
4232
+ * } catch (error) {
4233
+ * if (isRetryableError(error)) {
4234
+ * // Implement retry logic with exponential backoff
4235
+ * setTimeout(() => retryOperation(), 5000)
4236
+ * }
4237
+ * }
4238
+ * ```
4239
+ */
4240
+ declare function isRetryableError(error: unknown): boolean;
4241
+ /**
4242
+ * Combined type guard to check if error is KitError with INPUT type.
4243
+ *
4244
+ * INPUT errors have error codes in the 1000-1099 range and represent
4245
+ * validation failures, invalid parameters, or user input problems.
4246
+ * These errors are always FATAL and require the user to correct their
4247
+ * input before retrying.
4248
+ *
4249
+ * @param error - Unknown error to check
4250
+ * @returns True if error is KitError with INPUT error code range
4251
+ *
4252
+ * @example
4253
+ * ```typescript
4254
+ * import { isInputError } from '@core/errors'
4255
+ * import { createBridgeKit } from '@core/bridge'
4256
+ *
4257
+ * async function handleBridge() {
4258
+ * const kit = createBridgeKit(config)
4259
+ * const params = { amount: '100', from: 'ethereum', to: 'polygon' }
4260
+ *
4261
+ * try {
4262
+ * await kit.bridge(params)
4263
+ * } catch (error) {
4264
+ * if (isInputError(error)) {
4265
+ * console.log(`Input error: ${error.message} (code: ${error.code})`)
4266
+ * }
4267
+ * }
4268
+ * }
4269
+ * ```
4270
+ */
4271
+ declare function isInputError(error: unknown): error is KitError;
4272
+ /**
4273
+ * Safely extracts error message from any error type.
4274
+ *
4275
+ * This utility handles different error types gracefully, extracting
4276
+ * meaningful messages from Error instances, string errors, or providing
4277
+ * a fallback for unknown error types. Never throws.
4278
+ *
4279
+ * @param error - Unknown error to extract message from
4280
+ * @returns Error message string, or fallback message
4281
+ *
4282
+ * @example
4283
+ * ```typescript
4284
+ * import { getErrorMessage } from '@core/errors'
4285
+ *
4286
+ * try {
4287
+ * await riskyOperation()
4288
+ * } catch (error) {
4289
+ * const message = getErrorMessage(error)
4290
+ * console.log('Error occurred:', message)
4291
+ * // Works with Error, KitError, string, or any other type
4292
+ * }
4293
+ * ```
4294
+ */
4295
+ declare function getErrorMessage(error: unknown): string;
4296
+ /**
4297
+ * Gets the error code from a KitError, or null if not applicable.
4298
+ *
4299
+ * This utility safely extracts the numeric error code from KitError
4300
+ * instances, returning null for non-KitError types. Useful for
4301
+ * programmatic error handling based on specific error codes.
4302
+ *
4303
+ * @param error - Unknown error to extract code from
4304
+ * @returns Error code number, or null if not a KitError
4305
+ *
4306
+ * @example
4307
+ * ```typescript
4308
+ * import { getErrorCode, InputError } from '@core/errors'
4309
+ *
4310
+ * try {
4311
+ * await kit.bridge(params)
4312
+ * } catch (error) {
4313
+ * const code = getErrorCode(error)
4314
+ * if (code === InputError.NETWORK_MISMATCH.code) {
4315
+ * // Handle network mismatch specifically
4316
+ * showNetworkMismatchHelp()
4317
+ * }
4318
+ * }
4319
+ * ```
4320
+ */
4321
+ declare function getErrorCode(error: unknown): number | null;
4322
+
4323
+ export { Blockchain, BridgeKit, KitError, TransferSpeed, bridgeParamsWithChainIdentifierSchema, getErrorCode, getErrorMessage, isFatalError, isInputError, isKitError, isRetryableError, setExternalPrefix };
4324
+ export type { ActionHandler, AdapterContext, BridgeConfig, BridgeKitConfig, BridgeParams, BridgeResult, ChainDefinition, ChainIdentifier, CustomFeePolicy, ErrorDetails, Recoverability };