"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Chainable_1 = require("../Chainable");
const SetRules_1 = require("../../protocol/SetRules");
const SendVoteorder_1 = require("../../protocol/SendVoteorder");
const ConfirmVote_1 = require("../../protocol/ConfirmVote");
/**
 * Filters steem blockchain operations by type.
 */
class WiseOperationTypeFilter extends Chainable_1.ChainableFilter {
    constructor(type) {
        super();
        this.type = type;
    }
    me() {
        return this;
    }
    take(error, op) {
        if (error)
            throw error;
        if (this.type === WiseOperationTypeFilter.OperationType.SetRules) {
            if (SetRules_1.SetRules.isSetRules(op.command))
                return this.give(undefined, op);
        }
        else if (this.type === WiseOperationTypeFilter.OperationType.SendVoteorder) {
            if (SendVoteorder_1.SendVoteorder.isSendVoteorder(op.command))
                return this.give(undefined, op);
        }
        else if (this.type === WiseOperationTypeFilter.OperationType.ConfirmVote) {
            if (ConfirmVote_1.ConfirmVote.isConfirmVote(op.command))
                return this.give(undefined, op);
        }
        else
            throw new Error("Illegal type of filter");
        return true;
    }
}
exports.WiseOperationTypeFilter = WiseOperationTypeFilter;
(function (WiseOperationTypeFilter) {
    let OperationType;
    (function (OperationType) {
        OperationType[OperationType["SetRules"] = 0] = "SetRules";
        OperationType[OperationType["SendVoteorder"] = 1] = "SendVoteorder";
        OperationType[OperationType["ConfirmVote"] = 2] = "ConfirmVote";
    })(OperationType = WiseOperationTypeFilter.OperationType || (WiseOperationTypeFilter.OperationType = {}));
})(WiseOperationTypeFilter = exports.WiseOperationTypeFilter || (exports.WiseOperationTypeFilter = {}));
//# sourceMappingURL=WiseOperationTypeFilter.js.map