ault-sdk-ts 0.16.0 → 0.16.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/dist/index.js CHANGED
@@ -5,7 +5,7 @@ var __export = (target, all) => {
5
5
  };
6
6
 
7
7
  // src/core/user-agent.ts
8
- var SDK_VERSION = "0.16.0";
8
+ var SDK_VERSION = "0.16.1";
9
9
  var USER_AGENT = `ault-sdk-ts/${SDK_VERSION}`;
10
10
  function isServerRuntime() {
11
11
  if (typeof document !== "undefined") return false;
@@ -21590,6 +21590,14 @@ function compareBytes(a, b) {
21590
21590
  return a.length - b.length;
21591
21591
  }
21592
21592
 
21593
+ // src/rest/market-id.ts
21594
+ var MARKET_ID_HEX_RE = /^(0[xX])?([0-9a-fA-F]{2})+$/;
21595
+ function marketIdToBase64(marketId) {
21596
+ if (marketId instanceof MarketId) return marketId.toBase64();
21597
+ if (typeof marketId !== "string") return bytesToBase64(marketId);
21598
+ return MARKET_ID_HEX_RE.test(marketId) ? MarketId.fromHex(marketId).toBase64() : marketId;
21599
+ }
21600
+
21593
21601
  // src/proto/gen/ault/clob/v1/query.ts
21594
21602
  import { BinaryReader as BinaryReader45, BinaryWriter as BinaryWriter45 } from "@bufbuild/protobuf/wire";
21595
21603
 
@@ -22580,9 +22588,6 @@ function normalizeOrderId(orderId) {
22580
22588
  if (typeof orderId !== "string") return bytesToBase64(orderId);
22581
22589
  return ORDER_ID_HEX_RE.test(orderId) ? OrderId.fromHex(orderId).toBase64() : orderId;
22582
22590
  }
22583
- function normalizeMarketId(marketId) {
22584
- return typeof marketId === "string" ? marketId : bytesToBase64(marketId);
22585
- }
22586
22591
  var LIMIT_TYPE_URL = "/ault.clob.v1.MsgPlaceLimitOrder";
22587
22592
  var MARKET_TYPE_URL = "/ault.clob.v1.MsgPlaceMarketOrder";
22588
22593
  var OPTION_CODECS = {
@@ -22674,7 +22679,7 @@ function createClobApi(context) {
22674
22679
  },
22675
22680
  async getOrders(params = {}) {
22676
22681
  const query = buildQuery({
22677
- market_id: params.marketId ? normalizeMarketId(params.marketId) : void 0,
22682
+ market_id: params.marketId ? marketIdToBase64(params.marketId) : void 0,
22678
22683
  ...params.pagination
22679
22684
  });
22680
22685
  return fetchProtoJson(
@@ -25101,10 +25106,6 @@ function isSet46(value) {
25101
25106
  }
25102
25107
 
25103
25108
  // src/rest/margin.ts
25104
- function marketIdParam(marketId) {
25105
- if (marketId instanceof MarketId) return marketId.toBase64();
25106
- return typeof marketId === "string" ? marketId : bytesToBase64(marketId);
25107
- }
25108
25109
  var enc2 = encodeURIComponent;
25109
25110
  function createMarginApi(context) {
25110
25111
  return {
@@ -25121,7 +25122,7 @@ function createMarginApi(context) {
25121
25122
  },
25122
25123
  async getMarginAccount(owner, marketId) {
25123
25124
  const query = buildQuery({
25124
- market_id: marketId === void 0 ? void 0 : marketIdParam(marketId)
25125
+ market_id: marketId === void 0 ? void 0 : marketIdToBase64(marketId)
25125
25126
  });
25126
25127
  return fetchProtoJson(
25127
25128
  context,
@@ -25511,9 +25512,6 @@ function isSet48(value) {
25511
25512
  }
25512
25513
 
25513
25514
  // src/rest/market.ts
25514
- function normalizeMarketId2(marketId) {
25515
- return typeof marketId === "string" ? marketId : bytesToBase64(marketId);
25516
- }
25517
25515
  function createMarketApi(context) {
25518
25516
  return {
25519
25517
  async getParams() {
@@ -25526,7 +25524,7 @@ function createMarketApi(context) {
25526
25524
  async getMarket(marketId) {
25527
25525
  return fetchProtoJson(
25528
25526
  context,
25529
- `/ault/market/v1/markets/${encodeURIComponent(normalizeMarketId2(marketId))}`,
25527
+ `/ault/market/v1/markets/${encodeURIComponent(marketIdToBase64(marketId))}`,
25530
25528
  QueryMarketResponse
25531
25529
  );
25532
25530
  }
@@ -28741,10 +28739,6 @@ function isSet53(value) {
28741
28739
  }
28742
28740
 
28743
28741
  // src/rest/perpetual.ts
28744
- function normalizeMarketId3(marketId) {
28745
- if (marketId instanceof MarketId) return marketId.toBase64();
28746
- return typeof marketId === "string" ? marketId : bytesToBase64(marketId);
28747
- }
28748
28742
  function createPerpetualApi(context) {
28749
28743
  return {
28750
28744
  async getParams() {
@@ -28759,7 +28753,7 @@ function createPerpetualApi(context) {
28759
28753
  },
28760
28754
  async getAccount(owner, marketId) {
28761
28755
  const query = buildQuery({
28762
- market_id: marketId === void 0 ? void 0 : normalizeMarketId3(marketId)
28756
+ market_id: marketId === void 0 ? void 0 : marketIdToBase64(marketId)
28763
28757
  });
28764
28758
  return fetchProtoJson(
28765
28759
  context,
@@ -28768,7 +28762,7 @@ function createPerpetualApi(context) {
28768
28762
  );
28769
28763
  },
28770
28764
  async getPosition(owner, marketId, cross) {
28771
- const query = buildQuery({ market_id: normalizeMarketId3(marketId), cross });
28765
+ const query = buildQuery({ market_id: marketIdToBase64(marketId), cross });
28772
28766
  return fetchProtoJson(
28773
28767
  context,
28774
28768
  `/ault/perpetual/v1/position/${encodeURIComponent(normalizeAddress(owner))}${query}`,
@@ -28777,7 +28771,7 @@ function createPerpetualApi(context) {
28777
28771
  },
28778
28772
  async getAccountRisk(owner, marketId) {
28779
28773
  const query = buildQuery({
28780
- market_id: marketId === void 0 ? void 0 : normalizeMarketId3(marketId)
28774
+ market_id: marketId === void 0 ? void 0 : marketIdToBase64(marketId)
28781
28775
  });
28782
28776
  return fetchProtoJson(
28783
28777
  context,
@@ -28786,11 +28780,11 @@ function createPerpetualApi(context) {
28786
28780
  );
28787
28781
  },
28788
28782
  async getFunding(marketId) {
28789
- const query = buildQuery({ market_id: normalizeMarketId3(marketId) });
28783
+ const query = buildQuery({ market_id: marketIdToBase64(marketId) });
28790
28784
  return fetchProtoJson(context, `/ault/perpetual/v1/funding${query}`, QueryFundingResponse);
28791
28785
  },
28792
28786
  async getPrices(marketId) {
28793
- const id = encodeURIComponent(normalizeMarketId3(marketId));
28787
+ const id = encodeURIComponent(marketIdToBase64(marketId));
28794
28788
  return fetchProtoJson(
28795
28789
  context,
28796
28790
  `/ault/perpetual/v1/markets/${id}/prices`,
@@ -28798,7 +28792,7 @@ function createPerpetualApi(context) {
28798
28792
  );
28799
28793
  },
28800
28794
  async getImpactPrices(marketId) {
28801
- const id = encodeURIComponent(normalizeMarketId3(marketId));
28795
+ const id = encodeURIComponent(marketIdToBase64(marketId));
28802
28796
  return fetchProtoJson(
28803
28797
  context,
28804
28798
  `/ault/perpetual/v1/markets/${id}/impact_prices`,
@@ -29532,7 +29526,7 @@ function createRewardApi(context) {
29532
29526
  );
29533
29527
  },
29534
29528
  async getDeployerShare(marketId) {
29535
- const encoded = typeof marketId === "string" ? marketId : bytesToBase64(marketId);
29529
+ const encoded = marketIdToBase64(marketId);
29536
29530
  return fetchProtoJson(
29537
29531
  context,
29538
29532
  `/ault/reward/v1/deployer_share/${encodeURIComponent(encoded)}`,