Skip to content

Commit

Permalink
refactor(store): hellostore in IStoreEvents (#2357)
Browse files Browse the repository at this point in the history
  • Loading branch information
yonadaaa authored Mar 4, 2024
1 parent 2c920de commit c58da9a
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 26 deletions.
5 changes: 5 additions & 0 deletions .changeset/spicy-waves-wait.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@latticexyz/store": patch
---

Moved the `HelloStore` to `IStoreEvents` so all Store events are defined in the same interface.
30 changes: 14 additions & 16 deletions docs/pages/store/reference/store.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 0 additions & 6 deletions packages/store/src/IStoreData.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions packages/store/src/IStoreEvents.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion packages/store/src/StoreData.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -20,7 +21,7 @@ abstract contract StoreData is IStoreData, StoreRead {
*/
constructor() {
StoreCore.initialize();
emit HelloStore(STORE_VERSION);
emit IStoreEvents.HelloStore(STORE_VERSION);
}

/**
Expand Down
5 changes: 2 additions & 3 deletions packages/store/test/StoreMock.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

0 comments on commit c58da9a

Please sign in to comment.