Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
parentCurrency === 'ETH' ? toChecksumAddress(e) : e;
} else {
if (canValidate(parentCurrency)) {
const isValid = MAValidator.validate(e, parentCurrency);
if (isValid) {
_this.isValidAddress = isValid;
_this.hexAddress = e;
} else {
_this.isValidAddress = false;
_this.hexAddress = '';
removeElements();
if (e.length > 0) {
if (
parentCurrency === 'ETH' &&
(e.length !== 42 || !utils.isHexStrict(e))
) {
errorPar.innerText = _this.$t(
'ens.ens-resolver.invalid-eth-addr'
);
} else if (
parentCurrency === 'ETH' &&
!utils.checkAddressChecksum(e)
) {
errorPar.innerText = _this.$t(
'ens.ens-resolver.addr-not-checksummed'
);
// 'Incorrect checksum: check address format on EthVM';
} else {
errorPar.innerText = _this.$t(
'ens.ens-resolver.invalid-addr',
{ coin: parentCurrency }
parseValue: input => {
return !web3Utils.isHexStrict(input) || web3Utils.hexToBytes(input).length !== 32 ? undefined : input;
},
parseLiteral: ast => {
var inputBlockNumberFormatter = function (blockNumber) {
if (blockNumber === undefined) {
return undefined;
} else if (isPredefinedBlockNumber(blockNumber)) {
return blockNumber;
}
return (utils.isHexStrict(blockNumber)) ? ((_.isString(blockNumber)) ? blockNumber.toLowerCase() : blockNumber) : utils.numberToHex(blockNumber);
};
export function numToHex(number) {
if (isUndefined(number)) return number;
if (isHexStrict(number)) return number;
return numberToHex(number);
}
validate: text => {
if (!utils.isHexStrict(text) && !utils.isAddress(text)) {
return "Provide correct checksumed Ethereum address. Start with 0x ";
}
return true;
},
},
export const isAddress = (address: string | Address): boolean =>
`${address}`.length === 42 &&
web3Utils.isAddress(`${address}`) &&
web3Utils.isHexStrict(`${address}`);
static _validatePayload(payload: any) {
const assert = makeAssert('Invalid payload');
assert(isPlainObject(payload), 'Payload must be an object');
const { data, destinationAddress, sourceAddress, value } = payload || {};
assert(isHexStrict(data), 'data must be a hex string');
assert(
isValidAddress(destinationAddress),
'destinationAddress must be a valid address',
);
assert(
isValidAddress(sourceAddress),
'sourceAddress must be a valid address',
);
return assert(
Number(value) === value && value >= 0,
'value must be a positive number',
);
}
var inputSignFormatter = function (data) {
return (utils.isHexStrict(data)) ? data : utils.utf8ToHex(data);
};
constructor(signature: string) {
if (!isHexStrict(signature)) {
throw new Error('Invalid input: signature must be a hex string');
}
if (signature.length !== 132) {
throw new Error('Invalid input: signature must be 65 bytes');
}
this.signature = signature;
this.r = '0x' + signature.slice(2, 66);
this.s = '0x' + signature.slice(66, 130);
this.v = toDecimal('0x' + signature.slice(130, 132));
}
}