encodeKey method

  1. @override
String encodeKey(
  1. List<int> pubKey, [
  2. Map<String, dynamic> kwargs = const {}
])
override

Overrides the method to encode a EOS address from a given public key.

pubKey: The public key to be encoded as an EOS address. kwargs: A map of optional keyword arguments.

This method takes a public key, computes the address checksum, and encodes it as an EOS address.

Returns a string containing the EOS address.

Implementation

@override
String encodeKey(List<int> pubKey, [Map<String, dynamic> kwargs = const {}]) {
  /// Validate and get the Secp256k1 public key object
  final pubKeyObj = AddrKeyValidator.validateAndGetSecp256k1Key(pubKey);

  /// Get the raw compressed public key bytes
  final pubKeyBytes = pubKeyObj.compressed;

  /// Compute the checksum for the address
  final checksumBytes = _EosAddrUtils.computeChecksum(pubKeyBytes);

  /// Combine the address prefix, public key, and checksum to create the EOS address
  return CoinsConf.eos.params.addrPrefix! +
      Base58Encoder.encode(List<int>.from(pubKeyBytes + checksumBytes));
}