"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.PublicKey = void 0;
var _binary = require("../../binary");
var _helpers = require("../../helpers");
/** PublicKey defines the keys available for use with Validators */

/** PublicKey defines the keys available for use with Validators */

/** PublicKey defines the keys available for use with Validators */

function createBasePublicKey() {
  return {
    ed25519: undefined,
    secp256k1: undefined
  };
}
var PublicKey = exports.PublicKey = {
  typeUrl: "/tendermint.crypto.PublicKey",
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _binary.BinaryWriter.create();
    if (message.ed25519 !== undefined) {
      writer.uint32(10).bytes(message.ed25519);
    }
    if (message.secp256k1 !== undefined) {
      writer.uint32(18).bytes(message.secp256k1);
    }
    return writer;
  },
  fromJSON: function fromJSON(object) {
    return {
      ed25519: (0, _helpers.isSet)(object.ed25519) ? (0, _helpers.bytesFromBase64)(object.ed25519) : undefined,
      secp256k1: (0, _helpers.isSet)(object.secp256k1) ? (0, _helpers.bytesFromBase64)(object.secp256k1) : undefined
    };
  },
  fromPartial: function fromPartial(object) {
    var _object$ed, _object$secp256k;
    var message = createBasePublicKey();
    message.ed25519 = (_object$ed = object.ed25519) !== null && _object$ed !== void 0 ? _object$ed : undefined;
    message.secp256k1 = (_object$secp256k = object.secp256k1) !== null && _object$secp256k !== void 0 ? _object$secp256k : undefined;
    return message;
  },
  fromAmino: function fromAmino(object) {
    var message = createBasePublicKey();
    if (object.ed25519 !== undefined && object.ed25519 !== null) {
      message.ed25519 = (0, _helpers.bytesFromBase64)(object.ed25519);
    }
    if (object.secp256k1 !== undefined && object.secp256k1 !== null) {
      message.secp256k1 = (0, _helpers.bytesFromBase64)(object.secp256k1);
    }
    return message;
  },
  toAmino: function toAmino(message) {
    var obj = {};
    obj.ed25519 = message.ed25519 ? (0, _helpers.base64FromBytes)(message.ed25519) : undefined;
    obj.secp256k1 = message.secp256k1 ? (0, _helpers.base64FromBytes)(message.secp256k1) : undefined;
    return obj;
  },
  fromAminoMsg: function fromAminoMsg(object) {
    return PublicKey.fromAmino(object.value);
  },
  fromProtoMsg: function fromProtoMsg(message) {
    return PublicKey.decode(message.value);
  },
  toProto: function toProto(message) {
    return PublicKey.encode(message).finish();
  },
  toProtoMsg: function toProtoMsg(message) {
    return {
      typeUrl: "/tendermint.crypto.PublicKey",
      value: PublicKey.encode(message).finish()
    };
  }
};