encodeAddress static method

String encodeAddress({
  1. required List<int> hash,
  2. required int workChain,
  3. bool bounceable = true,
  4. bool testOnly = false,
  5. bool urlSafe = false,
})

Implementation

static String encodeAddress(
    {required List<int> hash,
    required int workChain,
    bool bounceable = true,
    bool testOnly = false,
    bool urlSafe = false}) {
  int tag = bounceable
      ? FriendlyAddressFlags.bounceable.flag
      : FriendlyAddressFlags.nonBounceable.flag;
  if (testOnly) {
    tag |= FriendlyAddressFlags.test.flag;
  }
  final List<int> addr =
      List<int>.unmodifiable([tag, workChain & mask8, ...hash]);
  final addrBytes = [...addr, ...Crc16.quickIntDigest(addr)];

  final encode = StringUtils.decode(addrBytes, type: StringEncoding.base64);
  if (urlSafe) {
    return encode.replaceAll('+', '-').replaceAll('/', '_');
  }
  return encode;
}