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

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 n=require("react"),q=require("./index3.cjs"),s=require("@gardenfi/core"),i=require("@catalogfi/utils"),m=require("@gardenfi/orderbook"),x=require("./index5.cjs"),w=n.createContext({isExecuting:!1,isExecutorRequired:!1}),S=({children:u,config:a})=>{const[e,v]=n.useState(),[C,O]=n.useState(),{pendingOrders:d}=q.useOrderbook(e),E=n.useMemo(()=>!!(e!=null&&e.secretManager.isInitialized),[e]),f=n.useMemo(()=>!!d.find(r=>{const t=r.status;return t===s.OrderStatus.InitiateDetected||t===s.OrderStatus.Initiated||t===s.OrderStatus.CounterPartyInitiateDetected||t===s.OrderStatus.CounterPartyInitiated||t===s.OrderStatus.RedeemDetected||t===s.OrderStatus.Expired}),[d]),G=async r=>{if(!e||!a.walletClient)return i.Err("Garden not initialized");const t=await e.swap(r);if(t.error)return i.Err(t.error);if(m.isBitcoin(t.val.source_swap.chain))return i.Ok(t.val);const o=await s.switchOrAddNetwork(r.fromAsset.chain,a.walletClient);if(o.error)return i.Err("Failed to switch network: "+o.error);const l=o.val.walletClient,c=await e.evmRelay.init(l,t.val);if(c.error)return i.Err(c.error);const h={...t.val,source_swap:{...t.val.source_swap,initiate_tx_hash:c.val}};return i.Ok(h)};return n.useEffect(()=>{var r;if(a.walletClient){if(!((r=a.walletClient.account)!=null&&r.address))throw new Error("WalletClient doesn't have an account");v(new s.Garden({environment:a.environment,evmWallet:a.walletClient}))}},[a.walletClient]),n.useEffect(()=>{e&&O(()=>async({fromAsset:r,toAsset:t,amount:o,isExactOut:l=!1})=>await e.quote.getQuote(x.constructOrderpair(r,t),o,l))},[e]),n.createElement(w.Provider,{value:{orderBook:e==null?void 0:e.orderbook,quote:e==null?void 0:e.quote,swapAndInitiate:G,pendingOrders:d,getQuote:C,garden:e,isExecuting:E,isExecutorRequired:f}},u)},k=()=>{const u=n.useContext(w);if(!u)throw new Error("useGarden must be used within a GardenProvider");return u};exports.GardenContext=w;exports.GardenProvider=S;exports.useGarden=k;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react"),S=require("./index3.cjs"),n=require("@gardenfi/core"),a=require("./index5.cjs"),p=require("@gardenfi/orderbook"),_=require("./index6.cjs"),h=s.createContext({isExecuting:!1,isExecutorRequired:!1}),R=({children:d,config:t})=>{var C,O;const[i,m]=s.useState(),{pendingOrders:c,isExecuting:E,digestKey:w}=S.useOrderbook(i,(O=(C=t.walletClient)==null?void 0:C.account)==null?void 0:O.address),y=s.useMemo(()=>!!c.find(r=>{const e=r.status;return e===n.OrderStatus.InitiateDetected||e===n.OrderStatus.Initiated||e===n.OrderStatus.CounterPartyInitiateDetected||e===n.OrderStatus.CounterPartyInitiated||e===n.OrderStatus.RedeemDetected||e===n.OrderStatus.Expired}),[c]),v=s.useMemo(()=>new n.Quote(t.quoteUrl||n.API[t.environment].quote),[t.quoteUrl,t.environment]),k=s.useMemo(()=>async({fromAsset:r,toAsset:e,amount:o,isExactOut:u=!1,request:l})=>await v.getQuote(_.constructOrderpair(r,e),o,u,l),[v]),q=async r=>{if(!i||!t.walletClient)return a.Err("Garden not initialized");const e=await i.swap(r);if(e.error)return a.Err(e.error);if(p.isBitcoin(e.val.source_swap.chain))return a.Ok(e.val);const o=await n.switchOrAddNetwork(r.fromAsset.chain,t.walletClient);if(o.error)return a.Err("Failed to switch network: "+o.error);const u=o.val.walletClient,l=await i.evmRelay.init(u,e.val);if(l.error)return a.Err(l.error);const G={...e.val,source_swap:{...e.val.source_swap,initiate_tx_hash:l.val}};return a.Ok(G)},x=async r=>{if(!i||!t.walletClient)return a.Err("garden not initialized");if(p.isBitcoin(r.source_swap.chain))return a.Err("Not an EVM order: sourceSwap.chain is Bitcoin");const e=await n.switchOrAddNetwork(r.source_swap.chain,t.walletClient);if(e.error)return a.Err("Failed to switch network: "+e.error);const o=e.val.walletClient,u=await i.evmRelay.init(o,r);if(u.error)return a.Err(u.error);const l={...r,source_swap:{...r.source_swap,initiate_tx_hash:u.val}};return a.Ok(l)};return s.useEffect(()=>{var e;if(!t.walletClient)return;if(!((e=t.walletClient.account)!=null&&e.address))throw new Error("WalletClient doesn't have an account");const r=w?n.SecretManager.fromDigestKey(w):void 0;m(new n.Garden({environment:t.environment,evmWallet:t.walletClient,siweOpts:t.siweOpts??{domain:window.location.hostname,store:t.store},apiKey:t.apiKey,secretManager:r}))},[t.walletClient,w]),s.createElement(h.Provider,{value:{orderBook:i==null?void 0:i.orderbook,quote:v,swapAndInitiate:q,pendingOrders:c,getQuote:k,garden:i,isExecuting:E,isExecutorRequired:y,evmInitiate:x}},d)},P=()=>{const d=s.useContext(h);if(!d)throw new Error("useGarden must be used within a GardenProvider");return d};exports.GardenContext=h;exports.GardenProvider=R;exports.useGarden=P;
package/dist/index2.js CHANGED
@@ -1,90 +1,122 @@
1
- import v, { createContext as k, useState as d, useMemo as w, useEffect as m } from "react";
2
- import { useOrderbook as I } from "./index3.js";
3
- import { OrderStatus as i, Garden as q, switchOrAddNetwork as y } from "@gardenfi/core";
4
- import { Err as s, Ok as f } from "@catalogfi/utils";
5
- import { isBitcoin as P } from "@gardenfi/orderbook";
6
- import { constructOrderpair as _ } from "./index5.js";
7
- const p = k({
1
+ import y, { createContext as q, useState as P, useMemo as m, useEffect as W } from "react";
2
+ import { useOrderbook as A } from "./index3.js";
3
+ import { OrderStatus as l, Quote as D, API as K, SecretManager as M, Garden as S, switchOrAddNetwork as C } from "@gardenfi/core";
4
+ import { Err as a, Ok as p } from "./index5.js";
5
+ import { isBitcoin as x } from "@gardenfi/orderbook";
6
+ import { constructOrderpair as b } from "./index6.js";
7
+ const E = q({
8
8
  isExecuting: !1,
9
9
  isExecutorRequired: !1
10
- }), B = ({
11
- children: a,
12
- config: n
10
+ }), V = ({
11
+ children: u,
12
+ config: t
13
13
  }) => {
14
- const [e, C] = d(), [h, x] = d(), { pendingOrders: u } = I(e), E = w(() => !!(e != null && e.secretManager.isInitialized), [e]), G = w(() => !!u.find((r) => {
15
- const t = r.status;
16
- return t === i.InitiateDetected || t === i.Initiated || t === i.CounterPartyInitiateDetected || t === i.CounterPartyInitiated || t === i.RedeemDetected || t === i.Expired;
17
- }), [u]), O = async (r) => {
18
- if (!e || !n.walletClient) return s("Garden not initialized");
19
- const t = await e.swap(r);
20
- if (t.error) return s(t.error);
21
- if (P(t.val.source_swap.chain)) return f(t.val);
22
- const o = await y(
14
+ var v, h;
15
+ const [n, _] = P(), { pendingOrders: c, isExecuting: f, digestKey: d } = A(
16
+ n,
17
+ (h = (v = t.walletClient) == null ? void 0 : v.account) == null ? void 0 : h.address
18
+ ), O = m(() => !!c.find((r) => {
19
+ const e = r.status;
20
+ return e === l.InitiateDetected || e === l.Initiated || e === l.CounterPartyInitiateDetected || e === l.CounterPartyInitiated || e === l.RedeemDetected || e === l.Expired;
21
+ }), [c]), w = m(() => new D(t.quoteUrl || K[t.environment].quote), [t.quoteUrl, t.environment]), R = m(
22
+ () => async ({
23
+ fromAsset: r,
24
+ toAsset: e,
25
+ amount: i,
26
+ isExactOut: s = !1,
27
+ request: o
28
+ }) => await w.getQuote(
29
+ b(r, e),
30
+ i,
31
+ s,
32
+ o
33
+ ),
34
+ [w]
35
+ ), G = async (r) => {
36
+ if (!n || !t.walletClient) return a("Garden not initialized");
37
+ const e = await n.swap(r);
38
+ if (e.error) return a(e.error);
39
+ if (x(e.val.source_swap.chain)) return p(e.val);
40
+ const i = await C(
23
41
  r.fromAsset.chain,
24
- n.walletClient
42
+ t.walletClient
25
43
  );
26
- if (o.error)
27
- return s("Failed to switch network: " + o.error);
28
- const l = o.val.walletClient, c = await e.evmRelay.init(l, t.val);
29
- if (c.error) return s(c.error);
30
- const R = {
31
- ...t.val,
44
+ if (i.error)
45
+ return a("Failed to switch network: " + i.error);
46
+ const s = i.val.walletClient, o = await n.evmRelay.init(s, e.val);
47
+ if (o.error) return a(o.error);
48
+ const I = {
49
+ ...e.val,
32
50
  source_swap: {
33
- ...t.val.source_swap,
34
- initiate_tx_hash: c.val
51
+ ...e.val.source_swap,
52
+ initiate_tx_hash: o.val
35
53
  }
36
54
  };
37
- return f(R);
55
+ return p(I);
56
+ }, k = async (r) => {
57
+ if (!n || !t.walletClient) return a("garden not initialized");
58
+ if (x(r.source_swap.chain))
59
+ return a("Not an EVM order: sourceSwap.chain is Bitcoin");
60
+ const e = await C(
61
+ r.source_swap.chain,
62
+ t.walletClient
63
+ );
64
+ if (e.error)
65
+ return a("Failed to switch network: " + e.error);
66
+ const i = e.val.walletClient, s = await n.evmRelay.init(i, r);
67
+ if (s.error) return a(s.error);
68
+ const o = {
69
+ ...r,
70
+ source_swap: {
71
+ ...r.source_swap,
72
+ initiate_tx_hash: s.val
73
+ }
74
+ };
75
+ return p(o);
38
76
  };
39
- return m(() => {
40
- var r;
41
- if (n.walletClient) {
42
- if (!((r = n.walletClient.account) != null && r.address))
43
- throw new Error("WalletClient doesn't have an account");
44
- C(
45
- new q({
46
- environment: n.environment,
47
- evmWallet: n.walletClient
48
- })
49
- );
50
- }
51
- }, [n.walletClient]), m(() => {
52
- e && x(
53
- () => async ({
54
- fromAsset: r,
55
- toAsset: t,
56
- amount: o,
57
- isExactOut: l = !1
58
- }) => await e.quote.getQuote(
59
- _(r, t),
60
- o,
61
- l
62
- )
77
+ return W(() => {
78
+ var e;
79
+ if (!t.walletClient) return;
80
+ if (!((e = t.walletClient.account) != null && e.address))
81
+ throw new Error("WalletClient doesn't have an account");
82
+ const r = d ? M.fromDigestKey(d) : void 0;
83
+ _(
84
+ new S({
85
+ environment: t.environment,
86
+ evmWallet: t.walletClient,
87
+ siweOpts: t.siweOpts ?? {
88
+ domain: window.location.hostname,
89
+ store: t.store
90
+ },
91
+ apiKey: t.apiKey,
92
+ secretManager: r
93
+ })
63
94
  );
64
- }, [e]), /* @__PURE__ */ v.createElement(
65
- p.Provider,
95
+ }, [t.walletClient, d]), /* @__PURE__ */ y.createElement(
96
+ E.Provider,
66
97
  {
67
98
  value: {
68
- orderBook: e == null ? void 0 : e.orderbook,
69
- quote: e == null ? void 0 : e.quote,
70
- swapAndInitiate: O,
71
- pendingOrders: u,
72
- getQuote: h,
73
- garden: e,
74
- isExecuting: E,
75
- isExecutorRequired: G
99
+ orderBook: n == null ? void 0 : n.orderbook,
100
+ quote: w,
101
+ swapAndInitiate: G,
102
+ pendingOrders: c,
103
+ getQuote: R,
104
+ garden: n,
105
+ isExecuting: f,
106
+ isExecutorRequired: O,
107
+ evmInitiate: k
76
108
  }
77
109
  },
78
- a
110
+ u
79
111
  );
80
- }, M = () => {
81
- const a = v.useContext(p);
82
- if (!a)
112
+ }, j = () => {
113
+ const u = y.useContext(E);
114
+ if (!u)
83
115
  throw new Error("useGarden must be used within a GardenProvider");
84
- return a;
116
+ return u;
85
117
  };
86
118
  export {
87
- p as GardenContext,
88
- B as GardenProvider,
89
- M as useGarden
119
+ E as GardenContext,
120
+ V as GardenProvider,
121
+ j as useGarden
90
122
  };
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 l=require("@gardenfi/core"),s=require("react"),M=(e,o)=>{const[b,u]=s.useState([]),[c,h]=s.useState(!1),[d,O]=s.useState({}),p=o?d[o]:void 0;return s.useEffect(()=>{if(!e)return;const r=()=>{if(e.secretManager.isInitialized){if(h(!0),!o)return;e.secretManager.getDigestKey().then(t=>{if(t.error){console.error("Failed to get Master DigestKey:",t.error);return}O(i=>({...i,[o]:t.val}))})}};return r(),e.secretManager.on("initialized",r),()=>{e.secretManager.off("initialized",r)}},[e]),s.useEffect(()=>{if(!e||!c)return;const r=e.execute(),t=i=>u(i);return e.on("onPendingOrdersChanged",t),()=>{(async()=>(await r)())(),e.off("onPendingOrdersChanged",t)}},[e,c]),s.useEffect(()=>{e&&e.blockNumberFetcher.fetchBlockNumbers().then(r=>{if(r.error)return;const{val:t}=r;e.orderbook.fetchOrders(!0,!0,{per_page:500}).then(i=>{if(i.error)return;const g=l.filterDeadlineExpiredOrders(i.val.data).map(n=>{const a=t[n.source_swap.chain],f=t[n.destination_swap.chain];if(!a||!f)return;const y=l.ParseOrderStatus(n,a,f);return{...n,status:y}}).filter(n=>n!==void 0);u(g)})})},[e]),{pendingOrders:b,isExecuting:c,digestKey:p}};exports.useOrderbook=M;
package/dist/index3.js CHANGED
@@ -1,40 +1,59 @@
1
- import { filterDeadlineExpiredOrders as l, ParseOrderStatus as d } from "@gardenfi/core";
2
- import { useState as h, useEffect as u } from "react";
3
- const O = (e) => {
4
- const [a, o] = h([]);
1
+ import { filterDeadlineExpiredOrders as M, ParseOrderStatus as k } from "@gardenfi/core";
2
+ import { useState as c, useEffect as u } from "react";
3
+ const v = (e, s) => {
4
+ const [b, a] = c([]), [o, h] = c(!1), [p, m] = c({}), O = s ? p[s] : void 0;
5
5
  return u(() => {
6
- if (!e || !e.secretManager.isInitialized) return;
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);
6
+ if (!e) return;
7
+ const r = () => {
8
+ if (e.secretManager.isInitialized) {
9
+ if (h(!0), !s) return;
10
+ e.secretManager.getDigestKey().then((t) => {
11
+ if (t.error) {
12
+ console.error("Failed to get Master DigestKey:", t.error);
13
+ return;
14
+ }
15
+ m((i) => ({
16
+ ...i,
17
+ [s]: t.val
18
+ }));
19
+ });
20
+ }
21
+ };
22
+ return r(), e.secretManager.on("initialized", r), () => {
23
+ e.secretManager.off("initialized", r);
11
24
  };
12
25
  }, [e]), u(() => {
13
- e && e.blockNumberFetcher.fetchBlockNumbers().then((s) => {
14
- if (s.error) return;
15
- const { val: r } = s;
26
+ if (!e || !o) return;
27
+ const r = e.execute(), t = (i) => a(i);
28
+ return e.on("onPendingOrdersChanged", t), () => {
29
+ (async () => (await r)())(), e.off("onPendingOrdersChanged", t);
30
+ };
31
+ }, [e, o]), u(() => {
32
+ e && e.blockNumberFetcher.fetchBlockNumbers().then((r) => {
33
+ if (r.error) return;
34
+ const { val: t } = r;
16
35
  e.orderbook.fetchOrders(!0, !0, {
17
36
  per_page: 500
18
- }).then((n) => {
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
37
+ }).then((i) => {
38
+ if (i.error) return;
39
+ const d = M(i.val.data).map((n) => {
40
+ const f = t[n.source_swap.chain], l = t[n.destination_swap.chain];
41
+ if (!f || !l) return;
42
+ const g = k(
43
+ n,
44
+ f,
45
+ l
27
46
  );
28
47
  return {
29
- ...t,
30
- status: f
48
+ ...n,
49
+ status: g
31
50
  };
32
- }).filter((t) => t !== void 0);
33
- o(b);
51
+ }).filter((n) => n !== void 0);
52
+ a(d);
34
53
  });
35
54
  });
36
- }, [e]), { pendingOrders: a };
55
+ }, [e]), { pendingOrders: b, isExecuting: o, digestKey: O };
37
56
  };
38
57
  export {
39
- O as useOrderbook
58
+ v as useOrderbook
40
59
  };
package/dist/index5.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=(r,c)=>`${r.chain}:${r.atomicSwapAddress}::${c.chain}:${c.atomicSwapAddress}`;exports.constructOrderpair=a;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var u=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},l=(e,t,r)=>(u(e,t,"read from private field"),r?r.call(e):t.get(e)),f=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},h=(e,t,r,i)=>(u(e,t,"write to private field"),t.set(e,r),r),n,o,a;class s{constructor(t,r,i=void 0){f(this,n,void 0),f(this,o,void 0),f(this,a,void 0),h(this,n,t),h(this,a,i),h(this,o,r)}get ok(){return l(this,n)}get error(){return l(this,a)}get val(){return l(this,o)}}n=new WeakMap,o=new WeakMap,a=new WeakMap;const d=e=>new s(!0,e),v=(e,...t)=>{if(typeof e=="string"&&t&&t.length>0){let r=[e,...t].map(i=>{if(i){if(i instanceof Error)return i.message;if(typeof i=="string")return i;if(i!=null&&i.toString)return i.toString()}});return new s(!1,null,r.filter(i=>i!==void 0).join(" "))}return new s(!1,null,e)};exports.Err=v;exports.Ok=d;exports.Result=s;
package/dist/index5.js CHANGED
@@ -1,4 +1,48 @@
1
- const r = (a, c) => `${a.chain}:${a.atomicSwapAddress}::${c.chain}:${c.atomicSwapAddress}`;
1
+ var u = (e, t, r) => {
2
+ if (!t.has(e))
3
+ throw TypeError("Cannot " + r);
4
+ }, s = (e, t, r) => (u(e, t, "read from private field"), r ? r.call(e) : t.get(e)), h = (e, t, r) => {
5
+ if (t.has(e))
6
+ throw TypeError("Cannot add the same private member more than once");
7
+ t instanceof WeakSet ? t.add(e) : t.set(e, r);
8
+ }, l = (e, t, r, i) => (u(e, t, "write to private field"), t.set(e, r), r), n, a, o;
9
+ class f {
10
+ constructor(t, r, i = void 0) {
11
+ h(this, n, void 0), h(this, a, void 0), h(this, o, void 0), l(this, n, t), l(this, o, i), l(this, a, r);
12
+ }
13
+ get ok() {
14
+ return s(this, n);
15
+ }
16
+ get error() {
17
+ return s(this, o);
18
+ }
19
+ get val() {
20
+ return s(this, a);
21
+ }
22
+ }
23
+ n = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new WeakMap(), o = /* @__PURE__ */ new WeakMap();
24
+ const d = (e) => new f(!0, e), p = (e, ...t) => {
25
+ if (typeof e == "string" && t && t.length > 0) {
26
+ let r = [e, ...t].map((i) => {
27
+ if (i) {
28
+ if (i instanceof Error)
29
+ return i.message;
30
+ if (typeof i == "string")
31
+ return i;
32
+ if (i != null && i.toString)
33
+ return i.toString();
34
+ }
35
+ });
36
+ return new f(
37
+ !1,
38
+ null,
39
+ r.filter((i) => i !== void 0).join(" ")
40
+ );
41
+ }
42
+ return new f(!1, null, e);
43
+ };
2
44
  export {
3
- r as constructOrderpair
45
+ p as Err,
46
+ d as Ok,
47
+ f as Result
4
48
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=(r,c)=>`${r.chain}:${r.atomicSwapAddress}::${c.chain}:${c.atomicSwapAddress}`;exports.constructOrderpair=a;
package/dist/index6.js ADDED
@@ -0,0 +1,4 @@
1
+ const r = (a, c) => `${a.chain}:${a.atomicSwapAddress}::${c.chain}:${c.atomicSwapAddress}`;
2
+ export {
3
+ r as constructOrderpair
4
+ };
@@ -1,4 +1,5 @@
1
1
  export { GardenProvider, useGarden } from './lib/context/GardenProvider';
2
+ export type { QuoteParams, GardenContextType, GardenProviderProps, } from './lib/context/gardenProvider.types';
2
3
  export { useOrderbook } from './lib/hooks/useOrderbook';
3
4
  export { BitcoinNetwork } from '@catalogfi/wallets';
4
5
  export { environment, GARDEN_CONFIG } from './lib/gardenConfig';
@@ -1,8 +1,8 @@
1
1
  import { WalletClient } from 'viem';
2
2
  import { OrderWithStatus, IGardenJS, IQuote, QuoteResponse, SwapParams } from '@gardenfi/core';
3
- import { AsyncResult, Result } from '@catalogfi/utils';
3
+ import { AsyncResult, Request, Result } from '@catalogfi/utils';
4
4
  import { Asset, IOrderbook, MatchedOrder } from '@gardenfi/orderbook';
5
- import { Environment, IStore } from '@gardenfi/utils';
5
+ import { Environment, IStore, SiweOpts } from '@gardenfi/utils';
6
6
 
7
7
  export type GardenContextType = {
8
8
  /**
@@ -46,6 +46,13 @@ export type GardenContextType = {
46
46
  * @returns {IQuote}
47
47
  */
48
48
  quote?: IQuote;
49
+ /**
50
+ * Initiates the order in the EVM chain. This can be useful if the initiation is failed when `swapAndInitiate` function is called.
51
+ * @param order - The order to initiate.
52
+ * @returns {AsyncResult<MatchedOrder, string>} - The initiated order.
53
+ * @NOTE This is only required if the source chain is EVM.
54
+ */
55
+ evmInitiate?: (order: MatchedOrder) => AsyncResult<MatchedOrder, string>;
49
56
  };
50
57
  export type GardenProviderProps = {
51
58
  children: React.ReactNode;
@@ -57,6 +64,8 @@ export type GardenProviderProps = {
57
64
  quoteUrl?: string;
58
65
  bitcoinRPCUrl?: string;
59
66
  blockNumberFetcherUrl?: string;
67
+ siweOpts?: SiweOpts;
68
+ apiKey?: string;
60
69
  };
61
70
  };
62
71
  export type QuoteParams = {
@@ -64,4 +73,5 @@ export type QuoteParams = {
64
73
  toAsset: Asset;
65
74
  amount: number;
66
75
  isExactOut?: boolean;
76
+ request?: Request;
67
77
  };
@@ -1,5 +1,8 @@
1
1
  import { IGardenJS, OrderWithStatus } from '@gardenfi/core';
2
+ import { Address } from 'viem';
2
3
 
3
- export declare const useOrderbook: (garden: IGardenJS | undefined) => {
4
+ export declare const useOrderbook: (garden: IGardenJS | undefined, address: Address | undefined) => {
4
5
  pendingOrders: OrderWithStatus[];
6
+ isExecuting: boolean;
7
+ digestKey: string | undefined;
5
8
  };
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.21",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -26,14 +26,12 @@
26
26
  "registry": "https://registry.npmjs.org/"
27
27
  },
28
28
  "dependencies": {
29
- "@catalogfi/utils": "^0.1.6",
30
- "@catalogfi/wallets": "^0.2.51",
31
- "@gardenfi/core": "^0.3.0-beta.15",
32
- "@gardenfi/orderbook": "^0.2.0-beta.42",
33
- "@gardenfi/utils": "^0.0.1-beta.20",
29
+ "@catalogfi/wallets": "^0.2.59",
30
+ "@gardenfi/core": "^2.0.18",
31
+ "@gardenfi/orderbook": "^2.0.4",
32
+ "@gardenfi/utils": "^2.0.1",
34
33
  "react": "^18.3.1",
35
- "viem": "^2.21.15",
36
- "wagmi": "^2.12.16"
34
+ "viem": "^2.21.23"
37
35
  },
38
36
  "devDependencies": {
39
37
  "@types/react": "^18",
File without changes