@gardenfi/orderbook 2.0.6 → 2.0.8

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 CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index2.cjs"),e=require("./index3.cjs"),o=require("./index4.cjs"),t=require("./index5.cjs");exports.Orderbook=r.Orderbook;exports.BlockchainType=e.BlockchainType;exports.Chains=e.Chains;exports.NetworkType=e.NetworkType;exports.TimeLocks=e.TimeLocks;exports.getBlockchainType=e.getBlockchainType;exports.getTimeLock=e.getTimeLock;exports.isBitcoin=e.isBitcoin;exports.isEVM=e.isEVM;exports.isMainnet=e.isMainnet;exports.OrdersProvider=o.OrdersProvider;exports.ArbitrumLocalnet=t.ArbitrumLocalnet;exports.EthereumLocalnet=t.EthereumLocalnet;exports.SupportedAssets=t.SupportedAssets;exports.WBTCArbitrumLocalnetAsset=t.WBTCArbitrumLocalnetAsset;exports.WBTCEthereumLocalnetAsset=t.WBTCEthereumLocalnetAsset;exports.bitcoinRegtestAsset=t.bitcoinRegtestAsset;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index2.cjs"),e=require("./index3.cjs"),s=require("./index4.cjs"),t=require("./index5.cjs");exports.Orderbook=r.Orderbook;exports.BlockchainType=e.BlockchainType;exports.Chains=e.Chains;exports.NetworkType=e.NetworkType;exports.TimeLocks=e.TimeLocks;exports.getBlockchainType=e.getBlockchainType;exports.getTimeLock=e.getTimeLock;exports.isBitcoin=e.isBitcoin;exports.isEVM=e.isEVM;exports.isMainnet=e.isMainnet;exports.isStarknet=e.isStarknet;exports.OrdersProvider=s.OrdersProvider;exports.ArbitrumLocalnet=t.ArbitrumLocalnet;exports.EthereumLocalnet=t.EthereumLocalnet;exports.SupportedAssets=t.SupportedAssets;exports.WBTCArbitrumLocalnetAsset=t.WBTCArbitrumLocalnetAsset;exports.WBTCEthereumLocalnetAsset=t.WBTCEthereumLocalnetAsset;exports.bitcoinRegtestAsset=t.bitcoinRegtestAsset;
package/dist/index.js CHANGED
@@ -1,23 +1,24 @@
1
1
  import { Orderbook as o } from "./index2.js";
2
- import { BlockchainType as i, Chains as s, NetworkType as c, TimeLocks as n, getBlockchainType as m, getTimeLock as p, isBitcoin as a, isEVM as T, isMainnet as k } from "./index3.js";
3
- import { OrdersProvider as A } from "./index4.js";
4
- import { ArbitrumLocalnet as h, EthereumLocalnet as u, SupportedAssets as B, WBTCArbitrumLocalnetAsset as b, WBTCEthereumLocalnetAsset as d, bitcoinRegtestAsset as f } from "./index5.js";
2
+ import { BlockchainType as i, Chains as s, NetworkType as c, TimeLocks as n, getBlockchainType as m, getTimeLock as a, isBitcoin as p, isEVM as k, isMainnet as T, isStarknet as l } from "./index3.js";
3
+ import { OrdersProvider as L } from "./index4.js";
4
+ import { ArbitrumLocalnet as u, EthereumLocalnet as B, SupportedAssets as b, WBTCArbitrumLocalnetAsset as d, WBTCEthereumLocalnetAsset as f, bitcoinRegtestAsset as x } from "./index5.js";
5
5
  export {
6
- h as ArbitrumLocalnet,
6
+ u as ArbitrumLocalnet,
7
7
  i as BlockchainType,
8
8
  s as Chains,
9
- u as EthereumLocalnet,
9
+ B as EthereumLocalnet,
10
10
  c as NetworkType,
11
11
  o as Orderbook,
12
- A as OrdersProvider,
13
- B as SupportedAssets,
12
+ L as OrdersProvider,
13
+ b as SupportedAssets,
14
14
  n as TimeLocks,
15
- b as WBTCArbitrumLocalnetAsset,
16
- d as WBTCEthereumLocalnetAsset,
17
- f as bitcoinRegtestAsset,
15
+ d as WBTCArbitrumLocalnetAsset,
16
+ f as WBTCEthereumLocalnetAsset,
17
+ x as bitcoinRegtestAsset,
18
18
  m as getBlockchainType,
19
- p as getTimeLock,
20
- a as isBitcoin,
21
- T as isEVM,
22
- k as isMainnet
19
+ a as getTimeLock,
20
+ p as isBitcoin,
21
+ k as isEVM,
22
+ T as isMainnet,
23
+ l as isStarknet
23
24
  };
package/dist/index2.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./index6.cjs"),c=require("./index7.cjs"),d=require("@gardenfi/utils"),l=require("./index4.cjs");class u extends l.OrdersProvider{constructor(r){const e=new d.Url("/relayer",r.url??c.MAINNET_ORDERBOOK_API);if(super(e),!r.auth)throw new Error("Auth is required");this.Url=e,this.walletClient=r.walletClient,this.auth=r.auth}static async init(r){var e;return await((e=r.auth.siwe)==null?void 0:e.getToken()),new u(r)}async createOrder(r){const e=await this.auth.getAuthHeaders();if(e.error)return s.Err(e.error);try{const t=await s.Fetcher.post(this.Url.endpoint("create-order"),{body:JSON.stringify(r),headers:{...e.val,"Content-Type":"application/json"}});return t.error?s.Err(t.error):t.result?s.Ok(t.result):s.Err("CreateOrder: Unexpected error, result is undefined")}catch(t){return s.Err("CreateOrder:",String(t))}}async fetchOrders(r,e=!1,t){var n;const a=(n=this.walletClient.account)==null?void 0:n.address;return a?r?await super.getMatchedOrders(a,e,t):await super.getUnMatchedOrders(a,t):s.Err("Wallet client does not have an account")}async subscribeToOrders(r,e,t,a){var i;const n=(i=this.walletClient.account)==null?void 0:i.address;return n?await super.subscribeOrders(n,!0,r,e,a,t):()=>{}}async getUserOrdersCount(){var e;const r=(e=this.walletClient.account)==null?void 0:e.address;return r?super.getOrdersCount(r):s.Err("Wallet client does not have an account")}}exports.Orderbook=u;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index6.cjs"),h=require("@gardenfi/utils"),i=require("./index7.cjs");class O{constructor(n){this.Url=n}async createOrder(n,o){const t=await o.getAuthHeaders();if(t.error)return r.Err(t.error);try{const s=await r.Fetcher.post(this.Url.endpoint("/relayer").endpoint("create-order"),{body:JSON.stringify(n),headers:{...t.val,"Content-Type":"application/json"}});return s.error?r.Err(s.error):s.result?r.Ok(s.result):r.Err("CreateOrder: Unexpected error, result is undefined")}catch(s){return r.Err("CreateOrder:",String(s))}}async getOrder(n,o){const t=o?`/id/matched/${n}`:`/id/unmatched/${n}`,s=this.Url.endpoint("orders").endpoint(t);try{const e=await r.Fetcher.get(s);return e.error?r.Err(e.error):e.result?r.Ok(e.result):r.Err("GetOrder: Unexpected error, result is undefined")}catch(e){return r.Err("GetOrder:",String(e))}}async getMatchedOrders(n,o,t){const s=i.ConstructUrl(this.Url.endpoint("orders"),`/user/matched/${n}`,{...t,pending:o});try{const e=await r.Fetcher.get(s);return e.error?r.Err(e.error):e.result?r.Ok(e.result):r.Err("GetMatchedOrders: Unexpected error, result is undefined")}catch(e){return r.Err("GetMatchedOrders:",String(e))}}async getUnMatchedOrders(n,o){const t=i.ConstructUrl(this.Url.endpoint("orders"),`/user/unmatched/${n}`,o);try{const s=await r.Fetcher.get(t);return s.error?r.Err(s.error):s.result?r.Ok(s.result):r.Err("GetUnMatchedOrders: Unexpected error, result is undefined")}catch(s){return r.Err("GetUnMatchedOrders:",String(s))}}async getOrders(n,o){const t=n?"/matched":"/unmatched",s=i.ConstructUrl(this.Url.endpoint("orders"),t,o);try{const e=await r.Fetcher.get(s);return e.error?r.Err(e.error):e.result?r.Ok(e.result):r.Err("GetAllOrders: Unexpected error, result is undefined")}catch(e){return r.Err("GetAllOrders:",String(e))}}async subscribeOrders(n,o,t,s,e=!1,u){let d=!1;const a=async()=>{if(!d){d=!0;try{const c=o?await this.getMatchedOrders(n,e,u):await this.getUnMatchedOrders(n,u);c.ok?await s(c.val):console.error("Error fetching orders:",c.error)}catch(c){console.error("Error fetching orders:",c)}finally{d=!1}}};await a();const l=setInterval(a,t);return()=>{clearInterval(l)}}async getOrdersCount(n){const o=this.Url.endpoint("orders").endpoint(`/user/count/${n}`);try{const t=await r.Fetcher.get(o);return t.error?r.Err(t.error):t.status===h.ApiStatus.Ok&&t.result!==void 0?r.Ok(t.result):r.Err("GetOrdersCount: Unexpected error, result is undefined")}catch(t){return r.Err("GetOrdersCount:",String(t))}}}exports.Orderbook=O;
package/dist/index2.js CHANGED
@@ -1,93 +1,123 @@
1
- import { Err as s, Fetcher as c, Ok as d } from "./index6.js";
2
- import { MAINNET_ORDERBOOK_API as l } from "./index7.js";
3
- import { Url as o } from "@gardenfi/utils";
4
- import { OrdersProvider as h } from "./index4.js";
5
- class u extends h {
6
- /**
7
- * Creates an instance of Orderbook. Does not login to the orderbook.
8
- * @constructor
9
- * @param {OrderbookConfig} orderbookConfig - The configuration object for the orderbook.
10
- */
11
- constructor(r) {
12
- const e = new o(
13
- "/relayer",
14
- r.url ?? l
15
- );
16
- if (super(e), !r.auth)
17
- throw new Error("Auth is required");
18
- this.Url = e, this.walletClient = r.walletClient, this.auth = r.auth;
19
- }
20
- /**
21
- * Initializes the orderbook as well as logs in the orderbook (fetches the auth token).
22
- * @param {OrderbookConfig} orderbookConfig - The configuration object for the orderbook.
23
- */
24
- static async init(r) {
25
- var e;
26
- return await ((e = r.auth.siwe) == null ? void 0 : e.getToken()), new u(r);
1
+ import { Err as s, Fetcher as d, Ok as a } from "./index6.js";
2
+ import { ApiStatus as f } from "@gardenfi/utils";
3
+ import { ConstructUrl as u } from "./index7.js";
4
+ class m {
5
+ constructor(n) {
6
+ this.Url = n;
27
7
  }
28
8
  /**
29
9
  * Creates an order
30
- * @param {CreateOrderConfig} createOrderConfig - The configuration for the creating the order.
10
+ * @param {CreateOrderRequestWithAdditionalData} order - The configuration for the creating the order.
11
+ * @param {IAuth} auth - The auth object.
31
12
  * @returns {string} The create order ID.
32
13
  */
33
- async createOrder(r) {
34
- const e = await this.auth.getAuthHeaders();
14
+ async createOrder(n, o) {
15
+ const e = await o.getAuthHeaders();
35
16
  if (e.error) return s(e.error);
36
17
  try {
37
- const t = await c.post(
38
- this.Url.endpoint("create-order"),
18
+ const t = await d.post(
19
+ this.Url.endpoint("/relayer").endpoint("create-order"),
39
20
  {
40
- body: JSON.stringify(r),
21
+ body: JSON.stringify(n),
41
22
  headers: {
42
23
  ...e.val,
43
24
  "Content-Type": "application/json"
44
25
  }
45
26
  }
46
27
  );
47
- return t.error ? s(t.error) : t.result ? d(t.result) : s("CreateOrder: Unexpected error, result is undefined");
28
+ return t.error ? s(t.error) : t.result ? a(t.result) : s("CreateOrder: Unexpected error, result is undefined");
48
29
  } catch (t) {
49
30
  return s("CreateOrder:", String(t));
50
31
  }
51
32
  }
52
- async fetchOrders(r, e = !1, t) {
53
- var n;
54
- const a = (n = this.walletClient.account) == null ? void 0 : n.address;
55
- return a ? r ? await super.getMatchedOrders(
56
- a,
57
- e,
58
- t
59
- ) : await super.getUnMatchedOrders(
60
- a,
61
- t
62
- ) : s("Wallet client does not have an account");
33
+ async getOrder(n, o) {
34
+ const e = o ? `/id/matched/${n}` : `/id/unmatched/${n}`, t = this.Url.endpoint("orders").endpoint(e);
35
+ try {
36
+ const r = await d.get(t);
37
+ return r.error ? s(r.error) : r.result ? a(r.result) : s("GetOrder: Unexpected error, result is undefined");
38
+ } catch (r) {
39
+ return s("GetOrder:", String(r));
40
+ }
63
41
  }
64
- /**
65
- * Wrapper for the subscribeOrders method in the OrdersProvider class to abstract the address parameter.
66
- * @param matched - Whether to get matched or unmatched orders
67
- * @param interval - The interval to poll for updates
68
- * @param cb - The callback to be called when the orders are updated
69
- * @param paginationConfig - The configuration for the pagination
70
- * @returns {() => void} A function to unsubscribe from the order updates
71
- */
72
- async subscribeToOrders(r, e, t, a) {
73
- var i;
74
- const n = (i = this.walletClient.account) == null ? void 0 : i.address;
75
- return n ? await super.subscribeOrders(
76
- n,
77
- !0,
78
- r,
42
+ async getMatchedOrders(n, o, e) {
43
+ const t = u(
44
+ this.Url.endpoint("orders"),
45
+ `/user/matched/${n}`,
46
+ {
47
+ ...e,
48
+ pending: o
49
+ }
50
+ );
51
+ try {
52
+ const r = await d.get(
53
+ t
54
+ );
55
+ return r.error ? s(r.error) : r.result ? a(r.result) : s("GetMatchedOrders: Unexpected error, result is undefined");
56
+ } catch (r) {
57
+ return s("GetMatchedOrders:", String(r));
58
+ }
59
+ }
60
+ async getUnMatchedOrders(n, o) {
61
+ const e = u(
62
+ this.Url.endpoint("orders"),
63
+ `/user/unmatched/${n}`,
64
+ o
65
+ );
66
+ try {
67
+ const t = await d.get(
68
+ e
69
+ );
70
+ return t.error ? s(t.error) : t.result ? a(t.result) : s("GetUnMatchedOrders: Unexpected error, result is undefined");
71
+ } catch (t) {
72
+ return s("GetUnMatchedOrders:", String(t));
73
+ }
74
+ }
75
+ async getOrders(n, o) {
76
+ const e = n ? "/matched" : "/unmatched", t = u(
77
+ this.Url.endpoint("orders"),
79
78
  e,
80
- a,
81
- t
82
- ) : () => {
79
+ o
80
+ );
81
+ try {
82
+ const r = await d.get(t);
83
+ return r.error ? s(r.error) : r.result ? a(r.result) : s("GetAllOrders: Unexpected error, result is undefined");
84
+ } catch (r) {
85
+ return s("GetAllOrders:", String(r));
86
+ }
87
+ }
88
+ async subscribeOrders(n, o, e, t, r = !1, l) {
89
+ let i = !1;
90
+ const h = async () => {
91
+ if (!i) {
92
+ i = !0;
93
+ try {
94
+ const c = o ? await this.getMatchedOrders(n, r, l) : await this.getUnMatchedOrders(n, l);
95
+ c.ok ? await t(
96
+ c.val
97
+ ) : console.error("Error fetching orders:", c.error);
98
+ } catch (c) {
99
+ console.error("Error fetching orders:", c);
100
+ } finally {
101
+ i = !1;
102
+ }
103
+ }
104
+ };
105
+ await h();
106
+ const O = setInterval(h, e);
107
+ return () => {
108
+ clearInterval(O);
83
109
  };
84
110
  }
85
- async getUserOrdersCount() {
86
- var e;
87
- const r = (e = this.walletClient.account) == null ? void 0 : e.address;
88
- return r ? super.getOrdersCount(r) : s("Wallet client does not have an account");
111
+ async getOrdersCount(n) {
112
+ const o = this.Url.endpoint("orders").endpoint(`/user/count/${n}`);
113
+ try {
114
+ const e = await d.get(o);
115
+ return e.error ? s(e.error) : e.status === f.Ok && e.result !== void 0 ? a(e.result) : s("GetOrdersCount: Unexpected error, result is undefined");
116
+ } catch (e) {
117
+ return s("GetOrdersCount:", String(e));
118
+ }
89
119
  }
90
120
  }
91
121
  export {
92
- u as Orderbook
122
+ m as Orderbook
93
123
  };
package/dist/index3.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var i=(e=>(e.Bitcoin="Bitcoin",e.EVM="EVM",e))(i||{}),o=(e=>(e.mainnet="mainnet",e.testnet="testnet",e.localnet="localnet",e))(o||{});const t={bitcoin:"bitcoin",bitcoin_testnet:"bitcoin_testnet",bitcoin_regtest:"bitcoin_regtest",ethereum:"ethereum",base:"base",arbitrum:"arbitrum",ethereum_sepolia:"ethereum_sepolia",arbitrum_localnet:"arbitrum_localnet",arbitrum_sepolia:"arbitrum_sepolia",ethereum_localnet:"ethereum_localnet",base_sepolia:"base_sepolia",bera_testnet:"bera_testnet",citrea_testnet:"citrea_testnet",bera:"bera",monad_testnet:"monad_testnet"},a=e=>!(e===t.ethereum_sepolia||e===t.bitcoin_testnet||e===t.bitcoin_regtest||e===t.arbitrum_localnet||e===t.ethereum_localnet||e===t.arbitrum_sepolia||e===t.base_sepolia||e===t.bera_testnet||e===t.citrea_testnet||e===t.monad_testnet),s=e=>e===t.bitcoin||e===t.bitcoin_testnet||e===t.bitcoin_regtest,n=e=>e===t.ethereum||e===t.arbitrum||e===t.ethereum_sepolia||e===t.ethereum_localnet||e===t.arbitrum_localnet||e===t.arbitrum_sepolia||e===t.base_sepolia||e===t.base||e===t.bera_testnet||e===t.citrea_testnet||e===t.bera||e===t.monad_testnet,r={[t.bitcoin]:144,[t.bitcoin_testnet]:144,[t.bitcoin_regtest]:144,[t.ethereum]:7200,[t.arbitrum]:7200,[t.ethereum_sepolia]:7200,[t.arbitrum_localnet]:7200,[t.arbitrum_sepolia]:7200,[t.ethereum_localnet]:7200,[t.base_sepolia]:7200,[t.base]:43200,[t.bera_testnet]:28800,[t.citrea_testnet]:28800,[t.bera]:43200,[t.monad_testnet]:172800},_=e=>{if(s(e))return"Bitcoin";if(n(e))return"EVM";throw new Error("Invalid or unsupported chain")},b=e=>{if(!r[e])throw new Error("Invalid or unsupported chain");return r[e]};exports.BlockchainType=i;exports.Chains=t;exports.NetworkType=o;exports.TimeLocks=r;exports.getBlockchainType=_;exports.getTimeLock=b;exports.isBitcoin=s;exports.isEVM=n;exports.isMainnet=a;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var s=(t=>(t.Bitcoin="Bitcoin",t.EVM="EVM",t.Starknet="Starknet",t))(s||{}),n=(t=>(t.mainnet="mainnet",t.testnet="testnet",t.localnet="localnet",t))(n||{});const e={bitcoin:"bitcoin",bitcoin_testnet:"bitcoin_testnet",bitcoin_regtest:"bitcoin_regtest",ethereum:"ethereum",base:"base",arbitrum:"arbitrum",ethereum_sepolia:"ethereum_sepolia",arbitrum_localnet:"arbitrum_localnet",arbitrum_sepolia:"arbitrum_sepolia",ethereum_localnet:"ethereum_localnet",base_sepolia:"base_sepolia",bera_testnet:"bera_testnet",citrea_testnet:"citrea_testnet",bera:"bera",monad_testnet:"monad_testnet",starknet:"starknet",starknet_sepolia:"starknet_sepolia",starknet_devnet:"starknet_devnet"},_=t=>!(t===e.ethereum_sepolia||t===e.bitcoin_testnet||t===e.bitcoin_regtest||t===e.arbitrum_localnet||t===e.ethereum_localnet||t===e.arbitrum_sepolia||t===e.base_sepolia||t===e.bera_testnet||t===e.citrea_testnet||t===e.monad_testnet||t===e.starknet_devnet||t===e.starknet_sepolia),o=t=>t===e.bitcoin||t===e.bitcoin_testnet||t===e.bitcoin_regtest,a=t=>t===e.ethereum||t===e.arbitrum||t===e.ethereum_sepolia||t===e.ethereum_localnet||t===e.arbitrum_localnet||t===e.arbitrum_sepolia||t===e.base_sepolia||t===e.base||t===e.bera_testnet||t===e.citrea_testnet||t===e.bera||t===e.monad_testnet,i=t=>t===e.starknet||t===e.starknet_devnet||t===e.starknet_sepolia,r={[e.bitcoin]:144,[e.bitcoin_testnet]:144,[e.bitcoin_regtest]:144,[e.ethereum]:7200,[e.arbitrum]:7200,[e.ethereum_sepolia]:7200,[e.arbitrum_localnet]:7200,[e.arbitrum_sepolia]:7200,[e.ethereum_localnet]:7200,[e.base_sepolia]:7200,[e.base]:43200,[e.bera_testnet]:28800,[e.citrea_testnet]:28800,[e.bera]:43200,[e.monad_testnet]:172800,[e.starknet]:2880,[e.starknet_devnet]:2880,[e.starknet_sepolia]:2880},l=t=>{if(o(t))return"Bitcoin";if(a(t))return"EVM";if(i(t))return"Starknet";throw new Error("Invalid or unsupported chain")},b=t=>{if(!r[t])throw new Error("Invalid or unsupported chain");return r[t]};exports.BlockchainType=s;exports.Chains=e;exports.NetworkType=n;exports.TimeLocks=r;exports.getBlockchainType=l;exports.getTimeLock=b;exports.isBitcoin=o;exports.isEVM=a;exports.isMainnet=_;exports.isStarknet=i;
package/dist/index3.js CHANGED
@@ -1,5 +1,5 @@
1
- var o = /* @__PURE__ */ ((e) => (e.Bitcoin = "Bitcoin", e.EVM = "EVM", e))(o || {}), s = /* @__PURE__ */ ((e) => (e.mainnet = "mainnet", e.testnet = "testnet", e.localnet = "localnet", e))(s || {});
2
- const t = {
1
+ var s = /* @__PURE__ */ ((t) => (t.Bitcoin = "Bitcoin", t.EVM = "EVM", t.Starknet = "Starknet", t))(s || {}), n = /* @__PURE__ */ ((t) => (t.mainnet = "mainnet", t.testnet = "testnet", t.localnet = "localnet", t))(n || {});
2
+ const e = {
3
3
  bitcoin: "bitcoin",
4
4
  bitcoin_testnet: "bitcoin_testnet",
5
5
  bitcoin_regtest: "bitcoin_regtest",
@@ -14,39 +14,47 @@ const t = {
14
14
  bera_testnet: "bera_testnet",
15
15
  citrea_testnet: "citrea_testnet",
16
16
  bera: "bera",
17
- monad_testnet: "monad_testnet"
18
- }, a = (e) => !(e === t.ethereum_sepolia || e === t.bitcoin_testnet || e === t.bitcoin_regtest || e === t.arbitrum_localnet || e === t.ethereum_localnet || e === t.arbitrum_sepolia || e === t.base_sepolia || e === t.bera_testnet || e === t.citrea_testnet || e === t.monad_testnet), n = (e) => e === t.bitcoin || e === t.bitcoin_testnet || e === t.bitcoin_regtest, i = (e) => e === t.ethereum || e === t.arbitrum || e === t.ethereum_sepolia || e === t.ethereum_localnet || e === t.arbitrum_localnet || e === t.arbitrum_sepolia || e === t.base_sepolia || e === t.base || e === t.bera_testnet || e === t.citrea_testnet || e === t.bera || e === t.monad_testnet, r = {
19
- [t.bitcoin]: 144,
20
- [t.bitcoin_testnet]: 144,
21
- [t.bitcoin_regtest]: 144,
22
- [t.ethereum]: 7200,
23
- [t.arbitrum]: 7200,
24
- [t.ethereum_sepolia]: 7200,
25
- [t.arbitrum_localnet]: 7200,
26
- [t.arbitrum_sepolia]: 7200,
27
- [t.ethereum_localnet]: 7200,
28
- [t.base_sepolia]: 7200,
29
- [t.base]: 43200,
30
- [t.bera_testnet]: 28800,
31
- [t.citrea_testnet]: 28800,
32
- [t.bera]: 43200,
33
- [t.monad_testnet]: 172800
34
- }, _ = (e) => {
35
- if (n(e)) return "Bitcoin";
36
- if (i(e)) return "EVM";
17
+ monad_testnet: "monad_testnet",
18
+ starknet: "starknet",
19
+ starknet_sepolia: "starknet_sepolia",
20
+ starknet_devnet: "starknet_devnet"
21
+ }, _ = (t) => !(t === e.ethereum_sepolia || t === e.bitcoin_testnet || t === e.bitcoin_regtest || t === e.arbitrum_localnet || t === e.ethereum_localnet || t === e.arbitrum_sepolia || t === e.base_sepolia || t === e.bera_testnet || t === e.citrea_testnet || t === e.monad_testnet || t === e.starknet_devnet || t === e.starknet_sepolia), a = (t) => t === e.bitcoin || t === e.bitcoin_testnet || t === e.bitcoin_regtest, o = (t) => t === e.ethereum || t === e.arbitrum || t === e.ethereum_sepolia || t === e.ethereum_localnet || t === e.arbitrum_localnet || t === e.arbitrum_sepolia || t === e.base_sepolia || t === e.base || t === e.bera_testnet || t === e.citrea_testnet || t === e.bera || t === e.monad_testnet, i = (t) => t === e.starknet || t === e.starknet_devnet || t === e.starknet_sepolia, r = {
22
+ [e.bitcoin]: 144,
23
+ [e.bitcoin_testnet]: 144,
24
+ [e.bitcoin_regtest]: 144,
25
+ [e.ethereum]: 7200,
26
+ [e.arbitrum]: 7200,
27
+ [e.ethereum_sepolia]: 7200,
28
+ [e.arbitrum_localnet]: 7200,
29
+ [e.arbitrum_sepolia]: 7200,
30
+ [e.ethereum_localnet]: 7200,
31
+ [e.base_sepolia]: 7200,
32
+ [e.base]: 43200,
33
+ [e.bera_testnet]: 28800,
34
+ [e.citrea_testnet]: 28800,
35
+ [e.bera]: 43200,
36
+ [e.monad_testnet]: 172800,
37
+ [e.starknet]: 2880,
38
+ [e.starknet_devnet]: 2880,
39
+ [e.starknet_sepolia]: 2880
40
+ }, b = (t) => {
41
+ if (a(t)) return "Bitcoin";
42
+ if (o(t)) return "EVM";
43
+ if (i(t)) return "Starknet";
37
44
  throw new Error("Invalid or unsupported chain");
38
- }, b = (e) => {
39
- if (!r[e]) throw new Error("Invalid or unsupported chain");
40
- return r[e];
45
+ }, l = (t) => {
46
+ if (!r[t]) throw new Error("Invalid or unsupported chain");
47
+ return r[t];
41
48
  };
42
49
  export {
43
- o as BlockchainType,
44
- t as Chains,
45
- s as NetworkType,
50
+ s as BlockchainType,
51
+ e as Chains,
52
+ n as NetworkType,
46
53
  r as TimeLocks,
47
- _ as getBlockchainType,
48
- b as getTimeLock,
49
- n as isBitcoin,
50
- i as isEVM,
51
- a as isMainnet
54
+ b as getBlockchainType,
55
+ l as getTimeLock,
56
+ a as isBitcoin,
57
+ o as isEVM,
58
+ _ as isMainnet,
59
+ i as isStarknet
52
60
  };
package/dist/index4.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index6.cjs"),l=require("@gardenfi/utils"),d=require("./index8.cjs");class O{constructor(s){this.url=new l.Url("/orders",s)}async getOrder(s,c){const t=c?`/id/matched/${s}`:`/id/unmatched/${s}`,n=this.url.endpoint(t);try{const e=await r.Fetcher.get(n);return e.error?r.Err(e.error):e.result?r.Ok(e.result):r.Err("GetOrder: Unexpected error, result is undefined")}catch(e){return r.Err("GetOrder:",String(e))}}async getMatchedOrders(s,c,t){const n=d.ConstructUrl(this.url,`/user/matched/${s}`,{...t,pending:c});try{const e=await r.Fetcher.get(n);return e.error?r.Err(e.error):e.result?r.Ok(e.result):r.Err("GetMatchedOrders: Unexpected error, result is undefined")}catch(e){return r.Err("GetMatchedOrders:",String(e))}}async getUnMatchedOrders(s,c){const t=d.ConstructUrl(this.url,`/user/unmatched/${s}`,c);try{const n=await r.Fetcher.get(t);return n.error?r.Err(n.error):n.result?r.Ok(n.result):r.Err("GetUnMatchedOrders: Unexpected error, result is undefined")}catch(n){return r.Err("GetUnMatchedOrders:",String(n))}}async getOrders(s,c){const t=s?"/matched":"/unmatched",n=d.ConstructUrl(this.url,t,c);try{const e=await r.Fetcher.get(n);return e.error?r.Err(e.error):e.result?r.Ok(e.result):r.Err("GetAllOrders: Unexpected error, result is undefined")}catch(e){return r.Err("GetAllOrders:",String(e))}}async subscribeOrders(s,c,t,n,e=!1,i){let o=!1;const a=async()=>{if(!o){o=!0;try{const u=c?await this.getMatchedOrders(s,e,i):await this.getUnMatchedOrders(s,i);u.ok?await n(u.val):console.error("Error fetching orders:",u.error)}catch(u){console.error("Error fetching orders:",u)}finally{o=!1}}};await a();const h=setInterval(a,t);return()=>{clearInterval(h)}}async getOrdersCount(s){const c=this.url.endpoint(`/user/count/${s}`);try{const t=await r.Fetcher.get(c);return t.error?r.Err(t.error):t.status===l.ApiStatus.Ok&&t.result!==void 0?r.Ok(t.result):r.Err("GetOrdersCount: Unexpected error, result is undefined")}catch(t){return r.Err("GetOrdersCount:",String(t))}}}exports.OrdersProvider=O;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index6.cjs"),l=require("@gardenfi/utils"),d=require("./index7.cjs");class O{constructor(s){this.url=new l.Url("/orders",s)}async getOrder(s,c){const t=c?`/id/matched/${s}`:`/id/unmatched/${s}`,n=this.url.endpoint(t);try{const e=await r.Fetcher.get(n);return e.error?r.Err(e.error):e.result?r.Ok(e.result):r.Err("GetOrder: Unexpected error, result is undefined")}catch(e){return r.Err("GetOrder:",String(e))}}async getMatchedOrders(s,c,t){const n=d.ConstructUrl(this.url,`/user/matched/${s}`,{...t,pending:c});try{const e=await r.Fetcher.get(n);return e.error?r.Err(e.error):e.result?r.Ok(e.result):r.Err("GetMatchedOrders: Unexpected error, result is undefined")}catch(e){return r.Err("GetMatchedOrders:",String(e))}}async getUnMatchedOrders(s,c){const t=d.ConstructUrl(this.url,`/user/unmatched/${s}`,c);try{const n=await r.Fetcher.get(t);return n.error?r.Err(n.error):n.result?r.Ok(n.result):r.Err("GetUnMatchedOrders: Unexpected error, result is undefined")}catch(n){return r.Err("GetUnMatchedOrders:",String(n))}}async getOrders(s,c){const t=s?"/matched":"/unmatched",n=d.ConstructUrl(this.url,t,c);try{const e=await r.Fetcher.get(n);return e.error?r.Err(e.error):e.result?r.Ok(e.result):r.Err("GetAllOrders: Unexpected error, result is undefined")}catch(e){return r.Err("GetAllOrders:",String(e))}}async subscribeOrders(s,c,t,n,e=!1,i){let o=!1;const a=async()=>{if(!o){o=!0;try{const u=c?await this.getMatchedOrders(s,e,i):await this.getUnMatchedOrders(s,i);u.ok?await n(u.val):console.error("Error fetching orders:",u.error)}catch(u){console.error("Error fetching orders:",u)}finally{o=!1}}};await a();const h=setInterval(a,t);return()=>{clearInterval(h)}}async getOrdersCount(s){const c=this.url.endpoint(`/user/count/${s}`);try{const t=await r.Fetcher.get(c);return t.error?r.Err(t.error):t.status===l.ApiStatus.Ok&&t.result!==void 0?r.Ok(t.result):r.Err("GetOrdersCount: Unexpected error, result is undefined")}catch(t){return r.Err("GetOrdersCount:",String(t))}}}exports.OrdersProvider=O;
package/dist/index4.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Fetcher as u, Err as s, Ok as d } from "./index6.js";
2
2
  import { Url as f, ApiStatus as g } from "@gardenfi/utils";
3
- import { ConstructUrl as i } from "./index8.js";
3
+ import { ConstructUrl as i } from "./index7.js";
4
4
  class w {
5
5
  constructor(t) {
6
6
  this.url = new f("/orders", t);
package/dist/index5.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index3.cjs"),t={id:31338,name:"Arbitrum Localnet",nativeCurrency:{name:"Ethereum",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["http://localhost:8546/"]}},testnet:!0},i={id:31337,name:"Ethereum Localnet",nativeCurrency:{name:"Ethereum",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["http://localhost:8545/"]}},testnet:!0},n={name:"Bitcoin Regtest",decimals:8,symbol:"BTC",chain:e.Chains.bitcoin_regtest,atomicSwapAddress:"primary",tokenAddress:"primary"},a={name:"WBTC Arbitrum Localnet",decimals:8,symbol:"WBTC",chain:e.Chains.arbitrum_localnet,atomicSwapAddress:"0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9",tokenAddress:"0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512"},s={name:"WBTC Ethereum Localnet",decimals:8,symbol:"WBTC",chain:e.Chains.ethereum_localnet,atomicSwapAddress:"0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",tokenAddress:"0x5FbDB2315678afecb367f032d93F642f64180aa3"},c={localnet:{arbitrum_localnet_WBTC:a,ethereum_localnet_WBTC:s},testnet:{bitcoin_testnet_BTC:{name:"BTC",decimals:8,symbol:"BTC",chain:e.Chains.bitcoin_testnet,tokenAddress:"primary",atomicSwapAddress:"primary"},ethereum_sepolia_WBTC:{name:"Wrapped Bitcoin",decimals:8,symbol:"WBTC",chain:e.Chains.ethereum_sepolia,logo:"https://garden-finance.imgix.net/token-images/wbtc.svg",tokenAddress:"0x4D68da063577F98C55166c7AF6955cF58a97b20A",atomicSwapAddress:"0x3C6a17b8cD92976D1D91E491c93c98cd81998265"},arbitrum_sepolia_WBTC:{name:"Wrapped Bitcoin",decimals:8,symbol:"WBTC",logo:"https://garden-finance.imgix.net/token-images/wbtc.svg",chain:e.Chains.arbitrum_sepolia,tokenAddress:"0x00ab86f54F436CfE15253845F139955ae0C00bAf",atomicSwapAddress:"0x1cd0bBd55fD66B4C5F7dfE434eFD009C09e628d1"},arbitrum_sepolia_SEED:{name:"Seed",decimals:18,symbol:"SEED",chain:e.Chains.arbitrum_sepolia,logo:"https://garden-finance.imgix.net/token-images/seed.svg",tokenAddress:"0x13DCec0762EcC5E666c207ab44Dc768e5e33070F",atomicSwapAddress:"0xD5FeDb4ceCB0F1D32788a190d9EB47D94D23eE4e"},arbitrum_sepolia_iBTC:{name:"iBTC",decimals:8,symbol:"iBTC",chain:e.Chains.arbitrum_sepolia,logo:"https://garden-finance.imgix.net/token-images/dlcBTCIcon.svg",tokenAddress:"0x685437f025c5f33a94818408c286bc1f023201fc",atomicSwapAddress:"0xdfe6d9363ee96152d39391009a6723819d9e25eb"},base_sepolia_WBTC:{name:"Wrapped Bitcoin",decimals:8,symbol:"WBTC",chain:e.Chains.base_sepolia,logo:"https://garden-finance.imgix.net/token-images/wbtc.svg",tokenAddress:"0x13DCec0762EcC5E666c207ab44Dc768e5e33070F",atomicSwapAddress:"0x00ab86f54F436CfE15253845F139955ae0C00bAf"},base_sepolia_USDT:{name:"Tether USD",decimals:6,symbol:"USDT",chain:e.Chains.base_sepolia,logo:"https://garden-finance.imgix.net/token-images/usdt.svg",tokenAddress:"0xD72Fc3e7D52301b3e5f7d4E3366F88d5C8747520",atomicSwapAddress:"0xB391CA6D0A76CD2A927bC314856E8a374a225CFc"},base_sepolia_iBTC:{name:"iBTC",decimals:8,symbol:"iBTC",chain:e.Chains.base_sepolia,logo:"https://garden-finance.imgix.net/token-images/dlcBTCIcon.svg",tokenAddress:"0x0b0D554D9573bAe1a7556d220847f45182918B28",atomicSwapAddress:"0xbcdad29ac77e5bb27fd528ab0045af630259fe4f"},bera_testnet_WBTC:{name:"Wrapped Bitcoin",decimals:8,symbol:"WBTC",chain:e.Chains.bera_testnet,logo:"https://garden-finance.imgix.net/token-images/wbtc.svg",tokenAddress:"0x00ab86f54F436CfE15253845F139955ae0C00bAf",atomicSwapAddress:"0x1dC94FdcAd8Aee13cfd34Db8a26d26E31572805c"},citrea_testnet_WCBTC:{name:"Wrapped Citrea Bitcoin",decimals:18,symbol:"WCBTC",chain:e.Chains.citrea_testnet,logo:"https://garden-finance.imgix.net/token-images/wbtc.svg",tokenAddress:"0x8d0c9d1c17aE5e40ffF9bE350f57840E9E66Cd93",atomicSwapAddress:"0xaD9d14CA82d9BF97fFf745fFC7d48172A1c0969E"}},mainnet:{bitcoin_BTC:{name:"BTC",decimals:8,symbol:"BTC",chain:e.Chains.bitcoin,tokenAddress:"primary",atomicSwapAddress:"primary"},base_cbBTC:{name:"Coinbase Bitcoin",decimals:8,symbol:"cbBTC",chain:e.Chains.base,logo:"https://garden-finance.imgix.net/token-images/cbBTC.svg",tokenAddress:"0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf",atomicSwapAddress:"0xeae7721d779276eb0f5837e2fe260118724a2ba4"},base_USDC:{name:"USD Coin",decimals:6,symbol:"USDC",chain:e.Chains.base,logo:"https://garden-finance.imgix.net/token-images/usdc.svg",tokenAddress:"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",atomicSwapAddress:"0xd8a6e3fca403d79b6ad6216b60527f51cc967d39"},ethereum_WBTC:{name:"Wrapped Bitcoin",decimals:8,symbol:"WBTC",chain:e.Chains.ethereum,logo:"https://garden-finance.imgix.net/token-images/wbtc.svg",tokenAddress:"0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",atomicSwapAddress:"0x795dcb58d1cd4789169d5f938ea05e17eceb68ca"},ethereum_USDC:{name:"USD Coin",decimals:6,symbol:"USDC",chain:e.Chains.ethereum,logo:"https://garden-finance.imgix.net/token-images/usdc.svg",tokenAddress:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",atomicSwapAddress:"0xd8a6e3fca403d79b6ad6216b60527f51cc967d39"},ethereum_cbBTC:{name:"Coinbase Bitcoin",decimals:8,symbol:"cbBTC",chain:e.Chains.ethereum,logo:"https://garden-finance.imgix.net/token-images/cbBTC.svg",tokenAddress:"0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf",atomicSwapAddress:"0xeae7721d779276eb0f5837e2fe260118724a2ba4"},arbitrum_WBTC:{name:"Wrapped Bitcoin",decimals:8,symbol:"WBTC",chain:e.Chains.arbitrum,logo:"https://garden-finance.imgix.net/token-images/wbtc.svg",tokenAddress:"0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",atomicSwapAddress:"0x6b6303fab8ec7232b4f2a7b9fa58e5216f608fcb"},arbitrum_USDC:{name:"USD Coin",decimals:6,symbol:"USDC",chain:e.Chains.arbitrum,logo:"https://garden-finance.imgix.net/token-images/usdc.svg",tokenAddress:"0xaf88d065e77c8cC2239327C5EDb3A432268e5831",atomicSwapAddress:"0xeae7721d779276eb0f5837e2fe260118724a2ba4"},arbitrum_iBTC:{name:"iBTC",decimals:8,symbol:"iBTC",chain:e.Chains.arbitrum,logo:"https://garden-finance.imgix.net/token-images/iBTC.svg",tokenAddress:"0x050C24dBf1eEc17babE5fc585F06116A259CC77A",atomicSwapAddress:"0xdc74a45e86dedf1ff7c6dac77e0c2f082f9e4f72"},bera_LBTC:{name:"Lombard Bitcoin",decimals:8,symbol:"LBTC",chain:e.Chains.bera,logo:"https://garden-finance.imgix.net/token-images/LBTC.svg",tokenAddress:"0xecAc9C5F704e954931349Da37F60E39f515c11c1",atomicSwapAddress:"0x39f3294352208905fc6ebf033954E6c6455CdB4C"}}};exports.ArbitrumLocalnet=t;exports.EthereumLocalnet=i;exports.SupportedAssets=c;exports.WBTCArbitrumLocalnetAsset=a;exports.WBTCEthereumLocalnetAsset=s;exports.bitcoinRegtestAsset=n;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index3.cjs"),i={id:31338,name:"Arbitrum Localnet",nativeCurrency:{name:"Ethereum",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["http://localhost:8546/"]}},testnet:!0},c={id:31337,name:"Ethereum Localnet",nativeCurrency:{name:"Ethereum",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["http://localhost:8545/"]}},testnet:!0},d={name:"Bitcoin Regtest",decimals:8,symbol:"BTC",chain:e.Chains.bitcoin_regtest,atomicSwapAddress:"primary",tokenAddress:"primary"},a={name:"WBTC Arbitrum Localnet",decimals:8,symbol:"WBTC",chain:e.Chains.arbitrum_localnet,atomicSwapAddress:"0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9",tokenAddress:"0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512"},s={name:"WBTC Ethereum Localnet",decimals:8,symbol:"WBTC",chain:e.Chains.ethereum_localnet,atomicSwapAddress:"0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",tokenAddress:"0x5FbDB2315678afecb367f032d93F642f64180aa3"},t={name:"STRK Starknet Localnet",decimals:18,symbol:"STRK",chain:e.Chains.starknet_devnet,atomicSwapAddress:"0x15cf8b127aa850c97ed10de6f8b300cabc4f09232a57e63667af02fdef8a55a",tokenAddress:"0x51aa025f1c9948790113e4ebea826dee24542bc50902076c05892774210e8d2"},n={name:"ETH Starknet Localnet",decimals:18,symbol:"ETH",chain:e.Chains.starknet_devnet,atomicSwapAddress:"0x1890470168440bbb9df50988748924a74ea22de10d22a081e458737b9574e75",tokenAddress:"0x51aa025f1c9948790113e4ebea826dee24542bc50902076c05892774210e8d2"},o={localnet:{arbitrum_localnet_WBTC:a,ethereum_localnet_WBTC:s,starknet_localnet_STRK:t,starknet_localnet_ETH:n},testnet:{bitcoin_testnet_BTC:{name:"BTC",decimals:8,symbol:"BTC",chain:e.Chains.bitcoin_testnet,tokenAddress:"primary",atomicSwapAddress:"primary"},ethereum_sepolia_WBTC:{name:"Wrapped Bitcoin",decimals:8,symbol:"WBTC",chain:e.Chains.ethereum_sepolia,logo:"https://garden-finance.imgix.net/token-images/wbtc.svg",tokenAddress:"0x4D68da063577F98C55166c7AF6955cF58a97b20A",atomicSwapAddress:"0x3C6a17b8cD92976D1D91E491c93c98cd81998265"},arbitrum_sepolia_WBTC:{name:"Wrapped Bitcoin",decimals:8,symbol:"WBTC",logo:"https://garden-finance.imgix.net/token-images/wbtc.svg",chain:e.Chains.arbitrum_sepolia,tokenAddress:"0x00ab86f54F436CfE15253845F139955ae0C00bAf",atomicSwapAddress:"0x1cd0bBd55fD66B4C5F7dfE434eFD009C09e628d1"},arbitrum_sepolia_SEED:{name:"Seed",decimals:18,symbol:"SEED",chain:e.Chains.arbitrum_sepolia,logo:"https://garden-finance.imgix.net/token-images/seed.svg",tokenAddress:"0x13DCec0762EcC5E666c207ab44Dc768e5e33070F",atomicSwapAddress:"0xD5FeDb4ceCB0F1D32788a190d9EB47D94D23eE4e"},arbitrum_sepolia_iBTC:{name:"iBTC",decimals:8,symbol:"iBTC",chain:e.Chains.arbitrum_sepolia,logo:"https://garden-finance.imgix.net/token-images/dlcBTCIcon.svg",tokenAddress:"0x685437f025c5f33a94818408c286bc1f023201fc",atomicSwapAddress:"0xdfe6d9363ee96152d39391009a6723819d9e25eb"},base_sepolia_WBTC:{name:"Wrapped Bitcoin",decimals:8,symbol:"WBTC",chain:e.Chains.base_sepolia,logo:"https://garden-finance.imgix.net/token-images/wbtc.svg",tokenAddress:"0x13DCec0762EcC5E666c207ab44Dc768e5e33070F",atomicSwapAddress:"0x00ab86f54F436CfE15253845F139955ae0C00bAf"},base_sepolia_USDT:{name:"Tether USD",decimals:6,symbol:"USDT",chain:e.Chains.base_sepolia,logo:"https://garden-finance.imgix.net/token-images/usdt.svg",tokenAddress:"0xD72Fc3e7D52301b3e5f7d4E3366F88d5C8747520",atomicSwapAddress:"0xB391CA6D0A76CD2A927bC314856E8a374a225CFc"},base_sepolia_iBTC:{name:"iBTC",decimals:8,symbol:"iBTC",chain:e.Chains.base_sepolia,logo:"https://garden-finance.imgix.net/token-images/dlcBTCIcon.svg",tokenAddress:"0x0b0D554D9573bAe1a7556d220847f45182918B28",atomicSwapAddress:"0xbcdad29ac77e5bb27fd528ab0045af630259fe4f"},bera_testnet_WBTC:{name:"Wrapped Bitcoin",decimals:8,symbol:"WBTC",chain:e.Chains.bera_testnet,logo:"https://garden-finance.imgix.net/token-images/wbtc.svg",tokenAddress:"0x00ab86f54F436CfE15253845F139955ae0C00bAf",atomicSwapAddress:"0x1dC94FdcAd8Aee13cfd34Db8a26d26E31572805c"},citrea_testnet_WCBTC:{name:"Wrapped Citrea Bitcoin",decimals:18,symbol:"WCBTC",chain:e.Chains.citrea_testnet,logo:"https://garden-finance.imgix.net/token-images/wbtc.svg",tokenAddress:"0x8d0c9d1c17aE5e40ffF9bE350f57840E9E66Cd93",atomicSwapAddress:"0xaD9d14CA82d9BF97fFf745fFC7d48172A1c0969E"},starknet_testnet_ETH:{name:"Starknet ETH",decimals:18,symbol:"ETH",chain:e.Chains.starknet_sepolia,logo:"https://garden-finance.imgix.net/token-images/wbtc.svg",tokenAddress:"0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",atomicSwapAddress:"0x13e7510b665d01c03f250e648c5be6f4a57b6cf56b3079293362ed2e4713c95"}},mainnet:{bitcoin_BTC:{name:"BTC",decimals:8,symbol:"BTC",chain:e.Chains.bitcoin,tokenAddress:"primary",atomicSwapAddress:"primary"},base_cbBTC:{name:"Coinbase Bitcoin",decimals:8,symbol:"cbBTC",chain:e.Chains.base,logo:"https://garden-finance.imgix.net/token-images/cbBTC.svg",tokenAddress:"0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf",atomicSwapAddress:"0xeae7721d779276eb0f5837e2fe260118724a2ba4"},base_USDC:{name:"USD Coin",decimals:6,symbol:"USDC",chain:e.Chains.base,logo:"https://garden-finance.imgix.net/token-images/usdc.svg",tokenAddress:"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",atomicSwapAddress:"0xd8a6e3fca403d79b6ad6216b60527f51cc967d39"},ethereum_WBTC:{name:"Wrapped Bitcoin",decimals:8,symbol:"WBTC",chain:e.Chains.ethereum,logo:"https://garden-finance.imgix.net/token-images/wbtc.svg",tokenAddress:"0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",atomicSwapAddress:"0x795dcb58d1cd4789169d5f938ea05e17eceb68ca"},ethereum_USDC:{name:"USD Coin",decimals:6,symbol:"USDC",chain:e.Chains.ethereum,logo:"https://garden-finance.imgix.net/token-images/usdc.svg",tokenAddress:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",atomicSwapAddress:"0xd8a6e3fca403d79b6ad6216b60527f51cc967d39"},ethereum_cbBTC:{name:"Coinbase Bitcoin",decimals:8,symbol:"cbBTC",chain:e.Chains.ethereum,logo:"https://garden-finance.imgix.net/token-images/cbBTC.svg",tokenAddress:"0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf",atomicSwapAddress:"0xeae7721d779276eb0f5837e2fe260118724a2ba4"},arbitrum_WBTC:{name:"Wrapped Bitcoin",decimals:8,symbol:"WBTC",chain:e.Chains.arbitrum,logo:"https://garden-finance.imgix.net/token-images/wbtc.svg",tokenAddress:"0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f",atomicSwapAddress:"0x6b6303fab8ec7232b4f2a7b9fa58e5216f608fcb"},arbitrum_USDC:{name:"USD Coin",decimals:6,symbol:"USDC",chain:e.Chains.arbitrum,logo:"https://garden-finance.imgix.net/token-images/usdc.svg",tokenAddress:"0xaf88d065e77c8cC2239327C5EDb3A432268e5831",atomicSwapAddress:"0xeae7721d779276eb0f5837e2fe260118724a2ba4"},arbitrum_iBTC:{name:"iBTC",decimals:8,symbol:"iBTC",chain:e.Chains.arbitrum,logo:"https://garden-finance.imgix.net/token-images/iBTC.svg",tokenAddress:"0x050C24dBf1eEc17babE5fc585F06116A259CC77A",atomicSwapAddress:"0xdc74a45e86dedf1ff7c6dac77e0c2f082f9e4f72"},bera_LBTC:{name:"Lombard Bitcoin",decimals:8,symbol:"LBTC",chain:e.Chains.bera,logo:"https://garden-finance.imgix.net/token-images/LBTC.svg",tokenAddress:"0xecAc9C5F704e954931349Da37F60E39f515c11c1",atomicSwapAddress:"0x39f3294352208905fc6ebf033954E6c6455CdB4C"}}};exports.ArbitrumLocalnet=i;exports.ETHStarknetLocalnetAsset=n;exports.EthereumLocalnet=c;exports.STRKStarknetLocalnetAsset=t;exports.SupportedAssets=o;exports.WBTCArbitrumLocalnetAsset=a;exports.WBTCEthereumLocalnetAsset=s;exports.bitcoinRegtestAsset=d;
package/dist/index5.js CHANGED
@@ -13,7 +13,7 @@ const i = {
13
13
  }
14
14
  },
15
15
  testnet: !0
16
- }, n = {
16
+ }, d = {
17
17
  id: 31337,
18
18
  name: "Ethereum Localnet",
19
19
  nativeCurrency: {
@@ -27,7 +27,7 @@ const i = {
27
27
  }
28
28
  },
29
29
  testnet: !0
30
- }, c = {
30
+ }, o = {
31
31
  name: "Bitcoin Regtest",
32
32
  decimals: 8,
33
33
  symbol: "BTC",
@@ -41,17 +41,33 @@ const i = {
41
41
  chain: e.arbitrum_localnet,
42
42
  atomicSwapAddress: "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9",
43
43
  tokenAddress: "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512"
44
- }, s = {
44
+ }, t = {
45
45
  name: "WBTC Ethereum Localnet",
46
46
  decimals: 8,
47
47
  symbol: "WBTC",
48
48
  chain: e.ethereum_localnet,
49
49
  atomicSwapAddress: "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
50
50
  tokenAddress: "0x5FbDB2315678afecb367f032d93F642f64180aa3"
51
- }, d = {
51
+ }, s = {
52
+ name: "STRK Starknet Localnet",
53
+ decimals: 18,
54
+ symbol: "STRK",
55
+ chain: e.starknet_devnet,
56
+ atomicSwapAddress: "0x15cf8b127aa850c97ed10de6f8b300cabc4f09232a57e63667af02fdef8a55a",
57
+ tokenAddress: "0x51aa025f1c9948790113e4ebea826dee24542bc50902076c05892774210e8d2"
58
+ }, n = {
59
+ name: "ETH Starknet Localnet",
60
+ decimals: 18,
61
+ symbol: "ETH",
62
+ chain: e.starknet_devnet,
63
+ atomicSwapAddress: "0x1890470168440bbb9df50988748924a74ea22de10d22a081e458737b9574e75",
64
+ tokenAddress: "0x51aa025f1c9948790113e4ebea826dee24542bc50902076c05892774210e8d2"
65
+ }, m = {
52
66
  localnet: {
53
67
  arbitrum_localnet_WBTC: a,
54
- ethereum_localnet_WBTC: s
68
+ ethereum_localnet_WBTC: t,
69
+ starknet_localnet_STRK: s,
70
+ starknet_localnet_ETH: n
55
71
  },
56
72
  testnet: {
57
73
  bitcoin_testnet_BTC: {
@@ -142,6 +158,15 @@ const i = {
142
158
  logo: "https://garden-finance.imgix.net/token-images/wbtc.svg",
143
159
  tokenAddress: "0x8d0c9d1c17aE5e40ffF9bE350f57840E9E66Cd93",
144
160
  atomicSwapAddress: "0xaD9d14CA82d9BF97fFf745fFC7d48172A1c0969E"
161
+ },
162
+ starknet_testnet_ETH: {
163
+ name: "Starknet ETH",
164
+ decimals: 18,
165
+ symbol: "ETH",
166
+ chain: e.starknet_sepolia,
167
+ logo: "https://garden-finance.imgix.net/token-images/wbtc.svg",
168
+ tokenAddress: "0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
169
+ atomicSwapAddress: "0x13e7510b665d01c03f250e648c5be6f4a57b6cf56b3079293362ed2e4713c95"
145
170
  }
146
171
  },
147
172
  mainnet: {
@@ -238,9 +263,11 @@ const i = {
238
263
  };
239
264
  export {
240
265
  i as ArbitrumLocalnet,
241
- n as EthereumLocalnet,
242
- d as SupportedAssets,
266
+ n as ETHStarknetLocalnetAsset,
267
+ d as EthereumLocalnet,
268
+ s as STRKStarknetLocalnetAsset,
269
+ m as SupportedAssets,
243
270
  a as WBTCArbitrumLocalnetAsset,
244
- s as WBTCEthereumLocalnetAsset,
245
- c as bitcoinRegtestAsset
271
+ t as WBTCEthereumLocalnetAsset,
272
+ o as bitcoinRegtestAsset
246
273
  };
package/dist/index7.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="https://api.garden.finance";exports.MAINNET_ORDERBOOK_API=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=(n,o,t)=>{const r=n.endpoint(o);return t&&Object.entries(t).forEach(([c,e])=>{e!==void 0&&r.searchParams.append(c,e.toString())}),r};exports.ConstructUrl=i;
package/dist/index7.js CHANGED
@@ -1,4 +1,9 @@
1
- const n = "https://api.garden.finance";
1
+ const i = (o, e, t) => {
2
+ const r = o.endpoint(e);
3
+ return t && Object.entries(t).forEach(([c, n]) => {
4
+ n !== void 0 && r.searchParams.append(c, n.toString());
5
+ }), r;
6
+ };
2
7
  export {
3
- n as MAINNET_ORDERBOOK_API
8
+ i as ConstructUrl
4
9
  };
@@ -1,7 +1,7 @@
1
1
  export { Orderbook } from './lib/orderbook/orderbook';
2
2
  export type * from './lib/orderbook/orderbook.types';
3
3
  export type { Chain, EvmChain, Asset } from './lib/asset';
4
- export { Chains, BlockchainType, isMainnet, isBitcoin, isEVM, getBlockchainType, NetworkType, TimeLocks, getTimeLock, } from './lib/asset';
4
+ export { Chains, BlockchainType, isMainnet, isBitcoin, isEVM, isStarknet, getBlockchainType, NetworkType, TimeLocks, getTimeLock, } from './lib/asset';
5
5
  export { OrdersProvider } from './lib/orders/ordersProvider';
6
6
  export type { IOrderProvider } from './lib/orders/orders.types';
7
7
  export { WBTCArbitrumLocalnetAsset, WBTCEthereumLocalnetAsset, ArbitrumLocalnet, EthereumLocalnet, bitcoinRegtestAsset, SupportedAssets, } from './lib/constants';
@@ -12,7 +12,8 @@ export type AssetToken = AssetCommon & {
12
12
  export type Asset = AssetToken;
13
13
  export declare enum BlockchainType {
14
14
  Bitcoin = "Bitcoin",
15
- EVM = "EVM"
15
+ EVM = "EVM",
16
+ Starknet = "Starknet"
16
17
  }
17
18
  export declare enum NetworkType {
18
19
  mainnet = "mainnet",
@@ -45,12 +46,16 @@ export declare const Chains: {
45
46
  readonly citrea_testnet: "citrea_testnet";
46
47
  readonly bera: "bera";
47
48
  readonly monad_testnet: "monad_testnet";
49
+ readonly starknet: "starknet";
50
+ readonly starknet_sepolia: "starknet_sepolia";
51
+ readonly starknet_devnet: "starknet_devnet";
48
52
  };
49
53
  export type Chain = keyof typeof Chains;
50
- export type EvmChain = keyof Omit<typeof Chains, 'bitcoin' | 'bitcoin_testnet' | 'bitcoin_regtest'>;
51
- export declare const isMainnet: (chain: Chain) => chain is "bitcoin" | "ethereum" | "base" | "arbitrum" | "bera";
54
+ export type EvmChain = keyof Omit<typeof Chains, 'bitcoin' | 'bitcoin_testnet' | 'bitcoin_regtest' | 'starknet' | 'starknet_devnet' | 'starknet_sepolia'>;
55
+ export declare const isMainnet: (chain: Chain) => chain is "bitcoin" | "ethereum" | "base" | "arbitrum" | "bera" | "starknet";
52
56
  export declare const isBitcoin: (chain: Chain) => chain is "bitcoin" | "bitcoin_testnet" | "bitcoin_regtest";
53
57
  export declare const isEVM: (chain: Chain) => chain is "ethereum" | "base" | "arbitrum" | "ethereum_sepolia" | "arbitrum_localnet" | "arbitrum_sepolia" | "ethereum_localnet" | "base_sepolia" | "bera_testnet" | "citrea_testnet" | "bera" | "monad_testnet";
58
+ export declare const isStarknet: (chain: Chain) => chain is "starknet" | "starknet_sepolia" | "starknet_devnet";
54
59
  export declare const TimeLocks: Record<Chain, number>;
55
60
  export declare const getBlockchainType: (chain: Chain) => BlockchainType;
56
61
  export declare const getTimeLock: (chain: Chain) => number;
@@ -1,15 +1,20 @@
1
1
  import { Chain } from 'viem';
2
2
  import { Asset } from './asset';
3
3
 
4
+ export declare const StarknetLocalnet: Chain;
4
5
  export declare const ArbitrumLocalnet: Chain;
5
6
  export declare const EthereumLocalnet: Chain;
6
7
  export declare const bitcoinRegtestAsset: Asset;
7
8
  export declare const WBTCArbitrumLocalnetAsset: Asset;
8
9
  export declare const WBTCEthereumLocalnetAsset: Asset;
10
+ export declare const STRKStarknetLocalnetAsset: Asset;
11
+ export declare const ETHStarknetLocalnetAsset: Asset;
9
12
  export declare const SupportedAssets: {
10
13
  readonly localnet: {
11
14
  readonly arbitrum_localnet_WBTC: import('./asset').AssetToken;
12
15
  readonly ethereum_localnet_WBTC: import('./asset').AssetToken;
16
+ readonly starknet_localnet_STRK: import('./asset').AssetToken;
17
+ readonly starknet_localnet_ETH: import('./asset').AssetToken;
13
18
  };
14
19
  readonly testnet: {
15
20
  readonly bitcoin_testnet_BTC: {
@@ -101,6 +106,15 @@ export declare const SupportedAssets: {
101
106
  readonly tokenAddress: "0x8d0c9d1c17aE5e40ffF9bE350f57840E9E66Cd93";
102
107
  readonly atomicSwapAddress: "0xaD9d14CA82d9BF97fFf745fFC7d48172A1c0969E";
103
108
  };
109
+ readonly starknet_testnet_ETH: {
110
+ readonly name: "Starknet ETH";
111
+ readonly decimals: 18;
112
+ readonly symbol: "ETH";
113
+ readonly chain: "starknet_sepolia";
114
+ readonly logo: "https://garden-finance.imgix.net/token-images/wbtc.svg";
115
+ readonly tokenAddress: "0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7";
116
+ readonly atomicSwapAddress: "0x13e7510b665d01c03f250e648c5be6f4a57b6cf56b3079293362ed2e4713c95";
117
+ };
104
118
  };
105
119
  readonly mainnet: {
106
120
  readonly bitcoin_BTC: {
@@ -1,43 +1,26 @@
1
1
  import { AsyncResult } from '@catalogfi/utils';
2
- import { CreateOrder, CreateOrderRequestWithAdditionalData, IOrderbook, MatchedOrder, OrderbookConfig, PaginatedData, PaginationConfig } from './orderbook.types';
3
- import { OrdersProvider } from '../orders/ordersProvider';
2
+ import { CreateOrder, CreateOrderRequestWithAdditionalData, IOrderbook, MatchedOrder, PaginatedData, PaginationConfig } from './orderbook.types';
3
+ import { IAuth, Url } from '@gardenfi/utils';
4
4
 
5
5
  /**
6
6
  * A class that allows you to create and manage orders with the orderbook url.
7
7
  * @class
8
- * @extends {OrdersProvider}
9
8
  * @implements {IOrderbook}
10
9
  */
11
- export declare class Orderbook extends OrdersProvider implements IOrderbook {
10
+ export declare class Orderbook implements IOrderbook {
12
11
  private Url;
13
- private auth;
14
- private walletClient;
15
- /**
16
- * Creates an instance of Orderbook. Does not login to the orderbook.
17
- * @constructor
18
- * @param {OrderbookConfig} orderbookConfig - The configuration object for the orderbook.
19
- */
20
- constructor(orderbookConfig: OrderbookConfig);
21
- /**
22
- * Initializes the orderbook as well as logs in the orderbook (fetches the auth token).
23
- * @param {OrderbookConfig} orderbookConfig - The configuration object for the orderbook.
24
- */
25
- static init(orderbookConfig: OrderbookConfig): Promise<Orderbook>;
12
+ constructor(url: Url);
26
13
  /**
27
14
  * Creates an order
28
- * @param {CreateOrderConfig} createOrderConfig - The configuration for the creating the order.
15
+ * @param {CreateOrderRequestWithAdditionalData} order - The configuration for the creating the order.
16
+ * @param {IAuth} auth - The auth object.
29
17
  * @returns {string} The create order ID.
30
18
  */
31
- createOrder(order: CreateOrderRequestWithAdditionalData): AsyncResult<string, string>;
32
- fetchOrders<T extends boolean>(matched: T, pending?: boolean, paginationConfig?: PaginationConfig): AsyncResult<PaginatedData<T extends true ? MatchedOrder : CreateOrder>, string>;
33
- /**
34
- * Wrapper for the subscribeOrders method in the OrdersProvider class to abstract the address parameter.
35
- * @param matched - Whether to get matched or unmatched orders
36
- * @param interval - The interval to poll for updates
37
- * @param cb - The callback to be called when the orders are updated
38
- * @param paginationConfig - The configuration for the pagination
39
- * @returns {() => void} A function to unsubscribe from the order updates
40
- */
41
- subscribeToOrders(interval: number, cb: (orders: PaginatedData<MatchedOrder>) => Promise<void>, paginationConfig?: PaginationConfig, pending?: boolean): Promise<() => void>;
42
- getUserOrdersCount(): AsyncResult<number, string>;
19
+ createOrder(order: CreateOrderRequestWithAdditionalData, auth: IAuth): AsyncResult<string, string>;
20
+ getOrder<T extends boolean>(id: string, matched: T): AsyncResult<T extends true ? MatchedOrder : CreateOrder, string>;
21
+ getMatchedOrders(address: string, pending: boolean, paginationConfig?: PaginationConfig): AsyncResult<PaginatedData<MatchedOrder>, string>;
22
+ getUnMatchedOrders(address: string, paginationConfig?: PaginationConfig): AsyncResult<PaginatedData<CreateOrder>, string>;
23
+ getOrders<T extends boolean>(matched: T, paginationConfig?: PaginationConfig): AsyncResult<PaginatedData<T extends true ? MatchedOrder : CreateOrder>, string>;
24
+ subscribeOrders<T extends boolean>(account: string, matched: T, interval: number, cb: (orders: PaginatedData<T extends true ? MatchedOrder : CreateOrder>) => Promise<void>, pending?: boolean, paginationConfig?: PaginationConfig): Promise<() => void>;
25
+ getOrdersCount(address: string): AsyncResult<number, string>;
43
26
  }
@@ -1,4 +1,3 @@
1
- import { WalletClient } from 'viem';
2
1
  import { AsyncResult } from '@catalogfi/utils';
3
2
  import { APIResponse, IAuth, IStore } from '@gardenfi/utils';
4
3
  import { Asset, Chain } from '../asset';
@@ -72,14 +71,6 @@ export type OrderbookOpts = {
72
71
  */
73
72
  store?: IStore;
74
73
  };
75
- /**
76
- * Interface for the configuration of an Orderbook.
77
- */
78
- export interface OrderbookConfig {
79
- url?: string;
80
- walletClient: WalletClient;
81
- auth: IAuth;
82
- }
83
74
  /**
84
75
  * Configuration for the orders you want to receive
85
76
  */
@@ -99,29 +90,62 @@ export interface IOrderbook extends IOrderProvider {
99
90
  * @param {CreateOrderConfig} orderConfig - The configuration for the creating the order.
100
91
  * @returns {number} The create order ID.
101
92
  */
102
- createOrder(order: CreateOrderRequestWithAdditionalData): AsyncResult<string, string>;
103
- /**
104
- * Wrapper for the getOrders method in the OrdersProvider class to abstract the address parameter.
105
- * @param matched - Whether to get matched or unmatched orders
106
- * @param paginationConfig - The pagination configuration
107
- * @param pending - Whether to get pending orders
108
- * @returns {AsyncResult<PaginatedData<T extends true ? MatchedOrder : CreateOrder>, string>}
109
- */
110
- fetchOrders<T extends boolean>(matched: T, pending?: boolean, paginationConfig?: PaginationConfig): AsyncResult<PaginatedData<T extends true ? MatchedOrder : CreateOrder>, string>;
111
- /**
112
- * Wrapper for the subscribeOrders method in the OrdersProvider class to abstract the address parameter.
113
- * @param matched - Whether to get matched or unmatched orders
114
- * @param interval - The interval to poll for updates
115
- * @param cb - The callback to be called when the orders are updated
116
- * @param paginationConfig - The configuration for the pagination
117
- * @returns {() => void} A function to unsubscribe from the order updates
118
- */
119
- subscribeToOrders(interval: number, cb: (orders: PaginatedData<MatchedOrder>) => Promise<void>, paginationConfig?: PaginationConfig, pending?: boolean): Promise<() => void>;
120
- /**
121
- * Get the current orders count associated with the provided address. Used to calculate nonce for secret generation.
93
+ createOrder(order: CreateOrderRequestWithAdditionalData, auth: IAuth): AsyncResult<string, string>;
94
+ /**
95
+ * Get the order from orderbook based on provided Id and match status.
96
+ * @param id - The create Id of the order
97
+ * @template T - If true, returns matched order, else returns create order (unmatched Order).
98
+ * @returns {AsyncResult<T extends true ? MatchedOrder : CreateOrder, string>} A promise that resolves to the order.
99
+ */
100
+ getOrder<T extends boolean>(id: string, matched: T): AsyncResult<T extends true ? MatchedOrder : CreateOrder, string>;
101
+ /**
102
+ * Get all matched orders from the orderbook associated with the `address`.
103
+ * @param address The address to get the orders for.
104
+ * @param pending If true, returns pending orders, else returns all matched orders.
105
+ * @param paginationConfig - The configuration for the pagination.
106
+ * @returns {AsyncResult<PaginatedData<MatchedOrder>, string>} A promise that resolves to the orders.
107
+ */
108
+ getMatchedOrders(address: string, pending: boolean, paginationConfig?: PaginationConfig): AsyncResult<PaginatedData<MatchedOrder>, string>;
109
+ /**
110
+ * Get all unmatched orders from the orderbook associated with the `address`.
111
+ * @param address The address to get the orders for.
112
+ * @param paginationConfig - The configuration for the pagination.
113
+ * @returns {AsyncResult<PaginatedData<CreateOrder>, string>} A promise that resolves to the orders.
114
+ */
115
+ getUnMatchedOrders(address: string, paginationConfig?: PaginationConfig): AsyncResult<PaginatedData<CreateOrder>, string>;
116
+ /**
117
+ * Get all orders from the orderbook based on the match status.
118
+ * @param matched - If true, returns matched orders, else returns unmatched orders.
119
+ * @param paginationConfig - The configuration for the pagination.
120
+ * @returns {AsyncResult<PaginatedData<T extends true ? MatchedOrder : CreateOrder>, string>} A promise that resolves to the orders.
121
+ */
122
+ getOrders<T extends boolean>(matched: T, paginationConfig?: PaginationConfig): AsyncResult<PaginatedData<T extends true ? MatchedOrder : CreateOrder>, string>;
123
+ /**
124
+ * Polls for every provided interval and returns matched and unmatched orders associated on the account.
125
+ * @param account The account to subscribe to
126
+ * @param matched If true, returns matched orders, else returns unmatched orders
127
+ * @param cb Th ack to be called when the orders are updated
128
+ * @param interval The interval to poll for updates
129
+ *
130
+ * Example usage:
131
+ *
132
+ * ```js
133
+ * const unsubscribe =await orderbook.subscribeOrders(account, matched, interval, handleOrders, paginationConfig);
134
+ *
135
+ * // Unsubscribe after 20 seconds
136
+ * setTimeout(() => {
137
+ * unsubscribe();
138
+ * console.log('Unsubscribed from orders');
139
+ * }, 20000);
140
+ * ```
141
+ */
142
+ subscribeOrders<T extends boolean>(account: string, matched: T, interval: number, cb: (orders: PaginatedData<T extends true ? MatchedOrder : CreateOrder>) => Promise<void>, pending?: boolean, paginationConfig?: PaginationConfig): Promise<() => void>;
143
+ /**
144
+ * Returns the current orders count associated with the provided address. Used to calculate nonce for secret generation.
145
+ * @param address The address to get the orders count for.
122
146
  * @returns {AsyncResult<number, string>} A promise that resolves to the orders count.
123
147
  */
124
- getUserOrdersCount(): AsyncResult<number, string>;
148
+ getOrdersCount(address: string): AsyncResult<number, string>;
125
149
  }
126
150
  export type DecodedAuthToken = {
127
151
  userWallet: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gardenfi/orderbook",
3
- "version": "2.0.6",
3
+ "version": "2.0.8",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -26,7 +26,7 @@
26
26
  "registry": "https://registry.npmjs.org/"
27
27
  },
28
28
  "dependencies": {
29
- "@gardenfi/utils": "^2.0.3",
29
+ "@gardenfi/utils": "^2.0.5",
30
30
  "bufferutil": "^4.0.8",
31
31
  "siwe": "^2.1.4",
32
32
  "utf-8-validate": "^6.0.3",
package/dist/index8.cjs DELETED
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=(n,o,t)=>{const r=n.endpoint(o);return t&&Object.entries(t).forEach(([c,e])=>{e!==void 0&&r.searchParams.append(c,e.toString())}),r};exports.ConstructUrl=i;
package/dist/index8.js DELETED
@@ -1,9 +0,0 @@
1
- const i = (o, e, t) => {
2
- const r = o.endpoint(e);
3
- return t && Object.entries(t).forEach(([c, n]) => {
4
- n !== void 0 && r.searchParams.append(c, n.toString());
5
- }), r;
6
- };
7
- export {
8
- i as ConstructUrl
9
- };