@decibeltrade/sdk 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.
Files changed (64) hide show
  1. package/dist/abi/generate-abis.js +9 -44
  2. package/dist/abi/types.js +1 -2
  3. package/dist/admin.js +10 -14
  4. package/dist/base.js +19 -26
  5. package/dist/constants.js +34 -41
  6. package/dist/fee-pay.js +1 -4
  7. package/dist/gas/gas-price-manager.js +3 -7
  8. package/dist/index.js +10 -26
  9. package/dist/order-event.types.js +1 -2
  10. package/dist/order-status.js +16 -23
  11. package/dist/read/account-overview/account-overview.reader.js +20 -91
  12. package/dist/read/account-overview/account-overview.types.d.ts +7 -7
  13. package/dist/read/account-overview/account-overview.types.js +23 -26
  14. package/dist/read/base-reader.js +5 -9
  15. package/dist/read/candlesticks/candlesticks.reader.js +24 -95
  16. package/dist/read/candlesticks/candlesticks.types.js +14 -17
  17. package/dist/read/delegations/delegations.reader.js +14 -84
  18. package/dist/read/delegations/delegations.types.js +6 -9
  19. package/dist/read/index.js +50 -68
  20. package/dist/read/leaderboard/leaderboard.reader.js +13 -94
  21. package/dist/read/leaderboard/leaderboard.types.js +10 -13
  22. package/dist/read/market-contexts/market-contexts.reader.js +16 -83
  23. package/dist/read/market-contexts/market-contexts.types.js +12 -15
  24. package/dist/read/market-depth/market-depth.reader.js +29 -101
  25. package/dist/read/market-depth/market-depth.types.js +8 -11
  26. package/dist/read/market-prices/market-prices.reader.js +30 -111
  27. package/dist/read/market-prices/market-prices.types.js +21 -24
  28. package/dist/read/market-trades/market-trades.reader.js +23 -94
  29. package/dist/read/market-trades/market-trades.types.js +18 -21
  30. package/dist/read/markets/markets.reader.js +55 -152
  31. package/dist/read/markets/markets.types.js +32 -35
  32. package/dist/read/pagination.types.js +5 -11
  33. package/dist/read/portfolio-chart/portfolio-chart.reader.js +12 -82
  34. package/dist/read/portfolio-chart/portfolio-chart.types.js +5 -8
  35. package/dist/read/types.js +58 -75
  36. package/dist/read/user-active-twaps/user-active-twaps.reader.js +16 -86
  37. package/dist/read/user-active-twaps/user-active-twaps.types.js +18 -21
  38. package/dist/read/user-bulk-orders/user-bulk-orders.reader.js +16 -86
  39. package/dist/read/user-bulk-orders/user-bulk-orders.types.js +16 -19
  40. package/dist/read/user-funding-history/user-funding-history.reader.js +16 -86
  41. package/dist/read/user-funding-history/user-funding-history.types.js +13 -16
  42. package/dist/read/user-notifications/user-notifications.reader.js +8 -32
  43. package/dist/read/user-notifications/user-notifications.types.js +19 -22
  44. package/dist/read/user-open-orders/user-open-orders.reader.js +16 -86
  45. package/dist/read/user-open-orders/user-open-orders.types.js +27 -30
  46. package/dist/read/user-order-history/user-order-history.reader.js +18 -88
  47. package/dist/read/user-order-history/user-order-history.types.js +29 -32
  48. package/dist/read/user-positions/user-positions.reader.js +24 -95
  49. package/dist/read/user-positions/user-positions.types.d.ts +15 -15
  50. package/dist/read/user-positions/user-positions.types.js +22 -25
  51. package/dist/read/user-subaccounts/user-subaccounts.reader.js +18 -89
  52. package/dist/read/user-subaccounts/user-subaccounts.types.js +8 -11
  53. package/dist/read/user-trade-history/user-trade-history.reader.js +16 -86
  54. package/dist/read/user-trade-history/user-trade-history.types.js +18 -21
  55. package/dist/read/vaults/vaults.reader.js +45 -150
  56. package/dist/read/vaults/vaults.types.js +52 -55
  57. package/dist/read/ws-subscription.js +10 -17
  58. package/dist/subaccount-types.js +4 -7
  59. package/dist/transaction-builder.js +15 -23
  60. package/dist/tsconfig.tsbuildinfo +1 -1
  61. package/dist/utils.js +28 -42
  62. package/dist/write.js +20 -24
  63. package/package.json +4 -3
  64. package/tsconfig.json +4 -1
@@ -1,167 +1,62 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
- return new (P || (P = Promise))(function (resolve, reject) {
20
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
- step((generator = generator.apply(thisArg, _arguments || [])).next());
24
- });
25
- };
26
- var __generator = (this && this.__generator) || function (thisArg, body) {
27
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
28
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
- function verb(n) { return function (v) { return step([n, v]); }; }
30
- function step(op) {
31
- if (f) throw new TypeError("Generator is already executing.");
32
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
33
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
- if (y = 0, t) op = [op[0] & 2, t.value];
35
- switch (op[0]) {
36
- case 0: case 1: t = op; break;
37
- case 4: _.label++; return { value: op[1], done: false };
38
- case 5: _.label++; y = op[1]; op = [0]; continue;
39
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
- default:
41
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
- if (t[2]) _.ops.pop();
46
- _.trys.pop(); continue;
47
- }
48
- op = body.call(thisArg, _);
49
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
- }
52
- };
53
- var __rest = (this && this.__rest) || function (s, e) {
54
- var t = {};
55
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
56
- t[p] = s[p];
57
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
58
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
59
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
60
- t[p[i]] = s[p[i]];
61
- }
62
- return t;
63
- };
64
- Object.defineProperty(exports, "__esModule", { value: true });
65
- exports.VaultsReader = void 0;
66
- var base_reader_1 = require("../base-reader");
67
- var vaults_types_1 = require("./vaults.types");
68
- var VaultsReader = /** @class */ (function (_super) {
69
- __extends(VaultsReader, _super);
70
- function VaultsReader() {
71
- return _super !== null && _super.apply(this, arguments) || this;
72
- }
1
+ import { BaseReader } from "../base-reader";
2
+ import { UserOwnedVaultsResponseSchema, UserPerformancesOnVaultsResponseSchema, VaultsResponseSchema, } from "./vaults.types";
3
+ export class VaultsReader extends BaseReader {
73
4
  /**
74
5
  * Get all vaults
75
6
  * @returns All vaults
76
7
  */
77
- VaultsReader.prototype.getVaults = function () {
78
- return __awaiter(this, arguments, void 0, function (_a) {
79
- var queryParams, response;
80
- if (_a === void 0) { _a = {}; }
81
- var fetchOptions = _a.fetchOptions, args = __rest(_a, ["fetchOptions"]);
82
- return __generator(this, function (_b) {
83
- switch (_b.label) {
84
- case 0:
85
- queryParams = new URLSearchParams();
86
- if (args.vaultType)
87
- queryParams.set("vault_type", args.vaultType);
88
- if (args.limit)
89
- queryParams.set("limit", args.limit.toString());
90
- if (args.offset)
91
- queryParams.set("offset", args.offset.toString());
92
- return [4 /*yield*/, this.getRequest({
93
- schema: vaults_types_1.VaultsResponseSchema,
94
- url: "".concat(this.deps.config.tradingHttpUrl, "/api/v1/vaults"),
95
- queryParams: queryParams,
96
- options: fetchOptions,
97
- })];
98
- case 1:
99
- response = _b.sent();
100
- return [2 /*return*/, response.data];
101
- }
102
- });
8
+ async getVaults({ fetchOptions, ...args } = {}) {
9
+ const queryParams = new URLSearchParams();
10
+ if (args.vaultType)
11
+ queryParams.set("vault_type", args.vaultType);
12
+ if (args.limit)
13
+ queryParams.set("limit", args.limit.toString());
14
+ if (args.offset)
15
+ queryParams.set("offset", args.offset.toString());
16
+ const response = await this.getRequest({
17
+ schema: VaultsResponseSchema,
18
+ url: `${this.deps.config.tradingHttpUrl}/api/v1/vaults`,
19
+ queryParams,
20
+ options: fetchOptions,
103
21
  });
104
- };
22
+ return response.data;
23
+ }
105
24
  /**
106
25
  * Get vaults by owner address
107
26
  * @param user The user address to filter vaults by
108
27
  * @returns The vaults for the given owner address
109
28
  */
110
- VaultsReader.prototype.getUserOwnedVaults = function (_a) {
111
- return __awaiter(this, void 0, void 0, function () {
112
- var queryParams, response;
113
- var fetchOptions = _a.fetchOptions, args = __rest(_a, ["fetchOptions"]);
114
- return __generator(this, function (_b) {
115
- switch (_b.label) {
116
- case 0:
117
- queryParams = new URLSearchParams({
118
- user: args.ownerAddr,
119
- });
120
- if (args.limit)
121
- queryParams.set("limit", args.limit.toString());
122
- if (args.offset)
123
- queryParams.set("offset", args.offset.toString());
124
- return [4 /*yield*/, this.getRequest({
125
- schema: vaults_types_1.UserOwnedVaultsResponseSchema,
126
- url: "".concat(this.deps.config.tradingHttpUrl, "/api/v1/user_owned_vaults"),
127
- queryParams: queryParams,
128
- options: fetchOptions,
129
- })];
130
- case 1:
131
- response = _b.sent();
132
- return [2 /*return*/, response.data];
133
- }
134
- });
29
+ async getUserOwnedVaults({ fetchOptions, ...args }) {
30
+ const queryParams = new URLSearchParams({
31
+ user: args.ownerAddr,
32
+ });
33
+ if (args.limit)
34
+ queryParams.set("limit", args.limit.toString());
35
+ if (args.offset)
36
+ queryParams.set("offset", args.offset.toString());
37
+ const response = await this.getRequest({
38
+ schema: UserOwnedVaultsResponseSchema,
39
+ url: `${this.deps.config.tradingHttpUrl}/api/v1/user_owned_vaults`,
40
+ queryParams,
41
+ options: fetchOptions,
135
42
  });
136
- };
43
+ return response.data;
44
+ }
137
45
  /**
138
46
  * Get user performance
139
47
  * @param args The arguments for the user performance
140
48
  * @returns The user performance
141
49
  */
142
- VaultsReader.prototype.getUserPerformancesOnVaults = function (_a) {
143
- return __awaiter(this, void 0, void 0, function () {
144
- var queryParams, response;
145
- var fetchOptions = _a.fetchOptions, args = __rest(_a, ["fetchOptions"]);
146
- return __generator(this, function (_b) {
147
- switch (_b.label) {
148
- case 0:
149
- queryParams = new URLSearchParams({
150
- user_address: args.ownerAddr,
151
- });
152
- return [4 /*yield*/, this.getRequest({
153
- schema: vaults_types_1.UserPerformancesOnVaultsResponseSchema,
154
- url: "".concat(this.deps.config.tradingHttpUrl, "/api/v1/user_vault_performance"),
155
- queryParams: queryParams,
156
- options: fetchOptions,
157
- })];
158
- case 1:
159
- response = _b.sent();
160
- return [2 /*return*/, response.data];
161
- }
162
- });
50
+ async getUserPerformancesOnVaults({ fetchOptions, ...args }) {
51
+ const queryParams = new URLSearchParams({
52
+ user_address: args.ownerAddr,
53
+ });
54
+ const response = await this.getRequest({
55
+ schema: UserPerformancesOnVaultsResponseSchema,
56
+ url: `${this.deps.config.tradingHttpUrl}/api/v1/user_vault_performance`,
57
+ queryParams,
58
+ options: fetchOptions,
163
59
  });
164
- };
165
- return VaultsReader;
166
- }(base_reader_1.BaseReader));
167
- exports.VaultsReader = VaultsReader;
60
+ return response.data;
61
+ }
62
+ }
@@ -1,71 +1,68 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UserPerformancesOnVaultsResponseSchema = exports.UserPerformanceOnVaultSchema = exports.UserOwnedVaultsResponseSchema = exports.UserOwnedVaultSchema = exports.VaultsResponseSchema = exports.VaultSchema = void 0;
4
- var v4_1 = require("zod/v4");
5
- var pagination_types_1 = require("../pagination.types");
1
+ import z from "zod/v4";
2
+ import { PaginatedResponseSchema } from "../pagination.types";
6
3
  /**
7
4
  * Schema for a vault in the protocol
8
5
  * Represents both protocol-wide vaults and user-managed vaults
9
6
  */
10
- exports.VaultSchema = v4_1.default.object({
11
- address: v4_1.default.string(),
12
- name: v4_1.default.string(),
13
- description: v4_1.default.string().nullable(),
14
- manager: v4_1.default.string(),
15
- status: v4_1.default.string(),
16
- created_at: v4_1.default.number(),
17
- tvl: v4_1.default.number().nullable(),
18
- volume: v4_1.default.number().nullable(),
19
- all_time_return: v4_1.default.number().nullable(),
20
- past_month_return: v4_1.default.number().nullable(),
21
- sharpe_ratio: v4_1.default.number().nullable(),
22
- max_drawdown: v4_1.default.number().nullable(),
23
- weekly_win_rate_12w: v4_1.default.number().nullable(),
24
- profit_share: v4_1.default.number().nullable(),
25
- pnl_90d: v4_1.default.number().nullable(),
26
- manager_avg_cash: v4_1.default.number().nullable(),
27
- average_leverage: v4_1.default.number().nullable(),
28
- depositors: v4_1.default.number().nullable(),
29
- perp_equity: v4_1.default.number().nullable(),
30
- vault_type: v4_1.default.string(),
31
- pnl_history: v4_1.default.array(v4_1.default.string()).nullable(),
32
- social_links: v4_1.default.array(v4_1.default.string()).nullable(),
7
+ export const VaultSchema = z.object({
8
+ address: z.string(),
9
+ name: z.string(),
10
+ description: z.string().nullable(),
11
+ manager: z.string(),
12
+ status: z.string(),
13
+ created_at: z.number(),
14
+ tvl: z.number().nullable(),
15
+ volume: z.number().nullable(),
16
+ all_time_return: z.number().nullable(),
17
+ past_month_return: z.number().nullable(),
18
+ sharpe_ratio: z.number().nullable(),
19
+ max_drawdown: z.number().nullable(),
20
+ weekly_win_rate_12w: z.number().nullable(),
21
+ profit_share: z.number().nullable(),
22
+ pnl_90d: z.number().nullable(),
23
+ manager_avg_cash: z.number().nullable(),
24
+ average_leverage: z.number().nullable(),
25
+ depositors: z.number().nullable(),
26
+ perp_equity: z.number().nullable(),
27
+ vault_type: z.string(),
28
+ pnl_history: z.array(z.string()).nullable(),
29
+ social_links: z.array(z.string()).nullable(),
33
30
  });
34
- exports.VaultsResponseSchema = (0, pagination_types_1.PaginatedResponseSchema)(exports.VaultSchema).extend({
35
- total_value_locked: v4_1.default.number(),
36
- total_volume: v4_1.default.number(),
31
+ export const VaultsResponseSchema = PaginatedResponseSchema(VaultSchema).extend({
32
+ total_value_locked: z.number(),
33
+ total_volume: z.number(),
37
34
  });
38
35
  /**
39
36
  * Schema for vaults owned/managed by a specific user
40
37
  * Contains summary information about vaults the user manages
41
38
  */
42
- exports.UserOwnedVaultSchema = v4_1.default.object({
43
- vault_address: v4_1.default.string(),
44
- vault_name: v4_1.default.string(),
45
- vault_share_symbol: v4_1.default.string(),
46
- status: v4_1.default.string(),
47
- age_days: v4_1.default.number(),
48
- num_managers: v4_1.default.number(),
49
- tvl: v4_1.default.number().nullable(),
50
- apr: v4_1.default.number().nullable(),
51
- manager_equity: v4_1.default.number().nullable(),
52
- manager_stake: v4_1.default.number().nullable(),
39
+ export const UserOwnedVaultSchema = z.object({
40
+ vault_address: z.string(),
41
+ vault_name: z.string(),
42
+ vault_share_symbol: z.string(),
43
+ status: z.string(),
44
+ age_days: z.number(),
45
+ num_managers: z.number(),
46
+ tvl: z.number().nullable(),
47
+ apr: z.number().nullable(),
48
+ manager_equity: z.number().nullable(),
49
+ manager_stake: z.number().nullable(),
53
50
  });
54
- exports.UserOwnedVaultsResponseSchema = (0, pagination_types_1.PaginatedResponseSchema)(exports.UserOwnedVaultSchema);
51
+ export const UserOwnedVaultsResponseSchema = PaginatedResponseSchema(UserOwnedVaultSchema);
55
52
  /**
56
53
  * Schema for user performance metrics within a vault
57
54
  * Tracks a user's deposits, shares, returns, and PnL for a specific vault
58
55
  */
59
- exports.UserPerformanceOnVaultSchema = v4_1.default.object({
60
- vault_address: v4_1.default.string(),
61
- user_address: v4_1.default.string(),
62
- net_deposits: v4_1.default.number().nullable(),
63
- current_num_shares: v4_1.default.number().nullable(),
64
- current_value_of_shares: v4_1.default.number().nullable(),
65
- all_time_return: v4_1.default.number().nullable(),
66
- unrealized_pnl: v4_1.default.number().nullable(),
67
- share_price: v4_1.default.number(),
68
- volume: v4_1.default.number(),
69
- weekly_win_rate_12w: v4_1.default.number().nullable(),
56
+ export const UserPerformanceOnVaultSchema = z.object({
57
+ vault_address: z.string(),
58
+ user_address: z.string(),
59
+ net_deposits: z.number().nullable(),
60
+ current_num_shares: z.number().nullable(),
61
+ current_value_of_shares: z.number().nullable(),
62
+ all_time_return: z.number().nullable(),
63
+ unrealized_pnl: z.number().nullable(),
64
+ share_price: z.number(),
65
+ volume: z.number(),
66
+ weekly_win_rate_12w: z.number().nullable(),
70
67
  });
71
- exports.UserPerformancesOnVaultsResponseSchema = v4_1.default.array(exports.UserPerformanceOnVaultSchema);
68
+ export const UserPerformancesOnVaultsResponseSchema = z.array(UserPerformanceOnVaultSchema);
@@ -1,12 +1,6 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.DecibelWsSubscription = void 0;
7
- const isomorphic_ws_1 = __importDefault(require("isomorphic-ws"));
8
- const utils_1 = require("../utils");
9
- class DecibelWsSubscription {
1
+ import WebSocket from "isomorphic-ws";
2
+ import { bigIntReviver, prettifyMaybeZodError } from "../utils";
3
+ export class DecibelWsSubscription {
10
4
  config;
11
5
  onError;
12
6
  constructor(config, onError) {
@@ -27,7 +21,7 @@ class DecibelWsSubscription {
27
21
  return null;
28
22
  }
29
23
  try {
30
- const jsonData = JSON.parse(data, utils_1.bigIntReviver);
24
+ const jsonData = JSON.parse(data, bigIntReviver);
31
25
  if (jsonData &&
32
26
  typeof jsonData === "object" &&
33
27
  "topic" in jsonData &&
@@ -45,7 +39,7 @@ class DecibelWsSubscription {
45
39
  if (this.#ws) {
46
40
  return;
47
41
  }
48
- const ws = new isomorphic_ws_1.default(this.config.tradingWsUrl);
42
+ const ws = new WebSocket(this.config.tradingWsUrl);
49
43
  ws.addEventListener("open", () => {
50
44
  this.#reconnectAttempts = 0;
51
45
  this.#subscriptions.keys().forEach((topic) => {
@@ -94,7 +88,7 @@ class DecibelWsSubscription {
94
88
  const listeners = this.#subscriptions.get(topic) ?? new Set();
95
89
  // If subscription arent found, subscribe to topic first
96
90
  if (listeners.size === 0) {
97
- if (this.#ws?.readyState === isomorphic_ws_1.default.OPEN) {
91
+ if (this.#ws?.readyState === WebSocket.OPEN) {
98
92
  this.#ws.send(this.#getSubscribeMessage(topic));
99
93
  }
100
94
  }
@@ -104,7 +98,7 @@ class DecibelWsSubscription {
104
98
  void onData(parsedData);
105
99
  }
106
100
  catch (e) {
107
- throw (0, utils_1.prettifyMaybeZodError)(e);
101
+ throw prettifyMaybeZodError(e);
108
102
  }
109
103
  };
110
104
  listeners.add(listener);
@@ -119,7 +113,7 @@ class DecibelWsSubscription {
119
113
  if (!this.#subscriptions.has(topic))
120
114
  return;
121
115
  this.#subscriptions.delete(topic);
122
- if (this.#ws?.readyState === isomorphic_ws_1.default.OPEN) {
116
+ if (this.#ws?.readyState === WebSocket.OPEN) {
123
117
  this.#ws.send(this.#getUnsubscribeMessage(topic));
124
118
  }
125
119
  // Close the WebSocket if the last subscription was removed.
@@ -159,7 +153,7 @@ class DecibelWsSubscription {
159
153
  if (!this.#subscriptions.has(topic)) {
160
154
  return;
161
155
  }
162
- if (this.#ws?.readyState === isomorphic_ws_1.default.OPEN) {
156
+ if (this.#ws?.readyState === WebSocket.OPEN) {
163
157
  this.#ws.send(this.#getUnsubscribeMessage(topic));
164
158
  this.#ws.send(this.#getSubscribeMessage(topic));
165
159
  return;
@@ -170,7 +164,6 @@ class DecibelWsSubscription {
170
164
  this.#ws?.close();
171
165
  }
172
166
  readyState() {
173
- return this.#ws?.readyState ?? isomorphic_ws_1.default.CLOSED;
167
+ return this.#ws?.readyState ?? WebSocket.CLOSED;
174
168
  }
175
169
  }
176
- exports.DecibelWsSubscription = DecibelWsSubscription;
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RenameSubaccountSchema = void 0;
4
- var v4_1 = require("zod/v4");
5
- exports.RenameSubaccountSchema = v4_1.default.object({
6
- subaccount_address: v4_1.default.string(),
7
- new_name: v4_1.default.string(),
1
+ import z from "zod/v4";
2
+ export const RenameSubaccountSchema = z.object({
3
+ subaccount_address: z.string(),
4
+ new_name: z.string(),
8
5
  });
@@ -1,34 +1,30 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateExpireTimestamp = void 0;
4
- exports.buildSimpleTransactionSync = buildSimpleTransactionSync;
5
- var ts_sdk_1 = require("@aptos-labs/ts-sdk");
6
- function buildSimpleTransactionSync(args) {
7
- var txnPayload = (0, ts_sdk_1.generateTransactionPayloadWithABI)({
1
+ import { AccountAddress, ChainId, convertPayloadToInnerPayload, findFirstNonSignerArg, generateTransactionPayloadWithABI, parseTypeTag, RawTransaction, SimpleTransaction, } from "@aptos-labs/ts-sdk";
2
+ export function buildSimpleTransactionSync(args) {
3
+ const txnPayload = generateTransactionPayloadWithABI({
8
4
  aptosConfig: args.aptosConfig,
9
5
  function: args.data.function,
10
6
  functionArguments: args.data.functionArguments,
11
7
  typeArguments: args.data.typeArguments,
12
8
  abi: parseMoveFnAbiToEntryFnABI(args.abi),
13
9
  });
14
- var expireTimestamp = (0, exports.generateExpireTimestamp)(args.aptosConfig, args.timeDeltaMs);
15
- var rawTxn = new ts_sdk_1.RawTransaction(ts_sdk_1.AccountAddress.from(args.sender),
10
+ const expireTimestamp = generateExpireTimestamp(args.aptosConfig, args.timeDeltaMs);
11
+ const rawTxn = new RawTransaction(AccountAddress.from(args.sender),
16
12
  // If replay nonce is provided, use it as the sequence number
17
13
  // This is an unused value, so it's specifically to show that the sequence number is not used
18
- BigInt("0xdeadbeef"), (0, ts_sdk_1.convertPayloadToInnerPayload)(txnPayload, args.replayProtectionNonce),
14
+ BigInt("0xdeadbeef"), convertPayloadToInnerPayload(txnPayload, args.replayProtectionNonce),
19
15
  // @Todo: Use gasPriceManager to get the max gas amount [as defaultMaxGasAmount might be very high number]
20
- BigInt(args.aptosConfig.getDefaultMaxGasAmount()), BigInt(args.gasUnitPrice), BigInt(expireTimestamp), new ts_sdk_1.ChainId(args.chainId));
21
- return new ts_sdk_1.SimpleTransaction(rawTxn, args.withFeePayer ? ts_sdk_1.AccountAddress.ZERO : undefined);
16
+ BigInt(args.aptosConfig.getDefaultMaxGasAmount()), BigInt(args.gasUnitPrice), BigInt(expireTimestamp), new ChainId(args.chainId));
17
+ return new SimpleTransaction(rawTxn, args.withFeePayer ? AccountAddress.ZERO : undefined);
22
18
  }
23
- var parseMoveFnAbiToEntryFnABI = function (functionAbi) {
19
+ const parseMoveFnAbiToEntryFnABI = (functionAbi) => {
24
20
  // Remove the signer arguments
25
- var numSigners = (0, ts_sdk_1.findFirstNonSignerArg)(functionAbi);
26
- var params = [];
27
- for (var i = numSigners; i < functionAbi.params.length; i += 1) {
28
- var param = functionAbi.params[i];
21
+ const numSigners = findFirstNonSignerArg(functionAbi);
22
+ const params = [];
23
+ for (let i = numSigners; i < functionAbi.params.length; i += 1) {
24
+ const param = functionAbi.params[i];
29
25
  if (!param)
30
26
  continue;
31
- params.push((0, ts_sdk_1.parseTypeTag)(param, { allowGenerics: true }));
27
+ params.push(parseTypeTag(param, { allowGenerics: true }));
32
28
  }
33
29
  return {
34
30
  signers: numSigners,
@@ -36,8 +32,4 @@ var parseMoveFnAbiToEntryFnABI = function (functionAbi) {
36
32
  parameters: params,
37
33
  };
38
34
  };
39
- var generateExpireTimestamp = function (aptosConfig, timeDeltaMs) {
40
- if (timeDeltaMs === void 0) { timeDeltaMs = 0; }
41
- return Math.floor((Date.now() + timeDeltaMs) / 1000) + aptosConfig.getDefaultTxnExpirySecFromNow();
42
- };
43
- exports.generateExpireTimestamp = generateExpireTimestamp;
35
+ export const generateExpireTimestamp = (aptosConfig, timeDeltaMs = 0) => Math.floor((Date.now() + timeDeltaMs) / 1000) + aptosConfig.getDefaultTxnExpirySecFromNow();