Update floCrypto.js

Added support for ethereum address validation
-- floCrypto.validateAddr
-- decodeAddress
This commit is contained in:
sairaj mote 2023-10-15 15:57:12 +05:30 committed by GitHub
parent eba2d7b37d
commit 6a57aa1273
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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'
}
}
}
@ -527,4 +534,4 @@
m => String.fromCharCode(parseInt(m.replace(/\\u/g, ''), 16)));
}
})('object' === typeof module ? module.exports : window.floCrypto = {});
})('object' === typeof module ? module.exports : window.floCrypto = {});