From a35c05ea95395e9c7da3e18030fc200c2cde1353 Mon Sep 17 00:00:00 2001 From: Kevin Ingersoll Date: Fri, 2 Feb 2024 11:39:33 +0000 Subject: [PATCH] feat(cli): hardcode table ID with codegen (#2229) --- .changeset/blue-roses-listen.md | 10 ++ .../contracts/src/codegen/tables/Multi.sol | 6 +- .../contracts/src/codegen/tables/Number.sol | 6 +- .../src/codegen/tables/NumberList.sol | 6 +- .../contracts/src/codegen/tables/Position.sol | 6 +- .../src/codegen/tables/StaticArray.sol | 6 +- .../contracts/src/codegen/tables/Vector.sol | 6 +- .../src/codegen/tables/CounterTable.sol | 6 +- .../src/codegen/tables/Inventory.sol | 6 +- .../src/codegen/tables/MessageTable.sol | 6 +- .../contracts/src/codegen/tables/LastCall.sol | 6 +- .../src/codegen/tables/Dynamics1.sol | 6 +- .../src/codegen/tables/Dynamics2.sol | 6 +- .../contracts/src/codegen/tables/Offchain.sol | 6 +- .../src/codegen/tables/Singleton.sol | 6 +- .../contracts/src/codegen/tables/Statics.sol | 6 +- .../src/codegen/tables/UserTyped.sol | 6 +- .../codegen/render-solidity/common.test.ts | 28 +--- .../src/codegen/render-solidity/common.ts | 18 +-- packages/store/gas-report.json | 150 +++++++++--------- packages/store/src/codegen/tables/Hooks.sol | 1 - .../store/src/codegen/tables/ResourceIds.sol | 6 +- .../store/src/codegen/tables/StoreHooks.sol | 6 +- packages/store/src/codegen/tables/Tables.sol | 6 +- .../store/test/codegen/tables/Callbacks.sol | 6 +- .../store/test/codegen/tables/KeyEncoding.sol | 6 +- packages/store/test/codegen/tables/Mixed.sol | 6 +- .../store/test/codegen/tables/Vector2.sol | 6 +- packages/store/ts/codegen/renderTable.ts | 1 - packages/world-modules/gas-report.json | 104 ++++++------ .../erc20-puppet/tables/Allowances.sol | 1 - .../erc20-puppet/tables/ERC20Metadata.sol | 1 - .../erc20-puppet/tables/ERC20Registry.sol | 1 - .../erc20-puppet/tables/TotalSupply.sol | 1 - .../erc721-puppet/tables/ERC721Metadata.sol | 1 - .../erc721-puppet/tables/ERC721Registry.sol | 1 - .../erc721-puppet/tables/OperatorApproval.sol | 1 - .../modules/erc721-puppet/tables/Owners.sol | 1 - .../erc721-puppet/tables/TokenApproval.sol | 1 - .../modules/erc721-puppet/tables/TokenURI.sol | 1 - .../keysintable/tables/KeysInTable.sol | 6 +- .../keysintable/tables/UsedKeysIndex.sol | 6 +- .../keyswithvalue/tables/KeysWithValue.sol | 1 - .../modules/puppet/tables/PuppetRegistry.sol | 1 - .../tables/CallboundDelegations.sol | 6 +- .../tables/SystemboundDelegations.sol | 6 +- .../tables/TimeboundDelegations.sol | 6 +- .../src/modules/tokens/tables/Balances.sol | 1 - .../uniqueentity/tables/UniqueEntity.sol | 1 - packages/world/gas-report.json | 62 ++++---- .../world/src/codegen/tables/Balances.sol | 6 +- .../src/codegen/tables/FunctionSelectors.sol | 6 +- .../src/codegen/tables/FunctionSignatures.sol | 6 +- .../src/codegen/tables/InitModuleAddress.sol | 6 +- .../src/codegen/tables/InstalledModules.sol | 6 +- .../tables/NamespaceDelegationControl.sol | 6 +- .../src/codegen/tables/NamespaceOwner.sol | 6 +- .../src/codegen/tables/ResourceAccess.sol | 6 +- .../world/src/codegen/tables/SystemHooks.sol | 6 +- .../src/codegen/tables/SystemRegistry.sol | 6 +- packages/world/src/codegen/tables/Systems.sol | 6 +- .../codegen/tables/UserDelegationControl.sol | 6 +- .../test/codegen/tables/AddressArray.sol | 1 - packages/world/test/codegen/tables/Bool.sol | 1 - .../world/test/codegen/tables/TwoFields.sol | 1 - .../contracts/src/codegen/tables/Counter.sol | 6 +- .../contracts/src/codegen/tables/Counter.sol | 6 +- .../contracts/src/codegen/tables/Tasks.sol | 6 +- .../contracts/src/codegen/tables/Position.sol | 6 +- .../contracts/src/codegen/tables/Counter.sol | 6 +- 70 files changed, 274 insertions(+), 387 deletions(-) create mode 100644 .changeset/blue-roses-listen.md diff --git a/.changeset/blue-roses-listen.md b/.changeset/blue-roses-listen.md new file mode 100644 index 0000000000..d9dcf6f08b --- /dev/null +++ b/.changeset/blue-roses-listen.md @@ -0,0 +1,10 @@ +--- +"@latticexyz/cli": patch +"@latticexyz/common": patch +"@latticexyz/store": patch +"@latticexyz/world-modules": patch +"@latticexyz/world": patch +"create-mud": patch +--- + +Table libraries now hardcode the `bytes32` table ID value rather than computing it in Solidity. This saves a bit of gas across all storage operations. diff --git a/e2e/packages/contracts/src/codegen/tables/Multi.sol b/e2e/packages/contracts/src/codegen/tables/Multi.sol index 3e30ab0d5f..99a5c7d699 100644 --- a/e2e/packages/contracts/src/codegen/tables/Multi.sol +++ b/e2e/packages/contracts/src/codegen/tables/Multi.sol @@ -18,11 +18,9 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14(""), bytes16("Multi"))) -); +// 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( diff --git a/e2e/packages/contracts/src/codegen/tables/Number.sol b/e2e/packages/contracts/src/codegen/tables/Number.sol index 53feeb91c7..39654130c2 100644 --- a/e2e/packages/contracts/src/codegen/tables/Number.sol +++ b/e2e/packages/contracts/src/codegen/tables/Number.sol @@ -18,11 +18,9 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14(""), bytes16("Number"))) -); +// 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( diff --git a/e2e/packages/contracts/src/codegen/tables/NumberList.sol b/e2e/packages/contracts/src/codegen/tables/NumberList.sol index 48ed29de1d..426f0600cf 100644 --- a/e2e/packages/contracts/src/codegen/tables/NumberList.sol +++ b/e2e/packages/contracts/src/codegen/tables/NumberList.sol @@ -18,11 +18,9 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14(""), bytes16("NumberList"))) -); +// 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( diff --git a/e2e/packages/contracts/src/codegen/tables/Position.sol b/e2e/packages/contracts/src/codegen/tables/Position.sol index f100614a3c..7a724cc2a1 100644 --- a/e2e/packages/contracts/src/codegen/tables/Position.sol +++ b/e2e/packages/contracts/src/codegen/tables/Position.sol @@ -18,11 +18,9 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14(""), bytes16("Position"))) -); +// 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( diff --git a/e2e/packages/contracts/src/codegen/tables/StaticArray.sol b/e2e/packages/contracts/src/codegen/tables/StaticArray.sol index 977512e429..95a942ff05 100644 --- a/e2e/packages/contracts/src/codegen/tables/StaticArray.sol +++ b/e2e/packages/contracts/src/codegen/tables/StaticArray.sol @@ -18,11 +18,9 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14(""), bytes16("StaticArray"))) -); +// 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( diff --git a/e2e/packages/contracts/src/codegen/tables/Vector.sol b/e2e/packages/contracts/src/codegen/tables/Vector.sol index 17e069e7d4..eb09153136 100644 --- a/e2e/packages/contracts/src/codegen/tables/Vector.sol +++ b/e2e/packages/contracts/src/codegen/tables/Vector.sol @@ -18,11 +18,9 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14(""), bytes16("Vector"))) -); +// 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( diff --git a/examples/minimal/packages/contracts/src/codegen/tables/CounterTable.sol b/examples/minimal/packages/contracts/src/codegen/tables/CounterTable.sol index f0cb4503e2..d3e5442de7 100644 --- a/examples/minimal/packages/contracts/src/codegen/tables/CounterTable.sol +++ b/examples/minimal/packages/contracts/src/codegen/tables/CounterTable.sol @@ -18,11 +18,9 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14(""), bytes16("CounterTable"))) -); +// 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( diff --git a/examples/minimal/packages/contracts/src/codegen/tables/Inventory.sol b/examples/minimal/packages/contracts/src/codegen/tables/Inventory.sol index c95a5e9a88..1b5c163695 100644 --- a/examples/minimal/packages/contracts/src/codegen/tables/Inventory.sol +++ b/examples/minimal/packages/contracts/src/codegen/tables/Inventory.sol @@ -18,11 +18,9 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14(""), bytes16("Inventory"))) -); +// 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( diff --git a/examples/minimal/packages/contracts/src/codegen/tables/MessageTable.sol b/examples/minimal/packages/contracts/src/codegen/tables/MessageTable.sol index ca0ac16ff3..aadbffde7c 100644 --- a/examples/minimal/packages/contracts/src/codegen/tables/MessageTable.sol +++ b/examples/minimal/packages/contracts/src/codegen/tables/MessageTable.sol @@ -18,11 +18,9 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_OFFCHAIN_TABLE, bytes14(""), bytes16("MessageTable"))) -); +// 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( 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 d6d71edc25..63fc9b3fb1 100644 --- a/examples/multiple-accounts/packages/contracts/src/codegen/tables/LastCall.sol +++ b/examples/multiple-accounts/packages/contracts/src/codegen/tables/LastCall.sol @@ -18,11 +18,9 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14("LastCall"), bytes16("LastCall"))) -); +// 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( diff --git a/packages/cli/contracts/src/codegen/tables/Dynamics1.sol b/packages/cli/contracts/src/codegen/tables/Dynamics1.sol index 9143895f0d..7267718a35 100644 --- a/packages/cli/contracts/src/codegen/tables/Dynamics1.sol +++ b/packages/cli/contracts/src/codegen/tables/Dynamics1.sol @@ -18,11 +18,9 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14(""), bytes16("Dynamics1"))) -); +// 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( diff --git a/packages/cli/contracts/src/codegen/tables/Dynamics2.sol b/packages/cli/contracts/src/codegen/tables/Dynamics2.sol index 58eae21bd5..4c877d16a6 100644 --- a/packages/cli/contracts/src/codegen/tables/Dynamics2.sol +++ b/packages/cli/contracts/src/codegen/tables/Dynamics2.sol @@ -18,11 +18,9 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14(""), bytes16("Dynamics2"))) -); +// 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( diff --git a/packages/cli/contracts/src/codegen/tables/Offchain.sol b/packages/cli/contracts/src/codegen/tables/Offchain.sol index bda58e250f..7d83afabc0 100644 --- a/packages/cli/contracts/src/codegen/tables/Offchain.sol +++ b/packages/cli/contracts/src/codegen/tables/Offchain.sol @@ -18,11 +18,9 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_OFFCHAIN_TABLE, bytes14(""), bytes16("Offchain"))) -); +// 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( diff --git a/packages/cli/contracts/src/codegen/tables/Singleton.sol b/packages/cli/contracts/src/codegen/tables/Singleton.sol index 809df6e628..af76be1d8a 100644 --- a/packages/cli/contracts/src/codegen/tables/Singleton.sol +++ b/packages/cli/contracts/src/codegen/tables/Singleton.sol @@ -18,11 +18,9 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14(""), bytes16("Singleton"))) -); +// 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( diff --git a/packages/cli/contracts/src/codegen/tables/Statics.sol b/packages/cli/contracts/src/codegen/tables/Statics.sol index 50406a93c3..ef1fcffa55 100644 --- a/packages/cli/contracts/src/codegen/tables/Statics.sol +++ b/packages/cli/contracts/src/codegen/tables/Statics.sol @@ -18,14 +18,12 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; // Import user types import { Enum2, Enum1 } from "./../common.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14(""), bytes16("Statics"))) -); +// 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( diff --git a/packages/cli/contracts/src/codegen/tables/UserTyped.sol b/packages/cli/contracts/src/codegen/tables/UserTyped.sol index d2bb83fa35..ccb63dbdca 100644 --- a/packages/cli/contracts/src/codegen/tables/UserTyped.sol +++ b/packages/cli/contracts/src/codegen/tables/UserTyped.sol @@ -18,15 +18,13 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; // Import user types import { TestTypeAddress, TestTypeInt64, TestTypeLibrary } from "./../../types.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14(""), bytes16("UserTyped"))) -); +// 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( diff --git a/packages/common/src/codegen/render-solidity/common.test.ts b/packages/common/src/codegen/render-solidity/common.test.ts index 87f0145d7a..e51e849b4f 100644 --- a/packages/common/src/codegen/render-solidity/common.test.ts +++ b/packages/common/src/codegen/render-solidity/common.test.ts @@ -62,34 +62,20 @@ describe("renderTableId", () => { it("returns Solidity code to compute table ID", () => { expect(renderTableId({ namespace: "somewhere", name: "Player", offchainOnly: false, tableIdName: "PlayerTableId" })) .toMatchInlineSnapshot(` - " - ResourceId constant _tableId = ResourceId.wrap( - bytes32( - abi.encodePacked( - RESOURCE_TABLE, - bytes14(\\"somewhere\\"), - bytes16(\\"Player\\") - ) - ) - ); - ResourceId constant PlayerTableId = _tableId; " - `); + // 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(` " - ResourceId constant _tableId = ResourceId.wrap( - bytes32( - abi.encodePacked( - RESOURCE_OFFCHAIN_TABLE, - bytes14(\\"somewhere\\"), - bytes16(\\"Player\\") - ) - ) - ); + // 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 ff95b9537d..ea985a0146 100644 --- a/packages/common/src/codegen/render-solidity/common.ts +++ b/packages/common/src/codegen/render-solidity/common.ts @@ -8,6 +8,7 @@ import { RenderType, } from "./types"; import { posixPath } from "../utils"; +import { resourceToHex } from "../../resourceToHex"; /** * Common header for all codegenerated solidity files @@ -213,15 +214,14 @@ export function renderTableId({ tableIdName, }: Pick): string { return ` - ResourceId constant _tableId = ResourceId.wrap( - bytes32( - abi.encodePacked( - ${offchainOnly ? "RESOURCE_OFFCHAIN_TABLE" : "RESOURCE_TABLE"}, - bytes14("${namespace}"), - bytes16("${name}") - ) - ) - ); + // Hex below is the result of \`WorldResourceIdLib.encode({ namespace: ${JSON.stringify( + 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; `; } diff --git a/packages/store/gas-report.json b/packages/store/gas-report.json index 9741002bd9..412450e007 100644 --- a/packages/store/gas-report.json +++ b/packages/store/gas-report.json @@ -15,19 +15,19 @@ "file": "test/Callbacks.t.sol", "test": "testSetAndGet", "name": "Callbacks: set field", - "gasUsed": 56262 + "gasUsed": 55829 }, { "file": "test/Callbacks.t.sol", "test": "testSetAndGet", "name": "Callbacks: get field (warm)", - "gasUsed": 2833 + "gasUsed": 2615 }, { "file": "test/Callbacks.t.sol", "test": "testSetAndGet", "name": "Callbacks: push 1 element", - "gasUsed": 32520 + "gasUsed": 32114 }, { "file": "test/FieldLayout.t.sol", @@ -321,7 +321,7 @@ "file": "test/KeyEncoding.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "register KeyEncoding table", - "gasUsed": 725222 + "gasUsed": 723941 }, { "file": "test/Mixed.t.sol", @@ -333,49 +333,49 @@ "file": "test/Mixed.t.sol", "test": "testDeleteExternalCold", "name": "delete record from Mixed (external, cold)", - "gasUsed": 24363 + "gasUsed": 23515 }, { "file": "test/Mixed.t.sol", "test": "testDeleteInternalCold", "name": "delete record from Mixed (internal, cold)", - "gasUsed": 19159 + "gasUsed": 18724 }, { "file": "test/Mixed.t.sol", "test": "testSetGetDeleteExternal", "name": "set record in Mixed (external, cold)", - "gasUsed": 108513 + "gasUsed": 107665 }, { "file": "test/Mixed.t.sol", "test": "testSetGetDeleteExternal", "name": "get record from Mixed (external, warm)", - "gasUsed": 6977 + "gasUsed": 6746 }, { "file": "test/Mixed.t.sol", "test": "testSetGetDeleteExternal", "name": "delete record from Mixed (external, warm)", - "gasUsed": 8679 + "gasUsed": 7826 }, { "file": "test/Mixed.t.sol", "test": "testSetGetDeleteInternal", "name": "set record in Mixed (internal, cold)", - "gasUsed": 103267 + "gasUsed": 102831 }, { "file": "test/Mixed.t.sol", "test": "testSetGetDeleteInternal", "name": "get record from Mixed (internal, warm)", - "gasUsed": 6663 + "gasUsed": 6434 }, { "file": "test/Mixed.t.sol", "test": "testSetGetDeleteInternal", "name": "delete record from Mixed (internal, warm)", - "gasUsed": 7472 + "gasUsed": 7033 }, { "file": "test/PackedCounter.t.sol", @@ -603,13 +603,13 @@ "file": "test/StoreCoreDynamic.t.sol", "test": "testGetSecondFieldLength", "name": "get field length (warm, 1 slot)", - "gasUsed": 1160 + "gasUsed": 1161 }, { "file": "test/StoreCoreDynamic.t.sol", "test": "testGetThirdFieldLength", "name": "get field length (warm due to , 2 slots)", - "gasUsed": 3163 + "gasUsed": 3164 }, { "file": "test/StoreCoreDynamic.t.sol", @@ -621,31 +621,31 @@ "file": "test/StoreCoreDynamic.t.sol", "test": "testPopFromSecondField", "name": "pop from field (cold, 1 slot, 1 uint32 item)", - "gasUsed": 18035 + "gasUsed": 17819 }, { "file": "test/StoreCoreDynamic.t.sol", "test": "testPopFromSecondField", "name": "pop from field (warm, 1 slot, 1 uint32 item)", - "gasUsed": 12043 + "gasUsed": 11825 }, { "file": "test/StoreCoreDynamic.t.sol", "test": "testPopFromThirdField", "name": "pop from field (cold, 2 slots, 10 uint32 items)", - "gasUsed": 15804 + "gasUsed": 15588 }, { "file": "test/StoreCoreDynamic.t.sol", "test": "testPopFromThirdField", "name": "pop from field (warm, 2 slots, 10 uint32 items)", - "gasUsed": 11812 + "gasUsed": 11594 }, { "file": "test/StoreCoreGas.t.sol", "test": "testAccessEmptyData", "name": "access non-existing record", - "gasUsed": 7074 + "gasUsed": 7073 }, { "file": "test/StoreCoreGas.t.sol", @@ -657,25 +657,25 @@ "file": "test/StoreCoreGas.t.sol", "test": "testAccessEmptyData", "name": "access dynamic field of non-existing record", - "gasUsed": 2063 + "gasUsed": 2062 }, { "file": "test/StoreCoreGas.t.sol", "test": "testAccessEmptyData", "name": "access length of dynamic field of non-existing record", - "gasUsed": 1159 + "gasUsed": 1158 }, { "file": "test/StoreCoreGas.t.sol", "test": "testDeleteData", "name": "delete record (complex data, 3 slots)", - "gasUsed": 8006 + "gasUsed": 7373 }, { "file": "test/StoreCoreGas.t.sol", "test": "testDeleteDataOffchainTable", "name": "StoreCore: delete record in offchain table", - "gasUsed": 4688 + "gasUsed": 4277 }, { "file": "test/StoreCoreGas.t.sol", @@ -693,103 +693,103 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHasFieldLayout", "name": "Check for existence of table (existent)", - "gasUsed": 1249 + "gasUsed": 1032 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHasFieldLayout", "name": "check for existence of table (non-existent)", - "gasUsed": 3249 + "gasUsed": 3033 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooks", "name": "register subscriber", - "gasUsed": 56903 + "gasUsed": 56304 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooks", "name": "set record on table with subscriber", - "gasUsed": 72222 + "gasUsed": 70986 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooks", "name": "set static field on table with subscriber", - "gasUsed": 19674 + "gasUsed": 19248 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooks", "name": "delete record on table with subscriber", - "gasUsed": 18433 + "gasUsed": 17197 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", "name": "register subscriber", - "gasUsed": 56903 + "gasUsed": 56304 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", "name": "set (dynamic) record on table with subscriber", - "gasUsed": 165356 + "gasUsed": 164119 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", "name": "set (dynamic) field on table with subscriber", - "gasUsed": 24283 + "gasUsed": 23856 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", "name": "delete (dynamic) record on table with subscriber", - "gasUsed": 20099 + "gasUsed": 18862 }, { "file": "test/StoreCoreGas.t.sol", "test": "testPushToDynamicField", "name": "push to field (1 slot, 1 uint32 item)", - "gasUsed": 9469 + "gasUsed": 9250 }, { "file": "test/StoreCoreGas.t.sol", "test": "testPushToDynamicField", "name": "push to field (2 slots, 10 uint32 items)", - "gasUsed": 32141 + "gasUsed": 31922 }, { "file": "test/StoreCoreGas.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "StoreCore: register table", - "gasUsed": 648923 + "gasUsed": 647841 }, { "file": "test/StoreCoreGas.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "StoreCore: get field layout (warm)", - "gasUsed": 922 + "gasUsed": 508 }, { "file": "test/StoreCoreGas.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "StoreCore: get value schema (warm)", - "gasUsed": 1666 + "gasUsed": 1441 }, { "file": "test/StoreCoreGas.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "StoreCore: get key schema (warm)", - "gasUsed": 2755 + "gasUsed": 2313 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetDynamicData", "name": "set complex record with dynamic data (4 slots)", - "gasUsed": 102498 + "gasUsed": 101866 }, { "file": "test/StoreCoreGas.t.sol", @@ -807,7 +807,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetDynamicData", "name": "compare: Set complex record with dynamic data using abi.encode", - "gasUsed": 267535 + "gasUsed": 267534 }, { "file": "test/StoreCoreGas.t.sol", @@ -819,31 +819,31 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetDynamicDataLength", "name": "set dynamic length of dynamic index 1", - "gasUsed": 968 + "gasUsed": 967 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetDynamicDataLength", "name": "reduce dynamic length of dynamic index 0", - "gasUsed": 958 + "gasUsed": 957 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "set static field (1 slot)", - "gasUsed": 31243 + "gasUsed": 31026 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "get static field (1 slot)", - "gasUsed": 1330 + "gasUsed": 1331 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "set static field (overlap 2 slot)", - "gasUsed": 29828 + "gasUsed": 29609 }, { "file": "test/StoreCoreGas.t.sol", @@ -855,7 +855,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "set dynamic field (1 slot, first dynamic field)", - "gasUsed": 53952 + "gasUsed": 53732 }, { "file": "test/StoreCoreGas.t.sol", @@ -867,31 +867,31 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "set dynamic field (1 slot, second dynamic field)", - "gasUsed": 32177 + "gasUsed": 31957 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "get dynamic field (1 slot, second dynamic field)", - "gasUsed": 2230 + "gasUsed": 2229 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetStaticData", "name": "set static record (1 slot)", - "gasUsed": 32773 + "gasUsed": 32142 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetStaticData", "name": "get static record (1 slot)", - "gasUsed": 1552 + "gasUsed": 1551 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetStaticDataSpanningWords", "name": "set static record (2 slots)", - "gasUsed": 55280 + "gasUsed": 54649 }, { "file": "test/StoreCoreGas.t.sol", @@ -903,19 +903,19 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetDataOffchainTable", "name": "StoreCore: set record in offchain table", - "gasUsed": 8093 + "gasUsed": 7681 }, { "file": "test/StoreCoreGas.t.sol", "test": "testUpdateInDynamicField", "name": "update in field (1 slot, 1 uint32 item)", - "gasUsed": 8829 + "gasUsed": 8610 }, { "file": "test/StoreCoreGas.t.sol", "test": "testUpdateInDynamicField", "name": "push to field (2 slots, 6 uint64 items)", - "gasUsed": 9273 + "gasUsed": 9053 }, { "file": "test/StoreHook.t.sol", @@ -945,103 +945,103 @@ "file": "test/StoreHooks.t.sol", "test": "testOneSlot", "name": "StoreHooks: set field with one elements (cold)", - "gasUsed": 58266 + "gasUsed": 57824 }, { "file": "test/StoreHooks.t.sol", "test": "testTable", "name": "StoreHooks: set field (cold)", - "gasUsed": 58266 + "gasUsed": 57824 }, { "file": "test/StoreHooks.t.sol", "test": "testTable", "name": "StoreHooks: get field (warm)", - "gasUsed": 2835 + "gasUsed": 2612 }, { "file": "test/StoreHooks.t.sol", "test": "testTable", "name": "StoreHooks: push 1 element (cold)", - "gasUsed": 12617 + "gasUsed": 12202 }, { "file": "test/StoreHooks.t.sol", "test": "testTable", "name": "StoreHooks: pop 1 element (warm)", - "gasUsed": 9952 + "gasUsed": 9506 }, { "file": "test/StoreHooks.t.sol", "test": "testTable", "name": "StoreHooks: push 1 element (warm)", - "gasUsed": 10637 + "gasUsed": 10218 }, { "file": "test/StoreHooks.t.sol", "test": "testTable", "name": "StoreHooks: update 1 element (warm)", - "gasUsed": 29877 + "gasUsed": 29452 }, { "file": "test/StoreHooks.t.sol", "test": "testTable", "name": "StoreHooks: delete record (warm)", - "gasUsed": 10419 + "gasUsed": 9552 }, { "file": "test/StoreHooks.t.sol", "test": "testTable", "name": "StoreHooks: set field (warm)", - "gasUsed": 30418 + "gasUsed": 29965 }, { "file": "test/StoreHooks.t.sol", "test": "testThreeSlots", "name": "StoreHooks: set field with three elements (cold)", - "gasUsed": 80957 + "gasUsed": 80515 }, { "file": "test/StoreHooks.t.sol", "test": "testTwoSlots", "name": "StoreHooks: set field with two elements (cold)", - "gasUsed": 80869 + "gasUsed": 80427 }, { "file": "test/StoreHooksColdLoad.t.sol", "test": "testDelete", "name": "StoreHooks: delete record (cold)", - "gasUsed": 19277 + "gasUsed": 18424 }, { "file": "test/StoreHooksColdLoad.t.sol", "test": "testGet", "name": "StoreHooks: get field (cold)", - "gasUsed": 8832 + "gasUsed": 8610 }, { "file": "test/StoreHooksColdLoad.t.sol", "test": "testGetItem", "name": "StoreHooks: get 1 element (cold)", - "gasUsed": 8443 + "gasUsed": 8224 }, { "file": "test/StoreHooksColdLoad.t.sol", "test": "testLength", "name": "StoreHooks: get length (cold)", - "gasUsed": 5394 + "gasUsed": 5172 }, { "file": "test/StoreHooksColdLoad.t.sol", "test": "testPop", "name": "StoreHooks: pop 1 element (cold)", - "gasUsed": 18384 + "gasUsed": 17942 }, { "file": "test/StoreHooksColdLoad.t.sol", "test": "testUpdate", "name": "StoreHooks: update 1 element (cold)", - "gasUsed": 20324 + "gasUsed": 19906 }, { "file": "test/StoreSwitch.t.sol", @@ -1107,18 +1107,18 @@ "file": "test/Vector2.t.sol", "test": "testRegisterAndGetFieldLayout", "name": "register Vector2 field layout", - "gasUsed": 449007 + "gasUsed": 447721 }, { "file": "test/Vector2.t.sol", "test": "testSetAndGet", "name": "set Vector2 record", - "gasUsed": 33675 + "gasUsed": 32824 }, { "file": "test/Vector2.t.sol", "test": "testSetAndGet", "name": "get Vector2 record", - "gasUsed": 2536 + "gasUsed": 2306 } ] diff --git a/packages/store/src/codegen/tables/Hooks.sol b/packages/store/src/codegen/tables/Hooks.sol index 280ec76835..117ee33579 100644 --- a/packages/store/src/codegen/tables/Hooks.sol +++ b/packages/store/src/codegen/tables/Hooks.sol @@ -18,7 +18,6 @@ import { FieldLayout, FieldLayoutLib } from "../../FieldLayout.sol"; import { Schema, SchemaLib } from "../../Schema.sol"; import { PackedCounter, PackedCounterLib } from "../../PackedCounter.sol"; import { ResourceId } from "../../ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "../../storeResourceTypes.sol"; // Import user types import { ResourceId } from "./../../ResourceId.sol"; diff --git a/packages/store/src/codegen/tables/ResourceIds.sol b/packages/store/src/codegen/tables/ResourceIds.sol index 49534752ec..555c16cde4 100644 --- a/packages/store/src/codegen/tables/ResourceIds.sol +++ b/packages/store/src/codegen/tables/ResourceIds.sol @@ -18,14 +18,12 @@ import { FieldLayout, FieldLayoutLib } from "../../FieldLayout.sol"; import { Schema, SchemaLib } from "../../Schema.sol"; import { PackedCounter, PackedCounterLib } from "../../PackedCounter.sol"; import { ResourceId } from "../../ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "../../storeResourceTypes.sol"; // Import user types import { ResourceId } from "./../../ResourceId.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14("store"), bytes16("ResourceIds"))) -); +// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "store", name: "ResourceIds", typeId: RESOURCE_TABLE });` +ResourceId constant _tableId = ResourceId.wrap(0x746273746f72650000000000000000005265736f757263654964730000000000); ResourceId constant ResourceIdsTableId = _tableId; FieldLayout constant _fieldLayout = FieldLayout.wrap( diff --git a/packages/store/src/codegen/tables/StoreHooks.sol b/packages/store/src/codegen/tables/StoreHooks.sol index 5722f81f7d..10917219c9 100644 --- a/packages/store/src/codegen/tables/StoreHooks.sol +++ b/packages/store/src/codegen/tables/StoreHooks.sol @@ -18,14 +18,12 @@ import { FieldLayout, FieldLayoutLib } from "../../FieldLayout.sol"; import { Schema, SchemaLib } from "../../Schema.sol"; import { PackedCounter, PackedCounterLib } from "../../PackedCounter.sol"; import { ResourceId } from "../../ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "../../storeResourceTypes.sol"; // Import user types import { ResourceId } from "./../../ResourceId.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14("store"), bytes16("StoreHooks"))) -); +// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "store", name: "StoreHooks", typeId: RESOURCE_TABLE });` +ResourceId constant _tableId = ResourceId.wrap(0x746273746f726500000000000000000053746f7265486f6f6b73000000000000); ResourceId constant StoreHooksTableId = _tableId; FieldLayout constant _fieldLayout = FieldLayout.wrap( diff --git a/packages/store/src/codegen/tables/Tables.sol b/packages/store/src/codegen/tables/Tables.sol index 070f78c1e9..17e0190294 100644 --- a/packages/store/src/codegen/tables/Tables.sol +++ b/packages/store/src/codegen/tables/Tables.sol @@ -18,16 +18,14 @@ import { FieldLayout, FieldLayoutLib } from "../../FieldLayout.sol"; import { Schema, SchemaLib } from "../../Schema.sol"; import { PackedCounter, PackedCounterLib } from "../../PackedCounter.sol"; import { ResourceId } from "../../ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "../../storeResourceTypes.sol"; // Import user types import { ResourceId } from "./../../ResourceId.sol"; import { FieldLayout } from "./../../FieldLayout.sol"; import { Schema } from "./../../Schema.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14("store"), bytes16("Tables"))) -); +// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "store", name: "Tables", typeId: RESOURCE_TABLE });` +ResourceId constant _tableId = ResourceId.wrap(0x746273746f72650000000000000000005461626c657300000000000000000000); ResourceId constant TablesTableId = _tableId; FieldLayout constant _fieldLayout = FieldLayout.wrap( diff --git a/packages/store/test/codegen/tables/Callbacks.sol b/packages/store/test/codegen/tables/Callbacks.sol index 0aff1e88d1..b69a323a2c 100644 --- a/packages/store/test/codegen/tables/Callbacks.sol +++ b/packages/store/test/codegen/tables/Callbacks.sol @@ -18,11 +18,9 @@ import { FieldLayout, FieldLayoutLib } from "../../../src/FieldLayout.sol"; import { Schema, SchemaLib } from "../../../src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "../../../src/PackedCounter.sol"; import { ResourceId } from "../../../src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "../../../src/storeResourceTypes.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14("store"), bytes16("Callbacks"))) -); +// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "store", name: "Callbacks", typeId: RESOURCE_TABLE });` +ResourceId constant _tableId = ResourceId.wrap(0x746273746f726500000000000000000043616c6c6261636b7300000000000000); ResourceId constant CallbacksTableId = _tableId; FieldLayout constant _fieldLayout = FieldLayout.wrap( diff --git a/packages/store/test/codegen/tables/KeyEncoding.sol b/packages/store/test/codegen/tables/KeyEncoding.sol index 8b29be3932..ecdf0b260b 100644 --- a/packages/store/test/codegen/tables/KeyEncoding.sol +++ b/packages/store/test/codegen/tables/KeyEncoding.sol @@ -18,14 +18,12 @@ import { FieldLayout, FieldLayoutLib } from "../../../src/FieldLayout.sol"; import { Schema, SchemaLib } from "../../../src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "../../../src/PackedCounter.sol"; import { ResourceId } from "../../../src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "../../../src/storeResourceTypes.sol"; // Import user types import { ExampleEnum } from "./../common.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14("store"), bytes16("KeyEncoding"))) -); +// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "store", name: "KeyEncoding", typeId: RESOURCE_TABLE });` +ResourceId constant _tableId = ResourceId.wrap(0x746273746f72650000000000000000004b6579456e636f64696e670000000000); ResourceId constant KeyEncodingTableId = _tableId; FieldLayout constant _fieldLayout = FieldLayout.wrap( diff --git a/packages/store/test/codegen/tables/Mixed.sol b/packages/store/test/codegen/tables/Mixed.sol index 3b8a89388e..57a7977e55 100644 --- a/packages/store/test/codegen/tables/Mixed.sol +++ b/packages/store/test/codegen/tables/Mixed.sol @@ -18,11 +18,9 @@ import { FieldLayout, FieldLayoutLib } from "../../../src/FieldLayout.sol"; import { Schema, SchemaLib } from "../../../src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "../../../src/PackedCounter.sol"; import { ResourceId } from "../../../src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "../../../src/storeResourceTypes.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14("store"), bytes16("Mixed"))) -); +// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "store", name: "Mixed", typeId: RESOURCE_TABLE });` +ResourceId constant _tableId = ResourceId.wrap(0x746273746f72650000000000000000004d697865640000000000000000000000); ResourceId constant MixedTableId = _tableId; FieldLayout constant _fieldLayout = FieldLayout.wrap( diff --git a/packages/store/test/codegen/tables/Vector2.sol b/packages/store/test/codegen/tables/Vector2.sol index 1cdb0de49c..687db88179 100644 --- a/packages/store/test/codegen/tables/Vector2.sol +++ b/packages/store/test/codegen/tables/Vector2.sol @@ -18,11 +18,9 @@ import { FieldLayout, FieldLayoutLib } from "../../../src/FieldLayout.sol"; import { Schema, SchemaLib } from "../../../src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "../../../src/PackedCounter.sol"; import { ResourceId } from "../../../src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "../../../src/storeResourceTypes.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14("store"), bytes16("Vector2"))) -); +// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "store", name: "Vector2", typeId: RESOURCE_TABLE });` +ResourceId constant _tableId = ResourceId.wrap(0x746273746f7265000000000000000000566563746f7232000000000000000000); ResourceId constant Vector2TableId = _tableId; FieldLayout constant _fieldLayout = FieldLayout.wrap( diff --git a/packages/store/ts/codegen/renderTable.ts b/packages/store/ts/codegen/renderTable.ts index 2a11d74847..9bcd9fa05b 100644 --- a/packages/store/ts/codegen/renderTable.ts +++ b/packages/store/ts/codegen/renderTable.ts @@ -55,7 +55,6 @@ export function renderTable(options: RenderTableOptions) { import { Schema, SchemaLib } from "${storeImportPath}Schema.sol"; import { PackedCounter, PackedCounterLib } from "${storeImportPath}PackedCounter.sol"; import { ResourceId } from "${storeImportPath}ResourceId.sol"; - import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "${storeImportPath}storeResourceTypes.sol"; ${ imports.length > 0 diff --git a/packages/world-modules/gas-report.json b/packages/world-modules/gas-report.json index a899568577..4da91a9a3a 100644 --- a/packages/world-modules/gas-report.json +++ b/packages/world-modules/gas-report.json @@ -3,139 +3,139 @@ "file": "test/ERC20.t.sol", "test": "testApprove", "name": "approve", - "gasUsed": 114363 + "gasUsed": 111908 }, { "file": "test/ERC20.t.sol", "test": "testBurn", "name": "burn", - "gasUsed": 75925 + "gasUsed": 72580 }, { "file": "test/ERC20.t.sol", "test": "testMint", "name": "mint", - "gasUsed": 161764 + "gasUsed": 158419 }, { "file": "test/ERC20.t.sol", "test": "testTransfer", "name": "transfer", - "gasUsed": 93010 + "gasUsed": 90086 }, { "file": "test/ERC20.t.sol", "test": "testTransferFrom", "name": "transferFrom", - "gasUsed": 130356 + "gasUsed": 126121 }, { "file": "test/ERC721.t.sol", "test": "testApproveAllGas", "name": "setApprovalForAll", - "gasUsed": 113987 + "gasUsed": 111531 }, { "file": "test/ERC721.t.sol", "test": "testApproveGas", "name": "approve", - "gasUsed": 87996 + "gasUsed": 85330 }, { "file": "test/ERC721.t.sol", "test": "testBurnGas", "name": "burn", - "gasUsed": 101925 + "gasUsed": 97480 }, { "file": "test/ERC721.t.sol", "test": "testMintGas", "name": "mint", - "gasUsed": 169495 + "gasUsed": 165728 }, { "file": "test/ERC721.t.sol", "test": "testSafeMintToEOAGas", "name": "safeMint", - "gasUsed": 169766 + "gasUsed": 165999 }, { "file": "test/ERC721.t.sol", "test": "testSafeTransferFromToEOAGas", "name": "safeTransferFrom", - "gasUsed": 143759 + "gasUsed": 139054 }, { "file": "test/ERC721.t.sol", "test": "testTransferFromGas", "name": "transferFrom", - "gasUsed": 136916 + "gasUsed": 132422 }, { "file": "test/KeysInTableModule.t.sol", "test": "testInstallComposite", "name": "install keys in table module", - "gasUsed": 1435619 + "gasUsed": 1424316 }, { "file": "test/KeysInTableModule.t.sol", "test": "testInstallGas", "name": "install keys in table module", - "gasUsed": 1435619 + "gasUsed": 1424316 }, { "file": "test/KeysInTableModule.t.sol", "test": "testInstallGas", "name": "set a record on a table with keysInTableModule installed", - "gasUsed": 158688 + "gasUsed": 154734 }, { "file": "test/KeysInTableModule.t.sol", "test": "testInstallSingleton", "name": "install keys in table module", - "gasUsed": 1435619 + "gasUsed": 1424316 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookCompositeGas", "name": "install keys in table module", - "gasUsed": 1435619 + "gasUsed": 1424316 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookCompositeGas", "name": "change a composite record on a table with keysInTableModule installed", - "gasUsed": 22341 + "gasUsed": 21240 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookCompositeGas", "name": "delete a composite record on a table with keysInTableModule installed", - "gasUsed": 155725 + "gasUsed": 145764 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookGas", "name": "install keys in table module", - "gasUsed": 1435619 + "gasUsed": 1424316 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookGas", "name": "change a record on a table with keysInTableModule installed", - "gasUsed": 21063 + "gasUsed": 19963 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookGas", "name": "delete a record on a table with keysInTableModule installed", - "gasUsed": 84947 + "gasUsed": 78999 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testGetKeysWithValueGas", "name": "install keys with value module", - "gasUsed": 685490 + "gasUsed": 676716 }, { "file": "test/KeysWithValueModule.t.sol", @@ -153,174 +153,174 @@ "file": "test/KeysWithValueModule.t.sol", "test": "testInstall", "name": "install keys with value module", - "gasUsed": 685490 + "gasUsed": 676716 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testInstall", "name": "set a record on a table with KeysWithValueModule installed", - "gasUsed": 135268 + "gasUsed": 132557 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetAndDeleteRecordHook", "name": "install keys with value module", - "gasUsed": 685490 + "gasUsed": 676716 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetAndDeleteRecordHook", "name": "change a record on a table with KeysWithValueModule installed", - "gasUsed": 103529 + "gasUsed": 101222 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetAndDeleteRecordHook", "name": "delete a record on a table with KeysWithValueModule installed", - "gasUsed": 36255 + "gasUsed": 34255 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetField", "name": "install keys with value module", - "gasUsed": 685490 + "gasUsed": 676716 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetField", "name": "set a field on a table with KeysWithValueModule installed", - "gasUsed": 146503 + "gasUsed": 143767 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetField", "name": "change a field on a table with KeysWithValueModule installed", - "gasUsed": 111191 + "gasUsed": 108454 }, { "file": "test/query.t.sol", "test": "testCombinedHasHasValueNotQuery", "name": "CombinedHasHasValueNotQuery", - "gasUsed": 101661 + "gasUsed": 96338 }, { "file": "test/query.t.sol", "test": "testCombinedHasHasValueQuery", "name": "CombinedHasHasValueQuery", - "gasUsed": 51507 + "gasUsed": 49724 }, { "file": "test/query.t.sol", "test": "testCombinedHasNotQuery", "name": "CombinedHasNotQuery", - "gasUsed": 128249 + "gasUsed": 119185 }, { "file": "test/query.t.sol", "test": "testCombinedHasQuery", "name": "CombinedHasQuery", - "gasUsed": 82505 + "gasUsed": 76121 }, { "file": "test/query.t.sol", "test": "testCombinedHasValueNotQuery", "name": "CombinedHasValueNotQuery", - "gasUsed": 82827 + "gasUsed": 77523 }, { "file": "test/query.t.sol", "test": "testCombinedHasValueQuery", "name": "CombinedHasValueQuery", - "gasUsed": 15042 + "gasUsed": 15030 }, { "file": "test/query.t.sol", "test": "testHasQuery", "name": "HasQuery", - "gasUsed": 18589 + "gasUsed": 17052 }, { "file": "test/query.t.sol", "test": "testHasQuery1000Keys", "name": "HasQuery with 1000 keys", - "gasUsed": 5693514 + "gasUsed": 5342895 }, { "file": "test/query.t.sol", "test": "testHasQuery100Keys", "name": "HasQuery with 100 keys", - "gasUsed": 530367 + "gasUsed": 505577 }, { "file": "test/query.t.sol", "test": "testHasValueQuery", "name": "HasValueQuery", - "gasUsed": 7296 + "gasUsed": 7290 }, { "file": "test/query.t.sol", "test": "testNotValueQuery", "name": "NotValueQuery", - "gasUsed": 45742 + "gasUsed": 43961 }, { "file": "test/StandardDelegationsModule.t.sol", "test": "testCallFromCallboundDelegation", "name": "register a callbound delegation", - "gasUsed": 118198 + "gasUsed": 116008 }, { "file": "test/StandardDelegationsModule.t.sol", "test": "testCallFromCallboundDelegation", "name": "call a system via a callbound delegation", - "gasUsed": 36679 + "gasUsed": 34757 }, { "file": "test/StandardDelegationsModule.t.sol", "test": "testCallFromSystemDelegation", "name": "register a systembound delegation", - "gasUsed": 115751 + "gasUsed": 113562 }, { "file": "test/StandardDelegationsModule.t.sol", "test": "testCallFromSystemDelegation", "name": "call a system via a systembound delegation", - "gasUsed": 33851 + "gasUsed": 32321 }, { "file": "test/StandardDelegationsModule.t.sol", "test": "testCallFromTimeboundDelegation", "name": "register a timebound delegation", - "gasUsed": 112674 + "gasUsed": 110497 }, { "file": "test/StandardDelegationsModule.t.sol", "test": "testCallFromTimeboundDelegation", "name": "call a system via a timebound delegation", - "gasUsed": 26797 + "gasUsed": 25687 }, { "file": "test/UniqueEntityModule.t.sol", "test": "testInstall", "name": "install unique entity module", - "gasUsed": 701529 + "gasUsed": 690443 }, { "file": "test/UniqueEntityModule.t.sol", "test": "testInstall", "name": "get a unique entity nonce (non-root module)", - "gasUsed": 50365 + "gasUsed": 49452 }, { "file": "test/UniqueEntityModule.t.sol", "test": "testInstallRoot", "name": "installRoot unique entity module", - "gasUsed": 670396 + "gasUsed": 660912 }, { "file": "test/UniqueEntityModule.t.sol", "test": "testInstallRoot", "name": "get a unique entity nonce (root module)", - "gasUsed": 50368 + "gasUsed": 49455 } ] diff --git a/packages/world-modules/src/modules/erc20-puppet/tables/Allowances.sol b/packages/world-modules/src/modules/erc20-puppet/tables/Allowances.sol index 457d9167b5..e803d156a2 100644 --- a/packages/world-modules/src/modules/erc20-puppet/tables/Allowances.sol +++ b/packages/world-modules/src/modules/erc20-puppet/tables/Allowances.sol @@ -18,7 +18,6 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; FieldLayout constant _fieldLayout = FieldLayout.wrap( 0x0020010020000000000000000000000000000000000000000000000000000000 diff --git a/packages/world-modules/src/modules/erc20-puppet/tables/ERC20Metadata.sol b/packages/world-modules/src/modules/erc20-puppet/tables/ERC20Metadata.sol index 2caa24f3cc..2786f6afcf 100644 --- a/packages/world-modules/src/modules/erc20-puppet/tables/ERC20Metadata.sol +++ b/packages/world-modules/src/modules/erc20-puppet/tables/ERC20Metadata.sol @@ -18,7 +18,6 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; FieldLayout constant _fieldLayout = FieldLayout.wrap( 0x0001010201000000000000000000000000000000000000000000000000000000 diff --git a/packages/world-modules/src/modules/erc20-puppet/tables/ERC20Registry.sol b/packages/world-modules/src/modules/erc20-puppet/tables/ERC20Registry.sol index e1962ce7c0..a257de1880 100644 --- a/packages/world-modules/src/modules/erc20-puppet/tables/ERC20Registry.sol +++ b/packages/world-modules/src/modules/erc20-puppet/tables/ERC20Registry.sol @@ -18,7 +18,6 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; // Import user types import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; diff --git a/packages/world-modules/src/modules/erc20-puppet/tables/TotalSupply.sol b/packages/world-modules/src/modules/erc20-puppet/tables/TotalSupply.sol index 0ba7ec51b2..eaf6762370 100644 --- a/packages/world-modules/src/modules/erc20-puppet/tables/TotalSupply.sol +++ b/packages/world-modules/src/modules/erc20-puppet/tables/TotalSupply.sol @@ -18,7 +18,6 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; FieldLayout constant _fieldLayout = FieldLayout.wrap( 0x0020010020000000000000000000000000000000000000000000000000000000 diff --git a/packages/world-modules/src/modules/erc721-puppet/tables/ERC721Metadata.sol b/packages/world-modules/src/modules/erc721-puppet/tables/ERC721Metadata.sol index 90b7212c74..42967867a1 100644 --- a/packages/world-modules/src/modules/erc721-puppet/tables/ERC721Metadata.sol +++ b/packages/world-modules/src/modules/erc721-puppet/tables/ERC721Metadata.sol @@ -18,7 +18,6 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; FieldLayout constant _fieldLayout = FieldLayout.wrap( 0x0000000300000000000000000000000000000000000000000000000000000000 diff --git a/packages/world-modules/src/modules/erc721-puppet/tables/ERC721Registry.sol b/packages/world-modules/src/modules/erc721-puppet/tables/ERC721Registry.sol index 4c921e7dd6..9b1b0b7a46 100644 --- a/packages/world-modules/src/modules/erc721-puppet/tables/ERC721Registry.sol +++ b/packages/world-modules/src/modules/erc721-puppet/tables/ERC721Registry.sol @@ -18,7 +18,6 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; // Import user types import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; diff --git a/packages/world-modules/src/modules/erc721-puppet/tables/OperatorApproval.sol b/packages/world-modules/src/modules/erc721-puppet/tables/OperatorApproval.sol index e94c1269bc..f8ed7b9a51 100644 --- a/packages/world-modules/src/modules/erc721-puppet/tables/OperatorApproval.sol +++ b/packages/world-modules/src/modules/erc721-puppet/tables/OperatorApproval.sol @@ -18,7 +18,6 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; FieldLayout constant _fieldLayout = FieldLayout.wrap( 0x0001010001000000000000000000000000000000000000000000000000000000 diff --git a/packages/world-modules/src/modules/erc721-puppet/tables/Owners.sol b/packages/world-modules/src/modules/erc721-puppet/tables/Owners.sol index 3683de8e88..9fd9b9d7ac 100644 --- a/packages/world-modules/src/modules/erc721-puppet/tables/Owners.sol +++ b/packages/world-modules/src/modules/erc721-puppet/tables/Owners.sol @@ -18,7 +18,6 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; FieldLayout constant _fieldLayout = FieldLayout.wrap( 0x0014010014000000000000000000000000000000000000000000000000000000 diff --git a/packages/world-modules/src/modules/erc721-puppet/tables/TokenApproval.sol b/packages/world-modules/src/modules/erc721-puppet/tables/TokenApproval.sol index 801928168f..81b050e9cd 100644 --- a/packages/world-modules/src/modules/erc721-puppet/tables/TokenApproval.sol +++ b/packages/world-modules/src/modules/erc721-puppet/tables/TokenApproval.sol @@ -18,7 +18,6 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; FieldLayout constant _fieldLayout = FieldLayout.wrap( 0x0014010014000000000000000000000000000000000000000000000000000000 diff --git a/packages/world-modules/src/modules/erc721-puppet/tables/TokenURI.sol b/packages/world-modules/src/modules/erc721-puppet/tables/TokenURI.sol index 3aef2b9f31..6a93a319da 100644 --- a/packages/world-modules/src/modules/erc721-puppet/tables/TokenURI.sol +++ b/packages/world-modules/src/modules/erc721-puppet/tables/TokenURI.sol @@ -18,7 +18,6 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; FieldLayout constant _fieldLayout = FieldLayout.wrap( 0x0000000100000000000000000000000000000000000000000000000000000000 diff --git a/packages/world-modules/src/modules/keysintable/tables/KeysInTable.sol b/packages/world-modules/src/modules/keysintable/tables/KeysInTable.sol index 4b6df40b65..a2352e77ca 100644 --- a/packages/world-modules/src/modules/keysintable/tables/KeysInTable.sol +++ b/packages/world-modules/src/modules/keysintable/tables/KeysInTable.sol @@ -18,14 +18,12 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; // Import user types import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14(""), bytes16("KeysInTable"))) -); +// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "KeysInTable", typeId: RESOURCE_TABLE });` +ResourceId constant _tableId = ResourceId.wrap(0x746200000000000000000000000000004b657973496e5461626c650000000000); ResourceId constant KeysInTableTableId = _tableId; FieldLayout constant _fieldLayout = FieldLayout.wrap( diff --git a/packages/world-modules/src/modules/keysintable/tables/UsedKeysIndex.sol b/packages/world-modules/src/modules/keysintable/tables/UsedKeysIndex.sol index a19a585899..120728ffec 100644 --- a/packages/world-modules/src/modules/keysintable/tables/UsedKeysIndex.sol +++ b/packages/world-modules/src/modules/keysintable/tables/UsedKeysIndex.sol @@ -18,14 +18,12 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; // Import user types import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14(""), bytes16("UsedKeysIndex"))) -); +// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "UsedKeysIndex", typeId: RESOURCE_TABLE });` +ResourceId constant _tableId = ResourceId.wrap(0x74620000000000000000000000000000557365644b657973496e646578000000); ResourceId constant UsedKeysIndexTableId = _tableId; FieldLayout constant _fieldLayout = FieldLayout.wrap( diff --git a/packages/world-modules/src/modules/keyswithvalue/tables/KeysWithValue.sol b/packages/world-modules/src/modules/keyswithvalue/tables/KeysWithValue.sol index ccc013c0e7..f8ca13729d 100644 --- a/packages/world-modules/src/modules/keyswithvalue/tables/KeysWithValue.sol +++ b/packages/world-modules/src/modules/keyswithvalue/tables/KeysWithValue.sol @@ -18,7 +18,6 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; FieldLayout constant _fieldLayout = FieldLayout.wrap( 0x0000000100000000000000000000000000000000000000000000000000000000 diff --git a/packages/world-modules/src/modules/puppet/tables/PuppetRegistry.sol b/packages/world-modules/src/modules/puppet/tables/PuppetRegistry.sol index 0e38880973..2cb94c5370 100644 --- a/packages/world-modules/src/modules/puppet/tables/PuppetRegistry.sol +++ b/packages/world-modules/src/modules/puppet/tables/PuppetRegistry.sol @@ -18,7 +18,6 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; // Import user types import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; diff --git a/packages/world-modules/src/modules/std-delegations/tables/CallboundDelegations.sol b/packages/world-modules/src/modules/std-delegations/tables/CallboundDelegations.sol index fff8bb127f..d5423166a2 100644 --- a/packages/world-modules/src/modules/std-delegations/tables/CallboundDelegations.sol +++ b/packages/world-modules/src/modules/std-delegations/tables/CallboundDelegations.sol @@ -18,14 +18,12 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; // Import user types import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14(""), bytes16("CallboundDelegat"))) -); +// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "CallboundDelegat", typeId: RESOURCE_TABLE });` +ResourceId constant _tableId = ResourceId.wrap(0x7462000000000000000000000000000043616c6c626f756e6444656c65676174); ResourceId constant CallboundDelegationsTableId = _tableId; FieldLayout constant _fieldLayout = FieldLayout.wrap( diff --git a/packages/world-modules/src/modules/std-delegations/tables/SystemboundDelegations.sol b/packages/world-modules/src/modules/std-delegations/tables/SystemboundDelegations.sol index 64a4621cef..d02c2b5587 100644 --- a/packages/world-modules/src/modules/std-delegations/tables/SystemboundDelegations.sol +++ b/packages/world-modules/src/modules/std-delegations/tables/SystemboundDelegations.sol @@ -18,14 +18,12 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; // Import user types import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14(""), bytes16("SystemboundDeleg"))) -); +// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "SystemboundDeleg", typeId: RESOURCE_TABLE });` +ResourceId constant _tableId = ResourceId.wrap(0x7462000000000000000000000000000053797374656d626f756e6444656c6567); ResourceId constant SystemboundDelegationsTableId = _tableId; FieldLayout constant _fieldLayout = FieldLayout.wrap( diff --git a/packages/world-modules/src/modules/std-delegations/tables/TimeboundDelegations.sol b/packages/world-modules/src/modules/std-delegations/tables/TimeboundDelegations.sol index 6b9c598d55..481c8157ec 100644 --- a/packages/world-modules/src/modules/std-delegations/tables/TimeboundDelegations.sol +++ b/packages/world-modules/src/modules/std-delegations/tables/TimeboundDelegations.sol @@ -18,11 +18,9 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14(""), bytes16("TimeboundDelegat"))) -); +// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "TimeboundDelegat", typeId: RESOURCE_TABLE });` +ResourceId constant _tableId = ResourceId.wrap(0x7462000000000000000000000000000054696d65626f756e6444656c65676174); ResourceId constant TimeboundDelegationsTableId = _tableId; FieldLayout constant _fieldLayout = FieldLayout.wrap( diff --git a/packages/world-modules/src/modules/tokens/tables/Balances.sol b/packages/world-modules/src/modules/tokens/tables/Balances.sol index f1de37351e..ef3b7d0ca9 100644 --- a/packages/world-modules/src/modules/tokens/tables/Balances.sol +++ b/packages/world-modules/src/modules/tokens/tables/Balances.sol @@ -18,7 +18,6 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; FieldLayout constant _fieldLayout = FieldLayout.wrap( 0x0020010020000000000000000000000000000000000000000000000000000000 diff --git a/packages/world-modules/src/modules/uniqueentity/tables/UniqueEntity.sol b/packages/world-modules/src/modules/uniqueentity/tables/UniqueEntity.sol index a6f0062200..e00eb767a6 100644 --- a/packages/world-modules/src/modules/uniqueentity/tables/UniqueEntity.sol +++ b/packages/world-modules/src/modules/uniqueentity/tables/UniqueEntity.sol @@ -18,7 +18,6 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; FieldLayout constant _fieldLayout = FieldLayout.wrap( 0x0020010020000000000000000000000000000000000000000000000000000000 diff --git a/packages/world/gas-report.json b/packages/world/gas-report.json index 5ce4c74a7f..2caa9349ff 100644 --- a/packages/world/gas-report.json +++ b/packages/world/gas-report.json @@ -3,187 +3,187 @@ "file": "test/AccessControl.t.sol", "test": "testAccessControl", "name": "AccessControl: hasAccess (cold)", - "gasUsed": 6990 + "gasUsed": 6521 }, { "file": "test/AccessControl.t.sol", "test": "testAccessControl", "name": "AccessControl: hasAccess (warm, namespace only)", - "gasUsed": 1535 + "gasUsed": 1300 }, { "file": "test/AccessControl.t.sol", "test": "testAccessControl", "name": "AccessControl: hasAccess (warm)", - "gasUsed": 2998 + "gasUsed": 2527 }, { "file": "test/AccessControl.t.sol", "test": "testRequireAccess", "name": "AccessControl: requireAccess (cold)", - "gasUsed": 7033 + "gasUsed": 6564 }, { "file": "test/AccessControl.t.sol", "test": "testRequireAccess", "name": "AccessControl: requireAccess (warm)", - "gasUsed": 3036 + "gasUsed": 2566 }, { "file": "test/AccessControl.t.sol", "test": "testRequireOwner", "name": "AccessControl: requireOwner (cold)", - "gasUsed": 3322 + "gasUsed": 3106 }, { "file": "test/AccessControl.t.sol", "test": "testRequireOwner", "name": "AccessControl: requireOwner (warm)", - "gasUsed": 1323 + "gasUsed": 1107 }, { "file": "test/BatchCall.t.sol", "test": "testBatchCallFromReturnData", "name": "call systems with batchCallFrom", - "gasUsed": 52477 + "gasUsed": 50689 }, { "file": "test/BatchCall.t.sol", "test": "testBatchCallReturnData", "name": "call systems with batchCall", - "gasUsed": 51323 + "gasUsed": 49764 }, { "file": "test/Factories.t.sol", "test": "testCreate2Factory", "name": "deploy contract via Create2", - "gasUsed": 4768291 + "gasUsed": 4586875 }, { "file": "test/Factories.t.sol", "test": "testWorldFactoryGas", "name": "deploy world via WorldFactory", - "gasUsed": 12961889 + "gasUsed": 12718635 }, { "file": "test/World.t.sol", "test": "testCall", "name": "call a system via the World", - "gasUsed": 12361 + "gasUsed": 11681 }, { "file": "test/World.t.sol", "test": "testCallFromNamespaceDelegation", "name": "call a system via a namespace fallback delegation", - "gasUsed": 26131 + "gasUsed": 24776 }, { "file": "test/World.t.sol", "test": "testCallFromUnlimitedDelegation", "name": "register an unlimited delegation", - "gasUsed": 47607 + "gasUsed": 46495 }, { "file": "test/World.t.sol", "test": "testCallFromUnlimitedDelegation", "name": "call a system via an unlimited delegation", - "gasUsed": 12797 + "gasUsed": 12123 }, { "file": "test/World.t.sol", "test": "testDeleteRecord", "name": "Delete record", - "gasUsed": 9837 + "gasUsed": 8957 }, { "file": "test/World.t.sol", "test": "testPushToDynamicField", "name": "Push data to the table", - "gasUsed": 85833 + "gasUsed": 85359 }, { "file": "test/World.t.sol", "test": "testRegisterFunctionSelector", "name": "Register a function selector", - "gasUsed": 81069 + "gasUsed": 79089 }, { "file": "test/World.t.sol", "test": "testRegisterNamespace", "name": "Register a new namespace", - "gasUsed": 123559 + "gasUsed": 121348 }, { "file": "test/World.t.sol", "test": "testRegisterRootFunctionSelector", "name": "Register a root function selector", - "gasUsed": 80445 + "gasUsed": 78683 }, { "file": "test/World.t.sol", "test": "testRegisterSystem", "name": "register a system", - "gasUsed": 164363 + "gasUsed": 161017 }, { "file": "test/World.t.sol", "test": "testRegisterTable", "name": "Register a new table in the namespace", - "gasUsed": 534893 + "gasUsed": 532676 }, { "file": "test/World.t.sol", "test": "testRenounceNamespace", "name": "Renounce namespace ownership", - "gasUsed": 39381 + "gasUsed": 37438 }, { "file": "test/World.t.sol", "test": "testSetField", "name": "Write data to a table field", - "gasUsed": 36903 + "gasUsed": 36435 }, { "file": "test/World.t.sol", "test": "testSetRecord", "name": "Write data to the table", - "gasUsed": 39047 + "gasUsed": 38167 }, { "file": "test/World.t.sol", "test": "testUnregisterNamespaceDelegation", "name": "unregister a namespace delegation", - "gasUsed": 30968 + "gasUsed": 29012 }, { "file": "test/World.t.sol", "test": "testUnregisterUnlimitedDelegation", "name": "unregister an unlimited delegation", - "gasUsed": 26255 + "gasUsed": 24722 }, { "file": "test/WorldDynamicUpdate.t.sol", "test": "testPopFromDynamicField", "name": "pop 1 address (cold)", - "gasUsed": 25621 + "gasUsed": 25146 }, { "file": "test/WorldDynamicUpdate.t.sol", "test": "testPopFromDynamicField", "name": "pop 1 address (warm)", - "gasUsed": 12767 + "gasUsed": 12292 }, { "file": "test/WorldDynamicUpdate.t.sol", "test": "testSpliceDynamicData", "name": "update in field 1 item (cold)", - "gasUsed": 25981 + "gasUsed": 25506 }, { "file": "test/WorldDynamicUpdate.t.sol", "test": "testSpliceDynamicData", "name": "update in field 1 item (warm)", - "gasUsed": 13182 + "gasUsed": 12707 }, { "file": "test/WorldResourceId.t.sol", diff --git a/packages/world/src/codegen/tables/Balances.sol b/packages/world/src/codegen/tables/Balances.sol index 03875c009d..7e478bb7b3 100644 --- a/packages/world/src/codegen/tables/Balances.sol +++ b/packages/world/src/codegen/tables/Balances.sol @@ -18,14 +18,12 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; // Import user types import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14("world"), bytes16("Balances"))) -); +// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "world", name: "Balances", typeId: RESOURCE_TABLE });` +ResourceId constant _tableId = ResourceId.wrap(0x7462776f726c6400000000000000000042616c616e6365730000000000000000); ResourceId constant BalancesTableId = _tableId; FieldLayout constant _fieldLayout = FieldLayout.wrap( diff --git a/packages/world/src/codegen/tables/FunctionSelectors.sol b/packages/world/src/codegen/tables/FunctionSelectors.sol index 3362aa9091..f45012ae4d 100644 --- a/packages/world/src/codegen/tables/FunctionSelectors.sol +++ b/packages/world/src/codegen/tables/FunctionSelectors.sol @@ -18,14 +18,12 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; // Import user types import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14("world"), bytes16("FunctionSelector"))) -); +// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "world", name: "FunctionSelector", typeId: RESOURCE_TABLE });` +ResourceId constant _tableId = ResourceId.wrap(0x7462776f726c6400000000000000000046756e6374696f6e53656c6563746f72); ResourceId constant FunctionSelectorsTableId = _tableId; FieldLayout constant _fieldLayout = FieldLayout.wrap( diff --git a/packages/world/src/codegen/tables/FunctionSignatures.sol b/packages/world/src/codegen/tables/FunctionSignatures.sol index 92e35dc7b1..227f39e97a 100644 --- a/packages/world/src/codegen/tables/FunctionSignatures.sol +++ b/packages/world/src/codegen/tables/FunctionSignatures.sol @@ -18,11 +18,9 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_OFFCHAIN_TABLE, bytes14("world"), bytes16("FunctionSignatur"))) -); +// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "world", name: "FunctionSignatur", typeId: RESOURCE_OFFCHAIN_TABLE });` +ResourceId constant _tableId = ResourceId.wrap(0x6f74776f726c6400000000000000000046756e6374696f6e5369676e61747572); ResourceId constant FunctionSignaturesTableId = _tableId; FieldLayout constant _fieldLayout = FieldLayout.wrap( diff --git a/packages/world/src/codegen/tables/InitModuleAddress.sol b/packages/world/src/codegen/tables/InitModuleAddress.sol index 8127779a7a..b179b181c5 100644 --- a/packages/world/src/codegen/tables/InitModuleAddress.sol +++ b/packages/world/src/codegen/tables/InitModuleAddress.sol @@ -18,11 +18,9 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14("world"), bytes16("InitModuleAddres"))) -); +// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "world", name: "InitModuleAddres", typeId: RESOURCE_TABLE });` +ResourceId constant _tableId = ResourceId.wrap(0x7462776f726c64000000000000000000496e69744d6f64756c65416464726573); ResourceId constant InitModuleAddressTableId = _tableId; FieldLayout constant _fieldLayout = FieldLayout.wrap( diff --git a/packages/world/src/codegen/tables/InstalledModules.sol b/packages/world/src/codegen/tables/InstalledModules.sol index 97f990842d..1961a8c2a6 100644 --- a/packages/world/src/codegen/tables/InstalledModules.sol +++ b/packages/world/src/codegen/tables/InstalledModules.sol @@ -18,11 +18,9 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14("world"), bytes16("InstalledModules"))) -); +// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "world", name: "InstalledModules", typeId: RESOURCE_TABLE });` +ResourceId constant _tableId = ResourceId.wrap(0x7462776f726c64000000000000000000496e7374616c6c65644d6f64756c6573); ResourceId constant InstalledModulesTableId = _tableId; FieldLayout constant _fieldLayout = FieldLayout.wrap( diff --git a/packages/world/src/codegen/tables/NamespaceDelegationControl.sol b/packages/world/src/codegen/tables/NamespaceDelegationControl.sol index c2d05f088a..aebe7d0930 100644 --- a/packages/world/src/codegen/tables/NamespaceDelegationControl.sol +++ b/packages/world/src/codegen/tables/NamespaceDelegationControl.sol @@ -18,14 +18,12 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; // Import user types import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14("world"), bytes16("NamespaceDelegat"))) -); +// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "world", name: "NamespaceDelegat", typeId: RESOURCE_TABLE });` +ResourceId constant _tableId = ResourceId.wrap(0x7462776f726c640000000000000000004e616d65737061636544656c65676174); ResourceId constant NamespaceDelegationControlTableId = _tableId; FieldLayout constant _fieldLayout = FieldLayout.wrap( diff --git a/packages/world/src/codegen/tables/NamespaceOwner.sol b/packages/world/src/codegen/tables/NamespaceOwner.sol index f9cf0ebc8a..e5cb0a3b7b 100644 --- a/packages/world/src/codegen/tables/NamespaceOwner.sol +++ b/packages/world/src/codegen/tables/NamespaceOwner.sol @@ -18,14 +18,12 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; // Import user types import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14("world"), bytes16("NamespaceOwner"))) -); +// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "world", name: "NamespaceOwner", typeId: RESOURCE_TABLE });` +ResourceId constant _tableId = ResourceId.wrap(0x7462776f726c640000000000000000004e616d6573706163654f776e65720000); ResourceId constant NamespaceOwnerTableId = _tableId; FieldLayout constant _fieldLayout = FieldLayout.wrap( diff --git a/packages/world/src/codegen/tables/ResourceAccess.sol b/packages/world/src/codegen/tables/ResourceAccess.sol index 93e043b592..5d5a6a50af 100644 --- a/packages/world/src/codegen/tables/ResourceAccess.sol +++ b/packages/world/src/codegen/tables/ResourceAccess.sol @@ -18,14 +18,12 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; // Import user types import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14("world"), bytes16("ResourceAccess"))) -); +// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "world", name: "ResourceAccess", typeId: RESOURCE_TABLE });` +ResourceId constant _tableId = ResourceId.wrap(0x7462776f726c640000000000000000005265736f757263654163636573730000); ResourceId constant ResourceAccessTableId = _tableId; FieldLayout constant _fieldLayout = FieldLayout.wrap( diff --git a/packages/world/src/codegen/tables/SystemHooks.sol b/packages/world/src/codegen/tables/SystemHooks.sol index 2d2c8b87a8..e73edd6d16 100644 --- a/packages/world/src/codegen/tables/SystemHooks.sol +++ b/packages/world/src/codegen/tables/SystemHooks.sol @@ -18,14 +18,12 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; // Import user types import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14("world"), bytes16("SystemHooks"))) -); +// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "world", name: "SystemHooks", typeId: RESOURCE_TABLE });` +ResourceId constant _tableId = ResourceId.wrap(0x7462776f726c6400000000000000000053797374656d486f6f6b730000000000); ResourceId constant SystemHooksTableId = _tableId; FieldLayout constant _fieldLayout = FieldLayout.wrap( diff --git a/packages/world/src/codegen/tables/SystemRegistry.sol b/packages/world/src/codegen/tables/SystemRegistry.sol index eba5240b1b..551a22293c 100644 --- a/packages/world/src/codegen/tables/SystemRegistry.sol +++ b/packages/world/src/codegen/tables/SystemRegistry.sol @@ -18,14 +18,12 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; // Import user types import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14("world"), bytes16("SystemRegistry"))) -); +// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "world", name: "SystemRegistry", typeId: RESOURCE_TABLE });` +ResourceId constant _tableId = ResourceId.wrap(0x7462776f726c6400000000000000000053797374656d52656769737472790000); ResourceId constant SystemRegistryTableId = _tableId; FieldLayout constant _fieldLayout = FieldLayout.wrap( diff --git a/packages/world/src/codegen/tables/Systems.sol b/packages/world/src/codegen/tables/Systems.sol index 0f669b4dc1..ec75746b38 100644 --- a/packages/world/src/codegen/tables/Systems.sol +++ b/packages/world/src/codegen/tables/Systems.sol @@ -18,14 +18,12 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; // Import user types import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14("world"), bytes16("Systems"))) -); +// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "world", name: "Systems", typeId: RESOURCE_TABLE });` +ResourceId constant _tableId = ResourceId.wrap(0x7462776f726c6400000000000000000053797374656d73000000000000000000); ResourceId constant SystemsTableId = _tableId; FieldLayout constant _fieldLayout = FieldLayout.wrap( diff --git a/packages/world/src/codegen/tables/UserDelegationControl.sol b/packages/world/src/codegen/tables/UserDelegationControl.sol index 0d76ee5730..f32fa0ca47 100644 --- a/packages/world/src/codegen/tables/UserDelegationControl.sol +++ b/packages/world/src/codegen/tables/UserDelegationControl.sol @@ -18,14 +18,12 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; // Import user types import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14("world"), bytes16("UserDelegationCo"))) -); +// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "world", name: "UserDelegationCo", typeId: RESOURCE_TABLE });` +ResourceId constant _tableId = ResourceId.wrap(0x7462776f726c640000000000000000005573657244656c65676174696f6e436f); ResourceId constant UserDelegationControlTableId = _tableId; FieldLayout constant _fieldLayout = FieldLayout.wrap( diff --git a/packages/world/test/codegen/tables/AddressArray.sol b/packages/world/test/codegen/tables/AddressArray.sol index c457299b22..406f83d870 100644 --- a/packages/world/test/codegen/tables/AddressArray.sol +++ b/packages/world/test/codegen/tables/AddressArray.sol @@ -18,7 +18,6 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; FieldLayout constant _fieldLayout = FieldLayout.wrap( 0x0000000100000000000000000000000000000000000000000000000000000000 diff --git a/packages/world/test/codegen/tables/Bool.sol b/packages/world/test/codegen/tables/Bool.sol index b7dc02e451..43d6b8fca3 100644 --- a/packages/world/test/codegen/tables/Bool.sol +++ b/packages/world/test/codegen/tables/Bool.sol @@ -18,7 +18,6 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; FieldLayout constant _fieldLayout = FieldLayout.wrap( 0x0001010001000000000000000000000000000000000000000000000000000000 diff --git a/packages/world/test/codegen/tables/TwoFields.sol b/packages/world/test/codegen/tables/TwoFields.sol index 48ad23b5d6..da4b7035a8 100644 --- a/packages/world/test/codegen/tables/TwoFields.sol +++ b/packages/world/test/codegen/tables/TwoFields.sol @@ -18,7 +18,6 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; FieldLayout constant _fieldLayout = FieldLayout.wrap( 0x0002020001010000000000000000000000000000000000000000000000000000 diff --git a/templates/phaser/packages/contracts/src/codegen/tables/Counter.sol b/templates/phaser/packages/contracts/src/codegen/tables/Counter.sol index c1a74c6761..40a1f45dcf 100644 --- a/templates/phaser/packages/contracts/src/codegen/tables/Counter.sol +++ b/templates/phaser/packages/contracts/src/codegen/tables/Counter.sol @@ -18,11 +18,9 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14(""), bytes16("Counter"))) -); +// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "Counter", typeId: RESOURCE_TABLE });` +ResourceId constant _tableId = ResourceId.wrap(0x74620000000000000000000000000000436f756e746572000000000000000000); ResourceId constant CounterTableId = _tableId; FieldLayout constant _fieldLayout = FieldLayout.wrap( diff --git a/templates/react-ecs/packages/contracts/src/codegen/tables/Counter.sol b/templates/react-ecs/packages/contracts/src/codegen/tables/Counter.sol index c1a74c6761..40a1f45dcf 100644 --- a/templates/react-ecs/packages/contracts/src/codegen/tables/Counter.sol +++ b/templates/react-ecs/packages/contracts/src/codegen/tables/Counter.sol @@ -18,11 +18,9 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14(""), bytes16("Counter"))) -); +// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "Counter", typeId: RESOURCE_TABLE });` +ResourceId constant _tableId = ResourceId.wrap(0x74620000000000000000000000000000436f756e746572000000000000000000); ResourceId constant CounterTableId = _tableId; FieldLayout constant _fieldLayout = FieldLayout.wrap( diff --git a/templates/react/packages/contracts/src/codegen/tables/Tasks.sol b/templates/react/packages/contracts/src/codegen/tables/Tasks.sol index 974c66f008..dd0f1cad01 100644 --- a/templates/react/packages/contracts/src/codegen/tables/Tasks.sol +++ b/templates/react/packages/contracts/src/codegen/tables/Tasks.sol @@ -18,11 +18,9 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14(""), bytes16("Tasks"))) -); +// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "Tasks", typeId: RESOURCE_TABLE });` +ResourceId constant _tableId = ResourceId.wrap(0x746200000000000000000000000000005461736b730000000000000000000000); ResourceId constant TasksTableId = _tableId; FieldLayout constant _fieldLayout = FieldLayout.wrap( diff --git a/templates/threejs/packages/contracts/src/codegen/tables/Position.sol b/templates/threejs/packages/contracts/src/codegen/tables/Position.sol index 791fe7fa37..ee7e364497 100644 --- a/templates/threejs/packages/contracts/src/codegen/tables/Position.sol +++ b/templates/threejs/packages/contracts/src/codegen/tables/Position.sol @@ -18,11 +18,9 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14(""), bytes16("Position"))) -); +// 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( diff --git a/templates/vanilla/packages/contracts/src/codegen/tables/Counter.sol b/templates/vanilla/packages/contracts/src/codegen/tables/Counter.sol index c1a74c6761..40a1f45dcf 100644 --- a/templates/vanilla/packages/contracts/src/codegen/tables/Counter.sol +++ b/templates/vanilla/packages/contracts/src/codegen/tables/Counter.sol @@ -18,11 +18,9 @@ import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.s import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; -ResourceId constant _tableId = ResourceId.wrap( - bytes32(abi.encodePacked(RESOURCE_TABLE, bytes14(""), bytes16("Counter"))) -); +// Hex below is the result of `WorldResourceIdLib.encode({ namespace: "", name: "Counter", typeId: RESOURCE_TABLE });` +ResourceId constant _tableId = ResourceId.wrap(0x74620000000000000000000000000000436f756e746572000000000000000000); ResourceId constant CounterTableId = _tableId; FieldLayout constant _fieldLayout = FieldLayout.wrap(