From f7321e9efa25153d567cc2ee4a6524eb21ca2005 Mon Sep 17 00:00:00 2001 From: Sonkeng Maldini Date: Wed, 31 May 2023 21:15:38 +0100 Subject: [PATCH] update for deployment --- contracts/WGhost.sol | 6 ++--- migrations/2_deploy_contracts.js | 11 +++++--- migrations/3_deploy_upgreadable.js.sample | 12 +++++++++ package.json | 2 +- truffle-config.js | 32 ----------------------- 5 files changed, 22 insertions(+), 41 deletions(-) create mode 100644 migrations/3_deploy_upgreadable.js.sample delete mode 100644 truffle-config.js diff --git a/contracts/WGhost.sol b/contracts/WGhost.sol index 82d7f5e..3dddee3 100644 --- a/contracts/WGhost.sol +++ b/contracts/WGhost.sol @@ -7,7 +7,7 @@ import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; -contract WGhost is Initializable, ERC20Upgradeable, OwnableUpgradeable, UUPSUpgradeable { +contract WGhostV1 is Initializable, ERC20Upgradeable, OwnableUpgradeable, UUPSUpgradeable { using ECDSA for bytes32; address public contractOwner; @@ -25,9 +25,7 @@ contract WGhost is Initializable, ERC20Upgradeable, OwnableUpgradeable, UUPSUpgr } /// @custom:oz-upgrades-unsafe-allow constructor - constructor() { - _disableInitializers(); - } + constructor() initializer {} function initialize() initializer public { __ERC20_init("Wrapped Ghost", "WGhost"); diff --git a/migrations/2_deploy_contracts.js b/migrations/2_deploy_contracts.js index 8519ef9..1f8f88b 100644 --- a/migrations/2_deploy_contracts.js +++ b/migrations/2_deploy_contracts.js @@ -1,5 +1,8 @@ -const WGhost = artifacts.require("WGhost"); +const { deployProxy } = require('@openzeppelin/truffle-upgrades'); -module.exports = function(deployer) { - deployer.deploy(WGhost); -}; +const WGhost = artifacts.require('WGhostV1'); + +module.exports = async function (deployer) { + const instance = await deployProxy(WGhost, { deployer, kind: 'uups'}); + console.log('Deployed', instance.address); +}; \ No newline at end of file diff --git a/migrations/3_deploy_upgreadable.js.sample b/migrations/3_deploy_upgreadable.js.sample new file mode 100644 index 0000000..30b36dd --- /dev/null +++ b/migrations/3_deploy_upgreadable.js.sample @@ -0,0 +1,12 @@ +// Example to use while doing upgrades + +const { upgradeProxy } = require('@openzeppelin/truffle-upgrades'); + +const WGhost = artifacts.require('WGhost'); +const WGhostV2 = artifacts.require('WGhostV2'); + +module.exports = async function (deployer) { + const existing = await WGhost.deployed(); + const instance = await upgradeProxy(existing.address, WGhostV2, { deployer }); + console.log("Upgraded", instance.address); +}; \ No newline at end of file diff --git a/package.json b/package.json index 601650d..00c5296 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "yargs": "^12.0.2" }, "devDependencies": { - "@openzeppelin/truffle-upgrades": "^1.18.0", + "@openzeppelin/truffle-upgrades": "^1.19.0", "truffle-hdwallet-provider-privkey": "^0.3.0" } } diff --git a/truffle-config.js b/truffle-config.js deleted file mode 100644 index 86bd7c2..0000000 --- a/truffle-config.js +++ /dev/null @@ -1,32 +0,0 @@ - -const privKeyrinkeby = "eae752e09ea4109e4ad21a4f35bf8df27e6fb83a67363ac1fcf7e3a330e3e862" -const PrivateKeyProvider = require("truffle-privatekey-provider"); - -module.exports = { - networks: { - development: { - host: "localhost", - port: 8545, - network_id: "*", // Match any network id - gas: 5000000 - }, - mumbai: { - host: "https://rpc.ankr.com/polygon_mumbai", - port: 8545, - network_id: "*", - gas: 5000000, - provider: () => new PrivateKeyProvider(privKeyrinkeby, "https://rpc.ankr.com/polygon_mumbai"), - } - }, - compilers: { - solc: { - version: "^0.8.0", - settings: { - optimizer: { - enabled: true, // Default: false - runs: 200 // Default: 200 - }, - } - } - } -};