@steemit/steem-js 1.0.9 → 1.0.11
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 +1 -1
- package/dist/api/index.d.ts +72 -0
- package/dist/api/transports/http.d.ts +1 -1
- package/dist/api/types.d.ts +78 -0
- package/dist/browser.esm.js +279 -47
- package/dist/browser.esm.js.map +1 -1
- package/dist/index.cjs +274 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +273 -41
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +278 -46
- 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/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/README.md
CHANGED
|
@@ -17,7 +17,7 @@ A modern JavaScript/TypeScript library for interacting with the Steem blockchain
|
|
|
17
17
|
|
|
18
18
|
### Requirements
|
|
19
19
|
|
|
20
|
-
- **Node.js**: >=
|
|
20
|
+
- **Node.js**: >= 20.19.0 (LTS recommended)
|
|
21
21
|
- **Browser**: Modern browsers with Web Crypto API support
|
|
22
22
|
|
|
23
23
|
### Installation
|
package/dist/api/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
2
|
import type { Transport } from './transports/types';
|
|
3
3
|
import type { TransportOptions } from './transports/types';
|
|
4
|
+
import type { ApiMethodSignatures } from './types';
|
|
4
5
|
interface ApiOptions {
|
|
5
6
|
url?: string;
|
|
6
7
|
transport?: string | (new (options: TransportOptions) => Transport);
|
|
@@ -20,6 +21,11 @@ export declare class Api extends EventEmitter {
|
|
|
20
21
|
private transport;
|
|
21
22
|
private options;
|
|
22
23
|
private __logger;
|
|
24
|
+
[key: string]: unknown;
|
|
25
|
+
getAccounts: ApiMethodSignatures['getAccounts'];
|
|
26
|
+
getAccountsAsync: ApiMethodSignatures['getAccountsAsync'];
|
|
27
|
+
getAccountsWith: ApiMethodSignatures['getAccountsWith'];
|
|
28
|
+
getAccountsWithAsync: ApiMethodSignatures['getAccountsWithAsync'];
|
|
23
29
|
private static _wrapWithPromise;
|
|
24
30
|
constructor(options?: ApiOptions);
|
|
25
31
|
private _setTransport;
|
|
@@ -29,13 +35,41 @@ export declare class Api extends EventEmitter {
|
|
|
29
35
|
stop(): Promise<void>;
|
|
30
36
|
send(api: string, data: unknown, callback: unknown): void | Promise<void>;
|
|
31
37
|
call(method: string, params: unknown[], callback: (err: Error | null, result?: unknown) => void): void;
|
|
38
|
+
/**
|
|
39
|
+
* Promise-based version of call
|
|
40
|
+
* Makes a JSON-RPC call to the Steem blockchain
|
|
41
|
+
* @param method Method name (e.g., 'condenser_api.get_accounts')
|
|
42
|
+
* @param params Parameters array for the method
|
|
43
|
+
* @returns Promise that resolves with the result or rejects with an error
|
|
44
|
+
*/
|
|
45
|
+
callAsync(method: string, params: unknown[]): Promise<unknown>;
|
|
32
46
|
signedCall(method: string, params: unknown[], account: string, key: string, callback: (err: Error | null, result?: unknown) => void): void;
|
|
47
|
+
/**
|
|
48
|
+
* Promise-based version of signedCall
|
|
49
|
+
* Makes an authenticated JSON-RPC call with cryptographic signature
|
|
50
|
+
* @param method Method name (e.g., 'conveyor.is_email_registered')
|
|
51
|
+
* @param params Parameters array for the method
|
|
52
|
+
* @param account Account name to sign the request with
|
|
53
|
+
* @param key Private key (WIF) to sign the request
|
|
54
|
+
* @returns Promise that resolves with the result or rejects with an error
|
|
55
|
+
*/
|
|
56
|
+
signedCallAsync(method: string, params: unknown[], account: string, key: string): Promise<unknown>;
|
|
33
57
|
/**
|
|
34
58
|
* Verify a signed RPC request
|
|
35
59
|
* @param signedRequest The signed request to verify
|
|
36
60
|
* @param callback Callback function
|
|
37
61
|
*/
|
|
38
62
|
verifySignedRequest(signedRequest: unknown, callback: (err: Error | null, result?: unknown) => void): void;
|
|
63
|
+
/**
|
|
64
|
+
* Promise-based version of verifySignedRequest
|
|
65
|
+
* Verifies a signed RPC request
|
|
66
|
+
* @param signedRequest The signed request to verify
|
|
67
|
+
* @returns Promise that resolves with verification result or rejects with an error
|
|
68
|
+
*/
|
|
69
|
+
verifySignedRequestAsync(signedRequest: unknown): Promise<{
|
|
70
|
+
valid: boolean;
|
|
71
|
+
params: unknown;
|
|
72
|
+
}>;
|
|
39
73
|
setOptions(options: ApiOptions): void;
|
|
40
74
|
setUrl(url: string): void;
|
|
41
75
|
streamBlockNumber(mode?: string | ((err: Error | null, blockNumber?: unknown) => void), callback?: (err: Error | null, blockNumber?: unknown) => void, ts?: number): () => void;
|
|
@@ -45,12 +79,28 @@ export declare class Api extends EventEmitter {
|
|
|
45
79
|
broadcastTransactionSynchronousWith(options: {
|
|
46
80
|
transaction: unknown;
|
|
47
81
|
}, callback: (err: Error | null, result?: unknown) => void): void;
|
|
82
|
+
/**
|
|
83
|
+
* Promise-based version of broadcastTransactionSynchronousWith
|
|
84
|
+
* Broadcasts a transaction synchronously
|
|
85
|
+
* @param options Options object containing the transaction
|
|
86
|
+
* @returns Promise that resolves with the result or rejects with an error
|
|
87
|
+
*/
|
|
88
|
+
broadcastTransactionSynchronousWithAsync(options: {
|
|
89
|
+
transaction: unknown;
|
|
90
|
+
}): Promise<unknown>;
|
|
48
91
|
/**
|
|
49
92
|
* Broadcast a transaction to the blockchain.
|
|
50
93
|
* @param trx The transaction object
|
|
51
94
|
* @param callback Callback function
|
|
52
95
|
*/
|
|
53
96
|
broadcastTransaction(trx: unknown, callback: (err: Error | null, result?: unknown) => void): void;
|
|
97
|
+
/**
|
|
98
|
+
* Promise-based version of broadcastTransaction
|
|
99
|
+
* Broadcasts a transaction to the blockchain
|
|
100
|
+
* @param trx The transaction object
|
|
101
|
+
* @returns Promise that resolves with the result or rejects with an error
|
|
102
|
+
*/
|
|
103
|
+
broadcastTransactionAsync(trx: unknown): Promise<unknown>;
|
|
54
104
|
/**
|
|
55
105
|
* Sign a transaction with the provided private key(s).
|
|
56
106
|
* @param trx The transaction object
|
|
@@ -75,18 +125,40 @@ export declare class Api extends EventEmitter {
|
|
|
75
125
|
* @param callback Callback function
|
|
76
126
|
*/
|
|
77
127
|
broadcastTransactionWithCallback(confirmationCallback: (result: unknown) => void, trx: unknown, callback: (err: Error | null, result?: unknown) => void): void;
|
|
128
|
+
/**
|
|
129
|
+
* Promise-based version of broadcastTransactionWithCallback
|
|
130
|
+
* Note: The confirmationCallback will still be called when the transaction is confirmed
|
|
131
|
+
* @param confirmationCallback Callback function for transaction confirmation
|
|
132
|
+
* @param trx Transaction object to broadcast
|
|
133
|
+
* @returns Promise that resolves with the result or rejects with an error
|
|
134
|
+
*/
|
|
135
|
+
broadcastTransactionWithCallbackAsync(confirmationCallback: (result: unknown) => void, trx: unknown): Promise<unknown>;
|
|
78
136
|
/**
|
|
79
137
|
* Broadcast a block to the network.
|
|
80
138
|
* @param block Block object to broadcast
|
|
81
139
|
* @param callback Callback function
|
|
82
140
|
*/
|
|
83
141
|
broadcastBlock(block: unknown, callback: (err: Error | null, result?: unknown) => void): void;
|
|
142
|
+
/**
|
|
143
|
+
* Promise-based version of broadcastBlock
|
|
144
|
+
* Broadcasts a block to the network
|
|
145
|
+
* @param block Block object to broadcast
|
|
146
|
+
* @returns Promise that resolves with the result or rejects with an error
|
|
147
|
+
*/
|
|
148
|
+
broadcastBlockAsync(block: unknown): Promise<unknown>;
|
|
84
149
|
/**
|
|
85
150
|
* Set the maximum block age for transaction acceptance.
|
|
86
151
|
* @param maxBlockAge Maximum block age in seconds
|
|
87
152
|
* @param callback Callback function
|
|
88
153
|
*/
|
|
89
154
|
setMaxBlockAge(maxBlockAge: number, callback: (err: Error | null, result?: unknown) => void): void;
|
|
155
|
+
/**
|
|
156
|
+
* Promise-based version of setMaxBlockAge
|
|
157
|
+
* Sets the maximum block age for transaction acceptance
|
|
158
|
+
* @param maxBlockAge Maximum block age in seconds
|
|
159
|
+
* @returns Promise that resolves with the result or rejects with an error
|
|
160
|
+
*/
|
|
161
|
+
setMaxBlockAgeAsync(maxBlockAge: number): Promise<unknown>;
|
|
90
162
|
/**
|
|
91
163
|
* Verify transaction authority.
|
|
92
164
|
* @param trx Transaction object to verify
|
|
@@ -2,7 +2,7 @@ import { TransportOptions, JsonRpcRequest } from './types';
|
|
|
2
2
|
import { BaseTransport } from './base';
|
|
3
3
|
/**
|
|
4
4
|
* Makes a JSON-RPC request using native fetch API
|
|
5
|
-
* Universal implementation that works in both Node.js (
|
|
5
|
+
* Universal implementation that works in both Node.js (20.19+) and browser
|
|
6
6
|
*
|
|
7
7
|
* @param url - The URL to the JSON-RPC endpoint
|
|
8
8
|
* @param request - The JSON-RPC request object
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for dynamically generated API methods
|
|
3
|
+
* These types provide TypeScript support for all API methods
|
|
4
|
+
*/
|
|
5
|
+
export type ApiCallback<T = unknown> = (err: Error | null, result?: T) => void;
|
|
6
|
+
type ApiMethodWithParams<TResult = unknown> = (...args: unknown[]) => Promise<TResult> | void;
|
|
7
|
+
type ApiMethodNoParams<TResult = unknown> = (callback?: ApiCallback<TResult>) => Promise<TResult> | void;
|
|
8
|
+
type ApiMethodWith<TResult = unknown> = (options: Record<string, unknown>, callback?: ApiCallback<TResult>) => Promise<TResult> | void;
|
|
9
|
+
type ApiMethodAsync<TParams extends unknown[] = unknown[], TResult = unknown> = (...args: TParams) => Promise<TResult>;
|
|
10
|
+
type ApiMethodWithAsync<TResult = unknown> = (options: Record<string, unknown>) => Promise<TResult>;
|
|
11
|
+
/**
|
|
12
|
+
* Type definitions for all API methods
|
|
13
|
+
* This interface provides type safety for dynamically generated methods
|
|
14
|
+
*/
|
|
15
|
+
export interface ApiMethodSignatures {
|
|
16
|
+
getAccounts(accounts: string[], callback?: ApiCallback<any[]>): Promise<any[]> | void;
|
|
17
|
+
getAccountsAsync(accounts: string[]): Promise<any[]>;
|
|
18
|
+
getAccountsWith(options: {
|
|
19
|
+
names: string[];
|
|
20
|
+
}, callback?: ApiCallback<any[]>): Promise<any[]> | void;
|
|
21
|
+
getAccountsWithAsync(options: {
|
|
22
|
+
names: string[];
|
|
23
|
+
}): Promise<any[]>;
|
|
24
|
+
getAccountHistory(account: string, from: number, limit: number, callback?: ApiCallback<any[]>): Promise<any[]> | void;
|
|
25
|
+
getAccountHistoryAsync(account: string, from: number, limit: number): Promise<any[]>;
|
|
26
|
+
getAccountHistoryWith(options: {
|
|
27
|
+
account: string;
|
|
28
|
+
from: number;
|
|
29
|
+
limit: number;
|
|
30
|
+
}, callback?: ApiCallback<any[]>): Promise<any[]> | void;
|
|
31
|
+
getAccountHistoryWithAsync(options: {
|
|
32
|
+
account: string;
|
|
33
|
+
from: number;
|
|
34
|
+
limit: number;
|
|
35
|
+
}): Promise<any[]>;
|
|
36
|
+
getDynamicGlobalProperties(callback?: ApiCallback<any>): Promise<any> | void;
|
|
37
|
+
getDynamicGlobalPropertiesAsync(): Promise<any>;
|
|
38
|
+
getDynamicGlobalPropertiesWith(options: Record<string, unknown>, callback?: ApiCallback<any>): Promise<any> | void;
|
|
39
|
+
getDynamicGlobalPropertiesWithAsync(options: Record<string, unknown>): Promise<any>;
|
|
40
|
+
getContent(author: string, permlink: string, callback?: ApiCallback<any>): Promise<any> | void;
|
|
41
|
+
getContentAsync(author: string, permlink: string): Promise<any>;
|
|
42
|
+
getContentWith(options: {
|
|
43
|
+
author: string;
|
|
44
|
+
permlink: string;
|
|
45
|
+
}, callback?: ApiCallback<any>): Promise<any> | void;
|
|
46
|
+
getContentWithAsync(options: {
|
|
47
|
+
author: string;
|
|
48
|
+
permlink: string;
|
|
49
|
+
}): Promise<any>;
|
|
50
|
+
getFollowers(following: string, startFollower: string, followType: string, limit: number, callback?: ApiCallback<any[]>): Promise<any[]> | void;
|
|
51
|
+
getFollowersAsync(following: string, startFollower: string, followType: string, limit: number): Promise<any[]>;
|
|
52
|
+
getFollowersWith(options: {
|
|
53
|
+
following: string;
|
|
54
|
+
startFollower: string;
|
|
55
|
+
followType: string;
|
|
56
|
+
limit: number;
|
|
57
|
+
}, callback?: ApiCallback<any[]>): Promise<any[]> | void;
|
|
58
|
+
getFollowersWithAsync(options: {
|
|
59
|
+
following: string;
|
|
60
|
+
startFollower: string;
|
|
61
|
+
followType: string;
|
|
62
|
+
limit: number;
|
|
63
|
+
}): Promise<any[]>;
|
|
64
|
+
getBlock(blockNum: number, callback?: ApiCallback<any>): Promise<any> | void;
|
|
65
|
+
getBlockAsync(blockNum: number): Promise<any>;
|
|
66
|
+
getBlockWith(options: {
|
|
67
|
+
blockNum: number;
|
|
68
|
+
}, callback?: ApiCallback<any>): Promise<any> | void;
|
|
69
|
+
getBlockWithAsync(options: {
|
|
70
|
+
blockNum: number;
|
|
71
|
+
}): Promise<any>;
|
|
72
|
+
getConfig(callback?: ApiCallback<any>): Promise<any> | void;
|
|
73
|
+
getConfigAsync(): Promise<any>;
|
|
74
|
+
getConfigWith(options: Record<string, unknown>, callback?: ApiCallback<any>): Promise<any> | void;
|
|
75
|
+
getConfigWithAsync(options: Record<string, unknown>): Promise<any>;
|
|
76
|
+
[methodName: string]: ApiMethodWithParams | ApiMethodNoParams | ApiMethodWith | ApiMethodAsync<unknown[]> | ApiMethodWithAsync | unknown;
|
|
77
|
+
}
|
|
78
|
+
export {};
|