@omnity/ree-client-ts-sdk 0.5.4 → 0.5.6
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/README.md +2 -1
- package/dist/index.cjs.js +48 -48
- package/dist/index.d.ts +7 -3
- package/dist/index.es.js +2128 -2101
- package/dist/react.cjs.js +1 -1
- package/dist/react.d.ts +11 -3
- package/dist/react.es.js +187 -181
- package/package.json +1 -1
package/dist/react.cjs.js
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 w=require("react/jsx-runtime"),e=require("react"),E=require("./index.cjs.js"),m=e.createContext(null);function v({children:t,config:s}){if(!s)throw new Error("ReeProvider: config is required");if(!s.network)throw new Error("ReeProvider: config.network is required");if(!s.maestroApiKey)throw new Error("ReeProvider: config.maestroApiKey is required");if(!s.exchangeIdlFactory)throw new Error("ReeProvider: config.exchangeIdlFactory is required");if(!s.exchangeCanisterId)throw new Error("ReeProvider: config.exchangeCanisterId is required");const[r,c]=e.useState({address:"",paymentAddress:"",publicKey:"",paymentPublicKey:""}),a=e.useCallback(o=>{c(d=>({...d,...o}))},[]),n=e.useMemo(()=>new E.ReeClient(s),[s]),f=e.useCallback(async o=>{if(!n)throw new Error("Client not available");if(!r.address||!r.paymentAddress)throw new Error("Wallet not connected");return n.createTransaction({address:r.address,paymentAddress:r.paymentAddress,feeRate:o?.feeRate,publicKey:r.publicKey,mergeSelfRuneBtcOutputs:o?.mergeSelfRuneBtcOutputs,clientInfo:o?.clientInfo})},[n,r]),l=e.useMemo(()=>({client:n,...r,exchange:n.exchange,updateWallet:a,createTransaction:f}),[n,r,a,f]);return w.jsx(m.Provider,{value:l,children:t})}function y(){const t=e.useContext(m);if(!t)throw new Error("useRee must be used within ReeProvider");return t}function S(t={}){const{refreshInterval:s=0,autoRefresh:r=!0}=t,{client:c,paymentAddress:a}=y(),[n,f]=e.useState(null),[l,o]=e.useState(!1),[d,h]=e.useState(null),u=e.useCallback(async()=>{if(!a){f(null),h("Payment address not set");return}o(!0),h(null);try{const i=await c.getBtcBalance(a);f(i)}catch(i){h(i instanceof Error?i.message:"Failed to fetch BTC balance"),f(null)}finally{o(!1)}},[c,a]);return e.useEffect(()=>{r&&u()},[a,u,r]),e.useEffect(()=>{if(s>0){const i=setInterval(u,s);return()=>clearInterval(i)}},[s,a,u]),{balance:n,loading:l,error:d,refetch:u}}function x(t,s={}){const{refreshInterval:r=0,autoRefresh:c=!0}=s,{client:a,address:n,publicKey:f}=y(),[l,o]=e.useState(null),[d,h]=e.useState(!1),[u,i]=e.useState(null),R=e.useCallback(async()=>{if(!n){o(null),i("Address not set");return}if(!t){o(null),i("Rune ID is required");return}h(!0),i(null);try{const g=await a.getRuneBalance(n,t,f);o(g??null)}catch(g){i(g instanceof Error?g.message:"Failed to fetch rune balance"),o(null)}finally{h(!1)}},[a,n,t]);return e.useEffect(()=>{c&&t&&R()},[n,t,R,c]),e.useEffect(()=>{if(r>0&&t){const g=setInterval(R,r);return()=>clearInterval(g)}},[r,n,t,R]),{balance:l,loading:d,error:u,refetch:R}}function b(t={}){const{refreshInterval:s=0,autoRefresh:r=!0}=t,{client:c,paymentAddress:a}=y(),[n,f]=e.useState([]),[l,o]=e.useState(!1),[d,h]=e.useState(null),u=e.useCallback(async()=>{if(!a){f([]),h("Payment address not set");return}o(!0),h(null);try{const i=await c.getBtcUtxos(a);f(i)}catch(i){h(i instanceof Error?i.message:"Failed to fetch BTC UTXOs"),f([])}finally{o(!1)}},[c,a]);return e.useEffect(()=>{r&&a&&u()},[a,u,r]),e.useEffect(()=>{if(s>0&&a){const i=setInterval(u,s);return()=>clearInterval(i)}},[s,a,u]),{utxos:n,loading:l,error:d,refetch:u}}function P(t,s={}){const{refreshInterval:r=0,autoRefresh:c=!0}=s,{client:a,address:n}=y(),[f,l]=e.useState([]),[o,d]=e.useState(!1),[h,u]=e.useState(null),i=e.useCallback(async()=>{if(!n){l([]),u("Address not set");return}if(!t){l([]),u("Rune ID is required");return}d(!0),u(null);try{const R=await a.getRuneUtxos(n,t);l(R)}catch(R){u(R instanceof Error?R.message:"Failed to fetch rune UTXOs"),l([])}finally{d(!1)}},[a,n,t]);return e.useEffect(()=>{c&&n&&t&&i()},[n,t,i,c]),e.useEffect(()=>{if(r>0&&n&&t){const R=setInterval(i,r);return()=>clearInterval(R)}},[r,n,t,i]),{utxos:f,loading:o,error:h,refetch:i}}function B(){const{client:t}=y();return e.useCallback(async r=>{const c=r;if(!c)throw new Error("Search keyword is required");return await t.searchRunes(c)},[t])}function I(t){const{client:s}=y(),[r,c]=e.useState(null),[a,n]=e.useState(!1),[f,l]=e.useState(null),o=e.useCallback(async()=>{if(!t){c(null),l("Rune ID is required");return}n(!0),l(null);try{const d=await s.getRuneInfo(t);c(d||null)}catch(d){l(d instanceof Error?d.message:"Failed to fetch rune info"),c(null)}finally{n(!1)}},[s,t]);return{runeInfo:r,loading:a,error:f,refetch:o}}function C(){const{client:t}=y(),[s,r]=e.useState([]),[c,a]=e.useState(!1),[n,f]=e.useState(null),l=e.useCallback(async()=>{a(!0),f(null);try{const o=await t.getPoolList();r(o)}catch(o){f(o instanceof Error?o.message:"Failed to fetch pool list"),r([])}finally{a(!1)}},[t]);return e.useEffect(()=>{l()},[l]),{pools:s,loading:c,error:n,refetch:l}}function p(t){const{client:s}=y(),[r,c]=e.useState(null),[a,n]=e.useState(!1),[f,l]=e.useState(null),o=e.useCallback(async()=>{if(!t){c(null),l("Pool address is required");return}n(!0),l(null);try{const d=await s.getPoolInfo(t);c(d)}catch(d){l(d instanceof Error?d.message:"Failed to fetch pool info"),c(null)}finally{n(!1)}},[s,t]);return e.useEffect(()=>{o()},[t]),{poolInfo:r,loading:a,error:f,refetch:o}}function k(t={}){const{refreshInterval:s=0,autoRefresh:r=!0}=t,{client:c}=y(),[a,n]=e.useState(null),[f,l]=e.useState(!1),[o,d]=e.useState(null),h=e.useCallback(async()=>{l(!0),d(null);try{const u=await c.getRecommendedFeeRate();n(u)}catch(u){d(u instanceof Error?u.message:"Failed to fetch recommended fee rate"),n(null)}finally{l(!1)}},[c]);return e.useEffect(()=>{r&&h()},[r,h]),e.useEffect(()=>{if(s>0){const u=setInterval(h,s);return()=>clearInterval(u)}},[s,h]),{feeRate:a,loading:f,error:o,refetch:h}}exports.Network=E.Network;exports.utils=E.utils;exports.ReeProvider=v;exports.useBtcBalance=S;exports.useBtcUtxos=b;exports.usePoolInfo=p;exports.usePoolList=C;exports.useRecommendedFeeRate=k;exports.useRee=y;exports.useRuneBalance=x;exports.useRuneInfo=I;exports.useRuneUtxos=P;exports.useSearchRunes=B;
|
package/dist/react.d.ts
CHANGED
|
@@ -257,7 +257,7 @@ declare class ReeClient {
|
|
|
257
257
|
* @param runeId - The rune ID to filter UTXOs by
|
|
258
258
|
* @returns Array of UTXOs containing the specified rune
|
|
259
259
|
*/
|
|
260
|
-
getRuneUtxos(address: string, runeId: string): Promise<Utxo[]>;
|
|
260
|
+
getRuneUtxos(address: string, runeId: string, publicKey?: string): Promise<Utxo[]>;
|
|
261
261
|
/**
|
|
262
262
|
* Search for runes by keyword or rune ID
|
|
263
263
|
* Supports both exact rune ID matches and fuzzy name matching
|
|
@@ -282,7 +282,7 @@ declare class ReeClient {
|
|
|
282
282
|
* @param runeId - The rune ID to get balance for (format: "block:index")
|
|
283
283
|
* @returns Rune balance as a number, or undefined if rune not found
|
|
284
284
|
*/
|
|
285
|
-
getRuneBalance(address: string, runeId: string): Promise<number | undefined>;
|
|
285
|
+
getRuneBalance(address: string, runeId: string, publicKey?: string): Promise<number | undefined>;
|
|
286
286
|
/**
|
|
287
287
|
* Get list of all available liquidity pools
|
|
288
288
|
* @returns Array of pool information
|
|
@@ -303,11 +303,13 @@ declare class ReeClient {
|
|
|
303
303
|
* @param params.involvedRuneId - Optional rune ID for rune swaps
|
|
304
304
|
* @returns Transaction instance
|
|
305
305
|
*/
|
|
306
|
-
createTransaction({ address, paymentAddress, feeRate, mergeSelfRuneBtcOutputs, }: {
|
|
306
|
+
createTransaction({ address, paymentAddress, publicKey, feeRate, mergeSelfRuneBtcOutputs, clientInfo, }: {
|
|
307
307
|
address: string;
|
|
308
308
|
paymentAddress: string;
|
|
309
|
+
publicKey?: string;
|
|
309
310
|
feeRate?: number;
|
|
310
311
|
mergeSelfRuneBtcOutputs?: boolean;
|
|
312
|
+
clientInfo?: string;
|
|
311
313
|
}): Promise<Transaction>;
|
|
312
314
|
getRecommendedFeeRate(): Promise<{
|
|
313
315
|
min: number;
|
|
@@ -320,13 +322,17 @@ declare interface ReeContextValue {
|
|
|
320
322
|
exchange: ActorSubclass;
|
|
321
323
|
address: string;
|
|
322
324
|
paymentAddress: string;
|
|
325
|
+
publicKey: string;
|
|
323
326
|
updateWallet: (wallet: {
|
|
324
327
|
address?: string;
|
|
325
328
|
paymentAddress?: string;
|
|
329
|
+
publicKey?: string;
|
|
330
|
+
paymentPublicKey?: string;
|
|
326
331
|
}) => void;
|
|
327
332
|
createTransaction: (params?: {
|
|
328
333
|
feeRate?: number;
|
|
329
334
|
mergeSelfRuneBtcOutputs?: boolean;
|
|
335
|
+
clientInfo?: string;
|
|
330
336
|
}) => Promise<Transaction>;
|
|
331
337
|
}
|
|
332
338
|
|
|
@@ -542,6 +548,7 @@ declare interface TransactionConfig {
|
|
|
542
548
|
exchangeId: string;
|
|
543
549
|
address: string;
|
|
544
550
|
paymentAddress: string;
|
|
551
|
+
publicKey?: string;
|
|
545
552
|
clientInfo?: string;
|
|
546
553
|
/** Optional manual fee rate in satoshis per virtual byte */
|
|
547
554
|
feeRate?: number;
|
|
@@ -686,6 +693,7 @@ export declare type Utxo = {
|
|
|
686
693
|
}[];
|
|
687
694
|
address: string;
|
|
688
695
|
scriptPk: string;
|
|
696
|
+
pubkey?: string;
|
|
689
697
|
};
|
|
690
698
|
|
|
691
699
|
export { }
|
package/dist/react.es.js
CHANGED
|
@@ -1,198 +1,204 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { ReeClient as
|
|
4
|
-
import { Network as
|
|
5
|
-
const
|
|
6
|
-
function U({ children: e, config:
|
|
7
|
-
if (!
|
|
1
|
+
import { jsx as E } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as p, useState as i, useCallback as g, useMemo as v, useContext as I, useEffect as R } from "react";
|
|
3
|
+
import { ReeClient as P } from "./index.es.js";
|
|
4
|
+
import { Network as X, utils as j } from "./index.es.js";
|
|
5
|
+
const x = p(null);
|
|
6
|
+
function U({ children: e, config: r }) {
|
|
7
|
+
if (!r)
|
|
8
8
|
throw new Error("ReeProvider: config is required");
|
|
9
|
-
if (!
|
|
9
|
+
if (!r.network)
|
|
10
10
|
throw new Error("ReeProvider: config.network is required");
|
|
11
|
-
if (!
|
|
11
|
+
if (!r.maestroApiKey)
|
|
12
12
|
throw new Error("ReeProvider: config.maestroApiKey is required");
|
|
13
|
-
if (!
|
|
13
|
+
if (!r.exchangeIdlFactory)
|
|
14
14
|
throw new Error("ReeProvider: config.exchangeIdlFactory is required");
|
|
15
|
-
if (!
|
|
15
|
+
if (!r.exchangeCanisterId)
|
|
16
16
|
throw new Error("ReeProvider: config.exchangeCanisterId is required");
|
|
17
|
-
const [
|
|
17
|
+
const [n, a] = i({
|
|
18
18
|
address: "",
|
|
19
19
|
paymentAddress: "",
|
|
20
20
|
publicKey: "",
|
|
21
21
|
paymentPublicKey: ""
|
|
22
|
-
}), s = g((
|
|
23
|
-
a((
|
|
24
|
-
}, []), t =
|
|
25
|
-
async (
|
|
22
|
+
}), s = g((o) => {
|
|
23
|
+
a((d) => ({ ...d, ...o }));
|
|
24
|
+
}, []), t = v(() => new P(r), [r]), f = g(
|
|
25
|
+
async (o) => {
|
|
26
26
|
if (!t) throw new Error("Client not available");
|
|
27
|
-
if (!
|
|
27
|
+
if (!n.address || !n.paymentAddress)
|
|
28
28
|
throw new Error("Wallet not connected");
|
|
29
29
|
return t.createTransaction({
|
|
30
|
-
address:
|
|
31
|
-
paymentAddress:
|
|
32
|
-
feeRate:
|
|
33
|
-
|
|
30
|
+
address: n.address,
|
|
31
|
+
paymentAddress: n.paymentAddress,
|
|
32
|
+
feeRate: o?.feeRate,
|
|
33
|
+
publicKey: n.publicKey,
|
|
34
|
+
mergeSelfRuneBtcOutputs: o?.mergeSelfRuneBtcOutputs,
|
|
35
|
+
clientInfo: o?.clientInfo
|
|
34
36
|
});
|
|
35
37
|
},
|
|
36
|
-
[t,
|
|
37
|
-
),
|
|
38
|
+
[t, n]
|
|
39
|
+
), c = v(
|
|
38
40
|
() => ({
|
|
39
41
|
client: t,
|
|
40
|
-
...
|
|
42
|
+
...n,
|
|
41
43
|
exchange: t.exchange,
|
|
42
44
|
updateWallet: s,
|
|
43
|
-
createTransaction:
|
|
45
|
+
createTransaction: f
|
|
44
46
|
}),
|
|
45
|
-
[t,
|
|
47
|
+
[t, n, s, f]
|
|
46
48
|
);
|
|
47
|
-
return /* @__PURE__ */ x
|
|
49
|
+
return /* @__PURE__ */ E(x.Provider, { value: c, children: e });
|
|
48
50
|
}
|
|
49
51
|
function m() {
|
|
50
|
-
const e =
|
|
52
|
+
const e = I(x);
|
|
51
53
|
if (!e)
|
|
52
54
|
throw new Error("useRee must be used within ReeProvider");
|
|
53
55
|
return e;
|
|
54
56
|
}
|
|
55
|
-
function
|
|
56
|
-
const { refreshInterval:
|
|
57
|
+
function L(e = {}) {
|
|
58
|
+
const { refreshInterval: r = 0, autoRefresh: n = !0 } = e, { client: a, paymentAddress: s } = m(), [t, f] = i(null), [c, o] = i(!1), [d, h] = i(null), l = g(async () => {
|
|
57
59
|
if (!s) {
|
|
58
|
-
|
|
60
|
+
f(null), h("Payment address not set");
|
|
59
61
|
return;
|
|
60
62
|
}
|
|
61
|
-
|
|
63
|
+
o(!0), h(null);
|
|
62
64
|
try {
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
} catch (
|
|
65
|
+
const u = await a.getBtcBalance(s);
|
|
66
|
+
f(u);
|
|
67
|
+
} catch (u) {
|
|
66
68
|
h(
|
|
67
|
-
|
|
68
|
-
),
|
|
69
|
+
u instanceof Error ? u.message : "Failed to fetch BTC balance"
|
|
70
|
+
), f(null);
|
|
69
71
|
} finally {
|
|
70
|
-
|
|
72
|
+
o(!1);
|
|
71
73
|
}
|
|
72
74
|
}, [a, s]);
|
|
73
|
-
return
|
|
74
|
-
|
|
75
|
-
}, [s,
|
|
76
|
-
if (
|
|
77
|
-
const
|
|
78
|
-
return () => clearInterval(
|
|
75
|
+
return R(() => {
|
|
76
|
+
n && l();
|
|
77
|
+
}, [s, l, n]), R(() => {
|
|
78
|
+
if (r > 0) {
|
|
79
|
+
const u = setInterval(l, r);
|
|
80
|
+
return () => clearInterval(u);
|
|
79
81
|
}
|
|
80
|
-
}, [
|
|
82
|
+
}, [r, s, l]), {
|
|
81
83
|
balance: t,
|
|
82
|
-
loading:
|
|
83
|
-
error:
|
|
84
|
-
refetch:
|
|
84
|
+
loading: c,
|
|
85
|
+
error: d,
|
|
86
|
+
refetch: l
|
|
85
87
|
};
|
|
86
88
|
}
|
|
87
|
-
function
|
|
88
|
-
const { refreshInterval:
|
|
89
|
+
function q(e, r = {}) {
|
|
90
|
+
const { refreshInterval: n = 0, autoRefresh: a = !0 } = r, { client: s, address: t, publicKey: f } = m(), [c, o] = i(null), [d, h] = i(!1), [l, u] = i(null), y = g(async () => {
|
|
89
91
|
if (!t) {
|
|
90
|
-
o(null),
|
|
92
|
+
o(null), u("Address not set");
|
|
91
93
|
return;
|
|
92
94
|
}
|
|
93
95
|
if (!e) {
|
|
94
|
-
o(null),
|
|
96
|
+
o(null), u("Rune ID is required");
|
|
95
97
|
return;
|
|
96
98
|
}
|
|
97
|
-
|
|
99
|
+
h(!0), u(null);
|
|
98
100
|
try {
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
const w = await s.getRuneBalance(
|
|
102
|
+
t,
|
|
103
|
+
e,
|
|
104
|
+
f
|
|
105
|
+
);
|
|
106
|
+
o(w ?? null);
|
|
107
|
+
} catch (w) {
|
|
108
|
+
u(
|
|
109
|
+
w instanceof Error ? w.message : "Failed to fetch rune balance"
|
|
104
110
|
), o(null);
|
|
105
111
|
} finally {
|
|
106
|
-
|
|
112
|
+
h(!1);
|
|
107
113
|
}
|
|
108
114
|
}, [s, t, e]);
|
|
109
|
-
return
|
|
110
|
-
a && e &&
|
|
111
|
-
}, [t, e,
|
|
112
|
-
if (
|
|
113
|
-
const
|
|
114
|
-
return () => clearInterval(
|
|
115
|
+
return R(() => {
|
|
116
|
+
a && e && y();
|
|
117
|
+
}, [t, e, y, a]), R(() => {
|
|
118
|
+
if (n > 0 && e) {
|
|
119
|
+
const w = setInterval(y, n);
|
|
120
|
+
return () => clearInterval(w);
|
|
115
121
|
}
|
|
116
|
-
}, [
|
|
117
|
-
balance:
|
|
118
|
-
loading:
|
|
119
|
-
error:
|
|
120
|
-
refetch:
|
|
122
|
+
}, [n, t, e, y]), {
|
|
123
|
+
balance: c,
|
|
124
|
+
loading: d,
|
|
125
|
+
error: l,
|
|
126
|
+
refetch: y
|
|
121
127
|
};
|
|
122
128
|
}
|
|
123
|
-
function
|
|
124
|
-
const { refreshInterval:
|
|
129
|
+
function C(e = {}) {
|
|
130
|
+
const { refreshInterval: r = 0, autoRefresh: n = !0 } = e, { client: a, paymentAddress: s } = m(), [t, f] = i([]), [c, o] = i(!1), [d, h] = i(null), l = g(async () => {
|
|
125
131
|
if (!s) {
|
|
126
|
-
|
|
132
|
+
f([]), h("Payment address not set");
|
|
127
133
|
return;
|
|
128
134
|
}
|
|
129
|
-
|
|
135
|
+
o(!0), h(null);
|
|
130
136
|
try {
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
} catch (
|
|
137
|
+
const u = await a.getBtcUtxos(s);
|
|
138
|
+
f(u);
|
|
139
|
+
} catch (u) {
|
|
134
140
|
h(
|
|
135
|
-
|
|
136
|
-
),
|
|
141
|
+
u instanceof Error ? u.message : "Failed to fetch BTC UTXOs"
|
|
142
|
+
), f([]);
|
|
137
143
|
} finally {
|
|
138
|
-
|
|
144
|
+
o(!1);
|
|
139
145
|
}
|
|
140
146
|
}, [a, s]);
|
|
141
|
-
return
|
|
142
|
-
|
|
143
|
-
}, [s,
|
|
144
|
-
if (
|
|
145
|
-
const
|
|
146
|
-
return () => clearInterval(
|
|
147
|
+
return R(() => {
|
|
148
|
+
n && s && l();
|
|
149
|
+
}, [s, l, n]), R(() => {
|
|
150
|
+
if (r > 0 && s) {
|
|
151
|
+
const u = setInterval(l, r);
|
|
152
|
+
return () => clearInterval(u);
|
|
147
153
|
}
|
|
148
|
-
}, [
|
|
154
|
+
}, [r, s, l]), {
|
|
149
155
|
utxos: t,
|
|
150
|
-
loading:
|
|
151
|
-
error:
|
|
152
|
-
refetch:
|
|
156
|
+
loading: c,
|
|
157
|
+
error: d,
|
|
158
|
+
refetch: l
|
|
153
159
|
};
|
|
154
160
|
}
|
|
155
|
-
function
|
|
156
|
-
const { refreshInterval:
|
|
161
|
+
function A(e, r = {}) {
|
|
162
|
+
const { refreshInterval: n = 0, autoRefresh: a = !0 } = r, { client: s, address: t } = m(), [f, c] = i([]), [o, d] = i(!1), [h, l] = i(null), u = g(async () => {
|
|
157
163
|
if (!t) {
|
|
158
|
-
|
|
164
|
+
c([]), l("Address not set");
|
|
159
165
|
return;
|
|
160
166
|
}
|
|
161
167
|
if (!e) {
|
|
162
|
-
|
|
168
|
+
c([]), l("Rune ID is required");
|
|
163
169
|
return;
|
|
164
170
|
}
|
|
165
|
-
|
|
171
|
+
d(!0), l(null);
|
|
166
172
|
try {
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
} catch (
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
),
|
|
173
|
+
const y = await s.getRuneUtxos(t, e);
|
|
174
|
+
c(y);
|
|
175
|
+
} catch (y) {
|
|
176
|
+
l(
|
|
177
|
+
y instanceof Error ? y.message : "Failed to fetch rune UTXOs"
|
|
178
|
+
), c([]);
|
|
173
179
|
} finally {
|
|
174
|
-
|
|
180
|
+
d(!1);
|
|
175
181
|
}
|
|
176
182
|
}, [s, t, e]);
|
|
177
|
-
return
|
|
178
|
-
a && t && e &&
|
|
179
|
-
}, [t, e,
|
|
180
|
-
if (
|
|
181
|
-
const
|
|
182
|
-
return () => clearInterval(
|
|
183
|
+
return R(() => {
|
|
184
|
+
a && t && e && u();
|
|
185
|
+
}, [t, e, u, a]), R(() => {
|
|
186
|
+
if (n > 0 && t && e) {
|
|
187
|
+
const y = setInterval(u, n);
|
|
188
|
+
return () => clearInterval(y);
|
|
183
189
|
}
|
|
184
|
-
}, [
|
|
185
|
-
utxos:
|
|
186
|
-
loading:
|
|
190
|
+
}, [n, t, e, u]), {
|
|
191
|
+
utxos: f,
|
|
192
|
+
loading: o,
|
|
187
193
|
error: h,
|
|
188
|
-
refetch:
|
|
194
|
+
refetch: u
|
|
189
195
|
};
|
|
190
196
|
}
|
|
191
|
-
function
|
|
197
|
+
function K() {
|
|
192
198
|
const { client: e } = m();
|
|
193
199
|
return g(
|
|
194
|
-
async (
|
|
195
|
-
const a =
|
|
200
|
+
async (n) => {
|
|
201
|
+
const a = n;
|
|
196
202
|
if (!a)
|
|
197
203
|
throw new Error("Search keyword is required");
|
|
198
204
|
return await e.searchRunes(a);
|
|
@@ -201,122 +207,122 @@ function A() {
|
|
|
201
207
|
);
|
|
202
208
|
}
|
|
203
209
|
function T(e) {
|
|
204
|
-
const { client:
|
|
210
|
+
const { client: r } = m(), [n, a] = i(null), [s, t] = i(!1), [f, c] = i(null), o = g(async () => {
|
|
205
211
|
if (!e) {
|
|
206
|
-
a(null),
|
|
212
|
+
a(null), c("Rune ID is required");
|
|
207
213
|
return;
|
|
208
214
|
}
|
|
209
|
-
t(!0),
|
|
215
|
+
t(!0), c(null);
|
|
210
216
|
try {
|
|
211
|
-
const
|
|
212
|
-
a(
|
|
213
|
-
} catch (
|
|
214
|
-
|
|
215
|
-
|
|
217
|
+
const d = await r.getRuneInfo(e);
|
|
218
|
+
a(d || null);
|
|
219
|
+
} catch (d) {
|
|
220
|
+
c(
|
|
221
|
+
d instanceof Error ? d.message : "Failed to fetch rune info"
|
|
216
222
|
), a(null);
|
|
217
223
|
} finally {
|
|
218
224
|
t(!1);
|
|
219
225
|
}
|
|
220
|
-
}, [
|
|
226
|
+
}, [r, e]);
|
|
221
227
|
return {
|
|
222
|
-
runeInfo:
|
|
228
|
+
runeInfo: n,
|
|
223
229
|
loading: s,
|
|
224
|
-
error:
|
|
225
|
-
refetch:
|
|
230
|
+
error: f,
|
|
231
|
+
refetch: o
|
|
226
232
|
};
|
|
227
233
|
}
|
|
228
234
|
function k() {
|
|
229
|
-
const { client: e } = m(), [
|
|
230
|
-
s(!0),
|
|
235
|
+
const { client: e } = m(), [r, n] = i([]), [a, s] = i(!1), [t, f] = i(null), c = g(async () => {
|
|
236
|
+
s(!0), f(null);
|
|
231
237
|
try {
|
|
232
|
-
const
|
|
233
|
-
|
|
234
|
-
} catch (
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
),
|
|
238
|
+
const o = await e.getPoolList();
|
|
239
|
+
n(o);
|
|
240
|
+
} catch (o) {
|
|
241
|
+
f(
|
|
242
|
+
o instanceof Error ? o.message : "Failed to fetch pool list"
|
|
243
|
+
), n([]);
|
|
238
244
|
} finally {
|
|
239
245
|
s(!1);
|
|
240
246
|
}
|
|
241
247
|
}, [e]);
|
|
242
|
-
return
|
|
243
|
-
|
|
244
|
-
}, [
|
|
245
|
-
pools:
|
|
248
|
+
return R(() => {
|
|
249
|
+
c();
|
|
250
|
+
}, [c]), {
|
|
251
|
+
pools: r,
|
|
246
252
|
loading: a,
|
|
247
253
|
error: t,
|
|
248
|
-
refetch:
|
|
254
|
+
refetch: c
|
|
249
255
|
};
|
|
250
256
|
}
|
|
251
257
|
function S(e) {
|
|
252
|
-
const { client:
|
|
258
|
+
const { client: r } = m(), [n, a] = i(null), [s, t] = i(!1), [f, c] = i(null), o = g(async () => {
|
|
253
259
|
if (!e) {
|
|
254
|
-
a(null),
|
|
260
|
+
a(null), c("Pool address is required");
|
|
255
261
|
return;
|
|
256
262
|
}
|
|
257
|
-
t(!0),
|
|
263
|
+
t(!0), c(null);
|
|
258
264
|
try {
|
|
259
|
-
const
|
|
260
|
-
a(
|
|
261
|
-
} catch (
|
|
262
|
-
|
|
263
|
-
|
|
265
|
+
const d = await r.getPoolInfo(e);
|
|
266
|
+
a(d);
|
|
267
|
+
} catch (d) {
|
|
268
|
+
c(
|
|
269
|
+
d instanceof Error ? d.message : "Failed to fetch pool info"
|
|
264
270
|
), a(null);
|
|
265
271
|
} finally {
|
|
266
272
|
t(!1);
|
|
267
273
|
}
|
|
268
|
-
}, [
|
|
269
|
-
return
|
|
270
|
-
|
|
274
|
+
}, [r, e]);
|
|
275
|
+
return R(() => {
|
|
276
|
+
o();
|
|
271
277
|
}, [e]), {
|
|
272
|
-
poolInfo:
|
|
278
|
+
poolInfo: n,
|
|
273
279
|
loading: s,
|
|
274
|
-
error:
|
|
275
|
-
refetch:
|
|
280
|
+
error: f,
|
|
281
|
+
refetch: o
|
|
276
282
|
};
|
|
277
283
|
}
|
|
278
|
-
function
|
|
279
|
-
const { refreshInterval:
|
|
284
|
+
function O(e = {}) {
|
|
285
|
+
const { refreshInterval: r = 0, autoRefresh: n = !0 } = e, { client: a } = m(), [s, t] = i(
|
|
280
286
|
null
|
|
281
|
-
), [
|
|
282
|
-
|
|
287
|
+
), [f, c] = i(!1), [o, d] = i(null), h = g(async () => {
|
|
288
|
+
c(!0), d(null);
|
|
283
289
|
try {
|
|
284
|
-
const
|
|
285
|
-
t(
|
|
286
|
-
} catch (
|
|
287
|
-
|
|
288
|
-
|
|
290
|
+
const l = await a.getRecommendedFeeRate();
|
|
291
|
+
t(l);
|
|
292
|
+
} catch (l) {
|
|
293
|
+
d(
|
|
294
|
+
l instanceof Error ? l.message : "Failed to fetch recommended fee rate"
|
|
289
295
|
), t(null);
|
|
290
296
|
} finally {
|
|
291
|
-
|
|
297
|
+
c(!1);
|
|
292
298
|
}
|
|
293
299
|
}, [a]);
|
|
294
|
-
return
|
|
295
|
-
|
|
296
|
-
}, [
|
|
297
|
-
if (
|
|
298
|
-
const
|
|
299
|
-
return () => clearInterval(
|
|
300
|
+
return R(() => {
|
|
301
|
+
n && h();
|
|
302
|
+
}, [n, h]), R(() => {
|
|
303
|
+
if (r > 0) {
|
|
304
|
+
const l = setInterval(h, r);
|
|
305
|
+
return () => clearInterval(l);
|
|
300
306
|
}
|
|
301
|
-
}, [
|
|
307
|
+
}, [r, h]), {
|
|
302
308
|
feeRate: s,
|
|
303
|
-
loading:
|
|
304
|
-
error:
|
|
309
|
+
loading: f,
|
|
310
|
+
error: o,
|
|
305
311
|
refetch: h
|
|
306
312
|
};
|
|
307
313
|
}
|
|
308
314
|
export {
|
|
309
|
-
|
|
315
|
+
X as Network,
|
|
310
316
|
U as ReeProvider,
|
|
311
|
-
|
|
312
|
-
|
|
317
|
+
L as useBtcBalance,
|
|
318
|
+
C as useBtcUtxos,
|
|
313
319
|
S as usePoolInfo,
|
|
314
320
|
k as usePoolList,
|
|
315
|
-
|
|
321
|
+
O as useRecommendedFeeRate,
|
|
316
322
|
m as useRee,
|
|
317
|
-
|
|
323
|
+
q as useRuneBalance,
|
|
318
324
|
T as useRuneInfo,
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
325
|
+
A as useRuneUtxos,
|
|
326
|
+
K as useSearchRunes,
|
|
327
|
+
j as utils
|
|
322
328
|
};
|