"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExecTxResult = exports.EventAttribute = exports.Event = exports.StoreKVPair = exports.ListenStateChangesResponse = exports.ListenStateChangesRequest = exports.ListenDeliverBlockResponse = exports.ListenDeliverBlockRequest = void 0;
const binary_1 = require("../../../binary");
const helpers_1 = require("../../../helpers");
const registry_1 = require("../../../registry");
function createBaseListenDeliverBlockRequest() {
    return {
        blockHeight: BigInt(0),
        txs: [],
        events: [],
        txResults: []
    };
}
exports.ListenDeliverBlockRequest = {
    typeUrl: "/cosmos.streaming.v1.ListenDeliverBlockRequest",
    aminoType: "cosmos-sdk/ListenDeliverBlockRequest",
    is(o) {
        return o && (o.$typeUrl === exports.ListenDeliverBlockRequest.typeUrl || typeof o.blockHeight === "bigint" && Array.isArray(o.txs) && (!o.txs.length || o.txs[0] instanceof Uint8Array || typeof o.txs[0] === "string") && Array.isArray(o.events) && (!o.events.length || exports.Event.is(o.events[0])) && Array.isArray(o.txResults) && (!o.txResults.length || exports.ExecTxResult.is(o.txResults[0])));
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.ListenDeliverBlockRequest.typeUrl || typeof o.block_height === "bigint" && Array.isArray(o.txs) && (!o.txs.length || o.txs[0] instanceof Uint8Array || typeof o.txs[0] === "string") && Array.isArray(o.events) && (!o.events.length || exports.Event.isAmino(o.events[0])) && Array.isArray(o.tx_results) && (!o.tx_results.length || exports.ExecTxResult.isAmino(o.tx_results[0])));
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        if (message.blockHeight !== BigInt(0)) {
            writer.uint32(8).int64(message.blockHeight);
        }
        for (const v of message.txs) {
            writer.uint32(18).bytes(v);
        }
        for (const v of message.events) {
            exports.Event.encode(v, writer.uint32(26).fork()).ldelim();
        }
        for (const v of message.txResults) {
            exports.ExecTxResult.encode(v, writer.uint32(34).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 = createBaseListenDeliverBlockRequest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.blockHeight = reader.int64();
                    break;
                case 2:
                    message.txs.push(reader.bytes());
                    break;
                case 3:
                    message.events.push(exports.Event.decode(reader, reader.uint32()));
                    break;
                case 4:
                    message.txResults.push(exports.ExecTxResult.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseListenDeliverBlockRequest();
        message.blockHeight = object.blockHeight !== undefined && object.blockHeight !== null ? BigInt(object.blockHeight.toString()) : BigInt(0);
        message.txs = object.txs?.map(e => e) || [];
        message.events = object.events?.map(e => exports.Event.fromPartial(e)) || [];
        message.txResults = object.txResults?.map(e => exports.ExecTxResult.fromPartial(e)) || [];
        return message;
    },
    fromAmino(object) {
        const message = createBaseListenDeliverBlockRequest();
        if (object.block_height !== undefined && object.block_height !== null) {
            message.blockHeight = BigInt(object.block_height);
        }
        message.txs = object.txs?.map(e => (0, helpers_1.bytesFromBase64)(e)) || [];
        message.events = object.events?.map(e => exports.Event.fromAmino(e)) || [];
        message.txResults = object.tx_results?.map(e => exports.ExecTxResult.fromAmino(e)) || [];
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.block_height = message.blockHeight !== BigInt(0) ? message.blockHeight?.toString() : undefined;
        if (message.txs) {
            obj.txs = message.txs.map(e => (0, helpers_1.base64FromBytes)(e));
        }
        else {
            obj.txs = message.txs;
        }
        if (message.events) {
            obj.events = message.events.map(e => e ? exports.Event.toAmino(e) : undefined);
        }
        else {
            obj.events = message.events;
        }
        if (message.txResults) {
            obj.tx_results = message.txResults.map(e => e ? exports.ExecTxResult.toAmino(e) : undefined);
        }
        else {
            obj.tx_results = message.txResults;
        }
        return obj;
    },
    fromAminoMsg(object) {
        return exports.ListenDeliverBlockRequest.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/ListenDeliverBlockRequest",
            value: exports.ListenDeliverBlockRequest.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.ListenDeliverBlockRequest.decode(message.value);
    },
    toProto(message) {
        return exports.ListenDeliverBlockRequest.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmos.streaming.v1.ListenDeliverBlockRequest",
            value: exports.ListenDeliverBlockRequest.encode(message).finish()
        };
    }
};
registry_1.GlobalDecoderRegistry.register(exports.ListenDeliverBlockRequest.typeUrl, exports.ListenDeliverBlockRequest);
registry_1.GlobalDecoderRegistry.registerAminoProtoMapping(exports.ListenDeliverBlockRequest.aminoType, exports.ListenDeliverBlockRequest.typeUrl);
function createBaseListenDeliverBlockResponse() {
    return {};
}
exports.ListenDeliverBlockResponse = {
    typeUrl: "/cosmos.streaming.v1.ListenDeliverBlockResponse",
    aminoType: "cosmos-sdk/ListenDeliverBlockResponse",
    is(o) {
        return o && o.$typeUrl === exports.ListenDeliverBlockResponse.typeUrl;
    },
    isAmino(o) {
        return o && o.$typeUrl === exports.ListenDeliverBlockResponse.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 = createBaseListenDeliverBlockResponse();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(_) {
        const message = createBaseListenDeliverBlockResponse();
        return message;
    },
    fromAmino(_) {
        const message = createBaseListenDeliverBlockResponse();
        return message;
    },
    toAmino(_) {
        const obj = {};
        return obj;
    },
    fromAminoMsg(object) {
        return exports.ListenDeliverBlockResponse.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/ListenDeliverBlockResponse",
            value: exports.ListenDeliverBlockResponse.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.ListenDeliverBlockResponse.decode(message.value);
    },
    toProto(message) {
        return exports.ListenDeliverBlockResponse.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmos.streaming.v1.ListenDeliverBlockResponse",
            value: exports.ListenDeliverBlockResponse.encode(message).finish()
        };
    }
};
registry_1.GlobalDecoderRegistry.register(exports.ListenDeliverBlockResponse.typeUrl, exports.ListenDeliverBlockResponse);
registry_1.GlobalDecoderRegistry.registerAminoProtoMapping(exports.ListenDeliverBlockResponse.aminoType, exports.ListenDeliverBlockResponse.typeUrl);
function createBaseListenStateChangesRequest() {
    return {
        blockHeight: BigInt(0),
        changeSet: [],
        appHash: new Uint8Array()
    };
}
exports.ListenStateChangesRequest = {
    typeUrl: "/cosmos.streaming.v1.ListenStateChangesRequest",
    aminoType: "cosmos-sdk/ListenStateChangesRequest",
    is(o) {
        return o && (o.$typeUrl === exports.ListenStateChangesRequest.typeUrl || typeof o.blockHeight === "bigint" && Array.isArray(o.changeSet) && (!o.changeSet.length || exports.StoreKVPair.is(o.changeSet[0])) && (o.appHash instanceof Uint8Array || typeof o.appHash === "string"));
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.ListenStateChangesRequest.typeUrl || typeof o.block_height === "bigint" && Array.isArray(o.change_set) && (!o.change_set.length || exports.StoreKVPair.isAmino(o.change_set[0])) && (o.app_hash instanceof Uint8Array || typeof o.app_hash === "string"));
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        if (message.blockHeight !== BigInt(0)) {
            writer.uint32(8).int64(message.blockHeight);
        }
        for (const v of message.changeSet) {
            exports.StoreKVPair.encode(v, writer.uint32(18).fork()).ldelim();
        }
        if (message.appHash.length !== 0) {
            writer.uint32(26).bytes(message.appHash);
        }
        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 = createBaseListenStateChangesRequest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.blockHeight = reader.int64();
                    break;
                case 2:
                    message.changeSet.push(exports.StoreKVPair.decode(reader, reader.uint32()));
                    break;
                case 3:
                    message.appHash = reader.bytes();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseListenStateChangesRequest();
        message.blockHeight = object.blockHeight !== undefined && object.blockHeight !== null ? BigInt(object.blockHeight.toString()) : BigInt(0);
        message.changeSet = object.changeSet?.map(e => exports.StoreKVPair.fromPartial(e)) || [];
        message.appHash = object.appHash ?? new Uint8Array();
        return message;
    },
    fromAmino(object) {
        const message = createBaseListenStateChangesRequest();
        if (object.block_height !== undefined && object.block_height !== null) {
            message.blockHeight = BigInt(object.block_height);
        }
        message.changeSet = object.change_set?.map(e => exports.StoreKVPair.fromAmino(e)) || [];
        if (object.app_hash !== undefined && object.app_hash !== null) {
            message.appHash = (0, helpers_1.bytesFromBase64)(object.app_hash);
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.block_height = message.blockHeight !== BigInt(0) ? message.blockHeight?.toString() : undefined;
        if (message.changeSet) {
            obj.change_set = message.changeSet.map(e => e ? exports.StoreKVPair.toAmino(e) : undefined);
        }
        else {
            obj.change_set = message.changeSet;
        }
        obj.app_hash = message.appHash ? (0, helpers_1.base64FromBytes)(message.appHash) : undefined;
        return obj;
    },
    fromAminoMsg(object) {
        return exports.ListenStateChangesRequest.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/ListenStateChangesRequest",
            value: exports.ListenStateChangesRequest.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.ListenStateChangesRequest.decode(message.value);
    },
    toProto(message) {
        return exports.ListenStateChangesRequest.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmos.streaming.v1.ListenStateChangesRequest",
            value: exports.ListenStateChangesRequest.encode(message).finish()
        };
    }
};
registry_1.GlobalDecoderRegistry.register(exports.ListenStateChangesRequest.typeUrl, exports.ListenStateChangesRequest);
registry_1.GlobalDecoderRegistry.registerAminoProtoMapping(exports.ListenStateChangesRequest.aminoType, exports.ListenStateChangesRequest.typeUrl);
function createBaseListenStateChangesResponse() {
    return {};
}
exports.ListenStateChangesResponse = {
    typeUrl: "/cosmos.streaming.v1.ListenStateChangesResponse",
    aminoType: "cosmos-sdk/ListenStateChangesResponse",
    is(o) {
        return o && o.$typeUrl === exports.ListenStateChangesResponse.typeUrl;
    },
    isAmino(o) {
        return o && o.$typeUrl === exports.ListenStateChangesResponse.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 = createBaseListenStateChangesResponse();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(_) {
        const message = createBaseListenStateChangesResponse();
        return message;
    },
    fromAmino(_) {
        const message = createBaseListenStateChangesResponse();
        return message;
    },
    toAmino(_) {
        const obj = {};
        return obj;
    },
    fromAminoMsg(object) {
        return exports.ListenStateChangesResponse.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/ListenStateChangesResponse",
            value: exports.ListenStateChangesResponse.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.ListenStateChangesResponse.decode(message.value);
    },
    toProto(message) {
        return exports.ListenStateChangesResponse.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmos.streaming.v1.ListenStateChangesResponse",
            value: exports.ListenStateChangesResponse.encode(message).finish()
        };
    }
};
registry_1.GlobalDecoderRegistry.register(exports.ListenStateChangesResponse.typeUrl, exports.ListenStateChangesResponse);
registry_1.GlobalDecoderRegistry.registerAminoProtoMapping(exports.ListenStateChangesResponse.aminoType, exports.ListenStateChangesResponse.typeUrl);
function createBaseStoreKVPair() {
    return {
        address: new Uint8Array(),
        key: new Uint8Array(),
        value: new Uint8Array(),
        delete: false
    };
}
exports.StoreKVPair = {
    typeUrl: "/cosmos.streaming.v1.StoreKVPair",
    aminoType: "cosmos-sdk/StoreKVPair",
    is(o) {
        return o && (o.$typeUrl === exports.StoreKVPair.typeUrl || (o.address instanceof Uint8Array || typeof o.address === "string") && (o.key instanceof Uint8Array || typeof o.key === "string") && (o.value instanceof Uint8Array || typeof o.value === "string") && typeof o.delete === "boolean");
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.StoreKVPair.typeUrl || (o.address instanceof Uint8Array || typeof o.address === "string") && (o.key instanceof Uint8Array || typeof o.key === "string") && (o.value instanceof Uint8Array || typeof o.value === "string") && typeof o.delete === "boolean");
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        if (message.address.length !== 0) {
            writer.uint32(10).bytes(message.address);
        }
        if (message.key.length !== 0) {
            writer.uint32(18).bytes(message.key);
        }
        if (message.value.length !== 0) {
            writer.uint32(26).bytes(message.value);
        }
        if (message.delete === true) {
            writer.uint32(32).bool(message.delete);
        }
        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 = createBaseStoreKVPair();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.address = reader.bytes();
                    break;
                case 2:
                    message.key = reader.bytes();
                    break;
                case 3:
                    message.value = reader.bytes();
                    break;
                case 4:
                    message.delete = reader.bool();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseStoreKVPair();
        message.address = object.address ?? new Uint8Array();
        message.key = object.key ?? new Uint8Array();
        message.value = object.value ?? new Uint8Array();
        message.delete = object.delete ?? false;
        return message;
    },
    fromAmino(object) {
        const message = createBaseStoreKVPair();
        if (object.address !== undefined && object.address !== null) {
            message.address = (0, helpers_1.bytesFromBase64)(object.address);
        }
        if (object.key !== undefined && object.key !== null) {
            message.key = (0, helpers_1.bytesFromBase64)(object.key);
        }
        if (object.value !== undefined && object.value !== null) {
            message.value = (0, helpers_1.bytesFromBase64)(object.value);
        }
        if (object.delete !== undefined && object.delete !== null) {
            message.delete = object.delete;
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.address = message.address ? (0, helpers_1.base64FromBytes)(message.address) : undefined;
        obj.key = message.key ? (0, helpers_1.base64FromBytes)(message.key) : undefined;
        obj.value = message.value ? (0, helpers_1.base64FromBytes)(message.value) : undefined;
        obj.delete = message.delete === false ? undefined : message.delete;
        return obj;
    },
    fromAminoMsg(object) {
        return exports.StoreKVPair.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/StoreKVPair",
            value: exports.StoreKVPair.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.StoreKVPair.decode(message.value);
    },
    toProto(message) {
        return exports.StoreKVPair.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmos.streaming.v1.StoreKVPair",
            value: exports.StoreKVPair.encode(message).finish()
        };
    }
};
registry_1.GlobalDecoderRegistry.register(exports.StoreKVPair.typeUrl, exports.StoreKVPair);
registry_1.GlobalDecoderRegistry.registerAminoProtoMapping(exports.StoreKVPair.aminoType, exports.StoreKVPair.typeUrl);
function createBaseEvent() {
    return {
        type: "",
        attributes: []
    };
}
exports.Event = {
    typeUrl: "/cosmos.streaming.v1.Event",
    aminoType: "cosmos-sdk/Event",
    is(o) {
        return o && (o.$typeUrl === exports.Event.typeUrl || typeof o.type === "string" && Array.isArray(o.attributes) && (!o.attributes.length || exports.EventAttribute.is(o.attributes[0])));
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.Event.typeUrl || typeof o.type === "string" && Array.isArray(o.attributes) && (!o.attributes.length || exports.EventAttribute.isAmino(o.attributes[0])));
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        if (message.type !== "") {
            writer.uint32(10).string(message.type);
        }
        for (const v of message.attributes) {
            exports.EventAttribute.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 = createBaseEvent();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.type = reader.string();
                    break;
                case 2:
                    message.attributes.push(exports.EventAttribute.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseEvent();
        message.type = object.type ?? "";
        message.attributes = object.attributes?.map(e => exports.EventAttribute.fromPartial(e)) || [];
        return message;
    },
    fromAmino(object) {
        const message = createBaseEvent();
        if (object.type !== undefined && object.type !== null) {
            message.type = object.type;
        }
        message.attributes = object.attributes?.map(e => exports.EventAttribute.fromAmino(e)) || [];
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.type = message.type === "" ? undefined : message.type;
        if (message.attributes) {
            obj.attributes = message.attributes.map(e => e ? exports.EventAttribute.toAmino(e) : undefined);
        }
        else {
            obj.attributes = message.attributes;
        }
        return obj;
    },
    fromAminoMsg(object) {
        return exports.Event.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/Event",
            value: exports.Event.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.Event.decode(message.value);
    },
    toProto(message) {
        return exports.Event.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmos.streaming.v1.Event",
            value: exports.Event.encode(message).finish()
        };
    }
};
registry_1.GlobalDecoderRegistry.register(exports.Event.typeUrl, exports.Event);
registry_1.GlobalDecoderRegistry.registerAminoProtoMapping(exports.Event.aminoType, exports.Event.typeUrl);
function createBaseEventAttribute() {
    return {
        key: "",
        value: ""
    };
}
exports.EventAttribute = {
    typeUrl: "/cosmos.streaming.v1.EventAttribute",
    aminoType: "cosmos-sdk/EventAttribute",
    is(o) {
        return o && (o.$typeUrl === exports.EventAttribute.typeUrl || typeof o.key === "string" && typeof o.value === "string");
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.EventAttribute.typeUrl || typeof o.key === "string" && typeof o.value === "string");
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        if (message.key !== "") {
            writer.uint32(10).string(message.key);
        }
        if (message.value !== "") {
            writer.uint32(18).string(message.value);
        }
        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 = createBaseEventAttribute();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.key = reader.string();
                    break;
                case 2:
                    message.value = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseEventAttribute();
        message.key = object.key ?? "";
        message.value = object.value ?? "";
        return message;
    },
    fromAmino(object) {
        const message = createBaseEventAttribute();
        if (object.key !== undefined && object.key !== null) {
            message.key = object.key;
        }
        if (object.value !== undefined && object.value !== null) {
            message.value = object.value;
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.key = message.key === "" ? undefined : message.key;
        obj.value = message.value === "" ? undefined : message.value;
        return obj;
    },
    fromAminoMsg(object) {
        return exports.EventAttribute.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/EventAttribute",
            value: exports.EventAttribute.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.EventAttribute.decode(message.value);
    },
    toProto(message) {
        return exports.EventAttribute.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmos.streaming.v1.EventAttribute",
            value: exports.EventAttribute.encode(message).finish()
        };
    }
};
registry_1.GlobalDecoderRegistry.register(exports.EventAttribute.typeUrl, exports.EventAttribute);
registry_1.GlobalDecoderRegistry.registerAminoProtoMapping(exports.EventAttribute.aminoType, exports.EventAttribute.typeUrl);
function createBaseExecTxResult() {
    return {
        code: 0,
        data: new Uint8Array(),
        log: "",
        info: "",
        gasWanted: BigInt(0),
        gasUsed: BigInt(0),
        events: [],
        codespace: ""
    };
}
exports.ExecTxResult = {
    typeUrl: "/cosmos.streaming.v1.ExecTxResult",
    aminoType: "cosmos-sdk/ExecTxResult",
    is(o) {
        return o && (o.$typeUrl === exports.ExecTxResult.typeUrl || typeof o.code === "number" && (o.data instanceof Uint8Array || typeof o.data === "string") && typeof o.log === "string" && typeof o.info === "string" && typeof o.gasWanted === "bigint" && typeof o.gasUsed === "bigint" && Array.isArray(o.events) && (!o.events.length || exports.Event.is(o.events[0])) && typeof o.codespace === "string");
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.ExecTxResult.typeUrl || typeof o.code === "number" && (o.data instanceof Uint8Array || typeof o.data === "string") && typeof o.log === "string" && typeof o.info === "string" && typeof o.gas_wanted === "bigint" && typeof o.gas_used === "bigint" && Array.isArray(o.events) && (!o.events.length || exports.Event.isAmino(o.events[0])) && typeof o.codespace === "string");
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        if (message.code !== 0) {
            writer.uint32(8).uint32(message.code);
        }
        if (message.data.length !== 0) {
            writer.uint32(18).bytes(message.data);
        }
        if (message.log !== "") {
            writer.uint32(26).string(message.log);
        }
        if (message.info !== "") {
            writer.uint32(34).string(message.info);
        }
        if (message.gasWanted !== BigInt(0)) {
            writer.uint32(40).int64(message.gasWanted);
        }
        if (message.gasUsed !== BigInt(0)) {
            writer.uint32(48).int64(message.gasUsed);
        }
        for (const v of message.events) {
            exports.Event.encode(v, writer.uint32(58).fork()).ldelim();
        }
        if (message.codespace !== "") {
            writer.uint32(66).string(message.codespace);
        }
        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 = createBaseExecTxResult();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.code = reader.uint32();
                    break;
                case 2:
                    message.data = reader.bytes();
                    break;
                case 3:
                    message.log = reader.string();
                    break;
                case 4:
                    message.info = reader.string();
                    break;
                case 5:
                    message.gasWanted = reader.int64();
                    break;
                case 6:
                    message.gasUsed = reader.int64();
                    break;
                case 7:
                    message.events.push(exports.Event.decode(reader, reader.uint32()));
                    break;
                case 8:
                    message.codespace = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseExecTxResult();
        message.code = object.code ?? 0;
        message.data = object.data ?? new Uint8Array();
        message.log = object.log ?? "";
        message.info = object.info ?? "";
        message.gasWanted = object.gasWanted !== undefined && object.gasWanted !== null ? BigInt(object.gasWanted.toString()) : BigInt(0);
        message.gasUsed = object.gasUsed !== undefined && object.gasUsed !== null ? BigInt(object.gasUsed.toString()) : BigInt(0);
        message.events = object.events?.map(e => exports.Event.fromPartial(e)) || [];
        message.codespace = object.codespace ?? "";
        return message;
    },
    fromAmino(object) {
        const message = createBaseExecTxResult();
        if (object.code !== undefined && object.code !== null) {
            message.code = object.code;
        }
        if (object.data !== undefined && object.data !== null) {
            message.data = (0, helpers_1.bytesFromBase64)(object.data);
        }
        if (object.log !== undefined && object.log !== null) {
            message.log = object.log;
        }
        if (object.info !== undefined && object.info !== null) {
            message.info = object.info;
        }
        if (object.gas_wanted !== undefined && object.gas_wanted !== null) {
            message.gasWanted = BigInt(object.gas_wanted);
        }
        if (object.gas_used !== undefined && object.gas_used !== null) {
            message.gasUsed = BigInt(object.gas_used);
        }
        message.events = object.events?.map(e => exports.Event.fromAmino(e)) || [];
        if (object.codespace !== undefined && object.codespace !== null) {
            message.codespace = object.codespace;
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.code = message.code === 0 ? undefined : message.code;
        obj.data = message.data ? (0, helpers_1.base64FromBytes)(message.data) : undefined;
        obj.log = message.log === "" ? undefined : message.log;
        obj.info = message.info === "" ? undefined : message.info;
        obj.gas_wanted = message.gasWanted !== BigInt(0) ? message.gasWanted?.toString() : undefined;
        obj.gas_used = message.gasUsed !== BigInt(0) ? message.gasUsed?.toString() : undefined;
        if (message.events) {
            obj.events = message.events.map(e => e ? exports.Event.toAmino(e) : undefined);
        }
        else {
            obj.events = message.events;
        }
        obj.codespace = message.codespace === "" ? undefined : message.codespace;
        return obj;
    },
    fromAminoMsg(object) {
        return exports.ExecTxResult.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/ExecTxResult",
            value: exports.ExecTxResult.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.ExecTxResult.decode(message.value);
    },
    toProto(message) {
        return exports.ExecTxResult.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmos.streaming.v1.ExecTxResult",
            value: exports.ExecTxResult.encode(message).finish()
        };
    }
};
registry_1.GlobalDecoderRegistry.register(exports.ExecTxResult.typeUrl, exports.ExecTxResult);
registry_1.GlobalDecoderRegistry.registerAminoProtoMapping(exports.ExecTxResult.aminoType, exports.ExecTxResult.typeUrl);
