import { BinaryWriter } from "../../../binary";
import { bytesFromBase64, base64FromBytes } from "../../../helpers";
/** GenesisState defines the raw genesis transaction in JSON. */

/** GenesisState defines the raw genesis transaction in JSON. */

/** GenesisState defines the raw genesis transaction in JSON. */

function createBaseGenesisState() {
  return {
    genTxs: []
  };
}
export const GenesisState = {
  typeUrl: "/cosmos.genutil.v1beta1.GenesisState",
  encode(message, writer = BinaryWriter.create()) {
    for (const v of message.genTxs) {
      writer.uint32(10).bytes(v);
    }
    return writer;
  },
  fromJSON(object) {
    return {
      genTxs: Array.isArray(object === null || object === void 0 ? void 0 : object.genTxs) ? object.genTxs.map(e => bytesFromBase64(e)) : []
    };
  },
  fromPartial(object) {
    var _object$genTxs;
    const message = createBaseGenesisState();
    message.genTxs = ((_object$genTxs = object.genTxs) === null || _object$genTxs === void 0 ? void 0 : _object$genTxs.map(e => e)) || [];
    return message;
  },
  fromAmino(object) {
    var _object$gen_txs;
    const message = createBaseGenesisState();
    message.genTxs = ((_object$gen_txs = object.gen_txs) === null || _object$gen_txs === void 0 ? void 0 : _object$gen_txs.map(e => bytesFromBase64(e))) || [];
    return message;
  },
  toAmino(message) {
    const obj = {};
    if (message.genTxs) {
      obj.gen_txs = message.genTxs.map(e => base64FromBytes(e));
    } else {
      obj.gen_txs = message.genTxs;
    }
    return obj;
  },
  fromAminoMsg(object) {
    return GenesisState.fromAmino(object.value);
  },
  toAminoMsg(message) {
    return {
      type: "cosmos-sdk/GenesisState",
      value: GenesisState.toAmino(message)
    };
  },
  fromProtoMsg(message) {
    return GenesisState.decode(message.value);
  },
  toProto(message) {
    return GenesisState.encode(message).finish();
  },
  toProtoMsg(message) {
    return {
      typeUrl: "/cosmos.genutil.v1beta1.GenesisState",
      value: GenesisState.encode(message).finish()
    };
  }
};