Description
Follow-up to #94.
Currently the path passed to the right hand side argument of abigen!
is expected to be relative to the std::env::current_dir
:
fuels-rs/fuels-core/src/source.rs
Line 47 in f6d4cc0
This evaluates to whatever happens to be the current directory at the time of macro expansion. This means that the necessary path given to abigen!
can change when the project is moved to a different subdirectory of the same workspace, or if its moved from a workspace into its own project, or vice versa. Ideally, we want our src
not to be dependent on the directory that the project happens to be executed within.
To fix this, we could model our behaviour after the std include_str!
macro. include_str!
accepts a path that is relative to the file in which it is invoked. For example if we have:
project/my-contract-abi.json
project/tests/harness.rs
the abigen!
macro could then be invoked within the project/tests/harness.rs
with
abigen!(MyContract, "../my-contract-abi.json");