@circle-fin/bridge-kit 1.3.0 → 1.4.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/index.mjs CHANGED
@@ -480,6 +480,12 @@ const InputError = {
480
480
  name: 'INPUT_INVALID_CHAIN',
481
481
  type: 'INPUT',
482
482
  },
483
+ /** Invalid or unknown token (symbol not found, missing decimals, etc.) */
484
+ INVALID_TOKEN: {
485
+ code: 1006,
486
+ name: 'INPUT_INVALID_TOKEN',
487
+ type: 'INPUT',
488
+ },
483
489
  /** General validation failure for complex validation rules */
484
490
  VALIDATION_FAILED: {
485
491
  code: 1098,
@@ -1262,8 +1268,11 @@ const ArcTestnet = defineChain({
1262
1268
  name: 'Arc Testnet',
1263
1269
  title: 'ArcTestnet',
1264
1270
  nativeCurrency: {
1265
- name: 'Arc',
1266
- symbol: 'Arc',
1271
+ name: 'USDC',
1272
+ symbol: 'USDC',
1273
+ // Arc uses native USDC with 18 decimals for gas payments (EVM standard).
1274
+ // Note: The ERC-20 USDC contract at usdcAddress uses 6 decimals.
1275
+ // See: https://docs.arc.network/arc/references/contract-addresses
1267
1276
  decimals: 18,
1268
1277
  },
1269
1278
  chainId: 5042002,
@@ -4628,7 +4637,7 @@ const parseAmount = (params) => {
4628
4637
  };
4629
4638
 
4630
4639
  var name = "@circle-fin/bridge-kit";
4631
- var version = "1.3.0";
4640
+ var version = "1.4.0";
4632
4641
  var pkg = {
4633
4642
  name: name,
4634
4643
  version: version};
@@ -5905,7 +5914,7 @@ class BridgeKit {
5905
5914
  return formatBridgeResult(await provider.estimate(finalResolvedParams), 'to-human-readable');
5906
5915
  }
5907
5916
  /**
5908
- * Get all chains supported by any provider in the kit.
5917
+ * Get all chains supported by any provider in the kit, with optional filtering.
5909
5918
  *
5910
5919
  * Aggregate and deduplicate the supported chains from all registered providers.
5911
5920
  * This provides a comprehensive list of chains that can be used as either source
@@ -5915,6 +5924,7 @@ class BridgeKit {
5915
5924
  * ensuring each chain appears only once in the result regardless of how many
5916
5925
  * providers support it.
5917
5926
  *
5927
+ * @param options - Optional filtering options to narrow down the returned chains
5918
5928
  * @returns Array of unique chain definitions supported by the registered providers
5919
5929
  *
5920
5930
  * @example
@@ -5922,19 +5932,56 @@ class BridgeKit {
5922
5932
  * import { BridgeKit } from '@circle-fin/bridge-kit'
5923
5933
  *
5924
5934
  * const kit = new BridgeKit()
5925
- * const chains = kit.getSupportedChains()
5935
+ *
5936
+ * // Get all supported chains (no filtering)
5937
+ * const allChains = kit.getSupportedChains()
5938
+ *
5939
+ * // Get only EVM chains
5940
+ * const evmChains = kit.getSupportedChains({ chainType: 'evm' })
5941
+ *
5942
+ * // Get EVM and Solana chains
5943
+ * const evmAndSolana = kit.getSupportedChains({ chainType: ['evm', 'solana'] })
5944
+ *
5945
+ * // Get only mainnet chains
5946
+ * const mainnets = kit.getSupportedChains({ isTestnet: false })
5947
+ *
5948
+ * // Get only EVM mainnet chains
5949
+ * const evmMainnets = kit.getSupportedChains({ chainType: 'evm', isTestnet: false })
5926
5950
  *
5927
5951
  * console.log('Supported chains:')
5928
- * chains.forEach(chain => {
5952
+ * allChains.forEach(chain => {
5929
5953
  * console.log(`- ${chain.name} (${chain.type})`)
5930
5954
  * })
5931
5955
  * ```
5932
5956
  */
5933
- getSupportedChains() {
5957
+ getSupportedChains(options) {
5934
5958
  const supportedChains = this.providers.flatMap((p) => p.supportedChains);
5935
5959
  // Deduplicate chains by using chain identifiers as object keys
5936
5960
  // Later duplicates will override earlier ones, keeping only the last occurrence
5937
- return Object.values(Object.fromEntries(supportedChains.map((chain) => [chain.chain, chain])));
5961
+ let chains = Object.values(Object.fromEntries(supportedChains.map((chain) => [chain.chain, chain])));
5962
+ // Apply chain type filter if provided
5963
+ if (options?.chainType !== undefined) {
5964
+ // Validate at runtime since JS consumers can bypass TypeScript's narrow type.
5965
+ const supportedChainTypes = ['evm', 'solana'];
5966
+ const chainTypeInput = options.chainType;
5967
+ const chainTypeValues = Array.isArray(chainTypeInput)
5968
+ ? chainTypeInput
5969
+ : [chainTypeInput];
5970
+ if (!chainTypeValues.every((chainType) => supportedChainTypes.includes(chainType))) {
5971
+ const listFormatter = new Intl.ListFormat('en', {
5972
+ style: 'long',
5973
+ type: 'conjunction',
5974
+ });
5975
+ throw createValidationFailedError$1('options.chainType', options.chainType, `Supported chain types include: ${listFormatter.format(supportedChainTypes)}`);
5976
+ }
5977
+ const chainTypes = new Set(chainTypeValues);
5978
+ chains = chains.filter((chain) => chainTypes.has(chain.type));
5979
+ }
5980
+ // Apply testnet filter if provided
5981
+ if (options?.isTestnet !== undefined) {
5982
+ chains = chains.filter((chain) => chain.isTestnet === options.isTestnet);
5983
+ }
5984
+ return chains;
5938
5985
  }
5939
5986
  /**
5940
5987
  * Validate that source and destination chains are on the same network type.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@circle-fin/bridge-kit",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "SDK for seamless cross-chain stablecoin bridging",
5
5
  "keywords": [
6
6
  "circle",
@@ -22,7 +22,7 @@
22
22
  "types": "./index.d.ts",
23
23
  "dependencies": {
24
24
  "zod": "3.25.67",
25
- "@circle-fin/provider-cctp-v2": "^1.1.0",
25
+ "@circle-fin/provider-cctp-v2": "^1.2.0",
26
26
  "abitype": "^1.1.0",
27
27
  "@solana/web3.js": "^1.98.4",
28
28
  "@ethersproject/address": "^5.8.0",