From 83bc404eb192fe3c75f906dbb72817c294807df6 Mon Sep 17 00:00:00 2001 From: dk1a Date: Wed, 16 Aug 2023 15:12:00 +0300 Subject: [PATCH] refactor(store): use _keyTupleDefinition in encodeKeyTuple (#1314) --- e2e/packages/contracts/src/codegen/tables/Multi.sol | 6 ++++-- e2e/packages/contracts/src/codegen/tables/Number.sol | 6 ++++-- .../contracts/src/codegen/tables/NumberList.sol | 6 ++++-- e2e/packages/contracts/src/codegen/tables/Vector.sol | 6 ++++-- .../contracts/src/codegen/tables/CounterTable.sol | 6 ++++-- .../contracts/src/codegen/tables/Inventory.sol | 10 ++++------ .../contracts/src/codegen/tables/MessageTable.sol | 6 ++++-- .../cli/contracts/src/codegen/tables/Dynamics1.sol | 6 ++++-- .../cli/contracts/src/codegen/tables/Dynamics2.sol | 6 ++++-- .../cli/contracts/src/codegen/tables/Ephemeral.sol | 6 ++++-- .../cli/contracts/src/codegen/tables/Singleton.sol | 6 ++++-- packages/cli/contracts/src/codegen/tables/Statics.sol | 6 ++++-- packages/store/src/codegen/tables/Callbacks.sol | 6 ++++-- packages/store/src/codegen/tables/Hooks.sol | 6 ++++-- packages/store/src/codegen/tables/KeyEncoding.sol | 6 ++++-- packages/store/src/codegen/tables/Mixed.sol | 6 ++++-- packages/store/src/codegen/tables/StoreMetadata.sol | 6 ++++-- packages/store/src/codegen/tables/Vector2.sol | 6 ++++-- packages/store/ts/codegen/renderTable.ts | 6 +++--- .../src/modules/core/tables/FunctionSelectors.sol | 6 ++++-- .../world/src/modules/core/tables/ResourceType.sol | 6 ++++-- packages/world/src/modules/core/tables/SystemHooks.sol | 6 ++++-- .../world/src/modules/core/tables/SystemRegistry.sol | 6 ++++-- packages/world/src/modules/core/tables/Systems.sol | 6 ++++-- .../src/modules/keysintable/tables/KeysInTable.sol | 6 ++++-- .../src/modules/keysintable/tables/UsedKeysIndex.sol | 6 ++++-- .../src/modules/keyswithvalue/tables/KeysWithValue.sol | 6 ++++-- .../src/modules/uniqueentity/tables/UniqueEntity.sol | 6 ++++-- packages/world/src/tables/InstalledModules.sol | 9 ++++----- packages/world/src/tables/NamespaceOwner.sol | 6 ++++-- packages/world/src/tables/ResourceAccess.sol | 6 ++++-- packages/world/test/tables/AddressArray.sol | 6 ++++-- packages/world/test/tables/Bool.sol | 6 ++++-- .../packages/contracts/src/codegen/tables/Counter.sol | 6 ++++-- .../packages/contracts/src/codegen/tables/Counter.sol | 6 ++++-- .../packages/contracts/src/codegen/tables/Position.sol | 6 ++++-- .../packages/contracts/src/codegen/tables/Counter.sol | 6 ++++-- 37 files changed, 147 insertions(+), 82 deletions(-) diff --git a/e2e/packages/contracts/src/codegen/tables/Multi.sol b/e2e/packages/contracts/src/codegen/tables/Multi.sol index 897212a608..b8dbb498b4 100644 --- a/e2e/packages/contracts/src/codegen/tables/Multi.sol +++ b/e2e/packages/contracts/src/codegen/tables/Multi.sol @@ -240,12 +240,14 @@ library Multi { } /** Encode keys as a bytes32 array using this table's schema */ - function encodeKeyTuple(uint32 a, bool b, uint256 c, int120 d) internal pure returns (bytes32[] memory _keyTuple) { - _keyTuple = new bytes32[](4); + function encodeKeyTuple(uint32 a, bool b, uint256 c, int120 d) internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](4); _keyTuple[0] = bytes32(uint256(a)); _keyTuple[1] = _boolToBytes32(b); _keyTuple[2] = bytes32(uint256(c)); _keyTuple[3] = bytes32(uint256(int256(d))); + + return _keyTuple; } /* Delete all data for given keys */ diff --git a/e2e/packages/contracts/src/codegen/tables/Number.sol b/e2e/packages/contracts/src/codegen/tables/Number.sol index d04ce89cd2..423831e5c4 100644 --- a/e2e/packages/contracts/src/codegen/tables/Number.sol +++ b/e2e/packages/contracts/src/codegen/tables/Number.sol @@ -105,9 +105,11 @@ library Number { } /** Encode keys as a bytes32 array using this table's schema */ - function encodeKeyTuple(uint32 key) internal pure returns (bytes32[] memory _keyTuple) { - _keyTuple = new bytes32[](1); + function encodeKeyTuple(uint32 key) internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); + + return _keyTuple; } /* Delete all data for given keys */ diff --git a/e2e/packages/contracts/src/codegen/tables/NumberList.sol b/e2e/packages/contracts/src/codegen/tables/NumberList.sol index fe99301d82..b450658074 100644 --- a/e2e/packages/contracts/src/codegen/tables/NumberList.sol +++ b/e2e/packages/contracts/src/codegen/tables/NumberList.sol @@ -202,8 +202,10 @@ library NumberList { } /** Encode keys as a bytes32 array using this table's schema */ - function encodeKeyTuple() internal pure returns (bytes32[] memory _keyTuple) { - _keyTuple = new bytes32[](0); + function encodeKeyTuple() internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](0); + + return _keyTuple; } /* Delete all data for given keys */ diff --git a/e2e/packages/contracts/src/codegen/tables/Vector.sol b/e2e/packages/contracts/src/codegen/tables/Vector.sol index b1378867e1..52cf8a6d1f 100644 --- a/e2e/packages/contracts/src/codegen/tables/Vector.sol +++ b/e2e/packages/contracts/src/codegen/tables/Vector.sol @@ -201,9 +201,11 @@ library Vector { } /** Encode keys as a bytes32 array using this table's schema */ - function encodeKeyTuple(uint32 key) internal pure returns (bytes32[] memory _keyTuple) { - _keyTuple = new bytes32[](1); + function encodeKeyTuple(uint32 key) internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(key)); + + return _keyTuple; } /* Delete all data for given keys */ diff --git a/examples/minimal/packages/contracts/src/codegen/tables/CounterTable.sol b/examples/minimal/packages/contracts/src/codegen/tables/CounterTable.sol index 2b096543ae..cc6c9f935d 100644 --- a/examples/minimal/packages/contracts/src/codegen/tables/CounterTable.sol +++ b/examples/minimal/packages/contracts/src/codegen/tables/CounterTable.sol @@ -100,8 +100,10 @@ library CounterTable { } /** Encode keys as a bytes32 array using this table's schema */ - function encodeKeyTuple() internal pure returns (bytes32[] memory _keyTuple) { - _keyTuple = new bytes32[](0); + function encodeKeyTuple() internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](0); + + return _keyTuple; } /* Delete all data for given keys */ diff --git a/examples/minimal/packages/contracts/src/codegen/tables/Inventory.sol b/examples/minimal/packages/contracts/src/codegen/tables/Inventory.sol index c79da3fb45..312dd5508c 100644 --- a/examples/minimal/packages/contracts/src/codegen/tables/Inventory.sol +++ b/examples/minimal/packages/contracts/src/codegen/tables/Inventory.sol @@ -115,15 +115,13 @@ library Inventory { } /** Encode keys as a bytes32 array using this table's schema */ - function encodeKeyTuple( - address owner, - uint32 item, - uint32 itemVariant - ) internal pure returns (bytes32[] memory _keyTuple) { - _keyTuple = new bytes32[](3); + function encodeKeyTuple(address owner, uint32 item, uint32 itemVariant) internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](3); _keyTuple[0] = bytes32(uint256(uint160(owner))); _keyTuple[1] = bytes32(uint256(item)); _keyTuple[2] = bytes32(uint256(itemVariant)); + + return _keyTuple; } /* Delete all data for given keys */ diff --git a/examples/minimal/packages/contracts/src/codegen/tables/MessageTable.sol b/examples/minimal/packages/contracts/src/codegen/tables/MessageTable.sol index 935e5bf105..62bba2fbd1 100644 --- a/examples/minimal/packages/contracts/src/codegen/tables/MessageTable.sol +++ b/examples/minimal/packages/contracts/src/codegen/tables/MessageTable.sol @@ -92,7 +92,9 @@ library MessageTable { } /** Encode keys as a bytes32 array using this table's schema */ - function encodeKeyTuple() internal pure returns (bytes32[] memory _keyTuple) { - _keyTuple = new bytes32[](0); + function encodeKeyTuple() internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](0); + + return _keyTuple; } } diff --git a/packages/cli/contracts/src/codegen/tables/Dynamics1.sol b/packages/cli/contracts/src/codegen/tables/Dynamics1.sol index 19c20c4149..10301f6d57 100644 --- a/packages/cli/contracts/src/codegen/tables/Dynamics1.sol +++ b/packages/cli/contracts/src/codegen/tables/Dynamics1.sol @@ -947,9 +947,11 @@ library Dynamics1 { } /** Encode keys as a bytes32 array using this table's schema */ - function encodeKeyTuple(bytes32 key) internal pure returns (bytes32[] memory _keyTuple) { - _keyTuple = new bytes32[](1); + function encodeKeyTuple(bytes32 key) internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; + + return _keyTuple; } /* Delete all data for given keys */ diff --git a/packages/cli/contracts/src/codegen/tables/Dynamics2.sol b/packages/cli/contracts/src/codegen/tables/Dynamics2.sol index 2de0e96b8b..df04316e0d 100644 --- a/packages/cli/contracts/src/codegen/tables/Dynamics2.sol +++ b/packages/cli/contracts/src/codegen/tables/Dynamics2.sol @@ -593,9 +593,11 @@ library Dynamics2 { } /** Encode keys as a bytes32 array using this table's schema */ - function encodeKeyTuple(bytes32 key) internal pure returns (bytes32[] memory _keyTuple) { - _keyTuple = new bytes32[](1); + function encodeKeyTuple(bytes32 key) internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; + + return _keyTuple; } /* Delete all data for given keys */ diff --git a/packages/cli/contracts/src/codegen/tables/Ephemeral.sol b/packages/cli/contracts/src/codegen/tables/Ephemeral.sol index 60edaa1a0d..10b5aaa18b 100644 --- a/packages/cli/contracts/src/codegen/tables/Ephemeral.sol +++ b/packages/cli/contracts/src/codegen/tables/Ephemeral.sol @@ -91,8 +91,10 @@ library Ephemeral { } /** Encode keys as a bytes32 array using this table's schema */ - function encodeKeyTuple(bytes32 key) internal pure returns (bytes32[] memory _keyTuple) { - _keyTuple = new bytes32[](1); + function encodeKeyTuple(bytes32 key) internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; + + return _keyTuple; } } diff --git a/packages/cli/contracts/src/codegen/tables/Singleton.sol b/packages/cli/contracts/src/codegen/tables/Singleton.sol index 30fac036d9..4ddd816e3d 100644 --- a/packages/cli/contracts/src/codegen/tables/Singleton.sol +++ b/packages/cli/contracts/src/codegen/tables/Singleton.sol @@ -580,8 +580,10 @@ library Singleton { } /** Encode keys as a bytes32 array using this table's schema */ - function encodeKeyTuple() internal pure returns (bytes32[] memory _keyTuple) { - _keyTuple = new bytes32[](0); + function encodeKeyTuple() internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](0); + + return _keyTuple; } /* Delete all data for given keys */ diff --git a/packages/cli/contracts/src/codegen/tables/Statics.sol b/packages/cli/contracts/src/codegen/tables/Statics.sol index c8b3f4be8b..d69a8c61f8 100644 --- a/packages/cli/contracts/src/codegen/tables/Statics.sol +++ b/packages/cli/contracts/src/codegen/tables/Statics.sol @@ -885,8 +885,8 @@ library Statics { bool k5, Enum1 k6, Enum2 k7 - ) internal pure returns (bytes32[] memory _keyTuple) { - _keyTuple = new bytes32[](7); + ) internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](7); _keyTuple[0] = bytes32(uint256(k1)); _keyTuple[1] = bytes32(uint256(int256(k2))); _keyTuple[2] = bytes32(k3); @@ -894,6 +894,8 @@ library Statics { _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); _keyTuple[6] = bytes32(uint256(uint8(k7))); + + return _keyTuple; } /* Delete all data for given keys */ diff --git a/packages/store/src/codegen/tables/Callbacks.sol b/packages/store/src/codegen/tables/Callbacks.sol index e3983aded6..40246f80de 100644 --- a/packages/store/src/codegen/tables/Callbacks.sol +++ b/packages/store/src/codegen/tables/Callbacks.sol @@ -224,9 +224,11 @@ library Callbacks { } /** Encode keys as a bytes32 array using this table's schema */ - function encodeKeyTuple(bytes32 key) internal pure returns (bytes32[] memory _keyTuple) { - _keyTuple = new bytes32[](1); + function encodeKeyTuple(bytes32 key) internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; + + return _keyTuple; } /* Delete all data for given keys */ diff --git a/packages/store/src/codegen/tables/Hooks.sol b/packages/store/src/codegen/tables/Hooks.sol index 4708636baa..3815c49696 100644 --- a/packages/store/src/codegen/tables/Hooks.sol +++ b/packages/store/src/codegen/tables/Hooks.sol @@ -224,9 +224,11 @@ library Hooks { } /** Encode keys as a bytes32 array using this table's schema */ - function encodeKeyTuple(bytes32 key) internal pure returns (bytes32[] memory _keyTuple) { - _keyTuple = new bytes32[](1); + function encodeKeyTuple(bytes32 key) internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; + + return _keyTuple; } /* Delete all data for given keys */ diff --git a/packages/store/src/codegen/tables/KeyEncoding.sol b/packages/store/src/codegen/tables/KeyEncoding.sol index 11a235d6df..090f3adc36 100644 --- a/packages/store/src/codegen/tables/KeyEncoding.sol +++ b/packages/store/src/codegen/tables/KeyEncoding.sol @@ -164,14 +164,16 @@ library KeyEncoding { address k4, bool k5, ExampleEnum k6 - ) internal pure returns (bytes32[] memory _keyTuple) { - _keyTuple = new bytes32[](6); + ) internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](6); _keyTuple[0] = bytes32(uint256(k1)); _keyTuple[1] = bytes32(uint256(int256(k2))); _keyTuple[2] = bytes32(k3); _keyTuple[3] = bytes32(uint256(uint160(k4))); _keyTuple[4] = _boolToBytes32(k5); _keyTuple[5] = bytes32(uint256(uint8(k6))); + + return _keyTuple; } /* Delete all data for given keys */ diff --git a/packages/store/src/codegen/tables/Mixed.sol b/packages/store/src/codegen/tables/Mixed.sol index 23ce59dbc2..2b5a00b7e2 100644 --- a/packages/store/src/codegen/tables/Mixed.sol +++ b/packages/store/src/codegen/tables/Mixed.sol @@ -519,9 +519,11 @@ library Mixed { } /** Encode keys as a bytes32 array using this table's schema */ - function encodeKeyTuple(bytes32 key) internal pure returns (bytes32[] memory _keyTuple) { - _keyTuple = new bytes32[](1); + function encodeKeyTuple(bytes32 key) internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; + + return _keyTuple; } /* Delete all data for given keys */ diff --git a/packages/store/src/codegen/tables/StoreMetadata.sol b/packages/store/src/codegen/tables/StoreMetadata.sol index 02012dce67..f365448cb8 100644 --- a/packages/store/src/codegen/tables/StoreMetadata.sol +++ b/packages/store/src/codegen/tables/StoreMetadata.sol @@ -448,9 +448,11 @@ library StoreMetadata { } /** Encode keys as a bytes32 array using this table's schema */ - function encodeKeyTuple(bytes32 tableId) internal pure returns (bytes32[] memory _keyTuple) { - _keyTuple = new bytes32[](1); + function encodeKeyTuple(bytes32 tableId) internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = tableId; + + return _keyTuple; } /* Delete all data for given keys */ diff --git a/packages/store/src/codegen/tables/Vector2.sol b/packages/store/src/codegen/tables/Vector2.sol index 29f709a934..7f96b6f389 100644 --- a/packages/store/src/codegen/tables/Vector2.sol +++ b/packages/store/src/codegen/tables/Vector2.sol @@ -201,9 +201,11 @@ library Vector2 { } /** Encode keys as a bytes32 array using this table's schema */ - function encodeKeyTuple(bytes32 key) internal pure returns (bytes32[] memory _keyTuple) { - _keyTuple = new bytes32[](1); + function encodeKeyTuple(bytes32 key) internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; + + return _keyTuple; } /* Delete all data for given keys */ diff --git a/packages/store/ts/codegen/renderTable.ts b/packages/store/ts/codegen/renderTable.ts index d2d6c73ab9..99c83c2986 100644 --- a/packages/store/ts/codegen/renderTable.ts +++ b/packages/store/ts/codegen/renderTable.ts @@ -135,9 +135,9 @@ library ${libraryName} { } /** Encode keys as a bytes32 array using this table's schema */ - function encodeKeyTuple(${renderArguments([_typedKeyArgs])}) internal pure returns (bytes32[] memory _keyTuple) { - _keyTuple = new bytes32[](${keyTuple.length}); - ${renderList(keyTuple, (key, index) => `_keyTuple[${index}] = ${renderValueTypeToBytes32(key.name, key)};`)} + function encodeKeyTuple(${renderArguments([_typedKeyArgs])}) internal pure returns (bytes32[] memory) { + ${_keyTupleDefinition} + return _keyTuple; } ${ diff --git a/packages/world/src/modules/core/tables/FunctionSelectors.sol b/packages/world/src/modules/core/tables/FunctionSelectors.sol index 618cc9ab0c..b9324bdcc5 100644 --- a/packages/world/src/modules/core/tables/FunctionSelectors.sol +++ b/packages/world/src/modules/core/tables/FunctionSelectors.sol @@ -240,9 +240,11 @@ library FunctionSelectors { } /** Encode keys as a bytes32 array using this table's schema */ - function encodeKeyTuple(bytes4 functionSelector) internal pure returns (bytes32[] memory _keyTuple) { - _keyTuple = new bytes32[](1); + function encodeKeyTuple(bytes4 functionSelector) internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(functionSelector); + + return _keyTuple; } /* Delete all data for given keys */ diff --git a/packages/world/src/modules/core/tables/ResourceType.sol b/packages/world/src/modules/core/tables/ResourceType.sol index 3d33df38a1..d62ff7576c 100644 --- a/packages/world/src/modules/core/tables/ResourceType.sol +++ b/packages/world/src/modules/core/tables/ResourceType.sol @@ -108,9 +108,11 @@ library ResourceType { } /** Encode keys as a bytes32 array using this table's schema */ - function encodeKeyTuple(bytes32 resourceSelector) internal pure returns (bytes32[] memory _keyTuple) { - _keyTuple = new bytes32[](1); + function encodeKeyTuple(bytes32 resourceSelector) internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = resourceSelector; + + return _keyTuple; } /* Delete all data for given keys */ diff --git a/packages/world/src/modules/core/tables/SystemHooks.sol b/packages/world/src/modules/core/tables/SystemHooks.sol index e0aa0f43e0..262125b965 100644 --- a/packages/world/src/modules/core/tables/SystemHooks.sol +++ b/packages/world/src/modules/core/tables/SystemHooks.sol @@ -224,9 +224,11 @@ library SystemHooks { } /** Encode keys as a bytes32 array using this table's schema */ - function encodeKeyTuple(bytes32 resourceSelector) internal pure returns (bytes32[] memory _keyTuple) { - _keyTuple = new bytes32[](1); + function encodeKeyTuple(bytes32 resourceSelector) internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = resourceSelector; + + return _keyTuple; } /* Delete all data for given keys */ diff --git a/packages/world/src/modules/core/tables/SystemRegistry.sol b/packages/world/src/modules/core/tables/SystemRegistry.sol index 1dd6e9bcad..2df68b1975 100644 --- a/packages/world/src/modules/core/tables/SystemRegistry.sol +++ b/packages/world/src/modules/core/tables/SystemRegistry.sol @@ -105,9 +105,11 @@ library SystemRegistry { } /** Encode keys as a bytes32 array using this table's schema */ - function encodeKeyTuple(address system) internal pure returns (bytes32[] memory _keyTuple) { - _keyTuple = new bytes32[](1); + function encodeKeyTuple(address system) internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(uint256(uint160(system))); + + return _keyTuple; } /* Delete all data for given keys */ diff --git a/packages/world/src/modules/core/tables/Systems.sol b/packages/world/src/modules/core/tables/Systems.sol index 16a250d86e..15ea87a05c 100644 --- a/packages/world/src/modules/core/tables/Systems.sol +++ b/packages/world/src/modules/core/tables/Systems.sol @@ -186,9 +186,11 @@ library Systems { } /** Encode keys as a bytes32 array using this table's schema */ - function encodeKeyTuple(bytes32 resourceSelector) internal pure returns (bytes32[] memory _keyTuple) { - _keyTuple = new bytes32[](1); + function encodeKeyTuple(bytes32 resourceSelector) internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = resourceSelector; + + return _keyTuple; } /* Delete all data for given keys */ diff --git a/packages/world/src/modules/keysintable/tables/KeysInTable.sol b/packages/world/src/modules/keysintable/tables/KeysInTable.sol index dde965f55e..9a10d7b3e7 100644 --- a/packages/world/src/modules/keysintable/tables/KeysInTable.sol +++ b/packages/world/src/modules/keysintable/tables/KeysInTable.sol @@ -961,9 +961,11 @@ library KeysInTable { } /** Encode keys as a bytes32 array using this table's schema */ - function encodeKeyTuple(bytes32 sourceTable) internal pure returns (bytes32[] memory _keyTuple) { - _keyTuple = new bytes32[](1); + function encodeKeyTuple(bytes32 sourceTable) internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = sourceTable; + + return _keyTuple; } /* Delete all data for given keys */ diff --git a/packages/world/src/modules/keysintable/tables/UsedKeysIndex.sol b/packages/world/src/modules/keysintable/tables/UsedKeysIndex.sol index 8378c830cb..4bf9d9ce67 100644 --- a/packages/world/src/modules/keysintable/tables/UsedKeysIndex.sol +++ b/packages/world/src/modules/keysintable/tables/UsedKeysIndex.sol @@ -199,10 +199,12 @@ library UsedKeysIndex { } /** Encode keys as a bytes32 array using this table's schema */ - function encodeKeyTuple(bytes32 sourceTable, bytes32 keysHash) internal pure returns (bytes32[] memory _keyTuple) { - _keyTuple = new bytes32[](2); + function encodeKeyTuple(bytes32 sourceTable, bytes32 keysHash) internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](2); _keyTuple[0] = sourceTable; _keyTuple[1] = keysHash; + + return _keyTuple; } /* Delete all data for given keys */ diff --git a/packages/world/src/modules/keyswithvalue/tables/KeysWithValue.sol b/packages/world/src/modules/keyswithvalue/tables/KeysWithValue.sol index 7195986076..9f9956e47e 100644 --- a/packages/world/src/modules/keyswithvalue/tables/KeysWithValue.sol +++ b/packages/world/src/modules/keyswithvalue/tables/KeysWithValue.sol @@ -225,9 +225,11 @@ library KeysWithValue { } /** Encode keys as a bytes32 array using this table's schema */ - function encodeKeyTuple(bytes32 valueHash) internal pure returns (bytes32[] memory _keyTuple) { - _keyTuple = new bytes32[](1); + function encodeKeyTuple(bytes32 valueHash) internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = valueHash; + + return _keyTuple; } /* Delete all data for given keys */ diff --git a/packages/world/src/modules/uniqueentity/tables/UniqueEntity.sol b/packages/world/src/modules/uniqueentity/tables/UniqueEntity.sol index d094fad3bc..bbcf97aca2 100644 --- a/packages/world/src/modules/uniqueentity/tables/UniqueEntity.sol +++ b/packages/world/src/modules/uniqueentity/tables/UniqueEntity.sol @@ -97,8 +97,10 @@ library UniqueEntity { } /** Encode keys as a bytes32 array using this table's schema */ - function encodeKeyTuple() internal pure returns (bytes32[] memory _keyTuple) { - _keyTuple = new bytes32[](0); + function encodeKeyTuple() internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](0); + + return _keyTuple; } /* Delete all data for given keys */ diff --git a/packages/world/src/tables/InstalledModules.sol b/packages/world/src/tables/InstalledModules.sol index 136d4e6909..aad89738e4 100644 --- a/packages/world/src/tables/InstalledModules.sol +++ b/packages/world/src/tables/InstalledModules.sol @@ -179,13 +179,12 @@ library InstalledModules { } /** Encode keys as a bytes32 array using this table's schema */ - function encodeKeyTuple( - bytes16 moduleName, - bytes32 argumentsHash - ) internal pure returns (bytes32[] memory _keyTuple) { - _keyTuple = new bytes32[](2); + function encodeKeyTuple(bytes16 moduleName, bytes32 argumentsHash) internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](2); _keyTuple[0] = bytes32(moduleName); _keyTuple[1] = argumentsHash; + + return _keyTuple; } /* Delete all data for given keys */ diff --git a/packages/world/src/tables/NamespaceOwner.sol b/packages/world/src/tables/NamespaceOwner.sol index 9e5a75ed00..b509ee5674 100644 --- a/packages/world/src/tables/NamespaceOwner.sol +++ b/packages/world/src/tables/NamespaceOwner.sol @@ -105,9 +105,11 @@ library NamespaceOwner { } /** Encode keys as a bytes32 array using this table's schema */ - function encodeKeyTuple(bytes16 namespace) internal pure returns (bytes32[] memory _keyTuple) { - _keyTuple = new bytes32[](1); + function encodeKeyTuple(bytes16 namespace) internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = bytes32(namespace); + + return _keyTuple; } /* Delete all data for given keys */ diff --git a/packages/world/src/tables/ResourceAccess.sol b/packages/world/src/tables/ResourceAccess.sol index 294106c30e..0bacd48605 100644 --- a/packages/world/src/tables/ResourceAccess.sol +++ b/packages/world/src/tables/ResourceAccess.sol @@ -110,10 +110,12 @@ library ResourceAccess { } /** Encode keys as a bytes32 array using this table's schema */ - function encodeKeyTuple(bytes32 resourceSelector, address caller) internal pure returns (bytes32[] memory _keyTuple) { - _keyTuple = new bytes32[](2); + function encodeKeyTuple(bytes32 resourceSelector, address caller) internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](2); _keyTuple[0] = resourceSelector; _keyTuple[1] = bytes32(uint256(uint160(caller))); + + return _keyTuple; } /* Delete all data for given keys */ diff --git a/packages/world/test/tables/AddressArray.sol b/packages/world/test/tables/AddressArray.sol index c338531100..77e07acd1b 100644 --- a/packages/world/test/tables/AddressArray.sol +++ b/packages/world/test/tables/AddressArray.sol @@ -221,9 +221,11 @@ library AddressArray { } /** Encode keys as a bytes32 array using this table's schema */ - function encodeKeyTuple(bytes32 key) internal pure returns (bytes32[] memory _keyTuple) { - _keyTuple = new bytes32[](1); + function encodeKeyTuple(bytes32 key) internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; + + return _keyTuple; } /* Delete all data for given keys */ diff --git a/packages/world/test/tables/Bool.sol b/packages/world/test/tables/Bool.sol index bcf67c13e3..71b1de5019 100644 --- a/packages/world/test/tables/Bool.sol +++ b/packages/world/test/tables/Bool.sol @@ -97,8 +97,10 @@ library Bool { } /** Encode keys as a bytes32 array using this table's schema */ - function encodeKeyTuple() internal pure returns (bytes32[] memory _keyTuple) { - _keyTuple = new bytes32[](0); + function encodeKeyTuple() internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](0); + + return _keyTuple; } /* Delete all data for given keys */ diff --git a/templates/phaser/packages/contracts/src/codegen/tables/Counter.sol b/templates/phaser/packages/contracts/src/codegen/tables/Counter.sol index 7f32cb2164..8cdba26bb5 100644 --- a/templates/phaser/packages/contracts/src/codegen/tables/Counter.sol +++ b/templates/phaser/packages/contracts/src/codegen/tables/Counter.sol @@ -100,8 +100,10 @@ library Counter { } /** Encode keys as a bytes32 array using this table's schema */ - function encodeKeyTuple() internal pure returns (bytes32[] memory _keyTuple) { - _keyTuple = new bytes32[](0); + function encodeKeyTuple() internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](0); + + return _keyTuple; } /* Delete all data for given keys */ diff --git a/templates/react/packages/contracts/src/codegen/tables/Counter.sol b/templates/react/packages/contracts/src/codegen/tables/Counter.sol index 7f32cb2164..8cdba26bb5 100644 --- a/templates/react/packages/contracts/src/codegen/tables/Counter.sol +++ b/templates/react/packages/contracts/src/codegen/tables/Counter.sol @@ -100,8 +100,10 @@ library Counter { } /** Encode keys as a bytes32 array using this table's schema */ - function encodeKeyTuple() internal pure returns (bytes32[] memory _keyTuple) { - _keyTuple = new bytes32[](0); + function encodeKeyTuple() internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](0); + + return _keyTuple; } /* Delete all data for given keys */ diff --git a/templates/threejs/packages/contracts/src/codegen/tables/Position.sol b/templates/threejs/packages/contracts/src/codegen/tables/Position.sol index 54a642249c..21930b0683 100644 --- a/templates/threejs/packages/contracts/src/codegen/tables/Position.sol +++ b/templates/threejs/packages/contracts/src/codegen/tables/Position.sol @@ -240,9 +240,11 @@ library Position { } /** Encode keys as a bytes32 array using this table's schema */ - function encodeKeyTuple(bytes32 key) internal pure returns (bytes32[] memory _keyTuple) { - _keyTuple = new bytes32[](1); + function encodeKeyTuple(bytes32 key) internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](1); _keyTuple[0] = key; + + return _keyTuple; } /* Delete all data for given keys */ diff --git a/templates/vanilla/packages/contracts/src/codegen/tables/Counter.sol b/templates/vanilla/packages/contracts/src/codegen/tables/Counter.sol index 7f32cb2164..8cdba26bb5 100644 --- a/templates/vanilla/packages/contracts/src/codegen/tables/Counter.sol +++ b/templates/vanilla/packages/contracts/src/codegen/tables/Counter.sol @@ -100,8 +100,10 @@ library Counter { } /** Encode keys as a bytes32 array using this table's schema */ - function encodeKeyTuple() internal pure returns (bytes32[] memory _keyTuple) { - _keyTuple = new bytes32[](0); + function encodeKeyTuple() internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](0); + + return _keyTuple; } /* Delete all data for given keys */