Giter Club home page Giter Club logo

foundry-rust-template's People

Contributors

0xjepsen avatar danipopes avatar gakonst avatar itsdevbear avatar mattsse avatar winor30 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

foundry-rust-template's Issues

Cargo.lock in .gitignore

Hi, any reason why the Cargo.lock is in the .gitignore?

I think it should be removed.

Greetz

Josh

`forge bind` produces ABI without `anonymous` field

Description

It seems adding events to the solidity contracts lets forge bind produce rust code with a "faulty" ABI.
I put faulty in quotes because I am unsure if the rust code should be able to handle the missing anonymous field or forge bind should add the fields to the contract.

Once I know where to look: I can see if I find the issue.
If it is a more complex issue (my rust is not that great): Is this something that should be raised in the "foundry" repo?

Sidenote (in case others also encounter this issue):
Taking the ABI produced in contracts/out/ and manually entering it into the rust code sidesteps the issue.

Steps to reproduce

Modify the example contract slightly:

diff --git a/contracts/src/Contract.sol b/contracts/src/Contract.sol
index 6ff7142..b630557 100644
--- a/contracts/src/Contract.sol
+++ b/contracts/src/Contract.sol
@@ -1,4 +1,6 @@
 // SPDX-License-Identifier: UNLICENSED
 pragma solidity 0.8.10;
 
-contract MyContract {}
+contract MyContract {
+       event Someevent();
+}

Rebuild

forge build --root ./contracts/
forge bind --overwrite --bindings-path ./bindings --root ./contracts --crate-name bindings

Run example

cargo run

Output

cargo run
   Compiling bindings v0.0.1 (/tmp/bugsearch/foundry-rust-template/bindings)
   Compiling app v0.1.0 (/tmp/bugsearch/foundry-rust-template/app)
    Finished dev [unoptimized + debuginfo] target(s) in 3.98s
     Running `target/debug/app`
thread 'main' panicked at 'invalid abi: Error("missing field `anonymous`", line: 1, column: 62)', bindings/src/my_contract.rs:24:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Afterwards

Cargo test failed on newly generated forge bind

I got this error message after using forge bind to generate new bindings:

   Compiling bindings v0.0.1 (/home/nxqd/dev/00_projects/defidog.d/defidog-sol/bindings)
error[E0433]: failed to resolve: could not find `__serde_json` in `utils`
  --> bindings/src/my_contract.rs:21:34
   |
21 |             ethers::core::utils::__serde_json::from_str("[]").expect("invalid abi")
   |                                  ^^^^^^^^^^^^ could not find `__serde_json` in `utils`

error[E0433]: failed to resolve: could not find `ContractDeployer` in `contract`
  --> bindings/src/my_contract.rs:93:46
   |
93 |             let deployer = ethers::contract::ContractDeployer::new(deployer);
   |                                              ^^^^^^^^^^^^^^^^ could not find `ContractDeployer` in `contract`

error[E0412]: cannot find type `ContractDeployer` in module `ethers::contract::builders`
  --> bindings/src/my_contract.rs:84:41
   |
84 |             ethers::contract::builders::ContractDeployer<M, Self>,
   |                                         ^^^^^^^^^^^^^^^^ not found in `ethers::contract::builders`

error[E0277]: the trait bound `ethers::prelude::Bytes: FromStr` is not satisfied
    --> bindings/src/my_contract.rs:26:204
     |
26   | ...a3ee64736f6c634300080a0033" . parse () . expect ("invalid bytecode")
     |                                  ^^^^^ the trait `FromStr` is not implemented for `ethers::prelude::Bytes`
     |
     = help: the following other types implement trait `FromStr`:
               Bloom
               BytecodeOutputSelection
               ContractOutputSelection
               DeployedBytecodeOutputSelection
               ERCNFT
               ERCNFTType
               EvmOutputSelection
               EvmVersion
             and 123 others
note: required by a bound in `core::str::<impl str>::parse`

error[E0599]: the method `clone` exists for struct `ethers::contract::Contract<M>`, but its trait bounds were not satisfied
   --> bindings/src/my_contract.rs:31:31
    |
31  |             MyContract(self.0.clone())
    |                               ^^^^^ method cannot be called on `ethers::contract::Contract<M>` due to unsatisfied trait bounds
    |
   ::: /home/nxqd/.cargo/git/checkouts/ethers-rs-c3a7c0a0ae0fe6be/19d2fd1/ethers-contract/src/contract.rs:154:1
    |
154 | pub struct Contract<M> {
    | ---------------------- doesn't satisfy `ethers::contract::Contract<M>: Clone`
    |
    = note: the following trait bounds were not satisfied:
            `M: Clone`
            which is required by `ethers::contract::Contract<M>: Clone`
help: one of the expressions' fields has a method of the same name
    |
31  |             MyContract(self.0.base_contract.clone())
    |                               ++++++++++++++
help: one of the expressions' fields has a method of the same name
    |
31  |             MyContract(self.0.address.clone())
# environment
forge -V
forge 0.2.0 (6cd6618 2022-08-11T00:03:54.64793456Z)

Failing repo ?

I just cloned it , forge install and then cargo build and lots of error, like

error[E0433]: failed to resolve: could not find `ContractDeployer` in `contract`

I didn't change anything. Is my setup wrong or is it because of outdated deps ?

Thank you

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.