import { Long } from "../../../helpers";
import * as _m0 from "protobufjs/minimal";
function createBaseParams() {
  return {
    isExecutionEnabled: false,
    registryContract: "",
    maxBeginBlockTotalGas: Long.UZERO,
    maxContractGasLimit: Long.UZERO,
    minGasPrice: ""
  };
}
export const Params = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.isExecutionEnabled === true) {
      writer.uint32(8).bool(message.isExecutionEnabled);
    }
    if (message.registryContract !== "") {
      writer.uint32(18).string(message.registryContract);
    }
    if (!message.maxBeginBlockTotalGas.isZero()) {
      writer.uint32(24).uint64(message.maxBeginBlockTotalGas);
    }
    if (!message.maxContractGasLimit.isZero()) {
      writer.uint32(32).uint64(message.maxContractGasLimit);
    }
    if (message.minGasPrice !== "") {
      writer.uint32(42).string(message.minGasPrice);
    }
    return writer;
  },
  decode(input, length) {
    const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseParams();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.isExecutionEnabled = reader.bool();
          break;
        case 2:
          message.registryContract = reader.string();
          break;
        case 3:
          message.maxBeginBlockTotalGas = reader.uint64();
          break;
        case 4:
          message.maxContractGasLimit = reader.uint64();
          break;
        case 5:
          message.minGasPrice = reader.string();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(object) {
    var _object$isExecutionEn, _object$registryContr, _object$minGasPrice;
    const message = createBaseParams();
    message.isExecutionEnabled = (_object$isExecutionEn = object.isExecutionEnabled) !== null && _object$isExecutionEn !== void 0 ? _object$isExecutionEn : false;
    message.registryContract = (_object$registryContr = object.registryContract) !== null && _object$registryContr !== void 0 ? _object$registryContr : "";
    message.maxBeginBlockTotalGas = object.maxBeginBlockTotalGas !== undefined && object.maxBeginBlockTotalGas !== null ? Long.fromValue(object.maxBeginBlockTotalGas) : Long.UZERO;
    message.maxContractGasLimit = object.maxContractGasLimit !== undefined && object.maxContractGasLimit !== null ? Long.fromValue(object.maxContractGasLimit) : Long.UZERO;
    message.minGasPrice = (_object$minGasPrice = object.minGasPrice) !== null && _object$minGasPrice !== void 0 ? _object$minGasPrice : "";
    return message;
  }
};
function createBaseContractRegistrationRequestProposal() {
  return {
    title: "",
    description: "",
    contractRegistrationRequest: undefined
  };
}
export const ContractRegistrationRequestProposal = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.title !== "") {
      writer.uint32(10).string(message.title);
    }
    if (message.description !== "") {
      writer.uint32(18).string(message.description);
    }
    if (message.contractRegistrationRequest !== undefined) {
      ContractRegistrationRequest.encode(message.contractRegistrationRequest, writer.uint32(26).fork()).ldelim();
    }
    return writer;
  },
  decode(input, length) {
    const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseContractRegistrationRequestProposal();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.title = reader.string();
          break;
        case 2:
          message.description = reader.string();
          break;
        case 3:
          message.contractRegistrationRequest = ContractRegistrationRequest.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(object) {
    var _object$title, _object$description;
    const message = createBaseContractRegistrationRequestProposal();
    message.title = (_object$title = object.title) !== null && _object$title !== void 0 ? _object$title : "";
    message.description = (_object$description = object.description) !== null && _object$description !== void 0 ? _object$description : "";
    message.contractRegistrationRequest = object.contractRegistrationRequest !== undefined && object.contractRegistrationRequest !== null ? ContractRegistrationRequest.fromPartial(object.contractRegistrationRequest) : undefined;
    return message;
  }
};
function createBaseBatchContractRegistrationRequestProposal() {
  return {
    title: "",
    description: "",
    contractRegistrationRequests: []
  };
}
export const BatchContractRegistrationRequestProposal = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.title !== "") {
      writer.uint32(10).string(message.title);
    }
    if (message.description !== "") {
      writer.uint32(18).string(message.description);
    }
    for (const v of message.contractRegistrationRequests) {
      ContractRegistrationRequest.encode(v, writer.uint32(26).fork()).ldelim();
    }
    return writer;
  },
  decode(input, length) {
    const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseBatchContractRegistrationRequestProposal();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.title = reader.string();
          break;
        case 2:
          message.description = reader.string();
          break;
        case 3:
          message.contractRegistrationRequests.push(ContractRegistrationRequest.decode(reader, reader.uint32()));
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(object) {
    var _object$title2, _object$description2, _object$contractRegis;
    const message = createBaseBatchContractRegistrationRequestProposal();
    message.title = (_object$title2 = object.title) !== null && _object$title2 !== void 0 ? _object$title2 : "";
    message.description = (_object$description2 = object.description) !== null && _object$description2 !== void 0 ? _object$description2 : "";
    message.contractRegistrationRequests = ((_object$contractRegis = object.contractRegistrationRequests) === null || _object$contractRegis === void 0 ? void 0 : _object$contractRegis.map(e => ContractRegistrationRequest.fromPartial(e))) || [];
    return message;
  }
};
function createBaseContractRegistrationRequest() {
  return {
    contractAddress: "",
    gasLimit: Long.UZERO,
    gasPrice: "",
    pinContract: false
  };
}
export const ContractRegistrationRequest = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.contractAddress !== "") {
      writer.uint32(10).string(message.contractAddress);
    }
    if (!message.gasLimit.isZero()) {
      writer.uint32(16).uint64(message.gasLimit);
    }
    if (message.gasPrice !== "") {
      writer.uint32(26).string(message.gasPrice);
    }
    if (message.pinContract === true) {
      writer.uint32(32).bool(message.pinContract);
    }
    return writer;
  },
  decode(input, length) {
    const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseContractRegistrationRequest();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.contractAddress = reader.string();
          break;
        case 2:
          message.gasLimit = reader.uint64();
          break;
        case 3:
          message.gasPrice = reader.string();
          break;
        case 4:
          message.pinContract = reader.bool();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromPartial(object) {
    var _object$contractAddre, _object$gasPrice, _object$pinContract;
    const message = createBaseContractRegistrationRequest();
    message.contractAddress = (_object$contractAddre = object.contractAddress) !== null && _object$contractAddre !== void 0 ? _object$contractAddre : "";
    message.gasLimit = object.gasLimit !== undefined && object.gasLimit !== null ? Long.fromValue(object.gasLimit) : Long.UZERO;
    message.gasPrice = (_object$gasPrice = object.gasPrice) !== null && _object$gasPrice !== void 0 ? _object$gasPrice : "";
    message.pinContract = (_object$pinContract = object.pinContract) !== null && _object$pinContract !== void 0 ? _object$pinContract : false;
    return message;
  }
};