Module: Solana::Ruby::Kit::Rpc::Api::GetAccountInfo
Overview
Fetches all stored information for an account at the given address. Mirrors TypeScript’s ‘GetAccountInfoApi.getAccountInfo(address, config?)`.
Returns a ‘RpcContextualValue` with:
.slot — context slot
.value — AccountInfoWithBase64Data | AccountInfoWithJsonData | nil
(nil when the account does not exist)
Constant Summary collapse
Instance Method Summary collapse
Instance Method Details
#get_account_info(address, encoding: 'base64', commitment: nil, min_context_slot: nil, data_slice: nil) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/solana/ruby/kit/rpc/api/get_account_info.rb', line 31 def get_account_info( address, encoding: 'base64', commitment: nil, min_context_slot: nil, data_slice: nil ) config = { 'encoding' => encoding } config['commitment'] = commitment.to_s if commitment config['minContextSlot'] = min_context_slot if min_context_slot config['dataSlice'] = data_slice if data_slice result = transport.request('getAccountInfo', [address, config]) slot = Kernel.Integer(result['context']['slot']) raw = result['value'] value = if raw.nil? nil elsif encoding == 'jsonParsed' RpcTypes::AccountInfoWithJsonData.new( executable: raw['executable'], lamports: Kernel.Integer(raw['lamports']), owner: raw['owner'], space: Kernel.Integer(raw.fetch('space', 0)), rent_epoch: Kernel.Integer(raw.fetch('rentEpoch', 0)), data: raw['data'] ) else RpcTypes::AccountInfoWithBase64Data.new( executable: raw['executable'], lamports: Kernel.Integer(raw['lamports']), owner: raw['owner'], space: Kernel.Integer(raw.fetch('space', 0)), rent_epoch: Kernel.Integer(raw.fetch('rentEpoch', 0)), data: Kernel.Array(raw['data']) ) end RpcTypes::RpcContextualValue.new(slot: slot, value: value) end |