From 952cd534447d08e6231ab147ed1cc24fb49bbb57 Mon Sep 17 00:00:00 2001 From: alvarius Date: Wed, 16 Aug 2023 16:26:29 +0200 Subject: [PATCH] feat(world, store): stop loading schema from storage, require schema as an argument (#1174) --- .changeset/few-mirrors-reflect.md | 23 + .../contracts/src/codegen/tables/Multi.sol | 24 +- .../contracts/src/codegen/tables/Number.sol | 12 +- .../src/codegen/tables/NumberList.sol | 24 +- .../contracts/src/codegen/tables/Vector.sol | 24 +- .../src/systems/NumberListSystem.sol | 2 +- .../types/ethers-contracts/IWorld.ts | 542 ++++++++++-------- .../factories/IWorld__factory.ts | 171 ++++-- e2e/packages/contracts/worlds.json | 2 +- .../sync-test/data/encodeTestData.test.ts | 14 +- e2e/packages/sync-test/data/encodeTestData.ts | 32 +- .../sync-test/data/setContractData.ts | 7 +- e2e/packages/sync-test/data/types.ts | 3 +- e2e/packages/sync-test/package.json | 1 + e2e/pnpm-lock.yaml | 4 + .../src/codegen/tables/CounterTable.sol | 12 +- .../src/codegen/tables/Inventory.sol | 12 +- .../src/codegen/tables/MessageTable.sol | 4 +- .../types/ethers-contracts/IWorld.ts | 542 ++++++++++-------- .../factories/IWorld__factory.ts | 171 ++++-- .../src/codegen/tables/Dynamics1.sol | 120 ++-- .../src/codegen/tables/Dynamics2.sol | 68 +-- .../src/codegen/tables/Ephemeral.sol | 4 +- .../src/codegen/tables/Singleton.sol | 76 +-- .../contracts/src/codegen/tables/Statics.sol | 64 +-- packages/cli/package.json | 1 + packages/cli/src/commands/trace.ts | 12 +- .../deprecated/utils/encodeSchema.ts | 1 + packages/store/abi/IStore.sol/IStore.abi.json | 70 ++- .../store/abi/IStore.sol/IStoreData.abi.json | 65 ++- .../abi/IStore.sol/IStoreEphemeral.abi.json | 5 + .../store/abi/IStore.sol/IStoreHook.abi.json | 20 + .../store/abi/IStore.sol/IStoreRead.abi.json | 35 +- .../store/abi/IStore.sol/IStoreWrite.abi.json | 30 + .../MirrorSubscriber.abi.json | 52 +- .../StoreCore.sol/StoreCoreExtended.abi.json | 1 - .../abi/StoreMock.sol/StoreMock.abi.json | 66 ++- .../abi/StoreRead.sol/StoreRead.abi.json | 31 +- .../StoreReadWithStubs.abi.json | 66 ++- packages/store/gas-report.json | 114 ++-- packages/store/src/IStore.sol | 73 ++- packages/store/src/StoreCore.sol | 272 ++++----- packages/store/src/StoreRead.sol | 14 +- packages/store/src/StoreReadWithStubs.sol | 14 +- packages/store/src/StoreSwitch.sol | 87 +-- .../store/src/codegen/tables/Callbacks.sol | 24 +- packages/store/src/codegen/tables/Hooks.sol | 24 +- .../store/src/codegen/tables/KeyEncoding.sol | 12 +- packages/store/src/codegen/tables/Mixed.sol | 64 +-- .../src/codegen/tables/StoreMetadata.sol | 48 +- packages/store/src/codegen/tables/Vector2.sol | 24 +- packages/store/test/MirrorSubscriber.sol | 20 +- packages/store/test/StoreCore.t.sol | 327 ++++++----- packages/store/test/StoreCoreDynamic.t.sol | 41 +- packages/store/test/StoreCoreGas.t.sol | 137 +++-- packages/store/test/StoreMock.sol | 47 +- packages/store/ts/codegen/ephemeral.ts | 2 +- packages/store/ts/codegen/field.ts | 11 +- packages/store/ts/codegen/record.ts | 2 +- packages/store/ts/codegen/renderTable.ts | 2 +- .../AccessManagementSystem.abi.json | 32 +- .../abi/CoreSystem.sol/CoreSystem.abi.json | 10 + .../EphemeralRecordSystem.abi.json | 42 +- .../abi/IBaseWorld.sol/IBaseWorld.abi.json | 171 ++++-- packages/world/abi/IStore.sol/IStore.abi.json | 70 ++- .../world/abi/IStore.sol/IStoreData.abi.json | 65 ++- .../abi/IStore.sol/IStoreEphemeral.abi.json | 5 + .../world/abi/IStore.sol/IStoreHook.abi.json | 20 + .../world/abi/IStore.sol/IStoreRead.abi.json | 35 +- .../world/abi/IStore.sol/IStoreWrite.abi.json | 30 + .../IWorldEphemeral.abi.json | 5 + .../abi/IWorldKernel.sol/IWorldData.abi.json | 30 + .../IWorldKernel.sol/IWorldKernel.abi.json | 30 + .../KeysInTableHook.abi.json | 36 +- .../KeysInTableModule.abi.json | 16 - .../KeysWithValueHook.abi.json | 52 +- .../KeysWithValueModule.abi.json | 16 - .../ModuleInstallationSystem.abi.json | 32 +- .../StoreCore.sol/StoreCoreExtended.abi.json | 1 - .../abi/StoreRead.sol/StoreRead.abi.json | 31 +- .../UniqueEntitySystem.abi.json | 32 +- packages/world/abi/World.sol/World.abi.json | 157 +++-- .../world/abi/src/IStore.sol/IStore.abi.json | 70 ++- .../abi/src/IStore.sol/IStoreData.abi.json | 65 ++- .../src/IStore.sol/IStoreEphemeral.abi.json | 5 + .../abi/src/IStore.sol/IStoreHook.abi.json | 20 + .../abi/src/IStore.sol/IStoreRead.abi.json | 35 +- .../abi/src/IStore.sol/IStoreWrite.abi.json | 30 + .../StoreCore.sol/StoreCoreExtended.abi.json | 1 - packages/world/gas-report.json | 100 ++-- packages/world/src/World.sol | 63 +- .../world/src/interfaces/IWorldEphemeral.sol | 10 +- .../world/src/interfaces/IWorldKernel.sol | 23 +- .../implementations/EphemeralRecordSystem.sol | 15 +- .../modules/core/tables/FunctionSelectors.sol | 32 +- .../src/modules/core/tables/ResourceType.sol | 12 +- .../src/modules/core/tables/SystemHooks.sol | 24 +- .../modules/core/tables/SystemRegistry.sol | 12 +- .../world/src/modules/core/tables/Systems.sol | 24 +- .../modules/keysintable/KeysInTableHook.sol | 9 +- .../keysintable/tables/KeysInTable.sol | 108 ++-- .../keysintable/tables/UsedKeysIndex.sol | 24 +- .../keyswithvalue/KeysWithValueHook.sol | 29 +- .../keyswithvalue/tables/KeysWithValue.sol | 24 +- .../uniqueentity/tables/UniqueEntity.sol | 12 +- .../world/src/tables/InstalledModules.sol | 16 +- packages/world/src/tables/NamespaceOwner.sol | 12 +- packages/world/src/tables/ResourceAccess.sol | 12 +- packages/world/test/KeysInTableModule.t.sol | 44 +- packages/world/test/KeysWithValueModule.t.sol | 18 +- packages/world/test/World.t.sol | 94 +-- packages/world/test/WorldDynamicUpdate.t.sol | 33 +- packages/world/test/query.t.sol | 112 ++-- packages/world/test/tables/AddressArray.sol | 24 +- packages/world/test/tables/Bool.sol | 12 +- pnpm-lock.yaml | 3 + .../contracts/src/codegen/tables/Counter.sol | 12 +- .../contracts/src/codegen/tables/Counter.sol | 12 +- .../contracts/src/codegen/tables/Position.sol | 32 +- .../contracts/src/codegen/tables/Counter.sol | 12 +- 120 files changed, 3342 insertions(+), 2543 deletions(-) create mode 100644 .changeset/few-mirrors-reflect.md delete mode 100644 packages/store/abi/StoreCore.sol/StoreCoreExtended.abi.json delete mode 100644 packages/world/abi/StoreCore.sol/StoreCoreExtended.abi.json delete mode 100644 packages/world/abi/src/StoreCore.sol/StoreCoreExtended.abi.json diff --git a/.changeset/few-mirrors-reflect.md b/.changeset/few-mirrors-reflect.md new file mode 100644 index 0000000000..01bd719f55 --- /dev/null +++ b/.changeset/few-mirrors-reflect.md @@ -0,0 +1,23 @@ +--- +"@latticexyz/cli": major +"@latticexyz/store": major +"@latticexyz/world": major +"create-mud": patch +--- + +All `Store` methods now require the table's value schema to be passed in as an argument instead of loading it from storage. +This decreases gas cost and removes circular dependencies of the Schema table (where it was not possible to write to the Schema table before the Schema table was registered). + +```diff + function setRecord( + bytes32 table, + bytes32[] calldata key, + bytes calldata data, ++ Schema valueSchema + ) external; +``` + +The same diff applies to `getRecord`, `getField`, `setField`, `pushToField`, `popFromField`, `updateInField`, and `deleteRecord`. + +This change only requires changes in downstream projects if the `Store` methods were accessed directly. In most cases it is fully abstracted in the generated table libraries, +so downstream projects only need to regenerate their table libraries after updating MUD. diff --git a/e2e/packages/contracts/src/codegen/tables/Multi.sol b/e2e/packages/contracts/src/codegen/tables/Multi.sol index b8dbb498b4..80ed45e627 100644 --- a/e2e/packages/contracts/src/codegen/tables/Multi.sol +++ b/e2e/packages/contracts/src/codegen/tables/Multi.sol @@ -83,7 +83,7 @@ library Multi { _keyTuple[2] = bytes32(uint256(c)); _keyTuple[3] = bytes32(uint256(int256(d))); - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0, getSchema()); return (int256(uint256(Bytes.slice32(_blob, 0)))); } @@ -95,7 +95,7 @@ library Multi { _keyTuple[2] = bytes32(uint256(c)); _keyTuple[3] = bytes32(uint256(int256(d))); - bytes memory _blob = _store.getField(_tableId, _keyTuple, 0); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 0, getSchema()); return (int256(uint256(Bytes.slice32(_blob, 0)))); } @@ -107,7 +107,7 @@ library Multi { _keyTuple[2] = bytes32(uint256(c)); _keyTuple[3] = bytes32(uint256(int256(d))); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((num))); + StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((num)), getSchema()); } /** Set num (using the specified store) */ @@ -118,7 +118,7 @@ library Multi { _keyTuple[2] = bytes32(uint256(c)); _keyTuple[3] = bytes32(uint256(int256(d))); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((num))); + _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((num)), getSchema()); } /** Get value */ @@ -129,7 +129,7 @@ library Multi { _keyTuple[2] = bytes32(uint256(c)); _keyTuple[3] = bytes32(uint256(int256(d))); - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 1); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 1, getSchema()); return (_toBool(uint8(Bytes.slice1(_blob, 0)))); } @@ -141,7 +141,7 @@ library Multi { _keyTuple[2] = bytes32(uint256(c)); _keyTuple[3] = bytes32(uint256(int256(d))); - bytes memory _blob = _store.getField(_tableId, _keyTuple, 1); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 1, getSchema()); return (_toBool(uint8(Bytes.slice1(_blob, 0)))); } @@ -153,7 +153,7 @@ library Multi { _keyTuple[2] = bytes32(uint256(c)); _keyTuple[3] = bytes32(uint256(int256(d))); - StoreSwitch.setField(_tableId, _keyTuple, 1, abi.encodePacked((value))); + StoreSwitch.setField(_tableId, _keyTuple, 1, abi.encodePacked((value)), getSchema()); } /** Set value (using the specified store) */ @@ -164,7 +164,7 @@ library Multi { _keyTuple[2] = bytes32(uint256(c)); _keyTuple[3] = bytes32(uint256(int256(d))); - _store.setField(_tableId, _keyTuple, 1, abi.encodePacked((value))); + _store.setField(_tableId, _keyTuple, 1, abi.encodePacked((value)), getSchema()); } /** Get the full data */ @@ -201,7 +201,7 @@ library Multi { _keyTuple[2] = bytes32(uint256(c)); _keyTuple[3] = bytes32(uint256(int256(d))); - StoreSwitch.setRecord(_tableId, _keyTuple, _data); + StoreSwitch.setRecord(_tableId, _keyTuple, _data, getSchema()); } /** Set the full data using individual values (using the specified store) */ @@ -214,7 +214,7 @@ library Multi { _keyTuple[2] = bytes32(uint256(c)); _keyTuple[3] = bytes32(uint256(int256(d))); - _store.setRecord(_tableId, _keyTuple, _data); + _store.setRecord(_tableId, _keyTuple, _data, getSchema()); } /** Set the full data using the data struct */ @@ -258,7 +258,7 @@ library Multi { _keyTuple[2] = bytes32(uint256(c)); _keyTuple[3] = bytes32(uint256(int256(d))); - StoreSwitch.deleteRecord(_tableId, _keyTuple); + StoreSwitch.deleteRecord(_tableId, _keyTuple, getSchema()); } /* Delete all data for given keys (using the specified store) */ @@ -269,7 +269,7 @@ library Multi { _keyTuple[2] = bytes32(uint256(c)); _keyTuple[3] = bytes32(uint256(int256(d))); - _store.deleteRecord(_tableId, _keyTuple); + _store.deleteRecord(_tableId, _keyTuple, getSchema()); } } diff --git a/e2e/packages/contracts/src/codegen/tables/Number.sol b/e2e/packages/contracts/src/codegen/tables/Number.sol index 423831e5c4..d7dac5bac4 100644 --- a/e2e/packages/contracts/src/codegen/tables/Number.sol +++ b/e2e/packages/contracts/src/codegen/tables/Number.sol @@ -70,7 +70,7 @@ library Number { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0, getSchema()); return (uint32(Bytes.slice4(_blob, 0))); } @@ -79,7 +79,7 @@ library Number { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - bytes memory _blob = _store.getField(_tableId, _keyTuple, 0); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 0, getSchema()); return (uint32(Bytes.slice4(_blob, 0))); } @@ -88,7 +88,7 @@ library Number { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((value))); + StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), getSchema()); } /** Set value (using the specified store) */ @@ -96,7 +96,7 @@ library Number { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((value))); + _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), getSchema()); } /** Tightly pack full data using this table's schema */ @@ -117,7 +117,7 @@ library Number { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - StoreSwitch.deleteRecord(_tableId, _keyTuple); + StoreSwitch.deleteRecord(_tableId, _keyTuple, getSchema()); } /* Delete all data for given keys (using the specified store) */ @@ -125,6 +125,6 @@ library Number { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - _store.deleteRecord(_tableId, _keyTuple); + _store.deleteRecord(_tableId, _keyTuple, getSchema()); } } diff --git a/e2e/packages/contracts/src/codegen/tables/NumberList.sol b/e2e/packages/contracts/src/codegen/tables/NumberList.sol index b450658074..16725ce200 100644 --- a/e2e/packages/contracts/src/codegen/tables/NumberList.sol +++ b/e2e/packages/contracts/src/codegen/tables/NumberList.sol @@ -68,7 +68,7 @@ library NumberList { function get() internal view returns (uint32[] memory value) { bytes32[] memory _keyTuple = new bytes32[](0); - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0, getSchema()); return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_uint32()); } @@ -76,7 +76,7 @@ library NumberList { function get(IStore _store) internal view returns (uint32[] memory value) { bytes32[] memory _keyTuple = new bytes32[](0); - bytes memory _blob = _store.getField(_tableId, _keyTuple, 0); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 0, getSchema()); return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_uint32()); } @@ -84,14 +84,14 @@ library NumberList { function set(uint32[] memory value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); + StoreSwitch.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), getSchema()); } /** Set value (using the specified store) */ function set(IStore _store, uint32[] memory value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); + _store.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), getSchema()); } /** Get the length of value */ @@ -144,28 +144,28 @@ library NumberList { function push(uint32 _element) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); + StoreSwitch.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), getSchema()); } /** Push an element to value (using the specified store) */ function push(IStore _store, uint32 _element) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); + _store.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), getSchema()); } /** Pop an element from value */ function pop() internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.popFromField(_tableId, _keyTuple, 0, 4); + StoreSwitch.popFromField(_tableId, _keyTuple, 0, 4, getSchema()); } /** Pop an element from value (using the specified store) */ function pop(IStore _store) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.popFromField(_tableId, _keyTuple, 0, 4); + _store.popFromField(_tableId, _keyTuple, 0, 4, getSchema()); } /** @@ -176,7 +176,7 @@ library NumberList { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 0, _index * 4, abi.encodePacked((_element))); + StoreSwitch.updateInField(_tableId, _keyTuple, 0, _index * 4, abi.encodePacked((_element)), getSchema()); } } @@ -188,7 +188,7 @@ library NumberList { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - _store.updateInField(_tableId, _keyTuple, 0, _index * 4, abi.encodePacked((_element))); + _store.updateInField(_tableId, _keyTuple, 0, _index * 4, abi.encodePacked((_element)), getSchema()); } } @@ -212,13 +212,13 @@ library NumberList { function deleteRecord() internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.deleteRecord(_tableId, _keyTuple); + StoreSwitch.deleteRecord(_tableId, _keyTuple, getSchema()); } /* Delete all data for given keys (using the specified store) */ function deleteRecord(IStore _store) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.deleteRecord(_tableId, _keyTuple); + _store.deleteRecord(_tableId, _keyTuple, getSchema()); } } diff --git a/e2e/packages/contracts/src/codegen/tables/Vector.sol b/e2e/packages/contracts/src/codegen/tables/Vector.sol index 52cf8a6d1f..ab38e25720 100644 --- a/e2e/packages/contracts/src/codegen/tables/Vector.sol +++ b/e2e/packages/contracts/src/codegen/tables/Vector.sol @@ -77,7 +77,7 @@ library Vector { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0, getSchema()); return (int32(uint32(Bytes.slice4(_blob, 0)))); } @@ -86,7 +86,7 @@ library Vector { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - bytes memory _blob = _store.getField(_tableId, _keyTuple, 0); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 0, getSchema()); return (int32(uint32(Bytes.slice4(_blob, 0)))); } @@ -95,7 +95,7 @@ library Vector { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((x))); + StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((x)), getSchema()); } /** Set x (using the specified store) */ @@ -103,7 +103,7 @@ library Vector { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((x))); + _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((x)), getSchema()); } /** Get y */ @@ -111,7 +111,7 @@ library Vector { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 1); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 1, getSchema()); return (int32(uint32(Bytes.slice4(_blob, 0)))); } @@ -120,7 +120,7 @@ library Vector { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - bytes memory _blob = _store.getField(_tableId, _keyTuple, 1); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 1, getSchema()); return (int32(uint32(Bytes.slice4(_blob, 0)))); } @@ -129,7 +129,7 @@ library Vector { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - StoreSwitch.setField(_tableId, _keyTuple, 1, abi.encodePacked((y))); + StoreSwitch.setField(_tableId, _keyTuple, 1, abi.encodePacked((y)), getSchema()); } /** Set y (using the specified store) */ @@ -137,7 +137,7 @@ library Vector { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - _store.setField(_tableId, _keyTuple, 1, abi.encodePacked((y))); + _store.setField(_tableId, _keyTuple, 1, abi.encodePacked((y)), getSchema()); } /** Get the full data */ @@ -165,7 +165,7 @@ library Vector { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - StoreSwitch.setRecord(_tableId, _keyTuple, _data); + StoreSwitch.setRecord(_tableId, _keyTuple, _data, getSchema()); } /** Set the full data using individual values (using the specified store) */ @@ -175,7 +175,7 @@ library Vector { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - _store.setRecord(_tableId, _keyTuple, _data); + _store.setRecord(_tableId, _keyTuple, _data, getSchema()); } /** Set the full data using the data struct */ @@ -213,7 +213,7 @@ library Vector { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - StoreSwitch.deleteRecord(_tableId, _keyTuple); + StoreSwitch.deleteRecord(_tableId, _keyTuple, getSchema()); } /* Delete all data for given keys (using the specified store) */ @@ -221,6 +221,6 @@ library Vector { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); - _store.deleteRecord(_tableId, _keyTuple); + _store.deleteRecord(_tableId, _keyTuple, getSchema()); } } diff --git a/e2e/packages/contracts/src/systems/NumberListSystem.sol b/e2e/packages/contracts/src/systems/NumberListSystem.sol index 1c80b4ac99..4587ea3879 100644 --- a/e2e/packages/contracts/src/systems/NumberListSystem.sol +++ b/e2e/packages/contracts/src/systems/NumberListSystem.sol @@ -22,7 +22,7 @@ contract NumberListSystem is System { } bytes32[] memory emptyKey; - StoreSwitch.pushToField(NumberListTableId, emptyKey, 0, EncodeArray.encode(list)); + StoreSwitch.pushToField(NumberListTableId, emptyKey, 0, EncodeArray.encode(list), NumberList.getSchema()); } function pop() public { diff --git a/e2e/packages/contracts/types/ethers-contracts/IWorld.ts b/e2e/packages/contracts/types/ethers-contracts/IWorld.ts index 1304448c02..69bddd92f8 100644 --- a/e2e/packages/contracts/types/ethers-contracts/IWorld.ts +++ b/e2e/packages/contracts/types/ethers-contracts/IWorld.ts @@ -31,27 +31,26 @@ import type { export interface IWorldInterface extends utils.Interface { functions: { "call(bytes16,bytes16,bytes)": FunctionFragment; - "deleteRecord(bytes32,bytes32[])": FunctionFragment; - "deleteRecord(bytes16,bytes16,bytes32[])": FunctionFragment; - "emitEphemeralRecord(bytes16,bytes16,bytes32[],bytes)": FunctionFragment; - "emitEphemeralRecord(bytes32,bytes32[],bytes)": FunctionFragment; - "getField(bytes32,bytes32[],uint8)": FunctionFragment; + "deleteRecord(bytes32,bytes32[],bytes32)": FunctionFragment; + "deleteRecord(bytes16,bytes16,bytes32[],bytes32)": FunctionFragment; + "emitEphemeralRecord(bytes16,bytes16,bytes32[],bytes,bytes32)": FunctionFragment; + "emitEphemeralRecord(bytes32,bytes32[],bytes,bytes32)": FunctionFragment; + "getField(bytes32,bytes32[],uint8,bytes32)": FunctionFragment; "getFieldLength(bytes32,bytes32[],uint8,bytes32)": FunctionFragment; "getFieldSlice(bytes32,bytes32[],uint8,bytes32,uint256,uint256)": FunctionFragment; "getKeySchema(bytes32)": FunctionFragment; "getRecord(bytes32,bytes32[],bytes32)": FunctionFragment; - "getRecord(bytes32,bytes32[])": FunctionFragment; "getSchema(bytes32)": FunctionFragment; "grantAccess(bytes16,bytes16,address)": FunctionFragment; "installModule(address,bytes)": FunctionFragment; "installRootModule(address,bytes)": FunctionFragment; "pop()": FunctionFragment; - "popFromField(bytes16,bytes16,bytes32[],uint8,uint256)": FunctionFragment; - "popFromField(bytes32,bytes32[],uint8,uint256)": FunctionFragment; + "popFromField(bytes32,bytes32[],uint8,uint256,bytes32)": FunctionFragment; + "popFromField(bytes16,bytes16,bytes32[],uint8,uint256,bytes32)": FunctionFragment; "push(uint32)": FunctionFragment; "pushRange(uint32,uint32)": FunctionFragment; - "pushToField(bytes32,bytes32[],uint8,bytes)": FunctionFragment; - "pushToField(bytes16,bytes16,bytes32[],uint8,bytes)": FunctionFragment; + "pushToField(bytes32,bytes32[],uint8,bytes,bytes32)": FunctionFragment; + "pushToField(bytes16,bytes16,bytes32[],uint8,bytes,bytes32)": FunctionFragment; "registerFunctionSelector(bytes16,bytes16,string,string)": FunctionFragment; "registerHook(bytes16,bytes16,address)": FunctionFragment; "registerNamespace(bytes16)": FunctionFragment; @@ -64,41 +63,40 @@ export interface IWorldInterface extends utils.Interface { "registerTableHook(bytes16,bytes16,address)": FunctionFragment; "revokeAccess(bytes16,bytes16,address)": FunctionFragment; "set(uint32[])": FunctionFragment; - "setField(bytes32,bytes32[],uint8,bytes)": FunctionFragment; - "setField(bytes16,bytes16,bytes32[],uint8,bytes)": FunctionFragment; + "setField(bytes16,bytes16,bytes32[],uint8,bytes,bytes32)": FunctionFragment; + "setField(bytes32,bytes32[],uint8,bytes,bytes32)": FunctionFragment; "setMetadata(bytes16,bytes16,string,string[])": FunctionFragment; "setMetadata(bytes32,string,string[])": FunctionFragment; - "setRecord(bytes16,bytes16,bytes32[],bytes)": FunctionFragment; - "setRecord(bytes32,bytes32[],bytes)": FunctionFragment; + "setRecord(bytes32,bytes32[],bytes,bytes32)": FunctionFragment; + "setRecord(bytes16,bytes16,bytes32[],bytes,bytes32)": FunctionFragment; "stub(uint256)": FunctionFragment; - "updateInField(bytes32,bytes32[],uint8,uint256,bytes)": FunctionFragment; - "updateInField(bytes16,bytes16,bytes32[],uint8,uint256,bytes)": FunctionFragment; + "updateInField(bytes32,bytes32[],uint8,uint256,bytes,bytes32)": FunctionFragment; + "updateInField(bytes16,bytes16,bytes32[],uint8,uint256,bytes,bytes32)": FunctionFragment; }; getFunction( nameOrSignatureOrTopic: | "call" - | "deleteRecord(bytes32,bytes32[])" - | "deleteRecord(bytes16,bytes16,bytes32[])" - | "emitEphemeralRecord(bytes16,bytes16,bytes32[],bytes)" - | "emitEphemeralRecord(bytes32,bytes32[],bytes)" + | "deleteRecord(bytes32,bytes32[],bytes32)" + | "deleteRecord(bytes16,bytes16,bytes32[],bytes32)" + | "emitEphemeralRecord(bytes16,bytes16,bytes32[],bytes,bytes32)" + | "emitEphemeralRecord(bytes32,bytes32[],bytes,bytes32)" | "getField" | "getFieldLength" | "getFieldSlice" | "getKeySchema" - | "getRecord(bytes32,bytes32[],bytes32)" - | "getRecord(bytes32,bytes32[])" + | "getRecord" | "getSchema" | "grantAccess" | "installModule" | "installRootModule" | "pop" - | "popFromField(bytes16,bytes16,bytes32[],uint8,uint256)" - | "popFromField(bytes32,bytes32[],uint8,uint256)" + | "popFromField(bytes32,bytes32[],uint8,uint256,bytes32)" + | "popFromField(bytes16,bytes16,bytes32[],uint8,uint256,bytes32)" | "push" | "pushRange" - | "pushToField(bytes32,bytes32[],uint8,bytes)" - | "pushToField(bytes16,bytes16,bytes32[],uint8,bytes)" + | "pushToField(bytes32,bytes32[],uint8,bytes,bytes32)" + | "pushToField(bytes16,bytes16,bytes32[],uint8,bytes,bytes32)" | "registerFunctionSelector" | "registerHook" | "registerNamespace" @@ -111,15 +109,15 @@ export interface IWorldInterface extends utils.Interface { | "registerTableHook" | "revokeAccess" | "set" - | "setField(bytes32,bytes32[],uint8,bytes)" - | "setField(bytes16,bytes16,bytes32[],uint8,bytes)" + | "setField(bytes16,bytes16,bytes32[],uint8,bytes,bytes32)" + | "setField(bytes32,bytes32[],uint8,bytes,bytes32)" | "setMetadata(bytes16,bytes16,string,string[])" | "setMetadata(bytes32,string,string[])" - | "setRecord(bytes16,bytes16,bytes32[],bytes)" - | "setRecord(bytes32,bytes32[],bytes)" + | "setRecord(bytes32,bytes32[],bytes,bytes32)" + | "setRecord(bytes16,bytes16,bytes32[],bytes,bytes32)" | "stub" - | "updateInField(bytes32,bytes32[],uint8,uint256,bytes)" - | "updateInField(bytes16,bytes16,bytes32[],uint8,uint256,bytes)" + | "updateInField(bytes32,bytes32[],uint8,uint256,bytes,bytes32)" + | "updateInField(bytes16,bytes16,bytes32[],uint8,uint256,bytes,bytes32)" ): FunctionFragment; encodeFunctionData( @@ -131,31 +129,38 @@ export interface IWorldInterface extends utils.Interface { ] ): string; encodeFunctionData( - functionFragment: "deleteRecord(bytes32,bytes32[])", - values: [PromiseOrValue, PromiseOrValue[]] + functionFragment: "deleteRecord(bytes32,bytes32[],bytes32)", + values: [ + PromiseOrValue, + PromiseOrValue[], + PromiseOrValue + ] ): string; encodeFunctionData( - functionFragment: "deleteRecord(bytes16,bytes16,bytes32[])", + functionFragment: "deleteRecord(bytes16,bytes16,bytes32[],bytes32)", values: [ PromiseOrValue, PromiseOrValue, - PromiseOrValue[] + PromiseOrValue[], + PromiseOrValue ] ): string; encodeFunctionData( - functionFragment: "emitEphemeralRecord(bytes16,bytes16,bytes32[],bytes)", + functionFragment: "emitEphemeralRecord(bytes16,bytes16,bytes32[],bytes,bytes32)", values: [ PromiseOrValue, PromiseOrValue, PromiseOrValue[], + PromiseOrValue, PromiseOrValue ] ): string; encodeFunctionData( - functionFragment: "emitEphemeralRecord(bytes32,bytes32[],bytes)", + functionFragment: "emitEphemeralRecord(bytes32,bytes32[],bytes,bytes32)", values: [ PromiseOrValue, PromiseOrValue[], + PromiseOrValue, PromiseOrValue ] ): string; @@ -164,7 +169,8 @@ export interface IWorldInterface extends utils.Interface { values: [ PromiseOrValue, PromiseOrValue[], - PromiseOrValue + PromiseOrValue, + PromiseOrValue ] ): string; encodeFunctionData( @@ -192,17 +198,13 @@ export interface IWorldInterface extends utils.Interface { values: [PromiseOrValue] ): string; encodeFunctionData( - functionFragment: "getRecord(bytes32,bytes32[],bytes32)", + functionFragment: "getRecord", values: [ PromiseOrValue, PromiseOrValue[], PromiseOrValue ] ): string; - encodeFunctionData( - functionFragment: "getRecord(bytes32,bytes32[])", - values: [PromiseOrValue, PromiseOrValue[]] - ): string; encodeFunctionData( functionFragment: "getSchema", values: [PromiseOrValue] @@ -225,22 +227,24 @@ export interface IWorldInterface extends utils.Interface { ): string; encodeFunctionData(functionFragment: "pop", values?: undefined): string; encodeFunctionData( - functionFragment: "popFromField(bytes16,bytes16,bytes32[],uint8,uint256)", + functionFragment: "popFromField(bytes32,bytes32[],uint8,uint256,bytes32)", values: [ - PromiseOrValue, PromiseOrValue, PromiseOrValue[], PromiseOrValue, - PromiseOrValue + PromiseOrValue, + PromiseOrValue ] ): string; encodeFunctionData( - functionFragment: "popFromField(bytes32,bytes32[],uint8,uint256)", + functionFragment: "popFromField(bytes16,bytes16,bytes32[],uint8,uint256,bytes32)", values: [ + PromiseOrValue, PromiseOrValue, PromiseOrValue[], PromiseOrValue, - PromiseOrValue + PromiseOrValue, + PromiseOrValue ] ): string; encodeFunctionData( @@ -252,21 +256,23 @@ export interface IWorldInterface extends utils.Interface { values: [PromiseOrValue, PromiseOrValue] ): string; encodeFunctionData( - functionFragment: "pushToField(bytes32,bytes32[],uint8,bytes)", + functionFragment: "pushToField(bytes32,bytes32[],uint8,bytes,bytes32)", values: [ PromiseOrValue, PromiseOrValue[], PromiseOrValue, + PromiseOrValue, PromiseOrValue ] ): string; encodeFunctionData( - functionFragment: "pushToField(bytes16,bytes16,bytes32[],uint8,bytes)", + functionFragment: "pushToField(bytes16,bytes16,bytes32[],uint8,bytes,bytes32)", values: [ PromiseOrValue, PromiseOrValue, PromiseOrValue[], PromiseOrValue, + PromiseOrValue, PromiseOrValue ] ): string; @@ -359,21 +365,23 @@ export interface IWorldInterface extends utils.Interface { values: [PromiseOrValue[]] ): string; encodeFunctionData( - functionFragment: "setField(bytes32,bytes32[],uint8,bytes)", + functionFragment: "setField(bytes16,bytes16,bytes32[],uint8,bytes,bytes32)", values: [ + PromiseOrValue, PromiseOrValue, PromiseOrValue[], PromiseOrValue, + PromiseOrValue, PromiseOrValue ] ): string; encodeFunctionData( - functionFragment: "setField(bytes16,bytes16,bytes32[],uint8,bytes)", + functionFragment: "setField(bytes32,bytes32[],uint8,bytes,bytes32)", values: [ - PromiseOrValue, PromiseOrValue, PromiseOrValue[], PromiseOrValue, + PromiseOrValue, PromiseOrValue ] ): string; @@ -395,19 +403,21 @@ export interface IWorldInterface extends utils.Interface { ] ): string; encodeFunctionData( - functionFragment: "setRecord(bytes16,bytes16,bytes32[],bytes)", + functionFragment: "setRecord(bytes32,bytes32[],bytes,bytes32)", values: [ - PromiseOrValue, PromiseOrValue, PromiseOrValue[], + PromiseOrValue, PromiseOrValue ] ): string; encodeFunctionData( - functionFragment: "setRecord(bytes32,bytes32[],bytes)", + functionFragment: "setRecord(bytes16,bytes16,bytes32[],bytes,bytes32)", values: [ + PromiseOrValue, PromiseOrValue, PromiseOrValue[], + PromiseOrValue, PromiseOrValue ] ): string; @@ -416,42 +426,44 @@ export interface IWorldInterface extends utils.Interface { values: [PromiseOrValue] ): string; encodeFunctionData( - functionFragment: "updateInField(bytes32,bytes32[],uint8,uint256,bytes)", + functionFragment: "updateInField(bytes32,bytes32[],uint8,uint256,bytes,bytes32)", values: [ PromiseOrValue, PromiseOrValue[], PromiseOrValue, PromiseOrValue, + PromiseOrValue, PromiseOrValue ] ): string; encodeFunctionData( - functionFragment: "updateInField(bytes16,bytes16,bytes32[],uint8,uint256,bytes)", + functionFragment: "updateInField(bytes16,bytes16,bytes32[],uint8,uint256,bytes,bytes32)", values: [ PromiseOrValue, PromiseOrValue, PromiseOrValue[], PromiseOrValue, PromiseOrValue, + PromiseOrValue, PromiseOrValue ] ): string; decodeFunctionResult(functionFragment: "call", data: BytesLike): Result; decodeFunctionResult( - functionFragment: "deleteRecord(bytes32,bytes32[])", + functionFragment: "deleteRecord(bytes32,bytes32[],bytes32)", data: BytesLike ): Result; decodeFunctionResult( - functionFragment: "deleteRecord(bytes16,bytes16,bytes32[])", + functionFragment: "deleteRecord(bytes16,bytes16,bytes32[],bytes32)", data: BytesLike ): Result; decodeFunctionResult( - functionFragment: "emitEphemeralRecord(bytes16,bytes16,bytes32[],bytes)", + functionFragment: "emitEphemeralRecord(bytes16,bytes16,bytes32[],bytes,bytes32)", data: BytesLike ): Result; decodeFunctionResult( - functionFragment: "emitEphemeralRecord(bytes32,bytes32[],bytes)", + functionFragment: "emitEphemeralRecord(bytes32,bytes32[],bytes,bytes32)", data: BytesLike ): Result; decodeFunctionResult(functionFragment: "getField", data: BytesLike): Result; @@ -467,14 +479,7 @@ export interface IWorldInterface extends utils.Interface { functionFragment: "getKeySchema", data: BytesLike ): Result; - decodeFunctionResult( - functionFragment: "getRecord(bytes32,bytes32[],bytes32)", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "getRecord(bytes32,bytes32[])", - data: BytesLike - ): Result; + decodeFunctionResult(functionFragment: "getRecord", data: BytesLike): Result; decodeFunctionResult(functionFragment: "getSchema", data: BytesLike): Result; decodeFunctionResult( functionFragment: "grantAccess", @@ -490,21 +495,21 @@ export interface IWorldInterface extends utils.Interface { ): Result; decodeFunctionResult(functionFragment: "pop", data: BytesLike): Result; decodeFunctionResult( - functionFragment: "popFromField(bytes16,bytes16,bytes32[],uint8,uint256)", + functionFragment: "popFromField(bytes32,bytes32[],uint8,uint256,bytes32)", data: BytesLike ): Result; decodeFunctionResult( - functionFragment: "popFromField(bytes32,bytes32[],uint8,uint256)", + functionFragment: "popFromField(bytes16,bytes16,bytes32[],uint8,uint256,bytes32)", data: BytesLike ): Result; decodeFunctionResult(functionFragment: "push", data: BytesLike): Result; decodeFunctionResult(functionFragment: "pushRange", data: BytesLike): Result; decodeFunctionResult( - functionFragment: "pushToField(bytes32,bytes32[],uint8,bytes)", + functionFragment: "pushToField(bytes32,bytes32[],uint8,bytes,bytes32)", data: BytesLike ): Result; decodeFunctionResult( - functionFragment: "pushToField(bytes16,bytes16,bytes32[],uint8,bytes)", + functionFragment: "pushToField(bytes16,bytes16,bytes32[],uint8,bytes,bytes32)", data: BytesLike ): Result; decodeFunctionResult( @@ -553,11 +558,11 @@ export interface IWorldInterface extends utils.Interface { ): Result; decodeFunctionResult(functionFragment: "set", data: BytesLike): Result; decodeFunctionResult( - functionFragment: "setField(bytes32,bytes32[],uint8,bytes)", + functionFragment: "setField(bytes16,bytes16,bytes32[],uint8,bytes,bytes32)", data: BytesLike ): Result; decodeFunctionResult( - functionFragment: "setField(bytes16,bytes16,bytes32[],uint8,bytes)", + functionFragment: "setField(bytes32,bytes32[],uint8,bytes,bytes32)", data: BytesLike ): Result; decodeFunctionResult( @@ -569,20 +574,20 @@ export interface IWorldInterface extends utils.Interface { data: BytesLike ): Result; decodeFunctionResult( - functionFragment: "setRecord(bytes16,bytes16,bytes32[],bytes)", + functionFragment: "setRecord(bytes32,bytes32[],bytes,bytes32)", data: BytesLike ): Result; decodeFunctionResult( - functionFragment: "setRecord(bytes32,bytes32[],bytes)", + functionFragment: "setRecord(bytes16,bytes16,bytes32[],bytes,bytes32)", data: BytesLike ): Result; decodeFunctionResult(functionFragment: "stub", data: BytesLike): Result; decodeFunctionResult( - functionFragment: "updateInField(bytes32,bytes32[],uint8,uint256,bytes)", + functionFragment: "updateInField(bytes32,bytes32[],uint8,uint256,bytes,bytes32)", data: BytesLike ): Result; decodeFunctionResult( - functionFragment: "updateInField(bytes16,bytes16,bytes32[],uint8,uint256,bytes)", + functionFragment: "updateInField(bytes16,bytes16,bytes32[],uint8,uint256,bytes,bytes32)", data: BytesLike ): Result; @@ -690,31 +695,35 @@ export interface IWorld extends BaseContract { overrides?: PayableOverrides & { from?: PromiseOrValue } ): Promise; - "deleteRecord(bytes32,bytes32[])"( + "deleteRecord(bytes32,bytes32[],bytes32)"( table: PromiseOrValue, key: PromiseOrValue[], + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "deleteRecord(bytes16,bytes16,bytes32[])"( + "deleteRecord(bytes16,bytes16,bytes32[],bytes32)"( namespace: PromiseOrValue, name: PromiseOrValue, key: PromiseOrValue[], + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "emitEphemeralRecord(bytes16,bytes16,bytes32[],bytes)"( + "emitEphemeralRecord(bytes16,bytes16,bytes32[],bytes,bytes32)"( namespace: PromiseOrValue, name: PromiseOrValue, key: PromiseOrValue[], data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "emitEphemeralRecord(bytes32,bytes32[],bytes)"( + "emitEphemeralRecord(bytes32,bytes32[],bytes,bytes32)"( table: PromiseOrValue, key: PromiseOrValue[], data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -722,6 +731,7 @@ export interface IWorld extends BaseContract { table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise<[string] & { data: string }>; @@ -729,7 +739,7 @@ export interface IWorld extends BaseContract { table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, - schema: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise<[BigNumber]>; @@ -737,7 +747,7 @@ export interface IWorld extends BaseContract { table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, - schema: PromiseOrValue, + valueSchema: PromiseOrValue, start: PromiseOrValue, end: PromiseOrValue, overrides?: CallOverrides @@ -748,16 +758,10 @@ export interface IWorld extends BaseContract { overrides?: CallOverrides ): Promise<[string] & { schema: string }>; - "getRecord(bytes32,bytes32[],bytes32)"( - table: PromiseOrValue, - key: PromiseOrValue[], - schema: PromiseOrValue, - overrides?: CallOverrides - ): Promise<[string] & { data: string }>; - - "getRecord(bytes32,bytes32[])"( + getRecord( table: PromiseOrValue, key: PromiseOrValue[], + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise<[string] & { data: string }>; @@ -789,20 +793,22 @@ export interface IWorld extends BaseContract { overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "popFromField(bytes16,bytes16,bytes32[],uint8,uint256)"( - namespace: PromiseOrValue, - name: PromiseOrValue, + "popFromField(bytes32,bytes32[],uint8,uint256,bytes32)"( + table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, byteLengthToPop: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "popFromField(bytes32,bytes32[],uint8,uint256)"( - table: PromiseOrValue, + "popFromField(bytes16,bytes16,bytes32[],uint8,uint256,bytes32)"( + namespace: PromiseOrValue, + name: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, byteLengthToPop: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -817,20 +823,22 @@ export interface IWorld extends BaseContract { overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "pushToField(bytes32,bytes32[],uint8,bytes)"( + "pushToField(bytes32,bytes32[],uint8,bytes,bytes32)"( table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, dataToPush: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "pushToField(bytes16,bytes16,bytes32[],uint8,bytes)"( + "pushToField(bytes16,bytes16,bytes32[],uint8,bytes,bytes32)"( namespace: PromiseOrValue, name: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, dataToPush: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -917,20 +925,22 @@ export interface IWorld extends BaseContract { overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "setField(bytes32,bytes32[],uint8,bytes)"( - table: PromiseOrValue, + "setField(bytes16,bytes16,bytes32[],uint8,bytes,bytes32)"( + namespace: PromiseOrValue, + name: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "setField(bytes16,bytes16,bytes32[],uint8,bytes)"( - namespace: PromiseOrValue, - name: PromiseOrValue, + "setField(bytes32,bytes32[],uint8,bytes,bytes32)"( + table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -949,18 +959,20 @@ export interface IWorld extends BaseContract { overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "setRecord(bytes16,bytes16,bytes32[],bytes)"( - namespace: PromiseOrValue, - name: PromiseOrValue, + "setRecord(bytes32,bytes32[],bytes,bytes32)"( + table: PromiseOrValue, key: PromiseOrValue[], data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "setRecord(bytes32,bytes32[],bytes)"( - table: PromiseOrValue, + "setRecord(bytes16,bytes16,bytes32[],bytes,bytes32)"( + namespace: PromiseOrValue, + name: PromiseOrValue, key: PromiseOrValue[], data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -969,22 +981,24 @@ export interface IWorld extends BaseContract { overrides?: CallOverrides ): Promise<[BigNumber]>; - "updateInField(bytes32,bytes32[],uint8,uint256,bytes)"( + "updateInField(bytes32,bytes32[],uint8,uint256,bytes,bytes32)"( table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, startByteIndex: PromiseOrValue, dataToSet: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "updateInField(bytes16,bytes16,bytes32[],uint8,uint256,bytes)"( + "updateInField(bytes16,bytes16,bytes32[],uint8,uint256,bytes,bytes32)"( namespace: PromiseOrValue, name: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, startByteIndex: PromiseOrValue, dataToSet: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; }; @@ -996,31 +1010,35 @@ export interface IWorld extends BaseContract { overrides?: PayableOverrides & { from?: PromiseOrValue } ): Promise; - "deleteRecord(bytes32,bytes32[])"( + "deleteRecord(bytes32,bytes32[],bytes32)"( table: PromiseOrValue, key: PromiseOrValue[], + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "deleteRecord(bytes16,bytes16,bytes32[])"( + "deleteRecord(bytes16,bytes16,bytes32[],bytes32)"( namespace: PromiseOrValue, name: PromiseOrValue, key: PromiseOrValue[], + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "emitEphemeralRecord(bytes16,bytes16,bytes32[],bytes)"( + "emitEphemeralRecord(bytes16,bytes16,bytes32[],bytes,bytes32)"( namespace: PromiseOrValue, name: PromiseOrValue, key: PromiseOrValue[], data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "emitEphemeralRecord(bytes32,bytes32[],bytes)"( + "emitEphemeralRecord(bytes32,bytes32[],bytes,bytes32)"( table: PromiseOrValue, key: PromiseOrValue[], data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -1028,6 +1046,7 @@ export interface IWorld extends BaseContract { table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; @@ -1035,7 +1054,7 @@ export interface IWorld extends BaseContract { table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, - schema: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; @@ -1043,7 +1062,7 @@ export interface IWorld extends BaseContract { table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, - schema: PromiseOrValue, + valueSchema: PromiseOrValue, start: PromiseOrValue, end: PromiseOrValue, overrides?: CallOverrides @@ -1054,16 +1073,10 @@ export interface IWorld extends BaseContract { overrides?: CallOverrides ): Promise; - "getRecord(bytes32,bytes32[],bytes32)"( - table: PromiseOrValue, - key: PromiseOrValue[], - schema: PromiseOrValue, - overrides?: CallOverrides - ): Promise; - - "getRecord(bytes32,bytes32[])"( + getRecord( table: PromiseOrValue, key: PromiseOrValue[], + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; @@ -1095,20 +1108,22 @@ export interface IWorld extends BaseContract { overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "popFromField(bytes16,bytes16,bytes32[],uint8,uint256)"( - namespace: PromiseOrValue, - name: PromiseOrValue, + "popFromField(bytes32,bytes32[],uint8,uint256,bytes32)"( + table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, byteLengthToPop: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "popFromField(bytes32,bytes32[],uint8,uint256)"( - table: PromiseOrValue, + "popFromField(bytes16,bytes16,bytes32[],uint8,uint256,bytes32)"( + namespace: PromiseOrValue, + name: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, byteLengthToPop: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -1123,20 +1138,22 @@ export interface IWorld extends BaseContract { overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "pushToField(bytes32,bytes32[],uint8,bytes)"( + "pushToField(bytes32,bytes32[],uint8,bytes,bytes32)"( table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, dataToPush: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "pushToField(bytes16,bytes16,bytes32[],uint8,bytes)"( + "pushToField(bytes16,bytes16,bytes32[],uint8,bytes,bytes32)"( namespace: PromiseOrValue, name: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, dataToPush: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -1223,20 +1240,22 @@ export interface IWorld extends BaseContract { overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "setField(bytes32,bytes32[],uint8,bytes)"( - table: PromiseOrValue, + "setField(bytes16,bytes16,bytes32[],uint8,bytes,bytes32)"( + namespace: PromiseOrValue, + name: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "setField(bytes16,bytes16,bytes32[],uint8,bytes)"( - namespace: PromiseOrValue, - name: PromiseOrValue, + "setField(bytes32,bytes32[],uint8,bytes,bytes32)"( + table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -1255,18 +1274,20 @@ export interface IWorld extends BaseContract { overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "setRecord(bytes16,bytes16,bytes32[],bytes)"( - namespace: PromiseOrValue, - name: PromiseOrValue, + "setRecord(bytes32,bytes32[],bytes,bytes32)"( + table: PromiseOrValue, key: PromiseOrValue[], data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "setRecord(bytes32,bytes32[],bytes)"( - table: PromiseOrValue, + "setRecord(bytes16,bytes16,bytes32[],bytes,bytes32)"( + namespace: PromiseOrValue, + name: PromiseOrValue, key: PromiseOrValue[], data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -1275,22 +1296,24 @@ export interface IWorld extends BaseContract { overrides?: CallOverrides ): Promise; - "updateInField(bytes32,bytes32[],uint8,uint256,bytes)"( + "updateInField(bytes32,bytes32[],uint8,uint256,bytes,bytes32)"( table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, startByteIndex: PromiseOrValue, dataToSet: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "updateInField(bytes16,bytes16,bytes32[],uint8,uint256,bytes)"( + "updateInField(bytes16,bytes16,bytes32[],uint8,uint256,bytes,bytes32)"( namespace: PromiseOrValue, name: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, startByteIndex: PromiseOrValue, dataToSet: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -1302,31 +1325,35 @@ export interface IWorld extends BaseContract { overrides?: CallOverrides ): Promise; - "deleteRecord(bytes32,bytes32[])"( + "deleteRecord(bytes32,bytes32[],bytes32)"( table: PromiseOrValue, key: PromiseOrValue[], + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; - "deleteRecord(bytes16,bytes16,bytes32[])"( + "deleteRecord(bytes16,bytes16,bytes32[],bytes32)"( namespace: PromiseOrValue, name: PromiseOrValue, key: PromiseOrValue[], + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; - "emitEphemeralRecord(bytes16,bytes16,bytes32[],bytes)"( + "emitEphemeralRecord(bytes16,bytes16,bytes32[],bytes,bytes32)"( namespace: PromiseOrValue, name: PromiseOrValue, key: PromiseOrValue[], data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; - "emitEphemeralRecord(bytes32,bytes32[],bytes)"( + "emitEphemeralRecord(bytes32,bytes32[],bytes,bytes32)"( table: PromiseOrValue, key: PromiseOrValue[], data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; @@ -1334,6 +1361,7 @@ export interface IWorld extends BaseContract { table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; @@ -1341,7 +1369,7 @@ export interface IWorld extends BaseContract { table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, - schema: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; @@ -1349,7 +1377,7 @@ export interface IWorld extends BaseContract { table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, - schema: PromiseOrValue, + valueSchema: PromiseOrValue, start: PromiseOrValue, end: PromiseOrValue, overrides?: CallOverrides @@ -1360,16 +1388,10 @@ export interface IWorld extends BaseContract { overrides?: CallOverrides ): Promise; - "getRecord(bytes32,bytes32[],bytes32)"( - table: PromiseOrValue, - key: PromiseOrValue[], - schema: PromiseOrValue, - overrides?: CallOverrides - ): Promise; - - "getRecord(bytes32,bytes32[])"( + getRecord( table: PromiseOrValue, key: PromiseOrValue[], + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; @@ -1399,20 +1421,22 @@ export interface IWorld extends BaseContract { pop(overrides?: CallOverrides): Promise; - "popFromField(bytes16,bytes16,bytes32[],uint8,uint256)"( - namespace: PromiseOrValue, - name: PromiseOrValue, + "popFromField(bytes32,bytes32[],uint8,uint256,bytes32)"( + table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, byteLengthToPop: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; - "popFromField(bytes32,bytes32[],uint8,uint256)"( - table: PromiseOrValue, + "popFromField(bytes16,bytes16,bytes32[],uint8,uint256,bytes32)"( + namespace: PromiseOrValue, + name: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, byteLengthToPop: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; @@ -1427,20 +1451,22 @@ export interface IWorld extends BaseContract { overrides?: CallOverrides ): Promise; - "pushToField(bytes32,bytes32[],uint8,bytes)"( + "pushToField(bytes32,bytes32[],uint8,bytes,bytes32)"( table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, dataToPush: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; - "pushToField(bytes16,bytes16,bytes32[],uint8,bytes)"( + "pushToField(bytes16,bytes16,bytes32[],uint8,bytes,bytes32)"( namespace: PromiseOrValue, name: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, dataToPush: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; @@ -1527,20 +1553,22 @@ export interface IWorld extends BaseContract { overrides?: CallOverrides ): Promise; - "setField(bytes32,bytes32[],uint8,bytes)"( - table: PromiseOrValue, + "setField(bytes16,bytes16,bytes32[],uint8,bytes,bytes32)"( + namespace: PromiseOrValue, + name: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; - "setField(bytes16,bytes16,bytes32[],uint8,bytes)"( - namespace: PromiseOrValue, - name: PromiseOrValue, + "setField(bytes32,bytes32[],uint8,bytes,bytes32)"( + table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; @@ -1559,18 +1587,20 @@ export interface IWorld extends BaseContract { overrides?: CallOverrides ): Promise; - "setRecord(bytes16,bytes16,bytes32[],bytes)"( - namespace: PromiseOrValue, - name: PromiseOrValue, + "setRecord(bytes32,bytes32[],bytes,bytes32)"( + table: PromiseOrValue, key: PromiseOrValue[], data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; - "setRecord(bytes32,bytes32[],bytes)"( - table: PromiseOrValue, + "setRecord(bytes16,bytes16,bytes32[],bytes,bytes32)"( + namespace: PromiseOrValue, + name: PromiseOrValue, key: PromiseOrValue[], data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; @@ -1579,22 +1609,24 @@ export interface IWorld extends BaseContract { overrides?: CallOverrides ): Promise; - "updateInField(bytes32,bytes32[],uint8,uint256,bytes)"( + "updateInField(bytes32,bytes32[],uint8,uint256,bytes,bytes32)"( table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, startByteIndex: PromiseOrValue, dataToSet: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; - "updateInField(bytes16,bytes16,bytes32[],uint8,uint256,bytes)"( + "updateInField(bytes16,bytes16,bytes32[],uint8,uint256,bytes,bytes32)"( namespace: PromiseOrValue, name: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, startByteIndex: PromiseOrValue, dataToSet: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; }; @@ -1653,31 +1685,35 @@ export interface IWorld extends BaseContract { overrides?: PayableOverrides & { from?: PromiseOrValue } ): Promise; - "deleteRecord(bytes32,bytes32[])"( + "deleteRecord(bytes32,bytes32[],bytes32)"( table: PromiseOrValue, key: PromiseOrValue[], + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "deleteRecord(bytes16,bytes16,bytes32[])"( + "deleteRecord(bytes16,bytes16,bytes32[],bytes32)"( namespace: PromiseOrValue, name: PromiseOrValue, key: PromiseOrValue[], + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "emitEphemeralRecord(bytes16,bytes16,bytes32[],bytes)"( + "emitEphemeralRecord(bytes16,bytes16,bytes32[],bytes,bytes32)"( namespace: PromiseOrValue, name: PromiseOrValue, key: PromiseOrValue[], data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "emitEphemeralRecord(bytes32,bytes32[],bytes)"( + "emitEphemeralRecord(bytes32,bytes32[],bytes,bytes32)"( table: PromiseOrValue, key: PromiseOrValue[], data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -1685,6 +1721,7 @@ export interface IWorld extends BaseContract { table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; @@ -1692,7 +1729,7 @@ export interface IWorld extends BaseContract { table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, - schema: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; @@ -1700,7 +1737,7 @@ export interface IWorld extends BaseContract { table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, - schema: PromiseOrValue, + valueSchema: PromiseOrValue, start: PromiseOrValue, end: PromiseOrValue, overrides?: CallOverrides @@ -1711,16 +1748,10 @@ export interface IWorld extends BaseContract { overrides?: CallOverrides ): Promise; - "getRecord(bytes32,bytes32[],bytes32)"( - table: PromiseOrValue, - key: PromiseOrValue[], - schema: PromiseOrValue, - overrides?: CallOverrides - ): Promise; - - "getRecord(bytes32,bytes32[])"( + getRecord( table: PromiseOrValue, key: PromiseOrValue[], + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; @@ -1752,20 +1783,22 @@ export interface IWorld extends BaseContract { overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "popFromField(bytes16,bytes16,bytes32[],uint8,uint256)"( - namespace: PromiseOrValue, - name: PromiseOrValue, + "popFromField(bytes32,bytes32[],uint8,uint256,bytes32)"( + table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, byteLengthToPop: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "popFromField(bytes32,bytes32[],uint8,uint256)"( - table: PromiseOrValue, + "popFromField(bytes16,bytes16,bytes32[],uint8,uint256,bytes32)"( + namespace: PromiseOrValue, + name: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, byteLengthToPop: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -1780,20 +1813,22 @@ export interface IWorld extends BaseContract { overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "pushToField(bytes32,bytes32[],uint8,bytes)"( + "pushToField(bytes32,bytes32[],uint8,bytes,bytes32)"( table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, dataToPush: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "pushToField(bytes16,bytes16,bytes32[],uint8,bytes)"( + "pushToField(bytes16,bytes16,bytes32[],uint8,bytes,bytes32)"( namespace: PromiseOrValue, name: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, dataToPush: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -1880,20 +1915,22 @@ export interface IWorld extends BaseContract { overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "setField(bytes32,bytes32[],uint8,bytes)"( - table: PromiseOrValue, + "setField(bytes16,bytes16,bytes32[],uint8,bytes,bytes32)"( + namespace: PromiseOrValue, + name: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "setField(bytes16,bytes16,bytes32[],uint8,bytes)"( - namespace: PromiseOrValue, - name: PromiseOrValue, + "setField(bytes32,bytes32[],uint8,bytes,bytes32)"( + table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -1912,18 +1949,20 @@ export interface IWorld extends BaseContract { overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "setRecord(bytes16,bytes16,bytes32[],bytes)"( - namespace: PromiseOrValue, - name: PromiseOrValue, + "setRecord(bytes32,bytes32[],bytes,bytes32)"( + table: PromiseOrValue, key: PromiseOrValue[], data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "setRecord(bytes32,bytes32[],bytes)"( - table: PromiseOrValue, + "setRecord(bytes16,bytes16,bytes32[],bytes,bytes32)"( + namespace: PromiseOrValue, + name: PromiseOrValue, key: PromiseOrValue[], data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -1932,22 +1971,24 @@ export interface IWorld extends BaseContract { overrides?: CallOverrides ): Promise; - "updateInField(bytes32,bytes32[],uint8,uint256,bytes)"( + "updateInField(bytes32,bytes32[],uint8,uint256,bytes,bytes32)"( table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, startByteIndex: PromiseOrValue, dataToSet: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "updateInField(bytes16,bytes16,bytes32[],uint8,uint256,bytes)"( + "updateInField(bytes16,bytes16,bytes32[],uint8,uint256,bytes,bytes32)"( namespace: PromiseOrValue, name: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, startByteIndex: PromiseOrValue, dataToSet: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; }; @@ -1960,31 +2001,35 @@ export interface IWorld extends BaseContract { overrides?: PayableOverrides & { from?: PromiseOrValue } ): Promise; - "deleteRecord(bytes32,bytes32[])"( + "deleteRecord(bytes32,bytes32[],bytes32)"( table: PromiseOrValue, key: PromiseOrValue[], + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "deleteRecord(bytes16,bytes16,bytes32[])"( + "deleteRecord(bytes16,bytes16,bytes32[],bytes32)"( namespace: PromiseOrValue, name: PromiseOrValue, key: PromiseOrValue[], + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "emitEphemeralRecord(bytes16,bytes16,bytes32[],bytes)"( + "emitEphemeralRecord(bytes16,bytes16,bytes32[],bytes,bytes32)"( namespace: PromiseOrValue, name: PromiseOrValue, key: PromiseOrValue[], data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "emitEphemeralRecord(bytes32,bytes32[],bytes)"( + "emitEphemeralRecord(bytes32,bytes32[],bytes,bytes32)"( table: PromiseOrValue, key: PromiseOrValue[], data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -1992,6 +2037,7 @@ export interface IWorld extends BaseContract { table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; @@ -1999,7 +2045,7 @@ export interface IWorld extends BaseContract { table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, - schema: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; @@ -2007,7 +2053,7 @@ export interface IWorld extends BaseContract { table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, - schema: PromiseOrValue, + valueSchema: PromiseOrValue, start: PromiseOrValue, end: PromiseOrValue, overrides?: CallOverrides @@ -2018,16 +2064,10 @@ export interface IWorld extends BaseContract { overrides?: CallOverrides ): Promise; - "getRecord(bytes32,bytes32[],bytes32)"( - table: PromiseOrValue, - key: PromiseOrValue[], - schema: PromiseOrValue, - overrides?: CallOverrides - ): Promise; - - "getRecord(bytes32,bytes32[])"( + getRecord( table: PromiseOrValue, key: PromiseOrValue[], + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; @@ -2059,20 +2099,22 @@ export interface IWorld extends BaseContract { overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "popFromField(bytes16,bytes16,bytes32[],uint8,uint256)"( - namespace: PromiseOrValue, - name: PromiseOrValue, + "popFromField(bytes32,bytes32[],uint8,uint256,bytes32)"( + table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, byteLengthToPop: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "popFromField(bytes32,bytes32[],uint8,uint256)"( - table: PromiseOrValue, + "popFromField(bytes16,bytes16,bytes32[],uint8,uint256,bytes32)"( + namespace: PromiseOrValue, + name: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, byteLengthToPop: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -2087,20 +2129,22 @@ export interface IWorld extends BaseContract { overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "pushToField(bytes32,bytes32[],uint8,bytes)"( + "pushToField(bytes32,bytes32[],uint8,bytes,bytes32)"( table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, dataToPush: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "pushToField(bytes16,bytes16,bytes32[],uint8,bytes)"( + "pushToField(bytes16,bytes16,bytes32[],uint8,bytes,bytes32)"( namespace: PromiseOrValue, name: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, dataToPush: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -2187,20 +2231,22 @@ export interface IWorld extends BaseContract { overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "setField(bytes32,bytes32[],uint8,bytes)"( - table: PromiseOrValue, + "setField(bytes16,bytes16,bytes32[],uint8,bytes,bytes32)"( + namespace: PromiseOrValue, + name: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "setField(bytes16,bytes16,bytes32[],uint8,bytes)"( - namespace: PromiseOrValue, - name: PromiseOrValue, + "setField(bytes32,bytes32[],uint8,bytes,bytes32)"( + table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -2219,18 +2265,20 @@ export interface IWorld extends BaseContract { overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "setRecord(bytes16,bytes16,bytes32[],bytes)"( - namespace: PromiseOrValue, - name: PromiseOrValue, + "setRecord(bytes32,bytes32[],bytes,bytes32)"( + table: PromiseOrValue, key: PromiseOrValue[], data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "setRecord(bytes32,bytes32[],bytes)"( - table: PromiseOrValue, + "setRecord(bytes16,bytes16,bytes32[],bytes,bytes32)"( + namespace: PromiseOrValue, + name: PromiseOrValue, key: PromiseOrValue[], data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -2239,22 +2287,24 @@ export interface IWorld extends BaseContract { overrides?: CallOverrides ): Promise; - "updateInField(bytes32,bytes32[],uint8,uint256,bytes)"( + "updateInField(bytes32,bytes32[],uint8,uint256,bytes,bytes32)"( table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, startByteIndex: PromiseOrValue, dataToSet: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "updateInField(bytes16,bytes16,bytes32[],uint8,uint256,bytes)"( + "updateInField(bytes16,bytes16,bytes32[],uint8,uint256,bytes,bytes32)"( namespace: PromiseOrValue, name: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, startByteIndex: PromiseOrValue, dataToSet: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; }; diff --git a/e2e/packages/contracts/types/ethers-contracts/factories/IWorld__factory.ts b/e2e/packages/contracts/types/ethers-contracts/factories/IWorld__factory.ts index 5caa2d7df6..8909650ca8 100644 --- a/e2e/packages/contracts/types/ethers-contracts/factories/IWorld__factory.ts +++ b/e2e/packages/contracts/types/ethers-contracts/factories/IWorld__factory.ts @@ -380,6 +380,11 @@ const _abi = [ name: "key", type: "bytes32[]", }, + { + internalType: "Schema", + name: "valueSchema", + type: "bytes32", + }, ], name: "deleteRecord", outputs: [], @@ -403,6 +408,11 @@ const _abi = [ name: "key", type: "bytes32[]", }, + { + internalType: "Schema", + name: "valueSchema", + type: "bytes32", + }, ], name: "deleteRecord", outputs: [], @@ -431,6 +441,11 @@ const _abi = [ name: "data", type: "bytes", }, + { + internalType: "Schema", + name: "valueSchema", + type: "bytes32", + }, ], name: "emitEphemeralRecord", outputs: [], @@ -454,6 +469,11 @@ const _abi = [ name: "data", type: "bytes", }, + { + internalType: "Schema", + name: "valueSchema", + type: "bytes32", + }, ], name: "emitEphemeralRecord", outputs: [], @@ -477,6 +497,11 @@ const _abi = [ name: "schemaIndex", type: "uint8", }, + { + internalType: "Schema", + name: "valueSchema", + type: "bytes32", + }, ], name: "getField", outputs: [ @@ -508,7 +533,7 @@ const _abi = [ }, { internalType: "Schema", - name: "schema", + name: "valueSchema", type: "bytes32", }, ], @@ -542,7 +567,7 @@ const _abi = [ }, { internalType: "Schema", - name: "schema", + name: "valueSchema", type: "bytes32", }, { @@ -600,33 +625,9 @@ const _abi = [ }, { internalType: "Schema", - name: "schema", - type: "bytes32", - }, - ], - name: "getRecord", - outputs: [ - { - internalType: "bytes", - name: "data", - type: "bytes", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { - internalType: "bytes32", - name: "table", + name: "valueSchema", type: "bytes32", }, - { - internalType: "bytes32[]", - name: "key", - type: "bytes32[]", - }, ], name: "getRecord", outputs: [ @@ -727,14 +728,9 @@ const _abi = [ { inputs: [ { - internalType: "bytes16", - name: "namespace", - type: "bytes16", - }, - { - internalType: "bytes16", - name: "name", - type: "bytes16", + internalType: "bytes32", + name: "table", + type: "bytes32", }, { internalType: "bytes32[]", @@ -751,6 +747,11 @@ const _abi = [ name: "byteLengthToPop", type: "uint256", }, + { + internalType: "Schema", + name: "valueSchema", + type: "bytes32", + }, ], name: "popFromField", outputs: [], @@ -760,9 +761,14 @@ const _abi = [ { inputs: [ { - internalType: "bytes32", - name: "table", - type: "bytes32", + internalType: "bytes16", + name: "namespace", + type: "bytes16", + }, + { + internalType: "bytes16", + name: "name", + type: "bytes16", }, { internalType: "bytes32[]", @@ -779,6 +785,11 @@ const _abi = [ name: "byteLengthToPop", type: "uint256", }, + { + internalType: "Schema", + name: "valueSchema", + type: "bytes32", + }, ], name: "popFromField", outputs: [], @@ -838,6 +849,11 @@ const _abi = [ name: "dataToPush", type: "bytes", }, + { + internalType: "Schema", + name: "valueSchema", + type: "bytes32", + }, ], name: "pushToField", outputs: [], @@ -871,6 +887,11 @@ const _abi = [ name: "dataToPush", type: "bytes", }, + { + internalType: "Schema", + name: "valueSchema", + type: "bytes32", + }, ], name: "pushToField", outputs: [], @@ -1175,9 +1196,14 @@ const _abi = [ { inputs: [ { - internalType: "bytes32", - name: "table", - type: "bytes32", + internalType: "bytes16", + name: "namespace", + type: "bytes16", + }, + { + internalType: "bytes16", + name: "name", + type: "bytes16", }, { internalType: "bytes32[]", @@ -1194,6 +1220,11 @@ const _abi = [ name: "data", type: "bytes", }, + { + internalType: "Schema", + name: "valueSchema", + type: "bytes32", + }, ], name: "setField", outputs: [], @@ -1203,14 +1234,9 @@ const _abi = [ { inputs: [ { - internalType: "bytes16", - name: "namespace", - type: "bytes16", - }, - { - internalType: "bytes16", - name: "name", - type: "bytes16", + internalType: "bytes32", + name: "table", + type: "bytes32", }, { internalType: "bytes32[]", @@ -1227,6 +1253,11 @@ const _abi = [ name: "data", type: "bytes", }, + { + internalType: "Schema", + name: "valueSchema", + type: "bytes32", + }, ], name: "setField", outputs: [], @@ -1287,14 +1318,9 @@ const _abi = [ { inputs: [ { - internalType: "bytes16", - name: "namespace", - type: "bytes16", - }, - { - internalType: "bytes16", - name: "name", - type: "bytes16", + internalType: "bytes32", + name: "table", + type: "bytes32", }, { internalType: "bytes32[]", @@ -1306,6 +1332,11 @@ const _abi = [ name: "data", type: "bytes", }, + { + internalType: "Schema", + name: "valueSchema", + type: "bytes32", + }, ], name: "setRecord", outputs: [], @@ -1315,9 +1346,14 @@ const _abi = [ { inputs: [ { - internalType: "bytes32", - name: "table", - type: "bytes32", + internalType: "bytes16", + name: "namespace", + type: "bytes16", + }, + { + internalType: "bytes16", + name: "name", + type: "bytes16", }, { internalType: "bytes32[]", @@ -1329,6 +1365,11 @@ const _abi = [ name: "data", type: "bytes", }, + { + internalType: "Schema", + name: "valueSchema", + type: "bytes32", + }, ], name: "setRecord", outputs: [], @@ -1381,6 +1422,11 @@ const _abi = [ name: "dataToSet", type: "bytes", }, + { + internalType: "Schema", + name: "valueSchema", + type: "bytes32", + }, ], name: "updateInField", outputs: [], @@ -1419,6 +1465,11 @@ const _abi = [ name: "dataToSet", type: "bytes", }, + { + internalType: "Schema", + name: "valueSchema", + type: "bytes32", + }, ], name: "updateInField", outputs: [], diff --git a/e2e/packages/contracts/worlds.json b/e2e/packages/contracts/worlds.json index bd48105fd7..a9f5c67245 100644 --- a/e2e/packages/contracts/worlds.json +++ b/e2e/packages/contracts/worlds.json @@ -1,5 +1,5 @@ { "31337": { - "address": "0x5FbDB2315678afecb367f032d93F642f64180aa3" + "address": "0xA7c59f010700930003b33aB25a7a0679C860f29c" } } \ No newline at end of file diff --git a/e2e/packages/sync-test/data/encodeTestData.test.ts b/e2e/packages/sync-test/data/encodeTestData.test.ts index 90507dc466..df67bb56e2 100644 --- a/e2e/packages/sync-test/data/encodeTestData.test.ts +++ b/e2e/packages/sync-test/data/encodeTestData.test.ts @@ -4,12 +4,22 @@ import { encodeTestData } from "./encodeTestData"; describe("encodeTestData", () => { it("should encode numbers", () => { expect(encodeTestData({ Number: [{ key: { key: 42 }, value: { value: 1337 } }] })).toStrictEqual({ - Number: [{ key: ["0x000000000000000000000000000000000000000000000000000000000000002a"], value: "0x00000539" }], + Number: [ + { + key: ["0x000000000000000000000000000000000000000000000000000000000000002a"], + value: "0x00000539", + valueSchema: "0x0004010003000000000000000000000000000000000000000000000000000000", + }, + ], }); expect(encodeTestData({ Vector: [{ key: { key: 1337 }, value: { x: 42, y: -69 } }] })).toStrictEqual({ Vector: [ - { key: ["0x0000000000000000000000000000000000000000000000000000000000000539"], value: "0x0000002affffffbb" }, + { + key: ["0x0000000000000000000000000000000000000000000000000000000000000539"], + value: "0x0000002affffffbb", + valueSchema: "0x0008020023230000000000000000000000000000000000000000000000000000", + }, ], }); }); diff --git a/e2e/packages/sync-test/data/encodeTestData.ts b/e2e/packages/sync-test/data/encodeTestData.ts index 34dcaa072a..c0a6ab9dd5 100644 --- a/e2e/packages/sync-test/data/encodeTestData.ts +++ b/e2e/packages/sync-test/data/encodeTestData.ts @@ -2,19 +2,31 @@ import { mapObject } from "@latticexyz/utils"; import { Data, EncodedData } from "./types"; import { encodeAbiParameters, encodePacked } from "viem"; import config from "../../contracts/mud.config"; +import { abiTypesToSchema, schemaToHex } from "@latticexyz/protocol-parser"; +import { StaticAbiType } from "@latticexyz/schema-type"; /** * Turns the typed data into encoded data in the format expected by `world.setRecord` */ export function encodeTestData(testData: Data) { - return mapObject(testData, (records, table) => - records - ? records.map((record) => ({ - key: Object.entries(record.key).map(([keyName, keyValue]) => { - return encodeAbiParameters([{ type: config.tables[table].keySchema[keyName] }], [keyValue]); - }), - value: encodePacked(Object.values(config.tables[table].schema), Object.values(record.value)), - })) - : undefined - ) as EncodedData; + return mapObject(testData, (records, table) => { + if (!records) return undefined; + const keyConfig = config.tables[table].keySchema; + return records.map((record) => { + const encodedKey = Object.entries(record.key).map(([keyName, keyValue]) => { + const keyType = keyConfig[keyName as keyof typeof keyConfig] as StaticAbiType; + return encodeAbiParameters([{ type: keyType }], [keyValue]); + }); + + const encodedValue = encodePacked(Object.values(config.tables[table].schema), Object.values(record.value)); + + const encodedValueSchema = schemaToHex(abiTypesToSchema(Object.values(config.tables[table].schema))); + + return { + key: encodedKey, + value: encodedValue, + valueSchema: encodedValueSchema, + }; + }); + }) as EncodedData; } diff --git a/e2e/packages/sync-test/data/setContractData.ts b/e2e/packages/sync-test/data/setContractData.ts index fdf8c948af..160a7ae114 100644 --- a/e2e/packages/sync-test/data/setContractData.ts +++ b/e2e/packages/sync-test/data/setContractData.ts @@ -3,7 +3,7 @@ import { Data } from "./types"; import { encodeTestData } from "./encodeTestData"; import { callWorld } from "./callWorld"; import { stringToBytes16 } from "@latticexyz/utils"; -import { Hex, toHex } from "viem"; +import { toHex } from "viem"; /** * Writes contract data by calling `world.setRecord` via the client @@ -17,8 +17,9 @@ export async function setContractData(page: Page, data: Data) { // TODO: add support for multiple namespaces after https://github.com/latticexyz/mud/issues/994 is resolved toHex(stringToBytes16("")), toHex(stringToBytes16(table)), - record.key as Hex[], - record.value as Hex, + record.key, + record.value, + record.valueSchema, ]); // Wait for transactions to be confirmed diff --git a/e2e/packages/sync-test/data/types.ts b/e2e/packages/sync-test/data/types.ts index 1d2d802dc5..4ab5dab4ed 100644 --- a/e2e/packages/sync-test/data/types.ts +++ b/e2e/packages/sync-test/data/types.ts @@ -1,6 +1,7 @@ // Note: this expects the config to not use shortcuts but the full definitions for table schemas import { SchemaAbiType, SchemaAbiTypeToPrimitiveType } from "@latticexyz/schema-type"; import config from "../../contracts/mud.config"; +import { Hex } from "viem"; type SchemaToPrimitive = Schema extends Record ? { [key in keyof Schema]: SchemaAbiTypeToPrimitiveType } : never; @@ -19,5 +20,5 @@ export type Datum> }; export type EncodedData = { - [Table in keyof T]: Array<{ key: string[]; value: string }>; + [Table in keyof T]: Array<{ key: Hex[]; value: Hex; valueSchema: Hex }>; }; diff --git a/e2e/packages/sync-test/package.json b/e2e/packages/sync-test/package.json index 7963a954d2..4f06547347 100644 --- a/e2e/packages/sync-test/package.json +++ b/e2e/packages/sync-test/package.json @@ -8,6 +8,7 @@ }, "devDependencies": { "@latticexyz/cli": "link:../../../packages/cli", + "@latticexyz/protocol-parser": "link:../../../packages/protocol-parser", "@latticexyz/recs": "link:../../../packages/recs", "@latticexyz/schema-type": "link:../../../packages/schema-type", "@latticexyz/store": "link:../../../packages/store", diff --git a/e2e/pnpm-lock.yaml b/e2e/pnpm-lock.yaml index 85f696816b..4d413dc374 100644 --- a/e2e/pnpm-lock.yaml +++ b/e2e/pnpm-lock.yaml @@ -144,6 +144,9 @@ importers: '@latticexyz/cli': specifier: link:../../../packages/cli version: link:../../../packages/cli + '@latticexyz/protocol-parser': + specifier: link:../../../packages/protocol-parser + version: link:../../../packages/protocol-parser '@latticexyz/recs': specifier: link:../../../packages/recs version: link:../../../packages/recs @@ -1313,6 +1316,7 @@ packages: /esm@3.2.25: resolution: {integrity: sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA==} engines: {node: '>=6'} + requiresBuild: true dev: false optional: true diff --git a/examples/minimal/packages/contracts/src/codegen/tables/CounterTable.sol b/examples/minimal/packages/contracts/src/codegen/tables/CounterTable.sol index cc6c9f935d..e769476b8d 100644 --- a/examples/minimal/packages/contracts/src/codegen/tables/CounterTable.sol +++ b/examples/minimal/packages/contracts/src/codegen/tables/CounterTable.sol @@ -68,7 +68,7 @@ library CounterTable { function get() internal view returns (uint32 value) { bytes32[] memory _keyTuple = new bytes32[](0); - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0, getSchema()); return (uint32(Bytes.slice4(_blob, 0))); } @@ -76,7 +76,7 @@ library CounterTable { function get(IStore _store) internal view returns (uint32 value) { bytes32[] memory _keyTuple = new bytes32[](0); - bytes memory _blob = _store.getField(_tableId, _keyTuple, 0); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 0, getSchema()); return (uint32(Bytes.slice4(_blob, 0))); } @@ -84,14 +84,14 @@ library CounterTable { function set(uint32 value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((value))); + StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), getSchema()); } /** Set value (using the specified store) */ function set(IStore _store, uint32 value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((value))); + _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), getSchema()); } /** Tightly pack full data using this table's schema */ @@ -110,13 +110,13 @@ library CounterTable { function deleteRecord() internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.deleteRecord(_tableId, _keyTuple); + StoreSwitch.deleteRecord(_tableId, _keyTuple, getSchema()); } /* Delete all data for given keys (using the specified store) */ function deleteRecord(IStore _store) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.deleteRecord(_tableId, _keyTuple); + _store.deleteRecord(_tableId, _keyTuple, getSchema()); } } diff --git a/examples/minimal/packages/contracts/src/codegen/tables/Inventory.sol b/examples/minimal/packages/contracts/src/codegen/tables/Inventory.sol index 312dd5508c..bf0398ea04 100644 --- a/examples/minimal/packages/contracts/src/codegen/tables/Inventory.sol +++ b/examples/minimal/packages/contracts/src/codegen/tables/Inventory.sol @@ -74,7 +74,7 @@ library Inventory { _keyTuple[1] = bytes32(uint256(item)); _keyTuple[2] = bytes32(uint256(itemVariant)); - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0, getSchema()); return (uint32(Bytes.slice4(_blob, 0))); } @@ -85,7 +85,7 @@ library Inventory { _keyTuple[1] = bytes32(uint256(item)); _keyTuple[2] = bytes32(uint256(itemVariant)); - bytes memory _blob = _store.getField(_tableId, _keyTuple, 0); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 0, getSchema()); return (uint32(Bytes.slice4(_blob, 0))); } @@ -96,7 +96,7 @@ library Inventory { _keyTuple[1] = bytes32(uint256(item)); _keyTuple[2] = bytes32(uint256(itemVariant)); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((amount))); + StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((amount)), getSchema()); } /** Set amount (using the specified store) */ @@ -106,7 +106,7 @@ library Inventory { _keyTuple[1] = bytes32(uint256(item)); _keyTuple[2] = bytes32(uint256(itemVariant)); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((amount))); + _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((amount)), getSchema()); } /** Tightly pack full data using this table's schema */ @@ -131,7 +131,7 @@ library Inventory { _keyTuple[1] = bytes32(uint256(item)); _keyTuple[2] = bytes32(uint256(itemVariant)); - StoreSwitch.deleteRecord(_tableId, _keyTuple); + StoreSwitch.deleteRecord(_tableId, _keyTuple, getSchema()); } /* Delete all data for given keys (using the specified store) */ @@ -141,6 +141,6 @@ library Inventory { _keyTuple[1] = bytes32(uint256(item)); _keyTuple[2] = bytes32(uint256(itemVariant)); - _store.deleteRecord(_tableId, _keyTuple); + _store.deleteRecord(_tableId, _keyTuple, getSchema()); } } diff --git a/examples/minimal/packages/contracts/src/codegen/tables/MessageTable.sol b/examples/minimal/packages/contracts/src/codegen/tables/MessageTable.sol index 62bba2fbd1..701e58677b 100644 --- a/examples/minimal/packages/contracts/src/codegen/tables/MessageTable.sol +++ b/examples/minimal/packages/contracts/src/codegen/tables/MessageTable.sol @@ -70,7 +70,7 @@ library MessageTable { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.emitEphemeralRecord(_tableId, _keyTuple, _data); + StoreSwitch.emitEphemeralRecord(_tableId, _keyTuple, _data, getSchema()); } /** Emit the ephemeral event using individual values (using the specified store) */ @@ -79,7 +79,7 @@ library MessageTable { bytes32[] memory _keyTuple = new bytes32[](0); - _store.emitEphemeralRecord(_tableId, _keyTuple, _data); + _store.emitEphemeralRecord(_tableId, _keyTuple, _data, getSchema()); } /** Tightly pack full data using this table's schema */ diff --git a/examples/minimal/packages/contracts/types/ethers-contracts/IWorld.ts b/examples/minimal/packages/contracts/types/ethers-contracts/IWorld.ts index a78373b57d..75d740e54c 100644 --- a/examples/minimal/packages/contracts/types/ethers-contracts/IWorld.ts +++ b/examples/minimal/packages/contracts/types/ethers-contracts/IWorld.ts @@ -39,28 +39,27 @@ export type StringStructStructOutput = [string] & { value: string }; export interface IWorldInterface extends utils.Interface { functions: { "call(bytes16,bytes16,bytes)": FunctionFragment; - "deleteRecord(bytes32,bytes32[])": FunctionFragment; - "deleteRecord(bytes16,bytes16,bytes32[])": FunctionFragment; + "deleteRecord(bytes32,bytes32[],bytes32)": FunctionFragment; + "deleteRecord(bytes16,bytes16,bytes32[],bytes32)": FunctionFragment; "dynamicArrayBytesStruct((bytes)[])": FunctionFragment; "dynamicArrayStringStruct((string)[])": FunctionFragment; - "emitEphemeralRecord(bytes16,bytes16,bytes32[],bytes)": FunctionFragment; - "emitEphemeralRecord(bytes32,bytes32[],bytes)": FunctionFragment; - "getField(bytes32,bytes32[],uint8)": FunctionFragment; + "emitEphemeralRecord(bytes16,bytes16,bytes32[],bytes,bytes32)": FunctionFragment; + "emitEphemeralRecord(bytes32,bytes32[],bytes,bytes32)": FunctionFragment; + "getField(bytes32,bytes32[],uint8,bytes32)": FunctionFragment; "getFieldLength(bytes32,bytes32[],uint8,bytes32)": FunctionFragment; "getFieldSlice(bytes32,bytes32[],uint8,bytes32,uint256,uint256)": FunctionFragment; "getKeySchema(bytes32)": FunctionFragment; "getRecord(bytes32,bytes32[],bytes32)": FunctionFragment; - "getRecord(bytes32,bytes32[])": FunctionFragment; "getSchema(bytes32)": FunctionFragment; "grantAccess(bytes16,bytes16,address)": FunctionFragment; "increment()": FunctionFragment; "installModule(address,bytes)": FunctionFragment; "installRootModule(address,bytes)": FunctionFragment; "pickUp(uint32,uint32)": FunctionFragment; - "popFromField(bytes16,bytes16,bytes32[],uint8,uint256)": FunctionFragment; - "popFromField(bytes32,bytes32[],uint8,uint256)": FunctionFragment; - "pushToField(bytes32,bytes32[],uint8,bytes)": FunctionFragment; - "pushToField(bytes16,bytes16,bytes32[],uint8,bytes)": FunctionFragment; + "popFromField(bytes32,bytes32[],uint8,uint256,bytes32)": FunctionFragment; + "popFromField(bytes16,bytes16,bytes32[],uint8,uint256,bytes32)": FunctionFragment; + "pushToField(bytes32,bytes32[],uint8,bytes,bytes32)": FunctionFragment; + "pushToField(bytes16,bytes16,bytes32[],uint8,bytes,bytes32)": FunctionFragment; "registerFunctionSelector(bytes16,bytes16,string,string)": FunctionFragment; "registerHook(bytes16,bytes16,address)": FunctionFragment; "registerNamespace(bytes16)": FunctionFragment; @@ -73,44 +72,43 @@ export interface IWorldInterface extends utils.Interface { "registerTableHook(bytes16,bytes16,address)": FunctionFragment; "revokeAccess(bytes16,bytes16,address)": FunctionFragment; "sendMessage(string)": FunctionFragment; - "setField(bytes32,bytes32[],uint8,bytes)": FunctionFragment; - "setField(bytes16,bytes16,bytes32[],uint8,bytes)": FunctionFragment; + "setField(bytes16,bytes16,bytes32[],uint8,bytes,bytes32)": FunctionFragment; + "setField(bytes32,bytes32[],uint8,bytes,bytes32)": FunctionFragment; "setMetadata(bytes16,bytes16,string,string[])": FunctionFragment; "setMetadata(bytes32,string,string[])": FunctionFragment; - "setRecord(bytes16,bytes16,bytes32[],bytes)": FunctionFragment; - "setRecord(bytes32,bytes32[],bytes)": FunctionFragment; + "setRecord(bytes32,bytes32[],bytes,bytes32)": FunctionFragment; + "setRecord(bytes16,bytes16,bytes32[],bytes,bytes32)": FunctionFragment; "staticArrayBytesStruct(tuple[1])": FunctionFragment; "staticArrayStringStruct(tuple[1])": FunctionFragment; - "updateInField(bytes32,bytes32[],uint8,uint256,bytes)": FunctionFragment; - "updateInField(bytes16,bytes16,bytes32[],uint8,uint256,bytes)": FunctionFragment; + "updateInField(bytes32,bytes32[],uint8,uint256,bytes,bytes32)": FunctionFragment; + "updateInField(bytes16,bytes16,bytes32[],uint8,uint256,bytes,bytes32)": FunctionFragment; "willRevert()": FunctionFragment; }; getFunction( nameOrSignatureOrTopic: | "call" - | "deleteRecord(bytes32,bytes32[])" - | "deleteRecord(bytes16,bytes16,bytes32[])" + | "deleteRecord(bytes32,bytes32[],bytes32)" + | "deleteRecord(bytes16,bytes16,bytes32[],bytes32)" | "dynamicArrayBytesStruct" | "dynamicArrayStringStruct" - | "emitEphemeralRecord(bytes16,bytes16,bytes32[],bytes)" - | "emitEphemeralRecord(bytes32,bytes32[],bytes)" + | "emitEphemeralRecord(bytes16,bytes16,bytes32[],bytes,bytes32)" + | "emitEphemeralRecord(bytes32,bytes32[],bytes,bytes32)" | "getField" | "getFieldLength" | "getFieldSlice" | "getKeySchema" - | "getRecord(bytes32,bytes32[],bytes32)" - | "getRecord(bytes32,bytes32[])" + | "getRecord" | "getSchema" | "grantAccess" | "increment" | "installModule" | "installRootModule" | "pickUp" - | "popFromField(bytes16,bytes16,bytes32[],uint8,uint256)" - | "popFromField(bytes32,bytes32[],uint8,uint256)" - | "pushToField(bytes32,bytes32[],uint8,bytes)" - | "pushToField(bytes16,bytes16,bytes32[],uint8,bytes)" + | "popFromField(bytes32,bytes32[],uint8,uint256,bytes32)" + | "popFromField(bytes16,bytes16,bytes32[],uint8,uint256,bytes32)" + | "pushToField(bytes32,bytes32[],uint8,bytes,bytes32)" + | "pushToField(bytes16,bytes16,bytes32[],uint8,bytes,bytes32)" | "registerFunctionSelector" | "registerHook" | "registerNamespace" @@ -123,16 +121,16 @@ export interface IWorldInterface extends utils.Interface { | "registerTableHook" | "revokeAccess" | "sendMessage" - | "setField(bytes32,bytes32[],uint8,bytes)" - | "setField(bytes16,bytes16,bytes32[],uint8,bytes)" + | "setField(bytes16,bytes16,bytes32[],uint8,bytes,bytes32)" + | "setField(bytes32,bytes32[],uint8,bytes,bytes32)" | "setMetadata(bytes16,bytes16,string,string[])" | "setMetadata(bytes32,string,string[])" - | "setRecord(bytes16,bytes16,bytes32[],bytes)" - | "setRecord(bytes32,bytes32[],bytes)" + | "setRecord(bytes32,bytes32[],bytes,bytes32)" + | "setRecord(bytes16,bytes16,bytes32[],bytes,bytes32)" | "staticArrayBytesStruct" | "staticArrayStringStruct" - | "updateInField(bytes32,bytes32[],uint8,uint256,bytes)" - | "updateInField(bytes16,bytes16,bytes32[],uint8,uint256,bytes)" + | "updateInField(bytes32,bytes32[],uint8,uint256,bytes,bytes32)" + | "updateInField(bytes16,bytes16,bytes32[],uint8,uint256,bytes,bytes32)" | "willRevert" ): FunctionFragment; @@ -145,15 +143,20 @@ export interface IWorldInterface extends utils.Interface { ] ): string; encodeFunctionData( - functionFragment: "deleteRecord(bytes32,bytes32[])", - values: [PromiseOrValue, PromiseOrValue[]] + functionFragment: "deleteRecord(bytes32,bytes32[],bytes32)", + values: [ + PromiseOrValue, + PromiseOrValue[], + PromiseOrValue + ] ): string; encodeFunctionData( - functionFragment: "deleteRecord(bytes16,bytes16,bytes32[])", + functionFragment: "deleteRecord(bytes16,bytes16,bytes32[],bytes32)", values: [ PromiseOrValue, PromiseOrValue, - PromiseOrValue[] + PromiseOrValue[], + PromiseOrValue ] ): string; encodeFunctionData( @@ -165,19 +168,21 @@ export interface IWorldInterface extends utils.Interface { values: [StringStructStruct[]] ): string; encodeFunctionData( - functionFragment: "emitEphemeralRecord(bytes16,bytes16,bytes32[],bytes)", + functionFragment: "emitEphemeralRecord(bytes16,bytes16,bytes32[],bytes,bytes32)", values: [ PromiseOrValue, PromiseOrValue, PromiseOrValue[], + PromiseOrValue, PromiseOrValue ] ): string; encodeFunctionData( - functionFragment: "emitEphemeralRecord(bytes32,bytes32[],bytes)", + functionFragment: "emitEphemeralRecord(bytes32,bytes32[],bytes,bytes32)", values: [ PromiseOrValue, PromiseOrValue[], + PromiseOrValue, PromiseOrValue ] ): string; @@ -186,7 +191,8 @@ export interface IWorldInterface extends utils.Interface { values: [ PromiseOrValue, PromiseOrValue[], - PromiseOrValue + PromiseOrValue, + PromiseOrValue ] ): string; encodeFunctionData( @@ -214,17 +220,13 @@ export interface IWorldInterface extends utils.Interface { values: [PromiseOrValue] ): string; encodeFunctionData( - functionFragment: "getRecord(bytes32,bytes32[],bytes32)", + functionFragment: "getRecord", values: [ PromiseOrValue, PromiseOrValue[], PromiseOrValue ] ): string; - encodeFunctionData( - functionFragment: "getRecord(bytes32,bytes32[])", - values: [PromiseOrValue, PromiseOrValue[]] - ): string; encodeFunctionData( functionFragment: "getSchema", values: [PromiseOrValue] @@ -251,40 +253,44 @@ export interface IWorldInterface extends utils.Interface { values: [PromiseOrValue, PromiseOrValue] ): string; encodeFunctionData( - functionFragment: "popFromField(bytes16,bytes16,bytes32[],uint8,uint256)", + functionFragment: "popFromField(bytes32,bytes32[],uint8,uint256,bytes32)", values: [ - PromiseOrValue, PromiseOrValue, PromiseOrValue[], PromiseOrValue, - PromiseOrValue + PromiseOrValue, + PromiseOrValue ] ): string; encodeFunctionData( - functionFragment: "popFromField(bytes32,bytes32[],uint8,uint256)", + functionFragment: "popFromField(bytes16,bytes16,bytes32[],uint8,uint256,bytes32)", values: [ + PromiseOrValue, PromiseOrValue, PromiseOrValue[], PromiseOrValue, - PromiseOrValue + PromiseOrValue, + PromiseOrValue ] ): string; encodeFunctionData( - functionFragment: "pushToField(bytes32,bytes32[],uint8,bytes)", + functionFragment: "pushToField(bytes32,bytes32[],uint8,bytes,bytes32)", values: [ PromiseOrValue, PromiseOrValue[], PromiseOrValue, + PromiseOrValue, PromiseOrValue ] ): string; encodeFunctionData( - functionFragment: "pushToField(bytes16,bytes16,bytes32[],uint8,bytes)", + functionFragment: "pushToField(bytes16,bytes16,bytes32[],uint8,bytes,bytes32)", values: [ PromiseOrValue, PromiseOrValue, PromiseOrValue[], PromiseOrValue, + PromiseOrValue, PromiseOrValue ] ): string; @@ -377,21 +383,23 @@ export interface IWorldInterface extends utils.Interface { values: [PromiseOrValue] ): string; encodeFunctionData( - functionFragment: "setField(bytes32,bytes32[],uint8,bytes)", + functionFragment: "setField(bytes16,bytes16,bytes32[],uint8,bytes,bytes32)", values: [ + PromiseOrValue, PromiseOrValue, PromiseOrValue[], PromiseOrValue, + PromiseOrValue, PromiseOrValue ] ): string; encodeFunctionData( - functionFragment: "setField(bytes16,bytes16,bytes32[],uint8,bytes)", + functionFragment: "setField(bytes32,bytes32[],uint8,bytes,bytes32)", values: [ - PromiseOrValue, PromiseOrValue, PromiseOrValue[], PromiseOrValue, + PromiseOrValue, PromiseOrValue ] ): string; @@ -413,19 +421,21 @@ export interface IWorldInterface extends utils.Interface { ] ): string; encodeFunctionData( - functionFragment: "setRecord(bytes16,bytes16,bytes32[],bytes)", + functionFragment: "setRecord(bytes32,bytes32[],bytes,bytes32)", values: [ - PromiseOrValue, PromiseOrValue, PromiseOrValue[], + PromiseOrValue, PromiseOrValue ] ): string; encodeFunctionData( - functionFragment: "setRecord(bytes32,bytes32[],bytes)", + functionFragment: "setRecord(bytes16,bytes16,bytes32[],bytes,bytes32)", values: [ + PromiseOrValue, PromiseOrValue, PromiseOrValue[], + PromiseOrValue, PromiseOrValue ] ): string; @@ -438,23 +448,25 @@ export interface IWorldInterface extends utils.Interface { values: [[StringStructStruct]] ): string; encodeFunctionData( - functionFragment: "updateInField(bytes32,bytes32[],uint8,uint256,bytes)", + functionFragment: "updateInField(bytes32,bytes32[],uint8,uint256,bytes,bytes32)", values: [ PromiseOrValue, PromiseOrValue[], PromiseOrValue, PromiseOrValue, + PromiseOrValue, PromiseOrValue ] ): string; encodeFunctionData( - functionFragment: "updateInField(bytes16,bytes16,bytes32[],uint8,uint256,bytes)", + functionFragment: "updateInField(bytes16,bytes16,bytes32[],uint8,uint256,bytes,bytes32)", values: [ PromiseOrValue, PromiseOrValue, PromiseOrValue[], PromiseOrValue, PromiseOrValue, + PromiseOrValue, PromiseOrValue ] ): string; @@ -465,11 +477,11 @@ export interface IWorldInterface extends utils.Interface { decodeFunctionResult(functionFragment: "call", data: BytesLike): Result; decodeFunctionResult( - functionFragment: "deleteRecord(bytes32,bytes32[])", + functionFragment: "deleteRecord(bytes32,bytes32[],bytes32)", data: BytesLike ): Result; decodeFunctionResult( - functionFragment: "deleteRecord(bytes16,bytes16,bytes32[])", + functionFragment: "deleteRecord(bytes16,bytes16,bytes32[],bytes32)", data: BytesLike ): Result; decodeFunctionResult( @@ -481,11 +493,11 @@ export interface IWorldInterface extends utils.Interface { data: BytesLike ): Result; decodeFunctionResult( - functionFragment: "emitEphemeralRecord(bytes16,bytes16,bytes32[],bytes)", + functionFragment: "emitEphemeralRecord(bytes16,bytes16,bytes32[],bytes,bytes32)", data: BytesLike ): Result; decodeFunctionResult( - functionFragment: "emitEphemeralRecord(bytes32,bytes32[],bytes)", + functionFragment: "emitEphemeralRecord(bytes32,bytes32[],bytes,bytes32)", data: BytesLike ): Result; decodeFunctionResult(functionFragment: "getField", data: BytesLike): Result; @@ -501,14 +513,7 @@ export interface IWorldInterface extends utils.Interface { functionFragment: "getKeySchema", data: BytesLike ): Result; - decodeFunctionResult( - functionFragment: "getRecord(bytes32,bytes32[],bytes32)", - data: BytesLike - ): Result; - decodeFunctionResult( - functionFragment: "getRecord(bytes32,bytes32[])", - data: BytesLike - ): Result; + decodeFunctionResult(functionFragment: "getRecord", data: BytesLike): Result; decodeFunctionResult(functionFragment: "getSchema", data: BytesLike): Result; decodeFunctionResult( functionFragment: "grantAccess", @@ -525,19 +530,19 @@ export interface IWorldInterface extends utils.Interface { ): Result; decodeFunctionResult(functionFragment: "pickUp", data: BytesLike): Result; decodeFunctionResult( - functionFragment: "popFromField(bytes16,bytes16,bytes32[],uint8,uint256)", + functionFragment: "popFromField(bytes32,bytes32[],uint8,uint256,bytes32)", data: BytesLike ): Result; decodeFunctionResult( - functionFragment: "popFromField(bytes32,bytes32[],uint8,uint256)", + functionFragment: "popFromField(bytes16,bytes16,bytes32[],uint8,uint256,bytes32)", data: BytesLike ): Result; decodeFunctionResult( - functionFragment: "pushToField(bytes32,bytes32[],uint8,bytes)", + functionFragment: "pushToField(bytes32,bytes32[],uint8,bytes,bytes32)", data: BytesLike ): Result; decodeFunctionResult( - functionFragment: "pushToField(bytes16,bytes16,bytes32[],uint8,bytes)", + functionFragment: "pushToField(bytes16,bytes16,bytes32[],uint8,bytes,bytes32)", data: BytesLike ): Result; decodeFunctionResult( @@ -589,11 +594,11 @@ export interface IWorldInterface extends utils.Interface { data: BytesLike ): Result; decodeFunctionResult( - functionFragment: "setField(bytes32,bytes32[],uint8,bytes)", + functionFragment: "setField(bytes16,bytes16,bytes32[],uint8,bytes,bytes32)", data: BytesLike ): Result; decodeFunctionResult( - functionFragment: "setField(bytes16,bytes16,bytes32[],uint8,bytes)", + functionFragment: "setField(bytes32,bytes32[],uint8,bytes,bytes32)", data: BytesLike ): Result; decodeFunctionResult( @@ -605,11 +610,11 @@ export interface IWorldInterface extends utils.Interface { data: BytesLike ): Result; decodeFunctionResult( - functionFragment: "setRecord(bytes16,bytes16,bytes32[],bytes)", + functionFragment: "setRecord(bytes32,bytes32[],bytes,bytes32)", data: BytesLike ): Result; decodeFunctionResult( - functionFragment: "setRecord(bytes32,bytes32[],bytes)", + functionFragment: "setRecord(bytes16,bytes16,bytes32[],bytes,bytes32)", data: BytesLike ): Result; decodeFunctionResult( @@ -621,11 +626,11 @@ export interface IWorldInterface extends utils.Interface { data: BytesLike ): Result; decodeFunctionResult( - functionFragment: "updateInField(bytes32,bytes32[],uint8,uint256,bytes)", + functionFragment: "updateInField(bytes32,bytes32[],uint8,uint256,bytes,bytes32)", data: BytesLike ): Result; decodeFunctionResult( - functionFragment: "updateInField(bytes16,bytes16,bytes32[],uint8,uint256,bytes)", + functionFragment: "updateInField(bytes16,bytes16,bytes32[],uint8,uint256,bytes,bytes32)", data: BytesLike ): Result; decodeFunctionResult(functionFragment: "willRevert", data: BytesLike): Result; @@ -734,16 +739,18 @@ export interface IWorld extends BaseContract { overrides?: PayableOverrides & { from?: PromiseOrValue } ): Promise; - "deleteRecord(bytes32,bytes32[])"( + "deleteRecord(bytes32,bytes32[],bytes32)"( table: PromiseOrValue, key: PromiseOrValue[], + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "deleteRecord(bytes16,bytes16,bytes32[])"( + "deleteRecord(bytes16,bytes16,bytes32[],bytes32)"( namespace: PromiseOrValue, name: PromiseOrValue, key: PromiseOrValue[], + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -757,18 +764,20 @@ export interface IWorld extends BaseContract { overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "emitEphemeralRecord(bytes16,bytes16,bytes32[],bytes)"( + "emitEphemeralRecord(bytes16,bytes16,bytes32[],bytes,bytes32)"( namespace: PromiseOrValue, name: PromiseOrValue, key: PromiseOrValue[], data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "emitEphemeralRecord(bytes32,bytes32[],bytes)"( + "emitEphemeralRecord(bytes32,bytes32[],bytes,bytes32)"( table: PromiseOrValue, key: PromiseOrValue[], data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -776,6 +785,7 @@ export interface IWorld extends BaseContract { table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise<[string] & { data: string }>; @@ -783,7 +793,7 @@ export interface IWorld extends BaseContract { table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, - schema: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise<[BigNumber]>; @@ -791,7 +801,7 @@ export interface IWorld extends BaseContract { table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, - schema: PromiseOrValue, + valueSchema: PromiseOrValue, start: PromiseOrValue, end: PromiseOrValue, overrides?: CallOverrides @@ -802,16 +812,10 @@ export interface IWorld extends BaseContract { overrides?: CallOverrides ): Promise<[string] & { schema: string }>; - "getRecord(bytes32,bytes32[],bytes32)"( - table: PromiseOrValue, - key: PromiseOrValue[], - schema: PromiseOrValue, - overrides?: CallOverrides - ): Promise<[string] & { data: string }>; - - "getRecord(bytes32,bytes32[])"( + getRecord( table: PromiseOrValue, key: PromiseOrValue[], + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise<[string] & { data: string }>; @@ -849,37 +853,41 @@ export interface IWorld extends BaseContract { overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "popFromField(bytes16,bytes16,bytes32[],uint8,uint256)"( - namespace: PromiseOrValue, - name: PromiseOrValue, + "popFromField(bytes32,bytes32[],uint8,uint256,bytes32)"( + table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, byteLengthToPop: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "popFromField(bytes32,bytes32[],uint8,uint256)"( - table: PromiseOrValue, + "popFromField(bytes16,bytes16,bytes32[],uint8,uint256,bytes32)"( + namespace: PromiseOrValue, + name: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, byteLengthToPop: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "pushToField(bytes32,bytes32[],uint8,bytes)"( + "pushToField(bytes32,bytes32[],uint8,bytes,bytes32)"( table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, dataToPush: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "pushToField(bytes16,bytes16,bytes32[],uint8,bytes)"( + "pushToField(bytes16,bytes16,bytes32[],uint8,bytes,bytes32)"( namespace: PromiseOrValue, name: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, dataToPush: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -966,20 +974,22 @@ export interface IWorld extends BaseContract { overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "setField(bytes32,bytes32[],uint8,bytes)"( - table: PromiseOrValue, + "setField(bytes16,bytes16,bytes32[],uint8,bytes,bytes32)"( + namespace: PromiseOrValue, + name: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "setField(bytes16,bytes16,bytes32[],uint8,bytes)"( - namespace: PromiseOrValue, - name: PromiseOrValue, + "setField(bytes32,bytes32[],uint8,bytes,bytes32)"( + table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -998,18 +1008,20 @@ export interface IWorld extends BaseContract { overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "setRecord(bytes16,bytes16,bytes32[],bytes)"( - namespace: PromiseOrValue, - name: PromiseOrValue, + "setRecord(bytes32,bytes32[],bytes,bytes32)"( + table: PromiseOrValue, key: PromiseOrValue[], data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "setRecord(bytes32,bytes32[],bytes)"( - table: PromiseOrValue, + "setRecord(bytes16,bytes16,bytes32[],bytes,bytes32)"( + namespace: PromiseOrValue, + name: PromiseOrValue, key: PromiseOrValue[], data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -1023,22 +1035,24 @@ export interface IWorld extends BaseContract { overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "updateInField(bytes32,bytes32[],uint8,uint256,bytes)"( + "updateInField(bytes32,bytes32[],uint8,uint256,bytes,bytes32)"( table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, startByteIndex: PromiseOrValue, dataToSet: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "updateInField(bytes16,bytes16,bytes32[],uint8,uint256,bytes)"( + "updateInField(bytes16,bytes16,bytes32[],uint8,uint256,bytes,bytes32)"( namespace: PromiseOrValue, name: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, startByteIndex: PromiseOrValue, dataToSet: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -1054,16 +1068,18 @@ export interface IWorld extends BaseContract { overrides?: PayableOverrides & { from?: PromiseOrValue } ): Promise; - "deleteRecord(bytes32,bytes32[])"( + "deleteRecord(bytes32,bytes32[],bytes32)"( table: PromiseOrValue, key: PromiseOrValue[], + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "deleteRecord(bytes16,bytes16,bytes32[])"( + "deleteRecord(bytes16,bytes16,bytes32[],bytes32)"( namespace: PromiseOrValue, name: PromiseOrValue, key: PromiseOrValue[], + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -1077,18 +1093,20 @@ export interface IWorld extends BaseContract { overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "emitEphemeralRecord(bytes16,bytes16,bytes32[],bytes)"( + "emitEphemeralRecord(bytes16,bytes16,bytes32[],bytes,bytes32)"( namespace: PromiseOrValue, name: PromiseOrValue, key: PromiseOrValue[], data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "emitEphemeralRecord(bytes32,bytes32[],bytes)"( + "emitEphemeralRecord(bytes32,bytes32[],bytes,bytes32)"( table: PromiseOrValue, key: PromiseOrValue[], data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -1096,6 +1114,7 @@ export interface IWorld extends BaseContract { table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; @@ -1103,7 +1122,7 @@ export interface IWorld extends BaseContract { table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, - schema: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; @@ -1111,7 +1130,7 @@ export interface IWorld extends BaseContract { table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, - schema: PromiseOrValue, + valueSchema: PromiseOrValue, start: PromiseOrValue, end: PromiseOrValue, overrides?: CallOverrides @@ -1122,16 +1141,10 @@ export interface IWorld extends BaseContract { overrides?: CallOverrides ): Promise; - "getRecord(bytes32,bytes32[],bytes32)"( - table: PromiseOrValue, - key: PromiseOrValue[], - schema: PromiseOrValue, - overrides?: CallOverrides - ): Promise; - - "getRecord(bytes32,bytes32[])"( + getRecord( table: PromiseOrValue, key: PromiseOrValue[], + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; @@ -1169,37 +1182,41 @@ export interface IWorld extends BaseContract { overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "popFromField(bytes16,bytes16,bytes32[],uint8,uint256)"( - namespace: PromiseOrValue, - name: PromiseOrValue, + "popFromField(bytes32,bytes32[],uint8,uint256,bytes32)"( + table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, byteLengthToPop: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "popFromField(bytes32,bytes32[],uint8,uint256)"( - table: PromiseOrValue, + "popFromField(bytes16,bytes16,bytes32[],uint8,uint256,bytes32)"( + namespace: PromiseOrValue, + name: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, byteLengthToPop: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "pushToField(bytes32,bytes32[],uint8,bytes)"( + "pushToField(bytes32,bytes32[],uint8,bytes,bytes32)"( table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, dataToPush: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "pushToField(bytes16,bytes16,bytes32[],uint8,bytes)"( + "pushToField(bytes16,bytes16,bytes32[],uint8,bytes,bytes32)"( namespace: PromiseOrValue, name: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, dataToPush: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -1286,20 +1303,22 @@ export interface IWorld extends BaseContract { overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "setField(bytes32,bytes32[],uint8,bytes)"( - table: PromiseOrValue, + "setField(bytes16,bytes16,bytes32[],uint8,bytes,bytes32)"( + namespace: PromiseOrValue, + name: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "setField(bytes16,bytes16,bytes32[],uint8,bytes)"( - namespace: PromiseOrValue, - name: PromiseOrValue, + "setField(bytes32,bytes32[],uint8,bytes,bytes32)"( + table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -1318,18 +1337,20 @@ export interface IWorld extends BaseContract { overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "setRecord(bytes16,bytes16,bytes32[],bytes)"( - namespace: PromiseOrValue, - name: PromiseOrValue, + "setRecord(bytes32,bytes32[],bytes,bytes32)"( + table: PromiseOrValue, key: PromiseOrValue[], data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "setRecord(bytes32,bytes32[],bytes)"( - table: PromiseOrValue, + "setRecord(bytes16,bytes16,bytes32[],bytes,bytes32)"( + namespace: PromiseOrValue, + name: PromiseOrValue, key: PromiseOrValue[], data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -1343,22 +1364,24 @@ export interface IWorld extends BaseContract { overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "updateInField(bytes32,bytes32[],uint8,uint256,bytes)"( + "updateInField(bytes32,bytes32[],uint8,uint256,bytes,bytes32)"( table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, startByteIndex: PromiseOrValue, dataToSet: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "updateInField(bytes16,bytes16,bytes32[],uint8,uint256,bytes)"( + "updateInField(bytes16,bytes16,bytes32[],uint8,uint256,bytes,bytes32)"( namespace: PromiseOrValue, name: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, startByteIndex: PromiseOrValue, dataToSet: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -1374,16 +1397,18 @@ export interface IWorld extends BaseContract { overrides?: CallOverrides ): Promise; - "deleteRecord(bytes32,bytes32[])"( + "deleteRecord(bytes32,bytes32[],bytes32)"( table: PromiseOrValue, key: PromiseOrValue[], + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; - "deleteRecord(bytes16,bytes16,bytes32[])"( + "deleteRecord(bytes16,bytes16,bytes32[],bytes32)"( namespace: PromiseOrValue, name: PromiseOrValue, key: PromiseOrValue[], + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; @@ -1397,18 +1422,20 @@ export interface IWorld extends BaseContract { overrides?: CallOverrides ): Promise; - "emitEphemeralRecord(bytes16,bytes16,bytes32[],bytes)"( + "emitEphemeralRecord(bytes16,bytes16,bytes32[],bytes,bytes32)"( namespace: PromiseOrValue, name: PromiseOrValue, key: PromiseOrValue[], data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; - "emitEphemeralRecord(bytes32,bytes32[],bytes)"( + "emitEphemeralRecord(bytes32,bytes32[],bytes,bytes32)"( table: PromiseOrValue, key: PromiseOrValue[], data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; @@ -1416,6 +1443,7 @@ export interface IWorld extends BaseContract { table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; @@ -1423,7 +1451,7 @@ export interface IWorld extends BaseContract { table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, - schema: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; @@ -1431,7 +1459,7 @@ export interface IWorld extends BaseContract { table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, - schema: PromiseOrValue, + valueSchema: PromiseOrValue, start: PromiseOrValue, end: PromiseOrValue, overrides?: CallOverrides @@ -1442,16 +1470,10 @@ export interface IWorld extends BaseContract { overrides?: CallOverrides ): Promise; - "getRecord(bytes32,bytes32[],bytes32)"( - table: PromiseOrValue, - key: PromiseOrValue[], - schema: PromiseOrValue, - overrides?: CallOverrides - ): Promise; - - "getRecord(bytes32,bytes32[])"( + getRecord( table: PromiseOrValue, key: PromiseOrValue[], + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; @@ -1487,37 +1509,41 @@ export interface IWorld extends BaseContract { overrides?: CallOverrides ): Promise; - "popFromField(bytes16,bytes16,bytes32[],uint8,uint256)"( - namespace: PromiseOrValue, - name: PromiseOrValue, + "popFromField(bytes32,bytes32[],uint8,uint256,bytes32)"( + table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, byteLengthToPop: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; - "popFromField(bytes32,bytes32[],uint8,uint256)"( - table: PromiseOrValue, + "popFromField(bytes16,bytes16,bytes32[],uint8,uint256,bytes32)"( + namespace: PromiseOrValue, + name: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, byteLengthToPop: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; - "pushToField(bytes32,bytes32[],uint8,bytes)"( + "pushToField(bytes32,bytes32[],uint8,bytes,bytes32)"( table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, dataToPush: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; - "pushToField(bytes16,bytes16,bytes32[],uint8,bytes)"( + "pushToField(bytes16,bytes16,bytes32[],uint8,bytes,bytes32)"( namespace: PromiseOrValue, name: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, dataToPush: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; @@ -1604,20 +1630,22 @@ export interface IWorld extends BaseContract { overrides?: CallOverrides ): Promise; - "setField(bytes32,bytes32[],uint8,bytes)"( - table: PromiseOrValue, + "setField(bytes16,bytes16,bytes32[],uint8,bytes,bytes32)"( + namespace: PromiseOrValue, + name: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; - "setField(bytes16,bytes16,bytes32[],uint8,bytes)"( - namespace: PromiseOrValue, - name: PromiseOrValue, + "setField(bytes32,bytes32[],uint8,bytes,bytes32)"( + table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; @@ -1636,18 +1664,20 @@ export interface IWorld extends BaseContract { overrides?: CallOverrides ): Promise; - "setRecord(bytes16,bytes16,bytes32[],bytes)"( - namespace: PromiseOrValue, - name: PromiseOrValue, + "setRecord(bytes32,bytes32[],bytes,bytes32)"( + table: PromiseOrValue, key: PromiseOrValue[], data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; - "setRecord(bytes32,bytes32[],bytes)"( - table: PromiseOrValue, + "setRecord(bytes16,bytes16,bytes32[],bytes,bytes32)"( + namespace: PromiseOrValue, + name: PromiseOrValue, key: PromiseOrValue[], data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; @@ -1661,22 +1691,24 @@ export interface IWorld extends BaseContract { overrides?: CallOverrides ): Promise; - "updateInField(bytes32,bytes32[],uint8,uint256,bytes)"( + "updateInField(bytes32,bytes32[],uint8,uint256,bytes,bytes32)"( table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, startByteIndex: PromiseOrValue, dataToSet: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; - "updateInField(bytes16,bytes16,bytes32[],uint8,uint256,bytes)"( + "updateInField(bytes16,bytes16,bytes32[],uint8,uint256,bytes,bytes32)"( namespace: PromiseOrValue, name: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, startByteIndex: PromiseOrValue, dataToSet: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; @@ -1737,16 +1769,18 @@ export interface IWorld extends BaseContract { overrides?: PayableOverrides & { from?: PromiseOrValue } ): Promise; - "deleteRecord(bytes32,bytes32[])"( + "deleteRecord(bytes32,bytes32[],bytes32)"( table: PromiseOrValue, key: PromiseOrValue[], + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "deleteRecord(bytes16,bytes16,bytes32[])"( + "deleteRecord(bytes16,bytes16,bytes32[],bytes32)"( namespace: PromiseOrValue, name: PromiseOrValue, key: PromiseOrValue[], + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -1760,18 +1794,20 @@ export interface IWorld extends BaseContract { overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "emitEphemeralRecord(bytes16,bytes16,bytes32[],bytes)"( + "emitEphemeralRecord(bytes16,bytes16,bytes32[],bytes,bytes32)"( namespace: PromiseOrValue, name: PromiseOrValue, key: PromiseOrValue[], data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "emitEphemeralRecord(bytes32,bytes32[],bytes)"( + "emitEphemeralRecord(bytes32,bytes32[],bytes,bytes32)"( table: PromiseOrValue, key: PromiseOrValue[], data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -1779,6 +1815,7 @@ export interface IWorld extends BaseContract { table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; @@ -1786,7 +1823,7 @@ export interface IWorld extends BaseContract { table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, - schema: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; @@ -1794,7 +1831,7 @@ export interface IWorld extends BaseContract { table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, - schema: PromiseOrValue, + valueSchema: PromiseOrValue, start: PromiseOrValue, end: PromiseOrValue, overrides?: CallOverrides @@ -1805,16 +1842,10 @@ export interface IWorld extends BaseContract { overrides?: CallOverrides ): Promise; - "getRecord(bytes32,bytes32[],bytes32)"( - table: PromiseOrValue, - key: PromiseOrValue[], - schema: PromiseOrValue, - overrides?: CallOverrides - ): Promise; - - "getRecord(bytes32,bytes32[])"( + getRecord( table: PromiseOrValue, key: PromiseOrValue[], + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; @@ -1852,37 +1883,41 @@ export interface IWorld extends BaseContract { overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "popFromField(bytes16,bytes16,bytes32[],uint8,uint256)"( - namespace: PromiseOrValue, - name: PromiseOrValue, + "popFromField(bytes32,bytes32[],uint8,uint256,bytes32)"( + table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, byteLengthToPop: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "popFromField(bytes32,bytes32[],uint8,uint256)"( - table: PromiseOrValue, + "popFromField(bytes16,bytes16,bytes32[],uint8,uint256,bytes32)"( + namespace: PromiseOrValue, + name: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, byteLengthToPop: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "pushToField(bytes32,bytes32[],uint8,bytes)"( + "pushToField(bytes32,bytes32[],uint8,bytes,bytes32)"( table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, dataToPush: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "pushToField(bytes16,bytes16,bytes32[],uint8,bytes)"( + "pushToField(bytes16,bytes16,bytes32[],uint8,bytes,bytes32)"( namespace: PromiseOrValue, name: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, dataToPush: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -1969,20 +2004,22 @@ export interface IWorld extends BaseContract { overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "setField(bytes32,bytes32[],uint8,bytes)"( - table: PromiseOrValue, + "setField(bytes16,bytes16,bytes32[],uint8,bytes,bytes32)"( + namespace: PromiseOrValue, + name: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "setField(bytes16,bytes16,bytes32[],uint8,bytes)"( - namespace: PromiseOrValue, - name: PromiseOrValue, + "setField(bytes32,bytes32[],uint8,bytes,bytes32)"( + table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -2001,18 +2038,20 @@ export interface IWorld extends BaseContract { overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "setRecord(bytes16,bytes16,bytes32[],bytes)"( - namespace: PromiseOrValue, - name: PromiseOrValue, + "setRecord(bytes32,bytes32[],bytes,bytes32)"( + table: PromiseOrValue, key: PromiseOrValue[], data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "setRecord(bytes32,bytes32[],bytes)"( - table: PromiseOrValue, + "setRecord(bytes16,bytes16,bytes32[],bytes,bytes32)"( + namespace: PromiseOrValue, + name: PromiseOrValue, key: PromiseOrValue[], data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -2026,22 +2065,24 @@ export interface IWorld extends BaseContract { overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "updateInField(bytes32,bytes32[],uint8,uint256,bytes)"( + "updateInField(bytes32,bytes32[],uint8,uint256,bytes,bytes32)"( table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, startByteIndex: PromiseOrValue, dataToSet: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "updateInField(bytes16,bytes16,bytes32[],uint8,uint256,bytes)"( + "updateInField(bytes16,bytes16,bytes32[],uint8,uint256,bytes,bytes32)"( namespace: PromiseOrValue, name: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, startByteIndex: PromiseOrValue, dataToSet: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -2058,16 +2099,18 @@ export interface IWorld extends BaseContract { overrides?: PayableOverrides & { from?: PromiseOrValue } ): Promise; - "deleteRecord(bytes32,bytes32[])"( + "deleteRecord(bytes32,bytes32[],bytes32)"( table: PromiseOrValue, key: PromiseOrValue[], + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "deleteRecord(bytes16,bytes16,bytes32[])"( + "deleteRecord(bytes16,bytes16,bytes32[],bytes32)"( namespace: PromiseOrValue, name: PromiseOrValue, key: PromiseOrValue[], + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -2081,18 +2124,20 @@ export interface IWorld extends BaseContract { overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "emitEphemeralRecord(bytes16,bytes16,bytes32[],bytes)"( + "emitEphemeralRecord(bytes16,bytes16,bytes32[],bytes,bytes32)"( namespace: PromiseOrValue, name: PromiseOrValue, key: PromiseOrValue[], data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "emitEphemeralRecord(bytes32,bytes32[],bytes)"( + "emitEphemeralRecord(bytes32,bytes32[],bytes,bytes32)"( table: PromiseOrValue, key: PromiseOrValue[], data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -2100,6 +2145,7 @@ export interface IWorld extends BaseContract { table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; @@ -2107,7 +2153,7 @@ export interface IWorld extends BaseContract { table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, - schema: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; @@ -2115,7 +2161,7 @@ export interface IWorld extends BaseContract { table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, - schema: PromiseOrValue, + valueSchema: PromiseOrValue, start: PromiseOrValue, end: PromiseOrValue, overrides?: CallOverrides @@ -2126,16 +2172,10 @@ export interface IWorld extends BaseContract { overrides?: CallOverrides ): Promise; - "getRecord(bytes32,bytes32[],bytes32)"( - table: PromiseOrValue, - key: PromiseOrValue[], - schema: PromiseOrValue, - overrides?: CallOverrides - ): Promise; - - "getRecord(bytes32,bytes32[])"( + getRecord( table: PromiseOrValue, key: PromiseOrValue[], + valueSchema: PromiseOrValue, overrides?: CallOverrides ): Promise; @@ -2173,37 +2213,41 @@ export interface IWorld extends BaseContract { overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "popFromField(bytes16,bytes16,bytes32[],uint8,uint256)"( - namespace: PromiseOrValue, - name: PromiseOrValue, + "popFromField(bytes32,bytes32[],uint8,uint256,bytes32)"( + table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, byteLengthToPop: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "popFromField(bytes32,bytes32[],uint8,uint256)"( - table: PromiseOrValue, + "popFromField(bytes16,bytes16,bytes32[],uint8,uint256,bytes32)"( + namespace: PromiseOrValue, + name: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, byteLengthToPop: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "pushToField(bytes32,bytes32[],uint8,bytes)"( + "pushToField(bytes32,bytes32[],uint8,bytes,bytes32)"( table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, dataToPush: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "pushToField(bytes16,bytes16,bytes32[],uint8,bytes)"( + "pushToField(bytes16,bytes16,bytes32[],uint8,bytes,bytes32)"( namespace: PromiseOrValue, name: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, dataToPush: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -2290,20 +2334,22 @@ export interface IWorld extends BaseContract { overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "setField(bytes32,bytes32[],uint8,bytes)"( - table: PromiseOrValue, + "setField(bytes16,bytes16,bytes32[],uint8,bytes,bytes32)"( + namespace: PromiseOrValue, + name: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "setField(bytes16,bytes16,bytes32[],uint8,bytes)"( - namespace: PromiseOrValue, - name: PromiseOrValue, + "setField(bytes32,bytes32[],uint8,bytes,bytes32)"( + table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -2322,18 +2368,20 @@ export interface IWorld extends BaseContract { overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "setRecord(bytes16,bytes16,bytes32[],bytes)"( - namespace: PromiseOrValue, - name: PromiseOrValue, + "setRecord(bytes32,bytes32[],bytes,bytes32)"( + table: PromiseOrValue, key: PromiseOrValue[], data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "setRecord(bytes32,bytes32[],bytes)"( - table: PromiseOrValue, + "setRecord(bytes16,bytes16,bytes32[],bytes,bytes32)"( + namespace: PromiseOrValue, + name: PromiseOrValue, key: PromiseOrValue[], data: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; @@ -2347,22 +2395,24 @@ export interface IWorld extends BaseContract { overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "updateInField(bytes32,bytes32[],uint8,uint256,bytes)"( + "updateInField(bytes32,bytes32[],uint8,uint256,bytes,bytes32)"( table: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, startByteIndex: PromiseOrValue, dataToSet: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; - "updateInField(bytes16,bytes16,bytes32[],uint8,uint256,bytes)"( + "updateInField(bytes16,bytes16,bytes32[],uint8,uint256,bytes,bytes32)"( namespace: PromiseOrValue, name: PromiseOrValue, key: PromiseOrValue[], schemaIndex: PromiseOrValue, startByteIndex: PromiseOrValue, dataToSet: PromiseOrValue, + valueSchema: PromiseOrValue, overrides?: Overrides & { from?: PromiseOrValue } ): Promise; diff --git a/examples/minimal/packages/contracts/types/ethers-contracts/factories/IWorld__factory.ts b/examples/minimal/packages/contracts/types/ethers-contracts/factories/IWorld__factory.ts index 4edb824fcf..202cb11229 100644 --- a/examples/minimal/packages/contracts/types/ethers-contracts/factories/IWorld__factory.ts +++ b/examples/minimal/packages/contracts/types/ethers-contracts/factories/IWorld__factory.ts @@ -342,6 +342,11 @@ const _abi = [ name: "key", type: "bytes32[]", }, + { + internalType: "Schema", + name: "valueSchema", + type: "bytes32", + }, ], name: "deleteRecord", outputs: [], @@ -365,6 +370,11 @@ const _abi = [ name: "key", type: "bytes32[]", }, + { + internalType: "Schema", + name: "valueSchema", + type: "bytes32", + }, ], name: "deleteRecord", outputs: [], @@ -433,6 +443,11 @@ const _abi = [ name: "data", type: "bytes", }, + { + internalType: "Schema", + name: "valueSchema", + type: "bytes32", + }, ], name: "emitEphemeralRecord", outputs: [], @@ -456,6 +471,11 @@ const _abi = [ name: "data", type: "bytes", }, + { + internalType: "Schema", + name: "valueSchema", + type: "bytes32", + }, ], name: "emitEphemeralRecord", outputs: [], @@ -479,6 +499,11 @@ const _abi = [ name: "schemaIndex", type: "uint8", }, + { + internalType: "Schema", + name: "valueSchema", + type: "bytes32", + }, ], name: "getField", outputs: [ @@ -510,7 +535,7 @@ const _abi = [ }, { internalType: "Schema", - name: "schema", + name: "valueSchema", type: "bytes32", }, ], @@ -544,7 +569,7 @@ const _abi = [ }, { internalType: "Schema", - name: "schema", + name: "valueSchema", type: "bytes32", }, { @@ -602,33 +627,9 @@ const _abi = [ }, { internalType: "Schema", - name: "schema", - type: "bytes32", - }, - ], - name: "getRecord", - outputs: [ - { - internalType: "bytes", - name: "data", - type: "bytes", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { - internalType: "bytes32", - name: "table", + name: "valueSchema", type: "bytes32", }, - { - internalType: "bytes32[]", - name: "key", - type: "bytes32[]", - }, ], name: "getRecord", outputs: [ @@ -753,14 +754,9 @@ const _abi = [ { inputs: [ { - internalType: "bytes16", - name: "namespace", - type: "bytes16", - }, - { - internalType: "bytes16", - name: "name", - type: "bytes16", + internalType: "bytes32", + name: "table", + type: "bytes32", }, { internalType: "bytes32[]", @@ -777,6 +773,11 @@ const _abi = [ name: "byteLengthToPop", type: "uint256", }, + { + internalType: "Schema", + name: "valueSchema", + type: "bytes32", + }, ], name: "popFromField", outputs: [], @@ -786,9 +787,14 @@ const _abi = [ { inputs: [ { - internalType: "bytes32", - name: "table", - type: "bytes32", + internalType: "bytes16", + name: "namespace", + type: "bytes16", + }, + { + internalType: "bytes16", + name: "name", + type: "bytes16", }, { internalType: "bytes32[]", @@ -805,6 +811,11 @@ const _abi = [ name: "byteLengthToPop", type: "uint256", }, + { + internalType: "Schema", + name: "valueSchema", + type: "bytes32", + }, ], name: "popFromField", outputs: [], @@ -833,6 +844,11 @@ const _abi = [ name: "dataToPush", type: "bytes", }, + { + internalType: "Schema", + name: "valueSchema", + type: "bytes32", + }, ], name: "pushToField", outputs: [], @@ -866,6 +882,11 @@ const _abi = [ name: "dataToPush", type: "bytes", }, + { + internalType: "Schema", + name: "valueSchema", + type: "bytes32", + }, ], name: "pushToField", outputs: [], @@ -1170,9 +1191,14 @@ const _abi = [ { inputs: [ { - internalType: "bytes32", - name: "table", - type: "bytes32", + internalType: "bytes16", + name: "namespace", + type: "bytes16", + }, + { + internalType: "bytes16", + name: "name", + type: "bytes16", }, { internalType: "bytes32[]", @@ -1189,6 +1215,11 @@ const _abi = [ name: "data", type: "bytes", }, + { + internalType: "Schema", + name: "valueSchema", + type: "bytes32", + }, ], name: "setField", outputs: [], @@ -1198,14 +1229,9 @@ const _abi = [ { inputs: [ { - internalType: "bytes16", - name: "namespace", - type: "bytes16", - }, - { - internalType: "bytes16", - name: "name", - type: "bytes16", + internalType: "bytes32", + name: "table", + type: "bytes32", }, { internalType: "bytes32[]", @@ -1222,6 +1248,11 @@ const _abi = [ name: "data", type: "bytes", }, + { + internalType: "Schema", + name: "valueSchema", + type: "bytes32", + }, ], name: "setField", outputs: [], @@ -1282,14 +1313,9 @@ const _abi = [ { inputs: [ { - internalType: "bytes16", - name: "namespace", - type: "bytes16", - }, - { - internalType: "bytes16", - name: "name", - type: "bytes16", + internalType: "bytes32", + name: "table", + type: "bytes32", }, { internalType: "bytes32[]", @@ -1301,6 +1327,11 @@ const _abi = [ name: "data", type: "bytes", }, + { + internalType: "Schema", + name: "valueSchema", + type: "bytes32", + }, ], name: "setRecord", outputs: [], @@ -1310,9 +1341,14 @@ const _abi = [ { inputs: [ { - internalType: "bytes32", - name: "table", - type: "bytes32", + internalType: "bytes16", + name: "namespace", + type: "bytes16", + }, + { + internalType: "bytes16", + name: "name", + type: "bytes16", }, { internalType: "bytes32[]", @@ -1324,6 +1360,11 @@ const _abi = [ name: "data", type: "bytes", }, + { + internalType: "Schema", + name: "valueSchema", + type: "bytes32", + }, ], name: "setRecord", outputs: [], @@ -1397,6 +1438,11 @@ const _abi = [ name: "dataToSet", type: "bytes", }, + { + internalType: "Schema", + name: "valueSchema", + type: "bytes32", + }, ], name: "updateInField", outputs: [], @@ -1435,6 +1481,11 @@ const _abi = [ name: "dataToSet", type: "bytes", }, + { + internalType: "Schema", + name: "valueSchema", + type: "bytes32", + }, ], name: "updateInField", outputs: [], diff --git a/packages/cli/contracts/src/codegen/tables/Dynamics1.sol b/packages/cli/contracts/src/codegen/tables/Dynamics1.sol index 10301f6d57..7ad4103b8f 100644 --- a/packages/cli/contracts/src/codegen/tables/Dynamics1.sol +++ b/packages/cli/contracts/src/codegen/tables/Dynamics1.sol @@ -86,7 +86,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0, getSchema()); return toStaticArray_bytes32_1(SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_bytes32()); } @@ -95,7 +95,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - bytes memory _blob = _store.getField(_tableId, _keyTuple, 0); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 0, getSchema()); return toStaticArray_bytes32_1(SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_bytes32()); } @@ -104,7 +104,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField(_tableId, _keyTuple, 0, EncodeArray.encode(fromStaticArray_bytes32_1(staticB32))); + StoreSwitch.setField(_tableId, _keyTuple, 0, EncodeArray.encode(fromStaticArray_bytes32_1(staticB32)), getSchema()); } /** Set staticB32 (using the specified store) */ @@ -112,7 +112,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 0, EncodeArray.encode(fromStaticArray_bytes32_1(staticB32))); + _store.setField(_tableId, _keyTuple, 0, EncodeArray.encode(fromStaticArray_bytes32_1(staticB32)), getSchema()); } /** Get the length of staticB32 */ @@ -177,7 +177,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); + StoreSwitch.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), getSchema()); } /** Push an element to staticB32 (using the specified store) */ @@ -185,7 +185,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); + _store.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), getSchema()); } /** Pop an element from staticB32 */ @@ -193,7 +193,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.popFromField(_tableId, _keyTuple, 0, 32); + StoreSwitch.popFromField(_tableId, _keyTuple, 0, 32, getSchema()); } /** Pop an element from staticB32 (using the specified store) */ @@ -201,7 +201,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.popFromField(_tableId, _keyTuple, 0, 32); + _store.popFromField(_tableId, _keyTuple, 0, 32, getSchema()); } /** @@ -213,7 +213,7 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element))); + StoreSwitch.updateInField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element)), getSchema()); } } @@ -226,7 +226,7 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - _store.updateInField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element))); + _store.updateInField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element)), getSchema()); } } @@ -235,7 +235,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 1); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 1, getSchema()); return toStaticArray_int32_2(SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_int32()); } @@ -244,7 +244,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - bytes memory _blob = _store.getField(_tableId, _keyTuple, 1); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 1, getSchema()); return toStaticArray_int32_2(SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_int32()); } @@ -253,7 +253,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField(_tableId, _keyTuple, 1, EncodeArray.encode(fromStaticArray_int32_2(staticI32))); + StoreSwitch.setField(_tableId, _keyTuple, 1, EncodeArray.encode(fromStaticArray_int32_2(staticI32)), getSchema()); } /** Set staticI32 (using the specified store) */ @@ -261,7 +261,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 1, EncodeArray.encode(fromStaticArray_int32_2(staticI32))); + _store.setField(_tableId, _keyTuple, 1, EncodeArray.encode(fromStaticArray_int32_2(staticI32)), getSchema()); } /** Get the length of staticI32 */ @@ -319,7 +319,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.pushToField(_tableId, _keyTuple, 1, abi.encodePacked((_element))); + StoreSwitch.pushToField(_tableId, _keyTuple, 1, abi.encodePacked((_element)), getSchema()); } /** Push an element to staticI32 (using the specified store) */ @@ -327,7 +327,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.pushToField(_tableId, _keyTuple, 1, abi.encodePacked((_element))); + _store.pushToField(_tableId, _keyTuple, 1, abi.encodePacked((_element)), getSchema()); } /** Pop an element from staticI32 */ @@ -335,7 +335,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.popFromField(_tableId, _keyTuple, 1, 4); + StoreSwitch.popFromField(_tableId, _keyTuple, 1, 4, getSchema()); } /** Pop an element from staticI32 (using the specified store) */ @@ -343,7 +343,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.popFromField(_tableId, _keyTuple, 1, 4); + _store.popFromField(_tableId, _keyTuple, 1, 4, getSchema()); } /** @@ -355,7 +355,7 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 1, _index * 4, abi.encodePacked((_element))); + StoreSwitch.updateInField(_tableId, _keyTuple, 1, _index * 4, abi.encodePacked((_element)), getSchema()); } } @@ -368,7 +368,7 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - _store.updateInField(_tableId, _keyTuple, 1, _index * 4, abi.encodePacked((_element))); + _store.updateInField(_tableId, _keyTuple, 1, _index * 4, abi.encodePacked((_element)), getSchema()); } } @@ -377,7 +377,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 2); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 2, getSchema()); return toStaticArray_uint128_3(SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_uint128()); } @@ -386,7 +386,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - bytes memory _blob = _store.getField(_tableId, _keyTuple, 2); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 2, getSchema()); return toStaticArray_uint128_3(SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_uint128()); } @@ -395,7 +395,13 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField(_tableId, _keyTuple, 2, EncodeArray.encode(fromStaticArray_uint128_3(staticU128))); + StoreSwitch.setField( + _tableId, + _keyTuple, + 2, + EncodeArray.encode(fromStaticArray_uint128_3(staticU128)), + getSchema() + ); } /** Set staticU128 (using the specified store) */ @@ -403,7 +409,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 2, EncodeArray.encode(fromStaticArray_uint128_3(staticU128))); + _store.setField(_tableId, _keyTuple, 2, EncodeArray.encode(fromStaticArray_uint128_3(staticU128)), getSchema()); } /** Get the length of staticU128 */ @@ -468,7 +474,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.pushToField(_tableId, _keyTuple, 2, abi.encodePacked((_element))); + StoreSwitch.pushToField(_tableId, _keyTuple, 2, abi.encodePacked((_element)), getSchema()); } /** Push an element to staticU128 (using the specified store) */ @@ -476,7 +482,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.pushToField(_tableId, _keyTuple, 2, abi.encodePacked((_element))); + _store.pushToField(_tableId, _keyTuple, 2, abi.encodePacked((_element)), getSchema()); } /** Pop an element from staticU128 */ @@ -484,7 +490,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.popFromField(_tableId, _keyTuple, 2, 16); + StoreSwitch.popFromField(_tableId, _keyTuple, 2, 16, getSchema()); } /** Pop an element from staticU128 (using the specified store) */ @@ -492,7 +498,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.popFromField(_tableId, _keyTuple, 2, 16); + _store.popFromField(_tableId, _keyTuple, 2, 16, getSchema()); } /** @@ -504,7 +510,7 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 2, _index * 16, abi.encodePacked((_element))); + StoreSwitch.updateInField(_tableId, _keyTuple, 2, _index * 16, abi.encodePacked((_element)), getSchema()); } } @@ -517,7 +523,7 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - _store.updateInField(_tableId, _keyTuple, 2, _index * 16, abi.encodePacked((_element))); + _store.updateInField(_tableId, _keyTuple, 2, _index * 16, abi.encodePacked((_element)), getSchema()); } } @@ -526,7 +532,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 3); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 3, getSchema()); return toStaticArray_address_4(SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_address()); } @@ -535,7 +541,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - bytes memory _blob = _store.getField(_tableId, _keyTuple, 3); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 3, getSchema()); return toStaticArray_address_4(SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_address()); } @@ -544,7 +550,13 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField(_tableId, _keyTuple, 3, EncodeArray.encode(fromStaticArray_address_4(staticAddrs))); + StoreSwitch.setField( + _tableId, + _keyTuple, + 3, + EncodeArray.encode(fromStaticArray_address_4(staticAddrs)), + getSchema() + ); } /** Set staticAddrs (using the specified store) */ @@ -552,7 +564,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 3, EncodeArray.encode(fromStaticArray_address_4(staticAddrs))); + _store.setField(_tableId, _keyTuple, 3, EncodeArray.encode(fromStaticArray_address_4(staticAddrs)), getSchema()); } /** Get the length of staticAddrs */ @@ -617,7 +629,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.pushToField(_tableId, _keyTuple, 3, abi.encodePacked((_element))); + StoreSwitch.pushToField(_tableId, _keyTuple, 3, abi.encodePacked((_element)), getSchema()); } /** Push an element to staticAddrs (using the specified store) */ @@ -625,7 +637,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.pushToField(_tableId, _keyTuple, 3, abi.encodePacked((_element))); + _store.pushToField(_tableId, _keyTuple, 3, abi.encodePacked((_element)), getSchema()); } /** Pop an element from staticAddrs */ @@ -633,7 +645,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.popFromField(_tableId, _keyTuple, 3, 20); + StoreSwitch.popFromField(_tableId, _keyTuple, 3, 20, getSchema()); } /** Pop an element from staticAddrs (using the specified store) */ @@ -641,7 +653,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.popFromField(_tableId, _keyTuple, 3, 20); + _store.popFromField(_tableId, _keyTuple, 3, 20, getSchema()); } /** @@ -653,7 +665,7 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 3, _index * 20, abi.encodePacked((_element))); + StoreSwitch.updateInField(_tableId, _keyTuple, 3, _index * 20, abi.encodePacked((_element)), getSchema()); } } @@ -666,7 +678,7 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - _store.updateInField(_tableId, _keyTuple, 3, _index * 20, abi.encodePacked((_element))); + _store.updateInField(_tableId, _keyTuple, 3, _index * 20, abi.encodePacked((_element)), getSchema()); } } @@ -675,7 +687,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 4); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 4, getSchema()); return toStaticArray_bool_5(SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_bool()); } @@ -684,7 +696,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - bytes memory _blob = _store.getField(_tableId, _keyTuple, 4); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 4, getSchema()); return toStaticArray_bool_5(SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_bool()); } @@ -693,7 +705,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField(_tableId, _keyTuple, 4, EncodeArray.encode(fromStaticArray_bool_5(staticBools))); + StoreSwitch.setField(_tableId, _keyTuple, 4, EncodeArray.encode(fromStaticArray_bool_5(staticBools)), getSchema()); } /** Set staticBools (using the specified store) */ @@ -701,7 +713,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 4, EncodeArray.encode(fromStaticArray_bool_5(staticBools))); + _store.setField(_tableId, _keyTuple, 4, EncodeArray.encode(fromStaticArray_bool_5(staticBools)), getSchema()); } /** Get the length of staticBools */ @@ -759,7 +771,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.pushToField(_tableId, _keyTuple, 4, abi.encodePacked((_element))); + StoreSwitch.pushToField(_tableId, _keyTuple, 4, abi.encodePacked((_element)), getSchema()); } /** Push an element to staticBools (using the specified store) */ @@ -767,7 +779,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.pushToField(_tableId, _keyTuple, 4, abi.encodePacked((_element))); + _store.pushToField(_tableId, _keyTuple, 4, abi.encodePacked((_element)), getSchema()); } /** Pop an element from staticBools */ @@ -775,7 +787,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.popFromField(_tableId, _keyTuple, 4, 1); + StoreSwitch.popFromField(_tableId, _keyTuple, 4, 1, getSchema()); } /** Pop an element from staticBools (using the specified store) */ @@ -783,7 +795,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.popFromField(_tableId, _keyTuple, 4, 1); + _store.popFromField(_tableId, _keyTuple, 4, 1, getSchema()); } /** @@ -795,7 +807,7 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 4, _index * 1, abi.encodePacked((_element))); + StoreSwitch.updateInField(_tableId, _keyTuple, 4, _index * 1, abi.encodePacked((_element)), getSchema()); } } @@ -808,7 +820,7 @@ library Dynamics1 { _keyTuple[0] = key; unchecked { - _store.updateInField(_tableId, _keyTuple, 4, _index * 1, abi.encodePacked((_element))); + _store.updateInField(_tableId, _keyTuple, 4, _index * 1, abi.encodePacked((_element)), getSchema()); } } @@ -844,7 +856,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setRecord(_tableId, _keyTuple, _data); + StoreSwitch.setRecord(_tableId, _keyTuple, _data, getSchema()); } /** Set the full data using individual values (using the specified store) */ @@ -862,7 +874,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setRecord(_tableId, _keyTuple, _data); + _store.setRecord(_tableId, _keyTuple, _data, getSchema()); } /** Set the full data using the data struct */ @@ -959,7 +971,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.deleteRecord(_tableId, _keyTuple); + StoreSwitch.deleteRecord(_tableId, _keyTuple, getSchema()); } /* Delete all data for given keys (using the specified store) */ @@ -967,7 +979,7 @@ library Dynamics1 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.deleteRecord(_tableId, _keyTuple); + _store.deleteRecord(_tableId, _keyTuple, getSchema()); } } diff --git a/packages/cli/contracts/src/codegen/tables/Dynamics2.sol b/packages/cli/contracts/src/codegen/tables/Dynamics2.sol index df04316e0d..598db942c5 100644 --- a/packages/cli/contracts/src/codegen/tables/Dynamics2.sol +++ b/packages/cli/contracts/src/codegen/tables/Dynamics2.sol @@ -80,7 +80,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0, getSchema()); return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_uint64()); } @@ -89,7 +89,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - bytes memory _blob = _store.getField(_tableId, _keyTuple, 0); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 0, getSchema()); return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_uint64()); } @@ -98,7 +98,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField(_tableId, _keyTuple, 0, EncodeArray.encode((u64))); + StoreSwitch.setField(_tableId, _keyTuple, 0, EncodeArray.encode((u64)), getSchema()); } /** Set u64 (using the specified store) */ @@ -106,7 +106,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 0, EncodeArray.encode((u64))); + _store.setField(_tableId, _keyTuple, 0, EncodeArray.encode((u64)), getSchema()); } /** Get the length of u64 */ @@ -164,7 +164,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); + StoreSwitch.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), getSchema()); } /** Push an element to u64 (using the specified store) */ @@ -172,7 +172,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); + _store.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), getSchema()); } /** Pop an element from u64 */ @@ -180,7 +180,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.popFromField(_tableId, _keyTuple, 0, 8); + StoreSwitch.popFromField(_tableId, _keyTuple, 0, 8, getSchema()); } /** Pop an element from u64 (using the specified store) */ @@ -188,7 +188,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.popFromField(_tableId, _keyTuple, 0, 8); + _store.popFromField(_tableId, _keyTuple, 0, 8, getSchema()); } /** @@ -200,7 +200,7 @@ library Dynamics2 { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 0, _index * 8, abi.encodePacked((_element))); + StoreSwitch.updateInField(_tableId, _keyTuple, 0, _index * 8, abi.encodePacked((_element)), getSchema()); } } @@ -213,7 +213,7 @@ library Dynamics2 { _keyTuple[0] = key; unchecked { - _store.updateInField(_tableId, _keyTuple, 0, _index * 8, abi.encodePacked((_element))); + _store.updateInField(_tableId, _keyTuple, 0, _index * 8, abi.encodePacked((_element)), getSchema()); } } @@ -222,7 +222,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 1); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 1, getSchema()); return (string(_blob)); } @@ -231,7 +231,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - bytes memory _blob = _store.getField(_tableId, _keyTuple, 1); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 1, getSchema()); return (string(_blob)); } @@ -240,7 +240,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField(_tableId, _keyTuple, 1, bytes((str))); + StoreSwitch.setField(_tableId, _keyTuple, 1, bytes((str)), getSchema()); } /** Set str (using the specified store) */ @@ -248,7 +248,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 1, bytes((str))); + _store.setField(_tableId, _keyTuple, 1, bytes((str)), getSchema()); } /** Get the length of str */ @@ -306,7 +306,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.pushToField(_tableId, _keyTuple, 1, bytes((_slice))); + StoreSwitch.pushToField(_tableId, _keyTuple, 1, bytes((_slice)), getSchema()); } /** Push a slice to str (using the specified store) */ @@ -314,7 +314,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.pushToField(_tableId, _keyTuple, 1, bytes((_slice))); + _store.pushToField(_tableId, _keyTuple, 1, bytes((_slice)), getSchema()); } /** Pop a slice from str */ @@ -322,7 +322,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.popFromField(_tableId, _keyTuple, 1, 1); + StoreSwitch.popFromField(_tableId, _keyTuple, 1, 1, getSchema()); } /** Pop a slice from str (using the specified store) */ @@ -330,7 +330,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.popFromField(_tableId, _keyTuple, 1, 1); + _store.popFromField(_tableId, _keyTuple, 1, 1, getSchema()); } /** @@ -342,7 +342,7 @@ library Dynamics2 { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 1, _index * 1, bytes((_slice))); + StoreSwitch.updateInField(_tableId, _keyTuple, 1, _index * 1, bytes((_slice)), getSchema()); } } @@ -355,7 +355,7 @@ library Dynamics2 { _keyTuple[0] = key; unchecked { - _store.updateInField(_tableId, _keyTuple, 1, _index * 1, bytes((_slice))); + _store.updateInField(_tableId, _keyTuple, 1, _index * 1, bytes((_slice)), getSchema()); } } @@ -364,7 +364,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 2); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 2, getSchema()); return (bytes(_blob)); } @@ -373,7 +373,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - bytes memory _blob = _store.getField(_tableId, _keyTuple, 2); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 2, getSchema()); return (bytes(_blob)); } @@ -382,7 +382,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField(_tableId, _keyTuple, 2, bytes((b))); + StoreSwitch.setField(_tableId, _keyTuple, 2, bytes((b)), getSchema()); } /** Set b (using the specified store) */ @@ -390,7 +390,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 2, bytes((b))); + _store.setField(_tableId, _keyTuple, 2, bytes((b)), getSchema()); } /** Get the length of b */ @@ -448,7 +448,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.pushToField(_tableId, _keyTuple, 2, bytes((_slice))); + StoreSwitch.pushToField(_tableId, _keyTuple, 2, bytes((_slice)), getSchema()); } /** Push a slice to b (using the specified store) */ @@ -456,7 +456,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.pushToField(_tableId, _keyTuple, 2, bytes((_slice))); + _store.pushToField(_tableId, _keyTuple, 2, bytes((_slice)), getSchema()); } /** Pop a slice from b */ @@ -464,7 +464,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.popFromField(_tableId, _keyTuple, 2, 1); + StoreSwitch.popFromField(_tableId, _keyTuple, 2, 1, getSchema()); } /** Pop a slice from b (using the specified store) */ @@ -472,7 +472,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.popFromField(_tableId, _keyTuple, 2, 1); + _store.popFromField(_tableId, _keyTuple, 2, 1, getSchema()); } /** @@ -484,7 +484,7 @@ library Dynamics2 { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 2, _index * 1, bytes((_slice))); + StoreSwitch.updateInField(_tableId, _keyTuple, 2, _index * 1, bytes((_slice)), getSchema()); } } @@ -497,7 +497,7 @@ library Dynamics2 { _keyTuple[0] = key; unchecked { - _store.updateInField(_tableId, _keyTuple, 2, _index * 1, bytes((_slice))); + _store.updateInField(_tableId, _keyTuple, 2, _index * 1, bytes((_slice)), getSchema()); } } @@ -526,7 +526,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setRecord(_tableId, _keyTuple, _data); + StoreSwitch.setRecord(_tableId, _keyTuple, _data, getSchema()); } /** Set the full data using individual values (using the specified store) */ @@ -536,7 +536,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setRecord(_tableId, _keyTuple, _data); + _store.setRecord(_tableId, _keyTuple, _data, getSchema()); } /** Set the full data using the data struct */ @@ -605,7 +605,7 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.deleteRecord(_tableId, _keyTuple); + StoreSwitch.deleteRecord(_tableId, _keyTuple, getSchema()); } /* Delete all data for given keys (using the specified store) */ @@ -613,6 +613,6 @@ library Dynamics2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.deleteRecord(_tableId, _keyTuple); + _store.deleteRecord(_tableId, _keyTuple, getSchema()); } } diff --git a/packages/cli/contracts/src/codegen/tables/Ephemeral.sol b/packages/cli/contracts/src/codegen/tables/Ephemeral.sol index 10b5aaa18b..380302a1dc 100644 --- a/packages/cli/contracts/src/codegen/tables/Ephemeral.sol +++ b/packages/cli/contracts/src/codegen/tables/Ephemeral.sol @@ -72,7 +72,7 @@ library Ephemeral { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.emitEphemeralRecord(_tableId, _keyTuple, _data); + StoreSwitch.emitEphemeralRecord(_tableId, _keyTuple, _data, getSchema()); } /** Emit the ephemeral event using individual values (using the specified store) */ @@ -82,7 +82,7 @@ library Ephemeral { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.emitEphemeralRecord(_tableId, _keyTuple, _data); + _store.emitEphemeralRecord(_tableId, _keyTuple, _data, getSchema()); } /** Tightly pack full data using this table's schema */ diff --git a/packages/cli/contracts/src/codegen/tables/Singleton.sol b/packages/cli/contracts/src/codegen/tables/Singleton.sol index 4ddd816e3d..cdaa73c153 100644 --- a/packages/cli/contracts/src/codegen/tables/Singleton.sol +++ b/packages/cli/contracts/src/codegen/tables/Singleton.sol @@ -74,7 +74,7 @@ library Singleton { function getV1() internal view returns (int256 v1) { bytes32[] memory _keyTuple = new bytes32[](0); - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0, getSchema()); return (int256(uint256(Bytes.slice32(_blob, 0)))); } @@ -82,7 +82,7 @@ library Singleton { function getV1(IStore _store) internal view returns (int256 v1) { bytes32[] memory _keyTuple = new bytes32[](0); - bytes memory _blob = _store.getField(_tableId, _keyTuple, 0); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 0, getSchema()); return (int256(uint256(Bytes.slice32(_blob, 0)))); } @@ -90,21 +90,21 @@ library Singleton { function setV1(int256 v1) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((v1))); + StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((v1)), getSchema()); } /** Set v1 (using the specified store) */ function setV1(IStore _store, int256 v1) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((v1))); + _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((v1)), getSchema()); } /** Get v2 */ function getV2() internal view returns (uint32[2] memory v2) { bytes32[] memory _keyTuple = new bytes32[](0); - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 1); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 1, getSchema()); return toStaticArray_uint32_2(SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_uint32()); } @@ -112,7 +112,7 @@ library Singleton { function getV2(IStore _store) internal view returns (uint32[2] memory v2) { bytes32[] memory _keyTuple = new bytes32[](0); - bytes memory _blob = _store.getField(_tableId, _keyTuple, 1); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 1, getSchema()); return toStaticArray_uint32_2(SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_uint32()); } @@ -120,14 +120,14 @@ library Singleton { function setV2(uint32[2] memory v2) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.setField(_tableId, _keyTuple, 1, EncodeArray.encode(fromStaticArray_uint32_2(v2))); + StoreSwitch.setField(_tableId, _keyTuple, 1, EncodeArray.encode(fromStaticArray_uint32_2(v2)), getSchema()); } /** Set v2 (using the specified store) */ function setV2(IStore _store, uint32[2] memory v2) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.setField(_tableId, _keyTuple, 1, EncodeArray.encode(fromStaticArray_uint32_2(v2))); + _store.setField(_tableId, _keyTuple, 1, EncodeArray.encode(fromStaticArray_uint32_2(v2)), getSchema()); } /** Get the length of v2 */ @@ -180,28 +180,28 @@ library Singleton { function pushV2(uint32 _element) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.pushToField(_tableId, _keyTuple, 1, abi.encodePacked((_element))); + StoreSwitch.pushToField(_tableId, _keyTuple, 1, abi.encodePacked((_element)), getSchema()); } /** Push an element to v2 (using the specified store) */ function pushV2(IStore _store, uint32 _element) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.pushToField(_tableId, _keyTuple, 1, abi.encodePacked((_element))); + _store.pushToField(_tableId, _keyTuple, 1, abi.encodePacked((_element)), getSchema()); } /** Pop an element from v2 */ function popV2() internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.popFromField(_tableId, _keyTuple, 1, 4); + StoreSwitch.popFromField(_tableId, _keyTuple, 1, 4, getSchema()); } /** Pop an element from v2 (using the specified store) */ function popV2(IStore _store) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.popFromField(_tableId, _keyTuple, 1, 4); + _store.popFromField(_tableId, _keyTuple, 1, 4, getSchema()); } /** @@ -212,7 +212,7 @@ library Singleton { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 1, _index * 4, abi.encodePacked((_element))); + StoreSwitch.updateInField(_tableId, _keyTuple, 1, _index * 4, abi.encodePacked((_element)), getSchema()); } } @@ -224,7 +224,7 @@ library Singleton { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - _store.updateInField(_tableId, _keyTuple, 1, _index * 4, abi.encodePacked((_element))); + _store.updateInField(_tableId, _keyTuple, 1, _index * 4, abi.encodePacked((_element)), getSchema()); } } @@ -232,7 +232,7 @@ library Singleton { function getV3() internal view returns (uint32[2] memory v3) { bytes32[] memory _keyTuple = new bytes32[](0); - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 2); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 2, getSchema()); return toStaticArray_uint32_2(SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_uint32()); } @@ -240,7 +240,7 @@ library Singleton { function getV3(IStore _store) internal view returns (uint32[2] memory v3) { bytes32[] memory _keyTuple = new bytes32[](0); - bytes memory _blob = _store.getField(_tableId, _keyTuple, 2); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 2, getSchema()); return toStaticArray_uint32_2(SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_uint32()); } @@ -248,14 +248,14 @@ library Singleton { function setV3(uint32[2] memory v3) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.setField(_tableId, _keyTuple, 2, EncodeArray.encode(fromStaticArray_uint32_2(v3))); + StoreSwitch.setField(_tableId, _keyTuple, 2, EncodeArray.encode(fromStaticArray_uint32_2(v3)), getSchema()); } /** Set v3 (using the specified store) */ function setV3(IStore _store, uint32[2] memory v3) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.setField(_tableId, _keyTuple, 2, EncodeArray.encode(fromStaticArray_uint32_2(v3))); + _store.setField(_tableId, _keyTuple, 2, EncodeArray.encode(fromStaticArray_uint32_2(v3)), getSchema()); } /** Get the length of v3 */ @@ -308,28 +308,28 @@ library Singleton { function pushV3(uint32 _element) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.pushToField(_tableId, _keyTuple, 2, abi.encodePacked((_element))); + StoreSwitch.pushToField(_tableId, _keyTuple, 2, abi.encodePacked((_element)), getSchema()); } /** Push an element to v3 (using the specified store) */ function pushV3(IStore _store, uint32 _element) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.pushToField(_tableId, _keyTuple, 2, abi.encodePacked((_element))); + _store.pushToField(_tableId, _keyTuple, 2, abi.encodePacked((_element)), getSchema()); } /** Pop an element from v3 */ function popV3() internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.popFromField(_tableId, _keyTuple, 2, 4); + StoreSwitch.popFromField(_tableId, _keyTuple, 2, 4, getSchema()); } /** Pop an element from v3 (using the specified store) */ function popV3(IStore _store) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.popFromField(_tableId, _keyTuple, 2, 4); + _store.popFromField(_tableId, _keyTuple, 2, 4, getSchema()); } /** @@ -340,7 +340,7 @@ library Singleton { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 2, _index * 4, abi.encodePacked((_element))); + StoreSwitch.updateInField(_tableId, _keyTuple, 2, _index * 4, abi.encodePacked((_element)), getSchema()); } } @@ -352,7 +352,7 @@ library Singleton { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - _store.updateInField(_tableId, _keyTuple, 2, _index * 4, abi.encodePacked((_element))); + _store.updateInField(_tableId, _keyTuple, 2, _index * 4, abi.encodePacked((_element)), getSchema()); } } @@ -360,7 +360,7 @@ library Singleton { function getV4() internal view returns (uint32[1] memory v4) { bytes32[] memory _keyTuple = new bytes32[](0); - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 3); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 3, getSchema()); return toStaticArray_uint32_1(SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_uint32()); } @@ -368,7 +368,7 @@ library Singleton { function getV4(IStore _store) internal view returns (uint32[1] memory v4) { bytes32[] memory _keyTuple = new bytes32[](0); - bytes memory _blob = _store.getField(_tableId, _keyTuple, 3); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 3, getSchema()); return toStaticArray_uint32_1(SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_uint32()); } @@ -376,14 +376,14 @@ library Singleton { function setV4(uint32[1] memory v4) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.setField(_tableId, _keyTuple, 3, EncodeArray.encode(fromStaticArray_uint32_1(v4))); + StoreSwitch.setField(_tableId, _keyTuple, 3, EncodeArray.encode(fromStaticArray_uint32_1(v4)), getSchema()); } /** Set v4 (using the specified store) */ function setV4(IStore _store, uint32[1] memory v4) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.setField(_tableId, _keyTuple, 3, EncodeArray.encode(fromStaticArray_uint32_1(v4))); + _store.setField(_tableId, _keyTuple, 3, EncodeArray.encode(fromStaticArray_uint32_1(v4)), getSchema()); } /** Get the length of v4 */ @@ -436,28 +436,28 @@ library Singleton { function pushV4(uint32 _element) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.pushToField(_tableId, _keyTuple, 3, abi.encodePacked((_element))); + StoreSwitch.pushToField(_tableId, _keyTuple, 3, abi.encodePacked((_element)), getSchema()); } /** Push an element to v4 (using the specified store) */ function pushV4(IStore _store, uint32 _element) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.pushToField(_tableId, _keyTuple, 3, abi.encodePacked((_element))); + _store.pushToField(_tableId, _keyTuple, 3, abi.encodePacked((_element)), getSchema()); } /** Pop an element from v4 */ function popV4() internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.popFromField(_tableId, _keyTuple, 3, 4); + StoreSwitch.popFromField(_tableId, _keyTuple, 3, 4, getSchema()); } /** Pop an element from v4 (using the specified store) */ function popV4(IStore _store) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.popFromField(_tableId, _keyTuple, 3, 4); + _store.popFromField(_tableId, _keyTuple, 3, 4, getSchema()); } /** @@ -468,7 +468,7 @@ library Singleton { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 3, _index * 4, abi.encodePacked((_element))); + StoreSwitch.updateInField(_tableId, _keyTuple, 3, _index * 4, abi.encodePacked((_element)), getSchema()); } } @@ -480,7 +480,7 @@ library Singleton { bytes32[] memory _keyTuple = new bytes32[](0); unchecked { - _store.updateInField(_tableId, _keyTuple, 3, _index * 4, abi.encodePacked((_element))); + _store.updateInField(_tableId, _keyTuple, 3, _index * 4, abi.encodePacked((_element)), getSchema()); } } @@ -508,7 +508,7 @@ library Singleton { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.setRecord(_tableId, _keyTuple, _data); + StoreSwitch.setRecord(_tableId, _keyTuple, _data, getSchema()); } /** Set the full data using individual values (using the specified store) */ @@ -517,7 +517,7 @@ library Singleton { bytes32[] memory _keyTuple = new bytes32[](0); - _store.setRecord(_tableId, _keyTuple, _data); + _store.setRecord(_tableId, _keyTuple, _data, getSchema()); } /** @@ -590,14 +590,14 @@ library Singleton { function deleteRecord() internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.deleteRecord(_tableId, _keyTuple); + StoreSwitch.deleteRecord(_tableId, _keyTuple, getSchema()); } /* Delete all data for given keys (using the specified store) */ function deleteRecord(IStore _store) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.deleteRecord(_tableId, _keyTuple); + _store.deleteRecord(_tableId, _keyTuple, getSchema()); } } diff --git a/packages/cli/contracts/src/codegen/tables/Statics.sol b/packages/cli/contracts/src/codegen/tables/Statics.sol index d69a8c61f8..ffd1d1cdc2 100644 --- a/packages/cli/contracts/src/codegen/tables/Statics.sol +++ b/packages/cli/contracts/src/codegen/tables/Statics.sol @@ -115,7 +115,7 @@ library Statics { _keyTuple[5] = bytes32(uint256(uint8(k6))); _keyTuple[6] = bytes32(uint256(uint8(k7))); - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0, getSchema()); return (uint256(Bytes.slice32(_blob, 0))); } @@ -139,7 +139,7 @@ library Statics { _keyTuple[5] = bytes32(uint256(uint8(k6))); _keyTuple[6] = bytes32(uint256(uint8(k7))); - bytes memory _blob = _store.getField(_tableId, _keyTuple, 0); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 0, getSchema()); return (uint256(Bytes.slice32(_blob, 0))); } @@ -154,7 +154,7 @@ library Statics { _keyTuple[5] = bytes32(uint256(uint8(k6))); _keyTuple[6] = bytes32(uint256(uint8(k7))); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((v1))); + StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((v1)), getSchema()); } /** Set v1 (using the specified store) */ @@ -178,7 +178,7 @@ library Statics { _keyTuple[5] = bytes32(uint256(uint8(k6))); _keyTuple[6] = bytes32(uint256(uint8(k7))); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((v1))); + _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((v1)), getSchema()); } /** Get v2 */ @@ -200,7 +200,7 @@ library Statics { _keyTuple[5] = bytes32(uint256(uint8(k6))); _keyTuple[6] = bytes32(uint256(uint8(k7))); - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 1); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 1, getSchema()); return (int32(uint32(Bytes.slice4(_blob, 0)))); } @@ -224,7 +224,7 @@ library Statics { _keyTuple[5] = bytes32(uint256(uint8(k6))); _keyTuple[6] = bytes32(uint256(uint8(k7))); - bytes memory _blob = _store.getField(_tableId, _keyTuple, 1); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 1, getSchema()); return (int32(uint32(Bytes.slice4(_blob, 0)))); } @@ -239,7 +239,7 @@ library Statics { _keyTuple[5] = bytes32(uint256(uint8(k6))); _keyTuple[6] = bytes32(uint256(uint8(k7))); - StoreSwitch.setField(_tableId, _keyTuple, 1, abi.encodePacked((v2))); + StoreSwitch.setField(_tableId, _keyTuple, 1, abi.encodePacked((v2)), getSchema()); } /** Set v2 (using the specified store) */ @@ -263,7 +263,7 @@ library Statics { _keyTuple[5] = bytes32(uint256(uint8(k6))); _keyTuple[6] = bytes32(uint256(uint8(k7))); - _store.setField(_tableId, _keyTuple, 1, abi.encodePacked((v2))); + _store.setField(_tableId, _keyTuple, 1, abi.encodePacked((v2)), getSchema()); } /** Get v3 */ @@ -285,7 +285,7 @@ library Statics { _keyTuple[5] = bytes32(uint256(uint8(k6))); _keyTuple[6] = bytes32(uint256(uint8(k7))); - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 2); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 2, getSchema()); return (Bytes.slice16(_blob, 0)); } @@ -309,7 +309,7 @@ library Statics { _keyTuple[5] = bytes32(uint256(uint8(k6))); _keyTuple[6] = bytes32(uint256(uint8(k7))); - bytes memory _blob = _store.getField(_tableId, _keyTuple, 2); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 2, getSchema()); return (Bytes.slice16(_blob, 0)); } @@ -324,7 +324,7 @@ library Statics { _keyTuple[5] = bytes32(uint256(uint8(k6))); _keyTuple[6] = bytes32(uint256(uint8(k7))); - StoreSwitch.setField(_tableId, _keyTuple, 2, abi.encodePacked((v3))); + StoreSwitch.setField(_tableId, _keyTuple, 2, abi.encodePacked((v3)), getSchema()); } /** Set v3 (using the specified store) */ @@ -348,7 +348,7 @@ library Statics { _keyTuple[5] = bytes32(uint256(uint8(k6))); _keyTuple[6] = bytes32(uint256(uint8(k7))); - _store.setField(_tableId, _keyTuple, 2, abi.encodePacked((v3))); + _store.setField(_tableId, _keyTuple, 2, abi.encodePacked((v3)), getSchema()); } /** Get v4 */ @@ -370,7 +370,7 @@ library Statics { _keyTuple[5] = bytes32(uint256(uint8(k6))); _keyTuple[6] = bytes32(uint256(uint8(k7))); - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 3); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 3, getSchema()); return (address(Bytes.slice20(_blob, 0))); } @@ -394,7 +394,7 @@ library Statics { _keyTuple[5] = bytes32(uint256(uint8(k6))); _keyTuple[6] = bytes32(uint256(uint8(k7))); - bytes memory _blob = _store.getField(_tableId, _keyTuple, 3); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 3, getSchema()); return (address(Bytes.slice20(_blob, 0))); } @@ -409,7 +409,7 @@ library Statics { _keyTuple[5] = bytes32(uint256(uint8(k6))); _keyTuple[6] = bytes32(uint256(uint8(k7))); - StoreSwitch.setField(_tableId, _keyTuple, 3, abi.encodePacked((v4))); + StoreSwitch.setField(_tableId, _keyTuple, 3, abi.encodePacked((v4)), getSchema()); } /** Set v4 (using the specified store) */ @@ -433,7 +433,7 @@ library Statics { _keyTuple[5] = bytes32(uint256(uint8(k6))); _keyTuple[6] = bytes32(uint256(uint8(k7))); - _store.setField(_tableId, _keyTuple, 3, abi.encodePacked((v4))); + _store.setField(_tableId, _keyTuple, 3, abi.encodePacked((v4)), getSchema()); } /** Get v5 */ @@ -455,7 +455,7 @@ library Statics { _keyTuple[5] = bytes32(uint256(uint8(k6))); _keyTuple[6] = bytes32(uint256(uint8(k7))); - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 4); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 4, getSchema()); return (_toBool(uint8(Bytes.slice1(_blob, 0)))); } @@ -479,7 +479,7 @@ library Statics { _keyTuple[5] = bytes32(uint256(uint8(k6))); _keyTuple[6] = bytes32(uint256(uint8(k7))); - bytes memory _blob = _store.getField(_tableId, _keyTuple, 4); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 4, getSchema()); return (_toBool(uint8(Bytes.slice1(_blob, 0)))); } @@ -494,7 +494,7 @@ library Statics { _keyTuple[5] = bytes32(uint256(uint8(k6))); _keyTuple[6] = bytes32(uint256(uint8(k7))); - StoreSwitch.setField(_tableId, _keyTuple, 4, abi.encodePacked((v5))); + StoreSwitch.setField(_tableId, _keyTuple, 4, abi.encodePacked((v5)), getSchema()); } /** Set v5 (using the specified store) */ @@ -518,7 +518,7 @@ library Statics { _keyTuple[5] = bytes32(uint256(uint8(k6))); _keyTuple[6] = bytes32(uint256(uint8(k7))); - _store.setField(_tableId, _keyTuple, 4, abi.encodePacked((v5))); + _store.setField(_tableId, _keyTuple, 4, abi.encodePacked((v5)), getSchema()); } /** Get v6 */ @@ -540,7 +540,7 @@ library Statics { _keyTuple[5] = bytes32(uint256(uint8(k6))); _keyTuple[6] = bytes32(uint256(uint8(k7))); - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 5); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 5, getSchema()); return Enum1(uint8(Bytes.slice1(_blob, 0))); } @@ -564,7 +564,7 @@ library Statics { _keyTuple[5] = bytes32(uint256(uint8(k6))); _keyTuple[6] = bytes32(uint256(uint8(k7))); - bytes memory _blob = _store.getField(_tableId, _keyTuple, 5); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 5, getSchema()); return Enum1(uint8(Bytes.slice1(_blob, 0))); } @@ -579,7 +579,7 @@ library Statics { _keyTuple[5] = bytes32(uint256(uint8(k6))); _keyTuple[6] = bytes32(uint256(uint8(k7))); - StoreSwitch.setField(_tableId, _keyTuple, 5, abi.encodePacked(uint8(v6))); + StoreSwitch.setField(_tableId, _keyTuple, 5, abi.encodePacked(uint8(v6)), getSchema()); } /** Set v6 (using the specified store) */ @@ -603,7 +603,7 @@ library Statics { _keyTuple[5] = bytes32(uint256(uint8(k6))); _keyTuple[6] = bytes32(uint256(uint8(k7))); - _store.setField(_tableId, _keyTuple, 5, abi.encodePacked(uint8(v6))); + _store.setField(_tableId, _keyTuple, 5, abi.encodePacked(uint8(v6)), getSchema()); } /** Get v7 */ @@ -625,7 +625,7 @@ library Statics { _keyTuple[5] = bytes32(uint256(uint8(k6))); _keyTuple[6] = bytes32(uint256(uint8(k7))); - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 6); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 6, getSchema()); return Enum2(uint8(Bytes.slice1(_blob, 0))); } @@ -649,7 +649,7 @@ library Statics { _keyTuple[5] = bytes32(uint256(uint8(k6))); _keyTuple[6] = bytes32(uint256(uint8(k7))); - bytes memory _blob = _store.getField(_tableId, _keyTuple, 6); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 6, getSchema()); return Enum2(uint8(Bytes.slice1(_blob, 0))); } @@ -664,7 +664,7 @@ library Statics { _keyTuple[5] = bytes32(uint256(uint8(k6))); _keyTuple[6] = bytes32(uint256(uint8(k7))); - StoreSwitch.setField(_tableId, _keyTuple, 6, abi.encodePacked(uint8(v7))); + StoreSwitch.setField(_tableId, _keyTuple, 6, abi.encodePacked(uint8(v7)), getSchema()); } /** Set v7 (using the specified store) */ @@ -688,7 +688,7 @@ library Statics { _keyTuple[5] = bytes32(uint256(uint8(k6))); _keyTuple[6] = bytes32(uint256(uint8(k7))); - _store.setField(_tableId, _keyTuple, 6, abi.encodePacked(uint8(v7))); + _store.setField(_tableId, _keyTuple, 6, abi.encodePacked(uint8(v7)), getSchema()); } /** Get the full data */ @@ -766,7 +766,7 @@ library Statics { _keyTuple[5] = bytes32(uint256(uint8(k6))); _keyTuple[6] = bytes32(uint256(uint8(k7))); - StoreSwitch.setRecord(_tableId, _keyTuple, _data); + StoreSwitch.setRecord(_tableId, _keyTuple, _data, getSchema()); } /** Set the full data using individual values (using the specified store) */ @@ -798,7 +798,7 @@ library Statics { _keyTuple[5] = bytes32(uint256(uint8(k6))); _keyTuple[6] = bytes32(uint256(uint8(k7))); - _store.setRecord(_tableId, _keyTuple, _data); + _store.setRecord(_tableId, _keyTuple, _data, getSchema()); } /** Set the full data using the data struct */ @@ -909,7 +909,7 @@ library Statics { _keyTuple[5] = bytes32(uint256(uint8(k6))); _keyTuple[6] = bytes32(uint256(uint8(k7))); - StoreSwitch.deleteRecord(_tableId, _keyTuple); + StoreSwitch.deleteRecord(_tableId, _keyTuple, getSchema()); } /* Delete all data for given keys (using the specified store) */ @@ -932,7 +932,7 @@ library Statics { _keyTuple[5] = bytes32(uint256(uint8(k6))); _keyTuple[6] = bytes32(uint256(uint8(k7))); - _store.deleteRecord(_tableId, _keyTuple); + _store.deleteRecord(_tableId, _keyTuple, getSchema()); } } diff --git a/packages/cli/package.json b/packages/cli/package.json index 976b2b80c2..e18c2bf0bb 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -34,6 +34,7 @@ "@latticexyz/common": "workspace:*", "@latticexyz/config": "workspace:*", "@latticexyz/gas-report": "workspace:*", + "@latticexyz/protocol-parser": "workspace:*", "@latticexyz/schema-type": "workspace:*", "@latticexyz/services": "workspace:*", "@latticexyz/solecs": "workspace:*", diff --git a/packages/cli/src/commands/trace.ts b/packages/cli/src/commands/trace.ts index ff2b1c210e..1a80c0fea9 100644 --- a/packages/cli/src/commands/trace.ts +++ b/packages/cli/src/commands/trace.ts @@ -5,14 +5,16 @@ import { ethers } from "ethers"; import { loadConfig } from "@latticexyz/config/node"; import { MUDError } from "@latticexyz/common/errors"; import { cast, getRpcUrl, getSrcDirectory } from "@latticexyz/common/foundry"; -import { TableId } from "@latticexyz/common/deprecated"; import { StoreConfig } from "@latticexyz/store"; import { resolveWorldConfig, WorldConfig } from "@latticexyz/world"; import { IBaseWorld } from "@latticexyz/world/types/ethers-contracts/IBaseWorld"; import IBaseWorldData from "@latticexyz/world/abi/IBaseWorld.sol/IBaseWorld.json" assert { type: "json" }; +import worldConfig from "@latticexyz/world/mud.config.js"; +import { tableIdToHex } from "@latticexyz/common"; import { getChainId, getExistingContracts } from "../utils"; -const systemsTableId = new TableId("", "Systems"); +// TODO account for multiple namespaces (https://github.com/latticexyz/mud/issues/994) +const systemsTableId = tableIdToHex(worldConfig.namespace, worldConfig.tables.Systems.name); type Options = { tx: string; @@ -70,11 +72,13 @@ const commandModule: CommandModule = { const namespace = mudConfig.namespace; const names = Object.values(resolvedConfig.systems).map(({ name }) => name); + // Fetch system table schema from chain + const systemTableSchema = await WorldContract.getSchema(systemsTableId); const labels: { name: string; address: string }[] = []; for (const name of names) { - const systemSelector = new TableId(namespace, name); + const systemSelector = tableIdToHex(namespace, name); // Get the first field of `Systems` table (the table maps system name to its address and other data) - const address = await WorldContract.getField(systemsTableId.toHex(), [systemSelector.toHex()], 0); + const address = await WorldContract.getField(systemsTableId, [systemSelector], 0, systemTableSchema); labels.push({ name, address }); } diff --git a/packages/schema-type/src/typescript/deprecated/utils/encodeSchema.ts b/packages/schema-type/src/typescript/deprecated/utils/encodeSchema.ts index c33883cd7b..f10ec6c891 100644 --- a/packages/schema-type/src/typescript/deprecated/utils/encodeSchema.ts +++ b/packages/schema-type/src/typescript/deprecated/utils/encodeSchema.ts @@ -6,6 +6,7 @@ import { SchemaType } from "../SchemaType"; * Port of `Schema.sol` from `@latticexyz/store` * @param schema The schema to encode SchemaType[] * @returns The encoded schema as a 32 byte hex string + * @deprecated use `schemaToHex` from `protocol-parser` instead */ export function encodeSchema(schema: SchemaType[]): Uint8Array { diff --git a/packages/store/abi/IStore.sol/IStore.abi.json b/packages/store/abi/IStore.sol/IStore.abi.json index 9af8379342..3dc7bc3b3a 100644 --- a/packages/store/abi/IStore.sol/IStore.abi.json +++ b/packages/store/abi/IStore.sol/IStore.abi.json @@ -200,6 +200,11 @@ "internalType": "bytes32[]", "name": "key", "type": "bytes32[]" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "deleteRecord", @@ -223,6 +228,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "emitEphemeralRecord", @@ -246,6 +256,11 @@ "internalType": "uint8", "name": "schemaIndex", "type": "uint8" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "getField", @@ -278,7 +293,7 @@ }, { "internalType": "Schema", - "name": "schema", + "name": "valueSchema", "type": "bytes32" } ], @@ -312,7 +327,7 @@ }, { "internalType": "Schema", - "name": "schema", + "name": "valueSchema", "type": "bytes32" }, { @@ -370,7 +385,7 @@ }, { "internalType": "Schema", - "name": "schema", + "name": "valueSchema", "type": "bytes32" } ], @@ -385,30 +400,6 @@ "stateMutability": "view", "type": "function" }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "table", - "type": "bytes32" - }, - { - "internalType": "bytes32[]", - "name": "key", - "type": "bytes32[]" - } - ], - "name": "getRecord", - "outputs": [ - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "stateMutability": "view", - "type": "function" - }, { "inputs": [ { @@ -449,6 +440,11 @@ "internalType": "uint256", "name": "byteLengthToPop", "type": "uint256" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "popFromField", @@ -477,6 +473,11 @@ "internalType": "bytes", "name": "dataToPush", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "pushToField", @@ -546,6 +547,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "setField", @@ -592,6 +598,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "setRecord", @@ -625,6 +636,11 @@ "internalType": "bytes", "name": "dataToSet", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "updateInField", diff --git a/packages/store/abi/IStore.sol/IStoreData.abi.json b/packages/store/abi/IStore.sol/IStoreData.abi.json index 3d3e52c5c6..8bdc4379fa 100644 --- a/packages/store/abi/IStore.sol/IStoreData.abi.json +++ b/packages/store/abi/IStore.sol/IStoreData.abi.json @@ -85,6 +85,11 @@ "internalType": "bytes32[]", "name": "key", "type": "bytes32[]" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "deleteRecord", @@ -108,6 +113,11 @@ "internalType": "uint8", "name": "schemaIndex", "type": "uint8" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "getField", @@ -140,7 +150,7 @@ }, { "internalType": "Schema", - "name": "schema", + "name": "valueSchema", "type": "bytes32" } ], @@ -174,7 +184,7 @@ }, { "internalType": "Schema", - "name": "schema", + "name": "valueSchema", "type": "bytes32" }, { @@ -232,7 +242,7 @@ }, { "internalType": "Schema", - "name": "schema", + "name": "valueSchema", "type": "bytes32" } ], @@ -247,30 +257,6 @@ "stateMutability": "view", "type": "function" }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "table", - "type": "bytes32" - }, - { - "internalType": "bytes32[]", - "name": "key", - "type": "bytes32[]" - } - ], - "name": "getRecord", - "outputs": [ - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "stateMutability": "view", - "type": "function" - }, { "inputs": [ { @@ -311,6 +297,11 @@ "internalType": "uint256", "name": "byteLengthToPop", "type": "uint256" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "popFromField", @@ -339,6 +330,11 @@ "internalType": "bytes", "name": "dataToPush", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "pushToField", @@ -367,6 +363,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "setField", @@ -390,6 +391,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "setRecord", @@ -423,6 +429,11 @@ "internalType": "bytes", "name": "dataToSet", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "updateInField", diff --git a/packages/store/abi/IStore.sol/IStoreEphemeral.abi.json b/packages/store/abi/IStore.sol/IStoreEphemeral.abi.json index eb2bb27255..c9cbd9770c 100644 --- a/packages/store/abi/IStore.sol/IStoreEphemeral.abi.json +++ b/packages/store/abi/IStore.sol/IStoreEphemeral.abi.json @@ -40,6 +40,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "emitEphemeralRecord", diff --git a/packages/store/abi/IStore.sol/IStoreHook.abi.json b/packages/store/abi/IStore.sol/IStoreHook.abi.json index f192f8efc5..171784fcb2 100644 --- a/packages/store/abi/IStore.sol/IStoreHook.abi.json +++ b/packages/store/abi/IStore.sol/IStoreHook.abi.json @@ -20,6 +20,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "onAfterSetField", @@ -48,6 +53,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "onBeforeSetField", @@ -66,6 +76,11 @@ "internalType": "bytes32[]", "name": "key", "type": "bytes32[]" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "onDeleteRecord", @@ -89,6 +104,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "onSetRecord", diff --git a/packages/store/abi/IStore.sol/IStoreRead.abi.json b/packages/store/abi/IStore.sol/IStoreRead.abi.json index e6955707bb..ca89eb4ba5 100644 --- a/packages/store/abi/IStore.sol/IStoreRead.abi.json +++ b/packages/store/abi/IStore.sol/IStoreRead.abi.json @@ -15,6 +15,11 @@ "internalType": "uint8", "name": "schemaIndex", "type": "uint8" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "getField", @@ -47,7 +52,7 @@ }, { "internalType": "Schema", - "name": "schema", + "name": "valueSchema", "type": "bytes32" } ], @@ -81,7 +86,7 @@ }, { "internalType": "Schema", - "name": "schema", + "name": "valueSchema", "type": "bytes32" }, { @@ -139,7 +144,7 @@ }, { "internalType": "Schema", - "name": "schema", + "name": "valueSchema", "type": "bytes32" } ], @@ -154,30 +159,6 @@ "stateMutability": "view", "type": "function" }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "table", - "type": "bytes32" - }, - { - "internalType": "bytes32[]", - "name": "key", - "type": "bytes32[]" - } - ], - "name": "getRecord", - "outputs": [ - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "stateMutability": "view", - "type": "function" - }, { "inputs": [ { diff --git a/packages/store/abi/IStore.sol/IStoreWrite.abi.json b/packages/store/abi/IStore.sol/IStoreWrite.abi.json index b15b6bd473..e5a35719c0 100644 --- a/packages/store/abi/IStore.sol/IStoreWrite.abi.json +++ b/packages/store/abi/IStore.sol/IStoreWrite.abi.json @@ -85,6 +85,11 @@ "internalType": "bytes32[]", "name": "key", "type": "bytes32[]" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "deleteRecord", @@ -113,6 +118,11 @@ "internalType": "uint256", "name": "byteLengthToPop", "type": "uint256" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "popFromField", @@ -141,6 +151,11 @@ "internalType": "bytes", "name": "dataToPush", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "pushToField", @@ -169,6 +184,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "setField", @@ -192,6 +212,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "setRecord", @@ -225,6 +250,11 @@ "internalType": "bytes", "name": "dataToSet", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "updateInField", diff --git a/packages/store/abi/MirrorSubscriber.sol/MirrorSubscriber.abi.json b/packages/store/abi/MirrorSubscriber.sol/MirrorSubscriber.abi.json index 0017c899a7..b915714321 100644 --- a/packages/store/abi/MirrorSubscriber.sol/MirrorSubscriber.abi.json +++ b/packages/store/abi/MirrorSubscriber.sol/MirrorSubscriber.abi.json @@ -20,6 +20,22 @@ "stateMutability": "nonpayable", "type": "constructor" }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "length", + "type": "uint256" + } + ], + "name": "SchemaLib_InvalidLength", + "type": "error" + }, + { + "inputs": [], + "name": "SchemaLib_StaticTypeAfterDynamicType", + "type": "error" + }, { "inputs": [ { @@ -57,22 +73,6 @@ "name": "StoreCore_InvalidDataLength", "type": "error" }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "tableId", - "type": "bytes32" - }, - { - "internalType": "string", - "name": "tableIdString", - "type": "string" - } - ], - "name": "StoreCore_TableNotFound", - "type": "error" - }, { "inputs": [ { @@ -94,6 +94,11 @@ "internalType": "bytes", "name": "", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "", + "type": "bytes32" } ], "name": "onAfterSetField", @@ -122,6 +127,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "onBeforeSetField", @@ -140,6 +150,11 @@ "internalType": "bytes32[]", "name": "key", "type": "bytes32[]" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "onDeleteRecord", @@ -163,6 +178,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "onSetRecord", diff --git a/packages/store/abi/StoreCore.sol/StoreCoreExtended.abi.json b/packages/store/abi/StoreCore.sol/StoreCoreExtended.abi.json deleted file mode 100644 index 0637a088a0..0000000000 --- a/packages/store/abi/StoreCore.sol/StoreCoreExtended.abi.json +++ /dev/null @@ -1 +0,0 @@ -[] \ No newline at end of file diff --git a/packages/store/abi/StoreMock.sol/StoreMock.abi.json b/packages/store/abi/StoreMock.sol/StoreMock.abi.json index dcf872c81f..b0bd44ca92 100644 --- a/packages/store/abi/StoreMock.sol/StoreMock.abi.json +++ b/packages/store/abi/StoreMock.sol/StoreMock.abi.json @@ -237,6 +237,11 @@ "internalType": "bytes32[]", "name": "key", "type": "bytes32[]" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "deleteRecord", @@ -260,6 +265,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "emitEphemeralRecord", @@ -283,6 +293,11 @@ "internalType": "uint8", "name": "schemaIndex", "type": "uint8" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "getField", @@ -407,7 +422,7 @@ }, { "internalType": "Schema", - "name": "schema", + "name": "valueSchema", "type": "bytes32" } ], @@ -422,30 +437,6 @@ "stateMutability": "view", "type": "function" }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "table", - "type": "bytes32" - }, - { - "internalType": "bytes32[]", - "name": "key", - "type": "bytes32[]" - } - ], - "name": "getRecord", - "outputs": [ - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "stateMutability": "view", - "type": "function" - }, { "inputs": [ { @@ -486,6 +477,11 @@ "internalType": "uint256", "name": "byteLengthToPop", "type": "uint256" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "popFromField", @@ -514,6 +510,11 @@ "internalType": "bytes", "name": "dataToPush", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "pushToField", @@ -583,6 +584,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "setField", @@ -629,6 +635,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "setRecord", @@ -662,6 +673,11 @@ "internalType": "bytes", "name": "dataToSet", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "updateInField", diff --git a/packages/store/abi/StoreRead.sol/StoreRead.abi.json b/packages/store/abi/StoreRead.sol/StoreRead.abi.json index 3e8785719d..b05f278530 100644 --- a/packages/store/abi/StoreRead.sol/StoreRead.abi.json +++ b/packages/store/abi/StoreRead.sol/StoreRead.abi.json @@ -126,6 +126,11 @@ "internalType": "uint8", "name": "schemaIndex", "type": "uint8" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "getField", @@ -250,7 +255,7 @@ }, { "internalType": "Schema", - "name": "schema", + "name": "valueSchema", "type": "bytes32" } ], @@ -265,30 +270,6 @@ "stateMutability": "view", "type": "function" }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "table", - "type": "bytes32" - }, - { - "internalType": "bytes32[]", - "name": "key", - "type": "bytes32[]" - } - ], - "name": "getRecord", - "outputs": [ - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "stateMutability": "view", - "type": "function" - }, { "inputs": [ { diff --git a/packages/store/abi/StoreReadWithStubs.sol/StoreReadWithStubs.abi.json b/packages/store/abi/StoreReadWithStubs.sol/StoreReadWithStubs.abi.json index 380d5e6255..e2c74d7f0c 100644 --- a/packages/store/abi/StoreReadWithStubs.sol/StoreReadWithStubs.abi.json +++ b/packages/store/abi/StoreReadWithStubs.sol/StoreReadWithStubs.abi.json @@ -242,6 +242,11 @@ "internalType": "bytes32[]", "name": "", "type": "bytes32[]" + }, + { + "internalType": "Schema", + "name": "", + "type": "bytes32" } ], "name": "deleteRecord", @@ -265,6 +270,11 @@ "internalType": "bytes", "name": "", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "", + "type": "bytes32" } ], "name": "emitEphemeralRecord", @@ -288,6 +298,11 @@ "internalType": "uint8", "name": "schemaIndex", "type": "uint8" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "getField", @@ -412,32 +427,8 @@ }, { "internalType": "Schema", - "name": "schema", - "type": "bytes32" - } - ], - "name": "getRecord", - "outputs": [ - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "table", + "name": "valueSchema", "type": "bytes32" - }, - { - "internalType": "bytes32[]", - "name": "key", - "type": "bytes32[]" } ], "name": "getRecord", @@ -491,6 +482,11 @@ "internalType": "uint256", "name": "", "type": "uint256" + }, + { + "internalType": "Schema", + "name": "", + "type": "bytes32" } ], "name": "popFromField", @@ -519,6 +515,11 @@ "internalType": "bytes", "name": "", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "", + "type": "bytes32" } ], "name": "pushToField", @@ -588,6 +589,11 @@ "internalType": "bytes", "name": "", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "", + "type": "bytes32" } ], "name": "setField", @@ -634,6 +640,11 @@ "internalType": "bytes", "name": "", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "", + "type": "bytes32" } ], "name": "setRecord", @@ -667,6 +678,11 @@ "internalType": "bytes", "name": "", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "", + "type": "bytes32" } ], "name": "updateInField", diff --git a/packages/store/gas-report.json b/packages/store/gas-report.json index 0cb345757d..02ec7cb886 100644 --- a/packages/store/gas-report.json +++ b/packages/store/gas-report.json @@ -261,13 +261,13 @@ "file": "test/Mixed.t.sol", "test": "testSetAndGet", "name": "set record in Mixed", - "gasUsed": 110021 + "gasUsed": 111113 }, { "file": "test/Mixed.t.sol", "test": "testSetAndGet", "name": "get record from Mixed", - "gasUsed": 12272 + "gasUsed": 12270 }, { "file": "test/PackedCounter.t.sol", @@ -483,61 +483,61 @@ "file": "test/StoreCoreDynamic.t.sol", "test": "testPopFromSecondField", "name": "pop from field (cold, 1 slot, 1 uint32 item)", - "gasUsed": 30234 + "gasUsed": 25220 }, { "file": "test/StoreCoreDynamic.t.sol", "test": "testPopFromSecondField", "name": "pop from field (warm, 1 slot, 1 uint32 item)", - "gasUsed": 18289 + "gasUsed": 17251 }, { "file": "test/StoreCoreDynamic.t.sol", "test": "testPopFromThirdField", "name": "pop from field (cold, 2 slots, 10 uint32 items)", - "gasUsed": 31984 + "gasUsed": 26970 }, { "file": "test/StoreCoreDynamic.t.sol", "test": "testPopFromThirdField", "name": "pop from field (warm, 2 slots, 10 uint32 items)", - "gasUsed": 18039 + "gasUsed": 17001 }, { "file": "test/StoreCoreGas.t.sol", "test": "testAccessEmptyData", "name": "access non-existing record", - "gasUsed": 7267 + "gasUsed": 6085 }, { "file": "test/StoreCoreGas.t.sol", "test": "testAccessEmptyData", "name": "access static field of non-existing record", - "gasUsed": 2758 + "gasUsed": 1569 }, { "file": "test/StoreCoreGas.t.sol", "test": "testAccessEmptyData", "name": "access dynamic field of non-existing record", - "gasUsed": 3420 + "gasUsed": 2227 }, { "file": "test/StoreCoreGas.t.sol", "test": "testAccessEmptyData", "name": "access length of dynamic field of non-existing record", - "gasUsed": 1328 + "gasUsed": 1327 }, { "file": "test/StoreCoreGas.t.sol", "test": "testAccessEmptyData", "name": "access slice of dynamic field of non-existing record", - "gasUsed": 1202 + "gasUsed": 1201 }, { "file": "test/StoreCoreGas.t.sol", "test": "testDeleteData", "name": "delete record (complex data, 3 slots)", - "gasUsed": 10000 + "gasUsed": 8973 }, { "file": "test/StoreCoreGas.t.sol", @@ -555,61 +555,61 @@ "file": "test/StoreCoreGas.t.sol", "test": "testHooks", "name": "register subscriber", - "gasUsed": 65852 + "gasUsed": 64193 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooks", "name": "set record on table with subscriber", - "gasUsed": 73501 + "gasUsed": 71618 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooks", "name": "set static field on table with subscriber", - "gasUsed": 29436 + "gasUsed": 27532 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooks", "name": "delete record on table with subscriber", - "gasUsed": 22078 + "gasUsed": 20037 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", "name": "register subscriber", - "gasUsed": 65852 + "gasUsed": 64193 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", "name": "set (dynamic) record on table with subscriber", - "gasUsed": 166830 + "gasUsed": 164922 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", "name": "set (dynamic) field on table with subscriber", - "gasUsed": 32510 + "gasUsed": 30414 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", "name": "delete (dynamic) record on table with subscriber", - "gasUsed": 23544 + "gasUsed": 21597 }, { "file": "test/StoreCoreGas.t.sol", "test": "testPushToField", "name": "push to field (1 slot, 1 uint32 item)", - "gasUsed": 15911 + "gasUsed": 14866 }, { "file": "test/StoreCoreGas.t.sol", "test": "testPushToField", "name": "push to field (2 slots, 10 uint32 items)", - "gasUsed": 38572 + "gasUsed": 37512 }, { "file": "test/StoreCoreGas.t.sol", @@ -633,13 +633,13 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetDynamicData", "name": "set complex record with dynamic data (4 slots)", - "gasUsed": 108618 + "gasUsed": 105598 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetDynamicData", "name": "get complex record with dynamic data (4 slots)", - "gasUsed": 6280 + "gasUsed": 5089 }, { "file": "test/StoreCoreGas.t.sol", @@ -651,7 +651,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetDynamicData", "name": "compare: Set complex record with dynamic data using abi.encode", - "gasUsed": 267369 + "gasUsed": 267368 }, { "file": "test/StoreCoreGas.t.sol", @@ -675,55 +675,55 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "set static field (1 slot)", - "gasUsed": 38931 + "gasUsed": 35914 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "get static field (1 slot)", - "gasUsed": 2759 + "gasUsed": 1569 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "set static field (overlap 2 slot)", - "gasUsed": 33878 + "gasUsed": 32849 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "get static field (overlap 2 slot)", - "gasUsed": 3580 + "gasUsed": 2383 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "set dynamic field (1 slot, first dynamic field)", - "gasUsed": 56358 + "gasUsed": 55302 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "get dynamic field (1 slot, first dynamic field)", - "gasUsed": 3609 + "gasUsed": 2404 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "set dynamic field (1 slot, second dynamic field)", - "gasUsed": 34491 + "gasUsed": 33420 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetField", "name": "get dynamic field (1 slot, second dynamic field)", - "gasUsed": 3625 + "gasUsed": 2411 }, { "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetStaticData", "name": "set static record (1 slot)", - "gasUsed": 38393 + "gasUsed": 35388 }, { "file": "test/StoreCoreGas.t.sol", @@ -735,7 +735,7 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetAndGetStaticDataSpanningWords", "name": "set static record (2 slots)", - "gasUsed": 60898 + "gasUsed": 57893 }, { "file": "test/StoreCoreGas.t.sol", @@ -747,31 +747,31 @@ "file": "test/StoreCoreGas.t.sol", "test": "testSetMetadata", "name": "StoreCore: set table metadata", - "gasUsed": 251738 + "gasUsed": 248815 }, { "file": "test/StoreCoreGas.t.sol", "test": "testUpdateInField", "name": "update in field (1 slot, 1 uint32 item)", - "gasUsed": 15433 + "gasUsed": 14402 }, { "file": "test/StoreCoreGas.t.sol", "test": "testUpdateInField", "name": "push to field (2 slots, 6 uint64 items)", - "gasUsed": 16474 + "gasUsed": 15431 }, { "file": "test/StoreMetadata.t.sol", "test": "testSetAndGet", "name": "set record in StoreMetadataTable", - "gasUsed": 250211 + "gasUsed": 247577 }, { "file": "test/StoreMetadata.t.sol", "test": "testSetAndGet", "name": "get record from StoreMetadataTable", - "gasUsed": 11412 + "gasUsed": 11408 }, { "file": "test/StoreSwitch.t.sol", @@ -789,79 +789,79 @@ "file": "test/tables/Callbacks.t.sol", "test": "testSetAndGet", "name": "Callbacks: set field", - "gasUsed": 61383 + "gasUsed": 59929 }, { "file": "test/tables/Callbacks.t.sol", "test": "testSetAndGet", "name": "Callbacks: get field (warm)", - "gasUsed": 5051 + "gasUsed": 5278 }, { "file": "test/tables/Callbacks.t.sol", "test": "testSetAndGet", "name": "Callbacks: push 1 element", - "gasUsed": 39268 + "gasUsed": 39797 }, { "file": "test/tables/Hooks.t.sol", "test": "testTable", "name": "Hooks: set field (cold)", - "gasUsed": 63374 + "gasUsed": 61928 }, { "file": "test/tables/Hooks.t.sol", "test": "testTable", "name": "Hooks: get field (warm)", - "gasUsed": 5035 + "gasUsed": 5281 }, { "file": "test/tables/Hooks.t.sol", "test": "testTable", "name": "Hooks: push 1 element (cold)", - "gasUsed": 39262 + "gasUsed": 39799 }, { "file": "test/tables/Hooks.t.sol", "test": "testTable", "name": "Hooks: pop 1 element (warm)", - "gasUsed": 15741 + "gasUsed": 16265 }, { "file": "test/tables/Hooks.t.sol", "test": "testTable", "name": "Hooks: push 1 element (warm)", - "gasUsed": 17449 + "gasUsed": 17957 }, { "file": "test/tables/Hooks.t.sol", "test": "testTable", "name": "Hooks: update 1 element (warm)", - "gasUsed": 17170 + "gasUsed": 17664 }, { "file": "test/tables/Hooks.t.sol", "test": "testTable", "name": "Hooks: delete record (warm)", - "gasUsed": 10501 + "gasUsed": 11002 }, { "file": "test/tables/Hooks.t.sol", "test": "testTable", "name": "Hooks: set field (warm)", - "gasUsed": 33677 + "gasUsed": 34154 }, { "file": "test/tables/HooksColdLoad.t.sol", "test": "testDelete", "name": "Hooks: delete record (cold)", - "gasUsed": 21230 + "gasUsed": 19797 }, { "file": "test/tables/HooksColdLoad.t.sol", "test": "testGet", "name": "Hooks: get field (cold)", - "gasUsed": 13020 + "gasUsed": 11270 }, { "file": "test/tables/HooksColdLoad.t.sol", @@ -879,13 +879,13 @@ "file": "test/tables/HooksColdLoad.t.sol", "test": "testPop", "name": "Hooks: pop 1 element (cold)", - "gasUsed": 27833 + "gasUsed": 26387 }, { "file": "test/tables/HooksColdLoad.t.sol", "test": "testUpdate", "name": "Hooks: update 1 element (cold)", - "gasUsed": 28683 + "gasUsed": 27237 }, { "file": "test/tightcoder/DecodeSlice.t.sol", @@ -945,12 +945,12 @@ "file": "test/Vector2.t.sol", "test": "testSetAndGet", "name": "set Vector2 record", - "gasUsed": 37212 + "gasUsed": 36699 }, { "file": "test/Vector2.t.sol", "test": "testSetAndGet", "name": "get Vector2 record", - "gasUsed": 4549 + "gasUsed": 4548 } ] diff --git a/packages/store/src/IStore.sol b/packages/store/src/IStore.sol index 9bec85453c..6f66e7699c 100644 --- a/packages/store/src/IStore.sol +++ b/packages/store/src/IStore.sol @@ -9,21 +9,27 @@ interface IStoreRead { function getKeySchema(bytes32 table) external view returns (Schema schema); - // Get full record (including full array, load table schema from storage) - function getRecord(bytes32 table, bytes32[] memory key) external view returns (bytes memory data); - // Get full record (including full array) - function getRecord(bytes32 table, bytes32[] calldata key, Schema schema) external view returns (bytes memory data); + function getRecord( + bytes32 table, + bytes32[] calldata key, + Schema valueSchema + ) external view returns (bytes memory data); // Get partial data at schema index - function getField(bytes32 table, bytes32[] calldata key, uint8 schemaIndex) external view returns (bytes memory data); + function getField( + bytes32 table, + bytes32[] calldata key, + uint8 schemaIndex, + Schema valueSchema + ) external view returns (bytes memory data); // Get field length at schema index function getFieldLength( bytes32 table, bytes32[] memory key, uint8 schemaIndex, - Schema schema + Schema valueSchema ) external view returns (uint256); // Get start:end slice of the field at schema index @@ -31,7 +37,7 @@ interface IStoreRead { bytes32 table, bytes32[] memory key, uint8 schemaIndex, - Schema schema, + Schema valueSchema, uint256 start, uint256 end ) external view returns (bytes memory data); @@ -43,16 +49,34 @@ interface IStoreWrite { event StoreDeleteRecord(bytes32 table, bytes32[] key); // Set full record (including full dynamic data) - function setRecord(bytes32 table, bytes32[] calldata key, bytes calldata data) external; + function setRecord(bytes32 table, bytes32[] calldata key, bytes calldata data, Schema valueSchema) external; // Set partial data at schema index - function setField(bytes32 table, bytes32[] calldata key, uint8 schemaIndex, bytes calldata data) external; + function setField( + bytes32 table, + bytes32[] calldata key, + uint8 schemaIndex, + bytes calldata data, + Schema valueSchema + ) external; // Push encoded items to the dynamic field at schema index - function pushToField(bytes32 table, bytes32[] calldata key, uint8 schemaIndex, bytes calldata dataToPush) external; + function pushToField( + bytes32 table, + bytes32[] calldata key, + uint8 schemaIndex, + bytes calldata dataToPush, + Schema valueSchema + ) external; // Pop byte length from the dynamic field at schema index - function popFromField(bytes32 table, bytes32[] calldata key, uint8 schemaIndex, uint256 byteLengthToPop) external; + function popFromField( + bytes32 table, + bytes32[] calldata key, + uint8 schemaIndex, + uint256 byteLengthToPop, + Schema valueSchema + ) external; // Change encoded items within the dynamic field at schema index function updateInField( @@ -60,18 +84,19 @@ interface IStoreWrite { bytes32[] calldata key, uint8 schemaIndex, uint256 startByteIndex, - bytes calldata dataToSet + bytes calldata dataToSet, + Schema valueSchema ) external; // Set full record (including full dynamic data) - function deleteRecord(bytes32 table, bytes32[] memory key) external; + function deleteRecord(bytes32 table, bytes32[] memory key, Schema valueSchema) external; } interface IStoreEphemeral { event StoreEphemeralRecord(bytes32 table, bytes32[] key, bytes data); // Emit the ephemeral event without modifying storage - function emitEphemeralRecord(bytes32 table, bytes32[] calldata key, bytes calldata data) external; + function emitEphemeralRecord(bytes32 table, bytes32[] calldata key, bytes calldata data, Schema valueSchema) external; } /** @@ -100,12 +125,24 @@ interface IStoreRegistration { interface IStore is IStoreData, IStoreRegistration, IStoreEphemeral, IStoreErrors {} interface IStoreHook { - function onSetRecord(bytes32 table, bytes32[] memory key, bytes memory data) external; + function onSetRecord(bytes32 table, bytes32[] memory key, bytes memory data, Schema valueSchema) external; // Split onSetField into pre and post to simplify the implementation of hooks - function onBeforeSetField(bytes32 table, bytes32[] memory key, uint8 schemaIndex, bytes memory data) external; + function onBeforeSetField( + bytes32 table, + bytes32[] memory key, + uint8 schemaIndex, + bytes memory data, + Schema valueSchema + ) external; - function onAfterSetField(bytes32 table, bytes32[] memory key, uint8 schemaIndex, bytes memory data) external; + function onAfterSetField( + bytes32 table, + bytes32[] memory key, + uint8 schemaIndex, + bytes memory data, + Schema valueSchema + ) external; - function onDeleteRecord(bytes32 table, bytes32[] memory key) external; + function onDeleteRecord(bytes32 table, bytes32[] memory key, Schema valueSchema) external; } diff --git a/packages/store/src/StoreCore.sol b/packages/store/src/StoreCore.sol index 6f8ec8a26e..14aabf2961 100644 --- a/packages/store/src/StoreCore.sol +++ b/packages/store/src/StoreCore.sol @@ -71,9 +71,9 @@ library StoreCore { /** * Get the schema for the given tableId */ - function getSchema(bytes32 tableId) internal view returns (Schema schema) { - schema = StoreCoreInternal._getSchema(tableId); - if (schema.isEmpty()) { + function getSchema(bytes32 tableId) internal view returns (Schema valueSchema) { + valueSchema = StoreCoreInternal._getSchema(tableId); + if (valueSchema.isEmpty()) { revert IStoreErrors.StoreCore_TableNotFound(tableId, string(abi.encodePacked(tableId))); } } @@ -117,11 +117,11 @@ library StoreCore { * Set metadata for a given tableId */ function setMetadata(bytes32 tableId, string memory tableName, string[] memory fieldNames) internal { - Schema schema = getSchema(tableId); + Schema valueSchema = getSchema(tableId); // Verify the number of field names corresponds to the schema length - if (!(fieldNames.length == 0 || fieldNames.length == schema.numFields())) { - revert IStoreErrors.StoreCore_InvalidFieldNamesLength(schema.numFields(), fieldNames.length); + if (!(fieldNames.length == 0 || fieldNames.length == valueSchema.numFields())) { + revert IStoreErrors.StoreCore_InvalidFieldNamesLength(valueSchema.numFields(), fieldNames.length); } // Set metadata @@ -148,15 +148,14 @@ library StoreCore { ************************************************************************/ /** - * Set full data record for the given tableId and key tuple (static and dynamic data) + * Set full data record for the given tableId and key tuple and schema */ - function setRecord(bytes32 tableId, bytes32[] memory key, bytes memory data) internal { + function setRecord(bytes32 tableId, bytes32[] memory key, bytes memory data, Schema valueSchema) internal { // verify the value has the correct length for the tableId (based on the tableId's schema) // to prevent invalid data from being stored - Schema schema = getSchema(tableId); // Verify static data length + dynamic data length matches the given data - (uint256 staticLength, PackedCounter dynamicLength) = StoreCoreInternal._validateDataLength(schema, data); + (uint256 staticLength, PackedCounter dynamicLength) = StoreCoreInternal._validateDataLength(valueSchema, data); // Emit event to notify indexers emit StoreSetRecord(tableId, key, data); @@ -165,7 +164,7 @@ library StoreCore { address[] memory hooks = Hooks.get(tableId); for (uint256 i; i < hooks.length; i++) { IStoreHook hook = IStoreHook(hooks[i]); - hook.onSetRecord(tableId, key, data); + hook.onSetRecord(tableId, key, data, valueSchema); } // Store the static data at the static data location @@ -180,7 +179,7 @@ library StoreCore { memoryPointer += staticLength + 32; // move the memory pointer to the start of the dynamic data (skip the encoded dynamic length) // If there is no dynamic data, we're done - if (schema.numDynamicFields() == 0) return; + if (valueSchema.numDynamicFields() == 0) return; // Store the dynamic data length at the dynamic data length location uint256 dynamicDataLengthLocation = StoreCoreInternal._getDynamicDataLengthLocation(tableId, key); @@ -189,7 +188,7 @@ library StoreCore { // For every dynamic element, slice off the dynamic data and store it at the dynamic location uint256 dynamicDataLocation; uint256 dynamicDataLength; - for (uint8 i; i < schema.numDynamicFields(); ) { + for (uint8 i; i < valueSchema.numDynamicFields(); ) { dynamicDataLocation = StoreCoreInternal._getDynamicDataLocation(tableId, key, i); dynamicDataLength = dynamicLength.atIndex(i); Storage.store({ @@ -205,9 +204,16 @@ library StoreCore { } } - function setField(bytes32 tableId, bytes32[] memory key, uint8 schemaIndex, bytes memory data) internal { - Schema schema = getSchema(tableId); - + /** + * Set data for a field in a table with the given tableId, key tuple and value schema + */ + function setField( + bytes32 tableId, + bytes32[] memory key, + uint8 schemaIndex, + bytes memory data, + Schema valueSchema + ) internal { // Emit event to notify indexers emit StoreSetField(tableId, key, schemaIndex, data); @@ -216,25 +222,26 @@ library StoreCore { for (uint256 i; i < hooks.length; i++) { IStoreHook hook = IStoreHook(hooks[i]); - hook.onBeforeSetField(tableId, key, schemaIndex, data); + hook.onBeforeSetField(tableId, key, schemaIndex, data, valueSchema); } - if (schemaIndex < schema.numStaticFields()) { - StoreCoreInternal._setStaticField(tableId, key, schema, schemaIndex, data); + if (schemaIndex < valueSchema.numStaticFields()) { + StoreCoreInternal._setStaticField(tableId, key, valueSchema, schemaIndex, data); } else { - StoreCoreInternal._setDynamicField(tableId, key, schema, schemaIndex, data); + StoreCoreInternal._setDynamicField(tableId, key, valueSchema, schemaIndex, data); } // Call onAfterSetField hooks (after modifying the state) for (uint256 i; i < hooks.length; i++) { IStoreHook hook = IStoreHook(hooks[i]); - hook.onAfterSetField(tableId, key, schemaIndex, data); + hook.onAfterSetField(tableId, key, schemaIndex, data, valueSchema); } } - function deleteRecord(bytes32 tableId, bytes32[] memory key) internal { - Schema schema = getSchema(tableId); - + /** + * Delete a record for the given tableId, key tuple and value schema + */ + function deleteRecord(bytes32 tableId, bytes32[] memory key, Schema valueSchema) internal { // Emit event to notify indexers emit StoreDeleteRecord(tableId, key); @@ -242,31 +249,38 @@ library StoreCore { address[] memory hooks = Hooks.get(tableId); for (uint256 i; i < hooks.length; i++) { IStoreHook hook = IStoreHook(hooks[i]); - hook.onDeleteRecord(tableId, key); + hook.onDeleteRecord(tableId, key, valueSchema); } // Delete static data uint256 staticDataLocation = StoreCoreInternal._getStaticDataLocation(tableId, key); - Storage.store({ storagePointer: staticDataLocation, offset: 0, data: new bytes(schema.staticDataLength()) }); + Storage.store({ storagePointer: staticDataLocation, offset: 0, data: new bytes(valueSchema.staticDataLength()) }); // If there are no dynamic fields, we're done - if (schema.numDynamicFields() == 0) return; + if (valueSchema.numDynamicFields() == 0) return; // Delete dynamic data length uint256 dynamicDataLengthLocation = StoreCoreInternal._getDynamicDataLengthLocation(tableId, key); Storage.store({ storagePointer: dynamicDataLengthLocation, data: bytes32(0) }); } - function pushToField(bytes32 tableId, bytes32[] memory key, uint8 schemaIndex, bytes memory dataToPush) internal { - Schema schema = getSchema(tableId); - - if (schemaIndex < schema.numStaticFields()) { + /** + * Push data to a field in a table with the given tableId, key tuple and value schema + */ + function pushToField( + bytes32 tableId, + bytes32[] memory key, + uint8 schemaIndex, + bytes memory dataToPush, + Schema valueSchema + ) internal { + if (schemaIndex < valueSchema.numStaticFields()) { revert IStoreErrors.StoreCore_NotDynamicField(); } // TODO add push-specific event and hook to avoid the storage read? (https://github.com/latticexyz/mud/issues/444) bytes memory fullData = abi.encodePacked( - StoreCoreInternal._getDynamicField(tableId, key, schemaIndex, schema), + StoreCoreInternal._getDynamicField(tableId, key, schemaIndex, valueSchema), dataToPush ); @@ -277,29 +291,36 @@ library StoreCore { address[] memory hooks = Hooks.get(tableId); for (uint256 i; i < hooks.length; i++) { IStoreHook hook = IStoreHook(hooks[i]); - hook.onBeforeSetField(tableId, key, schemaIndex, fullData); + hook.onBeforeSetField(tableId, key, schemaIndex, fullData, valueSchema); } - StoreCoreInternal._pushToDynamicField(tableId, key, schema, schemaIndex, dataToPush); + StoreCoreInternal._pushToDynamicField(tableId, key, valueSchema, schemaIndex, dataToPush); // Call onAfterSetField hooks (after modifying the state) for (uint256 i; i < hooks.length; i++) { IStoreHook hook = IStoreHook(hooks[i]); - hook.onAfterSetField(tableId, key, schemaIndex, fullData); + hook.onAfterSetField(tableId, key, schemaIndex, fullData, valueSchema); } } - function popFromField(bytes32 tableId, bytes32[] memory key, uint8 schemaIndex, uint256 byteLengthToPop) internal { - Schema schema = getSchema(tableId); - - if (schemaIndex < schema.numStaticFields()) { + /** + * Pop data from a field in a table with the given tableId, key tuple and value schema + */ + function popFromField( + bytes32 tableId, + bytes32[] memory key, + uint8 schemaIndex, + uint256 byteLengthToPop, + Schema valueSchema + ) internal { + if (schemaIndex < valueSchema.numStaticFields()) { revert IStoreErrors.StoreCore_NotDynamicField(); } // TODO add pop-specific event and hook to avoid the storage read? (https://github.com/latticexyz/mud/issues/444) bytes memory fullData; { - bytes memory oldData = StoreCoreInternal._getDynamicField(tableId, key, schemaIndex, schema); + bytes memory oldData = StoreCoreInternal._getDynamicField(tableId, key, schemaIndex, valueSchema); fullData = SliceLib.getSubslice(oldData, 0, oldData.length - byteLengthToPop).toBytes(); } @@ -310,28 +331,30 @@ library StoreCore { address[] memory hooks = Hooks.get(tableId); for (uint256 i; i < hooks.length; i++) { IStoreHook hook = IStoreHook(hooks[i]); - hook.onBeforeSetField(tableId, key, schemaIndex, fullData); + hook.onBeforeSetField(tableId, key, schemaIndex, fullData, valueSchema); } - StoreCoreInternal._popFromDynamicField(tableId, key, schema, schemaIndex, byteLengthToPop); + StoreCoreInternal._popFromDynamicField(tableId, key, valueSchema, schemaIndex, byteLengthToPop); // Call onAfterSetField hooks (after modifying the state) for (uint256 i; i < hooks.length; i++) { IStoreHook hook = IStoreHook(hooks[i]); - hook.onAfterSetField(tableId, key, schemaIndex, fullData); + hook.onAfterSetField(tableId, key, schemaIndex, fullData, valueSchema); } } + /** + * Update data in a field in a table with the given tableId, key tuple and value schema + */ function updateInField( bytes32 tableId, bytes32[] memory key, uint8 schemaIndex, uint256 startByteIndex, - bytes memory dataToSet + bytes memory dataToSet, + Schema valueSchema ) internal { - Schema schema = getSchema(tableId); - - if (schemaIndex < schema.numStaticFields()) { + if (schemaIndex < valueSchema.numStaticFields()) { revert IStoreErrors.StoreCore_NotDynamicField(); } // index must be checked because it could be arbitrarily large @@ -343,7 +366,7 @@ library StoreCore { // TODO add setItem-specific event and hook to avoid the storage read? (https://github.com/latticexyz/mud/issues/444) bytes memory fullData; { - bytes memory oldData = StoreCoreInternal._getDynamicField(tableId, key, schemaIndex, schema); + bytes memory oldData = StoreCoreInternal._getDynamicField(tableId, key, schemaIndex, valueSchema); fullData = abi.encodePacked( SliceLib.getSubslice(oldData, 0, startByteIndex).toBytes(), dataToSet, @@ -358,15 +381,15 @@ library StoreCore { address[] memory hooks = Hooks.get(tableId); for (uint256 i; i < hooks.length; i++) { IStoreHook hook = IStoreHook(hooks[i]); - hook.onBeforeSetField(tableId, key, schemaIndex, fullData); + hook.onBeforeSetField(tableId, key, schemaIndex, fullData, valueSchema); } - StoreCoreInternal._setDynamicFieldItem(tableId, key, schema, schemaIndex, startByteIndex, dataToSet); + StoreCoreInternal._setDynamicFieldItem(tableId, key, valueSchema, schemaIndex, startByteIndex, dataToSet); // Call onAfterSetField hooks (after modifying the state) for (uint256 i; i < hooks.length; i++) { IStoreHook hook = IStoreHook(hooks[i]); - hook.onAfterSetField(tableId, key, schemaIndex, fullData); + hook.onAfterSetField(tableId, key, schemaIndex, fullData, valueSchema); } } @@ -379,13 +402,9 @@ library StoreCore { /** * Emit the ephemeral event without modifying storage for the full data of the given tableId and key tuple */ - function emitEphemeralRecord(bytes32 tableId, bytes32[] memory key, bytes memory data) internal { - // verify the value has the correct length for the tableId (based on the tableId's schema) - // to prevent invalid data from being emitted - Schema schema = getSchema(tableId); - + function emitEphemeralRecord(bytes32 tableId, bytes32[] memory key, bytes memory data, Schema valueSchema) internal { // Verify static data length + dynamic data length matches the given data - StoreCoreInternal._validateDataLength(schema, data); + StoreCoreInternal._validateDataLength(valueSchema, data); // Emit event to notify indexers emit StoreEphemeralRecord(tableId, key, data); @@ -394,7 +413,7 @@ library StoreCore { address[] memory hooks = Hooks.get(tableId); for (uint256 i; i < hooks.length; i++) { IStoreHook hook = IStoreHook(hooks[i]); - hook.onSetRecord(tableId, key, data); + hook.onSetRecord(tableId, key, data, valueSchema); } } @@ -405,24 +424,16 @@ library StoreCore { ************************************************************************/ /** - * Get full record (all fields, static and dynamic data) for the given tableId and key tuple (loading schema from storage) + * Get full record (all fields, static and dynamic data) for the given tableId and key tuple, with the given value schema */ - function getRecord(bytes32 tableId, bytes32[] memory key) internal view returns (bytes memory) { - Schema schema = getSchema(tableId); - return getRecord(tableId, key, schema); - } - - /** - * Get full record (all fields, static and dynamic data) for the given tableId and key tuple, with the given schema - */ - function getRecord(bytes32 tableId, bytes32[] memory key, Schema schema) internal view returns (bytes memory) { + function getRecord(bytes32 tableId, bytes32[] memory key, Schema valueSchema) internal view returns (bytes memory) { // Get the static data length - uint256 staticLength = schema.staticDataLength(); + uint256 staticLength = valueSchema.staticDataLength(); uint256 outputLength = staticLength; // Load the dynamic data length if there are dynamic fields PackedCounter dynamicDataLength; - uint256 numDynamicFields = schema.numDynamicFields(); + uint256 numDynamicFields = valueSchema.numDynamicFields(); if (numDynamicFields > 0) { dynamicDataLength = StoreCoreInternal._loadEncodedDynamicDataLength(tableId, key); // TODO should total output include dynamic data length even if it's 0? @@ -464,41 +475,33 @@ library StoreCore { } /** - * Get a single field from the given tableId and key tuple (loading schema from storage) - */ - function getField(bytes32 tableId, bytes32[] memory key, uint8 schemaIndex) internal view returns (bytes memory) { - Schema schema = getSchema(tableId); - return getField(tableId, key, schemaIndex, schema); - } - - /** - * Get a single field from the given tableId and key tuple, with the given schema + * Get a single field from the given tableId and key tuple, with the given value schema */ function getField( bytes32 tableId, bytes32[] memory key, uint8 schemaIndex, - Schema schema + Schema valueSchema ) internal view returns (bytes memory) { - if (schemaIndex < schema.numStaticFields()) { - return StoreCoreInternal._getStaticField(tableId, key, schemaIndex, schema); + if (schemaIndex < valueSchema.numStaticFields()) { + return StoreCoreInternal._getStaticField(tableId, key, schemaIndex, valueSchema); } else { - return StoreCoreInternal._getDynamicField(tableId, key, schemaIndex, schema); + return StoreCoreInternal._getDynamicField(tableId, key, schemaIndex, valueSchema); } } /** - * Get the byte length of a single field from the given tableId and key tuple, with the given schema + * Get the byte length of a single field from the given tableId and key tuple, with the given value schema */ function getFieldLength( bytes32 tableId, bytes32[] memory key, uint8 schemaIndex, - Schema schema + Schema valueSchema ) internal view returns (uint256) { - uint8 numStaticFields = schema.numStaticFields(); + uint8 numStaticFields = valueSchema.numStaticFields(); if (schemaIndex < numStaticFields) { - SchemaType schemaType = schema.atIndex(schemaIndex); + SchemaType schemaType = valueSchema.atIndex(schemaIndex); return schemaType.getStaticByteLength(); } else { // Get the length and storage location of the dynamic field @@ -508,19 +511,19 @@ library StoreCore { } /** - * Get a byte slice (including start, excluding end) of a single dynamic field from the given tableId and key tuple, with the given schema. + * Get a byte slice (including start, excluding end) of a single dynamic field from the given tableId and key tuple, with the given value schema. * The slice is unchecked and will return invalid data if `start`:`end` overflow. */ function getFieldSlice( bytes32 tableId, bytes32[] memory key, uint8 schemaIndex, - Schema schema, + Schema valueSchema, uint256 start, uint256 end ) internal view returns (bytes memory) { - uint8 numStaticFields = schema.numStaticFields(); - if (schemaIndex < schema.numStaticFields()) { + uint8 numStaticFields = valueSchema.numStaticFields(); + if (schemaIndex < valueSchema.numStaticFields()) { revert IStoreErrors.StoreCore_NotDynamicField(); } @@ -579,30 +582,30 @@ library StoreCoreInternal { function _setStaticField( bytes32 tableId, bytes32[] memory key, - Schema schema, + Schema valueSchema, uint8 schemaIndex, bytes memory data ) internal { // verify the value has the correct length for the field - SchemaType schemaType = schema.atIndex(schemaIndex); + SchemaType schemaType = valueSchema.atIndex(schemaIndex); if (schemaType.getStaticByteLength() != data.length) { revert IStoreErrors.StoreCore_InvalidDataLength(schemaType.getStaticByteLength(), data.length); } // Store the provided value in storage uint256 location = _getStaticDataLocation(tableId, key); - uint256 offset = _getStaticDataOffset(schema, schemaIndex); + uint256 offset = _getStaticDataOffset(valueSchema, schemaIndex); Storage.store({ storagePointer: location, offset: offset, data: data }); } function _setDynamicField( bytes32 tableId, bytes32[] memory key, - Schema schema, + Schema valueSchema, uint8 schemaIndex, bytes memory data ) internal { - uint8 dynamicSchemaIndex = schemaIndex - schema.numStaticFields(); + uint8 dynamicSchemaIndex = schemaIndex - valueSchema.numStaticFields(); // Update the dynamic data length _setDynamicDataLengthAtIndex(tableId, key, dynamicSchemaIndex, data.length); @@ -615,11 +618,11 @@ library StoreCoreInternal { function _pushToDynamicField( bytes32 tableId, bytes32[] memory key, - Schema schema, + Schema valueSchema, uint8 schemaIndex, bytes memory dataToPush ) internal { - uint8 dynamicSchemaIndex = schemaIndex - schema.numStaticFields(); + uint8 dynamicSchemaIndex = schemaIndex - valueSchema.numStaticFields(); // Load dynamic data length from storage uint256 dynamicSchemaLengthSlot = _getDynamicDataLengthLocation(tableId, key); @@ -639,11 +642,11 @@ library StoreCoreInternal { function _popFromDynamicField( bytes32 tableId, bytes32[] memory key, - Schema schema, + Schema valueSchema, uint8 schemaIndex, uint256 byteLengthToPop ) internal { - uint8 dynamicSchemaIndex = schemaIndex - schema.numStaticFields(); + uint8 dynamicSchemaIndex = schemaIndex - valueSchema.numStaticFields(); // Load dynamic data length from storage uint256 dynamicSchemaLengthSlot = _getDynamicDataLengthLocation(tableId, key); @@ -663,12 +666,12 @@ library StoreCoreInternal { function _setDynamicFieldItem( bytes32 tableId, bytes32[] memory key, - Schema schema, + Schema valueSchema, uint8 schemaIndex, uint256 startByteIndex, bytes memory dataToSet ) internal { - uint8 dynamicSchemaIndex = schemaIndex - schema.numStaticFields(); + uint8 dynamicSchemaIndex = schemaIndex - valueSchema.numStaticFields(); // Set `dataToSet` at the given index _setPartialDynamicData(tableId, key, dynamicSchemaIndex, startByteIndex, dataToSet); @@ -680,14 +683,6 @@ library StoreCoreInternal { * ************************************************************************/ - /** - * Get full static record for the given tableId and key tuple (loading schema's static length from storage) - */ - function _getStaticData(bytes32 tableId, bytes32[] memory key, uint256 memoryPointer) internal view { - Schema schema = _getSchema(tableId); - _getStaticData(tableId, key, schema.staticDataLength(), memoryPointer); - } - /** * Get full static data for the given tableId and key tuple, with the given static length */ @@ -700,19 +695,19 @@ library StoreCoreInternal { } /** - * Get a single static field from the given tableId and key tuple, with the given schema + * Get a single static field from the given tableId and key tuple, with the given value schema */ function _getStaticField( bytes32 tableId, bytes32[] memory key, uint8 schemaIndex, - Schema schema + Schema valueSchema ) internal view returns (bytes memory) { // Get the length, storage location and offset of the static field - SchemaType schemaType = schema.atIndex(schemaIndex); + SchemaType schemaType = valueSchema.atIndex(schemaIndex); uint256 dataLength = schemaType.getStaticByteLength(); uint256 location = _getStaticDataLocation(tableId, key); - uint256 offset = _getStaticDataOffset(schema, schemaIndex); + uint256 offset = _getStaticDataOffset(valueSchema, schemaIndex); // Load the data from storage @@ -720,16 +715,16 @@ library StoreCoreInternal { } /** - * Get a single dynamic field from the given tableId and key tuple, with the given schema + * Get a single dynamic field from the given tableId and key tuple, with the given value schema */ function _getDynamicField( bytes32 tableId, bytes32[] memory key, uint8 schemaIndex, - Schema schema + Schema valueSchema ) internal view returns (bytes memory) { // Get the length and storage location of the dynamic field - uint8 dynamicSchemaIndex = schemaIndex - schema.numStaticFields(); + uint8 dynamicSchemaIndex = schemaIndex - valueSchema.numStaticFields(); uint256 location = _getDynamicDataLocation(tableId, key, dynamicSchemaIndex); uint256 dataLength = _loadEncodedDynamicDataLength(tableId, key).atIndex(dynamicSchemaIndex); @@ -747,13 +742,13 @@ library StoreCoreInternal { * Returns the static and dynamic lengths */ function _validateDataLength( - Schema schema, + Schema valueSchema, bytes memory data ) internal pure returns (uint256 staticLength, PackedCounter dynamicLength) { - staticLength = schema.staticDataLength(); + staticLength = valueSchema.staticDataLength(); uint256 expectedLength = staticLength; dynamicLength; - if (schema.numDynamicFields() > 0) { + if (valueSchema.numDynamicFields() > 0) { // Dynamic length is encoded at the start of the dynamic length blob dynamicLength = PackedCounter.wrap(Bytes.slice32(data, staticLength)); expectedLength += 32 + dynamicLength.total(); // encoded length + data @@ -776,12 +771,12 @@ library StoreCoreInternal { } /** - * Get storage offset for the given schema and (static length) index + * Get storage offset for the given value schema and (static length) index */ - function _getStaticDataOffset(Schema schema, uint8 schemaIndex) internal pure returns (uint256) { + function _getStaticDataOffset(Schema valueSchema, uint8 schemaIndex) internal pure returns (uint256) { uint256 offset = 0; for (uint256 i; i < schemaIndex; i++) { - offset += schema.atIndex(i).getStaticByteLength(); + offset += valueSchema.atIndex(i).getStaticByteLength(); } return offset; } @@ -809,7 +804,7 @@ library StoreCoreInternal { } /** - * Get the length of the dynamic data for the given schema and index + * Get the length of the dynamic data for the given value schema and index */ function _loadEncodedDynamicDataLength(bytes32 tableId, bytes32[] memory key) internal view returns (PackedCounter) { // Load dynamic data length from storage @@ -818,7 +813,7 @@ library StoreCoreInternal { } /** - * Set the length of the dynamic data (in bytes) for the given schema and index + * Set the length of the dynamic data (in bytes) for the given value schema and index */ function _setDynamicDataLengthAtIndex( bytes32 tableId, @@ -855,30 +850,3 @@ library StoreCoreInternal { Storage.store({ storagePointer: dynamicDataLocation, offset: offset, data: partialData }); } } - -// Overloads for single key and some fixed length array keys for better devex -library StoreCoreExtended { - /************************************************************************ - * - * SET DATA - * - ************************************************************************/ - - /************************************************************************ - * - * GET DATA - * - ************************************************************************/ - function getRecord(bytes32 tableId, bytes32 _key) internal view returns (bytes memory) { - bytes32[] memory key = new bytes32[](1); - key[0] = _key; - return StoreCore.getRecord(tableId, key); - } - - function getData(bytes32 tableId, bytes32[2] memory _key) internal view returns (bytes memory) { - bytes32[] memory key = new bytes32[](2); - key[0] = _key[0]; - key[1] = _key[1]; - return StoreCore.getRecord(tableId, key); - } -} diff --git a/packages/store/src/StoreRead.sol b/packages/store/src/StoreRead.sol index c668816d2f..f15ba8a646 100644 --- a/packages/store/src/StoreRead.sol +++ b/packages/store/src/StoreRead.sol @@ -18,27 +18,23 @@ contract StoreRead is IStoreRead { schema = StoreCore.getKeySchema(table); } - // Get full record (static and dynamic data, load schema from storage) - function getRecord(bytes32 table, bytes32[] calldata key) public view virtual returns (bytes memory data) { - data = StoreCore.getRecord(table, key); - } - // Get full record (static and dynamic data) function getRecord( bytes32 table, bytes32[] calldata key, - Schema schema + Schema valueSchema ) public view virtual returns (bytes memory data) { - data = StoreCore.getRecord(table, key, schema); + data = StoreCore.getRecord(table, key, valueSchema); } // Get partial data at schema index function getField( bytes32 table, bytes32[] calldata key, - uint8 schemaIndex + uint8 schemaIndex, + Schema valueSchema ) public view virtual returns (bytes memory data) { - data = StoreCore.getField(table, key, schemaIndex); + data = StoreCore.getField(table, key, schemaIndex, valueSchema); } function getFieldLength( diff --git a/packages/store/src/StoreReadWithStubs.sol b/packages/store/src/StoreReadWithStubs.sol index ab547f6216..3da61bb020 100644 --- a/packages/store/src/StoreReadWithStubs.sol +++ b/packages/store/src/StoreReadWithStubs.sol @@ -31,35 +31,35 @@ contract StoreReadWithStubs is IStore, StoreRead { /** * Not implemented in StoreReadWithStubs */ - function setRecord(bytes32, bytes32[] calldata, bytes calldata) public virtual { + function setRecord(bytes32, bytes32[] calldata, bytes calldata, Schema) public virtual { revert StoreReadWithStubs_NotImplemented(); } /** * Not implemented in StoreReadWithStubs */ - function setField(bytes32, bytes32[] calldata, uint8, bytes calldata) public virtual { + function setField(bytes32, bytes32[] calldata, uint8, bytes calldata, Schema) public virtual { revert StoreReadWithStubs_NotImplemented(); } /** * Not implemented in StoreReadWithStubs */ - function pushToField(bytes32, bytes32[] calldata, uint8, bytes calldata) public virtual { + function pushToField(bytes32, bytes32[] calldata, uint8, bytes calldata, Schema) public virtual { revert StoreReadWithStubs_NotImplemented(); } /** * Not implemented in StoreReadWithStubs */ - function popFromField(bytes32, bytes32[] calldata, uint8, uint256) public virtual { + function popFromField(bytes32, bytes32[] calldata, uint8, uint256, Schema) public virtual { revert StoreReadWithStubs_NotImplemented(); } /** * Not implemented in StoreReadWithStubs */ - function updateInField(bytes32, bytes32[] calldata, uint8, uint256, bytes calldata) public virtual { + function updateInField(bytes32, bytes32[] calldata, uint8, uint256, bytes calldata, Schema) public virtual { revert StoreReadWithStubs_NotImplemented(); } @@ -73,14 +73,14 @@ contract StoreReadWithStubs is IStore, StoreRead { /** * Not implemented in StoreReadWithStubs */ - function deleteRecord(bytes32, bytes32[] calldata) public virtual { + function deleteRecord(bytes32, bytes32[] calldata, Schema) public virtual { revert StoreReadWithStubs_NotImplemented(); } /** * Not implemented in StoreReadWithStubs */ - function emitEphemeralRecord(bytes32, bytes32[] calldata, bytes calldata) public virtual { + function emitEphemeralRecord(bytes32, bytes32[] calldata, bytes calldata, Schema) public virtual { revert StoreReadWithStubs_NotImplemented(); } } diff --git a/packages/store/src/StoreSwitch.sol b/packages/store/src/StoreSwitch.sol index 1681d1c64e..515a1bc16c 100644 --- a/packages/store/src/StoreSwitch.sol +++ b/packages/store/src/StoreSwitch.sol @@ -89,39 +89,57 @@ library StoreSwitch { } } - function setRecord(bytes32 table, bytes32[] memory key, bytes memory data) internal { + function setRecord(bytes32 table, bytes32[] memory key, bytes memory data, Schema valueSchema) internal { address _storeAddress = getStoreAddress(); if (_storeAddress == address(this)) { - StoreCore.setRecord(table, key, data); + StoreCore.setRecord(table, key, data, valueSchema); } else { - IStore(_storeAddress).setRecord(table, key, data); + IStore(_storeAddress).setRecord(table, key, data, valueSchema); } } - function setField(bytes32 table, bytes32[] memory key, uint8 fieldIndex, bytes memory data) internal { + function setField( + bytes32 table, + bytes32[] memory key, + uint8 fieldIndex, + bytes memory data, + Schema valueSchema + ) internal { address _storeAddress = getStoreAddress(); if (_storeAddress == address(this)) { - StoreCore.setField(table, key, fieldIndex, data); + StoreCore.setField(table, key, fieldIndex, data, valueSchema); } else { - IStore(_storeAddress).setField(table, key, fieldIndex, data); + IStore(_storeAddress).setField(table, key, fieldIndex, data, valueSchema); } } - function pushToField(bytes32 table, bytes32[] memory key, uint8 fieldIndex, bytes memory dataToPush) internal { + function pushToField( + bytes32 table, + bytes32[] memory key, + uint8 fieldIndex, + bytes memory dataToPush, + Schema valueSchema + ) internal { address _storeAddress = getStoreAddress(); if (_storeAddress == address(this)) { - StoreCore.pushToField(table, key, fieldIndex, dataToPush); + StoreCore.pushToField(table, key, fieldIndex, dataToPush, valueSchema); } else { - IStore(_storeAddress).pushToField(table, key, fieldIndex, dataToPush); + IStore(_storeAddress).pushToField(table, key, fieldIndex, dataToPush, valueSchema); } } - function popFromField(bytes32 table, bytes32[] memory key, uint8 fieldIndex, uint256 byteLengthToPop) internal { + function popFromField( + bytes32 table, + bytes32[] memory key, + uint8 fieldIndex, + uint256 byteLengthToPop, + Schema valueSchema + ) internal { address _storeAddress = getStoreAddress(); if (_storeAddress == address(this)) { - StoreCore.popFromField(table, key, fieldIndex, byteLengthToPop); + StoreCore.popFromField(table, key, fieldIndex, byteLengthToPop, valueSchema); } else { - IStore(_storeAddress).popFromField(table, key, fieldIndex, byteLengthToPop); + IStore(_storeAddress).popFromField(table, key, fieldIndex, byteLengthToPop, valueSchema); } } @@ -130,58 +148,55 @@ library StoreSwitch { bytes32[] memory key, uint8 fieldIndex, uint256 startByteIndex, - bytes memory dataToSet + bytes memory dataToSet, + Schema valueSchema ) internal { address _storeAddress = getStoreAddress(); if (_storeAddress == address(this)) { - StoreCore.updateInField(table, key, fieldIndex, startByteIndex, dataToSet); + StoreCore.updateInField(table, key, fieldIndex, startByteIndex, dataToSet, valueSchema); } else { - IStore(_storeAddress).updateInField(table, key, fieldIndex, startByteIndex, dataToSet); + IStore(_storeAddress).updateInField(table, key, fieldIndex, startByteIndex, dataToSet, valueSchema); } } - function deleteRecord(bytes32 table, bytes32[] memory key) internal { + function deleteRecord(bytes32 table, bytes32[] memory key, Schema valueSchema) internal { address _storeAddress = getStoreAddress(); if (_storeAddress == address(this)) { - StoreCore.deleteRecord(table, key); + StoreCore.deleteRecord(table, key, valueSchema); } else { - IStore(_storeAddress).deleteRecord(table, key); + IStore(_storeAddress).deleteRecord(table, key, valueSchema); } } - function emitEphemeralRecord(bytes32 table, bytes32[] memory key, bytes memory data) internal { + function emitEphemeralRecord(bytes32 table, bytes32[] memory key, bytes memory data, Schema valueSchema) internal { address _storeAddress = getStoreAddress(); if (_storeAddress == address(this)) { - StoreCore.emitEphemeralRecord(table, key, data); + StoreCore.emitEphemeralRecord(table, key, data, valueSchema); } else { - IStore(_storeAddress).emitEphemeralRecord(table, key, data); + IStore(_storeAddress).emitEphemeralRecord(table, key, data, valueSchema); } } - function getRecord(bytes32 table, bytes32[] memory key) internal view returns (bytes memory) { + function getRecord(bytes32 table, bytes32[] memory key, Schema valueSchema) internal view returns (bytes memory) { address _storeAddress = getStoreAddress(); if (_storeAddress == address(this)) { - return StoreCore.getRecord(table, key); + return StoreCore.getRecord(table, key, valueSchema); } else { - return IStore(_storeAddress).getRecord(table, key); + return IStore(_storeAddress).getRecord(table, key, valueSchema); } } - function getRecord(bytes32 table, bytes32[] memory key, Schema schema) internal view returns (bytes memory) { - address _storeAddress = getStoreAddress(); - if (_storeAddress == address(this)) { - return StoreCore.getRecord(table, key, schema); - } else { - return IStore(_storeAddress).getRecord(table, key, schema); - } - } - - function getField(bytes32 table, bytes32[] memory key, uint8 fieldIndex) internal view returns (bytes memory) { + function getField( + bytes32 table, + bytes32[] memory key, + uint8 fieldIndex, + Schema valueSchema + ) internal view returns (bytes memory) { address _storeAddress = getStoreAddress(); if (_storeAddress == address(this)) { - return StoreCore.getField(table, key, fieldIndex); + return StoreCore.getField(table, key, fieldIndex, valueSchema); } else { - return IStore(_storeAddress).getField(table, key, fieldIndex); + return IStore(_storeAddress).getField(table, key, fieldIndex, valueSchema); } } diff --git a/packages/store/src/codegen/tables/Callbacks.sol b/packages/store/src/codegen/tables/Callbacks.sol index 40246f80de..6ba8336ef2 100644 --- a/packages/store/src/codegen/tables/Callbacks.sol +++ b/packages/store/src/codegen/tables/Callbacks.sol @@ -70,7 +70,7 @@ library Callbacks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0, getSchema()); return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_bytes24()); } @@ -79,7 +79,7 @@ library Callbacks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - bytes memory _blob = _store.getField(_tableId, _keyTuple, 0); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 0, getSchema()); return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_bytes24()); } @@ -88,7 +88,7 @@ library Callbacks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); + StoreSwitch.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), getSchema()); } /** Set value (using the specified store) */ @@ -96,7 +96,7 @@ library Callbacks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); + _store.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), getSchema()); } /** Get the length of value */ @@ -161,7 +161,7 @@ library Callbacks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); + StoreSwitch.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), getSchema()); } /** Push an element to value (using the specified store) */ @@ -169,7 +169,7 @@ library Callbacks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); + _store.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), getSchema()); } /** Pop an element from value */ @@ -177,7 +177,7 @@ library Callbacks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.popFromField(_tableId, _keyTuple, 0, 24); + StoreSwitch.popFromField(_tableId, _keyTuple, 0, 24, getSchema()); } /** Pop an element from value (using the specified store) */ @@ -185,7 +185,7 @@ library Callbacks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.popFromField(_tableId, _keyTuple, 0, 24); + _store.popFromField(_tableId, _keyTuple, 0, 24, getSchema()); } /** @@ -197,7 +197,7 @@ library Callbacks { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 0, _index * 24, abi.encodePacked((_element))); + StoreSwitch.updateInField(_tableId, _keyTuple, 0, _index * 24, abi.encodePacked((_element)), getSchema()); } } @@ -210,7 +210,7 @@ library Callbacks { _keyTuple[0] = key; unchecked { - _store.updateInField(_tableId, _keyTuple, 0, _index * 24, abi.encodePacked((_element))); + _store.updateInField(_tableId, _keyTuple, 0, _index * 24, abi.encodePacked((_element)), getSchema()); } } @@ -236,7 +236,7 @@ library Callbacks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.deleteRecord(_tableId, _keyTuple); + StoreSwitch.deleteRecord(_tableId, _keyTuple, getSchema()); } /* Delete all data for given keys (using the specified store) */ @@ -244,6 +244,6 @@ library Callbacks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.deleteRecord(_tableId, _keyTuple); + _store.deleteRecord(_tableId, _keyTuple, getSchema()); } } diff --git a/packages/store/src/codegen/tables/Hooks.sol b/packages/store/src/codegen/tables/Hooks.sol index 3815c49696..23168cf52b 100644 --- a/packages/store/src/codegen/tables/Hooks.sol +++ b/packages/store/src/codegen/tables/Hooks.sol @@ -70,7 +70,7 @@ library Hooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0, getSchema()); return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_address()); } @@ -79,7 +79,7 @@ library Hooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - bytes memory _blob = _store.getField(_tableId, _keyTuple, 0); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 0, getSchema()); return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_address()); } @@ -88,7 +88,7 @@ library Hooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); + StoreSwitch.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), getSchema()); } /** Set value (using the specified store) */ @@ -96,7 +96,7 @@ library Hooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); + _store.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), getSchema()); } /** Get the length of value */ @@ -161,7 +161,7 @@ library Hooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); + StoreSwitch.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), getSchema()); } /** Push an element to value (using the specified store) */ @@ -169,7 +169,7 @@ library Hooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); + _store.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), getSchema()); } /** Pop an element from value */ @@ -177,7 +177,7 @@ library Hooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.popFromField(_tableId, _keyTuple, 0, 20); + StoreSwitch.popFromField(_tableId, _keyTuple, 0, 20, getSchema()); } /** Pop an element from value (using the specified store) */ @@ -185,7 +185,7 @@ library Hooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.popFromField(_tableId, _keyTuple, 0, 20); + _store.popFromField(_tableId, _keyTuple, 0, 20, getSchema()); } /** @@ -197,7 +197,7 @@ library Hooks { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 0, _index * 20, abi.encodePacked((_element))); + StoreSwitch.updateInField(_tableId, _keyTuple, 0, _index * 20, abi.encodePacked((_element)), getSchema()); } } @@ -210,7 +210,7 @@ library Hooks { _keyTuple[0] = key; unchecked { - _store.updateInField(_tableId, _keyTuple, 0, _index * 20, abi.encodePacked((_element))); + _store.updateInField(_tableId, _keyTuple, 0, _index * 20, abi.encodePacked((_element)), getSchema()); } } @@ -236,7 +236,7 @@ library Hooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.deleteRecord(_tableId, _keyTuple); + StoreSwitch.deleteRecord(_tableId, _keyTuple, getSchema()); } /* Delete all data for given keys (using the specified store) */ @@ -244,6 +244,6 @@ library Hooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.deleteRecord(_tableId, _keyTuple); + _store.deleteRecord(_tableId, _keyTuple, getSchema()); } } diff --git a/packages/store/src/codegen/tables/KeyEncoding.sol b/packages/store/src/codegen/tables/KeyEncoding.sol index 090f3adc36..b9867fe1d2 100644 --- a/packages/store/src/codegen/tables/KeyEncoding.sol +++ b/packages/store/src/codegen/tables/KeyEncoding.sol @@ -90,7 +90,7 @@ library KeyEncoding { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0, getSchema()); return (_toBool(uint8(Bytes.slice1(_blob, 0)))); } @@ -112,7 +112,7 @@ library KeyEncoding { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - bytes memory _blob = _store.getField(_tableId, _keyTuple, 0); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 0, getSchema()); return (_toBool(uint8(Bytes.slice1(_blob, 0)))); } @@ -126,7 +126,7 @@ library KeyEncoding { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((value))); + StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), getSchema()); } /** Set value (using the specified store) */ @@ -148,7 +148,7 @@ library KeyEncoding { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((value))); + _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), getSchema()); } /** Tightly pack full data using this table's schema */ @@ -186,7 +186,7 @@ library KeyEncoding { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - StoreSwitch.deleteRecord(_tableId, _keyTuple); + StoreSwitch.deleteRecord(_tableId, _keyTuple, getSchema()); } /* Delete all data for given keys (using the specified store) */ @@ -199,7 +199,7 @@ library KeyEncoding { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); - _store.deleteRecord(_tableId, _keyTuple); + _store.deleteRecord(_tableId, _keyTuple, getSchema()); } } diff --git a/packages/store/src/codegen/tables/Mixed.sol b/packages/store/src/codegen/tables/Mixed.sol index 2b5a00b7e2..cf039016a3 100644 --- a/packages/store/src/codegen/tables/Mixed.sol +++ b/packages/store/src/codegen/tables/Mixed.sol @@ -83,7 +83,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0, getSchema()); return (uint32(Bytes.slice4(_blob, 0))); } @@ -92,7 +92,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - bytes memory _blob = _store.getField(_tableId, _keyTuple, 0); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 0, getSchema()); return (uint32(Bytes.slice4(_blob, 0))); } @@ -101,7 +101,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((u32))); + StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((u32)), getSchema()); } /** Set u32 (using the specified store) */ @@ -109,7 +109,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((u32))); + _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((u32)), getSchema()); } /** Get u128 */ @@ -117,7 +117,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 1); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 1, getSchema()); return (uint128(Bytes.slice16(_blob, 0))); } @@ -126,7 +126,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - bytes memory _blob = _store.getField(_tableId, _keyTuple, 1); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 1, getSchema()); return (uint128(Bytes.slice16(_blob, 0))); } @@ -135,7 +135,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField(_tableId, _keyTuple, 1, abi.encodePacked((u128))); + StoreSwitch.setField(_tableId, _keyTuple, 1, abi.encodePacked((u128)), getSchema()); } /** Set u128 (using the specified store) */ @@ -143,7 +143,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 1, abi.encodePacked((u128))); + _store.setField(_tableId, _keyTuple, 1, abi.encodePacked((u128)), getSchema()); } /** Get a32 */ @@ -151,7 +151,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 2); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 2, getSchema()); return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_uint32()); } @@ -160,7 +160,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - bytes memory _blob = _store.getField(_tableId, _keyTuple, 2); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 2, getSchema()); return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_uint32()); } @@ -169,7 +169,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField(_tableId, _keyTuple, 2, EncodeArray.encode((a32))); + StoreSwitch.setField(_tableId, _keyTuple, 2, EncodeArray.encode((a32)), getSchema()); } /** Set a32 (using the specified store) */ @@ -177,7 +177,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 2, EncodeArray.encode((a32))); + _store.setField(_tableId, _keyTuple, 2, EncodeArray.encode((a32)), getSchema()); } /** Get the length of a32 */ @@ -235,7 +235,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.pushToField(_tableId, _keyTuple, 2, abi.encodePacked((_element))); + StoreSwitch.pushToField(_tableId, _keyTuple, 2, abi.encodePacked((_element)), getSchema()); } /** Push an element to a32 (using the specified store) */ @@ -243,7 +243,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.pushToField(_tableId, _keyTuple, 2, abi.encodePacked((_element))); + _store.pushToField(_tableId, _keyTuple, 2, abi.encodePacked((_element)), getSchema()); } /** Pop an element from a32 */ @@ -251,7 +251,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.popFromField(_tableId, _keyTuple, 2, 4); + StoreSwitch.popFromField(_tableId, _keyTuple, 2, 4, getSchema()); } /** Pop an element from a32 (using the specified store) */ @@ -259,7 +259,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.popFromField(_tableId, _keyTuple, 2, 4); + _store.popFromField(_tableId, _keyTuple, 2, 4, getSchema()); } /** @@ -271,7 +271,7 @@ library Mixed { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 2, _index * 4, abi.encodePacked((_element))); + StoreSwitch.updateInField(_tableId, _keyTuple, 2, _index * 4, abi.encodePacked((_element)), getSchema()); } } @@ -284,7 +284,7 @@ library Mixed { _keyTuple[0] = key; unchecked { - _store.updateInField(_tableId, _keyTuple, 2, _index * 4, abi.encodePacked((_element))); + _store.updateInField(_tableId, _keyTuple, 2, _index * 4, abi.encodePacked((_element)), getSchema()); } } @@ -293,7 +293,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 3); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 3, getSchema()); return (string(_blob)); } @@ -302,7 +302,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - bytes memory _blob = _store.getField(_tableId, _keyTuple, 3); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 3, getSchema()); return (string(_blob)); } @@ -311,7 +311,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField(_tableId, _keyTuple, 3, bytes((s))); + StoreSwitch.setField(_tableId, _keyTuple, 3, bytes((s)), getSchema()); } /** Set s (using the specified store) */ @@ -319,7 +319,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 3, bytes((s))); + _store.setField(_tableId, _keyTuple, 3, bytes((s)), getSchema()); } /** Get the length of s */ @@ -377,7 +377,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.pushToField(_tableId, _keyTuple, 3, bytes((_slice))); + StoreSwitch.pushToField(_tableId, _keyTuple, 3, bytes((_slice)), getSchema()); } /** Push a slice to s (using the specified store) */ @@ -385,7 +385,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.pushToField(_tableId, _keyTuple, 3, bytes((_slice))); + _store.pushToField(_tableId, _keyTuple, 3, bytes((_slice)), getSchema()); } /** Pop a slice from s */ @@ -393,7 +393,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.popFromField(_tableId, _keyTuple, 3, 1); + StoreSwitch.popFromField(_tableId, _keyTuple, 3, 1, getSchema()); } /** Pop a slice from s (using the specified store) */ @@ -401,7 +401,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.popFromField(_tableId, _keyTuple, 3, 1); + _store.popFromField(_tableId, _keyTuple, 3, 1, getSchema()); } /** @@ -413,7 +413,7 @@ library Mixed { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 3, _index * 1, bytes((_slice))); + StoreSwitch.updateInField(_tableId, _keyTuple, 3, _index * 1, bytes((_slice)), getSchema()); } } @@ -426,7 +426,7 @@ library Mixed { _keyTuple[0] = key; unchecked { - _store.updateInField(_tableId, _keyTuple, 3, _index * 1, bytes((_slice))); + _store.updateInField(_tableId, _keyTuple, 3, _index * 1, bytes((_slice)), getSchema()); } } @@ -455,7 +455,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setRecord(_tableId, _keyTuple, _data); + StoreSwitch.setRecord(_tableId, _keyTuple, _data, getSchema()); } /** Set the full data using individual values (using the specified store) */ @@ -465,7 +465,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setRecord(_tableId, _keyTuple, _data); + _store.setRecord(_tableId, _keyTuple, _data, getSchema()); } /** Set the full data using the data struct */ @@ -531,7 +531,7 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.deleteRecord(_tableId, _keyTuple); + StoreSwitch.deleteRecord(_tableId, _keyTuple, getSchema()); } /* Delete all data for given keys (using the specified store) */ @@ -539,6 +539,6 @@ library Mixed { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.deleteRecord(_tableId, _keyTuple); + _store.deleteRecord(_tableId, _keyTuple, getSchema()); } } diff --git a/packages/store/src/codegen/tables/StoreMetadata.sol b/packages/store/src/codegen/tables/StoreMetadata.sol index f365448cb8..e37ece34cb 100644 --- a/packages/store/src/codegen/tables/StoreMetadata.sol +++ b/packages/store/src/codegen/tables/StoreMetadata.sol @@ -77,7 +77,7 @@ library StoreMetadata { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0, getSchema()); return (string(_blob)); } @@ -86,7 +86,7 @@ library StoreMetadata { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - bytes memory _blob = _store.getField(_tableId, _keyTuple, 0); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 0, getSchema()); return (string(_blob)); } @@ -95,7 +95,7 @@ library StoreMetadata { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - StoreSwitch.setField(_tableId, _keyTuple, 0, bytes((tableName))); + StoreSwitch.setField(_tableId, _keyTuple, 0, bytes((tableName)), getSchema()); } /** Set tableName (using the specified store) */ @@ -103,7 +103,7 @@ library StoreMetadata { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - _store.setField(_tableId, _keyTuple, 0, bytes((tableName))); + _store.setField(_tableId, _keyTuple, 0, bytes((tableName)), getSchema()); } /** Get the length of tableName */ @@ -161,7 +161,7 @@ library StoreMetadata { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - StoreSwitch.pushToField(_tableId, _keyTuple, 0, bytes((_slice))); + StoreSwitch.pushToField(_tableId, _keyTuple, 0, bytes((_slice)), getSchema()); } /** Push a slice to tableName (using the specified store) */ @@ -169,7 +169,7 @@ library StoreMetadata { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - _store.pushToField(_tableId, _keyTuple, 0, bytes((_slice))); + _store.pushToField(_tableId, _keyTuple, 0, bytes((_slice)), getSchema()); } /** Pop a slice from tableName */ @@ -177,7 +177,7 @@ library StoreMetadata { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - StoreSwitch.popFromField(_tableId, _keyTuple, 0, 1); + StoreSwitch.popFromField(_tableId, _keyTuple, 0, 1, getSchema()); } /** Pop a slice from tableName (using the specified store) */ @@ -185,7 +185,7 @@ library StoreMetadata { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - _store.popFromField(_tableId, _keyTuple, 0, 1); + _store.popFromField(_tableId, _keyTuple, 0, 1, getSchema()); } /** @@ -197,7 +197,7 @@ library StoreMetadata { _keyTuple[0] = tableId; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 0, _index * 1, bytes((_slice))); + StoreSwitch.updateInField(_tableId, _keyTuple, 0, _index * 1, bytes((_slice)), getSchema()); } } @@ -210,7 +210,7 @@ library StoreMetadata { _keyTuple[0] = tableId; unchecked { - _store.updateInField(_tableId, _keyTuple, 0, _index * 1, bytes((_slice))); + _store.updateInField(_tableId, _keyTuple, 0, _index * 1, bytes((_slice)), getSchema()); } } @@ -219,7 +219,7 @@ library StoreMetadata { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 1); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 1, getSchema()); return (bytes(_blob)); } @@ -231,7 +231,7 @@ library StoreMetadata { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - bytes memory _blob = _store.getField(_tableId, _keyTuple, 1); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 1, getSchema()); return (bytes(_blob)); } @@ -240,7 +240,7 @@ library StoreMetadata { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - StoreSwitch.setField(_tableId, _keyTuple, 1, bytes((abiEncodedFieldNames))); + StoreSwitch.setField(_tableId, _keyTuple, 1, bytes((abiEncodedFieldNames)), getSchema()); } /** Set abiEncodedFieldNames (using the specified store) */ @@ -248,7 +248,7 @@ library StoreMetadata { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - _store.setField(_tableId, _keyTuple, 1, bytes((abiEncodedFieldNames))); + _store.setField(_tableId, _keyTuple, 1, bytes((abiEncodedFieldNames)), getSchema()); } /** Get the length of abiEncodedFieldNames */ @@ -310,7 +310,7 @@ library StoreMetadata { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - StoreSwitch.pushToField(_tableId, _keyTuple, 1, bytes((_slice))); + StoreSwitch.pushToField(_tableId, _keyTuple, 1, bytes((_slice)), getSchema()); } /** Push a slice to abiEncodedFieldNames (using the specified store) */ @@ -318,7 +318,7 @@ library StoreMetadata { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - _store.pushToField(_tableId, _keyTuple, 1, bytes((_slice))); + _store.pushToField(_tableId, _keyTuple, 1, bytes((_slice)), getSchema()); } /** Pop a slice from abiEncodedFieldNames */ @@ -326,7 +326,7 @@ library StoreMetadata { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - StoreSwitch.popFromField(_tableId, _keyTuple, 1, 1); + StoreSwitch.popFromField(_tableId, _keyTuple, 1, 1, getSchema()); } /** Pop a slice from abiEncodedFieldNames (using the specified store) */ @@ -334,7 +334,7 @@ library StoreMetadata { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - _store.popFromField(_tableId, _keyTuple, 1, 1); + _store.popFromField(_tableId, _keyTuple, 1, 1, getSchema()); } /** @@ -346,7 +346,7 @@ library StoreMetadata { _keyTuple[0] = tableId; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 1, _index * 1, bytes((_slice))); + StoreSwitch.updateInField(_tableId, _keyTuple, 1, _index * 1, bytes((_slice)), getSchema()); } } @@ -359,7 +359,7 @@ library StoreMetadata { _keyTuple[0] = tableId; unchecked { - _store.updateInField(_tableId, _keyTuple, 1, _index * 1, bytes((_slice))); + _store.updateInField(_tableId, _keyTuple, 1, _index * 1, bytes((_slice)), getSchema()); } } @@ -388,7 +388,7 @@ library StoreMetadata { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - StoreSwitch.setRecord(_tableId, _keyTuple, _data); + StoreSwitch.setRecord(_tableId, _keyTuple, _data, getSchema()); } /** Set the full data using individual values (using the specified store) */ @@ -398,7 +398,7 @@ library StoreMetadata { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - _store.setRecord(_tableId, _keyTuple, _data); + _store.setRecord(_tableId, _keyTuple, _data, getSchema()); } /** Set the full data using the data struct */ @@ -460,7 +460,7 @@ library StoreMetadata { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - StoreSwitch.deleteRecord(_tableId, _keyTuple); + StoreSwitch.deleteRecord(_tableId, _keyTuple, getSchema()); } /* Delete all data for given keys (using the specified store) */ @@ -468,6 +468,6 @@ library StoreMetadata { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; - _store.deleteRecord(_tableId, _keyTuple); + _store.deleteRecord(_tableId, _keyTuple, getSchema()); } } diff --git a/packages/store/src/codegen/tables/Vector2.sol b/packages/store/src/codegen/tables/Vector2.sol index 7f96b6f389..3780408232 100644 --- a/packages/store/src/codegen/tables/Vector2.sol +++ b/packages/store/src/codegen/tables/Vector2.sol @@ -77,7 +77,7 @@ library Vector2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0, getSchema()); return (uint32(Bytes.slice4(_blob, 0))); } @@ -86,7 +86,7 @@ library Vector2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - bytes memory _blob = _store.getField(_tableId, _keyTuple, 0); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 0, getSchema()); return (uint32(Bytes.slice4(_blob, 0))); } @@ -95,7 +95,7 @@ library Vector2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((x))); + StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((x)), getSchema()); } /** Set x (using the specified store) */ @@ -103,7 +103,7 @@ library Vector2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((x))); + _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((x)), getSchema()); } /** Get y */ @@ -111,7 +111,7 @@ library Vector2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 1); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 1, getSchema()); return (uint32(Bytes.slice4(_blob, 0))); } @@ -120,7 +120,7 @@ library Vector2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - bytes memory _blob = _store.getField(_tableId, _keyTuple, 1); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 1, getSchema()); return (uint32(Bytes.slice4(_blob, 0))); } @@ -129,7 +129,7 @@ library Vector2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField(_tableId, _keyTuple, 1, abi.encodePacked((y))); + StoreSwitch.setField(_tableId, _keyTuple, 1, abi.encodePacked((y)), getSchema()); } /** Set y (using the specified store) */ @@ -137,7 +137,7 @@ library Vector2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 1, abi.encodePacked((y))); + _store.setField(_tableId, _keyTuple, 1, abi.encodePacked((y)), getSchema()); } /** Get the full data */ @@ -165,7 +165,7 @@ library Vector2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setRecord(_tableId, _keyTuple, _data); + StoreSwitch.setRecord(_tableId, _keyTuple, _data, getSchema()); } /** Set the full data using individual values (using the specified store) */ @@ -175,7 +175,7 @@ library Vector2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setRecord(_tableId, _keyTuple, _data); + _store.setRecord(_tableId, _keyTuple, _data, getSchema()); } /** Set the full data using the data struct */ @@ -213,7 +213,7 @@ library Vector2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.deleteRecord(_tableId, _keyTuple); + StoreSwitch.deleteRecord(_tableId, _keyTuple, getSchema()); } /* Delete all data for given keys (using the specified store) */ @@ -221,6 +221,6 @@ library Vector2 { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.deleteRecord(_tableId, _keyTuple); + _store.deleteRecord(_tableId, _keyTuple, getSchema()); } } diff --git a/packages/store/test/MirrorSubscriber.sol b/packages/store/test/MirrorSubscriber.sol index 66ee093272..15e616711b 100644 --- a/packages/store/test/MirrorSubscriber.sol +++ b/packages/store/test/MirrorSubscriber.sol @@ -15,20 +15,26 @@ contract MirrorSubscriber is IStoreHook { _table = table; } - function onSetRecord(bytes32 table, bytes32[] memory key, bytes memory data) public { + function onSetRecord(bytes32 table, bytes32[] memory key, bytes memory data, Schema valueSchema) public { if (table != table) revert("invalid table"); - StoreSwitch.setRecord(indexerTableId, key, data); + StoreSwitch.setRecord(indexerTableId, key, data, valueSchema); } - function onBeforeSetField(bytes32 table, bytes32[] memory key, uint8 schemaIndex, bytes memory data) public { + function onBeforeSetField( + bytes32 table, + bytes32[] memory key, + uint8 schemaIndex, + bytes memory data, + Schema valueSchema + ) public { if (table != table) revert("invalid table"); - StoreSwitch.setField(indexerTableId, key, schemaIndex, data); + StoreSwitch.setField(indexerTableId, key, schemaIndex, data, valueSchema); } - function onAfterSetField(bytes32, bytes32[] memory, uint8, bytes memory) public {} + function onAfterSetField(bytes32, bytes32[] memory, uint8, bytes memory, Schema) public {} - function onDeleteRecord(bytes32 table, bytes32[] memory key) public { + function onDeleteRecord(bytes32 table, bytes32[] memory key, Schema valueSchema) public { if (table != table) revert("invalid table"); - StoreSwitch.deleteRecord(indexerTableId, key); + StoreSwitch.deleteRecord(indexerTableId, key, valueSchema); } } diff --git a/packages/store/test/StoreCore.t.sol b/packages/store/test/StoreCore.t.sol index 6f7e740abb..ed558a19ec 100644 --- a/packages/store/test/StoreCore.t.sol +++ b/packages/store/test/StoreCore.t.sol @@ -51,7 +51,8 @@ contract StoreCoreTest is Test, StoreMock { Schema loadedKeySchema = IStore(this).getKeySchema(table); assertEq(loadedKeySchema.unwrap(), keySchema.unwrap()); - bytes memory schemaRecord = IStore(this).getRecord(StoreCoreInternal.SCHEMA_TABLE, key); + Schema schemaTableSchema = SchemaEncodeHelper.encode(SchemaType.BYTES32, SchemaType.BYTES32); + bytes memory schemaRecord = IStore(this).getRecord(StoreCoreInternal.SCHEMA_TABLE, key, schemaTableSchema); assertEq(schemaRecord, abi.encodePacked(schema.unwrap(), keySchema.unwrap())); } @@ -112,7 +113,7 @@ contract StoreCoreTest is Test, StoreMock { assertEq(metadata.abiEncodedFieldNames, abi.encode(fieldNames)); } - function testlSetMetadataRevert() public { + function testSetMetadataRevert() public { bytes32 table = keccak256("some.table"); Schema schema = SchemaEncodeHelper.encode(SchemaType.UINT8); Schema keySchema = SchemaEncodeHelper.encode( @@ -193,7 +194,7 @@ contract StoreCoreTest is Test, StoreMock { vm.expectEmit(true, true, true, true); emit StoreSetRecord(table, key, data); - IStore(this).setRecord(table, key, data); + IStore(this).setRecord(table, key, data, schema); // Get data bytes memory loadedData = IStore(this).getRecord(table, key, schema); @@ -214,7 +215,7 @@ contract StoreCoreTest is Test, StoreMock { key[0] = keccak256("some.key"); // This should fail because the data is not 6 bytes long - IStore(this).setRecord(table, key, data); + IStore(this).setRecord(table, key, data, schema); } function testSetAndGetStaticDataSpanningWords() public { @@ -236,7 +237,7 @@ contract StoreCoreTest is Test, StoreMock { vm.expectEmit(true, true, true, true); emit StoreSetRecord(table, key, data); - IStore(this).setRecord(table, key, data); + IStore(this).setRecord(table, key, data, schema); // Get data bytes memory loadedData = IStore(this).getRecord(table, key, schema); @@ -247,11 +248,9 @@ contract StoreCoreTest is Test, StoreMock { function testSetAndGetDynamicData() public { bytes32 table = keccak256("some.table"); - { - // Register table's schema - Schema schema = SchemaEncodeHelper.encode(SchemaType.UINT128, SchemaType.UINT32_ARRAY, SchemaType.UINT32_ARRAY); - IStore(this).registerSchema(table, schema, defaultKeySchema); - } + // Register table's schema + Schema schema = SchemaEncodeHelper.encode(SchemaType.UINT128, SchemaType.UINT32_ARRAY, SchemaType.UINT32_ARRAY); + IStore(this).registerSchema(table, schema, defaultKeySchema); bytes16 firstDataBytes = bytes16(0x0102030405060708090a0b0c0d0e0f10); @@ -297,10 +296,10 @@ contract StoreCoreTest is Test, StoreMock { emit StoreSetRecord(table, key, data); // Set data - IStore(this).setRecord(table, key, data); + IStore(this).setRecord(table, key, data, schema); // Get data - bytes memory loadedData = IStore(this).getRecord(table, key); + bytes memory loadedData = IStore(this).getRecord(table, key, schema); assertEq(loadedData.length, data.length); assertEq(keccak256(loadedData), keccak256(data)); @@ -322,16 +321,14 @@ contract StoreCoreTest is Test, StoreMock { function testSetAndGetField() public { bytes32 table = keccak256("some.table"); - { - // Register table's schema - Schema schema = SchemaEncodeHelper.encode( - SchemaType.UINT128, - SchemaType.UINT256, - SchemaType.UINT32_ARRAY, - SchemaType.UINT32_ARRAY - ); - IStore(this).registerSchema(table, schema, defaultKeySchema); - } + // Register table's schema + Schema schema = SchemaEncodeHelper.encode( + SchemaType.UINT128, + SchemaType.UINT256, + SchemaType.UINT32_ARRAY, + SchemaType.UINT32_ARRAY + ); + IStore(this).registerSchema(table, schema, defaultKeySchema); bytes16 firstDataBytes = bytes16(0x0102030405060708090a0b0c0d0e0f10); @@ -346,21 +343,21 @@ contract StoreCoreTest is Test, StoreMock { emit StoreSetField(table, key, 0, firstDataPacked); // Set first field - IStore(this).setField(table, key, 0, firstDataPacked); + IStore(this).setField(table, key, 0, firstDataPacked, schema); //////////////// // Static data //////////////// // Get first field - bytes memory loadedData = IStore(this).getField(table, key, 0); + bytes memory loadedData = IStore(this).getField(table, key, 0, schema); // Verify loaded data is correct assertEq(loadedData.length, 16); assertEq(bytes16(loadedData), bytes16(firstDataBytes)); // Verify the second index is not set yet - assertEq(uint256(bytes32(IStore(this).getField(table, key, 1))), 0); + assertEq(uint256(bytes32(IStore(this).getField(table, key, 1, schema))), 0); // Set second field bytes32 secondDataBytes = keccak256("some data"); @@ -371,24 +368,24 @@ contract StoreCoreTest is Test, StoreMock { vm.expectEmit(true, true, true, true); emit StoreSetField(table, key, 1, secondDataPacked); - IStore(this).setField(table, key, 1, secondDataPacked); + IStore(this).setField(table, key, 1, secondDataPacked, schema); // Get second field - loadedData = IStore(this).getField(table, key, 1); + loadedData = IStore(this).getField(table, key, 1, schema); // Verify loaded data is correct assertEq(loadedData.length, 32); assertEq(bytes32(loadedData), secondDataBytes); // Verify the first field didn't change - assertEq(bytes16(IStore(this).getField(table, key, 0)), bytes16(firstDataBytes)); + assertEq(bytes16(IStore(this).getField(table, key, 0, schema)), bytes16(firstDataBytes)); // Verify the full static data is correct assertEq(IStore(this).getSchema(table).staticDataLength(), 48); - assertEq(Bytes.slice16(IStore(this).getRecord(table, key), 0), firstDataBytes); - assertEq(Bytes.slice32(IStore(this).getRecord(table, key), 16), secondDataBytes); + assertEq(Bytes.slice16(IStore(this).getRecord(table, key, schema), 0), firstDataBytes); + assertEq(Bytes.slice32(IStore(this).getRecord(table, key, schema), 16), secondDataBytes); assertEq( - keccak256(SliceLib.getSubslice(IStore(this).getRecord(table, key), 0, 48).toBytes()), + keccak256(SliceLib.getSubslice(IStore(this).getRecord(table, key, schema), 0, 48).toBytes()), keccak256(abi.encodePacked(firstDataBytes, secondDataBytes)) ); @@ -418,10 +415,10 @@ contract StoreCoreTest is Test, StoreMock { emit StoreSetField(table, key, 2, thirdDataBytes); // Set third field - IStore(this).setField(table, key, 2, thirdDataBytes); + IStore(this).setField(table, key, 2, thirdDataBytes, schema); // Get third field - loadedData = IStore(this).getField(table, key, 2); + loadedData = IStore(this).getField(table, key, 2, schema); // Verify loaded data is correct assertEq(SliceLib.fromBytes(loadedData).decodeArray_uint32().length, 2); @@ -429,21 +426,21 @@ contract StoreCoreTest is Test, StoreMock { assertEq(keccak256(loadedData), keccak256(thirdDataBytes)); // Verify the fourth field is not set yet - assertEq(IStore(this).getField(table, key, 3).length, 0); + assertEq(IStore(this).getField(table, key, 3, schema).length, 0); // Verify none of the previous fields were impacted - assertEq(bytes16(IStore(this).getField(table, key, 0)), bytes16(firstDataBytes)); - assertEq(bytes32(IStore(this).getField(table, key, 1)), bytes32(secondDataBytes)); + assertEq(bytes16(IStore(this).getField(table, key, 0, schema)), bytes16(firstDataBytes)); + assertEq(bytes32(IStore(this).getField(table, key, 1, schema)), bytes32(secondDataBytes)); // Expect a StoreSetField event to be emitted vm.expectEmit(true, true, true, true); emit StoreSetField(table, key, 3, fourthDataBytes); // Set fourth field - IStore(this).setField(table, key, 3, fourthDataBytes); + IStore(this).setField(table, key, 3, fourthDataBytes, schema); // Get fourth field - loadedData = IStore(this).getField(table, key, 3); + loadedData = IStore(this).getField(table, key, 3, schema); // Verify loaded data is correct assertEq(loadedData.length, fourthDataBytes.length); @@ -452,7 +449,7 @@ contract StoreCoreTest is Test, StoreMock { // Verify all fields are correct PackedCounter encodedLengths = PackedCounterLib.pack(uint40(thirdDataBytes.length), uint40(fourthDataBytes.length)); assertEq( - keccak256(IStore(this).getRecord(table, key)), + keccak256(IStore(this).getRecord(table, key, schema)), keccak256( abi.encodePacked(firstDataBytes, secondDataBytes, encodedLengths.unwrap(), thirdDataBytes, fourthDataBytes) ) @@ -506,10 +503,10 @@ contract StoreCoreTest is Test, StoreMock { key[0] = bytes32("some.key"); // Set data - IStore(this).setRecord(table, key, data); + IStore(this).setRecord(table, key, data, schema); // Get data - bytes memory loadedData = IStore(this).getRecord(table, key); + bytes memory loadedData = IStore(this).getRecord(table, key, schema); assertEq(loadedData.length, data.length); assertEq(keccak256(loadedData), keccak256(data)); @@ -519,80 +516,90 @@ contract StoreCoreTest is Test, StoreMock { emit StoreDeleteRecord(table, key); // Delete data - IStore(this).deleteRecord(table, key); + IStore(this).deleteRecord(table, key, schema); // Verify data is deleted - loadedData = IStore(this).getRecord(table, key); + loadedData = IStore(this).getRecord(table, key, schema); assertEq(keccak256(loadedData), keccak256(new bytes(schema.staticDataLength()))); } + struct TestPushToFieldData { + bytes32 table; + bytes32[] key; + bytes32 firstDataBytes; + bytes secondDataBytes; + bytes thirdDataBytes; + bytes secondDataToPush; + bytes newSecondDataBytes; + bytes loadedData; + bytes thirdDataToPush; + bytes newThirdDataBytes; + } + function testPushToField() public { - bytes32 table = keccak256("some.table"); + TestPushToFieldData memory data = TestPushToFieldData(0, new bytes32[](0), 0, "", "", "", "", "", "", ""); - { - // Register table's schema - Schema schema = SchemaEncodeHelper.encode(SchemaType.UINT256, SchemaType.UINT32_ARRAY, SchemaType.UINT32_ARRAY); - IStore(this).registerSchema(table, schema, defaultKeySchema); - } + data.table = keccak256("some.table"); + + // Register table's schema + Schema schema = SchemaEncodeHelper.encode(SchemaType.UINT256, SchemaType.UINT32_ARRAY, SchemaType.UINT32_ARRAY); + IStore(this).registerSchema(data.table, schema, defaultKeySchema); // Create key - bytes32[] memory key = new bytes32[](1); - key[0] = bytes32("some.key"); + data.key = new bytes32[](1); + data.key[0] = bytes32("some.key"); // Create data - bytes32 firstDataBytes = keccak256("some data"); - bytes memory secondDataBytes; + data.firstDataBytes = keccak256("some data"); { uint32[] memory secondData = new uint32[](2); secondData[0] = 0x11121314; secondData[1] = 0x15161718; - secondDataBytes = EncodeArray.encode(secondData); + data.secondDataBytes = EncodeArray.encode(secondData); } - bytes memory thirdDataBytes; + { uint32[] memory thirdData = new uint32[](3); thirdData[0] = 0x191a1b1c; thirdData[1] = 0x1d1e1f20; thirdData[2] = 0x21222324; - thirdDataBytes = EncodeArray.encode(thirdData); + data.thirdDataBytes = EncodeArray.encode(thirdData); } // Set fields - IStore(this).setField(table, key, 0, abi.encodePacked(firstDataBytes)); - IStore(this).setField(table, key, 1, secondDataBytes); + IStore(this).setField(data.table, data.key, 0, abi.encodePacked(data.firstDataBytes), schema); + IStore(this).setField(data.table, data.key, 1, data.secondDataBytes, schema); // Initialize a field with push - IStore(this).pushToField(table, key, 2, thirdDataBytes); + IStore(this).pushToField(data.table, data.key, 2, data.thirdDataBytes, schema); // Create data to push - bytes memory secondDataToPush; { uint32[] memory secondData = new uint32[](1); secondData[0] = 0x25262728; - secondDataToPush = EncodeArray.encode(secondData); + data.secondDataToPush = EncodeArray.encode(secondData); } - bytes memory newSecondDataBytes = abi.encodePacked(secondDataBytes, secondDataToPush); + data.newSecondDataBytes = abi.encodePacked(data.secondDataBytes, data.secondDataToPush); // Expect a StoreSetField event to be emitted vm.expectEmit(true, true, true, true); - emit StoreSetField(table, key, 1, newSecondDataBytes); + emit StoreSetField(data.table, data.key, 1, data.newSecondDataBytes); // Push to second field - IStore(this).pushToField(table, key, 1, secondDataToPush); + IStore(this).pushToField(data.table, data.key, 1, data.secondDataToPush, schema); // Get second field - bytes memory loadedData = IStore(this).getField(table, key, 1); + data.loadedData = IStore(this).getField(data.table, data.key, 1, schema); // Verify loaded data is correct - assertEq(SliceLib.fromBytes(loadedData).decodeArray_uint32().length, 2 + 1); - assertEq(loadedData.length, newSecondDataBytes.length); - assertEq(loadedData, newSecondDataBytes); + assertEq(SliceLib.fromBytes(data.loadedData).decodeArray_uint32().length, 2 + 1); + assertEq(data.loadedData.length, data.newSecondDataBytes.length); + assertEq(data.loadedData, data.newSecondDataBytes); // Verify none of the other fields were impacted - assertEq(bytes32(IStore(this).getField(table, key, 0)), firstDataBytes); - assertEq(IStore(this).getField(table, key, 2), thirdDataBytes); + assertEq(bytes32(IStore(this).getField(data.table, data.key, 0, schema)), data.firstDataBytes); + assertEq(IStore(this).getField(data.table, data.key, 2, schema), data.thirdDataBytes); // Create data to push - bytes memory thirdDataToPush; { uint32[] memory thirdData = new uint32[](10); thirdData[0] = 0x12345678; @@ -605,139 +612,163 @@ contract StoreCoreTest is Test, StoreMock { thirdData[7] = 0x9abcdef0; thirdData[8] = 0x12345678; thirdData[9] = 0x9abcdef0; - thirdDataToPush = EncodeArray.encode(thirdData); + data.thirdDataToPush = EncodeArray.encode(thirdData); } - bytes memory newThirdDataBytes = abi.encodePacked(thirdDataBytes, thirdDataToPush); + data.newThirdDataBytes = abi.encodePacked(data.thirdDataBytes, data.thirdDataToPush); // Expect a StoreSetField event to be emitted vm.expectEmit(true, true, true, true); - emit StoreSetField(table, key, 2, newThirdDataBytes); + emit StoreSetField(data.table, data.key, 2, data.newThirdDataBytes); // Push to third field - IStore(this).pushToField(table, key, 2, thirdDataToPush); + IStore(this).pushToField(data.table, data.key, 2, data.thirdDataToPush, schema); // Get third field - loadedData = IStore(this).getField(table, key, 2); + data.loadedData = IStore(this).getField(data.table, data.key, 2, schema); // Verify loaded data is correct - assertEq(SliceLib.fromBytes(loadedData).decodeArray_uint32().length, 3 + 10); - assertEq(loadedData.length, newThirdDataBytes.length); - assertEq(loadedData, newThirdDataBytes); + assertEq(SliceLib.fromBytes(data.loadedData).decodeArray_uint32().length, 3 + 10); + assertEq(data.loadedData.length, data.newThirdDataBytes.length); + assertEq(data.loadedData, data.newThirdDataBytes); // Verify none of the other fields were impacted - assertEq(bytes32(IStore(this).getField(table, key, 0)), firstDataBytes); - assertEq(IStore(this).getField(table, key, 1), newSecondDataBytes); + assertEq(bytes32(IStore(this).getField(data.table, data.key, 0, schema)), data.firstDataBytes); + assertEq(IStore(this).getField(data.table, data.key, 1, schema), data.newSecondDataBytes); + } + + struct TestUpdateInFieldData { + bytes32 table; + bytes32[] key; + bytes32 firstDataBytes; + uint32[] secondData; + bytes secondDataBytes; + bytes secondDataForUpdate; + bytes newSecondDataBytes; + uint64[] thirdData; + bytes thirdDataBytes; + bytes thirdDataForUpdate; + bytes newThirdDataBytes; + bytes loadedData; } function testUpdateInField() public { - bytes32 table = keccak256("some.table"); + TestUpdateInFieldData memory data = TestUpdateInFieldData( + 0, + new bytes32[](0), + 0, + new uint32[](0), + "", + "", + "", + new uint64[](0), + "", + "", + "", + "" + ); - { - // Register table's schema - Schema schema = SchemaEncodeHelper.encode(SchemaType.UINT256, SchemaType.UINT32_ARRAY, SchemaType.UINT64_ARRAY); - IStore(this).registerSchema(table, schema, defaultKeySchema); - } + data.table = keccak256("some.table"); + + // Register table's schema + Schema schema = SchemaEncodeHelper.encode(SchemaType.UINT256, SchemaType.UINT32_ARRAY, SchemaType.UINT64_ARRAY); + IStore(this).registerSchema(data.table, schema, defaultKeySchema); // Create key - bytes32[] memory key = new bytes32[](1); - key[0] = bytes32("some.key"); + data.key = new bytes32[](1); + data.key[0] = bytes32("some.key"); // Create data - bytes32 firstDataBytes = keccak256("some data"); - uint32[] memory secondData = new uint32[](2); - secondData[0] = 0x11121314; - secondData[1] = 0x15161718; - bytes memory secondDataBytes = EncodeArray.encode(secondData); - - uint64[] memory thirdData = new uint64[](6); - thirdData[0] = 0x1111111111111111; - thirdData[1] = 0x2222222222222222; - thirdData[2] = 0x3333333333333333; - thirdData[3] = 0x4444444444444444; - thirdData[4] = 0x5555555555555555; - thirdData[5] = 0x6666666666666666; - bytes memory thirdDataBytes = EncodeArray.encode(thirdData); + data.firstDataBytes = keccak256("some data"); + data.secondData = new uint32[](2); + data.secondData[0] = 0x11121314; + data.secondData[1] = 0x15161718; + data.secondDataBytes = EncodeArray.encode(data.secondData); + + data.thirdData = new uint64[](6); + data.thirdData[0] = 0x1111111111111111; + data.thirdData[1] = 0x2222222222222222; + data.thirdData[2] = 0x3333333333333333; + data.thirdData[3] = 0x4444444444444444; + data.thirdData[4] = 0x5555555555555555; + data.thirdData[5] = 0x6666666666666666; + data.thirdDataBytes = EncodeArray.encode(data.thirdData); // Set fields - IStore(this).setField(table, key, 0, abi.encodePacked(firstDataBytes)); - IStore(this).setField(table, key, 1, secondDataBytes); - IStore(this).setField(table, key, 2, thirdDataBytes); + IStore(this).setField(data.table, data.key, 0, abi.encodePacked(data.firstDataBytes), schema); + IStore(this).setField(data.table, data.key, 1, data.secondDataBytes, schema); + IStore(this).setField(data.table, data.key, 2, data.thirdDataBytes, schema); // Create data to use for the update - bytes memory secondDataForUpdate; - bytes memory newSecondDataBytes; { uint32[] memory _secondDataForUpdate = new uint32[](1); _secondDataForUpdate[0] = 0x25262728; - secondDataForUpdate = EncodeArray.encode(_secondDataForUpdate); + data.secondDataForUpdate = EncodeArray.encode(_secondDataForUpdate); - newSecondDataBytes = abi.encodePacked(secondData[0], _secondDataForUpdate[0]); + data.newSecondDataBytes = abi.encodePacked(data.secondData[0], _secondDataForUpdate[0]); } // Expect a StoreSetField event to be emitted vm.expectEmit(true, true, true, true); - emit StoreSetField(table, key, 1, newSecondDataBytes); + emit StoreSetField(data.table, data.key, 1, data.newSecondDataBytes); // Update index 1 in second field (4 = byte length of uint32) - IStore(this).updateInField(table, key, 1, 4 * 1, secondDataForUpdate); + IStore(this).updateInField(data.table, data.key, 1, 4 * 1, data.secondDataForUpdate, schema); // Get second field - bytes memory loadedData = IStore(this).getField(table, key, 1); + data.loadedData = IStore(this).getField(data.table, data.key, 1, schema); // Verify loaded data is correct - assertEq(SliceLib.fromBytes(loadedData).decodeArray_uint32().length, secondData.length); - assertEq(loadedData.length, newSecondDataBytes.length); - assertEq(loadedData, newSecondDataBytes); + assertEq(SliceLib.fromBytes(data.loadedData).decodeArray_uint32().length, data.secondData.length); + assertEq(data.loadedData.length, data.newSecondDataBytes.length); + assertEq(data.loadedData, data.newSecondDataBytes); // Verify none of the other fields were impacted - assertEq(bytes32(IStore(this).getField(table, key, 0)), firstDataBytes); - assertEq(IStore(this).getField(table, key, 2), thirdDataBytes); + assertEq(bytes32(IStore(this).getField(data.table, data.key, 0, schema)), data.firstDataBytes); + assertEq(IStore(this).getField(data.table, data.key, 2, schema), data.thirdDataBytes); // Create data for update - bytes memory thirdDataForUpdate; - bytes memory newThirdDataBytes; { uint64[] memory _thirdDataForUpdate = new uint64[](4); _thirdDataForUpdate[0] = 0x7777777777777777; _thirdDataForUpdate[1] = 0x8888888888888888; _thirdDataForUpdate[2] = 0x9999999999999999; _thirdDataForUpdate[3] = 0x0; - thirdDataForUpdate = EncodeArray.encode(_thirdDataForUpdate); + data.thirdDataForUpdate = EncodeArray.encode(_thirdDataForUpdate); - newThirdDataBytes = abi.encodePacked( - thirdData[0], + data.newThirdDataBytes = abi.encodePacked( + data.thirdData[0], _thirdDataForUpdate[0], _thirdDataForUpdate[1], _thirdDataForUpdate[2], _thirdDataForUpdate[3], - thirdData[5] + data.thirdData[5] ); } // Expect a StoreSetField event to be emitted vm.expectEmit(true, true, true, true); - emit StoreSetField(table, key, 2, newThirdDataBytes); + emit StoreSetField(data.table, data.key, 2, data.newThirdDataBytes); // Update indexes 1,2,3,4 in third field (8 = byte length of uint64) - IStore(this).updateInField(table, key, 2, 8 * 1, thirdDataForUpdate); + IStore(this).updateInField(data.table, data.key, 2, 8 * 1, data.thirdDataForUpdate, schema); // Get third field - loadedData = IStore(this).getField(table, key, 2); + data.loadedData = IStore(this).getField(data.table, data.key, 2, schema); // Verify loaded data is correct - assertEq(SliceLib.fromBytes(loadedData).decodeArray_uint64().length, thirdData.length); - assertEq(loadedData.length, newThirdDataBytes.length); - assertEq(loadedData, newThirdDataBytes); + assertEq(SliceLib.fromBytes(data.loadedData).decodeArray_uint64().length, data.thirdData.length); + assertEq(data.loadedData.length, data.newThirdDataBytes.length); + assertEq(data.loadedData, data.newThirdDataBytes); // Verify none of the other fields were impacted - assertEq(bytes32(IStore(this).getField(table, key, 0)), firstDataBytes); - assertEq(IStore(this).getField(table, key, 1), newSecondDataBytes); + assertEq(bytes32(IStore(this).getField(data.table, data.key, 0, schema)), data.firstDataBytes); + assertEq(IStore(this).getField(data.table, data.key, 1, schema), data.newSecondDataBytes); // startByteIndex must not overflow vm.expectRevert( abi.encodeWithSelector(IStoreErrors.StoreCore_DataIndexOverflow.selector, type(uint40).max, type(uint56).max) ); - IStore(this).updateInField(table, key, 2, type(uint56).max, thirdDataForUpdate); + IStore(this).updateInField(data.table, data.key, 2, type(uint56).max, data.thirdDataForUpdate, schema); } function testAccessEmptyData() public { @@ -750,13 +781,13 @@ contract StoreCoreTest is Test, StoreMock { bytes32[] memory key = new bytes32[](1); key[0] = bytes32("some.key"); - bytes memory data1 = IStore(this).getRecord(table, key); + bytes memory data1 = IStore(this).getRecord(table, key, schema); assertEq(data1.length, schema.staticDataLength()); - bytes memory data2 = IStore(this).getField(table, key, 0); + bytes memory data2 = IStore(this).getField(table, key, 0, schema); assertEq(data2.length, schema.staticDataLength()); - bytes memory data3 = IStore(this).getField(table, key, 1); + bytes memory data3 = IStore(this).getField(table, key, 1, schema); assertEq(data3.length, 0); uint256 data3Length = IStore(this).getFieldLength(table, key, 1, schema); @@ -782,24 +813,24 @@ contract StoreCoreTest is Test, StoreMock { bytes memory data = abi.encodePacked(bytes16(0x0102030405060708090a0b0c0d0e0f10)); - IStore(this).setRecord(table, key, data); + IStore(this).setRecord(table, key, data, schema); // Get data from indexed table - the indexer should have mirrored the data there - bytes memory indexedData = IStore(this).getRecord(indexerTableId, key); + bytes memory indexedData = IStore(this).getRecord(indexerTableId, key, schema); assertEq(keccak256(data), keccak256(indexedData)); data = abi.encodePacked(bytes16(0x1112131415161718191a1b1c1d1e1f20)); - IStore(this).setField(table, key, 0, data); + IStore(this).setField(table, key, 0, data, schema); // Get data from indexed table - the indexer should have mirrored the data there - indexedData = IStore(this).getRecord(indexerTableId, key); + indexedData = IStore(this).getRecord(indexerTableId, key, schema); assertEq(keccak256(data), keccak256(indexedData)); - IStore(this).deleteRecord(table, key); + IStore(this).deleteRecord(table, key, schema); // Get data from indexed table - the indexer should have mirrored the data there - indexedData = IStore(this).getRecord(indexerTableId, key); + indexedData = IStore(this).getRecord(indexerTableId, key, schema); assertEq(keccak256(indexedData), keccak256(abi.encodePacked(bytes16(0)))); } @@ -825,10 +856,10 @@ contract StoreCoreTest is Test, StoreMock { bytes memory staticData = abi.encodePacked(bytes16(0x0102030405060708090a0b0c0d0e0f10)); bytes memory data = abi.encodePacked(staticData, dynamicData); - IStore(this).setRecord(table, key, data); + IStore(this).setRecord(table, key, data, schema); // Get data from indexed table - the indexer should have mirrored the data there - bytes memory indexedData = IStore(this).getRecord(indexerTableId, key); + bytes memory indexedData = IStore(this).getRecord(indexerTableId, key, schema); assertEq(keccak256(data), keccak256(indexedData)); // Update dynamic data @@ -837,16 +868,16 @@ contract StoreCoreTest is Test, StoreMock { dynamicData = abi.encodePacked(encodedArrayDataLength.unwrap(), arrayDataBytes); data = abi.encodePacked(staticData, dynamicData); - IStore(this).setField(table, key, 1, arrayDataBytes); + IStore(this).setField(table, key, 1, arrayDataBytes, schema); // Get data from indexed table - the indexer should have mirrored the data there - indexedData = IStore(this).getRecord(indexerTableId, key); + indexedData = IStore(this).getRecord(indexerTableId, key, schema); assertEq(keccak256(data), keccak256(indexedData)); - IStore(this).deleteRecord(table, key); + IStore(this).deleteRecord(table, key, schema); // Get data from indexed table - the indexer should have mirrored the data there - indexedData = IStore(this).getRecord(indexerTableId, key); + indexedData = IStore(this).getRecord(indexerTableId, key, schema); assertEq(keccak256(indexedData), keccak256(abi.encodePacked(bytes16(0)))); } } diff --git a/packages/store/test/StoreCoreDynamic.t.sol b/packages/store/test/StoreCoreDynamic.t.sol index 0db7e3f4b0..bbeddf0b08 100644 --- a/packages/store/test/StoreCoreDynamic.t.sol +++ b/packages/store/test/StoreCoreDynamic.t.sol @@ -28,9 +28,10 @@ contract StoreCoreDynamicTest is Test, GasReporter, StoreReadWithStubs { bytes32 table, bytes32[] calldata key, uint8 schemaIndex, - uint256 byteLengthToPop + uint256 byteLengthToPop, + Schema valueSchema ) public override { - StoreCore.popFromField(table, key, schemaIndex, byteLengthToPop); + StoreCore.popFromField(table, key, schemaIndex, byteLengthToPop, valueSchema); } function setUp() public { @@ -65,13 +66,14 @@ contract StoreCoreDynamicTest is Test, GasReporter, StoreReadWithStubs { thirdDataBytes = EncodeArray.encode(thirdData); // Set fields - StoreCore.setField(_table, _key, 0, abi.encodePacked(firstDataBytes)); - StoreCore.setField(_table, _key, 1, secondDataBytes); + StoreCore.setField(_table, _key, 0, abi.encodePacked(firstDataBytes), schema); + StoreCore.setField(_table, _key, 1, secondDataBytes, schema); // Initialize a field with push - StoreCore.pushToField(_table, _key, 2, thirdDataBytes); + StoreCore.pushToField(_table, _key, 2, thirdDataBytes, schema); } function testPopFromSecondField() public { + Schema schema = StoreCore.getSchema(_table); bytes memory dataBytes = secondDataBytes; // Prepare expected data @@ -87,29 +89,30 @@ contract StoreCoreDynamicTest is Test, GasReporter, StoreReadWithStubs { // Pop from second field startGasReport("pop from field (cold, 1 slot, 1 uint32 item)"); - StoreCore.popFromField(_table, _key, 1, byteLengthToPop); + StoreCore.popFromField(_table, _key, 1, byteLengthToPop, schema); endGasReport(); // Get second field - bytes memory loadedData = StoreCore.getField(_table, _key, 1); + bytes memory loadedData = StoreCore.getField(_table, _key, 1, schema); // Verify loaded data is correct assertEq(loadedData, newDataBytes); // Reset the second field and pop again (but warm this time) - StoreCore.setField(_table, _key, 1, dataBytes); + StoreCore.setField(_table, _key, 1, dataBytes, schema); startGasReport("pop from field (warm, 1 slot, 1 uint32 item)"); - StoreCore.popFromField(_table, _key, 1, byteLengthToPop); + StoreCore.popFromField(_table, _key, 1, byteLengthToPop, schema); endGasReport(); // Get second field - loadedData = StoreCore.getField(_table, _key, 1); + loadedData = StoreCore.getField(_table, _key, 1, schema); // Verify loaded data is correct assertEq(loadedData, newDataBytes); // Verify none of the other fields were impacted - assertEq(bytes32(StoreCore.getField(_table, _key, 0)), firstDataBytes); - assertEq(StoreCore.getField(_table, _key, 2), thirdDataBytes); + assertEq(bytes32(StoreCore.getField(_table, _key, 0, schema)), firstDataBytes); + assertEq(StoreCore.getField(_table, _key, 2, schema), thirdDataBytes); } function testPopFromThirdField() public { + Schema schema = StoreCore.getSchema(_table); bytes memory dataBytes = thirdDataBytes; // Prepare expected data @@ -125,24 +128,24 @@ contract StoreCoreDynamicTest is Test, GasReporter, StoreReadWithStubs { // Pop from the field startGasReport("pop from field (cold, 2 slots, 10 uint32 items)"); - StoreCore.popFromField(_table, _key, 2, byteLengthToPop); + StoreCore.popFromField(_table, _key, 2, byteLengthToPop, schema); endGasReport(); // Load and verify the field - bytes memory loadedData = StoreCore.getField(_table, _key, 2); + bytes memory loadedData = StoreCore.getField(_table, _key, 2, schema); assertEq(loadedData, newDataBytes); // Reset the field and pop again (but warm this time) - StoreCore.setField(_table, _key, 2, dataBytes); + StoreCore.setField(_table, _key, 2, dataBytes, schema); startGasReport("pop from field (warm, 2 slots, 10 uint32 items)"); - StoreCore.popFromField(_table, _key, 2, byteLengthToPop); + StoreCore.popFromField(_table, _key, 2, byteLengthToPop, schema); endGasReport(); // Load and verify the field - loadedData = StoreCore.getField(_table, _key, 2); + loadedData = StoreCore.getField(_table, _key, 2, schema); assertEq(loadedData, newDataBytes); // Verify none of the other fields were impacted - assertEq(bytes32(StoreCore.getField(_table, _key, 0)), firstDataBytes); - assertEq(StoreCore.getField(_table, _key, 1), secondDataBytes); + assertEq(bytes32(StoreCore.getField(_table, _key, 0, schema)), firstDataBytes); + assertEq(StoreCore.getField(_table, _key, 1, schema), secondDataBytes); } function testGetSecondFieldLength() public { diff --git a/packages/store/test/StoreCoreGas.t.sol b/packages/store/test/StoreCoreGas.t.sol index db7d180be0..f4849288ef 100644 --- a/packages/store/test/StoreCoreGas.t.sol +++ b/packages/store/test/StoreCoreGas.t.sol @@ -131,7 +131,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { key[0] = keccak256("some.key"); startGasReport("set static record (1 slot)"); - StoreCore.setRecord(table, key, data); + StoreCore.setRecord(table, key, data, schema); endGasReport(); // Get data @@ -156,7 +156,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { key[0] = keccak256("some.key"); startGasReport("set static record (2 slots)"); - StoreCore.setRecord(table, key, data); + StoreCore.setRecord(table, key, data, schema); endGasReport(); // Get data @@ -168,11 +168,9 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { function testSetAndGetDynamicData() public { bytes32 table = keccak256("some.table"); - { - // Register table's schema - Schema schema = SchemaEncodeHelper.encode(SchemaType.UINT128, SchemaType.UINT32_ARRAY, SchemaType.UINT32_ARRAY); - StoreCore.registerSchema(table, schema, defaultKeySchema); - } + // Register table's schema + Schema schema = SchemaEncodeHelper.encode(SchemaType.UINT128, SchemaType.UINT32_ARRAY, SchemaType.UINT32_ARRAY); + StoreCore.registerSchema(table, schema, defaultKeySchema); bytes16 firstDataBytes = bytes16(0x0102030405060708090a0b0c0d0e0f10); @@ -215,12 +213,12 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { // Set data startGasReport("set complex record with dynamic data (4 slots)"); - StoreCore.setRecord(table, key, data); + StoreCore.setRecord(table, key, data, schema); endGasReport(); // Get data startGasReport("get complex record with dynamic data (4 slots)"); - StoreCore.getRecord(table, key); + StoreCore.getRecord(table, key, schema); endGasReport(); // Compare gas - setting the data as raw struct @@ -244,16 +242,14 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { function testSetAndGetField() public { bytes32 table = keccak256("some.table"); - { - // Register table's schema - Schema schema = SchemaEncodeHelper.encode( - SchemaType.UINT128, - SchemaType.UINT256, - SchemaType.UINT32_ARRAY, - SchemaType.UINT32_ARRAY - ); - StoreCore.registerSchema(table, schema, defaultKeySchema); - } + // Register table's schema + Schema schema = SchemaEncodeHelper.encode( + SchemaType.UINT128, + SchemaType.UINT256, + SchemaType.UINT32_ARRAY, + SchemaType.UINT32_ARRAY + ); + StoreCore.registerSchema(table, schema, defaultKeySchema); bytes16 firstDataBytes = bytes16(0x0102030405060708090a0b0c0d0e0f10); @@ -265,7 +261,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { // Set first field startGasReport("set static field (1 slot)"); - StoreCore.setField(table, key, 0, firstDataPacked); + StoreCore.setField(table, key, 0, firstDataPacked, schema); endGasReport(); //////////////// @@ -274,7 +270,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { // Get first field startGasReport("get static field (1 slot)"); - StoreCore.getField(table, key, 0); + StoreCore.getField(table, key, 0, schema); endGasReport(); // Set second field @@ -282,12 +278,12 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { bytes memory secondDataPacked = abi.encodePacked(secondDataBytes); startGasReport("set static field (overlap 2 slot)"); - StoreCore.setField(table, key, 1, secondDataPacked); + StoreCore.setField(table, key, 1, secondDataPacked, schema); endGasReport(); // Get second field startGasReport("get static field (overlap 2 slot)"); - StoreCore.getField(table, key, 1); + StoreCore.getField(table, key, 1, schema); endGasReport(); //////////////// @@ -313,22 +309,22 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { // Set third field startGasReport("set dynamic field (1 slot, first dynamic field)"); - StoreCore.setField(table, key, 2, thirdDataBytes); + StoreCore.setField(table, key, 2, thirdDataBytes, schema); endGasReport(); // Get third field startGasReport("get dynamic field (1 slot, first dynamic field)"); - StoreCore.getField(table, key, 2); + StoreCore.getField(table, key, 2, schema); endGasReport(); // Set fourth field startGasReport("set dynamic field (1 slot, second dynamic field)"); - StoreCore.setField(table, key, 3, fourthDataBytes); + StoreCore.setField(table, key, 3, fourthDataBytes, schema); endGasReport(); // Get fourth field startGasReport("get dynamic field (1 slot, second dynamic field)"); - StoreCore.getField(table, key, 3); + StoreCore.getField(table, key, 3, schema); endGasReport(); } @@ -379,22 +375,20 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { key[0] = bytes32("some.key"); // Set data - StoreCore.setRecord(table, key, data); + StoreCore.setRecord(table, key, data, schema); // Delete data startGasReport("delete record (complex data, 3 slots)"); - StoreCore.deleteRecord(table, key); + StoreCore.deleteRecord(table, key, schema); endGasReport(); } function testPushToField() public { bytes32 table = keccak256("some.table"); - { - // Register table's schema - Schema schema = SchemaEncodeHelper.encode(SchemaType.UINT256, SchemaType.UINT32_ARRAY, SchemaType.UINT32_ARRAY); - StoreCore.registerSchema(table, schema, defaultKeySchema); - } + // Register table's schema + Schema schema = SchemaEncodeHelper.encode(SchemaType.UINT256, SchemaType.UINT32_ARRAY, SchemaType.UINT32_ARRAY); + StoreCore.registerSchema(table, schema, defaultKeySchema); // Create key bytes32[] memory key = new bytes32[](1); @@ -419,10 +413,10 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { } // Set fields - StoreCore.setField(table, key, 0, abi.encodePacked(firstDataBytes)); - StoreCore.setField(table, key, 1, secondDataBytes); + StoreCore.setField(table, key, 0, abi.encodePacked(firstDataBytes), schema); + StoreCore.setField(table, key, 1, secondDataBytes, schema); // Initialize a field with push - StoreCore.pushToField(table, key, 2, thirdDataBytes); + StoreCore.pushToField(table, key, 2, thirdDataBytes, schema); // Create data to push bytes memory secondDataToPush; @@ -435,7 +429,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { // Push to second field startGasReport("push to field (1 slot, 1 uint32 item)"); - StoreCore.pushToField(table, key, 1, secondDataToPush); + StoreCore.pushToField(table, key, 1, secondDataToPush, schema); endGasReport(); // Create data to push @@ -457,29 +451,38 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { // Push to third field startGasReport("push to field (2 slots, 10 uint32 items)"); - StoreCore.pushToField(table, key, 2, thirdDataToPush); + StoreCore.pushToField(table, key, 2, thirdDataToPush, schema); endGasReport(); } + struct TestUpdateInFieldData { + bytes32 firstDataBytes; + bytes secondDataBytes; + bytes secondDataForUpdate; + bytes newSecondDataBytes; + bytes thirdDataBytes; + bytes thirdDataForUpdate; + bytes newThirdDataBytes; + } + function testUpdateInField() public { + TestUpdateInFieldData memory data = TestUpdateInFieldData("", "", "", "", "", "", ""); bytes32 table = keccak256("some.table"); - { - // Register table's schema - Schema schema = SchemaEncodeHelper.encode(SchemaType.UINT256, SchemaType.UINT32_ARRAY, SchemaType.UINT64_ARRAY); - StoreCore.registerSchema(table, schema, defaultKeySchema); - } + // Register table's schema + Schema schema = SchemaEncodeHelper.encode(SchemaType.UINT256, SchemaType.UINT32_ARRAY, SchemaType.UINT64_ARRAY); + StoreCore.registerSchema(table, schema, defaultKeySchema); // Create key bytes32[] memory key = new bytes32[](1); key[0] = bytes32("some.key"); // Create data - bytes32 firstDataBytes = keccak256("some data"); + data.firstDataBytes = keccak256("some data"); uint32[] memory secondData = new uint32[](2); secondData[0] = 0x11121314; secondData[1] = 0x15161718; - bytes memory secondDataBytes = EncodeArray.encode(secondData); + data.secondDataBytes = EncodeArray.encode(secondData); uint64[] memory thirdData = new uint64[](6); thirdData[0] = 0x1111111111111111; @@ -488,41 +491,37 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { thirdData[3] = 0x4444444444444444; thirdData[4] = 0x5555555555555555; thirdData[5] = 0x6666666666666666; - bytes memory thirdDataBytes = EncodeArray.encode(thirdData); + data.thirdDataBytes = EncodeArray.encode(thirdData); // Set fields - StoreCore.setField(table, key, 0, abi.encodePacked(firstDataBytes)); - StoreCore.setField(table, key, 1, secondDataBytes); - StoreCore.setField(table, key, 2, thirdDataBytes); + StoreCore.setField(table, key, 0, abi.encodePacked(data.firstDataBytes), schema); + StoreCore.setField(table, key, 1, data.secondDataBytes, schema); + StoreCore.setField(table, key, 2, data.thirdDataBytes, schema); // Create data to use for the update - bytes memory secondDataForUpdate; - bytes memory newSecondDataBytes; { uint32[] memory _secondDataForUpdate = new uint32[](1); _secondDataForUpdate[0] = 0x25262728; - secondDataForUpdate = EncodeArray.encode(_secondDataForUpdate); + data.secondDataForUpdate = EncodeArray.encode(_secondDataForUpdate); - newSecondDataBytes = abi.encodePacked(secondData[0], _secondDataForUpdate[0]); + data.newSecondDataBytes = abi.encodePacked(secondData[0], _secondDataForUpdate[0]); } // Update index 1 in second field (4 = byte length of uint32) startGasReport("update in field (1 slot, 1 uint32 item)"); - StoreCore.updateInField(table, key, 1, 4 * 1, secondDataForUpdate); + StoreCore.updateInField(table, key, 1, 4 * 1, data.secondDataForUpdate, schema); endGasReport(); // Create data for update - bytes memory thirdDataForUpdate; - bytes memory newThirdDataBytes; { uint64[] memory _thirdDataForUpdate = new uint64[](4); _thirdDataForUpdate[0] = 0x7777777777777777; _thirdDataForUpdate[1] = 0x8888888888888888; _thirdDataForUpdate[2] = 0x9999999999999999; _thirdDataForUpdate[3] = 0x0; - thirdDataForUpdate = EncodeArray.encode(_thirdDataForUpdate); + data.thirdDataForUpdate = EncodeArray.encode(_thirdDataForUpdate); - newThirdDataBytes = abi.encodePacked( + data.newThirdDataBytes = abi.encodePacked( thirdData[0], _thirdDataForUpdate[0], _thirdDataForUpdate[1], @@ -534,7 +533,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { // Update indexes 1,2,3,4 in third field (8 = byte length of uint64) startGasReport("push to field (2 slots, 6 uint64 items)"); - StoreCore.updateInField(table, key, 2, 8 * 1, thirdDataForUpdate); + StoreCore.updateInField(table, key, 2, 8 * 1, data.thirdDataForUpdate, schema); endGasReport(); } @@ -549,15 +548,15 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { key[0] = bytes32("some.key"); startGasReport("access non-existing record"); - StoreCore.getRecord(table, key); + StoreCore.getRecord(table, key, schema); endGasReport(); startGasReport("access static field of non-existing record"); - StoreCore.getField(table, key, 0); + StoreCore.getField(table, key, 0, schema); endGasReport(); startGasReport("access dynamic field of non-existing record"); - StoreCore.getField(table, key, 1); + StoreCore.getField(table, key, 1, schema); endGasReport(); startGasReport("access length of dynamic field of non-existing record"); @@ -588,17 +587,17 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { bytes memory data = abi.encodePacked(bytes16(0x0102030405060708090a0b0c0d0e0f10)); startGasReport("set record on table with subscriber"); - StoreCore.setRecord(table, key, data); + StoreCore.setRecord(table, key, data, schema); endGasReport(); data = abi.encodePacked(bytes16(0x1112131415161718191a1b1c1d1e1f20)); startGasReport("set static field on table with subscriber"); - StoreCore.setField(table, key, 0, data); + StoreCore.setField(table, key, 0, data, schema); endGasReport(); startGasReport("delete record on table with subscriber"); - StoreCore.deleteRecord(table, key); + StoreCore.deleteRecord(table, key, schema); endGasReport(); } @@ -627,7 +626,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { bytes memory data = abi.encodePacked(staticData, dynamicData); startGasReport("set (dynamic) record on table with subscriber"); - StoreCore.setRecord(table, key, data); + StoreCore.setRecord(table, key, data, schema); endGasReport(); // Update dynamic data @@ -637,11 +636,11 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { data = abi.encodePacked(staticData, dynamicData); startGasReport("set (dynamic) field on table with subscriber"); - StoreCore.setField(table, key, 1, arrayDataBytes); + StoreCore.setField(table, key, 1, arrayDataBytes, schema); endGasReport(); startGasReport("delete (dynamic) record on table with subscriber"); - StoreCore.deleteRecord(table, key); + StoreCore.deleteRecord(table, key, schema); endGasReport(); } } diff --git a/packages/store/test/StoreMock.sol b/packages/store/test/StoreMock.sol index f95f0b6c6e..6f457de05e 100644 --- a/packages/store/test/StoreMock.sol +++ b/packages/store/test/StoreMock.sol @@ -11,23 +11,41 @@ import { StoreRead } from "../src/StoreRead.sol"; */ contract StoreMock is IStore, StoreRead { // Set full record (including full dynamic data) - function setRecord(bytes32 table, bytes32[] calldata key, bytes calldata data) public { - StoreCore.setRecord(table, key, data); + function setRecord(bytes32 table, bytes32[] calldata key, bytes calldata data, Schema valueSchema) public { + StoreCore.setRecord(table, key, data, valueSchema); } // Set partial data at schema index - function setField(bytes32 table, bytes32[] calldata key, uint8 schemaIndex, bytes calldata data) public { - StoreCore.setField(table, key, schemaIndex, data); + function setField( + bytes32 table, + bytes32[] calldata key, + uint8 schemaIndex, + bytes calldata data, + Schema valueSchema + ) public { + StoreCore.setField(table, key, schemaIndex, data, valueSchema); } // Push encoded items to the dynamic field at schema index - function pushToField(bytes32 table, bytes32[] calldata key, uint8 schemaIndex, bytes calldata dataToPush) public { - StoreCore.pushToField(table, key, schemaIndex, dataToPush); + function pushToField( + bytes32 table, + bytes32[] calldata key, + uint8 schemaIndex, + bytes calldata dataToPush, + Schema valueSchema + ) public { + StoreCore.pushToField(table, key, schemaIndex, dataToPush, valueSchema); } // Pop byte length from the dynamic field at schema index - function popFromField(bytes32 table, bytes32[] calldata key, uint8 schemaIndex, uint256 byteLengthToPop) public { - StoreCore.popFromField(table, key, schemaIndex, byteLengthToPop); + function popFromField( + bytes32 table, + bytes32[] calldata key, + uint8 schemaIndex, + uint256 byteLengthToPop, + Schema valueSchema + ) public { + StoreCore.popFromField(table, key, schemaIndex, byteLengthToPop, valueSchema); } // Change encoded items within the dynamic field at schema index @@ -36,19 +54,20 @@ contract StoreMock is IStore, StoreRead { bytes32[] calldata key, uint8 schemaIndex, uint256 startByteIndex, - bytes calldata dataToSet + bytes calldata dataToSet, + Schema valueSchema ) public { - StoreCore.updateInField(table, key, schemaIndex, startByteIndex, dataToSet); + StoreCore.updateInField(table, key, schemaIndex, startByteIndex, dataToSet, valueSchema); } // Set full record (including full dynamic data) - function deleteRecord(bytes32 table, bytes32[] memory key) public { - StoreCore.deleteRecord(table, key); + function deleteRecord(bytes32 table, bytes32[] memory key, Schema valueSchema) public { + StoreCore.deleteRecord(table, key, valueSchema); } // Emit the ephemeral event without modifying storage - function emitEphemeralRecord(bytes32 table, bytes32[] calldata key, bytes calldata data) public { - StoreCore.emitEphemeralRecord(table, key, data); + function emitEphemeralRecord(bytes32 table, bytes32[] calldata key, bytes calldata data, Schema valueSchema) public { + StoreCore.emitEphemeralRecord(table, key, data, valueSchema); } function registerSchema(bytes32 table, Schema schema, Schema keySchema) public { diff --git a/packages/store/ts/codegen/ephemeral.ts b/packages/store/ts/codegen/ephemeral.ts index 6b339c2f5d..7e3d5b24da 100644 --- a/packages/store/ts/codegen/ephemeral.ts +++ b/packages/store/ts/codegen/ephemeral.ts @@ -19,7 +19,7 @@ export function renderEphemeralMethods(options: RenderTableOptions) { ${_keyTupleDefinition} - ${_store}.emitEphemeralRecord(_tableId, _keyTuple, _data); + ${_store}.emitEphemeralRecord(_tableId, _keyTuple, _data, getSchema()); } ` ); diff --git a/packages/store/ts/codegen/field.ts b/packages/store/ts/codegen/field.ts index 7b3c5a5758..db86a03a66 100644 --- a/packages/store/ts/codegen/field.ts +++ b/packages/store/ts/codegen/field.ts @@ -25,7 +25,7 @@ export function renderFieldMethods(options: RenderTableOptions) { _typedKeyArgs, ])}) internal view returns (${_typedFieldName}) { ${_keyTupleDefinition} - bytes memory _blob = ${_store}.getField(_tableId, _keyTuple, ${schemaIndex}); + bytes memory _blob = ${_store}.getField(_tableId, _keyTuple, ${schemaIndex}, getSchema()); return ${renderDecodeFieldSingle(field)}; } ` @@ -42,7 +42,7 @@ export function renderFieldMethods(options: RenderTableOptions) { _typedFieldName, ])}) internal { ${_keyTupleDefinition} - ${_store}.setField(_tableId, _keyTuple, ${schemaIndex}, ${renderEncodeFieldSingle(field)}); + ${_store}.setField(_tableId, _keyTuple, ${schemaIndex}, ${renderEncodeFieldSingle(field)}, getSchema()); } ` ); @@ -108,7 +108,7 @@ export function renderFieldMethods(options: RenderTableOptions) { `${portionData.typeWithLocation} ${portionData.name}`, ])}) internal { ${_keyTupleDefinition} - ${_store}.pushToField(_tableId, _keyTuple, ${schemaIndex}, ${portionData.encoded}); + ${_store}.pushToField(_tableId, _keyTuple, ${schemaIndex}, ${portionData.encoded}, getSchema()); } ` ); @@ -123,7 +123,7 @@ export function renderFieldMethods(options: RenderTableOptions) { _typedKeyArgs, ])}) internal { ${_keyTupleDefinition} - ${_store}.popFromField(_tableId, _keyTuple, ${schemaIndex}, ${portionData.elementLength}); + ${_store}.popFromField(_tableId, _keyTuple, ${schemaIndex}, ${portionData.elementLength}, getSchema()); } ` ); @@ -149,7 +149,8 @@ export function renderFieldMethods(options: RenderTableOptions) { _keyTuple, ${schemaIndex}, _index * ${portionData.elementLength}, - ${portionData.encoded} + ${portionData.encoded}, + getSchema() ); } } diff --git a/packages/store/ts/codegen/record.ts b/packages/store/ts/codegen/record.ts index 73f9865113..1a6aab3e86 100644 --- a/packages/store/ts/codegen/record.ts +++ b/packages/store/ts/codegen/record.ts @@ -42,7 +42,7 @@ export function renderRecordMethods(options: RenderTableOptions) { ${_keyTupleDefinition} - ${_store}.setRecord(_tableId, _keyTuple, _data); + ${_store}.setRecord(_tableId, _keyTuple, _data, getSchema()); } ` ); diff --git a/packages/store/ts/codegen/renderTable.ts b/packages/store/ts/codegen/renderTable.ts index 99c83c2986..ecc482660c 100644 --- a/packages/store/ts/codegen/renderTable.ts +++ b/packages/store/ts/codegen/renderTable.ts @@ -148,7 +148,7 @@ library ${libraryName} { /* Delete all data for given keys${_commentSuffix} */ function deleteRecord(${renderArguments([_typedStore, _typedTableId, _typedKeyArgs])}) internal { ${_keyTupleDefinition} - ${_store}.deleteRecord(_tableId, _keyTuple); + ${_store}.deleteRecord(_tableId, _keyTuple, getSchema()); } ` ) diff --git a/packages/world/abi/AccessManagementSystem.sol/AccessManagementSystem.abi.json b/packages/world/abi/AccessManagementSystem.sol/AccessManagementSystem.abi.json index 7801e6816e..e4a2d6f65b 100644 --- a/packages/world/abi/AccessManagementSystem.sol/AccessManagementSystem.abi.json +++ b/packages/world/abi/AccessManagementSystem.sol/AccessManagementSystem.abi.json @@ -15,6 +15,22 @@ "name": "AccessDenied", "type": "error" }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "length", + "type": "uint256" + } + ], + "name": "SchemaLib_InvalidLength", + "type": "error" + }, + { + "inputs": [], + "name": "SchemaLib_StaticTypeAfterDynamicType", + "type": "error" + }, { "inputs": [ { @@ -52,22 +68,6 @@ "name": "StoreCore_InvalidDataLength", "type": "error" }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "tableId", - "type": "bytes32" - }, - { - "internalType": "string", - "name": "tableIdString", - "type": "string" - } - ], - "name": "StoreCore_TableNotFound", - "type": "error" - }, { "inputs": [ { diff --git a/packages/world/abi/CoreSystem.sol/CoreSystem.abi.json b/packages/world/abi/CoreSystem.sol/CoreSystem.abi.json index 8c58fee71b..a887a2245e 100644 --- a/packages/world/abi/CoreSystem.sol/CoreSystem.abi.json +++ b/packages/world/abi/CoreSystem.sol/CoreSystem.abi.json @@ -244,6 +244,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "emitEphemeralRecord", @@ -267,6 +272,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "emitEphemeralRecord", diff --git a/packages/world/abi/EphemeralRecordSystem.sol/EphemeralRecordSystem.abi.json b/packages/world/abi/EphemeralRecordSystem.sol/EphemeralRecordSystem.abi.json index 3e51350f67..8ff8f51443 100644 --- a/packages/world/abi/EphemeralRecordSystem.sol/EphemeralRecordSystem.abi.json +++ b/packages/world/abi/EphemeralRecordSystem.sol/EphemeralRecordSystem.abi.json @@ -15,6 +15,22 @@ "name": "AccessDenied", "type": "error" }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "length", + "type": "uint256" + } + ], + "name": "SchemaLib_InvalidLength", + "type": "error" + }, + { + "inputs": [], + "name": "SchemaLib_StaticTypeAfterDynamicType", + "type": "error" + }, { "inputs": [ { @@ -52,22 +68,6 @@ "name": "StoreCore_InvalidDataLength", "type": "error" }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "tableId", - "type": "bytes32" - }, - { - "internalType": "string", - "name": "tableIdString", - "type": "string" - } - ], - "name": "StoreCore_TableNotFound", - "type": "error" - }, { "anonymous": false, "inputs": [ @@ -114,6 +114,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "emitEphemeralRecord", @@ -137,6 +142,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "emitEphemeralRecord", diff --git a/packages/world/abi/IBaseWorld.sol/IBaseWorld.abi.json b/packages/world/abi/IBaseWorld.sol/IBaseWorld.abi.json index 64e76c27d5..29c6d35666 100644 --- a/packages/world/abi/IBaseWorld.sol/IBaseWorld.abi.json +++ b/packages/world/abi/IBaseWorld.sol/IBaseWorld.abi.json @@ -328,6 +328,11 @@ "internalType": "bytes32[]", "name": "key", "type": "bytes32[]" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "deleteRecord", @@ -351,6 +356,11 @@ "internalType": "bytes32[]", "name": "key", "type": "bytes32[]" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "deleteRecord", @@ -379,6 +389,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "emitEphemeralRecord", @@ -402,6 +417,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "emitEphemeralRecord", @@ -425,6 +445,11 @@ "internalType": "uint8", "name": "schemaIndex", "type": "uint8" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "getField", @@ -457,7 +482,7 @@ }, { "internalType": "Schema", - "name": "schema", + "name": "valueSchema", "type": "bytes32" } ], @@ -491,7 +516,7 @@ }, { "internalType": "Schema", - "name": "schema", + "name": "valueSchema", "type": "bytes32" }, { @@ -549,32 +574,8 @@ }, { "internalType": "Schema", - "name": "schema", - "type": "bytes32" - } - ], - "name": "getRecord", - "outputs": [ - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "table", + "name": "valueSchema", "type": "bytes32" - }, - { - "internalType": "bytes32[]", - "name": "key", - "type": "bytes32[]" } ], "name": "getRecord", @@ -669,14 +670,9 @@ { "inputs": [ { - "internalType": "bytes16", - "name": "namespace", - "type": "bytes16" - }, - { - "internalType": "bytes16", - "name": "name", - "type": "bytes16" + "internalType": "bytes32", + "name": "table", + "type": "bytes32" }, { "internalType": "bytes32[]", @@ -692,6 +688,11 @@ "internalType": "uint256", "name": "byteLengthToPop", "type": "uint256" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "popFromField", @@ -702,9 +703,14 @@ { "inputs": [ { - "internalType": "bytes32", - "name": "table", - "type": "bytes32" + "internalType": "bytes16", + "name": "namespace", + "type": "bytes16" + }, + { + "internalType": "bytes16", + "name": "name", + "type": "bytes16" }, { "internalType": "bytes32[]", @@ -720,6 +726,11 @@ "internalType": "uint256", "name": "byteLengthToPop", "type": "uint256" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "popFromField", @@ -748,6 +759,11 @@ "internalType": "bytes", "name": "dataToPush", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "pushToField", @@ -781,6 +797,11 @@ "internalType": "bytes", "name": "dataToPush", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "pushToField", @@ -1073,9 +1094,14 @@ { "inputs": [ { - "internalType": "bytes32", - "name": "table", - "type": "bytes32" + "internalType": "bytes16", + "name": "namespace", + "type": "bytes16" + }, + { + "internalType": "bytes16", + "name": "name", + "type": "bytes16" }, { "internalType": "bytes32[]", @@ -1091,6 +1117,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "setField", @@ -1101,14 +1132,9 @@ { "inputs": [ { - "internalType": "bytes16", - "name": "namespace", - "type": "bytes16" - }, - { - "internalType": "bytes16", - "name": "name", - "type": "bytes16" + "internalType": "bytes32", + "name": "table", + "type": "bytes32" }, { "internalType": "bytes32[]", @@ -1124,6 +1150,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "setField", @@ -1185,14 +1216,9 @@ { "inputs": [ { - "internalType": "bytes16", - "name": "namespace", - "type": "bytes16" - }, - { - "internalType": "bytes16", - "name": "name", - "type": "bytes16" + "internalType": "bytes32", + "name": "table", + "type": "bytes32" }, { "internalType": "bytes32[]", @@ -1203,6 +1229,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "setRecord", @@ -1213,9 +1244,14 @@ { "inputs": [ { - "internalType": "bytes32", - "name": "table", - "type": "bytes32" + "internalType": "bytes16", + "name": "namespace", + "type": "bytes16" + }, + { + "internalType": "bytes16", + "name": "name", + "type": "bytes16" }, { "internalType": "bytes32[]", @@ -1226,6 +1262,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "setRecord", @@ -1259,6 +1300,11 @@ "internalType": "bytes", "name": "dataToSet", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "updateInField", @@ -1297,6 +1343,11 @@ "internalType": "bytes", "name": "dataToSet", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "updateInField", diff --git a/packages/world/abi/IStore.sol/IStore.abi.json b/packages/world/abi/IStore.sol/IStore.abi.json index 9af8379342..3dc7bc3b3a 100644 --- a/packages/world/abi/IStore.sol/IStore.abi.json +++ b/packages/world/abi/IStore.sol/IStore.abi.json @@ -200,6 +200,11 @@ "internalType": "bytes32[]", "name": "key", "type": "bytes32[]" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "deleteRecord", @@ -223,6 +228,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "emitEphemeralRecord", @@ -246,6 +256,11 @@ "internalType": "uint8", "name": "schemaIndex", "type": "uint8" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "getField", @@ -278,7 +293,7 @@ }, { "internalType": "Schema", - "name": "schema", + "name": "valueSchema", "type": "bytes32" } ], @@ -312,7 +327,7 @@ }, { "internalType": "Schema", - "name": "schema", + "name": "valueSchema", "type": "bytes32" }, { @@ -370,7 +385,7 @@ }, { "internalType": "Schema", - "name": "schema", + "name": "valueSchema", "type": "bytes32" } ], @@ -385,30 +400,6 @@ "stateMutability": "view", "type": "function" }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "table", - "type": "bytes32" - }, - { - "internalType": "bytes32[]", - "name": "key", - "type": "bytes32[]" - } - ], - "name": "getRecord", - "outputs": [ - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "stateMutability": "view", - "type": "function" - }, { "inputs": [ { @@ -449,6 +440,11 @@ "internalType": "uint256", "name": "byteLengthToPop", "type": "uint256" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "popFromField", @@ -477,6 +473,11 @@ "internalType": "bytes", "name": "dataToPush", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "pushToField", @@ -546,6 +547,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "setField", @@ -592,6 +598,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "setRecord", @@ -625,6 +636,11 @@ "internalType": "bytes", "name": "dataToSet", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "updateInField", diff --git a/packages/world/abi/IStore.sol/IStoreData.abi.json b/packages/world/abi/IStore.sol/IStoreData.abi.json index 3d3e52c5c6..8bdc4379fa 100644 --- a/packages/world/abi/IStore.sol/IStoreData.abi.json +++ b/packages/world/abi/IStore.sol/IStoreData.abi.json @@ -85,6 +85,11 @@ "internalType": "bytes32[]", "name": "key", "type": "bytes32[]" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "deleteRecord", @@ -108,6 +113,11 @@ "internalType": "uint8", "name": "schemaIndex", "type": "uint8" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "getField", @@ -140,7 +150,7 @@ }, { "internalType": "Schema", - "name": "schema", + "name": "valueSchema", "type": "bytes32" } ], @@ -174,7 +184,7 @@ }, { "internalType": "Schema", - "name": "schema", + "name": "valueSchema", "type": "bytes32" }, { @@ -232,7 +242,7 @@ }, { "internalType": "Schema", - "name": "schema", + "name": "valueSchema", "type": "bytes32" } ], @@ -247,30 +257,6 @@ "stateMutability": "view", "type": "function" }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "table", - "type": "bytes32" - }, - { - "internalType": "bytes32[]", - "name": "key", - "type": "bytes32[]" - } - ], - "name": "getRecord", - "outputs": [ - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "stateMutability": "view", - "type": "function" - }, { "inputs": [ { @@ -311,6 +297,11 @@ "internalType": "uint256", "name": "byteLengthToPop", "type": "uint256" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "popFromField", @@ -339,6 +330,11 @@ "internalType": "bytes", "name": "dataToPush", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "pushToField", @@ -367,6 +363,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "setField", @@ -390,6 +391,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "setRecord", @@ -423,6 +429,11 @@ "internalType": "bytes", "name": "dataToSet", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "updateInField", diff --git a/packages/world/abi/IStore.sol/IStoreEphemeral.abi.json b/packages/world/abi/IStore.sol/IStoreEphemeral.abi.json index eb2bb27255..c9cbd9770c 100644 --- a/packages/world/abi/IStore.sol/IStoreEphemeral.abi.json +++ b/packages/world/abi/IStore.sol/IStoreEphemeral.abi.json @@ -40,6 +40,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "emitEphemeralRecord", diff --git a/packages/world/abi/IStore.sol/IStoreHook.abi.json b/packages/world/abi/IStore.sol/IStoreHook.abi.json index f192f8efc5..171784fcb2 100644 --- a/packages/world/abi/IStore.sol/IStoreHook.abi.json +++ b/packages/world/abi/IStore.sol/IStoreHook.abi.json @@ -20,6 +20,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "onAfterSetField", @@ -48,6 +53,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "onBeforeSetField", @@ -66,6 +76,11 @@ "internalType": "bytes32[]", "name": "key", "type": "bytes32[]" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "onDeleteRecord", @@ -89,6 +104,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "onSetRecord", diff --git a/packages/world/abi/IStore.sol/IStoreRead.abi.json b/packages/world/abi/IStore.sol/IStoreRead.abi.json index e6955707bb..ca89eb4ba5 100644 --- a/packages/world/abi/IStore.sol/IStoreRead.abi.json +++ b/packages/world/abi/IStore.sol/IStoreRead.abi.json @@ -15,6 +15,11 @@ "internalType": "uint8", "name": "schemaIndex", "type": "uint8" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "getField", @@ -47,7 +52,7 @@ }, { "internalType": "Schema", - "name": "schema", + "name": "valueSchema", "type": "bytes32" } ], @@ -81,7 +86,7 @@ }, { "internalType": "Schema", - "name": "schema", + "name": "valueSchema", "type": "bytes32" }, { @@ -139,7 +144,7 @@ }, { "internalType": "Schema", - "name": "schema", + "name": "valueSchema", "type": "bytes32" } ], @@ -154,30 +159,6 @@ "stateMutability": "view", "type": "function" }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "table", - "type": "bytes32" - }, - { - "internalType": "bytes32[]", - "name": "key", - "type": "bytes32[]" - } - ], - "name": "getRecord", - "outputs": [ - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "stateMutability": "view", - "type": "function" - }, { "inputs": [ { diff --git a/packages/world/abi/IStore.sol/IStoreWrite.abi.json b/packages/world/abi/IStore.sol/IStoreWrite.abi.json index b15b6bd473..e5a35719c0 100644 --- a/packages/world/abi/IStore.sol/IStoreWrite.abi.json +++ b/packages/world/abi/IStore.sol/IStoreWrite.abi.json @@ -85,6 +85,11 @@ "internalType": "bytes32[]", "name": "key", "type": "bytes32[]" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "deleteRecord", @@ -113,6 +118,11 @@ "internalType": "uint256", "name": "byteLengthToPop", "type": "uint256" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "popFromField", @@ -141,6 +151,11 @@ "internalType": "bytes", "name": "dataToPush", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "pushToField", @@ -169,6 +184,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "setField", @@ -192,6 +212,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "setRecord", @@ -225,6 +250,11 @@ "internalType": "bytes", "name": "dataToSet", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "updateInField", diff --git a/packages/world/abi/IWorldEphemeral.sol/IWorldEphemeral.abi.json b/packages/world/abi/IWorldEphemeral.sol/IWorldEphemeral.abi.json index 83659ac983..c4d7e548b0 100644 --- a/packages/world/abi/IWorldEphemeral.sol/IWorldEphemeral.abi.json +++ b/packages/world/abi/IWorldEphemeral.sol/IWorldEphemeral.abi.json @@ -20,6 +20,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "emitEphemeralRecord", diff --git a/packages/world/abi/IWorldKernel.sol/IWorldData.abi.json b/packages/world/abi/IWorldKernel.sol/IWorldData.abi.json index 40f9b2b0cd..9be0c880bd 100644 --- a/packages/world/abi/IWorldKernel.sol/IWorldData.abi.json +++ b/packages/world/abi/IWorldKernel.sol/IWorldData.abi.json @@ -15,6 +15,11 @@ "internalType": "bytes32[]", "name": "key", "type": "bytes32[]" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "deleteRecord", @@ -48,6 +53,11 @@ "internalType": "uint256", "name": "byteLengthToPop", "type": "uint256" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "popFromField", @@ -81,6 +91,11 @@ "internalType": "bytes", "name": "dataToPush", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "pushToField", @@ -114,6 +129,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "setField", @@ -142,6 +162,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "setRecord", @@ -180,6 +205,11 @@ "internalType": "bytes", "name": "dataToSet", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "updateInField", diff --git a/packages/world/abi/IWorldKernel.sol/IWorldKernel.abi.json b/packages/world/abi/IWorldKernel.sol/IWorldKernel.abi.json index 3b495bbca8..860b7a890e 100644 --- a/packages/world/abi/IWorldKernel.sol/IWorldKernel.abi.json +++ b/packages/world/abi/IWorldKernel.sol/IWorldKernel.abi.json @@ -143,6 +143,11 @@ "internalType": "bytes32[]", "name": "key", "type": "bytes32[]" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "deleteRecord", @@ -194,6 +199,11 @@ "internalType": "uint256", "name": "byteLengthToPop", "type": "uint256" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "popFromField", @@ -227,6 +237,11 @@ "internalType": "bytes", "name": "dataToPush", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "pushToField", @@ -260,6 +275,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "setField", @@ -288,6 +308,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "setRecord", @@ -326,6 +351,11 @@ "internalType": "bytes", "name": "dataToSet", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "updateInField", diff --git a/packages/world/abi/KeysInTableHook.sol/KeysInTableHook.abi.json b/packages/world/abi/KeysInTableHook.sol/KeysInTableHook.abi.json index aff14f41e8..223ef6484f 100644 --- a/packages/world/abi/KeysInTableHook.sol/KeysInTableHook.abi.json +++ b/packages/world/abi/KeysInTableHook.sol/KeysInTableHook.abi.json @@ -73,22 +73,6 @@ "name": "StoreCore_NotDynamicField", "type": "error" }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "tableId", - "type": "bytes32" - }, - { - "internalType": "string", - "name": "tableIdString", - "type": "string" - } - ], - "name": "StoreCore_TableNotFound", - "type": "error" - }, { "inputs": [ { @@ -110,6 +94,11 @@ "internalType": "bytes", "name": "", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "", + "type": "bytes32" } ], "name": "onAfterSetField", @@ -138,6 +127,11 @@ "internalType": "bytes", "name": "", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "", + "type": "bytes32" } ], "name": "onBeforeSetField", @@ -156,6 +150,11 @@ "internalType": "bytes32[]", "name": "key", "type": "bytes32[]" + }, + { + "internalType": "Schema", + "name": "", + "type": "bytes32" } ], "name": "onDeleteRecord", @@ -179,6 +178,11 @@ "internalType": "bytes", "name": "", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "", + "type": "bytes32" } ], "name": "onSetRecord", diff --git a/packages/world/abi/KeysInTableModule.sol/KeysInTableModule.abi.json b/packages/world/abi/KeysInTableModule.sol/KeysInTableModule.abi.json index b281783ba3..64373ae108 100644 --- a/packages/world/abi/KeysInTableModule.sol/KeysInTableModule.abi.json +++ b/packages/world/abi/KeysInTableModule.sol/KeysInTableModule.abi.json @@ -26,22 +26,6 @@ "name": "SchemaLib_StaticTypeAfterDynamicType", "type": "error" }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "tableId", - "type": "bytes32" - }, - { - "internalType": "string", - "name": "tableIdString", - "type": "string" - } - ], - "name": "StoreCore_TableNotFound", - "type": "error" - }, { "inputs": [], "name": "getName", diff --git a/packages/world/abi/KeysWithValueHook.sol/KeysWithValueHook.abi.json b/packages/world/abi/KeysWithValueHook.sol/KeysWithValueHook.abi.json index d26dcd0e71..a4a456e299 100644 --- a/packages/world/abi/KeysWithValueHook.sol/KeysWithValueHook.abi.json +++ b/packages/world/abi/KeysWithValueHook.sol/KeysWithValueHook.abi.json @@ -1,4 +1,20 @@ [ + { + "inputs": [ + { + "internalType": "uint256", + "name": "length", + "type": "uint256" + } + ], + "name": "SchemaLib_InvalidLength", + "type": "error" + }, + { + "inputs": [], + "name": "SchemaLib_StaticTypeAfterDynamicType", + "type": "error" + }, { "inputs": [ { @@ -41,22 +57,6 @@ "name": "StoreCore_NotDynamicField", "type": "error" }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "tableId", - "type": "bytes32" - }, - { - "internalType": "string", - "name": "tableIdString", - "type": "string" - } - ], - "name": "StoreCore_TableNotFound", - "type": "error" - }, { "inputs": [ { @@ -78,6 +78,11 @@ "internalType": "bytes", "name": "", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "onAfterSetField", @@ -106,6 +111,11 @@ "internalType": "bytes", "name": "", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "onBeforeSetField", @@ -124,6 +134,11 @@ "internalType": "bytes32[]", "name": "key", "type": "bytes32[]" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "onDeleteRecord", @@ -147,6 +162,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "onSetRecord", diff --git a/packages/world/abi/KeysWithValueModule.sol/KeysWithValueModule.abi.json b/packages/world/abi/KeysWithValueModule.sol/KeysWithValueModule.abi.json index d616cf972b..b23c956332 100644 --- a/packages/world/abi/KeysWithValueModule.sol/KeysWithValueModule.abi.json +++ b/packages/world/abi/KeysWithValueModule.sol/KeysWithValueModule.abi.json @@ -52,22 +52,6 @@ "name": "StoreCore_NotDynamicField", "type": "error" }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "tableId", - "type": "bytes32" - }, - { - "internalType": "string", - "name": "tableIdString", - "type": "string" - } - ], - "name": "StoreCore_TableNotFound", - "type": "error" - }, { "inputs": [], "name": "getName", diff --git a/packages/world/abi/ModuleInstallationSystem.sol/ModuleInstallationSystem.abi.json b/packages/world/abi/ModuleInstallationSystem.sol/ModuleInstallationSystem.abi.json index ac5d10ea5d..3ba41db3c5 100644 --- a/packages/world/abi/ModuleInstallationSystem.sol/ModuleInstallationSystem.abi.json +++ b/packages/world/abi/ModuleInstallationSystem.sol/ModuleInstallationSystem.abi.json @@ -1,4 +1,20 @@ [ + { + "inputs": [ + { + "internalType": "uint256", + "name": "length", + "type": "uint256" + } + ], + "name": "SchemaLib_InvalidLength", + "type": "error" + }, + { + "inputs": [], + "name": "SchemaLib_StaticTypeAfterDynamicType", + "type": "error" + }, { "inputs": [ { @@ -36,22 +52,6 @@ "name": "StoreCore_InvalidDataLength", "type": "error" }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "tableId", - "type": "bytes32" - }, - { - "internalType": "string", - "name": "tableIdString", - "type": "string" - } - ], - "name": "StoreCore_TableNotFound", - "type": "error" - }, { "inputs": [ { diff --git a/packages/world/abi/StoreCore.sol/StoreCoreExtended.abi.json b/packages/world/abi/StoreCore.sol/StoreCoreExtended.abi.json deleted file mode 100644 index 0637a088a0..0000000000 --- a/packages/world/abi/StoreCore.sol/StoreCoreExtended.abi.json +++ /dev/null @@ -1 +0,0 @@ -[] \ No newline at end of file diff --git a/packages/world/abi/StoreRead.sol/StoreRead.abi.json b/packages/world/abi/StoreRead.sol/StoreRead.abi.json index 3e8785719d..b05f278530 100644 --- a/packages/world/abi/StoreRead.sol/StoreRead.abi.json +++ b/packages/world/abi/StoreRead.sol/StoreRead.abi.json @@ -126,6 +126,11 @@ "internalType": "uint8", "name": "schemaIndex", "type": "uint8" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "getField", @@ -250,7 +255,7 @@ }, { "internalType": "Schema", - "name": "schema", + "name": "valueSchema", "type": "bytes32" } ], @@ -265,30 +270,6 @@ "stateMutability": "view", "type": "function" }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "table", - "type": "bytes32" - }, - { - "internalType": "bytes32[]", - "name": "key", - "type": "bytes32[]" - } - ], - "name": "getRecord", - "outputs": [ - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "stateMutability": "view", - "type": "function" - }, { "inputs": [ { diff --git a/packages/world/abi/UniqueEntitySystem.sol/UniqueEntitySystem.abi.json b/packages/world/abi/UniqueEntitySystem.sol/UniqueEntitySystem.abi.json index 51b519610a..e4f117c782 100644 --- a/packages/world/abi/UniqueEntitySystem.sol/UniqueEntitySystem.abi.json +++ b/packages/world/abi/UniqueEntitySystem.sol/UniqueEntitySystem.abi.json @@ -1,4 +1,20 @@ [ + { + "inputs": [ + { + "internalType": "uint256", + "name": "length", + "type": "uint256" + } + ], + "name": "SchemaLib_InvalidLength", + "type": "error" + }, + { + "inputs": [], + "name": "SchemaLib_StaticTypeAfterDynamicType", + "type": "error" + }, { "inputs": [ { @@ -36,22 +52,6 @@ "name": "StoreCore_InvalidDataLength", "type": "error" }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "tableId", - "type": "bytes32" - }, - { - "internalType": "string", - "name": "tableIdString", - "type": "string" - } - ], - "name": "StoreCore_TableNotFound", - "type": "error" - }, { "inputs": [], "name": "getUniqueEntity", diff --git a/packages/world/abi/World.sol/World.abi.json b/packages/world/abi/World.sol/World.abi.json index 013356766d..aad1a60dad 100644 --- a/packages/world/abi/World.sol/World.abi.json +++ b/packages/world/abi/World.sol/World.abi.json @@ -344,6 +344,11 @@ "internalType": "bytes32[]", "name": "key", "type": "bytes32[]" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "deleteRecord", @@ -367,6 +372,11 @@ "internalType": "bytes32[]", "name": "key", "type": "bytes32[]" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "deleteRecord", @@ -390,6 +400,11 @@ "internalType": "uint8", "name": "schemaIndex", "type": "uint8" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "getField", @@ -514,32 +529,8 @@ }, { "internalType": "Schema", - "name": "schema", - "type": "bytes32" - } - ], - "name": "getRecord", - "outputs": [ - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "table", + "name": "valueSchema", "type": "bytes32" - }, - { - "internalType": "bytes32[]", - "name": "key", - "type": "bytes32[]" } ], "name": "getRecord", @@ -593,14 +584,9 @@ { "inputs": [ { - "internalType": "bytes16", - "name": "namespace", - "type": "bytes16" - }, - { - "internalType": "bytes16", - "name": "name", - "type": "bytes16" + "internalType": "bytes32", + "name": "tableId", + "type": "bytes32" }, { "internalType": "bytes32[]", @@ -616,6 +602,11 @@ "internalType": "uint256", "name": "byteLengthToPop", "type": "uint256" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "popFromField", @@ -626,9 +617,14 @@ { "inputs": [ { - "internalType": "bytes32", - "name": "tableId", - "type": "bytes32" + "internalType": "bytes16", + "name": "namespace", + "type": "bytes16" + }, + { + "internalType": "bytes16", + "name": "name", + "type": "bytes16" }, { "internalType": "bytes32[]", @@ -644,6 +640,11 @@ "internalType": "uint256", "name": "byteLengthToPop", "type": "uint256" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "popFromField", @@ -672,6 +673,11 @@ "internalType": "bytes", "name": "dataToPush", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "pushToField", @@ -705,6 +711,11 @@ "internalType": "bytes", "name": "dataToPush", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "pushToField", @@ -715,9 +726,14 @@ { "inputs": [ { - "internalType": "bytes32", - "name": "tableId", - "type": "bytes32" + "internalType": "bytes16", + "name": "namespace", + "type": "bytes16" + }, + { + "internalType": "bytes16", + "name": "name", + "type": "bytes16" }, { "internalType": "bytes32[]", @@ -733,6 +749,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "setField", @@ -743,14 +764,9 @@ { "inputs": [ { - "internalType": "bytes16", - "name": "namespace", - "type": "bytes16" - }, - { - "internalType": "bytes16", - "name": "name", - "type": "bytes16" + "internalType": "bytes32", + "name": "tableId", + "type": "bytes32" }, { "internalType": "bytes32[]", @@ -766,6 +782,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "setField", @@ -776,14 +797,9 @@ { "inputs": [ { - "internalType": "bytes16", - "name": "namespace", - "type": "bytes16" - }, - { - "internalType": "bytes16", - "name": "name", - "type": "bytes16" + "internalType": "bytes32", + "name": "tableId", + "type": "bytes32" }, { "internalType": "bytes32[]", @@ -794,6 +810,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "setRecord", @@ -804,9 +825,14 @@ { "inputs": [ { - "internalType": "bytes32", - "name": "tableId", - "type": "bytes32" + "internalType": "bytes16", + "name": "namespace", + "type": "bytes16" + }, + { + "internalType": "bytes16", + "name": "name", + "type": "bytes16" }, { "internalType": "bytes32[]", @@ -817,6 +843,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "setRecord", @@ -850,6 +881,11 @@ "internalType": "bytes", "name": "dataToSet", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "updateInField", @@ -888,6 +924,11 @@ "internalType": "bytes", "name": "dataToSet", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "updateInField", diff --git a/packages/world/abi/src/IStore.sol/IStore.abi.json b/packages/world/abi/src/IStore.sol/IStore.abi.json index 9af8379342..3dc7bc3b3a 100644 --- a/packages/world/abi/src/IStore.sol/IStore.abi.json +++ b/packages/world/abi/src/IStore.sol/IStore.abi.json @@ -200,6 +200,11 @@ "internalType": "bytes32[]", "name": "key", "type": "bytes32[]" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "deleteRecord", @@ -223,6 +228,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "emitEphemeralRecord", @@ -246,6 +256,11 @@ "internalType": "uint8", "name": "schemaIndex", "type": "uint8" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "getField", @@ -278,7 +293,7 @@ }, { "internalType": "Schema", - "name": "schema", + "name": "valueSchema", "type": "bytes32" } ], @@ -312,7 +327,7 @@ }, { "internalType": "Schema", - "name": "schema", + "name": "valueSchema", "type": "bytes32" }, { @@ -370,7 +385,7 @@ }, { "internalType": "Schema", - "name": "schema", + "name": "valueSchema", "type": "bytes32" } ], @@ -385,30 +400,6 @@ "stateMutability": "view", "type": "function" }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "table", - "type": "bytes32" - }, - { - "internalType": "bytes32[]", - "name": "key", - "type": "bytes32[]" - } - ], - "name": "getRecord", - "outputs": [ - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "stateMutability": "view", - "type": "function" - }, { "inputs": [ { @@ -449,6 +440,11 @@ "internalType": "uint256", "name": "byteLengthToPop", "type": "uint256" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "popFromField", @@ -477,6 +473,11 @@ "internalType": "bytes", "name": "dataToPush", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "pushToField", @@ -546,6 +547,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "setField", @@ -592,6 +598,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "setRecord", @@ -625,6 +636,11 @@ "internalType": "bytes", "name": "dataToSet", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "updateInField", diff --git a/packages/world/abi/src/IStore.sol/IStoreData.abi.json b/packages/world/abi/src/IStore.sol/IStoreData.abi.json index 3d3e52c5c6..8bdc4379fa 100644 --- a/packages/world/abi/src/IStore.sol/IStoreData.abi.json +++ b/packages/world/abi/src/IStore.sol/IStoreData.abi.json @@ -85,6 +85,11 @@ "internalType": "bytes32[]", "name": "key", "type": "bytes32[]" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "deleteRecord", @@ -108,6 +113,11 @@ "internalType": "uint8", "name": "schemaIndex", "type": "uint8" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "getField", @@ -140,7 +150,7 @@ }, { "internalType": "Schema", - "name": "schema", + "name": "valueSchema", "type": "bytes32" } ], @@ -174,7 +184,7 @@ }, { "internalType": "Schema", - "name": "schema", + "name": "valueSchema", "type": "bytes32" }, { @@ -232,7 +242,7 @@ }, { "internalType": "Schema", - "name": "schema", + "name": "valueSchema", "type": "bytes32" } ], @@ -247,30 +257,6 @@ "stateMutability": "view", "type": "function" }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "table", - "type": "bytes32" - }, - { - "internalType": "bytes32[]", - "name": "key", - "type": "bytes32[]" - } - ], - "name": "getRecord", - "outputs": [ - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "stateMutability": "view", - "type": "function" - }, { "inputs": [ { @@ -311,6 +297,11 @@ "internalType": "uint256", "name": "byteLengthToPop", "type": "uint256" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "popFromField", @@ -339,6 +330,11 @@ "internalType": "bytes", "name": "dataToPush", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "pushToField", @@ -367,6 +363,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "setField", @@ -390,6 +391,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "setRecord", @@ -423,6 +429,11 @@ "internalType": "bytes", "name": "dataToSet", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "updateInField", diff --git a/packages/world/abi/src/IStore.sol/IStoreEphemeral.abi.json b/packages/world/abi/src/IStore.sol/IStoreEphemeral.abi.json index eb2bb27255..c9cbd9770c 100644 --- a/packages/world/abi/src/IStore.sol/IStoreEphemeral.abi.json +++ b/packages/world/abi/src/IStore.sol/IStoreEphemeral.abi.json @@ -40,6 +40,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "emitEphemeralRecord", diff --git a/packages/world/abi/src/IStore.sol/IStoreHook.abi.json b/packages/world/abi/src/IStore.sol/IStoreHook.abi.json index f192f8efc5..171784fcb2 100644 --- a/packages/world/abi/src/IStore.sol/IStoreHook.abi.json +++ b/packages/world/abi/src/IStore.sol/IStoreHook.abi.json @@ -20,6 +20,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "onAfterSetField", @@ -48,6 +53,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "onBeforeSetField", @@ -66,6 +76,11 @@ "internalType": "bytes32[]", "name": "key", "type": "bytes32[]" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "onDeleteRecord", @@ -89,6 +104,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "onSetRecord", diff --git a/packages/world/abi/src/IStore.sol/IStoreRead.abi.json b/packages/world/abi/src/IStore.sol/IStoreRead.abi.json index e6955707bb..ca89eb4ba5 100644 --- a/packages/world/abi/src/IStore.sol/IStoreRead.abi.json +++ b/packages/world/abi/src/IStore.sol/IStoreRead.abi.json @@ -15,6 +15,11 @@ "internalType": "uint8", "name": "schemaIndex", "type": "uint8" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "getField", @@ -47,7 +52,7 @@ }, { "internalType": "Schema", - "name": "schema", + "name": "valueSchema", "type": "bytes32" } ], @@ -81,7 +86,7 @@ }, { "internalType": "Schema", - "name": "schema", + "name": "valueSchema", "type": "bytes32" }, { @@ -139,7 +144,7 @@ }, { "internalType": "Schema", - "name": "schema", + "name": "valueSchema", "type": "bytes32" } ], @@ -154,30 +159,6 @@ "stateMutability": "view", "type": "function" }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "table", - "type": "bytes32" - }, - { - "internalType": "bytes32[]", - "name": "key", - "type": "bytes32[]" - } - ], - "name": "getRecord", - "outputs": [ - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "stateMutability": "view", - "type": "function" - }, { "inputs": [ { diff --git a/packages/world/abi/src/IStore.sol/IStoreWrite.abi.json b/packages/world/abi/src/IStore.sol/IStoreWrite.abi.json index b15b6bd473..e5a35719c0 100644 --- a/packages/world/abi/src/IStore.sol/IStoreWrite.abi.json +++ b/packages/world/abi/src/IStore.sol/IStoreWrite.abi.json @@ -85,6 +85,11 @@ "internalType": "bytes32[]", "name": "key", "type": "bytes32[]" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "deleteRecord", @@ -113,6 +118,11 @@ "internalType": "uint256", "name": "byteLengthToPop", "type": "uint256" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "popFromField", @@ -141,6 +151,11 @@ "internalType": "bytes", "name": "dataToPush", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "pushToField", @@ -169,6 +184,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "setField", @@ -192,6 +212,11 @@ "internalType": "bytes", "name": "data", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "setRecord", @@ -225,6 +250,11 @@ "internalType": "bytes", "name": "dataToSet", "type": "bytes" + }, + { + "internalType": "Schema", + "name": "valueSchema", + "type": "bytes32" } ], "name": "updateInField", diff --git a/packages/world/abi/src/StoreCore.sol/StoreCoreExtended.abi.json b/packages/world/abi/src/StoreCore.sol/StoreCoreExtended.abi.json deleted file mode 100644 index 0637a088a0..0000000000 --- a/packages/world/abi/src/StoreCore.sol/StoreCoreExtended.abi.json +++ /dev/null @@ -1 +0,0 @@ -[] \ No newline at end of file diff --git a/packages/world/gas-report.json b/packages/world/gas-report.json index d87ce8e248..16d2f3c61b 100644 --- a/packages/world/gas-report.json +++ b/packages/world/gas-report.json @@ -3,73 +3,73 @@ "file": "test/KeysInTableModule.t.sol", "test": "testInstallComposite", "name": "install keys in table module", - "gasUsed": 1245428 + "gasUsed": 1245500 }, { "file": "test/KeysInTableModule.t.sol", "test": "testInstallGas", "name": "install keys in table module", - "gasUsed": 1245428 + "gasUsed": 1245500 }, { "file": "test/KeysInTableModule.t.sol", "test": "testInstallGas", "name": "set a record on a table with keysInTableModule installed", - "gasUsed": 186322 + "gasUsed": 192374 }, { "file": "test/KeysInTableModule.t.sol", "test": "testInstallSingleton", "name": "install keys in table module", - "gasUsed": 1245428 + "gasUsed": 1245500 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookCompositeGas", "name": "install keys in table module", - "gasUsed": 1245428 + "gasUsed": 1245500 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookCompositeGas", "name": "change a composite record on a table with keysInTableModule installed", - "gasUsed": 27582 + "gasUsed": 28061 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookCompositeGas", "name": "delete a composite record on a table with keysInTableModule installed", - "gasUsed": 259406 + "gasUsed": 285045 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookGas", "name": "install keys in table module", - "gasUsed": 1245428 + "gasUsed": 1245500 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookGas", "name": "change a record on a table with keysInTableModule installed", - "gasUsed": 26196 + "gasUsed": 26681 }, { "file": "test/KeysInTableModule.t.sol", "test": "testSetAndDeleteRecordHookGas", "name": "delete a record on a table with keysInTableModule installed", - "gasUsed": 136184 + "gasUsed": 146383 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testGetKeysWithValueGas", "name": "install keys with value module", - "gasUsed": 600072 + "gasUsed": 598260 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testGetKeysWithValueGas", "name": "Get list of keys with a given value", - "gasUsed": 7391 + "gasUsed": 7507 }, { "file": "test/KeysWithValueModule.t.sol", @@ -81,228 +81,228 @@ "file": "test/KeysWithValueModule.t.sol", "test": "testInstall", "name": "install keys with value module", - "gasUsed": 600072 + "gasUsed": 598260 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testInstall", "name": "set a record on a table with KeysWithValueModule installed", - "gasUsed": 159235 + "gasUsed": 159027 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetAndDeleteRecordHook", "name": "install keys with value module", - "gasUsed": 600072 + "gasUsed": 598260 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetAndDeleteRecordHook", "name": "change a record on a table with KeysWithValueModule installed", - "gasUsed": 126246 + "gasUsed": 126064 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetAndDeleteRecordHook", "name": "delete a record on a table with KeysWithValueModule installed", - "gasUsed": 48933 + "gasUsed": 47905 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetField", "name": "install keys with value module", - "gasUsed": 600072 + "gasUsed": 598260 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetField", "name": "set a field on a table with KeysWithValueModule installed", - "gasUsed": 167383 + "gasUsed": 166095 }, { "file": "test/KeysWithValueModule.t.sol", "test": "testSetField", "name": "change a field on a table with KeysWithValueModule installed", - "gasUsed": 129641 + "gasUsed": 128353 }, { "file": "test/query.t.sol", "test": "testCombinedHasHasValueNotQuery", "name": "CombinedHasHasValueNotQuery", - "gasUsed": 158213 + "gasUsed": 158332 }, { "file": "test/query.t.sol", "test": "testCombinedHasHasValueQuery", "name": "CombinedHasHasValueQuery", - "gasUsed": 74454 + "gasUsed": 74736 }, { "file": "test/query.t.sol", "test": "testCombinedHasNotQuery", "name": "CombinedHasNotQuery", - "gasUsed": 216199 + "gasUsed": 215752 }, { "file": "test/query.t.sol", "test": "testCombinedHasQuery", "name": "CombinedHasQuery", - "gasUsed": 136120 + "gasUsed": 135884 }, { "file": "test/query.t.sol", "test": "testCombinedHasValueNotQuery", "name": "CombinedHasValueNotQuery", - "gasUsed": 135034 + "gasUsed": 134907 }, { "file": "test/query.t.sol", "test": "testCombinedHasValueQuery", "name": "CombinedHasValueQuery", - "gasUsed": 18902 + "gasUsed": 19146 }, { "file": "test/query.t.sol", "test": "testHasQuery", "name": "HasQuery", - "gasUsed": 30718 + "gasUsed": 30667 }, { "file": "test/query.t.sol", "test": "testHasQuery1000Keys", "name": "HasQuery with 1000 keys", - "gasUsed": 10461456 + "gasUsed": 10429469 }, { "file": "test/query.t.sol", "test": "testHasQuery100Keys", "name": "HasQuery with 100 keys", - "gasUsed": 974359 + "gasUsed": 971172 }, { "file": "test/query.t.sol", "test": "testHasValueQuery", "name": "HasValueQuery", - "gasUsed": 9128 + "gasUsed": 9250 }, { "file": "test/query.t.sol", "test": "testNotValueQuery", "name": "NotValueQuery", - "gasUsed": 68048 + "gasUsed": 68332 }, { "file": "test/UniqueEntityModule.t.sol", "test": "testInstall", "name": "install unique entity module", - "gasUsed": 787777 + "gasUsed": 780716 }, { "file": "test/UniqueEntityModule.t.sol", "test": "testInstall", "name": "get a unique entity nonce (non-root module)", - "gasUsed": 69647 + "gasUsed": 70532 }, { "file": "test/UniqueEntityModule.t.sol", "test": "testInstallRoot", "name": "installRoot unique entity module", - "gasUsed": 760082 + "gasUsed": 752491 }, { "file": "test/UniqueEntityModule.t.sol", "test": "testInstallRoot", "name": "get a unique entity nonce (root module)", - "gasUsed": 69647 + "gasUsed": 70532 }, { "file": "test/World.t.sol", "test": "testDeleteRecord", "name": "Delete record", - "gasUsed": 14446 + "gasUsed": 13644 }, { "file": "test/World.t.sol", "test": "testPushToField", "name": "Push data to the table", - "gasUsed": 94564 + "gasUsed": 93813 }, { "file": "test/World.t.sol", "test": "testRegisterFallbackSystem", "name": "Register a fallback system", - "gasUsed": 80165 + "gasUsed": 84310 }, { "file": "test/World.t.sol", "test": "testRegisterFallbackSystem", "name": "Register a root fallback system", - "gasUsed": 71345 + "gasUsed": 77491 }, { "file": "test/World.t.sol", "test": "testRegisterFunctionSelector", "name": "Register a function selector", - "gasUsed": 100756 + "gasUsed": 104901 }, { "file": "test/World.t.sol", "test": "testRegisterNamespace", "name": "Register a new namespace", - "gasUsed": 155574 + "gasUsed": 146851 }, { "file": "test/World.t.sol", "test": "testRegisterRootFunctionSelector", "name": "Register a root function selector", - "gasUsed": 87260 + "gasUsed": 93406 }, { "file": "test/World.t.sol", "test": "testRegisterTable", "name": "Register a new table in the namespace", - "gasUsed": 252927 + "gasUsed": 244857 }, { "file": "test/World.t.sol", "test": "testSetField", "name": "Write data to a table field", - "gasUsed": 43035 + "gasUsed": 42256 }, { "file": "test/World.t.sol", "test": "testSetMetadata", "name": "Set metadata", - "gasUsed": 277799 + "gasUsed": 277166 }, { "file": "test/World.t.sol", "test": "testSetRecord", "name": "Write data to the table", - "gasUsed": 40890 + "gasUsed": 41450 }, { "file": "test/WorldDynamicUpdate.t.sol", "test": "testPopFromField", "name": "pop 1 address (cold)", - "gasUsed": 38107 + "gasUsed": 33369 }, { "file": "test/WorldDynamicUpdate.t.sol", "test": "testPopFromField", "name": "pop 1 address (warm)", - "gasUsed": 20897 + "gasUsed": 20160 }, { "file": "test/WorldDynamicUpdate.t.sol", "test": "testUpdateInField", "name": "updateInField 1 item (cold)", - "gasUsed": 39827 + "gasUsed": 35035 }, { "file": "test/WorldDynamicUpdate.t.sol", "test": "testUpdateInField", "name": "updateInField 1 item (warm)", - "gasUsed": 23032 + "gasUsed": 22239 } ] diff --git a/packages/world/src/World.sol b/packages/world/src/World.sol index 8b6741473b..1b24600f46 100644 --- a/packages/world/src/World.sol +++ b/packages/world/src/World.sol @@ -5,6 +5,7 @@ import { StoreRead } from "@latticexyz/store/src/StoreRead.sol"; import { IStoreData } from "@latticexyz/store/src/IStore.sol"; import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; import { Bytes } from "@latticexyz/store/src/Bytes.sol"; +import { Schema } from "@latticexyz/store/src/Schema.sol"; import { System } from "./System.sol"; import { ResourceSelector } from "./ResourceSelector.sol"; @@ -68,12 +69,18 @@ contract World is StoreRead, IStoreData, IWorldKernel { * Write a record in the table at the given namespace and name. * Requires the caller to have access to the namespace or name. */ - function setRecord(bytes16 namespace, bytes16 name, bytes32[] calldata key, bytes calldata data) public virtual { + function setRecord( + bytes16 namespace, + bytes16 name, + bytes32[] calldata key, + bytes calldata data, + Schema valueSchema + ) public virtual { // Require access to the namespace or name bytes32 resourceSelector = AccessControl.requireAccess(namespace, name, msg.sender); // Set the record - StoreCore.setRecord(resourceSelector, key, data); + StoreCore.setRecord(resourceSelector, key, data, valueSchema); } /** @@ -85,13 +92,14 @@ contract World is StoreRead, IStoreData, IWorldKernel { bytes16 name, bytes32[] calldata key, uint8 schemaIndex, - bytes calldata data + bytes calldata data, + Schema valueSchema ) public virtual { // Require access to namespace or name bytes32 resourceSelector = AccessControl.requireAccess(namespace, name, msg.sender); // Set the field - StoreCore.setField(resourceSelector, key, schemaIndex, data); + StoreCore.setField(resourceSelector, key, schemaIndex, data, valueSchema); } /** @@ -103,13 +111,14 @@ contract World is StoreRead, IStoreData, IWorldKernel { bytes16 name, bytes32[] calldata key, uint8 schemaIndex, - bytes calldata dataToPush + bytes calldata dataToPush, + Schema valueSchema ) public virtual { // Require access to namespace or name bytes32 resourceSelector = AccessControl.requireAccess(namespace, name, msg.sender); // Push to the field - StoreCore.pushToField(resourceSelector, key, schemaIndex, dataToPush); + StoreCore.pushToField(resourceSelector, key, schemaIndex, dataToPush, valueSchema); } /** @@ -121,13 +130,14 @@ contract World is StoreRead, IStoreData, IWorldKernel { bytes16 name, bytes32[] calldata key, uint8 schemaIndex, - uint256 byteLengthToPop + uint256 byteLengthToPop, + Schema valueSchema ) public virtual { // Require access to namespace or name bytes32 resourceSelector = AccessControl.requireAccess(namespace, name, msg.sender); // Push to the field - StoreCore.popFromField(resourceSelector, key, schemaIndex, byteLengthToPop); + StoreCore.popFromField(resourceSelector, key, schemaIndex, byteLengthToPop, valueSchema); } /** @@ -140,25 +150,26 @@ contract World is StoreRead, IStoreData, IWorldKernel { bytes32[] calldata key, uint8 schemaIndex, uint256 startByteIndex, - bytes calldata dataToSet + bytes calldata dataToSet, + Schema valueSchema ) public virtual { // Require access to namespace or name bytes32 resourceSelector = AccessControl.requireAccess(namespace, name, msg.sender); // Update data in the field - StoreCore.updateInField(resourceSelector, key, schemaIndex, startByteIndex, dataToSet); + StoreCore.updateInField(resourceSelector, key, schemaIndex, startByteIndex, dataToSet, valueSchema); } /** * Delete a record in the table at the given namespace and name. * Requires the caller to have access to the namespace or name. */ - function deleteRecord(bytes16 namespace, bytes16 name, bytes32[] calldata key) public virtual { + function deleteRecord(bytes16 namespace, bytes16 name, bytes32[] calldata key, Schema valueSchema) public virtual { // Require access to namespace or name bytes32 resourceSelector = AccessControl.requireAccess(namespace, name, msg.sender); // Delete the record - StoreCore.deleteRecord(resourceSelector, key); + StoreCore.deleteRecord(resourceSelector, key, valueSchema); } /************************************************************************ @@ -172,8 +183,8 @@ contract World is StoreRead, IStoreData, IWorldKernel { * This overload exists to conform with the `IStore` interface. * Access is checked based on the namespace or name (encoded in the tableId). */ - function setRecord(bytes32 tableId, bytes32[] calldata key, bytes calldata data) public virtual { - setRecord(tableId.getNamespace(), tableId.getName(), key, data); + function setRecord(bytes32 tableId, bytes32[] calldata key, bytes calldata data, Schema valueSchema) public virtual { + setRecord(tableId.getNamespace(), tableId.getName(), key, data, valueSchema); } /** @@ -185,9 +196,10 @@ contract World is StoreRead, IStoreData, IWorldKernel { bytes32 tableId, bytes32[] calldata key, uint8 schemaIndex, - bytes calldata data + bytes calldata data, + Schema valueSchema ) public virtual override { - setField(tableId.getNamespace(), tableId.getName(), key, schemaIndex, data); + setField(tableId.getNamespace(), tableId.getName(), key, schemaIndex, data, valueSchema); } /** @@ -199,9 +211,10 @@ contract World is StoreRead, IStoreData, IWorldKernel { bytes32 tableId, bytes32[] calldata key, uint8 schemaIndex, - bytes calldata dataToPush + bytes calldata dataToPush, + Schema valueSchema ) public override { - pushToField(tableId.getNamespace(), tableId.getName(), key, schemaIndex, dataToPush); + pushToField(tableId.getNamespace(), tableId.getName(), key, schemaIndex, dataToPush, valueSchema); } /** @@ -213,9 +226,10 @@ contract World is StoreRead, IStoreData, IWorldKernel { bytes32 tableId, bytes32[] calldata key, uint8 schemaIndex, - uint256 byteLengthToPop + uint256 byteLengthToPop, + Schema valueSchema ) public override { - popFromField(tableId.getNamespace(), tableId.getName(), key, schemaIndex, byteLengthToPop); + popFromField(tableId.getNamespace(), tableId.getName(), key, schemaIndex, byteLengthToPop, valueSchema); } /** @@ -228,9 +242,10 @@ contract World is StoreRead, IStoreData, IWorldKernel { bytes32[] calldata key, uint8 schemaIndex, uint256 startByteIndex, - bytes calldata dataToSet + bytes calldata dataToSet, + Schema valueSchema ) public virtual { - updateInField(tableId.getNamespace(), tableId.getName(), key, schemaIndex, startByteIndex, dataToSet); + updateInField(tableId.getNamespace(), tableId.getName(), key, schemaIndex, startByteIndex, dataToSet, valueSchema); } /** @@ -238,8 +253,8 @@ contract World is StoreRead, IStoreData, IWorldKernel { * This overload exists to conform with the `IStore` interface. * Access is checked based on the namespace or name (encoded in the tableId). */ - function deleteRecord(bytes32 tableId, bytes32[] calldata key) public virtual override { - deleteRecord(tableId.getNamespace(), tableId.getName(), key); + function deleteRecord(bytes32 tableId, bytes32[] calldata key, Schema valueSchema) public virtual override { + deleteRecord(tableId.getNamespace(), tableId.getName(), key, valueSchema); } /************************************************************************ diff --git a/packages/world/src/interfaces/IWorldEphemeral.sol b/packages/world/src/interfaces/IWorldEphemeral.sol index a1d36fe676..7616962411 100644 --- a/packages/world/src/interfaces/IWorldEphemeral.sol +++ b/packages/world/src/interfaces/IWorldEphemeral.sol @@ -1,6 +1,8 @@ // SPDX-License-Identifier: MIT pragma solidity >=0.8.0; +import { Schema } from "@latticexyz/store/src/Schema.sol"; + /** * Necessary in addition to `IStoreEphemeral` * because 2 functions with the same name need 2 separate interfaces to allow referencing their selector @@ -10,5 +12,11 @@ interface IWorldEphemeral { * Emit the ephemeral event without modifying storage at the given namespace and name. * Requires the caller to have access to the namespace or name. */ - function emitEphemeralRecord(bytes16 namespace, bytes16 name, bytes32[] calldata key, bytes calldata data) external; + function emitEphemeralRecord( + bytes16 namespace, + bytes16 name, + bytes32[] calldata key, + bytes calldata data, + Schema valueSchema + ) external; } diff --git a/packages/world/src/interfaces/IWorldKernel.sol b/packages/world/src/interfaces/IWorldKernel.sol index 03c3258431..7890c7bfd1 100644 --- a/packages/world/src/interfaces/IWorldKernel.sol +++ b/packages/world/src/interfaces/IWorldKernel.sol @@ -1,6 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity >=0.8.0; +import { Schema } from "@latticexyz/store/src/Schema.sol"; import { IWorldErrors } from "./IWorldErrors.sol"; import { IModule } from "./IModule.sol"; @@ -14,7 +15,13 @@ interface IWorldData { * Write a record in the table at the given namespace and name. * Requires the caller to have access to the namespace or name. */ - function setRecord(bytes16 namespace, bytes16 name, bytes32[] calldata key, bytes calldata data) external; + function setRecord( + bytes16 namespace, + bytes16 name, + bytes32[] calldata key, + bytes calldata data, + Schema valueSchema + ) external; /** * Write a field in the table at the given namespace and name. @@ -25,7 +32,8 @@ interface IWorldData { bytes16 name, bytes32[] calldata key, uint8 schemaIndex, - bytes calldata data + bytes calldata data, + Schema valueSchema ) external; /** @@ -37,7 +45,8 @@ interface IWorldData { bytes16 name, bytes32[] calldata key, uint8 schemaIndex, - bytes calldata dataToPush + bytes calldata dataToPush, + Schema valueSchema ) external; /** @@ -49,7 +58,8 @@ interface IWorldData { bytes16 name, bytes32[] calldata key, uint8 schemaIndex, - uint256 byteLengthToPop + uint256 byteLengthToPop, + Schema valueSchema ) external; /** @@ -62,14 +72,15 @@ interface IWorldData { bytes32[] calldata key, uint8 schemaIndex, uint256 startByteIndex, - bytes calldata dataToSet + bytes calldata dataToSet, + Schema valueSchema ) external; /** * Delete a record in the table at the given namespace and name. * Requires the caller to have access to the namespace or name. */ - function deleteRecord(bytes16 namespace, bytes16 name, bytes32[] calldata key) external; + function deleteRecord(bytes16 namespace, bytes16 name, bytes32[] calldata key, Schema valueSchema) external; } interface IWorldModuleInstallation { diff --git a/packages/world/src/modules/core/implementations/EphemeralRecordSystem.sol b/packages/world/src/modules/core/implementations/EphemeralRecordSystem.sol index 77156edb4f..b20fe81f57 100644 --- a/packages/world/src/modules/core/implementations/EphemeralRecordSystem.sol +++ b/packages/world/src/modules/core/implementations/EphemeralRecordSystem.sol @@ -2,6 +2,7 @@ pragma solidity >=0.8.0; import { IStoreEphemeral } from "@latticexyz/store/src/IStore.sol"; +import { Schema } from "@latticexyz/store/src/Schema.sol"; import { IModule } from "../../../interfaces/IModule.sol"; import { IWorldEphemeral } from "../../../interfaces/IWorldEphemeral.sol"; import { System } from "../../../System.sol"; @@ -23,13 +24,14 @@ contract EphemeralRecordSystem is IStoreEphemeral, IWorldEphemeral, System { bytes16 namespace, bytes16 name, bytes32[] calldata key, - bytes calldata data + bytes calldata data, + Schema valueSchema ) public virtual { // Require access to the namespace or name bytes32 resourceSelector = AccessControl.requireAccess(namespace, name, msg.sender); // Set the record - StoreCore.emitEphemeralRecord(resourceSelector, key, data); + StoreCore.emitEphemeralRecord(resourceSelector, key, data, valueSchema); } /** @@ -37,7 +39,12 @@ contract EphemeralRecordSystem is IStoreEphemeral, IWorldEphemeral, System { * This overload exists to conform with the `IStore` interface. * Access is checked based on the namespace or name (encoded in the tableId). */ - function emitEphemeralRecord(bytes32 tableId, bytes32[] calldata key, bytes calldata data) public virtual { - emitEphemeralRecord(tableId.getNamespace(), tableId.getName(), key, data); + function emitEphemeralRecord( + bytes32 tableId, + bytes32[] calldata key, + bytes calldata data, + Schema valueSchema + ) public virtual { + emitEphemeralRecord(tableId.getNamespace(), tableId.getName(), key, data, valueSchema); } } diff --git a/packages/world/src/modules/core/tables/FunctionSelectors.sol b/packages/world/src/modules/core/tables/FunctionSelectors.sol index b9324bdcc5..a45a9489d7 100644 --- a/packages/world/src/modules/core/tables/FunctionSelectors.sol +++ b/packages/world/src/modules/core/tables/FunctionSelectors.sol @@ -74,7 +74,7 @@ library FunctionSelectors { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(functionSelector); - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0, getSchema()); return (Bytes.slice16(_blob, 0)); } @@ -83,7 +83,7 @@ library FunctionSelectors { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(functionSelector); - bytes memory _blob = _store.getField(_tableId, _keyTuple, 0); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 0, getSchema()); return (Bytes.slice16(_blob, 0)); } @@ -92,7 +92,7 @@ library FunctionSelectors { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(functionSelector); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((namespace))); + StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((namespace)), getSchema()); } /** Set namespace (using the specified store) */ @@ -100,7 +100,7 @@ library FunctionSelectors { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(functionSelector); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((namespace))); + _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((namespace)), getSchema()); } /** Get name */ @@ -108,7 +108,7 @@ library FunctionSelectors { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(functionSelector); - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 1); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 1, getSchema()); return (Bytes.slice16(_blob, 0)); } @@ -117,7 +117,7 @@ library FunctionSelectors { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(functionSelector); - bytes memory _blob = _store.getField(_tableId, _keyTuple, 1); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 1, getSchema()); return (Bytes.slice16(_blob, 0)); } @@ -126,7 +126,7 @@ library FunctionSelectors { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(functionSelector); - StoreSwitch.setField(_tableId, _keyTuple, 1, abi.encodePacked((name))); + StoreSwitch.setField(_tableId, _keyTuple, 1, abi.encodePacked((name)), getSchema()); } /** Set name (using the specified store) */ @@ -134,7 +134,7 @@ library FunctionSelectors { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(functionSelector); - _store.setField(_tableId, _keyTuple, 1, abi.encodePacked((name))); + _store.setField(_tableId, _keyTuple, 1, abi.encodePacked((name)), getSchema()); } /** Get systemFunctionSelector */ @@ -142,7 +142,7 @@ library FunctionSelectors { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(functionSelector); - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 2); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 2, getSchema()); return (Bytes.slice4(_blob, 0)); } @@ -154,7 +154,7 @@ library FunctionSelectors { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(functionSelector); - bytes memory _blob = _store.getField(_tableId, _keyTuple, 2); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 2, getSchema()); return (Bytes.slice4(_blob, 0)); } @@ -163,7 +163,7 @@ library FunctionSelectors { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(functionSelector); - StoreSwitch.setField(_tableId, _keyTuple, 2, abi.encodePacked((systemFunctionSelector))); + StoreSwitch.setField(_tableId, _keyTuple, 2, abi.encodePacked((systemFunctionSelector)), getSchema()); } /** Set systemFunctionSelector (using the specified store) */ @@ -171,7 +171,7 @@ library FunctionSelectors { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(functionSelector); - _store.setField(_tableId, _keyTuple, 2, abi.encodePacked((systemFunctionSelector))); + _store.setField(_tableId, _keyTuple, 2, abi.encodePacked((systemFunctionSelector)), getSchema()); } /** Get the full data */ @@ -204,7 +204,7 @@ library FunctionSelectors { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(functionSelector); - StoreSwitch.setRecord(_tableId, _keyTuple, _data); + StoreSwitch.setRecord(_tableId, _keyTuple, _data, getSchema()); } /** Set the full data using individual values (using the specified store) */ @@ -220,7 +220,7 @@ library FunctionSelectors { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(functionSelector); - _store.setRecord(_tableId, _keyTuple, _data); + _store.setRecord(_tableId, _keyTuple, _data, getSchema()); } /** Decode the tightly packed blob using this table's schema */ @@ -252,7 +252,7 @@ library FunctionSelectors { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(functionSelector); - StoreSwitch.deleteRecord(_tableId, _keyTuple); + StoreSwitch.deleteRecord(_tableId, _keyTuple, getSchema()); } /* Delete all data for given keys (using the specified store) */ @@ -260,6 +260,6 @@ library FunctionSelectors { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(functionSelector); - _store.deleteRecord(_tableId, _keyTuple); + _store.deleteRecord(_tableId, _keyTuple, getSchema()); } } diff --git a/packages/world/src/modules/core/tables/ResourceType.sol b/packages/world/src/modules/core/tables/ResourceType.sol index d62ff7576c..9332605b34 100644 --- a/packages/world/src/modules/core/tables/ResourceType.sol +++ b/packages/world/src/modules/core/tables/ResourceType.sol @@ -73,7 +73,7 @@ library ResourceType { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = resourceSelector; - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0, getSchema()); return Resource(uint8(Bytes.slice1(_blob, 0))); } @@ -82,7 +82,7 @@ library ResourceType { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = resourceSelector; - bytes memory _blob = _store.getField(_tableId, _keyTuple, 0); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 0, getSchema()); return Resource(uint8(Bytes.slice1(_blob, 0))); } @@ -91,7 +91,7 @@ library ResourceType { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = resourceSelector; - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked(uint8(resourceType))); + StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked(uint8(resourceType)), getSchema()); } /** Set resourceType (using the specified store) */ @@ -99,7 +99,7 @@ library ResourceType { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = resourceSelector; - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked(uint8(resourceType))); + _store.setField(_tableId, _keyTuple, 0, abi.encodePacked(uint8(resourceType)), getSchema()); } /** Tightly pack full data using this table's schema */ @@ -120,7 +120,7 @@ library ResourceType { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = resourceSelector; - StoreSwitch.deleteRecord(_tableId, _keyTuple); + StoreSwitch.deleteRecord(_tableId, _keyTuple, getSchema()); } /* Delete all data for given keys (using the specified store) */ @@ -128,6 +128,6 @@ library ResourceType { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = resourceSelector; - _store.deleteRecord(_tableId, _keyTuple); + _store.deleteRecord(_tableId, _keyTuple, getSchema()); } } diff --git a/packages/world/src/modules/core/tables/SystemHooks.sol b/packages/world/src/modules/core/tables/SystemHooks.sol index 262125b965..c9fe64ef94 100644 --- a/packages/world/src/modules/core/tables/SystemHooks.sol +++ b/packages/world/src/modules/core/tables/SystemHooks.sol @@ -70,7 +70,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = resourceSelector; - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0, getSchema()); return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_address()); } @@ -79,7 +79,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = resourceSelector; - bytes memory _blob = _store.getField(_tableId, _keyTuple, 0); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 0, getSchema()); return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_address()); } @@ -88,7 +88,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = resourceSelector; - StoreSwitch.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); + StoreSwitch.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), getSchema()); } /** Set value (using the specified store) */ @@ -96,7 +96,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = resourceSelector; - _store.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); + _store.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), getSchema()); } /** Get the length of value */ @@ -161,7 +161,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = resourceSelector; - StoreSwitch.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); + StoreSwitch.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), getSchema()); } /** Push an element to value (using the specified store) */ @@ -169,7 +169,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = resourceSelector; - _store.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); + _store.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), getSchema()); } /** Pop an element from value */ @@ -177,7 +177,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = resourceSelector; - StoreSwitch.popFromField(_tableId, _keyTuple, 0, 20); + StoreSwitch.popFromField(_tableId, _keyTuple, 0, 20, getSchema()); } /** Pop an element from value (using the specified store) */ @@ -185,7 +185,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = resourceSelector; - _store.popFromField(_tableId, _keyTuple, 0, 20); + _store.popFromField(_tableId, _keyTuple, 0, 20, getSchema()); } /** @@ -197,7 +197,7 @@ library SystemHooks { _keyTuple[0] = resourceSelector; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 0, _index * 20, abi.encodePacked((_element))); + StoreSwitch.updateInField(_tableId, _keyTuple, 0, _index * 20, abi.encodePacked((_element)), getSchema()); } } @@ -210,7 +210,7 @@ library SystemHooks { _keyTuple[0] = resourceSelector; unchecked { - _store.updateInField(_tableId, _keyTuple, 0, _index * 20, abi.encodePacked((_element))); + _store.updateInField(_tableId, _keyTuple, 0, _index * 20, abi.encodePacked((_element)), getSchema()); } } @@ -236,7 +236,7 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = resourceSelector; - StoreSwitch.deleteRecord(_tableId, _keyTuple); + StoreSwitch.deleteRecord(_tableId, _keyTuple, getSchema()); } /* Delete all data for given keys (using the specified store) */ @@ -244,6 +244,6 @@ library SystemHooks { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = resourceSelector; - _store.deleteRecord(_tableId, _keyTuple); + _store.deleteRecord(_tableId, _keyTuple, getSchema()); } } diff --git a/packages/world/src/modules/core/tables/SystemRegistry.sol b/packages/world/src/modules/core/tables/SystemRegistry.sol index 2df68b1975..8f6b5abcc0 100644 --- a/packages/world/src/modules/core/tables/SystemRegistry.sol +++ b/packages/world/src/modules/core/tables/SystemRegistry.sol @@ -70,7 +70,7 @@ library SystemRegistry { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(uint160(system))); - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0, getSchema()); return (Bytes.slice32(_blob, 0)); } @@ -79,7 +79,7 @@ library SystemRegistry { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(uint160(system))); - bytes memory _blob = _store.getField(_tableId, _keyTuple, 0); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 0, getSchema()); return (Bytes.slice32(_blob, 0)); } @@ -88,7 +88,7 @@ library SystemRegistry { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(uint160(system))); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((resourceSelector))); + StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((resourceSelector)), getSchema()); } /** Set resourceSelector (using the specified store) */ @@ -96,7 +96,7 @@ library SystemRegistry { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(uint160(system))); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((resourceSelector))); + _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((resourceSelector)), getSchema()); } /** Tightly pack full data using this table's schema */ @@ -117,7 +117,7 @@ library SystemRegistry { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(uint160(system))); - StoreSwitch.deleteRecord(_tableId, _keyTuple); + StoreSwitch.deleteRecord(_tableId, _keyTuple, getSchema()); } /* Delete all data for given keys (using the specified store) */ @@ -125,6 +125,6 @@ library SystemRegistry { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(uint160(system))); - _store.deleteRecord(_tableId, _keyTuple); + _store.deleteRecord(_tableId, _keyTuple, getSchema()); } } diff --git a/packages/world/src/modules/core/tables/Systems.sol b/packages/world/src/modules/core/tables/Systems.sol index 15ea87a05c..ad0accbaa3 100644 --- a/packages/world/src/modules/core/tables/Systems.sol +++ b/packages/world/src/modules/core/tables/Systems.sol @@ -72,7 +72,7 @@ library Systems { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = resourceSelector; - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0, getSchema()); return (address(Bytes.slice20(_blob, 0))); } @@ -81,7 +81,7 @@ library Systems { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = resourceSelector; - bytes memory _blob = _store.getField(_tableId, _keyTuple, 0); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 0, getSchema()); return (address(Bytes.slice20(_blob, 0))); } @@ -90,7 +90,7 @@ library Systems { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = resourceSelector; - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((system))); + StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((system)), getSchema()); } /** Set system (using the specified store) */ @@ -98,7 +98,7 @@ library Systems { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = resourceSelector; - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((system))); + _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((system)), getSchema()); } /** Get publicAccess */ @@ -106,7 +106,7 @@ library Systems { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = resourceSelector; - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 1); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 1, getSchema()); return (_toBool(uint8(Bytes.slice1(_blob, 0)))); } @@ -115,7 +115,7 @@ library Systems { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = resourceSelector; - bytes memory _blob = _store.getField(_tableId, _keyTuple, 1); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 1, getSchema()); return (_toBool(uint8(Bytes.slice1(_blob, 0)))); } @@ -124,7 +124,7 @@ library Systems { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = resourceSelector; - StoreSwitch.setField(_tableId, _keyTuple, 1, abi.encodePacked((publicAccess))); + StoreSwitch.setField(_tableId, _keyTuple, 1, abi.encodePacked((publicAccess)), getSchema()); } /** Set publicAccess (using the specified store) */ @@ -132,7 +132,7 @@ library Systems { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = resourceSelector; - _store.setField(_tableId, _keyTuple, 1, abi.encodePacked((publicAccess))); + _store.setField(_tableId, _keyTuple, 1, abi.encodePacked((publicAccess)), getSchema()); } /** Get the full data */ @@ -160,7 +160,7 @@ library Systems { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = resourceSelector; - StoreSwitch.setRecord(_tableId, _keyTuple, _data); + StoreSwitch.setRecord(_tableId, _keyTuple, _data, getSchema()); } /** Set the full data using individual values (using the specified store) */ @@ -170,7 +170,7 @@ library Systems { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = resourceSelector; - _store.setRecord(_tableId, _keyTuple, _data); + _store.setRecord(_tableId, _keyTuple, _data, getSchema()); } /** Decode the tightly packed blob using this table's schema */ @@ -198,7 +198,7 @@ library Systems { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = resourceSelector; - StoreSwitch.deleteRecord(_tableId, _keyTuple); + StoreSwitch.deleteRecord(_tableId, _keyTuple, getSchema()); } /* Delete all data for given keys (using the specified store) */ @@ -206,7 +206,7 @@ library Systems { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = resourceSelector; - _store.deleteRecord(_tableId, _keyTuple); + _store.deleteRecord(_tableId, _keyTuple, getSchema()); } } diff --git a/packages/world/src/modules/keysintable/KeysInTableHook.sol b/packages/world/src/modules/keysintable/KeysInTableHook.sol index 747b5a709b..f2c4522de5 100644 --- a/packages/world/src/modules/keysintable/KeysInTableHook.sol +++ b/packages/world/src/modules/keysintable/KeysInTableHook.sol @@ -2,6 +2,7 @@ pragma solidity >=0.8.0; import { IStoreHook } from "@latticexyz/store/src/IStore.sol"; +import { Schema } from "@latticexyz/store/src/Schema.sol"; import { KeysInTable } from "./tables/KeysInTable.sol"; import { UsedKeysIndex } from "./tables/UsedKeysIndex.sol"; @@ -39,17 +40,17 @@ contract KeysInTableHook is IStoreHook { } } - function onSetRecord(bytes32 table, bytes32[] memory key, bytes memory) public { + function onSetRecord(bytes32 table, bytes32[] memory key, bytes memory, Schema) public { handleSet(table, key); } - function onBeforeSetField(bytes32 table, bytes32[] memory key, uint8, bytes memory) public {} + function onBeforeSetField(bytes32 table, bytes32[] memory key, uint8, bytes memory, Schema) public {} - function onAfterSetField(bytes32 table, bytes32[] memory key, uint8, bytes memory) public { + function onAfterSetField(bytes32 table, bytes32[] memory key, uint8, bytes memory, Schema) public { handleSet(table, key); } - function onDeleteRecord(bytes32 tableId, bytes32[] memory key) public { + function onDeleteRecord(bytes32 tableId, bytes32[] memory key, Schema) public { bytes32 keysHash = keccak256(abi.encode(key)); (bool has, uint40 index) = UsedKeysIndex.get(tableId, keysHash); diff --git a/packages/world/src/modules/keysintable/tables/KeysInTable.sol b/packages/world/src/modules/keysintable/tables/KeysInTable.sol index 9a10d7b3e7..4710be73d6 100644 --- a/packages/world/src/modules/keysintable/tables/KeysInTable.sol +++ b/packages/world/src/modules/keysintable/tables/KeysInTable.sol @@ -86,7 +86,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0, getSchema()); return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_bytes32()); } @@ -95,7 +95,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - bytes memory _blob = _store.getField(_tableId, _keyTuple, 0); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 0, getSchema()); return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_bytes32()); } @@ -104,7 +104,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.setField(_tableId, _keyTuple, 0, EncodeArray.encode((keys0))); + StoreSwitch.setField(_tableId, _keyTuple, 0, EncodeArray.encode((keys0)), getSchema()); } /** Set keys0 (using the specified store) */ @@ -112,7 +112,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.setField(_tableId, _keyTuple, 0, EncodeArray.encode((keys0))); + _store.setField(_tableId, _keyTuple, 0, EncodeArray.encode((keys0)), getSchema()); } /** Get the length of keys0 */ @@ -177,7 +177,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); + StoreSwitch.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), getSchema()); } /** Push an element to keys0 (using the specified store) */ @@ -185,7 +185,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); + _store.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), getSchema()); } /** Pop an element from keys0 */ @@ -193,7 +193,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.popFromField(_tableId, _keyTuple, 0, 32); + StoreSwitch.popFromField(_tableId, _keyTuple, 0, 32, getSchema()); } /** Pop an element from keys0 (using the specified store) */ @@ -201,7 +201,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.popFromField(_tableId, _keyTuple, 0, 32); + _store.popFromField(_tableId, _keyTuple, 0, 32, getSchema()); } /** @@ -213,7 +213,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element))); + StoreSwitch.updateInField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element)), getSchema()); } } @@ -226,7 +226,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - _store.updateInField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element))); + _store.updateInField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element)), getSchema()); } } @@ -235,7 +235,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 1); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 1, getSchema()); return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_bytes32()); } @@ -244,7 +244,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - bytes memory _blob = _store.getField(_tableId, _keyTuple, 1); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 1, getSchema()); return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_bytes32()); } @@ -253,7 +253,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.setField(_tableId, _keyTuple, 1, EncodeArray.encode((keys1))); + StoreSwitch.setField(_tableId, _keyTuple, 1, EncodeArray.encode((keys1)), getSchema()); } /** Set keys1 (using the specified store) */ @@ -261,7 +261,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.setField(_tableId, _keyTuple, 1, EncodeArray.encode((keys1))); + _store.setField(_tableId, _keyTuple, 1, EncodeArray.encode((keys1)), getSchema()); } /** Get the length of keys1 */ @@ -326,7 +326,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.pushToField(_tableId, _keyTuple, 1, abi.encodePacked((_element))); + StoreSwitch.pushToField(_tableId, _keyTuple, 1, abi.encodePacked((_element)), getSchema()); } /** Push an element to keys1 (using the specified store) */ @@ -334,7 +334,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.pushToField(_tableId, _keyTuple, 1, abi.encodePacked((_element))); + _store.pushToField(_tableId, _keyTuple, 1, abi.encodePacked((_element)), getSchema()); } /** Pop an element from keys1 */ @@ -342,7 +342,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.popFromField(_tableId, _keyTuple, 1, 32); + StoreSwitch.popFromField(_tableId, _keyTuple, 1, 32, getSchema()); } /** Pop an element from keys1 (using the specified store) */ @@ -350,7 +350,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.popFromField(_tableId, _keyTuple, 1, 32); + _store.popFromField(_tableId, _keyTuple, 1, 32, getSchema()); } /** @@ -362,7 +362,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 1, _index * 32, abi.encodePacked((_element))); + StoreSwitch.updateInField(_tableId, _keyTuple, 1, _index * 32, abi.encodePacked((_element)), getSchema()); } } @@ -375,7 +375,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - _store.updateInField(_tableId, _keyTuple, 1, _index * 32, abi.encodePacked((_element))); + _store.updateInField(_tableId, _keyTuple, 1, _index * 32, abi.encodePacked((_element)), getSchema()); } } @@ -384,7 +384,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 2); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 2, getSchema()); return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_bytes32()); } @@ -393,7 +393,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - bytes memory _blob = _store.getField(_tableId, _keyTuple, 2); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 2, getSchema()); return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_bytes32()); } @@ -402,7 +402,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.setField(_tableId, _keyTuple, 2, EncodeArray.encode((keys2))); + StoreSwitch.setField(_tableId, _keyTuple, 2, EncodeArray.encode((keys2)), getSchema()); } /** Set keys2 (using the specified store) */ @@ -410,7 +410,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.setField(_tableId, _keyTuple, 2, EncodeArray.encode((keys2))); + _store.setField(_tableId, _keyTuple, 2, EncodeArray.encode((keys2)), getSchema()); } /** Get the length of keys2 */ @@ -475,7 +475,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.pushToField(_tableId, _keyTuple, 2, abi.encodePacked((_element))); + StoreSwitch.pushToField(_tableId, _keyTuple, 2, abi.encodePacked((_element)), getSchema()); } /** Push an element to keys2 (using the specified store) */ @@ -483,7 +483,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.pushToField(_tableId, _keyTuple, 2, abi.encodePacked((_element))); + _store.pushToField(_tableId, _keyTuple, 2, abi.encodePacked((_element)), getSchema()); } /** Pop an element from keys2 */ @@ -491,7 +491,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.popFromField(_tableId, _keyTuple, 2, 32); + StoreSwitch.popFromField(_tableId, _keyTuple, 2, 32, getSchema()); } /** Pop an element from keys2 (using the specified store) */ @@ -499,7 +499,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.popFromField(_tableId, _keyTuple, 2, 32); + _store.popFromField(_tableId, _keyTuple, 2, 32, getSchema()); } /** @@ -511,7 +511,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 2, _index * 32, abi.encodePacked((_element))); + StoreSwitch.updateInField(_tableId, _keyTuple, 2, _index * 32, abi.encodePacked((_element)), getSchema()); } } @@ -524,7 +524,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - _store.updateInField(_tableId, _keyTuple, 2, _index * 32, abi.encodePacked((_element))); + _store.updateInField(_tableId, _keyTuple, 2, _index * 32, abi.encodePacked((_element)), getSchema()); } } @@ -533,7 +533,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 3); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 3, getSchema()); return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_bytes32()); } @@ -542,7 +542,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - bytes memory _blob = _store.getField(_tableId, _keyTuple, 3); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 3, getSchema()); return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_bytes32()); } @@ -551,7 +551,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.setField(_tableId, _keyTuple, 3, EncodeArray.encode((keys3))); + StoreSwitch.setField(_tableId, _keyTuple, 3, EncodeArray.encode((keys3)), getSchema()); } /** Set keys3 (using the specified store) */ @@ -559,7 +559,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.setField(_tableId, _keyTuple, 3, EncodeArray.encode((keys3))); + _store.setField(_tableId, _keyTuple, 3, EncodeArray.encode((keys3)), getSchema()); } /** Get the length of keys3 */ @@ -624,7 +624,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.pushToField(_tableId, _keyTuple, 3, abi.encodePacked((_element))); + StoreSwitch.pushToField(_tableId, _keyTuple, 3, abi.encodePacked((_element)), getSchema()); } /** Push an element to keys3 (using the specified store) */ @@ -632,7 +632,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.pushToField(_tableId, _keyTuple, 3, abi.encodePacked((_element))); + _store.pushToField(_tableId, _keyTuple, 3, abi.encodePacked((_element)), getSchema()); } /** Pop an element from keys3 */ @@ -640,7 +640,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.popFromField(_tableId, _keyTuple, 3, 32); + StoreSwitch.popFromField(_tableId, _keyTuple, 3, 32, getSchema()); } /** Pop an element from keys3 (using the specified store) */ @@ -648,7 +648,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.popFromField(_tableId, _keyTuple, 3, 32); + _store.popFromField(_tableId, _keyTuple, 3, 32, getSchema()); } /** @@ -660,7 +660,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 3, _index * 32, abi.encodePacked((_element))); + StoreSwitch.updateInField(_tableId, _keyTuple, 3, _index * 32, abi.encodePacked((_element)), getSchema()); } } @@ -673,7 +673,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - _store.updateInField(_tableId, _keyTuple, 3, _index * 32, abi.encodePacked((_element))); + _store.updateInField(_tableId, _keyTuple, 3, _index * 32, abi.encodePacked((_element)), getSchema()); } } @@ -682,7 +682,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 4); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 4, getSchema()); return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_bytes32()); } @@ -691,7 +691,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - bytes memory _blob = _store.getField(_tableId, _keyTuple, 4); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 4, getSchema()); return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_bytes32()); } @@ -700,7 +700,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.setField(_tableId, _keyTuple, 4, EncodeArray.encode((keys4))); + StoreSwitch.setField(_tableId, _keyTuple, 4, EncodeArray.encode((keys4)), getSchema()); } /** Set keys4 (using the specified store) */ @@ -708,7 +708,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.setField(_tableId, _keyTuple, 4, EncodeArray.encode((keys4))); + _store.setField(_tableId, _keyTuple, 4, EncodeArray.encode((keys4)), getSchema()); } /** Get the length of keys4 */ @@ -773,7 +773,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.pushToField(_tableId, _keyTuple, 4, abi.encodePacked((_element))); + StoreSwitch.pushToField(_tableId, _keyTuple, 4, abi.encodePacked((_element)), getSchema()); } /** Push an element to keys4 (using the specified store) */ @@ -781,7 +781,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.pushToField(_tableId, _keyTuple, 4, abi.encodePacked((_element))); + _store.pushToField(_tableId, _keyTuple, 4, abi.encodePacked((_element)), getSchema()); } /** Pop an element from keys4 */ @@ -789,7 +789,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.popFromField(_tableId, _keyTuple, 4, 32); + StoreSwitch.popFromField(_tableId, _keyTuple, 4, 32, getSchema()); } /** Pop an element from keys4 (using the specified store) */ @@ -797,7 +797,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.popFromField(_tableId, _keyTuple, 4, 32); + _store.popFromField(_tableId, _keyTuple, 4, 32, getSchema()); } /** @@ -809,7 +809,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 4, _index * 32, abi.encodePacked((_element))); + StoreSwitch.updateInField(_tableId, _keyTuple, 4, _index * 32, abi.encodePacked((_element)), getSchema()); } } @@ -822,7 +822,7 @@ library KeysInTable { _keyTuple[0] = sourceTable; unchecked { - _store.updateInField(_tableId, _keyTuple, 4, _index * 32, abi.encodePacked((_element))); + _store.updateInField(_tableId, _keyTuple, 4, _index * 32, abi.encodePacked((_element)), getSchema()); } } @@ -858,7 +858,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.setRecord(_tableId, _keyTuple, _data); + StoreSwitch.setRecord(_tableId, _keyTuple, _data, getSchema()); } /** Set the full data using individual values (using the specified store) */ @@ -876,7 +876,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.setRecord(_tableId, _keyTuple, _data); + _store.setRecord(_tableId, _keyTuple, _data, getSchema()); } /** Set the full data using the data struct */ @@ -973,7 +973,7 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - StoreSwitch.deleteRecord(_tableId, _keyTuple); + StoreSwitch.deleteRecord(_tableId, _keyTuple, getSchema()); } /* Delete all data for given keys (using the specified store) */ @@ -981,6 +981,6 @@ library KeysInTable { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; - _store.deleteRecord(_tableId, _keyTuple); + _store.deleteRecord(_tableId, _keyTuple, getSchema()); } } diff --git a/packages/world/src/modules/keysintable/tables/UsedKeysIndex.sol b/packages/world/src/modules/keysintable/tables/UsedKeysIndex.sol index 4bf9d9ce67..833dd2228d 100644 --- a/packages/world/src/modules/keysintable/tables/UsedKeysIndex.sol +++ b/packages/world/src/modules/keysintable/tables/UsedKeysIndex.sol @@ -74,7 +74,7 @@ library UsedKeysIndex { _keyTuple[0] = sourceTable; _keyTuple[1] = keysHash; - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0, getSchema()); return (_toBool(uint8(Bytes.slice1(_blob, 0)))); } @@ -84,7 +84,7 @@ library UsedKeysIndex { _keyTuple[0] = sourceTable; _keyTuple[1] = keysHash; - bytes memory _blob = _store.getField(_tableId, _keyTuple, 0); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 0, getSchema()); return (_toBool(uint8(Bytes.slice1(_blob, 0)))); } @@ -94,7 +94,7 @@ library UsedKeysIndex { _keyTuple[0] = sourceTable; _keyTuple[1] = keysHash; - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((has))); + StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((has)), getSchema()); } /** Set has (using the specified store) */ @@ -103,7 +103,7 @@ library UsedKeysIndex { _keyTuple[0] = sourceTable; _keyTuple[1] = keysHash; - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((has))); + _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((has)), getSchema()); } /** Get index */ @@ -112,7 +112,7 @@ library UsedKeysIndex { _keyTuple[0] = sourceTable; _keyTuple[1] = keysHash; - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 1); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 1, getSchema()); return (uint40(Bytes.slice5(_blob, 0))); } @@ -122,7 +122,7 @@ library UsedKeysIndex { _keyTuple[0] = sourceTable; _keyTuple[1] = keysHash; - bytes memory _blob = _store.getField(_tableId, _keyTuple, 1); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 1, getSchema()); return (uint40(Bytes.slice5(_blob, 0))); } @@ -132,7 +132,7 @@ library UsedKeysIndex { _keyTuple[0] = sourceTable; _keyTuple[1] = keysHash; - StoreSwitch.setField(_tableId, _keyTuple, 1, abi.encodePacked((index))); + StoreSwitch.setField(_tableId, _keyTuple, 1, abi.encodePacked((index)), getSchema()); } /** Set index (using the specified store) */ @@ -141,7 +141,7 @@ library UsedKeysIndex { _keyTuple[0] = sourceTable; _keyTuple[1] = keysHash; - _store.setField(_tableId, _keyTuple, 1, abi.encodePacked((index))); + _store.setField(_tableId, _keyTuple, 1, abi.encodePacked((index)), getSchema()); } /** Get the full data */ @@ -172,7 +172,7 @@ library UsedKeysIndex { _keyTuple[0] = sourceTable; _keyTuple[1] = keysHash; - StoreSwitch.setRecord(_tableId, _keyTuple, _data); + StoreSwitch.setRecord(_tableId, _keyTuple, _data, getSchema()); } /** Set the full data using individual values (using the specified store) */ @@ -183,7 +183,7 @@ library UsedKeysIndex { _keyTuple[0] = sourceTable; _keyTuple[1] = keysHash; - _store.setRecord(_tableId, _keyTuple, _data); + _store.setRecord(_tableId, _keyTuple, _data, getSchema()); } /** Decode the tightly packed blob using this table's schema */ @@ -213,7 +213,7 @@ library UsedKeysIndex { _keyTuple[0] = sourceTable; _keyTuple[1] = keysHash; - StoreSwitch.deleteRecord(_tableId, _keyTuple); + StoreSwitch.deleteRecord(_tableId, _keyTuple, getSchema()); } /* Delete all data for given keys (using the specified store) */ @@ -222,7 +222,7 @@ library UsedKeysIndex { _keyTuple[0] = sourceTable; _keyTuple[1] = keysHash; - _store.deleteRecord(_tableId, _keyTuple); + _store.deleteRecord(_tableId, _keyTuple, getSchema()); } } diff --git a/packages/world/src/modules/keyswithvalue/KeysWithValueHook.sol b/packages/world/src/modules/keyswithvalue/KeysWithValueHook.sol index 82d931d6ce..ce53f7792f 100644 --- a/packages/world/src/modules/keyswithvalue/KeysWithValueHook.sol +++ b/packages/world/src/modules/keyswithvalue/KeysWithValueHook.sol @@ -3,6 +3,7 @@ pragma solidity >=0.8.0; import { IStoreHook } from "@latticexyz/store/src/IStore.sol"; import { Bytes } from "@latticexyz/store/src/Bytes.sol"; +import { Schema } from "@latticexyz/store/src/Schema.sol"; import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; import { IBaseWorld } from "../../interfaces/IBaseWorld.sol"; @@ -29,11 +30,11 @@ contract KeysWithValueHook is IStoreHook { return IBaseWorld(StoreSwitch.getStoreAddress()); } - function onSetRecord(bytes32 sourceTableId, bytes32[] memory key, bytes memory data) public { + function onSetRecord(bytes32 sourceTableId, bytes32[] memory key, bytes memory data, Schema valueSchema) public { bytes32 targetTableId = getTargetTableSelector(MODULE_NAMESPACE, sourceTableId); // Get the previous value - bytes32 previousValue = keccak256(_world().getRecord(sourceTableId, key)); + bytes32 previousValue = keccak256(_world().getRecord(sourceTableId, key, valueSchema)); // Remove the key from the list of keys with the previous value _removeKeyFromList(targetTableId, key[0], previousValue); @@ -42,23 +43,35 @@ contract KeysWithValueHook is IStoreHook { KeysWithValue.push(targetTableId, keccak256(data), key[0]); } - function onBeforeSetField(bytes32 sourceTableId, bytes32[] memory key, uint8, bytes memory) public { + function onBeforeSetField( + bytes32 sourceTableId, + bytes32[] memory key, + uint8, + bytes memory, + Schema valueSchema + ) public { // Remove the key from the list of keys with the previous value - bytes32 previousValue = keccak256(_world().getRecord(sourceTableId, key)); + bytes32 previousValue = keccak256(_world().getRecord(sourceTableId, key, valueSchema)); bytes32 targetTableId = getTargetTableSelector(MODULE_NAMESPACE, sourceTableId); _removeKeyFromList(targetTableId, key[0], previousValue); } - function onAfterSetField(bytes32 sourceTableId, bytes32[] memory key, uint8, bytes memory) public { + function onAfterSetField( + bytes32 sourceTableId, + bytes32[] memory key, + uint8, + bytes memory, + Schema valueSchema + ) public { // Add the key to the list of keys with the new value - bytes32 newValue = keccak256(_world().getRecord(sourceTableId, key)); + bytes32 newValue = keccak256(_world().getRecord(sourceTableId, key, valueSchema)); bytes32 targetTableId = getTargetTableSelector(MODULE_NAMESPACE, sourceTableId); KeysWithValue.push(targetTableId, newValue, key[0]); } - function onDeleteRecord(bytes32 sourceTableId, bytes32[] memory key) public { + function onDeleteRecord(bytes32 sourceTableId, bytes32[] memory key, Schema valueSchema) public { // Remove the key from the list of keys with the previous value - bytes32 previousValue = keccak256(_world().getRecord(sourceTableId, key)); + bytes32 previousValue = keccak256(_world().getRecord(sourceTableId, key, valueSchema)); bytes32 targetTableId = getTargetTableSelector(MODULE_NAMESPACE, sourceTableId); _removeKeyFromList(targetTableId, key[0], previousValue); } diff --git a/packages/world/src/modules/keyswithvalue/tables/KeysWithValue.sol b/packages/world/src/modules/keyswithvalue/tables/KeysWithValue.sol index 9f9956e47e..0d35ca9b74 100644 --- a/packages/world/src/modules/keyswithvalue/tables/KeysWithValue.sol +++ b/packages/world/src/modules/keyswithvalue/tables/KeysWithValue.sol @@ -67,7 +67,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0, getSchema()); return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_bytes32()); } @@ -80,7 +80,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - bytes memory _blob = _store.getField(_tableId, _keyTuple, 0); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 0, getSchema()); return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_bytes32()); } @@ -89,7 +89,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - StoreSwitch.setField(_tableId, _keyTuple, 0, EncodeArray.encode((keysWithValue))); + StoreSwitch.setField(_tableId, _keyTuple, 0, EncodeArray.encode((keysWithValue)), getSchema()); } /** Set keysWithValue (using the specified store) */ @@ -97,7 +97,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - _store.setField(_tableId, _keyTuple, 0, EncodeArray.encode((keysWithValue))); + _store.setField(_tableId, _keyTuple, 0, EncodeArray.encode((keysWithValue)), getSchema()); } /** Get the length of keysWithValue */ @@ -162,7 +162,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - StoreSwitch.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); + StoreSwitch.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), getSchema()); } /** Push an element to keysWithValue (using the specified store) */ @@ -170,7 +170,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - _store.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); + _store.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), getSchema()); } /** Pop an element from keysWithValue */ @@ -178,7 +178,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - StoreSwitch.popFromField(_tableId, _keyTuple, 0, 32); + StoreSwitch.popFromField(_tableId, _keyTuple, 0, 32, getSchema()); } /** Pop an element from keysWithValue (using the specified store) */ @@ -186,7 +186,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - _store.popFromField(_tableId, _keyTuple, 0, 32); + _store.popFromField(_tableId, _keyTuple, 0, 32, getSchema()); } /** @@ -198,7 +198,7 @@ library KeysWithValue { _keyTuple[0] = valueHash; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element))); + StoreSwitch.updateInField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element)), getSchema()); } } @@ -211,7 +211,7 @@ library KeysWithValue { _keyTuple[0] = valueHash; unchecked { - _store.updateInField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element))); + _store.updateInField(_tableId, _keyTuple, 0, _index * 32, abi.encodePacked((_element)), getSchema()); } } @@ -237,7 +237,7 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - StoreSwitch.deleteRecord(_tableId, _keyTuple); + StoreSwitch.deleteRecord(_tableId, _keyTuple, getSchema()); } /* Delete all data for given keys (using the specified store) */ @@ -245,6 +245,6 @@ library KeysWithValue { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; - _store.deleteRecord(_tableId, _keyTuple); + _store.deleteRecord(_tableId, _keyTuple, getSchema()); } } diff --git a/packages/world/src/modules/uniqueentity/tables/UniqueEntity.sol b/packages/world/src/modules/uniqueentity/tables/UniqueEntity.sol index bbcf97aca2..273500b356 100644 --- a/packages/world/src/modules/uniqueentity/tables/UniqueEntity.sol +++ b/packages/world/src/modules/uniqueentity/tables/UniqueEntity.sol @@ -65,7 +65,7 @@ library UniqueEntity { function get(bytes32 _tableId) internal view returns (uint256 value) { bytes32[] memory _keyTuple = new bytes32[](0); - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0, getSchema()); return (uint256(Bytes.slice32(_blob, 0))); } @@ -73,7 +73,7 @@ library UniqueEntity { function get(IStore _store, bytes32 _tableId) internal view returns (uint256 value) { bytes32[] memory _keyTuple = new bytes32[](0); - bytes memory _blob = _store.getField(_tableId, _keyTuple, 0); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 0, getSchema()); return (uint256(Bytes.slice32(_blob, 0))); } @@ -81,14 +81,14 @@ library UniqueEntity { function set(bytes32 _tableId, uint256 value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((value))); + StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), getSchema()); } /** Set value (using the specified store) */ function set(IStore _store, bytes32 _tableId, uint256 value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((value))); + _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), getSchema()); } /** Tightly pack full data using this table's schema */ @@ -107,13 +107,13 @@ library UniqueEntity { function deleteRecord(bytes32 _tableId) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.deleteRecord(_tableId, _keyTuple); + StoreSwitch.deleteRecord(_tableId, _keyTuple, getSchema()); } /* Delete all data for given keys (using the specified store) */ function deleteRecord(IStore _store, bytes32 _tableId) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.deleteRecord(_tableId, _keyTuple); + _store.deleteRecord(_tableId, _keyTuple, getSchema()); } } diff --git a/packages/world/src/tables/InstalledModules.sol b/packages/world/src/tables/InstalledModules.sol index aad89738e4..9370712a20 100644 --- a/packages/world/src/tables/InstalledModules.sol +++ b/packages/world/src/tables/InstalledModules.sol @@ -76,7 +76,7 @@ library InstalledModules { _keyTuple[0] = bytes32(moduleName); _keyTuple[1] = argumentsHash; - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0, getSchema()); return (address(Bytes.slice20(_blob, 0))); } @@ -90,7 +90,7 @@ library InstalledModules { _keyTuple[0] = bytes32(moduleName); _keyTuple[1] = argumentsHash; - bytes memory _blob = _store.getField(_tableId, _keyTuple, 0); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 0, getSchema()); return (address(Bytes.slice20(_blob, 0))); } @@ -100,7 +100,7 @@ library InstalledModules { _keyTuple[0] = bytes32(moduleName); _keyTuple[1] = argumentsHash; - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((moduleAddress))); + StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((moduleAddress)), getSchema()); } /** Set moduleAddress (using the specified store) */ @@ -109,7 +109,7 @@ library InstalledModules { _keyTuple[0] = bytes32(moduleName); _keyTuple[1] = argumentsHash; - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((moduleAddress))); + _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((moduleAddress)), getSchema()); } /** Get the full data */ @@ -144,7 +144,7 @@ library InstalledModules { _keyTuple[0] = bytes32(moduleName); _keyTuple[1] = argumentsHash; - StoreSwitch.setRecord(_tableId, _keyTuple, _data); + StoreSwitch.setRecord(_tableId, _keyTuple, _data, getSchema()); } /** Set the full data using individual values (using the specified store) */ @@ -155,7 +155,7 @@ library InstalledModules { _keyTuple[0] = bytes32(moduleName); _keyTuple[1] = argumentsHash; - _store.setRecord(_tableId, _keyTuple, _data); + _store.setRecord(_tableId, _keyTuple, _data, getSchema()); } /** Set the full data using the data struct */ @@ -193,7 +193,7 @@ library InstalledModules { _keyTuple[0] = bytes32(moduleName); _keyTuple[1] = argumentsHash; - StoreSwitch.deleteRecord(_tableId, _keyTuple); + StoreSwitch.deleteRecord(_tableId, _keyTuple, getSchema()); } /* Delete all data for given keys (using the specified store) */ @@ -202,6 +202,6 @@ library InstalledModules { _keyTuple[0] = bytes32(moduleName); _keyTuple[1] = argumentsHash; - _store.deleteRecord(_tableId, _keyTuple); + _store.deleteRecord(_tableId, _keyTuple, getSchema()); } } diff --git a/packages/world/src/tables/NamespaceOwner.sol b/packages/world/src/tables/NamespaceOwner.sol index b509ee5674..79c2a002a5 100644 --- a/packages/world/src/tables/NamespaceOwner.sol +++ b/packages/world/src/tables/NamespaceOwner.sol @@ -70,7 +70,7 @@ library NamespaceOwner { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(namespace); - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0, getSchema()); return (address(Bytes.slice20(_blob, 0))); } @@ -79,7 +79,7 @@ library NamespaceOwner { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(namespace); - bytes memory _blob = _store.getField(_tableId, _keyTuple, 0); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 0, getSchema()); return (address(Bytes.slice20(_blob, 0))); } @@ -88,7 +88,7 @@ library NamespaceOwner { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(namespace); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((owner))); + StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((owner)), getSchema()); } /** Set owner (using the specified store) */ @@ -96,7 +96,7 @@ library NamespaceOwner { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(namespace); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((owner))); + _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((owner)), getSchema()); } /** Tightly pack full data using this table's schema */ @@ -117,7 +117,7 @@ library NamespaceOwner { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(namespace); - StoreSwitch.deleteRecord(_tableId, _keyTuple); + StoreSwitch.deleteRecord(_tableId, _keyTuple, getSchema()); } /* Delete all data for given keys (using the specified store) */ @@ -125,6 +125,6 @@ library NamespaceOwner { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(namespace); - _store.deleteRecord(_tableId, _keyTuple); + _store.deleteRecord(_tableId, _keyTuple, getSchema()); } } diff --git a/packages/world/src/tables/ResourceAccess.sol b/packages/world/src/tables/ResourceAccess.sol index 0bacd48605..a5d8fde47f 100644 --- a/packages/world/src/tables/ResourceAccess.sol +++ b/packages/world/src/tables/ResourceAccess.sol @@ -72,7 +72,7 @@ library ResourceAccess { _keyTuple[0] = resourceSelector; _keyTuple[1] = bytes32(uint256(uint160(caller))); - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0, getSchema()); return (_toBool(uint8(Bytes.slice1(_blob, 0)))); } @@ -82,7 +82,7 @@ library ResourceAccess { _keyTuple[0] = resourceSelector; _keyTuple[1] = bytes32(uint256(uint160(caller))); - bytes memory _blob = _store.getField(_tableId, _keyTuple, 0); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 0, getSchema()); return (_toBool(uint8(Bytes.slice1(_blob, 0)))); } @@ -92,7 +92,7 @@ library ResourceAccess { _keyTuple[0] = resourceSelector; _keyTuple[1] = bytes32(uint256(uint160(caller))); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((access))); + StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((access)), getSchema()); } /** Set access (using the specified store) */ @@ -101,7 +101,7 @@ library ResourceAccess { _keyTuple[0] = resourceSelector; _keyTuple[1] = bytes32(uint256(uint160(caller))); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((access))); + _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((access)), getSchema()); } /** Tightly pack full data using this table's schema */ @@ -124,7 +124,7 @@ library ResourceAccess { _keyTuple[0] = resourceSelector; _keyTuple[1] = bytes32(uint256(uint160(caller))); - StoreSwitch.deleteRecord(_tableId, _keyTuple); + StoreSwitch.deleteRecord(_tableId, _keyTuple, getSchema()); } /* Delete all data for given keys (using the specified store) */ @@ -133,7 +133,7 @@ library ResourceAccess { _keyTuple[0] = resourceSelector; _keyTuple[1] = bytes32(uint256(uint160(caller))); - _store.deleteRecord(_tableId, _keyTuple); + _store.deleteRecord(_tableId, _keyTuple, getSchema()); } } diff --git a/packages/world/test/KeysInTableModule.t.sol b/packages/world/test/KeysInTableModule.t.sol index dd6b057bc5..b330eaaa0c 100644 --- a/packages/world/test/KeysInTableModule.t.sol +++ b/packages/world/test/KeysInTableModule.t.sol @@ -86,7 +86,7 @@ contract KeysInTableModuleTest is Test, GasReporter { bytes32[] memory keyTuple = new bytes32[](0); - world.setRecord(namespace, singletonName, keyTuple, abi.encodePacked(val1)); + world.setRecord(namespace, singletonName, keyTuple, abi.encodePacked(val1), tableSchema); // Get the list of keys in this target table bytes32[][] memory keysInTable = getKeysInTable(world, singletonTableId); @@ -103,7 +103,7 @@ contract KeysInTableModuleTest is Test, GasReporter { keyTuple[1] = "two"; keyTuple[2] = "three"; - world.setRecord(namespace, compositeName, keyTuple, abi.encodePacked(val1)); + world.setRecord(namespace, compositeName, keyTuple, abi.encodePacked(val1), tableSchema); // Get the list of keys in this target table bytes32[][] memory keysInTable = getKeysInTable(world, compositeTableId); @@ -128,7 +128,7 @@ contract KeysInTableModuleTest is Test, GasReporter { _installKeysInTableModule(); // Set a value in the source table startGasReport("set a record on a table with keysInTableModule installed"); - world.setRecord(namespace, name, keyTuple1, abi.encodePacked(value)); + world.setRecord(namespace, name, keyTuple1, abi.encodePacked(value), tableSchema); endGasReport(); // Get the list of keys in this target table @@ -147,7 +147,7 @@ contract KeysInTableModuleTest is Test, GasReporter { // Set a value in the source table startGasReport("set a record on a table with keysInTableModule installed (first)"); - world.setRecord(namespace, name, keyTuple, abi.encodePacked(value1)); + world.setRecord(namespace, name, keyTuple, abi.encodePacked(value1), tableSchema); endGasReport(); // Get the list of keys in the first target table @@ -167,7 +167,7 @@ contract KeysInTableModuleTest is Test, GasReporter { // Set a value in the source table startGasReport("set a record on a table with keysInTableModule installed (second)"); - world.setRecord(namespace, sourceFile2, keyTuple, abi.encodePacked(value2)); + world.setRecord(namespace, sourceFile2, keyTuple, abi.encodePacked(value2), tableSchema); endGasReport(); // Get the list of keys in the second target table @@ -187,7 +187,7 @@ contract KeysInTableModuleTest is Test, GasReporter { _installKeysInTableModule(); // Set a value in the source table - world.setRecord(namespace, name, keyTuple1, abi.encodePacked(value1)); + world.setRecord(namespace, name, keyTuple1, abi.encodePacked(value1), tableSchema); // Get the list of keys in the target table bytes32[][] memory keysInTable = getKeysInTable(world, tableId); @@ -197,7 +197,7 @@ contract KeysInTableModuleTest is Test, GasReporter { assertEq(keysInTable[0][0], key1, "2"); // Set another key with the same value - world.setRecord(namespace, name, keyTuple2, abi.encodePacked(value1)); + world.setRecord(namespace, name, keyTuple2, abi.encodePacked(value1), tableSchema); // Get the list of keys in the target table keysInTable = getKeysInTable(world, tableId); @@ -209,7 +209,7 @@ contract KeysInTableModuleTest is Test, GasReporter { // Change the value of the first key startGasReport("change a record on a table with keysInTableModule installed"); - world.setRecord(namespace, name, keyTuple1, abi.encodePacked(value2)); + world.setRecord(namespace, name, keyTuple1, abi.encodePacked(value2), tableSchema); endGasReport(); // Get the list of keys in the target table @@ -222,7 +222,7 @@ contract KeysInTableModuleTest is Test, GasReporter { // Delete the first key startGasReport("delete a record on a table with keysInTableModule installed"); - world.deleteRecord(namespace, name, keyTuple1); + world.deleteRecord(namespace, name, keyTuple1, tableSchema); endGasReport(); // Get the list of keys in the target table @@ -252,7 +252,7 @@ contract KeysInTableModuleTest is Test, GasReporter { keyTupleB[2] = "charlie"; // Set a value in the source table - world.setRecord(namespace, compositeName, keyTupleA, abi.encodePacked(value1)); + world.setRecord(namespace, compositeName, keyTupleA, abi.encodePacked(value1), tableSchema); // Get the list of keys in the target table bytes32[][] memory keysInTable = getKeysInTable(world, compositeTableId); @@ -264,7 +264,7 @@ contract KeysInTableModuleTest is Test, GasReporter { } // Set another key with the same value - world.setRecord(namespace, compositeName, keyTupleB, abi.encodePacked(value1)); + world.setRecord(namespace, compositeName, keyTupleB, abi.encodePacked(value1), tableSchema); // Get the list of keys in the target table keysInTable = getKeysInTable(world, compositeTableId); @@ -280,7 +280,7 @@ contract KeysInTableModuleTest is Test, GasReporter { // Change the value of the first key startGasReport("change a composite record on a table with keysInTableModule installed"); - world.setRecord(namespace, compositeName, keyTupleA, abi.encodePacked(value2)); + world.setRecord(namespace, compositeName, keyTupleA, abi.encodePacked(value2), tableSchema); endGasReport(); // Get the list of keys in the target table @@ -297,7 +297,7 @@ contract KeysInTableModuleTest is Test, GasReporter { // Delete the first key startGasReport("delete a composite record on a table with keysInTableModule installed"); - world.deleteRecord(namespace, compositeName, keyTupleA); + world.deleteRecord(namespace, compositeName, keyTupleA, tableSchema); endGasReport(); // Get the list of keys in the target table @@ -315,7 +315,7 @@ contract KeysInTableModuleTest is Test, GasReporter { // Set a value in the source table startGasReport("set a field on a table with keysInTableModule installed"); - world.setField(namespace, name, keyTuple1, 0, abi.encodePacked(value1)); + world.setField(namespace, name, keyTuple1, 0, abi.encodePacked(value1), tableSchema); endGasReport(); // Get the list of keys in the target table @@ -327,7 +327,7 @@ contract KeysInTableModuleTest is Test, GasReporter { // Change the value using setField startGasReport("change a field on a table with keysInTableModule installed"); - world.setField(namespace, name, keyTuple1, 0, abi.encodePacked(value2)); + world.setField(namespace, name, keyTuple1, 0, abi.encodePacked(value2), tableSchema); endGasReport(); // Get the list of keys in the target table @@ -342,7 +342,7 @@ contract KeysInTableModuleTest is Test, GasReporter { _installKeysInTableModule(); // Set a value in the source table - world.setRecord(namespace, name, keyTuple1, abi.encodePacked(value1)); + world.setRecord(namespace, name, keyTuple1, abi.encodePacked(value1), tableSchema); startGasReport("Get list of keys in a given table"); bytes32[][] memory keysInTable = getKeysInTable(world, tableId); @@ -353,7 +353,7 @@ contract KeysInTableModuleTest is Test, GasReporter { assertEq(keysInTable[0][0], key1); // Set another key with a different value - world.setRecord(namespace, name, keyTuple2, abi.encodePacked(value2)); + world.setRecord(namespace, name, keyTuple2, abi.encodePacked(value2), tableSchema); // Get the list of keys in the target table keysInTable = getKeysInTable(world, tableId); @@ -368,14 +368,14 @@ contract KeysInTableModuleTest is Test, GasReporter { _installKeysInTableModule(); // Add 3 values - world.setRecord(namespace, name, keyTuple1, abi.encodePacked(value)); - world.setRecord(namespace, name, keyTuple2, abi.encodePacked(value)); - world.setRecord(namespace, name, keyTuple3, abi.encodePacked(value)); + world.setRecord(namespace, name, keyTuple1, abi.encodePacked(value), tableSchema); + world.setRecord(namespace, name, keyTuple2, abi.encodePacked(value), tableSchema); + world.setRecord(namespace, name, keyTuple3, abi.encodePacked(value), tableSchema); // Remove 2, starting from the middle // This tests that KeysInTable correctly tracks swaps indexes - world.deleteRecord(namespace, name, keyTuple2); - world.deleteRecord(namespace, name, keyTuple3); + world.deleteRecord(namespace, name, keyTuple2, tableSchema); + world.deleteRecord(namespace, name, keyTuple3, tableSchema); // Get the list of keys in the target table bytes32[][] memory keysInTable = getKeysInTable(world, tableId); diff --git a/packages/world/test/KeysWithValueModule.t.sol b/packages/world/test/KeysWithValueModule.t.sol index 0a063c41ac..5ab148ca00 100644 --- a/packages/world/test/KeysWithValueModule.t.sol +++ b/packages/world/test/KeysWithValueModule.t.sol @@ -68,7 +68,7 @@ contract KeysWithValueModuleTest is Test, GasReporter { uint256 value = 1; startGasReport("set a record on a table with KeysWithValueModule installed"); - world.setRecord(namespace, sourceName, keyTuple1, abi.encodePacked(value)); + world.setRecord(namespace, sourceName, keyTuple1, abi.encodePacked(value), sourceTableSchema); endGasReport(); // Get the list of entities with this value from the target table @@ -85,7 +85,7 @@ contract KeysWithValueModuleTest is Test, GasReporter { // Set a value in the source table uint256 value1 = 1; - world.setRecord(namespace, sourceName, keyTuple1, abi.encodePacked(value1)); + world.setRecord(namespace, sourceName, keyTuple1, abi.encodePacked(value1), sourceTableSchema); // Get the list of entities with value1 from the target table bytes32[] memory keysWithValue = KeysWithValue.get(world, targetTableId, keccak256(abi.encode(value1))); @@ -95,7 +95,7 @@ contract KeysWithValueModuleTest is Test, GasReporter { assertEq(keysWithValue[0], key1, "2"); // Set a another key with the same value - world.setRecord(namespace, sourceName, keyTuple2, abi.encodePacked(value1)); + world.setRecord(namespace, sourceName, keyTuple2, abi.encodePacked(value1), sourceTableSchema); // Get the list of entities with value2 from the target table keysWithValue = KeysWithValue.get(world, targetTableId, keccak256(abi.encode(value1))); @@ -109,7 +109,7 @@ contract KeysWithValueModuleTest is Test, GasReporter { uint256 value2 = 2; startGasReport("change a record on a table with KeysWithValueModule installed"); - world.setRecord(namespace, sourceName, keyTuple1, abi.encodePacked(value2)); + world.setRecord(namespace, sourceName, keyTuple1, abi.encodePacked(value2), sourceTableSchema); endGasReport(); // Get the list of entities with value1 from the target table @@ -128,7 +128,7 @@ contract KeysWithValueModuleTest is Test, GasReporter { // Delete the first key startGasReport("delete a record on a table with KeysWithValueModule installed"); - world.deleteRecord(namespace, sourceName, keyTuple1); + world.deleteRecord(namespace, sourceName, keyTuple1, sourceTableSchema); endGasReport(); // Get the list of entities with value2 from the target table @@ -145,7 +145,7 @@ contract KeysWithValueModuleTest is Test, GasReporter { uint256 value1 = 1; startGasReport("set a field on a table with KeysWithValueModule installed"); - world.setField(namespace, sourceName, keyTuple1, 0, abi.encodePacked(value1)); + world.setField(namespace, sourceName, keyTuple1, 0, abi.encodePacked(value1), sourceTableSchema); endGasReport(); // Get the list of entities with value1 from the target table @@ -159,7 +159,7 @@ contract KeysWithValueModuleTest is Test, GasReporter { // Change the value using setField startGasReport("change a field on a table with KeysWithValueModule installed"); - world.setField(namespace, sourceName, keyTuple1, 0, abi.encodePacked(value2)); + world.setField(namespace, sourceName, keyTuple1, 0, abi.encodePacked(value2), sourceTableSchema); endGasReport(); // Get the list of entities with value1 from the target table @@ -200,7 +200,7 @@ contract KeysWithValueModuleTest is Test, GasReporter { _installKeysWithValueModule(); // Set a value in the source table - world.setRecord(namespace, sourceName, keyTuple1, abi.encodePacked(value)); + world.setRecord(namespace, sourceName, keyTuple1, abi.encodePacked(value), sourceTableSchema); startGasReport("Get list of keys with a given value"); bytes32[] memory keysWithValue = getKeysWithValue(world, sourceTableId, abi.encode(value)); @@ -211,7 +211,7 @@ contract KeysWithValueModuleTest is Test, GasReporter { assertEq(keysWithValue[0], key1); // Set a another key with the same value - world.setRecord(namespace, sourceName, keyTuple2, abi.encodePacked(value)); + world.setRecord(namespace, sourceName, keyTuple2, abi.encodePacked(value), sourceTableSchema); // Get the list of keys with value from the target table keysWithValue = getKeysWithValue(world, sourceTableId, abi.encode(value)); diff --git a/packages/world/test/World.t.sol b/packages/world/test/World.t.sol index c34aacb87f..ac82db2502 100644 --- a/packages/world/test/World.t.sol +++ b/packages/world/test/World.t.sol @@ -76,12 +76,13 @@ contract WorldTestSystem is System { function writeData(bytes16 namespace, bytes16 name, bool data) public { bytes32[] memory key = new bytes32[](0); + bytes32 tableId = ResourceSelector.from(namespace, name); + Schema valueSchema = StoreSwitch.getSchema(tableId); if (StoreSwitch.getStoreAddress() == address(this)) { - bytes32 tableId = ResourceSelector.from(namespace, name); - StoreCore.setRecord(tableId, key, abi.encodePacked(data)); + StoreCore.setRecord(tableId, key, abi.encodePacked(data), valueSchema); } else { - IBaseWorld(msg.sender).setRecord(namespace, name, key, abi.encodePacked(data)); + IBaseWorld(msg.sender).setRecord(namespace, name, key, abi.encodePacked(data), valueSchema); } } @@ -107,20 +108,32 @@ contract PayableFallbackSystem is System { contract WorldTestTableHook is IStoreHook { event HookCalled(bytes data); - function onSetRecord(bytes32 table, bytes32[] memory key, bytes memory data) public { - emit HookCalled(abi.encode(table, key, data)); + function onSetRecord(bytes32 table, bytes32[] memory key, bytes memory data, Schema valueSchema) public { + emit HookCalled(abi.encode(table, key, data, valueSchema)); } - function onBeforeSetField(bytes32 table, bytes32[] memory key, uint8 schemaIndex, bytes memory data) public { - emit HookCalled(abi.encode(table, key, schemaIndex, data)); + function onBeforeSetField( + bytes32 table, + bytes32[] memory key, + uint8 schemaIndex, + bytes memory data, + Schema valueSchema + ) public { + emit HookCalled(abi.encode(table, key, schemaIndex, data, valueSchema)); } - function onAfterSetField(bytes32 table, bytes32[] memory key, uint8 schemaIndex, bytes memory data) public { - emit HookCalled(abi.encode(table, key, schemaIndex, data)); + function onAfterSetField( + bytes32 table, + bytes32[] memory key, + uint8 schemaIndex, + bytes memory data, + Schema valueSchema + ) public { + emit HookCalled(abi.encode(table, key, schemaIndex, data, valueSchema)); } - function onDeleteRecord(bytes32 table, bytes32[] memory key) public { - emit HookCalled(abi.encode(table, key)); + function onDeleteRecord(bytes32 table, bytes32[] memory key, Schema valueSchema) public { + emit HookCalled(abi.encode(table, key, valueSchema)); } } @@ -180,7 +193,11 @@ contract WorldTest is Test, GasReporter { bytes32[] memory schemaKey = new bytes32[](1); schemaKey[0] = StoreCoreInternal.SCHEMA_TABLE; - bytes memory value = world.getRecord(StoreCoreInternal.SCHEMA_TABLE, schemaKey); + bytes memory value = world.getRecord( + StoreCoreInternal.SCHEMA_TABLE, + schemaKey, + SchemaEncodeHelper.encode(SchemaType.BYTES32, SchemaType.BYTES32) + ); assertEq( value, abi.encodePacked( @@ -405,42 +422,44 @@ contract WorldTest is Test, GasReporter { function testSetField() public { bytes16 namespace = "testSetField"; bytes16 name = "testTable"; + Schema schema = Bool.getSchema(); // Register a new table - bytes32 tableId = world.registerTable(namespace, name, Bool.getSchema(), defaultKeySchema); + bytes32 tableId = world.registerTable(namespace, name, schema, defaultKeySchema); startGasReport("Write data to a table field"); - world.setField(namespace, name, singletonKey, 0, abi.encodePacked(true)); + world.setField(namespace, name, singletonKey, 0, abi.encodePacked(true), schema); endGasReport(); // Expect the data to be written assertTrue(Bool.get(world, tableId)); // Write data to the table via its tableId - world.setField(tableId, singletonKey, 0, abi.encodePacked(false)); + world.setField(tableId, singletonKey, 0, abi.encodePacked(false), schema); // Expect the data to be written assertFalse(Bool.get(world, tableId)); // Expect an error when trying to write from an address that doesn't have access when calling via the namespace _expectAccessDenied(address(0x01), "testSetField", "testTable"); - world.setField("testSetField", "testTable", singletonKey, 0, abi.encodePacked(true)); + world.setField("testSetField", "testTable", singletonKey, 0, abi.encodePacked(true), schema); // Expect an error when trying to write from an address that doesn't have access when calling via the tableId _expectAccessDenied(address(0x01), "testSetField", "testTable"); - world.setField(tableId, singletonKey, 0, abi.encodePacked(true)); + world.setField(tableId, singletonKey, 0, abi.encodePacked(true), schema); // Expect the World to have access vm.prank(address(world)); - world.setField("testSetField", "testTable", singletonKey, 0, abi.encodePacked(true)); + world.setField("testSetField", "testTable", singletonKey, 0, abi.encodePacked(true), schema); } function testPushToField() public { bytes16 namespace = "testPushToField"; bytes16 name = "testTable"; + Schema schema = AddressArray.getSchema(); // Register a new table - bytes32 tableId = world.registerTable(namespace, name, AddressArray.getSchema(), defaultKeySchema); + bytes32 tableId = world.registerTable(namespace, name, schema, defaultKeySchema); // Create data address[] memory dataToPush = new address[](3); @@ -450,75 +469,76 @@ contract WorldTest is Test, GasReporter { bytes memory encodedData = EncodeArray.encode(dataToPush); startGasReport("Push data to the table"); - world.pushToField(namespace, name, keyTuple, 0, encodedData); + world.pushToField(namespace, name, keyTuple, 0, encodedData, schema); endGasReport(); // Expect the data to be written assertEq(AddressArray.get(world, tableId, key), dataToPush); // Delete the data - world.deleteRecord(namespace, name, keyTuple); + world.deleteRecord(namespace, name, keyTuple, schema); // Push data to the table via direct access - world.pushToField(tableId, keyTuple, 0, encodedData); + world.pushToField(tableId, keyTuple, 0, encodedData, schema); // Expect the data to be written assertEq(AddressArray.get(world, tableId, key), dataToPush); // Expect an error when trying to write from an address that doesn't have access (via namespace/name) _expectAccessDenied(address(0x01), namespace, name); - world.pushToField(namespace, name, keyTuple, 0, encodedData); + world.pushToField(namespace, name, keyTuple, 0, encodedData, schema); // Expect an error when trying to write from an address that doesn't have access (via tableId) _expectAccessDenied(address(0x01), namespace, name); - world.pushToField(tableId, keyTuple, 0, encodedData); + world.pushToField(tableId, keyTuple, 0, encodedData, schema); // Expect the World to have access vm.prank(address(world)); - world.pushToField(namespace, name, keyTuple, 0, encodedData); + world.pushToField(namespace, name, keyTuple, 0, encodedData, schema); } function testDeleteRecord() public { bytes16 namespace = "testDeleteRecord"; bytes16 name = "testTable"; + Schema schema = Bool.getSchema(); // Register a new table - bytes32 tableId = world.registerTable(namespace, name, Bool.getSchema(), defaultKeySchema); + bytes32 tableId = world.registerTable(namespace, name, schema, defaultKeySchema); // Write data to the table via the namespace and expect it to be written - world.setRecord(namespace, name, singletonKey, abi.encodePacked(true)); + world.setRecord(namespace, name, singletonKey, abi.encodePacked(true), schema); assertTrue(Bool.get(world, tableId)); startGasReport("Delete record"); - world.deleteRecord(namespace, name, singletonKey); + world.deleteRecord(namespace, name, singletonKey, schema); endGasReport(); // expect it to be deleted assertFalse(Bool.get(world, tableId)); // Write data to the table via the namespace and expect it to be written - world.setRecord("testDeleteRecord", "testTable", singletonKey, abi.encodePacked(true)); + world.setRecord("testDeleteRecord", "testTable", singletonKey, abi.encodePacked(true), schema); assertTrue(Bool.get(world, tableId)); // Delete the record via the tableId and expect it to be deleted - world.deleteRecord(tableId, singletonKey); + world.deleteRecord(tableId, singletonKey, schema); assertFalse(Bool.get(world, tableId)); // Write data to the table via the namespace and expect it to be written - world.setRecord("testDeleteRecord", "testTable", singletonKey, abi.encodePacked(true)); + world.setRecord("testDeleteRecord", "testTable", singletonKey, abi.encodePacked(true), schema); assertTrue(Bool.get(world, tableId)); // Expect an error when trying to delete from an address that doesn't have access when calling via the namespace _expectAccessDenied(address(0x01), "testDeleteRecord", "testTable"); - world.deleteRecord("testDeleteRecord", "testTable", singletonKey); + world.deleteRecord("testDeleteRecord", "testTable", singletonKey, schema); // Expect an error when trying to delete from an address that doesn't have access when calling via the tableId _expectAccessDenied(address(0x02), "testDeleteRecord", "testTable"); - world.deleteRecord(tableId, singletonKey); + world.deleteRecord(tableId, singletonKey, schema); // Expect the World to have access vm.prank(address(world)); - world.deleteRecord("testDeleteRecord", "testTable", singletonKey); + world.deleteRecord("testDeleteRecord", "testTable", singletonKey, schema); } function testCall() public { @@ -593,6 +613,8 @@ contract WorldTest is Test, GasReporter { } function testRegisterTableHook() public { + Schema schema = Bool.getSchema(); + // Register a new table bytes32 tableId = world.registerTable("", "testTable", Bool.getSchema(), defaultKeySchema); @@ -605,8 +627,8 @@ contract WorldTest is Test, GasReporter { // Expect the hook to be notified when a record is written vm.expectEmit(true, true, true, true); - emit HookCalled(abi.encode(tableId, singletonKey, value)); - world.setRecord(tableId, singletonKey, value); + emit HookCalled(abi.encode(tableId, singletonKey, value, schema)); + world.setRecord(tableId, singletonKey, value, schema); // TODO: add tests for other hook methods (onBeforeSetField, onAfterSetField, onDeleteRecord) // (See https://github.com/latticexyz/mud/issues/444) diff --git a/packages/world/test/WorldDynamicUpdate.t.sol b/packages/world/test/WorldDynamicUpdate.t.sol index dd1da325dc..5e4f0cd411 100644 --- a/packages/world/test/WorldDynamicUpdate.t.sol +++ b/packages/world/test/WorldDynamicUpdate.t.sol @@ -50,6 +50,7 @@ contract UpdateInFieldTest is Test, GasReporter { keyTuple = new bytes32[](1); keyTuple[0] = key; singletonKey = new bytes32[](0); + Schema schema = AddressArray.getSchema(); // Initialize the data in setUp so that slots aren't warm in tests (to test cold update) @@ -57,7 +58,7 @@ contract UpdateInFieldTest is Test, GasReporter { bytes16 name = "testTable"; // Register a new table - tableId = world.registerTable(namespace, name, AddressArray.getSchema(), defaultKeySchema); + tableId = world.registerTable(namespace, name, schema, defaultKeySchema); // Create data initData = new address[](3); @@ -66,7 +67,7 @@ contract UpdateInFieldTest is Test, GasReporter { initData[2] = address(bytes20(keccak256("another address"))); encodedData = EncodeArray.encode(initData); - world.setField(namespace, name, keyTuple, 0, encodedData); + world.setField(namespace, name, keyTuple, 0, encodedData, schema); } // Expect an error when trying to write from an address that doesn't have access @@ -84,6 +85,7 @@ contract UpdateInFieldTest is Test, GasReporter { function testPopFromField() public { bytes16 namespace = "DynamicUpdTest"; bytes16 name = "testTable"; + Schema schema = AddressArray.getSchema(); // Expect the data to be written assertEq(AddressArray.get(world, tableId, key), initData); @@ -92,7 +94,7 @@ contract UpdateInFieldTest is Test, GasReporter { uint256 byteLengthToPop = 20; startGasReport("pop 1 address (cold)"); - world.popFromField(namespace, name, keyTuple, 0, byteLengthToPop); + world.popFromField(namespace, name, keyTuple, 0, byteLengthToPop, schema); endGasReport(); // Expect the data to be updated @@ -106,7 +108,7 @@ contract UpdateInFieldTest is Test, GasReporter { byteLengthToPop = 20; startGasReport("pop 1 address (warm)"); - world.popFromField(namespace, name, keyTuple, 0, byteLengthToPop); + world.popFromField(namespace, name, keyTuple, 0, byteLengthToPop, schema); endGasReport(); // Expect the data to be updated @@ -117,10 +119,10 @@ contract UpdateInFieldTest is Test, GasReporter { } // Reset data - world.setField(namespace, name, keyTuple, 0, encodedData); + world.setField(namespace, name, keyTuple, 0, encodedData, schema); // Pop 2 items via direct access byteLengthToPop = 20 * 2; - world.popFromField(tableId, keyTuple, 0, byteLengthToPop); + world.popFromField(tableId, keyTuple, 0, byteLengthToPop, schema); // Expect the data to be updated loadedData = AddressArray.get(world, tableId, key); assertEq(loadedData.length, initData.length - 2); @@ -130,20 +132,21 @@ contract UpdateInFieldTest is Test, GasReporter { // Expect an error when trying to write from an address that doesn't have access (via namespace/name) _expectAccessDenied(address(0x01), namespace, name); - world.popFromField(namespace, name, keyTuple, 0, 20); + world.popFromField(namespace, name, keyTuple, 0, 20, schema); // Expect an error when trying to write from an address that doesn't have access (via tableId) _expectAccessDenied(address(0x01), namespace, name); - world.popFromField(tableId, keyTuple, 0, 20); + world.popFromField(tableId, keyTuple, 0, 20, schema); // Expect the World to have access vm.prank(address(world)); - world.popFromField(namespace, name, keyTuple, 0, 20); + world.popFromField(namespace, name, keyTuple, 0, 20, schema); } function testUpdateInField() public { bytes16 namespace = "DynamicUpdTest"; bytes16 name = "testTable"; + Schema schema = AddressArray.getSchema(); // Expect the data to be written assertEq(AddressArray.get(world, tableId, key), initData); @@ -153,11 +156,11 @@ contract UpdateInFieldTest is Test, GasReporter { dataForUpdate[0] = address(bytes20(keccak256("address for update"))); startGasReport("updateInField 1 item (cold)"); - world.updateInField(namespace, name, keyTuple, 0, 0, EncodeArray.encode(dataForUpdate)); + world.updateInField(namespace, name, keyTuple, 0, 0, EncodeArray.encode(dataForUpdate), schema); endGasReport(); startGasReport("updateInField 1 item (warm)"); - world.updateInField(namespace, name, keyTuple, 0, 0, EncodeArray.encode(dataForUpdate)); + world.updateInField(namespace, name, keyTuple, 0, 0, EncodeArray.encode(dataForUpdate), schema); endGasReport(); // Expect the data to be updated @@ -165,7 +168,7 @@ contract UpdateInFieldTest is Test, GasReporter { assertEq(AddressArray.get(world, tableId, key), initData); // Update index 1 via direct access - world.updateInField(tableId, keyTuple, 0, 20 * 1, EncodeArray.encode(dataForUpdate)); + world.updateInField(tableId, keyTuple, 0, 20 * 1, EncodeArray.encode(dataForUpdate), schema); // Expect the data to be updated initData[1] = dataForUpdate[0]; @@ -173,14 +176,14 @@ contract UpdateInFieldTest is Test, GasReporter { // Expect an error when trying to write from an address that doesn't have access (via namespace/name) _expectAccessDenied(address(0x01), namespace, name); - world.updateInField(namespace, name, keyTuple, 0, 0, EncodeArray.encode(dataForUpdate)); + world.updateInField(namespace, name, keyTuple, 0, 0, EncodeArray.encode(dataForUpdate), schema); // Expect an error when trying to write from an address that doesn't have access (via tableId) _expectAccessDenied(address(0x01), namespace, name); - world.updateInField(tableId, keyTuple, 0, 0, EncodeArray.encode(dataForUpdate)); + world.updateInField(tableId, keyTuple, 0, 0, EncodeArray.encode(dataForUpdate), schema); // Expect the World to have access vm.prank(address(world)); - world.updateInField(namespace, name, keyTuple, 0, 0, EncodeArray.encode(dataForUpdate)); + world.updateInField(namespace, name, keyTuple, 0, 0, EncodeArray.encode(dataForUpdate), schema); } } diff --git a/packages/world/test/query.t.sol b/packages/world/test/query.t.sol index dd5a419fea..73913ee7ea 100644 --- a/packages/world/test/query.t.sol +++ b/packages/world/test/query.t.sol @@ -86,9 +86,9 @@ contract QueryTest is Test, GasReporter { function testHasQuery() public { _installKeysInTableModule(); - world.setRecord(namespace, name1, key1, abi.encode(1)); - world.setRecord(namespace, name1, key2, abi.encode(1)); - world.setRecord(namespace, name2, key1, abi.encode(0)); + world.setRecord(namespace, name1, key1, abi.encode(1), tableSchema); + world.setRecord(namespace, name1, key2, abi.encode(1), tableSchema); + world.setRecord(namespace, name2, key1, abi.encode(0), tableSchema); // Query should return all keys in table1 QueryFragment[] memory fragments = new QueryFragment[](1); @@ -107,9 +107,9 @@ contract QueryTest is Test, GasReporter { _installKeysInTableModule(); _installKeysWithValueModule(); - world.setRecord(namespace, name1, key1, abi.encode(2)); - world.setRecord(namespace, name1, key2, abi.encode(1)); - world.setRecord(namespace, name1, key3, abi.encode(1)); + world.setRecord(namespace, name1, key1, abi.encode(2), tableSchema); + world.setRecord(namespace, name1, key2, abi.encode(1), tableSchema); + world.setRecord(namespace, name1, key3, abi.encode(1), tableSchema); // Query should return all keys in table1 with value 1 QueryFragment[] memory fragments = new QueryFragment[](1); fragments[0] = QueryFragment(QueryType.HasValue, table1, abi.encode(1)); @@ -125,12 +125,12 @@ contract QueryTest is Test, GasReporter { function testCombinedHasQuery() public { _installKeysInTableModule(); - world.setRecord(namespace, name1, key1, abi.encode(2)); - world.setRecord(namespace, name1, key2, abi.encode(1)); - world.setRecord(namespace, name1, key3, abi.encode(1)); - world.setRecord(namespace, name2, key2, abi.encode(1)); - world.setRecord(namespace, name2, key3, abi.encode(1)); - world.setRecord(namespace, name3, key1, abi.encode(1)); + world.setRecord(namespace, name1, key1, abi.encode(2), tableSchema); + world.setRecord(namespace, name1, key2, abi.encode(1), tableSchema); + world.setRecord(namespace, name1, key3, abi.encode(1), tableSchema); + world.setRecord(namespace, name2, key2, abi.encode(1), tableSchema); + world.setRecord(namespace, name2, key3, abi.encode(1), tableSchema); + world.setRecord(namespace, name3, key1, abi.encode(1), tableSchema); // Query should return all entities that have table1 and table2 QueryFragment[] memory fragments = new QueryFragment[](2); @@ -149,12 +149,12 @@ contract QueryTest is Test, GasReporter { _installKeysInTableModule(); _installKeysWithValueModule(); - world.setRecord(namespace, name1, key1, abi.encode(2)); - world.setRecord(namespace, name1, key2, abi.encode(2)); - world.setRecord(namespace, name1, key3, abi.encode(1)); - world.setRecord(namespace, name2, key2, abi.encode(1)); - world.setRecord(namespace, name2, key3, abi.encode(1)); - world.setRecord(namespace, name3, key1, abi.encode(1)); + world.setRecord(namespace, name1, key1, abi.encode(2), tableSchema); + world.setRecord(namespace, name1, key2, abi.encode(2), tableSchema); + world.setRecord(namespace, name1, key3, abi.encode(1), tableSchema); + world.setRecord(namespace, name2, key2, abi.encode(1), tableSchema); + world.setRecord(namespace, name2, key3, abi.encode(1), tableSchema); + world.setRecord(namespace, name3, key1, abi.encode(1), tableSchema); // Query should return all entities that have table1 and table2 QueryFragment[] memory fragments = new QueryFragment[](2); @@ -172,13 +172,13 @@ contract QueryTest is Test, GasReporter { _installKeysInTableModule(); _installKeysWithValueModule(); - world.setRecord(namespace, name1, key1, abi.encode(1)); - world.setRecord(namespace, name1, key2, abi.encode(1)); - world.setRecord(namespace, name1, key3, abi.encode(1)); - world.setRecord(namespace, name2, key1, abi.encode(1)); - world.setRecord(namespace, name2, key2, abi.encode(2)); - world.setRecord(namespace, name2, key3, abi.encode(2)); - world.setRecord(namespace, name2, key4, abi.encode(2)); + world.setRecord(namespace, name1, key1, abi.encode(1), tableSchema); + world.setRecord(namespace, name1, key2, abi.encode(1), tableSchema); + world.setRecord(namespace, name1, key3, abi.encode(1), tableSchema); + world.setRecord(namespace, name2, key1, abi.encode(1), tableSchema); + world.setRecord(namespace, name2, key2, abi.encode(2), tableSchema); + world.setRecord(namespace, name2, key3, abi.encode(2), tableSchema); + world.setRecord(namespace, name2, key4, abi.encode(2), tableSchema); // Query should return all entities that have table1 and table2 QueryFragment[] memory fragments = new QueryFragment[](2); @@ -196,13 +196,13 @@ contract QueryTest is Test, GasReporter { function testCombinedHasNotQuery() public { _installKeysInTableModule(); - world.setRecord(namespace, name1, key1, abi.encode(1)); - world.setRecord(namespace, name1, key2, abi.encode(1)); - world.setRecord(namespace, name1, key3, abi.encode(1)); - world.setRecord(namespace, name2, key1, abi.encode(1)); - world.setRecord(namespace, name2, key2, abi.encode(2)); - world.setRecord(namespace, name2, key3, abi.encode(2)); - world.setRecord(namespace, name2, key4, abi.encode(2)); + world.setRecord(namespace, name1, key1, abi.encode(1), tableSchema); + world.setRecord(namespace, name1, key2, abi.encode(1), tableSchema); + world.setRecord(namespace, name1, key3, abi.encode(1), tableSchema); + world.setRecord(namespace, name2, key1, abi.encode(1), tableSchema); + world.setRecord(namespace, name2, key2, abi.encode(2), tableSchema); + world.setRecord(namespace, name2, key3, abi.encode(2), tableSchema); + world.setRecord(namespace, name2, key4, abi.encode(2), tableSchema); // Query should return all entities that have table1 and table2 QueryFragment[] memory fragments = new QueryFragment[](2); @@ -220,13 +220,13 @@ contract QueryTest is Test, GasReporter { _installKeysInTableModule(); _installKeysWithValueModule(); - world.setRecord(namespace, name1, key1, abi.encode(1)); - world.setRecord(namespace, name1, key2, abi.encode(1)); - world.setRecord(namespace, name1, key3, abi.encode(1)); - world.setRecord(namespace, name2, key1, abi.encode(1)); - world.setRecord(namespace, name2, key2, abi.encode(2)); - world.setRecord(namespace, name2, key3, abi.encode(1)); - world.setRecord(namespace, name2, key4, abi.encode(1)); + world.setRecord(namespace, name1, key1, abi.encode(1), tableSchema); + world.setRecord(namespace, name1, key2, abi.encode(1), tableSchema); + world.setRecord(namespace, name1, key3, abi.encode(1), tableSchema); + world.setRecord(namespace, name2, key1, abi.encode(1), tableSchema); + world.setRecord(namespace, name2, key2, abi.encode(2), tableSchema); + world.setRecord(namespace, name2, key3, abi.encode(1), tableSchema); + world.setRecord(namespace, name2, key4, abi.encode(1), tableSchema); // Query should return all entities that have table1 and table2 QueryFragment[] memory fragments = new QueryFragment[](2); @@ -244,16 +244,16 @@ contract QueryTest is Test, GasReporter { _installKeysInTableModule(); _installKeysWithValueModule(); - world.setRecord(namespace, name1, key1, abi.encode(1)); - world.setRecord(namespace, name1, key2, abi.encode(1)); - world.setRecord(namespace, name1, key3, abi.encode(1)); - world.setRecord(namespace, name2, key1, abi.encode(1)); - world.setRecord(namespace, name2, key2, abi.encode(2)); - world.setRecord(namespace, name2, key3, abi.encode(1)); - world.setRecord(namespace, name2, key4, abi.encode(1)); - world.setRecord(namespace, name3, key2, abi.encode(1)); - world.setRecord(namespace, name3, key3, abi.encode(1)); - world.setRecord(namespace, name3, key4, abi.encode(1)); + world.setRecord(namespace, name1, key1, abi.encode(1), tableSchema); + world.setRecord(namespace, name1, key2, abi.encode(1), tableSchema); + world.setRecord(namespace, name1, key3, abi.encode(1), tableSchema); + world.setRecord(namespace, name2, key1, abi.encode(1), tableSchema); + world.setRecord(namespace, name2, key2, abi.encode(2), tableSchema); + world.setRecord(namespace, name2, key3, abi.encode(1), tableSchema); + world.setRecord(namespace, name2, key4, abi.encode(1), tableSchema); + world.setRecord(namespace, name3, key2, abi.encode(1), tableSchema); + world.setRecord(namespace, name3, key3, abi.encode(1), tableSchema); + world.setRecord(namespace, name3, key4, abi.encode(1), tableSchema); // Query should return all entities that have table2 and not table1 QueryFragment[] memory fragments = new QueryFragment[](3); @@ -272,9 +272,9 @@ contract QueryTest is Test, GasReporter { _installKeysInTableModule(); _installKeysWithValueModule(); - world.setRecord(namespace, name1, key1, abi.encode(4)); - world.setRecord(namespace, name1, key2, abi.encode(5)); - world.setRecord(namespace, name1, key3, abi.encode(6)); + world.setRecord(namespace, name1, key1, abi.encode(4), tableSchema); + world.setRecord(namespace, name1, key2, abi.encode(5), tableSchema); + world.setRecord(namespace, name1, key3, abi.encode(6), tableSchema); // Query should return all entities with table1 except value 6 QueryFragment[] memory fragments = new QueryFragment[](2); @@ -295,9 +295,9 @@ contract QueryTest is Test, GasReporter { for (uint256 i; i < 100; i++) { bytes32[] memory key = new bytes32[](1); key[0] = bytes32(i); - world.setRecord(namespace, name1, key, abi.encode(1)); + world.setRecord(namespace, name1, key, abi.encode(1), tableSchema); } - world.setRecord(namespace, name2, key1, abi.encode(0)); + world.setRecord(namespace, name2, key1, abi.encode(0), tableSchema); // Query should return all keys in table1 QueryFragment[] memory fragments = new QueryFragment[](1); @@ -316,9 +316,9 @@ contract QueryTest is Test, GasReporter { for (uint256 i; i < 1000; i++) { bytes32[] memory key = new bytes32[](1); key[0] = bytes32(i); - world.setRecord(namespace, name1, key, abi.encode(1)); + world.setRecord(namespace, name1, key, abi.encode(1), tableSchema); } - world.setRecord(namespace, name2, key1, abi.encode(0)); + world.setRecord(namespace, name2, key1, abi.encode(0), tableSchema); // Query should return all keys in table1 QueryFragment[] memory fragments = new QueryFragment[](1); diff --git a/packages/world/test/tables/AddressArray.sol b/packages/world/test/tables/AddressArray.sol index 77e07acd1b..1e908a3ff9 100644 --- a/packages/world/test/tables/AddressArray.sol +++ b/packages/world/test/tables/AddressArray.sol @@ -67,7 +67,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0, getSchema()); return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_address()); } @@ -76,7 +76,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - bytes memory _blob = _store.getField(_tableId, _keyTuple, 0); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 0, getSchema()); return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_address()); } @@ -85,7 +85,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); + StoreSwitch.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), getSchema()); } /** Set value (using the specified store) */ @@ -93,7 +93,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); + _store.setField(_tableId, _keyTuple, 0, EncodeArray.encode((value)), getSchema()); } /** Get the length of value */ @@ -158,7 +158,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); + StoreSwitch.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), getSchema()); } /** Push an element to value (using the specified store) */ @@ -166,7 +166,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); + _store.pushToField(_tableId, _keyTuple, 0, abi.encodePacked((_element)), getSchema()); } /** Pop an element from value */ @@ -174,7 +174,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.popFromField(_tableId, _keyTuple, 0, 20); + StoreSwitch.popFromField(_tableId, _keyTuple, 0, 20, getSchema()); } /** Pop an element from value (using the specified store) */ @@ -182,7 +182,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.popFromField(_tableId, _keyTuple, 0, 20); + _store.popFromField(_tableId, _keyTuple, 0, 20, getSchema()); } /** @@ -194,7 +194,7 @@ library AddressArray { _keyTuple[0] = key; unchecked { - StoreSwitch.updateInField(_tableId, _keyTuple, 0, _index * 20, abi.encodePacked((_element))); + StoreSwitch.updateInField(_tableId, _keyTuple, 0, _index * 20, abi.encodePacked((_element)), getSchema()); } } @@ -207,7 +207,7 @@ library AddressArray { _keyTuple[0] = key; unchecked { - _store.updateInField(_tableId, _keyTuple, 0, _index * 20, abi.encodePacked((_element))); + _store.updateInField(_tableId, _keyTuple, 0, _index * 20, abi.encodePacked((_element)), getSchema()); } } @@ -233,7 +233,7 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.deleteRecord(_tableId, _keyTuple); + StoreSwitch.deleteRecord(_tableId, _keyTuple, getSchema()); } /* Delete all data for given keys (using the specified store) */ @@ -241,6 +241,6 @@ library AddressArray { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.deleteRecord(_tableId, _keyTuple); + _store.deleteRecord(_tableId, _keyTuple, getSchema()); } } diff --git a/packages/world/test/tables/Bool.sol b/packages/world/test/tables/Bool.sol index 71b1de5019..c26547f043 100644 --- a/packages/world/test/tables/Bool.sol +++ b/packages/world/test/tables/Bool.sol @@ -65,7 +65,7 @@ library Bool { function get(bytes32 _tableId) internal view returns (bool value) { bytes32[] memory _keyTuple = new bytes32[](0); - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0, getSchema()); return (_toBool(uint8(Bytes.slice1(_blob, 0)))); } @@ -73,7 +73,7 @@ library Bool { function get(IStore _store, bytes32 _tableId) internal view returns (bool value) { bytes32[] memory _keyTuple = new bytes32[](0); - bytes memory _blob = _store.getField(_tableId, _keyTuple, 0); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 0, getSchema()); return (_toBool(uint8(Bytes.slice1(_blob, 0)))); } @@ -81,14 +81,14 @@ library Bool { function set(bytes32 _tableId, bool value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((value))); + StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), getSchema()); } /** Set value (using the specified store) */ function set(IStore _store, bytes32 _tableId, bool value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((value))); + _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), getSchema()); } /** Tightly pack full data using this table's schema */ @@ -107,14 +107,14 @@ library Bool { function deleteRecord(bytes32 _tableId) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.deleteRecord(_tableId, _keyTuple); + StoreSwitch.deleteRecord(_tableId, _keyTuple, getSchema()); } /* Delete all data for given keys (using the specified store) */ function deleteRecord(IStore _store, bytes32 _tableId) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.deleteRecord(_tableId, _keyTuple); + _store.deleteRecord(_tableId, _keyTuple, getSchema()); } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index da3f054842..b0bcd0c5c7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -107,6 +107,9 @@ importers: '@latticexyz/gas-report': specifier: workspace:* version: link:../gas-report + '@latticexyz/protocol-parser': + specifier: workspace:* + version: link:../protocol-parser '@latticexyz/schema-type': specifier: workspace:* version: link:../schema-type diff --git a/templates/phaser/packages/contracts/src/codegen/tables/Counter.sol b/templates/phaser/packages/contracts/src/codegen/tables/Counter.sol index 8cdba26bb5..703fec8f7b 100644 --- a/templates/phaser/packages/contracts/src/codegen/tables/Counter.sol +++ b/templates/phaser/packages/contracts/src/codegen/tables/Counter.sol @@ -68,7 +68,7 @@ library Counter { function get() internal view returns (uint32 value) { bytes32[] memory _keyTuple = new bytes32[](0); - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0, getSchema()); return (uint32(Bytes.slice4(_blob, 0))); } @@ -76,7 +76,7 @@ library Counter { function get(IStore _store) internal view returns (uint32 value) { bytes32[] memory _keyTuple = new bytes32[](0); - bytes memory _blob = _store.getField(_tableId, _keyTuple, 0); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 0, getSchema()); return (uint32(Bytes.slice4(_blob, 0))); } @@ -84,14 +84,14 @@ library Counter { function set(uint32 value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((value))); + StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), getSchema()); } /** Set value (using the specified store) */ function set(IStore _store, uint32 value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((value))); + _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), getSchema()); } /** Tightly pack full data using this table's schema */ @@ -110,13 +110,13 @@ library Counter { function deleteRecord() internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.deleteRecord(_tableId, _keyTuple); + StoreSwitch.deleteRecord(_tableId, _keyTuple, getSchema()); } /* Delete all data for given keys (using the specified store) */ function deleteRecord(IStore _store) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.deleteRecord(_tableId, _keyTuple); + _store.deleteRecord(_tableId, _keyTuple, getSchema()); } } diff --git a/templates/react/packages/contracts/src/codegen/tables/Counter.sol b/templates/react/packages/contracts/src/codegen/tables/Counter.sol index 8cdba26bb5..703fec8f7b 100644 --- a/templates/react/packages/contracts/src/codegen/tables/Counter.sol +++ b/templates/react/packages/contracts/src/codegen/tables/Counter.sol @@ -68,7 +68,7 @@ library Counter { function get() internal view returns (uint32 value) { bytes32[] memory _keyTuple = new bytes32[](0); - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0, getSchema()); return (uint32(Bytes.slice4(_blob, 0))); } @@ -76,7 +76,7 @@ library Counter { function get(IStore _store) internal view returns (uint32 value) { bytes32[] memory _keyTuple = new bytes32[](0); - bytes memory _blob = _store.getField(_tableId, _keyTuple, 0); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 0, getSchema()); return (uint32(Bytes.slice4(_blob, 0))); } @@ -84,14 +84,14 @@ library Counter { function set(uint32 value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((value))); + StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), getSchema()); } /** Set value (using the specified store) */ function set(IStore _store, uint32 value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((value))); + _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), getSchema()); } /** Tightly pack full data using this table's schema */ @@ -110,13 +110,13 @@ library Counter { function deleteRecord() internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.deleteRecord(_tableId, _keyTuple); + StoreSwitch.deleteRecord(_tableId, _keyTuple, getSchema()); } /* Delete all data for given keys (using the specified store) */ function deleteRecord(IStore _store) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.deleteRecord(_tableId, _keyTuple); + _store.deleteRecord(_tableId, _keyTuple, getSchema()); } } diff --git a/templates/threejs/packages/contracts/src/codegen/tables/Position.sol b/templates/threejs/packages/contracts/src/codegen/tables/Position.sol index 21930b0683..1571a36216 100644 --- a/templates/threejs/packages/contracts/src/codegen/tables/Position.sol +++ b/templates/threejs/packages/contracts/src/codegen/tables/Position.sol @@ -80,7 +80,7 @@ library Position { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0, getSchema()); return (int32(uint32(Bytes.slice4(_blob, 0)))); } @@ -89,7 +89,7 @@ library Position { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - bytes memory _blob = _store.getField(_tableId, _keyTuple, 0); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 0, getSchema()); return (int32(uint32(Bytes.slice4(_blob, 0)))); } @@ -98,7 +98,7 @@ library Position { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((x))); + StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((x)), getSchema()); } /** Set x (using the specified store) */ @@ -106,7 +106,7 @@ library Position { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((x))); + _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((x)), getSchema()); } /** Get y */ @@ -114,7 +114,7 @@ library Position { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 1); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 1, getSchema()); return (int32(uint32(Bytes.slice4(_blob, 0)))); } @@ -123,7 +123,7 @@ library Position { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - bytes memory _blob = _store.getField(_tableId, _keyTuple, 1); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 1, getSchema()); return (int32(uint32(Bytes.slice4(_blob, 0)))); } @@ -132,7 +132,7 @@ library Position { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField(_tableId, _keyTuple, 1, abi.encodePacked((y))); + StoreSwitch.setField(_tableId, _keyTuple, 1, abi.encodePacked((y)), getSchema()); } /** Set y (using the specified store) */ @@ -140,7 +140,7 @@ library Position { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 1, abi.encodePacked((y))); + _store.setField(_tableId, _keyTuple, 1, abi.encodePacked((y)), getSchema()); } /** Get z */ @@ -148,7 +148,7 @@ library Position { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 2); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 2, getSchema()); return (int32(uint32(Bytes.slice4(_blob, 0)))); } @@ -157,7 +157,7 @@ library Position { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - bytes memory _blob = _store.getField(_tableId, _keyTuple, 2); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 2, getSchema()); return (int32(uint32(Bytes.slice4(_blob, 0)))); } @@ -166,7 +166,7 @@ library Position { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setField(_tableId, _keyTuple, 2, abi.encodePacked((z))); + StoreSwitch.setField(_tableId, _keyTuple, 2, abi.encodePacked((z)), getSchema()); } /** Set z (using the specified store) */ @@ -174,7 +174,7 @@ library Position { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setField(_tableId, _keyTuple, 2, abi.encodePacked((z))); + _store.setField(_tableId, _keyTuple, 2, abi.encodePacked((z)), getSchema()); } /** Get the full data */ @@ -202,7 +202,7 @@ library Position { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.setRecord(_tableId, _keyTuple, _data); + StoreSwitch.setRecord(_tableId, _keyTuple, _data, getSchema()); } /** Set the full data using individual values (using the specified store) */ @@ -212,7 +212,7 @@ library Position { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.setRecord(_tableId, _keyTuple, _data); + _store.setRecord(_tableId, _keyTuple, _data, getSchema()); } /** Set the full data using the data struct */ @@ -252,7 +252,7 @@ library Position { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - StoreSwitch.deleteRecord(_tableId, _keyTuple); + StoreSwitch.deleteRecord(_tableId, _keyTuple, getSchema()); } /* Delete all data for given keys (using the specified store) */ @@ -260,6 +260,6 @@ library Position { bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; - _store.deleteRecord(_tableId, _keyTuple); + _store.deleteRecord(_tableId, _keyTuple, getSchema()); } } diff --git a/templates/vanilla/packages/contracts/src/codegen/tables/Counter.sol b/templates/vanilla/packages/contracts/src/codegen/tables/Counter.sol index 8cdba26bb5..703fec8f7b 100644 --- a/templates/vanilla/packages/contracts/src/codegen/tables/Counter.sol +++ b/templates/vanilla/packages/contracts/src/codegen/tables/Counter.sol @@ -68,7 +68,7 @@ library Counter { function get() internal view returns (uint32 value) { bytes32[] memory _keyTuple = new bytes32[](0); - bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0); + bytes memory _blob = StoreSwitch.getField(_tableId, _keyTuple, 0, getSchema()); return (uint32(Bytes.slice4(_blob, 0))); } @@ -76,7 +76,7 @@ library Counter { function get(IStore _store) internal view returns (uint32 value) { bytes32[] memory _keyTuple = new bytes32[](0); - bytes memory _blob = _store.getField(_tableId, _keyTuple, 0); + bytes memory _blob = _store.getField(_tableId, _keyTuple, 0, getSchema()); return (uint32(Bytes.slice4(_blob, 0))); } @@ -84,14 +84,14 @@ library Counter { function set(uint32 value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((value))); + StoreSwitch.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), getSchema()); } /** Set value (using the specified store) */ function set(IStore _store, uint32 value) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((value))); + _store.setField(_tableId, _keyTuple, 0, abi.encodePacked((value)), getSchema()); } /** Tightly pack full data using this table's schema */ @@ -110,13 +110,13 @@ library Counter { function deleteRecord() internal { bytes32[] memory _keyTuple = new bytes32[](0); - StoreSwitch.deleteRecord(_tableId, _keyTuple); + StoreSwitch.deleteRecord(_tableId, _keyTuple, getSchema()); } /* Delete all data for given keys (using the specified store) */ function deleteRecord(IStore _store) internal { bytes32[] memory _keyTuple = new bytes32[](0); - _store.deleteRecord(_tableId, _keyTuple); + _store.deleteRecord(_tableId, _keyTuple, getSchema()); } }