random.js 381 B

1234567891011121314
  1. const { ethers } = require('hardhat');
  2. const randomArray = (generator, arrayLength = 3) => Array(arrayLength).fill().map(generator);
  3. const generators = {
  4. address: () => ethers.Wallet.createRandom().address,
  5. bytes32: () => ethers.hexlify(ethers.randomBytes(32)),
  6. uint256: () => ethers.toBigInt(ethers.randomBytes(32)),
  7. };
  8. module.exports = {
  9. randomArray,
  10. generators,
  11. };