"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MsgUpdateClientConfigResponse = exports.MsgUpdateClientConfig = exports.MsgRegisterCounterpartyResponse = exports.MsgRegisterCounterparty = void 0;
const config_1 = require("./config");
const binary_1 = require("../../../../binary");
const helpers_1 = require("../../../../helpers");
const registry_1 = require("../../../../registry");
function createBaseMsgRegisterCounterparty() {
    return {
        clientId: "",
        counterpartyMerklePrefix: [],
        counterpartyClientId: "",
        signer: ""
    };
}
/**
 * MsgRegisterCounterparty defines a message to register a counterparty on a client
 * @name MsgRegisterCounterparty
 * @package ibc.core.client.v2
 * @see proto type: ibc.core.client.v2.MsgRegisterCounterparty
 */
exports.MsgRegisterCounterparty = {
    typeUrl: "/ibc.core.client.v2.MsgRegisterCounterparty",
    aminoType: "cosmos-sdk/MsgRegisterCounterparty",
    is(o) {
        return o && (o.$typeUrl === exports.MsgRegisterCounterparty.typeUrl || typeof o.clientId === "string" && Array.isArray(o.counterpartyMerklePrefix) && (!o.counterpartyMerklePrefix.length || o.counterpartyMerklePrefix[0] instanceof Uint8Array || typeof o.counterpartyMerklePrefix[0] === "string") && typeof o.counterpartyClientId === "string" && typeof o.signer === "string");
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.MsgRegisterCounterparty.typeUrl || typeof o.client_id === "string" && Array.isArray(o.counterparty_merkle_prefix) && (!o.counterparty_merkle_prefix.length || o.counterparty_merkle_prefix[0] instanceof Uint8Array || typeof o.counterparty_merkle_prefix[0] === "string") && typeof o.counterparty_client_id === "string" && typeof o.signer === "string");
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        if (message.clientId !== "") {
            writer.uint32(10).string(message.clientId);
        }
        for (const v of message.counterpartyMerklePrefix) {
            writer.uint32(18).bytes(v);
        }
        if (message.counterpartyClientId !== "") {
            writer.uint32(26).string(message.counterpartyClientId);
        }
        if (message.signer !== "") {
            writer.uint32(34).string(message.signer);
        }
        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 = createBaseMsgRegisterCounterparty();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.clientId = reader.string();
                    break;
                case 2:
                    message.counterpartyMerklePrefix.push(reader.bytes());
                    break;
                case 3:
                    message.counterpartyClientId = reader.string();
                    break;
                case 4:
                    message.signer = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseMsgRegisterCounterparty();
        message.clientId = object.clientId ?? "";
        message.counterpartyMerklePrefix = object.counterpartyMerklePrefix?.map(e => e) || [];
        message.counterpartyClientId = object.counterpartyClientId ?? "";
        message.signer = object.signer ?? "";
        return message;
    },
    fromAmino(object) {
        const message = createBaseMsgRegisterCounterparty();
        if (object.client_id !== undefined && object.client_id !== null) {
            message.clientId = object.client_id;
        }
        message.counterpartyMerklePrefix = object.counterparty_merkle_prefix?.map(e => (0, helpers_1.bytesFromBase64)(e)) || [];
        if (object.counterparty_client_id !== undefined && object.counterparty_client_id !== null) {
            message.counterpartyClientId = object.counterparty_client_id;
        }
        if (object.signer !== undefined && object.signer !== null) {
            message.signer = object.signer;
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.client_id = message.clientId === "" ? undefined : message.clientId;
        if (message.counterpartyMerklePrefix) {
            obj.counterparty_merkle_prefix = message.counterpartyMerklePrefix.map(e => (0, helpers_1.base64FromBytes)(e));
        }
        else {
            obj.counterparty_merkle_prefix = message.counterpartyMerklePrefix;
        }
        obj.counterparty_client_id = message.counterpartyClientId === "" ? undefined : message.counterpartyClientId;
        obj.signer = message.signer === "" ? undefined : message.signer;
        return obj;
    },
    fromAminoMsg(object) {
        return exports.MsgRegisterCounterparty.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/MsgRegisterCounterparty",
            value: exports.MsgRegisterCounterparty.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.MsgRegisterCounterparty.decode(message.value);
    },
    toProto(message) {
        return exports.MsgRegisterCounterparty.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.core.client.v2.MsgRegisterCounterparty",
            value: exports.MsgRegisterCounterparty.encode(message).finish()
        };
    },
    registerTypeUrl() { }
};
function createBaseMsgRegisterCounterpartyResponse() {
    return {};
}
/**
 * MsgRegisterCounterpartyResponse defines the Msg/RegisterCounterparty response type.
 * @name MsgRegisterCounterpartyResponse
 * @package ibc.core.client.v2
 * @see proto type: ibc.core.client.v2.MsgRegisterCounterpartyResponse
 */
exports.MsgRegisterCounterpartyResponse = {
    typeUrl: "/ibc.core.client.v2.MsgRegisterCounterpartyResponse",
    aminoType: "cosmos-sdk/MsgRegisterCounterpartyResponse",
    is(o) {
        return o && o.$typeUrl === exports.MsgRegisterCounterpartyResponse.typeUrl;
    },
    isAmino(o) {
        return o && o.$typeUrl === exports.MsgRegisterCounterpartyResponse.typeUrl;
    },
    encode(_, writer = binary_1.BinaryWriter.create()) {
        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 = createBaseMsgRegisterCounterpartyResponse();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(_) {
        const message = createBaseMsgRegisterCounterpartyResponse();
        return message;
    },
    fromAmino(_) {
        const message = createBaseMsgRegisterCounterpartyResponse();
        return message;
    },
    toAmino(_) {
        const obj = {};
        return obj;
    },
    fromAminoMsg(object) {
        return exports.MsgRegisterCounterpartyResponse.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/MsgRegisterCounterpartyResponse",
            value: exports.MsgRegisterCounterpartyResponse.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.MsgRegisterCounterpartyResponse.decode(message.value);
    },
    toProto(message) {
        return exports.MsgRegisterCounterpartyResponse.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.core.client.v2.MsgRegisterCounterpartyResponse",
            value: exports.MsgRegisterCounterpartyResponse.encode(message).finish()
        };
    },
    registerTypeUrl() { }
};
function createBaseMsgUpdateClientConfig() {
    return {
        clientId: "",
        config: config_1.Config.fromPartial({}),
        signer: ""
    };
}
/**
 * MsgUpdateClientConfig defines the sdk.Msg type to update the configuration for a given client
 * @name MsgUpdateClientConfig
 * @package ibc.core.client.v2
 * @see proto type: ibc.core.client.v2.MsgUpdateClientConfig
 */
exports.MsgUpdateClientConfig = {
    typeUrl: "/ibc.core.client.v2.MsgUpdateClientConfig",
    aminoType: "cosmos-sdk/MsgUpdateClientConfig",
    is(o) {
        return o && (o.$typeUrl === exports.MsgUpdateClientConfig.typeUrl || typeof o.clientId === "string" && config_1.Config.is(o.config) && typeof o.signer === "string");
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.MsgUpdateClientConfig.typeUrl || typeof o.client_id === "string" && config_1.Config.isAmino(o.config) && typeof o.signer === "string");
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        if (message.clientId !== "") {
            writer.uint32(10).string(message.clientId);
        }
        if (message.config !== undefined) {
            config_1.Config.encode(message.config, writer.uint32(18).fork()).ldelim();
        }
        if (message.signer !== "") {
            writer.uint32(26).string(message.signer);
        }
        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 = createBaseMsgUpdateClientConfig();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.clientId = reader.string();
                    break;
                case 2:
                    message.config = config_1.Config.decode(reader, reader.uint32());
                    break;
                case 3:
                    message.signer = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseMsgUpdateClientConfig();
        message.clientId = object.clientId ?? "";
        message.config = object.config !== undefined && object.config !== null ? config_1.Config.fromPartial(object.config) : undefined;
        message.signer = object.signer ?? "";
        return message;
    },
    fromAmino(object) {
        const message = createBaseMsgUpdateClientConfig();
        if (object.client_id !== undefined && object.client_id !== null) {
            message.clientId = object.client_id;
        }
        if (object.config !== undefined && object.config !== null) {
            message.config = config_1.Config.fromAmino(object.config);
        }
        if (object.signer !== undefined && object.signer !== null) {
            message.signer = object.signer;
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.client_id = message.clientId === "" ? undefined : message.clientId;
        obj.config = message.config ? config_1.Config.toAmino(message.config) : undefined;
        obj.signer = message.signer === "" ? undefined : message.signer;
        return obj;
    },
    fromAminoMsg(object) {
        return exports.MsgUpdateClientConfig.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/MsgUpdateClientConfig",
            value: exports.MsgUpdateClientConfig.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.MsgUpdateClientConfig.decode(message.value);
    },
    toProto(message) {
        return exports.MsgUpdateClientConfig.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.core.client.v2.MsgUpdateClientConfig",
            value: exports.MsgUpdateClientConfig.encode(message).finish()
        };
    },
    registerTypeUrl() {
        if (!registry_1.GlobalDecoderRegistry.registerExistingTypeUrl(exports.MsgUpdateClientConfig.typeUrl)) {
            return;
        }
        config_1.Config.registerTypeUrl();
    }
};
function createBaseMsgUpdateClientConfigResponse() {
    return {};
}
/**
 * MsgUpdateClientConfigResponse defines the MsgUpdateClientConfig response type.
 * @name MsgUpdateClientConfigResponse
 * @package ibc.core.client.v2
 * @see proto type: ibc.core.client.v2.MsgUpdateClientConfigResponse
 */
exports.MsgUpdateClientConfigResponse = {
    typeUrl: "/ibc.core.client.v2.MsgUpdateClientConfigResponse",
    aminoType: "cosmos-sdk/MsgUpdateClientConfigResponse",
    is(o) {
        return o && o.$typeUrl === exports.MsgUpdateClientConfigResponse.typeUrl;
    },
    isAmino(o) {
        return o && o.$typeUrl === exports.MsgUpdateClientConfigResponse.typeUrl;
    },
    encode(_, writer = binary_1.BinaryWriter.create()) {
        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 = createBaseMsgUpdateClientConfigResponse();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(_) {
        const message = createBaseMsgUpdateClientConfigResponse();
        return message;
    },
    fromAmino(_) {
        const message = createBaseMsgUpdateClientConfigResponse();
        return message;
    },
    toAmino(_) {
        const obj = {};
        return obj;
    },
    fromAminoMsg(object) {
        return exports.MsgUpdateClientConfigResponse.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/MsgUpdateClientConfigResponse",
            value: exports.MsgUpdateClientConfigResponse.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.MsgUpdateClientConfigResponse.decode(message.value);
    },
    toProto(message) {
        return exports.MsgUpdateClientConfigResponse.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.core.client.v2.MsgUpdateClientConfigResponse",
            value: exports.MsgUpdateClientConfigResponse.encode(message).finish()
        };
    },
    registerTypeUrl() { }
};
