From 0bf1cf5cfea44b0b2f90c2b2a8a2837a42f4cee8 Mon Sep 17 00:00:00 2001 From: Bliss Da Sailor Date: Thu, 14 Jul 2022 21:45:32 -0500 Subject: [PATCH 1/2] exclude lock files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index f3196b9..e2f66ab 100644 --- a/.gitignore +++ b/.gitignore @@ -51,6 +51,7 @@ artifacts # misc .DS_Store .env* +*.lock # debug npm-debug.log* From 4ea2d7ed082e8ade17b7e08400c7666bb26d9b87 Mon Sep 17 00:00:00 2001 From: farque65 Date: Mon, 25 Jul 2022 01:05:45 -0400 Subject: [PATCH 2/2] feat(hardhat, react-app): updates for week3 demo --- packages/hardhat/contracts/Staking.sol | 42 +++++++++++++++++--------- packages/react-app/src/App.jsx | 4 +-- packages/react-app/src/constants.js | 2 +- yarn.lock | 5 +++ 4 files changed, 35 insertions(+), 18 deletions(-) diff --git a/packages/hardhat/contracts/Staking.sol b/packages/hardhat/contracts/Staking.sol index 6193a77..0a8f254 100644 --- a/packages/hardhat/contracts/Staking.sol +++ b/packages/hardhat/contracts/Staking.sol @@ -38,16 +38,19 @@ contract Staking is Ownable { uint256 start, uint256 duration, string memory meta - ) public onlyOwner { - if (latestRound > 0) { - require( - start > - rounds[latestRound].start + rounds[latestRound].duration, - "new rounds have to start after old rounds" - ); - } + //Removed onlyOwner modifier for testing purposes + ) public { - require(start > block.timestamp, "new rounds should be in the future"); + // REMOVING these require statements because they are not necessary to test staking and locking + // if (latestRound > 0) { + // require( + // start > + // rounds[latestRound].start + rounds[latestRound].duration, + // "new rounds have to start after old rounds" + // ); + // } + + // require(start > block.timestamp, "new rounds should be in the future"); latestRound++; @@ -60,7 +63,7 @@ contract Staking is Ownable { // stake function stake(uint256 roundId, uint256 amount) public { - require(isActiveRound(roundId), "Can't stake an inactive round"); + // require(isActiveRound(roundId), "Can't stake an inactive round"); token.transferFrom(msg.sender, address(this), amount); @@ -73,10 +76,10 @@ contract Staking is Ownable { // unstake function unstake(uint256 roundId, uint256 amount) public { - require( - !isActiveRound(roundId), - "Can't unstake during an active round" - ); + // require( + // !isActiveRound(roundId), + // "Can't unstake during an active round" + // ); require( rounds[roundId].stakes[msg.sender] >= amount, "Not enough balance to withdraw" @@ -140,9 +143,18 @@ contract Staking is Ownable { function getUserStakeForRound(uint256 roundId, address user) public view - roundExists(roundId) + ///roundExists(roundId) returns (uint256) { return rounds[roundId].stakes[user]; } + + function getUserStakeFromLatestRound(address user) + public + view + ///roundExists(roundId) + returns (uint256) + { + return rounds[latestRound].stakes[user]; + } } diff --git a/packages/react-app/src/App.jsx b/packages/react-app/src/App.jsx index 9314620..6e89d57 100644 --- a/packages/react-app/src/App.jsx +++ b/packages/react-app/src/App.jsx @@ -46,7 +46,7 @@ const { ethers } = require("ethers"); */ /// 📡 What chain are your contracts deployed to? -const initialNetwork = NETWORKS.localhost; // <------- select your target frontend network (localhost, rinkeby, xdai, mainnet) +const initialNetwork = NETWORKS.goerli; // <------- select your target frontend network (localhost, rinkeby, xdai, mainnet) // 😬 Sorry for all the console logging const DEBUG = true; @@ -70,7 +70,7 @@ function App(props) { const [injectedProvider, setInjectedProvider] = useState(); const [address, setAddress] = useState(); - const [selectedNetwork, setSelectedNetwork] = useState(networkOptions[0]); + const [selectedNetwork, setSelectedNetwork] = useState(networkOptions[3]); const location = useLocation(); const targetNetwork = NETWORKS[selectedNetwork]; diff --git a/packages/react-app/src/constants.js b/packages/react-app/src/constants.js index 809bbb8..23c788a 100644 --- a/packages/react-app/src/constants.js +++ b/packages/react-app/src/constants.js @@ -10,7 +10,7 @@ export const BLOCKNATIVE_DAPPID = "0b58206a-f3c0-4701-a62f-73c7243e8c77"; export const ALCHEMY_KEY = "oKxs-03sij-U_N0iOlrSsZFr29-IqbuF"; const localRpcUrl = process.env.REACT_APP_CODESPACES - ? `https://${window.location.hostname.replace("3000", "8545")}` + ? `https://${window.location.hostname.replace("3001", "8545")}` : "http://" + (global.window ? window.location.hostname : "localhost") + ":8545"; export const NETWORKS = { diff --git a/yarn.lock b/yarn.lock index 73acbd5..f4c93b1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -15947,6 +15947,11 @@ moment@^2.24.0, moment@^2.25.3: resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.2.tgz#00910c60b20843bcba52d37d58c628b47b1f20e4" integrity sha512-UgzG4rvxYpN15jgCmVJwac49h9ly9NurikMWGPdVxm8GZD6XjkKPxDTjQQ43gtGgnV3X0cAyWDdP2Wexoquifg== +moment@^2.29.4: + version "2.29.4" + resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.4.tgz#3dbe052889fe7c1b2ed966fcb3a77328964ef108" + integrity sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w== + moniker@0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/moniker/-/moniker-0.1.2.tgz#872dfba575dcea8fa04a5135b13d5f24beccc97e"