@gardenfi/react-hooks 0.0.2-beta.2 → 0.0.2-beta.3

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/index3.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@gardenfi/core"),o=require("react"),f=e=>{const[b,c]=o.useState([]);return o.useEffect(()=>{if(!e||!e.secretManager.isInitialized)return;console.log("started executor",e.secretManager.isInitialized);const n=e.execute(),r=s=>c(s);return e.on("onPendingOrdersChanged",r),()=>{(async()=>(await n)())(),e.off("onPendingOrdersChanged",r)}},[e]),o.useEffect(()=>{e&&e.blockNumberFetcher.fetchBlockNumbers().then(n=>{if(n.error)return;const{val:r}=n;e.orderbook.fetchOrders(!0,!0,{per_page:500}).then(s=>{if(s.error)return;const l=a.filterDeadlineExpiredOrders(s.val.data).map(t=>{const i=r[t.source_swap.chain],u=r[t.destination_swap.chain];if(!i||!u)return;const d=a.ParseOrderStatus(t,i,u);return{...t,status:d}}).filter(t=>t!==void 0);c(l)})})},[e]),{pendingOrders:b}};exports.useOrderbook=f;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("@gardenfi/core"),o=require("react"),f=e=>{const[i,c]=o.useState([]);return console.log("pendingOrders inside orderbook :",i),console.log("garden inside orderbook",e),o.useEffect(()=>{if(!e||!e.secretManager.isInitialized)return;console.log("started executor",e.secretManager.isInitialized);const n=e.execute(),t=s=>c(s);return e.on("onPendingOrdersChanged",t),()=>{(async()=>(await n)())(),e.off("onPendingOrdersChanged",t)}},[e]),o.useEffect(()=>{e&&e.blockNumberFetcher.fetchBlockNumbers().then(n=>{if(n.error)return;const{val:t}=n;e.orderbook.fetchOrders(!0,!0,{per_page:500}).then(s=>{if(s.error)return;const l=d.filterDeadlineExpiredOrders(s.val.data).map(r=>{const u=t[r.source_swap.chain],a=t[r.destination_swap.chain];if(!u||!a)return;const b=d.ParseOrderStatus(r,u,a);return{...r,status:b}}).filter(r=>r!==void 0);c(l)})})},[e]),{pendingOrders:i}};exports.useOrderbook=f;
package/dist/index3.js CHANGED
@@ -1,39 +1,39 @@
1
- import { filterDeadlineExpiredOrders as l, ParseOrderStatus as d } from "@gardenfi/core";
2
- import { useState as h, useEffect as u } from "react";
1
+ import { filterDeadlineExpiredOrders as b, ParseOrderStatus as f } from "@gardenfi/core";
2
+ import { useState as h, useEffect as a } from "react";
3
3
  const O = (e) => {
4
- const [a, o] = h([]);
5
- return u(() => {
4
+ const [o, i] = h([]);
5
+ return console.log("pendingOrders inside orderbook :", o), console.log("garden inside orderbook", e), a(() => {
6
6
  if (!e || !e.secretManager.isInitialized) return;
7
7
  console.log("started executor", e.secretManager.isInitialized);
8
- const s = e.execute(), r = (n) => o(n);
9
- return e.on("onPendingOrdersChanged", r), () => {
10
- (async () => (await s)())(), e.off("onPendingOrdersChanged", r);
8
+ const s = e.execute(), t = (n) => i(n);
9
+ return e.on("onPendingOrdersChanged", t), () => {
10
+ (async () => (await s)())(), e.off("onPendingOrdersChanged", t);
11
11
  };
12
- }, [e]), u(() => {
12
+ }, [e]), a(() => {
13
13
  e && e.blockNumberFetcher.fetchBlockNumbers().then((s) => {
14
14
  if (s.error) return;
15
- const { val: r } = s;
15
+ const { val: t } = s;
16
16
  e.orderbook.fetchOrders(!0, !0, {
17
17
  per_page: 500
18
18
  }).then((n) => {
19
19
  if (n.error) return;
20
- const b = l(n.val.data).map((t) => {
21
- const i = r[t.source_swap.chain], c = r[t.destination_swap.chain];
22
- if (!i || !c) return;
23
- const f = d(
24
- t,
25
- i,
26
- c
20
+ const d = b(n.val.data).map((r) => {
21
+ const c = t[r.source_swap.chain], u = t[r.destination_swap.chain];
22
+ if (!c || !u) return;
23
+ const l = f(
24
+ r,
25
+ c,
26
+ u
27
27
  );
28
28
  return {
29
- ...t,
30
- status: f
29
+ ...r,
30
+ status: l
31
31
  };
32
- }).filter((t) => t !== void 0);
33
- o(b);
32
+ }).filter((r) => r !== void 0);
33
+ i(d);
34
34
  });
35
35
  });
36
- }, [e]), { pendingOrders: a };
36
+ }, [e]), { pendingOrders: o };
37
37
  };
38
38
  export {
39
39
  O as useOrderbook
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gardenfi/react-hooks",
3
- "version": "0.0.2-beta.2",
3
+ "version": "0.0.2-beta.3",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",