@gardenfi/orderbook 3.0.4 → 3.0.5-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1 +1 @@
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;
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"),o=require("./index6.cjs"),t=require("./index7.cjs"),a=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.isTron=e.isTron;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=a.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,59 +1,60 @@
1
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 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
- import { buildAssetsWithChain as K } from "./index6.js";
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
- import { ChainAsset as G } from "./index8.js";
8
- import { OrderAction as Q, ParseOrderStatus as X, isCompleted as Y, isDeadlinePassed as Z, parseAction as $ } from "./index9.js";
9
- import { AssetManager as te } from "./index10.js";
10
- import { RouteValidator as re } from "./index11.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, isTron as C } from "./index4.js";
4
+ import { ArbitrumLocalnet as v, ETHStarknetLocalnetAsset as B, EthereumLocalnet as N, SOLSolanaLocalnetAsset as b, STRKStarknetLocalnetAsset as g, StarknetLocalnet as y, WBTCArbitrumLocalnetAsset as M, WBTCEthereumLocalnetAsset as V, bitcoinRegtestAsset as W } from "./index5.js";
5
+ import { buildAssetsWithChain as P } from "./index6.js";
6
+ import { ConstructUrl as H, discriminateOrderResponse as I, getOrderResponseType as U, isBitcoinOrderResponse as _, isEvmOrderResponse as j, isOrder as q, isSolanaOrderResponse as w, isStarknetOrderResponse as z, isSuiOrderResponse as F } from "./index7.js";
7
+ import { ChainAsset as J } from "./index8.js";
8
+ import { OrderAction as X, ParseOrderStatus as Y, isCompleted as Z, isDeadlinePassed as $, parseAction as ee } from "./index9.js";
9
+ import { AssetManager as se } from "./index10.js";
10
+ import { RouteValidator as oe } from "./index11.js";
11
11
  export {
12
- E as ArbitrumLocalnet,
13
- te as AssetManager,
12
+ v as ArbitrumLocalnet,
13
+ se as AssetManager,
14
14
  n as Assets,
15
15
  o as BlockchainType,
16
- G as ChainAsset,
16
+ J as ChainAsset,
17
17
  a as Chains,
18
18
  p as Config,
19
- D as ConstructUrl,
20
- v as ETHStarknetLocalnetAsset,
21
- B as EthereumLocalnet,
19
+ H as ConstructUrl,
20
+ B as ETHStarknetLocalnetAsset,
21
+ N as EthereumLocalnet,
22
22
  c as NATIVE_TOKENS,
23
- Q as OrderAction,
23
+ X as OrderAction,
24
24
  l as OrderLifecycle,
25
25
  d as OrderStatus,
26
26
  s as Orderbook,
27
- X as ParseOrderStatus,
28
- re as RouteValidator,
29
- N as SOLSolanaLocalnetAsset,
30
- b as STRKStarknetLocalnetAsset,
31
- g as StarknetLocalnet,
32
- y as WBTCArbitrumLocalnetAsset,
33
- M as WBTCEthereumLocalnetAsset,
34
- V as bitcoinRegtestAsset,
35
- K as buildAssetsWithChain,
36
- H as discriminateOrderResponse,
27
+ Y as ParseOrderStatus,
28
+ oe as RouteValidator,
29
+ b as SOLSolanaLocalnetAsset,
30
+ g as STRKStarknetLocalnetAsset,
31
+ y as StarknetLocalnet,
32
+ M as WBTCArbitrumLocalnetAsset,
33
+ V as WBTCEthereumLocalnetAsset,
34
+ W as bitcoinRegtestAsset,
35
+ P as buildAssetsWithChain,
36
+ I as discriminateOrderResponse,
37
37
  m as getBlockchainType,
38
- I as getOrderResponseType,
38
+ U as getOrderResponseType,
39
39
  S as is,
40
40
  A as isBitcoin,
41
- U as isBitcoinOrderResponse,
42
- Y as isCompleted,
43
- Z as isDeadlinePassed,
41
+ _ as isBitcoinOrderResponse,
42
+ Z as isCompleted,
43
+ $ as isDeadlinePassed,
44
44
  O as isEVM,
45
45
  T as isEvmNativeToken,
46
- _ as isEvmOrderResponse,
46
+ j as isEvmOrderResponse,
47
47
  f as isMainnet,
48
48
  k as isNativeToken,
49
- j as isOrder,
49
+ q as isOrder,
50
50
  u as isSolana,
51
51
  x as isSolanaNativeToken,
52
- q as isSolanaOrderResponse,
52
+ w as isSolanaOrderResponse,
53
53
  L as isStarknet,
54
- w as isStarknetOrderResponse,
54
+ z as isStarknetOrderResponse,
55
55
  R as isSui,
56
56
  h as isSuiNativeToken,
57
- z as isSuiOrderResponse,
58
- $ as parseAction
57
+ F as isSuiOrderResponse,
58
+ C as isTron,
59
+ ee as parseAction
59
60
  };
package/dist/index10.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("@gardenfi/utils"),y=require("./index11.cjs"),p=require("./index4.cjs"),r=require("./index8.cjs"),o=require("./index12.cjs"),h=Object.keys(p.Config);class g{constructor(t,s){this.assets=null,this.chains=null,this.routeMatrix=null,this.isLoading=!1,this.error=null,typeof s=="string"?this.auth=new n.ApiKey(s):this.auth=s;const e=o.ensureUrl(t.baseUrl),i=o.buildDefaultEndpoint(e,"/v2/chains"),a=o.buildDefaultEndpoint(e,"/v2/policy");this.urls={base:e,assets:o.ensureUrl(t.assetsUrl??i),policy:o.ensureUrl(t.policyUrl??a)},this.routeValidator=new y.RouteValidator(this.urls.policy.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 n.Err("Failed to get auth headers");const s=await n.Fetcher.get(this.urls.assets,{headers:{...t.val}});if(!s.result)return n.Err(`Failed to fetch chains data: ${s.error}`);const{assets:e,chains:i}=this.processApiData(s.result);return this.assets=e,this.chains=i,await this.buildRouteMatrix(),n.Ok("AssetManager initialized successfully")}catch(t){return n.Err(`Failed to fetch assets data: ${t}`)}finally{this.isLoading=!1}}async isRouteValid(t,s){return await this.routeValidator.isValidRoute(r.ChainAsset.from(t.id),r.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 i=e.toString();return Object.values(this.assets).find(a=>r.ChainAsset.from(a).toString()===i)}).filter(Boolean):[]}getAsset(t){if(!this.assets)return;const s=r.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 r.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 i of t){const a=this.parseChainIdentifier(i.chain);if(!a||!h.includes(a))continue;const u={...i,name:this.formatChainName(i.chain),chain:a};for(const l of i.assets){const c=r.ChainAsset.from(l.id).toString(),{name:d,symbol:f}=o.parseAssetNameSymbol(l.name,l.id),A={...l,id:r.ChainAsset.from(l.id),chain:a,name:d,symbol:f};s[c]=A,e[a]||(e[a]=u)}}return{assets:s,chains:e}}parseChainIdentifier(t){return h.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=g;
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,21 +1,12 @@
1
- import { ApiKey as A, Err as o, Fetcher as y, Ok as g } from "@gardenfi/utils";
1
+ import { Url as m, ApiKey as A, Err as o, Fetcher as g, Ok as p } from "@gardenfi/utils";
2
2
  import { RouteValidator as C } from "./index11.js";
3
- import { Config as b } from "./index4.js";
3
+ import { Config as y } from "./index4.js";
4
4
  import { ChainAsset as r } from "./index8.js";
5
- import { ensureUrl as l, buildDefaultEndpoint as u, parseAssetNameSymbol as w } from "./index12.js";
6
- const c = Object.keys(b);
7
- class I {
5
+ import { parseAssetNameSymbol as w } from "./index12.js";
6
+ const u = Object.keys(y);
7
+ class R {
8
8
  constructor(t, s) {
9
- this.assets = null, this.chains = null, this.routeMatrix = null, this.isLoading = !1, this.error = null, typeof s == "string" ? this.auth = new A(s) : this.auth = s;
10
- const i = l(t.baseUrl), e = u(i, "/v2/chains"), a = u(i, "/v2/policy");
11
- this.urls = {
12
- base: i,
13
- assets: l(t.assetsUrl ?? e),
14
- policy: l(t.policyUrl ?? a)
15
- }, this.routeValidator = new C(
16
- this.urls.policy.toString(),
17
- this.auth
18
- );
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);
19
10
  }
20
11
  // ============================================
21
12
  // Initialization Methods
@@ -34,17 +25,14 @@ class I {
34
25
  this.isLoading = !0, this.error = null;
35
26
  const t = await this.auth.getAuthHeaders();
36
27
  if (!t.ok) return o("Failed to get auth headers");
37
- const s = await y.get(
38
- this.urls.assets,
39
- {
40
- headers: {
41
- ...t.val
42
- }
28
+ const s = this.url.endpoint("/v2/chains"), i = await g.get(s, {
29
+ headers: {
30
+ ...t.val
43
31
  }
44
- );
45
- if (!s.result) return o(`Failed to fetch chains data: ${s.error}`);
46
- const { assets: i, chains: e } = this.processApiData(s.result);
47
- return this.assets = i, this.chains = e, await this.buildRouteMatrix(), g("AssetManager initialized successfully");
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");
48
36
  } catch (t) {
49
37
  return o(`Failed to fetch assets data: ${t}`);
50
38
  } finally {
@@ -73,8 +61,8 @@ class I {
73
61
  ), [];
74
62
  const s = this.routeMatrix[t.id.toString().toLowerCase()];
75
63
  return s ? s.map((i) => {
76
- const e = i.toString();
77
- return Object.values(this.assets).find((a) => r.from(a).toString() === e);
64
+ const a = i.toString();
65
+ return Object.values(this.assets).find((e) => r.from(e).toString() === a);
78
66
  }).filter(Boolean) : [];
79
67
  }
80
68
  // ============================================
@@ -136,27 +124,27 @@ class I {
136
124
  */
137
125
  processApiData(t) {
138
126
  const s = {}, i = {};
139
- for (const e of t) {
140
- const a = this.parseChainIdentifier(e.chain);
141
- if (!a || !c.includes(a))
127
+ for (const a of t) {
128
+ const e = this.parseChainIdentifier(a.chain);
129
+ if (!e || !u.includes(e))
142
130
  continue;
143
131
  const h = {
144
- ...e,
145
- name: this.formatChainName(e.chain),
146
- chain: a
132
+ ...a,
133
+ name: this.formatChainName(a.chain),
134
+ chain: e
147
135
  };
148
- for (const n of e.assets) {
149
- const d = r.from(n.id).toString(), { name: f, symbol: m } = w(
136
+ for (const n of a.assets) {
137
+ const l = r.from(n.id).toString(), { name: c, symbol: d } = w(
150
138
  n.name,
151
139
  n.id
152
- ), p = {
140
+ ), f = {
153
141
  ...n,
154
142
  id: r.from(n.id),
155
- chain: a,
156
- name: f,
157
- symbol: m
143
+ chain: e,
144
+ name: c,
145
+ symbol: d
158
146
  };
159
- s[d] = p, i[a] || (i[a] = h);
147
+ s[l] = f, i[e] || (i[e] = h);
160
148
  }
161
149
  }
162
150
  return { assets: s, chains: i };
@@ -165,7 +153,7 @@ class I {
165
153
  * Parse chain identifier from string
166
154
  */
167
155
  parseChainIdentifier(t) {
168
- return c.includes(t) ? t : null;
156
+ return u.includes(t) ? t : null;
169
157
  }
170
158
  /**
171
159
  * Format chain name for display
@@ -184,5 +172,5 @@ class I {
184
172
  }
185
173
  }
186
174
  export {
187
- I as AssetManager
175
+ R as AssetManager
188
176
  };
package/dist/index11.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@gardenfi/utils"),h=require("node-cache"),o=class o{constructor(e,t){this.policy=new h({stdTTL:36e3,checkperiod:3600}),typeof t=="string"?this.auth=new a.ApiKey(t):this.auth=t,typeof e=="string"?this.apiBaseUrl=new a.Url(e):this.apiBaseUrl=e}getPolicy(){return this.policy.get(o.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(o.POLICY_CACHE_KEY,s),s}async loadPolicy(){const e=this.getPolicy();if(e)return a.Ok(e);try{const t=await this.auth.getAuthHeaders();if(!t.ok)return a.Err(`Failed to get auth headers: ${t.error}`);const s=await a.Fetcher.get(this.apiBaseUrl,{headers:{"Content-Type":"application/json",...t.val}});return s.result?a.Ok(this.setPolicy(s.result)):a.Err(`API Error: ${s.error}`)}catch(t){return a.Err(`Failed to load policy: ${t}`)}}async isValidRoute(e,t){const s=await this.loadPolicy();if(!s.ok||e.toString()===t.toString())return!1;const{sortedIsolationRules:r,sortedBlacklistRules:i,sortedWhitelistRules:n}=this.preprocessRules(s.val),c=this.findMatchingRule(e,r);if(c&&!this.matchesRuleDestination(t,c))return!1;const l=this.findMatchingRule(t,r);return l&&l.rule.direction==="<->"&&!this.matchesRuleSource(e,l)?!1:this.matchesRuleList(e,t,i)?!!this.matchesRuleList(e,t,n):s.val.default==="open"}async getValidDestinations(e,t){const s=[];for(const r of t)await this.isValidRoute(e,r)&&s.push(r);return s}async getAllValidRoutes(e){const t=[];for(const s of e)for(const r of e)await this.isValidRoute(s,r)&&t.push({from:s,to:r});return t}preprocessRules(e){const t=e.isolation_groups.map(i=>this.parseRule(i)).sort((i,n)=>n.specificity-i.specificity),s=e.blacklist_pairs.map(i=>this.parseRule(i)).sort((i,n)=>n.specificity-i.specificity),r=e.whitelist_overrides.map(i=>this.parseRule(i)).sort((i,n)=>n.specificity-i.specificity);return{sortedIsolationRules:t,sortedBlacklistRules:s,sortedWhitelistRules:r}}parseRule(e){const s=e.includes("<->")?"<->":"->",[r,i]=e.split(s).map(n=>n.trim());return{pattern:e,fromPattern:r,toPattern:i,direction:s,specificity:this.calculateSpecificity(r,i)}}calculateSpecificity(e,t){const s=r=>{const i=r.toLowerCase();return i==="*"?0:i.includes("*")?1:2};return s(e)*10+s(t)}findMatchingRule(e,t){for(const s of t){if(this.matchesAssetPattern(e,s.fromPattern))return{rule:s,matchedAs:"from"};if(s.direction==="<->"&&this.matchesAssetPattern(e,s.toPattern))return{rule:s,matchedAs:"to"}}return null}matchesRuleDestination(e,t){return t.matchedAs==="from"?this.matchesAssetPattern(e,t.rule.toPattern):t.rule.direction!=="<->"?!1:this.matchesAssetPattern(e,t.rule.fromPattern)}matchesRuleSource(e,t){return t.matchedAs==="to"?this.matchesAssetPattern(e,t.rule.fromPattern):t.rule.direction!=="<->"?!1:this.matchesAssetPattern(e,t.rule.toPattern)}matchesRuleList(e,t,s){return s.some(r=>this.matchesRule(e,t,r))}matchesRule(e,t,s){const r=this.matchesAssetPattern(e,s.fromPattern)&&this.matchesAssetPattern(t,s.toPattern);if(s.direction==="<->"){const i=this.matchesAssetPattern(e,s.toPattern)&&this.matchesAssetPattern(t,s.fromPattern);return r||i}return r}matchesAssetPattern(e,t){const[s="",r=""]=t.split(":").map(c=>c.trim().toLowerCase()),i=s===""||s==="*"||s===e.chain.toLowerCase(),n=r===""||r==="*"||r===e.symbol.toLowerCase();return i&&n}async buildRouteMatrix(e){const t={};for(const s of e){const r=[];for(const i of e)await this.isValidRoute(s,i)&&r.push(i);t[s.toString()]=r}return t}};o.POLICY_CACHE_KEY="route_policy";let u=o;exports.RouteValidator=u;
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,6 +1,6 @@
1
- import { ApiKey as f, Url as p, Ok as u, Err as l, Fetcher as d } 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 a = class a {
3
+ const o = class o {
4
4
  constructor(e, t) {
5
5
  this.policy = new m({
6
6
  stdTTL: 36e3,
@@ -10,7 +10,7 @@ const a = class a {
10
10
  }), typeof t == "string" ? this.auth = new f(t) : this.auth = t, typeof e == "string" ? this.apiBaseUrl = new p(e) : this.apiBaseUrl = e;
11
11
  }
12
12
  getPolicy() {
13
- return this.policy.get(a.POLICY_CACHE_KEY);
13
+ return this.policy.get(o.POLICY_CACHE_KEY);
14
14
  }
15
15
  setPolicy(e) {
16
16
  const t = this.getPolicy(), s = {
@@ -34,7 +34,7 @@ const a = class a {
34
34
  ])
35
35
  ]
36
36
  };
37
- return this.policy.set(a.POLICY_CACHE_KEY, s), s;
37
+ return this.policy.set(o.POLICY_CACHE_KEY, s), s;
38
38
  }
39
39
  /**
40
40
  * Loads the current route policy, cached or via API.
@@ -45,9 +45,9 @@ const a = class a {
45
45
  try {
46
46
  const t = await this.auth.getAuthHeaders();
47
47
  if (!t.ok)
48
- return l(`Failed to get auth headers: ${t.error}`);
48
+ return c(`Failed to get auth headers: ${t.error}`);
49
49
  const s = await d.get(
50
- this.apiBaseUrl,
50
+ this.apiBaseUrl.endpoint("v2/policy"),
51
51
  {
52
52
  headers: {
53
53
  "Content-Type": "application/json",
@@ -55,9 +55,9 @@ const a = class a {
55
55
  }
56
56
  }
57
57
  );
58
- return s.result ? u(this.setPolicy(s.result)) : l(`API Error: ${s.error}`);
58
+ return s.result ? u(this.setPolicy(s.result)) : c(`API Error: ${s.error}`);
59
59
  } catch (t) {
60
- return l(`Failed to load policy: ${t}`);
60
+ return c(`Failed to load policy: ${t}`);
61
61
  }
62
62
  }
63
63
  /**
@@ -66,25 +66,29 @@ const a = class a {
66
66
  async isValidRoute(e, t) {
67
67
  const s = await this.loadPolicy();
68
68
  if (!s.ok || e.toString() === t.toString()) return !1;
69
- const { sortedIsolationRules: r, sortedBlacklistRules: i, sortedWhitelistRules: n } = this.preprocessRules(s.val), o = this.findMatchingRule(
69
+ const { sortedIsolationRules: i, sortedBlacklistRules: r, sortedWhitelistRules: n } = this.preprocessRules(s.val), l = this.findMatchingRule(
70
70
  e,
71
- r
71
+ i,
72
+ "from"
73
+ /* From */
72
74
  );
73
- if (o && !this.matchesRuleDestination(t, o))
75
+ if (l && !this.matchesRuleDestination(t, l))
74
76
  return !1;
75
- const c = this.findMatchingRule(
77
+ const a = this.findMatchingRule(
76
78
  t,
77
- r
79
+ i,
80
+ "to"
81
+ /* To */
78
82
  );
79
- return c && c.rule.direction === "<->" && !this.matchesRuleSource(e, c) ? !1 : this.matchesRuleList(e, t, i) ? !!this.matchesRuleList(e, t, n) : s.val.default === "open";
83
+ return a && a.direction === "<->" && !this.matchesRuleSource(e, a) ? !1 : this.matchesRuleList(e, t, r) ? !!this.matchesRuleList(e, t, n) : s.val.default === "open";
80
84
  }
81
85
  /**
82
86
  * Returns all valid destinations for a given source asset.
83
87
  */
84
88
  async getValidDestinations(e, t) {
85
89
  const s = [];
86
- for (const r of t)
87
- await this.isValidRoute(e, r) && s.push(r);
90
+ for (const i of t)
91
+ await this.isValidRoute(e, i) && s.push(i);
88
92
  return s;
89
93
  }
90
94
  /**
@@ -93,16 +97,16 @@ const a = class a {
93
97
  async getAllValidRoutes(e) {
94
98
  const t = [];
95
99
  for (const s of e)
96
- for (const r of e)
97
- await this.isValidRoute(s, r) && t.push({ from: s, to: r });
100
+ for (const i of e)
101
+ await this.isValidRoute(s, i) && t.push({ from: s, to: i });
98
102
  return t;
99
103
  }
100
104
  /**
101
105
  * Turns policy string rules into sorted ParsedRule objects.
102
106
  */
103
107
  preprocessRules(e) {
104
- const t = e.isolation_groups.map((i) => this.parseRule(i)).sort((i, n) => n.specificity - i.specificity), s = e.blacklist_pairs.map((i) => this.parseRule(i)).sort((i, n) => n.specificity - i.specificity), r = e.whitelist_overrides.map((i) => this.parseRule(i)).sort((i, n) => n.specificity - i.specificity);
105
- return { sortedIsolationRules: t, sortedBlacklistRules: s, sortedWhitelistRules: r };
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 };
106
110
  }
107
111
  /**
108
112
  * Parses a rule string (e.g. "ethereum:usdc -> base:usdt") into parts.
@@ -111,22 +115,22 @@ const a = class a {
111
115
  const s = e.includes(
112
116
  "<->"
113
117
  /* Bidirectional */
114
- ) ? "<->" : "->", [r, i] = e.split(s).map((n) => n.trim());
118
+ ) ? "<->" : "->", [i, r] = e.split(s).map((n) => n.trim());
115
119
  return {
116
120
  pattern: e,
117
- fromPattern: r,
118
- toPattern: i,
121
+ fromPattern: i,
122
+ toPattern: r,
119
123
  direction: s,
120
- specificity: this.calculateSpecificity(r, i)
124
+ specificity: this.calculateSpecificity(i, r)
121
125
  };
122
126
  }
123
127
  /**
124
128
  * Gives a specificity score to a rule pattern for prioritizing.
125
129
  */
126
130
  calculateSpecificity(e, t) {
127
- const s = (r) => {
128
- const i = r.toLowerCase();
129
- return i === "*" ? 0 : i.includes(
131
+ const s = (i) => {
132
+ const r = i.toLowerCase();
133
+ return r === "*" ? 0 : r.includes(
130
134
  "*"
131
135
  /* Any */
132
136
  ) ? 1 : 2;
@@ -136,20 +140,14 @@ const a = class a {
136
140
  /**
137
141
  * Finds the first matching rule for an asset given the rule "side".
138
142
  */
139
- findMatchingRule(e, t) {
140
- for (const s of t) {
141
- if (this.matchesAssetPattern(e, s.fromPattern))
142
- return {
143
- rule: s,
144
- matchedAs: "from"
145
- /* From */
146
- };
147
- if (s.direction === "<->" && this.matchesAssetPattern(e, s.toPattern))
148
- return {
149
- rule: s,
150
- matchedAs: "to"
151
- /* To */
152
- };
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;
150
+ }
153
151
  }
154
152
  return null;
155
153
  }
@@ -157,51 +155,51 @@ const a = class a {
157
155
  * Checks if a given toAsset matches the rule's destination side.
158
156
  */
159
157
  matchesRuleDestination(e, t) {
160
- return t.matchedAs === "from" ? this.matchesAssetPattern(e, t.rule.toPattern) : t.rule.direction !== "<->" ? !1 : this.matchesAssetPattern(e, t.rule.fromPattern);
158
+ return !!(this.matchesAssetPattern(e, t.toPattern) || t.direction === "<->" && this.matchesAssetPattern(e, t.fromPattern));
161
159
  }
162
160
  /**
163
161
  * Checks if a given fromAsset matches the rule's source side.
164
162
  */
165
163
  matchesRuleSource(e, t) {
166
- return t.matchedAs === "to" ? this.matchesAssetPattern(e, t.rule.fromPattern) : t.rule.direction !== "<->" ? !1 : this.matchesAssetPattern(e, t.rule.toPattern);
164
+ return !!(this.matchesAssetPattern(e, t.fromPattern) || t.direction === "<->" && this.matchesAssetPattern(e, t.toPattern));
167
165
  }
168
166
  /**
169
167
  * Checks if any rule in a list matches fromAsset and toAsset.
170
168
  */
171
169
  matchesRuleList(e, t, s) {
172
- return s.some((r) => this.matchesRule(e, t, r));
170
+ return s.some((i) => this.matchesRule(e, t, i));
173
171
  }
174
172
  /**
175
173
  * Checks if a rule matches fromAsset and toAsset (forward or backward if bidirectional).
176
174
  */
177
175
  matchesRule(e, t, s) {
178
- const r = this.matchesAssetPattern(e, s.fromPattern) && this.matchesAssetPattern(t, s.toPattern);
176
+ const i = this.matchesAssetPattern(e, s.fromPattern) && this.matchesAssetPattern(t, s.toPattern);
179
177
  if (s.direction === "<->") {
180
- const i = this.matchesAssetPattern(e, s.toPattern) && this.matchesAssetPattern(t, s.fromPattern);
181
- return r || i;
178
+ const r = this.matchesAssetPattern(e, s.toPattern) && this.matchesAssetPattern(t, s.fromPattern);
179
+ return i || r;
182
180
  }
183
- return r;
181
+ return i;
184
182
  }
185
183
  /**
186
184
  * Checks if an asset string matches a rule's pattern (wildcards supported).
187
185
  */
188
186
  matchesAssetPattern(e, t) {
189
- const [s = "", r = ""] = t.split(":").map((o) => o.trim().toLowerCase()), i = s === "" || s === "*" || s === e.chain.toLowerCase(), n = r === "" || r === "*" || r === e.symbol.toLowerCase();
190
- return i && n;
187
+ const [s, i] = t.split(":"), r = s === "*" || s === e.chain, n = i.toLowerCase() === "*" || i.toLowerCase() === e.symbol.toLowerCase();
188
+ return r && n;
191
189
  }
192
190
  async buildRouteMatrix(e) {
193
191
  const t = {};
194
192
  for (const s of e) {
195
- const r = [];
196
- for (const i of e)
197
- await this.isValidRoute(s, i) && r.push(i);
198
- t[s.toString()] = r;
193
+ const i = [];
194
+ for (const r of e)
195
+ await this.isValidRoute(s, r) && i.push(r);
196
+ t[s.toString()] = i;
199
197
  }
200
198
  return t;
201
199
  }
202
200
  };
203
- a.POLICY_CACHE_KEY = "route_policy";
204
- let h = a;
201
+ o.POLICY_CACHE_KEY = "route_policy";
202
+ let h = o;
205
203
  export {
206
204
  h as RouteValidator
207
205
  };
package/dist/index12.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@gardenfi/utils"),p=require("./index8.cjs");function d(n,t,e){var o;const r=(n??"").trim();if(!r)return{name:"",symbol:""};const i=r.split(":");if(i.length>=2){const u=((o=i[0])==null?void 0:o.trim())||"",m=i.slice(1).join(":").trim()||(e==null?void 0:e.trim())||"";return{name:u,symbol:m}}let s="";if(t)try{s=(typeof t=="string"?p.ChainAsset.from(t):t).symbol.toUpperCase()}catch{}return{name:r,symbol:s||(e==null?void 0:e.trim())||""}}function h(n){return n instanceof c.Url?n:new c.Url(n)}function A(n,t){const e=n.toString().replace(/\/+$/,""),r=t.startsWith("/")?t:`/${t}`;return`${e}${r}`}exports.buildDefaultEndpoint=A;exports.ensureUrl=h;exports.parseAssetNameSymbol=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./index8.cjs");function c(m,e,t){var i;const r=(m??"").trim();if(!r)return{name:"",symbol:""};const s=r.split(":");if(s.length>=2){const o=((i=s[0])==null?void 0:i.trim())||"",p=s.slice(1).join(":").trim()||(t==null?void 0:t.trim())||"";return{name:o,symbol:p}}let n="";if(e)try{n=(typeof e=="string"?u.ChainAsset.from(e):e).symbol.toUpperCase()}catch{}return{name:r,symbol:n||(t==null?void 0:t.trim())||""}}exports.parseAssetNameSymbol=c;
package/dist/index12.js CHANGED
@@ -1,31 +1,21 @@
1
- import { Url as p } from "@gardenfi/utils";
2
- import { ChainAsset as c } from "./index8.js";
3
- function $(r, t, n) {
4
- var o;
5
- const e = (r ?? "").trim();
6
- if (!e) return { name: "", symbol: "" };
7
- const i = e.split(":");
8
- if (i.length >= 2) {
9
- const m = ((o = i[0]) == null ? void 0 : o.trim()) || "", u = i.slice(1).join(":").trim() || (n == null ? void 0 : n.trim()) || "";
10
- return { name: m, symbol: u };
1
+ import { ChainAsset as h } from "./index8.js";
2
+ function A(m, r, t) {
3
+ var s;
4
+ const n = (m ?? "").trim();
5
+ if (!n) return { name: "", symbol: "" };
6
+ const e = n.split(":");
7
+ if (e.length >= 2) {
8
+ const o = ((s = e[0]) == null ? void 0 : s.trim()) || "", p = e.slice(1).join(":").trim() || (t == null ? void 0 : t.trim()) || "";
9
+ return { name: o, symbol: p };
11
10
  }
12
- let s = "";
13
- if (t)
11
+ let i = "";
12
+ if (r)
14
13
  try {
15
- s = (typeof t == "string" ? c.from(t) : t).symbol.toUpperCase();
14
+ i = (typeof r == "string" ? h.from(r) : r).symbol.toUpperCase();
16
15
  } catch {
17
16
  }
18
- return { name: e, symbol: s || (n == null ? void 0 : n.trim()) || "" };
19
- }
20
- function d(r) {
21
- return r instanceof p ? r : new p(r);
22
- }
23
- function f(r, t) {
24
- const n = r.toString().replace(/\/+$/, ""), e = t.startsWith("/") ? t : `/${t}`;
25
- return `${n}${e}`;
17
+ return { name: n, symbol: i || (t == null ? void 0 : t.trim()) || "" };
26
18
  }
27
19
  export {
28
- f as buildDefaultEndpoint,
29
- d as ensureUrl,
30
- $ as parseAssetNameSymbol
20
+ A as parseAssetNameSymbol
31
21
  };
package/dist/index3.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e=(t=>(t.bitcoin="bitcoin",t.evm="evm",t.solana="solana",t.starknet="starknet",t.sui="sui",t))(e||{});exports.BlockchainType=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var r=(t=>(t.bitcoin="bitcoin",t.evm="evm",t.solana="solana",t.starknet="starknet",t.sui="sui",t.tron="tron",t))(r||{});exports.BlockchainType=r;
package/dist/index3.js CHANGED
@@ -1,4 +1,4 @@
1
- var r = /* @__PURE__ */ ((t) => (t.bitcoin = "bitcoin", t.evm = "evm", t.solana = "solana", t.starknet = "starknet", t.sui = "sui", t))(r || {});
1
+ var r = /* @__PURE__ */ ((t) => (t.bitcoin = "bitcoin", t.evm = "evm", t.solana = "solana", t.starknet = "starknet", t.sui = "sui", t.tron = "tron", t))(r || {});
2
2
  export {
3
3
  r as BlockchainType
4
4
  };