//@ts-nocheck
import { Bond, BuyOrder, SellOrder, SwapOrder } from "./bonds";
import { Coin } from "../../../cosmos/base/v1beta1/coin";
import * as _m0 from "protobufjs/minimal";
import { isSet } from "../../../helpers";
/** 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
  };
}
export const BondCreatedEvent = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.bond !== undefined) {
      Bond.encode(message.bond, writer.uint32(10).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 = createBaseBondCreatedEvent();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.bond = Bond.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      bond: isSet(object.bond) ? Bond.fromJSON(object.bond) : undefined
    };
  },
  toJSON(message) {
    const obj = {};
    message.bond !== undefined && (obj.bond = message.bond ? Bond.toJSON(message.bond) : undefined);
    return obj;
  },
  fromPartial(object) {
    const message = createBaseBondCreatedEvent();
    message.bond = object.bond !== undefined && object.bond !== null ? Bond.fromPartial(object.bond) : undefined;
    return message;
  }
};
function createBaseBondUpdatedEvent() {
  return {
    bond: undefined
  };
}
export const BondUpdatedEvent = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.bond !== undefined) {
      Bond.encode(message.bond, writer.uint32(10).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 = createBaseBondUpdatedEvent();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.bond = Bond.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      bond: isSet(object.bond) ? Bond.fromJSON(object.bond) : undefined
    };
  },
  toJSON(message) {
    const obj = {};
    message.bond !== undefined && (obj.bond = message.bond ? Bond.toJSON(message.bond) : undefined);
    return obj;
  },
  fromPartial(object) {
    const message = createBaseBondUpdatedEvent();
    message.bond = object.bond !== undefined && object.bond !== null ? Bond.fromPartial(object.bond) : undefined;
    return message;
  }
};
function createBaseBondSetNextAlphaEvent() {
  return {
    bondDid: "",
    nextAlpha: "",
    signer: ""
  };
}
export const BondSetNextAlphaEvent = {
  encode(message, writer = _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(input, length) {
    const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseBondSetNextAlphaEvent();
    while (reader.pos < end) {
      const 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(object) {
    return {
      bondDid: isSet(object.bondDid) ? String(object.bondDid) : "",
      nextAlpha: isSet(object.nextAlpha) ? String(object.nextAlpha) : "",
      signer: isSet(object.signer) ? String(object.signer) : ""
    };
  },
  toJSON(message) {
    const 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(object) {
    var _object$bondDid, _object$nextAlpha, _object$signer;
    const 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: ""
  };
}
export const BondBuyOrderEvent = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.order !== undefined) {
      BuyOrder.encode(message.order, writer.uint32(10).fork()).ldelim();
    }
    if (message.bondDid !== "") {
      writer.uint32(18).string(message.bondDid);
    }
    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 = createBaseBondBuyOrderEvent();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.order = BuyOrder.decode(reader, reader.uint32());
          break;
        case 2:
          message.bondDid = reader.string();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      order: isSet(object.order) ? BuyOrder.fromJSON(object.order) : undefined,
      bondDid: isSet(object.bondDid) ? String(object.bondDid) : ""
    };
  },
  toJSON(message) {
    const obj = {};
    message.order !== undefined && (obj.order = message.order ? BuyOrder.toJSON(message.order) : undefined);
    message.bondDid !== undefined && (obj.bondDid = message.bondDid);
    return obj;
  },
  fromPartial(object) {
    var _object$bondDid2;
    const message = createBaseBondBuyOrderEvent();
    message.order = object.order !== undefined && object.order !== null ? 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: ""
  };
}
export const BondSellOrderEvent = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.order !== undefined) {
      SellOrder.encode(message.order, writer.uint32(10).fork()).ldelim();
    }
    if (message.bondDid !== "") {
      writer.uint32(18).string(message.bondDid);
    }
    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 = createBaseBondSellOrderEvent();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.order = SellOrder.decode(reader, reader.uint32());
          break;
        case 2:
          message.bondDid = reader.string();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      order: isSet(object.order) ? SellOrder.fromJSON(object.order) : undefined,
      bondDid: isSet(object.bondDid) ? String(object.bondDid) : ""
    };
  },
  toJSON(message) {
    const obj = {};
    message.order !== undefined && (obj.order = message.order ? SellOrder.toJSON(message.order) : undefined);
    message.bondDid !== undefined && (obj.bondDid = message.bondDid);
    return obj;
  },
  fromPartial(object) {
    var _object$bondDid3;
    const message = createBaseBondSellOrderEvent();
    message.order = object.order !== undefined && object.order !== null ? 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: ""
  };
}
export const BondSwapOrderEvent = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.order !== undefined) {
      SwapOrder.encode(message.order, writer.uint32(10).fork()).ldelim();
    }
    if (message.bondDid !== "") {
      writer.uint32(18).string(message.bondDid);
    }
    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 = createBaseBondSwapOrderEvent();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.order = SwapOrder.decode(reader, reader.uint32());
          break;
        case 2:
          message.bondDid = reader.string();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      order: isSet(object.order) ? SwapOrder.fromJSON(object.order) : undefined,
      bondDid: isSet(object.bondDid) ? String(object.bondDid) : ""
    };
  },
  toJSON(message) {
    const obj = {};
    message.order !== undefined && (obj.order = message.order ? SwapOrder.toJSON(message.order) : undefined);
    message.bondDid !== undefined && (obj.bondDid = message.bondDid);
    return obj;
  },
  fromPartial(object) {
    var _object$bondDid4;
    const message = createBaseBondSwapOrderEvent();
    message.order = object.order !== undefined && object.order !== null ? 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: ""
  };
}
export const BondMakeOutcomePaymentEvent = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.bondDid !== "") {
      writer.uint32(10).string(message.bondDid);
    }
    for (const v of message.outcomePayment) {
      Coin.encode(v, writer.uint32(18).fork()).ldelim();
    }
    if (message.senderDid !== "") {
      writer.uint32(26).string(message.senderDid);
    }
    if (message.senderAddress !== "") {
      writer.uint32(34).string(message.senderAddress);
    }
    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 = createBaseBondMakeOutcomePaymentEvent();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.bondDid = reader.string();
          break;
        case 2:
          message.outcomePayment.push(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(object) {
    return {
      bondDid: isSet(object.bondDid) ? String(object.bondDid) : "",
      outcomePayment: Array.isArray(object === null || object === void 0 ? void 0 : object.outcomePayment) ? object.outcomePayment.map(e => Coin.fromJSON(e)) : [],
      senderDid: isSet(object.senderDid) ? String(object.senderDid) : "",
      senderAddress: isSet(object.senderAddress) ? String(object.senderAddress) : ""
    };
  },
  toJSON(message) {
    const obj = {};
    message.bondDid !== undefined && (obj.bondDid = message.bondDid);
    if (message.outcomePayment) {
      obj.outcomePayment = message.outcomePayment.map(e => e ? Coin.toJSON(e) : undefined);
    } else {
      obj.outcomePayment = [];
    }
    message.senderDid !== undefined && (obj.senderDid = message.senderDid);
    message.senderAddress !== undefined && (obj.senderAddress = message.senderAddress);
    return obj;
  },
  fromPartial(object) {
    var _object$bondDid5, _object$outcomePaymen, _object$senderDid, _object$senderAddress;
    const 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(e => 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: ""
  };
}
export const BondWithdrawShareEvent = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.bondDid !== "") {
      writer.uint32(10).string(message.bondDid);
    }
    for (const v of message.withdrawPayment) {
      Coin.encode(v, writer.uint32(18).fork()).ldelim();
    }
    if (message.recipientDid !== "") {
      writer.uint32(26).string(message.recipientDid);
    }
    if (message.recipientAddress !== "") {
      writer.uint32(34).string(message.recipientAddress);
    }
    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 = createBaseBondWithdrawShareEvent();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.bondDid = reader.string();
          break;
        case 2:
          message.withdrawPayment.push(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(object) {
    return {
      bondDid: isSet(object.bondDid) ? String(object.bondDid) : "",
      withdrawPayment: Array.isArray(object === null || object === void 0 ? void 0 : object.withdrawPayment) ? object.withdrawPayment.map(e => Coin.fromJSON(e)) : [],
      recipientDid: isSet(object.recipientDid) ? String(object.recipientDid) : "",
      recipientAddress: isSet(object.recipientAddress) ? String(object.recipientAddress) : ""
    };
  },
  toJSON(message) {
    const obj = {};
    message.bondDid !== undefined && (obj.bondDid = message.bondDid);
    if (message.withdrawPayment) {
      obj.withdrawPayment = message.withdrawPayment.map(e => e ? Coin.toJSON(e) : undefined);
    } else {
      obj.withdrawPayment = [];
    }
    message.recipientDid !== undefined && (obj.recipientDid = message.recipientDid);
    message.recipientAddress !== undefined && (obj.recipientAddress = message.recipientAddress);
    return obj;
  },
  fromPartial(object) {
    var _object$bondDid6, _object$withdrawPayme, _object$recipientDid, _object$recipientAddr;
    const 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(e => 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: ""
  };
}
export const BondWithdrawReserveEvent = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.bondDid !== "") {
      writer.uint32(10).string(message.bondDid);
    }
    for (const v of message.withdrawAmount) {
      Coin.encode(v, writer.uint32(18).fork()).ldelim();
    }
    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(input, length) {
    const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseBondWithdrawReserveEvent();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.bondDid = reader.string();
          break;
        case 2:
          message.withdrawAmount.push(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(object) {
    return {
      bondDid: isSet(object.bondDid) ? String(object.bondDid) : "",
      withdrawAmount: Array.isArray(object === null || object === void 0 ? void 0 : object.withdrawAmount) ? object.withdrawAmount.map(e => Coin.fromJSON(e)) : [],
      withdrawerDid: isSet(object.withdrawerDid) ? String(object.withdrawerDid) : "",
      withdrawerAddress: isSet(object.withdrawerAddress) ? String(object.withdrawerAddress) : "",
      reserveWithdrawalAddress: isSet(object.reserveWithdrawalAddress) ? String(object.reserveWithdrawalAddress) : ""
    };
  },
  toJSON(message) {
    const obj = {};
    message.bondDid !== undefined && (obj.bondDid = message.bondDid);
    if (message.withdrawAmount) {
      obj.withdrawAmount = message.withdrawAmount.map(e => e ? 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(object) {
    var _object$bondDid7, _object$withdrawAmoun, _object$withdrawerDid, _object$withdrawerAdd, _object$reserveWithdr;
    const 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(e => 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: ""
  };
}
export const BondEditAlphaSuccessEvent = {
  encode(message, writer = _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(input, length) {
    const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseBondEditAlphaSuccessEvent();
    while (reader.pos < end) {
      const 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(object) {
    return {
      bondDid: isSet(object.bondDid) ? String(object.bondDid) : "",
      token: isSet(object.token) ? String(object.token) : "",
      publicAlpha: isSet(object.publicAlpha) ? String(object.publicAlpha) : "",
      systemAlpha: isSet(object.systemAlpha) ? String(object.systemAlpha) : ""
    };
  },
  toJSON(message) {
    const 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(object) {
    var _object$bondDid8, _object$token, _object$publicAlpha, _object$systemAlpha;
    const 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: ""
  };
}
export const BondEditAlphaFailedEvent = {
  encode(message, writer = _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(input, length) {
    const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseBondEditAlphaFailedEvent();
    while (reader.pos < end) {
      const 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(object) {
    return {
      bondDid: isSet(object.bondDid) ? String(object.bondDid) : "",
      token: isSet(object.token) ? String(object.token) : "",
      cancelReason: isSet(object.cancelReason) ? String(object.cancelReason) : ""
    };
  },
  toJSON(message) {
    const 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(object) {
    var _object$bondDid9, _object$token2, _object$cancelReason;
    const 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: []
  };
}
export const BondBuyOrderFulfilledEvent = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.bondDid !== "") {
      writer.uint32(10).string(message.bondDid);
    }
    if (message.order !== undefined) {
      BuyOrder.encode(message.order, writer.uint32(18).fork()).ldelim();
    }
    for (const v of message.chargedPrices) {
      Coin.encode(v, writer.uint32(26).fork()).ldelim();
    }
    for (const v of message.chargedFees) {
      Coin.encode(v, writer.uint32(34).fork()).ldelim();
    }
    for (const v of message.returnedToAddress) {
      Coin.encode(v, writer.uint32(42).fork()).ldelim();
    }
    if (message.newBondTokenBalance !== "") {
      writer.uint32(50).string(message.newBondTokenBalance);
    }
    if (message.chargedPricesOfWhichReserve !== undefined) {
      writer.uint32(58).string(message.chargedPricesOfWhichReserve);
    }
    for (const v of message.chargedPricesOfWhichFunding) {
      Coin.encode(v, writer.uint32(66).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 = createBaseBondBuyOrderFulfilledEvent();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.bondDid = reader.string();
          break;
        case 2:
          message.order = BuyOrder.decode(reader, reader.uint32());
          break;
        case 3:
          message.chargedPrices.push(Coin.decode(reader, reader.uint32()));
          break;
        case 4:
          message.chargedFees.push(Coin.decode(reader, reader.uint32()));
          break;
        case 5:
          message.returnedToAddress.push(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.decode(reader, reader.uint32()));
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      bondDid: isSet(object.bondDid) ? String(object.bondDid) : "",
      order: isSet(object.order) ? BuyOrder.fromJSON(object.order) : undefined,
      chargedPrices: Array.isArray(object === null || object === void 0 ? void 0 : object.chargedPrices) ? object.chargedPrices.map(e => Coin.fromJSON(e)) : [],
      chargedFees: Array.isArray(object === null || object === void 0 ? void 0 : object.chargedFees) ? object.chargedFees.map(e => Coin.fromJSON(e)) : [],
      returnedToAddress: Array.isArray(object === null || object === void 0 ? void 0 : object.returnedToAddress) ? object.returnedToAddress.map(e => Coin.fromJSON(e)) : [],
      newBondTokenBalance: isSet(object.newBondTokenBalance) ? String(object.newBondTokenBalance) : "",
      chargedPricesOfWhichReserve: isSet(object.chargedPricesOfWhichReserve) ? String(object.chargedPricesOfWhichReserve) : undefined,
      chargedPricesOfWhichFunding: Array.isArray(object === null || object === void 0 ? void 0 : object.chargedPricesOfWhichFunding) ? object.chargedPricesOfWhichFunding.map(e => Coin.fromJSON(e)) : []
    };
  },
  toJSON(message) {
    const obj = {};
    message.bondDid !== undefined && (obj.bondDid = message.bondDid);
    message.order !== undefined && (obj.order = message.order ? BuyOrder.toJSON(message.order) : undefined);
    if (message.chargedPrices) {
      obj.chargedPrices = message.chargedPrices.map(e => e ? Coin.toJSON(e) : undefined);
    } else {
      obj.chargedPrices = [];
    }
    if (message.chargedFees) {
      obj.chargedFees = message.chargedFees.map(e => e ? Coin.toJSON(e) : undefined);
    } else {
      obj.chargedFees = [];
    }
    if (message.returnedToAddress) {
      obj.returnedToAddress = message.returnedToAddress.map(e => e ? 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(e => e ? Coin.toJSON(e) : undefined);
    } else {
      obj.chargedPricesOfWhichFunding = [];
    }
    return obj;
  },
  fromPartial(object) {
    var _object$bondDid0, _object$chargedPrices, _object$chargedFees, _object$returnedToAdd, _object$newBondTokenB, _object$chargedPrices2, _object$chargedPrices3;
    const message = createBaseBondBuyOrderFulfilledEvent();
    message.bondDid = (_object$bondDid0 = object.bondDid) !== null && _object$bondDid0 !== void 0 ? _object$bondDid0 : "";
    message.order = object.order !== undefined && object.order !== null ? BuyOrder.fromPartial(object.order) : undefined;
    message.chargedPrices = ((_object$chargedPrices = object.chargedPrices) === null || _object$chargedPrices === void 0 ? void 0 : _object$chargedPrices.map(e => Coin.fromPartial(e))) || [];
    message.chargedFees = ((_object$chargedFees = object.chargedFees) === null || _object$chargedFees === void 0 ? void 0 : _object$chargedFees.map(e => Coin.fromPartial(e))) || [];
    message.returnedToAddress = ((_object$returnedToAdd = object.returnedToAddress) === null || _object$returnedToAdd === void 0 ? void 0 : _object$returnedToAdd.map(e => 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(e => Coin.fromPartial(e))) || [];
    return message;
  }
};
function createBaseBondSellOrderFulfilledEvent() {
  return {
    bondDid: "",
    order: undefined,
    chargedFees: [],
    returnedToAddress: [],
    newBondTokenBalance: ""
  };
}
export const BondSellOrderFulfilledEvent = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.bondDid !== "") {
      writer.uint32(10).string(message.bondDid);
    }
    if (message.order !== undefined) {
      SellOrder.encode(message.order, writer.uint32(18).fork()).ldelim();
    }
    for (const v of message.chargedFees) {
      Coin.encode(v, writer.uint32(26).fork()).ldelim();
    }
    for (const v of message.returnedToAddress) {
      Coin.encode(v, writer.uint32(34).fork()).ldelim();
    }
    if (message.newBondTokenBalance !== "") {
      writer.uint32(42).string(message.newBondTokenBalance);
    }
    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 = createBaseBondSellOrderFulfilledEvent();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.bondDid = reader.string();
          break;
        case 2:
          message.order = SellOrder.decode(reader, reader.uint32());
          break;
        case 3:
          message.chargedFees.push(Coin.decode(reader, reader.uint32()));
          break;
        case 4:
          message.returnedToAddress.push(Coin.decode(reader, reader.uint32()));
          break;
        case 5:
          message.newBondTokenBalance = reader.string();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      bondDid: isSet(object.bondDid) ? String(object.bondDid) : "",
      order: isSet(object.order) ? SellOrder.fromJSON(object.order) : undefined,
      chargedFees: Array.isArray(object === null || object === void 0 ? void 0 : object.chargedFees) ? object.chargedFees.map(e => Coin.fromJSON(e)) : [],
      returnedToAddress: Array.isArray(object === null || object === void 0 ? void 0 : object.returnedToAddress) ? object.returnedToAddress.map(e => Coin.fromJSON(e)) : [],
      newBondTokenBalance: isSet(object.newBondTokenBalance) ? String(object.newBondTokenBalance) : ""
    };
  },
  toJSON(message) {
    const obj = {};
    message.bondDid !== undefined && (obj.bondDid = message.bondDid);
    message.order !== undefined && (obj.order = message.order ? SellOrder.toJSON(message.order) : undefined);
    if (message.chargedFees) {
      obj.chargedFees = message.chargedFees.map(e => e ? Coin.toJSON(e) : undefined);
    } else {
      obj.chargedFees = [];
    }
    if (message.returnedToAddress) {
      obj.returnedToAddress = message.returnedToAddress.map(e => e ? Coin.toJSON(e) : undefined);
    } else {
      obj.returnedToAddress = [];
    }
    message.newBondTokenBalance !== undefined && (obj.newBondTokenBalance = message.newBondTokenBalance);
    return obj;
  },
  fromPartial(object) {
    var _object$bondDid1, _object$chargedFees2, _object$returnedToAdd2, _object$newBondTokenB2;
    const message = createBaseBondSellOrderFulfilledEvent();
    message.bondDid = (_object$bondDid1 = object.bondDid) !== null && _object$bondDid1 !== void 0 ? _object$bondDid1 : "";
    message.order = object.order !== undefined && object.order !== null ? SellOrder.fromPartial(object.order) : undefined;
    message.chargedFees = ((_object$chargedFees2 = object.chargedFees) === null || _object$chargedFees2 === void 0 ? void 0 : _object$chargedFees2.map(e => Coin.fromPartial(e))) || [];
    message.returnedToAddress = ((_object$returnedToAdd2 = object.returnedToAddress) === null || _object$returnedToAdd2 === void 0 ? void 0 : _object$returnedToAdd2.map(e => 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
  };
}
export const BondSwapOrderFulfilledEvent = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.bondDid !== "") {
      writer.uint32(10).string(message.bondDid);
    }
    if (message.order !== undefined) {
      SwapOrder.encode(message.order, writer.uint32(18).fork()).ldelim();
    }
    if (message.chargedFee !== undefined) {
      Coin.encode(message.chargedFee, writer.uint32(26).fork()).ldelim();
    }
    for (const v of message.returnedToAddress) {
      Coin.encode(v, writer.uint32(34).fork()).ldelim();
    }
    if (message.tokensSwapped !== undefined) {
      Coin.encode(message.tokensSwapped, writer.uint32(42).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 = createBaseBondSwapOrderFulfilledEvent();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.bondDid = reader.string();
          break;
        case 2:
          message.order = SwapOrder.decode(reader, reader.uint32());
          break;
        case 3:
          message.chargedFee = Coin.decode(reader, reader.uint32());
          break;
        case 4:
          message.returnedToAddress.push(Coin.decode(reader, reader.uint32()));
          break;
        case 5:
          message.tokensSwapped = Coin.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      bondDid: isSet(object.bondDid) ? String(object.bondDid) : "",
      order: isSet(object.order) ? SwapOrder.fromJSON(object.order) : undefined,
      chargedFee: isSet(object.chargedFee) ? Coin.fromJSON(object.chargedFee) : undefined,
      returnedToAddress: Array.isArray(object === null || object === void 0 ? void 0 : object.returnedToAddress) ? object.returnedToAddress.map(e => Coin.fromJSON(e)) : [],
      tokensSwapped: isSet(object.tokensSwapped) ? Coin.fromJSON(object.tokensSwapped) : undefined
    };
  },
  toJSON(message) {
    const obj = {};
    message.bondDid !== undefined && (obj.bondDid = message.bondDid);
    message.order !== undefined && (obj.order = message.order ? SwapOrder.toJSON(message.order) : undefined);
    message.chargedFee !== undefined && (obj.chargedFee = message.chargedFee ? Coin.toJSON(message.chargedFee) : undefined);
    if (message.returnedToAddress) {
      obj.returnedToAddress = message.returnedToAddress.map(e => e ? Coin.toJSON(e) : undefined);
    } else {
      obj.returnedToAddress = [];
    }
    message.tokensSwapped !== undefined && (obj.tokensSwapped = message.tokensSwapped ? Coin.toJSON(message.tokensSwapped) : undefined);
    return obj;
  },
  fromPartial(object) {
    var _object$bondDid10, _object$returnedToAdd3;
    const message = createBaseBondSwapOrderFulfilledEvent();
    message.bondDid = (_object$bondDid10 = object.bondDid) !== null && _object$bondDid10 !== void 0 ? _object$bondDid10 : "";
    message.order = object.order !== undefined && object.order !== null ? SwapOrder.fromPartial(object.order) : undefined;
    message.chargedFee = object.chargedFee !== undefined && object.chargedFee !== null ? Coin.fromPartial(object.chargedFee) : undefined;
    message.returnedToAddress = ((_object$returnedToAdd3 = object.returnedToAddress) === null || _object$returnedToAdd3 === void 0 ? void 0 : _object$returnedToAdd3.map(e => Coin.fromPartial(e))) || [];
    message.tokensSwapped = object.tokensSwapped !== undefined && object.tokensSwapped !== null ? Coin.fromPartial(object.tokensSwapped) : undefined;
    return message;
  }
};
function createBaseBondBuyOrderCancelledEvent() {
  return {
    bondDid: "",
    order: undefined
  };
}
export const BondBuyOrderCancelledEvent = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.bondDid !== "") {
      writer.uint32(10).string(message.bondDid);
    }
    if (message.order !== undefined) {
      BuyOrder.encode(message.order, writer.uint32(18).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 = createBaseBondBuyOrderCancelledEvent();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.bondDid = reader.string();
          break;
        case 2:
          message.order = BuyOrder.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      bondDid: isSet(object.bondDid) ? String(object.bondDid) : "",
      order: isSet(object.order) ? BuyOrder.fromJSON(object.order) : undefined
    };
  },
  toJSON(message) {
    const obj = {};
    message.bondDid !== undefined && (obj.bondDid = message.bondDid);
    message.order !== undefined && (obj.order = message.order ? BuyOrder.toJSON(message.order) : undefined);
    return obj;
  },
  fromPartial(object) {
    var _object$bondDid11;
    const message = createBaseBondBuyOrderCancelledEvent();
    message.bondDid = (_object$bondDid11 = object.bondDid) !== null && _object$bondDid11 !== void 0 ? _object$bondDid11 : "";
    message.order = object.order !== undefined && object.order !== null ? BuyOrder.fromPartial(object.order) : undefined;
    return message;
  }
};