validateEVMAddress function
Implementation
AddressError? validateEVMAddress({required String address}) {
if (address.trim().length != address.length) {
return AddressError.WHITESPACE;
}
if (!address.startsWith("0x")) {
final utxoError = validateUTXOAddress(address: address, token: null).$1;
if (utxoError == null) {
return AddressError.WRONG_CHAIN;
} else {
return AddressError.INVALID;
}
}
try {
_validate(address);
return null;
} catch (e) {
if (e.toString().contains("not EIP-55 conformant")) {
return AddressError.INVALID_CHECKSUM;
} else {
return AddressError.INVALID;
}
}
}