solana_rpc_ruby 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -1
- data/README.md +10 -2
- data/lib/solana_rpc_ruby/methods_wrapper.rb +13 -1
- data/lib/solana_rpc_ruby/request_body.rb +9 -4
- data/lib/solana_rpc_ruby/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8994ffbb52e73a3bca8479da9dcef3cc95bbed08785c3250341a0172843aa634
|
4
|
+
data.tar.gz: 9865e6aec8576bb6d1ab7ae8bb342b1cdd548b60bab0831b302a17782d941e06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 198abd4194eca1ae77dee6d73ebfd16abeab319d2a14488602dab1403cf75c3fb2ce2a27f54c1cb67d88165defcf425fd1a6b6873520298a6f7f2a6700a151dd
|
7
|
+
data.tar.gz: c107ba6e72f81988c0545763dc8096f031ce705ee96e860c7d913ad3c07906006ce1196fc66e0fd6885f87fd3c6001b7b9276d52ba7885cc47062aa49b2d1c1b
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
![specs](https://github.com/Block-Logic/solana-rpc-ruby/actions/workflows/specs.yml/badge.svg
|
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(
|
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
|
-
|
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":
|
35
|
+
"id": id
|
31
36
|
}
|
32
37
|
end
|
33
38
|
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.
|
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-
|
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.
|
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.
|