Skip to content
This repository was archived by the owner on Aug 17, 2026. It is now read-only.
This repository was archived by the owner on Aug 17, 2026. It is now read-only.

Merge storage declarations into derive macro Storage #288

Description

@clearloop

As we can see in https://github.com/zink-lang/zink/blob/d340f7ef28280c34947ca780fc8cafeffc4b1f47/examples/erc20.rs#L12-L25 the storage interfaces are currently distributed into different structs, instead, we want an interface like below to improve the developer experience

#[derive(Storage)]
pub struct MyERC20 {
  // #[zink::storage(String32)]
  // struct Name(String32);
  pub name: String32,
  // #[zink::storage(String32)]
  // struct Symbol(String32);
  pub symbol: String32,
  // ...
  pub total_supply: U256,
  pub balances: Mapping<Address, U256>,
  pub allowances: DoubleKeyMapping<Address, Address, U256>,
}

#[zink::contract]
impl MyERC20 {
  /// this method will be compiled as an external call because we have `pub` here
  /// 
  /// `self` here will be the entrance of the storage
  pub fn set_and_get(&self, new_name: String32) -> String32 {
    self.name.set(new_name);
    self.name.get()
  }
}

related to #260

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

refactorThis issue requires a refactor to the design

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions