From 994f02406c2e0499a00e3eea6b1f1cf63678bda4 Mon Sep 17 00:00:00 2001 From: Kevin Ingersoll Date: Wed, 20 Mar 2024 17:13:42 +0000 Subject: [PATCH] update templates --- templates/react/packages/client/src/App.tsx | 4 +- .../client/src/mud/createSystemCalls.ts | 10 +- .../contracts/src/codegen/tables/Tasks.sol | 126 +++++++++--------- .../src/codegen/world/ITasksSystem.sol | 8 +- .../contracts/src/systems/TasksSystem.sol | 18 +-- .../contracts/src/codegen/tables/Position.sol | 86 ++++++------ 6 files changed, 126 insertions(+), 126 deletions(-) diff --git a/templates/react/packages/client/src/App.tsx b/templates/react/packages/client/src/App.tsx index 4ac69bc4c7..82c60486a9 100644 --- a/templates/react/packages/client/src/App.tsx +++ b/templates/react/packages/client/src/App.tsx @@ -31,7 +31,7 @@ export const App = () => { checkbox.disabled = true; try { - await toggleTask(task.key.key); + await toggleTask(task.key.id); } finally { checkbox.disabled = false; } @@ -51,7 +51,7 @@ export const App = () => { const button = event.currentTarget; button.disabled = true; try { - await deleteTask(task.key.key); + await deleteTask(task.key.id); } finally { button.disabled = false; } diff --git a/templates/react/packages/client/src/mud/createSystemCalls.ts b/templates/react/packages/client/src/mud/createSystemCalls.ts index d7714ec453..a7447d143c 100644 --- a/templates/react/packages/client/src/mud/createSystemCalls.ts +++ b/templates/react/packages/client/src/mud/createSystemCalls.ts @@ -35,14 +35,14 @@ export function createSystemCalls( await waitForTransaction(tx); }; - const toggleTask = async (key: Hex) => { - const isComplete = (useStore.getState().getValue(tables.Tasks, { key })?.completedAt ?? 0n) > 0n; - const tx = isComplete ? await worldContract.write.resetTask([key]) : await worldContract.write.completeTask([key]); + const toggleTask = async (id: Hex) => { + const isComplete = (useStore.getState().getValue(tables.Tasks, { id })?.completedAt ?? 0n) > 0n; + const tx = isComplete ? await worldContract.write.resetTask([id]) : await worldContract.write.completeTask([id]); await waitForTransaction(tx); }; - const deleteTask = async (key: Hex) => { - const tx = await worldContract.write.deleteTask([key]); + const deleteTask = async (id: Hex) => { + const tx = await worldContract.write.deleteTask([id]); await waitForTransaction(tx); }; diff --git a/templates/react/packages/contracts/src/codegen/tables/Tasks.sol b/templates/react/packages/contracts/src/codegen/tables/Tasks.sol index f14b49f6a3..454d03032d 100644 --- a/templates/react/packages/contracts/src/codegen/tables/Tasks.sol +++ b/templates/react/packages/contracts/src/codegen/tables/Tasks.sol @@ -40,7 +40,7 @@ library Tasks { */ function getKeyNames() internal pure returns (string[] memory keyNames) { keyNames = new string[](1); - keyNames[0] = "key"; + keyNames[0] = "id"; } /** @@ -71,9 +71,9 @@ library Tasks { /** * @notice Get createdAt. */ - function getCreatedAt(bytes32 key) internal view returns (uint256 createdAt) { + function getCreatedAt(bytes32 id) internal view returns (uint256 createdAt) { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); return (uint256(bytes32(_blob))); @@ -82,9 +82,9 @@ library Tasks { /** * @notice Get createdAt. */ - function _getCreatedAt(bytes32 key) internal view returns (uint256 createdAt) { + function _getCreatedAt(bytes32 id) internal view returns (uint256 createdAt) { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); return (uint256(bytes32(_blob))); @@ -93,9 +93,9 @@ library Tasks { /** * @notice Set createdAt. */ - function setCreatedAt(bytes32 key, uint256 createdAt) internal { + function setCreatedAt(bytes32 id, uint256 createdAt) internal { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((createdAt)), _fieldLayout); } @@ -103,9 +103,9 @@ library Tasks { /** * @notice Set createdAt. */ - function _setCreatedAt(bytes32 key, uint256 createdAt) internal { + function _setCreatedAt(bytes32 id, uint256 createdAt) internal { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((createdAt)), _fieldLayout); } @@ -113,9 +113,9 @@ library Tasks { /** * @notice Get completedAt. */ - function getCompletedAt(bytes32 key) internal view returns (uint256 completedAt) { + function getCompletedAt(bytes32 id) internal view returns (uint256 completedAt) { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 1, _fieldLayout); return (uint256(bytes32(_blob))); @@ -124,9 +124,9 @@ library Tasks { /** * @notice Get completedAt. */ - function _getCompletedAt(bytes32 key) internal view returns (uint256 completedAt) { + function _getCompletedAt(bytes32 id) internal view returns (uint256 completedAt) { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 1, _fieldLayout); return (uint256(bytes32(_blob))); @@ -135,9 +135,9 @@ library Tasks { /** * @notice Set completedAt. */ - function setCompletedAt(bytes32 key, uint256 completedAt) internal { + function setCompletedAt(bytes32 id, uint256 completedAt) internal { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; StoreSwitch.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((completedAt)), _fieldLayout); } @@ -145,9 +145,9 @@ library Tasks { /** * @notice Set completedAt. */ - function _setCompletedAt(bytes32 key, uint256 completedAt) internal { + function _setCompletedAt(bytes32 id, uint256 completedAt) internal { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; StoreCore.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((completedAt)), _fieldLayout); } @@ -155,9 +155,9 @@ library Tasks { /** * @notice Get description. */ - function getDescription(bytes32 key) internal view returns (string memory description) { + function getDescription(bytes32 id) internal view returns (string memory description) { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; bytes memory _blob = StoreSwitch.getDynamicField(_tableId, _keyTuple, 0); return (string(_blob)); @@ -166,9 +166,9 @@ library Tasks { /** * @notice Get description. */ - function _getDescription(bytes32 key) internal view returns (string memory description) { + function _getDescription(bytes32 id) internal view returns (string memory description) { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; bytes memory _blob = StoreCore.getDynamicField(_tableId, _keyTuple, 0); return (string(_blob)); @@ -177,9 +177,9 @@ library Tasks { /** * @notice Set description. */ - function setDescription(bytes32 key, string memory description) internal { + function setDescription(bytes32 id, string memory description) internal { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; StoreSwitch.setDynamicField(_tableId, _keyTuple, 0, bytes((description))); } @@ -187,9 +187,9 @@ library Tasks { /** * @notice Set description. */ - function _setDescription(bytes32 key, string memory description) internal { + function _setDescription(bytes32 id, string memory description) internal { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; StoreCore.setDynamicField(_tableId, _keyTuple, 0, bytes((description))); } @@ -197,9 +197,9 @@ library Tasks { /** * @notice Get the length of description. */ - function lengthDescription(bytes32 key) internal view returns (uint256) { + function lengthDescription(bytes32 id) internal view returns (uint256) { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { @@ -210,9 +210,9 @@ library Tasks { /** * @notice Get the length of description. */ - function _lengthDescription(bytes32 key) internal view returns (uint256) { + function _lengthDescription(bytes32 id) internal view returns (uint256) { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 0); unchecked { @@ -224,9 +224,9 @@ library Tasks { * @notice Get an item of description. * @dev Reverts with Store_IndexOutOfBounds if `_index` is out of bounds for the array. */ - function getItemDescription(bytes32 key, uint256 _index) internal view returns (string memory) { + function getItemDescription(bytes32 id, uint256 _index) internal view returns (string memory) { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; unchecked { bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 1, (_index + 1) * 1); @@ -238,9 +238,9 @@ library Tasks { * @notice Get an item of description. * @dev Reverts with Store_IndexOutOfBounds if `_index` is out of bounds for the array. */ - function _getItemDescription(bytes32 key, uint256 _index) internal view returns (string memory) { + function _getItemDescription(bytes32 id, uint256 _index) internal view returns (string memory) { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; unchecked { bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 1, (_index + 1) * 1); @@ -251,9 +251,9 @@ library Tasks { /** * @notice Push a slice to description. */ - function pushDescription(bytes32 key, string memory _slice) internal { + function pushDescription(bytes32 id, string memory _slice) internal { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 0, bytes((_slice))); } @@ -261,9 +261,9 @@ library Tasks { /** * @notice Push a slice to description. */ - function _pushDescription(bytes32 key, string memory _slice) internal { + function _pushDescription(bytes32 id, string memory _slice) internal { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; StoreCore.pushToDynamicField(_tableId, _keyTuple, 0, bytes((_slice))); } @@ -271,9 +271,9 @@ library Tasks { /** * @notice Pop a slice from description. */ - function popDescription(bytes32 key) internal { + function popDescription(bytes32 id) internal { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 0, 1); } @@ -281,9 +281,9 @@ library Tasks { /** * @notice Pop a slice from description. */ - function _popDescription(bytes32 key) internal { + function _popDescription(bytes32 id) internal { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; StoreCore.popFromDynamicField(_tableId, _keyTuple, 0, 1); } @@ -291,9 +291,9 @@ library Tasks { /** * @notice Update a slice of description at `_index`. */ - function updateDescription(bytes32 key, uint256 _index, string memory _slice) internal { + function updateDescription(bytes32 id, uint256 _index, string memory _slice) internal { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; unchecked { bytes memory _encoded = bytes((_slice)); @@ -304,9 +304,9 @@ library Tasks { /** * @notice Update a slice of description at `_index`. */ - function _updateDescription(bytes32 key, uint256 _index, string memory _slice) internal { + function _updateDescription(bytes32 id, uint256 _index, string memory _slice) internal { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; unchecked { bytes memory _encoded = bytes((_slice)); @@ -317,9 +317,9 @@ library Tasks { /** * @notice Get the full data. */ - function get(bytes32 key) internal view returns (TasksData memory _table) { + function get(bytes32 id) internal view returns (TasksData memory _table) { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; (bytes memory _staticData, PackedCounter _encodedLengths, bytes memory _dynamicData) = StoreSwitch.getRecord( _tableId, @@ -332,9 +332,9 @@ library Tasks { /** * @notice Get the full data. */ - function _get(bytes32 key) internal view returns (TasksData memory _table) { + function _get(bytes32 id) internal view returns (TasksData memory _table) { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; (bytes memory _staticData, PackedCounter _encodedLengths, bytes memory _dynamicData) = StoreCore.getRecord( _tableId, @@ -347,14 +347,14 @@ library Tasks { /** * @notice Set the full data using individual values. */ - function set(bytes32 key, uint256 createdAt, uint256 completedAt, string memory description) internal { + function set(bytes32 id, uint256 createdAt, uint256 completedAt, string memory description) internal { bytes memory _staticData = encodeStatic(createdAt, completedAt); PackedCounter _encodedLengths = encodeLengths(description); bytes memory _dynamicData = encodeDynamic(description); bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } @@ -362,14 +362,14 @@ library Tasks { /** * @notice Set the full data using individual values. */ - function _set(bytes32 key, uint256 createdAt, uint256 completedAt, string memory description) internal { + function _set(bytes32 id, uint256 createdAt, uint256 completedAt, string memory description) internal { bytes memory _staticData = encodeStatic(createdAt, completedAt); PackedCounter _encodedLengths = encodeLengths(description); bytes memory _dynamicData = encodeDynamic(description); bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); } @@ -377,14 +377,14 @@ library Tasks { /** * @notice Set the full data using the data struct. */ - function set(bytes32 key, TasksData memory _table) internal { + function set(bytes32 id, TasksData memory _table) internal { bytes memory _staticData = encodeStatic(_table.createdAt, _table.completedAt); PackedCounter _encodedLengths = encodeLengths(_table.description); bytes memory _dynamicData = encodeDynamic(_table.description); bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } @@ -392,14 +392,14 @@ library Tasks { /** * @notice Set the full data using the data struct. */ - function _set(bytes32 key, TasksData memory _table) internal { + function _set(bytes32 id, TasksData memory _table) internal { bytes memory _staticData = encodeStatic(_table.createdAt, _table.completedAt); PackedCounter _encodedLengths = encodeLengths(_table.description); bytes memory _dynamicData = encodeDynamic(_table.description); bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); } @@ -447,9 +447,9 @@ library Tasks { /** * @notice Delete all data for given keys. */ - function deleteRecord(bytes32 key) internal { + function deleteRecord(bytes32 id) internal { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; StoreSwitch.deleteRecord(_tableId, _keyTuple); } @@ -457,9 +457,9 @@ library Tasks { /** * @notice Delete all data for given keys. */ - function _deleteRecord(bytes32 key) internal { + function _deleteRecord(bytes32 id) internal { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } @@ -513,9 +513,9 @@ library Tasks { /** * @notice Encode keys as a bytes32 array using this table's field layout. */ - function encodeKeyTuple(bytes32 key) internal pure returns (bytes32[] memory) { + function encodeKeyTuple(bytes32 id) internal pure returns (bytes32[] memory) { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; return _keyTuple; } diff --git a/templates/react/packages/contracts/src/codegen/world/ITasksSystem.sol b/templates/react/packages/contracts/src/codegen/world/ITasksSystem.sol index 4a18791ccf..bfddd5c830 100644 --- a/templates/react/packages/contracts/src/codegen/world/ITasksSystem.sol +++ b/templates/react/packages/contracts/src/codegen/world/ITasksSystem.sol @@ -9,11 +9,11 @@ pragma solidity >=0.8.24; * @dev This interface is automatically generated from the corresponding system contract. Do not edit manually. */ interface ITasksSystem { - function addTask(string memory description) external returns (bytes32 key); + function addTask(string memory description) external returns (bytes32 id); - function completeTask(bytes32 key) external; + function completeTask(bytes32 id) external; - function resetTask(bytes32 key) external; + function resetTask(bytes32 id) external; - function deleteTask(bytes32 key) external; + function deleteTask(bytes32 id) external; } diff --git a/templates/react/packages/contracts/src/systems/TasksSystem.sol b/templates/react/packages/contracts/src/systems/TasksSystem.sol index 9574e202c9..e9a5654f2c 100644 --- a/templates/react/packages/contracts/src/systems/TasksSystem.sol +++ b/templates/react/packages/contracts/src/systems/TasksSystem.sol @@ -5,20 +5,20 @@ import { System } from "@latticexyz/world/src/System.sol"; import { Tasks, TasksData } from "../codegen/index.sol"; contract TasksSystem is System { - function addTask(string memory description) public returns (bytes32 key) { - key = keccak256(abi.encode(block.prevrandao, _msgSender(), description)); - Tasks.set(key, TasksData({ description: description, createdAt: block.timestamp, completedAt: 0 })); + function addTask(string memory description) public returns (bytes32 id) { + id = keccak256(abi.encode(block.prevrandao, _msgSender(), description)); + Tasks.set(id, TasksData({ description: description, createdAt: block.timestamp, completedAt: 0 })); } - function completeTask(bytes32 key) public { - Tasks.setCompletedAt(key, block.timestamp); + function completeTask(bytes32 id) public { + Tasks.setCompletedAt(id, block.timestamp); } - function resetTask(bytes32 key) public { - Tasks.setCompletedAt(key, 0); + function resetTask(bytes32 id) public { + Tasks.setCompletedAt(id, 0); } - function deleteTask(bytes32 key) public { - Tasks.deleteRecord(key); + function deleteTask(bytes32 id) public { + Tasks.deleteRecord(id); } } diff --git a/templates/threejs/packages/contracts/src/codegen/tables/Position.sol b/templates/threejs/packages/contracts/src/codegen/tables/Position.sol index 6f405bf0e3..3a8edfb588 100644 --- a/templates/threejs/packages/contracts/src/codegen/tables/Position.sol +++ b/templates/threejs/packages/contracts/src/codegen/tables/Position.sol @@ -40,7 +40,7 @@ library Position { */ function getKeyNames() internal pure returns (string[] memory keyNames) { keyNames = new string[](1); - keyNames[0] = "key"; + keyNames[0] = "id"; } /** @@ -71,9 +71,9 @@ library Position { /** * @notice Get x. */ - function getX(bytes32 key) internal view returns (int32 x) { + function getX(bytes32 id) internal view returns (int32 x) { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); return (int32(uint32(bytes4(_blob)))); @@ -82,9 +82,9 @@ library Position { /** * @notice Get x. */ - function _getX(bytes32 key) internal view returns (int32 x) { + function _getX(bytes32 id) internal view returns (int32 x) { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); return (int32(uint32(bytes4(_blob)))); @@ -93,9 +93,9 @@ library Position { /** * @notice Set x. */ - function setX(bytes32 key, int32 x) internal { + function setX(bytes32 id, int32 x) internal { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((x)), _fieldLayout); } @@ -103,9 +103,9 @@ library Position { /** * @notice Set x. */ - function _setX(bytes32 key, int32 x) internal { + function _setX(bytes32 id, int32 x) internal { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((x)), _fieldLayout); } @@ -113,9 +113,9 @@ library Position { /** * @notice Get y. */ - function getY(bytes32 key) internal view returns (int32 y) { + function getY(bytes32 id) internal view returns (int32 y) { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 1, _fieldLayout); return (int32(uint32(bytes4(_blob)))); @@ -124,9 +124,9 @@ library Position { /** * @notice Get y. */ - function _getY(bytes32 key) internal view returns (int32 y) { + function _getY(bytes32 id) internal view returns (int32 y) { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 1, _fieldLayout); return (int32(uint32(bytes4(_blob)))); @@ -135,9 +135,9 @@ library Position { /** * @notice Set y. */ - function setY(bytes32 key, int32 y) internal { + function setY(bytes32 id, int32 y) internal { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; StoreSwitch.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((y)), _fieldLayout); } @@ -145,9 +145,9 @@ library Position { /** * @notice Set y. */ - function _setY(bytes32 key, int32 y) internal { + function _setY(bytes32 id, int32 y) internal { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; StoreCore.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((y)), _fieldLayout); } @@ -155,9 +155,9 @@ library Position { /** * @notice Get z. */ - function getZ(bytes32 key) internal view returns (int32 z) { + function getZ(bytes32 id) internal view returns (int32 z) { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 2, _fieldLayout); return (int32(uint32(bytes4(_blob)))); @@ -166,9 +166,9 @@ library Position { /** * @notice Get z. */ - function _getZ(bytes32 key) internal view returns (int32 z) { + function _getZ(bytes32 id) internal view returns (int32 z) { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 2, _fieldLayout); return (int32(uint32(bytes4(_blob)))); @@ -177,9 +177,9 @@ library Position { /** * @notice Set z. */ - function setZ(bytes32 key, int32 z) internal { + function setZ(bytes32 id, int32 z) internal { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; StoreSwitch.setStaticField(_tableId, _keyTuple, 2, abi.encodePacked((z)), _fieldLayout); } @@ -187,9 +187,9 @@ library Position { /** * @notice Set z. */ - function _setZ(bytes32 key, int32 z) internal { + function _setZ(bytes32 id, int32 z) internal { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; StoreCore.setStaticField(_tableId, _keyTuple, 2, abi.encodePacked((z)), _fieldLayout); } @@ -197,9 +197,9 @@ library Position { /** * @notice Get the full data. */ - function get(bytes32 key) internal view returns (PositionData memory _table) { + function get(bytes32 id) internal view returns (PositionData memory _table) { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; (bytes memory _staticData, PackedCounter _encodedLengths, bytes memory _dynamicData) = StoreSwitch.getRecord( _tableId, @@ -212,9 +212,9 @@ library Position { /** * @notice Get the full data. */ - function _get(bytes32 key) internal view returns (PositionData memory _table) { + function _get(bytes32 id) internal view returns (PositionData memory _table) { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; (bytes memory _staticData, PackedCounter _encodedLengths, bytes memory _dynamicData) = StoreCore.getRecord( _tableId, @@ -227,14 +227,14 @@ library Position { /** * @notice Set the full data using individual values. */ - function set(bytes32 key, int32 x, int32 y, int32 z) internal { + function set(bytes32 id, int32 x, int32 y, int32 z) internal { bytes memory _staticData = encodeStatic(x, y, z); PackedCounter _encodedLengths; bytes memory _dynamicData; bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } @@ -242,14 +242,14 @@ library Position { /** * @notice Set the full data using individual values. */ - function _set(bytes32 key, int32 x, int32 y, int32 z) internal { + function _set(bytes32 id, int32 x, int32 y, int32 z) internal { bytes memory _staticData = encodeStatic(x, y, z); PackedCounter _encodedLengths; bytes memory _dynamicData; bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); } @@ -257,14 +257,14 @@ library Position { /** * @notice Set the full data using the data struct. */ - function set(bytes32 key, PositionData memory _table) internal { + function set(bytes32 id, PositionData memory _table) internal { bytes memory _staticData = encodeStatic(_table.x, _table.y, _table.z); PackedCounter _encodedLengths; bytes memory _dynamicData; bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); } @@ -272,14 +272,14 @@ library Position { /** * @notice Set the full data using the data struct. */ - function _set(bytes32 key, PositionData memory _table) internal { + function _set(bytes32 id, PositionData memory _table) internal { bytes memory _staticData = encodeStatic(_table.x, _table.y, _table.z); PackedCounter _encodedLengths; bytes memory _dynamicData; bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); } @@ -312,9 +312,9 @@ library Position { /** * @notice Delete all data for given keys. */ - function deleteRecord(bytes32 key) internal { + function deleteRecord(bytes32 id) internal { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; StoreSwitch.deleteRecord(_tableId, _keyTuple); } @@ -322,9 +322,9 @@ library Position { /** * @notice Delete all data for given keys. */ - function _deleteRecord(bytes32 key) internal { + function _deleteRecord(bytes32 id) internal { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); } @@ -355,9 +355,9 @@ library Position { /** * @notice Encode keys as a bytes32 array using this table's field layout. */ - function encodeKeyTuple(bytes32 key) internal pure returns (bytes32[] memory) { + function encodeKeyTuple(bytes32 id) internal pure returns (bytes32[] memory) { bytes32[] memory _keyTuple = new bytes32[](1); - _keyTuple[0] = key; + _keyTuple[0] = id; return _keyTuple; }