"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Config = void 0;
const binary_1 = require("../../../../binary");
function createBaseConfig() {
    return {
        allowedRelayers: []
    };
}
/**
 * Config is a **per-client** configuration struct that sets which relayers are allowed to relay v2 IBC messages
 * for a given client.
 * If it is set, then only relayers in the allow list can send v2 messages
 * If it is not set, then the client allows permissionless relaying of v2 messages
 * @name Config
 * @package ibc.core.client.v2
 * @see proto type: ibc.core.client.v2.Config
 */
exports.Config = {
    typeUrl: "/ibc.core.client.v2.Config",
    aminoType: "cosmos-sdk/Config",
    is(o) {
        return o && (o.$typeUrl === exports.Config.typeUrl || Array.isArray(o.allowedRelayers) && (!o.allowedRelayers.length || typeof o.allowedRelayers[0] === "string"));
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.Config.typeUrl || Array.isArray(o.allowed_relayers) && (!o.allowed_relayers.length || typeof o.allowed_relayers[0] === "string"));
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        for (const v of message.allowedRelayers) {
            writer.uint32(10).string(v);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof binary_1.BinaryReader ? input : new binary_1.BinaryReader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseConfig();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.allowedRelayers.push(reader.string());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseConfig();
        message.allowedRelayers = object.allowedRelayers?.map(e => e) || [];
        return message;
    },
    fromAmino(object) {
        const message = createBaseConfig();
        message.allowedRelayers = object.allowed_relayers?.map(e => e) || [];
        return message;
    },
    toAmino(message) {
        const obj = {};
        if (message.allowedRelayers) {
            obj.allowed_relayers = message.allowedRelayers.map(e => e);
        }
        else {
            obj.allowed_relayers = message.allowedRelayers;
        }
        return obj;
    },
    fromAminoMsg(object) {
        return exports.Config.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/Config",
            value: exports.Config.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.Config.decode(message.value);
    },
    toProto(message) {
        return exports.Config.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.core.client.v2.Config",
            value: exports.Config.encode(message).finish()
        };
    },
    registerTypeUrl() { }
};
