@psalomo/jsonrpc-client 1.0.2 → 1.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.
@@ -89,23 +89,31 @@ class NearRpcClient {
89
89
  * This is used internally by the standalone RPC functions
90
90
  */
91
91
  async makeRequest(method, params) {
92
- // Convert camelCase params to snake_case for the RPC call
93
- const snakeCaseParams = params ? convertKeysToSnakeCase(params) : params;
94
- const request = {
92
+ // Create request with original camelCase params for validation
93
+ const requestForValidation = {
95
94
  jsonrpc: '2.0',
96
95
  id: REQUEST_ID,
97
96
  method,
98
- params: snakeCaseParams,
97
+ params: params !== undefined ? params : null,
99
98
  };
100
- // Validate request if validation is enabled
99
+ // Validate request if validation is enabled (before snake_case conversion)
101
100
  if (this.validation) {
102
101
  if ('validateMethodRequest' in this.validation) {
103
- this.validation.validateMethodRequest(method, request);
102
+ this.validation.validateMethodRequest(method, requestForValidation);
104
103
  }
105
104
  else {
106
- this.validation.validateRequest(request);
105
+ this.validation.validateRequest(requestForValidation);
107
106
  }
108
107
  }
108
+ // Convert camelCase params to snake_case for the RPC call
109
+ // Also convert undefined to null for methods that expect null params
110
+ const snakeCaseParams = params !== undefined ? convertKeysToSnakeCase(params) : null;
111
+ const request = {
112
+ jsonrpc: '2.0',
113
+ id: REQUEST_ID,
114
+ method,
115
+ params: snakeCaseParams,
116
+ };
109
117
  let lastError = null;
110
118
  for (let attempt = 0; attempt <= this.retries; attempt++) {
111
119
  try {
@@ -148,6 +156,15 @@ class NearRpcClient {
148
156
  const camelCaseResult = jsonResponse.result
149
157
  ? convertKeysToCamelCase(jsonResponse.result)
150
158
  : jsonResponse.result;
159
+ // Check if the result contains an error field (non-standard NEAR RPC error response)
160
+ // This happens when validation is disabled and certain RPC errors occur
161
+ if (camelCaseResult &&
162
+ typeof camelCaseResult === 'object' &&
163
+ 'error' in camelCaseResult) {
164
+ const errorMessage = camelCaseResult.error;
165
+ throw new JsonRpcClientError(`RPC Error: ${errorMessage}`, -32000, // Generic RPC error code
166
+ camelCaseResult);
167
+ }
151
168
  // Validate method-specific response structure after camelCase conversion
152
169
  if (this.validation && 'validateMethodResponse' in this.validation) {
153
170
  // Create a camelCase version of the response for validation
@@ -1522,7 +1539,9 @@ var AccessKeyPermissionViewSchema = () => union([
1522
1539
  _enum(["FullAccess"]),
1523
1540
  object({
1524
1541
  FunctionCall: object({
1525
- allowance: optional(string()),
1542
+ allowance: optional(
1543
+ union([union([string(), _null()]), _null()])
1544
+ ),
1526
1545
  methodNames: array(string()),
1527
1546
  receiverId: string()
1528
1547
  })
@@ -1615,7 +1634,7 @@ var ActionCreationConfigViewSchema = () => object({
1615
1634
  transferCost: _lazy(() => FeeSchema())
1616
1635
  });
1617
1636
  var ActionErrorSchema = () => object({
1618
- index: optional(number()),
1637
+ index: optional(union([union([number(), _null()]), _null()])),
1619
1638
  kind: _lazy(() => ActionErrorKindSchema())
1620
1639
  });
1621
1640
  var ActionErrorKindSchema = () => union([
@@ -1903,10 +1922,14 @@ var BlockHeaderViewSchema = () => object({
1903
1922
  union([_lazy(() => CryptoHashSchema()), _null()])
1904
1923
  ),
1905
1924
  blockMerkleRoot: _lazy(() => CryptoHashSchema()),
1906
- blockOrdinal: optional(number()),
1925
+ blockOrdinal: optional(
1926
+ union([union([number(), _null()]), _null()])
1927
+ ),
1907
1928
  challengesResult: array(_lazy(() => SlashedValidatorSchema())),
1908
1929
  challengesRoot: _lazy(() => CryptoHashSchema()),
1909
- chunkEndorsements: optional(array(array(number()))),
1930
+ chunkEndorsements: optional(
1931
+ union([union([array(array(number())), _null()]), _null()])
1932
+ ),
1910
1933
  chunkHeadersRoot: _lazy(() => CryptoHashSchema()),
1911
1934
  chunkMask: array(boolean()),
1912
1935
  chunkReceiptsRoot: _lazy(() => CryptoHashSchema()),
@@ -1926,7 +1949,9 @@ var BlockHeaderViewSchema = () => object({
1926
1949
  nextEpochId: _lazy(() => CryptoHashSchema()),
1927
1950
  outcomeRoot: _lazy(() => CryptoHashSchema()),
1928
1951
  prevHash: _lazy(() => CryptoHashSchema()),
1929
- prevHeight: optional(number()),
1952
+ prevHeight: optional(
1953
+ union([union([number(), _null()]), _null()])
1954
+ ),
1930
1955
  prevStateRoot: _lazy(() => CryptoHashSchema()),
1931
1956
  randomValue: _lazy(() => CryptoHashSchema()),
1932
1957
  rentPaid: string(),
@@ -2089,12 +2114,19 @@ var DetailedDebugStatusSchema = () => object({
2089
2114
  });
2090
2115
  var DirectionSchema = () => _enum(["Left", "Right"]);
2091
2116
  var DumpConfigSchema = () => object({
2092
- credentialsFile: optional(string()),
2117
+ credentialsFile: optional(
2118
+ union([union([string(), _null()]), _null()])
2119
+ ),
2093
2120
  iterationDelay: optional(
2094
2121
  union([_lazy(() => DurationAsStdSchemaProviderSchema()), _null()])
2095
2122
  ),
2096
2123
  location: _lazy(() => ExternalStorageLocationSchema()),
2097
- restartDumpForShards: optional(array(_lazy(() => ShardIdSchema())))
2124
+ restartDumpForShards: optional(
2125
+ union([
2126
+ union([array(_lazy(() => ShardIdSchema())), _null()]),
2127
+ _null()
2128
+ ])
2129
+ )
2098
2130
  });
2099
2131
  var DurationAsStdSchemaProviderSchema = () => object({
2100
2132
  nanos: number(),
@@ -2108,7 +2140,12 @@ var EpochSyncConfigSchema = () => object({
2108
2140
  timeoutForEpochSync: _lazy(() => DurationAsStdSchemaProviderSchema())
2109
2141
  });
2110
2142
  var ExecutionMetadataViewSchema = () => object({
2111
- gasProfile: optional(array(_lazy(() => CostGasUsedSchema()))),
2143
+ gasProfile: optional(
2144
+ union([
2145
+ union([array(_lazy(() => CostGasUsedSchema())), _null()]),
2146
+ _null()
2147
+ ])
2148
+ ),
2112
2149
  version: number()
2113
2150
  });
2114
2151
  var ExecutionOutcomeViewSchema = () => object({
@@ -2311,7 +2348,7 @@ var FunctionCallErrorSchema = () => union([
2311
2348
  })
2312
2349
  ]);
2313
2350
  var FunctionCallPermissionSchema = () => object({
2314
- allowance: optional(string()),
2351
+ allowance: optional(union([union([string(), _null()]), _null()])),
2315
2352
  methodNames: array(string()),
2316
2353
  receiverId: string()
2317
2354
  });
@@ -2680,6 +2717,12 @@ var JsonRpcRequestForBlockSchema = () => object({
2680
2717
  method: _enum(["block"]),
2681
2718
  params: _lazy(() => RpcBlockRequestSchema())
2682
2719
  });
2720
+ var JsonRpcRequestForBlockEffectsSchema = () => object({
2721
+ id: string(),
2722
+ jsonrpc: string(),
2723
+ method: _enum(["block_effects"]),
2724
+ params: _lazy(() => RpcStateChangesInBlockRequestSchema())
2725
+ });
2683
2726
  var JsonRpcRequestForBroadcastTxAsyncSchema = () => object({
2684
2727
  id: string(),
2685
2728
  jsonrpc: string(),
@@ -2728,6 +2771,12 @@ var JsonRpcRequestForLightClientProofSchema = () => object({
2728
2771
  method: _enum(["light_client_proof"]),
2729
2772
  params: _lazy(() => RpcLightClientExecutionProofRequestSchema())
2730
2773
  });
2774
+ var JsonRpcRequestForMaintenanceWindowsSchema = () => object({
2775
+ id: string(),
2776
+ jsonrpc: string(),
2777
+ method: _enum(["maintenance_windows"]),
2778
+ params: _lazy(() => RpcMaintenanceWindowsRequestSchema())
2779
+ });
2731
2780
  var JsonRpcRequestForNetworkInfoSchema = () => object({
2732
2781
  id: string(),
2733
2782
  jsonrpc: string(),
@@ -3094,7 +3143,12 @@ var JsonRpcResponseFor_RpcValidatorResponseAnd_RpcErrorSchema = () => intersecti
3094
3143
  );
3095
3144
  var KnownProducerViewSchema = () => object({
3096
3145
  accountId: _lazy(() => AccountIdSchema()),
3097
- nextHops: optional(array(_lazy(() => PublicKeySchema()))),
3146
+ nextHops: optional(
3147
+ union([
3148
+ union([array(_lazy(() => PublicKeySchema())), _null()]),
3149
+ _null()
3150
+ ])
3151
+ ),
3098
3152
  peerId: _lazy(() => PublicKeySchema())
3099
3153
  });
3100
3154
  var LightClientBlockLiteViewSchema = () => object({
@@ -3110,13 +3164,17 @@ var LimitConfigSchema = () => object({
3110
3164
  maxActionsPerReceipt: number(),
3111
3165
  maxArgumentsLength: number(),
3112
3166
  maxContractSize: number(),
3113
- maxFunctionsNumberPerContract: optional(number()),
3167
+ maxFunctionsNumberPerContract: optional(
3168
+ union([union([number(), _null()]), _null()])
3169
+ ),
3114
3170
  maxGasBurnt: number(),
3115
3171
  maxLengthMethodName: number(),
3116
3172
  maxLengthReturnedData: number(),
3117
3173
  maxLengthStorageKey: number(),
3118
3174
  maxLengthStorageValue: number(),
3119
- maxLocalsPerContract: optional(number()),
3175
+ maxLocalsPerContract: optional(
3176
+ union([union([number(), _null()]), _null()])
3177
+ ),
3120
3178
  maxMemoryPages: number(),
3121
3179
  maxNumberBytesMethodNames: number(),
3122
3180
  maxNumberInputDataDependencies: number(),
@@ -3176,7 +3234,7 @@ var PeerInfoViewSchema = () => object({
3176
3234
  union([_lazy(() => CryptoHashSchema()), _null()])
3177
3235
  ),
3178
3236
  connectionEstablishedTimeMillis: number(),
3179
- height: optional(number()),
3237
+ height: optional(union([union([number(), _null()]), _null()])),
3180
3238
  isHighestBlockInvalid: boolean(),
3181
3239
  isOutboundPeer: boolean(),
3182
3240
  lastTimePeerRequestedMillis: number(),
@@ -3217,7 +3275,7 @@ var ReceiptEnumViewSchema = () => union([
3217
3275
  }),
3218
3276
  object({
3219
3277
  Data: object({
3220
- data: optional(string()),
3278
+ data: optional(union([union([string(), _null()]), _null()])),
3221
3279
  dataId: _lazy(() => CryptoHashSchema()),
3222
3280
  isPromiseResume: optional(boolean())
3223
3281
  })
@@ -3324,6 +3382,7 @@ var RpcClientConfigResponseSchema = () => object({
3324
3382
  union([_lazy(() => ChunkDistributionNetworkConfigSchema()), _null()])
3325
3383
  ),
3326
3384
  chunkRequestRetryPeriod: array(number()),
3385
+ chunkValidationThreads: number(),
3327
3386
  chunkWaitMult: array(number()),
3328
3387
  clientBackgroundMigrationThreads: number(),
3329
3388
  doomslugStepPeriod: array(number()),
@@ -3341,7 +3400,9 @@ var RpcClientConfigResponseSchema = () => object({
3341
3400
  logSummaryStyle: _lazy(() => LogSummaryStyleSchema()),
3342
3401
  maxBlockProductionDelay: array(number()),
3343
3402
  maxBlockWaitDelay: array(number()),
3344
- maxGasBurntView: optional(number()),
3403
+ maxGasBurntView: optional(
3404
+ union([union([number(), _null()]), _null()])
3405
+ ),
3345
3406
  minBlockProductionDelay: array(number()),
3346
3407
  minNumPeers: number(),
3347
3408
  numBlockProducerSeats: number(),
@@ -3350,12 +3411,15 @@ var RpcClientConfigResponseSchema = () => object({
3350
3411
  produceChunkAddTransactionsTimeLimit: string(),
3351
3412
  produceEmptyBlocks: boolean(),
3352
3413
  reshardingConfig: _lazy(() => MutableConfigValueSchema()),
3353
- rpcAddr: optional(string()),
3414
+ rpcAddr: optional(union([union([string(), _null()]), _null()])),
3354
3415
  saveInvalidWitnesses: boolean(),
3355
3416
  saveLatestWitnesses: boolean(),
3356
3417
  saveTrieChanges: boolean(),
3357
3418
  saveTxOutcomes: boolean(),
3358
3419
  skipSyncWait: boolean(),
3420
+ stateRequestServerThreads: number(),
3421
+ stateRequestThrottlePeriod: array(number()),
3422
+ stateRequestsPerThrottlePeriod: number(),
3359
3423
  stateSync: _lazy(() => StateSyncConfigSchema()),
3360
3424
  stateSyncEnabled: boolean(),
3361
3425
  stateSyncExternalBackoff: array(number()),
@@ -3367,15 +3431,17 @@ var RpcClientConfigResponseSchema = () => object({
3367
3431
  syncMaxBlockRequests: number(),
3368
3432
  syncStepPeriod: array(number()),
3369
3433
  trackedShardsConfig: _lazy(() => TrackedShardsConfigSchema()),
3370
- transactionPoolSizeLimit: optional(number()),
3434
+ transactionPoolSizeLimit: optional(
3435
+ union([union([number(), _null()]), _null()])
3436
+ ),
3371
3437
  transactionRequestHandlerThreads: number(),
3372
- trieViewerStateSizeLimit: optional(number()),
3438
+ trieViewerStateSizeLimit: optional(
3439
+ union([union([number(), _null()]), _null()])
3440
+ ),
3373
3441
  ttlAccountIdRouter: array(number()),
3374
3442
  txRoutingHeightHorizon: number(),
3375
3443
  version: _lazy(() => VersionSchema()),
3376
- viewClientNumStateRequestsPerThrottlePeriod: number(),
3377
- viewClientThreads: number(),
3378
- viewClientThrottlePeriod: array(number())
3444
+ viewClientThreads: number()
3379
3445
  });
3380
3446
  var RpcCongestionLevelRequestSchema = () => union([
3381
3447
  object({
@@ -3422,7 +3488,7 @@ var RpcHealthRequestSchema = () => _null();
3422
3488
  var RpcHealthResponseSchema = () => _null();
3423
3489
  var RpcKnownProducerSchema = () => object({
3424
3490
  accountId: _lazy(() => AccountIdSchema()),
3425
- addr: optional(string()),
3491
+ addr: optional(union([union([string(), _null()]), _null()])),
3426
3492
  peerId: _lazy(() => PeerIdSchema())
3427
3493
  });
3428
3494
  var RpcLightClientBlockProofRequestSchema = () => object({
@@ -3466,7 +3532,12 @@ var RpcLightClientNextBlockResponseSchema = () => object({
3466
3532
  innerLite: optional(_lazy(() => BlockHeaderInnerLiteViewSchema())),
3467
3533
  innerRestHash: optional(_lazy(() => CryptoHashSchema())),
3468
3534
  nextBlockInnerHash: optional(_lazy(() => CryptoHashSchema())),
3469
- nextBps: optional(array(_lazy(() => ValidatorStakeViewSchema()))),
3535
+ nextBps: optional(
3536
+ union([
3537
+ union([array(_lazy(() => ValidatorStakeViewSchema())), _null()]),
3538
+ _null()
3539
+ ])
3540
+ ),
3470
3541
  prevBlockHash: optional(_lazy(() => CryptoHashSchema()))
3471
3542
  });
3472
3543
  var RpcMaintenanceWindowsRequestSchema = () => object({
@@ -3483,7 +3554,7 @@ var RpcNetworkInfoResponseSchema = () => object({
3483
3554
  });
3484
3555
  var RpcPeerInfoSchema = () => object({
3485
3556
  accountId: optional(union([_lazy(() => AccountIdSchema()), _null()])),
3486
- addr: optional(string()),
3557
+ addr: optional(union([union([string(), _null()]), _null()])),
3487
3558
  id: _lazy(() => PeerIdSchema())
3488
3559
  });
3489
3560
  var RpcProtocolConfigRequestSchema = () => union([
@@ -3803,10 +3874,16 @@ var RpcSendTransactionRequestSchema = () => object({
3803
3874
  });
3804
3875
  var RpcSplitStorageInfoRequestSchema = () => record(string(), unknown());
3805
3876
  var RpcSplitStorageInfoResponseSchema = () => object({
3806
- coldHeadHeight: optional(number()),
3807
- finalHeadHeight: optional(number()),
3808
- headHeight: optional(number()),
3809
- hotDbKind: optional(string())
3877
+ coldHeadHeight: optional(
3878
+ union([union([number(), _null()]), _null()])
3879
+ ),
3880
+ finalHeadHeight: optional(
3881
+ union([union([number(), _null()]), _null()])
3882
+ ),
3883
+ headHeight: optional(
3884
+ union([union([number(), _null()]), _null()])
3885
+ ),
3886
+ hotDbKind: optional(union([union([string(), _null()]), _null()]))
3810
3887
  });
3811
3888
  var RpcStateChangesInBlockByTypeRequestSchema = () => union([
3812
3889
  intersection(
@@ -4032,7 +4109,7 @@ var RpcStatusResponseSchema = () => object({
4032
4109
  nodeKey: optional(union([_lazy(() => PublicKeySchema()), _null()])),
4033
4110
  nodePublicKey: _lazy(() => PublicKeySchema()),
4034
4111
  protocolVersion: number(),
4035
- rpcAddr: optional(string()),
4112
+ rpcAddr: optional(union([union([string(), _null()]), _null()])),
4036
4113
  syncInfo: _lazy(() => StatusSyncInfoSchema()),
4037
4114
  uptimeSec: number(),
4038
4115
  validatorAccountId: optional(
@@ -4115,8 +4192,18 @@ var ShardLayoutV0Schema = () => object({
4115
4192
  });
4116
4193
  var ShardLayoutV1Schema = () => object({
4117
4194
  boundaryAccounts: array(_lazy(() => AccountIdSchema())),
4118
- shardsSplitMap: optional(array(array(_lazy(() => ShardIdSchema())))),
4119
- toParentShardMap: optional(array(_lazy(() => ShardIdSchema()))),
4195
+ shardsSplitMap: optional(
4196
+ union([
4197
+ union([array(array(_lazy(() => ShardIdSchema()))), _null()]),
4198
+ _null()
4199
+ ])
4200
+ ),
4201
+ toParentShardMap: optional(
4202
+ union([
4203
+ union([array(_lazy(() => ShardIdSchema())), _null()]),
4204
+ _null()
4205
+ ])
4206
+ ),
4120
4207
  version: number()
4121
4208
  });
4122
4209
  var ShardLayoutV2Schema = () => object({
@@ -4128,13 +4215,25 @@ var ShardLayoutV2Schema = () => object({
4128
4215
  ),
4129
4216
  shardIds: array(_lazy(() => ShardIdSchema())),
4130
4217
  shardsParentMap: optional(
4131
- record(
4132
- string(),
4133
- _lazy(() => ShardIdSchema())
4134
- )
4218
+ union([
4219
+ union([
4220
+ record(
4221
+ string(),
4222
+ _lazy(() => ShardIdSchema())
4223
+ ),
4224
+ _null()
4225
+ ]),
4226
+ _null()
4227
+ ])
4135
4228
  ),
4136
4229
  shardsSplitMap: optional(
4137
- record(string(), array(_lazy(() => ShardIdSchema())))
4230
+ union([
4231
+ union([
4232
+ record(string(), array(_lazy(() => ShardIdSchema()))),
4233
+ _null()
4234
+ ]),
4235
+ _null()
4236
+ ])
4138
4237
  ),
4139
4238
  version: number()
4140
4239
  });
@@ -4334,10 +4433,16 @@ var StatusSyncInfoSchema = () => object({
4334
4433
  earliestBlockHash: optional(
4335
4434
  union([_lazy(() => CryptoHashSchema()), _null()])
4336
4435
  ),
4337
- earliestBlockHeight: optional(number()),
4338
- earliestBlockTime: optional(string()),
4436
+ earliestBlockHeight: optional(
4437
+ union([union([number(), _null()]), _null()])
4438
+ ),
4439
+ earliestBlockTime: optional(
4440
+ union([union([string(), _null()]), _null()])
4441
+ ),
4339
4442
  epochId: optional(union([_lazy(() => EpochIdSchema()), _null()])),
4340
- epochStartHeight: optional(number()),
4443
+ epochStartHeight: optional(
4444
+ union([union([number(), _null()]), _null()])
4445
+ ),
4341
4446
  latestBlockHash: _lazy(() => CryptoHashSchema()),
4342
4447
  latestBlockHeight: number(),
4343
4448
  latestBlockTime: string(),
@@ -4560,6 +4665,10 @@ var EXPERIMENTALValidatorsOrderedResponseSchema = () => _lazy(
4560
4665
  );
4561
4666
  var BlockRequestSchema = () => _lazy(() => JsonRpcRequestForBlockSchema());
4562
4667
  var BlockResponseSchema = () => _lazy(() => JsonRpcResponseFor_RpcBlockResponseAnd_RpcErrorSchema());
4668
+ var BlockEffectsRequestSchema = () => _lazy(() => JsonRpcRequestForBlockEffectsSchema());
4669
+ var BlockEffectsResponseSchema = () => _lazy(
4670
+ () => JsonRpcResponseFor_RpcStateChangesInBlockByTypeResponseAnd_RpcErrorSchema()
4671
+ );
4563
4672
  var BroadcastTxAsyncRequestSchema = () => _lazy(() => JsonRpcRequestForBroadcastTxAsyncSchema());
4564
4673
  var BroadcastTxAsyncResponseSchema = () => _lazy(() => JsonRpcResponseFor_CryptoHashAnd_RpcErrorSchema());
4565
4674
  var BroadcastTxCommitRequestSchema = () => _lazy(() => JsonRpcRequestForBroadcastTxCommitSchema());
@@ -4574,6 +4683,7 @@ var ClientConfigRequestSchema = () => _lazy(() => JsonRpcRequestForClientConfigS
4574
4683
  var ClientConfigResponseSchema = () => _lazy(() => JsonRpcResponseFor_RpcClientConfigResponseAnd_RpcErrorSchema());
4575
4684
  var GasPriceRequestSchema = () => _lazy(() => JsonRpcRequestForGasPriceSchema());
4576
4685
  var GasPriceResponseSchema = () => _lazy(() => JsonRpcResponseFor_RpcGasPriceResponseAnd_RpcErrorSchema());
4686
+ var GenesisConfigResponseSchema = () => _lazy(() => JsonRpcResponseFor_GenesisConfigAnd_RpcErrorSchema());
4577
4687
  var HealthRequestSchema = () => _lazy(() => JsonRpcRequestForHealthSchema());
4578
4688
  var HealthResponseSchema = () => _lazy(
4579
4689
  () => JsonRpcResponseFor_Nullable_RpcHealthResponseAnd_RpcErrorSchema()
@@ -4582,6 +4692,8 @@ var LightClientProofRequestSchema = () => _lazy(() => JsonRpcRequestForLightClie
4582
4692
  var LightClientProofResponseSchema = () => _lazy(
4583
4693
  () => JsonRpcResponseFor_RpcLightClientExecutionProofResponseAnd_RpcErrorSchema()
4584
4694
  );
4695
+ var MaintenanceWindowsRequestSchema = () => _lazy(() => JsonRpcRequestForMaintenanceWindowsSchema());
4696
+ var MaintenanceWindowsResponseSchema = () => _lazy(() => JsonRpcResponseFor_ArrayOf_RangeOfUint64And_RpcErrorSchema());
4585
4697
  var NetworkInfoRequestSchema = () => _lazy(() => JsonRpcRequestForNetworkInfoSchema());
4586
4698
  var NetworkInfoResponseSchema = () => _lazy(() => JsonRpcResponseFor_RpcNetworkInfoResponseAnd_RpcErrorSchema());
4587
4699
  var NextLightClientBlockRequestSchema = () => _lazy(() => JsonRpcRequestForNextLightClientBlockSchema());
@@ -4651,6 +4763,10 @@ var VALIDATION_SCHEMA_MAP = {
4651
4763
  requestSchema: BlockRequestSchema,
4652
4764
  responseSchema: BlockResponseSchema
4653
4765
  },
4766
+ block_effects: {
4767
+ requestSchema: BlockEffectsRequestSchema,
4768
+ responseSchema: BlockEffectsResponseSchema
4769
+ },
4654
4770
  broadcast_tx_async: {
4655
4771
  requestSchema: BroadcastTxAsyncRequestSchema,
4656
4772
  responseSchema: BroadcastTxAsyncResponseSchema
@@ -4675,6 +4791,10 @@ var VALIDATION_SCHEMA_MAP = {
4675
4791
  requestSchema: GasPriceRequestSchema,
4676
4792
  responseSchema: GasPriceResponseSchema
4677
4793
  },
4794
+ genesis_config: {
4795
+ requestSchema: GenesisConfigRequestSchema,
4796
+ responseSchema: GenesisConfigResponseSchema
4797
+ },
4678
4798
  health: {
4679
4799
  requestSchema: HealthRequestSchema,
4680
4800
  responseSchema: HealthResponseSchema
@@ -4683,6 +4803,10 @@ var VALIDATION_SCHEMA_MAP = {
4683
4803
  requestSchema: LightClientProofRequestSchema,
4684
4804
  responseSchema: LightClientProofResponseSchema
4685
4805
  },
4806
+ maintenance_windows: {
4807
+ requestSchema: MaintenanceWindowsRequestSchema,
4808
+ responseSchema: MaintenanceWindowsResponseSchema
4809
+ },
4686
4810
  network_info: {
4687
4811
  requestSchema: NetworkInfoRequestSchema,
4688
4812
  responseSchema: NetworkInfoResponseSchema
@@ -4742,14 +4866,17 @@ var PATH_TO_METHOD_MAP = {
4742
4866
  "/EXPERIMENTAL_tx_status": "EXPERIMENTAL_tx_status",
4743
4867
  "/EXPERIMENTAL_validators_ordered": "EXPERIMENTAL_validators_ordered",
4744
4868
  "/block": "block",
4869
+ "/block_effects": "block_effects",
4745
4870
  "/broadcast_tx_async": "broadcast_tx_async",
4746
4871
  "/broadcast_tx_commit": "broadcast_tx_commit",
4747
4872
  "/changes": "changes",
4748
4873
  "/chunk": "chunk",
4749
4874
  "/client_config": "client_config",
4750
4875
  "/gas_price": "gas_price",
4876
+ "/genesis_config": "genesis_config",
4751
4877
  "/health": "health",
4752
4878
  "/light_client_proof": "light_client_proof",
4879
+ "/maintenance_windows": "maintenance_windows",
4753
4880
  "/network_info": "network_info",
4754
4881
  "/next_light_client_block": "next_light_client_block",
4755
4882
  "/query": "query",
@@ -4763,8 +4890,8 @@ Object.entries(PATH_TO_METHOD_MAP).forEach(([path, method]) => {
4763
4890
  var RPC_METHODS = Object.values(PATH_TO_METHOD_MAP);
4764
4891
 
4765
4892
  // Auto-generated static RPC functions for tree-shaking
4766
- // Generated at: 2025-07-28T13:29:57.104Z
4767
- // Total functions: 28
4893
+ // Generated at: 2025-07-30T06:06:30.752Z
4894
+ // Total functions: 31
4768
4895
  //
4769
4896
  // This file is automatically generated by tools/codegen/generate-client-interface.ts
4770
4897
  // Do not edit manually - changes will be overwritten
@@ -4820,6 +4947,10 @@ async function experimentalValidatorsOrdered(client, params) {
4820
4947
  async function block(client, params) {
4821
4948
  return client.makeRequest('block', params);
4822
4949
  }
4950
+ // block_effects static function
4951
+ async function blockEffects(client, params) {
4952
+ return client.makeRequest('block_effects', params);
4953
+ }
4823
4954
  // broadcast_tx_async static function
4824
4955
  async function broadcastTxAsync(client, params) {
4825
4956
  return client.makeRequest('broadcast_tx_async', params);
@@ -4844,6 +4975,10 @@ async function clientConfig(client, params) {
4844
4975
  async function gasPrice(client, params) {
4845
4976
  return client.makeRequest('gas_price', params);
4846
4977
  }
4978
+ // genesis_config static function
4979
+ async function genesisConfig(client, params) {
4980
+ return client.makeRequest('genesis_config', params);
4981
+ }
4847
4982
  // health static function
4848
4983
  async function health(client, params) {
4849
4984
  return client.makeRequest('health', params);
@@ -4852,6 +4987,10 @@ async function health(client, params) {
4852
4987
  async function lightClientProof(client, params) {
4853
4988
  return client.makeRequest('light_client_proof', params);
4854
4989
  }
4990
+ // maintenance_windows static function
4991
+ async function maintenanceWindows(client, params) {
4992
+ return client.makeRequest('maintenance_windows', params);
4993
+ }
4855
4994
  // network_info static function
4856
4995
  async function networkInfo(client, params) {
4857
4996
  return client.makeRequest('network_info', params);
@@ -4972,6 +5111,14 @@ function enableValidation() {
4972
5111
  try {
4973
5112
  // First validate basic JSON-RPC structure
4974
5113
  responseSchema.parse(response);
5114
+ // Check if the result contains an error field before validating the schema
5115
+ // This provides a better error message when NEAR RPC returns non-standard errors
5116
+ if (response.result &&
5117
+ typeof response.result === 'object' &&
5118
+ 'error' in response.result) {
5119
+ const serverError = response.result.error;
5120
+ throw new JsonRpcClientError(`Server error: ${serverError}`, -32000, response.result);
5121
+ }
4975
5122
  // Then validate method-specific response structure if schema exists
4976
5123
  const methodSchemas = VALIDATION_SCHEMA_MAP[method];
4977
5124
  if (methodSchemas?.responseSchema) {
@@ -4980,10 +5127,15 @@ function enableValidation() {
4980
5127
  }
4981
5128
  }
4982
5129
  catch (error) {
5130
+ // If it's already a JsonRpcClientError (from server error check), re-throw it
5131
+ if (error instanceof JsonRpcClientError) {
5132
+ throw error;
5133
+ }
5134
+ // Otherwise, it's a validation error
4983
5135
  throw new JsonRpcClientError(`Invalid ${method} response: ${error instanceof Error ? error.message : 'Unknown error'}`);
4984
5136
  }
4985
5137
  },
4986
5138
  };
4987
5139
  }
4988
5140
 
4989
- export { JsonRpcClientError, JsonRpcNetworkError, JsonRpcRequestSchema, JsonRpcResponseSchema, NearRpcClient, NearRpcError, RPC_METHODS, 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 };
5141
+ export { JsonRpcClientError, JsonRpcNetworkError, JsonRpcRequestSchema, JsonRpcResponseSchema, NearRpcClient, NearRpcError, RPC_METHODS, 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 };