encodeGeneric static method

String encodeGeneric(
  1. String hrp,
  2. Uint8List data
)

Encodes data to Bech32 address without version byte.

Implementation

static String encodeGeneric(String hrp, Uint8List data) {
  // Cosmos uses Behc32 (original constant 1)
  final values = _convertBits(data, 8, 5, true);
  final checksum = _createChecksum(
      hrp, values, false); // Always false for generic Bech32? Or param?
  // Usually generic libraries use constant 1 (Bech32).

  final result = StringBuffer(hrp);
  result.write('1');
  for (final d in [...values, ...checksum]) {
    result.write(_charset[d]);
  }
  return result.toString();
}