"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AcceptedMessagesFilter = exports.AcceptedMessageKeysFilter = exports.AllowAllMessagesFilter = exports.CombinedLimit = exports.MaxFundsLimit = exports.MaxCallsLimit = exports.ContractGrant = exports.CodeGrant = exports.ContractMigrationAuthorization = exports.ContractExecutionAuthorization = exports.StoreCodeAuthorization = void 0;
const types_1 = require("./types");
const any_1 = require("../../../google/protobuf/any");
const coin_1 = require("../../../cosmos/base/v1beta1/coin");
const binary_1 = require("../../../binary");
const helpers_1 = require("../../../helpers");
const registry_1 = require("../../../registry");
const encoding_1 = require("@interchainjs/encoding");
function createBaseStoreCodeAuthorization() {
    return {
        $typeUrl: "/cosmwasm.wasm.v1.StoreCodeAuthorization",
        grants: []
    };
}
/**
 * StoreCodeAuthorization defines authorization for wasm code upload.
 * Since: wasmd 0.42
 * @name StoreCodeAuthorization
 * @package cosmwasm.wasm.v1
 * @see proto type: cosmwasm.wasm.v1.StoreCodeAuthorization
 */
exports.StoreCodeAuthorization = {
    typeUrl: "/cosmwasm.wasm.v1.StoreCodeAuthorization",
    aminoType: "wasm/StoreCodeAuthorization",
    is(o) {
        return o && (o.$typeUrl === exports.StoreCodeAuthorization.typeUrl || Array.isArray(o.grants) && (!o.grants.length || exports.CodeGrant.is(o.grants[0])));
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.StoreCodeAuthorization.typeUrl || Array.isArray(o.grants) && (!o.grants.length || exports.CodeGrant.isAmino(o.grants[0])));
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        for (const v of message.grants) {
            exports.CodeGrant.encode(v, writer.uint32(10).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 = createBaseStoreCodeAuthorization();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.grants.push(exports.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 => exports.CodeGrant.fromPartial(e)) || [];
        return message;
    },
    fromAmino(object) {
        const message = createBaseStoreCodeAuthorization();
        message.grants = object.grants?.map(e => exports.CodeGrant.fromAmino(e)) || [];
        return message;
    },
    toAmino(message) {
        const obj = {};
        if (message.grants) {
            obj.grants = message.grants.map(e => e ? exports.CodeGrant.toAmino(e) : undefined);
        }
        else {
            obj.grants = message.grants;
        }
        return obj;
    },
    fromAminoMsg(object) {
        return exports.StoreCodeAuthorization.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "wasm/StoreCodeAuthorization",
            value: exports.StoreCodeAuthorization.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.StoreCodeAuthorization.decode(message.value);
    },
    toProto(message) {
        return exports.StoreCodeAuthorization.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmwasm.wasm.v1.StoreCodeAuthorization",
            value: exports.StoreCodeAuthorization.encode(message).finish()
        };
    },
    registerTypeUrl() {
        if (!registry_1.GlobalDecoderRegistry.registerExistingTypeUrl(exports.StoreCodeAuthorization.typeUrl)) {
            return;
        }
        registry_1.GlobalDecoderRegistry.register(exports.StoreCodeAuthorization.typeUrl, exports.StoreCodeAuthorization);
        registry_1.GlobalDecoderRegistry.registerAminoProtoMapping(exports.StoreCodeAuthorization.aminoType, exports.StoreCodeAuthorization.typeUrl);
        exports.CodeGrant.registerTypeUrl();
    }
};
function createBaseContractExecutionAuthorization() {
    return {
        $typeUrl: "/cosmwasm.wasm.v1.ContractExecutionAuthorization",
        grants: []
    };
}
/**
 * ContractExecutionAuthorization defines authorization for wasm execute.
 * Since: wasmd 0.30
 * @name ContractExecutionAuthorization
 * @package cosmwasm.wasm.v1
 * @see proto type: cosmwasm.wasm.v1.ContractExecutionAuthorization
 */
exports.ContractExecutionAuthorization = {
    typeUrl: "/cosmwasm.wasm.v1.ContractExecutionAuthorization",
    aminoType: "wasm/ContractExecutionAuthorization",
    is(o) {
        return o && (o.$typeUrl === exports.ContractExecutionAuthorization.typeUrl || Array.isArray(o.grants) && (!o.grants.length || exports.ContractGrant.is(o.grants[0])));
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.ContractExecutionAuthorization.typeUrl || Array.isArray(o.grants) && (!o.grants.length || exports.ContractGrant.isAmino(o.grants[0])));
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        for (const v of message.grants) {
            exports.ContractGrant.encode(v, writer.uint32(10).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 = createBaseContractExecutionAuthorization();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.grants.push(exports.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 => exports.ContractGrant.fromPartial(e)) || [];
        return message;
    },
    fromAmino(object) {
        const message = createBaseContractExecutionAuthorization();
        message.grants = object.grants?.map(e => exports.ContractGrant.fromAmino(e)) || [];
        return message;
    },
    toAmino(message) {
        const obj = {};
        if (message.grants) {
            obj.grants = message.grants.map(e => e ? exports.ContractGrant.toAmino(e) : undefined);
        }
        else {
            obj.grants = message.grants;
        }
        return obj;
    },
    fromAminoMsg(object) {
        return exports.ContractExecutionAuthorization.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "wasm/ContractExecutionAuthorization",
            value: exports.ContractExecutionAuthorization.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.ContractExecutionAuthorization.decode(message.value);
    },
    toProto(message) {
        return exports.ContractExecutionAuthorization.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmwasm.wasm.v1.ContractExecutionAuthorization",
            value: exports.ContractExecutionAuthorization.encode(message).finish()
        };
    },
    registerTypeUrl() {
        if (!registry_1.GlobalDecoderRegistry.registerExistingTypeUrl(exports.ContractExecutionAuthorization.typeUrl)) {
            return;
        }
        registry_1.GlobalDecoderRegistry.register(exports.ContractExecutionAuthorization.typeUrl, exports.ContractExecutionAuthorization);
        registry_1.GlobalDecoderRegistry.registerAminoProtoMapping(exports.ContractExecutionAuthorization.aminoType, exports.ContractExecutionAuthorization.typeUrl);
        exports.ContractGrant.registerTypeUrl();
    }
};
function createBaseContractMigrationAuthorization() {
    return {
        $typeUrl: "/cosmwasm.wasm.v1.ContractMigrationAuthorization",
        grants: []
    };
}
/**
 * ContractMigrationAuthorization defines authorization for wasm contract
 * migration. Since: wasmd 0.30
 * @name ContractMigrationAuthorization
 * @package cosmwasm.wasm.v1
 * @see proto type: cosmwasm.wasm.v1.ContractMigrationAuthorization
 */
exports.ContractMigrationAuthorization = {
    typeUrl: "/cosmwasm.wasm.v1.ContractMigrationAuthorization",
    aminoType: "wasm/ContractMigrationAuthorization",
    is(o) {
        return o && (o.$typeUrl === exports.ContractMigrationAuthorization.typeUrl || Array.isArray(o.grants) && (!o.grants.length || exports.ContractGrant.is(o.grants[0])));
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.ContractMigrationAuthorization.typeUrl || Array.isArray(o.grants) && (!o.grants.length || exports.ContractGrant.isAmino(o.grants[0])));
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        for (const v of message.grants) {
            exports.ContractGrant.encode(v, writer.uint32(10).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 = createBaseContractMigrationAuthorization();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.grants.push(exports.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 => exports.ContractGrant.fromPartial(e)) || [];
        return message;
    },
    fromAmino(object) {
        const message = createBaseContractMigrationAuthorization();
        message.grants = object.grants?.map(e => exports.ContractGrant.fromAmino(e)) || [];
        return message;
    },
    toAmino(message) {
        const obj = {};
        if (message.grants) {
            obj.grants = message.grants.map(e => e ? exports.ContractGrant.toAmino(e) : undefined);
        }
        else {
            obj.grants = message.grants;
        }
        return obj;
    },
    fromAminoMsg(object) {
        return exports.ContractMigrationAuthorization.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "wasm/ContractMigrationAuthorization",
            value: exports.ContractMigrationAuthorization.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.ContractMigrationAuthorization.decode(message.value);
    },
    toProto(message) {
        return exports.ContractMigrationAuthorization.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmwasm.wasm.v1.ContractMigrationAuthorization",
            value: exports.ContractMigrationAuthorization.encode(message).finish()
        };
    },
    registerTypeUrl() {
        if (!registry_1.GlobalDecoderRegistry.registerExistingTypeUrl(exports.ContractMigrationAuthorization.typeUrl)) {
            return;
        }
        registry_1.GlobalDecoderRegistry.register(exports.ContractMigrationAuthorization.typeUrl, exports.ContractMigrationAuthorization);
        registry_1.GlobalDecoderRegistry.registerAminoProtoMapping(exports.ContractMigrationAuthorization.aminoType, exports.ContractMigrationAuthorization.typeUrl);
        exports.ContractGrant.registerTypeUrl();
    }
};
function createBaseCodeGrant() {
    return {
        codeHash: new Uint8Array(),
        instantiatePermission: undefined
    };
}
/**
 * CodeGrant a granted permission for a single code
 * @name CodeGrant
 * @package cosmwasm.wasm.v1
 * @see proto type: cosmwasm.wasm.v1.CodeGrant
 */
exports.CodeGrant = {
    typeUrl: "/cosmwasm.wasm.v1.CodeGrant",
    aminoType: "wasm/CodeGrant",
    is(o) {
        return o && (o.$typeUrl === exports.CodeGrant.typeUrl || o.codeHash instanceof Uint8Array || typeof o.codeHash === "string");
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.CodeGrant.typeUrl || o.code_hash instanceof Uint8Array || typeof o.code_hash === "string");
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        if (message.codeHash.length !== 0) {
            writer.uint32(10).bytes(message.codeHash);
        }
        if (message.instantiatePermission !== undefined) {
            types_1.AccessConfig.encode(message.instantiatePermission, 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 = createBaseCodeGrant();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.codeHash = reader.bytes();
                    break;
                case 2:
                    message.instantiatePermission = types_1.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 ? types_1.AccessConfig.fromPartial(object.instantiatePermission) : undefined;
        return message;
    },
    fromAmino(object) {
        const message = createBaseCodeGrant();
        if (object.code_hash !== undefined && object.code_hash !== null) {
            message.codeHash = (0, helpers_1.bytesFromBase64)(object.code_hash);
        }
        if (object.instantiate_permission !== undefined && object.instantiate_permission !== null) {
            message.instantiatePermission = types_1.AccessConfig.fromAmino(object.instantiate_permission);
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.code_hash = message.codeHash ? (0, helpers_1.base64FromBytes)(message.codeHash) : undefined;
        obj.instantiate_permission = message.instantiatePermission ? types_1.AccessConfig.toAmino(message.instantiatePermission) : undefined;
        return obj;
    },
    fromAminoMsg(object) {
        return exports.CodeGrant.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "wasm/CodeGrant",
            value: exports.CodeGrant.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.CodeGrant.decode(message.value);
    },
    toProto(message) {
        return exports.CodeGrant.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmwasm.wasm.v1.CodeGrant",
            value: exports.CodeGrant.encode(message).finish()
        };
    },
    registerTypeUrl() {
        if (!registry_1.GlobalDecoderRegistry.registerExistingTypeUrl(exports.CodeGrant.typeUrl)) {
            return;
        }
        types_1.AccessConfig.registerTypeUrl();
    }
};
function createBaseContractGrant() {
    return {
        contract: "",
        limit: undefined,
        filter: undefined
    };
}
/**
 * ContractGrant a granted permission for a single contract
 * Since: wasmd 0.30
 * @name ContractGrant
 * @package cosmwasm.wasm.v1
 * @see proto type: cosmwasm.wasm.v1.ContractGrant
 */
exports.ContractGrant = {
    typeUrl: "/cosmwasm.wasm.v1.ContractGrant",
    aminoType: "wasm/ContractGrant",
    is(o) {
        return o && (o.$typeUrl === exports.ContractGrant.typeUrl || typeof o.contract === "string");
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.ContractGrant.typeUrl || typeof o.contract === "string");
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        if (message.contract !== "") {
            writer.uint32(10).string(message.contract);
        }
        if (message.limit !== undefined) {
            any_1.Any.encode(registry_1.GlobalDecoderRegistry.wrapAny(message.limit), writer.uint32(18).fork()).ldelim();
        }
        if (message.filter !== undefined) {
            any_1.Any.encode(registry_1.GlobalDecoderRegistry.wrapAny(message.filter), 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 = createBaseContractGrant();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.contract = reader.string();
                    break;
                case 2:
                    message.limit = registry_1.GlobalDecoderRegistry.unwrapAny(reader);
                    break;
                case 3:
                    message.filter = registry_1.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 ? registry_1.GlobalDecoderRegistry.fromPartial(object.limit) : undefined;
        message.filter = object.filter !== undefined && object.filter !== null ? registry_1.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 = registry_1.GlobalDecoderRegistry.fromAminoMsg(object.limit);
        }
        if (object.filter !== undefined && object.filter !== null) {
            message.filter = registry_1.GlobalDecoderRegistry.fromAminoMsg(object.filter);
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.contract = message.contract === "" ? undefined : message.contract;
        obj.limit = message.limit ? registry_1.GlobalDecoderRegistry.toAminoMsg(message.limit) : undefined;
        obj.filter = message.filter ? registry_1.GlobalDecoderRegistry.toAminoMsg(message.filter) : undefined;
        return obj;
    },
    fromAminoMsg(object) {
        return exports.ContractGrant.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "wasm/ContractGrant",
            value: exports.ContractGrant.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.ContractGrant.decode(message.value);
    },
    toProto(message) {
        return exports.ContractGrant.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmwasm.wasm.v1.ContractGrant",
            value: exports.ContractGrant.encode(message).finish()
        };
    },
    registerTypeUrl() {
        if (!registry_1.GlobalDecoderRegistry.registerExistingTypeUrl(exports.ContractGrant.typeUrl)) {
            return;
        }
        exports.AllowAllMessagesFilter.registerTypeUrl();
        exports.AcceptedMessageKeysFilter.registerTypeUrl();
        exports.AcceptedMessagesFilter.registerTypeUrl();
    }
};
function createBaseMaxCallsLimit() {
    return {
        $typeUrl: "/cosmwasm.wasm.v1.MaxCallsLimit",
        remaining: BigInt(0)
    };
}
/**
 * MaxCallsLimit limited number of calls to the contract. No funds transferable.
 * Since: wasmd 0.30
 * @name MaxCallsLimit
 * @package cosmwasm.wasm.v1
 * @see proto type: cosmwasm.wasm.v1.MaxCallsLimit
 */
exports.MaxCallsLimit = {
    typeUrl: "/cosmwasm.wasm.v1.MaxCallsLimit",
    aminoType: "wasm/MaxCallsLimit",
    is(o) {
        return o && (o.$typeUrl === exports.MaxCallsLimit.typeUrl || typeof o.remaining === "bigint");
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.MaxCallsLimit.typeUrl || typeof o.remaining === "bigint");
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        if (message.remaining !== BigInt(0)) {
            writer.uint32(8).uint64(message.remaining);
        }
        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 = 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 exports.MaxCallsLimit.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "wasm/MaxCallsLimit",
            value: exports.MaxCallsLimit.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.MaxCallsLimit.decode(message.value);
    },
    toProto(message) {
        return exports.MaxCallsLimit.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmwasm.wasm.v1.MaxCallsLimit",
            value: exports.MaxCallsLimit.encode(message).finish()
        };
    },
    registerTypeUrl() {
        if (!registry_1.GlobalDecoderRegistry.registerExistingTypeUrl(exports.MaxCallsLimit.typeUrl)) {
            return;
        }
        registry_1.GlobalDecoderRegistry.register(exports.MaxCallsLimit.typeUrl, exports.MaxCallsLimit);
        registry_1.GlobalDecoderRegistry.registerAminoProtoMapping(exports.MaxCallsLimit.aminoType, exports.MaxCallsLimit.typeUrl);
    }
};
function createBaseMaxFundsLimit() {
    return {
        $typeUrl: "/cosmwasm.wasm.v1.MaxFundsLimit",
        amounts: []
    };
}
/**
 * MaxFundsLimit defines the maximal amounts that can be sent to the contract.
 * Since: wasmd 0.30
 * @name MaxFundsLimit
 * @package cosmwasm.wasm.v1
 * @see proto type: cosmwasm.wasm.v1.MaxFundsLimit
 */
exports.MaxFundsLimit = {
    typeUrl: "/cosmwasm.wasm.v1.MaxFundsLimit",
    aminoType: "wasm/MaxFundsLimit",
    is(o) {
        return o && (o.$typeUrl === exports.MaxFundsLimit.typeUrl || Array.isArray(o.amounts) && (!o.amounts.length || coin_1.Coin.is(o.amounts[0])));
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.MaxFundsLimit.typeUrl || Array.isArray(o.amounts) && (!o.amounts.length || coin_1.Coin.isAmino(o.amounts[0])));
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        for (const v of message.amounts) {
            coin_1.Coin.encode(v, writer.uint32(10).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 = createBaseMaxFundsLimit();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.amounts.push(coin_1.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_1.Coin.fromPartial(e)) || [];
        return message;
    },
    fromAmino(object) {
        const message = createBaseMaxFundsLimit();
        message.amounts = object.amounts?.map(e => coin_1.Coin.fromAmino(e)) || [];
        return message;
    },
    toAmino(message) {
        const obj = {};
        if (message.amounts) {
            obj.amounts = message.amounts.map(e => e ? coin_1.Coin.toAmino(e) : undefined);
        }
        else {
            obj.amounts = message.amounts;
        }
        return obj;
    },
    fromAminoMsg(object) {
        return exports.MaxFundsLimit.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "wasm/MaxFundsLimit",
            value: exports.MaxFundsLimit.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.MaxFundsLimit.decode(message.value);
    },
    toProto(message) {
        return exports.MaxFundsLimit.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmwasm.wasm.v1.MaxFundsLimit",
            value: exports.MaxFundsLimit.encode(message).finish()
        };
    },
    registerTypeUrl() {
        if (!registry_1.GlobalDecoderRegistry.registerExistingTypeUrl(exports.MaxFundsLimit.typeUrl)) {
            return;
        }
        registry_1.GlobalDecoderRegistry.register(exports.MaxFundsLimit.typeUrl, exports.MaxFundsLimit);
        registry_1.GlobalDecoderRegistry.registerAminoProtoMapping(exports.MaxFundsLimit.aminoType, exports.MaxFundsLimit.typeUrl);
        coin_1.Coin.registerTypeUrl();
    }
};
function createBaseCombinedLimit() {
    return {
        $typeUrl: "/cosmwasm.wasm.v1.CombinedLimit",
        callsRemaining: BigInt(0),
        amounts: []
    };
}
/**
 * CombinedLimit defines the maximal amounts that can be sent to a contract and
 * the maximal number of calls executable. Both need to remain >0 to be valid.
 * Since: wasmd 0.30
 * @name CombinedLimit
 * @package cosmwasm.wasm.v1
 * @see proto type: cosmwasm.wasm.v1.CombinedLimit
 */
exports.CombinedLimit = {
    typeUrl: "/cosmwasm.wasm.v1.CombinedLimit",
    aminoType: "wasm/CombinedLimit",
    is(o) {
        return o && (o.$typeUrl === exports.CombinedLimit.typeUrl || typeof o.callsRemaining === "bigint" && Array.isArray(o.amounts) && (!o.amounts.length || coin_1.Coin.is(o.amounts[0])));
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.CombinedLimit.typeUrl || typeof o.calls_remaining === "bigint" && Array.isArray(o.amounts) && (!o.amounts.length || coin_1.Coin.isAmino(o.amounts[0])));
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        if (message.callsRemaining !== BigInt(0)) {
            writer.uint32(8).uint64(message.callsRemaining);
        }
        for (const v of message.amounts) {
            coin_1.Coin.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 = 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_1.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_1.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_1.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_1.Coin.toAmino(e) : undefined);
        }
        else {
            obj.amounts = message.amounts;
        }
        return obj;
    },
    fromAminoMsg(object) {
        return exports.CombinedLimit.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "wasm/CombinedLimit",
            value: exports.CombinedLimit.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.CombinedLimit.decode(message.value);
    },
    toProto(message) {
        return exports.CombinedLimit.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmwasm.wasm.v1.CombinedLimit",
            value: exports.CombinedLimit.encode(message).finish()
        };
    },
    registerTypeUrl() {
        if (!registry_1.GlobalDecoderRegistry.registerExistingTypeUrl(exports.CombinedLimit.typeUrl)) {
            return;
        }
        registry_1.GlobalDecoderRegistry.register(exports.CombinedLimit.typeUrl, exports.CombinedLimit);
        registry_1.GlobalDecoderRegistry.registerAminoProtoMapping(exports.CombinedLimit.aminoType, exports.CombinedLimit.typeUrl);
        coin_1.Coin.registerTypeUrl();
    }
};
function createBaseAllowAllMessagesFilter() {
    return {
        $typeUrl: "/cosmwasm.wasm.v1.AllowAllMessagesFilter"
    };
}
/**
 * AllowAllMessagesFilter is a wildcard to allow any type of contract payload
 * message.
 * Since: wasmd 0.30
 * @name AllowAllMessagesFilter
 * @package cosmwasm.wasm.v1
 * @see proto type: cosmwasm.wasm.v1.AllowAllMessagesFilter
 */
exports.AllowAllMessagesFilter = {
    typeUrl: "/cosmwasm.wasm.v1.AllowAllMessagesFilter",
    aminoType: "wasm/AllowAllMessagesFilter",
    is(o) {
        return o && o.$typeUrl === exports.AllowAllMessagesFilter.typeUrl;
    },
    isAmino(o) {
        return o && o.$typeUrl === exports.AllowAllMessagesFilter.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 = 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 exports.AllowAllMessagesFilter.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "wasm/AllowAllMessagesFilter",
            value: exports.AllowAllMessagesFilter.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.AllowAllMessagesFilter.decode(message.value);
    },
    toProto(message) {
        return exports.AllowAllMessagesFilter.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmwasm.wasm.v1.AllowAllMessagesFilter",
            value: exports.AllowAllMessagesFilter.encode(message).finish()
        };
    },
    registerTypeUrl() {
        if (!registry_1.GlobalDecoderRegistry.registerExistingTypeUrl(exports.AllowAllMessagesFilter.typeUrl)) {
            return;
        }
        registry_1.GlobalDecoderRegistry.register(exports.AllowAllMessagesFilter.typeUrl, exports.AllowAllMessagesFilter);
        registry_1.GlobalDecoderRegistry.registerAminoProtoMapping(exports.AllowAllMessagesFilter.aminoType, exports.AllowAllMessagesFilter.typeUrl);
    }
};
function createBaseAcceptedMessageKeysFilter() {
    return {
        $typeUrl: "/cosmwasm.wasm.v1.AcceptedMessageKeysFilter",
        keys: []
    };
}
/**
 * AcceptedMessageKeysFilter accept only the specific contract message keys in
 * the json object to be executed.
 * Since: wasmd 0.30
 * @name AcceptedMessageKeysFilter
 * @package cosmwasm.wasm.v1
 * @see proto type: cosmwasm.wasm.v1.AcceptedMessageKeysFilter
 */
exports.AcceptedMessageKeysFilter = {
    typeUrl: "/cosmwasm.wasm.v1.AcceptedMessageKeysFilter",
    aminoType: "wasm/AcceptedMessageKeysFilter",
    is(o) {
        return o && (o.$typeUrl === exports.AcceptedMessageKeysFilter.typeUrl || Array.isArray(o.keys) && (!o.keys.length || typeof o.keys[0] === "string"));
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.AcceptedMessageKeysFilter.typeUrl || Array.isArray(o.keys) && (!o.keys.length || typeof o.keys[0] === "string"));
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        for (const v of message.keys) {
            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 = 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 exports.AcceptedMessageKeysFilter.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "wasm/AcceptedMessageKeysFilter",
            value: exports.AcceptedMessageKeysFilter.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.AcceptedMessageKeysFilter.decode(message.value);
    },
    toProto(message) {
        return exports.AcceptedMessageKeysFilter.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmwasm.wasm.v1.AcceptedMessageKeysFilter",
            value: exports.AcceptedMessageKeysFilter.encode(message).finish()
        };
    },
    registerTypeUrl() {
        if (!registry_1.GlobalDecoderRegistry.registerExistingTypeUrl(exports.AcceptedMessageKeysFilter.typeUrl)) {
            return;
        }
        registry_1.GlobalDecoderRegistry.register(exports.AcceptedMessageKeysFilter.typeUrl, exports.AcceptedMessageKeysFilter);
        registry_1.GlobalDecoderRegistry.registerAminoProtoMapping(exports.AcceptedMessageKeysFilter.aminoType, exports.AcceptedMessageKeysFilter.typeUrl);
    }
};
function createBaseAcceptedMessagesFilter() {
    return {
        $typeUrl: "/cosmwasm.wasm.v1.AcceptedMessagesFilter",
        messages: []
    };
}
/**
 * AcceptedMessagesFilter accept only the specific raw contract messages to be
 * executed.
 * Since: wasmd 0.30
 * @name AcceptedMessagesFilter
 * @package cosmwasm.wasm.v1
 * @see proto type: cosmwasm.wasm.v1.AcceptedMessagesFilter
 */
exports.AcceptedMessagesFilter = {
    typeUrl: "/cosmwasm.wasm.v1.AcceptedMessagesFilter",
    aminoType: "wasm/AcceptedMessagesFilter",
    is(o) {
        return o && (o.$typeUrl === exports.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 === exports.AcceptedMessagesFilter.typeUrl || Array.isArray(o.messages) && (!o.messages.length || o.messages[0] instanceof Uint8Array || typeof o.messages[0] === "string"));
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        for (const v of message.messages) {
            writer.uint32(10).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 = 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 => (0, encoding_1.toUtf8)(JSON.stringify(e))) || [];
        return message;
    },
    toAmino(message) {
        const obj = {};
        if (message.messages) {
            obj.messages = message.messages.map(e => JSON.parse((0, encoding_1.fromUtf8)(e)));
        }
        else {
            obj.messages = message.messages;
        }
        return obj;
    },
    fromAminoMsg(object) {
        return exports.AcceptedMessagesFilter.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "wasm/AcceptedMessagesFilter",
            value: exports.AcceptedMessagesFilter.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.AcceptedMessagesFilter.decode(message.value);
    },
    toProto(message) {
        return exports.AcceptedMessagesFilter.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmwasm.wasm.v1.AcceptedMessagesFilter",
            value: exports.AcceptedMessagesFilter.encode(message).finish()
        };
    },
    registerTypeUrl() {
        if (!registry_1.GlobalDecoderRegistry.registerExistingTypeUrl(exports.AcceptedMessagesFilter.typeUrl)) {
            return;
        }
        registry_1.GlobalDecoderRegistry.register(exports.AcceptedMessagesFilter.typeUrl, exports.AcceptedMessagesFilter);
        registry_1.GlobalDecoderRegistry.registerAminoProtoMapping(exports.AcceptedMessagesFilter.aminoType, exports.AcceptedMessagesFilter.typeUrl);
    }
};
