@n1xyz/nord-ts 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions.d.ts +57 -0
- package/dist/actions.js +186 -0
- package/dist/bundle.js +79181 -0
- package/dist/{nord/client → client}/Nord.d.ts +90 -107
- package/dist/{nord/client → client}/Nord.js +157 -218
- package/dist/{nord/client → client}/NordAdmin.d.ts +68 -102
- package/dist/{nord/client → client}/NordAdmin.js +109 -140
- package/dist/{nord/client → client}/NordUser.d.ts +86 -98
- package/dist/{nord/client → client}/NordUser.js +204 -271
- package/dist/const.js +5 -8
- package/dist/{nord/utils/NordError.js → error.js} +7 -5
- package/dist/gen/nord_pb.js +88 -92
- package/dist/gen/openapi.d.ts +39 -0
- package/dist/gen/openapi.js +1 -2
- package/dist/index.d.ts +6 -1
- package/dist/index.js +10 -21
- package/dist/types.d.ts +5 -50
- package/dist/types.js +21 -83
- package/dist/utils.d.ts +8 -11
- package/dist/utils.js +55 -90
- package/dist/websocket/NordWebSocketClient.js +12 -17
- package/dist/{nord/models → websocket}/Subscriber.d.ts +1 -1
- package/dist/{nord/models → websocket}/Subscriber.js +6 -7
- package/dist/websocket/events.js +1 -2
- package/dist/websocket/index.d.ts +19 -2
- package/dist/websocket/index.js +80 -5
- package/package.json +2 -3
- package/dist/api/client.d.ts +0 -14
- package/dist/api/client.js +0 -45
- package/dist/bridge/client.d.ts +0 -151
- package/dist/bridge/client.js +0 -434
- package/dist/bridge/const.d.ts +0 -23
- package/dist/bridge/const.js +0 -47
- package/dist/bridge/index.d.ts +0 -4
- package/dist/bridge/index.js +0 -23
- package/dist/bridge/types.d.ts +0 -120
- package/dist/bridge/types.js +0 -18
- package/dist/bridge/utils.d.ts +0 -64
- package/dist/bridge/utils.js +0 -131
- package/dist/gen/common.d.ts +0 -68
- package/dist/gen/common.js +0 -215
- package/dist/gen/nord.d.ts +0 -882
- package/dist/gen/nord.js +0 -6520
- package/dist/idl/bridge.d.ts +0 -569
- package/dist/idl/bridge.js +0 -8
- package/dist/idl/bridge.json +0 -1506
- package/dist/idl/index.d.ts +0 -607
- package/dist/idl/index.js +0 -8
- package/dist/nord/api/actions.d.ts +0 -126
- package/dist/nord/api/actions.js +0 -397
- package/dist/nord/api/core.d.ts +0 -16
- package/dist/nord/api/core.js +0 -81
- package/dist/nord/api/market.d.ts +0 -36
- package/dist/nord/api/market.js +0 -96
- package/dist/nord/api/metrics.d.ts +0 -67
- package/dist/nord/api/metrics.js +0 -229
- package/dist/nord/api/queries.d.ts +0 -46
- package/dist/nord/api/queries.js +0 -109
- package/dist/nord/api/triggers.d.ts +0 -7
- package/dist/nord/api/triggers.js +0 -38
- package/dist/nord/client/NordClient.d.ts +0 -33
- package/dist/nord/client/NordClient.js +0 -45
- package/dist/nord/index.d.ts +0 -11
- package/dist/nord/index.js +0 -36
- package/src/const.ts +0 -34
- package/src/gen/.gitkeep +0 -0
- package/src/gen/nord_pb.ts +0 -5053
- package/src/gen/openapi.ts +0 -2864
- package/src/index.ts +0 -5
- package/src/nord/api/actions.ts +0 -648
- package/src/nord/api/core.ts +0 -96
- package/src/nord/api/metrics.ts +0 -269
- package/src/nord/client/Nord.ts +0 -937
- package/src/nord/client/NordAdmin.ts +0 -514
- package/src/nord/client/NordClient.ts +0 -79
- package/src/nord/client/NordUser.ts +0 -1211
- package/src/nord/index.ts +0 -25
- package/src/nord/models/Subscriber.ts +0 -56
- package/src/nord/utils/NordError.ts +0 -76
- package/src/types.ts +0 -377
- package/src/utils.ts +0 -269
- package/src/websocket/NordWebSocketClient.ts +0 -316
- package/src/websocket/events.ts +0 -31
- package/src/websocket/index.ts +0 -2
- /package/dist/{nord/utils/NordError.d.ts → error.d.ts} +0 -0
|
@@ -1,57 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.NordAdmin = exports.AclRole = void 0;
|
|
37
|
-
const protobuf_1 = require("@bufbuild/protobuf");
|
|
38
|
-
const proto = __importStar(require("../../gen/nord_pb"));
|
|
39
|
-
const utils_1 = require("../../utils");
|
|
40
|
-
const actions_1 = require("../api/actions");
|
|
41
|
-
const NordError_1 = require("../utils/NordError");
|
|
1
|
+
import { create } from "@bufbuild/protobuf";
|
|
2
|
+
import * as proto from "../gen/nord_pb";
|
|
3
|
+
import { decodeHex, signUserPayload } from "../utils";
|
|
4
|
+
import { createAction, sendAction, expectReceiptKind } from "../actions";
|
|
5
|
+
import { NordError } from "../error";
|
|
42
6
|
// NOTE: keep in sync with `acl.rs`.
|
|
43
|
-
|
|
44
|
-
var AclRole;
|
|
7
|
+
export var AclRole;
|
|
45
8
|
(function (AclRole) {
|
|
9
|
+
// note: use 2 ** n instead of 1 << n since js internally
|
|
10
|
+
// casts number to a signed int for bitwise ops. when merging
|
|
11
|
+
// these roles, make sure to use += instead of |=. this will
|
|
12
|
+
// only work when the roles are powers of two.
|
|
46
13
|
AclRole[AclRole["FEE_MANAGER"] = 1] = "FEE_MANAGER";
|
|
47
14
|
AclRole[AclRole["MARKET_MANAGER"] = 2] = "MARKET_MANAGER";
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
})(AclRole || (exports.AclRole = AclRole = {}));
|
|
15
|
+
AclRole[AclRole["ADMIN"] = 2147483648] = "ADMIN";
|
|
16
|
+
})(AclRole || (AclRole = {}));
|
|
51
17
|
/**
|
|
52
18
|
* Administrative client capable of submitting privileged configuration actions.
|
|
53
19
|
*/
|
|
54
|
-
class NordAdmin {
|
|
20
|
+
export class NordAdmin {
|
|
21
|
+
nord;
|
|
22
|
+
admin;
|
|
23
|
+
signFn;
|
|
55
24
|
constructor({ nord, admin, signFn, }) {
|
|
56
25
|
this.nord = nord;
|
|
57
26
|
this.admin = admin;
|
|
@@ -62,25 +31,8 @@ class NordAdmin {
|
|
|
62
31
|
* @param nord - Nord instance
|
|
63
32
|
* @param admin - The user that will be signing actions.
|
|
64
33
|
* @param signFn - Function to sign messages with the admin's wallet.
|
|
65
|
-
*
|
|
66
|
-
* `signFn` must sign the _hex-encoded_ message, not the raw message itself, for
|
|
67
|
-
* the purpose of being compatible with Solana wallets.
|
|
68
|
-
*
|
|
69
|
-
* In practice, you will do something along the lines of:
|
|
70
|
-
*
|
|
71
|
-
* ```typescript
|
|
72
|
-
* (x) => wallet.signMessage(new TextEncoder().encode(x.toHex()));
|
|
73
|
-
* ```
|
|
74
|
-
*
|
|
75
|
-
* For a software signing key, this might look more like:
|
|
76
|
-
*
|
|
77
|
-
* ```typescript
|
|
78
|
-
* (x) => nacl.sign.detached(new TextEncoder().encode(x.toHex()), sk);
|
|
79
|
-
* ``
|
|
80
|
-
*
|
|
81
|
-
* where `nacl` is the tweetnacl library.
|
|
82
34
|
*/
|
|
83
|
-
static new({ nord, admin, signFn, }) {
|
|
35
|
+
static async new({ nord, admin, signFn, }) {
|
|
84
36
|
return new NordAdmin({
|
|
85
37
|
nord,
|
|
86
38
|
admin,
|
|
@@ -95,12 +47,13 @@ class NordAdmin {
|
|
|
95
47
|
*/
|
|
96
48
|
async submitAction(kind) {
|
|
97
49
|
const timestamp = await this.nord.getTimestamp();
|
|
98
|
-
const action =
|
|
99
|
-
return
|
|
100
|
-
const signature = await
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
50
|
+
const action = createAction(timestamp, 0, kind);
|
|
51
|
+
return sendAction(this.nord.httpClient, async (xs) => {
|
|
52
|
+
const signature = await signUserPayload({
|
|
53
|
+
payload: xs,
|
|
54
|
+
user: this.admin,
|
|
55
|
+
signTransaction: this.signFn,
|
|
56
|
+
});
|
|
104
57
|
return Uint8Array.from([...xs, ...signature]);
|
|
105
58
|
}, action);
|
|
106
59
|
}
|
|
@@ -115,37 +68,43 @@ class NordAdmin {
|
|
|
115
68
|
async updateAcl({ target, addRoles, removeRoles, }) {
|
|
116
69
|
const allRoles = addRoles.concat(removeRoles);
|
|
117
70
|
if (allRoles.length !== new Set(allRoles).size) {
|
|
118
|
-
throw new
|
|
71
|
+
throw new NordError("duplicate roles in acl update; must be unique");
|
|
119
72
|
}
|
|
120
73
|
let mask = 0;
|
|
121
74
|
let values = 0;
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
75
|
+
// using += instead of |= to avoid the internal cast to i32 >:(
|
|
76
|
+
// this works because our roles are powers of two.
|
|
77
|
+
for (const role of allRoles)
|
|
78
|
+
mask += role;
|
|
79
|
+
for (const role of addRoles)
|
|
80
|
+
values += role;
|
|
128
81
|
const receipt = await this.submitAction({
|
|
129
82
|
case: "updateAcl",
|
|
130
|
-
value:
|
|
83
|
+
value: create(proto.Action_UpdateAclSchema, {
|
|
131
84
|
aclPubkey: this.admin.toBytes(),
|
|
132
85
|
targetPubkey: target.toBytes(),
|
|
86
|
+
rolesValue: values,
|
|
87
|
+
rolesMask: mask,
|
|
133
88
|
}),
|
|
134
89
|
});
|
|
135
|
-
|
|
90
|
+
expectReceiptKind(receipt, "aclUpdated", "update acl");
|
|
136
91
|
return { ...receipt.kind.value, actionId: receipt.actionId };
|
|
137
92
|
}
|
|
138
93
|
/**
|
|
139
94
|
* Register a new token that can be listed on Nord.
|
|
140
95
|
*
|
|
141
|
-
* @param
|
|
96
|
+
* @param tokenDecimals - Decimal shift used when parsing deposits/withdrawals
|
|
97
|
+
* @param weightBps - Risk weight in basis points applied in account value calculations
|
|
98
|
+
* @param viewSymbol - Symbol surfaced to Nord clients
|
|
99
|
+
* @param oracleSymbol - Symbol resolved by the oracle adapter
|
|
100
|
+
* @param mintAddr - Solana mint backing this token
|
|
142
101
|
* @returns Action identifier and resulting token metadata
|
|
143
102
|
* @throws {NordError} If the action submission fails
|
|
144
103
|
*/
|
|
145
104
|
async createToken({ tokenDecimals, weightBps, viewSymbol, oracleSymbol, mintAddr, }) {
|
|
146
105
|
const receipt = await this.submitAction({
|
|
147
106
|
case: "createToken",
|
|
148
|
-
value:
|
|
107
|
+
value: create(proto.Action_CreateTokenSchema, {
|
|
149
108
|
aclPubkey: this.admin.toBytes(),
|
|
150
109
|
tokenDecimals,
|
|
151
110
|
weightBps,
|
|
@@ -154,33 +113,41 @@ class NordAdmin {
|
|
|
154
113
|
solAddr: mintAddr.toBytes(),
|
|
155
114
|
}),
|
|
156
115
|
});
|
|
157
|
-
|
|
116
|
+
expectReceiptKind(receipt, "insertTokenResult", "create token");
|
|
158
117
|
return { actionId: receipt.actionId, ...receipt.kind.value };
|
|
159
118
|
}
|
|
160
119
|
/**
|
|
161
120
|
* Open a new market with the provided trading parameters.
|
|
162
121
|
*
|
|
163
|
-
* @param
|
|
122
|
+
* @param sizeDecimals - Decimal shift for contract sizes
|
|
123
|
+
* @param priceDecimals - Decimal shift for price ticks
|
|
124
|
+
* @param imfBps - Base initial margin fraction (IMF) in basis points, see docs/MARKETS.md
|
|
125
|
+
* @param cmfBps - Cancel margin fraction (CMF) in basis points, see docs/MARKETS.md
|
|
126
|
+
* @param mmfBps - Maintenance margin fraction (MMF) in basis points, see docs/MARKETS.md
|
|
127
|
+
* @param marketType - Spot or perpetual market type
|
|
128
|
+
* @param viewSymbol - Symbol exposed to Nord clients
|
|
129
|
+
* @param oracleSymbol - Symbol resolved by the oracle adapter
|
|
130
|
+
* @param baseTokenId - Registered base token backing this market
|
|
164
131
|
* @returns Action identifier and resulting market metadata
|
|
165
132
|
* @throws {NordError} If the action submission fails
|
|
166
133
|
*/
|
|
167
|
-
async createMarket(
|
|
134
|
+
async createMarket({ sizeDecimals, priceDecimals, imfBps, cmfBps, mmfBps, marketType, viewSymbol, oracleSymbol, baseTokenId, }) {
|
|
168
135
|
const receipt = await this.submitAction({
|
|
169
136
|
case: "createMarket",
|
|
170
|
-
value:
|
|
137
|
+
value: create(proto.Action_CreateMarketSchema, {
|
|
171
138
|
aclPubkey: this.admin.toBytes(),
|
|
172
|
-
sizeDecimals
|
|
173
|
-
priceDecimals
|
|
174
|
-
imfBps
|
|
175
|
-
cmfBps
|
|
176
|
-
mmfBps
|
|
177
|
-
marketType
|
|
178
|
-
viewSymbol
|
|
179
|
-
oracleSymbol
|
|
180
|
-
baseTokenId
|
|
139
|
+
sizeDecimals,
|
|
140
|
+
priceDecimals,
|
|
141
|
+
imfBps,
|
|
142
|
+
cmfBps,
|
|
143
|
+
mmfBps,
|
|
144
|
+
marketType,
|
|
145
|
+
viewSymbol,
|
|
146
|
+
oracleSymbol,
|
|
147
|
+
baseTokenId,
|
|
181
148
|
}),
|
|
182
149
|
});
|
|
183
|
-
|
|
150
|
+
expectReceiptKind(receipt, "insertMarketResult", "create market");
|
|
184
151
|
return { actionId: receipt.actionId, ...receipt.kind.value };
|
|
185
152
|
}
|
|
186
153
|
/**
|
|
@@ -190,32 +157,33 @@ class NordAdmin {
|
|
|
190
157
|
* leading `0x` prefix). The engine validates the supplied guardian set index
|
|
191
158
|
* before applying the update.
|
|
192
159
|
*
|
|
193
|
-
* @param
|
|
160
|
+
* @param guardianSetIndex - Wormhole guardian set index that must already exist
|
|
161
|
+
* @param addresses - 20-byte hex-encoded guardian addresses
|
|
194
162
|
* @returns Action identifier and guardian update receipt
|
|
195
163
|
* @throws {NordError} If the action submission fails
|
|
196
164
|
*/
|
|
197
|
-
async pythSetWormholeGuardians(
|
|
198
|
-
const
|
|
165
|
+
async pythSetWormholeGuardians({ guardianSetIndex, addresses, }) {
|
|
166
|
+
const parsedAddresses = addresses.map((address) => {
|
|
199
167
|
try {
|
|
200
|
-
const decoded =
|
|
168
|
+
const decoded = decodeHex(address);
|
|
201
169
|
if (decoded.length !== 20) {
|
|
202
170
|
throw new Error("guardian address must be 20 bytes");
|
|
203
171
|
}
|
|
204
172
|
return decoded;
|
|
205
173
|
}
|
|
206
174
|
catch (e) {
|
|
207
|
-
throw new
|
|
175
|
+
throw new NordError("invalid guardian address; must be a 20 byte hex address", { cause: e });
|
|
208
176
|
}
|
|
209
177
|
});
|
|
210
178
|
const receipt = await this.submitAction({
|
|
211
179
|
case: "pythSetWormholeGuardians",
|
|
212
|
-
value:
|
|
180
|
+
value: create(proto.Action_PythSetWormholeGuardiansSchema, {
|
|
213
181
|
aclPubkey: this.admin.toBytes(),
|
|
214
|
-
guardianSetIndex
|
|
215
|
-
addresses,
|
|
182
|
+
guardianSetIndex,
|
|
183
|
+
addresses: parsedAddresses,
|
|
216
184
|
}),
|
|
217
185
|
});
|
|
218
|
-
|
|
186
|
+
expectReceiptKind(receipt, "updateGuardianSetResult", "update wormhole guardians");
|
|
219
187
|
return { actionId: receipt.actionId, ...receipt.kind.value };
|
|
220
188
|
}
|
|
221
189
|
/**
|
|
@@ -225,32 +193,33 @@ class NordAdmin {
|
|
|
225
193
|
* leading `0x` prefix). Use this call to create or update the mapping used
|
|
226
194
|
* by the oracle integration.
|
|
227
195
|
*
|
|
228
|
-
* @param
|
|
196
|
+
* @param oracleSymbol - Symbol resolved by the oracle adapter
|
|
197
|
+
* @param priceFeedId - 32-byte hex-encoded Pyth price feed identifier
|
|
229
198
|
* @returns Action identifier and symbol feed receipt
|
|
230
199
|
* @throws {NordError} If the action submission fails
|
|
231
200
|
*/
|
|
232
|
-
async pythSetSymbolFeed(
|
|
201
|
+
async pythSetSymbolFeed({ oracleSymbol, priceFeedId: priceFeedIdHex, }) {
|
|
233
202
|
let priceFeedId;
|
|
234
203
|
try {
|
|
235
|
-
priceFeedId =
|
|
204
|
+
priceFeedId = decodeHex(priceFeedIdHex);
|
|
236
205
|
if (priceFeedId.length !== 32) {
|
|
237
206
|
throw new Error("price feed id must be 32 bytes");
|
|
238
207
|
}
|
|
239
208
|
}
|
|
240
209
|
catch (e) {
|
|
241
|
-
throw new
|
|
210
|
+
throw new NordError("invalid price feed id; must be a 32 byte hex id", {
|
|
242
211
|
cause: e,
|
|
243
212
|
});
|
|
244
213
|
}
|
|
245
214
|
const receipt = await this.submitAction({
|
|
246
215
|
case: "pythSetSymbolFeed",
|
|
247
|
-
value:
|
|
216
|
+
value: create(proto.Action_PythSetSymbolFeedSchema, {
|
|
248
217
|
aclPubkey: this.admin.toBytes(),
|
|
249
|
-
oracleSymbol
|
|
218
|
+
oracleSymbol,
|
|
250
219
|
priceFeedId,
|
|
251
220
|
}),
|
|
252
221
|
});
|
|
253
|
-
|
|
222
|
+
expectReceiptKind(receipt, "oracleSymbolFeedResult", "set symbol feed");
|
|
254
223
|
return { actionId: receipt.actionId, ...receipt.kind.value };
|
|
255
224
|
}
|
|
256
225
|
/**
|
|
@@ -262,11 +231,11 @@ class NordAdmin {
|
|
|
262
231
|
async pause() {
|
|
263
232
|
const receipt = await this.submitAction({
|
|
264
233
|
case: "pause",
|
|
265
|
-
value:
|
|
234
|
+
value: create(proto.Action_PauseSchema, {
|
|
266
235
|
aclPubkey: this.admin.toBytes(),
|
|
267
236
|
}),
|
|
268
237
|
});
|
|
269
|
-
|
|
238
|
+
expectReceiptKind(receipt, "paused", "pause");
|
|
270
239
|
return { actionId: receipt.actionId };
|
|
271
240
|
}
|
|
272
241
|
/**
|
|
@@ -278,47 +247,47 @@ class NordAdmin {
|
|
|
278
247
|
async unpause() {
|
|
279
248
|
const receipt = await this.submitAction({
|
|
280
249
|
case: "unpause",
|
|
281
|
-
value:
|
|
250
|
+
value: create(proto.Action_UnpauseSchema, {
|
|
282
251
|
aclPubkey: this.admin.toBytes(),
|
|
283
252
|
}),
|
|
284
253
|
});
|
|
285
|
-
|
|
254
|
+
expectReceiptKind(receipt, "unpaused", "unpause");
|
|
286
255
|
return { actionId: receipt.actionId };
|
|
287
256
|
}
|
|
288
257
|
/**
|
|
289
258
|
* Freeze an individual market, preventing new trades and orders.
|
|
290
259
|
*
|
|
291
|
-
* @param
|
|
260
|
+
* @param marketId - Target market identifier
|
|
292
261
|
* @returns Action identifier and freeze receipt
|
|
293
262
|
* @throws {NordError} If the action submission fails
|
|
294
263
|
*/
|
|
295
|
-
async freezeMarket(
|
|
264
|
+
async freezeMarket({ marketId, }) {
|
|
296
265
|
const receipt = await this.submitAction({
|
|
297
266
|
case: "freezeMarket",
|
|
298
|
-
value:
|
|
299
|
-
marketId
|
|
267
|
+
value: create(proto.Action_FreezeMarketSchema, {
|
|
268
|
+
marketId,
|
|
300
269
|
aclPubkey: this.admin.toBytes(),
|
|
301
270
|
}),
|
|
302
271
|
});
|
|
303
|
-
|
|
272
|
+
expectReceiptKind(receipt, "marketFreezeUpdated", "freeze market");
|
|
304
273
|
return { actionId: receipt.actionId, ...receipt.kind.value };
|
|
305
274
|
}
|
|
306
275
|
/**
|
|
307
276
|
* Unfreeze a market that was previously halted.
|
|
308
277
|
*
|
|
309
|
-
* @param
|
|
278
|
+
* @param marketId - Target market identifier
|
|
310
279
|
* @returns Action identifier and freeze receipt
|
|
311
280
|
* @throws {NordError} If the action submission fails
|
|
312
281
|
*/
|
|
313
|
-
async unfreezeMarket(
|
|
282
|
+
async unfreezeMarket({ marketId, }) {
|
|
314
283
|
const receipt = await this.submitAction({
|
|
315
284
|
case: "unfreezeMarket",
|
|
316
|
-
value:
|
|
317
|
-
marketId
|
|
285
|
+
value: create(proto.Action_UnfreezeMarketSchema, {
|
|
286
|
+
marketId,
|
|
318
287
|
aclPubkey: this.admin.toBytes(),
|
|
319
288
|
}),
|
|
320
289
|
});
|
|
321
|
-
|
|
290
|
+
expectReceiptKind(receipt, "marketFreezeUpdated", "unfreeze market");
|
|
322
291
|
return { actionId: receipt.actionId, ...receipt.kind.value };
|
|
323
292
|
}
|
|
324
293
|
/**
|
|
@@ -328,19 +297,19 @@ class NordAdmin {
|
|
|
328
297
|
* the default Nord fees; use `updateFeeTier` if you need to change it.
|
|
329
298
|
* - The first appended tier receives id 1, and subsequent tiers increment the id.
|
|
330
299
|
*
|
|
331
|
-
* @param
|
|
300
|
+
* @param config - Fee tier configuration to insert
|
|
332
301
|
* @returns Action identifier and fee tier addition receipt
|
|
333
302
|
* @throws {NordError} If the action submission fails or the new tier exceeds the maximum range (0-15).
|
|
334
303
|
*/
|
|
335
|
-
async addFeeTier(
|
|
304
|
+
async addFeeTier({ config, }) {
|
|
336
305
|
const receipt = await this.submitAction({
|
|
337
306
|
case: "addFeeTier",
|
|
338
|
-
value:
|
|
307
|
+
value: create(proto.Action_AddFeeTierSchema, {
|
|
339
308
|
aclPubkey: this.admin.toBytes(),
|
|
340
|
-
config:
|
|
309
|
+
config: create(proto.FeeTierConfigSchema, config),
|
|
341
310
|
}),
|
|
342
311
|
});
|
|
343
|
-
|
|
312
|
+
expectReceiptKind(receipt, "feeTierAdded", "add fee tier");
|
|
344
313
|
return { actionId: receipt.actionId, ...receipt.kind.value };
|
|
345
314
|
}
|
|
346
315
|
/**
|
|
@@ -349,20 +318,21 @@ class NordAdmin {
|
|
|
349
318
|
* Tier identifiers must already exist; attempting to update a missing tier
|
|
350
319
|
* causes the action to fail.
|
|
351
320
|
*
|
|
352
|
-
* @param
|
|
321
|
+
* @param tierId - Existing fee tier identifier to update
|
|
322
|
+
* @param config - Replacement configuration for the tier
|
|
353
323
|
* @returns Action identifier and fee tier update receipt
|
|
354
324
|
* @throws {NordError} If the action submission fails or the tier ID exceeds the configured range.
|
|
355
325
|
*/
|
|
356
|
-
async updateFeeTier(
|
|
326
|
+
async updateFeeTier({ tierId, config, }) {
|
|
357
327
|
const receipt = await this.submitAction({
|
|
358
328
|
case: "updateFeeTier",
|
|
359
|
-
value:
|
|
329
|
+
value: create(proto.Action_UpdateFeeTierSchema, {
|
|
360
330
|
aclPubkey: this.admin.toBytes(),
|
|
361
|
-
id:
|
|
362
|
-
config:
|
|
331
|
+
id: tierId,
|
|
332
|
+
config: create(proto.FeeTierConfigSchema, config),
|
|
363
333
|
}),
|
|
364
334
|
});
|
|
365
|
-
|
|
335
|
+
expectReceiptKind(receipt, "feeTierUpdated", "update fee tier");
|
|
366
336
|
return { actionId: receipt.actionId, ...receipt.kind.value };
|
|
367
337
|
}
|
|
368
338
|
/**
|
|
@@ -380,14 +350,13 @@ class NordAdmin {
|
|
|
380
350
|
async updateAccountsTier(accounts, tierId) {
|
|
381
351
|
const receipt = await this.submitAction({
|
|
382
352
|
case: "updateAccountsTier",
|
|
383
|
-
value:
|
|
353
|
+
value: create(proto.Action_UpdateAccountsTierSchema, {
|
|
384
354
|
aclPubkey: this.admin.toBytes(),
|
|
385
355
|
accounts,
|
|
386
356
|
tierId,
|
|
387
357
|
}),
|
|
388
358
|
});
|
|
389
|
-
|
|
359
|
+
expectReceiptKind(receipt, "accountsTierUpdated", "update accounts tier");
|
|
390
360
|
return { actionId: receipt.actionId, ...receipt.kind.value };
|
|
391
361
|
}
|
|
392
362
|
}
|
|
393
|
-
exports.NordAdmin = NordAdmin;
|