import { AccessConfig } from "./types";
import { Any } from "../../../google/protobuf/any";
import { Coin } from "../../../cosmos/base/v1beta1/coin";
import { BinaryReader, BinaryWriter } from "../../../binary";
import { bytesFromBase64, base64FromBytes } from "../../../helpers";
import { GlobalDecoderRegistry } from "../../../registry";
import { toUtf8, fromUtf8 } from "@cosmjs/encoding";
function createBaseStoreCodeAuthorization() {
    return {
        grants: []
    };
}
export const StoreCodeAuthorization = {
    typeUrl: "/cosmwasm.wasm.v1.StoreCodeAuthorization",
    aminoType: "wasm/StoreCodeAuthorization",
    is(o) {
        return o && (o.$typeUrl === StoreCodeAuthorization.typeUrl || Array.isArray(o.grants) && (!o.grants.length || CodeGrant.is(o.grants[0])));
    },
    isAmino(o) {
        return o && (o.$typeUrl === StoreCodeAuthorization.typeUrl || Array.isArray(o.grants) && (!o.grants.length || CodeGrant.isAmino(o.grants[0])));
    },
    encode(message, writer = BinaryWriter.create()) {
        for (const v of message.grants) {
            CodeGrant.encode(v, writer.uint32(10).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseStoreCodeAuthorization();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.grants.push(CodeGrant.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseStoreCodeAuthorization();
        message.grants = object.grants?.map(e => CodeGrant.fromPartial(e)) || [];
        return message;
    },
    fromAmino(object) {
        const message = createBaseStoreCodeAuthorization();
        message.grants = object.grants?.map(e => CodeGrant.fromAmino(e)) || [];
        return message;
    },
    toAmino(message) {
        const obj = {};
        if (message.grants) {
            obj.grants = message.grants.map(e => e ? CodeGrant.toAmino(e) : undefined);
        }
        else {
            obj.grants = message.grants;
        }
        return obj;
    },
    fromAminoMsg(object) {
        return StoreCodeAuthorization.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "wasm/StoreCodeAuthorization",
            value: StoreCodeAuthorization.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return StoreCodeAuthorization.decode(message.value);
    },
    toProto(message) {
        return StoreCodeAuthorization.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmwasm.wasm.v1.StoreCodeAuthorization",
            value: StoreCodeAuthorization.encode(message).finish()
        };
    }
};
GlobalDecoderRegistry.register(StoreCodeAuthorization.typeUrl, StoreCodeAuthorization);
GlobalDecoderRegistry.registerAminoProtoMapping(StoreCodeAuthorization.aminoType, StoreCodeAuthorization.typeUrl);
function createBaseContractExecutionAuthorization() {
    return {
        grants: []
    };
}
export const ContractExecutionAuthorization = {
    typeUrl: "/cosmwasm.wasm.v1.ContractExecutionAuthorization",
    aminoType: "wasm/ContractExecutionAuthorization",
    is(o) {
        return o && (o.$typeUrl === ContractExecutionAuthorization.typeUrl || Array.isArray(o.grants) && (!o.grants.length || ContractGrant.is(o.grants[0])));
    },
    isAmino(o) {
        return o && (o.$typeUrl === ContractExecutionAuthorization.typeUrl || Array.isArray(o.grants) && (!o.grants.length || ContractGrant.isAmino(o.grants[0])));
    },
    encode(message, writer = BinaryWriter.create()) {
        for (const v of message.grants) {
            ContractGrant.encode(v, writer.uint32(10).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseContractExecutionAuthorization();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.grants.push(ContractGrant.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseContractExecutionAuthorization();
        message.grants = object.grants?.map(e => ContractGrant.fromPartial(e)) || [];
        return message;
    },
    fromAmino(object) {
        const message = createBaseContractExecutionAuthorization();
        message.grants = object.grants?.map(e => ContractGrant.fromAmino(e)) || [];
        return message;
    },
    toAmino(message) {
        const obj = {};
        if (message.grants) {
            obj.grants = message.grants.map(e => e ? ContractGrant.toAmino(e) : undefined);
        }
        else {
            obj.grants = message.grants;
        }
        return obj;
    },
    fromAminoMsg(object) {
        return ContractExecutionAuthorization.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "wasm/ContractExecutionAuthorization",
            value: ContractExecutionAuthorization.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return ContractExecutionAuthorization.decode(message.value);
    },
    toProto(message) {
        return ContractExecutionAuthorization.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmwasm.wasm.v1.ContractExecutionAuthorization",
            value: ContractExecutionAuthorization.encode(message).finish()
        };
    }
};
GlobalDecoderRegistry.register(ContractExecutionAuthorization.typeUrl, ContractExecutionAuthorization);
GlobalDecoderRegistry.registerAminoProtoMapping(ContractExecutionAuthorization.aminoType, ContractExecutionAuthorization.typeUrl);
function createBaseContractMigrationAuthorization() {
    return {
        grants: []
    };
}
export const ContractMigrationAuthorization = {
    typeUrl: "/cosmwasm.wasm.v1.ContractMigrationAuthorization",
    aminoType: "wasm/ContractMigrationAuthorization",
    is(o) {
        return o && (o.$typeUrl === ContractMigrationAuthorization.typeUrl || Array.isArray(o.grants) && (!o.grants.length || ContractGrant.is(o.grants[0])));
    },
    isAmino(o) {
        return o && (o.$typeUrl === ContractMigrationAuthorization.typeUrl || Array.isArray(o.grants) && (!o.grants.length || ContractGrant.isAmino(o.grants[0])));
    },
    encode(message, writer = BinaryWriter.create()) {
        for (const v of message.grants) {
            ContractGrant.encode(v, writer.uint32(10).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseContractMigrationAuthorization();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.grants.push(ContractGrant.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseContractMigrationAuthorization();
        message.grants = object.grants?.map(e => ContractGrant.fromPartial(e)) || [];
        return message;
    },
    fromAmino(object) {
        const message = createBaseContractMigrationAuthorization();
        message.grants = object.grants?.map(e => ContractGrant.fromAmino(e)) || [];
        return message;
    },
    toAmino(message) {
        const obj = {};
        if (message.grants) {
            obj.grants = message.grants.map(e => e ? ContractGrant.toAmino(e) : undefined);
        }
        else {
            obj.grants = message.grants;
        }
        return obj;
    },
    fromAminoMsg(object) {
        return ContractMigrationAuthorization.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "wasm/ContractMigrationAuthorization",
            value: ContractMigrationAuthorization.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return ContractMigrationAuthorization.decode(message.value);
    },
    toProto(message) {
        return ContractMigrationAuthorization.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmwasm.wasm.v1.ContractMigrationAuthorization",
            value: ContractMigrationAuthorization.encode(message).finish()
        };
    }
};
GlobalDecoderRegistry.register(ContractMigrationAuthorization.typeUrl, ContractMigrationAuthorization);
GlobalDecoderRegistry.registerAminoProtoMapping(ContractMigrationAuthorization.aminoType, ContractMigrationAuthorization.typeUrl);
function createBaseCodeGrant() {
    return {
        codeHash: new Uint8Array(),
        instantiatePermission: undefined
    };
}
export const CodeGrant = {
    typeUrl: "/cosmwasm.wasm.v1.CodeGrant",
    aminoType: "wasm/CodeGrant",
    is(o) {
        return o && (o.$typeUrl === CodeGrant.typeUrl || o.codeHash instanceof Uint8Array || typeof o.codeHash === "string");
    },
    isAmino(o) {
        return o && (o.$typeUrl === CodeGrant.typeUrl || o.code_hash instanceof Uint8Array || typeof o.code_hash === "string");
    },
    encode(message, writer = BinaryWriter.create()) {
        if (message.codeHash.length !== 0) {
            writer.uint32(10).bytes(message.codeHash);
        }
        if (message.instantiatePermission !== undefined) {
            AccessConfig.encode(message.instantiatePermission, writer.uint32(18).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseCodeGrant();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.codeHash = reader.bytes();
                    break;
                case 2:
                    message.instantiatePermission = AccessConfig.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseCodeGrant();
        message.codeHash = object.codeHash ?? new Uint8Array();
        message.instantiatePermission = object.instantiatePermission !== undefined && object.instantiatePermission !== null ? AccessConfig.fromPartial(object.instantiatePermission) : undefined;
        return message;
    },
    fromAmino(object) {
        const message = createBaseCodeGrant();
        if (object.code_hash !== undefined && object.code_hash !== null) {
            message.codeHash = bytesFromBase64(object.code_hash);
        }
        if (object.instantiate_permission !== undefined && object.instantiate_permission !== null) {
            message.instantiatePermission = AccessConfig.fromAmino(object.instantiate_permission);
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.code_hash = message.codeHash ? base64FromBytes(message.codeHash) : undefined;
        obj.instantiate_permission = message.instantiatePermission ? AccessConfig.toAmino(message.instantiatePermission) : undefined;
        return obj;
    },
    fromAminoMsg(object) {
        return CodeGrant.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "wasm/CodeGrant",
            value: CodeGrant.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return CodeGrant.decode(message.value);
    },
    toProto(message) {
        return CodeGrant.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmwasm.wasm.v1.CodeGrant",
            value: CodeGrant.encode(message).finish()
        };
    }
};
GlobalDecoderRegistry.register(CodeGrant.typeUrl, CodeGrant);
GlobalDecoderRegistry.registerAminoProtoMapping(CodeGrant.aminoType, CodeGrant.typeUrl);
function createBaseContractGrant() {
    return {
        contract: "",
        limit: undefined,
        filter: undefined
    };
}
export const ContractGrant = {
    typeUrl: "/cosmwasm.wasm.v1.ContractGrant",
    aminoType: "wasm/ContractGrant",
    is(o) {
        return o && (o.$typeUrl === ContractGrant.typeUrl || typeof o.contract === "string");
    },
    isAmino(o) {
        return o && (o.$typeUrl === ContractGrant.typeUrl || typeof o.contract === "string");
    },
    encode(message, writer = BinaryWriter.create()) {
        if (message.contract !== "") {
            writer.uint32(10).string(message.contract);
        }
        if (message.limit !== undefined) {
            Any.encode(GlobalDecoderRegistry.wrapAny(message.limit), writer.uint32(18).fork()).ldelim();
        }
        if (message.filter !== undefined) {
            Any.encode(GlobalDecoderRegistry.wrapAny(message.filter), writer.uint32(26).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseContractGrant();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.contract = reader.string();
                    break;
                case 2:
                    message.limit = GlobalDecoderRegistry.unwrapAny(reader);
                    break;
                case 3:
                    message.filter = GlobalDecoderRegistry.unwrapAny(reader);
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseContractGrant();
        message.contract = object.contract ?? "";
        message.limit = object.limit !== undefined && object.limit !== null ? GlobalDecoderRegistry.fromPartial(object.limit) : undefined;
        message.filter = object.filter !== undefined && object.filter !== null ? GlobalDecoderRegistry.fromPartial(object.filter) : undefined;
        return message;
    },
    fromAmino(object) {
        const message = createBaseContractGrant();
        if (object.contract !== undefined && object.contract !== null) {
            message.contract = object.contract;
        }
        if (object.limit !== undefined && object.limit !== null) {
            message.limit = GlobalDecoderRegistry.fromAminoMsg(object.limit);
        }
        if (object.filter !== undefined && object.filter !== null) {
            message.filter = GlobalDecoderRegistry.fromAminoMsg(object.filter);
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.contract = message.contract === "" ? undefined : message.contract;
        obj.limit = message.limit ? GlobalDecoderRegistry.toAminoMsg(message.limit) : undefined;
        obj.filter = message.filter ? GlobalDecoderRegistry.toAminoMsg(message.filter) : undefined;
        return obj;
    },
    fromAminoMsg(object) {
        return ContractGrant.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "wasm/ContractGrant",
            value: ContractGrant.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return ContractGrant.decode(message.value);
    },
    toProto(message) {
        return ContractGrant.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmwasm.wasm.v1.ContractGrant",
            value: ContractGrant.encode(message).finish()
        };
    }
};
GlobalDecoderRegistry.register(ContractGrant.typeUrl, ContractGrant);
GlobalDecoderRegistry.registerAminoProtoMapping(ContractGrant.aminoType, ContractGrant.typeUrl);
function createBaseMaxCallsLimit() {
    return {
        remaining: BigInt(0)
    };
}
export const MaxCallsLimit = {
    typeUrl: "/cosmwasm.wasm.v1.MaxCallsLimit",
    aminoType: "wasm/MaxCallsLimit",
    is(o) {
        return o && (o.$typeUrl === MaxCallsLimit.typeUrl || typeof o.remaining === "bigint");
    },
    isAmino(o) {
        return o && (o.$typeUrl === MaxCallsLimit.typeUrl || typeof o.remaining === "bigint");
    },
    encode(message, writer = BinaryWriter.create()) {
        if (message.remaining !== BigInt(0)) {
            writer.uint32(8).uint64(message.remaining);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseMaxCallsLimit();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.remaining = reader.uint64();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseMaxCallsLimit();
        message.remaining = object.remaining !== undefined && object.remaining !== null ? BigInt(object.remaining.toString()) : BigInt(0);
        return message;
    },
    fromAmino(object) {
        const message = createBaseMaxCallsLimit();
        if (object.remaining !== undefined && object.remaining !== null) {
            message.remaining = BigInt(object.remaining);
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.remaining = message.remaining !== BigInt(0) ? message.remaining?.toString() : undefined;
        return obj;
    },
    fromAminoMsg(object) {
        return MaxCallsLimit.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "wasm/MaxCallsLimit",
            value: MaxCallsLimit.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return MaxCallsLimit.decode(message.value);
    },
    toProto(message) {
        return MaxCallsLimit.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmwasm.wasm.v1.MaxCallsLimit",
            value: MaxCallsLimit.encode(message).finish()
        };
    }
};
GlobalDecoderRegistry.register(MaxCallsLimit.typeUrl, MaxCallsLimit);
GlobalDecoderRegistry.registerAminoProtoMapping(MaxCallsLimit.aminoType, MaxCallsLimit.typeUrl);
function createBaseMaxFundsLimit() {
    return {
        amounts: []
    };
}
export const MaxFundsLimit = {
    typeUrl: "/cosmwasm.wasm.v1.MaxFundsLimit",
    aminoType: "wasm/MaxFundsLimit",
    is(o) {
        return o && (o.$typeUrl === MaxFundsLimit.typeUrl || Array.isArray(o.amounts) && (!o.amounts.length || Coin.is(o.amounts[0])));
    },
    isAmino(o) {
        return o && (o.$typeUrl === MaxFundsLimit.typeUrl || Array.isArray(o.amounts) && (!o.amounts.length || Coin.isAmino(o.amounts[0])));
    },
    encode(message, writer = BinaryWriter.create()) {
        for (const v of message.amounts) {
            Coin.encode(v, writer.uint32(10).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseMaxFundsLimit();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.amounts.push(Coin.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseMaxFundsLimit();
        message.amounts = object.amounts?.map(e => Coin.fromPartial(e)) || [];
        return message;
    },
    fromAmino(object) {
        const message = createBaseMaxFundsLimit();
        message.amounts = object.amounts?.map(e => Coin.fromAmino(e)) || [];
        return message;
    },
    toAmino(message) {
        const obj = {};
        if (message.amounts) {
            obj.amounts = message.amounts.map(e => e ? Coin.toAmino(e) : undefined);
        }
        else {
            obj.amounts = message.amounts;
        }
        return obj;
    },
    fromAminoMsg(object) {
        return MaxFundsLimit.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "wasm/MaxFundsLimit",
            value: MaxFundsLimit.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return MaxFundsLimit.decode(message.value);
    },
    toProto(message) {
        return MaxFundsLimit.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmwasm.wasm.v1.MaxFundsLimit",
            value: MaxFundsLimit.encode(message).finish()
        };
    }
};
GlobalDecoderRegistry.register(MaxFundsLimit.typeUrl, MaxFundsLimit);
GlobalDecoderRegistry.registerAminoProtoMapping(MaxFundsLimit.aminoType, MaxFundsLimit.typeUrl);
function createBaseCombinedLimit() {
    return {
        callsRemaining: BigInt(0),
        amounts: []
    };
}
export const CombinedLimit = {
    typeUrl: "/cosmwasm.wasm.v1.CombinedLimit",
    aminoType: "wasm/CombinedLimit",
    is(o) {
        return o && (o.$typeUrl === CombinedLimit.typeUrl || typeof o.callsRemaining === "bigint" && Array.isArray(o.amounts) && (!o.amounts.length || Coin.is(o.amounts[0])));
    },
    isAmino(o) {
        return o && (o.$typeUrl === CombinedLimit.typeUrl || typeof o.calls_remaining === "bigint" && Array.isArray(o.amounts) && (!o.amounts.length || Coin.isAmino(o.amounts[0])));
    },
    encode(message, writer = BinaryWriter.create()) {
        if (message.callsRemaining !== BigInt(0)) {
            writer.uint32(8).uint64(message.callsRemaining);
        }
        for (const v of message.amounts) {
            Coin.encode(v, writer.uint32(18).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseCombinedLimit();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.callsRemaining = reader.uint64();
                    break;
                case 2:
                    message.amounts.push(Coin.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseCombinedLimit();
        message.callsRemaining = object.callsRemaining !== undefined && object.callsRemaining !== null ? BigInt(object.callsRemaining.toString()) : BigInt(0);
        message.amounts = object.amounts?.map(e => Coin.fromPartial(e)) || [];
        return message;
    },
    fromAmino(object) {
        const message = createBaseCombinedLimit();
        if (object.calls_remaining !== undefined && object.calls_remaining !== null) {
            message.callsRemaining = BigInt(object.calls_remaining);
        }
        message.amounts = object.amounts?.map(e => Coin.fromAmino(e)) || [];
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.calls_remaining = message.callsRemaining !== BigInt(0) ? message.callsRemaining?.toString() : undefined;
        if (message.amounts) {
            obj.amounts = message.amounts.map(e => e ? Coin.toAmino(e) : undefined);
        }
        else {
            obj.amounts = message.amounts;
        }
        return obj;
    },
    fromAminoMsg(object) {
        return CombinedLimit.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "wasm/CombinedLimit",
            value: CombinedLimit.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return CombinedLimit.decode(message.value);
    },
    toProto(message) {
        return CombinedLimit.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmwasm.wasm.v1.CombinedLimit",
            value: CombinedLimit.encode(message).finish()
        };
    }
};
GlobalDecoderRegistry.register(CombinedLimit.typeUrl, CombinedLimit);
GlobalDecoderRegistry.registerAminoProtoMapping(CombinedLimit.aminoType, CombinedLimit.typeUrl);
function createBaseAllowAllMessagesFilter() {
    return {};
}
export const AllowAllMessagesFilter = {
    typeUrl: "/cosmwasm.wasm.v1.AllowAllMessagesFilter",
    aminoType: "wasm/AllowAllMessagesFilter",
    is(o) {
        return o && o.$typeUrl === AllowAllMessagesFilter.typeUrl;
    },
    isAmino(o) {
        return o && o.$typeUrl === AllowAllMessagesFilter.typeUrl;
    },
    encode(_, writer = BinaryWriter.create()) {
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseAllowAllMessagesFilter();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(_) {
        const message = createBaseAllowAllMessagesFilter();
        return message;
    },
    fromAmino(_) {
        const message = createBaseAllowAllMessagesFilter();
        return message;
    },
    toAmino(_) {
        const obj = {};
        return obj;
    },
    fromAminoMsg(object) {
        return AllowAllMessagesFilter.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "wasm/AllowAllMessagesFilter",
            value: AllowAllMessagesFilter.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return AllowAllMessagesFilter.decode(message.value);
    },
    toProto(message) {
        return AllowAllMessagesFilter.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmwasm.wasm.v1.AllowAllMessagesFilter",
            value: AllowAllMessagesFilter.encode(message).finish()
        };
    }
};
GlobalDecoderRegistry.register(AllowAllMessagesFilter.typeUrl, AllowAllMessagesFilter);
GlobalDecoderRegistry.registerAminoProtoMapping(AllowAllMessagesFilter.aminoType, AllowAllMessagesFilter.typeUrl);
function createBaseAcceptedMessageKeysFilter() {
    return {
        keys: []
    };
}
export const AcceptedMessageKeysFilter = {
    typeUrl: "/cosmwasm.wasm.v1.AcceptedMessageKeysFilter",
    aminoType: "wasm/AcceptedMessageKeysFilter",
    is(o) {
        return o && (o.$typeUrl === AcceptedMessageKeysFilter.typeUrl || Array.isArray(o.keys) && (!o.keys.length || typeof o.keys[0] === "string"));
    },
    isAmino(o) {
        return o && (o.$typeUrl === AcceptedMessageKeysFilter.typeUrl || Array.isArray(o.keys) && (!o.keys.length || typeof o.keys[0] === "string"));
    },
    encode(message, writer = BinaryWriter.create()) {
        for (const v of message.keys) {
            writer.uint32(10).string(v);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseAcceptedMessageKeysFilter();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.keys.push(reader.string());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseAcceptedMessageKeysFilter();
        message.keys = object.keys?.map(e => e) || [];
        return message;
    },
    fromAmino(object) {
        const message = createBaseAcceptedMessageKeysFilter();
        message.keys = object.keys?.map(e => e) || [];
        return message;
    },
    toAmino(message) {
        const obj = {};
        if (message.keys) {
            obj.keys = message.keys.map(e => e);
        }
        else {
            obj.keys = message.keys;
        }
        return obj;
    },
    fromAminoMsg(object) {
        return AcceptedMessageKeysFilter.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "wasm/AcceptedMessageKeysFilter",
            value: AcceptedMessageKeysFilter.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return AcceptedMessageKeysFilter.decode(message.value);
    },
    toProto(message) {
        return AcceptedMessageKeysFilter.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmwasm.wasm.v1.AcceptedMessageKeysFilter",
            value: AcceptedMessageKeysFilter.encode(message).finish()
        };
    }
};
GlobalDecoderRegistry.register(AcceptedMessageKeysFilter.typeUrl, AcceptedMessageKeysFilter);
GlobalDecoderRegistry.registerAminoProtoMapping(AcceptedMessageKeysFilter.aminoType, AcceptedMessageKeysFilter.typeUrl);
function createBaseAcceptedMessagesFilter() {
    return {
        messages: []
    };
}
export const AcceptedMessagesFilter = {
    typeUrl: "/cosmwasm.wasm.v1.AcceptedMessagesFilter",
    aminoType: "wasm/AcceptedMessagesFilter",
    is(o) {
        return o && (o.$typeUrl === AcceptedMessagesFilter.typeUrl || Array.isArray(o.messages) && (!o.messages.length || o.messages[0] instanceof Uint8Array || typeof o.messages[0] === "string"));
    },
    isAmino(o) {
        return o && (o.$typeUrl === AcceptedMessagesFilter.typeUrl || Array.isArray(o.messages) && (!o.messages.length || o.messages[0] instanceof Uint8Array || typeof o.messages[0] === "string"));
    },
    encode(message, writer = BinaryWriter.create()) {
        for (const v of message.messages) {
            writer.uint32(10).bytes(v);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseAcceptedMessagesFilter();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.messages.push(reader.bytes());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseAcceptedMessagesFilter();
        message.messages = object.messages?.map(e => e) || [];
        return message;
    },
    fromAmino(object) {
        const message = createBaseAcceptedMessagesFilter();
        message.messages = object.messages?.map(e => toUtf8(JSON.stringify(e))) || [];
        return message;
    },
    toAmino(message) {
        const obj = {};
        if (message.messages) {
            obj.messages = message.messages.map(e => JSON.parse(fromUtf8(e)));
        }
        else {
            obj.messages = message.messages;
        }
        return obj;
    },
    fromAminoMsg(object) {
        return AcceptedMessagesFilter.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "wasm/AcceptedMessagesFilter",
            value: AcceptedMessagesFilter.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return AcceptedMessagesFilter.decode(message.value);
    },
    toProto(message) {
        return AcceptedMessagesFilter.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmwasm.wasm.v1.AcceptedMessagesFilter",
            value: AcceptedMessagesFilter.encode(message).finish()
        };
    }
};
GlobalDecoderRegistry.register(AcceptedMessagesFilter.typeUrl, AcceptedMessagesFilter);
GlobalDecoderRegistry.registerAminoProtoMapping(AcceptedMessagesFilter.aminoType, AcceptedMessagesFilter.typeUrl);
