encodeKey method
Overrides the base class method to encode a public key as an OKExChain address using Bech32 encoding.
This method encodes a public key as an OKExChain address using Bech32 encoding. It expects an Ethereum address as input, encodes it as an Ethereum address without a '0x' prefix, and then encodes it as an OKExChain address using the OKExChain configuration's Human-Readable Part (HRP). The result is returned as a String representing the Bech32-encoded OKExChain address.
Parameters:
- pubKey: The Ethereum address in the form of a List
- kwargs: Optional keyword arguments.
Returns: A String representing the Bech32-encoded OKExChain address derived from the provided Ethereum address.
Implementation
@override
String encodeKey(List<int> pubKey, [Map<String, dynamic> kwargs = const {}]) {
/// Encode the Ethereum address without the '0x' prefix.
final String ethAddr =
StringUtils.strip0x(EthAddrEncoder().encodeKey(pubKey));
/// Encode the Ethereum address as an OKExChain address using Bech32 encoding.
return Bech32Encoder.encode(
CoinsConf.okexChain.params.addrHrp!,
BytesUtils.fromHexString(ethAddr),
);
}