@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.
@@ -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
  *
@@ -5760,6 +5863,139 @@ type BridgeDestination<TAdapterCapabilities extends AdapterCapabilities = Adapte
5760
5863
  useForwarder?: boolean;
5761
5864
  }) | ForwarderDestination<TChainIdentifier>;
5762
5865
 
5866
+ /**
5867
+ * The expiry window of a signed quote.
5868
+ *
5869
+ * A signed quote is short-lived; refresh it immediately before submitting
5870
+ * on-chain rather than caching it.
5871
+ */
5872
+ type FeeQuoteExpiry = {
5873
+ /** Identify an exact Unix timestamp expiry. */
5874
+ readonly mode: 'TIMESTAMP';
5875
+ /** Unix timestamp in seconds at which the quote expires. */
5876
+ readonly expiresAt: number;
5877
+ } | {
5878
+ /** Identify a source-chain block-number expiry. */
5879
+ readonly mode: 'BLOCK_NUMBER';
5880
+ /** Authoritative source-chain block at which the quote expires. */
5881
+ readonly expiresAtBlock: number;
5882
+ /** Optional advisory Unix timestamp estimate for the expiry block. */
5883
+ readonly blockEstimatedAt?: number;
5884
+ };
5885
+
5886
+ /**
5887
+ * Configure how CCTP and forwarding fees are collected for a bridge.
5888
+ *
5889
+ * @remarks
5890
+ * Use `'source'` with `to.useForwarder: true` to treat `amount` as the exact
5891
+ * destination amount. Bridge Kit obtains a signed fee quote, collects the fee
5892
+ * in source-chain USDC, and leaves the destination mint unreduced. Omit the
5893
+ * option (or use `'destination'`) to preserve the existing max-fee behavior.
5894
+ *
5895
+ * @example
5896
+ * ```typescript
5897
+ * import type { BridgeExecutionConfig } from '@circle-fin/bridge-kit'
5898
+ *
5899
+ * const config: BridgeExecutionConfig = {
5900
+ * transferSpeed: 'FAST',
5901
+ * feePayment: 'source',
5902
+ * }
5903
+ * ```
5904
+ * @since 1.14.0
5905
+ */
5906
+ interface BridgeExecutionConfig extends BridgeConfig {
5907
+ /** Select source-side signed fees or the legacy destination-side fee path. */
5908
+ feePayment?: 'source' | 'destination';
5909
+ }
5910
+ /**
5911
+ * Describe one signed Fee Service line item in human-readable USDC.
5912
+ *
5913
+ * @example
5914
+ * ```typescript
5915
+ * import type { ReceiveExactFeeItem } from '@circle-fin/bridge-kit'
5916
+ *
5917
+ * const item: ReceiveExactFeeItem = {
5918
+ * type: 'FORWARD',
5919
+ * amount: '0.25',
5920
+ * args: [],
5921
+ * argsHash: `0x${'00'.repeat(32)}`,
5922
+ * }
5923
+ * ```
5924
+ * @since 1.14.0
5925
+ */
5926
+ interface ReceiveExactFeeItem {
5927
+ /** The Fee Service item type, such as `FORWARD` or `PRE_FINALITY`. */
5928
+ readonly type: string;
5929
+ /** The fee amount in human-readable USDC. */
5930
+ readonly amount: string;
5931
+ /** The ABI arguments covered by the signed quote. */
5932
+ readonly args: readonly string[];
5933
+ /** The hash of the ABI arguments covered by the signed quote. */
5934
+ readonly argsHash: string;
5935
+ }
5936
+ /**
5937
+ * Return a receive-exact bridge estimate backed by a short-lived signed quote.
5938
+ *
5939
+ * @remarks
5940
+ * Treat `quote` as opaque and sensitive. Pass it back to
5941
+ * {@link BridgeKit.bridge}; do not log or decode it. Bridge Kit validates a
5942
+ * supplied quote against the exact transfer parameters and rejects it when it
5943
+ * is invalid, mismatched, expired, or too close to expiry.
5944
+ *
5945
+ * @example
5946
+ * ```typescript
5947
+ * import { BridgeKit, type BridgeParams } from '@circle-fin/bridge-kit'
5948
+ *
5949
+ * declare const adapter: BridgeParams['from']['adapter']
5950
+ * const kit = new BridgeKit()
5951
+ *
5952
+ * const estimate = await kit.estimate({
5953
+ * from: { adapter, chain: 'Ethereum' },
5954
+ * to: {
5955
+ * chain: 'Base',
5956
+ * recipientAddress: '0x1234567890123456789012345678901234567890',
5957
+ * useForwarder: true,
5958
+ * },
5959
+ * amount: '100',
5960
+ * config: { feePayment: 'source' },
5961
+ * })
5962
+ * console.log(estimate.amountReceived, estimate.totalDebit)
5963
+ * ```
5964
+ * @since 1.14.0
5965
+ */
5966
+ interface ReceiveExactEstimateResult extends EstimateResult {
5967
+ /** The exact amount the destination recipient receives, in USDC. */
5968
+ readonly amountReceived: string;
5969
+ /** The total signed fee collected on the source chain, in USDC. */
5970
+ readonly feeTotal: string;
5971
+ /** The itemized signed fee quote, with amounts in human-readable USDC. */
5972
+ readonly feeItems: readonly ReceiveExactFeeItem[];
5973
+ /** The total source-wallet debit (`amountReceived + feeTotal`), in USDC. */
5974
+ readonly totalDebit: string;
5975
+ /** The authoritative expiry returned by the Fee Service. */
5976
+ readonly quoteExpiry: FeeQuoteExpiry;
5977
+ /** Opaque signed quote bytes to pass to {@link BridgeKit.bridge}. */
5978
+ readonly quote: string;
5979
+ }
5980
+ /**
5981
+ * Result returned by {@link BridgeKit.estimate} for legacy and source-fee modes.
5982
+ *
5983
+ * @example
5984
+ * ```typescript
5985
+ * import {
5986
+ * BridgeKit,
5987
+ * type BridgeEstimateResult,
5988
+ * type BridgeParams,
5989
+ * } from '@circle-fin/bridge-kit'
5990
+ *
5991
+ * declare const params: BridgeParams
5992
+ * const kit = new BridgeKit()
5993
+ * const result: BridgeEstimateResult = await kit.estimate(params)
5994
+ * if ('amountReceived' in result) console.log(result.totalDebit)
5995
+ * ```
5996
+ * @since 1.14.0
5997
+ */
5998
+ type BridgeEstimateResult = EstimateResult | ReceiveExactEstimateResult;
5763
5999
  type FeeFunction<TFromAdapterCapabilities extends AdapterCapabilities, TToAdapterCapabilities extends AdapterCapabilities> = (params: BridgeParams$1<TFromAdapterCapabilities, TToAdapterCapabilities>) => Promise<string> | string;
5764
6000
  type FeeRecipientFunction<TFromAdapterCapabilities extends AdapterCapabilities, TToAdapterCapabilities extends AdapterCapabilities> = (feePayoutChain: ChainDefinition, params: BridgeParams$1<TFromAdapterCapabilities, TToAdapterCapabilities>) => Promise<string> | string;
5765
6001
  /**
@@ -5920,7 +6156,7 @@ interface BridgeParams<TFromAdapterCapabilities extends AdapterCapabilities = Ad
5920
6156
  * Optional bridge configuration (e.g., transfer speed).
5921
6157
  * If omitted, defaults will be used
5922
6158
  */
5923
- config?: BridgeConfig;
6159
+ config?: BridgeExecutionConfig;
5924
6160
  /**
5925
6161
  * The token to transfer. Defaults to 'USDC'.
5926
6162
  * If omitted, the provider will use 'USDC' by default.
@@ -5947,6 +6183,16 @@ interface BridgeParams<TFromAdapterCapabilities extends AdapterCapabilities = Ad
5947
6183
  * ```
5948
6184
  */
5949
6185
  invocationMeta?: InvocationMeta;
6186
+ /**
6187
+ * Reuse the opaque signed quote returned by a receive-exact estimate.
6188
+ *
6189
+ * @remarks
6190
+ * Bridge Kit validates a supplied quote against the exact transfer and fails
6191
+ * when it is invalid, mismatched, expired, or too close to expiry. Omit this
6192
+ * value to let Bridge Kit fetch a fresh quote automatically. Never log or
6193
+ * decode it.
6194
+ */
6195
+ quote?: string;
5950
6196
  }
5951
6197
 
5952
6198
  /**
@@ -6062,12 +6308,21 @@ interface ServiceSwapConfig {
6062
6308
  recipientAddress?: string;
6063
6309
  };
6064
6310
  /**
6065
- * Stablecoin Service Kit Key used to authenticate service-backed swap
6066
- * requests.
6311
+ * Circle API key used to authenticate service-backed swap requests.
6312
+ *
6313
+ * Format: `<ENV>_API_KEY:<keyId>:<keySecret>`. A legacy
6314
+ * `KIT_KEY:<keyId>:<keySecret>` value is also accepted.
6067
6315
  *
6068
6316
  * Treat this value as a credential. Do not log it, embed it in client-side
6069
6317
  * source, or expose it in telemetry.
6070
6318
  */
6319
+ apiKey?: string | undefined;
6320
+ /**
6321
+ * Circle API key used to authenticate service-backed swap requests.
6322
+ *
6323
+ * @deprecated Use {@link ServiceSwapConfig.apiKey} instead. Still honored
6324
+ * when `apiKey` is omitted, and `apiKey` takes precedence when both are set.
6325
+ */
6071
6326
  kitKey?: string;
6072
6327
  /**
6073
6328
  * DEX aggregator identifier used to source the swap route.
@@ -6545,12 +6800,21 @@ interface SwapConfig {
6545
6800
  recipientAddress: string;
6546
6801
  };
6547
6802
  /**
6548
- * Stablecoin Service Kit Key used to authenticate service-backed swap
6549
- * requests.
6803
+ * Circle API key used to authenticate service-backed swap requests.
6804
+ *
6805
+ * Format: `<ENV>_API_KEY:<keyId>:<keySecret>`. A legacy
6806
+ * `KIT_KEY:<keyId>:<keySecret>` value is also accepted.
6550
6807
  *
6551
6808
  * Treat this value as a credential. Do not log it, embed it in client-side
6552
6809
  * source, or expose it in telemetry.
6553
6810
  */
6811
+ apiKey?: string | undefined;
6812
+ /**
6813
+ * Circle API key used to authenticate service-backed swap requests.
6814
+ *
6815
+ * @deprecated Use {@link SwapConfig.apiKey} instead. Still honored when
6816
+ * `apiKey` is omitted, and `apiKey` takes precedence when both are set.
6817
+ */
6554
6818
  kitKey?: string;
6555
6819
  }
6556
6820
  /**
@@ -6679,29 +6943,37 @@ type EarnAdapterContext<TAdapterCapabilities extends AdapterCapabilities = Adapt
6679
6943
  * Configuration options for earn operations.
6680
6944
  *
6681
6945
  * EarnKit supports dual-mode authentication: operations work both with
6682
- * and without a Kit Key. When present, the Kit Key enables permissioned
6946
+ * and without an API key. When present, the API key enables permissioned
6683
6947
  * features like integrator attribution tracking.
6684
6948
  *
6685
6949
  * @example
6686
6950
  * ```typescript
6687
- * // Permissionless (no Kit Key)
6951
+ * // Permissionless (no API key)
6688
6952
  * const config: EarnConfig = {}
6689
6953
  *
6690
- * // Permissioned (with Kit Key)
6954
+ * // Permissioned (with API key)
6691
6955
  * const config: EarnConfig = {
6692
- * kitKey: 'KIT_KEY:keyId:keySecret',
6956
+ * apiKey: 'TEST_API_KEY:keyId:keySecret',
6693
6957
  * }
6694
6958
  * ```
6695
6959
  */
6696
6960
  interface EarnConfig {
6697
6961
  /**
6698
- * Optional Kit Key for permissioned access.
6962
+ * Optional Circle API key for permissioned access.
6699
6963
  *
6700
6964
  * When provided, enables integrator attribution tracking and
6701
6965
  * higher rate limits. When omitted, the SDK operates in
6702
6966
  * permissionless mode.
6703
6967
  *
6704
- * Format: `KIT_KEY:<keyId>:<keySecret>`
6968
+ * Format: `<ENV>_API_KEY:<keyId>:<keySecret>`. A legacy
6969
+ * `KIT_KEY:<keyId>:<keySecret>` value is also accepted.
6970
+ */
6971
+ readonly apiKey?: string | undefined;
6972
+ /**
6973
+ * Optional Circle API key for permissioned access.
6974
+ *
6975
+ * @deprecated Use {@link EarnConfig.apiKey} instead. Still honored when
6976
+ * `apiKey` is omitted, and `apiKey` takes precedence when both are set.
6705
6977
  */
6706
6978
  readonly kitKey?: string | undefined;
6707
6979
  /**
@@ -7468,13 +7740,18 @@ interface AppKitContext {
7468
7740
  */
7469
7741
  disableErrorReporting?: boolean;
7470
7742
  /**
7471
- * Custom HTTP headers forwarded with the underlying CCTP provider's
7472
- * attestation (Iris) API requests made by bridge operations.
7743
+ * Custom HTTP headers forwarded with Circle API requests made by the
7744
+ * underlying kits: the CCTP provider's attestation (Iris) requests for
7745
+ * bridge operations, and the Gateway API requests for unified-balance
7746
+ * operations.
7473
7747
  *
7474
7748
  * @remarks
7475
7749
  * Headers are merged on top of the SDK defaults (such as `Content-Type`)
7476
- * rather than replacing them. The header is forwarded as-is to Circle's API;
7477
- * the SDK does not interpret it.
7750
+ * rather than replacing them. Each header is forwarded as-is to Circle's API;
7751
+ * the SDK does not interpret it. The same map is forwarded to every relevant
7752
+ * kit, so a header a given API ignores is simply a no-op there. A
7753
+ * `unifiedBalance.headers` value, if provided, takes precedence for the
7754
+ * unified-balance kit.
7478
7755
  */
7479
7756
  headers?: Record<string, string>;
7480
7757
  }
@@ -7518,6 +7795,6 @@ interface AppKitContext {
7518
7795
  * console.log('Estimated gas fees:', estimate.gasFees)
7519
7796
  * ```
7520
7797
  */
7521
- declare const estimateBridge: (context: AppKitContext, params: BridgeParams) => Promise<EstimateResult>;
7798
+ declare const estimateBridge: (context: AppKitContext, params: BridgeParams) => Promise<BridgeEstimateResult>;
7522
7799
 
7523
7800
  export { estimateBridge };