@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.
package/estimateSwap.d.ts CHANGED
@@ -718,6 +718,8 @@ declare enum Blockchain {
718
718
  Optimism_Sepolia = "Optimism_Sepolia",
719
719
  Pharos = "Pharos",
720
720
  Pharos_Testnet = "Pharos_Testnet",
721
+ Plasma = "Plasma",
722
+ Plasma_Testnet = "Plasma_Testnet",
721
723
  Polkadot_Asset_Hub = "Polkadot_Asset_Hub",
722
724
  Polkadot_Westmint = "Polkadot_Westmint",
723
725
  Plume = "Plume",
@@ -946,6 +948,7 @@ declare enum BridgeChain {
946
948
  Morph = "Morph",
947
949
  Optimism = "Optimism",
948
950
  Pharos = "Pharos",
951
+ Plasma = "Plasma",
949
952
  Plume = "Plume",
950
953
  Polygon = "Polygon",
951
954
  Sei = "Sei",
@@ -971,6 +974,7 @@ declare enum BridgeChain {
971
974
  Morph_Testnet = "Morph_Testnet",
972
975
  Optimism_Sepolia = "Optimism_Sepolia",
973
976
  Pharos_Testnet = "Pharos_Testnet",
977
+ Plasma_Testnet = "Plasma_Testnet",
974
978
  Plume_Testnet = "Plume_Testnet",
975
979
  Polygon_Amoy_Testnet = "Polygon_Amoy_Testnet",
976
980
  Sei_Testnet = "Sei_Testnet",
@@ -2652,7 +2656,7 @@ interface ExecuteParams {
2652
2656
  * fromAddress: '0x...',
2653
2657
  * toAddress: '0x...',
2654
2658
  * amount: '1000000',
2655
- * apiKey: 'KIT_KEY:...',
2659
+ * apiKey: 'TEST_API_KEY:...',
2656
2660
  * })
2657
2661
  *
2658
2662
  * // Build token inputs with permit
@@ -2796,7 +2800,7 @@ interface ExecuteSwapEVMParams extends ActionParameters {
2796
2800
  * fromAddress: 'YubQzu18FDqJRyNfG8JqHmsdbxhnoQqcKUHBdUkN6tP',
2797
2801
  * toAddress: 'YubQzu18FDqJRyNfG8JqHmsdbxhnoQqcKUHBdUkN6tP',
2798
2802
  * amount: '1000000',
2799
- * apiKey: 'KIT_KEY:...',
2803
+ * apiKey: 'TEST_API_KEY:...',
2800
2804
  * })
2801
2805
  *
2802
2806
  * // Prepare action parameters
@@ -2957,6 +2961,18 @@ interface TokenActionMap {
2957
2961
  */
2958
2962
  walletAddress?: string | undefined;
2959
2963
  };
2964
+ /**
2965
+ * Get the on-chain name of the token contract.
2966
+ *
2967
+ * This is a read-only operation. For USDC the value is also the EIP-712
2968
+ * domain name, which permit and authorize signing flows need.
2969
+ */
2970
+ name: ActionParameters & {
2971
+ /**
2972
+ * The contract address of the token.
2973
+ */
2974
+ tokenAddress: string;
2975
+ };
2960
2976
  }
2961
2977
 
2962
2978
  /**
@@ -3786,6 +3802,30 @@ declare class ActionRegistry {
3786
3802
  executeAction<TActionKey extends ActionKeys>(action: TActionKey, params: ActionPayload<TActionKey>, context: ResolvedOperationContext): Promise<PreparedChainRequest>;
3787
3803
  }
3788
3804
 
3805
+ /**
3806
+ * Canonical list of actions that do not prepare or submit transactions.
3807
+ *
3808
+ * @internal
3809
+ */
3810
+ 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"];
3811
+ /**
3812
+ * Action keys that execute without preparing or submitting a transaction.
3813
+ *
3814
+ * @remarks
3815
+ * Derive this type from the canonical runtime list so compile-time and runtime
3816
+ * classification cannot drift. `gateway.v1.signBurnIntents` is included
3817
+ * because the action system models off-chain signing as a read action: it does
3818
+ * not prepare a chain request.
3819
+ *
3820
+ * @example
3821
+ * ```typescript
3822
+ * import type { ReadActionKey } from '@core/adapter'
3823
+ *
3824
+ * const action: ReadActionKey = 'token.allowance'
3825
+ * ```
3826
+ */
3827
+ type ReadActionKey = (typeof READ_ACTION_KEYS)[number];
3828
+
3789
3829
  /**
3790
3830
  * Defines the capabilities of an adapter, including address handling patterns and supported chains.
3791
3831
  *
@@ -3954,6 +3994,69 @@ declare abstract class Adapter<TAdapterCapabilities extends AdapterCapabilities
3954
3994
  * ```
3955
3995
  */
3956
3996
  prepareAction<TActionKey extends ActionKeys>(action: TActionKey, params: ActionPayload<TActionKey>, ctx: OperationContext<TAdapterCapabilities>): Promise<PreparedChainRequest>;
3997
+ /**
3998
+ * Execute a non-transaction action without routing through transaction preparation.
3999
+ *
4000
+ * @remarks
4001
+ * Use this seam for balance, allowance, contract-state, and other actions
4002
+ * classified as reads. It never calls {@link Adapter.prepareAction}, so
4003
+ * transaction authorization wrappers only observe actions that can produce a
4004
+ * signable chain request.
4005
+ *
4006
+ * @typeParam TActionKey - The read action key.
4007
+ * @param action - The read action to execute.
4008
+ * @param params - The parameters for the read action.
4009
+ * @param ctx - The operation context.
4010
+ * @returns The raw action response.
4011
+ * @throws {KitError} When the key is not a read action or no handler is registered.
4012
+ * @throws Error When the operation context or action handler fails.
4013
+ *
4014
+ * @example
4015
+ * ```typescript
4016
+ * import { Ethereum } from '@core/chains'
4017
+ *
4018
+ * const balance = await adapter.readAction(
4019
+ * 'token.balanceOf',
4020
+ * { tokenAddress, walletAddress },
4021
+ * { chain: Ethereum },
4022
+ * )
4023
+ * ```
4024
+ *
4025
+ * @internal
4026
+ */
4027
+ readAction<TActionKey extends ReadActionKey>(action: TActionKey, params: ActionPayload<TActionKey>, ctx: OperationContext<TAdapterCapabilities>): Promise<unknown>;
4028
+ /**
4029
+ * Read the current token allowance a delegate holds over an owner's tokens.
4030
+ *
4031
+ * @remarks
4032
+ * Perform a network read through {@link Adapter.readAction}. This method
4033
+ * never routes through {@link Adapter.prepareAction}. On chains without an
4034
+ * allowance model, such as Solana, return the maximum uint256 value.
4035
+ *
4036
+ * @param params - The token to query and the delegate whose allowance is being read.
4037
+ * @param ctx - Operation context with compile-time validated address requirements.
4038
+ * @returns A promise resolving to the current allowance in the token's base units.
4039
+ * @throws {KitError} When the adapter does not register a `token.allowance` handler.
4040
+ * @throws Error When the operation context or action handler fails.
4041
+ *
4042
+ * @example
4043
+ * ```typescript
4044
+ * import type { Adapter } from '@core/adapter'
4045
+ * import { Ethereum } from '@core/chains'
4046
+ *
4047
+ * declare const adapter: Adapter
4048
+ *
4049
+ * const allowance = await adapter.getTokenAllowance(
4050
+ * {
4051
+ * tokenAddress: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
4052
+ * delegate: '0x1111111111111111111111111111111111111111',
4053
+ * },
4054
+ * { chain: Ethereum },
4055
+ * )
4056
+ * console.log(allowance) // 1000000n
4057
+ * ```
4058
+ */
4059
+ getTokenAllowance(params: ActionPayload<'token.allowance'>, ctx: OperationContext<TAdapterCapabilities>): Promise<bigint>;
3957
4060
  /**
3958
4061
  * Prepares a transaction for future gas estimation and execution.
3959
4062
  *
@@ -5851,12 +5954,21 @@ interface ServiceSwapConfig {
5851
5954
  recipientAddress?: string;
5852
5955
  };
5853
5956
  /**
5854
- * Stablecoin Service Kit Key used to authenticate service-backed swap
5855
- * requests.
5957
+ * Circle API key used to authenticate service-backed swap requests.
5958
+ *
5959
+ * Format: `<ENV>_API_KEY:<keyId>:<keySecret>`. A legacy
5960
+ * `KIT_KEY:<keyId>:<keySecret>` value is also accepted.
5856
5961
  *
5857
5962
  * Treat this value as a credential. Do not log it, embed it in client-side
5858
5963
  * source, or expose it in telemetry.
5859
5964
  */
5965
+ apiKey?: string | undefined;
5966
+ /**
5967
+ * Circle API key used to authenticate service-backed swap requests.
5968
+ *
5969
+ * @deprecated Use {@link ServiceSwapConfig.apiKey} instead. Still honored
5970
+ * when `apiKey` is omitted, and `apiKey` takes precedence when both are set.
5971
+ */
5860
5972
  kitKey?: string;
5861
5973
  /**
5862
5974
  * DEX aggregator identifier used to source the swap route.
@@ -6387,12 +6499,21 @@ interface SwapConfig {
6387
6499
  recipientAddress: string;
6388
6500
  };
6389
6501
  /**
6390
- * Stablecoin Service Kit Key used to authenticate service-backed swap
6391
- * requests.
6502
+ * Circle API key used to authenticate service-backed swap requests.
6503
+ *
6504
+ * Format: `<ENV>_API_KEY:<keyId>:<keySecret>`. A legacy
6505
+ * `KIT_KEY:<keyId>:<keySecret>` value is also accepted.
6392
6506
  *
6393
6507
  * Treat this value as a credential. Do not log it, embed it in client-side
6394
6508
  * source, or expose it in telemetry.
6395
6509
  */
6510
+ apiKey?: string | undefined;
6511
+ /**
6512
+ * Circle API key used to authenticate service-backed swap requests.
6513
+ *
6514
+ * @deprecated Use {@link SwapConfig.apiKey} instead. Still honored when
6515
+ * `apiKey` is omitted, and `apiKey` takes precedence when both are set.
6516
+ */
6396
6517
  kitKey?: string;
6397
6518
  }
6398
6519
  /**
@@ -6591,6 +6712,30 @@ interface SwapParams<TFromAdapterCapabilities extends AdapterCapabilities = Adap
6591
6712
  config?: SwapConfig;
6592
6713
  }
6593
6714
 
6715
+ /**
6716
+ * Configure how CCTP and forwarding fees are collected for a bridge.
6717
+ *
6718
+ * @remarks
6719
+ * Use `'source'` with `to.useForwarder: true` to treat `amount` as the exact
6720
+ * destination amount. Bridge Kit obtains a signed fee quote, collects the fee
6721
+ * in source-chain USDC, and leaves the destination mint unreduced. Omit the
6722
+ * option (or use `'destination'`) to preserve the existing max-fee behavior.
6723
+ *
6724
+ * @example
6725
+ * ```typescript
6726
+ * import type { BridgeExecutionConfig } from '@circle-fin/bridge-kit'
6727
+ *
6728
+ * const config: BridgeExecutionConfig = {
6729
+ * transferSpeed: 'FAST',
6730
+ * feePayment: 'source',
6731
+ * }
6732
+ * ```
6733
+ * @since 1.14.0
6734
+ */
6735
+ interface BridgeExecutionConfig extends BridgeConfig {
6736
+ /** Select source-side signed fees or the legacy destination-side fee path. */
6737
+ feePayment?: 'source' | 'destination';
6738
+ }
6594
6739
  type FeeFunction<TFromAdapterCapabilities extends AdapterCapabilities, TToAdapterCapabilities extends AdapterCapabilities> = (params: BridgeParams$1<TFromAdapterCapabilities, TToAdapterCapabilities>) => Promise<string> | string;
6595
6740
  type FeeRecipientFunction<TFromAdapterCapabilities extends AdapterCapabilities, TToAdapterCapabilities extends AdapterCapabilities> = (feePayoutChain: ChainDefinition, params: BridgeParams$1<TFromAdapterCapabilities, TToAdapterCapabilities>) => Promise<string> | string;
6596
6741
  /**
@@ -6751,7 +6896,7 @@ interface BridgeParams<TFromAdapterCapabilities extends AdapterCapabilities = Ad
6751
6896
  * Optional bridge configuration (e.g., transfer speed).
6752
6897
  * If omitted, defaults will be used
6753
6898
  */
6754
- config?: BridgeConfig;
6899
+ config?: BridgeExecutionConfig;
6755
6900
  /**
6756
6901
  * The token to transfer. Defaults to 'USDC'.
6757
6902
  * If omitted, the provider will use 'USDC' by default.
@@ -6778,6 +6923,16 @@ interface BridgeParams<TFromAdapterCapabilities extends AdapterCapabilities = Ad
6778
6923
  * ```
6779
6924
  */
6780
6925
  invocationMeta?: InvocationMeta;
6926
+ /**
6927
+ * Reuse the opaque signed quote returned by a receive-exact estimate.
6928
+ *
6929
+ * @remarks
6930
+ * Bridge Kit validates a supplied quote against the exact transfer and fails
6931
+ * when it is invalid, mismatched, expired, or too close to expiry. Omit this
6932
+ * value to let Bridge Kit fetch a fresh quote automatically. Never log or
6933
+ * decode it.
6934
+ */
6935
+ quote?: string;
6781
6936
  }
6782
6937
 
6783
6938
  /**
@@ -6822,29 +6977,37 @@ type EarnAdapterContext<TAdapterCapabilities extends AdapterCapabilities = Adapt
6822
6977
  * Configuration options for earn operations.
6823
6978
  *
6824
6979
  * EarnKit supports dual-mode authentication: operations work both with
6825
- * and without a Kit Key. When present, the Kit Key enables permissioned
6980
+ * and without an API key. When present, the API key enables permissioned
6826
6981
  * features like integrator attribution tracking.
6827
6982
  *
6828
6983
  * @example
6829
6984
  * ```typescript
6830
- * // Permissionless (no Kit Key)
6985
+ * // Permissionless (no API key)
6831
6986
  * const config: EarnConfig = {}
6832
6987
  *
6833
- * // Permissioned (with Kit Key)
6988
+ * // Permissioned (with API key)
6834
6989
  * const config: EarnConfig = {
6835
- * kitKey: 'KIT_KEY:keyId:keySecret',
6990
+ * apiKey: 'TEST_API_KEY:keyId:keySecret',
6836
6991
  * }
6837
6992
  * ```
6838
6993
  */
6839
6994
  interface EarnConfig {
6840
6995
  /**
6841
- * Optional Kit Key for permissioned access.
6996
+ * Optional Circle API key for permissioned access.
6842
6997
  *
6843
6998
  * When provided, enables integrator attribution tracking and
6844
6999
  * higher rate limits. When omitted, the SDK operates in
6845
7000
  * permissionless mode.
6846
7001
  *
6847
- * Format: `KIT_KEY:<keyId>:<keySecret>`
7002
+ * Format: `<ENV>_API_KEY:<keyId>:<keySecret>`. A legacy
7003
+ * `KIT_KEY:<keyId>:<keySecret>` value is also accepted.
7004
+ */
7005
+ readonly apiKey?: string | undefined;
7006
+ /**
7007
+ * Optional Circle API key for permissioned access.
7008
+ *
7009
+ * @deprecated Use {@link EarnConfig.apiKey} instead. Still honored when
7010
+ * `apiKey` is omitted, and `apiKey` takes precedence when both are set.
6848
7011
  */
6849
7012
  readonly kitKey?: string | undefined;
6850
7013
  /**
@@ -7611,13 +7774,18 @@ interface AppKitContext {
7611
7774
  */
7612
7775
  disableErrorReporting?: boolean;
7613
7776
  /**
7614
- * Custom HTTP headers forwarded with the underlying CCTP provider's
7615
- * attestation (Iris) API requests made by bridge operations.
7777
+ * Custom HTTP headers forwarded with Circle API requests made by the
7778
+ * underlying kits: the CCTP provider's attestation (Iris) requests for
7779
+ * bridge operations, and the Gateway API requests for unified-balance
7780
+ * operations.
7616
7781
  *
7617
7782
  * @remarks
7618
7783
  * Headers are merged on top of the SDK defaults (such as `Content-Type`)
7619
- * rather than replacing them. The header is forwarded as-is to Circle's API;
7620
- * the SDK does not interpret it.
7784
+ * rather than replacing them. Each header is forwarded as-is to Circle's API;
7785
+ * the SDK does not interpret it. The same map is forwarded to every relevant
7786
+ * kit, so a header a given API ignores is simply a no-op there. A
7787
+ * `unifiedBalance.headers` value, if provided, takes precedence for the
7788
+ * unified-balance kit.
7621
7789
  */
7622
7790
  headers?: Record<string, string>;
7623
7791
  }