"use strict";

var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.InterchainAccount = void 0;
var _auth = require("../../../../cosmos/auth/v1beta1/auth");
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); }
//@ts-nocheck

/** An InterchainAccount is defined as a BaseAccount & the address of the account owner on the controller chain */

/** An InterchainAccount is defined as a BaseAccount & the address of the account owner on the controller chain */

function createBaseInterchainAccount() {
  return {
    baseAccount: undefined,
    accountOwner: ""
  };
}
var InterchainAccount = exports.InterchainAccount = {
  encode: function encode(message) {
    var writer = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _m0.Writer.create();
    if (message.baseAccount !== undefined) {
      _auth.BaseAccount.encode(message.baseAccount, writer.uint32(10).fork()).ldelim();
    }
    if (message.accountOwner !== "") {
      writer.uint32(18).string(message.accountOwner);
    }
    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 = createBaseInterchainAccount();
    while (reader.pos < end) {
      var tag = reader.uint32();
      switch (tag >>> 3) {
        case 1:
          message.baseAccount = _auth.BaseAccount.decode(reader, reader.uint32());
          break;
        case 2:
          message.accountOwner = reader.string();
          break;
        default:
          reader.skipType(tag & 7);
          break;
      }
    }
    return message;
  },
  fromJSON: function fromJSON(object) {
    return {
      baseAccount: (0, _helpers.isSet)(object.baseAccount) ? _auth.BaseAccount.fromJSON(object.baseAccount) : undefined,
      accountOwner: (0, _helpers.isSet)(object.accountOwner) ? String(object.accountOwner) : ""
    };
  },
  toJSON: function toJSON(message) {
    var obj = {};
    message.baseAccount !== undefined && (obj.baseAccount = message.baseAccount ? _auth.BaseAccount.toJSON(message.baseAccount) : undefined);
    message.accountOwner !== undefined && (obj.accountOwner = message.accountOwner);
    return obj;
  },
  fromPartial: function fromPartial(object) {
    var _object$accountOwner;
    var message = createBaseInterchainAccount();
    message.baseAccount = object.baseAccount !== undefined && object.baseAccount !== null ? _auth.BaseAccount.fromPartial(object.baseAccount) : undefined;
    message.accountOwner = (_object$accountOwner = object.accountOwner) !== null && _object$accountOwner !== void 0 ? _object$accountOwner : "";
    return message;
  }
};