Sha256: b5ec4a83eaa67ef4f19d759a45b37fb8be286ae34ff8a3f804a40e8df08c0b11
Contents?: true
Size: 1.21 KB
Versions: 12
Compression:
Stored size: 1.21 KB
Contents
# frozen_string_literal: true module SolanaRuby module WebSocketMethods # Acccount Related Web Socket Methods module AccountMethods FINALIZED_OPTIONS = { commitment: "finalized" }.freeze ENCODING_OPTIONS = { encoding: "base64" }.freeze def on_account_change(pubkey, options = FINALIZED_OPTIONS, &block) params = [pubkey, options] subscribe("accountSubscribe", params) do |account_info| block.call(account_info) end end # Unsubscribe from account change updates def remove_account_change_listener(subscription_id) unsubscribe("accountUnsubscribe", subscription_id) @subscriptions.delete(subscription_id) end def on_program_account_change(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 # Unsubscribe from program account change updates def remove_program_account_listener(subscription_id) unsubscribe("programUnsubscribe", subscription_id) end end end end
Version data entries
12 entries across 12 versions & 1 rubygems