From 9aa5e7865bc8f6f090f599ac1367bc927aaee2e4 Mon Sep 17 00:00:00 2001 From: Kevin Ingersoll Date: Tue, 12 Mar 2024 11:12:27 +0000 Subject: [PATCH] feat(store,world): set protocol version, add tests (#2412) --- .changeset/green-eggs-end.md | 6 ++ docs/pages/store/reference/misc.mdx | 6 +- docs/pages/store/reference/store-core.mdx | 8 +-- docs/pages/store/reference/store.mdx | 4 +- docs/pages/world/reference/misc.mdx | 6 +- docs/pages/world/reference/world-external.mdx | 16 ++--- packages/cli/src/deploy/common.ts | 4 +- packages/cli/src/deploy/logsToWorldDeploy.ts | 6 +- packages/store/src/IStoreEvents.sol | 4 +- packages/store/src/StoreData.sol | 4 +- packages/store/src/version.sol | 8 +-- .../store/ts/protocol-snapshots/2.0.0.snap | 34 ++++++++++ packages/store/ts/protocolVersions.test.ts | 17 +++++ packages/store/ts/protocolVersions.ts | 4 ++ packages/world/gas-report.json | 4 +- packages/world/src/IWorldEvents.sol | 4 +- packages/world/src/IWorldKernel.sol | 4 +- packages/world/src/version.sol | 8 +-- .../world/ts/protocol-snapshots/2.0.0.snap | 67 +++++++++++++++++++ packages/world/ts/protocolVersions.test.ts | 17 +++++ packages/world/ts/protocolVersions.ts | 4 ++ 21 files changed, 192 insertions(+), 43 deletions(-) create mode 100644 .changeset/green-eggs-end.md create mode 100644 packages/store/ts/protocol-snapshots/2.0.0.snap create mode 100644 packages/store/ts/protocolVersions.test.ts create mode 100644 packages/store/ts/protocolVersions.ts create mode 100644 packages/world/ts/protocol-snapshots/2.0.0.snap create mode 100644 packages/world/ts/protocolVersions.test.ts create mode 100644 packages/world/ts/protocolVersions.ts diff --git a/.changeset/green-eggs-end.md b/.changeset/green-eggs-end.md new file mode 100644 index 0000000000..a72504825d --- /dev/null +++ b/.changeset/green-eggs-end.md @@ -0,0 +1,6 @@ +--- +"@latticexyz/store": major +"@latticexyz/world": major +--- + +Set the protocol version to `2.0.0` for each Store and World. diff --git a/docs/pages/store/reference/misc.mdx b/docs/pages/store/reference/misc.mdx index bdc85064bc..953870cc1e 100644 --- a/docs/pages/store/reference/misc.mdx +++ b/docs/pages/store/reference/misc.mdx @@ -2683,10 +2683,10 @@ bytes2 constant RESOURCE_OFFCHAIN_TABLE = "ot"; #### STORE_VERSION -Contains a constant representing the version of the Store. +Contains a constant representing the version of the Store protocol. -_Identifier for the current Store version._ +_Identifier for the current Store protocol version._ ```solidity -bytes32 constant STORE_VERSION = "1.0.0-unaudited"; +bytes32 constant STORE_VERSION = "2.0.0"; ``` diff --git a/docs/pages/store/reference/store-core.mdx b/docs/pages/store/reference/store-core.mdx index f5888d234c..e20a9fe22b 100644 --- a/docs/pages/store/reference/store-core.mdx +++ b/docs/pages/store/reference/store-core.mdx @@ -1041,7 +1041,7 @@ constructor(); #### storeVersion -Retrieves the version of the store. +Retrieves the protocol version of the Store. ```solidity function storeVersion() public pure returns (bytes32); @@ -1049,9 +1049,9 @@ function storeVersion() public pure returns (bytes32); **Returns** -| Name | Type | Description | -| -------- | --------- | ---------------------------------------------- | -| `` | `bytes32` | The current version of the store as a bytes32. | +| Name | Type | Description | +| -------- | --------- | ---------------------------------- | +| `` | `bytes32` | The protocol version of the Store. | ## StoreRead diff --git a/docs/pages/store/reference/store.mdx b/docs/pages/store/reference/store.mdx index f0c3ecb1a7..ba9b118bcf 100644 --- a/docs/pages/store/reference/store.mdx +++ b/docs/pages/store/reference/store.mdx @@ -17,7 +17,7 @@ IStore implements the error interfaces for each library that it uses. #### HelloStore -Emitted when the store is initialized. +Emitted when the Store is created. ```solidity event HelloStore(bytes32 indexed storeVersion); @@ -27,7 +27,7 @@ event HelloStore(bytes32 indexed storeVersion); | Name | Type | Description | | -------------- | --------- | ---------------------------------- | -| `storeVersion` | `bytes32` | The version of the Store contract. | +| `storeVersion` | `bytes32` | The protocol version of the Store. | #### Store_SetRecord diff --git a/docs/pages/world/reference/misc.mdx b/docs/pages/world/reference/misc.mdx index 2fed485aec..6b7adfe3f7 100644 --- a/docs/pages/world/reference/misc.mdx +++ b/docs/pages/world/reference/misc.mdx @@ -99,10 +99,10 @@ function revertWithBytes(bytes memory reason) pure; #### WORLD_VERSION -Contains a constant representing the version of the World. +Contains a constant representing the version of the World protocol. -_Identifier for the current World version._ +_Identifier for the current World protocol version._ ```solidity -bytes32 constant WORLD_VERSION = "1.0.0-unaudited"; +bytes32 constant WORLD_VERSION = "2.0.0"; ``` diff --git a/docs/pages/world/reference/world-external.mdx b/docs/pages/world/reference/world-external.mdx index 0c7caf776b..5e39647f00 100644 --- a/docs/pages/world/reference/world-external.mdx +++ b/docs/pages/world/reference/world-external.mdx @@ -16,7 +16,7 @@ _._ #### storeVersion -Retrieves the version of the store. +Retrieves the protocol version of the Store. ```solidity function storeVersion() public pure returns (bytes32); @@ -24,9 +24,9 @@ function storeVersion() public pure returns (bytes32); **Returns** -| Name | Type | Description | -| -------- | --------- | ---------------------------------------------- | -| `` | `bytes32` | The current version of the store as a bytes32. | +| Name | Type | Description | +| -------- | --------- | ---------------------------------- | +| `` | `bytes32` | The protocol version of the Store. | #### registerTable @@ -718,7 +718,7 @@ so it's ABI should include these errors._ #### worldVersion -Retrieve the version of the World. +Retrieve the protocol version of the World. ```solidity function worldVersion() external view returns (bytes32); @@ -726,9 +726,9 @@ function worldVersion() external view returns (bytes32); **Returns** -| Name | Type | Description | -| -------- | --------- | ------------------------------------ | -| `` | `bytes32` | The version identifier of the World. | +| Name | Type | Description | +| -------- | --------- | ---------------------------------- | +| `` | `bytes32` | The protocol version of the World. | #### creator diff --git a/packages/cli/src/deploy/common.ts b/packages/cli/src/deploy/common.ts index 2fba024595..184083c5d2 100644 --- a/packages/cli/src/deploy/common.ts +++ b/packages/cli/src/deploy/common.ts @@ -21,8 +21,8 @@ export const worldDeployEvents = [helloStoreEvent, helloWorldEvent] as const; export const worldAbi = [...IBaseWorldAbi, ...IModuleAbi] as const; // Ideally, this should be an append-only list. Before adding more versions here, be sure to add backwards-compatible support for old Store/World versions. -export const supportedStoreVersions = ["1.0.0-unaudited"]; -export const supportedWorldVersions = ["1.0.0-unaudited"]; +export const supportedStoreVersions = ["2.0.0"]; +export const supportedWorldVersions = ["2.0.0"]; // TODO: extend this to include factory+deployer address? so we can reuse the deployer for a world? export type WorldDeploy = { diff --git a/packages/cli/src/deploy/logsToWorldDeploy.ts b/packages/cli/src/deploy/logsToWorldDeploy.ts index a6f078766f..7f462605c4 100644 --- a/packages/cli/src/deploy/logsToWorldDeploy.ts +++ b/packages/cli/src/deploy/logsToWorldDeploy.ts @@ -1,4 +1,4 @@ -import { AbiEventSignatureNotFoundError, Log, decodeEventLog, hexToString, parseAbi, trim } from "viem"; +import { AbiEventSignatureNotFoundError, Log, decodeEventLog, hexToString, parseAbi } from "viem"; import { WorldDeploy, worldDeployEvents } from "./common"; import { isDefined } from "@latticexyz/common/utils"; @@ -31,10 +31,10 @@ export function logsToWorldDeploy(logs: readonly Log[]): address: log.address, deployBlock: log.blockNumber, ...(log.eventName === "HelloWorld" - ? { worldVersion: hexToString(trim(log.args.worldVersion, { dir: "right" })) } + ? { worldVersion: hexToString(log.args.worldVersion).replace(/\0+$/, "") } : null), ...(log.eventName === "HelloStore" - ? { storeVersion: hexToString(trim(log.args.storeVersion, { dir: "right" })) } + ? { storeVersion: hexToString(log.args.storeVersion).replace(/\0+$/, "") } : null), }), {}, diff --git a/packages/store/src/IStoreEvents.sol b/packages/store/src/IStoreEvents.sol index 63a93aac87..489441691b 100644 --- a/packages/store/src/IStoreEvents.sol +++ b/packages/store/src/IStoreEvents.sol @@ -10,8 +10,8 @@ import { PackedCounter } from "./PackedCounter.sol"; */ interface IStoreEvents { /** - * @notice Emitted when the store is initialized. - * @param storeVersion The version of the Store contract. + * @notice Emitted when the Store is created. + * @param storeVersion The protocol version of the Store. */ event HelloStore(bytes32 indexed storeVersion); diff --git a/packages/store/src/StoreData.sol b/packages/store/src/StoreData.sol index c963bf4623..e2002563b4 100644 --- a/packages/store/src/StoreData.sol +++ b/packages/store/src/StoreData.sol @@ -25,8 +25,8 @@ abstract contract StoreData is IStoreData, StoreRead { } /** - * @notice Retrieves the version of the store. - * @return The current version of the store as a bytes32. + * @notice Retrieves the protocol version of the Store. + * @return The protocol version of the Store. */ function storeVersion() public pure returns (bytes32) { return STORE_VERSION; diff --git a/packages/store/src/version.sol b/packages/store/src/version.sol index 279871337e..c124e9f542 100644 --- a/packages/store/src/version.sol +++ b/packages/store/src/version.sol @@ -2,10 +2,10 @@ pragma solidity >=0.8.24; /** - * @title Store version + * @title Store protocol version * @author MUD (https://mud.dev) by Lattice (https://lattice.xyz) - * @notice Contains a constant representing the version of the Store. + * @notice Contains a constant representing the version of the Store protocol. */ -/// @dev Identifier for the current Store version. -bytes32 constant STORE_VERSION = "1.0.0-unaudited"; +/// @dev Identifier for the current Store protocol version. +bytes32 constant STORE_VERSION = "2.0.0"; diff --git a/packages/store/ts/protocol-snapshots/2.0.0.snap b/packages/store/ts/protocol-snapshots/2.0.0.snap new file mode 100644 index 0000000000..c8092e625b --- /dev/null +++ b/packages/store/ts/protocol-snapshots/2.0.0.snap @@ -0,0 +1,34 @@ +[ + "error Store_IndexOutOfBounds(uint256 length, uint256 accessedIndex)", + "error Store_InvalidBounds(uint256 start, uint256 end)", + "error Store_TableNotFound(bytes32 tableId, string tableIdString)", + "event HelloStore(bytes32 indexed storeVersion)", + "event Store_DeleteRecord(bytes32 indexed tableId, bytes32[] keyTuple)", + "event Store_SetRecord(bytes32 indexed tableId, bytes32[] keyTuple, bytes staticData, bytes32 encodedLengths, bytes dynamicData)", + "event Store_SpliceDynamicData(bytes32 indexed tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex, uint48 start, uint40 deleteCount, bytes32 encodedLengths, bytes data)", + "event Store_SpliceStaticData(bytes32 indexed tableId, bytes32[] keyTuple, uint48 start, bytes data)", + "function deleteRecord(bytes32 tableId, bytes32[] keyTuple)", + "function getDynamicField(bytes32 tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex) view returns (bytes data)", + "function getDynamicFieldLength(bytes32 tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex) view returns (uint256)", + "function getDynamicFieldSlice(bytes32 tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex, uint256 start, uint256 end) view returns (bytes)", + "function getField(bytes32 tableId, bytes32[] keyTuple, uint8 fieldIndex, bytes32 fieldLayout) view returns (bytes data)", + "function getField(bytes32 tableId, bytes32[] keyTuple, uint8 fieldIndex) view returns (bytes data)", + "function getFieldLayout(bytes32 tableId) view returns (bytes32 fieldLayout)", + "function getFieldLength(bytes32 tableId, bytes32[] keyTuple, uint8 fieldIndex, bytes32 fieldLayout) view returns (uint256)", + "function getFieldLength(bytes32 tableId, bytes32[] keyTuple, uint8 fieldIndex) view returns (uint256)", + "function getKeySchema(bytes32 tableId) view returns (bytes32 keySchema)", + "function getRecord(bytes32 tableId, bytes32[] keyTuple, bytes32 fieldLayout) view returns (bytes staticData, bytes32 encodedLengths, bytes dynamicData)", + "function getRecord(bytes32 tableId, bytes32[] keyTuple) view returns (bytes staticData, bytes32 encodedLengths, bytes dynamicData)", + "function getStaticField(bytes32 tableId, bytes32[] keyTuple, uint8 fieldIndex, bytes32 fieldLayout) view returns (bytes32 data)", + "function getValueSchema(bytes32 tableId) view returns (bytes32 valueSchema)", + "function popFromDynamicField(bytes32 tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex, uint256 byteLengthToPop)", + "function pushToDynamicField(bytes32 tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex, bytes dataToPush)", + "function setDynamicField(bytes32 tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex, bytes data)", + "function setField(bytes32 tableId, bytes32[] keyTuple, uint8 fieldIndex, bytes data, bytes32 fieldLayout)", + "function setField(bytes32 tableId, bytes32[] keyTuple, uint8 fieldIndex, bytes data)", + "function setRecord(bytes32 tableId, bytes32[] keyTuple, bytes staticData, bytes32 encodedLengths, bytes dynamicData)", + "function setStaticField(bytes32 tableId, bytes32[] keyTuple, uint8 fieldIndex, bytes data, bytes32 fieldLayout)", + "function spliceDynamicData(bytes32 tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex, uint40 startWithinField, uint40 deleteCount, bytes data)", + "function spliceStaticData(bytes32 tableId, bytes32[] keyTuple, uint48 start, bytes data)", + "function storeVersion() pure returns (bytes32)", +] \ No newline at end of file diff --git a/packages/store/ts/protocolVersions.test.ts b/packages/store/ts/protocolVersions.test.ts new file mode 100644 index 0000000000..dbf3648785 --- /dev/null +++ b/packages/store/ts/protocolVersions.test.ts @@ -0,0 +1,17 @@ +import { describe, expect, it } from "vitest"; +import fs from "node:fs"; +import StoreAbi from "../out/StoreData.sol/StoreData.abi.json"; +import { formatAbi } from "abitype"; +import { protocolVersions } from "./protocolVersions"; + +const [, currentVersion] = fs.readFileSync(`${__dirname}/../src/version.sol`, "utf8").match(/VERSION = "(.*?)"/) ?? []; + +const currentAbi = formatAbi(StoreAbi).sort((a, b) => a.localeCompare(b)); + +describe("Store protocol version", () => { + it("is up to date", async () => { + expect(currentVersion).toMatch(/^\d+\.\d+\.\d+$/); + expect(protocolVersions).toHaveProperty(currentVersion); + await expect(currentAbi).toMatchFileSnapshot(`${__dirname}/protocol-snapshots/${currentVersion}.snap`); + }); +}); diff --git a/packages/store/ts/protocolVersions.ts b/packages/store/ts/protocolVersions.ts new file mode 100644 index 0000000000..5fcdce84b4 --- /dev/null +++ b/packages/store/ts/protocolVersions.ts @@ -0,0 +1,4 @@ +// History of protocol versions and a short description of what changed in each. +export const protocolVersions = { + "2.0.0": "Initial v2 release. See mud.dev/changelog for the full list of changes from v1.", +}; diff --git a/packages/world/gas-report.json b/packages/world/gas-report.json index 0955954567..dfc6b5ab43 100644 --- a/packages/world/gas-report.json +++ b/packages/world/gas-report.json @@ -57,13 +57,13 @@ "file": "test/Factories.t.sol", "test": "testCreate2Factory", "name": "deploy contract via Create2", - "gasUsed": 4965450 + "gasUsed": 4960875 }, { "file": "test/Factories.t.sol", "test": "testWorldFactoryGas", "name": "deploy world via WorldFactory", - "gasUsed": 12796228 + "gasUsed": 12796213 }, { "file": "test/World.t.sol", diff --git a/packages/world/src/IWorldEvents.sol b/packages/world/src/IWorldEvents.sol index 2e5d0c7fec..03fa598f11 100644 --- a/packages/world/src/IWorldEvents.sol +++ b/packages/world/src/IWorldEvents.sol @@ -13,8 +13,8 @@ import { ResourceId } from "./WorldResourceId.sol"; */ interface IWorldEvents { /** - * @dev Emitted upon successful World initialization. - * @param worldVersion The version of the World being initialized. + * @notice Emitted when the World is created. + * @param worldVersion The protocol version of the World. */ event HelloWorld(bytes32 indexed worldVersion); } diff --git a/packages/world/src/IWorldKernel.sol b/packages/world/src/IWorldKernel.sol index 63b64d7470..492a5ef365 100644 --- a/packages/world/src/IWorldKernel.sol +++ b/packages/world/src/IWorldKernel.sol @@ -65,8 +65,8 @@ interface IWorldCall { */ interface IWorldKernel is IWorldModuleInstallation, IWorldCall, IWorldErrors, IWorldEvents, IModuleErrors { /** - * @notice Retrieve the version of the World. - * @return The version identifier of the World. + * @notice Retrieve the protocol version of the World. + * @return The protocol version of the World. */ function worldVersion() external view returns (bytes32); diff --git a/packages/world/src/version.sol b/packages/world/src/version.sol index 44dfc1f624..1882e51272 100644 --- a/packages/world/src/version.sol +++ b/packages/world/src/version.sol @@ -2,10 +2,10 @@ pragma solidity >=0.8.24; /** - * @title World version + * @title World protocol version * @author MUD (https://mud.dev) by Lattice (https://lattice.xyz) - * @notice Contains a constant representing the version of the World. + * @notice Contains a constant representing the version of the World protocol. */ -/// @dev Identifier for the current World version. -bytes32 constant WORLD_VERSION = "1.0.0-unaudited"; +/// @dev Identifier for the current World protocol version. +bytes32 constant WORLD_VERSION = "2.0.0"; diff --git a/packages/world/ts/protocol-snapshots/2.0.0.snap b/packages/world/ts/protocol-snapshots/2.0.0.snap new file mode 100644 index 0000000000..4ee517930f --- /dev/null +++ b/packages/world/ts/protocol-snapshots/2.0.0.snap @@ -0,0 +1,67 @@ +[ + "constructor()", + "error Module_AlreadyInstalled()", + "error Module_MissingDependency(address dependency)", + "error Module_NonRootInstallNotSupported()", + "error Module_RootInstallNotSupported()", + "error PackedCounter_InvalidLength(uint256 length)", + "error Slice_OutOfBounds(bytes data, uint256 start, uint256 end)", + "error Store_IndexOutOfBounds(uint256 length, uint256 accessedIndex)", + "error Store_InvalidBounds(uint256 start, uint256 end)", + "error Store_InvalidResourceType(bytes2 expected, bytes32 resourceId, string resourceIdString)", + "error Store_InvalidSplice(uint40 startWithinField, uint40 deleteCount, uint40 fieldLength)", + "error Store_TableNotFound(bytes32 tableId, string tableIdString)", + "error World_AccessDenied(string resource, address caller)", + "error World_AlreadyInitialized()", + "error World_CallbackNotAllowed(bytes4 functionSelector)", + "error World_DelegationNotFound(address delegator, address delegatee)", + "error World_FunctionSelectorAlreadyExists(bytes4 functionSelector)", + "error World_FunctionSelectorNotFound(bytes4 functionSelector)", + "error World_InsufficientBalance(uint256 balance, uint256 amount)", + "error World_InterfaceNotSupported(address contractAddress, bytes4 interfaceId)", + "error World_InvalidNamespace(bytes14 namespace)", + "error World_InvalidResourceId(bytes32 resourceId, string resourceIdString)", + "error World_InvalidResourceType(bytes2 expected, bytes32 resourceId, string resourceIdString)", + "error World_ResourceAlreadyExists(bytes32 resourceId, string resourceIdString)", + "error World_ResourceNotFound(bytes32 resourceId, string resourceIdString)", + "error World_SystemAlreadyExists(address system)", + "error World_UnlimitedDelegationNotAllowed()", + "event HelloStore(bytes32 indexed storeVersion)", + "event HelloWorld(bytes32 indexed worldVersion)", + "event Store_DeleteRecord(bytes32 indexed tableId, bytes32[] keyTuple)", + "event Store_SetRecord(bytes32 indexed tableId, bytes32[] keyTuple, bytes staticData, bytes32 encodedLengths, bytes dynamicData)", + "event Store_SpliceDynamicData(bytes32 indexed tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex, uint48 start, uint40 deleteCount, bytes32 encodedLengths, bytes data)", + "event Store_SpliceStaticData(bytes32 indexed tableId, bytes32[] keyTuple, uint48 start, bytes data)", + "fallback()", + "function call(bytes32 systemId, bytes callData) payable returns (bytes)", + "function callFrom(address delegator, bytes32 systemId, bytes callData) payable returns (bytes)", + "function creator() view returns (address)", + "function deleteRecord(bytes32 tableId, bytes32[] keyTuple)", + "function getDynamicField(bytes32 tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex) view returns (bytes data)", + "function getDynamicFieldLength(bytes32 tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex) view returns (uint256)", + "function getDynamicFieldSlice(bytes32 tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex, uint256 start, uint256 end) view returns (bytes)", + "function getField(bytes32 tableId, bytes32[] keyTuple, uint8 fieldIndex, bytes32 fieldLayout) view returns (bytes data)", + "function getField(bytes32 tableId, bytes32[] keyTuple, uint8 fieldIndex) view returns (bytes data)", + "function getFieldLayout(bytes32 tableId) view returns (bytes32 fieldLayout)", + "function getFieldLength(bytes32 tableId, bytes32[] keyTuple, uint8 fieldIndex, bytes32 fieldLayout) view returns (uint256)", + "function getFieldLength(bytes32 tableId, bytes32[] keyTuple, uint8 fieldIndex) view returns (uint256)", + "function getKeySchema(bytes32 tableId) view returns (bytes32 keySchema)", + "function getRecord(bytes32 tableId, bytes32[] keyTuple, bytes32 fieldLayout) view returns (bytes staticData, bytes32 encodedLengths, bytes dynamicData)", + "function getRecord(bytes32 tableId, bytes32[] keyTuple) view returns (bytes staticData, bytes32 encodedLengths, bytes dynamicData)", + "function getStaticField(bytes32 tableId, bytes32[] keyTuple, uint8 fieldIndex, bytes32 fieldLayout) view returns (bytes32 data)", + "function getValueSchema(bytes32 tableId) view returns (bytes32 valueSchema)", + "function initialize(address initModule)", + "function installRootModule(address module, bytes encodedArgs)", + "function popFromDynamicField(bytes32 tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex, uint256 byteLengthToPop)", + "function pushToDynamicField(bytes32 tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex, bytes dataToPush)", + "function setDynamicField(bytes32 tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex, bytes data)", + "function setField(bytes32 tableId, bytes32[] keyTuple, uint8 fieldIndex, bytes data, bytes32 fieldLayout)", + "function setField(bytes32 tableId, bytes32[] keyTuple, uint8 fieldIndex, bytes data)", + "function setRecord(bytes32 tableId, bytes32[] keyTuple, bytes staticData, bytes32 encodedLengths, bytes dynamicData)", + "function setStaticField(bytes32 tableId, bytes32[] keyTuple, uint8 fieldIndex, bytes data, bytes32 fieldLayout)", + "function spliceDynamicData(bytes32 tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex, uint40 startWithinField, uint40 deleteCount, bytes data)", + "function spliceStaticData(bytes32 tableId, bytes32[] keyTuple, uint48 start, bytes data)", + "function storeVersion() pure returns (bytes32)", + "function worldVersion() pure returns (bytes32)", + "receive() external payable", +] \ No newline at end of file diff --git a/packages/world/ts/protocolVersions.test.ts b/packages/world/ts/protocolVersions.test.ts new file mode 100644 index 0000000000..cefd591e94 --- /dev/null +++ b/packages/world/ts/protocolVersions.test.ts @@ -0,0 +1,17 @@ +import { describe, expect, it } from "vitest"; +import fs from "node:fs"; +import WorldAbi from "../out/World.sol/World.abi.json"; +import { formatAbi } from "abitype"; +import { protocolVersions } from "./protocolVersions"; + +const [, currentVersion] = fs.readFileSync(`${__dirname}/../src/version.sol`, "utf8").match(/VERSION = "(.*?)"/) ?? []; + +const currentAbi = formatAbi(WorldAbi).sort((a, b) => a.localeCompare(b)); + +describe("World protocol version", () => { + it("is up to date", async () => { + expect(currentVersion).toMatch(/^\d+\.\d+\.\d+$/); + expect(protocolVersions).toHaveProperty(currentVersion); + await expect(currentAbi).toMatchFileSnapshot(`${__dirname}/protocol-snapshots/${currentVersion}.snap`); + }); +}); diff --git a/packages/world/ts/protocolVersions.ts b/packages/world/ts/protocolVersions.ts new file mode 100644 index 0000000000..5fcdce84b4 --- /dev/null +++ b/packages/world/ts/protocolVersions.ts @@ -0,0 +1,4 @@ +// History of protocol versions and a short description of what changed in each. +export const protocolVersions = { + "2.0.0": "Initial v2 release. See mud.dev/changelog for the full list of changes from v1.", +};