@anywalletkit/protocol-swap2-core 0.3.0 → 0.3.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.
@@ -240,6 +240,12 @@ function chainType(caip2) {
240
240
  if (["bitcoin", "litecoin", "doge", "bch", "zcash"].includes(ns)) return "utxo";
241
241
  return ns;
242
242
  }
243
+ var SWAP2_CHAIN_ALIASES = Object.freeze({
244
+ "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp": "solana:mainnet",
245
+ "tron:0x2b6653dc": "tron:728126428",
246
+ "bip122:000000000019d6689c085ae165831e93": "bitcoin:mainnet"
247
+ });
248
+ var swap2ChainId = (chain) => SWAP2_CHAIN_ALIASES[chain] ?? chain;
243
249
  function toCaip2(chain, fallback) {
244
250
  if (chain == null || chain === "") return fallback;
245
251
  if (typeof chain === "number") {
@@ -254,7 +260,7 @@ function toCaip2(chain, fallback) {
254
260
  if (!/^[a-z0-9]{3,8}:[-_A-Za-z0-9]{1,32}$/.test(chain)) {
255
261
  throw new Swap2ValidationError("swap2: chain must be a valid CAIP-2 identifier");
256
262
  }
257
- return chain;
263
+ return swap2ChainId(chain);
258
264
  }
259
265
  function toSymbol(caip2, ref) {
260
266
  const byToken = ref.startsWith("0x") || ref.length > 20 ? (0, import_swap2_assets.ccAssetByToken)(caip2, ref) : void 0;
@@ -409,7 +415,7 @@ var BaseSwap2Protocol = class extends import_core.Swap2Protocol {
409
415
  }
410
416
  const expected = this.fromChain;
411
417
  const expectedId = expected.startsWith("eip155:") ? expected.slice("eip155:".length) : expected;
412
- const actualText = typeof actual === "string" ? actual : String(actual);
418
+ const actualText = swap2ChainId(typeof actual === "string" ? actual : String(actual));
413
419
  const actualId = actualText.startsWith("eip155:") ? actualText.slice("eip155:".length) : actualText;
414
420
  if (actualId !== expectedId) {
415
421
  throw new Error(`swap2: account is bound to ${actualText}, but fromChain is ${expected}`);