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

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 (pubkey, options = FINALIZED_OPTIONS, &block)
  params = [pubkey, options]

  subscribe("accountSubscribe", params) do ||
    block.call()
  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 (program_id, options = ENCODING_OPTIONS.merge(FINALIZED_OPTIONS), filters = [],
                              &block)
  params = [program_id, options]
  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 (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 (subscription_id)
  unsubscribe("programUnsubscribe", subscription_id)
end