@gardenfi/react-hooks 0.0.1-beta.9 → 0.0.1-beta.91
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 +1 -1
- package/dist/index2.js +160 -83
- package/dist/index3.cjs +1 -1
- package/dist/index3.js +39 -14
- package/dist/src/lib/context/gardenProvider.types.d.ts +48 -3
- package/dist/src/lib/hooks/useOrderbook.d.ts +2 -1
- package/package.json +5 -5
package/dist/index2.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 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,100 +1,177 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useWalletClient as
|
|
3
|
-
import { useSecretManager as
|
|
4
|
-
import { useOrderbook as
|
|
5
|
-
import { Quote as
|
|
6
|
-
import { Err as
|
|
7
|
-
import { isBitcoin as
|
|
8
|
-
import { BitcoinProvider as
|
|
9
|
-
import { Siwe as
|
|
10
|
-
import { constructOrderpair as
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
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
|
+
import { Siwe as X, Url as Y } from "@gardenfi/utils";
|
|
10
|
+
import { constructOrderpair as Z } from "./index5.js";
|
|
11
|
+
const g = T({
|
|
12
|
+
isExecuting: !1
|
|
13
|
+
}), ce = ({
|
|
14
|
+
children: w,
|
|
15
|
+
config: r
|
|
14
16
|
}) => {
|
|
15
|
-
const [
|
|
16
|
-
() =>
|
|
17
|
-
[
|
|
18
|
-
),
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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(
|
|
27
|
+
() => new L(r.network, r.bitcoinRPCUrl),
|
|
28
|
+
[r.network, r.bitcoinRPCUrl]
|
|
29
|
+
), { data: a } = V(), { initializeSecretManager: O } = j(z), { orderbook: v } = D(
|
|
30
|
+
r.orderBookUrl,
|
|
31
|
+
n,
|
|
32
|
+
P,
|
|
33
|
+
U
|
|
34
|
+
), M = async () => {
|
|
35
|
+
if (!a || !n)
|
|
36
|
+
return i("WalletClient or auth not initialized");
|
|
37
|
+
const e = await O();
|
|
38
|
+
if (e.error) return i(e.error);
|
|
39
|
+
const o = E.fromPrivateKey(
|
|
40
|
+
e.val.getMasterPrivKey(),
|
|
41
|
+
y
|
|
42
|
+
), t = new F({
|
|
43
|
+
orderbookURl: r.orderBookUrl,
|
|
44
|
+
secretManager: e.val,
|
|
45
|
+
quote: m,
|
|
46
|
+
auth: n,
|
|
47
|
+
wallets: {
|
|
48
|
+
evmWallet: a,
|
|
49
|
+
btcWallet: o
|
|
50
|
+
},
|
|
51
|
+
blockNumberFetcher: U
|
|
52
|
+
});
|
|
53
|
+
return B(t), p(t);
|
|
54
|
+
}, A = async (e) => {
|
|
55
|
+
if (!v || !a || !n)
|
|
56
|
+
return i("Orderbook or walletClient or auth not initialized");
|
|
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;
|
|
62
|
+
}
|
|
63
|
+
const t = await o.swap(e);
|
|
64
|
+
if (t.error) return i(t.error);
|
|
65
|
+
if (x(t.val.source_swap.chain)) return p(t.val);
|
|
66
|
+
const c = await G(
|
|
67
|
+
e.fromAsset.chain,
|
|
68
|
+
a
|
|
69
|
+
);
|
|
70
|
+
if (c.error)
|
|
71
|
+
return i("Failed to switch network: " + c.error);
|
|
72
|
+
const _ = c.val.walletClient, u = await new N(t.val, r.orderBookUrl, n).init(_);
|
|
73
|
+
if (u.error) return i(u.error);
|
|
74
|
+
const d = {
|
|
75
|
+
...t.val,
|
|
76
|
+
source_swap: {
|
|
77
|
+
...t.val.source_swap,
|
|
78
|
+
initiate_tx_hash: u.val
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
return p(d);
|
|
82
|
+
}, Q = async (e) => {
|
|
83
|
+
if (!a || !n)
|
|
84
|
+
return i("Orderbook or walletClient or auth not initialized");
|
|
85
|
+
let o = s;
|
|
86
|
+
if (!l || !o) {
|
|
87
|
+
const d = await M();
|
|
88
|
+
if (d.error) return i(d.error);
|
|
89
|
+
o = d.val;
|
|
24
90
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
t
|
|
91
|
+
if (x(e.source_swap.chain))
|
|
92
|
+
return i("Not an EVM order: sourceSwap.chain is Bitcoin");
|
|
93
|
+
const t = await G(
|
|
94
|
+
e.source_swap.chain,
|
|
95
|
+
a
|
|
31
96
|
);
|
|
32
|
-
if (
|
|
33
|
-
return
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
97
|
+
if (t.error)
|
|
98
|
+
return i("Failed to switch network: " + t.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);
|
|
101
|
+
const u = {
|
|
102
|
+
...e,
|
|
103
|
+
source_swap: {
|
|
104
|
+
...e.source_swap,
|
|
105
|
+
initiate_tx_hash: h.val
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
return p(u);
|
|
109
|
+
}, I = async ({
|
|
110
|
+
fromAsset: e,
|
|
38
111
|
toAsset: o,
|
|
39
|
-
amount:
|
|
40
|
-
isExactOut:
|
|
41
|
-
}) => await
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
112
|
+
amount: t,
|
|
113
|
+
isExactOut: c = !1
|
|
114
|
+
}) => await m.getQuote(
|
|
115
|
+
Z(e, o),
|
|
116
|
+
t,
|
|
117
|
+
c
|
|
45
118
|
);
|
|
46
|
-
return
|
|
47
|
-
if (!
|
|
48
|
-
const
|
|
49
|
-
store:
|
|
119
|
+
return R(() => {
|
|
120
|
+
if (!a) return;
|
|
121
|
+
const e = new X(new Y(r.orderBookUrl), a, {
|
|
122
|
+
store: r.store
|
|
50
123
|
});
|
|
51
|
-
|
|
52
|
-
}, [
|
|
53
|
-
if (!n) return;
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
)
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
orderbookURl: e.orderBookUrl,
|
|
63
|
-
secretManager: n,
|
|
64
|
-
quote: w,
|
|
65
|
-
auth: a,
|
|
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({
|
|
131
|
+
orderbookURl: r.orderBookUrl,
|
|
132
|
+
secretManager: l,
|
|
133
|
+
quote: m,
|
|
134
|
+
auth: n,
|
|
66
135
|
wallets: {
|
|
67
|
-
evmWallet:
|
|
68
|
-
btcWallet:
|
|
69
|
-
}
|
|
136
|
+
evmWallet: a,
|
|
137
|
+
btcWallet: e
|
|
138
|
+
},
|
|
139
|
+
blockNumberFetcher: U
|
|
70
140
|
});
|
|
71
|
-
|
|
72
|
-
}, [
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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);
|
|
147
|
+
};
|
|
148
|
+
}, [s]), /* @__PURE__ */ S.createElement(
|
|
149
|
+
g.Provider,
|
|
78
150
|
{
|
|
79
151
|
value: {
|
|
80
|
-
orderBookUrl:
|
|
81
|
-
initializeSecretManager:
|
|
82
|
-
orderBook:
|
|
83
|
-
swap:
|
|
84
|
-
|
|
85
|
-
getQuote:
|
|
152
|
+
orderBookUrl: r.orderBookUrl,
|
|
153
|
+
initializeSecretManager: O,
|
|
154
|
+
orderBook: v,
|
|
155
|
+
swap: A,
|
|
156
|
+
pendingOrders: f,
|
|
157
|
+
getQuote: I,
|
|
158
|
+
secretManager: l,
|
|
159
|
+
garden: s,
|
|
160
|
+
isExecuting: q,
|
|
161
|
+
evmInitiate: Q,
|
|
162
|
+
quote: m
|
|
86
163
|
}
|
|
87
164
|
},
|
|
88
|
-
|
|
165
|
+
w
|
|
89
166
|
);
|
|
90
|
-
},
|
|
91
|
-
const
|
|
92
|
-
if (!
|
|
167
|
+
}, ue = () => {
|
|
168
|
+
const w = S.useContext(g);
|
|
169
|
+
if (!w)
|
|
93
170
|
throw new Error("useGarden must be used within a GardenProvider");
|
|
94
|
-
return
|
|
171
|
+
return w;
|
|
95
172
|
};
|
|
96
173
|
export {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
174
|
+
g as GardenContext,
|
|
175
|
+
ce as GardenProvider,
|
|
176
|
+
ue as useGarden
|
|
100
177
|
};
|
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 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,18 +1,43 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
|
12
13
|
});
|
|
13
|
-
|
|
14
|
-
}, [
|
|
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
|
+
});
|
|
38
|
+
});
|
|
39
|
+
}, [r, s]), { orderbook: r };
|
|
15
40
|
};
|
|
16
41
|
export {
|
|
17
|
-
|
|
42
|
+
E as useOrderbook
|
|
18
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 { 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,8 +22,44 @@ export type GardenContextType = {
|
|
|
14
22
|
* @returns {AsyncResult<string, string>} - create order ID.
|
|
15
23
|
*/
|
|
16
24
|
swap?: (params: SwapParams) => AsyncResult<MatchedOrder, string>;
|
|
17
|
-
|
|
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
|
+
*/
|
|
41
|
+
secretManager?: ISecretManager;
|
|
42
|
+
/**
|
|
43
|
+
* The garden instance.
|
|
44
|
+
* @returns {IGardenJS}
|
|
45
|
+
*/
|
|
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
|
+
*/
|
|
53
|
+
evmInitiate?: (order: MatchedOrder) => AsyncResult<MatchedOrder, string>;
|
|
54
|
+
/**
|
|
55
|
+
* Indicates if the orders are executing.
|
|
56
|
+
*/
|
|
57
|
+
isExecuting: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* The quote instance.
|
|
60
|
+
* @returns {IQuote}
|
|
61
|
+
*/
|
|
62
|
+
quote?: IQuote;
|
|
19
63
|
};
|
|
20
64
|
export type GardenProviderProps = {
|
|
21
65
|
children: React.ReactNode;
|
|
@@ -23,8 +67,9 @@ export type GardenProviderProps = {
|
|
|
23
67
|
orderBookUrl: string;
|
|
24
68
|
quoteUrl: string;
|
|
25
69
|
store: IStore;
|
|
26
|
-
|
|
70
|
+
network: BitcoinNetwork;
|
|
27
71
|
bitcoinRPCUrl?: string;
|
|
72
|
+
blockNumberFetcherUrl?: string;
|
|
28
73
|
};
|
|
29
74
|
};
|
|
30
75
|
export type QuoteParams = {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { IBlockNumberFetcher, OrderWithStatus } from '@gardenfi/core';
|
|
1
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) => {
|
|
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.
|
|
3
|
+
"version": "0.0.1-beta.91",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@catalogfi/utils": "^0.1.6",
|
|
30
|
-
"@catalogfi/wallets": "^0.2.
|
|
31
|
-
"@gardenfi/core": "^0.2.0-beta.
|
|
32
|
-
"@gardenfi/orderbook": "^0.2.0-beta.
|
|
33
|
-
"@gardenfi/utils": "^0.0.1-beta.
|
|
30
|
+
"@catalogfi/wallets": "^0.2.51",
|
|
31
|
+
"@gardenfi/core": "^0.2.0-beta.71",
|
|
32
|
+
"@gardenfi/orderbook": "^0.2.0-beta.17",
|
|
33
|
+
"@gardenfi/utils": "^0.0.1-beta.18",
|
|
34
34
|
"react": "^18.3.1",
|
|
35
35
|
"viem": "^2.21.15",
|
|
36
36
|
"wagmi": "^2.12.16"
|