From c58da9adc6c67bc410fdc1c72f21cb1af8bdb50f Mon Sep 17 00:00:00 2001 From: yonada Date: Mon, 4 Mar 2024 11:38:12 +0000 Subject: [PATCH] refactor(store): hellostore in IStoreEvents (#2357) --- .changeset/spicy-waves-wait.md | 5 +++++ docs/pages/store/reference/store.mdx | 30 +++++++++++++--------------- packages/store/src/IStoreData.sol | 6 ------ packages/store/src/IStoreEvents.sol | 6 ++++++ packages/store/src/StoreData.sol | 3 ++- packages/store/test/StoreMock.t.sol | 5 ++--- 6 files changed, 29 insertions(+), 26 deletions(-) create mode 100644 .changeset/spicy-waves-wait.md diff --git a/.changeset/spicy-waves-wait.md b/.changeset/spicy-waves-wait.md new file mode 100644 index 0000000000..9c070fdd64 --- /dev/null +++ b/.changeset/spicy-waves-wait.md @@ -0,0 +1,5 @@ +--- +"@latticexyz/store": patch +--- + +Moved the `HelloStore` to `IStoreEvents` so all Store events are defined in the same interface. diff --git a/docs/pages/store/reference/store.mdx b/docs/pages/store/reference/store.mdx index 5cb36a4cb7..4106a722f0 100644 --- a/docs/pages/store/reference/store.mdx +++ b/docs/pages/store/reference/store.mdx @@ -15,6 +15,20 @@ IStore implements the error interfaces for each library that it uses. ### Events +#### HelloStore + +Emitted when the store is initialized. + +```solidity +event HelloStore(bytes32 indexed storeVersion); +``` + +**Parameters** + +| Name | Type | Description | +| -------------- | --------- | ---------------------------------- | +| `storeVersion` | `bytes32` | The version of the Store contract. | + #### Store_SetRecord Emitted when a new record is set in the store. @@ -212,22 +226,6 @@ function storeVersion() external view returns (bytes32 version); | --------- | --------- | ---------------------------------- | | `version` | `bytes32` | The version of the Store contract. | -### Events - -#### HelloStore - -Emitted when the store is initialized. - -```solidity -event HelloStore(bytes32 indexed storeVersion); -``` - -**Parameters** - -| Name | Type | Description | -| -------------- | --------- | ---------------------------------- | -| `storeVersion` | `bytes32` | The version of the Store contract. | - ## IStoreRead [Git Source](https://github.com/latticexyz/mud/blob/main/packages/store/src/IStoreRead.sol) diff --git a/packages/store/src/IStoreData.sol b/packages/store/src/IStoreData.sol index 3e488002a4..95059765df 100644 --- a/packages/store/src/IStoreData.sol +++ b/packages/store/src/IStoreData.sol @@ -11,12 +11,6 @@ import { IStoreWrite } from "./IStoreWrite.sol"; * @dev These methods are frequently invoked during runtime, so it is essential to prioritize optimizing their gas cost. */ interface IStoreData is IStoreRead, IStoreWrite { - /** - * @notice Emitted when the store is initialized. - * @param storeVersion The version of the Store contract. - */ - event HelloStore(bytes32 indexed storeVersion); - /** * @notice Returns the version of the Store contract. * @return version The version of the Store contract. diff --git a/packages/store/src/IStoreEvents.sol b/packages/store/src/IStoreEvents.sol index 5b0d813d97..63a93aac87 100644 --- a/packages/store/src/IStoreEvents.sol +++ b/packages/store/src/IStoreEvents.sol @@ -9,6 +9,12 @@ import { PackedCounter } from "./PackedCounter.sol"; * @author MUD (https://mud.dev) by Lattice (https://lattice.xyz) */ interface IStoreEvents { + /** + * @notice Emitted when the store is initialized. + * @param storeVersion The version of the Store contract. + */ + event HelloStore(bytes32 indexed storeVersion); + /** * @notice Emitted when a new record is set in the store. * @param tableId The ID of the table where the record is set. diff --git a/packages/store/src/StoreData.sol b/packages/store/src/StoreData.sol index 278c1da2cb..c963bf4623 100644 --- a/packages/store/src/StoreData.sol +++ b/packages/store/src/StoreData.sol @@ -5,6 +5,7 @@ import { STORE_VERSION } from "./version.sol"; import { IStoreData } from "./IStoreData.sol"; import { StoreRead } from "./StoreRead.sol"; import { StoreCore } from "./StoreCore.sol"; +import { IStoreEvents } from "./IStoreEvents.sol"; /** * @title Store Data Contract @@ -20,7 +21,7 @@ abstract contract StoreData is IStoreData, StoreRead { */ constructor() { StoreCore.initialize(); - emit HelloStore(STORE_VERSION); + emit IStoreEvents.HelloStore(STORE_VERSION); } /** diff --git a/packages/store/test/StoreMock.t.sol b/packages/store/test/StoreMock.t.sol index b4e7be586a..3aa1191288 100644 --- a/packages/store/test/StoreMock.t.sol +++ b/packages/store/test/StoreMock.t.sol @@ -7,13 +7,12 @@ import { STORE_VERSION } from "../src/version.sol"; import { StoreCore } from "../src/StoreCore.sol"; import { StoreMock } from "../test/StoreMock.sol"; import { StoreSwitch } from "../src/StoreSwitch.sol"; +import { IStoreEvents } from "../src/IStoreEvents.sol"; contract StoreMockTest is Test { - event HelloStore(bytes32 indexed storeVersion); - function testStoreMockConstrctor() public { vm.expectEmit(true, true, true, true); - emit HelloStore(STORE_VERSION); + emit IStoreEvents.HelloStore(STORE_VERSION); new StoreMock(); } }