"use strict";

var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.BondWithdrawShareEvent = exports.BondWithdrawReserveEvent = exports.BondUpdatedEvent = exports.BondSwapOrderFulfilledEvent = exports.BondSwapOrderEvent = exports.BondSetNextAlphaEvent = exports.BondSellOrderFulfilledEvent = exports.BondSellOrderEvent = exports.BondMakeOutcomePaymentEvent = exports.BondEditAlphaSuccessEvent = exports.BondEditAlphaFailedEvent = exports.BondCreatedEvent = exports.BondBuyOrderFulfilledEvent = exports.BondBuyOrderEvent = exports.BondBuyOrderCancelledEvent = void 0;
var _bonds = require("./bonds");
var _coin = require("../../../cosmos/base/v1beta1/coin");
var _m0 = _interopRequireWildcard(require("protobufjs/minimal"));
var _helpers = require("../../../helpers");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } //@ts-nocheck
/** BondCreatedEvent is an event triggered on a Bond creation */

/** BondCreatedEvent is an event triggered on a Bond creation */

/** BondUpdatedEvent is an event triggered on a Bond update */

/** BondUpdatedEvent is an event triggered on a Bond update */

/** BondSetNextAlphaEvent is an event triggered when next batch alpha is set */

/** BondSetNextAlphaEvent is an event triggered when next batch alpha is set */

/** BondBuyOrderEvent is an event triggered on a Bond buy order */

/** BondBuyOrderEvent is an event triggered on a Bond buy order */

/** BondSellOrderEvent is an event triggered on a Bond sell order */

/** BondSellOrderEvent is an event triggered on a Bond sell order */

/** BondSwapOrderEvent is an event triggered on a Bond swap order */

/** BondSwapOrderEvent is an event triggered on a Bond swap order */

/**
 * BondMakeOutcomePaymentEvent is an event triggered on a Bond make outcome
 * payment
 */

/**
 * BondMakeOutcomePaymentEvent is an event triggered on a Bond make outcome
 * payment
 */

/** BondWithdrawShareEvent is an event triggered on a Bond share withdrawal */

/** BondWithdrawShareEvent is an event triggered on a Bond share withdrawal */

/** BondWithdrawReserveEvent is an event triggered on a Bond reserve withdrawal */

/** BondWithdrawReserveEvent is an event triggered on a Bond reserve withdrawal */

/**
 * BondEditAlphaSuccessEvent is an event triggered on a successful edit of Bond
 * alpha value
 */

/**
 * BondEditAlphaSuccessEvent is an event triggered on a successful edit of Bond
 * alpha value
 */

/**
 * BondEditAlphaFailedEvent is an event triggered on a failed attempt to edit of
 * Bond alpha value
 */

/**
 * BondEditAlphaFailedEvent is an event triggered on a failed attempt to edit of
 * Bond alpha value
 */

/**
 * BondBuyOrderFulfilledEvent is an event triggered on a Bond buy order
 * fullfillment
 */

/**
 * BondBuyOrderFulfilledEvent is an event triggered on a Bond buy order
 * fullfillment
 */

/**
 * BondSellOrderFulfilledEvent is an event triggered on a Bond sell order
 * fullfillment
 */

/**
 * BondSellOrderFulfilledEvent is an event triggered on a Bond sell order
 * fullfillment
 */

/**
 * BondSwapOrderFulfilledEvent is an event triggered on a Bond swap order
 * fullfillment
 */

/**
 * BondSwapOrderFulfilledEvent is an event triggered on a Bond swap order
 * fullfillment
 */

/**
 * BondBuyOrderCancelledEvent is an event triggered on a Bond buy order
 * cancellation
 */

/**
 * BondBuyOrderCancelledEvent is an event triggered on a Bond buy order
 * cancellation
 */

function createBaseBondCreatedEvent() {
  return {
    bond: undefined
  };
}
var BondCreatedEvent = exports.BondCreatedEvent = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.bond !== undefined) {
      _bonds.Bond.encode(message.bond, writer.uint32(10).fork()).ldelim();
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseBondCreatedEvent();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.bond = _bonds.Bond.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      bond: (0, _helpers.isSet)(object.bond) ? _bonds.Bond.fromJSON(object.bond) : undefined
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    message.bond !== undefined && (obj.bond = message.bond ? _bonds.Bond.toJSON(message.bond) : undefined);
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var message = createBaseBondCreatedEvent();
    message.bond = object.bond !== undefined && object.bond !== null ? _bonds.Bond.fromPartial(object.bond) : undefined;
    return message;
  }
};
function createBaseBondUpdatedEvent() {
  return {
    bond: undefined
  };
}
var BondUpdatedEvent = exports.BondUpdatedEvent = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.bond !== undefined) {
      _bonds.Bond.encode(message.bond, writer.uint32(10).fork()).ldelim();
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseBondUpdatedEvent();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.bond = _bonds.Bond.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      bond: (0, _helpers.isSet)(object.bond) ? _bonds.Bond.fromJSON(object.bond) : undefined
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    message.bond !== undefined && (obj.bond = message.bond ? _bonds.Bond.toJSON(message.bond) : undefined);
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var message = createBaseBondUpdatedEvent();
    message.bond = object.bond !== undefined && object.bond !== null ? _bonds.Bond.fromPartial(object.bond) : undefined;
    return message;
  }
};
function createBaseBondSetNextAlphaEvent() {
  return {
    bondDid: "",
    nextAlpha: "",
    signer: ""
  };
}
var BondSetNextAlphaEvent = exports.BondSetNextAlphaEvent = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.bondDid !== "") {
      writer.uint32(10).string(message.bondDid);
    }
    if (message.nextAlpha !== "") {
      writer.uint32(18).string(message.nextAlpha);
    }
    if (message.signer !== "") {
      writer.uint32(26).string(message.signer);
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseBondSetNextAlphaEvent();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.bondDid = reader.string();
          break;
        case 2:
          message.nextAlpha = reader.string();
          break;
        case 3:
          message.signer = reader.string();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      bondDid: (0, _helpers.isSet)(object.bondDid) ? String(object.bondDid) : "",
      nextAlpha: (0, _helpers.isSet)(object.nextAlpha) ? String(object.nextAlpha) : "",
      signer: (0, _helpers.isSet)(object.signer) ? String(object.signer) : ""
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    message.bondDid !== undefined && (obj.bondDid = message.bondDid);
    message.nextAlpha !== undefined && (obj.nextAlpha = message.nextAlpha);
    message.signer !== undefined && (obj.signer = message.signer);
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var _object$bondDid, _object$nextAlpha, _object$signer;
    var message = createBaseBondSetNextAlphaEvent();
    message.bondDid = (_object$bondDid = object.bondDid) !== null && _object$bondDid !== void 0 ? _object$bondDid : "";
    message.nextAlpha = (_object$nextAlpha = object.nextAlpha) !== null && _object$nextAlpha !== void 0 ? _object$nextAlpha : "";
    message.signer = (_object$signer = object.signer) !== null && _object$signer !== void 0 ? _object$signer : "";
    return message;
  }
};
function createBaseBondBuyOrderEvent() {
  return {
    order: undefined,
    bondDid: ""
  };
}
var BondBuyOrderEvent = exports.BondBuyOrderEvent = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.order !== undefined) {
      _bonds.BuyOrder.encode(message.order, writer.uint32(10).fork()).ldelim();
    }
    if (message.bondDid !== "") {
      writer.uint32(18).string(message.bondDid);
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseBondBuyOrderEvent();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.order = _bonds.BuyOrder.decode(reader, reader.uint32());
          break;
        case 2:
          message.bondDid = reader.string();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      order: (0, _helpers.isSet)(object.order) ? _bonds.BuyOrder.fromJSON(object.order) : undefined,
      bondDid: (0, _helpers.isSet)(object.bondDid) ? String(object.bondDid) : ""
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    message.order !== undefined && (obj.order = message.order ? _bonds.BuyOrder.toJSON(message.order) : undefined);
    message.bondDid !== undefined && (obj.bondDid = message.bondDid);
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var _object$bondDid2;
    var message = createBaseBondBuyOrderEvent();
    message.order = object.order !== undefined && object.order !== null ? _bonds.BuyOrder.fromPartial(object.order) : undefined;
    message.bondDid = (_object$bondDid2 = object.bondDid) !== null && _object$bondDid2 !== void 0 ? _object$bondDid2 : "";
    return message;
  }
};
function createBaseBondSellOrderEvent() {
  return {
    order: undefined,
    bondDid: ""
  };
}
var BondSellOrderEvent = exports.BondSellOrderEvent = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.order !== undefined) {
      _bonds.SellOrder.encode(message.order, writer.uint32(10).fork()).ldelim();
    }
    if (message.bondDid !== "") {
      writer.uint32(18).string(message.bondDid);
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseBondSellOrderEvent();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.order = _bonds.SellOrder.decode(reader, reader.uint32());
          break;
        case 2:
          message.bondDid = reader.string();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      order: (0, _helpers.isSet)(object.order) ? _bonds.SellOrder.fromJSON(object.order) : undefined,
      bondDid: (0, _helpers.isSet)(object.bondDid) ? String(object.bondDid) : ""
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    message.order !== undefined && (obj.order = message.order ? _bonds.SellOrder.toJSON(message.order) : undefined);
    message.bondDid !== undefined && (obj.bondDid = message.bondDid);
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var _object$bondDid3;
    var message = createBaseBondSellOrderEvent();
    message.order = object.order !== undefined && object.order !== null ? _bonds.SellOrder.fromPartial(object.order) : undefined;
    message.bondDid = (_object$bondDid3 = object.bondDid) !== null && _object$bondDid3 !== void 0 ? _object$bondDid3 : "";
    return message;
  }
};
function createBaseBondSwapOrderEvent() {
  return {
    order: undefined,
    bondDid: ""
  };
}
var BondSwapOrderEvent = exports.BondSwapOrderEvent = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.order !== undefined) {
      _bonds.SwapOrder.encode(message.order, writer.uint32(10).fork()).ldelim();
    }
    if (message.bondDid !== "") {
      writer.uint32(18).string(message.bondDid);
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseBondSwapOrderEvent();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.order = _bonds.SwapOrder.decode(reader, reader.uint32());
          break;
        case 2:
          message.bondDid = reader.string();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      order: (0, _helpers.isSet)(object.order) ? _bonds.SwapOrder.fromJSON(object.order) : undefined,
      bondDid: (0, _helpers.isSet)(object.bondDid) ? String(object.bondDid) : ""
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    message.order !== undefined && (obj.order = message.order ? _bonds.SwapOrder.toJSON(message.order) : undefined);
    message.bondDid !== undefined && (obj.bondDid = message.bondDid);
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var _object$bondDid4;
    var message = createBaseBondSwapOrderEvent();
    message.order = object.order !== undefined && object.order !== null ? _bonds.SwapOrder.fromPartial(object.order) : undefined;
    message.bondDid = (_object$bondDid4 = object.bondDid) !== null && _object$bondDid4 !== void 0 ? _object$bondDid4 : "";
    return message;
  }
};
function createBaseBondMakeOutcomePaymentEvent() {
  return {
    bondDid: "",
    outcomePayment: [],
    senderDid: "",
    senderAddress: ""
  };
}
var BondMakeOutcomePaymentEvent = exports.BondMakeOutcomePaymentEvent = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.bondDid !== "") {
      writer.uint32(10).string(message.bondDid);
    }
    var _iterator = _createForOfIteratorHelper(message.outcomePayment),
      _step;
    try {
      for (_iterator.s(); !(_step = _iterator.n()).done;) {
        var v = _step.value;
        _coin.Coin.encode(v, writer.uint32(18).fork()).ldelim();
      }
    } catch (err) {
      _iterator.e(err);
    } finally {
      _iterator.f();
    }
    if (message.senderDid !== "") {
      writer.uint32(26).string(message.senderDid);
    }
    if (message.senderAddress !== "") {
      writer.uint32(34).string(message.senderAddress);
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseBondMakeOutcomePaymentEvent();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.bondDid = reader.string();
          break;
        case 2:
          message.outcomePayment.push(_coin.Coin.decode(reader, reader.uint32()));
          break;
        case 3:
          message.senderDid = reader.string();
          break;
        case 4:
          message.senderAddress = reader.string();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      bondDid: (0, _helpers.isSet)(object.bondDid) ? String(object.bondDid) : "",
      outcomePayment: Array.isArray(object === null || object === void 0 ? void 0 : object.outcomePayment) ? object.outcomePayment.map(function (e) {
        return _coin.Coin.fromJSON(e);
      }) : [],
      senderDid: (0, _helpers.isSet)(object.senderDid) ? String(object.senderDid) : "",
      senderAddress: (0, _helpers.isSet)(object.senderAddress) ? String(object.senderAddress) : ""
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    message.bondDid !== undefined && (obj.bondDid = message.bondDid);
    if (message.outcomePayment) {
      obj.outcomePayment = message.outcomePayment.map(function (e) {
        return e ? _coin.Coin.toJSON(e) : undefined;
      });
    } else {
      obj.outcomePayment = [];
    }
    message.senderDid !== undefined && (obj.senderDid = message.senderDid);
    message.senderAddress !== undefined && (obj.senderAddress = message.senderAddress);
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var _object$bondDid5, _object$outcomePaymen, _object$senderDid, _object$senderAddress;
    var message = createBaseBondMakeOutcomePaymentEvent();
    message.bondDid = (_object$bondDid5 = object.bondDid) !== null && _object$bondDid5 !== void 0 ? _object$bondDid5 : "";
    message.outcomePayment = ((_object$outcomePaymen = object.outcomePayment) === null || _object$outcomePaymen === void 0 ? void 0 : _object$outcomePaymen.map(function (e) {
      return _coin.Coin.fromPartial(e);
    })) || [];
    message.senderDid = (_object$senderDid = object.senderDid) !== null && _object$senderDid !== void 0 ? _object$senderDid : "";
    message.senderAddress = (_object$senderAddress = object.senderAddress) !== null && _object$senderAddress !== void 0 ? _object$senderAddress : "";
    return message;
  }
};
function createBaseBondWithdrawShareEvent() {
  return {
    bondDid: "",
    withdrawPayment: [],
    recipientDid: "",
    recipientAddress: ""
  };
}
var BondWithdrawShareEvent = exports.BondWithdrawShareEvent = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.bondDid !== "") {
      writer.uint32(10).string(message.bondDid);
    }
    var _iterator2 = _createForOfIteratorHelper(message.withdrawPayment),
      _step2;
    try {
      for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
        var v = _step2.value;
        _coin.Coin.encode(v, writer.uint32(18).fork()).ldelim();
      }
    } catch (err) {
      _iterator2.e(err);
    } finally {
      _iterator2.f();
    }
    if (message.recipientDid !== "") {
      writer.uint32(26).string(message.recipientDid);
    }
    if (message.recipientAddress !== "") {
      writer.uint32(34).string(message.recipientAddress);
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseBondWithdrawShareEvent();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.bondDid = reader.string();
          break;
        case 2:
          message.withdrawPayment.push(_coin.Coin.decode(reader, reader.uint32()));
          break;
        case 3:
          message.recipientDid = reader.string();
          break;
        case 4:
          message.recipientAddress = reader.string();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      bondDid: (0, _helpers.isSet)(object.bondDid) ? String(object.bondDid) : "",
      withdrawPayment: Array.isArray(object === null || object === void 0 ? void 0 : object.withdrawPayment) ? object.withdrawPayment.map(function (e) {
        return _coin.Coin.fromJSON(e);
      }) : [],
      recipientDid: (0, _helpers.isSet)(object.recipientDid) ? String(object.recipientDid) : "",
      recipientAddress: (0, _helpers.isSet)(object.recipientAddress) ? String(object.recipientAddress) : ""
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    message.bondDid !== undefined && (obj.bondDid = message.bondDid);
    if (message.withdrawPayment) {
      obj.withdrawPayment = message.withdrawPayment.map(function (e) {
        return e ? _coin.Coin.toJSON(e) : undefined;
      });
    } else {
      obj.withdrawPayment = [];
    }
    message.recipientDid !== undefined && (obj.recipientDid = message.recipientDid);
    message.recipientAddress !== undefined && (obj.recipientAddress = message.recipientAddress);
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var _object$bondDid6, _object$withdrawPayme, _object$recipientDid, _object$recipientAddr;
    var message = createBaseBondWithdrawShareEvent();
    message.bondDid = (_object$bondDid6 = object.bondDid) !== null && _object$bondDid6 !== void 0 ? _object$bondDid6 : "";
    message.withdrawPayment = ((_object$withdrawPayme = object.withdrawPayment) === null || _object$withdrawPayme === void 0 ? void 0 : _object$withdrawPayme.map(function (e) {
      return _coin.Coin.fromPartial(e);
    })) || [];
    message.recipientDid = (_object$recipientDid = object.recipientDid) !== null && _object$recipientDid !== void 0 ? _object$recipientDid : "";
    message.recipientAddress = (_object$recipientAddr = object.recipientAddress) !== null && _object$recipientAddr !== void 0 ? _object$recipientAddr : "";
    return message;
  }
};
function createBaseBondWithdrawReserveEvent() {
  return {
    bondDid: "",
    withdrawAmount: [],
    withdrawerDid: "",
    withdrawerAddress: "",
    reserveWithdrawalAddress: ""
  };
}
var BondWithdrawReserveEvent = exports.BondWithdrawReserveEvent = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.bondDid !== "") {
      writer.uint32(10).string(message.bondDid);
    }
    var _iterator3 = _createForOfIteratorHelper(message.withdrawAmount),
      _step3;
    try {
      for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
        var v = _step3.value;
        _coin.Coin.encode(v, writer.uint32(18).fork()).ldelim();
      }
    } catch (err) {
      _iterator3.e(err);
    } finally {
      _iterator3.f();
    }
    if (message.withdrawerDid !== "") {
      writer.uint32(26).string(message.withdrawerDid);
    }
    if (message.withdrawerAddress !== "") {
      writer.uint32(34).string(message.withdrawerAddress);
    }
    if (message.reserveWithdrawalAddress !== "") {
      writer.uint32(42).string(message.reserveWithdrawalAddress);
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseBondWithdrawReserveEvent();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.bondDid = reader.string();
          break;
        case 2:
          message.withdrawAmount.push(_coin.Coin.decode(reader, reader.uint32()));
          break;
        case 3:
          message.withdrawerDid = reader.string();
          break;
        case 4:
          message.withdrawerAddress = reader.string();
          break;
        case 5:
          message.reserveWithdrawalAddress = reader.string();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      bondDid: (0, _helpers.isSet)(object.bondDid) ? String(object.bondDid) : "",
      withdrawAmount: Array.isArray(object === null || object === void 0 ? void 0 : object.withdrawAmount) ? object.withdrawAmount.map(function (e) {
        return _coin.Coin.fromJSON(e);
      }) : [],
      withdrawerDid: (0, _helpers.isSet)(object.withdrawerDid) ? String(object.withdrawerDid) : "",
      withdrawerAddress: (0, _helpers.isSet)(object.withdrawerAddress) ? String(object.withdrawerAddress) : "",
      reserveWithdrawalAddress: (0, _helpers.isSet)(object.reserveWithdrawalAddress) ? String(object.reserveWithdrawalAddress) : ""
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    message.bondDid !== undefined && (obj.bondDid = message.bondDid);
    if (message.withdrawAmount) {
      obj.withdrawAmount = message.withdrawAmount.map(function (e) {
        return e ? _coin.Coin.toJSON(e) : undefined;
      });
    } else {
      obj.withdrawAmount = [];
    }
    message.withdrawerDid !== undefined && (obj.withdrawerDid = message.withdrawerDid);
    message.withdrawerAddress !== undefined && (obj.withdrawerAddress = message.withdrawerAddress);
    message.reserveWithdrawalAddress !== undefined && (obj.reserveWithdrawalAddress = message.reserveWithdrawalAddress);
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var _object$bondDid7, _object$withdrawAmoun, _object$withdrawerDid, _object$withdrawerAdd, _object$reserveWithdr;
    var message = createBaseBondWithdrawReserveEvent();
    message.bondDid = (_object$bondDid7 = object.bondDid) !== null && _object$bondDid7 !== void 0 ? _object$bondDid7 : "";
    message.withdrawAmount = ((_object$withdrawAmoun = object.withdrawAmount) === null || _object$withdrawAmoun === void 0 ? void 0 : _object$withdrawAmoun.map(function (e) {
      return _coin.Coin.fromPartial(e);
    })) || [];
    message.withdrawerDid = (_object$withdrawerDid = object.withdrawerDid) !== null && _object$withdrawerDid !== void 0 ? _object$withdrawerDid : "";
    message.withdrawerAddress = (_object$withdrawerAdd = object.withdrawerAddress) !== null && _object$withdrawerAdd !== void 0 ? _object$withdrawerAdd : "";
    message.reserveWithdrawalAddress = (_object$reserveWithdr = object.reserveWithdrawalAddress) !== null && _object$reserveWithdr !== void 0 ? _object$reserveWithdr : "";
    return message;
  }
};
function createBaseBondEditAlphaSuccessEvent() {
  return {
    bondDid: "",
    token: "",
    publicAlpha: "",
    systemAlpha: ""
  };
}
var BondEditAlphaSuccessEvent = exports.BondEditAlphaSuccessEvent = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.bondDid !== "") {
      writer.uint32(10).string(message.bondDid);
    }
    if (message.token !== "") {
      writer.uint32(18).string(message.token);
    }
    if (message.publicAlpha !== "") {
      writer.uint32(26).string(message.publicAlpha);
    }
    if (message.systemAlpha !== "") {
      writer.uint32(34).string(message.systemAlpha);
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseBondEditAlphaSuccessEvent();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.bondDid = reader.string();
          break;
        case 2:
          message.token = reader.string();
          break;
        case 3:
          message.publicAlpha = reader.string();
          break;
        case 4:
          message.systemAlpha = reader.string();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      bondDid: (0, _helpers.isSet)(object.bondDid) ? String(object.bondDid) : "",
      token: (0, _helpers.isSet)(object.token) ? String(object.token) : "",
      publicAlpha: (0, _helpers.isSet)(object.publicAlpha) ? String(object.publicAlpha) : "",
      systemAlpha: (0, _helpers.isSet)(object.systemAlpha) ? String(object.systemAlpha) : ""
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    message.bondDid !== undefined && (obj.bondDid = message.bondDid);
    message.token !== undefined && (obj.token = message.token);
    message.publicAlpha !== undefined && (obj.publicAlpha = message.publicAlpha);
    message.systemAlpha !== undefined && (obj.systemAlpha = message.systemAlpha);
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var _object$bondDid8, _object$token, _object$publicAlpha, _object$systemAlpha;
    var message = createBaseBondEditAlphaSuccessEvent();
    message.bondDid = (_object$bondDid8 = object.bondDid) !== null && _object$bondDid8 !== void 0 ? _object$bondDid8 : "";
    message.token = (_object$token = object.token) !== null && _object$token !== void 0 ? _object$token : "";
    message.publicAlpha = (_object$publicAlpha = object.publicAlpha) !== null && _object$publicAlpha !== void 0 ? _object$publicAlpha : "";
    message.systemAlpha = (_object$systemAlpha = object.systemAlpha) !== null && _object$systemAlpha !== void 0 ? _object$systemAlpha : "";
    return message;
  }
};
function createBaseBondEditAlphaFailedEvent() {
  return {
    bondDid: "",
    token: "",
    cancelReason: ""
  };
}
var BondEditAlphaFailedEvent = exports.BondEditAlphaFailedEvent = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.bondDid !== "") {
      writer.uint32(10).string(message.bondDid);
    }
    if (message.token !== "") {
      writer.uint32(18).string(message.token);
    }
    if (message.cancelReason !== "") {
      writer.uint32(26).string(message.cancelReason);
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseBondEditAlphaFailedEvent();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.bondDid = reader.string();
          break;
        case 2:
          message.token = reader.string();
          break;
        case 3:
          message.cancelReason = reader.string();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      bondDid: (0, _helpers.isSet)(object.bondDid) ? String(object.bondDid) : "",
      token: (0, _helpers.isSet)(object.token) ? String(object.token) : "",
      cancelReason: (0, _helpers.isSet)(object.cancelReason) ? String(object.cancelReason) : ""
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    message.bondDid !== undefined && (obj.bondDid = message.bondDid);
    message.token !== undefined && (obj.token = message.token);
    message.cancelReason !== undefined && (obj.cancelReason = message.cancelReason);
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var _object$bondDid9, _object$token2, _object$cancelReason;
    var message = createBaseBondEditAlphaFailedEvent();
    message.bondDid = (_object$bondDid9 = object.bondDid) !== null && _object$bondDid9 !== void 0 ? _object$bondDid9 : "";
    message.token = (_object$token2 = object.token) !== null && _object$token2 !== void 0 ? _object$token2 : "";
    message.cancelReason = (_object$cancelReason = object.cancelReason) !== null && _object$cancelReason !== void 0 ? _object$cancelReason : "";
    return message;
  }
};
function createBaseBondBuyOrderFulfilledEvent() {
  return {
    bondDid: "",
    order: undefined,
    chargedPrices: [],
    chargedFees: [],
    returnedToAddress: [],
    newBondTokenBalance: "",
    chargedPricesOfWhichReserve: undefined,
    chargedPricesOfWhichFunding: []
  };
}
var BondBuyOrderFulfilledEvent = exports.BondBuyOrderFulfilledEvent = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.bondDid !== "") {
      writer.uint32(10).string(message.bondDid);
    }
    if (message.order !== undefined) {
      _bonds.BuyOrder.encode(message.order, writer.uint32(18).fork()).ldelim();
    }
    var _iterator4 = _createForOfIteratorHelper(message.chargedPrices),
      _step4;
    try {
      for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
        var v = _step4.value;
        _coin.Coin.encode(v, writer.uint32(26).fork()).ldelim();
      }
    } catch (err) {
      _iterator4.e(err);
    } finally {
      _iterator4.f();
    }
    var _iterator5 = _createForOfIteratorHelper(message.chargedFees),
      _step5;
    try {
      for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
        var _v = _step5.value;
        _coin.Coin.encode(_v, writer.uint32(34).fork()).ldelim();
      }
    } catch (err) {
      _iterator5.e(err);
    } finally {
      _iterator5.f();
    }
    var _iterator6 = _createForOfIteratorHelper(message.returnedToAddress),
      _step6;
    try {
      for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
        var _v2 = _step6.value;
        _coin.Coin.encode(_v2, writer.uint32(42).fork()).ldelim();
      }
    } catch (err) {
      _iterator6.e(err);
    } finally {
      _iterator6.f();
    }
    if (message.newBondTokenBalance !== "") {
      writer.uint32(50).string(message.newBondTokenBalance);
    }
    if (message.chargedPricesOfWhichReserve !== undefined) {
      writer.uint32(58).string(message.chargedPricesOfWhichReserve);
    }
    var _iterator7 = _createForOfIteratorHelper(message.chargedPricesOfWhichFunding),
      _step7;
    try {
      for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
        var _v3 = _step7.value;
        _coin.Coin.encode(_v3, writer.uint32(66).fork()).ldelim();
      }
    } catch (err) {
      _iterator7.e(err);
    } finally {
      _iterator7.f();
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseBondBuyOrderFulfilledEvent();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.bondDid = reader.string();
          break;
        case 2:
          message.order = _bonds.BuyOrder.decode(reader, reader.uint32());
          break;
        case 3:
          message.chargedPrices.push(_coin.Coin.decode(reader, reader.uint32()));
          break;
        case 4:
          message.chargedFees.push(_coin.Coin.decode(reader, reader.uint32()));
          break;
        case 5:
          message.returnedToAddress.push(_coin.Coin.decode(reader, reader.uint32()));
          break;
        case 6:
          message.newBondTokenBalance = reader.string();
          break;
        case 7:
          message.chargedPricesOfWhichReserve = reader.string();
          break;
        case 8:
          message.chargedPricesOfWhichFunding.push(_coin.Coin.decode(reader, reader.uint32()));
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      bondDid: (0, _helpers.isSet)(object.bondDid) ? String(object.bondDid) : "",
      order: (0, _helpers.isSet)(object.order) ? _bonds.BuyOrder.fromJSON(object.order) : undefined,
      chargedPrices: Array.isArray(object === null || object === void 0 ? void 0 : object.chargedPrices) ? object.chargedPrices.map(function (e) {
        return _coin.Coin.fromJSON(e);
      }) : [],
      chargedFees: Array.isArray(object === null || object === void 0 ? void 0 : object.chargedFees) ? object.chargedFees.map(function (e) {
        return _coin.Coin.fromJSON(e);
      }) : [],
      returnedToAddress: Array.isArray(object === null || object === void 0 ? void 0 : object.returnedToAddress) ? object.returnedToAddress.map(function (e) {
        return _coin.Coin.fromJSON(e);
      }) : [],
      newBondTokenBalance: (0, _helpers.isSet)(object.newBondTokenBalance) ? String(object.newBondTokenBalance) : "",
      chargedPricesOfWhichReserve: (0, _helpers.isSet)(object.chargedPricesOfWhichReserve) ? String(object.chargedPricesOfWhichReserve) : undefined,
      chargedPricesOfWhichFunding: Array.isArray(object === null || object === void 0 ? void 0 : object.chargedPricesOfWhichFunding) ? object.chargedPricesOfWhichFunding.map(function (e) {
        return _coin.Coin.fromJSON(e);
      }) : []
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    message.bondDid !== undefined && (obj.bondDid = message.bondDid);
    message.order !== undefined && (obj.order = message.order ? _bonds.BuyOrder.toJSON(message.order) : undefined);
    if (message.chargedPrices) {
      obj.chargedPrices = message.chargedPrices.map(function (e) {
        return e ? _coin.Coin.toJSON(e) : undefined;
      });
    } else {
      obj.chargedPrices = [];
    }
    if (message.chargedFees) {
      obj.chargedFees = message.chargedFees.map(function (e) {
        return e ? _coin.Coin.toJSON(e) : undefined;
      });
    } else {
      obj.chargedFees = [];
    }
    if (message.returnedToAddress) {
      obj.returnedToAddress = message.returnedToAddress.map(function (e) {
        return e ? _coin.Coin.toJSON(e) : undefined;
      });
    } else {
      obj.returnedToAddress = [];
    }
    message.newBondTokenBalance !== undefined && (obj.newBondTokenBalance = message.newBondTokenBalance);
    message.chargedPricesOfWhichReserve !== undefined && (obj.chargedPricesOfWhichReserve = message.chargedPricesOfWhichReserve);
    if (message.chargedPricesOfWhichFunding) {
      obj.chargedPricesOfWhichFunding = message.chargedPricesOfWhichFunding.map(function (e) {
        return e ? _coin.Coin.toJSON(e) : undefined;
      });
    } else {
      obj.chargedPricesOfWhichFunding = [];
    }
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var _object$bondDid0, _object$chargedPrices, _object$chargedFees, _object$returnedToAdd, _object$newBondTokenB, _object$chargedPrices2, _object$chargedPrices3;
    var message = createBaseBondBuyOrderFulfilledEvent();
    message.bondDid = (_object$bondDid0 = object.bondDid) !== null && _object$bondDid0 !== void 0 ? _object$bondDid0 : "";
    message.order = object.order !== undefined && object.order !== null ? _bonds.BuyOrder.fromPartial(object.order) : undefined;
    message.chargedPrices = ((_object$chargedPrices = object.chargedPrices) === null || _object$chargedPrices === void 0 ? void 0 : _object$chargedPrices.map(function (e) {
      return _coin.Coin.fromPartial(e);
    })) || [];
    message.chargedFees = ((_object$chargedFees = object.chargedFees) === null || _object$chargedFees === void 0 ? void 0 : _object$chargedFees.map(function (e) {
      return _coin.Coin.fromPartial(e);
    })) || [];
    message.returnedToAddress = ((_object$returnedToAdd = object.returnedToAddress) === null || _object$returnedToAdd === void 0 ? void 0 : _object$returnedToAdd.map(function (e) {
      return _coin.Coin.fromPartial(e);
    })) || [];
    message.newBondTokenBalance = (_object$newBondTokenB = object.newBondTokenBalance) !== null && _object$newBondTokenB !== void 0 ? _object$newBondTokenB : "";
    message.chargedPricesOfWhichReserve = (_object$chargedPrices2 = object.chargedPricesOfWhichReserve) !== null && _object$chargedPrices2 !== void 0 ? _object$chargedPrices2 : undefined;
    message.chargedPricesOfWhichFunding = ((_object$chargedPrices3 = object.chargedPricesOfWhichFunding) === null || _object$chargedPrices3 === void 0 ? void 0 : _object$chargedPrices3.map(function (e) {
      return _coin.Coin.fromPartial(e);
    })) || [];
    return message;
  }
};
function createBaseBondSellOrderFulfilledEvent() {
  return {
    bondDid: "",
    order: undefined,
    chargedFees: [],
    returnedToAddress: [],
    newBondTokenBalance: ""
  };
}
var BondSellOrderFulfilledEvent = exports.BondSellOrderFulfilledEvent = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.bondDid !== "") {
      writer.uint32(10).string(message.bondDid);
    }
    if (message.order !== undefined) {
      _bonds.SellOrder.encode(message.order, writer.uint32(18).fork()).ldelim();
    }
    var _iterator8 = _createForOfIteratorHelper(message.chargedFees),
      _step8;
    try {
      for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
        var v = _step8.value;
        _coin.Coin.encode(v, writer.uint32(26).fork()).ldelim();
      }
    } catch (err) {
      _iterator8.e(err);
    } finally {
      _iterator8.f();
    }
    var _iterator9 = _createForOfIteratorHelper(message.returnedToAddress),
      _step9;
    try {
      for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
        var _v4 = _step9.value;
        _coin.Coin.encode(_v4, writer.uint32(34).fork()).ldelim();
      }
    } catch (err) {
      _iterator9.e(err);
    } finally {
      _iterator9.f();
    }
    if (message.newBondTokenBalance !== "") {
      writer.uint32(42).string(message.newBondTokenBalance);
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseBondSellOrderFulfilledEvent();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.bondDid = reader.string();
          break;
        case 2:
          message.order = _bonds.SellOrder.decode(reader, reader.uint32());
          break;
        case 3:
          message.chargedFees.push(_coin.Coin.decode(reader, reader.uint32()));
          break;
        case 4:
          message.returnedToAddress.push(_coin.Coin.decode(reader, reader.uint32()));
          break;
        case 5:
          message.newBondTokenBalance = reader.string();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      bondDid: (0, _helpers.isSet)(object.bondDid) ? String(object.bondDid) : "",
      order: (0, _helpers.isSet)(object.order) ? _bonds.SellOrder.fromJSON(object.order) : undefined,
      chargedFees: Array.isArray(object === null || object === void 0 ? void 0 : object.chargedFees) ? object.chargedFees.map(function (e) {
        return _coin.Coin.fromJSON(e);
      }) : [],
      returnedToAddress: Array.isArray(object === null || object === void 0 ? void 0 : object.returnedToAddress) ? object.returnedToAddress.map(function (e) {
        return _coin.Coin.fromJSON(e);
      }) : [],
      newBondTokenBalance: (0, _helpers.isSet)(object.newBondTokenBalance) ? String(object.newBondTokenBalance) : ""
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    message.bondDid !== undefined && (obj.bondDid = message.bondDid);
    message.order !== undefined && (obj.order = message.order ? _bonds.SellOrder.toJSON(message.order) : undefined);
    if (message.chargedFees) {
      obj.chargedFees = message.chargedFees.map(function (e) {
        return e ? _coin.Coin.toJSON(e) : undefined;
      });
    } else {
      obj.chargedFees = [];
    }
    if (message.returnedToAddress) {
      obj.returnedToAddress = message.returnedToAddress.map(function (e) {
        return e ? _coin.Coin.toJSON(e) : undefined;
      });
    } else {
      obj.returnedToAddress = [];
    }
    message.newBondTokenBalance !== undefined && (obj.newBondTokenBalance = message.newBondTokenBalance);
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var _object$bondDid1, _object$chargedFees2, _object$returnedToAdd2, _object$newBondTokenB2;
    var message = createBaseBondSellOrderFulfilledEvent();
    message.bondDid = (_object$bondDid1 = object.bondDid) !== null && _object$bondDid1 !== void 0 ? _object$bondDid1 : "";
    message.order = object.order !== undefined && object.order !== null ? _bonds.SellOrder.fromPartial(object.order) : undefined;
    message.chargedFees = ((_object$chargedFees2 = object.chargedFees) === null || _object$chargedFees2 === void 0 ? void 0 : _object$chargedFees2.map(function (e) {
      return _coin.Coin.fromPartial(e);
    })) || [];
    message.returnedToAddress = ((_object$returnedToAdd2 = object.returnedToAddress) === null || _object$returnedToAdd2 === void 0 ? void 0 : _object$returnedToAdd2.map(function (e) {
      return _coin.Coin.fromPartial(e);
    })) || [];
    message.newBondTokenBalance = (_object$newBondTokenB2 = object.newBondTokenBalance) !== null && _object$newBondTokenB2 !== void 0 ? _object$newBondTokenB2 : "";
    return message;
  }
};
function createBaseBondSwapOrderFulfilledEvent() {
  return {
    bondDid: "",
    order: undefined,
    chargedFee: undefined,
    returnedToAddress: [],
    tokensSwapped: undefined
  };
}
var BondSwapOrderFulfilledEvent = exports.BondSwapOrderFulfilledEvent = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.bondDid !== "") {
      writer.uint32(10).string(message.bondDid);
    }
    if (message.order !== undefined) {
      _bonds.SwapOrder.encode(message.order, writer.uint32(18).fork()).ldelim();
    }
    if (message.chargedFee !== undefined) {
      _coin.Coin.encode(message.chargedFee, writer.uint32(26).fork()).ldelim();
    }
    var _iterator0 = _createForOfIteratorHelper(message.returnedToAddress),
      _step0;
    try {
      for (_iterator0.s(); !(_step0 = _iterator0.n()).done;) {
        var v = _step0.value;
        _coin.Coin.encode(v, writer.uint32(34).fork()).ldelim();
      }
    } catch (err) {
      _iterator0.e(err);
    } finally {
      _iterator0.f();
    }
    if (message.tokensSwapped !== undefined) {
      _coin.Coin.encode(message.tokensSwapped, writer.uint32(42).fork()).ldelim();
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseBondSwapOrderFulfilledEvent();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.bondDid = reader.string();
          break;
        case 2:
          message.order = _bonds.SwapOrder.decode(reader, reader.uint32());
          break;
        case 3:
          message.chargedFee = _coin.Coin.decode(reader, reader.uint32());
          break;
        case 4:
          message.returnedToAddress.push(_coin.Coin.decode(reader, reader.uint32()));
          break;
        case 5:
          message.tokensSwapped = _coin.Coin.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      bondDid: (0, _helpers.isSet)(object.bondDid) ? String(object.bondDid) : "",
      order: (0, _helpers.isSet)(object.order) ? _bonds.SwapOrder.fromJSON(object.order) : undefined,
      chargedFee: (0, _helpers.isSet)(object.chargedFee) ? _coin.Coin.fromJSON(object.chargedFee) : undefined,
      returnedToAddress: Array.isArray(object === null || object === void 0 ? void 0 : object.returnedToAddress) ? object.returnedToAddress.map(function (e) {
        return _coin.Coin.fromJSON(e);
      }) : [],
      tokensSwapped: (0, _helpers.isSet)(object.tokensSwapped) ? _coin.Coin.fromJSON(object.tokensSwapped) : undefined
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    message.bondDid !== undefined && (obj.bondDid = message.bondDid);
    message.order !== undefined && (obj.order = message.order ? _bonds.SwapOrder.toJSON(message.order) : undefined);
    message.chargedFee !== undefined && (obj.chargedFee = message.chargedFee ? _coin.Coin.toJSON(message.chargedFee) : undefined);
    if (message.returnedToAddress) {
      obj.returnedToAddress = message.returnedToAddress.map(function (e) {
        return e ? _coin.Coin.toJSON(e) : undefined;
      });
    } else {
      obj.returnedToAddress = [];
    }
    message.tokensSwapped !== undefined && (obj.tokensSwapped = message.tokensSwapped ? _coin.Coin.toJSON(message.tokensSwapped) : undefined);
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var _object$bondDid10, _object$returnedToAdd3;
    var message = createBaseBondSwapOrderFulfilledEvent();
    message.bondDid = (_object$bondDid10 = object.bondDid) !== null && _object$bondDid10 !== void 0 ? _object$bondDid10 : "";
    message.order = object.order !== undefined && object.order !== null ? _bonds.SwapOrder.fromPartial(object.order) : undefined;
    message.chargedFee = object.chargedFee !== undefined && object.chargedFee !== null ? _coin.Coin.fromPartial(object.chargedFee) : undefined;
    message.returnedToAddress = ((_object$returnedToAdd3 = object.returnedToAddress) === null || _object$returnedToAdd3 === void 0 ? void 0 : _object$returnedToAdd3.map(function (e) {
      return _coin.Coin.fromPartial(e);
    })) || [];
    message.tokensSwapped = object.tokensSwapped !== undefined && object.tokensSwapped !== null ? _coin.Coin.fromPartial(object.tokensSwapped) : undefined;
    return message;
  }
};
function createBaseBondBuyOrderCancelledEvent() {
  return {
    bondDid: "",
    order: undefined
  };
}
var BondBuyOrderCancelledEvent = exports.BondBuyOrderCancelledEvent = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.bondDid !== "") {
      writer.uint32(10).string(message.bondDid);
    }
    if (message.order !== undefined) {
      _bonds.BuyOrder.encode(message.order, writer.uint32(18).fork()).ldelim();
    }
    return writer;
  },
  decode: function decode(input, length) {
    var reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    var end = length === undefined ? reader.len : reader.pos + length;
    var message = createBaseBondBuyOrderCancelledEvent();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.bondDid = reader.string();
          break;
        case 2:
          message.order = _bonds.BuyOrder.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      bondDid: (0, _helpers.isSet)(object.bondDid) ? String(object.bondDid) : "",
      order: (0, _helpers.isSet)(object.order) ? _bonds.BuyOrder.fromJSON(object.order) : undefined
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    message.bondDid !== undefined && (obj.bondDid = message.bondDid);
    message.order !== undefined && (obj.order = message.order ? _bonds.BuyOrder.toJSON(message.order) : undefined);
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var _object$bondDid11;
    var message = createBaseBondBuyOrderCancelledEvent();
    message.bondDid = (_object$bondDid11 = object.bondDid) !== null && _object$bondDid11 !== void 0 ? _object$bondDid11 : "";
    message.order = object.order !== undefined && object.order !== null ? _bonds.BuyOrder.fromPartial(object.order) : undefined;
    return message;
  }
};