decodeAddr method

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

Overrides the base class method to decode a Harmony ONE address.

This method decodes a Harmony ONE address from the provided input string using Bech32 encoding. It expects an optional map of keyword arguments for custom behavior, but specifically, it skips the checksum encoding validation. The address Human-Readable Part (HRP) is retrieved from the Harmony ONE configuration. The method first decodes the Bech32 address, and then decodes it again as an Ethereum address with a custom prefix. The result is returned as a List

Parameters:

  • addr: The Harmony ONE address to be decoded.
  • kwargs: Optional keyword arguments (with 'skip_chksum_enc' for skipping checksum encoding).

Returns: A List

Implementation

@override
List<int> decodeAddr(String addr, [Map<String, dynamic> kwargs = const {}]) {
  List<int> addrDecBytes =
      Bech32Decoder.decode(CoinsConf.harmonyOne.params.addrHrp!, addr);

  /// Decode the address again as an Ethereum address with a custom prefix.
  return EthAddrDecoder().decodeAddr(
      CoinsConf.ethereum.params.addrPrefix! +
          BytesUtils.toHexString(addrDecBytes),
      {"skip_chksum_enc": true});
}