@circle-fin/app-kit 1.12.0 → 1.13.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.
@@ -717,6 +717,8 @@ declare enum Blockchain {
717
717
  Optimism_Sepolia = "Optimism_Sepolia",
718
718
  Pharos = "Pharos",
719
719
  Pharos_Testnet = "Pharos_Testnet",
720
+ Plasma = "Plasma",
721
+ Plasma_Testnet = "Plasma_Testnet",
720
722
  Polkadot_Asset_Hub = "Polkadot_Asset_Hub",
721
723
  Polkadot_Westmint = "Polkadot_Westmint",
722
724
  Plume = "Plume",
@@ -2299,7 +2301,7 @@ interface ExecuteParams {
2299
2301
  * fromAddress: '0x...',
2300
2302
  * toAddress: '0x...',
2301
2303
  * amount: '1000000',
2302
- * apiKey: 'KIT_KEY:...',
2304
+ * apiKey: 'TEST_API_KEY:...',
2303
2305
  * })
2304
2306
  *
2305
2307
  * // Build token inputs with permit
@@ -2443,7 +2445,7 @@ interface ExecuteSwapEVMParams extends ActionParameters {
2443
2445
  * fromAddress: 'YubQzu18FDqJRyNfG8JqHmsdbxhnoQqcKUHBdUkN6tP',
2444
2446
  * toAddress: 'YubQzu18FDqJRyNfG8JqHmsdbxhnoQqcKUHBdUkN6tP',
2445
2447
  * amount: '1000000',
2446
- * apiKey: 'KIT_KEY:...',
2448
+ * apiKey: 'TEST_API_KEY:...',
2447
2449
  * })
2448
2450
  *
2449
2451
  * // Prepare action parameters
@@ -2604,6 +2606,18 @@ interface TokenActionMap {
2604
2606
  */
2605
2607
  walletAddress?: string | undefined;
2606
2608
  };
2609
+ /**
2610
+ * Get the on-chain name of the token contract.
2611
+ *
2612
+ * This is a read-only operation. For USDC the value is also the EIP-712
2613
+ * domain name, which permit and authorize signing flows need.
2614
+ */
2615
+ name: ActionParameters & {
2616
+ /**
2617
+ * The contract address of the token.
2618
+ */
2619
+ tokenAddress: string;
2620
+ };
2607
2621
  }
2608
2622
 
2609
2623
  /**
@@ -3433,6 +3447,30 @@ declare class ActionRegistry {
3433
3447
  executeAction<TActionKey extends ActionKeys>(action: TActionKey, params: ActionPayload<TActionKey>, context: ResolvedOperationContext): Promise<PreparedChainRequest>;
3434
3448
  }
3435
3449
 
3450
+ /**
3451
+ * Canonical list of actions that do not prepare or submit transactions.
3452
+ *
3453
+ * @internal
3454
+ */
3455
+ declare const READ_ACTION_KEYS: readonly ["token.allowance", "token.balanceOf", "token.name", "native.balanceOf", "usdc.allowance", "usdc.balanceOf", "usdc.name", "gateway.v1.isDelegate", "gateway.v1.withdrawingBalance", "gateway.v1.withdrawalBlock", "gateway.v1.signBurnIntents"];
3456
+ /**
3457
+ * Action keys that execute without preparing or submitting a transaction.
3458
+ *
3459
+ * @remarks
3460
+ * Derive this type from the canonical runtime list so compile-time and runtime
3461
+ * classification cannot drift. `gateway.v1.signBurnIntents` is included
3462
+ * because the action system models off-chain signing as a read action: it does
3463
+ * not prepare a chain request.
3464
+ *
3465
+ * @example
3466
+ * ```typescript
3467
+ * import type { ReadActionKey } from '@core/adapter'
3468
+ *
3469
+ * const action: ReadActionKey = 'token.allowance'
3470
+ * ```
3471
+ */
3472
+ type ReadActionKey = (typeof READ_ACTION_KEYS)[number];
3473
+
3436
3474
  /**
3437
3475
  * Defines the capabilities of an adapter, including address handling patterns and supported chains.
3438
3476
  *
@@ -3601,6 +3639,69 @@ declare abstract class Adapter<TAdapterCapabilities extends AdapterCapabilities
3601
3639
  * ```
3602
3640
  */
3603
3641
  prepareAction<TActionKey extends ActionKeys>(action: TActionKey, params: ActionPayload<TActionKey>, ctx: OperationContext<TAdapterCapabilities>): Promise<PreparedChainRequest>;
3642
+ /**
3643
+ * Execute a non-transaction action without routing through transaction preparation.
3644
+ *
3645
+ * @remarks
3646
+ * Use this seam for balance, allowance, contract-state, and other actions
3647
+ * classified as reads. It never calls {@link Adapter.prepareAction}, so
3648
+ * transaction authorization wrappers only observe actions that can produce a
3649
+ * signable chain request.
3650
+ *
3651
+ * @typeParam TActionKey - The read action key.
3652
+ * @param action - The read action to execute.
3653
+ * @param params - The parameters for the read action.
3654
+ * @param ctx - The operation context.
3655
+ * @returns The raw action response.
3656
+ * @throws {KitError} When the key is not a read action or no handler is registered.
3657
+ * @throws Error When the operation context or action handler fails.
3658
+ *
3659
+ * @example
3660
+ * ```typescript
3661
+ * import { Ethereum } from '@core/chains'
3662
+ *
3663
+ * const balance = await adapter.readAction(
3664
+ * 'token.balanceOf',
3665
+ * { tokenAddress, walletAddress },
3666
+ * { chain: Ethereum },
3667
+ * )
3668
+ * ```
3669
+ *
3670
+ * @internal
3671
+ */
3672
+ readAction<TActionKey extends ReadActionKey>(action: TActionKey, params: ActionPayload<TActionKey>, ctx: OperationContext<TAdapterCapabilities>): Promise<unknown>;
3673
+ /**
3674
+ * Read the current token allowance a delegate holds over an owner's tokens.
3675
+ *
3676
+ * @remarks
3677
+ * Perform a network read through {@link Adapter.readAction}. This method
3678
+ * never routes through {@link Adapter.prepareAction}. On chains without an
3679
+ * allowance model, such as Solana, return the maximum uint256 value.
3680
+ *
3681
+ * @param params - The token to query and the delegate whose allowance is being read.
3682
+ * @param ctx - Operation context with compile-time validated address requirements.
3683
+ * @returns A promise resolving to the current allowance in the token's base units.
3684
+ * @throws {KitError} When the adapter does not register a `token.allowance` handler.
3685
+ * @throws Error When the operation context or action handler fails.
3686
+ *
3687
+ * @example
3688
+ * ```typescript
3689
+ * import type { Adapter } from '@core/adapter'
3690
+ * import { Ethereum } from '@core/chains'
3691
+ *
3692
+ * declare const adapter: Adapter
3693
+ *
3694
+ * const allowance = await adapter.getTokenAllowance(
3695
+ * {
3696
+ * tokenAddress: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
3697
+ * delegate: '0x1111111111111111111111111111111111111111',
3698
+ * },
3699
+ * { chain: Ethereum },
3700
+ * )
3701
+ * console.log(allowance) // 1000000n
3702
+ * ```
3703
+ */
3704
+ getTokenAllowance(params: ActionPayload<'token.allowance'>, ctx: OperationContext<TAdapterCapabilities>): Promise<bigint>;
3604
3705
  /**
3605
3706
  * Prepares a transaction for future gas estimation and execution.
3606
3707
  *
@@ -3787,6 +3888,80 @@ declare abstract class Adapter<TAdapterCapabilities extends AdapterCapabilities
3787
3888
  abstract getTokenDecimals(tokenAddress: string, chain: ChainDefinition): Promise<number>;
3788
3889
  }
3789
3890
 
3891
+ /**
3892
+ * Simplified error information structure for logging and events.
3893
+ *
3894
+ * @remarks
3895
+ * This lightweight type is used for error reporting in events, logs, and
3896
+ * observability systems. It provides essential error context without the
3897
+ * full ErrorDetails structure. Used across retry mechanisms, adapters,
3898
+ * and other subsystems that need to record error information.
3899
+ *
3900
+ * @example
3901
+ * ```typescript
3902
+ * import { ErrorInfo } from '@core/errors'
3903
+ *
3904
+ * const info: ErrorInfo = {
3905
+ * name: 'NETWORK_TIMEOUT',
3906
+ * message: 'Request timed out after 5000ms',
3907
+ * code: 3002
3908
+ * }
3909
+ * ```
3910
+ */
3911
+ interface ErrorInfo {
3912
+ /** Error name (e.g., 'TypeError', 'KitError', 'NETWORK_TIMEOUT'). */
3913
+ name: string;
3914
+ /** Error message describing what went wrong. */
3915
+ message: string;
3916
+ /** Optional error code if the error has one (e.g., KitError codes). */
3917
+ code?: number;
3918
+ /** Error category (e.g., INPUT, RPC, ONCHAIN, BALANCE, NETWORK, UNKNOWN). Only set for KitError instances. */
3919
+ type?: string;
3920
+ }
3921
+
3922
+ /**
3923
+ * Configuration options for the API polling utility.
3924
+ *
3925
+ * @remarks
3926
+ * These settings control the behavior of the API polling process:
3927
+ * - timeout: Maximum time (ms) to wait for each request before aborting
3928
+ * - maxRetries: Maximum number of retry attempts for failed requests
3929
+ * - retryDelay: Base delay (ms); constant wait for `'fixed'` or exponential seed for `'exponential'`
3930
+ * - backoff: Retry-delay strategy, `'fixed'` (default) or `'exponential'`
3931
+ * - maxRetryDelayMs: Optional ceiling (ms) for a single backoff wait
3932
+ * - headers: Optional HTTP headers to include with each request
3933
+ */
3934
+ interface ApiPollingConfig {
3935
+ /** Maximum time in milliseconds to wait for each request */
3936
+ timeout: number;
3937
+ /** Maximum number of retry attempts for failed requests */
3938
+ maxRetries: number;
3939
+ /**
3940
+ * Delay in milliseconds between retry attempts. With the default
3941
+ * `backoff: 'fixed'` strategy this is the constant wait; with
3942
+ * `backoff: 'exponential'` it is the base the exponential backoff grows
3943
+ * from (see {@link pollApiWithValidation}).
3944
+ */
3945
+ retryDelay: number;
3946
+ /**
3947
+ * Retry-delay strategy. `'fixed'` (the default when omitted) waits a
3948
+ * constant `retryDelay` between attempts; `'exponential'` grows the wait
3949
+ * exponentially off `retryDelay` and randomizes it with full jitter, which
3950
+ * spreads out retries so rate-limited (429) bursts do not retry in
3951
+ * lockstep. Opt in per caller; existing callers keep the fixed delay.
3952
+ */
3953
+ backoff?: 'fixed' | 'exponential' | undefined;
3954
+ /**
3955
+ * Optional ceiling, in milliseconds, for a single backoff wait. Only
3956
+ * applies when `backoff` is `'exponential'`: the exponential delay is
3957
+ * capped at this value before jitter is applied. Defaults to
3958
+ * {@link DEFAULT_MAX_RETRY_DELAY_MS} when omitted.
3959
+ */
3960
+ maxRetryDelayMs?: number | undefined;
3961
+ /** Optional HTTP headers to include with requests */
3962
+ headers?: Record<string, string> | undefined;
3963
+ }
3964
+
3790
3965
  /**
3791
3966
  * A type-safe event emitter for managing action-based event subscriptions.
3792
3967
  *
@@ -4027,37 +4202,6 @@ declare module './types' {
4027
4202
  }
4028
4203
  }
4029
4204
 
4030
- /**
4031
- * Simplified error information structure for logging and events.
4032
- *
4033
- * @remarks
4034
- * This lightweight type is used for error reporting in events, logs, and
4035
- * observability systems. It provides essential error context without the
4036
- * full ErrorDetails structure. Used across retry mechanisms, adapters,
4037
- * and other subsystems that need to record error information.
4038
- *
4039
- * @example
4040
- * ```typescript
4041
- * import { ErrorInfo } from '@core/errors'
4042
- *
4043
- * const info: ErrorInfo = {
4044
- * name: 'NETWORK_TIMEOUT',
4045
- * message: 'Request timed out after 5000ms',
4046
- * code: 3002
4047
- * }
4048
- * ```
4049
- */
4050
- interface ErrorInfo {
4051
- /** Error name (e.g., 'TypeError', 'KitError', 'NETWORK_TIMEOUT'). */
4052
- name: string;
4053
- /** Error message describing what went wrong. */
4054
- message: string;
4055
- /** Optional error code if the error has one (e.g., KitError codes). */
4056
- code?: number;
4057
- /** Error category (e.g., INPUT, RPC, ONCHAIN, BALANCE, NETWORK, UNKNOWN). Only set for KitError instances. */
4058
- type?: string;
4059
- }
4060
-
4061
4205
  /**
4062
4206
  * Runtime array of token identifiers supported by the Gateway v1 provider.
4063
4207
  *
@@ -4564,6 +4708,15 @@ interface SpendOptions {
4564
4708
  * @internal
4565
4709
  */
4566
4710
  onBroadcast?: (txHash: string) => void;
4711
+ /**
4712
+ * Partial polling config forwarded to every Gateway API request the spend
4713
+ * makes (estimate, transfer, forwarder status, and the balance lookups on
4714
+ * the auto-allocation path). The provider factory populates this from its
4715
+ * `headers` config so a configured header reaches all spend-path calls.
4716
+ *
4717
+ * @internal
4718
+ */
4719
+ requestConfig?: Partial<ApiPollingConfig>;
4567
4720
  }
4568
4721
  /**
4569
4722
  * Result returned after a successful spend (mint) operation.
@@ -6395,6 +6548,26 @@ interface UnifiedBalanceKitConfig<TExtraProviders extends FlexibleGatewayProvide
6395
6548
  * @defaultValue false
6396
6549
  */
6397
6550
  excludeDefaultProviders?: boolean;
6551
+ /**
6552
+ * Custom HTTP headers forwarded with every Circle Gateway API request the
6553
+ * default Gateway v1 provider makes (balances, deposits, spend estimate,
6554
+ * transfer, forwarder status, and `/v1/info`).
6555
+ *
6556
+ * @remarks
6557
+ * Headers are merged on top of the SDK defaults (such as `Content-Type`)
6558
+ * rather than replacing them. Each header is forwarded as-is to Circle's
6559
+ * API; the SDK does not interpret it. Only applies to the default provider —
6560
+ * has no effect when `excludeDefaultProviders` is `true` or on custom
6561
+ * providers supplied via `providers`.
6562
+ *
6563
+ * @example
6564
+ * ```typescript
6565
+ * const kit = new UnifiedBalanceKit({
6566
+ * headers: { 'X-Access-Key': process.env.GATEWAY_ACCESS_KEY! },
6567
+ * })
6568
+ * ```
6569
+ */
6570
+ headers?: Record<string, string>;
6398
6571
  }
6399
6572
 
6400
6573
  /**