@latticexyz/world-modules 2.0.12-type-resolutions-effc7ab1 → 2.0.12-type-resolutions-8538f80e

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/cache/solidity-files-cache.json +1 -1
  2. package/package.json +9 -8
  3. package/src/index.sol +25 -0
  4. package/src/interfaces/IBaseWorld.sol +16 -0
  5. package/src/interfaces/IERC20System.sol +33 -0
  6. package/src/interfaces/IERC721System.sol +43 -0
  7. package/src/interfaces/IPuppetFactorySystem.sol +15 -0
  8. package/src/interfaces/IUniqueEntitySystem.sol +13 -0
  9. package/src/interfaces/IUnstable_CallWithSignatureSystem.sol +20 -0
  10. package/src/modules/callwithsignature/ECDSA.sol +174 -0
  11. package/src/modules/callwithsignature/IERC1271.sol +17 -0
  12. package/src/modules/callwithsignature/IUnstable_CallWithSignatureErrors.sol +9 -0
  13. package/src/modules/callwithsignature/SignatureChecker.sol +50 -0
  14. package/src/modules/callwithsignature/Unstable_CallWithSignatureModule.sol +48 -0
  15. package/src/modules/callwithsignature/Unstable_CallWithSignatureSystem.sol +36 -0
  16. package/src/modules/callwithsignature/constants.sol +10 -0
  17. package/src/modules/callwithsignature/getSignedMessageHash.sol +54 -0
  18. package/src/modules/callwithsignature/tables/CallWithSignatureNonces.sol +199 -0
  19. package/src/modules/callwithsignature/validateCallWithSignature.sol +31 -0
  20. package/src/modules/erc20-puppet/ERC20Module.sol +88 -0
  21. package/src/modules/erc20-puppet/ERC20System.sol +286 -0
  22. package/src/modules/erc20-puppet/IERC20.sol +94 -0
  23. package/src/modules/erc20-puppet/IERC20Errors.sol +49 -0
  24. package/src/modules/erc20-puppet/IERC20Events.sol +18 -0
  25. package/src/modules/erc20-puppet/IERC20Mintable.sol +25 -0
  26. package/src/modules/erc20-puppet/constants.sol +20 -0
  27. package/src/modules/erc20-puppet/registerERC20.sol +35 -0
  28. package/src/modules/erc20-puppet/tables/Allowances.sol +208 -0
  29. package/src/modules/erc20-puppet/tables/ERC20Metadata.sol +604 -0
  30. package/src/modules/erc20-puppet/tables/ERC20Registry.sol +199 -0
  31. package/src/modules/erc20-puppet/tables/TotalSupply.sol +184 -0
  32. package/src/modules/erc20-puppet/utils.sol +30 -0
  33. package/src/modules/erc721-puppet/ERC721Module.sol +95 -0
  34. package/src/modules/erc721-puppet/ERC721System.sol +531 -0
  35. package/src/modules/erc721-puppet/IERC721.sol +120 -0
  36. package/src/modules/erc721-puppet/IERC721Errors.sol +61 -0
  37. package/src/modules/erc721-puppet/IERC721Events.sol +23 -0
  38. package/src/modules/erc721-puppet/IERC721Metadata.sol +27 -0
  39. package/src/modules/erc721-puppet/IERC721Mintable.sol +53 -0
  40. package/src/modules/erc721-puppet/IERC721Receiver.sol +28 -0
  41. package/src/modules/erc721-puppet/constants.sol +23 -0
  42. package/src/modules/erc721-puppet/libraries/LibString.sol +77 -0
  43. package/src/modules/erc721-puppet/registerERC721.sol +37 -0
  44. package/src/modules/erc721-puppet/tables/ERC721Metadata.sol +703 -0
  45. package/src/modules/erc721-puppet/tables/ERC721Registry.sol +199 -0
  46. package/src/modules/erc721-puppet/tables/OperatorApproval.sol +220 -0
  47. package/src/modules/erc721-puppet/tables/Owners.sol +196 -0
  48. package/src/modules/erc721-puppet/tables/TokenApproval.sol +196 -0
  49. package/src/modules/erc721-puppet/tables/TokenURI.sol +450 -0
  50. package/src/modules/erc721-puppet/utils.sol +38 -0
  51. package/src/modules/keysintable/KeysInTableHook.sol +141 -0
  52. package/src/modules/keysintable/KeysInTableModule.sol +110 -0
  53. package/src/modules/keysintable/constants.sol +7 -0
  54. package/src/modules/keysintable/getKeysInTable.sol +81 -0
  55. package/src/modules/keysintable/hasKey.sol +28 -0
  56. package/src/modules/keysintable/query.sol +200 -0
  57. package/src/modules/keysintable/tables/KeysInTable.sol +1638 -0
  58. package/src/modules/keysintable/tables/UsedKeysIndex.sol +414 -0
  59. package/src/modules/keyswithvalue/KeysWithValueHook.sol +158 -0
  60. package/src/modules/keyswithvalue/KeysWithValueModule.sol +103 -0
  61. package/src/modules/keyswithvalue/constants.sol +7 -0
  62. package/src/modules/keyswithvalue/getKeysWithValue.sol +58 -0
  63. package/src/modules/keyswithvalue/getTargetTableId.sol +32 -0
  64. package/src/modules/keyswithvalue/tables/KeysWithValue.sol +668 -0
  65. package/src/modules/puppet/Puppet.sol +80 -0
  66. package/src/modules/puppet/PuppetDelegationControl.sol +17 -0
  67. package/src/modules/puppet/PuppetFactorySystem.sol +25 -0
  68. package/src/modules/puppet/PuppetMaster.sol +19 -0
  69. package/src/modules/puppet/PuppetModule.sol +64 -0
  70. package/src/modules/puppet/constants.sol +23 -0
  71. package/src/modules/puppet/createPuppet.sol +24 -0
  72. package/src/modules/puppet/tables/PuppetRegistry.sol +199 -0
  73. package/src/modules/puppet/utils.sol +10 -0
  74. package/src/modules/std-delegations/CallboundDelegationControl.sol +64 -0
  75. package/src/modules/std-delegations/StandardDelegationsModule.sol +55 -0
  76. package/src/modules/std-delegations/SystemboundDelegationControl.sol +54 -0
  77. package/src/modules/std-delegations/TimeboundDelegationControl.sol +27 -0
  78. package/src/modules/std-delegations/constants.sol +21 -0
  79. package/src/modules/std-delegations/tables/CallboundDelegations.sol +287 -0
  80. package/src/modules/std-delegations/tables/SystemboundDelegations.sol +256 -0
  81. package/src/modules/std-delegations/tables/TimeboundDelegations.sol +211 -0
  82. package/src/modules/tokens/tables/Balances.sol +196 -0
  83. package/src/modules/uniqueentity/UniqueEntityModule.sol +73 -0
  84. package/src/modules/uniqueentity/UniqueEntitySystem.sol +18 -0
  85. package/src/modules/uniqueentity/constants.sol +13 -0
  86. package/src/modules/uniqueentity/getUniqueEntity.sol +26 -0
  87. package/src/modules/uniqueentity/tables/UniqueEntity.sol +238 -0
  88. package/src/modules/utils/ArrayLib.sol +55 -0
  89. package/src/utils/AccessControlLib.sol +55 -0
  90. package/src/utils/SystemSwitch.sol +80 -0
@@ -0,0 +1,199 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity >=0.8.24;
3
+
4
+ /* Autogenerated file. Do not edit manually. */
5
+
6
+ // Import store internals
7
+ import { IStore } from "@latticexyz/store/src/IStore.sol";
8
+ import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol";
9
+ import { StoreCore } from "@latticexyz/store/src/StoreCore.sol";
10
+ import { Bytes } from "@latticexyz/store/src/Bytes.sol";
11
+ import { Memory } from "@latticexyz/store/src/Memory.sol";
12
+ import { SliceLib } from "@latticexyz/store/src/Slice.sol";
13
+ import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol";
14
+ import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol";
15
+ import { Schema } from "@latticexyz/store/src/Schema.sol";
16
+ import { EncodedLengths, EncodedLengthsLib } from "@latticexyz/store/src/EncodedLengths.sol";
17
+ import { ResourceId } from "@latticexyz/store/src/ResourceId.sol";
18
+
19
+ // Import user types
20
+ import { ResourceId } from "@latticexyz/store/src/ResourceId.sol";
21
+
22
+ library ERC721Registry {
23
+ FieldLayout constant _fieldLayout =
24
+ FieldLayout.wrap(0x0014010014000000000000000000000000000000000000000000000000000000);
25
+
26
+ // Hex-encoded key schema of (bytes32)
27
+ Schema constant _keySchema = Schema.wrap(0x002001005f000000000000000000000000000000000000000000000000000000);
28
+ // Hex-encoded value schema of (address)
29
+ Schema constant _valueSchema = Schema.wrap(0x0014010061000000000000000000000000000000000000000000000000000000);
30
+
31
+ /**
32
+ * @notice Get the table's key field names.
33
+ * @return keyNames An array of strings with the names of key fields.
34
+ */
35
+ function getKeyNames() internal pure returns (string[] memory keyNames) {
36
+ keyNames = new string[](1);
37
+ keyNames[0] = "namespaceId";
38
+ }
39
+
40
+ /**
41
+ * @notice Get the table's value field names.
42
+ * @return fieldNames An array of strings with the names of value fields.
43
+ */
44
+ function getFieldNames() internal pure returns (string[] memory fieldNames) {
45
+ fieldNames = new string[](1);
46
+ fieldNames[0] = "tokenAddress";
47
+ }
48
+
49
+ /**
50
+ * @notice Register the table with its config.
51
+ */
52
+ function register(ResourceId _tableId) internal {
53
+ StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
54
+ }
55
+
56
+ /**
57
+ * @notice Register the table with its config.
58
+ */
59
+ function _register(ResourceId _tableId) internal {
60
+ StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
61
+ }
62
+
63
+ /**
64
+ * @notice Get tokenAddress.
65
+ */
66
+ function getTokenAddress(ResourceId _tableId, ResourceId namespaceId) internal view returns (address tokenAddress) {
67
+ bytes32[] memory _keyTuple = new bytes32[](1);
68
+ _keyTuple[0] = ResourceId.unwrap(namespaceId);
69
+
70
+ bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout);
71
+ return (address(bytes20(_blob)));
72
+ }
73
+
74
+ /**
75
+ * @notice Get tokenAddress.
76
+ */
77
+ function _getTokenAddress(ResourceId _tableId, ResourceId namespaceId) internal view returns (address tokenAddress) {
78
+ bytes32[] memory _keyTuple = new bytes32[](1);
79
+ _keyTuple[0] = ResourceId.unwrap(namespaceId);
80
+
81
+ bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout);
82
+ return (address(bytes20(_blob)));
83
+ }
84
+
85
+ /**
86
+ * @notice Get tokenAddress.
87
+ */
88
+ function get(ResourceId _tableId, ResourceId namespaceId) internal view returns (address tokenAddress) {
89
+ bytes32[] memory _keyTuple = new bytes32[](1);
90
+ _keyTuple[0] = ResourceId.unwrap(namespaceId);
91
+
92
+ bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout);
93
+ return (address(bytes20(_blob)));
94
+ }
95
+
96
+ /**
97
+ * @notice Get tokenAddress.
98
+ */
99
+ function _get(ResourceId _tableId, ResourceId namespaceId) internal view returns (address tokenAddress) {
100
+ bytes32[] memory _keyTuple = new bytes32[](1);
101
+ _keyTuple[0] = ResourceId.unwrap(namespaceId);
102
+
103
+ bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout);
104
+ return (address(bytes20(_blob)));
105
+ }
106
+
107
+ /**
108
+ * @notice Set tokenAddress.
109
+ */
110
+ function setTokenAddress(ResourceId _tableId, ResourceId namespaceId, address tokenAddress) internal {
111
+ bytes32[] memory _keyTuple = new bytes32[](1);
112
+ _keyTuple[0] = ResourceId.unwrap(namespaceId);
113
+
114
+ StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((tokenAddress)), _fieldLayout);
115
+ }
116
+
117
+ /**
118
+ * @notice Set tokenAddress.
119
+ */
120
+ function _setTokenAddress(ResourceId _tableId, ResourceId namespaceId, address tokenAddress) internal {
121
+ bytes32[] memory _keyTuple = new bytes32[](1);
122
+ _keyTuple[0] = ResourceId.unwrap(namespaceId);
123
+
124
+ StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((tokenAddress)), _fieldLayout);
125
+ }
126
+
127
+ /**
128
+ * @notice Set tokenAddress.
129
+ */
130
+ function set(ResourceId _tableId, ResourceId namespaceId, address tokenAddress) internal {
131
+ bytes32[] memory _keyTuple = new bytes32[](1);
132
+ _keyTuple[0] = ResourceId.unwrap(namespaceId);
133
+
134
+ StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((tokenAddress)), _fieldLayout);
135
+ }
136
+
137
+ /**
138
+ * @notice Set tokenAddress.
139
+ */
140
+ function _set(ResourceId _tableId, ResourceId namespaceId, address tokenAddress) internal {
141
+ bytes32[] memory _keyTuple = new bytes32[](1);
142
+ _keyTuple[0] = ResourceId.unwrap(namespaceId);
143
+
144
+ StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((tokenAddress)), _fieldLayout);
145
+ }
146
+
147
+ /**
148
+ * @notice Delete all data for given keys.
149
+ */
150
+ function deleteRecord(ResourceId _tableId, ResourceId namespaceId) internal {
151
+ bytes32[] memory _keyTuple = new bytes32[](1);
152
+ _keyTuple[0] = ResourceId.unwrap(namespaceId);
153
+
154
+ StoreSwitch.deleteRecord(_tableId, _keyTuple);
155
+ }
156
+
157
+ /**
158
+ * @notice Delete all data for given keys.
159
+ */
160
+ function _deleteRecord(ResourceId _tableId, ResourceId namespaceId) internal {
161
+ bytes32[] memory _keyTuple = new bytes32[](1);
162
+ _keyTuple[0] = ResourceId.unwrap(namespaceId);
163
+
164
+ StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout);
165
+ }
166
+
167
+ /**
168
+ * @notice Tightly pack static (fixed length) data using this table's schema.
169
+ * @return The static data, encoded into a sequence of bytes.
170
+ */
171
+ function encodeStatic(address tokenAddress) internal pure returns (bytes memory) {
172
+ return abi.encodePacked(tokenAddress);
173
+ }
174
+
175
+ /**
176
+ * @notice Encode all of a record's fields.
177
+ * @return The static (fixed length) data, encoded into a sequence of bytes.
178
+ * @return The lengths of the dynamic fields (packed into a single bytes32 value).
179
+ * @return The dynamic (variable length) data, encoded into a sequence of bytes.
180
+ */
181
+ function encode(address tokenAddress) internal pure returns (bytes memory, EncodedLengths, bytes memory) {
182
+ bytes memory _staticData = encodeStatic(tokenAddress);
183
+
184
+ EncodedLengths _encodedLengths;
185
+ bytes memory _dynamicData;
186
+
187
+ return (_staticData, _encodedLengths, _dynamicData);
188
+ }
189
+
190
+ /**
191
+ * @notice Encode keys as a bytes32 array using this table's field layout.
192
+ */
193
+ function encodeKeyTuple(ResourceId namespaceId) internal pure returns (bytes32[] memory) {
194
+ bytes32[] memory _keyTuple = new bytes32[](1);
195
+ _keyTuple[0] = ResourceId.unwrap(namespaceId);
196
+
197
+ return _keyTuple;
198
+ }
199
+ }
@@ -0,0 +1,220 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity >=0.8.24;
3
+
4
+ /* Autogenerated file. Do not edit manually. */
5
+
6
+ // Import store internals
7
+ import { IStore } from "@latticexyz/store/src/IStore.sol";
8
+ import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol";
9
+ import { StoreCore } from "@latticexyz/store/src/StoreCore.sol";
10
+ import { Bytes } from "@latticexyz/store/src/Bytes.sol";
11
+ import { Memory } from "@latticexyz/store/src/Memory.sol";
12
+ import { SliceLib } from "@latticexyz/store/src/Slice.sol";
13
+ import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol";
14
+ import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol";
15
+ import { Schema } from "@latticexyz/store/src/Schema.sol";
16
+ import { EncodedLengths, EncodedLengthsLib } from "@latticexyz/store/src/EncodedLengths.sol";
17
+ import { ResourceId } from "@latticexyz/store/src/ResourceId.sol";
18
+
19
+ library OperatorApproval {
20
+ FieldLayout constant _fieldLayout =
21
+ FieldLayout.wrap(0x0001010001000000000000000000000000000000000000000000000000000000);
22
+
23
+ // Hex-encoded key schema of (address, address)
24
+ Schema constant _keySchema = Schema.wrap(0x0028020061610000000000000000000000000000000000000000000000000000);
25
+ // Hex-encoded value schema of (bool)
26
+ Schema constant _valueSchema = Schema.wrap(0x0001010060000000000000000000000000000000000000000000000000000000);
27
+
28
+ /**
29
+ * @notice Get the table's key field names.
30
+ * @return keyNames An array of strings with the names of key fields.
31
+ */
32
+ function getKeyNames() internal pure returns (string[] memory keyNames) {
33
+ keyNames = new string[](2);
34
+ keyNames[0] = "owner";
35
+ keyNames[1] = "operator";
36
+ }
37
+
38
+ /**
39
+ * @notice Get the table's value field names.
40
+ * @return fieldNames An array of strings with the names of value fields.
41
+ */
42
+ function getFieldNames() internal pure returns (string[] memory fieldNames) {
43
+ fieldNames = new string[](1);
44
+ fieldNames[0] = "approved";
45
+ }
46
+
47
+ /**
48
+ * @notice Register the table with its config.
49
+ */
50
+ function register(ResourceId _tableId) internal {
51
+ StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
52
+ }
53
+
54
+ /**
55
+ * @notice Register the table with its config.
56
+ */
57
+ function _register(ResourceId _tableId) internal {
58
+ StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
59
+ }
60
+
61
+ /**
62
+ * @notice Get approved.
63
+ */
64
+ function getApproved(ResourceId _tableId, address owner, address operator) internal view returns (bool approved) {
65
+ bytes32[] memory _keyTuple = new bytes32[](2);
66
+ _keyTuple[0] = bytes32(uint256(uint160(owner)));
67
+ _keyTuple[1] = bytes32(uint256(uint160(operator)));
68
+
69
+ bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout);
70
+ return (_toBool(uint8(bytes1(_blob))));
71
+ }
72
+
73
+ /**
74
+ * @notice Get approved.
75
+ */
76
+ function _getApproved(ResourceId _tableId, address owner, address operator) internal view returns (bool approved) {
77
+ bytes32[] memory _keyTuple = new bytes32[](2);
78
+ _keyTuple[0] = bytes32(uint256(uint160(owner)));
79
+ _keyTuple[1] = bytes32(uint256(uint160(operator)));
80
+
81
+ bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout);
82
+ return (_toBool(uint8(bytes1(_blob))));
83
+ }
84
+
85
+ /**
86
+ * @notice Get approved.
87
+ */
88
+ function get(ResourceId _tableId, address owner, address operator) internal view returns (bool approved) {
89
+ bytes32[] memory _keyTuple = new bytes32[](2);
90
+ _keyTuple[0] = bytes32(uint256(uint160(owner)));
91
+ _keyTuple[1] = bytes32(uint256(uint160(operator)));
92
+
93
+ bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout);
94
+ return (_toBool(uint8(bytes1(_blob))));
95
+ }
96
+
97
+ /**
98
+ * @notice Get approved.
99
+ */
100
+ function _get(ResourceId _tableId, address owner, address operator) internal view returns (bool approved) {
101
+ bytes32[] memory _keyTuple = new bytes32[](2);
102
+ _keyTuple[0] = bytes32(uint256(uint160(owner)));
103
+ _keyTuple[1] = bytes32(uint256(uint160(operator)));
104
+
105
+ bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout);
106
+ return (_toBool(uint8(bytes1(_blob))));
107
+ }
108
+
109
+ /**
110
+ * @notice Set approved.
111
+ */
112
+ function setApproved(ResourceId _tableId, address owner, address operator, bool approved) internal {
113
+ bytes32[] memory _keyTuple = new bytes32[](2);
114
+ _keyTuple[0] = bytes32(uint256(uint160(owner)));
115
+ _keyTuple[1] = bytes32(uint256(uint160(operator)));
116
+
117
+ StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((approved)), _fieldLayout);
118
+ }
119
+
120
+ /**
121
+ * @notice Set approved.
122
+ */
123
+ function _setApproved(ResourceId _tableId, address owner, address operator, bool approved) internal {
124
+ bytes32[] memory _keyTuple = new bytes32[](2);
125
+ _keyTuple[0] = bytes32(uint256(uint160(owner)));
126
+ _keyTuple[1] = bytes32(uint256(uint160(operator)));
127
+
128
+ StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((approved)), _fieldLayout);
129
+ }
130
+
131
+ /**
132
+ * @notice Set approved.
133
+ */
134
+ function set(ResourceId _tableId, address owner, address operator, bool approved) internal {
135
+ bytes32[] memory _keyTuple = new bytes32[](2);
136
+ _keyTuple[0] = bytes32(uint256(uint160(owner)));
137
+ _keyTuple[1] = bytes32(uint256(uint160(operator)));
138
+
139
+ StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((approved)), _fieldLayout);
140
+ }
141
+
142
+ /**
143
+ * @notice Set approved.
144
+ */
145
+ function _set(ResourceId _tableId, address owner, address operator, bool approved) internal {
146
+ bytes32[] memory _keyTuple = new bytes32[](2);
147
+ _keyTuple[0] = bytes32(uint256(uint160(owner)));
148
+ _keyTuple[1] = bytes32(uint256(uint160(operator)));
149
+
150
+ StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((approved)), _fieldLayout);
151
+ }
152
+
153
+ /**
154
+ * @notice Delete all data for given keys.
155
+ */
156
+ function deleteRecord(ResourceId _tableId, address owner, address operator) internal {
157
+ bytes32[] memory _keyTuple = new bytes32[](2);
158
+ _keyTuple[0] = bytes32(uint256(uint160(owner)));
159
+ _keyTuple[1] = bytes32(uint256(uint160(operator)));
160
+
161
+ StoreSwitch.deleteRecord(_tableId, _keyTuple);
162
+ }
163
+
164
+ /**
165
+ * @notice Delete all data for given keys.
166
+ */
167
+ function _deleteRecord(ResourceId _tableId, address owner, address operator) internal {
168
+ bytes32[] memory _keyTuple = new bytes32[](2);
169
+ _keyTuple[0] = bytes32(uint256(uint160(owner)));
170
+ _keyTuple[1] = bytes32(uint256(uint160(operator)));
171
+
172
+ StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout);
173
+ }
174
+
175
+ /**
176
+ * @notice Tightly pack static (fixed length) data using this table's schema.
177
+ * @return The static data, encoded into a sequence of bytes.
178
+ */
179
+ function encodeStatic(bool approved) internal pure returns (bytes memory) {
180
+ return abi.encodePacked(approved);
181
+ }
182
+
183
+ /**
184
+ * @notice Encode all of a record's fields.
185
+ * @return The static (fixed length) data, encoded into a sequence of bytes.
186
+ * @return The lengths of the dynamic fields (packed into a single bytes32 value).
187
+ * @return The dynamic (variable length) data, encoded into a sequence of bytes.
188
+ */
189
+ function encode(bool approved) internal pure returns (bytes memory, EncodedLengths, bytes memory) {
190
+ bytes memory _staticData = encodeStatic(approved);
191
+
192
+ EncodedLengths _encodedLengths;
193
+ bytes memory _dynamicData;
194
+
195
+ return (_staticData, _encodedLengths, _dynamicData);
196
+ }
197
+
198
+ /**
199
+ * @notice Encode keys as a bytes32 array using this table's field layout.
200
+ */
201
+ function encodeKeyTuple(address owner, address operator) internal pure returns (bytes32[] memory) {
202
+ bytes32[] memory _keyTuple = new bytes32[](2);
203
+ _keyTuple[0] = bytes32(uint256(uint160(owner)));
204
+ _keyTuple[1] = bytes32(uint256(uint160(operator)));
205
+
206
+ return _keyTuple;
207
+ }
208
+ }
209
+
210
+ /**
211
+ * @notice Cast a value to a bool.
212
+ * @dev Boolean values are encoded as uint8 (1 = true, 0 = false), but Solidity doesn't allow casting between uint8 and bool.
213
+ * @param value The uint8 value to convert.
214
+ * @return result The boolean value.
215
+ */
216
+ function _toBool(uint8 value) pure returns (bool result) {
217
+ assembly {
218
+ result := value
219
+ }
220
+ }
@@ -0,0 +1,196 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity >=0.8.24;
3
+
4
+ /* Autogenerated file. Do not edit manually. */
5
+
6
+ // Import store internals
7
+ import { IStore } from "@latticexyz/store/src/IStore.sol";
8
+ import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol";
9
+ import { StoreCore } from "@latticexyz/store/src/StoreCore.sol";
10
+ import { Bytes } from "@latticexyz/store/src/Bytes.sol";
11
+ import { Memory } from "@latticexyz/store/src/Memory.sol";
12
+ import { SliceLib } from "@latticexyz/store/src/Slice.sol";
13
+ import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol";
14
+ import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol";
15
+ import { Schema } from "@latticexyz/store/src/Schema.sol";
16
+ import { EncodedLengths, EncodedLengthsLib } from "@latticexyz/store/src/EncodedLengths.sol";
17
+ import { ResourceId } from "@latticexyz/store/src/ResourceId.sol";
18
+
19
+ library Owners {
20
+ FieldLayout constant _fieldLayout =
21
+ FieldLayout.wrap(0x0014010014000000000000000000000000000000000000000000000000000000);
22
+
23
+ // Hex-encoded key schema of (uint256)
24
+ Schema constant _keySchema = Schema.wrap(0x002001001f000000000000000000000000000000000000000000000000000000);
25
+ // Hex-encoded value schema of (address)
26
+ Schema constant _valueSchema = Schema.wrap(0x0014010061000000000000000000000000000000000000000000000000000000);
27
+
28
+ /**
29
+ * @notice Get the table's key field names.
30
+ * @return keyNames An array of strings with the names of key fields.
31
+ */
32
+ function getKeyNames() internal pure returns (string[] memory keyNames) {
33
+ keyNames = new string[](1);
34
+ keyNames[0] = "tokenId";
35
+ }
36
+
37
+ /**
38
+ * @notice Get the table's value field names.
39
+ * @return fieldNames An array of strings with the names of value fields.
40
+ */
41
+ function getFieldNames() internal pure returns (string[] memory fieldNames) {
42
+ fieldNames = new string[](1);
43
+ fieldNames[0] = "owner";
44
+ }
45
+
46
+ /**
47
+ * @notice Register the table with its config.
48
+ */
49
+ function register(ResourceId _tableId) internal {
50
+ StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
51
+ }
52
+
53
+ /**
54
+ * @notice Register the table with its config.
55
+ */
56
+ function _register(ResourceId _tableId) internal {
57
+ StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
58
+ }
59
+
60
+ /**
61
+ * @notice Get owner.
62
+ */
63
+ function getOwner(ResourceId _tableId, uint256 tokenId) internal view returns (address owner) {
64
+ bytes32[] memory _keyTuple = new bytes32[](1);
65
+ _keyTuple[0] = bytes32(uint256(tokenId));
66
+
67
+ bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout);
68
+ return (address(bytes20(_blob)));
69
+ }
70
+
71
+ /**
72
+ * @notice Get owner.
73
+ */
74
+ function _getOwner(ResourceId _tableId, uint256 tokenId) internal view returns (address owner) {
75
+ bytes32[] memory _keyTuple = new bytes32[](1);
76
+ _keyTuple[0] = bytes32(uint256(tokenId));
77
+
78
+ bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout);
79
+ return (address(bytes20(_blob)));
80
+ }
81
+
82
+ /**
83
+ * @notice Get owner.
84
+ */
85
+ function get(ResourceId _tableId, uint256 tokenId) internal view returns (address owner) {
86
+ bytes32[] memory _keyTuple = new bytes32[](1);
87
+ _keyTuple[0] = bytes32(uint256(tokenId));
88
+
89
+ bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout);
90
+ return (address(bytes20(_blob)));
91
+ }
92
+
93
+ /**
94
+ * @notice Get owner.
95
+ */
96
+ function _get(ResourceId _tableId, uint256 tokenId) internal view returns (address owner) {
97
+ bytes32[] memory _keyTuple = new bytes32[](1);
98
+ _keyTuple[0] = bytes32(uint256(tokenId));
99
+
100
+ bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout);
101
+ return (address(bytes20(_blob)));
102
+ }
103
+
104
+ /**
105
+ * @notice Set owner.
106
+ */
107
+ function setOwner(ResourceId _tableId, uint256 tokenId, address owner) internal {
108
+ bytes32[] memory _keyTuple = new bytes32[](1);
109
+ _keyTuple[0] = bytes32(uint256(tokenId));
110
+
111
+ StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((owner)), _fieldLayout);
112
+ }
113
+
114
+ /**
115
+ * @notice Set owner.
116
+ */
117
+ function _setOwner(ResourceId _tableId, uint256 tokenId, address owner) internal {
118
+ bytes32[] memory _keyTuple = new bytes32[](1);
119
+ _keyTuple[0] = bytes32(uint256(tokenId));
120
+
121
+ StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((owner)), _fieldLayout);
122
+ }
123
+
124
+ /**
125
+ * @notice Set owner.
126
+ */
127
+ function set(ResourceId _tableId, uint256 tokenId, address owner) internal {
128
+ bytes32[] memory _keyTuple = new bytes32[](1);
129
+ _keyTuple[0] = bytes32(uint256(tokenId));
130
+
131
+ StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((owner)), _fieldLayout);
132
+ }
133
+
134
+ /**
135
+ * @notice Set owner.
136
+ */
137
+ function _set(ResourceId _tableId, uint256 tokenId, address owner) internal {
138
+ bytes32[] memory _keyTuple = new bytes32[](1);
139
+ _keyTuple[0] = bytes32(uint256(tokenId));
140
+
141
+ StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((owner)), _fieldLayout);
142
+ }
143
+
144
+ /**
145
+ * @notice Delete all data for given keys.
146
+ */
147
+ function deleteRecord(ResourceId _tableId, uint256 tokenId) internal {
148
+ bytes32[] memory _keyTuple = new bytes32[](1);
149
+ _keyTuple[0] = bytes32(uint256(tokenId));
150
+
151
+ StoreSwitch.deleteRecord(_tableId, _keyTuple);
152
+ }
153
+
154
+ /**
155
+ * @notice Delete all data for given keys.
156
+ */
157
+ function _deleteRecord(ResourceId _tableId, uint256 tokenId) internal {
158
+ bytes32[] memory _keyTuple = new bytes32[](1);
159
+ _keyTuple[0] = bytes32(uint256(tokenId));
160
+
161
+ StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout);
162
+ }
163
+
164
+ /**
165
+ * @notice Tightly pack static (fixed length) data using this table's schema.
166
+ * @return The static data, encoded into a sequence of bytes.
167
+ */
168
+ function encodeStatic(address owner) internal pure returns (bytes memory) {
169
+ return abi.encodePacked(owner);
170
+ }
171
+
172
+ /**
173
+ * @notice Encode all of a record's fields.
174
+ * @return The static (fixed length) data, encoded into a sequence of bytes.
175
+ * @return The lengths of the dynamic fields (packed into a single bytes32 value).
176
+ * @return The dynamic (variable length) data, encoded into a sequence of bytes.
177
+ */
178
+ function encode(address owner) internal pure returns (bytes memory, EncodedLengths, bytes memory) {
179
+ bytes memory _staticData = encodeStatic(owner);
180
+
181
+ EncodedLengths _encodedLengths;
182
+ bytes memory _dynamicData;
183
+
184
+ return (_staticData, _encodedLengths, _dynamicData);
185
+ }
186
+
187
+ /**
188
+ * @notice Encode keys as a bytes32 array using this table's field layout.
189
+ */
190
+ function encodeKeyTuple(uint256 tokenId) internal pure returns (bytes32[] memory) {
191
+ bytes32[] memory _keyTuple = new bytes32[](1);
192
+ _keyTuple[0] = bytes32(uint256(tokenId));
193
+
194
+ return _keyTuple;
195
+ }
196
+ }