@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/earn.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/earn.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/earn.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.mjs CHANGED
@@ -7525,6 +7525,7 @@ const swapTokenEnumSchema = z.enum([
7525
7525
  [Blockchain.Arbitrum_Sepolia]: '0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d',
7526
7526
  [Blockchain.Avalanche_Fuji]: '0x5425890298aed601595a70AB815c96711a31Bc65',
7527
7527
  [Blockchain.Base_Sepolia]: '0x036CbD53842c5426634e7929541eC2318f3dCF7e',
7528
+ [Blockchain.Celo_Alfajores_Testnet]: '0x2F25deB3848C207fc8E0c34035B3Ba7fC157602B',
7528
7529
  [Blockchain.Codex_Testnet]: '0x6d7f141b6819C2c9CC2f818e6ad549E7Ca090F8f',
7529
7530
  [Blockchain.Cronos_Testnet]: '0xEb33dc5fac03833e132593659e1dE7256aB59794',
7530
7531
  [Blockchain.Edge_Testnet]: '0x2d9F7CAD728051AA35Ecdc472a14cf8cDF5CFD6B',
@@ -8746,6 +8747,179 @@ var pkg$3 = {
8746
8747
  }
8747
8748
  });
8748
8749
 
8750
+ /**
8751
+ * Canonical list of actions that do not prepare or submit transactions.
8752
+ *
8753
+ * @internal
8754
+ */ const READ_ACTION_KEYS = [
8755
+ 'token.allowance',
8756
+ 'token.balanceOf',
8757
+ 'token.name',
8758
+ 'native.balanceOf',
8759
+ 'usdc.allowance',
8760
+ 'usdc.balanceOf',
8761
+ 'usdc.name',
8762
+ 'gateway.v1.isDelegate',
8763
+ 'gateway.v1.withdrawingBalance',
8764
+ 'gateway.v1.withdrawalBlock',
8765
+ 'gateway.v1.signBurnIntents'
8766
+ ];
8767
+ const READ_ACTION_KEY_SET = new Set(READ_ACTION_KEYS);
8768
+ /**
8769
+ * Check whether a runtime value identifies a read action.
8770
+ *
8771
+ * @param action - The value to classify.
8772
+ * @returns Whether the value is a registered read-action key.
8773
+ *
8774
+ * @example
8775
+ * ```typescript
8776
+ * import { isReadActionKey } from '@core/adapter'
8777
+ *
8778
+ * if (isReadActionKey(value)) {
8779
+ * await adapter.readAction(value, params, context)
8780
+ * }
8781
+ * ```
8782
+ *
8783
+ * @internal
8784
+ */ function isReadActionKey(action) {
8785
+ return READ_ACTION_KEY_SET.has(action);
8786
+ }
8787
+
8788
+ /**
8789
+ * Create the standard error for a missing or non-read action.
8790
+ *
8791
+ * @param action - The unsupported action value.
8792
+ * @returns A fatal unsupported-action error.
8793
+ *
8794
+ * @internal
8795
+ */ function createUnsupportedReadActionError(action) {
8796
+ return new KitError({
8797
+ ...InputError.UNSUPPORTED_ACTION,
8798
+ recoverability: 'FATAL',
8799
+ message: `Read action "${String(action)}" is not registered in this adapter.`
8800
+ });
8801
+ }
8802
+ /**
8803
+ * Execute a read through the adapter's dedicated read seam when available.
8804
+ *
8805
+ * @remarks
8806
+ * Fall back to the legacy `prepareAction().execute()` contract so providers
8807
+ * remain runtime-compatible with adapter versions released before `readAction`.
8808
+ * Consumers must upgrade their adapter package for reads to bypass custom
8809
+ * `prepareAction` wrappers.
8810
+ *
8811
+ * @typeParam TAdapterCapabilities - The adapter capabilities type.
8812
+ * @typeParam TActionKey - The read action key.
8813
+ * @param adapter - The adapter that owns the read action.
8814
+ * @param action - The read action to execute.
8815
+ * @param params - The parameters for the read action.
8816
+ * @param ctx - The operation context.
8817
+ * @returns The raw read-action result.
8818
+ * @throws {KitError} When `action` is not a supported read-action key.
8819
+ *
8820
+ * @example
8821
+ * ```typescript
8822
+ * import { executeAdapterReadAction } from '@core/adapter'
8823
+ * import { Ethereum } from '@core/chains'
8824
+ *
8825
+ * const allowance = await executeAdapterReadAction(
8826
+ * adapter,
8827
+ * 'token.allowance',
8828
+ * { tokenAddress, delegate },
8829
+ * { chain: Ethereum },
8830
+ * )
8831
+ * ```
8832
+ *
8833
+ * @internal
8834
+ */ async function executeAdapterReadAction(adapter, action, params, ctx) {
8835
+ if (!isReadActionKey(action)) {
8836
+ throw createUnsupportedReadActionError(action);
8837
+ }
8838
+ const runtimeAdapter = adapter;
8839
+ if (typeof runtimeAdapter.readAction === 'function') {
8840
+ return runtimeAdapter.readAction(action, params, ctx);
8841
+ }
8842
+ let request;
8843
+ try {
8844
+ request = await adapter.prepareAction(action, params, ctx);
8845
+ } catch (error) {
8846
+ if (error instanceof Error && error.message === `Action ${action} is not supported`) {
8847
+ throw createUnsupportedReadActionError(action);
8848
+ }
8849
+ throw error;
8850
+ }
8851
+ return request.execute();
8852
+ }
8853
+ /**
8854
+ * Read and parse a token allowance while supporting older adapter versions.
8855
+ *
8856
+ * @remarks
8857
+ * Prefer the adapter's dedicated read seam and fall back to the legacy
8858
+ * `prepareAction().execute()` contract when the runtime adapter predates it.
8859
+ *
8860
+ * @typeParam TAdapterCapabilities - The adapter capabilities type.
8861
+ * @param adapter - The adapter that owns the allowance action.
8862
+ * @param params - The token and delegate whose allowance is being read.
8863
+ * @param ctx - The operation context.
8864
+ * @returns The non-negative allowance in token base units.
8865
+ * @throws {KitError} When the action is unsupported or its response is malformed.
8866
+ *
8867
+ * @example
8868
+ * ```typescript
8869
+ * import { readTokenAllowance } from '@core/adapter'
8870
+ * import { Ethereum } from '@core/chains'
8871
+ *
8872
+ * const allowance = await readTokenAllowance(
8873
+ * adapter,
8874
+ * { tokenAddress, delegate },
8875
+ * { chain: Ethereum },
8876
+ * )
8877
+ * ```
8878
+ *
8879
+ * @internal
8880
+ */ async function readTokenAllowance(adapter, params, ctx) {
8881
+ return parseAllowanceResponse(await executeAdapterReadAction(adapter, 'token.allowance', params, ctx));
8882
+ }
8883
+ /**
8884
+ * Parse a raw token allowance response into base units.
8885
+ *
8886
+ * @param allowanceRaw - The adapter response, optionally wrapped as an Amount output.
8887
+ * @returns The non-negative allowance as a bigint, or zero for a missing value.
8888
+ * @throws {KitError} When the response cannot represent a non-negative bigint.
8889
+ *
8890
+ * @example
8891
+ * ```typescript
8892
+ * import { parseAllowanceResponse } from '@core/adapter'
8893
+ *
8894
+ * const allowance = parseAllowanceResponse({ amount: { raw: 1000000n } })
8895
+ * ```
8896
+ */ function parseAllowanceResponse(allowanceRaw) {
8897
+ let value = allowanceRaw;
8898
+ if (typeof value === 'object' && value !== null && 'amount' in value) {
8899
+ const amount = value.amount;
8900
+ if (typeof amount === 'object' && amount !== null && 'raw' in amount) {
8901
+ value = amount.raw;
8902
+ }
8903
+ }
8904
+ if (value === undefined || value === null) {
8905
+ return 0n;
8906
+ }
8907
+ let allowance;
8908
+ if (typeof value === 'bigint') {
8909
+ allowance = value;
8910
+ } else if (typeof value === 'string') {
8911
+ try {
8912
+ allowance = BigInt(value);
8913
+ } catch {
8914
+ allowance = undefined;
8915
+ }
8916
+ }
8917
+ if (allowance === undefined || allowance < 0n) {
8918
+ throw createValidationFailedError('token.allowance', value, 'token.allowance response must be a non-negative bigint-compatible string or bigint');
8919
+ }
8920
+ return allowance;
8921
+ }
8922
+
8749
8923
  /**
8750
8924
  * Schema for validating hexadecimal strings with '0x' prefix.
8751
8925
  *
@@ -9569,7 +9743,7 @@ var TransferSpeed;
9569
9743
  registerKit(`${pkg$3.name}/${pkg$3.version}`);
9570
9744
 
9571
9745
  var name$2 = "@circle-fin/swap-kit";
9572
- var version$2 = "1.5.1";
9746
+ var version$2 = "1.5.2";
9573
9747
  var pkg$2 = {
9574
9748
  name: name$2,
9575
9749
  version: version$2};
@@ -13183,7 +13357,7 @@ new Set(Object.values(Blockchain));
13183
13357
  registerKit(`${pkg$2.name}/${pkg$2.version}`);
13184
13358
 
13185
13359
  var name$1 = "@circle-fin/earn-kit";
13186
- var version$1 = "1.5.0";
13360
+ var version$1 = "1.5.1";
13187
13361
  var pkg$1 = {
13188
13362
  name: name$1,
13189
13363
  version: version$1};
@@ -13430,30 +13604,6 @@ function toSdkChain(chain) {
13430
13604
  return assertHexAddress('chain.kitContracts.adapter', adapterContractAddress, `Adapter contract for chain ${chain.name} must be a 0x-prefixed 20-byte hex address.`);
13431
13605
  }
13432
13606
 
13433
- /**
13434
- * Parse the raw `token.allowance` adapter response into a bigint.
13435
- *
13436
- * @internal
13437
- */ function parseAllowanceResponse(allowanceRaw) {
13438
- if (allowanceRaw === undefined || allowanceRaw === null) {
13439
- return 0n;
13440
- }
13441
- let allowance;
13442
- if (typeof allowanceRaw === 'bigint') {
13443
- allowance = allowanceRaw;
13444
- } else if (typeof allowanceRaw === 'string') {
13445
- try {
13446
- allowance = BigInt(allowanceRaw);
13447
- } catch {
13448
- allowance = undefined;
13449
- }
13450
- }
13451
- if (allowance === undefined || allowance < 0n) {
13452
- throw createValidationFailedError('token.allowance', allowanceRaw, 'token.allowance response must be a non-negative bigint-compatible string or bigint');
13453
- }
13454
- return allowance;
13455
- }
13456
-
13457
13607
  /**
13458
13608
  * Safety multiplier applied to locally estimated gas for earn transactions.
13459
13609
  *
@@ -13675,17 +13825,15 @@ const GAS_SAFETY_MULTIPLIER_DENOMINATOR = 10n;
13675
13825
  if (requiredAllowance <= 0n) {
13676
13826
  return undefined;
13677
13827
  }
13678
- const allowancePrepared = await adapter.prepareAction('token.allowance', {
13679
- tokenAddress,
13680
- delegate
13681
- }, {
13682
- chain,
13683
- address
13684
- });
13685
- // Each execute() is a fresh allowance read at `latest`, so the same prepared
13686
- // action serves both the pre-approval decision read and the post-approval
13687
- // propagation polls.
13688
- const readAllowance = async ()=>parseAllowanceResponse(await allowancePrepared.execute());
13828
+ // Each call is a fresh allowance read at `latest`, so the same function serves
13829
+ // both the pre-approval decision and post-approval propagation polls.
13830
+ const readAllowance = async ()=>readTokenAllowance(adapter, {
13831
+ tokenAddress,
13832
+ delegate
13833
+ }, {
13834
+ chain,
13835
+ address
13836
+ });
13689
13837
  const currentAllowance = await readAllowance();
13690
13838
  if (currentAllowance >= requiredAllowance) {
13691
13839
  return undefined;
@@ -14730,14 +14878,13 @@ function throwBatchFailure(result, executeReceipt, chain, actionKey, revertMessa
14730
14878
  // approveAllowanceIfNeeded guard and avoids an increaseAllowance underflow
14731
14879
  // (requiredAllowance - currentAllowance would be negative, which reverts as
14732
14880
  // an out-of-range uint256).
14733
- const allowancePrepared = await adapter.prepareAction('token.allowance', {
14881
+ const currentAllowance = await readTokenAllowance(adapter, {
14734
14882
  tokenAddress: approvalToken,
14735
14883
  delegate
14736
14884
  }, {
14737
14885
  chain,
14738
14886
  address
14739
14887
  });
14740
- const currentAllowance = parseAllowanceResponse(await allowancePrepared.execute());
14741
14888
  const approvalNeeded = currentAllowance < requiredAllowance;
14742
14889
  const executePrepared = await adapter.prepareAction(actionKey, {
14743
14890
  executeParams,
@@ -16114,7 +16261,7 @@ const bridgeDepositPrepareReviewSchema = z.object({
16114
16261
  }
16115
16262
 
16116
16263
  var name = "@circle-fin/provider-earn-service";
16117
- var version = "1.4.0";
16264
+ var version = "1.4.1";
16118
16265
  var pkg = {
16119
16266
  name: name,
16120
16267
  version: version};