encodeKey method
Encodes a public key into a Substrate address.
This method takes a public key as a List<int> and an optional map of keyword
arguments, with the 'ss58_format' key specifying the desired SS58 format for
the address. It validates the arguments, encodes the public key, and returns
the resulting Substrate address as a String.
Parameters:
- pubKey: The public key to be encoded as a Substrate address.
- kwargs: Optional keyword arguments (e.g., 'ss58_format') for customization.
Returns: A String representing the Substrate address encoded from the provided public key.
Throws:
- FormatException if the provided SS58 format is invalid or if the public key is not a valid Ed25519 key.
Implementation
@override
String encodeKey(List<int> pubKey, {int? ss58Format}) {
ss58Format = AddrKeyValidator.getAddrArg<int>(ss58Format, "ss58Format");
final pubKeyObj = AddrKeyValidator.validateAndGetEd25519Key(pubKey);
return _SubstrateAddrUtils.encode(
pubKeyObj.compressed.sublist(1),
ss58Format,
);
}