readAddress static method

dynamic readAddress(
  1. String hexValue,
  2. Uint8List b
)

Implementation

static readAddress(String hexValue, Uint8List b) {
  if (hexValue.length != 44 && hexValue.length != 42) {
    throw new Exception("Incorrect hex length to parse an address");
  }
  var implicitHint = hexValue.length == 44
      ? hexValue.substring(0, 4)
      : "00" + hexValue.substring(0, 2);
  if (implicitHint == "0000") {
    return GenerateKeys.readKeysWithHint(b, '06a19f');
  } else if (implicitHint == "0001") {
    return GenerateKeys.readKeysWithHint(b, '06a1a1');
  } else if (implicitHint == "0002") {
    return GenerateKeys.readKeysWithHint(b, '06a1a4');
  } else if (hexValue.substring(0, 2) == "01" && hexValue.length == 44) {
    return GenerateKeys.readKeysWithHint(
        Uint8List.fromList(
          hex.decode(
            hexValue.substring(
              2,
              42,
            ),
          ),
        ),
        '025a79');
  } else {
    throw new Exception("Unrecognized address type");
  }
}