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