@psalomo/jsonrpc-client 0.4.0 → 1.0.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 +12 -12
- package/dist/__tests__/test-utils.d.ts +5 -0
- package/dist/__tests__/test-utils.d.ts.map +1 -0
- package/dist/browser-standalone.js +4038 -13674
- package/dist/browser-standalone.min.js +1 -0
- package/dist/client.d.ts +58 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/convenience.d.ts +21 -0
- package/dist/convenience.d.ts.map +1 -0
- package/dist/generated-functions.d.ts +3 -0
- package/dist/generated-functions.d.ts.map +1 -0
- package/dist/generated-types.d.ts +84 -0
- package/dist/generated-types.d.ts.map +1 -0
- package/dist/index.d.mts +133 -72
- package/dist/index.d.ts +10 -137
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +335 -105
- package/dist/index.mjs +307 -110
- package/dist/types.d.ts +23 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/validation.d.ts +14 -0
- package/dist/validation.d.ts.map +1 -0
- package/package.json +10 -6
package/dist/index.d.mts
CHANGED
@@ -1,67 +1,25 @@
|
|
1
|
-
import { RpcStateChangesInBlockByTypeRequest, RpcStateChangesInBlockResponse, RpcStateChangesInBlockRequest, RpcStateChangesInBlockByTypeResponse, RpcCongestionLevelRequest, RpcCongestionLevelResponse, GenesisConfigRequest, GenesisConfig, RpcLightClientBlockProofRequest, RpcLightClientBlockProofResponse, RpcLightClientExecutionProofRequest, RpcLightClientExecutionProofResponse, RpcMaintenanceWindowsRequest, EXPERIMENTALMaintenanceWindowsResponse, RpcProtocolConfigRequest, RpcProtocolConfigResponse, RpcReceiptRequest, RpcReceiptResponse, RpcSplitStorageInfoRequest, RpcSplitStorageInfoResponse, RpcTransactionStatusRequest, RpcTransactionResponse, RpcValidatorsOrderedRequest, EXPERIMENTALValidatorsOrderedResponse, RpcBlockRequest, RpcBlockResponse, RpcSendTransactionRequest, CryptoHash, RpcChunkRequest, RpcChunkResponse, RpcClientConfigRequest, RpcClientConfigResponse, RpcGasPriceRequest, RpcGasPriceResponse, RpcHealthRequest, RpcHealthResponse, RpcNetworkInfoRequest, RpcNetworkInfoResponse, RpcLightClientNextBlockRequest, RpcLightClientNextBlockResponse, RpcQueryRequest, RpcQueryResponse, RpcStatusRequest, RpcStatusResponse, RpcValidatorRequest, RpcValidatorResponse, AccountView, CallResult, AccessKeyView
|
1
|
+
import { RpcStateChangesInBlockByTypeRequest, RpcStateChangesInBlockResponse, RpcStateChangesInBlockRequest, RpcStateChangesInBlockByTypeResponse, RpcCongestionLevelRequest, RpcCongestionLevelResponse, GenesisConfigRequest, GenesisConfig, RpcLightClientBlockProofRequest, RpcLightClientBlockProofResponse, RpcLightClientExecutionProofRequest, RpcLightClientExecutionProofResponse, RpcMaintenanceWindowsRequest, EXPERIMENTALMaintenanceWindowsResponse, RpcProtocolConfigRequest, RpcProtocolConfigResponse, RpcReceiptRequest, RpcReceiptResponse, RpcSplitStorageInfoRequest, RpcSplitStorageInfoResponse, RpcTransactionStatusRequest, RpcTransactionResponse, RpcValidatorsOrderedRequest, EXPERIMENTALValidatorsOrderedResponse, RpcBlockRequest, RpcBlockResponse, RpcSendTransactionRequest, CryptoHash, RpcChunkRequest, RpcChunkResponse, RpcClientConfigRequest, RpcClientConfigResponse, RpcGasPriceRequest, RpcGasPriceResponse, RpcHealthRequest, RpcHealthResponse, RpcNetworkInfoRequest, RpcNetworkInfoResponse, RpcLightClientNextBlockRequest, RpcLightClientNextBlockResponse, RpcQueryRequest, RpcQueryResponse, RpcStatusRequest, RpcStatusResponse, RpcValidatorRequest, RpcValidatorResponse, AccountView, CallResult, AccessKeyView } from '@near-js/jsonrpc-types';
|
2
2
|
export { JsonRpcRequestSchema, JsonRpcResponseSchema, RPC_METHODS } from '@near-js/jsonrpc-types';
|
3
3
|
|
4
|
-
interface
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
experimentalLightClientBlockProof(params?: RpcLightClientBlockProofRequest): Promise<RpcLightClientBlockProofResponse>;
|
10
|
-
experimentalLightClientProof(params?: RpcLightClientExecutionProofRequest): Promise<RpcLightClientExecutionProofResponse>;
|
11
|
-
experimentalMaintenanceWindows(params?: RpcMaintenanceWindowsRequest): Promise<EXPERIMENTALMaintenanceWindowsResponse>;
|
12
|
-
experimentalProtocolConfig(params?: RpcProtocolConfigRequest): Promise<RpcProtocolConfigResponse>;
|
13
|
-
experimentalReceipt(params?: RpcReceiptRequest): Promise<RpcReceiptResponse>;
|
14
|
-
experimentalSplitStorageInfo(params?: RpcSplitStorageInfoRequest): Promise<RpcSplitStorageInfoResponse>;
|
15
|
-
experimentalTxStatus(params?: RpcTransactionStatusRequest): Promise<RpcTransactionResponse>;
|
16
|
-
experimentalValidatorsOrdered(params?: RpcValidatorsOrderedRequest): Promise<EXPERIMENTALValidatorsOrderedResponse>;
|
17
|
-
block(params?: RpcBlockRequest): Promise<RpcBlockResponse>;
|
18
|
-
broadcastTxAsync(params?: RpcSendTransactionRequest): Promise<CryptoHash>;
|
19
|
-
broadcastTxCommit(params?: RpcSendTransactionRequest): Promise<RpcTransactionResponse>;
|
20
|
-
changes(params?: RpcStateChangesInBlockByTypeRequest): Promise<RpcStateChangesInBlockResponse>;
|
21
|
-
chunk(params?: RpcChunkRequest): Promise<RpcChunkResponse>;
|
22
|
-
clientConfig(params?: RpcClientConfigRequest): Promise<RpcClientConfigResponse>;
|
23
|
-
gasPrice(params?: RpcGasPriceRequest): Promise<RpcGasPriceResponse>;
|
24
|
-
health(params?: RpcHealthRequest): Promise<RpcHealthResponse>;
|
25
|
-
lightClientProof(params?: RpcLightClientExecutionProofRequest): Promise<RpcLightClientExecutionProofResponse>;
|
26
|
-
networkInfo(params?: RpcNetworkInfoRequest): Promise<RpcNetworkInfoResponse>;
|
27
|
-
nextLightClientBlock(params?: RpcLightClientNextBlockRequest): Promise<RpcLightClientNextBlockResponse>;
|
28
|
-
query(params?: RpcQueryRequest): Promise<RpcQueryResponse>;
|
29
|
-
sendTx(params?: RpcSendTransactionRequest): Promise<RpcTransactionResponse>;
|
30
|
-
status(params?: RpcStatusRequest): Promise<RpcStatusResponse>;
|
31
|
-
tx(params?: RpcTransactionStatusRequest): Promise<RpcTransactionResponse>;
|
32
|
-
validators(params?: RpcValidatorRequest): Promise<RpcValidatorResponse>;
|
33
|
-
}
|
34
|
-
interface ConvenienceMethods {
|
35
|
-
viewAccount(params: {
|
36
|
-
accountId: string;
|
37
|
-
finality?: 'final' | 'near-final' | 'optimistic';
|
38
|
-
blockId?: string | number;
|
39
|
-
}): Promise<AccountView>;
|
40
|
-
viewFunction(params: {
|
41
|
-
accountId: string;
|
42
|
-
methodName: string;
|
43
|
-
argsBase64?: string;
|
44
|
-
finality?: 'final' | 'near-final' | 'optimistic';
|
45
|
-
blockId?: string | number;
|
46
|
-
}): Promise<CallResult>;
|
47
|
-
viewAccessKey(params: {
|
48
|
-
accountId: string;
|
49
|
-
publicKey: string;
|
50
|
-
finality?: 'final' | 'near-final' | 'optimistic';
|
51
|
-
blockId?: string | number;
|
52
|
-
}): Promise<AccessKeyView>;
|
53
|
-
}
|
54
|
-
interface CompleteClientInterface extends DynamicRpcMethods, ConvenienceMethods {
|
55
|
-
call<TParams = unknown, TResult = unknown>(method: string, params?: TParams): Promise<TResult>;
|
4
|
+
interface ValidationResult {
|
5
|
+
validateRequest: (request: JsonRpcRequest) => void;
|
6
|
+
validateResponse: (response: JsonRpcResponse) => void;
|
7
|
+
validateMethodRequest?: (method: string, request: JsonRpcRequest) => void;
|
8
|
+
validateMethodResponse?: (method: string, response: JsonRpcResponse) => void;
|
56
9
|
}
|
10
|
+
/**
|
11
|
+
* Enable validation for the client
|
12
|
+
* This function should only be called if you want to include schema validation
|
13
|
+
* Calling this function will include Zod schemas in your bundle
|
14
|
+
*/
|
15
|
+
declare function enableValidation(): ValidationResult;
|
57
16
|
|
58
|
-
type RpcMethod = (typeof RPC_METHODS)[number];
|
59
17
|
interface ClientConfig {
|
60
18
|
endpoint: string;
|
61
19
|
headers?: Record<string, string>;
|
62
20
|
timeout?: number;
|
63
21
|
retries?: number;
|
64
|
-
|
22
|
+
validation?: ValidationResult;
|
65
23
|
}
|
66
24
|
interface JsonRpcRequest<T = unknown> {
|
67
25
|
jsonrpc: '2.0';
|
@@ -86,30 +44,32 @@ declare class JsonRpcClientError extends Error {
|
|
86
44
|
constructor(message: string, code?: number | undefined, data?: unknown | undefined);
|
87
45
|
}
|
88
46
|
declare class JsonRpcNetworkError extends Error {
|
89
|
-
originalError
|
90
|
-
constructor(message: string, originalError
|
47
|
+
originalError?: Error | undefined;
|
48
|
+
constructor(message: string, originalError?: Error | undefined);
|
91
49
|
}
|
92
|
-
|
50
|
+
/**
|
51
|
+
* NEAR RPC Client with static function architecture
|
52
|
+
* This client only holds configuration and provides a makeRequest method
|
53
|
+
* Individual RPC methods are provided as standalone functions that take this client as a parameter
|
54
|
+
*/
|
93
55
|
declare class NearRpcClient {
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
private
|
99
|
-
private requestIdCounter;
|
56
|
+
readonly endpoint: string;
|
57
|
+
readonly headers: Record<string, string>;
|
58
|
+
readonly timeout: number;
|
59
|
+
readonly retries: number;
|
60
|
+
private readonly validation?;
|
100
61
|
constructor(config: string | ClientConfig);
|
101
62
|
/**
|
102
|
-
*
|
63
|
+
* Make a raw JSON-RPC request
|
64
|
+
* This is used internally by the standalone RPC functions
|
103
65
|
*/
|
104
|
-
|
66
|
+
makeRequest<TParams = unknown, TResult = unknown>(method: string, params?: TParams): Promise<TResult>;
|
105
67
|
/**
|
106
|
-
*
|
107
|
-
* This method is public to allow dynamic calls to any RPC method
|
68
|
+
* Create a new client with modified configuration
|
108
69
|
*/
|
109
|
-
|
110
|
-
}
|
111
|
-
interface NearRpcClient extends DynamicRpcMethods, ConvenienceMethods {
|
70
|
+
withConfig(config: Partial<ClientConfig>): NearRpcClient;
|
112
71
|
}
|
72
|
+
declare const defaultClient: NearRpcClient;
|
113
73
|
|
114
74
|
interface RpcRequest {
|
115
75
|
jsonrpc: '2.0';
|
@@ -134,4 +94,105 @@ declare class NearRpcError extends Error {
|
|
134
94
|
constructor(code: number, message: string, data?: unknown | undefined);
|
135
95
|
}
|
136
96
|
|
137
|
-
|
97
|
+
interface DynamicRpcMethods {
|
98
|
+
experimentalChanges(params?: RpcStateChangesInBlockByTypeRequest): Promise<RpcStateChangesInBlockResponse>;
|
99
|
+
experimentalChangesInBlock(params?: RpcStateChangesInBlockRequest): Promise<RpcStateChangesInBlockByTypeResponse>;
|
100
|
+
experimentalCongestionLevel(params?: RpcCongestionLevelRequest): Promise<RpcCongestionLevelResponse>;
|
101
|
+
experimentalGenesisConfig(params?: GenesisConfigRequest): Promise<GenesisConfig>;
|
102
|
+
experimentalLightClientBlockProof(params?: RpcLightClientBlockProofRequest): Promise<RpcLightClientBlockProofResponse>;
|
103
|
+
experimentalLightClientProof(params?: RpcLightClientExecutionProofRequest): Promise<RpcLightClientExecutionProofResponse>;
|
104
|
+
experimentalMaintenanceWindows(params?: RpcMaintenanceWindowsRequest): Promise<EXPERIMENTALMaintenanceWindowsResponse>;
|
105
|
+
experimentalProtocolConfig(params?: RpcProtocolConfigRequest): Promise<RpcProtocolConfigResponse>;
|
106
|
+
experimentalReceipt(params?: RpcReceiptRequest): Promise<RpcReceiptResponse>;
|
107
|
+
experimentalSplitStorageInfo(params?: RpcSplitStorageInfoRequest): Promise<RpcSplitStorageInfoResponse>;
|
108
|
+
experimentalTxStatus(params?: RpcTransactionStatusRequest): Promise<RpcTransactionResponse>;
|
109
|
+
experimentalValidatorsOrdered(params?: RpcValidatorsOrderedRequest): Promise<EXPERIMENTALValidatorsOrderedResponse>;
|
110
|
+
block(params?: RpcBlockRequest): Promise<RpcBlockResponse>;
|
111
|
+
broadcastTxAsync(params?: RpcSendTransactionRequest): Promise<CryptoHash>;
|
112
|
+
broadcastTxCommit(params?: RpcSendTransactionRequest): Promise<RpcTransactionResponse>;
|
113
|
+
changes(params?: RpcStateChangesInBlockByTypeRequest): Promise<RpcStateChangesInBlockResponse>;
|
114
|
+
chunk(params?: RpcChunkRequest): Promise<RpcChunkResponse>;
|
115
|
+
clientConfig(params?: RpcClientConfigRequest): Promise<RpcClientConfigResponse>;
|
116
|
+
gasPrice(params?: RpcGasPriceRequest): Promise<RpcGasPriceResponse>;
|
117
|
+
health(params?: RpcHealthRequest): Promise<RpcHealthResponse>;
|
118
|
+
lightClientProof(params?: RpcLightClientExecutionProofRequest): Promise<RpcLightClientExecutionProofResponse>;
|
119
|
+
networkInfo(params?: RpcNetworkInfoRequest): Promise<RpcNetworkInfoResponse>;
|
120
|
+
nextLightClientBlock(params?: RpcLightClientNextBlockRequest): Promise<RpcLightClientNextBlockResponse>;
|
121
|
+
query(params?: RpcQueryRequest): Promise<RpcQueryResponse>;
|
122
|
+
sendTx(params?: RpcSendTransactionRequest): Promise<RpcTransactionResponse>;
|
123
|
+
status(params?: RpcStatusRequest): Promise<RpcStatusResponse>;
|
124
|
+
tx(params?: RpcTransactionStatusRequest): Promise<RpcTransactionResponse>;
|
125
|
+
validators(params?: RpcValidatorRequest): Promise<RpcValidatorResponse>;
|
126
|
+
}
|
127
|
+
interface ConvenienceMethods {
|
128
|
+
viewAccount(params: {
|
129
|
+
accountId: string;
|
130
|
+
finality?: 'final' | 'near-final' | 'optimistic';
|
131
|
+
blockId?: string | number;
|
132
|
+
}): Promise<AccountView>;
|
133
|
+
viewFunction(params: {
|
134
|
+
accountId: string;
|
135
|
+
methodName: string;
|
136
|
+
argsBase64?: string;
|
137
|
+
finality?: 'final' | 'near-final' | 'optimistic';
|
138
|
+
blockId?: string | number;
|
139
|
+
}): Promise<CallResult>;
|
140
|
+
viewAccessKey(params: {
|
141
|
+
accountId: string;
|
142
|
+
publicKey: string;
|
143
|
+
finality?: 'final' | 'near-final' | 'optimistic';
|
144
|
+
blockId?: string | number;
|
145
|
+
}): Promise<AccessKeyView>;
|
146
|
+
}
|
147
|
+
interface CompleteClientInterface extends DynamicRpcMethods, ConvenienceMethods {
|
148
|
+
call<TParams = unknown, TResult = unknown>(method: string, params?: TParams): Promise<TResult>;
|
149
|
+
}
|
150
|
+
declare function experimentalChanges(client: NearRpcClient, params?: RpcStateChangesInBlockByTypeRequest): Promise<RpcStateChangesInBlockResponse>;
|
151
|
+
declare function experimentalChangesInBlock(client: NearRpcClient, params?: RpcStateChangesInBlockRequest): Promise<RpcStateChangesInBlockByTypeResponse>;
|
152
|
+
declare function experimentalCongestionLevel(client: NearRpcClient, params?: RpcCongestionLevelRequest): Promise<RpcCongestionLevelResponse>;
|
153
|
+
declare function experimentalGenesisConfig(client: NearRpcClient, params?: GenesisConfigRequest): Promise<GenesisConfig>;
|
154
|
+
declare function experimentalLightClientBlockProof(client: NearRpcClient, params?: RpcLightClientBlockProofRequest): Promise<RpcLightClientBlockProofResponse>;
|
155
|
+
declare function experimentalLightClientProof(client: NearRpcClient, params?: RpcLightClientExecutionProofRequest): Promise<RpcLightClientExecutionProofResponse>;
|
156
|
+
declare function experimentalMaintenanceWindows(client: NearRpcClient, params?: RpcMaintenanceWindowsRequest): Promise<EXPERIMENTALMaintenanceWindowsResponse>;
|
157
|
+
declare function experimentalProtocolConfig(client: NearRpcClient, params?: RpcProtocolConfigRequest): Promise<RpcProtocolConfigResponse>;
|
158
|
+
declare function experimentalReceipt(client: NearRpcClient, params?: RpcReceiptRequest): Promise<RpcReceiptResponse>;
|
159
|
+
declare function experimentalSplitStorageInfo(client: NearRpcClient, params?: RpcSplitStorageInfoRequest): Promise<RpcSplitStorageInfoResponse>;
|
160
|
+
declare function experimentalTxStatus(client: NearRpcClient, params?: RpcTransactionStatusRequest): Promise<RpcTransactionResponse>;
|
161
|
+
declare function experimentalValidatorsOrdered(client: NearRpcClient, params?: RpcValidatorsOrderedRequest): Promise<EXPERIMENTALValidatorsOrderedResponse>;
|
162
|
+
declare function block(client: NearRpcClient, params?: RpcBlockRequest): Promise<RpcBlockResponse>;
|
163
|
+
declare function broadcastTxAsync(client: NearRpcClient, params?: RpcSendTransactionRequest): Promise<CryptoHash>;
|
164
|
+
declare function broadcastTxCommit(client: NearRpcClient, params?: RpcSendTransactionRequest): Promise<RpcTransactionResponse>;
|
165
|
+
declare function changes(client: NearRpcClient, params?: RpcStateChangesInBlockByTypeRequest): Promise<RpcStateChangesInBlockResponse>;
|
166
|
+
declare function chunk(client: NearRpcClient, params?: RpcChunkRequest): Promise<RpcChunkResponse>;
|
167
|
+
declare function clientConfig(client: NearRpcClient, params?: RpcClientConfigRequest): Promise<RpcClientConfigResponse>;
|
168
|
+
declare function gasPrice(client: NearRpcClient, params?: RpcGasPriceRequest): Promise<RpcGasPriceResponse>;
|
169
|
+
declare function health(client: NearRpcClient, params?: RpcHealthRequest): Promise<RpcHealthResponse>;
|
170
|
+
declare function lightClientProof(client: NearRpcClient, params?: RpcLightClientExecutionProofRequest): Promise<RpcLightClientExecutionProofResponse>;
|
171
|
+
declare function networkInfo(client: NearRpcClient, params?: RpcNetworkInfoRequest): Promise<RpcNetworkInfoResponse>;
|
172
|
+
declare function nextLightClientBlock(client: NearRpcClient, params?: RpcLightClientNextBlockRequest): Promise<RpcLightClientNextBlockResponse>;
|
173
|
+
declare function query(client: NearRpcClient, params?: RpcQueryRequest): Promise<RpcQueryResponse>;
|
174
|
+
declare function sendTx(client: NearRpcClient, params?: RpcSendTransactionRequest): Promise<RpcTransactionResponse>;
|
175
|
+
declare function status(client: NearRpcClient, params?: RpcStatusRequest): Promise<RpcStatusResponse>;
|
176
|
+
declare function tx(client: NearRpcClient, params?: RpcTransactionStatusRequest): Promise<RpcTransactionResponse>;
|
177
|
+
declare function validators(client: NearRpcClient, params?: RpcValidatorRequest): Promise<RpcValidatorResponse>;
|
178
|
+
|
179
|
+
declare function viewAccount(client: NearRpcClient, params: {
|
180
|
+
accountId: string;
|
181
|
+
finality?: 'final' | 'near-final' | 'optimistic';
|
182
|
+
blockId?: string | number;
|
183
|
+
}): Promise<AccountView>;
|
184
|
+
declare function viewFunction(client: NearRpcClient, params: {
|
185
|
+
accountId: string;
|
186
|
+
methodName: string;
|
187
|
+
argsBase64?: string;
|
188
|
+
finality?: 'final' | 'near-final' | 'optimistic';
|
189
|
+
blockId?: string | number;
|
190
|
+
}): Promise<CallResult>;
|
191
|
+
declare function viewAccessKey(client: NearRpcClient, params: {
|
192
|
+
accountId: string;
|
193
|
+
publicKey: string;
|
194
|
+
finality?: 'final' | 'near-final' | 'optimistic';
|
195
|
+
blockId?: string | number;
|
196
|
+
}): Promise<AccessKeyView>;
|
197
|
+
|
198
|
+
export { type ClientConfig, type CompleteClientInterface, type ConvenienceMethods, type DynamicRpcMethods, JsonRpcClientError, type JsonRpcError, JsonRpcNetworkError, type JsonRpcRequest, type JsonRpcResponse, NearRpcClient, NearRpcError, type RpcError, type RpcRequest, type RpcResponse, block, broadcastTxAsync, broadcastTxCommit, changes, chunk, clientConfig, NearRpcClient as default, defaultClient, enableValidation, experimentalChanges, experimentalChangesInBlock, experimentalCongestionLevel, experimentalGenesisConfig, experimentalLightClientBlockProof, experimentalLightClientProof, experimentalMaintenanceWindows, experimentalProtocolConfig, experimentalReceipt, experimentalSplitStorageInfo, experimentalTxStatus, experimentalValidatorsOrdered, gasPrice, health, lightClientProof, networkInfo, nextLightClientBlock, query, sendTx, status, tx, validators, viewAccessKey, viewAccount, viewFunction };
|
package/dist/index.d.ts
CHANGED
@@ -1,137 +1,10 @@
|
|
1
|
-
|
2
|
-
export
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
experimentalMaintenanceWindows(params?: RpcMaintenanceWindowsRequest): Promise<EXPERIMENTALMaintenanceWindowsResponse>;
|
12
|
-
experimentalProtocolConfig(params?: RpcProtocolConfigRequest): Promise<RpcProtocolConfigResponse>;
|
13
|
-
experimentalReceipt(params?: RpcReceiptRequest): Promise<RpcReceiptResponse>;
|
14
|
-
experimentalSplitStorageInfo(params?: RpcSplitStorageInfoRequest): Promise<RpcSplitStorageInfoResponse>;
|
15
|
-
experimentalTxStatus(params?: RpcTransactionStatusRequest): Promise<RpcTransactionResponse>;
|
16
|
-
experimentalValidatorsOrdered(params?: RpcValidatorsOrderedRequest): Promise<EXPERIMENTALValidatorsOrderedResponse>;
|
17
|
-
block(params?: RpcBlockRequest): Promise<RpcBlockResponse>;
|
18
|
-
broadcastTxAsync(params?: RpcSendTransactionRequest): Promise<CryptoHash>;
|
19
|
-
broadcastTxCommit(params?: RpcSendTransactionRequest): Promise<RpcTransactionResponse>;
|
20
|
-
changes(params?: RpcStateChangesInBlockByTypeRequest): Promise<RpcStateChangesInBlockResponse>;
|
21
|
-
chunk(params?: RpcChunkRequest): Promise<RpcChunkResponse>;
|
22
|
-
clientConfig(params?: RpcClientConfigRequest): Promise<RpcClientConfigResponse>;
|
23
|
-
gasPrice(params?: RpcGasPriceRequest): Promise<RpcGasPriceResponse>;
|
24
|
-
health(params?: RpcHealthRequest): Promise<RpcHealthResponse>;
|
25
|
-
lightClientProof(params?: RpcLightClientExecutionProofRequest): Promise<RpcLightClientExecutionProofResponse>;
|
26
|
-
networkInfo(params?: RpcNetworkInfoRequest): Promise<RpcNetworkInfoResponse>;
|
27
|
-
nextLightClientBlock(params?: RpcLightClientNextBlockRequest): Promise<RpcLightClientNextBlockResponse>;
|
28
|
-
query(params?: RpcQueryRequest): Promise<RpcQueryResponse>;
|
29
|
-
sendTx(params?: RpcSendTransactionRequest): Promise<RpcTransactionResponse>;
|
30
|
-
status(params?: RpcStatusRequest): Promise<RpcStatusResponse>;
|
31
|
-
tx(params?: RpcTransactionStatusRequest): Promise<RpcTransactionResponse>;
|
32
|
-
validators(params?: RpcValidatorRequest): Promise<RpcValidatorResponse>;
|
33
|
-
}
|
34
|
-
interface ConvenienceMethods {
|
35
|
-
viewAccount(params: {
|
36
|
-
accountId: string;
|
37
|
-
finality?: 'final' | 'near-final' | 'optimistic';
|
38
|
-
blockId?: string | number;
|
39
|
-
}): Promise<AccountView>;
|
40
|
-
viewFunction(params: {
|
41
|
-
accountId: string;
|
42
|
-
methodName: string;
|
43
|
-
argsBase64?: string;
|
44
|
-
finality?: 'final' | 'near-final' | 'optimistic';
|
45
|
-
blockId?: string | number;
|
46
|
-
}): Promise<CallResult>;
|
47
|
-
viewAccessKey(params: {
|
48
|
-
accountId: string;
|
49
|
-
publicKey: string;
|
50
|
-
finality?: 'final' | 'near-final' | 'optimistic';
|
51
|
-
blockId?: string | number;
|
52
|
-
}): Promise<AccessKeyView>;
|
53
|
-
}
|
54
|
-
interface CompleteClientInterface extends DynamicRpcMethods, ConvenienceMethods {
|
55
|
-
call<TParams = unknown, TResult = unknown>(method: string, params?: TParams): Promise<TResult>;
|
56
|
-
}
|
57
|
-
|
58
|
-
type RpcMethod = (typeof RPC_METHODS)[number];
|
59
|
-
interface ClientConfig {
|
60
|
-
endpoint: string;
|
61
|
-
headers?: Record<string, string>;
|
62
|
-
timeout?: number;
|
63
|
-
retries?: number;
|
64
|
-
validateResponses?: boolean;
|
65
|
-
}
|
66
|
-
interface JsonRpcRequest<T = unknown> {
|
67
|
-
jsonrpc: '2.0';
|
68
|
-
id: string;
|
69
|
-
method: string;
|
70
|
-
params?: T;
|
71
|
-
}
|
72
|
-
interface JsonRpcResponse<T = unknown> {
|
73
|
-
jsonrpc: '2.0';
|
74
|
-
id: string;
|
75
|
-
result?: T;
|
76
|
-
error?: JsonRpcError;
|
77
|
-
}
|
78
|
-
interface JsonRpcError {
|
79
|
-
code: number;
|
80
|
-
message: string;
|
81
|
-
data?: unknown;
|
82
|
-
}
|
83
|
-
declare class JsonRpcClientError extends Error {
|
84
|
-
code?: number | undefined;
|
85
|
-
data?: unknown | undefined;
|
86
|
-
constructor(message: string, code?: number | undefined, data?: unknown | undefined);
|
87
|
-
}
|
88
|
-
declare class JsonRpcNetworkError extends Error {
|
89
|
-
originalError: Error;
|
90
|
-
constructor(message: string, originalError: Error);
|
91
|
-
}
|
92
|
-
|
93
|
-
declare class NearRpcClient {
|
94
|
-
private endpoint;
|
95
|
-
private headers;
|
96
|
-
private timeout;
|
97
|
-
private retries;
|
98
|
-
private validateResponses;
|
99
|
-
private requestIdCounter;
|
100
|
-
constructor(config: string | ClientConfig);
|
101
|
-
/**
|
102
|
-
* Generate a unique request ID
|
103
|
-
*/
|
104
|
-
private generateRequestId;
|
105
|
-
/**
|
106
|
-
* Make a raw JSON-RPC call
|
107
|
-
* This method is public to allow dynamic calls to any RPC method
|
108
|
-
*/
|
109
|
-
call<TParams = unknown, TResult = unknown>(method: RpcMethod, params?: TParams): Promise<TResult>;
|
110
|
-
}
|
111
|
-
interface NearRpcClient extends DynamicRpcMethods, ConvenienceMethods {
|
112
|
-
}
|
113
|
-
|
114
|
-
interface RpcRequest {
|
115
|
-
jsonrpc: '2.0';
|
116
|
-
id: string | number;
|
117
|
-
method: string;
|
118
|
-
params: unknown;
|
119
|
-
}
|
120
|
-
interface RpcResponse<T = unknown> {
|
121
|
-
jsonrpc: '2.0';
|
122
|
-
id: string | number;
|
123
|
-
result?: T;
|
124
|
-
error?: RpcError;
|
125
|
-
}
|
126
|
-
interface RpcError {
|
127
|
-
code: number;
|
128
|
-
message: string;
|
129
|
-
data?: unknown;
|
130
|
-
}
|
131
|
-
declare class NearRpcError extends Error {
|
132
|
-
code: number;
|
133
|
-
data?: unknown | undefined;
|
134
|
-
constructor(code: number, message: string, data?: unknown | undefined);
|
135
|
-
}
|
136
|
-
|
137
|
-
export { type ClientConfig, type CompleteClientInterface, type ConvenienceMethods, type DynamicRpcMethods, JsonRpcClientError, type JsonRpcError, JsonRpcNetworkError, type JsonRpcRequest, type JsonRpcResponse, NearRpcClient, NearRpcError, type RpcError, type RpcRequest, type RpcResponse, NearRpcClient as default };
|
1
|
+
export * from './client';
|
2
|
+
export * from './types';
|
3
|
+
export { NearRpcClient, defaultClient } from './client';
|
4
|
+
export type { DynamicRpcMethods, ConvenienceMethods, CompleteClientInterface, } from './generated-types';
|
5
|
+
export { JsonRpcRequestSchema, JsonRpcResponseSchema, } from '@near-js/jsonrpc-types';
|
6
|
+
export { RPC_METHODS } from '@near-js/jsonrpc-types';
|
7
|
+
export * from './generated-functions';
|
8
|
+
export { enableValidation } from './validation.js';
|
9
|
+
export { NearRpcClient as default } from './client';
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AAGxB,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGxD,YAAY,EACV,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAGrD,cAAc,uBAAuB,CAAC;AAGtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAGnD,OAAO,EAAE,aAAa,IAAI,OAAO,EAAE,MAAM,UAAU,CAAC"}
|