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