@pioneer-platform/ton-network 8.11.2 → 8.11.3
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/.turbo/turbo-build.log +2 -1
- package/CHANGELOG.md +6 -0
- package/lib/index.js +22 -5
- package/package.json +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
[0m[2m[35m$[0m [2m[1mtsc -p .[0m
|
package/CHANGELOG.md
CHANGED
package/lib/index.js
CHANGED
|
@@ -67,8 +67,11 @@ var axiosLib = require('axios');
|
|
|
67
67
|
var Axios = axiosLib.default || axiosLib;
|
|
68
68
|
var https = require('https');
|
|
69
69
|
var log = require('@pioneer-platform/loggerdog')();
|
|
70
|
-
// Default TON mainnet API (
|
|
71
|
-
var
|
|
70
|
+
// Default TON mainnet API (NOWNodes with API key from env)
|
|
71
|
+
var NOWNODES_API_KEY = process.env.NOWNODES_API_KEY;
|
|
72
|
+
var DEFAULT_API_URL = NOWNODES_API_KEY
|
|
73
|
+
? "https://ton.nownodes.io"
|
|
74
|
+
: "https://toncenter.com/api/v2";
|
|
72
75
|
// Network constants
|
|
73
76
|
exports.NETWORK_ID = 'ton:-239';
|
|
74
77
|
exports.CHAIN_SYMBOL = 'TON';
|
|
@@ -106,13 +109,21 @@ module.exports = {
|
|
|
106
109
|
case 1:
|
|
107
110
|
_a.trys.push([1, 3, , 4]);
|
|
108
111
|
apiUrl = url || process.env['TON_API_URL'] || DEFAULT_API_URL;
|
|
109
|
-
apiKey = (settings === null || settings === void 0 ? void 0 : settings.apiKey) || process.env['TONCENTER_API_KEY'] || null;
|
|
112
|
+
apiKey = (settings === null || settings === void 0 ? void 0 : settings.apiKey) || process.env['NOWNODES_API_KEY'] || process.env['TONCENTER_API_KEY'] || null;
|
|
110
113
|
log.info(tag, "Initializing TON network...");
|
|
111
114
|
log.info(tag, "API Endpoint:", apiUrl);
|
|
112
115
|
log.info(tag, "API Key configured:", apiKey ? "Yes" : "No (rate limited)");
|
|
116
|
+
log.info(tag, "NOWNODES_API_KEY from env:", process.env['NOWNODES_API_KEY'] ? "SET" : "NOT SET");
|
|
117
|
+
log.info(tag, "DEFAULT_API_URL value:", DEFAULT_API_URL);
|
|
113
118
|
headers = { 'Content-Type': 'application/json' };
|
|
114
119
|
if (apiKey) {
|
|
115
|
-
|
|
120
|
+
// NOWNodes uses 'api-key' header, TonCenter uses 'X-API-Key'
|
|
121
|
+
if (apiUrl.includes('nownodes.io')) {
|
|
122
|
+
headers['api-key'] = apiKey;
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
headers['X-API-Key'] = apiKey;
|
|
126
|
+
}
|
|
116
127
|
}
|
|
117
128
|
return [4 /*yield*/, axios({
|
|
118
129
|
url: "".concat(apiUrl, "/getMasterchainInfo"),
|
|
@@ -218,7 +229,13 @@ module.exports = {
|
|
|
218
229
|
function getHeaders() {
|
|
219
230
|
var headers = { 'Content-Type': 'application/json' };
|
|
220
231
|
if (apiKey) {
|
|
221
|
-
|
|
232
|
+
// NOWNodes uses 'api-key' header, TonCenter uses 'X-API-Key'
|
|
233
|
+
if (apiUrl.includes('nownodes.io')) {
|
|
234
|
+
headers['api-key'] = apiKey;
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
headers['X-API-Key'] = apiKey;
|
|
238
|
+
}
|
|
222
239
|
}
|
|
223
240
|
return headers;
|
|
224
241
|
}
|