@nadohq/client 0.1.0-alpha.1
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/README.md +3 -0
- package/dist/apis/base.cjs +66 -0
- package/dist/apis/base.cjs.map +1 -0
- package/dist/apis/base.d.cts +23 -0
- package/dist/apis/base.d.ts +23 -0
- package/dist/apis/base.js +41 -0
- package/dist/apis/base.js.map +1 -0
- package/dist/apis/market/MarketExecuteAPI.cjs +169 -0
- package/dist/apis/market/MarketExecuteAPI.cjs.map +1 -0
- package/dist/apis/market/MarketExecuteAPI.d.cts +57 -0
- package/dist/apis/market/MarketExecuteAPI.d.ts +57 -0
- package/dist/apis/market/MarketExecuteAPI.js +144 -0
- package/dist/apis/market/MarketExecuteAPI.js.map +1 -0
- package/dist/apis/market/MarketQueryAPI.cjs +191 -0
- package/dist/apis/market/MarketQueryAPI.cjs.map +1 -0
- package/dist/apis/market/MarketQueryAPI.d.cts +127 -0
- package/dist/apis/market/MarketQueryAPI.d.ts +127 -0
- package/dist/apis/market/MarketQueryAPI.js +166 -0
- package/dist/apis/market/MarketQueryAPI.js.map +1 -0
- package/dist/apis/market/index.cjs +38 -0
- package/dist/apis/market/index.cjs.map +1 -0
- package/dist/apis/market/index.d.cts +18 -0
- package/dist/apis/market/index.d.ts +18 -0
- package/dist/apis/market/index.js +11 -0
- package/dist/apis/market/index.js.map +1 -0
- package/dist/apis/market/types.cjs +19 -0
- package/dist/apis/market/types.cjs.map +1 -0
- package/dist/apis/market/types.d.cts +26 -0
- package/dist/apis/market/types.d.ts +26 -0
- package/dist/apis/market/types.js +1 -0
- package/dist/apis/market/types.js.map +1 -0
- package/dist/apis/perp/PerpExecuteAPI.cjs +36 -0
- package/dist/apis/perp/PerpExecuteAPI.cjs.map +1 -0
- package/dist/apis/perp/PerpExecuteAPI.d.cts +13 -0
- package/dist/apis/perp/PerpExecuteAPI.d.ts +13 -0
- package/dist/apis/perp/PerpExecuteAPI.js +11 -0
- package/dist/apis/perp/PerpExecuteAPI.js.map +1 -0
- package/dist/apis/perp/PerpQueryAPI.cjs +47 -0
- package/dist/apis/perp/PerpQueryAPI.cjs.map +1 -0
- package/dist/apis/perp/PerpQueryAPI.d.cts +23 -0
- package/dist/apis/perp/PerpQueryAPI.d.ts +23 -0
- package/dist/apis/perp/PerpQueryAPI.js +22 -0
- package/dist/apis/perp/PerpQueryAPI.js.map +1 -0
- package/dist/apis/perp/index.cjs +35 -0
- package/dist/apis/perp/index.cjs.map +1 -0
- package/dist/apis/perp/index.d.cts +16 -0
- package/dist/apis/perp/index.d.ts +16 -0
- package/dist/apis/perp/index.js +10 -0
- package/dist/apis/perp/index.js.map +1 -0
- package/dist/apis/spot/BaseSpotAPI.cjs +55 -0
- package/dist/apis/spot/BaseSpotAPI.cjs.map +1 -0
- package/dist/apis/spot/BaseSpotAPI.d.cts +19 -0
- package/dist/apis/spot/BaseSpotAPI.d.ts +19 -0
- package/dist/apis/spot/BaseSpotAPI.js +30 -0
- package/dist/apis/spot/BaseSpotAPI.js.map +1 -0
- package/dist/apis/spot/SpotExecuteAPI.cjs +108 -0
- package/dist/apis/spot/SpotExecuteAPI.cjs.map +1 -0
- package/dist/apis/spot/SpotExecuteAPI.d.cts +28 -0
- package/dist/apis/spot/SpotExecuteAPI.d.ts +28 -0
- package/dist/apis/spot/SpotExecuteAPI.js +88 -0
- package/dist/apis/spot/SpotExecuteAPI.js.map +1 -0
- package/dist/apis/spot/SpotQueryAPI.cjs +74 -0
- package/dist/apis/spot/SpotQueryAPI.cjs.map +1 -0
- package/dist/apis/spot/SpotQueryAPI.d.cts +35 -0
- package/dist/apis/spot/SpotQueryAPI.d.ts +35 -0
- package/dist/apis/spot/SpotQueryAPI.js +49 -0
- package/dist/apis/spot/SpotQueryAPI.js.map +1 -0
- package/dist/apis/spot/index.cjs +38 -0
- package/dist/apis/spot/index.cjs.map +1 -0
- package/dist/apis/spot/index.d.cts +23 -0
- package/dist/apis/spot/index.d.ts +23 -0
- package/dist/apis/spot/index.js +11 -0
- package/dist/apis/spot/index.js.map +1 -0
- package/dist/apis/spot/types.cjs +19 -0
- package/dist/apis/spot/types.cjs.map +1 -0
- package/dist/apis/spot/types.d.cts +23 -0
- package/dist/apis/spot/types.d.ts +23 -0
- package/dist/apis/spot/types.js +1 -0
- package/dist/apis/spot/types.js.map +1 -0
- package/dist/apis/subaccount/SubaccountExecuteAPI.cjs +59 -0
- package/dist/apis/subaccount/SubaccountExecuteAPI.cjs.map +1 -0
- package/dist/apis/subaccount/SubaccountExecuteAPI.d.cts +26 -0
- package/dist/apis/subaccount/SubaccountExecuteAPI.d.ts +26 -0
- package/dist/apis/subaccount/SubaccountExecuteAPI.js +34 -0
- package/dist/apis/subaccount/SubaccountExecuteAPI.js.map +1 -0
- package/dist/apis/subaccount/SubaccountQueryAPI.cjs +84 -0
- package/dist/apis/subaccount/SubaccountQueryAPI.cjs.map +1 -0
- package/dist/apis/subaccount/SubaccountQueryAPI.d.cts +51 -0
- package/dist/apis/subaccount/SubaccountQueryAPI.d.ts +51 -0
- package/dist/apis/subaccount/SubaccountQueryAPI.js +61 -0
- package/dist/apis/subaccount/SubaccountQueryAPI.js.map +1 -0
- package/dist/apis/subaccount/index.cjs +68 -0
- package/dist/apis/subaccount/index.cjs.map +1 -0
- package/dist/apis/subaccount/index.d.cts +27 -0
- package/dist/apis/subaccount/index.d.ts +27 -0
- package/dist/apis/subaccount/index.js +41 -0
- package/dist/apis/subaccount/index.js.map +1 -0
- package/dist/apis/subaccount/types.cjs +19 -0
- package/dist/apis/subaccount/types.cjs.map +1 -0
- package/dist/apis/subaccount/types.d.cts +9 -0
- package/dist/apis/subaccount/types.d.ts +9 -0
- package/dist/apis/subaccount/types.js +1 -0
- package/dist/apis/subaccount/types.js.map +1 -0
- package/dist/apis/types.cjs +19 -0
- package/dist/apis/types.cjs.map +1 -0
- package/dist/apis/types.d.cts +9 -0
- package/dist/apis/types.d.ts +9 -0
- package/dist/apis/types.js +1 -0
- package/dist/apis/types.js.map +1 -0
- package/dist/apis/ws/WebSocketExecuteAPI.cjs +73 -0
- package/dist/apis/ws/WebSocketExecuteAPI.cjs.map +1 -0
- package/dist/apis/ws/WebSocketExecuteAPI.d.cts +48 -0
- package/dist/apis/ws/WebSocketExecuteAPI.d.ts +48 -0
- package/dist/apis/ws/WebSocketExecuteAPI.js +48 -0
- package/dist/apis/ws/WebSocketExecuteAPI.js.map +1 -0
- package/dist/apis/ws/WebSocketQueryAPI.cjs +42 -0
- package/dist/apis/ws/WebSocketQueryAPI.cjs.map +1 -0
- package/dist/apis/ws/WebSocketQueryAPI.d.cts +23 -0
- package/dist/apis/ws/WebSocketQueryAPI.d.ts +23 -0
- package/dist/apis/ws/WebSocketQueryAPI.js +17 -0
- package/dist/apis/ws/WebSocketQueryAPI.js.map +1 -0
- package/dist/apis/ws/WebSocketSubscriptionAPI.cjs +61 -0
- package/dist/apis/ws/WebSocketSubscriptionAPI.cjs.map +1 -0
- package/dist/apis/ws/WebSocketSubscriptionAPI.d.cts +37 -0
- package/dist/apis/ws/WebSocketSubscriptionAPI.d.ts +37 -0
- package/dist/apis/ws/WebSocketSubscriptionAPI.js +36 -0
- package/dist/apis/ws/WebSocketSubscriptionAPI.js.map +1 -0
- package/dist/apis/ws/index.cjs +42 -0
- package/dist/apis/ws/index.cjs.map +1 -0
- package/dist/apis/ws/index.d.cts +22 -0
- package/dist/apis/ws/index.d.ts +22 -0
- package/dist/apis/ws/index.js +17 -0
- package/dist/apis/ws/index.js.map +1 -0
- package/dist/client.cjs +79 -0
- package/dist/client.cjs.map +1 -0
- package/dist/client.d.cts +57 -0
- package/dist/client.d.ts +57 -0
- package/dist/client.js +54 -0
- package/dist/client.js.map +1 -0
- package/dist/context.cjs +125 -0
- package/dist/context.cjs.map +1 -0
- package/dist/context.d.cts +42 -0
- package/dist/context.d.ts +42 -0
- package/dist/context.js +109 -0
- package/dist/context.js.map +1 -0
- package/dist/createNadoClient.cjs +35 -0
- package/dist/createNadoClient.cjs.map +1 -0
- package/dist/createNadoClient.d.cts +42 -0
- package/dist/createNadoClient.d.ts +42 -0
- package/dist/createNadoClient.js +12 -0
- package/dist/createNadoClient.js.map +1 -0
- package/dist/index.cjs +47 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +32 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/package.json +54 -0
- package/src/apis/base.ts +52 -0
- package/src/apis/market/MarketExecuteAPI.ts +169 -0
- package/src/apis/market/MarketQueryAPI.ts +214 -0
- package/src/apis/market/index.ts +7 -0
- package/src/apis/market/types.ts +58 -0
- package/src/apis/perp/PerpExecuteAPI.ts +8 -0
- package/src/apis/perp/PerpQueryAPI.ts +25 -0
- package/src/apis/perp/index.ts +5 -0
- package/src/apis/spot/BaseSpotAPI.ts +30 -0
- package/src/apis/spot/SpotExecuteAPI.ts +102 -0
- package/src/apis/spot/SpotQueryAPI.ts +53 -0
- package/src/apis/spot/index.ts +10 -0
- package/src/apis/spot/types.ts +44 -0
- package/src/apis/subaccount/SubaccountExecuteAPI.ts +32 -0
- package/src/apis/subaccount/SubaccountQueryAPI.ts +78 -0
- package/src/apis/subaccount/index.ts +44 -0
- package/src/apis/subaccount/types.ts +16 -0
- package/src/apis/types.ts +11 -0
- package/src/apis/ws/WebSocketExecuteAPI.ts +70 -0
- package/src/apis/ws/WebSocketQueryAPI.ts +25 -0
- package/src/apis/ws/WebSocketSubscriptionAPI.ts +62 -0
- package/src/apis/ws/index.ts +21 -0
- package/src/client.ts +67 -0
- package/src/context.ts +165 -0
- package/src/createNadoClient.ts +20 -0
- package/src/index.ts +15 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/apis/ws/WebSocketSubscriptionAPI.ts"],"sourcesContent":["import {\n EngineServerSubscriptionRequest,\n EngineServerSubscriptionRequestByType,\n EngineServerSubscriptionRequestType,\n EngineServerSubscriptionStream,\n EngineServerSubscriptionStreamParamsByType,\n EngineServerSubscriptionStreamParamsType,\n} from '@nadohq/engine-client';\nimport { BaseNadoAPI } from '../base';\n\n/**\n * Builds subscription messages as expected by the server to send over Websocket.\n *\n * @example\n * const tradeSubscriptionParams = nadoClient.ws.subscription.buildSubscriptionParams('trade', ...);\n * const tradeSubscriptionMessage = nadoClient.ws.subscription.buildSubscriptionMessage(\n * 'subscribe', tradeSubscriptionParams);\n */\nexport class WebSocketSubscriptionAPI extends BaseNadoAPI {\n /**\n * Builds a subscription request message as expected by the server via Websocket.\n * @param requestType name of request to build message for.\n * @param id identifier to associate messages with responses.\n * @param params request message params.\n * @returns subscription request message.\n */\n public buildSubscriptionMessage<\n TRequestType extends EngineServerSubscriptionRequestType,\n >(\n id: number,\n requestType: TRequestType,\n params: EngineServerSubscriptionRequestByType[TRequestType],\n ): EngineServerSubscriptionRequest<TRequestType> {\n return {\n id,\n method: requestType,\n ...params,\n };\n }\n\n /**\n * Builds a subscription stream param as expected by the server via Websocket.\n * @param streamType name of stream to build params for.\n * @param params\n * @returns subscription stream params.\n */\n public buildSubscriptionParams<\n TStreamType extends EngineServerSubscriptionStreamParamsType,\n >(\n streamType: TStreamType,\n params: EngineServerSubscriptionStreamParamsByType[TStreamType],\n ): {\n stream: EngineServerSubscriptionStream<TStreamType>;\n } {\n return {\n stream: {\n type: streamType,\n ...params,\n },\n };\n }\n}\n"],"mappings":";AAQA,SAAS,mBAAmB;AAUrB,IAAM,2BAAN,cAAuC,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQjD,yBAGL,IACA,aACA,QAC+C;AAC/C,WAAO;AAAA,MACL;AAAA,MACA,QAAQ;AAAA,MACR,GAAG;AAAA,IACL;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQO,wBAGL,YACA,QAGA;AACA,WAAO;AAAA,MACL,QAAQ;AAAA,QACN,MAAM;AAAA,QACN,GAAG;AAAA,MACL;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/apis/ws/index.ts
|
|
21
|
+
var ws_exports = {};
|
|
22
|
+
__export(ws_exports, {
|
|
23
|
+
WebsocketAPI: () => WebsocketAPI
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(ws_exports);
|
|
26
|
+
var import_base = require("../base.cjs");
|
|
27
|
+
var import_WebSocketExecuteAPI = require("./WebSocketExecuteAPI.cjs");
|
|
28
|
+
var import_WebSocketQueryAPI = require("./WebSocketQueryAPI.cjs");
|
|
29
|
+
var import_WebSocketSubscriptionAPI = require("./WebSocketSubscriptionAPI.cjs");
|
|
30
|
+
var WebsocketAPI = class extends import_base.BaseNadoAPI {
|
|
31
|
+
constructor(context) {
|
|
32
|
+
super(context);
|
|
33
|
+
this.query = new import_WebSocketQueryAPI.WebSocketQueryAPI(context);
|
|
34
|
+
this.execute = new import_WebSocketExecuteAPI.WebSocketExecuteAPI(context);
|
|
35
|
+
this.subscription = new import_WebSocketSubscriptionAPI.WebSocketSubscriptionAPI(context);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
WebsocketAPI
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/apis/ws/index.ts"],"sourcesContent":["import { NadoClientContext } from '../../context';\nimport { BaseNadoAPI } from '../base';\nimport { WebSocketExecuteAPI } from './WebSocketExecuteAPI';\nimport { WebSocketQueryAPI } from './WebSocketQueryAPI';\nimport { WebSocketSubscriptionAPI } from './WebSocketSubscriptionAPI';\n\n/**\n * Builds ws messages as expected by the server to send over Websocket.\n */\nexport class WebsocketAPI extends BaseNadoAPI {\n readonly query: WebSocketQueryAPI;\n readonly execute: WebSocketExecuteAPI;\n readonly subscription: WebSocketSubscriptionAPI;\n\n constructor(context: NadoClientContext) {\n super(context);\n this.query = new WebSocketQueryAPI(context);\n this.execute = new WebSocketExecuteAPI(context);\n this.subscription = new WebSocketSubscriptionAPI(context);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAA4B;AAC5B,iCAAoC;AACpC,+BAAkC;AAClC,sCAAyC;AAKlC,IAAM,eAAN,cAA2B,wBAAY;AAAA,EAK5C,YAAY,SAA4B;AACtC,UAAM,OAAO;AACb,SAAK,QAAQ,IAAI,2CAAkB,OAAO;AAC1C,SAAK,UAAU,IAAI,+CAAoB,OAAO;AAC9C,SAAK,eAAe,IAAI,yDAAyB,OAAO;AAAA,EAC1D;AACF;","names":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { NadoClientContext } from '../../context.cjs';
|
|
2
|
+
import { BaseNadoAPI } from '../base.cjs';
|
|
3
|
+
import { WebSocketExecuteAPI } from './WebSocketExecuteAPI.cjs';
|
|
4
|
+
import { WebSocketQueryAPI } from './WebSocketQueryAPI.cjs';
|
|
5
|
+
import { WebSocketSubscriptionAPI } from './WebSocketSubscriptionAPI.cjs';
|
|
6
|
+
import '@nadohq/contracts';
|
|
7
|
+
import '@nadohq/engine-client';
|
|
8
|
+
import '@nadohq/indexer-client';
|
|
9
|
+
import '@nadohq/trigger-client';
|
|
10
|
+
import 'viem';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Builds ws messages as expected by the server to send over Websocket.
|
|
14
|
+
*/
|
|
15
|
+
declare class WebsocketAPI extends BaseNadoAPI {
|
|
16
|
+
readonly query: WebSocketQueryAPI;
|
|
17
|
+
readonly execute: WebSocketExecuteAPI;
|
|
18
|
+
readonly subscription: WebSocketSubscriptionAPI;
|
|
19
|
+
constructor(context: NadoClientContext);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { WebsocketAPI };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { NadoClientContext } from '../../context.js';
|
|
2
|
+
import { BaseNadoAPI } from '../base.js';
|
|
3
|
+
import { WebSocketExecuteAPI } from './WebSocketExecuteAPI.js';
|
|
4
|
+
import { WebSocketQueryAPI } from './WebSocketQueryAPI.js';
|
|
5
|
+
import { WebSocketSubscriptionAPI } from './WebSocketSubscriptionAPI.js';
|
|
6
|
+
import '@nadohq/contracts';
|
|
7
|
+
import '@nadohq/engine-client';
|
|
8
|
+
import '@nadohq/indexer-client';
|
|
9
|
+
import '@nadohq/trigger-client';
|
|
10
|
+
import 'viem';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Builds ws messages as expected by the server to send over Websocket.
|
|
14
|
+
*/
|
|
15
|
+
declare class WebsocketAPI extends BaseNadoAPI {
|
|
16
|
+
readonly query: WebSocketQueryAPI;
|
|
17
|
+
readonly execute: WebSocketExecuteAPI;
|
|
18
|
+
readonly subscription: WebSocketSubscriptionAPI;
|
|
19
|
+
constructor(context: NadoClientContext);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { WebsocketAPI };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/apis/ws/index.ts
|
|
2
|
+
import { BaseNadoAPI } from "../base.js";
|
|
3
|
+
import { WebSocketExecuteAPI } from "./WebSocketExecuteAPI.js";
|
|
4
|
+
import { WebSocketQueryAPI } from "./WebSocketQueryAPI.js";
|
|
5
|
+
import { WebSocketSubscriptionAPI } from "./WebSocketSubscriptionAPI.js";
|
|
6
|
+
var WebsocketAPI = class extends BaseNadoAPI {
|
|
7
|
+
constructor(context) {
|
|
8
|
+
super(context);
|
|
9
|
+
this.query = new WebSocketQueryAPI(context);
|
|
10
|
+
this.execute = new WebSocketExecuteAPI(context);
|
|
11
|
+
this.subscription = new WebSocketSubscriptionAPI(context);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
WebsocketAPI
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/apis/ws/index.ts"],"sourcesContent":["import { NadoClientContext } from '../../context';\nimport { BaseNadoAPI } from '../base';\nimport { WebSocketExecuteAPI } from './WebSocketExecuteAPI';\nimport { WebSocketQueryAPI } from './WebSocketQueryAPI';\nimport { WebSocketSubscriptionAPI } from './WebSocketSubscriptionAPI';\n\n/**\n * Builds ws messages as expected by the server to send over Websocket.\n */\nexport class WebsocketAPI extends BaseNadoAPI {\n readonly query: WebSocketQueryAPI;\n readonly execute: WebSocketExecuteAPI;\n readonly subscription: WebSocketSubscriptionAPI;\n\n constructor(context: NadoClientContext) {\n super(context);\n this.query = new WebSocketQueryAPI(context);\n this.execute = new WebSocketExecuteAPI(context);\n this.subscription = new WebSocketSubscriptionAPI(context);\n }\n}\n"],"mappings":";AACA,SAAS,mBAAmB;AAC5B,SAAS,2BAA2B;AACpC,SAAS,yBAAyB;AAClC,SAAS,gCAAgC;AAKlC,IAAM,eAAN,cAA2B,YAAY;AAAA,EAK5C,YAAY,SAA4B;AACtC,UAAM,OAAO;AACb,SAAK,QAAQ,IAAI,kBAAkB,OAAO;AAC1C,SAAK,UAAU,IAAI,oBAAoB,OAAO;AAC9C,SAAK,eAAe,IAAI,yBAAyB,OAAO;AAAA,EAC1D;AACF;","names":[]}
|
package/dist/client.cjs
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/client.ts
|
|
21
|
+
var client_exports = {};
|
|
22
|
+
__export(client_exports, {
|
|
23
|
+
NadoClient: () => NadoClient
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(client_exports);
|
|
26
|
+
var import_market = require("./apis/market/index.cjs");
|
|
27
|
+
var import_perp = require("./apis/perp/index.cjs");
|
|
28
|
+
var import_spot = require("./apis/spot/index.cjs");
|
|
29
|
+
var import_subaccount = require("./apis/subaccount/index.cjs");
|
|
30
|
+
var import_ws = require("./apis/ws/index.cjs");
|
|
31
|
+
var import_context = require("./context.cjs");
|
|
32
|
+
var NadoClient = class {
|
|
33
|
+
constructor(context) {
|
|
34
|
+
this.setupFromContext(context);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Sets the linked signer for the client. Set to null to revert to the chain signer.
|
|
38
|
+
* @param linkedSignerWalletClient
|
|
39
|
+
*/
|
|
40
|
+
setLinkedSigner(linkedSignerWalletClient) {
|
|
41
|
+
this.context.linkedSignerWalletClient = linkedSignerWalletClient ?? void 0;
|
|
42
|
+
this.context.engineClient.setLinkedSigner(linkedSignerWalletClient);
|
|
43
|
+
this.context.triggerClient.setLinkedSigner(linkedSignerWalletClient);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Sets the WalletClient for the client. Will cause a full reload of the current context.
|
|
47
|
+
* @param walletClient
|
|
48
|
+
*/
|
|
49
|
+
setWalletClient(walletClient) {
|
|
50
|
+
const newContext = (0, import_context.createClientContext)(
|
|
51
|
+
{
|
|
52
|
+
contractAddresses: this.context.contractAddresses,
|
|
53
|
+
engineEndpoint: this.context.engineClient.opts.url,
|
|
54
|
+
indexerEndpoint: this.context.indexerClient.opts.url,
|
|
55
|
+
triggerEndpoint: this.context.triggerClient.opts.url
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
walletClient,
|
|
59
|
+
// No need to call setLinkedSigner as this property doesn't change
|
|
60
|
+
linkedSignerWalletClient: this.context.linkedSignerWalletClient,
|
|
61
|
+
publicClient: this.context.publicClient
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
this.setupFromContext(newContext);
|
|
65
|
+
}
|
|
66
|
+
setupFromContext(context) {
|
|
67
|
+
this.context = context;
|
|
68
|
+
this.market = new import_market.MarketAPI(context);
|
|
69
|
+
this.subaccount = new import_subaccount.SubaccountAPI(context);
|
|
70
|
+
this.spot = new import_spot.SpotAPI(context);
|
|
71
|
+
this.perp = new import_perp.PerpAPI(context);
|
|
72
|
+
this.ws = new import_ws.WebsocketAPI(context);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
76
|
+
0 && (module.exports = {
|
|
77
|
+
NadoClient
|
|
78
|
+
});
|
|
79
|
+
//# sourceMappingURL=client.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/client.ts"],"sourcesContent":["import { WalletClientWithAccount } from '@nadohq/contracts';\nimport { MarketAPI } from './apis/market';\nimport { PerpAPI } from './apis/perp';\nimport { SpotAPI } from './apis/spot';\nimport { SubaccountAPI } from './apis/subaccount';\nimport { WebsocketAPI } from './apis/ws';\nimport { createClientContext, NadoClientContext } from './context';\n\n/**\n * Client for querying and executing against Nado Clearinghouse.\n * Usually not instantiated directly. Instead, use {@link createNadoClient:CLIENT}.\n */\nexport class NadoClient {\n context!: NadoClientContext;\n market!: MarketAPI;\n subaccount!: SubaccountAPI;\n spot!: SpotAPI;\n perp!: PerpAPI;\n ws!: WebsocketAPI;\n\n constructor(context: NadoClientContext) {\n this.setupFromContext(context);\n }\n\n /**\n * Sets the linked signer for the client. Set to null to revert to the chain signer.\n * @param linkedSignerWalletClient\n */\n setLinkedSigner(linkedSignerWalletClient: WalletClientWithAccount | null) {\n // This is a bit ugly, but works for now\n this.context.linkedSignerWalletClient =\n linkedSignerWalletClient ?? undefined;\n this.context.engineClient.setLinkedSigner(linkedSignerWalletClient);\n this.context.triggerClient.setLinkedSigner(linkedSignerWalletClient);\n }\n\n /**\n * Sets the WalletClient for the client. Will cause a full reload of the current context.\n * @param walletClient\n */\n setWalletClient(walletClient: NadoClientContext['walletClient']) {\n const newContext = createClientContext(\n {\n contractAddresses: this.context.contractAddresses,\n engineEndpoint: this.context.engineClient.opts.url,\n indexerEndpoint: this.context.indexerClient.opts.url,\n triggerEndpoint: this.context.triggerClient.opts.url,\n },\n {\n walletClient,\n // No need to call setLinkedSigner as this property doesn't change\n linkedSignerWalletClient: this.context.linkedSignerWalletClient,\n publicClient: this.context.publicClient,\n },\n );\n this.setupFromContext(newContext);\n }\n\n private setupFromContext(context: NadoClientContext) {\n this.context = context;\n this.market = new MarketAPI(context);\n this.subaccount = new SubaccountAPI(context);\n this.spot = new SpotAPI(context);\n this.perp = new PerpAPI(context);\n this.ws = new WebsocketAPI(context);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA0B;AAC1B,kBAAwB;AACxB,kBAAwB;AACxB,wBAA8B;AAC9B,gBAA6B;AAC7B,qBAAuD;AAMhD,IAAM,aAAN,MAAiB;AAAA,EAQtB,YAAY,SAA4B;AACtC,SAAK,iBAAiB,OAAO;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,gBAAgB,0BAA0D;AAExE,SAAK,QAAQ,2BACX,4BAA4B;AAC9B,SAAK,QAAQ,aAAa,gBAAgB,wBAAwB;AAClE,SAAK,QAAQ,cAAc,gBAAgB,wBAAwB;AAAA,EACrE;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,gBAAgB,cAAiD;AAC/D,UAAM,iBAAa;AAAA,MACjB;AAAA,QACE,mBAAmB,KAAK,QAAQ;AAAA,QAChC,gBAAgB,KAAK,QAAQ,aAAa,KAAK;AAAA,QAC/C,iBAAiB,KAAK,QAAQ,cAAc,KAAK;AAAA,QACjD,iBAAiB,KAAK,QAAQ,cAAc,KAAK;AAAA,MACnD;AAAA,MACA;AAAA,QACE;AAAA;AAAA,QAEA,0BAA0B,KAAK,QAAQ;AAAA,QACvC,cAAc,KAAK,QAAQ;AAAA,MAC7B;AAAA,IACF;AACA,SAAK,iBAAiB,UAAU;AAAA,EAClC;AAAA,EAEQ,iBAAiB,SAA4B;AACnD,SAAK,UAAU;AACf,SAAK,SAAS,IAAI,wBAAU,OAAO;AACnC,SAAK,aAAa,IAAI,gCAAc,OAAO;AAC3C,SAAK,OAAO,IAAI,oBAAQ,OAAO;AAC/B,SAAK,OAAO,IAAI,oBAAQ,OAAO;AAC/B,SAAK,KAAK,IAAI,uBAAa,OAAO;AAAA,EACpC;AACF;","names":[]}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { WalletClientWithAccount } from '@nadohq/contracts';
|
|
2
|
+
import { MarketAPI } from './apis/market/index.cjs';
|
|
3
|
+
import { PerpAPI } from './apis/perp/index.cjs';
|
|
4
|
+
import { SpotAPI } from './apis/spot/index.cjs';
|
|
5
|
+
import { SubaccountAPI } from './apis/subaccount/index.cjs';
|
|
6
|
+
import { WebsocketAPI } from './apis/ws/index.cjs';
|
|
7
|
+
import { NadoClientContext } from './context.cjs';
|
|
8
|
+
import 'ts-mixer/dist/types/types';
|
|
9
|
+
import './apis/market/MarketExecuteAPI.cjs';
|
|
10
|
+
import '@nadohq/trigger-client';
|
|
11
|
+
import '@nadohq/engine-client';
|
|
12
|
+
import './apis/base.cjs';
|
|
13
|
+
import './apis/types.cjs';
|
|
14
|
+
import './apis/market/types.cjs';
|
|
15
|
+
import './apis/market/MarketQueryAPI.cjs';
|
|
16
|
+
import '@nadohq/indexer-client';
|
|
17
|
+
import './apis/perp/PerpExecuteAPI.cjs';
|
|
18
|
+
import './apis/perp/PerpQueryAPI.cjs';
|
|
19
|
+
import './apis/spot/SpotExecuteAPI.cjs';
|
|
20
|
+
import './apis/spot/BaseSpotAPI.cjs';
|
|
21
|
+
import './apis/spot/types.cjs';
|
|
22
|
+
import '@nadohq/utils';
|
|
23
|
+
import './apis/spot/SpotQueryAPI.cjs';
|
|
24
|
+
import './apis/subaccount/SubaccountExecuteAPI.cjs';
|
|
25
|
+
import './apis/subaccount/types.cjs';
|
|
26
|
+
import './apis/subaccount/SubaccountQueryAPI.cjs';
|
|
27
|
+
import './apis/ws/WebSocketExecuteAPI.cjs';
|
|
28
|
+
import './apis/ws/WebSocketQueryAPI.cjs';
|
|
29
|
+
import './apis/ws/WebSocketSubscriptionAPI.cjs';
|
|
30
|
+
import 'viem';
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Client for querying and executing against Nado Clearinghouse.
|
|
34
|
+
* Usually not instantiated directly. Instead, use {@link createNadoClient:CLIENT}.
|
|
35
|
+
*/
|
|
36
|
+
declare class NadoClient {
|
|
37
|
+
context: NadoClientContext;
|
|
38
|
+
market: MarketAPI;
|
|
39
|
+
subaccount: SubaccountAPI;
|
|
40
|
+
spot: SpotAPI;
|
|
41
|
+
perp: PerpAPI;
|
|
42
|
+
ws: WebsocketAPI;
|
|
43
|
+
constructor(context: NadoClientContext);
|
|
44
|
+
/**
|
|
45
|
+
* Sets the linked signer for the client. Set to null to revert to the chain signer.
|
|
46
|
+
* @param linkedSignerWalletClient
|
|
47
|
+
*/
|
|
48
|
+
setLinkedSigner(linkedSignerWalletClient: WalletClientWithAccount | null): void;
|
|
49
|
+
/**
|
|
50
|
+
* Sets the WalletClient for the client. Will cause a full reload of the current context.
|
|
51
|
+
* @param walletClient
|
|
52
|
+
*/
|
|
53
|
+
setWalletClient(walletClient: NadoClientContext['walletClient']): void;
|
|
54
|
+
private setupFromContext;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export { NadoClient };
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { WalletClientWithAccount } from '@nadohq/contracts';
|
|
2
|
+
import { MarketAPI } from './apis/market/index.js';
|
|
3
|
+
import { PerpAPI } from './apis/perp/index.js';
|
|
4
|
+
import { SpotAPI } from './apis/spot/index.js';
|
|
5
|
+
import { SubaccountAPI } from './apis/subaccount/index.js';
|
|
6
|
+
import { WebsocketAPI } from './apis/ws/index.js';
|
|
7
|
+
import { NadoClientContext } from './context.js';
|
|
8
|
+
import 'ts-mixer/dist/types/types';
|
|
9
|
+
import './apis/market/MarketExecuteAPI.js';
|
|
10
|
+
import '@nadohq/trigger-client';
|
|
11
|
+
import '@nadohq/engine-client';
|
|
12
|
+
import './apis/base.js';
|
|
13
|
+
import './apis/types.js';
|
|
14
|
+
import './apis/market/types.js';
|
|
15
|
+
import './apis/market/MarketQueryAPI.js';
|
|
16
|
+
import '@nadohq/indexer-client';
|
|
17
|
+
import './apis/perp/PerpExecuteAPI.js';
|
|
18
|
+
import './apis/perp/PerpQueryAPI.js';
|
|
19
|
+
import './apis/spot/SpotExecuteAPI.js';
|
|
20
|
+
import './apis/spot/BaseSpotAPI.js';
|
|
21
|
+
import './apis/spot/types.js';
|
|
22
|
+
import '@nadohq/utils';
|
|
23
|
+
import './apis/spot/SpotQueryAPI.js';
|
|
24
|
+
import './apis/subaccount/SubaccountExecuteAPI.js';
|
|
25
|
+
import './apis/subaccount/types.js';
|
|
26
|
+
import './apis/subaccount/SubaccountQueryAPI.js';
|
|
27
|
+
import './apis/ws/WebSocketExecuteAPI.js';
|
|
28
|
+
import './apis/ws/WebSocketQueryAPI.js';
|
|
29
|
+
import './apis/ws/WebSocketSubscriptionAPI.js';
|
|
30
|
+
import 'viem';
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Client for querying and executing against Nado Clearinghouse.
|
|
34
|
+
* Usually not instantiated directly. Instead, use {@link createNadoClient:CLIENT}.
|
|
35
|
+
*/
|
|
36
|
+
declare class NadoClient {
|
|
37
|
+
context: NadoClientContext;
|
|
38
|
+
market: MarketAPI;
|
|
39
|
+
subaccount: SubaccountAPI;
|
|
40
|
+
spot: SpotAPI;
|
|
41
|
+
perp: PerpAPI;
|
|
42
|
+
ws: WebsocketAPI;
|
|
43
|
+
constructor(context: NadoClientContext);
|
|
44
|
+
/**
|
|
45
|
+
* Sets the linked signer for the client. Set to null to revert to the chain signer.
|
|
46
|
+
* @param linkedSignerWalletClient
|
|
47
|
+
*/
|
|
48
|
+
setLinkedSigner(linkedSignerWalletClient: WalletClientWithAccount | null): void;
|
|
49
|
+
/**
|
|
50
|
+
* Sets the WalletClient for the client. Will cause a full reload of the current context.
|
|
51
|
+
* @param walletClient
|
|
52
|
+
*/
|
|
53
|
+
setWalletClient(walletClient: NadoClientContext['walletClient']): void;
|
|
54
|
+
private setupFromContext;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export { NadoClient };
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// src/client.ts
|
|
2
|
+
import { MarketAPI } from "./apis/market/index.js";
|
|
3
|
+
import { PerpAPI } from "./apis/perp/index.js";
|
|
4
|
+
import { SpotAPI } from "./apis/spot/index.js";
|
|
5
|
+
import { SubaccountAPI } from "./apis/subaccount/index.js";
|
|
6
|
+
import { WebsocketAPI } from "./apis/ws/index.js";
|
|
7
|
+
import { createClientContext } from "./context.js";
|
|
8
|
+
var NadoClient = class {
|
|
9
|
+
constructor(context) {
|
|
10
|
+
this.setupFromContext(context);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Sets the linked signer for the client. Set to null to revert to the chain signer.
|
|
14
|
+
* @param linkedSignerWalletClient
|
|
15
|
+
*/
|
|
16
|
+
setLinkedSigner(linkedSignerWalletClient) {
|
|
17
|
+
this.context.linkedSignerWalletClient = linkedSignerWalletClient ?? void 0;
|
|
18
|
+
this.context.engineClient.setLinkedSigner(linkedSignerWalletClient);
|
|
19
|
+
this.context.triggerClient.setLinkedSigner(linkedSignerWalletClient);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Sets the WalletClient for the client. Will cause a full reload of the current context.
|
|
23
|
+
* @param walletClient
|
|
24
|
+
*/
|
|
25
|
+
setWalletClient(walletClient) {
|
|
26
|
+
const newContext = createClientContext(
|
|
27
|
+
{
|
|
28
|
+
contractAddresses: this.context.contractAddresses,
|
|
29
|
+
engineEndpoint: this.context.engineClient.opts.url,
|
|
30
|
+
indexerEndpoint: this.context.indexerClient.opts.url,
|
|
31
|
+
triggerEndpoint: this.context.triggerClient.opts.url
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
walletClient,
|
|
35
|
+
// No need to call setLinkedSigner as this property doesn't change
|
|
36
|
+
linkedSignerWalletClient: this.context.linkedSignerWalletClient,
|
|
37
|
+
publicClient: this.context.publicClient
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
this.setupFromContext(newContext);
|
|
41
|
+
}
|
|
42
|
+
setupFromContext(context) {
|
|
43
|
+
this.context = context;
|
|
44
|
+
this.market = new MarketAPI(context);
|
|
45
|
+
this.subaccount = new SubaccountAPI(context);
|
|
46
|
+
this.spot = new SpotAPI(context);
|
|
47
|
+
this.perp = new PerpAPI(context);
|
|
48
|
+
this.ws = new WebsocketAPI(context);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
export {
|
|
52
|
+
NadoClient
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/client.ts"],"sourcesContent":["import { WalletClientWithAccount } from '@nadohq/contracts';\nimport { MarketAPI } from './apis/market';\nimport { PerpAPI } from './apis/perp';\nimport { SpotAPI } from './apis/spot';\nimport { SubaccountAPI } from './apis/subaccount';\nimport { WebsocketAPI } from './apis/ws';\nimport { createClientContext, NadoClientContext } from './context';\n\n/**\n * Client for querying and executing against Nado Clearinghouse.\n * Usually not instantiated directly. Instead, use {@link createNadoClient:CLIENT}.\n */\nexport class NadoClient {\n context!: NadoClientContext;\n market!: MarketAPI;\n subaccount!: SubaccountAPI;\n spot!: SpotAPI;\n perp!: PerpAPI;\n ws!: WebsocketAPI;\n\n constructor(context: NadoClientContext) {\n this.setupFromContext(context);\n }\n\n /**\n * Sets the linked signer for the client. Set to null to revert to the chain signer.\n * @param linkedSignerWalletClient\n */\n setLinkedSigner(linkedSignerWalletClient: WalletClientWithAccount | null) {\n // This is a bit ugly, but works for now\n this.context.linkedSignerWalletClient =\n linkedSignerWalletClient ?? undefined;\n this.context.engineClient.setLinkedSigner(linkedSignerWalletClient);\n this.context.triggerClient.setLinkedSigner(linkedSignerWalletClient);\n }\n\n /**\n * Sets the WalletClient for the client. Will cause a full reload of the current context.\n * @param walletClient\n */\n setWalletClient(walletClient: NadoClientContext['walletClient']) {\n const newContext = createClientContext(\n {\n contractAddresses: this.context.contractAddresses,\n engineEndpoint: this.context.engineClient.opts.url,\n indexerEndpoint: this.context.indexerClient.opts.url,\n triggerEndpoint: this.context.triggerClient.opts.url,\n },\n {\n walletClient,\n // No need to call setLinkedSigner as this property doesn't change\n linkedSignerWalletClient: this.context.linkedSignerWalletClient,\n publicClient: this.context.publicClient,\n },\n );\n this.setupFromContext(newContext);\n }\n\n private setupFromContext(context: NadoClientContext) {\n this.context = context;\n this.market = new MarketAPI(context);\n this.subaccount = new SubaccountAPI(context);\n this.spot = new SpotAPI(context);\n this.perp = new PerpAPI(context);\n this.ws = new WebsocketAPI(context);\n }\n}\n"],"mappings":";AACA,SAAS,iBAAiB;AAC1B,SAAS,eAAe;AACxB,SAAS,eAAe;AACxB,SAAS,qBAAqB;AAC9B,SAAS,oBAAoB;AAC7B,SAAS,2BAA8C;AAMhD,IAAM,aAAN,MAAiB;AAAA,EAQtB,YAAY,SAA4B;AACtC,SAAK,iBAAiB,OAAO;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,gBAAgB,0BAA0D;AAExE,SAAK,QAAQ,2BACX,4BAA4B;AAC9B,SAAK,QAAQ,aAAa,gBAAgB,wBAAwB;AAClE,SAAK,QAAQ,cAAc,gBAAgB,wBAAwB;AAAA,EACrE;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,gBAAgB,cAAiD;AAC/D,UAAM,aAAa;AAAA,MACjB;AAAA,QACE,mBAAmB,KAAK,QAAQ;AAAA,QAChC,gBAAgB,KAAK,QAAQ,aAAa,KAAK;AAAA,QAC/C,iBAAiB,KAAK,QAAQ,cAAc,KAAK;AAAA,QACjD,iBAAiB,KAAK,QAAQ,cAAc,KAAK;AAAA,MACnD;AAAA,MACA;AAAA,QACE;AAAA;AAAA,QAEA,0BAA0B,KAAK,QAAQ;AAAA,QACvC,cAAc,KAAK,QAAQ;AAAA,MAC7B;AAAA,IACF;AACA,SAAK,iBAAiB,UAAU;AAAA,EAClC;AAAA,EAEQ,iBAAiB,SAA4B;AACnD,SAAK,UAAU;AACf,SAAK,SAAS,IAAI,UAAU,OAAO;AACnC,SAAK,aAAa,IAAI,cAAc,OAAO;AAC3C,SAAK,OAAO,IAAI,QAAQ,OAAO;AAC/B,SAAK,OAAO,IAAI,QAAQ,OAAO;AAC/B,SAAK,KAAK,IAAI,aAAa,OAAO;AAAA,EACpC;AACF;","names":[]}
|
package/dist/context.cjs
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/context.ts
|
|
21
|
+
var context_exports = {};
|
|
22
|
+
__export(context_exports, {
|
|
23
|
+
createClientContext: () => createClientContext
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(context_exports);
|
|
26
|
+
var import_contracts = require("@nadohq/contracts");
|
|
27
|
+
var import_engine_client = require("@nadohq/engine-client");
|
|
28
|
+
var import_indexer_client = require("@nadohq/indexer-client");
|
|
29
|
+
var import_trigger_client = require("@nadohq/trigger-client");
|
|
30
|
+
var import_viem = require("viem");
|
|
31
|
+
function createClientContext(opts, accountOpts) {
|
|
32
|
+
const {
|
|
33
|
+
contractAddresses,
|
|
34
|
+
engineEndpoint,
|
|
35
|
+
indexerEndpoint,
|
|
36
|
+
triggerEndpoint
|
|
37
|
+
} = (() => {
|
|
38
|
+
if (typeof opts === "object") {
|
|
39
|
+
return opts;
|
|
40
|
+
}
|
|
41
|
+
const chainEnv = opts;
|
|
42
|
+
return {
|
|
43
|
+
contractAddresses: import_contracts.NADO_DEPLOYMENTS[chainEnv],
|
|
44
|
+
engineEndpoint: import_engine_client.ENGINE_CLIENT_ENDPOINTS[chainEnv],
|
|
45
|
+
indexerEndpoint: import_indexer_client.INDEXER_CLIENT_ENDPOINTS[chainEnv],
|
|
46
|
+
triggerEndpoint: import_trigger_client.TRIGGER_CLIENT_ENDPOINTS[chainEnv]
|
|
47
|
+
};
|
|
48
|
+
})();
|
|
49
|
+
const { publicClient, walletClient, linkedSignerWalletClient } = accountOpts;
|
|
50
|
+
return {
|
|
51
|
+
walletClient,
|
|
52
|
+
linkedSignerWalletClient,
|
|
53
|
+
publicClient,
|
|
54
|
+
contracts: {
|
|
55
|
+
querier: getNadoContract({
|
|
56
|
+
contractAddresses,
|
|
57
|
+
contractName: "querier",
|
|
58
|
+
walletClient,
|
|
59
|
+
publicClient
|
|
60
|
+
}),
|
|
61
|
+
clearinghouse: getNadoContract({
|
|
62
|
+
contractAddresses,
|
|
63
|
+
contractName: "clearinghouse",
|
|
64
|
+
walletClient,
|
|
65
|
+
publicClient
|
|
66
|
+
}),
|
|
67
|
+
endpoint: getNadoContract({
|
|
68
|
+
contractAddresses,
|
|
69
|
+
contractName: "endpoint",
|
|
70
|
+
walletClient,
|
|
71
|
+
publicClient
|
|
72
|
+
}),
|
|
73
|
+
spotEngine: getNadoContract({
|
|
74
|
+
contractAddresses,
|
|
75
|
+
contractName: "spotEngine",
|
|
76
|
+
walletClient,
|
|
77
|
+
publicClient
|
|
78
|
+
}),
|
|
79
|
+
perpEngine: getNadoContract({
|
|
80
|
+
contractAddresses,
|
|
81
|
+
contractName: "perpEngine",
|
|
82
|
+
walletClient,
|
|
83
|
+
publicClient
|
|
84
|
+
}),
|
|
85
|
+
withdrawPool: getNadoContract({
|
|
86
|
+
contractAddresses,
|
|
87
|
+
contractName: "withdrawPool",
|
|
88
|
+
walletClient,
|
|
89
|
+
publicClient
|
|
90
|
+
})
|
|
91
|
+
},
|
|
92
|
+
contractAddresses,
|
|
93
|
+
engineClient: new import_engine_client.EngineClient({
|
|
94
|
+
url: engineEndpoint,
|
|
95
|
+
walletClient,
|
|
96
|
+
linkedSignerWalletClient
|
|
97
|
+
}),
|
|
98
|
+
indexerClient: new import_indexer_client.IndexerClient({
|
|
99
|
+
url: indexerEndpoint,
|
|
100
|
+
walletClient
|
|
101
|
+
}),
|
|
102
|
+
triggerClient: new import_trigger_client.TriggerClient({
|
|
103
|
+
url: triggerEndpoint,
|
|
104
|
+
walletClient,
|
|
105
|
+
linkedSignerWalletClient
|
|
106
|
+
})
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function getNadoContract({
|
|
110
|
+
contractAddresses,
|
|
111
|
+
contractName,
|
|
112
|
+
walletClient,
|
|
113
|
+
publicClient
|
|
114
|
+
}) {
|
|
115
|
+
return (0, import_viem.getContract)({
|
|
116
|
+
address: contractAddresses[contractName],
|
|
117
|
+
abi: import_contracts.NADO_ABIS[contractName],
|
|
118
|
+
client: walletClient ?? publicClient
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
122
|
+
0 && (module.exports = {
|
|
123
|
+
createClientContext
|
|
124
|
+
});
|
|
125
|
+
//# sourceMappingURL=context.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/context.ts"],"sourcesContent":["import {\n ChainEnv,\n NADO_ABIS,\n NADO_DEPLOYMENTS,\n NadoContractName,\n NadoContracts,\n NadoDeploymentAddresses,\n WalletClientWithAccount,\n} from '@nadohq/contracts';\nimport { ENGINE_CLIENT_ENDPOINTS, EngineClient } from '@nadohq/engine-client';\nimport {\n INDEXER_CLIENT_ENDPOINTS,\n IndexerClient,\n} from '@nadohq/indexer-client';\nimport {\n TRIGGER_CLIENT_ENDPOINTS,\n TriggerClient,\n} from '@nadohq/trigger-client';\nimport { getContract, PublicClient } from 'viem';\n\n/**\n * Context required to use the Nado client.\n */\nexport interface NadoClientContext {\n publicClient: PublicClient;\n walletClient?: WalletClientWithAccount;\n // If provided, this is used to sign engine transactions instead of the account associated with walletClient\n linkedSignerWalletClient?: WalletClientWithAccount;\n contracts: NadoContracts;\n contractAddresses: NadoDeploymentAddresses;\n engineClient: EngineClient;\n indexerClient: IndexerClient;\n triggerClient: TriggerClient;\n}\n\n/**\n * Args for creating a context\n */\ninterface NadoClientContextOpts {\n contractAddresses: NadoDeploymentAddresses;\n engineEndpoint: string;\n indexerEndpoint: string;\n triggerEndpoint: string;\n}\n\n/**\n * Args for signing configuration for creating a context\n */\nexport type CreateNadoClientContextAccountOpts = Pick<\n NadoClientContext,\n 'walletClient' | 'linkedSignerWalletClient' | 'publicClient'\n>;\n\nexport type CreateNadoClientContextOpts = NadoClientContextOpts | ChainEnv;\n\n/**\n * Utility function to create client context from options\n *\n * @param opts\n * @param accountOpts\n */\nexport function createClientContext(\n opts: CreateNadoClientContextOpts,\n accountOpts: CreateNadoClientContextAccountOpts,\n): NadoClientContext {\n const {\n contractAddresses,\n engineEndpoint,\n indexerEndpoint,\n triggerEndpoint,\n } = ((): NadoClientContextOpts => {\n // Custom options\n if (typeof opts === 'object') {\n return opts;\n }\n\n const chainEnv = opts;\n return {\n contractAddresses: NADO_DEPLOYMENTS[chainEnv],\n engineEndpoint: ENGINE_CLIENT_ENDPOINTS[chainEnv],\n indexerEndpoint: INDEXER_CLIENT_ENDPOINTS[chainEnv],\n triggerEndpoint: TRIGGER_CLIENT_ENDPOINTS[chainEnv],\n };\n })();\n const { publicClient, walletClient, linkedSignerWalletClient } = accountOpts;\n\n return {\n walletClient,\n linkedSignerWalletClient,\n publicClient,\n contracts: {\n querier: getNadoContract({\n contractAddresses,\n contractName: 'querier',\n walletClient,\n publicClient,\n }),\n clearinghouse: getNadoContract({\n contractAddresses,\n contractName: 'clearinghouse',\n walletClient,\n publicClient,\n }),\n endpoint: getNadoContract({\n contractAddresses,\n contractName: 'endpoint',\n walletClient,\n publicClient,\n }),\n spotEngine: getNadoContract({\n contractAddresses,\n contractName: 'spotEngine',\n walletClient,\n publicClient,\n }),\n perpEngine: getNadoContract({\n contractAddresses,\n contractName: 'perpEngine',\n walletClient,\n publicClient,\n }),\n withdrawPool: getNadoContract({\n contractAddresses,\n contractName: 'withdrawPool',\n walletClient,\n publicClient,\n }),\n },\n contractAddresses,\n engineClient: new EngineClient({\n url: engineEndpoint,\n walletClient,\n linkedSignerWalletClient,\n }),\n indexerClient: new IndexerClient({\n url: indexerEndpoint,\n walletClient,\n }),\n triggerClient: new TriggerClient({\n url: triggerEndpoint,\n walletClient,\n linkedSignerWalletClient,\n }),\n };\n}\n\ninterface GetNadoContractParams<T extends NadoContractName> {\n contractAddresses: NadoDeploymentAddresses;\n contractName: T;\n walletClient?: WalletClientWithAccount;\n publicClient: PublicClient;\n}\n\nfunction getNadoContract<T extends NadoContractName>({\n contractAddresses,\n contractName,\n walletClient,\n publicClient,\n}: GetNadoContractParams<T>): NadoContracts[T] {\n return getContract({\n address: contractAddresses[contractName],\n abi: NADO_ABIS[contractName],\n client: walletClient ?? publicClient,\n }) as NadoContracts[T];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAQO;AACP,2BAAsD;AACtD,4BAGO;AACP,4BAGO;AACP,kBAA0C;AA2CnC,SAAS,oBACd,MACA,aACmB;AACnB,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,KAAK,MAA6B;AAEhC,QAAI,OAAO,SAAS,UAAU;AAC5B,aAAO;AAAA,IACT;AAEA,UAAM,WAAW;AACjB,WAAO;AAAA,MACL,mBAAmB,kCAAiB,QAAQ;AAAA,MAC5C,gBAAgB,6CAAwB,QAAQ;AAAA,MAChD,iBAAiB,+CAAyB,QAAQ;AAAA,MAClD,iBAAiB,+CAAyB,QAAQ;AAAA,IACpD;AAAA,EACF,GAAG;AACH,QAAM,EAAE,cAAc,cAAc,yBAAyB,IAAI;AAEjE,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW;AAAA,MACT,SAAS,gBAAgB;AAAA,QACvB;AAAA,QACA,cAAc;AAAA,QACd;AAAA,QACA;AAAA,MACF,CAAC;AAAA,MACD,eAAe,gBAAgB;AAAA,QAC7B;AAAA,QACA,cAAc;AAAA,QACd;AAAA,QACA;AAAA,MACF,CAAC;AAAA,MACD,UAAU,gBAAgB;AAAA,QACxB;AAAA,QACA,cAAc;AAAA,QACd;AAAA,QACA;AAAA,MACF,CAAC;AAAA,MACD,YAAY,gBAAgB;AAAA,QAC1B;AAAA,QACA,cAAc;AAAA,QACd;AAAA,QACA;AAAA,MACF,CAAC;AAAA,MACD,YAAY,gBAAgB;AAAA,QAC1B;AAAA,QACA,cAAc;AAAA,QACd;AAAA,QACA;AAAA,MACF,CAAC;AAAA,MACD,cAAc,gBAAgB;AAAA,QAC5B;AAAA,QACA,cAAc;AAAA,QACd;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IACA;AAAA,IACA,cAAc,IAAI,kCAAa;AAAA,MAC7B,KAAK;AAAA,MACL;AAAA,MACA;AAAA,IACF,CAAC;AAAA,IACD,eAAe,IAAI,oCAAc;AAAA,MAC/B,KAAK;AAAA,MACL;AAAA,IACF,CAAC;AAAA,IACD,eAAe,IAAI,oCAAc;AAAA,MAC/B,KAAK;AAAA,MACL;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AACF;AASA,SAAS,gBAA4C;AAAA,EACnD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA+C;AAC7C,aAAO,yBAAY;AAAA,IACjB,SAAS,kBAAkB,YAAY;AAAA,IACvC,KAAK,2BAAU,YAAY;AAAA,IAC3B,QAAQ,gBAAgB;AAAA,EAC1B,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { WalletClientWithAccount, NadoContracts, NadoDeploymentAddresses, ChainEnv } from '@nadohq/contracts';
|
|
2
|
+
import { EngineClient } from '@nadohq/engine-client';
|
|
3
|
+
import { IndexerClient } from '@nadohq/indexer-client';
|
|
4
|
+
import { TriggerClient } from '@nadohq/trigger-client';
|
|
5
|
+
import { PublicClient } from 'viem';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Context required to use the Nado client.
|
|
9
|
+
*/
|
|
10
|
+
interface NadoClientContext {
|
|
11
|
+
publicClient: PublicClient;
|
|
12
|
+
walletClient?: WalletClientWithAccount;
|
|
13
|
+
linkedSignerWalletClient?: WalletClientWithAccount;
|
|
14
|
+
contracts: NadoContracts;
|
|
15
|
+
contractAddresses: NadoDeploymentAddresses;
|
|
16
|
+
engineClient: EngineClient;
|
|
17
|
+
indexerClient: IndexerClient;
|
|
18
|
+
triggerClient: TriggerClient;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Args for creating a context
|
|
22
|
+
*/
|
|
23
|
+
interface NadoClientContextOpts {
|
|
24
|
+
contractAddresses: NadoDeploymentAddresses;
|
|
25
|
+
engineEndpoint: string;
|
|
26
|
+
indexerEndpoint: string;
|
|
27
|
+
triggerEndpoint: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Args for signing configuration for creating a context
|
|
31
|
+
*/
|
|
32
|
+
type CreateNadoClientContextAccountOpts = Pick<NadoClientContext, 'walletClient' | 'linkedSignerWalletClient' | 'publicClient'>;
|
|
33
|
+
type CreateNadoClientContextOpts = NadoClientContextOpts | ChainEnv;
|
|
34
|
+
/**
|
|
35
|
+
* Utility function to create client context from options
|
|
36
|
+
*
|
|
37
|
+
* @param opts
|
|
38
|
+
* @param accountOpts
|
|
39
|
+
*/
|
|
40
|
+
declare function createClientContext(opts: CreateNadoClientContextOpts, accountOpts: CreateNadoClientContextAccountOpts): NadoClientContext;
|
|
41
|
+
|
|
42
|
+
export { type CreateNadoClientContextAccountOpts, type CreateNadoClientContextOpts, type NadoClientContext, createClientContext };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { WalletClientWithAccount, NadoContracts, NadoDeploymentAddresses, ChainEnv } from '@nadohq/contracts';
|
|
2
|
+
import { EngineClient } from '@nadohq/engine-client';
|
|
3
|
+
import { IndexerClient } from '@nadohq/indexer-client';
|
|
4
|
+
import { TriggerClient } from '@nadohq/trigger-client';
|
|
5
|
+
import { PublicClient } from 'viem';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Context required to use the Nado client.
|
|
9
|
+
*/
|
|
10
|
+
interface NadoClientContext {
|
|
11
|
+
publicClient: PublicClient;
|
|
12
|
+
walletClient?: WalletClientWithAccount;
|
|
13
|
+
linkedSignerWalletClient?: WalletClientWithAccount;
|
|
14
|
+
contracts: NadoContracts;
|
|
15
|
+
contractAddresses: NadoDeploymentAddresses;
|
|
16
|
+
engineClient: EngineClient;
|
|
17
|
+
indexerClient: IndexerClient;
|
|
18
|
+
triggerClient: TriggerClient;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Args for creating a context
|
|
22
|
+
*/
|
|
23
|
+
interface NadoClientContextOpts {
|
|
24
|
+
contractAddresses: NadoDeploymentAddresses;
|
|
25
|
+
engineEndpoint: string;
|
|
26
|
+
indexerEndpoint: string;
|
|
27
|
+
triggerEndpoint: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Args for signing configuration for creating a context
|
|
31
|
+
*/
|
|
32
|
+
type CreateNadoClientContextAccountOpts = Pick<NadoClientContext, 'walletClient' | 'linkedSignerWalletClient' | 'publicClient'>;
|
|
33
|
+
type CreateNadoClientContextOpts = NadoClientContextOpts | ChainEnv;
|
|
34
|
+
/**
|
|
35
|
+
* Utility function to create client context from options
|
|
36
|
+
*
|
|
37
|
+
* @param opts
|
|
38
|
+
* @param accountOpts
|
|
39
|
+
*/
|
|
40
|
+
declare function createClientContext(opts: CreateNadoClientContextOpts, accountOpts: CreateNadoClientContextAccountOpts): NadoClientContext;
|
|
41
|
+
|
|
42
|
+
export { type CreateNadoClientContextAccountOpts, type CreateNadoClientContextOpts, type NadoClientContext, createClientContext };
|