common-contracts.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. const { task } = require('hardhat/config');
  2. const { TASK_TEST_SETUP_TEST_ENVIRONMENT } = require('hardhat/builtin-tasks/task-names');
  3. const { setCode } = require('@nomicfoundation/hardhat-network-helpers');
  4. const fs = require('fs');
  5. const path = require('path');
  6. const INSTANCES = {
  7. // Entrypoint v0.7.0
  8. entrypoint: {
  9. address: '0x0000000071727De22E5E9d8BAf0edAc6f37da032',
  10. abi: JSON.parse(fs.readFileSync(path.resolve(__dirname, '../test/bin/EntryPoint070.abi'), 'utf-8')),
  11. bytecode: fs.readFileSync(path.resolve(__dirname, '../test/bin/EntryPoint070.bytecode'), 'hex'),
  12. },
  13. senderCreator: {
  14. address: '0xEFC2c1444eBCC4Db75e7613d20C6a62fF67A167C',
  15. abi: JSON.parse(fs.readFileSync(path.resolve(__dirname, '../test/bin/SenderCreator070.abi'), 'utf-8')),
  16. bytecode: fs.readFileSync(path.resolve(__dirname, '../test/bin/SenderCreator070.bytecode'), 'hex'),
  17. },
  18. // Arachnid's deterministic deployment proxy
  19. // See: https://github.com/Arachnid/deterministic-deployment-proxy/tree/master
  20. arachnidDeployer: {
  21. address: '0x4e59b44847b379578588920cA78FbF26c0B4956C',
  22. abi: [],
  23. bytecode:
  24. '0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3',
  25. },
  26. // Micah's deployer
  27. micahDeployer: {
  28. address: '0x7A0D94F55792C434d74a40883C6ed8545E406D12',
  29. abi: [],
  30. bytecode: '0x60003681823780368234f58015156014578182fd5b80825250506014600cf3',
  31. },
  32. };
  33. task(TASK_TEST_SETUP_TEST_ENVIRONMENT).setAction((_, env, runSuper) =>
  34. runSuper().then(() =>
  35. Promise.all(
  36. Object.entries(INSTANCES).map(([name, { address, abi, bytecode }]) =>
  37. setCode(address, '0x' + bytecode.replace(/0x/, '')).then(() =>
  38. env.ethers.getContractAt(abi, address).then(instance => (env[name] = instance)),
  39. ),
  40. ),
  41. ),
  42. ),
  43. );