@gardenfi/orderbook 2.5.3-beta.10 → 2.5.3-beta.12

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 o=require("@gardenfi/utils"),_=require("./index11.cjs"),C=require("./index4.cjs"),a=require("./index8.cjs"),y=require("./index12.cjs"),f=Object.keys(C.Config);class m{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 o.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 this.fetchAndSetAssetsAndChains()}async fetchAndSetAssetsAndChains(){try{this._isLoading=!0,this._error=null,await this.initializeRouteValidator();const s=this.url.endpoint("/v2/chains"),t=await o.Fetcher.get(s);if(t.error)return o.Err(t.error);if(!t.result)return o.Err("Failed to fetch chains data");const{allChains:i,allAssets:e,assets:n,chains:r}=this.processApiData(t.result);return this._allChains=i,this._allAssets=e,this._assets=n,this._chains=r,await this.buildRouteMatrix(),o.Ok("AssetManager initialized successfully")}catch(s){return o.Err(`Failed to fetch assets data: ${s}`)}finally{this._isLoading=!1}}async 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 i=a.ChainAsset.from(s.id),e=a.ChainAsset.from(t.id);return await this._routeValidator.isValidRoute(i,e)}catch(i){return console.error("Error in isRouteValid:",i),!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(i=>{const e=i.toString();return Object.values(this._assets).find(n=>a.ChainAsset.from(n).toString()===e)}).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=a.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(i=>i.symbol.toLowerCase().includes(t)||i.name.toLowerCase().includes(t))}getChain(s){if(this._chains)return this._chains[s]}async initializeRouteValidator(){this._routeValidator=new _.RouteValidator(this.url.toString(),this.apiKey),await this._routeValidator.loadPolicy()}async buildRouteMatrix(){if(!this._allAssets||!this._routeValidator)return;const s=Object.values(this._allAssets).map(t=>{if(!t.id)return null;try{return a.ChainAsset.from(t.id)}catch{return null}}).filter(t=>t!==null);this._routeMatrix=await _.buildRouteMatrix(s,this._routeValidator)}processApiData(s){const t={},i={},e={},n={};for(const r of s){const l=this.parseChainIdentifier(r.chain);if(!l||!f.includes(l))continue;const u={...r,name:this.formatChainName(r.chain),chain:l};t[l]=u;for(const h of r.assets){const c=a.ChainAsset.from(h.id).toString(),{name:A,symbol:g}=y.parseAssetNameSymbol(h.name,h.id),d={...h,id:a.ChainAsset.from(h.id),chain:l,name:A,symbol:g};i[c]=d,e[c]=d}n[l]=u}return{allChains:t,allAssets:i,assets:e,chains:n}}parseChainIdentifier(s){return f.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=m;
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,39 +1,12 @@
1
- import { Url as g, Fetcher as m, Err as h, Ok as C } from "@gardenfi/utils";
2
- import { RouteValidator as p, buildRouteMatrix as y } from "./index11.js";
3
- import { Config as V } from "./index4.js";
4
- import { ChainAsset as a } from "./index8.js";
5
- import { parseAssetNameSymbol as b } from "./index12.js";
6
- const _ = Object.keys(V);
7
- class O {
8
- constructor(s, t) {
9
- 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 g(s), this.apiKey = t;
10
- }
11
- // ============================================
12
- // Getters
13
- // ============================================
14
- get allChains() {
15
- return this._allChains;
16
- }
17
- get allAssets() {
18
- return this._allAssets;
19
- }
20
- get assets() {
21
- return this._assets;
22
- }
23
- get chains() {
24
- return this._chains;
25
- }
26
- get routeValidator() {
27
- return this._routeValidator;
28
- }
29
- get routeMatrix() {
30
- return this._routeMatrix;
31
- }
32
- get isLoading() {
33
- return this._isLoading;
34
- }
35
- get error() {
36
- 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);
37
10
  }
38
11
  // ============================================
39
12
  // Initialization Methods
@@ -42,25 +15,28 @@ class O {
42
15
  * Initialize the AssetManager by fetching all required data
43
16
  */
44
17
  async initialize() {
45
- await this.fetchAndSetAssetsAndChains();
18
+ await this.fetchAndSetAssetsAndChains(), await this.routeValidator.loadPolicy();
46
19
  }
47
20
  /**
48
21
  * Fetch and cache asset and chain data from API
49
22
  */
50
23
  async fetchAndSetAssetsAndChains() {
51
24
  try {
52
- this._isLoading = !0, this._error = null, await this.initializeRouteValidator();
53
- const s = this.url.endpoint("/v2/chains"), t = await m.get(s);
54
- if (t.error) return h(t.error);
55
- if (!t.result) return h("Failed to fetch chains data");
56
- const { allChains: i, allAssets: e, assets: n, chains: r } = this.processApiData(
57
- t.result
58
- );
59
- return this._allChains = i, this._allAssets = e, this._assets = n, this._chains = r, await this.buildRouteMatrix(), C("AssetManager initialized successfully");
60
- } catch (s) {
61
- return h(`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}`);
62
38
  } finally {
63
- this._isLoading = !1;
39
+ this.isLoading = !1;
64
40
  }
65
41
  }
66
42
  // ============================================
@@ -69,34 +45,25 @@ class O {
69
45
  /**
70
46
  * Check if a swap route from one asset to another is valid
71
47
  */
72
- async isRouteValid(s, t) {
73
- if (!this._routeValidator || !s || !t || !s.id || !t.id)
74
- return console.warn("Missing routeValidator, from, or to. Returning true."), !0;
75
- try {
76
- const i = a.from(s.id), e = a.from(t.id);
77
- return await this._routeValidator.isValidRoute(
78
- i,
79
- e
80
- );
81
- } catch (i) {
82
- return console.error("Error in isRouteValid:", i), !0;
83
- }
48
+ async isRouteValid(t, s) {
49
+ return await this.routeValidator.isValidRoute(
50
+ r.from(t.id),
51
+ r.from(s.id)
52
+ );
84
53
  }
85
54
  /**
86
55
  * Get all valid destination assets for a given source asset
87
56
  */
88
- getValidDestinations(s) {
89
- if (!this._routeMatrix || !this._assets || !s.id)
90
- return Object.values(this._assets || {});
91
- try {
92
- const t = this._routeMatrix[s.id.toString()];
93
- return t ? t.map((i) => {
94
- const e = i.toString();
95
- return Object.values(this._assets).find((n) => a.from(n).toString() === e);
96
- }).filter(Boolean) : Object.values(this._assets);
97
- } catch (t) {
98
- return console.error("Error in getValidDestinations:", t), Object.values(this._assets || {});
99
- }
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) : [];
100
67
  }
101
68
  // ============================================
102
69
  // Asset Query Methods
@@ -104,105 +71,95 @@ class O {
104
71
  /**
105
72
  * Get asset by chain and token address
106
73
  */
107
- getAsset(s) {
108
- if (!this._assets) return;
109
- const t = a.from(s).toString();
110
- return this._assets[t];
74
+ getAsset(t) {
75
+ if (!this.assets) return;
76
+ const s = r.from(t).toString();
77
+ return this.assets[s];
111
78
  }
112
79
  /**
113
80
  * Get all assets for a specific chain
114
81
  */
115
- getAssetsByChain(s) {
116
- 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) : [];
117
84
  }
118
85
  /**
119
86
  * Search assets by symbol or name
120
87
  */
121
- searchAssets(s) {
122
- if (!this._assets) return [];
123
- const t = s.toLowerCase();
124
- return Object.values(this._assets).filter(
125
- (i) => i.symbol.toLowerCase().includes(t) || i.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)
126
93
  );
127
94
  }
128
95
  /**
129
96
  * Get chain data by chain identifier
130
97
  */
131
- getChain(s) {
132
- if (this._chains)
133
- return this._chains[s];
98
+ getChain(t) {
99
+ if (this.chains)
100
+ return this.chains[t];
134
101
  }
135
102
  // ============================================
136
103
  // Private Helper Methods
137
104
  // ============================================
138
- /**
139
- * Initialize the route validator
140
- */
141
- async initializeRouteValidator() {
142
- this._routeValidator = new p(this.url.toString(), this.apiKey), await this._routeValidator.loadPolicy();
143
- }
144
105
  /**
145
106
  * Build route matrix for fast O(1) route lookups
146
107
  */
147
108
  async buildRouteMatrix() {
148
- if (!this._allAssets || !this._routeValidator)
149
- return;
150
- const s = Object.values(this._allAssets).map((t) => {
151
- if (!t.id) return null;
109
+ if (!this.assets || !this.routeValidator) return;
110
+ const t = Object.values(this.assets).map((s) => {
111
+ if (!s.id) return null;
152
112
  try {
153
- return a.from(t.id);
113
+ return r.from(s.id);
154
114
  } catch {
155
115
  return null;
156
116
  }
157
- }).filter((t) => t !== null);
158
- this._routeMatrix = await y(
159
- s,
160
- this._routeValidator
117
+ }).filter((s) => s !== null);
118
+ this.routeMatrix = await this.routeValidator.buildRouteMatrix(
119
+ t
161
120
  );
162
121
  }
163
122
  /**
164
123
  * Process raw API data into structured format
165
124
  */
166
- processApiData(s) {
167
- const t = {}, i = {}, e = {}, n = {};
168
- for (const r of s) {
169
- const o = this.parseChainIdentifier(r.chain);
170
- if (!o || !_.includes(o))
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))
171
130
  continue;
172
- const u = {
173
- ...r,
174
- name: this.formatChainName(r.chain),
175
- chain: o
131
+ const h = {
132
+ ...a,
133
+ name: this.formatChainName(a.chain),
134
+ chain: e
176
135
  };
177
- t[o] = u;
178
- for (const l of r.assets) {
179
- const c = a.from(l.id).toString(), { name: f, symbol: A } = b(
180
- l.name,
181
- l.id
182
- ), d = {
183
- ...l,
184
- id: a.from(l.id),
185
- chain: o,
186
- name: f,
187
- symbol: A
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
188
146
  };
189
- i[c] = d, e[c] = d;
147
+ s[l] = f, i[e] || (i[e] = h);
190
148
  }
191
- n[o] = u;
192
149
  }
193
- return { allChains: t, allAssets: i, assets: e, chains: n };
150
+ return { assets: s, chains: i };
194
151
  }
195
152
  /**
196
153
  * Parse chain identifier from string
197
154
  */
198
- parseChainIdentifier(s) {
199
- return _.includes(s) ? s : null;
155
+ parseChainIdentifier(t) {
156
+ return u.includes(t) ? t : null;
200
157
  }
201
158
  /**
202
159
  * Format chain name for display
203
160
  */
204
- formatChainName(s) {
205
- 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(" ");
206
163
  }
207
164
  // ============================================
208
165
  // Data Refresh Methods
@@ -213,13 +170,7 @@ class O {
213
170
  async refresh() {
214
171
  await this.initialize();
215
172
  }
216
- /**
217
- * Clear all cached data
218
- */
219
- clear() {
220
- this._allChains = null, this._allAssets = null, this._assets = null, this._chains = null, this._routeValidator = null, this._routeMatrix = null, this._error = null;
221
- }
222
173
  }
223
174
  export {
224
- O as AssetManager
175
+ R as AssetManager
225
176
  };
package/dist/index11.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@gardenfi/utils"),d=require("node-cache"),n=class n{constructor(t,e){this.apiBaseUrl=t,this.apiKey=e,typeof this.apiKey=="string"?this.auth=new o.ApiKey(this.apiKey):this.auth=this.apiKey}async loadPolicy(){const t=n.cache.get(n.POLICY_CACHE_KEY);if(t)return o.Ok(t);try{if(!this.auth)return o.Err("Authentication not configured");const e=await this.auth.getAuthHeaders();if(e.error)return o.Err(`Failed to get auth headers: ${e.error}`);const s=await(await fetch(`${this.apiBaseUrl}/v2/policy`,{headers:{...e.val,accept:"application/json"}})).json();return s.status!=="Ok"?o.Err(`API Error: ${s.error}`):(n.cache.set(n.POLICY_CACHE_KEY,s.result),o.Ok(s.result))}catch(e){return o.Err(`Failed to load policy: ${e}`)}}async isValidRoute(t,e){const r=await this.loadPolicy();if(!r.ok)return!1;const{sortedIsolationRules:s,sortedBlacklistRules:i,sortedWhitelistRules:a}=this.preprocessRules(r.val);if(t.toString()===e.toString())return!1;if(this.matchesRuleList(t,e,a))return!0;const u=this.findMatchingRule(t,s,"from");if(u&&!this.matchesRuleDestination(e,u))return!1;const h=this.findMatchingRule(e,s,"to");return h&&!this.matchesRuleSource(t,h)||this.matchesRuleList(t,e,i)?!1:r.val.default==="open"}async isAssetInIsolationGroup(t){const e=await this.loadPolicy();if(!e.ok)return!1;const{sortedIsolationRules:r}=this.preprocessRules(e.val);return r.some(s=>this.matchesAssetPattern(t,s.fromPattern)||this.matchesAssetPattern(t,s.toPattern))}async getValidDestinations(t,e){if(!(await this.loadPolicy()).ok)return[];const s=[];for(const i of e)await this.isValidRoute(t,i)&&s.push(i);return s}async getAllValidRoutes(t){const e=[];for(const r of t)for(const s of t)await this.isValidRoute(r,s)&&e.push({from:r,to:s});return e}static clearCache(){n.cache.del(n.POLICY_CACHE_KEY)}static getCacheStats(){return n.cache.getStats()}preprocessRules(t){const e=t.isolation_groups.map(i=>this.parseRule(i)).sort((i,a)=>a.specificity-i.specificity),r=t.blacklist_pairs.map(i=>this.parseRule(i)).sort((i,a)=>a.specificity-i.specificity),s=t.whitelist_overrides.map(i=>this.parseRule(i)).sort((i,a)=>a.specificity-i.specificity);return{sortedIsolationRules:e,sortedBlacklistRules:r,sortedWhitelistRules:s}}parseRule(t){const r=t.includes("<->")?"<->":"->",[s,i]=t.split(r).map(a=>a.trim());return{pattern:t,fromPattern:s,toPattern:i,direction:r,specificity:this.calculateSpecificity(s,i)}}calculateSpecificity(t,e){const r=s=>{const i=s.toLowerCase();return i==="*"?0:i.includes("*")?1:2};return r(t)*10+r(e)}findMatchingRule(t,e,r){for(const s of e){const i=r==="from"?s.fromPattern:s.toPattern;if(this.matchesAssetPattern(t,i))return s;if(s.direction==="<->"){const a=r==="from"?s.toPattern:s.fromPattern;if(this.matchesAssetPattern(t,a))return s}}return null}matchesRuleDestination(t,e){return!!(this.matchesAssetPattern(t,e.toPattern)||e.direction==="<->"&&this.matchesAssetPattern(t,e.fromPattern))}matchesRuleSource(t,e){return!!(this.matchesAssetPattern(t,e.fromPattern)||e.direction==="<->"&&this.matchesAssetPattern(t,e.toPattern))}matchesRuleList(t,e,r){return r.some(s=>this.matchesRule(t,e,s))}matchesRule(t,e,r){const s=this.matchesAssetPattern(t,r.fromPattern)&&this.matchesAssetPattern(e,r.toPattern);if(r.direction==="<->"){const i=this.matchesAssetPattern(t,r.toPattern)&&this.matchesAssetPattern(e,r.fromPattern);return s||i}return s}matchesAssetPattern(t,e){const r=t.toString().toLowerCase(),s=e.toLowerCase();if(s==="*")return!0;if(s.endsWith(":*")){const i=s.slice(0,-1);return r.startsWith(i)}if(s.startsWith("*:")){const i=s.slice(1);return r.endsWith(i)}return r===s}};n.cache=new d({stdTTL:36e3,checkperiod:3600}),n.POLICY_CACHE_KEY="route_policy";let c=n;async function p(l,t){const e={};for(const r of l)e[r.toString()]=await t.getValidDestinations(r,l);return e}exports.RouteValidator=c;exports.buildRouteMatrix=p;
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:i,sortedBlacklistRules:r,sortedWhitelistRules:n}=this.preprocessRules(s.val),l=this.findMatchingRule(e,i,"from");if(l&&!this.matchesRuleDestination(t,l))return!1;const c=this.findMatchingRule(t,i,"to");return c&&c.direction==="<->"&&!this.matchesRuleSource(e,c)?!1:this.matchesRuleList(e,t,r)?!!this.matchesRuleList(e,t,n):s.val.default==="open"}async getValidDestinations(e,t){const s=[];for(const i of t)await this.isValidRoute(e,i)&&s.push(i);return s}async getAllValidRoutes(e){const t=[];for(const s of e)for(const i of e)await this.isValidRoute(s,i)&&t.push({from:s,to:i});return t}preprocessRules(e){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);return{sortedIsolationRules:t,sortedBlacklistRules:s,sortedWhitelistRules:i}}parseRule(e){const s=e.includes("<->")?"<->":"->",[i,r]=e.split(s).map(n=>n.trim());return{pattern:e,fromPattern:i,toPattern:r,direction:s,specificity:this.calculateSpecificity(i,r)}}calculateSpecificity(e,t){const s=i=>{const r=i.toLowerCase();return r==="*"?0:r.includes("*")?1:2};return s(e)*10+s(t)}findMatchingRule(e,t,s){for(const i of t){const r=s==="from"?i.fromPattern:i.toPattern;if(this.matchesAssetPattern(e,r))return i;if(i.direction==="<->"){const n=s==="from"?i.toPattern:i.fromPattern;if(this.matchesAssetPattern(e,n))return i}}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(i=>this.matchesRule(e,t,i))}matchesRule(e,t,s){const i=this.matchesAssetPattern(e,s.fromPattern)&&this.matchesAssetPattern(t,s.toPattern);if(s.direction==="<->"){const r=this.matchesAssetPattern(e,s.toPattern)&&this.matchesAssetPattern(t,s.fromPattern);return i||r}return i}matchesAssetPattern(e,t){const[s,i]=t.split(":"),r=s==="*"||s===e.chain,n=i.toLowerCase()==="*"||i.toLowerCase()===e.symbol.toLowerCase();return r&&n}async buildRouteMatrix(e){const t={};for(const s of e){const i=[];for(const r of e)await this.isValidRoute(s,r)&&i.push(r);t[s.toString()]=i}return t}};a.POLICY_CACHE_KEY="route_policy";let u=a;exports.RouteValidator=u;
package/dist/index11.js CHANGED
@@ -1,153 +1,152 @@
1
- import { ApiKey as d, Ok as u, Err as o } from "@gardenfi/utils";
1
+ import { ApiKey as f, Url as p, Ok as u, Err as c, Fetcher as d } from "@gardenfi/utils";
2
2
  import m from "node-cache";
3
- const n = class n {
4
- constructor(t, e) {
5
- this.apiBaseUrl = t, this.apiKey = e, typeof this.apiKey == "string" ? this.auth = new d(this.apiKey) : this.auth = this.apiKey;
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;
11
+ }
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;
6
38
  }
7
39
  /**
8
40
  * Loads the current route policy, cached or via API.
9
41
  */
10
42
  async loadPolicy() {
11
- const t = n.cache.get(
12
- n.POLICY_CACHE_KEY
13
- );
14
- if (t)
15
- return u(t);
43
+ const e = this.getPolicy();
44
+ if (e) return u(e);
16
45
  try {
17
- if (!this.auth)
18
- return o("Authentication not configured");
19
- const e = await this.auth.getAuthHeaders();
20
- if (e.error)
21
- return o(`Failed to get auth headers: ${e.error}`);
22
- const s = await (await fetch(`${this.apiBaseUrl}/v2/policy`, {
23
- headers: {
24
- ...e.val,
25
- accept: "application/json"
46
+ const t = await this.auth.getAuthHeaders();
47
+ if (!t.ok)
48
+ return c(`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
+ }
26
56
  }
27
- })).json();
28
- return s.status !== "Ok" ? o(`API Error: ${s.error}`) : (n.cache.set(n.POLICY_CACHE_KEY, s.result), u(s.result));
29
- } catch (e) {
30
- return o(`Failed to load policy: ${e}`);
57
+ );
58
+ return s.result ? u(this.setPolicy(s.result)) : c(`API Error: ${s.error}`);
59
+ } catch (t) {
60
+ return c(`Failed to load policy: ${t}`);
31
61
  }
32
62
  }
33
63
  /**
34
64
  * Checks if a given route is valid based on all route rules.
35
65
  */
36
- async isValidRoute(t, e) {
37
- const i = await this.loadPolicy();
38
- if (!i.ok)
39
- return !1;
40
- const { sortedIsolationRules: s, sortedBlacklistRules: r, sortedWhitelistRules: a } = this.preprocessRules(i.val);
41
- if (t.toString() === e.toString()) return !1;
42
- if (this.matchesRuleList(t, e, a))
43
- return !0;
44
- const l = this.findMatchingRule(
45
- t,
46
- s,
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), l = this.findMatchingRule(
70
+ e,
71
+ i,
47
72
  "from"
73
+ /* From */
48
74
  );
49
- if (l && !this.matchesRuleDestination(e, l))
75
+ if (l && !this.matchesRuleDestination(t, l))
50
76
  return !1;
51
- const h = this.findMatchingRule(
52
- e,
53
- s,
77
+ const a = this.findMatchingRule(
78
+ t,
79
+ i,
54
80
  "to"
81
+ /* To */
55
82
  );
56
- return h && !this.matchesRuleSource(t, h) || this.matchesRuleList(t, e, r) ? !1 : i.val.default === "open";
57
- }
58
- /**
59
- * Returns true if asset is part of any isolation group rule.
60
- */
61
- async isAssetInIsolationGroup(t) {
62
- const e = await this.loadPolicy();
63
- if (!e.ok)
64
- return !1;
65
- const { sortedIsolationRules: i } = this.preprocessRules(e.val);
66
- return i.some(
67
- (s) => this.matchesAssetPattern(t, s.fromPattern) || this.matchesAssetPattern(t, s.toPattern)
68
- );
83
+ return a && a.direction === "<->" && !this.matchesRuleSource(e, a) ? !1 : this.matchesRuleList(e, t, r) ? !!this.matchesRuleList(e, t, n) : s.val.default === "open";
69
84
  }
70
85
  /**
71
86
  * Returns all valid destinations for a given source asset.
72
87
  */
73
- async getValidDestinations(t, e) {
74
- if (!(await this.loadPolicy()).ok)
75
- return [];
88
+ async getValidDestinations(e, t) {
76
89
  const s = [];
77
- for (const r of e)
78
- await this.isValidRoute(t, r) && s.push(r);
90
+ for (const i of t)
91
+ await this.isValidRoute(e, i) && s.push(i);
79
92
  return s;
80
93
  }
81
94
  /**
82
95
  * Returns every valid route (from-to pair) among the provided assets.
83
96
  */
84
- async getAllValidRoutes(t) {
85
- const e = [];
86
- for (const i of t)
87
- for (const s of t)
88
- await this.isValidRoute(i, s) && e.push({ from: i, to: s });
89
- return e;
90
- }
91
- /**
92
- * Manually clear the cached route policy.
93
- */
94
- static clearCache() {
95
- n.cache.del(n.POLICY_CACHE_KEY);
96
- }
97
- /**
98
- * Returns cache library statistics.
99
- */
100
- static getCacheStats() {
101
- return n.cache.getStats();
97
+ async getAllValidRoutes(e) {
98
+ const t = [];
99
+ for (const s of e)
100
+ for (const i of e)
101
+ await this.isValidRoute(s, i) && t.push({ from: s, to: i });
102
+ return t;
102
103
  }
103
104
  /**
104
105
  * Turns policy string rules into sorted ParsedRule objects.
105
106
  */
106
- preprocessRules(t) {
107
- const e = t.isolation_groups.map((r) => this.parseRule(r)).sort((r, a) => a.specificity - r.specificity), i = t.blacklist_pairs.map((r) => this.parseRule(r)).sort((r, a) => a.specificity - r.specificity), s = t.whitelist_overrides.map((r) => this.parseRule(r)).sort((r, a) => a.specificity - r.specificity);
108
- return { sortedIsolationRules: e, sortedBlacklistRules: i, sortedWhitelistRules: s };
107
+ preprocessRules(e) {
108
+ 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);
109
+ return { sortedIsolationRules: t, sortedBlacklistRules: s, sortedWhitelistRules: i };
109
110
  }
110
111
  /**
111
- * Parses a rule string (e.g. "eth:usdc->avalanche:usdt") into parts.
112
+ * Parses a rule string (e.g. "ethereum:usdc -> base:usdt") into parts.
112
113
  */
113
- parseRule(t) {
114
- const i = t.includes(
114
+ parseRule(e) {
115
+ const s = e.includes(
115
116
  "<->"
116
117
  /* Bidirectional */
117
- ) ? "<->" : "->", [s, r] = t.split(i).map((a) => a.trim());
118
+ ) ? "<->" : "->", [i, r] = e.split(s).map((n) => n.trim());
118
119
  return {
119
- pattern: t,
120
- fromPattern: s,
120
+ pattern: e,
121
+ fromPattern: i,
121
122
  toPattern: r,
122
- direction: i,
123
- specificity: this.calculateSpecificity(s, r)
123
+ direction: s,
124
+ specificity: this.calculateSpecificity(i, r)
124
125
  };
125
126
  }
126
127
  /**
127
128
  * Gives a specificity score to a rule pattern for prioritizing.
128
129
  */
129
- calculateSpecificity(t, e) {
130
- const i = (s) => {
131
- const r = s.toLowerCase();
130
+ calculateSpecificity(e, t) {
131
+ const s = (i) => {
132
+ const r = i.toLowerCase();
132
133
  return r === "*" ? 0 : r.includes(
133
134
  "*"
134
- /* WildCard */
135
+ /* Any */
135
136
  ) ? 1 : 2;
136
137
  };
137
- return i(t) * 10 + i(e);
138
+ return s(e) * 10 + s(t);
138
139
  }
139
140
  /**
140
141
  * Finds the first matching rule for an asset given the rule "side".
141
142
  */
142
- findMatchingRule(t, e, i) {
143
- for (const s of e) {
144
- const r = i === "from" ? s.fromPattern : s.toPattern;
145
- if (this.matchesAssetPattern(t, r))
146
- return s;
147
- if (s.direction === "<->") {
148
- const a = i === "from" ? s.toPattern : s.fromPattern;
149
- if (this.matchesAssetPattern(t, a))
150
- return s;
143
+ findMatchingRule(e, t, s) {
144
+ for (const i of t) {
145
+ const r = s === "from" ? i.fromPattern : i.toPattern;
146
+ if (this.matchesAssetPattern(e, r)) return i;
147
+ if (i.direction === "<->") {
148
+ const n = s === "from" ? i.toPattern : i.fromPattern;
149
+ if (this.matchesAssetPattern(e, n)) return i;
151
150
  }
152
151
  }
153
152
  return null;
@@ -155,72 +154,52 @@ const n = class n {
155
154
  /**
156
155
  * Checks if a given toAsset matches the rule's destination side.
157
156
  */
158
- matchesRuleDestination(t, e) {
159
- return !!(this.matchesAssetPattern(t, e.toPattern) || e.direction === "<->" && this.matchesAssetPattern(t, e.fromPattern));
157
+ matchesRuleDestination(e, t) {
158
+ return !!(this.matchesAssetPattern(e, t.toPattern) || t.direction === "<->" && this.matchesAssetPattern(e, t.fromPattern));
160
159
  }
161
160
  /**
162
161
  * Checks if a given fromAsset matches the rule's source side.
163
162
  */
164
- matchesRuleSource(t, e) {
165
- return !!(this.matchesAssetPattern(t, e.fromPattern) || e.direction === "<->" && this.matchesAssetPattern(t, e.toPattern));
163
+ matchesRuleSource(e, t) {
164
+ return !!(this.matchesAssetPattern(e, t.fromPattern) || t.direction === "<->" && this.matchesAssetPattern(e, t.toPattern));
166
165
  }
167
166
  /**
168
167
  * Checks if any rule in a list matches fromAsset and toAsset.
169
168
  */
170
- matchesRuleList(t, e, i) {
171
- return i.some((s) => this.matchesRule(t, e, s));
169
+ matchesRuleList(e, t, s) {
170
+ return s.some((i) => this.matchesRule(e, t, i));
172
171
  }
173
172
  /**
174
173
  * Checks if a rule matches fromAsset and toAsset (forward or backward if bidirectional).
175
174
  */
176
- matchesRule(t, e, i) {
177
- const s = this.matchesAssetPattern(t, i.fromPattern) && this.matchesAssetPattern(e, i.toPattern);
178
- if (i.direction === "<->") {
179
- const r = this.matchesAssetPattern(t, i.toPattern) && this.matchesAssetPattern(e, i.fromPattern);
180
- return s || r;
175
+ matchesRule(e, t, s) {
176
+ const i = this.matchesAssetPattern(e, s.fromPattern) && this.matchesAssetPattern(t, s.toPattern);
177
+ if (s.direction === "<->") {
178
+ const r = this.matchesAssetPattern(e, s.toPattern) && this.matchesAssetPattern(t, s.fromPattern);
179
+ return i || r;
181
180
  }
182
- return s;
181
+ return i;
183
182
  }
184
183
  /**
185
184
  * Checks if an asset string matches a rule's pattern (wildcards supported).
186
185
  */
187
- matchesAssetPattern(t, e) {
188
- const i = t.toString().toLowerCase(), s = e.toLowerCase();
189
- if (s === "*") return !0;
190
- if (s.endsWith(
191
- ":*"
192
- /* TokenWildcard */
193
- )) {
194
- const r = s.slice(0, -1);
195
- return i.startsWith(r);
196
- }
197
- if (s.startsWith(
198
- "*:"
199
- /* ChainWildcard */
200
- )) {
201
- const r = s.slice(1);
202
- return i.endsWith(r);
186
+ matchesAssetPattern(e, t) {
187
+ const [s, i] = t.split(":"), r = s === "*" || s === e.chain, n = i.toLowerCase() === "*" || i.toLowerCase() === e.symbol.toLowerCase();
188
+ return r && n;
189
+ }
190
+ async buildRouteMatrix(e) {
191
+ const t = {};
192
+ for (const s of e) {
193
+ const i = [];
194
+ for (const r of e)
195
+ await this.isValidRoute(s, r) && i.push(r);
196
+ t[s.toString()] = i;
203
197
  }
204
- return i === s;
198
+ return t;
205
199
  }
206
200
  };
207
- n.cache = new m({
208
- stdTTL: 36e3,
209
- // 10 hours in seconds
210
- checkperiod: 3600
211
- // Check for expired keys every hour
212
- }), n.POLICY_CACHE_KEY = "route_policy";
213
- let f = n;
214
- async function R(c, t) {
215
- const e = {};
216
- for (const i of c)
217
- e[i.toString()] = await t.getValidDestinations(
218
- i,
219
- c
220
- );
221
- return e;
222
- }
201
+ o.POLICY_CACHE_KEY = "route_policy";
202
+ let h = o;
223
203
  export {
224
- f as RouteValidator,
225
- R as buildRouteMatrix
204
+ h as RouteValidator
226
205
  };
package/dist/index4.cjs CHANGED
@@ -1 +1 @@
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"}}},alpen_testnet:{type:e.BlockchainType.evm,network:a.Network.TESTNET,sBTC:{id:"alpen_testnet:sbtc",name:"Signet Bitcoin",symbol:"sBTC",decimals:18,icon:"https://avatars.githubusercontent.com/u/113091135",chain:"evm:2892",htlc:{address:"0x39269522737a4a155F78EC1B1BDb86288c1Fcf67",schema:"evm:htlc"},token:null},USDC:{id:"alpen_testnet:usdc",name:"USD Coin",symbol:"USDC",decimals:6,icon:"https://garden.imgix.net/token-images/usdc.svg",chain:"evm:2892",htlc:{address:"0x45b0d0c85bEb4512610fC2627CCB1587A7a044d4",schema:"evm:htlc_erc20"},token:{address:"0x9753D0481fC7e18797877B4e731B496439c849dE",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"}}}},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;
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"}}},alpen_testnet:{type:e.BlockchainType.evm,network:a.Network.TESTNET,sBTC:{id:"alpen_testnet:sbtc",name:"Signet Bitcoin",symbol:"sBTC",decimals:18,icon:"https://avatars.githubusercontent.com/u/113091135",chain:"evm:2892",htlc:{address:"0x39269522737a4a155F78EC1B1BDb86288c1Fcf67",schema:"evm:htlc"},token:null},USDC:{id:"alpen_testnet:usdc",name:"USD Coin",symbol:"USDC",decimals:6,icon:"https://garden.imgix.net/token-images/usdc.svg",chain:"evm:2892",htlc:{address:"0x45b0d0c85bEb4512610fC2627CCB1587A7a044d4",schema:"evm:htlc_erc20"},token:{address:"0x9753D0481fC7e18797877B4e731B496439c849dE",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
@@ -949,37 +949,45 @@ const s = {
949
949
  schema: "evm:erc20"
950
950
  }
951
951
  }
952
+ },
953
+ hypercore: {
954
+ type: e.evm,
955
+ network: c.MAINNET
956
+ },
957
+ hypercore_testnet: {
958
+ type: e.evm,
959
+ network: c.TESTNET
952
960
  }
953
961
  }, _ = Object.keys(s).reduce(
954
962
  (a, t) => (a[t] = t, a),
955
963
  {}
956
- ), F = C(s), w = (a) => s[a].network === c.MAINNET;
964
+ ), w = C(s), F = (a) => s[a].network === c.MAINNET;
957
965
  function n(a) {
958
966
  return (t) => s[t].type === a;
959
967
  }
960
- 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 = {
968
+ 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 = {
961
969
  [e.evm]: "eth",
962
970
  [e.solana]: "sol",
963
971
  [e.sui]: "sui"
964
- }, 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], N = (a) => {
972
+ }, 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) => {
965
973
  const t = a.chain, i = a.symbol;
966
974
  return D(t, i) || T(t, i) || p(t) || x(t, i) || // Starknet doesn't have a native token
967
975
  !k(t);
968
976
  };
969
977
  export {
970
- F as Assets,
978
+ w as Assets,
971
979
  _ as Chains,
972
980
  s as Config,
973
981
  d as NATIVE_TOKENS,
974
982
  B as OrderLifecycle,
975
983
  g as OrderStatus,
976
- U as getBlockchainType,
984
+ N as getBlockchainType,
977
985
  n as is,
978
986
  p as isBitcoin,
979
987
  v as isEVM,
980
988
  D as isEvmNativeToken,
981
- w as isMainnet,
982
- N as isNativeToken,
989
+ F as isMainnet,
990
+ U as isNativeToken,
983
991
  f as isSolana,
984
992
  T as isSolanaNativeToken,
985
993
  k as isStarknet,
@@ -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,4 +1,4 @@
1
- import { AsyncResult } from '@gardenfi/utils';
1
+ import { AsyncResult, IAuth } from '@gardenfi/utils';
2
2
  import { RouteValidator } from './routeValidator/routeValidator';
3
3
  import { Assets, ChainData, Chains } from './types';
4
4
  import { ChainAsset } from '../chainAsset/chainAsset';
@@ -12,25 +12,15 @@ import { Asset, Chain } from '../constants/asset.types';
12
12
  * to make route lookups fast.
13
13
  */
14
14
  export declare class AssetManager {
15
- private _allChains;
16
- private _allAssets;
17
- private _assets;
18
- private _chains;
19
- private _routeValidator;
20
- private _routeMatrix;
21
- private _isLoading;
22
- 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;
23
21
  private readonly url;
24
- private apiKey;
25
- constructor(url: string, apiKey: string);
26
- get allChains(): Chains | null;
27
- get allAssets(): Assets | null;
28
- get assets(): Assets | null;
29
- get chains(): Chains | null;
30
- get routeValidator(): RouteValidator | null;
31
- get routeMatrix(): Record<string, ChainAsset[]> | null;
32
- get isLoading(): boolean;
33
- get error(): string | null;
22
+ private auth;
23
+ constructor(url: string, apiKey: IAuth | string);
34
24
  /**
35
25
  * Initialize the AssetManager by fetching all required data
36
26
  */
@@ -46,7 +36,7 @@ export declare class AssetManager {
46
36
  /**
47
37
  * Get all valid destination assets for a given source asset
48
38
  */
49
- getValidDestinations(fromAsset: Asset): Asset[];
39
+ getValidDestinations(asset: Asset): Asset[];
50
40
  /**
51
41
  * Get asset by chain and token address
52
42
  */
@@ -63,14 +53,10 @@ export declare class AssetManager {
63
53
  * Get chain data by chain identifier
64
54
  */
65
55
  getChain(chain: Chain): ChainData | undefined;
66
- /**
67
- * Initialize the route validator
68
- */
69
- private initializeRouteValidator;
70
56
  /**
71
57
  * Build route matrix for fast O(1) route lookups
72
58
  */
73
- private buildRouteMatrix;
59
+ buildRouteMatrix(): Promise<void>;
74
60
  /**
75
61
  * Process raw API data into structured format
76
62
  */
@@ -87,8 +73,4 @@ export declare class AssetManager {
87
73
  * Refresh all data
88
74
  */
89
75
  refresh(): Promise<void>;
90
- /**
91
- * Clear all cached data
92
- */
93
- clear(): void;
94
76
  }
@@ -1,4 +1,4 @@
1
- import { ApiKey, AsyncResult, IAuth } from '@gardenfi/utils';
1
+ import { AsyncResult, IAuth } from '@gardenfi/utils';
2
2
  import { ChainAsset } from '../../chainAsset/chainAsset';
3
3
  import { default as NodeCache } from 'node-cache';
4
4
 
@@ -9,12 +9,13 @@ type RoutePolicy = {
9
9
  whitelist_overrides: string[];
10
10
  };
11
11
  declare class RouteValidator {
12
- private readonly apiBaseUrl;
13
- private readonly apiKey;
14
- private static cache;
12
+ policy: NodeCache;
15
13
  private static readonly POLICY_CACHE_KEY;
14
+ private apiBaseUrl;
16
15
  private auth;
17
- constructor(apiBaseUrl: string, apiKey: string | ApiKey | IAuth);
16
+ constructor(apiBaseUrl: string, apiKey: string | IAuth);
17
+ getPolicy(): RoutePolicy | undefined;
18
+ setPolicy(policy: RoutePolicy): RoutePolicy;
18
19
  /**
19
20
  * Loads the current route policy, cached or via API.
20
21
  */
@@ -23,10 +24,6 @@ declare class RouteValidator {
23
24
  * Checks if a given route is valid based on all route rules.
24
25
  */
25
26
  isValidRoute(fromAsset: ChainAsset, toAsset: ChainAsset): Promise<boolean>;
26
- /**
27
- * Returns true if asset is part of any isolation group rule.
28
- */
29
- isAssetInIsolationGroup(asset: ChainAsset): Promise<boolean>;
30
27
  /**
31
28
  * Returns all valid destinations for a given source asset.
32
29
  */
@@ -38,20 +35,12 @@ declare class RouteValidator {
38
35
  from: ChainAsset;
39
36
  to: ChainAsset;
40
37
  }>>;
41
- /**
42
- * Manually clear the cached route policy.
43
- */
44
- static clearCache(): void;
45
- /**
46
- * Returns cache library statistics.
47
- */
48
- static getCacheStats(): NodeCache.Stats;
49
38
  /**
50
39
  * Turns policy string rules into sorted ParsedRule objects.
51
40
  */
52
41
  private preprocessRules;
53
42
  /**
54
- * Parses a rule string (e.g. "eth:usdc->avalanche:usdt") into parts.
43
+ * Parses a rule string (e.g. "ethereum:usdc -> base:usdt") into parts.
55
44
  */
56
45
  private parseRule;
57
46
  /**
@@ -82,9 +71,6 @@ declare class RouteValidator {
82
71
  * Checks if an asset string matches a rule's pattern (wildcards supported).
83
72
  */
84
73
  private matchesAssetPattern;
74
+ buildRouteMatrix(assets: ChainAsset[]): Promise<Record<string, ChainAsset[]>>;
85
75
  }
86
- /**
87
- * Builds a fast lookup matrix for all valid destination assets per source asset.
88
- */
89
- declare function buildRouteMatrix(assets: ChainAsset[], validator: RouteValidator): Promise<Record<string, ChainAsset[]>>;
90
- export { RouteValidator, buildRouteMatrix, type RoutePolicy };
76
+ export { RouteValidator, type RoutePolicy };
@@ -1007,6 +1007,14 @@ export declare const Config: {
1007
1007
  };
1008
1008
  };
1009
1009
  };
1010
+ readonly hypercore: {
1011
+ readonly type: BlockchainType.evm;
1012
+ readonly network: Network.MAINNET;
1013
+ };
1014
+ readonly hypercore_testnet: {
1015
+ readonly type: BlockchainType.evm;
1016
+ readonly network: Network.TESTNET;
1017
+ };
1010
1018
  };
1011
1019
  export declare const Chains: Record<Chain, Chain>;
1012
1020
  export declare const Assets: import('./utils').AssetsType<{
@@ -1992,10 +2000,18 @@ export declare const Assets: import('./utils').AssetsType<{
1992
2000
  };
1993
2001
  };
1994
2002
  };
2003
+ readonly hypercore: {
2004
+ readonly type: BlockchainType.evm;
2005
+ readonly network: Network.MAINNET;
2006
+ };
2007
+ readonly hypercore_testnet: {
2008
+ readonly type: BlockchainType.evm;
2009
+ readonly network: Network.TESTNET;
2010
+ };
1995
2011
  }>;
1996
2012
  export declare const isMainnet: (chain: Chain) => boolean;
1997
2013
  export declare function is<T extends BlockchainType>(type: T): (chain: Chain) => chain is Extract<Chain, ChainsByBlockchainType<T>>;
1998
- 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" | "alpen_testnet" | "base" | "arbitrum" | "ethereum" | "bera" | "hyperliquid" | "unichain" | "corn" | "botanix" | "bnbchain" | "core";
2014
+ 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" | "alpen_testnet" | "base" | "arbitrum" | "ethereum" | "bera" | "hyperliquid" | "unichain" | "corn" | "botanix" | "bnbchain" | "core" | "hypercore" | "hypercore_testnet";
1999
2015
  export declare const isBitcoin: (chain: Chain) => chain is "bitcoin" | "bitcoin_regtest" | "bitcoin_testnet";
2000
2016
  export declare const isSolana: (chain: Chain) => chain is "solana_localnet" | "solana_testnet" | "solana";
2001
2017
  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.10",
3
+ "version": "2.5.3-beta.12",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "dependencies": {
30
30
  "@coral-xyz/anchor": "^0.31.1",
31
- "@gardenfi/utils": "2.5.3",
31
+ "@gardenfi/utils": "2.5.3-beta.6",
32
32
  "bufferutil": "^4.0.8",
33
33
  "node-cache": "^5.1.2",
34
34
  "siwe": "^2.1.4",