def account_to_dict(address, with_storage_root: false, with_storage: true)
      address = Utils.normalize_address address

      # if there are uncommited account changes the current storage root is
      # meaningless
      raise ArgumentError, "cannot include storage root with uncommited account changes" if with_storage_root && !@journal.empty?

      h = {}
      account = get_account address

      h[:nonce] = (@caches[:nonce][address] || account.nonce).to_s
      h[:balance] = (@caches[:balance][address] || account.balance).to_s

      code = @caches[:code][address] || account.code
      h[:code] = "0x#{Utils.encode_hex code}"

      storage_trie = SecureTrie.new PruningTrie.new(db, account.storage)
      h[:storage_root] = Utils.encode_hex storage_trie.root_hash if with_storage_root
      if with_storage
        h[:storage] = {}
        sh = storage_trie.to_h

        cache = @caches["storage:#{address}"] || {}
        keys = cache.keys.map {|k| Utils.zpad Utils.coerce_to_bytes(k), 32 }

        (sh.keys + keys).each do |k|
          hexkey = "0x#{Utils.encode_hex Utils.zunpad(k)}"

          v = cache[Utils.big_endian_to_int(k)]
          if v.true?
            h[:storage][hexkey] = "0x#{Utils.encode_hex Utils.int_to_big_endian(v)}"
          else
            v = sh[k]
            h[:storage][hexkey] = "0x#{Utils.encode_hex RLP.decode(v)}" if v
          end
        end
      end

      h
    end
def account_to_dict(address, with_storage_root: false, with_storage: true)
      address = Utils.normalize_address address

      # if there are uncommited account changes the current storage root is
      # meaningless
      raise ArgumentError, "cannot include storage root with uncommited account changes" if with_storage_root && !@journal.empty?

      h = {}
      account = get_account address

      h[:nonce] = (@caches[:nonce][address] || account.nonce).to_s
      h[:balance] = (@caches[:balance][address] || account.balance).to_s

      code = @caches[:code][address] || account.code
      h[:code] = "0x#{Utils.encode_hex code}"

      storage_trie = SecureTrie.new PruningTrie.new(db, account.storage)
      h[:storage_root] = Utils.encode_hex storage_trie.root_hash if with_storage_root
      if with_storage
        h[:storage] = {}
        sh = storage_trie.to_h

        cache = @caches["storage:#{address}"] || {}
        keys = cache.keys.map {|k| Utils.zpad Utils.coerce_to_bytes(k), 32 }

        (sh.keys + keys).each do |k|
          hexkey = "0x#{Utils.encode_hex Utils.zunpad(k)}"

          v = cache[Utils.big_endian_to_int(k)]
          if v.true?
            h[:storage][hexkey] = "0x#{Utils.encode_hex Utils.int_to_big_endian(v)}"
          else
            v = sh[k]
            h[:storage][hexkey] = "0x#{Utils.encode_hex RLP.decode(v)}" if v
          end
        end
      end

      h
    end
Serialize an account to a hash with human readable entries.

 @param address [String] the account address
 @param with_storage_root [Bool] include the account's storage root
 @param with_storage [Bool] include the whole account's storage

 @return [Hash] hash represent the account