"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
const dopts = require("default-options");
const commonTypes_1 = require("../commonTypes");
const contractWrapperBase_1 = require("../contractWrapperBase");
const contractWrapperFactory_1 = require("../contractWrapperFactory");
class VoteInOrganizationSchemeWrapper extends contractWrapperBase_1.ContractWrapperBase {
    constructor() {
        super(...arguments);
        this.name = "VoteInOrganizationScheme";
        this.frendlyName = "Vote In Organization Scheme";
        this.factory = exports.VoteInOrganizationSchemeFactory;
        /**
         * Events
         */
        /* tslint:disable:max-line-length */
        this.ProposalExecuted = this.createEventFetcherFactory("ProposalExecuted");
        this.ProposalDeleted = this.createEventFetcherFactory("ProposalDeleted");
        this.VoteOnBehalf = this.createEventFetcherFactory("VoteOnBehalf");
    }
    /* tslint:enable:max-line-length */
    proposeVote(opts = {}) {
        return __awaiter(this, void 0, void 0, function* () {
            /**
             * see VoteInOrganizationProposeVoteConfig
             */
            const defaults = {
                avatar: undefined,
                originalIntVote: undefined,
                originalProposalId: undefined,
            };
            const options = dopts(opts, defaults, { allowUnknown: true });
            if (!options.avatar) {
                throw new Error("avatar is not defined");
            }
            if (!options.originalIntVote) {
                throw new Error("originalIntVote is not defined");
            }
            if (!options.originalProposalId) {
                throw new Error("originalProposalId is not defined");
            }
            const tx = yield this.contract.proposeVote(options.avatar, options.originalIntVote, options.originalProposalId);
            return new contractWrapperBase_1.ArcTransactionProposalResult(tx);
        });
    }
    setParameters(params) {
        const _super = name => super[name];
        return __awaiter(this, void 0, void 0, function* () {
            this.validateStandardSchemeParams(params);
            return _super("setParameters").call(this, params.voteParametersHash, params.votingMachineAddress);
        });
    }
    getDefaultPermissions(overrideValue) {
        // return overrideValue || Utils.numberToPermissionsString(DefaultSchemePermissions.VoteInOrganizationScheme);
        return (overrideValue || commonTypes_1.DefaultSchemePermissions.VoteInOrganizationScheme);
    }
    getSchemePermissions(avatarAddress) {
        return __awaiter(this, void 0, void 0, function* () {
            return this._getSchemePermissions(avatarAddress);
        });
    }
    getSchemeParameters(avatarAddress) {
        return __awaiter(this, void 0, void 0, function* () {
            return this._getSchemeParameters(avatarAddress);
        });
    }
    getParameters(paramsHash) {
        return __awaiter(this, void 0, void 0, function* () {
            const params = yield this.getParametersArray(paramsHash);
            return {
                voteParametersHash: params[1],
                votingMachineAddress: params[0],
            };
        });
    }
}
exports.VoteInOrganizationSchemeWrapper = VoteInOrganizationSchemeWrapper;
exports.VoteInOrganizationSchemeFactory = new contractWrapperFactory_1.default("VoteInOrganizationScheme", VoteInOrganizationSchemeWrapper);
//# sourceMappingURL=voteInOrganizationScheme.js.map