Skip to content
This repository has been archived by the owner on Nov 21, 2019. It is now read-only.

Commit

Permalink
Reverse initial solution, Add proper error catch, add error msg
Browse files Browse the repository at this point in the history
  • Loading branch information
gamalielhere committed Aug 13, 2018
1 parent 79d0a89 commit 6a120f0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
23 changes: 14 additions & 9 deletions app/scripts/directives/addressFieldDrtv.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ var addressFieldDrtv = function($compile, darkList) {
var placeholder = attrs.placeholder == undefined ? 'mewtopia.eth or 0xDECAF9CD2367cdbb726E904cD6397eDFcAe6068D' : attrs.placeholder ;
var labelTranslated = attrs.labeltranslated == undefined ? 'SEND_addr' : attrs.labeltranslated;
var setValue = function(value) {
var temp = scope;
for (var i in varArr) {
if (i == varArr.length - 1) temp[varArr[i]] = value;
else {
temp = temp[varArr[i]];
}
var temp = scope;
for (var i in varArr) {
if (i == varArr.length - 1) temp[varArr[i]] = value;
else {
temp = temp[varArr[i]];
}
}
}

var checkDarkList = function(value) {
Expand Down Expand Up @@ -88,9 +88,14 @@ var addressFieldDrtv = function($compile, darkList) {
});
} else {
setValue('');
scope.addressDrtv.showDerivedAddress = false;
scope.phishing.msg = '';
scope.phishing.error = false;
if(scope.addressDrtv.ensAddressField !== '') {
scope.phishing.msg = 'Invalid address or ENS. Please make sure that the address or ENS you put in is valid';
scope.phishing.error = true;
} else {
scope.addressDrtv.showDerivedAddress = false;
scope.phishing.msg = '';
scope.phishing.error = false;
}
}

});
Expand Down
6 changes: 5 additions & 1 deletion app/scripts/ens.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var ens = function() {
_this.setCurrentRegistry(ens.registry.NULL);
}
};
ens.uts46 = uts46
ens.registry = {
ETH: require('./ensConfigs/ETHConfig.json'),
Rinkeby: require('./ensConfigs/RinkebyConfig.json'),
Expand All @@ -38,7 +39,10 @@ ens.registry = {
};
ens.normalise = function(name) {
try {
return uts46.toUnicode(name);
return uts46.toUnicode(name, {
useStd3ASCII: true,
transitional: false
});
} catch (e) {
throw e;
}
Expand Down
6 changes: 5 additions & 1 deletion app/scripts/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ validator.isChecksumAddress = function(address) {
return ethFuncs.isChecksumAddress(address);
}
validator.isValidENSorEtherAddress = function(address) {
return (validator.isValidAddress(address) || validator.isValidENSAddress(address));
return (validator.isValidAddress(address) || validator.isValidENSAddress(address));
}
validator.isValidSubName = function(str) {
try {
Expand All @@ -31,7 +31,11 @@ validator.isValidTxHash = function(txHash) {
return txHash.substring(0, 2) == "0x" && txHash.length == 66 && this.isValidHex(txHash);
}
validator.isValidENSAddress = function(address) {
try {
address = ens.normalise(address);
} catch (e) {
return false
}
return address.lastIndexOf(".") != -1;
}
validator.isValidBTCAddress = function(address) {
Expand Down

0 comments on commit 6a120f0

Please sign in to comment.