@gardenfi/react-hooks 0.0.1-beta.108 → 0.0.1-beta.109

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"),x=require("wagmi"),z=require("./index4.cjs"),A=require("./index3.cjs"),u=require("@gardenfi/core"),n=require("@catalogfi/utils"),G=require("@gardenfi/orderbook"),b=require("@catalogfi/wallets"),q=require("@gardenfi/utils"),K=require("./index5.cjs"),R=a.createContext({isExecuting:!1}),Q=({children:h,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]),w=a.useMemo(()=>new u.Quote(r.quoteUrl),[r.quoteUrl]),B=a.useMemo(()=>{const e=r.network===b.BitcoinNetwork.Mainnet?"mainnet":r.network===b.BitcoinNetwork.Testnet?"testnet":void 0;return r.blockNumberFetcherUrl&&e?new u.BlockNumberFetcher(r.blockNumberFetcherUrl,e):void 0},[r.blockNumberFetcherUrl,r.network]),M=a.useMemo(()=>new b.BitcoinProvider(r.network,r.bitcoinRPCUrl),[r.network,r.bitcoinRPCUrl]),{data:i}=x.useWalletClient(),{initializeSecretManager:P}=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 P();if(e.error)return n.Err(e.error);const o=b.BitcoinWallet.fromPrivateKey(e.val.getMasterPrivKey(),M),t=new u.Garden({orderbookURl:r.orderBookUrl,secretManager:e.val,quote:w,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,k=await new u.EvmRelay(t.val,r.orderBookUrl,s).init(p);if(k.error)return n.Err(k.error);const v={...t.val,source_swap:{...t.val.source_swap,initiate_tx_hash:k.val}};return n.Ok(v)},F=async e=>{if(!i||!s)return n.Err("Orderbook or walletClient or auth not initialized");if(G.isBitcoin(e.source_swap.chain))return n.Err("Not an EVM order: sourceSwap.chain is Bitcoin");let o=l;if(!c||!o){const v=await f();if(v.error)return n.Err(v.error);o=v.val}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 k={...e,source_swap:{...e.source_swap,initiate_tx_hash:E.val}};return n.Ok(k)},W=a.useMemo(()=>async({fromAsset:e,toAsset:o,amount:t,isExactOut:d=!1})=>await w.getQuote(K.constructOrderpair(e,o),t,d),[w]);return a.useEffect(()=>{if(!i||!window)return;const e=new q.Siwe(new q.Url(r.orderBookUrl),i,{store:r.store,domain:window.location.hostname});N(e)},[i]),a.useEffect(()=>{if(!c||!i||!m||!s)return;const e=b.BitcoinWallet.fromPrivateKey(c.getMasterPrivKey(),M),o=new u.Garden({orderbookURl:r.orderBookUrl,secretManager:c,quote:w,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:P,orderBook:m,swapAndInitiate:g,pendingOrders:O,getQuote:W,secretManager:c,garden:l,isExecuting:_,evmInitiate:F,quote:w}},h)},$=()=>{const h=a.useContext(R);if(!h)throw new Error("useGarden must be used within a GardenProvider");return h};exports.GardenContext=R;exports.GardenProvider=Q;exports.useGarden=$;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react"),Q=require("wagmi"),I=require("./index4.cjs"),j=require("./index3.cjs"),u=require("@gardenfi/core"),t=require("@catalogfi/utils"),F=require("@gardenfi/orderbook"),O=require("@catalogfi/wallets"),N=require("@gardenfi/utils"),T=require("./index5.cjs"),_=require("./index6.cjs"),P=n.createContext({isExecuting:!1}),V=({children:h,config:i})=>{const[l,W]=n.useState(),[c,U]=n.useState(),[a,x]=n.useState(),[g,y]=n.useState(),z=n.useMemo(()=>!!(l&&c&&a&&g),[l,c,a,g]),{orderBookUrl:d,quoteUrl:M,bitcoinRPCUrl:q,blockNumberFetcherUrl:C}=n.useMemo(()=>{const e=_.getConfigForNetwork(i.environment);return{orderBookUrl:i.orderBookUrl||e.orderBookUrl,quoteUrl:i.quoteUrl||e.quoteUrl,bitcoinRPCUrl:i.bitcoinRPCUrl||e.bitcoinRPCUrl,blockNumberFetcherUrl:i.blockNumberFetcherUrl||e.blockNumberFetcherUrl}},[i]),v=n.useMemo(()=>new u.Quote(M),[M]),E=n.useMemo(()=>C&&i.environment?new u.BlockNumberFetcher(C,i.environment):void 0,[C,i.environment]),p=n.useMemo(()=>new O.BitcoinProvider(_.getBitcoinNetwork(i.environment),q),[i.environment,q]),{data:s}=Q.useWalletClient(),{initializeSecretManager:G}=I.useSecretManager(W),{orderbook:k}=j.useOrderbook(d,a,y,E),B=async()=>{if(!s||!a)return t.Err("WalletClient or auth not initialized");const e=await G();if(e.error)return t.Err(e.error);const o=O.BitcoinWallet.fromPrivateKey(e.val.getMasterPrivKey(),p),r=new u.Garden({orderbookURl:d,secretManager:e.val,quote:v,auth:a,wallets:{evmWallet:s,btcWallet:o},blockNumberFetcher:E});return U(r),t.Ok(r)},A=async e=>{if(!k||!s||!a)return t.Err("Orderbook or walletClient or auth not initialized");let o=c;if(!l||!o){const R=await B();if(R.error)return t.Err(R.error);o=R.val}const r=await o.swap(e);if(r.error)return t.Err(r.error);if(F.isBitcoin(r.val.source_swap.chain))return t.Ok(r.val);const w=await u.switchOrAddNetwork(e.fromAsset.chain,s);if(w.error)return t.Err("Failed to switch network: "+w.error);const S=w.val.walletClient,b=await new u.EvmRelay(r.val,d,a).init(S);if(b.error)return t.Err(b.error);const m={...r.val,source_swap:{...r.val.source_swap,initiate_tx_hash:b.val}};return t.Ok(m)},K=async e=>{if(!s||!a)return t.Err("Orderbook or walletClient or auth not initialized");if(F.isBitcoin(e.source_swap.chain))return t.Err("Not an EVM order: sourceSwap.chain is Bitcoin");let o=c;if(!l||!o){const m=await B();if(m.error)return t.Err(m.error);o=m.val}const r=await u.switchOrAddNetwork(e.source_swap.chain,s);if(r.error)return t.Err("Failed to switch network: "+r.error);const w=r.val.walletClient,f=await new u.EvmRelay(e,d,a).init(w);if(f.error)return t.Err(f.error);const b={...e,source_swap:{...e.source_swap,initiate_tx_hash:f.val}};return t.Ok(b)},$=n.useMemo(()=>async({fromAsset:e,toAsset:o,amount:r,isExactOut:w=!1})=>await v.getQuote(T.constructOrderpair(e,o),r,w),[v]);return n.useEffect(()=>{if(!s||!window)return;const e=new N.Siwe(new N.Url(d),s,{store:i.store,domain:window.location.hostname});x(e)},[s]),n.useEffect(()=>{if(!l||!s||!k||!a)return;const e=O.BitcoinWallet.fromPrivateKey(l.getMasterPrivKey(),p),o=new u.Garden({orderbookURl:d,secretManager:l,quote:v,auth:a,wallets:{evmWallet:s,btcWallet:e},blockNumberFetcher:E});U(o)},[l,s,k,a]),n.useEffect(()=>{if(!c)return;const e=c.execute(),o=r=>y(r);return c.on("onPendingOrdersChanged",o),()=>{(async()=>(await e)())(),c.off("onPendingOrdersChanged",o)}},[c]),n.createElement(P.Provider,{value:{orderBookUrl:d,initializeSecretManager:G,orderBook:k,swapAndInitiate:A,pendingOrders:g,getQuote:$,secretManager:l,garden:c,isExecuting:z,evmInitiate:K,quote:v}},h)},D=()=>{const h=n.useContext(P);if(!h)throw new Error("useGarden must be used within a GardenProvider");return h};exports.GardenContext=P;exports.GardenProvider=V;exports.useGarden=D;
package/dist/index2.js CHANGED
@@ -1,176 +1,179 @@
1
- import S, { createContext as T, useState as b, useMemo as m, 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({
1
+ import z, { createContext as H, useState as p, useMemo as d, useEffect as P } from "react";
2
+ import { useWalletClient as J } from "wagmi";
3
+ import { useSecretManager as L } from "./index4.js";
4
+ import { useOrderbook as T } from "./index3.js";
5
+ import { Quote as X, BlockNumberFetcher as Y, Garden as x, switchOrAddNetwork as W, EvmRelay as E } from "@gardenfi/core";
6
+ import { Err as a, Ok as k } from "@catalogfi/utils";
7
+ import { isBitcoin as S } from "@gardenfi/orderbook";
8
+ import { BitcoinProvider as Z, BitcoinWallet as q } from "@catalogfi/wallets";
9
+ import { Siwe as $, Url as ee } from "@gardenfi/utils";
10
+ import { constructOrderpair as re } from "./index5.js";
11
+ import { getConfigForNetwork as te, getBitcoinNetwork as ne } from "./index6.js";
12
+ const A = H({
12
13
  isExecuting: !1
13
- }), ce = ({
14
+ }), he = ({
14
15
  children: h,
15
- config: r
16
+ config: n
16
17
  }) => {
17
- const [l, z] = b(), [s, B] = b(), [n, A] = b(), [f, P] = b(), K = m(
18
- () => !!(l && s && n && f),
19
- [l, s, n, f]
20
- ), u = m(() => new H(r.quoteUrl), [r.quoteUrl]), U = m(() => {
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 = m(
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
18
+ const [l, K] = p(), [s, y] = p(), [o, Q] = p(), [C, O] = p(), I = d(
19
+ () => !!(l && s && o && C),
20
+ [l, s, o, C]
21
+ ), { orderBookUrl: c, quoteUrl: B, bitcoinRPCUrl: F, blockNumberFetcherUrl: g } = d(() => {
22
+ const e = te(n.environment);
23
+ return {
24
+ orderBookUrl: n.orderBookUrl || e.orderBookUrl,
25
+ quoteUrl: n.quoteUrl || e.quoteUrl,
26
+ bitcoinRPCUrl: n.bitcoinRPCUrl || e.bitcoinRPCUrl,
27
+ blockNumberFetcherUrl: n.blockNumberFetcherUrl || e.blockNumberFetcherUrl
28
+ };
29
+ }, [n]), w = d(() => new X(B), [B]), R = d(() => g && n.environment ? new Y(g, n.environment) : void 0, [g, n.environment]), _ = d(
30
+ () => new Z(ne(n.environment), F),
31
+ [n.environment, F]
32
+ ), { data: i } = J(), { initializeSecretManager: G } = L(K), { orderbook: b } = T(
33
+ c,
34
+ o,
35
+ O,
36
+ R
34
37
  ), 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(
38
+ if (!i || !o)
39
+ return a("WalletClient or auth not initialized");
40
+ const e = await G();
41
+ if (e.error) return a(e.error);
42
+ const t = q.fromPrivateKey(
40
43
  e.val.getMasterPrivKey(),
41
- y
42
- ), t = new F({
43
- orderbookURl: r.orderBookUrl,
44
+ _
45
+ ), r = new x({
46
+ orderbookURl: c,
44
47
  secretManager: e.val,
45
- quote: u,
46
- auth: n,
48
+ quote: w,
49
+ auth: o,
47
50
  wallets: {
48
- evmWallet: a,
49
- btcWallet: o
51
+ evmWallet: i,
52
+ btcWallet: t
50
53
  },
51
- blockNumberFetcher: U
54
+ blockNumberFetcher: R
52
55
  });
53
- return B(t), p(t);
54
- }, q = 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;
56
+ return y(r), k(r);
57
+ }, V = async (e) => {
58
+ if (!b || !i || !o)
59
+ return a("Orderbook or walletClient or auth not initialized");
60
+ let t = s;
61
+ if (!l || !t) {
62
+ const U = await M();
63
+ if (U.error) return a(U.error);
64
+ t = U.val;
62
65
  }
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(
66
+ const r = await t.swap(e);
67
+ if (r.error) return a(r.error);
68
+ if (S(r.val.source_swap.chain)) return k(r.val);
69
+ const u = await W(
67
70
  e.fromAsset.chain,
68
- a
71
+ i
69
72
  );
70
- if (c.error)
71
- return i("Failed to switch network: " + c.error);
72
- const _ = c.val.walletClient, d = await new N(t.val, r.orderBookUrl, n).init(_);
73
- if (d.error) return i(d.error);
74
- const w = {
75
- ...t.val,
73
+ if (u.error)
74
+ return a("Failed to switch network: " + u.error);
75
+ const N = u.val.walletClient, m = await new E(r.val, c, o).init(N);
76
+ if (m.error) return a(m.error);
77
+ const v = {
78
+ ...r.val,
76
79
  source_swap: {
77
- ...t.val.source_swap,
78
- initiate_tx_hash: d.val
80
+ ...r.val.source_swap,
81
+ initiate_tx_hash: m.val
79
82
  }
80
83
  };
81
- return p(w);
82
- }, Q = async (e) => {
83
- if (!a || !n)
84
- return i("Orderbook or walletClient or auth not initialized");
85
- if (x(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 w = await M();
90
- if (w.error) return i(w.error);
91
- o = w.val;
84
+ return k(v);
85
+ }, j = async (e) => {
86
+ if (!i || !o)
87
+ return a("Orderbook or walletClient or auth not initialized");
88
+ if (S(e.source_swap.chain))
89
+ return a("Not an EVM order: sourceSwap.chain is Bitcoin");
90
+ let t = s;
91
+ if (!l || !t) {
92
+ const v = await M();
93
+ if (v.error) return a(v.error);
94
+ t = v.val;
92
95
  }
93
- const t = await G(
96
+ const r = await W(
94
97
  e.source_swap.chain,
95
- a
98
+ i
96
99
  );
97
- if (t.error)
98
- return i("Failed to switch network: " + t.error);
99
- const c = t.val.walletClient, k = await new N(e, r.orderBookUrl, n).init(c);
100
- if (k.error) return i(k.error);
101
- const d = {
100
+ if (r.error)
101
+ return a("Failed to switch network: " + r.error);
102
+ const u = r.val.walletClient, f = await new E(e, c, o).init(u);
103
+ if (f.error) return a(f.error);
104
+ const m = {
102
105
  ...e,
103
106
  source_swap: {
104
107
  ...e.source_swap,
105
- initiate_tx_hash: k.val
108
+ initiate_tx_hash: f.val
106
109
  }
107
110
  };
108
- return p(d);
109
- }, I = m(
110
- () => async ({ fromAsset: e, toAsset: o, amount: t, isExactOut: c = !1 }) => await u.getQuote(
111
- Z(e, o),
112
- t,
113
- c
111
+ return k(m);
112
+ }, D = d(
113
+ () => async ({ fromAsset: e, toAsset: t, amount: r, isExactOut: u = !1 }) => await w.getQuote(
114
+ re(e, t),
115
+ r,
116
+ u
114
117
  ),
115
- [u]
118
+ [w]
116
119
  );
117
- return R(() => {
118
- if (!a || !window) return;
119
- const e = new X(new Y(r.orderBookUrl), a, {
120
- store: r.store,
120
+ return P(() => {
121
+ if (!i || !window) return;
122
+ const e = new $(new ee(c), i, {
123
+ store: n.store,
121
124
  domain: window.location.hostname
122
125
  });
123
- A(e);
124
- }, [a]), R(() => {
125
- if (!l || !a || !v || !n) return;
126
- const e = E.fromPrivateKey(
126
+ Q(e);
127
+ }, [i]), P(() => {
128
+ if (!l || !i || !b || !o) return;
129
+ const e = q.fromPrivateKey(
127
130
  l.getMasterPrivKey(),
128
- y
129
- ), o = new F({
130
- orderbookURl: r.orderBookUrl,
131
+ _
132
+ ), t = new x({
133
+ orderbookURl: c,
131
134
  secretManager: l,
132
- quote: u,
133
- auth: n,
135
+ quote: w,
136
+ auth: o,
134
137
  wallets: {
135
- evmWallet: a,
138
+ evmWallet: i,
136
139
  btcWallet: e
137
140
  },
138
- blockNumberFetcher: U
141
+ blockNumberFetcher: R
139
142
  });
140
- B(o);
141
- }, [l, a, v, n]), R(() => {
143
+ y(t);
144
+ }, [l, i, b, o]), P(() => {
142
145
  if (!s) return;
143
- const e = s.execute(), o = (t) => P(t);
144
- return s.on("onPendingOrdersChanged", o), () => {
145
- (async () => (await e)())(), s.off("onPendingOrdersChanged", o);
146
+ const e = s.execute(), t = (r) => O(r);
147
+ return s.on("onPendingOrdersChanged", t), () => {
148
+ (async () => (await e)())(), s.off("onPendingOrdersChanged", t);
146
149
  };
147
- }, [s]), /* @__PURE__ */ S.createElement(
148
- g.Provider,
150
+ }, [s]), /* @__PURE__ */ z.createElement(
151
+ A.Provider,
149
152
  {
150
153
  value: {
151
- orderBookUrl: r.orderBookUrl,
152
- initializeSecretManager: O,
153
- orderBook: v,
154
- swapAndInitiate: q,
155
- pendingOrders: f,
156
- getQuote: I,
154
+ orderBookUrl: c,
155
+ initializeSecretManager: G,
156
+ orderBook: b,
157
+ swapAndInitiate: V,
158
+ pendingOrders: C,
159
+ getQuote: D,
157
160
  secretManager: l,
158
161
  garden: s,
159
- isExecuting: K,
160
- evmInitiate: Q,
161
- quote: u
162
+ isExecuting: I,
163
+ evmInitiate: j,
164
+ quote: w
162
165
  }
163
166
  },
164
167
  h
165
168
  );
166
- }, ue = () => {
167
- const h = S.useContext(g);
169
+ }, be = () => {
170
+ const h = z.useContext(A);
168
171
  if (!h)
169
172
  throw new Error("useGarden must be used within a GardenProvider");
170
173
  return h;
171
174
  };
172
175
  export {
173
- g as GardenContext,
174
- ce as GardenProvider,
175
- ue as useGarden
176
+ A as GardenContext,
177
+ he as GardenProvider,
178
+ be as useGarden
176
179
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@catalogfi/wallets"),r={testnet:{orderBookUrl:"https://evm-swapper-relay.onrender.com",quoteUrl:"https://quote-knrp.onrender.com",bitcoinRPCUrl:"https://mempool.space/testnet4",blockNumberFetcherUrl:"https://mempool.space"}},n=t=>{const e=r[t];if(!e)throw new Error(`Configuration for network ${t} not found`);return e},i=t=>{switch(t){case"mainnet":return o.BitcoinNetwork.Mainnet;case"testnet":return o.BitcoinNetwork.Testnet;default:throw new Error(`Invalid bitcoin network ${t}`)}};exports.GARDEN_CONFIG=r;exports.getBitcoinNetwork=i;exports.getConfigForNetwork=n;
package/dist/index6.js ADDED
@@ -0,0 +1,28 @@
1
+ import { BitcoinNetwork as o } from "@catalogfi/wallets";
2
+ const r = {
3
+ testnet: {
4
+ orderBookUrl: "https://evm-swapper-relay.onrender.com",
5
+ quoteUrl: "https://quote-knrp.onrender.com",
6
+ bitcoinRPCUrl: "https://mempool.space/testnet4",
7
+ blockNumberFetcherUrl: "https://mempool.space"
8
+ }
9
+ }, c = (t) => {
10
+ const e = r[t];
11
+ if (!e)
12
+ throw new Error(`Configuration for network ${t} not found`);
13
+ return e;
14
+ }, i = (t) => {
15
+ switch (t) {
16
+ case "mainnet":
17
+ return o.Mainnet;
18
+ case "testnet":
19
+ return o.Testnet;
20
+ default:
21
+ throw new Error(`Invalid bitcoin network ${t}`);
22
+ }
23
+ };
24
+ export {
25
+ r as GARDEN_CONFIG,
26
+ i as getBitcoinNetwork,
27
+ c as getConfigForNetwork
28
+ };
@@ -1,8 +1,8 @@
1
1
  import { OrderWithStatus, IGardenJS, IQuote, ISecretManager, QuoteResponse, SecretManager, SwapParams } from '@gardenfi/core';
2
2
  import { AsyncResult } from '@catalogfi/utils';
3
- import { BitcoinNetwork } from '@catalogfi/wallets';
4
3
  import { Asset, IOrderbook, MatchedOrder } from '@gardenfi/orderbook';
5
4
  import { IStore } from '@gardenfi/utils';
5
+ import { environment } from '../gardenConfig';
6
6
 
7
7
  export type GardenContextType = {
8
8
  orderBookUrl?: string;
@@ -64,10 +64,10 @@ export type GardenContextType = {
64
64
  export type GardenProviderProps = {
65
65
  children: React.ReactNode;
66
66
  config: {
67
- orderBookUrl: string;
68
- quoteUrl: string;
69
67
  store: IStore;
70
- network: BitcoinNetwork;
68
+ environment: environment;
69
+ orderBookUrl?: string;
70
+ quoteUrl?: string;
71
71
  bitcoinRPCUrl?: string;
72
72
  blockNumberFetcherUrl?: string;
73
73
  };
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gardenfi/react-hooks",
3
- "version": "0.0.1-beta.108",
3
+ "version": "0.0.1-beta.109",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",