@circle-fin/app-kit 1.11.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/CHANGELOG.md +53 -0
- package/README.md +56 -25
- package/bridge.cjs +1696 -1348
- package/bridge.d.cts +979 -2
- package/bridge.d.mts +979 -2
- package/bridge.d.ts +979 -2
- package/bridge.mjs +1696 -1348
- package/chains.cjs +106 -1
- package/chains.d.cts +96 -2
- package/chains.d.mts +96 -2
- package/chains.d.ts +96 -2
- package/chains.mjs +105 -2
- package/context.d.cts +978 -1
- package/context.d.mts +978 -1
- package/context.d.ts +978 -1
- package/earn.cjs +1728 -65
- package/earn.d.cts +978 -1
- package/earn.d.mts +978 -1
- package/earn.d.ts +978 -1
- package/earn.mjs +1728 -65
- package/estimateBridge.cjs +1695 -1347
- package/estimateBridge.d.cts +978 -1
- package/estimateBridge.d.mts +978 -1
- package/estimateBridge.d.ts +978 -1
- package/estimateBridge.mjs +1695 -1347
- package/estimateSwap.cjs +312 -17
- package/estimateSwap.d.cts +977 -1
- package/estimateSwap.d.mts +977 -1
- package/estimateSwap.d.ts +977 -1
- package/estimateSwap.mjs +312 -17
- package/index.cjs +3608 -1603
- package/index.d.cts +4181 -3426
- package/index.d.mts +4181 -3426
- package/index.d.ts +4181 -3426
- package/index.mjs +3607 -1604
- package/package.json +6 -6
- package/swap.cjs +312 -17
- package/swap.d.cts +977 -1
- package/swap.d.mts +977 -1
- package/swap.d.ts +977 -1
- package/swap.mjs +312 -17
- package/unifiedBalance.cjs +436 -122
- package/unifiedBalance.d.cts +132 -31
- package/unifiedBalance.d.mts +132 -31
- package/unifiedBalance.d.ts +132 -31
- package/unifiedBalance.mjs +436 -122
package/unifiedBalance.d.cts
CHANGED
|
@@ -739,6 +739,8 @@ declare enum Blockchain {
|
|
|
739
739
|
World_Chain_Sepolia = "World_Chain_Sepolia",
|
|
740
740
|
XDC = "XDC",
|
|
741
741
|
XDC_Apothem = "XDC_Apothem",
|
|
742
|
+
X_Layer = "X_Layer",
|
|
743
|
+
X_Layer_Testnet = "X_Layer_Testnet",
|
|
742
744
|
ZKSync_Era = "ZKSync_Era",
|
|
743
745
|
ZKSync_Sepolia = "ZKSync_Sepolia"
|
|
744
746
|
}
|
|
@@ -2602,6 +2604,18 @@ interface TokenActionMap {
|
|
|
2602
2604
|
*/
|
|
2603
2605
|
walletAddress?: string | undefined;
|
|
2604
2606
|
};
|
|
2607
|
+
/**
|
|
2608
|
+
* Get the on-chain name of the token contract.
|
|
2609
|
+
*
|
|
2610
|
+
* This is a read-only operation. For USDC the value is also the EIP-712
|
|
2611
|
+
* domain name, which permit and authorize signing flows need.
|
|
2612
|
+
*/
|
|
2613
|
+
name: ActionParameters & {
|
|
2614
|
+
/**
|
|
2615
|
+
* The contract address of the token.
|
|
2616
|
+
*/
|
|
2617
|
+
tokenAddress: string;
|
|
2618
|
+
};
|
|
2605
2619
|
}
|
|
2606
2620
|
|
|
2607
2621
|
/**
|
|
@@ -3431,6 +3445,30 @@ declare class ActionRegistry {
|
|
|
3431
3445
|
executeAction<TActionKey extends ActionKeys>(action: TActionKey, params: ActionPayload<TActionKey>, context: ResolvedOperationContext): Promise<PreparedChainRequest>;
|
|
3432
3446
|
}
|
|
3433
3447
|
|
|
3448
|
+
/**
|
|
3449
|
+
* Canonical list of actions that do not prepare or submit transactions.
|
|
3450
|
+
*
|
|
3451
|
+
* @internal
|
|
3452
|
+
*/
|
|
3453
|
+
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"];
|
|
3454
|
+
/**
|
|
3455
|
+
* Action keys that execute without preparing or submitting a transaction.
|
|
3456
|
+
*
|
|
3457
|
+
* @remarks
|
|
3458
|
+
* Derive this type from the canonical runtime list so compile-time and runtime
|
|
3459
|
+
* classification cannot drift. `gateway.v1.signBurnIntents` is included
|
|
3460
|
+
* because the action system models off-chain signing as a read action: it does
|
|
3461
|
+
* not prepare a chain request.
|
|
3462
|
+
*
|
|
3463
|
+
* @example
|
|
3464
|
+
* ```typescript
|
|
3465
|
+
* import type { ReadActionKey } from '@core/adapter'
|
|
3466
|
+
*
|
|
3467
|
+
* const action: ReadActionKey = 'token.allowance'
|
|
3468
|
+
* ```
|
|
3469
|
+
*/
|
|
3470
|
+
type ReadActionKey = (typeof READ_ACTION_KEYS)[number];
|
|
3471
|
+
|
|
3434
3472
|
/**
|
|
3435
3473
|
* Defines the capabilities of an adapter, including address handling patterns and supported chains.
|
|
3436
3474
|
*
|
|
@@ -3599,6 +3637,69 @@ declare abstract class Adapter<TAdapterCapabilities extends AdapterCapabilities
|
|
|
3599
3637
|
* ```
|
|
3600
3638
|
*/
|
|
3601
3639
|
prepareAction<TActionKey extends ActionKeys>(action: TActionKey, params: ActionPayload<TActionKey>, ctx: OperationContext<TAdapterCapabilities>): Promise<PreparedChainRequest>;
|
|
3640
|
+
/**
|
|
3641
|
+
* Execute a non-transaction action without routing through transaction preparation.
|
|
3642
|
+
*
|
|
3643
|
+
* @remarks
|
|
3644
|
+
* Use this seam for balance, allowance, contract-state, and other actions
|
|
3645
|
+
* classified as reads. It never calls {@link Adapter.prepareAction}, so
|
|
3646
|
+
* transaction authorization wrappers only observe actions that can produce a
|
|
3647
|
+
* signable chain request.
|
|
3648
|
+
*
|
|
3649
|
+
* @typeParam TActionKey - The read action key.
|
|
3650
|
+
* @param action - The read action to execute.
|
|
3651
|
+
* @param params - The parameters for the read action.
|
|
3652
|
+
* @param ctx - The operation context.
|
|
3653
|
+
* @returns The raw action response.
|
|
3654
|
+
* @throws {KitError} When the key is not a read action or no handler is registered.
|
|
3655
|
+
* @throws Error When the operation context or action handler fails.
|
|
3656
|
+
*
|
|
3657
|
+
* @example
|
|
3658
|
+
* ```typescript
|
|
3659
|
+
* import { Ethereum } from '@core/chains'
|
|
3660
|
+
*
|
|
3661
|
+
* const balance = await adapter.readAction(
|
|
3662
|
+
* 'token.balanceOf',
|
|
3663
|
+
* { tokenAddress, walletAddress },
|
|
3664
|
+
* { chain: Ethereum },
|
|
3665
|
+
* )
|
|
3666
|
+
* ```
|
|
3667
|
+
*
|
|
3668
|
+
* @internal
|
|
3669
|
+
*/
|
|
3670
|
+
readAction<TActionKey extends ReadActionKey>(action: TActionKey, params: ActionPayload<TActionKey>, ctx: OperationContext<TAdapterCapabilities>): Promise<unknown>;
|
|
3671
|
+
/**
|
|
3672
|
+
* Read the current token allowance a delegate holds over an owner's tokens.
|
|
3673
|
+
*
|
|
3674
|
+
* @remarks
|
|
3675
|
+
* Perform a network read through {@link Adapter.readAction}. This method
|
|
3676
|
+
* never routes through {@link Adapter.prepareAction}. On chains without an
|
|
3677
|
+
* allowance model, such as Solana, return the maximum uint256 value.
|
|
3678
|
+
*
|
|
3679
|
+
* @param params - The token to query and the delegate whose allowance is being read.
|
|
3680
|
+
* @param ctx - Operation context with compile-time validated address requirements.
|
|
3681
|
+
* @returns A promise resolving to the current allowance in the token's base units.
|
|
3682
|
+
* @throws {KitError} When the adapter does not register a `token.allowance` handler.
|
|
3683
|
+
* @throws Error When the operation context or action handler fails.
|
|
3684
|
+
*
|
|
3685
|
+
* @example
|
|
3686
|
+
* ```typescript
|
|
3687
|
+
* import type { Adapter } from '@core/adapter'
|
|
3688
|
+
* import { Ethereum } from '@core/chains'
|
|
3689
|
+
*
|
|
3690
|
+
* declare const adapter: Adapter
|
|
3691
|
+
*
|
|
3692
|
+
* const allowance = await adapter.getTokenAllowance(
|
|
3693
|
+
* {
|
|
3694
|
+
* tokenAddress: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
|
3695
|
+
* delegate: '0x1111111111111111111111111111111111111111',
|
|
3696
|
+
* },
|
|
3697
|
+
* { chain: Ethereum },
|
|
3698
|
+
* )
|
|
3699
|
+
* console.log(allowance) // 1000000n
|
|
3700
|
+
* ```
|
|
3701
|
+
*/
|
|
3702
|
+
getTokenAllowance(params: ActionPayload<'token.allowance'>, ctx: OperationContext<TAdapterCapabilities>): Promise<bigint>;
|
|
3602
3703
|
/**
|
|
3603
3704
|
* Prepares a transaction for future gas estimation and execution.
|
|
3604
3705
|
*
|
|
@@ -3785,6 +3886,37 @@ declare abstract class Adapter<TAdapterCapabilities extends AdapterCapabilities
|
|
|
3785
3886
|
abstract getTokenDecimals(tokenAddress: string, chain: ChainDefinition): Promise<number>;
|
|
3786
3887
|
}
|
|
3787
3888
|
|
|
3889
|
+
/**
|
|
3890
|
+
* Simplified error information structure for logging and events.
|
|
3891
|
+
*
|
|
3892
|
+
* @remarks
|
|
3893
|
+
* This lightweight type is used for error reporting in events, logs, and
|
|
3894
|
+
* observability systems. It provides essential error context without the
|
|
3895
|
+
* full ErrorDetails structure. Used across retry mechanisms, adapters,
|
|
3896
|
+
* and other subsystems that need to record error information.
|
|
3897
|
+
*
|
|
3898
|
+
* @example
|
|
3899
|
+
* ```typescript
|
|
3900
|
+
* import { ErrorInfo } from '@core/errors'
|
|
3901
|
+
*
|
|
3902
|
+
* const info: ErrorInfo = {
|
|
3903
|
+
* name: 'NETWORK_TIMEOUT',
|
|
3904
|
+
* message: 'Request timed out after 5000ms',
|
|
3905
|
+
* code: 3002
|
|
3906
|
+
* }
|
|
3907
|
+
* ```
|
|
3908
|
+
*/
|
|
3909
|
+
interface ErrorInfo {
|
|
3910
|
+
/** Error name (e.g., 'TypeError', 'KitError', 'NETWORK_TIMEOUT'). */
|
|
3911
|
+
name: string;
|
|
3912
|
+
/** Error message describing what went wrong. */
|
|
3913
|
+
message: string;
|
|
3914
|
+
/** Optional error code if the error has one (e.g., KitError codes). */
|
|
3915
|
+
code?: number;
|
|
3916
|
+
/** Error category (e.g., INPUT, RPC, ONCHAIN, BALANCE, NETWORK, UNKNOWN). Only set for KitError instances. */
|
|
3917
|
+
type?: string;
|
|
3918
|
+
}
|
|
3919
|
+
|
|
3788
3920
|
/**
|
|
3789
3921
|
* A type-safe event emitter for managing action-based event subscriptions.
|
|
3790
3922
|
*
|
|
@@ -4025,37 +4157,6 @@ declare module './types' {
|
|
|
4025
4157
|
}
|
|
4026
4158
|
}
|
|
4027
4159
|
|
|
4028
|
-
/**
|
|
4029
|
-
* Simplified error information structure for logging and events.
|
|
4030
|
-
*
|
|
4031
|
-
* @remarks
|
|
4032
|
-
* This lightweight type is used for error reporting in events, logs, and
|
|
4033
|
-
* observability systems. It provides essential error context without the
|
|
4034
|
-
* full ErrorDetails structure. Used across retry mechanisms, adapters,
|
|
4035
|
-
* and other subsystems that need to record error information.
|
|
4036
|
-
*
|
|
4037
|
-
* @example
|
|
4038
|
-
* ```typescript
|
|
4039
|
-
* import { ErrorInfo } from '@core/errors'
|
|
4040
|
-
*
|
|
4041
|
-
* const info: ErrorInfo = {
|
|
4042
|
-
* name: 'NETWORK_TIMEOUT',
|
|
4043
|
-
* message: 'Request timed out after 5000ms',
|
|
4044
|
-
* code: 3002
|
|
4045
|
-
* }
|
|
4046
|
-
* ```
|
|
4047
|
-
*/
|
|
4048
|
-
interface ErrorInfo {
|
|
4049
|
-
/** Error name (e.g., 'TypeError', 'KitError', 'NETWORK_TIMEOUT'). */
|
|
4050
|
-
name: string;
|
|
4051
|
-
/** Error message describing what went wrong. */
|
|
4052
|
-
message: string;
|
|
4053
|
-
/** Optional error code if the error has one (e.g., KitError codes). */
|
|
4054
|
-
code?: number;
|
|
4055
|
-
/** Error category (e.g., INPUT, RPC, ONCHAIN, BALANCE, NETWORK, UNKNOWN). Only set for KitError instances. */
|
|
4056
|
-
type?: string;
|
|
4057
|
-
}
|
|
4058
|
-
|
|
4059
4160
|
/**
|
|
4060
4161
|
* Runtime array of token identifiers supported by the Gateway v1 provider.
|
|
4061
4162
|
*
|
package/unifiedBalance.d.mts
CHANGED
|
@@ -739,6 +739,8 @@ declare enum Blockchain {
|
|
|
739
739
|
World_Chain_Sepolia = "World_Chain_Sepolia",
|
|
740
740
|
XDC = "XDC",
|
|
741
741
|
XDC_Apothem = "XDC_Apothem",
|
|
742
|
+
X_Layer = "X_Layer",
|
|
743
|
+
X_Layer_Testnet = "X_Layer_Testnet",
|
|
742
744
|
ZKSync_Era = "ZKSync_Era",
|
|
743
745
|
ZKSync_Sepolia = "ZKSync_Sepolia"
|
|
744
746
|
}
|
|
@@ -2602,6 +2604,18 @@ interface TokenActionMap {
|
|
|
2602
2604
|
*/
|
|
2603
2605
|
walletAddress?: string | undefined;
|
|
2604
2606
|
};
|
|
2607
|
+
/**
|
|
2608
|
+
* Get the on-chain name of the token contract.
|
|
2609
|
+
*
|
|
2610
|
+
* This is a read-only operation. For USDC the value is also the EIP-712
|
|
2611
|
+
* domain name, which permit and authorize signing flows need.
|
|
2612
|
+
*/
|
|
2613
|
+
name: ActionParameters & {
|
|
2614
|
+
/**
|
|
2615
|
+
* The contract address of the token.
|
|
2616
|
+
*/
|
|
2617
|
+
tokenAddress: string;
|
|
2618
|
+
};
|
|
2605
2619
|
}
|
|
2606
2620
|
|
|
2607
2621
|
/**
|
|
@@ -3431,6 +3445,30 @@ declare class ActionRegistry {
|
|
|
3431
3445
|
executeAction<TActionKey extends ActionKeys>(action: TActionKey, params: ActionPayload<TActionKey>, context: ResolvedOperationContext): Promise<PreparedChainRequest>;
|
|
3432
3446
|
}
|
|
3433
3447
|
|
|
3448
|
+
/**
|
|
3449
|
+
* Canonical list of actions that do not prepare or submit transactions.
|
|
3450
|
+
*
|
|
3451
|
+
* @internal
|
|
3452
|
+
*/
|
|
3453
|
+
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"];
|
|
3454
|
+
/**
|
|
3455
|
+
* Action keys that execute without preparing or submitting a transaction.
|
|
3456
|
+
*
|
|
3457
|
+
* @remarks
|
|
3458
|
+
* Derive this type from the canonical runtime list so compile-time and runtime
|
|
3459
|
+
* classification cannot drift. `gateway.v1.signBurnIntents` is included
|
|
3460
|
+
* because the action system models off-chain signing as a read action: it does
|
|
3461
|
+
* not prepare a chain request.
|
|
3462
|
+
*
|
|
3463
|
+
* @example
|
|
3464
|
+
* ```typescript
|
|
3465
|
+
* import type { ReadActionKey } from '@core/adapter'
|
|
3466
|
+
*
|
|
3467
|
+
* const action: ReadActionKey = 'token.allowance'
|
|
3468
|
+
* ```
|
|
3469
|
+
*/
|
|
3470
|
+
type ReadActionKey = (typeof READ_ACTION_KEYS)[number];
|
|
3471
|
+
|
|
3434
3472
|
/**
|
|
3435
3473
|
* Defines the capabilities of an adapter, including address handling patterns and supported chains.
|
|
3436
3474
|
*
|
|
@@ -3599,6 +3637,69 @@ declare abstract class Adapter<TAdapterCapabilities extends AdapterCapabilities
|
|
|
3599
3637
|
* ```
|
|
3600
3638
|
*/
|
|
3601
3639
|
prepareAction<TActionKey extends ActionKeys>(action: TActionKey, params: ActionPayload<TActionKey>, ctx: OperationContext<TAdapterCapabilities>): Promise<PreparedChainRequest>;
|
|
3640
|
+
/**
|
|
3641
|
+
* Execute a non-transaction action without routing through transaction preparation.
|
|
3642
|
+
*
|
|
3643
|
+
* @remarks
|
|
3644
|
+
* Use this seam for balance, allowance, contract-state, and other actions
|
|
3645
|
+
* classified as reads. It never calls {@link Adapter.prepareAction}, so
|
|
3646
|
+
* transaction authorization wrappers only observe actions that can produce a
|
|
3647
|
+
* signable chain request.
|
|
3648
|
+
*
|
|
3649
|
+
* @typeParam TActionKey - The read action key.
|
|
3650
|
+
* @param action - The read action to execute.
|
|
3651
|
+
* @param params - The parameters for the read action.
|
|
3652
|
+
* @param ctx - The operation context.
|
|
3653
|
+
* @returns The raw action response.
|
|
3654
|
+
* @throws {KitError} When the key is not a read action or no handler is registered.
|
|
3655
|
+
* @throws Error When the operation context or action handler fails.
|
|
3656
|
+
*
|
|
3657
|
+
* @example
|
|
3658
|
+
* ```typescript
|
|
3659
|
+
* import { Ethereum } from '@core/chains'
|
|
3660
|
+
*
|
|
3661
|
+
* const balance = await adapter.readAction(
|
|
3662
|
+
* 'token.balanceOf',
|
|
3663
|
+
* { tokenAddress, walletAddress },
|
|
3664
|
+
* { chain: Ethereum },
|
|
3665
|
+
* )
|
|
3666
|
+
* ```
|
|
3667
|
+
*
|
|
3668
|
+
* @internal
|
|
3669
|
+
*/
|
|
3670
|
+
readAction<TActionKey extends ReadActionKey>(action: TActionKey, params: ActionPayload<TActionKey>, ctx: OperationContext<TAdapterCapabilities>): Promise<unknown>;
|
|
3671
|
+
/**
|
|
3672
|
+
* Read the current token allowance a delegate holds over an owner's tokens.
|
|
3673
|
+
*
|
|
3674
|
+
* @remarks
|
|
3675
|
+
* Perform a network read through {@link Adapter.readAction}. This method
|
|
3676
|
+
* never routes through {@link Adapter.prepareAction}. On chains without an
|
|
3677
|
+
* allowance model, such as Solana, return the maximum uint256 value.
|
|
3678
|
+
*
|
|
3679
|
+
* @param params - The token to query and the delegate whose allowance is being read.
|
|
3680
|
+
* @param ctx - Operation context with compile-time validated address requirements.
|
|
3681
|
+
* @returns A promise resolving to the current allowance in the token's base units.
|
|
3682
|
+
* @throws {KitError} When the adapter does not register a `token.allowance` handler.
|
|
3683
|
+
* @throws Error When the operation context or action handler fails.
|
|
3684
|
+
*
|
|
3685
|
+
* @example
|
|
3686
|
+
* ```typescript
|
|
3687
|
+
* import type { Adapter } from '@core/adapter'
|
|
3688
|
+
* import { Ethereum } from '@core/chains'
|
|
3689
|
+
*
|
|
3690
|
+
* declare const adapter: Adapter
|
|
3691
|
+
*
|
|
3692
|
+
* const allowance = await adapter.getTokenAllowance(
|
|
3693
|
+
* {
|
|
3694
|
+
* tokenAddress: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
|
3695
|
+
* delegate: '0x1111111111111111111111111111111111111111',
|
|
3696
|
+
* },
|
|
3697
|
+
* { chain: Ethereum },
|
|
3698
|
+
* )
|
|
3699
|
+
* console.log(allowance) // 1000000n
|
|
3700
|
+
* ```
|
|
3701
|
+
*/
|
|
3702
|
+
getTokenAllowance(params: ActionPayload<'token.allowance'>, ctx: OperationContext<TAdapterCapabilities>): Promise<bigint>;
|
|
3602
3703
|
/**
|
|
3603
3704
|
* Prepares a transaction for future gas estimation and execution.
|
|
3604
3705
|
*
|
|
@@ -3785,6 +3886,37 @@ declare abstract class Adapter<TAdapterCapabilities extends AdapterCapabilities
|
|
|
3785
3886
|
abstract getTokenDecimals(tokenAddress: string, chain: ChainDefinition): Promise<number>;
|
|
3786
3887
|
}
|
|
3787
3888
|
|
|
3889
|
+
/**
|
|
3890
|
+
* Simplified error information structure for logging and events.
|
|
3891
|
+
*
|
|
3892
|
+
* @remarks
|
|
3893
|
+
* This lightweight type is used for error reporting in events, logs, and
|
|
3894
|
+
* observability systems. It provides essential error context without the
|
|
3895
|
+
* full ErrorDetails structure. Used across retry mechanisms, adapters,
|
|
3896
|
+
* and other subsystems that need to record error information.
|
|
3897
|
+
*
|
|
3898
|
+
* @example
|
|
3899
|
+
* ```typescript
|
|
3900
|
+
* import { ErrorInfo } from '@core/errors'
|
|
3901
|
+
*
|
|
3902
|
+
* const info: ErrorInfo = {
|
|
3903
|
+
* name: 'NETWORK_TIMEOUT',
|
|
3904
|
+
* message: 'Request timed out after 5000ms',
|
|
3905
|
+
* code: 3002
|
|
3906
|
+
* }
|
|
3907
|
+
* ```
|
|
3908
|
+
*/
|
|
3909
|
+
interface ErrorInfo {
|
|
3910
|
+
/** Error name (e.g., 'TypeError', 'KitError', 'NETWORK_TIMEOUT'). */
|
|
3911
|
+
name: string;
|
|
3912
|
+
/** Error message describing what went wrong. */
|
|
3913
|
+
message: string;
|
|
3914
|
+
/** Optional error code if the error has one (e.g., KitError codes). */
|
|
3915
|
+
code?: number;
|
|
3916
|
+
/** Error category (e.g., INPUT, RPC, ONCHAIN, BALANCE, NETWORK, UNKNOWN). Only set for KitError instances. */
|
|
3917
|
+
type?: string;
|
|
3918
|
+
}
|
|
3919
|
+
|
|
3788
3920
|
/**
|
|
3789
3921
|
* A type-safe event emitter for managing action-based event subscriptions.
|
|
3790
3922
|
*
|
|
@@ -4025,37 +4157,6 @@ declare module './types' {
|
|
|
4025
4157
|
}
|
|
4026
4158
|
}
|
|
4027
4159
|
|
|
4028
|
-
/**
|
|
4029
|
-
* Simplified error information structure for logging and events.
|
|
4030
|
-
*
|
|
4031
|
-
* @remarks
|
|
4032
|
-
* This lightweight type is used for error reporting in events, logs, and
|
|
4033
|
-
* observability systems. It provides essential error context without the
|
|
4034
|
-
* full ErrorDetails structure. Used across retry mechanisms, adapters,
|
|
4035
|
-
* and other subsystems that need to record error information.
|
|
4036
|
-
*
|
|
4037
|
-
* @example
|
|
4038
|
-
* ```typescript
|
|
4039
|
-
* import { ErrorInfo } from '@core/errors'
|
|
4040
|
-
*
|
|
4041
|
-
* const info: ErrorInfo = {
|
|
4042
|
-
* name: 'NETWORK_TIMEOUT',
|
|
4043
|
-
* message: 'Request timed out after 5000ms',
|
|
4044
|
-
* code: 3002
|
|
4045
|
-
* }
|
|
4046
|
-
* ```
|
|
4047
|
-
*/
|
|
4048
|
-
interface ErrorInfo {
|
|
4049
|
-
/** Error name (e.g., 'TypeError', 'KitError', 'NETWORK_TIMEOUT'). */
|
|
4050
|
-
name: string;
|
|
4051
|
-
/** Error message describing what went wrong. */
|
|
4052
|
-
message: string;
|
|
4053
|
-
/** Optional error code if the error has one (e.g., KitError codes). */
|
|
4054
|
-
code?: number;
|
|
4055
|
-
/** Error category (e.g., INPUT, RPC, ONCHAIN, BALANCE, NETWORK, UNKNOWN). Only set for KitError instances. */
|
|
4056
|
-
type?: string;
|
|
4057
|
-
}
|
|
4058
|
-
|
|
4059
4160
|
/**
|
|
4060
4161
|
* Runtime array of token identifiers supported by the Gateway v1 provider.
|
|
4061
4162
|
*
|
package/unifiedBalance.d.ts
CHANGED
|
@@ -739,6 +739,8 @@ declare enum Blockchain {
|
|
|
739
739
|
World_Chain_Sepolia = "World_Chain_Sepolia",
|
|
740
740
|
XDC = "XDC",
|
|
741
741
|
XDC_Apothem = "XDC_Apothem",
|
|
742
|
+
X_Layer = "X_Layer",
|
|
743
|
+
X_Layer_Testnet = "X_Layer_Testnet",
|
|
742
744
|
ZKSync_Era = "ZKSync_Era",
|
|
743
745
|
ZKSync_Sepolia = "ZKSync_Sepolia"
|
|
744
746
|
}
|
|
@@ -2602,6 +2604,18 @@ interface TokenActionMap {
|
|
|
2602
2604
|
*/
|
|
2603
2605
|
walletAddress?: string | undefined;
|
|
2604
2606
|
};
|
|
2607
|
+
/**
|
|
2608
|
+
* Get the on-chain name of the token contract.
|
|
2609
|
+
*
|
|
2610
|
+
* This is a read-only operation. For USDC the value is also the EIP-712
|
|
2611
|
+
* domain name, which permit and authorize signing flows need.
|
|
2612
|
+
*/
|
|
2613
|
+
name: ActionParameters & {
|
|
2614
|
+
/**
|
|
2615
|
+
* The contract address of the token.
|
|
2616
|
+
*/
|
|
2617
|
+
tokenAddress: string;
|
|
2618
|
+
};
|
|
2605
2619
|
}
|
|
2606
2620
|
|
|
2607
2621
|
/**
|
|
@@ -3431,6 +3445,30 @@ declare class ActionRegistry {
|
|
|
3431
3445
|
executeAction<TActionKey extends ActionKeys>(action: TActionKey, params: ActionPayload<TActionKey>, context: ResolvedOperationContext): Promise<PreparedChainRequest>;
|
|
3432
3446
|
}
|
|
3433
3447
|
|
|
3448
|
+
/**
|
|
3449
|
+
* Canonical list of actions that do not prepare or submit transactions.
|
|
3450
|
+
*
|
|
3451
|
+
* @internal
|
|
3452
|
+
*/
|
|
3453
|
+
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"];
|
|
3454
|
+
/**
|
|
3455
|
+
* Action keys that execute without preparing or submitting a transaction.
|
|
3456
|
+
*
|
|
3457
|
+
* @remarks
|
|
3458
|
+
* Derive this type from the canonical runtime list so compile-time and runtime
|
|
3459
|
+
* classification cannot drift. `gateway.v1.signBurnIntents` is included
|
|
3460
|
+
* because the action system models off-chain signing as a read action: it does
|
|
3461
|
+
* not prepare a chain request.
|
|
3462
|
+
*
|
|
3463
|
+
* @example
|
|
3464
|
+
* ```typescript
|
|
3465
|
+
* import type { ReadActionKey } from '@core/adapter'
|
|
3466
|
+
*
|
|
3467
|
+
* const action: ReadActionKey = 'token.allowance'
|
|
3468
|
+
* ```
|
|
3469
|
+
*/
|
|
3470
|
+
type ReadActionKey = (typeof READ_ACTION_KEYS)[number];
|
|
3471
|
+
|
|
3434
3472
|
/**
|
|
3435
3473
|
* Defines the capabilities of an adapter, including address handling patterns and supported chains.
|
|
3436
3474
|
*
|
|
@@ -3599,6 +3637,69 @@ declare abstract class Adapter<TAdapterCapabilities extends AdapterCapabilities
|
|
|
3599
3637
|
* ```
|
|
3600
3638
|
*/
|
|
3601
3639
|
prepareAction<TActionKey extends ActionKeys>(action: TActionKey, params: ActionPayload<TActionKey>, ctx: OperationContext<TAdapterCapabilities>): Promise<PreparedChainRequest>;
|
|
3640
|
+
/**
|
|
3641
|
+
* Execute a non-transaction action without routing through transaction preparation.
|
|
3642
|
+
*
|
|
3643
|
+
* @remarks
|
|
3644
|
+
* Use this seam for balance, allowance, contract-state, and other actions
|
|
3645
|
+
* classified as reads. It never calls {@link Adapter.prepareAction}, so
|
|
3646
|
+
* transaction authorization wrappers only observe actions that can produce a
|
|
3647
|
+
* signable chain request.
|
|
3648
|
+
*
|
|
3649
|
+
* @typeParam TActionKey - The read action key.
|
|
3650
|
+
* @param action - The read action to execute.
|
|
3651
|
+
* @param params - The parameters for the read action.
|
|
3652
|
+
* @param ctx - The operation context.
|
|
3653
|
+
* @returns The raw action response.
|
|
3654
|
+
* @throws {KitError} When the key is not a read action or no handler is registered.
|
|
3655
|
+
* @throws Error When the operation context or action handler fails.
|
|
3656
|
+
*
|
|
3657
|
+
* @example
|
|
3658
|
+
* ```typescript
|
|
3659
|
+
* import { Ethereum } from '@core/chains'
|
|
3660
|
+
*
|
|
3661
|
+
* const balance = await adapter.readAction(
|
|
3662
|
+
* 'token.balanceOf',
|
|
3663
|
+
* { tokenAddress, walletAddress },
|
|
3664
|
+
* { chain: Ethereum },
|
|
3665
|
+
* )
|
|
3666
|
+
* ```
|
|
3667
|
+
*
|
|
3668
|
+
* @internal
|
|
3669
|
+
*/
|
|
3670
|
+
readAction<TActionKey extends ReadActionKey>(action: TActionKey, params: ActionPayload<TActionKey>, ctx: OperationContext<TAdapterCapabilities>): Promise<unknown>;
|
|
3671
|
+
/**
|
|
3672
|
+
* Read the current token allowance a delegate holds over an owner's tokens.
|
|
3673
|
+
*
|
|
3674
|
+
* @remarks
|
|
3675
|
+
* Perform a network read through {@link Adapter.readAction}. This method
|
|
3676
|
+
* never routes through {@link Adapter.prepareAction}. On chains without an
|
|
3677
|
+
* allowance model, such as Solana, return the maximum uint256 value.
|
|
3678
|
+
*
|
|
3679
|
+
* @param params - The token to query and the delegate whose allowance is being read.
|
|
3680
|
+
* @param ctx - Operation context with compile-time validated address requirements.
|
|
3681
|
+
* @returns A promise resolving to the current allowance in the token's base units.
|
|
3682
|
+
* @throws {KitError} When the adapter does not register a `token.allowance` handler.
|
|
3683
|
+
* @throws Error When the operation context or action handler fails.
|
|
3684
|
+
*
|
|
3685
|
+
* @example
|
|
3686
|
+
* ```typescript
|
|
3687
|
+
* import type { Adapter } from '@core/adapter'
|
|
3688
|
+
* import { Ethereum } from '@core/chains'
|
|
3689
|
+
*
|
|
3690
|
+
* declare const adapter: Adapter
|
|
3691
|
+
*
|
|
3692
|
+
* const allowance = await adapter.getTokenAllowance(
|
|
3693
|
+
* {
|
|
3694
|
+
* tokenAddress: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
|
3695
|
+
* delegate: '0x1111111111111111111111111111111111111111',
|
|
3696
|
+
* },
|
|
3697
|
+
* { chain: Ethereum },
|
|
3698
|
+
* )
|
|
3699
|
+
* console.log(allowance) // 1000000n
|
|
3700
|
+
* ```
|
|
3701
|
+
*/
|
|
3702
|
+
getTokenAllowance(params: ActionPayload<'token.allowance'>, ctx: OperationContext<TAdapterCapabilities>): Promise<bigint>;
|
|
3602
3703
|
/**
|
|
3603
3704
|
* Prepares a transaction for future gas estimation and execution.
|
|
3604
3705
|
*
|
|
@@ -3785,6 +3886,37 @@ declare abstract class Adapter<TAdapterCapabilities extends AdapterCapabilities
|
|
|
3785
3886
|
abstract getTokenDecimals(tokenAddress: string, chain: ChainDefinition): Promise<number>;
|
|
3786
3887
|
}
|
|
3787
3888
|
|
|
3889
|
+
/**
|
|
3890
|
+
* Simplified error information structure for logging and events.
|
|
3891
|
+
*
|
|
3892
|
+
* @remarks
|
|
3893
|
+
* This lightweight type is used for error reporting in events, logs, and
|
|
3894
|
+
* observability systems. It provides essential error context without the
|
|
3895
|
+
* full ErrorDetails structure. Used across retry mechanisms, adapters,
|
|
3896
|
+
* and other subsystems that need to record error information.
|
|
3897
|
+
*
|
|
3898
|
+
* @example
|
|
3899
|
+
* ```typescript
|
|
3900
|
+
* import { ErrorInfo } from '@core/errors'
|
|
3901
|
+
*
|
|
3902
|
+
* const info: ErrorInfo = {
|
|
3903
|
+
* name: 'NETWORK_TIMEOUT',
|
|
3904
|
+
* message: 'Request timed out after 5000ms',
|
|
3905
|
+
* code: 3002
|
|
3906
|
+
* }
|
|
3907
|
+
* ```
|
|
3908
|
+
*/
|
|
3909
|
+
interface ErrorInfo {
|
|
3910
|
+
/** Error name (e.g., 'TypeError', 'KitError', 'NETWORK_TIMEOUT'). */
|
|
3911
|
+
name: string;
|
|
3912
|
+
/** Error message describing what went wrong. */
|
|
3913
|
+
message: string;
|
|
3914
|
+
/** Optional error code if the error has one (e.g., KitError codes). */
|
|
3915
|
+
code?: number;
|
|
3916
|
+
/** Error category (e.g., INPUT, RPC, ONCHAIN, BALANCE, NETWORK, UNKNOWN). Only set for KitError instances. */
|
|
3917
|
+
type?: string;
|
|
3918
|
+
}
|
|
3919
|
+
|
|
3788
3920
|
/**
|
|
3789
3921
|
* A type-safe event emitter for managing action-based event subscriptions.
|
|
3790
3922
|
*
|
|
@@ -4025,37 +4157,6 @@ declare module './types' {
|
|
|
4025
4157
|
}
|
|
4026
4158
|
}
|
|
4027
4159
|
|
|
4028
|
-
/**
|
|
4029
|
-
* Simplified error information structure for logging and events.
|
|
4030
|
-
*
|
|
4031
|
-
* @remarks
|
|
4032
|
-
* This lightweight type is used for error reporting in events, logs, and
|
|
4033
|
-
* observability systems. It provides essential error context without the
|
|
4034
|
-
* full ErrorDetails structure. Used across retry mechanisms, adapters,
|
|
4035
|
-
* and other subsystems that need to record error information.
|
|
4036
|
-
*
|
|
4037
|
-
* @example
|
|
4038
|
-
* ```typescript
|
|
4039
|
-
* import { ErrorInfo } from '@core/errors'
|
|
4040
|
-
*
|
|
4041
|
-
* const info: ErrorInfo = {
|
|
4042
|
-
* name: 'NETWORK_TIMEOUT',
|
|
4043
|
-
* message: 'Request timed out after 5000ms',
|
|
4044
|
-
* code: 3002
|
|
4045
|
-
* }
|
|
4046
|
-
* ```
|
|
4047
|
-
*/
|
|
4048
|
-
interface ErrorInfo {
|
|
4049
|
-
/** Error name (e.g., 'TypeError', 'KitError', 'NETWORK_TIMEOUT'). */
|
|
4050
|
-
name: string;
|
|
4051
|
-
/** Error message describing what went wrong. */
|
|
4052
|
-
message: string;
|
|
4053
|
-
/** Optional error code if the error has one (e.g., KitError codes). */
|
|
4054
|
-
code?: number;
|
|
4055
|
-
/** Error category (e.g., INPUT, RPC, ONCHAIN, BALANCE, NETWORK, UNKNOWN). Only set for KitError instances. */
|
|
4056
|
-
type?: string;
|
|
4057
|
-
}
|
|
4058
|
-
|
|
4059
4160
|
/**
|
|
4060
4161
|
* Runtime array of token identifiers supported by the Gateway v1 provider.
|
|
4061
4162
|
*
|