Expand description
§Pendzl functionality and utils
The library is organized into three main components
§1. Code Generation Module (codegen)
This module contains the implementations of macros used for code generation in the library.
-
Contains:
- Implementation of the
codegen::implementationmacro:- Implements the
implementationmacro, which injects default fn implementations (& overrides) of standard traits.
- Implements the
- Boilerplate code for implementations injecting:
- Every implementation of a trait (PSP22, PSP34, PSP22Metadata etc) is injected with the default implementation of the trait.
- Implementation of the
codegen::storage_itemmacro:- Implements functionality for the
storage_itemmacro, handling storage-related code generation.
- Implements functionality for the
- Implementation of the
codegen::storage_field_getter_derivemacro:- Contains the implementation for deriving the
StorageFieldGettertrait for storage structures.
- Contains the implementation for deriving the
- Implementation of the
See more about the code generation module here.
§2. Macro Definitions Module (macro)
This module defines the public macros that are exposed to end users.
- Contains:
- Definition of the
implementationmacro:- Utilizes
codegen::implementationinternally to provide default implementations of standard traits.
- Utilizes
- Definition of the
storage_itemmacro:- Uses
codegen::storage_itemto handle storage-related macros.
- Uses
- Definition of the
StorageFieldGetterderive macro:- Employs
codegen::storage_field_getter_deriveto automatically derive getter methods for storage fields.
- Employs
- Definition of the
§3. Source Module (src)
This module serves as the main entry point and provides utility functions and re-exports for end users.
- Features:
- Re-exports the
macromodule:- Makes the macros defined in the
macromodule available to users.
- Makes the macros defined in the
- Contains mathematical utilities:
- Provides utility functions for mathematical operations used in the library.
- Includes various trait and type helpers:
- Contains helper traits and types to assist both the library and end users in developing smart contracts.
- Re-exports the
Modules§
Macros§
- storage_
unique_ key - Return the hash of the format!(“{}::{}”, ::core::module_path!(), struct_name). Also, if field naming is provided, it will return the hash of the format!(“{}::{}::{}”, ::core::module_path!(), struct_name, field_name). It cam be used to generate unique storage key of the struct.
Attribute Macros§
- implementation
- This macro implements the default traits defined in pendzl, while also allowing users
to override them with
#[overrider]attribute.#[overrider]is used when you want to change the behavior of the method by your implementation. - storage_
item - The macro implements
ink::storage_itemmacro for the struct, which means that it prepares your struct to be a part of contract’s storage. Also, inside of struct marked by this macro you can use#[lazy]attribute to mark fields, that should be lazily loaded and wrapped in::ink::storage::Lazy. The macro also generates constant storage keys for every mapping or lazy field and inserts them into type definition following recomendation from https://use.ink/datastructures/storage-layout