@steemit/steem-js 1.0.8 → 1.0.10
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 +3 -3
- package/dist/api/index.d.ts +67 -2
- package/dist/api/transports/http.d.ts +3 -3
- package/dist/api/transports/types.d.ts +1 -2
- package/dist/browser.esm.js +224 -70
- package/dist/browser.esm.js.map +1 -1
- package/dist/config.d.ts +0 -2
- package/dist/index.cjs +218 -63
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +218 -64
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +234 -79
- 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 +1 -0
- package/package.json +2 -2
- package/dist/api/transports/ws.d.ts +0 -19
- package/dist/crypto/browser-crypto.d.ts +0 -43
- package/dist/index.browser.js +0 -56378
- package/dist/index.browser.js.map +0 -1
- package/dist/polyfills/secure-random-browser.d.ts +0 -8
- package/dist/utils/buffer-global.d.ts +0 -7
- package/dist/utils/net-polyfill.d.ts +0 -17
- package/dist/utils/polyfill-test.d.ts +0 -19
- package/dist/utils/tls-polyfill.d.ts +0 -15
- package/dist/utils/util-polyfill.d.ts +0 -17
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();
|
|
@@ -294,7 +292,7 @@ function requireBn$1 () {
|
|
|
294
292
|
if (hasRequiredBn$1) return bn$1.exports;
|
|
295
293
|
hasRequiredBn$1 = 1;
|
|
296
294
|
(function (module) {
|
|
297
|
-
(function (module, exports
|
|
295
|
+
(function (module, exports) {
|
|
298
296
|
|
|
299
297
|
// Utils
|
|
300
298
|
function assert (val, msg) {
|
|
@@ -337,7 +335,7 @@ function requireBn$1 () {
|
|
|
337
335
|
if (typeof module === 'object') {
|
|
338
336
|
module.exports = BN;
|
|
339
337
|
} else {
|
|
340
|
-
exports
|
|
338
|
+
exports.BN = BN;
|
|
341
339
|
}
|
|
342
340
|
|
|
343
341
|
BN.BN = BN;
|
|
@@ -3769,9 +3767,9 @@ var hasRequiredUtils$2;
|
|
|
3769
3767
|
function requireUtils$2 () {
|
|
3770
3768
|
if (hasRequiredUtils$2) return utils$1;
|
|
3771
3769
|
hasRequiredUtils$2 = 1;
|
|
3772
|
-
(function (exports
|
|
3770
|
+
(function (exports) {
|
|
3773
3771
|
|
|
3774
|
-
var utils = exports
|
|
3772
|
+
var utils = exports;
|
|
3775
3773
|
|
|
3776
3774
|
function toArray(msg, enc) {
|
|
3777
3775
|
if (Array.isArray(msg))
|
|
@@ -3836,9 +3834,9 @@ var hasRequiredUtils$1;
|
|
|
3836
3834
|
function requireUtils$1 () {
|
|
3837
3835
|
if (hasRequiredUtils$1) return utils$2;
|
|
3838
3836
|
hasRequiredUtils$1 = 1;
|
|
3839
|
-
(function (exports
|
|
3837
|
+
(function (exports) {
|
|
3840
3838
|
|
|
3841
|
-
var utils = exports
|
|
3839
|
+
var utils = exports;
|
|
3842
3840
|
var BN = requireBn$1();
|
|
3843
3841
|
var minAssert = requireMinimalisticAssert();
|
|
3844
3842
|
var minUtils = requireUtils$2();
|
|
@@ -6062,9 +6060,9 @@ var hasRequiredCurve;
|
|
|
6062
6060
|
function requireCurve () {
|
|
6063
6061
|
if (hasRequiredCurve) return curve;
|
|
6064
6062
|
hasRequiredCurve = 1;
|
|
6065
|
-
(function (exports
|
|
6063
|
+
(function (exports) {
|
|
6066
6064
|
|
|
6067
|
-
var curve = exports
|
|
6065
|
+
var curve = exports;
|
|
6068
6066
|
|
|
6069
6067
|
curve.base = requireBase();
|
|
6070
6068
|
curve.short = requireShort();
|
|
@@ -7368,8 +7366,8 @@ var hasRequiredHash;
|
|
|
7368
7366
|
function requireHash () {
|
|
7369
7367
|
if (hasRequiredHash) return hash;
|
|
7370
7368
|
hasRequiredHash = 1;
|
|
7371
|
-
(function (exports
|
|
7372
|
-
var hash = exports
|
|
7369
|
+
(function (exports) {
|
|
7370
|
+
var hash = exports;
|
|
7373
7371
|
|
|
7374
7372
|
hash.utils = requireUtils();
|
|
7375
7373
|
hash.common = requireCommon$1();
|
|
@@ -8182,9 +8180,9 @@ var hasRequiredCurves;
|
|
|
8182
8180
|
function requireCurves () {
|
|
8183
8181
|
if (hasRequiredCurves) return curves;
|
|
8184
8182
|
hasRequiredCurves = 1;
|
|
8185
|
-
(function (exports
|
|
8183
|
+
(function (exports) {
|
|
8186
8184
|
|
|
8187
|
-
var curves = exports
|
|
8185
|
+
var curves = exports;
|
|
8188
8186
|
|
|
8189
8187
|
var hash = requireHash();
|
|
8190
8188
|
var curve = requireCurve();
|
|
@@ -9423,9 +9421,9 @@ var hasRequiredElliptic;
|
|
|
9423
9421
|
function requireElliptic () {
|
|
9424
9422
|
if (hasRequiredElliptic) return elliptic;
|
|
9425
9423
|
hasRequiredElliptic = 1;
|
|
9426
|
-
(function (exports
|
|
9424
|
+
(function (exports) {
|
|
9427
9425
|
|
|
9428
|
-
var elliptic = exports
|
|
9426
|
+
var elliptic = exports;
|
|
9429
9427
|
|
|
9430
9428
|
elliptic.version = require$$0$1.version;
|
|
9431
9429
|
elliptic.utils = requireUtils$1();
|
|
@@ -9452,7 +9450,7 @@ function requireBn () {
|
|
|
9452
9450
|
if (hasRequiredBn) return bn.exports;
|
|
9453
9451
|
hasRequiredBn = 1;
|
|
9454
9452
|
(function (module) {
|
|
9455
|
-
(function (module, exports
|
|
9453
|
+
(function (module, exports) {
|
|
9456
9454
|
|
|
9457
9455
|
// Utils
|
|
9458
9456
|
function assert (val, msg) {
|
|
@@ -9495,7 +9493,7 @@ function requireBn () {
|
|
|
9495
9493
|
if (typeof module === 'object') {
|
|
9496
9494
|
module.exports = BN;
|
|
9497
9495
|
} else {
|
|
9498
|
-
exports
|
|
9496
|
+
exports.BN = BN;
|
|
9499
9497
|
}
|
|
9500
9498
|
|
|
9501
9499
|
BN.BN = BN;
|
|
@@ -14427,24 +14425,24 @@ class Address {
|
|
|
14427
14425
|
* @returns Buffer with random bytes
|
|
14428
14426
|
*/
|
|
14429
14427
|
function randomBytes(size) {
|
|
14430
|
-
// Always try Web Crypto API first (works in both browser and Node.js
|
|
14428
|
+
// Always try Web Crypto API first (works in both browser and Node.js 20.19+)
|
|
14431
14429
|
if (typeof crypto !== 'undefined' && crypto.getRandomValues) {
|
|
14432
14430
|
const array = new Uint8Array(size);
|
|
14433
14431
|
crypto.getRandomValues(array);
|
|
14434
14432
|
return Buffer.from(array);
|
|
14435
14433
|
}
|
|
14436
14434
|
// Fallback to Node.js crypto only if Web Crypto API is not available
|
|
14437
|
-
// This code path should not be reached in Node.js
|
|
14435
|
+
// This code path should not be reached in Node.js 20.19+ (which has Web Crypto API)
|
|
14438
14436
|
// and is kept as a safety fallback for edge cases.
|
|
14439
14437
|
// In browser builds, Rollup will tree-shake this code away because
|
|
14440
14438
|
// the condition above will always be true in browsers.
|
|
14441
14439
|
//
|
|
14442
|
-
// Note: This SDK requires Node.js >=
|
|
14443
|
-
// Node.js
|
|
14444
|
-
// In ESM mode, require is undefined, but since Node.js
|
|
14440
|
+
// Note: This SDK requires Node.js >= 20.19.0 (see package.json engines field).
|
|
14441
|
+
// Node.js 20.19+ has Web Crypto API, so this fallback is rarely needed.
|
|
14442
|
+
// In ESM mode, require is undefined, but since Node.js 20.19+ has Web Crypto API,
|
|
14445
14443
|
// this code path won't be reached in ESM mode with the minimum required version.
|
|
14446
14444
|
try {
|
|
14447
|
-
// Use dynamic require as a safety fallback (for Node.js <
|
|
14445
|
+
// Use dynamic require as a safety fallback (for Node.js < 20.19 edge cases)
|
|
14448
14446
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
14449
14447
|
const nodeCrypto = typeof require !== 'undefined' ? require('crypto') : null;
|
|
14450
14448
|
if (nodeCrypto && typeof nodeCrypto.randomBytes === 'function') {
|
|
@@ -14455,7 +14453,7 @@ function randomBytes(size) {
|
|
|
14455
14453
|
// Ignore require errors in browser environments or ESM mode
|
|
14456
14454
|
}
|
|
14457
14455
|
// If neither Web Crypto API nor Node.js crypto is available, throw error
|
|
14458
|
-
throw new Error('Random bytes generation is not available. This library requires either Web Crypto API (browser/Node.js
|
|
14456
|
+
throw new Error('Random bytes generation is not available. This library requires either Web Crypto API (browser/Node.js 20.19+) or Node.js crypto module.');
|
|
14459
14457
|
}
|
|
14460
14458
|
|
|
14461
14459
|
/**
|
|
@@ -15408,11 +15406,11 @@ var hasRequiredRetry$1;
|
|
|
15408
15406
|
function requireRetry$1 () {
|
|
15409
15407
|
if (hasRequiredRetry$1) return retry$2;
|
|
15410
15408
|
hasRequiredRetry$1 = 1;
|
|
15411
|
-
(function (exports
|
|
15409
|
+
(function (exports) {
|
|
15412
15410
|
var RetryOperation = requireRetry_operation();
|
|
15413
15411
|
|
|
15414
|
-
exports
|
|
15415
|
-
var timeouts = exports
|
|
15412
|
+
exports.operation = function(options) {
|
|
15413
|
+
var timeouts = exports.timeouts(options);
|
|
15416
15414
|
return new RetryOperation(timeouts, {
|
|
15417
15415
|
forever: options && (options.forever || options.retries === Infinity),
|
|
15418
15416
|
unref: options && options.unref,
|
|
@@ -15420,7 +15418,7 @@ function requireRetry$1 () {
|
|
|
15420
15418
|
});
|
|
15421
15419
|
};
|
|
15422
15420
|
|
|
15423
|
-
exports
|
|
15421
|
+
exports.timeouts = function(options) {
|
|
15424
15422
|
if (options instanceof Array) {
|
|
15425
15423
|
return [].concat(options);
|
|
15426
15424
|
}
|
|
@@ -15457,7 +15455,7 @@ function requireRetry$1 () {
|
|
|
15457
15455
|
return timeouts;
|
|
15458
15456
|
};
|
|
15459
15457
|
|
|
15460
|
-
exports
|
|
15458
|
+
exports.createTimeout = function(attempt, opts) {
|
|
15461
15459
|
var random = (opts.randomize)
|
|
15462
15460
|
? (Math.random() + 1)
|
|
15463
15461
|
: 1;
|
|
@@ -15468,7 +15466,7 @@ function requireRetry$1 () {
|
|
|
15468
15466
|
return timeout;
|
|
15469
15467
|
};
|
|
15470
15468
|
|
|
15471
|
-
exports
|
|
15469
|
+
exports.wrap = function(obj, options, methods) {
|
|
15472
15470
|
if (options instanceof Array) {
|
|
15473
15471
|
methods = options;
|
|
15474
15472
|
options = null;
|
|
@@ -15488,7 +15486,7 @@ function requireRetry$1 () {
|
|
|
15488
15486
|
var original = obj[method];
|
|
15489
15487
|
|
|
15490
15488
|
obj[method] = function retryWrapper(original) {
|
|
15491
|
-
var op = exports
|
|
15489
|
+
var op = exports.operation(options);
|
|
15492
15490
|
var args = Array.prototype.slice.call(arguments, 1);
|
|
15493
15491
|
var callback = args.pop();
|
|
15494
15492
|
|
|
@@ -15581,15 +15579,15 @@ class JsonRpcError extends Error {
|
|
|
15581
15579
|
}
|
|
15582
15580
|
/**
|
|
15583
15581
|
* Makes a JSON-RPC request using native fetch API
|
|
15584
|
-
* Universal implementation that works in both Node.js (
|
|
15582
|
+
* Universal implementation that works in both Node.js (20.19+) 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',
|
|
@@ -15928,7 +15926,7 @@ function requireLong () {
|
|
|
15928
15926
|
if (value >= TWO_PWR_64_DBL)
|
|
15929
15927
|
return MAX_UNSIGNED_VALUE;
|
|
15930
15928
|
} else {
|
|
15931
|
-
if (value <= -
|
|
15929
|
+
if (value <= -9223372036854776e3)
|
|
15932
15930
|
return MIN_VALUE;
|
|
15933
15931
|
if (value + 1 >= TWO_PWR_63_DBL)
|
|
15934
15932
|
return MAX_VALUE;
|
|
@@ -20673,7 +20671,7 @@ function fromNumber(value, unsigned) {
|
|
|
20673
20671
|
if (value < 0) return UZERO;
|
|
20674
20672
|
if (value >= TWO_PWR_64_DBL) return MAX_UNSIGNED_VALUE;
|
|
20675
20673
|
} else {
|
|
20676
|
-
if (value <= -
|
|
20674
|
+
if (value <= -9223372036854776e3) return MIN_VALUE;
|
|
20677
20675
|
if (value + 1 >= TWO_PWR_63_DBL) return MAX_VALUE;
|
|
20678
20676
|
}
|
|
20679
20677
|
if (value < 0) return fromNumber(-value, unsigned).neg();
|
|
@@ -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,9 +22747,28 @@ 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
|
}
|
|
22753
|
+
/**
|
|
22754
|
+
* Promise-based version of call
|
|
22755
|
+
* Makes a JSON-RPC call to the Steem blockchain
|
|
22756
|
+
* @param method Method name (e.g., 'condenser_api.get_accounts')
|
|
22757
|
+
* @param params Parameters array for the method
|
|
22758
|
+
* @returns Promise that resolves with the result or rejects with an error
|
|
22759
|
+
*/
|
|
22760
|
+
callAsync(method, params) {
|
|
22761
|
+
return new Promise((resolve, reject) => {
|
|
22762
|
+
this.call(method, params, (err, result) => {
|
|
22763
|
+
if (err) {
|
|
22764
|
+
reject(err);
|
|
22765
|
+
}
|
|
22766
|
+
else {
|
|
22767
|
+
resolve(result);
|
|
22768
|
+
}
|
|
22769
|
+
});
|
|
22770
|
+
});
|
|
22771
|
+
}
|
|
22755
22772
|
signedCall(method, params, account, key, callback) {
|
|
22756
22773
|
if (this._transportType !== 'http') {
|
|
22757
22774
|
callback(new Error('RPC methods can only be called when using http transport'));
|
|
@@ -22767,9 +22784,30 @@ class Api extends events.EventEmitter {
|
|
|
22767
22784
|
return;
|
|
22768
22785
|
}
|
|
22769
22786
|
const fetchMethod = this.options.fetchMethod || fetch;
|
|
22770
|
-
jsonRpc(this.options.
|
|
22787
|
+
jsonRpc(this.options.url, request, fetchMethod)
|
|
22771
22788
|
.then(res => { callback(null, res); }, err => { callback(err); });
|
|
22772
22789
|
}
|
|
22790
|
+
/**
|
|
22791
|
+
* Promise-based version of signedCall
|
|
22792
|
+
* Makes an authenticated JSON-RPC call with cryptographic signature
|
|
22793
|
+
* @param method Method name (e.g., 'conveyor.is_email_registered')
|
|
22794
|
+
* @param params Parameters array for the method
|
|
22795
|
+
* @param account Account name to sign the request with
|
|
22796
|
+
* @param key Private key (WIF) to sign the request
|
|
22797
|
+
* @returns Promise that resolves with the result or rejects with an error
|
|
22798
|
+
*/
|
|
22799
|
+
signedCallAsync(method, params, account, key) {
|
|
22800
|
+
return new Promise((resolve, reject) => {
|
|
22801
|
+
this.signedCall(method, params, account, key, (err, result) => {
|
|
22802
|
+
if (err) {
|
|
22803
|
+
reject(err);
|
|
22804
|
+
}
|
|
22805
|
+
else {
|
|
22806
|
+
resolve(result);
|
|
22807
|
+
}
|
|
22808
|
+
});
|
|
22809
|
+
});
|
|
22810
|
+
}
|
|
22773
22811
|
/**
|
|
22774
22812
|
* Verify a signed RPC request
|
|
22775
22813
|
* @param signedRequest The signed request to verify
|
|
@@ -22832,6 +22870,24 @@ class Api extends events.EventEmitter {
|
|
|
22832
22870
|
.catch(error => callback(error instanceof Error ? error : new Error(String(error))));
|
|
22833
22871
|
}).catch(callback);
|
|
22834
22872
|
}
|
|
22873
|
+
/**
|
|
22874
|
+
* Promise-based version of verifySignedRequest
|
|
22875
|
+
* Verifies a signed RPC request
|
|
22876
|
+
* @param signedRequest The signed request to verify
|
|
22877
|
+
* @returns Promise that resolves with verification result or rejects with an error
|
|
22878
|
+
*/
|
|
22879
|
+
verifySignedRequestAsync(signedRequest) {
|
|
22880
|
+
return new Promise((resolve, reject) => {
|
|
22881
|
+
this.verifySignedRequest(signedRequest, (err, result) => {
|
|
22882
|
+
if (err) {
|
|
22883
|
+
reject(err);
|
|
22884
|
+
}
|
|
22885
|
+
else {
|
|
22886
|
+
resolve(result);
|
|
22887
|
+
}
|
|
22888
|
+
});
|
|
22889
|
+
});
|
|
22890
|
+
}
|
|
22835
22891
|
setOptions(options) {
|
|
22836
22892
|
Object.assign(this.options, options);
|
|
22837
22893
|
this._setLogger(options);
|
|
@@ -22844,9 +22900,9 @@ class Api extends events.EventEmitter {
|
|
|
22844
22900
|
getConfig().set('address_prefix', options.useTestNet ? 'TST' : 'STM');
|
|
22845
22901
|
}
|
|
22846
22902
|
}
|
|
22847
|
-
|
|
22903
|
+
setUrl(url) {
|
|
22848
22904
|
this.setOptions({
|
|
22849
|
-
|
|
22905
|
+
url: url
|
|
22850
22906
|
});
|
|
22851
22907
|
}
|
|
22852
22908
|
streamBlockNumber(mode = 'head', callback, ts = 200) {
|
|
@@ -23006,6 +23062,24 @@ class Api extends events.EventEmitter {
|
|
|
23006
23062
|
}
|
|
23007
23063
|
this.broadcastTransactionSynchronous(trx, callback);
|
|
23008
23064
|
}
|
|
23065
|
+
/**
|
|
23066
|
+
* Promise-based version of broadcastTransactionSynchronousWith
|
|
23067
|
+
* Broadcasts a transaction synchronously
|
|
23068
|
+
* @param options Options object containing the transaction
|
|
23069
|
+
* @returns Promise that resolves with the result or rejects with an error
|
|
23070
|
+
*/
|
|
23071
|
+
broadcastTransactionSynchronousWithAsync(options) {
|
|
23072
|
+
return new Promise((resolve, reject) => {
|
|
23073
|
+
this.broadcastTransactionSynchronousWith(options, (err, result) => {
|
|
23074
|
+
if (err) {
|
|
23075
|
+
reject(err);
|
|
23076
|
+
}
|
|
23077
|
+
else {
|
|
23078
|
+
resolve(result);
|
|
23079
|
+
}
|
|
23080
|
+
});
|
|
23081
|
+
});
|
|
23082
|
+
}
|
|
23009
23083
|
/**
|
|
23010
23084
|
* Broadcast a transaction to the blockchain.
|
|
23011
23085
|
* @param trx The transaction object
|
|
@@ -23025,6 +23099,24 @@ class Api extends events.EventEmitter {
|
|
|
23025
23099
|
callback(new Error('broadcastTransaction is not implemented'));
|
|
23026
23100
|
}
|
|
23027
23101
|
}
|
|
23102
|
+
/**
|
|
23103
|
+
* Promise-based version of broadcastTransaction
|
|
23104
|
+
* Broadcasts a transaction to the blockchain
|
|
23105
|
+
* @param trx The transaction object
|
|
23106
|
+
* @returns Promise that resolves with the result or rejects with an error
|
|
23107
|
+
*/
|
|
23108
|
+
broadcastTransactionAsync(trx) {
|
|
23109
|
+
return new Promise((resolve, reject) => {
|
|
23110
|
+
this.broadcastTransaction(trx, (err, result) => {
|
|
23111
|
+
if (err) {
|
|
23112
|
+
reject(err);
|
|
23113
|
+
}
|
|
23114
|
+
else {
|
|
23115
|
+
resolve(result);
|
|
23116
|
+
}
|
|
23117
|
+
});
|
|
23118
|
+
});
|
|
23119
|
+
}
|
|
23028
23120
|
/**
|
|
23029
23121
|
* Sign a transaction with the provided private key(s).
|
|
23030
23122
|
* @param trx The transaction object
|
|
@@ -23073,6 +23165,25 @@ class Api extends events.EventEmitter {
|
|
|
23073
23165
|
params: [confirmationCallback, trx]
|
|
23074
23166
|
}, callback);
|
|
23075
23167
|
}
|
|
23168
|
+
/**
|
|
23169
|
+
* Promise-based version of broadcastTransactionWithCallback
|
|
23170
|
+
* Note: The confirmationCallback will still be called when the transaction is confirmed
|
|
23171
|
+
* @param confirmationCallback Callback function for transaction confirmation
|
|
23172
|
+
* @param trx Transaction object to broadcast
|
|
23173
|
+
* @returns Promise that resolves with the result or rejects with an error
|
|
23174
|
+
*/
|
|
23175
|
+
broadcastTransactionWithCallbackAsync(confirmationCallback, trx) {
|
|
23176
|
+
return new Promise((resolve, reject) => {
|
|
23177
|
+
this.broadcastTransactionWithCallback(confirmationCallback, trx, (err, result) => {
|
|
23178
|
+
if (err) {
|
|
23179
|
+
reject(err);
|
|
23180
|
+
}
|
|
23181
|
+
else {
|
|
23182
|
+
resolve(result);
|
|
23183
|
+
}
|
|
23184
|
+
});
|
|
23185
|
+
});
|
|
23186
|
+
}
|
|
23076
23187
|
/**
|
|
23077
23188
|
* Broadcast a block to the network.
|
|
23078
23189
|
* @param block Block object to broadcast
|
|
@@ -23088,6 +23199,24 @@ class Api extends events.EventEmitter {
|
|
|
23088
23199
|
params: [block]
|
|
23089
23200
|
}, callback);
|
|
23090
23201
|
}
|
|
23202
|
+
/**
|
|
23203
|
+
* Promise-based version of broadcastBlock
|
|
23204
|
+
* Broadcasts a block to the network
|
|
23205
|
+
* @param block Block object to broadcast
|
|
23206
|
+
* @returns Promise that resolves with the result or rejects with an error
|
|
23207
|
+
*/
|
|
23208
|
+
broadcastBlockAsync(block) {
|
|
23209
|
+
return new Promise((resolve, reject) => {
|
|
23210
|
+
this.broadcastBlock(block, (err, result) => {
|
|
23211
|
+
if (err) {
|
|
23212
|
+
reject(err);
|
|
23213
|
+
}
|
|
23214
|
+
else {
|
|
23215
|
+
resolve(result);
|
|
23216
|
+
}
|
|
23217
|
+
});
|
|
23218
|
+
});
|
|
23219
|
+
}
|
|
23091
23220
|
/**
|
|
23092
23221
|
* Set the maximum block age for transaction acceptance.
|
|
23093
23222
|
* @param maxBlockAge Maximum block age in seconds
|
|
@@ -23103,6 +23232,24 @@ class Api extends events.EventEmitter {
|
|
|
23103
23232
|
params: [maxBlockAge]
|
|
23104
23233
|
}, callback);
|
|
23105
23234
|
}
|
|
23235
|
+
/**
|
|
23236
|
+
* Promise-based version of setMaxBlockAge
|
|
23237
|
+
* Sets the maximum block age for transaction acceptance
|
|
23238
|
+
* @param maxBlockAge Maximum block age in seconds
|
|
23239
|
+
* @returns Promise that resolves with the result or rejects with an error
|
|
23240
|
+
*/
|
|
23241
|
+
setMaxBlockAgeAsync(maxBlockAge) {
|
|
23242
|
+
return new Promise((resolve, reject) => {
|
|
23243
|
+
this.setMaxBlockAge(maxBlockAge, (err, result) => {
|
|
23244
|
+
if (err) {
|
|
23245
|
+
reject(err);
|
|
23246
|
+
}
|
|
23247
|
+
else {
|
|
23248
|
+
resolve(result);
|
|
23249
|
+
}
|
|
23250
|
+
});
|
|
23251
|
+
});
|
|
23252
|
+
}
|
|
23106
23253
|
/**
|
|
23107
23254
|
* Verify transaction authority.
|
|
23108
23255
|
* @param trx Transaction object to verify
|
|
@@ -23176,15 +23323,17 @@ class Api extends events.EventEmitter {
|
|
|
23176
23323
|
}
|
|
23177
23324
|
}
|
|
23178
23325
|
// Export singleton instance for compatibility
|
|
23179
|
-
|
|
23326
|
+
// Use first node from config.nodes array
|
|
23327
|
+
const nodes = getConfig().get('nodes') || ['https://api.steemit.com'];
|
|
23328
|
+
const api = new Api({ url: nodes[0] || 'https://api.steemit.com' });
|
|
23180
23329
|
function setOptions(options) {
|
|
23181
|
-
api
|
|
23330
|
+
api.setOptions(options);
|
|
23182
23331
|
}
|
|
23183
23332
|
// Export async variants and listeners for compatibility with tests
|
|
23184
|
-
api
|
|
23185
|
-
api
|
|
23186
|
-
api
|
|
23187
|
-
api
|
|
23333
|
+
api.getDynamicGlobalPropertiesAsync;
|
|
23334
|
+
api.getBlockAsync;
|
|
23335
|
+
api.getFollowersAsync;
|
|
23336
|
+
api.getContentAsync;
|
|
23188
23337
|
|
|
23189
23338
|
const operations$1 = [
|
|
23190
23339
|
{
|
|
@@ -25593,8 +25742,8 @@ const verify = (message, signature, publicKey) => {
|
|
|
25593
25742
|
}
|
|
25594
25743
|
};
|
|
25595
25744
|
|
|
25596
|
-
//
|
|
25597
|
-
|
|
25745
|
+
// Use the singleton API instance exported from api module
|
|
25746
|
+
// This ensures steem.api and setOptions() operate on the same instance
|
|
25598
25747
|
// Create the main steem object with all modules
|
|
25599
25748
|
const steem = {
|
|
25600
25749
|
api,
|
|
@@ -25605,10 +25754,15 @@ const steem = {
|
|
|
25605
25754
|
operations,
|
|
25606
25755
|
serializer,
|
|
25607
25756
|
utils: utils$3,
|
|
25608
|
-
version: '1.0.
|
|
25757
|
+
version: '1.0.10',
|
|
25609
25758
|
config: {
|
|
25610
25759
|
set: (options) => {
|
|
25611
|
-
|
|
25760
|
+
// If nodes is provided, extract the first node as url for API
|
|
25761
|
+
const apiOptions = { ...options };
|
|
25762
|
+
if (options.nodes && Array.isArray(options.nodes) && options.nodes.length > 0) {
|
|
25763
|
+
apiOptions.url = options.nodes[0];
|
|
25764
|
+
}
|
|
25765
|
+
setOptions(apiOptions);
|
|
25612
25766
|
setOptions$1(options);
|
|
25613
25767
|
},
|
|
25614
25768
|
get: (key) => getConfig().get(key),
|
|
@@ -25640,6 +25794,7 @@ if (typeof window !== 'undefined' || typeof globalThis !== 'undefined') {
|
|
|
25640
25794
|
}
|
|
25641
25795
|
}
|
|
25642
25796
|
|
|
25797
|
+
exports.Api = Api;
|
|
25643
25798
|
exports.doubleSha256 = doubleSha256;
|
|
25644
25799
|
exports.generateKeyPair = generateKeyPair;
|
|
25645
25800
|
exports.hmacSha256 = hmacSha256;
|