Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
values.forEach((value, index) => {
let param = eventFragment.inputs[index];
if (!param.indexed) {
if (value != null) {
logger.throwArgumentError("cannot filter non-indexed parameters; must be null", ("contract." + param.name), value);
}
return;
}
if (value == null) {
topics.push(null);
}
else if (param.type === "string") {
topics.push(id(value));
}
else if (param.type === "bytes") {
topics.push(keccak256(hexlify(value)));
}
else if (param.type.indexOf("[") !== -1 || param.type.substring(0, 5) === "tuple") {
logger.throwArgumentError("filtering with tuples or arrays not supported", ("contract." + param.name), value);
}
else {
// Check addresses are valid
if (param.type === "address") {
this._abiCoder.encode(["address"], [value]);
}
topics.push(hexZeroPad(hexlify(value), 32));
}
});
// Trim off trailing nulls
function getContractAddress(transaction) {
var from = null;
try {
from = getAddress(transaction.from);
}
catch (error) {
logger.throwArgumentError("missing from address", "transaction", transaction);
}
var nonce = bytes_1.stripZeros(bytes_1.arrayify(bignumber_1.BigNumber.from(transaction.nonce).toHexString()));
return getAddress(bytes_1.hexDataSlice(keccak256_1.keccak256(rlp_1.encode([from, nonce])), 12));
}
exports.getContractAddress = getContractAddress;
export function namehash(name: string): string {
if (typeof(name) !== "string") {
logger.throwArgumentError("invalid address - " + String(name), "name", name);
}
let result: string | Uint8Array = Zeros;
while (name.length) {
const partition = name.match(Partition);
const label = toUtf8Bytes(nameprep(partition[3]));
result = keccak256(concat([result, keccak256(label)]));
name = partition[2] || "";
}
return hexlify(result);
}
function id(text) {
return keccak256_1.keccak256(strings_1.toUtf8Bytes(text));
}
exports.id = id;
function computeAddress(key) {
var publicKey = signing_key_1.computePublicKey(key);
return address_1.getAddress(bytes_1.hexDataSlice(keccak256_1.keccak256(bytes_1.hexDataSlice(publicKey, 1)), 12));
}
exports.computeAddress = computeAddress;
static createRandom(options) {
let entropy = randomBytes(16);
if (!options) {
options = {};
}
if (options.extraEntropy) {
entropy = arrayify(hexDataSlice(keccak256(concat([entropy, options.extraEntropy])), 0, 16));
}
const mnemonic = entropyToMnemonic(entropy, options.locale);
return Wallet.fromMnemonic(mnemonic, options.path, options.locale);
}
static fromEncryptedJson(json, password, progressCallback) {
export function namehash(name) {
if (typeof (name) !== "string") {
logger.throwArgumentError("invalid address - " + String(name), "name", name);
}
let result = Zeros;
while (name.length) {
const partition = name.match(Partition);
const label = toUtf8Bytes(nameprep(partition[3]));
result = keccak256(concat([result, keccak256(label)]));
name = partition[2] || "";
}
return hexlify(result);
}
export function id(text) {
return resolveProperties(transaction).then((tx) => {
if (tx.from != null) {
if (getAddress(tx.from) !== this.address) {
throw new Error("transaction from address mismatch");
}
delete tx.from;
}
const signature = this._signingKey().signDigest(keccak256(serialize(tx)));
return serialize(tx, signature);
});
}
function namehash(name) {
if (typeof (name) !== "string") {
logger.throwArgumentError("invalid address - " + String(name), "name", name);
}
var result = Zeros;
while (name.length) {
var partition = name.match(Partition);
var label = strings_1.toUtf8Bytes(strings_1.nameprep(partition[3]));
result = keccak256_1.keccak256(bytes_1.concat([result, keccak256_1.keccak256(label)]));
name = partition[2] || "";
}
return bytes_1.hexlify(result);
}
exports.namehash = namehash;