solana_rpc_ruby 1.1.4 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b2b14096111bbe436c1b308176794fd8430c0cf1a4a4ab2619812631e9789c12
4
- data.tar.gz: 1334bb335177b3c3f019ad8a4c73b9c1357700b00ea7e2d326991929cccacf34
3
+ metadata.gz: 445e4852f291cb7e6d417e3a3277905c7c2935ed40ec9cdca3e1d5f2f599f8ab
4
+ data.tar.gz: 36f27011567ebd56e0f0b86db2fa93c04e66c55351d0307a014b432a3988f8e5
5
5
  SHA512:
6
- metadata.gz: 0defe25b84f574253aa26519489e6ca7428958e598fc5c53519d301bcfda229cb7be951afa53f472c9df8242d8b78b3a24f43ff10859dea4bab6d3ce66249169
7
- data.tar.gz: 824349620d2471754a063fd8da98e03e8adc34bb984084560763114a91953522d17e7a7363c985e20660ed2b4751c9a47ffa3bb7de57746529233b267871cd2c
6
+ metadata.gz: 9be80c9efcff01f3324cee479e4262cafd9ca8cc43dfc7d19e6bf537f336428a5bacf124b4d920955c364638fd355e9bdbe33bf425bc458a2d37025bbfbb794e
7
+ data.tar.gz: 86e7db1d6cdf6b2a5b208b7b5b8fdae6766fbeb5e919ff8dfd23c845c9c8d5105827f4609d10ad01581f0049a1dfbd1c9e9ded0937f621ad7912856837397da2
data/CHANGELOG.md CHANGED
@@ -25,3 +25,11 @@
25
25
 
26
26
  ## 1.1.4
27
27
  * Removes deprecated constant
28
+
29
+ ## 1.2.0
30
+ * Fix handling commitment param in methods
31
+ * Add RPC and websocket methods added by solana core to RPC recently
32
+ * Add new params to methods added by solana core
33
+ * Add warns to deprecated methods
34
+ * Update docs
35
+ * Small fixes
@@ -29,7 +29,7 @@ module SolanaRpcRuby
29
29
  # @param cluster [String] cluster where requests will be sent.
30
30
  # @param id [Integer] unique client-generated identifying integer.
31
31
  def initialize(
32
- api_client: ApiClient,
32
+ api_client: ApiClient,
33
33
  cluster: SolanaRpcRuby.cluster,
34
34
  id: rand(1...99_999)
35
35
  )
@@ -40,16 +40,18 @@ module SolanaRpcRuby
40
40
  end
41
41
 
42
42
  # @see https://docs.solana.com/developing/clients/jsonrpc-api#getaccountinfo
43
+ #
43
44
  # Returns all information associated with the account of provided Pubkey
44
45
  #
45
46
  # @param account_pubkey [String]
46
47
  # @param encoding [String]
48
+ # @param commitment [String]
47
49
  # @param data_slice [Hash]
48
50
  # @option data_slice [Integer] :offset
49
51
  # @option data_slice [Integer] :length
50
52
  #
51
53
  # @return [Response, ApiError] Response when success, ApiError on failure.
52
- def get_account_info(account_pubkey, encoding: '', data_slice: {})
54
+ def get_account_info(account_pubkey, encoding: '', data_slice: {}, commitment: '')
53
55
  http_method = :post
54
56
  method = create_method_name(__method__)
55
57
 
@@ -58,6 +60,7 @@ module SolanaRpcRuby
58
60
 
59
61
  params_hash['encoding'] = encoding unless blank?(encoding)
60
62
  params_hash['dataSlice'] = data_slice unless data_slice.empty?
63
+ params_hash['commitment'] = commitment unless blank?(commitment)
61
64
 
62
65
  params << account_pubkey
63
66
  params << params_hash unless params_hash.empty?
@@ -68,6 +71,7 @@ module SolanaRpcRuby
68
71
  end
69
72
 
70
73
  # @see https://docs.solana.com/developing/clients/jsonrpc-api#getbalance
74
+ #
71
75
  # Returns the balance of the account of provided Pubkey
72
76
  #
73
77
  # @param account_pubkey [String]
@@ -94,6 +98,7 @@ module SolanaRpcRuby
94
98
 
95
99
  # @see https://docs.solana.com/developing/clients/jsonrpc-api#getblock
96
100
  # NEW: This method is only available in solana-core v1.7 or newer. Please use getConfirmedBlock for solana-core v1.6
101
+ #
97
102
  # Returns identity and transaction information about a confirmed block in the ledger
98
103
  #
99
104
  # @param slot [Integer]
@@ -124,6 +129,7 @@ module SolanaRpcRuby
124
129
  end
125
130
 
126
131
  # @see https://docs.solana.com/developing/clients/jsonrpc-api#getblockheight
132
+ #
127
133
  # Returns the current block height of the node
128
134
  #
129
135
  # @param commitment [String]
@@ -145,6 +151,7 @@ module SolanaRpcRuby
145
151
  end
146
152
 
147
153
  # @see https://docs.solana.com/developing/clients/jsonrpc-api#getblockproduction
154
+ #
148
155
  # Returns recent block production information from the current or previous epoch.
149
156
  #
150
157
  # @param identity [String]
@@ -167,6 +174,7 @@ module SolanaRpcRuby
167
174
 
168
175
  params_hash['identity'] = identity unless blank?(identity)
169
176
  params_hash['range'] = range_hash unless range_hash.empty?
177
+ params_hash['commitment'] = commitment unless blank?(commitment)
170
178
 
171
179
  params << params_hash unless params_hash.empty?
172
180
 
@@ -176,6 +184,7 @@ module SolanaRpcRuby
176
184
  end
177
185
 
178
186
  # @see https://docs.solana.com/developing/clients/jsonrpc-api#getblockcommitment
187
+ #
179
188
  # Returns commitment for particular block
180
189
  #
181
190
  # @param block [Integer]
@@ -196,20 +205,25 @@ module SolanaRpcRuby
196
205
 
197
206
  # @see https://docs.solana.com/developing/clients/jsonrpc-api#getblocks
198
207
  # NEW: This method is only available in solana-core v1.7 or newer. Please use getConfirmedBlocks for solana-core v1.6
208
+ #
199
209
  # Returns a list of confirmed blocks between two slots
200
210
  #
201
211
  # @param start_slot [Integer]
202
212
  # @param end_slot [Integer]
203
213
  #
204
214
  # @return [Response, ApiError] Response when success, ApiError on failure.
205
- def get_blocks(start_slot, end_slot: nil)
215
+ def get_blocks(start_slot, end_slot: nil, commitment: nil)
206
216
  http_method = :post
207
217
  method = create_method_name(__method__)
208
218
 
209
219
  params = []
220
+ params_hash = {}
210
221
 
211
222
  params << start_slot
212
223
  params << end_slot unless end_slot.nil?
224
+ params_hash['commitment'] = commitment unless blank?(commitment)
225
+
226
+ params << params_hash unless params_hash.empty?
213
227
 
214
228
  body = create_json_body(method, method_params: params)
215
229
 
@@ -218,6 +232,7 @@ module SolanaRpcRuby
218
232
 
219
233
  # @see https://docs.solana.com/developing/clients/jsonrpc-api#getblockswithlimit
220
234
  # NEW: This method is only available in solana-core v1.7 or newer. Please use getConfirmedBlocks for solana-core v1.6
235
+ #
221
236
  # Returns a list of confirmed blocks starting at the given slot
222
237
  #
223
238
  # @param start_slot [Integer]
@@ -244,6 +259,7 @@ module SolanaRpcRuby
244
259
  end
245
260
 
246
261
  # @see https://docs.solana.com/developing/clients/jsonrpc-api#getblocktime
262
+ #
247
263
  # Returns the estimated production time of a block.
248
264
  #
249
265
  # @param block [Integer]
@@ -263,6 +279,7 @@ module SolanaRpcRuby
263
279
  end
264
280
 
265
281
  # @see https://docs.solana.com/developing/clients/jsonrpc-api#getclusternodes
282
+ #
266
283
  # Returns information about all the nodes participating in the cluster
267
284
  #
268
285
  # @return [Response, ApiError] Response when success, ApiError on failure.
@@ -276,28 +293,7 @@ module SolanaRpcRuby
276
293
  end
277
294
 
278
295
  # @see https://docs.solana.com/developing/clients/jsonrpc-api#getepochinfo
279
- # DEPRECATED: Please use getBlocks instead This method is expected to be removed in solana-core v1.8
280
- # Returns a list of confirmed blocks between two slots
281
296
  #
282
- # @param start_slot [Integer]
283
- # @param end_slot [Integer]
284
- #
285
- # @return [Response, ApiError] Response when success, ApiError on failure.
286
- def get_confirmed_blocks(start_slot, end_slot: nil)
287
- http_method = :post
288
- method = create_method_name(__method__)
289
-
290
- params = []
291
-
292
- params << start_slot
293
- params << end_slot unless end_slot.nil? # optional
294
-
295
- body = create_json_body(method, method_params: params)
296
-
297
- send_request(body, http_method)
298
- end
299
-
300
- # @see https://docs.solana.com/developing/clients/jsonrpc-api#getepochinfo
301
297
  # Returns information about the current epoch
302
298
  #
303
299
  # @param commitment [String]
@@ -320,6 +316,7 @@ module SolanaRpcRuby
320
316
  end
321
317
 
322
318
  # @see https://docs.solana.com/developing/clients/jsonrpc-api#getepochschedule
319
+ #
323
320
  # Returns epoch schedule information from this cluster's genesis config
324
321
  #
325
322
  # @return [Response, ApiError] Response when success, ApiError on failure.
@@ -332,35 +329,37 @@ module SolanaRpcRuby
332
329
  send_request(body, http_method)
333
330
  end
334
331
 
335
- # @see https://docs.solana.com/developing/clients/jsonrpc-api#getfeecalculatorforblockhash
336
- # Returns the fee calculator associated with the query blockhash, or null if the blockhash has expired
332
+ # @see https://docs.solana.com/developing/clients/jsonrpc-api#getfeeformessage
333
+ # NEW: This method is only available in solana-core v1.9 or newer. Please use getFees for solana-core v1.8
337
334
  #
338
- # @param query_blockhash [String]
335
+ # Get the fee the network will charge for a particular Message
336
+ #
337
+ # @param message [String]
339
338
  # @param commitment [String]
340
339
  #
341
340
  # @return [Response, ApiError] Response when success, ApiError on failure.
342
- def get_fee_calculator_for_blockhash(query_blockhash, commitment: nil)
341
+ def get_fee_for_message(message, commitment: nil)
343
342
  http_method = :post
344
343
  method = create_method_name(__method__)
345
344
 
346
345
  params = []
347
346
  params_hash = {}
348
347
 
348
+ params << message
349
349
  params_hash['commitment'] = commitment unless blank?(commitment)
350
350
 
351
- params << query_blockhash
352
351
  params << params_hash unless params_hash.empty?
353
-
354
352
  body = create_json_body(method, method_params: params)
355
353
 
356
354
  send_request(body, http_method)
357
355
  end
358
356
 
359
- # @see https://docs.solana.com/developing/clients/jsonrpc-api#getfeerategovernor
360
- # Returns the fee rate governor information from the root bank
357
+ # @see https://docs.solana.com/developing/clients/jsonrpc-api#getfirstavailableblock
358
+ #
359
+ # Returns the slot of the lowest confirmed block that has not been purged from the ledger
361
360
  #
362
361
  # @return [Response, ApiError] Response when success, ApiError on failure.
363
- def get_fee_rate_governor
362
+ def get_first_available_block
364
363
  http_method = :post
365
364
  method = create_method_name(__method__)
366
365
 
@@ -369,33 +368,12 @@ module SolanaRpcRuby
369
368
  send_request(body, http_method)
370
369
  end
371
370
 
372
- # @see https://docs.solana.com/developing/clients/jsonrpc-api#getfees
373
- # Returns a recent block hash from the ledger, a fee schedule that can be used to compute
374
- # the cost of submitting a transaction using it, and the last slot in which the blockhash will be valid.
375
- #
376
- # @param commitment [String]
371
+ # @see https://docs.solana.com/developing/clients/jsonrpc-api#getgenesishash
377
372
  #
378
- # @return [Response, ApiError] Response when success, ApiError on failure.
379
- def get_fees(commitment: nil)
380
- http_method = :post
381
- method = create_method_name(__method__)
382
-
383
- params = []
384
- params_hash = {}
385
-
386
- params_hash['commitment'] = commitment unless blank?(commitment)
387
- params << params_hash unless params_hash.empty?
388
-
389
- body = create_json_body(method, method_params: params)
390
-
391
- send_request(body, http_method)
392
- end
393
-
394
- # @see https://docs.solana.com/developing/clients/jsonrpc-api#getfirstavailableblock
395
- # Returns the slot of the lowest confirmed block that has not been purged from the ledger
373
+ # Returns the genesis hash.
396
374
  #
397
375
  # @return [Response, ApiError] Response when success, ApiError on failure.
398
- def get_first_available_block
376
+ def get_genesis_hash
399
377
  http_method = :post
400
378
  method = create_method_name(__method__)
401
379
 
@@ -404,11 +382,12 @@ module SolanaRpcRuby
404
382
  send_request(body, http_method)
405
383
  end
406
384
 
407
- # @see https://docs.solana.com/developing/clients/jsonrpc-api#getgenesishash
408
- # Returns the genesis hash.
385
+ # @see https://docs.solana.com/developing/clients/jsonrpc-api#gethealth
386
+ #
387
+ # Returns the current health of the node.
409
388
  #
410
389
  # @return [Response, ApiError] Response when success, ApiError on failure.
411
- def get_genesis_hash
390
+ def get_health
412
391
  http_method = :post
413
392
  method = create_method_name(__method__)
414
393
 
@@ -417,11 +396,15 @@ module SolanaRpcRuby
417
396
  send_request(body, http_method)
418
397
  end
419
398
 
420
- # @see https://docs.solana.com/developing/clients/jsonrpc-api#gethealth
421
- # Returns the current health of the node.
399
+ # @see https://docs.solana.com/developing/clients/jsonrpc-api#gethighestsnapshotslot
400
+ #
401
+ # NEW: This method is only available in solana-core v1.9 or newer. Please use getSnapshotSlot for solana-core v1.8
402
+ #
403
+ # Returns the highest slot information that the node has snapshots for.
404
+ # This will find the highest full snapshot slot, and the highest incremental snapshot slot based on the full snapshot slot, if there is one.
422
405
  #
423
406
  # @return [Response, ApiError] Response when success, ApiError on failure.
424
- def get_health
407
+ def get_highest_snapshot_slot
425
408
  http_method = :post
426
409
  method = create_method_name(__method__)
427
410
 
@@ -431,6 +414,7 @@ module SolanaRpcRuby
431
414
  end
432
415
 
433
416
  # @see https://docs.solana.com/developing/clients/jsonrpc-api#getidentity
417
+ #
434
418
  # Returns the identity pubkey for the current node.
435
419
  #
436
420
  # @return [Response, ApiError] Response when success, ApiError on failure.
@@ -444,6 +428,7 @@ module SolanaRpcRuby
444
428
  end
445
429
 
446
430
  # @see https://docs.solana.com/developing/clients/jsonrpc-api#getinflationgovernor
431
+ #
447
432
  # Returns the current inflation governor.
448
433
  #
449
434
  # @param commitment [String]
@@ -466,6 +451,7 @@ module SolanaRpcRuby
466
451
  end
467
452
 
468
453
  # @see https://docs.solana.com/developing/clients/jsonrpc-api#getinflationrate
454
+ #
469
455
  # Returns the specific inflation values for the current epoch.
470
456
  #
471
457
  # @return [Response, ApiError] Response when success, ApiError on failure.
@@ -479,6 +465,7 @@ module SolanaRpcRuby
479
465
  end
480
466
 
481
467
  # @see https://docs.solana.com/developing/clients/jsonrpc-api#getinflationreward
468
+ #
482
469
  # Returns the inflation reward for a list of addresses for an epoch.
483
470
  #
484
471
  # @param addresses [Array]
@@ -506,6 +493,7 @@ module SolanaRpcRuby
506
493
  end
507
494
 
508
495
  # @see https://docs.solana.com/developing/clients/jsonrpc-api#getlargestaccounts
496
+ #
509
497
  # Returns the 20 largest accounts, by lamport balance (results may be cached up to two hours)
510
498
  #
511
499
  # @param commitment [String]
@@ -529,7 +517,32 @@ module SolanaRpcRuby
529
517
  send_request(body, http_method)
530
518
  end
531
519
 
520
+ # @see https://docs.solana.com/developing/clients/jsonrpc-api#getlatestblockhash
521
+ # NEW: This method is only available in solana-core v1.9 or newer. Please use getRecentBlockhash for solana-core v1.8
522
+ #
523
+ # Returns the latest blockhash.
524
+ #
525
+ # @param commitment [String]
526
+ #
527
+ # @return [Response, ApiError] Response when success, ApiError on failure.
528
+ def get_latest_blockhash(commitment: nil)
529
+ http_method = :post
530
+ method = create_method_name(__method__)
531
+
532
+ params = []
533
+ params_hash = {}
534
+
535
+ params_hash['commitment'] = commitment unless blank?(commitment)
536
+
537
+ params << params_hash unless params_hash.empty?
538
+
539
+ body = create_json_body(method, method_params: params)
540
+
541
+ send_request(body, http_method)
542
+ end
543
+
532
544
  # @see https://docs.solana.com/developing/clients/jsonrpc-api#getleaderschedule
545
+ #
533
546
  # Returns the leader schedule for an epoch.
534
547
  #
535
548
  # @param epoch [Integer]
@@ -556,6 +569,7 @@ module SolanaRpcRuby
556
569
  end
557
570
 
558
571
  # @see https://docs.solana.com/developing/clients/jsonrpc-api#getmaxretransmitslot
572
+ #
559
573
  # Get the max slot seen from retransmit stage.
560
574
  #
561
575
  # @return [Response, ApiError] Response when success, ApiError on failure.
@@ -582,6 +596,7 @@ module SolanaRpcRuby
582
596
  end
583
597
 
584
598
  # @see https://docs.solana.com/developing/clients/jsonrpc-api#getminimumbalanceforrentexemption
599
+ #
585
600
  # Returns minimum balance required to make account rent exempt.
586
601
  #
587
602
  # @param account_data_length [String]
@@ -609,12 +624,15 @@ module SolanaRpcRuby
609
624
  end
610
625
 
611
626
  # @see https://docs.solana.com/developing/clients/jsonrpc-api#getmultipleaccounts
627
+ #
612
628
  # Returns the account information for a list of Pubkeys.
613
- # @param account_data_length [String]
614
- # @param commitment [String]
615
629
  #
616
- # @return [Response, ApiError] Response when success, ApiError on failure. # @param account_data_length [String]
630
+ # @param pubkeys [Array]
617
631
  # @param commitment [String]
632
+ # @param encoding [String]
633
+ # @param data_slice [Hash]
634
+ # @option data_slice [Integer] :offset
635
+ # @option data_slice [Integer] :length
618
636
  #
619
637
  # @return [Response, ApiError] Response when success, ApiError on failure.
620
638
  def get_multiple_accounts(
@@ -688,30 +706,8 @@ module SolanaRpcRuby
688
706
  send_request(body, http_method)
689
707
  end
690
708
 
691
- # @see https://docs.solana.com/developing/clients/jsonrpc-api#getrecentblockhash
692
- # Returns a recent block hash from the ledger, and a fee schedule
693
- # that can be used to compute the cost of submitting a transaction using it.
694
- #
695
- # @param commitment [String]
696
- #
697
- # @return [Response, ApiError] Response when success, ApiError on failure.
698
- def get_recent_blockhash(commitment: nil)
699
- http_method = :post
700
- method = create_method_name(__method__)
701
-
702
- params = []
703
- params_hash = {}
704
-
705
- params_hash['commitment'] = commitment unless blank?(commitment)
706
-
707
- params << params_hash unless params_hash.empty?
708
-
709
- body = create_json_body(method, method_params: params)
710
-
711
- send_request(body, http_method)
712
- end
713
-
714
709
  # @see https://docs.solana.com/developing/clients/jsonrpc-api#getrecentperformancesamples
710
+ #
715
711
  # Returns a list of recent performance samples, in reverse slot order.
716
712
  # Performance samples are taken every 60 seconds and include the number of transactions and slots that occur in a given time window.
717
713
  #
@@ -731,19 +727,6 @@ module SolanaRpcRuby
731
727
  send_request(body, http_method)
732
728
  end
733
729
 
734
- # @see https://docs.solana.com/developing/clients/jsonrpc-api#getsnapshotslot
735
- # Returns the highest slot that the node has a snapshot for.
736
- #
737
- # @return [Response, ApiError] Response when success, ApiError on failure.
738
- def get_snapshot_slot
739
- http_method = :post
740
- method = create_method_name(__method__)
741
-
742
- body = create_json_body(method)
743
-
744
- send_request(body, http_method)
745
- end
746
-
747
730
  # @see https://docs.solana.com/developing/clients/jsonrpc-api#getsignaturesforaddress
748
731
  # NEW: This method is only available in solana-core v1.7 or newer.
749
732
  # Please use getConfirmedSignaturesForAddress2 for solana-core v1.6
@@ -816,6 +799,7 @@ module SolanaRpcRuby
816
799
  end
817
800
 
818
801
  # @see https://docs.solana.com/developing/clients/jsonrpc-api#getslot
802
+ #
819
803
  # Returns the current slot the node is processing.
820
804
  #
821
805
  # @param commitment [String]
@@ -838,6 +822,7 @@ module SolanaRpcRuby
838
822
  end
839
823
 
840
824
  # @see https://docs.solana.com/developing/clients/jsonrpc-api#getslotleader
825
+ #
841
826
  # Returns the current slot leader
842
827
  #
843
828
  # @param commitment [String]
@@ -860,6 +845,7 @@ module SolanaRpcRuby
860
845
  end
861
846
 
862
847
  # @see https://docs.solana.com/developing/clients/jsonrpc-api#getslotleaders
848
+ #
863
849
  # Returns the slot leaders for a given slot range.
864
850
  #
865
851
  # @param start_slot [Integer]
@@ -878,6 +864,7 @@ module SolanaRpcRuby
878
864
  end
879
865
 
880
866
  # @see https://docs.solana.com/developing/clients/jsonrpc-api#getstakeactivation
867
+ #
881
868
  # Returns epoch activation information for a stake account.
882
869
  #
883
870
  # @param pubkey [String]
@@ -904,12 +891,14 @@ module SolanaRpcRuby
904
891
  end
905
892
 
906
893
  # @see https://docs.solana.com/developing/clients/jsonrpc-api#getsupply
894
+ #
907
895
  # Returns information about the current supply.
908
896
  #
909
897
  # @param commitment [String]
898
+ # @param exclude_non_circulating_accounts_list [Boolean]
910
899
  #
911
900
  # @return [Response, ApiError] Response when success, ApiError on failure.
912
- def get_supply(commitment: nil)
901
+ def get_supply(commitment: nil, exclude_non_circulating_accounts_list: nil)
913
902
  http_method = :post
914
903
  method = create_method_name(__method__)
915
904
 
@@ -917,6 +906,8 @@ module SolanaRpcRuby
917
906
  params_hash = {}
918
907
 
919
908
  params_hash['commitment'] = commitment unless blank?(commitment)
909
+ params_hash['exclude_non_circulating_accounts_list'] = exclude_non_circulating_accounts_list \
910
+ unless exclude_non_circulating_accounts_list.nil?
920
911
 
921
912
  params << params_hash unless params_hash.empty?
922
913
 
@@ -1080,6 +1071,35 @@ module SolanaRpcRuby
1080
1071
  send_request(body, http_method)
1081
1072
  end
1082
1073
 
1074
+ # @see https://docs.solana.com/developing/clients/jsonrpc-api#gettokensupply
1075
+ #
1076
+ # Returns the total supply of an SPL Token type.
1077
+ #
1078
+ # @param token_mint_pubkey [String]
1079
+ # @param commitment [String]
1080
+ #
1081
+ # @return [Response, ApiError] Response when success, ApiError on failure.
1082
+ def get_token_supply(
1083
+ token_mint_pubkey,
1084
+ commitment: nil
1085
+ )
1086
+
1087
+ http_method = :post
1088
+ method = create_method_name(__method__)
1089
+
1090
+ params = []
1091
+ params_hash = {}
1092
+
1093
+ params_hash['commitment'] = commitment unless blank?(commitment)
1094
+
1095
+ params << token_mint_pubkey
1096
+ params << params_hash unless params_hash.empty?
1097
+
1098
+ body = create_json_body(method, method_params: params)
1099
+
1100
+ send_request(body, http_method)
1101
+ end
1102
+
1083
1103
  # @see https://docs.solana.com/developing/clients/jsonrpc-api#gettransaction
1084
1104
  #
1085
1105
  # Returns transaction details for a confirmed transaction
@@ -1145,13 +1165,21 @@ module SolanaRpcRuby
1145
1165
  end
1146
1166
 
1147
1167
  # @see https://docs.solana.com/developing/clients/jsonrpc-api#getvoteaccounts
1168
+ #
1148
1169
  # Returns the account info and associated stake for all the voting accounts in the current bank.
1149
1170
  #
1150
1171
  # @param commitment [String]
1151
1172
  # @param vote_pubkey [String]
1173
+ # @param keep_unstaked_delinquents [Boolean]
1174
+ # @param delinquent_slot_distance [Integer] NOTE: For the sake of consistency between ecosystem products, it is not recommended that this argument be specified.
1152
1175
  #
1153
1176
  # @return [Response, ApiError] Response when success, ApiError on failure.
1154
- def get_vote_accounts(commitment: nil, vote_pubkey: nil)
1177
+ def get_vote_accounts(
1178
+ commitment: nil,
1179
+ vote_pubkey: nil,
1180
+ keep_unstaked_delinquents: nil,
1181
+ delinquent_slot_distance: nil
1182
+ )
1155
1183
  http_method = :post
1156
1184
  method = create_method_name(__method__)
1157
1185
 
@@ -1160,6 +1188,8 @@ module SolanaRpcRuby
1160
1188
 
1161
1189
  params_hash['votePubkey'] = vote_pubkey unless blank?(vote_pubkey)
1162
1190
  params_hash['commitment'] = commitment unless blank?(commitment)
1191
+ params_hash['keep_unstaked_delinquents'] = keep_unstaked_delinquents unless keep_unstaked_delinquents.nil?
1192
+ params_hash['delinquent_slot_distance'] = delinquent_slot_distance unless blank?(delinquent_slot_distance)
1163
1193
 
1164
1194
  params << params_hash unless params_hash.empty?
1165
1195
 
@@ -1168,16 +1198,28 @@ module SolanaRpcRuby
1168
1198
  send_request(body, http_method)
1169
1199
  end
1170
1200
 
1171
- # @see https://docs.solana.com/developing/clients/jsonrpc-api#minimumledgerslot
1201
+ # @see https://docs.solana.com/developing/clients/jsonrpc-api#isblockhashvalid
1202
+ # NEW: This method is only available in solana-core v1.9 or newer. Please use getFeeCalculatorForBlockhash for solana-core v1.8
1172
1203
  #
1173
- # Returns the current solana versions running on the node.
1204
+ # Returns whether a blockhash is still valid or not.
1205
+ #
1206
+ # @param blockhash [String]
1207
+ # @param commitment [String]
1174
1208
  #
1175
1209
  # @return [Response, ApiError] Response when success, ApiError on failure.
1176
- def get_version
1210
+ def is_blockhash_valid(blockhash, commitment: nil)
1177
1211
  http_method = :post
1178
1212
  method = create_method_name(__method__)
1179
1213
 
1180
- body = create_json_body(method)
1214
+ params = []
1215
+ params_hash = {}
1216
+
1217
+ params_hash['commitment'] = commitment unless blank?(commitment)
1218
+
1219
+ params << blockhash
1220
+ params << params_hash unless params_hash.empty?
1221
+
1222
+ body = create_json_body(method, method_params: params)
1181
1223
 
1182
1224
  send_request(body, http_method)
1183
1225
  end
@@ -1212,6 +1254,7 @@ module SolanaRpcRuby
1212
1254
 
1213
1255
  params = []
1214
1256
  params_hash = {}
1257
+ params_hash['commitment'] = commitment unless blank?(commitment)
1215
1258
 
1216
1259
  params << pubkey
1217
1260
  params << lamports
@@ -1230,13 +1273,15 @@ module SolanaRpcRuby
1230
1273
  # @param skip_pre_flight [Boolean]
1231
1274
  # @param pre_flight_commitment [String]
1232
1275
  # @param encoding [String]
1276
+ # @param max_retries [Integer]
1233
1277
  #
1234
1278
  # @return [Response, ApiError] Response when success, ApiError on failure.
1235
1279
  def send_transaction(
1236
1280
  transaction_signature,
1237
1281
  skip_pre_flight: false,
1238
1282
  pre_flight_commitment: nil,
1239
- encoding: ''
1283
+ encoding: '',
1284
+ max_retries: nil
1240
1285
  )
1241
1286
  http_method = :post
1242
1287
  method = create_method_name(__method__)
@@ -1247,6 +1292,7 @@ module SolanaRpcRuby
1247
1292
  params_hash['skipPreFlight'] = skip_pre_flight unless skip_pre_flight.nil?
1248
1293
  params_hash['preflightCommitment'] = pre_flight_commitment unless blank?(pre_flight_commitment)
1249
1294
  params_hash['encoding'] = encoding unless blank?(encoding)
1295
+ params_hash['max_retries'] = max_retries unless blank?(max_retries)
1250
1296
 
1251
1297
  params << transaction_signature
1252
1298
  params << params_hash unless params_hash.empty?
@@ -1306,7 +1352,155 @@ module SolanaRpcRuby
1306
1352
  send_request(body, http_method)
1307
1353
  end
1308
1354
 
1355
+
1356
+ ######## DEPRECATED METHODS #########
1357
+
1358
+ # @deprecated Please use getBlocks instead This method is expected to be removed in solana-core v1.8
1359
+ #
1360
+ # @see https://docs.solana.com/developing/clients/jsonrpc-api#getepochinfo
1361
+ #
1362
+ # Returns a list of confirmed blocks between two slots
1363
+ #
1364
+ # @param start_slot [Integer]
1365
+ # @param end_slot [Integer]
1366
+ #
1367
+ # @return [Response, ApiError] Response when success, ApiError on failure.
1368
+ def get_confirmed_blocks(start_slot, end_slot: nil)
1369
+ warn 'DEPRECATED: Please use getBlocks instead. This method is expected to be removed in solana-core v1.8'
1370
+
1371
+ http_method = :post
1372
+ method = create_method_name(__method__)
1373
+
1374
+ params = []
1375
+
1376
+ params << start_slot
1377
+ params << end_slot unless end_slot.nil? # optional
1378
+
1379
+ body = create_json_body(method, method_params: params)
1380
+
1381
+ send_request(body, http_method)
1382
+ end
1383
+
1384
+ # @deprecated Please use isBlockhashValid or getFeeForMessage instead This method is expected to be removed in solana-core v2.0
1385
+ #
1386
+ # @see https://docs.solana.com/developing/clients/jsonrpc-api#getfeecalculatorforblockhash
1387
+ #
1388
+ # Returns the fee calculator associated with the query blockhash, or null if the blockhash has expired
1389
+ #
1390
+ # @param query_blockhash [String]
1391
+ # @param commitment [String]
1392
+ #
1393
+ # @return [Response, ApiError] Response when success, ApiError on failure.
1394
+ def get_fee_calculator_for_blockhash(query_blockhash, commitment: nil)
1395
+ warn "DEPRECATED: Please use isBlockhashValid or getFeeForMessage instead. This method is expected to be removed in solana-core v2.0"
1396
+
1397
+ http_method = :post
1398
+ method = create_method_name(__method__)
1399
+
1400
+ params = []
1401
+ params_hash = {}
1402
+
1403
+ params_hash['commitment'] = commitment unless blank?(commitment)
1404
+
1405
+ params << query_blockhash
1406
+ params << params_hash unless params_hash.empty?
1407
+
1408
+ body = create_json_body(method, method_params: params)
1409
+
1410
+ send_request(body, http_method)
1411
+ end
1412
+
1413
+ # @deprecated Please check solana docs for substitution.
1414
+ #
1415
+ # @see https://docs.solana.com/developing/clients/jsonrpc-api#getfeerategovernor
1416
+ #
1417
+ # Returns the fee rate governor information from the root bank
1418
+ #
1419
+ # @return [Response, ApiError] Response when success, ApiError on failure.
1420
+ def get_fee_rate_governor
1421
+ warn "DEPRECATED Please check solana docs for substitution."
1422
+
1423
+ http_method = :post
1424
+ method = create_method_name(__method__)
1425
+
1426
+ body = create_json_body(method)
1427
+
1428
+ send_request(body, http_method)
1429
+ end
1430
+
1431
+ # @deprecated DEPRECATED: Please use getFeeForMessage instead This method is expected to be removed in solana-core v2.0
1432
+ #
1433
+ # @see https://docs.solana.com/developing/clients/jsonrpc-api#getfees
1434
+ #
1435
+ # Returns a recent block hash from the ledger, a fee schedule that can be used to compute
1436
+ # the cost of submitting a transaction using it, and the last slot in which the blockhash will be valid.
1437
+ #
1438
+ # @param commitment [String]
1439
+ #
1440
+ # @return [Response, ApiError] Response when success, ApiError on failure.
1441
+ def get_fees(commitment: nil)
1442
+ warn "DEPRECATED: Please use getFeeForMessage instead This method is expected to be removed in solana-core v2.0"
1443
+
1444
+ http_method = :post
1445
+ method = create_method_name(__method__)
1446
+
1447
+ params = []
1448
+ params_hash = {}
1449
+
1450
+ params_hash['commitment'] = commitment unless blank?(commitment)
1451
+ params << params_hash unless params_hash.empty?
1452
+
1453
+ body = create_json_body(method, method_params: params)
1454
+
1455
+ send_request(body, http_method)
1456
+ end
1457
+
1458
+ # @depreated Please use getFeeForMessage instead This method is expected to be removed in solana-core v2.0
1459
+ #
1460
+ # @see https://docs.solana.com/developing/clients/jsonrpc-api#getrecentblockhash
1461
+ #
1462
+ # Returns a recent block hash from the ledger, and a fee schedule
1463
+ # that can be used to compute the cost of submitting a transaction using it.
1464
+ #
1465
+ # @param commitment [String]
1466
+ #
1467
+ # @return [Response, ApiError] Response when success, ApiError on failure.
1468
+ def get_recent_blockhash(commitment: nil)
1469
+ warn "DEPRECATED: Please use getFeeForMessage instead This method is expected to be removed in solana-core v2.0"
1470
+ http_method = :post
1471
+ method = create_method_name(__method__)
1472
+
1473
+ params = []
1474
+ params_hash = {}
1475
+
1476
+ params_hash['commitment'] = commitment unless blank?(commitment)
1477
+
1478
+ params << params_hash unless params_hash.empty?
1479
+
1480
+ body = create_json_body(method, method_params: params)
1481
+
1482
+ send_request(body, http_method)
1483
+ end
1484
+
1485
+ # @deprecated Please use getHighestSnapshotSlot instead This method is expected to be removed in solana-core v2.0
1486
+ #
1487
+ # @see https://docs.solana.com/developing/clients/jsonrpc-api#getsnapshotslot
1488
+ #
1489
+ # Returns the highest slot that the node has a snapshot for.
1490
+ #
1491
+ # @return [Response, ApiError] Response when success, ApiError on failure.
1492
+ def get_snapshot_slot
1493
+ warn "DEPRECATED: Please use getHighestSnapshotSlot instead This method is expected to be removed in solana-core v2.0"
1494
+ http_method = :post
1495
+ method = create_method_name(__method__)
1496
+
1497
+ body = create_json_body(method)
1498
+
1499
+ send_request(body, http_method)
1500
+ end
1501
+
1309
1502
  private
1503
+
1310
1504
  def send_request(body, http_method)
1311
1505
  api_response = api_client.call_api(
1312
1506
  body: body,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolanaRpcRuby
4
- VERSION = '1.1.4'
4
+ VERSION = '1.2.0'
5
5
  end
@@ -29,7 +29,7 @@ module SolanaRpcRuby
29
29
  # @param cluster [String] cluster where requests will be sent.
30
30
  # @param id [Integer] unique client-generated identifying integer.
31
31
  def initialize(
32
- websocket_client: WebsocketClient,
32
+ websocket_client: WebsocketClient,
33
33
  cluster: SolanaRpcRuby.ws_cluster,
34
34
  id: rand(1...99_999)
35
35
  )
@@ -47,7 +47,7 @@ module SolanaRpcRuby
47
47
  #
48
48
  # @return [Integer] Subscription id (needed to unsubscribe)
49
49
  def account_subscribe(account_pubkey, commitment: nil, encoding: '', &block)
50
- method = create_method_name(__method__)
50
+ method = create_method_name(__method__)
51
51
 
52
52
  params = []
53
53
  params_hash = {}
@@ -56,7 +56,7 @@ module SolanaRpcRuby
56
56
 
57
57
  params << account_pubkey
58
58
  params << params_hash if params_hash.any?
59
-
59
+
60
60
  subscribe(method, method_params: params, &block)
61
61
  end
62
62
 
@@ -71,6 +71,57 @@ module SolanaRpcRuby
71
71
  unsubscribe(method, subscription_id: subscription_id)
72
72
  end
73
73
 
74
+ # @see https://docs.solana.com/developing/clients/jsonrpc-api#blocksubscribe---unstable-disabled-by-default
75
+ # This subscription is unstable and only available if the validator was started with the --rpc-pubsub-enable-block-subscription flag. The format of this subscription may change in the future
76
+ #
77
+ # Subscribe to receive notification anytime a new block is Confirmed or Finalized.
78
+ #
79
+ # @param filter [String] # 'all' or public key as base-58 endcoded string
80
+ # @param commitment [String]
81
+ # @param encoding [String]
82
+ # @param transaction_details [String]
83
+ # @param show_rewards [Boolean]
84
+ # @param &block [Proc]
85
+ #
86
+ # @return [Integer] Subscription id (needed to unsubscribe)
87
+ def block_subscribe(
88
+ filter,
89
+ commitment: nil,
90
+ encoding: '',
91
+ transaction_details: '',
92
+ show_rewards: nil,
93
+ &block
94
+ )
95
+ method = create_method_name(__method__)
96
+
97
+ params = []
98
+ param_filter = nil
99
+ params_hash = {}
100
+
101
+ param_filter = filter == 'all' ? filter : { 'mentionsAccountOrProgram': filter}
102
+
103
+ params_hash['commitment'] = commitment unless blank?(commitment)
104
+ params_hash['encoding'] = encoding unless blank?(encoding)
105
+ params_hash['transactionDetails'] = transaction_details unless blank?(transaction_details)
106
+ params_hash['showRewards'] = show_rewards unless blank?(show_rewards)
107
+
108
+ params << param_filter
109
+ params << params_hash if params_hash.any?
110
+
111
+ subscribe(method, method_params: params, &block)
112
+ end
113
+
114
+ # @see https://docs.solana.com/developing/clients/jsonrpc-api#blockunsubscribe
115
+ # Unsubscribe from block notifications
116
+ #
117
+ # @param subscription_id [Integer]
118
+ #
119
+ # @return [Bool] unsubscribe success message
120
+ def block_unsubscribe(subscription_id)
121
+ method = create_method_name(__method__)
122
+ unsubscribe(method, subscription_id: subscription_id)
123
+ end
124
+
74
125
  # @see https://docs.solana.com/developing/clients/jsonrpc-api#logssubscribe
75
126
  # Subscribe to transaction logging
76
127
  #
@@ -81,15 +132,15 @@ module SolanaRpcRuby
81
132
  #
82
133
  # @return [Integer] Subscription id (needed to unsubscribe)
83
134
  def logs_subscribe(filter, commitment: nil, &block)
84
- method = create_method_name(__method__)
135
+ method = create_method_name(__method__)
85
136
 
86
137
  params = []
87
138
  params_hash = {}
88
139
  params_hash['commitment'] = commitment unless blank?(commitment)
89
-
140
+
90
141
  params << filter
91
142
  params << params_hash
92
-
143
+
93
144
  subscribe(method, method_params: params, &block)
94
145
  end
95
146
 
@@ -107,7 +158,7 @@ module SolanaRpcRuby
107
158
 
108
159
  # @see https://docs.solana.com/developing/clients/jsonrpc-api#programsubscribe
109
160
  # Subscribe to a program to receive notifications when the lamports or data for a given account owned by the program changes
110
- #
161
+ #
111
162
  # @param account_pubkey [String]
112
163
  # @param commitment [String]
113
164
  # @param encoding [String]
@@ -116,13 +167,13 @@ module SolanaRpcRuby
116
167
  #
117
168
  # @return [Integer] Subscription id (needed to unsubscribe)
118
169
  def program_subscribe(
119
- program_id_pubkey,
120
- commitment: nil,
121
- encoding: '',
170
+ program_id_pubkey,
171
+ commitment: nil,
172
+ encoding: '',
122
173
  filters: [],
123
174
  &block
124
175
  )
125
- method = create_method_name(__method__)
176
+ method = create_method_name(__method__)
126
177
 
127
178
  params = []
128
179
  params_hash = {}
@@ -132,7 +183,7 @@ module SolanaRpcRuby
132
183
 
133
184
  params << program_id_pubkey
134
185
  params << params_hash if params_hash.any?
135
-
186
+
136
187
  subscribe(method, method_params: params, &block)
137
188
  end
138
189
 
@@ -149,7 +200,7 @@ module SolanaRpcRuby
149
200
  end
150
201
 
151
202
  # @see https://docs.solana.com/developing/clients/jsonrpc-api#signaturesubscribe
152
- # Subscribe to a transaction signature to receive notification when the transaction is confirmed
203
+ # Subscribe to a transaction signature to receive notification when the transaction is confirmed
153
204
  # On signatureNotification, the subscription is automatically cancelled
154
205
  #
155
206
  # @param transaction_signature [String]
@@ -158,19 +209,19 @@ module SolanaRpcRuby
158
209
  #
159
210
  # @return [Integer] Subscription id (needed to unsubscribe)
160
211
  def signature_subscribe(
161
- transaction_signature,
212
+ transaction_signature,
162
213
  commitment: nil,
163
214
  &block
164
215
  )
165
- method = create_method_name(__method__)
216
+ method = create_method_name(__method__)
166
217
 
167
218
  params = []
168
219
  params_hash = {}
169
220
  params_hash['commitment'] = commitment unless blank?(commitment)
170
-
221
+
171
222
  params << transaction_signature
172
223
  params << params_hash
173
-
224
+
174
225
  subscribe(method, method_params: params, &block)
175
226
  end
176
227
 
@@ -189,11 +240,11 @@ module SolanaRpcRuby
189
240
  # Subscribe to receive notification anytime a slot is processed by the validator
190
241
  #
191
242
  # @param &block [Proc]
192
- #
243
+ #
193
244
  # @return [Integer] Subscription id (needed to unsubscribe)
194
245
  def slot_subscribe(&block)
195
246
  method = create_method_name(__method__)
196
-
247
+
197
248
  subscribe(method, &block)
198
249
  end
199
250
 
@@ -209,16 +260,16 @@ module SolanaRpcRuby
209
260
  end
210
261
 
211
262
  # @see https://docs.solana.com/developing/clients/jsonrpc-api#slotsupdatessubscribe---unstable
212
- #
263
+ #
213
264
  # This subscription is unstable; the format of this subscription may change in the future and it may not always be supported
214
265
  # Subscribe to receive a notification from the validator on a variety of updates on every slot
215
266
  #
216
267
  # @param &block [Proc]
217
- #
268
+ #
218
269
  # @return [Integer] Subscription id (needed to unsubscribe)
219
270
  def slots_updates_subscribe(&block)
220
271
  method = create_method_name(__method__)
221
-
272
+
222
273
  subscribe(method, &block)
223
274
  end
224
275
 
@@ -234,15 +285,15 @@ module SolanaRpcRuby
234
285
  end
235
286
 
236
287
  # @see https://docs.solana.com/developing/clients/jsonrpc-api#rootsubscribe
237
- #
288
+ #
238
289
  # Subscribe to receive notification anytime a new root is set by the validator.
239
290
  #
240
291
  # @param &block [Proc]
241
- #
292
+ #
242
293
  # @return [Integer] Subscription id (needed to unsubscribe)
243
294
  def root_subscribe(&block)
244
295
  method = create_method_name(__method__)
245
-
296
+
246
297
  subscribe(method, &block)
247
298
  end
248
299
 
@@ -258,19 +309,19 @@ module SolanaRpcRuby
258
309
  end
259
310
 
260
311
  # @see https://docs.solana.com/developing/clients/jsonrpc-api#votesubscribe---unstable-disabled-by-default
261
- #
262
- # This subscription is unstable and only available if the validator was started with the --rpc-pubsub-enable-vote-subscription flag.
312
+ #
313
+ # This subscription is unstable and only available if the validator was started with the --rpc-pubsub-enable-vote-subscription flag.
263
314
  # The format of this subscription may change in the future
264
- #
265
- # Subscribe to receive notification anytime a new vote is observed in gossip.
315
+ #
316
+ # Subscribe to receive notification anytime a new vote is observed in gossip.
266
317
  # These votes are pre-consensus therefore there is no guarantee these votes will enter the ledger.
267
318
  #
268
319
  # @param &block [Proc]
269
- #
320
+ #
270
321
  # @return [Integer] Subscription id (needed to unsubscribe)
271
322
  def vote_subscribe(&block)
272
323
  method = create_method_name(__method__)
273
-
324
+
274
325
  subscribe(method, &block)
275
326
  end
276
327
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solana_rpc_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Block Logic Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-15 00:00:00.000000000 Z
11
+ date: 2022-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faye-websocket
@@ -256,7 +256,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
256
256
  - !ruby/object:Gem::Version
257
257
  version: '0'
258
258
  requirements: []
259
- rubygems_version: 3.0.8
259
+ rubygems_version: 3.2.2
260
260
  signing_key:
261
261
  specification_version: 4
262
262
  summary: Ruby wrapper for solana JSON RPC API.