diff --git a/.changeset/beige-radios-drop.md b/.changeset/beige-radios-drop.md new file mode 100644 index 0000000000..c821afbfe4 --- /dev/null +++ b/.changeset/beige-radios-drop.md @@ -0,0 +1,14 @@ +--- +"@latticexyz/world": minor +--- + +It is now possible to upgrade systems by calling `registerSystem` again with an existing system id (resource selector). + +```solidity +// Register a system +world.registerSystem(systemId, systemAddress, publicAccess); + +// Upgrade the system by calling `registerSystem` with the +// same system id but a new system address or publicAccess flag +world.registerSystem(systemId, newSystemAddress, newPublicAccess); +``` diff --git a/.changeset/funny-paws-admire.md b/.changeset/funny-paws-admire.md new file mode 100644 index 0000000000..6cba8148f8 --- /dev/null +++ b/.changeset/funny-paws-admire.md @@ -0,0 +1,5 @@ +--- +"@latticexyz/services": patch +--- + +The build phase of services now works on machines with older protobuf compilers diff --git a/.changeset/pre.json b/.changeset/pre.json index 8ae0fd44a2..bff5dcdc88 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -32,11 +32,13 @@ }, "changesets": [ "afraid-hotels-bathe", + "beige-radios-drop", "big-goats-prove", "brave-needles-love", "brave-rings-tickle", "brown-icons-burn", "chilled-chicken-repair", + "clever-rats-sip", "cool-snakes-reply", "dirty-items-retire", "eighty-tigers-argue", @@ -48,6 +50,7 @@ "flat-trainers-marry", "fluffy-moles-march", "four-coats-pull", + "funny-paws-admire", "giant-masks-carry", "great-cooks-dream", "grumpy-geckos-raise", @@ -67,6 +70,7 @@ "modern-bikes-build", "modern-hornets-jam", "nasty-waves-divide", + "nervous-walls-knock", "nice-moose-love", "nice-pandas-knock", "olive-parrots-move", @@ -75,7 +79,9 @@ "pink-horses-deny", "pretty-hotels-drop", "quick-numbers-flash", + "quiet-squids-share", "rare-planes-draw", + "rare-trainers-fry", "red-turkeys-develop", "selfish-cycles-retire", "seven-flies-chew", @@ -100,6 +106,7 @@ "twenty-birds-scream", "weak-mails-cross", "wild-gorillas-care", - "witty-jokes-serve" + "witty-jokes-serve", + "witty-tigers-rest" ] } diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..b3d04a3155 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,13 @@ +node_modules +**/node_modules +.gitignore +*.md +dist +**/dist +**/out/ +**/cache/ +**/bindings/ +**/artifacts/ +**/abi/ +**/broadcast/ +**/deploys/ \ No newline at end of file diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 2d536f614b..3c9302afbc 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -52,4 +52,4 @@ jobs: env: DATABASE_URL: "postgres://postgres@localhost:5432/postgres" working-directory: ./e2e/packages/sync-test - run: pnpm test + run: pnpm test:ci diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8ec86755a4..f36c3200eb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,7 +30,7 @@ jobs: - name: Run tests env: DATABASE_URL: "postgres://postgres@localhost:5432/postgres" - run: pnpm test + run: pnpm test:ci - name: Generate gas reports run: pnpm gas-report diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ef0bb5390..bfc8829368 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,222 @@ +# Version 2.0.0-next.5 + +## Major changes + +**[refactor(world): separate call utils into `WorldContextProvider` and `SystemCall` (#1370)](https://github.com/latticexyz/mud/commit/9d0f492a90e5d94c6b38ad732e78fd4b13b2adbe)** (@latticexyz/world) + +- The previous `Call.withSender` util is replaced with `WorldContextProvider`, since the usecase of appending the `msg.sender` to the calldata is tightly coupled with `WorldContextConsumer` (which extracts the appended context from the calldata). + + The previous `Call.withSender` utility reverted if the call failed and only returned the returndata on success. This is replaced with `callWithContextOrRevert`/`delegatecallWithContextOrRevert` + + ```diff + -import { Call } from "@latticexyz/world/src/Call.sol"; + +import { WorldContextProvider } from "@latticexyz/world/src/WorldContext.sol"; + + -Call.withSender({ + - delegate: false, + - value: 0, + - ... + -}); + +WorldContextProvider.callWithContextOrRevert({ + + value: 0, + + ... + +}); + + -Call.withSender({ + - delegate: true, + - value: 0, + - ... + -}); + +WorldContextProvider.delegatecallWithContextOrRevert({ + + ... + +}); + ``` + + In addition there are utils that return a `bool success` flag instead of reverting on errors. This mirrors the behavior of Solidity's low level `call`/`delegatecall` functions and is useful in situations where additional logic should be executed in case of a reverting external call. + + ```solidity + library WorldContextProvider { + function callWithContext( + address target, // Address to call + bytes memory funcSelectorAndArgs, // Abi encoded function selector and arguments to pass to pass to the contract + address msgSender, // Address to append to the calldata as context for msgSender + uint256 value // Value to pass with the call + ) internal returns (bool success, bytes memory data); + + function delegatecallWithContext( + address target, // Address to call + bytes memory funcSelectorAndArgs, // Abi encoded function selector and arguments to pass to pass to the contract + address msgSender // Address to append to the calldata as context for msgSender + ) internal returns (bool success, bytes memory data); + } + ``` + +- `WorldContext` is renamed to `WorldContextConsumer` to clarify the relationship between `WorldContextProvider` (appending context to the calldata) and `WorldContextConsumer` (extracting context from the calldata) + + ```diff + -import { WorldContext } from "@latticexyz/world/src/WorldContext.sol"; + -import { WorldContextConsumer } from "@latticexyz/world/src/WorldContext.sol"; + ``` + +- The `World` contract previously had a `_call` method to handle calling systems via their resource selector, performing accesss control checks and call hooks registered for the system. + + ```solidity + library SystemCall { + /** + * Calls a system via its resource selector and perform access control checks. + * Does not revert if the call fails, but returns a `success` flag along with the returndata. + */ + function call( + address caller, + bytes32 resourceSelector, + bytes memory funcSelectorAndArgs, + uint256 value + ) internal returns (bool success, bytes memory data); + + /** + * Calls a system via its resource selector, perform access control checks and trigger hooks registered for the system. + * Does not revert if the call fails, but returns a `success` flag along with the returndata. + */ + function callWithHooks( + address caller, + bytes32 resourceSelector, + bytes memory funcSelectorAndArgs, + uint256 value + ) internal returns (bool success, bytes memory data); + + /** + * Calls a system via its resource selector, perform access control checks and trigger hooks registered for the system. + * Reverts if the call fails. + */ + function callWithHooksOrRevert( + address caller, + bytes32 resourceSelector, + bytes memory funcSelectorAndArgs, + uint256 value + ) internal returns (bytes memory data); + } + ``` + +- System hooks now are called with the system's resource selector instead of its address. The system's address can still easily obtained within the hook via `Systems.get(resourceSelector)` if necessary. + + ```diff + interface ISystemHook { + function onBeforeCallSystem( + address msgSender, + - address systemAddress, + + bytes32 resourceSelector, + bytes memory funcSelectorAndArgs + ) external; + + function onAfterCallSystem( + address msgSender, + - address systemAddress, + + bytes32 resourceSelector, + bytes memory funcSelectorAndArgs + ) external; + } + ``` + +## Minor changes + +**[feat(world): add support for upgrading systems (#1378)](https://github.com/latticexyz/mud/commit/ce97426c0d70832e5efdb8bad83207a9d840302b)** (@latticexyz/world) + +It is now possible to upgrade systems by calling `registerSystem` again with an existing system id (resource selector). + +```solidity +// Register a system +world.registerSystem(systemId, systemAddress, publicAccess); + +// Upgrade the system by calling `registerSystem` with the +// same system id but a new system address or publicAccess flag +world.registerSystem(systemId, newSystemAddress, newPublicAccess); +``` + +**[feat(world): add callFrom entry point (#1364)](https://github.com/latticexyz/mud/commit/1ca35e9a1630a51dfd1e082c26399f76f2cd06ed)** (@latticexyz/world) + +The `World` has a new `callFrom` entry point which allows systems to be called on behalf of other addresses if those addresses have registered a delegation. +If there is a delegation, the call is forwarded to the system with `delegator` as `msgSender`. + +```solidity +interface IBaseWorld { + function callFrom( + address delegator, + bytes32 resourceSelector, + bytes memory funcSelectorAndArgs + ) external payable virtual returns (bytes memory); +} +``` + +A delegation can be registered via the `World`'s `registerDelegation` function. +If `delegatee` is `address(0)`, the delegation is considered to be a "fallback" delegation and is used in `callFrom` if there is no delegation is found for the specific caller. +Otherwise the delegation is registered for the specific `delegatee`. + +```solidity +interface IBaseWorld { + function registerDelegation( + address delegatee, + bytes32 delegationControl, + bytes memory initFuncSelectorAndArgs + ) external; +} +``` + +The `delegationControl` refers to the resource selector of a `DelegationControl` system that must have been registered beforehand. +As part of registering the delegation, the `DelegationControl` system is called with the provided `initFuncSelectorAndArgs`. +This can be used to initialize data in the given `DelegationControl` system. + +The `DelegationControl` system must implement the `IDelegationControl` interface: + +```solidity +interface IDelegationControl { + function verify(address delegator, bytes32 systemId, bytes calldata funcSelectorAndArgs) external returns (bool); +} +``` + +When `callFrom` is called, the `World` checks if a delegation is registered for the given caller, and if so calls the delegation control's `verify` function with the same same arguments as `callFrom`. +If the call to `verify` is successful and returns `true`, the delegation is valid and the call is forwarded to the system with `delegator` as `msgSender`. + +Note: if `UNLIMITED_DELEGATION` (from `@latticexyz/world/src/constants.sol`) is passed as `delegationControl`, the external call to the delegation control contract is skipped and the delegation is considered valid. + +For examples of `DelegationControl` systems, check out the `CallboundDelegationControl` or `TimeboundDelegationControl` systems in the `std-delegations` module. +See `StandardDelegations.t.sol` for usage examples. + +**[feat(world): allow transferring ownership of namespaces (#1274)](https://github.com/latticexyz/mud/commit/c583f3cd08767575ce9df39725ec51195b5feb5b)** (@latticexyz/world) + +It is now possible to transfer ownership of namespaces! + +```solidity +// Register a new namespace +world.registerNamespace("namespace"); +// It's owned by the caller of the function (address(this)) + +// Transfer ownership of the namespace to address(42) +world.transferOwnership("namespace", address(42)); +// It's now owned by address(42) +``` + +## Patch changes + +**[fix(services): correctly export typescript types (#1377)](https://github.com/latticexyz/mud/commit/33f50f8a473398dcc19b17d10a17a552a82678c7)** (@latticexyz/services) + +Fixed an issue where the TypeScript types for createFaucetService were not exported correctly from the @latticexyz/services package + +**[feat: docker monorepo build (#1219)](https://github.com/latticexyz/mud/commit/80a26419f15177333b523bac5d09767487b4ffef)** (@latticexyz/services) + +The build phase of services now works on machines with older protobuf compilers + +**[refactor: remove v1 network package, remove snap sync module, deprecate std-client (#1311)](https://github.com/latticexyz/mud/commit/331f0d636f6f327824307570a63fb301d9b897d1)** (@latticexyz/common, @latticexyz/store, @latticexyz/world) + +- Refactor tightcoder to use typescript functions instead of ejs +- Optimize `TightCoder` library +- Add `isLeftAligned` and `getLeftPaddingBits` common codegen helpers + +**[fix(cli): make mud test exit with code 1 on test error (#1371)](https://github.com/latticexyz/mud/commit/dc258e6860196ad34bf1d4ac7fce382f70e2c0c8)** (@latticexyz/cli) + +The `mud test` cli now exits with code 1 on test failure. It used to exit with code 0, which meant that CIs didn't notice test failures. + +--- + # Version 2.0.0-next.4 ## Major changes diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..6acdf3cd85 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,40 @@ +FROM docker.io/library/debian:bullseye-slim as base +ENV SHELL /bin/bash + +WORKDIR /opt +RUN apt-get -y update --fix-missing && \ + apt-get -y upgrade && \ + apt-get install -y --no-install-recommends \ + libssl-dev make cmake graphviz \ + git pkg-config curl time rhash ca-certificates jq \ + python3 python3-pip lsof ruby ruby-bundler git-restore-mtime xz-utils zstd unzip gnupg protobuf-compiler \ + wget net-tools iptables iproute2 iputils-ping ed zlib1g-dev wabt && \ + curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \ + apt-get install -y nodejs + +# foundry +RUN curl -L https://foundry.paradigm.xyz/ | bash && \ + ${HOME}/.foundry/bin/foundryup \ + && forge --version \ + && cast --version \ + && anvil --version \ + && chisel --version +# go +RUN wget https://dl.google.com/go/go1.20.4.linux-amd64.tar.gz && \ + # -C to move to given directory + tar -C /usr/local/ -xzf go1.20.4.linux-amd64.tar.gz +# pnpm +RUN npm install pnpm --global && pnpm --version + +FROM base AS builder +COPY . /app +WORKDIR /app + +ENV PATH="${PATH}:/usr/local/go/bin" +ENV PATH="${PATH}:/root/.foundry/bin" +RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile +RUN pnpm run -r build + +FROM builder AS store-indexer +WORKDIR /app/packages/store-indexer +EXPOSE 3001 \ No newline at end of file diff --git a/docs/pages/store/advanced-features.mdx b/docs/pages/store/advanced-features.mdx index 8b060f22fd..1ad66d5ed0 100644 --- a/docs/pages/store/advanced-features.mdx +++ b/docs/pages/store/advanced-features.mdx @@ -90,17 +90,17 @@ contract MirrorSubscriber is IStoreHook { } function onSetRecord(uint256 table, bytes32[] memory key, bytes memory data) public { - if (table != table) revert("invalid table"); + if (_table != table) revert("invalid table"); StoreSwitch.setRecord(indexerTableId, key, data); } function onSetField(uint256 table, bytes32[] memory key, uint8 schemaIndex, bytes memory data) public { - if (table != table) revert("invalid table"); + if (_table != table) revert("invalid table"); StoreSwitch.setField(indexerTableId, key, schemaIndex, data); } function onDeleteRecord(uint256 table, bytes32[] memory key) public { - if (table != table) revert("invalid table"); + if (_table != table) revert("invalid table"); StoreSwitch.deleteRecord(indexerTableId, key); } } diff --git a/docs/pages/tutorials.mdx b/docs/pages/tutorials.mdx index caf20dc60c..a04f9cdfde 100644 --- a/docs/pages/tutorials.mdx +++ b/docs/pages/tutorials.mdx @@ -2,9 +2,9 @@ These tutorials teach you how to do various things with MUD. -## Modifying the getting started example +## Modifying the template -[These tutorials](tutorials/minimal) teach you how to make various changes to [the getting started example](https://github.com/latticexyz/mud/tree/main/examples/minimal). +[These tutorials](tutorials/minimal) teach you how to make various changes to [the application template](https://github.com/latticexyz/mud/tree/main/examples/minimal). This is an easy way to learn how to modify MUD functionality in various ways. - [Add a table](tutorials/minimal/add-table): @@ -16,7 +16,7 @@ This is an easy way to learn how to modify MUD functionality in various ways. [These tutorials](tutorials/walkthrough) are deep dives into various sections of code. -- [The onchain components of getting started](tutorials/walkthrough/onchain): +- [The onchain components of the template](tutorials/walkthrough/onchain): In this walkthrough you learn how to understand the onchain components of the minimal template. - [The MUD client libraries](walkthrough/client-lib): In this walkthrough you learn the MUD client libraries, which are shared between all the different versions of the minimal template. diff --git a/docs/pages/tutorials/minimal.mdx b/docs/pages/tutorials/minimal.mdx index 7ade7dd777..129e269066 100644 --- a/docs/pages/tutorials/minimal.mdx +++ b/docs/pages/tutorials/minimal.mdx @@ -1,11 +1,11 @@ -# Modifying the getting started example +# Modifying the template -These tutorials teach you how to make various changes to [the getting started example](https://github.com/latticexyz/mud/tree/main/examples/minimal). +These tutorials teach you how to make various changes to [the vanilla template](https://github.com/latticexyz/mud/tree/main/templates/vanilla). This is an easy way to learn how to modify MUD functionality in various ways. ## Getting the initial version -All of these examples are based on the vanilla version of getting started. +All of these examples are based on the vanilla version of the template. To create the basic version to modify, follow these steps: 1. Create a version 2.0 MUD starter. @@ -16,7 +16,7 @@ To create the basic version to modify, follow these steps: 1. Select the **vanilla** template. -1. Change to the tutorial directory and start the getting started application. +1. Change to the tutorial directory and start the application. ```bash copy cd tutorial diff --git a/docs/pages/tutorials/walkthrough/_meta.js b/docs/pages/tutorials/walkthrough/_meta.js index 8648a1a309..496b0cacd1 100644 --- a/docs/pages/tutorials/walkthrough/_meta.js +++ b/docs/pages/tutorials/walkthrough/_meta.js @@ -1,4 +1,4 @@ export default { - "minimal-onchain": "Onchain components of getting started", + "minimal-onchain": "The onchain components of the template", "client-lib": "The MUD client libraries" }; diff --git a/docs/pages/tutorials/walkthrough/minimal-onchain.mdx b/docs/pages/tutorials/walkthrough/minimal-onchain.mdx index 347f38dfec..2cdb489d95 100644 --- a/docs/pages/tutorials/walkthrough/minimal-onchain.mdx +++ b/docs/pages/tutorials/walkthrough/minimal-onchain.mdx @@ -1,6 +1,6 @@ -# The onchain components of getting started +# The onchain components of the template -You [installed the getting started code](/quick-start), and now you can increment the counter with the best of them. +You [installed the template code](/quick-start), and now you can increment the counter with the best of them. Unfortunately, when you tried to figure out what is happening, it is as clear as mud. Have no fear, in this tutorial you learn how to understand the onchain components of the minimal template. diff --git a/e2e/package.json b/e2e/package.json index 74638aafb8..446c64733d 100644 --- a/e2e/package.json +++ b/e2e/package.json @@ -5,7 +5,8 @@ "build": "pnpm recursive run build", "clean": "pnpm recursive run clean", "playwright-install": "pnpx playwright@1.35.1 install --with-deps chromium", - "test": "pnpm recursive run test" + "test": "pnpm recursive run test", + "test:ci": "pnpm run test" }, "devDependencies": { "@playwright/test": "1.35.1" diff --git a/e2e/packages/contracts/package.json b/e2e/packages/contracts/package.json index 02124532eb..8a9d8c57b3 100644 --- a/e2e/packages/contracts/package.json +++ b/e2e/packages/contracts/package.json @@ -13,7 +13,8 @@ "clean:mud": "rimraf src/codegen", "clean:typechain": "rimraf types", "deploy:local": "mud deploy", - "test": "mud test" + "test": "mud test", + "test:ci": "pnpm run test" }, "devDependencies": { "@latticexyz/cli": "link:../../../packages/cli", diff --git a/e2e/packages/sync-test/package.json b/e2e/packages/sync-test/package.json index 25ce8b27c9..edbba42692 100644 --- a/e2e/packages/sync-test/package.json +++ b/e2e/packages/sync-test/package.json @@ -4,7 +4,8 @@ "private": true, "license": "MIT", "scripts": { - "test": "vitest --run" + "test": "vitest --run", + "test:ci": "pnpm run test" }, "devDependencies": { "@latticexyz/cli": "link:../../../packages/cli", diff --git a/package.json b/package.json index 2d4ea61b02..37438a75a3 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,8 @@ "release:publish": "pnpm install && pnpm build && changeset publish", "release:version": "changeset version && pnpm install --lockfile-only && pnpx bun@0.7.3 scripts/changelog.ts", "sort-package-json": "npx sort-package-json package.json 'packages/*/package.json' 'templates/*/package.json' 'templates/*/packages/*/package.json' 'examples/*/package.json' 'examples/*/packages/*/package.json' 'e2e/*/package.json' 'e2e/*/packages/*/package.json' 'docs/package.json'", - "test": "pnpm recursive run test" + "test": "pnpm recursive run test", + "test:ci": "pnpm recursive run test:ci" }, "lint-staged": { "*.{ts,tsx}": "eslint --cache --fix", diff --git a/packages/block-logs-stream/CHANGELOG.md b/packages/block-logs-stream/CHANGELOG.md index 2d9f81718f..9fe178d923 100644 --- a/packages/block-logs-stream/CHANGELOG.md +++ b/packages/block-logs-stream/CHANGELOG.md @@ -1,5 +1,14 @@ # @latticexyz/block-logs-stream +## 2.0.0-next.5 + +### Patch Changes + +- Updated dependencies []: + - @latticexyz/common@2.0.0-next.5 + - @latticexyz/config@2.0.0-next.5 + - @latticexyz/schema-type@2.0.0-next.5 + ## 2.0.0-next.4 ### Patch Changes diff --git a/packages/block-logs-stream/package.json b/packages/block-logs-stream/package.json index 8e26dd60bf..71fcf0ccc6 100644 --- a/packages/block-logs-stream/package.json +++ b/packages/block-logs-stream/package.json @@ -1,6 +1,6 @@ { "name": "@latticexyz/block-logs-stream", - "version": "2.0.0-next.4", + "version": "2.0.0-next.5", "description": "Create a stream of EVM block logs for events", "repository": { "type": "git", @@ -20,7 +20,8 @@ "clean:js": "rimraf dist", "dev": "tsup --watch", "lint": "eslint .", - "test": "vitest typecheck --run --passWithNoTests && vitest --run --passWithNoTests" + "test": "vitest typecheck --run --passWithNoTests && vitest --run --passWithNoTests", + "test:ci": "pnpm run test" }, "dependencies": { "@latticexyz/common": "workspace:*", diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index 28be05063e..63bfe4be38 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -1,5 +1,22 @@ # Change Log +## 2.0.0-next.5 + +### Patch Changes + +- [#1371](https://github.com/latticexyz/mud/pull/1371) [`dc258e68`](https://github.com/latticexyz/mud/commit/dc258e6860196ad34bf1d4ac7fce382f70e2c0c8) Thanks [@alvrs](https://github.com/alvrs)! - The `mud test` cli now exits with code 1 on test failure. It used to exit with code 0, which meant that CIs didn't notice test failures. + +- Updated dependencies [[`ce97426c`](https://github.com/latticexyz/mud/commit/ce97426c0d70832e5efdb8bad83207a9d840302b), [`33f50f8a`](https://github.com/latticexyz/mud/commit/33f50f8a473398dcc19b17d10a17a552a82678c7), [`80a26419`](https://github.com/latticexyz/mud/commit/80a26419f15177333b523bac5d09767487b4ffef), [`1ca35e9a`](https://github.com/latticexyz/mud/commit/1ca35e9a1630a51dfd1e082c26399f76f2cd06ed), [`9d0f492a`](https://github.com/latticexyz/mud/commit/9d0f492a90e5d94c6b38ad732e78fd4b13b2adbe), [`c583f3cd`](https://github.com/latticexyz/mud/commit/c583f3cd08767575ce9df39725ec51195b5feb5b)]: + - @latticexyz/world@2.0.0-next.5 + - @latticexyz/services@2.0.0-next.5 + - @latticexyz/common@2.0.0-next.5 + - @latticexyz/config@2.0.0-next.5 + - @latticexyz/gas-report@2.0.0-next.5 + - @latticexyz/protocol-parser@2.0.0-next.5 + - @latticexyz/schema-type@2.0.0-next.5 + - @latticexyz/store@2.0.0-next.5 + - @latticexyz/utils@2.0.0-next.5 + ## 2.0.0-next.4 ### Patch Changes diff --git a/packages/cli/package.json b/packages/cli/package.json index 139781bf92..317fef0ce4 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@latticexyz/cli", - "version": "2.0.0-next.4", + "version": "2.0.0-next.5", "description": "Command line interface for mud", "repository": { "type": "git", @@ -24,7 +24,8 @@ "clean:js": "rimraf dist", "dev": "tsup --watch", "lint": "eslint . --ext .ts", - "test": "tsc --noEmit && forge test" + "test": "tsc --noEmit && forge test", + "test:ci": "pnpm run test" }, "dependencies": { "@ethersproject/abi": "^5.7.0", diff --git a/packages/common/CHANGELOG.md b/packages/common/CHANGELOG.md index ff77611209..c3b551122f 100644 --- a/packages/common/CHANGELOG.md +++ b/packages/common/CHANGELOG.md @@ -1,5 +1,12 @@ # Change Log +## 2.0.0-next.5 + +### Patch Changes + +- Updated dependencies []: + - @latticexyz/schema-type@2.0.0-next.5 + ## 2.0.0-next.4 ### Patch Changes diff --git a/packages/common/package.json b/packages/common/package.json index 61bd230277..e55e37a87b 100644 --- a/packages/common/package.json +++ b/packages/common/package.json @@ -1,6 +1,6 @@ { "name": "@latticexyz/common", - "version": "2.0.0-next.4", + "version": "2.0.0-next.5", "description": "Common low level logic shared between packages", "repository": { "type": "git", @@ -53,7 +53,8 @@ "clean": "pnpm run clean:js", "clean:js": "rimraf dist", "dev": "tsup --watch", - "test": "vitest typecheck --run --passWithNoTests && vitest --run" + "test": "vitest typecheck --run --passWithNoTests && vitest --run", + "test:ci": "pnpm run test" }, "dependencies": { "@latticexyz/schema-type": "workspace:*", diff --git a/packages/config/CHANGELOG.md b/packages/config/CHANGELOG.md index e71a6ecf06..641441c06e 100644 --- a/packages/config/CHANGELOG.md +++ b/packages/config/CHANGELOG.md @@ -1,5 +1,13 @@ # Change Log +## 2.0.0-next.5 + +### Patch Changes + +- Updated dependencies []: + - @latticexyz/common@2.0.0-next.5 + - @latticexyz/schema-type@2.0.0-next.5 + ## 2.0.0-next.4 ### Patch Changes diff --git a/packages/config/package.json b/packages/config/package.json index ecdea79f1e..5df67c2027 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -1,6 +1,6 @@ { "name": "@latticexyz/config", - "version": "2.0.0-next.4", + "version": "2.0.0-next.5", "description": "Config for Store and World", "repository": { "type": "git", @@ -33,7 +33,8 @@ "clean": "pnpm run clean:js", "clean:js": "rimraf dist", "dev": "tsup --watch", - "test": "tsc --noEmit" + "test": "tsc --noEmit", + "test:ci": "pnpm run test" }, "dependencies": { "@latticexyz/common": "workspace:*", diff --git a/packages/create-mud/CHANGELOG.md b/packages/create-mud/CHANGELOG.md index 60ee5952da..7fc69586fd 100644 --- a/packages/create-mud/CHANGELOG.md +++ b/packages/create-mud/CHANGELOG.md @@ -1,5 +1,7 @@ # Change Log +## 2.0.0-next.5 + ## 2.0.0-next.4 ## 2.0.0-next.3 diff --git a/packages/create-mud/package.json b/packages/create-mud/package.json index bbdfd059a8..02d7476bc4 100644 --- a/packages/create-mud/package.json +++ b/packages/create-mud/package.json @@ -1,6 +1,6 @@ { "name": "create-mud", - "version": "2.0.0-next.4", + "version": "2.0.0-next.5", "description": "Create a new MUD project", "license": "MIT", "author": "Lattice ", @@ -16,6 +16,7 @@ "dev": "tsup --watch", "prepublishOnly": "npm run clean && npm run build", "test": "pnpm run test:vanilla && pnpm run test:react && pnpm run test:phaser && pnpm run test:threejs", + "test:ci": "pnpm run test", "test:phaser": "dist/cli.js test-project --template phaser && rimraf test-project", "test:react": "dist/cli.js test-project --template react && rimraf test-project", "test:threejs": "dist/cli.js test-project --template threejs && rimraf test-project", diff --git a/packages/dev-tools/CHANGELOG.md b/packages/dev-tools/CHANGELOG.md index 9f0d648ce5..565c60eb77 100644 --- a/packages/dev-tools/CHANGELOG.md +++ b/packages/dev-tools/CHANGELOG.md @@ -1,5 +1,18 @@ # @latticexyz/dev-tools +## 2.0.0-next.5 + +### Patch Changes + +- Updated dependencies [[`ce97426c`](https://github.com/latticexyz/mud/commit/ce97426c0d70832e5efdb8bad83207a9d840302b), [`1ca35e9a`](https://github.com/latticexyz/mud/commit/1ca35e9a1630a51dfd1e082c26399f76f2cd06ed), [`9d0f492a`](https://github.com/latticexyz/mud/commit/9d0f492a90e5d94c6b38ad732e78fd4b13b2adbe), [`c583f3cd`](https://github.com/latticexyz/mud/commit/c583f3cd08767575ce9df39725ec51195b5feb5b)]: + - @latticexyz/world@2.0.0-next.5 + - @latticexyz/store-sync@2.0.0-next.5 + - @latticexyz/common@2.0.0-next.5 + - @latticexyz/react@2.0.0-next.5 + - @latticexyz/recs@2.0.0-next.5 + - @latticexyz/store@2.0.0-next.5 + - @latticexyz/utils@2.0.0-next.5 + ## 2.0.0-next.4 ### Patch Changes diff --git a/packages/dev-tools/package.json b/packages/dev-tools/package.json index 5e2a327ff2..bbbbe5a7bf 100644 --- a/packages/dev-tools/package.json +++ b/packages/dev-tools/package.json @@ -1,6 +1,6 @@ { "name": "@latticexyz/dev-tools", - "version": "2.0.0-next.4", + "version": "2.0.0-next.5", "description": "MUD developer tools", "repository": { "type": "git", @@ -19,7 +19,8 @@ "clean": "pnpm run clean:js", "clean:js": "rimraf dist", "dev": "tsup --watch", - "test": "tsc --noEmit" + "test": "tsc --noEmit", + "test:ci": "pnpm run test" }, "dependencies": { "@latticexyz/common": "workspace:*", @@ -50,12 +51,12 @@ "vitest": "0.31.4" }, "peerDependencies": { - "@latticexyz/common": "2.0.0-next.4", - "@latticexyz/recs": "2.0.0-next.4", - "@latticexyz/store": "2.0.0-next.4", - "@latticexyz/store-sync": "2.0.0-next.4", - "@latticexyz/utils": "2.0.0-next.4", - "@latticexyz/world": "2.0.0-next.4" + "@latticexyz/common": "2.0.0-next.5", + "@latticexyz/recs": "2.0.0-next.5", + "@latticexyz/store": "2.0.0-next.5", + "@latticexyz/store-sync": "2.0.0-next.5", + "@latticexyz/utils": "2.0.0-next.5", + "@latticexyz/world": "2.0.0-next.5" }, "publishConfig": { "access": "public" diff --git a/packages/ecs-browser/CHANGELOG.md b/packages/ecs-browser/CHANGELOG.md index a7a77eed13..02344572bc 100644 --- a/packages/ecs-browser/CHANGELOG.md +++ b/packages/ecs-browser/CHANGELOG.md @@ -1,5 +1,7 @@ # @latticexyz/ecs-browser +## 2.0.0-next.5 + ## 2.0.0-next.4 ### Major Changes diff --git a/packages/ecs-browser/package.json b/packages/ecs-browser/package.json index e2b118dd11..49d7268750 100644 --- a/packages/ecs-browser/package.json +++ b/packages/ecs-browser/package.json @@ -1,5 +1,5 @@ { "name": "@latticexyz/ecs-browser", - "version": "2.0.0-next.4", + "version": "2.0.0-next.5", "private": true } diff --git a/packages/gas-report/CHANGELOG.md b/packages/gas-report/CHANGELOG.md index ec0be4c25d..1a110044a7 100644 --- a/packages/gas-report/CHANGELOG.md +++ b/packages/gas-report/CHANGELOG.md @@ -1,5 +1,7 @@ # Change Log +## 2.0.0-next.5 + ## 2.0.0-next.4 ## 2.0.0-next.3 diff --git a/packages/gas-report/package.json b/packages/gas-report/package.json index 568e160b68..2995de67ee 100644 --- a/packages/gas-report/package.json +++ b/packages/gas-report/package.json @@ -1,6 +1,6 @@ { "name": "@latticexyz/gas-report", - "version": "2.0.0-next.4", + "version": "2.0.0-next.5", "description": "Gas reporter for specific lines within forge tests", "repository": { "type": "git", @@ -26,7 +26,8 @@ "build": "tsup", "clean": "rimraf dist", "dev": "tsup --watch", - "test": "vitest typecheck --run --passWithNoTests && vitest --run --passWithNoTests && forge test" + "test": "vitest typecheck --run --passWithNoTests && vitest --run --passWithNoTests && forge test", + "test:ci": "pnpm run test" }, "dependencies": { "chalk": "^5.3.0", diff --git a/packages/network/CHANGELOG.md b/packages/network/CHANGELOG.md index 8d1c5b8da0..cf9e6dba8a 100644 --- a/packages/network/CHANGELOG.md +++ b/packages/network/CHANGELOG.md @@ -1,5 +1,7 @@ # @latticexyz/network +## 2.0.0-next.5 + ## 2.0.0-next.4 ### Major Changes diff --git a/packages/network/package.json b/packages/network/package.json index 1d01bd0058..8cd96418cc 100644 --- a/packages/network/package.json +++ b/packages/network/package.json @@ -1,5 +1,5 @@ { "name": "@latticexyz/network", - "version": "2.0.0-next.4", + "version": "2.0.0-next.5", "private": true } diff --git a/packages/noise/CHANGELOG.md b/packages/noise/CHANGELOG.md index ef74553b9c..5c1e20ab63 100644 --- a/packages/noise/CHANGELOG.md +++ b/packages/noise/CHANGELOG.md @@ -1,5 +1,7 @@ # Change Log +## 2.0.0-next.5 + ## 2.0.0-next.4 ## 2.0.0-next.3 diff --git a/packages/noise/package.json b/packages/noise/package.json index 8f18923cde..10549676ec 100644 --- a/packages/noise/package.json +++ b/packages/noise/package.json @@ -1,6 +1,6 @@ { "name": "@latticexyz/noise", - "version": "2.0.0-next.4", + "version": "2.0.0-next.5", "license": "MIT", "type": "module", "exports": { @@ -16,7 +16,8 @@ "clean:wasm": "rimraf build", "dev": "tsup --watch", "start": "npx serve .", - "test": "forge test && tsc --noEmit" + "test": "forge test && tsc --noEmit", + "test:ci": "pnpm run test" }, "dependencies": { "abdk-libraries-solidity": "^3.0.0", diff --git a/packages/phaserx/CHANGELOG.md b/packages/phaserx/CHANGELOG.md index acdd3a6957..18bebaaeb8 100644 --- a/packages/phaserx/CHANGELOG.md +++ b/packages/phaserx/CHANGELOG.md @@ -1,5 +1,12 @@ # Change Log +## 2.0.0-next.5 + +### Patch Changes + +- Updated dependencies []: + - @latticexyz/utils@2.0.0-next.5 + ## 2.0.0-next.4 ### Patch Changes diff --git a/packages/phaserx/package.json b/packages/phaserx/package.json index 42076c9951..f26667b689 100644 --- a/packages/phaserx/package.json +++ b/packages/phaserx/package.json @@ -1,6 +1,6 @@ { "name": "@latticexyz/phaserx", - "version": "2.0.0-next.4", + "version": "2.0.0-next.5", "repository": { "type": "git", "url": "https://github.com/latticexyz/mud.git", @@ -19,7 +19,8 @@ "clean:js": "rimraf dist", "dev": "tsup --watch", "lint": "eslint . --ext .ts", - "test": "tsc --noEmit" + "test": "tsc --noEmit", + "test:ci": "pnpm run test" }, "dependencies": { "@latticexyz/utils": "workspace:*", diff --git a/packages/protocol-parser/CHANGELOG.md b/packages/protocol-parser/CHANGELOG.md index 765644cd90..557f2f441b 100644 --- a/packages/protocol-parser/CHANGELOG.md +++ b/packages/protocol-parser/CHANGELOG.md @@ -1,5 +1,13 @@ # @latticexyz/protocol-parser +## 2.0.0-next.5 + +### Patch Changes + +- Updated dependencies []: + - @latticexyz/common@2.0.0-next.5 + - @latticexyz/schema-type@2.0.0-next.5 + ## 2.0.0-next.4 ### Patch Changes diff --git a/packages/protocol-parser/package.json b/packages/protocol-parser/package.json index 9a7a46cb7e..3fa8b4ff19 100644 --- a/packages/protocol-parser/package.json +++ b/packages/protocol-parser/package.json @@ -1,6 +1,6 @@ { "name": "@latticexyz/protocol-parser", - "version": "2.0.0-next.4", + "version": "2.0.0-next.5", "description": "Parser utilities for the MUD protocol", "repository": { "type": "git", @@ -20,7 +20,8 @@ "clean:js": "rimraf dist", "dev": "tsup --watch", "lint": "eslint .", - "test": "vitest typecheck --run && vitest --run" + "test": "vitest typecheck --run && vitest --run", + "test:ci": "pnpm run test" }, "dependencies": { "@latticexyz/common": "workspace:*", diff --git a/packages/react/CHANGELOG.md b/packages/react/CHANGELOG.md index 0b7f80530c..ebc7ea2ca6 100644 --- a/packages/react/CHANGELOG.md +++ b/packages/react/CHANGELOG.md @@ -1,5 +1,13 @@ # Change Log +## 2.0.0-next.5 + +### Patch Changes + +- Updated dependencies []: + - @latticexyz/recs@2.0.0-next.5 + - @latticexyz/store@2.0.0-next.5 + ## 2.0.0-next.4 ### Major Changes diff --git a/packages/react/package.json b/packages/react/package.json index 325080bafa..b3780755be 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -1,6 +1,6 @@ { "name": "@latticexyz/react", - "version": "2.0.0-next.4", + "version": "2.0.0-next.5", "description": "React tools for MUD client.", "repository": { "type": "git", @@ -19,7 +19,8 @@ "clean": "pnpm run clean:js", "clean:js": "rimraf dist", "dev": "tsup --watch", - "test": "tsc --noEmit && vitest --run" + "test": "tsc --noEmit && vitest --run", + "test:ci": "pnpm run test" }, "dependencies": { "@latticexyz/recs": "workspace:*", diff --git a/packages/recs/CHANGELOG.md b/packages/recs/CHANGELOG.md index b94011747f..3853bfd943 100644 --- a/packages/recs/CHANGELOG.md +++ b/packages/recs/CHANGELOG.md @@ -1,5 +1,13 @@ # Change Log +## 2.0.0-next.5 + +### Patch Changes + +- Updated dependencies []: + - @latticexyz/schema-type@2.0.0-next.5 + - @latticexyz/utils@2.0.0-next.5 + ## 2.0.0-next.4 ### Minor Changes diff --git a/packages/recs/package.json b/packages/recs/package.json index 886dced6f7..12e3e31514 100644 --- a/packages/recs/package.json +++ b/packages/recs/package.json @@ -1,6 +1,6 @@ { "name": "@latticexyz/recs", - "version": "2.0.0-next.4", + "version": "2.0.0-next.5", "repository": { "type": "git", "url": "https://github.com/latticexyz/mud.git", @@ -29,7 +29,8 @@ "clean:js": "rimraf dist", "dev": "tsup --watch", "lint": "eslint . --ext .ts", - "test": "tsc --noEmit && jest" + "test": "tsc --noEmit && jest", + "test:ci": "pnpm run test" }, "dependencies": { "@latticexyz/schema-type": "workspace:*", diff --git a/packages/schema-type/CHANGELOG.md b/packages/schema-type/CHANGELOG.md index 16993b7395..dd349d3101 100644 --- a/packages/schema-type/CHANGELOG.md +++ b/packages/schema-type/CHANGELOG.md @@ -1,5 +1,7 @@ # Change Log +## 2.0.0-next.5 + ## 2.0.0-next.4 ## 2.0.0-next.3 diff --git a/packages/schema-type/package.json b/packages/schema-type/package.json index e9cf890e18..52110375d1 100644 --- a/packages/schema-type/package.json +++ b/packages/schema-type/package.json @@ -1,6 +1,6 @@ { "name": "@latticexyz/schema-type", - "version": "2.0.0-next.4", + "version": "2.0.0-next.5", "description": "SchemaType enum for various languages", "repository": { "type": "git", @@ -30,7 +30,8 @@ "clean:js": "rimraf dist/typescript", "dev": "tsup --watch", "gas-report": "mud-gas-report --save gas-report.json", - "test": "vitest typecheck --run && vitest --run && forge test" + "test": "vitest typecheck --run && vitest --run && forge test", + "test:ci": "pnpm run test" }, "dependencies": { "abitype": "0.9.3", diff --git a/packages/services/CHANGELOG.md b/packages/services/CHANGELOG.md index 3edccdaed8..3e284e05a0 100644 --- a/packages/services/CHANGELOG.md +++ b/packages/services/CHANGELOG.md @@ -1,5 +1,13 @@ # Change Log +## 2.0.0-next.5 + +### Patch Changes + +- [#1377](https://github.com/latticexyz/mud/pull/1377) [`33f50f8a`](https://github.com/latticexyz/mud/commit/33f50f8a473398dcc19b17d10a17a552a82678c7) Thanks [@alvrs](https://github.com/alvrs)! - Fixed an issue where the TypeScript types for createFaucetService were not exported correctly from the @latticexyz/services package + +- [#1219](https://github.com/latticexyz/mud/pull/1219) [`80a26419`](https://github.com/latticexyz/mud/commit/80a26419f15177333b523bac5d09767487b4ffef) Thanks [@ludns](https://github.com/ludns)! - The build phase of services now works on machines with older protobuf compilers + ## 2.0.0-next.4 ## 2.0.0-next.3 diff --git a/packages/services/Makefile b/packages/services/Makefile index 989dcdba22..945a2318bf 100644 --- a/packages/services/Makefile +++ b/packages/services/Makefile @@ -29,27 +29,32 @@ protoc-ts: --plugin protoc-gen-ts_proto=./node_modules/.bin/protoc-gen-ts_proto \ --ts_proto_out ./protobuf/ts/ecs-stream \ --ts_proto_opt=env=browser,outputServices=nice-grpc,outputServices=generic-definitions,outputJsonMethods=false,useExactTypes=false,eslint_disable,esModuleInterop=true,importSuffix=.js \ - --proto_path proto proto/ecs-stream.proto + --proto_path proto proto/ecs-stream.proto \ + --experimental_allow_proto3_optional protoc \ --plugin protoc-gen-ts_proto=./node_modules/.bin/protoc-gen-ts_proto \ --ts_proto_out ./protobuf/ts/ecs-snapshot \ --ts_proto_opt=env=browser,outputServices=nice-grpc,outputServices=generic-definitions,outputJsonMethods=false,useExactTypes=false,eslint_disable,esModuleInterop=true,importSuffix=.js \ - --proto_path proto proto/ecs-snapshot.proto + --proto_path proto proto/ecs-snapshot.proto \ + --experimental_allow_proto3_optional protoc \ --plugin protoc-gen-ts_proto=./node_modules/.bin/protoc-gen-ts_proto \ --ts_proto_out ./protobuf/ts/ecs-relay \ --ts_proto_opt=env=browser,outputServices=nice-grpc,outputServices=generic-definitions,outputJsonMethods=false,useExactTypes=false,eslint_disable,esModuleInterop=true,importSuffix=.js \ - --proto_path proto proto/ecs-relay.proto + --proto_path proto proto/ecs-relay.proto \ + --experimental_allow_proto3_optional protoc \ --plugin protoc-gen-ts_proto=./node_modules/.bin/protoc-gen-ts_proto \ --ts_proto_out ./protobuf/ts/faucet \ --ts_proto_opt=env=browser,outputServices=nice-grpc,outputServices=generic-definitions,outputJsonMethods=false,useExactTypes=false,eslint_disable,esModuleInterop=true,importSuffix=.js \ - --proto_path proto proto/faucet.proto + --proto_path proto proto/faucet.proto \ + --experimental_allow_proto3_optional protoc \ --plugin protoc-gen-ts_proto=./node_modules/.bin/protoc-gen-ts_proto \ --ts_proto_out ./protobuf/ts/mode \ --ts_proto_opt=env=browser,outputServices=nice-grpc,outputServices=generic-definitions,outputJsonMethods=false,useExactTypes=false,eslint_disable,esModuleInterop=true,importSuffix=.js \ - --proto_path proto proto/mode.proto + --proto_path proto proto/mode.proto \ + --experimental_allow_proto3_optional .PHONY: protoc-ts protoc-clean: diff --git a/packages/services/package.json b/packages/services/package.json index d99ca3f7fb..0763ac49d8 100644 --- a/packages/services/package.json +++ b/packages/services/package.json @@ -1,6 +1,6 @@ { "name": "@latticexyz/services", - "version": "2.0.0-next.4", + "version": "2.0.0-next.5", "description": "MUD services for enhanced interactions with on-chain ECS state", "repository": { "type": "git", @@ -42,6 +42,7 @@ "build:protobuf": "make protoc-ts && prettier --write protobuf/ts/**/*.ts", "dev": "tsup --watch", "test": "pnpm run test:go", + "test:ci": "pnpm run test", "test:go": "go test -v ./..." }, "dependencies": { diff --git a/packages/solecs/CHANGELOG.md b/packages/solecs/CHANGELOG.md index 72267d0339..3861d7519a 100644 --- a/packages/solecs/CHANGELOG.md +++ b/packages/solecs/CHANGELOG.md @@ -1,5 +1,7 @@ # @latticexyz/solecs +## 2.0.0-next.5 + ## 2.0.0-next.4 ### Major Changes diff --git a/packages/solecs/package.json b/packages/solecs/package.json index 3e55da84cf..b78228af40 100644 --- a/packages/solecs/package.json +++ b/packages/solecs/package.json @@ -1,5 +1,5 @@ { "name": "@latticexyz/solecs", - "version": "2.0.0-next.4", + "version": "2.0.0-next.5", "private": true } diff --git a/packages/solhint-config-mud/CHANGELOG.md b/packages/solhint-config-mud/CHANGELOG.md index 5cae8b8b41..ecb612012b 100644 --- a/packages/solhint-config-mud/CHANGELOG.md +++ b/packages/solhint-config-mud/CHANGELOG.md @@ -1,5 +1,7 @@ # Change Log +## 2.0.0-next.5 + ## 2.0.0-next.4 ## 2.0.0-next.3 diff --git a/packages/solhint-config-mud/package.json b/packages/solhint-config-mud/package.json index d0ece73535..7415006f40 100644 --- a/packages/solhint-config-mud/package.json +++ b/packages/solhint-config-mud/package.json @@ -1,6 +1,6 @@ { "name": "solhint-config-mud", - "version": "2.0.0-next.4", + "version": "2.0.0-next.5", "repository": { "type": "git", "url": "https://github.com/latticexyz/mud.git", diff --git a/packages/solhint-plugin-mud/CHANGELOG.md b/packages/solhint-plugin-mud/CHANGELOG.md index 5cae8b8b41..ecb612012b 100644 --- a/packages/solhint-plugin-mud/CHANGELOG.md +++ b/packages/solhint-plugin-mud/CHANGELOG.md @@ -1,5 +1,7 @@ # Change Log +## 2.0.0-next.5 + ## 2.0.0-next.4 ## 2.0.0-next.3 diff --git a/packages/solhint-plugin-mud/package.json b/packages/solhint-plugin-mud/package.json index 79dfa324c0..4bac91dfcb 100644 --- a/packages/solhint-plugin-mud/package.json +++ b/packages/solhint-plugin-mud/package.json @@ -1,6 +1,6 @@ { "name": "solhint-plugin-mud", - "version": "2.0.0-next.4", + "version": "2.0.0-next.5", "repository": { "type": "git", "url": "https://github.com/latticexyz/mud.git", diff --git a/packages/std-client/CHANGELOG.md b/packages/std-client/CHANGELOG.md index d9865b1f47..8a3499aa5b 100644 --- a/packages/std-client/CHANGELOG.md +++ b/packages/std-client/CHANGELOG.md @@ -1,5 +1,7 @@ # @latticexyz/std-client +## 2.0.0-next.5 + ## 2.0.0-next.4 ### Major Changes diff --git a/packages/std-client/package.json b/packages/std-client/package.json index 6a35629b3c..b551b4f70e 100644 --- a/packages/std-client/package.json +++ b/packages/std-client/package.json @@ -1,5 +1,5 @@ { "name": "@latticexyz/std-client", - "version": "2.0.0-next.4", + "version": "2.0.0-next.5", "private": true } diff --git a/packages/std-contracts/CHANGELOG.md b/packages/std-contracts/CHANGELOG.md index 9e01d3aa24..a429270498 100644 --- a/packages/std-contracts/CHANGELOG.md +++ b/packages/std-contracts/CHANGELOG.md @@ -1,5 +1,7 @@ # @latticexyz/std-contracts +## 2.0.0-next.5 + ## 2.0.0-next.4 ### Major Changes diff --git a/packages/std-contracts/package.json b/packages/std-contracts/package.json index a26824d6cb..e93d7552bd 100644 --- a/packages/std-contracts/package.json +++ b/packages/std-contracts/package.json @@ -1,5 +1,5 @@ { "name": "@latticexyz/std-contracts", - "version": "2.0.0-next.4", + "version": "2.0.0-next.5", "private": true } diff --git a/packages/store-cache/CHANGELOG.md b/packages/store-cache/CHANGELOG.md index 80de76b427..fed2fc6479 100644 --- a/packages/store-cache/CHANGELOG.md +++ b/packages/store-cache/CHANGELOG.md @@ -1,5 +1,7 @@ # @latticexyz/store-cache +## 2.0.0-next.5 + ## 2.0.0-next.4 ### Major Changes diff --git a/packages/store-cache/package.json b/packages/store-cache/package.json index cf316e5245..9a3209bb66 100644 --- a/packages/store-cache/package.json +++ b/packages/store-cache/package.json @@ -1,5 +1,5 @@ { "name": "@latticexyz/store-cache", - "version": "2.0.0-next.4", + "version": "2.0.0-next.5", "private": true } diff --git a/packages/store-indexer/CHANGELOG.md b/packages/store-indexer/CHANGELOG.md index f07012677c..51b19b5d29 100644 --- a/packages/store-indexer/CHANGELOG.md +++ b/packages/store-indexer/CHANGELOG.md @@ -1,5 +1,15 @@ # @latticexyz/store-indexer +## 2.0.0-next.5 + +### Patch Changes + +- Updated dependencies []: + - @latticexyz/store-sync@2.0.0-next.5 + - @latticexyz/block-logs-stream@2.0.0-next.5 + - @latticexyz/common@2.0.0-next.5 + - @latticexyz/store@2.0.0-next.5 + ## 2.0.0-next.4 ### Patch Changes diff --git a/packages/store-indexer/package.json b/packages/store-indexer/package.json index a4f9431668..e637cc412c 100644 --- a/packages/store-indexer/package.json +++ b/packages/store-indexer/package.json @@ -1,6 +1,6 @@ { "name": "@latticexyz/store-indexer", - "version": "2.0.0-next.4", + "version": "2.0.0-next.5", "description": "Minimal Typescript indexer for Store", "repository": { "type": "git", @@ -28,7 +28,8 @@ "start:sqlite:local": "SQLITE_FILENAME=anvil.db CHAIN_ID=31337 pnpm start:sqlite", "start:sqlite:testnet": "SQLITE_FILENAME=testnet.db CHAIN_ID=4242 START_BLOCK=19037160 pnpm start:sqlite", "start:sqlite:testnet2": "SQLITE_FILENAME=testnet2.db CHAIN_ID=4243 pnpm start:sqlite", - "test": "tsc --noEmit --skipLibCheck" + "test": "tsc --noEmit --skipLibCheck", + "test:ci": "pnpm run test" }, "dependencies": { "@fastify/cors": "^8.3.0", diff --git a/packages/store-sync/CHANGELOG.md b/packages/store-sync/CHANGELOG.md index afdcb39dde..18afab971b 100644 --- a/packages/store-sync/CHANGELOG.md +++ b/packages/store-sync/CHANGELOG.md @@ -1,5 +1,18 @@ # @latticexyz/store-sync +## 2.0.0-next.5 + +### Patch Changes + +- Updated dependencies [[`ce97426c`](https://github.com/latticexyz/mud/commit/ce97426c0d70832e5efdb8bad83207a9d840302b), [`1ca35e9a`](https://github.com/latticexyz/mud/commit/1ca35e9a1630a51dfd1e082c26399f76f2cd06ed), [`9d0f492a`](https://github.com/latticexyz/mud/commit/9d0f492a90e5d94c6b38ad732e78fd4b13b2adbe), [`c583f3cd`](https://github.com/latticexyz/mud/commit/c583f3cd08767575ce9df39725ec51195b5feb5b)]: + - @latticexyz/world@2.0.0-next.5 + - @latticexyz/block-logs-stream@2.0.0-next.5 + - @latticexyz/common@2.0.0-next.5 + - @latticexyz/protocol-parser@2.0.0-next.5 + - @latticexyz/recs@2.0.0-next.5 + - @latticexyz/schema-type@2.0.0-next.5 + - @latticexyz/store@2.0.0-next.5 + ## 2.0.0-next.4 ### Patch Changes diff --git a/packages/store-sync/package.json b/packages/store-sync/package.json index 406dcb2cb9..709a9aeb2e 100644 --- a/packages/store-sync/package.json +++ b/packages/store-sync/package.json @@ -1,6 +1,6 @@ { "name": "@latticexyz/store-sync", - "version": "2.0.0-next.4", + "version": "2.0.0-next.5", "description": "Utilities to sync MUD Store events with a client or cache", "repository": { "type": "git", @@ -42,8 +42,8 @@ "clean:js": "rimraf dist", "dev": "tsup --watch", "lint": "eslint .", - "test": "vitest --run", - "test:local": "DATABASE_URL=http://127.0.0.1:5432/postgres vitest" + "test": "DATABASE_URL=http://127.0.0.1:5432/postgres vitest", + "test:ci": "vitest --run" }, "dependencies": { "@latticexyz/block-logs-stream": "workspace:*", diff --git a/packages/store/CHANGELOG.md b/packages/store/CHANGELOG.md index 7310612633..c5fddbca42 100644 --- a/packages/store/CHANGELOG.md +++ b/packages/store/CHANGELOG.md @@ -1,5 +1,15 @@ # Change Log +## 2.0.0-next.5 + +### Patch Changes + +- Updated dependencies []: + - @latticexyz/common@2.0.0-next.5 + - @latticexyz/config@2.0.0-next.5 + - @latticexyz/gas-report@2.0.0-next.5 + - @latticexyz/schema-type@2.0.0-next.5 + ## 2.0.0-next.4 ### Patch Changes diff --git a/packages/store/package.json b/packages/store/package.json index 1dfb249ef2..dae5c1f8a1 100644 --- a/packages/store/package.json +++ b/packages/store/package.json @@ -1,6 +1,6 @@ { "name": "@latticexyz/store", - "version": "2.0.0-next.4", + "version": "2.0.0-next.5", "description": "Store", "repository": { "type": "git", @@ -48,7 +48,8 @@ "dev": "tsup --watch", "gas-report": "mud-gas-report --save gas-report.json", "lint": "solhint --config ./.solhint.json 'src/**/*.sol'", - "test": "vitest typecheck --run && vitest --run --passWithNoTests && forge test" + "test": "vitest typecheck --run && vitest --run --passWithNoTests && forge test", + "test:ci": "pnpm run test" }, "dependencies": { "@ethersproject/abi": "^5.7.0", diff --git a/packages/utils/CHANGELOG.md b/packages/utils/CHANGELOG.md index 623dc83c03..084fe5d32f 100644 --- a/packages/utils/CHANGELOG.md +++ b/packages/utils/CHANGELOG.md @@ -1,5 +1,7 @@ # Change Log +## 2.0.0-next.5 + ## 2.0.0-next.4 ## 2.0.0-next.3 diff --git a/packages/utils/package.json b/packages/utils/package.json index 7e5618a8e6..48b882ceb3 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@latticexyz/utils", - "version": "2.0.0-next.4", + "version": "2.0.0-next.5", "repository": { "type": "git", "url": "https://github.com/latticexyz/mud.git", @@ -19,7 +19,8 @@ "clean:js": "rimraf dist", "dev": "tsup --watch", "lint": "eslint . --ext .ts", - "test": "tsc --noEmit && jest" + "test": "tsc --noEmit && jest", + "test:ci": "pnpm run test" }, "dependencies": { "ethers": "^5.7.2", diff --git a/packages/world/CHANGELOG.md b/packages/world/CHANGELOG.md index 6366289860..8cd0e316a6 100644 --- a/packages/world/CHANGELOG.md +++ b/packages/world/CHANGELOG.md @@ -1,5 +1,203 @@ # Change Log +## 2.0.0-next.5 + +### Major Changes + +- [#1370](https://github.com/latticexyz/mud/pull/1370) [`9d0f492a`](https://github.com/latticexyz/mud/commit/9d0f492a90e5d94c6b38ad732e78fd4b13b2adbe) Thanks [@alvrs](https://github.com/alvrs)! - - The previous `Call.withSender` util is replaced with `WorldContextProvider`, since the usecase of appending the `msg.sender` to the calldata is tightly coupled with `WorldContextConsumer` (which extracts the appended context from the calldata). + + The previous `Call.withSender` utility reverted if the call failed and only returned the returndata on success. This is replaced with `callWithContextOrRevert`/`delegatecallWithContextOrRevert` + + ```diff + -import { Call } from "@latticexyz/world/src/Call.sol"; + +import { WorldContextProvider } from "@latticexyz/world/src/WorldContext.sol"; + + -Call.withSender({ + - delegate: false, + - value: 0, + - ... + -}); + +WorldContextProvider.callWithContextOrRevert({ + + value: 0, + + ... + +}); + + -Call.withSender({ + - delegate: true, + - value: 0, + - ... + -}); + +WorldContextProvider.delegatecallWithContextOrRevert({ + + ... + +}); + ``` + + In addition there are utils that return a `bool success` flag instead of reverting on errors. This mirrors the behavior of Solidity's low level `call`/`delegatecall` functions and is useful in situations where additional logic should be executed in case of a reverting external call. + + ```solidity + library WorldContextProvider { + function callWithContext( + address target, // Address to call + bytes memory funcSelectorAndArgs, // Abi encoded function selector and arguments to pass to pass to the contract + address msgSender, // Address to append to the calldata as context for msgSender + uint256 value // Value to pass with the call + ) internal returns (bool success, bytes memory data); + + function delegatecallWithContext( + address target, // Address to call + bytes memory funcSelectorAndArgs, // Abi encoded function selector and arguments to pass to pass to the contract + address msgSender // Address to append to the calldata as context for msgSender + ) internal returns (bool success, bytes memory data); + } + ``` + + - `WorldContext` is renamed to `WorldContextConsumer` to clarify the relationship between `WorldContextProvider` (appending context to the calldata) and `WorldContextConsumer` (extracting context from the calldata) + + ```diff + -import { WorldContext } from "@latticexyz/world/src/WorldContext.sol"; + -import { WorldContextConsumer } from "@latticexyz/world/src/WorldContext.sol"; + ``` + + - The `World` contract previously had a `_call` method to handle calling systems via their resource selector, performing accesss control checks and call hooks registered for the system. + + ```solidity + library SystemCall { + /** + * Calls a system via its resource selector and perform access control checks. + * Does not revert if the call fails, but returns a `success` flag along with the returndata. + */ + function call( + address caller, + bytes32 resourceSelector, + bytes memory funcSelectorAndArgs, + uint256 value + ) internal returns (bool success, bytes memory data); + + /** + * Calls a system via its resource selector, perform access control checks and trigger hooks registered for the system. + * Does not revert if the call fails, but returns a `success` flag along with the returndata. + */ + function callWithHooks( + address caller, + bytes32 resourceSelector, + bytes memory funcSelectorAndArgs, + uint256 value + ) internal returns (bool success, bytes memory data); + + /** + * Calls a system via its resource selector, perform access control checks and trigger hooks registered for the system. + * Reverts if the call fails. + */ + function callWithHooksOrRevert( + address caller, + bytes32 resourceSelector, + bytes memory funcSelectorAndArgs, + uint256 value + ) internal returns (bytes memory data); + } + ``` + + - System hooks now are called with the system's resource selector instead of its address. The system's address can still easily obtained within the hook via `Systems.get(resourceSelector)` if necessary. + + ```diff + interface ISystemHook { + function onBeforeCallSystem( + address msgSender, + - address systemAddress, + + bytes32 resourceSelector, + bytes memory funcSelectorAndArgs + ) external; + + function onAfterCallSystem( + address msgSender, + - address systemAddress, + + bytes32 resourceSelector, + bytes memory funcSelectorAndArgs + ) external; + } + ``` + +### Minor Changes + +- [#1378](https://github.com/latticexyz/mud/pull/1378) [`ce97426c`](https://github.com/latticexyz/mud/commit/ce97426c0d70832e5efdb8bad83207a9d840302b) Thanks [@alvrs](https://github.com/alvrs)! - It is now possible to upgrade systems by calling `registerSystem` again with an existing system id (resource selector). + + ```solidity + // Register a system + world.registerSystem(systemId, systemAddress, publicAccess); + + // Upgrade the system by calling `registerSystem` with the + // same system id but a new system address or publicAccess flag + world.registerSystem(systemId, newSystemAddress, newPublicAccess); + ``` + +- [#1364](https://github.com/latticexyz/mud/pull/1364) [`1ca35e9a`](https://github.com/latticexyz/mud/commit/1ca35e9a1630a51dfd1e082c26399f76f2cd06ed) Thanks [@alvrs](https://github.com/alvrs)! - The `World` has a new `callFrom` entry point which allows systems to be called on behalf of other addresses if those addresses have registered a delegation. + If there is a delegation, the call is forwarded to the system with `delegator` as `msgSender`. + + ```solidity + interface IBaseWorld { + function callFrom( + address delegator, + bytes32 resourceSelector, + bytes memory funcSelectorAndArgs + ) external payable virtual returns (bytes memory); + } + ``` + + A delegation can be registered via the `World`'s `registerDelegation` function. + If `delegatee` is `address(0)`, the delegation is considered to be a "fallback" delegation and is used in `callFrom` if there is no delegation is found for the specific caller. + Otherwise the delegation is registered for the specific `delegatee`. + + ```solidity + interface IBaseWorld { + function registerDelegation( + address delegatee, + bytes32 delegationControl, + bytes memory initFuncSelectorAndArgs + ) external; + } + ``` + + The `delegationControl` refers to the resource selector of a `DelegationControl` system that must have been registered beforehand. + As part of registering the delegation, the `DelegationControl` system is called with the provided `initFuncSelectorAndArgs`. + This can be used to initialize data in the given `DelegationControl` system. + + The `DelegationControl` system must implement the `IDelegationControl` interface: + + ```solidity + interface IDelegationControl { + function verify(address delegator, bytes32 systemId, bytes calldata funcSelectorAndArgs) external returns (bool); + } + ``` + + When `callFrom` is called, the `World` checks if a delegation is registered for the given caller, and if so calls the delegation control's `verify` function with the same same arguments as `callFrom`. + If the call to `verify` is successful and returns `true`, the delegation is valid and the call is forwarded to the system with `delegator` as `msgSender`. + + Note: if `UNLIMITED_DELEGATION` (from `@latticexyz/world/src/constants.sol`) is passed as `delegationControl`, the external call to the delegation control contract is skipped and the delegation is considered valid. + + For examples of `DelegationControl` systems, check out the `CallboundDelegationControl` or `TimeboundDelegationControl` systems in the `std-delegations` module. + See `StandardDelegations.t.sol` for usage examples. + +- [#1274](https://github.com/latticexyz/mud/pull/1274) [`c583f3cd`](https://github.com/latticexyz/mud/commit/c583f3cd08767575ce9df39725ec51195b5feb5b) Thanks [@johngrantuk](https://github.com/johngrantuk)! - It is now possible to transfer ownership of namespaces! + + ```solidity + // Register a new namespace + world.registerNamespace("namespace"); + // It's owned by the caller of the function (address(this)) + + // Transfer ownership of the namespace to address(42) + world.transferOwnership("namespace", address(42)); + // It's now owned by address(42) + ``` + +### Patch Changes + +- Updated dependencies []: + - @latticexyz/common@2.0.0-next.5 + - @latticexyz/config@2.0.0-next.5 + - @latticexyz/gas-report@2.0.0-next.5 + - @latticexyz/schema-type@2.0.0-next.5 + - @latticexyz/store@2.0.0-next.5 + ## 2.0.0-next.4 ### Patch Changes diff --git a/packages/world/gas-report.json b/packages/world/gas-report.json index 7a66c2d785..b142eb66ee 100644 --- a/packages/world/gas-report.json +++ b/packages/world/gas-report.json @@ -255,7 +255,7 @@ "file": "test/UniqueEntityModule.t.sol", "test": "testInstall", "name": "install unique entity module", - "gasUsed": 722425 + "gasUsed": 726281 }, { "file": "test/UniqueEntityModule.t.sol", @@ -267,7 +267,7 @@ "file": "test/UniqueEntityModule.t.sol", "test": "testInstallRoot", "name": "installRoot unique entity module", - "gasUsed": 701392 + "gasUsed": 705270 }, { "file": "test/UniqueEntityModule.t.sol", @@ -309,19 +309,19 @@ "file": "test/World.t.sol", "test": "testRegisterFallbackSystem", "name": "Register a fallback system", - "gasUsed": 70416 + "gasUsed": 70405 }, { "file": "test/World.t.sol", "test": "testRegisterFallbackSystem", "name": "Register a root fallback system", - "gasUsed": 63722 + "gasUsed": 63711 }, { "file": "test/World.t.sol", "test": "testRegisterFunctionSelector", "name": "Register a function selector", - "gasUsed": 91010 + "gasUsed": 90999 }, { "file": "test/World.t.sol", @@ -333,7 +333,7 @@ "file": "test/World.t.sol", "test": "testRegisterRootFunctionSelector", "name": "Register a root function selector", - "gasUsed": 79633 + "gasUsed": 79622 }, { "file": "test/World.t.sol", diff --git a/packages/world/package.json b/packages/world/package.json index b827b3e748..9c73236b55 100644 --- a/packages/world/package.json +++ b/packages/world/package.json @@ -1,6 +1,6 @@ { "name": "@latticexyz/world", - "version": "2.0.0-next.4", + "version": "2.0.0-next.5", "description": "World framework", "repository": { "type": "git", @@ -44,7 +44,8 @@ "dev": "tsup --watch", "gas-report": "mud-gas-report --save gas-report.json", "lint": "solhint --config ./.solhint.json 'src/**/*.sol'", - "test": "tsc --noEmit && vitest --run && forge test" + "test": "tsc --noEmit && vitest --run && forge test", + "test:ci": "pnpm run test" }, "dependencies": { "@ethersproject/abi": "^5.7.0", diff --git a/packages/world/src/modules/core/implementations/WorldRegistrationSystem.sol b/packages/world/src/modules/core/implementations/WorldRegistrationSystem.sol index ceba247354..9f38aa0c33 100644 --- a/packages/world/src/modules/core/implementations/WorldRegistrationSystem.sol +++ b/packages/world/src/modules/core/implementations/WorldRegistrationSystem.sol @@ -62,13 +62,19 @@ contract WorldRegistrationSystem is System, IWorldErrors { * If the namespace doesn't exist yet, it is registered. * The system is granted access to its namespace, so it can write to any table in the same namespace. * If publicAccess is true, no access control check is performed for calling the system. + * + * Note: this function doesn't check whether a system already exists at the given selector, + * making it possible to upgrade systems. */ function registerSystem(bytes32 resourceSelector, WorldContextConsumer system, bool publicAccess) public virtual { // Require the name to not be the namespace's root name if (resourceSelector.getName() == ROOT_NAME) revert InvalidSelector(resourceSelector.toString()); - // Require the system to not exist yet - if (SystemRegistry.get(address(system)) != 0) revert SystemExists(address(system)); + // Require this system to not be registered at a different resource selector yet + bytes32 existingResourceSelector = SystemRegistry.get(address(system)); + if (existingResourceSelector != 0 && existingResourceSelector != resourceSelector) { + revert SystemExists(address(system)); + } // If the namespace doesn't exist yet, register it // otherwise require caller to own the namespace @@ -76,13 +82,26 @@ contract WorldRegistrationSystem is System, IWorldErrors { if (ResourceType.get(namespace) == Resource.NONE) registerNamespace(namespace); else AccessControl.requireOwnerOrSelf(namespace, _msgSender()); - // Require no resource to exist at this selector yet - if (ResourceType.get(resourceSelector) != Resource.NONE) { + // Require no resource other than a system to exist at this selector yet + Resource resourceType = ResourceType.get(resourceSelector); + if (resourceType != Resource.NONE && resourceType != Resource.SYSTEM) { revert ResourceExists(resourceSelector.toString()); } - // Store the system resource type - ResourceType.set(resourceSelector, Resource.SYSTEM); + // Check if a system already exists at this resource selector + address existingSystem = Systems.getSystem(resourceSelector); + + // If there is an existing system with this resource selector, remove it + if (existingSystem != address(0)) { + // Remove the existing system from the system registry + SystemRegistry.deleteRecord(existingSystem); + + // Remove the existing system's access to its namespace + ResourceAccess.deleteRecord(namespace, existingSystem); + } else { + // Otherwise, this is a new system, so register its resource type + ResourceType.set(resourceSelector, Resource.SYSTEM); + } // Systems = mapping from resourceSelector to system address and publicAccess Systems.set(resourceSelector, address(system), publicAccess); diff --git a/packages/world/test/World.t.sol b/packages/world/test/World.t.sol index 5044a3f4d5..f9f47e2756 100644 --- a/packages/world/test/World.t.sol +++ b/packages/world/test/World.t.sol @@ -19,12 +19,15 @@ import { World } from "../src/World.sol"; import { System } from "../src/System.sol"; import { ResourceSelector } from "../src/ResourceSelector.sol"; import { ROOT_NAMESPACE, ROOT_NAME, UNLIMITED_DELEGATION } from "../src/constants.sol"; +import { Resource } from "../src/Types.sol"; import { NamespaceOwner, NamespaceOwnerTableId } from "../src/tables/NamespaceOwner.sol"; import { ResourceAccess } from "../src/tables/ResourceAccess.sol"; import { CoreModule } from "../src/modules/core/CoreModule.sol"; import { Systems } from "../src/modules/core/tables/Systems.sol"; +import { SystemRegistry } from "../src/modules/core/tables/SystemRegistry.sol"; +import { ResourceType } from "../src/modules/core/tables/ResourceType.sol"; import { IBaseWorld } from "../src/interfaces/IBaseWorld.sol"; import { IWorldErrors } from "../src/interfaces/IWorldErrors.sol"; @@ -355,16 +358,19 @@ contract WorldTest is Test, GasReporter { world.registerSystem(ResourceSelector.from("newNamespace", "testSystem"), new System(), false); assertEq(NamespaceOwner.get(world, "newNamespace"), address(this)); - // Expect an error when registering an existing system + // Expect an error when registering an existing system at a new resource selector vm.expectRevert(abi.encodeWithSelector(IWorldErrors.SystemExists.selector, address(system))); world.registerSystem(ResourceSelector.from("", "newSystem"), system, true); - // Expect an error when registering a system at an existing resource selector - System newSystem = new System(); + // Don't expect an error when updating the public access of an existing system + world.registerSystem(resourceSelector, system, true); - // Expect an error when registering a system at an existing resource selector - vm.expectRevert(abi.encodeWithSelector(IWorldErrors.ResourceExists.selector, resourceSelector.toString())); - world.registerSystem(ResourceSelector.from("", "testSystem"), newSystem, true); + // Expect an error when registering a system at an existing resource selector of a different type + System newSystem = new System(); + bytes32 tableId = ResourceSelector.from("", "testTable"); + world.registerTable(tableId, defaultKeySchema, Bool.getValueSchema(), new string[](1), new string[](1)); + vm.expectRevert(abi.encodeWithSelector(IWorldErrors.ResourceExists.selector, tableId.toString())); + world.registerSystem(tableId, newSystem, true); // Expect an error when registering a system in a namespace is not owned by the caller System yetAnotherSystem = new System(); @@ -376,6 +382,42 @@ contract WorldTest is Test, GasReporter { world.registerSystem(ResourceSelector.from("", "rootSystem"), yetAnotherSystem, true); } + function testUpgradeSystem() public { + bytes16 namespace = "testNamespace"; + bytes16 systemName = "testSystem"; + bytes32 systemId = ResourceSelector.from(namespace, systemName); + + // Register a system + System oldSystem = new System(); + world.registerSystem(systemId, oldSystem, true); + + // Upgrade the system and set public access to false + System newSystem = new System(); + world.registerSystem(systemId, newSystem, false); + + // Expect the system address and public access to be updated in the System table + (address registeredAddress, bool publicAccess) = Systems.get(world, systemId); + assertEq(registeredAddress, address(newSystem)); + assertEq(publicAccess, false); + + // Expect the SystemRegistry table to not have a reference to the old system anymore + bytes32 registeredSystemId = SystemRegistry.get(world, address(oldSystem)); + assertEq(registeredSystemId, bytes32(0)); + + // Expect the SystemRegistry table to have a reference to the new system + registeredSystemId = SystemRegistry.get(world, address(newSystem)); + assertEq(registeredSystemId, systemId); + + // Expect the old system to not have access to the namespace anymore + assertFalse(ResourceAccess.get(world, namespace, address(oldSystem))); + + // Expect the new system to have access to the namespace + assertTrue(ResourceAccess.get(world, namespace, address(newSystem))); + + // Expect the resource type to still be SYSTEM + assertEq(uint8(ResourceType.get(world, systemId)), uint8(Resource.SYSTEM)); + } + function testDuplicateSelectors() public { // Register a new table bytes32 resourceSelector = ResourceSelector.from("namespace", "name");