foundry-rs / foundry-rust-template Goto Github PK
View Code? Open in Web Editor NEWTemplate for quickly getting started with developing Rust applications that leverage Foundry for EVM smart contract development
Template for quickly getting started with developing Rust applications that leverage Foundry for EVM smart contract development
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
Hi, any reason why the Cargo.lock is in the .gitignore?
I think it should be removed.
Greetz
Josh
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.
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();
+}
forge build --root ./contracts/
forge bind --overwrite --bindings-path ./bindings --root ./contracts --crate-name bindings
cargo run
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
make
results with:
error[E0432]: unresolved import `bindings::counter::Counter`
--> app/src/main.rs:1:5
|
1 | use bindings::counter::Counter;
| ^^^^^^^^^^^^^^^^^^^-------
| | |
| | help: a similar name exists in the module (notice the capitalization): `counter`
| no `Counter` in `counter`
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)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.