solace 0.0.9 → 0.0.10

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: d4a098840bd57cd1b7f5380aa77f15e8e7098162b0b9e33d45ba6bcc6359ca4c
4
- data.tar.gz: c81d536ae4ab12043505b5689adf45675f47b963ed66d4e8a42fe9ed91f0ce4b
3
+ metadata.gz: 669a517f72b280a594613b55fcd3e86c6e0f7ef9ba3d6633b0edfbd5dc5b0a0c
4
+ data.tar.gz: a542d3ce4edaeb81d3c6e8aee35fadfb9df4a4cd5a618f9f643ac46544f4cc65
5
5
  SHA512:
6
- metadata.gz: 6653760f426f50f5d64e6c3a31f39c84ebf9e1e3fe12c77fac8ffcbd9a22b4c78b6ebddd69e18ddf374670967b52fbc227d72c845d5ca4086831277a8daff75d
7
- data.tar.gz: ff9c39b9f2ecb89845fdb29ad5f923cd2855806c3e7c30d1ef0b6823f8938e55f073eeea2f6870b9c3b354345a2c89ab8ea88ff3fdb0d448a011ccb576bbbeeb
6
+ metadata.gz: c43a013d3007b0853a5501c96dc7b2e737b0aefa5d35844008127ddcdfd59c0770e4ceaf9db99086aa69c294ae20563b022b3d6e370be84701c9fe8a453ce25d
7
+ data.tar.gz: 42eab84e19bf00741e1c29a50facb39966f3020a005c2baa3ee63d545d6a43bcc267cb86d17ba09cb05be6d64875504c9a557275f9c365f6ce5764ce95501baf
data/CHANGELOG CHANGED
@@ -16,6 +16,18 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
16
16
  ### Fixed
17
17
  ```
18
18
 
19
+ ## [0.0.10] - yyyy-mm-dd
20
+
21
+ ### Added
22
+ 1.
23
+
24
+ ### Changed
25
+ 2. Updated `build_instructions` method on `TransactionComposer` to flatten the array, allowing composers to return multiple instructions when relevant (i.e. creating an account and then writing to it).
26
+ 3. Changed get_latest_blockhash to use the expected comittment level by the connection or passed options and return array (blockhash and lastValidBlockheight)
27
+ 4. Changed default commitment level to `processed` in `Solace::Connection`.
28
+
29
+ ### Fixed
30
+
19
31
  ## [0.0.9] - 2025-08-12
20
32
 
21
33
  ### Added
data/README.md CHANGED
@@ -61,7 +61,7 @@ message = Solace::Message.new(
61
61
  system_program_id
62
62
  ],
63
63
  instructions: [transfer_instruction],
64
- recent_blockhash: connection.get_latest_blockhash,
64
+ recent_blockhash: connection.get_latest_blockhash[0],
65
65
  )
66
66
 
67
67
  # Create and sign transaction
@@ -51,7 +51,7 @@ module Solace
51
51
  # @param [Integer] http_read_timeout The timeout for reading an HTTP response
52
52
  def initialize(
53
53
  rpc_url = 'http://localhost:8899',
54
- commitment: 'confirmed',
54
+ commitment: 'processed',
55
55
  http_open_timeout: 30,
56
56
  http_read_timeout: 60
57
57
  )
@@ -69,23 +69,6 @@ module Solace
69
69
  }
70
70
  end
71
71
 
72
- # Sends a JSON-RPC request to the configured Solana RPC server.
73
- #
74
- # @param method [String] the JSON-RPC method name
75
- # @param params [Array] the parameters for the RPC method
76
- # @return [Hash] the parsed JSON response
77
- # @raise [
78
- # Solace::Errors::HTTPError,
79
- # Solace::Errors::ParseError,
80
- # Solace::Errors::RPCError,
81
- # Solace::Errors::ConfirmationTimeout
82
- # ]
83
- def rpc_request(method, params = [])
84
- request = build_rpc_request(method, params)
85
- response = perform_http_request(request)
86
- handle_rpc_response(response)
87
- end
88
-
89
72
  # Request an airdrop of lamports to a given address
90
73
  #
91
74
  # @param pubkey [String] The public key of the account to receive the airdrop
@@ -103,11 +86,23 @@ module Solace
103
86
  )
104
87
  end
105
88
 
89
+ # Build options for get_latest_blockhash
90
+ #
91
+ # @return [Hash{Symbol => Object}]
92
+ def build_get_latest_blockhash_options
93
+ {
94
+ commitment: default_options[:commitment]
95
+ }
96
+ end
97
+
106
98
  # Get the latest blockhash from the Solana node
107
99
  #
108
- # @return [String] The latest blockhash
100
+ # @return [Array<String, Integer>] The latest blockhash and lastValidBlockHeight
109
101
  def get_latest_blockhash
110
- @rpc_client.rpc_request('getLatestBlockhash').dig('result', 'value', 'blockhash')
102
+ @rpc_client
103
+ .rpc_request('getLatestBlockhash', [build_get_latest_blockhash_options])
104
+ .dig('result', 'value')
105
+ .values_at('blockhash', 'lastValidBlockHeight')
111
106
  end
112
107
 
113
108
  # Get the minimum required lamports for rent exemption
@@ -178,13 +173,26 @@ module Solace
178
173
  get_signature_statuses([signature])
179
174
  end
180
175
 
176
+ # Builds send_tranaction options
177
+ #
178
+ # @params [Hash] The overrides for the options
179
+ # @return [Hash] The options for the send_transaction call
180
+ def build_send_transaction_options(overrides)
181
+ {
182
+ skipPreflight: false,
183
+ encoding: default_options[:encoding],
184
+ commitment: default_options[:commitment],
185
+ preflightCommitment: default_options[:commitment]
186
+ }.merge(overrides)
187
+ end
188
+
181
189
  # Send a transaction to the Solana node
182
190
  #
183
191
  # @param transaction [Solace::Transaction] The transaction to send
192
+ # @param [Hash{Symbol => Object}] overrides
184
193
  # @return [String] The signature of the transaction
185
- # @param [Hash{Symbol => Object}] options
186
- def send_transaction(transaction, options = {})
187
- @rpc_client.rpc_request('sendTransaction', [transaction, default_options.merge(options)])
194
+ def send_transaction(transaction, overrides = {})
195
+ @rpc_client.rpc_request('sendTransaction', [transaction, build_send_transaction_options(overrides)])
188
196
  end
189
197
 
190
198
  # Wait until the yielded signature reaches the desired commitment or timeout.
@@ -95,7 +95,7 @@ module Solace
95
95
  message = Message.new(
96
96
  header: [2, 0, 3],
97
97
  accounts: accounts,
98
- recent_blockhash: @connection.get_latest_blockhash,
98
+ recent_blockhash: @connection.get_latest_blockhash[0],
99
99
  instructions: [create_account_ix, initialize_mint_ix]
100
100
  )
101
101
 
@@ -153,7 +153,7 @@ module Solace
153
153
  header: [2, 0, 1],
154
154
  accounts: accounts,
155
155
  instructions: [ix],
156
- recent_blockhash: connection.get_latest_blockhash
156
+ recent_blockhash: connection.get_latest_blockhash[0]
157
157
  )
158
158
 
159
159
  tx = Solace::Transaction.new(message: message)
@@ -210,7 +210,7 @@ module Solace
210
210
  header: [2, 0, 1],
211
211
  accounts: accounts,
212
212
  instructions: [ix],
213
- recent_blockhash: connection.get_latest_blockhash
213
+ recent_blockhash: connection.get_latest_blockhash[0]
214
214
  )
215
215
 
216
216
  tx = Solace::Transaction.new(message: message)
@@ -90,7 +90,7 @@ module Solace
90
90
  header: context.header,
91
91
  accounts: context.accounts,
92
92
  instructions: build_instructions,
93
- recent_blockhash: connection.get_latest_blockhash
93
+ recent_blockhash: connection.get_latest_blockhash[0]
94
94
  )
95
95
 
96
96
  Solace::Transaction.new(message: message)
@@ -102,7 +102,7 @@ module Solace
102
102
  #
103
103
  # @return [Array<Solace::Instruction>] The built instructions
104
104
  def build_instructions
105
- instruction_composers.map { _1.build_instruction(context) }
105
+ instruction_composers.map { _1.build_instruction(context) }.flatten
106
106
  end
107
107
 
108
108
  # Merge all accounts from another AccountContext into this one
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Solace::VERSION is the version of the Solace gem
4
4
  module Solace
5
- VERSION = '0.0.9'
5
+ VERSION = '0.0.10'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solace
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Scholl