@steemit/steem-js 1.0.7 → 1.0.9
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/README.md +2 -2
- package/dist/api/index.d.ts +1 -2
- package/dist/api/transports/http.d.ts +2 -2
- package/dist/api/transports/types.d.ts +1 -2
- package/dist/browser.esm.js +36 -30
- package/dist/browser.esm.js.map +1 -1
- package/dist/config.d.ts +0 -2
- package/dist/index.cjs +36 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +36 -30
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +46 -39
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/dist/types.d.ts +1 -3
- package/dist/umd.d.ts +2 -0
- package/package.json +1 -1
package/dist/config.d.ts
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -51,12 +51,10 @@ class Config {
|
|
|
51
51
|
const DEFAULT_CONFIG = {
|
|
52
52
|
address_prefix: 'STM',
|
|
53
53
|
chain_id: '0000000000000000000000000000000000000000000000000000000000000000',
|
|
54
|
-
// Default API
|
|
55
|
-
node: 'https://api.steemit.com',
|
|
54
|
+
// Default API endpoints: api.steemit.com
|
|
56
55
|
nodes: [
|
|
57
56
|
'https://api.steemit.com'
|
|
58
|
-
]
|
|
59
|
-
uri: 'https://api.steemit.com'
|
|
57
|
+
]
|
|
60
58
|
};
|
|
61
59
|
// Singleton config instance
|
|
62
60
|
const config = new Config();
|
|
@@ -15583,13 +15581,13 @@ class JsonRpcError extends Error {
|
|
|
15583
15581
|
* Makes a JSON-RPC request using native fetch API
|
|
15584
15582
|
* Universal implementation that works in both Node.js (18+) and browser
|
|
15585
15583
|
*
|
|
15586
|
-
* @param
|
|
15584
|
+
* @param url - The URL to the JSON-RPC endpoint
|
|
15587
15585
|
* @param request - The JSON-RPC request object
|
|
15588
15586
|
* @param fetchMethod - Optional fetch implementation (defaults to global fetch)
|
|
15589
15587
|
* @param timeoutMs - Request timeout in milliseconds (default: 30000)
|
|
15590
15588
|
* @returns Promise resolving to the JSON-RPC result
|
|
15591
15589
|
*/
|
|
15592
|
-
const jsonRpc = async (
|
|
15590
|
+
const jsonRpc = async (url, request, fetchMethod = fetch, timeoutMs = 30000) => {
|
|
15593
15591
|
const payload = {
|
|
15594
15592
|
jsonrpc: '2.0',
|
|
15595
15593
|
...request
|
|
@@ -15602,7 +15600,7 @@ const jsonRpc = async (uri, request, fetchMethod = fetch, timeoutMs = 30000) =>
|
|
|
15602
15600
|
}, timeoutMs);
|
|
15603
15601
|
});
|
|
15604
15602
|
// Create the fetch promise
|
|
15605
|
-
const fetchPromise = fetchMethod(
|
|
15603
|
+
const fetchPromise = fetchMethod(url, {
|
|
15606
15604
|
method: 'POST',
|
|
15607
15605
|
headers: {
|
|
15608
15606
|
'Content-Type': 'application/json',
|
|
@@ -15651,9 +15649,9 @@ class HttpTransport extends BaseTransport {
|
|
|
15651
15649
|
if (typeof callback !== 'function') {
|
|
15652
15650
|
callback = () => { };
|
|
15653
15651
|
}
|
|
15654
|
-
const
|
|
15655
|
-
if (!
|
|
15656
|
-
throw new Error('HTTP transport requires a valid
|
|
15652
|
+
const url = this.options.url;
|
|
15653
|
+
if (!url) {
|
|
15654
|
+
throw new Error('HTTP transport requires a valid URL');
|
|
15657
15655
|
}
|
|
15658
15656
|
const fetchMethod = this.options.fetchMethod || fetch;
|
|
15659
15657
|
const id = data.id;
|
|
@@ -15664,7 +15662,7 @@ class HttpTransport extends BaseTransport {
|
|
|
15664
15662
|
if (!isBroadcast && retryOptions) {
|
|
15665
15663
|
const operation = typeof retryOptions === 'object' ? retry.operation(retryOptions) : retry.operation();
|
|
15666
15664
|
operation.attempt((currentAttempt) => {
|
|
15667
|
-
fetchMethod(
|
|
15665
|
+
fetchMethod(url, {
|
|
15668
15666
|
method: 'POST',
|
|
15669
15667
|
body: JSON.stringify({
|
|
15670
15668
|
jsonrpc: '2.0',
|
|
@@ -15698,7 +15696,7 @@ class HttpTransport extends BaseTransport {
|
|
|
15698
15696
|
});
|
|
15699
15697
|
}
|
|
15700
15698
|
else {
|
|
15701
|
-
fetchMethod(
|
|
15699
|
+
fetchMethod(url, {
|
|
15702
15700
|
method: 'POST',
|
|
15703
15701
|
body: JSON.stringify({
|
|
15704
15702
|
jsonrpc: '2.0',
|
|
@@ -22638,7 +22636,6 @@ class Api extends events.EventEmitter {
|
|
|
22638
22636
|
_setTransport(options) {
|
|
22639
22637
|
// Use HTTP transport only
|
|
22640
22638
|
if (options.url && options.url.match(/^((http|https)?:\/\/)/)) {
|
|
22641
|
-
options.uri = options.url;
|
|
22642
22639
|
options.transport = 'http';
|
|
22643
22640
|
this._transportType = options.transport;
|
|
22644
22641
|
this.options = options;
|
|
@@ -22664,9 +22661,10 @@ class Api extends events.EventEmitter {
|
|
|
22664
22661
|
}
|
|
22665
22662
|
}
|
|
22666
22663
|
else {
|
|
22667
|
-
// Default to HTTP
|
|
22668
|
-
const
|
|
22669
|
-
|
|
22664
|
+
// Default to HTTP using first node from config.nodes
|
|
22665
|
+
const nodes = getConfig().get('nodes') || ['https://api.steemit.com'];
|
|
22666
|
+
const defaultNode = nodes[0] || 'https://api.steemit.com';
|
|
22667
|
+
options.url = defaultNode;
|
|
22670
22668
|
options.transport = 'http';
|
|
22671
22669
|
this._transportType = options.transport;
|
|
22672
22670
|
this.options = options;
|
|
@@ -22749,7 +22747,7 @@ class Api extends events.EventEmitter {
|
|
|
22749
22747
|
}
|
|
22750
22748
|
const id = ++this.seqNo;
|
|
22751
22749
|
const fetchMethod = this.options.fetchMethod || fetch;
|
|
22752
|
-
jsonRpc(this.options.
|
|
22750
|
+
jsonRpc(this.options.url, { method, params, id }, fetchMethod)
|
|
22753
22751
|
.then(res => { callback(null, res); }, err => { callback(err); });
|
|
22754
22752
|
}
|
|
22755
22753
|
signedCall(method, params, account, key, callback) {
|
|
@@ -22767,7 +22765,7 @@ class Api extends events.EventEmitter {
|
|
|
22767
22765
|
return;
|
|
22768
22766
|
}
|
|
22769
22767
|
const fetchMethod = this.options.fetchMethod || fetch;
|
|
22770
|
-
jsonRpc(this.options.
|
|
22768
|
+
jsonRpc(this.options.url, request, fetchMethod)
|
|
22771
22769
|
.then(res => { callback(null, res); }, err => { callback(err); });
|
|
22772
22770
|
}
|
|
22773
22771
|
/**
|
|
@@ -22844,9 +22842,9 @@ class Api extends events.EventEmitter {
|
|
|
22844
22842
|
getConfig().set('address_prefix', options.useTestNet ? 'TST' : 'STM');
|
|
22845
22843
|
}
|
|
22846
22844
|
}
|
|
22847
|
-
|
|
22845
|
+
setUrl(url) {
|
|
22848
22846
|
this.setOptions({
|
|
22849
|
-
|
|
22847
|
+
url: url
|
|
22850
22848
|
});
|
|
22851
22849
|
}
|
|
22852
22850
|
streamBlockNumber(mode = 'head', callback, ts = 200) {
|
|
@@ -23176,15 +23174,17 @@ class Api extends events.EventEmitter {
|
|
|
23176
23174
|
}
|
|
23177
23175
|
}
|
|
23178
23176
|
// Export singleton instance for compatibility
|
|
23179
|
-
|
|
23177
|
+
// Use first node from config.nodes array
|
|
23178
|
+
const nodes = getConfig().get('nodes') || ['https://api.steemit.com'];
|
|
23179
|
+
const api = new Api({ url: nodes[0] || 'https://api.steemit.com' });
|
|
23180
23180
|
function setOptions(options) {
|
|
23181
|
-
api
|
|
23181
|
+
api.setOptions(options);
|
|
23182
23182
|
}
|
|
23183
23183
|
// Export async variants and listeners for compatibility with tests
|
|
23184
|
-
api
|
|
23185
|
-
api
|
|
23186
|
-
api
|
|
23187
|
-
api
|
|
23184
|
+
api.getDynamicGlobalPropertiesAsync;
|
|
23185
|
+
api.getBlockAsync;
|
|
23186
|
+
api.getFollowersAsync;
|
|
23187
|
+
api.getContentAsync;
|
|
23188
23188
|
|
|
23189
23189
|
const operations$1 = [
|
|
23190
23190
|
{
|
|
@@ -25593,8 +25593,8 @@ const verify = (message, signature, publicKey) => {
|
|
|
25593
25593
|
}
|
|
25594
25594
|
};
|
|
25595
25595
|
|
|
25596
|
-
//
|
|
25597
|
-
|
|
25596
|
+
// Use the singleton API instance exported from api module
|
|
25597
|
+
// This ensures steem.api and setOptions() operate on the same instance
|
|
25598
25598
|
// Create the main steem object with all modules
|
|
25599
25599
|
const steem = {
|
|
25600
25600
|
api,
|
|
@@ -25605,9 +25605,15 @@ const steem = {
|
|
|
25605
25605
|
operations,
|
|
25606
25606
|
serializer,
|
|
25607
25607
|
utils: utils$3,
|
|
25608
|
+
version: '1.0.9',
|
|
25608
25609
|
config: {
|
|
25609
25610
|
set: (options) => {
|
|
25610
|
-
|
|
25611
|
+
// If nodes is provided, extract the first node as url for API
|
|
25612
|
+
const apiOptions = { ...options };
|
|
25613
|
+
if (options.nodes && Array.isArray(options.nodes) && options.nodes.length > 0) {
|
|
25614
|
+
apiOptions.url = options.nodes[0];
|
|
25615
|
+
}
|
|
25616
|
+
setOptions(apiOptions);
|
|
25611
25617
|
setOptions$1(options);
|
|
25612
25618
|
},
|
|
25613
25619
|
get: (key) => getConfig().get(key),
|
|
@@ -25639,6 +25645,7 @@ if (typeof window !== 'undefined' || typeof globalThis !== 'undefined') {
|
|
|
25639
25645
|
}
|
|
25640
25646
|
}
|
|
25641
25647
|
|
|
25648
|
+
exports.Api = Api;
|
|
25642
25649
|
exports.doubleSha256 = doubleSha256;
|
|
25643
25650
|
exports.generateKeyPair = generateKeyPair;
|
|
25644
25651
|
exports.hmacSha256 = hmacSha256;
|