@n1xyz/nord-ts 0.1.4 → 0.1.5

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.
@@ -1,43 +1,8 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
36
3
  exports.NordClient = void 0;
37
4
  const web3_js_1 = require("@solana/web3.js");
38
- const proto = __importStar(require("../../gen/nord_pb"));
39
5
  const actions_1 = require("../api/actions");
40
- const NordError_1 = require("../utils/NordError");
41
6
  class NordClient {
42
7
  constructor(params) {
43
8
  this.lastTs = 0;
@@ -76,18 +41,5 @@ class NordClient {
76
41
  getSolanaPublicKey() {
77
42
  return this.address;
78
43
  }
79
- expectReceiptKind(receipt, expected, action) {
80
- if (receipt.kind?.case !== expected) {
81
- const label = this.formatReceiptError(receipt);
82
- throw new NordError_1.NordError(`Failed to ${action}: ${label}`);
83
- }
84
- }
85
- formatReceiptError(receipt) {
86
- if (receipt.kind?.case === "err") {
87
- const err = receipt.kind.value;
88
- return proto.Error[err] ?? err.toString();
89
- }
90
- return receipt.kind?.case ?? "unknown";
91
- }
92
44
  }
93
45
  exports.NordClient = NordClient;
@@ -407,7 +407,7 @@ class NordUser extends NordClient_1.NordClient {
407
407
  amount: scaledAmount,
408
408
  }),
409
409
  });
410
- this.expectReceiptKind(receipt, "withdrawResult", "withdraw");
410
+ (0, actions_1.expectReceiptKind)(receipt, "withdrawResult", "withdraw");
411
411
  return { actionId: receipt.actionId };
412
412
  }
413
413
  catch (error) {
@@ -457,7 +457,7 @@ class NordUser extends NordClient_1.NordClient {
457
457
  : BigInt(params.clientOrderId),
458
458
  }),
459
459
  });
460
- this.expectReceiptKind(receipt, "placeOrderResult", "place order");
460
+ (0, actions_1.expectReceiptKind)(receipt, "placeOrderResult", "place order");
461
461
  const result = receipt.kind.value;
462
462
  return {
463
463
  actionId: receipt.actionId,
@@ -489,7 +489,7 @@ class NordUser extends NordClient_1.NordClient {
489
489
  senderAccountId: accountId,
490
490
  }),
491
491
  });
492
- this.expectReceiptKind(receipt, "cancelOrderResult", "cancel order");
492
+ (0, actions_1.expectReceiptKind)(receipt, "cancelOrderResult", "cancel order");
493
493
  return {
494
494
  actionId: receipt.actionId,
495
495
  orderId: receipt.kind.value.orderId,
@@ -544,7 +544,7 @@ class NordUser extends NordClient_1.NordClient {
544
544
  accountId: params.accountId,
545
545
  }),
546
546
  });
547
- this.expectReceiptKind(receipt, "triggerAdded", "add trigger");
547
+ (0, actions_1.expectReceiptKind)(receipt, "triggerAdded", "add trigger");
548
548
  return { actionId: receipt.actionId };
549
549
  }
550
550
  catch (error) {
@@ -580,7 +580,7 @@ class NordUser extends NordClient_1.NordClient {
580
580
  accountId: params.accountId,
581
581
  }),
582
582
  });
583
- this.expectReceiptKind(receipt, "triggerRemoved", "remove trigger");
583
+ (0, actions_1.expectReceiptKind)(receipt, "triggerRemoved", "remove trigger");
584
584
  return { actionId: receipt.actionId };
585
585
  }
586
586
  catch (error) {
@@ -611,7 +611,7 @@ class NordUser extends NordClient_1.NordClient {
611
611
  amount,
612
612
  }),
613
613
  });
614
- this.expectReceiptKind(receipt, "transferred", "transfer tokens");
614
+ (0, actions_1.expectReceiptKind)(receipt, "transferred", "transfer tokens");
615
615
  }
616
616
  catch (error) {
617
617
  throw new NordError_1.NordError("Failed to transfer tokens", { cause: error });
@@ -3,7 +3,7 @@ export { NordUser } from "./client/NordUser";
3
3
  export { NordAdmin } from "./client/NordAdmin";
4
4
  export { NordClient } from "./client/NordClient";
5
5
  export type { NordClientParams } from "./client/NordClient";
6
- export type { CreateTokenParams, CreateMarketParams, PythSetWormholeGuardiansParams, PythSetSymbolFeedParams, FreezeMarketParams, UnfreezeMarketParams, NordAdminParams, } from "./client/NordAdmin";
6
+ export type { CreateTokenParams, CreateMarketParams, PythSetWormholeGuardiansParams, PythSetSymbolFeedParams, FreezeMarketParams, UnfreezeMarketParams, } from "./client/NordAdmin";
7
7
  export { NordError } from "./utils/NordError";
8
8
  export * from "./api/core";
9
9
  export * from "./api/metrics";
package/dist/types.d.ts CHANGED
@@ -78,6 +78,11 @@ export type AccountPnlPage = components["schemas"]["PageResult_for_uint64_and_Ac
78
78
  export type AccountTriggerInfo = components["schemas"]["AccountTriggerInfo"];
79
79
  export type TriggerHistoryPage = components["schemas"]["PageResult_for_uint64_and_HistoryTriggerInfo"];
80
80
  export type HistoryTriggerQuery = components["schemas"]["AccountTriggersQuery"];
81
+ export type FeeTierConfig = components["schemas"]["FeeTierConfig"];
82
+ export type FeeTierId = components["schemas"]["FeeTierId"];
83
+ export type TokenStats = components["schemas"]["TokenStats"];
84
+ export type AccountFeeTier = components["schemas"]["AccountFeeTier"];
85
+ export type AccountFeeTierPage = components["schemas"]["PageResult_for_uint32_and_AccountFeeTier"];
81
86
  /**
82
87
  * Configuration options for the Nord client
83
88
  */
package/dist/utils.d.ts CHANGED
@@ -79,6 +79,7 @@ export declare const toScaledU128: (x: Decimal.Value, decimals: number) => bigin
79
79
  */
80
80
  export declare function decodeLengthDelimited<T extends Message>(bytes: Uint8Array, schema: GenMessage<T>): T;
81
81
  export declare function checkPubKeyLength(keyType: KeyType, len: number): void;
82
+ export declare function decodeHex(value: string): Uint8Array;
82
83
  export declare function findMarket(markets: Market[], marketId: number): Market;
83
84
  export declare function findToken(tokens: Token[], tokenId: number): Token;
84
85
  export declare function keypairFromPrivateKey(privateKey: string | Uint8Array): Keypair;
package/dist/utils.js CHANGED
@@ -13,6 +13,7 @@ exports.signAction = signAction;
13
13
  exports.makeWalletSignFn = makeWalletSignFn;
14
14
  exports.decodeLengthDelimited = decodeLengthDelimited;
15
15
  exports.checkPubKeyLength = checkPubKeyLength;
16
+ exports.decodeHex = decodeHex;
16
17
  exports.findMarket = findMarket;
17
18
  exports.findToken = findToken;
18
19
  exports.keypairFromPrivateKey = keypairFromPrivateKey;
@@ -195,6 +196,10 @@ function checkPubKeyLength(keyType, len) {
195
196
  throw new Error("Secp256k1 pubkeys must be 33 length.");
196
197
  }
197
198
  }
199
+ function decodeHex(value) {
200
+ const hex = value.startsWith("0x") ? value.slice(2) : value;
201
+ return Uint8Array.from(Buffer.from(hex, "hex"));
202
+ }
198
203
  function findMarket(markets, marketId) {
199
204
  if (marketId < 0 || markets.length - 1 < marketId) {
200
205
  throw new Error(`The market with marketId=${marketId} not found`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@n1xyz/nord-ts",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Typescript for Nord",
5
5
  "keywords": [],
6
6
  "author": "",
@@ -45,7 +45,7 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "@bufbuild/protobuf": "^2.6.3",
48
- "@n1xyz/proton": "0.0.5",
48
+ "@n1xyz/proton": "0.0.6",
49
49
  "@noble/curves": "^1.9.6",
50
50
  "@noble/ed25519": "^2.3.0",
51
51
  "@noble/hashes": "^1.8.0",