VoteAccount.fromBuffer constructor

VoteAccount.fromBuffer(
  1. List<int> data
)

Implementation

factory VoteAccount.fromBuffer(List<int> data) {
  final version = LayoutConst.u32().deserialize(data.sublist(0, 4)).value;
  final decode = LayoutSerializable.decode(
      bytes: data.sublist(4), layout: _Utils.layout(version));
  return VoteAccount(
      version: version,
      authorizedVoters: (decode["authorizedVoters"] as List)
          .map((e) => AuthorizedVoter.fromJson(e))
          .toList(),
      authorizedWithdrawer: decode["authorizedWithdrawer"],
      commission: decode["commission"],
      epochCredits: (decode["epochCredits"] as List)
          .map((e) => EpochCredits.fromJson(e))
          .toList(),
      lastTimestamp: BlockTimestamp.fromJson(decode["lastTimestamp"]),
      nodePubkey: decode["nodePubkey"],
      priorVoter: PriorVoters.fromJson(decode["priorVoters"]),
      rootSlot: decode["rootSlot"],
      votes:
          (decode["votes"] as List).map((e) => Lockout.fromJson(e)).toList());
}