@circle-fin/app-kit 1.14.0 → 1.15.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 +72 -0
- package/README.md +3 -3
- package/bridge.cjs +7464 -454
- package/bridge.d.cts +585 -61
- package/bridge.d.mts +585 -61
- package/bridge.d.ts +585 -61
- package/bridge.mjs +7464 -454
- package/chains.cjs +146 -5
- package/chains.d.cts +108 -2
- package/chains.d.mts +108 -2
- package/chains.d.ts +108 -2
- package/chains.mjs +146 -6
- package/context.d.cts +522 -57
- package/context.d.mts +522 -57
- package/context.d.ts +522 -57
- package/earn.cjs +478 -181
- package/earn.d.cts +522 -57
- package/earn.d.mts +522 -57
- package/earn.d.ts +522 -57
- package/earn.mjs +478 -181
- package/estimateBridge.cjs +7464 -457
- package/estimateBridge.d.cts +643 -82
- package/estimateBridge.d.mts +643 -82
- package/estimateBridge.d.ts +643 -82
- package/estimateBridge.mjs +7464 -457
- package/estimateSwap.cjs +528 -185
- package/estimateSwap.d.cts +522 -57
- package/estimateSwap.d.mts +522 -57
- package/estimateSwap.d.ts +522 -57
- package/estimateSwap.mjs +528 -185
- package/index.cjs +11548 -2936
- package/index.d.cts +5073 -1738
- package/index.d.mts +5073 -1738
- package/index.d.ts +5073 -1738
- package/index.mjs +11547 -2937
- package/package.json +17 -6
- package/server.cjs +10040 -0
- package/server.cjs.map +1 -0
- package/server.d.cts +2467 -0
- package/server.d.mts +2467 -0
- package/server.d.ts +2467 -0
- package/server.mjs +10028 -0
- package/server.mjs.map +1 -0
- package/swap.cjs +528 -185
- package/swap.d.cts +522 -57
- package/swap.d.mts +522 -57
- package/swap.d.ts +522 -57
- package/swap.mjs +528 -185
- package/unifiedBalance.cjs +742 -44
- package/unifiedBalance.d.cts +223 -1
- package/unifiedBalance.d.mts +223 -1
- package/unifiedBalance.d.ts +223 -1
- package/unifiedBalance.mjs +742 -44
package/earn.mjs
CHANGED
|
@@ -859,8 +859,7 @@ class KitError extends Error {
|
|
|
859
859
|
code: 8002,
|
|
860
860
|
name: 'SERVICE_UNKNOWN_ERROR',
|
|
861
861
|
type: 'SERVICE'
|
|
862
|
-
}
|
|
863
|
-
};
|
|
862
|
+
}};
|
|
864
863
|
|
|
865
864
|
/**
|
|
866
865
|
* Creates error for network type mismatch between source and destination.
|
|
@@ -1047,7 +1046,7 @@ class KitError extends Error {
|
|
|
1047
1046
|
* import { createValidationErrorFromZod } from '@core/errors'
|
|
1048
1047
|
*
|
|
1049
1048
|
* function validateBridgeParams(params: unknown): asserts params is BridgeParams {
|
|
1050
|
-
* const result =
|
|
1049
|
+
* const result = usdcBridgeParamsSchema.safeParse(params)
|
|
1051
1050
|
* if (!result.success) {
|
|
1052
1051
|
* throw createValidationErrorFromZod(result.error, 'bridge parameters')
|
|
1053
1052
|
* }
|
|
@@ -2308,9 +2307,10 @@ function getOptionalString(value) {
|
|
|
2308
2307
|
Blockchain["Algorand_Testnet"] = "Algorand_Testnet";
|
|
2309
2308
|
Blockchain["Aptos"] = "Aptos";
|
|
2310
2309
|
Blockchain["Aptos_Testnet"] = "Aptos_Testnet";
|
|
2311
|
-
Blockchain["Arc_Testnet"] = "Arc_Testnet";
|
|
2312
2310
|
Blockchain["Arbitrum"] = "Arbitrum";
|
|
2313
2311
|
Blockchain["Arbitrum_Sepolia"] = "Arbitrum_Sepolia";
|
|
2312
|
+
Blockchain["Arc"] = "Arc";
|
|
2313
|
+
Blockchain["Arc_Testnet"] = "Arc_Testnet";
|
|
2314
2314
|
Blockchain["Avalanche"] = "Avalanche";
|
|
2315
2315
|
Blockchain["Avalanche_Fuji"] = "Avalanche_Fuji";
|
|
2316
2316
|
Blockchain["Base"] = "Base";
|
|
@@ -2397,6 +2397,7 @@ var SwapChain;
|
|
|
2397
2397
|
SwapChain["XDC"] = "XDC";
|
|
2398
2398
|
SwapChain["HyperEVM"] = "HyperEVM";
|
|
2399
2399
|
SwapChain["Monad"] = "Monad";
|
|
2400
|
+
SwapChain["Arc"] = "Arc";
|
|
2400
2401
|
// Testnet chains with swap support
|
|
2401
2402
|
SwapChain["Arc_Testnet"] = "Arc_Testnet";
|
|
2402
2403
|
})(SwapChain || (SwapChain = {}));
|
|
@@ -2404,6 +2405,7 @@ var BridgeChain;
|
|
|
2404
2405
|
(function(BridgeChain) {
|
|
2405
2406
|
// Mainnet chains with CCTPv2 support
|
|
2406
2407
|
BridgeChain["Arbitrum"] = "Arbitrum";
|
|
2408
|
+
BridgeChain["Arc"] = "Arc";
|
|
2407
2409
|
BridgeChain["Avalanche"] = "Avalanche";
|
|
2408
2410
|
BridgeChain["Base"] = "Base";
|
|
2409
2411
|
BridgeChain["Codex"] = "Codex";
|
|
@@ -2459,6 +2461,7 @@ var BridgeChain;
|
|
|
2459
2461
|
var UnifiedBalanceChain;
|
|
2460
2462
|
(function(UnifiedBalanceChain) {
|
|
2461
2463
|
// Mainnet chains with Gateway V1 support
|
|
2464
|
+
UnifiedBalanceChain["Arc"] = "Arc";
|
|
2462
2465
|
UnifiedBalanceChain["Arbitrum"] = "Arbitrum";
|
|
2463
2466
|
UnifiedBalanceChain["Avalanche"] = "Avalanche";
|
|
2464
2467
|
UnifiedBalanceChain["Base"] = "Base";
|
|
@@ -2488,6 +2491,7 @@ var UnifiedBalanceChain;
|
|
|
2488
2491
|
})(UnifiedBalanceChain || (UnifiedBalanceChain = {}));
|
|
2489
2492
|
var EarnChain;
|
|
2490
2493
|
(function(EarnChain) {
|
|
2494
|
+
EarnChain["Arc"] = "Arc";
|
|
2491
2495
|
EarnChain["Arc_Testnet"] = "Arc_Testnet";
|
|
2492
2496
|
})(EarnChain || (EarnChain = {}));
|
|
2493
2497
|
/**
|
|
@@ -2504,8 +2508,11 @@ var EarnChain;
|
|
|
2504
2508
|
* console.log(EARN_BRIDGE_SOURCE_BLOCKCHAINS.join(', '))
|
|
2505
2509
|
* ```
|
|
2506
2510
|
*/ const EARN_BRIDGE_SOURCE_BLOCKCHAINS = [
|
|
2511
|
+
"Arbitrum",
|
|
2507
2512
|
"Arbitrum_Sepolia",
|
|
2513
|
+
"Base",
|
|
2508
2514
|
"Base_Sepolia",
|
|
2515
|
+
"Ethereum",
|
|
2509
2516
|
"Ethereum_Sepolia"
|
|
2510
2517
|
];
|
|
2511
2518
|
/**
|
|
@@ -2519,6 +2526,7 @@ var EarnChain;
|
|
|
2519
2526
|
* console.log(EARN_BRIDGE_DESTINATION_BLOCKCHAINS.join(', '))
|
|
2520
2527
|
* ```
|
|
2521
2528
|
*/ const EARN_BRIDGE_DESTINATION_BLOCKCHAINS = [
|
|
2529
|
+
"Arc",
|
|
2522
2530
|
"Arc_Testnet"
|
|
2523
2531
|
];
|
|
2524
2532
|
|
|
@@ -2824,6 +2832,25 @@ var EarnChain;
|
|
|
2824
2832
|
* EVM-compatible chains. Use this address when deploying or testing
|
|
2825
2833
|
* cross-chain USDC transfers on test networks.
|
|
2826
2834
|
*/ const BRIDGE_CONTRACT_EVM_TESTNET = '0xC5567a5E3370d4DBfB0540025078e283e36A363d';
|
|
2835
|
+
/**
|
|
2836
|
+
* The CrossChainTokenService (CCTPx) service address for EVM testnet networks.
|
|
2837
|
+
*
|
|
2838
|
+
* This service coordinates CCTPx cross-chain token operations on testnet
|
|
2839
|
+
* environments and is shared by every EVM test network CCTPx supports. Read the
|
|
2840
|
+
* chain definitions via `isCCTPXSupported` rather than trusting a list here,
|
|
2841
|
+
* which goes stale as deployments land.
|
|
2842
|
+
*/ const CCTPX_SERVICE_ADDRESS_EVM_TESTNET = '0x63753E722bd2C2A5DF6EE19C5106662208B81077';
|
|
2843
|
+
/**
|
|
2844
|
+
* CrossChainTokenService (CCTS) proxy address for CCTPx on EVM **mainnet**.
|
|
2845
|
+
*
|
|
2846
|
+
* @remarks
|
|
2847
|
+
* A distinct deployment from {@link CCTPX_SERVICE_ADDRESS_EVM_TESTNET}, shared
|
|
2848
|
+
* by every EVM mainnet chain that CCTPx supports. A chain becomes
|
|
2849
|
+
* CCTPx-eligible only once its definition carries this as
|
|
2850
|
+
* `cctpx.serviceAddress`, and a route additionally needs both of its endpoints
|
|
2851
|
+
* eligible — so adding a chain here is the deliberate, reviewable step that
|
|
2852
|
+
* opens mainnet CCTPx for it.
|
|
2853
|
+
*/ const CCTPX_SERVICE_ADDRESS_EVM_MAINNET = '0x431871229103b780868f8C6BB820cd16ECf942BC';
|
|
2827
2854
|
/**
|
|
2828
2855
|
* The bridge contract address for EVM mainnet networks.
|
|
2829
2856
|
*
|
|
@@ -2932,6 +2959,76 @@ var EarnChain;
|
|
|
2932
2959
|
* Identical across all testnet EVM destination chains.
|
|
2933
2960
|
*/ const GENERIC_EXECUTOR_EVM_TESTNET = '0xEdC81040756AcCfF070c21D37b265b9D0b5Ba45e';
|
|
2934
2961
|
|
|
2962
|
+
/**
|
|
2963
|
+
* Arc Mainnet chain definition
|
|
2964
|
+
* @remarks
|
|
2965
|
+
* This represents the official production network for the Arc blockchain,
|
|
2966
|
+
* Circle's EVM-compatible Layer-1 designed for stablecoin finance
|
|
2967
|
+
* and asset tokenization. Arc uses USDC as the native gas token and
|
|
2968
|
+
* features the Malachite Byzantine Fault Tolerant (BFT) consensus
|
|
2969
|
+
* engine for sub-second finality.
|
|
2970
|
+
*/ const Arc = defineChain({
|
|
2971
|
+
type: 'evm',
|
|
2972
|
+
chain: Blockchain.Arc,
|
|
2973
|
+
name: 'Arc',
|
|
2974
|
+
title: 'Arc Mainnet',
|
|
2975
|
+
nativeCurrency: {
|
|
2976
|
+
name: 'USDC',
|
|
2977
|
+
symbol: 'USDC',
|
|
2978
|
+
// Arc uses native USDC with 18 decimals for gas payments (EVM standard).
|
|
2979
|
+
// Note: The ERC-20 USDC contract at usdcAddress uses 6 decimals.
|
|
2980
|
+
// See: https://docs.arc.network/arc/references/contract-addresses
|
|
2981
|
+
decimals: 18
|
|
2982
|
+
},
|
|
2983
|
+
chainId: 5042,
|
|
2984
|
+
isTestnet: false,
|
|
2985
|
+
explorerUrl: 'https://explorer.arc.io/tx/{hash}',
|
|
2986
|
+
rpcEndpoints: [
|
|
2987
|
+
'https://rpc.mainnet.arc.io/'
|
|
2988
|
+
],
|
|
2989
|
+
eurcAddress: '0xbEf5f6d51CB62b58e6A8f77868681825C6fe21c1',
|
|
2990
|
+
usdcAddress: '0x3600000000000000000000000000000000000000',
|
|
2991
|
+
usdtAddress: null,
|
|
2992
|
+
cctp: {
|
|
2993
|
+
domain: 26,
|
|
2994
|
+
contracts: {
|
|
2995
|
+
v2: {
|
|
2996
|
+
type: 'split',
|
|
2997
|
+
tokenMessenger: '0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d',
|
|
2998
|
+
messageTransmitter: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',
|
|
2999
|
+
confirmations: 1,
|
|
3000
|
+
fastConfirmations: 1
|
|
3001
|
+
}
|
|
3002
|
+
},
|
|
3003
|
+
forwarderSupported: {
|
|
3004
|
+
source: false,
|
|
3005
|
+
destination: true
|
|
3006
|
+
}
|
|
3007
|
+
},
|
|
3008
|
+
cctpx: {
|
|
3009
|
+
serviceAddress: CCTPX_SERVICE_ADDRESS_EVM_MAINNET
|
|
3010
|
+
},
|
|
3011
|
+
kitContracts: {
|
|
3012
|
+
bridge: BRIDGE_CONTRACT_EVM_MAINNET,
|
|
3013
|
+
adapter: ADAPTER_CONTRACT_EVM_MAINNET
|
|
3014
|
+
},
|
|
3015
|
+
gateway: {
|
|
3016
|
+
domain: 26,
|
|
3017
|
+
contracts: {
|
|
3018
|
+
v1: {
|
|
3019
|
+
wallet: GATEWAY_WALLET_EVM_MAINNET,
|
|
3020
|
+
minter: GATEWAY_MINTER_EVM_MAINNET,
|
|
3021
|
+
depositForHandler: DEPOSIT_FOR_HANDLER_EVM_MAINNET,
|
|
3022
|
+
genericExecutor: GENERIC_EXECUTOR_EVM_MAINNET
|
|
3023
|
+
}
|
|
3024
|
+
},
|
|
3025
|
+
forwarderSupported: {
|
|
3026
|
+
source: true,
|
|
3027
|
+
destination: true
|
|
3028
|
+
}
|
|
3029
|
+
}
|
|
3030
|
+
});
|
|
3031
|
+
|
|
2935
3032
|
/**
|
|
2936
3033
|
* Arc Testnet chain definition
|
|
2937
3034
|
* @remarks
|
|
@@ -2979,6 +3076,9 @@ var EarnChain;
|
|
|
2979
3076
|
destination: true
|
|
2980
3077
|
}
|
|
2981
3078
|
},
|
|
3079
|
+
cctpx: {
|
|
3080
|
+
serviceAddress: CCTPX_SERVICE_ADDRESS_EVM_TESTNET
|
|
3081
|
+
},
|
|
2982
3082
|
kitContracts: {
|
|
2983
3083
|
bridge: BRIDGE_CONTRACT_EVM_TESTNET,
|
|
2984
3084
|
adapter: ADAPTER_CONTRACT_EVM_TESTNET
|
|
@@ -3046,6 +3146,9 @@ var EarnChain;
|
|
|
3046
3146
|
destination: true
|
|
3047
3147
|
}
|
|
3048
3148
|
},
|
|
3149
|
+
cctpx: {
|
|
3150
|
+
serviceAddress: CCTPX_SERVICE_ADDRESS_EVM_MAINNET
|
|
3151
|
+
},
|
|
3049
3152
|
kitContracts: {
|
|
3050
3153
|
bridge: BRIDGE_CONTRACT_EVM_MAINNET,
|
|
3051
3154
|
adapter: ADAPTER_CONTRACT_EVM_MAINNET
|
|
@@ -3111,6 +3214,9 @@ var EarnChain;
|
|
|
3111
3214
|
destination: true
|
|
3112
3215
|
}
|
|
3113
3216
|
},
|
|
3217
|
+
cctpx: {
|
|
3218
|
+
serviceAddress: CCTPX_SERVICE_ADDRESS_EVM_TESTNET
|
|
3219
|
+
},
|
|
3114
3220
|
kitContracts: {
|
|
3115
3221
|
bridge: BRIDGE_CONTRACT_EVM_TESTNET,
|
|
3116
3222
|
adapter: ADAPTER_CONTRACT_EVM_TESTNET
|
|
@@ -3176,6 +3282,9 @@ var EarnChain;
|
|
|
3176
3282
|
destination: true
|
|
3177
3283
|
}
|
|
3178
3284
|
},
|
|
3285
|
+
cctpx: {
|
|
3286
|
+
serviceAddress: CCTPX_SERVICE_ADDRESS_EVM_MAINNET
|
|
3287
|
+
},
|
|
3179
3288
|
kitContracts: {
|
|
3180
3289
|
bridge: BRIDGE_CONTRACT_EVM_MAINNET,
|
|
3181
3290
|
adapter: ADAPTER_CONTRACT_EVM_MAINNET
|
|
@@ -3243,6 +3352,9 @@ var EarnChain;
|
|
|
3243
3352
|
rpcEndpoints: [
|
|
3244
3353
|
'https://api.avax-test.network/ext/bc/C/rpc'
|
|
3245
3354
|
],
|
|
3355
|
+
cctpx: {
|
|
3356
|
+
serviceAddress: CCTPX_SERVICE_ADDRESS_EVM_TESTNET
|
|
3357
|
+
},
|
|
3246
3358
|
kitContracts: {
|
|
3247
3359
|
bridge: BRIDGE_CONTRACT_EVM_TESTNET
|
|
3248
3360
|
},
|
|
@@ -3310,6 +3422,9 @@ var EarnChain;
|
|
|
3310
3422
|
destination: true
|
|
3311
3423
|
}
|
|
3312
3424
|
},
|
|
3425
|
+
cctpx: {
|
|
3426
|
+
serviceAddress: CCTPX_SERVICE_ADDRESS_EVM_MAINNET
|
|
3427
|
+
},
|
|
3313
3428
|
kitContracts: {
|
|
3314
3429
|
bridge: BRIDGE_CONTRACT_EVM_MAINNET,
|
|
3315
3430
|
adapter: ADAPTER_CONTRACT_EVM_MAINNET
|
|
@@ -3375,6 +3490,9 @@ var EarnChain;
|
|
|
3375
3490
|
destination: true
|
|
3376
3491
|
}
|
|
3377
3492
|
},
|
|
3493
|
+
cctpx: {
|
|
3494
|
+
serviceAddress: CCTPX_SERVICE_ADDRESS_EVM_TESTNET
|
|
3495
|
+
},
|
|
3378
3496
|
kitContracts: {
|
|
3379
3497
|
bridge: BRIDGE_CONTRACT_EVM_TESTNET,
|
|
3380
3498
|
adapter: ADAPTER_CONTRACT_EVM_TESTNET
|
|
@@ -3767,6 +3885,9 @@ var EarnChain;
|
|
|
3767
3885
|
destination: true
|
|
3768
3886
|
}
|
|
3769
3887
|
},
|
|
3888
|
+
cctpx: {
|
|
3889
|
+
serviceAddress: CCTPX_SERVICE_ADDRESS_EVM_MAINNET
|
|
3890
|
+
},
|
|
3770
3891
|
kitContracts: {
|
|
3771
3892
|
bridge: BRIDGE_CONTRACT_EVM_MAINNET,
|
|
3772
3893
|
adapter: ADAPTER_CONTRACT_EVM_MAINNET
|
|
@@ -3832,6 +3953,9 @@ var EarnChain;
|
|
|
3832
3953
|
destination: true
|
|
3833
3954
|
}
|
|
3834
3955
|
},
|
|
3956
|
+
cctpx: {
|
|
3957
|
+
serviceAddress: CCTPX_SERVICE_ADDRESS_EVM_TESTNET
|
|
3958
|
+
},
|
|
3835
3959
|
kitContracts: {
|
|
3836
3960
|
bridge: BRIDGE_CONTRACT_EVM_TESTNET,
|
|
3837
3961
|
adapter: ADAPTER_CONTRACT_EVM_TESTNET
|
|
@@ -4663,6 +4787,9 @@ var EarnChain;
|
|
|
4663
4787
|
destination: true
|
|
4664
4788
|
}
|
|
4665
4789
|
},
|
|
4790
|
+
cctpx: {
|
|
4791
|
+
serviceAddress: CCTPX_SERVICE_ADDRESS_EVM_MAINNET
|
|
4792
|
+
},
|
|
4666
4793
|
kitContracts: {
|
|
4667
4794
|
bridge: BRIDGE_CONTRACT_EVM_MAINNET,
|
|
4668
4795
|
adapter: ADAPTER_CONTRACT_EVM_MAINNET
|
|
@@ -4728,6 +4855,9 @@ var EarnChain;
|
|
|
4728
4855
|
destination: true
|
|
4729
4856
|
}
|
|
4730
4857
|
},
|
|
4858
|
+
cctpx: {
|
|
4859
|
+
serviceAddress: CCTPX_SERVICE_ADDRESS_EVM_TESTNET
|
|
4860
|
+
},
|
|
4731
4861
|
kitContracts: {
|
|
4732
4862
|
bridge: BRIDGE_CONTRACT_EVM_TESTNET
|
|
4733
4863
|
},
|
|
@@ -5123,6 +5253,9 @@ var EarnChain;
|
|
|
5123
5253
|
destination: true
|
|
5124
5254
|
}
|
|
5125
5255
|
},
|
|
5256
|
+
cctpx: {
|
|
5257
|
+
serviceAddress: CCTPX_SERVICE_ADDRESS_EVM_MAINNET
|
|
5258
|
+
},
|
|
5126
5259
|
kitContracts: {
|
|
5127
5260
|
bridge: BRIDGE_CONTRACT_EVM_MAINNET,
|
|
5128
5261
|
adapter: ADAPTER_CONTRACT_EVM_MAINNET
|
|
@@ -5191,6 +5324,9 @@ var EarnChain;
|
|
|
5191
5324
|
destination: true
|
|
5192
5325
|
}
|
|
5193
5326
|
},
|
|
5327
|
+
cctpx: {
|
|
5328
|
+
serviceAddress: CCTPX_SERVICE_ADDRESS_EVM_TESTNET
|
|
5329
|
+
},
|
|
5194
5330
|
kitContracts: {
|
|
5195
5331
|
bridge: BRIDGE_CONTRACT_EVM_TESTNET
|
|
5196
5332
|
},
|
|
@@ -6199,6 +6335,7 @@ var Chains = /*#__PURE__*/Object.freeze({
|
|
|
6199
6335
|
AptosTestnet: AptosTestnet,
|
|
6200
6336
|
Arbitrum: Arbitrum,
|
|
6201
6337
|
ArbitrumSepolia: ArbitrumSepolia,
|
|
6338
|
+
Arc: Arc,
|
|
6202
6339
|
ArcTestnet: ArcTestnet,
|
|
6203
6340
|
Avalanche: Avalanche,
|
|
6204
6341
|
AvalancheFuji: AvalancheFuji,
|
|
@@ -6456,6 +6593,7 @@ var Chains = /*#__PURE__*/Object.freeze({
|
|
|
6456
6593
|
usdcAddress: z.string().nullable(),
|
|
6457
6594
|
usdtAddress: z.string().nullable(),
|
|
6458
6595
|
cctp: z.any().nullable(),
|
|
6596
|
+
cctpx: z.any().optional(),
|
|
6459
6597
|
kitContracts: z.object({
|
|
6460
6598
|
bridge: z.string().optional(),
|
|
6461
6599
|
adapter: z.string().optional()
|
|
@@ -6661,14 +6799,15 @@ const EARN_BRIDGE_DESTINATION_CHAIN_VALUES = EARN_BRIDGE_DESTINATION_BLOCKCHAINS
|
|
|
6661
6799
|
* Zod schema for validating the source chain of a cross-chain Earn deposit.
|
|
6662
6800
|
*
|
|
6663
6801
|
* Accept a supported source Blockchain value, a matching string literal, or a
|
|
6664
|
-
* ChainDefinition for a supported source chain. Source chains are Ethereum
|
|
6665
|
-
*
|
|
6802
|
+
* ChainDefinition for a supported source chain. Source chains are Ethereum,
|
|
6803
|
+
* Arbitrum, and Base (mainnet and testnet).
|
|
6666
6804
|
*
|
|
6667
6805
|
* @example
|
|
6668
6806
|
* ```typescript
|
|
6669
6807
|
* import { earnBridgeSourceChainIdentifierSchema } from '@core/chains'
|
|
6670
6808
|
*
|
|
6671
6809
|
* // Valid
|
|
6810
|
+
* earnBridgeSourceChainIdentifierSchema.parse('Ethereum')
|
|
6672
6811
|
* earnBridgeSourceChainIdentifierSchema.parse('Ethereum_Sepolia')
|
|
6673
6812
|
*
|
|
6674
6813
|
* // Invalid (throws ZodError)
|
|
@@ -6687,14 +6826,15 @@ const EARN_BRIDGE_DESTINATION_CHAIN_VALUES = EARN_BRIDGE_DESTINATION_BLOCKCHAINS
|
|
|
6687
6826
|
* deposit.
|
|
6688
6827
|
*
|
|
6689
6828
|
* Accept a supported destination Blockchain value, a matching string literal,
|
|
6690
|
-
* or a ChainDefinition for a supported destination chain.
|
|
6691
|
-
* Testnet
|
|
6829
|
+
* or a ChainDefinition for a supported destination chain. Arc (mainnet) and
|
|
6830
|
+
* Arc Testnet are supported.
|
|
6692
6831
|
*
|
|
6693
6832
|
* @example
|
|
6694
6833
|
* ```typescript
|
|
6695
6834
|
* import { earnBridgeDestinationChainIdentifierSchema } from '@core/chains'
|
|
6696
6835
|
*
|
|
6697
6836
|
* // Valid
|
|
6837
|
+
* earnBridgeDestinationChainIdentifierSchema.parse('Arc')
|
|
6698
6838
|
* earnBridgeDestinationChainIdentifierSchema.parse('Arc_Testnet')
|
|
6699
6839
|
*
|
|
6700
6840
|
* // Invalid (throws ZodError)
|
|
@@ -7740,6 +7880,7 @@ const swapTokenEnumSchema = z.enum([
|
|
|
7740
7880
|
// Mainnets (alphabetically sorted)
|
|
7741
7881
|
// =========================================================================
|
|
7742
7882
|
[Blockchain.Arbitrum]: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
|
|
7883
|
+
[Blockchain.Arc]: '0x3600000000000000000000000000000000000000',
|
|
7743
7884
|
[Blockchain.Avalanche]: '0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E',
|
|
7744
7885
|
[Blockchain.Base]: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
|
|
7745
7886
|
[Blockchain.Celo]: '0xcebA9300f2b948710d2653dD7B07f33A8B32118C',
|
|
@@ -7854,6 +7995,7 @@ const swapTokenEnumSchema = z.enum([
|
|
|
7854
7995
|
// =========================================================================
|
|
7855
7996
|
// Mainnets
|
|
7856
7997
|
// =========================================================================
|
|
7998
|
+
[Blockchain.Arc]: '0xbEf5f6d51CB62b58e6A8f77868681825C6fe21c1',
|
|
7857
7999
|
[Blockchain.Avalanche]: '0xc891EB4cbdEFf6e073e859e987815Ed1505c2ACD',
|
|
7858
8000
|
[Blockchain.Base]: '0x60a3E35Cc302bFA44Cb288Bc5a4F316Fdb1adb42',
|
|
7859
8001
|
[Blockchain.Cronos]: '0xA6dE01a2d62C6B5f3525d768f34d276652C554c8',
|
|
@@ -8097,6 +8239,7 @@ const swapTokenEnumSchema = z.enum([
|
|
|
8097
8239
|
// =========================================================================
|
|
8098
8240
|
// Mainnets
|
|
8099
8241
|
// =========================================================================
|
|
8242
|
+
[Blockchain.Arc]: '0x171A4217b86A807A64eB94757Db6849fb4bDbAA0',
|
|
8100
8243
|
[Blockchain.Ethereum]: '0x72DFB2E44f59C5AD2bAFE84314E5b99a7cd5075E',
|
|
8101
8244
|
// =========================================================================
|
|
8102
8245
|
// Testnets
|
|
@@ -8189,13 +8332,28 @@ const swapTokenEnumSchema = z.enum([
|
|
|
8189
8332
|
}
|
|
8190
8333
|
|
|
8191
8334
|
/**
|
|
8192
|
-
*
|
|
8335
|
+
* Type guard: narrows a {@link TokenSelector} to a {@link RawTokenSelector}.
|
|
8193
8336
|
*
|
|
8194
8337
|
* @param selector - The token selector to check.
|
|
8195
|
-
* @returns
|
|
8338
|
+
* @returns `true` if `selector` is a raw token selector (object with `locator`).
|
|
8339
|
+
*
|
|
8340
|
+
* @example
|
|
8341
|
+
* ```typescript
|
|
8342
|
+
* if (isRawSelector(selector)) {
|
|
8343
|
+
* console.log(selector.locator)
|
|
8344
|
+
* }
|
|
8345
|
+
* ```
|
|
8196
8346
|
*/ function isRawSelector(selector) {
|
|
8197
|
-
|
|
8347
|
+
// `typeof null === 'object'` (a JS quirk) and `'locator' in null`
|
|
8348
|
+
// throws, so the explicit `null` check is required at this exported
|
|
8349
|
+
// guard for JS consumers passing nullish values. The lint rule sees
|
|
8350
|
+
// the parameter typed as `TokenSelector` (no null) and flags the
|
|
8351
|
+
// check as unnecessary — disabled because the check IS necessary at
|
|
8352
|
+
// runtime even though TypeScript can prove it dead statically.
|
|
8353
|
+
return typeof selector === 'object' && // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
8354
|
+
selector !== null && 'locator' in selector;
|
|
8198
8355
|
}
|
|
8356
|
+
|
|
8199
8357
|
/**
|
|
8200
8358
|
* Normalize a symbol to uppercase for case-insensitive lookup.
|
|
8201
8359
|
*
|
|
@@ -8383,7 +8541,7 @@ const swapTokenEnumSchema = z.enum([
|
|
|
8383
8541
|
if (typeof selector === 'string') {
|
|
8384
8542
|
return resolveSymbol(selector, chainId);
|
|
8385
8543
|
}
|
|
8386
|
-
throw createTokenResolutionError(`Invalid selector type: ${typeof selector}. Expected
|
|
8544
|
+
throw createTokenResolutionError(`Invalid selector type: ${typeof selector}. Expected a token symbol or a raw selector (with locator).`, selector, chainId);
|
|
8387
8545
|
},
|
|
8388
8546
|
resolveByAddress (address, chainId) {
|
|
8389
8547
|
if (!address || typeof address !== 'string') {
|
|
@@ -8971,7 +9129,7 @@ const swapTokenEnumSchema = z.enum([
|
|
|
8971
9129
|
}
|
|
8972
9130
|
|
|
8973
9131
|
var name$3 = "@circle-fin/bridge-kit";
|
|
8974
|
-
var version$3 = "1.
|
|
9132
|
+
var version$3 = "1.15.0";
|
|
8975
9133
|
var pkg$3 = {
|
|
8976
9134
|
name: name$3,
|
|
8977
9135
|
version: version$3};
|
|
@@ -9591,7 +9749,72 @@ var TransferSpeed;
|
|
|
9591
9749
|
*/ recipientAddress: z.string().trim().min(1, 'Fee recipient must be a non-empty string').optional()
|
|
9592
9750
|
}).strict();
|
|
9593
9751
|
/**
|
|
9594
|
-
*
|
|
9752
|
+
* Factory for the bridge-params Zod schema, parameterized by the token
|
|
9753
|
+
* validator. The base schema enforces all non-token fields (amount,
|
|
9754
|
+
* source, destination, config); callers supply the Zod schema for the
|
|
9755
|
+
* `token` field, allowing each provider to validate the token type it
|
|
9756
|
+
* accepts.
|
|
9757
|
+
*
|
|
9758
|
+
* @param tokenSchema - Zod schema applied to the `token` field. Pass
|
|
9759
|
+
* `z.literal('USDC')` for USDC-only validation, or any
|
|
9760
|
+
* provider-specific schema (e.g. a `0x`-prefixed hex regex) for
|
|
9761
|
+
* providers that accept a different token type.
|
|
9762
|
+
* @param config - Required. `maxDecimals` caps the decimal precision
|
|
9763
|
+
* permitted in `amount` and `config.maxFee`. Pass the widest value
|
|
9764
|
+
* any of the provider's tokens require — `6` for USDC-only, `18`
|
|
9765
|
+
* for an ERC-20 family that includes wETH, etc. The schema is a
|
|
9766
|
+
* coarse syntactic gate; narrower per-token precision is enforced
|
|
9767
|
+
* by the provider downstream.
|
|
9768
|
+
* @returns A Zod object schema whose `token` field is validated by
|
|
9769
|
+
* `tokenSchema` and whose other fields (`amount`, `source`,
|
|
9770
|
+
* `destination`, `config`) are validated against the shared bridge
|
|
9771
|
+
* contract. Use `.safeParse` / `.parse` directly, or feed the schema
|
|
9772
|
+
* to {@link parseOrThrow} from `@core/utils` to surface validation
|
|
9773
|
+
* failures as `KitError` with the canonical
|
|
9774
|
+
* `INPUT_VALIDATION_FAILED` code.
|
|
9775
|
+
*
|
|
9776
|
+
* @example
|
|
9777
|
+
* ```typescript
|
|
9778
|
+
* import { createBridgeParamsSchema, z } from '@core/provider'
|
|
9779
|
+
*
|
|
9780
|
+
* const usdcSchema = createBridgeParamsSchema(z.literal('USDC'), { maxDecimals: 6 })
|
|
9781
|
+
* const hexSchema = createBridgeParamsSchema(
|
|
9782
|
+
* z.string().regex(/^0x[0-9a-fA-F]{64}$/),
|
|
9783
|
+
* { maxDecimals: 18 },
|
|
9784
|
+
* )
|
|
9785
|
+
* ```
|
|
9786
|
+
*/ // The full inferred return type of `z.object({...})` here is
|
|
9787
|
+
// effectively impossible to spell out by hand without re-stating every
|
|
9788
|
+
// field's schema. TypeScript infers it from the body — callers receive
|
|
9789
|
+
// a precise Zod schema type via inference, and the explicit-return
|
|
9790
|
+
// rules are disabled for that reason.
|
|
9791
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/explicit-module-boundary-types
|
|
9792
|
+
function createBridgeParamsSchema(tokenSchema, config) {
|
|
9793
|
+
const { maxDecimals } = config;
|
|
9794
|
+
return z.object({
|
|
9795
|
+
amount: z.string().min(1, 'Required').pipe(createDecimalStringValidator({
|
|
9796
|
+
allowZero: false,
|
|
9797
|
+
regexMessage: AMOUNT_FORMAT_ERROR_MESSAGE,
|
|
9798
|
+
attributeName: 'amount',
|
|
9799
|
+
maxDecimals
|
|
9800
|
+
})(z.string())),
|
|
9801
|
+
source: walletContextSchema,
|
|
9802
|
+
destination: bridgeDestinationSchema$1,
|
|
9803
|
+
token: tokenSchema,
|
|
9804
|
+
config: z.object({
|
|
9805
|
+
transferSpeed: z.nativeEnum(TransferSpeed).optional(),
|
|
9806
|
+
maxFee: z.string().pipe(createDecimalStringValidator({
|
|
9807
|
+
allowZero: true,
|
|
9808
|
+
regexMessage: MAX_FEE_FORMAT_ERROR_MESSAGE,
|
|
9809
|
+
attributeName: 'maxFee',
|
|
9810
|
+
maxDecimals
|
|
9811
|
+
})(z.string())).optional(),
|
|
9812
|
+
customFee: customFeeSchema.optional()
|
|
9813
|
+
})
|
|
9814
|
+
});
|
|
9815
|
+
}
|
|
9816
|
+
/**
|
|
9817
|
+
* Schema for validating bridge parameters with USDC as the token.
|
|
9595
9818
|
* This ensures all required fields are present and properly typed.
|
|
9596
9819
|
* A bridge must include:
|
|
9597
9820
|
* - A valid amount (non-empty numeric string \> 0)
|
|
@@ -9599,11 +9822,15 @@ var TransferSpeed;
|
|
|
9599
9822
|
* - USDC as the token
|
|
9600
9823
|
* - Optional config with transfer speed and max fee settings
|
|
9601
9824
|
*
|
|
9825
|
+
* Providers that accept a non-USDC token type should call
|
|
9826
|
+
* {@link createBridgeParamsSchema} with their own token schema rather
|
|
9827
|
+
* than reusing this constant.
|
|
9828
|
+
*
|
|
9602
9829
|
* @throws KitError if validation fails
|
|
9603
9830
|
*
|
|
9604
9831
|
* @example
|
|
9605
9832
|
* ```typescript
|
|
9606
|
-
* import {
|
|
9833
|
+
* import { usdcBridgeParamsSchema } from '@core/provider'
|
|
9607
9834
|
*
|
|
9608
9835
|
* const validBridge = {
|
|
9609
9836
|
* amount: '100.50',
|
|
@@ -9628,175 +9855,43 @@ var TransferSpeed;
|
|
|
9628
9855
|
* }
|
|
9629
9856
|
* }
|
|
9630
9857
|
*
|
|
9631
|
-
* const result =
|
|
9858
|
+
* const result = usdcBridgeParamsSchema.safeParse(validBridge)
|
|
9632
9859
|
* console.log(result.success) // true
|
|
9633
9860
|
* ```
|
|
9634
|
-
*/ z.
|
|
9635
|
-
|
|
9636
|
-
allowZero: false,
|
|
9637
|
-
regexMessage: AMOUNT_FORMAT_ERROR_MESSAGE,
|
|
9638
|
-
attributeName: 'amount',
|
|
9639
|
-
maxDecimals: 6
|
|
9640
|
-
})(z.string())),
|
|
9641
|
-
source: walletContextSchema,
|
|
9642
|
-
destination: bridgeDestinationSchema$1,
|
|
9643
|
-
token: z.literal('USDC'),
|
|
9644
|
-
config: z.object({
|
|
9645
|
-
transferSpeed: z.nativeEnum(TransferSpeed).optional(),
|
|
9646
|
-
maxFee: z.string().pipe(createDecimalStringValidator({
|
|
9647
|
-
allowZero: true,
|
|
9648
|
-
regexMessage: MAX_FEE_FORMAT_ERROR_MESSAGE,
|
|
9649
|
-
attributeName: 'maxFee',
|
|
9650
|
-
maxDecimals: 6
|
|
9651
|
-
})(z.string())).optional(),
|
|
9652
|
-
customFee: customFeeSchema.optional()
|
|
9653
|
-
})
|
|
9861
|
+
*/ createBridgeParamsSchema(z.literal('USDC'), {
|
|
9862
|
+
maxDecimals: 6
|
|
9654
9863
|
});
|
|
9655
9864
|
|
|
9656
|
-
|
|
9657
|
-
|
|
9658
|
-
|
|
9659
|
-
|
|
9660
|
-
|
|
9661
|
-
|
|
9662
|
-
|
|
9663
|
-
|
|
9664
|
-
|
|
9665
|
-
|
|
9666
|
-
|
|
9667
|
-
|
|
9668
|
-
|
|
9669
|
-
|
|
9670
|
-
|
|
9671
|
-
|
|
9672
|
-
|
|
9673
|
-
|
|
9674
|
-
|
|
9675
|
-
|
|
9676
|
-
}
|
|
9677
|
-
};
|
|
9678
|
-
}
|
|
9679
|
-
/**
|
|
9680
|
-
* Schema for validating AdapterContext for bridge operations.
|
|
9681
|
-
* Must always contain both adapter and chain explicitly.
|
|
9682
|
-
*
|
|
9683
|
-
* Optionally includes address for developer-controlled adapters.
|
|
9684
|
-
*/ const adapterContextSchema$3 = z.object({
|
|
9685
|
-
adapter: adapterSchema,
|
|
9686
|
-
chain: bridgeChainIdentifierSchema,
|
|
9687
|
-
address: z.string().optional()
|
|
9688
|
-
});
|
|
9689
|
-
/**
|
|
9690
|
-
* Schema for validating BridgeDestinationWithAddress objects.
|
|
9691
|
-
* Contains an explicit recipientAddress along with adapter and chain.
|
|
9692
|
-
* The address format is validated based on the chain type (EVM or Solana).
|
|
9693
|
-
*/ const bridgeDestinationWithAddressSchema = adapterContextSchema$3.extend({
|
|
9694
|
-
recipientAddress: z.string().min(1, 'Recipient address is required'),
|
|
9695
|
-
useForwarder: z.boolean().optional()
|
|
9696
|
-
}).superRefine(createRecipientAddressValidator());
|
|
9697
|
-
/**
|
|
9698
|
-
* Schema for validating AdapterContext with optional useForwarder.
|
|
9699
|
-
* Extends adapterContextSchema with the useForwarder flag.
|
|
9700
|
-
*/ const adapterContextWithForwarderSchema = adapterContextSchema$3.extend({
|
|
9701
|
-
useForwarder: z.boolean().optional()
|
|
9702
|
-
});
|
|
9703
|
-
/**
|
|
9704
|
-
* Schema for validating ForwarderDestination objects.
|
|
9705
|
-
* Used when useForwarder is true and no adapter is provided.
|
|
9706
|
-
* Requires chain, recipientAddress, and useForwarder: true.
|
|
9707
|
-
*
|
|
9708
|
-
* When using this destination type:
|
|
9709
|
-
* - The mint step completes when the IRIS API confirms forwardState === 'CONFIRMED'
|
|
9710
|
-
* - No on-chain transaction confirmation is performed (no adapter available)
|
|
9711
|
-
* - The mint step's data field will be undefined (no transaction receipt)
|
|
9712
|
-
*/ const forwarderDestinationSchema = z.object({
|
|
9713
|
-
chain: bridgeChainIdentifierSchema,
|
|
9714
|
-
recipientAddress: z.string().min(1, 'Recipient address is required'),
|
|
9715
|
-
useForwarder: z.literal(true)
|
|
9716
|
-
}).strict().superRefine(createRecipientAddressValidator());
|
|
9717
|
-
/**
|
|
9718
|
-
* Schema for validating BridgeDestination union type.
|
|
9719
|
-
* Supports three destination configurations:
|
|
9720
|
-
* - BridgeDestinationWithAddress (adapter with explicit recipient)
|
|
9721
|
-
* - ForwarderDestination (no adapter, requires useForwarder: true and recipientAddress)
|
|
9722
|
-
* - AdapterContext with optional useForwarder (adapter for default recipient)
|
|
9723
|
-
*
|
|
9724
|
-
* When using ForwarderDestination (no adapter):
|
|
9725
|
-
* - The mint step completes when the IRIS API confirms forwardState === 'CONFIRMED'
|
|
9726
|
-
* - No on-chain transaction confirmation is performed
|
|
9727
|
-
*
|
|
9728
|
-
* The order matters: we check the more specific schemas first.
|
|
9729
|
-
* This ensures that objects with specific fields are matched correctly.
|
|
9730
|
-
*/ const bridgeDestinationSchema = z.union([
|
|
9731
|
-
bridgeDestinationWithAddressSchema,
|
|
9732
|
-
forwarderDestinationSchema,
|
|
9733
|
-
adapterContextWithForwarderSchema.strict()
|
|
9734
|
-
]);
|
|
9735
|
-
/**
|
|
9736
|
-
* Schema for validating bridge parameters with chain identifiers.
|
|
9737
|
-
* This extends the core provider's schema but adapts it for the bridge kit's
|
|
9738
|
-
* more flexible interface that accepts chain identifiers.
|
|
9739
|
-
*
|
|
9740
|
-
* The schema validates:
|
|
9741
|
-
* - From adapter context (must always include both adapter and chain)
|
|
9742
|
-
* - To bridge destination (AdapterContext or BridgeDestinationWithAddress)
|
|
9743
|
-
* - Amount is a non-empty numeric string \> 0
|
|
9744
|
-
* - Token is optional and defaults to 'USDC'
|
|
9745
|
-
* - Optional config parameters (transfer speed, max fee)
|
|
9865
|
+
// ----------------------------------------------------------------------------
|
|
9866
|
+
// IRIS API base URLs
|
|
9867
|
+
// ----------------------------------------------------------------------------
|
|
9868
|
+
// ----------------------------------------------------------------------------
|
|
9869
|
+
// Known token symbols (DX convenience)
|
|
9870
|
+
// ----------------------------------------------------------------------------
|
|
9871
|
+
//
|
|
9872
|
+
// These constants back symbol -> id resolution as a convenience: a caller may
|
|
9873
|
+
// pass a known symbol instead of a raw bytes32 id. They do NOT gate
|
|
9874
|
+
// routability.
|
|
9875
|
+
/**
|
|
9876
|
+
* Display symbols the provider recognizes as a convenience for callers.
|
|
9877
|
+
*
|
|
9878
|
+
* A consumer may pass one of these symbols instead of a raw bytes32 token
|
|
9879
|
+
* id; the provider resolves it to the symbol's canonical bytes32 id via
|
|
9880
|
+
* {@link KNOWN_TOKEN_IDS_BY_NETWORK} (a symbol can map to more than one
|
|
9881
|
+
* bridge, so the map pins the canonical one). This list does NOT gate
|
|
9882
|
+
* routability: any token the IRIS registry lists with deployments on both
|
|
9883
|
+
* endpoints routes when passed by its bytes32 id, whether listed here or
|
|
9884
|
+
* not.
|
|
9746
9885
|
*
|
|
9747
9886
|
* @example
|
|
9748
9887
|
* ```typescript
|
|
9749
|
-
*
|
|
9750
|
-
*
|
|
9751
|
-
* const params = {
|
|
9752
|
-
* from: {
|
|
9753
|
-
* adapter: sourceAdapter,
|
|
9754
|
-
* chain: 'Ethereum'
|
|
9755
|
-
* },
|
|
9756
|
-
* to: {
|
|
9757
|
-
* adapter: destAdapter,
|
|
9758
|
-
* chain: 'Base'
|
|
9759
|
-
* },
|
|
9760
|
-
* amount: '100.50',
|
|
9761
|
-
* token: 'USDC',
|
|
9762
|
-
* config: {
|
|
9763
|
-
* transferSpeed: 'FAST'
|
|
9764
|
-
* }
|
|
9765
|
-
* }
|
|
9766
|
-
*
|
|
9767
|
-
* const result = bridgeParamsWithChainIdentifierSchema.safeParse(params)
|
|
9768
|
-
* if (result.success) {
|
|
9769
|
-
* console.log('Parameters are valid')
|
|
9770
|
-
* } else {
|
|
9771
|
-
* console.error('Validation failed:', result.error)
|
|
9772
|
-
* }
|
|
9888
|
+
* for (const symbol of KNOWN_TOKEN_SYMBOLS) console.log(symbol)
|
|
9773
9889
|
* ```
|
|
9774
|
-
*/
|
|
9775
|
-
|
|
9776
|
-
|
|
9777
|
-
|
|
9778
|
-
|
|
9779
|
-
regexMessage: AMOUNT_FORMAT_ERROR_MESSAGE,
|
|
9780
|
-
attributeName: 'amount',
|
|
9781
|
-
maxDecimals: 6
|
|
9782
|
-
})(z.string())),
|
|
9783
|
-
token: z.literal('USDC').optional(),
|
|
9784
|
-
config: z.object({
|
|
9785
|
-
transferSpeed: z.nativeEnum(TransferSpeed).optional(),
|
|
9786
|
-
feePayment: z.enum([
|
|
9787
|
-
'source',
|
|
9788
|
-
'destination'
|
|
9789
|
-
]).optional(),
|
|
9790
|
-
maxFee: z.string().min(1, 'Required').pipe(createDecimalStringValidator({
|
|
9791
|
-
allowZero: true,
|
|
9792
|
-
regexMessage: MAX_FEE_FORMAT_ERROR_MESSAGE,
|
|
9793
|
-
attributeName: 'maxFee',
|
|
9794
|
-
maxDecimals: 6
|
|
9795
|
-
})(z.string())).optional(),
|
|
9796
|
-
customFee: customFeeSchema.optional()
|
|
9797
|
-
}).optional(),
|
|
9798
|
-
quote: z.string().regex(/^0x([a-fA-F0-9]{2})+$/, 'must be non-empty 0x hex').optional()
|
|
9799
|
-
});
|
|
9890
|
+
*/ const KNOWN_TOKEN_SYMBOLS = [
|
|
9891
|
+
'cirBTC',
|
|
9892
|
+
'wETH',
|
|
9893
|
+
'EURC'
|
|
9894
|
+
];
|
|
9800
9895
|
|
|
9801
9896
|
// ============================================================================
|
|
9802
9897
|
// Crypto Utilities (Internal)
|
|
@@ -10217,6 +10312,186 @@ var TransferSpeed;
|
|
|
10217
10312
|
clock: z.any().optional()
|
|
10218
10313
|
}).passthrough();
|
|
10219
10314
|
|
|
10315
|
+
/**
|
|
10316
|
+
* Creates a Zod superRefine validator for recipient address format validation.
|
|
10317
|
+
* Validates that the address format matches the expected format for the chain type.
|
|
10318
|
+
*
|
|
10319
|
+
* @returns A superRefine function that validates recipientAddress against chain type
|
|
10320
|
+
*/ function createRecipientAddressValidator() {
|
|
10321
|
+
return (data, ctx)=>{
|
|
10322
|
+
const chain = data.chain;
|
|
10323
|
+
if (chain === null) {
|
|
10324
|
+
return;
|
|
10325
|
+
}
|
|
10326
|
+
if (!isValidAddressForChain(data.recipientAddress, chain)) {
|
|
10327
|
+
const chainInfo = extractChainInfo(chain);
|
|
10328
|
+
ctx.addIssue({
|
|
10329
|
+
code: z.ZodIssueCode.custom,
|
|
10330
|
+
path: [
|
|
10331
|
+
'recipientAddress'
|
|
10332
|
+
],
|
|
10333
|
+
message: `Invalid address format for ${String(chainInfo.name)}. Expected ${chainInfo.expectedAddressFormat}, but received: ${data.recipientAddress}`
|
|
10334
|
+
});
|
|
10335
|
+
}
|
|
10336
|
+
};
|
|
10337
|
+
}
|
|
10338
|
+
/**
|
|
10339
|
+
* Schema for `BridgeParams.token`.
|
|
10340
|
+
*
|
|
10341
|
+
* Accept `'USDC'`, a symbol from {@link KNOWN_TOKEN_SYMBOLS}, or a bytes32 id
|
|
10342
|
+
* (`0x` plus exactly 64 hex characters). Reject unknown symbols, malformed ids,
|
|
10343
|
+
* and `{ provider, id }` objects. A custom extra provider cannot introduce a
|
|
10344
|
+
* new symbol through this field — only a bytes32 id.
|
|
10345
|
+
*
|
|
10346
|
+
* Omit the field to default to `'USDC'`.
|
|
10347
|
+
*/ const bridgeTokenSchema = z.union([
|
|
10348
|
+
z.enum([
|
|
10349
|
+
'USDC',
|
|
10350
|
+
...KNOWN_TOKEN_SYMBOLS
|
|
10351
|
+
]),
|
|
10352
|
+
z.string().regex(/^0x[0-9a-fA-F]{64}$/, 'Token id must be a bytes32 (0x-prefixed, 64 hex chars)')
|
|
10353
|
+
]);
|
|
10354
|
+
/**
|
|
10355
|
+
* Schema for validating AdapterContext for bridge operations.
|
|
10356
|
+
* Must always contain both adapter and chain explicitly.
|
|
10357
|
+
*
|
|
10358
|
+
* Optionally includes address for developer-controlled adapters.
|
|
10359
|
+
*/ const adapterContextSchema$3 = z.object({
|
|
10360
|
+
adapter: adapterSchema,
|
|
10361
|
+
chain: bridgeChainIdentifierSchema,
|
|
10362
|
+
address: z.string().optional()
|
|
10363
|
+
});
|
|
10364
|
+
/**
|
|
10365
|
+
* Schema for validating BridgeDestinationWithAddress objects.
|
|
10366
|
+
* Contains an explicit recipientAddress along with adapter and chain.
|
|
10367
|
+
* The address format is validated based on the chain type (EVM or Solana).
|
|
10368
|
+
*/ const bridgeDestinationWithAddressSchema = adapterContextSchema$3.extend({
|
|
10369
|
+
recipientAddress: z.string().min(1, 'Recipient address is required'),
|
|
10370
|
+
useForwarder: z.boolean().optional()
|
|
10371
|
+
}).superRefine(createRecipientAddressValidator());
|
|
10372
|
+
/**
|
|
10373
|
+
* Schema for validating AdapterContext with optional useForwarder.
|
|
10374
|
+
* Extends adapterContextSchema with the useForwarder flag.
|
|
10375
|
+
*/ const adapterContextWithForwarderSchema = adapterContextSchema$3.extend({
|
|
10376
|
+
useForwarder: z.boolean().optional()
|
|
10377
|
+
});
|
|
10378
|
+
/**
|
|
10379
|
+
* Schema for validating ForwarderDestination objects.
|
|
10380
|
+
* Used when useForwarder is true and no adapter is provided.
|
|
10381
|
+
* Requires chain, recipientAddress, and useForwarder: true.
|
|
10382
|
+
*
|
|
10383
|
+
* When using this destination type:
|
|
10384
|
+
* - The mint step completes when the IRIS API confirms forwardState === 'CONFIRMED'
|
|
10385
|
+
* - No on-chain transaction confirmation is performed (no adapter available)
|
|
10386
|
+
* - The mint step's data field will be undefined (no transaction receipt)
|
|
10387
|
+
*/ const forwarderDestinationSchema = z.object({
|
|
10388
|
+
chain: bridgeChainIdentifierSchema,
|
|
10389
|
+
recipientAddress: z.string().min(1, 'Recipient address is required'),
|
|
10390
|
+
useForwarder: z.literal(true)
|
|
10391
|
+
}).strict().superRefine(createRecipientAddressValidator());
|
|
10392
|
+
/**
|
|
10393
|
+
* Schema for validating BridgeDestination union type.
|
|
10394
|
+
* Supports three destination configurations:
|
|
10395
|
+
* - BridgeDestinationWithAddress (adapter with explicit recipient)
|
|
10396
|
+
* - ForwarderDestination (no adapter, requires useForwarder: true and recipientAddress)
|
|
10397
|
+
* - AdapterContext with optional useForwarder (adapter for default recipient)
|
|
10398
|
+
*
|
|
10399
|
+
* When using ForwarderDestination (no adapter):
|
|
10400
|
+
* - The mint step completes when the IRIS API confirms forwardState === 'CONFIRMED'
|
|
10401
|
+
* - No on-chain transaction confirmation is performed
|
|
10402
|
+
*
|
|
10403
|
+
* The order matters: we check the more specific schemas first.
|
|
10404
|
+
* This ensures that objects with specific fields are matched correctly.
|
|
10405
|
+
*/ const bridgeDestinationSchema = z.union([
|
|
10406
|
+
bridgeDestinationWithAddressSchema,
|
|
10407
|
+
forwarderDestinationSchema,
|
|
10408
|
+
adapterContextWithForwarderSchema.strict()
|
|
10409
|
+
]);
|
|
10410
|
+
/**
|
|
10411
|
+
* Schema for validating bridge parameters with chain identifiers.
|
|
10412
|
+
* This extends the core provider's schema but adapts it for the bridge kit's
|
|
10413
|
+
* more flexible interface that accepts chain identifiers.
|
|
10414
|
+
*
|
|
10415
|
+
* The schema validates:
|
|
10416
|
+
* - From adapter context (must always include both adapter and chain)
|
|
10417
|
+
* - To bridge destination (AdapterContext or BridgeDestinationWithAddress)
|
|
10418
|
+
* - Amount is a non-empty numeric string \> 0
|
|
10419
|
+
* - Token is optional and defaults to 'USDC'
|
|
10420
|
+
* - Optional config parameters (transfer speed, max fee)
|
|
10421
|
+
*
|
|
10422
|
+
* @example
|
|
10423
|
+
* ```typescript
|
|
10424
|
+
* import { bridgeParamsWithChainIdentifierSchema } from '@circle-fin/bridge-kit'
|
|
10425
|
+
*
|
|
10426
|
+
* const params = {
|
|
10427
|
+
* from: {
|
|
10428
|
+
* adapter: sourceAdapter,
|
|
10429
|
+
* chain: 'Ethereum'
|
|
10430
|
+
* },
|
|
10431
|
+
* to: {
|
|
10432
|
+
* adapter: destAdapter,
|
|
10433
|
+
* chain: 'Base'
|
|
10434
|
+
* },
|
|
10435
|
+
* amount: '100.50',
|
|
10436
|
+
* token: 'USDC',
|
|
10437
|
+
* config: {
|
|
10438
|
+
* transferSpeed: 'FAST'
|
|
10439
|
+
* }
|
|
10440
|
+
* }
|
|
10441
|
+
*
|
|
10442
|
+
* const result = bridgeParamsWithChainIdentifierSchema.safeParse(params)
|
|
10443
|
+
* if (result.success) {
|
|
10444
|
+
* console.log('Parameters are valid')
|
|
10445
|
+
* } else {
|
|
10446
|
+
* console.error('Validation failed:', result.error)
|
|
10447
|
+
* }
|
|
10448
|
+
* ```
|
|
10449
|
+
*/ z.object({
|
|
10450
|
+
from: adapterContextSchema$3.strict(),
|
|
10451
|
+
to: bridgeDestinationSchema,
|
|
10452
|
+
amount: z.string().min(1, 'Required').pipe(createDecimalStringValidator({
|
|
10453
|
+
allowZero: false,
|
|
10454
|
+
regexMessage: AMOUNT_FORMAT_ERROR_MESSAGE,
|
|
10455
|
+
attributeName: 'amount',
|
|
10456
|
+
// Widest precision any routable token needs (wETH = 18). This gate is
|
|
10457
|
+
// token-agnostic and runs before the route provider is known, so it
|
|
10458
|
+
// can only cap coarsely; the token's exact precision is enforced later
|
|
10459
|
+
// at the scaling boundary (`BridgeKit.scaleResolvedAmount`). USDC (6)
|
|
10460
|
+
// and every narrower token stay valid.
|
|
10461
|
+
maxDecimals: 18
|
|
10462
|
+
})(z.string())),
|
|
10463
|
+
token: bridgeTokenSchema.optional(),
|
|
10464
|
+
config: z.object({
|
|
10465
|
+
transferSpeed: z.nativeEnum(TransferSpeed).optional(),
|
|
10466
|
+
feePayment: z.enum([
|
|
10467
|
+
'source',
|
|
10468
|
+
'destination'
|
|
10469
|
+
]).optional(),
|
|
10470
|
+
maxFee: z.string().min(1, 'Required').pipe(createDecimalStringValidator({
|
|
10471
|
+
allowZero: true,
|
|
10472
|
+
regexMessage: MAX_FEE_FORMAT_ERROR_MESSAGE,
|
|
10473
|
+
attributeName: 'maxFee',
|
|
10474
|
+
// See `amount` above: widest routable precision (18); the exact
|
|
10475
|
+
// per-token precision is enforced at the scaling boundary.
|
|
10476
|
+
maxDecimals: 18
|
|
10477
|
+
})(z.string())).optional(),
|
|
10478
|
+
customFee: customFeeSchema.optional()
|
|
10479
|
+
}).optional(),
|
|
10480
|
+
// Top-level (not nested under `config`) to mirror `BridgeParams.quote`.
|
|
10481
|
+
//
|
|
10482
|
+
// `z.unknown()` rather than a shape: the quote belongs to whichever provider
|
|
10483
|
+
// issued it, and a route is matched to a provider only after these
|
|
10484
|
+
// parameters are validated, so there is no one shape to check here.
|
|
10485
|
+
//
|
|
10486
|
+
// It also keeps the value intact. This object strips unknown keys, so a
|
|
10487
|
+
// nested `z.object()` would clone the quote and drop every key not listed —
|
|
10488
|
+
// losing a field the issuing provider added, between `estimate` and
|
|
10489
|
+
// `bridge`. Shape is checked where the quote is consumed instead: CCTPx
|
|
10490
|
+
// against its own envelope schema, and the receive-exact path in
|
|
10491
|
+
// `sourceFees.ts` before it calls the Fee Service.
|
|
10492
|
+
quote: z.unknown().optional()
|
|
10493
|
+
});
|
|
10494
|
+
|
|
10220
10495
|
/**
|
|
10221
10496
|
* The ASCII "cctp-forward" magic, hex-encoded (no `0x`), that a forward-friendly
|
|
10222
10497
|
* hookData must start with.
|
|
@@ -10456,7 +10731,7 @@ const validateQuoteItemSchema = z.object({
|
|
|
10456
10731
|
registerKit(`${pkg$3.name}/${pkg$3.version}`);
|
|
10457
10732
|
|
|
10458
10733
|
var name$2 = "@circle-fin/swap-kit";
|
|
10459
|
-
var version$2 = "1.
|
|
10734
|
+
var version$2 = "1.7.0";
|
|
10460
10735
|
var pkg$2 = {
|
|
10461
10736
|
name: name$2,
|
|
10462
10737
|
version: version$2};
|
|
@@ -12620,6 +12895,11 @@ createTokenRegistry();
|
|
|
12620
12895
|
name: 'USDC',
|
|
12621
12896
|
version: '2'
|
|
12622
12897
|
},
|
|
12898
|
+
Arc: {
|
|
12899
|
+
chainId: Arc.chainId,
|
|
12900
|
+
name: 'USDC',
|
|
12901
|
+
version: '2'
|
|
12902
|
+
},
|
|
12623
12903
|
Arc_Testnet: {
|
|
12624
12904
|
chainId: ArcTestnet.chainId,
|
|
12625
12905
|
name: 'USDC',
|
|
@@ -14155,7 +14435,7 @@ new Set(Object.values(Blockchain));
|
|
|
14155
14435
|
registerKit(`${pkg$2.name}/${pkg$2.version}`);
|
|
14156
14436
|
|
|
14157
14437
|
var name$1 = "@circle-fin/earn-kit";
|
|
14158
|
-
var version$1 = "1.
|
|
14438
|
+
var version$1 = "1.7.0";
|
|
14159
14439
|
var pkg$1 = {
|
|
14160
14440
|
name: name$1,
|
|
14161
14441
|
version: version$1};
|
|
@@ -14183,18 +14463,22 @@ const EARN_BRIDGE_ERC3009_TOKEN_SYMBOLS = [
|
|
|
14183
14463
|
*
|
|
14184
14464
|
* @internal
|
|
14185
14465
|
*/ const CHAIN_TO_API = {
|
|
14466
|
+
[Blockchain.Arc]: 'ARC',
|
|
14186
14467
|
[Blockchain.Arc_Testnet]: 'ARC-TESTNET'
|
|
14187
14468
|
};
|
|
14188
14469
|
/**
|
|
14189
14470
|
* Map SDK source chain identifiers to bridge source-chain strings.
|
|
14190
14471
|
*
|
|
14191
|
-
* Cross-chain Earn deposits
|
|
14192
|
-
*
|
|
14472
|
+
* Cross-chain Earn deposits support Ethereum, Arbitrum, and Base (mainnet
|
|
14473
|
+
* and testnet) as source chains.
|
|
14193
14474
|
*
|
|
14194
14475
|
* @internal
|
|
14195
14476
|
*/ const EARN_BRIDGE_SOURCE_CHAIN_TO_API = {
|
|
14477
|
+
[Blockchain.Arbitrum]: 'ARB',
|
|
14196
14478
|
[Blockchain.Arbitrum_Sepolia]: 'ARB-SEPOLIA',
|
|
14479
|
+
[Blockchain.Base]: 'BASE',
|
|
14197
14480
|
[Blockchain.Base_Sepolia]: 'BASE-SEPOLIA',
|
|
14481
|
+
[Blockchain.Ethereum]: 'ETH',
|
|
14198
14482
|
[Blockchain.Ethereum_Sepolia]: 'ETH-SEPOLIA'
|
|
14199
14483
|
};
|
|
14200
14484
|
/**
|
|
@@ -14205,17 +14489,30 @@ const EARN_BRIDGE_ERC3009_TOKEN_SYMBOLS = [
|
|
|
14205
14489
|
*
|
|
14206
14490
|
* @internal
|
|
14207
14491
|
*/ const EARN_BRIDGE_DESTINATION_CHAIN_TO_API = {
|
|
14492
|
+
[Blockchain.Arc]: CHAIN_TO_API[Blockchain.Arc],
|
|
14208
14493
|
[Blockchain.Arc_Testnet]: CHAIN_TO_API[Blockchain.Arc_Testnet]
|
|
14209
14494
|
};
|
|
14210
14495
|
const EARN_BRIDGE_USDC_ERC3009_DOMAINS = {
|
|
14496
|
+
[Blockchain.Arbitrum]: {
|
|
14497
|
+
name: 'USD Coin',
|
|
14498
|
+
version: '2'
|
|
14499
|
+
},
|
|
14211
14500
|
[Blockchain.Arbitrum_Sepolia]: {
|
|
14212
14501
|
name: 'USD Coin',
|
|
14213
14502
|
version: '2'
|
|
14214
14503
|
},
|
|
14504
|
+
[Blockchain.Base]: {
|
|
14505
|
+
name: 'USD Coin',
|
|
14506
|
+
version: '2'
|
|
14507
|
+
},
|
|
14215
14508
|
[Blockchain.Base_Sepolia]: {
|
|
14216
14509
|
name: 'USDC',
|
|
14217
14510
|
version: '2'
|
|
14218
14511
|
},
|
|
14512
|
+
[Blockchain.Ethereum]: {
|
|
14513
|
+
name: 'USD Coin',
|
|
14514
|
+
version: '2'
|
|
14515
|
+
},
|
|
14219
14516
|
[Blockchain.Ethereum_Sepolia]: {
|
|
14220
14517
|
name: 'USDC',
|
|
14221
14518
|
version: '2'
|
|
@@ -17059,7 +17356,7 @@ const bridgeDepositPrepareReviewSchema = z.object({
|
|
|
17059
17356
|
}
|
|
17060
17357
|
|
|
17061
17358
|
var name = "@circle-fin/provider-earn-service";
|
|
17062
|
-
var version = "1.
|
|
17359
|
+
var version = "1.6.0";
|
|
17063
17360
|
var pkg = {
|
|
17064
17361
|
name: name,
|
|
17065
17362
|
version: version};
|