How to use the @ethersproject/hash.id function in @ethersproject/hash

To help you get started, we’ve selected a few @ethersproject/hash examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ethers-io / ethers.js / packages / abi / lib.esm / interface.js View on Github external
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
github ethers-io / ethers.js / packages / abi / lib / interface.js View on Github external
values.forEach(function (value, index) {
            var 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(hash_1.id(value));
            }
            else if (param.type === "bytes") {
                topics.push(keccak256_1.keccak256(bytes_1.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(bytes_1.hexZeroPad(bytes_1.hexlify(value), 32));
            }
        });
        // Trim off trailing nulls
github ethers-io / ethers.js / packages / wordlists / lib / wordlist.js View on Github external
Wordlist.check = function (wordlist) {
        var words = [];
        for (var i = 0; i < 2048; i++) {
            var word = wordlist.getWord(i);
            if (i !== wordlist.getWordIndex(word)) {
                return "0x";
            }
            words.push(word);
        }
        return hash_1.id(words.join("\n") + "\n");
    };
    Wordlist.register = function (lang, name) {
github ethers-io / ethers.js / packages / abi / lib / interface.js View on Github external
Interface.prototype._sighashify = function (functionFragment) {
        return bytes_1.hexDataSlice(hash_1.id(functionFragment.format()), 0, 4);
    };
    Interface.prototype._topicify = function (eventFragment) {
github ethers-io / ethers.js / packages / wordlists / wordlist.js View on Github external
function check(wordlist) {
    var words = [];
    for (var i = 0; i < 2048; i++) {
        var word = wordlist.getWord(i);
        if (i !== wordlist.getWordIndex(word)) {
            return "0x";
        }
        words.push(word);
    }
    return hash_1.id(words.join("\n") + "\n");
}
exports.check = check;
github ethers-io / ethers.js / packages / abi / lib.esm / interface.js View on Github external
_sighashify(functionFragment) {
        return hexDataSlice(id(functionFragment.format()), 0, 4);
    }
    _topicify(eventFragment) {
github ethers-io / ethers.js / packages / wordlists / lib.esm / wordlist.js View on Github external
static check(wordlist) {
        const words = [];
        for (let i = 0; i < 2048; i++) {
            const word = wordlist.getWord(i);
            if (i !== wordlist.getWordIndex(word)) {
                return "0x";
            }
            words.push(word);
        }
        return id(words.join("\n") + "\n");
    }
    static register(lang, name) {
github ethers-io / ethers.js / packages / abi / lib.esm / interface.js View on Github external
_topicify(eventFragment) {
        return id(eventFragment.format());
    }
    getFunction(nameOrSignatureOrSighash) {

@ethersproject/hash

Hash utility functions for Ethereum.

MIT
Latest version published 2 years ago

Package Health Score

59 / 100
Full package analysis