@circle-fin/bridge-kit 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/QUICKSTART.md +175 -11
- package/README.md +79 -3
- package/chains.cjs.js +70 -16
- package/chains.d.ts +444 -7
- package/chains.mjs +60 -17
- package/index.cjs.js +361 -25
- package/index.d.ts +233 -14
- package/index.mjs +355 -26
- package/package.json +3 -1
package/index.d.ts
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
import { Abi } from 'abitype';
|
|
20
20
|
import { TransactionInstruction, Signer } from '@solana/web3.js';
|
|
21
21
|
import { CCTPV2BridgingProvider } from '@circle-fin/provider-cctp-v2';
|
|
22
|
-
import { z } from '/home/runner/_work/stablecoin-kits-private/stablecoin-kits-private/node_modules/zod/dist/types/index.d.ts';
|
|
22
|
+
import { z } from '/home/runner/_work/stablecoin-kits-private/stablecoin-kits-private/kits/bridge-kit/node_modules/zod/dist/types/index.d.ts';
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* @packageDocumentation
|
|
@@ -410,6 +410,7 @@ declare enum Blockchain {
|
|
|
410
410
|
Algorand_Testnet = "Algorand_Testnet",
|
|
411
411
|
Aptos = "Aptos",
|
|
412
412
|
Aptos_Testnet = "Aptos_Testnet",
|
|
413
|
+
Arc_Testnet = "Arc_Testnet",
|
|
413
414
|
Arbitrum = "Arbitrum",
|
|
414
415
|
Arbitrum_Sepolia = "Arbitrum_Sepolia",
|
|
415
416
|
Avalanche = "Avalanche",
|
|
@@ -2349,6 +2350,24 @@ declare class Actionable<AllActions> {
|
|
|
2349
2350
|
dispatch<K extends keyof AllActions>(action: K, payload: AllActions[K]): void;
|
|
2350
2351
|
}
|
|
2351
2352
|
|
|
2353
|
+
/**
|
|
2354
|
+
* Set an application-level identifier prefix for all HTTP requests.
|
|
2355
|
+
*
|
|
2356
|
+
* This allows applications to identify themselves in the user agent string,
|
|
2357
|
+
* which is useful for tracking and analytics at the application level.
|
|
2358
|
+
*
|
|
2359
|
+
* @param prefix - Application identifier with version, e.g., "my-app/1.0.0"
|
|
2360
|
+
*
|
|
2361
|
+
* @example
|
|
2362
|
+
* ```typescript
|
|
2363
|
+
* import { setExternalPrefix } from '\@circle-fin/bridge-kit'
|
|
2364
|
+
*
|
|
2365
|
+
* setExternalPrefix('my-dapp/2.1.0')
|
|
2366
|
+
* // All subsequent HTTP requests will include this prefix
|
|
2367
|
+
* ```
|
|
2368
|
+
*/
|
|
2369
|
+
declare const setExternalPrefix: (prefix: string) => void;
|
|
2370
|
+
|
|
2352
2371
|
/**
|
|
2353
2372
|
* Transfer speed options for cross-chain operations.
|
|
2354
2373
|
*
|
|
@@ -2572,7 +2591,26 @@ interface BridgeConfig {
|
|
|
2572
2591
|
/**
|
|
2573
2592
|
* The maximum fee to pay for the burn operation.
|
|
2574
2593
|
*
|
|
2575
|
-
*
|
|
2594
|
+
* Provide the amount as a base-10 numeric string representing the
|
|
2595
|
+
* token amount in human-readable format. For example: to set a maximum
|
|
2596
|
+
* fee of 1 USDC, pass `"1"`. Decimal values are supported (e.g., `"0.5"`
|
|
2597
|
+
* for half a USDC).
|
|
2598
|
+
*
|
|
2599
|
+
* @defaultValue `"0"`
|
|
2600
|
+
*
|
|
2601
|
+
* @example
|
|
2602
|
+
* ```typescript
|
|
2603
|
+
* import type { BridgeConfig, TransferSpeed } from '@core/provider'
|
|
2604
|
+
*
|
|
2605
|
+
* const config: BridgeConfig = {
|
|
2606
|
+
* transferSpeed: TransferSpeed.FAST,
|
|
2607
|
+
* maxFee: "1", // 1 USDC maximum fee
|
|
2608
|
+
* customFee: {
|
|
2609
|
+
* value: "0.5", // 0.5 USDC developer fee
|
|
2610
|
+
* recipientAddress: "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb0"
|
|
2611
|
+
* }
|
|
2612
|
+
* }
|
|
2613
|
+
* ```
|
|
2576
2614
|
*/
|
|
2577
2615
|
maxFee?: string;
|
|
2578
2616
|
/**
|
|
@@ -2583,8 +2621,8 @@ interface BridgeConfig {
|
|
|
2583
2621
|
/**
|
|
2584
2622
|
* Custom fee configuration charged by the integrator.
|
|
2585
2623
|
*
|
|
2586
|
-
* Use to charge an absolute fee on the source chain
|
|
2587
|
-
*
|
|
2624
|
+
* Use to charge an absolute fee on the source chain in human-readable
|
|
2625
|
+
* token amounts.
|
|
2588
2626
|
*
|
|
2589
2627
|
* @remarks
|
|
2590
2628
|
* This is an absolute amount, not a percentage. The `recipientAddress` must be
|
|
@@ -2595,7 +2633,7 @@ interface BridgeConfig {
|
|
|
2595
2633
|
* import type { CustomFee } from '@core/provider'
|
|
2596
2634
|
*
|
|
2597
2635
|
* const config: CustomFee = {
|
|
2598
|
-
* value: '
|
|
2636
|
+
* value: '1', // 1 USDC
|
|
2599
2637
|
* recipientAddress: '0x1234567890123456789012345678901234567890',
|
|
2600
2638
|
* }
|
|
2601
2639
|
* ```
|
|
@@ -2603,20 +2641,25 @@ interface BridgeConfig {
|
|
|
2603
2641
|
interface CustomFee {
|
|
2604
2642
|
/**
|
|
2605
2643
|
* The absolute fee to charge for the transfer.
|
|
2606
|
-
*
|
|
2607
|
-
*
|
|
2644
|
+
*
|
|
2645
|
+
* Provide the amount as a base-10 numeric string representing the token
|
|
2646
|
+
* amount in human-readable format. For example: to charge 1 USDC, pass
|
|
2647
|
+
* `"1"`. Decimal values are supported (e.g., `"0.5"` for half a USDC).
|
|
2608
2648
|
* This is not a percentage.
|
|
2609
2649
|
*
|
|
2610
|
-
* Note: passing `
|
|
2650
|
+
* Note: passing `"0"` results in no fee being charged.
|
|
2611
2651
|
*/
|
|
2612
2652
|
value?: string | undefined;
|
|
2613
2653
|
/**
|
|
2614
2654
|
* The fee recipient for the bridge transfer.
|
|
2615
|
-
*
|
|
2616
|
-
*
|
|
2655
|
+
*
|
|
2656
|
+
* This is the address that will receive the fee on the source chain of the
|
|
2657
|
+
* bridge transfer. The fee recipient address **must be a valid address for
|
|
2658
|
+
* the source chain** of the bridge transfer.
|
|
2617
2659
|
*
|
|
2618
2660
|
* For example: if bridging from Ethereum to Solana, pass an EVM address like
|
|
2619
|
-
* `
|
|
2661
|
+
* `"0x1234567890123456789012345678901234567890"` because the source chain
|
|
2662
|
+
* is Ethereum.
|
|
2620
2663
|
*/
|
|
2621
2664
|
recipientAddress?: string | undefined;
|
|
2622
2665
|
}
|
|
@@ -3732,13 +3775,15 @@ declare const bridgeParamsWithChainIdentifierSchema: z.ZodObject<{
|
|
|
3732
3775
|
getAddress: (...args: unknown[]) => unknown;
|
|
3733
3776
|
}>;
|
|
3734
3777
|
chain: never;
|
|
3735
|
-
|
|
3778
|
+
address: z.ZodOptional<z.ZodString>;
|
|
3779
|
+
}, "strict", z.ZodTypeAny, {
|
|
3736
3780
|
adapter: {
|
|
3737
3781
|
prepare: (...args: unknown[]) => unknown;
|
|
3738
3782
|
waitForTransaction: (...args: unknown[]) => unknown;
|
|
3739
3783
|
getAddress: (...args: unknown[]) => unknown;
|
|
3740
3784
|
};
|
|
3741
3785
|
chain: never;
|
|
3786
|
+
address?: string | undefined;
|
|
3742
3787
|
}, {
|
|
3743
3788
|
adapter: {
|
|
3744
3789
|
prepare: (...args: unknown[]) => unknown;
|
|
@@ -3746,6 +3791,7 @@ declare const bridgeParamsWithChainIdentifierSchema: z.ZodObject<{
|
|
|
3746
3791
|
getAddress: (...args: unknown[]) => unknown;
|
|
3747
3792
|
};
|
|
3748
3793
|
chain: never;
|
|
3794
|
+
address?: string | undefined;
|
|
3749
3795
|
}>;
|
|
3750
3796
|
to: z.ZodUnion<[z.ZodEffects<z.ZodObject<{
|
|
3751
3797
|
adapter: z.ZodObject<{
|
|
@@ -3762,6 +3808,7 @@ declare const bridgeParamsWithChainIdentifierSchema: z.ZodObject<{
|
|
|
3762
3808
|
getAddress: (...args: unknown[]) => unknown;
|
|
3763
3809
|
}>;
|
|
3764
3810
|
chain: never;
|
|
3811
|
+
address: z.ZodOptional<z.ZodString>;
|
|
3765
3812
|
} & {
|
|
3766
3813
|
recipientAddress: z.ZodString;
|
|
3767
3814
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -3772,6 +3819,7 @@ declare const bridgeParamsWithChainIdentifierSchema: z.ZodObject<{
|
|
|
3772
3819
|
};
|
|
3773
3820
|
chain: never;
|
|
3774
3821
|
recipientAddress: string;
|
|
3822
|
+
address?: string | undefined;
|
|
3775
3823
|
}, {
|
|
3776
3824
|
adapter: {
|
|
3777
3825
|
prepare: (...args: unknown[]) => unknown;
|
|
@@ -3780,6 +3828,7 @@ declare const bridgeParamsWithChainIdentifierSchema: z.ZodObject<{
|
|
|
3780
3828
|
};
|
|
3781
3829
|
chain: never;
|
|
3782
3830
|
recipientAddress: string;
|
|
3831
|
+
address?: string | undefined;
|
|
3783
3832
|
}>, {
|
|
3784
3833
|
adapter: {
|
|
3785
3834
|
prepare: (...args: unknown[]) => unknown;
|
|
@@ -3788,6 +3837,7 @@ declare const bridgeParamsWithChainIdentifierSchema: z.ZodObject<{
|
|
|
3788
3837
|
};
|
|
3789
3838
|
chain: never;
|
|
3790
3839
|
recipientAddress: string;
|
|
3840
|
+
address?: string | undefined;
|
|
3791
3841
|
}, {
|
|
3792
3842
|
adapter: {
|
|
3793
3843
|
prepare: (...args: unknown[]) => unknown;
|
|
@@ -3796,6 +3846,7 @@ declare const bridgeParamsWithChainIdentifierSchema: z.ZodObject<{
|
|
|
3796
3846
|
};
|
|
3797
3847
|
chain: never;
|
|
3798
3848
|
recipientAddress: string;
|
|
3849
|
+
address?: string | undefined;
|
|
3799
3850
|
}>, z.ZodObject<{
|
|
3800
3851
|
adapter: z.ZodObject<{
|
|
3801
3852
|
prepare: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodUnknown>;
|
|
@@ -3811,6 +3862,7 @@ declare const bridgeParamsWithChainIdentifierSchema: z.ZodObject<{
|
|
|
3811
3862
|
getAddress: (...args: unknown[]) => unknown;
|
|
3812
3863
|
}>;
|
|
3813
3864
|
chain: never;
|
|
3865
|
+
address: z.ZodOptional<z.ZodString>;
|
|
3814
3866
|
}, "strict", z.ZodTypeAny, {
|
|
3815
3867
|
adapter: {
|
|
3816
3868
|
prepare: (...args: unknown[]) => unknown;
|
|
@@ -3818,6 +3870,7 @@ declare const bridgeParamsWithChainIdentifierSchema: z.ZodObject<{
|
|
|
3818
3870
|
getAddress: (...args: unknown[]) => unknown;
|
|
3819
3871
|
};
|
|
3820
3872
|
chain: never;
|
|
3873
|
+
address?: string | undefined;
|
|
3821
3874
|
}, {
|
|
3822
3875
|
adapter: {
|
|
3823
3876
|
prepare: (...args: unknown[]) => unknown;
|
|
@@ -3825,12 +3878,13 @@ declare const bridgeParamsWithChainIdentifierSchema: z.ZodObject<{
|
|
|
3825
3878
|
getAddress: (...args: unknown[]) => unknown;
|
|
3826
3879
|
};
|
|
3827
3880
|
chain: never;
|
|
3881
|
+
address?: string | undefined;
|
|
3828
3882
|
}>]>;
|
|
3829
3883
|
amount: z.ZodPipeline<z.ZodString, z.ZodType<string, z.ZodTypeDef, string>>;
|
|
3830
3884
|
token: z.ZodOptional<z.ZodLiteral<"USDC">>;
|
|
3831
3885
|
config: z.ZodOptional<z.ZodObject<{
|
|
3832
3886
|
transferSpeed: z.ZodOptional<z.ZodNativeEnum<typeof TransferSpeed>>;
|
|
3833
|
-
maxFee: z.ZodOptional<z.ZodString
|
|
3887
|
+
maxFee: z.ZodOptional<z.ZodPipeline<z.ZodString, z.ZodType<string, z.ZodTypeDef, string>>>;
|
|
3834
3888
|
customFee: z.ZodOptional<z.ZodObject<{
|
|
3835
3889
|
value: z.ZodOptional<z.ZodType<string, z.ZodTypeDef, string>>;
|
|
3836
3890
|
recipientAddress: z.ZodOptional<z.ZodString>;
|
|
@@ -3864,6 +3918,7 @@ declare const bridgeParamsWithChainIdentifierSchema: z.ZodObject<{
|
|
|
3864
3918
|
getAddress: (...args: unknown[]) => unknown;
|
|
3865
3919
|
};
|
|
3866
3920
|
chain: never;
|
|
3921
|
+
address?: string | undefined;
|
|
3867
3922
|
};
|
|
3868
3923
|
to: {
|
|
3869
3924
|
adapter: {
|
|
@@ -3872,6 +3927,7 @@ declare const bridgeParamsWithChainIdentifierSchema: z.ZodObject<{
|
|
|
3872
3927
|
getAddress: (...args: unknown[]) => unknown;
|
|
3873
3928
|
};
|
|
3874
3929
|
chain: never;
|
|
3930
|
+
address?: string | undefined;
|
|
3875
3931
|
} | {
|
|
3876
3932
|
adapter: {
|
|
3877
3933
|
prepare: (...args: unknown[]) => unknown;
|
|
@@ -3880,6 +3936,7 @@ declare const bridgeParamsWithChainIdentifierSchema: z.ZodObject<{
|
|
|
3880
3936
|
};
|
|
3881
3937
|
chain: never;
|
|
3882
3938
|
recipientAddress: string;
|
|
3939
|
+
address?: string | undefined;
|
|
3883
3940
|
};
|
|
3884
3941
|
amount: string;
|
|
3885
3942
|
token?: "USDC" | undefined;
|
|
@@ -3899,6 +3956,7 @@ declare const bridgeParamsWithChainIdentifierSchema: z.ZodObject<{
|
|
|
3899
3956
|
getAddress: (...args: unknown[]) => unknown;
|
|
3900
3957
|
};
|
|
3901
3958
|
chain: never;
|
|
3959
|
+
address?: string | undefined;
|
|
3902
3960
|
};
|
|
3903
3961
|
to: {
|
|
3904
3962
|
adapter: {
|
|
@@ -3907,6 +3965,7 @@ declare const bridgeParamsWithChainIdentifierSchema: z.ZodObject<{
|
|
|
3907
3965
|
getAddress: (...args: unknown[]) => unknown;
|
|
3908
3966
|
};
|
|
3909
3967
|
chain: never;
|
|
3968
|
+
address?: string | undefined;
|
|
3910
3969
|
} | {
|
|
3911
3970
|
adapter: {
|
|
3912
3971
|
prepare: (...args: unknown[]) => unknown;
|
|
@@ -3915,6 +3974,7 @@ declare const bridgeParamsWithChainIdentifierSchema: z.ZodObject<{
|
|
|
3915
3974
|
};
|
|
3916
3975
|
chain: never;
|
|
3917
3976
|
recipientAddress: string;
|
|
3977
|
+
address?: string | undefined;
|
|
3918
3978
|
};
|
|
3919
3979
|
amount: string;
|
|
3920
3980
|
token?: "USDC" | undefined;
|
|
@@ -4044,5 +4104,164 @@ declare class KitError extends Error implements ErrorDetails {
|
|
|
4044
4104
|
constructor(details: ErrorDetails);
|
|
4045
4105
|
}
|
|
4046
4106
|
|
|
4047
|
-
|
|
4107
|
+
/**
|
|
4108
|
+
* Type guard to check if an error is a KitError instance.
|
|
4109
|
+
*
|
|
4110
|
+
* This guard enables TypeScript to narrow the type from `unknown` to
|
|
4111
|
+
* `KitError`, providing access to structured error properties like
|
|
4112
|
+
* code, name, and recoverability.
|
|
4113
|
+
*
|
|
4114
|
+
* @param error - Unknown error to check
|
|
4115
|
+
* @returns True if error is KitError with proper type narrowing
|
|
4116
|
+
*
|
|
4117
|
+
* @example
|
|
4118
|
+
* ```typescript
|
|
4119
|
+
* import { isKitError } from '@core/errors'
|
|
4120
|
+
*
|
|
4121
|
+
* try {
|
|
4122
|
+
* await kit.bridge(params)
|
|
4123
|
+
* } catch (error) {
|
|
4124
|
+
* if (isKitError(error)) {
|
|
4125
|
+
* // TypeScript knows this is KitError
|
|
4126
|
+
* console.log(`Structured error: ${error.name} (${error.code})`)
|
|
4127
|
+
* } else {
|
|
4128
|
+
* console.log('Regular error:', error)
|
|
4129
|
+
* }
|
|
4130
|
+
* }
|
|
4131
|
+
* ```
|
|
4132
|
+
*/
|
|
4133
|
+
declare function isKitError(error: unknown): error is KitError;
|
|
4134
|
+
/**
|
|
4135
|
+
* Checks if an error is a KitError with FATAL recoverability.
|
|
4136
|
+
*
|
|
4137
|
+
* FATAL errors indicate issues that cannot be resolved through retries,
|
|
4138
|
+
* such as invalid inputs, configuration problems, or business rule
|
|
4139
|
+
* violations. These errors require user intervention to fix.
|
|
4140
|
+
*
|
|
4141
|
+
* @param error - Unknown error to check
|
|
4142
|
+
* @returns True if error is a KitError with FATAL recoverability
|
|
4143
|
+
*
|
|
4144
|
+
* @example
|
|
4145
|
+
* ```typescript
|
|
4146
|
+
* import { isFatalError } from '@core/errors'
|
|
4147
|
+
*
|
|
4148
|
+
* try {
|
|
4149
|
+
* await kit.bridge(params)
|
|
4150
|
+
* } catch (error) {
|
|
4151
|
+
* if (isFatalError(error)) {
|
|
4152
|
+
* // Show user-friendly error message - don't retry
|
|
4153
|
+
* showUserError(error.message)
|
|
4154
|
+
* }
|
|
4155
|
+
* }
|
|
4156
|
+
* ```
|
|
4157
|
+
*/
|
|
4158
|
+
declare function isFatalError(error: unknown): boolean;
|
|
4159
|
+
/**
|
|
4160
|
+
* Checks if an error is a KitError with RETRYABLE recoverability.
|
|
4161
|
+
*
|
|
4162
|
+
* RETRYABLE errors indicate transient failures that may succeed on
|
|
4163
|
+
* subsequent attempts, such as network timeouts or temporary service
|
|
4164
|
+
* unavailability. These errors are safe to retry after a delay.
|
|
4165
|
+
*
|
|
4166
|
+
* @param error - Unknown error to check
|
|
4167
|
+
* @returns True if error is a KitError with RETRYABLE recoverability
|
|
4168
|
+
*
|
|
4169
|
+
* @example
|
|
4170
|
+
* ```typescript
|
|
4171
|
+
* import { isRetryableError } from '@core/errors'
|
|
4172
|
+
*
|
|
4173
|
+
* try {
|
|
4174
|
+
* await kit.bridge(params)
|
|
4175
|
+
* } catch (error) {
|
|
4176
|
+
* if (isRetryableError(error)) {
|
|
4177
|
+
* // Implement retry logic with exponential backoff
|
|
4178
|
+
* setTimeout(() => retryOperation(), 5000)
|
|
4179
|
+
* }
|
|
4180
|
+
* }
|
|
4181
|
+
* ```
|
|
4182
|
+
*/
|
|
4183
|
+
declare function isRetryableError(error: unknown): boolean;
|
|
4184
|
+
/**
|
|
4185
|
+
* Combined type guard to check if error is KitError with INPUT type.
|
|
4186
|
+
*
|
|
4187
|
+
* INPUT errors have error codes in the 1000-1099 range and represent
|
|
4188
|
+
* validation failures, invalid parameters, or user input problems.
|
|
4189
|
+
* These errors are always FATAL and require the user to correct their
|
|
4190
|
+
* input before retrying.
|
|
4191
|
+
*
|
|
4192
|
+
* @param error - Unknown error to check
|
|
4193
|
+
* @returns True if error is KitError with INPUT error code range
|
|
4194
|
+
*
|
|
4195
|
+
* @example
|
|
4196
|
+
* ```typescript
|
|
4197
|
+
* import { isInputError } from '@core/errors'
|
|
4198
|
+
* import { createBridgeKit } from '@core/bridge'
|
|
4199
|
+
*
|
|
4200
|
+
* async function handleBridge() {
|
|
4201
|
+
* const kit = createBridgeKit(config)
|
|
4202
|
+
* const params = { amount: '100', from: 'ethereum', to: 'polygon' }
|
|
4203
|
+
*
|
|
4204
|
+
* try {
|
|
4205
|
+
* await kit.bridge(params)
|
|
4206
|
+
* } catch (error) {
|
|
4207
|
+
* if (isInputError(error)) {
|
|
4208
|
+
* console.log(`Input error: ${error.message} (code: ${error.code})`)
|
|
4209
|
+
* }
|
|
4210
|
+
* }
|
|
4211
|
+
* }
|
|
4212
|
+
* ```
|
|
4213
|
+
*/
|
|
4214
|
+
declare function isInputError(error: unknown): error is KitError;
|
|
4215
|
+
/**
|
|
4216
|
+
* Safely extracts error message from any error type.
|
|
4217
|
+
*
|
|
4218
|
+
* This utility handles different error types gracefully, extracting
|
|
4219
|
+
* meaningful messages from Error instances, string errors, or providing
|
|
4220
|
+
* a fallback for unknown error types. Never throws.
|
|
4221
|
+
*
|
|
4222
|
+
* @param error - Unknown error to extract message from
|
|
4223
|
+
* @returns Error message string, or fallback message
|
|
4224
|
+
*
|
|
4225
|
+
* @example
|
|
4226
|
+
* ```typescript
|
|
4227
|
+
* import { getErrorMessage } from '@core/errors'
|
|
4228
|
+
*
|
|
4229
|
+
* try {
|
|
4230
|
+
* await riskyOperation()
|
|
4231
|
+
* } catch (error) {
|
|
4232
|
+
* const message = getErrorMessage(error)
|
|
4233
|
+
* console.log('Error occurred:', message)
|
|
4234
|
+
* // Works with Error, KitError, string, or any other type
|
|
4235
|
+
* }
|
|
4236
|
+
* ```
|
|
4237
|
+
*/
|
|
4238
|
+
declare function getErrorMessage(error: unknown): string;
|
|
4239
|
+
/**
|
|
4240
|
+
* Gets the error code from a KitError, or null if not applicable.
|
|
4241
|
+
*
|
|
4242
|
+
* This utility safely extracts the numeric error code from KitError
|
|
4243
|
+
* instances, returning null for non-KitError types. Useful for
|
|
4244
|
+
* programmatic error handling based on specific error codes.
|
|
4245
|
+
*
|
|
4246
|
+
* @param error - Unknown error to extract code from
|
|
4247
|
+
* @returns Error code number, or null if not a KitError
|
|
4248
|
+
*
|
|
4249
|
+
* @example
|
|
4250
|
+
* ```typescript
|
|
4251
|
+
* import { getErrorCode, InputError } from '@core/errors'
|
|
4252
|
+
*
|
|
4253
|
+
* try {
|
|
4254
|
+
* await kit.bridge(params)
|
|
4255
|
+
* } catch (error) {
|
|
4256
|
+
* const code = getErrorCode(error)
|
|
4257
|
+
* if (code === InputError.NETWORK_MISMATCH.code) {
|
|
4258
|
+
* // Handle network mismatch specifically
|
|
4259
|
+
* showNetworkMismatchHelp()
|
|
4260
|
+
* }
|
|
4261
|
+
* }
|
|
4262
|
+
* ```
|
|
4263
|
+
*/
|
|
4264
|
+
declare function getErrorCode(error: unknown): number | null;
|
|
4265
|
+
|
|
4266
|
+
export { Blockchain, BridgeKit, KitError, bridgeParamsWithChainIdentifierSchema, getErrorCode, getErrorMessage, isFatalError, isInputError, isKitError, isRetryableError, setExternalPrefix };
|
|
4048
4267
|
export type { ActionHandler, BridgeKitConfig, BridgeParams, BridgeResult, ChainDefinition, ChainIdentifier, ErrorDetails, Recoverability };
|