//@ts-nocheck
import { Token, TokenProperties } from "./token";
import { TokenBatch } from "./tx";
import * as _m0 from "protobufjs/minimal";
import { isSet } from "../../../helpers";
/** TokenCreatedEvent is an event triggered on a Token creation */

/** TokenCreatedEvent is an event triggered on a Token creation */

/** TokenUpdatedEvent is an event triggered on a Token update */

/** TokenUpdatedEvent is an event triggered on a Token update */

/** TokenMintedEvent is an event triggered on a Token mint execution */

/** TokenMintedEvent is an event triggered on a Token mint execution */

/** TokenTransferedEvent is an event triggered on a Token transfer execution */

/** TokenTransferedEvent is an event triggered on a Token transfer execution */

/** TokenCancelledEvent is an event triggered on a Token cancel execution */

/** TokenCancelledEvent is an event triggered on a Token cancel execution */

/** TokenRetiredEvent is an event triggered on a Token retire execution */

/** TokenRetiredEvent is an event triggered on a Token retire execution */

/**
 * CreditsTransferredEvent is an event triggered on a Credit transfer
 * execution
 */

/**
 * CreditsTransferredEvent is an event triggered on a Credit transfer
 * execution
 */

/** TokenPausedEvent is an event triggered on a Token pause/unpause execution */

/** TokenPausedEvent is an event triggered on a Token pause/unpause execution */

/** TokenStoppedEvent is an event triggered on a Token stopped execution */

/** TokenStoppedEvent is an event triggered on a Token stopped execution */

function createBaseTokenCreatedEvent() {
  return {
    token: undefined
  };
}
export const TokenCreatedEvent = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.token !== undefined) {
      Token.encode(message.token, 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 = createBaseTokenCreatedEvent();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.token = Token.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      token: isSet(object.token) ? Token.fromJSON(object.token) : undefined
    };
  },
  toJSON(message) {
    const obj = {};
    message.token !== undefined && (obj.token = message.token ? Token.toJSON(message.token) : undefined);
    return obj;
  },
  fromPartial(object) {
    const message = createBaseTokenCreatedEvent();
    message.token = object.token !== undefined && object.token !== null ? Token.fromPartial(object.token) : undefined;
    return message;
  }
};
function createBaseTokenUpdatedEvent() {
  return {
    token: undefined
  };
}
export const TokenUpdatedEvent = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.token !== undefined) {
      Token.encode(message.token, 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 = createBaseTokenUpdatedEvent();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.token = Token.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      token: isSet(object.token) ? Token.fromJSON(object.token) : undefined
    };
  },
  toJSON(message) {
    const obj = {};
    message.token !== undefined && (obj.token = message.token ? Token.toJSON(message.token) : undefined);
    return obj;
  },
  fromPartial(object) {
    const message = createBaseTokenUpdatedEvent();
    message.token = object.token !== undefined && object.token !== null ? Token.fromPartial(object.token) : undefined;
    return message;
  }
};
function createBaseTokenMintedEvent() {
  return {
    contractAddress: "",
    minter: "",
    owner: "",
    amount: "",
    tokenProperties: undefined
  };
}
export const TokenMintedEvent = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.contractAddress !== "") {
      writer.uint32(10).string(message.contractAddress);
    }
    if (message.minter !== "") {
      writer.uint32(18).string(message.minter);
    }
    if (message.owner !== "") {
      writer.uint32(26).string(message.owner);
    }
    if (message.amount !== "") {
      writer.uint32(34).string(message.amount);
    }
    if (message.tokenProperties !== undefined) {
      TokenProperties.encode(message.tokenProperties, 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 = createBaseTokenMintedEvent();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.contractAddress = reader.string();
          break;
        case 2:
          message.minter = reader.string();
          break;
        case 3:
          message.owner = reader.string();
          break;
        case 4:
          message.amount = reader.string();
          break;
        case 5:
          message.tokenProperties = TokenProperties.decode(reader, reader.uint32());
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      contractAddress: isSet(object.contractAddress) ? String(object.contractAddress) : "",
      minter: isSet(object.minter) ? String(object.minter) : "",
      owner: isSet(object.owner) ? String(object.owner) : "",
      amount: isSet(object.amount) ? String(object.amount) : "",
      tokenProperties: isSet(object.tokenProperties) ? TokenProperties.fromJSON(object.tokenProperties) : undefined
    };
  },
  toJSON(message) {
    const obj = {};
    message.contractAddress !== undefined && (obj.contractAddress = message.contractAddress);
    message.minter !== undefined && (obj.minter = message.minter);
    message.owner !== undefined && (obj.owner = message.owner);
    message.amount !== undefined && (obj.amount = message.amount);
    message.tokenProperties !== undefined && (obj.tokenProperties = message.tokenProperties ? TokenProperties.toJSON(message.tokenProperties) : undefined);
    return obj;
  },
  fromPartial(object) {
    var _object$contractAddre, _object$minter, _object$owner, _object$amount;
    const message = createBaseTokenMintedEvent();
    message.contractAddress = (_object$contractAddre = object.contractAddress) !== null && _object$contractAddre !== void 0 ? _object$contractAddre : "";
    message.minter = (_object$minter = object.minter) !== null && _object$minter !== void 0 ? _object$minter : "";
    message.owner = (_object$owner = object.owner) !== null && _object$owner !== void 0 ? _object$owner : "";
    message.amount = (_object$amount = object.amount) !== null && _object$amount !== void 0 ? _object$amount : "";
    message.tokenProperties = object.tokenProperties !== undefined && object.tokenProperties !== null ? TokenProperties.fromPartial(object.tokenProperties) : undefined;
    return message;
  }
};
function createBaseTokenTransferredEvent() {
  return {
    owner: "",
    recipient: "",
    tokens: []
  };
}
export const TokenTransferredEvent = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.owner !== "") {
      writer.uint32(10).string(message.owner);
    }
    if (message.recipient !== "") {
      writer.uint32(18).string(message.recipient);
    }
    for (const v of message.tokens) {
      TokenBatch.encode(v, writer.uint32(26).fork()).ldelim();
    }
    return writer;
  },
  decode(input, length) {
    const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
    let end = length === undefined ? reader.len : reader.pos + length;
    const message = createBaseTokenTransferredEvent();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.owner = reader.string();
          break;
        case 2:
          message.recipient = reader.string();
          break;
        case 3:
          message.tokens.push(TokenBatch.decode(reader, reader.uint32()));
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      owner: isSet(object.owner) ? String(object.owner) : "",
      recipient: isSet(object.recipient) ? String(object.recipient) : "",
      tokens: Array.isArray(object === null || object === void 0 ? void 0 : object.tokens) ? object.tokens.map(e => TokenBatch.fromJSON(e)) : []
    };
  },
  toJSON(message) {
    const obj = {};
    message.owner !== undefined && (obj.owner = message.owner);
    message.recipient !== undefined && (obj.recipient = message.recipient);
    if (message.tokens) {
      obj.tokens = message.tokens.map(e => e ? TokenBatch.toJSON(e) : undefined);
    } else {
      obj.tokens = [];
    }
    return obj;
  },
  fromPartial(object) {
    var _object$owner2, _object$recipient, _object$tokens;
    const message = createBaseTokenTransferredEvent();
    message.owner = (_object$owner2 = object.owner) !== null && _object$owner2 !== void 0 ? _object$owner2 : "";
    message.recipient = (_object$recipient = object.recipient) !== null && _object$recipient !== void 0 ? _object$recipient : "";
    message.tokens = ((_object$tokens = object.tokens) === null || _object$tokens === void 0 ? void 0 : _object$tokens.map(e => TokenBatch.fromPartial(e))) || [];
    return message;
  }
};
function createBaseTokenCancelledEvent() {
  return {
    owner: "",
    tokens: []
  };
}
export const TokenCancelledEvent = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.owner !== "") {
      writer.uint32(10).string(message.owner);
    }
    for (const v of message.tokens) {
      TokenBatch.encode(v, 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 = createBaseTokenCancelledEvent();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.owner = reader.string();
          break;
        case 2:
          message.tokens.push(TokenBatch.decode(reader, reader.uint32()));
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      owner: isSet(object.owner) ? String(object.owner) : "",
      tokens: Array.isArray(object === null || object === void 0 ? void 0 : object.tokens) ? object.tokens.map(e => TokenBatch.fromJSON(e)) : []
    };
  },
  toJSON(message) {
    const obj = {};
    message.owner !== undefined && (obj.owner = message.owner);
    if (message.tokens) {
      obj.tokens = message.tokens.map(e => e ? TokenBatch.toJSON(e) : undefined);
    } else {
      obj.tokens = [];
    }
    return obj;
  },
  fromPartial(object) {
    var _object$owner3, _object$tokens2;
    const message = createBaseTokenCancelledEvent();
    message.owner = (_object$owner3 = object.owner) !== null && _object$owner3 !== void 0 ? _object$owner3 : "";
    message.tokens = ((_object$tokens2 = object.tokens) === null || _object$tokens2 === void 0 ? void 0 : _object$tokens2.map(e => TokenBatch.fromPartial(e))) || [];
    return message;
  }
};
function createBaseTokenRetiredEvent() {
  return {
    owner: "",
    tokens: []
  };
}
export const TokenRetiredEvent = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.owner !== "") {
      writer.uint32(10).string(message.owner);
    }
    for (const v of message.tokens) {
      TokenBatch.encode(v, 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 = createBaseTokenRetiredEvent();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.owner = reader.string();
          break;
        case 2:
          message.tokens.push(TokenBatch.decode(reader, reader.uint32()));
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      owner: isSet(object.owner) ? String(object.owner) : "",
      tokens: Array.isArray(object === null || object === void 0 ? void 0 : object.tokens) ? object.tokens.map(e => TokenBatch.fromJSON(e)) : []
    };
  },
  toJSON(message) {
    const obj = {};
    message.owner !== undefined && (obj.owner = message.owner);
    if (message.tokens) {
      obj.tokens = message.tokens.map(e => e ? TokenBatch.toJSON(e) : undefined);
    } else {
      obj.tokens = [];
    }
    return obj;
  },
  fromPartial(object) {
    var _object$owner4, _object$tokens3;
    const message = createBaseTokenRetiredEvent();
    message.owner = (_object$owner4 = object.owner) !== null && _object$owner4 !== void 0 ? _object$owner4 : "";
    message.tokens = ((_object$tokens3 = object.tokens) === null || _object$tokens3 === void 0 ? void 0 : _object$tokens3.map(e => TokenBatch.fromPartial(e))) || [];
    return message;
  }
};
function createBaseCreditsTransferredEvent() {
  return {
    owner: "",
    tokens: []
  };
}
export const CreditsTransferredEvent = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.owner !== "") {
      writer.uint32(10).string(message.owner);
    }
    for (const v of message.tokens) {
      TokenBatch.encode(v, 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 = createBaseCreditsTransferredEvent();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.owner = reader.string();
          break;
        case 2:
          message.tokens.push(TokenBatch.decode(reader, reader.uint32()));
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      owner: isSet(object.owner) ? String(object.owner) : "",
      tokens: Array.isArray(object === null || object === void 0 ? void 0 : object.tokens) ? object.tokens.map(e => TokenBatch.fromJSON(e)) : []
    };
  },
  toJSON(message) {
    const obj = {};
    message.owner !== undefined && (obj.owner = message.owner);
    if (message.tokens) {
      obj.tokens = message.tokens.map(e => e ? TokenBatch.toJSON(e) : undefined);
    } else {
      obj.tokens = [];
    }
    return obj;
  },
  fromPartial(object) {
    var _object$owner5, _object$tokens4;
    const message = createBaseCreditsTransferredEvent();
    message.owner = (_object$owner5 = object.owner) !== null && _object$owner5 !== void 0 ? _object$owner5 : "";
    message.tokens = ((_object$tokens4 = object.tokens) === null || _object$tokens4 === void 0 ? void 0 : _object$tokens4.map(e => TokenBatch.fromPartial(e))) || [];
    return message;
  }
};
function createBaseTokenPausedEvent() {
  return {
    minter: "",
    contractAddress: "",
    paused: false
  };
}
export const TokenPausedEvent = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.minter !== "") {
      writer.uint32(10).string(message.minter);
    }
    if (message.contractAddress !== "") {
      writer.uint32(18).string(message.contractAddress);
    }
    if (message.paused === true) {
      writer.uint32(24).bool(message.paused);
    }
    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 = createBaseTokenPausedEvent();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.minter = reader.string();
          break;
        case 2:
          message.contractAddress = reader.string();
          break;
        case 3:
          message.paused = reader.bool();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      minter: isSet(object.minter) ? String(object.minter) : "",
      contractAddress: isSet(object.contractAddress) ? String(object.contractAddress) : "",
      paused: isSet(object.paused) ? Boolean(object.paused) : false
    };
  },
  toJSON(message) {
    const obj = {};
    message.minter !== undefined && (obj.minter = message.minter);
    message.contractAddress !== undefined && (obj.contractAddress = message.contractAddress);
    message.paused !== undefined && (obj.paused = message.paused);
    return obj;
  },
  fromPartial(object) {
    var _object$minter2, _object$contractAddre2, _object$paused;
    const message = createBaseTokenPausedEvent();
    message.minter = (_object$minter2 = object.minter) !== null && _object$minter2 !== void 0 ? _object$minter2 : "";
    message.contractAddress = (_object$contractAddre2 = object.contractAddress) !== null && _object$contractAddre2 !== void 0 ? _object$contractAddre2 : "";
    message.paused = (_object$paused = object.paused) !== null && _object$paused !== void 0 ? _object$paused : false;
    return message;
  }
};
function createBaseTokenStoppedEvent() {
  return {
    minter: "",
    contractAddress: "",
    stopped: false
  };
}
export const TokenStoppedEvent = {
  encode(message, writer = _m0.Writer.create()) {
    if (message.minter !== "") {
      writer.uint32(10).string(message.minter);
    }
    if (message.contractAddress !== "") {
      writer.uint32(18).string(message.contractAddress);
    }
    if (message.stopped === true) {
      writer.uint32(24).bool(message.stopped);
    }
    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 = createBaseTokenStoppedEvent();
    while (reader.pos < end) {
      const tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.minter = reader.string();
          break;
        case 2:
          message.contractAddress = reader.string();
          break;
        case 3:
          message.stopped = reader.bool();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON(object) {
    return {
      minter: isSet(object.minter) ? String(object.minter) : "",
      contractAddress: isSet(object.contractAddress) ? String(object.contractAddress) : "",
      stopped: isSet(object.stopped) ? Boolean(object.stopped) : false
    };
  },
  toJSON(message) {
    const obj = {};
    message.minter !== undefined && (obj.minter = message.minter);
    message.contractAddress !== undefined && (obj.contractAddress = message.contractAddress);
    message.stopped !== undefined && (obj.stopped = message.stopped);
    return obj;
  },
  fromPartial(object) {
    var _object$minter3, _object$contractAddre3, _object$stopped;
    const message = createBaseTokenStoppedEvent();
    message.minter = (_object$minter3 = object.minter) !== null && _object$minter3 !== void 0 ? _object$minter3 : "";
    message.contractAddress = (_object$contractAddre3 = object.contractAddress) !== null && _object$contractAddre3 !== void 0 ? _object$contractAddre3 : "";
    message.stopped = (_object$stopped = object.stopped) !== null && _object$stopped !== void 0 ? _object$stopped : false;
    return message;
  }
};