@gardenfi/orderbook 0.2.0-beta.41 → 0.2.0-beta.42
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 s=require("@catalogfi/utils"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@catalogfi/utils"),l=require("./index6.cjs"),c=require("@gardenfi/utils"),d=require("./index4.cjs");class i extends d.OrdersProvider{constructor(r){const e=new c.Url("/relayer",r.url??l.MAINNET_ORDERBOOK_API);super(e),this.Url=e,this.walletClient=r.walletClient,this.auth=r.auth}static async init(r){return await r.auth.getToken(),new i(r)}async createOrder(r){const e=await this.auth.getToken();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:{Authorization:c.Authorization(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 u;const n=(u=this.walletClient.account)==null?void 0:u.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=i;
|
package/dist/index2.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { Err as s, Fetcher as
|
|
2
|
-
import { MAINNET_ORDERBOOK_API as
|
|
3
|
-
import { Url as
|
|
4
|
-
import { OrdersProvider as
|
|
5
|
-
class
|
|
1
|
+
import { Err as s, Fetcher as c, Ok as o } from "@catalogfi/utils";
|
|
2
|
+
import { MAINNET_ORDERBOOK_API as l } from "./index6.js";
|
|
3
|
+
import { Url as d, Authorization as h } from "@gardenfi/utils";
|
|
4
|
+
import { OrdersProvider as O } from "./index4.js";
|
|
5
|
+
class u extends O {
|
|
6
6
|
/**
|
|
7
7
|
* Creates an instance of Orderbook. Does not login to the orderbook.
|
|
8
8
|
* @constructor
|
|
9
9
|
* @param {OrderbookConfig} orderbookConfig - The configuration object for the orderbook.
|
|
10
10
|
*/
|
|
11
11
|
constructor(r) {
|
|
12
|
-
const e = new
|
|
12
|
+
const e = new d(
|
|
13
13
|
"/relayer",
|
|
14
|
-
r.url ??
|
|
14
|
+
r.url ?? l
|
|
15
15
|
);
|
|
16
16
|
super(e), this.Url = e, this.walletClient = r.walletClient, this.auth = r.auth;
|
|
17
17
|
}
|
|
@@ -20,7 +20,7 @@ class c extends p {
|
|
|
20
20
|
* @param {OrderbookConfig} orderbookConfig - The configuration object for the orderbook.
|
|
21
21
|
*/
|
|
22
22
|
static async init(r) {
|
|
23
|
-
return await r.auth.getToken(), new
|
|
23
|
+
return await r.auth.getToken(), new u(r);
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* Creates an order
|
|
@@ -31,17 +31,17 @@ class c extends p {
|
|
|
31
31
|
const e = await this.auth.getToken();
|
|
32
32
|
if (e.error) return s(e.error);
|
|
33
33
|
try {
|
|
34
|
-
const t = await
|
|
34
|
+
const t = await c.post(
|
|
35
35
|
this.Url.endpoint("create-order"),
|
|
36
36
|
{
|
|
37
37
|
body: JSON.stringify(r),
|
|
38
38
|
headers: {
|
|
39
|
-
Authorization:
|
|
39
|
+
Authorization: h(e.val),
|
|
40
40
|
"Content-Type": "application/json"
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
);
|
|
44
|
-
return t.error ? s(t.error) : t.result ?
|
|
44
|
+
return t.error ? s(t.error) : t.result ? o(t.result) : s("CreateOrder: Unexpected error, result is undefined");
|
|
45
45
|
} catch (t) {
|
|
46
46
|
return s("CreateOrder:", String(t));
|
|
47
47
|
}
|
|
@@ -66,16 +66,16 @@ class c extends p {
|
|
|
66
66
|
* @param paginationConfig - The configuration for the pagination
|
|
67
67
|
* @returns {() => void} A function to unsubscribe from the order updates
|
|
68
68
|
*/
|
|
69
|
-
async subscribeToOrders(r, e, t, a
|
|
70
|
-
var
|
|
71
|
-
const
|
|
72
|
-
return
|
|
73
|
-
|
|
69
|
+
async subscribeToOrders(r, e, t, a) {
|
|
70
|
+
var i;
|
|
71
|
+
const n = (i = this.walletClient.account) == null ? void 0 : i.address;
|
|
72
|
+
return n ? await super.subscribeOrders(
|
|
73
|
+
n,
|
|
74
|
+
!0,
|
|
74
75
|
r,
|
|
75
76
|
e,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
a
|
|
77
|
+
a,
|
|
78
|
+
t
|
|
79
79
|
) : () => {
|
|
80
80
|
};
|
|
81
81
|
}
|
|
@@ -86,5 +86,5 @@ class c extends p {
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
export {
|
|
89
|
-
|
|
89
|
+
u as Orderbook
|
|
90
90
|
};
|
|
@@ -38,6 +38,6 @@ export declare class Orderbook extends OrdersProvider implements IOrderbook {
|
|
|
38
38
|
* @param paginationConfig - The configuration for the pagination
|
|
39
39
|
* @returns {() => void} A function to unsubscribe from the order updates
|
|
40
40
|
*/
|
|
41
|
-
subscribeToOrders
|
|
41
|
+
subscribeToOrders(interval: number, cb: (orders: PaginatedData<MatchedOrder>) => Promise<void>, paginationConfig?: PaginationConfig, pending?: boolean): Promise<() => void>;
|
|
42
42
|
getUserOrdersCount(): AsyncResult<number, string>;
|
|
43
43
|
}
|
|
@@ -116,7 +116,7 @@ export interface IOrderbook extends IOrderProvider {
|
|
|
116
116
|
* @param paginationConfig - The configuration for the pagination
|
|
117
117
|
* @returns {() => void} A function to unsubscribe from the order updates
|
|
118
118
|
*/
|
|
119
|
-
subscribeToOrders
|
|
119
|
+
subscribeToOrders(interval: number, cb: (orders: PaginatedData<MatchedOrder>) => Promise<void>, paginationConfig?: PaginationConfig, pending?: boolean): Promise<() => void>;
|
|
120
120
|
/**
|
|
121
121
|
* Get the current orders count associated with the provided address. Used to calculate nonce for secret generation.
|
|
122
122
|
* @returns {AsyncResult<number, string>} A promise that resolves to the orders count.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gardenfi/orderbook",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.42",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@catalogfi/utils": "^0.1.6",
|
|
30
|
-
"@gardenfi/utils": "^0.0.1-beta.
|
|
30
|
+
"@gardenfi/utils": "^0.0.1-beta.20",
|
|
31
31
|
"bufferutil": "^4.0.8",
|
|
32
32
|
"siwe": "^2.1.4",
|
|
33
33
|
"utf-8-validate": "^6.0.3",
|