Factory.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // deploys and connects the three primary contracts of Mirrorgate onto one chain
  2. // this deploy file does not connect these contracts to other contracts.
  3. module.exports = async ({ getNamedAccounts, deployments }) => {
  4. const { deploy } = deployments
  5. const { deployer } = await getNamedAccounts()
  6. let router = await ethers.getContract("Router")
  7. // deploy Factory.sol
  8. await deploy("Factory", {
  9. from: deployer,
  10. args: [router.address],
  11. log: true,
  12. skipIfAlreadyDeployed: true,
  13. waitConfirmations: 1,
  14. })
  15. // set router params
  16. let bridge = await ethers.getContract("Bridge")
  17. let factory = await ethers.getContract("Factory")
  18. let currRouterBridge = await router.bridge()
  19. let currRouterFactory = await router.factory()
  20. if (bridge.address !== currRouterBridge || factory.address !== currRouterFactory) {
  21. let tx = await (await router.setBridgeAndFactory(bridge.address, factory.address)).wait()
  22. if (hre.network.name !== "hardhat") {
  23. console.log(bridge.address, factory.address)
  24. console.log(`- router.setBridgeAndFactory( ${bridge.address}, ${factory.address} ) | tx: ${tx.transactionHash}`)
  25. }
  26. } else {
  27. if (hre.network.name !== "hardhat") {
  28. console.log(`- router.setBridgeAndFactory(${bridge.address}, ${factory.address}) | *already sets*`)
  29. }
  30. }
  31. }
  32. module.exports.tags = ["Factory", "test"]
  33. module.exports.dependencies = ["Bridge", "Router"]