@gardenfi/react-hooks 0.0.1-beta.83 → 0.0.1-beta.85

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 a=require("react"),z=require("wagmi"),A=require("./index4.cjs"),K=require("./index3.cjs"),d=require("@gardenfi/core"),n=require("@catalogfi/utils"),q=require("@gardenfi/orderbook"),v=require("@catalogfi/wallets"),S=require("@gardenfi/utils"),Q=require("./index5.cjs"),B=a.createContext({isExecuting:!1}),$=({children:b,config:r})=>{const[l,_]=a.useState(),[c,O]=a.useState(),[s,N]=a.useState(),[R,U]=a.useState(),W=a.useMemo(()=>!!(l&&c&&s&&R),[l,c,s,R]),h=a.useMemo(()=>new d.Quote(r.quoteUrl),[r.quoteUrl]),{data:i}=z.useWalletClient(),{initializeSecretManager:C}=A.useSecretManager(_),{orderbook:m}=K.useOrderbook(r.orderBookUrl,s,U),M=r.network===v.BitcoinNetwork.Mainnet?"mainnet":r.network===v.BitcoinNetwork.Testnet?"testnet":void 0,P=r.blockNumberFetcherUrl&&M?{url:r.blockNumberFetcherUrl,network:M}:void 0,f=a.useMemo(()=>new v.BitcoinProvider(r.network,r.bitcoinRPCUrl),[r.network,r.bitcoinRPCUrl]),p=async()=>{if(!i||!s)return n.Err("WalletClient or auth not initialized");const e=await C();if(e.error)return n.Err(e.error);const o=v.BitcoinWallet.fromPrivateKey(e.val.getMasterPrivKey(),f),t=new d.Garden({orderbookURl:r.orderBookUrl,secretManager:e.val,quote:h,auth:s,wallets:{evmWallet:i,btcWallet:o},blockNumberFetcher:P});return O(t),n.Ok(t)},x=async e=>{if(!m||!i||!s)return n.Err("Orderbook or walletClient or auth not initialized");let o=c;if(!l||!o){const y=await p();if(y.error)return n.Err(y.error);o=y.val}const t=await o.swap(e);if(t.error)return n.Err(t.error);if(q.isBitcoin(t.val.source_swap.chain))return n.Ok(t.val);const u=await d.switchOrAddNetwork(e.fromAsset.chain,i);if(u.error)return n.Err("Failed to switch network: "+u.error);const G=u.val.walletClient,w=await new d.EvmRelay(t.val,r.orderBookUrl,s).init(G);if(w.error)return n.Err(w.error);const k={...t.val,source_swap:{...t.val.source_swap,initiate_tx_hash:w.val}};return n.Ok(k)},g=async e=>{if(!i||!s)return n.Err("Orderbook or walletClient or auth not initialized");let o=c;if(!l||!o){const k=await p();if(k.error)return n.Err(k.error);o=k.val}if(q.isBitcoin(e.source_swap.chain))return n.Err("Not an EVM order: sourceSwap.chain is Bitcoin");const t=await d.switchOrAddNetwork(e.source_swap.chain,i);if(t.error)return n.Err("Failed to switch network: "+t.error);const u=t.val.walletClient,E=await new d.EvmRelay(e,r.orderBookUrl,s).init(u);if(E.error)return n.Err(E.error);const w={...e,source_swap:{...e.source_swap,initiate_tx_hash:E.val}};return n.Ok(w)},F=async({fromAsset:e,toAsset:o,amount:t,isExactOut:u=!1})=>await h.getQuote(Q.constructOrderpair(e,o),t,u);return a.useEffect(()=>{if(!i)return;const e=new S.Siwe(new S.Url(r.orderBookUrl),i,{store:r.store});N(e)},[i]),a.useEffect(()=>{if(!l||!i||!m||!s)return;const e=v.BitcoinWallet.fromPrivateKey(l.getMasterPrivKey(),f),o=new d.Garden({orderbookURl:r.orderBookUrl,secretManager:l,quote:h,auth:s,wallets:{evmWallet:i,btcWallet:e},blockNumberFetcher:P});O(o)},[l,i,m,s]),a.useEffect(()=>{if(!c)return;const e=c.execute();return c.on("onPendingOrdersChanged",o=>{U(o)}),()=>{(async()=>(await e)())()}},[c]),a.createElement(B.Provider,{value:{orderBookUrl:r.orderBookUrl,initializeSecretManager:C,orderBook:m,swap:x,pendingOrders:R,getQuote:F,secretManager:l,garden:c,isExecuting:W,evmInitiate:g,quote:h}},b)},T=()=>{const b=a.useContext(B);if(!b)throw new Error("useGarden must be used within a GardenProvider");return b};exports.GardenContext=B;exports.GardenProvider=$;exports.useGarden=T;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react"),x=require("wagmi"),z=require("./index4.cjs"),A=require("./index3.cjs"),u=require("@gardenfi/core"),n=require("@catalogfi/utils"),G=require("@gardenfi/orderbook"),v=require("@catalogfi/wallets"),q=require("@gardenfi/utils"),K=require("./index5.cjs"),R=a.createContext({isExecuting:!1}),Q=({children:b,config:r})=>{const[c,S]=a.useState(),[l,U]=a.useState(),[s,N]=a.useState(),[O,y]=a.useState(),_=a.useMemo(()=>!!(c&&l&&s&&O),[c,l,s,O]),h=a.useMemo(()=>new u.Quote(r.quoteUrl),[r.quoteUrl]),B=a.useMemo(()=>{const e=r.network===v.BitcoinNetwork.Mainnet?"mainnet":r.network===v.BitcoinNetwork.Testnet?"testnet":void 0;return r.blockNumberFetcherUrl&&e?new u.BlockNumberFetcher(r.blockNumberFetcherUrl,e):void 0},[r.blockNumberFetcherUrl,r.network]),P=a.useMemo(()=>new v.BitcoinProvider(r.network,r.bitcoinRPCUrl),[r.network,r.bitcoinRPCUrl]),{data:i}=x.useWalletClient(),{initializeSecretManager:M}=z.useSecretManager(S),{orderbook:m}=A.useOrderbook(r.orderBookUrl,s,y,B),f=async()=>{if(!i||!s)return n.Err("WalletClient or auth not initialized");const e=await M();if(e.error)return n.Err(e.error);const o=v.BitcoinWallet.fromPrivateKey(e.val.getMasterPrivKey(),P),t=new u.Garden({orderbookURl:r.orderBookUrl,secretManager:e.val,quote:h,auth:s,wallets:{evmWallet:i,btcWallet:o},blockNumberFetcher:B});return U(t),n.Ok(t)},g=async e=>{if(!m||!i||!s)return n.Err("Orderbook or walletClient or auth not initialized");let o=l;if(!c||!o){const C=await f();if(C.error)return n.Err(C.error);o=C.val}const t=await o.swap(e);if(t.error)return n.Err(t.error);if(G.isBitcoin(t.val.source_swap.chain))return n.Ok(t.val);const d=await u.switchOrAddNetwork(e.fromAsset.chain,i);if(d.error)return n.Err("Failed to switch network: "+d.error);const p=d.val.walletClient,w=await new u.EvmRelay(t.val,r.orderBookUrl,s).init(p);if(w.error)return n.Err(w.error);const k={...t.val,source_swap:{...t.val.source_swap,initiate_tx_hash:w.val}};return n.Ok(k)},F=async e=>{if(!i||!s)return n.Err("Orderbook or walletClient or auth not initialized");let o=l;if(!c||!o){const k=await f();if(k.error)return n.Err(k.error);o=k.val}if(G.isBitcoin(e.source_swap.chain))return n.Err("Not an EVM order: sourceSwap.chain is Bitcoin");const t=await u.switchOrAddNetwork(e.source_swap.chain,i);if(t.error)return n.Err("Failed to switch network: "+t.error);const d=t.val.walletClient,E=await new u.EvmRelay(e,r.orderBookUrl,s).init(d);if(E.error)return n.Err(E.error);const w={...e,source_swap:{...e.source_swap,initiate_tx_hash:E.val}};return n.Ok(w)},W=async({fromAsset:e,toAsset:o,amount:t,isExactOut:d=!1})=>await h.getQuote(K.constructOrderpair(e,o),t,d);return a.useEffect(()=>{if(!i)return;const e=new q.Siwe(new q.Url(r.orderBookUrl),i,{store:r.store});N(e)},[i]),a.useEffect(()=>{if(!c||!i||!m||!s)return;const e=v.BitcoinWallet.fromPrivateKey(c.getMasterPrivKey(),P),o=new u.Garden({orderbookURl:r.orderBookUrl,secretManager:c,quote:h,auth:s,wallets:{evmWallet:i,btcWallet:e},blockNumberFetcher:B});U(o)},[c,i,m,s]),a.useEffect(()=>{if(!l)return;const e=l.execute(),o=t=>y(t);return l.on("onPendingOrdersChanged",o),()=>{(async()=>(await e)())(),l.off("onPendingOrdersChanged",o)}},[l]),a.createElement(R.Provider,{value:{orderBookUrl:r.orderBookUrl,initializeSecretManager:M,orderBook:m,swap:g,pendingOrders:O,getQuote:W,secretManager:c,garden:l,isExecuting:_,evmInitiate:F,quote:h}},b)},$=()=>{const b=a.useContext(R);if(!b)throw new Error("useGarden must be used within a GardenProvider");return b};exports.GardenContext=R;exports.GardenProvider=Q;exports.useGarden=$;
package/dist/index2.js CHANGED
@@ -1,41 +1,45 @@
1
- import z, { createContext as V, useState as h, useMemo as R, useEffect as U } from "react";
2
- import { useWalletClient as j } from "wagmi";
3
- import { useSecretManager as D } from "./index4.js";
4
- import { useOrderbook as H } from "./index3.js";
5
- import { Quote as J, Garden as x, switchOrAddNetwork as W, EvmRelay as E } from "@gardenfi/core";
6
- import { Err as i, Ok as b } from "@catalogfi/utils";
7
- import { isBitcoin as F } from "@gardenfi/orderbook";
8
- import { BitcoinNetwork as N, BitcoinProvider as L, BitcoinWallet as S } from "@catalogfi/wallets";
1
+ import S, { createContext as T, useState as k, useMemo as b, useEffect as R } from "react";
2
+ import { useWalletClient as V } from "wagmi";
3
+ import { useSecretManager as j } from "./index4.js";
4
+ import { useOrderbook as D } from "./index3.js";
5
+ import { Quote as H, BlockNumberFetcher as J, Garden as F, switchOrAddNetwork as G, EvmRelay as N } from "@gardenfi/core";
6
+ import { Err as i, Ok as p } from "@catalogfi/utils";
7
+ import { isBitcoin as x } from "@gardenfi/orderbook";
8
+ import { BitcoinNetwork as W, BitcoinProvider as L, BitcoinWallet as E } from "@catalogfi/wallets";
9
9
  import { Siwe as X, Url as Y } from "@gardenfi/utils";
10
10
  import { constructOrderpair as Z } from "./index5.js";
11
- const g = V({
11
+ const g = T({
12
12
  isExecuting: !1
13
13
  }), ce = ({
14
14
  children: w,
15
15
  config: r
16
16
  }) => {
17
- const [s, K] = h(), [l, C] = h(), [n, q] = h(), [p, y] = h(), A = R(
18
- () => !!(s && l && n && p),
19
- [s, l, n, p]
20
- ), m = R(() => new J(r.quoteUrl), [r.quoteUrl]), { data: a } = j(), { initializeSecretManager: B } = D(K), { orderbook: v } = H(
21
- r.orderBookUrl,
22
- n,
23
- y
24
- ), P = r.network === N.Mainnet ? "mainnet" : r.network === N.Testnet ? "testnet" : void 0, M = r.blockNumberFetcherUrl && P ? {
25
- url: r.blockNumberFetcherUrl,
26
- network: P
27
- } : void 0, O = R(
17
+ const [l, z] = k(), [s, B] = k(), [n, K] = k(), [f, P] = k(), q = b(
18
+ () => !!(l && s && n && f),
19
+ [l, s, n, f]
20
+ ), m = b(() => new H(r.quoteUrl), [r.quoteUrl]), U = b(() => {
21
+ const e = r.network === W.Mainnet ? "mainnet" : r.network === W.Testnet ? "testnet" : void 0;
22
+ return r.blockNumberFetcherUrl && e ? new J(
23
+ r.blockNumberFetcherUrl,
24
+ e
25
+ ) : void 0;
26
+ }, [r.blockNumberFetcherUrl, r.network]), y = b(
28
27
  () => new L(r.network, r.bitcoinRPCUrl),
29
28
  [r.network, r.bitcoinRPCUrl]
30
- ), _ = async () => {
29
+ ), { data: a } = V(), { initializeSecretManager: O } = j(z), { orderbook: v } = D(
30
+ r.orderBookUrl,
31
+ n,
32
+ P,
33
+ U
34
+ ), M = async () => {
31
35
  if (!a || !n)
32
36
  return i("WalletClient or auth not initialized");
33
- const e = await B();
37
+ const e = await O();
34
38
  if (e.error) return i(e.error);
35
- const o = S.fromPrivateKey(
39
+ const o = E.fromPrivateKey(
36
40
  e.val.getMasterPrivKey(),
37
- O
38
- ), t = new x({
41
+ y
42
+ ), t = new F({
39
43
  orderbookURl: r.orderBookUrl,
40
44
  secretManager: e.val,
41
45
  quote: m,
@@ -44,28 +48,28 @@ const g = V({
44
48
  evmWallet: a,
45
49
  btcWallet: o
46
50
  },
47
- blockNumberFetcher: M
51
+ blockNumberFetcher: U
48
52
  });
49
- return C(t), b(t);
50
- }, Q = async (e) => {
53
+ return B(t), p(t);
54
+ }, A = async (e) => {
51
55
  if (!v || !a || !n)
52
56
  return i("Orderbook or walletClient or auth not initialized");
53
- let o = l;
54
- if (!s || !o) {
55
- const f = await _();
56
- if (f.error) return i(f.error);
57
- o = f.val;
57
+ let o = s;
58
+ if (!l || !o) {
59
+ const C = await M();
60
+ if (C.error) return i(C.error);
61
+ o = C.val;
58
62
  }
59
63
  const t = await o.swap(e);
60
64
  if (t.error) return i(t.error);
61
- if (F(t.val.source_swap.chain)) return b(t.val);
62
- const c = await W(
65
+ if (x(t.val.source_swap.chain)) return p(t.val);
66
+ const c = await G(
63
67
  e.fromAsset.chain,
64
68
  a
65
69
  );
66
70
  if (c.error)
67
71
  return i("Failed to switch network: " + c.error);
68
- const G = c.val.walletClient, u = await new E(t.val, r.orderBookUrl, n).init(G);
72
+ const _ = c.val.walletClient, u = await new N(t.val, r.orderBookUrl, n).init(_);
69
73
  if (u.error) return i(u.error);
70
74
  const d = {
71
75
  ...t.val,
@@ -74,35 +78,35 @@ const g = V({
74
78
  initiate_tx_hash: u.val
75
79
  }
76
80
  };
77
- return b(d);
78
- }, I = async (e) => {
81
+ return p(d);
82
+ }, Q = async (e) => {
79
83
  if (!a || !n)
80
84
  return i("Orderbook or walletClient or auth not initialized");
81
- let o = l;
82
- if (!s || !o) {
83
- const d = await _();
85
+ let o = s;
86
+ if (!l || !o) {
87
+ const d = await M();
84
88
  if (d.error) return i(d.error);
85
89
  o = d.val;
86
90
  }
87
- if (F(e.source_swap.chain))
91
+ if (x(e.source_swap.chain))
88
92
  return i("Not an EVM order: sourceSwap.chain is Bitcoin");
89
- const t = await W(
93
+ const t = await G(
90
94
  e.source_swap.chain,
91
95
  a
92
96
  );
93
97
  if (t.error)
94
98
  return i("Failed to switch network: " + t.error);
95
- const c = t.val.walletClient, k = await new E(e, r.orderBookUrl, n).init(c);
96
- if (k.error) return i(k.error);
99
+ const c = t.val.walletClient, h = await new N(e, r.orderBookUrl, n).init(c);
100
+ if (h.error) return i(h.error);
97
101
  const u = {
98
102
  ...e,
99
103
  source_swap: {
100
104
  ...e.source_swap,
101
- initiate_tx_hash: k.val
105
+ initiate_tx_hash: h.val
102
106
  }
103
107
  };
104
- return b(u);
105
- }, T = async ({
108
+ return p(u);
109
+ }, I = async ({
106
110
  fromAsset: e,
107
111
  toAsset: o,
108
112
  amount: t,
@@ -112,58 +116,56 @@ const g = V({
112
116
  t,
113
117
  c
114
118
  );
115
- return U(() => {
119
+ return R(() => {
116
120
  if (!a) return;
117
121
  const e = new X(new Y(r.orderBookUrl), a, {
118
122
  store: r.store
119
123
  });
120
- q(e);
121
- }, [a]), U(() => {
122
- if (!s || !a || !v || !n) return;
123
- const e = S.fromPrivateKey(
124
- s.getMasterPrivKey(),
125
- O
126
- ), o = new x({
124
+ K(e);
125
+ }, [a]), R(() => {
126
+ if (!l || !a || !v || !n) return;
127
+ const e = E.fromPrivateKey(
128
+ l.getMasterPrivKey(),
129
+ y
130
+ ), o = new F({
127
131
  orderbookURl: r.orderBookUrl,
128
- secretManager: s,
132
+ secretManager: l,
129
133
  quote: m,
130
134
  auth: n,
131
135
  wallets: {
132
136
  evmWallet: a,
133
137
  btcWallet: e
134
138
  },
135
- blockNumberFetcher: M
139
+ blockNumberFetcher: U
136
140
  });
137
- C(o);
138
- }, [s, a, v, n]), U(() => {
139
- if (!l) return;
140
- const e = l.execute();
141
- return l.on("onPendingOrdersChanged", (o) => {
142
- y(o);
143
- }), () => {
144
- (async () => (await e)())();
141
+ B(o);
142
+ }, [l, a, v, n]), R(() => {
143
+ if (!s) return;
144
+ const e = s.execute(), o = (t) => P(t);
145
+ return s.on("onPendingOrdersChanged", o), () => {
146
+ (async () => (await e)())(), s.off("onPendingOrdersChanged", o);
145
147
  };
146
- }, [l]), /* @__PURE__ */ z.createElement(
148
+ }, [s]), /* @__PURE__ */ S.createElement(
147
149
  g.Provider,
148
150
  {
149
151
  value: {
150
152
  orderBookUrl: r.orderBookUrl,
151
- initializeSecretManager: B,
153
+ initializeSecretManager: O,
152
154
  orderBook: v,
153
- swap: Q,
154
- pendingOrders: p,
155
- getQuote: T,
156
- secretManager: s,
157
- garden: l,
158
- isExecuting: A,
159
- evmInitiate: I,
155
+ swap: A,
156
+ pendingOrders: f,
157
+ getQuote: I,
158
+ secretManager: l,
159
+ garden: s,
160
+ isExecuting: q,
161
+ evmInitiate: Q,
160
162
  quote: m
161
163
  }
162
164
  },
163
165
  w
164
166
  );
165
167
  }, ue = () => {
166
- const w = z.useContext(g);
168
+ const w = S.useContext(g);
167
169
  if (!w)
168
170
  throw new Error("useGarden must be used within a GardenProvider");
169
171
  return w;
package/dist/index3.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@gardenfi/core"),d=require("@gardenfi/orderbook"),s=require("react"),l=require("wagmi"),b=(e,r,i)=>{const{data:t}=l.useWalletClient(),[u,c]=s.useState();return s.useEffect(()=>{if(!t||!e||!r)return;const n=new d.Orderbook({url:e,walletClient:t,auth:r});c(n),n.fetchOrders(!0,!0,{per_page:500}).then(o=>{!o.error&&o.val&&i(a.filterDeadlineExpiredOrders(o.val.data))})},[t,e,r]),{orderbook:u}};exports.useOrderbook=b;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("@gardenfi/core"),m=require("@gardenfi/orderbook"),i=require("react"),w=require("wagmi"),S=(o,s,b,n)=>{const[t,k]=i.useState(),{data:u}=w.useWalletClient();return i.useEffect(()=>{if(!u||!o||!s)return;const r=new m.Orderbook({url:o,walletClient:u,auth:s});k(r)},[u,o,s]),i.useEffect(()=>{!t||!n||n.fetchBlockNumbers().then(r=>{if(r.error)return;const{val:c}=r;t.fetchOrders(!0,!0,{per_page:500}).then(a=>{if(a.error)return;const O=f.filterDeadlineExpiredOrders(a.val.data).map(e=>{const d=c[e.source_swap.chain],l=c[e.destination_swap.chain];if(!d||!l)return;const p=f.ParseOrderStatus(e,d,l);return{...e,status:p}}).filter(e=>e!==void 0);b(O)})})},[t,n]),{orderbook:t}};exports.useOrderbook=S;
package/dist/index3.js CHANGED
@@ -1,23 +1,43 @@
1
- import { filterDeadlineExpiredOrders as l } from "@gardenfi/core";
2
- import { Orderbook as s } from "@gardenfi/orderbook";
3
- import { useState as m, useEffect as p } from "react";
4
- import { useWalletClient as d } from "wagmi";
5
- const k = (e, r, n) => {
6
- const { data: t } = d(), [f, a] = m();
7
- return p(() => {
8
- if (!t || !e || !r) return;
9
- const i = new s({
10
- url: e,
11
- walletClient: t,
12
- auth: r
1
+ import { filterDeadlineExpiredOrders as O, ParseOrderStatus as k } from "@gardenfi/core";
2
+ import { Orderbook as w } from "@gardenfi/orderbook";
3
+ import { useState as h, useEffect as l } from "react";
4
+ import { useWalletClient as v } from "wagmi";
5
+ const E = (o, n, m, s) => {
6
+ const [r, p] = h(), { data: i } = v();
7
+ return l(() => {
8
+ if (!i || !o || !n) return;
9
+ const e = new w({
10
+ url: o,
11
+ walletClient: i,
12
+ auth: n
13
13
  });
14
- a(i), i.fetchOrders(!0, !0, {
15
- per_page: 500
16
- }).then((o) => {
17
- !o.error && o.val && n(l(o.val.data));
14
+ p(e);
15
+ }, [i, o, n]), l(() => {
16
+ !r || !s || s.fetchBlockNumbers().then((e) => {
17
+ if (e.error) return;
18
+ const { val: a } = e;
19
+ r.fetchOrders(!0, !0, {
20
+ per_page: 500
21
+ }).then((u) => {
22
+ if (u.error) return;
23
+ const d = O(u.val.data).map((t) => {
24
+ const c = a[t.source_swap.chain], f = a[t.destination_swap.chain];
25
+ if (!c || !f) return;
26
+ const b = k(
27
+ t,
28
+ c,
29
+ f
30
+ );
31
+ return {
32
+ ...t,
33
+ status: b
34
+ };
35
+ }).filter((t) => t !== void 0);
36
+ m(d);
37
+ });
18
38
  });
19
- }, [t, e, r]), { orderbook: f };
39
+ }, [r, s]), { orderbook: r };
20
40
  };
21
41
  export {
22
- k as useOrderbook
42
+ E as useOrderbook
23
43
  };
@@ -1,12 +1,20 @@
1
+ import { OrderWithStatus, IGardenJS, IQuote, ISecretManager, QuoteResponse, SecretManager, SwapParams } from '@gardenfi/core';
1
2
  import { AsyncResult } from '@catalogfi/utils';
2
3
  import { BitcoinNetwork } from '@catalogfi/wallets';
3
- import { IGardenJS, IQuote, ISecretManager, QuoteResponse, SecretManager, SwapParams } from '@gardenfi/core';
4
4
  import { Asset, IOrderbook, MatchedOrder } from '@gardenfi/orderbook';
5
5
  import { IStore } from '@gardenfi/utils';
6
6
 
7
7
  export type GardenContextType = {
8
8
  orderBookUrl?: string;
9
+ /**
10
+ * Initializing secretManager is necessary for executing orders.
11
+ * @returns {AsyncResult<SecretManager, string>} - The secret manager instance.
12
+ */
9
13
  initializeSecretManager?: () => AsyncResult<SecretManager, string>;
14
+ /**
15
+ * The orderbook instance.
16
+ * @returns {IOrderbook}
17
+ */
10
18
  orderBook?: IOrderbook | undefined;
11
19
  /**
12
20
  * Create an order and wait until its matched and then initiates if source chain is EVM.
@@ -14,12 +22,43 @@ export type GardenContextType = {
14
22
  * @returns {AsyncResult<string, string>} - create order ID.
15
23
  */
16
24
  swap?: (params: SwapParams) => AsyncResult<MatchedOrder, string>;
17
- pendingOrders?: MatchedOrder[];
25
+ /**
26
+ * Get all the pending orders of the user. This will return all the orders that are yet to be initiated, redeemed, or refunded.
27
+ * It will not return orders that have expired (deadline expiry).
28
+ * @returns {MatchedOrder[]} - The pending orders of the user.
29
+ */
30
+ pendingOrders?: OrderWithStatus[];
31
+ /**
32
+ * Get the quote for the given parameters. This will also return USD values of the assets.
33
+ * @param params
34
+ * @returns
35
+ */
18
36
  getQuote?: (params: QuoteParams) => AsyncResult<QuoteResponse, string>;
37
+ /**
38
+ * The secret manager instance.
39
+ * @returns {ISecretManager}
40
+ */
19
41
  secretManager?: ISecretManager;
42
+ /**
43
+ * The garden instance.
44
+ * @returns {IGardenJS}
45
+ */
20
46
  garden?: IGardenJS;
47
+ /**
48
+ * Initiates the order in the EVM chain. This can be useful if the initiation is failed when `swap` function is called.
49
+ * @param order - The order to initiate.
50
+ * @returns {AsyncResult<MatchedOrder, string>} - The initiated order.
51
+ * @NOTE This is only required if the source chain is EVM.
52
+ */
21
53
  evmInitiate?: (order: MatchedOrder) => AsyncResult<MatchedOrder, string>;
54
+ /**
55
+ * Indicates if the orders are executing.
56
+ */
22
57
  isExecuting: boolean;
58
+ /**
59
+ * The quote instance.
60
+ * @returns {IQuote}
61
+ */
23
62
  quote?: IQuote;
24
63
  };
25
64
  export type GardenProviderProps = {
@@ -1,6 +1,7 @@
1
- import { IOrderbook, MatchedOrder } from '@gardenfi/orderbook';
1
+ import { IBlockNumberFetcher, OrderWithStatus } from '@gardenfi/core';
2
+ import { IOrderbook } from '@gardenfi/orderbook';
2
3
  import { IAuth } from '@gardenfi/utils';
3
4
 
4
- export declare const useOrderbook: (orderBookUrl: string, auth: IAuth | undefined, setPendingOrders: React.Dispatch<React.SetStateAction<MatchedOrder[] | undefined>>) => {
5
+ export declare const useOrderbook: (orderBookUrl: string, auth: IAuth | undefined, setPendingOrders: React.Dispatch<React.SetStateAction<OrderWithStatus[] | undefined>>, blockNumberFetcher?: IBlockNumberFetcher) => {
5
6
  orderbook: IOrderbook | undefined;
6
7
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gardenfi/react-hooks",
3
- "version": "0.0.1-beta.83",
3
+ "version": "0.0.1-beta.85",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -28,7 +28,7 @@
28
28
  "dependencies": {
29
29
  "@catalogfi/utils": "^0.1.6",
30
30
  "@catalogfi/wallets": "^0.2.51",
31
- "@gardenfi/core": "^0.2.0-beta.62",
31
+ "@gardenfi/core": "^0.2.0-beta.65",
32
32
  "@gardenfi/orderbook": "^0.2.0-beta.14",
33
33
  "@gardenfi/utils": "^0.0.1-beta.18",
34
34
  "react": "^18.3.1",