"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useOwnerIsTimelock = exports.useTimelockByChain = void 0;
var react_1 = require("react");
var common_1 = require("../common");
var typechain_1 = require("../../typechain");
var utils_1 = require("../../utils");
function useTimelockByChain(chain) {
    var signerOrProvider = (0, common_1.useSignerOrProvider)(chain);
    return (0, react_1.useMemo)(function () {
        if (!chain || !signerOrProvider)
            return;
        var sectorTimelock = (0, utils_1.getContractAddrById)(chain, 'SectorTimelock');
        var address = sectorTimelock;
        if (!address)
            return;
        return typechain_1.SectorTimelock__factory.connect(address, signerOrProvider);
    }, [chain, signerOrProvider]);
}
exports.useTimelockByChain = useTimelockByChain;
function useOwnerIsTimelock(contract, timelock) {
    var owner = (0, common_1.useCallOnce)(contract === null || contract === void 0 ? void 0 : contract.owner).res;
    var ownerIsTimelock = (0, react_1.useMemo)(function () { var _a; return (owner === null || owner === void 0 ? void 0 : owner.toLowerCase()) === ((_a = timelock === null || timelock === void 0 ? void 0 : timelock.address) === null || _a === void 0 ? void 0 : _a.toLowerCase()); }, [owner, timelock === null || timelock === void 0 ? void 0 : timelock.address]);
    return { ownerIsTimelock: ownerIsTimelock };
}
exports.useOwnerIsTimelock = useOwnerIsTimelock;
//# sourceMappingURL=useTimelock.js.map