@gardenfi/react-hooks 0.0.2-beta.6 → 0.0.2-beta.8

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