From c32c8e8f2ccac02c4242f715f296bffd5465bd71 Mon Sep 17 00:00:00 2001 From: Kevin Ingersoll Date: Tue, 22 Aug 2023 02:10:31 -0700 Subject: [PATCH] chore: delete std-contracts package (#1341) --- .changeset/brown-icons-burn.md | 6 + packages/cli/package.json | 1 - packages/std-contracts/.gitignore | 9 - packages/std-contracts/.npmignore | 7 - packages/std-contracts/.solhint.json | 8 - packages/std-contracts/CHANGELOG.md | 442 ------------------ packages/std-contracts/README.md | 7 - packages/std-contracts/exports.txt | 6 - packages/std-contracts/foundry.toml | 10 - packages/std-contracts/hardhat.config.ts | 19 - packages/std-contracts/index.ts | 1 - packages/std-contracts/package.json | 32 +- packages/std-contracts/remappings.txt | 6 - .../src/components/AddressBareComponent.sol | 24 - .../src/components/AddressComponent.sol | 28 -- .../src/components/BoolBareComponent.sol | 24 - .../src/components/BoolComponent.sol | 28 -- .../src/components/CoordBareComponent.sol | 32 -- .../src/components/CoordComponent.sol | 36 -- .../src/components/FunctionBareComponent.sol | 38 -- .../src/components/FunctionComponent.sol | 42 -- .../src/components/Int32BareComponent.sol | 24 - .../src/components/Int32Component.sol | 28 -- .../components/StringArrayBareComponent.sol | 23 - .../src/components/StringArrayComponent.sol | 27 -- .../src/components/StringBareComponent.sol | 24 - .../src/components/StringComponent.sol | 28 -- .../SystemCallbackBareComponent.sol | 48 -- .../components/SystemCallbackComponent.sol | 34 -- .../components/Uint256ArrayBareComponent.sol | 23 - .../src/components/Uint256ArrayComponent.sol | 27 -- .../src/components/Uint256BareComponent.sol | 27 -- .../src/components/Uint256Component.sol | 3 - .../components/Uint32ArrayBareComponent.sol | 23 - .../src/components/Uint32ArrayComponent.sol | 27 -- .../src/components/Uint32BareComponent.sol | 24 - .../src/components/Uint32Component.sol | 28 -- .../components/VoxelCoordBareComponent.sol | 36 -- .../src/components/VoxelCoordComponent.sol | 40 -- .../std-contracts/src/libraries/LibUtils.sol | 130 ------ .../src/systems/BulkSetStateSystem.sol | 45 -- .../src/systems/ComponentDevSystem.sol | 35 -- .../src/systems/UpgradableSystem.sol | 54 --- packages/std-contracts/src/test/MudTest.t.sol | 55 --- .../src/test/TestBareComponent.sol | 46 -- .../std-contracts/src/test/TestComponent.sol | 50 -- .../std-contracts/src/test/TestSystem.sol | 34 -- packages/std-contracts/src/test/Utilities.sol | 35 -- packages/std-contracts/tasks/compile.ts | 38 -- .../std-contracts/test/ComponentGas.t.sol | 177 ------- .../test/SystemCallbackComponent.t.sol | 144 ------ packages/std-contracts/tsconfig.json | 102 ---- packages/store/package.json | 1 - packages/world/package.json | 1 - pnpm-lock.yaml | 45 +- 55 files changed, 11 insertions(+), 2281 deletions(-) create mode 100644 .changeset/brown-icons-burn.md delete mode 100644 packages/std-contracts/.gitignore delete mode 100644 packages/std-contracts/.npmignore delete mode 100644 packages/std-contracts/.solhint.json delete mode 100644 packages/std-contracts/CHANGELOG.md delete mode 100644 packages/std-contracts/README.md delete mode 100644 packages/std-contracts/exports.txt delete mode 100644 packages/std-contracts/foundry.toml delete mode 100644 packages/std-contracts/hardhat.config.ts delete mode 100644 packages/std-contracts/index.ts delete mode 100644 packages/std-contracts/remappings.txt delete mode 100644 packages/std-contracts/src/components/AddressBareComponent.sol delete mode 100644 packages/std-contracts/src/components/AddressComponent.sol delete mode 100644 packages/std-contracts/src/components/BoolBareComponent.sol delete mode 100644 packages/std-contracts/src/components/BoolComponent.sol delete mode 100644 packages/std-contracts/src/components/CoordBareComponent.sol delete mode 100644 packages/std-contracts/src/components/CoordComponent.sol delete mode 100644 packages/std-contracts/src/components/FunctionBareComponent.sol delete mode 100644 packages/std-contracts/src/components/FunctionComponent.sol delete mode 100644 packages/std-contracts/src/components/Int32BareComponent.sol delete mode 100644 packages/std-contracts/src/components/Int32Component.sol delete mode 100644 packages/std-contracts/src/components/StringArrayBareComponent.sol delete mode 100644 packages/std-contracts/src/components/StringArrayComponent.sol delete mode 100644 packages/std-contracts/src/components/StringBareComponent.sol delete mode 100644 packages/std-contracts/src/components/StringComponent.sol delete mode 100644 packages/std-contracts/src/components/SystemCallbackBareComponent.sol delete mode 100644 packages/std-contracts/src/components/SystemCallbackComponent.sol delete mode 100644 packages/std-contracts/src/components/Uint256ArrayBareComponent.sol delete mode 100644 packages/std-contracts/src/components/Uint256ArrayComponent.sol delete mode 100644 packages/std-contracts/src/components/Uint256BareComponent.sol delete mode 100644 packages/std-contracts/src/components/Uint256Component.sol delete mode 100644 packages/std-contracts/src/components/Uint32ArrayBareComponent.sol delete mode 100644 packages/std-contracts/src/components/Uint32ArrayComponent.sol delete mode 100644 packages/std-contracts/src/components/Uint32BareComponent.sol delete mode 100644 packages/std-contracts/src/components/Uint32Component.sol delete mode 100644 packages/std-contracts/src/components/VoxelCoordBareComponent.sol delete mode 100644 packages/std-contracts/src/components/VoxelCoordComponent.sol delete mode 100644 packages/std-contracts/src/libraries/LibUtils.sol delete mode 100644 packages/std-contracts/src/systems/BulkSetStateSystem.sol delete mode 100644 packages/std-contracts/src/systems/ComponentDevSystem.sol delete mode 100644 packages/std-contracts/src/systems/UpgradableSystem.sol delete mode 100644 packages/std-contracts/src/test/MudTest.t.sol delete mode 100644 packages/std-contracts/src/test/TestBareComponent.sol delete mode 100644 packages/std-contracts/src/test/TestComponent.sol delete mode 100644 packages/std-contracts/src/test/TestSystem.sol delete mode 100644 packages/std-contracts/src/test/Utilities.sol delete mode 100644 packages/std-contracts/tasks/compile.ts delete mode 100644 packages/std-contracts/test/ComponentGas.t.sol delete mode 100644 packages/std-contracts/test/SystemCallbackComponent.t.sol delete mode 100644 packages/std-contracts/tsconfig.json diff --git a/.changeset/brown-icons-burn.md b/.changeset/brown-icons-burn.md new file mode 100644 index 0000000000..5752af611d --- /dev/null +++ b/.changeset/brown-icons-burn.md @@ -0,0 +1,6 @@ +--- +"@latticexyz/cli": patch +"@latticexyz/std-contracts": major +--- + +Removes `std-contracts` 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/packages/cli/package.json b/packages/cli/package.json index c94f4651f9..302124ec05 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -38,7 +38,6 @@ "@latticexyz/schema-type": "workspace:*", "@latticexyz/services": "workspace:*", "@latticexyz/solecs": "workspace:*", - "@latticexyz/std-contracts": "workspace:*", "@latticexyz/store": "workspace:*", "@latticexyz/utils": "workspace:*", "@latticexyz/world": "workspace:*", diff --git a/packages/std-contracts/.gitignore b/packages/std-contracts/.gitignore deleted file mode 100644 index 5b4fad10b0..0000000000 --- a/packages/std-contracts/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -cache -out -abi -types/ethers-contracts -docs -_docs -artifacts -DOCS.md -API \ No newline at end of file diff --git a/packages/std-contracts/.npmignore b/packages/std-contracts/.npmignore deleted file mode 100644 index f9cbc3639b..0000000000 --- a/packages/std-contracts/.npmignore +++ /dev/null @@ -1,7 +0,0 @@ -* - -!src/** -!abi/** -!types/** -!package.json -!README.md \ No newline at end of file diff --git a/packages/std-contracts/.solhint.json b/packages/std-contracts/.solhint.json deleted file mode 100644 index 4e2baa8be7..0000000000 --- a/packages/std-contracts/.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/std-contracts/CHANGELOG.md b/packages/std-contracts/CHANGELOG.md deleted file mode 100644 index c698d0ea0e..0000000000 --- a/packages/std-contracts/CHANGELOG.md +++ /dev/null @@ -1,442 +0,0 @@ -# Change Log - -## 2.0.0-next.3 - -## 2.0.0-next.2 - -## 2.0.0-next.1 - -## 2.0.0-next.0 - -### Minor Changes - -- [#1061](https://github.com/latticexyz/mud/pull/1061) [`a7b30c79`](https://github.com/latticexyz/mud/commit/a7b30c79bcc78530d2d01858de46a0fb87954fda) Thanks [@dk1a](https://github.com/dk1a)! - Rename `MudV2Test` to `MudTest` and move from `@latticexyz/std-contracts` to `@latticexyz/store`. - - ```solidity - // old import - import { MudV2Test } from "@latticexyz/std-contracts/src/test/MudV2Test.t.sol"; - // new import - import { MudTest } from "@latticexyz/store/src/MudTest.sol"; - ``` - - Refactor `StoreSwitch` to use a storage slot instead of `function isStore()` to determine which contract is Store: - - - Previously `StoreSwitch` called `isStore()` on `msg.sender` to determine if `msg.sender` is a `Store` contract. If the call succeeded, the `Store` methods were called on `msg.sender`, otherwise the data was written to the own storage. - - With this change `StoreSwitch` instead checks for an `address` in a known storage slot. If the address equals the own address, data is written to the own storage. If it is an external address, `Store` methods are called on this address. If it is unset (`address(0)`), store methods are called on `msg.sender`. - - In practice this has the same effect as before: By default the `World` contracts sets its own address in `StoreSwitch`, while `System` contracts keep the Store address undefined, so `Systems` write to their caller (`World`) if they are executed via `call` or directly to the `World` storage if they are executed via `delegatecall`. - - Besides gas savings, this change has two additional benefits: - 1. it is now possible for `Systems` to explicitly set a `Store` address to make them exclusive to that `Store` and - 2. table libraries can now be used in tests without having to provide an explicit `Store` argument, because the `MudTest` base contract redirects reads and writes to the internal `World` contract. - -### 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)) -- **cli:** add `mud test-v2` command ([#554](https://github.com/latticexyz/mud/issues/554)) ([d6be8b0](https://github.com/latticexyz/mud/commit/d6be8b08d0eeae3b10eb9e7bffb6d4dd2fc58aa0)) - -# [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/std-contracts - -# [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/std-contracts - -# [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/std-contracts - -# [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/std-contracts - -## [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/std-contracts - -# [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/std-contracts - -# [1.35.0](https://github.com/latticexyz/mud/compare/v1.34.0...v1.35.0) (2023-02-15) - -### 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/std-contracts - -# [1.33.0](https://github.com/latticexyz/mud/compare/v1.32.0...v1.33.0) (2023-01-12) - -### Features - -- **std-contracts:** add SystemCallbackComponent ([#303](https://github.com/latticexyz/mud/issues/303)) ([7b3a859](https://github.com/latticexyz/mud/commit/7b3a859b8a776e66183baef900fad6f40b1529cb)) - -# [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/std-contracts - -## [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/std-contracts - -## [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/std-contracts - -## [1.31.1](https://github.com/latticexyz/mud/compare/v1.31.0...v1.31.1) (2022-12-15) - -### Bug Fixes - -- **std-contracts:** add virtual to MudTest setUp ([#298](https://github.com/latticexyz/mud/issues/298)) ([942cfcd](https://github.com/latticexyz/mud/commit/942cfcdd41ea961c32478764e7c4f33a1b6ca16e)) - -# [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)) - -## [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/std-contracts - -# [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 - -- **std-contracts:** basic gas metrics for mud components ([#255](https://github.com/latticexyz/mud/issues/255)) ([2aeb4a6](https://github.com/latticexyz/mud/commit/2aeb4a65343de8bd026afcfa4b3b043c90662683)) - -## [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/std-contracts - -# [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/std-contracts - -# [1.27.0](https://github.com/latticexyz/mud/compare/v1.26.0...v1.27.0) (2022-11-15) - -**Note:** Version bump only for package @latticexyz/std-contracts - -# [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/std-contracts - -## [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/std-contracts - -# [1.25.0](https://github.com/latticexyz/mud/compare/v1.24.1...v1.25.0) (2022-11-03) - -**Note:** Version bump only for package @latticexyz/std-contracts - -## [1.24.1](https://github.com/latticexyz/mud/compare/v1.24.0...v1.24.1) (2022-10-29) - -### Bug Fixes - -- **std-contracts:** use assembly for delegation in UpgradableSystem ([#228](https://github.com/latticexyz/mud/issues/228)) ([1fa46fd](https://github.com/latticexyz/mud/commit/1fa46fd37da706e4c559a7b7d02ffa1b1bacc1bc)) - -# [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/std-contracts - -## [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/std-contracts - -# [1.23.0](https://github.com/latticexyz/mud/compare/v1.22.0...v1.23.0) (2022-10-26) - -### Features - -- add UpgradableSystem ([#225](https://github.com/latticexyz/mud/issues/225)) ([8229633](https://github.com/latticexyz/mud/commit/822963305af2af0a7409282f815fc6a1dd3ca2b2)) - -# [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/std-contracts - -# [1.21.0](https://github.com/latticexyz/mud/compare/v1.20.0...v1.21.0) (2022-10-26) - -**Note:** Version bump only for package @latticexyz/std-contracts - -# [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/std-contracts - -# [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/std-contracts - -# [1.18.0](https://github.com/latticexyz/mud/compare/v1.17.0...v1.18.0) (2022-10-21) - -**Note:** Version bump only for package @latticexyz/std-contracts - -# [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/std-contracts - -# [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/std-contracts - -# [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/std-contracts - -## [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/std-contracts - -## [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/std-contracts - -# [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/std-contracts - -# [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/std-contracts - -# [1.12.0](https://github.com/latticexyz/mud/compare/v1.11.0...v1.12.0) (2022-10-12) - -### Bug Fixes - -- **std-contracts:** fix name of Uint32Component ([#201](https://github.com/latticexyz/mud/issues/201)) ([82600e2](https://github.com/latticexyz/mud/commit/82600e24a71d48baa4956294b09de567eae33e48)) - -# [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/std-contracts - -# [1.9.0](https://github.com/latticexyz/mud/compare/v1.8.0...v1.9.0) (2022-10-11) - -**Note:** Version bump only for package @latticexyz/std-contracts - -# [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/std-contracts - -## [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/std-contracts - -# [1.7.0](https://github.com/latticexyz/mud/compare/v1.6.0...v1.7.0) (2022-10-06) - -**Note:** Version bump only for package @latticexyz/std-contracts - -# [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/std-contracts - -## [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/std-contracts - -# [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/std-contracts - -## [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/std-contracts - -# [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/std-contracts - -# [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/std-contracts - -# [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/std-contracts - -# [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/std-contracts - -# [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/std-contracts - -## [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/std-contracts - -## [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/std-contracts - -## [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/std-contracts - -## [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/std-contracts - -# [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/std-contracts - -# [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/std-contracts - -## [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/std-contracts - -## [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/std-contracts - -# [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/std-contracts - -# [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/std-contracts - -# [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/std-contracts - -# [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/std-contracts - -# [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/std-contracts - -## [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) - -### 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/std-contracts - -# [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/std-contracts - -## [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/std-contracts - -# [0.5.0](https://github.com/latticexyz/mud/compare/v0.4.3...v0.5.0) (2022-08-05) - -**Note:** Version bump only for package @latticexyz/std-contracts - -## [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/std-contracts - -## [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/std-contracts - -## [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/std-contracts - -# [0.4.0](https://github.com/latticexyz/mud/compare/v0.3.2...v0.4.0) (2022-07-29) - -### Features - -- add 3d components ([d230339](https://github.com/latticexyz/mud/commit/d230339bdf3fbfaf4596de759a25fb616a7ab572)) - -## [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/std-contracts - -## [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/std-contracts - -# [0.3.0](https://github.com/latticexyz/mud/compare/v0.2.0...v0.3.0) (2022-07-26) - -### Bug Fixes - -- **std-contracts:** add openzeppelin to remappings to fix build ([5db32a8](https://github.com/latticexyz/mud/commit/5db32a80ecbe9c1b66517fc671beb34062296814)) - -### Features - -- 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 - -- component browser 📈 ([#16](https://github.com/latticexyz/mud/issues/16)) ([37af75e](https://github.com/latticexyz/mud/commit/37af75ecb11266e5877d04cb3224698605b87646)) -- 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) diff --git a/packages/std-contracts/README.md b/packages/std-contracts/README.md deleted file mode 100644 index 547b78319d..0000000000 --- a/packages/std-contracts/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# MUD Contracts Standard Library - -## Adding new components - -Important: add new components to `exports.txt` to include them in the compile script. - -Components/Functions for making MUD game contracts diff --git a/packages/std-contracts/exports.txt b/packages/std-contracts/exports.txt deleted file mode 100644 index e6cf431723..0000000000 --- a/packages/std-contracts/exports.txt +++ /dev/null @@ -1,6 +0,0 @@ -AddressComponent -BoolComponent -CoordComponent -StringComponent -Uint32Component -Uint256Component \ No newline at end of file diff --git a/packages/std-contracts/foundry.toml b/packages/std-contracts/foundry.toml deleted file mode 100644 index 56279dd4d6..0000000000 --- a/packages/std-contracts/foundry.toml +++ /dev/null @@ -1,10 +0,0 @@ -[profile.default] -solc_version = "0.8.13" -ffi = false -fuzz_runs = 256 -optimizer = true -optimizer_runs = 1000000 -verbosity = 2 -allow_paths = ["../../node_modules", "../solecs"] -src = "src" -out = "out" diff --git a/packages/std-contracts/hardhat.config.ts b/packages/std-contracts/hardhat.config.ts deleted file mode 100644 index 32338a8fe1..0000000000 --- a/packages/std-contracts/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/std-contracts/index.ts b/packages/std-contracts/index.ts deleted file mode 100644 index cb0ff5c3b5..0000000000 --- a/packages/std-contracts/index.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/packages/std-contracts/package.json b/packages/std-contracts/package.json index 637511b3aa..2a434ff02a 100644 --- a/packages/std-contracts/package.json +++ b/packages/std-contracts/package.json @@ -1,35 +1,5 @@ { "name": "@latticexyz/std-contracts", "version": "2.0.0-next.3", - "description": "MUD Contracts Standard Library", - "repository": { - "type": "git", - "url": "https://github.com/latticexyz/mud.git", - "directory": "packages/std-contracts" - }, - "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": "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" - }, - "devDependencies": { - "@latticexyz/solecs": "workspace:*", - "@solidstate/contracts": "^0.0.52", - "@typechain/ethers-v5": "^10.2.0", - "ds-test": "https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0", - "forge-std": "https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1", - "hardhat": "^2.10.2", - "memmove": "https://github.com/dk1a/memmove.git#ffd71cd77b1708574ef46a667b23ca3a5cc9fa27", - "solhint": "^3.3.7", - "solmate": "https://github.com/transmissions11/solmate.git#9cf1428245074e39090dceacb0c28b1f684f584c", - "typechain": "^8.1.1" - }, - "gitHead": "914a1e0ae4a573d685841ca2ea921435057deb8f" + "private": true } diff --git a/packages/std-contracts/remappings.txt b/packages/std-contracts/remappings.txt deleted file mode 100644 index 353e9cbd78..0000000000 --- a/packages/std-contracts/remappings.txt +++ /dev/null @@ -1,6 +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 -solecs/=node_modules/@latticexyz/solecs/src/ -@solidstate/=node_modules/@solidstate/ diff --git a/packages/std-contracts/src/components/AddressBareComponent.sol b/packages/std-contracts/src/components/AddressBareComponent.sol deleted file mode 100644 index b2d0343aaa..0000000000 --- a/packages/std-contracts/src/components/AddressBareComponent.sol +++ /dev/null @@ -1,24 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; -import "solecs/BareComponent.sol"; - -contract AddressBareComponent is BareComponent { - constructor(address world, uint256 id) BareComponent(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, address value) public virtual { - set(entity, abi.encode(value)); - } - - function getValue(uint256 entity) public view virtual returns (address) { - address value = abi.decode(getRawValue(entity), (address)); - return value; - } -} diff --git a/packages/std-contracts/src/components/AddressComponent.sol b/packages/std-contracts/src/components/AddressComponent.sol deleted file mode 100644 index facc609024..0000000000 --- a/packages/std-contracts/src/components/AddressComponent.sol +++ /dev/null @@ -1,28 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; -import "solecs/Component.sol"; - -contract AddressComponent is Component { - 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, address value) public virtual { - set(entity, abi.encode(value)); - } - - function getValue(uint256 entity) public view virtual returns (address) { - address value = abi.decode(getRawValue(entity), (address)); - return value; - } - - function getEntitiesWithValue(address value) public view virtual returns (uint256[] memory) { - return getEntitiesWithValue(abi.encode(value)); - } -} diff --git a/packages/std-contracts/src/components/BoolBareComponent.sol b/packages/std-contracts/src/components/BoolBareComponent.sol deleted file mode 100644 index 70b1158201..0000000000 --- a/packages/std-contracts/src/components/BoolBareComponent.sol +++ /dev/null @@ -1,24 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; -import "solecs/BareComponent.sol"; - -contract BoolBareComponent is BareComponent { - constructor(address world, uint256 id) BareComponent(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.BOOL; - } - - function set(uint256 entity) public virtual { - set(entity, abi.encode(true)); - } - - function getValue(uint256 entity) public view virtual returns (bool) { - bool value = abi.decode(getRawValue(entity), (bool)); - return value; - } -} diff --git a/packages/std-contracts/src/components/BoolComponent.sol b/packages/std-contracts/src/components/BoolComponent.sol deleted file mode 100644 index a5953dc609..0000000000 --- a/packages/std-contracts/src/components/BoolComponent.sol +++ /dev/null @@ -1,28 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; -import "solecs/Component.sol"; - -contract BoolComponent is Component { - 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.BOOL; - } - - function set(uint256 entity) public { - set(entity, abi.encode(true)); - } - - function getValue(uint256 entity) public view virtual returns (bool) { - bool value = abi.decode(getRawValue(entity), (bool)); - return value; - } - - function getEntitiesWithValue(bool value) public view virtual returns (uint256[] memory) { - return getEntitiesWithValue(abi.encode(value)); - } -} diff --git a/packages/std-contracts/src/components/CoordBareComponent.sol b/packages/std-contracts/src/components/CoordBareComponent.sol deleted file mode 100644 index 54f9ad6cda..0000000000 --- a/packages/std-contracts/src/components/CoordBareComponent.sol +++ /dev/null @@ -1,32 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; -import "solecs/BareComponent.sol"; - -struct Coord { - int32 x; - int32 y; -} - -contract CoordBareComponent is BareComponent { - constructor(address world, uint256 id) BareComponent(world, id) {} - - function getSchema() public pure override returns (string[] memory keys, LibTypes.SchemaValue[] memory values) { - keys = new string[](2); - values = new LibTypes.SchemaValue[](2); - - keys[0] = "x"; - values[0] = LibTypes.SchemaValue.INT32; - - keys[1] = "y"; - values[1] = LibTypes.SchemaValue.INT32; - } - - function set(uint256 entity, Coord calldata value) public virtual { - set(entity, abi.encode(value)); - } - - function getValue(uint256 entity) public view virtual returns (Coord memory) { - (int32 x, int32 y) = abi.decode(getRawValue(entity), (int32, int32)); - return Coord(x, y); - } -} diff --git a/packages/std-contracts/src/components/CoordComponent.sol b/packages/std-contracts/src/components/CoordComponent.sol deleted file mode 100644 index b97c5e11ff..0000000000 --- a/packages/std-contracts/src/components/CoordComponent.sol +++ /dev/null @@ -1,36 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; -import "solecs/Component.sol"; - -struct Coord { - int32 x; - int32 y; -} - -contract CoordComponent is Component { - constructor(address world, uint256 id) Component(world, id) {} - - function getSchema() public pure override returns (string[] memory keys, LibTypes.SchemaValue[] memory values) { - keys = new string[](2); - values = new LibTypes.SchemaValue[](2); - - keys[0] = "x"; - values[0] = LibTypes.SchemaValue.INT32; - - keys[1] = "y"; - values[1] = LibTypes.SchemaValue.INT32; - } - - function set(uint256 entity, Coord calldata value) public virtual { - set(entity, abi.encode(value)); - } - - function getValue(uint256 entity) public view virtual returns (Coord memory) { - (int32 x, int32 y) = abi.decode(getRawValue(entity), (int32, int32)); - return Coord(x, y); - } - - function getEntitiesWithValue(Coord calldata coord) public view virtual returns (uint256[] memory) { - return getEntitiesWithValue(abi.encode(coord)); - } -} diff --git a/packages/std-contracts/src/components/FunctionBareComponent.sol b/packages/std-contracts/src/components/FunctionBareComponent.sol deleted file mode 100644 index 36b2ff23a3..0000000000 --- a/packages/std-contracts/src/components/FunctionBareComponent.sol +++ /dev/null @@ -1,38 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; -import "solecs/BareComponent.sol"; - -struct FunctionSelector { - address contr; - bytes4 func; -} - -contract FunctionBareComponent is BareComponent { - constructor(address world, uint256 id) BareComponent(world, id) {} - - function getSchema() public pure override returns (string[] memory keys, LibTypes.SchemaValue[] memory values) { - keys = new string[](2); - values = new LibTypes.SchemaValue[](2); - - keys[0] = "contr"; - values[0] = LibTypes.SchemaValue.ADDRESS; - - keys[1] = "func"; - values[1] = LibTypes.SchemaValue.BYTES4; - } - - function set(uint256 entity, FunctionSelector memory value) public virtual { - set(entity, abi.encode(value)); - } - - function getValue(uint256 entity) public view virtual returns (FunctionSelector memory) { - return abi.decode(getRawValue(entity), (FunctionSelector)); - } -} - -function staticcallFunctionSelector( - FunctionSelector memory functionSelector, - bytes memory args -) view returns (bool, bytes memory) { - return functionSelector.contr.staticcall(bytes.concat(functionSelector.func, args)); -} diff --git a/packages/std-contracts/src/components/FunctionComponent.sol b/packages/std-contracts/src/components/FunctionComponent.sol deleted file mode 100644 index ca1e460632..0000000000 --- a/packages/std-contracts/src/components/FunctionComponent.sol +++ /dev/null @@ -1,42 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; -import "solecs/Component.sol"; - -struct FunctionSelector { - address contr; - bytes4 func; -} - -contract FunctionComponent is Component { - constructor(address world, uint256 id) Component(world, id) {} - - function getSchema() public pure override returns (string[] memory keys, LibTypes.SchemaValue[] memory values) { - keys = new string[](2); - values = new LibTypes.SchemaValue[](2); - - keys[0] = "contr"; - values[0] = LibTypes.SchemaValue.ADDRESS; - - keys[1] = "func"; - values[1] = LibTypes.SchemaValue.BYTES4; - } - - function set(uint256 entity, FunctionSelector memory value) public virtual { - set(entity, abi.encode(value)); - } - - function getValue(uint256 entity) public view virtual returns (FunctionSelector memory) { - return abi.decode(getRawValue(entity), (FunctionSelector)); - } - - function getEntitiesWithValue(FunctionSelector memory value) public view virtual returns (uint256[] memory) { - return getEntitiesWithValue(abi.encode(value)); - } -} - -function staticcallFunctionSelector( - FunctionSelector memory functionSelector, - bytes memory args -) view returns (bool, bytes memory) { - return functionSelector.contr.staticcall(bytes.concat(functionSelector.func, args)); -} diff --git a/packages/std-contracts/src/components/Int32BareComponent.sol b/packages/std-contracts/src/components/Int32BareComponent.sol deleted file mode 100644 index d95b3f8fed..0000000000 --- a/packages/std-contracts/src/components/Int32BareComponent.sol +++ /dev/null @@ -1,24 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; -import "solecs/BareComponent.sol"; - -contract Int32BareComponent is BareComponent { - constructor(address world, uint256 id) BareComponent(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.INT32; - } - - function set(uint256 entity, int32 value) public virtual { - set(entity, abi.encode(value)); - } - - function getValue(uint256 entity) public view virtual returns (int32) { - int32 value = abi.decode(getRawValue(entity), (int32)); - return value; - } -} diff --git a/packages/std-contracts/src/components/Int32Component.sol b/packages/std-contracts/src/components/Int32Component.sol deleted file mode 100644 index a34e7964a0..0000000000 --- a/packages/std-contracts/src/components/Int32Component.sol +++ /dev/null @@ -1,28 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; -import "solecs/Component.sol"; - -contract Int32Component is Component { - 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.INT32; - } - - function set(uint256 entity, int32 value) public virtual { - set(entity, abi.encode(value)); - } - - function getValue(uint256 entity) public view virtual returns (int32) { - int32 value = abi.decode(getRawValue(entity), (int32)); - return value; - } - - function getEntitiesWithValue(int32 value) public view virtual returns (uint256[] memory) { - return getEntitiesWithValue(abi.encode(value)); - } -} diff --git a/packages/std-contracts/src/components/StringArrayBareComponent.sol b/packages/std-contracts/src/components/StringArrayBareComponent.sol deleted file mode 100644 index de36ef5d61..0000000000 --- a/packages/std-contracts/src/components/StringArrayBareComponent.sol +++ /dev/null @@ -1,23 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; -import "solecs/BareComponent.sol"; - -contract StringArrayBareComponent is BareComponent { - constructor(address world, uint256 id) BareComponent(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.STRING_ARRAY; - } - - function set(uint256 entity, string[] memory value) public virtual { - set(entity, abi.encode(value)); - } - - function getValue(uint256 entity) public view virtual returns (string[] memory) { - return abi.decode(getRawValue(entity), (string[])); - } -} diff --git a/packages/std-contracts/src/components/StringArrayComponent.sol b/packages/std-contracts/src/components/StringArrayComponent.sol deleted file mode 100644 index f14c0d0c6a..0000000000 --- a/packages/std-contracts/src/components/StringArrayComponent.sol +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; -import "solecs/Component.sol"; - -contract StringArrayComponent is Component { - 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.STRING_ARRAY; - } - - function set(uint256 entity, string[] memory value) public virtual { - set(entity, abi.encode(value)); - } - - function getValue(uint256 entity) public view virtual returns (string[] memory) { - return abi.decode(getRawValue(entity), (string[])); - } - - function getEntitiesWithValue(string[] memory value) public view virtual returns (uint256[] memory) { - return getEntitiesWithValue(abi.encode(value)); - } -} diff --git a/packages/std-contracts/src/components/StringBareComponent.sol b/packages/std-contracts/src/components/StringBareComponent.sol deleted file mode 100644 index 561c5f8797..0000000000 --- a/packages/std-contracts/src/components/StringBareComponent.sol +++ /dev/null @@ -1,24 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; -import "solecs/BareComponent.sol"; - -contract StringBareComponent is BareComponent { - constructor(address world, uint256 id) BareComponent(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.STRING; - } - - function set(uint256 entity, string memory value) public virtual { - set(entity, abi.encode(value)); - } - - function getValue(uint256 entity) public view virtual returns (string memory) { - string memory value = abi.decode(getRawValue(entity), (string)); - return value; - } -} diff --git a/packages/std-contracts/src/components/StringComponent.sol b/packages/std-contracts/src/components/StringComponent.sol deleted file mode 100644 index c985547431..0000000000 --- a/packages/std-contracts/src/components/StringComponent.sol +++ /dev/null @@ -1,28 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; -import "solecs/Component.sol"; - -contract StringComponent is Component { - 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.STRING; - } - - function set(uint256 entity, string memory value) public virtual { - set(entity, abi.encode(value)); - } - - function getValue(uint256 entity) public view virtual returns (string memory) { - string memory value = abi.decode(getRawValue(entity), (string)); - return value; - } - - function getEntitiesWithValue(string memory value) public view virtual returns (uint256[] memory) { - return getEntitiesWithValue(abi.encode(value)); - } -} diff --git a/packages/std-contracts/src/components/SystemCallbackBareComponent.sol b/packages/std-contracts/src/components/SystemCallbackBareComponent.sol deleted file mode 100644 index d64f84cc44..0000000000 --- a/packages/std-contracts/src/components/SystemCallbackBareComponent.sol +++ /dev/null @@ -1,48 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; - -// imports for the component -import { LibTypes } from "solecs/LibTypes.sol"; -import { BareComponent } from "solecs/BareComponent.sol"; - -// imports for `executeSystemCallback` helper -import { IWorld } from "solecs/interfaces/IWorld.sol"; -import { ISystem } from "solecs/interfaces/ISystem.sol"; -import { getAddressById } from "solecs/utils.sol"; - -struct SystemCallback { - uint256 systemId; - bytes args; -} - -contract SystemCallbackBareComponent is BareComponent { - constructor(address world, uint256 id) BareComponent(world, id) {} - - function getSchema() public pure override returns (string[] memory keys, LibTypes.SchemaValue[] memory values) { - keys = new string[](2); - values = new LibTypes.SchemaValue[](2); - - keys[0] = "systemId"; - values[0] = LibTypes.SchemaValue.UINT256; - - keys[1] = "args"; - values[1] = LibTypes.SchemaValue.BYTES; - } - - function set(uint256 entity, SystemCallback memory value) public virtual { - set(entity, abi.encode(value)); - } - - function getValue(uint256 entity) public view virtual returns (SystemCallback memory) { - return abi.decode(getRawValue(entity), (SystemCallback)); - } -} - -/** - * @dev Queries `world.systems()` for `cb.systemId`, - * then executes the system with `cb.args`. - */ -function executeSystemCallback(IWorld world, SystemCallback memory cb) returns (bytes memory) { - ISystem system = ISystem(getAddressById(world.systems(), cb.systemId)); - return system.execute(cb.args); -} diff --git a/packages/std-contracts/src/components/SystemCallbackComponent.sol b/packages/std-contracts/src/components/SystemCallbackComponent.sol deleted file mode 100644 index 1e6a57c82a..0000000000 --- a/packages/std-contracts/src/components/SystemCallbackComponent.sol +++ /dev/null @@ -1,34 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; - -import { LibTypes } from "solecs/LibTypes.sol"; -import { Component } from "solecs/Component.sol"; - -import { SystemCallback, executeSystemCallback } from "./SystemCallbackBareComponent.sol"; - -contract SystemCallbackComponent is Component { - constructor(address world, uint256 id) Component(world, id) {} - - function getSchema() public pure override returns (string[] memory keys, LibTypes.SchemaValue[] memory values) { - keys = new string[](2); - values = new LibTypes.SchemaValue[](2); - - keys[0] = "systemId"; - values[0] = LibTypes.SchemaValue.UINT256; - - keys[1] = "args"; - values[1] = LibTypes.SchemaValue.BYTES; - } - - function set(uint256 entity, SystemCallback memory value) public virtual { - set(entity, abi.encode(value)); - } - - function getValue(uint256 entity) public view virtual returns (SystemCallback memory) { - return abi.decode(getRawValue(entity), (SystemCallback)); - } - - function getEntitiesWithValue(SystemCallback memory value) public view virtual returns (uint256[] memory) { - return getEntitiesWithValue(abi.encode(value)); - } -} diff --git a/packages/std-contracts/src/components/Uint256ArrayBareComponent.sol b/packages/std-contracts/src/components/Uint256ArrayBareComponent.sol deleted file mode 100644 index 6a579c599b..0000000000 --- a/packages/std-contracts/src/components/Uint256ArrayBareComponent.sol +++ /dev/null @@ -1,23 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; -import "solecs/BareComponent.sol"; - -contract Uint256ArrayBareComponent is BareComponent { - constructor(address world, uint256 id) BareComponent(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_ARRAY; - } - - function set(uint256 entity, uint256[] memory value) public virtual { - set(entity, abi.encode(value)); - } - - function getValue(uint256 entity) public view virtual returns (uint256[] memory) { - return abi.decode(getRawValue(entity), (uint256[])); - } -} diff --git a/packages/std-contracts/src/components/Uint256ArrayComponent.sol b/packages/std-contracts/src/components/Uint256ArrayComponent.sol deleted file mode 100644 index ff9a7538cf..0000000000 --- a/packages/std-contracts/src/components/Uint256ArrayComponent.sol +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; -import "solecs/Component.sol"; - -contract Uint256ArrayComponent is Component { - 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_ARRAY; - } - - function set(uint256 entity, uint256[] memory value) public virtual { - set(entity, abi.encode(value)); - } - - function getValue(uint256 entity) public view virtual returns (uint256[] memory) { - return abi.decode(getRawValue(entity), (uint256[])); - } - - function getEntitiesWithValue(uint256 value) public view virtual returns (uint256[] memory) { - return getEntitiesWithValue(abi.encode(value)); - } -} diff --git a/packages/std-contracts/src/components/Uint256BareComponent.sol b/packages/std-contracts/src/components/Uint256BareComponent.sol deleted file mode 100644 index c8de990fe4..0000000000 --- a/packages/std-contracts/src/components/Uint256BareComponent.sol +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; -import "solecs/BareComponent.sol"; - -/** - * Reference implementation of a component storing a uint256 value for each entity. - */ -contract Uint256BareComponent is BareComponent { - constructor(address world, uint256 id) BareComponent(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; - } -} diff --git a/packages/std-contracts/src/components/Uint256Component.sol b/packages/std-contracts/src/components/Uint256Component.sol deleted file mode 100644 index fc54289420..0000000000 --- a/packages/std-contracts/src/components/Uint256Component.sol +++ /dev/null @@ -1,3 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; -import "solecs/components/Uint256Component.sol"; diff --git a/packages/std-contracts/src/components/Uint32ArrayBareComponent.sol b/packages/std-contracts/src/components/Uint32ArrayBareComponent.sol deleted file mode 100644 index 2ae0834627..0000000000 --- a/packages/std-contracts/src/components/Uint32ArrayBareComponent.sol +++ /dev/null @@ -1,23 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; -import "solecs/BareComponent.sol"; - -contract Uint32ArrayBareComponent is BareComponent { - constructor(address world, uint256 id) BareComponent(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.UINT32_ARRAY; - } - - function set(uint256 entity, uint32[] memory value) public virtual { - set(entity, abi.encode(value)); - } - - function getValue(uint256 entity) public view virtual returns (uint32[] memory) { - return abi.decode(getRawValue(entity), (uint32[])); - } -} diff --git a/packages/std-contracts/src/components/Uint32ArrayComponent.sol b/packages/std-contracts/src/components/Uint32ArrayComponent.sol deleted file mode 100644 index 2e83102cb2..0000000000 --- a/packages/std-contracts/src/components/Uint32ArrayComponent.sol +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; -import "solecs/Component.sol"; - -contract Uint32ArrayComponent is Component { - 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.UINT32_ARRAY; - } - - function set(uint256 entity, uint32[] memory value) public virtual { - set(entity, abi.encode(value)); - } - - function getValue(uint256 entity) public view virtual returns (uint32[] memory) { - return abi.decode(getRawValue(entity), (uint32[])); - } - - function getEntitiesWithValue(uint32[] memory value) public view virtual returns (uint256[] memory) { - return getEntitiesWithValue(abi.encode(value)); - } -} diff --git a/packages/std-contracts/src/components/Uint32BareComponent.sol b/packages/std-contracts/src/components/Uint32BareComponent.sol deleted file mode 100644 index 9be8538e8d..0000000000 --- a/packages/std-contracts/src/components/Uint32BareComponent.sol +++ /dev/null @@ -1,24 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; -import "solecs/BareComponent.sol"; - -contract Uint32BareComponent is BareComponent { - constructor(address world, uint256 id) BareComponent(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.UINT32; - } - - function set(uint256 entity, uint32 value) public virtual { - set(entity, abi.encode(value)); - } - - function getValue(uint256 entity) public view virtual returns (uint32) { - uint32 value = abi.decode(getRawValue(entity), (uint32)); - return value; - } -} diff --git a/packages/std-contracts/src/components/Uint32Component.sol b/packages/std-contracts/src/components/Uint32Component.sol deleted file mode 100644 index 101aef8548..0000000000 --- a/packages/std-contracts/src/components/Uint32Component.sol +++ /dev/null @@ -1,28 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; -import "solecs/Component.sol"; - -contract Uint32Component is Component { - 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.UINT32; - } - - function set(uint256 entity, uint32 value) public virtual { - set(entity, abi.encode(value)); - } - - function getValue(uint256 entity) public view virtual returns (uint32) { - uint32 value = abi.decode(getRawValue(entity), (uint32)); - return value; - } - - function getEntitiesWithValue(uint32 value) public view virtual returns (uint256[] memory) { - return getEntitiesWithValue(abi.encode(value)); - } -} diff --git a/packages/std-contracts/src/components/VoxelCoordBareComponent.sol b/packages/std-contracts/src/components/VoxelCoordBareComponent.sol deleted file mode 100644 index 971db3137e..0000000000 --- a/packages/std-contracts/src/components/VoxelCoordBareComponent.sol +++ /dev/null @@ -1,36 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; -import "solecs/BareComponent.sol"; - -struct VoxelCoord { - int32 x; - int32 y; - int32 z; -} - -contract VoxelCoordComponent is BareComponent { - constructor(address world, uint256 id) BareComponent(world, id) {} - - function getSchema() public pure override returns (string[] memory keys, LibTypes.SchemaValue[] memory values) { - keys = new string[](3); - values = new LibTypes.SchemaValue[](3); - - keys[0] = "x"; - values[0] = LibTypes.SchemaValue.INT32; - - keys[1] = "y"; - values[1] = LibTypes.SchemaValue.INT32; - - keys[2] = "z"; - values[2] = LibTypes.SchemaValue.INT32; - } - - function set(uint256 entity, VoxelCoord calldata value) public virtual { - set(entity, abi.encode(value)); - } - - function getValue(uint256 entity) public view virtual returns (VoxelCoord memory) { - (int32 x, int32 y, int32 z) = abi.decode(getRawValue(entity), (int32, int32, int32)); - return VoxelCoord(x, y, z); - } -} diff --git a/packages/std-contracts/src/components/VoxelCoordComponent.sol b/packages/std-contracts/src/components/VoxelCoordComponent.sol deleted file mode 100644 index 46772a5c7a..0000000000 --- a/packages/std-contracts/src/components/VoxelCoordComponent.sol +++ /dev/null @@ -1,40 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; -import "solecs/Component.sol"; - -struct VoxelCoord { - int32 x; - int32 y; - int32 z; -} - -contract VoxelCoordComponent is Component { - constructor(address world, uint256 id) Component(world, id) {} - - function getSchema() public pure override returns (string[] memory keys, LibTypes.SchemaValue[] memory values) { - keys = new string[](3); - values = new LibTypes.SchemaValue[](3); - - keys[0] = "x"; - values[0] = LibTypes.SchemaValue.INT32; - - keys[1] = "y"; - values[1] = LibTypes.SchemaValue.INT32; - - keys[2] = "z"; - values[2] = LibTypes.SchemaValue.INT32; - } - - function set(uint256 entity, VoxelCoord calldata value) public virtual { - set(entity, abi.encode(value)); - } - - function getValue(uint256 entity) public view virtual returns (VoxelCoord memory) { - (int32 x, int32 y, int32 z) = abi.decode(getRawValue(entity), (int32, int32, int32)); - return VoxelCoord(x, y, z); - } - - function getEntitiesWithValue(VoxelCoord calldata coord) public view virtual returns (uint256[] memory) { - return getEntitiesWithValue(abi.encode(coord)); - } -} diff --git a/packages/std-contracts/src/libraries/LibUtils.sol b/packages/std-contracts/src/libraries/LibUtils.sol deleted file mode 100644 index a5a35bdb01..0000000000 --- a/packages/std-contracts/src/libraries/LibUtils.sol +++ /dev/null @@ -1,130 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; -import { World, WorldQueryFragment } from "solecs/World.sol"; -import { QueryFragment, QueryType, LibQuery } from "solecs/LibQuery.sol"; -import { IUint256Component } from "solecs/interfaces/IUint256Component.sol"; -import { getAddressById } from "solecs/utils.sol"; -import { IComponent } from "solecs/interfaces/IComponent.sol"; -import { CoordComponent, Coord } from "../components/CoordComponent.sol"; - -library LibUtils { - function toHex(bytes memory data) internal pure returns (bytes memory res) { - res = new bytes(data.length * 2); - bytes memory alphabet = "0123456789abcdef"; - for (uint256 i = 0; i < data.length; i++) { - res[i * 2 + 0] = alphabet[uint256(uint8(data[i])) >> 4]; - res[i * 2 + 1] = alphabet[uint256(uint8(data[i])) & 15]; - } - } - - function arrayContains(uint256[] memory arr, uint256 value) internal pure returns (bool) { - for (uint256 i; i < arr.length; i++) { - if (arr[i] == value) { - return true; - } - } - return false; - } - - function safeDelegateCall(address addr, bytes memory callData) internal returns (bytes memory) { - (bool success, bytes memory returnData) = addr.delegatecall(callData); - // if the function call reverted - if (success == false) { - // if there is a return reason string - if (returnData.length > 0) { - // bubble up any reason for revert - assembly { - let returnDataSize := mload(returnData) - revert(add(32, returnData), returnDataSize) - } - } else { - revert("DelegateCall reverted"); - } - } - return returnData; - } - - function distanceBetween( - IUint256Component components, - uint256 e1, - uint256 e2, - uint256 positionComponentId - ) internal view returns (int32) { - CoordComponent positionComponent = CoordComponent(getAddressById(components, positionComponentId)); - - require(positionComponent.has(e1), "no position"); - require(positionComponent.has(e2), "no position"); - - return manhattan(positionComponent.getValue(e1), positionComponent.getValue(e2)); - } - - function manhattan(Coord memory a, Coord memory b) internal pure returns (int32) { - int32 dx = a.x > b.x ? a.x - b.x : b.x - a.x; - int32 dy = a.y > b.y ? a.y - b.y : b.y - a.y; - return dx + dy; - } - - // Using componentComponent - function getEntityAt( - IUint256Component components, - Coord memory position, - uint256 positionComponentId - ) internal view returns (uint256, bool found) { - QueryFragment[] memory fragments = new QueryFragment[](1); - fragments[0] = QueryFragment( - QueryType.HasValue, - IComponent(getAddressById(components, positionComponentId)), - abi.encode(position) - ); - uint256[] memory entities = LibQuery.query(fragments); - if (entities.length == 0) return (0, false); - return (entities[0], true); - } - - // Using world - function getEntityAt( - World world, - Coord memory position, - uint256 positionComponentId - ) internal view returns (uint256, bool found) { - WorldQueryFragment[] memory fragments = new WorldQueryFragment[](1); - fragments[0] = WorldQueryFragment(QueryType.HasValue, positionComponentId, abi.encode(position)); - uint256[] memory entities = world.query(fragments); - if (entities.length == 0) return (0, false); - return (entities[0], true); - } - - // Using componentComponent - function getEntityWithAt( - IUint256Component components, - uint256 componentID, - Coord memory position, - uint256 positionComponentId - ) internal view returns (uint256 entity, bool found) { - QueryFragment[] memory fragments = new QueryFragment[](2); - fragments[0] = QueryFragment( - QueryType.HasValue, - IComponent(getAddressById(components, positionComponentId)), - abi.encode(position) - ); - fragments[1] = QueryFragment(QueryType.Has, IComponent(getAddressById(components, componentID)), new bytes(0)); - uint256[] memory entities = LibQuery.query(fragments); - if (entities.length == 0) return (0, false); - return (entities[0], true); - } - - // Using world - function getEntityWithAt( - World world, - uint256 componentID, - Coord memory position, - uint256 positionComponentId - ) internal view returns (uint256 entity, bool found) { - WorldQueryFragment[] memory fragments = new WorldQueryFragment[](2); - fragments[0] = WorldQueryFragment(QueryType.HasValue, positionComponentId, abi.encode(position)); - fragments[1] = WorldQueryFragment(QueryType.Has, componentID, new bytes(0)); - uint256[] memory entities = world.query(fragments); - if (entities.length == 0) return (0, false); - return (entities[0], true); - } -} diff --git a/packages/std-contracts/src/systems/BulkSetStateSystem.sol b/packages/std-contracts/src/systems/BulkSetStateSystem.sol deleted file mode 100644 index 5b27a6cde2..0000000000 --- a/packages/std-contracts/src/systems/BulkSetStateSystem.sol +++ /dev/null @@ -1,45 +0,0 @@ -// 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, getSystemAddressById } from "solecs/utils.sol"; - -import { ComponentDevSystem, ID as ComponentDevSystemID } from "./ComponentDevSystem.sol"; - -uint256 constant ID = uint256(keccak256("system.BulkSetState")); - -struct ECSEvent { - uint8 component; - uint32 entity; - bytes value; -} - -contract BulkSetStateSystem is System { - constructor(IWorld _world, address _components) System(_world, _components) {} - - function requirement(bytes memory) public view returns (bytes memory) { - // NOTE: Make sure to not include this system in a production deployment, as anyone can change all component values - } - - function execute(bytes memory args) public returns (bytes memory) { - (uint256[] memory componentIds, uint256[] memory entities, ECSEvent[] memory state) = abi.decode( - args, - (uint256[], uint256[], ECSEvent[]) - ); - - for (uint256 i; i < state.length; i++) { - IComponent c = IComponent(getAddressById(components, componentIds[state[i].component])); - c.set(entities[state[i].entity], state[i].value); - } - } - - function executeTyped( - uint256[] memory componentIds, - uint256[] memory entities, - ECSEvent[] memory state - ) external returns (bytes memory) { - return execute(abi.encode(componentIds, entities, state)); - } -} diff --git a/packages/std-contracts/src/systems/ComponentDevSystem.sol b/packages/std-contracts/src/systems/ComponentDevSystem.sol deleted file mode 100644 index 06f8eb776e..0000000000 --- a/packages/std-contracts/src/systems/ComponentDevSystem.sol +++ /dev/null @@ -1,35 +0,0 @@ -// 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"; - -uint256 constant ID = uint256(keccak256("system.ComponentDev")); - -contract ComponentDevSystem is System { - constructor(IWorld _world, address _components) System(_world, _components) {} - - function requirement(bytes memory) public view returns (bytes memory) { - // NOTE: Make sure to not include this system in a production deployment, as anyone can change all component values - } - - function execute(bytes memory args) public returns (bytes memory) { - (uint256 componentId, uint256 entity, bytes memory value) = abi.decode(args, (uint256, uint256, bytes)); - IComponent c = IComponent(getAddressById(components, componentId)); - if (value.length == 0) { - c.remove(entity); - } else { - c.set(entity, value); - } - } - - function executeTyped( - uint256 componentId, - uint256 entity, - bytes memory value // If value has length 0, the component is removed - ) public returns (bytes memory) { - return execute(abi.encode(componentId, entity, value)); - } -} diff --git a/packages/std-contracts/src/systems/UpgradableSystem.sol b/packages/std-contracts/src/systems/UpgradableSystem.sol deleted file mode 100644 index aaaca46341..0000000000 --- a/packages/std-contracts/src/systems/UpgradableSystem.sol +++ /dev/null @@ -1,54 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; -import "solecs/PayableSystem.sol"; -import { IWorld } from "solecs/interfaces/IWorld.sol"; -import { IComponent } from "solecs/interfaces/IComponent.sol"; -import { getAddressById } from "solecs/utils.sol"; -import { AddressBareComponent } from "../components/AddressBareComponent.sol"; - -uint256 constant ID = uint256(keccak256("system.Upgradable")); - -contract UpgradableSystem is PayableSystem { - address implementation; - - constructor(IWorld _world, address _components) PayableSystem(_world, _components) {} - - function execute(bytes memory args) public payable returns (bytes memory) { - _delegate(implementation); - } - - function upgrade(address impl) public onlyOwner { - implementation = impl; - } - - /** - * From https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.7.3/contracts/proxy/Proxy.sol - * @dev Delegates the current call to `implementation`. - * - * This function does not return to its internal call site, it will return directly to the external caller. - */ - function _delegate(address impl) internal { - assembly { - // Copy msg.data. We take full control of memory in this inline assembly - // block because it will not return to Solidity code. We overwrite the - // Solidity scratch pad at memory position 0. - calldatacopy(0, 0, calldatasize()) - - // Call the implementation. - // out and outsize are 0 because we don't know the size yet. - let result := delegatecall(gas(), impl, 0, calldatasize(), 0, 0) - - // Copy the returned data. - returndatacopy(0, 0, returndatasize()) - - switch result - // delegatecall returns 0 on error. - case 0 { - revert(0, returndatasize()) - } - default { - return(0, returndatasize()) - } - } - } -} diff --git a/packages/std-contracts/src/test/MudTest.t.sol b/packages/std-contracts/src/test/MudTest.t.sol deleted file mode 100644 index 782e97b18f..0000000000 --- a/packages/std-contracts/src/test/MudTest.t.sol +++ /dev/null @@ -1,55 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; - -import { DSTest } from "ds-test/test.sol"; -import { IWorld } from "solecs/interfaces/IWorld.sol"; -import { IUint256Component } from "solecs/interfaces/IUint256Component.sol"; -import { Vm } from "forge-std/Vm.sol"; -import { getAddressById } from "solecs/utils.sol"; -import { SystemStorage } from "solecs/SystemStorage.sol"; -import { console } from "forge-std/console.sol"; -import { Utilities } from "./Utilities.sol"; - -interface IDeploy { - function deploy(address deployer) external returns (IWorld world); -} - -contract MudTest is DSTest { - Vm internal immutable vm = Vm(HEVM_ADDRESS); - Utilities internal immutable utils = new Utilities(); - - address payable internal alice; - address payable internal bob; - address payable internal eve; - address internal deployer; - - IWorld internal world; - IUint256Component components; - IUint256Component systems; - - IDeploy internal deploy; - - constructor(IDeploy _deploy) { - deploy = _deploy; - } - - function component(uint256 id) public view returns (address) { - return getAddressById(components, id); - } - - function system(uint256 id) public view returns (address) { - return getAddressById(systems, id); - } - - function setUp() public virtual { - deployer = utils.getNextUserAddress(); - world = deploy.deploy(deployer); - - components = world.components(); - systems = world.systems(); - alice = utils.getNextUserAddress(); - bob = utils.getNextUserAddress(); - eve = utils.getNextUserAddress(); - SystemStorage.init(world, components); - } -} diff --git a/packages/std-contracts/src/test/TestBareComponent.sol b/packages/std-contracts/src/test/TestBareComponent.sol deleted file mode 100644 index 6b250f2736..0000000000 --- a/packages/std-contracts/src/test/TestBareComponent.sol +++ /dev/null @@ -1,46 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; -import { BareComponent } from "solecs/BareComponent.sol"; -import { LibTypes } from "solecs/LibTypes.sol"; - -uint256 constant ID = uint256(keccak256("lib.testComponentBare")); - -struct TestStructBare { - uint256 a; - int32 b; - address c; - string d; -} - -contract TestBareComponent is BareComponent { - constructor(address world) BareComponent(world, ID) {} - - function getSchema() public pure override returns (string[] memory keys, LibTypes.SchemaValue[] memory values) { - keys = new string[](4); - values = new LibTypes.SchemaValue[](4); - - keys[0] = "a"; - values[0] = LibTypes.SchemaValue.UINT256; - - keys[1] = "b"; - values[1] = LibTypes.SchemaValue.INT32; - - keys[2] = "c"; - values[2] = LibTypes.SchemaValue.ADDRESS; - - keys[3] = "d"; - values[3] = LibTypes.SchemaValue.STRING; - } - - function set(uint256 entity, TestStructBare calldata value) public { - set(entity, abi.encode(value)); - } - - function getValue(uint256 entity) public view returns (TestStructBare memory) { - (uint256 a, int32 b, address c, string memory d) = abi.decode( - getRawValue(entity), - (uint32, int32, address, string) - ); - return TestStructBare(a, b, c, d); - } -} diff --git a/packages/std-contracts/src/test/TestComponent.sol b/packages/std-contracts/src/test/TestComponent.sol deleted file mode 100644 index ec93dbd457..0000000000 --- a/packages/std-contracts/src/test/TestComponent.sol +++ /dev/null @@ -1,50 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; -import { Component } from "solecs/Component.sol"; -import { LibTypes } from "solecs/LibTypes.sol"; - -uint256 constant ID = uint256(keccak256("lib.testComponent")); - -struct TestStruct { - uint256 a; - int32 b; - address c; - string d; -} - -contract TestComponent is Component { - constructor(address world) Component(world, ID) {} - - function getSchema() public pure override returns (string[] memory keys, LibTypes.SchemaValue[] memory values) { - keys = new string[](4); - values = new LibTypes.SchemaValue[](4); - - keys[0] = "a"; - values[0] = LibTypes.SchemaValue.UINT256; - - keys[1] = "b"; - values[1] = LibTypes.SchemaValue.INT32; - - keys[2] = "c"; - values[2] = LibTypes.SchemaValue.ADDRESS; - - keys[3] = "d"; - values[3] = LibTypes.SchemaValue.STRING; - } - - function set(uint256 entity, TestStruct calldata value) public { - set(entity, abi.encode(value)); - } - - function getValue(uint256 entity) public view returns (TestStruct memory) { - (uint256 a, int32 b, address c, string memory d) = abi.decode( - getRawValue(entity), - (uint32, int32, address, string) - ); - return TestStruct(a, b, c, d); - } - - function getEntitiesWithValue(TestStruct calldata test) public view returns (uint256[] memory) { - return getEntitiesWithValue(abi.encode(test)); - } -} diff --git a/packages/std-contracts/src/test/TestSystem.sol b/packages/std-contracts/src/test/TestSystem.sol deleted file mode 100644 index f17a4da8c5..0000000000 --- a/packages/std-contracts/src/test/TestSystem.sol +++ /dev/null @@ -1,34 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; - -import { IWorld } from "solecs/interfaces/IWorld.sol"; -import { IComponent } from "solecs/interfaces/IComponent.sol"; -import { System } from "solecs/System.sol"; -import { getAddressById } from "solecs/utils.sol"; - -uint256 constant ID = uint256(keccak256("lib.testSystem")); - -/// @dev Sets values of `entities` to `newValues` for the component with `componentId` -contract TestSystem is System { - constructor(IWorld _world, address _components) System(_world, _components) {} - - function execute(bytes memory args) public returns (bytes memory) { - (uint256 componentId, uint256[] memory entities, bytes[] memory newValues) = abi.decode( - args, - (uint256, uint256[], bytes[]) - ); - - IComponent comp = IComponent(getAddressById(components, componentId)); - - for (uint256 i; i < entities.length; i++) { - uint256 entity = entities[i]; - bytes memory newValue = newValues[i]; - comp.set(entity, newValue); - } - return ""; - } - - function executeTyped(uint256 componentId, uint256[] memory entities, bytes[] memory newValues) public { - execute(abi.encode(componentId, entities, newValues)); - } -} diff --git a/packages/std-contracts/src/test/Utilities.sol b/packages/std-contracts/src/test/Utilities.sol deleted file mode 100644 index 469e01b31f..0000000000 --- a/packages/std-contracts/src/test/Utilities.sol +++ /dev/null @@ -1,35 +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"; - -//common utilities for forge tests -contract Utilities is DSTest { - Vm internal immutable vm = Vm(HEVM_ADDRESS); - bytes32 internal nextUser = keccak256(abi.encodePacked("user address")); - - function getNextUserAddress() external returns (address payable) { - //bytes32 to address conversion - address payable user = payable(address(uint160(uint256(nextUser)))); - nextUser = keccak256(abi.encodePacked(nextUser)); - return user; - } - - //create users with 100 ether balance - function createUsers(uint256 userNum) external returns (address payable[] memory) { - address payable[] memory users = new address payable[](userNum); - for (uint256 i = 0; i < userNum; i++) { - address payable user = this.getNextUserAddress(); - vm.deal(user, 100 ether); - users[i] = user; - } - return users; - } - - //move block.number forward by a given number of blocks - function mineBlocks(uint256 numBlocks) external { - uint256 targetBlock = block.number + numBlocks; - vm.roll(targetBlock); - } -} diff --git a/packages/std-contracts/tasks/compile.ts b/packages/std-contracts/tasks/compile.ts deleted file mode 100644 index 65335021b4..0000000000 --- a/packages/std-contracts/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/std-contracts/test/ComponentGas.t.sol b/packages/std-contracts/test/ComponentGas.t.sol deleted file mode 100644 index bd52295196..0000000000 --- a/packages/std-contracts/test/ComponentGas.t.sol +++ /dev/null @@ -1,177 +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 { World } from "solecs/World.sol"; - -import { BoolComponent } from "../src/components/BoolComponent.sol"; -import { BoolBareComponent } from "../src/components/BoolBareComponent.sol"; -import { Uint256Component } from "../src/components/Uint256Component.sol"; -import { Uint256BareComponent } from "../src/components/Uint256BareComponent.sol"; -import { CoordComponent, Coord } from "../src/components/CoordComponent.sol"; -import { CoordBareComponent, Coord as BareCoord } from "../src/components/CoordBareComponent.sol"; - -import { TestComponent, TestStruct } from "../src/test/TestComponent.sol"; -import { TestBareComponent, TestStructBare } from "../src/test/TestBareComponent.sol"; - -contract ComponentTest is DSTestPlus { - Vm internal immutable vm = Vm(HEVM_ADDRESS); - - address payable[] internal users; - - BoolComponent internal boolComponent; - uint256 constant BoolID = uint256(keccak256("component.Bool")); - - BoolBareComponent internal boolBareComponent; - uint256 constant BoolBareID = uint256(keccak256("component.BoolBare")); - - Uint256Component internal uint256Component; - uint256 constant Uint256ID = uint256(keccak256("component.Uint256")); - - Uint256BareComponent internal uint256BareComponent; - uint256 constant Uint256BareID = uint256(keccak256("component.Uint256Bare")); - - CoordComponent internal coordComponent; - uint256 constant CoordID = uint256(keccak256("component.Coord")); - - CoordBareComponent internal coordBareComponent; - uint256 constant CoordBareID = uint256(keccak256("component.CoordBare")); - - TestComponent internal testComponent; - TestBareComponent internal testBareComponent; - - function setUp() public { - World world = new World(); - world.init(); - boolComponent = new BoolComponent(address(world), BoolID); - boolBareComponent = new BoolBareComponent(address(world), BoolBareID); - uint256Component = new Uint256Component(address(world), Uint256ID); - uint256BareComponent = new Uint256BareComponent(address(world), Uint256BareID); - coordComponent = new CoordComponent(address(world), CoordID); - coordBareComponent = new CoordBareComponent(address(world), CoordBareID); - testComponent = new TestComponent(address(world)); - testBareComponent = new TestBareComponent(address(world)); - } - - function testBaseComponentGas() public { - uint256 entity = 420; - uint256 gas; - - // Set Corod - Coord memory temp = Coord({ x: 1, y: 1 }); - gas = gasleft(); - coordComponent.set(entity, temp); - console.log("Setting a Coord component used %s gas", gas - gasleft()); - // Update - gas = gasleft(); - coordComponent.set(entity, Coord({ x: 2, y: 2 })); - console.log("Updating a Coord component used %s gas", gas - gasleft()); - // Remove - gas = gasleft(); - coordComponent.remove(entity); - console.log("Removing a Coord component used %s gas", gas - gasleft()); - - // Coord Bare - BareCoord memory bareTemp = BareCoord({ x: 3, y: 3 }); - gas = gasleft(); - coordBareComponent.set(entity, bareTemp); - console.log("Setting a Bare Coord component used %s gas", gas - gasleft()); - // Update - gas = gasleft(); - coordBareComponent.set(entity, BareCoord({ x: 2, y: 2 })); - console.log("Updating a Bare Coord component used %s gas", gas - gasleft()); - // Remove - gas = gasleft(); - coordBareComponent.remove(entity); - console.log("Removing a Bare Coord component used %s gas", gas - gasleft()); - - // Set Uint256 - gas = gasleft(); - uint256Component.set(entity, 1); - console.log("Setting a Uint256 component used %s gas", gas - gasleft()); - // Update - gas = gasleft(); - uint256Component.set(entity, 2); - console.log("Updating a Uint256 component used %s gas", gas - gasleft()); - // Remove - gas = gasleft(); - uint256Component.remove(entity); - console.log("Removing a Uint256 component used %s gas", gas - gasleft()); - - // Set Bare Uint256 - gas = gasleft(); - uint256BareComponent.set(entity, 1); - console.log("Setting a Bare Uint256 component used %s gas", gas - gasleft()); - // Update - gas = gasleft(); - uint256BareComponent.set(entity, 2); - console.log("Updating a Bare Uint256 component used %s gas", gas - gasleft()); - // Remove - gas = gasleft(); - uint256BareComponent.remove(entity); - console.log("Removing a Bare Uint256 component used %s gas", gas - gasleft()); - - // Set Bool - gas = gasleft(); - boolComponent.set(entity); - console.log("Setting a Bool component used %s gas", gas - gasleft()); - // Update - gas = gasleft(); - boolComponent.set(entity); - console.log("Updating a Bool component used %s gas", gas - gasleft()); - // Remove - gas = gasleft(); - boolComponent.remove(entity); - console.log("Removing a Bool component used %s gas", gas - gasleft()); - - // Set Bool Bare - gas = gasleft(); - boolBareComponent.set(entity); - console.log("Setting a Bool Bare component used %s gas", gas - gasleft()); - // Update - gas = gasleft(); - boolBareComponent.set(entity); - console.log("Updating a Bool Bare component used %s gas", gas - gasleft()); - // Remove - gas = gasleft(); - boolBareComponent.remove(entity); - console.log("Removing a Bool Bare component used %s gas", gas - gasleft()); - } - - function testStructComponentGas() public { - uint256 entity = 420; - uint256 gas; - - TestStruct memory t = TestStruct({ a: 100, b: -20, c: address(this), d: "hello" }); - TestStruct memory t1 = TestStruct({ a: 101, b: -21, c: address(this), d: "hi" }); - - gas = gasleft(); - testComponent.set(entity, t); - console.log("Setting a Struct component used %s gas", gas - gasleft()); - // Update - gas = gasleft(); - testComponent.set(entity, t1); - console.log("Updating a Struct component used %s gas", gas - gasleft()); - // Remove - gas = gasleft(); - testComponent.remove(entity); - console.log("Removing a Struct component used %s gas", gas - gasleft()); - - // Test Bare - TestStructBare memory tb = TestStructBare({ a: 100, b: -20, c: address(this), d: "hello" }); - TestStructBare memory tb1 = TestStructBare({ a: 101, b: -21, c: address(this), d: "hi" }); - - gas = gasleft(); - testBareComponent.set(entity, tb); - console.log("Setting a Bare Struct component used %s gas", gas - gasleft()); - // Update - gas = gasleft(); - testBareComponent.set(entity, tb1); - console.log("Updating a Bare Struct component used %s gas", gas - gasleft()); - // Remove - gas = gasleft(); - testBareComponent.remove(entity); - console.log("Removing a Bare Struct component used %s gas", gas - gasleft()); - } -} diff --git a/packages/std-contracts/test/SystemCallbackComponent.t.sol b/packages/std-contracts/test/SystemCallbackComponent.t.sol deleted file mode 100644 index 36ee594fad..0000000000 --- a/packages/std-contracts/test/SystemCallbackComponent.t.sol +++ /dev/null @@ -1,144 +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 "solecs/World.sol"; -import { Uint256BareComponent } from "../src/components/Uint256BareComponent.sol"; -import { TestSystem } from "../src/test/TestSystem.sol"; -import { SystemCallbackComponent } from "../src/components/SystemCallbackComponent.sol"; -import { SystemCallbackBareComponent, SystemCallback, executeSystemCallback } from "../src/components/SystemCallbackBareComponent.sol"; - -contract SystemCallbackComponentTest is DSTest { - Vm internal immutable vm = Vm(HEVM_ADDRESS); - - World internal world; - - Uint256BareComponent internal uint256BareComponent; - uint256 Uint256BareID = uint256(keccak256("component.Uint256Bare")); - - SystemCallbackBareComponent internal systemCallbackBareComponent; - SystemCallbackComponent internal systemCallbackComponent; - - TestSystem internal system; - uint256 TestSystemID = uint256(keccak256("system.TestSystem")); - - uint256 internal entity = uint256(keccak256("test entity")); - uint256[] internal entities; - bytes[] internal values; - - function setUp() public { - world = new World(); - world.init(); - address worldAddress = address(world); - - uint256BareComponent = new Uint256BareComponent(worldAddress, Uint256BareID); - systemCallbackBareComponent = new SystemCallbackBareComponent( - worldAddress, - uint256(keccak256("component.SystemCallbackBare")) - ); - systemCallbackComponent = new SystemCallbackComponent(worldAddress, uint256(keccak256("component.SystemCallback"))); - - system = new TestSystem(world, address(world.components())); - world.registerSystem(address(system), TestSystemID); - uint256BareComponent.authorizeWriter(address(system)); - - // initialize sample values for TestSystem, - // which will be called by `executeSystemCallback` to set these values - entities = new uint256[](10); - values = new bytes[](10); - for (uint256 i; i < entities.length; i++) { - entities[i] = i; - values[i] = abi.encode(i + 10); - } - } - - function testGetAndExecuteSystemCallbackBare() public { - SystemCallback memory cb = SystemCallback({ - systemId: TestSystemID, - args: abi.encode(Uint256BareID, entities, values) - }); - systemCallbackBareComponent.set(entity, cb); - - executeSystemCallback(world, systemCallbackBareComponent.getValue(entity)); - - for (uint256 i; i < entities.length; i++) { - assertEq(uint256BareComponent.getValue(i), i + 10); - } - } - - function testGetAndExecuteSystemCallback() public { - SystemCallback memory cb = SystemCallback({ - systemId: TestSystemID, - args: abi.encode(Uint256BareID, entities, values) - }); - systemCallbackComponent.set(entity, cb); - - executeSystemCallback(world, systemCallbackComponent.getValue(entity)); - - for (uint256 i; i < entities.length; i++) { - assertEq(uint256BareComponent.getValue(i), i + 10); - } - } - - function _cbForGas() internal returns (SystemCallback memory) { - // minimize the args so they don't affect gas too much - entities = new uint256[](1); - values = new bytes[](1); - return SystemCallback({ systemId: TestSystemID, args: abi.encode(Uint256BareID, entities, values) }); - } - - function testSystemCallbackGas() public { - uint256 gas; - SystemCallback memory cb = _cbForGas(); - - // Set - gas = gasleft(); - systemCallbackComponent.set(entity, cb); - console.log("Setting a SystemCallback component used %s gas", gas - gasleft()); - // Get - gas = gasleft(); - cb = systemCallbackComponent.getValue(entity); - console.log("Getting a SystemCallback component used %s gas", gas - gasleft()); - // Update - gas = gasleft(); - systemCallbackComponent.set(entity, cb); - console.log("Updating a SystemCallback component used %s gas", gas - gasleft()); - // Remove - gas = gasleft(); - systemCallbackComponent.remove(entity); - console.log("Removing a SystemCallback component used %s gas", gas - gasleft()); - // Call - gas = gasleft(); - executeSystemCallback(world, cb); - console.log("Executing a SystemCallback used %s gas", gas - gasleft()); - } - - function testSystemCallbackBareGas() public { - uint256 gas; - SystemCallback memory cb = _cbForGas(); - - // Set - gas = gasleft(); - systemCallbackBareComponent.set(entity, cb); - console.log("Setting a Bare SystemCallback component used %s gas", gas - gasleft()); - // Get - gas = gasleft(); - cb = systemCallbackBareComponent.getValue(entity); - console.log("Getting a Bare SystemCallback component used %s gas", gas - gasleft()); - // Update - gas = gasleft(); - systemCallbackBareComponent.set(entity, cb); - console.log("Updating a Bare SystemCallback component used %s gas", gas - gasleft()); - // Remove - gas = gasleft(); - systemCallbackBareComponent.remove(entity); - console.log("Removing a Bare SystemCallback component used %s gas", gas - gasleft()); - // Call - gas = gasleft(); - executeSystemCallback(world, cb); - console.log("Executing a SystemCallback used %s gas", gas - gasleft()); - } -} diff --git a/packages/std-contracts/tsconfig.json b/packages/std-contracts/tsconfig.json deleted file mode 100644 index 42f492082e..0000000000 --- a/packages/std-contracts/tsconfig.json +++ /dev/null @@ -1,102 +0,0 @@ -{ - "compilerOptions": { - /* Visit https://aka.ms/tsconfig.json to read more about this file */ - - /* Projects */ - // "incremental": true, /* Enable incremental compilation */ - // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ - // "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */ - // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */ - // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ - // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ - - /* Language and Environment */ - "target": "es2020" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, - // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ - // "jsx": "preserve", /* Specify what JSX code is generated. */ - // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ - // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ - // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */ - // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ - // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */ - // "reactNamespace": "", /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */ - // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ - // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ - - /* Modules */ - // "module": "esnext" /* Specify what module code is generated. */, - // "rootDir": "." /* Specify the root folder within your source files. */, - "moduleResolution": "node" /* Specify how TypeScript looks up a file from a given module specifier. */, - // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ - // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ - // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ - // "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */ - "types": ["mocha"] /* Specify type package names to be included without being referenced in a source file. */, - // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ - // "resolveJsonModule": true, /* Enable importing .json files */ - // "noResolve": true, /* Disallow `import`s, `require`s or ``s from expanding the number of files TypeScript should add to a project. */ - - /* JavaScript Support */ - // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */ - // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ - // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */ - - /* Emit */ - // "declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */, - // "declarationMap": true, /* Create sourcemaps for d.ts files. */ - // "emitDeclarationOnly": true /* Only output d.ts files and not JavaScript files. */, - // "sourceMap": true /* Create source map files for emitted JavaScript files. */, - // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */ - // "outDir": "dist" /* Specify an output folder for all emitted files. */, - // "removeComments": true, /* Disable emitting comments. */ - // "noEmit": true, /* Disable emitting files from a compilation. */ - // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ - // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */ - // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ - // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ - // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ - // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ - // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ - // "newLine": "crlf", /* Set the newline character for emitting files. */ - // "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */ - // "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */ - // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ - // "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */ - // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ - // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ - - /* Interop Constraints */ - // "isolatedModules": true /* Ensure that each file can be safely transpiled without relying on other imports. */, - // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ - "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */ - // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ - // "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */ - - /* Type Checking */ - // "strict": true /* Enable all strict type-checking options. */ - // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */ - // "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */ - // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ - // "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */ - // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ - // "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */ - // "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */ - // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ - // "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */ - // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */ - // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ - // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ - // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ - // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ - // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ - // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */ - // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ - // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ - - /* Completeness */ - // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ - // "skipLibCheck": true /* Skip type checking all .d.ts files. */ - } - // "exclude": ["dist", "**/*.spec.ts", "packages"] -} diff --git a/packages/store/package.json b/packages/store/package.json index 101c4de37e..144896e91e 100644 --- a/packages/store/package.json +++ b/packages/store/package.json @@ -62,7 +62,6 @@ "zod": "^3.21.4" }, "devDependencies": { - "@latticexyz/std-contracts": "workspace:*", "@typechain/ethers-v5": "^10.2.0", "@types/ejs": "^3.1.1", "@types/mocha": "^9.1.1", diff --git a/packages/world/package.json b/packages/world/package.json index 65739270f7..e14eae4482 100644 --- a/packages/world/package.json +++ b/packages/world/package.json @@ -58,7 +58,6 @@ "zod": "^3.21.4" }, "devDependencies": { - "@latticexyz/std-contracts": "workspace:*", "@typechain/ethers-v5": "^10.2.0", "@types/ejs": "^3.1.1", "@types/glob": "^7.2.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fa5ba642d0..9101557aef 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -123,9 +123,6 @@ importers: '@latticexyz/solecs': specifier: workspace:* version: link:../solecs - '@latticexyz/std-contracts': - specifier: workspace:* - version: link:../std-contracts '@latticexyz/store': specifier: workspace:* version: link:../store @@ -792,38 +789,7 @@ importers: specifier: 0.31.4 version: 0.31.4(jsdom@22.1.0) - packages/std-contracts: - devDependencies: - '@latticexyz/solecs': - specifier: workspace:* - version: link:../solecs - '@solidstate/contracts': - specifier: ^0.0.52 - version: 0.0.52 - '@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) - ds-test: - specifier: https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0 - version: github.com/dapphub/ds-test/e282159d5170298eb2455a6c05280ab5a73a4ef0 - 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) - memmove: - specifier: https://github.com/dk1a/memmove.git#ffd71cd77b1708574ef46a667b23ca3a5cc9fa27 - version: github.com/dk1a/memmove/ffd71cd77b1708574ef46a667b23ca3a5cc9fa27 - solhint: - specifier: ^3.3.7 - version: 3.3.7 - solmate: - specifier: https://github.com/transmissions11/solmate.git#9cf1428245074e39090dceacb0c28b1f684f584c - version: github.com/transmissions11/solmate/9cf1428245074e39090dceacb0c28b1f684f584c - typechain: - specifier: ^8.1.1 - version: 8.1.1(typescript@5.1.6) + packages/std-contracts: {} packages/store: dependencies: @@ -855,9 +821,6 @@ importers: specifier: ^3.21.4 version: 3.21.4 devDependencies: - '@latticexyz/std-contracts': - specifier: workspace:* - version: link:../std-contracts '@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) @@ -1130,9 +1093,6 @@ importers: specifier: ^3.21.4 version: 3.21.4 devDependencies: - '@latticexyz/std-contracts': - specifier: workspace:* - version: link:../std-contracts '@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) @@ -3193,6 +3153,7 @@ packages: /@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==} @@ -11722,6 +11683,7 @@ packages: 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} @@ -11755,3 +11717,4 @@ packages: resolution: {tarball: https://codeload.github.com/transmissions11/solmate/tar.gz/9cf1428245074e39090dceacb0c28b1f684f584c} name: solmate version: 6.5.0 + dev: false