4_deploy_pyth.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. require('dotenv').config({ path: "../.env" });
  2. const PythDataBridge = artifacts.require("PythDataBridge");
  3. const PythImplementation = artifacts.require("PythImplementation");
  4. const PythSetup = artifacts.require("PythSetup");
  5. const Wormhole = artifacts.require("Wormhole");
  6. const chainId = process.env.PYTH_INIT_CHAIN_ID;
  7. const governanceChainId = process.env.PYTH_INIT_GOV_CHAIN_ID;
  8. const governanceContract = process.env.PYTH_INIT_GOV_CONTRACT; // bytes32
  9. const pyth2WormholeChainId = process.env.PYTH_TO_WORMHOLE_CHAIN_ID;
  10. const pyth2WormholeContract = process.env.PYTH_TO_WORMHOLE_CONTRACT; // bytes32
  11. module.exports = async function (deployer) {
  12. // deploy implementation
  13. await deployer.deploy(PythImplementation);
  14. // deploy implementation
  15. await deployer.deploy(PythSetup);
  16. // encode initialisation data
  17. const setup = new web3.eth.Contract(PythSetup.abi, PythSetup.address);
  18. const initData = setup.methods.setup(
  19. PythImplementation.address,
  20. chainId,
  21. (await Wormhole.deployed()).address,
  22. governanceChainId,
  23. governanceContract,
  24. pyth2WormholeChainId,
  25. pyth2WormholeContract,
  26. ).encodeABI();
  27. // deploy proxy
  28. await deployer.deploy(PythDataBridge, PythSetup.address, initData);
  29. };