@gardenfi/orderbook 2.5.3-beta.7 → 2.5.3-beta.8

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/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./index2.cjs"),a=require("./index3.cjs"),e=require("./index4.cjs"),s=require("./index5.cjs"),o=require("./index6.cjs"),t=require("./index7.cjs"),c=require("./index8.cjs"),i=require("./index9.cjs"),l=require("./index10.cjs"),r=require("./index11.cjs");exports.Orderbook=n.Orderbook;exports.BlockchainType=a.BlockchainType;exports.Assets=e.Assets;exports.Chains=e.Chains;exports.Config=e.Config;exports.NATIVE_TOKENS=e.NATIVE_TOKENS;exports.OrderLifecycle=e.OrderLifecycle;exports.OrderStatus=e.OrderStatus;exports.getBlockchainType=e.getBlockchainType;exports.is=e.is;exports.isBitcoin=e.isBitcoin;exports.isEVM=e.isEVM;exports.isEvmNativeToken=e.isEvmNativeToken;exports.isMainnet=e.isMainnet;exports.isNativeToken=e.isNativeToken;exports.isSolana=e.isSolana;exports.isSolanaNativeToken=e.isSolanaNativeToken;exports.isStarknet=e.isStarknet;exports.isSui=e.isSui;exports.isSuiNativeToken=e.isSuiNativeToken;exports.ArbitrumLocalnet=s.ArbitrumLocalnet;exports.ETHStarknetLocalnetAsset=s.ETHStarknetLocalnetAsset;exports.EthereumLocalnet=s.EthereumLocalnet;exports.SOLSolanaLocalnetAsset=s.SOLSolanaLocalnetAsset;exports.STRKStarknetLocalnetAsset=s.STRKStarknetLocalnetAsset;exports.StarknetLocalnet=s.StarknetLocalnet;exports.WBTCArbitrumLocalnetAsset=s.WBTCArbitrumLocalnetAsset;exports.WBTCEthereumLocalnetAsset=s.WBTCEthereumLocalnetAsset;exports.bitcoinRegtestAsset=s.bitcoinRegtestAsset;exports.buildAssetsWithChain=o.buildAssetsWithChain;exports.ConstructUrl=t.ConstructUrl;exports.discriminateOrderResponse=t.discriminateOrderResponse;exports.getOrderResponseType=t.getOrderResponseType;exports.isBitcoinOrderResponse=t.isBitcoinOrderResponse;exports.isEvmOrderResponse=t.isEvmOrderResponse;exports.isOrder=t.isOrder;exports.isSolanaOrderResponse=t.isSolanaOrderResponse;exports.isStarknetOrderResponse=t.isStarknetOrderResponse;exports.isSuiOrderResponse=t.isSuiOrderResponse;exports.ChainAsset=c.ChainAsset;exports.OrderAction=i.OrderAction;exports.ParseOrderStatus=i.ParseOrderStatus;exports.isCompleted=i.isCompleted;exports.isDeadlinePassed=i.isDeadlinePassed;exports.parseAction=i.parseAction;exports.AssetManager=l.AssetManager;exports.RouteValidator=r.RouteValidator;exports.buildRouteMatrix=r.buildRouteMatrix;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index2.cjs"),n=require("./index3.cjs"),e=require("./index4.cjs"),s=require("./index5.cjs"),a=require("./index6.cjs"),t=require("./index7.cjs"),o=require("./index8.cjs"),i=require("./index9.cjs"),c=require("./index10.cjs"),l=require("./index11.cjs");exports.Orderbook=r.Orderbook;exports.BlockchainType=n.BlockchainType;exports.Assets=e.Assets;exports.Chains=e.Chains;exports.Config=e.Config;exports.NATIVE_TOKENS=e.NATIVE_TOKENS;exports.OrderLifecycle=e.OrderLifecycle;exports.OrderStatus=e.OrderStatus;exports.getBlockchainType=e.getBlockchainType;exports.is=e.is;exports.isBitcoin=e.isBitcoin;exports.isEVM=e.isEVM;exports.isEvmNativeToken=e.isEvmNativeToken;exports.isMainnet=e.isMainnet;exports.isNativeToken=e.isNativeToken;exports.isSolana=e.isSolana;exports.isSolanaNativeToken=e.isSolanaNativeToken;exports.isStarknet=e.isStarknet;exports.isSui=e.isSui;exports.isSuiNativeToken=e.isSuiNativeToken;exports.ArbitrumLocalnet=s.ArbitrumLocalnet;exports.ETHStarknetLocalnetAsset=s.ETHStarknetLocalnetAsset;exports.EthereumLocalnet=s.EthereumLocalnet;exports.SOLSolanaLocalnetAsset=s.SOLSolanaLocalnetAsset;exports.STRKStarknetLocalnetAsset=s.STRKStarknetLocalnetAsset;exports.StarknetLocalnet=s.StarknetLocalnet;exports.WBTCArbitrumLocalnetAsset=s.WBTCArbitrumLocalnetAsset;exports.WBTCEthereumLocalnetAsset=s.WBTCEthereumLocalnetAsset;exports.bitcoinRegtestAsset=s.bitcoinRegtestAsset;exports.buildAssetsWithChain=a.buildAssetsWithChain;exports.ConstructUrl=t.ConstructUrl;exports.discriminateOrderResponse=t.discriminateOrderResponse;exports.getOrderResponseType=t.getOrderResponseType;exports.isBitcoinOrderResponse=t.isBitcoinOrderResponse;exports.isEvmOrderResponse=t.isEvmOrderResponse;exports.isOrder=t.isOrder;exports.isSolanaOrderResponse=t.isSolanaOrderResponse;exports.isStarknetOrderResponse=t.isStarknetOrderResponse;exports.isSuiOrderResponse=t.isSuiOrderResponse;exports.ChainAsset=o.ChainAsset;exports.OrderAction=i.OrderAction;exports.ParseOrderStatus=i.ParseOrderStatus;exports.isCompleted=i.isCompleted;exports.isDeadlinePassed=i.isDeadlinePassed;exports.parseAction=i.parseAction;exports.AssetManager=c.AssetManager;exports.RouteValidator=l.RouteValidator;
package/dist/index.js CHANGED
@@ -1,13 +1,13 @@
1
- import { Orderbook as r } from "./index2.js";
1
+ import { Orderbook as s } from "./index2.js";
2
2
  import { BlockchainType as o } from "./index3.js";
3
- import { Assets as n, Chains as a, Config as p, NATIVE_TOKENS as c, OrderLifecycle as l, OrderStatus as d, getBlockchainType as m, is as S, isBitcoin as A, isEVM as O, isEvmNativeToken as u, isMainnet as T, isNativeToken as f, isSolana as k, isSolanaNativeToken as x, isStarknet as R, isSui as L, isSuiNativeToken as h } from "./index4.js";
4
- import { ArbitrumLocalnet as E, ETHStarknetLocalnetAsset as b, EthereumLocalnet as v, SOLSolanaLocalnetAsset as B, STRKStarknetLocalnetAsset as N, StarknetLocalnet as g, WBTCArbitrumLocalnetAsset as y, WBTCEthereumLocalnetAsset as M, bitcoinRegtestAsset as V } from "./index5.js";
3
+ import { Assets as n, Chains as a, Config as p, NATIVE_TOKENS as c, OrderLifecycle as l, OrderStatus as d, getBlockchainType as m, is as S, isBitcoin as A, isEVM as O, isEvmNativeToken as T, isMainnet as f, isNativeToken as k, isSolana as u, isSolanaNativeToken as x, isStarknet as L, isSui as R, isSuiNativeToken as h } from "./index4.js";
4
+ import { ArbitrumLocalnet as E, ETHStarknetLocalnetAsset as v, EthereumLocalnet as B, SOLSolanaLocalnetAsset as N, STRKStarknetLocalnetAsset as b, StarknetLocalnet as g, WBTCArbitrumLocalnetAsset as y, WBTCEthereumLocalnetAsset as M, bitcoinRegtestAsset as V } from "./index5.js";
5
5
  import { buildAssetsWithChain as K } from "./index6.js";
6
6
  import { ConstructUrl as D, discriminateOrderResponse as H, getOrderResponseType as I, isBitcoinOrderResponse as U, isEvmOrderResponse as _, isOrder as j, isSolanaOrderResponse as q, isStarknetOrderResponse as w, isSuiOrderResponse as z } from "./index7.js";
7
7
  import { ChainAsset as G } from "./index8.js";
8
8
  import { OrderAction as Q, ParseOrderStatus as X, isCompleted as Y, isDeadlinePassed as Z, parseAction as $ } from "./index9.js";
9
9
  import { AssetManager as te } from "./index10.js";
10
- import { RouteValidator as se, buildRouteMatrix as oe } from "./index11.js";
10
+ import { RouteValidator as re } from "./index11.js";
11
11
  export {
12
12
  E as ArbitrumLocalnet,
13
13
  te as AssetManager,
@@ -17,23 +17,22 @@ export {
17
17
  a as Chains,
18
18
  p as Config,
19
19
  D as ConstructUrl,
20
- b as ETHStarknetLocalnetAsset,
21
- v as EthereumLocalnet,
20
+ v as ETHStarknetLocalnetAsset,
21
+ B as EthereumLocalnet,
22
22
  c as NATIVE_TOKENS,
23
23
  Q as OrderAction,
24
24
  l as OrderLifecycle,
25
25
  d as OrderStatus,
26
- r as Orderbook,
26
+ s as Orderbook,
27
27
  X as ParseOrderStatus,
28
- se as RouteValidator,
29
- B as SOLSolanaLocalnetAsset,
30
- N as STRKStarknetLocalnetAsset,
28
+ re as RouteValidator,
29
+ N as SOLSolanaLocalnetAsset,
30
+ b as STRKStarknetLocalnetAsset,
31
31
  g as StarknetLocalnet,
32
32
  y as WBTCArbitrumLocalnetAsset,
33
33
  M as WBTCEthereumLocalnetAsset,
34
34
  V as bitcoinRegtestAsset,
35
35
  K as buildAssetsWithChain,
36
- oe as buildRouteMatrix,
37
36
  H as discriminateOrderResponse,
38
37
  m as getBlockchainType,
39
38
  I as getOrderResponseType,
@@ -43,17 +42,17 @@ export {
43
42
  Y as isCompleted,
44
43
  Z as isDeadlinePassed,
45
44
  O as isEVM,
46
- u as isEvmNativeToken,
45
+ T as isEvmNativeToken,
47
46
  _ as isEvmOrderResponse,
48
- T as isMainnet,
49
- f as isNativeToken,
47
+ f as isMainnet,
48
+ k as isNativeToken,
50
49
  j as isOrder,
51
- k as isSolana,
50
+ u as isSolana,
52
51
  x as isSolanaNativeToken,
53
52
  q as isSolanaOrderResponse,
54
- R as isStarknet,
53
+ L as isStarknet,
55
54
  w as isStarknetOrderResponse,
56
- L as isSui,
55
+ R as isSui,
57
56
  h as isSuiNativeToken,
58
57
  z as isSuiOrderResponse,
59
58
  $ as parseAction
package/dist/index10.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("@gardenfi/utils"),p=require("./index11.cjs"),w=require("./index4.cjs"),n=require("./index8.cjs"),y=Object.keys(w.Config);class b{constructor(s,t){this._allChains=null,this._allAssets=null,this._assets=null,this._chains=null,this._routeValidator=null,this._routeMatrix=null,this._isLoading=!1,this._error=null,this.url=new C.Url(s),this.apiKey=t}get allChains(){return this._allChains}get allAssets(){return this._allAssets}get assets(){return this._assets}get chains(){return this._chains}get routeValidator(){return this._routeValidator}get routeMatrix(){return this._routeMatrix}get isLoading(){return this._isLoading}get error(){return this._error}async initialize(){await Promise.all([this.fetchAndSetAssetsAndChains()])}async fetchAndSetAssetsAndChains(){try{this._isLoading=!0,this._error=null,await this.initializeRouteValidator();const s=this.url.endpoint("/v2/assets"),t=await C.Fetcher.get(s);if(t.error)throw new Error(t.error);if(!t.result)throw new Error("Failed to fetch chains data");const{allChains:e,allAssets:a,assets:o,chains:h}=this.processApiData(t.result);this._allChains=e,this._allAssets=a,this._assets=o,this._chains=h,this.buildRouteMatrix(),console.info("AssetManager initialized successfully")}catch(s){throw console.error("Failed to fetch assets data ❌",s),this._error="Failed to fetch assets data",s}finally{this._isLoading=!1}}isRouteValid(s,t){if(!this._routeValidator||!s||!t||!s.id||!t.id)return console.warn("Missing routeValidator, from, or to. Returning true."),!0;try{const e=n.ChainAsset.from(s.id),a=n.ChainAsset.from(t.id);return this._routeValidator.isValidRoute(e,a)}catch(e){return console.error("Error in isRouteValid:",e),!0}}getValidDestinations(s){if(!this._routeMatrix||!this._assets||!s.id)return Object.values(this._assets||{});try{const t=this._routeMatrix[s.id.toString()];return t?t.map(e=>{const a=e.toString();return Object.values(this._assets).find(o=>n.ChainAsset.from(o).toString()===a)}).filter(Boolean):Object.values(this._assets)}catch(t){return console.error("Error in getValidDestinations:",t),Object.values(this._assets||{})}}getAsset(s){if(!this._assets)return;const t=n.ChainAsset.from(s).toString();return this._assets[t]}getAssetsByChain(s){return this._assets?Object.values(this._assets).filter(t=>t.chain===s):[]}searchAssets(s){if(!this._assets)return[];const t=s.toLowerCase();return Object.values(this._assets).filter(e=>e.symbol.toLowerCase().includes(t)||e.name.toLowerCase().includes(t))}getChain(s){if(this._chains)return this._chains[s]}async initializeRouteValidator(){this._routeValidator=new p.RouteValidator(this.url.toString(),this.apiKey),await this._routeValidator.loadPolicy()}buildRouteMatrix(){if(!this._allAssets||!this._routeValidator)return;const s=Object.values(this._allAssets).map(t=>{if(!t.id)return null;try{return n.ChainAsset.from(t.id)}catch{return null}}).filter(t=>t!==null);this._routeMatrix=p.buildRouteMatrix(s,this._routeValidator)}processApiData(s){var h,u,c,d;const t={},e={},a={},o={};for(const r of s){const l=this.parseChainIdentifier(r.chain);if(!l||!y.includes(l))continue;const _={name:this.formatChainName(r.chain),chain:l,id:r.id,explorer_url:r.explorer_url,icon:r.icon,confirmation_target:r.confirmation_target,source_timelock:r.source_timelock,destination_timelock:r.destination_timelock,supported_htlc_schemas:r.supported_htlc_schemas,supported_token_schemas:r.supported_token_schemas};t[l]=_;let f=0;for(const i of r.assets){const m=((h=i.htlc)==null?void 0:h.address)||"",V=((u=i.token)==null?void 0:u.address)||m,A=n.ChainAsset.from(i.id).toString(),g={id:n.ChainAsset.from(i.id),chain:l,htlc:{address:m,schema:((c=i.htlc)==null?void 0:c.schema)||null},token:{address:V,schema:((d=i.token)==null?void 0:d.schema)||null},decimals:i.decimals,name:i.name,symbol:n.ChainAsset.from(i.id).symbol.toUpperCase(),icon:i.icon,price:i.price,min_amount:i.min_amount,max_amount:i.max_amount};e[A]=g,a[A]=g,f++}f>0&&(o[l]=_)}return{allChains:t,allAssets:e,assets:a,chains:o}}parseChainIdentifier(s){return y.includes(s)?s:null}formatChainName(s){return s.split("_").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}async refresh(){await this.initialize()}clear(){this._allChains=null,this._allAssets=null,this._assets=null,this._chains=null,this._routeValidator=null,this._routeMatrix=null,this._error=null}}exports.AssetManager=b;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("@gardenfi/utils"),A=require("./index11.cjs"),g=require("./index4.cjs"),n=require("./index8.cjs"),C=require("./index12.cjs"),u=Object.keys(g.Config);class m{constructor(t,s){this.assets=null,this.chains=null,this.routeMatrix=null,this.isLoading=!1,this.error=null,this.url=new r.Url(t),typeof s=="string"?this.auth=new r.ApiKey(s):this.auth=s,this.routeValidator=new A.RouteValidator(this.url.toString(),this.auth)}async initialize(){await this.fetchAndSetAssetsAndChains(),await this.routeValidator.loadPolicy()}async fetchAndSetAssetsAndChains(){try{this.isLoading=!0,this.error=null;const t=await this.auth.getAuthHeaders();if(!t.ok)return r.Err("Failed to get auth headers");const s=this.url.endpoint("/v2/chains"),e=await r.Fetcher.get(s,{headers:{...t.val}});if(!e.result)return r.Err(`Failed to fetch chains data: ${e.error}`);const{assets:a,chains:i}=this.processApiData(e.result);return this.assets=a,this.chains=i,await this.buildRouteMatrix(),r.Ok("AssetManager initialized successfully")}catch(t){return r.Err(`Failed to fetch assets data: ${t}`)}finally{this.isLoading=!1}}async isRouteValid(t,s){return await this.routeValidator.isValidRoute(n.ChainAsset.from(t.id),n.ChainAsset.from(s.id))}getValidDestinations(t){if(!this.routeMatrix||!this.assets||!t.id)return console.warn("Missing routeMatrix, assets, or asset. Returning all assets."),[];const s=this.routeMatrix[t.id.toString().toLowerCase()];return s?s.map(e=>{const a=e.toString();return Object.values(this.assets).find(i=>n.ChainAsset.from(i).toString()===a)}).filter(Boolean):[]}getAsset(t){if(!this.assets)return;const s=n.ChainAsset.from(t).toString();return this.assets[s]}getAssetsByChain(t){return this.assets?Object.values(this.assets).filter(s=>s.chain===t):[]}searchAssets(t){if(!this.assets)return[];const s=t.toLowerCase();return Object.values(this.assets).filter(e=>e.symbol.toLowerCase().includes(s)||e.name.toLowerCase().includes(s))}getChain(t){if(this.chains)return this.chains[t]}async buildRouteMatrix(){if(!this.assets||!this.routeValidator)return;const t=Object.values(this.assets).map(s=>{if(!s.id)return null;try{return n.ChainAsset.from(s.id)}catch{return null}}).filter(s=>s!==null);this.routeMatrix=await this.routeValidator.buildRouteMatrix(t)}processApiData(t){const s={},e={};for(const a of t){const i=this.parseChainIdentifier(a.chain);if(!i||!u.includes(i))continue;const h={...a,name:this.formatChainName(a.chain),chain:i};for(const o of a.assets){const l=n.ChainAsset.from(o.id).toString(),{name:c,symbol:d}=C.parseAssetNameSymbol(o.name,o.id),f={...o,id:n.ChainAsset.from(o.id),chain:i,name:c,symbol:d};s[l]=f,e[i]||(e[i]=h)}}return{assets:s,chains:e}}parseChainIdentifier(t){return u.includes(t)?t:null}formatChainName(t){return t.split("_").map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join(" ")}async refresh(){await this.initialize()}}exports.AssetManager=m;
package/dist/index10.js CHANGED
@@ -1,38 +1,12 @@
1
- import { Url as y, Fetcher as V } from "@gardenfi/utils";
2
- import { RouteValidator as w, buildRouteMatrix as x } from "./index11.js";
3
- import { Config as b } from "./index4.js";
4
- import { ChainAsset as n } from "./index8.js";
5
- const g = Object.keys(b);
6
- class j {
7
- constructor(s, t) {
8
- this._allChains = null, this._allAssets = null, this._assets = null, this._chains = null, this._routeValidator = null, this._routeMatrix = null, this._isLoading = !1, this._error = null, this.url = new y(s), this.apiKey = t;
9
- }
10
- // ============================================
11
- // Getters
12
- // ============================================
13
- get allChains() {
14
- return this._allChains;
15
- }
16
- get allAssets() {
17
- return this._allAssets;
18
- }
19
- get assets() {
20
- return this._assets;
21
- }
22
- get chains() {
23
- return this._chains;
24
- }
25
- get routeValidator() {
26
- return this._routeValidator;
27
- }
28
- get routeMatrix() {
29
- return this._routeMatrix;
30
- }
31
- get isLoading() {
32
- return this._isLoading;
33
- }
34
- get error() {
35
- return this._error;
1
+ import { Url as m, ApiKey as A, Err as o, Fetcher as g, Ok as p } from "@gardenfi/utils";
2
+ import { RouteValidator as C } from "./index11.js";
3
+ import { Config as y } from "./index4.js";
4
+ import { ChainAsset as r } from "./index8.js";
5
+ import { parseAssetNameSymbol as w } from "./index12.js";
6
+ const u = Object.keys(y);
7
+ class R {
8
+ constructor(t, s) {
9
+ this.assets = null, this.chains = null, this.routeMatrix = null, this.isLoading = !1, this.error = null, this.url = new m(t), typeof s == "string" ? this.auth = new A(s) : this.auth = s, this.routeValidator = new C(this.url.toString(), this.auth);
36
10
  }
37
11
  // ============================================
38
12
  // Initialization Methods
@@ -41,27 +15,28 @@ class j {
41
15
  * Initialize the AssetManager by fetching all required data
42
16
  */
43
17
  async initialize() {
44
- await Promise.all([this.fetchAndSetAssetsAndChains()]);
18
+ await this.fetchAndSetAssetsAndChains(), await this.routeValidator.loadPolicy();
45
19
  }
46
20
  /**
47
21
  * Fetch and cache asset and chain data from API
48
22
  */
49
23
  async fetchAndSetAssetsAndChains() {
50
24
  try {
51
- this._isLoading = !0, this._error = null, await this.initializeRouteValidator();
52
- const s = this.url.endpoint("/v2/assets"), t = await V.get(s);
53
- if (t.error)
54
- throw new Error(t.error);
55
- if (!t.result)
56
- throw new Error("Failed to fetch chains data");
57
- const { allChains: e, allAssets: a, assets: o, chains: h } = this.processApiData(
58
- t.result
59
- );
60
- this._allChains = e, this._allAssets = a, this._assets = o, this._chains = h, this.buildRouteMatrix(), console.info("AssetManager initialized successfully ✅");
61
- } catch (s) {
62
- throw console.error("Failed to fetch assets data ❌", s), this._error = "Failed to fetch assets data", s;
25
+ this.isLoading = !0, this.error = null;
26
+ const t = await this.auth.getAuthHeaders();
27
+ if (!t.ok) return o("Failed to get auth headers");
28
+ const s = this.url.endpoint("/v2/chains"), i = await g.get(s, {
29
+ headers: {
30
+ ...t.val
31
+ }
32
+ });
33
+ if (!i.result) return o(`Failed to fetch chains data: ${i.error}`);
34
+ const { assets: a, chains: e } = this.processApiData(i.result);
35
+ return this.assets = a, this.chains = e, await this.buildRouteMatrix(), p("AssetManager initialized successfully");
36
+ } catch (t) {
37
+ return o(`Failed to fetch assets data: ${t}`);
63
38
  } finally {
64
- this._isLoading = !1;
39
+ this.isLoading = !1;
65
40
  }
66
41
  }
67
42
  // ============================================
@@ -70,31 +45,25 @@ class j {
70
45
  /**
71
46
  * Check if a swap route from one asset to another is valid
72
47
  */
73
- isRouteValid(s, t) {
74
- if (!this._routeValidator || !s || !t || !s.id || !t.id)
75
- return console.warn("Missing routeValidator, from, or to. Returning true."), !0;
76
- try {
77
- const e = n.from(s.id), a = n.from(t.id);
78
- return this._routeValidator.isValidRoute(e, a);
79
- } catch (e) {
80
- return console.error("Error in isRouteValid:", e), !0;
81
- }
48
+ async isRouteValid(t, s) {
49
+ return await this.routeValidator.isValidRoute(
50
+ r.from(t.id),
51
+ r.from(s.id)
52
+ );
82
53
  }
83
54
  /**
84
55
  * Get all valid destination assets for a given source asset
85
56
  */
86
- getValidDestinations(s) {
87
- if (!this._routeMatrix || !this._assets || !s.id)
88
- return Object.values(this._assets || {});
89
- try {
90
- const t = this._routeMatrix[s.id.toString()];
91
- return t ? t.map((e) => {
92
- const a = e.toString();
93
- return Object.values(this._assets).find((o) => n.from(o).toString() === a);
94
- }).filter(Boolean) : Object.values(this._assets);
95
- } catch (t) {
96
- return console.error("Error in getValidDestinations:", t), Object.values(this._assets || {});
97
- }
57
+ getValidDestinations(t) {
58
+ if (!this.routeMatrix || !this.assets || !t.id)
59
+ return console.warn(
60
+ "Missing routeMatrix, assets, or asset. Returning all assets."
61
+ ), [];
62
+ const s = this.routeMatrix[t.id.toString().toLowerCase()];
63
+ return s ? s.map((i) => {
64
+ const a = i.toString();
65
+ return Object.values(this.assets).find((e) => r.from(e).toString() === a);
66
+ }).filter(Boolean) : [];
98
67
  }
99
68
  // ============================================
100
69
  // Asset Query Methods
@@ -102,120 +71,95 @@ class j {
102
71
  /**
103
72
  * Get asset by chain and token address
104
73
  */
105
- getAsset(s) {
106
- if (!this._assets) return;
107
- const t = n.from(s).toString();
108
- return this._assets[t];
74
+ getAsset(t) {
75
+ if (!this.assets) return;
76
+ const s = r.from(t).toString();
77
+ return this.assets[s];
109
78
  }
110
79
  /**
111
80
  * Get all assets for a specific chain
112
81
  */
113
- getAssetsByChain(s) {
114
- return this._assets ? Object.values(this._assets).filter((t) => t.chain === s) : [];
82
+ getAssetsByChain(t) {
83
+ return this.assets ? Object.values(this.assets).filter((s) => s.chain === t) : [];
115
84
  }
116
85
  /**
117
86
  * Search assets by symbol or name
118
87
  */
119
- searchAssets(s) {
120
- if (!this._assets) return [];
121
- const t = s.toLowerCase();
122
- return Object.values(this._assets).filter(
123
- (e) => e.symbol.toLowerCase().includes(t) || e.name.toLowerCase().includes(t)
88
+ searchAssets(t) {
89
+ if (!this.assets) return [];
90
+ const s = t.toLowerCase();
91
+ return Object.values(this.assets).filter(
92
+ (i) => i.symbol.toLowerCase().includes(s) || i.name.toLowerCase().includes(s)
124
93
  );
125
94
  }
126
95
  /**
127
96
  * Get chain data by chain identifier
128
97
  */
129
- getChain(s) {
130
- if (this._chains)
131
- return this._chains[s];
98
+ getChain(t) {
99
+ if (this.chains)
100
+ return this.chains[t];
132
101
  }
133
102
  // ============================================
134
103
  // Private Helper Methods
135
104
  // ============================================
136
- /**
137
- * Initialize the route validator
138
- */
139
- async initializeRouteValidator() {
140
- this._routeValidator = new w(this.url.toString(), this.apiKey), await this._routeValidator.loadPolicy();
141
- }
142
105
  /**
143
106
  * Build route matrix for fast O(1) route lookups
144
107
  */
145
- buildRouteMatrix() {
146
- if (!this._allAssets || !this._routeValidator)
147
- return;
148
- const s = Object.values(this._allAssets).map((t) => {
149
- if (!t.id) return null;
108
+ async buildRouteMatrix() {
109
+ if (!this.assets || !this.routeValidator) return;
110
+ const t = Object.values(this.assets).map((s) => {
111
+ if (!s.id) return null;
150
112
  try {
151
- return n.from(t.id);
113
+ return r.from(s.id);
152
114
  } catch {
153
115
  return null;
154
116
  }
155
- }).filter((t) => t !== null);
156
- this._routeMatrix = x(s, this._routeValidator);
117
+ }).filter((s) => s !== null);
118
+ this.routeMatrix = await this.routeValidator.buildRouteMatrix(
119
+ t
120
+ );
157
121
  }
158
122
  /**
159
123
  * Process raw API data into structured format
160
124
  */
161
- processApiData(s) {
162
- var h, u, c, d;
163
- const t = {}, e = {}, a = {}, o = {};
164
- for (const r of s) {
165
- const l = this.parseChainIdentifier(r.chain);
166
- if (!l || !g.includes(l))
125
+ processApiData(t) {
126
+ const s = {}, i = {};
127
+ for (const a of t) {
128
+ const e = this.parseChainIdentifier(a.chain);
129
+ if (!e || !u.includes(e))
167
130
  continue;
168
- const _ = {
169
- name: this.formatChainName(r.chain),
170
- chain: l,
171
- id: r.id,
172
- explorer_url: r.explorer_url,
173
- icon: r.icon,
174
- confirmation_target: r.confirmation_target,
175
- source_timelock: r.source_timelock,
176
- destination_timelock: r.destination_timelock,
177
- supported_htlc_schemas: r.supported_htlc_schemas,
178
- supported_token_schemas: r.supported_token_schemas
131
+ const h = {
132
+ ...a,
133
+ name: this.formatChainName(a.chain),
134
+ chain: e
179
135
  };
180
- t[l] = _;
181
- let m = 0;
182
- for (const i of r.assets) {
183
- const f = ((h = i.htlc) == null ? void 0 : h.address) || "", C = ((u = i.token) == null ? void 0 : u.address) || f, p = n.from(i.id).toString(), A = {
184
- id: n.from(i.id),
185
- chain: l,
186
- htlc: {
187
- address: f,
188
- schema: ((c = i.htlc) == null ? void 0 : c.schema) || null
189
- },
190
- token: {
191
- address: C,
192
- schema: ((d = i.token) == null ? void 0 : d.schema) || null
193
- },
194
- decimals: i.decimals,
195
- name: i.name,
196
- symbol: n.from(i.id).symbol.toUpperCase(),
197
- icon: i.icon,
198
- price: i.price,
199
- min_amount: i.min_amount,
200
- max_amount: i.max_amount
136
+ for (const n of a.assets) {
137
+ const l = r.from(n.id).toString(), { name: c, symbol: d } = w(
138
+ n.name,
139
+ n.id
140
+ ), f = {
141
+ ...n,
142
+ id: r.from(n.id),
143
+ chain: e,
144
+ name: c,
145
+ symbol: d
201
146
  };
202
- e[p] = A, a[p] = A, m++;
147
+ s[l] = f, i[e] || (i[e] = h);
203
148
  }
204
- m > 0 && (o[l] = _);
205
149
  }
206
- return { allChains: t, allAssets: e, assets: a, chains: o };
150
+ return { assets: s, chains: i };
207
151
  }
208
152
  /**
209
153
  * Parse chain identifier from string
210
154
  */
211
- parseChainIdentifier(s) {
212
- return g.includes(s) ? s : null;
155
+ parseChainIdentifier(t) {
156
+ return u.includes(t) ? t : null;
213
157
  }
214
158
  /**
215
159
  * Format chain name for display
216
160
  */
217
- formatChainName(s) {
218
- return s.split("_").map((t) => t.charAt(0).toUpperCase() + t.slice(1)).join(" ");
161
+ formatChainName(t) {
162
+ return t.split("_").map((s) => s.charAt(0).toUpperCase() + s.slice(1)).join(" ");
219
163
  }
220
164
  // ============================================
221
165
  // Data Refresh Methods
@@ -226,13 +170,7 @@ class j {
226
170
  async refresh() {
227
171
  await this.initialize();
228
172
  }
229
- /**
230
- * Clear all cached data
231
- */
232
- clear() {
233
- this._allChains = null, this._allAssets = null, this._assets = null, this._chains = null, this._routeValidator = null, this._routeMatrix = null, this._error = null;
234
- }
235
173
  }
236
174
  export {
237
- j as AssetManager
175
+ R as AssetManager
238
176
  };
package/dist/index11.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class u{constructor(t,r){this.apiBaseUrl=t,this.apiKey=r,this.policy=null}async loadPolicy(){try{const r=await(await fetch(`${this.apiBaseUrl}/v2/policy`,{headers:{"garden-app-id":this.apiKey,accept:"application/json"}})).json();if(r.status!=="Ok")throw new Error(`API Error: ${r.error}`);this.policy=r.result}catch(t){throw new Error(`Failed to load policy: ${t}`)}}isValidRoute(t,r){const e=this.ensurePolicyLoaded();if(t===r)return!1;const i=this.findIsolationGroup(t),o=this.findIsolationGroup(r);return i!==null||o!==null?i===o:this.matchesPatternList(t,r,e.whitelist_overrides)?!0:this.matchesPatternList(t,r,e.blacklist_pairs)?!1:e.default==="open"}isAssetInIsolationGroup(t){return this.ensurePolicyLoaded(),this.findIsolationGroup(t)!==null}getValidDestinations(t,r){this.ensurePolicyLoaded();const e=this.findIsolationGroup(t);return e!==null?r.filter(i=>i!==t&&this.findIsolationGroup(i)===e):r.filter(i=>t===i||this.findIsolationGroup(i)!==null?!1:this.isValidRoute(t,i))}getAllValidRoutes(t){return t.flatMap(r=>t.filter(e=>this.isValidRoute(r,e)).map(e=>({from:r,to:e})))}ensurePolicyLoaded(){if(!this.policy)throw new Error("Policy not loaded. Call loadPolicy() first.");return this.policy}findIsolationGroup(t){if(!this.policy)return null;for(let r=0;r<this.policy.isolation_groups.length;r++)if(this.matchesIsolationGroup(t,this.policy.isolation_groups[r]))return r;return null}matchesIsolationGroup(t,r){return this.parsePattern(r).some(i=>this.matchesAssetPattern(t,i))}matchesPatternList(t,r,e){return e.some(i=>this.matchesRoutePattern(t,r,i))}matchesRoutePattern(t,r,e){const i=e.includes("<->")?"<->":"->",[o,a]=e.split(i).map(s=>s.trim()),l=this.matchesAssetPattern(t,o)&&this.matchesAssetPattern(r,a);if(i==="<->"){const s=this.matchesAssetPattern(t,a)&&this.matchesAssetPattern(r,o);return l||s}return l}parsePattern(t){const r=t.includes("<->")?"<->":"->";return t.split(r).map(e=>e.trim())}matchesAssetPattern(t,r){const e=t.toString().toLowerCase(),i=r.toLowerCase();return i==="*"?!0:i.endsWith(":*")?e.startsWith(i.slice(0,-2)+":"):i.startsWith("*:")?e.endsWith(":"+i.slice(2)):e===i}}function c(n,t){return Object.fromEntries(n.map(r=>[r.toString(),t.getValidDestinations(r,n)]))}exports.RouteValidator=u;exports.buildRouteMatrix=c;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@gardenfi/utils"),h=require("node-cache"),a=class a{constructor(e,t){this.policy=new h({stdTTL:36e3,checkperiod:3600}),typeof t=="string"?this.auth=new o.ApiKey(t):this.auth=t,typeof e=="string"?this.apiBaseUrl=new o.Url(e):this.apiBaseUrl=e}getPolicy(){return this.policy.get(a.POLICY_CACHE_KEY)}setPolicy(e){const t=this.getPolicy(),s={default:e.default||(t==null?void 0:t.default)||"open",isolation_groups:[...new Set([...(t==null?void 0:t.isolation_groups)||[],...e.isolation_groups])],blacklist_pairs:[...new Set([...(t==null?void 0:t.blacklist_pairs)||[],...e.blacklist_pairs])],whitelist_overrides:[...new Set([...(t==null?void 0:t.whitelist_overrides)||[],...e.whitelist_overrides])]};return this.policy.set(a.POLICY_CACHE_KEY,s),s}async loadPolicy(){const e=this.getPolicy();if(e)return o.Ok(e);try{const t=await this.auth.getAuthHeaders();if(!t.ok)return o.Err(`Failed to get auth headers: ${t.error}`);const s=await o.Fetcher.get(this.apiBaseUrl.endpoint("v2/policy"),{headers:{"Content-Type":"application/json",...t.val}});return s.result?o.Ok(this.setPolicy(s.result)):o.Err(`API Error: ${s.error}`)}catch(t){return o.Err(`Failed to load policy: ${t}`)}}async isValidRoute(e,t){const s=await this.loadPolicy();if(!s.ok||e.toString()===t.toString())return!1;const{sortedIsolationRules:r,sortedBlacklistRules:i,sortedWhitelistRules:n}=this.preprocessRules(s.val);if(this.matchesRuleList(e,t,n))return!0;const l=this.findMatchingRule(e,r,"from");if(l&&!this.matchesRuleDestination(t,l))return!1;const u=this.findMatchingRule(t,r,"to");return u&&!this.matchesRuleSource(e,u)||this.matchesRuleList(e,t,i)?!1:s.val.default==="open"}async isAssetInIsolationGroup(e){const t=await this.loadPolicy();if(!t.ok)return!1;const{sortedIsolationRules:s}=this.preprocessRules(t.val);return s.some(r=>this.matchesAssetPattern(e,r.fromPattern)||this.matchesAssetPattern(e,r.toPattern))}async getValidDestinations(e,t){if(!(await this.loadPolicy()).ok)return[];const r=[];for(const i of t)await this.isValidRoute(e,i)&&r.push(i);return r}async getAllValidRoutes(e){const t=[];for(const s of e)for(const r of e)await this.isValidRoute(s,r)&&t.push({from:s,to:r});return t}preprocessRules(e){const t=e.isolation_groups.map(i=>this.parseRule(i)).sort((i,n)=>n.specificity-i.specificity),s=e.blacklist_pairs.map(i=>this.parseRule(i)).sort((i,n)=>n.specificity-i.specificity),r=e.whitelist_overrides.map(i=>this.parseRule(i)).sort((i,n)=>n.specificity-i.specificity);return{sortedIsolationRules:t,sortedBlacklistRules:s,sortedWhitelistRules:r}}parseRule(e){const s=e.includes("<->")?"<->":"->",[r,i]=e.split(s).map(n=>n.trim());return{pattern:e,fromPattern:r,toPattern:i,direction:s,specificity:this.calculateSpecificity(r,i)}}calculateSpecificity(e,t){const s=r=>{const i=r.toLowerCase();return i==="*"?0:i.includes("*")?1:2};return s(e)*10+s(t)}findMatchingRule(e,t,s){for(const r of t){const i=s==="from"?r.fromPattern:r.toPattern;if(this.matchesAssetPattern(e,i))return r;if(r.direction==="<->"){const n=s==="from"?r.toPattern:r.fromPattern;if(this.matchesAssetPattern(e,n))return r}}return null}matchesRuleDestination(e,t){return!!(this.matchesAssetPattern(e,t.toPattern)||t.direction==="<->"&&this.matchesAssetPattern(e,t.fromPattern))}matchesRuleSource(e,t){return!!(this.matchesAssetPattern(e,t.fromPattern)||t.direction==="<->"&&this.matchesAssetPattern(e,t.toPattern))}matchesRuleList(e,t,s){return s.some(r=>this.matchesRule(e,t,r))}matchesRule(e,t,s){const r=this.matchesAssetPattern(e,s.fromPattern)&&this.matchesAssetPattern(t,s.toPattern);if(s.direction==="<->"){const i=this.matchesAssetPattern(e,s.toPattern)&&this.matchesAssetPattern(t,s.fromPattern);return r||i}return r}matchesAssetPattern(e,t){const s=t.toLowerCase();return s==="*"?!0:s.endsWith(":*")?e.chain.toLowerCase()===s.slice(0,-2):s.startsWith("*:")?e.symbol.toLowerCase()===s.slice(2):e.toString().toLowerCase()===s}async buildRouteMatrix(e){const t={};for(const s of e)t[s.toString()]=await this.getValidDestinations(s,e);return t}};a.POLICY_CACHE_KEY="route_policy";let c=a;exports.RouteValidator=c;
package/dist/index11.js CHANGED
@@ -1,90 +1,224 @@
1
- class u {
2
- constructor(t, r) {
3
- this.apiBaseUrl = t, this.apiKey = r, this.policy = null;
1
+ import { ApiKey as f, Url as p, Ok as u, Err as a, Fetcher as d } from "@gardenfi/utils";
2
+ import m from "node-cache";
3
+ const o = class o {
4
+ constructor(e, t) {
5
+ this.policy = new m({
6
+ stdTTL: 36e3,
7
+ // 10 hours in seconds
8
+ checkperiod: 3600
9
+ // Check for expired keys every hour
10
+ }), typeof t == "string" ? this.auth = new f(t) : this.auth = t, typeof e == "string" ? this.apiBaseUrl = new p(e) : this.apiBaseUrl = e;
4
11
  }
5
- // Fetch policy from the API
12
+ getPolicy() {
13
+ return this.policy.get(o.POLICY_CACHE_KEY);
14
+ }
15
+ setPolicy(e) {
16
+ const t = this.getPolicy(), s = {
17
+ default: e.default || (t == null ? void 0 : t.default) || "open",
18
+ isolation_groups: [
19
+ .../* @__PURE__ */ new Set([
20
+ ...(t == null ? void 0 : t.isolation_groups) || [],
21
+ ...e.isolation_groups
22
+ ])
23
+ ],
24
+ blacklist_pairs: [
25
+ .../* @__PURE__ */ new Set([
26
+ ...(t == null ? void 0 : t.blacklist_pairs) || [],
27
+ ...e.blacklist_pairs
28
+ ])
29
+ ],
30
+ whitelist_overrides: [
31
+ .../* @__PURE__ */ new Set([
32
+ ...(t == null ? void 0 : t.whitelist_overrides) || [],
33
+ ...e.whitelist_overrides
34
+ ])
35
+ ]
36
+ };
37
+ return this.policy.set(o.POLICY_CACHE_KEY, s), s;
38
+ }
39
+ /**
40
+ * Loads the current route policy, cached or via API.
41
+ */
6
42
  async loadPolicy() {
43
+ const e = this.getPolicy();
44
+ if (e) return u(e);
7
45
  try {
8
- const r = await (await fetch(`${this.apiBaseUrl}/v2/policy`, {
9
- headers: {
10
- "garden-app-id": this.apiKey,
11
- accept: "application/json"
46
+ const t = await this.auth.getAuthHeaders();
47
+ if (!t.ok)
48
+ return a(`Failed to get auth headers: ${t.error}`);
49
+ const s = await d.get(
50
+ this.apiBaseUrl.endpoint("v2/policy"),
51
+ {
52
+ headers: {
53
+ "Content-Type": "application/json",
54
+ ...t.val
55
+ }
12
56
  }
13
- })).json();
14
- if (r.status !== "Ok")
15
- throw new Error(`API Error: ${r.error}`);
16
- this.policy = r.result;
57
+ );
58
+ return s.result ? u(this.setPolicy(s.result)) : a(`API Error: ${s.error}`);
17
59
  } catch (t) {
18
- throw new Error(`Failed to load policy: ${t}`);
60
+ return a(`Failed to load policy: ${t}`);
19
61
  }
20
62
  }
21
- isValidRoute(t, r) {
22
- const e = this.ensurePolicyLoaded();
23
- if (t === r) return !1;
24
- const i = this.findIsolationGroup(t), o = this.findIsolationGroup(r);
25
- return i !== null || o !== null ? i === o : this.matchesPatternList(t, r, e.whitelist_overrides) ? !0 : this.matchesPatternList(t, r, e.blacklist_pairs) ? !1 : e.default === "open";
26
- }
27
- isAssetInIsolationGroup(t) {
28
- return this.ensurePolicyLoaded(), this.findIsolationGroup(t) !== null;
29
- }
30
- getValidDestinations(t, r) {
31
- this.ensurePolicyLoaded();
32
- const e = this.findIsolationGroup(t);
33
- return e !== null ? r.filter(
34
- (i) => i !== t && this.findIsolationGroup(i) === e
35
- ) : r.filter((i) => t === i || this.findIsolationGroup(i) !== null ? !1 : this.isValidRoute(t, i));
36
- }
37
- getAllValidRoutes(t) {
38
- return t.flatMap(
39
- (r) => t.filter((e) => this.isValidRoute(r, e)).map((e) => ({ from: r, to: e }))
63
+ /**
64
+ * Checks if a given route is valid based on all route rules.
65
+ */
66
+ async isValidRoute(e, t) {
67
+ const s = await this.loadPolicy();
68
+ if (!s.ok || e.toString() === t.toString()) return !1;
69
+ const { sortedIsolationRules: i, sortedBlacklistRules: r, sortedWhitelistRules: n } = this.preprocessRules(s.val);
70
+ if (this.matchesRuleList(e, t, n))
71
+ return !0;
72
+ const c = this.findMatchingRule(
73
+ e,
74
+ i,
75
+ "from"
76
+ );
77
+ if (c && !this.matchesRuleDestination(t, c))
78
+ return !1;
79
+ const l = this.findMatchingRule(
80
+ t,
81
+ i,
82
+ "to"
83
+ );
84
+ return l && !this.matchesRuleSource(e, l) || this.matchesRuleList(e, t, r) ? !1 : s.val.default === "open";
85
+ }
86
+ /**
87
+ * Returns true if asset is part of any isolation group rule.
88
+ */
89
+ async isAssetInIsolationGroup(e) {
90
+ const t = await this.loadPolicy();
91
+ if (!t.ok) return !1;
92
+ const { sortedIsolationRules: s } = this.preprocessRules(t.val);
93
+ return s.some(
94
+ (i) => this.matchesAssetPattern(e, i.fromPattern) || this.matchesAssetPattern(e, i.toPattern)
40
95
  );
41
96
  }
42
- ensurePolicyLoaded() {
43
- if (!this.policy)
44
- throw new Error("Policy not loaded. Call loadPolicy() first.");
45
- return this.policy;
97
+ /**
98
+ * Returns all valid destinations for a given source asset.
99
+ */
100
+ async getValidDestinations(e, t) {
101
+ if (!(await this.loadPolicy()).ok) return [];
102
+ const i = [];
103
+ for (const r of t)
104
+ await this.isValidRoute(e, r) && i.push(r);
105
+ return i;
106
+ }
107
+ /**
108
+ * Returns every valid route (from-to pair) among the provided assets.
109
+ */
110
+ async getAllValidRoutes(e) {
111
+ const t = [];
112
+ for (const s of e)
113
+ for (const i of e)
114
+ await this.isValidRoute(s, i) && t.push({ from: s, to: i });
115
+ return t;
116
+ }
117
+ /**
118
+ * Turns policy string rules into sorted ParsedRule objects.
119
+ */
120
+ preprocessRules(e) {
121
+ const t = e.isolation_groups.map((r) => this.parseRule(r)).sort((r, n) => n.specificity - r.specificity), s = e.blacklist_pairs.map((r) => this.parseRule(r)).sort((r, n) => n.specificity - r.specificity), i = e.whitelist_overrides.map((r) => this.parseRule(r)).sort((r, n) => n.specificity - r.specificity);
122
+ return { sortedIsolationRules: t, sortedBlacklistRules: s, sortedWhitelistRules: i };
123
+ }
124
+ /**
125
+ * Parses a rule string (e.g. "ethereum:usdc -> base:usdt") into parts.
126
+ */
127
+ parseRule(e) {
128
+ const s = e.includes(
129
+ "<->"
130
+ /* Bidirectional */
131
+ ) ? "<->" : "->", [i, r] = e.split(s).map((n) => n.trim());
132
+ return {
133
+ pattern: e,
134
+ fromPattern: i,
135
+ toPattern: r,
136
+ direction: s,
137
+ specificity: this.calculateSpecificity(i, r)
138
+ };
46
139
  }
47
- findIsolationGroup(t) {
48
- if (!this.policy) return null;
49
- for (let r = 0; r < this.policy.isolation_groups.length; r++)
50
- if (this.matchesIsolationGroup(t, this.policy.isolation_groups[r]))
51
- return r;
140
+ /**
141
+ * Gives a specificity score to a rule pattern for prioritizing.
142
+ */
143
+ calculateSpecificity(e, t) {
144
+ const s = (i) => {
145
+ const r = i.toLowerCase();
146
+ return r === "*" ? 0 : r.includes(
147
+ "*"
148
+ /* Any */
149
+ ) ? 1 : 2;
150
+ };
151
+ return s(e) * 10 + s(t);
152
+ }
153
+ /**
154
+ * Finds the first matching rule for an asset given the rule "side".
155
+ */
156
+ findMatchingRule(e, t, s) {
157
+ for (const i of t) {
158
+ const r = s === "from" ? i.fromPattern : i.toPattern;
159
+ if (this.matchesAssetPattern(e, r)) return i;
160
+ if (i.direction === "<->") {
161
+ const n = s === "from" ? i.toPattern : i.fromPattern;
162
+ if (this.matchesAssetPattern(e, n))
163
+ return i;
164
+ }
165
+ }
52
166
  return null;
53
167
  }
54
- matchesIsolationGroup(t, r) {
55
- return this.parsePattern(r).some((i) => this.matchesAssetPattern(t, i));
168
+ /**
169
+ * Checks if a given toAsset matches the rule's destination side.
170
+ */
171
+ matchesRuleDestination(e, t) {
172
+ return !!(this.matchesAssetPattern(e, t.toPattern) || t.direction === "<->" && this.matchesAssetPattern(e, t.fromPattern));
56
173
  }
57
- matchesPatternList(t, r, e) {
58
- return e.some(
59
- (i) => this.matchesRoutePattern(t, r, i)
60
- );
174
+ /**
175
+ * Checks if a given fromAsset matches the rule's source side.
176
+ */
177
+ matchesRuleSource(e, t) {
178
+ return !!(this.matchesAssetPattern(e, t.fromPattern) || t.direction === "<->" && this.matchesAssetPattern(e, t.toPattern));
179
+ }
180
+ /**
181
+ * Checks if any rule in a list matches fromAsset and toAsset.
182
+ */
183
+ matchesRuleList(e, t, s) {
184
+ return s.some((i) => this.matchesRule(e, t, i));
61
185
  }
62
- matchesRoutePattern(t, r, e) {
63
- const i = e.includes("<->") ? "<->" : "->", [o, a] = e.split(i).map((s) => s.trim()), l = this.matchesAssetPattern(t, o) && this.matchesAssetPattern(r, a);
64
- if (i === "<->") {
65
- const s = this.matchesAssetPattern(t, a) && this.matchesAssetPattern(r, o);
66
- return l || s;
186
+ /**
187
+ * Checks if a rule matches fromAsset and toAsset (forward or backward if bidirectional).
188
+ */
189
+ matchesRule(e, t, s) {
190
+ const i = this.matchesAssetPattern(e, s.fromPattern) && this.matchesAssetPattern(t, s.toPattern);
191
+ if (s.direction === "<->") {
192
+ const r = this.matchesAssetPattern(e, s.toPattern) && this.matchesAssetPattern(t, s.fromPattern);
193
+ return i || r;
67
194
  }
68
- return l;
69
- }
70
- parsePattern(t) {
71
- const r = t.includes("<->") ? "<->" : "->";
72
- return t.split(r).map((e) => e.trim());
73
- }
74
- matchesAssetPattern(t, r) {
75
- const e = t.toString().toLowerCase(), i = r.toLowerCase();
76
- return i === "*" ? !0 : i.endsWith(":*") ? e.startsWith(i.slice(0, -2) + ":") : i.startsWith("*:") ? e.endsWith(":" + i.slice(2)) : e === i;
77
- }
78
- }
79
- function c(n, t) {
80
- return Object.fromEntries(
81
- n.map((r) => [
82
- r.toString(),
83
- t.getValidDestinations(r, n)
84
- ])
85
- );
86
- }
195
+ return i;
196
+ }
197
+ /**
198
+ * Checks if an asset string matches a rule's pattern (wildcards supported).
199
+ */
200
+ matchesAssetPattern(e, t) {
201
+ const s = t.toLowerCase();
202
+ return s === "*" ? !0 : s.endsWith(
203
+ ":*"
204
+ /* AnyToken */
205
+ ) ? e.chain.toLowerCase() === s.slice(0, -2) : s.startsWith(
206
+ "*:"
207
+ /* AnyChain */
208
+ ) ? e.symbol.toLowerCase() === s.slice(2) : e.toString().toLowerCase() === s;
209
+ }
210
+ async buildRouteMatrix(e) {
211
+ const t = {};
212
+ for (const s of e)
213
+ t[s.toString()] = await this.getValidDestinations(
214
+ s,
215
+ e
216
+ );
217
+ return t;
218
+ }
219
+ };
220
+ o.POLICY_CACHE_KEY = "route_policy";
221
+ let h = o;
87
222
  export {
88
- u as RouteValidator,
89
- c as buildRouteMatrix
223
+ h as RouteValidator
90
224
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./index8.cjs");function c(m,e,t){var i;const r=(m??"").trim();if(!r)return{name:"",symbol:""};const s=r.split(":");if(s.length>=2){const o=((i=s[0])==null?void 0:i.trim())||"",p=s.slice(1).join(":").trim()||(t==null?void 0:t.trim())||"";return{name:o,symbol:p}}let n="";if(e)try{n=(typeof e=="string"?u.ChainAsset.from(e):e).symbol.toUpperCase()}catch{}return{name:r,symbol:n||(t==null?void 0:t.trim())||""}}exports.parseAssetNameSymbol=c;
@@ -0,0 +1,21 @@
1
+ import { ChainAsset as h } from "./index8.js";
2
+ function A(m, r, t) {
3
+ var s;
4
+ const n = (m ?? "").trim();
5
+ if (!n) return { name: "", symbol: "" };
6
+ const e = n.split(":");
7
+ if (e.length >= 2) {
8
+ const o = ((s = e[0]) == null ? void 0 : s.trim()) || "", p = e.slice(1).join(":").trim() || (t == null ? void 0 : t.trim()) || "";
9
+ return { name: o, symbol: p };
10
+ }
11
+ let i = "";
12
+ if (r)
13
+ try {
14
+ i = (typeof r == "string" ? h.from(r) : r).symbol.toUpperCase();
15
+ } catch {
16
+ }
17
+ return { name: n, symbol: i || (t == null ? void 0 : t.trim()) || "" };
18
+ }
19
+ export {
20
+ A as parseAssetNameSymbol
21
+ };
package/dist/index4.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@gardenfi/utils"),e=require("./index3.cjs"),s=require("./index5.cjs"),v=require("./index6.cjs");var o=(a=>(a.Created="Created",a.InitiateDetected="Initiate Detected",a.Initiated="Initiated",a.AwaitingRedeem="Awaiting Redeem",a.RedeemDetected="Redeem Detected",a.Redeemed="Redeemed",a.AwaitingRefund="Awaiting Refund",a.RefundDetected="Refund Detected",a.Refunded="Refunded",a.Expired="Expired",a))(o||{}),r=(a=>(a.refunded="refunded",a.expired="expired",a.completed="completed",a.inProgress="in-progress",a.notInitiated="not-initiated",a.all="all",a.pending="pending",a.fulfilled="fulfilled",a))(r||{});const n={solana_localnet:{type:e.BlockchainType.solana,SOL:s.SOLSolanaLocalnetAsset,network:c.Network.LOCALNET},arbitrum_localnet:{type:e.BlockchainType.evm,WBTC:s.WBTCArbitrumLocalnetAsset,network:c.Network.LOCALNET},ethereum_localnet:{type:e.BlockchainType.evm,WBTC:s.WBTCEthereumLocalnetAsset,network:c.Network.LOCALNET},bitcoin_regtest:{type:e.BlockchainType.bitcoin,BTC:s.bitcoinRegtestAsset,network:c.Network.LOCALNET},starknet_devnet:{type:e.BlockchainType.starknet,STRK:s.STRKStarknetLocalnetAsset,ETH:s.ETHStarknetLocalnetAsset,network:c.Network.LOCALNET},solana_testnet:{type:e.BlockchainType.solana,network:c.Network.TESTNET,SOL:{id:"solana_testnet:sol",name:"Solana",symbol:"SOL",decimals:9,icon:"https://garden-finance.imgix.net/chain_images/solana.png",chain:"solana:103",htlc:{address:"2bag6xpshpvPe7SJ9nSDLHpxqhEAoHPGpEkjNSv7gxoF",schema:"solana:htlc"},token:null},USDC:{id:"solana_testnet:usdc",name:"USD Coin",symbol:"USDC",decimals:6,icon:"https://garden.imgix.net/token-images/usdc.svg",chain:"solana:103",htlc:{address:"gdnvdMCHJgnidtU7SL8RkRshHPvDJU1pdfZEpoLvqdU",schema:"solana:htlc_spltoken"},token:{address:"5JbWjyLdYKTuykpq2itWbdRcZkhK3hs6fiH62pkmLYZi",schema:null}},cbBTC:{id:"solana_testnet:cbbtc",name:"Coinbase Wrapped Bitcoin",symbol:"cbBTC",decimals:8,icon:"https://garden.imgix.net/token-images/cbBTC.svg",chain:"solana:103",htlc:{address:"gdnvdMCHJgnidtU7SL8RkRshHPvDJU1pdfZEpoLvqdU",schema:"solana:htlc_spltoken"},token:{address:"CL8C4gsaEQyWPxL4Zn7dcnZ8LKvPYqHmv4ipMax4cDUL",schema:null}}},bitcoin_testnet:{type:e.BlockchainType.bitcoin,network:c.Network.TESTNET,BTC:{id:"bitcoin_testnet:btc",name:"Bitcoin",symbol:"BTC",decimals:8,icon:"https://garden.imgix.net/token-images/bitcoin.svg",chain:"bitcoin",htlc:null,token:null}},ethereum_sepolia:{type:e.BlockchainType.evm,network:c.Network.TESTNET,WBTC:{id:"ethereum_sepolia:wbtc",name:"Wrapped Bitcoin",symbol:"WBTC",decimals:8,icon:"https://garden.imgix.net/token-images/wbtc.svg",chain:"evm:11155111",htlc:{address:"0xd1E0Ba2b165726b3a6051b765d4564d030FDcf50",schema:"evm:htlc_erc20"},token:{address:"0xE918A5a47b8e0AFAC2382bC5D1e981613e63fB07",schema:"evm:erc20"}},USDC:{id:"ethereum_sepolia:usdc",name:"USD Coin",symbol:"USDC",decimals:6,icon:"https://garden.imgix.net/token-images/usdc.svg",chain:"evm:11155111",htlc:{address:"0x730Be401ef981D199a0560C87DfdDaFd3EC1C493",schema:"evm:htlc_erc20"},token:{address:"0xadDD620EA6D20f4f9c24fff3BC039E497ceBEDc2",schema:"evm:erc20"}}},arbitrum_sepolia:{type:e.BlockchainType.evm,network:c.Network.TESTNET,iBTC:{id:"arbitrum_sepolia:ibtc",name:"iBTC",symbol:"iBTC",decimals:8,icon:"https://garden.imgix.net/token-images/dlcBTCIcon.svg",chain:"evm:421614",htlc:{address:"0x7e8c18fa79bd4014cfCf49294Bf315139eD39f45",schema:"evm:htlc_erc20"},token:{address:"0x685437f025c5f33A94818408C286bc1F023201Fc",schema:"evm:erc20"}},WBTC:{id:"arbitrum_sepolia:wbtc",name:"Wrapped Bitcoin",symbol:"WBTC",decimals:8,icon:"https://garden.imgix.net/token-images/wbtc.svg",chain:"evm:421614",htlc:{address:"0xb5AE9785349186069C48794a763DB39EC756B1cF",schema:"evm:htlc_erc20"},token:{address:"0x1c287717c886794ac9f5DF3987195431Ceb3456E",schema:"evm:erc20"}},USDC:{id:"arbitrum_sepolia:usdc",name:"USD Coin",symbol:"USDC",decimals:6,icon:"https://garden.imgix.net/token-images/usdc.svg",chain:"evm:421614",htlc:{address:"0x8E12d730756457B99ce6E6AbFd60eBe751dA169B",schema:"evm:htlc_erc20"},token:{address:"0xC90Ad772eCc10a52a681ceDAE6EbBD3470A0c829",schema:"evm:erc20"}},SEED:{id:"arbitrum_sepolia:seed",name:"Seed",symbol:"SEED",decimals:18,icon:"https://garden.imgix.net/token-images/SEED.svg",chain:"evm:421614",htlc:{address:"0xFBD30cB9313fe580031A7E0258693E1cec002803",schema:"evm:htlc_erc20"},token:{address:"0x432B43764548c3E47eA65aAdeB91D75C84DBcC2c",schema:"evm:erc20"}}},base_sepolia:{type:e.BlockchainType.evm,network:c.Network.TESTNET,iBTC:{id:"base_sepolia:ibtc",name:"iBTC",symbol:"iBTC",decimals:8,icon:"https://garden.imgix.net/token-images/dlcBTCIcon.svg",chain:"evm:84532",htlc:{address:"0x46F1Ba9C9d89C34F9dbC4085F6B1f9965c589ca1",schema:"evm:htlc_erc20"},token:{address:"0x0b0D554D9573bAe1a7556d220847f45182918B28",schema:"evm:erc20"}},WBTC:{id:"base_sepolia:wbtc",name:"Wrapped Bitcoin",symbol:"WBTC",decimals:8,icon:"https://garden.imgix.net/token-images/wbtc.svg",chain:"evm:84532",htlc:{address:"0xd1E0Ba2b165726b3a6051b765d4564d030FDcf50",schema:"evm:htlc_erc20"},token:{address:"0xD8a6E3FCA403d79b6AD6216b60527F51cc967D39",schema:"evm:erc20"}},USDT:{id:"base_sepolia:usdt",name:"Tether USD",symbol:"USDT",decimals:6,icon:"https://garden.imgix.net/token-images/usdt.svg",chain:"evm:84532",htlc:{address:"0x917cfef972d667dC0FeC76806cB5623585B81493",schema:"evm:htlc_erc20"},token:{address:"0xeaE7721d779276eb0f5837e2fE260118724a2Ba4",schema:"evm:erc20"}},USDC:{id:"base_sepolia:usdc",name:"USD Coin",symbol:"USDC",decimals:6,icon:"https://garden.imgix.net/token-images/usdc.svg",chain:"evm:84532",htlc:{address:"0x730Be401ef981D199a0560C87DfdDaFd3EC1C493",schema:"evm:htlc_erc20"},token:{address:"0x1ac7A0ebf13a996D5915e212900bE2d074f94988",schema:"evm:erc20"}}},bera_testnet:{type:e.BlockchainType.evm,network:c.Network.TESTNET},citrea_testnet:{type:e.BlockchainType.evm,network:c.Network.TESTNET,WCBTC:{id:"citrea_testnet:wcbtc",name:"Wrapped Citrea Bitcoin",symbol:"WCBTC",decimals:18,icon:"https://garden.imgix.net/token-images/wbtc.svg",chain:"evm:5115",htlc:{address:"0xD8e99df8cf77E7383c2f2a84bC6384b2DF88CAd3",schema:"evm:htlc_erc20"},token:{address:"0x8d0c9d1c17aE5e40ffF9bE350f57840E9E66Cd93",schema:"evm:erc20"}},WBTC:{id:"citrea_testnet:wbtc",name:"Wrapped Bitcoin",symbol:"WBTC",decimals:8,icon:"https://garden.imgix.net/token-images/wbtc.svg",chain:"evm:5115",htlc:{address:"0xd1E0Ba2b165726b3a6051b765d4564d030FDcf50",schema:"evm:htlc_erc20"},token:{address:"0x3edA22460259b29433704dda71cc921F528165Ea",schema:"evm:erc20"}},CBTC:{id:"citrea_testnet:cbtc",name:"Citrea Bitcoin",symbol:"CBTC",decimals:18,icon:"https://garden.imgix.net/token-images/bitcoin.svg",chain:"evm:5115",htlc:{address:"0xE413743B51f3cC8b3ac24addf50D18fa138cB0Bb",schema:"evm:htlc"},token:null},CBBTC:{id:"citrea_testnet:cbbtc",name:"Coinbase Wrapped Bitcoin",symbol:"CBBTC",decimals:8,icon:"https://garden.imgix.net/token-images/bitcoin.svg",chain:"evm:5115",htlc:{address:"0x8656d38352CD90ca55881eBd0AF6822839b435A8",schema:"evm:htlc_erc20"},token:{address:"0xeAa998aF280a62Ae08BaE4f9fa59C9b30e6BD306",schema:"evm:erc20"}},USDC:{id:"citrea_testnet:usdc",name:"USD Coin",symbol:"USDC",decimals:6,icon:"https://garden.imgix.net/token-images/usdc.svg",chain:"evm:5115",htlc:{address:"0x730Be401ef981D199a0560C87DfdDaFd3EC1C493",schema:"evm:htlc_erc20"},token:{address:"0xCdA8661fDA031deFCc9BdD88C0e12669Cac47Fb0",schema:"evm:erc20"}},USDT:{id:"citrea_testnet:usdt",name:"Tether USD",symbol:"USDT",decimals:6,icon:"https://garden.imgix.net/token-images/usdt.svg",chain:"evm:5115",htlc:{address:"0x917cfef972d667dC0FeC76806cB5623585B81493",schema:"evm:htlc_erc20"},token:{address:"0xF5cFE09b852Ddb164cF6Db419B9c11aAb5F30cb6",schema:"evm:erc20"}}},monad_testnet:{type:e.BlockchainType.evm,network:c.Network.TESTNET,cBBTC:{id:"monad_testnet:cbbtc",name:"Coinbase Wrapped Bitcoin",symbol:"cBBTC",decimals:8,icon:"https://garden.imgix.net/token-images/cbBTC.svg",chain:"evm:10143",htlc:{address:"0x8656d38352CD90ca55881eBd0AF6822839b435A8",schema:"evm:htlc_erc20"},token:{address:"0x6b6303fAb8eC7232b4f2a7b9fa58E5216F608fcb",schema:"evm:erc20"}},USDC:{id:"monad_testnet:usdc",name:"USD Coin",symbol:"USDC",decimals:6,icon:"https://garden.imgix.net/token-images/usdc.svg",chain:"evm:10143",htlc:{address:"0x730Be401ef981D199a0560C87DfdDaFd3EC1C493",schema:"evm:htlc_erc20"},token:{address:"0xf817257fed379853cde0fa4f97ab987181b1e5ea",schema:"evm:erc20"}}},starknet_sepolia:{type:e.BlockchainType.starknet,network:c.Network.TESTNET,WBTC:{id:"starknet_sepolia:wbtc",name:"Wrapped Bitcoin",symbol:"WBTC",decimals:8,icon:"https://garden.imgix.net/token-images/wbtc.svg",chain:"starknet:393402133025997798000961",htlc:{address:"0x06579d255314109429a4477d89629bc2b94f529ae01979c2f8014f9246482603",schema:"starknet:htlc_erc20"},token:{address:"0x496bef3ed20371382fbe0ca6a5a64252c5c848f9f1f0cccf8110fc4def912d5",schema:"starknet:erc20"}}},sui_testnet:{type:e.BlockchainType.sui,network:c.Network.TESTNET,SUI:{id:"sui_testnet:sui",name:"SUI",symbol:"SUI",decimals:9,icon:"https://garden-finance.imgix.net/chain_images/sui.svg",chain:"sui",htlc:{address:"0x5c438715b7dcc02d12ab92449153a1e5ade2301620d5bf60aa748f006726d369",schema:null},token:{address:"0x2::sui::SUI",schema:null}}},hyperliquid_testnet:{type:e.BlockchainType.evm,network:c.Network.TESTNET},bnbchain_testnet:{type:e.BlockchainType.evm,network:c.Network.TESTNET,WBTC:{id:"bnbchain_testnet:wbtc",name:"Wrapped Bitcoin",symbol:"WBTC",decimals:8,icon:"https://garden.imgix.net/token-images/wbtc.svg",chain:"evm:97",htlc:{address:"0xd1E0Ba2b165726b3a6051b765d4564d030FDcf50",schema:"evm:htlc_erc20"},token:{address:"0x39f3294352208905fc6ebf033954E6c6455CdB4C",schema:"evm:erc20"}}},bitcoin:{type:e.BlockchainType.bitcoin,network:c.Network.MAINNET,BTC:{id:"bitcoin:btc",name:"Bitcoin",symbol:"BTC",decimals:8,icon:"https://garden.imgix.net/token-images/bitcoin.svg",chain:"bitcoin",htlc:null,token:null}},base:{type:e.BlockchainType.evm,network:c.Network.MAINNET,USDC:{id:"base:usdc",name:"USD Coin",symbol:"USDC",decimals:6,icon:"https://garden.imgix.net/token-images/usdc.svg",chain:"evm:8453",htlc:{address:"0x5fA58e4E89c85B8d678Ade970bD6afD4311aF17E",schema:"evm:htlc_erc20"},token:{address:"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",schema:"evm:erc20"}},cBBTC:{id:"base:cbbtc",name:"Coinbase Wrapped Bitcoin",symbol:"cBBTC",decimals:8,icon:"https://coin-images.coingecko.com/coins/images/51336/large/cbbtc.png?1730814747",chain:"evm:8453",htlc:{address:"0xe35d025d0f0d9492db4700FE8646f7F89150eC04",schema:"evm:htlc_erc20"},token:{address:"0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf",schema:"evm:erc20"}}},arbitrum:{type:e.BlockchainType.evm,network:c.Network.MAINNET,WBTC:{id:"arbitrum:wbtc",name:"Wrapped Bitcoin",symbol:"WBTC",decimals:8,icon:"https://garden.imgix.net/token-images/wbtc.svg",chain:"evm:42161",htlc:{address:"0xb5AE9785349186069C48794a763DB39EC756B1cF",schema:"evm:htlc_erc20"},token:{address:"0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",schema:"evm:erc20"}},USDC:{id:"arbitrum:usdc",name:"USD Coin",symbol:"USDC",decimals:6,icon:"https://garden.imgix.net/token-images/usdc.svg",chain:"evm:42161",htlc:{address:"0x8E12d730756457B99ce6E6AbFd60eBe751dA169B",schema:"evm:htlc_erc20"},token:{address:"0xaf88d065e77c8cC2239327C5EDb3A432268e5831",schema:"evm:erc20"}},SEED:{id:"arbitrum:seed",name:"SEED",symbol:"SEED",decimals:18,icon:"https://garden.imgix.net/token-images/SEED.svg",chain:"evm:42161",htlc:{address:"0xFBD30cB9313fe580031A7E0258693E1cec002803",schema:"evm:htlc_erc20"},token:{address:"0x86f65121804D2Cdbef79F9f072D4e0c2eEbABC08",schema:"evm:erc20"}}},ethereum:{type:e.BlockchainType.evm,network:c.Network.MAINNET,ETH:{id:"ethereum:eth",name:"Ethereum",symbol:"ETH",decimals:18,icon:"https://garden.imgix.net/chain_images/ethereum.svg",chain:"evm:1",htlc:{address:"0xE413743B51f3cC8b3ac24addf50D18fa138cB0Bb",schema:"evm:htlc"},token:null},USDC:{id:"ethereum:usdc",name:"USD Coin",symbol:"USDC",decimals:6,icon:"https://garden.imgix.net/token-images/usdc.svg",chain:"evm:1",htlc:{address:"0x5fA58e4E89c85B8d678Ade970bD6afD4311aF17E",schema:"evm:htlc_erc20"},token:{address:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",schema:"evm:erc20"}},WBTC:{id:"ethereum:wbtc",name:"Wrapped Bitcoin",symbol:"WBTC",decimals:8,icon:"https://garden.imgix.net/token-images/wbtc.svg",chain:"evm:1",htlc:{address:"0xD781a2abB3FCB9fC0D1Dd85697c237d06b75fe95",schema:"evm:htlc_erc20"},token:{address:"0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",schema:"evm:erc20"}},cBBTC:{id:"ethereum:cbbtc",name:"Coinbase Wrapped Bitcoin",symbol:"cBBTC",decimals:8,icon:"https://garden.imgix.net/token-images/cbBTC.svg",chain:"evm:1",htlc:{address:"0xe35d025d0f0d9492db4700FE8646f7F89150eC04",schema:"evm:htlc_erc20"},token:{address:"0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf",schema:"evm:erc20"}},SEED:{id:"ethereum:seed",name:"SEED",symbol:"SEED",decimals:18,icon:"https://garden.imgix.net/token-images/SEED.svg",chain:"evm:1",htlc:{address:"0xCE511De667885f92B8c36fcfC79C3B5bEb875463",schema:"evm:htlc_erc20"},token:{address:"0x5eed99d066a8CaF10f3E4327c1b3D8b673485eED",schema:"evm:erc20"}}},solana:{type:e.BlockchainType.solana,network:c.Network.MAINNET,SOL:{id:"solana:sol",name:"Solana",symbol:"SOL",decimals:9,icon:"https://garden-finance.imgix.net/chain_images/solana.png",chain:"solana:101",htlc:{address:"2bag6xpshpvPe7SJ9nSDLHpxqhEAoHPGpEkjNSv7gxoF",schema:"solana:htlc"},token:null},USDC:{id:"solana:usdc",name:"USD Coin",symbol:"USDC",decimals:6,icon:"https://garden.imgix.net/token-images/usdc.svg",chain:"solana:101",htlc:{address:"gdnvdMCHJgnidtU7SL8RkRshHPvDJU1pdfZEpoLvqdU",schema:"solana:htlc_spltoken"},token:{address:"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",schema:"primary"}},cBBTC:{id:"solana:cbbtc",name:"Coinbase Wrapped Bitcoin",symbol:"cBBTC",decimals:8,icon:"https://garden.imgix.net/token-images/cbBTC.svg",chain:"solana:101",htlc:{address:"gdnvdMCHJgnidtU7SL8RkRshHPvDJU1pdfZEpoLvqdU",schema:"solana:htlc_spltoken"},token:{address:"cbbtcf3aa214zXHbiAZQwf4122FBYbraNdFqgw4iMij",schema:"primary"}}},bera:{type:e.BlockchainType.evm,network:c.Network.MAINNET,LBTC:{id:"bera:lbtc",name:"Lombard Bitcoin",symbol:"LBTC",decimals:8,icon:"https://garden.imgix.net/token-images/LBTC.svg",chain:"evm:80094",htlc:{address:"0x84A396920d8B8CA2e69bD9503Bc1B2f73f1b8b33",schema:"evm:htlc_erc20"},token:{address:"0xecAc9C5F704e954931349Da37F60E39f515c11c1",schema:"evm:erc20"}}},starknet:{type:e.BlockchainType.starknet,network:c.Network.MAINNET,WBTC:{id:"starknet:wbtc",name:"Wrapped Bitcoin",symbol:"WBTC",decimals:8,icon:"https://garden.imgix.net/token-images/wbtc.svg",chain:"starknet:23448594291968334",htlc:{address:"0x7defd8eb3b770005ab1ca5f89ad31f98fb5bc3c52deaeafd130be3b49f967b4",schema:"starknet:htlc_erc20"},token:{address:"0x3fe2b97c1fd336e750087d68b9b867997fd64a2661ff3ca5a7c771641e8e7ac",schema:"starknet:erc20"}}},sui:{type:e.BlockchainType.sui,network:c.Network.MAINNET,SUI:{id:"sui:sui",name:"SUI",symbol:"SUI",decimals:9,icon:"https://garden-finance.imgix.net/chain_images/sui.svg",chain:"sui:0",htlc:{address:"0xa4f4e653547e98d4b541378e14db2393a09aff4b829f158b133d2eb3c3a942b5",schema:null},token:{address:"0x2::sui::SUI",schema:null}}},hyperliquid:{type:e.BlockchainType.evm,network:c.Network.MAINNET,uBTC:{id:"hyperliquid:ubtc",name:"Unit Bitcoin",symbol:"uBTC",decimals:8,icon:"https://garden.imgix.net/token-images/bitcoin.svg",chain:"evm:999",htlc:{address:"0xDC74a45e86DEdf1fF7c6dac77e0c2F082f9E4F72",schema:"evm:htlc_erc20"},token:{address:"0x9FDBdA0A5e284c32744D2f17Ee5c74B284993463",schema:"evm:erc20"}}},unichain:{type:e.BlockchainType.evm,network:c.Network.MAINNET,WBTC:{id:"unichain:wbtc",name:"Wrapped Bitcoin",symbol:"WBTC",decimals:8,icon:"https://garden.imgix.net/token-images/wbtc.svg",chain:"evm:130",htlc:{address:"0xD781a2abB3FCB9fC0D1Dd85697c237d06b75fe95",schema:"evm:htlc_erc20"},token:{address:"0x927B51f251480a681271180DA4de28D44EC4AfB8",schema:"evm:erc20"}},USDC:{id:"unichain:usdc",name:"USD Coin",symbol:"USDC",decimals:6,icon:"https://garden.imgix.net/token-images/usdc.svg",chain:"evm:130",htlc:{address:"0x5fA58e4E89c85B8d678Ade970bD6afD4311aF17E",schema:"evm:htlc_erc20"},token:{address:"0x078D782b760474a361dDA0AF3839290b0EF57AD6",schema:"evm:erc20"}}},corn:{type:e.BlockchainType.evm,network:c.Network.MAINNET,BTCN:{id:"corn:btcn",name:"Bitcorn",symbol:"BTCN",decimals:18,icon:"https://garden.imgix.net/token-images/bitcorn.svg",chain:"evm:21000000",htlc:{address:"0xE413743B51f3cC8b3ac24addf50D18fa138cB0Bb",schema:"evm:htlc"},token:null}},botanix:{type:e.BlockchainType.evm,network:c.Network.MAINNET,BTC:{id:"botanix:btc",name:"Botanix Bitcoin",symbol:"BTC",decimals:18,icon:"https://garden.imgix.net/token-images/bitcoin.svg",chain:"evm:3637",htlc:{address:"0xE413743B51f3cC8b3ac24addf50D18fa138cB0Bb",schema:"evm:htlc"},token:null}},bnbchain:{type:e.BlockchainType.evm,network:c.Network.MAINNET,BTCB:{id:"bnbchain:btcb",name:"Binance Bitcoin",symbol:"BTCB",decimals:18,icon:"https://garden.imgix.net/token-images/bitcoin.svg",chain:"evm:56",htlc:{address:"0xe74784E5A45528fDEcB257477DD6bd31c8ef0761",schema:"evm:htlc_erc20"},token:{address:"0x7130d2A12B9BCbFAe4f2634d864A1Ee1Ce3Ead9c",schema:"evm:erc20"}},USDC:{id:"bnbchain:usdc",name:"USD Coin",symbol:"USDC",decimals:18,icon:"https://garden.imgix.net/token-images/usdc.svg",chain:"evm:56",htlc:{address:"0x5fA58e4E89c85B8d678Ade970bD6afD4311aF17E",schema:"evm:htlc_erc20"},token:{address:"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",schema:"evm:erc20"}},BNB:{id:"bnbchain:bnb",name:"BNB",symbol:"BNB",decimals:18,icon:"https://garden-finance.imgix.net/chain_images/bnb.png",chain:"evm:56",htlc:{address:"0xE413743B51f3cC8b3ac24addf50D18fa138cB0Bb",schema:"evm:htlc"},token:null}},core:{type:e.BlockchainType.evm,network:c.Network.MAINNET,WBTC:{id:"core:wbtc",name:"Wrapped Bitcoin",symbol:"WBTC",decimals:8,icon:"https://garden.imgix.net/token-images/wbtc.svg",chain:"evm:1116",htlc:{address:"0xD781a2abB3FCB9fC0D1Dd85697c237d06b75fe95",schema:"evm:htlc_erc20"},token:{address:"0x5832f53d147b3d6Cd4578B9CBD62425C7ea9d0Bd",schema:"evm:erc20"}}}},T=Object.keys(n).reduce((a,t)=>(a[t]=t,a),{}),f=v.buildAssetsWithChain(n),E=a=>n[a].network===c.Network.MAINNET;function i(a){return t=>n[t].type===a}const h=i(e.BlockchainType.evm),l=i(e.BlockchainType.bitcoin),b=i(e.BlockchainType.solana),B=i(e.BlockchainType.starknet),k=i(e.BlockchainType.sui),D=a=>n[a].type,d={[e.BlockchainType.evm]:"eth",[e.BlockchainType.solana]:"sol",[e.BlockchainType.sui]:"sui"},g=(a,t)=>h(a)&&t.toLowerCase()===d[e.BlockchainType.evm],C=(a,t)=>b(a)&&t.toLowerCase()===d[e.BlockchainType.solana],p=(a,t)=>k(a)&&t.toLowerCase()===d[e.BlockchainType.sui],x=a=>{const t=a.chain,m=a.symbol;return g(t,m)||C(t,m)||l(t)||p(t,m)||!B(t)};exports.Assets=f;exports.Chains=T;exports.Config=n;exports.NATIVE_TOKENS=d;exports.OrderLifecycle=r;exports.OrderStatus=o;exports.getBlockchainType=D;exports.is=i;exports.isBitcoin=l;exports.isEVM=h;exports.isEvmNativeToken=g;exports.isMainnet=E;exports.isNativeToken=x;exports.isSolana=b;exports.isSolanaNativeToken=C;exports.isStarknet=B;exports.isSui=k;exports.isSuiNativeToken=p;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@gardenfi/utils"),e=require("./index3.cjs"),s=require("./index5.cjs"),v=require("./index6.cjs");var o=(c=>(c.Created="Created",c.InitiateDetected="Initiate Detected",c.Initiated="Initiated",c.AwaitingRedeem="Awaiting Redeem",c.RedeemDetected="Redeem Detected",c.Redeemed="Redeemed",c.AwaitingRefund="Awaiting Refund",c.RefundDetected="Refund Detected",c.Refunded="Refunded",c.Expired="Expired",c))(o||{}),r=(c=>(c.refunded="refunded",c.expired="expired",c.completed="completed",c.inProgress="in-progress",c.notInitiated="not-initiated",c.all="all",c.pending="pending",c.fulfilled="fulfilled",c))(r||{});const n={solana_localnet:{type:e.BlockchainType.solana,SOL:s.SOLSolanaLocalnetAsset,network:a.Network.LOCALNET},arbitrum_localnet:{type:e.BlockchainType.evm,WBTC:s.WBTCArbitrumLocalnetAsset,network:a.Network.LOCALNET},ethereum_localnet:{type:e.BlockchainType.evm,WBTC:s.WBTCEthereumLocalnetAsset,network:a.Network.LOCALNET},bitcoin_regtest:{type:e.BlockchainType.bitcoin,BTC:s.bitcoinRegtestAsset,network:a.Network.LOCALNET},starknet_devnet:{type:e.BlockchainType.starknet,STRK:s.STRKStarknetLocalnetAsset,ETH:s.ETHStarknetLocalnetAsset,network:a.Network.LOCALNET},solana_testnet:{type:e.BlockchainType.solana,network:a.Network.TESTNET,SOL:{id:"solana_testnet:sol",name:"Solana",symbol:"SOL",decimals:9,icon:"https://garden-finance.imgix.net/chain_images/solana.png",chain:"solana:103",htlc:{address:"2bag6xpshpvPe7SJ9nSDLHpxqhEAoHPGpEkjNSv7gxoF",schema:"solana:htlc"},token:null},USDC:{id:"solana_testnet:usdc",name:"USD Coin",symbol:"USDC",decimals:6,icon:"https://garden.imgix.net/token-images/usdc.svg",chain:"solana:103",htlc:{address:"gdnvdMCHJgnidtU7SL8RkRshHPvDJU1pdfZEpoLvqdU",schema:"solana:htlc_spltoken"},token:{address:"5JbWjyLdYKTuykpq2itWbdRcZkhK3hs6fiH62pkmLYZi",schema:null}},cbBTC:{id:"solana_testnet:cbbtc",name:"Coinbase Wrapped Bitcoin",symbol:"cbBTC",decimals:8,icon:"https://garden.imgix.net/token-images/cbBTC.svg",chain:"solana:103",htlc:{address:"gdnvdMCHJgnidtU7SL8RkRshHPvDJU1pdfZEpoLvqdU",schema:"solana:htlc_spltoken"},token:{address:"CL8C4gsaEQyWPxL4Zn7dcnZ8LKvPYqHmv4ipMax4cDUL",schema:null}}},bitcoin_testnet:{type:e.BlockchainType.bitcoin,network:a.Network.TESTNET,BTC:{id:"bitcoin_testnet:btc",name:"Bitcoin",symbol:"BTC",decimals:8,icon:"https://garden.imgix.net/token-images/bitcoin.svg",chain:"bitcoin",htlc:null,token:null}},ethereum_sepolia:{type:e.BlockchainType.evm,network:a.Network.TESTNET,WBTC:{id:"ethereum_sepolia:wbtc",name:"Wrapped Bitcoin",symbol:"WBTC",decimals:8,icon:"https://garden.imgix.net/token-images/wbtc.svg",chain:"evm:11155111",htlc:{address:"0xd1E0Ba2b165726b3a6051b765d4564d030FDcf50",schema:"evm:htlc_erc20"},token:{address:"0xE918A5a47b8e0AFAC2382bC5D1e981613e63fB07",schema:"evm:erc20"}},USDC:{id:"ethereum_sepolia:usdc",name:"USD Coin",symbol:"USDC",decimals:6,icon:"https://garden.imgix.net/token-images/usdc.svg",chain:"evm:11155111",htlc:{address:"0x730Be401ef981D199a0560C87DfdDaFd3EC1C493",schema:"evm:htlc_erc20"},token:{address:"0xadDD620EA6D20f4f9c24fff3BC039E497ceBEDc2",schema:"evm:erc20"}}},arbitrum_sepolia:{type:e.BlockchainType.evm,network:a.Network.TESTNET,iBTC:{id:"arbitrum_sepolia:ibtc",name:"iBTC",symbol:"iBTC",decimals:8,icon:"https://garden.imgix.net/token-images/dlcBTCIcon.svg",chain:"evm:421614",htlc:{address:"0x7e8c18fa79bd4014cfCf49294Bf315139eD39f45",schema:"evm:htlc_erc20"},token:{address:"0x685437f025c5f33A94818408C286bc1F023201Fc",schema:"evm:erc20"}},WBTC:{id:"arbitrum_sepolia:wbtc",name:"Wrapped Bitcoin",symbol:"WBTC",decimals:8,icon:"https://garden.imgix.net/token-images/wbtc.svg",chain:"evm:421614",htlc:{address:"0xb5AE9785349186069C48794a763DB39EC756B1cF",schema:"evm:htlc_erc20"},token:{address:"0x1c287717c886794ac9f5DF3987195431Ceb3456E",schema:"evm:erc20"}},USDC:{id:"arbitrum_sepolia:usdc",name:"USD Coin",symbol:"USDC",decimals:6,icon:"https://garden.imgix.net/token-images/usdc.svg",chain:"evm:421614",htlc:{address:"0x8E12d730756457B99ce6E6AbFd60eBe751dA169B",schema:"evm:htlc_erc20"},token:{address:"0xC90Ad772eCc10a52a681ceDAE6EbBD3470A0c829",schema:"evm:erc20"}},SEED:{id:"arbitrum_sepolia:seed",name:"Seed",symbol:"SEED",decimals:18,icon:"https://garden.imgix.net/token-images/SEED.svg",chain:"evm:421614",htlc:{address:"0xFBD30cB9313fe580031A7E0258693E1cec002803",schema:"evm:htlc_erc20"},token:{address:"0x432B43764548c3E47eA65aAdeB91D75C84DBcC2c",schema:"evm:erc20"}}},base_sepolia:{type:e.BlockchainType.evm,network:a.Network.TESTNET,iBTC:{id:"base_sepolia:ibtc",name:"iBTC",symbol:"iBTC",decimals:8,icon:"https://garden.imgix.net/token-images/dlcBTCIcon.svg",chain:"evm:84532",htlc:{address:"0x46F1Ba9C9d89C34F9dbC4085F6B1f9965c589ca1",schema:"evm:htlc_erc20"},token:{address:"0x0b0D554D9573bAe1a7556d220847f45182918B28",schema:"evm:erc20"}},WBTC:{id:"base_sepolia:wbtc",name:"Wrapped Bitcoin",symbol:"WBTC",decimals:8,icon:"https://garden.imgix.net/token-images/wbtc.svg",chain:"evm:84532",htlc:{address:"0xd1E0Ba2b165726b3a6051b765d4564d030FDcf50",schema:"evm:htlc_erc20"},token:{address:"0xD8a6E3FCA403d79b6AD6216b60527F51cc967D39",schema:"evm:erc20"}},USDT:{id:"base_sepolia:usdt",name:"Tether USD",symbol:"USDT",decimals:6,icon:"https://garden.imgix.net/token-images/usdt.svg",chain:"evm:84532",htlc:{address:"0x917cfef972d667dC0FeC76806cB5623585B81493",schema:"evm:htlc_erc20"},token:{address:"0xeaE7721d779276eb0f5837e2fE260118724a2Ba4",schema:"evm:erc20"}},USDC:{id:"base_sepolia:usdc",name:"USD Coin",symbol:"USDC",decimals:6,icon:"https://garden.imgix.net/token-images/usdc.svg",chain:"evm:84532",htlc:{address:"0x730Be401ef981D199a0560C87DfdDaFd3EC1C493",schema:"evm:htlc_erc20"},token:{address:"0x1ac7A0ebf13a996D5915e212900bE2d074f94988",schema:"evm:erc20"}}},bera_testnet:{type:e.BlockchainType.evm,network:a.Network.TESTNET},citrea_testnet:{type:e.BlockchainType.evm,network:a.Network.TESTNET,WCBTC:{id:"citrea_testnet:wcbtc",name:"Wrapped Citrea Bitcoin",symbol:"WCBTC",decimals:18,icon:"https://garden.imgix.net/token-images/wbtc.svg",chain:"evm:5115",htlc:{address:"0xD8e99df8cf77E7383c2f2a84bC6384b2DF88CAd3",schema:"evm:htlc_erc20"},token:{address:"0x8d0c9d1c17aE5e40ffF9bE350f57840E9E66Cd93",schema:"evm:erc20"}},WBTC:{id:"citrea_testnet:wbtc",name:"Wrapped Bitcoin",symbol:"WBTC",decimals:8,icon:"https://garden.imgix.net/token-images/wbtc.svg",chain:"evm:5115",htlc:{address:"0xd1E0Ba2b165726b3a6051b765d4564d030FDcf50",schema:"evm:htlc_erc20"},token:{address:"0x3edA22460259b29433704dda71cc921F528165Ea",schema:"evm:erc20"}},CBTC:{id:"citrea_testnet:cbtc",name:"Citrea Bitcoin",symbol:"CBTC",decimals:18,icon:"https://garden.imgix.net/token-images/bitcoin.svg",chain:"evm:5115",htlc:{address:"0xE413743B51f3cC8b3ac24addf50D18fa138cB0Bb",schema:"evm:htlc"},token:null},CBBTC:{id:"citrea_testnet:cbbtc",name:"Coinbase Wrapped Bitcoin",symbol:"CBBTC",decimals:8,icon:"https://garden.imgix.net/token-images/bitcoin.svg",chain:"evm:5115",htlc:{address:"0x8656d38352CD90ca55881eBd0AF6822839b435A8",schema:"evm:htlc_erc20"},token:{address:"0xeAa998aF280a62Ae08BaE4f9fa59C9b30e6BD306",schema:"evm:erc20"}},USDC:{id:"citrea_testnet:usdc",name:"USD Coin",symbol:"USDC",decimals:6,icon:"https://garden.imgix.net/token-images/usdc.svg",chain:"evm:5115",htlc:{address:"0x730Be401ef981D199a0560C87DfdDaFd3EC1C493",schema:"evm:htlc_erc20"},token:{address:"0xCdA8661fDA031deFCc9BdD88C0e12669Cac47Fb0",schema:"evm:erc20"}},USDT:{id:"citrea_testnet:usdt",name:"Tether USD",symbol:"USDT",decimals:6,icon:"https://garden.imgix.net/token-images/usdt.svg",chain:"evm:5115",htlc:{address:"0x917cfef972d667dC0FeC76806cB5623585B81493",schema:"evm:htlc_erc20"},token:{address:"0xF5cFE09b852Ddb164cF6Db419B9c11aAb5F30cb6",schema:"evm:erc20"}}},monad_testnet:{type:e.BlockchainType.evm,network:a.Network.TESTNET,cBBTC:{id:"monad_testnet:cbbtc",name:"Coinbase Wrapped Bitcoin",symbol:"cBBTC",decimals:8,icon:"https://garden.imgix.net/token-images/cbBTC.svg",chain:"evm:10143",htlc:{address:"0x8656d38352CD90ca55881eBd0AF6822839b435A8",schema:"evm:htlc_erc20"},token:{address:"0x6b6303fAb8eC7232b4f2a7b9fa58E5216F608fcb",schema:"evm:erc20"}},USDC:{id:"monad_testnet:usdc",name:"USD Coin",symbol:"USDC",decimals:6,icon:"https://garden.imgix.net/token-images/usdc.svg",chain:"evm:10143",htlc:{address:"0x730Be401ef981D199a0560C87DfdDaFd3EC1C493",schema:"evm:htlc_erc20"},token:{address:"0xf817257fed379853cde0fa4f97ab987181b1e5ea",schema:"evm:erc20"}}},starknet_sepolia:{type:e.BlockchainType.starknet,network:a.Network.TESTNET,WBTC:{id:"starknet_sepolia:wbtc",name:"Wrapped Bitcoin",symbol:"WBTC",decimals:8,icon:"https://garden.imgix.net/token-images/wbtc.svg",chain:"starknet:393402133025997798000961",htlc:{address:"0x06579d255314109429a4477d89629bc2b94f529ae01979c2f8014f9246482603",schema:"starknet:htlc_erc20"},token:{address:"0x496bef3ed20371382fbe0ca6a5a64252c5c848f9f1f0cccf8110fc4def912d5",schema:"starknet:erc20"}}},sui_testnet:{type:e.BlockchainType.sui,network:a.Network.TESTNET,SUI:{id:"sui_testnet:sui",name:"SUI",symbol:"SUI",decimals:9,icon:"https://garden-finance.imgix.net/chain_images/sui.svg",chain:"sui",htlc:{address:"0x5c438715b7dcc02d12ab92449153a1e5ade2301620d5bf60aa748f006726d369",schema:null},token:{address:"0x2::sui::SUI",schema:null}}},hyperliquid_testnet:{type:e.BlockchainType.evm,network:a.Network.TESTNET},bnbchain_testnet:{type:e.BlockchainType.evm,network:a.Network.TESTNET,WBTC:{id:"bnbchain_testnet:wbtc",name:"Wrapped Bitcoin",symbol:"WBTC",decimals:8,icon:"https://garden.imgix.net/token-images/wbtc.svg",chain:"evm:97",htlc:{address:"0xd1E0Ba2b165726b3a6051b765d4564d030FDcf50",schema:"evm:htlc_erc20"},token:{address:"0x39f3294352208905fc6ebf033954E6c6455CdB4C",schema:"evm:erc20"}}},bitcoin:{type:e.BlockchainType.bitcoin,network:a.Network.MAINNET,BTC:{id:"bitcoin:btc",name:"Bitcoin",symbol:"BTC",decimals:8,icon:"https://garden.imgix.net/token-images/bitcoin.svg",chain:"bitcoin",htlc:null,token:null}},base:{type:e.BlockchainType.evm,network:a.Network.MAINNET,USDC:{id:"base:usdc",name:"USD Coin",symbol:"USDC",decimals:6,icon:"https://garden.imgix.net/token-images/usdc.svg",chain:"evm:8453",htlc:{address:"0x5fA58e4E89c85B8d678Ade970bD6afD4311aF17E",schema:"evm:htlc_erc20"},token:{address:"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",schema:"evm:erc20"}},cBBTC:{id:"base:cbbtc",name:"Coinbase Wrapped Bitcoin",symbol:"cBBTC",decimals:8,icon:"https://coin-images.coingecko.com/coins/images/51336/large/cbbtc.png?1730814747",chain:"evm:8453",htlc:{address:"0xe35d025d0f0d9492db4700FE8646f7F89150eC04",schema:"evm:htlc_erc20"},token:{address:"0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf",schema:"evm:erc20"}}},arbitrum:{type:e.BlockchainType.evm,network:a.Network.MAINNET,WBTC:{id:"arbitrum:wbtc",name:"Wrapped Bitcoin",symbol:"WBTC",decimals:8,icon:"https://garden.imgix.net/token-images/wbtc.svg",chain:"evm:42161",htlc:{address:"0xb5AE9785349186069C48794a763DB39EC756B1cF",schema:"evm:htlc_erc20"},token:{address:"0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",schema:"evm:erc20"}},USDC:{id:"arbitrum:usdc",name:"USD Coin",symbol:"USDC",decimals:6,icon:"https://garden.imgix.net/token-images/usdc.svg",chain:"evm:42161",htlc:{address:"0x8E12d730756457B99ce6E6AbFd60eBe751dA169B",schema:"evm:htlc_erc20"},token:{address:"0xaf88d065e77c8cC2239327C5EDb3A432268e5831",schema:"evm:erc20"}},SEED:{id:"arbitrum:seed",name:"SEED",symbol:"SEED",decimals:18,icon:"https://garden.imgix.net/token-images/SEED.svg",chain:"evm:42161",htlc:{address:"0xFBD30cB9313fe580031A7E0258693E1cec002803",schema:"evm:htlc_erc20"},token:{address:"0x86f65121804D2Cdbef79F9f072D4e0c2eEbABC08",schema:"evm:erc20"}}},ethereum:{type:e.BlockchainType.evm,network:a.Network.MAINNET,ETH:{id:"ethereum:eth",name:"Ethereum",symbol:"ETH",decimals:18,icon:"https://garden.imgix.net/chain_images/ethereum.svg",chain:"evm:1",htlc:{address:"0xE413743B51f3cC8b3ac24addf50D18fa138cB0Bb",schema:"evm:htlc"},token:null},USDC:{id:"ethereum:usdc",name:"USD Coin",symbol:"USDC",decimals:6,icon:"https://garden.imgix.net/token-images/usdc.svg",chain:"evm:1",htlc:{address:"0x5fA58e4E89c85B8d678Ade970bD6afD4311aF17E",schema:"evm:htlc_erc20"},token:{address:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",schema:"evm:erc20"}},WBTC:{id:"ethereum:wbtc",name:"Wrapped Bitcoin",symbol:"WBTC",decimals:8,icon:"https://garden.imgix.net/token-images/wbtc.svg",chain:"evm:1",htlc:{address:"0xD781a2abB3FCB9fC0D1Dd85697c237d06b75fe95",schema:"evm:htlc_erc20"},token:{address:"0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",schema:"evm:erc20"}},cBBTC:{id:"ethereum:cbbtc",name:"Coinbase Wrapped Bitcoin",symbol:"cBBTC",decimals:8,icon:"https://garden.imgix.net/token-images/cbBTC.svg",chain:"evm:1",htlc:{address:"0xe35d025d0f0d9492db4700FE8646f7F89150eC04",schema:"evm:htlc_erc20"},token:{address:"0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf",schema:"evm:erc20"}},SEED:{id:"ethereum:seed",name:"SEED",symbol:"SEED",decimals:18,icon:"https://garden.imgix.net/token-images/SEED.svg",chain:"evm:1",htlc:{address:"0xCE511De667885f92B8c36fcfC79C3B5bEb875463",schema:"evm:htlc_erc20"},token:{address:"0x5eed99d066a8CaF10f3E4327c1b3D8b673485eED",schema:"evm:erc20"}}},solana:{type:e.BlockchainType.solana,network:a.Network.MAINNET,SOL:{id:"solana:sol",name:"Solana",symbol:"SOL",decimals:9,icon:"https://garden-finance.imgix.net/chain_images/solana.png",chain:"solana:101",htlc:{address:"2bag6xpshpvPe7SJ9nSDLHpxqhEAoHPGpEkjNSv7gxoF",schema:"solana:htlc"},token:null},USDC:{id:"solana:usdc",name:"USD Coin",symbol:"USDC",decimals:6,icon:"https://garden.imgix.net/token-images/usdc.svg",chain:"solana:101",htlc:{address:"gdnvdMCHJgnidtU7SL8RkRshHPvDJU1pdfZEpoLvqdU",schema:"solana:htlc_spltoken"},token:{address:"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",schema:"primary"}},cBBTC:{id:"solana:cbbtc",name:"Coinbase Wrapped Bitcoin",symbol:"cBBTC",decimals:8,icon:"https://garden.imgix.net/token-images/cbBTC.svg",chain:"solana:101",htlc:{address:"gdnvdMCHJgnidtU7SL8RkRshHPvDJU1pdfZEpoLvqdU",schema:"solana:htlc_spltoken"},token:{address:"cbbtcf3aa214zXHbiAZQwf4122FBYbraNdFqgw4iMij",schema:"primary"}}},bera:{type:e.BlockchainType.evm,network:a.Network.MAINNET,LBTC:{id:"bera:lbtc",name:"Lombard Bitcoin",symbol:"LBTC",decimals:8,icon:"https://garden.imgix.net/token-images/LBTC.svg",chain:"evm:80094",htlc:{address:"0x84A396920d8B8CA2e69bD9503Bc1B2f73f1b8b33",schema:"evm:htlc_erc20"},token:{address:"0xecAc9C5F704e954931349Da37F60E39f515c11c1",schema:"evm:erc20"}}},starknet:{type:e.BlockchainType.starknet,network:a.Network.MAINNET,WBTC:{id:"starknet:wbtc",name:"Wrapped Bitcoin",symbol:"WBTC",decimals:8,icon:"https://garden.imgix.net/token-images/wbtc.svg",chain:"starknet:23448594291968334",htlc:{address:"0x7defd8eb3b770005ab1ca5f89ad31f98fb5bc3c52deaeafd130be3b49f967b4",schema:"starknet:htlc_erc20"},token:{address:"0x3fe2b97c1fd336e750087d68b9b867997fd64a2661ff3ca5a7c771641e8e7ac",schema:"starknet:erc20"}}},sui:{type:e.BlockchainType.sui,network:a.Network.MAINNET,SUI:{id:"sui:sui",name:"SUI",symbol:"SUI",decimals:9,icon:"https://garden-finance.imgix.net/chain_images/sui.svg",chain:"sui:0",htlc:{address:"0xa4f4e653547e98d4b541378e14db2393a09aff4b829f158b133d2eb3c3a942b5",schema:null},token:{address:"0x2::sui::SUI",schema:null}}},hyperliquid:{type:e.BlockchainType.evm,network:a.Network.MAINNET,uBTC:{id:"hyperliquid:ubtc",name:"Unit Bitcoin",symbol:"uBTC",decimals:8,icon:"https://garden.imgix.net/token-images/bitcoin.svg",chain:"evm:999",htlc:{address:"0xDC74a45e86DEdf1fF7c6dac77e0c2F082f9E4F72",schema:"evm:htlc_erc20"},token:{address:"0x9FDBdA0A5e284c32744D2f17Ee5c74B284993463",schema:"evm:erc20"}}},unichain:{type:e.BlockchainType.evm,network:a.Network.MAINNET,WBTC:{id:"unichain:wbtc",name:"Wrapped Bitcoin",symbol:"WBTC",decimals:8,icon:"https://garden.imgix.net/token-images/wbtc.svg",chain:"evm:130",htlc:{address:"0xD781a2abB3FCB9fC0D1Dd85697c237d06b75fe95",schema:"evm:htlc_erc20"},token:{address:"0x927B51f251480a681271180DA4de28D44EC4AfB8",schema:"evm:erc20"}},USDC:{id:"unichain:usdc",name:"USD Coin",symbol:"USDC",decimals:6,icon:"https://garden.imgix.net/token-images/usdc.svg",chain:"evm:130",htlc:{address:"0x5fA58e4E89c85B8d678Ade970bD6afD4311aF17E",schema:"evm:htlc_erc20"},token:{address:"0x078D782b760474a361dDA0AF3839290b0EF57AD6",schema:"evm:erc20"}}},corn:{type:e.BlockchainType.evm,network:a.Network.MAINNET,BTCN:{id:"corn:btcn",name:"Bitcorn",symbol:"BTCN",decimals:18,icon:"https://garden.imgix.net/token-images/bitcorn.svg",chain:"evm:21000000",htlc:{address:"0xE413743B51f3cC8b3ac24addf50D18fa138cB0Bb",schema:"evm:htlc"},token:null}},botanix:{type:e.BlockchainType.evm,network:a.Network.MAINNET,BTC:{id:"botanix:btc",name:"Botanix Bitcoin",symbol:"BTC",decimals:18,icon:"https://garden.imgix.net/token-images/bitcoin.svg",chain:"evm:3637",htlc:{address:"0xE413743B51f3cC8b3ac24addf50D18fa138cB0Bb",schema:"evm:htlc"},token:null}},bnbchain:{type:e.BlockchainType.evm,network:a.Network.MAINNET,BTCB:{id:"bnbchain:btcb",name:"Binance Bitcoin",symbol:"BTCB",decimals:18,icon:"https://garden.imgix.net/token-images/bitcoin.svg",chain:"evm:56",htlc:{address:"0xe74784E5A45528fDEcB257477DD6bd31c8ef0761",schema:"evm:htlc_erc20"},token:{address:"0x7130d2A12B9BCbFAe4f2634d864A1Ee1Ce3Ead9c",schema:"evm:erc20"}},USDC:{id:"bnbchain:usdc",name:"USD Coin",symbol:"USDC",decimals:18,icon:"https://garden.imgix.net/token-images/usdc.svg",chain:"evm:56",htlc:{address:"0x5fA58e4E89c85B8d678Ade970bD6afD4311aF17E",schema:"evm:htlc_erc20"},token:{address:"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",schema:"evm:erc20"}},BNB:{id:"bnbchain:bnb",name:"BNB",symbol:"BNB",decimals:18,icon:"https://garden-finance.imgix.net/chain_images/bnb.png",chain:"evm:56",htlc:{address:"0xE413743B51f3cC8b3ac24addf50D18fa138cB0Bb",schema:"evm:htlc"},token:null}},core:{type:e.BlockchainType.evm,network:a.Network.MAINNET,WBTC:{id:"core:wbtc",name:"Wrapped Bitcoin",symbol:"WBTC",decimals:8,icon:"https://garden.imgix.net/token-images/wbtc.svg",chain:"evm:1116",htlc:{address:"0xD781a2abB3FCB9fC0D1Dd85697c237d06b75fe95",schema:"evm:htlc_erc20"},token:{address:"0x5832f53d147b3d6Cd4578B9CBD62425C7ea9d0Bd",schema:"evm:erc20"}}},hypercore:{type:e.BlockchainType.evm,network:a.Network.MAINNET},hypercore_testnet:{type:e.BlockchainType.evm,network:a.Network.TESTNET}},T=Object.keys(n).reduce((c,t)=>(c[t]=t,c),{}),f=v.buildAssetsWithChain(n),E=c=>n[c].network===a.Network.MAINNET;function i(c){return t=>n[t].type===c}const h=i(e.BlockchainType.evm),l=i(e.BlockchainType.bitcoin),b=i(e.BlockchainType.solana),B=i(e.BlockchainType.starknet),k=i(e.BlockchainType.sui),D=c=>n[c].type,d={[e.BlockchainType.evm]:"eth",[e.BlockchainType.solana]:"sol",[e.BlockchainType.sui]:"sui"},g=(c,t)=>h(c)&&t.toLowerCase()===d[e.BlockchainType.evm],C=(c,t)=>b(c)&&t.toLowerCase()===d[e.BlockchainType.solana],p=(c,t)=>k(c)&&t.toLowerCase()===d[e.BlockchainType.sui],x=c=>{const t=c.chain,m=c.symbol;return g(t,m)||C(t,m)||l(t)||p(t,m)||!B(t)};exports.Assets=f;exports.Chains=T;exports.Config=n;exports.NATIVE_TOKENS=d;exports.OrderLifecycle=r;exports.OrderStatus=o;exports.getBlockchainType=D;exports.is=i;exports.isBitcoin=l;exports.isEVM=h;exports.isEvmNativeToken=g;exports.isMainnet=E;exports.isNativeToken=x;exports.isSolana=b;exports.isSolanaNativeToken=C;exports.isStarknet=B;exports.isSui=k;exports.isSuiNativeToken=p;
package/dist/index4.js CHANGED
@@ -916,40 +916,48 @@ const s = {
916
916
  schema: "evm:erc20"
917
917
  }
918
918
  }
919
+ },
920
+ hypercore: {
921
+ type: e.evm,
922
+ network: c.MAINNET
923
+ },
924
+ hypercore_testnet: {
925
+ type: e.evm,
926
+ network: c.TESTNET
919
927
  }
920
928
  }, _ = Object.keys(s).reduce(
921
929
  (a, t) => (a[t] = t, a),
922
930
  {}
923
- ), F = g(s), w = (a) => s[a].network === c.MAINNET;
931
+ ), w = g(s), F = (a) => s[a].network === c.MAINNET;
924
932
  function n(a) {
925
933
  return (t) => s[t].type === a;
926
934
  }
927
- const v = n(e.evm), p = n(e.bitcoin), f = n(e.solana), k = n(e.starknet), E = n(e.sui), U = (a) => s[a].type, d = {
935
+ const v = n(e.evm), p = n(e.bitcoin), f = n(e.solana), k = n(e.starknet), E = n(e.sui), N = (a) => s[a].type, d = {
928
936
  [e.evm]: "eth",
929
937
  [e.solana]: "sol",
930
938
  [e.sui]: "sui"
931
- }, D = (a, t) => v(a) && t.toLowerCase() === d[e.evm], x = (a, t) => f(a) && t.toLowerCase() === d[e.solana], T = (a, t) => E(a) && t.toLowerCase() === d[e.sui], N = (a) => {
939
+ }, D = (a, t) => v(a) && t.toLowerCase() === d[e.evm], T = (a, t) => f(a) && t.toLowerCase() === d[e.solana], x = (a, t) => E(a) && t.toLowerCase() === d[e.sui], U = (a) => {
932
940
  const t = a.chain, i = a.symbol;
933
- return D(t, i) || x(t, i) || p(t) || T(t, i) || // Starknet doesn't have a native token
941
+ return D(t, i) || T(t, i) || p(t) || x(t, i) || // Starknet doesn't have a native token
934
942
  !k(t);
935
943
  };
936
944
  export {
937
- F as Assets,
945
+ w as Assets,
938
946
  _ as Chains,
939
947
  s as Config,
940
948
  d as NATIVE_TOKENS,
941
949
  B as OrderLifecycle,
942
950
  C as OrderStatus,
943
- U as getBlockchainType,
951
+ N as getBlockchainType,
944
952
  n as is,
945
953
  p as isBitcoin,
946
954
  v as isEVM,
947
955
  D as isEvmNativeToken,
948
- w as isMainnet,
949
- N as isNativeToken,
956
+ F as isMainnet,
957
+ U as isNativeToken,
950
958
  f as isSolana,
951
- x as isSolanaNativeToken,
959
+ T as isSolanaNativeToken,
952
960
  k as isStarknet,
953
961
  E as isSui,
954
- T as isSuiNativeToken
962
+ x as isSuiNativeToken
955
963
  };
@@ -11,5 +11,5 @@ export type { ChainAssetString, AssetLike } from './lib/chainAsset/chainAsset';
11
11
  export { OrderAction, ParseOrderStatus, isCompleted, isDeadlinePassed, parseAction, } from './lib/orderStatus/orderStatus';
12
12
  export { AssetManager } from './lib/assetManager/AssetManager';
13
13
  export type { ApiChainData, ApiChainsResponse, AssetManagerState, BaseChainData, ChainData, FiatResponse, } from './lib/assetManager/types';
14
- export { RouteValidator, buildRouteMatrix, } from './lib/assetManager/routeValidator/routeValidator';
14
+ export { RouteValidator } from './lib/assetManager/routeValidator/routeValidator';
15
15
  export type { RoutePolicy } from './lib/assetManager/routeValidator/routeValidator';
@@ -1,3 +1,4 @@
1
+ import { AsyncResult, IAuth } from '@gardenfi/utils';
1
2
  import { RouteValidator } from './routeValidator/routeValidator';
2
3
  import { Assets, ChainData, Chains } from './types';
3
4
  import { ChainAsset } from '../chainAsset/chainAsset';
@@ -6,33 +7,20 @@ import { Asset, Chain } from '../constants/asset.types';
6
7
  /**
7
8
  * AssetManager
8
9
  *
9
- * A comprehensive manager for handling asset and chain data across the application.
10
- * Responsibilities:
11
- * - Fetching and caching asset/chain data from API
12
- * - Managing route validation between assets
13
- * - Managing asset selection state
14
- * - Building and maintaining route matrices for performance optimization
10
+ * It fetches asset data from our API, caches it locally, and provides methods
11
+ * to check if routes between assets are valid. Also builds a route matrix
12
+ * to make route lookups fast.
15
13
  */
16
14
  export declare class AssetManager {
17
- private _allChains;
18
- private _allAssets;
19
- private _assets;
20
- private _chains;
21
- private _routeValidator;
22
- private _routeMatrix;
23
- private _isLoading;
24
- private _error;
15
+ assets: Assets | null;
16
+ chains: Chains | null;
17
+ routeValidator: RouteValidator;
18
+ routeMatrix: Record<string, ChainAsset[]> | null;
19
+ isLoading: boolean;
20
+ error: string | null;
25
21
  private readonly url;
26
- private apiKey;
27
- constructor(url: string, apiKey: string);
28
- get allChains(): Chains | null;
29
- get allAssets(): Assets | null;
30
- get assets(): Assets | null;
31
- get chains(): Chains | null;
32
- get routeValidator(): RouteValidator | null;
33
- get routeMatrix(): Record<string, ChainAsset[]> | null;
34
- get isLoading(): boolean;
35
- get error(): string | null;
22
+ private auth;
23
+ constructor(url: string, apiKey: IAuth | string);
36
24
  /**
37
25
  * Initialize the AssetManager by fetching all required data
38
26
  */
@@ -40,15 +28,15 @@ export declare class AssetManager {
40
28
  /**
41
29
  * Fetch and cache asset and chain data from API
42
30
  */
43
- fetchAndSetAssetsAndChains(): Promise<void>;
31
+ fetchAndSetAssetsAndChains(): AsyncResult<string, string>;
44
32
  /**
45
33
  * Check if a swap route from one asset to another is valid
46
34
  */
47
- isRouteValid(from: Asset, to: Asset): boolean;
35
+ isRouteValid(from: Asset, to: Asset): Promise<boolean>;
48
36
  /**
49
37
  * Get all valid destination assets for a given source asset
50
38
  */
51
- getValidDestinations(fromAsset: Asset): Asset[];
39
+ getValidDestinations(asset: Asset): Asset[];
52
40
  /**
53
41
  * Get asset by chain and token address
54
42
  */
@@ -65,14 +53,10 @@ export declare class AssetManager {
65
53
  * Get chain data by chain identifier
66
54
  */
67
55
  getChain(chain: Chain): ChainData | undefined;
68
- /**
69
- * Initialize the route validator
70
- */
71
- private initializeRouteValidator;
72
56
  /**
73
57
  * Build route matrix for fast O(1) route lookups
74
58
  */
75
- private buildRouteMatrix;
59
+ buildRouteMatrix(): Promise<void>;
76
60
  /**
77
61
  * Process raw API data into structured format
78
62
  */
@@ -89,8 +73,4 @@ export declare class AssetManager {
89
73
  * Refresh all data
90
74
  */
91
75
  refresh(): Promise<void>;
92
- /**
93
- * Clear all cached data
94
- */
95
- clear(): void;
96
76
  }
@@ -1,31 +1,80 @@
1
+ import { AsyncResult, IAuth } from '@gardenfi/utils';
1
2
  import { ChainAsset } from '../../chainAsset/chainAsset';
3
+ import { default as NodeCache } from 'node-cache';
2
4
 
3
- interface RoutePolicy {
5
+ type RoutePolicy = {
4
6
  default: 'open' | 'closed';
5
7
  isolation_groups: string[];
6
8
  blacklist_pairs: string[];
7
9
  whitelist_overrides: string[];
8
- }
10
+ };
9
11
  declare class RouteValidator {
10
- private readonly apiBaseUrl;
11
- private readonly apiKey;
12
- private policy;
13
- constructor(apiBaseUrl: string, apiKey: string);
14
- loadPolicy(): Promise<void>;
15
- isValidRoute(fromAsset: ChainAsset, toAsset: ChainAsset): boolean;
16
- isAssetInIsolationGroup(asset: ChainAsset): boolean;
17
- getValidDestinations(fromAsset: ChainAsset, allAssets: ChainAsset[]): ChainAsset[];
18
- getAllValidRoutes(assets: ChainAsset[]): Array<{
12
+ policy: NodeCache;
13
+ private static readonly POLICY_CACHE_KEY;
14
+ private apiBaseUrl;
15
+ private auth;
16
+ constructor(apiBaseUrl: string, apiKey: string | IAuth);
17
+ getPolicy(): RoutePolicy | undefined;
18
+ setPolicy(policy: RoutePolicy): RoutePolicy;
19
+ /**
20
+ * Loads the current route policy, cached or via API.
21
+ */
22
+ loadPolicy(): AsyncResult<RoutePolicy, string>;
23
+ /**
24
+ * Checks if a given route is valid based on all route rules.
25
+ */
26
+ isValidRoute(fromAsset: ChainAsset, toAsset: ChainAsset): Promise<boolean>;
27
+ /**
28
+ * Returns true if asset is part of any isolation group rule.
29
+ */
30
+ isAssetInIsolationGroup(asset: ChainAsset): Promise<boolean>;
31
+ /**
32
+ * Returns all valid destinations for a given source asset.
33
+ */
34
+ getValidDestinations(fromAsset: ChainAsset, allAssets: ChainAsset[]): Promise<ChainAsset[]>;
35
+ /**
36
+ * Returns every valid route (from-to pair) among the provided assets.
37
+ */
38
+ getAllValidRoutes(assets: ChainAsset[]): Promise<Array<{
19
39
  from: ChainAsset;
20
40
  to: ChainAsset;
21
- }>;
22
- private ensurePolicyLoaded;
23
- private findIsolationGroup;
24
- private matchesIsolationGroup;
25
- private matchesPatternList;
26
- private matchesRoutePattern;
27
- private parsePattern;
41
+ }>>;
42
+ /**
43
+ * Turns policy string rules into sorted ParsedRule objects.
44
+ */
45
+ private preprocessRules;
46
+ /**
47
+ * Parses a rule string (e.g. "ethereum:usdc -> base:usdt") into parts.
48
+ */
49
+ private parseRule;
50
+ /**
51
+ * Gives a specificity score to a rule pattern for prioritizing.
52
+ */
53
+ private calculateSpecificity;
54
+ /**
55
+ * Finds the first matching rule for an asset given the rule "side".
56
+ */
57
+ private findMatchingRule;
58
+ /**
59
+ * Checks if a given toAsset matches the rule's destination side.
60
+ */
61
+ private matchesRuleDestination;
62
+ /**
63
+ * Checks if a given fromAsset matches the rule's source side.
64
+ */
65
+ private matchesRuleSource;
66
+ /**
67
+ * Checks if any rule in a list matches fromAsset and toAsset.
68
+ */
69
+ private matchesRuleList;
70
+ /**
71
+ * Checks if a rule matches fromAsset and toAsset (forward or backward if bidirectional).
72
+ */
73
+ private matchesRule;
74
+ /**
75
+ * Checks if an asset string matches a rule's pattern (wildcards supported).
76
+ */
28
77
  private matchesAssetPattern;
78
+ buildRouteMatrix(assets: ChainAsset[]): Promise<Record<string, ChainAsset[]>>;
29
79
  }
30
- declare function buildRouteMatrix(assets: ChainAsset[], validator: RouteValidator): Record<string, ChainAsset[]>;
31
- export { RouteValidator, buildRouteMatrix, type RoutePolicy };
80
+ export { RouteValidator, type RoutePolicy };
@@ -0,0 +1,6 @@
1
+ import { ChainAsset } from '../chainAsset/chainAsset';
2
+
3
+ export declare function parseAssetNameSymbol(input: string | undefined, assetId?: string | ChainAsset, fallbackSymbol?: string): {
4
+ name: string;
5
+ symbol: string;
6
+ };
@@ -974,6 +974,14 @@ export declare const Config: {
974
974
  };
975
975
  };
976
976
  };
977
+ readonly hypercore: {
978
+ readonly type: BlockchainType.evm;
979
+ readonly network: Network.MAINNET;
980
+ };
981
+ readonly hypercore_testnet: {
982
+ readonly type: BlockchainType.evm;
983
+ readonly network: Network.TESTNET;
984
+ };
977
985
  };
978
986
  export declare const Chains: Record<Chain, Chain>;
979
987
  export declare const Assets: import('./utils').AssetsType<{
@@ -1926,10 +1934,18 @@ export declare const Assets: import('./utils').AssetsType<{
1926
1934
  };
1927
1935
  };
1928
1936
  };
1937
+ readonly hypercore: {
1938
+ readonly type: BlockchainType.evm;
1939
+ readonly network: Network.MAINNET;
1940
+ };
1941
+ readonly hypercore_testnet: {
1942
+ readonly type: BlockchainType.evm;
1943
+ readonly network: Network.TESTNET;
1944
+ };
1929
1945
  }>;
1930
1946
  export declare const isMainnet: (chain: Chain) => boolean;
1931
1947
  export declare function is<T extends BlockchainType>(type: T): (chain: Chain) => chain is Extract<Chain, ChainsByBlockchainType<T>>;
1932
- export declare const isEVM: (chain: Chain) => chain is "arbitrum_localnet" | "ethereum_localnet" | "ethereum_sepolia" | "arbitrum_sepolia" | "base_sepolia" | "bera_testnet" | "citrea_testnet" | "monad_testnet" | "hyperliquid_testnet" | "bnbchain_testnet" | "base" | "arbitrum" | "ethereum" | "bera" | "hyperliquid" | "unichain" | "corn" | "botanix" | "bnbchain" | "core";
1948
+ export declare const isEVM: (chain: Chain) => chain is "arbitrum_localnet" | "ethereum_localnet" | "ethereum_sepolia" | "arbitrum_sepolia" | "base_sepolia" | "bera_testnet" | "citrea_testnet" | "monad_testnet" | "hyperliquid_testnet" | "bnbchain_testnet" | "base" | "arbitrum" | "ethereum" | "bera" | "hyperliquid" | "unichain" | "corn" | "botanix" | "bnbchain" | "core" | "hypercore" | "hypercore_testnet";
1933
1949
  export declare const isBitcoin: (chain: Chain) => chain is "bitcoin" | "bitcoin_regtest" | "bitcoin_testnet";
1934
1950
  export declare const isSolana: (chain: Chain) => chain is "solana_localnet" | "solana_testnet" | "solana";
1935
1951
  export declare const isStarknet: (chain: Chain) => chain is "starknet_devnet" | "starknet_sepolia" | "starknet";
@@ -14,7 +14,7 @@ export type AddressSchema = {
14
14
  schema: string | null;
15
15
  };
16
16
  export type Asset = {
17
- id: ChainAsset;
17
+ id: ChainAsset | string;
18
18
  name: string;
19
19
  chain: Chain;
20
20
  symbol: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gardenfi/orderbook",
3
- "version": "2.5.3-beta.7",
3
+ "version": "2.5.3-beta.8",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -30,6 +30,7 @@
30
30
  "@coral-xyz/anchor": "^0.31.1",
31
31
  "@gardenfi/utils": "2.5.3",
32
32
  "bufferutil": "^4.0.8",
33
+ "node-cache": "^5.1.2",
33
34
  "siwe": "^2.1.4",
34
35
  "utf-8-validate": "^6.0.3",
35
36
  "ws": "^8.14.2"