3_deploy_bridge.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. require('dotenv').config({ path: "../.env" });
  2. const TokenBridge = artifacts.require("TokenBridge");
  3. const BridgeImplementation = artifacts.require("BridgeImplementation");
  4. const BridgeSetup = artifacts.require("BridgeSetup");
  5. const TokenImplementation = artifacts.require("TokenImplementation");
  6. const Wormhole = artifacts.require("Wormhole");
  7. const chainId = process.env.BRIDGE_INIT_CHAIN_ID;
  8. const governanceChainId = process.env.BRIDGE_INIT_GOV_CHAIN_ID;
  9. const governanceContract = process.env.BRIDGE_INIT_GOV_CONTRACT; // bytes32
  10. const WETH = process.env.BRIDGE_INIT_WETH;
  11. module.exports = async function (deployer) {
  12. // deploy token implementation
  13. await deployer.deploy(TokenImplementation);
  14. // deploy setup
  15. await deployer.deploy(BridgeSetup);
  16. // deploy implementation
  17. await deployer.deploy(BridgeImplementation);
  18. // encode initialisation data
  19. const setup = new web3.eth.Contract(BridgeSetup.abi, BridgeSetup.address);
  20. const initData = setup.methods.setup(
  21. BridgeImplementation.address,
  22. chainId,
  23. (await Wormhole.deployed()).address,
  24. governanceChainId,
  25. governanceContract,
  26. TokenImplementation.address,
  27. WETH
  28. ).encodeABI();
  29. // deploy proxy
  30. await deployer.deploy(TokenBridge, BridgeSetup.address, initData);
  31. };