-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(store,world): set protocol version, add tests (#2412)
- Loading branch information
Showing
21 changed files
with
192 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@latticexyz/store": major | ||
"@latticexyz/world": major | ||
--- | ||
|
||
Set the protocol version to `2.0.0` for each Store and World. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.", | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.", | ||
}; |