Module: SolanaRuby::WebSocketMethods::AccountMethods
- Included in:
- SolanaRuby::WebSocketClient
- Defined in:
- lib/solana_ruby/web_socket_methods/account_methods.rb
Overview
Acccount Related Web Socket Methods
Constant Summary collapse
- FINALIZED_OPTIONS =
{ commitment: "finalized" }.freeze
- ENCODING_OPTIONS =
{ encoding: "base64" }.freeze
Instance Method Summary collapse
- #on_account_change(pubkey, options = FINALIZED_OPTIONS, &block) ⇒ Object
- #on_program_account_change(program_id, options = ENCODING_OPTIONS.merge(FINALIZED_OPTIONS), filters = [], &block) ⇒ Object
-
#remove_account_change_listener(subscription_id) ⇒ Object
Unsubscribe from account change updates.
-
#remove_program_account_listener(subscription_id) ⇒ Object
Unsubscribe from program account change updates.
Instance Method Details
#on_account_change(pubkey, options = FINALIZED_OPTIONS, &block) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/solana_ruby/web_socket_methods/account_methods.rb', line 10 def on_account_change(pubkey, = FINALIZED_OPTIONS, &block) params = [pubkey, ] subscribe("accountSubscribe", params) do |account_info| block.call(account_info) end end |
#on_program_account_change(program_id, options = ENCODING_OPTIONS.merge(FINALIZED_OPTIONS), filters = [], &block) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/solana_ruby/web_socket_methods/account_methods.rb', line 24 def on_program_account_change(program_id, = ENCODING_OPTIONS.merge(FINALIZED_OPTIONS), filters = [], &block) params = [program_id, ] params.last[:filters] = filters unless filters.empty? subscribe("programSubscribe", params, &block) end |
#remove_account_change_listener(subscription_id) ⇒ Object
Unsubscribe from account change updates
19 20 21 22 |
# File 'lib/solana_ruby/web_socket_methods/account_methods.rb', line 19 def remove_account_change_listener(subscription_id) unsubscribe("accountUnsubscribe", subscription_id) @subscriptions.delete(subscription_id) end |
#remove_program_account_listener(subscription_id) ⇒ Object
Unsubscribe from program account change updates
32 33 34 |
# File 'lib/solana_ruby/web_socket_methods/account_methods.rb', line 32 def remove_program_account_listener(subscription_id) unsubscribe("programUnsubscribe", subscription_id) end |