3_deploy_pyth.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334
  1. require('dotenv').config({ path: "../.env" });
  2. const bs58 = require("bs58");
  3. const PythUpgradable = artifacts.require("PythUpgradable");
  4. const WormholeReceiver = artifacts.require("WormholeReceiver");
  5. const pyth2WormholeChainId = process.env.PYTH_TO_WORMHOLE_CHAIN_ID;
  6. const pyth2WormholeEmitter = process.env.PYTH_TO_WORMHOLE_EMITTER;
  7. const { deployProxy } = require("@openzeppelin/truffle-upgrades");
  8. const tdr = require('truffle-deploy-registry');
  9. console.log("pyth2WormholeEmitter: " + pyth2WormholeEmitter)
  10. console.log("pyth2WormholeChainId: " + pyth2WormholeChainId)
  11. module.exports = async function (deployer, network) {
  12. // Deploy the proxy. This will return an instance of PythUpgradable,
  13. // with the address field corresponding to the fronting ERC1967Proxy.
  14. let proxyInstance = await deployProxy(PythUpgradable,
  15. [
  16. (await WormholeReceiver.deployed()).address,
  17. pyth2WormholeChainId,
  18. pyth2WormholeEmitter
  19. ],
  20. { deployer });
  21. // Add the ERC1967Proxy address to the PythUpgradable contract's
  22. // entry in the registry. This allows us to call upgradeProxy
  23. // functions with the value of PythUpgradable.deployed().address:
  24. // e.g. upgradeProxy(PythUpgradable.deployed().address, NewImplementation)
  25. if (!tdr.isDryRunNetworkName(network)) {
  26. await tdr.appendInstance(proxyInstance);
  27. }
  28. };