'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _regenerator = require('babel-runtime/regenerator');

var _regenerator2 = _interopRequireDefault(_regenerator);

var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');

var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);

var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');

var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _inherits2 = require('babel-runtime/helpers/inherits');

var _inherits3 = _interopRequireDefault(_inherits2);

var _BlockHashRNG = require('kleros-interaction/build/contracts/BlockHashRNG');

var _BlockHashRNG2 = _interopRequireDefault(_BlockHashRNG);

var _lodash = require('lodash');

var _lodash2 = _interopRequireDefault(_lodash);

var _eth = require('../../../constants/eth');

var ethConstants = _interopRequireWildcard(_eth);

var _ContractImplementation = require('../../ContractImplementation');

var _ContractImplementation2 = _interopRequireDefault(_ContractImplementation);

var _deployContractAsync = require('../../../utils/deployContractAsync');

var _deployContractAsync2 = _interopRequireDefault(_deployContractAsync);

function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

/**
 * Provides interaction with an instance of BlockHashRNG.
 */
var BlockHashRNG = function (_ContractImplementati) {
  (0, _inherits3.default)(BlockHashRNG, _ContractImplementati);

  /**
   * Constructor BlockHashRNG.
   * @param {object} web3Provider - instance
   * @param {string} contractAddress - of the contract (optionnal)
   */
  function BlockHashRNG(web3Provider, contractAddress) {
    (0, _classCallCheck3.default)(this, BlockHashRNG);
    return (0, _possibleConstructorReturn3.default)(this, (BlockHashRNG.__proto__ || (0, _getPrototypeOf2.default)(BlockHashRNG)).call(this, web3Provider, _BlockHashRNG2.default, contractAddress));
  }

  /**
   * BlockHashRNG deploy.
   * @param {string} account - users account
   * @param {object} web3Provider - web3 provider object
   * @returns {object} - truffle-contract Object | err The contract object or error deploy
   */


  return BlockHashRNG;
}(_ContractImplementation2.default);

BlockHashRNG.deploy = function () {
  var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(account, web3Provider) {
    var contractDeployed;
    return _regenerator2.default.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            _context.next = 2;
            return (0, _deployContractAsync2.default)(account, ethConstants.TRANSACTION.VALUE, _BlockHashRNG2.default, web3Provider);

          case 2:
            contractDeployed = _context.sent;
            return _context.abrupt('return', contractDeployed);

          case 4:
          case 'end':
            return _context.stop();
        }
      }
    }, _callee, undefined);
  }));

  return function (_x, _x2) {
    return _ref.apply(this, arguments);
  };
}();

exports.default = BlockHashRNG;
//# sourceMappingURL=BlockHashRNG.js.map