@psalomo/jsonrpc-client 0.1.0
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 +43 -0
- package/dist/browser-standalone.js +13651 -0
- package/dist/index.d.mts +241 -0
- package/dist/index.d.ts +241 -0
- package/dist/index.js +367 -0
- package/dist/index.mjs +339 -0
- package/package.json +58 -0
package/dist/index.d.mts
ADDED
@@ -0,0 +1,241 @@
|
|
1
|
+
export { JsonRpcErrorSchema, JsonRpcRequestSchema, JsonRpcResponseSchema, RPC_METHODS } from '@near-js/jsonrpc-types';
|
2
|
+
|
3
|
+
interface ClientConfig {
|
4
|
+
endpoint: string;
|
5
|
+
headers?: Record<string, string>;
|
6
|
+
timeout?: number;
|
7
|
+
retries?: number;
|
8
|
+
validateResponses?: boolean;
|
9
|
+
}
|
10
|
+
interface JsonRpcRequest<T = unknown> {
|
11
|
+
jsonrpc: '2.0';
|
12
|
+
id: string;
|
13
|
+
method: string;
|
14
|
+
params?: T;
|
15
|
+
}
|
16
|
+
interface JsonRpcResponse<T = unknown> {
|
17
|
+
jsonrpc: '2.0';
|
18
|
+
id: string;
|
19
|
+
result?: T;
|
20
|
+
error?: JsonRpcError;
|
21
|
+
}
|
22
|
+
interface JsonRpcError {
|
23
|
+
code: number;
|
24
|
+
message: string;
|
25
|
+
data?: unknown;
|
26
|
+
}
|
27
|
+
declare class JsonRpcClientError extends Error {
|
28
|
+
code?: number | undefined;
|
29
|
+
data?: unknown | undefined;
|
30
|
+
constructor(message: string, code?: number | undefined, data?: unknown | undefined);
|
31
|
+
}
|
32
|
+
declare class JsonRpcNetworkError extends Error {
|
33
|
+
originalError: Error;
|
34
|
+
constructor(message: string, originalError: Error);
|
35
|
+
}
|
36
|
+
declare class NearRpcClient {
|
37
|
+
private endpoint;
|
38
|
+
private headers;
|
39
|
+
private timeout;
|
40
|
+
private retries;
|
41
|
+
private validateResponses;
|
42
|
+
private requestIdCounter;
|
43
|
+
constructor(config: string | ClientConfig);
|
44
|
+
/**
|
45
|
+
* Generate a unique request ID
|
46
|
+
*/
|
47
|
+
private generateRequestId;
|
48
|
+
/**
|
49
|
+
* Make a raw JSON-RPC call
|
50
|
+
*/
|
51
|
+
private call;
|
52
|
+
/**
|
53
|
+
* Get node status
|
54
|
+
*/
|
55
|
+
status(): Promise<any>;
|
56
|
+
/**
|
57
|
+
* Get block information
|
58
|
+
*/
|
59
|
+
block(params?: {
|
60
|
+
blockId?: string | number;
|
61
|
+
finality?: 'final' | 'near-final' | 'optimistic';
|
62
|
+
}): Promise<any>;
|
63
|
+
/**
|
64
|
+
* Get current gas price
|
65
|
+
*/
|
66
|
+
gasPrice(params?: {
|
67
|
+
blockId?: string | number;
|
68
|
+
}): Promise<any>;
|
69
|
+
/**
|
70
|
+
* Get chunk information
|
71
|
+
*/
|
72
|
+
chunk(params: {
|
73
|
+
chunkId: string;
|
74
|
+
} | {
|
75
|
+
blockId: string | number;
|
76
|
+
shardId: number;
|
77
|
+
}): Promise<any>;
|
78
|
+
/**
|
79
|
+
* Health check
|
80
|
+
*/
|
81
|
+
health(): Promise<any>;
|
82
|
+
/**
|
83
|
+
* Get network information
|
84
|
+
*/
|
85
|
+
networkInfo(): Promise<any>;
|
86
|
+
/**
|
87
|
+
* Get current validators
|
88
|
+
*/
|
89
|
+
validators(params?: {
|
90
|
+
blockId?: string | number;
|
91
|
+
}): Promise<any>;
|
92
|
+
/**
|
93
|
+
* Get client configuration
|
94
|
+
*/
|
95
|
+
clientConfig(): Promise<any>;
|
96
|
+
/**
|
97
|
+
* Broadcast transaction asynchronously
|
98
|
+
*/
|
99
|
+
broadcastTxAsync(params: {
|
100
|
+
signedTxBase64: string;
|
101
|
+
}): Promise<any>;
|
102
|
+
/**
|
103
|
+
* Broadcast transaction and wait for commit
|
104
|
+
*/
|
105
|
+
broadcastTxCommit(params: {
|
106
|
+
signedTxBase64: string;
|
107
|
+
}): Promise<any>;
|
108
|
+
/**
|
109
|
+
* Send transaction
|
110
|
+
*/
|
111
|
+
sendTx(params: {
|
112
|
+
signedTxBase64: string;
|
113
|
+
}): Promise<any>;
|
114
|
+
/**
|
115
|
+
* Get transaction status
|
116
|
+
*/
|
117
|
+
tx(params: {
|
118
|
+
txHash: string;
|
119
|
+
senderAccountId: string;
|
120
|
+
}): Promise<any>;
|
121
|
+
/**
|
122
|
+
* Query account/contract state
|
123
|
+
*/
|
124
|
+
query(params: {
|
125
|
+
requestType: string;
|
126
|
+
finality?: 'final' | 'near-final' | 'optimistic';
|
127
|
+
blockId?: string | number;
|
128
|
+
accountId?: string;
|
129
|
+
methodName?: string;
|
130
|
+
argsBase64?: string;
|
131
|
+
publicKey?: string;
|
132
|
+
keyType?: string;
|
133
|
+
}): Promise<any>;
|
134
|
+
/**
|
135
|
+
* View account information (convenience method)
|
136
|
+
*/
|
137
|
+
viewAccount(params: {
|
138
|
+
accountId: string;
|
139
|
+
finality?: 'final' | 'near-final' | 'optimistic';
|
140
|
+
blockId?: string | number;
|
141
|
+
}): Promise<any>;
|
142
|
+
/**
|
143
|
+
* View function call (convenience method)
|
144
|
+
*/
|
145
|
+
viewFunction(params: {
|
146
|
+
accountId: string;
|
147
|
+
methodName: string;
|
148
|
+
argsBase64?: string;
|
149
|
+
finality?: 'final' | 'near-final' | 'optimistic';
|
150
|
+
blockId?: string | number;
|
151
|
+
}): Promise<any>;
|
152
|
+
/**
|
153
|
+
* View access key (convenience method)
|
154
|
+
*/
|
155
|
+
viewAccessKey(params: {
|
156
|
+
accountId: string;
|
157
|
+
publicKey: string;
|
158
|
+
finality?: 'final' | 'near-final' | 'optimistic';
|
159
|
+
blockId?: string | number;
|
160
|
+
}): Promise<any>;
|
161
|
+
/**
|
162
|
+
* Get light client proof
|
163
|
+
*/
|
164
|
+
lightClientProof(params: {
|
165
|
+
type: string;
|
166
|
+
lightClientHead: string;
|
167
|
+
transactionHash?: string;
|
168
|
+
senderId?: string;
|
169
|
+
receiptId?: string;
|
170
|
+
}): Promise<any>;
|
171
|
+
/**
|
172
|
+
* Get state changes (experimental)
|
173
|
+
*/
|
174
|
+
experimentalChanges(params: {
|
175
|
+
changesType: string;
|
176
|
+
accountIds?: string[];
|
177
|
+
keyPrefixBase64?: string;
|
178
|
+
blockId?: string | number;
|
179
|
+
}): Promise<any>;
|
180
|
+
/**
|
181
|
+
* Get state changes in block (experimental)
|
182
|
+
*/
|
183
|
+
experimentalChangesInBlock(params: {
|
184
|
+
blockId: string | number;
|
185
|
+
}): Promise<any>;
|
186
|
+
/**
|
187
|
+
* Get ordered validators (experimental)
|
188
|
+
*/
|
189
|
+
experimentalValidatorsOrdered(params?: {
|
190
|
+
blockId?: string | number;
|
191
|
+
}): Promise<any>;
|
192
|
+
/**
|
193
|
+
* Get protocol configuration (experimental)
|
194
|
+
*/
|
195
|
+
experimentalProtocolConfig(params?: {
|
196
|
+
blockId?: string | number;
|
197
|
+
finality?: 'final' | 'near-final' | 'optimistic';
|
198
|
+
}): Promise<any>;
|
199
|
+
/**
|
200
|
+
* Get genesis configuration (experimental)
|
201
|
+
*/
|
202
|
+
experimentalGenesisConfig(): Promise<any>;
|
203
|
+
/**
|
204
|
+
* Get receipt information (experimental)
|
205
|
+
*/
|
206
|
+
experimentalReceipt(params: {
|
207
|
+
receiptId: string;
|
208
|
+
}): Promise<any>;
|
209
|
+
/**
|
210
|
+
* Get transaction status (experimental)
|
211
|
+
*/
|
212
|
+
experimentalTxStatus(params: {
|
213
|
+
txHash: string;
|
214
|
+
senderAccountId: string;
|
215
|
+
}): Promise<any>;
|
216
|
+
}
|
217
|
+
|
218
|
+
interface RpcRequest {
|
219
|
+
jsonrpc: '2.0';
|
220
|
+
id: string | number;
|
221
|
+
method: string;
|
222
|
+
params: unknown;
|
223
|
+
}
|
224
|
+
interface RpcResponse<T = unknown> {
|
225
|
+
jsonrpc: '2.0';
|
226
|
+
id: string | number;
|
227
|
+
result?: T;
|
228
|
+
error?: RpcError;
|
229
|
+
}
|
230
|
+
interface RpcError {
|
231
|
+
code: number;
|
232
|
+
message: string;
|
233
|
+
data?: unknown;
|
234
|
+
}
|
235
|
+
declare class NearRpcError extends Error {
|
236
|
+
code: number;
|
237
|
+
data?: unknown | undefined;
|
238
|
+
constructor(code: number, message: string, data?: unknown | undefined);
|
239
|
+
}
|
240
|
+
|
241
|
+
export { type ClientConfig, JsonRpcClientError, type JsonRpcError, JsonRpcNetworkError, type JsonRpcRequest, type JsonRpcResponse, NearRpcClient, NearRpcError, type RpcError, type RpcRequest, type RpcResponse, NearRpcClient as default };
|
package/dist/index.d.ts
ADDED
@@ -0,0 +1,241 @@
|
|
1
|
+
export { JsonRpcErrorSchema, JsonRpcRequestSchema, JsonRpcResponseSchema, RPC_METHODS } from '@near-js/jsonrpc-types';
|
2
|
+
|
3
|
+
interface ClientConfig {
|
4
|
+
endpoint: string;
|
5
|
+
headers?: Record<string, string>;
|
6
|
+
timeout?: number;
|
7
|
+
retries?: number;
|
8
|
+
validateResponses?: boolean;
|
9
|
+
}
|
10
|
+
interface JsonRpcRequest<T = unknown> {
|
11
|
+
jsonrpc: '2.0';
|
12
|
+
id: string;
|
13
|
+
method: string;
|
14
|
+
params?: T;
|
15
|
+
}
|
16
|
+
interface JsonRpcResponse<T = unknown> {
|
17
|
+
jsonrpc: '2.0';
|
18
|
+
id: string;
|
19
|
+
result?: T;
|
20
|
+
error?: JsonRpcError;
|
21
|
+
}
|
22
|
+
interface JsonRpcError {
|
23
|
+
code: number;
|
24
|
+
message: string;
|
25
|
+
data?: unknown;
|
26
|
+
}
|
27
|
+
declare class JsonRpcClientError extends Error {
|
28
|
+
code?: number | undefined;
|
29
|
+
data?: unknown | undefined;
|
30
|
+
constructor(message: string, code?: number | undefined, data?: unknown | undefined);
|
31
|
+
}
|
32
|
+
declare class JsonRpcNetworkError extends Error {
|
33
|
+
originalError: Error;
|
34
|
+
constructor(message: string, originalError: Error);
|
35
|
+
}
|
36
|
+
declare class NearRpcClient {
|
37
|
+
private endpoint;
|
38
|
+
private headers;
|
39
|
+
private timeout;
|
40
|
+
private retries;
|
41
|
+
private validateResponses;
|
42
|
+
private requestIdCounter;
|
43
|
+
constructor(config: string | ClientConfig);
|
44
|
+
/**
|
45
|
+
* Generate a unique request ID
|
46
|
+
*/
|
47
|
+
private generateRequestId;
|
48
|
+
/**
|
49
|
+
* Make a raw JSON-RPC call
|
50
|
+
*/
|
51
|
+
private call;
|
52
|
+
/**
|
53
|
+
* Get node status
|
54
|
+
*/
|
55
|
+
status(): Promise<any>;
|
56
|
+
/**
|
57
|
+
* Get block information
|
58
|
+
*/
|
59
|
+
block(params?: {
|
60
|
+
blockId?: string | number;
|
61
|
+
finality?: 'final' | 'near-final' | 'optimistic';
|
62
|
+
}): Promise<any>;
|
63
|
+
/**
|
64
|
+
* Get current gas price
|
65
|
+
*/
|
66
|
+
gasPrice(params?: {
|
67
|
+
blockId?: string | number;
|
68
|
+
}): Promise<any>;
|
69
|
+
/**
|
70
|
+
* Get chunk information
|
71
|
+
*/
|
72
|
+
chunk(params: {
|
73
|
+
chunkId: string;
|
74
|
+
} | {
|
75
|
+
blockId: string | number;
|
76
|
+
shardId: number;
|
77
|
+
}): Promise<any>;
|
78
|
+
/**
|
79
|
+
* Health check
|
80
|
+
*/
|
81
|
+
health(): Promise<any>;
|
82
|
+
/**
|
83
|
+
* Get network information
|
84
|
+
*/
|
85
|
+
networkInfo(): Promise<any>;
|
86
|
+
/**
|
87
|
+
* Get current validators
|
88
|
+
*/
|
89
|
+
validators(params?: {
|
90
|
+
blockId?: string | number;
|
91
|
+
}): Promise<any>;
|
92
|
+
/**
|
93
|
+
* Get client configuration
|
94
|
+
*/
|
95
|
+
clientConfig(): Promise<any>;
|
96
|
+
/**
|
97
|
+
* Broadcast transaction asynchronously
|
98
|
+
*/
|
99
|
+
broadcastTxAsync(params: {
|
100
|
+
signedTxBase64: string;
|
101
|
+
}): Promise<any>;
|
102
|
+
/**
|
103
|
+
* Broadcast transaction and wait for commit
|
104
|
+
*/
|
105
|
+
broadcastTxCommit(params: {
|
106
|
+
signedTxBase64: string;
|
107
|
+
}): Promise<any>;
|
108
|
+
/**
|
109
|
+
* Send transaction
|
110
|
+
*/
|
111
|
+
sendTx(params: {
|
112
|
+
signedTxBase64: string;
|
113
|
+
}): Promise<any>;
|
114
|
+
/**
|
115
|
+
* Get transaction status
|
116
|
+
*/
|
117
|
+
tx(params: {
|
118
|
+
txHash: string;
|
119
|
+
senderAccountId: string;
|
120
|
+
}): Promise<any>;
|
121
|
+
/**
|
122
|
+
* Query account/contract state
|
123
|
+
*/
|
124
|
+
query(params: {
|
125
|
+
requestType: string;
|
126
|
+
finality?: 'final' | 'near-final' | 'optimistic';
|
127
|
+
blockId?: string | number;
|
128
|
+
accountId?: string;
|
129
|
+
methodName?: string;
|
130
|
+
argsBase64?: string;
|
131
|
+
publicKey?: string;
|
132
|
+
keyType?: string;
|
133
|
+
}): Promise<any>;
|
134
|
+
/**
|
135
|
+
* View account information (convenience method)
|
136
|
+
*/
|
137
|
+
viewAccount(params: {
|
138
|
+
accountId: string;
|
139
|
+
finality?: 'final' | 'near-final' | 'optimistic';
|
140
|
+
blockId?: string | number;
|
141
|
+
}): Promise<any>;
|
142
|
+
/**
|
143
|
+
* View function call (convenience method)
|
144
|
+
*/
|
145
|
+
viewFunction(params: {
|
146
|
+
accountId: string;
|
147
|
+
methodName: string;
|
148
|
+
argsBase64?: string;
|
149
|
+
finality?: 'final' | 'near-final' | 'optimistic';
|
150
|
+
blockId?: string | number;
|
151
|
+
}): Promise<any>;
|
152
|
+
/**
|
153
|
+
* View access key (convenience method)
|
154
|
+
*/
|
155
|
+
viewAccessKey(params: {
|
156
|
+
accountId: string;
|
157
|
+
publicKey: string;
|
158
|
+
finality?: 'final' | 'near-final' | 'optimistic';
|
159
|
+
blockId?: string | number;
|
160
|
+
}): Promise<any>;
|
161
|
+
/**
|
162
|
+
* Get light client proof
|
163
|
+
*/
|
164
|
+
lightClientProof(params: {
|
165
|
+
type: string;
|
166
|
+
lightClientHead: string;
|
167
|
+
transactionHash?: string;
|
168
|
+
senderId?: string;
|
169
|
+
receiptId?: string;
|
170
|
+
}): Promise<any>;
|
171
|
+
/**
|
172
|
+
* Get state changes (experimental)
|
173
|
+
*/
|
174
|
+
experimentalChanges(params: {
|
175
|
+
changesType: string;
|
176
|
+
accountIds?: string[];
|
177
|
+
keyPrefixBase64?: string;
|
178
|
+
blockId?: string | number;
|
179
|
+
}): Promise<any>;
|
180
|
+
/**
|
181
|
+
* Get state changes in block (experimental)
|
182
|
+
*/
|
183
|
+
experimentalChangesInBlock(params: {
|
184
|
+
blockId: string | number;
|
185
|
+
}): Promise<any>;
|
186
|
+
/**
|
187
|
+
* Get ordered validators (experimental)
|
188
|
+
*/
|
189
|
+
experimentalValidatorsOrdered(params?: {
|
190
|
+
blockId?: string | number;
|
191
|
+
}): Promise<any>;
|
192
|
+
/**
|
193
|
+
* Get protocol configuration (experimental)
|
194
|
+
*/
|
195
|
+
experimentalProtocolConfig(params?: {
|
196
|
+
blockId?: string | number;
|
197
|
+
finality?: 'final' | 'near-final' | 'optimistic';
|
198
|
+
}): Promise<any>;
|
199
|
+
/**
|
200
|
+
* Get genesis configuration (experimental)
|
201
|
+
*/
|
202
|
+
experimentalGenesisConfig(): Promise<any>;
|
203
|
+
/**
|
204
|
+
* Get receipt information (experimental)
|
205
|
+
*/
|
206
|
+
experimentalReceipt(params: {
|
207
|
+
receiptId: string;
|
208
|
+
}): Promise<any>;
|
209
|
+
/**
|
210
|
+
* Get transaction status (experimental)
|
211
|
+
*/
|
212
|
+
experimentalTxStatus(params: {
|
213
|
+
txHash: string;
|
214
|
+
senderAccountId: string;
|
215
|
+
}): Promise<any>;
|
216
|
+
}
|
217
|
+
|
218
|
+
interface RpcRequest {
|
219
|
+
jsonrpc: '2.0';
|
220
|
+
id: string | number;
|
221
|
+
method: string;
|
222
|
+
params: unknown;
|
223
|
+
}
|
224
|
+
interface RpcResponse<T = unknown> {
|
225
|
+
jsonrpc: '2.0';
|
226
|
+
id: string | number;
|
227
|
+
result?: T;
|
228
|
+
error?: RpcError;
|
229
|
+
}
|
230
|
+
interface RpcError {
|
231
|
+
code: number;
|
232
|
+
message: string;
|
233
|
+
data?: unknown;
|
234
|
+
}
|
235
|
+
declare class NearRpcError extends Error {
|
236
|
+
code: number;
|
237
|
+
data?: unknown | undefined;
|
238
|
+
constructor(code: number, message: string, data?: unknown | undefined);
|
239
|
+
}
|
240
|
+
|
241
|
+
export { type ClientConfig, JsonRpcClientError, type JsonRpcError, JsonRpcNetworkError, type JsonRpcRequest, type JsonRpcResponse, NearRpcClient, NearRpcError, type RpcError, type RpcRequest, type RpcResponse, NearRpcClient as default };
|