Simplify zero address regex

This commit is contained in:
Leonid Logvinov 2017-05-26 17:51:16 +02:00
parent 4c3c1d049b
commit 75c67f3ce3
No known key found for this signature in database
GPG Key ID: 0DD294BFDE8C95D4

View File

@ -50,7 +50,7 @@ export class Web3Wrapper {
public async doesContractExistAtAddressAsync(address: string): Promise<boolean> { public async doesContractExistAtAddressAsync(address: string): Promise<boolean> {
const code = await promisify(this.web3.eth.getCode)(address); const code = await promisify(this.web3.eth.getCode)(address);
// Regex matches 0x0, 0x00, 0x in order to accomodate poorly implemented clients // Regex matches 0x0, 0x00, 0x in order to accomodate poorly implemented clients
const zeroHexAddressRegex = /^0[xX][0]*$/; const zeroHexAddressRegex = /^0x0*$/i;
const didFindCode = _.isNull(code.match(zeroHexAddressRegex)); const didFindCode = _.isNull(code.match(zeroHexAddressRegex));
return didFindCode; return didFindCode;
} }