Prechádzať zdrojové kódy

Update migrate script to work with new proxy setup

Tom Pointon 3 rokov pred
rodič
commit
7ac83542a5
1 zmenil súbory, kde vykonal 12 pridanie a 22 odobranie
  1. 12 22
      ethereum/migrations/5_deploy_pyth.js

+ 12 - 22
ethereum/migrations/5_deploy_pyth.js

@@ -1,35 +1,25 @@
 require('dotenv').config({ path: "../.env" });
 const bs58 = require("bs58");
 
-const PythDataBridge = artifacts.require("PythDataBridge");
-const PythImplementation = artifacts.require("PythImplementation");
-const PythSetup = artifacts.require("PythSetup");
+const PythProxy = artifacts.require("PythProxy");
 const Wormhole = artifacts.require("Wormhole");
 
 const chainId = process.env.PYTH_INIT_CHAIN_ID;
 const pyth2WormholeChainId = process.env.PYTH_TO_WORMHOLE_CHAIN_ID;
 const pyth2WormholeEmitter = bs58.decode(process.env.PYTH_TO_WORMHOLE_EMITTER); // base58, must fit into bytes32
 
+const { deployProxy } = require("@openzeppelin/truffle-upgrades");
+
 console.log("Deploying Pyth with emitter", pyth2WormholeEmitter.toString("hex"))
 
 module.exports = async function (deployer) {
-    // deploy implementation
-    await deployer.deploy(PythImplementation);
-    // deploy implementation
-    await deployer.deploy(PythSetup);
-
-    // encode initialisation data
-    const setup = new web3.eth.Contract(PythSetup.abi, PythSetup.address);
-    const initData = setup.methods.setup(
-        PythImplementation.address,
-
-        chainId,
-        (await Wormhole.deployed()).address,
-
-        pyth2WormholeChainId,
-        "0x" + pyth2WormholeEmitter.toString("hex"),
-    ).encodeABI();
-
-    // deploy proxy
-    await deployer.deploy(PythDataBridge, PythSetup.address, initData);
+    // Deploy the proxy script
+    await deployProxy(PythProxy,
+        [
+            chainId,
+            (await Wormhole.deployed()).address,
+            pyth2WormholeChainId,
+            "0x" + pyth2WormholeEmitter.toString("hex")
+        ],
+        { deployer });
 };