Module: SolanaRuby::HttpMethods::AccountMethods
- Defined in:
- lib/solana_ruby/http_methods/account_methods.rb
Overview
Account Related HTTP Methods
Constant Summary collapse
- ENCODING_JSON_OPTIONS =
{ encoding: "jsonParsed", commitment: "finalized" }.freeze
- FINALIZED_OPTIONS =
{ commitment: "finalized" }.freeze
- ENCODING_BASE58_OPTIONS =
{ encoding: "base58" }.freeze
Instance Method Summary collapse
- #get_account_info(pubkey) ⇒ Object
- #get_account_info_and_context(pubkey, options = {}) ⇒ Object
- #get_largest_accounts(options = ENCODING_BASE58_OPTIONS.merge(FINALIZED_OPTIONS)) ⇒ Object
- #get_multiple_account_info(pubkeys, options = ENCODING_BASE58_OPTIONS) ⇒ Object
- #get_multiple_account_info_and_context(pubkeys, options = ENCODING_BASE58_OPTIONS) ⇒ Object
- #get_multiple_parsed_accounts(pubkeys, options = ENCODING_JSON_OPTIONS) ⇒ Object
- #get_nonce(pubkey) ⇒ Object
- #get_nonce_and_context(pubkey) ⇒ Object
- #get_parsed_account_info(pubkey, options = ENCODING_JSON_OPTIONS) ⇒ Object
- #get_parsed_program_accounts(program_id, options = ENCODING_JSON_OPTIONS) ⇒ Object
- #get_parsed_token_accounts_by_owner(owner_pubkey, filters = {}, options = ENCODING_JSON_OPTIONS) ⇒ Object
- #get_program_accounts(program_id, options = FINALIZED_OPTIONS) ⇒ Object
- #get_vote_accounts(options = FINALIZED_OPTIONS) ⇒ Object
Instance Method Details
#get_account_info(pubkey) ⇒ Object
11 12 13 14 |
# File 'lib/solana_ruby/http_methods/account_methods.rb', line 11 def get_account_info(pubkey) account_info = get_account_info_and_context(pubkey) account_info["value"] end |
#get_account_info_and_context(pubkey, options = {}) ⇒ Object
20 21 22 23 |
# File 'lib/solana_ruby/http_methods/account_methods.rb', line 20 def get_account_info_and_context(pubkey, = {}) account_info = request("getAccountInfo", [pubkey, ]) account_info["result"] end |
#get_largest_accounts(options = ENCODING_BASE58_OPTIONS.merge(FINALIZED_OPTIONS)) ⇒ Object
40 41 42 43 |
# File 'lib/solana_ruby/http_methods/account_methods.rb', line 40 def get_largest_accounts( = ENCODING_BASE58_OPTIONS.merge(FINALIZED_OPTIONS)) account_info = request("getLargestAccounts", []) account_info["result"] end |
#get_multiple_account_info(pubkeys, options = ENCODING_BASE58_OPTIONS) ⇒ Object
25 26 27 28 |
# File 'lib/solana_ruby/http_methods/account_methods.rb', line 25 def get_multiple_account_info(pubkeys, = ENCODING_BASE58_OPTIONS) accounts_info = get_multiple_account_info_and_context(pubkeys, ) accounts_info["value"] end |
#get_multiple_account_info_and_context(pubkeys, options = ENCODING_BASE58_OPTIONS) ⇒ Object
30 31 32 33 34 |
# File 'lib/solana_ruby/http_methods/account_methods.rb', line 30 def get_multiple_account_info_and_context(pubkeys, = ENCODING_BASE58_OPTIONS) params = [pubkeys, ] accounts_info = request("getMultipleAccounts", params) accounts_info["result"] end |
#get_multiple_parsed_accounts(pubkeys, options = ENCODING_JSON_OPTIONS) ⇒ Object
36 37 38 |
# File 'lib/solana_ruby/http_methods/account_methods.rb', line 36 def get_multiple_parsed_accounts(pubkeys, = ENCODING_JSON_OPTIONS) get_multiple_account_info_and_context(pubkeys, ) end |
#get_nonce(pubkey) ⇒ Object
83 84 85 86 |
# File 'lib/solana_ruby/http_methods/account_methods.rb', line 83 def get_nonce(pubkey) nonce_info = get_nonce_and_context(pubkey) nonce_info[:value] end |
#get_nonce_and_context(pubkey) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/solana_ruby/http_methods/account_methods.rb', line 66 def get_nonce_and_context(pubkey) account_info_and_context = get_account_info_and_context(pubkey) unless account_info_and_context["value"]["owner"] == "11111111111111111111111111111111" raise "Provided account is not a nonce account" end data = account_info_and_context["value"]["data"][0] raise "Nonce account data is empty" if data.nil? || data.empty? decoded_data = Base64.decode64(data) nonce_info = parse_nonce_account(decoded_data) { context: account_info_and_context["context"], value: nonce_info } end |
#get_parsed_account_info(pubkey, options = ENCODING_JSON_OPTIONS) ⇒ Object
16 17 18 |
# File 'lib/solana_ruby/http_methods/account_methods.rb', line 16 def get_parsed_account_info(pubkey, = ENCODING_JSON_OPTIONS) get_account_info_and_context(pubkey, ) end |
#get_parsed_program_accounts(program_id, options = ENCODING_JSON_OPTIONS) ⇒ Object
51 52 53 |
# File 'lib/solana_ruby/http_methods/account_methods.rb', line 51 def get_parsed_program_accounts(program_id, = ENCODING_JSON_OPTIONS) get_program_accounts(program_id, ) end |
#get_parsed_token_accounts_by_owner(owner_pubkey, filters = {}, options = ENCODING_JSON_OPTIONS) ⇒ Object
60 61 62 63 64 |
# File 'lib/solana_ruby/http_methods/account_methods.rb', line 60 def get_parsed_token_accounts_by_owner(owner_pubkey, filters = {}, = ENCODING_JSON_OPTIONS) params = [owner_pubkey, filters, ] parsed_token_accounts = request("getTokenAccountsByOwner", params) parsed_token_accounts["result"] end |
#get_program_accounts(program_id, options = FINALIZED_OPTIONS) ⇒ Object
45 46 47 48 49 |
# File 'lib/solana_ruby/http_methods/account_methods.rb', line 45 def get_program_accounts(program_id, = FINALIZED_OPTIONS) params = [program_id, ] account_info = request("getProgramAccounts", params) account_info["result"] end |
#get_vote_accounts(options = FINALIZED_OPTIONS) ⇒ Object
55 56 57 58 |
# File 'lib/solana_ruby/http_methods/account_methods.rb', line 55 def get_vote_accounts( = FINALIZED_OPTIONS) account_info = request("getVoteAccounts", []) account_info["result"] end |