@gardenfi/orderbook 3.1.3-beta.5 → 3.1.3-beta.7

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/index11.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("@gardenfi/utils"),y=require("./index12.cjs"),p=require("./index4.cjs"),r=require("./index8.cjs"),o=require("./index13.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),a=o.buildDefaultEndpoint(e,"/v2/chains"),i=o.buildDefaultEndpoint(e,"/v2/policy");this.urls={base:e,assets:o.ensureUrl(t.assetsUrl??a),policy:o.ensureUrl(t.policyUrl??i)},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:a}=this.processApiData(s.result);return this.assets=e,this.chains=a,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 a=e.toString();return Object.values(this.assets).find(i=>r.ChainAsset.from(i).toString()===a)}).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 a of t){const i=this.parseChainIdentifier(a.chain);if(!i||!h.includes(i))continue;const u={...a,name:a.name||this.formatChainName(i),chain:i};for(const l of a.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:i,name:d,symbol:f};s[c]=A,e[i]||(e[i]=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 n=require("@gardenfi/utils"),y=require("./index12.cjs"),p=require("./index4.cjs"),r=require("./index8.cjs"),o=require("./index14.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),a=o.buildDefaultEndpoint(e,"/v2/chains"),i=o.buildDefaultEndpoint(e,"/v2/policy");this.urls={base:e,assets:o.ensureUrl(t.assetsUrl??a),policy:o.ensureUrl(t.policyUrl??i)},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:a}=this.processApiData(s.result);return this.assets=e,this.chains=a,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 a=e.toString();return Object.values(this.assets).find(i=>r.ChainAsset.from(i).toString()===a)}).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 a of t){const i=this.parseChainIdentifier(a.chain);if(!i||!h.includes(i))continue;const u={...a,name:a.name||this.formatChainName(i),chain:i};for(const l of a.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:i,name:d,symbol:f};s[c]=A,e[i]||(e[i]=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;
package/dist/index11.js CHANGED
@@ -2,7 +2,7 @@ import { ApiKey as A, Err as o, Fetcher as y, Ok as g } from "@gardenfi/utils";
2
2
  import { RouteValidator as C } from "./index12.js";
3
3
  import { Config as b } from "./index4.js";
4
4
  import { ChainAsset as r } from "./index8.js";
5
- import { ensureUrl as l, buildDefaultEndpoint as u, parseAssetNameSymbol as w } from "./index13.js";
5
+ import { ensureUrl as l, buildDefaultEndpoint as u, parseAssetNameSymbol as w } from "./index14.js";
6
6
  const c = Object.keys(b);
7
7
  class I {
8
8
  constructor(t, s) {
package/dist/index13.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 e={INVALID_SEND_AMOUNT:"invalid send amount",INVALID_RECEIVE_AMOUNT:"invalid receive amount",UNSUPPORTED_CHAIN:"unsupported chain",SAME_ASSET:"cannot create orderpair with the same assets",INVALID_AS_ADDRESS:"invalid atomic swap address",INVALID_TOKEN:"invalid token address",INVALID_AMOUNTS:"invalid amounts",RECEIVE_AMOUNT_GREATER:"receive amount is greater than send amount",INSUFFICIENT_LIQUIDITY:"insufficient liquidity"};exports.OrderbookErrors=e;
package/dist/index13.js CHANGED
@@ -1,31 +1,14 @@
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 };
11
- }
12
- let s = "";
13
- if (t)
14
- try {
15
- s = (typeof t == "string" ? c.from(t) : t).symbol.toUpperCase();
16
- } catch {
17
- }
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}`;
26
- }
1
+ const e = {
2
+ INVALID_SEND_AMOUNT: "invalid send amount",
3
+ INVALID_RECEIVE_AMOUNT: "invalid receive amount",
4
+ UNSUPPORTED_CHAIN: "unsupported chain",
5
+ SAME_ASSET: "cannot create orderpair with the same assets",
6
+ INVALID_AS_ADDRESS: "invalid atomic swap address",
7
+ INVALID_TOKEN: "invalid token address",
8
+ INVALID_AMOUNTS: "invalid amounts",
9
+ RECEIVE_AMOUNT_GREATER: "receive amount is greater than send amount",
10
+ INSUFFICIENT_LIQUIDITY: "insufficient liquidity"
11
+ };
27
12
  export {
28
- f as buildDefaultEndpoint,
29
- d as ensureUrl,
30
- $ as parseAssetNameSymbol
13
+ e as OrderbookErrors
31
14
  };
@@ -0,0 +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;
@@ -0,0 +1,31 @@
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 };
11
+ }
12
+ let s = "";
13
+ if (t)
14
+ try {
15
+ s = (typeof t == "string" ? c.from(t) : t).symbol.toUpperCase();
16
+ } catch {
17
+ }
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}`;
26
+ }
27
+ export {
28
+ f as buildDefaultEndpoint,
29
+ d as ensureUrl,
30
+ $ as parseAssetNameSymbol
31
+ };
package/dist/index2.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("@gardenfi/utils"),c=require("./index7.cjs"),d=require("./index10.cjs");class l{constructor(o,s){this.url=o,this.auth=s}async createOrder(o){try{const s=await this.auth.getAuthHeaders();if(s.error)return r.Err(s.error);const e=await r.Fetcher.post(this.url.endpoint("/v2/orders"),{body:JSON.stringify(o),headers:{...s.val,"Content-Type":"application/json"}});if(e.error)return r.Err(e.error);if(!e.result)return r.Err("CreateOrder: Unexpected error, result is undefined");const i=c.discriminateOrderResponse(e.result);return i?r.Ok(i):r.Err("CreateOrder: Unable to determine order type from response")}catch(s){return r.Err("CreateOrder Err:",String(s))}}async getOrder(o,s){try{const e=await this.auth.getAuthHeaders();if(e.error)return r.Err(e.error);const i=this.url.endpoint("/v2/orders").endpoint(o),n=await r.Fetcher.get(i,{...s,headers:{...e.val,"Content-Type":"application/json"}});if(n.error)return r.Err(n.error);if(!n.result)return r.Err("GetOrder: Unexpected error, result is undefined");const t=d.ParseOrderStatus(n.result);return r.Ok({...n.result,status:t})}catch(e){return r.Err(`GetOrder: ${e instanceof Error?e.message:String(e)}`)}}async getOrders(o,s){const e=await this.auth.getAuthHeaders();if(e.error)return r.Err(e.error);const n=c.ConstructUrl(this.url,"/v2/orders",o);try{const t=await r.Fetcher.get(n,{...s,headers:{...e.val,"Content-Type":"application/json"}});if(t.error)return r.Err(t.error);if(!t.result)return r.Err("GetAllOrders: Unexpected error, result is undefined");const u=t.result.data.map(a=>({...a,status:d.ParseOrderStatus(a)}));return r.Ok({...t.result,data:u})}catch(t){return r.Err(`GetAllOrders: ${t instanceof Error?t.message:String(t)}`)}}async subscribeOrders(o,s,e,i){let n=!1;const t=async()=>{if(!n){n=!0;try{const a=await this.getOrders(o,i);a.ok?await s(a.val):console.error("Error fetching orders:",a.error)}catch(a){console.error("Error fetching orders:",a)}finally{n=!1}}};await t();const u=setInterval(t,e);return()=>{clearInterval(u)}}}exports.Orderbook=l;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("@gardenfi/utils"),c=require("./index7.cjs"),d=require("./index10.cjs"),l=require("./index13.cjs");class h{constructor(o,n){this.url=o,this.auth=n}async createOrder(o){try{const n=await this.auth.getAuthHeaders();if(n.error)return r.Err(n.error);const e=await r.Fetcher.post(this.url.endpoint("/v2/orders"),{body:JSON.stringify(o),headers:{...n.val,"Content-Type":"application/json"},onRetry:t=>!((t==null?void 0:t.message)||(t==null?void 0:t.toString())||"").toLowerCase().includes(l.OrderbookErrors.INSUFFICIENT_LIQUIDITY)});if(e.error)return r.Err(e.error);if(!e.result)return r.Err("CreateOrder: Unexpected error, result is undefined");const i=c.discriminateOrderResponse(e.result);return i?r.Ok(i):r.Err("CreateOrder: Unable to determine order type from response")}catch(n){return r.Err("CreateOrder Err:",String(n))}}async getOrder(o,n){try{const e=await this.auth.getAuthHeaders();if(e.error)return r.Err(e.error);const i=this.url.endpoint("/v2/orders").endpoint(o),t=await r.Fetcher.get(i,{...n,headers:{...e.val,"Content-Type":"application/json"}});if(t.error)return r.Err(t.error);if(!t.result)return r.Err("GetOrder: Unexpected error, result is undefined");const s=d.ParseOrderStatus(t.result);return r.Ok({...t.result,status:s})}catch(e){return r.Err(`GetOrder: ${e instanceof Error?e.message:String(e)}`)}}async getOrders(o,n){const e=await this.auth.getAuthHeaders();if(e.error)return r.Err(e.error);const t=c.ConstructUrl(this.url,"/v2/orders",o);try{const s=await r.Fetcher.get(t,{...n,headers:{...e.val,"Content-Type":"application/json"}});if(s.error)return r.Err(s.error);if(!s.result)return r.Err("GetAllOrders: Unexpected error, result is undefined");const u=s.result.data.map(a=>({...a,status:d.ParseOrderStatus(a)}));return r.Ok({...s.result,data:u})}catch(s){return r.Err(`GetAllOrders: ${s instanceof Error?s.message:String(s)}`)}}async subscribeOrders(o,n,e,i){let t=!1;const s=async()=>{if(!t){t=!0;try{const a=await this.getOrders(o,i);a.ok?await n(a.val):console.error("Error fetching orders:",a.error)}catch(a){console.error("Error fetching orders:",a)}finally{t=!1}}};await s();const u=setInterval(s,e);return()=>{clearInterval(u)}}}exports.Orderbook=h;
package/dist/index2.js CHANGED
@@ -1,84 +1,83 @@
1
- import { Err as s, Fetcher as d, Ok as c } from "@gardenfi/utils";
1
+ import { Err as o, Fetcher as d, Ok as c } from "@gardenfi/utils";
2
2
  import { discriminateOrderResponse as h, ConstructUrl as f } from "./index7.js";
3
3
  import { ParseOrderStatus as l } from "./index10.js";
4
- class m {
5
- constructor(o, t) {
6
- this.url = o, this.auth = t;
4
+ import { OrderbookErrors as p } from "./index13.js";
5
+ class w {
6
+ constructor(n, s) {
7
+ this.url = n, this.auth = s;
7
8
  }
8
- async createOrder(o) {
9
+ async createOrder(n) {
9
10
  try {
10
- const t = await this.auth.getAuthHeaders();
11
- if (t.error) return s(t.error);
11
+ const s = await this.auth.getAuthHeaders();
12
+ if (s.error) return o(s.error);
12
13
  const r = await d.post(
13
14
  this.url.endpoint("/v2/orders"),
14
15
  {
15
- body: JSON.stringify(o),
16
+ body: JSON.stringify(n),
16
17
  headers: {
17
- ...t.val,
18
+ ...s.val,
18
19
  "Content-Type": "application/json"
19
- }
20
+ },
21
+ onRetry: (e) => !((e == null ? void 0 : e.message) || (e == null ? void 0 : e.toString()) || "").toLowerCase().includes(p.INSUFFICIENT_LIQUIDITY)
20
22
  }
21
23
  );
22
- if (r.error) return s(r.error);
24
+ if (r.error) return o(r.error);
23
25
  if (!r.result)
24
- return s("CreateOrder: Unexpected error, result is undefined");
26
+ return o("CreateOrder: Unexpected error, result is undefined");
25
27
  const i = h(r.result);
26
- return i ? c(i) : s("CreateOrder: Unable to determine order type from response");
27
- } catch (t) {
28
- return s("CreateOrder Err:", String(t));
28
+ return i ? c(i) : o("CreateOrder: Unable to determine order type from response");
29
+ } catch (s) {
30
+ return o("CreateOrder Err:", String(s));
29
31
  }
30
32
  }
31
- async getOrder(o, t) {
33
+ async getOrder(n, s) {
32
34
  try {
33
35
  const r = await this.auth.getAuthHeaders();
34
- if (r.error) return s(r.error);
35
- const i = this.url.endpoint("/v2/orders").endpoint(o), n = await d.get(
36
- i,
37
- {
38
- ...t,
39
- headers: {
40
- ...r.val,
41
- "Content-Type": "application/json"
42
- }
36
+ if (r.error) return o(r.error);
37
+ const i = this.url.endpoint("/v2/orders").endpoint(n), e = await d.get(i, {
38
+ ...s,
39
+ headers: {
40
+ ...r.val,
41
+ "Content-Type": "application/json"
43
42
  }
44
- );
45
- if (n.error) return s(n.error);
46
- if (!n.result)
47
- return s("GetOrder: Unexpected error, result is undefined");
48
- const e = l(n.result);
49
- return c({ ...n.result, status: e });
43
+ });
44
+ if (e.error) return o(e.error);
45
+ if (!e.result)
46
+ return o("GetOrder: Unexpected error, result is undefined");
47
+ const t = l(e.result);
48
+ return c({ ...e.result, status: t });
50
49
  } catch (r) {
51
- return s(
50
+ return o(
52
51
  `GetOrder: ${r instanceof Error ? r.message : String(r)}`
53
52
  );
54
53
  }
55
54
  }
56
- async getOrders(o, t) {
55
+ async getOrders(n, s) {
57
56
  const r = await this.auth.getAuthHeaders();
58
- if (r.error) return s(r.error);
59
- const n = f(this.url, "/v2/orders", o);
57
+ if (r.error) return o(r.error);
58
+ const e = f(this.url, "/v2/orders", n);
60
59
  try {
61
- const e = await d.get(n, {
62
- ...t,
60
+ const t = await d.get(e, {
61
+ ...s,
63
62
  headers: {
64
63
  ...r.val,
65
64
  "Content-Type": "application/json"
66
65
  }
67
66
  });
68
- if (e.error) return s(e.error);
69
- if (!e.result)
70
- return s("GetAllOrders: Unexpected error, result is undefined");
71
- const u = e.result.data.map((a) => ({
67
+ if (t.error) return o(t.error);
68
+ if (!t.result)
69
+ return o("GetAllOrders: Unexpected error, result is undefined");
70
+ const u = t.result.data.map((a) => ({
72
71
  ...a,
73
72
  status: l(a)
74
73
  }));
75
74
  return c({
76
- ...e.result,
75
+ ...t.result,
77
76
  data: u
78
77
  });
79
- } catch (e) {
80
- return s(
81
- `GetAllOrders: ${e instanceof Error ? e.message : String(e)}`
78
+ } catch (t) {
79
+ return o(
80
+ `GetAllOrders: ${t instanceof Error ? t.message : String(t)}`
82
81
  );
83
82
  }
84
83
  }
@@ -91,28 +90,28 @@ class m {
91
90
  * @param paginationConfig - The pagination configuration
92
91
  * @returns {Promise<() => void>} A promise that resolves to the unsubscribe function.
93
92
  */
94
- async subscribeOrders(o, t, r, i) {
95
- let n = !1;
96
- const e = async () => {
97
- if (!n) {
98
- n = !0;
93
+ async subscribeOrders(n, s, r, i) {
94
+ let e = !1;
95
+ const t = async () => {
96
+ if (!e) {
97
+ e = !0;
99
98
  try {
100
- const a = await this.getOrders(o, i);
101
- a.ok ? await t(a.val) : console.error("Error fetching orders:", a.error);
99
+ const a = await this.getOrders(n, i);
100
+ a.ok ? await s(a.val) : console.error("Error fetching orders:", a.error);
102
101
  } catch (a) {
103
102
  console.error("Error fetching orders:", a);
104
103
  } finally {
105
- n = !1;
104
+ e = !1;
106
105
  }
107
106
  }
108
107
  };
109
- await e();
110
- const u = setInterval(e, r);
108
+ await t();
109
+ const u = setInterval(t, r);
111
110
  return () => {
112
111
  clearInterval(u);
113
112
  };
114
113
  }
115
114
  }
116
115
  export {
117
- m as Orderbook
116
+ w as Orderbook
118
117
  };
@@ -7,4 +7,5 @@ export declare const OrderbookErrors: {
7
7
  INVALID_TOKEN: string;
8
8
  INVALID_AMOUNTS: string;
9
9
  RECEIVE_AMOUNT_GREATER: string;
10
+ INSUFFICIENT_LIQUIDITY: string;
10
11
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gardenfi/orderbook",
3
- "version": "3.1.3-beta.5",
3
+ "version": "3.1.3-beta.7",
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": "3.1.1-beta.3",
31
+ "@gardenfi/utils": "3.1.1-beta.5",
32
32
  "bufferutil": "^4.0.8",
33
33
  "node-cache": "^5.1.2",
34
34
  "siwe": "^2.1.4",