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
🧐 Motivation
Currently, we can't dynamically set the name and version when implementing SNIP12, but we need to set them as constant short strings. This intentionally saves some gas by avoiding unnecessary storage reads, but sometimes that's the desired behavior, like for example, with a token generator.
📝 Details
Make the SNIP12Metadata trait generic on the contract state, so it can optionally access storage members.
The text was updated successfully, but these errors were encountered:
This is already achievable by using unsafe_new_contract_state, or the StoragePath trait from Cairo 2.7:
use openzeppelin::utils::snip12::SNIP12Metadata;
impl SNIP12MetadataImpl of SNIP12Metadata {
fn name() -> felt252 {
let state = unsafe_new_contract_state();
// Some logic to get the name from storage
state.erc20.name().at(0).unwrap().into()
}
fn version() -> felt252 { 'v1' }
}
🧐 Motivation
Currently, we can't dynamically set the name and version when implementing SNIP12, but we need to set them as constant short strings. This intentionally saves some gas by avoiding unnecessary storage reads, but sometimes that's the desired behavior, like for example, with a token generator.
📝 Details
Make the SNIP12Metadata trait generic on the contract state, so it can optionally access storage members.
The text was updated successfully, but these errors were encountered: