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.

Parameters:

  • the (String)

    address string value

Returns:


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 (address)
  req = Access::GetAccountAtLatestBlockRequest.new(address: to_bytes(address))

  begin
    res = @stub.(req)
  rescue GRPC::BadStatus => e
    raise ClientError, e.details
  else
     = FlowClient::Account.new(
      address: res..address.unpack1("H*"),
      balance: res..balance/100000000.0
    )

    res..keys.each do |key|
      .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

    .contracts = res..contracts
    
  end
end