Git Product home page Git Product logo

challenge-1-decentralized-staking's Issues

Remarks

  1. Please give names to the parameters in your Stake event. It makes it easy to understand your code, its purpose, and will be helpful for indexing (like creating a subgraph).
  2. Good practice to always set initializing values even when opting for default ones (openForWithdraw state variable)
  3. Your execute function can be more optimized if you check for openForWithdraw. As we know that execute has been already performed if the variable is true.
function execute() public notCompleted {
    //if excuted was performed succesfully before, show an error to reflect this//
    require(!openForWithdraw, "Actions has been already performed!");
    // if deadline is not passed, show error to refelct it//
    require(block.timestamp > deadline, "Deadline is not completed yet!");
    // if is used instead of require becasu we have a counter action to set "openForWithdraw" to true//�
    if(address(this).balance >= threshold) {
      exampleExternalContract.complete{value: address(this).balance}();
    } else {
      // If the `threshold` was not met, allow everyone to call a `withdraw()` function
      openForWithdraw = true;
    }
  }
  1. Bug in withdraw function. You are not updating the balances which will allow user to withdraw multiple times.
  2. Your modifiers must be above functions to follow best practices and conventions.
  3. Good job on deploying and verifying the contract. Please try to link them in readme.
  4. Lack of comments. Please add comments with @notice, @params, etc to make your code easy to understand

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.