@exromany/lido-csm-sdk
Version:
[](https://github.com/lidofinance/lido-csm-sdk/blob/main/LICENSE.txt) [](h
27 lines • 1.14 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.wrapLeaf = exports.filterLeafsByNodeOperator = exports.findLeaf = exports.findProof = void 0;
const find_index_and_leaf_js_1 = require("../common/utils/find-index-and-leaf.js");
const findProof = (tree, pubkey) => {
const [index, leaf] = (0, find_index_and_leaf_js_1.findIndexAndLeaf)(tree, (leaf) => leaf[1] === pubkey);
if (index !== undefined && leaf) {
return tree.getProof(index);
}
return null;
};
exports.findProof = findProof;
const findLeaf = (tree, pubkey) => {
const [, leaf] = (0, find_index_and_leaf_js_1.findIndexAndLeaf)(tree, (leaf) => leaf[1] === pubkey);
return leaf ? (0, exports.wrapLeaf)(leaf) : null;
};
exports.findLeaf = findLeaf;
const filterLeafsByNodeOperator = (tree, id) => {
return (0, find_index_and_leaf_js_1.filterLeafs)(tree, (leaf) => leaf[0] === id).map(exports.wrapLeaf);
};
exports.filterLeafsByNodeOperator = filterLeafsByNodeOperator;
const wrapLeaf = (leaf) => ({
pubkey: leaf[1],
strikes: leaf[2],
});
exports.wrapLeaf = wrapLeaf;
//# sourceMappingURL=find-proof.js.map