@gardenfi/orderbook 2.0.9-beta.15 → 2.0.9-beta.16

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/index2.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index6.cjs"),h=require("@gardenfi/utils"),i=require("./index7.cjs");class O{constructor(n){this.Url=n}async createOrder(n,o){const t=await o.getAuthHeaders();if(t.error)return r.Err(t.error);try{const s=await r.Fetcher.post(this.Url.endpoint("/relayer").endpoint("create-order"),{body:JSON.stringify(n),headers:{...t.val,"Content-Type":"application/json"}});return s.error?r.Err(s.error):s.result?r.Ok(s.result):r.Err("CreateOrder: Unexpected error, result is undefined")}catch(s){return r.Err("CreateOrder:",String(s))}}async getOrder(n,o){const t=o?`/id/matched/${n}`:`/id/unmatched/${n}`,s=this.Url.endpoint("orders").endpoint(t);try{const e=await r.Fetcher.get(s);return e.error?r.Err(e.error):e.result?r.Ok(e.result):r.Err("GetOrder: Unexpected error, result is undefined")}catch(e){return r.Err("GetOrder:",String(e))}}async getMatchedOrders(n,o,t){const s=i.ConstructUrl(this.Url.endpoint("orders"),`/user/matched/${n}`,{...t,pending:o});try{const e=await r.Fetcher.get(s);return e.error?r.Err(e.error):e.result?r.Ok(e.result):r.Err("GetMatchedOrders: Unexpected error, result is undefined")}catch(e){return r.Err("GetMatchedOrders:",String(e))}}async getUnMatchedOrders(n,o){const t=i.ConstructUrl(this.Url.endpoint("orders"),`/user/unmatched/${n}`,o);try{const s=await r.Fetcher.get(t);return s.error?r.Err(s.error):s.result?r.Ok(s.result):r.Err("GetUnMatchedOrders: Unexpected error, result is undefined")}catch(s){return r.Err("GetUnMatchedOrders:",String(s))}}async getOrders(n,o){const t=n?"/matched":"/unmatched",s=i.ConstructUrl(this.Url.endpoint("orders"),t,o);try{const e=await r.Fetcher.get(s);return e.error?r.Err(e.error):e.result?r.Ok(e.result):r.Err("GetAllOrders: Unexpected error, result is undefined")}catch(e){return r.Err("GetAllOrders:",String(e))}}async subscribeOrders(n,o,t,s,e=!1,u){let d=!1;const a=async()=>{if(!d){d=!0;try{const c=o?await this.getMatchedOrders(n,e,u):await this.getUnMatchedOrders(n,u);c.ok?await s(c.val):console.error("Error fetching orders:",c.error)}catch(c){console.error("Error fetching orders:",c)}finally{d=!1}}};await a();const l=setInterval(a,t);return()=>{clearInterval(l)}}async getOrdersCount(n){const o=this.Url.endpoint("orders").endpoint(`/user/count/${n}`);try{const t=await r.Fetcher.get(o);return t.error?r.Err(t.error):t.status===h.ApiStatus.Ok&&t.result!==void 0?r.Ok(t.result):r.Err("GetOrdersCount: Unexpected error, result is undefined")}catch(t){return r.Err("GetOrdersCount:",String(t))}}}exports.Orderbook=O;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index6.cjs"),h=require("@gardenfi/utils"),i=require("./index7.cjs");class O{constructor(n){this.Url=n}async createOrder(n,o){const t=await o.getAuthHeaders();if(t.error)return r.Err(t.error);try{const s=await r.Fetcher.post(this.Url.endpoint("/relayer").endpoint("create-order"),{body:JSON.stringify(n),headers:{...t.val,"Content-Type":"application/json"}});return s.error?r.Err(s.error):s.result?r.Ok(s.result):r.Err("CreateOrder: Unexpected error, result is undefined")}catch(s){return r.Err("CreateOrder:",String(s))}}async getOrder(n,o){const t=o?`/id/${n}/matched`:`/id/${n}/unmatched`,s=this.Url.endpoint("orders").endpoint(t);try{const e=await r.Fetcher.get(s);return e.error?r.Err(e.error):e.result?r.Ok(e.result):r.Err("GetOrder: Unexpected error, result is undefined")}catch(e){return r.Err("GetOrder:",String(e))}}async getMatchedOrders(n,o,t){const s=i.ConstructUrl(this.Url.endpoint("orders"),`/user/${n}/matched`,{...t,pending:o});try{const e=await r.Fetcher.get(s);return e.error?r.Err(e.error):e.result?r.Ok(e.result):r.Err("GetMatchedOrders: Unexpected error, result is undefined")}catch(e){return r.Err("GetMatchedOrders:",String(e))}}async getUnMatchedOrders(n,o){const t=i.ConstructUrl(this.Url.endpoint("orders"),`/user/${n}/unmatched`,o);try{const s=await r.Fetcher.get(t);return s.error?r.Err(s.error):s.result?r.Ok(s.result):r.Err("GetUnMatchedOrders: Unexpected error, result is undefined")}catch(s){return r.Err("GetUnMatchedOrders:",String(s))}}async getOrders(n,o){const t=n?"/matched":"/unmatched",s=i.ConstructUrl(this.Url.endpoint("orders"),t,o);try{const e=await r.Fetcher.get(s);return e.error?r.Err(e.error):e.result?r.Ok(e.result):r.Err("GetAllOrders: Unexpected error, result is undefined")}catch(e){return r.Err("GetAllOrders:",String(e))}}async subscribeOrders(n,o,t,s,e=!1,u){let d=!1;const a=async()=>{if(!d){d=!0;try{const c=o?await this.getMatchedOrders(n,e,u):await this.getUnMatchedOrders(n,u);c.ok?await s(c.val):console.error("Error fetching orders:",c.error)}catch(c){console.error("Error fetching orders:",c)}finally{d=!1}}};await a();const l=setInterval(a,t);return()=>{clearInterval(l)}}async getOrdersCount(n){const o=this.Url.endpoint("orders").endpoint(`/user/${n}/count`);try{const t=await r.Fetcher.get(o);return t.error?r.Err(t.error):t.status===h.ApiStatus.Ok&&t.result!==void 0?r.Ok(t.result):r.Err("GetOrdersCount: Unexpected error, result is undefined")}catch(t){return r.Err("GetOrdersCount:",String(t))}}}exports.Orderbook=O;
package/dist/index2.js CHANGED
@@ -31,7 +31,7 @@ class m {
31
31
  }
32
32
  }
33
33
  async getOrder(n, o) {
34
- const e = o ? `/id/matched/${n}` : `/id/unmatched/${n}`, t = this.Url.endpoint("orders").endpoint(e);
34
+ const e = o ? `/id/${n}/matched` : `/id/${n}/unmatched`, t = this.Url.endpoint("orders").endpoint(e);
35
35
  try {
36
36
  const r = await d.get(t);
37
37
  return r.error ? s(r.error) : r.result ? a(r.result) : s("GetOrder: Unexpected error, result is undefined");
@@ -42,7 +42,7 @@ class m {
42
42
  async getMatchedOrders(n, o, e) {
43
43
  const t = u(
44
44
  this.Url.endpoint("orders"),
45
- `/user/matched/${n}`,
45
+ `/user/${n}/matched`,
46
46
  {
47
47
  ...e,
48
48
  pending: o
@@ -60,7 +60,7 @@ class m {
60
60
  async getUnMatchedOrders(n, o) {
61
61
  const e = u(
62
62
  this.Url.endpoint("orders"),
63
- `/user/unmatched/${n}`,
63
+ `/user/${n}/unmatched`,
64
64
  o
65
65
  );
66
66
  try {
@@ -109,7 +109,7 @@ class m {
109
109
  };
110
110
  }
111
111
  async getOrdersCount(n) {
112
- const o = this.Url.endpoint("orders").endpoint(`/user/count/${n}`);
112
+ const o = this.Url.endpoint("orders").endpoint(`/user/${n}/count`);
113
113
  try {
114
114
  const e = await d.get(o);
115
115
  return e.error ? s(e.error) : e.status === f.Ok && e.result !== void 0 ? a(e.result) : s("GetOrdersCount: Unexpected error, result is undefined");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gardenfi/orderbook",
3
- "version": "2.0.9-beta.15",
3
+ "version": "2.0.9-beta.16",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -26,7 +26,7 @@
26
26
  "registry": "https://registry.npmjs.org/"
27
27
  },
28
28
  "dependencies": {
29
- "@gardenfi/utils": "2.0.6-beta.12",
29
+ "@gardenfi/utils": "2.0.6-beta.13",
30
30
  "bufferutil": "^4.0.8",
31
31
  "siwe": "^2.1.4",
32
32
  "utf-8-validate": "^6.0.3",