You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently all ink! items are always defined in a single file.
The reason for this is that we only allow defining ink! definitions that have the known ink! markers such as #[ink(storage)], #[ink(event)] etc. to be defined within the ink!'s smart contract module:
This is becoming an increasing problem especially for more complex smart contracts as smart contract writers want to be able to specify certain parts of their smart contracts be be structurally in different files.
Potential Solution
A potential solution to solve this problem is to make use of so-called out-of-line modules that have a special marker to make it possible to annotate in which file those modules exist.
The semantics of having such an annotated module within an ink! module would be the same as simply including the annotated module's code directly into the ink! module as if it was an inline module definition.
An example contract using this feature would then look like the following:
To make this work properly we'd need to recursively check all the definitions inside those expanded inline-modules for special ink! definitions and properly make use of them or report errors.
A big problem might become reporting error with correct span information of those out-of-line modules since we want to report the errors with their original span information of the out-of-line module, not of the post-expanded inline-module definition.
The text was updated successfully, but these errors were encountered:
Hey there! Recently discovered ink! and I love it! This problem however seems like a dealbreaker for collaborative work on bigger-scale projects. Is there any ETA if and when this gets resolved?
Problem Description & Current State
Currently all ink! items are always defined in a single file.
The reason for this is that we only allow defining ink! definitions that have the known ink! markers such as
#[ink(storage)]
,#[ink(event)]
etc. to be defined within the ink!'s smart contract module:This is becoming an increasing problem especially for more complex smart contracts as smart contract writers want to be able to specify certain parts of their smart contracts be be structurally in different files.
Potential Solution
A potential solution to solve this problem is to make use of so-called out-of-line modules that have a special marker to make it possible to annotate in which file those modules exist.
Rust already supports annotating out-of-line modules with the
#[path = <module_path.rs>]
marker. However, due to design rationals stated in this comment we might want to consider using a slightly different specialized ink! marker for the same purpose, e.g.#[ink(path = <module_path.rs>)]
.The semantics of having such an annotated module within an ink! module would be the same as simply including the annotated module's code directly into the ink! module as if it was an inline module definition.
An example contract using this feature would then look like the following:
With
my_contract_impls
being a file such as:Which would end up after initial expansion as:
Hard Problems To Solve First
To make this work properly we'd need to recursively check all the definitions inside those expanded inline-modules for special ink! definitions and properly make use of them or report errors.
A big problem might become reporting error with correct span information of those out-of-line modules since we want to report the errors with their original span information of the out-of-line module, not of the post-expanded inline-module definition.
The text was updated successfully, but these errors were encountered: