diff --git a/README.md b/README.md index ac9ee94d..661c7c97 100644 --- a/README.md +++ b/README.md @@ -35,17 +35,7 @@ yarn install ``` -## Usage - -```sh -yarn dev -``` - -## Run tests - -```sh -yarn test -``` +Remember to create `.env` file from `.env.example` then deploy smart contract and open web app. ## Hardhat guideline @@ -74,6 +64,18 @@ npx solhint 'contracts/**/*.sol' npx solhint 'contracts/**/*.sol' --fix ``` +## Usage + +```sh +yarn dev +``` + +## Run tests + +```sh +yarn test +``` + ## Etherscan verification To try out Etherscan verification, you first need to deploy a contract to an Ethereum network that's supported by Etherscan, such as Ropsten. diff --git a/contracts/Box.sol b/contracts/Box.sol index 7fff1975..ee239f0a 100644 --- a/contracts/Box.sol +++ b/contracts/Box.sol @@ -1,9 +1,14 @@ // SPDX-License-Identifier: Unlicense pragma solidity ^0.8.0; +import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; -contract Box { +contract Box is Initializable{ uint256 private _value; + function initialize(uint256 value) public initializer { + _value = value; + } + // Emitted when the stored value changes event ValueChanged(uint256 value); diff --git a/contracts/BoxV2.sol b/contracts/BoxV2.sol index 750a0b3d..9512e56e 100644 --- a/contracts/BoxV2.sol +++ b/contracts/BoxV2.sol @@ -1,9 +1,14 @@ // SPDX-License-Identifier: Unlicense pragma solidity ^0.8.0; +import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; -contract BoxV2 { +contract BoxV2 is Initializable { uint256 private _value; + function initialize(uint256 value) public initializer { + _value = value; + } + // Emitted when the stored value changes event ValueChanged(uint256 value); diff --git a/hardhat.config.js b/hardhat.config.js index 7bf2ac04..e4ba00e3 100644 --- a/hardhat.config.js +++ b/hardhat.config.js @@ -62,6 +62,11 @@ module.exports = { url: process.env.BSC_PROVIDER_URL || "https://speedy-nodes-nyc.moralis.io/036063875a28828fa0c00596/bsc/testnet", accounts: process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [], }, + tomotestnet: { + chainId: 89, + url: "https://rpc.testnet.tomochain.com", + accounts: process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [], + }, }, gasReporter: { enabled: process.env.REPORT_GAS !== undefined, diff --git a/package.json b/package.json index 1701b18e..5d4f9cc1 100644 --- a/package.json +++ b/package.json @@ -10,63 +10,63 @@ "test": "mocha --exit --recursive" }, "dependencies": { - "@tailwindcss/typography": "0.4.1", + "@tailwindcss/typography": "0.5.7", "@web3-react/core": "6.1.9", "@web3-react/injected-connector": "6.0.7", - "@web3-react/network-connector": "6.1.9", - "@web3-react/walletconnect-connector": "6.2.4", - "daisyui": "1.14.0", - "loglevel": "1.7.1", - "react": "17.0.2", - "react-dom": "17.0.2", + "@web3-react/network-connector": "6.2.9", + "@web3-react/walletconnect-connector": "6.2.13", + "daisyui": "2.38.0", + "loglevel": "1.8.0", + "react": "18.2.0", + "react-dom": "18.2.0", "web3-react": "5.0.5" }, "devDependencies": { - "@nomiclabs/hardhat-ethers": "2.0.2", - "@nomiclabs/hardhat-etherscan": "2.1.5", - "@nomiclabs/hardhat-waffle": "2.0.1", - "@openzeppelin/contracts": "4.3.1", - "@openzeppelin/contracts-upgradeable": "4.3.1", - "@openzeppelin/hardhat-upgrades": "1.10.0", - "@trivago/prettier-plugin-sort-imports": "2.0.4", - "@typechain/ethers-v5": "7.0.1", - "@typechain/hardhat": "2.3.0", - "@types/react": "17.0.19", - "@types/react-dom": "17.0.9", - "@typescript-eslint/eslint-plugin": "4.29.3", - "@typescript-eslint/parser": "4.29.3", - "@vitejs/plugin-react-refresh": "1.3.6", - "autoprefixer": "10.3.3", - "chai": "4.3.4", - "dotenv": "10.0.0", - "eslint": "7.32.0", - "eslint-config-airbnb": "18.2.1", - "eslint-config-prettier": "8.3.0", - "eslint-plugin-import": "2.24.2", - "eslint-plugin-jsx-a11y": "6.4.1", + "@nomiclabs/hardhat-ethers": "2.2.1", + "@nomiclabs/hardhat-etherscan": "3.1.2", + "@nomiclabs/hardhat-waffle": "2.0.3", + "@openzeppelin/contracts": "4.7.3", + "@openzeppelin/contracts-upgradeable": "4.7.3", + "@openzeppelin/hardhat-upgrades": "1.21.0", + "@trivago/prettier-plugin-sort-imports": "3.4.0", + "@typechain/ethers-v5": "10.1.1", + "@typechain/hardhat": "6.1.4", + "@types/mocha": "^10.0.0", + "@types/react": "18.0.24", + "@types/react-dom": "18.0.8", + "@typescript-eslint/eslint-plugin": "5.42.0", + "@typescript-eslint/parser": "5.42.0", + "@vitejs/plugin-react": "^2.2.0", + "autoprefixer": "10.4.13", + "chai": "4.3.6", + "dotenv": "16.0.3", + "eslint": "8.26.0", + "eslint-config-airbnb": "19.0.4", + "eslint-config-prettier": "8.5.0", + "eslint-plugin-import": "2.26.0", + "eslint-plugin-jsx-a11y": "6.6.1", "eslint-plugin-node": "11.1.0", - "eslint-plugin-promise": "5.1.0", - "eslint-plugin-react": "7.25.1", - "eslint-plugin-react-hooks": "4.2.0", - "ethereum-waffle": "3.4.0", - "ethers": "5.4.6", - "hardhat": "2.6.1", - "hardhat-gas-reporter": "1.0.4", - "husky": "7.0.2", - "lint-staged": "11.1.2", - "postcss": "8.3.6", - "prettier": "2.3.2", - "prettier-plugin-solidity": "1.0.0-beta.17", - "solhint": "3.3.6", - "solidity-coverage": "0.7.17", - "tailwindcss": "2.2.9", - "typechain": "5.1.2", - "typescript": "4.4.2", - "vite": "2.5.1", - "vite-plugin-checker": "0.3.4" + "eslint-plugin-promise": "6.1.1", + "eslint-plugin-react": "7.31.10", + "eslint-plugin-react-hooks": "4.6.0", + "ethereum-waffle": "3.4.4", + "ethers": "5.7.2", + "hardhat": "2.12.2", + "hardhat-gas-reporter": "1.0.9", + "husky": "8.0.1", + "lint-staged": "13.0.3", + "postcss": "8.4.18", + "prettier": "2.7.1", + "prettier-plugin-solidity": "1.0.0-rc.1", + "solhint": "3.3.7", + "solidity-coverage": "0.8.2", + "tailwindcss": "3.2.1", + "typechain": "8.1.1", + "typescript": "4.8.4", + "vite": "3.2.2" }, "lint-staged": { "*.js": "eslint --cache --fix", "*.{js,css,md}": "prettier --write" } -} \ No newline at end of file +} diff --git a/scripts/deploy_upgradeable_box.js b/scripts/deploy_upgradeable_box.js index 8c4b50c9..7b11a358 100644 --- a/scripts/deploy_upgradeable_box.js +++ b/scripts/deploy_upgradeable_box.js @@ -20,6 +20,9 @@ async function main() { const box = await upgrades.deployProxy(Box, [42], { initializer: "store" }); await box.deployed(); console.log("Box deployed to:", box.address); + + const value = await box.retrieve(); + console.log("Box value:", value); } // We recommend this pattern to be able to use async/await everywhere diff --git a/scripts/upgrade_box.js b/scripts/upgrade_box.js index 1639f452..ac44d075 100644 --- a/scripts/upgrade_box.js +++ b/scripts/upgrade_box.js @@ -1,9 +1,10 @@ +/* eslint-disable import/no-extraneous-dependencies */ // We require the Hardhat Runtime Environment explicitly here. This is optional // but useful for running the script in a standalone fashion through `node