@nightlylabs/dex-sdk 0.2.40 → 0.2.42

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.cjs CHANGED
@@ -1409,8 +1409,9 @@ var AccountSequenceNumber = class {
1409
1409
  // src/client.ts
1410
1410
  var getRandomId = () => (0, import_uuid.v4)();
1411
1411
  var Client = class _Client {
1412
- constructor(connection, enableWs, url, apiKey, chainId, params) {
1412
+ constructor(connection, enableWs, url, apiKey, chainId, params, proxyUrl) {
1413
1413
  this._apiKeySequenceNumber = 0;
1414
+ // URL for proxy route (e.g., '/api/submit-sponsored-transaction')
1414
1415
  this._subscriptions = /* @__PURE__ */ new Map();
1415
1416
  this._gasUnitPrice = 100;
1416
1417
  this._expirationTimestampDelay = 20;
@@ -1430,6 +1431,13 @@ var Client = class _Client {
1430
1431
  secondarySigners: [],
1431
1432
  secondarySignersAuthenticators: []
1432
1433
  };
1434
+ if (this._proxyUrl) {
1435
+ const response2 = await this.sendPostJson(
1436
+ payload,
1437
+ this._proxyUrl
1438
+ );
1439
+ return response2;
1440
+ }
1433
1441
  const response = await this.sendPostJson(
1434
1442
  payload,
1435
1443
  "/v1/submit_sponsored_transaction" /* SubmitSponsoredTransactionRequest */
@@ -1451,6 +1459,13 @@ var Client = class _Client {
1451
1459
  (s) => Array.from(s.bcsToBytes())
1452
1460
  )
1453
1461
  };
1462
+ if (this._proxyUrl) {
1463
+ const response2 = await this.sendPostJson(
1464
+ payload,
1465
+ this._proxyUrl
1466
+ );
1467
+ return response2;
1468
+ }
1454
1469
  const response = await this.sendPostJson(
1455
1470
  payload,
1456
1471
  "/v1/submit_sponsored_transaction" /* SubmitSponsoredTransactionRequest */
@@ -1495,7 +1510,14 @@ var Client = class _Client {
1495
1510
  }
1496
1511
  };
1497
1512
  this.sendPostJson = async (message, endpoint) => {
1498
- const URL = this._serverUrl + endpoint;
1513
+ let URL;
1514
+ if (endpoint.startsWith("http://") || endpoint.startsWith("https://")) {
1515
+ URL = endpoint;
1516
+ } else if (endpoint.startsWith("/") && this._proxyUrl) {
1517
+ URL = endpoint;
1518
+ } else {
1519
+ URL = this._serverUrl + endpoint;
1520
+ }
1499
1521
  const headers = {
1500
1522
  "Content-Type": "application/json"
1501
1523
  };
@@ -1856,6 +1878,7 @@ var Client = class _Client {
1856
1878
  this._apiKey = apiKey || generateApiKey();
1857
1879
  this._subscriptions = /* @__PURE__ */ new Map();
1858
1880
  this._serverUrl = url || "https://api.dev.neony.exchange";
1881
+ this._proxyUrl = proxyUrl;
1859
1882
  this._sequenceNumberManager = new AccountSequenceNumber(this._aptos, this._apiKey);
1860
1883
  this._maxGas = params?.maxGas || 2e4;
1861
1884
  this._gasUnitPrice = params?.gasUnitPrice || 100;
@@ -1864,16 +1887,16 @@ var Client = class _Client {
1864
1887
  this.connectWebSocket();
1865
1888
  }
1866
1889
  }
1867
- static async init(connection, enableWs = true, url, apiKey, chainId, params) {
1890
+ static async init(connection, enableWs = true, url, apiKey, chainId, params, proxyUrl) {
1868
1891
  const id = chainId || await connection.getChainId();
1869
- const client = new _Client(connection, enableWs, url, apiKey, id, params);
1892
+ const client = new _Client(connection, enableWs, url, apiKey, id, params, proxyUrl);
1870
1893
  if (enableWs) {
1871
1894
  client.connectWebSocket();
1872
1895
  }
1873
1896
  return client;
1874
1897
  }
1875
- static async create(connection, enableWs = true, url, apiKey) {
1876
- return _Client.init(connection, enableWs, url, apiKey);
1898
+ static async create(connection, enableWs = true, url, apiKey, proxyUrl) {
1899
+ return _Client.init(connection, enableWs, url, apiKey, void 0, void 0, proxyUrl);
1877
1900
  }
1878
1901
  async setApiKey(apiKey) {
1879
1902
  this._apiKey = apiKey;
package/dist/index.d.cts CHANGED
@@ -2029,15 +2029,16 @@ declare class Client {
2029
2029
  _apiKeySequenceNumber: number;
2030
2030
  _ws: WebSocket | undefined;
2031
2031
  _serverUrl: string;
2032
+ _proxyUrl?: string;
2032
2033
  _subscriptions: Map<string, (data: WsMessage) => void>;
2033
2034
  _sequenceNumberManager: AccountSequenceNumber;
2034
2035
  _maxGas: number;
2035
2036
  _gasUnitPrice: number;
2036
2037
  _expirationTimestampDelay: number;
2037
2038
  timeout: number;
2038
- static init(connection: Aptos, enableWs?: boolean, url?: string, apiKey?: Account, chainId?: number, params?: TxParams): Promise<Client>;
2039
- constructor(connection: Aptos, enableWs: boolean, url?: string, apiKey?: Account, chainId?: number, params?: TxParams);
2040
- static create(connection: Aptos, enableWs?: boolean, url?: string, apiKey?: Account): Promise<Client>;
2039
+ static init(connection: Aptos, enableWs?: boolean, url?: string, apiKey?: Account, chainId?: number, params?: TxParams, proxyUrl?: string): Promise<Client>;
2040
+ constructor(connection: Aptos, enableWs: boolean, url?: string, apiKey?: Account, chainId?: number, params?: TxParams, proxyUrl?: string);
2041
+ static create(connection: Aptos, enableWs?: boolean, url?: string, apiKey?: Account, proxyUrl?: string): Promise<Client>;
2041
2042
  setApiKey(apiKey: Account): Promise<void>;
2042
2043
  getApiKeySequenceNumber(): Promise<bigint | null>;
2043
2044
  fetchApiKeySequenceNumber(): Promise<number>;
package/dist/index.d.ts CHANGED
@@ -2029,15 +2029,16 @@ declare class Client {
2029
2029
  _apiKeySequenceNumber: number;
2030
2030
  _ws: WebSocket | undefined;
2031
2031
  _serverUrl: string;
2032
+ _proxyUrl?: string;
2032
2033
  _subscriptions: Map<string, (data: WsMessage) => void>;
2033
2034
  _sequenceNumberManager: AccountSequenceNumber;
2034
2035
  _maxGas: number;
2035
2036
  _gasUnitPrice: number;
2036
2037
  _expirationTimestampDelay: number;
2037
2038
  timeout: number;
2038
- static init(connection: Aptos, enableWs?: boolean, url?: string, apiKey?: Account, chainId?: number, params?: TxParams): Promise<Client>;
2039
- constructor(connection: Aptos, enableWs: boolean, url?: string, apiKey?: Account, chainId?: number, params?: TxParams);
2040
- static create(connection: Aptos, enableWs?: boolean, url?: string, apiKey?: Account): Promise<Client>;
2039
+ static init(connection: Aptos, enableWs?: boolean, url?: string, apiKey?: Account, chainId?: number, params?: TxParams, proxyUrl?: string): Promise<Client>;
2040
+ constructor(connection: Aptos, enableWs: boolean, url?: string, apiKey?: Account, chainId?: number, params?: TxParams, proxyUrl?: string);
2041
+ static create(connection: Aptos, enableWs?: boolean, url?: string, apiKey?: Account, proxyUrl?: string): Promise<Client>;
2041
2042
  setApiKey(apiKey: Account): Promise<void>;
2042
2043
  getApiKeySequenceNumber(): Promise<bigint | null>;
2043
2044
  fetchApiKeySequenceNumber(): Promise<number>;
package/dist/index.js CHANGED
@@ -1359,8 +1359,9 @@ var AccountSequenceNumber = class {
1359
1359
  // src/client.ts
1360
1360
  var getRandomId = () => uuidv4();
1361
1361
  var Client = class _Client {
1362
- constructor(connection, enableWs, url, apiKey, chainId, params) {
1362
+ constructor(connection, enableWs, url, apiKey, chainId, params, proxyUrl) {
1363
1363
  this._apiKeySequenceNumber = 0;
1364
+ // URL for proxy route (e.g., '/api/submit-sponsored-transaction')
1364
1365
  this._subscriptions = /* @__PURE__ */ new Map();
1365
1366
  this._gasUnitPrice = 100;
1366
1367
  this._expirationTimestampDelay = 20;
@@ -1380,6 +1381,13 @@ var Client = class _Client {
1380
1381
  secondarySigners: [],
1381
1382
  secondarySignersAuthenticators: []
1382
1383
  };
1384
+ if (this._proxyUrl) {
1385
+ const response2 = await this.sendPostJson(
1386
+ payload,
1387
+ this._proxyUrl
1388
+ );
1389
+ return response2;
1390
+ }
1383
1391
  const response = await this.sendPostJson(
1384
1392
  payload,
1385
1393
  "/v1/submit_sponsored_transaction" /* SubmitSponsoredTransactionRequest */
@@ -1401,6 +1409,13 @@ var Client = class _Client {
1401
1409
  (s) => Array.from(s.bcsToBytes())
1402
1410
  )
1403
1411
  };
1412
+ if (this._proxyUrl) {
1413
+ const response2 = await this.sendPostJson(
1414
+ payload,
1415
+ this._proxyUrl
1416
+ );
1417
+ return response2;
1418
+ }
1404
1419
  const response = await this.sendPostJson(
1405
1420
  payload,
1406
1421
  "/v1/submit_sponsored_transaction" /* SubmitSponsoredTransactionRequest */
@@ -1445,7 +1460,14 @@ var Client = class _Client {
1445
1460
  }
1446
1461
  };
1447
1462
  this.sendPostJson = async (message, endpoint) => {
1448
- const URL = this._serverUrl + endpoint;
1463
+ let URL;
1464
+ if (endpoint.startsWith("http://") || endpoint.startsWith("https://")) {
1465
+ URL = endpoint;
1466
+ } else if (endpoint.startsWith("/") && this._proxyUrl) {
1467
+ URL = endpoint;
1468
+ } else {
1469
+ URL = this._serverUrl + endpoint;
1470
+ }
1449
1471
  const headers = {
1450
1472
  "Content-Type": "application/json"
1451
1473
  };
@@ -1806,6 +1828,7 @@ var Client = class _Client {
1806
1828
  this._apiKey = apiKey || generateApiKey();
1807
1829
  this._subscriptions = /* @__PURE__ */ new Map();
1808
1830
  this._serverUrl = url || "https://api.dev.neony.exchange";
1831
+ this._proxyUrl = proxyUrl;
1809
1832
  this._sequenceNumberManager = new AccountSequenceNumber(this._aptos, this._apiKey);
1810
1833
  this._maxGas = params?.maxGas || 2e4;
1811
1834
  this._gasUnitPrice = params?.gasUnitPrice || 100;
@@ -1814,16 +1837,16 @@ var Client = class _Client {
1814
1837
  this.connectWebSocket();
1815
1838
  }
1816
1839
  }
1817
- static async init(connection, enableWs = true, url, apiKey, chainId, params) {
1840
+ static async init(connection, enableWs = true, url, apiKey, chainId, params, proxyUrl) {
1818
1841
  const id = chainId || await connection.getChainId();
1819
- const client = new _Client(connection, enableWs, url, apiKey, id, params);
1842
+ const client = new _Client(connection, enableWs, url, apiKey, id, params, proxyUrl);
1820
1843
  if (enableWs) {
1821
1844
  client.connectWebSocket();
1822
1845
  }
1823
1846
  return client;
1824
1847
  }
1825
- static async create(connection, enableWs = true, url, apiKey) {
1826
- return _Client.init(connection, enableWs, url, apiKey);
1848
+ static async create(connection, enableWs = true, url, apiKey, proxyUrl) {
1849
+ return _Client.init(connection, enableWs, url, apiKey, void 0, void 0, proxyUrl);
1827
1850
  }
1828
1851
  async setApiKey(apiKey) {
1829
1852
  this._apiKey = apiKey;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nightlylabs/dex-sdk",
3
- "version": "0.2.40",
3
+ "version": "0.2.42",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {