diff --git a/.gitignore b/.gitignore
index c55e7b8..dac7d03 100644
--- a/.gitignore
+++ b/.gitignore
@@ -42,3 +42,4 @@ package-lock.json
.vs/
bin/
.idea/
+*.iml
diff --git a/app/components/ens/nameLookup.js b/app/components/ens/nameLookup.js
index ed0a6ce..511e526 100644
--- a/app/components/ens/nameLookup.js
+++ b/app/components/ens/nameLookup.js
@@ -36,12 +36,12 @@ import DisplayBox from './DisplayBox';
const normalizer = new IDNANormalizer();
const invalidSuffix = '0000000000000000000000000000000000000000'
-const validAddress = address => address != nullAddress;
+const validAddress = address => address !== nullAddress;
const validStatusAddress = address => !address.includes(invalidSuffix);
const formatName = domainName => domainName.includes('.') ? normalizer.normalize(domainName) : normalizer.normalize(`${domainName}.stateofus.eth`);
const getDomain = fullDomain => formatName(fullDomain).split('.').slice(1).join('.');
const hashedDomain = domainName => hash(getDomain(domainName));
-const registryIsOwner = address => address == UsernameRegistrar._address;
+const registryIsOwner = address => address === UsernameRegistrar._address;
const { soliditySha3, fromWei } = web3.utils;
@@ -70,7 +70,7 @@ const pastReleaseDate = timestamp => new Date > new Date(timestamp * 1000);
const MobileAddressDisplay = ({ domainName, address, statusAccount, expirationTime, creationTime, defaultAccount, isOwner, edit, onSubmit, handleChange, values, handleSubmit }) => (
-
+
{ this.setState({ copied: v }) }
- const isCopied = address => address == copied;
+ const isCopied = address => address === copied;
const renderCopied = address => isCopied(address) && Copied!;
const onClose = value => { this.setState({ editAction: value, editMenu: false }) }
const onClickEdit = () => { validAddress(address) ? this.setState({ editMenu: true }) : this.setState({ editAction: 'edit' }) }
@@ -120,7 +120,7 @@ class RenderAddresses extends PureComponent {
const canBeReleased = validTimestamp(expirationTime) && pastReleaseDate(expirationTime);
const closeReleaseAlert = value => {
if (!isNil(value)) {
- this.setState({ submitted: true })
+ this.setState({ submitted: true });
release(
soliditySha3(domainName)
)
@@ -186,7 +186,7 @@ const RegisterInfoCard = ({ formattedDomain, domainPrice, registryOwnsDomain })
-)
+);
const TransactionComplete = ({ type, setStatus }) => (
@@ -269,7 +269,7 @@ const DisplayAddress = connect(mapStateToProps)((props) => (
))
-const LookupForm = ({ handleSubmit, values, handleChange, justSearch }) => (
+const LookupForm = ({ handleSubmit, values, handleChange, isWarningDisplayed }) => (
-)
+);
+
+const isValidDomainName = val => /^([a-z0-9]+)$/.test(val.toLowerCase());
const NameLookup = withFormik({
mapPropsToValues: props => ({ domainName: '' }),
+
async handleSubmit(values, { status, setSubmitting, setStatus }) {
const { domainName } = values;
- const { methods: { owner, resolver } } = ENSRegistry;
- const lookupHash = hash(formatName(domainName));
- const subdomainHash = soliditySha3(domainName);
- const resolverContract = await getResolver(lookupHash);
- const { addr, pubkey } = resolverContract.methods;
- const address = addr(lookupHash).call();
- const keys = pubkey(lookupHash).call();
- const ownerAddress = owner(lookupHash).call();
- const suffixOwner = owner(hash(getDomain(domainName))).call();
- const expirationTime = getExpirationTime(subdomainHash).call();
- const creationTime = getCreationTime(subdomainHash).call();
- Promise.all([address, keys, ownerAddress, expirationTime, creationTime, suffixOwner])
- .then(([ address, keys, ownerAddress, expirationTime, creationTime, suffixOwner ]) => {
- const statusAccount = keyFromXY(keys[0], keys[1]);
- const registryOwnsDomain = registryIsOwner(suffixOwner)
- const resolvedDomainName = domainName;
- setStatus({ address, statusAccount, expirationTime, creationTime, ownerAddress, registryOwnsDomain, resolvedDomainName });
- })
+
+ if (isValidDomainName(domainName)) {
+ const { methods: { owner, resolver } } = ENSRegistry;
+ const lookupHash = hash(formatName(domainName));
+ const subdomainHash = soliditySha3(domainName);
+ const resolverContract = await getResolver(lookupHash);
+ const { addr, pubkey } = resolverContract.methods;
+ const address = addr(lookupHash).call();
+ const keys = pubkey(lookupHash).call();
+ const ownerAddress = owner(lookupHash).call();
+ const suffixOwner = owner(hash(getDomain(domainName))).call();
+ const expirationTime = getExpirationTime(subdomainHash).call();
+ const creationTime = getCreationTime(subdomainHash).call();
+
+ Promise.all([address, keys, ownerAddress, expirationTime, creationTime,suffixOwner])
+ .then(([ address, keys, ownerAddress, expirationTime, creationTime, suffixOwner ]) => {
+ const statusAccount = keyFromXY(keys[0], keys[1]);
+ const registryOwnsDomain = registryIsOwner(suffixOwner);
+
+ setStatus({
+ address,
+ statusAccount,
+ expirationTime,
+ creationTime,
+ ownerAddress,
+ registryOwnsDomain,
+ domainName
+ });
+ });
+ } else {
+ setStatus({isInvalidDomain: true });
+ }
}
-})(InnerForm)
+})(InnerForm);
export default connect(mapStateToProps)(NameLookup);