"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GolangBinding = exports.ModuleConfig = exports.Config = void 0;
const any_1 = require("../../../google/protobuf/any");
const binary_1 = require("../../../binary");
const registry_1 = require("../../../registry");
function createBaseConfig() {
    return {
        modules: [],
        golangBindings: []
    };
}
/**
 * Config represents the configuration for a Cosmos SDK ABCI app.
 * It is intended that all state machine logic including the version of
 * baseapp and tx handlers (and possibly even Tendermint) that an app needs
 * can be described in a config object. For compatibility, the framework should
 * allow a mixture of declarative and imperative app wiring, however, apps
 * that strive for the maximum ease of maintainability should be able to describe
 * their state machine with a config object alone.
 * @name Config
 * @package cosmos.app.v1alpha1
 * @see proto type: cosmos.app.v1alpha1.Config
 */
exports.Config = {
    typeUrl: "/cosmos.app.v1alpha1.Config",
    aminoType: "cosmos-sdk/Config",
    is(o) {
        return o && (o.$typeUrl === exports.Config.typeUrl || Array.isArray(o.modules) && (!o.modules.length || exports.ModuleConfig.is(o.modules[0])) && Array.isArray(o.golangBindings) && (!o.golangBindings.length || exports.GolangBinding.is(o.golangBindings[0])));
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.Config.typeUrl || Array.isArray(o.modules) && (!o.modules.length || exports.ModuleConfig.isAmino(o.modules[0])) && Array.isArray(o.golang_bindings) && (!o.golang_bindings.length || exports.GolangBinding.isAmino(o.golang_bindings[0])));
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        for (const v of message.modules) {
            exports.ModuleConfig.encode(v, writer.uint32(10).fork()).ldelim();
        }
        for (const v of message.golangBindings) {
            exports.GolangBinding.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 = createBaseConfig();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.modules.push(exports.ModuleConfig.decode(reader, reader.uint32()));
                    break;
                case 2:
                    message.golangBindings.push(exports.GolangBinding.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseConfig();
        message.modules = object.modules?.map(e => exports.ModuleConfig.fromPartial(e)) || [];
        message.golangBindings = object.golangBindings?.map(e => exports.GolangBinding.fromPartial(e)) || [];
        return message;
    },
    fromAmino(object) {
        const message = createBaseConfig();
        message.modules = object.modules?.map(e => exports.ModuleConfig.fromAmino(e)) || [];
        message.golangBindings = object.golang_bindings?.map(e => exports.GolangBinding.fromAmino(e)) || [];
        return message;
    },
    toAmino(message) {
        const obj = {};
        if (message.modules) {
            obj.modules = message.modules.map(e => e ? exports.ModuleConfig.toAmino(e) : undefined);
        }
        else {
            obj.modules = message.modules;
        }
        if (message.golangBindings) {
            obj.golang_bindings = message.golangBindings.map(e => e ? exports.GolangBinding.toAmino(e) : undefined);
        }
        else {
            obj.golang_bindings = message.golangBindings;
        }
        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: "/cosmos.app.v1alpha1.Config",
            value: exports.Config.encode(message).finish()
        };
    },
    registerTypeUrl() {
        if (!registry_1.GlobalDecoderRegistry.registerExistingTypeUrl(exports.Config.typeUrl)) {
            return;
        }
        exports.ModuleConfig.registerTypeUrl();
        exports.GolangBinding.registerTypeUrl();
    }
};
function createBaseModuleConfig() {
    return {
        name: "",
        config: undefined,
        golangBindings: []
    };
}
/**
 * ModuleConfig is a module configuration for an app.
 * @name ModuleConfig
 * @package cosmos.app.v1alpha1
 * @see proto type: cosmos.app.v1alpha1.ModuleConfig
 */
exports.ModuleConfig = {
    typeUrl: "/cosmos.app.v1alpha1.ModuleConfig",
    aminoType: "cosmos-sdk/ModuleConfig",
    is(o) {
        return o && (o.$typeUrl === exports.ModuleConfig.typeUrl || typeof o.name === "string" && Array.isArray(o.golangBindings) && (!o.golangBindings.length || exports.GolangBinding.is(o.golangBindings[0])));
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.ModuleConfig.typeUrl || typeof o.name === "string" && Array.isArray(o.golang_bindings) && (!o.golang_bindings.length || exports.GolangBinding.isAmino(o.golang_bindings[0])));
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        if (message.name !== "") {
            writer.uint32(10).string(message.name);
        }
        if (message.config !== undefined) {
            any_1.Any.encode(message.config, writer.uint32(18).fork()).ldelim();
        }
        for (const v of message.golangBindings) {
            exports.GolangBinding.encode(v, writer.uint32(26).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 = createBaseModuleConfig();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.name = reader.string();
                    break;
                case 2:
                    message.config = any_1.Any.decode(reader, reader.uint32());
                    break;
                case 3:
                    message.golangBindings.push(exports.GolangBinding.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseModuleConfig();
        message.name = object.name ?? "";
        message.config = object.config !== undefined && object.config !== null ? any_1.Any.fromPartial(object.config) : undefined;
        message.golangBindings = object.golangBindings?.map(e => exports.GolangBinding.fromPartial(e)) || [];
        return message;
    },
    fromAmino(object) {
        const message = createBaseModuleConfig();
        if (object.name !== undefined && object.name !== null) {
            message.name = object.name;
        }
        if (object.config !== undefined && object.config !== null) {
            message.config = any_1.Any.fromAmino(object.config);
        }
        message.golangBindings = object.golang_bindings?.map(e => exports.GolangBinding.fromAmino(e)) || [];
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.name = message.name === "" ? undefined : message.name;
        obj.config = message.config ? any_1.Any.toAmino(message.config) : undefined;
        if (message.golangBindings) {
            obj.golang_bindings = message.golangBindings.map(e => e ? exports.GolangBinding.toAmino(e) : undefined);
        }
        else {
            obj.golang_bindings = message.golangBindings;
        }
        return obj;
    },
    fromAminoMsg(object) {
        return exports.ModuleConfig.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/ModuleConfig",
            value: exports.ModuleConfig.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.ModuleConfig.decode(message.value);
    },
    toProto(message) {
        return exports.ModuleConfig.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmos.app.v1alpha1.ModuleConfig",
            value: exports.ModuleConfig.encode(message).finish()
        };
    },
    registerTypeUrl() {
        if (!registry_1.GlobalDecoderRegistry.registerExistingTypeUrl(exports.ModuleConfig.typeUrl)) {
            return;
        }
        exports.GolangBinding.registerTypeUrl();
    }
};
function createBaseGolangBinding() {
    return {
        interfaceType: "",
        implementation: ""
    };
}
/**
 * GolangBinding is an explicit interface type to implementing type binding for dependency injection.
 * @name GolangBinding
 * @package cosmos.app.v1alpha1
 * @see proto type: cosmos.app.v1alpha1.GolangBinding
 */
exports.GolangBinding = {
    typeUrl: "/cosmos.app.v1alpha1.GolangBinding",
    aminoType: "cosmos-sdk/GolangBinding",
    is(o) {
        return o && (o.$typeUrl === exports.GolangBinding.typeUrl || typeof o.interfaceType === "string" && typeof o.implementation === "string");
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.GolangBinding.typeUrl || typeof o.interface_type === "string" && typeof o.implementation === "string");
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        if (message.interfaceType !== "") {
            writer.uint32(10).string(message.interfaceType);
        }
        if (message.implementation !== "") {
            writer.uint32(18).string(message.implementation);
        }
        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 = createBaseGolangBinding();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.interfaceType = reader.string();
                    break;
                case 2:
                    message.implementation = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseGolangBinding();
        message.interfaceType = object.interfaceType ?? "";
        message.implementation = object.implementation ?? "";
        return message;
    },
    fromAmino(object) {
        const message = createBaseGolangBinding();
        if (object.interface_type !== undefined && object.interface_type !== null) {
            message.interfaceType = object.interface_type;
        }
        if (object.implementation !== undefined && object.implementation !== null) {
            message.implementation = object.implementation;
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.interface_type = message.interfaceType === "" ? undefined : message.interfaceType;
        obj.implementation = message.implementation === "" ? undefined : message.implementation;
        return obj;
    },
    fromAminoMsg(object) {
        return exports.GolangBinding.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/GolangBinding",
            value: exports.GolangBinding.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.GolangBinding.decode(message.value);
    },
    toProto(message) {
        return exports.GolangBinding.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmos.app.v1alpha1.GolangBinding",
            value: exports.GolangBinding.encode(message).finish()
        };
    },
    registerTypeUrl() { }
};
