diff --git a/.changeset/dull-otters-smash.md b/.changeset/dull-otters-smash.md
new file mode 100644
index 0000000000..d53d909197
--- /dev/null
+++ b/.changeset/dull-otters-smash.md
@@ -0,0 +1,5 @@
+---
+"@latticexyz/world-modules": patch
+---
+
+ERC20 and ERC721 implementations now always register the token namespace, instead of checking if it has already been registered. This prevents issues with registering the namespace beforehand, namely that only the owner of a system can create a puppet for it.
diff --git a/.changeset/famous-feet-suffer.md b/.changeset/famous-feet-suffer.md
new file mode 100644
index 0000000000..e42174b4d9
--- /dev/null
+++ b/.changeset/famous-feet-suffer.md
@@ -0,0 +1,5 @@
+---
+"@latticexyz/store": patch
+---
+
+Refactored `StoreCore` to import `IStoreEvents` instead of defining the events twice.
diff --git a/.changeset/few-berries-tickle.md b/.changeset/few-berries-tickle.md
new file mode 100644
index 0000000000..dcbf3602a1
--- /dev/null
+++ b/.changeset/few-berries-tickle.md
@@ -0,0 +1,21 @@
+---
+"create-mud": patch
+"@latticexyz/cli": major
+"@latticexyz/common": major
+"@latticexyz/store": patch
+"@latticexyz/world": patch
+"@latticexyz/world-modules": patch
+---
+
+Moved table ID and field layout constants in code-generated table libraries from the file level into the library, for clearer access and cleaner imports.
+
+```diff
+-import { SomeTable, SomeTableTableId } from "./codegen/tables/SomeTable.sol";
++import { SomeTable } from "./codegen/tables/SomeTable.sol";
+
+-console.log(SomeTableTableId);
++console.log(SomeTable._tableId);
+
+-console.log(SomeTable.getFieldLayout());
++console.log(SomeTable._fieldLayout);
+```
diff --git a/.changeset/heavy-shirts-dance.md b/.changeset/heavy-shirts-dance.md
new file mode 100644
index 0000000000..6317deb7f4
--- /dev/null
+++ b/.changeset/heavy-shirts-dance.md
@@ -0,0 +1,5 @@
+---
+"@latticexyz/store": patch
+---
+
+Added interfaces for all errors that are used by `StoreCore`, which includes `FieldLayout`, `PackedCounter`, `Schema`, and `Slice`. This interfaces are inherited by `IStore`, ensuring that all possible errors are included in the `IStore` ABI for proper decoding in the frontend.
diff --git a/.changeset/loud-rockets-switch.md b/.changeset/loud-rockets-switch.md
new file mode 100644
index 0000000000..2e80de7d69
--- /dev/null
+++ b/.changeset/loud-rockets-switch.md
@@ -0,0 +1,5 @@
+---
+"@latticexyz/common": patch
+---
+
+Upgraded prettier version to 3.2.5 and prettier-plugin-solidity version to 1.3.1.
diff --git a/.changeset/moody-shirts-carry.md b/.changeset/moody-shirts-carry.md
new file mode 100644
index 0000000000..c6f1943f1b
--- /dev/null
+++ b/.changeset/moody-shirts-carry.md
@@ -0,0 +1,25 @@
+---
+"@latticexyz/common": minor
+"create-mud": minor
+---
+
+Added viem custom client actions that work the same as MUD's now-deprecated `getContract`, `writeContract`, and `sendTransaction` wrappers. Templates have been updated to reflect the new patterns.
+
+You can migrate your own code like this:
+
+```diff
+-import { createWalletClient } from "viem";
+-import { getContract, writeContract, sendTransaction } from "@latticexyz/common";
++import { createWalletClient, getContract } from "viem";
++import { transactionQueue, writeObserver } from "@latticexyz/common/actions";
+
+-const walletClient = createWalletClient(...);
++const walletClient = createWalletClient(...)
++ .extend(transactionQueue())
++ .extend(writeObserver({ onWrite });
+
+ const worldContract = getContract({
+ client: { publicClient, walletClient },
+- onWrite,
+ });
+```
diff --git a/.changeset/nasty-waves-divide.md b/.changeset/nasty-waves-divide.md
index f85dd96047..61ac31054c 100644
--- a/.changeset/nasty-waves-divide.md
+++ b/.changeset/nasty-waves-divide.md
@@ -22,7 +22,7 @@ const latestBlock$ = await createBlockStream({ publicClient, blockTag: "latest"
const latestBlockNumber$ = latestBlock$.pipe(
filter(isNonPendingBlock),
- map((block) => block.number)
+ map((block) => block.number),
);
latestBlockNumber$
@@ -38,7 +38,7 @@ latestBlockNumber$
"event StoreEphemeralRecord(bytes32 table, bytes32[] key, bytes data)",
]),
}),
- mergeMap(({ logs }) => from(groupLogsByBlockNumber(logs)))
+ mergeMap(({ logs }) => from(groupLogsByBlockNumber(logs))),
)
.subscribe((block) => {
console.log("got events for block", block);
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/.changeset/tame-lemons-play.md b/.changeset/tame-lemons-play.md
index e20f0bcd55..17de0f9339 100644
--- a/.changeset/tame-lemons-play.md
+++ b/.changeset/tame-lemons-play.md
@@ -172,7 +172,7 @@ As you migrate, you may find some features replaced, removed, or not included by
.pipe(
map((block) => Number(block.timestamp) * 1000), // Map to timestamp in ms
filter((blockTimestamp) => blockTimestamp !== clock.lastUpdateTime), // Ignore if the clock was already refreshed with this block
- filter((blockTimestamp) => blockTimestamp !== clock.currentTime) // Ignore if the current local timestamp is correct
+ filter((blockTimestamp) => blockTimestamp !== clock.currentTime), // Ignore if the current local timestamp is correct
)
.subscribe(clock.update); // Update the local clock
```
diff --git a/.changeset/tough-pumpkins-reply.md b/.changeset/tough-pumpkins-reply.md
new file mode 100644
index 0000000000..559c3ef6d5
--- /dev/null
+++ b/.changeset/tough-pumpkins-reply.md
@@ -0,0 +1,16 @@
+---
+"create-mud": patch
+"@latticexyz/store": minor
+"@latticexyz/world": minor
+"@latticexyz/world-modules": minor
+---
+
+Moved key schema and value schema methods to constants in code-generated table libraries for less bytecode and less gas in register/install methods.
+
+```diff
+-console.log(SomeTable.getKeySchema());
++console.log(SomeTable._keySchema);
+
+-console.log(SomeTable.getValueSchema());
++console.log(SomeTable._valueSchema);
+```
diff --git a/.github/workflows/test-published-packages.yml b/.github/workflows/test-published-packages.yml
index e9358fd8bf..d72a6162f5 100644
--- a/.github/workflows/test-published-packages.yml
+++ b/.github/workflows/test-published-packages.yml
@@ -15,12 +15,13 @@ on:
jobs:
test-create-mud-project:
name: Test create-mud project
- runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
+ os: [ubuntu-latest-16-cores, windows-latest]
template: [vanilla, react, react-ecs, phaser, threejs]
+ runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
with:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9e3efbf55d..12d6a624bf 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3395,7 +3395,7 @@ As you migrate, you may find some features replaced, removed, or not included by
.pipe(
map((block) => Number(block.timestamp) * 1000), // Map to timestamp in ms
filter((blockTimestamp) => blockTimestamp !== clock.lastUpdateTime), // Ignore if the clock was already refreshed with this block
- filter((blockTimestamp) => blockTimestamp !== clock.currentTime) // Ignore if the current local timestamp is correct
+ filter((blockTimestamp) => blockTimestamp !== clock.currentTime), // Ignore if the current local timestamp is correct
)
.subscribe(clock.update); // Update the local clock
```
@@ -3633,7 +3633,7 @@ const latestBlock$ = await createBlockStream({ publicClient, blockTag: "latest"
const latestBlockNumber$ = latestBlock$.pipe(
filter(isNonPendingBlock),
- map((block) => block.number)
+ map((block) => block.number),
);
latestBlockNumber$
@@ -3649,7 +3649,7 @@ latestBlockNumber$
"event StoreEphemeralRecord(bytes32 table, bytes32[] key, bytes data)",
]),
}),
- mergeMap(({ logs }) => from(groupLogsByBlockNumber(logs)))
+ mergeMap(({ logs }) => from(groupLogsByBlockNumber(logs))),
)
.subscribe((block) => {
console.log("got events for block", block);
diff --git a/docs/app/page.tsx b/docs/app/page.tsx
index 7a954b39d5..bbb7c29d8c 100644
--- a/docs/app/page.tsx
+++ b/docs/app/page.tsx
@@ -24,7 +24,7 @@ export default async function HomePage() {
"min-h-screen flex flex-col animate-in animate-duration-500 fade-in",
"gap-12 p-8",
"sm:justify-between",
- "md:gap-16 md:p-16"
+ "md:gap-16 md:p-16",
)}
>
diff --git a/docs/components/MUDTable.module.css b/docs/components/MUDTable.module.css
index becc677b84..97b6223686 100644
--- a/docs/components/MUDTable.module.css
+++ b/docs/components/MUDTable.module.css
@@ -1,5 +1,13 @@
.table {
- font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, Courier New, monospace;
+ font-family:
+ ui-monospace,
+ SFMono-Regular,
+ Menlo,
+ Monaco,
+ Consolas,
+ Liberation Mono,
+ Courier New,
+ monospace;
background-color: hsl(var(--nextra-primary-hue) 100% 66%/0.1);
margin-top: 1em;
text-align: center;
diff --git a/docs/pages/changelog.mdx b/docs/pages/changelog.mdx
index 9e3efbf55d..12d6a624bf 100644
--- a/docs/pages/changelog.mdx
+++ b/docs/pages/changelog.mdx
@@ -3395,7 +3395,7 @@ As you migrate, you may find some features replaced, removed, or not included by
.pipe(
map((block) => Number(block.timestamp) * 1000), // Map to timestamp in ms
filter((blockTimestamp) => blockTimestamp !== clock.lastUpdateTime), // Ignore if the clock was already refreshed with this block
- filter((blockTimestamp) => blockTimestamp !== clock.currentTime) // Ignore if the current local timestamp is correct
+ filter((blockTimestamp) => blockTimestamp !== clock.currentTime), // Ignore if the current local timestamp is correct
)
.subscribe(clock.update); // Update the local clock
```
@@ -3633,7 +3633,7 @@ const latestBlock$ = await createBlockStream({ publicClient, blockTag: "latest"
const latestBlockNumber$ = latestBlock$.pipe(
filter(isNonPendingBlock),
- map((block) => block.number)
+ map((block) => block.number),
);
latestBlockNumber$
@@ -3649,7 +3649,7 @@ latestBlockNumber$
"event StoreEphemeralRecord(bytes32 table, bytes32[] key, bytes data)",
]),
}),
- mergeMap(({ logs }) => from(groupLogsByBlockNumber(logs)))
+ mergeMap(({ logs }) => from(groupLogsByBlockNumber(logs))),
)
.subscribe((block) => {
console.log("got events for block", block);
diff --git a/docs/pages/guides/emojimon/3-players-and-movement.mdx b/docs/pages/guides/emojimon/3-players-and-movement.mdx
index d5eac88e95..cefe114200 100644
--- a/docs/pages/guides/emojimon/3-players-and-movement.mdx
+++ b/docs/pages/guides/emojimon/3-players-and-movement.mdx
@@ -255,7 +255,7 @@ export type SystemCalls = ReturnType
;
export function createSystemCalls(
{ playerEntity, worldContract, waitForTransaction }: SetupNetworkResult,
- { Player, Position }: ClientComponents
+ { Player, Position }: ClientComponents,
) {
const moveBy = async (deltaX: number, deltaY: number) => {
if (!playerEntity) {
diff --git a/docs/pages/guides/emojimon/4-map-and-terrain.mdx b/docs/pages/guides/emojimon/4-map-and-terrain.mdx
index 4e81e1584d..bbbc842494 100644
--- a/docs/pages/guides/emojimon/4-map-and-terrain.mdx
+++ b/docs/pages/guides/emojimon/4-map-and-terrain.mdx
@@ -445,7 +445,7 @@ export type SystemCalls = ReturnType;
export function createSystemCalls(
{ playerEntity, worldContract, waitForTransaction }: SetupNetworkResult,
- { MapConfig, Obstruction, Player, Position }: ClientComponents
+ { MapConfig, Obstruction, Player, Position }: ClientComponents,
) {
const isObstructed = (x: number, y: number) => {
return runQuery([Has(Obstruction), HasValue(Position, { x, y })]).size > 0;
diff --git a/docs/pages/guides/emojimon/5-a-wild-emojimon-appears.mdx b/docs/pages/guides/emojimon/5-a-wild-emojimon-appears.mdx
index 7392e1f57e..b7522d7304 100644
--- a/docs/pages/guides/emojimon/5-a-wild-emojimon-appears.mdx
+++ b/docs/pages/guides/emojimon/5-a-wild-emojimon-appears.mdx
@@ -718,7 +718,7 @@ export type SystemCalls = ReturnType;
export function createSystemCalls(
{ playerEntity, worldContract, waitForTransaction }: SetupNetworkResult,
- { Encounter, MapConfig, MonsterCatchAttempt, Obstruction, Player, Position }: ClientComponents
+ { Encounter, MapConfig, MonsterCatchAttempt, Obstruction, Player, Position }: ClientComponents,
) {
const wrapPosition = (x: number, y: number) => {
const mapConfig = getComponentValue(MapConfig, singletonEntity);
@@ -890,7 +890,7 @@ export type SystemCalls = ReturnType;
export function createSystemCalls(
{ playerEntity, worldContract, waitForTransaction }: SetupNetworkResult,
- { Encounter, MapConfig, MonsterCatchAttempt, Obstruction, Player, Position }: ClientComponents
+ { Encounter, MapConfig, MonsterCatchAttempt, Obstruction, Player, Position }: ClientComponents,
) {
const wrapPosition = (x: number, y: number) => {
const mapConfig = getComponentValue(MapConfig, singletonEntity);
diff --git a/docs/pages/guides/hello-world/add-table.mdx b/docs/pages/guides/hello-world/add-table.mdx
index 0673138767..b1fa6dc4d6 100644
--- a/docs/pages/guides/hello-world/add-table.mdx
+++ b/docs/pages/guides/hello-world/add-table.mdx
@@ -261,7 +261,7 @@ This exclamation point tells the compiler that it's OK, there will be a real val
```html filename="index.html" copy showLineNumbers {12-17}
-
+
diff --git a/docs/pages/store/reference/misc.mdx b/docs/pages/store/reference/misc.mdx
index 78e1f5d689..301a4846d9 100644
--- a/docs/pages/store/reference/misc.mdx
+++ b/docs/pages/store/reference/misc.mdx
@@ -470,50 +470,6 @@ function encode(uint256[] memory _staticFieldLengths, uint256 numDynamicFields)
| -------- | ------------- | ------------------------------------------------------------ |
| `` | `FieldLayout` | A FieldLayout structure containing the encoded field layout. |
-### Errors
-
-#### FieldLayoutLib_TooManyFields
-
-```solidity
-error FieldLayoutLib_TooManyFields(uint256 numFields, uint256 maxFields);
-```
-
-#### FieldLayoutLib_TooManyDynamicFields
-
-```solidity
-error FieldLayoutLib_TooManyDynamicFields(uint256 numFields, uint256 maxFields);
-```
-
-#### FieldLayoutLib_Empty
-
-```solidity
-error FieldLayoutLib_Empty();
-```
-
-#### FieldLayoutLib_InvalidStaticDataLength
-
-```solidity
-error FieldLayoutLib_InvalidStaticDataLength(uint256 staticDataLength, uint256 computedStaticDataLength);
-```
-
-#### FieldLayoutLib_StaticLengthIsZero
-
-```solidity
-error FieldLayoutLib_StaticLengthIsZero(uint256 index);
-```
-
-#### FieldLayoutLib_StaticLengthIsNotZero
-
-```solidity
-error FieldLayoutLib_StaticLengthIsNotZero(uint256 index);
-```
-
-#### FieldLayoutLib_StaticLengthDoesNotFitInAWord
-
-```solidity
-error FieldLayoutLib_StaticLengthDoesNotFitInAWord(uint256 index);
-```
-
## FieldLayout
[Git Source](https://github.com/latticexyz/mud/blob/main/packages/store/src/FieldLayout.sol)
@@ -991,24 +947,6 @@ function encode(SchemaType[] memory schemas) internal pure returns (Schema);
| -------- | -------- | ------------------- |
| `` | `Schema` | The encoded Schema. |
-### Errors
-
-#### SchemaLib_InvalidLength
-
-_Error raised when the provided schema has an invalid length._
-
-```solidity
-error SchemaLib_InvalidLength(uint256 length);
-```
-
-#### SchemaLib_StaticTypeAfterDynamicType
-
-_Error raised when a static type is placed after a dynamic type in a schema._
-
-```solidity
-error SchemaLib_StaticTypeAfterDynamicType();
-```
-
## Schema
[Git Source](https://github.com/latticexyz/mud/blob/main/packages/store/src/Schema.sol)
@@ -1192,14 +1130,6 @@ function getSubslice(bytes memory data, uint256 start, uint256 end) internal pur
| -------- | ------- | ------------------------------------- |
| `` | `Slice` | A new Slice representing the subslice |
-### Errors
-
-#### Slice_OutOfBounds
-
-```solidity
-error Slice_OutOfBounds(bytes data, uint256 start, uint256 end);
-```
-
## Slice
[Git Source](https://github.com/latticexyz/mud/blob/main/packages/store/src/Slice.sol)
@@ -1618,9 +1548,9 @@ 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.
-_Identifier for the current store version._
+_Identifier for the current Store version._
```solidity
bytes32 constant STORE_VERSION = "1.0.0-unaudited";
diff --git a/docs/pages/store/reference/store-core.mdx b/docs/pages/store/reference/store-core.mdx
index 4d9d0f1dd8..f5888d234c 100644
--- a/docs/pages/store/reference/store-core.mdx
+++ b/docs/pages/store/reference/store-core.mdx
@@ -762,91 +762,6 @@ function getDynamicFieldSlice(
| -------- | ------- | ------------------------------------ |
| `` | `bytes` | The byte slice of the dynamic field. |
-### Events
-
-#### Store_SetRecord
-
-Emitted when a new record is set in the store.
-
-```solidity
-event Store_SetRecord(
- ResourceId indexed tableId, bytes32[] keyTuple, bytes staticData, PackedCounter encodedLengths, bytes dynamicData
-);
-```
-
-**Parameters**
-
-| Name | Type | Description |
-| ---------------- | --------------- | ------------------------------------------------------- |
-| `tableId` | `ResourceId` | The ID of the table where the record is set. |
-| `keyTuple` | `bytes32[]` | An array representing the composite key for the record. |
-| `staticData` | `bytes` | The static data of the record. |
-| `encodedLengths` | `PackedCounter` | The encoded lengths of the dynamic data of the record. |
-| `dynamicData` | `bytes` | The dynamic data of the record. |
-
-#### Store_SpliceStaticData
-
-Emitted when static data in the store is spliced.
-
-_In static data, data is always overwritten starting at the start position,
-so the total length of the data remains the same and no data is shifted._
-
-```solidity
-event Store_SpliceStaticData(ResourceId indexed tableId, bytes32[] keyTuple, uint48 start, bytes data);
-```
-
-**Parameters**
-
-| Name | Type | Description |
-| ---------- | ------------ | --------------------------------------------------------------------- |
-| `tableId` | `ResourceId` | The ID of the table where the data is spliced. |
-| `keyTuple` | `bytes32[]` | An array representing the key for the record. |
-| `start` | `uint48` | The start position in bytes for the splice operation. |
-| `data` | `bytes` | The data to write to the static data of the record at the start byte. |
-
-#### Store_SpliceDynamicData
-
-Emitted when dynamic data in the store is spliced.
-
-```solidity
-event Store_SpliceDynamicData(
- ResourceId indexed tableId,
- bytes32[] keyTuple,
- uint8 dynamicFieldIndex,
- uint48 start,
- uint40 deleteCount,
- PackedCounter encodedLengths,
- bytes data
-);
-```
-
-**Parameters**
-
-| Name | Type | Description |
-| ------------------- | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `tableId` | `ResourceId` | The ID of the table where the data is spliced. |
-| `keyTuple` | `bytes32[]` | An array representing the composite key for the record. |
-| `dynamicFieldIndex` | `uint8` | The index of the dynamic field to splice data, relative to the start of the dynamic fields. (Dynamic field index = field index - number of static fields) |
-| `start` | `uint48` | The start position in bytes for the splice operation. |
-| `deleteCount` | `uint40` | The number of bytes to delete in the splice operation. |
-| `encodedLengths` | `PackedCounter` | The encoded lengths of the dynamic data of the record. |
-| `data` | `bytes` | The data to insert into the dynamic data of the record at the start byte. |
-
-#### Store_DeleteRecord
-
-Emitted when a record is deleted from the store.
-
-```solidity
-event Store_DeleteRecord(ResourceId indexed tableId, bytes32[] keyTuple);
-```
-
-**Parameters**
-
-| Name | Type | Description |
-| ---------- | ------------ | ------------------------------------------------------- |
-| `tableId` | `ResourceId` | The ID of the table where the record is deleted. |
-| `keyTuple` | `bytes32[]` | An array representing the composite key for the record. |
-
## StoreCoreInternal
[Git Source](https://github.com/latticexyz/mud/blob/main/packages/store/src/StoreCore.sol)
diff --git a/docs/pages/store/reference/store.mdx b/docs/pages/store/reference/store.mdx
index df300ce8c7..4106a722f0 100644
--- a/docs/pages/store/reference/store.mdx
+++ b/docs/pages/store/reference/store.mdx
@@ -5,7 +5,9 @@
[Git Source](https://github.com/latticexyz/mud/blob/main/packages/store/src/IStore.sol)
**Inherits:**
-[IStoreData](/store/reference/store#istoredata), [IStoreRegistration](/store/reference/store#istoreregistration), [IStoreErrors](/store/reference/store#istoreerrors)
+[IStoreData](/store/reference/store#istoredata), [IStoreRegistration](/store/reference/store#istoreregistration), [IStoreErrors](/store/reference/store#istoreerrors), [IFieldLayoutErrors](/src/IFieldLayoutErrors.sol/interface.IFieldLayoutErrors.md), [IPackedCounterErrors](/src/IPackedCounterErrors.sol/interface.IPackedCounterErrors.md), [ISchemaErrors](/src/ISchemaErrors.sol/interface.ISchemaErrors.md), [ISliceErrors](/src/ISliceErrors.sol/interface.ISliceErrors.md)
+
+IStore implements the error interfaces for each library that it uses.
## IStoreEvents
@@ -13,13 +15,31 @@
### 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.
```solidity
event Store_SetRecord(
- ResourceId indexed tableId, bytes32[] keyTuple, bytes staticData, PackedCounter encodedLengths, bytes dynamicData
+ ResourceId indexed tableId,
+ bytes32[] keyTuple,
+ bytes staticData,
+ PackedCounter encodedLengths,
+ bytes dynamicData
);
```
@@ -59,13 +79,13 @@ Emitted when dynamic data in the store is spliced.
```solidity
event Store_SpliceDynamicData(
- ResourceId indexed tableId,
- bytes32[] keyTuple,
- uint8 dynamicFieldIndex,
- uint48 start,
- uint40 deleteCount,
- PackedCounter encodedLengths,
- bytes data
+ ResourceId indexed tableId,
+ bytes32[] keyTuple,
+ uint8 dynamicFieldIndex,
+ uint48 start,
+ uint40 deleteCount,
+ PackedCounter encodedLengths,
+ bytes data
);
```
@@ -100,6 +120,11 @@ event Store_DeleteRecord(ResourceId indexed tableId, bytes32[] keyTuple);
[Git Source](https://github.com/latticexyz/mud/blob/main/packages/store/src/IStoreErrors.sol)
+This interface includes errors for Store.
+
+_We bundle these errors in an interface (instead of at the file-level or in their corresponding library) so they can be inherited by IStore.
+This ensures that all possible errors are included in the IStore ABI for proper decoding in the frontend._
+
### Errors
#### Store_TableAlreadyExists
@@ -201,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)
@@ -482,9 +491,7 @@ function deleteRecord(ResourceId tableId, bytes32[] memory keyTuple) external;
[Git Source](https://github.com/latticexyz/mud/blob/main/packages/store/src/IStoreRegistration.sol)
-The IStoreRegistration interface includes methods for managing table field layouts,
-metadata, and hooks, which are usually called once in the setup phase of an application,
-making them less performance critical than the methods.
+_This interface includes methods for managing table field layouts, metadata, and hooks, which are usually called once in the setup phase of an application, making them less performance critical than the methods._
### Functions
diff --git a/docs/pages/world/reference/internal/erc165.mdx b/docs/pages/world/reference/internal/erc165.mdx
index e6595d57d6..624f36d17f 100644
--- a/docs/pages/world/reference/internal/erc165.mdx
+++ b/docs/pages/world/reference/internal/erc165.mdx
@@ -93,12 +93,8 @@ function supportsERC165InterfaceUnchecked(address account, bytes4 interfaceId) i
[Git Source](https://github.com/latticexyz/mud/blob/main/packages/world/src/requireInterface.sol)
-Utility function to validate interface support on a given contract using ERC-165.
-
Checks if a given contract at `contractAddress` supports the interface with ID `interfaceId`.
-_This function uses the ERC-165 standard's `supportsInterface` to check if a given contract supports a specific interface._
-
_Uses the ERC-165 `supportsInterface` method. If the contract doesn't support the interface or doesn't implement ERC-165, the function will revert with a relevant error message._
```solidity
diff --git a/docs/pages/world/reference/misc.mdx b/docs/pages/world/reference/misc.mdx
index b2ebefd27c..2fed485aec 100644
--- a/docs/pages/world/reference/misc.mdx
+++ b/docs/pages/world/reference/misc.mdx
@@ -79,12 +79,8 @@ ResourceId constant UNLIMITED_DELEGATION = ResourceId.wrap(
[Git Source](https://github.com/latticexyz/mud/blob/main/packages/world/src/revertWithBytes.sol)
-Utility function to revert transactions with raw bytes.
-
Reverts the transaction using the provided raw bytes as the revert reason.
-_This can be especially useful when reverting with a message obtained from a low-level call or a pre-encoded error._
-
_Uses assembly to perform the revert operation with the raw bytes._
```solidity
@@ -103,9 +99,9 @@ function revertWithBytes(bytes memory reason) pure;
#### WORLD_VERSION
-_World Version Constant
-Defines the version identifier for the World contract or module.
-This version identifier can be used for version checks, logging, and more._
+Contains a constant representing the version of the World.
+
+_Identifier for the current World version._
```solidity
bytes32 constant WORLD_VERSION = "1.0.0-unaudited";
diff --git a/docs/pages/world/reference/resource-ids.mdx b/docs/pages/world/reference/resource-ids.mdx
index 5a6c7a5f0e..6b053e370c 100644
--- a/docs/pages/world/reference/resource-ids.mdx
+++ b/docs/pages/world/reference/resource-ids.mdx
@@ -194,11 +194,7 @@ function toTrimmedString(bytes16 paddedString) internal pure returns (string mem
#### RESOURCE_NAMESPACE
-_World Resource Types_
-
-_Constants related to World Resource Types and Masks._
-
-_These constants are used to represent various resource types within the system._
+_Constants used to work with world resource types._
```solidity
bytes2 constant RESOURCE_NAMESPACE = "ns";
diff --git a/docs/pages/world/reference/world-context-external.mdx b/docs/pages/world/reference/world-context-external.mdx
index cb3469d2f7..f213c32c65 100644
--- a/docs/pages/world/reference/world-context-external.mdx
+++ b/docs/pages/world/reference/world-context-external.mdx
@@ -11,11 +11,6 @@ This contract is designed to extract trusted context values (like msg.sender and
from the appended calldata. It provides mechanisms similar to EIP-2771 (https://eips.ethereum.org/EIPS/eip-2771),
but allowing any contract to be the trusted forwarder.
-_World Context Consumer Interface
-This interface defines the functions a contract needs to consume the world context.
-It includes helper functions to retrieve the message sender, value, and world address.
-Additionally, it integrates with the ERC-165 standard for interface detection._
-
_This contract should only be used for contracts without their own storage, like Systems._
### Functions
diff --git a/docs/pages/world/reference/world-context.mdx b/docs/pages/world/reference/world-context.mdx
index 514178c281..512d8a7253 100644
--- a/docs/pages/world/reference/world-context.mdx
+++ b/docs/pages/world/reference/world-context.mdx
@@ -92,6 +92,8 @@ uint256 constant CONTEXT_BYTES = 20 + 32;
[Git Source](https://github.com/latticexyz/mud/blob/main/packages/world/src/WorldContext.sol)
+Helpers for working with data in the context of calling a World
+
### Functions
#### \_msgSender
diff --git a/docs/pages/world/reference/world.mdx b/docs/pages/world/reference/world.mdx
index f25400d6e3..2bed5edbe2 100644
--- a/docs/pages/world/reference/world.mdx
+++ b/docs/pages/world/reference/world.mdx
@@ -44,7 +44,10 @@ constructor();
#### prohibitDirectCallback
-_Prevents the World contract from calling itself._
+_Prevents the World contract from calling itself.
+If the World is able to call itself via `delegatecall` from a system, the system would have root access to context like internal tables, causing a potential vulnerability.
+Ideally this should not happen because all operations to internal tables happen as internal library calls, and all calls to root systems happen as a `delegatecall` to the system.
+However, since this is an important invariant, we make it explicit by reverting if `msg.sender` is `address(this)` in all `World` methods._
```solidity
modifier prohibitDirectCallback();
diff --git a/docs/src/tailwindcss-plugins/animate.ts b/docs/src/tailwindcss-plugins/animate.ts
index f64ba44b27..1c6e3c1369 100644
--- a/docs/src/tailwindcss-plugins/animate.ts
+++ b/docs/src/tailwindcss-plugins/animate.ts
@@ -37,7 +37,7 @@ module.exports = plugin(
"fade-in": (value) => ({ "--tw-enter-opacity": value }),
"fade-out": (value) => ({ "--tw-exit-opacity": value }),
},
- { values: theme("animationOpacity") }
+ { values: theme("animationOpacity") },
);
matchUtilities(
@@ -45,7 +45,7 @@ module.exports = plugin(
"zoom-in": (value) => ({ "--tw-enter-scale": value }),
"zoom-out": (value) => ({ "--tw-exit-scale": value }),
},
- { values: theme("animationScale") }
+ { values: theme("animationScale") },
);
matchUtilities(
@@ -53,7 +53,7 @@ module.exports = plugin(
"spin-in": (value) => ({ "--tw-enter-rotate": value }),
"spin-out": (value) => ({ "--tw-exit-rotate": value }),
},
- { values: theme("animationRotate") }
+ { values: theme("animationRotate") },
);
matchUtilities(
@@ -83,19 +83,19 @@ module.exports = plugin(
"--tw-exit-translate-x": value,
}),
},
- { values: theme("animationTranslate") }
+ { values: theme("animationTranslate") },
);
matchUtilities(
{ "animate-duration": (value: string) => ({ animationDuration: value }) },
- { values: filterDefault(theme("animationDuration")) }
+ { values: filterDefault(theme("animationDuration")) },
);
matchUtilities({ delay: (value) => ({ animationDelay: value }) }, { values: theme("animationDelay") });
matchUtilities(
{ ease: (value: string) => ({ animationTimingFunction: value }) },
- { values: filterDefault(theme("animationTimingFunction")) }
+ { values: filterDefault(theme("animationTimingFunction")) },
);
addUtilities({
@@ -175,5 +175,5 @@ module.exports = plugin(
},
},
},
- }
+ },
);
diff --git a/e2e/packages/client-vanilla/src/index.ts b/e2e/packages/client-vanilla/src/index.ts
index 464d986f78..7899f3c949 100644
--- a/e2e/packages/client-vanilla/src/index.ts
+++ b/e2e/packages/client-vanilla/src/index.ts
@@ -17,7 +17,7 @@ _window.getEntities = (componentName: keyof typeof components) => Array.from(com
_window.getKeys = (componentName: keyof typeof components) =>
Array.from(components[componentName].entities()).map((entity) =>
- decodeEntity(components[componentName].metadata.keySchema, entity)
+ decodeEntity(components[componentName].metadata.keySchema, entity),
);
// Update block number in the UI
diff --git a/e2e/packages/contracts/package.json b/e2e/packages/contracts/package.json
index 27a8b462a5..3f1b229fb3 100644
--- a/e2e/packages/contracts/package.json
+++ b/e2e/packages/contracts/package.json
@@ -19,7 +19,7 @@
"dotenv": "^16.0.3",
"ds-test": "https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0",
"forge-std": "https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1",
- "prettier": "^2.6.2",
+ "prettier": "3.2.5",
"rimraf": "^3.0.2",
"typescript": "5.1.6",
"vite": "^4.2.1",
diff --git a/e2e/packages/contracts/src/codegen/index.sol b/e2e/packages/contracts/src/codegen/index.sol
index 409d155bf2..8de689e3ae 100644
--- a/e2e/packages/contracts/src/codegen/index.sol
+++ b/e2e/packages/contracts/src/codegen/index.sol
@@ -3,9 +3,9 @@ pragma solidity >=0.8.24;
/* Autogenerated file. Do not edit manually. */
-import { Number, NumberTableId } from "./tables/Number.sol";
-import { Vector, VectorData, VectorTableId } from "./tables/Vector.sol";
-import { NumberList, NumberListTableId } from "./tables/NumberList.sol";
-import { Multi, MultiData, MultiTableId } from "./tables/Multi.sol";
-import { Position, PositionTableId } from "./tables/Position.sol";
-import { StaticArray, StaticArrayTableId } from "./tables/StaticArray.sol";
+import { Number } from "./tables/Number.sol";
+import { Vector, VectorData } from "./tables/Vector.sol";
+import { NumberList } from "./tables/NumberList.sol";
+import { Multi, MultiData } from "./tables/Multi.sol";
+import { Position } from "./tables/Position.sol";
+import { StaticArray } from "./tables/StaticArray.sol";
diff --git a/e2e/packages/contracts/src/codegen/tables/Multi.sol b/e2e/packages/contracts/src/codegen/tables/Multi.sol
index 99a5c7d699..ae9811c45f 100644
--- a/e2e/packages/contracts/src/codegen/tables/Multi.sol
+++ b/e2e/packages/contracts/src/codegen/tables/Multi.sol
@@ -3,9 +3,6 @@ pragma solidity >=0.8.24;
/* Autogenerated file. Do not edit manually. */
-// Import schema type
-import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol";
-
// Import store internals
import { IStore } from "@latticexyz/store/src/IStore.sol";
import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol";
@@ -14,58 +11,27 @@ import { Bytes } from "@latticexyz/store/src/Bytes.sol";
import { Memory } from "@latticexyz/store/src/Memory.sol";
import { SliceLib } from "@latticexyz/store/src/Slice.sol";
import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol";
-import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.sol";
-import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol";
+import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol";
+import { Schema } from "@latticexyz/store/src/Schema.sol";
import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol";
import { ResourceId } from "@latticexyz/store/src/ResourceId.sol";
-// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "Multi", typeId: RESOURCE_TABLE });`
-ResourceId constant _tableId = ResourceId.wrap(0x746200000000000000000000000000004d756c74690000000000000000000000);
-ResourceId constant MultiTableId = _tableId;
-
-FieldLayout constant _fieldLayout = FieldLayout.wrap(
- 0x0021020020010000000000000000000000000000000000000000000000000000
-);
-
struct MultiData {
int256 num;
bool value;
}
library Multi {
- /**
- * @notice Get the table values' field layout.
- * @return _fieldLayout The field layout for the table.
- */
- function getFieldLayout() internal pure returns (FieldLayout) {
- return _fieldLayout;
- }
+ // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "Multi", typeId: RESOURCE_TABLE });`
+ ResourceId constant _tableId = ResourceId.wrap(0x746200000000000000000000000000004d756c74690000000000000000000000);
- /**
- * @notice Get the table's key schema.
- * @return _keySchema The key schema for the table.
- */
- function getKeySchema() internal pure returns (Schema) {
- SchemaType[] memory _keySchema = new SchemaType[](4);
- _keySchema[0] = SchemaType.UINT32;
- _keySchema[1] = SchemaType.BOOL;
- _keySchema[2] = SchemaType.UINT256;
- _keySchema[3] = SchemaType.INT120;
-
- return SchemaLib.encode(_keySchema);
- }
-
- /**
- * @notice Get the table's value schema.
- * @return _valueSchema The value schema for the table.
- */
- function getValueSchema() internal pure returns (Schema) {
- SchemaType[] memory _valueSchema = new SchemaType[](2);
- _valueSchema[0] = SchemaType.INT256;
- _valueSchema[1] = SchemaType.BOOL;
+ FieldLayout constant _fieldLayout =
+ FieldLayout.wrap(0x0021020020010000000000000000000000000000000000000000000000000000);
- return SchemaLib.encode(_valueSchema);
- }
+ // Hex-encoded key schema of (uint32, bool, uint256, int120)
+ Schema constant _keySchema = Schema.wrap(0x0034040003601f2e000000000000000000000000000000000000000000000000);
+ // Hex-encoded value schema of (int256, bool)
+ Schema constant _valueSchema = Schema.wrap(0x002102003f600000000000000000000000000000000000000000000000000000);
/**
* @notice Get the table's key field names.
@@ -93,14 +59,14 @@ library Multi {
* @notice Register the table with its config.
*/
function register() internal {
- StoreSwitch.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
+ StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
}
/**
* @notice Register the table with its config.
*/
function _register() internal {
- StoreCore.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
+ StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
}
/**
diff --git a/e2e/packages/contracts/src/codegen/tables/Number.sol b/e2e/packages/contracts/src/codegen/tables/Number.sol
index 39654130c2..2c2820a54a 100644
--- a/e2e/packages/contracts/src/codegen/tables/Number.sol
+++ b/e2e/packages/contracts/src/codegen/tables/Number.sol
@@ -3,9 +3,6 @@ pragma solidity >=0.8.24;
/* Autogenerated file. Do not edit manually. */
-// Import schema type
-import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol";
-
// Import store internals
import { IStore } from "@latticexyz/store/src/IStore.sol";
import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol";
@@ -14,49 +11,22 @@ import { Bytes } from "@latticexyz/store/src/Bytes.sol";
import { Memory } from "@latticexyz/store/src/Memory.sol";
import { SliceLib } from "@latticexyz/store/src/Slice.sol";
import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol";
-import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.sol";
-import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol";
+import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol";
+import { Schema } from "@latticexyz/store/src/Schema.sol";
import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol";
import { ResourceId } from "@latticexyz/store/src/ResourceId.sol";
-// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "Number", typeId: RESOURCE_TABLE });`
-ResourceId constant _tableId = ResourceId.wrap(0x746200000000000000000000000000004e756d62657200000000000000000000);
-ResourceId constant NumberTableId = _tableId;
-
-FieldLayout constant _fieldLayout = FieldLayout.wrap(
- 0x0004010004000000000000000000000000000000000000000000000000000000
-);
-
library Number {
- /**
- * @notice Get the table values' field layout.
- * @return _fieldLayout The field layout for the table.
- */
- function getFieldLayout() internal pure returns (FieldLayout) {
- return _fieldLayout;
- }
-
- /**
- * @notice Get the table's key schema.
- * @return _keySchema The key schema for the table.
- */
- function getKeySchema() internal pure returns (Schema) {
- SchemaType[] memory _keySchema = new SchemaType[](1);
- _keySchema[0] = SchemaType.UINT32;
+ // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "Number", typeId: RESOURCE_TABLE });`
+ ResourceId constant _tableId = ResourceId.wrap(0x746200000000000000000000000000004e756d62657200000000000000000000);
- return SchemaLib.encode(_keySchema);
- }
+ FieldLayout constant _fieldLayout =
+ FieldLayout.wrap(0x0004010004000000000000000000000000000000000000000000000000000000);
- /**
- * @notice Get the table's value schema.
- * @return _valueSchema The value schema for the table.
- */
- function getValueSchema() internal pure returns (Schema) {
- SchemaType[] memory _valueSchema = new SchemaType[](1);
- _valueSchema[0] = SchemaType.UINT32;
-
- return SchemaLib.encode(_valueSchema);
- }
+ // Hex-encoded key schema of (uint32)
+ Schema constant _keySchema = Schema.wrap(0x0004010003000000000000000000000000000000000000000000000000000000);
+ // Hex-encoded value schema of (uint32)
+ Schema constant _valueSchema = Schema.wrap(0x0004010003000000000000000000000000000000000000000000000000000000);
/**
* @notice Get the table's key field names.
@@ -80,14 +50,14 @@ library Number {
* @notice Register the table with its config.
*/
function register() internal {
- StoreSwitch.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
+ StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
}
/**
* @notice Register the table with its config.
*/
function _register() internal {
- StoreCore.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
+ StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
}
/**
diff --git a/e2e/packages/contracts/src/codegen/tables/NumberList.sol b/e2e/packages/contracts/src/codegen/tables/NumberList.sol
index 426f0600cf..667191bfa2 100644
--- a/e2e/packages/contracts/src/codegen/tables/NumberList.sol
+++ b/e2e/packages/contracts/src/codegen/tables/NumberList.sol
@@ -3,9 +3,6 @@ pragma solidity >=0.8.24;
/* Autogenerated file. Do not edit manually. */
-// Import schema type
-import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol";
-
// Import store internals
import { IStore } from "@latticexyz/store/src/IStore.sol";
import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol";
@@ -14,48 +11,22 @@ import { Bytes } from "@latticexyz/store/src/Bytes.sol";
import { Memory } from "@latticexyz/store/src/Memory.sol";
import { SliceLib } from "@latticexyz/store/src/Slice.sol";
import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol";
-import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.sol";
-import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol";
+import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol";
+import { Schema } from "@latticexyz/store/src/Schema.sol";
import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol";
import { ResourceId } from "@latticexyz/store/src/ResourceId.sol";
-// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "NumberList", typeId: RESOURCE_TABLE });`
-ResourceId constant _tableId = ResourceId.wrap(0x746200000000000000000000000000004e756d6265724c697374000000000000);
-ResourceId constant NumberListTableId = _tableId;
-
-FieldLayout constant _fieldLayout = FieldLayout.wrap(
- 0x0000000100000000000000000000000000000000000000000000000000000000
-);
-
library NumberList {
- /**
- * @notice Get the table values' field layout.
- * @return _fieldLayout The field layout for the table.
- */
- function getFieldLayout() internal pure returns (FieldLayout) {
- return _fieldLayout;
- }
-
- /**
- * @notice Get the table's key schema.
- * @return _keySchema The key schema for the table.
- */
- function getKeySchema() internal pure returns (Schema) {
- SchemaType[] memory _keySchema = new SchemaType[](0);
+ // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "NumberList", typeId: RESOURCE_TABLE });`
+ ResourceId constant _tableId = ResourceId.wrap(0x746200000000000000000000000000004e756d6265724c697374000000000000);
- return SchemaLib.encode(_keySchema);
- }
+ FieldLayout constant _fieldLayout =
+ FieldLayout.wrap(0x0000000100000000000000000000000000000000000000000000000000000000);
- /**
- * @notice Get the table's value schema.
- * @return _valueSchema The value schema for the table.
- */
- function getValueSchema() internal pure returns (Schema) {
- SchemaType[] memory _valueSchema = new SchemaType[](1);
- _valueSchema[0] = SchemaType.UINT32_ARRAY;
-
- return SchemaLib.encode(_valueSchema);
- }
+ // Hex-encoded key schema of ()
+ Schema constant _keySchema = Schema.wrap(0x0000000000000000000000000000000000000000000000000000000000000000);
+ // Hex-encoded value schema of (uint32[])
+ Schema constant _valueSchema = Schema.wrap(0x0000000165000000000000000000000000000000000000000000000000000000);
/**
* @notice Get the table's key field names.
@@ -78,14 +49,14 @@ library NumberList {
* @notice Register the table with its config.
*/
function register() internal {
- StoreSwitch.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
+ StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
}
/**
* @notice Register the table with its config.
*/
function _register() internal {
- StoreCore.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
+ StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
}
/**
diff --git a/e2e/packages/contracts/src/codegen/tables/Position.sol b/e2e/packages/contracts/src/codegen/tables/Position.sol
index 7a724cc2a1..2cfe47fc5b 100644
--- a/e2e/packages/contracts/src/codegen/tables/Position.sol
+++ b/e2e/packages/contracts/src/codegen/tables/Position.sol
@@ -3,9 +3,6 @@ pragma solidity >=0.8.24;
/* Autogenerated file. Do not edit manually. */
-// Import schema type
-import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol";
-
// Import store internals
import { IStore } from "@latticexyz/store/src/IStore.sol";
import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol";
@@ -14,51 +11,22 @@ import { Bytes } from "@latticexyz/store/src/Bytes.sol";
import { Memory } from "@latticexyz/store/src/Memory.sol";
import { SliceLib } from "@latticexyz/store/src/Slice.sol";
import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol";
-import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.sol";
-import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol";
+import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol";
+import { Schema } from "@latticexyz/store/src/Schema.sol";
import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol";
import { ResourceId } from "@latticexyz/store/src/ResourceId.sol";
-// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "Position", typeId: RESOURCE_TABLE });`
-ResourceId constant _tableId = ResourceId.wrap(0x74620000000000000000000000000000506f736974696f6e0000000000000000);
-ResourceId constant PositionTableId = _tableId;
-
-FieldLayout constant _fieldLayout = FieldLayout.wrap(
- 0x0014010014000000000000000000000000000000000000000000000000000000
-);
-
library Position {
- /**
- * @notice Get the table values' field layout.
- * @return _fieldLayout The field layout for the table.
- */
- function getFieldLayout() internal pure returns (FieldLayout) {
- return _fieldLayout;
- }
-
- /**
- * @notice Get the table's key schema.
- * @return _keySchema The key schema for the table.
- */
- function getKeySchema() internal pure returns (Schema) {
- SchemaType[] memory _keySchema = new SchemaType[](3);
- _keySchema[0] = SchemaType.BYTES32;
- _keySchema[1] = SchemaType.INT32;
- _keySchema[2] = SchemaType.INT32;
+ // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "Position", typeId: RESOURCE_TABLE });`
+ ResourceId constant _tableId = ResourceId.wrap(0x74620000000000000000000000000000506f736974696f6e0000000000000000);
- return SchemaLib.encode(_keySchema);
- }
+ FieldLayout constant _fieldLayout =
+ FieldLayout.wrap(0x0014010014000000000000000000000000000000000000000000000000000000);
- /**
- * @notice Get the table's value schema.
- * @return _valueSchema The value schema for the table.
- */
- function getValueSchema() internal pure returns (Schema) {
- SchemaType[] memory _valueSchema = new SchemaType[](1);
- _valueSchema[0] = SchemaType.ADDRESS;
-
- return SchemaLib.encode(_valueSchema);
- }
+ // Hex-encoded key schema of (bytes32, int32, int32)
+ Schema constant _keySchema = Schema.wrap(0x002803005f232300000000000000000000000000000000000000000000000000);
+ // Hex-encoded value schema of (address)
+ Schema constant _valueSchema = Schema.wrap(0x0014010061000000000000000000000000000000000000000000000000000000);
/**
* @notice Get the table's key field names.
@@ -84,14 +52,14 @@ library Position {
* @notice Register the table with its config.
*/
function register() internal {
- StoreSwitch.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
+ StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
}
/**
* @notice Register the table with its config.
*/
function _register() internal {
- StoreCore.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
+ StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
}
/**
diff --git a/e2e/packages/contracts/src/codegen/tables/StaticArray.sol b/e2e/packages/contracts/src/codegen/tables/StaticArray.sol
index 95a942ff05..99d6b62320 100644
--- a/e2e/packages/contracts/src/codegen/tables/StaticArray.sol
+++ b/e2e/packages/contracts/src/codegen/tables/StaticArray.sol
@@ -3,9 +3,6 @@ pragma solidity >=0.8.24;
/* Autogenerated file. Do not edit manually. */
-// Import schema type
-import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol";
-
// Import store internals
import { IStore } from "@latticexyz/store/src/IStore.sol";
import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol";
@@ -14,48 +11,22 @@ import { Bytes } from "@latticexyz/store/src/Bytes.sol";
import { Memory } from "@latticexyz/store/src/Memory.sol";
import { SliceLib } from "@latticexyz/store/src/Slice.sol";
import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol";
-import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.sol";
-import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol";
+import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol";
+import { Schema } from "@latticexyz/store/src/Schema.sol";
import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol";
import { ResourceId } from "@latticexyz/store/src/ResourceId.sol";
-// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "StaticArray", typeId: RESOURCE_TABLE });`
-ResourceId constant _tableId = ResourceId.wrap(0x7462000000000000000000000000000053746174696341727261790000000000);
-ResourceId constant StaticArrayTableId = _tableId;
-
-FieldLayout constant _fieldLayout = FieldLayout.wrap(
- 0x0000000100000000000000000000000000000000000000000000000000000000
-);
-
library StaticArray {
- /**
- * @notice Get the table values' field layout.
- * @return _fieldLayout The field layout for the table.
- */
- function getFieldLayout() internal pure returns (FieldLayout) {
- return _fieldLayout;
- }
-
- /**
- * @notice Get the table's key schema.
- * @return _keySchema The key schema for the table.
- */
- function getKeySchema() internal pure returns (Schema) {
- SchemaType[] memory _keySchema = new SchemaType[](0);
+ // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "StaticArray", typeId: RESOURCE_TABLE });`
+ ResourceId constant _tableId = ResourceId.wrap(0x7462000000000000000000000000000053746174696341727261790000000000);
- return SchemaLib.encode(_keySchema);
- }
+ FieldLayout constant _fieldLayout =
+ FieldLayout.wrap(0x0000000100000000000000000000000000000000000000000000000000000000);
- /**
- * @notice Get the table's value schema.
- * @return _valueSchema The value schema for the table.
- */
- function getValueSchema() internal pure returns (Schema) {
- SchemaType[] memory _valueSchema = new SchemaType[](1);
- _valueSchema[0] = SchemaType.UINT256_ARRAY;
-
- return SchemaLib.encode(_valueSchema);
- }
+ // Hex-encoded key schema of ()
+ Schema constant _keySchema = Schema.wrap(0x0000000000000000000000000000000000000000000000000000000000000000);
+ // Hex-encoded value schema of (uint256[])
+ Schema constant _valueSchema = Schema.wrap(0x0000000181000000000000000000000000000000000000000000000000000000);
/**
* @notice Get the table's key field names.
@@ -78,14 +49,14 @@ library StaticArray {
* @notice Register the table with its config.
*/
function register() internal {
- StoreSwitch.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
+ StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
}
/**
* @notice Register the table with its config.
*/
function _register() internal {
- StoreCore.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
+ StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
}
/**
diff --git a/e2e/packages/contracts/src/codegen/tables/Vector.sol b/e2e/packages/contracts/src/codegen/tables/Vector.sol
index eb09153136..6d3d109d55 100644
--- a/e2e/packages/contracts/src/codegen/tables/Vector.sol
+++ b/e2e/packages/contracts/src/codegen/tables/Vector.sol
@@ -3,9 +3,6 @@ pragma solidity >=0.8.24;
/* Autogenerated file. Do not edit manually. */
-// Import schema type
-import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol";
-
// Import store internals
import { IStore } from "@latticexyz/store/src/IStore.sol";
import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol";
@@ -14,55 +11,27 @@ import { Bytes } from "@latticexyz/store/src/Bytes.sol";
import { Memory } from "@latticexyz/store/src/Memory.sol";
import { SliceLib } from "@latticexyz/store/src/Slice.sol";
import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol";
-import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.sol";
-import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol";
+import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol";
+import { Schema } from "@latticexyz/store/src/Schema.sol";
import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol";
import { ResourceId } from "@latticexyz/store/src/ResourceId.sol";
-// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "Vector", typeId: RESOURCE_TABLE });`
-ResourceId constant _tableId = ResourceId.wrap(0x74620000000000000000000000000000566563746f7200000000000000000000);
-ResourceId constant VectorTableId = _tableId;
-
-FieldLayout constant _fieldLayout = FieldLayout.wrap(
- 0x0008020004040000000000000000000000000000000000000000000000000000
-);
-
struct VectorData {
int32 x;
int32 y;
}
library Vector {
- /**
- * @notice Get the table values' field layout.
- * @return _fieldLayout The field layout for the table.
- */
- function getFieldLayout() internal pure returns (FieldLayout) {
- return _fieldLayout;
- }
-
- /**
- * @notice Get the table's key schema.
- * @return _keySchema The key schema for the table.
- */
- function getKeySchema() internal pure returns (Schema) {
- SchemaType[] memory _keySchema = new SchemaType[](1);
- _keySchema[0] = SchemaType.UINT32;
+ // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "Vector", typeId: RESOURCE_TABLE });`
+ ResourceId constant _tableId = ResourceId.wrap(0x74620000000000000000000000000000566563746f7200000000000000000000);
- return SchemaLib.encode(_keySchema);
- }
+ FieldLayout constant _fieldLayout =
+ FieldLayout.wrap(0x0008020004040000000000000000000000000000000000000000000000000000);
- /**
- * @notice Get the table's value schema.
- * @return _valueSchema The value schema for the table.
- */
- function getValueSchema() internal pure returns (Schema) {
- SchemaType[] memory _valueSchema = new SchemaType[](2);
- _valueSchema[0] = SchemaType.INT32;
- _valueSchema[1] = SchemaType.INT32;
-
- return SchemaLib.encode(_valueSchema);
- }
+ // Hex-encoded key schema of (uint32)
+ Schema constant _keySchema = Schema.wrap(0x0004010003000000000000000000000000000000000000000000000000000000);
+ // Hex-encoded value schema of (int32, int32)
+ Schema constant _valueSchema = Schema.wrap(0x0008020023230000000000000000000000000000000000000000000000000000);
/**
* @notice Get the table's key field names.
@@ -87,14 +56,14 @@ library Vector {
* @notice Register the table with its config.
*/
function register() internal {
- StoreSwitch.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
+ StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
}
/**
* @notice Register the table with its config.
*/
function _register() internal {
- StoreCore.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
+ StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
}
/**
diff --git a/e2e/packages/contracts/src/codegen/world/ICustomErrorsSystem.sol b/e2e/packages/contracts/src/codegen/world/ICustomErrorsSystem.sol
index a7fb0f251f..ce3085beda 100644
--- a/e2e/packages/contracts/src/codegen/world/ICustomErrorsSystem.sol
+++ b/e2e/packages/contracts/src/codegen/world/ICustomErrorsSystem.sol
@@ -7,6 +7,7 @@ import { Position } from "./../../CustomTypes.sol";
/**
* @title ICustomErrorsSystem
+ * @author MUD (https://mud.dev) by Lattice (https://lattice.xyz)
* @dev This interface is automatically generated from the corresponding system contract. Do not edit manually.
*/
interface ICustomErrorsSystem {
diff --git a/e2e/packages/contracts/src/codegen/world/INumberListSystem.sol b/e2e/packages/contracts/src/codegen/world/INumberListSystem.sol
index 318735091d..115020b005 100644
--- a/e2e/packages/contracts/src/codegen/world/INumberListSystem.sol
+++ b/e2e/packages/contracts/src/codegen/world/INumberListSystem.sol
@@ -5,6 +5,7 @@ pragma solidity >=0.8.24;
/**
* @title INumberListSystem
+ * @author MUD (https://mud.dev) by Lattice (https://lattice.xyz)
* @dev This interface is automatically generated from the corresponding system contract. Do not edit manually.
*/
interface INumberListSystem {
diff --git a/e2e/packages/contracts/src/codegen/world/INumberSystem.sol b/e2e/packages/contracts/src/codegen/world/INumberSystem.sol
index 963d1dca41..674c332050 100644
--- a/e2e/packages/contracts/src/codegen/world/INumberSystem.sol
+++ b/e2e/packages/contracts/src/codegen/world/INumberSystem.sol
@@ -5,6 +5,7 @@ pragma solidity >=0.8.24;
/**
* @title INumberSystem
+ * @author MUD (https://mud.dev) by Lattice (https://lattice.xyz)
* @dev This interface is automatically generated from the corresponding system contract. Do not edit manually.
*/
interface INumberSystem {
diff --git a/e2e/packages/contracts/src/codegen/world/IVectorSystem.sol b/e2e/packages/contracts/src/codegen/world/IVectorSystem.sol
index 6b3b91b89c..8c43954556 100644
--- a/e2e/packages/contracts/src/codegen/world/IVectorSystem.sol
+++ b/e2e/packages/contracts/src/codegen/world/IVectorSystem.sol
@@ -5,6 +5,7 @@ pragma solidity >=0.8.24;
/**
* @title IVectorSystem
+ * @author MUD (https://mud.dev) by Lattice (https://lattice.xyz)
* @dev This interface is automatically generated from the corresponding system contract. Do not edit manually.
*/
interface IVectorSystem {
diff --git a/e2e/packages/contracts/src/codegen/world/IWorld.sol b/e2e/packages/contracts/src/codegen/world/IWorld.sol
index 6865aa9033..62448e2b51 100644
--- a/e2e/packages/contracts/src/codegen/world/IWorld.sol
+++ b/e2e/packages/contracts/src/codegen/world/IWorld.sol
@@ -12,10 +12,9 @@ import { IVectorSystem } from "./IVectorSystem.sol";
/**
* @title IWorld
+ * @author MUD (https://mud.dev) by Lattice (https://lattice.xyz)
* @notice This interface integrates all systems and associated function selectors
* that are dynamically registered in the World during deployment.
* @dev This is an autogenerated file; do not edit manually.
*/
-interface IWorld is IBaseWorld, ICustomErrorsSystem, INumberListSystem, INumberSystem, IVectorSystem {
-
-}
+interface IWorld is IBaseWorld, ICustomErrorsSystem, INumberListSystem, INumberSystem, IVectorSystem {}
diff --git a/e2e/packages/contracts/src/systems/NumberListSystem.sol b/e2e/packages/contracts/src/systems/NumberListSystem.sol
index a36fe62521..aa07345160 100644
--- a/e2e/packages/contracts/src/systems/NumberListSystem.sol
+++ b/e2e/packages/contracts/src/systems/NumberListSystem.sol
@@ -4,7 +4,7 @@ pragma solidity >=0.8.24;
import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol";
import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol";
import { System } from "@latticexyz/world/src/System.sol";
-import { NumberList, NumberListTableId } from "../codegen/index.sol";
+import { NumberList } from "../codegen/index.sol";
contract NumberListSystem is System {
function set(uint32[] memory list) public {
@@ -22,7 +22,7 @@ contract NumberListSystem is System {
}
bytes32[] memory emptyKey;
- StoreSwitch.pushToDynamicField(NumberListTableId, emptyKey, 0, EncodeArray.encode(list));
+ StoreSwitch.pushToDynamicField(NumberList._tableId, emptyKey, 0, EncodeArray.encode(list));
}
function pop() public {
diff --git a/e2e/packages/sync-test/compare/compare.test.ts b/e2e/packages/sync-test/compare/compare.test.ts
index f3bb9b5351..c6d7f0f8f7 100644
--- a/e2e/packages/sync-test/compare/compare.test.ts
+++ b/e2e/packages/sync-test/compare/compare.test.ts
@@ -35,7 +35,7 @@ function setRecord(
address: Address,
tableId: TableId,
key: Key,
- data: Data
+ data: Data,
): void {
state[address.toLowerCase()] ??= {};
state[address.toLowerCase()][tableId] ??= {};
@@ -46,7 +46,7 @@ function getRecord(
state: Record>>,
address: Address,
tableId: TableId,
- key: Key
+ key: Key,
): Data | undefined {
return state[address]?.[tableId]?.[key];
}
diff --git a/e2e/packages/sync-test/data/callPageFunction.ts b/e2e/packages/sync-test/data/callPageFunction.ts
index ece5b02e01..89a9c395a4 100644
--- a/e2e/packages/sync-test/data/callPageFunction.ts
+++ b/e2e/packages/sync-test/data/callPageFunction.ts
@@ -9,7 +9,7 @@ import { deserialize, serialize } from "./utils";
export async function callPageFunction(
page: Page,
functionName: string,
- args: unknown[]
+ args: unknown[],
): Promise | undefined> {
const context = [functionName, args, serialize.toString(), deserialize.toString()] as const;
const serializedValue = await page.evaluate(async ([functionName, args, serializeString, deserializeString]) => {
diff --git a/e2e/packages/sync-test/data/callWorld.ts b/e2e/packages/sync-test/data/callWorld.ts
index c19e1d9029..c6b58c04c6 100644
--- a/e2e/packages/sync-test/data/callWorld.ts
+++ b/e2e/packages/sync-test/data/callWorld.ts
@@ -23,6 +23,6 @@ export function callWorld(page: Page, method: T
throw new Error([`Error executing ${_method} with args:`, JSON.stringify(_args), error].join("\n\n"));
});
},
- [method, args]
+ [method, args],
);
}
diff --git a/e2e/packages/sync-test/data/types.ts b/e2e/packages/sync-test/data/types.ts
index b79ac3f3b6..98369a7426 100644
--- a/e2e/packages/sync-test/data/types.ts
+++ b/e2e/packages/sync-test/data/types.ts
@@ -2,9 +2,10 @@
import { SchemaAbiType, SchemaAbiTypeToPrimitiveType } from "@latticexyz/schema-type";
import config from "../../contracts/mud.config";
import { Hex } from "viem";
-type SchemaToPrimitive = Schema extends Record
- ? { [key in keyof Schema]: SchemaAbiTypeToPrimitiveType }
- : never;
+type SchemaToPrimitive =
+ Schema extends Record
+ ? { [key in keyof Schema]: SchemaAbiTypeToPrimitiveType }
+ : never;
type Key = SchemaToPrimitive<
(typeof config)["tables"][Table]["keySchema"]
diff --git a/e2e/packages/sync-test/indexerSync.test.ts b/e2e/packages/sync-test/indexerSync.test.ts
index f23edf5f16..3585c6e4a2 100644
--- a/e2e/packages/sync-test/indexerSync.test.ts
+++ b/e2e/packages/sync-test/indexerSync.test.ts
@@ -143,7 +143,7 @@ describe("Sync from indexer", async () => {
y: -2,
zone: "0x6d61703100000000000000000000000000000000000000000000000000000000",
},
- ])
+ ]),
);
// Should not have thrown errors
diff --git a/e2e/packages/sync-test/setup/openClientWithRootAccount.ts b/e2e/packages/sync-test/setup/openClientWithRootAccount.ts
index 85b88658d6..98158ca286 100644
--- a/e2e/packages/sync-test/setup/openClientWithRootAccount.ts
+++ b/e2e/packages/sync-test/setup/openClientWithRootAccount.ts
@@ -12,6 +12,6 @@ export async function openClientWithRootAccount(page: Page, options?: { indexerU
// I wish I could pass undefined values into URLSearchParams and have them be ignored during stringify
...(process.env.PRIVATE_KEY ? { privateKey: process.env.PRIVATE_KEY } : null),
...(options?.indexerUrl ? { indexerUrl: options?.indexerUrl } : null),
- }).toString()}`
+ }).toString()}`,
);
}
diff --git a/e2e/packages/sync-test/setup/startBrowserAndPage.ts b/e2e/packages/sync-test/setup/startBrowserAndPage.ts
index 0f18151879..9cbced06a0 100644
--- a/e2e/packages/sync-test/setup/startBrowserAndPage.ts
+++ b/e2e/packages/sync-test/setup/startBrowserAndPage.ts
@@ -2,7 +2,7 @@ import { Browser, Page, chromium } from "@playwright/test";
import chalk from "chalk";
export async function startBrowserAndPage(
- reportError: (error: string) => void
+ reportError: (error: string) => void,
): Promise<{ browser: Browser; page: Page }> {
// open browser page
const browser = await chromium.launch();
diff --git a/e2e/packages/test-data/generate-bench-data-bulk.ts b/e2e/packages/test-data/generate-bench-data-bulk.ts
index 313ad45a7d..c69fad503f 100644
--- a/e2e/packages/test-data/generate-bench-data-bulk.ts
+++ b/e2e/packages/test-data/generate-bench-data-bulk.ts
@@ -34,7 +34,7 @@ for (let i = 0; i < NUM_RECORDS.length; i++) {
const logsFilename = path.join(
path.dirname(fileURLToPath(import.meta.url)),
- `../../../test-data/world-logs-bulk-${numRecords}.json`
+ `../../../test-data/world-logs-bulk-${numRecords}.json`,
);
console.log("writing", logs.length, "logs to", logsFilename);
diff --git a/e2e/packages/test-data/generate-bench-data-query.ts b/e2e/packages/test-data/generate-bench-data-query.ts
index d97a976fd4..4e34afe75c 100644
--- a/e2e/packages/test-data/generate-bench-data-query.ts
+++ b/e2e/packages/test-data/generate-bench-data-query.ts
@@ -30,7 +30,7 @@ const logs = await generateLogs(rpc, async (worldContract) => {
const logsFilename = path.join(
path.dirname(fileURLToPath(import.meta.url)),
- `../../../test-data/world-logs-query.json`
+ `../../../test-data/world-logs-query.json`,
);
console.log("writing", logs.length, "logs to", logsFilename);
diff --git a/e2e/packages/test-data/generateLogs.ts b/e2e/packages/test-data/generateLogs.ts
index fff5449b2f..ba855efe61 100644
--- a/e2e/packages/test-data/generateLogs.ts
+++ b/e2e/packages/test-data/generateLogs.ts
@@ -31,7 +31,7 @@ type WorldContract = GetContractReturnType<
export async function generateLogs(
rpc: string,
- transactionHook: (worldContract: WorldContract) => Promise
+ transactionHook: (worldContract: WorldContract) => Promise,
): Promise {
console.log("deploying world");
const { stdout, stderr } = await execa("pnpm", ["mud", "deploy", "--rpc", rpc, "--saveDeployment", "false"], {
@@ -88,7 +88,7 @@ export async function generateLogs(
encodeEventTopics({
abi: [event],
eventName: event.name,
- })
+ }),
),
],
fromBlock: numberToHex(0n),
diff --git a/e2e/pnpm-lock.yaml b/e2e/pnpm-lock.yaml
index 5f0ff0d145..cce221a655 100644
--- a/e2e/pnpm-lock.yaml
+++ b/e2e/pnpm-lock.yaml
@@ -112,8 +112,8 @@ importers:
specifier: https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1
version: github.com/foundry-rs/forge-std/74cfb77e308dd188d2f58864aaf44963ae6b88b1
prettier:
- specifier: ^2.6.2
- version: 2.6.2
+ specifier: 3.2.5
+ version: 3.2.5
rimraf:
specifier: ^3.0.2
version: 3.0.2
@@ -1531,9 +1531,9 @@ packages:
resolution: {integrity: sha512-+JD93VELV9gHkqpV5gdL5/70HdGtEw4/XE1S4BC8f1mcPmdib3K5XsKVbnR1XcAyC41zOnifJ+9YRKxdIsXiUw==}
dev: true
- /prettier@2.6.2:
- resolution: {integrity: sha512-PkUpF+qoXTqhOeWL9fu7As8LXsIUZ1WYaJiY/a7McAQzxjk82OF0tibkFXVCDImZtWxbvojFjerkiLb0/q8mew==}
- engines: {node: '>=10.13.0'}
+ /prettier@3.2.5:
+ resolution: {integrity: sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==}
+ engines: {node: '>=14'}
hasBin: true
dev: true
diff --git a/examples/minimal/packages/client-phaser/src/mud/createSystemCalls.ts b/examples/minimal/packages/client-phaser/src/mud/createSystemCalls.ts
index 1e0c674320..37203654b1 100644
--- a/examples/minimal/packages/client-phaser/src/mud/createSystemCalls.ts
+++ b/examples/minimal/packages/client-phaser/src/mud/createSystemCalls.ts
@@ -7,7 +7,7 @@ export type SystemCalls = ReturnType;
export function createSystemCalls(
{ worldContract, waitForTransaction }: SetupNetworkResult,
- { CounterTable }: ClientComponents
+ { CounterTable }: ClientComponents,
) {
const increment = async () => {
const tx = await worldContract.write.increment();
diff --git a/examples/minimal/packages/client-phaser/src/ui/App.tsx b/examples/minimal/packages/client-phaser/src/ui/App.tsx
index 69529815b5..0ddd731ec7 100644
--- a/examples/minimal/packages/client-phaser/src/ui/App.tsx
+++ b/examples/minimal/packages/client-phaser/src/ui/App.tsx
@@ -26,7 +26,7 @@ export const App = () => {
worldAbi: networkLayer.network.worldContract.abi,
write$: networkLayer.network.write$,
recsWorld: networkLayer.world,
- })
+ }),
);
}
}, [networkLayer]);
diff --git a/examples/minimal/packages/client-phaser/src/ui/hooks/usePhaserLayer.tsx b/examples/minimal/packages/client-phaser/src/ui/hooks/usePhaserLayer.tsx
index f0a4c36da7..c6292e57ff 100644
--- a/examples/minimal/packages/client-phaser/src/ui/hooks/usePhaserLayer.tsx
+++ b/examples/minimal/packages/client-phaser/src/ui/hooks/usePhaserLayer.tsx
@@ -79,7 +79,7 @@ export const usePhaserLayer = ({ networkLayer }: Props) => {
}
}
},
- [container]
+ [container],
);
return useMemo(() => ({ ref, phaserLayer }), [ref, phaserLayer]);
diff --git a/examples/minimal/packages/client-react/src/index.tsx b/examples/minimal/packages/client-react/src/index.tsx
index da8d70f020..1b005dc561 100644
--- a/examples/minimal/packages/client-react/src/index.tsx
+++ b/examples/minimal/packages/client-react/src/index.tsx
@@ -13,7 +13,7 @@ setup().then(async (result) => {
root.render(
-
+ ,
);
// https://vitejs.dev/guide/env-and-mode.html
diff --git a/examples/minimal/packages/client-react/src/mud/createSystemCalls.ts b/examples/minimal/packages/client-react/src/mud/createSystemCalls.ts
index 1e0c674320..37203654b1 100644
--- a/examples/minimal/packages/client-react/src/mud/createSystemCalls.ts
+++ b/examples/minimal/packages/client-react/src/mud/createSystemCalls.ts
@@ -7,7 +7,7 @@ export type SystemCalls = ReturnType;
export function createSystemCalls(
{ worldContract, waitForTransaction }: SetupNetworkResult,
- { CounterTable }: ClientComponents
+ { CounterTable }: ClientComponents,
) {
const increment = async () => {
const tx = await worldContract.write.increment();
diff --git a/examples/minimal/packages/contracts/package.json b/examples/minimal/packages/contracts/package.json
index 1bd8b4276b..7d49c273a0 100644
--- a/examples/minimal/packages/contracts/package.json
+++ b/examples/minimal/packages/contracts/package.json
@@ -27,8 +27,8 @@
"@types/node": "^18.15.11",
"ds-test": "https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0",
"forge-std": "https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1",
- "prettier": "^2.6.2",
- "prettier-plugin-solidity": "1.1.3",
+ "prettier": "3.2.5",
+ "prettier-plugin-solidity": "1.3.1",
"rimraf": "^3.0.2",
"solhint": "^3.4.1",
"solhint-config-mud": "file:../../../../packages/solhint-config-mud",
diff --git a/examples/minimal/packages/contracts/script/PostDeploy.s.sol b/examples/minimal/packages/contracts/script/PostDeploy.s.sol
index 9a760231f0..f39faa8fed 100644
--- a/examples/minimal/packages/contracts/script/PostDeploy.s.sol
+++ b/examples/minimal/packages/contracts/script/PostDeploy.s.sol
@@ -7,7 +7,7 @@ import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol";
import { ResourceId, WorldResourceIdLib, WorldResourceIdInstance } from "@latticexyz/world/src/WorldResourceId.sol";
import { RESOURCE_SYSTEM } from "@latticexyz/world/src/worldResourceTypes.sol";
-import { MessageTable, MessageTableTableId } from "../src/codegen/index.sol";
+import { MessageTable } from "../src/codegen/index.sol";
import { IWorld } from "../src/codegen/world/IWorld.sol";
import { ChatNamespacedSystem } from "../src/systems/ChatNamespacedSystem.sol";
@@ -36,7 +36,7 @@ contract PostDeploy is Script {
IWorld(worldAddress).registerFunctionSelector(systemId, "sendMessage(string)");
// Grant this system access to MessageTable
- IWorld(worldAddress).grantAccess(MessageTableTableId, address(chatNamespacedSystem));
+ IWorld(worldAddress).grantAccess(MessageTable._tableId, address(chatNamespacedSystem));
// ------------------ EXAMPLES ------------------
diff --git a/examples/minimal/packages/contracts/src/codegen/index.sol b/examples/minimal/packages/contracts/src/codegen/index.sol
index ac4baf9ad1..172a4254f3 100644
--- a/examples/minimal/packages/contracts/src/codegen/index.sol
+++ b/examples/minimal/packages/contracts/src/codegen/index.sol
@@ -3,6 +3,6 @@ pragma solidity >=0.8.24;
/* Autogenerated file. Do not edit manually. */
-import { CounterTable, CounterTableTableId } from "./tables/CounterTable.sol";
-import { MessageTable, MessageTableTableId } from "./tables/MessageTable.sol";
-import { Inventory, InventoryTableId } from "./tables/Inventory.sol";
+import { CounterTable } from "./tables/CounterTable.sol";
+import { MessageTable } from "./tables/MessageTable.sol";
+import { Inventory } from "./tables/Inventory.sol";
diff --git a/examples/minimal/packages/contracts/src/codegen/tables/CounterTable.sol b/examples/minimal/packages/contracts/src/codegen/tables/CounterTable.sol
index d3e5442de7..c9a05bc627 100644
--- a/examples/minimal/packages/contracts/src/codegen/tables/CounterTable.sol
+++ b/examples/minimal/packages/contracts/src/codegen/tables/CounterTable.sol
@@ -3,9 +3,6 @@ pragma solidity >=0.8.24;
/* Autogenerated file. Do not edit manually. */
-// Import schema type
-import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol";
-
// Import store internals
import { IStore } from "@latticexyz/store/src/IStore.sol";
import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol";
@@ -14,48 +11,22 @@ import { Bytes } from "@latticexyz/store/src/Bytes.sol";
import { Memory } from "@latticexyz/store/src/Memory.sol";
import { SliceLib } from "@latticexyz/store/src/Slice.sol";
import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol";
-import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.sol";
-import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol";
+import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol";
+import { Schema } from "@latticexyz/store/src/Schema.sol";
import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol";
import { ResourceId } from "@latticexyz/store/src/ResourceId.sol";
-// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "CounterTable", typeId: RESOURCE_TABLE });`
-ResourceId constant _tableId = ResourceId.wrap(0x74620000000000000000000000000000436f756e7465725461626c6500000000);
-ResourceId constant CounterTableTableId = _tableId;
-
-FieldLayout constant _fieldLayout = FieldLayout.wrap(
- 0x0004010004000000000000000000000000000000000000000000000000000000
-);
-
library CounterTable {
- /**
- * @notice Get the table values' field layout.
- * @return _fieldLayout The field layout for the table.
- */
- function getFieldLayout() internal pure returns (FieldLayout) {
- return _fieldLayout;
- }
-
- /**
- * @notice Get the table's key schema.
- * @return _keySchema The key schema for the table.
- */
- function getKeySchema() internal pure returns (Schema) {
- SchemaType[] memory _keySchema = new SchemaType[](0);
+ // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "CounterTable", typeId: RESOURCE_TABLE });`
+ ResourceId constant _tableId = ResourceId.wrap(0x74620000000000000000000000000000436f756e7465725461626c6500000000);
- return SchemaLib.encode(_keySchema);
- }
+ FieldLayout constant _fieldLayout =
+ FieldLayout.wrap(0x0004010004000000000000000000000000000000000000000000000000000000);
- /**
- * @notice Get the table's value schema.
- * @return _valueSchema The value schema for the table.
- */
- function getValueSchema() internal pure returns (Schema) {
- SchemaType[] memory _valueSchema = new SchemaType[](1);
- _valueSchema[0] = SchemaType.UINT32;
-
- return SchemaLib.encode(_valueSchema);
- }
+ // Hex-encoded key schema of ()
+ Schema constant _keySchema = Schema.wrap(0x0000000000000000000000000000000000000000000000000000000000000000);
+ // Hex-encoded value schema of (uint32)
+ Schema constant _valueSchema = Schema.wrap(0x0004010003000000000000000000000000000000000000000000000000000000);
/**
* @notice Get the table's key field names.
@@ -78,21 +49,21 @@ library CounterTable {
* @notice Register the table with its config.
*/
function register() internal {
- StoreSwitch.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
+ StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
}
/**
* @notice Register the table with its config.
*/
function _register() internal {
- StoreCore.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
+ StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
}
/**
* @notice Register the table with its config (using the specified store).
*/
function register(IStore _store) internal {
- _store.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
+ _store.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
}
/**
diff --git a/examples/minimal/packages/contracts/src/codegen/tables/Inventory.sol b/examples/minimal/packages/contracts/src/codegen/tables/Inventory.sol
index 1b5c163695..f04fddc6e7 100644
--- a/examples/minimal/packages/contracts/src/codegen/tables/Inventory.sol
+++ b/examples/minimal/packages/contracts/src/codegen/tables/Inventory.sol
@@ -3,9 +3,6 @@ pragma solidity >=0.8.24;
/* Autogenerated file. Do not edit manually. */
-// Import schema type
-import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol";
-
// Import store internals
import { IStore } from "@latticexyz/store/src/IStore.sol";
import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol";
@@ -14,51 +11,22 @@ import { Bytes } from "@latticexyz/store/src/Bytes.sol";
import { Memory } from "@latticexyz/store/src/Memory.sol";
import { SliceLib } from "@latticexyz/store/src/Slice.sol";
import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol";
-import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.sol";
-import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol";
+import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol";
+import { Schema } from "@latticexyz/store/src/Schema.sol";
import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol";
import { ResourceId } from "@latticexyz/store/src/ResourceId.sol";
-// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "Inventory", typeId: RESOURCE_TABLE });`
-ResourceId constant _tableId = ResourceId.wrap(0x74620000000000000000000000000000496e76656e746f727900000000000000);
-ResourceId constant InventoryTableId = _tableId;
-
-FieldLayout constant _fieldLayout = FieldLayout.wrap(
- 0x0004010004000000000000000000000000000000000000000000000000000000
-);
-
library Inventory {
- /**
- * @notice Get the table values' field layout.
- * @return _fieldLayout The field layout for the table.
- */
- function getFieldLayout() internal pure returns (FieldLayout) {
- return _fieldLayout;
- }
-
- /**
- * @notice Get the table's key schema.
- * @return _keySchema The key schema for the table.
- */
- function getKeySchema() internal pure returns (Schema) {
- SchemaType[] memory _keySchema = new SchemaType[](3);
- _keySchema[0] = SchemaType.ADDRESS;
- _keySchema[1] = SchemaType.UINT32;
- _keySchema[2] = SchemaType.UINT32;
+ // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "Inventory", typeId: RESOURCE_TABLE });`
+ ResourceId constant _tableId = ResourceId.wrap(0x74620000000000000000000000000000496e76656e746f727900000000000000);
- return SchemaLib.encode(_keySchema);
- }
+ FieldLayout constant _fieldLayout =
+ FieldLayout.wrap(0x0004010004000000000000000000000000000000000000000000000000000000);
- /**
- * @notice Get the table's value schema.
- * @return _valueSchema The value schema for the table.
- */
- function getValueSchema() internal pure returns (Schema) {
- SchemaType[] memory _valueSchema = new SchemaType[](1);
- _valueSchema[0] = SchemaType.UINT32;
-
- return SchemaLib.encode(_valueSchema);
- }
+ // Hex-encoded key schema of (address, uint32, uint32)
+ Schema constant _keySchema = Schema.wrap(0x001c030061030300000000000000000000000000000000000000000000000000);
+ // Hex-encoded value schema of (uint32)
+ Schema constant _valueSchema = Schema.wrap(0x0004010003000000000000000000000000000000000000000000000000000000);
/**
* @notice Get the table's key field names.
@@ -84,14 +52,14 @@ library Inventory {
* @notice Register the table with its config.
*/
function register() internal {
- StoreSwitch.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
+ StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
}
/**
* @notice Register the table with its config.
*/
function _register() internal {
- StoreCore.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
+ StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
}
/**
diff --git a/examples/minimal/packages/contracts/src/codegen/tables/MessageTable.sol b/examples/minimal/packages/contracts/src/codegen/tables/MessageTable.sol
index aadbffde7c..343a9aac91 100644
--- a/examples/minimal/packages/contracts/src/codegen/tables/MessageTable.sol
+++ b/examples/minimal/packages/contracts/src/codegen/tables/MessageTable.sol
@@ -3,9 +3,6 @@ pragma solidity >=0.8.24;
/* Autogenerated file. Do not edit manually. */
-// Import schema type
-import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol";
-
// Import store internals
import { IStore } from "@latticexyz/store/src/IStore.sol";
import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol";
@@ -14,48 +11,22 @@ import { Bytes } from "@latticexyz/store/src/Bytes.sol";
import { Memory } from "@latticexyz/store/src/Memory.sol";
import { SliceLib } from "@latticexyz/store/src/Slice.sol";
import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol";
-import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.sol";
-import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol";
+import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol";
+import { Schema } from "@latticexyz/store/src/Schema.sol";
import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol";
import { ResourceId } from "@latticexyz/store/src/ResourceId.sol";
-// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "MessageTable", typeId: RESOURCE_OFFCHAIN_TABLE });`
-ResourceId constant _tableId = ResourceId.wrap(0x6f7400000000000000000000000000004d6573736167655461626c6500000000);
-ResourceId constant MessageTableTableId = _tableId;
-
-FieldLayout constant _fieldLayout = FieldLayout.wrap(
- 0x0000000100000000000000000000000000000000000000000000000000000000
-);
-
library MessageTable {
- /**
- * @notice Get the table values' field layout.
- * @return _fieldLayout The field layout for the table.
- */
- function getFieldLayout() internal pure returns (FieldLayout) {
- return _fieldLayout;
- }
-
- /**
- * @notice Get the table's key schema.
- * @return _keySchema The key schema for the table.
- */
- function getKeySchema() internal pure returns (Schema) {
- SchemaType[] memory _keySchema = new SchemaType[](0);
+ // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "MessageTable", typeId: RESOURCE_OFFCHAIN_TABLE });`
+ ResourceId constant _tableId = ResourceId.wrap(0x6f7400000000000000000000000000004d6573736167655461626c6500000000);
- return SchemaLib.encode(_keySchema);
- }
+ FieldLayout constant _fieldLayout =
+ FieldLayout.wrap(0x0000000100000000000000000000000000000000000000000000000000000000);
- /**
- * @notice Get the table's value schema.
- * @return _valueSchema The value schema for the table.
- */
- function getValueSchema() internal pure returns (Schema) {
- SchemaType[] memory _valueSchema = new SchemaType[](1);
- _valueSchema[0] = SchemaType.STRING;
-
- return SchemaLib.encode(_valueSchema);
- }
+ // Hex-encoded key schema of ()
+ Schema constant _keySchema = Schema.wrap(0x0000000000000000000000000000000000000000000000000000000000000000);
+ // Hex-encoded value schema of (string)
+ Schema constant _valueSchema = Schema.wrap(0x00000001c5000000000000000000000000000000000000000000000000000000);
/**
* @notice Get the table's key field names.
@@ -78,14 +49,14 @@ library MessageTable {
* @notice Register the table with its config.
*/
function register() internal {
- StoreSwitch.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
+ StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
}
/**
* @notice Register the table with its config.
*/
function _register() internal {
- StoreCore.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
+ StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
}
/**
diff --git a/examples/minimal/packages/contracts/src/codegen/world/IChatSystem.sol b/examples/minimal/packages/contracts/src/codegen/world/IChatSystem.sol
index 48e977a1c7..9903a303cd 100644
--- a/examples/minimal/packages/contracts/src/codegen/world/IChatSystem.sol
+++ b/examples/minimal/packages/contracts/src/codegen/world/IChatSystem.sol
@@ -5,6 +5,7 @@ pragma solidity >=0.8.24;
/**
* @title IChatSystem
+ * @author MUD (https://mud.dev) by Lattice (https://lattice.xyz)
* @dev This interface is automatically generated from the corresponding system contract. Do not edit manually.
*/
interface IChatSystem {
diff --git a/examples/minimal/packages/contracts/src/codegen/world/IIncrementSystem.sol b/examples/minimal/packages/contracts/src/codegen/world/IIncrementSystem.sol
index 8989fe0eae..8b31683a45 100644
--- a/examples/minimal/packages/contracts/src/codegen/world/IIncrementSystem.sol
+++ b/examples/minimal/packages/contracts/src/codegen/world/IIncrementSystem.sol
@@ -5,6 +5,7 @@ pragma solidity >=0.8.24;
/**
* @title IIncrementSystem
+ * @author MUD (https://mud.dev) by Lattice (https://lattice.xyz)
* @dev This interface is automatically generated from the corresponding system contract. Do not edit manually.
*/
interface IIncrementSystem {
diff --git a/examples/minimal/packages/contracts/src/codegen/world/IInventorySystem.sol b/examples/minimal/packages/contracts/src/codegen/world/IInventorySystem.sol
index 2b59bb3249..98494820df 100644
--- a/examples/minimal/packages/contracts/src/codegen/world/IInventorySystem.sol
+++ b/examples/minimal/packages/contracts/src/codegen/world/IInventorySystem.sol
@@ -5,6 +5,7 @@ pragma solidity >=0.8.24;
/**
* @title IInventorySystem
+ * @author MUD (https://mud.dev) by Lattice (https://lattice.xyz)
* @dev This interface is automatically generated from the corresponding system contract. Do not edit manually.
*/
interface IInventorySystem {
diff --git a/examples/minimal/packages/contracts/src/codegen/world/IStructSystem.sol b/examples/minimal/packages/contracts/src/codegen/world/IStructSystem.sol
index 061c1bfce9..a95d9eb919 100644
--- a/examples/minimal/packages/contracts/src/codegen/world/IStructSystem.sol
+++ b/examples/minimal/packages/contracts/src/codegen/world/IStructSystem.sol
@@ -7,6 +7,7 @@ import { BytesStruct, StringStruct } from "./../../systems/structs.sol";
/**
* @title IStructSystem
+ * @author MUD (https://mud.dev) by Lattice (https://lattice.xyz)
* @dev This interface is automatically generated from the corresponding system contract. Do not edit manually.
*/
interface IStructSystem {
diff --git a/examples/minimal/packages/contracts/src/codegen/world/IWorld.sol b/examples/minimal/packages/contracts/src/codegen/world/IWorld.sol
index 31f6c0439b..6eb7845c59 100644
--- a/examples/minimal/packages/contracts/src/codegen/world/IWorld.sol
+++ b/examples/minimal/packages/contracts/src/codegen/world/IWorld.sol
@@ -12,10 +12,9 @@ import { IStructSystem } from "./IStructSystem.sol";
/**
* @title IWorld
+ * @author MUD (https://mud.dev) by Lattice (https://lattice.xyz)
* @notice This interface integrates all systems and associated function selectors
* that are dynamically registered in the World during deployment.
* @dev This is an autogenerated file; do not edit manually.
*/
-interface IWorld is IBaseWorld, IChatSystem, IIncrementSystem, IInventorySystem, IStructSystem {
-
-}
+interface IWorld is IBaseWorld, IChatSystem, IIncrementSystem, IInventorySystem, IStructSystem {}
diff --git a/examples/minimal/packages/contracts/test/ChatNamespaced.t.sol b/examples/minimal/packages/contracts/test/ChatNamespaced.t.sol
index eaecdb806a..fe27846c43 100644
--- a/examples/minimal/packages/contracts/test/ChatNamespaced.t.sol
+++ b/examples/minimal/packages/contracts/test/ChatNamespaced.t.sol
@@ -4,10 +4,10 @@ pragma solidity >=0.8.24;
import "forge-std/Test.sol";
import { MudTest } from "@latticexyz/world/test/MudTest.t.sol";
import { getKeysWithValue } from "@latticexyz/world-modules/src/modules/keyswithvalue/getKeysWithValue.sol";
-import { StoreCore } from "@latticexyz/store/src/StoreCore.sol";
+import { IStoreEvents } from "@latticexyz/store/src/IStoreEvents.sol";
import { IWorld } from "../src/codegen/world/IWorld.sol";
-import { MessageTable, MessageTableTableId } from "../src/codegen/index.sol";
+import { MessageTable } from "../src/codegen/index.sol";
import { IChatNamespacedSystem } from "../src/interfaces/IChatNamespacedSystem.sol";
contract ChatNamespacedTest is MudTest {
@@ -15,8 +15,8 @@ contract ChatNamespacedTest is MudTest {
bytes32[] memory keyTuple;
string memory value = "test";
vm.expectEmit(true, true, true, true);
- emit StoreCore.Store_SetRecord(
- MessageTableTableId,
+ emit IStoreEvents.Store_SetRecord(
+ MessageTable._tableId,
keyTuple,
new bytes(0),
MessageTable.encodeLengths(value),
diff --git a/examples/minimal/packages/contracts/test/CounterTest.t.sol b/examples/minimal/packages/contracts/test/CounterTest.t.sol
index 81cfc6df7d..1c26465979 100644
--- a/examples/minimal/packages/contracts/test/CounterTest.t.sol
+++ b/examples/minimal/packages/contracts/test/CounterTest.t.sol
@@ -6,7 +6,7 @@ import { MudTest } from "@latticexyz/world/test/MudTest.t.sol";
import { getKeysWithValue } from "@latticexyz/world-modules/src/modules/keyswithvalue/getKeysWithValue.sol";
import { IWorld } from "../src/codegen/world/IWorld.sol";
-import { CounterTable, CounterTableTableId } from "../src/codegen/index.sol";
+import { CounterTable } from "../src/codegen/index.sol";
contract CounterTest is MudTest {
function testWorldExists() public {
@@ -32,7 +32,7 @@ contract CounterTest is MudTest {
// TODO: re-enable the KeysWithValueModule in mud.config.ts once it supports singleton keys
// function testKeysWithValue() public {
// uint32 counter = CounterTable.get();
- // bytes32[] memory keysWithValue = getKeysWithValue(CounterTableTableId, CounterTable.encode(counter));
+ // bytes32[] memory keysWithValue = getKeysWithValue(CounterTable._tableId, CounterTable.encode(counter));
// assertEq(keysWithValue.length, 1);
// }
}
diff --git a/examples/minimal/packages/contracts/test/StructTest.t.sol b/examples/minimal/packages/contracts/test/StructTest.t.sol
index a6789628ef..b57273ff28 100644
--- a/examples/minimal/packages/contracts/test/StructTest.t.sol
+++ b/examples/minimal/packages/contracts/test/StructTest.t.sol
@@ -6,7 +6,7 @@ import { MudTest } from "@latticexyz/world/test/MudTest.t.sol";
import { getKeysWithValue } from "@latticexyz/world-modules/src/modules/keyswithvalue/getKeysWithValue.sol";
import { IWorld } from "../src/codegen/world/IWorld.sol";
-import { CounterTable, CounterTableTableId } from "../src/codegen/index.sol";
+import { CounterTable } from "../src/codegen/index.sol";
import { BytesStruct, StringStruct } from "../src/systems/structs.sol";
contract StructTest is MudTest {
diff --git a/examples/minimal/pnpm-lock.yaml b/examples/minimal/pnpm-lock.yaml
index 932aaf3a72..f14ec12a18 100644
--- a/examples/minimal/pnpm-lock.yaml
+++ b/examples/minimal/pnpm-lock.yaml
@@ -339,11 +339,11 @@ importers:
specifier: https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1
version: github.com/foundry-rs/forge-std/74cfb77e308dd188d2f58864aaf44963ae6b88b1
prettier:
- specifier: ^2.6.2
- version: 2.6.2
+ specifier: 3.2.5
+ version: 3.2.5
prettier-plugin-solidity:
- specifier: 1.1.3
- version: 1.1.3(prettier@2.6.2)
+ specifier: 1.3.1
+ version: 1.3.1(prettier@3.2.5)
rimraf:
specifier: ^3.0.2
version: 3.0.2
@@ -1032,6 +1032,10 @@ packages:
antlr4ts: 0.5.0-alpha.4
dev: true
+ /@solidity-parser/parser@0.17.0:
+ resolution: {integrity: sha512-Nko8R0/kUo391jsEHHxrGM07QFdnPGvlmox4rmH0kNiNAashItAilhy4Mv4pK5gQmW5f4sXAF58fwJbmlkGcVw==}
+ dev: true
+
/@solidstate/contracts@0.0.52:
resolution: {integrity: sha512-xSBn5oLnfYtgNYrsRq/COlWHt0NxK26PFQ3FvI2DDMAFpZKFsffGLzUl8umezj2gVKpN7EZ+EVLdPKjqx6eUOw==}
dev: true
@@ -2885,22 +2889,16 @@ packages:
engines: {node: '>= 0.8.0'}
dev: true
- /prettier-plugin-solidity@1.1.3(prettier@2.6.2):
- resolution: {integrity: sha512-fQ9yucPi2sBbA2U2Xjh6m4isUTJ7S7QLc/XDDsktqqxYfTwdYKJ0EnnywXHwCGAaYbQNK+HIYPL1OemxuMsgeg==}
- engines: {node: '>=12'}
+ /prettier-plugin-solidity@1.3.1(prettier@3.2.5):
+ resolution: {integrity: sha512-MN4OP5I2gHAzHZG1wcuJl0FsLS3c4Cc5494bbg+6oQWBPuEamjwDvmGfFMZ6NFzsh3Efd9UUxeT7ImgjNH4ozA==}
+ engines: {node: '>=16'}
peerDependencies:
- prettier: '>=2.3.0 || >=3.0.0-alpha.0'
+ prettier: '>=2.3.0'
dependencies:
- '@solidity-parser/parser': 0.16.0
- prettier: 2.6.2
- semver: 7.5.0
- solidity-comments-extractor: 0.0.7
- dev: true
-
- /prettier@2.6.2:
- resolution: {integrity: sha512-PkUpF+qoXTqhOeWL9fu7As8LXsIUZ1WYaJiY/a7McAQzxjk82OF0tibkFXVCDImZtWxbvojFjerkiLb0/q8mew==}
- engines: {node: '>=10.13.0'}
- hasBin: true
+ '@solidity-parser/parser': 0.17.0
+ prettier: 3.2.5
+ semver: 7.6.0
+ solidity-comments-extractor: 0.0.8
dev: true
/prettier@2.8.8:
@@ -2911,6 +2909,12 @@ packages:
dev: true
optional: true
+ /prettier@3.2.5:
+ resolution: {integrity: sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==}
+ engines: {node: '>=14'}
+ hasBin: true
+ dev: true
+
/prop-types@15.8.1:
resolution: {integrity: sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==}
dependencies:
@@ -3096,6 +3100,14 @@ packages:
lru-cache: 6.0.0
dev: true
+ /semver@7.6.0:
+ resolution: {integrity: sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==}
+ engines: {node: '>=10'}
+ hasBin: true
+ dependencies:
+ lru-cache: 6.0.0
+ dev: true
+
/shallowequal@1.1.0:
resolution: {integrity: sha512-y0m1JoUZSlPAjXVtPPW70aZWfIL/dSP7AFkRnniLCrK/8MDKog3TySTBmckD+RObVxH0v4Tox67+F14PdED2oQ==}
dev: false
@@ -3167,8 +3179,8 @@ packages:
prettier: 2.8.8
dev: true
- /solidity-comments-extractor@0.0.7:
- resolution: {integrity: sha512-wciNMLg/Irp8OKGrh3S2tfvZiZ0NEyILfcRCXCD4mp7SgK/i9gzLfhY2hY7VMCQJ3kH9UB9BzNdibIVMchzyYw==}
+ /solidity-comments-extractor@0.0.8:
+ resolution: {integrity: sha512-htM7Vn6LhHreR+EglVMd2s+sZhcXAirB1Zlyrv5zBuTxieCvjfnRpd7iZk75m/u6NOlEyQ94C6TWbBn2cY7w8g==}
dev: true
/source-map-js@1.0.2:
diff --git a/examples/multiple-accounts/package.json b/examples/multiple-accounts/package.json
index 16893bf7de..9e94423c4d 100644
--- a/examples/multiple-accounts/package.json
+++ b/examples/multiple-accounts/package.json
@@ -14,7 +14,6 @@
"devDependencies": {
"@latticexyz/cli": "link:../../packages/cli",
"@types/debug": "4.1.7",
- "@types/prettier": "2.7.2",
"@typescript-eslint/eslint-plugin": "5.46.1",
"@typescript-eslint/parser": "5.46.1",
"eslint": "8.29.0",
diff --git a/examples/multiple-accounts/packages/client/src/index.tsx b/examples/multiple-accounts/packages/client/src/index.tsx
index 3ba2a44052..c9b662c9f0 100644
--- a/examples/multiple-accounts/packages/client/src/index.tsx
+++ b/examples/multiple-accounts/packages/client/src/index.tsx
@@ -13,7 +13,7 @@ setup().then(async (result) => {
root.render(
-
+ ,
);
// https://vitejs.dev/guide/env-and-mode.html
diff --git a/examples/multiple-accounts/packages/contracts/package.json b/examples/multiple-accounts/packages/contracts/package.json
index 6b71970f9e..461ceb6001 100644
--- a/examples/multiple-accounts/packages/contracts/package.json
+++ b/examples/multiple-accounts/packages/contracts/package.json
@@ -25,8 +25,8 @@
"@types/node": "^18.15.11",
"ds-test": "https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0",
"forge-std": "https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1",
- "prettier": "^2.6.2",
- "prettier-plugin-solidity": "1.1.3",
+ "prettier": "3.2.5",
+ "prettier-plugin-solidity": "1.3.1",
"solhint": "^3.3.7",
"solhint-config-mud": "2.0.0-next.15",
"solhint-plugin-mud": "2.0.0-next.15"
diff --git a/examples/multiple-accounts/packages/contracts/src/codegen/index.sol b/examples/multiple-accounts/packages/contracts/src/codegen/index.sol
index 0746454b44..5813f4d78d 100644
--- a/examples/multiple-accounts/packages/contracts/src/codegen/index.sol
+++ b/examples/multiple-accounts/packages/contracts/src/codegen/index.sol
@@ -3,4 +3,4 @@ pragma solidity >=0.8.24;
/* Autogenerated file. Do not edit manually. */
-import { LastCall, LastCallData, LastCallTableId } from "./tables/LastCall.sol";
+import { LastCall, LastCallData } from "./tables/LastCall.sol";
diff --git a/examples/multiple-accounts/packages/contracts/src/codegen/tables/LastCall.sol b/examples/multiple-accounts/packages/contracts/src/codegen/tables/LastCall.sol
index 63fc9b3fb1..6ae2f1ad37 100644
--- a/examples/multiple-accounts/packages/contracts/src/codegen/tables/LastCall.sol
+++ b/examples/multiple-accounts/packages/contracts/src/codegen/tables/LastCall.sol
@@ -3,9 +3,6 @@ pragma solidity >=0.8.24;
/* Autogenerated file. Do not edit manually. */
-// Import schema type
-import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol";
-
// Import store internals
import { IStore } from "@latticexyz/store/src/IStore.sol";
import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol";
@@ -14,55 +11,27 @@ import { Bytes } from "@latticexyz/store/src/Bytes.sol";
import { Memory } from "@latticexyz/store/src/Memory.sol";
import { SliceLib } from "@latticexyz/store/src/Slice.sol";
import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol";
-import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.sol";
-import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol";
+import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol";
+import { Schema } from "@latticexyz/store/src/Schema.sol";
import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol";
import { ResourceId } from "@latticexyz/store/src/ResourceId.sol";
-// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "LastCall", name: "LastCall", typeId: RESOURCE_TABLE });`
-ResourceId constant _tableId = ResourceId.wrap(0x74624c61737443616c6c0000000000004c61737443616c6c0000000000000000);
-ResourceId constant LastCallTableId = _tableId;
-
-FieldLayout constant _fieldLayout = FieldLayout.wrap(
- 0x0034020020140000000000000000000000000000000000000000000000000000
-);
-
struct LastCallData {
uint256 callTime;
address sender;
}
library LastCall {
- /**
- * @notice Get the table values' field layout.
- * @return _fieldLayout The field layout for the table.
- */
- function getFieldLayout() internal pure returns (FieldLayout) {
- return _fieldLayout;
- }
-
- /**
- * @notice Get the table's key schema.
- * @return _keySchema The key schema for the table.
- */
- function getKeySchema() internal pure returns (Schema) {
- SchemaType[] memory _keySchema = new SchemaType[](1);
- _keySchema[0] = SchemaType.ADDRESS;
+ // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "LastCall", name: "LastCall", typeId: RESOURCE_TABLE });`
+ ResourceId constant _tableId = ResourceId.wrap(0x74624c61737443616c6c0000000000004c61737443616c6c0000000000000000);
- return SchemaLib.encode(_keySchema);
- }
+ FieldLayout constant _fieldLayout =
+ FieldLayout.wrap(0x0034020020140000000000000000000000000000000000000000000000000000);
- /**
- * @notice Get the table's value schema.
- * @return _valueSchema The value schema for the table.
- */
- function getValueSchema() internal pure returns (Schema) {
- SchemaType[] memory _valueSchema = new SchemaType[](2);
- _valueSchema[0] = SchemaType.UINT256;
- _valueSchema[1] = SchemaType.ADDRESS;
-
- return SchemaLib.encode(_valueSchema);
- }
+ // Hex-encoded key schema of (address)
+ Schema constant _keySchema = Schema.wrap(0x0014010061000000000000000000000000000000000000000000000000000000);
+ // Hex-encoded value schema of (uint256, address)
+ Schema constant _valueSchema = Schema.wrap(0x003402001f610000000000000000000000000000000000000000000000000000);
/**
* @notice Get the table's key field names.
@@ -87,14 +56,14 @@ library LastCall {
* @notice Register the table with its config.
*/
function register() internal {
- StoreSwitch.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
+ StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
}
/**
* @notice Register the table with its config.
*/
function _register() internal {
- StoreCore.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
+ StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
}
/**
diff --git a/examples/multiple-accounts/packages/contracts/src/codegen/world/ILastCallSystem.sol b/examples/multiple-accounts/packages/contracts/src/codegen/world/ILastCallSystem.sol
index 85bccbafea..69c45f210c 100644
--- a/examples/multiple-accounts/packages/contracts/src/codegen/world/ILastCallSystem.sol
+++ b/examples/multiple-accounts/packages/contracts/src/codegen/world/ILastCallSystem.sol
@@ -5,6 +5,7 @@ pragma solidity >=0.8.24;
/**
* @title ILastCallSystem
+ * @author MUD (https://mud.dev) by Lattice (https://lattice.xyz)
* @dev This interface is automatically generated from the corresponding system contract. Do not edit manually.
*/
interface ILastCallSystem {
diff --git a/examples/multiple-accounts/packages/contracts/src/codegen/world/ITasksSystem.sol b/examples/multiple-accounts/packages/contracts/src/codegen/world/ITasksSystem.sol
index 81127a78eb..4a18791ccf 100644
--- a/examples/multiple-accounts/packages/contracts/src/codegen/world/ITasksSystem.sol
+++ b/examples/multiple-accounts/packages/contracts/src/codegen/world/ITasksSystem.sol
@@ -5,6 +5,7 @@ pragma solidity >=0.8.24;
/**
* @title ITasksSystem
+ * @author MUD (https://mud.dev) by Lattice (https://lattice.xyz)
* @dev This interface is automatically generated from the corresponding system contract. Do not edit manually.
*/
interface ITasksSystem {
diff --git a/examples/multiple-accounts/packages/contracts/src/codegen/world/IWorld.sol b/examples/multiple-accounts/packages/contracts/src/codegen/world/IWorld.sol
index a6f78a1166..2c909e6f4f 100644
--- a/examples/multiple-accounts/packages/contracts/src/codegen/world/IWorld.sol
+++ b/examples/multiple-accounts/packages/contracts/src/codegen/world/IWorld.sol
@@ -9,10 +9,9 @@ import { ILastCallSystem } from "./ILastCallSystem.sol";
/**
* @title IWorld
+ * @author MUD (https://mud.dev) by Lattice (https://lattice.xyz)
* @notice This interface integrates all systems and associated function selectors
* that are dynamically registered in the World during deployment.
* @dev This is an autogenerated file; do not edit manually.
*/
-interface IWorld is IBaseWorld, ILastCallSystem {
-
-}
+interface IWorld is IBaseWorld, ILastCallSystem {}
diff --git a/examples/multiple-accounts/pnpm-lock.yaml b/examples/multiple-accounts/pnpm-lock.yaml
index 7015942044..878afde32c 100644
--- a/examples/multiple-accounts/pnpm-lock.yaml
+++ b/examples/multiple-accounts/pnpm-lock.yaml
@@ -14,9 +14,6 @@ importers:
'@types/debug':
specifier: 4.1.7
version: 4.1.7
- '@types/prettier':
- specifier: 2.7.2
- version: 2.7.2
'@typescript-eslint/eslint-plugin':
specifier: 5.46.1
version: 5.46.1(@typescript-eslint/parser@5.46.1)(eslint@8.29.0)(typescript@5.1.6)
@@ -128,11 +125,11 @@ importers:
specifier: https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1
version: github.com/foundry-rs/forge-std/74cfb77e308dd188d2f58864aaf44963ae6b88b1
prettier:
- specifier: ^2.6.2
- version: 2.8.8
+ specifier: 3.2.5
+ version: 3.2.5
prettier-plugin-solidity:
- specifier: 1.1.3
- version: 1.1.3(prettier@2.8.8)
+ specifier: 1.3.1
+ version: 1.3.1(prettier@3.2.5)
solhint:
specifier: ^3.3.7
version: 3.6.2(typescript@5.1.6)
@@ -700,6 +697,10 @@ packages:
antlr4ts: 0.5.0-alpha.4
dev: true
+ /@solidity-parser/parser@0.17.0:
+ resolution: {integrity: sha512-Nko8R0/kUo391jsEHHxrGM07QFdnPGvlmox4rmH0kNiNAashItAilhy4Mv4pK5gQmW5f4sXAF58fwJbmlkGcVw==}
+ dev: true
+
/@types/debug@4.1.7:
resolution: {integrity: sha512-9AonUzyTjXXhEOa0DnqpzZi6VHlqKMswga9EXjpXnnqxwLtdvPPtlO8evrI5D9S6asFRCQ6v+wpiUKbw+vKqyg==}
dependencies:
@@ -720,10 +721,6 @@ packages:
undici-types: 5.26.5
dev: true
- /@types/prettier@2.7.2:
- resolution: {integrity: sha512-KufADq8uQqo1pYKVIYzfKbJfBAc0sOeXqGbFaSpv8MRmC/zXgowNZmFcbngndGk922QDmOASEXUZCaY48gs4cg==}
- dev: true
-
/@types/prop-types@15.7.11:
resolution: {integrity: sha512-ga8y9v9uyeiLdpKddhxYQkxNDrfvuPrlFb0N1qnZZByvcElJaXthF1UhvCh9TLWJBEHeNtdnbysW7Y6Uq8CVng==}
dev: true
@@ -2285,22 +2282,30 @@ packages:
engines: {node: '>= 0.8.0'}
dev: true
- /prettier-plugin-solidity@1.1.3(prettier@2.8.8):
- resolution: {integrity: sha512-fQ9yucPi2sBbA2U2Xjh6m4isUTJ7S7QLc/XDDsktqqxYfTwdYKJ0EnnywXHwCGAaYbQNK+HIYPL1OemxuMsgeg==}
- engines: {node: '>=12'}
+ /prettier-plugin-solidity@1.3.1(prettier@3.2.5):
+ resolution: {integrity: sha512-MN4OP5I2gHAzHZG1wcuJl0FsLS3c4Cc5494bbg+6oQWBPuEamjwDvmGfFMZ6NFzsh3Efd9UUxeT7ImgjNH4ozA==}
+ engines: {node: '>=16'}
peerDependencies:
- prettier: '>=2.3.0 || >=3.0.0-alpha.0'
+ prettier: '>=2.3.0'
dependencies:
- '@solidity-parser/parser': 0.16.2
- prettier: 2.8.8
+ '@solidity-parser/parser': 0.17.0
+ prettier: 3.2.5
semver: 7.5.4
- solidity-comments-extractor: 0.0.7
+ solidity-comments-extractor: 0.0.8
dev: true
/prettier@2.8.8:
resolution: {integrity: sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==}
engines: {node: '>=10.13.0'}
hasBin: true
+ requiresBuild: true
+ dev: true
+ optional: true
+
+ /prettier@3.2.5:
+ resolution: {integrity: sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==}
+ engines: {node: '>=14'}
+ hasBin: true
dev: true
/prop-types@15.8.1:
@@ -2539,8 +2544,8 @@ packages:
- typescript
dev: true
- /solidity-comments-extractor@0.0.7:
- resolution: {integrity: sha512-wciNMLg/Irp8OKGrh3S2tfvZiZ0NEyILfcRCXCD4mp7SgK/i9gzLfhY2hY7VMCQJ3kH9UB9BzNdibIVMchzyYw==}
+ /solidity-comments-extractor@0.0.8:
+ resolution: {integrity: sha512-htM7Vn6LhHreR+EglVMd2s+sZhcXAirB1Zlyrv5zBuTxieCvjfnRpd7iZk75m/u6NOlEyQ94C6TWbBn2cY7w8g==}
dev: true
/source-map-js@1.0.2:
diff --git a/package.json b/package.json
index 17c7bc3c33..b9abb3e9e1 100644
--- a/package.json
+++ b/package.json
@@ -45,8 +45,8 @@
"execa": "^7.0.0",
"husky": ">=6",
"lint-staged": ">=10",
- "prettier": "^2.8.4",
- "prettier-plugin-solidity": "1.1.3",
+ "prettier": "3.2.5",
+ "prettier-plugin-solidity": "1.3.1",
"rimraf": "^3.0.2",
"turbo": "^1.9.3",
"typescript": "5.1.6"
diff --git a/packages/abi-ts/src/abi-ts.ts b/packages/abi-ts/src/abi-ts.ts
index 8d12d0ee0a..a6093d52ec 100755
--- a/packages/abi-ts/src/abi-ts.ts
+++ b/packages/abi-ts/src/abi-ts.ts
@@ -21,7 +21,7 @@ yargs(hideBin(process.argv))
console.error(chalk.red(msg));
if (msg.includes("Missing required argument")) {
console.log(
- chalk.yellow(`Run 'pnpm abi-ts ${process.argv[2]} --help' for a list of available and required arguments.`)
+ chalk.yellow(`Run 'pnpm abi-ts ${process.argv[2]} --help' for a list of available and required arguments.`),
);
}
diff --git a/packages/block-logs-stream/CHANGELOG.md b/packages/block-logs-stream/CHANGELOG.md
index 545ea08a88..7e9de47863 100644
--- a/packages/block-logs-stream/CHANGELOG.md
+++ b/packages/block-logs-stream/CHANGELOG.md
@@ -418,7 +418,7 @@
const latestBlockNumber$ = latestBlock$.pipe(
filter(isNonPendingBlock),
- map((block) => block.number)
+ map((block) => block.number),
);
latestBlockNumber$
@@ -434,7 +434,7 @@
"event StoreEphemeralRecord(bytes32 table, bytes32[] key, bytes data)",
]),
}),
- mergeMap(({ logs }) => from(groupLogsByBlockNumber(logs)))
+ mergeMap(({ logs }) => from(groupLogsByBlockNumber(logs))),
)
.subscribe((block) => {
console.log("got events for block", block);
diff --git a/packages/block-logs-stream/README.md b/packages/block-logs-stream/README.md
index a76e15825f..0d7ccc924f 100644
--- a/packages/block-logs-stream/README.md
+++ b/packages/block-logs-stream/README.md
@@ -32,7 +32,7 @@ latestBlockNumber$
"event Store_DeleteRecord(bytes32 indexed tableId, bytes32[] keyTuple)",
]),
}),
- mergeMap(({ logs }) => from(groupLogsByBlockNumber(logs)))
+ mergeMap(({ logs }) => from(groupLogsByBlockNumber(logs))),
)
.subscribe((block) => {
console.log("got events for block", block);
diff --git a/packages/block-logs-stream/src/blockRangeToLogs.test.ts b/packages/block-logs-stream/src/blockRangeToLogs.test.ts
index a0474841b8..607a8dea77 100644
--- a/packages/block-logs-stream/src/blockRangeToLogs.test.ts
+++ b/packages/block-logs-stream/src/blockRangeToLogs.test.ts
@@ -41,7 +41,7 @@ describe("blockRangeToLogs", () => {
publicClient,
address: "0x",
events: [],
- })
+ }),
);
(async (): Promise => {
diff --git a/packages/block-logs-stream/src/blockRangeToLogs.ts b/packages/block-logs-stream/src/blockRangeToLogs.ts
index 825320f14d..9a87da6242 100644
--- a/packages/block-logs-stream/src/blockRangeToLogs.ts
+++ b/packages/block-logs-stream/src/blockRangeToLogs.ts
@@ -65,12 +65,12 @@ export function blockRangeToLogs({
fromBlock,
toBlock,
maxBlockRange,
- })
+ }),
).pipe(
tap(({ toBlock }) => {
fromBlock = toBlock + 1n;
- })
+ }),
);
- })
+ }),
);
}
diff --git a/packages/block-logs-stream/src/fetchLogs.test.ts b/packages/block-logs-stream/src/fetchLogs.test.ts
index 7f95f507b9..4bd28cb1c2 100644
--- a/packages/block-logs-stream/src/fetchLogs.test.ts
+++ b/packages/block-logs-stream/src/fetchLogs.test.ts
@@ -150,7 +150,7 @@ describe("fetchLogs", () => {
code: -32005,
message: "block range exceeded",
},
- })
+ }),
);
}
@@ -374,7 +374,7 @@ describe("fetchLogs", () => {
code: -32005,
message: "rate limit exceeded",
},
- })
+ }),
);
}
diff --git a/packages/block-logs-stream/src/groupLogsByBlockNumber.ts b/packages/block-logs-stream/src/groupLogsByBlockNumber.ts
index b0656acfbc..37fd614d35 100644
--- a/packages/block-logs-stream/src/groupLogsByBlockNumber.ts
+++ b/packages/block-logs-stream/src/groupLogsByBlockNumber.ts
@@ -24,7 +24,7 @@ export type GroupLogsByBlockNumberResult = {
*/
export function groupLogsByBlockNumber(
logs: readonly TLog[],
- toBlock?: BlockNumber
+ toBlock?: BlockNumber,
): GroupLogsByBlockNumberResult {
const blockNumbers = Array.from(new Set(logs.map((log) => log.blockNumber)));
blockNumbers.sort(bigIntSort);
diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md
index 0bec448c15..705083a33e 100644
--- a/packages/cli/CHANGELOG.md
+++ b/packages/cli/CHANGELOG.md
@@ -1135,7 +1135,7 @@
.pipe(
map((block) => Number(block.timestamp) * 1000), // Map to timestamp in ms
filter((blockTimestamp) => blockTimestamp !== clock.lastUpdateTime), // Ignore if the clock was already refreshed with this block
- filter((blockTimestamp) => blockTimestamp !== clock.currentTime) // Ignore if the current local timestamp is correct
+ filter((blockTimestamp) => blockTimestamp !== clock.currentTime), // Ignore if the current local timestamp is correct
)
.subscribe(clock.update); // Update the local clock
```
diff --git a/packages/cli/contracts/src/codegen/index.sol b/packages/cli/contracts/src/codegen/index.sol
index 80f2b14a6f..a785c0c5bd 100644
--- a/packages/cli/contracts/src/codegen/index.sol
+++ b/packages/cli/contracts/src/codegen/index.sol
@@ -3,9 +3,9 @@ pragma solidity >=0.8.24;
/* Autogenerated file. Do not edit manually. */
-import { Statics, StaticsData, StaticsTableId } from "./tables/Statics.sol";
-import { Dynamics1, Dynamics1Data, Dynamics1TableId } from "./tables/Dynamics1.sol";
-import { Dynamics2, Dynamics2Data, Dynamics2TableId } from "./tables/Dynamics2.sol";
-import { Singleton, SingletonTableId } from "./tables/Singleton.sol";
-import { Offchain, OffchainTableId } from "./tables/Offchain.sol";
-import { UserTyped, UserTypedData, UserTypedTableId } from "./tables/UserTyped.sol";
+import { Statics, StaticsData } from "./tables/Statics.sol";
+import { Dynamics1, Dynamics1Data } from "./tables/Dynamics1.sol";
+import { Dynamics2, Dynamics2Data } from "./tables/Dynamics2.sol";
+import { Singleton } from "./tables/Singleton.sol";
+import { Offchain } from "./tables/Offchain.sol";
+import { UserTyped, UserTypedData } from "./tables/UserTyped.sol";
diff --git a/packages/cli/contracts/src/codegen/tables/Dynamics1.sol b/packages/cli/contracts/src/codegen/tables/Dynamics1.sol
index 7267718a35..c9f147afdd 100644
--- a/packages/cli/contracts/src/codegen/tables/Dynamics1.sol
+++ b/packages/cli/contracts/src/codegen/tables/Dynamics1.sol
@@ -3,9 +3,6 @@ pragma solidity >=0.8.24;
/* Autogenerated file. Do not edit manually. */
-// Import schema type
-import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol";
-
// Import store internals
import { IStore } from "@latticexyz/store/src/IStore.sol";
import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol";
@@ -14,19 +11,11 @@ import { Bytes } from "@latticexyz/store/src/Bytes.sol";
import { Memory } from "@latticexyz/store/src/Memory.sol";
import { SliceLib } from "@latticexyz/store/src/Slice.sol";
import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol";
-import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.sol";
-import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol";
+import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol";
+import { Schema } from "@latticexyz/store/src/Schema.sol";
import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol";
import { ResourceId } from "@latticexyz/store/src/ResourceId.sol";
-// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "Dynamics1", typeId: RESOURCE_TABLE });`
-ResourceId constant _tableId = ResourceId.wrap(0x7462000000000000000000000000000044796e616d6963733100000000000000);
-ResourceId constant Dynamics1TableId = _tableId;
-
-FieldLayout constant _fieldLayout = FieldLayout.wrap(
- 0x0000000500000000000000000000000000000000000000000000000000000000
-);
-
struct Dynamics1Data {
bytes32[1] staticB32;
int32[2] staticI32;
@@ -36,39 +25,16 @@ struct Dynamics1Data {
}
library Dynamics1 {
- /**
- * @notice Get the table values' field layout.
- * @return _fieldLayout The field layout for the table.
- */
- function getFieldLayout() internal pure returns (FieldLayout) {
- return _fieldLayout;
- }
-
- /**
- * @notice Get the table's key schema.
- * @return _keySchema The key schema for the table.
- */
- function getKeySchema() internal pure returns (Schema) {
- SchemaType[] memory _keySchema = new SchemaType[](1);
- _keySchema[0] = SchemaType.BYTES32;
+ // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "Dynamics1", typeId: RESOURCE_TABLE });`
+ ResourceId constant _tableId = ResourceId.wrap(0x7462000000000000000000000000000044796e616d6963733100000000000000);
- return SchemaLib.encode(_keySchema);
- }
+ FieldLayout constant _fieldLayout =
+ FieldLayout.wrap(0x0000000500000000000000000000000000000000000000000000000000000000);
- /**
- * @notice Get the table's value schema.
- * @return _valueSchema The value schema for the table.
- */
- function getValueSchema() internal pure returns (Schema) {
- SchemaType[] memory _valueSchema = new SchemaType[](5);
- _valueSchema[0] = SchemaType.BYTES32_ARRAY;
- _valueSchema[1] = SchemaType.INT32_ARRAY;
- _valueSchema[2] = SchemaType.UINT128_ARRAY;
- _valueSchema[3] = SchemaType.ADDRESS_ARRAY;
- _valueSchema[4] = SchemaType.BOOL_ARRAY;
-
- return SchemaLib.encode(_valueSchema);
- }
+ // Hex-encoded key schema of (bytes32)
+ Schema constant _keySchema = Schema.wrap(0x002001005f000000000000000000000000000000000000000000000000000000);
+ // Hex-encoded value schema of (bytes32[], int32[], uint128[], address[], bool[])
+ Schema constant _valueSchema = Schema.wrap(0x00000005c18571c3c20000000000000000000000000000000000000000000000);
/**
* @notice Get the table's key field names.
@@ -96,14 +62,14 @@ library Dynamics1 {
* @notice Register the table with its config.
*/
function register() internal {
- StoreSwitch.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
+ StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
}
/**
* @notice Register the table with its config.
*/
function _register() internal {
- StoreCore.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
+ StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
}
/**
diff --git a/packages/cli/contracts/src/codegen/tables/Dynamics2.sol b/packages/cli/contracts/src/codegen/tables/Dynamics2.sol
index 4c877d16a6..07bc193055 100644
--- a/packages/cli/contracts/src/codegen/tables/Dynamics2.sol
+++ b/packages/cli/contracts/src/codegen/tables/Dynamics2.sol
@@ -3,9 +3,6 @@ pragma solidity >=0.8.24;
/* Autogenerated file. Do not edit manually. */
-// Import schema type
-import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol";
-
// Import store internals
import { IStore } from "@latticexyz/store/src/IStore.sol";
import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol";
@@ -14,19 +11,11 @@ import { Bytes } from "@latticexyz/store/src/Bytes.sol";
import { Memory } from "@latticexyz/store/src/Memory.sol";
import { SliceLib } from "@latticexyz/store/src/Slice.sol";
import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol";
-import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.sol";
-import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol";
+import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol";
+import { Schema } from "@latticexyz/store/src/Schema.sol";
import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol";
import { ResourceId } from "@latticexyz/store/src/ResourceId.sol";
-// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "Dynamics2", typeId: RESOURCE_TABLE });`
-ResourceId constant _tableId = ResourceId.wrap(0x7462000000000000000000000000000044796e616d6963733200000000000000);
-ResourceId constant Dynamics2TableId = _tableId;
-
-FieldLayout constant _fieldLayout = FieldLayout.wrap(
- 0x0000000300000000000000000000000000000000000000000000000000000000
-);
-
struct Dynamics2Data {
uint64[] u64;
string str;
@@ -34,37 +23,16 @@ struct Dynamics2Data {
}
library Dynamics2 {
- /**
- * @notice Get the table values' field layout.
- * @return _fieldLayout The field layout for the table.
- */
- function getFieldLayout() internal pure returns (FieldLayout) {
- return _fieldLayout;
- }
-
- /**
- * @notice Get the table's key schema.
- * @return _keySchema The key schema for the table.
- */
- function getKeySchema() internal pure returns (Schema) {
- SchemaType[] memory _keySchema = new SchemaType[](1);
- _keySchema[0] = SchemaType.BYTES32;
+ // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "Dynamics2", typeId: RESOURCE_TABLE });`
+ ResourceId constant _tableId = ResourceId.wrap(0x7462000000000000000000000000000044796e616d6963733200000000000000);
- return SchemaLib.encode(_keySchema);
- }
+ FieldLayout constant _fieldLayout =
+ FieldLayout.wrap(0x0000000300000000000000000000000000000000000000000000000000000000);
- /**
- * @notice Get the table's value schema.
- * @return _valueSchema The value schema for the table.
- */
- function getValueSchema() internal pure returns (Schema) {
- SchemaType[] memory _valueSchema = new SchemaType[](3);
- _valueSchema[0] = SchemaType.UINT64_ARRAY;
- _valueSchema[1] = SchemaType.STRING;
- _valueSchema[2] = SchemaType.BYTES;
-
- return SchemaLib.encode(_valueSchema);
- }
+ // Hex-encoded key schema of (bytes32)
+ Schema constant _keySchema = Schema.wrap(0x002001005f000000000000000000000000000000000000000000000000000000);
+ // Hex-encoded value schema of (uint64[], string, bytes)
+ Schema constant _valueSchema = Schema.wrap(0x0000000369c5c400000000000000000000000000000000000000000000000000);
/**
* @notice Get the table's key field names.
@@ -90,14 +58,14 @@ library Dynamics2 {
* @notice Register the table with its config.
*/
function register() internal {
- StoreSwitch.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
+ StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
}
/**
* @notice Register the table with its config.
*/
function _register() internal {
- StoreCore.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
+ StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
}
/**
diff --git a/packages/cli/contracts/src/codegen/tables/Offchain.sol b/packages/cli/contracts/src/codegen/tables/Offchain.sol
index 7d83afabc0..16732168f8 100644
--- a/packages/cli/contracts/src/codegen/tables/Offchain.sol
+++ b/packages/cli/contracts/src/codegen/tables/Offchain.sol
@@ -3,9 +3,6 @@ pragma solidity >=0.8.24;
/* Autogenerated file. Do not edit manually. */
-// Import schema type
-import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol";
-
// Import store internals
import { IStore } from "@latticexyz/store/src/IStore.sol";
import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol";
@@ -14,49 +11,22 @@ import { Bytes } from "@latticexyz/store/src/Bytes.sol";
import { Memory } from "@latticexyz/store/src/Memory.sol";
import { SliceLib } from "@latticexyz/store/src/Slice.sol";
import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol";
-import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.sol";
-import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol";
+import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol";
+import { Schema } from "@latticexyz/store/src/Schema.sol";
import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol";
import { ResourceId } from "@latticexyz/store/src/ResourceId.sol";
-// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "Offchain", typeId: RESOURCE_OFFCHAIN_TABLE });`
-ResourceId constant _tableId = ResourceId.wrap(0x6f7400000000000000000000000000004f6666636861696e0000000000000000);
-ResourceId constant OffchainTableId = _tableId;
-
-FieldLayout constant _fieldLayout = FieldLayout.wrap(
- 0x0020010020000000000000000000000000000000000000000000000000000000
-);
-
library Offchain {
- /**
- * @notice Get the table values' field layout.
- * @return _fieldLayout The field layout for the table.
- */
- function getFieldLayout() internal pure returns (FieldLayout) {
- return _fieldLayout;
- }
-
- /**
- * @notice Get the table's key schema.
- * @return _keySchema The key schema for the table.
- */
- function getKeySchema() internal pure returns (Schema) {
- SchemaType[] memory _keySchema = new SchemaType[](1);
- _keySchema[0] = SchemaType.BYTES32;
+ // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "Offchain", typeId: RESOURCE_OFFCHAIN_TABLE });`
+ ResourceId constant _tableId = ResourceId.wrap(0x6f7400000000000000000000000000004f6666636861696e0000000000000000);
- return SchemaLib.encode(_keySchema);
- }
+ FieldLayout constant _fieldLayout =
+ FieldLayout.wrap(0x0020010020000000000000000000000000000000000000000000000000000000);
- /**
- * @notice Get the table's value schema.
- * @return _valueSchema The value schema for the table.
- */
- function getValueSchema() internal pure returns (Schema) {
- SchemaType[] memory _valueSchema = new SchemaType[](1);
- _valueSchema[0] = SchemaType.UINT256;
-
- return SchemaLib.encode(_valueSchema);
- }
+ // Hex-encoded key schema of (bytes32)
+ Schema constant _keySchema = Schema.wrap(0x002001005f000000000000000000000000000000000000000000000000000000);
+ // Hex-encoded value schema of (uint256)
+ Schema constant _valueSchema = Schema.wrap(0x002001001f000000000000000000000000000000000000000000000000000000);
/**
* @notice Get the table's key field names.
@@ -80,14 +50,14 @@ library Offchain {
* @notice Register the table with its config.
*/
function register() internal {
- StoreSwitch.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
+ StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
}
/**
* @notice Register the table with its config.
*/
function _register() internal {
- StoreCore.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
+ StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
}
/**
diff --git a/packages/cli/contracts/src/codegen/tables/Singleton.sol b/packages/cli/contracts/src/codegen/tables/Singleton.sol
index af76be1d8a..ac7955f7e7 100644
--- a/packages/cli/contracts/src/codegen/tables/Singleton.sol
+++ b/packages/cli/contracts/src/codegen/tables/Singleton.sol
@@ -3,9 +3,6 @@ pragma solidity >=0.8.24;
/* Autogenerated file. Do not edit manually. */
-// Import schema type
-import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol";
-
// Import store internals
import { IStore } from "@latticexyz/store/src/IStore.sol";
import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol";
@@ -14,51 +11,22 @@ import { Bytes } from "@latticexyz/store/src/Bytes.sol";
import { Memory } from "@latticexyz/store/src/Memory.sol";
import { SliceLib } from "@latticexyz/store/src/Slice.sol";
import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol";
-import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.sol";
-import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol";
+import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol";
+import { Schema } from "@latticexyz/store/src/Schema.sol";
import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol";
import { ResourceId } from "@latticexyz/store/src/ResourceId.sol";
-// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "Singleton", typeId: RESOURCE_TABLE });`
-ResourceId constant _tableId = ResourceId.wrap(0x7462000000000000000000000000000053696e676c65746f6e00000000000000);
-ResourceId constant SingletonTableId = _tableId;
-
-FieldLayout constant _fieldLayout = FieldLayout.wrap(
- 0x0020010320000000000000000000000000000000000000000000000000000000
-);
-
library Singleton {
- /**
- * @notice Get the table values' field layout.
- * @return _fieldLayout The field layout for the table.
- */
- function getFieldLayout() internal pure returns (FieldLayout) {
- return _fieldLayout;
- }
-
- /**
- * @notice Get the table's key schema.
- * @return _keySchema The key schema for the table.
- */
- function getKeySchema() internal pure returns (Schema) {
- SchemaType[] memory _keySchema = new SchemaType[](0);
+ // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "Singleton", typeId: RESOURCE_TABLE });`
+ ResourceId constant _tableId = ResourceId.wrap(0x7462000000000000000000000000000053696e676c65746f6e00000000000000);
- return SchemaLib.encode(_keySchema);
- }
+ FieldLayout constant _fieldLayout =
+ FieldLayout.wrap(0x0020010320000000000000000000000000000000000000000000000000000000);
- /**
- * @notice Get the table's value schema.
- * @return _valueSchema The value schema for the table.
- */
- function getValueSchema() internal pure returns (Schema) {
- SchemaType[] memory _valueSchema = new SchemaType[](4);
- _valueSchema[0] = SchemaType.INT256;
- _valueSchema[1] = SchemaType.UINT32_ARRAY;
- _valueSchema[2] = SchemaType.UINT32_ARRAY;
- _valueSchema[3] = SchemaType.UINT32_ARRAY;
-
- return SchemaLib.encode(_valueSchema);
- }
+ // Hex-encoded key schema of ()
+ Schema constant _keySchema = Schema.wrap(0x0000000000000000000000000000000000000000000000000000000000000000);
+ // Hex-encoded value schema of (int256, uint32[], uint32[], uint32[])
+ Schema constant _valueSchema = Schema.wrap(0x002001033f656565000000000000000000000000000000000000000000000000);
/**
* @notice Get the table's key field names.
@@ -84,14 +52,14 @@ library Singleton {
* @notice Register the table with its config.
*/
function register() internal {
- StoreSwitch.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
+ StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
}
/**
* @notice Register the table with its config.
*/
function _register() internal {
- StoreCore.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
+ StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
}
/**
diff --git a/packages/cli/contracts/src/codegen/tables/Statics.sol b/packages/cli/contracts/src/codegen/tables/Statics.sol
index ef1fcffa55..86453360fe 100644
--- a/packages/cli/contracts/src/codegen/tables/Statics.sol
+++ b/packages/cli/contracts/src/codegen/tables/Statics.sol
@@ -3,9 +3,6 @@ pragma solidity >=0.8.24;
/* Autogenerated file. Do not edit manually. */
-// Import schema type
-import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol";
-
// Import store internals
import { IStore } from "@latticexyz/store/src/IStore.sol";
import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol";
@@ -14,22 +11,14 @@ import { Bytes } from "@latticexyz/store/src/Bytes.sol";
import { Memory } from "@latticexyz/store/src/Memory.sol";
import { SliceLib } from "@latticexyz/store/src/Slice.sol";
import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol";
-import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.sol";
-import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol";
+import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol";
+import { Schema } from "@latticexyz/store/src/Schema.sol";
import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol";
import { ResourceId } from "@latticexyz/store/src/ResourceId.sol";
// Import user types
import { Enum2, Enum1 } from "./../common.sol";
-// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "Statics", typeId: RESOURCE_TABLE });`
-ResourceId constant _tableId = ResourceId.wrap(0x7462000000000000000000000000000053746174696373000000000000000000);
-ResourceId constant StaticsTableId = _tableId;
-
-FieldLayout constant _fieldLayout = FieldLayout.wrap(
- 0x004a060020041014010100000000000000000000000000000000000000000000
-);
-
struct StaticsData {
uint256 v1;
int32 v2;
@@ -40,45 +29,16 @@ struct StaticsData {
}
library Statics {
- /**
- * @notice Get the table values' field layout.
- * @return _fieldLayout The field layout for the table.
- */
- function getFieldLayout() internal pure returns (FieldLayout) {
- return _fieldLayout;
- }
-
- /**
- * @notice Get the table's key schema.
- * @return _keySchema The key schema for the table.
- */
- function getKeySchema() internal pure returns (Schema) {
- SchemaType[] memory _keySchema = new SchemaType[](6);
- _keySchema[0] = SchemaType.UINT256;
- _keySchema[1] = SchemaType.INT32;
- _keySchema[2] = SchemaType.BYTES16;
- _keySchema[3] = SchemaType.ADDRESS;
- _keySchema[4] = SchemaType.BOOL;
- _keySchema[5] = SchemaType.UINT8;
+ // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "Statics", typeId: RESOURCE_TABLE });`
+ ResourceId constant _tableId = ResourceId.wrap(0x7462000000000000000000000000000053746174696373000000000000000000);
- return SchemaLib.encode(_keySchema);
- }
+ FieldLayout constant _fieldLayout =
+ FieldLayout.wrap(0x004a060020041014010100000000000000000000000000000000000000000000);
- /**
- * @notice Get the table's value schema.
- * @return _valueSchema The value schema for the table.
- */
- function getValueSchema() internal pure returns (Schema) {
- SchemaType[] memory _valueSchema = new SchemaType[](6);
- _valueSchema[0] = SchemaType.UINT256;
- _valueSchema[1] = SchemaType.INT32;
- _valueSchema[2] = SchemaType.BYTES16;
- _valueSchema[3] = SchemaType.ADDRESS;
- _valueSchema[4] = SchemaType.BOOL;
- _valueSchema[5] = SchemaType.UINT8;
-
- return SchemaLib.encode(_valueSchema);
- }
+ // Hex-encoded key schema of (uint256, int32, bytes16, address, bool, uint8)
+ Schema constant _keySchema = Schema.wrap(0x004a06001f234f61600000000000000000000000000000000000000000000000);
+ // Hex-encoded value schema of (uint256, int32, bytes16, address, bool, uint8)
+ Schema constant _valueSchema = Schema.wrap(0x004a06001f234f61600000000000000000000000000000000000000000000000);
/**
* @notice Get the table's key field names.
@@ -112,14 +72,14 @@ library Statics {
* @notice Register the table with its config.
*/
function register() internal {
- StoreSwitch.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
+ StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
}
/**
* @notice Register the table with its config.
*/
function _register() internal {
- StoreCore.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
+ StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
}
/**
diff --git a/packages/cli/contracts/src/codegen/tables/UserTyped.sol b/packages/cli/contracts/src/codegen/tables/UserTyped.sol
index ccb63dbdca..fc3fcf29c8 100644
--- a/packages/cli/contracts/src/codegen/tables/UserTyped.sol
+++ b/packages/cli/contracts/src/codegen/tables/UserTyped.sol
@@ -3,9 +3,6 @@ pragma solidity >=0.8.24;
/* Autogenerated file. Do not edit manually. */
-// Import schema type
-import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol";
-
// Import store internals
import { IStore } from "@latticexyz/store/src/IStore.sol";
import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol";
@@ -14,8 +11,8 @@ import { Bytes } from "@latticexyz/store/src/Bytes.sol";
import { Memory } from "@latticexyz/store/src/Memory.sol";
import { SliceLib } from "@latticexyz/store/src/Slice.sol";
import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol";
-import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.sol";
-import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol";
+import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol";
+import { Schema } from "@latticexyz/store/src/Schema.sol";
import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol";
import { ResourceId } from "@latticexyz/store/src/ResourceId.sol";
@@ -23,14 +20,6 @@ import { ResourceId } from "@latticexyz/store/src/ResourceId.sol";
import { TestTypeAddress, TestTypeInt64, TestTypeLibrary } from "./../../types.sol";
import { ResourceId } from "@latticexyz/store/src/ResourceId.sol";
-// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "UserTyped", typeId: RESOURCE_TABLE });`
-ResourceId constant _tableId = ResourceId.wrap(0x7462000000000000000000000000000055736572547970656400000000000000);
-ResourceId constant UserTypedTableId = _tableId;
-
-FieldLayout constant _fieldLayout = FieldLayout.wrap(
- 0x004d050014080110200000000000000000000000000000000000000000000000
-);
-
struct UserTypedData {
TestTypeAddress v1;
TestTypeInt64 v2;
@@ -40,43 +29,16 @@ struct UserTypedData {
}
library UserTyped {
- /**
- * @notice Get the table values' field layout.
- * @return _fieldLayout The field layout for the table.
- */
- function getFieldLayout() internal pure returns (FieldLayout) {
- return _fieldLayout;
- }
-
- /**
- * @notice Get the table's key schema.
- * @return _keySchema The key schema for the table.
- */
- function getKeySchema() internal pure returns (Schema) {
- SchemaType[] memory _keySchema = new SchemaType[](5);
- _keySchema[0] = SchemaType.ADDRESS;
- _keySchema[1] = SchemaType.INT64;
- _keySchema[2] = SchemaType.BOOL;
- _keySchema[3] = SchemaType.UINT128;
- _keySchema[4] = SchemaType.BYTES32;
+ // Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "UserTyped", typeId: RESOURCE_TABLE });`
+ ResourceId constant _tableId = ResourceId.wrap(0x7462000000000000000000000000000055736572547970656400000000000000);
- return SchemaLib.encode(_keySchema);
- }
+ FieldLayout constant _fieldLayout =
+ FieldLayout.wrap(0x004d050014080110200000000000000000000000000000000000000000000000);
- /**
- * @notice Get the table's value schema.
- * @return _valueSchema The value schema for the table.
- */
- function getValueSchema() internal pure returns (Schema) {
- SchemaType[] memory _valueSchema = new SchemaType[](5);
- _valueSchema[0] = SchemaType.ADDRESS;
- _valueSchema[1] = SchemaType.INT64;
- _valueSchema[2] = SchemaType.BOOL;
- _valueSchema[3] = SchemaType.UINT128;
- _valueSchema[4] = SchemaType.BYTES32;
-
- return SchemaLib.encode(_valueSchema);
- }
+ // Hex-encoded key schema of (address, int64, bool, uint128, bytes32)
+ Schema constant _keySchema = Schema.wrap(0x004d05006127600f5f0000000000000000000000000000000000000000000000);
+ // Hex-encoded value schema of (address, int64, bool, uint128, bytes32)
+ Schema constant _valueSchema = Schema.wrap(0x004d05006127600f5f0000000000000000000000000000000000000000000000);
/**
* @notice Get the table's key field names.
@@ -108,14 +70,14 @@ library UserTyped {
* @notice Register the table with its config.
*/
function register() internal {
- StoreSwitch.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
+ StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
}
/**
* @notice Register the table with its config.
*/
function _register() internal {
- StoreCore.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
+ StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
}
/**
diff --git a/packages/cli/src/commands/dev-contracts.ts b/packages/cli/src/commands/dev-contracts.ts
index 084c271275..23b7b1d03c 100644
--- a/packages/cli/src/commands/dev-contracts.ts
+++ b/packages/cli/src/commands/dev-contracts.ts
@@ -106,7 +106,7 @@ const commandModule: CommandModule = {
const mutuallyExclusiveOptions = ["mudVersion", "link", "tag", "commit", "restore"];
const numMutuallyExclusiveOptions = mutuallyExclusiveOptions.reduce(
(acc, opt) => (options[opt] ? acc + 1 : acc),
- 0
+ 0,
);
if (numMutuallyExclusiveOptions === 0) {
diff --git a/packages/cli/src/commands/trace.ts b/packages/cli/src/commands/trace.ts
index e6d55a9ece..e8659eb089 100644
--- a/packages/cli/src/commands/trace.ts
+++ b/packages/cli/src/commands/trace.ts
@@ -63,7 +63,7 @@ const commandModule: CommandModule = {
const resolvedConfig = resolveWorldConfig(
mudConfig,
- existingContracts.map(({ basename }) => basename)
+ existingContracts.map(({ basename }) => basename),
);
// Get worldAddress either from args or from worldsFile
diff --git a/packages/cli/src/deploy/configToTables.ts b/packages/cli/src/deploy/configToTables.ts
index 4c07a81bb3..3e9b0e5729 100644
--- a/packages/cli/src/deploy/configToTables.ts
+++ b/packages/cli/src/deploy/configToTables.ts
@@ -14,12 +14,12 @@ type UserTypes = config["userTypes"];
export type TableKey<
config extends StoreConfig = StoreConfig,
- table extends config["tables"][keyof config["tables"]] = config["tables"][keyof config["tables"]]
+ table extends config["tables"][keyof config["tables"]] = config["tables"][keyof config["tables"]],
> = `${config["namespace"]}_${table["name"]}`;
export type Table<
config extends StoreConfig = StoreConfig,
- table extends config["tables"][keyof config["tables"]] = config["tables"][keyof config["tables"]]
+ table extends config["tables"][keyof config["tables"]] = config["tables"][keyof config["tables"]],
> = {
readonly namespace: config["namespace"];
readonly name: table["name"];
@@ -63,6 +63,6 @@ export function configToTables(config: config): Tabl
keySchema: resolveUserTypes(table.keySchema, userTypes) as any,
valueSchema: resolveUserTypes(table.valueSchema, userTypes) as any,
} satisfies Table,
- ])
+ ]),
) as Tables;
}
diff --git a/packages/cli/src/deploy/deployWorld.ts b/packages/cli/src/deploy/deployWorld.ts
index 16c4c7bc75..7f5bf4ba04 100644
--- a/packages/cli/src/deploy/deployWorld.ts
+++ b/packages/cli/src/deploy/deployWorld.ts
@@ -10,7 +10,7 @@ import { WorldDeploy } from "./common";
export async function deployWorld(
client: Client,
deployerAddress: Hex,
- salt: Hex
+ salt: Hex,
): Promise {
const worldFactory = await ensureWorldFactory(client, deployerAddress);
diff --git a/packages/cli/src/deploy/ensureContract.ts b/packages/cli/src/deploy/ensureContract.ts
index b7110bcb1d..d86269ee54 100644
--- a/packages/cli/src/deploy/ensureContract.ts
+++ b/packages/cli/src/deploy/ensureContract.ts
@@ -32,11 +32,11 @@ export async function ensureContract({
if (deployedBytecodeSize > contractSizeLimit) {
console.warn(
- `\nBytecode for ${label} (${deployedBytecodeSize} bytes) is over the contract size limit (${contractSizeLimit} bytes). Run \`forge build --sizes\` for more info.\n`
+ `\nBytecode for ${label} (${deployedBytecodeSize} bytes) is over the contract size limit (${contractSizeLimit} bytes). Run \`forge build --sizes\` for more info.\n`,
);
} else if (deployedBytecodeSize > contractSizeLimit * 0.95) {
console.warn(
- `\nBytecode for ${label} (${deployedBytecodeSize} bytes) is almost over the contract size limit (${contractSizeLimit} bytes). Run \`forge build --sizes\` for more info.\n`
+ `\nBytecode for ${label} (${deployedBytecodeSize} bytes) is almost over the contract size limit (${contractSizeLimit} bytes). Run \`forge build --sizes\` for more info.\n`,
);
}
@@ -56,7 +56,7 @@ export async function ensureContract({
debug(`failed to deploy ${label}, retrying in ${delay}ms...`);
await wait(delay);
},
- }
+ },
),
];
}
diff --git a/packages/cli/src/deploy/ensureDeployer.ts b/packages/cli/src/deploy/ensureDeployer.ts
index 709f27d6f3..92c7c136b0 100644
--- a/packages/cli/src/deploy/ensureDeployer.ts
+++ b/packages/cli/src/deploy/ensureDeployer.ts
@@ -12,7 +12,7 @@ export async function ensureDeployer(client: Client func.signature).join(", ")
+ wrongSystem.map((func) => func.signature).join(", "),
);
}
}
@@ -59,7 +59,7 @@ export async function ensureFunctions({
debug(`failed to register function ${func.signature}, retrying in ${delay}ms...`);
await wait(delay);
},
- }
+ },
);
}
return pRetry(
@@ -79,8 +79,8 @@ export async function ensureFunctions({
debug(`failed to register function ${func.signature}, retrying in ${delay}ms...`);
await wait(delay);
},
- }
+ },
);
- })
+ }),
);
}
diff --git a/packages/cli/src/deploy/ensureModules.ts b/packages/cli/src/deploy/ensureModules.ts
index dddef29a09..5a658a85c2 100644
--- a/packages/cli/src/deploy/ensureModules.ts
+++ b/packages/cli/src/deploy/ensureModules.ts
@@ -68,9 +68,9 @@ export async function ensureModules({
debug(`failed to install module ${mod.name}, retrying in ${delay}ms...`);
await wait(delay);
},
- }
- )
- )
+ },
+ ),
+ ),
)
).filter(isDefined);
}
diff --git a/packages/cli/src/deploy/ensureNamespaceOwner.ts b/packages/cli/src/deploy/ensureNamespaceOwner.ts
index 65384d2de3..0771951e90 100644
--- a/packages/cli/src/deploy/ensureNamespaceOwner.ts
+++ b/packages/cli/src/deploy/ensureNamespaceOwner.ts
@@ -24,7 +24,7 @@ export async function ensureNamespaceOwner({
"existing namespaces:",
Array.from(existingNamespaces)
.map((namespace) => (namespace === "" ? "" : namespace))
- .join(", ")
+ .join(", "),
);
}
@@ -39,7 +39,7 @@ export async function ensureNamespaceOwner({
key: { namespaceId: resourceToHex({ type: "namespace", namespace, name: "" }) },
});
return [namespace, owner];
- })
+ }),
);
const unauthorizedNamespaces = namespaceOwners
@@ -63,8 +63,8 @@ export async function ensureNamespaceOwner({
abi: worldAbi,
functionName: "registerNamespace",
args: [resourceToHex({ namespace, type: "namespace", name: "" })],
- })
- )
+ }),
+ ),
);
return registrationTxs;
diff --git a/packages/cli/src/deploy/ensureSystems.ts b/packages/cli/src/deploy/ensureSystems.ts
index 51bac4ae5b..dc1661a8c2 100644
--- a/packages/cli/src/deploy/ensureSystems.ts
+++ b/packages/cli/src/deploy/ensureSystems.ts
@@ -32,8 +32,8 @@ export async function ensureSystems({
worldSystems.some(
(worldSystem) =>
worldSystem.systemId === system.systemId &&
- getAddress(worldSystem.address) === getAddress(system.getAddress(deployerAddress))
- )
+ getAddress(worldSystem.address) === getAddress(system.getAddress(deployerAddress)),
+ ),
);
if (existingSystems.length) {
debug("existing systems", existingSystems.map(resourceToLabel).join(", "));
@@ -47,15 +47,15 @@ export async function ensureSystems({
worldSystems.some(
(worldSystem) =>
worldSystem.systemId === system.systemId &&
- getAddress(worldSystem.address) !== getAddress(system.getAddress(deployerAddress))
- )
+ getAddress(worldSystem.address) !== getAddress(system.getAddress(deployerAddress)),
+ ),
);
if (systemsToUpgrade.length) {
debug("upgrading systems", systemsToUpgrade.map(resourceToLabel).join(", "));
}
const systemsToAdd = missingSystems.filter(
- (system) => !worldSystems.some((worldSystem) => worldSystem.systemId === system.systemId)
+ (system) => !worldSystems.some((worldSystem) => worldSystem.systemId === system.systemId),
);
if (systemsToAdd.length) {
debug("registering new systems", systemsToAdd.map(resourceToLabel).join(", "));
@@ -90,9 +90,9 @@ export async function ensureSystems({
debug(`failed to register system ${resourceToLabel(system)}, retrying in ${delay}ms...`);
await wait(delay);
},
- }
- )
- )
+ },
+ ),
+ ),
);
// Adjust system access
@@ -101,7 +101,7 @@ export async function ensureSystems({
const currentAccess = worldAccess.filter(({ resourceId }) => systemIds.includes(resourceId));
const desiredAccess = [
...systems.flatMap((system) =>
- system.allowedAddresses.map((address) => ({ resourceId: system.systemId, address }))
+ system.allowedAddresses.map((address) => ({ resourceId: system.systemId, address })),
),
...systems.flatMap((system) =>
system.allowedSystemIds
@@ -111,7 +111,7 @@ export async function ensureSystems({
worldSystems.find((s) => s.systemId === systemId)?.address ??
systems.find((s) => s.systemId === systemId)?.getAddress(deployerAddress),
}))
- .filter((access): access is typeof access & { address: Address } => access.address != null)
+ .filter((access): access is typeof access & { address: Address } => access.address != null),
),
];
@@ -119,16 +119,16 @@ export async function ensureSystems({
(access) =>
!currentAccess.some(
({ resourceId, address }) =>
- resourceId === access.resourceId && getAddress(address) === getAddress(access.address)
- )
+ resourceId === access.resourceId && getAddress(address) === getAddress(access.address),
+ ),
);
const accessToRemove = currentAccess.filter(
(access) =>
!desiredAccess.some(
({ resourceId, address }) =>
- resourceId === access.resourceId && getAddress(address) === getAddress(access.address)
- )
+ resourceId === access.resourceId && getAddress(address) === getAddress(access.address),
+ ),
);
if (accessToRemove.length) {
@@ -156,8 +156,8 @@ export async function ensureSystems({
debug(`failed to revoke access, retrying in ${delay}ms...`);
await wait(delay);
},
- }
- )
+ },
+ ),
),
...accessToAdd.map((access) =>
pRetry(
@@ -176,8 +176,8 @@ export async function ensureSystems({
debug(`failed to grant access, retrying in ${delay}ms...`);
await wait(delay);
},
- }
- )
+ },
+ ),
),
]);
diff --git a/packages/cli/src/deploy/ensureTables.ts b/packages/cli/src/deploy/ensureTables.ts
index 31beddba46..0ab65681bd 100644
--- a/packages/cli/src/deploy/ensureTables.ts
+++ b/packages/cli/src/deploy/ensureTables.ts
@@ -54,9 +54,9 @@ export async function ensureTables({
debug(`failed to register table ${resourceToLabel(table)}, retrying in ${delay}ms...`);
await wait(delay);
},
- }
- )
- )
+ },
+ ),
+ ),
);
}
diff --git a/packages/cli/src/deploy/ensureWorldFactory.ts b/packages/cli/src/deploy/ensureWorldFactory.ts
index 0df1c21508..0c241f7669 100644
--- a/packages/cli/src/deploy/ensureWorldFactory.ts
+++ b/packages/cli/src/deploy/ensureWorldFactory.ts
@@ -13,7 +13,7 @@ import { Contract } from "./ensureContract";
export async function ensureWorldFactory(
client: Client,
- deployerAddress: Hex
+ deployerAddress: Hex,
): Promise {
const accessManagementSystemDeployedBytecodeSize = size(accessManagementSystemBuild.deployedBytecode.object as Hex);
const accessManagementSystemBytecode = accessManagementSystemBuild.bytecode.object as Hex;
diff --git a/packages/cli/src/deploy/getFunctions.ts b/packages/cli/src/deploy/getFunctions.ts
index 39b7955486..834dd2cecb 100644
--- a/packages/cli/src/deploy/getFunctions.ts
+++ b/packages/cli/src/deploy/getFunctions.ts
@@ -51,7 +51,7 @@ export async function getFunctions({
systemFunctionSignature,
systemFunctionSelector,
};
- })
+ }),
);
return functions;
diff --git a/packages/cli/src/deploy/getResourceAccess.ts b/packages/cli/src/deploy/getResourceAccess.ts
index e38a2b2cfd..a9642085be 100644
--- a/packages/cli/src/deploy/getResourceAccess.ts
+++ b/packages/cli/src/deploy/getResourceAccess.ts
@@ -35,8 +35,8 @@ export async function getResourceAccess({
await Promise.all(
keys.map(
async (key) =>
- [key, await getTableValue({ client, worldDeploy, table: worldTables.world_ResourceAccess, key })] as const
- )
+ [key, await getTableValue({ client, worldDeploy, table: worldTables.world_ResourceAccess, key })] as const,
+ ),
)
)
.filter(([, value]) => value.access)
diff --git a/packages/cli/src/deploy/getSystems.ts b/packages/cli/src/deploy/getSystems.ts
index c87145efc1..b3cfa98eb6 100644
--- a/packages/cli/src/deploy/getSystems.ts
+++ b/packages/cli/src/deploy/getSystems.ts
@@ -42,6 +42,6 @@ export async function getSystems({
.map(({ address }) => address),
functions: systemFunctions,
};
- })
+ }),
);
}
diff --git a/packages/cli/src/deploy/getTables.ts b/packages/cli/src/deploy/getTables.ts
index 4154f38199..3342c7b9db 100644
--- a/packages/cli/src/deploy/getTables.ts
+++ b/packages/cli/src/deploy/getTables.ts
@@ -45,7 +45,7 @@ export async function getTables({
const valueAbiTypes = [...valueSchemaFields.staticFields, ...valueSchemaFields.dynamicFields];
const keySchema = Object.fromEntries(
- keySchemaFields.staticFields.map((abiType, i) => [keyNames[i], abiType])
+ keySchemaFields.staticFields.map((abiType, i) => [keyNames[i], abiType]),
) as KeySchema;
const valueSchema = Object.fromEntries(valueAbiTypes.map((abiType, i) => [fieldNames[i], abiType])) as ValueSchema;
diff --git a/packages/cli/src/deploy/logsToWorldDeploy.ts b/packages/cli/src/deploy/logsToWorldDeploy.ts
index 81091270fd..a6f078766f 100644
--- a/packages/cli/src/deploy/logsToWorldDeploy.ts
+++ b/packages/cli/src/deploy/logsToWorldDeploy.ts
@@ -37,7 +37,7 @@ export function logsToWorldDeploy(logs: readonly Log[]):
? { storeVersion: hexToString(trim(log.args.storeVersion, { dir: "right" })) }
: null),
}),
- {}
+ {},
);
if (address == null) throw new Error("could not find world address");
diff --git a/packages/cli/src/deploy/resolveConfig.ts b/packages/cli/src/deploy/resolveConfig.ts
index bc56ad8dc2..2cde8cfc1f 100644
--- a/packages/cli/src/deploy/resolveConfig.ts
+++ b/packages/cli/src/deploy/resolveConfig.ts
@@ -61,7 +61,7 @@ export function resolveConfig({
allowAll: system.openAccess,
allowedAddresses: system.accessListAddresses as Hex[],
allowedSystemIds: system.accessListSystems.map((name) =>
- resourceToHex({ type: "system", namespace, name: resolvedConfig.systems[name].name })
+ resourceToHex({ type: "system", namespace, name: resolvedConfig.systems[name].name }),
),
getAddress: (deployer: Address) => getCreate2Address({ from: deployer, bytecode: contractData.bytecode, salt }),
bytecode: contractData.bytecode,
@@ -81,8 +81,8 @@ export function resolveConfig({
const names = overlappingSystems.map((system) => system.name);
throw new Error(
`Found systems with overlapping system ID: ${names.join(
- ", "
- )}.\n\nSystem IDs are generated from the first 16 bytes of the name, so you may need to rename them to avoid the overlap.`
+ ", ",
+ )}.\n\nSystem IDs are generated from the first 16 bytes of the name, so you may need to rename them to avoid the overlap.`,
);
}
@@ -96,9 +96,9 @@ export function resolveConfig({
type: table.offchainOnly ? "offchainTable" : "table",
namespace: config.namespace,
name: table.name,
- })
+ }),
),
- ])
+ ]),
),
};
diff --git a/packages/cli/src/mud.ts b/packages/cli/src/mud.ts
index b1f85a25fb..b01f04031b 100755
--- a/packages/cli/src/mud.ts
+++ b/packages/cli/src/mud.ts
@@ -26,7 +26,7 @@ async function run() {
console.error(chalk.red(msg));
if (msg.includes("Missing required argument")) {
console.log(
- chalk.yellow(`Run 'pnpm mud ${process.argv[2]} --help' for a list of available and required arguments.`)
+ chalk.yellow(`Run 'pnpm mud ${process.argv[2]} --help' for a list of available and required arguments.`),
);
}
console.log("");
diff --git a/packages/cli/src/runDeploy.ts b/packages/cli/src/runDeploy.ts
index ba668668b8..0535fe29f0 100644
--- a/packages/cli/src/runDeploy.ts
+++ b/packages/cli/src/runDeploy.ts
@@ -64,8 +64,8 @@ export async function runDeploy(opts: DeployOptions): Promise {
const rpc = opts.rpc ?? (await getRpcUrl(profile));
console.log(
chalk.bgBlue(
- chalk.whiteBright(`\n Deploying MUD contracts${profile ? " with profile " + profile : ""} to RPC ${rpc} \n`)
- )
+ chalk.whiteBright(`\n Deploying MUD contracts${profile ? " with profile " + profile : ""} to RPC ${rpc} \n`),
+ ),
);
// Run build
@@ -78,7 +78,7 @@ export async function runDeploy(opts: DeployOptions): Promise {
throw new MUDError(
`Missing PRIVATE_KEY environment variable.
Run 'echo "PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" > .env'
-in your contracts directory to use the default anvil private key.`
+in your contracts directory to use the default anvil private key.`,
);
}
@@ -126,7 +126,7 @@ in your contracts directory to use the default anvil private key.`
writeFileSync(config.worldsFile, JSON.stringify(deploys, null, 2));
console.log(
- chalk.bgGreen(chalk.whiteBright(`\n Deployment result (written to ${config.worldsFile} and ${deploysDir}): \n`))
+ chalk.bgGreen(chalk.whiteBright(`\n Deployment result (written to ${config.worldsFile} and ${deploysDir}): \n`)),
);
}
diff --git a/packages/cli/src/utils/printMUD.ts b/packages/cli/src/utils/printMUD.ts
index b3114e5916..5933c97d6f 100644
--- a/packages/cli/src/utils/printMUD.ts
+++ b/packages/cli/src/utils/printMUD.ts
@@ -9,6 +9,6 @@ export function printMUD() {
| :\\/: || :\\/: || (__) |
| '--'M|| '--'U|| '--'D|
'------''------''------'
-`)
+`),
);
}
diff --git a/packages/cli/src/utils/utils/getContractData.ts b/packages/cli/src/utils/utils/getContractData.ts
index a289b0443d..c527d2b873 100644
--- a/packages/cli/src/utils/utils/getContractData.ts
+++ b/packages/cli/src/utils/utils/getContractData.ts
@@ -9,7 +9,7 @@ import { Abi, Hex, size } from "viem";
*/
export function getContractData(
contractName: string,
- forgeOutDirectory: string
+ forgeOutDirectory: string,
): { bytecode: Hex; abi: Abi; deployedBytecodeSize: number } {
let data: any;
const contractDataPath = path.join(forgeOutDirectory, contractName + ".sol", contractName + ".json");
diff --git a/packages/cli/src/utils/utils/postDeploy.ts b/packages/cli/src/utils/utils/postDeploy.ts
index e30d63eaa1..a03eb1e2fa 100644
--- a/packages/cli/src/utils/utils/postDeploy.ts
+++ b/packages/cli/src/utils/utils/postDeploy.ts
@@ -7,7 +7,7 @@ export async function postDeploy(
postDeployScript: string,
worldAddress: string,
rpc: string,
- profile: string | undefined
+ profile: string | undefined,
): Promise {
// Execute postDeploy forge script
const postDeployPath = path.join(await getScriptDirectory(), postDeployScript + ".s.sol");
@@ -17,7 +17,7 @@ export async function postDeploy(
["script", postDeployScript, "--sig", "run(address)", worldAddress, "--broadcast", "--rpc-url", rpc, "-vvv"],
{
profile: profile,
- }
+ },
);
} else {
console.log(`No script at ${postDeployPath}, skipping post deploy hook`);
diff --git a/packages/cli/tsup.config.ts b/packages/cli/tsup.config.ts
index 8e74fd917d..cc3e3ca7de 100644
--- a/packages/cli/tsup.config.ts
+++ b/packages/cli/tsup.config.ts
@@ -14,7 +14,7 @@ const mudPackages: MudPackages = Object.fromEntries(
JSON.parse(readFileSync(filename, "utf8")),
])
.filter(([, packageJson]) => !packageJson.private)
- .map(([localPath, packageJson]) => [packageJson.name, { localPath }])
+ .map(([localPath, packageJson]) => [packageJson.name, { localPath }]),
);
export default defineConfig({
diff --git a/packages/common/CHANGELOG.md b/packages/common/CHANGELOG.md
index 042dabaa3c..3d53ad41dd 100644
--- a/packages/common/CHANGELOG.md
+++ b/packages/common/CHANGELOG.md
@@ -669,7 +669,7 @@
.pipe(
map((block) => Number(block.timestamp) * 1000), // Map to timestamp in ms
filter((blockTimestamp) => blockTimestamp !== clock.lastUpdateTime), // Ignore if the clock was already refreshed with this block
- filter((blockTimestamp) => blockTimestamp !== clock.currentTime) // Ignore if the current local timestamp is correct
+ filter((blockTimestamp) => blockTimestamp !== clock.currentTime), // Ignore if the current local timestamp is correct
)
.subscribe(clock.update); // Update the local clock
```
diff --git a/packages/common/package.json b/packages/common/package.json
index 216270c946..47b0beb187 100644
--- a/packages/common/package.json
+++ b/packages/common/package.json
@@ -11,6 +11,7 @@
"type": "module",
"exports": {
".": "./dist/index.js",
+ "./actions": "./dist/actions.js",
"./chains": "./dist/chains.js",
"./codegen": "./dist/codegen.js",
"./errors": "./dist/errors.js",
@@ -23,6 +24,9 @@
"index": [
"./src/index.ts"
],
+ "actions": [
+ "./src/actions/index.ts"
+ ],
"chains": [
"./src/chains/index.ts"
],
@@ -59,8 +63,8 @@
"execa": "^7.0.0",
"p-queue": "^7.4.1",
"p-retry": "^5.1.2",
- "prettier": "^2.8.4",
- "prettier-plugin-solidity": "1.1.3",
+ "prettier": "3.2.5",
+ "prettier-plugin-solidity": "1.3.1",
"viem": "2.7.12"
},
"devDependencies": {
diff --git a/packages/common/src/actions/index.ts b/packages/common/src/actions/index.ts
new file mode 100644
index 0000000000..79e6f9f176
--- /dev/null
+++ b/packages/common/src/actions/index.ts
@@ -0,0 +1,2 @@
+export * from "./transactionQueue";
+export * from "./writeObserver";
diff --git a/packages/common/src/actions/transactionQueue.ts b/packages/common/src/actions/transactionQueue.ts
new file mode 100644
index 0000000000..dfa8adbb6a
--- /dev/null
+++ b/packages/common/src/actions/transactionQueue.ts
@@ -0,0 +1,14 @@
+import type { Transport, Chain, Account, WalletActions, WalletClient } from "viem";
+import { writeContract as mud_writeContract } from "../writeContract";
+import { sendTransaction as mud_sendTransaction } from "../sendTransaction";
+
+export function transactionQueue(): (
+ client: WalletClient,
+) => Pick, "writeContract" | "sendTransaction"> {
+ return (client) => ({
+ // Applies to: `client.writeContract`, `getContract(client, ...).write`
+ writeContract: (args) => mud_writeContract(client, args),
+ // Applies to: `client.sendTransaction`
+ sendTransaction: (args) => mud_sendTransaction(client, args),
+ });
+}
diff --git a/packages/common/src/actions/writeObserver.ts b/packages/common/src/actions/writeObserver.ts
new file mode 100644
index 0000000000..1a1fc10cf7
--- /dev/null
+++ b/packages/common/src/actions/writeObserver.ts
@@ -0,0 +1,34 @@
+import type {
+ WriteContractParameters,
+ Transport,
+ Chain,
+ Account,
+ WalletActions,
+ WalletClient,
+ WriteContractReturnType,
+} from "viem";
+import { getAction } from "viem/utils";
+import { writeContract } from "viem/actions";
+import { type ContractWrite } from "../getContract";
+
+type WriteObserverParameters = { onWrite: (write: ContractWrite) => void };
+
+export function writeObserver({
+ onWrite,
+}: WriteObserverParameters): (
+ client: WalletClient,
+) => Pick, "writeContract"> {
+ let nextWriteId = 0;
+
+ return (client) => ({
+ // Applies to: `client.writeContract`, `getContract(client, ...).write`
+ writeContract: (args): Promise => {
+ const result = getAction(client, writeContract, "writeContract")(args);
+
+ const id = `${client.chain.id}:${client.account.address}:${nextWriteId++}`;
+ onWrite({ id, request: args as WriteContractParameters, result });
+
+ return result;
+ },
+ });
+}
diff --git a/packages/common/src/codegen/render-solidity/common.test.ts b/packages/common/src/codegen/render-solidity/common.test.ts
index e51e849b4f..c249c21cec 100644
--- a/packages/common/src/codegen/render-solidity/common.test.ts
+++ b/packages/common/src/codegen/render-solidity/common.test.ts
@@ -22,62 +22,58 @@ describe("getLeftPaddingBits", () => {
describe("renderValueTypeToBytes32", () => {
it("returns Solidity code to cast native type to bytes32", () => {
expect(renderValueTypeToBytes32("someField", { typeUnwrap: "", internalTypeId: "bytes32" })).toMatchInlineSnapshot(
- '"someField"'
+ '"someField"',
);
expect(
- renderValueTypeToBytes32("someField", { typeUnwrap: "SomeStruct.unwrap", internalTypeId: "bytes32" })
+ renderValueTypeToBytes32("someField", { typeUnwrap: "SomeStruct.unwrap", internalTypeId: "bytes32" }),
).toMatchInlineSnapshot('"SomeStruct.unwrap(someField)"');
expect(renderValueTypeToBytes32("someField", { typeUnwrap: "", internalTypeId: "bytes16" })).toMatchInlineSnapshot(
- '"bytes32(someField)"'
+ '"bytes32(someField)"',
);
expect(
- renderValueTypeToBytes32("someField", { typeUnwrap: "SomeStruct.unwrap", internalTypeId: "bytes16" })
+ renderValueTypeToBytes32("someField", { typeUnwrap: "SomeStruct.unwrap", internalTypeId: "bytes16" }),
).toMatchInlineSnapshot('"bytes32(SomeStruct.unwrap(someField))"');
expect(renderValueTypeToBytes32("someField", { typeUnwrap: "", internalTypeId: "uint8" })).toMatchInlineSnapshot(
- '"bytes32(uint256(someField))"'
+ '"bytes32(uint256(someField))"',
);
expect(
- renderValueTypeToBytes32("someField", { typeUnwrap: "SomeStruct.unwrap", internalTypeId: "uint8" })
+ renderValueTypeToBytes32("someField", { typeUnwrap: "SomeStruct.unwrap", internalTypeId: "uint8" }),
).toMatchInlineSnapshot('"bytes32(uint256(SomeStruct.unwrap(someField)))"');
expect(renderValueTypeToBytes32("someField", { typeUnwrap: "", internalTypeId: "bool" })).toMatchInlineSnapshot(
- '"_boolToBytes32(someField)"'
+ '"_boolToBytes32(someField)"',
);
expect(
- renderValueTypeToBytes32("someField", { typeUnwrap: "SomeStruct.unwrap", internalTypeId: "bool" })
+ renderValueTypeToBytes32("someField", { typeUnwrap: "SomeStruct.unwrap", internalTypeId: "bool" }),
).toMatchInlineSnapshot('"_boolToBytes32(SomeStruct.unwrap(someField))"');
expect(renderValueTypeToBytes32("someField", { typeUnwrap: "", internalTypeId: "address" })).toMatchInlineSnapshot(
- '"bytes32(uint256(uint160(someField)))"'
+ '"bytes32(uint256(uint160(someField)))"',
);
expect(
- renderValueTypeToBytes32("someField", { typeUnwrap: "SomeStruct.unwrap", internalTypeId: "address" })
+ renderValueTypeToBytes32("someField", { typeUnwrap: "SomeStruct.unwrap", internalTypeId: "address" }),
).toMatchInlineSnapshot('"bytes32(uint256(uint160(SomeStruct.unwrap(someField))))"');
});
});
describe("renderTableId", () => {
it("returns Solidity code to compute table ID", () => {
- expect(renderTableId({ namespace: "somewhere", name: "Player", offchainOnly: false, tableIdName: "PlayerTableId" }))
- .toMatchInlineSnapshot(`
+ expect(renderTableId({ namespace: "somewhere", name: "Player", offchainOnly: false })).toMatchInlineSnapshot(`
+ "
+ // Hex below is the result of \`WorldResourceIdLib.encode({ namespace: \\"somewhere\\", name: \\"Player\\", typeId: RESOURCE_TABLE });\`
+ ResourceId constant _tableId = ResourceId.wrap(0x7462736f6d6577686572650000000000506c6179657200000000000000000000);
"
- // Hex below is the result of \`WorldResourceIdLib.encode({ namespace: \\"somewhere\\", name: \\"Player\\", typeId: RESOURCE_TABLE });\`
- ResourceId constant _tableId = ResourceId.wrap(0x7462736f6d6577686572650000000000506c6179657200000000000000000000);
- ResourceId constant PlayerTableId = _tableId;
- "
- `);
+ `);
});
it("returns Solidity code to compute offchain table ID", () => {
- expect(renderTableId({ namespace: "somewhere", name: "Player", offchainOnly: true, tableIdName: "PlayerTableId" }))
- .toMatchInlineSnapshot(`
+ expect(renderTableId({ namespace: "somewhere", name: "Player", offchainOnly: true })).toMatchInlineSnapshot(`
+ "
+ // Hex below is the result of \`WorldResourceIdLib.encode({ namespace: \\"somewhere\\", name: \\"Player\\", typeId: RESOURCE_OFFCHAIN_TABLE });\`
+ ResourceId constant _tableId = ResourceId.wrap(0x6f74736f6d6577686572650000000000506c6179657200000000000000000000);
"
- // Hex below is the result of \`WorldResourceIdLib.encode({ namespace: \\"somewhere\\", name: \\"Player\\", typeId: RESOURCE_OFFCHAIN_TABLE });\`
- ResourceId constant _tableId = ResourceId.wrap(0x6f74736f6d6577686572650000000000506c6179657200000000000000000000);
- ResourceId constant PlayerTableId = _tableId;
- "
- `);
+ `);
});
});
diff --git a/packages/common/src/codegen/render-solidity/common.ts b/packages/common/src/codegen/render-solidity/common.ts
index ea985a0146..58bbdf4b99 100644
--- a/packages/common/src/codegen/render-solidity/common.ts
+++ b/packages/common/src/codegen/render-solidity/common.ts
@@ -94,7 +94,7 @@ export function renderImports(imports: ImportDatum[]): string {
path: solidityRelativeImportPath(importDatum.fromPath, importDatum.usedInPath),
};
}
- })
+ }),
);
}
@@ -107,7 +107,7 @@ export function renderRelativeImports(imports: RelativeImportDatum[]): string {
imports.map(({ symbol, fromPath, usedInPath }) => ({
symbol,
path: solidityRelativeImportPath(fromPath, usedInPath),
- }))
+ })),
);
}
@@ -154,7 +154,7 @@ interface RenderWithStoreCallbackData {
*/
export function renderWithStore(
storeArgument: boolean,
- callback: (data: RenderWithStoreCallbackData) => string
+ callback: (data: RenderWithStoreCallbackData) => string,
): string {
let result = "";
result += callback({ _typedStore: undefined, _store: "StoreSwitch", _commentSuffix: "", _methodNamePrefix: "" });
@@ -190,7 +190,7 @@ export function renderWithStore(
export function renderWithFieldSuffix(
withSuffixlessFieldMethods: boolean,
fieldName: string,
- callback: (_methodNameSuffix: string) => string
+ callback: (_methodNameSuffix: string) => string,
): string {
const methodNameSuffix = `${fieldName[0].toUpperCase()}${fieldName.slice(1)}`;
let result = "";
@@ -204,25 +204,23 @@ export function renderWithFieldSuffix(
}
/**
- * Renders `_tableId` variable definition and initialization, and its alias which uses the provided `tableIdName`.
- * @param param0 static resource data needed to construct the table id
+ * Renders `_tableId` definition of the given table.
+ * @param param0 static resource data needed to construct the table ID
*/
export function renderTableId({
namespace,
name,
offchainOnly,
- tableIdName,
-}: Pick): string {
+}: Pick): string {
return `
// Hex below is the result of \`WorldResourceIdLib.encode({ namespace: ${JSON.stringify(
- namespace
+ namespace,
)}, name: ${JSON.stringify(name)}, typeId: ${offchainOnly ? "RESOURCE_OFFCHAIN_TABLE" : "RESOURCE_TABLE"} });\`
ResourceId constant _tableId = ResourceId.wrap(${resourceToHex({
type: offchainOnly ? "offchainTable" : "table",
namespace,
name,
})});
- ResourceId constant ${tableIdName} = _tableId;
`;
}
@@ -233,7 +231,7 @@ export function renderTableId({
*/
export function renderValueTypeToBytes32(
name: string,
- { typeUnwrap, internalTypeId }: Pick
+ { typeUnwrap, internalTypeId }: Pick,
): string {
const innerText = typeUnwrap.length ? `${typeUnwrap}(${name})` : name;
@@ -278,7 +276,7 @@ export function getLeftPaddingBits(field: Pick(
lineTerminator: string,
list: T[],
- renderItem: (item: T, index: number) => string
+ renderItem: (item: T, index: number) => string,
): string {
return list
.map((item, index) => renderItem(item, index) + (index === list.length - 1 ? "" : lineTerminator))
diff --git a/packages/common/src/codegen/render-solidity/renderEnums.ts b/packages/common/src/codegen/render-solidity/renderEnums.ts
index 00df0b1094..74d456d81a 100644
--- a/packages/common/src/codegen/render-solidity/renderEnums.ts
+++ b/packages/common/src/codegen/render-solidity/renderEnums.ts
@@ -13,7 +13,7 @@ export function renderEnums(enums: RenderEnum[]): string {
enum ${name} {
${renderArguments(memberNames)}
}
- `
+ `,
);
return result;
diff --git a/packages/common/src/codegen/render-solidity/renderTypeHelpers.ts b/packages/common/src/codegen/render-solidity/renderTypeHelpers.ts
index 81b39c4baa..f6182d60e0 100644
--- a/packages/common/src/codegen/render-solidity/renderTypeHelpers.ts
+++ b/packages/common/src/codegen/render-solidity/renderTypeHelpers.ts
@@ -74,7 +74,7 @@ function renderWrapperStaticArray(
functionName: string,
elementType: string,
staticLength: number,
- internalTypeId: string
+ internalTypeId: string,
): string {
// WARNING: ensure this still works if changing major solidity versions!
// (the memory layout for static arrays may change)
@@ -119,7 +119,7 @@ function renderUnwrapperStaticArray(
functionName: string,
elementType: string,
staticLength: number,
- internalTypeId: string
+ internalTypeId: string,
): string {
// byte length for memory copying (more efficient than a loop)
const byteLength = staticLength * 32;
diff --git a/packages/common/src/codegen/render-solidity/types.ts b/packages/common/src/codegen/render-solidity/types.ts
index f395edcaae..e61da22518 100644
--- a/packages/common/src/codegen/render-solidity/types.ts
+++ b/packages/common/src/codegen/render-solidity/types.ts
@@ -12,8 +12,6 @@ export interface RelativeImportDatum {
export type ImportDatum = AbsoluteImportDatum | RelativeImportDatum;
export interface StaticResourceData {
- /** Name of the table id constant to render. */
- tableIdName: string;
/** Table namespace string */
namespace: string;
/** Table name string */
diff --git a/packages/common/src/codegen/utils/contractToInterface.ts b/packages/common/src/codegen/utils/contractToInterface.ts
index 13c347290a..2e1e83e907 100644
--- a/packages/common/src/codegen/utils/contractToInterface.ts
+++ b/packages/common/src/codegen/utils/contractToInterface.ts
@@ -33,7 +33,7 @@ interface SymbolImport {
*/
export function contractToInterface(
data: string,
- contractName: string
+ contractName: string,
): {
functions: ContractInterfaceFunction[];
errors: ContractInterfaceError[];
diff --git a/packages/common/src/codegen/utils/extractUserTypes.ts b/packages/common/src/codegen/utils/extractUserTypes.ts
index 21f48c0ed2..8bdc960699 100644
--- a/packages/common/src/codegen/utils/extractUserTypes.ts
+++ b/packages/common/src/codegen/utils/extractUserTypes.ts
@@ -24,7 +24,7 @@ export interface SolidityUserDefinedType {
export function extractUserTypes(
data: string,
userTypeNames: string[],
- fromPath: string
+ fromPath: string,
): Record {
const ast = parse(data);
diff --git a/packages/common/src/codegen/utils/formatAndWrite.ts b/packages/common/src/codegen/utils/formatAndWrite.ts
index f8cca27b1f..1121d58262 100644
--- a/packages/common/src/codegen/utils/formatAndWrite.ts
+++ b/packages/common/src/codegen/utils/formatAndWrite.ts
@@ -27,7 +27,7 @@ export async function formatAndWriteSolidity(output: string, fullOutputPath: str
export async function formatAndWriteTypescript(
output: string,
fullOutputPath: string,
- logPrefix: string
+ logPrefix: string,
): Promise {
const formattedOutput = await formatTypescript(output);
diff --git a/packages/common/src/codegen/utils/loadUserTypesFile.ts b/packages/common/src/codegen/utils/loadUserTypesFile.ts
index cacbd59472..127299d92f 100644
--- a/packages/common/src/codegen/utils/loadUserTypesFile.ts
+++ b/packages/common/src/codegen/utils/loadUserTypesFile.ts
@@ -19,7 +19,7 @@ export type UserType = {
export function loadAndExtractUserTypes(
userTypes: Record,
outputBaseDirectory: string,
- remappings: [string, string][]
+ remappings: [string, string][],
): Record {
const userTypesPerFile: Record = {};
for (const [userTypeName, { filePath: unresolvedFilePath }] of Object.entries(userTypes)) {
@@ -37,7 +37,7 @@ export function loadAndExtractUserTypes(
for (const [userTypeName, userType] of Object.entries(userTypesInFile)) {
if (userType.internalTypeId !== userTypes[userTypeName].internalType) {
throw new MUDError(
- `User type "${userTypeName}" has internal type "${userType.internalTypeId}" but config specifies "${userTypes[userTypeName].internalType}"`
+ `User type "${userTypeName}" has internal type "${userType.internalTypeId}" but config specifies "${userTypes[userTypeName].internalType}"`,
);
}
}
@@ -50,7 +50,7 @@ export function loadAndExtractUserTypes(
function loadUserTypesFile(
outputBaseDirectory: string,
unresolvedFilePath: string,
- remappings: [string, string][]
+ remappings: [string, string][],
): {
filePath: string;
data: string;
diff --git a/packages/common/src/foundry/index.ts b/packages/common/src/foundry/index.ts
index b7f29ee61a..83f20bff42 100644
--- a/packages/common/src/foundry/index.ts
+++ b/packages/common/src/foundry/index.ts
@@ -87,7 +87,7 @@ export async function getRemappings(profile?: string): Promise<[string, string][
*/
export async function forge(
args: string[],
- options?: { profile?: string; silent?: boolean; env?: NodeJS.ProcessEnv }
+ options?: { profile?: string; silent?: boolean; env?: NodeJS.ProcessEnv },
): Promise {
const execOptions: Options = {
env: { FOUNDRY_PROFILE: options?.profile, ...options?.env },
diff --git a/packages/common/src/getContract.ts b/packages/common/src/getContract.ts
index a845359dd8..4f67ad9cae 100644
--- a/packages/common/src/getContract.ts
+++ b/packages/common/src/getContract.ts
@@ -42,7 +42,7 @@ export type GetContractOptions<
TChain extends Chain,
TAccount extends Account,
TPublicClient extends PublicClient,
- TWalletClient extends WalletClient
+ TWalletClient extends WalletClient,
> = GetContractParameters<
TTransport,
TChain,
@@ -56,6 +56,7 @@ export type GetContractOptions<
// TODO: migrate away from this approach once we can hook into viem: https://github.com/wagmi-dev/viem/discussions/1230
+/** @deprecated Use `walletClient.extend(transactionQueue()).extend(writeObserver({ onWrite }))` and viem's `getContract` instead. */
export function getContract<
TTransport extends Transport,
TAddress extends Address,
@@ -63,7 +64,7 @@ export function getContract<
TChain extends Chain,
TAccount extends Account,
TPublicClient extends PublicClient,
- TWalletClient extends WalletClient
+ TWalletClient extends WalletClient,
>({
abi,
address,
@@ -99,7 +100,7 @@ export function getContract<
return (
...parameters: [
args?: readonly unknown[],
- options?: UnionOmit
+ options?: UnionOmit,
]
) => {
const { args, options } = getFunctionParameters(parameters);
@@ -125,7 +126,7 @@ export function getContract<
return result;
};
},
- }
+ },
);
}
diff --git a/packages/common/src/hexToResource.ts b/packages/common/src/hexToResource.ts
index 1ccf25e506..f95c93d15b 100644
--- a/packages/common/src/hexToResource.ts
+++ b/packages/common/src/hexToResource.ts
@@ -6,7 +6,7 @@ import { ReverseMap } from "./type-utils/common";
import { resourceToLabel } from "./resourceLabel";
const resourceTypeIdToType = Object.fromEntries(
- Object.entries(resourceTypeIds).map(([key, value]) => [value, key])
+ Object.entries(resourceTypeIds).map(([key, value]) => [value, key]),
) as ReverseMap;
function getResourceType(resourceTypeId: string): ResourceType | undefined {
@@ -24,9 +24,7 @@ export function hexToResource(hex: Hex): Resource {
const name = hexToString(sliceHex(hex, 16, 32)).replace(/\0+$/, "");
if (!type) {
- throw new Error(
- `Unknown type (${resourceTypeId}) for resource (${resourceTypeId}:${resourceToLabel({ namespace, name })})`
- );
+ throw new Error(`Unknown type (${resourceTypeId}) for resource (${resourceToLabel({ namespace, name })})`);
}
return { resourceId: hex, type, namespace, name };
diff --git a/packages/common/src/sendTransaction.ts b/packages/common/src/sendTransaction.ts
index 9e64497825..b450f5c8d2 100644
--- a/packages/common/src/sendTransaction.ts
+++ b/packages/common/src/sendTransaction.ts
@@ -17,13 +17,14 @@ const debug = parentDebug.extend("sendTransaction");
// TODO: migrate away from this approach once we can hook into viem's nonce management: https://github.com/wagmi-dev/viem/discussions/1230
+/** @deprecated Use `walletClient.extend(transactionQueue())` instead. */
export async function sendTransaction<
TChain extends Chain | undefined,
TAccount extends Account | undefined,
- TChainOverride extends Chain | undefined
+ TChainOverride extends Chain | undefined,
>(
client: Client,
- request: SendTransactionParameters
+ request: SendTransactionParameters,
): Promise {
const rawAccount = request.account ?? client.account;
if (!rawAccount) {
@@ -83,8 +84,8 @@ export async function sendTransaction<
// TODO: prepare again if there are gas errors?
throw error;
},
- }
+ },
),
- { throwOnTimeout: true }
+ { throwOnTimeout: true },
);
}
diff --git a/packages/common/src/utils/groupBy.ts b/packages/common/src/utils/groupBy.ts
index 5a81d49e3f..556f7a89b7 100644
--- a/packages/common/src/utils/groupBy.ts
+++ b/packages/common/src/utils/groupBy.ts
@@ -1,6 +1,6 @@
export function groupBy(
values: readonly value[],
- getKey: (value: value) => key
+ getKey: (value: value) => key,
): Map {
const map = new Map();
for (const value of values) {
diff --git a/packages/common/src/utils/mapObject.ts b/packages/common/src/utils/mapObject.ts
index 189f568657..89434b19b9 100644
--- a/packages/common/src/utils/mapObject.ts
+++ b/packages/common/src/utils/mapObject.ts
@@ -3,9 +3,9 @@
*/
export function mapObject<
Source extends Record,
- Target extends { [key in keyof Source]: unknown }
+ Target extends { [key in keyof Source]: unknown },
>(source: Source, valueMap: (value: Source[typeof key], key: keyof Source) => Target[typeof key]): Target {
return Object.fromEntries(
- Object.entries(source).map(([key, value]) => [key, valueMap(value as Source[keyof Source], key)])
+ Object.entries(source).map(([key, value]) => [key, valueMap(value as Source[keyof Source], key)]),
) as Target;
}
diff --git a/packages/common/src/writeContract.ts b/packages/common/src/writeContract.ts
index 973ecfb8bb..5ce34e5c24 100644
--- a/packages/common/src/writeContract.ts
+++ b/packages/common/src/writeContract.ts
@@ -20,16 +20,17 @@ const debug = parentDebug.extend("writeContract");
// TODO: migrate away from this approach once we can hook into viem's nonce management: https://github.com/wagmi-dev/viem/discussions/1230
+/** @deprecated Use `walletClient.extend(transactionQueue())` instead. */
export async function writeContract<
chain extends Chain | undefined,
account extends Account | undefined,
abi extends Abi | readonly unknown[],
functionName extends ContractFunctionName,
args extends ContractFunctionArgs,
- chainOverride extends Chain | undefined
+ chainOverride extends Chain | undefined,
>(
client: Client,
- request: WriteContractParameters
+ request: WriteContractParameters,
): Promise {
const rawAccount = request.account ?? client.account;
if (!rawAccount) {
@@ -88,8 +89,8 @@ export async function writeContract<
// TODO: prepareWrite again if there are gas errors?
throw error;
},
- }
+ },
),
- { throwOnTimeout: true }
+ { throwOnTimeout: true },
);
}
diff --git a/packages/common/tsup.config.ts b/packages/common/tsup.config.ts
index ba8ccf3917..0a6d6d0491 100644
--- a/packages/common/tsup.config.ts
+++ b/packages/common/tsup.config.ts
@@ -3,6 +3,7 @@ import { defineConfig } from "tsup";
export default defineConfig({
entry: {
index: "src/index.ts",
+ actions: "src/actions/index.ts",
chains: "src/chains/index.ts",
codegen: "src/codegen/index.ts",
errors: "src/errors/index.ts",
diff --git a/packages/config/src/library/dynamicResolution.ts b/packages/config/src/library/dynamicResolution.ts
index 4fc1dbdbcc..cf6e4083eb 100644
--- a/packages/config/src/library/dynamicResolution.ts
+++ b/packages/config/src/library/dynamicResolution.ts
@@ -35,7 +35,7 @@ export function isDynamicResolution(value: unknown): value is DynamicResolution
*/
export function resolveWithContext(
unresolved: any,
- context: { systemAddresses?: Record>; tableIds?: Record }
+ context: { systemAddresses?: Record>; tableIds?: Record },
): ValueWithType {
if (!isDynamicResolution(unresolved)) return unresolved;
let resolved: ValueWithType | undefined = undefined;
diff --git a/packages/create-mud/CHANGELOG.md b/packages/create-mud/CHANGELOG.md
index 71ccd47861..ddb24ed63f 100644
--- a/packages/create-mud/CHANGELOG.md
+++ b/packages/create-mud/CHANGELOG.md
@@ -636,7 +636,7 @@
.pipe(
map((block) => Number(block.timestamp) * 1000), // Map to timestamp in ms
filter((blockTimestamp) => blockTimestamp !== clock.lastUpdateTime), // Ignore if the clock was already refreshed with this block
- filter((blockTimestamp) => blockTimestamp !== clock.currentTime) // Ignore if the current local timestamp is correct
+ filter((blockTimestamp) => blockTimestamp !== clock.currentTime), // Ignore if the current local timestamp is correct
)
.subscribe(clock.update); // Update the local clock
```
diff --git a/packages/dev-tools/src/App.tsx b/packages/dev-tools/src/App.tsx
index 08f1fd7ccb..0d74c3fcae 100644
--- a/packages/dev-tools/src/App.tsx
+++ b/packages/dev-tools/src/App.tsx
@@ -29,7 +29,7 @@ export function App() {
className={twMerge(
"pointer-events-auto w-full max-w-screen-sm h-full absolute right-0",
"transition duration-500",
- shown ? "translate-x-0" : "translate-x-full"
+ shown ? "translate-x-0" : "translate-x-full",
)}
>