npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@dk1a/solecslib

v0.4.2

Published

ERC1155 and ERC721 Subsystems that use components to store data

Downloads

2

Readme

solecslib

ERC1155 and ERC721 Subsystems that use components to store data

Experimental additions to @latticexyz/solecs

See mud.dev first for context on solecs and what a System is.

A Subsystem is a System that inherits OwnableWritable instead of Ownable. Call Subsystem.authorizeWriter(systemAddress) to allow a System to execute a Subsystem.

Development

Install dependencies via node

yarn install

Run tests via both forge and hardhat

yarn test

Forge is used for tests internally. Except ERC tests are entirely taken from @solidstate/spec, which is why hardhat is also used.


Tokens

ERC1155, ERC721

They have similar contracts with shared suffixes:

  • VData - Virtual data abstraction, like an internal interface
  • Internal - ERC internals, inherits VData
  • Logic - ERC public+internal methods, inherits Internal. This is a full ERC implementation, lacking only a data provider.
  • DataComponents - data provider (only simple setters/getters), inherits VData.
  • ERC__Subsystem - Logic + DataComponents + Subsystem + constructor + default execute implementation.

ERC1155BaseSubsystem, ERC721BaseSubsystem

Full ERC1155/721 and Subsystem implementation, with a default execute and sub-executes (mint,burn,transfer all share 1 contract). Its components may be read by anyone without even awareness of ERC1155/721, but writes must always go through ERC__BaseSubsystem (this is mostly because of events, only 1 contract should emit them).

Notes on VData and Logic

Data and Logic separation isn't really necessary, but this was an interesting use case for it. For example by having Logic + DataStorage + constructor you could get an ordinary ERC1155/721 implementation (where DataStorage implements VData but just uses normal contract storage). And imo keeping components away from Logic makes it easier to compare to @solidstate/contracts (I tried to keep it very similar, and even reuse tests via @solidstate/spec).

Forwarder systems, like OperatorApprovalSystem

These exist as an optional addition to ERC__BaseSubsystem. They are pure-ECS wrappers for transfers and approvals. I'm not sure they're useful.


FromPrototype

Instantiates prototypes, ensures a reverse mapping.

instanceContext is encoded with protoEntity to get instanced entity in newInstance and other methods.

ScopedValueFromPrototype has an example.


ScopedValue, ScopedValueFromPrototype

FromPrototype-wrapped version is likely more useful.

Interact with batches (identified by scope) of entity values, or individual entity values.

Scope is for doing batched read/increase/decrease without looping through everything.

Value is any kind of entity to counter mapping.

ScopedValueFromPrototypeTest has an example.