@circle-fin/app-kit 1.13.0 → 1.15.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/CHANGELOG.md +122 -0
- package/README.md +3 -3
- package/bridge.cjs +8388 -515
- package/bridge.d.cts +640 -61
- package/bridge.d.mts +640 -61
- package/bridge.d.ts +640 -61
- package/bridge.mjs +8389 -516
- package/chains.cjs +275 -15
- package/chains.d.cts +117 -2
- package/chains.d.mts +117 -2
- package/chains.d.ts +117 -2
- package/chains.mjs +275 -16
- package/context.d.cts +577 -57
- package/context.d.mts +577 -57
- package/context.d.ts +577 -57
- package/earn.cjs +973 -271
- package/earn.d.cts +577 -57
- package/earn.d.mts +577 -57
- package/earn.d.ts +577 -57
- package/earn.mjs +919 -221
- package/estimateBridge.cjs +8388 -518
- package/estimateBridge.d.cts +704 -82
- package/estimateBridge.d.mts +704 -82
- package/estimateBridge.d.ts +704 -82
- package/estimateBridge.mjs +8390 -520
- package/estimateSwap.cjs +982 -237
- package/estimateSwap.d.cts +577 -57
- package/estimateSwap.d.mts +577 -57
- package/estimateSwap.d.ts +577 -57
- package/estimateSwap.mjs +981 -237
- package/index.cjs +21401 -8522
- package/index.d.cts +6045 -2149
- package/index.d.mts +6045 -2149
- package/index.d.ts +6045 -2149
- package/index.mjs +21401 -8524
- 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 +982 -237
- package/swap.d.cts +577 -57
- package/swap.d.mts +577 -57
- package/swap.d.ts +577 -57
- package/swap.mjs +981 -237
- package/unifiedBalance.cjs +20510 -7599
- package/unifiedBalance.d.cts +807 -201
- package/unifiedBalance.d.mts +807 -201
- package/unifiedBalance.d.ts +807 -201
- package/unifiedBalance.mjs +20513 -7603
package/earn.cjs
CHANGED
|
@@ -30,7 +30,7 @@ if (typeof window !== 'undefined' && typeof window.Buffer === 'undefined') {
|
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
var zod = require('zod');
|
|
33
|
-
require('pino');
|
|
33
|
+
var pino = require('pino');
|
|
34
34
|
require('@ethersproject/bytes');
|
|
35
35
|
require('@ethersproject/abi');
|
|
36
36
|
require('@ethersproject/address');
|
|
@@ -43,6 +43,10 @@ var viem = require('viem');
|
|
|
43
43
|
var units = require('@ethersproject/units');
|
|
44
44
|
var keccak256 = require('@ethersproject/keccak256');
|
|
45
45
|
|
|
46
|
+
function _interopDefault (e) { return e && e.__esModule ? e.default : e; }
|
|
47
|
+
|
|
48
|
+
var pino__default = /*#__PURE__*/_interopDefault(pino);
|
|
49
|
+
|
|
46
50
|
// Import global type declarations
|
|
47
51
|
/**
|
|
48
52
|
* Check whether the current runtime is Node.js.
|
|
@@ -861,8 +865,7 @@ class KitError extends Error {
|
|
|
861
865
|
code: 8002,
|
|
862
866
|
name: 'SERVICE_UNKNOWN_ERROR',
|
|
863
867
|
type: 'SERVICE'
|
|
864
|
-
}
|
|
865
|
-
};
|
|
868
|
+
}};
|
|
866
869
|
|
|
867
870
|
/**
|
|
868
871
|
* Creates error for network type mismatch between source and destination.
|
|
@@ -1049,7 +1052,7 @@ class KitError extends Error {
|
|
|
1049
1052
|
* import { createValidationErrorFromZod } from '@core/errors'
|
|
1050
1053
|
*
|
|
1051
1054
|
* function validateBridgeParams(params: unknown): asserts params is BridgeParams {
|
|
1052
|
-
* const result =
|
|
1055
|
+
* const result = usdcBridgeParamsSchema.safeParse(params)
|
|
1053
1056
|
* if (!result.success) {
|
|
1054
1057
|
* throw createValidationErrorFromZod(result.error, 'bridge parameters')
|
|
1055
1058
|
* }
|
|
@@ -2310,9 +2313,10 @@ function getOptionalString(value) {
|
|
|
2310
2313
|
Blockchain["Algorand_Testnet"] = "Algorand_Testnet";
|
|
2311
2314
|
Blockchain["Aptos"] = "Aptos";
|
|
2312
2315
|
Blockchain["Aptos_Testnet"] = "Aptos_Testnet";
|
|
2313
|
-
Blockchain["Arc_Testnet"] = "Arc_Testnet";
|
|
2314
2316
|
Blockchain["Arbitrum"] = "Arbitrum";
|
|
2315
2317
|
Blockchain["Arbitrum_Sepolia"] = "Arbitrum_Sepolia";
|
|
2318
|
+
Blockchain["Arc"] = "Arc";
|
|
2319
|
+
Blockchain["Arc_Testnet"] = "Arc_Testnet";
|
|
2316
2320
|
Blockchain["Avalanche"] = "Avalanche";
|
|
2317
2321
|
Blockchain["Avalanche_Fuji"] = "Avalanche_Fuji";
|
|
2318
2322
|
Blockchain["Base"] = "Base";
|
|
@@ -2399,6 +2403,7 @@ var SwapChain;
|
|
|
2399
2403
|
SwapChain["XDC"] = "XDC";
|
|
2400
2404
|
SwapChain["HyperEVM"] = "HyperEVM";
|
|
2401
2405
|
SwapChain["Monad"] = "Monad";
|
|
2406
|
+
SwapChain["Arc"] = "Arc";
|
|
2402
2407
|
// Testnet chains with swap support
|
|
2403
2408
|
SwapChain["Arc_Testnet"] = "Arc_Testnet";
|
|
2404
2409
|
})(SwapChain || (SwapChain = {}));
|
|
@@ -2406,6 +2411,7 @@ var BridgeChain;
|
|
|
2406
2411
|
(function(BridgeChain) {
|
|
2407
2412
|
// Mainnet chains with CCTPv2 support
|
|
2408
2413
|
BridgeChain["Arbitrum"] = "Arbitrum";
|
|
2414
|
+
BridgeChain["Arc"] = "Arc";
|
|
2409
2415
|
BridgeChain["Avalanche"] = "Avalanche";
|
|
2410
2416
|
BridgeChain["Base"] = "Base";
|
|
2411
2417
|
BridgeChain["Codex"] = "Codex";
|
|
@@ -2461,6 +2467,7 @@ var BridgeChain;
|
|
|
2461
2467
|
var UnifiedBalanceChain;
|
|
2462
2468
|
(function(UnifiedBalanceChain) {
|
|
2463
2469
|
// Mainnet chains with Gateway V1 support
|
|
2470
|
+
UnifiedBalanceChain["Arc"] = "Arc";
|
|
2464
2471
|
UnifiedBalanceChain["Arbitrum"] = "Arbitrum";
|
|
2465
2472
|
UnifiedBalanceChain["Avalanche"] = "Avalanche";
|
|
2466
2473
|
UnifiedBalanceChain["Base"] = "Base";
|
|
@@ -2490,6 +2497,7 @@ var UnifiedBalanceChain;
|
|
|
2490
2497
|
})(UnifiedBalanceChain || (UnifiedBalanceChain = {}));
|
|
2491
2498
|
var EarnChain;
|
|
2492
2499
|
(function(EarnChain) {
|
|
2500
|
+
EarnChain["Arc"] = "Arc";
|
|
2493
2501
|
EarnChain["Arc_Testnet"] = "Arc_Testnet";
|
|
2494
2502
|
})(EarnChain || (EarnChain = {}));
|
|
2495
2503
|
/**
|
|
@@ -2506,8 +2514,11 @@ var EarnChain;
|
|
|
2506
2514
|
* console.log(EARN_BRIDGE_SOURCE_BLOCKCHAINS.join(', '))
|
|
2507
2515
|
* ```
|
|
2508
2516
|
*/ const EARN_BRIDGE_SOURCE_BLOCKCHAINS = [
|
|
2517
|
+
"Arbitrum",
|
|
2509
2518
|
"Arbitrum_Sepolia",
|
|
2519
|
+
"Base",
|
|
2510
2520
|
"Base_Sepolia",
|
|
2521
|
+
"Ethereum",
|
|
2511
2522
|
"Ethereum_Sepolia"
|
|
2512
2523
|
];
|
|
2513
2524
|
/**
|
|
@@ -2521,6 +2532,7 @@ var EarnChain;
|
|
|
2521
2532
|
* console.log(EARN_BRIDGE_DESTINATION_BLOCKCHAINS.join(', '))
|
|
2522
2533
|
* ```
|
|
2523
2534
|
*/ const EARN_BRIDGE_DESTINATION_BLOCKCHAINS = [
|
|
2535
|
+
"Arc",
|
|
2524
2536
|
"Arc_Testnet"
|
|
2525
2537
|
];
|
|
2526
2538
|
|
|
@@ -2826,6 +2838,25 @@ var EarnChain;
|
|
|
2826
2838
|
* EVM-compatible chains. Use this address when deploying or testing
|
|
2827
2839
|
* cross-chain USDC transfers on test networks.
|
|
2828
2840
|
*/ const BRIDGE_CONTRACT_EVM_TESTNET = '0xC5567a5E3370d4DBfB0540025078e283e36A363d';
|
|
2841
|
+
/**
|
|
2842
|
+
* The CrossChainTokenService (CCTPx) service address for EVM testnet networks.
|
|
2843
|
+
*
|
|
2844
|
+
* This service coordinates CCTPx cross-chain token operations on testnet
|
|
2845
|
+
* environments and is shared by every EVM test network CCTPx supports. Read the
|
|
2846
|
+
* chain definitions via `isCCTPXSupported` rather than trusting a list here,
|
|
2847
|
+
* which goes stale as deployments land.
|
|
2848
|
+
*/ const CCTPX_SERVICE_ADDRESS_EVM_TESTNET = '0x63753E722bd2C2A5DF6EE19C5106662208B81077';
|
|
2849
|
+
/**
|
|
2850
|
+
* CrossChainTokenService (CCTS) proxy address for CCTPx on EVM **mainnet**.
|
|
2851
|
+
*
|
|
2852
|
+
* @remarks
|
|
2853
|
+
* A distinct deployment from {@link CCTPX_SERVICE_ADDRESS_EVM_TESTNET}, shared
|
|
2854
|
+
* by every EVM mainnet chain that CCTPx supports. A chain becomes
|
|
2855
|
+
* CCTPx-eligible only once its definition carries this as
|
|
2856
|
+
* `cctpx.serviceAddress`, and a route additionally needs both of its endpoints
|
|
2857
|
+
* eligible — so adding a chain here is the deliberate, reviewable step that
|
|
2858
|
+
* opens mainnet CCTPx for it.
|
|
2859
|
+
*/ const CCTPX_SERVICE_ADDRESS_EVM_MAINNET = '0x431871229103b780868f8C6BB820cd16ECf942BC';
|
|
2829
2860
|
/**
|
|
2830
2861
|
* The bridge contract address for EVM mainnet networks.
|
|
2831
2862
|
*
|
|
@@ -2894,8 +2925,115 @@ var EarnChain;
|
|
|
2894
2925
|
* This program handles minting operations for Gateway transactions
|
|
2895
2926
|
* on Solana devnet.
|
|
2896
2927
|
*/ const GATEWAY_MINTER_SOLANA_DEVNET = 'GATEmKK2ECL1brEngQZWCgMWPbvrEYqsV6u29dAaHavr';
|
|
2897
|
-
/**
|
|
2898
|
-
|
|
2928
|
+
/**
|
|
2929
|
+
* The `TokenMessengerWithFees` proxy contract address for EVM mainnet networks
|
|
2930
|
+
* (all chains except Edge).
|
|
2931
|
+
*
|
|
2932
|
+
* Deployed at a CREATE3-derived address; identical across all mainnet EVM
|
|
2933
|
+
* source chains. Present on any chain that supports the prepaid FORWARD path
|
|
2934
|
+
* via `depositForBurnWithHookAndFees`.
|
|
2935
|
+
*/ const TOKEN_MESSENGER_WITH_FEES_EVM_MAINNET = '0x71f54F818671cD0D7ea140Da213e5C8b5C92a408';
|
|
2936
|
+
/**
|
|
2937
|
+
* The `TokenMessengerWithFees` proxy contract address for EVM testnet networks.
|
|
2938
|
+
*
|
|
2939
|
+
* Identical across all testnet EVM source chains. Present on any testnet chain
|
|
2940
|
+
* that supports the prepaid FORWARD path via `depositForBurnWithHookAndFees`.
|
|
2941
|
+
*/ const TOKEN_MESSENGER_WITH_FEES_EVM_TESTNET = '0x8745D906D67C346E5eb1aEEED38Eb87F34DF0C0A';
|
|
2942
|
+
/**
|
|
2943
|
+
* The `DepositForHandler` proxy contract address for EVM mainnet networks.
|
|
2944
|
+
*
|
|
2945
|
+
* The handler the GenericExecutor calls on a fast-deposit destination chain to
|
|
2946
|
+
* run a cross-chain deposit into the GatewayWallet. Deployed at the same
|
|
2947
|
+
* address across all mainnet EVM destination chains.
|
|
2948
|
+
*/ const DEPOSIT_FOR_HANDLER_EVM_MAINNET = '0x16529813203f77E036576666336554a1210dce4D';
|
|
2949
|
+
/**
|
|
2950
|
+
* The `DepositForHandler` proxy contract address for EVM testnet networks.
|
|
2951
|
+
*
|
|
2952
|
+
* Identical across all testnet EVM destination chains.
|
|
2953
|
+
*/ const DEPOSIT_FOR_HANDLER_EVM_TESTNET = '0xD05E7D2E7d30b92c5F17d7d0fC575fce231F1A48';
|
|
2954
|
+
/**
|
|
2955
|
+
* The `GenericExecutor` proxy contract address for EVM mainnet networks.
|
|
2956
|
+
*
|
|
2957
|
+
* The GenericExecutor is the `mintRecipient` and `destinationCaller` on the
|
|
2958
|
+
* destination chain for the CCTP v2 prepaid FORWARD path. It receives the CCTP
|
|
2959
|
+
* mint and calls the `DepositForHandler` to complete the fast deposit.
|
|
2960
|
+
* Deployed at the same address across all mainnet EVM destination chains.
|
|
2961
|
+
*/ const GENERIC_EXECUTOR_EVM_MAINNET = '0xFa7be2f04F3Ad4ca969260729c6d45B5625984A7';
|
|
2962
|
+
/**
|
|
2963
|
+
* The `GenericExecutor` proxy contract address for EVM testnet networks.
|
|
2964
|
+
*
|
|
2965
|
+
* Identical across all testnet EVM destination chains.
|
|
2966
|
+
*/ const GENERIC_EXECUTOR_EVM_TESTNET = '0xEdC81040756AcCfF070c21D37b265b9D0b5Ba45e';
|
|
2967
|
+
|
|
2968
|
+
/**
|
|
2969
|
+
* Arc Mainnet chain definition
|
|
2970
|
+
* @remarks
|
|
2971
|
+
* This represents the official production network for the Arc blockchain,
|
|
2972
|
+
* Circle's EVM-compatible Layer-1 designed for stablecoin finance
|
|
2973
|
+
* and asset tokenization. Arc uses USDC as the native gas token and
|
|
2974
|
+
* features the Malachite Byzantine Fault Tolerant (BFT) consensus
|
|
2975
|
+
* engine for sub-second finality.
|
|
2976
|
+
*/ const Arc = defineChain({
|
|
2977
|
+
type: 'evm',
|
|
2978
|
+
chain: Blockchain.Arc,
|
|
2979
|
+
name: 'Arc',
|
|
2980
|
+
title: 'Arc Mainnet',
|
|
2981
|
+
nativeCurrency: {
|
|
2982
|
+
name: 'USDC',
|
|
2983
|
+
symbol: 'USDC',
|
|
2984
|
+
// Arc uses native USDC with 18 decimals for gas payments (EVM standard).
|
|
2985
|
+
// Note: The ERC-20 USDC contract at usdcAddress uses 6 decimals.
|
|
2986
|
+
// See: https://docs.arc.network/arc/references/contract-addresses
|
|
2987
|
+
decimals: 18
|
|
2988
|
+
},
|
|
2989
|
+
chainId: 5042,
|
|
2990
|
+
isTestnet: false,
|
|
2991
|
+
explorerUrl: 'https://explorer.arc.io/tx/{hash}',
|
|
2992
|
+
rpcEndpoints: [
|
|
2993
|
+
'https://rpc.mainnet.arc.io/'
|
|
2994
|
+
],
|
|
2995
|
+
eurcAddress: '0xbEf5f6d51CB62b58e6A8f77868681825C6fe21c1',
|
|
2996
|
+
usdcAddress: '0x3600000000000000000000000000000000000000',
|
|
2997
|
+
usdtAddress: null,
|
|
2998
|
+
cctp: {
|
|
2999
|
+
domain: 26,
|
|
3000
|
+
contracts: {
|
|
3001
|
+
v2: {
|
|
3002
|
+
type: 'split',
|
|
3003
|
+
tokenMessenger: '0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d',
|
|
3004
|
+
messageTransmitter: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',
|
|
3005
|
+
confirmations: 1,
|
|
3006
|
+
fastConfirmations: 1
|
|
3007
|
+
}
|
|
3008
|
+
},
|
|
3009
|
+
forwarderSupported: {
|
|
3010
|
+
source: false,
|
|
3011
|
+
destination: true
|
|
3012
|
+
}
|
|
3013
|
+
},
|
|
3014
|
+
cctpx: {
|
|
3015
|
+
serviceAddress: CCTPX_SERVICE_ADDRESS_EVM_MAINNET
|
|
3016
|
+
},
|
|
3017
|
+
kitContracts: {
|
|
3018
|
+
bridge: BRIDGE_CONTRACT_EVM_MAINNET,
|
|
3019
|
+
adapter: ADAPTER_CONTRACT_EVM_MAINNET
|
|
3020
|
+
},
|
|
3021
|
+
gateway: {
|
|
3022
|
+
domain: 26,
|
|
3023
|
+
contracts: {
|
|
3024
|
+
v1: {
|
|
3025
|
+
wallet: GATEWAY_WALLET_EVM_MAINNET,
|
|
3026
|
+
minter: GATEWAY_MINTER_EVM_MAINNET,
|
|
3027
|
+
depositForHandler: DEPOSIT_FOR_HANDLER_EVM_MAINNET,
|
|
3028
|
+
genericExecutor: GENERIC_EXECUTOR_EVM_MAINNET
|
|
3029
|
+
}
|
|
3030
|
+
},
|
|
3031
|
+
forwarderSupported: {
|
|
3032
|
+
source: true,
|
|
3033
|
+
destination: true
|
|
3034
|
+
}
|
|
3035
|
+
}
|
|
3036
|
+
});
|
|
2899
3037
|
|
|
2900
3038
|
/**
|
|
2901
3039
|
* Arc Testnet chain definition
|
|
@@ -2944,6 +3082,9 @@ var EarnChain;
|
|
|
2944
3082
|
destination: true
|
|
2945
3083
|
}
|
|
2946
3084
|
},
|
|
3085
|
+
cctpx: {
|
|
3086
|
+
serviceAddress: CCTPX_SERVICE_ADDRESS_EVM_TESTNET
|
|
3087
|
+
},
|
|
2947
3088
|
kitContracts: {
|
|
2948
3089
|
bridge: BRIDGE_CONTRACT_EVM_TESTNET,
|
|
2949
3090
|
adapter: ADAPTER_CONTRACT_EVM_TESTNET
|
|
@@ -2954,9 +3095,8 @@ var EarnChain;
|
|
|
2954
3095
|
v1: {
|
|
2955
3096
|
wallet: GATEWAY_WALLET_EVM_TESTNET,
|
|
2956
3097
|
minter: GATEWAY_MINTER_EVM_TESTNET,
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
depositForHandler: '0xD05E7D2E7d30b92c5F17d7d0fC575fce231F1A48'
|
|
3098
|
+
depositForHandler: DEPOSIT_FOR_HANDLER_EVM_TESTNET,
|
|
3099
|
+
genericExecutor: GENERIC_EXECUTOR_EVM_TESTNET
|
|
2960
3100
|
}
|
|
2961
3101
|
},
|
|
2962
3102
|
forwarderSupported: {
|
|
@@ -3012,6 +3152,9 @@ var EarnChain;
|
|
|
3012
3152
|
destination: true
|
|
3013
3153
|
}
|
|
3014
3154
|
},
|
|
3155
|
+
cctpx: {
|
|
3156
|
+
serviceAddress: CCTPX_SERVICE_ADDRESS_EVM_MAINNET
|
|
3157
|
+
},
|
|
3015
3158
|
kitContracts: {
|
|
3016
3159
|
bridge: BRIDGE_CONTRACT_EVM_MAINNET,
|
|
3017
3160
|
adapter: ADAPTER_CONTRACT_EVM_MAINNET
|
|
@@ -3077,6 +3220,9 @@ var EarnChain;
|
|
|
3077
3220
|
destination: true
|
|
3078
3221
|
}
|
|
3079
3222
|
},
|
|
3223
|
+
cctpx: {
|
|
3224
|
+
serviceAddress: CCTPX_SERVICE_ADDRESS_EVM_TESTNET
|
|
3225
|
+
},
|
|
3080
3226
|
kitContracts: {
|
|
3081
3227
|
bridge: BRIDGE_CONTRACT_EVM_TESTNET,
|
|
3082
3228
|
adapter: ADAPTER_CONTRACT_EVM_TESTNET
|
|
@@ -3142,6 +3288,9 @@ var EarnChain;
|
|
|
3142
3288
|
destination: true
|
|
3143
3289
|
}
|
|
3144
3290
|
},
|
|
3291
|
+
cctpx: {
|
|
3292
|
+
serviceAddress: CCTPX_SERVICE_ADDRESS_EVM_MAINNET
|
|
3293
|
+
},
|
|
3145
3294
|
kitContracts: {
|
|
3146
3295
|
bridge: BRIDGE_CONTRACT_EVM_MAINNET,
|
|
3147
3296
|
adapter: ADAPTER_CONTRACT_EVM_MAINNET
|
|
@@ -3151,7 +3300,9 @@ var EarnChain;
|
|
|
3151
3300
|
contracts: {
|
|
3152
3301
|
v1: {
|
|
3153
3302
|
wallet: GATEWAY_WALLET_EVM_MAINNET,
|
|
3154
|
-
minter: GATEWAY_MINTER_EVM_MAINNET
|
|
3303
|
+
minter: GATEWAY_MINTER_EVM_MAINNET,
|
|
3304
|
+
depositForHandler: DEPOSIT_FOR_HANDLER_EVM_MAINNET,
|
|
3305
|
+
genericExecutor: GENERIC_EXECUTOR_EVM_MAINNET
|
|
3155
3306
|
}
|
|
3156
3307
|
},
|
|
3157
3308
|
forwarderSupported: {
|
|
@@ -3207,6 +3358,9 @@ var EarnChain;
|
|
|
3207
3358
|
rpcEndpoints: [
|
|
3208
3359
|
'https://api.avax-test.network/ext/bc/C/rpc'
|
|
3209
3360
|
],
|
|
3361
|
+
cctpx: {
|
|
3362
|
+
serviceAddress: CCTPX_SERVICE_ADDRESS_EVM_TESTNET
|
|
3363
|
+
},
|
|
3210
3364
|
kitContracts: {
|
|
3211
3365
|
bridge: BRIDGE_CONTRACT_EVM_TESTNET
|
|
3212
3366
|
},
|
|
@@ -3215,7 +3369,9 @@ var EarnChain;
|
|
|
3215
3369
|
contracts: {
|
|
3216
3370
|
v1: {
|
|
3217
3371
|
wallet: GATEWAY_WALLET_EVM_TESTNET,
|
|
3218
|
-
minter: GATEWAY_MINTER_EVM_TESTNET
|
|
3372
|
+
minter: GATEWAY_MINTER_EVM_TESTNET,
|
|
3373
|
+
depositForHandler: DEPOSIT_FOR_HANDLER_EVM_TESTNET,
|
|
3374
|
+
genericExecutor: GENERIC_EXECUTOR_EVM_TESTNET
|
|
3219
3375
|
}
|
|
3220
3376
|
},
|
|
3221
3377
|
forwarderSupported: {
|
|
@@ -3272,6 +3428,9 @@ var EarnChain;
|
|
|
3272
3428
|
destination: true
|
|
3273
3429
|
}
|
|
3274
3430
|
},
|
|
3431
|
+
cctpx: {
|
|
3432
|
+
serviceAddress: CCTPX_SERVICE_ADDRESS_EVM_MAINNET
|
|
3433
|
+
},
|
|
3275
3434
|
kitContracts: {
|
|
3276
3435
|
bridge: BRIDGE_CONTRACT_EVM_MAINNET,
|
|
3277
3436
|
adapter: ADAPTER_CONTRACT_EVM_MAINNET
|
|
@@ -3337,6 +3496,9 @@ var EarnChain;
|
|
|
3337
3496
|
destination: true
|
|
3338
3497
|
}
|
|
3339
3498
|
},
|
|
3499
|
+
cctpx: {
|
|
3500
|
+
serviceAddress: CCTPX_SERVICE_ADDRESS_EVM_TESTNET
|
|
3501
|
+
},
|
|
3340
3502
|
kitContracts: {
|
|
3341
3503
|
bridge: BRIDGE_CONTRACT_EVM_TESTNET,
|
|
3342
3504
|
adapter: ADAPTER_CONTRACT_EVM_TESTNET
|
|
@@ -3528,6 +3690,7 @@ var EarnChain;
|
|
|
3528
3690
|
v2: {
|
|
3529
3691
|
type: 'split',
|
|
3530
3692
|
tokenMessenger: '0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d',
|
|
3693
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_MAINNET,
|
|
3531
3694
|
messageTransmitter: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',
|
|
3532
3695
|
confirmations: 1,
|
|
3533
3696
|
fastConfirmations: 1
|
|
@@ -3573,6 +3736,7 @@ var EarnChain;
|
|
|
3573
3736
|
v2: {
|
|
3574
3737
|
type: 'split',
|
|
3575
3738
|
tokenMessenger: '0x8FE6B999Dc680CcFDD5Bf7EB0974218be2542DAA',
|
|
3739
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_TESTNET,
|
|
3576
3740
|
messageTransmitter: '0xE737e5cEBEEBa77EFE34D4aa090756590b1CE275',
|
|
3577
3741
|
confirmations: 1,
|
|
3578
3742
|
fastConfirmations: 1
|
|
@@ -3618,6 +3782,7 @@ var EarnChain;
|
|
|
3618
3782
|
v2: {
|
|
3619
3783
|
type: 'split',
|
|
3620
3784
|
tokenMessenger: '0x98706A006bc632Df31CAdFCBD43F38887ce2ca5c',
|
|
3785
|
+
tokenMessengerWithFees: '0x3Ac96675F9a3E6922713e041645D82f3561d3686',
|
|
3621
3786
|
messageTransmitter: '0x5b61381Fc9e58E70EfC13a4A97516997019198ee',
|
|
3622
3787
|
confirmations: 65,
|
|
3623
3788
|
fastConfirmations: 1
|
|
@@ -3663,6 +3828,7 @@ var EarnChain;
|
|
|
3663
3828
|
v2: {
|
|
3664
3829
|
type: 'split',
|
|
3665
3830
|
tokenMessenger: '0x8FE6B999Dc680CcFDD5Bf7EB0974218be2542DAA',
|
|
3831
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_TESTNET,
|
|
3666
3832
|
messageTransmitter: '0xE737e5cEBEEBa77EFE34D4aa090756590b1CE275',
|
|
3667
3833
|
confirmations: 65,
|
|
3668
3834
|
fastConfirmations: 1
|
|
@@ -3725,6 +3891,9 @@ var EarnChain;
|
|
|
3725
3891
|
destination: true
|
|
3726
3892
|
}
|
|
3727
3893
|
},
|
|
3894
|
+
cctpx: {
|
|
3895
|
+
serviceAddress: CCTPX_SERVICE_ADDRESS_EVM_MAINNET
|
|
3896
|
+
},
|
|
3728
3897
|
kitContracts: {
|
|
3729
3898
|
bridge: BRIDGE_CONTRACT_EVM_MAINNET,
|
|
3730
3899
|
adapter: ADAPTER_CONTRACT_EVM_MAINNET
|
|
@@ -3790,6 +3959,9 @@ var EarnChain;
|
|
|
3790
3959
|
destination: true
|
|
3791
3960
|
}
|
|
3792
3961
|
},
|
|
3962
|
+
cctpx: {
|
|
3963
|
+
serviceAddress: CCTPX_SERVICE_ADDRESS_EVM_TESTNET
|
|
3964
|
+
},
|
|
3793
3965
|
kitContracts: {
|
|
3794
3966
|
bridge: BRIDGE_CONTRACT_EVM_TESTNET,
|
|
3795
3967
|
adapter: ADAPTER_CONTRACT_EVM_TESTNET
|
|
@@ -4011,6 +4183,7 @@ var EarnChain;
|
|
|
4011
4183
|
v2: {
|
|
4012
4184
|
type: 'split',
|
|
4013
4185
|
tokenMessenger: '0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d',
|
|
4186
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_MAINNET,
|
|
4014
4187
|
messageTransmitter: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',
|
|
4015
4188
|
confirmations: 1,
|
|
4016
4189
|
fastConfirmations: 1
|
|
@@ -4058,6 +4231,7 @@ var EarnChain;
|
|
|
4058
4231
|
v2: {
|
|
4059
4232
|
type: 'split',
|
|
4060
4233
|
tokenMessenger: '0x8FE6B999Dc680CcFDD5Bf7EB0974218be2542DAA',
|
|
4234
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_TESTNET,
|
|
4061
4235
|
messageTransmitter: '0xE737e5cEBEEBa77EFE34D4aa090756590b1CE275',
|
|
4062
4236
|
confirmations: 1,
|
|
4063
4237
|
fastConfirmations: 1
|
|
@@ -4339,6 +4513,7 @@ var EarnChain;
|
|
|
4339
4513
|
v2: {
|
|
4340
4514
|
type: 'split',
|
|
4341
4515
|
tokenMessenger: '0x8FE6B999Dc680CcFDD5Bf7EB0974218be2542DAA',
|
|
4516
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_TESTNET,
|
|
4342
4517
|
messageTransmitter: '0xE737e5cEBEEBa77EFE34D4aa090756590b1CE275',
|
|
4343
4518
|
confirmations: 1,
|
|
4344
4519
|
fastConfirmations: 1
|
|
@@ -4384,6 +4559,7 @@ var EarnChain;
|
|
|
4384
4559
|
v2: {
|
|
4385
4560
|
type: 'split',
|
|
4386
4561
|
tokenMessenger: '0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d',
|
|
4562
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_MAINNET,
|
|
4387
4563
|
messageTransmitter: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',
|
|
4388
4564
|
confirmations: 64,
|
|
4389
4565
|
fastConfirmations: 1
|
|
@@ -4429,6 +4605,7 @@ var EarnChain;
|
|
|
4429
4605
|
v2: {
|
|
4430
4606
|
type: 'split',
|
|
4431
4607
|
tokenMessenger: '0x8FE6B999Dc680CcFDD5Bf7EB0974218be2542DAA',
|
|
4608
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_TESTNET,
|
|
4432
4609
|
messageTransmitter: '0xE737e5cEBEEBa77EFE34D4aa090756590b1CE275',
|
|
4433
4610
|
confirmations: 64,
|
|
4434
4611
|
fastConfirmations: 1
|
|
@@ -4616,6 +4793,9 @@ var EarnChain;
|
|
|
4616
4793
|
destination: true
|
|
4617
4794
|
}
|
|
4618
4795
|
},
|
|
4796
|
+
cctpx: {
|
|
4797
|
+
serviceAddress: CCTPX_SERVICE_ADDRESS_EVM_MAINNET
|
|
4798
|
+
},
|
|
4619
4799
|
kitContracts: {
|
|
4620
4800
|
bridge: BRIDGE_CONTRACT_EVM_MAINNET,
|
|
4621
4801
|
adapter: ADAPTER_CONTRACT_EVM_MAINNET
|
|
@@ -4681,6 +4861,9 @@ var EarnChain;
|
|
|
4681
4861
|
destination: true
|
|
4682
4862
|
}
|
|
4683
4863
|
},
|
|
4864
|
+
cctpx: {
|
|
4865
|
+
serviceAddress: CCTPX_SERVICE_ADDRESS_EVM_TESTNET
|
|
4866
|
+
},
|
|
4684
4867
|
kitContracts: {
|
|
4685
4868
|
bridge: BRIDGE_CONTRACT_EVM_TESTNET
|
|
4686
4869
|
},
|
|
@@ -4730,6 +4913,7 @@ var EarnChain;
|
|
|
4730
4913
|
v2: {
|
|
4731
4914
|
type: 'split',
|
|
4732
4915
|
tokenMessenger: '0x28b5a0e9C621a5BadaA536219b3a228C8168cf5d',
|
|
4916
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_MAINNET,
|
|
4733
4917
|
messageTransmitter: '0x81D40F21F12A8F0E3252Bccb954D722d4c464B64',
|
|
4734
4918
|
confirmations: 1,
|
|
4735
4919
|
fastConfirmations: 1
|
|
@@ -4776,6 +4960,7 @@ var EarnChain;
|
|
|
4776
4960
|
v2: {
|
|
4777
4961
|
type: 'split',
|
|
4778
4962
|
tokenMessenger: '0x8FE6B999Dc680CcFDD5Bf7EB0974218be2542DAA',
|
|
4963
|
+
tokenMessengerWithFees: TOKEN_MESSENGER_WITH_FEES_EVM_TESTNET,
|
|
4779
4964
|
messageTransmitter: '0xE737e5cEBEEBa77EFE34D4aa090756590b1CE275',
|
|
4780
4965
|
confirmations: 1,
|
|
4781
4966
|
fastConfirmations: 1
|
|
@@ -5074,6 +5259,9 @@ var EarnChain;
|
|
|
5074
5259
|
destination: true
|
|
5075
5260
|
}
|
|
5076
5261
|
},
|
|
5262
|
+
cctpx: {
|
|
5263
|
+
serviceAddress: CCTPX_SERVICE_ADDRESS_EVM_MAINNET
|
|
5264
|
+
},
|
|
5077
5265
|
kitContracts: {
|
|
5078
5266
|
bridge: BRIDGE_CONTRACT_EVM_MAINNET,
|
|
5079
5267
|
adapter: ADAPTER_CONTRACT_EVM_MAINNET
|
|
@@ -5083,7 +5271,9 @@ var EarnChain;
|
|
|
5083
5271
|
contracts: {
|
|
5084
5272
|
v1: {
|
|
5085
5273
|
wallet: GATEWAY_WALLET_EVM_MAINNET,
|
|
5086
|
-
minter: GATEWAY_MINTER_EVM_MAINNET
|
|
5274
|
+
minter: GATEWAY_MINTER_EVM_MAINNET,
|
|
5275
|
+
depositForHandler: DEPOSIT_FOR_HANDLER_EVM_MAINNET,
|
|
5276
|
+
genericExecutor: GENERIC_EXECUTOR_EVM_MAINNET
|
|
5087
5277
|
}
|
|
5088
5278
|
},
|
|
5089
5279
|
forwarderSupported: {
|
|
@@ -5140,6 +5330,9 @@ var EarnChain;
|
|
|
5140
5330
|
destination: true
|
|
5141
5331
|
}
|
|
5142
5332
|
},
|
|
5333
|
+
cctpx: {
|
|
5334
|
+
serviceAddress: CCTPX_SERVICE_ADDRESS_EVM_TESTNET
|
|
5335
|
+
},
|
|
5143
5336
|
kitContracts: {
|
|
5144
5337
|
bridge: BRIDGE_CONTRACT_EVM_TESTNET
|
|
5145
5338
|
},
|
|
@@ -5148,7 +5341,9 @@ var EarnChain;
|
|
|
5148
5341
|
contracts: {
|
|
5149
5342
|
v1: {
|
|
5150
5343
|
wallet: GATEWAY_WALLET_EVM_TESTNET,
|
|
5151
|
-
minter: GATEWAY_MINTER_EVM_TESTNET
|
|
5344
|
+
minter: GATEWAY_MINTER_EVM_TESTNET,
|
|
5345
|
+
depositForHandler: DEPOSIT_FOR_HANDLER_EVM_TESTNET,
|
|
5346
|
+
genericExecutor: GENERIC_EXECUTOR_EVM_TESTNET
|
|
5152
5347
|
}
|
|
5153
5348
|
},
|
|
5154
5349
|
forwarderSupported: {
|
|
@@ -6146,6 +6341,7 @@ var Chains = {
|
|
|
6146
6341
|
AptosTestnet: AptosTestnet,
|
|
6147
6342
|
Arbitrum: Arbitrum,
|
|
6148
6343
|
ArbitrumSepolia: ArbitrumSepolia,
|
|
6344
|
+
Arc: Arc,
|
|
6149
6345
|
ArcTestnet: ArcTestnet,
|
|
6150
6346
|
Avalanche: Avalanche,
|
|
6151
6347
|
AvalancheFuji: AvalancheFuji,
|
|
@@ -6234,6 +6430,67 @@ var Chains = {
|
|
|
6234
6430
|
return chain.cctp?.contracts.v2 !== undefined;
|
|
6235
6431
|
}
|
|
6236
6432
|
|
|
6433
|
+
/**
|
|
6434
|
+
* Chains the Fee Service accepts as a SOURCE for source-paid ("receive-exact")
|
|
6435
|
+
* CCTP v2 fees. An explicit allowlist is required because the
|
|
6436
|
+
* `TokenMessengerWithFees` wrapper address is now shared with the fast-deposit
|
|
6437
|
+
* forwarder path, so wrapper presence no longer implies source-fee support.
|
|
6438
|
+
* Keep in sync with backend coverage.
|
|
6439
|
+
*/ new Set([
|
|
6440
|
+
// Mainnet
|
|
6441
|
+
Blockchain.Ethereum,
|
|
6442
|
+
Blockchain.Base,
|
|
6443
|
+
Blockchain.Arbitrum,
|
|
6444
|
+
Blockchain.Unichain,
|
|
6445
|
+
Blockchain.Optimism,
|
|
6446
|
+
Blockchain.Codex,
|
|
6447
|
+
Blockchain.Ink,
|
|
6448
|
+
Blockchain.Plume,
|
|
6449
|
+
Blockchain.Linea,
|
|
6450
|
+
Blockchain.World_Chain,
|
|
6451
|
+
// Testnet counterparts
|
|
6452
|
+
Blockchain.Ethereum_Sepolia,
|
|
6453
|
+
Blockchain.Base_Sepolia,
|
|
6454
|
+
Blockchain.Arbitrum_Sepolia,
|
|
6455
|
+
Blockchain.Unichain_Sepolia,
|
|
6456
|
+
Blockchain.Optimism_Sepolia,
|
|
6457
|
+
Blockchain.Codex_Testnet,
|
|
6458
|
+
Blockchain.Ink_Testnet,
|
|
6459
|
+
Blockchain.Plume_Testnet,
|
|
6460
|
+
Blockchain.Linea_Sepolia,
|
|
6461
|
+
Blockchain.World_Chain_Sepolia
|
|
6462
|
+
]);
|
|
6463
|
+
|
|
6464
|
+
/**
|
|
6465
|
+
* Temporary allowlist of chains permitted to initiate Gateway fast deposits.
|
|
6466
|
+
* Only chains keyed here are eligible; all others are rejected. Using the
|
|
6467
|
+
* {@link Blockchain} enum keeps entries type-safe and catches typos at compile
|
|
6468
|
+
* time. Remove this allowlist once roll-out is complete.
|
|
6469
|
+
*/ new Set([
|
|
6470
|
+
// Mainnet
|
|
6471
|
+
Blockchain.Ethereum,
|
|
6472
|
+
Blockchain.Base,
|
|
6473
|
+
Blockchain.Arbitrum,
|
|
6474
|
+
Blockchain.Unichain,
|
|
6475
|
+
Blockchain.Optimism,
|
|
6476
|
+
Blockchain.Codex,
|
|
6477
|
+
Blockchain.Ink,
|
|
6478
|
+
Blockchain.Plume,
|
|
6479
|
+
Blockchain.Linea,
|
|
6480
|
+
Blockchain.World_Chain,
|
|
6481
|
+
// Testnet counterparts
|
|
6482
|
+
Blockchain.Ethereum_Sepolia,
|
|
6483
|
+
Blockchain.Base_Sepolia,
|
|
6484
|
+
Blockchain.Arbitrum_Sepolia,
|
|
6485
|
+
Blockchain.Unichain_Sepolia,
|
|
6486
|
+
Blockchain.Optimism_Sepolia,
|
|
6487
|
+
Blockchain.Codex_Testnet,
|
|
6488
|
+
Blockchain.Ink_Testnet,
|
|
6489
|
+
Blockchain.Plume_Testnet,
|
|
6490
|
+
Blockchain.Linea_Sepolia,
|
|
6491
|
+
Blockchain.World_Chain_Sepolia
|
|
6492
|
+
]);
|
|
6493
|
+
|
|
6237
6494
|
/**
|
|
6238
6495
|
* Zod schema for validating Gateway v1 contract addresses.
|
|
6239
6496
|
*
|
|
@@ -6255,7 +6512,10 @@ var Chains = {
|
|
|
6255
6512
|
}).min(1, 'Gateway minter address cannot be empty.'),
|
|
6256
6513
|
depositForHandler: zod.z.string({
|
|
6257
6514
|
invalid_type_error: 'Gateway depositForHandler address must be a string.'
|
|
6258
|
-
}).min(1, 'Gateway depositForHandler address cannot be empty.').optional()
|
|
6515
|
+
}).min(1, 'Gateway depositForHandler address cannot be empty.').optional(),
|
|
6516
|
+
genericExecutor: zod.z.string({
|
|
6517
|
+
invalid_type_error: 'Gateway genericExecutor address must be a string.'
|
|
6518
|
+
}).min(1, 'Gateway genericExecutor address cannot be empty.').optional()
|
|
6259
6519
|
}).strict() // Reject any additional properties not defined in the schema
|
|
6260
6520
|
;
|
|
6261
6521
|
/**
|
|
@@ -6339,6 +6599,7 @@ var Chains = {
|
|
|
6339
6599
|
usdcAddress: zod.z.string().nullable(),
|
|
6340
6600
|
usdtAddress: zod.z.string().nullable(),
|
|
6341
6601
|
cctp: zod.z.any().nullable(),
|
|
6602
|
+
cctpx: zod.z.any().optional(),
|
|
6342
6603
|
kitContracts: zod.z.object({
|
|
6343
6604
|
bridge: zod.z.string().optional(),
|
|
6344
6605
|
adapter: zod.z.string().optional()
|
|
@@ -6544,14 +6805,15 @@ const EARN_BRIDGE_DESTINATION_CHAIN_VALUES = EARN_BRIDGE_DESTINATION_BLOCKCHAINS
|
|
|
6544
6805
|
* Zod schema for validating the source chain of a cross-chain Earn deposit.
|
|
6545
6806
|
*
|
|
6546
6807
|
* Accept a supported source Blockchain value, a matching string literal, or a
|
|
6547
|
-
* ChainDefinition for a supported source chain. Source chains are Ethereum
|
|
6548
|
-
*
|
|
6808
|
+
* ChainDefinition for a supported source chain. Source chains are Ethereum,
|
|
6809
|
+
* Arbitrum, and Base (mainnet and testnet).
|
|
6549
6810
|
*
|
|
6550
6811
|
* @example
|
|
6551
6812
|
* ```typescript
|
|
6552
6813
|
* import { earnBridgeSourceChainIdentifierSchema } from '@core/chains'
|
|
6553
6814
|
*
|
|
6554
6815
|
* // Valid
|
|
6816
|
+
* earnBridgeSourceChainIdentifierSchema.parse('Ethereum')
|
|
6555
6817
|
* earnBridgeSourceChainIdentifierSchema.parse('Ethereum_Sepolia')
|
|
6556
6818
|
*
|
|
6557
6819
|
* // Invalid (throws ZodError)
|
|
@@ -6570,14 +6832,15 @@ const EARN_BRIDGE_DESTINATION_CHAIN_VALUES = EARN_BRIDGE_DESTINATION_BLOCKCHAINS
|
|
|
6570
6832
|
* deposit.
|
|
6571
6833
|
*
|
|
6572
6834
|
* Accept a supported destination Blockchain value, a matching string literal,
|
|
6573
|
-
* or a ChainDefinition for a supported destination chain.
|
|
6574
|
-
* Testnet
|
|
6835
|
+
* or a ChainDefinition for a supported destination chain. Arc (mainnet) and
|
|
6836
|
+
* Arc Testnet are supported.
|
|
6575
6837
|
*
|
|
6576
6838
|
* @example
|
|
6577
6839
|
* ```typescript
|
|
6578
6840
|
* import { earnBridgeDestinationChainIdentifierSchema } from '@core/chains'
|
|
6579
6841
|
*
|
|
6580
6842
|
* // Valid
|
|
6843
|
+
* earnBridgeDestinationChainIdentifierSchema.parse('Arc')
|
|
6581
6844
|
* earnBridgeDestinationChainIdentifierSchema.parse('Arc_Testnet')
|
|
6582
6845
|
*
|
|
6583
6846
|
* // Invalid (throws ZodError)
|
|
@@ -7623,6 +7886,7 @@ const swapTokenEnumSchema = zod.z.enum([
|
|
|
7623
7886
|
// Mainnets (alphabetically sorted)
|
|
7624
7887
|
// =========================================================================
|
|
7625
7888
|
[Blockchain.Arbitrum]: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
|
|
7889
|
+
[Blockchain.Arc]: '0x3600000000000000000000000000000000000000',
|
|
7626
7890
|
[Blockchain.Avalanche]: '0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E',
|
|
7627
7891
|
[Blockchain.Base]: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
|
|
7628
7892
|
[Blockchain.Celo]: '0xcebA9300f2b948710d2653dD7B07f33A8B32118C',
|
|
@@ -7737,6 +8001,7 @@ const swapTokenEnumSchema = zod.z.enum([
|
|
|
7737
8001
|
// =========================================================================
|
|
7738
8002
|
// Mainnets
|
|
7739
8003
|
// =========================================================================
|
|
8004
|
+
[Blockchain.Arc]: '0xbEf5f6d51CB62b58e6A8f77868681825C6fe21c1',
|
|
7740
8005
|
[Blockchain.Avalanche]: '0xc891EB4cbdEFf6e073e859e987815Ed1505c2ACD',
|
|
7741
8006
|
[Blockchain.Base]: '0x60a3E35Cc302bFA44Cb288Bc5a4F316Fdb1adb42',
|
|
7742
8007
|
[Blockchain.Cronos]: '0xA6dE01a2d62C6B5f3525d768f34d276652C554c8',
|
|
@@ -7980,6 +8245,7 @@ const swapTokenEnumSchema = zod.z.enum([
|
|
|
7980
8245
|
// =========================================================================
|
|
7981
8246
|
// Mainnets
|
|
7982
8247
|
// =========================================================================
|
|
8248
|
+
[Blockchain.Arc]: '0x171A4217b86A807A64eB94757Db6849fb4bDbAA0',
|
|
7983
8249
|
[Blockchain.Ethereum]: '0x72DFB2E44f59C5AD2bAFE84314E5b99a7cd5075E',
|
|
7984
8250
|
// =========================================================================
|
|
7985
8251
|
// Testnets
|
|
@@ -8072,13 +8338,28 @@ const swapTokenEnumSchema = zod.z.enum([
|
|
|
8072
8338
|
}
|
|
8073
8339
|
|
|
8074
8340
|
/**
|
|
8075
|
-
*
|
|
8341
|
+
* Type guard: narrows a {@link TokenSelector} to a {@link RawTokenSelector}.
|
|
8076
8342
|
*
|
|
8077
8343
|
* @param selector - The token selector to check.
|
|
8078
|
-
* @returns
|
|
8344
|
+
* @returns `true` if `selector` is a raw token selector (object with `locator`).
|
|
8345
|
+
*
|
|
8346
|
+
* @example
|
|
8347
|
+
* ```typescript
|
|
8348
|
+
* if (isRawSelector(selector)) {
|
|
8349
|
+
* console.log(selector.locator)
|
|
8350
|
+
* }
|
|
8351
|
+
* ```
|
|
8079
8352
|
*/ function isRawSelector(selector) {
|
|
8080
|
-
|
|
8353
|
+
// `typeof null === 'object'` (a JS quirk) and `'locator' in null`
|
|
8354
|
+
// throws, so the explicit `null` check is required at this exported
|
|
8355
|
+
// guard for JS consumers passing nullish values. The lint rule sees
|
|
8356
|
+
// the parameter typed as `TokenSelector` (no null) and flags the
|
|
8357
|
+
// check as unnecessary — disabled because the check IS necessary at
|
|
8358
|
+
// runtime even though TypeScript can prove it dead statically.
|
|
8359
|
+
return typeof selector === 'object' && // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
8360
|
+
selector !== null && 'locator' in selector;
|
|
8081
8361
|
}
|
|
8362
|
+
|
|
8082
8363
|
/**
|
|
8083
8364
|
* Normalize a symbol to uppercase for case-insensitive lookup.
|
|
8084
8365
|
*
|
|
@@ -8266,7 +8547,7 @@ const swapTokenEnumSchema = zod.z.enum([
|
|
|
8266
8547
|
if (typeof selector === 'string') {
|
|
8267
8548
|
return resolveSymbol(selector, chainId);
|
|
8268
8549
|
}
|
|
8269
|
-
throw createTokenResolutionError(`Invalid selector type: ${typeof selector}. Expected
|
|
8550
|
+
throw createTokenResolutionError(`Invalid selector type: ${typeof selector}. Expected a token symbol or a raw selector (with locator).`, selector, chainId);
|
|
8270
8551
|
},
|
|
8271
8552
|
resolveByAddress (address, chainId) {
|
|
8272
8553
|
if (!address || typeof address !== 'string') {
|
|
@@ -8469,7 +8750,7 @@ const swapTokenEnumSchema = zod.z.enum([
|
|
|
8469
8750
|
* allowlisted {@link ClientLogPayload} fields (and the allowlisted
|
|
8470
8751
|
* sub-fields of `errorDetails` / `clientContext`) are copied across.
|
|
8471
8752
|
* A regressing upstream mapper — or a plain-JS caller that bypasses the
|
|
8472
|
-
* type — therefore cannot exfiltrate stray properties (secrets,
|
|
8753
|
+
* type — therefore cannot exfiltrate stray properties (secrets,
|
|
8473
8754
|
* raw error stacks) through the analytics channel. Optional fields are
|
|
8474
8755
|
* only included when present so the serialised shape matches the
|
|
8475
8756
|
* server's strict schema.
|
|
@@ -8492,6 +8773,9 @@ const swapTokenEnumSchema = zod.z.enum([
|
|
|
8492
8773
|
if (payload.destinationChain !== undefined) safe['destinationChain'] = payload.destinationChain;
|
|
8493
8774
|
if (payload.tokenIn !== undefined) safe['tokenIn'] = payload.tokenIn;
|
|
8494
8775
|
if (payload.tokenOut !== undefined) safe['tokenOut'] = payload.tokenOut;
|
|
8776
|
+
if (payload.amountIn !== undefined) safe['amountIn'] = payload.amountIn;
|
|
8777
|
+
if (payload.durationMs !== undefined) safe['durationMs'] = payload.durationMs;
|
|
8778
|
+
if (payload.sourceAddress !== undefined) safe['sourceAddress'] = payload.sourceAddress;
|
|
8495
8779
|
if (payload.txHash !== undefined) safe['txHash'] = payload.txHash;
|
|
8496
8780
|
if (payload.correlationId !== undefined) safe['correlationId'] = payload.correlationId;
|
|
8497
8781
|
if (payload.errorDetails !== undefined) {
|
|
@@ -8688,14 +8972,28 @@ const swapTokenEnumSchema = zod.z.enum([
|
|
|
8688
8972
|
}
|
|
8689
8973
|
|
|
8690
8974
|
/**
|
|
8691
|
-
*
|
|
8692
|
-
*
|
|
8975
|
+
* Emit a stable console warning when building or emitting a telemetry payload
|
|
8976
|
+
* throws — for example, a buggy `TelemetryContextResolver`, a regression in
|
|
8693
8977
|
* `extractErrorDetails`, or a synchronous failure inside `emitAnalyticsLog`
|
|
8694
|
-
* before it could swallow the error itself.
|
|
8695
|
-
*
|
|
8696
|
-
*
|
|
8978
|
+
* before it could swallow the error itself. Uses a stable prefix so the
|
|
8979
|
+
* drop is discoverable via grep. Never re-throws: the caller's original
|
|
8980
|
+
* operation error must always win.
|
|
8697
8981
|
*
|
|
8698
8982
|
* @internal
|
|
8983
|
+
*
|
|
8984
|
+
* @param eventType - The telemetry event type that was being emitted.
|
|
8985
|
+
* @param cause - The error or value that caused the drop.
|
|
8986
|
+
*
|
|
8987
|
+
* @example
|
|
8988
|
+
* ```typescript
|
|
8989
|
+
* import { warnTelemetryDrop } from '@core/utils'
|
|
8990
|
+
*
|
|
8991
|
+
* try {
|
|
8992
|
+
* void emitAnalyticsLog(payload)
|
|
8993
|
+
* } catch (err) {
|
|
8994
|
+
* warnTelemetryDrop('my_event', err)
|
|
8995
|
+
* }
|
|
8996
|
+
* ```
|
|
8699
8997
|
*/ function warnTelemetryDrop(eventType, cause) {
|
|
8700
8998
|
try {
|
|
8701
8999
|
// Pass `cause` as the second console.warn argument rather than
|
|
@@ -8735,6 +9033,9 @@ const swapTokenEnumSchema = zod.z.enum([
|
|
|
8735
9033
|
...context?.tokenOut != null && {
|
|
8736
9034
|
tokenOut: context.tokenOut
|
|
8737
9035
|
},
|
|
9036
|
+
...context?.amountIn != null && {
|
|
9037
|
+
amountIn: context.amountIn
|
|
9038
|
+
},
|
|
8738
9039
|
...context?.txHash != null && {
|
|
8739
9040
|
txHash: context.txHash
|
|
8740
9041
|
},
|
|
@@ -8834,7 +9135,7 @@ const swapTokenEnumSchema = zod.z.enum([
|
|
|
8834
9135
|
}
|
|
8835
9136
|
|
|
8836
9137
|
var name$3 = "@circle-fin/bridge-kit";
|
|
8837
|
-
var version$3 = "1.
|
|
9138
|
+
var version$3 = "1.15.0";
|
|
8838
9139
|
var pkg$3 = {
|
|
8839
9140
|
name: name$3,
|
|
8840
9141
|
version: version$3};
|
|
@@ -9454,7 +9755,72 @@ var TransferSpeed;
|
|
|
9454
9755
|
*/ recipientAddress: zod.z.string().trim().min(1, 'Fee recipient must be a non-empty string').optional()
|
|
9455
9756
|
}).strict();
|
|
9456
9757
|
/**
|
|
9457
|
-
*
|
|
9758
|
+
* Factory for the bridge-params Zod schema, parameterized by the token
|
|
9759
|
+
* validator. The base schema enforces all non-token fields (amount,
|
|
9760
|
+
* source, destination, config); callers supply the Zod schema for the
|
|
9761
|
+
* `token` field, allowing each provider to validate the token type it
|
|
9762
|
+
* accepts.
|
|
9763
|
+
*
|
|
9764
|
+
* @param tokenSchema - Zod schema applied to the `token` field. Pass
|
|
9765
|
+
* `z.literal('USDC')` for USDC-only validation, or any
|
|
9766
|
+
* provider-specific schema (e.g. a `0x`-prefixed hex regex) for
|
|
9767
|
+
* providers that accept a different token type.
|
|
9768
|
+
* @param config - Required. `maxDecimals` caps the decimal precision
|
|
9769
|
+
* permitted in `amount` and `config.maxFee`. Pass the widest value
|
|
9770
|
+
* any of the provider's tokens require — `6` for USDC-only, `18`
|
|
9771
|
+
* for an ERC-20 family that includes wETH, etc. The schema is a
|
|
9772
|
+
* coarse syntactic gate; narrower per-token precision is enforced
|
|
9773
|
+
* by the provider downstream.
|
|
9774
|
+
* @returns A Zod object schema whose `token` field is validated by
|
|
9775
|
+
* `tokenSchema` and whose other fields (`amount`, `source`,
|
|
9776
|
+
* `destination`, `config`) are validated against the shared bridge
|
|
9777
|
+
* contract. Use `.safeParse` / `.parse` directly, or feed the schema
|
|
9778
|
+
* to {@link parseOrThrow} from `@core/utils` to surface validation
|
|
9779
|
+
* failures as `KitError` with the canonical
|
|
9780
|
+
* `INPUT_VALIDATION_FAILED` code.
|
|
9781
|
+
*
|
|
9782
|
+
* @example
|
|
9783
|
+
* ```typescript
|
|
9784
|
+
* import { createBridgeParamsSchema, z } from '@core/provider'
|
|
9785
|
+
*
|
|
9786
|
+
* const usdcSchema = createBridgeParamsSchema(z.literal('USDC'), { maxDecimals: 6 })
|
|
9787
|
+
* const hexSchema = createBridgeParamsSchema(
|
|
9788
|
+
* z.string().regex(/^0x[0-9a-fA-F]{64}$/),
|
|
9789
|
+
* { maxDecimals: 18 },
|
|
9790
|
+
* )
|
|
9791
|
+
* ```
|
|
9792
|
+
*/ // The full inferred return type of `z.object({...})` here is
|
|
9793
|
+
// effectively impossible to spell out by hand without re-stating every
|
|
9794
|
+
// field's schema. TypeScript infers it from the body — callers receive
|
|
9795
|
+
// a precise Zod schema type via inference, and the explicit-return
|
|
9796
|
+
// rules are disabled for that reason.
|
|
9797
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/explicit-module-boundary-types
|
|
9798
|
+
function createBridgeParamsSchema(tokenSchema, config) {
|
|
9799
|
+
const { maxDecimals } = config;
|
|
9800
|
+
return zod.z.object({
|
|
9801
|
+
amount: zod.z.string().min(1, 'Required').pipe(createDecimalStringValidator({
|
|
9802
|
+
allowZero: false,
|
|
9803
|
+
regexMessage: AMOUNT_FORMAT_ERROR_MESSAGE,
|
|
9804
|
+
attributeName: 'amount',
|
|
9805
|
+
maxDecimals
|
|
9806
|
+
})(zod.z.string())),
|
|
9807
|
+
source: walletContextSchema,
|
|
9808
|
+
destination: bridgeDestinationSchema$1,
|
|
9809
|
+
token: tokenSchema,
|
|
9810
|
+
config: zod.z.object({
|
|
9811
|
+
transferSpeed: zod.z.nativeEnum(TransferSpeed).optional(),
|
|
9812
|
+
maxFee: zod.z.string().pipe(createDecimalStringValidator({
|
|
9813
|
+
allowZero: true,
|
|
9814
|
+
regexMessage: MAX_FEE_FORMAT_ERROR_MESSAGE,
|
|
9815
|
+
attributeName: 'maxFee',
|
|
9816
|
+
maxDecimals
|
|
9817
|
+
})(zod.z.string())).optional(),
|
|
9818
|
+
customFee: customFeeSchema.optional()
|
|
9819
|
+
})
|
|
9820
|
+
});
|
|
9821
|
+
}
|
|
9822
|
+
/**
|
|
9823
|
+
* Schema for validating bridge parameters with USDC as the token.
|
|
9458
9824
|
* This ensures all required fields are present and properly typed.
|
|
9459
9825
|
* A bridge must include:
|
|
9460
9826
|
* - A valid amount (non-empty numeric string \> 0)
|
|
@@ -9462,11 +9828,15 @@ var TransferSpeed;
|
|
|
9462
9828
|
* - USDC as the token
|
|
9463
9829
|
* - Optional config with transfer speed and max fee settings
|
|
9464
9830
|
*
|
|
9831
|
+
* Providers that accept a non-USDC token type should call
|
|
9832
|
+
* {@link createBridgeParamsSchema} with their own token schema rather
|
|
9833
|
+
* than reusing this constant.
|
|
9834
|
+
*
|
|
9465
9835
|
* @throws KitError if validation fails
|
|
9466
9836
|
*
|
|
9467
9837
|
* @example
|
|
9468
9838
|
* ```typescript
|
|
9469
|
-
* import {
|
|
9839
|
+
* import { usdcBridgeParamsSchema } from '@core/provider'
|
|
9470
9840
|
*
|
|
9471
9841
|
* const validBridge = {
|
|
9472
9842
|
* amount: '100.50',
|
|
@@ -9491,280 +9861,383 @@ var TransferSpeed;
|
|
|
9491
9861
|
* }
|
|
9492
9862
|
* }
|
|
9493
9863
|
*
|
|
9494
|
-
* const result =
|
|
9864
|
+
* const result = usdcBridgeParamsSchema.safeParse(validBridge)
|
|
9495
9865
|
* console.log(result.success) // true
|
|
9496
9866
|
* ```
|
|
9497
|
-
*/ zod.z.
|
|
9498
|
-
|
|
9499
|
-
allowZero: false,
|
|
9500
|
-
regexMessage: AMOUNT_FORMAT_ERROR_MESSAGE,
|
|
9501
|
-
attributeName: 'amount',
|
|
9502
|
-
maxDecimals: 6
|
|
9503
|
-
})(zod.z.string())),
|
|
9504
|
-
source: walletContextSchema,
|
|
9505
|
-
destination: bridgeDestinationSchema$1,
|
|
9506
|
-
token: zod.z.literal('USDC'),
|
|
9507
|
-
config: zod.z.object({
|
|
9508
|
-
transferSpeed: zod.z.nativeEnum(TransferSpeed).optional(),
|
|
9509
|
-
maxFee: zod.z.string().pipe(createDecimalStringValidator({
|
|
9510
|
-
allowZero: true,
|
|
9511
|
-
regexMessage: MAX_FEE_FORMAT_ERROR_MESSAGE,
|
|
9512
|
-
attributeName: 'maxFee',
|
|
9513
|
-
maxDecimals: 6
|
|
9514
|
-
})(zod.z.string())).optional(),
|
|
9515
|
-
customFee: customFeeSchema.optional()
|
|
9516
|
-
})
|
|
9867
|
+
*/ createBridgeParamsSchema(zod.z.literal('USDC'), {
|
|
9868
|
+
maxDecimals: 6
|
|
9517
9869
|
});
|
|
9518
9870
|
|
|
9871
|
+
// ----------------------------------------------------------------------------
|
|
9872
|
+
// IRIS API base URLs
|
|
9873
|
+
// ----------------------------------------------------------------------------
|
|
9874
|
+
// ----------------------------------------------------------------------------
|
|
9875
|
+
// Known token symbols (DX convenience)
|
|
9876
|
+
// ----------------------------------------------------------------------------
|
|
9877
|
+
//
|
|
9878
|
+
// These constants back symbol -> id resolution as a convenience: a caller may
|
|
9879
|
+
// pass a known symbol instead of a raw bytes32 id. They do NOT gate
|
|
9880
|
+
// routability.
|
|
9881
|
+
/**
|
|
9882
|
+
* Display symbols the provider recognizes as a convenience for callers.
|
|
9883
|
+
*
|
|
9884
|
+
* A consumer may pass one of these symbols instead of a raw bytes32 token
|
|
9885
|
+
* id; the provider resolves it to the symbol's canonical bytes32 id via
|
|
9886
|
+
* {@link KNOWN_TOKEN_IDS_BY_NETWORK} (a symbol can map to more than one
|
|
9887
|
+
* bridge, so the map pins the canonical one). This list does NOT gate
|
|
9888
|
+
* routability: any token the IRIS registry lists with deployments on both
|
|
9889
|
+
* endpoints routes when passed by its bytes32 id, whether listed here or
|
|
9890
|
+
* not.
|
|
9891
|
+
*
|
|
9892
|
+
* @example
|
|
9893
|
+
* ```typescript
|
|
9894
|
+
* for (const symbol of KNOWN_TOKEN_SYMBOLS) console.log(symbol)
|
|
9895
|
+
* ```
|
|
9896
|
+
*/ const KNOWN_TOKEN_SYMBOLS = [
|
|
9897
|
+
'cirBTC',
|
|
9898
|
+
'wETH',
|
|
9899
|
+
'EURC'
|
|
9900
|
+
];
|
|
9901
|
+
|
|
9902
|
+
// ============================================================================
|
|
9903
|
+
// Crypto Utilities (Internal)
|
|
9904
|
+
// ============================================================================
|
|
9905
|
+
/** @internal */ function hasGetRandomValues() {
|
|
9906
|
+
return typeof crypto !== 'undefined' && typeof crypto.getRandomValues === 'function';
|
|
9907
|
+
}
|
|
9908
|
+
/** @internal */ function hasRandomUUID() {
|
|
9909
|
+
return typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function';
|
|
9910
|
+
}
|
|
9519
9911
|
/**
|
|
9520
|
-
*
|
|
9521
|
-
* Validates that the address format matches the expected format for the chain type.
|
|
9912
|
+
* Create an RFC 4122 compliant UUIDv4.
|
|
9522
9913
|
*
|
|
9523
|
-
* @returns
|
|
9524
|
-
|
|
9525
|
-
|
|
9526
|
-
|
|
9527
|
-
|
|
9528
|
-
|
|
9529
|
-
|
|
9530
|
-
|
|
9531
|
-
|
|
9532
|
-
|
|
9533
|
-
|
|
9534
|
-
|
|
9535
|
-
|
|
9536
|
-
|
|
9537
|
-
|
|
9538
|
-
|
|
9914
|
+
* @returns UUID string (8-4-4-4-12 hex digits with hyphens).
|
|
9915
|
+
*
|
|
9916
|
+
* @remarks
|
|
9917
|
+
* Use when external systems require RFC 4122 UUID format.
|
|
9918
|
+
* For traceId, use {@link createTraceId} instead.
|
|
9919
|
+
*
|
|
9920
|
+
* @example
|
|
9921
|
+
* ```typescript
|
|
9922
|
+
* const uuid = createUuidV4() // "550e8400-e29b-41d4-a716-446655440000"
|
|
9923
|
+
* ```
|
|
9924
|
+
*/ function createUuidV4() {
|
|
9925
|
+
if (hasRandomUUID()) {
|
|
9926
|
+
return crypto.randomUUID();
|
|
9927
|
+
}
|
|
9928
|
+
const bytes = new Uint8Array(16);
|
|
9929
|
+
if (hasGetRandomValues()) {
|
|
9930
|
+
crypto.getRandomValues(bytes);
|
|
9931
|
+
} else {
|
|
9932
|
+
for(let i = 0; i < 16; i++){
|
|
9933
|
+
bytes[i] = Math.floor(Math.random() * 256) // NOSONAR:
|
|
9934
|
+
;
|
|
9539
9935
|
}
|
|
9540
|
-
}
|
|
9936
|
+
}
|
|
9937
|
+
// Set version (4) and variant (RFC 4122) bits
|
|
9938
|
+
const byte6 = bytes[6] ?? 0;
|
|
9939
|
+
const byte8 = bytes[8] ?? 0;
|
|
9940
|
+
bytes[6] = byte6 & 0x0f | 0x40 // Version 4
|
|
9941
|
+
;
|
|
9942
|
+
bytes[8] = byte8 & 0x3f | 0x80 // Variant 10
|
|
9943
|
+
;
|
|
9944
|
+
const hex = Array.from(bytes, (b)=>b.toString(16).padStart(2, '0')).join('');
|
|
9945
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
9541
9946
|
}
|
|
9947
|
+
|
|
9542
9948
|
/**
|
|
9543
|
-
*
|
|
9544
|
-
* Must always contain both adapter and chain explicitly.
|
|
9949
|
+
* Define a schema for runtime logger interfaces.
|
|
9545
9950
|
*
|
|
9546
|
-
*
|
|
9547
|
-
|
|
9548
|
-
|
|
9549
|
-
|
|
9550
|
-
|
|
9951
|
+
* @remarks
|
|
9952
|
+
* Validate that a runtime logger provides the minimal methods expected by the SDK.
|
|
9953
|
+
*
|
|
9954
|
+
* @example
|
|
9955
|
+
* ```typescript
|
|
9956
|
+
* import { loggerSchema } from '@core/runtime'
|
|
9957
|
+
*
|
|
9958
|
+
* const logger = {
|
|
9959
|
+
* debug: () => undefined,
|
|
9960
|
+
* info: () => undefined,
|
|
9961
|
+
* warn: () => undefined,
|
|
9962
|
+
* error: () => undefined,
|
|
9963
|
+
* child: () => logger,
|
|
9964
|
+
* }
|
|
9965
|
+
*
|
|
9966
|
+
* loggerSchema.parse(logger)
|
|
9967
|
+
* ```
|
|
9968
|
+
*/ const loggerSchema = zod.z.custom((value)=>{
|
|
9969
|
+
if (value === null || typeof value !== 'object') {
|
|
9970
|
+
return false;
|
|
9971
|
+
}
|
|
9972
|
+
const record = value;
|
|
9973
|
+
return typeof record['debug'] === 'function' && typeof record['info'] === 'function' && typeof record['warn'] === 'function' && typeof record['error'] === 'function' && typeof record['child'] === 'function';
|
|
9974
|
+
}, {
|
|
9975
|
+
message: 'Invalid logger'
|
|
9551
9976
|
});
|
|
9977
|
+
|
|
9552
9978
|
/**
|
|
9553
|
-
*
|
|
9554
|
-
* Contains an explicit recipientAddress along with adapter and chain.
|
|
9555
|
-
* The address format is validated based on the chain type (EVM or Solana).
|
|
9556
|
-
*/ const bridgeDestinationWithAddressSchema = adapterContextSchema$3.extend({
|
|
9557
|
-
recipientAddress: zod.z.string().min(1, 'Recipient address is required'),
|
|
9558
|
-
useForwarder: zod.z.boolean().optional()
|
|
9559
|
-
}).superRefine(createRecipientAddressValidator());
|
|
9560
|
-
/**
|
|
9561
|
-
* Schema for validating AdapterContext with optional useForwarder.
|
|
9562
|
-
* Extends adapterContextSchema with the useForwarder flag.
|
|
9563
|
-
*/ const adapterContextWithForwarderSchema = adapterContextSchema$3.extend({
|
|
9564
|
-
useForwarder: zod.z.boolean().optional()
|
|
9565
|
-
});
|
|
9566
|
-
/**
|
|
9567
|
-
* Schema for validating ForwarderDestination objects.
|
|
9568
|
-
* Used when useForwarder is true and no adapter is provided.
|
|
9569
|
-
* Requires chain, recipientAddress, and useForwarder: true.
|
|
9570
|
-
*
|
|
9571
|
-
* When using this destination type:
|
|
9572
|
-
* - The mint step completes when the IRIS API confirms forwardState === 'CONFIRMED'
|
|
9573
|
-
* - No on-chain transaction confirmation is performed (no adapter available)
|
|
9574
|
-
* - The mint step's data field will be undefined (no transaction receipt)
|
|
9575
|
-
*/ const forwarderDestinationSchema = zod.z.object({
|
|
9576
|
-
chain: bridgeChainIdentifierSchema,
|
|
9577
|
-
recipientAddress: zod.z.string().min(1, 'Recipient address is required'),
|
|
9578
|
-
useForwarder: zod.z.literal(true)
|
|
9579
|
-
}).strict().superRefine(createRecipientAddressValidator());
|
|
9580
|
-
/**
|
|
9581
|
-
* Schema for validating BridgeDestination union type.
|
|
9582
|
-
* Supports three destination configurations:
|
|
9583
|
-
* - BridgeDestinationWithAddress (adapter with explicit recipient)
|
|
9584
|
-
* - ForwarderDestination (no adapter, requires useForwarder: true and recipientAddress)
|
|
9585
|
-
* - AdapterContext with optional useForwarder (adapter for default recipient)
|
|
9586
|
-
*
|
|
9587
|
-
* When using ForwarderDestination (no adapter):
|
|
9588
|
-
* - The mint step completes when the IRIS API confirms forwardState === 'CONFIRMED'
|
|
9589
|
-
* - No on-chain transaction confirmation is performed
|
|
9590
|
-
*
|
|
9591
|
-
* The order matters: we check the more specific schemas first.
|
|
9592
|
-
* This ensures that objects with specific fields are matched correctly.
|
|
9593
|
-
*/ const bridgeDestinationSchema = zod.z.union([
|
|
9594
|
-
bridgeDestinationWithAddressSchema,
|
|
9595
|
-
forwarderDestinationSchema,
|
|
9596
|
-
adapterContextWithForwarderSchema.strict()
|
|
9597
|
-
]);
|
|
9598
|
-
/**
|
|
9599
|
-
* Schema for validating bridge parameters with chain identifiers.
|
|
9600
|
-
* This extends the core provider's schema but adapts it for the bridge kit's
|
|
9601
|
-
* more flexible interface that accepts chain identifiers.
|
|
9979
|
+
* Define a schema for runtime metrics interfaces.
|
|
9602
9980
|
*
|
|
9603
|
-
*
|
|
9604
|
-
*
|
|
9605
|
-
* - To bridge destination (AdapterContext or BridgeDestinationWithAddress)
|
|
9606
|
-
* - Amount is a non-empty numeric string \> 0
|
|
9607
|
-
* - Token is optional and defaults to 'USDC'
|
|
9608
|
-
* - Optional config parameters (transfer speed, max fee)
|
|
9981
|
+
* @remarks
|
|
9982
|
+
* Validate that a metrics implementation exposes the minimal API expected by the runtime.
|
|
9609
9983
|
*
|
|
9610
9984
|
* @example
|
|
9611
9985
|
* ```typescript
|
|
9612
|
-
* import {
|
|
9986
|
+
* import { metricsSchema } from '@core/runtime'
|
|
9613
9987
|
*
|
|
9614
|
-
* const
|
|
9615
|
-
*
|
|
9616
|
-
*
|
|
9617
|
-
*
|
|
9618
|
-
*
|
|
9619
|
-
* to: {
|
|
9620
|
-
* adapter: destAdapter,
|
|
9621
|
-
* chain: 'Base'
|
|
9622
|
-
* },
|
|
9623
|
-
* amount: '100.50',
|
|
9624
|
-
* token: 'USDC',
|
|
9625
|
-
* config: {
|
|
9626
|
-
* transferSpeed: 'FAST'
|
|
9627
|
-
* }
|
|
9988
|
+
* const metrics = {
|
|
9989
|
+
* counter: () => ({ inc: () => undefined }),
|
|
9990
|
+
* histogram: () => ({ observe: () => undefined }),
|
|
9991
|
+
* timer: () => ({ start: () => () => undefined }),
|
|
9992
|
+
* child: () => metrics,
|
|
9628
9993
|
* }
|
|
9629
9994
|
*
|
|
9630
|
-
*
|
|
9631
|
-
* if (result.success) {
|
|
9632
|
-
* console.log('Parameters are valid')
|
|
9633
|
-
* } else {
|
|
9634
|
-
* console.error('Validation failed:', result.error)
|
|
9635
|
-
* }
|
|
9995
|
+
* metricsSchema.parse(metrics)
|
|
9636
9996
|
* ```
|
|
9637
|
-
*/ zod.z.
|
|
9638
|
-
|
|
9639
|
-
|
|
9640
|
-
|
|
9641
|
-
|
|
9642
|
-
|
|
9643
|
-
|
|
9644
|
-
|
|
9645
|
-
})(zod.z.string())),
|
|
9646
|
-
token: zod.z.literal('USDC').optional(),
|
|
9647
|
-
config: zod.z.object({
|
|
9648
|
-
transferSpeed: zod.z.nativeEnum(TransferSpeed).optional(),
|
|
9649
|
-
feePayment: zod.z.enum([
|
|
9650
|
-
'source',
|
|
9651
|
-
'destination'
|
|
9652
|
-
]).optional(),
|
|
9653
|
-
maxFee: zod.z.string().min(1, 'Required').pipe(createDecimalStringValidator({
|
|
9654
|
-
allowZero: true,
|
|
9655
|
-
regexMessage: MAX_FEE_FORMAT_ERROR_MESSAGE,
|
|
9656
|
-
attributeName: 'maxFee',
|
|
9657
|
-
maxDecimals: 6
|
|
9658
|
-
})(zod.z.string())).optional(),
|
|
9659
|
-
customFee: customFeeSchema.optional()
|
|
9660
|
-
}).optional(),
|
|
9661
|
-
quote: zod.z.string().regex(/^0x([a-fA-F0-9]{2})+$/, 'must be non-empty 0x hex').optional()
|
|
9997
|
+
*/ const metricsSchema = zod.z.custom((value)=>{
|
|
9998
|
+
if (value === null || typeof value !== 'object') {
|
|
9999
|
+
return false;
|
|
10000
|
+
}
|
|
10001
|
+
const record = value;
|
|
10002
|
+
return typeof record['counter'] === 'function' && typeof record['histogram'] === 'function' && typeof record['timer'] === 'function' && typeof record['child'] === 'function';
|
|
10003
|
+
}, {
|
|
10004
|
+
message: 'Invalid metrics'
|
|
9662
10005
|
});
|
|
9663
10006
|
|
|
9664
|
-
// ============================================================================
|
|
9665
|
-
// Crypto Utilities (Internal)
|
|
9666
|
-
// ============================================================================
|
|
9667
|
-
/** @internal */ function hasGetRandomValues() {
|
|
9668
|
-
return typeof crypto !== 'undefined' && typeof crypto.getRandomValues === 'function';
|
|
9669
|
-
}
|
|
9670
|
-
/** @internal */ function hasRandomUUID() {
|
|
9671
|
-
return typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function';
|
|
9672
|
-
}
|
|
9673
10007
|
/**
|
|
9674
|
-
*
|
|
10008
|
+
* Omit undefined values from an object.
|
|
9675
10009
|
*
|
|
9676
|
-
* @
|
|
10010
|
+
* @param obj - The object to process.
|
|
10011
|
+
* @returns A new object with undefined values removed.
|
|
9677
10012
|
*
|
|
10013
|
+
* @internal
|
|
9678
10014
|
* @remarks
|
|
9679
|
-
*
|
|
9680
|
-
*
|
|
9681
|
-
*
|
|
9682
|
-
|
|
9683
|
-
|
|
9684
|
-
|
|
9685
|
-
|
|
9686
|
-
|
|
9687
|
-
if (hasRandomUUID()) {
|
|
9688
|
-
return crypto.randomUUID();
|
|
9689
|
-
}
|
|
9690
|
-
const bytes = new Uint8Array(16);
|
|
9691
|
-
if (hasGetRandomValues()) {
|
|
9692
|
-
crypto.getRandomValues(bytes);
|
|
9693
|
-
} else {
|
|
9694
|
-
for(let i = 0; i < 16; i++){
|
|
9695
|
-
bytes[i] = Math.floor(Math.random() * 256) // NOSONAR:
|
|
9696
|
-
;
|
|
10015
|
+
* Used by both production and mock loggers to ensure consistent behavior.
|
|
10016
|
+
* This prevents undefined values from being serialized in log output,
|
|
10017
|
+
* which can cause issues with some log transports.
|
|
10018
|
+
*/ function omitUndefined(obj) {
|
|
10019
|
+
const result = {};
|
|
10020
|
+
for (const [key, value] of Object.entries(obj)){
|
|
10021
|
+
if (value !== undefined) {
|
|
10022
|
+
result[key] = value;
|
|
9697
10023
|
}
|
|
9698
10024
|
}
|
|
9699
|
-
|
|
9700
|
-
const byte6 = bytes[6] ?? 0;
|
|
9701
|
-
const byte8 = bytes[8] ?? 0;
|
|
9702
|
-
bytes[6] = byte6 & 0x0f | 0x40 // Version 4
|
|
9703
|
-
;
|
|
9704
|
-
bytes[8] = byte8 & 0x3f | 0x80 // Variant 10
|
|
9705
|
-
;
|
|
9706
|
-
const hex = Array.from(bytes, (b)=>b.toString(16).padStart(2, '0')).join('');
|
|
9707
|
-
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
10025
|
+
return result;
|
|
9708
10026
|
}
|
|
9709
10027
|
|
|
9710
10028
|
/**
|
|
9711
|
-
*
|
|
10029
|
+
* Default redaction paths for web3/blockchain SDKs.
|
|
9712
10030
|
*
|
|
9713
10031
|
* @remarks
|
|
9714
|
-
*
|
|
10032
|
+
* These paths target common sensitive fields in blockchain applications.
|
|
10033
|
+
* All user fields are nested under `context`, so paths start with `context.`.
|
|
10034
|
+
* Wildcard `*` matches any key at that level.
|
|
10035
|
+
*/ const DEFAULT_REDACT_PATHS = [
|
|
10036
|
+
// Generic Credentials
|
|
10037
|
+
'context.password',
|
|
10038
|
+
'context.passphrase',
|
|
10039
|
+
'context.secret',
|
|
10040
|
+
'context.token',
|
|
10041
|
+
'context.*.password',
|
|
10042
|
+
'context.*.passphrase',
|
|
10043
|
+
'context.*.secret',
|
|
10044
|
+
'context.*.token',
|
|
10045
|
+
// API Keys & Auth Tokens
|
|
10046
|
+
'context.apiKey',
|
|
10047
|
+
'context.apiSecret',
|
|
10048
|
+
'context.accessToken',
|
|
10049
|
+
'context.refreshToken',
|
|
10050
|
+
'context.jwt',
|
|
10051
|
+
'context.bearerToken',
|
|
10052
|
+
'context.sessionId',
|
|
10053
|
+
'context.authorization',
|
|
10054
|
+
'context.cookie',
|
|
10055
|
+
'context.*.apiKey',
|
|
10056
|
+
'context.*.apiSecret',
|
|
10057
|
+
'context.*.accessToken',
|
|
10058
|
+
'context.*.refreshToken',
|
|
10059
|
+
'context.*.jwt',
|
|
10060
|
+
'context.*.bearerToken',
|
|
10061
|
+
'context.*.sessionId',
|
|
10062
|
+
'context.*.authorization',
|
|
10063
|
+
'context.*.cookie',
|
|
10064
|
+
// Web3 / Crypto Keys
|
|
10065
|
+
'context.privateKey',
|
|
10066
|
+
'context.secretKey',
|
|
10067
|
+
'context.signingKey',
|
|
10068
|
+
'context.encryptionKey',
|
|
10069
|
+
'context.*.privateKey',
|
|
10070
|
+
'context.*.secretKey',
|
|
10071
|
+
'context.*.signingKey',
|
|
10072
|
+
'context.*.encryptionKey',
|
|
10073
|
+
// Web3 / Crypto Mnemonics and Seeds
|
|
10074
|
+
'context.mnemonic',
|
|
10075
|
+
'context.seed',
|
|
10076
|
+
'context.seedPhrase',
|
|
10077
|
+
'context.*.mnemonic',
|
|
10078
|
+
'context.*.seed',
|
|
10079
|
+
'context.*.seedPhrase',
|
|
10080
|
+
// OTP / Verification Codes
|
|
10081
|
+
'context.otp',
|
|
10082
|
+
'context.verificationCode',
|
|
10083
|
+
'context.*.otp',
|
|
10084
|
+
'context.*.verificationCode',
|
|
10085
|
+
// Payment Information
|
|
10086
|
+
'context.cardNumber',
|
|
10087
|
+
'context.cvv',
|
|
10088
|
+
'context.accountNumber',
|
|
10089
|
+
'context.*.cardNumber',
|
|
10090
|
+
'context.*.cvv',
|
|
10091
|
+
'context.*.accountNumber'
|
|
10092
|
+
];
|
|
10093
|
+
/**
|
|
10094
|
+
* Wrap user fields under `context` to prevent collision with pino internals.
|
|
9715
10095
|
*
|
|
9716
|
-
* @
|
|
9717
|
-
*
|
|
9718
|
-
* import { loggerSchema } from '@core/runtime'
|
|
10096
|
+
* @param fields - User-provided log fields.
|
|
10097
|
+
* @returns Object with fields nested under `context`, or undefined if empty.
|
|
9719
10098
|
*
|
|
9720
|
-
*
|
|
9721
|
-
*
|
|
9722
|
-
*
|
|
9723
|
-
*
|
|
9724
|
-
|
|
9725
|
-
|
|
9726
|
-
|
|
10099
|
+
* @remarks
|
|
10100
|
+
* This function handles edge cases by returning undefined for null, undefined,
|
|
10101
|
+
* or empty objects to avoid unnecessary wrapping in log output.
|
|
10102
|
+
* Undefined values are cleaned before wrapping.
|
|
10103
|
+
*/ function wrapInContext(fields) {
|
|
10104
|
+
if (!fields) return undefined;
|
|
10105
|
+
// Clean undefined values for consistency and transport compatibility
|
|
10106
|
+
const cleaned = omitUndefined(fields);
|
|
10107
|
+
// Handle edge case: all values were undefined, resulting in empty object
|
|
10108
|
+
const keys = Object.keys(cleaned);
|
|
10109
|
+
if (keys.length === 0) return undefined;
|
|
10110
|
+
return {
|
|
10111
|
+
context: cleaned
|
|
10112
|
+
};
|
|
10113
|
+
}
|
|
10114
|
+
/**
|
|
10115
|
+
* Wrap a pino instance to conform to our Logger interface.
|
|
9727
10116
|
*
|
|
9728
|
-
*
|
|
9729
|
-
*
|
|
9730
|
-
*/
|
|
9731
|
-
|
|
9732
|
-
|
|
10117
|
+
* @param pinoInstance - The pino logger instance to wrap.
|
|
10118
|
+
* @returns A Logger instance conforming to our stable interface.
|
|
10119
|
+
*/ function wrapPino(pinoInstance) {
|
|
10120
|
+
return {
|
|
10121
|
+
debug (message, fields) {
|
|
10122
|
+
const wrapped = wrapInContext(fields);
|
|
10123
|
+
if (wrapped) {
|
|
10124
|
+
pinoInstance.debug(wrapped, message);
|
|
10125
|
+
} else {
|
|
10126
|
+
pinoInstance.debug(message);
|
|
10127
|
+
}
|
|
10128
|
+
},
|
|
10129
|
+
info (message, fields) {
|
|
10130
|
+
const wrapped = wrapInContext(fields);
|
|
10131
|
+
if (wrapped) {
|
|
10132
|
+
pinoInstance.info(wrapped, message);
|
|
10133
|
+
} else {
|
|
10134
|
+
pinoInstance.info(message);
|
|
10135
|
+
}
|
|
10136
|
+
},
|
|
10137
|
+
warn (message, fields) {
|
|
10138
|
+
const wrapped = wrapInContext(fields);
|
|
10139
|
+
if (wrapped) {
|
|
10140
|
+
pinoInstance.warn(wrapped, message);
|
|
10141
|
+
} else {
|
|
10142
|
+
pinoInstance.warn(message);
|
|
10143
|
+
}
|
|
10144
|
+
},
|
|
10145
|
+
error (message, fields) {
|
|
10146
|
+
const wrapped = wrapInContext(fields);
|
|
10147
|
+
if (wrapped) {
|
|
10148
|
+
pinoInstance.error(wrapped, message);
|
|
10149
|
+
} else {
|
|
10150
|
+
pinoInstance.error(message);
|
|
10151
|
+
}
|
|
10152
|
+
},
|
|
10153
|
+
child (tags) {
|
|
10154
|
+
// Child bindings stay flat (not wrapped) - they're part of logger's base context
|
|
10155
|
+
const cleaned = omitUndefined(tags);
|
|
10156
|
+
return wrapPino(pinoInstance.child(cleaned));
|
|
10157
|
+
}
|
|
10158
|
+
};
|
|
10159
|
+
}
|
|
10160
|
+
/**
|
|
10161
|
+
* Build pino redact configuration from our simplified options.
|
|
10162
|
+
*
|
|
10163
|
+
* @param redact - The redact configuration option.
|
|
10164
|
+
* @returns Pino-compatible redact configuration or undefined.
|
|
10165
|
+
*/ function buildRedactConfig(redact) {
|
|
10166
|
+
// Explicitly disabled
|
|
10167
|
+
if (redact === false) {
|
|
10168
|
+
return undefined;
|
|
9733
10169
|
}
|
|
9734
|
-
|
|
9735
|
-
|
|
9736
|
-
|
|
9737
|
-
|
|
9738
|
-
|
|
9739
|
-
|
|
10170
|
+
// Custom paths provided
|
|
10171
|
+
if (Array.isArray(redact)) {
|
|
10172
|
+
return redact.length > 0 ? {
|
|
10173
|
+
paths: redact,
|
|
10174
|
+
censor: '[REDACTED]'
|
|
10175
|
+
} : undefined;
|
|
10176
|
+
}
|
|
10177
|
+
// Default: use web3 sensible defaults
|
|
10178
|
+
return {
|
|
10179
|
+
paths: [
|
|
10180
|
+
...DEFAULT_REDACT_PATHS
|
|
10181
|
+
],
|
|
10182
|
+
censor: '[REDACTED]'
|
|
10183
|
+
};
|
|
10184
|
+
}
|
|
9740
10185
|
/**
|
|
9741
|
-
*
|
|
10186
|
+
* Create a logger backed by pino.
|
|
10187
|
+
*
|
|
10188
|
+
* @param options - Logger options (optional).
|
|
10189
|
+
* @param stream - Destination stream (optional).
|
|
10190
|
+
* @returns A Logger instance.
|
|
10191
|
+
* @throws Error if invalid pino options are provided.
|
|
9742
10192
|
*
|
|
9743
10193
|
* @remarks
|
|
9744
|
-
*
|
|
10194
|
+
* This is a thin wrapper around pino that exposes our stable Logger interface.
|
|
10195
|
+
* Pino handles all transport concerns: JSON, pretty printing, file, remote, browser, etc.
|
|
10196
|
+
*
|
|
10197
|
+
* **Security**: By default, sensitive web3 fields (privateKey, mnemonic, apiKey, etc.)
|
|
10198
|
+
* are automatically redacted from log output. Use `redact: false` to disable.
|
|
9745
10199
|
*
|
|
9746
10200
|
* @example
|
|
9747
10201
|
* ```typescript
|
|
9748
|
-
* import {
|
|
10202
|
+
* import { createLogger } from '@core/runtime'
|
|
9749
10203
|
*
|
|
9750
|
-
*
|
|
9751
|
-
*
|
|
9752
|
-
*
|
|
9753
|
-
*
|
|
9754
|
-
* child: () => metrics,
|
|
9755
|
-
* }
|
|
10204
|
+
* // Default: web3 sensitive fields are redacted
|
|
10205
|
+
* const logger = createLogger({ level: 'info' })
|
|
10206
|
+
* logger.info('Signing', { privateKey: '0x123...' })
|
|
10207
|
+
* // Output: { context: { privateKey: '[REDACTED]' }, msg: 'Signing' }
|
|
9756
10208
|
*
|
|
9757
|
-
*
|
|
10209
|
+
* // Disable redaction (use with caution)
|
|
10210
|
+
* const unsafeLogger = createLogger({ level: 'debug', redact: false })
|
|
10211
|
+
*
|
|
10212
|
+
* // Custom redaction paths
|
|
10213
|
+
* const customLogger = createLogger({
|
|
10214
|
+
* level: 'info',
|
|
10215
|
+
* redact: ['context.mySecret', 'context.*.credentials']
|
|
10216
|
+
* })
|
|
10217
|
+
*
|
|
10218
|
+
* // Pretty output for development
|
|
10219
|
+
* const devLogger = createLogger({
|
|
10220
|
+
* level: 'debug',
|
|
10221
|
+
* transport: { target: 'pino-pretty' }
|
|
10222
|
+
* })
|
|
10223
|
+
*
|
|
10224
|
+
* // Browser logger
|
|
10225
|
+
* const browserLogger = createLogger({
|
|
10226
|
+
* browser: { asObject: true }
|
|
10227
|
+
* })
|
|
9758
10228
|
* ```
|
|
9759
|
-
*/
|
|
9760
|
-
|
|
9761
|
-
|
|
9762
|
-
|
|
9763
|
-
|
|
9764
|
-
|
|
9765
|
-
|
|
9766
|
-
|
|
9767
|
-
}
|
|
10229
|
+
*/ function createLogger(options, stream) {
|
|
10230
|
+
const { redact, ...pinoOptions } = options ?? {};
|
|
10231
|
+
// Build redaction config
|
|
10232
|
+
const redactConfig = buildRedactConfig(redact);
|
|
10233
|
+
// Build final pino options, only include redact if defined
|
|
10234
|
+
const finalOptions = redactConfig ? {
|
|
10235
|
+
...pinoOptions,
|
|
10236
|
+
redact: redactConfig
|
|
10237
|
+
} : pinoOptions;
|
|
10238
|
+
const pinoInstance = pino__default(finalOptions);
|
|
10239
|
+
return wrapPino(pinoInstance);
|
|
10240
|
+
}
|
|
9768
10241
|
|
|
9769
10242
|
// ============================================================================
|
|
9770
10243
|
// Validation Schema
|
|
@@ -9845,6 +10318,186 @@ var TransferSpeed;
|
|
|
9845
10318
|
clock: zod.z.any().optional()
|
|
9846
10319
|
}).passthrough();
|
|
9847
10320
|
|
|
10321
|
+
/**
|
|
10322
|
+
* Creates a Zod superRefine validator for recipient address format validation.
|
|
10323
|
+
* Validates that the address format matches the expected format for the chain type.
|
|
10324
|
+
*
|
|
10325
|
+
* @returns A superRefine function that validates recipientAddress against chain type
|
|
10326
|
+
*/ function createRecipientAddressValidator() {
|
|
10327
|
+
return (data, ctx)=>{
|
|
10328
|
+
const chain = data.chain;
|
|
10329
|
+
if (chain === null) {
|
|
10330
|
+
return;
|
|
10331
|
+
}
|
|
10332
|
+
if (!isValidAddressForChain(data.recipientAddress, chain)) {
|
|
10333
|
+
const chainInfo = extractChainInfo(chain);
|
|
10334
|
+
ctx.addIssue({
|
|
10335
|
+
code: zod.z.ZodIssueCode.custom,
|
|
10336
|
+
path: [
|
|
10337
|
+
'recipientAddress'
|
|
10338
|
+
],
|
|
10339
|
+
message: `Invalid address format for ${String(chainInfo.name)}. Expected ${chainInfo.expectedAddressFormat}, but received: ${data.recipientAddress}`
|
|
10340
|
+
});
|
|
10341
|
+
}
|
|
10342
|
+
};
|
|
10343
|
+
}
|
|
10344
|
+
/**
|
|
10345
|
+
* Schema for `BridgeParams.token`.
|
|
10346
|
+
*
|
|
10347
|
+
* Accept `'USDC'`, a symbol from {@link KNOWN_TOKEN_SYMBOLS}, or a bytes32 id
|
|
10348
|
+
* (`0x` plus exactly 64 hex characters). Reject unknown symbols, malformed ids,
|
|
10349
|
+
* and `{ provider, id }` objects. A custom extra provider cannot introduce a
|
|
10350
|
+
* new symbol through this field — only a bytes32 id.
|
|
10351
|
+
*
|
|
10352
|
+
* Omit the field to default to `'USDC'`.
|
|
10353
|
+
*/ const bridgeTokenSchema = zod.z.union([
|
|
10354
|
+
zod.z.enum([
|
|
10355
|
+
'USDC',
|
|
10356
|
+
...KNOWN_TOKEN_SYMBOLS
|
|
10357
|
+
]),
|
|
10358
|
+
zod.z.string().regex(/^0x[0-9a-fA-F]{64}$/, 'Token id must be a bytes32 (0x-prefixed, 64 hex chars)')
|
|
10359
|
+
]);
|
|
10360
|
+
/**
|
|
10361
|
+
* Schema for validating AdapterContext for bridge operations.
|
|
10362
|
+
* Must always contain both adapter and chain explicitly.
|
|
10363
|
+
*
|
|
10364
|
+
* Optionally includes address for developer-controlled adapters.
|
|
10365
|
+
*/ const adapterContextSchema$3 = zod.z.object({
|
|
10366
|
+
adapter: adapterSchema,
|
|
10367
|
+
chain: bridgeChainIdentifierSchema,
|
|
10368
|
+
address: zod.z.string().optional()
|
|
10369
|
+
});
|
|
10370
|
+
/**
|
|
10371
|
+
* Schema for validating BridgeDestinationWithAddress objects.
|
|
10372
|
+
* Contains an explicit recipientAddress along with adapter and chain.
|
|
10373
|
+
* The address format is validated based on the chain type (EVM or Solana).
|
|
10374
|
+
*/ const bridgeDestinationWithAddressSchema = adapterContextSchema$3.extend({
|
|
10375
|
+
recipientAddress: zod.z.string().min(1, 'Recipient address is required'),
|
|
10376
|
+
useForwarder: zod.z.boolean().optional()
|
|
10377
|
+
}).superRefine(createRecipientAddressValidator());
|
|
10378
|
+
/**
|
|
10379
|
+
* Schema for validating AdapterContext with optional useForwarder.
|
|
10380
|
+
* Extends adapterContextSchema with the useForwarder flag.
|
|
10381
|
+
*/ const adapterContextWithForwarderSchema = adapterContextSchema$3.extend({
|
|
10382
|
+
useForwarder: zod.z.boolean().optional()
|
|
10383
|
+
});
|
|
10384
|
+
/**
|
|
10385
|
+
* Schema for validating ForwarderDestination objects.
|
|
10386
|
+
* Used when useForwarder is true and no adapter is provided.
|
|
10387
|
+
* Requires chain, recipientAddress, and useForwarder: true.
|
|
10388
|
+
*
|
|
10389
|
+
* When using this destination type:
|
|
10390
|
+
* - The mint step completes when the IRIS API confirms forwardState === 'CONFIRMED'
|
|
10391
|
+
* - No on-chain transaction confirmation is performed (no adapter available)
|
|
10392
|
+
* - The mint step's data field will be undefined (no transaction receipt)
|
|
10393
|
+
*/ const forwarderDestinationSchema = zod.z.object({
|
|
10394
|
+
chain: bridgeChainIdentifierSchema,
|
|
10395
|
+
recipientAddress: zod.z.string().min(1, 'Recipient address is required'),
|
|
10396
|
+
useForwarder: zod.z.literal(true)
|
|
10397
|
+
}).strict().superRefine(createRecipientAddressValidator());
|
|
10398
|
+
/**
|
|
10399
|
+
* Schema for validating BridgeDestination union type.
|
|
10400
|
+
* Supports three destination configurations:
|
|
10401
|
+
* - BridgeDestinationWithAddress (adapter with explicit recipient)
|
|
10402
|
+
* - ForwarderDestination (no adapter, requires useForwarder: true and recipientAddress)
|
|
10403
|
+
* - AdapterContext with optional useForwarder (adapter for default recipient)
|
|
10404
|
+
*
|
|
10405
|
+
* When using ForwarderDestination (no adapter):
|
|
10406
|
+
* - The mint step completes when the IRIS API confirms forwardState === 'CONFIRMED'
|
|
10407
|
+
* - No on-chain transaction confirmation is performed
|
|
10408
|
+
*
|
|
10409
|
+
* The order matters: we check the more specific schemas first.
|
|
10410
|
+
* This ensures that objects with specific fields are matched correctly.
|
|
10411
|
+
*/ const bridgeDestinationSchema = zod.z.union([
|
|
10412
|
+
bridgeDestinationWithAddressSchema,
|
|
10413
|
+
forwarderDestinationSchema,
|
|
10414
|
+
adapterContextWithForwarderSchema.strict()
|
|
10415
|
+
]);
|
|
10416
|
+
/**
|
|
10417
|
+
* Schema for validating bridge parameters with chain identifiers.
|
|
10418
|
+
* This extends the core provider's schema but adapts it for the bridge kit's
|
|
10419
|
+
* more flexible interface that accepts chain identifiers.
|
|
10420
|
+
*
|
|
10421
|
+
* The schema validates:
|
|
10422
|
+
* - From adapter context (must always include both adapter and chain)
|
|
10423
|
+
* - To bridge destination (AdapterContext or BridgeDestinationWithAddress)
|
|
10424
|
+
* - Amount is a non-empty numeric string \> 0
|
|
10425
|
+
* - Token is optional and defaults to 'USDC'
|
|
10426
|
+
* - Optional config parameters (transfer speed, max fee)
|
|
10427
|
+
*
|
|
10428
|
+
* @example
|
|
10429
|
+
* ```typescript
|
|
10430
|
+
* import { bridgeParamsWithChainIdentifierSchema } from '@circle-fin/bridge-kit'
|
|
10431
|
+
*
|
|
10432
|
+
* const params = {
|
|
10433
|
+
* from: {
|
|
10434
|
+
* adapter: sourceAdapter,
|
|
10435
|
+
* chain: 'Ethereum'
|
|
10436
|
+
* },
|
|
10437
|
+
* to: {
|
|
10438
|
+
* adapter: destAdapter,
|
|
10439
|
+
* chain: 'Base'
|
|
10440
|
+
* },
|
|
10441
|
+
* amount: '100.50',
|
|
10442
|
+
* token: 'USDC',
|
|
10443
|
+
* config: {
|
|
10444
|
+
* transferSpeed: 'FAST'
|
|
10445
|
+
* }
|
|
10446
|
+
* }
|
|
10447
|
+
*
|
|
10448
|
+
* const result = bridgeParamsWithChainIdentifierSchema.safeParse(params)
|
|
10449
|
+
* if (result.success) {
|
|
10450
|
+
* console.log('Parameters are valid')
|
|
10451
|
+
* } else {
|
|
10452
|
+
* console.error('Validation failed:', result.error)
|
|
10453
|
+
* }
|
|
10454
|
+
* ```
|
|
10455
|
+
*/ zod.z.object({
|
|
10456
|
+
from: adapterContextSchema$3.strict(),
|
|
10457
|
+
to: bridgeDestinationSchema,
|
|
10458
|
+
amount: zod.z.string().min(1, 'Required').pipe(createDecimalStringValidator({
|
|
10459
|
+
allowZero: false,
|
|
10460
|
+
regexMessage: AMOUNT_FORMAT_ERROR_MESSAGE,
|
|
10461
|
+
attributeName: 'amount',
|
|
10462
|
+
// Widest precision any routable token needs (wETH = 18). This gate is
|
|
10463
|
+
// token-agnostic and runs before the route provider is known, so it
|
|
10464
|
+
// can only cap coarsely; the token's exact precision is enforced later
|
|
10465
|
+
// at the scaling boundary (`BridgeKit.scaleResolvedAmount`). USDC (6)
|
|
10466
|
+
// and every narrower token stay valid.
|
|
10467
|
+
maxDecimals: 18
|
|
10468
|
+
})(zod.z.string())),
|
|
10469
|
+
token: bridgeTokenSchema.optional(),
|
|
10470
|
+
config: zod.z.object({
|
|
10471
|
+
transferSpeed: zod.z.nativeEnum(TransferSpeed).optional(),
|
|
10472
|
+
feePayment: zod.z.enum([
|
|
10473
|
+
'source',
|
|
10474
|
+
'destination'
|
|
10475
|
+
]).optional(),
|
|
10476
|
+
maxFee: zod.z.string().min(1, 'Required').pipe(createDecimalStringValidator({
|
|
10477
|
+
allowZero: true,
|
|
10478
|
+
regexMessage: MAX_FEE_FORMAT_ERROR_MESSAGE,
|
|
10479
|
+
attributeName: 'maxFee',
|
|
10480
|
+
// See `amount` above: widest routable precision (18); the exact
|
|
10481
|
+
// per-token precision is enforced at the scaling boundary.
|
|
10482
|
+
maxDecimals: 18
|
|
10483
|
+
})(zod.z.string())).optional(),
|
|
10484
|
+
customFee: customFeeSchema.optional()
|
|
10485
|
+
}).optional(),
|
|
10486
|
+
// Top-level (not nested under `config`) to mirror `BridgeParams.quote`.
|
|
10487
|
+
//
|
|
10488
|
+
// `z.unknown()` rather than a shape: the quote belongs to whichever provider
|
|
10489
|
+
// issued it, and a route is matched to a provider only after these
|
|
10490
|
+
// parameters are validated, so there is no one shape to check here.
|
|
10491
|
+
//
|
|
10492
|
+
// It also keeps the value intact. This object strips unknown keys, so a
|
|
10493
|
+
// nested `z.object()` would clone the quote and drop every key not listed —
|
|
10494
|
+
// losing a field the issuing provider added, between `estimate` and
|
|
10495
|
+
// `bridge`. Shape is checked where the quote is consumed instead: CCTPx
|
|
10496
|
+
// against its own envelope schema, and the receive-exact path in
|
|
10497
|
+
// `sourceFees.ts` before it calls the Fee Service.
|
|
10498
|
+
quote: zod.z.unknown().optional()
|
|
10499
|
+
});
|
|
10500
|
+
|
|
9848
10501
|
/**
|
|
9849
10502
|
* The ASCII "cctp-forward" magic, hex-encoded (no `0x`), that a forward-friendly
|
|
9850
10503
|
* hookData must start with.
|
|
@@ -9873,6 +10526,9 @@ var TransferSpeed;
|
|
|
9873
10526
|
[TransferSpeed.SLOW]: 2000
|
|
9874
10527
|
});
|
|
9875
10528
|
|
|
10529
|
+
createLogger({
|
|
10530
|
+
name: 'provider-cctp-v2'
|
|
10531
|
+
});
|
|
9876
10532
|
/**
|
|
9877
10533
|
* All chains that are supported by the CCTP v2 provider.
|
|
9878
10534
|
*
|
|
@@ -9882,7 +10538,11 @@ var TransferSpeed;
|
|
|
9882
10538
|
* @internal
|
|
9883
10539
|
*/ Object.values(Chains).filter((chain)=>isCCTPV2Supported(chain));
|
|
9884
10540
|
|
|
9885
|
-
/**
|
|
10541
|
+
/**
|
|
10542
|
+
* Decimal string in token minor units, constrained to be strictly positive.
|
|
10543
|
+
*
|
|
10544
|
+
* @internal
|
|
10545
|
+
*/ const positiveAmountSchema = zod.z.string().regex(/^\d+$/, 'must be a non-negative integer string')// Re-check the digit shape here: zod still runs this refinement when the
|
|
9886
10546
|
// regex check above fails ("dirty"), so guard BigInt() against throwing on a
|
|
9887
10547
|
// non-numeric value before comparing.
|
|
9888
10548
|
.refine((value)=>/^\d+$/.test(value) && BigInt(value) > 0n, 'must be greater than zero');
|
|
@@ -9917,11 +10577,19 @@ const forwardRequestSchema = zod.z.object({
|
|
|
9917
10577
|
const preFinalityRequestSchema = zod.z.object({
|
|
9918
10578
|
type: zod.z.literal('PRE_FINALITY')
|
|
9919
10579
|
}).strict();
|
|
9920
|
-
/**
|
|
10580
|
+
/**
|
|
10581
|
+
* A single quote request item (`FORWARD` or `PRE_FINALITY`).
|
|
10582
|
+
*
|
|
10583
|
+
* @internal
|
|
10584
|
+
*/ const feeQuoteRequestSchema = zod.z.discriminatedUnion('type', [
|
|
9921
10585
|
forwardRequestSchema,
|
|
9922
10586
|
preFinalityRequestSchema
|
|
9923
10587
|
]);
|
|
9924
|
-
/**
|
|
10588
|
+
/**
|
|
10589
|
+
* A non-empty list of quote request items with unique types.
|
|
10590
|
+
*
|
|
10591
|
+
* @internal
|
|
10592
|
+
*/ const feeQuoteRequestsSchema = zod.z.array(feeQuoteRequestSchema).min(1, 'at least one request item is required').refine((items)=>new Set(items.map((item)=>item.type)).size === items.length, 'request item types must be unique');
|
|
9925
10593
|
/**
|
|
9926
10594
|
* A structured `Partial<ApiPollingConfig>` polling override.
|
|
9927
10595
|
*
|
|
@@ -9949,6 +10617,8 @@ const preFinalityRequestSchema = zod.z.object({
|
|
|
9949
10617
|
* it `undefined`, which is falsy and silently selects the production base URL.
|
|
9950
10618
|
* (`buildFeeQuoteUrl` independently re-validates the domains for standalone
|
|
9951
10619
|
* callers.)
|
|
10620
|
+
*
|
|
10621
|
+
* @internal
|
|
9952
10622
|
*/ zod.z.object({
|
|
9953
10623
|
sourceDomain: zod.z.number().int().nonnegative(),
|
|
9954
10624
|
destinationDomain: zod.z.number().int().nonnegative(),
|
|
@@ -9984,7 +10654,11 @@ const metadataSchema = zod.z.object({
|
|
|
9984
10654
|
blockEstimatedAt: zod.z.number().int().nonnegative().optional()
|
|
9985
10655
|
}).passthrough()
|
|
9986
10656
|
]);
|
|
9987
|
-
/**
|
|
10657
|
+
/**
|
|
10658
|
+
* Schema for a signed fee quote returned by the Quote API.
|
|
10659
|
+
*
|
|
10660
|
+
* @internal
|
|
10661
|
+
*/ zod.z.object({
|
|
9988
10662
|
// The runtime YAML spec maps signedQuote to a looser `hex` (which allows
|
|
9989
10663
|
// an empty `0x`); we keep the stricter non-empty form. Do not relax
|
|
9990
10664
|
// without a reason.
|
|
@@ -9998,7 +10672,11 @@ const metadataSchema = zod.z.object({
|
|
|
9998
10672
|
items: zod.z.array(feeQuoteItemSchema),
|
|
9999
10673
|
metadata: metadataSchema.optional()
|
|
10000
10674
|
}).passthrough();
|
|
10001
|
-
/**
|
|
10675
|
+
/**
|
|
10676
|
+
* Validates input to {@link validateQuote}.
|
|
10677
|
+
*
|
|
10678
|
+
* @internal
|
|
10679
|
+
*/ zod.z.object({
|
|
10002
10680
|
sourceDomain: zod.z.number().int().nonnegative(),
|
|
10003
10681
|
abiSignature: zod.z.string().min(1),
|
|
10004
10682
|
args: zod.z.array(zod.z.union([
|
|
@@ -10033,11 +10711,13 @@ const validateQuoteItemSchema = zod.z.object({
|
|
|
10033
10711
|
computedArgsHash: bytes32Schema.optional()
|
|
10034
10712
|
}).passthrough();
|
|
10035
10713
|
/**
|
|
10036
|
-
* Schema for a
|
|
10714
|
+
* Schema for a validate-quote result returned by the Iris `/validate/usdc/:sourceDomain` endpoint.
|
|
10037
10715
|
*
|
|
10038
10716
|
* The endpoint takes the source domain as a URL path parameter and does not
|
|
10039
10717
|
* return it in the response body, so `sourceDomain` is intentionally not part
|
|
10040
10718
|
* of this schema.
|
|
10719
|
+
*
|
|
10720
|
+
* @internal
|
|
10041
10721
|
*/ zod.z.object({
|
|
10042
10722
|
signedQuote: nonEmptyHexSchema,
|
|
10043
10723
|
expiry: quoteExpiryStatusSchema,
|
|
@@ -10057,7 +10737,7 @@ const validateQuoteItemSchema = zod.z.object({
|
|
|
10057
10737
|
registerKit(`${pkg$3.name}/${pkg$3.version}`);
|
|
10058
10738
|
|
|
10059
10739
|
var name$2 = "@circle-fin/swap-kit";
|
|
10060
|
-
var version$2 = "1.
|
|
10740
|
+
var version$2 = "1.7.0";
|
|
10061
10741
|
var pkg$2 = {
|
|
10062
10742
|
name: name$2,
|
|
10063
10743
|
version: version$2};
|
|
@@ -12221,6 +12901,11 @@ createTokenRegistry();
|
|
|
12221
12901
|
name: 'USDC',
|
|
12222
12902
|
version: '2'
|
|
12223
12903
|
},
|
|
12904
|
+
Arc: {
|
|
12905
|
+
chainId: Arc.chainId,
|
|
12906
|
+
name: 'USDC',
|
|
12907
|
+
version: '2'
|
|
12908
|
+
},
|
|
12224
12909
|
Arc_Testnet: {
|
|
12225
12910
|
chainId: ArcTestnet.chainId,
|
|
12226
12911
|
name: 'USDC',
|
|
@@ -13756,7 +14441,7 @@ new Set(Object.values(Blockchain));
|
|
|
13756
14441
|
registerKit(`${pkg$2.name}/${pkg$2.version}`);
|
|
13757
14442
|
|
|
13758
14443
|
var name$1 = "@circle-fin/earn-kit";
|
|
13759
|
-
var version$1 = "1.
|
|
14444
|
+
var version$1 = "1.7.0";
|
|
13760
14445
|
var pkg$1 = {
|
|
13761
14446
|
name: name$1,
|
|
13762
14447
|
version: version$1};
|
|
@@ -13784,18 +14469,22 @@ const EARN_BRIDGE_ERC3009_TOKEN_SYMBOLS = [
|
|
|
13784
14469
|
*
|
|
13785
14470
|
* @internal
|
|
13786
14471
|
*/ const CHAIN_TO_API = {
|
|
14472
|
+
[Blockchain.Arc]: 'ARC',
|
|
13787
14473
|
[Blockchain.Arc_Testnet]: 'ARC-TESTNET'
|
|
13788
14474
|
};
|
|
13789
14475
|
/**
|
|
13790
14476
|
* Map SDK source chain identifiers to bridge source-chain strings.
|
|
13791
14477
|
*
|
|
13792
|
-
* Cross-chain Earn deposits
|
|
13793
|
-
*
|
|
14478
|
+
* Cross-chain Earn deposits support Ethereum, Arbitrum, and Base (mainnet
|
|
14479
|
+
* and testnet) as source chains.
|
|
13794
14480
|
*
|
|
13795
14481
|
* @internal
|
|
13796
14482
|
*/ const EARN_BRIDGE_SOURCE_CHAIN_TO_API = {
|
|
14483
|
+
[Blockchain.Arbitrum]: 'ARB',
|
|
13797
14484
|
[Blockchain.Arbitrum_Sepolia]: 'ARB-SEPOLIA',
|
|
14485
|
+
[Blockchain.Base]: 'BASE',
|
|
13798
14486
|
[Blockchain.Base_Sepolia]: 'BASE-SEPOLIA',
|
|
14487
|
+
[Blockchain.Ethereum]: 'ETH',
|
|
13799
14488
|
[Blockchain.Ethereum_Sepolia]: 'ETH-SEPOLIA'
|
|
13800
14489
|
};
|
|
13801
14490
|
/**
|
|
@@ -13806,17 +14495,30 @@ const EARN_BRIDGE_ERC3009_TOKEN_SYMBOLS = [
|
|
|
13806
14495
|
*
|
|
13807
14496
|
* @internal
|
|
13808
14497
|
*/ const EARN_BRIDGE_DESTINATION_CHAIN_TO_API = {
|
|
14498
|
+
[Blockchain.Arc]: CHAIN_TO_API[Blockchain.Arc],
|
|
13809
14499
|
[Blockchain.Arc_Testnet]: CHAIN_TO_API[Blockchain.Arc_Testnet]
|
|
13810
14500
|
};
|
|
13811
14501
|
const EARN_BRIDGE_USDC_ERC3009_DOMAINS = {
|
|
14502
|
+
[Blockchain.Arbitrum]: {
|
|
14503
|
+
name: 'USD Coin',
|
|
14504
|
+
version: '2'
|
|
14505
|
+
},
|
|
13812
14506
|
[Blockchain.Arbitrum_Sepolia]: {
|
|
13813
14507
|
name: 'USD Coin',
|
|
13814
14508
|
version: '2'
|
|
13815
14509
|
},
|
|
14510
|
+
[Blockchain.Base]: {
|
|
14511
|
+
name: 'USD Coin',
|
|
14512
|
+
version: '2'
|
|
14513
|
+
},
|
|
13816
14514
|
[Blockchain.Base_Sepolia]: {
|
|
13817
14515
|
name: 'USDC',
|
|
13818
14516
|
version: '2'
|
|
13819
14517
|
},
|
|
14518
|
+
[Blockchain.Ethereum]: {
|
|
14519
|
+
name: 'USD Coin',
|
|
14520
|
+
version: '2'
|
|
14521
|
+
},
|
|
13820
14522
|
[Blockchain.Ethereum_Sepolia]: {
|
|
13821
14523
|
name: 'USDC',
|
|
13822
14524
|
version: '2'
|
|
@@ -16660,7 +17362,7 @@ const bridgeDepositPrepareReviewSchema = zod.z.object({
|
|
|
16660
17362
|
}
|
|
16661
17363
|
|
|
16662
17364
|
var name = "@circle-fin/provider-earn-service";
|
|
16663
|
-
var version = "1.
|
|
17365
|
+
var version = "1.6.0";
|
|
16664
17366
|
var pkg = {
|
|
16665
17367
|
name: name,
|
|
16666
17368
|
version: version};
|