@nightlylabs/dex-sdk 0.2.40 → 0.2.41
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 +22 -6
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +22 -6
- package/package.json +1 -1
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,7 @@ var Client = class _Client {
|
|
|
1495
1510
|
}
|
|
1496
1511
|
};
|
|
1497
1512
|
this.sendPostJson = async (message, endpoint) => {
|
|
1498
|
-
const URL = this._serverUrl + endpoint;
|
|
1513
|
+
const URL = endpoint.startsWith("/") ? endpoint : this._serverUrl + endpoint;
|
|
1499
1514
|
const headers = {
|
|
1500
1515
|
"Content-Type": "application/json"
|
|
1501
1516
|
};
|
|
@@ -1856,6 +1871,7 @@ var Client = class _Client {
|
|
|
1856
1871
|
this._apiKey = apiKey || generateApiKey();
|
|
1857
1872
|
this._subscriptions = /* @__PURE__ */ new Map();
|
|
1858
1873
|
this._serverUrl = url || "https://api.dev.neony.exchange";
|
|
1874
|
+
this._proxyUrl = proxyUrl;
|
|
1859
1875
|
this._sequenceNumberManager = new AccountSequenceNumber(this._aptos, this._apiKey);
|
|
1860
1876
|
this._maxGas = params?.maxGas || 2e4;
|
|
1861
1877
|
this._gasUnitPrice = params?.gasUnitPrice || 100;
|
|
@@ -1864,16 +1880,16 @@ var Client = class _Client {
|
|
|
1864
1880
|
this.connectWebSocket();
|
|
1865
1881
|
}
|
|
1866
1882
|
}
|
|
1867
|
-
static async init(connection, enableWs = true, url, apiKey, chainId, params) {
|
|
1883
|
+
static async init(connection, enableWs = true, url, apiKey, chainId, params, proxyUrl) {
|
|
1868
1884
|
const id = chainId || await connection.getChainId();
|
|
1869
|
-
const client = new _Client(connection, enableWs, url, apiKey, id, params);
|
|
1885
|
+
const client = new _Client(connection, enableWs, url, apiKey, id, params, proxyUrl);
|
|
1870
1886
|
if (enableWs) {
|
|
1871
1887
|
client.connectWebSocket();
|
|
1872
1888
|
}
|
|
1873
1889
|
return client;
|
|
1874
1890
|
}
|
|
1875
|
-
static async create(connection, enableWs = true, url, apiKey) {
|
|
1876
|
-
return _Client.init(connection, enableWs, url, apiKey);
|
|
1891
|
+
static async create(connection, enableWs = true, url, apiKey, proxyUrl) {
|
|
1892
|
+
return _Client.init(connection, enableWs, url, apiKey, void 0, void 0, proxyUrl);
|
|
1877
1893
|
}
|
|
1878
1894
|
async setApiKey(apiKey) {
|
|
1879
1895
|
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,7 @@ var Client = class _Client {
|
|
|
1445
1460
|
}
|
|
1446
1461
|
};
|
|
1447
1462
|
this.sendPostJson = async (message, endpoint) => {
|
|
1448
|
-
const URL = this._serverUrl + endpoint;
|
|
1463
|
+
const URL = endpoint.startsWith("/") ? endpoint : this._serverUrl + endpoint;
|
|
1449
1464
|
const headers = {
|
|
1450
1465
|
"Content-Type": "application/json"
|
|
1451
1466
|
};
|
|
@@ -1806,6 +1821,7 @@ var Client = class _Client {
|
|
|
1806
1821
|
this._apiKey = apiKey || generateApiKey();
|
|
1807
1822
|
this._subscriptions = /* @__PURE__ */ new Map();
|
|
1808
1823
|
this._serverUrl = url || "https://api.dev.neony.exchange";
|
|
1824
|
+
this._proxyUrl = proxyUrl;
|
|
1809
1825
|
this._sequenceNumberManager = new AccountSequenceNumber(this._aptos, this._apiKey);
|
|
1810
1826
|
this._maxGas = params?.maxGas || 2e4;
|
|
1811
1827
|
this._gasUnitPrice = params?.gasUnitPrice || 100;
|
|
@@ -1814,16 +1830,16 @@ var Client = class _Client {
|
|
|
1814
1830
|
this.connectWebSocket();
|
|
1815
1831
|
}
|
|
1816
1832
|
}
|
|
1817
|
-
static async init(connection, enableWs = true, url, apiKey, chainId, params) {
|
|
1833
|
+
static async init(connection, enableWs = true, url, apiKey, chainId, params, proxyUrl) {
|
|
1818
1834
|
const id = chainId || await connection.getChainId();
|
|
1819
|
-
const client = new _Client(connection, enableWs, url, apiKey, id, params);
|
|
1835
|
+
const client = new _Client(connection, enableWs, url, apiKey, id, params, proxyUrl);
|
|
1820
1836
|
if (enableWs) {
|
|
1821
1837
|
client.connectWebSocket();
|
|
1822
1838
|
}
|
|
1823
1839
|
return client;
|
|
1824
1840
|
}
|
|
1825
|
-
static async create(connection, enableWs = true, url, apiKey) {
|
|
1826
|
-
return _Client.init(connection, enableWs, url, apiKey);
|
|
1841
|
+
static async create(connection, enableWs = true, url, apiKey, proxyUrl) {
|
|
1842
|
+
return _Client.init(connection, enableWs, url, apiKey, void 0, void 0, proxyUrl);
|
|
1827
1843
|
}
|
|
1828
1844
|
async setApiKey(apiKey) {
|
|
1829
1845
|
this._apiKey = apiKey;
|