@psalomo/jsonrpc-client 1.0.3 → 1.2.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 +69 -19
- package/dist/browser-standalone.js +804 -37
- package/dist/browser-standalone.min.js +1 -1
- package/dist/chunk-GCIU6ZLN.mjs +395 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/convenience-DFvZCHOk.d.mts +212 -0
- package/dist/convenience-DFvZCHOk.d.ts +212 -0
- package/dist/convenience.d.ts +9 -1
- package/dist/convenience.d.ts.map +1 -1
- package/dist/generated-types.d.ts +1 -1
- package/dist/index.d.mts +23 -172
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +646 -51
- package/dist/index.mjs +684 -331
- package/dist/no-validation/index.d.mts +6 -0
- package/dist/no-validation/index.d.ts +9 -0
- package/dist/no-validation/index.d.ts.map +1 -0
- package/dist/no-validation/index.js +471 -0
- package/dist/no-validation/index.mjs +95 -0
- package/dist/validated/index.d.ts +54 -0
- package/dist/validated/index.d.ts.map +1 -0
- package/dist/validation.d.ts.map +1 -1
- package/package.json +7 -2
@@ -0,0 +1,212 @@
|
|
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, MaintenanceWindowsResponse, RpcNetworkInfoRequest, RpcNetworkInfoResponse, RpcLightClientNextBlockRequest, RpcLightClientNextBlockResponse, RpcQueryRequest, RpcQueryResponse, RpcStatusRequest, RpcStatusResponse, RpcValidatorRequest, RpcValidatorResponse, AccountView, CallResult, AccessKeyView } from '@psalomo/jsonrpc-types';
|
2
|
+
|
3
|
+
interface ValidationResult {
|
4
|
+
validateRequest: (request: JsonRpcRequest) => void;
|
5
|
+
validateResponse: (response: JsonRpcResponse) => void;
|
6
|
+
validateMethodRequest?: (method: string, request: JsonRpcRequest) => void;
|
7
|
+
validateMethodResponse?: (method: string, response: JsonRpcResponse) => void;
|
8
|
+
}
|
9
|
+
/**
|
10
|
+
* Enable validation for the client
|
11
|
+
* This function should only be called if you want to include schema validation
|
12
|
+
* Calling this function will include Zod schemas in your bundle
|
13
|
+
*/
|
14
|
+
declare function enableValidation(): ValidationResult;
|
15
|
+
|
16
|
+
interface ClientConfig {
|
17
|
+
endpoint: string;
|
18
|
+
headers?: Record<string, string>;
|
19
|
+
timeout?: number;
|
20
|
+
retries?: number;
|
21
|
+
validation?: ValidationResult;
|
22
|
+
}
|
23
|
+
interface JsonRpcRequest<T = unknown> {
|
24
|
+
jsonrpc: '2.0';
|
25
|
+
id: string;
|
26
|
+
method: string;
|
27
|
+
params?: T;
|
28
|
+
}
|
29
|
+
interface JsonRpcResponse<T = unknown> {
|
30
|
+
jsonrpc: '2.0';
|
31
|
+
id: string;
|
32
|
+
result?: T;
|
33
|
+
error?: JsonRpcError;
|
34
|
+
}
|
35
|
+
interface JsonRpcError {
|
36
|
+
code: number;
|
37
|
+
message: string;
|
38
|
+
data?: unknown;
|
39
|
+
}
|
40
|
+
declare class JsonRpcClientError extends Error {
|
41
|
+
code?: number | undefined;
|
42
|
+
data?: unknown | undefined;
|
43
|
+
constructor(message: string, code?: number | undefined, data?: unknown | undefined);
|
44
|
+
}
|
45
|
+
declare class JsonRpcNetworkError extends Error {
|
46
|
+
originalError?: Error | undefined;
|
47
|
+
responseBody?: unknown | undefined;
|
48
|
+
constructor(message: string, originalError?: Error | undefined, responseBody?: unknown | undefined);
|
49
|
+
}
|
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
|
+
*/
|
55
|
+
declare class NearRpcClient {
|
56
|
+
readonly endpoint: string;
|
57
|
+
readonly headers: Record<string, string>;
|
58
|
+
readonly timeout: number;
|
59
|
+
readonly retries: number;
|
60
|
+
private readonly validation;
|
61
|
+
constructor(config: string | ClientConfig);
|
62
|
+
/**
|
63
|
+
* Make a raw JSON-RPC request
|
64
|
+
* This is used internally by the standalone RPC functions
|
65
|
+
*/
|
66
|
+
makeRequest<TParams = unknown, TResult = unknown>(method: string, params?: TParams): Promise<TResult>;
|
67
|
+
/**
|
68
|
+
* Create a new client with modified configuration
|
69
|
+
*/
|
70
|
+
withConfig(config: Partial<ClientConfig>): NearRpcClient;
|
71
|
+
}
|
72
|
+
declare const defaultClient: NearRpcClient;
|
73
|
+
|
74
|
+
interface RpcRequest {
|
75
|
+
jsonrpc: '2.0';
|
76
|
+
id: string | number;
|
77
|
+
method: string;
|
78
|
+
params: unknown;
|
79
|
+
}
|
80
|
+
interface RpcResponse<T = unknown> {
|
81
|
+
jsonrpc: '2.0';
|
82
|
+
id: string | number;
|
83
|
+
result?: T;
|
84
|
+
error?: RpcError;
|
85
|
+
}
|
86
|
+
interface RpcError {
|
87
|
+
code: number;
|
88
|
+
message: string;
|
89
|
+
data?: unknown;
|
90
|
+
}
|
91
|
+
declare class NearRpcError extends Error {
|
92
|
+
code: number;
|
93
|
+
data?: unknown | undefined;
|
94
|
+
constructor(code: number, message: string, data?: unknown | undefined);
|
95
|
+
}
|
96
|
+
|
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
|
+
blockEffects(params?: RpcStateChangesInBlockRequest): Promise<RpcStateChangesInBlockByTypeResponse>;
|
112
|
+
broadcastTxAsync(params?: RpcSendTransactionRequest): Promise<CryptoHash>;
|
113
|
+
broadcastTxCommit(params?: RpcSendTransactionRequest): Promise<RpcTransactionResponse>;
|
114
|
+
changes(params?: RpcStateChangesInBlockByTypeRequest): Promise<RpcStateChangesInBlockResponse>;
|
115
|
+
chunk(params?: RpcChunkRequest): Promise<RpcChunkResponse>;
|
116
|
+
clientConfig(params?: RpcClientConfigRequest): Promise<RpcClientConfigResponse>;
|
117
|
+
gasPrice(params?: RpcGasPriceRequest): Promise<RpcGasPriceResponse>;
|
118
|
+
genesisConfig(params?: GenesisConfigRequest): Promise<GenesisConfig>;
|
119
|
+
health(params?: RpcHealthRequest): Promise<RpcHealthResponse>;
|
120
|
+
lightClientProof(params?: RpcLightClientExecutionProofRequest): Promise<RpcLightClientExecutionProofResponse>;
|
121
|
+
maintenanceWindows(params?: RpcMaintenanceWindowsRequest): Promise<MaintenanceWindowsResponse>;
|
122
|
+
networkInfo(params?: RpcNetworkInfoRequest): Promise<RpcNetworkInfoResponse>;
|
123
|
+
nextLightClientBlock(params?: RpcLightClientNextBlockRequest): Promise<RpcLightClientNextBlockResponse>;
|
124
|
+
query(params?: RpcQueryRequest): Promise<RpcQueryResponse>;
|
125
|
+
sendTx(params?: RpcSendTransactionRequest): Promise<RpcTransactionResponse>;
|
126
|
+
status(params?: RpcStatusRequest): Promise<RpcStatusResponse>;
|
127
|
+
tx(params?: RpcTransactionStatusRequest): Promise<RpcTransactionResponse>;
|
128
|
+
validators(params?: RpcValidatorRequest): Promise<RpcValidatorResponse>;
|
129
|
+
}
|
130
|
+
interface ConvenienceMethods {
|
131
|
+
viewAccount(params: {
|
132
|
+
accountId: string;
|
133
|
+
finality?: 'final' | 'near-final' | 'optimistic';
|
134
|
+
blockId?: string | number;
|
135
|
+
}): Promise<AccountView>;
|
136
|
+
viewFunction(params: {
|
137
|
+
accountId: string;
|
138
|
+
methodName: string;
|
139
|
+
argsBase64?: string;
|
140
|
+
finality?: 'final' | 'near-final' | 'optimistic';
|
141
|
+
blockId?: string | number;
|
142
|
+
}): Promise<CallResult>;
|
143
|
+
viewAccessKey(params: {
|
144
|
+
accountId: string;
|
145
|
+
publicKey: string;
|
146
|
+
finality?: 'final' | 'near-final' | 'optimistic';
|
147
|
+
blockId?: string | number;
|
148
|
+
}): Promise<AccessKeyView>;
|
149
|
+
}
|
150
|
+
interface CompleteClientInterface extends DynamicRpcMethods, ConvenienceMethods {
|
151
|
+
call<TParams = unknown, TResult = unknown>(method: string, params?: TParams): Promise<TResult>;
|
152
|
+
}
|
153
|
+
declare function experimentalChanges(client: NearRpcClient, params?: RpcStateChangesInBlockByTypeRequest): Promise<RpcStateChangesInBlockResponse>;
|
154
|
+
declare function experimentalChangesInBlock(client: NearRpcClient, params?: RpcStateChangesInBlockRequest): Promise<RpcStateChangesInBlockByTypeResponse>;
|
155
|
+
declare function experimentalCongestionLevel(client: NearRpcClient, params?: RpcCongestionLevelRequest): Promise<RpcCongestionLevelResponse>;
|
156
|
+
declare function experimentalGenesisConfig(client: NearRpcClient, params?: GenesisConfigRequest): Promise<GenesisConfig>;
|
157
|
+
declare function experimentalLightClientBlockProof(client: NearRpcClient, params?: RpcLightClientBlockProofRequest): Promise<RpcLightClientBlockProofResponse>;
|
158
|
+
declare function experimentalLightClientProof(client: NearRpcClient, params?: RpcLightClientExecutionProofRequest): Promise<RpcLightClientExecutionProofResponse>;
|
159
|
+
declare function experimentalMaintenanceWindows(client: NearRpcClient, params?: RpcMaintenanceWindowsRequest): Promise<EXPERIMENTALMaintenanceWindowsResponse>;
|
160
|
+
declare function experimentalProtocolConfig(client: NearRpcClient, params?: RpcProtocolConfigRequest): Promise<RpcProtocolConfigResponse>;
|
161
|
+
declare function experimentalReceipt(client: NearRpcClient, params?: RpcReceiptRequest): Promise<RpcReceiptResponse>;
|
162
|
+
declare function experimentalSplitStorageInfo(client: NearRpcClient, params?: RpcSplitStorageInfoRequest): Promise<RpcSplitStorageInfoResponse>;
|
163
|
+
declare function experimentalTxStatus(client: NearRpcClient, params?: RpcTransactionStatusRequest): Promise<RpcTransactionResponse>;
|
164
|
+
declare function experimentalValidatorsOrdered(client: NearRpcClient, params?: RpcValidatorsOrderedRequest): Promise<EXPERIMENTALValidatorsOrderedResponse>;
|
165
|
+
declare function block(client: NearRpcClient, params?: RpcBlockRequest): Promise<RpcBlockResponse>;
|
166
|
+
declare function blockEffects(client: NearRpcClient, params?: RpcStateChangesInBlockRequest): Promise<RpcStateChangesInBlockByTypeResponse>;
|
167
|
+
declare function broadcastTxAsync(client: NearRpcClient, params?: RpcSendTransactionRequest): Promise<CryptoHash>;
|
168
|
+
declare function broadcastTxCommit(client: NearRpcClient, params?: RpcSendTransactionRequest): Promise<RpcTransactionResponse>;
|
169
|
+
declare function changes(client: NearRpcClient, params?: RpcStateChangesInBlockByTypeRequest): Promise<RpcStateChangesInBlockResponse>;
|
170
|
+
declare function chunk(client: NearRpcClient, params?: RpcChunkRequest): Promise<RpcChunkResponse>;
|
171
|
+
declare function clientConfig(client: NearRpcClient, params?: RpcClientConfigRequest): Promise<RpcClientConfigResponse>;
|
172
|
+
declare function gasPrice(client: NearRpcClient, params?: RpcGasPriceRequest): Promise<RpcGasPriceResponse>;
|
173
|
+
declare function genesisConfig(client: NearRpcClient, params?: GenesisConfigRequest): Promise<GenesisConfig>;
|
174
|
+
declare function health(client: NearRpcClient, params?: RpcHealthRequest): Promise<RpcHealthResponse>;
|
175
|
+
declare function lightClientProof(client: NearRpcClient, params?: RpcLightClientExecutionProofRequest): Promise<RpcLightClientExecutionProofResponse>;
|
176
|
+
declare function maintenanceWindows(client: NearRpcClient, params?: RpcMaintenanceWindowsRequest): Promise<MaintenanceWindowsResponse>;
|
177
|
+
declare function networkInfo(client: NearRpcClient, params?: RpcNetworkInfoRequest): Promise<RpcNetworkInfoResponse>;
|
178
|
+
declare function nextLightClientBlock(client: NearRpcClient, params?: RpcLightClientNextBlockRequest): Promise<RpcLightClientNextBlockResponse>;
|
179
|
+
declare function query(client: NearRpcClient, params?: RpcQueryRequest): Promise<RpcQueryResponse>;
|
180
|
+
declare function sendTx(client: NearRpcClient, params?: RpcSendTransactionRequest): Promise<RpcTransactionResponse>;
|
181
|
+
declare function status(client: NearRpcClient, params?: RpcStatusRequest): Promise<RpcStatusResponse>;
|
182
|
+
declare function tx(client: NearRpcClient, params?: RpcTransactionStatusRequest): Promise<RpcTransactionResponse>;
|
183
|
+
declare function validators(client: NearRpcClient, params?: RpcValidatorRequest): Promise<RpcValidatorResponse>;
|
184
|
+
|
185
|
+
declare function viewAccount(client: NearRpcClient, params: {
|
186
|
+
accountId: string;
|
187
|
+
finality?: 'final' | 'near-final' | 'optimistic';
|
188
|
+
blockId?: string | number;
|
189
|
+
}): Promise<AccountView>;
|
190
|
+
declare function viewFunction(client: NearRpcClient, params: {
|
191
|
+
accountId: string;
|
192
|
+
methodName: string;
|
193
|
+
argsBase64?: string;
|
194
|
+
finality?: 'final' | 'near-final' | 'optimistic';
|
195
|
+
blockId?: string | number;
|
196
|
+
}): Promise<CallResult>;
|
197
|
+
declare function viewAccessKey(client: NearRpcClient, params: {
|
198
|
+
accountId: string;
|
199
|
+
publicKey: string;
|
200
|
+
finality?: 'final' | 'near-final' | 'optimistic';
|
201
|
+
blockId?: string | number;
|
202
|
+
}): Promise<AccessKeyView>;
|
203
|
+
declare function parseCallResultToJson<T = unknown>(callResult: CallResult): T;
|
204
|
+
declare function viewFunctionAsJson<T = unknown>(client: NearRpcClient, params: {
|
205
|
+
accountId: string;
|
206
|
+
methodName: string;
|
207
|
+
argsBase64?: string;
|
208
|
+
finality?: 'final' | 'near-final' | 'optimistic';
|
209
|
+
blockId?: string | number;
|
210
|
+
}): Promise<T>;
|
211
|
+
|
212
|
+
export { blockEffects as A, broadcastTxAsync as B, type ConvenienceMethods as C, type DynamicRpcMethods as D, broadcastTxCommit as E, changes as F, chunk as G, clientConfig as H, gasPrice as I, type JsonRpcRequest as J, genesisConfig as K, health as L, lightClientProof as M, NearRpcClient as N, maintenanceWindows as O, networkInfo as P, nextLightClientBlock as Q, type RpcRequest as R, query as S, sendTx as T, status as U, tx as V, validators as W, viewAccount as X, viewFunction as Y, viewAccessKey as Z, type CompleteClientInterface as a, type ClientConfig as b, type JsonRpcResponse as c, defaultClient as d, enableValidation as e, type JsonRpcError as f, JsonRpcClientError as g, JsonRpcNetworkError as h, type RpcResponse as i, type RpcError as j, NearRpcError as k, experimentalChanges as l, experimentalChangesInBlock as m, experimentalCongestionLevel as n, experimentalGenesisConfig as o, parseCallResultToJson as p, experimentalLightClientBlockProof as q, experimentalLightClientProof as r, experimentalMaintenanceWindows as s, experimentalProtocolConfig as t, experimentalReceipt as u, viewFunctionAsJson as v, experimentalSplitStorageInfo as w, experimentalTxStatus as x, experimentalValidatorsOrdered as y, block as z };
|
package/dist/convenience.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { NearRpcClient } from './client.js';
|
2
|
-
import type { AccountView, CallResult, AccessKeyView } from '@
|
2
|
+
import type { AccountView, CallResult, AccessKeyView } from '@psalomo/jsonrpc-types';
|
3
3
|
export declare function viewAccount(client: NearRpcClient, params: {
|
4
4
|
accountId: string;
|
5
5
|
finality?: 'final' | 'near-final' | 'optimistic';
|
@@ -18,4 +18,12 @@ export declare function viewAccessKey(client: NearRpcClient, params: {
|
|
18
18
|
finality?: 'final' | 'near-final' | 'optimistic';
|
19
19
|
blockId?: string | number;
|
20
20
|
}): Promise<AccessKeyView>;
|
21
|
+
export declare function parseCallResultToJson<T = unknown>(callResult: CallResult): T;
|
22
|
+
export declare function viewFunctionAsJson<T = unknown>(client: NearRpcClient, params: {
|
23
|
+
accountId: string;
|
24
|
+
methodName: string;
|
25
|
+
argsBase64?: string;
|
26
|
+
finality?: 'final' | 'near-final' | 'optimistic';
|
27
|
+
blockId?: string | number;
|
28
|
+
}): Promise<T>;
|
21
29
|
//# sourceMappingURL=convenience.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"convenience.d.ts","sourceRoot":"","sources":["../src/convenience.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,aAAa,EACd,MAAM,wBAAwB,CAAC;AAEhC,wBAAsB,WAAW,CAC/B,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE;IACN,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,GAAG,YAAY,GAAG,YAAY,CAAC;IACjD,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC3B,GACA,OAAO,CAAC,WAAW,CAAC,CAetB;AAED,wBAAsB,YAAY,CAChC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE;IACN,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,GAAG,YAAY,GAAG,YAAY,CAAC;IACjD,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC3B,GACA,OAAO,CAAC,UAAU,CAAC,CAcrB;AAED,wBAAsB,aAAa,CACjC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE;IACN,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,GAAG,YAAY,GAAG,YAAY,CAAC;IACjD,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC3B,GACA,OAAO,CAAC,aAAa,CAAC,CAiBxB"}
|
1
|
+
{"version":3,"file":"convenience.d.ts","sourceRoot":"","sources":["../src/convenience.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,aAAa,EACd,MAAM,wBAAwB,CAAC;AAEhC,wBAAsB,WAAW,CAC/B,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE;IACN,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,GAAG,YAAY,GAAG,YAAY,CAAC;IACjD,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC3B,GACA,OAAO,CAAC,WAAW,CAAC,CAetB;AAED,wBAAsB,YAAY,CAChC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE;IACN,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,GAAG,YAAY,GAAG,YAAY,CAAC;IACjD,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC3B,GACA,OAAO,CAAC,UAAU,CAAC,CAcrB;AAED,wBAAsB,aAAa,CACjC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE;IACN,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,GAAG,YAAY,GAAG,YAAY,CAAC;IACjD,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC3B,GACA,OAAO,CAAC,aAAa,CAAC,CAiBxB;AAED,wBAAgB,qBAAqB,CAAC,CAAC,GAAG,OAAO,EAAE,UAAU,EAAE,UAAU,GAAG,CAAC,CAI5E;AAED,wBAAsB,kBAAkB,CAAC,CAAC,GAAG,OAAO,EAClD,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE;IACN,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,GAAG,YAAY,GAAG,YAAY,CAAC;IACjD,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC3B,GACA,OAAO,CAAC,CAAC,CAAC,CAGZ"}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { AccessKeyView, AccountView, CallResult, CryptoHash, EXPERIMENTALMaintenanceWindowsResponse, EXPERIMENTALValidatorsOrderedResponse, GenesisConfig, GenesisConfigRequest, MaintenanceWindowsResponse, RpcBlockRequest, RpcBlockResponse, RpcChunkRequest, RpcChunkResponse, RpcClientConfigRequest, RpcClientConfigResponse, RpcCongestionLevelRequest, RpcCongestionLevelResponse, RpcGasPriceRequest, RpcGasPriceResponse, RpcHealthRequest, RpcHealthResponse, RpcLightClientBlockProofRequest, RpcLightClientBlockProofResponse, RpcLightClientExecutionProofRequest, RpcLightClientExecutionProofResponse, RpcLightClientNextBlockRequest, RpcLightClientNextBlockResponse, RpcMaintenanceWindowsRequest, RpcNetworkInfoRequest, RpcNetworkInfoResponse, RpcProtocolConfigRequest, RpcProtocolConfigResponse, RpcQueryRequest, RpcQueryResponse, RpcReceiptRequest, RpcReceiptResponse, RpcSendTransactionRequest, RpcSplitStorageInfoRequest, RpcSplitStorageInfoResponse, RpcStateChangesInBlockByTypeRequest, RpcStateChangesInBlockByTypeResponse, RpcStateChangesInBlockRequest, RpcStateChangesInBlockResponse, RpcStatusRequest, RpcStatusResponse, RpcTransactionResponse, RpcTransactionStatusRequest, RpcValidatorRequest, RpcValidatorResponse, RpcValidatorsOrderedRequest } from '@
|
1
|
+
import type { AccessKeyView, AccountView, CallResult, CryptoHash, EXPERIMENTALMaintenanceWindowsResponse, EXPERIMENTALValidatorsOrderedResponse, GenesisConfig, GenesisConfigRequest, MaintenanceWindowsResponse, RpcBlockRequest, RpcBlockResponse, RpcChunkRequest, RpcChunkResponse, RpcClientConfigRequest, RpcClientConfigResponse, RpcCongestionLevelRequest, RpcCongestionLevelResponse, RpcGasPriceRequest, RpcGasPriceResponse, RpcHealthRequest, RpcHealthResponse, RpcLightClientBlockProofRequest, RpcLightClientBlockProofResponse, RpcLightClientExecutionProofRequest, RpcLightClientExecutionProofResponse, RpcLightClientNextBlockRequest, RpcLightClientNextBlockResponse, RpcMaintenanceWindowsRequest, RpcNetworkInfoRequest, RpcNetworkInfoResponse, RpcProtocolConfigRequest, RpcProtocolConfigResponse, RpcQueryRequest, RpcQueryResponse, RpcReceiptRequest, RpcReceiptResponse, RpcSendTransactionRequest, RpcSplitStorageInfoRequest, RpcSplitStorageInfoResponse, RpcStateChangesInBlockByTypeRequest, RpcStateChangesInBlockByTypeResponse, RpcStateChangesInBlockRequest, RpcStateChangesInBlockResponse, RpcStatusRequest, RpcStatusResponse, RpcTransactionResponse, RpcTransactionStatusRequest, RpcValidatorRequest, RpcValidatorResponse, RpcValidatorsOrderedRequest } from '@psalomo/jsonrpc-types';
|
2
2
|
import type { NearRpcClient } from './client';
|
3
3
|
export interface DynamicRpcMethods {
|
4
4
|
experimentalChanges(params?: RpcStateChangesInBlockByTypeRequest): Promise<RpcStateChangesInBlockResponse>;
|
package/dist/index.d.mts
CHANGED
@@ -1,156 +1,26 @@
|
|
1
|
-
import {
|
2
|
-
export {
|
1
|
+
import { N as NearRpcClient } from './convenience-DFvZCHOk.mjs';
|
2
|
+
export { b as ClientConfig, a as CompleteClientInterface, C as ConvenienceMethods, D as DynamicRpcMethods, g as JsonRpcClientError, f as JsonRpcError, h as JsonRpcNetworkError, J as JsonRpcRequest, c as JsonRpcResponse, k as NearRpcError, j as RpcError, R as RpcRequest, i as RpcResponse, d as defaultClient, e as enableValidation, p as parseCallResultToJson, v as viewFunctionAsJson } from './convenience-DFvZCHOk.mjs';
|
3
|
+
import { AccountView, CallResult, AccessKeyView, 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, MaintenanceWindowsResponse, RpcNetworkInfoRequest, RpcNetworkInfoResponse, RpcLightClientNextBlockRequest, RpcLightClientNextBlockResponse, RpcQueryRequest, RpcQueryResponse, RpcStatusRequest, RpcStatusResponse, RpcValidatorRequest, RpcValidatorResponse } from '@psalomo/jsonrpc-types';
|
4
|
+
export { JsonRpcRequestSchema, JsonRpcResponseSchema, RPC_METHODS } from '@psalomo/jsonrpc-types';
|
3
5
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
validation?: ValidationResult;
|
23
|
-
}
|
24
|
-
interface JsonRpcRequest<T = unknown> {
|
25
|
-
jsonrpc: '2.0';
|
26
|
-
id: string;
|
27
|
-
method: string;
|
28
|
-
params?: T;
|
29
|
-
}
|
30
|
-
interface JsonRpcResponse<T = unknown> {
|
31
|
-
jsonrpc: '2.0';
|
32
|
-
id: string;
|
33
|
-
result?: T;
|
34
|
-
error?: JsonRpcError;
|
35
|
-
}
|
36
|
-
interface JsonRpcError {
|
37
|
-
code: number;
|
38
|
-
message: string;
|
39
|
-
data?: unknown;
|
40
|
-
}
|
41
|
-
declare class JsonRpcClientError extends Error {
|
42
|
-
code?: number | undefined;
|
43
|
-
data?: unknown | undefined;
|
44
|
-
constructor(message: string, code?: number | undefined, data?: unknown | undefined);
|
45
|
-
}
|
46
|
-
declare class JsonRpcNetworkError extends Error {
|
47
|
-
originalError?: Error | undefined;
|
48
|
-
responseBody?: unknown | undefined;
|
49
|
-
constructor(message: string, originalError?: Error | undefined, responseBody?: unknown | undefined);
|
50
|
-
}
|
51
|
-
/**
|
52
|
-
* NEAR RPC Client with static function architecture
|
53
|
-
* This client only holds configuration and provides a makeRequest method
|
54
|
-
* Individual RPC methods are provided as standalone functions that take this client as a parameter
|
55
|
-
*/
|
56
|
-
declare class NearRpcClient {
|
57
|
-
readonly endpoint: string;
|
58
|
-
readonly headers: Record<string, string>;
|
59
|
-
readonly timeout: number;
|
60
|
-
readonly retries: number;
|
61
|
-
private readonly validation;
|
62
|
-
constructor(config: string | ClientConfig);
|
63
|
-
/**
|
64
|
-
* Make a raw JSON-RPC request
|
65
|
-
* This is used internally by the standalone RPC functions
|
66
|
-
*/
|
67
|
-
makeRequest<TParams = unknown, TResult = unknown>(method: string, params?: TParams): Promise<TResult>;
|
68
|
-
/**
|
69
|
-
* Create a new client with modified configuration
|
70
|
-
*/
|
71
|
-
withConfig(config: Partial<ClientConfig>): NearRpcClient;
|
72
|
-
}
|
73
|
-
declare const defaultClient: NearRpcClient;
|
74
|
-
|
75
|
-
interface RpcRequest {
|
76
|
-
jsonrpc: '2.0';
|
77
|
-
id: string | number;
|
78
|
-
method: string;
|
79
|
-
params: unknown;
|
80
|
-
}
|
81
|
-
interface RpcResponse<T = unknown> {
|
82
|
-
jsonrpc: '2.0';
|
83
|
-
id: string | number;
|
84
|
-
result?: T;
|
85
|
-
error?: RpcError;
|
86
|
-
}
|
87
|
-
interface RpcError {
|
88
|
-
code: number;
|
89
|
-
message: string;
|
90
|
-
data?: unknown;
|
91
|
-
}
|
92
|
-
declare class NearRpcError extends Error {
|
93
|
-
code: number;
|
94
|
-
data?: unknown | undefined;
|
95
|
-
constructor(code: number, message: string, data?: unknown | undefined);
|
96
|
-
}
|
97
|
-
|
98
|
-
interface DynamicRpcMethods {
|
99
|
-
experimentalChanges(params?: RpcStateChangesInBlockByTypeRequest): Promise<RpcStateChangesInBlockResponse>;
|
100
|
-
experimentalChangesInBlock(params?: RpcStateChangesInBlockRequest): Promise<RpcStateChangesInBlockByTypeResponse>;
|
101
|
-
experimentalCongestionLevel(params?: RpcCongestionLevelRequest): Promise<RpcCongestionLevelResponse>;
|
102
|
-
experimentalGenesisConfig(params?: GenesisConfigRequest): Promise<GenesisConfig>;
|
103
|
-
experimentalLightClientBlockProof(params?: RpcLightClientBlockProofRequest): Promise<RpcLightClientBlockProofResponse>;
|
104
|
-
experimentalLightClientProof(params?: RpcLightClientExecutionProofRequest): Promise<RpcLightClientExecutionProofResponse>;
|
105
|
-
experimentalMaintenanceWindows(params?: RpcMaintenanceWindowsRequest): Promise<EXPERIMENTALMaintenanceWindowsResponse>;
|
106
|
-
experimentalProtocolConfig(params?: RpcProtocolConfigRequest): Promise<RpcProtocolConfigResponse>;
|
107
|
-
experimentalReceipt(params?: RpcReceiptRequest): Promise<RpcReceiptResponse>;
|
108
|
-
experimentalSplitStorageInfo(params?: RpcSplitStorageInfoRequest): Promise<RpcSplitStorageInfoResponse>;
|
109
|
-
experimentalTxStatus(params?: RpcTransactionStatusRequest): Promise<RpcTransactionResponse>;
|
110
|
-
experimentalValidatorsOrdered(params?: RpcValidatorsOrderedRequest): Promise<EXPERIMENTALValidatorsOrderedResponse>;
|
111
|
-
block(params?: RpcBlockRequest): Promise<RpcBlockResponse>;
|
112
|
-
blockEffects(params?: RpcStateChangesInBlockRequest): Promise<RpcStateChangesInBlockByTypeResponse>;
|
113
|
-
broadcastTxAsync(params?: RpcSendTransactionRequest): Promise<CryptoHash>;
|
114
|
-
broadcastTxCommit(params?: RpcSendTransactionRequest): Promise<RpcTransactionResponse>;
|
115
|
-
changes(params?: RpcStateChangesInBlockByTypeRequest): Promise<RpcStateChangesInBlockResponse>;
|
116
|
-
chunk(params?: RpcChunkRequest): Promise<RpcChunkResponse>;
|
117
|
-
clientConfig(params?: RpcClientConfigRequest): Promise<RpcClientConfigResponse>;
|
118
|
-
gasPrice(params?: RpcGasPriceRequest): Promise<RpcGasPriceResponse>;
|
119
|
-
genesisConfig(params?: GenesisConfigRequest): Promise<GenesisConfig>;
|
120
|
-
health(params?: RpcHealthRequest): Promise<RpcHealthResponse>;
|
121
|
-
lightClientProof(params?: RpcLightClientExecutionProofRequest): Promise<RpcLightClientExecutionProofResponse>;
|
122
|
-
maintenanceWindows(params?: RpcMaintenanceWindowsRequest): Promise<MaintenanceWindowsResponse>;
|
123
|
-
networkInfo(params?: RpcNetworkInfoRequest): Promise<RpcNetworkInfoResponse>;
|
124
|
-
nextLightClientBlock(params?: RpcLightClientNextBlockRequest): Promise<RpcLightClientNextBlockResponse>;
|
125
|
-
query(params?: RpcQueryRequest): Promise<RpcQueryResponse>;
|
126
|
-
sendTx(params?: RpcSendTransactionRequest): Promise<RpcTransactionResponse>;
|
127
|
-
status(params?: RpcStatusRequest): Promise<RpcStatusResponse>;
|
128
|
-
tx(params?: RpcTransactionStatusRequest): Promise<RpcTransactionResponse>;
|
129
|
-
validators(params?: RpcValidatorRequest): Promise<RpcValidatorResponse>;
|
130
|
-
}
|
131
|
-
interface ConvenienceMethods {
|
132
|
-
viewAccount(params: {
|
133
|
-
accountId: string;
|
134
|
-
finality?: 'final' | 'near-final' | 'optimistic';
|
135
|
-
blockId?: string | number;
|
136
|
-
}): Promise<AccountView>;
|
137
|
-
viewFunction(params: {
|
138
|
-
accountId: string;
|
139
|
-
methodName: string;
|
140
|
-
argsBase64?: string;
|
141
|
-
finality?: 'final' | 'near-final' | 'optimistic';
|
142
|
-
blockId?: string | number;
|
143
|
-
}): Promise<CallResult>;
|
144
|
-
viewAccessKey(params: {
|
145
|
-
accountId: string;
|
146
|
-
publicKey: string;
|
147
|
-
finality?: 'final' | 'near-final' | 'optimistic';
|
148
|
-
blockId?: string | number;
|
149
|
-
}): Promise<AccessKeyView>;
|
150
|
-
}
|
151
|
-
interface CompleteClientInterface extends DynamicRpcMethods, ConvenienceMethods {
|
152
|
-
call<TParams = unknown, TResult = unknown>(method: string, params?: TParams): Promise<TResult>;
|
153
|
-
}
|
6
|
+
declare function viewAccount(client: NearRpcClient, params: {
|
7
|
+
accountId: string;
|
8
|
+
finality?: 'final' | 'near-final' | 'optimistic';
|
9
|
+
blockId?: string | number;
|
10
|
+
}): Promise<AccountView>;
|
11
|
+
declare function viewFunction(client: NearRpcClient, params: {
|
12
|
+
accountId: string;
|
13
|
+
methodName: string;
|
14
|
+
argsBase64?: string;
|
15
|
+
finality?: 'final' | 'near-final' | 'optimistic';
|
16
|
+
blockId?: string | number;
|
17
|
+
}): Promise<CallResult>;
|
18
|
+
declare function viewAccessKey(client: NearRpcClient, params: {
|
19
|
+
accountId: string;
|
20
|
+
publicKey: string;
|
21
|
+
finality?: 'final' | 'near-final' | 'optimistic';
|
22
|
+
blockId?: string | number;
|
23
|
+
}): Promise<AccessKeyView>;
|
154
24
|
declare function experimentalChanges(client: NearRpcClient, params?: RpcStateChangesInBlockByTypeRequest): Promise<RpcStateChangesInBlockResponse>;
|
155
25
|
declare function experimentalChangesInBlock(client: NearRpcClient, params?: RpcStateChangesInBlockRequest): Promise<RpcStateChangesInBlockByTypeResponse>;
|
156
26
|
declare function experimentalCongestionLevel(client: NearRpcClient, params?: RpcCongestionLevelRequest): Promise<RpcCongestionLevelResponse>;
|
@@ -183,23 +53,4 @@ declare function status(client: NearRpcClient, params?: RpcStatusRequest): Promi
|
|
183
53
|
declare function tx(client: NearRpcClient, params?: RpcTransactionStatusRequest): Promise<RpcTransactionResponse>;
|
184
54
|
declare function validators(client: NearRpcClient, params?: RpcValidatorRequest): Promise<RpcValidatorResponse>;
|
185
55
|
|
186
|
-
|
187
|
-
accountId: string;
|
188
|
-
finality?: 'final' | 'near-final' | 'optimistic';
|
189
|
-
blockId?: string | number;
|
190
|
-
}): Promise<AccountView>;
|
191
|
-
declare function viewFunction(client: NearRpcClient, params: {
|
192
|
-
accountId: string;
|
193
|
-
methodName: string;
|
194
|
-
argsBase64?: string;
|
195
|
-
finality?: 'final' | 'near-final' | 'optimistic';
|
196
|
-
blockId?: string | number;
|
197
|
-
}): Promise<CallResult>;
|
198
|
-
declare function viewAccessKey(client: NearRpcClient, params: {
|
199
|
-
accountId: string;
|
200
|
-
publicKey: string;
|
201
|
-
finality?: 'final' | 'near-final' | 'optimistic';
|
202
|
-
blockId?: string | number;
|
203
|
-
}): Promise<AccessKeyView>;
|
204
|
-
|
205
|
-
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, blockEffects, broadcastTxAsync, broadcastTxCommit, changes, chunk, clientConfig, NearRpcClient as default, defaultClient, enableValidation, experimentalChanges, experimentalChangesInBlock, experimentalCongestionLevel, experimentalGenesisConfig, experimentalLightClientBlockProof, experimentalLightClientProof, experimentalMaintenanceWindows, experimentalProtocolConfig, experimentalReceipt, experimentalSplitStorageInfo, experimentalTxStatus, experimentalValidatorsOrdered, gasPrice, genesisConfig, health, lightClientProof, maintenanceWindows, networkInfo, nextLightClientBlock, query, sendTx, status, tx, validators, viewAccessKey, viewAccount, viewFunction };
|
56
|
+
export { NearRpcClient, block, blockEffects, broadcastTxAsync, broadcastTxCommit, changes, chunk, clientConfig, NearRpcClient as default, experimentalChanges, experimentalChangesInBlock, experimentalCongestionLevel, experimentalGenesisConfig, experimentalLightClientBlockProof, experimentalLightClientProof, experimentalMaintenanceWindows, experimentalProtocolConfig, experimentalReceipt, experimentalSplitStorageInfo, experimentalTxStatus, experimentalValidatorsOrdered, gasPrice, genesisConfig, health, lightClientProof, maintenanceWindows, networkInfo, nextLightClientBlock, query, sendTx, status, tx, validators, viewAccessKey, viewAccount, viewFunction };
|
package/dist/index.d.ts
CHANGED
@@ -2,9 +2,9 @@ export * from './client';
|
|
2
2
|
export * from './types';
|
3
3
|
export { NearRpcClient, defaultClient } from './client';
|
4
4
|
export type { DynamicRpcMethods, ConvenienceMethods, CompleteClientInterface, } from './generated-types';
|
5
|
-
export { JsonRpcRequestSchema, JsonRpcResponseSchema, } from '@
|
6
|
-
export { RPC_METHODS } from '@
|
7
|
-
export * from './
|
5
|
+
export { JsonRpcRequestSchema, JsonRpcResponseSchema, } from '@psalomo/jsonrpc-types';
|
6
|
+
export { RPC_METHODS } from '@psalomo/jsonrpc-types';
|
7
|
+
export * from './validated/index.js';
|
8
8
|
export { enableValidation } from './validation.js';
|
9
9
|
export { NearRpcClient as default } from './client';
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
@@ -1 +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,
|
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,sBAAsB,CAAC;AAGrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAGnD,OAAO,EAAE,aAAa,IAAI,OAAO,EAAE,MAAM,UAAU,CAAC"}
|