"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MsgLoadTestResponse = exports.MsgLoadTest = void 0;
const benchmark_1 = require("./benchmark");
const binary_1 = require("../../../binary");
const helpers_1 = require("../../../helpers");
const registry_1 = require("../../../registry");
function createBaseMsgLoadTest() {
    return {
        caller: new Uint8Array(),
        ops: []
    };
}
/**
 * MsgLoadTestOps defines a message containing a sequence of load test operations.
 * @name MsgLoadTest
 * @package cosmos.benchmark.v1
 * @see proto type: cosmos.benchmark.v1.MsgLoadTest
 */
exports.MsgLoadTest = {
    typeUrl: "/cosmos.benchmark.v1.MsgLoadTest",
    aminoType: "cosmos-sdk/tools/benchmark/v1/MsgLoadTest",
    is(o) {
        return o && (o.$typeUrl === exports.MsgLoadTest.typeUrl || (o.caller instanceof Uint8Array || typeof o.caller === "string") && Array.isArray(o.ops) && (!o.ops.length || benchmark_1.Op.is(o.ops[0])));
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.MsgLoadTest.typeUrl || (o.caller instanceof Uint8Array || typeof o.caller === "string") && Array.isArray(o.ops) && (!o.ops.length || benchmark_1.Op.isAmino(o.ops[0])));
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        if (message.caller.length !== 0) {
            writer.uint32(10).bytes(message.caller);
        }
        for (const v of message.ops) {
            benchmark_1.Op.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 = createBaseMsgLoadTest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.caller = reader.bytes();
                    break;
                case 2:
                    message.ops.push(benchmark_1.Op.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseMsgLoadTest();
        message.caller = object.caller ?? new Uint8Array();
        message.ops = object.ops?.map(e => benchmark_1.Op.fromPartial(e)) || [];
        return message;
    },
    fromAmino(object) {
        const message = createBaseMsgLoadTest();
        if (object.caller !== undefined && object.caller !== null) {
            message.caller = (0, helpers_1.bytesFromBase64)(object.caller);
        }
        message.ops = object.ops?.map(e => benchmark_1.Op.fromAmino(e)) || [];
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.caller = message.caller ? (0, helpers_1.base64FromBytes)(message.caller) : undefined;
        if (message.ops) {
            obj.ops = message.ops.map(e => e ? benchmark_1.Op.toAmino(e) : undefined);
        }
        else {
            obj.ops = message.ops;
        }
        return obj;
    },
    fromAminoMsg(object) {
        return exports.MsgLoadTest.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/tools/benchmark/v1/MsgLoadTest",
            value: exports.MsgLoadTest.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.MsgLoadTest.decode(message.value);
    },
    toProto(message) {
        return exports.MsgLoadTest.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmos.benchmark.v1.MsgLoadTest",
            value: exports.MsgLoadTest.encode(message).finish()
        };
    },
    registerTypeUrl() {
        if (!registry_1.GlobalDecoderRegistry.registerExistingTypeUrl(exports.MsgLoadTest.typeUrl)) {
            return;
        }
        benchmark_1.Op.registerTypeUrl();
    }
};
function createBaseMsgLoadTestResponse() {
    return {
        totalTime: BigInt(0),
        totalErrors: BigInt(0)
    };
}
/**
 * MsgLoadTestResponse defines a message containing the results of a load test operation.
 * @name MsgLoadTestResponse
 * @package cosmos.benchmark.v1
 * @see proto type: cosmos.benchmark.v1.MsgLoadTestResponse
 */
exports.MsgLoadTestResponse = {
    typeUrl: "/cosmos.benchmark.v1.MsgLoadTestResponse",
    aminoType: "cosmos-sdk/MsgLoadTestResponse",
    is(o) {
        return o && (o.$typeUrl === exports.MsgLoadTestResponse.typeUrl || typeof o.totalTime === "bigint" && typeof o.totalErrors === "bigint");
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.MsgLoadTestResponse.typeUrl || typeof o.total_time === "bigint" && typeof o.total_errors === "bigint");
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        if (message.totalTime !== BigInt(0)) {
            writer.uint32(8).uint64(message.totalTime);
        }
        if (message.totalErrors !== BigInt(0)) {
            writer.uint32(16).uint64(message.totalErrors);
        }
        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 = createBaseMsgLoadTestResponse();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.totalTime = reader.uint64();
                    break;
                case 2:
                    message.totalErrors = reader.uint64();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseMsgLoadTestResponse();
        message.totalTime = object.totalTime !== undefined && object.totalTime !== null ? BigInt(object.totalTime.toString()) : BigInt(0);
        message.totalErrors = object.totalErrors !== undefined && object.totalErrors !== null ? BigInt(object.totalErrors.toString()) : BigInt(0);
        return message;
    },
    fromAmino(object) {
        const message = createBaseMsgLoadTestResponse();
        if (object.total_time !== undefined && object.total_time !== null) {
            message.totalTime = BigInt(object.total_time);
        }
        if (object.total_errors !== undefined && object.total_errors !== null) {
            message.totalErrors = BigInt(object.total_errors);
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.total_time = message.totalTime !== BigInt(0) ? message.totalTime?.toString() : undefined;
        obj.total_errors = message.totalErrors !== BigInt(0) ? message.totalErrors?.toString() : undefined;
        return obj;
    },
    fromAminoMsg(object) {
        return exports.MsgLoadTestResponse.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/MsgLoadTestResponse",
            value: exports.MsgLoadTestResponse.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.MsgLoadTestResponse.decode(message.value);
    },
    toProto(message) {
        return exports.MsgLoadTestResponse.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmos.benchmark.v1.MsgLoadTestResponse",
            value: exports.MsgLoadTestResponse.encode(message).finish()
        };
    },
    registerTypeUrl() { }
};
