solana_rpc_ruby 1.0.0 → 1.0.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d7e06c7b9170275c6f9c2db723a176c2299c9bfbfb17f162f3ae4932b96a2bec
4
- data.tar.gz: 81a53fd34e8f748201a118dcc8d19572aee2da3faf96376f2271370a5ac6364f
3
+ metadata.gz: 8994ffbb52e73a3bca8479da9dcef3cc95bbed08785c3250341a0172843aa634
4
+ data.tar.gz: 9865e6aec8576bb6d1ab7ae8bb342b1cdd548b60bab0831b302a17782d941e06
5
5
  SHA512:
6
- metadata.gz: e51c2162d5f3f8e49d33847f9f37e38ec3088d0a7deaf7900d0c3eb7239370be2836e1d93407e529f9833def7dc76cf9e7eb74aa4a23ca2cda415f4244a0ea1b
7
- data.tar.gz: 719c862c3d0a4e8a6dbe44a9300b05df6aa6be22dd689ffcfd0e1b8fb778f0d5f44aa90d5bfc80cb6a7dfeed61c0e5bd4a3cec3b9ee2155ac26f971e4428353e
6
+ metadata.gz: 198abd4194eca1ae77dee6d73ebfd16abeab319d2a14488602dab1403cf75c3fb2ce2a27f54c1cb67d88165defcf425fd1a6b6873520298a6f7f2a6700a151dd
7
+ data.tar.gz: c107ba6e72f81988c0545763dc8096f031ce705ee96e860c7d913ad3c07906006ce1196fc66e0fd6885f87fd3c6001b7b9276d52ba7885cc47062aa49b2d1c1b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
1
  # Changelog
2
- ## 1.0.0 (TBA)
2
+ ## 1.0.0
3
3
  * Initial release
4
+
5
+ ## 1.0.1
6
+ * Add optional id argument that can be passed to MethodsWrapper class.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- ![specs](https://github.com/Block-Logic/solana-rpc-ruby/actions/workflows/specs.yml/badge.svg?branch=177580443_create_wrapper_for_solana_rpc)
1
+ ![specs](https://github.com/Block-Logic/solana-rpc-ruby/actions/workflows/specs.yml/badge.svg)
2
2
  # solana_rpc_ruby
3
3
  A Solana RPC Client for Ruby. This gem provides a wrapper methods for Solana RPC JSON API https://docs.solana.com/developing/clients/jsonrpc-api.
4
4
 
@@ -37,9 +37,17 @@ You can customize it to your needs.
37
37
  ### Usage examples
38
38
  ```ruby
39
39
  # If you set default cluster you don't need to pass it every time.
40
- method_wrapper = SolanaRpcRuby::MethodsWrapper.new(cluster: 'https://api.testnet.solana.com')
40
+ method_wrapper = SolanaRpcRuby::MethodsWrapper.new(
41
+ cluster: 'https://api.testnet.solana.com', # optional, if not passed, default cluster from config will be used
42
+ id: 123 # optional, if not passed, default random number from range 1 to 99_999 will be used
43
+ )
44
+
41
45
  response = method_wrapper.get_account_info(account_pubkey)
42
46
  puts response
47
+
48
+ # You can check cluster and that are used.
49
+ method_wrapper.cluster
50
+ method_wrapper.id
43
51
  ```
44
52
 
45
53
  All info about methods you can find in the docs on: https://www.rubydoc.info/github/Block-Logic/solana-rpc-ruby/main/SolanaRpcRuby
@@ -19,12 +19,24 @@ module SolanaRpcRuby
19
19
  # @return [String]
20
20
  attr_accessor :cluster
21
21
 
22
+ # Unique client-generated identifying integer.
23
+ # @return [Integer]
24
+ attr_accessor :id
25
+
22
26
  # Initialize object with cluster address where requests will be sent.
23
27
  #
24
28
  # @param api_client [ApiClient]
25
29
  # @param cluster [String] cluster where requests will be sent.
26
- def initialize(api_client: ApiClient, cluster: SolanaRpcRuby.cluster)
30
+ # @param id [Integer] unique client-generated identifying integer.
31
+ def initialize(
32
+ api_client: ApiClient,
33
+ cluster: SolanaRpcRuby.cluster,
34
+ id: rand(1...99_999)
35
+ )
36
+
27
37
  @api_client = api_client.new(cluster)
38
+ @cluster = cluster
39
+ @id = id
28
40
  end
29
41
 
30
42
  # @see https://docs.solana.com/developing/clients/jsonrpc-api#getaccountinfo
@@ -12,22 +12,27 @@ module SolanaRpcRuby
12
12
  #
13
13
  # @param method [string] method name.
14
14
  # @param method_params [Array] ordered array with required and/or optional params.
15
+ # @param id [Integer] Unique client-generated identifying integer.
15
16
  #
16
17
  # @return [Json] JSON string with body.
17
18
  #
18
- def create_json_body(method, method_params: [])
19
- body = base_body
19
+ def create_json_body(method, method_params: [], id: @id)
20
+ body = base_body(id: id)
20
21
  body[:method] = method
21
22
  body[:params] = method_params if method_params.any?
22
23
  body.to_json
23
24
  end
24
25
 
25
26
  # Hash with default body params.
27
+ # @param id [Integer] Unique client-generated identifying integer.
28
+ #
26
29
  # @return [Hash] hash with base params for every request.
27
- def base_body
30
+ def base_body(id: 1)
31
+ raise ArgumentError, 'id must be an integer' unless id.is_a?(Integer)
32
+
28
33
  {
29
34
  "jsonrpc": SolanaRpcRuby.json_rpc_version,
30
- "id": 1
35
+ "id": id
31
36
  }
32
37
  end
33
38
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolanaRpcRuby
4
- VERSION = '1.0.0'
4
+ VERSION = '1.0.1'
5
5
  end
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.0.0
4
+ version: 1.0.1
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-07-15 00:00:00.000000000 Z
11
+ date: 2021-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -240,7 +240,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
240
240
  - !ruby/object:Gem::Version
241
241
  version: '0'
242
242
  requirements: []
243
- rubygems_version: 3.2.2
243
+ rubygems_version: 3.0.8
244
244
  signing_key:
245
245
  specification_version: 4
246
246
  summary: Ruby wrapper for solana JSON RPC API.