#[default_impl]Expand description
Generates the missing default implementations for the traits provided by OpenZeppelin Stellar library.
#[contractimpl] macro requires all the default implementations to be
provided under the code block:
ⓘ
#[contractimpl]
impl Trait for MyContract {
/*
The client generated by the `#[contractimpl]` macro will have access only
to the methods specified in here. Which means, if you do not provide the
default implementations of the methods, the client generated by the
`#[contractimpl]` macro won't have access to those methods.
This is due to how macros work in Rust. They cannot access the default
implementations of the methods of this trait, since they are not in the
scope of the macro.
To overcome this, we provide a macro for our traits, that generates the
missing default implementations for the methods of the trait, so
you can only focus on the overrides, and leave the default implementations
out as per usual.
*/
}§Example:
ⓘ
#[default_impl] // IMPORTANT: place this above `#[contractimpl]`
#[contractimpl]
impl NonFungibleToken for MyContract {
/* your overrides here */
}This macro works for the following traits:
FungibleTokenFungibleBurnableNonFungibleTokenNonFungibleBurnableNonFungibleEnumerableAccessControlOwnable
§Notes
This macro does not support the below traits on purpose:
FungibleAllowListFungibleBlockListNonFungibleRoyalties
Because, there are no default implementation to enforce how the authorization should be configured. Not providing a default implementation for these traits is a reminder for the implementor to provide the authorization logic for these traits.