"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const enums_1 = require("../../../enums");
const managers_1 = require("../../../managers");
const utils_1 = require("../../../utils");
const schemas = __importStar(require("../schemas"));
const transaction_1 = require("../transaction");
class MultiSignatureRegistrationTransaction extends transaction_1.Transaction {
    static getSchema() {
        return schemas.multiSignature;
    }
    static staticFee(feeContext = {}) {
        if (feeContext.data?.asset?.multiSignature) {
            return super.staticFee(feeContext).times(feeContext.data.asset.multiSignature.publicKeys.length + 1);
        }
        return super.staticFee(feeContext);
    }
    verify() {
        return managers_1.configManager.getMilestone().aip11 && super.verify();
    }
    serialize(options) {
        const { data } = this;
        const { min, publicKeys } = data.asset.multiSignature;
        const buff = new utils_1.ByteBuffer(Buffer.alloc(2 + publicKeys.length * 33));
        buff.writeUInt8(min);
        buff.writeUInt8(publicKeys.length);
        for (const publicKey of publicKeys) {
            buff.writeBuffer(Buffer.from(publicKey, "hex"));
        }
        return buff;
    }
    deserialize(buf) {
        const { data } = this;
        const multiSignature = { publicKeys: [], min: 0 };
        multiSignature.min = buf.readUInt8();
        const count = buf.readUInt8();
        for (let i = 0; i < count; i++) {
            const publicKey = buf.readBuffer(33).toString("hex");
            multiSignature.publicKeys.push(publicKey);
        }
        data.asset = { multiSignature };
    }
}
exports.MultiSignatureRegistrationTransaction = MultiSignatureRegistrationTransaction;
MultiSignatureRegistrationTransaction.typeGroup = enums_1.TransactionTypeGroup.Core;
MultiSignatureRegistrationTransaction.type = enums_1.TransactionType.MultiSignature;
MultiSignatureRegistrationTransaction.key = "multiSignature";
MultiSignatureRegistrationTransaction.version = 2;
MultiSignatureRegistrationTransaction.defaultStaticFee = utils_1.BigNumber.make("500000000");
//# sourceMappingURL=multi-signature-registration.js.map