"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const commonTypes_1 = require("../commonTypes");
const contractWrapperBase_1 = require("../contractWrapperBase");
const contractWrapperFactory_1 = require("../contractWrapperFactory");
class GlobalConstraintRegistrarWrapper extends contractWrapperBase_1.ContractWrapperBase {
    constructor() {
        super(...arguments);
        this.name = "GlobalConstraintRegistrar";
        this.friendlyName = "Global Constraint Registrar";
        this.factory = exports.GlobalConstraintRegistrarFactory;
        /**
         * Events
         */
        /* tslint:disable:max-line-length */
        this.NewGlobalConstraintsProposal = this.createEventFetcherFactory("NewGlobalConstraintsProposal");
        this.RemoveGlobalConstraintsProposal = this.createEventFetcherFactory("RemoveGlobalConstraintsProposal");
        this.ProposalExecuted = this.createEventFetcherFactory("ProposalExecuted");
        this.ProposalDeleted = this.createEventFetcherFactory("ProposalDeleted");
    }
    /* tslint:enable:max-line-length */
    proposeToAddModifyGlobalConstraint(options = {}) {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            if (!options.avatar) {
                throw new Error("address is not defined");
            }
            if (!options.globalConstraint) {
                throw new Error("globalConstraint is not defined");
            }
            if (!options.globalConstraintParametersHash) {
                throw new Error("globalConstraintParametersHash is not defined");
            }
            if (!options.votingMachineHash) {
                throw new Error("votingMachineHash is not defined");
            }
            this.logContractFunctionCall("GlobalConstraintRegistrar.proposeGlobalConstraint", options);
            const txResult = yield this.wrapTransactionInvocation("GlobalConstraintRegistrar.proposeToAddModifyGlobalConstraint", options, () => {
                return this.contract.proposeGlobalConstraint(options.avatar, options.globalConstraint, options.globalConstraintParametersHash, options.votingMachineHash);
            });
            return new contractWrapperBase_1.ArcTransactionProposalResult(txResult.tx);
        });
    }
    proposeToRemoveGlobalConstraint(options = {}) {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            if (!options.avatar) {
                throw new Error("avatar address is not defined");
            }
            if (!options.globalConstraint) {
                throw new Error("avatar globalConstraint is not defined");
            }
            this.logContractFunctionCall("GlobalConstraintRegistrar.proposeToRemoveGC", options);
            const txResult = yield this.wrapTransactionInvocation("GlobalConstraintRegistrar.proposeToRemoveGlobalConstraint", options, () => {
                return this.contract.proposeToRemoveGC(options.avatar, options.globalConstraint);
            });
            return new contractWrapperBase_1.ArcTransactionProposalResult(txResult.tx);
        });
    }
    setParameters(params) {
        const _super = name => super[name];
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            this.validateStandardSchemeParams(params);
            return _super("_setParameters").call(this, "GlobalConstraintRegistrar.setParameters", params.voteParametersHash, params.votingMachineAddress);
        });
    }
    getDefaultPermissions() {
        return commonTypes_1.DefaultSchemePermissions.GlobalConstraintRegistrar;
    }
    getSchemePermissions(avatarAddress) {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            return this._getSchemePermissions(avatarAddress);
        });
    }
    getSchemeParameters(avatarAddress) {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            return this._getSchemeParameters(avatarAddress);
        });
    }
    getParameters(paramsHash) {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            const params = yield this.getParametersArray(paramsHash);
            return {
                voteParametersHash: params[0],
                votingMachineAddress: params[1],
            };
        });
    }
}
exports.GlobalConstraintRegistrarWrapper = GlobalConstraintRegistrarWrapper;
exports.GlobalConstraintRegistrarFactory = new contractWrapperFactory_1.ContractWrapperFactory("GlobalConstraintRegistrar", GlobalConstraintRegistrarWrapper);
//# sourceMappingURL=globalConstraintRegistrar.js.map