@gardenfi/react-hooks 0.0.1-beta.99 → 0.0.2-beta.1
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/index.cjs +1 -1
- package/dist/index.js +9 -8
- package/dist/index2.cjs +1 -1
- package/dist/index2.js +72 -162
- package/dist/index3.cjs +1 -1
- package/dist/index3.js +28 -31
- package/dist/index4.cjs +1 -1
- package/dist/index4.js +17 -11
- package/dist/src/index.d.ts +1 -1
- package/dist/src/lib/context/gardenProvider.types.d.ts +14 -27
- package/dist/src/lib/gardenConfig.d.ts +15 -0
- package/dist/src/lib/hooks/useOrderbook.d.ts +3 -5
- package/dist/src/lib/hooks/useSecretManager.d.ts +0 -6
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index2.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index2.cjs"),o=require("./index3.cjs"),n=require("@catalogfi/wallets"),r=require("./index4.cjs");exports.GardenProvider=e.GardenProvider;exports.useGarden=e.useGarden;exports.useOrderbook=o.useOrderbook;Object.defineProperty(exports,"BitcoinNetwork",{enumerable:!0,get:()=>n.BitcoinNetwork});exports.GARDEN_CONFIG=r.GARDEN_CONFIG;exports.environment=r.environment;
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { GardenProvider as
|
|
2
|
-
import { useOrderbook as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { GardenProvider as e, useGarden as t } from "./index2.js";
|
|
2
|
+
import { useOrderbook as m } from "./index3.js";
|
|
3
|
+
import { BitcoinNetwork as f } from "@catalogfi/wallets";
|
|
4
|
+
import { GARDEN_CONFIG as p, environment as x } from "./index4.js";
|
|
5
5
|
export {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
f as BitcoinNetwork,
|
|
7
|
+
p as GARDEN_CONFIG,
|
|
8
|
+
e as GardenProvider,
|
|
9
|
+
x as environment,
|
|
8
10
|
t as useGarden,
|
|
9
|
-
|
|
10
|
-
m as useSecretManager
|
|
11
|
+
m as useOrderbook
|
|
11
12
|
};
|
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 s=require("react"),q=require("./index3.cjs"),n=require("@gardenfi/core"),i=require("@catalogfi/utils"),G=require("@gardenfi/orderbook"),f=require("./index5.cjs"),w=s.createContext({isExecuting:!1,isExecutorRequired:!1}),x=({children:u,config:a})=>{const[e,v]=s.useState(),{pendingOrders:d}=q.useOrderbook(e),C=s.useMemo(()=>!!(e!=null&&e.secretManager.isInitialized),[e]),O=s.useMemo(()=>!!d.find(r=>{const t=r.status;return t===n.OrderStatus.InitiateDetected||t===n.OrderStatus.Initiated||t===n.OrderStatus.CounterPartyInitiateDetected||t===n.OrderStatus.CounterPartyInitiated||t===n.OrderStatus.RedeemDetected||t===n.OrderStatus.Expired}),[d]),E=e&&s.useMemo(()=>async({fromAsset:r,toAsset:t,amount:o,isExactOut:l=!1})=>await e.quote.getQuote(f.constructOrderpair(r,t),o,l),[e]),h=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(G.isBitcoin(t.val.source_swap.chain))return i.Ok(t.val);const o=await n.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 m={...t.val,source_swap:{...t.val.source_swap,initiate_tx_hash:c.val}};return i.Ok(m)};return s.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 n.Garden({environment:a.environment,evmWallet:a.walletClient}))}},[a.walletClient]),s.createElement(w.Provider,{value:{orderBook:e==null?void 0:e.orderbook,quote:e==null?void 0:e.quote,swapAndInitiate:h,pendingOrders:d,getQuote:E,garden:e,isExecuting:C,isExecutorRequired:O}},u)},k=()=>{const u=s.useContext(w);if(!u)throw new Error("useGarden must be used within a GardenProvider");return u};exports.GardenContext=w;exports.GardenProvider=x;exports.useGarden=k;
|
package/dist/index2.js
CHANGED
|
@@ -1,179 +1,89 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}), ce = ({
|
|
14
|
-
children: w,
|
|
15
|
-
config: r
|
|
1
|
+
import m, { createContext as G, useState as O, useMemo as d, useEffect as R } from "react";
|
|
2
|
+
import { useOrderbook as k } from "./index3.js";
|
|
3
|
+
import { OrderStatus as i, Garden as I, switchOrAddNetwork as q } from "@gardenfi/core";
|
|
4
|
+
import { Err as s, Ok as w } from "@catalogfi/utils";
|
|
5
|
+
import { isBitcoin as y } from "@gardenfi/orderbook";
|
|
6
|
+
import { constructOrderpair as P } from "./index5.js";
|
|
7
|
+
const v = G({
|
|
8
|
+
isExecuting: !1,
|
|
9
|
+
isExecutorRequired: !1
|
|
10
|
+
}), B = ({
|
|
11
|
+
children: a,
|
|
12
|
+
config: n
|
|
16
13
|
}) => {
|
|
17
|
-
const [
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
),
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
e.val.getMasterPrivKey(),
|
|
41
|
-
y
|
|
42
|
-
), t = new F({
|
|
43
|
-
orderbookURl: r.orderBookUrl,
|
|
44
|
-
secretManager: e.val,
|
|
45
|
-
quote: m,
|
|
46
|
-
auth: a,
|
|
47
|
-
wallets: {
|
|
48
|
-
evmWallet: n,
|
|
49
|
-
btcWallet: o
|
|
50
|
-
},
|
|
51
|
-
blockNumberFetcher: C
|
|
52
|
-
});
|
|
53
|
-
return B(t), p(t);
|
|
54
|
-
}, A = async (e) => {
|
|
55
|
-
if (!v || !n || !a)
|
|
56
|
-
return i("Orderbook or walletClient or auth not initialized");
|
|
57
|
-
let o = s;
|
|
58
|
-
if (!l || !o) {
|
|
59
|
-
const U = await M();
|
|
60
|
-
if (U.error) return i(U.error);
|
|
61
|
-
o = U.val;
|
|
62
|
-
}
|
|
63
|
-
const t = await o.swap(e);
|
|
64
|
-
if (t.error) return i(t.error);
|
|
65
|
-
if (W(t.val.source_swap.chain)) return p(t.val);
|
|
66
|
-
const c = await G(
|
|
67
|
-
e.fromAsset.chain,
|
|
68
|
-
n
|
|
14
|
+
const [e, f] = O(), { pendingOrders: u } = k(e), p = d(() => !!(e != null && e.secretManager.isInitialized), [e]), C = d(() => !!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]), h = e && d(
|
|
18
|
+
() => async ({
|
|
19
|
+
fromAsset: r,
|
|
20
|
+
toAsset: t,
|
|
21
|
+
amount: o,
|
|
22
|
+
isExactOut: l = !1
|
|
23
|
+
}) => await e.quote.getQuote(
|
|
24
|
+
P(r, t),
|
|
25
|
+
o,
|
|
26
|
+
l
|
|
27
|
+
),
|
|
28
|
+
[e]
|
|
29
|
+
), x = async (r) => {
|
|
30
|
+
if (!e || !n.walletClient) return s("Garden not initialized");
|
|
31
|
+
const t = await e.swap(r);
|
|
32
|
+
if (t.error) return s(t.error);
|
|
33
|
+
if (y(t.val.source_swap.chain)) return w(t.val);
|
|
34
|
+
const o = await q(
|
|
35
|
+
r.fromAsset.chain,
|
|
36
|
+
n.walletClient
|
|
69
37
|
);
|
|
70
|
-
if (
|
|
71
|
-
return
|
|
72
|
-
const
|
|
73
|
-
if (
|
|
74
|
-
const
|
|
38
|
+
if (o.error)
|
|
39
|
+
return s("Failed to switch network: " + o.error);
|
|
40
|
+
const l = o.val.walletClient, c = await e.evmRelay.init(l, t.val);
|
|
41
|
+
if (c.error) return s(c.error);
|
|
42
|
+
const E = {
|
|
75
43
|
...t.val,
|
|
76
44
|
source_swap: {
|
|
77
45
|
...t.val.source_swap,
|
|
78
|
-
initiate_tx_hash:
|
|
46
|
+
initiate_tx_hash: c.val
|
|
79
47
|
}
|
|
80
48
|
};
|
|
81
|
-
return
|
|
82
|
-
}
|
|
83
|
-
if (console.log("walletClient inside evmInitiate :", n), !n || !a)
|
|
84
|
-
return i("Orderbook or walletClient or auth not initialized");
|
|
85
|
-
if (W(e.source_swap.chain))
|
|
86
|
-
return i("Not an EVM order: sourceSwap.chain is Bitcoin");
|
|
87
|
-
let o = s;
|
|
88
|
-
if (!l || !o) {
|
|
89
|
-
const d = await M();
|
|
90
|
-
if (d.error) return i(d.error);
|
|
91
|
-
o = d.val;
|
|
92
|
-
}
|
|
93
|
-
const t = await G(
|
|
94
|
-
e.source_swap.chain,
|
|
95
|
-
n
|
|
96
|
-
);
|
|
97
|
-
if (t.error)
|
|
98
|
-
return i("Failed to switch network: " + t.error);
|
|
99
|
-
const c = t.val.walletClient;
|
|
100
|
-
console.log("newWalletClient :", c);
|
|
101
|
-
const h = await new N(e, r.orderBookUrl, a).init(c);
|
|
102
|
-
if (h.error) return i(h.error);
|
|
103
|
-
const u = {
|
|
104
|
-
...e,
|
|
105
|
-
source_swap: {
|
|
106
|
-
...e.source_swap,
|
|
107
|
-
initiate_tx_hash: h.val
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
return p(u);
|
|
111
|
-
}, I = async ({
|
|
112
|
-
fromAsset: e,
|
|
113
|
-
toAsset: o,
|
|
114
|
-
amount: t,
|
|
115
|
-
isExactOut: c = !1
|
|
116
|
-
}) => await m.getQuote(
|
|
117
|
-
Z(e, o),
|
|
118
|
-
t,
|
|
119
|
-
c
|
|
120
|
-
);
|
|
49
|
+
return w(E);
|
|
50
|
+
};
|
|
121
51
|
return R(() => {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
quote: m,
|
|
136
|
-
auth: a,
|
|
137
|
-
wallets: {
|
|
138
|
-
evmWallet: n,
|
|
139
|
-
btcWallet: e
|
|
140
|
-
},
|
|
141
|
-
blockNumberFetcher: C
|
|
142
|
-
});
|
|
143
|
-
B(o);
|
|
144
|
-
}, [l, n, v, a]), R(() => {
|
|
145
|
-
if (!s) return;
|
|
146
|
-
const e = s.execute(), o = (t) => P(t);
|
|
147
|
-
return s.on("onPendingOrdersChanged", o), () => {
|
|
148
|
-
(async () => (await e)())(), s.off("onPendingOrdersChanged", o);
|
|
149
|
-
};
|
|
150
|
-
}, [s]), /* @__PURE__ */ E.createElement(
|
|
151
|
-
S.Provider,
|
|
52
|
+
var r;
|
|
53
|
+
if (n.walletClient) {
|
|
54
|
+
if (!((r = n.walletClient.account) != null && r.address))
|
|
55
|
+
throw new Error("WalletClient doesn't have an account");
|
|
56
|
+
f(
|
|
57
|
+
new I({
|
|
58
|
+
environment: n.environment,
|
|
59
|
+
evmWallet: n.walletClient
|
|
60
|
+
})
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
}, [n.walletClient]), /* @__PURE__ */ m.createElement(
|
|
64
|
+
v.Provider,
|
|
152
65
|
{
|
|
153
66
|
value: {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
isExecuting: q,
|
|
163
|
-
evmInitiate: Q,
|
|
164
|
-
quote: m
|
|
67
|
+
orderBook: e == null ? void 0 : e.orderbook,
|
|
68
|
+
quote: e == null ? void 0 : e.quote,
|
|
69
|
+
swapAndInitiate: x,
|
|
70
|
+
pendingOrders: u,
|
|
71
|
+
getQuote: h,
|
|
72
|
+
garden: e,
|
|
73
|
+
isExecuting: p,
|
|
74
|
+
isExecutorRequired: C
|
|
165
75
|
}
|
|
166
76
|
},
|
|
167
|
-
|
|
77
|
+
a
|
|
168
78
|
);
|
|
169
|
-
},
|
|
170
|
-
const
|
|
171
|
-
if (!
|
|
79
|
+
}, M = () => {
|
|
80
|
+
const a = m.useContext(v);
|
|
81
|
+
if (!a)
|
|
172
82
|
throw new Error("useGarden must be used within a GardenProvider");
|
|
173
|
-
return
|
|
83
|
+
return a;
|
|
174
84
|
};
|
|
175
85
|
export {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
86
|
+
v as GardenContext,
|
|
87
|
+
B as GardenProvider,
|
|
88
|
+
M as useGarden
|
|
179
89
|
};
|
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 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;
|
package/dist/index3.js
CHANGED
|
@@ -1,43 +1,40 @@
|
|
|
1
|
-
import { filterDeadlineExpiredOrders as
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (e.error) return;
|
|
18
|
-
const { val: a } = e;
|
|
19
|
-
r.fetchOrders(!0, !0, {
|
|
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([]);
|
|
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);
|
|
11
|
+
};
|
|
12
|
+
}, [e]), u(() => {
|
|
13
|
+
e && e.blockNumberFetcher.fetchBlockNumbers().then((s) => {
|
|
14
|
+
if (s.error) return;
|
|
15
|
+
const { val: r } = s;
|
|
16
|
+
e.orderbook.fetchOrders(!0, !0, {
|
|
20
17
|
per_page: 500
|
|
21
|
-
}).then((
|
|
22
|
-
if (
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
if (!
|
|
26
|
-
const
|
|
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(
|
|
27
24
|
t,
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
i,
|
|
26
|
+
c
|
|
30
27
|
);
|
|
31
28
|
return {
|
|
32
29
|
...t,
|
|
33
|
-
status:
|
|
30
|
+
status: f
|
|
34
31
|
};
|
|
35
32
|
}).filter((t) => t !== void 0);
|
|
36
|
-
|
|
33
|
+
o(b);
|
|
37
34
|
});
|
|
38
35
|
});
|
|
39
|
-
}, [
|
|
36
|
+
}, [e]), { pendingOrders: a };
|
|
40
37
|
};
|
|
41
38
|
export {
|
|
42
|
-
|
|
39
|
+
O as useOrderbook
|
|
43
40
|
};
|
package/dist/index4.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("@catalogfi/wallets");var t=(e=>(e.mainnet="mainnet",e.testnet="testnet",e))(t||{});const r={testnet:{orderBookUrl:"https://evm-swapper-relay.onrender.com",quoteUrl:"https://quote-knrp.onrender.com",bitcoinRPCUrl:"https://mempool.space/testnet4/api",blockNumberFetcherUrl:"https://prod-mainnet-virtual-balance-pr-5.onrender.com"},mainnet:{orderBookUrl:"https://orderbookv2.garden.finance/",quoteUrl:"https://quotev2.garden.finance",bitcoinRPCUrl:"https://mempool.space/api",blockNumberFetcherUrl:"https://info-8ocl.onrender.com"}};exports.GARDEN_CONFIG=r;exports.environment=t;
|
package/dist/index4.js
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import "@catalogfi/wallets";
|
|
2
|
+
var t = /* @__PURE__ */ ((e) => (e.mainnet = "mainnet", e.testnet = "testnet", e))(t || {});
|
|
3
|
+
const o = {
|
|
4
|
+
testnet: {
|
|
5
|
+
orderBookUrl: "https://evm-swapper-relay.onrender.com",
|
|
6
|
+
quoteUrl: "https://quote-knrp.onrender.com",
|
|
7
|
+
bitcoinRPCUrl: "https://mempool.space/testnet4/api",
|
|
8
|
+
blockNumberFetcherUrl: "https://prod-mainnet-virtual-balance-pr-5.onrender.com"
|
|
9
|
+
},
|
|
10
|
+
mainnet: {
|
|
11
|
+
orderBookUrl: "https://orderbookv2.garden.finance/",
|
|
12
|
+
quoteUrl: "https://quotev2.garden.finance",
|
|
13
|
+
bitcoinRPCUrl: "https://mempool.space/api",
|
|
14
|
+
blockNumberFetcherUrl: "https://info-8ocl.onrender.com"
|
|
15
|
+
}
|
|
11
16
|
};
|
|
12
17
|
export {
|
|
13
|
-
|
|
18
|
+
o as GARDEN_CONFIG,
|
|
19
|
+
t as environment
|
|
14
20
|
};
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { GardenProvider, useGarden } from './lib/context/GardenProvider';
|
|
2
2
|
export { useOrderbook } from './lib/hooks/useOrderbook';
|
|
3
|
-
export { useSecretManager } from './lib/hooks/useSecretManager';
|
|
4
3
|
export { BitcoinNetwork } from '@catalogfi/wallets';
|
|
4
|
+
export { environment, GARDEN_CONFIG } from './lib/gardenConfig';
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { WalletClient } from 'viem';
|
|
2
|
+
import { OrderWithStatus, IGardenJS, IQuote, QuoteResponse, SwapParams } from '@gardenfi/core';
|
|
3
|
+
import { AsyncResult, Result } from '@catalogfi/utils';
|
|
4
4
|
import { Asset, IOrderbook, MatchedOrder } from '@gardenfi/orderbook';
|
|
5
|
-
import { IStore } from '@gardenfi/utils';
|
|
5
|
+
import { Environment, IStore } from '@gardenfi/utils';
|
|
6
6
|
|
|
7
7
|
export type GardenContextType = {
|
|
8
|
-
orderBookUrl?: string;
|
|
9
|
-
/**
|
|
10
|
-
* Initializing secretManager is necessary for executing orders.
|
|
11
|
-
* @returns {AsyncResult<SecretManager, string>} - The secret manager instance.
|
|
12
|
-
*/
|
|
13
|
-
initializeSecretManager?: () => AsyncResult<SecretManager, string>;
|
|
14
8
|
/**
|
|
15
9
|
* The orderbook instance.
|
|
16
10
|
* @returns {IOrderbook}
|
|
@@ -21,7 +15,7 @@ export type GardenContextType = {
|
|
|
21
15
|
* @params {SwapParams} - The parameters for creating the order.
|
|
22
16
|
* @returns {AsyncResult<string, string>} - create order ID.
|
|
23
17
|
*/
|
|
24
|
-
|
|
18
|
+
swapAndInitiate?: (params: SwapParams) => AsyncResult<MatchedOrder, string>;
|
|
25
19
|
/**
|
|
26
20
|
* Get all the pending orders of the user. This will return all the orders that are yet to be initiated, redeemed, or refunded.
|
|
27
21
|
* It will not return orders that have expired (deadline expiry).
|
|
@@ -33,28 +27,20 @@ export type GardenContextType = {
|
|
|
33
27
|
* @param params
|
|
34
28
|
* @returns
|
|
35
29
|
*/
|
|
36
|
-
getQuote?: (params: QuoteParams) =>
|
|
37
|
-
/**
|
|
38
|
-
* The secret manager instance.
|
|
39
|
-
* @returns {ISecretManager}
|
|
40
|
-
*/
|
|
41
|
-
secretManager?: ISecretManager;
|
|
30
|
+
getQuote?: (params: QuoteParams) => Promise<Result<QuoteResponse, string>>;
|
|
42
31
|
/**
|
|
43
32
|
* The garden instance.
|
|
44
33
|
* @returns {IGardenJS}
|
|
45
34
|
*/
|
|
46
35
|
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
36
|
/**
|
|
55
37
|
* Indicates if the orders are executing.
|
|
56
38
|
*/
|
|
57
39
|
isExecuting: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Indicates if the executor is required based on pending orders.
|
|
42
|
+
*/
|
|
43
|
+
isExecutorRequired: boolean;
|
|
58
44
|
/**
|
|
59
45
|
* The quote instance.
|
|
60
46
|
* @returns {IQuote}
|
|
@@ -64,10 +50,11 @@ export type GardenContextType = {
|
|
|
64
50
|
export type GardenProviderProps = {
|
|
65
51
|
children: React.ReactNode;
|
|
66
52
|
config: {
|
|
67
|
-
orderBookUrl: string;
|
|
68
|
-
quoteUrl: string;
|
|
69
53
|
store: IStore;
|
|
70
|
-
|
|
54
|
+
environment: Environment;
|
|
55
|
+
walletClient?: WalletClient;
|
|
56
|
+
orderBookUrl?: string;
|
|
57
|
+
quoteUrl?: string;
|
|
71
58
|
bitcoinRPCUrl?: string;
|
|
72
59
|
blockNumberFetcherUrl?: string;
|
|
73
60
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BitcoinNetwork } from '@catalogfi/wallets';
|
|
2
|
+
|
|
3
|
+
export type GardenConfigType = {
|
|
4
|
+
orderBookUrl: string;
|
|
5
|
+
quoteUrl: string;
|
|
6
|
+
bitcoinRPCUrl: string;
|
|
7
|
+
blockNumberFetcherUrl: string;
|
|
8
|
+
};
|
|
9
|
+
export declare enum environment {
|
|
10
|
+
mainnet = "mainnet",
|
|
11
|
+
testnet = "testnet"
|
|
12
|
+
}
|
|
13
|
+
export declare const GARDEN_CONFIG: Partial<Record<environment, GardenConfigType>>;
|
|
14
|
+
export declare const getConfigForNetwork: (network: environment) => GardenConfigType;
|
|
15
|
+
export declare const getBitcoinNetwork: (network: environment) => BitcoinNetwork;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { IOrderbook } from '@gardenfi/orderbook';
|
|
3
|
-
import { IAuth } from '@gardenfi/utils';
|
|
1
|
+
import { IGardenJS, OrderWithStatus } from '@gardenfi/core';
|
|
4
2
|
|
|
5
|
-
export declare const useOrderbook: (
|
|
6
|
-
|
|
3
|
+
export declare const useOrderbook: (garden: IGardenJS | undefined) => {
|
|
4
|
+
pendingOrders: OrderWithStatus[];
|
|
7
5
|
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { ISecretManager, SecretManager } from '@gardenfi/core';
|
|
2
|
-
import { SetStateAction } from 'react';
|
|
3
|
-
|
|
4
|
-
export declare const useSecretManager: (setSecretManager: React.Dispatch<SetStateAction<ISecretManager | undefined>>) => {
|
|
5
|
-
initializeSecretManager: () => Promise<import('@catalogfi/utils').Result<never, string> | import('@catalogfi/utils').Result<SecretManager, never>>;
|
|
6
|
-
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gardenfi/react-hooks",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2-beta.1",
|
|
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.
|
|
32
|
-
"@gardenfi/orderbook": "^0.2.0-beta.
|
|
33
|
-
"@gardenfi/utils": "^0.0.1-beta.
|
|
31
|
+
"@gardenfi/core": "^0.3.0-beta.15",
|
|
32
|
+
"@gardenfi/orderbook": "^0.2.0-beta.42",
|
|
33
|
+
"@gardenfi/utils": "^0.0.1-beta.20",
|
|
34
34
|
"react": "^18.3.1",
|
|
35
35
|
"viem": "^2.21.15",
|
|
36
36
|
"wagmi": "^2.12.16"
|