Method: FlowClient::Client#get_account
- Defined in:
- lib/flow_client/client.rb
#get_account(address) ⇒ FlowClient::Account
Returns an account for the address specified at the latest block.
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 |
# File 'lib/flow_client/client.rb', line 37 def get_account(address) req = Access::GetAccountAtLatestBlockRequest.new(address: to_bytes(address)) begin res = @stub.get_account_at_latest_block(req) rescue GRPC::BadStatus => e raise ClientError, e.details else account = FlowClient::Account.new( address: res.account.address.unpack1("H*"), balance: res.account.balance/100000000.0 ) res.account.keys.each do |key| account.keys << FlowClient::AccountKey.new( public_key: key.public_key.unpack1("H*"), index: key.index, sequence_number: key.sequence_number, revoked: key.revoked, weight: key.weight ) end account.contracts = res.account.contracts account end end |