"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MsgModuleQuerySafeResponse = exports.MsgModuleQuerySafe = exports.MsgUpdateParamsResponse = exports.MsgUpdateParams = void 0;
const host_1 = require("./host");
const binary_1 = require("../../../../../binary");
const registry_1 = require("../../../../../registry");
const helpers_1 = require("../../../../../helpers");
function createBaseMsgUpdateParams() {
    return {
        signer: "",
        params: host_1.Params.fromPartial({})
    };
}
exports.MsgUpdateParams = {
    typeUrl: "/ibc.applications.interchain_accounts.host.v1.MsgUpdateParams",
    aminoType: "cosmos-sdk/MsgUpdateParams",
    is(o) {
        return o && (o.$typeUrl === exports.MsgUpdateParams.typeUrl || typeof o.signer === "string" && host_1.Params.is(o.params));
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.MsgUpdateParams.typeUrl || typeof o.signer === "string" && host_1.Params.isAmino(o.params));
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        if (message.signer !== "") {
            writer.uint32(10).string(message.signer);
        }
        if (message.params !== undefined) {
            host_1.Params.encode(message.params, writer.uint32(18).fork()).ldelim();
        }
        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 = createBaseMsgUpdateParams();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.signer = reader.string();
                    break;
                case 2:
                    message.params = host_1.Params.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseMsgUpdateParams();
        message.signer = object.signer ?? "";
        message.params = object.params !== undefined && object.params !== null ? host_1.Params.fromPartial(object.params) : undefined;
        return message;
    },
    fromAmino(object) {
        const message = createBaseMsgUpdateParams();
        if (object.signer !== undefined && object.signer !== null) {
            message.signer = object.signer;
        }
        if (object.params !== undefined && object.params !== null) {
            message.params = host_1.Params.fromAmino(object.params);
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.signer = message.signer === "" ? undefined : message.signer;
        obj.params = message.params ? host_1.Params.toAmino(message.params) : undefined;
        return obj;
    },
    fromAminoMsg(object) {
        return exports.MsgUpdateParams.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/MsgUpdateParams",
            value: exports.MsgUpdateParams.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.MsgUpdateParams.decode(message.value);
    },
    toProto(message) {
        return exports.MsgUpdateParams.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.applications.interchain_accounts.host.v1.MsgUpdateParams",
            value: exports.MsgUpdateParams.encode(message).finish()
        };
    }
};
registry_1.GlobalDecoderRegistry.register(exports.MsgUpdateParams.typeUrl, exports.MsgUpdateParams);
registry_1.GlobalDecoderRegistry.registerAminoProtoMapping(exports.MsgUpdateParams.aminoType, exports.MsgUpdateParams.typeUrl);
function createBaseMsgUpdateParamsResponse() {
    return {};
}
exports.MsgUpdateParamsResponse = {
    typeUrl: "/ibc.applications.interchain_accounts.host.v1.MsgUpdateParamsResponse",
    aminoType: "cosmos-sdk/MsgUpdateParamsResponse",
    is(o) {
        return o && o.$typeUrl === exports.MsgUpdateParamsResponse.typeUrl;
    },
    isAmino(o) {
        return o && o.$typeUrl === exports.MsgUpdateParamsResponse.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 = createBaseMsgUpdateParamsResponse();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(_) {
        const message = createBaseMsgUpdateParamsResponse();
        return message;
    },
    fromAmino(_) {
        const message = createBaseMsgUpdateParamsResponse();
        return message;
    },
    toAmino(_) {
        const obj = {};
        return obj;
    },
    fromAminoMsg(object) {
        return exports.MsgUpdateParamsResponse.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/MsgUpdateParamsResponse",
            value: exports.MsgUpdateParamsResponse.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.MsgUpdateParamsResponse.decode(message.value);
    },
    toProto(message) {
        return exports.MsgUpdateParamsResponse.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.applications.interchain_accounts.host.v1.MsgUpdateParamsResponse",
            value: exports.MsgUpdateParamsResponse.encode(message).finish()
        };
    }
};
registry_1.GlobalDecoderRegistry.register(exports.MsgUpdateParamsResponse.typeUrl, exports.MsgUpdateParamsResponse);
registry_1.GlobalDecoderRegistry.registerAminoProtoMapping(exports.MsgUpdateParamsResponse.aminoType, exports.MsgUpdateParamsResponse.typeUrl);
function createBaseMsgModuleQuerySafe() {
    return {
        signer: "",
        requests: []
    };
}
exports.MsgModuleQuerySafe = {
    typeUrl: "/ibc.applications.interchain_accounts.host.v1.MsgModuleQuerySafe",
    aminoType: "cosmos-sdk/MsgModuleQuerySafe",
    is(o) {
        return o && (o.$typeUrl === exports.MsgModuleQuerySafe.typeUrl || typeof o.signer === "string" && Array.isArray(o.requests) && (!o.requests.length || host_1.QueryRequest.is(o.requests[0])));
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.MsgModuleQuerySafe.typeUrl || typeof o.signer === "string" && Array.isArray(o.requests) && (!o.requests.length || host_1.QueryRequest.isAmino(o.requests[0])));
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        if (message.signer !== "") {
            writer.uint32(10).string(message.signer);
        }
        for (const v of message.requests) {
            host_1.QueryRequest.encode(v, writer.uint32(18).fork()).ldelim();
        }
        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 = createBaseMsgModuleQuerySafe();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.signer = reader.string();
                    break;
                case 2:
                    message.requests.push(host_1.QueryRequest.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseMsgModuleQuerySafe();
        message.signer = object.signer ?? "";
        message.requests = object.requests?.map(e => host_1.QueryRequest.fromPartial(e)) || [];
        return message;
    },
    fromAmino(object) {
        const message = createBaseMsgModuleQuerySafe();
        if (object.signer !== undefined && object.signer !== null) {
            message.signer = object.signer;
        }
        message.requests = object.requests?.map(e => host_1.QueryRequest.fromAmino(e)) || [];
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.signer = message.signer === "" ? undefined : message.signer;
        if (message.requests) {
            obj.requests = message.requests.map(e => e ? host_1.QueryRequest.toAmino(e) : undefined);
        }
        else {
            obj.requests = message.requests;
        }
        return obj;
    },
    fromAminoMsg(object) {
        return exports.MsgModuleQuerySafe.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/MsgModuleQuerySafe",
            value: exports.MsgModuleQuerySafe.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.MsgModuleQuerySafe.decode(message.value);
    },
    toProto(message) {
        return exports.MsgModuleQuerySafe.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.applications.interchain_accounts.host.v1.MsgModuleQuerySafe",
            value: exports.MsgModuleQuerySafe.encode(message).finish()
        };
    }
};
registry_1.GlobalDecoderRegistry.register(exports.MsgModuleQuerySafe.typeUrl, exports.MsgModuleQuerySafe);
registry_1.GlobalDecoderRegistry.registerAminoProtoMapping(exports.MsgModuleQuerySafe.aminoType, exports.MsgModuleQuerySafe.typeUrl);
function createBaseMsgModuleQuerySafeResponse() {
    return {
        height: BigInt(0),
        responses: []
    };
}
exports.MsgModuleQuerySafeResponse = {
    typeUrl: "/ibc.applications.interchain_accounts.host.v1.MsgModuleQuerySafeResponse",
    aminoType: "cosmos-sdk/MsgModuleQuerySafeResponse",
    is(o) {
        return o && (o.$typeUrl === exports.MsgModuleQuerySafeResponse.typeUrl || typeof o.height === "bigint" && Array.isArray(o.responses) && (!o.responses.length || o.responses[0] instanceof Uint8Array || typeof o.responses[0] === "string"));
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.MsgModuleQuerySafeResponse.typeUrl || typeof o.height === "bigint" && Array.isArray(o.responses) && (!o.responses.length || o.responses[0] instanceof Uint8Array || typeof o.responses[0] === "string"));
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        if (message.height !== BigInt(0)) {
            writer.uint32(8).uint64(message.height);
        }
        for (const v of message.responses) {
            writer.uint32(18).bytes(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 = createBaseMsgModuleQuerySafeResponse();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.height = reader.uint64();
                    break;
                case 2:
                    message.responses.push(reader.bytes());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseMsgModuleQuerySafeResponse();
        message.height = object.height !== undefined && object.height !== null ? BigInt(object.height.toString()) : BigInt(0);
        message.responses = object.responses?.map(e => e) || [];
        return message;
    },
    fromAmino(object) {
        const message = createBaseMsgModuleQuerySafeResponse();
        if (object.height !== undefined && object.height !== null) {
            message.height = BigInt(object.height);
        }
        message.responses = object.responses?.map(e => (0, helpers_1.bytesFromBase64)(e)) || [];
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.height = message.height !== BigInt(0) ? message.height?.toString() : undefined;
        if (message.responses) {
            obj.responses = message.responses.map(e => (0, helpers_1.base64FromBytes)(e));
        }
        else {
            obj.responses = message.responses;
        }
        return obj;
    },
    fromAminoMsg(object) {
        return exports.MsgModuleQuerySafeResponse.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/MsgModuleQuerySafeResponse",
            value: exports.MsgModuleQuerySafeResponse.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.MsgModuleQuerySafeResponse.decode(message.value);
    },
    toProto(message) {
        return exports.MsgModuleQuerySafeResponse.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.applications.interchain_accounts.host.v1.MsgModuleQuerySafeResponse",
            value: exports.MsgModuleQuerySafeResponse.encode(message).finish()
        };
    }
};
registry_1.GlobalDecoderRegistry.register(exports.MsgModuleQuerySafeResponse.typeUrl, exports.MsgModuleQuerySafeResponse);
registry_1.GlobalDecoderRegistry.registerAminoProtoMapping(exports.MsgModuleQuerySafeResponse.aminoType, exports.MsgModuleQuerySafeResponse.typeUrl);
