validateAndRemovePrefix static method

String validateAndRemovePrefix(
  1. String addr,
  2. String prefix
)

Validate and remove prefix from an address.

Implementation

static String validateAndRemovePrefix(
  String addr,
  String prefix,
) {
  final prefixGot = addr.substring(0, prefix.length);

  if (prefix != prefixGot) {
    throw AddressConverterException(
      'Invalid prefix (expected $prefix, got $prefixGot)',
    );
  }

  return addr.substring(prefix.length);
}