import _regeneratorRuntime from 'babel-runtime/regenerator';
import _asyncToGenerator from 'babel-runtime/helpers/asyncToGenerator';
import _Object$getPrototypeOf from 'babel-runtime/core-js/object/get-prototype-of';
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
import _inherits from 'babel-runtime/helpers/inherits';

var _this2 = this;

import BlockHashRNGArtifact from 'kleros-interaction/build/contracts/BlockHashRNG';
import _ from 'lodash';

import * as ethConstants from '../../../constants/eth';
import ContractImplementation from '../../ContractImplementation';
import deployContractAsync from '../../../utils/deployContractAsync';

/**
 * Provides interaction with an instance of BlockHashRNG.
 */

var BlockHashRNG = function (_ContractImplementati) {
  _inherits(BlockHashRNG, _ContractImplementati);

  /**
   * Constructor BlockHashRNG.
   * @param {object} web3Provider - instance
   * @param {string} contractAddress - of the contract (optionnal)
   */
  function BlockHashRNG(web3Provider, contractAddress) {
    _classCallCheck(this, BlockHashRNG);

    return _possibleConstructorReturn(this, (BlockHashRNG.__proto__ || _Object$getPrototypeOf(BlockHashRNG)).call(this, web3Provider, BlockHashRNGArtifact, 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;
}(ContractImplementation);

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

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

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

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

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