{"size": 1345, "ext": "js", "max_stars_repo_path": "truffle.js", "max_stars_repo_name": "lehuan94cntt/huan-casino", "max_stars_repo_stars_event_min_datetime": "2021-05-09T00:30:22.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-01T20:41:26.000Z", "max_issues_repo_path": "truffle.js", "max_issues_repo_name": "lcsouzamenezes/zeros-dice", "max_issues_repo_issues_event_min_datetime": "2021-03-09T04:16:55.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-17T23:09:18.000Z", "max_forks_repo_path": "truffle.js", "max_forks_repo_name": "lcsouzamenezes/zeros-dice", "max_forks_repo_forks_event_min_datetime": "2020-04-30T17:15:02.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-23T13:45:10.000Z"}
{"max_stars_count": 8, "max_issues_count": 4, "max_forks_count": 8, "avg_line_length": 22.7966101695, "max_line_length": 79, "alphanum_fraction": 0.6408921933}
require('dotenv').config();
const WalletProvider = require('truffle-wallet-provider')
const Wallet = require('ethereumjs-wallet')

const parsePrivateKey = privateKey => new Buffer(privateKey, "hex")

const getWalle = function (network) {
  let wallet;
  switch (network) {
    case 'ropsten':
      let ropstenPrivateKey = parsePrivateKey(process.env.ROPSTEN_PRIVATE_KEY)
      wallet = Wallet.fromPrivateKey(ropstenPrivateKey)
      break
    case 'rinkeby':
      let rinkebyPrivateKey = parsePrivateKey(process.env.RINKEBY_PRIVATE_KEY);
      wallet = Wallet.fromPrivateKey(rinkebyPrivateKey);
      break
    default:
      break
  }

  return wallet
}

const infuraProvider = function (network) {
  let wallet = getWalle(network)
  return new WalletProvider(wallet, `https://${network}.infura.io/`)
}

module.exports = {
  networks: {
    development: {
      host: "localhost",
      port: 8545,
      network_id: "*" // Match any network id
    },
    ropsten: {
      provider: infuraProvider("ropsten"),
      gas: 4600000,
      gasPrice: 100000000000,
      network_id: "3"
    },
    rinkeby: {
      provider: infuraProvider("rinkeby"),
      gas: 4600000,
      gasPrice: 100000000000,
      network_id: "4"
    }
  },
  solc: {
    optimizer: {
      enabled: true,
      runs: 200
    }
  },
  mocha: {
    useColors: true
  }
};