Added support for ethereum address validation

This commit is contained in:
sairaj mote 2023-10-15 15:53:08 +05:30
parent 69b73acdf8
commit a5a242d50f
7 changed files with 17 additions and 6 deletions

View File

@ -12,6 +12,7 @@
html,
body {
height: 100%;
view-transition-name: none;
}
body {

2
css/main.min.css vendored

File diff suppressed because one or more lines are too long

View File

@ -12,6 +12,7 @@
html,
body {
height: 100%;
view-transition-name: none;
}
body {

View File

@ -403,7 +403,7 @@
});
hash[0] != checksum[0] || hash[1] != checksum[1] || hash[2] != checksum[2] || hash[3] != checksum[3] ?
bytes = undefined : bytes.shift();
} else if (address.length == 42 || address.length == 62) { //bech encoding
} else if (!address.startsWith("0x") && address.length == 42 || address.length == 62) { //bech encoding
if (typeof coinjs !== 'function')
throw "library missing (lib_btc.js)";
let decode = coinjs.bech32_decode(address);
@ -418,11 +418,11 @@
bytes = ripemd160(Crypto.SHA256(Crypto.util.hexToBytes(address), {
asBytes: true
}));
} else if ((address.length == 42 && address.startsWith("0x")) || (address.length == 40 && !address.startsWith("0x"))){ //Ethereum Address
if (address.startsWith("0x")) { address = address.substring(2);}
} else if ((address.length == 42 && address.startsWith("0x")) || (address.length == 40 && !address.startsWith("0x"))) { //Ethereum Address
if (address.startsWith("0x")) { address = address.substring(2); }
bytes = Crypto.util.hexToBytes(address);
}
if (!bytes)
throw "Invalid address: " + address;
else {

1
scripts/floCloudAPI.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -299,6 +299,8 @@
return true;
else
return false;
} else if (raw.type === 'ethereum') {
return true
} else //unknown
return false;
}
@ -414,7 +416,7 @@
hex: Crypto.util.bytesToHex(bytes),
bytes
}
} else if (address.length == 42 || address.length == 62) { //bech encoding
} else if (!address.startsWith("0x") && address.length == 42 || address.length == 62) { //bech encoding
let decode = coinjs.bech32_decode(address);
if (decode) {
let bytes = decode.data;
@ -428,6 +430,11 @@
}
} else
return null;
} else if ((address.length == 42 && address.startsWith("0x")) || (address.length == 40 && !address.startsWith("0x"))) { //Ethereum Address
return {
hex: address,
type: 'ethereum'
}
}
}

1
scripts/floCrypto.min.js vendored Normal file

File diff suppressed because one or more lines are too long