@circle-fin/adapter-ethers-v6 0.0.2-alpha.7 → 1.0.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.
Files changed (5) hide show
  1. package/README.md +39 -13
  2. package/index.cjs.js +457 -252
  3. package/index.d.ts +276 -97
  4. package/index.mjs +396 -194
  5. package/package.json +6 -4
package/index.cjs.js CHANGED
@@ -262,12 +262,13 @@ class ActionRegistry {
262
262
  * @category Enums
263
263
  * @description Provides string identifiers for each supported blockchain.
264
264
  */
265
- var Blockchain;
265
+ exports.Blockchain = void 0;
266
266
  (function (Blockchain) {
267
267
  Blockchain["Algorand"] = "Algorand";
268
268
  Blockchain["Algorand_Testnet"] = "Algorand_Testnet";
269
269
  Blockchain["Aptos"] = "Aptos";
270
270
  Blockchain["Aptos_Testnet"] = "Aptos_Testnet";
271
+ Blockchain["Arc_Testnet"] = "Arc_Testnet";
271
272
  Blockchain["Arbitrum"] = "Arbitrum";
272
273
  Blockchain["Arbitrum_Sepolia"] = "Arbitrum_Sepolia";
273
274
  Blockchain["Avalanche"] = "Avalanche";
@@ -318,7 +319,7 @@ var Blockchain;
318
319
  Blockchain["XDC_Apothem"] = "XDC_Apothem";
319
320
  Blockchain["ZKSync_Era"] = "ZKSync_Era";
320
321
  Blockchain["ZKSync_Sepolia"] = "ZKSync_Sepolia";
321
- })(Blockchain || (Blockchain = {}));
322
+ })(exports.Blockchain || (exports.Blockchain = {}));
322
323
 
323
324
  /**
324
325
  * Helper function to define a chain with proper TypeScript typing.
@@ -366,7 +367,7 @@ function defineChain(chain) {
366
367
  */
367
368
  const Algorand = defineChain({
368
369
  type: 'algorand',
369
- chain: Blockchain.Algorand,
370
+ chain: exports.Blockchain.Algorand,
370
371
  name: 'Algorand',
371
372
  title: 'Algorand Mainnet',
372
373
  nativeCurrency: {
@@ -389,7 +390,7 @@ const Algorand = defineChain({
389
390
  */
390
391
  const AlgorandTestnet = defineChain({
391
392
  type: 'algorand',
392
- chain: Blockchain.Algorand_Testnet,
393
+ chain: exports.Blockchain.Algorand_Testnet,
393
394
  name: 'Algorand Testnet',
394
395
  title: 'Algorand Test Network',
395
396
  nativeCurrency: {
@@ -412,7 +413,7 @@ const AlgorandTestnet = defineChain({
412
413
  */
413
414
  const Aptos = defineChain({
414
415
  type: 'aptos',
415
- chain: Blockchain.Aptos,
416
+ chain: exports.Blockchain.Aptos,
416
417
  name: 'Aptos',
417
418
  title: 'Aptos Mainnet',
418
419
  nativeCurrency: {
@@ -445,7 +446,7 @@ const Aptos = defineChain({
445
446
  */
446
447
  const AptosTestnet = defineChain({
447
448
  type: 'aptos',
448
- chain: Blockchain.Aptos_Testnet,
449
+ chain: exports.Blockchain.Aptos_Testnet,
449
450
  name: 'Aptos Testnet',
450
451
  title: 'Aptos Test Network',
451
452
  nativeCurrency: {
@@ -488,6 +489,48 @@ const BRIDGE_CONTRACT_EVM_TESTNET = '0xC5567a5E3370d4DBfB0540025078e283e36A363d'
488
489
  */
489
490
  const BRIDGE_CONTRACT_EVM_MAINNET = '0xB3FA262d0fB521cc93bE83d87b322b8A23DAf3F0';
490
491
 
492
+ /**
493
+ * Arc Testnet chain definition
494
+ * @remarks
495
+ * This represents the test network for the Arc blockchain,
496
+ * Circle's EVM-compatible Layer-1 designed for stablecoin finance
497
+ * and asset tokenization. Arc uses USDC as the native gas token and
498
+ * features the Malachite Byzantine Fault Tolerant (BFT) consensus
499
+ * engine for sub-second finality.
500
+ */
501
+ const ArcTestnet = defineChain({
502
+ type: 'evm',
503
+ chain: exports.Blockchain.Arc_Testnet,
504
+ name: 'Arc Testnet',
505
+ title: 'ArcTestnet',
506
+ nativeCurrency: {
507
+ name: 'Arc',
508
+ symbol: 'Arc',
509
+ decimals: 18,
510
+ },
511
+ chainId: 5042002,
512
+ isTestnet: true,
513
+ explorerUrl: 'https://testnet.arcscan.app/tx/{hash}',
514
+ rpcEndpoints: ['https://rpc.testnet.arc.network/'],
515
+ eurcAddress: '0x89B50855Aa3bE2F677cD6303Cec089B5F319D72a',
516
+ usdcAddress: '0x3600000000000000000000000000000000000000',
517
+ cctp: {
518
+ domain: 26,
519
+ contracts: {
520
+ v2: {
521
+ type: 'split',
522
+ tokenMessenger: '0x8FE6B999Dc680CcFDD5Bf7EB0974218be2542DAA',
523
+ messageTransmitter: '0xE737e5cEBEEBa77EFE34D4aa090756590b1CE275',
524
+ confirmations: 1,
525
+ fastConfirmations: 1,
526
+ },
527
+ },
528
+ },
529
+ kitContracts: {
530
+ bridge: BRIDGE_CONTRACT_EVM_TESTNET,
531
+ },
532
+ });
533
+
491
534
  /**
492
535
  * Arbitrum Mainnet chain definition
493
536
  * @remarks
@@ -495,7 +538,7 @@ const BRIDGE_CONTRACT_EVM_MAINNET = '0xB3FA262d0fB521cc93bE83d87b322b8A23DAf3F0'
495
538
  */
496
539
  const Arbitrum = defineChain({
497
540
  type: 'evm',
498
- chain: Blockchain.Arbitrum,
541
+ chain: exports.Blockchain.Arbitrum,
499
542
  name: 'Arbitrum',
500
543
  title: 'Arbitrum Mainnet',
501
544
  nativeCurrency: {
@@ -539,7 +582,7 @@ const Arbitrum = defineChain({
539
582
  */
540
583
  const ArbitrumSepolia = defineChain({
541
584
  type: 'evm',
542
- chain: Blockchain.Arbitrum_Sepolia,
585
+ chain: exports.Blockchain.Arbitrum_Sepolia,
543
586
  name: 'Arbitrum Sepolia',
544
587
  title: 'Arbitrum Sepolia Testnet',
545
588
  nativeCurrency: {
@@ -583,7 +626,7 @@ const ArbitrumSepolia = defineChain({
583
626
  */
584
627
  const Avalanche = defineChain({
585
628
  type: 'evm',
586
- chain: Blockchain.Avalanche,
629
+ chain: exports.Blockchain.Avalanche,
587
630
  name: 'Avalanche',
588
631
  title: 'Avalanche Mainnet',
589
632
  nativeCurrency: {
@@ -627,7 +670,7 @@ const Avalanche = defineChain({
627
670
  */
628
671
  const AvalancheFuji = defineChain({
629
672
  type: 'evm',
630
- chain: Blockchain.Avalanche_Fuji,
673
+ chain: exports.Blockchain.Avalanche_Fuji,
631
674
  name: 'Avalanche Fuji',
632
675
  title: 'Avalanche Fuji Testnet',
633
676
  nativeCurrency: {
@@ -671,7 +714,7 @@ const AvalancheFuji = defineChain({
671
714
  */
672
715
  const Base = defineChain({
673
716
  type: 'evm',
674
- chain: Blockchain.Base,
717
+ chain: exports.Blockchain.Base,
675
718
  name: 'Base',
676
719
  title: 'Base Mainnet',
677
720
  nativeCurrency: {
@@ -715,7 +758,7 @@ const Base = defineChain({
715
758
  */
716
759
  const BaseSepolia = defineChain({
717
760
  type: 'evm',
718
- chain: Blockchain.Base_Sepolia,
761
+ chain: exports.Blockchain.Base_Sepolia,
719
762
  name: 'Base Sepolia',
720
763
  title: 'Base Sepolia Testnet',
721
764
  nativeCurrency: {
@@ -759,7 +802,7 @@ const BaseSepolia = defineChain({
759
802
  */
760
803
  const Celo = defineChain({
761
804
  type: 'evm',
762
- chain: Blockchain.Celo,
805
+ chain: exports.Blockchain.Celo,
763
806
  name: 'Celo',
764
807
  title: 'Celo Mainnet',
765
808
  nativeCurrency: {
@@ -783,7 +826,7 @@ const Celo = defineChain({
783
826
  */
784
827
  const CeloAlfajoresTestnet = defineChain({
785
828
  type: 'evm',
786
- chain: Blockchain.Celo_Alfajores_Testnet,
829
+ chain: exports.Blockchain.Celo_Alfajores_Testnet,
787
830
  name: 'Celo Alfajores',
788
831
  title: 'Celo Alfajores Testnet',
789
832
  nativeCurrency: {
@@ -807,7 +850,7 @@ const CeloAlfajoresTestnet = defineChain({
807
850
  */
808
851
  const Codex = defineChain({
809
852
  type: 'evm',
810
- chain: Blockchain.Codex,
853
+ chain: exports.Blockchain.Codex,
811
854
  name: 'Codex Mainnet',
812
855
  title: 'Codex Mainnet',
813
856
  nativeCurrency: {
@@ -845,7 +888,7 @@ const Codex = defineChain({
845
888
  */
846
889
  const CodexTestnet = defineChain({
847
890
  type: 'evm',
848
- chain: Blockchain.Codex_Testnet,
891
+ chain: exports.Blockchain.Codex_Testnet,
849
892
  name: 'Codex Testnet',
850
893
  title: 'Codex Testnet',
851
894
  nativeCurrency: {
@@ -883,7 +926,7 @@ const CodexTestnet = defineChain({
883
926
  */
884
927
  const Ethereum = defineChain({
885
928
  type: 'evm',
886
- chain: Blockchain.Ethereum,
929
+ chain: exports.Blockchain.Ethereum,
887
930
  name: 'Ethereum',
888
931
  title: 'Ethereum Mainnet',
889
932
  nativeCurrency: {
@@ -927,7 +970,7 @@ const Ethereum = defineChain({
927
970
  */
928
971
  const EthereumSepolia = defineChain({
929
972
  type: 'evm',
930
- chain: Blockchain.Ethereum_Sepolia,
973
+ chain: exports.Blockchain.Ethereum_Sepolia,
931
974
  name: 'Ethereum Sepolia',
932
975
  title: 'Ethereum Sepolia Testnet',
933
976
  nativeCurrency: {
@@ -971,7 +1014,7 @@ const EthereumSepolia = defineChain({
971
1014
  */
972
1015
  const Hedera = defineChain({
973
1016
  type: 'hedera',
974
- chain: Blockchain.Hedera,
1017
+ chain: exports.Blockchain.Hedera,
975
1018
  name: 'Hedera',
976
1019
  title: 'Hedera Mainnet',
977
1020
  nativeCurrency: {
@@ -994,7 +1037,7 @@ const Hedera = defineChain({
994
1037
  */
995
1038
  const HederaTestnet = defineChain({
996
1039
  type: 'hedera',
997
- chain: Blockchain.Hedera_Testnet,
1040
+ chain: exports.Blockchain.Hedera_Testnet,
998
1041
  name: 'Hedera Testnet',
999
1042
  title: 'Hedera Test Network',
1000
1043
  nativeCurrency: {
@@ -1019,7 +1062,7 @@ const HederaTestnet = defineChain({
1019
1062
  */
1020
1063
  const HyperEVM = defineChain({
1021
1064
  type: 'evm',
1022
- chain: Blockchain.HyperEVM,
1065
+ chain: exports.Blockchain.HyperEVM,
1023
1066
  name: 'HyperEVM',
1024
1067
  title: 'HyperEVM Mainnet',
1025
1068
  nativeCurrency: {
@@ -1058,7 +1101,7 @@ const HyperEVM = defineChain({
1058
1101
  */
1059
1102
  const HyperEVMTestnet = defineChain({
1060
1103
  type: 'evm',
1061
- chain: Blockchain.HyperEVM_Testnet,
1104
+ chain: exports.Blockchain.HyperEVM_Testnet,
1062
1105
  name: 'HyperEVM Testnet',
1063
1106
  title: 'HyperEVM Test Network',
1064
1107
  nativeCurrency: {
@@ -1098,7 +1141,7 @@ const HyperEVMTestnet = defineChain({
1098
1141
  */
1099
1142
  const Ink = defineChain({
1100
1143
  type: 'evm',
1101
- chain: Blockchain.Ink,
1144
+ chain: exports.Blockchain.Ink,
1102
1145
  name: 'Ink',
1103
1146
  title: 'Ink Mainnet',
1104
1147
  nativeCurrency: {
@@ -1140,7 +1183,7 @@ const Ink = defineChain({
1140
1183
  */
1141
1184
  const InkTestnet = defineChain({
1142
1185
  type: 'evm',
1143
- chain: Blockchain.Ink_Testnet,
1186
+ chain: exports.Blockchain.Ink_Testnet,
1144
1187
  name: 'Ink Sepolia',
1145
1188
  title: 'Ink Sepolia Testnet',
1146
1189
  nativeCurrency: {
@@ -1181,7 +1224,7 @@ const InkTestnet = defineChain({
1181
1224
  */
1182
1225
  const Linea = defineChain({
1183
1226
  type: 'evm',
1184
- chain: Blockchain.Linea,
1227
+ chain: exports.Blockchain.Linea,
1185
1228
  name: 'Linea',
1186
1229
  title: 'Linea Mainnet',
1187
1230
  nativeCurrency: {
@@ -1219,7 +1262,7 @@ const Linea = defineChain({
1219
1262
  */
1220
1263
  const LineaSepolia = defineChain({
1221
1264
  type: 'evm',
1222
- chain: Blockchain.Linea_Sepolia,
1265
+ chain: exports.Blockchain.Linea_Sepolia,
1223
1266
  name: 'Linea Sepolia',
1224
1267
  title: 'Linea Sepolia Testnet',
1225
1268
  nativeCurrency: {
@@ -1257,7 +1300,7 @@ const LineaSepolia = defineChain({
1257
1300
  */
1258
1301
  const NEAR = defineChain({
1259
1302
  type: 'near',
1260
- chain: Blockchain.NEAR,
1303
+ chain: exports.Blockchain.NEAR,
1261
1304
  name: 'NEAR Protocol',
1262
1305
  title: 'NEAR Mainnet',
1263
1306
  nativeCurrency: {
@@ -1280,7 +1323,7 @@ const NEAR = defineChain({
1280
1323
  */
1281
1324
  const NEARTestnet = defineChain({
1282
1325
  type: 'near',
1283
- chain: Blockchain.NEAR_Testnet,
1326
+ chain: exports.Blockchain.NEAR_Testnet,
1284
1327
  name: 'NEAR Protocol Testnet',
1285
1328
  title: 'NEAR Test Network',
1286
1329
  nativeCurrency: {
@@ -1303,7 +1346,7 @@ const NEARTestnet = defineChain({
1303
1346
  */
1304
1347
  const Noble = defineChain({
1305
1348
  type: 'noble',
1306
- chain: Blockchain.Noble,
1349
+ chain: exports.Blockchain.Noble,
1307
1350
  name: 'Noble',
1308
1351
  title: 'Noble Mainnet',
1309
1352
  nativeCurrency: {
@@ -1335,7 +1378,7 @@ const Noble = defineChain({
1335
1378
  */
1336
1379
  const NobleTestnet = defineChain({
1337
1380
  type: 'noble',
1338
- chain: Blockchain.Noble_Testnet,
1381
+ chain: exports.Blockchain.Noble_Testnet,
1339
1382
  name: 'Noble Testnet',
1340
1383
  title: 'Noble Test Network',
1341
1384
  nativeCurrency: {
@@ -1367,7 +1410,7 @@ const NobleTestnet = defineChain({
1367
1410
  */
1368
1411
  const Optimism = defineChain({
1369
1412
  type: 'evm',
1370
- chain: Blockchain.Optimism,
1413
+ chain: exports.Blockchain.Optimism,
1371
1414
  name: 'Optimism',
1372
1415
  title: 'Optimism Mainnet',
1373
1416
  nativeCurrency: {
@@ -1411,7 +1454,7 @@ const Optimism = defineChain({
1411
1454
  */
1412
1455
  const OptimismSepolia = defineChain({
1413
1456
  type: 'evm',
1414
- chain: Blockchain.Optimism_Sepolia,
1457
+ chain: exports.Blockchain.Optimism_Sepolia,
1415
1458
  name: 'Optimism Sepolia',
1416
1459
  title: 'Optimism Sepolia Testnet',
1417
1460
  nativeCurrency: {
@@ -1457,7 +1500,7 @@ const OptimismSepolia = defineChain({
1457
1500
  */
1458
1501
  const Plume = defineChain({
1459
1502
  type: 'evm',
1460
- chain: Blockchain.Plume,
1503
+ chain: exports.Blockchain.Plume,
1461
1504
  name: 'Plume',
1462
1505
  title: 'Plume Mainnet',
1463
1506
  nativeCurrency: {
@@ -1496,7 +1539,7 @@ const Plume = defineChain({
1496
1539
  */
1497
1540
  const PlumeTestnet = defineChain({
1498
1541
  type: 'evm',
1499
- chain: Blockchain.Plume_Testnet,
1542
+ chain: exports.Blockchain.Plume_Testnet,
1500
1543
  name: 'Plume Testnet',
1501
1544
  title: 'Plume Test Network',
1502
1545
  nativeCurrency: {
@@ -1534,7 +1577,7 @@ const PlumeTestnet = defineChain({
1534
1577
  */
1535
1578
  const PolkadotAssetHub = defineChain({
1536
1579
  type: 'polkadot',
1537
- chain: Blockchain.Polkadot_Asset_Hub,
1580
+ chain: exports.Blockchain.Polkadot_Asset_Hub,
1538
1581
  name: 'Polkadot Asset Hub',
1539
1582
  title: 'Polkadot Asset Hub',
1540
1583
  nativeCurrency: {
@@ -1557,7 +1600,7 @@ const PolkadotAssetHub = defineChain({
1557
1600
  */
1558
1601
  const PolkadotWestmint = defineChain({
1559
1602
  type: 'polkadot',
1560
- chain: Blockchain.Polkadot_Westmint,
1603
+ chain: exports.Blockchain.Polkadot_Westmint,
1561
1604
  name: 'Polkadot Westmint',
1562
1605
  title: 'Polkadot Westmint',
1563
1606
  nativeCurrency: {
@@ -1580,7 +1623,7 @@ const PolkadotWestmint = defineChain({
1580
1623
  */
1581
1624
  const Polygon = defineChain({
1582
1625
  type: 'evm',
1583
- chain: Blockchain.Polygon,
1626
+ chain: exports.Blockchain.Polygon,
1584
1627
  name: 'Polygon',
1585
1628
  title: 'Polygon Mainnet',
1586
1629
  nativeCurrency: {
@@ -1624,7 +1667,7 @@ const Polygon = defineChain({
1624
1667
  */
1625
1668
  const PolygonAmoy = defineChain({
1626
1669
  type: 'evm',
1627
- chain: Blockchain.Polygon_Amoy_Testnet,
1670
+ chain: exports.Blockchain.Polygon_Amoy_Testnet,
1628
1671
  name: 'Polygon Amoy',
1629
1672
  title: 'Polygon Amoy Testnet',
1630
1673
  nativeCurrency: {
@@ -1670,7 +1713,7 @@ const PolygonAmoy = defineChain({
1670
1713
  */
1671
1714
  const Sei = defineChain({
1672
1715
  type: 'evm',
1673
- chain: Blockchain.Sei,
1716
+ chain: exports.Blockchain.Sei,
1674
1717
  name: 'Sei',
1675
1718
  title: 'Sei Mainnet',
1676
1719
  nativeCurrency: {
@@ -1709,7 +1752,7 @@ const Sei = defineChain({
1709
1752
  */
1710
1753
  const SeiTestnet = defineChain({
1711
1754
  type: 'evm',
1712
- chain: Blockchain.Sei_Testnet,
1755
+ chain: exports.Blockchain.Sei_Testnet,
1713
1756
  name: 'Sei Testnet',
1714
1757
  title: 'Sei Test Network',
1715
1758
  nativeCurrency: {
@@ -1747,7 +1790,7 @@ const SeiTestnet = defineChain({
1747
1790
  */
1748
1791
  const Sonic = defineChain({
1749
1792
  type: 'evm',
1750
- chain: Blockchain.Sonic,
1793
+ chain: exports.Blockchain.Sonic,
1751
1794
  name: 'Sonic',
1752
1795
  title: 'Sonic Mainnet',
1753
1796
  nativeCurrency: {
@@ -1779,26 +1822,26 @@ const Sonic = defineChain({
1779
1822
  });
1780
1823
 
1781
1824
  /**
1782
- * Sonic Blaze Testnet chain definition
1825
+ * Sonic Testnet chain definition
1783
1826
  * @remarks
1784
1827
  * This represents the official test network for the Sonic blockchain.
1785
1828
  */
1786
1829
  const SonicTestnet = defineChain({
1787
1830
  type: 'evm',
1788
- chain: Blockchain.Sonic_Testnet,
1789
- name: 'Sonic Blaze Testnet',
1790
- title: 'Sonic Blaze Testnet',
1831
+ chain: exports.Blockchain.Sonic_Testnet,
1832
+ name: 'Sonic Testnet',
1833
+ title: 'Sonic Testnet',
1791
1834
  nativeCurrency: {
1792
1835
  name: 'Sonic',
1793
1836
  symbol: 'S',
1794
1837
  decimals: 18,
1795
1838
  },
1796
- chainId: 57054,
1839
+ chainId: 14601,
1797
1840
  isTestnet: true,
1798
1841
  explorerUrl: 'https://testnet.sonicscan.org/tx/{hash}',
1799
- rpcEndpoints: ['https://rpc.blaze.soniclabs.com'],
1842
+ rpcEndpoints: ['https://rpc.testnet.soniclabs.com'],
1800
1843
  eurcAddress: null,
1801
- usdcAddress: '0xA4879Fed32Ecbef99399e5cbC247E533421C4eC6',
1844
+ usdcAddress: '0x0BA304580ee7c9a980CF72e55f5Ed2E9fd30Bc51',
1802
1845
  cctp: {
1803
1846
  domain: 13,
1804
1847
  contracts: {
@@ -1823,7 +1866,7 @@ const SonicTestnet = defineChain({
1823
1866
  */
1824
1867
  const Solana = defineChain({
1825
1868
  type: 'solana',
1826
- chain: Blockchain.Solana,
1869
+ chain: exports.Blockchain.Solana,
1827
1870
  name: 'Solana',
1828
1871
  title: 'Solana Mainnet',
1829
1872
  nativeCurrency: {
@@ -1866,7 +1909,7 @@ const Solana = defineChain({
1866
1909
  */
1867
1910
  const SolanaDevnet = defineChain({
1868
1911
  type: 'solana',
1869
- chain: Blockchain.Solana_Devnet,
1912
+ chain: exports.Blockchain.Solana_Devnet,
1870
1913
  name: 'Solana Devnet',
1871
1914
  title: 'Solana Development Network',
1872
1915
  nativeCurrency: {
@@ -1909,7 +1952,7 @@ const SolanaDevnet = defineChain({
1909
1952
  */
1910
1953
  const Stellar = defineChain({
1911
1954
  type: 'stellar',
1912
- chain: Blockchain.Stellar,
1955
+ chain: exports.Blockchain.Stellar,
1913
1956
  name: 'Stellar',
1914
1957
  title: 'Stellar Mainnet',
1915
1958
  nativeCurrency: {
@@ -1932,7 +1975,7 @@ const Stellar = defineChain({
1932
1975
  */
1933
1976
  const StellarTestnet = defineChain({
1934
1977
  type: 'stellar',
1935
- chain: Blockchain.Stellar_Testnet,
1978
+ chain: exports.Blockchain.Stellar_Testnet,
1936
1979
  name: 'Stellar Testnet',
1937
1980
  title: 'Stellar Test Network',
1938
1981
  nativeCurrency: {
@@ -1955,7 +1998,7 @@ const StellarTestnet = defineChain({
1955
1998
  */
1956
1999
  const Sui = defineChain({
1957
2000
  type: 'sui',
1958
- chain: Blockchain.Sui,
2001
+ chain: exports.Blockchain.Sui,
1959
2002
  name: 'Sui',
1960
2003
  title: 'Sui Mainnet',
1961
2004
  nativeCurrency: {
@@ -1988,7 +2031,7 @@ const Sui = defineChain({
1988
2031
  */
1989
2032
  const SuiTestnet = defineChain({
1990
2033
  type: 'sui',
1991
- chain: Blockchain.Sui_Testnet,
2034
+ chain: exports.Blockchain.Sui_Testnet,
1992
2035
  name: 'Sui Testnet',
1993
2036
  title: 'Sui Test Network',
1994
2037
  nativeCurrency: {
@@ -2021,7 +2064,7 @@ const SuiTestnet = defineChain({
2021
2064
  */
2022
2065
  const Unichain = defineChain({
2023
2066
  type: 'evm',
2024
- chain: Blockchain.Unichain,
2067
+ chain: exports.Blockchain.Unichain,
2025
2068
  name: 'Unichain',
2026
2069
  title: 'Unichain Mainnet',
2027
2070
  nativeCurrency: {
@@ -2065,7 +2108,7 @@ const Unichain = defineChain({
2065
2108
  */
2066
2109
  const UnichainSepolia = defineChain({
2067
2110
  type: 'evm',
2068
- chain: Blockchain.Unichain_Sepolia,
2111
+ chain: exports.Blockchain.Unichain_Sepolia,
2069
2112
  name: 'Unichain Sepolia',
2070
2113
  title: 'Unichain Sepolia Testnet',
2071
2114
  nativeCurrency: {
@@ -2109,7 +2152,7 @@ const UnichainSepolia = defineChain({
2109
2152
  */
2110
2153
  const WorldChain = defineChain({
2111
2154
  type: 'evm',
2112
- chain: Blockchain.World_Chain,
2155
+ chain: exports.Blockchain.World_Chain,
2113
2156
  name: 'World Chain',
2114
2157
  title: 'World Chain',
2115
2158
  nativeCurrency: {
@@ -2147,7 +2190,7 @@ const WorldChain = defineChain({
2147
2190
  */
2148
2191
  const WorldChainSepolia = defineChain({
2149
2192
  type: 'evm',
2150
- chain: Blockchain.World_Chain_Sepolia,
2193
+ chain: exports.Blockchain.World_Chain_Sepolia,
2151
2194
  name: 'World Chain Sepolia',
2152
2195
  title: 'World Chain Sepolia',
2153
2196
  nativeCurrency: {
@@ -2190,7 +2233,7 @@ const WorldChainSepolia = defineChain({
2190
2233
  */
2191
2234
  const XDC = defineChain({
2192
2235
  type: 'evm',
2193
- chain: Blockchain.XDC,
2236
+ chain: exports.Blockchain.XDC,
2194
2237
  name: 'XDC',
2195
2238
  title: 'XDC Mainnet',
2196
2239
  nativeCurrency: {
@@ -2228,7 +2271,7 @@ const XDC = defineChain({
2228
2271
  */
2229
2272
  const XDCApothem = defineChain({
2230
2273
  type: 'evm',
2231
- chain: Blockchain.XDC_Apothem,
2274
+ chain: exports.Blockchain.XDC_Apothem,
2232
2275
  name: 'Apothem Network',
2233
2276
  title: 'Apothem Network',
2234
2277
  nativeCurrency: {
@@ -2266,7 +2309,7 @@ const XDCApothem = defineChain({
2266
2309
  */
2267
2310
  const ZKSyncEra = defineChain({
2268
2311
  type: 'evm',
2269
- chain: Blockchain.ZKSync_Era,
2312
+ chain: exports.Blockchain.ZKSync_Era,
2270
2313
  name: 'ZKSync Era',
2271
2314
  title: 'ZKSync Era Mainnet',
2272
2315
  nativeCurrency: {
@@ -2290,7 +2333,7 @@ const ZKSyncEra = defineChain({
2290
2333
  */
2291
2334
  const ZKSyncEraSepolia = defineChain({
2292
2335
  type: 'evm',
2293
- chain: Blockchain.ZKSync_Sepolia,
2336
+ chain: exports.Blockchain.ZKSync_Sepolia,
2294
2337
  name: 'ZKSync Era Sepolia',
2295
2338
  title: 'ZKSync Era Sepolia Testnet',
2296
2339
  nativeCurrency: {
@@ -2315,6 +2358,7 @@ var Blockchains = {
2315
2358
  AptosTestnet: AptosTestnet,
2316
2359
  Arbitrum: Arbitrum,
2317
2360
  ArbitrumSepolia: ArbitrumSepolia,
2361
+ ArcTestnet: ArcTestnet,
2318
2362
  Avalanche: Avalanche,
2319
2363
  AvalancheFuji: AvalancheFuji,
2320
2364
  Base: Base,
@@ -2421,7 +2465,7 @@ function hasCustomContractSupport(chain, contractType) {
2421
2465
  * This contains all properties shared between EVM and non-EVM chains.
2422
2466
  */
2423
2467
  const baseChainDefinitionSchema = zod.z.object({
2424
- chain: zod.z.nativeEnum(Blockchain, {
2468
+ chain: zod.z.nativeEnum(exports.Blockchain, {
2425
2469
  required_error: 'Chain enum is required. Please provide a valid Blockchain enum value.',
2426
2470
  invalid_type_error: 'Chain must be a valid Blockchain enum value.',
2427
2471
  }),
@@ -2447,6 +2491,11 @@ const baseChainDefinitionSchema = zod.z.object({
2447
2491
  eurcAddress: zod.z.string().nullable(),
2448
2492
  usdcAddress: zod.z.string().nullable(),
2449
2493
  cctp: zod.z.any().nullable(), // We'll accept any CCTP config structure
2494
+ kitContracts: zod.z
2495
+ .object({
2496
+ bridge: zod.z.string().optional(),
2497
+ })
2498
+ .optional(),
2450
2499
  });
2451
2500
  /**
2452
2501
  * Zod schema for validating EVM chain definitions specifically.
@@ -2478,13 +2527,15 @@ const baseChainDefinitionSchema = zod.z.object({
2478
2527
  * }
2479
2528
  * ```
2480
2529
  */
2481
- const evmChainDefinitionSchema = baseChainDefinitionSchema.extend({
2530
+ const evmChainDefinitionSchema = baseChainDefinitionSchema
2531
+ .extend({
2482
2532
  type: zod.z.literal('evm'),
2483
2533
  chainId: zod.z.number({
2484
2534
  required_error: 'EVM chains must have a chainId. Please provide a valid EVM chain ID.',
2485
2535
  invalid_type_error: 'EVM chain ID must be a number.',
2486
2536
  }),
2487
- });
2537
+ })
2538
+ .strict(); //// Reject any additional properties not defined in the schema
2488
2539
  /**
2489
2540
  * Zod schema for validating non-EVM chain definitions.
2490
2541
  * This schema extends the base schema with non-EVM specific properties.
@@ -2504,7 +2555,7 @@ const nonEvmChainDefinitionSchema = baseChainDefinitionSchema
2504
2555
  'polkadot',
2505
2556
  ]),
2506
2557
  })
2507
- .strict(); // Reject additional properties like chainId
2558
+ .strict(); // Reject any additional properties not defined in the schema
2508
2559
  /**
2509
2560
  * Discriminated union schema for all chain definitions.
2510
2561
  * This schema validates different chain types based on their 'type' field.
@@ -2553,8 +2604,8 @@ const chainDefinitionSchema$1 = zod.z.discriminatedUnion('type', [
2553
2604
  zod.z.union([
2554
2605
  zod.z
2555
2606
  .string()
2556
- .refine((val) => val in Blockchain, 'Must be a valid Blockchain enum value as string'),
2557
- zod.z.nativeEnum(Blockchain),
2607
+ .refine((val) => val in exports.Blockchain, 'Must be a valid Blockchain enum value as string'),
2608
+ zod.z.nativeEnum(exports.Blockchain),
2558
2609
  chainDefinitionSchema$1,
2559
2610
  ]);
2560
2611
 
@@ -2986,67 +3037,41 @@ class KitError extends Error {
2986
3037
  }
2987
3038
 
2988
3039
  /**
2989
- * Standardized error codes for INPUT type errors.
3040
+ * Minimum error code for INPUT type errors.
3041
+ * INPUT errors represent validation failures and invalid parameters.
3042
+ */
3043
+ /**
3044
+ * Standardized error definitions for INPUT type errors.
3045
+ *
3046
+ * Each entry combines the numeric error code with its corresponding
3047
+ * string name to ensure consistency when creating error instances.
2990
3048
  *
2991
3049
  * Error codes follow a hierarchical numbering scheme where the first digit
2992
3050
  * indicates the error category (1 = INPUT) and subsequent digits provide
2993
3051
  * specific error identification within that category.
2994
3052
  *
3053
+ *
2995
3054
  * @example
2996
3055
  * ```typescript
2997
- * import { InputErrorCode, InputErrorName } from '@core/errors'
3056
+ * import { InputError } from '@core/errors'
2998
3057
  *
2999
3058
  * const error = new KitError({
3000
- * code: InputErrorCode.NETWORK_MISMATCH,
3001
- * name: InputErrorName.NETWORK_MISMATCH,
3059
+ * ...InputError.NETWORK_MISMATCH,
3002
3060
  * recoverability: 'FATAL',
3003
3061
  * message: 'Source and destination networks must be different'
3004
3062
  * })
3005
- * ```
3006
- */
3007
- var InputErrorCode;
3008
- (function (InputErrorCode) {
3009
- /** Network type mismatch between chains (mainnet vs testnet) */
3010
- InputErrorCode[InputErrorCode["NETWORK_MISMATCH"] = 1001] = "NETWORK_MISMATCH";
3011
- /** Invalid amount format or value (negative, zero, or malformed) */
3012
- InputErrorCode[InputErrorCode["INVALID_AMOUNT"] = 1002] = "INVALID_AMOUNT";
3013
- /** Unsupported or invalid bridge route configuration */
3014
- InputErrorCode[InputErrorCode["UNSUPPORTED_ROUTE"] = 1003] = "UNSUPPORTED_ROUTE";
3015
- /** Invalid wallet or contract address format */
3016
- InputErrorCode[InputErrorCode["INVALID_ADDRESS"] = 1004] = "INVALID_ADDRESS";
3017
- /** Invalid or unsupported chain identifier */
3018
- InputErrorCode[InputErrorCode["INVALID_CHAIN"] = 1005] = "INVALID_CHAIN";
3019
- /** General validation failure for complex validation rules */
3020
- InputErrorCode[InputErrorCode["VALIDATION_FAILED"] = 1098] = "VALIDATION_FAILED";
3021
- })(InputErrorCode || (InputErrorCode = {}));
3022
- /**
3023
- * Standardized error names for INPUT type errors.
3024
- *
3025
- * These names correspond 1:1 with InputErrorCode and should always
3026
- * be used together to ensure consistency across error instances.
3027
3063
  *
3028
- * @example
3029
- * ```typescript
3030
- * import { InputErrorCode, InputErrorName } from '@core/errors'
3031
- *
3032
- * // Use matching code and name enums
3033
- * const error = new KitError({
3034
- * code: InputErrorCode.NETWORK_MISMATCH,
3035
- * name: InputErrorName.NETWORK_MISMATCH,
3036
- * recoverability: 'FATAL',
3037
- * message: 'Network mismatch detected'
3038
- * })
3064
+ * // Access code and name individually if needed
3065
+ * console.log(InputError.NETWORK_MISMATCH.code) // 1001
3066
+ * console.log(InputError.NETWORK_MISMATCH.name) // 'INPUT_NETWORK_MISMATCH'
3039
3067
  * ```
3040
3068
  */
3041
- var InputErrorName;
3042
- (function (InputErrorName) {
3043
- InputErrorName["NETWORK_MISMATCH"] = "INPUT_NETWORK_MISMATCH";
3044
- InputErrorName["INVALID_AMOUNT"] = "INPUT_INVALID_AMOUNT";
3045
- InputErrorName["UNSUPPORTED_ROUTE"] = "INPUT_UNSUPPORTED_ROUTE";
3046
- InputErrorName["INVALID_ADDRESS"] = "INPUT_INVALID_ADDRESS";
3047
- InputErrorName["INVALID_CHAIN"] = "INPUT_INVALID_CHAIN";
3048
- InputErrorName["VALIDATION_FAILED"] = "INPUT_VALIDATION_FAILED";
3049
- })(InputErrorName || (InputErrorName = {}));
3069
+ const InputError = {
3070
+ /** Unsupported or invalid bridge route configuration */
3071
+ UNSUPPORTED_ROUTE: {
3072
+ code: 1003,
3073
+ name: 'INPUT_UNSUPPORTED_ROUTE',
3074
+ }};
3050
3075
 
3051
3076
  /**
3052
3077
  * Creates error for unsupported bridge route.
@@ -3068,8 +3093,7 @@ var InputErrorName;
3068
3093
  */
3069
3094
  function createUnsupportedRouteError(source, destination) {
3070
3095
  const errorDetails = {
3071
- code: InputErrorCode.UNSUPPORTED_ROUTE,
3072
- name: InputErrorName.UNSUPPORTED_ROUTE,
3096
+ ...InputError.UNSUPPORTED_ROUTE,
3073
3097
  recoverability: 'FATAL',
3074
3098
  message: `Route from ${source} to ${destination} is not supported.`,
3075
3099
  cause: {
@@ -3118,26 +3142,6 @@ class Adapter {
3118
3142
  * ```
3119
3143
  */
3120
3144
  capabilities;
3121
- /**
3122
- * Default chain for operations when none is explicitly provided.
3123
- *
3124
- * This allows adapters to have sensible defaults for chain operations,
3125
- * reducing the need for explicit chain specification in every call.
3126
- *
3127
- * @remarks
3128
- * This is optional for backward compatibility and because some adapter types
3129
- * (like developer-controlled adapters) may not have meaningful defaults.
3130
- *
3131
- * @example
3132
- * ```typescript
3133
- * // User-controlled adapter with default chain
3134
- * defaultChain = Ethereum
3135
- *
3136
- * // Developer-controlled adapter (no default)
3137
- * defaultChain = undefined
3138
- * ```
3139
- */
3140
- defaultChain;
3141
3145
  /**
3142
3146
  * Registry of available actions for this adapter.
3143
3147
  *
@@ -3209,17 +3213,14 @@ class Adapter {
3209
3213
  * - **Browser wallet adapters**: Request chain switch via EIP-1193 or equivalent
3210
3214
  * - **Multi-entity adapters**: Validate chain support (operations are contextual)
3211
3215
  *
3212
- * @param chain - The target chain for operations. If not provided, uses the adapter's defaultChain.
3216
+ * @param chain - The target chain for operations.
3213
3217
  * @returns A promise that resolves when the adapter is operating on the specified chain.
3214
3218
  * @throws When the target chain is not supported or chain switching fails.
3215
3219
  *
3216
3220
  * @remarks
3217
- * This method replaces the pattern of calling `getChain()` to check current chain and then
3218
- * manually switching. It provides a declarative "ensure this chain" interface for operations.
3219
- *
3220
- * **Backward Compatibility**: The default implementation provides basic validation but
3221
- * doesn't perform actual chain switching. Concrete adapter implementations should override
3222
- * this method to provide proper chain switching logic.
3221
+ * This method always calls `switchToChain()` to ensure consistency across all adapter types.
3222
+ * The underlying implementations handle idempotent switching efficiently (e.g., browser wallets
3223
+ * gracefully handle switching to the current chain, private key adapters recreate lightweight clients).
3223
3224
  *
3224
3225
  * @example
3225
3226
  * ```typescript
@@ -3233,25 +3234,9 @@ class Adapter {
3233
3234
  * await circleWalletsAdapter.ensureChain(Ethereum)
3234
3235
  * ```
3235
3236
  */
3236
- async ensureChain(chain) {
3237
- const targetChain = chain ?? this.defaultChain;
3238
- if (!targetChain) {
3239
- return;
3240
- }
3237
+ async ensureChain(targetChain) {
3241
3238
  this.validateChainSupport(targetChain);
3242
- // Check if already on the target chain (skip for developer-controlled adapters)
3243
- if (this.capabilities?.addressContext !== 'developer-controlled') {
3244
- try {
3245
- const currentChain = await this.getChain();
3246
- if (currentChain.chain === targetChain.chain) {
3247
- return; // Already on the correct chain
3248
- }
3249
- }
3250
- catch {
3251
- // If getChain() fails, we'll proceed with switching anyway
3252
- }
3253
- }
3254
- // Delegate actual switching to the concrete implementation
3239
+ // Always delegate to switchToChain - implementations handle idempotent switching
3255
3240
  try {
3256
3241
  await this.switchToChain(targetChain);
3257
3242
  }
@@ -3814,7 +3799,6 @@ base58StringSchema.refine((value) => value.length >= 86 && value.length <= 88, '
3814
3799
  const adapterSchema = zod.z.object({
3815
3800
  prepare: zod.z.function(),
3816
3801
  waitForTransaction: zod.z.function(),
3817
- getChain: zod.z.function(),
3818
3802
  getAddress: zod.z.function(),
3819
3803
  });
3820
3804
 
@@ -8076,6 +8060,246 @@ class EvmAdapter extends Adapter {
8076
8060
  }
8077
8061
  }
8078
8062
 
8063
+ // --- Signature Parsing Constants ---
8064
+ const SIGNATURE_BYTE_LENGTH = 65; // Total bytes in an Ethereum signature
8065
+ const HEX_CHARS_PER_BYTE = 2;
8066
+ const SIGNATURE_HEX_LENGTH = SIGNATURE_BYTE_LENGTH * HEX_CHARS_PER_BYTE;
8067
+ const R_HEX_LENGTH = 32 * HEX_CHARS_PER_BYTE; // 32 bytes for 'r'
8068
+ const S_HEX_LENGTH = 32 * HEX_CHARS_PER_BYTE; // 32 bytes for 's'
8069
+ // --- Recovery ID Validation Constants ---
8070
+ /**
8071
+ * Legacy recovery IDs (pre-EIP-155 format):
8072
+ * - 0 or 1 (older clients) or 27, 28 (Ethereum before chain-id inclusion)
8073
+ */
8074
+ const LEGACY_V_VALUES = new Set([0, 1, 27, 28]);
8075
+ /**
8076
+ * Minimum v value indicating an EIP-155 style signature.
8077
+ * Calculated as 35 + (2 * chainId) + recoveryId (0 or 1).
8078
+ */
8079
+ const MIN_EIP155_V = 35;
8080
+ /**
8081
+ * parseSignature
8082
+ *
8083
+ * Parse a 65-byte ECDSA signature into its r, s, and v components, expressed in hex.
8084
+ *
8085
+ * Ethereum signatures are structured as:
8086
+ * signature = r (32 bytes) || s (32 bytes) || v (1 byte)
8087
+ *
8088
+ * - r, s: Big-endian hex values (32 bytes each)
8089
+ * - v: Recovery identifier, used by secp256k1 to reconstruct the signer’s public key
8090
+ *
8091
+ * @param signatureHex - Signature as a hex string, optionally prefixed with "0x".
8092
+ * @returns { r, s, v }
8093
+ * - r: Hex string of the R component.
8094
+ * - s: Hex string of the S component.
8095
+ * - v: Numeric recovery ID.
8096
+ *
8097
+ * @throws Error if:
8098
+ * - Input is not valid hex.
8099
+ * - Incorrect length (must be exactly 65 bytes / 130 hex chars).
8100
+ * - v is outside the supported range (Legacy or EIP-155 formula).
8101
+ *
8102
+ * Notes on EIP-155 overload:
8103
+ * EIP-155 repurposes the v field so that:
8104
+ * v = 35 + (2 * chainId) + recoveryId(0 or 1)
8105
+ * Any v value >= 35 indicates the chain-id is encoded, preventing cross-chain replay.
8106
+ * r and s values remain unchanged.
8107
+ *
8108
+ * Example:
8109
+ * ```typescript
8110
+ * const rawSig = '0x6c1b...f02b'
8111
+ * try {
8112
+ * const { r, s, v } = parseSignature(rawSig)
8113
+ * console.log('R:', r)
8114
+ * console.log('S:', s)
8115
+ * console.log('Recovery ID (v):', v)
8116
+ * } catch (err) {
8117
+ * console.error('Signature parse error:', err.message)
8118
+ * }
8119
+ * ```
8120
+ */
8121
+ function parseSignature(signatureHex) {
8122
+ // 1) Remove optional '0x' prefix
8123
+ const hex = signatureHex.startsWith('0x')
8124
+ ? signatureHex.slice(2)
8125
+ : signatureHex;
8126
+ // 2) Validate hex format and length
8127
+ const VALID_HEX_REGEX = /^[0-9a-fA-F]+$/;
8128
+ if (!VALID_HEX_REGEX.test(hex)) {
8129
+ throw new Error('Signature must be a valid hex string (0-9, a-f, A-F).');
8130
+ }
8131
+ if (hex.length !== SIGNATURE_HEX_LENGTH) {
8132
+ throw new Error(`Invalid length: expected ${SIGNATURE_HEX_LENGTH.toString()} hex chars (65 bytes), got ${hex.length.toString()}`);
8133
+ }
8134
+ // 3) Extract components
8135
+ const r = `0x${hex.slice(0, R_HEX_LENGTH)}`;
8136
+ const s = `0x${hex.slice(R_HEX_LENGTH, R_HEX_LENGTH + S_HEX_LENGTH)}`;
8137
+ const vValue = parseInt(hex.slice(R_HEX_LENGTH + S_HEX_LENGTH), 16);
8138
+ // 4) Ensure v is within supported values
8139
+ const isLegacy = LEGACY_V_VALUES.has(vValue);
8140
+ const isEIP155 = vValue >= MIN_EIP155_V;
8141
+ if (!isLegacy && !isEIP155) {
8142
+ throw new Error(`Unsupported v value: ${vValue.toString()}. Must be one of [${[
8143
+ ...LEGACY_V_VALUES,
8144
+ ].join(', ')}] or >=${MIN_EIP155_V.toString()}`);
8145
+ }
8146
+ return { r: r, s: s, v: vValue };
8147
+ }
8148
+ /**
8149
+ * buildTypedData
8150
+ *
8151
+ * Create an EIP-712 compliant "TypedData" object, encapsulating:
8152
+ * - Domain separator (application/contract identity, chain ID)
8153
+ * - Explicit type definitions (field names and types)
8154
+ * - Primary type name identifying the root object
8155
+ * - Message payload matching the defined schema
8156
+ *
8157
+ * This enforces structured, non-ambiguous signing, and guards against signature replay.
8158
+ *
8159
+ * @typeParam Types - Map of type names to arrays of { name, type } definitions.
8160
+ * @typeParam Msg - Object whose shape matches the primaryType fields.
8161
+ *
8162
+ * @param domain - EIP712Domain, e.g. { name, version, chainId, verifyingContract }.
8163
+ * @param types - Type definitions, e.g.:
8164
+ * {
8165
+ * Mail: [ { name: 'from', type: 'string' }, { name: 'contents', type: 'string' } ],
8166
+ * }
8167
+ * @param primaryType - Root key in types, e.g. 'Mail'.
8168
+ * @param message - The actual values, e.g. { from: 'Alice', contents: 'Hello' }.
8169
+ *
8170
+ * @returns TypedData object ready for use with signing libraries.
8171
+ *
8172
+ * Example:
8173
+ * ```typescript
8174
+ * const typedData = buildTypedData(
8175
+ * { name: 'MyDApp', version: '1', chainId: 1, verifyingContract: '0xabc...' },
8176
+ * { Message: [{ name: 'text', type: 'string' }] },
8177
+ * 'Message',
8178
+ * { text: 'Hello, EIP-712!' }
8179
+ * )
8180
+ * // Pass typedData to ethers.js signer._signTypedData(domain, types, message)
8181
+ * ```
8182
+ */
8183
+ function buildTypedData(domain, types, primaryType, message) {
8184
+ return { domain, types, primaryType, message };
8185
+ }
8186
+
8187
+ /**
8188
+ * Compute default deadline for permit signatures.
8189
+ *
8190
+ * Returns a timestamp 1 hour (3600 seconds) from the current time,
8191
+ * converted to Unix timestamp format as a bigint. This is commonly
8192
+ * used as the default expiration time for EIP-2612 permit signatures.
8193
+ *
8194
+ * @returns Unix timestamp (in seconds) 1 hour from now as a bigint
8195
+ *
8196
+ * @example
8197
+ * ```typescript
8198
+ * import { computeDefaultDeadline } from '@core/adapter-evm'
8199
+ *
8200
+ * const deadline = computeDefaultDeadline()
8201
+ * console.log(`Permit expires at: ${deadline}`)
8202
+ * // Output: Permit expires at: 1640998800
8203
+ * ```
8204
+ */
8205
+ function computeDefaultDeadline() {
8206
+ return BigInt(Math.floor(Date.now() / 1000) + 3600);
8207
+ }
8208
+
8209
+ /**
8210
+ * EIP-2612 permit type definition.
8211
+ * Defines the structure for permit signatures according to EIP-2612 specification.
8212
+ *
8213
+ * @see {@link https://eips.ethereum.org/EIPS/eip-2612 | EIP-2612 Specification}
8214
+ */
8215
+ const EIP2612_TYPES = {
8216
+ Permit: [
8217
+ { name: 'owner', type: 'address' },
8218
+ { name: 'spender', type: 'address' },
8219
+ { name: 'value', type: 'uint256' },
8220
+ { name: 'nonce', type: 'uint256' },
8221
+ { name: 'deadline', type: 'uint256' },
8222
+ ],
8223
+ };
8224
+
8225
+ /**
8226
+ * Build EIP-2612 typed data for permit signing.
8227
+ *
8228
+ * This function creates the complete EIP-712 typed data structure required
8229
+ * for EIP-2612 permit signatures, including automatic nonce fetching using
8230
+ * the adapter's built-in nonce fetching capability.
8231
+ *
8232
+ * **Address Formatting**: All addresses are automatically formatted with proper
8233
+ * EIP-55 checksumming using the `convertAddress` utility, ensuring compatibility
8234
+ * with strict validation libraries like viem.
8235
+ *
8236
+ * **Nonce Handling**: The nonce can be provided explicitly or will be fetched
8237
+ * automatically using the adapter's `fetchEIP2612Nonce` method, which queries
8238
+ * the token contract's `nonces(owner)` function.
8239
+ *
8240
+ * **Deadline Calculation**: If no deadline is provided, it defaults to 24 hours
8241
+ * from the current time (computed using `computeDefaultDeadline`).
8242
+ *
8243
+ * @param meta - Domain metadata for the token contract
8244
+ * @param adapter - Adapter instance with nonce-fetching capability
8245
+ * @param opts - EIP-2612 permit options including owner, spender, value
8246
+ * @returns Complete EIP-712 typed data ready for signing
8247
+ *
8248
+ * @example
8249
+ * ```typescript
8250
+ * import { buildEIP2612TypedData } from '@core/adapter-evm'
8251
+ *
8252
+ * const typedData = await buildEIP2612TypedData(
8253
+ * {
8254
+ * name: 'USD Coin',
8255
+ * version: '2',
8256
+ * chainId: 1,
8257
+ * verifyingContract: '0xa0b86a33e6441e4d178bb0c14ce0e9ce9c83bdd8'
8258
+ * },
8259
+ * adapter,
8260
+ * {
8261
+ * owner: '0x742d35cc6639c0532fbe9002b3a2265ca4c878f8e',
8262
+ * spender: '0x1234567890123456789012345678901234567890',
8263
+ * value: 1000000n
8264
+ * }
8265
+ * )
8266
+ *
8267
+ * const signature = await adapter.signTypedData(typedData)
8268
+ * ```
8269
+ */
8270
+ async function buildEIP2612TypedData(meta, adapter, opts, ctx) {
8271
+ // Format addresses to ensure proper EIP-55 checksumming
8272
+ const formattedOwner = convertAddress(opts.owner, 'evm');
8273
+ const formattedSpender = convertAddress(opts.spender, 'evm');
8274
+ const formattedContract = convertAddress(meta.verifyingContract, 'evm');
8275
+ // Fetch nonce if not provided - adapter handles the contract interaction
8276
+ const nonce = opts.nonce ??
8277
+ (await adapter.fetchEIP2612Nonce(formattedContract, formattedOwner, ctx));
8278
+ /*
8279
+ * Calculate deadline if not provided (24 hours from now)
8280
+ * EIP-2612 deadline is a uint256 in the permit struct, so we use bigint for full compatibility
8281
+ * with on-chain values and to avoid overflow/precision issues with large timestamps.
8282
+ * Most real-world deadlines are within JS safe integer range, but using bigint is safest.
8283
+ */
8284
+ const now = BigInt(Math.floor(Date.now() / 1000));
8285
+ const deadline = opts.deadline !== undefined
8286
+ ? BigInt(opts.deadline)
8287
+ : computeDefaultDeadline();
8288
+ if (deadline <= now) {
8289
+ throw new Error(`EIP-2612 deadline must be in the future (got ${deadline.toString()}, now ${now.toString()})`);
8290
+ }
8291
+ // Build the message with properly formatted addresses
8292
+ const message = {
8293
+ owner: formattedOwner,
8294
+ spender: formattedSpender,
8295
+ value: opts.value,
8296
+ nonce,
8297
+ deadline,
8298
+ };
8299
+ // Return complete typed data structure with formatted contract address
8300
+ return buildTypedData({ ...meta, verifyingContract: formattedContract }, EIP2612_TYPES, 'Permit', message);
8301
+ }
8302
+
8079
8303
  /**
8080
8304
  * Checks if a function in an ABI is read-only (view or pure).
8081
8305
  *
@@ -8450,7 +8674,6 @@ const abiSchema = zod.z
8450
8674
  * - A chainType property set to 'evm'
8451
8675
  * - An actionRegistry with registerHandlers method and actionHandlers record
8452
8676
  * - A prepare method for creating chain requests
8453
- * - A getChain method for retrieving chain configuration
8454
8677
  *
8455
8678
  * @throws \{ValidationError\} If validation fails, with details about which properties failed
8456
8679
  *
@@ -8467,7 +8690,6 @@ const abiSchema = zod.z
8467
8690
  * }
8468
8691
  * },
8469
8692
  * prepare: async (request: any) => ({}),
8470
- * getChain: async () => ({ name: 'Ethereum', type: 'evm' as const })
8471
8693
  * }
8472
8694
  *
8473
8695
  * const result = evmAdapterSchema.safeParse(validAdapter)
@@ -8569,6 +8791,44 @@ const evmTransactionHashSchema = zod.z
8569
8791
  .refine((hash) => /^0x[0-9a-fA-F]{64}$/.test(hash), (hash) => ({
8570
8792
  message: `Transaction hash "${hash}" contains invalid characters. Only hexadecimal characters (0-9, a-f, A-F) are allowed after '0x'.`,
8571
8793
  }));
8794
+ /**
8795
+ * Zod schema for validating EVM private keys.
8796
+ *
8797
+ * This schema validates private key strings to ensure they are properly formatted:
8798
+ * - Accepts private keys with or without '0x' prefix
8799
+ * - Automatically normalizes by adding '0x' prefix if missing
8800
+ * - Validates that the key is exactly 64 hexadecimal characters (32 bytes)
8801
+ * - Ensures only valid hexadecimal characters (0-9, a-f, A-F) are used
8802
+ *
8803
+ * @remarks
8804
+ * This is a shared schema used by both ethers.v6 and viem.v2 adapters to ensure
8805
+ * consistent private key validation across all EVM adapters.
8806
+ *
8807
+ * @throws \{ValidationError\} If validation fails, with details about the issue
8808
+ *
8809
+ * @example
8810
+ * ```typescript
8811
+ * import { evmPrivateKeySchema } from '@core/adapter-evm/validation'
8812
+ *
8813
+ * // Both formats are accepted and normalized
8814
+ * const keyWithPrefix = '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef'
8815
+ * const keyWithoutPrefix = '1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef'
8816
+ *
8817
+ * const result1 = evmPrivateKeySchema.safeParse(keyWithPrefix)
8818
+ * const result2 = evmPrivateKeySchema.safeParse(keyWithoutPrefix)
8819
+ *
8820
+ * // Both succeed and produce the same normalized result with '0x' prefix
8821
+ * ```
8822
+ */
8823
+ const evmPrivateKeySchema = zod.z
8824
+ .string({
8825
+ required_error: 'Private key is required. Please provide a valid private key.',
8826
+ invalid_type_error: 'Private key must be a string. Please provide a valid private key.',
8827
+ })
8828
+ .transform((val) => (val.startsWith('0x') ? val : `0x${val}`))
8829
+ .pipe(zod.z.string().regex(/^0x[0-9a-fA-F]{64}$/, {
8830
+ message: 'Private key must be a valid 64-character hex string. Please provide a valid private key with or without "0x" prefix.',
8831
+ }));
8572
8832
 
8573
8833
  const assertEvmPreparedChainRequestParamsSymbol = Symbol('assertEvmPreparedChainRequestParams');
8574
8834
  /**
@@ -9337,7 +9597,7 @@ const ethersAdapterOptionsSchema = zod.z.object({
9337
9597
  * Zod schema for validating parameters to create an EthersAdapter from a private key.
9338
9598
  *
9339
9599
  * @remarks
9340
- * - `privateKey` must be a string starting with "0x" and 64 hexadecimal characters.
9600
+ * - `privateKey` can be provided with or without the "0x" prefix. The schema automatically normalizes keys by adding the "0x" prefix if missing before validation.
9341
9601
  * - `getProvider` is optional and, if provided, must be a function accepting an object with a `chain` parameter and returning any value.
9342
9602
  * - `capabilities` is optional and allows partial overrides with smart defaults.
9343
9603
  *
@@ -9345,27 +9605,22 @@ const ethersAdapterOptionsSchema = zod.z.object({
9345
9605
  * ```typescript
9346
9606
  * import { createAdapterFromPrivateKeyParamsSchema } from '@circle-fin/adapter-ethers-v6/validation'
9347
9607
  *
9348
- * const params = {
9608
+ * // Both formats are supported:
9609
+ * const paramsWithPrefix = {
9349
9610
  * privateKey: '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef'
9350
9611
  * }
9351
9612
  *
9352
- * const result = createAdapterFromPrivateKeyParamsSchema.safeParse(params)
9353
- * if (result.success) {
9354
- * console.log('Parameters are valid')
9355
- * } else {
9356
- * console.error('Validation failed:', result.error)
9613
+ * const paramsWithoutPrefix = {
9614
+ * privateKey: '1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef'
9357
9615
  * }
9616
+ *
9617
+ * const result1 = createAdapterFromPrivateKeyParamsSchema.safeParse(paramsWithPrefix)
9618
+ * const result2 = createAdapterFromPrivateKeyParamsSchema.safeParse(paramsWithoutPrefix)
9619
+ * // Both succeed and produce the same normalized result
9358
9620
  * ```
9359
9621
  */
9360
9622
  const createAdapterFromPrivateKeyParamsSchema = zod.z.object({
9361
- privateKey: zod.z
9362
- .string({
9363
- required_error: 'Private key is required. Please provide a valid private key.',
9364
- invalid_type_error: 'Private key must be a string. Please provide a valid private key.',
9365
- })
9366
- .regex(/^0x[0-9a-fA-F]{64}$/, {
9367
- message: 'Private key must be a 64-character hexadecimal string prefixed with "0x".',
9368
- }),
9623
+ privateKey: evmPrivateKeySchema,
9369
9624
  getProvider: zod.z
9370
9625
  .function()
9371
9626
  .args(zod.z.object({ chain: zod.z.unknown() }))
@@ -9474,28 +9729,6 @@ zod.z.object({
9474
9729
  function validateEthersAdapterOptions(options) {
9475
9730
  validate(options, ethersAdapterOptionsSchema, 'EthersAdapterOptions');
9476
9731
  }
9477
- /**
9478
- * Validates parameters for creating an Ethers adapter from a private key.
9479
- *
9480
- * This function validates the parameters used by the createAdapterFromPrivateKey
9481
- * factory function for the Ethers adapter.
9482
- *
9483
- * @param params - The parameters to validate. Must include a `privateKey` string and optionally a `getProvider` function and `capabilities`.
9484
- * @throws \{ValidationError\} If validation fails.
9485
- * @example
9486
- * ```typescript
9487
- * import { validateCreateAdapterFromPrivateKeyParams } from '@circle-fin/adapter-ethers-v6/validation'
9488
- *
9489
- * const params = {
9490
- * privateKey: '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef'
9491
- * }
9492
- *
9493
- * validateCreateAdapterFromPrivateKeyParams(params) // throws if invalid
9494
- * ```
9495
- */
9496
- function validateCreateAdapterFromPrivateKeyParams(params) {
9497
- validate(params, createAdapterFromPrivateKeyParamsSchema, 'CreateAdapterFromPrivateKeyParams');
9498
- }
9499
9732
  /**
9500
9733
  * Validates parameters for creating an Ethers adapter from an EIP-1193 provider.
9501
9734
  *
@@ -10041,6 +10274,11 @@ class EthersAdapter extends EvmAdapter {
10041
10274
  * ```
10042
10275
  */
10043
10276
  async getAddress(chain) {
10277
+ // Prevent calling getAddress on developer-controlled adapters
10278
+ if (this.capabilities?.addressContext === 'developer-controlled') {
10279
+ throw new Error('Cannot call getAddress() on developer-controlled adapters. ' +
10280
+ 'Address must be provided explicitly in the operation context.');
10281
+ }
10044
10282
  // Chain parameter should now be provided by resolveOperationContext
10045
10283
  if (!chain) {
10046
10284
  throw new Error('Chain parameter is required for address resolution. ' +
@@ -10052,45 +10290,6 @@ class EthersAdapter extends EvmAdapter {
10052
10290
  const address = await signer.getAddress();
10053
10291
  return address;
10054
10292
  }
10055
- /**
10056
- * Gets the current chain definition.
10057
- *
10058
- * TEMP This method is temporary and will be removed once all adapters migrate to the OperationContext pattern.
10059
- *
10060
- * **Migration Guide:**
10061
- *
10062
- * With the OperationContext pattern, chain information is provided explicitly in each operation
10063
- * rather than queried from the adapter. This eliminates ambiguity and enables seamless multi-chain
10064
- * operations with a single adapter instance.
10065
- *
10066
- * **Before (Deprecated):**
10067
- * ```typescript
10068
- * const chain = await adapter.getChain()
10069
- * const prepared = await adapter.prepare(params) // Uses cached chain
10070
- * ```
10071
- *
10072
- * **After (OperationContext):**
10073
- * ```typescript
10074
- * // Chain specified explicitly per operation
10075
- * const prepared = await adapter.prepare(params, { chain: 'Ethereum' })
10076
- *
10077
- * // Multi-chain operations with same adapter
10078
- * const ethPrepared = await adapter.prepare(params, { chain: 'Ethereum' })
10079
- * const basePrepared = await adapter.prepare(params, { chain: 'Base' })
10080
- * ```
10081
- *
10082
- * @returns A promise that resolves to the first supported chain from capabilities
10083
- * @throws Error when no supported chains are configured
10084
- */
10085
- async getChain() {
10086
- // Fallback: return first supported chain (deprecated - only for backward compatibility)
10087
- const firstChain = this.capabilities?.supportedChains?.[0];
10088
- if (!firstChain) {
10089
- throw new Error('No supported chains configured. ' +
10090
- 'This method is deprecated - use OperationContext pattern instead.');
10091
- }
10092
- return await Promise.resolve(firstChain);
10093
- }
10094
10293
  /**
10095
10294
  * Waits for a transaction to be mined and confirmed on the blockchain.
10096
10295
  *
@@ -10365,16 +10564,17 @@ class EthersAdapter extends EvmAdapter {
10365
10564
  * ```typescript
10366
10565
  * import { createAdapterFromPrivateKey } from '@circle-fin/adapter-ethers-v6'
10367
10566
  *
10368
- * // Minimal configuration with lazy initialization
10369
- * const adapter = createAdapterFromPrivateKey({
10370
- * privateKey: '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef'
10371
- * // Defaults applied:
10372
- * // - addressContext: 'user-controlled'
10373
- * // - supportedChains: all EVM chains (~29 networks)
10567
+ * // Both private key formats are supported (with or without '0x' prefix):
10568
+ * const adapter1 = createAdapterFromPrivateKey({
10569
+ * privateKey: '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef' // With prefix
10570
+ * })
10571
+ *
10572
+ * const adapter2 = createAdapterFromPrivateKey({
10573
+ * privateKey: '1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef' // Without prefix (automatically normalized)
10374
10574
  * })
10375
10575
  *
10376
10576
  * // Chain specified per-operation via OperationContext
10377
- * const prepared = await adapter.prepare({
10577
+ * const prepared = await adapter1.prepare({
10378
10578
  * address: '0x...',
10379
10579
  * abi: contractAbi,
10380
10580
  * functionName: 'transfer',
@@ -10433,9 +10633,9 @@ class EthersAdapter extends EvmAdapter {
10433
10633
  * ```
10434
10634
  */
10435
10635
  function createAdapterFromPrivateKey(params) {
10436
- // Validate input parameters at runtime
10437
- validateCreateAdapterFromPrivateKeyParams(params);
10438
- const { privateKey, getProvider, capabilities } = params;
10636
+ // Parse and validate input parameters at runtime (normalizes the private key by adding '0x' prefix if missing)
10637
+ const { privateKey } = createAdapterFromPrivateKeyParamsSchema.parse(params);
10638
+ const { getProvider, capabilities } = params;
10439
10639
  // Resolve capabilities with default configuration
10440
10640
  const resolvedCapabilities = createAdapterCapabilities('evm', capabilities);
10441
10641
  // Validate that capabilities are appropriate for private key adapters
@@ -10450,6 +10650,7 @@ function createAdapterFromPrivateKey(params) {
10450
10650
  const getProviderFn = getProvider ?? getDefaultProviderUtil(new Map());
10451
10651
  // Create wallet WITHOUT provider (lazy initialization)
10452
10652
  // The wallet will be connected to a provider when ensureChain is called
10653
+ // Type assertion safe because we normalized the private key in the schema
10453
10654
  const wallet = new ethers.Wallet(privateKey);
10454
10655
  // Create and return the adapter
10455
10656
  return new EthersAdapter({
@@ -10558,13 +10759,13 @@ function createAdapterFromPrivateKey(params) {
10558
10759
  * ```typescript
10559
10760
  * // Cross-chain transfer using a single adapter
10560
10761
  * import { createAdapterFromProvider } from '@circle-fin/adapter-ethers-v6'
10561
- * import { BridgingKit } from '@circle-fin/bridging-kit'
10762
+ * import { BridgeKit } from '@circle-fin/bridge-kit'
10562
10763
  *
10563
10764
  * const adapter = await createAdapterFromProvider({
10564
10765
  * provider: window.ethereum
10565
10766
  * })
10566
10767
  *
10567
- * const kit = new BridgingKit()
10768
+ * const kit = new BridgeKit()
10568
10769
  *
10569
10770
  * // Use the same adapter for both source and destination
10570
10771
  * const result = await kit.bridge({
@@ -10627,8 +10828,12 @@ const createAdapterFromProvider = async (params) => {
10627
10828
  }, resolvedCapabilities);
10628
10829
  };
10629
10830
 
10831
+ exports.JsonRpcProvider = ethers.JsonRpcProvider;
10630
10832
  exports.EthersAdapter = EthersAdapter;
10833
+ exports.buildEIP2612TypedData = buildEIP2612TypedData;
10834
+ exports.computeDefaultDeadline = computeDefaultDeadline;
10631
10835
  exports.createAdapterFromPrivateKey = createAdapterFromPrivateKey;
10632
10836
  exports.createAdapterFromProvider = createAdapterFromProvider;
10837
+ exports.parseSignature = parseSignature;
10633
10838
  exports.validateAdapterCapabilities = validateAdapterCapabilities;
10634
10839
  //# sourceMappingURL=index.cjs.js.map