@circle-fin/app-kit 1.12.0 → 1.12.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/context.d.cts CHANGED
@@ -2957,6 +2957,18 @@ interface TokenActionMap {
2957
2957
  */
2958
2958
  walletAddress?: string | undefined;
2959
2959
  };
2960
+ /**
2961
+ * Get the on-chain name of the token contract.
2962
+ *
2963
+ * This is a read-only operation. For USDC the value is also the EIP-712
2964
+ * domain name, which permit and authorize signing flows need.
2965
+ */
2966
+ name: ActionParameters & {
2967
+ /**
2968
+ * The contract address of the token.
2969
+ */
2970
+ tokenAddress: string;
2971
+ };
2960
2972
  }
2961
2973
 
2962
2974
  /**
@@ -3786,6 +3798,30 @@ declare class ActionRegistry {
3786
3798
  executeAction<TActionKey extends ActionKeys>(action: TActionKey, params: ActionPayload<TActionKey>, context: ResolvedOperationContext): Promise<PreparedChainRequest>;
3787
3799
  }
3788
3800
 
3801
+ /**
3802
+ * Canonical list of actions that do not prepare or submit transactions.
3803
+ *
3804
+ * @internal
3805
+ */
3806
+ 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"];
3807
+ /**
3808
+ * Action keys that execute without preparing or submitting a transaction.
3809
+ *
3810
+ * @remarks
3811
+ * Derive this type from the canonical runtime list so compile-time and runtime
3812
+ * classification cannot drift. `gateway.v1.signBurnIntents` is included
3813
+ * because the action system models off-chain signing as a read action: it does
3814
+ * not prepare a chain request.
3815
+ *
3816
+ * @example
3817
+ * ```typescript
3818
+ * import type { ReadActionKey } from '@core/adapter'
3819
+ *
3820
+ * const action: ReadActionKey = 'token.allowance'
3821
+ * ```
3822
+ */
3823
+ type ReadActionKey = (typeof READ_ACTION_KEYS)[number];
3824
+
3789
3825
  /**
3790
3826
  * Defines the capabilities of an adapter, including address handling patterns and supported chains.
3791
3827
  *
@@ -3954,6 +3990,69 @@ declare abstract class Adapter<TAdapterCapabilities extends AdapterCapabilities
3954
3990
  * ```
3955
3991
  */
3956
3992
  prepareAction<TActionKey extends ActionKeys>(action: TActionKey, params: ActionPayload<TActionKey>, ctx: OperationContext<TAdapterCapabilities>): Promise<PreparedChainRequest>;
3993
+ /**
3994
+ * Execute a non-transaction action without routing through transaction preparation.
3995
+ *
3996
+ * @remarks
3997
+ * Use this seam for balance, allowance, contract-state, and other actions
3998
+ * classified as reads. It never calls {@link Adapter.prepareAction}, so
3999
+ * transaction authorization wrappers only observe actions that can produce a
4000
+ * signable chain request.
4001
+ *
4002
+ * @typeParam TActionKey - The read action key.
4003
+ * @param action - The read action to execute.
4004
+ * @param params - The parameters for the read action.
4005
+ * @param ctx - The operation context.
4006
+ * @returns The raw action response.
4007
+ * @throws {KitError} When the key is not a read action or no handler is registered.
4008
+ * @throws Error When the operation context or action handler fails.
4009
+ *
4010
+ * @example
4011
+ * ```typescript
4012
+ * import { Ethereum } from '@core/chains'
4013
+ *
4014
+ * const balance = await adapter.readAction(
4015
+ * 'token.balanceOf',
4016
+ * { tokenAddress, walletAddress },
4017
+ * { chain: Ethereum },
4018
+ * )
4019
+ * ```
4020
+ *
4021
+ * @internal
4022
+ */
4023
+ readAction<TActionKey extends ReadActionKey>(action: TActionKey, params: ActionPayload<TActionKey>, ctx: OperationContext<TAdapterCapabilities>): Promise<unknown>;
4024
+ /**
4025
+ * Read the current token allowance a delegate holds over an owner's tokens.
4026
+ *
4027
+ * @remarks
4028
+ * Perform a network read through {@link Adapter.readAction}. This method
4029
+ * never routes through {@link Adapter.prepareAction}. On chains without an
4030
+ * allowance model, such as Solana, return the maximum uint256 value.
4031
+ *
4032
+ * @param params - The token to query and the delegate whose allowance is being read.
4033
+ * @param ctx - Operation context with compile-time validated address requirements.
4034
+ * @returns A promise resolving to the current allowance in the token's base units.
4035
+ * @throws {KitError} When the adapter does not register a `token.allowance` handler.
4036
+ * @throws Error When the operation context or action handler fails.
4037
+ *
4038
+ * @example
4039
+ * ```typescript
4040
+ * import type { Adapter } from '@core/adapter'
4041
+ * import { Ethereum } from '@core/chains'
4042
+ *
4043
+ * declare const adapter: Adapter
4044
+ *
4045
+ * const allowance = await adapter.getTokenAllowance(
4046
+ * {
4047
+ * tokenAddress: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
4048
+ * delegate: '0x1111111111111111111111111111111111111111',
4049
+ * },
4050
+ * { chain: Ethereum },
4051
+ * )
4052
+ * console.log(allowance) // 1000000n
4053
+ * ```
4054
+ */
4055
+ getTokenAllowance(params: ActionPayload<'token.allowance'>, ctx: OperationContext<TAdapterCapabilities>): Promise<bigint>;
3957
4056
  /**
3958
4057
  * Prepares a transaction for future gas estimation and execution.
3959
4058
  *
package/context.d.mts CHANGED
@@ -2957,6 +2957,18 @@ interface TokenActionMap {
2957
2957
  */
2958
2958
  walletAddress?: string | undefined;
2959
2959
  };
2960
+ /**
2961
+ * Get the on-chain name of the token contract.
2962
+ *
2963
+ * This is a read-only operation. For USDC the value is also the EIP-712
2964
+ * domain name, which permit and authorize signing flows need.
2965
+ */
2966
+ name: ActionParameters & {
2967
+ /**
2968
+ * The contract address of the token.
2969
+ */
2970
+ tokenAddress: string;
2971
+ };
2960
2972
  }
2961
2973
 
2962
2974
  /**
@@ -3786,6 +3798,30 @@ declare class ActionRegistry {
3786
3798
  executeAction<TActionKey extends ActionKeys>(action: TActionKey, params: ActionPayload<TActionKey>, context: ResolvedOperationContext): Promise<PreparedChainRequest>;
3787
3799
  }
3788
3800
 
3801
+ /**
3802
+ * Canonical list of actions that do not prepare or submit transactions.
3803
+ *
3804
+ * @internal
3805
+ */
3806
+ 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"];
3807
+ /**
3808
+ * Action keys that execute without preparing or submitting a transaction.
3809
+ *
3810
+ * @remarks
3811
+ * Derive this type from the canonical runtime list so compile-time and runtime
3812
+ * classification cannot drift. `gateway.v1.signBurnIntents` is included
3813
+ * because the action system models off-chain signing as a read action: it does
3814
+ * not prepare a chain request.
3815
+ *
3816
+ * @example
3817
+ * ```typescript
3818
+ * import type { ReadActionKey } from '@core/adapter'
3819
+ *
3820
+ * const action: ReadActionKey = 'token.allowance'
3821
+ * ```
3822
+ */
3823
+ type ReadActionKey = (typeof READ_ACTION_KEYS)[number];
3824
+
3789
3825
  /**
3790
3826
  * Defines the capabilities of an adapter, including address handling patterns and supported chains.
3791
3827
  *
@@ -3954,6 +3990,69 @@ declare abstract class Adapter<TAdapterCapabilities extends AdapterCapabilities
3954
3990
  * ```
3955
3991
  */
3956
3992
  prepareAction<TActionKey extends ActionKeys>(action: TActionKey, params: ActionPayload<TActionKey>, ctx: OperationContext<TAdapterCapabilities>): Promise<PreparedChainRequest>;
3993
+ /**
3994
+ * Execute a non-transaction action without routing through transaction preparation.
3995
+ *
3996
+ * @remarks
3997
+ * Use this seam for balance, allowance, contract-state, and other actions
3998
+ * classified as reads. It never calls {@link Adapter.prepareAction}, so
3999
+ * transaction authorization wrappers only observe actions that can produce a
4000
+ * signable chain request.
4001
+ *
4002
+ * @typeParam TActionKey - The read action key.
4003
+ * @param action - The read action to execute.
4004
+ * @param params - The parameters for the read action.
4005
+ * @param ctx - The operation context.
4006
+ * @returns The raw action response.
4007
+ * @throws {KitError} When the key is not a read action or no handler is registered.
4008
+ * @throws Error When the operation context or action handler fails.
4009
+ *
4010
+ * @example
4011
+ * ```typescript
4012
+ * import { Ethereum } from '@core/chains'
4013
+ *
4014
+ * const balance = await adapter.readAction(
4015
+ * 'token.balanceOf',
4016
+ * { tokenAddress, walletAddress },
4017
+ * { chain: Ethereum },
4018
+ * )
4019
+ * ```
4020
+ *
4021
+ * @internal
4022
+ */
4023
+ readAction<TActionKey extends ReadActionKey>(action: TActionKey, params: ActionPayload<TActionKey>, ctx: OperationContext<TAdapterCapabilities>): Promise<unknown>;
4024
+ /**
4025
+ * Read the current token allowance a delegate holds over an owner's tokens.
4026
+ *
4027
+ * @remarks
4028
+ * Perform a network read through {@link Adapter.readAction}. This method
4029
+ * never routes through {@link Adapter.prepareAction}. On chains without an
4030
+ * allowance model, such as Solana, return the maximum uint256 value.
4031
+ *
4032
+ * @param params - The token to query and the delegate whose allowance is being read.
4033
+ * @param ctx - Operation context with compile-time validated address requirements.
4034
+ * @returns A promise resolving to the current allowance in the token's base units.
4035
+ * @throws {KitError} When the adapter does not register a `token.allowance` handler.
4036
+ * @throws Error When the operation context or action handler fails.
4037
+ *
4038
+ * @example
4039
+ * ```typescript
4040
+ * import type { Adapter } from '@core/adapter'
4041
+ * import { Ethereum } from '@core/chains'
4042
+ *
4043
+ * declare const adapter: Adapter
4044
+ *
4045
+ * const allowance = await adapter.getTokenAllowance(
4046
+ * {
4047
+ * tokenAddress: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
4048
+ * delegate: '0x1111111111111111111111111111111111111111',
4049
+ * },
4050
+ * { chain: Ethereum },
4051
+ * )
4052
+ * console.log(allowance) // 1000000n
4053
+ * ```
4054
+ */
4055
+ getTokenAllowance(params: ActionPayload<'token.allowance'>, ctx: OperationContext<TAdapterCapabilities>): Promise<bigint>;
3957
4056
  /**
3958
4057
  * Prepares a transaction for future gas estimation and execution.
3959
4058
  *
package/context.d.ts CHANGED
@@ -2957,6 +2957,18 @@ interface TokenActionMap {
2957
2957
  */
2958
2958
  walletAddress?: string | undefined;
2959
2959
  };
2960
+ /**
2961
+ * Get the on-chain name of the token contract.
2962
+ *
2963
+ * This is a read-only operation. For USDC the value is also the EIP-712
2964
+ * domain name, which permit and authorize signing flows need.
2965
+ */
2966
+ name: ActionParameters & {
2967
+ /**
2968
+ * The contract address of the token.
2969
+ */
2970
+ tokenAddress: string;
2971
+ };
2960
2972
  }
2961
2973
 
2962
2974
  /**
@@ -3786,6 +3798,30 @@ declare class ActionRegistry {
3786
3798
  executeAction<TActionKey extends ActionKeys>(action: TActionKey, params: ActionPayload<TActionKey>, context: ResolvedOperationContext): Promise<PreparedChainRequest>;
3787
3799
  }
3788
3800
 
3801
+ /**
3802
+ * Canonical list of actions that do not prepare or submit transactions.
3803
+ *
3804
+ * @internal
3805
+ */
3806
+ 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"];
3807
+ /**
3808
+ * Action keys that execute without preparing or submitting a transaction.
3809
+ *
3810
+ * @remarks
3811
+ * Derive this type from the canonical runtime list so compile-time and runtime
3812
+ * classification cannot drift. `gateway.v1.signBurnIntents` is included
3813
+ * because the action system models off-chain signing as a read action: it does
3814
+ * not prepare a chain request.
3815
+ *
3816
+ * @example
3817
+ * ```typescript
3818
+ * import type { ReadActionKey } from '@core/adapter'
3819
+ *
3820
+ * const action: ReadActionKey = 'token.allowance'
3821
+ * ```
3822
+ */
3823
+ type ReadActionKey = (typeof READ_ACTION_KEYS)[number];
3824
+
3789
3825
  /**
3790
3826
  * Defines the capabilities of an adapter, including address handling patterns and supported chains.
3791
3827
  *
@@ -3954,6 +3990,69 @@ declare abstract class Adapter<TAdapterCapabilities extends AdapterCapabilities
3954
3990
  * ```
3955
3991
  */
3956
3992
  prepareAction<TActionKey extends ActionKeys>(action: TActionKey, params: ActionPayload<TActionKey>, ctx: OperationContext<TAdapterCapabilities>): Promise<PreparedChainRequest>;
3993
+ /**
3994
+ * Execute a non-transaction action without routing through transaction preparation.
3995
+ *
3996
+ * @remarks
3997
+ * Use this seam for balance, allowance, contract-state, and other actions
3998
+ * classified as reads. It never calls {@link Adapter.prepareAction}, so
3999
+ * transaction authorization wrappers only observe actions that can produce a
4000
+ * signable chain request.
4001
+ *
4002
+ * @typeParam TActionKey - The read action key.
4003
+ * @param action - The read action to execute.
4004
+ * @param params - The parameters for the read action.
4005
+ * @param ctx - The operation context.
4006
+ * @returns The raw action response.
4007
+ * @throws {KitError} When the key is not a read action or no handler is registered.
4008
+ * @throws Error When the operation context or action handler fails.
4009
+ *
4010
+ * @example
4011
+ * ```typescript
4012
+ * import { Ethereum } from '@core/chains'
4013
+ *
4014
+ * const balance = await adapter.readAction(
4015
+ * 'token.balanceOf',
4016
+ * { tokenAddress, walletAddress },
4017
+ * { chain: Ethereum },
4018
+ * )
4019
+ * ```
4020
+ *
4021
+ * @internal
4022
+ */
4023
+ readAction<TActionKey extends ReadActionKey>(action: TActionKey, params: ActionPayload<TActionKey>, ctx: OperationContext<TAdapterCapabilities>): Promise<unknown>;
4024
+ /**
4025
+ * Read the current token allowance a delegate holds over an owner's tokens.
4026
+ *
4027
+ * @remarks
4028
+ * Perform a network read through {@link Adapter.readAction}. This method
4029
+ * never routes through {@link Adapter.prepareAction}. On chains without an
4030
+ * allowance model, such as Solana, return the maximum uint256 value.
4031
+ *
4032
+ * @param params - The token to query and the delegate whose allowance is being read.
4033
+ * @param ctx - Operation context with compile-time validated address requirements.
4034
+ * @returns A promise resolving to the current allowance in the token's base units.
4035
+ * @throws {KitError} When the adapter does not register a `token.allowance` handler.
4036
+ * @throws Error When the operation context or action handler fails.
4037
+ *
4038
+ * @example
4039
+ * ```typescript
4040
+ * import type { Adapter } from '@core/adapter'
4041
+ * import { Ethereum } from '@core/chains'
4042
+ *
4043
+ * declare const adapter: Adapter
4044
+ *
4045
+ * const allowance = await adapter.getTokenAllowance(
4046
+ * {
4047
+ * tokenAddress: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
4048
+ * delegate: '0x1111111111111111111111111111111111111111',
4049
+ * },
4050
+ * { chain: Ethereum },
4051
+ * )
4052
+ * console.log(allowance) // 1000000n
4053
+ * ```
4054
+ */
4055
+ getTokenAllowance(params: ActionPayload<'token.allowance'>, ctx: OperationContext<TAdapterCapabilities>): Promise<bigint>;
3957
4056
  /**
3958
4057
  * Prepares a transaction for future gas estimation and execution.
3959
4058
  *
package/earn.cjs CHANGED
@@ -7527,6 +7527,7 @@ const swapTokenEnumSchema = zod.z.enum([
7527
7527
  [Blockchain.Arbitrum_Sepolia]: '0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d',
7528
7528
  [Blockchain.Avalanche_Fuji]: '0x5425890298aed601595a70AB815c96711a31Bc65',
7529
7529
  [Blockchain.Base_Sepolia]: '0x036CbD53842c5426634e7929541eC2318f3dCF7e',
7530
+ [Blockchain.Celo_Alfajores_Testnet]: '0x2F25deB3848C207fc8E0c34035B3Ba7fC157602B',
7530
7531
  [Blockchain.Codex_Testnet]: '0x6d7f141b6819C2c9CC2f818e6ad549E7Ca090F8f',
7531
7532
  [Blockchain.Cronos_Testnet]: '0xEb33dc5fac03833e132593659e1dE7256aB59794',
7532
7533
  [Blockchain.Edge_Testnet]: '0x2d9F7CAD728051AA35Ecdc472a14cf8cDF5CFD6B',
@@ -8748,6 +8749,179 @@ var pkg$3 = {
8748
8749
  }
8749
8750
  });
8750
8751
 
8752
+ /**
8753
+ * Canonical list of actions that do not prepare or submit transactions.
8754
+ *
8755
+ * @internal
8756
+ */ const READ_ACTION_KEYS = [
8757
+ 'token.allowance',
8758
+ 'token.balanceOf',
8759
+ 'token.name',
8760
+ 'native.balanceOf',
8761
+ 'usdc.allowance',
8762
+ 'usdc.balanceOf',
8763
+ 'usdc.name',
8764
+ 'gateway.v1.isDelegate',
8765
+ 'gateway.v1.withdrawingBalance',
8766
+ 'gateway.v1.withdrawalBlock',
8767
+ 'gateway.v1.signBurnIntents'
8768
+ ];
8769
+ const READ_ACTION_KEY_SET = new Set(READ_ACTION_KEYS);
8770
+ /**
8771
+ * Check whether a runtime value identifies a read action.
8772
+ *
8773
+ * @param action - The value to classify.
8774
+ * @returns Whether the value is a registered read-action key.
8775
+ *
8776
+ * @example
8777
+ * ```typescript
8778
+ * import { isReadActionKey } from '@core/adapter'
8779
+ *
8780
+ * if (isReadActionKey(value)) {
8781
+ * await adapter.readAction(value, params, context)
8782
+ * }
8783
+ * ```
8784
+ *
8785
+ * @internal
8786
+ */ function isReadActionKey(action) {
8787
+ return READ_ACTION_KEY_SET.has(action);
8788
+ }
8789
+
8790
+ /**
8791
+ * Create the standard error for a missing or non-read action.
8792
+ *
8793
+ * @param action - The unsupported action value.
8794
+ * @returns A fatal unsupported-action error.
8795
+ *
8796
+ * @internal
8797
+ */ function createUnsupportedReadActionError(action) {
8798
+ return new KitError({
8799
+ ...InputError.UNSUPPORTED_ACTION,
8800
+ recoverability: 'FATAL',
8801
+ message: `Read action "${String(action)}" is not registered in this adapter.`
8802
+ });
8803
+ }
8804
+ /**
8805
+ * Execute a read through the adapter's dedicated read seam when available.
8806
+ *
8807
+ * @remarks
8808
+ * Fall back to the legacy `prepareAction().execute()` contract so providers
8809
+ * remain runtime-compatible with adapter versions released before `readAction`.
8810
+ * Consumers must upgrade their adapter package for reads to bypass custom
8811
+ * `prepareAction` wrappers.
8812
+ *
8813
+ * @typeParam TAdapterCapabilities - The adapter capabilities type.
8814
+ * @typeParam TActionKey - The read action key.
8815
+ * @param adapter - The adapter that owns the read action.
8816
+ * @param action - The read action to execute.
8817
+ * @param params - The parameters for the read action.
8818
+ * @param ctx - The operation context.
8819
+ * @returns The raw read-action result.
8820
+ * @throws {KitError} When `action` is not a supported read-action key.
8821
+ *
8822
+ * @example
8823
+ * ```typescript
8824
+ * import { executeAdapterReadAction } from '@core/adapter'
8825
+ * import { Ethereum } from '@core/chains'
8826
+ *
8827
+ * const allowance = await executeAdapterReadAction(
8828
+ * adapter,
8829
+ * 'token.allowance',
8830
+ * { tokenAddress, delegate },
8831
+ * { chain: Ethereum },
8832
+ * )
8833
+ * ```
8834
+ *
8835
+ * @internal
8836
+ */ async function executeAdapterReadAction(adapter, action, params, ctx) {
8837
+ if (!isReadActionKey(action)) {
8838
+ throw createUnsupportedReadActionError(action);
8839
+ }
8840
+ const runtimeAdapter = adapter;
8841
+ if (typeof runtimeAdapter.readAction === 'function') {
8842
+ return runtimeAdapter.readAction(action, params, ctx);
8843
+ }
8844
+ let request;
8845
+ try {
8846
+ request = await adapter.prepareAction(action, params, ctx);
8847
+ } catch (error) {
8848
+ if (error instanceof Error && error.message === `Action ${action} is not supported`) {
8849
+ throw createUnsupportedReadActionError(action);
8850
+ }
8851
+ throw error;
8852
+ }
8853
+ return request.execute();
8854
+ }
8855
+ /**
8856
+ * Read and parse a token allowance while supporting older adapter versions.
8857
+ *
8858
+ * @remarks
8859
+ * Prefer the adapter's dedicated read seam and fall back to the legacy
8860
+ * `prepareAction().execute()` contract when the runtime adapter predates it.
8861
+ *
8862
+ * @typeParam TAdapterCapabilities - The adapter capabilities type.
8863
+ * @param adapter - The adapter that owns the allowance action.
8864
+ * @param params - The token and delegate whose allowance is being read.
8865
+ * @param ctx - The operation context.
8866
+ * @returns The non-negative allowance in token base units.
8867
+ * @throws {KitError} When the action is unsupported or its response is malformed.
8868
+ *
8869
+ * @example
8870
+ * ```typescript
8871
+ * import { readTokenAllowance } from '@core/adapter'
8872
+ * import { Ethereum } from '@core/chains'
8873
+ *
8874
+ * const allowance = await readTokenAllowance(
8875
+ * adapter,
8876
+ * { tokenAddress, delegate },
8877
+ * { chain: Ethereum },
8878
+ * )
8879
+ * ```
8880
+ *
8881
+ * @internal
8882
+ */ async function readTokenAllowance(adapter, params, ctx) {
8883
+ return parseAllowanceResponse(await executeAdapterReadAction(adapter, 'token.allowance', params, ctx));
8884
+ }
8885
+ /**
8886
+ * Parse a raw token allowance response into base units.
8887
+ *
8888
+ * @param allowanceRaw - The adapter response, optionally wrapped as an Amount output.
8889
+ * @returns The non-negative allowance as a bigint, or zero for a missing value.
8890
+ * @throws {KitError} When the response cannot represent a non-negative bigint.
8891
+ *
8892
+ * @example
8893
+ * ```typescript
8894
+ * import { parseAllowanceResponse } from '@core/adapter'
8895
+ *
8896
+ * const allowance = parseAllowanceResponse({ amount: { raw: 1000000n } })
8897
+ * ```
8898
+ */ function parseAllowanceResponse(allowanceRaw) {
8899
+ let value = allowanceRaw;
8900
+ if (typeof value === 'object' && value !== null && 'amount' in value) {
8901
+ const amount = value.amount;
8902
+ if (typeof amount === 'object' && amount !== null && 'raw' in amount) {
8903
+ value = amount.raw;
8904
+ }
8905
+ }
8906
+ if (value === undefined || value === null) {
8907
+ return 0n;
8908
+ }
8909
+ let allowance;
8910
+ if (typeof value === 'bigint') {
8911
+ allowance = value;
8912
+ } else if (typeof value === 'string') {
8913
+ try {
8914
+ allowance = BigInt(value);
8915
+ } catch {
8916
+ allowance = undefined;
8917
+ }
8918
+ }
8919
+ if (allowance === undefined || allowance < 0n) {
8920
+ throw createValidationFailedError('token.allowance', value, 'token.allowance response must be a non-negative bigint-compatible string or bigint');
8921
+ }
8922
+ return allowance;
8923
+ }
8924
+
8751
8925
  /**
8752
8926
  * Schema for validating hexadecimal strings with '0x' prefix.
8753
8927
  *
@@ -9571,7 +9745,7 @@ var TransferSpeed;
9571
9745
  registerKit(`${pkg$3.name}/${pkg$3.version}`);
9572
9746
 
9573
9747
  var name$2 = "@circle-fin/swap-kit";
9574
- var version$2 = "1.5.1";
9748
+ var version$2 = "1.5.2";
9575
9749
  var pkg$2 = {
9576
9750
  name: name$2,
9577
9751
  version: version$2};
@@ -13185,7 +13359,7 @@ new Set(Object.values(Blockchain));
13185
13359
  registerKit(`${pkg$2.name}/${pkg$2.version}`);
13186
13360
 
13187
13361
  var name$1 = "@circle-fin/earn-kit";
13188
- var version$1 = "1.5.0";
13362
+ var version$1 = "1.5.1";
13189
13363
  var pkg$1 = {
13190
13364
  name: name$1,
13191
13365
  version: version$1};
@@ -13432,30 +13606,6 @@ function toSdkChain(chain) {
13432
13606
  return assertHexAddress('chain.kitContracts.adapter', adapterContractAddress, `Adapter contract for chain ${chain.name} must be a 0x-prefixed 20-byte hex address.`);
13433
13607
  }
13434
13608
 
13435
- /**
13436
- * Parse the raw `token.allowance` adapter response into a bigint.
13437
- *
13438
- * @internal
13439
- */ function parseAllowanceResponse(allowanceRaw) {
13440
- if (allowanceRaw === undefined || allowanceRaw === null) {
13441
- return 0n;
13442
- }
13443
- let allowance;
13444
- if (typeof allowanceRaw === 'bigint') {
13445
- allowance = allowanceRaw;
13446
- } else if (typeof allowanceRaw === 'string') {
13447
- try {
13448
- allowance = BigInt(allowanceRaw);
13449
- } catch {
13450
- allowance = undefined;
13451
- }
13452
- }
13453
- if (allowance === undefined || allowance < 0n) {
13454
- throw createValidationFailedError('token.allowance', allowanceRaw, 'token.allowance response must be a non-negative bigint-compatible string or bigint');
13455
- }
13456
- return allowance;
13457
- }
13458
-
13459
13609
  /**
13460
13610
  * Safety multiplier applied to locally estimated gas for earn transactions.
13461
13611
  *
@@ -13677,17 +13827,15 @@ const GAS_SAFETY_MULTIPLIER_DENOMINATOR = 10n;
13677
13827
  if (requiredAllowance <= 0n) {
13678
13828
  return undefined;
13679
13829
  }
13680
- const allowancePrepared = await adapter.prepareAction('token.allowance', {
13681
- tokenAddress,
13682
- delegate
13683
- }, {
13684
- chain,
13685
- address
13686
- });
13687
- // Each execute() is a fresh allowance read at `latest`, so the same prepared
13688
- // action serves both the pre-approval decision read and the post-approval
13689
- // propagation polls.
13690
- const readAllowance = async ()=>parseAllowanceResponse(await allowancePrepared.execute());
13830
+ // Each call is a fresh allowance read at `latest`, so the same function serves
13831
+ // both the pre-approval decision and post-approval propagation polls.
13832
+ const readAllowance = async ()=>readTokenAllowance(adapter, {
13833
+ tokenAddress,
13834
+ delegate
13835
+ }, {
13836
+ chain,
13837
+ address
13838
+ });
13691
13839
  const currentAllowance = await readAllowance();
13692
13840
  if (currentAllowance >= requiredAllowance) {
13693
13841
  return undefined;
@@ -14732,14 +14880,13 @@ function throwBatchFailure(result, executeReceipt, chain, actionKey, revertMessa
14732
14880
  // approveAllowanceIfNeeded guard and avoids an increaseAllowance underflow
14733
14881
  // (requiredAllowance - currentAllowance would be negative, which reverts as
14734
14882
  // an out-of-range uint256).
14735
- const allowancePrepared = await adapter.prepareAction('token.allowance', {
14883
+ const currentAllowance = await readTokenAllowance(adapter, {
14736
14884
  tokenAddress: approvalToken,
14737
14885
  delegate
14738
14886
  }, {
14739
14887
  chain,
14740
14888
  address
14741
14889
  });
14742
- const currentAllowance = parseAllowanceResponse(await allowancePrepared.execute());
14743
14890
  const approvalNeeded = currentAllowance < requiredAllowance;
14744
14891
  const executePrepared = await adapter.prepareAction(actionKey, {
14745
14892
  executeParams,
@@ -16116,7 +16263,7 @@ const bridgeDepositPrepareReviewSchema = zod.z.object({
16116
16263
  }
16117
16264
 
16118
16265
  var name = "@circle-fin/provider-earn-service";
16119
- var version = "1.4.0";
16266
+ var version = "1.4.1";
16120
16267
  var pkg = {
16121
16268
  name: name,
16122
16269
  version: version};