-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
enhancementNew feature or requestNew feature or request
Description
The near sdk's #[near_bindgen] allows generating code for "impl" blocks, whether they are direct impls on structures, or impls of traits into structures.
The objective of the generated code is to:
- Expose a function from the wasm binary (if they are public).
- Parsing of arguments and some helper/common interface behavior, such as denying payments when invoking some particular function.
- Calling the actual method implementation, passing the arguments and the state.
- Managing state storage from the modified data in RAM.
The #[contract] proc-macro should behave similarly, by mostly doing points 2-4.
- - On point 2, it should generate public structures to represent the arguments (
Args) and also a structure to represent a type that can be specialized into a method call (Serve), both of those assuming that generics are present.
See more in Public items #14. - On point 1, this should be out-of-scope of this proc-macro because it cannot know how generic types will be specialized yet. Some other macro, even if it's own definition is generated automatically, should be used for WASM function exporting.
See more in Generate macro for extern "C" function generation #12.
In overall, #[contract] should be applicable for:
- standalone functions
- standalone impl block of some structure
- trait impl for some structure
- with option to refer to an existing
#[contract]trait definition - with the option to not refer to an existing
#[contract]trait definition
- with option to refer to an existing
- trait definition
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request