Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate interface::Serve trait implementation for any impls #5

Open
5 of 8 tasks
swfsql opened this issue Oct 12, 2021 · 0 comments
Open
5 of 8 tasks

Generate interface::Serve trait implementation for any impls #5

swfsql opened this issue Oct 12, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@swfsql
Copy link

swfsql commented Oct 12, 2021

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:

  1. Expose a function from the wasm binary (if they are public).
  2. Parsing of arguments and some helper/common interface behavior, such as denying payments when invoking some particular function.
  3. Calling the actual method implementation, passing the arguments and the state.
  4. 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
  • trait definition
@swfsql swfsql added the enhancement New feature or request label Oct 12, 2021
@swfsql swfsql self-assigned this Oct 12, 2021
@swfsql swfsql changed the title Generate CalledIn trait implementation for any impls Generate interface::Serve trait implementation for any impls Oct 24, 2021
@swfsql swfsql removed their assignment Dec 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant