Code Monkey home page Code Monkey logo

book's People

Contributors

0xvv avatar allcontributors[bot] avatar appleseed-iii avatar danipopes avatar devanoneth avatar dmfxyz avatar evalir avatar github-actions[bot] avatar klkvr avatar l0gykal avatar leutwiler avatar m0ham3dx avatar mattsse avatar mds1 avatar odyslam avatar omahs avatar onbjerg avatar paulrberg avatar perelyn-sama avatar portdeveloper avatar rkrasiuk avatar robriks avatar rootulp avatar sabnock01 avatar sbvegan avatar shawnharmsen avatar skaunov avatar wiasliaw avatar wildmolasses avatar zeroekkusu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

book's Issues

Switch host

The book should probably be deployed to Netlify or Vercel so we can have previews in pull requests

Chapters on upcoming features

We should add chapters on the following features when they are released:

Landed recently:

Coming later:

  • Coverage reports
  • Invariant tests
  • Symbolic testing
  • Mutation testing
  • Documentation generation
  • Deployment system

Chapters on current features

Meta

  • Introduction

Getting started

  • Installation
  • First steps with Foundry

Forge

  • Creating a new project
  • Working on an existing project
  • Dependencies
    • Add sections on forge remove and forge update
    • Document release/tag behavior
  • Project layout
  • foundry.toml
  • Tests
    • Writing tests
    • Cheatcodes
    • Understanding traces
  • Advanced Testing
    • Fuzz testing
  • Continous integration
  • Debugger
  • Cache
  • Deployment (as of now, forge create)

Additional guides

  • Incremental adoption
  • Integrating with VSCode
  • Shell autocompletion

Reference

  • ds-test Reference
  • foundry.toml Reference
  • Cheatcodes Reference

Automate some documentation

It would be nice to automate some parts of the documentation, such as the overall reference for cast, forge and the output of specific commands. This will require some scripts, and it might be possible to use the output of forge --help/cast --help or rustdoc in some way.

We still want to retain examples and so on, so it will require some thinking. If this can be pulled off, it would mean that some documentation is essentially written by improving the output of the help commands on the relevant commands upstream in Foundry, which will increase the quality of those

No guidance on how to import "cheats.expectRevert"

While reading the Writing Tests chapter, I stumbled upon the following code snippet:

function testCannotSubtract43() public {
    cheats.expectRevert(abi.encodeWithSignature("Panic(uint256)", 0x11));
    testNumber -= 43;
}

I tried to run it but I got the following error:

Error:
   0: Compiler run failed
      DeclarationError: Undeclared identifier.
        --> /Users/paulrberg/workspace/templates/foundry-template/test/Contract.t.sol:22:9:
         |
      22 |         cheats.expectRevert(abi.encodeWithSignature("Panic(uint256)", 0x11));
         |         ^^^^^^

It looks like the docs are not showing how to import and initialize the cheats when first mentioning them.

Add Test Contract address to foundry.toml Reference

Test contracts are deployed to 0xb4c79dab8f259c7aee6e5b2aa729821864227e84, but this address is not listed in the config.md reference.

A quick test confirms this is the deploy address.

//SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.0 <0.9.0;

import "ds-test/test.sol";

contract JustChecking is DSTest{
    function testDeployer() public {
        emit log_named_address("msg.sender", msg.sender);
        emit log_named_address("tx.origin", tx.origin);
        emit log_named_address("this", address(this));
    }
}

Output

Logs:
  msg.sender: 0x00a329c0648769a73afac7f9381e08fb43dbea72
  tx.origin: 0x00a329c0648769a73afac7f9381e08fb43dbea72
  this: 0xb4c79dab8f259c7aee6e5b2aa729821864227e84

I do not know if there is an environment variable in Forge to control the test deploy address. In DS-Test this environment variable is called DAPP_TEST_ADDRESS (see here).

It is useful to have this address somewhere in the documentation because this contract is the default owner of contracts deployed by the test.

Add note about `extcodesize` for `vm.mockCall`

If you mock a call on an address with no code the call might fail regardless because Solidity does an extcodesize check before calls under normal circumstances. Can be fixed by using vm.etch in tandem

Encountered error using "expectRevert"

Encountered error

> forge test
compiling...
Compiling 1 files with 0.8.12
Compilation finished successfully
Error:
   0: Compiler run failed
      TypeError: Member "expectRevert" not found or not visible after argument-dependent lookup in contract CheatCodes.
        --> /Users/rootulp/git/rootulp/hello_foundry/src/Contract.sol:43:5:
         |
      43 |     cheats.expectRevert(
         |     ^^^^^^^^^^^^^^^^^^^

while trying to reproduce and update the output for https://github.com/onbjerg/foundry-book/blame/master/src/forge/cheatcodes.md#L124

Book restructuring

I want to restructure the book a bit by including section headers, draft chapters and removing some chapters that just take up space.

Draft SUMMARY.md:

# Summary

[Introduction](./README.md)

# Getting Started

- [Installation](./getting-started/installation.md)
- [First Steps with Foundry](./getting-started/first-steps.md)

# Forge Overview

- [What is Forge?](./forge/README.md)
- [Projects]()
  - [Creating a New Project](./forge/creating-a-new-project.md)
  - [Working on an Existing Project](./forge/working-on-an-existing-project.md)
  - [Dependencies](./forge/dependencies.md)
  - [Project Layout](./forge/project-layout.md)
  - [Configuring with `foundry.toml`](./forge/config.md)
- [Tests](./forge/tests.md)
  - [Writing Tests](./forge/writing-tests.md)
  - [Cheatcodes](./forge/cheatcodes.md)
  - [Understanding Traces](./forge/traces.md)
  - [Forking Mode](./forge/forking-mode.md)
  - [Coverage Reports]()
- [Advanced Testing](./forge/advanced-testing.md)
  - [Fuzz Testing](./forge/fuzz-testing.md)
  - [Invariant Testing]()
  - [Symbolic Testing]()
  - [Table Testing]()
  - [Mutation Testing]()
- [Linting and Formatting]()
- [Generating Documentation]()
- [Deploying and Verifying](./forge/deploying.md)
- [Gas Tracking](./forge/gas-tracking.md)
  - [Gas Reports]()
  - [Gas Snapshots]()
- [Debugger](./forge/debugger.md)

# Cast Overview

- [What is Cast?](./cast/cast-overview.md)

# Additional Configuration

- [Integrating with VSCode](./guides/vscode.md)
- [Shell Autocompletion](./guides/shell-autocompletion.md)
- [Continuous Integration](./forge/continous-integration.md)

# Tutorials

- [Creating an NFT with Solmate and Foundry](./tutorials/solmate-nft.md)
- [Incremental Adoption]()

# References

- [`forge` Reference]()
- [`cast` Reference](./reference/cast.md)
- [`foundry.toml` Reference](./reference/config.md)
- [`ds-test` Reference](./reference/ds-test.md)
- [Cheatcodes Reference](./reference/cheatcodes.md)

Document `forge run`

This is the original PR, but it might have changed a bit since then - most notably the debugger is accessible only through this command for the time being.

DSTest examples might be incorrect

File: ds-test.md

Issue: The docs might be incorrect

Getting TypeError: No unique declaration found after argument-dependent lookup. when an int_const is passed to an assertion function.

// function assertEq(uint a, uint b) internal;
assertEq(1 ether, 1e18 wei);

Meanwhile, logging works fine:

// event log_uint(uint);
emit log_uint(1 ether);

Solution: I will fix the docs if others are getting the same error.

Add contributing guide

Should contain:

  • General ideas on structure
  • General ideas on wording
  • What the labels mean

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.