@gardenfi/orderbook 0.2.0-beta.3 → 0.2.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index2.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@catalogfi/utils"),c=require("./index6.cjs"),h=require("./index7.cjs"),u=require("@gardenfi/utils"),f=require("./index4.cjs"),O=require("./index3.cjs");class A extends f.OrdersProvider{constructor(r){var s;const t=new u.Url("/relayer",r.url??h.MAINNET_ORDERBOOK_API);super(t),this.Url=t,this.walletClient=r.walletClient,this.auth=new u.Siwe(this.Url,r.walletClient,{...r.opts,store:((s=r.opts)==null?void 0:s.store)||new u.MemoryStorage})}static async init(r){return await new u.Siwe(new u.Url("/relayer",r.url??h.MAINNET_ORDERBOOK_API),r.walletClient,r.opts).getToken(),new A(r)}async createOrder(r){const{sendAmount:t,secretHash:s,receiveAmount:n,fromAsset:i,toAsset:a,receiveAddress:o,sendAddress:_,minDestinationConfirmations:w=0,timelock:p,btcInputAddress:m}=r,E=this.validateConfig(r);if(E.error)return e.Err(E.error);const l=await this.auth.getToken();if(l.error)return e.Err(l.error);const S={additional_data:{bitcoin_optional_recipient:m??""}},I={nonce:r.nonce,source_amount:t,destination_amount:n,source_asset:i.atomicSwapAddress,destination_asset:a.atomicSwapAddress,secret_hash:e.trim0x(s),source_chain:i.chain,destination_chain:a.chain,initiator_source_address:_,initiator_destination_address:o,min_destination_confirmations:w,timelock:p,...S,fee:"1"};try{const d=await e.Fetcher.post(this.Url.endpoint("create-order"),{body:JSON.stringify(I),headers:{Authorization:u.Authorization(l.val),"Content-Type":"application/json"}});return d.error?e.Err(d.error):d.result?e.Ok(d.result):e.Err("CreateOrder: Unexpected error, result is undefined")}catch(d){return e.Err("CreateOrder:",String(d))}}async fetchOrders(r,t=!1,s){var i;const n=(i=this.walletClient.account)==null?void 0:i.address;return n?r?await super.getMatchedOrders(n,t,s):await super.getUnMatchedOrders(n,s):e.Err("Wallet client does not have an account")}async subscribeToOrders(r,t,s,n,i){var o;const a=(o=this.walletClient.account)==null?void 0:o.address;return a?await super.subscribeOrders(a,r,t,s,n,i):()=>{}}async getUserOrdersCount(){var t;const r=(t=this.walletClient.account)==null?void 0:t.address;return r?super.getOrdersCount(r):e.Err("Wallet client does not have an account")}validateConfig(r){const{sendAmount:t,receiveAmount:s,toAsset:n,fromAsset:i}=r;if(n.atomicSwapAddress.toLowerCase()===i.atomicSwapAddress.toLowerCase()&&n.chain===i.chain)return e.Err(c.OrderbookErrors.SAME_ASSET);if(!O.isBitcoin(n.chain)&&!n.atomicSwapAddress||!O.isBitcoin(i.chain)&&!i.atomicSwapAddress)return e.Err(c.OrderbookErrors.INVALID_AS_ADDRESS);if(!n.tokenAddress||!i.tokenAddress)return e.Err(c.OrderbookErrors.INVALID_TOKEN);const a=BigInt(t),o=BigInt(s);return t==null||a<=0n||t.includes(".")?e.Err(c.OrderbookErrors.INVALID_SEND_AMOUNT):s==null||o<=0n||s.includes(".")?e.Err(c.OrderbookErrors.INVALID_RECEIVE_AMOUNT):a<o?e.Err(c.OrderbookErrors.RECEIVE_AMOUNT_GREATER):e.Ok(e.Void)}}exports.Orderbook=A;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@catalogfi/utils"),d=require("./index6.cjs"),a=require("@gardenfi/utils"),o=require("./index4.cjs");class u extends o.OrdersProvider{constructor(e){var t;const r=new a.Url("/relayer",e.url??d.MAINNET_ORDERBOOK_API);super(r),this.Url=r,this.walletClient=e.walletClient,this.auth=new a.Siwe(this.Url,e.walletClient,{...e.opts,store:((t=e.opts)==null?void 0:t.store)||new a.MemoryStorage})}static async init(e){return await new a.Siwe(new a.Url("/relayer",e.url??d.MAINNET_ORDERBOOK_API),e.walletClient,e.opts).getToken(),new u(e)}async createOrder(e){const r=await this.auth.getToken();if(r.error)return s.Err(r.error);try{const t=await s.Fetcher.post(this.Url.endpoint("create-order"),{body:JSON.stringify(e),headers:{Authorization:a.Authorization(r.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(e,r=!1,t){var i;const n=(i=this.walletClient.account)==null?void 0:i.address;return n?e?await super.getMatchedOrders(n,r,t):await super.getUnMatchedOrders(n,t):s.Err("Wallet client does not have an account")}async subscribeToOrders(e,r,t,n,i){var c;const l=(c=this.walletClient.account)==null?void 0:c.address;return l?await super.subscribeOrders(l,e,r,t,n,i):()=>{}}async getUserOrdersCount(){var r;const e=(r=this.walletClient.account)==null?void 0:r.address;return e?super.getOrdersCount(e):s.Err("Wallet client does not have an account")}}exports.Orderbook=u;
package/dist/index2.js CHANGED
@@ -1,104 +1,70 @@
1
- import { Err as r, trim0x as y, Fetcher as D, Ok as A, Void as T } from "@catalogfi/utils";
2
- import { OrderbookErrors as c } from "./index6.js";
3
- import { MAINNET_ORDERBOOK_API as h } from "./index7.js";
4
- import { Url as m, Siwe as p, MemoryStorage as U, Authorization as v } from "@gardenfi/utils";
5
- import { OrdersProvider as C } from "./index4.js";
6
- import { isBitcoin as _ } from "./index3.js";
7
- class w extends C {
1
+ import { Err as s, Fetcher as h, Ok as w } from "@catalogfi/utils";
2
+ import { MAINNET_ORDERBOOK_API as u } from "./index6.js";
3
+ import { Url as c, Siwe as d, MemoryStorage as p, Authorization as O } from "@gardenfi/utils";
4
+ import { OrdersProvider as y } from "./index4.js";
5
+ class o extends y {
8
6
  /**
9
7
  * Creates an instance of Orderbook. Does not login to the orderbook.
10
8
  * @constructor
11
9
  * @param {OrderbookConfig} orderbookConfig - The configuration object for the orderbook.
12
10
  */
13
- constructor(t) {
14
- var s;
15
- const e = new m(
11
+ constructor(e) {
12
+ var r;
13
+ const t = new c(
16
14
  "/relayer",
17
- t.url ?? h
15
+ e.url ?? u
18
16
  );
19
- super(e), this.Url = e, this.walletClient = t.walletClient, this.auth = new p(this.Url, t.walletClient, {
20
- ...t.opts,
21
- store: ((s = t.opts) == null ? void 0 : s.store) || new U()
17
+ super(t), this.Url = t, this.walletClient = e.walletClient, this.auth = new d(this.Url, e.walletClient, {
18
+ ...e.opts,
19
+ store: ((r = e.opts) == null ? void 0 : r.store) || new p()
22
20
  });
23
21
  }
24
22
  /**
25
23
  * Initializes the orderbook as well as logs in the orderbook (fetches the auth token).
26
24
  * @param {OrderbookConfig} orderbookConfig - The configuration object for the orderbook.
27
25
  */
28
- static async init(t) {
29
- return await new p(
30
- new m("/relayer", t.url ?? h),
31
- t.walletClient,
32
- t.opts
33
- ).getToken(), new w(t);
26
+ static async init(e) {
27
+ return await new d(
28
+ new c("/relayer", e.url ?? u),
29
+ e.walletClient,
30
+ e.opts
31
+ ).getToken(), new o(e);
34
32
  }
35
33
  /**
36
34
  * Creates an order
37
35
  * @param {CreateOrderConfig} createOrderConfig - The configuration for the creating the order.
38
36
  * @returns {string} The create order ID.
39
37
  */
40
- async createOrder(t) {
41
- const {
42
- sendAmount: e,
43
- secretHash: s,
44
- receiveAmount: n,
45
- fromAsset: i,
46
- toAsset: a,
47
- receiveAddress: o,
48
- sendAddress: f,
49
- minDestinationConfirmations: O = 0,
50
- timelock: S,
51
- btcInputAddress: E
52
- } = t, l = this.validateConfig(t);
53
- if (l.error) return r(l.error);
54
- const u = await this.auth.getToken();
55
- if (u.error) return r(u.error);
56
- const I = {
57
- additional_data: { bitcoin_optional_recipient: E ?? "" }
58
- }, N = {
59
- nonce: t.nonce,
60
- source_amount: e,
61
- destination_amount: n,
62
- source_asset: i.atomicSwapAddress,
63
- destination_asset: a.atomicSwapAddress,
64
- secret_hash: y(s),
65
- source_chain: i.chain,
66
- destination_chain: a.chain,
67
- initiator_source_address: f,
68
- initiator_destination_address: o,
69
- min_destination_confirmations: O,
70
- timelock: S,
71
- ...I,
72
- //signature:''
73
- fee: "1"
74
- };
38
+ async createOrder(e) {
39
+ const t = await this.auth.getToken();
40
+ if (t.error) return s(t.error);
75
41
  try {
76
- const d = await D.post(
42
+ const r = await h.post(
77
43
  this.Url.endpoint("create-order"),
78
44
  {
79
- body: JSON.stringify(N),
45
+ body: JSON.stringify(e),
80
46
  headers: {
81
- Authorization: v(u.val),
47
+ Authorization: O(t.val),
82
48
  "Content-Type": "application/json"
83
49
  }
84
50
  }
85
51
  );
86
- return d.error ? r(d.error) : d.result ? A(d.result) : r("CreateOrder: Unexpected error, result is undefined");
87
- } catch (d) {
88
- return r("CreateOrder:", String(d));
52
+ return r.error ? s(r.error) : r.result ? w(r.result) : s("CreateOrder: Unexpected error, result is undefined");
53
+ } catch (r) {
54
+ return s("CreateOrder:", String(r));
89
55
  }
90
56
  }
91
- async fetchOrders(t, e = !1, s) {
92
- var i;
93
- const n = (i = this.walletClient.account) == null ? void 0 : i.address;
94
- return n ? t ? await super.getMatchedOrders(
95
- n,
96
- e,
97
- s
57
+ async fetchOrders(e, t = !1, r) {
58
+ var n;
59
+ const a = (n = this.walletClient.account) == null ? void 0 : n.address;
60
+ return a ? e ? await super.getMatchedOrders(
61
+ a,
62
+ t,
63
+ r
98
64
  ) : await super.getUnMatchedOrders(
99
- n,
100
- s
101
- ) : r("Wallet client does not have an account");
65
+ a,
66
+ r
67
+ ) : s("Wallet client does not have an account");
102
68
  }
103
69
  /**
104
70
  * Wrapper for the subscribeOrders method in the OrdersProvider class to abstract the address parameter.
@@ -108,38 +74,25 @@ class w extends C {
108
74
  * @param paginationConfig - The configuration for the pagination
109
75
  * @returns {() => void} A function to unsubscribe from the order updates
110
76
  */
111
- async subscribeToOrders(t, e, s, n, i) {
112
- var o;
113
- const a = (o = this.walletClient.account) == null ? void 0 : o.address;
114
- return a ? await super.subscribeOrders(
115
- a,
116
- t,
77
+ async subscribeToOrders(e, t, r, a, n) {
78
+ var l;
79
+ const i = (l = this.walletClient.account) == null ? void 0 : l.address;
80
+ return i ? await super.subscribeOrders(
81
+ i,
117
82
  e,
118
- s,
119
- n,
120
- i
83
+ t,
84
+ r,
85
+ a,
86
+ n
121
87
  ) : () => {
122
88
  };
123
89
  }
124
90
  async getUserOrdersCount() {
125
- var e;
126
- const t = (e = this.walletClient.account) == null ? void 0 : e.address;
127
- return t ? super.getOrdersCount(t) : r("Wallet client does not have an account");
128
- }
129
- validateConfig(t) {
130
- const { sendAmount: e, receiveAmount: s, toAsset: n, fromAsset: i } = t;
131
- if (n.atomicSwapAddress.toLowerCase() === i.atomicSwapAddress.toLowerCase() && n.chain === i.chain)
132
- return r(c.SAME_ASSET);
133
- if (!_(n.chain) && !n.atomicSwapAddress)
134
- return r(c.INVALID_AS_ADDRESS);
135
- if (!_(i.chain) && !i.atomicSwapAddress)
136
- return r(c.INVALID_AS_ADDRESS);
137
- if (!n.tokenAddress || !i.tokenAddress)
138
- return r(c.INVALID_TOKEN);
139
- const a = BigInt(e), o = BigInt(s);
140
- return e == null || a <= 0n || e.includes(".") ? r(c.INVALID_SEND_AMOUNT) : s == null || o <= 0n || s.includes(".") ? r(c.INVALID_RECEIVE_AMOUNT) : a < o ? r(c.RECEIVE_AMOUNT_GREATER) : A(T);
91
+ var t;
92
+ const e = (t = this.walletClient.account) == null ? void 0 : t.address;
93
+ return e ? super.getOrdersCount(e) : s("Wallet client does not have an account");
141
94
  }
142
95
  }
143
96
  export {
144
- w as Orderbook
97
+ o as Orderbook
145
98
  };
package/dist/index4.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("@catalogfi/utils"),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("@catalogfi/utils"),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 "@catalogfi/utils";
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/index6.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={INVALID_SEND_AMOUNT:"invalid send amount",INVALID_RECEIVE_AMOUNT:"invalid receive amount",UNSUPPORTED_CHAIN:"unsupported chain",SAME_ASSET:"cannot create orderpair with the same assets",INVALID_AS_ADDRESS:"invalid atomic swap address",INVALID_TOKEN:"invalid token address",INVALID_AMOUNTS:"invalid amounts",RECEIVE_AMOUNT_GREATER:"receive amount is greater than send amount"};exports.OrderbookErrors=e;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="https://api.garden.finance";exports.MAINNET_ORDERBOOK_API=e;
package/dist/index6.js CHANGED
@@ -1,13 +1,4 @@
1
- const a = {
2
- INVALID_SEND_AMOUNT: "invalid send amount",
3
- INVALID_RECEIVE_AMOUNT: "invalid receive amount",
4
- UNSUPPORTED_CHAIN: "unsupported chain",
5
- SAME_ASSET: "cannot create orderpair with the same assets",
6
- INVALID_AS_ADDRESS: "invalid atomic swap address",
7
- INVALID_TOKEN: "invalid token address",
8
- INVALID_AMOUNTS: "invalid amounts",
9
- RECEIVE_AMOUNT_GREATER: "receive amount is greater than send amount"
10
- };
1
+ const n = "https://api.garden.finance";
11
2
  export {
12
- a as OrderbookErrors
3
+ n as MAINNET_ORDERBOOK_API
13
4
  };
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,5 +1,5 @@
1
1
  import { AsyncResult } from '@catalogfi/utils';
2
- import { CreateOrder, CreateOrderConfig, IOrderbook, MatchedOrder, OrderbookConfig, PaginatedData, PaginationConfig } from './orderbook.types';
2
+ import { CreateOrder, CreateOrderRequestWithAdditionalData, IOrderbook, MatchedOrder, OrderbookConfig, PaginatedData, PaginationConfig } from './orderbook.types';
3
3
  import { OrdersProvider } from '../orders/ordersProvider';
4
4
 
5
5
  /**
@@ -28,7 +28,7 @@ export declare class Orderbook extends OrdersProvider implements IOrderbook {
28
28
  * @param {CreateOrderConfig} createOrderConfig - The configuration for the creating the order.
29
29
  * @returns {string} The create order ID.
30
30
  */
31
- createOrder(createOrderConfig: CreateOrderConfig): AsyncResult<string, string>;
31
+ createOrder(order: CreateOrderRequestWithAdditionalData): AsyncResult<string, string>;
32
32
  fetchOrders<T extends boolean>(matched: T, pending?: boolean, paginationConfig?: PaginationConfig): AsyncResult<PaginatedData<T extends true ? MatchedOrder : CreateOrder>, string>;
33
33
  /**
34
34
  * Wrapper for the subscribeOrders method in the OrdersProvider class to abstract the address parameter.
@@ -40,5 +40,4 @@ export declare class Orderbook extends OrdersProvider implements IOrderbook {
40
40
  */
41
41
  subscribeToOrders<T extends boolean>(matched: T, interval: number, cb: (orders: PaginatedData<T extends true ? MatchedOrder : CreateOrder>) => Promise<void>, pending?: boolean, paginationConfig?: PaginationConfig): Promise<() => void>;
42
42
  getUserOrdersCount(): AsyncResult<number, string>;
43
- private validateConfig;
44
43
  }
@@ -99,7 +99,7 @@ export interface IOrderbook extends IOrderProvider {
99
99
  * @param {CreateOrderConfig} orderConfig - The configuration for the creating the order.
100
100
  * @returns {number} The create order ID.
101
101
  */
102
- createOrder(orderConfig: CreateOrderConfig): AsyncResult<string, string>;
102
+ createOrder(order: CreateOrderRequestWithAdditionalData): AsyncResult<string, string>;
103
103
  /**
104
104
  * Wrapper for the getOrder method in the OrdersProvider class to abstract the address parameter.
105
105
  * @param matched - Whether to get matched or unmatched orders
@@ -132,6 +132,25 @@ export type Orders = {
132
132
  unmatched: PaginatedData<CreateOrder[]>;
133
133
  matched: PaginatedData<MatchedOrder[]>;
134
134
  };
135
+ export type AdditionalData = {
136
+ additional_data: {
137
+ strategy_id: string;
138
+ sig: string;
139
+ input_token_price: number;
140
+ output_token_price: number;
141
+ deadline: string;
142
+ bitcoin_optional_recipient?: string;
143
+ [key: string]: any;
144
+ };
145
+ };
146
+ export type AdditionalDataWithStrategyId = {
147
+ additional_data: {
148
+ strategy_id: string;
149
+ bitcoin_optional_recipient?: string;
150
+ [key: string]: any;
151
+ };
152
+ };
153
+ export type CreateOrderReqWithStrategyId = CreateOrderRequest & AdditionalDataWithStrategyId;
135
154
  export type CreateOrderRequest = {
136
155
  source_chain: string;
137
156
  destination_chain: string;
@@ -146,11 +165,9 @@ export type CreateOrderRequest = {
146
165
  min_destination_confirmations: number;
147
166
  timelock: number;
148
167
  secret_hash: string;
149
- additional_data?: {
150
- bitcoin_optional_recipient: string;
151
- };
152
168
  };
153
- export type CreateOrder = CreateOrderRequest & {
169
+ export type CreateOrderRequestWithAdditionalData = CreateOrderRequest & AdditionalData;
170
+ export type CreateOrder = CreateOrderRequestWithAdditionalData & {
154
171
  created_at: string;
155
172
  updated_at: string;
156
173
  deleted_at: string | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gardenfi/orderbook",
3
- "version": "0.2.0-beta.3",
3
+ "version": "0.2.0-beta.4",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -28,7 +28,7 @@
28
28
  "dependencies": {
29
29
  "@catalogfi/utils": "^0.1.6",
30
30
  "@catalogfi/wallets": "0.2.43",
31
- "@gardenfi/utils": "^0.0.1-beta.3",
31
+ "@gardenfi/utils": "^0.0.1-beta.4",
32
32
  "bufferutil": "^4.0.8",
33
33
  "siwe": "^2.1.4",
34
34
  "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
- };