@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/dist/react.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react/jsx-runtime"),e=require("react"),g=require("./index.cjs.js"),E=e.createContext(null);function w({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(u=>{c(f=>({...f,...u}))},[]),n=e.useMemo(()=>new g.ReeClient(s),[s]),d=e.useCallback(async u=>{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:u?.feeRate,mergeSelfRuneBtcOutputs:u?.mergeSelfRuneBtcOutputs})},[n,r]),o=e.useMemo(()=>({client:n,...r,exchange:n.exchange,updateWallet:a,createTransaction:d}),[n,r,a,d]);return m.jsx(E.Provider,{value:o,children:t})}function y(){const t=e.useContext(E);if(!t)throw new Error("useRee must be used within ReeProvider");return t}function v(t={}){const{refreshInterval:s=0,autoRefresh:r=!0}=t,{client:c,paymentAddress:a}=y(),[n,d]=e.useState(null),[o,u]=e.useState(!1),[f,h]=e.useState(null),l=e.useCallback(async()=>{if(!a){d(null),h("Payment address not set");return}u(!0),h(null);try{const i=await c.getBtcBalance(a);d(i)}catch(i){h(i instanceof Error?i.message:"Failed to fetch BTC balance"),d(null)}finally{u(!1)}},[c,a]);return e.useEffect(()=>{r&&l()},[a,l,r]),e.useEffect(()=>{if(s>0){const i=setInterval(l,s);return()=>clearInterval(i)}},[s,a,l]),{balance:n,loading:o,error:f,refetch:l}}function S(t,s={}){const{refreshInterval:r=0,autoRefresh:c=!0}=s,{client:a,address:n}=y(),[d,o]=e.useState(null),[u,f]=e.useState(!1),[h,l]=e.useState(null),i=e.useCallback(async()=>{if(!n){o(null),l("Address not set");return}if(!t){o(null),l("Rune ID is required");return}f(!0),l(null);try{const R=await a.getRuneBalance(n,t);o(R??null)}catch(R){l(R instanceof Error?R.message:"Failed to fetch rune balance"),o(null)}finally{f(!1)}},[a,n,t]);return e.useEffect(()=>{c&&t&&i()},[n,t,i,c]),e.useEffect(()=>{if(r>0&&t){const R=setInterval(i,r);return()=>clearInterval(R)}},[r,n,t,i]),{balance:d,loading:u,error:h,refetch:i}}function x(t={}){const{refreshInterval:s=0,autoRefresh:r=!0}=t,{client:c,paymentAddress:a}=y(),[n,d]=e.useState([]),[o,u]=e.useState(!1),[f,h]=e.useState(null),l=e.useCallback(async()=>{if(!a){d([]),h("Payment address not set");return}u(!0),h(null);try{const i=await c.getBtcUtxos(a);d(i)}catch(i){h(i instanceof Error?i.message:"Failed to fetch BTC UTXOs"),d([])}finally{u(!1)}},[c,a]);return e.useEffect(()=>{r&&a&&l()},[a,l,r]),e.useEffect(()=>{if(s>0&&a){const i=setInterval(l,s);return()=>clearInterval(i)}},[s,a,l]),{utxos:n,loading:o,error:f,refetch:l}}function P(t,s={}){const{refreshInterval:r=0,autoRefresh:c=!0}=s,{client:a,address:n}=y(),[d,o]=e.useState([]),[u,f]=e.useState(!1),[h,l]=e.useState(null),i=e.useCallback(async()=>{if(!n){o([]),l("Address not set");return}if(!t){o([]),l("Rune ID is required");return}f(!0),l(null);try{const R=await a.getRuneUtxos(n,t);o(R)}catch(R){l(R instanceof Error?R.message:"Failed to fetch rune UTXOs"),o([])}finally{f(!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:d,loading:u,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 B(t){const{client:s}=y(),[r,c]=e.useState(null),[a,n]=e.useState(!1),[d,o]=e.useState(null),u=e.useCallback(async()=>{if(!t){c(null),o("Rune ID is required");return}n(!0),o(null);try{const f=await s.getRuneInfo(t);c(f||null)}catch(f){o(f instanceof Error?f.message:"Failed to fetch rune info"),c(null)}finally{n(!1)}},[s,t]);return{runeInfo:r,loading:a,error:d,refetch:u}}function C(){const{client:t}=y(),[s,r]=e.useState([]),[c,a]=e.useState(!1),[n,d]=e.useState(null),o=e.useCallback(async()=>{a(!0),d(null);try{const u=await t.getPoolList();r(u)}catch(u){d(u instanceof Error?u.message:"Failed to fetch pool list"),r([])}finally{a(!1)}},[t]);return e.useEffect(()=>{o()},[o]),{pools:s,loading:c,error:n,refetch:o}}function I(t){const{client:s}=y(),[r,c]=e.useState(null),[a,n]=e.useState(!1),[d,o]=e.useState(null),u=e.useCallback(async()=>{if(!t){c(null),o("Pool address is required");return}n(!0),o(null);try{const f=await s.getPoolInfo(t);c(f)}catch(f){o(f instanceof Error?f.message:"Failed to fetch pool info"),c(null)}finally{n(!1)}},[s,t]);return e.useEffect(()=>{u()},[t]),{poolInfo:r,loading:a,error:d,refetch:u}}function k(t={}){const{refreshInterval:s=0,autoRefresh:r=!0}=t,{client:c}=y(),[a,n]=e.useState(null),[d,o]=e.useState(!1),[u,f]=e.useState(null),h=e.useCallback(async()=>{o(!0),f(null);try{const l=await c.getRecommendedFeeRate();n(l)}catch(l){f(l instanceof Error?l.message:"Failed to fetch recommended fee rate"),n(null)}finally{o(!1)}},[c]);return e.useEffect(()=>{r&&h()},[r,h]),e.useEffect(()=>{if(s>0){const l=setInterval(h,s);return()=>clearInterval(l)}},[s,h]),{feeRate:a,loading:d,error:u,refetch:h}}exports.Network=g.Network;exports.utils=g.utils;exports.ReeProvider=w;exports.useBtcBalance=v;exports.useBtcUtxos=x;exports.usePoolInfo=I;exports.usePoolList=C;exports.useRecommendedFeeRate=k;exports.useRee=y;exports.useRuneBalance=S;exports.useRuneInfo=B;exports.useRuneUtxos=P;exports.useSearchRunes=b;
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 x } from "react/jsx-runtime";
2
- import { createContext as E, useState as u, useCallback as g, useMemo as w, useContext as P, useEffect as y } from "react";
3
- import { ReeClient as p } from "./index.es.js";
4
- import { Network as W, utils as X } from "./index.es.js";
5
- const v = E(null);
6
- function U({ children: e, config: n }) {
7
- if (!n)
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 (!n.network)
9
+ if (!r.network)
10
10
  throw new Error("ReeProvider: config.network is required");
11
- if (!n.maestroApiKey)
11
+ if (!r.maestroApiKey)
12
12
  throw new Error("ReeProvider: config.maestroApiKey is required");
13
- if (!n.exchangeIdlFactory)
13
+ if (!r.exchangeIdlFactory)
14
14
  throw new Error("ReeProvider: config.exchangeIdlFactory is required");
15
- if (!n.exchangeCanisterId)
15
+ if (!r.exchangeCanisterId)
16
16
  throw new Error("ReeProvider: config.exchangeCanisterId is required");
17
- const [r, a] = u({
17
+ const [n, a] = i({
18
18
  address: "",
19
19
  paymentAddress: "",
20
20
  publicKey: "",
21
21
  paymentPublicKey: ""
22
- }), s = g((l) => {
23
- a((f) => ({ ...f, ...l }));
24
- }, []), t = w(() => new p(n), [n]), d = g(
25
- async (l) => {
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 (!r.address || !r.paymentAddress)
27
+ if (!n.address || !n.paymentAddress)
28
28
  throw new Error("Wallet not connected");
29
29
  return t.createTransaction({
30
- address: r.address,
31
- paymentAddress: r.paymentAddress,
32
- feeRate: l?.feeRate,
33
- mergeSelfRuneBtcOutputs: l?.mergeSelfRuneBtcOutputs
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, r]
37
- ), o = w(
38
+ [t, n]
39
+ ), c = v(
38
40
  () => ({
39
41
  client: t,
40
- ...r,
42
+ ...n,
41
43
  exchange: t.exchange,
42
44
  updateWallet: s,
43
- createTransaction: d
45
+ createTransaction: f
44
46
  }),
45
- [t, r, s, d]
47
+ [t, n, s, f]
46
48
  );
47
- return /* @__PURE__ */ x(v.Provider, { value: o, children: e });
49
+ return /* @__PURE__ */ E(x.Provider, { value: c, children: e });
48
50
  }
49
51
  function m() {
50
- const e = P(v);
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 b(e = {}) {
56
- const { refreshInterval: n = 0, autoRefresh: r = !0 } = e, { client: a, paymentAddress: s } = m(), [t, d] = u(null), [o, l] = u(!1), [f, h] = u(null), c = g(async () => {
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
- d(null), h("Payment address not set");
60
+ f(null), h("Payment address not set");
59
61
  return;
60
62
  }
61
- l(!0), h(null);
63
+ o(!0), h(null);
62
64
  try {
63
- const i = await a.getBtcBalance(s);
64
- d(i);
65
- } catch (i) {
65
+ const u = await a.getBtcBalance(s);
66
+ f(u);
67
+ } catch (u) {
66
68
  h(
67
- i instanceof Error ? i.message : "Failed to fetch BTC balance"
68
- ), d(null);
69
+ u instanceof Error ? u.message : "Failed to fetch BTC balance"
70
+ ), f(null);
69
71
  } finally {
70
- l(!1);
72
+ o(!1);
71
73
  }
72
74
  }, [a, s]);
73
- return y(() => {
74
- r && c();
75
- }, [s, c, r]), y(() => {
76
- if (n > 0) {
77
- const i = setInterval(c, n);
78
- return () => clearInterval(i);
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
- }, [n, s, c]), {
82
+ }, [r, s, l]), {
81
83
  balance: t,
82
- loading: o,
83
- error: f,
84
- refetch: c
84
+ loading: c,
85
+ error: d,
86
+ refetch: l
85
87
  };
86
88
  }
87
- function L(e, n = {}) {
88
- const { refreshInterval: r = 0, autoRefresh: a = !0 } = n, { client: s, address: t } = m(), [d, o] = u(null), [l, f] = u(!1), [h, c] = u(null), i = g(async () => {
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), c("Address not set");
92
+ o(null), u("Address not set");
91
93
  return;
92
94
  }
93
95
  if (!e) {
94
- o(null), c("Rune ID is required");
96
+ o(null), u("Rune ID is required");
95
97
  return;
96
98
  }
97
- f(!0), c(null);
99
+ h(!0), u(null);
98
100
  try {
99
- const R = await s.getRuneBalance(t, e);
100
- o(R ?? null);
101
- } catch (R) {
102
- c(
103
- R instanceof Error ? R.message : "Failed to fetch rune balance"
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
- f(!1);
112
+ h(!1);
107
113
  }
108
114
  }, [s, t, e]);
109
- return y(() => {
110
- a && e && i();
111
- }, [t, e, i, a]), y(() => {
112
- if (r > 0 && e) {
113
- const R = setInterval(i, r);
114
- return () => clearInterval(R);
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
- }, [r, t, e, i]), {
117
- balance: d,
118
- loading: l,
119
- error: h,
120
- refetch: i
122
+ }, [n, t, e, y]), {
123
+ balance: c,
124
+ loading: d,
125
+ error: l,
126
+ refetch: y
121
127
  };
122
128
  }
123
- function q(e = {}) {
124
- const { refreshInterval: n = 0, autoRefresh: r = !0 } = e, { client: a, paymentAddress: s } = m(), [t, d] = u([]), [o, l] = u(!1), [f, h] = u(null), c = g(async () => {
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
- d([]), h("Payment address not set");
132
+ f([]), h("Payment address not set");
127
133
  return;
128
134
  }
129
- l(!0), h(null);
135
+ o(!0), h(null);
130
136
  try {
131
- const i = await a.getBtcUtxos(s);
132
- d(i);
133
- } catch (i) {
137
+ const u = await a.getBtcUtxos(s);
138
+ f(u);
139
+ } catch (u) {
134
140
  h(
135
- i instanceof Error ? i.message : "Failed to fetch BTC UTXOs"
136
- ), d([]);
141
+ u instanceof Error ? u.message : "Failed to fetch BTC UTXOs"
142
+ ), f([]);
137
143
  } finally {
138
- l(!1);
144
+ o(!1);
139
145
  }
140
146
  }, [a, s]);
141
- return y(() => {
142
- r && s && c();
143
- }, [s, c, r]), y(() => {
144
- if (n > 0 && s) {
145
- const i = setInterval(c, n);
146
- return () => clearInterval(i);
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
- }, [n, s, c]), {
154
+ }, [r, s, l]), {
149
155
  utxos: t,
150
- loading: o,
151
- error: f,
152
- refetch: c
156
+ loading: c,
157
+ error: d,
158
+ refetch: l
153
159
  };
154
160
  }
155
- function C(e, n = {}) {
156
- const { refreshInterval: r = 0, autoRefresh: a = !0 } = n, { client: s, address: t } = m(), [d, o] = u([]), [l, f] = u(!1), [h, c] = u(null), i = g(async () => {
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
- o([]), c("Address not set");
164
+ c([]), l("Address not set");
159
165
  return;
160
166
  }
161
167
  if (!e) {
162
- o([]), c("Rune ID is required");
168
+ c([]), l("Rune ID is required");
163
169
  return;
164
170
  }
165
- f(!0), c(null);
171
+ d(!0), l(null);
166
172
  try {
167
- const R = await s.getRuneUtxos(t, e);
168
- o(R);
169
- } catch (R) {
170
- c(
171
- R instanceof Error ? R.message : "Failed to fetch rune UTXOs"
172
- ), o([]);
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
- f(!1);
180
+ d(!1);
175
181
  }
176
182
  }, [s, t, e]);
177
- return y(() => {
178
- a && t && e && i();
179
- }, [t, e, i, a]), y(() => {
180
- if (r > 0 && t && e) {
181
- const R = setInterval(i, r);
182
- return () => clearInterval(R);
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
- }, [r, t, e, i]), {
185
- utxos: d,
186
- loading: l,
190
+ }, [n, t, e, u]), {
191
+ utxos: f,
192
+ loading: o,
187
193
  error: h,
188
- refetch: i
194
+ refetch: u
189
195
  };
190
196
  }
191
- function A() {
197
+ function K() {
192
198
  const { client: e } = m();
193
199
  return g(
194
- async (r) => {
195
- const a = r;
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: n } = m(), [r, a] = u(null), [s, t] = u(!1), [d, o] = u(null), l = g(async () => {
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), o("Rune ID is required");
212
+ a(null), c("Rune ID is required");
207
213
  return;
208
214
  }
209
- t(!0), o(null);
215
+ t(!0), c(null);
210
216
  try {
211
- const f = await n.getRuneInfo(e);
212
- a(f || null);
213
- } catch (f) {
214
- o(
215
- f instanceof Error ? f.message : "Failed to fetch rune info"
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
- }, [n, e]);
226
+ }, [r, e]);
221
227
  return {
222
- runeInfo: r,
228
+ runeInfo: n,
223
229
  loading: s,
224
- error: d,
225
- refetch: l
230
+ error: f,
231
+ refetch: o
226
232
  };
227
233
  }
228
234
  function k() {
229
- const { client: e } = m(), [n, r] = u([]), [a, s] = u(!1), [t, d] = u(null), o = g(async () => {
230
- s(!0), d(null);
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 l = await e.getPoolList();
233
- r(l);
234
- } catch (l) {
235
- d(
236
- l instanceof Error ? l.message : "Failed to fetch pool list"
237
- ), r([]);
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 y(() => {
243
- o();
244
- }, [o]), {
245
- pools: n,
248
+ return R(() => {
249
+ c();
250
+ }, [c]), {
251
+ pools: r,
246
252
  loading: a,
247
253
  error: t,
248
- refetch: o
254
+ refetch: c
249
255
  };
250
256
  }
251
257
  function S(e) {
252
- const { client: n } = m(), [r, a] = u(null), [s, t] = u(!1), [d, o] = u(null), l = g(async () => {
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), o("Pool address is required");
260
+ a(null), c("Pool address is required");
255
261
  return;
256
262
  }
257
- t(!0), o(null);
263
+ t(!0), c(null);
258
264
  try {
259
- const f = await n.getPoolInfo(e);
260
- a(f);
261
- } catch (f) {
262
- o(
263
- f instanceof Error ? f.message : "Failed to fetch pool info"
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
- }, [n, e]);
269
- return y(() => {
270
- l();
274
+ }, [r, e]);
275
+ return R(() => {
276
+ o();
271
277
  }, [e]), {
272
- poolInfo: r,
278
+ poolInfo: n,
273
279
  loading: s,
274
- error: d,
275
- refetch: l
280
+ error: f,
281
+ refetch: o
276
282
  };
277
283
  }
278
- function K(e = {}) {
279
- const { refreshInterval: n = 0, autoRefresh: r = !0 } = e, { client: a } = m(), [s, t] = u(
284
+ function O(e = {}) {
285
+ const { refreshInterval: r = 0, autoRefresh: n = !0 } = e, { client: a } = m(), [s, t] = i(
280
286
  null
281
- ), [d, o] = u(!1), [l, f] = u(null), h = g(async () => {
282
- o(!0), f(null);
287
+ ), [f, c] = i(!1), [o, d] = i(null), h = g(async () => {
288
+ c(!0), d(null);
283
289
  try {
284
- const c = await a.getRecommendedFeeRate();
285
- t(c);
286
- } catch (c) {
287
- f(
288
- c instanceof Error ? c.message : "Failed to fetch recommended fee rate"
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
- o(!1);
297
+ c(!1);
292
298
  }
293
299
  }, [a]);
294
- return y(() => {
295
- r && h();
296
- }, [r, h]), y(() => {
297
- if (n > 0) {
298
- const c = setInterval(h, n);
299
- return () => clearInterval(c);
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
- }, [n, h]), {
307
+ }, [r, h]), {
302
308
  feeRate: s,
303
- loading: d,
304
- error: l,
309
+ loading: f,
310
+ error: o,
305
311
  refetch: h
306
312
  };
307
313
  }
308
314
  export {
309
- W as Network,
315
+ X as Network,
310
316
  U as ReeProvider,
311
- b as useBtcBalance,
312
- q as useBtcUtxos,
317
+ L as useBtcBalance,
318
+ C as useBtcUtxos,
313
319
  S as usePoolInfo,
314
320
  k as usePoolList,
315
- K as useRecommendedFeeRate,
321
+ O as useRecommendedFeeRate,
316
322
  m as useRee,
317
- L as useRuneBalance,
323
+ q as useRuneBalance,
318
324
  T as useRuneInfo,
319
- C as useRuneUtxos,
320
- A as useSearchRunes,
321
- X as utils
325
+ A as useRuneUtxos,
326
+ K as useSearchRunes,
327
+ j as utils
322
328
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omnity/ree-client-ts-sdk",
3
- "version": "0.5.4",
3
+ "version": "0.5.6",
4
4
  "description": "A TypeScript SDK for interacting with the Ree protocol on Bitcoin",
5
5
  "keywords": [
6
6
  "bitcoin",