4_deploy_nft_bridge.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. require('dotenv').config({ path: "../.env" });
  2. const TokenBridge = artifacts.require("NFTBridgeEntrypoint");
  3. const BridgeImplementation = artifacts.require("NFTBridgeImplementation");
  4. const BridgeSetup = artifacts.require("NFTBridgeSetup");
  5. const TokenImplementation = artifacts.require("NFTImplementation");
  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. module.exports = async function (deployer) {
  11. // deploy token implementation
  12. await deployer.deploy(TokenImplementation);
  13. // deploy setup
  14. await deployer.deploy(BridgeSetup);
  15. // deploy implementation
  16. await deployer.deploy(BridgeImplementation);
  17. // encode initialisation data
  18. const setup = new web3.eth.Contract(BridgeSetup.abi, BridgeSetup.address);
  19. const initData = setup.methods.setup(
  20. BridgeImplementation.address,
  21. chainId,
  22. (await Wormhole.deployed()).address,
  23. governanceChainId,
  24. governanceContract,
  25. TokenImplementation.address
  26. ).encodeABI();
  27. // deploy proxy
  28. await deployer.deploy(TokenBridge, BridgeSetup.address, initData);
  29. };