diff --git a/.changeset/chilled-chicken-repair.md b/.changeset/chilled-chicken-repair.md
new file mode 100644
index 0000000000..36e6a4fc90
--- /dev/null
+++ b/.changeset/chilled-chicken-repair.md
@@ -0,0 +1,8 @@
+---
+"@latticexyz/cli": patch
+"@latticexyz/recs": patch
+"@latticexyz/solecs": major
+"@latticexyz/std-client": patch
+---
+
+Removes `solecs` package. These were v1 contracts, now entirely replaced by our v2 tooling. See the [MUD docs](https://mud.dev/) for building with v2 or create a new project from our v2 templates with `pnpm create mud@next your-app-name`.
diff --git a/README.md b/README.md
index 0db40ee91e..1cf5479caa 100644
--- a/README.md
+++ b/README.md
@@ -70,16 +70,13 @@ More more information on how to get started, have a look at the [MUD documentati
MUD consists of several libraries. They can be used independently, but are best used together.
-| Package | Version |
-| ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
-| **[@latticexyz/solecs](/packages/solecs)**
Solidity Entity Component System library | [![npm version](https://img.shields.io/npm/v/@latticexyz/solecs.svg)](https://www.npmjs.org/package/@latticexyz/solecs) |
-| **[@latticexyz/network](/packages/network)**
TypeScript networking library for automatic contract/client state sync | [![npm version](https://img.shields.io/npm/v/@latticexyz/network.svg)](https://www.npmjs.org/package/@latticexyz/network) |
-| **[@latticexyz/recs](/packages/recs)**
TypeScript Reactive Entity Component System library | [![npm version](https://img.shields.io/npm/v/@latticexyz/recs.svg)](https://www.npmjs.org/package/@latticexyz/recs) |
-| **[@latticexyz/services](/packages/services)**
Go services for indexer, faucet, message relay | [![npm version](https://img.shields.io/npm/v/@latticexyz/services.svg)](https://www.npmjs.org/package/@latticexyz/services) |
-| **[@latticexyz/cli](/packages/cli)**
Command line interface for types, testing, faucet, deployment and more | [![npm version](https://img.shields.io/npm/v/@latticexyz/cli.svg)](https://www.npmjs.org/package/@latticexyz/cli) |
-| **[@latticexyz/std-contracts](/packages/std-contracts)**
Solidity standard library | [![npm version](https://img.shields.io/npm/v/@latticexyz/std-contracts.svg)](https://www.npmjs.org/package/@latticexyz/std-contracts) |
-| **[@latticexyz/std-client](/packages/std-client)**
Typescript standard library | [![npm version](https://img.shields.io/npm/v/@latticexyz/std-client.svg)](https://www.npmjs.org/package/@latticexyz/std-client) |
-| **[@latticexyz/noise](/packages/noise)**
Solidity and AssemblyScript implementations of Perlin noise | [![npm version](https://img.shields.io/npm/v/@latticexyz/noise.svg)](https://www.npmjs.org/package/@latticexyz/noise) |
+| Package | Version |
+| ----------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
+| **[@latticexyz/recs](/packages/recs)**
TypeScript Reactive Entity Component System library | [![npm version](https://img.shields.io/npm/v/@latticexyz/recs.svg)](https://www.npmjs.org/package/@latticexyz/recs) |
+| **[@latticexyz/services](/packages/services)**
Go services for indexer, faucet, message relay | [![npm version](https://img.shields.io/npm/v/@latticexyz/services.svg)](https://www.npmjs.org/package/@latticexyz/services) |
+| **[@latticexyz/cli](/packages/cli)**
Command line interface for types, testing, faucet, deployment and more | [![npm version](https://img.shields.io/npm/v/@latticexyz/cli.svg)](https://www.npmjs.org/package/@latticexyz/cli) |
+| **[@latticexyz/std-client](/packages/std-client)**
Typescript standard library | [![npm version](https://img.shields.io/npm/v/@latticexyz/std-client.svg)](https://www.npmjs.org/package/@latticexyz/std-client) |
+| **[@latticexyz/noise](/packages/noise)**
Solidity and AssemblyScript implementations of Perlin noise | [![npm version](https://img.shields.io/npm/v/@latticexyz/noise.svg)](https://www.npmjs.org/package/@latticexyz/noise) |
## Contribute
diff --git a/examples/minimal/packages/contracts/package.json b/examples/minimal/packages/contracts/package.json
index 10b95c71d8..3b4d44f4a0 100644
--- a/examples/minimal/packages/contracts/package.json
+++ b/examples/minimal/packages/contracts/package.json
@@ -23,7 +23,6 @@
"@latticexyz/cli": "link:../../../../packages/cli",
"@latticexyz/config": "link:../../../../packages/config",
"@latticexyz/schema-type": "link:../../../../packages/schema-type",
- "@latticexyz/solecs": "link:../../../../packages/solecs",
"@latticexyz/store": "link:../../../../packages/store",
"@latticexyz/world": "link:../../../../packages/world",
"@solidstate/contracts": "^0.0.52",
diff --git a/examples/minimal/pnpm-lock.yaml b/examples/minimal/pnpm-lock.yaml
index 2f9214e3cf..9d539a3893 100644
--- a/examples/minimal/pnpm-lock.yaml
+++ b/examples/minimal/pnpm-lock.yaml
@@ -335,9 +335,6 @@ importers:
'@latticexyz/schema-type':
specifier: link:../../../../packages/schema-type
version: link:../../../../packages/schema-type
- '@latticexyz/solecs':
- specifier: link:../../../../packages/solecs
- version: link:../../../../packages/solecs
'@latticexyz/store':
specifier: link:../../../../packages/store
version: link:../../../../packages/store
diff --git a/packages/cli/package.json b/packages/cli/package.json
index 302124ec05..c26fdf7955 100644
--- a/packages/cli/package.json
+++ b/packages/cli/package.json
@@ -37,7 +37,6 @@
"@latticexyz/protocol-parser": "workspace:*",
"@latticexyz/schema-type": "workspace:*",
"@latticexyz/services": "workspace:*",
- "@latticexyz/solecs": "workspace:*",
"@latticexyz/store": "workspace:*",
"@latticexyz/utils": "workspace:*",
"@latticexyz/world": "workspace:*",
diff --git a/packages/recs/src/Component.ts b/packages/recs/src/Component.ts
index e6f62664c0..dc4be8750c 100644
--- a/packages/recs/src/Component.ts
+++ b/packages/recs/src/Component.ts
@@ -37,7 +37,7 @@ function getComponentName(component: Component) {
* @param schema {@link Schema} of component values. Uses Type enum as bridge between typescript types and javascript accessible values.
* @param options Optional: {
* id: descriptive id for this component (otherwise an autogenerated id is used),
- * metadata: arbitrary metadata (eg. contractId for solecs mapped components),
+ * metadata: arbitrary metadata,
* indexed: if this flag is set, an indexer is applied to this component (see {@link createIndexer})
* }
* @returns Component object linked to the provided World
diff --git a/packages/recs/src/Entity.ts b/packages/recs/src/Entity.ts
index dc5f36cce2..768ba36177 100644
--- a/packages/recs/src/Entity.ts
+++ b/packages/recs/src/Entity.ts
@@ -8,7 +8,7 @@ import { Component, ComponentValue, Entity, EntitySymbol, World } from "./types"
* @param components Array of [{@link defineComponent Component}, {@link ComponentValue}] tuples to be added to this entity.
* (Use {@link withValue} to generate these tuples with type safety.)
* @param options Optional: {
- * id: {@link Entity} for this entity. Use this for entities that were created outside of recs, eg. in the corresponding solecs contracts.
+ * id: {@link Entity} for this entity. Use this for entities that were created outside of recs.
* idSuffix: string to be appended to the auto-generated id. Use this for improved readability. Do not use this if the `id` option is provided.
* }
* @returns index of this entity in the {@link World}. This {@link Entity} is used to refer to this entity in other recs methods (eg {@link setComponent}).
diff --git a/packages/recs/src/types.ts b/packages/recs/src/types.ts
index 4f0c905f6e..b25bc4333c 100644
--- a/packages/recs/src/types.ts
+++ b/packages/recs/src/types.ts
@@ -20,7 +20,6 @@ export type Schema = {
/**
* Used to add arbitrary metadata to components.
- * (Eg `contractId` for components that have a corresponding solecs component contract.)
*/
export type Metadata =
| {
diff --git a/packages/solecs/.gitignore b/packages/solecs/.gitignore
deleted file mode 100644
index 2f6f3adfc2..0000000000
--- a/packages/solecs/.gitignore
+++ /dev/null
@@ -1,10 +0,0 @@
-cache
-abi
-out
-types/ethers-contracts
-docs
-_docs
-DOCS.md
-artifacts
-yarn-error.log
-API
\ No newline at end of file
diff --git a/packages/solecs/.npmignore b/packages/solecs/.npmignore
deleted file mode 100644
index 4240dbeb28..0000000000
--- a/packages/solecs/.npmignore
+++ /dev/null
@@ -1,7 +0,0 @@
-*
-
-!abi/**
-!src/**
-!types/**
-!package.json
-!README.md
\ No newline at end of file
diff --git a/packages/solecs/.solhint.json b/packages/solecs/.solhint.json
deleted file mode 100644
index 4e2baa8be7..0000000000
--- a/packages/solecs/.solhint.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "extends": "solhint:recommended",
- "rules": {
- "compiler-version": ["error", ">=0.8.0"],
- "avoid-low-level-calls": "off",
- "func-visibility": ["warn", { "ignoreConstructors": true }]
- }
-}
diff --git a/packages/solecs/CHANGELOG.md b/packages/solecs/CHANGELOG.md
deleted file mode 100644
index 63b0f806ee..0000000000
--- a/packages/solecs/CHANGELOG.md
+++ /dev/null
@@ -1,534 +0,0 @@
-# Change Log
-
-## 2.0.0-next.3
-
-## 2.0.0-next.2
-
-## 2.0.0-next.1
-
-## 2.0.0-next.0
-
-### Patch Changes
-
-- [#1168](https://github.com/latticexyz/mud/pull/1168) [`48909d15`](https://github.com/latticexyz/mud/commit/48909d151b3dfceab128c120bc6bb77de53c456b) Thanks [@dk1a](https://github.com/dk1a)! - bump forge-std and ds-test dependencies
-
-All notable changes to this project will be documented in this file.
-See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
-
-# [1.42.0](https://github.com/latticexyz/mud/compare/v1.41.0...v1.42.0) (2023-04-13)
-
-### Features
-
-- align git dep versions ([#577](https://github.com/latticexyz/mud/issues/577)) ([2b5fb5e](https://github.com/latticexyz/mud/commit/2b5fb5e94ad3e7e1134608121fec6c7b6a64d539))
-
-# [1.41.0](https://github.com/latticexyz/mud/compare/v1.40.0...v1.41.0) (2023-03-09)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-# [1.40.0](https://github.com/latticexyz/mud/compare/v1.39.0...v1.40.0) (2023-03-03)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-# [1.39.0](https://github.com/latticexyz/mud/compare/v1.38.0...v1.39.0) (2023-02-22)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-# [1.38.0](https://github.com/latticexyz/mud/compare/v1.37.1...v1.38.0) (2023-02-22)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-## [1.37.1](https://github.com/latticexyz/mud/compare/v1.37.0...v1.37.1) (2023-02-17)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-# [1.37.0](https://github.com/latticexyz/mud/compare/v1.36.1...v1.37.0) (2023-02-16)
-
-### Reverts
-
-- Revert "chore(release): publish v1.37.0" ([c934f53](https://github.com/latticexyz/mud/commit/c934f5388c1e56f2fe6390fdda30f5b9b1ea1c20))
-
-## [1.36.1](https://github.com/latticexyz/mud/compare/v1.36.0...v1.36.1) (2023-02-16)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-# [1.35.0](https://github.com/latticexyz/mud/compare/v1.34.0...v1.35.0) (2023-02-15)
-
-### Bug Fixes
-
-- **solecs:** make OwnableWritable overridable ([#370](https://github.com/latticexyz/mud/issues/370)) ([49d520e](https://github.com/latticexyz/mud/commit/49d520e643aefe954a84fdff5d6b742afd0cf010))
-
-### Features
-
-- update forge-std, use some new features in cli ([#311](https://github.com/latticexyz/mud/issues/311)) ([43ad118](https://github.com/latticexyz/mud/commit/43ad11837ae280509be92737e8f86d749d4d48d8))
-
-# [1.34.0](https://github.com/latticexyz/mud/compare/v1.33.1...v1.34.0) (2023-01-29)
-
-### Features
-
-- **solecs:** add deterministic storage location for systems, add storage access util ([#264](https://github.com/latticexyz/mud/issues/264)) ([f18c398](https://github.com/latticexyz/mud/commit/f18c39831f5d5ab0186529eb2cfaee4991570e6f))
-
-## [1.33.1](https://github.com/latticexyz/mud/compare/v1.33.0...v1.33.1) (2023-01-12)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-# [1.33.0](https://github.com/latticexyz/mud/compare/v1.32.0...v1.33.0) (2023-01-12)
-
-### Bug Fixes
-
-- **solecs:** use \_setOwner in Ownable constructor ([#338](https://github.com/latticexyz/mud/issues/338)) ([851a3e6](https://github.com/latticexyz/mud/commit/851a3e60d226f1dec856f1f89e2d55bfe9c1ac8c))
-
-# [1.32.0](https://github.com/latticexyz/mud/compare/v1.31.3...v1.32.0) (2023-01-06)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-## [1.31.3](https://github.com/latticexyz/mud/compare/v1.31.2...v1.31.3) (2022-12-16)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-## [1.31.2](https://github.com/latticexyz/mud/compare/v1.31.1...v1.31.2) (2022-12-15)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-## [1.31.1](https://github.com/latticexyz/mud/compare/v1.31.0...v1.31.1) (2022-12-15)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-# [1.31.0](https://github.com/latticexyz/mud/compare/v1.30.1...v1.31.0) (2022-12-14)
-
-### Bug Fixes
-
-- use interfaces in LibDeploy ([#278](https://github.com/latticexyz/mud/issues/278)) ([6d01082](https://github.com/latticexyz/mud/commit/6d01082f8119c67fcfdb2351aa98a3d7efa0989f))
-
-### Features
-
-- **solecs:** add world to IComponent definition ([#284](https://github.com/latticexyz/mud/issues/284)) ([881e4ea](https://github.com/latticexyz/mud/commit/881e4ea9e2e6aaa08abea3743c1449e02b9e12ae))
-
-## [1.30.1](https://github.com/latticexyz/mud/compare/v1.30.0...v1.30.1) (2022-12-02)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-# [1.30.0](https://github.com/latticexyz/mud/compare/v1.29.0...v1.30.0) (2022-12-02)
-
-### Features
-
-- **cli:** hot system replacement, new commands (deploy-contracts, codegen-libdeploy, devnode, types, test, create) ([#277](https://github.com/latticexyz/mud/issues/277)) ([8e32f98](https://github.com/latticexyz/mud/commit/8e32f983208c37839bc3e347058dbc7e49b6247e))
-
-# [1.29.0](https://github.com/latticexyz/mud/compare/v1.28.1...v1.29.0) (2022-11-29)
-
-### Bug Fixes
-
-- allow overriding preset components, replace Owned interface with IERC173, fix IComponent interface ([#239](https://github.com/latticexyz/mud/issues/239)) ([ae3983b](https://github.com/latticexyz/mud/commit/ae3983b047271ebcf96506f8a6cb0458deb602e7))
-
-### Features
-
-- **solecs:** add util to split up bitpacked data ([#247](https://github.com/latticexyz/mud/issues/247)) ([a7f73b0](https://github.com/latticexyz/mud/commit/a7f73b01e2f0387927e30a4e7b0846a69b3c0ce0))
-
-## [1.28.1](https://github.com/latticexyz/mud/compare/v1.28.0...v1.28.1) (2022-11-24)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-# [1.28.0](https://github.com/latticexyz/mud/compare/v1.27.1...v1.28.0) (2022-11-20)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-# [1.27.0](https://github.com/latticexyz/mud/compare/v1.26.0...v1.27.0) (2022-11-15)
-
-### Bug Fixes
-
-- **solecs:** restrict write access to Set and MapSet to owner ([#244](https://github.com/latticexyz/mud/issues/244)) ([f17a6d7](https://github.com/latticexyz/mud/commit/f17a6d7d3f533c385f7033835f0af4e13577776b))
-
-# [1.26.0](https://github.com/latticexyz/mud/compare/v1.25.1...v1.26.0) (2022-11-07)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-## [1.25.1](https://github.com/latticexyz/mud/compare/v1.25.0...v1.25.1) (2022-11-03)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-# [1.25.0](https://github.com/latticexyz/mud/compare/v1.24.1...v1.25.0) (2022-11-03)
-
-### Features
-
-- **solecs:** allow overriding Component logic, better inheritance ([#229](https://github.com/latticexyz/mud/issues/229)) ([d4f5a4b](https://github.com/latticexyz/mud/commit/d4f5a4be482d249e1a417cbc1c91a4eb27233952))
-
-## [1.24.1](https://github.com/latticexyz/mud/compare/v1.24.0...v1.24.1) (2022-10-29)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-# [1.24.0](https://github.com/latticexyz/mud/compare/v1.23.1...v1.24.0) (2022-10-28)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-## [1.23.1](https://github.com/latticexyz/mud/compare/v1.23.0...v1.23.1) (2022-10-28)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-# [1.23.0](https://github.com/latticexyz/mud/compare/v1.22.0...v1.23.0) (2022-10-26)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-# [1.22.0](https://github.com/latticexyz/mud/compare/v1.21.0...v1.22.0) (2022-10-26)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-# [1.21.0](https://github.com/latticexyz/mud/compare/v1.20.0...v1.21.0) (2022-10-26)
-
-### Bug Fixes
-
-- **solecs:** remove console import from MapSet ([#216](https://github.com/latticexyz/mud/issues/216)) ([b3116b3](https://github.com/latticexyz/mud/commit/b3116b39912638f980eaccd2e2d25227d0917874))
-
-# [1.20.0](https://github.com/latticexyz/mud/compare/v1.19.0...v1.20.0) (2022-10-22)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-# [1.19.0](https://github.com/latticexyz/mud/compare/v1.18.0...v1.19.0) (2022-10-21)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-# [1.18.0](https://github.com/latticexyz/mud/compare/v1.17.0...v1.18.0) (2022-10-21)
-
-### Features
-
-- **solecs:** add payable system interface ([#206](https://github.com/latticexyz/mud/issues/206)) ([a436d9e](https://github.com/latticexyz/mud/commit/a436d9e7795b42f81192fc12e11362006a074d24))
-
-# [1.17.0](https://github.com/latticexyz/mud/compare/v1.16.0...v1.17.0) (2022-10-19)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-# [1.16.0](https://github.com/latticexyz/mud/compare/v1.15.0...v1.16.0) (2022-10-19)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-# [1.15.0](https://github.com/latticexyz/mud/compare/v1.14.2...v1.15.0) (2022-10-18)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-## [1.14.2](https://github.com/latticexyz/mud/compare/v1.14.1...v1.14.2) (2022-10-18)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-## [1.14.1](https://github.com/latticexyz/mud/compare/v1.14.0...v1.14.1) (2022-10-18)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-# [1.14.0](https://github.com/latticexyz/mud/compare/v1.13.0...v1.14.0) (2022-10-18)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-# [1.13.0](https://github.com/latticexyz/mud/compare/v1.12.0...v1.13.0) (2022-10-15)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-# [1.12.0](https://github.com/latticexyz/mud/compare/v1.11.0...v1.12.0) (2022-10-12)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-# [1.11.0](https://github.com/latticexyz/mud/compare/v1.10.0...v1.11.0) (2022-10-11)
-
-### Features
-
-- add BareComponent ([#200](https://github.com/latticexyz/mud/issues/200)) ([780d62c](https://github.com/latticexyz/mud/commit/780d62c716fdda67373f031dc1e0b3155e77b562))
-
-# [1.10.0](https://github.com/latticexyz/mud/compare/v1.9.0...v1.10.0) (2022-10-11)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-# [1.9.0](https://github.com/latticexyz/mud/compare/v1.8.0...v1.9.0) (2022-10-11)
-
-### Bug Fixes
-
-- **solecs): only allow components to register their own updates, feat(std-client:** add support for multiple overrides per component per action ([#199](https://github.com/latticexyz/mud/issues/199)) ([d8dd63e](https://github.com/latticexyz/mud/commit/d8dd63e8055c603d5df41ad47765a286d800c529))
-
-# [1.8.0](https://github.com/latticexyz/mud/compare/v1.7.1...v1.8.0) (2022-10-07)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-## [1.7.1](https://github.com/latticexyz/mud/compare/v1.7.0...v1.7.1) (2022-10-06)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-# [1.7.0](https://github.com/latticexyz/mud/compare/v1.6.0...v1.7.0) (2022-10-06)
-
-### Features
-
-- **soleces:** expose component functions set and remove internally without onlyWriter permissions ([#182](https://github.com/latticexyz/mud/issues/182)) ([662936b](https://github.com/latticexyz/mud/commit/662936bdeee38ac0da735c987413816b14b0218d))
-
-# [1.6.0](https://github.com/latticexyz/mud/compare/v1.5.1...v1.6.0) (2022-10-04)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-## [1.5.1](https://github.com/latticexyz/mud/compare/v1.5.0...v1.5.1) (2022-10-03)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-# [1.5.0](https://github.com/latticexyz/mud/compare/v1.4.1...v1.5.0) (2022-10-03)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-## [1.4.1](https://github.com/latticexyz/mud/compare/v1.4.0...v1.4.1) (2022-10-03)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-# [1.4.0](https://github.com/latticexyz/mud/compare/v1.3.0...v1.4.0) (2022-10-03)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-# [1.3.0](https://github.com/latticexyz/mud/compare/v1.2.0...v1.3.0) (2022-09-30)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-# [1.2.0](https://github.com/latticexyz/mud/compare/v1.1.0...v1.2.0) (2022-09-29)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-# [1.1.0](https://github.com/latticexyz/mud/compare/v1.0.0...v1.1.0) (2022-09-28)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-# [1.0.0](https://github.com/latticexyz/mud/compare/v0.16.4...v1.0.0) (2022-09-27)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-## [0.16.4](https://github.com/latticexyz/mud/compare/v0.16.3...v0.16.4) (2022-09-26)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-## [0.16.3](https://github.com/latticexyz/mud/compare/v0.16.2...v0.16.3) (2022-09-26)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-## [0.16.2](https://github.com/latticexyz/mud/compare/v0.16.1...v0.16.2) (2022-09-26)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-## [0.16.1](https://github.com/latticexyz/mud/compare/v0.16.0...v0.16.1) (2022-09-26)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-# [0.16.0](https://github.com/latticexyz/mud/compare/v0.15.1...v0.16.0) (2022-09-26)
-
-### Features
-
-- **std-contracts:** add FunctionComponent ([#161](https://github.com/latticexyz/mud/issues/161)) ([d720277](https://github.com/latticexyz/mud/commit/d7202774a5a068a99b88a63cb18100482dc18cb8))
-
-## [0.15.1](https://github.com/latticexyz/mud/compare/v0.15.0...v0.15.1) (2022-09-23)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-# [0.15.0](https://github.com/latticexyz/mud/compare/v0.14.2...v0.15.0) (2022-09-21)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-## [0.14.2](https://github.com/latticexyz/mud/compare/v0.14.1...v0.14.2) (2022-09-21)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-## [0.14.1](https://github.com/latticexyz/mud/compare/v0.14.0...v0.14.1) (2022-09-21)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-# [0.14.0](https://github.com/latticexyz/mud/compare/v0.13.0...v0.14.0) (2022-09-20)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-# [0.13.0](https://github.com/latticexyz/mud/compare/v0.12.0...v0.13.0) (2022-09-19)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-# [0.12.0](https://github.com/latticexyz/mud/compare/v0.11.1...v0.12.0) (2022-09-16)
-
-### Features
-
-- **cli:** forge bulk upload ecs state script ([#142](https://github.com/latticexyz/mud/issues/142)) ([bbd6e1f](https://github.com/latticexyz/mud/commit/bbd6e1f4be18dcae94addc65849136ad01d1ba2a))
-
-## [0.11.1](https://github.com/latticexyz/mud/compare/v0.11.0...v0.11.1) (2022-09-15)
-
-### Bug Fixes
-
-- do not run prepack multiple times when publishing ([4f6f4c3](https://github.com/latticexyz/mud/commit/4f6f4c35a53c105951b32a071e47a748b2502cda))
-
-# [0.11.0](https://github.com/latticexyz/mud/compare/v0.10.0...v0.11.0) (2022-09-15)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-# [0.10.0](https://github.com/latticexyz/mud/compare/v0.9.0...v0.10.0) (2022-09-14)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-# [0.9.0](https://github.com/latticexyz/mud/compare/v0.8.1...v0.9.0) (2022-09-13)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-## [0.8.1](https://github.com/latticexyz/mud/compare/v0.8.0...v0.8.1) (2022-08-22)
-
-### Bug Fixes
-
-- start from initialBlockNumber, build settings, fix github actions, and other minor additions ([#137](https://github.com/latticexyz/mud/issues/137)) ([08eab5c](https://github.com/latticexyz/mud/commit/08eab5c6b0d99a9ffa8a315e16454ecc9306f410))
-
-# [0.8.0](https://github.com/latticexyz/mud/compare/v0.7.0...v0.8.0) (2022-08-22)
-
-### Bug Fixes
-
-- fix mud.dev build and improve responsiveness ([#134](https://github.com/latticexyz/mud/issues/134)) ([a3f2b24](https://github.com/latticexyz/mud/commit/a3f2b2438203697f1dd9f8710b15caa5cd83e40d))
-
-### Features
-
-- add mud.dev ([#133](https://github.com/latticexyz/mud/issues/133)) ([302588c](https://github.com/latticexyz/mud/commit/302588cbbab2803396b894bc006d13e6ac943da9))
-
-# [0.7.0](https://github.com/latticexyz/mud/compare/v0.6.0...v0.7.0) (2022-08-19)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-# [0.6.0](https://github.com/latticexyz/mud/compare/v0.5.1...v0.6.0) (2022-08-15)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-## [0.5.1](https://github.com/latticexyz/mud/compare/v0.5.0...v0.5.1) (2022-08-05)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-# [0.5.0](https://github.com/latticexyz/mud/compare/v0.4.3...v0.5.0) (2022-08-05)
-
-### Bug Fixes
-
-- optimism, cancel action if gas check fails, add noise utils, fix ecs-browser entry point ([#119](https://github.com/latticexyz/mud/issues/119)) ([f35d3c3](https://github.com/latticexyz/mud/commit/f35d3c3cc7fc9385a215dfda6762a2a825c9fd6d))
-
-## [0.4.3](https://github.com/latticexyz/mud/compare/v0.4.2...v0.4.3) (2022-07-30)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-## [0.4.2](https://github.com/latticexyz/mud/compare/v0.4.1...v0.4.2) (2022-07-29)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-## [0.4.1](https://github.com/latticexyz/mud/compare/v0.4.0...v0.4.1) (2022-07-29)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-# [0.4.0](https://github.com/latticexyz/mud/compare/v0.3.2...v0.4.0) (2022-07-29)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-## [0.3.2](https://github.com/latticexyz/mud/compare/v0.3.1...v0.3.2) (2022-07-26)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-## [0.3.1](https://github.com/latticexyz/mud/compare/v0.3.0...v0.3.1) (2022-07-26)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-# [0.3.0](https://github.com/latticexyz/mud/compare/v0.2.0...v0.3.0) (2022-07-26)
-
-### Features
-
-- add componentComponent to store component to id mapping ([#60](https://github.com/latticexyz/mud/issues/60)) ([e9cb97b](https://github.com/latticexyz/mud/commit/e9cb97b07d8c9ea622efe7612d0646775f03e61a))
-- mudwar prototype (nyc sprint 2) ([#59](https://github.com/latticexyz/mud/issues/59)) ([a3db20e](https://github.com/latticexyz/mud/commit/a3db20e14c641b8b456775ee191eca6f016d47f5)), closes [#58](https://github.com/latticexyz/mud/issues/58) [#61](https://github.com/latticexyz/mud/issues/61) [#64](https://github.com/latticexyz/mud/issues/64) [#62](https://github.com/latticexyz/mud/issues/62) [#66](https://github.com/latticexyz/mud/issues/66) [#69](https://github.com/latticexyz/mud/issues/69) [#72](https://github.com/latticexyz/mud/issues/72) [#73](https://github.com/latticexyz/mud/issues/73) [#74](https://github.com/latticexyz/mud/issues/74) [#76](https://github.com/latticexyz/mud/issues/76) [#75](https://github.com/latticexyz/mud/issues/75) [#77](https://github.com/latticexyz/mud/issues/77) [#78](https://github.com/latticexyz/mud/issues/78) [#79](https://github.com/latticexyz/mud/issues/79) [#80](https://github.com/latticexyz/mud/issues/80) [#82](https://github.com/latticexyz/mud/issues/82) [#86](https://github.com/latticexyz/mud/issues/86) [#83](https://github.com/latticexyz/mud/issues/83) [#81](https://github.com/latticexyz/mud/issues/81) [#85](https://github.com/latticexyz/mud/issues/85) [#84](https://github.com/latticexyz/mud/issues/84) [#87](https://github.com/latticexyz/mud/issues/87) [#91](https://github.com/latticexyz/mud/issues/91) [#88](https://github.com/latticexyz/mud/issues/88) [#90](https://github.com/latticexyz/mud/issues/90) [#92](https://github.com/latticexyz/mud/issues/92) [#93](https://github.com/latticexyz/mud/issues/93) [#89](https://github.com/latticexyz/mud/issues/89) [#94](https://github.com/latticexyz/mud/issues/94) [#95](https://github.com/latticexyz/mud/issues/95) [#98](https://github.com/latticexyz/mud/issues/98) [#100](https://github.com/latticexyz/mud/issues/100) [#97](https://github.com/latticexyz/mud/issues/97) [#101](https://github.com/latticexyz/mud/issues/101) [#105](https://github.com/latticexyz/mud/issues/105) [#106](https://github.com/latticexyz/mud/issues/106)
-- new systems pattern ([#63](https://github.com/latticexyz/mud/issues/63)) ([fb6197b](https://github.com/latticexyz/mud/commit/fb6197b997eb7232e38ecfb9116ff256491dc38c))
-- **solecs, std-contracts:** update the build scripts with additional jq delete statements to make the abi files cleaner ([#53](https://github.com/latticexyz/mud/issues/53)) ([198dfa5](https://github.com/latticexyz/mud/commit/198dfa56238178a6f0c64ea63b3e4d9c979d742b))
-
-# [0.2.0](https://github.com/latticexyz/mud/compare/v0.1.8...v0.2.0) (2022-07-05)
-
-### Features
-
-- add webworker architecture for contract/client sync, add cache webworker ([#10](https://github.com/latticexyz/mud/issues/10)) ([4ef9f90](https://github.com/latticexyz/mud/commit/4ef9f909d1d3c10f6bea888b2c32b1d1df04185a)), closes [#14](https://github.com/latticexyz/mud/issues/14)
-- on-chain maps (nyc sprint 1) ([#38](https://github.com/latticexyz/mud/issues/38)) ([089c46d](https://github.com/latticexyz/mud/commit/089c46d7c0e112d1670e3bcd01a35f08ee21d593)), closes [#17](https://github.com/latticexyz/mud/issues/17) [#20](https://github.com/latticexyz/mud/issues/20) [#18](https://github.com/latticexyz/mud/issues/18) [#25](https://github.com/latticexyz/mud/issues/25) [#26](https://github.com/latticexyz/mud/issues/26) [#27](https://github.com/latticexyz/mud/issues/27) [#28](https://github.com/latticexyz/mud/issues/28) [#29](https://github.com/latticexyz/mud/issues/29) [#30](https://github.com/latticexyz/mud/issues/30) [#31](https://github.com/latticexyz/mud/issues/31) [#33](https://github.com/latticexyz/mud/issues/33) [#32](https://github.com/latticexyz/mud/issues/32) [#34](https://github.com/latticexyz/mud/issues/34) [#35](https://github.com/latticexyz/mud/issues/35) [#36](https://github.com/latticexyz/mud/issues/36) [#37](https://github.com/latticexyz/mud/issues/37) [#39](https://github.com/latticexyz/mud/issues/39) [#40](https://github.com/latticexyz/mud/issues/40) [#41](https://github.com/latticexyz/mud/issues/41) [#42](https://github.com/latticexyz/mud/issues/42) [#43](https://github.com/latticexyz/mud/issues/43) [#44](https://github.com/latticexyz/mud/issues/44) [#45](https://github.com/latticexyz/mud/issues/45) [#46](https://github.com/latticexyz/mud/issues/46) [#48](https://github.com/latticexyz/mud/issues/48) [#49](https://github.com/latticexyz/mud/issues/49) [#50](https://github.com/latticexyz/mud/issues/50)
-- **solecs:** create getUniqueEntityId function on World contract ([#4](https://github.com/latticexyz/mud/issues/4)) ([a06a9c5](https://github.com/latticexyz/mud/commit/a06a9c5ac1efb20eb61c459dabd00245d988de30))
-
-### BREAKING CHANGES
-
-- Components have to implement a getSchema() function
-
-- feat(network): make Sync worker return a stream of ECS events (prev contract events)
-
-- feat(ri-contracts): integrate solecs change (add getSchema to components)
-
-- feat(ri-client): integrate network package changes
-
-- feat(network): store ECS state in cache
-
-- feat(network): load state from cache
-
-- feat(utils): add more utils for iterables
-
-- refactor(network): clean up
-
-- feat(network): generalize component value decoder function, add tests
-
-- fix(network): make it possible to subscribe to ecsStream from sync worker multiple times
-
-- fix(network): start sync from provided initial block number
-
-- feat(network): move storing ecs to indexDB to its own Cache worker
-
-- feat(network): create separate cache for every World contract address
-
-- fix(network): fix issues discovered during live review
-
-- chore: remove unused import
-
-- Update packages/network/src/createBlockNumberStream.ts
-
-Co-authored-by: ludens
-
-- feat(network): add clock syncInterval as config parameter
-
-- feat(utils): emit values through componentToStream and observableToStream only if non-null
-
-- feat(network): add chain id to cache id, disable loading from cache on hardhat
-
-- fix(contracts): change Position and EntityType schema to int32/uint32 to fit in js number
-
-- docs(client): fix typos in comments
-
-- fix(network): fix tests
-
-- fix(scripting): integrate new network package into ri scripting
-
-- fix(network): fix sending multiple requests for component schema if many events get reduced
-
-## [0.1.8](https://github.com/latticexyz/mud/compare/v0.1.7...v0.1.8) (2022-05-25)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-## [0.1.7](https://github.com/latticexyz/mud/compare/v0.1.6...v0.1.7) (2022-05-25)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-## [0.1.6](https://github.com/latticexyz/mud/compare/v0.1.5...v0.1.6) (2022-05-25)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-## [0.1.5](https://github.com/latticexyz/mud/compare/v0.1.4...v0.1.5) (2022-05-24)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-## [0.1.4](https://github.com/latticexyz/mud/compare/v0.1.3...v0.1.4) (2022-05-24)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-## [0.1.3](https://github.com/latticexyz/mud/compare/v0.1.2...v0.1.3) (2022-05-23)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-## [0.1.2](https://github.com/latticexyz/mud/compare/v0.1.1...v0.1.2) (2022-05-23)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-## [0.1.1](https://github.com/latticexyz/mud/compare/v0.1.0...v0.1.1) (2022-05-23)
-
-**Note:** Version bump only for package @latticexyz/solecs
-
-# 0.1.0 (2022-05-23)
-
-### Bug Fixes
-
-- **@mud/solecs:** early return from Component.remove if value does not exist ([02f78c1](https://github.com/latticexyz/mud/commit/02f78c1114f311196928d565cd271c2243b1e9ef))
-
-### Features
-
-- **@mud/solecs:** add @mud/solecs ([84f05f0](https://github.com/latticexyz/mud/commit/84f05f00540c411eb15cdb8139127fd64fa118cc))
-- **@mud/solecs:** add advanced queries with support for relationships ([e56f6f4](https://github.com/latticexyz/mud/commit/e56f6f42163653efd53f11e019eb502d41bd3a2b))
-
-### Performance Improvements
-
-- **@mud/solecs:** add MapSet.sol to improve solecs Component performance (reduce gas) ([678c7ac](https://github.com/latticexyz/mud/commit/678c7aca0db785e2c7df3ab6124c674dac1279ca))
diff --git a/packages/solecs/README.md b/packages/solecs/README.md
deleted file mode 100644
index 25e129720f..0000000000
--- a/packages/solecs/README.md
+++ /dev/null
@@ -1,283 +0,0 @@
-# solecs - Solidity Entity Component System
-
-`solecs` is a framework to build highly composable, extendable and maintainable on-chain Worlds.
-
-It is designed around the Entity Component System architecture pattern. To build some fundamental intuition around ECS, have a look at [our MUD ECS introduction](https://mud.dev/blog/ecs).
-
-`solecs` is seamlessly integrated with the other MUD libraries, but can be used independently.
-
-# Features
-
-- Fully on-chain ECS
-- Powerful queries, including advanced recursive or indirect relationship queries
-- Seamless integration with other MUD libraries and services
-- Simple API
-
-# Concepts
-
-## World
-
-The `World` contract is at the core of every on-chain world.
-Entities, components and systems are registered in the `World`.
-Components register updates to their state via the `registerComponentValueSet` and `registerComponentValueRemoved` methods, which emit the `ComponentValueSet` and `ComponentValueRemoved` events respectively.
-Clients can reconstruct the entire state (of all components) by listening to these two events, instead of having to add a separate getter or event listener for every type of data. (Have a look at the MUD network package for a TypeScript implementation of contract/client state sync.)
-
-The `World` is an ownerless and permissionless contract.
-Anyone can register new components and systems in the world (via the `registerComponent` and `registerSystem` methods).
-Clients decide which components and systems they care about.
-
-```solidity
-interface IWorld {
- function registerComponent(address componentAddr, uint256 id) external;
-
- function registerSystem(address systemAddr, uint256 id) external;
-
- function registerComponentValueSet(address component, uint256 entity, bytes calldata data) external;
-
- function registerComponentValueRemoved(address component, uint256 entity) external;
-
- function components() external view returns (IUint256Component);
-
- function systems() external view returns (IUint256Component);
-
- function getNumEntities() external view returns (uint256);
-
- function hasEntity(uint256 entity) external view returns (bool);
-
- function getUniqueEntityId() external view returns (uint256);
-
- function query(WorldQueryFragment[] calldata worldQueryFragments) external view returns (uint256[] memory);
-}
-```
-
-## Entities
-
-An entity is just a `uint256` id.
-While any `uint256` is a valid id, `uint256`s from 0 to 2160 are reserved for Ethereum addresses as a convention.
-This allows every contract and EOA to be a valid entity.
-
-A simple use-case of this convention is being able to represent components and systems (both of which are contracts) as entities (with their entity id being their contract address).
-This allows them to be stored in "registry components" in the World, which means every component and system is automatically known to the client via the standardized contract/client sync described in the [World section](#world). Pretty meta.
-
-## Components
-
-Components are a key-value store from entity id to component value.
-Each component is its own contract.
-This allows components to be deployed independently from each other.
-
-Components have an owner, who can grant write access to more addresses.
-(Systems that want to write to a component need to be given write access first.)
-Everyone has read access.
-
-For convenience the component implementation in `solecs` also includes a reverse mapping from `keccak256(value)` to set of entities with this value, but this is not strictly required and might change in a future release.
-
-```solidity
-interface IComponent is IOwnableWritable {
- /** Return the keys and value types of the schema of this component. */
- function getSchema() external pure returns (string[] memory keys, LibTypes.SchemaValue[] memory values);
-
- function set(uint256 entity, bytes memory value) external;
-
- function remove(uint256 entity) external;
-
- function has(uint256 entity) external view returns (bool);
-
- function getRawValue(uint256 entity) external view returns (bytes memory);
-
- function getEntities() external view returns (uint256[] memory);
-
- function getEntitiesWithValue(bytes memory value) external view returns (uint256[] memory);
-
- function registerIndexer(address indexer) external;
-}
-```
-
-To have a common interface, the base component contract stores values as raw bytes.
-For a typed component that is easier to work with, extend the base component class and add typed `getValue`, `set` and `getEnttiiesWithValue` methods.
-
-Example `PositionComponent.sol`:
-
-```solidity
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.0;
-
-import { Component } from "solecs/Component.sol";
-
-struct Coord {
- int64 x;
- int64 y;
-}
-
-uint256 constant ID = uint256(keccak256("example.component.Position"));
-
-contract PositionComponent is Component {
- constructor(address world) Component(world, ID) {}
-
- function set(uint256 entity, Coord calldata value) public {
- set(entity, abi.encode(value));
- }
-
- function getValue(uint256 entity) public view returns (Coord memory) {
- return abi.decode(getRawValue(entity), (Coord));
- }
-
- function getEntitiesWithValue(Coord calldata value) public view returns (uint256[] memory) {
- return getEntitiesWithValue(abi.encode(value));
- }
-}
-```
-
-To allow clients to automatically create a decoder for the abi-encoded raw component value, add an optional `getSchema` method:
-
-```
-contract PositionComponent is Component {
-
- ...
-
- function getSchema() public pure override returns (string[] memory keys, LibTypes.SchemaValue[] memory values) {
- keys[0] = "x";
- values[0] = LibTypes.SchemaValue.INT64;
-
- keys[1] = "y";
- values[1] = LibTypes.SchemaValue.INT64;
- }
-}
-```
-
-Components are registered in the World contract and also register updates to their state in the World contract.
-(This happens automatically when extending the `Component.sol` base contract).
-
-## Systems
-
-System are contracts with a single `execute` function.
-
-```solidity
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.0;
-
-import "./IERC173.sol";
-
-interface ISystem is IERC173 {
- function execute(bytes memory arguments) external returns (bytes memory);
-}
-```
-
-For convenience adding a typed `executeTyped` method taking care of abi-encoding the arguments is recommended.
-
-Like components, systems are registered on the World contract to allow clients to automatically sync their contract address.
-
-In the `solecs` `System.sol` base contract, the system is initialized with a reference to the World contract and the world's component registry.
-Systems have read access to every component, but need to be granted write access to components they should modify.
-
-Example `MoveSystem.sol`:
-
-```solidity
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.0;
-
-import "solecs/System.sol";
-import { IWorld } from "solecs/interfaces/IWorld.sol";
-import { IUint256Component } from "solecs/interfaces/IUint256Component.sol";
-import { IComponent } from "solecs/interfaces/IComponent.sol";
-import { getAddressById } from "solecs/utils.sol";
-
-import { PositionComponent, ID as PositionComponentID, Coord } from "./PositionComponent.sol";
-
-uint256 constant ID = uint256(keccak256("ember.system.move"));
-
-contract MoveSystem is System {
- constructor(IUint256Component _components, IWorld _world) System(_components, _world) {}
-
- function execute(bytes memory arguments) public returns (bytes memory) {
- (uint256 entity, Coord memory targetPosition) = abi.decode(arguments, (uint256, Coord));
-
- PositionComponent position = PositionComponent(getAddressById(components, PositionComponentID));
- position.set(entity, targetPosition);
- }
-
- function executeTyped(uint256 entity, Coord memory targetPosition) public returns (bytes memory) {
- return execute(abi.encode(entity, targetPosition));
- }
-}
-```
-
-## Queries
-
-Queries provide a simple API to get a list of entities matching certain specified criteria.
-A query consists of a list of query fragments.
-A query fragment is a struct with three fields:
-
-```solidity
-struct QueryFragment {
- QueryType queryType;
- IComponent component;
- bytes value;
-}
-```
-
-Available query fragments are:
-
-- `Has`: filter for entities that have the specified component. The `value` field in the query fragment is ignored.
-- `HasValue`: filter for entities that have the specified component with the specified value.
-- `Not`: filter for entities that do not have the specified component. The `value` field in th query fragment is ignored.
-- `NotValue`: filter for entities that do not have the specified component with the specified value.
-- `ProxyRead`: enable the proxy read mode for the rest of the query (more details below).
-- `ProxyExpand`: enable the proxy expand mode for the rest of the query (more details below).
-
-The query fragments are executed from left to right and are concatenated with a logical `AND`.
-For performance reasons, the most restrictive query fragment should be first in the list of query fragments,
-in order to reduce the number of entities the next query fragment needs to be checked for.
-If no proxy fragments are used, every entity in the resulting set passes every query fragment.
-If setting fragments are used, the order of the query fragments influences the result, since settings only apply to
-fragments after the setting fragment.
-
-Example: Query for all movable entities at position (0,0):
-
-```solidity
-QueryFragment[] memory fragments = new QueryFragment[](2);
-
-// Specify the more restrictive filter first for performance reasons
-fragments[0] = QueryFragment(QueryType.HasValue, position, abi.encode(Coord(0,0)));
-
-// The value argument is ignored in Has query fragments
-fragments[1] = QueryFragment(QueryType.Has, movable, new bytes(0));
-
-uint256[] memory entities = LibQuery.query(fragments);
-```
-
-### Proxy queries
-
-Proxy query fragments provide a way to query for more advanced recursive or indirect relationships.
-
-The `ProxyRead` query fragment enables the "proxy read mode" for the rest of the query.
-This means that for all remaining fragments in the query not only the entities themselves are checked, but also their "ancestors" up to the given depth (specified in the `value` field of the query fragment) on the relationship chain defined by the given `component`.
-The `component` must be a `Uint256Component` (a component whose raw value decodes to a single `uint256` that points to another entity).
-
-Example: Query for all entities that have a `position` and are (directly or indirectly) owned by an entity with `name` "Alice":
-
-```solidity
-QueryFragment[] memory fragments = new QueryFragment[](3);
-
-fragments[0] = QueryFragment(QueryType.Has, position, new bytes(0)));
-fragments[1] = QueryFragment(QueryType.ProxyRead, ownedBy, abi.encode(0xff)); // Max depth 255
-fragments[2] = QueryFragment(QueryType.HasValue, name, abi.encode("Alice"));
-
-uint256[] memory entities = LibQuery.query(fragments);
-```
-
-The `ProxyExpand` query fragment enables the "proxy expand mode" for the rest of the query.
-This means that for all remaining fragments in the query not only the matching entities themselves are included in the intermediate set, but also all their "children" down to the given depth (specified in the `value` field of the query fragment) on the relationship chain define by the given `component`.
-The `component` must be a `Uint256Component` (a component whose raw value decodes to a single `uint256` that points to another entity).
-
-Example: Query for all entities (directly or indirectly) owned by an entity with `name` "Alice":
-
-```solidity
-QueryFragment[] memory fragments = new QueryFragment[](2);
-
-fragments[0] = QueryFragment(QueryType.ProxyExpand, ownedBy, abi.encode(0xff))); // Max depth 255
-fragments[1] = QueryFragment(QueryType.HasValue, name, abi.encode("Alice"));
-
-uint256[] memory entities = LibQuery.query(fragments);
-```
-
-Proxy queries are significantly less performant (more gas intensive) than regular queries and should be used sparingly.
diff --git a/packages/solecs/foundry.toml b/packages/solecs/foundry.toml
deleted file mode 100644
index 7a043f37bf..0000000000
--- a/packages/solecs/foundry.toml
+++ /dev/null
@@ -1,10 +0,0 @@
-[profile.default]
-solc_version = "0.8.13"
-ffi = false
-fuzz_runs = 256
-optimizer = true
-optimizer_runs = 3000
-verbosity = 2
-allow_paths = ["../../node_modules"]
-src = "src"
-out = "out"
diff --git a/packages/solecs/hardhat.config.ts b/packages/solecs/hardhat.config.ts
deleted file mode 100644
index 32338a8fe1..0000000000
--- a/packages/solecs/hardhat.config.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-import { HardhatUserConfig } from "hardhat/config";
-import "./tasks/compile";
-
-const config: HardhatUserConfig = {
- paths: {
- sources: "./src",
- },
- solidity: {
- version: "0.8.13",
- settings: {
- optimizer: {
- enabled: true,
- runs: 200,
- },
- },
- },
-};
-
-export default config;
diff --git a/packages/solecs/index.ts b/packages/solecs/index.ts
deleted file mode 100644
index cb0ff5c3b5..0000000000
--- a/packages/solecs/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export {};
diff --git a/packages/solecs/package.json b/packages/solecs/package.json
index a1a70aab81..49906b2d47 100644
--- a/packages/solecs/package.json
+++ b/packages/solecs/package.json
@@ -1,39 +1,5 @@
{
"name": "@latticexyz/solecs",
"version": "2.0.0-next.3",
- "description": "Solidity Entity Component System",
- "repository": {
- "type": "git",
- "url": "https://github.com/latticexyz/mud.git",
- "directory": "packages/solecs"
- },
- "license": "MIT",
- "types": "./types/ethers-contracts/",
- "scripts": {
- "build": "pnpm run build:abi && pnpm run build:typechain",
- "build:abi": "forge build --extra-output-files abi --out abi --skip test script",
- "build:typechain": "rimraf abi/ownable && typechain --target ethers-v5 'abi/**/*.sol/!(*.abi).json'",
- "clean": "pnpm run clean:abi && pnpm run clean:typechain",
- "clean:abi": "rimraf abi",
- "clean:typechain": "rimraf types",
- "lint": "solhint --config ./.solhint.json 'src/**/*.sol'",
- "test": "forge test"
- },
- "dependencies": {
- "@ethersproject/abi": "^5.7.0",
- "@ethersproject/providers": "^5.7.2",
- "@solidstate/contracts": "^0.0.52",
- "ds-test": "https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0",
- "ethers": "^5.7.2",
- "memmove": "https://github.com/dk1a/memmove.git#ffd71cd77b1708574ef46a667b23ca3a5cc9fa27",
- "solmate": "https://github.com/transmissions11/solmate.git#9cf1428245074e39090dceacb0c28b1f684f584c"
- },
- "devDependencies": {
- "@typechain/ethers-v5": "^10.2.0",
- "forge-std": "https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1",
- "hardhat": "^2.10.2",
- "solhint": "^3.3.7",
- "typechain": "^8.1.1"
- },
- "gitHead": "914a1e0ae4a573d685841ca2ea921435057deb8f"
+ "private": true
}
diff --git a/packages/solecs/remappings.txt b/packages/solecs/remappings.txt
deleted file mode 100644
index 72364280b1..0000000000
--- a/packages/solecs/remappings.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-memmove/=node_modules/memmove/src/
-ds-test/=node_modules/ds-test/src/
-forge-std/=node_modules/forge-std/src/
-solmate/=node_modules/solmate/src
-@solidstate/=node_modules/@solidstate/
diff --git a/packages/solecs/src/BareComponent.sol b/packages/solecs/src/BareComponent.sol
deleted file mode 100644
index cd85eecace..0000000000
--- a/packages/solecs/src/BareComponent.sol
+++ /dev/null
@@ -1,129 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.0;
-
-import { IWorld } from "./interfaces/IWorld.sol";
-import { IComponent } from "./interfaces/IComponent.sol";
-
-import { Set } from "./Set.sol";
-import { MapSet } from "./MapSet.sol";
-import { LibTypes } from "./LibTypes.sol";
-
-import { OwnableWritable } from "./OwnableWritable.sol";
-
-/**
- * Components are a key-value store from entity id to component value.
- * They are registered in the World and register updates to their state in the World.
- * They have an owner, who can grant write access to more addresses.
- * (Systems that want to write to a component need to be given write access first.)
- * Everyone has read access.
- */
-abstract contract BareComponent is IComponent, OwnableWritable {
- error BareComponent__NotImplemented();
-
- /** Reference to the World contract this component is registered in */
- address public world;
-
- /** Mapping from entity id to value in this component */
- mapping(uint256 => bytes) internal entityToValue;
-
- /** Public identifier of this component */
- uint256 public id;
-
- constructor(address _world, uint256 _id) {
- id = _id;
- if (_world != address(0)) registerWorld(_world);
- }
-
- /**
- * Register this component in the given world.
- * @param _world Address of the World contract.
- */
- function registerWorld(address _world) public onlyOwner {
- world = _world;
- IWorld(world).registerComponent(address(this), id);
- }
-
- /**
- * Set the given component value for the given entity.
- * Registers the update in the World contract.
- * Can only be called by addresses with write access to this component.
- * @param entity Entity to set the value for.
- * @param value Value to set for the given entity.
- */
- function set(uint256 entity, bytes memory value) public override onlyWriter {
- _set(entity, value);
- }
-
- /**
- * Remove the given entity from this component.
- * Registers the update in the World contract.
- * Can only be called by addresses with write access to this component.
- * @param entity Entity to remove from this component.
- */
- function remove(uint256 entity) public override onlyWriter {
- _remove(entity);
- }
-
- /**
- * Check whether the given entity has a value in this component.
- * @param entity Entity to check whether it has a value in this component for.
- */
- function has(uint256 entity) public view virtual override returns (bool) {
- return entityToValue[entity].length != 0;
- }
-
- /**
- * Get the raw (abi-encoded) value of the given entity in this component.
- * @param entity Entity to get the raw value in this component for.
- */
- function getRawValue(uint256 entity) public view virtual override returns (bytes memory) {
- // Return the entity's component value
- return entityToValue[entity];
- }
-
- /** Not implemented in BareComponent */
- function getEntities() public view virtual override returns (uint256[] memory) {
- revert BareComponent__NotImplemented();
- }
-
- /** Not implemented in BareComponent */
- function getEntitiesWithValue(bytes memory) public view virtual override returns (uint256[] memory) {
- revert BareComponent__NotImplemented();
- }
-
- /** Not implemented in BareComponent */
- function registerIndexer(address) external virtual override {
- revert BareComponent__NotImplemented();
- }
-
- /**
- * Set the given component value for the given entity.
- * Registers the update in the World contract.
- * Can only be called internally (by the component or contracts deriving from it),
- * without requiring explicit write access.
- * @param entity Entity to set the value for.
- * @param value Value to set for the given entity.
- */
- function _set(uint256 entity, bytes memory value) internal virtual {
- // Store the entity's value;
- entityToValue[entity] = value;
-
- // Emit global event
- IWorld(world).registerComponentValueSet(entity, value);
- }
-
- /**
- * Remove the given entity from this component.
- * Registers the update in the World contract.
- * Can only be called internally (by the component or contracts deriving from it),
- * without requiring explicit write access.
- * @param entity Entity to remove from this component.
- */
- function _remove(uint256 entity) internal virtual {
- // Remove the entity from the mapping
- delete entityToValue[entity];
-
- // Emit global event
- IWorld(world).registerComponentValueRemoved(entity);
- }
-}
diff --git a/packages/solecs/src/Component.sol b/packages/solecs/src/Component.sol
deleted file mode 100644
index fd092d6e20..0000000000
--- a/packages/solecs/src/Component.sol
+++ /dev/null
@@ -1,106 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.0;
-
-import { IEntityIndexer } from "./interfaces/IEntityIndexer.sol";
-import { IWorld } from "./interfaces/IWorld.sol";
-import { BareComponent } from "./BareComponent.sol";
-
-import { Set } from "./Set.sol";
-import { MapSet } from "./MapSet.sol";
-import { LibTypes } from "./LibTypes.sol";
-
-/**
- * Components are a key-value store from entity id to component value.
- * They are registered in the World and register updates to their state in the World.
- * They have an owner, who can grant write access to more addresses.
- * (Systems that want to write to a component need to be given write access first.)
- * Everyone has read access.
- */
-abstract contract Component is BareComponent {
- /** Set of entities with values in this component */
- Set internal entities;
-
- /** Reverse mapping from value to set of entities */
- MapSet internal valueToEntities;
-
- /** List of indexers to be updated when a component value changes */
- IEntityIndexer[] internal indexers;
-
- constructor(address _world, uint256 _id) BareComponent(_world, _id) {
- entities = new Set();
- valueToEntities = new MapSet();
- }
-
- /**
- * @inheritdoc BareComponent
- */
- function has(uint256 entity) public view virtual override returns (bool) {
- return entities.has(entity);
- }
-
- /**
- * Get a list of all entities that have a value in this component.
- */
- function getEntities() public view virtual override returns (uint256[] memory) {
- return entities.getItems();
- }
-
- /**
- * Get a list of all entities that have the specified value in this component.
- * @param value Abi-encoded value to get the list of entities with this value for.
- */
- function getEntitiesWithValue(bytes memory value) public view virtual override returns (uint256[] memory) {
- // Return all entities with this component value
- return valueToEntities.getItems(uint256(keccak256(value)));
- }
-
- /**
- * Register a new indexer that gets notified when a component value is set.
- * @param indexer Address of the indexer to notify when a component value is set.
- */
- function registerIndexer(address indexer) external virtual override onlyWriter {
- indexers.push(IEntityIndexer(indexer));
- }
-
- /**
- * @inheritdoc BareComponent
- */
- function _set(uint256 entity, bytes memory value) internal virtual override {
- // Store the entity
- entities.add(entity);
-
- // Remove the entity from the previous reverse mapping if there is one
- valueToEntities.remove(uint256(keccak256(entityToValue[entity])), entity);
-
- // Add the entity to the new reverse mapping
- valueToEntities.add(uint256(keccak256(value)), entity);
-
- // Store the entity's value; Emit global event
- super._set(entity, value);
-
- for (uint256 i = 0; i < indexers.length; i++) {
- indexers[i].update(entity, value);
- }
- }
-
- /**
- * @inheritdoc BareComponent
- */
- function _remove(uint256 entity) internal virtual override {
- // If there is no entity with this value, return
- if (valueToEntities.size(uint256(keccak256(entityToValue[entity]))) == 0) return;
-
- // Remove the entity from the reverse mapping
- valueToEntities.remove(uint256(keccak256(entityToValue[entity])), entity);
-
- // Remove the entity from the entity list
- entities.remove(entity);
-
- // Remove the entity from the mapping; Emit global event
- super._remove(entity);
-
- for (uint256 i = 0; i < indexers.length; i++) {
- indexers[i].remove(entity);
- }
- }
-}
diff --git a/packages/solecs/src/Indexer.sol b/packages/solecs/src/Indexer.sol
deleted file mode 100644
index 42b6dd6279..0000000000
--- a/packages/solecs/src/Indexer.sol
+++ /dev/null
@@ -1,150 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.0;
-
-import { IERC165 } from "./interfaces/IERC165.sol";
-import { IEntityContainer } from "./interfaces/IEntityContainer.sol";
-import { IEntityIndexer } from "./interfaces/IEntityIndexer.sol";
-
-import { Set } from "./Set.sol";
-import { Component } from "./Component.sol";
-
-contract Indexer is IEntityIndexer, IERC165 {
- Set private entities;
- mapping(bytes => address) internal valueToEntities;
- mapping(uint256 => bytes) internal entityToValue;
- Component[] private components;
- bool[] private trackValueForComponent;
-
- constructor(Component[] memory _components, bool[] memory _trackValueForComponent) {
- components = _components;
- trackValueForComponent = _trackValueForComponent;
- entities = new Set();
- }
-
- function update(uint256 entity, bytes memory value) external {
- Component component = Component(msg.sender);
- bytes[] memory values = new bytes[](components.length);
- uint256 index;
- bool foundSenderComponent;
-
- for (uint256 i; i < components.length; i++) {
- if (components[i] == component) {
- foundSenderComponent = true;
- }
- }
-
- require(foundSenderComponent, "Message Sender is not indexed!");
-
- // If data for entity doesn't exist yet create it
- if (entityToValue[entity].length == 0) {
- // Get all component values from ECS
- for (uint256 i = 0; i < components.length; i++) {
- // Get ECS Value (or set new value)
- values[i] = components[i] == component ? value : components[i].getRawValue(entity);
-
- // If one of the tracked values does not exist yet we can't index
- if (values[i].length == 0) {
- return;
- }
-
- // Ignore non tracked values
- if (!trackValueForComponent[i]) {
- values[i] = new bytes(0);
- }
- }
-
- _set(entity, values);
- return;
- }
-
- // Get index of current component
- for (uint256 i; i < components.length; i++) {
- if (components[i] == component) {
- index = i;
- }
- }
-
- values = abi.decode(entityToValue[entity], (bytes[]));
- // Set value at index
- values[index] = value;
-
- // Remove old value
- Set(valueToEntities[entityToValue[entity]]).remove(entity);
-
- // Add new value
- bytes memory indexerValue = abi.encode(values);
-
- entityToValue[entity] = indexerValue;
-
- // Store the reverse mapping
- if (valueToEntities[indexerValue] == address(0)) {
- valueToEntities[indexerValue] = address(new Set());
- }
- Set(valueToEntities[indexerValue]).add(entity);
- }
-
- function remove(uint256 entity) external {
- Component component = Component(msg.sender);
- bool foundSenderComponent;
-
- for (uint256 i; i < components.length; i++) {
- if (components[i] == component) {
- foundSenderComponent = true;
- }
- }
-
- require(foundSenderComponent, "Message Sender is not indexed!");
-
- // If there is no entity with this value, return
- if (!has(entity)) return;
-
- // Remove the entity from the reverse mapping
- Set(valueToEntities[entityToValue[entity]]).remove(entity);
-
- // Remove the entity from the entity list
- entities.remove(entity);
-
- // Remove the entity from the mapping
- delete entityToValue[entity];
- }
-
- function supportsInterface(bytes4 interfaceId) external view returns (bool) {
- return interfaceId == type(IERC165).interfaceId || interfaceId == type(IEntityIndexer).interfaceId;
- }
-
- function getEntities() external view returns (uint256[] memory) {
- return entities.getItems();
- }
-
- function getEntitiesWithValue(bytes memory value) external view returns (uint256[] memory) {
- if (valueToEntities[value] == address(0)) {
- return new uint256[](0);
- }
-
- // Return all entities with this component value
- return Set(valueToEntities[value]).getItems();
- }
-
- function has(uint256 entity) public view returns (bool) {
- return entities.has(entity);
- }
-
- function _set(uint256 entity, bytes[] memory newValues) internal {
- require(newValues.length == components.length, "Need values for all components.");
-
- // Store the entity
- entities.add(entity);
-
- bytes memory indexerValue = abi.encode(newValues);
-
- // Store the entity's value;
- entityToValue[entity] = indexerValue;
-
- // Store the reverse mapping
- if (valueToEntities[indexerValue] == address(0)) {
- valueToEntities[indexerValue] = address(new Set());
- }
-
- Set(valueToEntities[indexerValue]).add(entity);
- }
-}
diff --git a/packages/solecs/src/LibQuery.sol b/packages/solecs/src/LibQuery.sol
deleted file mode 100644
index ffe71c62b3..0000000000
--- a/packages/solecs/src/LibQuery.sol
+++ /dev/null
@@ -1,352 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.13;
-
-import { IComponent } from "./interfaces/IComponent.sol";
-import { QueryFragment, QueryType } from "./interfaces/Query.sol";
-import { LinkedList, LinkedListLib } from "memmove/LinkedList.sol";
-
-struct Uint256Node {
- uint256 value;
- uint256 next;
-}
-
-function pointer(Uint256Node memory a) pure returns (bytes32 ptr) {
- /// @solidity memory-safe-assembly
- assembly {
- ptr := a
- }
-}
-
-function fromPointer(bytes32 ptr) pure returns (Uint256Node memory a) {
- /// @solidity memory-safe-assembly
- assembly {
- a := ptr
- }
-}
-
-function isPositiveFragment(QueryFragment memory fragment) pure returns (bool) {
- return fragment.queryType == QueryType.Has || fragment.queryType == QueryType.HasValue;
-}
-
-function isNegativeFragment(QueryFragment memory fragment) pure returns (bool) {
- return fragment.queryType == QueryType.Not || fragment.queryType == QueryType.NotValue;
-}
-
-function isSettingFragment(QueryFragment memory fragment) pure returns (bool) {
- return fragment.queryType == QueryType.ProxyRead || fragment.queryType == QueryType.ProxyExpand;
-}
-
-function isEntityFragment(QueryFragment memory fragment) pure returns (bool) {
- return
- fragment.queryType == QueryType.Has ||
- fragment.queryType == QueryType.HasValue ||
- fragment.queryType == QueryType.Not ||
- fragment.queryType == QueryType.NotValue;
-}
-
-function passesQueryFragment(uint256 entity, QueryFragment memory fragment) view returns (bool) {
- if (fragment.queryType == QueryType.Has) {
- // Entity must have given component
- return fragment.component.has(entity);
- }
-
- if (fragment.queryType == QueryType.HasValue) {
- // Entity must have the given component value
- return keccak256(fragment.value) == keccak256(fragment.component.getRawValue(entity));
- }
-
- if (fragment.queryType == QueryType.Not) {
- // Entity must not have the given value
- return !fragment.component.has(entity);
- }
-
- if (fragment.queryType == QueryType.NotValue) {
- // Entity must not have the given component value
- return keccak256(fragment.value) != keccak256(fragment.component.getRawValue(entity));
- }
-
- require(isEntityFragment(fragment), "NO_ENTITY_FRAGMENT");
- return false;
-}
-
-function passesQueryFragmentProxy(
- uint256 entity,
- QueryFragment memory fragment,
- QueryFragment memory proxyRead
-) view returns (bool passes, bool proxyFound) {
- require(isEntityFragment(fragment), "NO_ENTITY_FRAGMENT");
- require(proxyRead.queryType == QueryType.ProxyRead, "NO_PROXY_READ_FRAGMENT");
-
- uint256 proxyEntity = entity;
-
- for (uint256 i; i < abi.decode(proxyRead.value, (uint256)); i++) {
- // If the current entity does not have the proxy component, abort
- if (!proxyRead.component.has(proxyEntity)) {
- return (passes, false);
- }
-
- // Move up the proxy chain
- proxyEntity = abi.decode(proxyRead.component.getRawValue(proxyEntity), (uint256));
- passes = passesQueryFragment(proxyEntity, fragment);
-
- if (isBreakingPassState(passes, fragment)) {
- return (passes, true);
- }
- }
- return (passes, true);
-}
-
-/**
- * For positive fragments (Has/HasValue) we need to find any passing entity up the proxy chain
- * so as soon as passes is true, we can early return. For negative fragments (Not/NotValue) every entity
- * up the proxy chain must pass, so we can early return if we find one that doesn't pass.
- */
-function isBreakingPassState(bool passes, QueryFragment memory fragment) pure returns (bool) {
- return (passes && isPositiveFragment(fragment)) || (!passes && isNegativeFragment(fragment));
-}
-
-struct QueryVars {
- LinkedList entities;
- uint256 numEntities;
- QueryFragment proxyRead;
- QueryFragment proxyExpand;
- bool initialFragment;
-}
-
-library LibQuery {
- using LinkedListLib for LinkedList;
-
- /**
- * Execute the given query and return a list of entity ids
- * @param fragments List of query fragments to execute
- * @return entities List of entities matching the query
- */
- function query(QueryFragment[] memory fragments) internal view returns (uint256[] memory) {
- QueryVars memory v;
- v.entities = LinkedListLib.newLinkedList(32);
- v.numEntities = 0;
- v.proxyRead;
- v.proxyExpand;
- v.initialFragment = true;
-
- // Process fragments
- for (uint256 i; i < fragments.length; i++) {
- QueryFragment memory fragment = fragments[i];
- if (isSettingFragment(fragment)) {
- // Store setting fragments for subsequent query fragments
- if (fragment.queryType == QueryType.ProxyRead) v.proxyRead = fragment;
- if (fragment.queryType == QueryType.ProxyExpand) v.proxyExpand = fragment;
- } else if (v.initialFragment) {
- // Handle entity query fragments
- // First regular fragment must be Has or HasValue
- require(isPositiveFragment(fragment), "NEGATIVE_INITIAL_FRAGMENT");
- v.initialFragment = false;
-
- // Create the first interim result
- uint256[] memory entityArray = fragment.queryType == QueryType.Has
- ? fragment.component.getEntities()
- : fragment.component.getEntitiesWithValue(fragment.value);
-
- v.entities = arrayToList(entityArray);
- v.numEntities = entityArray.length;
-
- // Add entity's children up to the specified depth if proxy expand is active,
- if ((address(v.proxyExpand.component) != address(0)) && abi.decode(v.proxyExpand.value, (uint256)) > 0) {
- for (uint256 ctr; ctr < entityArray.length; ctr++) {
- uint256[] memory childEntities = getChildEntities(
- entityArray[ctr],
- v.proxyExpand.component,
- abi.decode(v.proxyExpand.value, (uint256))
- );
-
- for (uint256 childIndex; childIndex < childEntities.length; childIndex++) {
- v.entities = v.entities.push_and_link(pointer(Uint256Node(childEntities[childIndex], 0)));
- v.numEntities++;
- }
- }
- }
- } else {
- // There already is an interim result, apply the current fragment
- LinkedList nextEntities = LinkedListLib.newLinkedList(32);
- uint256 nextNumEntities = 0;
- bool success = true;
- bytes32 element = v.entities.head();
-
- // Iterate through the current interim result
- while (success) {
- Uint256Node memory node = fromPointer(element);
- uint256 entity = node.value;
-
- // Branch 1: Simple / check if the current entity passes the query fragment
- bool passes = passesQueryFragment(entity, fragment);
-
- // Branch 2: Proxy upwards / check if proxy entity passes the query
- passes = _processProxyRead(v, fragment, entity, passes);
-
- // If the entity passes the query fragment, add it to the new interim result
- if (passes) {
- nextEntities = nextEntities.push_and_link(pointer(Uint256Node(entity, 0)));
- nextNumEntities++;
- }
-
- // Branch 3: Proxy downwards / run the query fragments on child entities if proxy expand is active
- (nextEntities, nextNumEntities) = _processProxyExpand(v, fragment, entity, nextEntities, nextNumEntities);
-
- // Move to the next entity
- (success, element) = v.entities.next(element);
- }
-
- // Update interim result
- v.entities = nextEntities;
- v.numEntities = nextNumEntities;
- }
- }
-
- return listToArray(v.entities, v.numEntities);
- }
-
- // Branch 2: Proxy upwards / check if proxy entity passes the query
- function _processProxyRead(
- QueryVars memory v,
- QueryFragment memory fragment,
- uint256 entity,
- bool passes
- ) internal view returns (bool) {
- if (
- address(v.proxyRead.component) != address(0) &&
- abi.decode(v.proxyRead.value, (uint256)) > 0 &&
- !isBreakingPassState(passes, fragment)
- ) {
- (bool newPasses, bool proxyFound) = passesQueryFragmentProxy(entity, fragment, v.proxyRead);
- if (proxyFound) return newPasses;
- }
- return passes;
- }
-
- // Branch 3: Proxy downwards / run the query fragments on child entities if proxy expand is active
- function _processProxyExpand(
- QueryVars memory v,
- QueryFragment memory fragment,
- uint256 entity,
- LinkedList nextEntities,
- uint256 nextNumEntities
- ) internal view returns (LinkedList, uint256) {
- if ((address(v.proxyExpand.component) != address(0)) && abi.decode(v.proxyExpand.value, (uint256)) > 0) {
- uint256[] memory childEntities = getChildEntities(
- entity,
- v.proxyExpand.component,
- abi.decode(v.proxyExpand.value, (uint256))
- );
-
- for (uint256 ctr; ctr < childEntities.length; ctr++) {
- uint256 childEntity = childEntities[ctr];
-
- // Add the child entity if it passes the direct check
- bool childPasses = passesQueryFragment(childEntity, fragment);
-
- // or if a proxy read is active and it passes the proxy read check
- if (
- !childPasses && address(v.proxyRead.component) != address(0) && abi.decode(v.proxyRead.value, (uint256)) > 0
- ) {
- (bool proxyPasses, bool proxyFound) = passesQueryFragmentProxy(childEntity, fragment, v.proxyRead);
- if (proxyFound) childPasses = proxyPasses;
- }
-
- if (childPasses) {
- nextEntities = nextEntities.push_and_link(pointer(Uint256Node(entity, 0)));
- nextNumEntities++;
- }
- }
- }
-
- return (nextEntities, nextNumEntities);
- }
-
- /**
- * Recursively computes all direct and indirect child entities up to the specified depth
- * @param entity Entity to get all child entities up to the specified depth
- * @param component Entity reference component
- * @param depth Depth up to which the recursion should be applied
- * @return Set of entities that are child entities of the given entity via the given component
- */
- function getChildEntities(
- uint256 entity,
- IComponent component,
- uint256 depth
- ) internal view returns (uint256[] memory) {
- if (depth == 0) return new uint256[](0);
-
- uint256[] memory directChildren = component.getEntitiesWithValue(abi.encode(entity));
- if (depth == 1) return directChildren;
-
- LinkedList indirectChildList = LinkedListLib.newLinkedList(32);
- uint256 numIndirectChildren = 0;
-
- for (uint256 i; i < directChildren.length; i++) {
- uint256[] memory indirectChildren = getChildEntities(directChildren[i], component, depth - 1);
- for (uint256 j; j < indirectChildren.length; j++) {
- indirectChildList = indirectChildList.push_and_link(pointer(Uint256Node(indirectChildren[j], 0)));
- numIndirectChildren++;
- }
- }
-
- uint256[] memory allChildren = listToArray(indirectChildList, numIndirectChildren + directChildren.length);
- for (uint256 i; i < directChildren.length; i++) {
- allChildren[numIndirectChildren + i] = directChildren[i];
- }
-
- return allChildren;
- }
-
- function getValueWithProxy(
- IComponent component,
- uint256 entity,
- IComponent proxyComponent,
- uint256 depth
- ) internal view returns (bytes memory value, bool found) {
- uint256 proxyEntity = entity;
- for (uint256 i; i <= depth; i++) {
- // Check if the current entity has the requested value
- if (component.has(proxyEntity)) return (component.getRawValue(proxyEntity), true);
-
- // Abort if the current entity has no value in the proxy component
- if (!proxyComponent.has(proxyEntity)) {
- return (new bytes(0), false);
- }
-
- // Move up the proxy chain
- proxyEntity = abi.decode(proxyComponent.getRawValue(proxyEntity), (uint256));
- }
-
- return (new bytes(0), false);
- }
-
- /**
- * Helper function to turn a linked list into an array
- */
- function listToArray(LinkedList list, uint256 length) public pure returns (uint256[] memory array) {
- array = new uint256[](length);
- if (length == 0) return array;
-
- bool success = true;
- bytes32 element = list.head();
- uint256 i = 0;
-
- while (success) {
- Uint256Node memory node = fromPointer(element);
- array[i] = node.value;
- i++;
- (success, element) = list.next(element);
- }
- }
-
- /**
- * Helper function to turn an array into a linked list
- */
- function arrayToList(uint256[] memory array) public pure returns (LinkedList list) {
- list = LinkedListLib.newLinkedList(32);
- for (uint256 i; i < array.length; i++) {
- list = list.push_and_link(pointer(Uint256Node(array[i], 0)));
- }
- }
-}
diff --git a/packages/solecs/src/LibTypes.sol b/packages/solecs/src/LibTypes.sol
deleted file mode 100644
index 7b0c155a3c..0000000000
--- a/packages/solecs/src/LibTypes.sol
+++ /dev/null
@@ -1,44 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.13;
-
-/**
- * Enum of supported schema types
- */
-library LibTypes {
- enum SchemaValue {
- BOOL,
- INT8,
- INT16,
- INT32,
- INT64,
- INT128,
- INT256,
- INT,
- UINT8,
- UINT16,
- UINT32,
- UINT64,
- UINT128,
- UINT256,
- BYTES,
- STRING,
- ADDRESS,
- BYTES4,
- BOOL_ARRAY,
- INT8_ARRAY,
- INT16_ARRAY,
- INT32_ARRAY,
- INT64_ARRAY,
- INT128_ARRAY,
- INT256_ARRAY,
- INT_ARRAY,
- UINT8_ARRAY,
- UINT16_ARRAY,
- UINT32_ARRAY,
- UINT64_ARRAY,
- UINT128_ARRAY,
- UINT256_ARRAY,
- BYTES_ARRAY,
- STRING_ARRAY
- }
-}
diff --git a/packages/solecs/src/MapSet.sol b/packages/solecs/src/MapSet.sol
deleted file mode 100644
index 755025bd75..0000000000
--- a/packages/solecs/src/MapSet.sol
+++ /dev/null
@@ -1,49 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.0;
-
-import { Ownable } from "./Ownable.sol";
-
-/**
- * Key value store with uint256 key and uint256 Set value
- */
-contract MapSet is Ownable {
- mapping(uint256 => uint256[]) internal items;
- mapping(uint256 => mapping(uint256 => uint256)) internal itemToIndex;
-
- function add(uint256 setKey, uint256 item) public onlyOwner {
- if (has(setKey, item)) return;
-
- itemToIndex[setKey][item] = items[setKey].length;
- items[setKey].push(item);
- }
-
- function remove(uint256 setKey, uint256 item) public onlyOwner {
- if (!has(setKey, item)) return;
-
- // Copy the last item to the given item's index
- items[setKey][itemToIndex[setKey][item]] = items[setKey][items[setKey].length - 1];
-
- // Update the moved item's stored index to the new index
- itemToIndex[setKey][items[setKey][itemToIndex[setKey][item]]] = itemToIndex[setKey][item];
-
- // Remove the given item's stored index
- delete itemToIndex[setKey][item];
-
- // Remove the last item
- items[setKey].pop();
- }
-
- function has(uint256 setKey, uint256 item) public view returns (bool) {
- if (items[setKey].length == 0) return false;
- if (itemToIndex[setKey][item] == 0) return items[setKey][0] == item;
- return itemToIndex[setKey][item] != 0;
- }
-
- function getItems(uint256 setKey) public view returns (uint256[] memory) {
- return items[setKey];
- }
-
- function size(uint256 setKey) public view returns (uint256) {
- return items[setKey].length;
- }
-}
diff --git a/packages/solecs/src/Ownable.sol b/packages/solecs/src/Ownable.sol
deleted file mode 100644
index 109e267ef7..0000000000
--- a/packages/solecs/src/Ownable.sol
+++ /dev/null
@@ -1,15 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.0;
-
-import { Ownable as SolidStateOwnable } from "@solidstate/contracts/access/ownable/Ownable.sol";
-import { OwnableStorage } from "@solidstate/contracts/access/ownable/OwnableStorage.sol";
-
-/**
- * IERC173 implementation
- */
-contract Ownable is SolidStateOwnable {
- constructor() {
- // Initialize owner (SolidState has no constructors)
- _setOwner(msg.sender);
- }
-}
diff --git a/packages/solecs/src/OwnableWritable.sol b/packages/solecs/src/OwnableWritable.sol
deleted file mode 100644
index ea6256c8d0..0000000000
--- a/packages/solecs/src/OwnableWritable.sol
+++ /dev/null
@@ -1,45 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.0;
-
-import { IOwnableWritable } from "./interfaces/IOwnableWritable.sol";
-
-import { Ownable } from "./Ownable.sol";
-import { OwnableWritableStorage } from "./OwnableWritableStorage.sol";
-
-/**
- * Ownable with authorized writers
- */
-abstract contract OwnableWritable is IOwnableWritable, Ownable {
- error OwnableWritable__NotWriter();
-
- /** Whether given operator has write access */
- function writeAccess(address operator) public view virtual returns (bool) {
- return OwnableWritableStorage.layout().writeAccess[operator] || operator == owner();
- }
-
- /** Revert if caller does not have write access to this component */
- modifier onlyWriter() {
- if (!writeAccess(msg.sender)) {
- revert OwnableWritable__NotWriter();
- }
- _;
- }
-
- /**
- * Grant write access to the given address.
- * Can only be called by the owner.
- * @param writer Address to grant write access to.
- */
- function authorizeWriter(address writer) public virtual override onlyOwner {
- OwnableWritableStorage.layout().writeAccess[writer] = true;
- }
-
- /**
- * Revoke write access from the given address.
- * Can only be called by the owner.
- * @param writer Address to revoke write access.
- */
- function unauthorizeWriter(address writer) public virtual override onlyOwner {
- delete OwnableWritableStorage.layout().writeAccess[writer];
- }
-}
diff --git a/packages/solecs/src/OwnableWritableStorage.sol b/packages/solecs/src/OwnableWritableStorage.sol
deleted file mode 100644
index e84141b270..0000000000
--- a/packages/solecs/src/OwnableWritableStorage.sol
+++ /dev/null
@@ -1,18 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.0;
-
-library OwnableWritableStorage {
- struct Layout {
- /** Addresses with write access */
- mapping(address => bool) writeAccess;
- }
-
- bytes32 internal constant STORAGE_SLOT = keccak256("solecs.contracts.storage.OwnableWritable");
-
- function layout() internal pure returns (Layout storage l) {
- bytes32 slot = STORAGE_SLOT;
- assembly {
- l.slot := slot
- }
- }
-}
diff --git a/packages/solecs/src/PayableSystem.sol b/packages/solecs/src/PayableSystem.sol
deleted file mode 100644
index 4bd4eb5247..0000000000
--- a/packages/solecs/src/PayableSystem.sol
+++ /dev/null
@@ -1,21 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.0;
-
-import { IPayableSystem } from "./interfaces/IPayableSystem.sol";
-import { IUint256Component } from "./interfaces/IUint256Component.sol";
-import { IWorld } from "./interfaces/IWorld.sol";
-
-import { Ownable } from "./Ownable.sol";
-
-/**
- * System base contract
- */
-abstract contract PayableSystem is IPayableSystem, Ownable {
- IUint256Component components;
- IWorld world;
-
- constructor(IWorld _world, address _components) {
- components = _components == address(0) ? _world.components() : IUint256Component(_components);
- world = _world;
- }
-}
diff --git a/packages/solecs/src/Set.sol b/packages/solecs/src/Set.sol
deleted file mode 100644
index 99c7253fed..0000000000
--- a/packages/solecs/src/Set.sol
+++ /dev/null
@@ -1,55 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.0;
-
-import { Ownable } from "./Ownable.sol";
-
-/**
- * Set of unique uint256
- */
-contract Set is Ownable {
- uint256[] internal items;
- mapping(uint256 => uint256) internal itemToIndex;
-
- function add(uint256 item) public onlyOwner {
- if (has(item)) return;
-
- itemToIndex[item] = items.length;
- items.push(item);
- }
-
- function remove(uint256 item) public onlyOwner {
- if (!has(item)) return;
-
- // Copy the last item to the given item's index
- items[itemToIndex[item]] = items[items.length - 1];
-
- // Update the moved item's stored index to the new index
- itemToIndex[items[itemToIndex[item]]] = itemToIndex[item];
-
- // Remove the given item's stored index
- delete itemToIndex[item];
-
- // Remove the last item
- items.pop();
- }
-
- function getIndex(uint256 item) public view returns (bool, uint256) {
- if (!has(item)) return (false, 0);
-
- return (true, itemToIndex[item]);
- }
-
- function has(uint256 item) public view returns (bool) {
- if (items.length == 0) return false;
- if (itemToIndex[item] == 0) return items[0] == item;
- return itemToIndex[item] != 0;
- }
-
- function getItems() public view returns (uint256[] memory) {
- return items;
- }
-
- function size() public view returns (uint256) {
- return items.length;
- }
-}
diff --git a/packages/solecs/src/SingletonID.sol b/packages/solecs/src/SingletonID.sol
deleted file mode 100644
index f73895fe37..0000000000
--- a/packages/solecs/src/SingletonID.sol
+++ /dev/null
@@ -1,4 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.0;
-
-uint256 constant SingletonID = 0x60D;
diff --git a/packages/solecs/src/System.sol b/packages/solecs/src/System.sol
deleted file mode 100644
index aa9520a070..0000000000
--- a/packages/solecs/src/System.sol
+++ /dev/null
@@ -1,25 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.0;
-
-import { ISystem } from "./interfaces/ISystem.sol";
-import { IUint256Component } from "./interfaces/IUint256Component.sol";
-import { IWorld } from "./interfaces/IWorld.sol";
-import { SystemStorage } from "./SystemStorage.sol";
-
-import { Ownable } from "./Ownable.sol";
-
-/**
- * System base contract
- */
-abstract contract System is ISystem, Ownable {
- IUint256Component components;
- IWorld world;
-
- constructor(IWorld _world, address _components) {
- // @deprecated use SystemStorage.components() instead of components
- components = _components == address(0) ? _world.components() : IUint256Component(_components);
- // @deprecated use SystemStorage.world() instead of world
- world = _world;
- SystemStorage.init(world, components);
- }
-}
diff --git a/packages/solecs/src/SystemStorage.sol b/packages/solecs/src/SystemStorage.sol
deleted file mode 100644
index 4ccc2efe40..0000000000
--- a/packages/solecs/src/SystemStorage.sol
+++ /dev/null
@@ -1,77 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.0;
-
-import { IUint256Component } from "./interfaces/IUint256Component.sol";
-import { IWorld } from "./interfaces/IWorld.sol";
-import { getSystemAddressById, getAddressById } from "./utils.sol";
-
-/**
- * Systems contain the address of the components registry and world contract as state variables.
- * SystemStorage ensures that these addresses are stored at deterministic locations in a System contract's storage.
- * Developers can read/write components and access world utilities from any library called by a System.
- * Warning: Library must be initialized (init) by a contract that can access components + world contracts before use.
- * The intialization is done automatically for any contract inheriting System or MudTest.
- */
-library SystemStorage {
- /** Data that the system stores */
- struct Layout {
- IUint256Component components;
- IWorld world;
- }
-
- /** Location in memory where the Layout struct will be stored */
- bytes32 internal constant STORAGE_SLOT = keccak256("solecs.contracts.storage.System");
-
- /**
- * Utility for accessing the STORAGE_SLOT location in the contract's storage
- * @return l Layout struct at storage position l
- */
- function layout() internal pure returns (Layout storage l) {
- bytes32 slot = STORAGE_SLOT;
- assembly {
- l.slot := slot
- }
- }
-
- /**
- * Register this component in the given world.
- * @param _world Address of the World contract.
- * @param _components Address of the Components registry contract.
- * @dev This function must be called at the start of any contract that expects libraries to access SystemStorage!
- */
- function init(IWorld _world, IUint256Component _components) internal {
- Layout storage l = layout();
- l.world = _world;
- l.components = _components;
- }
-
- /**
- * @return Component registry contract
- */
- function components() public view returns (IUint256Component) {
- return layout().components;
- }
-
- /**
- * @return World contract
- */
- function world() public view returns (IWorld) {
- return layout().world;
- }
-
- /**
- * @param systemID ID for a system
- * @return address of the System contract from the components registry
- */
- function system(uint256 systemID) internal view returns (address) {
- return getSystemAddressById(layout().components, systemID);
- }
-
- /**
- * @param componentID ID for a component
- * @return address of the Component contract from the components registry
- */
- function component(uint256 componentID) internal view returns (address) {
- return getAddressById(layout().components, componentID);
- }
-}
diff --git a/packages/solecs/src/World.sol b/packages/solecs/src/World.sol
deleted file mode 100644
index feacfe3c28..0000000000
--- a/packages/solecs/src/World.sol
+++ /dev/null
@@ -1,198 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.0;
-
-import { Set } from "./Set.sol";
-import { LibQuery } from "./LibQuery.sol";
-import { IWorld, WorldQueryFragment } from "./interfaces/IWorld.sol";
-import { QueryFragment } from "./interfaces/Query.sol";
-import { IUint256Component } from "./interfaces/IUint256Component.sol";
-import { Uint256Component } from "./components/Uint256Component.sol";
-import { addressToEntity, entityToAddress, getIdByAddress, getAddressById, getComponentById } from "./utils.sol";
-import { componentsComponentId, systemsComponentId } from "./constants.sol";
-import { RegisterSystem, ID as registerSystemId, RegisterType } from "./systems/RegisterSystem.sol";
-
-/**
- * The `World` contract is at the core of every on-chain world.
- * Entities, components and systems are registered in the `World`.
- * Components register updates to their state via the `registerComponentValueSet`
- * and `registerComponentValueRemoved` methods, which emit the `ComponentValueSet` and `ComponentValueRemoved` events respectively.
- *
- * Clients can reconstruct the entire state (of all components) by listening to
- * these two events, instead of having to add a separate getter or event listener
- * for every type of data. (Have a look at the MUD network package for a TypeScript
- * implementation of contract/client state sync.)
- *
- * The `World` is an ownerless and permissionless contract.
- * Anyone can register new components and systems in the world (via the `registerComponent` and `registerSystem` methods).
- * Clients decide which components and systems they care about.
- */
-contract World is IWorld {
- Set private entities = new Set();
- Uint256Component private _components;
- Uint256Component private _systems;
- RegisterSystem public register;
-
- event ComponentValueSet(uint256 indexed componentId, address indexed component, uint256 indexed entity, bytes data);
- event ComponentValueRemoved(uint256 indexed componentId, address indexed component, uint256 indexed entity);
-
- constructor() {
- _components = new Uint256Component(address(0), componentsComponentId);
- _systems = new Uint256Component(address(0), systemsComponentId);
- register = new RegisterSystem(this, address(_components));
- _systems.authorizeWriter(address(register));
- _components.authorizeWriter(address(register));
- }
-
- /**
- * Initialize the World.
- * Separated from the constructor to prevent circular dependencies.
- */
- function init() public {
- _components.registerWorld(address(this));
- _systems.registerWorld(address(this));
- register.execute(abi.encode(msg.sender, RegisterType.System, address(register), registerSystemId));
- }
-
- /**
- * Get the component registry Uint256Component
- * (mapping from component address to component id)
- */
- function components() public view returns (IUint256Component) {
- return _components;
- }
-
- /**
- * Get the system registry Uint256Component
- * (mapping from system address to system id)
- */
- function systems() public view returns (IUint256Component) {
- return _systems;
- }
-
- /**
- * Register a new component in this World.
- * ID must be unique.
- */
- function registerComponent(address componentAddr, uint256 id) public {
- register.execute(abi.encode(msg.sender, RegisterType.Component, componentAddr, id));
- }
-
- /**
- * Register a new system in this World.
- * ID must be unique.
- */
- function registerSystem(address systemAddr, uint256 id) public {
- register.execute(abi.encode(msg.sender, RegisterType.System, systemAddr, id));
- }
-
- /**
- * Reverts if the component is not registered in this World.
- */
- modifier requireComponentRegistered(address component) {
- require(_components.has(addressToEntity(component)), "component not registered");
- _;
- }
-
- /**
- * Deprecated - use registerComponentValueSet(entity, data) instead
- * Register a component value update.
- * Emits the `ComponentValueSet` event for clients to reconstruct the state.
- */
- function registerComponentValueSet(
- address component,
- uint256 entity,
- bytes calldata data
- ) public requireComponentRegistered(component) {
- require(msg.sender == component);
- Set(entities).add(entity);
- emit ComponentValueSet(getIdByAddress(_components, component), component, entity, data);
- }
-
- /**
- * Register a component value update.
- * Emits the `ComponentValueSet` event for clients to reconstruct the state.
- */
- function registerComponentValueSet(
- uint256 entity,
- bytes calldata data
- ) public requireComponentRegistered(msg.sender) {
- Set(entities).add(entity);
- emit ComponentValueSet(getIdByAddress(_components, msg.sender), msg.sender, entity, data);
- }
-
- /**
- * Deprecated - use registerComponentValueRemoved(entity) instead
- * Register a component value removal.
- * Emits the `ComponentValueRemoved` event for clients to reconstruct the state.
- */
- function registerComponentValueRemoved(
- address component,
- uint256 entity
- ) public requireComponentRegistered(component) {
- require(msg.sender == component);
- emit ComponentValueRemoved(getIdByAddress(_components, component), component, entity);
- }
-
- /**
- * Register a component value removal.
- * Emits the `ComponentValueRemoved` event for clients to reconstruct the state.
- */
- function registerComponentValueRemoved(uint256 entity) public requireComponentRegistered(msg.sender) {
- emit ComponentValueRemoved(getIdByAddress(_components, msg.sender), msg.sender, entity);
- }
-
- /** Deprecated, but left here for backward compatibility. TODO: refactor all consumers. */
- function getComponent(uint256 id) external view returns (address) {
- return getAddressById(_components, id);
- }
-
- /** Deprecated, but left here for backward compatibility. TODO: refactor all consumers. */
- function getComponentIdFromAddress(address componentAddr) external view returns (uint256) {
- return getIdByAddress(_components, componentAddr);
- }
-
- /** Deprecated, but left here for backward compatibility. TODO: refactor all consumers. */
- function getSystemAddress(uint256 systemId) external view returns (address) {
- return getAddressById(_systems, systemId);
- }
-
- function getNumEntities() public view returns (uint256) {
- return Set(entities).size();
- }
-
- /**
- * Helper function to execute a query with query fragments referring to a component ID instead of a component address.
- */
- function query(WorldQueryFragment[] calldata worldQueryFragments) public view returns (uint256[] memory) {
- QueryFragment[] memory fragments = new QueryFragment[](worldQueryFragments.length);
- for (uint256 i; i < worldQueryFragments.length; i++) {
- fragments[i] = QueryFragment(
- worldQueryFragments[i].queryType,
- getComponentById(_components, worldQueryFragments[i].componentId),
- worldQueryFragments[i].value
- );
- }
- return LibQuery.query(fragments);
- }
-
- /**
- * Check whether an entity exists in this world.
- */
- function hasEntity(uint256 entity) public view returns (bool) {
- return Set(entities).has(entity);
- }
-
- /**
- * Get a new unique entity ID.
- */
- function getUniqueEntityId() public view returns (uint256) {
- uint256 entityNum = getNumEntities();
- uint256 id;
- do {
- entityNum++;
- id = uint256(keccak256(abi.encodePacked(entityNum)));
- } while (hasEntity(id));
-
- return id;
- }
-}
diff --git a/packages/solecs/src/components/Uint256Component.sol b/packages/solecs/src/components/Uint256Component.sol
deleted file mode 100644
index 75971683ce..0000000000
--- a/packages/solecs/src/components/Uint256Component.sol
+++ /dev/null
@@ -1,34 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.0;
-
-import { Component } from "../Component.sol";
-import { LibTypes } from "../LibTypes.sol";
-import { IUint256Component } from "../interfaces/IUint256Component.sol";
-
-/**
- * Reference implementation of a component storing a uint256 value for each entity.
- */
-contract Uint256Component is Component, IUint256Component {
- constructor(address world, uint256 id) Component(world, id) {}
-
- function getSchema() public pure override returns (string[] memory keys, LibTypes.SchemaValue[] memory values) {
- keys = new string[](1);
- values = new LibTypes.SchemaValue[](1);
-
- keys[0] = "value";
- values[0] = LibTypes.SchemaValue.UINT256;
- }
-
- function set(uint256 entity, uint256 value) public virtual {
- set(entity, abi.encode(value));
- }
-
- function getValue(uint256 entity) public view virtual returns (uint256) {
- uint256 value = abi.decode(getRawValue(entity), (uint256));
- return value;
- }
-
- function getEntitiesWithValue(uint256 value) public view virtual returns (uint256[] memory) {
- return getEntitiesWithValue(abi.encode(value));
- }
-}
diff --git a/packages/solecs/src/constants.sol b/packages/solecs/src/constants.sol
deleted file mode 100644
index c52b887a8c..0000000000
--- a/packages/solecs/src/constants.sol
+++ /dev/null
@@ -1,5 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.0;
-
-uint256 constant componentsComponentId = uint256(keccak256("world.component.components"));
-uint256 constant systemsComponentId = uint256(keccak256("world.component.systems"));
diff --git a/packages/solecs/src/interfaces/IComponent.sol b/packages/solecs/src/interfaces/IComponent.sol
deleted file mode 100644
index f3d33d2028..0000000000
--- a/packages/solecs/src/interfaces/IComponent.sol
+++ /dev/null
@@ -1,26 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.0;
-
-import { IOwnableWritable } from "./IOwnableWritable.sol";
-import { LibTypes } from "../LibTypes.sol";
-
-interface IComponent is IOwnableWritable {
- /** Return the keys and value types of the schema of this component. */
- function getSchema() external pure returns (string[] memory keys, LibTypes.SchemaValue[] memory values);
-
- function set(uint256 entity, bytes memory value) external;
-
- function remove(uint256 entity) external;
-
- function has(uint256 entity) external view returns (bool);
-
- function getRawValue(uint256 entity) external view returns (bytes memory);
-
- function getEntities() external view returns (uint256[] memory);
-
- function getEntitiesWithValue(bytes memory value) external view returns (uint256[] memory);
-
- function registerIndexer(address indexer) external;
-
- function world() external view returns (address);
-}
diff --git a/packages/solecs/src/interfaces/IERC165.sol b/packages/solecs/src/interfaces/IERC165.sol
deleted file mode 100644
index d026ac3b87..0000000000
--- a/packages/solecs/src/interfaces/IERC165.sol
+++ /dev/null
@@ -1,4 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity ^0.8.0;
-
-import { IERC165 } from "@solidstate/contracts/interfaces/IERC165.sol";
diff --git a/packages/solecs/src/interfaces/IERC173.sol b/packages/solecs/src/interfaces/IERC173.sol
deleted file mode 100644
index bd315fe720..0000000000
--- a/packages/solecs/src/interfaces/IERC173.sol
+++ /dev/null
@@ -1,4 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.0;
-
-import { IERC173 } from "@solidstate/contracts/interfaces/IERC173.sol";
diff --git a/packages/solecs/src/interfaces/IEntityContainer.sol b/packages/solecs/src/interfaces/IEntityContainer.sol
deleted file mode 100644
index 7c27a19a85..0000000000
--- a/packages/solecs/src/interfaces/IEntityContainer.sol
+++ /dev/null
@@ -1,10 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.0;
-
-interface IEntityContainer {
- function has(uint256 entity) external view returns (bool);
-
- function getEntities() external view returns (uint256[] memory);
-
- function getEntitiesWithValue(bytes memory value) external view returns (uint256[] memory);
-}
diff --git a/packages/solecs/src/interfaces/IEntityIndexer.sol b/packages/solecs/src/interfaces/IEntityIndexer.sol
deleted file mode 100644
index 094ce12cdd..0000000000
--- a/packages/solecs/src/interfaces/IEntityIndexer.sol
+++ /dev/null
@@ -1,10 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.0;
-
-import { IEntityContainer } from "./IEntityContainer.sol";
-
-interface IEntityIndexer is IEntityContainer {
- function update(uint256 entity, bytes memory value) external;
-
- function remove(uint256 entity) external;
-}
diff --git a/packages/solecs/src/interfaces/IOwnableWritable.sol b/packages/solecs/src/interfaces/IOwnableWritable.sol
deleted file mode 100644
index 154b898a61..0000000000
--- a/packages/solecs/src/interfaces/IOwnableWritable.sol
+++ /dev/null
@@ -1,10 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.0;
-
-import { IERC173 } from "./IERC173.sol";
-
-interface IOwnableWritable is IERC173 {
- function authorizeWriter(address writer) external;
-
- function unauthorizeWriter(address writer) external;
-}
diff --git a/packages/solecs/src/interfaces/IPayableSystem.sol b/packages/solecs/src/interfaces/IPayableSystem.sol
deleted file mode 100644
index 4a3ab01ceb..0000000000
--- a/packages/solecs/src/interfaces/IPayableSystem.sol
+++ /dev/null
@@ -1,10 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.0;
-
-import { IERC173 } from "./IERC173.sol";
-
-// The minimum requirement for a system is to have an `execute` function.
-// For convenience having an `executeTyped` function with typed arguments is recommended.
-interface IPayableSystem is IERC173 {
- function execute(bytes memory args) external payable returns (bytes memory);
-}
diff --git a/packages/solecs/src/interfaces/ISystem.sol b/packages/solecs/src/interfaces/ISystem.sol
deleted file mode 100644
index 952c40dede..0000000000
--- a/packages/solecs/src/interfaces/ISystem.sol
+++ /dev/null
@@ -1,10 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.0;
-
-import { IERC173 } from "./IERC173.sol";
-
-// The minimum requirement for a system is to have an `execute` function.
-// For convenience having an `executeTyped` function with typed arguments is recommended.
-interface ISystem is IERC173 {
- function execute(bytes memory args) external returns (bytes memory);
-}
diff --git a/packages/solecs/src/interfaces/IUint256Component.sol b/packages/solecs/src/interfaces/IUint256Component.sol
deleted file mode 100644
index d94c906efc..0000000000
--- a/packages/solecs/src/interfaces/IUint256Component.sol
+++ /dev/null
@@ -1,12 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.0;
-
-import { IComponent } from "./IComponent.sol";
-
-interface IUint256Component is IComponent {
- function set(uint256 entity, uint256 value) external;
-
- function getValue(uint256 entity) external view returns (uint256);
-
- function getEntitiesWithValue(uint256 value) external view returns (uint256[] memory);
-}
diff --git a/packages/solecs/src/interfaces/IWorld.sol b/packages/solecs/src/interfaces/IWorld.sol
deleted file mode 100644
index b913f29504..0000000000
--- a/packages/solecs/src/interfaces/IWorld.sol
+++ /dev/null
@@ -1,46 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.0;
-
-import { QueryType } from "./Query.sol";
-import { IUint256Component } from "./IUint256Component.sol";
-
-// For ProxyRead and ProxyExpand QueryFragments:
-// - component must be a component whose raw value decodes to a single uint256
-// - value must decode to a single uint256 represents the proxy depth
-struct WorldQueryFragment {
- QueryType queryType;
- uint256 componentId;
- bytes value;
-}
-
-interface IWorld {
- function components() external view returns (IUint256Component);
-
- function systems() external view returns (IUint256Component);
-
- function registerComponent(address componentAddr, uint256 id) external;
-
- function getComponent(uint256 id) external view returns (address);
-
- function getComponentIdFromAddress(address componentAddr) external view returns (uint256);
-
- function registerSystem(address systemAddr, uint256 id) external;
-
- function registerComponentValueSet(address component, uint256 entity, bytes calldata data) external;
-
- function registerComponentValueSet(uint256 entity, bytes calldata data) external;
-
- function registerComponentValueRemoved(address component, uint256 entity) external;
-
- function registerComponentValueRemoved(uint256 entity) external;
-
- function getNumEntities() external view returns (uint256);
-
- function hasEntity(uint256 entity) external view returns (bool);
-
- function getUniqueEntityId() external view returns (uint256);
-
- function query(WorldQueryFragment[] calldata worldQueryFragments) external view returns (uint256[] memory);
-
- function init() external;
-}
diff --git a/packages/solecs/src/interfaces/Query.sol b/packages/solecs/src/interfaces/Query.sol
deleted file mode 100644
index 570a97de7a..0000000000
--- a/packages/solecs/src/interfaces/Query.sol
+++ /dev/null
@@ -1,23 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.13;
-
-import { IComponent } from "./IComponent.sol";
-import { LinkedList } from "memmove/LinkedList.sol";
-
-enum QueryType {
- Has,
- Not,
- HasValue,
- NotValue,
- ProxyRead,
- ProxyExpand
-}
-
-// For ProxyRead and ProxyExpand QueryFragments:
-// - component must be a component whose raw value decodes to a single uint256
-// - value must decode to a single uint256 represents the proxy depth
-struct QueryFragment {
- QueryType queryType;
- IComponent component;
- bytes value;
-}
diff --git a/packages/solecs/src/systems/RegisterSystem.sol b/packages/solecs/src/systems/RegisterSystem.sol
deleted file mode 100644
index a8af26f30e..0000000000
--- a/packages/solecs/src/systems/RegisterSystem.sol
+++ /dev/null
@@ -1,67 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.0;
-
-import { ISystem } from "../interfaces/ISystem.sol";
-import { IWorld } from "../interfaces/IWorld.sol";
-import { IERC173 } from "../interfaces/IERC173.sol";
-import { IUint256Component } from "../interfaces/IUint256Component.sol";
-import { addressToEntity, entityToAddress, getAddressById } from "../utils.sol";
-import { systemsComponentId } from "../constants.sol";
-import { System } from "../System.sol";
-
-enum RegisterType {
- Component,
- System
-}
-
-uint256 constant ID = uint256(keccak256("world.system.register"));
-
-contract RegisterSystem is System {
- constructor(IWorld _world, address _components) System(_world, _components) {}
-
- function requirement(bytes memory args) public view returns (bytes memory) {
- // TODO: Refactor to remove requirement/execute split
- }
-
- function execute(
- address msgSender,
- RegisterType registerType,
- address addr,
- uint256 id
- ) public returns (bytes memory) {
- return execute(abi.encode(msgSender, registerType, addr, id));
- }
-
- function execute(bytes memory args) public returns (bytes memory) {
- (address msgSender, RegisterType registerType, address addr, uint256 id) = abi.decode(
- args,
- (address, RegisterType, address, uint256)
- );
- require(msg.sender == address(world), "system can only be called via World");
- require(registerType == RegisterType.Component || registerType == RegisterType.System, "invalid type");
- require(id != 0, "invalid id");
- require(addr != address(0), "invalid address");
-
- IUint256Component registry = registerType == RegisterType.Component
- ? components
- : IUint256Component(getAddressById(components, systemsComponentId));
- uint256 entity = addressToEntity(addr);
-
- require(!registry.has(entity), "entity already registered");
-
- uint256[] memory entitiesWithId = registry.getEntitiesWithValue(id);
-
- require(
- entitiesWithId.length == 0 ||
- (entitiesWithId.length == 1 && IERC173(entityToAddress(entitiesWithId[0])).owner() == msgSender),
- "id already registered and caller not owner"
- );
-
- if (entitiesWithId.length == 1) {
- // Remove previous system
- registry.remove(entitiesWithId[0]);
- }
-
- registry.set(entity, id);
- }
-}
diff --git a/packages/solecs/src/test/Component.t.sol b/packages/solecs/src/test/Component.t.sol
deleted file mode 100644
index f86ec4857a..0000000000
--- a/packages/solecs/src/test/Component.t.sol
+++ /dev/null
@@ -1,73 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.0;
-import { DSTestPlus } from "solmate/test/utils/DSTestPlus.sol";
-import { Vm } from "forge-std/Vm.sol";
-import { console } from "forge-std/console.sol";
-
-import { TestComponent } from "./components/TestComponent.sol";
-import { World } from "../World.sol";
-
-contract ComponentTest is DSTestPlus {
- Vm internal immutable vm = Vm(HEVM_ADDRESS);
-
- address payable[] internal users;
-
- TestComponent internal component;
-
- function setUp() public {
- World world = new World();
- world.init();
- component = new TestComponent(address(world));
- }
-
- function testSetAndGetValue() public {
- assertTrue(!component.has(1));
- component.set(1, abi.encode(1));
- assertTrue(component.has(1));
- assertEq(abi.decode(component.getRawValue(1), (uint256)), 1);
-
- component.set(1, abi.encode(2));
- component.set(2, abi.encode(4));
- assertTrue(component.has(1));
- assertTrue(component.has(2));
- assertEq(abi.decode(component.getRawValue(1), (uint256)), 2);
- assertEq(abi.decode(component.getRawValue(2), (uint256)), 4);
- }
-
- function testRemove() public {
- assertTrue(!component.has(1));
- component.set(1, abi.encode(1));
- assertTrue(component.has(1));
- component.remove(1);
- assertTrue(!component.has(1));
- }
-
- function testGetEntities() public {
- component.set(1, abi.encode(2));
- component.set(2, abi.encode(4));
- component.set(3, abi.encode(10));
-
- uint256[] memory entities = component.getEntities();
- assertEq(entities[0], 1);
- assertEq(entities[1], 2);
- assertEq(entities[2], 3);
- }
-
- function testGetEntitiesWithValue() public {
- component.set(1, abi.encode(1));
- component.set(2, abi.encode(1));
- component.set(3, abi.encode(2));
-
- uint256[] memory entities = component.getEntitiesWithValue(abi.encode(1));
- assertEq(entities.length, 2);
- assertEq(entities[0], 1);
- assertEq(entities[1], 2);
-
- entities = component.getEntitiesWithValue(abi.encode(2));
- assertEq(entities.length, 1);
- assertEq(entities[0], 3);
-
- entities = component.getEntitiesWithValue(abi.encode(3));
- assertEq(entities.length, 0);
- }
-}
diff --git a/packages/solecs/src/test/Indexer.t.sol b/packages/solecs/src/test/Indexer.t.sol
deleted file mode 100644
index 88c3666033..0000000000
--- a/packages/solecs/src/test/Indexer.t.sol
+++ /dev/null
@@ -1,108 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.0;
-
-import { DSTestPlus } from "solmate/test/utils/DSTestPlus.sol";
-import { Vm } from "forge-std/Vm.sol";
-
-import { DamageComponent } from "./components/DamageComponent.sol";
-import { PositionComponent, Position } from "./components/PositionComponent.sol";
-import { Indexer } from "../Indexer.sol";
-import { World } from "../World.sol";
-import { Component } from "../Component.sol";
-
-contract IndexerTest is DSTestPlus {
- Vm internal immutable vm = Vm(HEVM_ADDRESS);
-
- PositionComponent internal position;
- DamageComponent internal damage;
- Indexer internal regionCreatures;
-
- function setUp() public {
- World world = new World();
- world.init();
-
- position = new PositionComponent(address(world));
- damage = new DamageComponent(address(world));
- Component[] memory components = new Component[](2);
- components[0] = position;
- components[1] = damage;
- bool[] memory track = new bool[](2);
- track[0] = true;
- track[1] = false;
- regionCreatures = new Indexer(components, track);
- position.registerIndexer(address(regionCreatures));
- damage.registerIndexer(address(regionCreatures));
- }
-
- function testSetAndGetEntitiesWithValue() public {
- assertFalse(regionCreatures.has(1));
- damage.set(1, 1);
- position.set(1, Position(1, 1));
-
- assertTrue(regionCreatures.has(1));
-
- position.set(2, Position(1, 1));
- assertFalse(regionCreatures.has(2));
-
- // Should only give 1
- bytes[] memory content = new bytes[](2);
- content[0] = abi.encode(Position(1, 1));
- bytes memory query = abi.encode(content);
-
- assertEq(regionCreatures.getEntitiesWithValue(query).length, 1);
- assertEq(regionCreatures.getEntitiesWithValue(query)[0], 1);
-
- // Should be 2 now
- damage.set(2, 1);
- assertEq(regionCreatures.getEntitiesWithValue(query)[0], 1);
- assertEq(regionCreatures.getEntitiesWithValue(query)[1], 2);
- }
-
- function testUpdate() public {
- damage.set(1, 1);
- position.set(1, Position(1, 1));
-
- // Should only give 1
- bytes[] memory content = new bytes[](2);
- content[0] = abi.encode(Position(1, 1));
- bytes memory query = abi.encode(content);
-
- assertEq(regionCreatures.getEntitiesWithValue(query).length, 1);
- assertEq(regionCreatures.getEntitiesWithValue(query)[0], 1);
-
- // Update and check query is correct
- position.set(1, Position(2, 2));
- assertEq(regionCreatures.getEntitiesWithValue(query).length, 0);
- content[0] = abi.encode(Position(2, 2));
- query = abi.encode(content);
- assertEq(regionCreatures.getEntitiesWithValue(query)[0], 1);
- }
-
- function testRemove() public {
- damage.set(1, 1);
- position.set(1, Position(1, 1));
-
- // Should only give 1
- bytes[] memory content = new bytes[](2);
- content[0] = abi.encode(Position(1, 1));
- bytes memory query = abi.encode(content);
-
- assertEq(regionCreatures.getEntitiesWithValue(query).length, 1);
- assertEq(regionCreatures.getEntitiesWithValue(query)[0], 1);
-
- // Should be gone from indexer after removal
- damage.remove(1);
- assertEq(regionCreatures.getEntitiesWithValue(query).length, 0);
- }
-
- function testGetEntities() public {
- damage.set(1, 1);
- position.set(1, Position(1, 1));
- position.set(2, Position(1, 1));
- damage.set(2, 1);
-
- uint256[] memory entities = regionCreatures.getEntities();
- assertEq(entities[0], 1);
- assertEq(entities[1], 2);
- }
-}
diff --git a/packages/solecs/src/test/LibQuery.t.sol b/packages/solecs/src/test/LibQuery.t.sol
deleted file mode 100644
index dc4b9937d3..0000000000
--- a/packages/solecs/src/test/LibQuery.t.sol
+++ /dev/null
@@ -1,362 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.0;
-
-import { DSTest } from "ds-test/test.sol";
-import { Vm } from "forge-std/Vm.sol";
-import { console } from "forge-std/console.sol";
-
-import { World } from "../World.sol";
-import { LibQuery } from "../LibQuery.sol";
-import { QueryFragment, QueryType } from "../interfaces/Query.sol";
-import { TestComponent1, TestComponent2, TestComponent3 } from "./components/TestComponent.sol";
-import { PrototypeTagComponent } from "./components/PrototypeTagComponent.sol";
-import { FromPrototypeComponent } from "./components/FromPrototypeComponent.sol";
-import { OwnedByEntityComponent } from "./components/OwnedByEntityComponent.sol";
-
-contract LibQueryTest is DSTest {
- Vm internal immutable vm = Vm(HEVM_ADDRESS);
-
- address payable[] internal users;
-
- TestComponent1 internal component1;
- TestComponent2 internal component2;
- TestComponent3 internal component3;
-
- PrototypeTagComponent internal prototypeTag;
- FromPrototypeComponent internal fromPrototype;
- OwnedByEntityComponent internal ownedByEntity;
-
- function setUp() public {
- World world = new World();
- world.init();
- component1 = new TestComponent1(address(world));
- component2 = new TestComponent2(address(world));
- component3 = new TestComponent3(address(world));
- prototypeTag = new PrototypeTagComponent(address(world));
- fromPrototype = new FromPrototypeComponent(address(world));
- ownedByEntity = new OwnedByEntityComponent(address(world));
- }
-
- function testHasQuery() public {
- component1.set(1, abi.encode(1));
- component1.set(2, abi.encode(1));
- component2.set(1, abi.encode(0));
- // Query should return all entities that have component1
- QueryFragment[] memory fragments = new QueryFragment[](1);
- // The value argument is ignored in for Has query fragments
- fragments[0] = QueryFragment(QueryType.Has, component1, new bytes(0));
- uint256[] memory entities = LibQuery.query(fragments);
-
- assertTrue(entities.length == 2);
- assertTrue(entities[0] == 1);
- assertTrue(entities[1] == 2);
- }
-
- function testHasValueQuery() public {
- component1.set(1, abi.encode(2));
- component1.set(2, abi.encode(1));
- component1.set(3, abi.encode(1));
- // Query should return all entities that have component1 with value 1
- QueryFragment[] memory fragments = new QueryFragment[](1);
- fragments[0] = QueryFragment(QueryType.HasValue, component1, abi.encode(1));
- uint256[] memory entities = LibQuery.query(fragments);
-
- assertTrue(entities.length == 2);
- assertTrue(entities[0] == 2);
- assertTrue(entities[1] == 3);
- }
-
- function testCombinedHasQuery() public {
- component1.set(1, abi.encode(2));
- component1.set(2, abi.encode(1));
- component1.set(3, abi.encode(1));
- component2.set(2, abi.encode(1));
- component2.set(3, abi.encode(1));
- component3.set(1, abi.encode(1));
-
- // Query should return all entities that have component1 and component2
- QueryFragment[] memory fragments = new QueryFragment[](2);
- fragments[0] = QueryFragment(QueryType.Has, component1, new bytes(0));
- fragments[1] = QueryFragment(QueryType.Has, component2, new bytes(0));
- uint256[] memory entities = LibQuery.query(fragments);
-
- assertTrue(entities.length == 2);
- assertTrue(entities[0] == 2);
- assertTrue(entities[1] == 3);
- }
-
- function testCombinedHasValueQuery() public {
- component1.set(1, abi.encode(2));
- component1.set(2, abi.encode(2));
- component1.set(3, abi.encode(1));
- component2.set(2, abi.encode(1));
- component2.set(3, abi.encode(1));
- component3.set(1, abi.encode(1));
-
- // Query should return all entities that have component1 and component2
- QueryFragment[] memory fragments = new QueryFragment[](2);
- fragments[0] = QueryFragment(QueryType.HasValue, component1, abi.encode(1));
- fragments[1] = QueryFragment(QueryType.HasValue, component2, abi.encode(1));
- uint256[] memory entities = LibQuery.query(fragments);
-
- assertTrue(entities.length == 1);
- assertTrue(entities[0] == 3);
- }
-
- function testCombinedHasHasValueQuery() public {
- component1.set(1, abi.encode(1));
- component1.set(2, abi.encode(1));
- component1.set(3, abi.encode(1));
- component2.set(1, abi.encode(1));
- component2.set(2, abi.encode(2));
- component2.set(3, abi.encode(2));
- component2.set(4, abi.encode(2));
-
- // Query should return all entities that have component1 and component2
- QueryFragment[] memory fragments = new QueryFragment[](2);
- fragments[0] = QueryFragment(QueryType.Has, component1, new bytes(0));
- fragments[1] = QueryFragment(QueryType.HasValue, component2, abi.encode(2));
- uint256[] memory entities = LibQuery.query(fragments);
-
- assertTrue(entities.length == 2);
- assertTrue(entities[0] == 2);
- assertTrue(entities[1] == 3);
- }
-
- function testCombinedHasNotQuery() public {
- component1.set(1, abi.encode(1));
- component1.set(2, abi.encode(1));
- component1.set(3, abi.encode(1));
- component2.set(1, abi.encode(1));
- component2.set(2, abi.encode(2));
- component2.set(3, abi.encode(2));
- component2.set(4, abi.encode(2));
-
- // Query should return all entities that have component2 and not component1
- QueryFragment[] memory fragments = new QueryFragment[](2);
- fragments[0] = QueryFragment(QueryType.Has, component2, new bytes(0));
- fragments[1] = QueryFragment(QueryType.Not, component1, new bytes(0));
- uint256[] memory entities = LibQuery.query(fragments);
-
- assertTrue(entities.length == 1);
- assertTrue(entities[0] == 4);
- }
-
- function testCombinedHasValueNotQuery() public {
- component1.set(1, abi.encode(1));
- component1.set(2, abi.encode(1));
- component1.set(3, abi.encode(1));
- component2.set(1, abi.encode(1));
- component2.set(2, abi.encode(2));
- component2.set(3, abi.encode(1));
- component2.set(4, abi.encode(1));
-
- // Query should return all entities that have component2 and not component1
- QueryFragment[] memory fragments = new QueryFragment[](2);
- fragments[0] = QueryFragment(QueryType.HasValue, component2, abi.encode(1));
- fragments[1] = QueryFragment(QueryType.Not, component1, new bytes(0));
- uint256[] memory entities = LibQuery.query(fragments);
-
- assertTrue(entities.length == 1);
- assertTrue(entities[0] == 4);
- }
-
- function testCombinedHasHasValueNotQuery() public {
- component1.set(1, abi.encode(1));
- component1.set(2, abi.encode(1));
- component1.set(3, abi.encode(1));
- component2.set(1, abi.encode(1));
- component2.set(2, abi.encode(2));
- component2.set(3, abi.encode(1));
- component2.set(4, abi.encode(1));
- component3.set(2, abi.encode(1));
- component3.set(3, abi.encode(1));
- component3.set(4, abi.encode(1));
-
- // Query should return all entities that have component2 and not component1
- QueryFragment[] memory fragments = new QueryFragment[](3);
- fragments[0] = QueryFragment(QueryType.Has, component1, new bytes(0));
- fragments[1] = QueryFragment(QueryType.HasValue, component2, abi.encode(1));
- fragments[2] = QueryFragment(QueryType.Not, component3, new bytes(0));
- uint256[] memory entities = LibQuery.query(fragments);
-
- assertTrue(entities.length == 1);
- assertTrue(entities[0] == 1);
- }
-
- function testNotValueQuery() public {
- component1.set(1, abi.encode(4));
- component1.set(2, abi.encode(5));
- component1.set(3, abi.encode(6));
-
- // Query should return all entities with component 1 except value 6
- QueryFragment[] memory fragments = new QueryFragment[](2);
- fragments[0] = QueryFragment(QueryType.Has, component1, new bytes(0));
- fragments[1] = QueryFragment(QueryType.NotValue, component1, abi.encode(6));
- uint256[] memory entities = LibQuery.query(fragments);
-
- assertTrue(entities.length == 2);
- assertTrue(entities[0] == 1);
- assertTrue(entities[1] == 2);
- }
-
- function testInitialProxyExpand() public {
- // 1 is a prototype entity and has component1
- prototypeTag.set(1, new bytes(0));
- component1.set(1, abi.encode(1));
-
- // 2 is an instance of prototype 1
- fromPrototype.set(2, 1);
-
- // Query should return all entities with component1, including instances
- QueryFragment[] memory fragments = new QueryFragment[](2);
- fragments[0] = QueryFragment(QueryType.ProxyExpand, fromPrototype, abi.encode(1));
- fragments[1] = QueryFragment(QueryType.Has, component1, new bytes(0));
- uint256[] memory entities = LibQuery.query(fragments);
-
- assertTrue(entities.length == 2);
- assertTrue(entities[0] == 1);
- assertTrue(entities[1] == 2);
- }
-
- function testDeepProxyExpand() public {
- // 1 is an instance with component1
- component1.set(1, abi.encode(1));
-
- // 2 is owned by 1
- ownedByEntity.set(2, 1);
-
- // 3 is owned by 1
- ownedByEntity.set(3, 1);
-
- // 4 is owned by 2
- ownedByEntity.set(4, 2);
-
- // 5 is owned by 4
- ownedByEntity.set(5, 4);
-
- // 6 is owned by 3
- ownedByEntity.set(6, 3);
-
- // 42 is owned by 69
- ownedByEntity.set(42, 69);
-
- // Query should return all entities owned by 1
- QueryFragment[] memory fragments = new QueryFragment[](2);
- fragments[0] = QueryFragment(QueryType.ProxyExpand, ownedByEntity, abi.encode(0xff)); // Depth of 256 should be enough
- fragments[1] = QueryFragment(QueryType.Has, component1, new bytes(0));
- uint256[] memory entities = LibQuery.query(fragments);
-
- assertTrue(entities.length == 6);
- assertTrue(entities[0] == 1);
- assertTrue(entities[1] == 5);
- assertTrue(entities[2] == 4);
- assertTrue(entities[3] == 6);
- assertTrue(entities[4] == 2);
- assertTrue(entities[5] == 3);
- }
-
- function testProxyRead() public {
- // 1 is a prototype with component1 value 1
- prototypeTag.set(1, new bytes(0));
- component1.set(1, abi.encode(1));
-
- // 2 is a prototype with component1 value 2
- prototypeTag.set(2, new bytes(0));
- component1.set(2, abi.encode(2));
-
- // 3 is a prototype with component2 value 1
- prototypeTag.set(3, new bytes(0));
- component2.set(3, abi.encode(1));
-
- // 4 is an instance of 1 and has component 3
- fromPrototype.set(4, 1);
- component3.set(4, abi.encode(1));
-
- // 5 is an instance of 2 and has component 3
- fromPrototype.set(5, 2);
- component3.set(5, abi.encode(1));
-
- // 6 is an instace of 3 and has component 3
- fromPrototype.set(6, 3);
- component3.set(6, abi.encode(1));
-
- // Gimme all entities with component3 and component1
- QueryFragment[] memory fragments = new QueryFragment[](3);
- fragments[0] = QueryFragment(QueryType.ProxyRead, fromPrototype, abi.encode(1));
- fragments[1] = QueryFragment(QueryType.Has, component3, new bytes(0)); // interim result 4,5,6
- fragments[2] = QueryFragment(QueryType.Has, component1, new bytes(0));
- uint256[] memory entities = LibQuery.query(fragments);
- assertTrue(entities.length == 2);
- assertTrue(entities[0] == 4);
- assertTrue(entities[1] == 5);
-
- // Gimme all entities with component3 and component2
- fragments[2] = QueryFragment(QueryType.Has, component2, new bytes(0));
- entities = LibQuery.query(fragments);
- assertTrue(entities.length == 1);
- assertTrue(entities[0] == 6);
-
- // Gimme all entities with component3 and component1 value 1
- fragments[2] = QueryFragment(QueryType.HasValue, component1, abi.encode(1));
- entities = LibQuery.query(fragments);
- assertTrue(entities.length == 1);
- assertTrue(entities[0] == 4);
- }
-
- function testDeepProxyRead() public {
- component1.set(1, abi.encode(1));
- ownedByEntity.set(2, 1);
- ownedByEntity.set(3, 2);
- ownedByEntity.set(4, 3);
- ownedByEntity.set(5, 4);
- ownedByEntity.set(6, 5);
-
- component1.set(7, abi.encode(2));
- ownedByEntity.set(8, 7);
-
- // Gimme all entities owned by an entity with component1 value 1
- QueryFragment[] memory fragments = new QueryFragment[](5);
- fragments[0] = QueryFragment(QueryType.ProxyRead, ownedByEntity, abi.encode(0xff)); // Depth 255
- fragments[1] = QueryFragment(QueryType.Has, ownedByEntity, new bytes(0));
- fragments[2] = QueryFragment(QueryType.HasValue, component1, abi.encode(1));
- fragments[3] = QueryFragment(QueryType.ProxyRead, ownedByEntity, abi.encode(0)); // Turn off proxy read
- fragments[4] = QueryFragment(QueryType.NotValue, component1, abi.encode(1)); // Exclude entities having component1 value 1 themselves
- uint256[] memory entities = LibQuery.query(fragments);
- assertTrue(entities.length == 5);
- assertTrue(entities[0] == 2);
- assertTrue(entities[1] == 3);
- assertTrue(entities[2] == 4);
- assertTrue(entities[3] == 5);
- assertTrue(entities[4] == 6);
-
- // Gimme all entities owned by an entity with component1 value 2
- fragments[2] = QueryFragment(QueryType.HasValue, component1, abi.encode(2));
- fragments[3] = QueryFragment(QueryType.ProxyRead, ownedByEntity, abi.encode(0)); // Turn off proxy read
- fragments[4] = QueryFragment(QueryType.NotValue, component1, abi.encode(2)); // Exclude entities having component1 value 1 themselves
- entities = LibQuery.query(fragments);
- assertTrue(entities.length == 1);
- assertTrue(entities[0] == 8);
- }
-
- function testGetValueWithProxy() public {
- component1.set(1, abi.encode(1));
- ownedByEntity.set(2, 1);
- ownedByEntity.set(3, 2);
- ownedByEntity.set(4, 3);
- ownedByEntity.set(5, 4);
- ownedByEntity.set(6, 5);
-
- (bytes memory value, bool found) = LibQuery.getValueWithProxy(component1, 1, ownedByEntity, 0);
- assertTrue(found);
- assertTrue(abi.decode(value, (uint256)) == 1);
-
- (value, found) = LibQuery.getValueWithProxy(component1, 6, ownedByEntity, 5);
- assertTrue(found);
- assertTrue(abi.decode(value, (uint256)) == 1);
-
- (value, found) = LibQuery.getValueWithProxy(component1, 6, ownedByEntity, 4);
- assertTrue(!found);
- assertTrue(value.length == 0);
- }
-}
diff --git a/packages/solecs/src/test/Set.t.sol b/packages/solecs/src/test/Set.t.sol
deleted file mode 100644
index 069cc79e6a..0000000000
--- a/packages/solecs/src/test/Set.t.sol
+++ /dev/null
@@ -1,99 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.0;
-
-import { DSTestPlus } from "solmate/test/utils/DSTestPlus.sol";
-import { Vm } from "forge-std/Vm.sol";
-import { console } from "forge-std/console.sol";
-
-import { Set } from "../Set.sol";
-
-contract SetTest is DSTestPlus {
- Vm internal immutable vm = Vm(HEVM_ADDRESS);
-
- address payable[] internal users;
-
- Set internal set;
-
- function setUp() public {
- set = new Set();
- }
-
- // Should add the items to the list
- function testAdd() public {
- set.add(1);
- set.add(2);
- assertTrue(set.has(1));
- assertTrue(set.has(2));
- assertTrue(!set.has(3));
- }
-
- // Should not add if it already exists
- function testAddDuplicate() public {
- assertEq(set.size(), 0);
- set.add(1);
- assertEq(set.size(), 1);
- set.add(1);
- assertEq(set.size(), 1);
- }
-
- // Should remove the item
- function testRemove() public {
- set.add(1);
- assertEq(set.size(), 1);
- assertTrue(set.has(1));
-
- set.remove(1);
-
- assertEq(set.size(), 0);
- assertTrue(!set.has(1));
-
- set.remove(1);
- set.remove(0);
-
- assertEq(set.size(), 0);
- assertTrue(!set.has(1));
- }
-
- // Should return a list of all items
- function testGetItems() public {
- set.add(1);
- set.add(2);
-
- uint256[] memory items = set.getItems();
-
- assertEq(items[0], 1);
- assertEq(items[1], 2);
- }
-
- // Should return the number of items in the set
- function testSize() public {
- set.add(1);
- assertEq(set.size(), 1);
-
- set.add(2);
- assertEq(set.size(), 2);
- }
-
- // Should return true if the list has the value, false otherwise
- function testHas() public {
- assertTrue(!set.has(1));
-
- set.add(1);
- assertTrue(set.has(1));
- assertTrue(!set.has(2));
-
- set.add(4);
- assertTrue(set.has(1));
- assertTrue(set.has(4));
- assertTrue(!set.has(2));
-
- set.add(10);
- assertTrue(set.has(1));
- assertTrue(set.has(4));
- assertTrue(set.has(10));
- assertTrue(!set.has(2));
-
- set.remove(1);
- assertTrue(!set.has(1));
- }
-}
diff --git a/packages/solecs/src/test/System.t.sol b/packages/solecs/src/test/System.t.sol
deleted file mode 100644
index 352e7bdcda..0000000000
--- a/packages/solecs/src/test/System.t.sol
+++ /dev/null
@@ -1,57 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.0;
-
-import { DSTest } from "ds-test/test.sol";
-import { World } from "../World.sol";
-import { IUint256Component } from "../interfaces/IUint256Component.sol";
-import { IWorld } from "../interfaces/IWorld.sol";
-import { SystemStorage } from "../SystemStorage.sol";
-import { System } from "../System.sol";
-
-contract SampleSystem is System {
- constructor(IWorld _world, address _components) System(_world, _components) {}
-
- function execute(bytes memory arguments) public returns (bytes memory) {}
-
- function executeTyped() external returns (bytes memory) {
- return execute(abi.encode(""));
- }
-
- // Note: These two getter functions are necessary to access the vars of SampleSystem
- function getWorld() public view returns (IWorld) {
- return world;
- }
-
- function getComponents() public view returns (IUint256Component) {
- return components;
- }
-}
-
-contract SystemTest is DSTest {
- IUint256Component public systems;
- World internal world;
- IUint256Component public components;
- SampleSystem system;
-
- function setUp() public {
- world = new World();
- components = world.components();
- systems = world.systems();
-
- // Place world and component addresses in SystemTest's storage
- SystemStorage.init(world, components);
- system = new SampleSystem(world, address(components));
- }
-
- // System has correct storage
- function testSystemStorage() public {
- assertEq(address(system.getWorld()), address(SystemStorage.world()));
- assertEq(address(system.getComponents()), address(SystemStorage.components()));
- }
-
- // SystemTest has correct storage
- function testSystemStorageTest() public {
- assertEq(address(world), address(SystemStorage.world()));
- assertEq(address(components), address(SystemStorage.components()));
- }
-}
diff --git a/packages/solecs/src/test/World.t.sol b/packages/solecs/src/test/World.t.sol
deleted file mode 100644
index 68fa4c58ad..0000000000
--- a/packages/solecs/src/test/World.t.sol
+++ /dev/null
@@ -1,90 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.0;
-
-import { DSTest } from "ds-test/test.sol";
-import { Vm } from "forge-std/Vm.sol";
-import { console } from "forge-std/console.sol";
-
-import { World, WorldQueryFragment } from "../World.sol";
-import { LibQuery } from "../LibQuery.sol";
-import { QueryFragment, QueryType } from "../interfaces/Query.sol";
-import { TestComponent1, TestComponent2, TestComponent3 } from "./components/TestComponent.sol";
-import { PrototypeTagComponent } from "./components/PrototypeTagComponent.sol";
-import { FromPrototypeComponent } from "./components/FromPrototypeComponent.sol";
-import { OwnedByEntityComponent } from "./components/OwnedByEntityComponent.sol";
-
-contract WorldTest is DSTest {
- Vm internal immutable vm = Vm(HEVM_ADDRESS);
-
- address payable[] internal users;
-
- World internal world;
-
- TestComponent1 internal component1;
- TestComponent2 internal component2;
- TestComponent3 internal component3;
-
- PrototypeTagComponent internal prototypeTag;
- FromPrototypeComponent internal fromPrototype;
- OwnedByEntityComponent internal ownedByEntity;
-
- function setUp() public {
- world = new World();
- world.init();
- address worldAddress = address(world);
- component1 = new TestComponent1(worldAddress);
- component2 = new TestComponent2(worldAddress);
- component3 = new TestComponent3(worldAddress);
- prototypeTag = new PrototypeTagComponent(worldAddress);
- fromPrototype = new FromPrototypeComponent(worldAddress);
- ownedByEntity = new OwnedByEntityComponent(worldAddress);
- }
-
- function testQuery() public {
- // 1 is a prototype with component1 value 1
- prototypeTag.set(1, new bytes(0));
- component1.set(1, abi.encode(1));
-
- // 2 is a prototype with component1 value 2
- prototypeTag.set(2, new bytes(0));
- component1.set(2, abi.encode(2));
-
- // 3 is a prototype with component2 value 1
- prototypeTag.set(3, new bytes(0));
- component2.set(3, abi.encode(1));
-
- // 4 is an instance of 1 and has component 3
- fromPrototype.set(4, 1);
- component3.set(4, abi.encode(1));
-
- // 5 is an instance of 2 and has component 3
- fromPrototype.set(5, 2);
- component3.set(5, abi.encode(1));
-
- // 6 is an instace of 3 and has component 3
- fromPrototype.set(6, 3);
- component3.set(6, abi.encode(1));
-
- // Gimme all entities with component3 and component1
- WorldQueryFragment[] memory fragments = new WorldQueryFragment[](3);
- fragments[0] = WorldQueryFragment(QueryType.ProxyRead, fromPrototype.id(), abi.encode(1));
- fragments[1] = WorldQueryFragment(QueryType.Has, component3.id(), new bytes(0)); // interim result 4,5,6
- fragments[2] = WorldQueryFragment(QueryType.Has, component1.id(), new bytes(0));
- uint256[] memory entities = world.query(fragments);
- assertTrue(entities.length == 2);
- assertTrue(entities[0] == 4);
- assertTrue(entities[1] == 5);
-
- // Gimme all entities with component3 and component2
- fragments[2] = WorldQueryFragment(QueryType.Has, component2.id(), new bytes(0));
- entities = world.query(fragments);
- assertTrue(entities.length == 1);
- assertTrue(entities[0] == 6);
-
- // Gimme all entities with component3 and component1 value 1
- fragments[2] = WorldQueryFragment(QueryType.HasValue, component1.id(), abi.encode(1));
- entities = world.query(fragments);
- assertTrue(entities.length == 1);
- assertTrue(entities[0] == 4);
- }
-}
diff --git a/packages/solecs/src/test/components/DamageComponent.sol b/packages/solecs/src/test/components/DamageComponent.sol
deleted file mode 100644
index 8dfd97a4f0..0000000000
--- a/packages/solecs/src/test/components/DamageComponent.sol
+++ /dev/null
@@ -1,26 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.0;
-import { Component } from "../../Component.sol";
-import { LibTypes } from "../../LibTypes.sol";
-
-uint256 constant ID = uint256(keccak256("mudwar.components.Damage"));
-
-contract DamageComponent is Component {
- constructor(address world) Component(world, ID) {}
-
- function getSchema() public pure override returns (string[] memory keys, LibTypes.SchemaValue[] memory values) {
- values[0] = LibTypes.SchemaValue.UINT256;
- }
-
- function set(uint256 entity, uint256 value) public {
- set(entity, abi.encode(value));
- }
-
- function getValue(uint256 entity) public view returns (uint256) {
- return abi.decode(getRawValue(entity), (uint256));
- }
-
- function getEntitiesWithValue(uint256 value) public view returns (uint256[] memory) {
- return getEntitiesWithValue(abi.encode(value));
- }
-}
diff --git a/packages/solecs/src/test/components/FromPrototypeComponent.sol b/packages/solecs/src/test/components/FromPrototypeComponent.sol
deleted file mode 100644
index 914141af0a..0000000000
--- a/packages/solecs/src/test/components/FromPrototypeComponent.sol
+++ /dev/null
@@ -1,26 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.0;
-import { Component } from "../../Component.sol";
-import { LibTypes } from "../../LibTypes.sol";
-
-contract FromPrototypeComponent is Component {
- uint256 public constant ID = uint256(keccak256("lib.fromPrototype"));
-
- constructor(address world) Component(world, ID) {}
-
- function getSchema() public pure override returns (string[] memory keys, LibTypes.SchemaValue[] memory values) {
- values[0] = LibTypes.SchemaValue.UINT256;
- }
-
- function set(uint256 entity, uint256 prototypeEntity) public {
- set(entity, abi.encode(prototypeEntity));
- }
-
- function getValue(uint256 entity) public view returns (uint256) {
- return abi.decode(getRawValue(entity), (uint256));
- }
-
- function getEntitiesWithValue(uint256 prototypeEntity) public view returns (uint256[] memory) {
- return getEntitiesWithValue(abi.encode(prototypeEntity));
- }
-}
diff --git a/packages/solecs/src/test/components/OwnedByEntityComponent.sol b/packages/solecs/src/test/components/OwnedByEntityComponent.sol
deleted file mode 100644
index 86ec30bcb9..0000000000
--- a/packages/solecs/src/test/components/OwnedByEntityComponent.sol
+++ /dev/null
@@ -1,26 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.0;
-import { Component } from "../../Component.sol";
-import { LibTypes } from "../../LibTypes.sol";
-
-contract OwnedByEntityComponent is Component {
- uint256 public constant ID = uint256(keccak256("lib.ownedByEntity"));
-
- constructor(address world) Component(world, ID) {}
-
- function getSchema() public pure override returns (string[] memory keys, LibTypes.SchemaValue[] memory values) {
- values[0] = LibTypes.SchemaValue.UINT256;
- }
-
- function set(uint256 entity, uint256 ownedByEntity) public {
- set(entity, abi.encode(ownedByEntity));
- }
-
- function getValue(uint256 entity) public view returns (uint256) {
- return abi.decode(getRawValue(entity), (uint256));
- }
-
- function getEntitiesWithValue(uint256 ownedByEntity) public view returns (uint256[] memory) {
- return getEntitiesWithValue(abi.encode(ownedByEntity));
- }
-}
diff --git a/packages/solecs/src/test/components/PositionComponent.sol b/packages/solecs/src/test/components/PositionComponent.sol
deleted file mode 100644
index 03d6ae2468..0000000000
--- a/packages/solecs/src/test/components/PositionComponent.sol
+++ /dev/null
@@ -1,37 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.0;
-
-import { Component } from "../../Component.sol";
-import { LibTypes } from "../../LibTypes.sol";
-
-struct Position {
- int64 x;
- int64 y;
-}
-
-uint256 constant ID = uint256(keccak256("mudwar.components.Position"));
-
-contract PositionComponent is Component {
- constructor(address world) Component(world, ID) {}
-
- function getSchema() public pure override returns (string[] memory keys, LibTypes.SchemaValue[] memory values) {
- keys[0] = "x";
- values[0] = LibTypes.SchemaValue.INT64;
-
- keys[1] = "y";
- values[1] = LibTypes.SchemaValue.INT64;
- }
-
- function set(uint256 entity, Position calldata value) public {
- set(entity, abi.encode(value));
- }
-
- function getValue(uint256 entity) public view returns (Position memory) {
- (int64 x, int64 y) = abi.decode(getRawValue(entity), (int64, int64));
- return Position(x, y);
- }
-
- function getEntitiesWithValue(Position calldata value) public view returns (uint256[] memory) {
- return getEntitiesWithValue(abi.encode(value));
- }
-}
diff --git a/packages/solecs/src/test/components/PrototypeTagComponent.sol b/packages/solecs/src/test/components/PrototypeTagComponent.sol
deleted file mode 100644
index 40d678b8eb..0000000000
--- a/packages/solecs/src/test/components/PrototypeTagComponent.sol
+++ /dev/null
@@ -1,26 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.0;
-import { Component } from "../../Component.sol";
-import { LibTypes } from "../../LibTypes.sol";
-
-contract PrototypeTagComponent is Component {
- uint256 public constant ID = uint256(keccak256("lib.prototypeTag"));
-
- constructor(address world) Component(world, ID) {}
-
- function getSchema() public pure override returns (string[] memory keys, LibTypes.SchemaValue[] memory values) {
- values[0] = LibTypes.SchemaValue.UINT256;
- }
-
- function set(uint256 entity, bool value) public {
- set(entity, abi.encode(value));
- }
-
- function getValue(uint256 entity) public view returns (bool) {
- return abi.decode(getRawValue(entity), (bool));
- }
-
- function getEntitiesWithValue(bool value) public view returns (uint256[] memory) {
- return getEntitiesWithValue(abi.encode(value));
- }
-}
diff --git a/packages/solecs/src/test/components/TestComponent.sol b/packages/solecs/src/test/components/TestComponent.sol
deleted file mode 100644
index f6a5a96e8c..0000000000
--- a/packages/solecs/src/test/components/TestComponent.sol
+++ /dev/null
@@ -1,54 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.0;
-import { Component } from "../../Component.sol";
-import { LibTypes } from "../../LibTypes.sol";
-
-contract TestComponent is Component {
- uint256 public constant ID = uint256(keccak256("lib.testComponent"));
-
- constructor(address world) Component(world, ID) {}
-
- function getSchema() public pure override returns (string[] memory keys, LibTypes.SchemaValue[] memory values) {
- values[0] = LibTypes.SchemaValue.UINT256;
- }
-}
-
-contract TestComponent1 is Component {
- uint256 public constant ID = uint256(keccak256("lib.testComponent1"));
-
- constructor(address world) Component(world, ID) {}
-
- function getSchema() public pure override returns (string[] memory keys, LibTypes.SchemaValue[] memory values) {
- values[0] = LibTypes.SchemaValue.UINT256;
- }
-}
-
-contract TestComponent2 is Component {
- uint256 public constant ID = uint256(keccak256("lib.testComponent2"));
-
- constructor(address world) Component(world, ID) {}
-
- function getSchema() public pure override returns (string[] memory keys, LibTypes.SchemaValue[] memory values) {
- values[0] = LibTypes.SchemaValue.UINT256;
- }
-}
-
-contract TestComponent3 is Component {
- uint256 public constant ID = uint256(keccak256("lib.testComponent3"));
-
- constructor(address world) Component(world, ID) {}
-
- function getSchema() public pure override returns (string[] memory keys, LibTypes.SchemaValue[] memory values) {
- values[0] = LibTypes.SchemaValue.UINT256;
- }
-}
-
-contract TestComponent4 is Component {
- uint256 public constant ID = uint256(keccak256("lib.testComponent4"));
-
- constructor(address world) Component(world, ID) {}
-
- function getSchema() public pure override returns (string[] memory keys, LibTypes.SchemaValue[] memory values) {
- values[0] = LibTypes.SchemaValue.UINT256;
- }
-}
diff --git a/packages/solecs/src/test/utils.t.sol b/packages/solecs/src/test/utils.t.sol
deleted file mode 100644
index 367171958f..0000000000
--- a/packages/solecs/src/test/utils.t.sol
+++ /dev/null
@@ -1,24 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.0;
-
-import { DSTestPlus } from "solmate/test/utils/DSTestPlus.sol";
-import { split } from "../utils.sol";
-
-contract UtilsTest is DSTestPlus {
- function testSplit() public {
- uint32 first = 1;
- uint64 second = 2;
-
- // Pack data
- bytes memory packed = bytes.concat(bytes4(first), bytes8(second));
-
- // Unpack data
- uint8[] memory lengths = new uint8[](2);
- lengths[0] = 4;
- lengths[1] = 8;
- bytes[] memory unpacked = split(packed, lengths);
-
- assertEq(uint32(bytes4(unpacked[0])), first);
- assertEq(uint64(bytes8(unpacked[1])), second);
- }
-}
diff --git a/packages/solecs/src/utils.sol b/packages/solecs/src/utils.sol
deleted file mode 100644
index e0fea3a128..0000000000
--- a/packages/solecs/src/utils.sol
+++ /dev/null
@@ -1,72 +0,0 @@
-// SPDX-License-Identifier: MIT
-pragma solidity >=0.8.0;
-
-import { IUint256Component } from "./interfaces/IUint256Component.sol";
-import { IComponent } from "./interfaces/IComponent.sol";
-import { ISystem } from "./interfaces/ISystem.sol";
-import { systemsComponentId } from "./constants.sol";
-
-/** Turn an entity ID into its corresponding Ethereum address. */
-function entityToAddress(uint256 entity) pure returns (address) {
- return address(uint160(entity));
-}
-
-/** Turn an Ethereum address into its corresponding entity ID. */
-function addressToEntity(address addr) pure returns (uint256) {
- return uint256(uint160(addr));
-}
-
-/** Get an Ethereum address from an address/id registry component (like _components/_systems in World.sol) */
-function getAddressById(IUint256Component registry, uint256 id) view returns (address) {
- uint256[] memory entities = registry.getEntitiesWithValue(id);
- require(entities.length != 0, "id not registered");
- return entityToAddress(entities[0]);
-}
-
-/** Get an entity id from an address/id registry component (like _components/_systems in World.sol) */
-function getIdByAddress(IUint256Component registry, address addr) view returns (uint256) {
- require(registry.has(addressToEntity(addr)), "address not registered");
- return registry.getValue(addressToEntity(addr));
-}
-
-/** Get a Component from an address/id registry component (like _components in World.sol) */
-function getComponentById(IUint256Component components, uint256 id) view returns (IComponent) {
- return IComponent(getAddressById(components, id));
-}
-
-/**
- * Get the Ethereum address of a System from an address/id component registry component in which the
- * System registry component is registered (like _components in World.sol)
- */
-function getSystemAddressById(IUint256Component components, uint256 id) view returns (address) {
- IUint256Component systems = IUint256Component(getAddressById(components, systemsComponentId));
- return getAddressById(systems, id);
-}
-
-/**
- * Get a System from an address/id component registry component in which the
- * System registry component is registered (like _components in World.sol)
- */
-function getSystemById(IUint256Component components, uint256 id) view returns (ISystem) {
- return ISystem(getSystemAddressById(components, id));
-}
-
-/** Split a single bytes blob into an array of bytes of the given length */
-function split(bytes memory data, uint8[] memory lengths) pure returns (bytes[] memory) {
- bytes[] memory unpacked = new bytes[](lengths.length);
- uint256 sum = 0;
- for (uint256 i = 0; i < lengths.length; ) {
- unpacked[i] = new bytes(lengths[i]);
- for (uint256 j = 0; j < lengths[i]; ) {
- unchecked {
- unpacked[i][j] = data[sum + j];
- j += 1;
- }
- }
- unchecked {
- sum += lengths[i];
- i += 1;
- }
- }
- return unpacked;
-}
diff --git a/packages/solecs/tasks/compile.ts b/packages/solecs/tasks/compile.ts
deleted file mode 100644
index 65335021b4..0000000000
--- a/packages/solecs/tasks/compile.ts
+++ /dev/null
@@ -1,38 +0,0 @@
-import { TASK_COMPILE_SOLIDITY } from "hardhat/builtin-tasks/task-names";
-import * as fs from "fs";
-import * as path from "path";
-import { subtask } from "hardhat/config";
-
-subtask(TASK_COMPILE_SOLIDITY).setAction(async (_: { force: boolean; quiet: boolean }, { config }, runSuper) => {
- console.log("Symlinking forge-style libraries");
- const symlinks: string[] = [];
- const remappings = fs
- .readFileSync("remappings.txt")
- .toString()
- .split("\n")
- .filter((r) => r.length > 0)
- .map((r) => r.split("="));
-
- console.log("remappings", remappings);
- for (const [library, libraryPath] of remappings) {
- const symlinkPath = path.join(process.cwd(), library.replace("/", ""));
- console.log("Adding symlink at path: " + symlinkPath);
- if (fs.existsSync(symlinkPath)) {
- console.warn("symlink already exists!");
- } else {
- const libPath = path.join(config.paths.sources, "..", libraryPath);
- fs.symlinkSync(libPath, symlinkPath, "dir");
- }
- symlinks.push(symlinkPath);
- }
- try {
- await runSuper();
- } catch (e) {
- console.error(e);
- } finally {
- for (const symlink of symlinks) {
- console.log("Removing symlink at path: " + symlink);
- fs.unlinkSync(symlink);
- }
- }
-});
diff --git a/packages/solecs/tsconfig.json b/packages/solecs/tsconfig.json
deleted file mode 100644
index e5312945c8..0000000000
--- a/packages/solecs/tsconfig.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "compilerOptions": {
- "target": "es2020",
- "moduleResolution": "node",
- "esModuleInterop": true
- }
-}
diff --git a/packages/std-client/package.json b/packages/std-client/package.json
index 1b4ac51b04..a808f76911 100644
--- a/packages/std-client/package.json
+++ b/packages/std-client/package.json
@@ -33,7 +33,6 @@
"@latticexyz/common": "workspace:*",
"@latticexyz/config": "workspace:*",
"@latticexyz/recs": "workspace:*",
- "@latticexyz/solecs": "workspace:*",
"@latticexyz/store": "workspace:*",
"@latticexyz/utils": "workspace:*",
"@latticexyz/world": "workspace:*",
diff --git a/packages/world/src/modules/keyswithvalue/KeysWithValueHook.sol b/packages/world/src/modules/keyswithvalue/KeysWithValueHook.sol
index ce53f7792f..d16f90b2a2 100644
--- a/packages/world/src/modules/keyswithvalue/KeysWithValueHook.sol
+++ b/packages/world/src/modules/keyswithvalue/KeysWithValueHook.sol
@@ -17,7 +17,6 @@ import { getTargetTableSelector } from "../utils/getTargetTableSelector.sol";
/**
* This is a very naive and inefficient implementation for now.
* We can optimize this by adding support for `setIndexOfField` in Store
- * and then replicate logic from solecs's Set.sol.
* (See https://github.com/latticexyz/mud/issues/444)
*
* Note: if a table with composite keys is used, only the first key is indexed
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 3e5d4c1924..2039f50162 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -120,9 +120,6 @@ importers:
'@latticexyz/services':
specifier: workspace:*
version: link:../services
- '@latticexyz/solecs':
- specifier: workspace:*
- version: link:../solecs
'@latticexyz/store':
specifier: workspace:*
version: link:../store
@@ -651,45 +648,7 @@ importers:
specifier: ^6.7.0
version: 6.7.0(postcss@8.4.23)(typescript@5.1.6)
- packages/solecs:
- dependencies:
- '@ethersproject/abi':
- specifier: ^5.7.0
- version: 5.7.0
- '@ethersproject/providers':
- specifier: ^5.7.2
- version: 5.7.2
- '@solidstate/contracts':
- specifier: ^0.0.52
- version: 0.0.52
- ds-test:
- specifier: https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0
- version: github.com/dapphub/ds-test/e282159d5170298eb2455a6c05280ab5a73a4ef0
- ethers:
- specifier: ^5.7.2
- version: 5.7.2
- memmove:
- specifier: https://github.com/dk1a/memmove.git#ffd71cd77b1708574ef46a667b23ca3a5cc9fa27
- version: github.com/dk1a/memmove/ffd71cd77b1708574ef46a667b23ca3a5cc9fa27
- solmate:
- specifier: https://github.com/transmissions11/solmate.git#9cf1428245074e39090dceacb0c28b1f684f584c
- version: github.com/transmissions11/solmate/9cf1428245074e39090dceacb0c28b1f684f584c
- devDependencies:
- '@typechain/ethers-v5':
- specifier: ^10.2.0
- version: 10.2.0(@ethersproject/abi@5.7.0)(@ethersproject/bytes@5.7.0)(@ethersproject/providers@5.7.2)(ethers@5.7.2)(typechain@8.1.1)(typescript@5.1.6)
- forge-std:
- specifier: https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1
- version: github.com/foundry-rs/forge-std/74cfb77e308dd188d2f58864aaf44963ae6b88b1
- hardhat:
- specifier: ^2.10.2
- version: 2.10.2(typescript@5.1.6)
- solhint:
- specifier: ^3.3.7
- version: 3.3.7
- typechain:
- specifier: ^8.1.1
- version: 8.1.1(typescript@5.1.6)
+ packages/solecs: {}
packages/solhint-config-mud:
devDependencies:
@@ -727,9 +686,6 @@ importers:
'@latticexyz/recs':
specifier: workspace:*
version: link:../recs
- '@latticexyz/solecs':
- specifier: workspace:*
- version: link:../solecs
'@latticexyz/store':
specifier: workspace:*
version: link:../store
@@ -3119,10 +3075,6 @@ packages:
antlr4ts: 0.5.0-alpha.4
dev: false
- /@solidstate/contracts@0.0.52:
- resolution: {integrity: sha512-xSBn5oLnfYtgNYrsRq/COlWHt0NxK26PFQ3FvI2DDMAFpZKFsffGLzUl8umezj2gVKpN7EZ+EVLdPKjqx6eUOw==}
- dev: false
-
/@testing-library/react-hooks@8.0.1(@types/react@18.2.6)(react-test-renderer@18.2.0)(react@18.2.0):
resolution: {integrity: sha512-Aqhl2IVmLt8IovEVarNDFuJDVWVvhnr9/GCU6UUnrYXwgDFF9h2L2o2P9KBni1AST5sT6riAyoukFLyjQUgD/g==}
engines: {node: '>=12'}
@@ -11575,12 +11527,6 @@ packages:
name: ds-test
version: 1.0.0
- github.com/dk1a/memmove/ffd71cd77b1708574ef46a667b23ca3a5cc9fa27:
- resolution: {tarball: https://codeload.github.com/dk1a/memmove/tar.gz/ffd71cd77b1708574ef46a667b23ca3a5cc9fa27}
- name: memmove
- version: 0.1.0
- dev: false
-
github.com/foundry-rs/forge-std/74cfb77e308dd188d2f58864aaf44963ae6b88b1:
resolution: {tarball: https://codeload.github.com/foundry-rs/forge-std/tar.gz/74cfb77e308dd188d2f58864aaf44963ae6b88b1}
name: forge-std
@@ -11608,9 +11554,3 @@ packages:
transitivePeerDependencies:
- encoding
dev: false
-
- github.com/transmissions11/solmate/9cf1428245074e39090dceacb0c28b1f684f584c:
- resolution: {tarball: https://codeload.github.com/transmissions11/solmate/tar.gz/9cf1428245074e39090dceacb0c28b1f684f584c}
- name: solmate
- version: 6.5.0
- dev: false