@nadohq/engine-client 0.19.1 → 0.21.0
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/{EngineBaseClient-DOOXIhnZ.d.ts → EngineBaseClient-Cn4PMYKt.d.ts} +30 -5
- package/dist/EngineBaseClient-Cn4PMYKt.d.ts.map +1 -0
- package/dist/{EngineBaseClient-L1ue7jBx.d.cts → EngineBaseClient-a2leWTER.d.cts} +30 -5
- package/dist/EngineBaseClient-a2leWTER.d.cts.map +1 -0
- package/dist/{EngineBaseClient-Uc1D8ftx.cjs → EngineBaseClient-zgQmbhJv.cjs} +41 -7
- package/dist/EngineBaseClient-zgQmbhJv.cjs.map +1 -0
- package/dist/EngineBaseClient.cjs +1 -1
- package/dist/EngineBaseClient.d.cts +1 -1
- package/dist/EngineBaseClient.d.ts +1 -1
- package/dist/EngineBaseClient.js +40 -6
- package/dist/EngineBaseClient.js.map +1 -1
- package/dist/EngineClient.cjs +4 -3
- package/dist/EngineClient.cjs.map +1 -1
- package/dist/EngineClient.d.cts +6 -5
- package/dist/EngineClient.d.cts.map +1 -1
- package/dist/EngineClient.d.ts +6 -5
- package/dist/EngineClient.d.ts.map +1 -1
- package/dist/EngineClient.js +3 -2
- package/dist/EngineClient.js.map +1 -1
- package/dist/EngineEdgeQueryClient-B9Y8srJa.d.ts +79 -0
- package/dist/EngineEdgeQueryClient-B9Y8srJa.d.ts.map +1 -0
- package/dist/EngineEdgeQueryClient-CPEDAOd0.d.cts +79 -0
- package/dist/EngineEdgeQueryClient-CPEDAOd0.d.cts.map +1 -0
- package/dist/EngineEdgeQueryClient.cjs +143 -0
- package/dist/EngineEdgeQueryClient.cjs.map +1 -0
- package/dist/EngineEdgeQueryClient.d.cts +2 -0
- package/dist/EngineEdgeQueryClient.d.ts +2 -0
- package/dist/EngineEdgeQueryClient.js +142 -0
- package/dist/EngineEdgeQueryClient.js.map +1 -0
- package/dist/{EngineExecuteBuilder-t8EQ5Rmp.d.ts → EngineExecuteBuilder-BXKoW0uz.d.ts} +2 -2
- package/dist/{EngineExecuteBuilder-t8EQ5Rmp.d.ts.map → EngineExecuteBuilder-BXKoW0uz.d.ts.map} +1 -1
- package/dist/{EngineExecuteBuilder-VLrEndhv.d.cts → EngineExecuteBuilder-BaMHTuf-.d.cts} +2 -2
- package/dist/{EngineExecuteBuilder-VLrEndhv.d.cts.map → EngineExecuteBuilder-BaMHTuf-.d.cts.map} +1 -1
- package/dist/EngineExecuteBuilder.cjs +1 -1
- package/dist/EngineExecuteBuilder.d.cts +1 -1
- package/dist/EngineExecuteBuilder.d.ts +1 -1
- package/dist/{EngineExecuteClient-BGlNK5Le.d.cts → EngineExecuteClient-BLUkw1vR.d.cts} +3 -3
- package/dist/{EngineExecuteClient-BGlNK5Le.d.cts.map → EngineExecuteClient-BLUkw1vR.d.cts.map} +1 -1
- package/dist/{EngineExecuteClient-0EBoXRd7.d.ts → EngineExecuteClient-ReEcySA_.d.ts} +3 -3
- package/dist/{EngineExecuteClient-0EBoXRd7.d.ts.map → EngineExecuteClient-ReEcySA_.d.ts.map} +1 -1
- package/dist/EngineExecuteClient.cjs +1 -1
- package/dist/EngineExecuteClient.d.cts +1 -1
- package/dist/EngineExecuteClient.d.ts +1 -1
- package/dist/{EngineQueryClient-C_7p1oRx.d.cts → EngineQueryClient-Br-BC5LQ.d.cts} +3 -3
- package/dist/{EngineQueryClient-C_7p1oRx.d.cts.map → EngineQueryClient-Br-BC5LQ.d.cts.map} +1 -1
- package/dist/{EngineQueryClient-DQwCRaYl.d.ts → EngineQueryClient-C0xBMTo-.d.ts} +3 -3
- package/dist/{EngineQueryClient-DQwCRaYl.d.ts.map → EngineQueryClient-C0xBMTo-.d.ts.map} +1 -1
- package/dist/EngineQueryClient.cjs +1 -1
- package/dist/EngineQueryClient.d.cts +1 -1
- package/dist/EngineQueryClient.d.ts +1 -1
- package/dist/{EngineWebClient-CEwqgd4t.d.ts → EngineWebClient-KXOdpUol.d.ts} +3 -3
- package/dist/{EngineWebClient-CEwqgd4t.d.ts.map → EngineWebClient-KXOdpUol.d.ts.map} +1 -1
- package/dist/{EngineWebClient-DajZqKAQ.d.cts → EngineWebClient-i8BslipN.d.cts} +3 -3
- package/dist/{EngineWebClient-DajZqKAQ.d.cts.map → EngineWebClient-i8BslipN.d.cts.map} +1 -1
- package/dist/EngineWebClient.cjs +1 -1
- package/dist/EngineWebClient.d.cts +1 -1
- package/dist/EngineWebClient.d.ts +1 -1
- package/dist/{clientQueryTypes-DlTtS_mX.d.cts → clientQueryTypes-BTKfuoGI.d.cts} +39 -2
- package/dist/{clientQueryTypes-DlTtS_mX.d.cts.map → clientQueryTypes-BTKfuoGI.d.cts.map} +1 -1
- package/dist/{clientQueryTypes-DuRgEeBT.d.ts → clientQueryTypes-BaYOTnpm.d.ts} +39 -2
- package/dist/{clientQueryTypes-DuRgEeBT.d.ts.map → clientQueryTypes-BaYOTnpm.d.ts.map} +1 -1
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +6 -5
- package/dist/index.d.ts +6 -5
- package/dist/index.js +2 -2
- package/dist/{queryDataMappers-BguxA579.d.ts → queryDataMappers-CyUgQn0_.d.ts} +5 -3
- package/dist/{queryDataMappers-DO9yWdLo.d.cts.map → queryDataMappers-CyUgQn0_.d.ts.map} +1 -1
- package/dist/{queryDataMappers-DO9yWdLo.d.cts → queryDataMappers-kC-SPiHX.d.cts} +5 -3
- package/dist/queryDataMappers-kC-SPiHX.d.cts.map +1 -0
- package/dist/serverEdgeQueryTypes-BpMlbsCD.d.cts +100 -0
- package/dist/serverEdgeQueryTypes-BpMlbsCD.d.cts.map +1 -0
- package/dist/serverEdgeQueryTypes-DbSUWFzo.d.ts +100 -0
- package/dist/serverEdgeQueryTypes-DbSUWFzo.d.ts.map +1 -0
- package/dist/{serverSubscriptionEventTypes-CbT2Fx8Y.d.ts → serverSubscriptionEventTypes-Co3utjCs.d.ts} +1 -1
- package/dist/{serverSubscriptionEventTypes-CbT2Fx8Y.d.ts.map → serverSubscriptionEventTypes-Co3utjCs.d.ts.map} +1 -1
- package/dist/{serverSubscriptionEventTypes-UorThoIE.d.cts → serverSubscriptionEventTypes-CpmdNk1G.d.cts} +1 -1
- package/dist/{serverSubscriptionEventTypes-UorThoIE.d.cts.map → serverSubscriptionEventTypes-CpmdNk1G.d.cts.map} +1 -1
- package/dist/{serverSubscriptionTypes-CE6BIS-C.d.cts → serverSubscriptionTypes-BA92bWic.d.cts} +1 -1
- package/dist/{serverSubscriptionTypes-CE6BIS-C.d.cts.map → serverSubscriptionTypes-BA92bWic.d.cts.map} +1 -1
- package/dist/{serverSubscriptionTypes-Cgz-h0ot.d.ts → serverSubscriptionTypes-CEis5IgT.d.ts} +1 -1
- package/dist/{serverSubscriptionTypes-Cgz-h0ot.d.ts.map → serverSubscriptionTypes-CEis5IgT.d.ts.map} +1 -1
- package/dist/types/clientQueryTypes.d.cts +2 -2
- package/dist/types/clientQueryTypes.d.ts +2 -2
- package/dist/types/index.d.cts +5 -4
- package/dist/types/index.d.ts +5 -4
- package/dist/types/serverEdgeQueryTypes.cjs +0 -0
- package/dist/types/serverEdgeQueryTypes.d.cts +2 -0
- package/dist/types/serverEdgeQueryTypes.d.ts +2 -0
- package/dist/types/serverEdgeQueryTypes.js +1 -0
- package/dist/types/serverSubscriptionEventTypes.d.cts +1 -1
- package/dist/types/serverSubscriptionEventTypes.d.ts +1 -1
- package/dist/types/serverSubscriptionTypes.d.cts +1 -1
- package/dist/types/serverSubscriptionTypes.d.ts +1 -1
- package/dist/utils/index.cjs +1 -0
- package/dist/utils/index.d.cts +2 -2
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.js +2 -2
- package/dist/utils/productEngineTypeMappers.cjs +1 -1
- package/dist/utils/queryDataMappers.cjs +14 -1
- package/dist/utils/queryDataMappers.cjs.map +1 -1
- package/dist/utils/queryDataMappers.d.cts +2 -2
- package/dist/utils/queryDataMappers.d.ts +2 -2
- package/dist/utils/queryDataMappers.js +13 -1
- package/dist/utils/queryDataMappers.js.map +1 -1
- package/package.json +3 -3
- package/src/EngineBaseClient.ts +86 -10
- package/src/EngineClient.ts +3 -1
- package/src/EngineEdgeQueryClient.ts +211 -0
- package/src/types/clientQueryTypes.ts +54 -0
- package/src/types/index.ts +1 -0
- package/src/types/serverEdgeQueryTypes.ts +153 -0
- package/src/utils/queryDataMappers.ts +17 -0
- package/dist/EngineBaseClient-DOOXIhnZ.d.ts.map +0 -1
- package/dist/EngineBaseClient-L1ue7jBx.d.cts.map +0 -1
- package/dist/EngineBaseClient-Uc1D8ftx.cjs.map +0 -1
- package/dist/queryDataMappers-BguxA579.d.ts.map +0 -1
- /package/dist/{index-CmCelmEL.d.cts → index-D6CnpA_r.d.cts} +0 -0
- /package/dist/{index-D0E78WnU.d.ts → index-DhI2LvVQ.d.ts} +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { G as EngineServerQueryResponseByType, H as EngineServerQueryRequestByType, U as EngineServerQueryRequestType
|
|
1
|
+
import { G as EngineServerQueryResponseByType, H as EngineServerQueryRequestByType, U as EngineServerQueryRequestType } from "./serverQueryTypes-B3vC8vxT.js";
|
|
2
2
|
import { a as EngineServerExecuteRequestByType, l as EngineServerExecuteSuccessResult, o as EngineServerExecuteRequestType } from "./serverExecuteTypes-CgbHjnWM.js";
|
|
3
|
-
import {
|
|
3
|
+
import { G as GetEngineNoncesResponse, W as GetEngineNoncesParams } from "./clientQueryTypes-BaYOTnpm.js";
|
|
4
|
+
import { a as EngineServerCachedQueryRequestByType, c as EngineServerCachedQueryResponseByType, d as EngineServerEdgeControlRequestByType, f as EngineServerEdgeControlRequestType, o as EngineServerCachedQueryRequestType, p as EngineServerEdgeControlResponseByType } from "./serverEdgeQueryTypes-DbSUWFzo.js";
|
|
4
5
|
import { SignableRequestType, SignableRequestTypeToParams, WalletClientWithAccount } from "@nadohq/shared";
|
|
5
6
|
import { AxiosInstance } from "axios";
|
|
6
7
|
|
|
@@ -35,12 +36,25 @@ declare class EngineBaseClient {
|
|
|
35
36
|
*/
|
|
36
37
|
query<TRequestType extends EngineServerQueryRequestType>(requestType: TRequestType, params: EngineServerQueryRequestByType[TRequestType]): Promise<EngineServerQueryResponseByType[TRequestType]>;
|
|
37
38
|
/**
|
|
38
|
-
*
|
|
39
|
+
* Queries the gateway's in-memory cache via the `/edge/query` endpoint. Lower latency than
|
|
40
|
+
* {@link query} at the cost of eventual consistency — do not use for order, margin, or
|
|
41
|
+
* settlement decisions.
|
|
39
42
|
*
|
|
40
43
|
* @param requestType
|
|
41
44
|
* @param params
|
|
45
|
+
* @public
|
|
46
|
+
*/
|
|
47
|
+
edgeQuery<TRequestType extends EngineServerCachedQueryRequestType>(requestType: TRequestType, params: EngineServerCachedQueryRequestByType[TRequestType]): Promise<EngineServerCachedQueryResponseByType[TRequestType]>;
|
|
48
|
+
/**
|
|
49
|
+
* Sends an edge control message (`ping` / `time`) via the `/edge/query` endpoint. These
|
|
50
|
+
* return immediately from the server clock and use a different envelope than the cached data
|
|
51
|
+
* queries (no `data` field), so the whole response body is returned.
|
|
52
|
+
*
|
|
53
|
+
* @param requestType
|
|
54
|
+
* @param params
|
|
55
|
+
* @public
|
|
42
56
|
*/
|
|
43
|
-
|
|
57
|
+
edgeControlQuery<TRequestType extends EngineServerEdgeControlRequestType>(requestType: TRequestType, params: EngineServerEdgeControlRequestByType[TRequestType]): Promise<EngineServerEdgeControlResponseByType[TRequestType]>;
|
|
44
58
|
/**
|
|
45
59
|
* POSTs an execute message to the engine and returns the successful response. Throws the failure response wrapped
|
|
46
60
|
* in an EngineServerFailureError on failure.
|
|
@@ -50,6 +64,17 @@ declare class EngineBaseClient {
|
|
|
50
64
|
* @public
|
|
51
65
|
*/
|
|
52
66
|
execute<TRequestType extends EngineServerExecuteRequestType>(requestType: TRequestType, params: EngineServerExecuteRequestByType[TRequestType]): Promise<EngineServerExecuteSuccessResult<TRequestType>>;
|
|
67
|
+
/**
|
|
68
|
+
* A simple, typechecked fn for constructing a `type`-tagged request body in the format expected
|
|
69
|
+
* by the server. Generic over the request type / params pair so it can build live query, edge
|
|
70
|
+
* (cached) query, and edge control request bodies alike.
|
|
71
|
+
*
|
|
72
|
+
* @param requestType
|
|
73
|
+
* @param params
|
|
74
|
+
*/
|
|
75
|
+
getQueryRequest<TRequestType extends string, TParams extends object>(requestType: TRequestType, params: TParams): {
|
|
76
|
+
type: TRequestType;
|
|
77
|
+
} & TParams;
|
|
53
78
|
/**
|
|
54
79
|
* A simple, typechecked fn for constructing an execute request in the format expected by the server.
|
|
55
80
|
*
|
|
@@ -72,4 +97,4 @@ declare class EngineBaseClient {
|
|
|
72
97
|
}
|
|
73
98
|
//#endregion
|
|
74
99
|
export { EngineClientOpts as n, EngineBaseClient as t };
|
|
75
|
-
//# sourceMappingURL=EngineBaseClient-
|
|
100
|
+
//# sourceMappingURL=EngineBaseClient-Cn4PMYKt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EngineBaseClient-Cn4PMYKt.d.ts","names":[],"sources":["../src/src/EngineBaseClient.ts"],"mappings":";;;;;;;;UA+BiB,gBAAA;EAEf,GAAA;EAEA,YAAA,GAAe,uBAAA;EAEf,wBAAA,GAA2B,uBAAuB;AAAA;AAAA,KAI/C,wBAAA,GAA2B,OAAO,CAAC,gCAAA;AAVxC;;;AAAA,cAwBa,gBAAA;EAAA,SACF,IAAA,EAAM,gBAAA;EAAA,SACN,aAAA,EAAe,aAAA;cAEZ,IAAA,EAAM,gBAAA;EAtBlB;;;AAAkD;AACnD;EAmCQ,eAAA,CACL,wBAAA,EAA0B,uBAAA;EAKf,UAAA,CAAW,OAAA,YAAmB,OAAA;EAc9B,SAAA,CACX,MAAA,EAAQ,qBAAA,GACP,OAAA,CAAQ,uBAAA;EAtD2D;AAcxE;;;;;;EAwDe,KAAA,sBAA2B,4BAAA,CAAA,CACtC,WAAA,EAAa,YAAA,EACb,MAAA,EAAQ,8BAAA,CAA+B,YAAA,IACtC,OAAA,CAAQ,+BAAA,CAAgC,YAAA;EAnCA;;;;;;;;;EA8D9B,SAAA,sBACU,kCAAA,CAAA,CAErB,WAAA,EAAa,YAAA,EACb,MAAA,EAAQ,oCAAA,CAAqC,YAAA,IAC5C,OAAA,CAAQ,qCAAA,CAAsC,YAAA;EAhC9C;;;;;;;;;EA4DU,gBAAA,sBACU,kCAAA,CAAA,CAErB,WAAA,EAAa,YAAA,EACb,MAAA,EAAQ,oCAAA,CAAqC,YAAA,IAC5C,OAAA,CAAQ,qCAAA,CAAsC,YAAA;EADvC;;;;;;;;EAqBG,OAAA,sBAA6B,8BAAA,CAAA,CACxC,WAAA,EAAa,YAAA,EACb,MAAA,EAAQ,gCAAA,CAAiC,YAAA,IACxC,OAAA,CAAQ,gCAAA,CAAiC,YAAA;EAAA;;;;;;;;EAqBrC,eAAA,qDAAA,CACL,WAAA,EAAa,YAAA,EACb,MAAA,EAAQ,OAAA;IACL,IAAA,EAAM,YAAA;EAAA,IAAiB,OAAA;EAgBzB;;;;;;EAHI,iBAAA,sBAAuC,8BAAA,CAAA,CAC5C,WAAA,EAAa,YAAA,EACb,MAAA,EAAQ,gCAAA,CAAiC,YAAA,IACxC,wBAAA;EAmBqC;;;;;;;;;EAJ3B,IAAA,WAAe,mBAAA,CAAA,CAC1B,WAAA,EAAa,CAAA,EACb,iBAAA,UACA,OAAA,UACA,MAAA,EAAQ,2BAAA,CAA4B,CAAA,IAAE,OAAA;EAAA,QAmBhC,mBAAA;EAAA,QAQA,iBAAA;AAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { G as EngineServerQueryResponseByType, H as EngineServerQueryRequestByType, U as EngineServerQueryRequestType
|
|
1
|
+
import { G as EngineServerQueryResponseByType, H as EngineServerQueryRequestByType, U as EngineServerQueryRequestType } from "./serverQueryTypes-Dva9R2tV.cjs";
|
|
2
2
|
import { a as EngineServerExecuteRequestByType, l as EngineServerExecuteSuccessResult, o as EngineServerExecuteRequestType } from "./serverExecuteTypes-DejTR8Is.cjs";
|
|
3
|
-
import {
|
|
3
|
+
import { G as GetEngineNoncesResponse, W as GetEngineNoncesParams } from "./clientQueryTypes-BTKfuoGI.cjs";
|
|
4
|
+
import { a as EngineServerCachedQueryRequestByType, c as EngineServerCachedQueryResponseByType, d as EngineServerEdgeControlRequestByType, f as EngineServerEdgeControlRequestType, o as EngineServerCachedQueryRequestType, p as EngineServerEdgeControlResponseByType } from "./serverEdgeQueryTypes-BpMlbsCD.cjs";
|
|
4
5
|
import { SignableRequestType, SignableRequestTypeToParams, WalletClientWithAccount } from "@nadohq/shared";
|
|
5
6
|
import { AxiosInstance } from "axios";
|
|
6
7
|
|
|
@@ -35,12 +36,25 @@ declare class EngineBaseClient {
|
|
|
35
36
|
*/
|
|
36
37
|
query<TRequestType extends EngineServerQueryRequestType>(requestType: TRequestType, params: EngineServerQueryRequestByType[TRequestType]): Promise<EngineServerQueryResponseByType[TRequestType]>;
|
|
37
38
|
/**
|
|
38
|
-
*
|
|
39
|
+
* Queries the gateway's in-memory cache via the `/edge/query` endpoint. Lower latency than
|
|
40
|
+
* {@link query} at the cost of eventual consistency — do not use for order, margin, or
|
|
41
|
+
* settlement decisions.
|
|
39
42
|
*
|
|
40
43
|
* @param requestType
|
|
41
44
|
* @param params
|
|
45
|
+
* @public
|
|
46
|
+
*/
|
|
47
|
+
edgeQuery<TRequestType extends EngineServerCachedQueryRequestType>(requestType: TRequestType, params: EngineServerCachedQueryRequestByType[TRequestType]): Promise<EngineServerCachedQueryResponseByType[TRequestType]>;
|
|
48
|
+
/**
|
|
49
|
+
* Sends an edge control message (`ping` / `time`) via the `/edge/query` endpoint. These
|
|
50
|
+
* return immediately from the server clock and use a different envelope than the cached data
|
|
51
|
+
* queries (no `data` field), so the whole response body is returned.
|
|
52
|
+
*
|
|
53
|
+
* @param requestType
|
|
54
|
+
* @param params
|
|
55
|
+
* @public
|
|
42
56
|
*/
|
|
43
|
-
|
|
57
|
+
edgeControlQuery<TRequestType extends EngineServerEdgeControlRequestType>(requestType: TRequestType, params: EngineServerEdgeControlRequestByType[TRequestType]): Promise<EngineServerEdgeControlResponseByType[TRequestType]>;
|
|
44
58
|
/**
|
|
45
59
|
* POSTs an execute message to the engine and returns the successful response. Throws the failure response wrapped
|
|
46
60
|
* in an EngineServerFailureError on failure.
|
|
@@ -50,6 +64,17 @@ declare class EngineBaseClient {
|
|
|
50
64
|
* @public
|
|
51
65
|
*/
|
|
52
66
|
execute<TRequestType extends EngineServerExecuteRequestType>(requestType: TRequestType, params: EngineServerExecuteRequestByType[TRequestType]): Promise<EngineServerExecuteSuccessResult<TRequestType>>;
|
|
67
|
+
/**
|
|
68
|
+
* A simple, typechecked fn for constructing a `type`-tagged request body in the format expected
|
|
69
|
+
* by the server. Generic over the request type / params pair so it can build live query, edge
|
|
70
|
+
* (cached) query, and edge control request bodies alike.
|
|
71
|
+
*
|
|
72
|
+
* @param requestType
|
|
73
|
+
* @param params
|
|
74
|
+
*/
|
|
75
|
+
getQueryRequest<TRequestType extends string, TParams extends object>(requestType: TRequestType, params: TParams): {
|
|
76
|
+
type: TRequestType;
|
|
77
|
+
} & TParams;
|
|
53
78
|
/**
|
|
54
79
|
* A simple, typechecked fn for constructing an execute request in the format expected by the server.
|
|
55
80
|
*
|
|
@@ -72,4 +97,4 @@ declare class EngineBaseClient {
|
|
|
72
97
|
}
|
|
73
98
|
//#endregion
|
|
74
99
|
export { EngineClientOpts as n, EngineBaseClient as t };
|
|
75
|
-
//# sourceMappingURL=EngineBaseClient-
|
|
100
|
+
//# sourceMappingURL=EngineBaseClient-a2leWTER.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EngineBaseClient-a2leWTER.d.cts","names":[],"sources":["../src/src/EngineBaseClient.ts"],"mappings":";;;;;;;;UA+BiB,gBAAA;EAEf,GAAA;EAEA,YAAA,GAAe,uBAAA;EAEf,wBAAA,GAA2B,uBAAuB;AAAA;AAAA,KAI/C,wBAAA,GAA2B,OAAO,CAA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,CAAA,EACb,iBAAA,UACA,OAAA,UACA,MAAA,EAAQ,2BAAA,CAA4B,CAAA,IAAE,OAAA;EAAA,QAmBhC,mBAAA;EAAA,QAQA,iBAAA;AAAA"}
|
|
@@ -71,16 +71,36 @@ var EngineBaseClient = class {
|
|
|
71
71
|
return response.data.data;
|
|
72
72
|
}
|
|
73
73
|
/**
|
|
74
|
-
*
|
|
74
|
+
* Queries the gateway's in-memory cache via the `/edge/query` endpoint. Lower latency than
|
|
75
|
+
* {@link query} at the cost of eventual consistency — do not use for order, margin, or
|
|
76
|
+
* settlement decisions.
|
|
75
77
|
*
|
|
76
78
|
* @param requestType
|
|
77
79
|
* @param params
|
|
80
|
+
* @public
|
|
78
81
|
*/
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
async edgeQuery(requestType, params) {
|
|
83
|
+
const request = this.getQueryRequest(requestType, params);
|
|
84
|
+
const response = await this.axiosInstance.post(`${this.opts.url}/edge/query`, request);
|
|
85
|
+
this.checkResponseStatus(response);
|
|
86
|
+
this.checkServerStatus(response);
|
|
87
|
+
return response.data.data;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Sends an edge control message (`ping` / `time`) via the `/edge/query` endpoint. These
|
|
91
|
+
* return immediately from the server clock and use a different envelope than the cached data
|
|
92
|
+
* queries (no `data` field), so the whole response body is returned.
|
|
93
|
+
*
|
|
94
|
+
* @param requestType
|
|
95
|
+
* @param params
|
|
96
|
+
* @public
|
|
97
|
+
*/
|
|
98
|
+
async edgeControlQuery(requestType, params) {
|
|
99
|
+
const request = this.getQueryRequest(requestType, params);
|
|
100
|
+
const response = await this.axiosInstance.post(`${this.opts.url}/edge/query`, request);
|
|
101
|
+
this.checkResponseStatus(response);
|
|
102
|
+
this.checkServerStatus(response);
|
|
103
|
+
return response.data;
|
|
84
104
|
}
|
|
85
105
|
/**
|
|
86
106
|
* POSTs an execute message to the engine and returns the successful response. Throws the failure response wrapped
|
|
@@ -98,6 +118,20 @@ var EngineBaseClient = class {
|
|
|
98
118
|
return response.data;
|
|
99
119
|
}
|
|
100
120
|
/**
|
|
121
|
+
* A simple, typechecked fn for constructing a `type`-tagged request body in the format expected
|
|
122
|
+
* by the server. Generic over the request type / params pair so it can build live query, edge
|
|
123
|
+
* (cached) query, and edge control request bodies alike.
|
|
124
|
+
*
|
|
125
|
+
* @param requestType
|
|
126
|
+
* @param params
|
|
127
|
+
*/
|
|
128
|
+
getQueryRequest(requestType, params) {
|
|
129
|
+
return {
|
|
130
|
+
type: requestType,
|
|
131
|
+
...params
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
101
135
|
* A simple, typechecked fn for constructing an execute request in the format expected by the server.
|
|
102
136
|
*
|
|
103
137
|
* @param requestType
|
|
@@ -147,4 +181,4 @@ Object.defineProperty(exports, "__toESM", {
|
|
|
147
181
|
}
|
|
148
182
|
});
|
|
149
183
|
|
|
150
|
-
//# sourceMappingURL=EngineBaseClient-
|
|
184
|
+
//# sourceMappingURL=EngineBaseClient-zgQmbhJv.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EngineBaseClient-zgQmbhJv.cjs","names":["WalletNotProvidedError","successResponse","EngineServerFailureError"],"sources":["../src/EngineBaseClient.ts"],"sourcesContent":["import {\n getSignedTransactionRequest,\n SignableRequestType,\n SignableRequestTypeToParams,\n WalletClientWithAccount,\n WalletNotProvidedError,\n} from '@nadohq/shared';\nimport axios, { AxiosInstance, AxiosResponse } from 'axios';\nimport {\n EngineServerCachedQueryRequestByType,\n EngineServerCachedQueryRequestType,\n EngineServerCachedQueryResponse,\n EngineServerCachedQueryResponseByType,\n EngineServerCachedQuerySuccessResponse,\n EngineServerEdgeControlRequestByType,\n EngineServerEdgeControlRequestType,\n EngineServerEdgeControlResponseByType,\n EngineServerExecuteRequestByType,\n EngineServerExecuteRequestType,\n EngineServerExecuteResult,\n EngineServerExecuteSuccessResult,\n EngineServerQueryRequestByType,\n EngineServerQueryRequestType,\n EngineServerQueryResponse,\n EngineServerQueryResponseByType,\n EngineServerQuerySuccessResponse,\n GetEngineNoncesParams,\n GetEngineNoncesResponse,\n} from './types';\nimport { EngineServerFailureError } from './types/EngineServerFailureError';\n\nexport interface EngineClientOpts {\n // Server URL\n url: string;\n // Wallet client for EIP712 signing\n walletClient?: WalletClientWithAccount;\n // Linked signer registered through the engine, if provided, execute requests will use this signer\n linkedSignerWalletClient?: WalletClientWithAccount;\n}\n\n// Only 1 key can be defined per execute request\ntype EngineExecuteRequestBody = Partial<EngineServerExecuteRequestByType>;\n\ntype EngineQueryRequestResponse<\n T extends EngineServerQueryRequestType = EngineServerQueryRequestType,\n> = EngineServerQueryResponse<T>;\n\ntype EngineCachedQueryRequestResponse<\n T extends EngineServerCachedQueryRequestType =\n EngineServerCachedQueryRequestType,\n> = EngineServerCachedQueryResponse<T>;\n\n/**\n * Base client for all engine requests\n */\nexport class EngineBaseClient {\n readonly opts: EngineClientOpts;\n readonly axiosInstance: AxiosInstance;\n\n constructor(opts: EngineClientOpts) {\n this.opts = opts;\n this.axiosInstance = axios.create({\n withCredentials: true,\n // We have custom logic to validate response status and create an appropriate error\n validateStatus: () => true,\n });\n }\n\n /**\n * Sets the linked signer for execute requests\n *\n * @param linkedSignerWalletClient The linkedSigner to use for all signatures. Set to null to revert to the chain signer\n */\n public setLinkedSigner(\n linkedSignerWalletClient: WalletClientWithAccount | null,\n ) {\n this.opts.linkedSignerWalletClient = linkedSignerWalletClient ?? undefined;\n }\n\n public async getTxNonce(address?: string): Promise<string> {\n const addr = address ?? this.opts.walletClient?.account.address;\n\n if (!addr) {\n throw new WalletNotProvidedError();\n }\n\n return (\n await this.getNonces({\n address: addr,\n })\n ).txNonce;\n }\n\n public async getNonces(\n params: GetEngineNoncesParams,\n ): Promise<GetEngineNoncesResponse> {\n const baseResp = await this.query('nonces', params);\n\n return {\n orderNonce: baseResp.order_nonce,\n txNonce: baseResp.tx_nonce,\n };\n }\n\n /**\n * Queries the engine, all query params are stringified into the query string\n *\n * @param requestType\n * @param params\n * @public\n */\n public async query<TRequestType extends EngineServerQueryRequestType>(\n requestType: TRequestType,\n params: EngineServerQueryRequestByType[TRequestType],\n ): Promise<EngineServerQueryResponseByType[TRequestType]> {\n const request = this.getQueryRequest(requestType, params);\n const response = await this.axiosInstance.post<EngineQueryRequestResponse>(\n `${this.opts.url}/query`,\n request,\n );\n\n this.checkResponseStatus(response);\n this.checkServerStatus(response);\n\n // checkServerStatus throws on failure responses so the cast to the success response is acceptable here\n const successResponse = response as AxiosResponse<\n EngineServerQuerySuccessResponse<TRequestType>\n >;\n\n return successResponse.data.data;\n }\n\n /**\n * Queries the gateway's in-memory cache via the `/edge/query` endpoint. Lower latency than\n * {@link query} at the cost of eventual consistency — do not use for order, margin, or\n * settlement decisions.\n *\n * @param requestType\n * @param params\n * @public\n */\n public async edgeQuery<\n TRequestType extends EngineServerCachedQueryRequestType,\n >(\n requestType: TRequestType,\n params: EngineServerCachedQueryRequestByType[TRequestType],\n ): Promise<EngineServerCachedQueryResponseByType[TRequestType]> {\n const request = this.getQueryRequest(requestType, params);\n const response =\n await this.axiosInstance.post<EngineCachedQueryRequestResponse>(\n `${this.opts.url}/edge/query`,\n request,\n );\n\n this.checkResponseStatus(response);\n this.checkServerStatus(response);\n\n // checkServerStatus throws on failure responses so the cast to the success response is acceptable here\n const successResponse = response as AxiosResponse<\n EngineServerCachedQuerySuccessResponse<TRequestType>\n >;\n\n return successResponse.data.data;\n }\n\n /**\n * Sends an edge control message (`ping` / `time`) via the `/edge/query` endpoint. These\n * return immediately from the server clock and use a different envelope than the cached data\n * queries (no `data` field), so the whole response body is returned.\n *\n * @param requestType\n * @param params\n * @public\n */\n public async edgeControlQuery<\n TRequestType extends EngineServerEdgeControlRequestType,\n >(\n requestType: TRequestType,\n params: EngineServerEdgeControlRequestByType[TRequestType],\n ): Promise<EngineServerEdgeControlResponseByType[TRequestType]> {\n const request = this.getQueryRequest(requestType, params);\n const response = await this.axiosInstance.post<\n EngineServerEdgeControlResponseByType[TRequestType]\n >(`${this.opts.url}/edge/query`, request);\n\n this.checkResponseStatus(response);\n this.checkServerStatus(response);\n\n return response.data;\n }\n\n /**\n * POSTs an execute message to the engine and returns the successful response. Throws the failure response wrapped\n * in an EngineServerFailureError on failure.\n *\n * @param requestType\n * @param params\n * @public\n */\n public async execute<TRequestType extends EngineServerExecuteRequestType>(\n requestType: TRequestType,\n params: EngineServerExecuteRequestByType[TRequestType],\n ): Promise<EngineServerExecuteSuccessResult<TRequestType>> {\n const reqBody = this.getExecuteRequest(requestType, params);\n const response = await this.axiosInstance.post<\n EngineServerExecuteResult<TRequestType>\n >(`${this.opts.url}/execute`, reqBody);\n\n this.checkResponseStatus(response);\n this.checkServerStatus(response);\n\n // checkServerStatus catches the failure result and throws the error, so the cast to the success response is acceptable here\n return response.data as EngineServerExecuteSuccessResult<TRequestType>;\n }\n\n /**\n * A simple, typechecked fn for constructing a `type`-tagged request body in the format expected\n * by the server. Generic over the request type / params pair so it can build live query, edge\n * (cached) query, and edge control request bodies alike.\n *\n * @param requestType\n * @param params\n */\n public getQueryRequest<TRequestType extends string, TParams extends object>(\n requestType: TRequestType,\n params: TParams,\n ): { type: TRequestType } & TParams {\n return {\n type: requestType,\n ...params,\n };\n }\n\n /**\n * A simple, typechecked fn for constructing an execute request in the format expected by the server.\n *\n * @param requestType\n * @param params\n */\n public getExecuteRequest<TRequestType extends EngineServerExecuteRequestType>(\n requestType: TRequestType,\n params: EngineServerExecuteRequestByType[TRequestType],\n ): EngineExecuteRequestBody {\n return {\n [requestType]: params,\n };\n }\n\n /**\n * Signs a given request with the signer provided to the engine\n *\n * @param requestType\n * @param verifyingContract\n * @param chainId\n * @param params\n * @public\n */\n public async sign<T extends SignableRequestType>(\n requestType: T,\n verifyingContract: string,\n chainId: number,\n params: SignableRequestTypeToParams[T],\n ) {\n // Use the linked signer if provided, otherwise use the default signer provided to the engine\n const walletClient =\n this.opts.linkedSignerWalletClient ?? this.opts.walletClient;\n\n if (!walletClient) {\n throw new WalletNotProvidedError();\n }\n\n return getSignedTransactionRequest({\n chainId,\n requestParams: params,\n requestType,\n walletClient,\n verifyingContract,\n });\n }\n\n private checkResponseStatus(response: AxiosResponse) {\n if (response.status !== 200 || !response.data) {\n throw Error(\n `Unexpected response from server: ${response.status} ${response.statusText}. Data: ${response.data}`,\n );\n }\n }\n\n private checkServerStatus(\n response: AxiosResponse<\n | EngineServerExecuteResult\n | EngineQueryRequestResponse\n | EngineCachedQueryRequestResponse\n | EngineServerEdgeControlResponseByType[EngineServerEdgeControlRequestType]\n >,\n ) {\n if (response.data.status !== 'success') {\n throw new EngineServerFailureError(response.data);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDA,IAAa,mBAAb,MAA8B;CAI5B,YAAY,MAAwB;EAClC,KAAK,OAAO;EACZ,KAAK,gBAAgB,MAAA,QAAM,OAAO;GAChC,iBAAiB;GAEjB,sBAAsB;EACxB,CAAC;CACH;;;;;;CAOA,gBACE,0BACA;EACA,KAAK,KAAK,2BAA2B,4BAA4B,KAAA;CACnE;CAEA,MAAa,WAAW,SAAmC;EACzD,MAAM,OAAO,WAAW,KAAK,KAAK,cAAc,QAAQ;EAExD,IAAI,CAAC,MACH,MAAM,IAAIA,eAAAA,uBAAuB;EAGnC,QACE,MAAM,KAAK,UAAU,EACnB,SAAS,KACX,CAAC,GACD;CACJ;CAEA,MAAa,UACX,QACkC;EAClC,MAAM,WAAW,MAAM,KAAK,MAAM,UAAU,MAAM;EAElD,OAAO;GACL,YAAY,SAAS;GACrB,SAAS,SAAS;EACpB;CACF;;;;;;;;CASA,MAAa,MACX,aACA,QACwD;EACxD,MAAM,UAAU,KAAK,gBAAgB,aAAa,MAAM;EACxD,MAAM,WAAW,MAAM,KAAK,cAAc,KACxC,GAAG,KAAK,KAAK,IAAI,SACjB,OACF;EAEA,KAAK,oBAAoB,QAAQ;EACjC,K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S,MACvC,MAAM,MACJ,oCAAoC,SAAS,OAAO,GAAG,SAAS,WAAW,UAAU,SAAS,MAChG;CAEJ;CAEA,kBACE,UAMA;EACA,IAAI,SAAS,KAAK,WAAW,WAC3B,MAAM,IAAIE,uCAAAA,yBAAyB,SAAS,IAAI;CAEpD;AACF"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_EngineBaseClient = require("./EngineBaseClient-
|
|
2
|
+
const require_EngineBaseClient = require("./EngineBaseClient-zgQmbhJv.cjs");
|
|
3
3
|
exports.EngineBaseClient = require_EngineBaseClient.EngineBaseClient;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as EngineClientOpts, t as EngineBaseClient } from "./EngineBaseClient-
|
|
1
|
+
import { n as EngineClientOpts, t as EngineBaseClient } from "./EngineBaseClient-a2leWTER.cjs";
|
|
2
2
|
export { EngineBaseClient, EngineClientOpts };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as EngineClientOpts, t as EngineBaseClient } from "./EngineBaseClient-
|
|
1
|
+
import { n as EngineClientOpts, t as EngineBaseClient } from "./EngineBaseClient-Cn4PMYKt.js";
|
|
2
2
|
export { EngineBaseClient, EngineClientOpts };
|
package/dist/EngineBaseClient.js
CHANGED
|
@@ -48,16 +48,36 @@ var EngineBaseClient = class {
|
|
|
48
48
|
return response.data.data;
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
|
-
*
|
|
51
|
+
* Queries the gateway's in-memory cache via the `/edge/query` endpoint. Lower latency than
|
|
52
|
+
* {@link query} at the cost of eventual consistency — do not use for order, margin, or
|
|
53
|
+
* settlement decisions.
|
|
52
54
|
*
|
|
53
55
|
* @param requestType
|
|
54
56
|
* @param params
|
|
57
|
+
* @public
|
|
55
58
|
*/
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
async edgeQuery(requestType, params) {
|
|
60
|
+
const request = this.getQueryRequest(requestType, params);
|
|
61
|
+
const response = await this.axiosInstance.post(`${this.opts.url}/edge/query`, request);
|
|
62
|
+
this.checkResponseStatus(response);
|
|
63
|
+
this.checkServerStatus(response);
|
|
64
|
+
return response.data.data;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Sends an edge control message (`ping` / `time`) via the `/edge/query` endpoint. These
|
|
68
|
+
* return immediately from the server clock and use a different envelope than the cached data
|
|
69
|
+
* queries (no `data` field), so the whole response body is returned.
|
|
70
|
+
*
|
|
71
|
+
* @param requestType
|
|
72
|
+
* @param params
|
|
73
|
+
* @public
|
|
74
|
+
*/
|
|
75
|
+
async edgeControlQuery(requestType, params) {
|
|
76
|
+
const request = this.getQueryRequest(requestType, params);
|
|
77
|
+
const response = await this.axiosInstance.post(`${this.opts.url}/edge/query`, request);
|
|
78
|
+
this.checkResponseStatus(response);
|
|
79
|
+
this.checkServerStatus(response);
|
|
80
|
+
return response.data;
|
|
61
81
|
}
|
|
62
82
|
/**
|
|
63
83
|
* POSTs an execute message to the engine and returns the successful response. Throws the failure response wrapped
|
|
@@ -75,6 +95,20 @@ var EngineBaseClient = class {
|
|
|
75
95
|
return response.data;
|
|
76
96
|
}
|
|
77
97
|
/**
|
|
98
|
+
* A simple, typechecked fn for constructing a `type`-tagged request body in the format expected
|
|
99
|
+
* by the server. Generic over the request type / params pair so it can build live query, edge
|
|
100
|
+
* (cached) query, and edge control request bodies alike.
|
|
101
|
+
*
|
|
102
|
+
* @param requestType
|
|
103
|
+
* @param params
|
|
104
|
+
*/
|
|
105
|
+
getQueryRequest(requestType, params) {
|
|
106
|
+
return {
|
|
107
|
+
type: requestType,
|
|
108
|
+
...params
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
78
112
|
* A simple, typechecked fn for constructing an execute request in the format expected by the server.
|
|
79
113
|
*
|
|
80
114
|
* @param requestType
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EngineBaseClient.js","names":["successResponse"],"sources":["../src/EngineBaseClient.ts"],"sourcesContent":["import {\n getSignedTransactionRequest,\n SignableRequestType,\n SignableRequestTypeToParams,\n WalletClientWithAccount,\n WalletNotProvidedError,\n} from '@nadohq/shared';\nimport axios, { AxiosInstance, AxiosResponse } from 'axios';\nimport {\n EngineServerExecuteRequestByType,\n EngineServerExecuteRequestType,\n EngineServerExecuteResult,\n EngineServerExecuteSuccessResult,\n EngineServerQueryRequest,\n EngineServerQueryRequestByType,\n EngineServerQueryRequestType,\n EngineServerQueryResponse,\n EngineServerQueryResponseByType,\n EngineServerQuerySuccessResponse,\n GetEngineNoncesParams,\n GetEngineNoncesResponse,\n} from './types';\nimport { EngineServerFailureError } from './types/EngineServerFailureError';\n\nexport interface EngineClientOpts {\n // Server URL\n url: string;\n // Wallet client for EIP712 signing\n walletClient?: WalletClientWithAccount;\n // Linked signer registered through the engine, if provided, execute requests will use this signer\n linkedSignerWalletClient?: WalletClientWithAccount;\n}\n\n// Only 1 key can be defined per execute request\ntype EngineExecuteRequestBody = Partial<EngineServerExecuteRequestByType>;\n\ntype EngineQueryRequestResponse<\n T extends EngineServerQueryRequestType = EngineServerQueryRequestType,\n> = EngineServerQueryResponse<T>;\n\n/**\n * Base client for all engine requests\n */\nexport class EngineBaseClient {\n readonly opts: EngineClientOpts;\n readonly axiosInstance: AxiosInstance;\n\n constructor(opts: EngineClientOpts) {\n this.opts = opts;\n this.axiosInstance = axios.create({\n withCredentials: true,\n // We have custom logic to validate response status and create an appropriate error\n validateStatus: () => true,\n });\n }\n\n /**\n * Sets the linked signer for execute requests\n *\n * @param linkedSignerWalletClient The linkedSigner to use for all signatures. Set to null to revert to the chain signer\n */\n public setLinkedSigner(\n linkedSignerWalletClient: WalletClientWithAccount | null,\n ) {\n this.opts.linkedSignerWalletClient = linkedSignerWalletClient ?? undefined;\n }\n\n public async getTxNonce(address?: string): Promise<string> {\n const addr = address ?? this.opts.walletClient?.account.address;\n\n if (!addr) {\n throw new WalletNotProvidedError();\n }\n\n return (\n await this.getNonces({\n address: addr,\n })\n ).txNonce;\n }\n\n public async getNonces(\n params: GetEngineNoncesParams,\n ): Promise<GetEngineNoncesResponse> {\n const baseResp = await this.query('nonces', params);\n\n return {\n orderNonce: baseResp.order_nonce,\n txNonce: baseResp.tx_nonce,\n };\n }\n\n /**\n * Queries the engine, all query params are stringified into the query string\n *\n * @param requestType\n * @param params\n * @public\n */\n public async query<TRequestType extends EngineServerQueryRequestType>(\n requestType: TRequestType,\n params: EngineServerQueryRequestByType[TRequestType],\n ): Promise<EngineServerQueryResponseByType[TRequestType]> {\n const request = this.getQueryRequest(requestType, params);\n const response = await this.axiosInstance.post<EngineQueryRequestResponse>(\n `${this.opts.url}/query`,\n request,\n );\n\n this.checkResponseStatus(response);\n this.checkServerStatus(response);\n\n // checkServerStatus throws on failure responses so the cast to the success response is acceptable here\n const successResponse = response as AxiosResponse<\n EngineServerQuerySuccessResponse<TRequestType>\n >;\n\n return successResponse.data.data;\n }\n\n /**\n * A simple, typechecked fn for constructing a query request in the format expected by the server.\n *\n * @param requestType\n * @param params\n */\n public getQueryRequest<TRequestType extends EngineServerQueryRequestType>(\n requestType: TRequestType,\n params: EngineServerQueryRequestByType[TRequestType],\n ): EngineServerQueryRequest<TRequestType> {\n return {\n type: requestType,\n ...params,\n };\n }\n\n /**\n * POSTs an execute message to the engine and returns the successful response. Throws the failure response wrapped\n * in an EngineServerFailureError on failure.\n *\n * @param requestType\n * @param params\n * @public\n */\n public async execute<TRequestType extends EngineServerExecuteRequestType>(\n requestType: TRequestType,\n params: EngineServerExecuteRequestByType[TRequestType],\n ): Promise<EngineServerExecuteSuccessResult<TRequestType>> {\n const reqBody = this.getExecuteRequest(requestType, params);\n const response = await this.axiosInstance.post<\n EngineServerExecuteResult<TRequestType>\n >(`${this.opts.url}/execute`, reqBody);\n\n this.checkResponseStatus(response);\n this.checkServerStatus(response);\n\n // checkServerStatus catches the failure result and throws the error, so the cast to the success response is acceptable here\n return response.data as EngineServerExecuteSuccessResult<TRequestType>;\n }\n\n /**\n * A simple, typechecked fn for constructing an execute request in the format expected by the server.\n *\n * @param requestType\n * @param params\n */\n public getExecuteRequest<TRequestType extends EngineServerExecuteRequestType>(\n requestType: TRequestType,\n params: EngineServerExecuteRequestByType[TRequestType],\n ): EngineExecuteRequestBody {\n return {\n [requestType]: params,\n };\n }\n\n /**\n * Signs a given request with the signer provided to the engine\n *\n * @param requestType\n * @param verifyingContract\n * @param chainId\n * @param params\n * @public\n */\n public async sign<T extends SignableRequestType>(\n requestType: T,\n verifyingContract: string,\n chainId: number,\n params: SignableRequestTypeToParams[T],\n ) {\n // Use the linked signer if provided, otherwise use the default signer provided to the engine\n const walletClient =\n this.opts.linkedSignerWalletClient ?? this.opts.walletClient;\n\n if (!walletClient) {\n throw new WalletNotProvidedError();\n }\n\n return getSignedTransactionRequest({\n chainId,\n requestParams: params,\n requestType,\n walletClient,\n verifyingContract,\n });\n }\n\n private checkResponseStatus(response: AxiosResponse) {\n if (response.status !== 200 || !response.data) {\n throw Error(\n `Unexpected response from server: ${response.status} ${response.statusText}. Data: ${response.data}`,\n );\n }\n }\n\n private checkServerStatus(\n response: AxiosResponse<\n EngineServerExecuteResult | EngineQueryRequestResponse\n >,\n ) {\n if (response.data.status !== 'success') {\n throw new EngineServerFailureError(response.data);\n }\n }\n}\n"],"mappings":";;;;;;;AA2CA,IAAa,mBAAb,MAA8B;CAI5B,YAAY,MAAwB;EAClC,KAAK,OAAO;EACZ,KAAK,gBAAgB,MAAM,OAAO;GAChC,iBAAiB;GAEjB,sBAAsB;EACxB,CAAC;CACH;;;;;;CAOA,gBACE,0BACA;EACA,KAAK,KAAK,2BAA2B,4BAA4B,KAAA;CACnE;CAEA,MAAa,WAAW,SAAmC;EACzD,MAAM,OAAO,WAAW,KAAK,KAAK,cAAc,QAAQ;EAExD,IAAI,CAAC,MACH,MAAM,IAAI,uBAAuB;EAGnC,QACE,MAAM,KAAK,U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,IAAI;CAEpD;AACF"}
|
|
1
|
+
{"version":3,"file":"EngineBaseClient.js","names":["successResponse"],"sources":["../src/EngineBaseClient.ts"],"sourcesContent":["import {\n getSignedTransactionRequest,\n SignableRequestType,\n SignableRequestTypeToParams,\n WalletClientWithAccount,\n WalletNotProvidedError,\n} from '@nadohq/shared';\nimport axios, { AxiosInstance, AxiosResponse } from 'axios';\nimport {\n EngineServerCachedQueryRequestByType,\n EngineServerCachedQueryRequestType,\n EngineServerCachedQueryResponse,\n EngineServerCachedQueryResponseByType,\n EngineServerCachedQuerySuccessResponse,\n EngineServerEdgeControlRequestByType,\n EngineServerEdgeControlRequestType,\n EngineServerEdgeControlResponseByType,\n EngineServerExecuteRequestByType,\n EngineServerExecuteRequestType,\n EngineServerExecuteResult,\n EngineServerExecuteSuccessResult,\n EngineServerQueryRequestByType,\n EngineServerQueryRequestType,\n EngineServerQueryResponse,\n EngineServerQueryResponseByType,\n EngineServerQuerySuccessResponse,\n GetEngineNoncesParams,\n GetEngineNoncesResponse,\n} from './types';\nimport { EngineServerFailureError } from './types/EngineServerFailureError';\n\nexport interface EngineClientOpts {\n // Server URL\n url: string;\n // Wallet client for EIP712 signing\n walletClient?: WalletClientWithAccount;\n // Linked signer registered through the engine, if provided, execute requests will use this signer\n linkedSignerWalletClient?: WalletClientWithAccount;\n}\n\n// Only 1 key can be defined per execute request\ntype EngineExecuteRequestBody = Partial<EngineServerExecuteRequestByType>;\n\ntype EngineQueryRequestResponse<\n T extends EngineServerQueryRequestType = EngineServerQueryRequestType,\n> = EngineServerQueryResponse<T>;\n\ntype EngineCachedQueryRequestResponse<\n T extends EngineServerCachedQueryRequestType =\n EngineServerCachedQueryRequestType,\n> = EngineServerCachedQueryResponse<T>;\n\n/**\n * Base client for all engine requests\n */\nexport class EngineBaseClient {\n readonly opts: EngineClientOpts;\n readonly axiosInstance: AxiosInstance;\n\n constructor(opts: EngineClientOpts) {\n this.opts = opts;\n this.axiosInstance = axios.create({\n withCredentials: true,\n // We have custom logic to validate response status and create an appropriate error\n validateStatus: () => true,\n });\n }\n\n /**\n * Sets the linked signer for execute requests\n *\n * @param linkedSignerWalletClient The linkedSigner to use for all signatures. Set to null to revert to the chain signer\n */\n public setLinkedSigner(\n linkedSignerWalletClient: WalletClientWithAccount | null,\n ) {\n this.opts.linkedSignerWalletClient = linkedSignerWalletClient ?? undefined;\n }\n\n public async getTxNonce(address?: string): Promise<string> {\n const addr = address ?? this.opts.walletClient?.account.address;\n\n if (!addr) {\n throw new WalletNotProvidedError();\n }\n\n return (\n await this.getNonces({\n address: addr,\n })\n ).txNonce;\n }\n\n public async getNonces(\n params: GetEngineNoncesParams,\n ): Promise<GetEngineNoncesResponse> {\n const baseResp = await this.query('nonces', params);\n\n return {\n orderNonce: baseResp.order_nonce,\n txNonce: baseResp.tx_nonce,\n };\n }\n\n /**\n * Queries the engine, all query params are stringified into the query string\n *\n * @param requestType\n * @param params\n * @public\n */\n public async query<TRequestType extends EngineServerQueryRequestType>(\n requestType: TRequestType,\n params: EngineServerQueryRequestByType[TRequestType],\n ): Promise<EngineServerQueryResponseByType[TRequestType]> {\n const request = this.getQueryRequest(requestType, params);\n const response = await this.axiosInstance.post<EngineQueryRequestResponse>(\n `${this.opts.url}/query`,\n request,\n );\n\n this.checkResponseStatus(response);\n this.checkServerStatus(response);\n\n // checkServerStatus throws on failure responses so the cast to the success response is acceptable here\n const successResponse = response as AxiosResponse<\n EngineServerQuerySuccessResponse<TRequestType>\n >;\n\n return successResponse.data.data;\n }\n\n /**\n * Queries the gateway's in-memory cache via the `/edge/query` endpoint. Lower latency than\n * {@link query} at the cost of eventual consistency — do not use for order, margin, or\n * settlement decisions.\n *\n * @param requestType\n * @param params\n * @public\n */\n public async edgeQuery<\n TRequestType extends EngineServerCachedQueryRequestType,\n >(\n requestType: TRequestType,\n params: EngineServerCachedQueryRequestByType[TRequestType],\n ): Promise<EngineServerCachedQueryResponseByType[TRequestType]> {\n const request = this.getQueryRequest(requestType, params);\n const response =\n await this.axiosInstance.post<EngineCachedQueryRequestResponse>(\n `${this.opts.url}/edge/query`,\n request,\n );\n\n this.checkResponseStatus(response);\n this.checkServerStatus(response);\n\n // checkServerStatus throws on failure responses so the cast to the success response is acceptable here\n const successResponse = response as AxiosResponse<\n EngineServerCachedQuerySuccessResponse<TRequestType>\n >;\n\n return successResponse.data.data;\n }\n\n /**\n * Sends an edge control message (`ping` / `time`) via the `/edge/query` endpoint. These\n * return immediately from the server clock and use a different envelope than the cached data\n * queries (no `data` field), so the whole response body is returned.\n *\n * @param requestType\n * @param params\n * @public\n */\n public async edgeControlQuery<\n TRequestType extends EngineServerEdgeControlRequestType,\n >(\n requestType: TRequestType,\n params: EngineServerEdgeControlRequestByType[TRequestType],\n ): Promise<EngineServerEdgeControlResponseByType[TRequestType]> {\n const request = this.getQueryRequest(requestType, params);\n const response = await this.axiosInstance.post<\n EngineServerEdgeControlResponseByType[TRequestType]\n >(`${this.opts.url}/edge/query`, request);\n\n this.checkResponseStatus(response);\n this.checkServerStatus(response);\n\n return response.data;\n }\n\n /**\n * POSTs an execute message to the engine and returns the successful response. Throws the failure response wrapped\n * in an EngineServerFailureError on failure.\n *\n * @param requestType\n * @param params\n * @public\n */\n public async execute<TRequestType extends EngineServerExecuteRequestType>(\n requestType: TRequestType,\n params: EngineServerExecuteRequestByType[TRequestType],\n ): Promise<EngineServerExecuteSuccessResult<TRequestType>> {\n const reqBody = this.getExecuteRequest(requestType, params);\n const response = await this.axiosInstance.post<\n EngineServerExecuteResult<TRequestType>\n >(`${this.opts.url}/execute`, reqBody);\n\n this.checkResponseStatus(response);\n this.checkServerStatus(response);\n\n // checkServerStatus catches the failure result and throws the error, so the cast to the success response is acceptable here\n return response.data as EngineServerExecuteSuccessResult<TRequestType>;\n }\n\n /**\n * A simple, typechecked fn for constructing a `type`-tagged request body in the format expected\n * by the server. Generic over the request type / params pair so it can build live query, edge\n * (cached) query, and edge control request bodies alike.\n *\n * @param requestType\n * @param params\n */\n public getQueryRequest<TRequestType extends string, TParams extends object>(\n requestType: TRequestType,\n params: TParams,\n ): { type: TRequestType } & TParams {\n return {\n type: requestType,\n ...params,\n };\n }\n\n /**\n * A simple, typechecked fn for constructing an execute request in the format expected by the server.\n *\n * @param requestType\n * @param params\n */\n public getExecuteRequest<TRequestType extends EngineServerExecuteRequestType>(\n requestType: TRequestType,\n params: EngineServerExecuteRequestByType[TRequestType],\n ): EngineExecuteRequestBody {\n return {\n [requestType]: params,\n };\n }\n\n /**\n * Signs a given request with the signer provided to the engine\n *\n * @param requestType\n * @param verifyingContract\n * @param chainId\n * @param params\n * @public\n */\n public async sign<T extends SignableRequestType>(\n requestType: T,\n verifyingContract: string,\n chainId: number,\n params: SignableRequestTypeToParams[T],\n ) {\n // Use the linked signer if provided, otherwise use the default signer provided to the engine\n const walletClient =\n this.opts.linkedSignerWalletClient ?? this.opts.walletClient;\n\n if (!walletClient) {\n throw new WalletNotProvidedError();\n }\n\n return getSignedTransactionRequest({\n chainId,\n requestParams: params,\n requestType,\n walletClient,\n verifyingContract,\n });\n }\n\n private checkResponseStatus(response: AxiosResponse) {\n if (response.status !== 200 || !response.data) {\n throw Error(\n `Unexpected response from server: ${response.status} ${response.statusText}. Data: ${response.data}`,\n );\n }\n }\n\n private checkServerStatus(\n response: AxiosResponse<\n | EngineServerExecuteResult\n | EngineQueryRequestResponse\n | EngineCachedQueryRequestResponse\n | EngineServerEdgeControlResponseByType[EngineServerEdgeControlRequestType]\n >,\n ) {\n if (response.data.status !== 'success') {\n throw new EngineServerFailureError(response.data);\n }\n }\n}\n"],"mappings":";;;;;;;AAuDA,IAAa,mBAAb,MAA8B;CAI5B,YAAY,MAAwB;EAClC,KAAK,OAAO;EACZ,KAAK,gBAAgB,MAAM,OAAO;GAChC,iBAAiB;GAEjB,sBAAsB;EACxB,CAAC;CACH;;;;;;CAOA,gBACE,0BACA;EACA,KAAK,KAAK,2BAA2B,4BAA4B,KAAA;CACnE;CAEA,MAAa,WAAW,SAAmC;EACzD,MAA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QAAQ;EAG/B,OAAO,SAAS;CAClB;;;;;;;;;CAUA,gBACE,aACA,QACkC;EAClC,OAAO;GACL,MAAM;GACN,GAAG;EACL;CACF;;;;;;;CAQA,kBACE,aACA,QAC0B;EAC1B,OAAO,GACJ,cAAc,OACjB;CACF;;;;;;;;;;CAWA,MAAa,KACX,aACA,mBACA,SACA,QACA;EAEA,MAAM,eACJ,KAAK,KAAK,4BAA4B,KAAK,KAAK;EAElD,IAAI,CAAC,cACH,MAAM,IAAI,uBAAuB;EAGnC,OAAO,4BAA4B;GACjC;GACA,eAAe;GACf;GACA;GACA;EACF,CAAC;CACH;CAEA,oBAA4B,UAAyB;EACnD,IAAI,SAAS,WAAW,OAAO,CAAC,SAAS,MACvC,MAAM,MACJ,oCAAoC,SAAS,OAAO,GAAG,SAAS,WAAW,UAAU,SAAS,MAChG;CAEJ;CAEA,kBACE,UAMA;EACA,IAAI,SAAS,KAAK,WAAW,WAC3B,MAAM,IAAI,yBAAyB,SAAS,IAAI;CAEpD;AACF"}
|
package/dist/EngineClient.cjs
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
require("./EngineBaseClient-
|
|
2
|
+
require("./EngineBaseClient-zgQmbhJv.cjs");
|
|
3
|
+
const require_EngineEdgeQueryClient = require("./EngineEdgeQueryClient.cjs");
|
|
3
4
|
const require_EngineExecuteClient = require("./EngineExecuteClient.cjs");
|
|
4
5
|
const require_EngineQueryClient = require("./EngineQueryClient.cjs");
|
|
5
6
|
const require_EngineWebClient = require("./EngineWebClient.cjs");
|
|
6
7
|
let ts_mixer = require("ts-mixer");
|
|
7
8
|
//#region src/EngineClient.ts
|
|
8
9
|
/**
|
|
9
|
-
* Combined Engine client providing query, execution, and WebSocket functionality for off-chain matching engine communication
|
|
10
|
+
* Combined Engine client providing query, edge (cached) query, execution, and WebSocket functionality for off-chain matching engine communication
|
|
10
11
|
*/
|
|
11
|
-
var EngineClient = class extends (0, ts_mixer.Mixin)(require_EngineQueryClient.EngineQueryClient, require_EngineExecuteClient.EngineExecuteClient, require_EngineWebClient.EngineWebClient) {};
|
|
12
|
+
var EngineClient = class extends (0, ts_mixer.Mixin)(require_EngineQueryClient.EngineQueryClient, require_EngineEdgeQueryClient.EngineEdgeQueryClient, require_EngineExecuteClient.EngineExecuteClient, require_EngineWebClient.EngineWebClient) {};
|
|
12
13
|
//#endregion
|
|
13
14
|
exports.EngineClient = EngineClient;
|
|
14
15
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EngineClient.cjs","names":["EngineQueryClient","EngineExecuteClient","EngineWebClient"],"sources":["../src/EngineClient.ts"],"sourcesContent":["import { Mixin } from 'ts-mixer';\nimport { EngineExecuteClient } from './EngineExecuteClient';\nimport { EngineQueryClient } from './EngineQueryClient';\nimport { EngineWebClient } from './EngineWebClient';\n\n/**\n * Combined Engine client providing query, execution, and WebSocket functionality for off-chain matching engine communication\n */\nexport class EngineClient extends Mixin(\n EngineQueryClient,\n EngineExecuteClient,\n EngineWebClient,\n) {}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"EngineClient.cjs","names":["EngineQueryClient","EngineEdgeQueryClient","EngineExecuteClient","EngineWebClient"],"sources":["../src/EngineClient.ts"],"sourcesContent":["import { Mixin } from 'ts-mixer';\nimport { EngineEdgeQueryClient } from './EngineEdgeQueryClient';\nimport { EngineExecuteClient } from './EngineExecuteClient';\nimport { EngineQueryClient } from './EngineQueryClient';\nimport { EngineWebClient } from './EngineWebClient';\n\n/**\n * Combined Engine client providing query, edge (cached) query, execution, and WebSocket functionality for off-chain matching engine communication\n */\nexport class EngineClient extends Mixin(\n EngineQueryClient,\n EngineEdgeQueryClient,\n EngineExecuteClient,\n EngineWebClient,\n) {}\n"],"mappings":";;;;;;;;;;;AASA,IAAa,eAAb,eAAA,GAAA,SAAA,OACEA,0BAAAA,mBACAC,8BAAAA,uBACAC,4BAAAA,qBACAC,wBAAAA,eACF,EAAE,CAAC"}
|
package/dist/EngineClient.d.cts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import { t as
|
|
3
|
-
import { t as
|
|
1
|
+
import { t as EngineEdgeQueryClient } from "./EngineEdgeQueryClient-CPEDAOd0.cjs";
|
|
2
|
+
import { t as EngineExecuteClient } from "./EngineExecuteClient-BLUkw1vR.cjs";
|
|
3
|
+
import { t as EngineQueryClient } from "./EngineQueryClient-Br-BC5LQ.cjs";
|
|
4
|
+
import { t as EngineWebClient } from "./EngineWebClient-i8BslipN.cjs";
|
|
4
5
|
|
|
5
6
|
//#region src/EngineClient.d.ts
|
|
6
|
-
declare const EngineClient_base: import("ts-mixer/dist/types/types").Class<any[], EngineQueryClient & EngineExecuteClient & EngineWebClient, typeof EngineQueryClient & typeof EngineExecuteClient & typeof EngineWebClient>;
|
|
7
|
+
declare const EngineClient_base: import("ts-mixer/dist/types/types").Class<any[], EngineQueryClient & EngineEdgeQueryClient & EngineExecuteClient & EngineWebClient, typeof EngineQueryClient & typeof EngineEdgeQueryClient & typeof EngineExecuteClient & typeof EngineWebClient>;
|
|
7
8
|
/**
|
|
8
|
-
* Combined Engine client providing query, execution, and WebSocket functionality for off-chain matching engine communication
|
|
9
|
+
* Combined Engine client providing query, edge (cached) query, execution, and WebSocket functionality for off-chain matching engine communication
|
|
9
10
|
*/
|
|
10
11
|
declare class EngineClient extends EngineClient_base {}
|
|
11
12
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EngineClient.d.cts","names":[],"sources":["../src/src/EngineClient.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"EngineClient.d.cts","names":[],"sources":["../src/src/EngineClient.ts"],"mappings":";;;;;;cAIoD,iBAAA;;AAAA;;cAKvC,YAAA,SAAqB,iBAKjC"}
|
package/dist/EngineClient.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import { t as
|
|
3
|
-
import { t as
|
|
1
|
+
import { t as EngineEdgeQueryClient } from "./EngineEdgeQueryClient-B9Y8srJa.js";
|
|
2
|
+
import { t as EngineExecuteClient } from "./EngineExecuteClient-ReEcySA_.js";
|
|
3
|
+
import { t as EngineQueryClient } from "./EngineQueryClient-C0xBMTo-.js";
|
|
4
|
+
import { t as EngineWebClient } from "./EngineWebClient-KXOdpUol.js";
|
|
4
5
|
|
|
5
6
|
//#region src/EngineClient.d.ts
|
|
6
|
-
declare const EngineClient_base: import("ts-mixer/dist/types/types").Class<any[], EngineQueryClient & EngineExecuteClient & EngineWebClient, typeof EngineQueryClient & typeof EngineExecuteClient & typeof EngineWebClient>;
|
|
7
|
+
declare const EngineClient_base: import("ts-mixer/dist/types/types").Class<any[], EngineQueryClient & EngineEdgeQueryClient & EngineExecuteClient & EngineWebClient, typeof EngineQueryClient & typeof EngineEdgeQueryClient & typeof EngineExecuteClient & typeof EngineWebClient>;
|
|
7
8
|
/**
|
|
8
|
-
* Combined Engine client providing query, execution, and WebSocket functionality for off-chain matching engine communication
|
|
9
|
+
* Combined Engine client providing query, edge (cached) query, execution, and WebSocket functionality for off-chain matching engine communication
|
|
9
10
|
*/
|
|
10
11
|
declare class EngineClient extends EngineClient_base {}
|
|
11
12
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EngineClient.d.ts","names":[],"sources":["../src/src/EngineClient.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"EngineClient.d.ts","names":[],"sources":["../src/src/EngineClient.ts"],"mappings":";;;;;;cAIoD,iBAAA;;AAAA;;cAKvC,YAAA,SAAqB,iBAKjC"}
|
package/dist/EngineClient.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { EngineEdgeQueryClient } from "./EngineEdgeQueryClient.js";
|
|
1
2
|
import { EngineExecuteClient } from "./EngineExecuteClient.js";
|
|
2
3
|
import { EngineQueryClient } from "./EngineQueryClient.js";
|
|
3
4
|
import { EngineWebClient } from "./EngineWebClient.js";
|
|
4
5
|
import { Mixin } from "ts-mixer";
|
|
5
6
|
//#region src/EngineClient.ts
|
|
6
7
|
/**
|
|
7
|
-
* Combined Engine client providing query, execution, and WebSocket functionality for off-chain matching engine communication
|
|
8
|
+
* Combined Engine client providing query, edge (cached) query, execution, and WebSocket functionality for off-chain matching engine communication
|
|
8
9
|
*/
|
|
9
|
-
var EngineClient = class extends Mixin(EngineQueryClient, EngineExecuteClient, EngineWebClient) {};
|
|
10
|
+
var EngineClient = class extends Mixin(EngineQueryClient, EngineEdgeQueryClient, EngineExecuteClient, EngineWebClient) {};
|
|
10
11
|
//#endregion
|
|
11
12
|
export { EngineClient };
|
|
12
13
|
|
package/dist/EngineClient.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EngineClient.js","names":[],"sources":["../src/EngineClient.ts"],"sourcesContent":["import { Mixin } from 'ts-mixer';\nimport { EngineExecuteClient } from './EngineExecuteClient';\nimport { EngineQueryClient } from './EngineQueryClient';\nimport { EngineWebClient } from './EngineWebClient';\n\n/**\n * Combined Engine client providing query, execution, and WebSocket functionality for off-chain matching engine communication\n */\nexport class EngineClient extends Mixin(\n EngineQueryClient,\n EngineExecuteClient,\n EngineWebClient,\n) {}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"EngineClient.js","names":[],"sources":["../src/EngineClient.ts"],"sourcesContent":["import { Mixin } from 'ts-mixer';\nimport { EngineEdgeQueryClient } from './EngineEdgeQueryClient';\nimport { EngineExecuteClient } from './EngineExecuteClient';\nimport { EngineQueryClient } from './EngineQueryClient';\nimport { EngineWebClient } from './EngineWebClient';\n\n/**\n * Combined Engine client providing query, edge (cached) query, execution, and WebSocket functionality for off-chain matching engine communication\n */\nexport class EngineClient extends Mixin(\n EngineQueryClient,\n EngineEdgeQueryClient,\n EngineExecuteClient,\n EngineWebClient,\n) {}\n"],"mappings":";;;;;;;;;AASA,IAAa,eAAb,cAAkC,MAChC,mBACA,uBACA,qBACA,eACF,EAAE,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { q as EngineServerStatusResponse } from "./serverQueryTypes-B3vC8vxT.js";
|
|
2
|
+
import { M as GetEngineMarketPricesResponse, U as GetEngineNlpPoolInfoResponse, _ as GetEngineContractsResponse, b as GetEngineHealthGroupsResponse, c as EnginePingResponse, f as EngineSymbolsResponse, g as GetEngineCachedMarketPricesParams, h as GetEngineCachedBboHistoryResponse, m as GetEngineCachedBboHistoryParams, n as EngineCachedTimeParams, nt as GetEngineSymbolsParams, p as GetEngineAllMarketsResponse, s as EnginePingParams } from "./clientQueryTypes-BaYOTnpm.js";
|
|
3
|
+
import { t as EngineBaseClient } from "./EngineBaseClient-Cn4PMYKt.js";
|
|
4
|
+
import { MarketWithProduct } from "@nadohq/shared";
|
|
5
|
+
|
|
6
|
+
//#region src/EngineEdgeQueryClient.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* "Edge" queries hit the gateway's in-memory cache via `/edge/query`. They are lower latency
|
|
9
|
+
* than the live {@link EngineQueryClient} queries but eventually consistent — do not use them
|
|
10
|
+
* for order, margin, or settlement decisions.
|
|
11
|
+
*
|
|
12
|
+
* Each `getCached*` method mirrors the data shape of its live counterpart; only the request
|
|
13
|
+
* type and refresh semantics differ.
|
|
14
|
+
*
|
|
15
|
+
* @see https://docs.nado.xyz/developer-resources/api/gateway/edge
|
|
16
|
+
*/
|
|
17
|
+
declare class EngineEdgeQueryClient extends EngineBaseClient {
|
|
18
|
+
/**
|
|
19
|
+
* Cached highest bid / lowest ask per product. Products with no cached best-bid/offer yet are
|
|
20
|
+
* silently omitted, so the returned array may be shorter than `productIds`.
|
|
21
|
+
*
|
|
22
|
+
* @param params Omit `productIds` to return every product currently in the cache
|
|
23
|
+
*/
|
|
24
|
+
getCachedMarketPrices(params?: GetEngineCachedMarketPricesParams): Promise<GetEngineMarketPricesResponse>;
|
|
25
|
+
/**
|
|
26
|
+
* Cached product metadata and trading config (increments, fees, weights, trading status).
|
|
27
|
+
*
|
|
28
|
+
* @param params Optional `productIds` / `productType` filters
|
|
29
|
+
*/
|
|
30
|
+
getCachedSymbols(params?: GetEngineSymbolsParams): Promise<EngineSymbolsResponse>;
|
|
31
|
+
/**
|
|
32
|
+
* Cached chain ID and on-chain contract addresses for the current chain. Always available: if
|
|
33
|
+
* the cache is cold the gateway falls back to its live contract config.
|
|
34
|
+
*/
|
|
35
|
+
getCachedContracts(): Promise<GetEngineContractsResponse>;
|
|
36
|
+
/**
|
|
37
|
+
* Cached engine status (e.g. `active`, `syncing`). Refreshed every 500ms.
|
|
38
|
+
*/
|
|
39
|
+
getCachedStatus(): Promise<EngineServerStatusResponse>;
|
|
40
|
+
/**
|
|
41
|
+
* Cached full config, risk, and on-chain state for every spot and perp product.
|
|
42
|
+
*/
|
|
43
|
+
getCachedAllMarkets(): Promise<GetEngineAllMarketsResponse>;
|
|
44
|
+
/**
|
|
45
|
+
* Cached all products grouped per edge market, keyed by chain ID.
|
|
46
|
+
*/
|
|
47
|
+
getCachedEdgeAllMarkets(): Promise<Record<number, MarketWithProduct[]>>;
|
|
48
|
+
/**
|
|
49
|
+
* Cached spot/perp product pairings used for health grouping.
|
|
50
|
+
*/
|
|
51
|
+
getCachedHealthGroups(): Promise<GetEngineHealthGroupsResponse>;
|
|
52
|
+
/**
|
|
53
|
+
* Cached NLP pool information. Refreshed every 5s.
|
|
54
|
+
*/
|
|
55
|
+
getCachedNlpPoolInfo(): Promise<GetEngineNlpPoolInfoResponse>;
|
|
56
|
+
/**
|
|
57
|
+
* A rolling, down-samplable time series of best-bid/offer snapshots per product. The gateway
|
|
58
|
+
* samples the live price cache every 500ms and retains up to 30 minutes of history per product.
|
|
59
|
+
*
|
|
60
|
+
* @param params
|
|
61
|
+
*/
|
|
62
|
+
getCachedBboHistory(params?: GetEngineCachedBboHistoryParams): Promise<GetEngineCachedBboHistoryResponse>;
|
|
63
|
+
/**
|
|
64
|
+
* Latency / clock-sync helper. Echoes `clientTime` back alongside the server time so the caller
|
|
65
|
+
* can measure round-trip latency and clock offset in one call.
|
|
66
|
+
*
|
|
67
|
+
* @param params
|
|
68
|
+
*/
|
|
69
|
+
ping(params?: EnginePingParams): Promise<EnginePingResponse>;
|
|
70
|
+
/**
|
|
71
|
+
* Returns the current server time (epoch ms) from the gateway clock.
|
|
72
|
+
*
|
|
73
|
+
* @param params
|
|
74
|
+
*/
|
|
75
|
+
getEdgeControlTime(params?: EngineCachedTimeParams): Promise<number>;
|
|
76
|
+
}
|
|
77
|
+
//#endregion
|
|
78
|
+
export { EngineEdgeQueryClient as t };
|
|
79
|
+
//# sourceMappingURL=EngineEdgeQueryClient-B9Y8srJa.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EngineEdgeQueryClient-B9Y8srJa.d.ts","names":[],"sources":["../src/src/EngineEdgeQueryClient.ts"],"mappings":";;;;;;;;;;AAsCA;;;;;;cAAa,qBAAA,SAA8B,gBAAA;EAyB9B;;;;;;EAlBL,qBAAA,CACJ,MAAA,GAAQ,iCAAA,GACP,OAAA,CAAQ,6BAAA;EAiDkB;;;;;EAnCvB,gBAAA,CACJ,MAAA,GAAQ,sBAAA,GACP,OAAA,CAAQ,qBAAA;EAyF2B;;;;EA1EhC,kBAAA,CAAA,GAAsB,OAAA,CAAQ,0BAAA;EAuGjB;;;EA5Fb,eAAA,CAAA,GAAmB,OAAA,CAAQ,0BAAA;EAmH9B;;;EA5GG,mBAAA,CAAA,GAAuB,OAAA,CAAQ,2BAAA;EA1DI;;;EA2EnC,uBAAA,CAAA,GAA2B,OAAA,CAC/B,MAAA,SAAe,iBAAA;EAnEd;;;EAyFG,qBAAA,CAAA,GAAyB,OAAA,CAAQ,6BAAA;EA1ErC;;;EA0FI,oBAAA,CAAA,GAAwB,OAAA,CAAQ,4BAAA;EA1EV;;;;;;EAqFtB,mBAAA,CACJ,MAAA,GAAQ,+BAAA,GACP,OAAA,CAAQ,iCAAA;EArE0B;;;;;;EAqF/B,IAAA,CAAK,MAAA,GAAQ,gBAAA,GAAwB,OAAA,CAAQ,kBAAA;EA7CZ;;;;;EAkEjC,kBAAA,CACJ,MAAA,GAAQ,sBAAA,GACP,OAAA;AAAA"}
|