From 993201a200e030558a602f1978a45b6f1f7497e4 Mon Sep 17 00:00:00 2001 From: Kevin Ingersoll Date: Thu, 21 Mar 2024 15:14:55 +0000 Subject: [PATCH 1/5] docs: store config changeset --- .changeset/calm-snails-report.md | 114 +++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 .changeset/calm-snails-report.md diff --git a/.changeset/calm-snails-report.md b/.changeset/calm-snails-report.md new file mode 100644 index 0000000000..73de8ba14b --- /dev/null +++ b/.changeset/calm-snails-report.md @@ -0,0 +1,114 @@ +--- +"@latticexyz/store": major +--- + +Store config has been rebuilt with strong types. The shape of the config has also changed slightly for clarity. + +_Note that the Store config is a subset of the World config and if you have a MUD project, you likely want to follow the World changelog for config migration steps._ + +To migrate, first update the imported config method: + +```diff filename="mud.config.ts" +-import { mudConfig } from "@latticexyz/store/register"; ++import { defineStore } from "@latticexyz/store"; + +-export default mudConfig({ ++export default defineStore({ +``` + +Then migrate the table key by renaming `keySchema` to `schema` and define the table `key` with each field name from your key schema: + +```diff filename="mud.config.ts" + export default defineStore({ + tables: { + Position: { +- keySchema: { ++ schema: { + player: "address", + }, + valueSchema: { + x: "int32", + y: "int32", + }, ++ key: ['player'], + }, + }, + }); +``` + +Now we can merge the `valueSchema` into `schema`. + +```diff filename="mud.config.ts" + export default defineStore({ + tables: { + Position: { + schema: { + player: "address", +- }, +- valueSchema: { + x: "int32", + y: "int32", + }, + key: ['player'], + }, + }, + }); +``` + +If you previously used the table config shorthand without the full `keySchema` and `valueSchema`, some of the defaults have changed. Shorthands now use an `id: "bytes32"` field by default rather than `key: "bytes32"` and corresponding `key: ["id"]`. To keep previous behavior, you may have to manually define your `schema` with the previous `key` and `value` fields. + +```diff filename="mud.config.ts" + export default defineStore({ + tables: { +- OwnedBy: "address", ++ OwnedBy: { ++ schema: { ++ key: "bytes32", ++ value: "address", ++ }, ++ key: ["key"], ++ }, + }, + }); +``` + +Singleton tables are defined similarly, where an empty `key` rather than `keySchema` is provided: + +```diff filename="mud.config.ts" +-keySchema: {} ++key: [] +``` + +Offchain tables are now defined as a table `type` instead an `offchainOnly` boolean: + +```diff filename="mud.config.ts" +-offchainOnly: true ++type: 'offchainTable' +``` + +All codegen options have moved under `codegen`: + +```diff filename="mud.config.ts" + export default defineStore({ +- codegenDirectory: "…", ++ codegen: { ++ outputDirectory: "…", ++ }, + tables: { + Position: { + schema: { + player: "address", + x: "int32", + y: "int32", + }, + key: ['player'], +- directory: "…", +- dataStruct: false, ++ codegen: { ++ outputDirectory: "…", ++ dataStruct: false, ++ }, + }, + }, + }); +``` From e7fc0ea4613d1e7aa06d4b8792ee71ba80fdd702 Mon Sep 17 00:00:00 2001 From: Kevin Ingersoll Date: Thu, 21 Mar 2024 15:22:34 +0000 Subject: [PATCH 2/5] docs: world config changeset --- .changeset/brave-dodos-relate.md | 112 +++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 .changeset/brave-dodos-relate.md diff --git a/.changeset/brave-dodos-relate.md b/.changeset/brave-dodos-relate.md new file mode 100644 index 0000000000..27dd245d67 --- /dev/null +++ b/.changeset/brave-dodos-relate.md @@ -0,0 +1,112 @@ +--- +"@latticexyz/world": major +--- + +World config has been rebuilt with strong types. The shape of the config has also changed slightly for clarity. + +To migrate, first update the imported config method: + +```diff filename="mud.config.ts" +-import { mudConfig } from "@latticexyz/world/register"; ++import { defineWorld } from "@latticexyz/world"; + +-export default mudConfig({ ++export default defineWorld({ +``` + +Then migrate the table key by renaming `keySchema` to `schema` and define the table `key` with each field name from your key schema: + +```diff filename="mud.config.ts" + export default defineWorld({ + tables: { + Position: { +- keySchema: { ++ schema: { + player: "address", + }, + valueSchema: { + x: "int32", + y: "int32", + }, ++ key: ['player'], + }, + }, + }); +``` + +Now we can merge the `valueSchema` into `schema`. + +```diff filename="mud.config.ts" + export default defineWorld({ + tables: { + Position: { + schema: { + player: "address", +- }, +- valueSchema: { + x: "int32", + y: "int32", + }, + key: ['player'], + }, + }, + }); +``` + +If you previously used the table config shorthand without the full `keySchema` and `valueSchema`, some of the defaults have changed. Shorthands now use an `id: "bytes32"` field by default rather than `key: "bytes32"` and corresponding `key: ["id"]`. To keep previous behavior, you may have to manually define your `schema` with the previous `key` and `value` fields. + +```diff filename="mud.config.ts" + export default defineWorld({ + tables: { +- OwnedBy: "address", ++ OwnedBy: { ++ schema: { ++ key: "bytes32", ++ value: "address", ++ }, ++ key: ["key"], ++ }, + }, + }); +``` + +Singleton tables are defined similarly, where an empty `key` rather than `keySchema` is provided: + +```diff filename="mud.config.ts" +-keySchema: {} ++key: [] +``` + +Offchain tables are now defined as a table `type` instead an `offchainOnly` boolean: + +```diff filename="mud.config.ts" +-offchainOnly: true ++type: 'offchainTable' +``` + +All codegen options have moved under `codegen`: + +```diff filename="mud.config.ts" + export default defineWorld({ +- codegenDirectory: "…", ++ codegen: { ++ outputDirectory: "…", ++ }, + tables: { + Position: { + schema: { + player: "address", + x: "int32", + y: "int32", + }, + key: ['player'], +- directory: "…", +- dataStruct: false, ++ codegen: { ++ outputDirectory: "…", ++ dataStruct: false, ++ }, + }, + }, + }); +``` From 153f023da505ae8f21f4d2e6272322e189f7f2dd Mon Sep 17 00:00:00 2001 From: Kevin Ingersoll Date: Thu, 21 Mar 2024 15:38:27 +0000 Subject: [PATCH 3/5] small summary of shape change --- .changeset/brave-dodos-relate.md | 2 +- .changeset/calm-snails-report.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.changeset/brave-dodos-relate.md b/.changeset/brave-dodos-relate.md index 27dd245d67..bdac06d092 100644 --- a/.changeset/brave-dodos-relate.md +++ b/.changeset/brave-dodos-relate.md @@ -2,7 +2,7 @@ "@latticexyz/world": major --- -World config has been rebuilt with strong types. The shape of the config has also changed slightly for clarity. +World config has been rebuilt with strong types. The shape of the config has also changed slightly for clarity, the biggest change of which is merging of `keySchema` and `valueSchema` into a single `schema` with a separate `key` for the table's primary key. To migrate, first update the imported config method: diff --git a/.changeset/calm-snails-report.md b/.changeset/calm-snails-report.md index 73de8ba14b..ccf17fc0b2 100644 --- a/.changeset/calm-snails-report.md +++ b/.changeset/calm-snails-report.md @@ -2,7 +2,7 @@ "@latticexyz/store": major --- -Store config has been rebuilt with strong types. The shape of the config has also changed slightly for clarity. +Store config has been rebuilt with strong types. The shape of the config has also changed slightly for clarity, the biggest change of which is merging of `keySchema` and `valueSchema` into a single `schema` with a separate `key` for the table's primary key. _Note that the Store config is a subset of the World config and if you have a MUD project, you likely want to follow the World changelog for config migration steps._ From 4f124906787590fa0b149c911cc0c25cc450a17f Mon Sep 17 00:00:00 2001 From: Kevin Ingersoll Date: Thu, 21 Mar 2024 15:45:32 +0000 Subject: [PATCH 4/5] merge changesets --- .changeset/brave-dodos-relate.md | 5 +- .changeset/calm-snails-report.md | 114 ------------------------------- 2 files changed, 4 insertions(+), 115 deletions(-) delete mode 100644 .changeset/calm-snails-report.md diff --git a/.changeset/brave-dodos-relate.md b/.changeset/brave-dodos-relate.md index bdac06d092..b4f7a8df20 100644 --- a/.changeset/brave-dodos-relate.md +++ b/.changeset/brave-dodos-relate.md @@ -1,8 +1,9 @@ --- +"@latticexyz/store": major "@latticexyz/world": major --- -World config has been rebuilt with strong types. The shape of the config has also changed slightly for clarity, the biggest change of which is merging of `keySchema` and `valueSchema` into a single `schema` with a separate `key` for the table's primary key. +Store and World configs have been rebuilt with strong types. The shape of these configs have also changed slightly for clarity, the biggest change of which is merging of `keySchema` and `valueSchema` into a single `schema` with a separate `key` for the table's primary key. To migrate, first update the imported config method: @@ -14,6 +15,8 @@ To migrate, first update the imported config method: +export default defineWorld({ ``` +_Note that if you are only using Store, you will need to import `defineStore` from `@latticexyz/store`._ + Then migrate the table key by renaming `keySchema` to `schema` and define the table `key` with each field name from your key schema: ```diff filename="mud.config.ts" diff --git a/.changeset/calm-snails-report.md b/.changeset/calm-snails-report.md deleted file mode 100644 index ccf17fc0b2..0000000000 --- a/.changeset/calm-snails-report.md +++ /dev/null @@ -1,114 +0,0 @@ ---- -"@latticexyz/store": major ---- - -Store config has been rebuilt with strong types. The shape of the config has also changed slightly for clarity, the biggest change of which is merging of `keySchema` and `valueSchema` into a single `schema` with a separate `key` for the table's primary key. - -_Note that the Store config is a subset of the World config and if you have a MUD project, you likely want to follow the World changelog for config migration steps._ - -To migrate, first update the imported config method: - -```diff filename="mud.config.ts" --import { mudConfig } from "@latticexyz/store/register"; -+import { defineStore } from "@latticexyz/store"; - --export default mudConfig({ -+export default defineStore({ -``` - -Then migrate the table key by renaming `keySchema` to `schema` and define the table `key` with each field name from your key schema: - -```diff filename="mud.config.ts" - export default defineStore({ - tables: { - Position: { -- keySchema: { -+ schema: { - player: "address", - }, - valueSchema: { - x: "int32", - y: "int32", - }, -+ key: ['player'], - }, - }, - }); -``` - -Now we can merge the `valueSchema` into `schema`. - -```diff filename="mud.config.ts" - export default defineStore({ - tables: { - Position: { - schema: { - player: "address", -- }, -- valueSchema: { - x: "int32", - y: "int32", - }, - key: ['player'], - }, - }, - }); -``` - -If you previously used the table config shorthand without the full `keySchema` and `valueSchema`, some of the defaults have changed. Shorthands now use an `id: "bytes32"` field by default rather than `key: "bytes32"` and corresponding `key: ["id"]`. To keep previous behavior, you may have to manually define your `schema` with the previous `key` and `value` fields. - -```diff filename="mud.config.ts" - export default defineStore({ - tables: { -- OwnedBy: "address", -+ OwnedBy: { -+ schema: { -+ key: "bytes32", -+ value: "address", -+ }, -+ key: ["key"], -+ }, - }, - }); -``` - -Singleton tables are defined similarly, where an empty `key` rather than `keySchema` is provided: - -```diff filename="mud.config.ts" --keySchema: {} -+key: [] -``` - -Offchain tables are now defined as a table `type` instead an `offchainOnly` boolean: - -```diff filename="mud.config.ts" --offchainOnly: true -+type: 'offchainTable' -``` - -All codegen options have moved under `codegen`: - -```diff filename="mud.config.ts" - export default defineStore({ -- codegenDirectory: "…", -+ codegen: { -+ outputDirectory: "…", -+ }, - tables: { - Position: { - schema: { - player: "address", - x: "int32", - y: "int32", - }, - key: ['player'], -- directory: "…", -- dataStruct: false, -+ codegen: { -+ outputDirectory: "…", -+ dataStruct: false, -+ }, - }, - }, - }); -``` From 4bdc54a6e62e549fb65a9650674dcbd76186f667 Mon Sep 17 00:00:00 2001 From: Kevin Ingersoll Date: Thu, 21 Mar 2024 08:51:30 -0700 Subject: [PATCH 5/5] Update brave-dodos-relate.md --- .changeset/brave-dodos-relate.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/brave-dodos-relate.md b/.changeset/brave-dodos-relate.md index b4f7a8df20..ff1ba8ed7d 100644 --- a/.changeset/brave-dodos-relate.md +++ b/.changeset/brave-dodos-relate.md @@ -3,7 +3,7 @@ "@latticexyz/world": major --- -Store and World configs have been rebuilt with strong types. The shape of these configs have also changed slightly for clarity, the biggest change of which is merging of `keySchema` and `valueSchema` into a single `schema` with a separate `key` for the table's primary key. +Store and World configs have been rebuilt with strong types. The shape of these configs have also changed slightly for clarity, the biggest change of which is merging of `keySchema` and `valueSchema` into a single `schema` with a separate `key` for a table's primary key. To migrate, first update the imported config method: