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

chore: turn Mapping into a wrapper type #33

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

0xrusowsky
Copy link
Contributor

@0xrusowsky 0xrusowsky commented Jan 15, 2025

tackles the 1st:

since Mapping is now a wrapper type, i had to split StorageStorable into 2 types of traits: based on whether there is direct interaction with the db or nor.

then, i created 2 traits (DirectStorage, KeyValueStorage) to signal the public fn read(), fn write() API that devs will use. Maybe skill issue, but i didn't mange to do it with a single trait. Open to feedback or a better design if this one feels too convoluted.

I tried to summarize my logic in the docs:

///  STORAGE TYPES:
///  > Must implement the following traits:
///     - `StorageLayout`: Allows the `storage` macro to allocate a storage slot.
///  > Must implement one of the following traits, for external consumption:
///     - `DirectStorage`:  Exposes read and write capabilities of values that are directly accessed.
///     - `KeyValueStorage`:  Exposes read and write capabilities of values that are accesed by key.
///  > Unless it is a wrapper type (like `Mapping`) it must implement the following traits:
///     - `StorageStorable`: Allows db storage reads and writes with abi de/encoding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant