@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/dist/index.umd.js CHANGED
@@ -2,18 +2,18 @@
2
2
  // Provide minimal polyfills for browser
3
3
  var g = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
4
4
 
5
- // Process polyfill
5
+ // Process polyfill
6
6
  if (typeof g.process === 'undefined') {
7
7
  g.process = {
8
- browser: true,
9
- env: {},
10
- version: '',
11
- versions: {},
12
- nextTick: function(fn) { setTimeout(fn, 0); },
13
- exit: function() {},
14
- cwd: function() { return '/'; },
15
- platform: 'browser'
16
- };
8
+ browser: true,
9
+ env: {},
10
+ version: '',
11
+ versions: {},
12
+ nextTick: function(fn) { setTimeout(fn, 0); },
13
+ exit: function() {},
14
+ cwd: function() { return '/'; },
15
+ platform: 'browser'
16
+ };
17
17
  if (typeof globalThis !== 'undefined') {
18
18
  globalThis.process = g.process;
19
19
  }
@@ -564,12 +564,10 @@
564
564
  const DEFAULT_CONFIG = {
565
565
  address_prefix: 'STM',
566
566
  chain_id: '0000000000000000000000000000000000000000000000000000000000000000',
567
- // Default API endpoint: api.steemit.com
568
- node: 'https://api.steemit.com',
567
+ // Default API endpoints: api.steemit.com
569
568
  nodes: [
570
569
  'https://api.steemit.com'
571
- ],
572
- uri: 'https://api.steemit.com'
570
+ ]
573
571
  };
574
572
  // Singleton config instance
575
573
  const config = new Config();
@@ -18294,13 +18292,13 @@
18294
18292
  * Makes a JSON-RPC request using native fetch API
18295
18293
  * Universal implementation that works in both Node.js (18+) and browser
18296
18294
  *
18297
- * @param uri - The URI to the JSON-RPC endpoint
18295
+ * @param url - The URL to the JSON-RPC endpoint
18298
18296
  * @param request - The JSON-RPC request object
18299
18297
  * @param fetchMethod - Optional fetch implementation (defaults to global fetch)
18300
18298
  * @param timeoutMs - Request timeout in milliseconds (default: 30000)
18301
18299
  * @returns Promise resolving to the JSON-RPC result
18302
18300
  */
18303
- const jsonRpc = async (uri, request, fetchMethod = fetch, timeoutMs = 30000) => {
18301
+ const jsonRpc = async (url, request, fetchMethod = fetch, timeoutMs = 30000) => {
18304
18302
  const payload = {
18305
18303
  jsonrpc: '2.0',
18306
18304
  ...request
@@ -18313,7 +18311,7 @@
18313
18311
  }, timeoutMs);
18314
18312
  });
18315
18313
  // Create the fetch promise
18316
- const fetchPromise = fetchMethod(uri, {
18314
+ const fetchPromise = fetchMethod(url, {
18317
18315
  method: 'POST',
18318
18316
  headers: {
18319
18317
  'Content-Type': 'application/json',
@@ -18362,9 +18360,9 @@
18362
18360
  if (typeof callback !== 'function') {
18363
18361
  callback = () => { };
18364
18362
  }
18365
- const uri = this.options.uri;
18366
- if (!uri) {
18367
- throw new Error('HTTP transport requires a valid URI');
18363
+ const url = this.options.url;
18364
+ if (!url) {
18365
+ throw new Error('HTTP transport requires a valid URL');
18368
18366
  }
18369
18367
  const fetchMethod = this.options.fetchMethod || fetch;
18370
18368
  const id = data.id;
@@ -18375,7 +18373,7 @@
18375
18373
  if (!isBroadcast && retryOptions) {
18376
18374
  const operation = typeof retryOptions === 'object' ? retry$1.operation(retryOptions) : retry$1.operation();
18377
18375
  operation.attempt((currentAttempt) => {
18378
- fetchMethod(uri, {
18376
+ fetchMethod(url, {
18379
18377
  method: 'POST',
18380
18378
  body: JSON.stringify({
18381
18379
  jsonrpc: '2.0',
@@ -18409,7 +18407,7 @@
18409
18407
  });
18410
18408
  }
18411
18409
  else {
18412
- fetchMethod(uri, {
18410
+ fetchMethod(url, {
18413
18411
  method: 'POST',
18414
18412
  body: JSON.stringify({
18415
18413
  jsonrpc: '2.0',
@@ -25633,7 +25631,6 @@
25633
25631
  _setTransport(options) {
25634
25632
  // Use HTTP transport only
25635
25633
  if (options.url && options.url.match(/^((http|https)?:\/\/)/)) {
25636
- options.uri = options.url;
25637
25634
  options.transport = 'http';
25638
25635
  this._transportType = options.transport;
25639
25636
  this.options = options;
@@ -25659,9 +25656,10 @@
25659
25656
  }
25660
25657
  }
25661
25658
  else {
25662
- // Default to HTTP for https://api.steemit.com
25663
- const defaultNode = getConfig().get('node') || 'https://api.steemit.com';
25664
- options.uri = defaultNode;
25659
+ // Default to HTTP using first node from config.nodes
25660
+ const nodes = getConfig().get('nodes') || ['https://api.steemit.com'];
25661
+ const defaultNode = nodes[0] || 'https://api.steemit.com';
25662
+ options.url = defaultNode;
25665
25663
  options.transport = 'http';
25666
25664
  this._transportType = options.transport;
25667
25665
  this.options = options;
@@ -25744,7 +25742,7 @@
25744
25742
  }
25745
25743
  const id = ++this.seqNo;
25746
25744
  const fetchMethod = this.options.fetchMethod || fetch;
25747
- jsonRpc(this.options.uri, { method, params, id }, fetchMethod)
25745
+ jsonRpc(this.options.url, { method, params, id }, fetchMethod)
25748
25746
  .then(res => { callback(null, res); }, err => { callback(err); });
25749
25747
  }
25750
25748
  signedCall(method, params, account, key, callback) {
@@ -25762,7 +25760,7 @@
25762
25760
  return;
25763
25761
  }
25764
25762
  const fetchMethod = this.options.fetchMethod || fetch;
25765
- jsonRpc(this.options.uri, request, fetchMethod)
25763
+ jsonRpc(this.options.url, request, fetchMethod)
25766
25764
  .then(res => { callback(null, res); }, err => { callback(err); });
25767
25765
  }
25768
25766
  /**
@@ -25839,9 +25837,9 @@
25839
25837
  getConfig().set('address_prefix', options.useTestNet ? 'TST' : 'STM');
25840
25838
  }
25841
25839
  }
25842
- setUri(url) {
25840
+ setUrl(url) {
25843
25841
  this.setOptions({
25844
- uri: url
25842
+ url: url
25845
25843
  });
25846
25844
  }
25847
25845
  streamBlockNumber(mode = 'head', callback, ts = 200) {
@@ -26171,15 +26169,17 @@
26171
26169
  }
26172
26170
  }
26173
26171
  // Export singleton instance for compatibility
26174
- const api$1 = new Api({ uri: getConfig().get('uri') || 'https://api.steemit.com' });
26172
+ // Use first node from config.nodes array
26173
+ const nodes = getConfig().get('nodes') || ['https://api.steemit.com'];
26174
+ const api = new Api({ url: nodes[0] || 'https://api.steemit.com' });
26175
26175
  function setOptions(options) {
26176
- api$1.setOptions(options);
26176
+ api.setOptions(options);
26177
26177
  }
26178
26178
  // Export async variants and listeners for compatibility with tests
26179
- api$1.getDynamicGlobalPropertiesAsync;
26180
- api$1.getBlockAsync;
26181
- api$1.getFollowersAsync;
26182
- api$1.getContentAsync;
26179
+ api.getDynamicGlobalPropertiesAsync;
26180
+ api.getBlockAsync;
26181
+ api.getFollowersAsync;
26182
+ api.getContentAsync;
26183
26183
 
26184
26184
  const operations$1 = [
26185
26185
  {
@@ -28598,11 +28598,12 @@
28598
28598
  verify: verify
28599
28599
  });
28600
28600
 
28601
- // Create the API instance
28602
- const api = new Api();
28601
+ // Use the singleton API instance exported from api module
28602
+ // This ensures steem.api and setOptions() operate on the same instance
28603
28603
  // Create the main steem object with all modules - this will be the default export for UMD
28604
28604
  const steem = {
28605
28605
  api,
28606
+ Api, // Export Api class for creating multiple instances
28606
28607
  auth,
28607
28608
  broadcast: broadcast$1,
28608
28609
  formatter,
@@ -28611,9 +28612,15 @@
28611
28612
  serializer,
28612
28613
  utils: utils$n,
28613
28614
  ...crypto$1,
28615
+ version: '1.0.9',
28614
28616
  config: {
28615
28617
  set: (options) => {
28616
- setOptions(options);
28618
+ // If nodes is provided, extract the first node as url for API
28619
+ const apiOptions = { ...options };
28620
+ if (options.nodes && Array.isArray(options.nodes) && options.nodes.length > 0) {
28621
+ apiOptions.url = options.nodes[0];
28622
+ }
28623
+ setOptions(apiOptions);
28617
28624
  setOptions$1(options);
28618
28625
  },
28619
28626
  get: (key) => getConfig().get(key),