BuidlGuidl / eth-tech-tree-challenges

This repository houses the many challenges of the Ethereum Development Tech Tree
MIT License
3 stars 9 forks source link

Styling Updates - Dead Man's Switch #39

Open escottalexander opened 1 month ago

escottalexander commented 1 month ago

The Dead Man's Switch challenge was completed before we had this style guide and custom error requirements. This issue is for updating the challenge to use the new styling and custom errors (testing the custom errors will need to be added as well).

// Layout of Contract:
// version
// imports
// errors
// interfaces, libraries, contracts
// Type declarations
// State variables
// Events
// Modifiers
// Functions

// Layout of Functions:
// constructor
// receive function (if exists)
// fallback function (if exists)
// external
// public
// internal
// private
// internal & private view & pure functions
// external & public view & pure functions

Let's also designate the different sections with large block comments like this:

    ///////////////////
    // Public Functions
    ///////////////////

Lastly, let's use custom errors. For several contracts we have been doing generic reverts with strings but in the tests we can only expect any revert. By using custom errors and informing challengers about them in the requirements we are able to test that a contract reverts for a specific reason. This is also generally better practice for gas efficiency.

Look at almost any other completed challenge to get a visual idea about what it should look like.