decodeAddr method

  1. @override
List<int> decodeAddr(
  1. String addr
)
override

Overrides the base class method to decode an OKExChain address.

Implementation

@override
List<int> decodeAddr(String addr) {
  try {
    /// Decode the OKExChain address using the OKExChain configuration's HRP.
    final List<int> addrDecBytes = Bech32Decoder.decode(
      AddrKeyValidator.getConfigArg(
        CoinsConf.okexChain.params.addrHrp,
        "addrHrp",
      ),
      addr,
    );

    /// Decode the address again as an Ethereum address with a custom prefix.
    return EthAddrDecoder().decodeAddr(
      AddrKeyValidator.getConfigArg(
            CoinsConf.ethereum.params.addrPrefix,
            "addrPrefix",
          ) +
          BytesUtils.toHexString(addrDecBytes),
      skipChecksum: true,
    );
  } catch (e) {
    throw AddressConverterException.addressValidationFailed(
      details: {"error": e.toString()},
    );
  }
}