getAddressType static method

AddressType getAddressType(
  1. String raw
)

Implementation

static AddressType getAddressType(String raw) {
  if (validator.isAddress(raw) && validator.isValidChecksumAddress(raw)) {
    return AddressType.CheckSum;
  } else if (validator.isAddress(raw) &&
      !validator.isValidChecksumAddress(raw) &&
      raw.startsWith('0x')) {
    return AddressType.Bytes20Hex;
  } else if (validator.isAddress(raw) &&
      !validator.isValidChecksumAddress(raw) &&
      !raw.startsWith('0x')) {
    return AddressType.Bytes20;
  } else if (validator.isBech32(raw) &&
      validator.isValidChecksumAddress(fromBech32Address(raw))) {
    return AddressType.Bech32;
  } else {
    return AddressType.Invalid;
  }
}