@latticexyz/world-modules 2.0.0-main-e20633d4 → 2.0.0-main-071aadb9

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 (113) hide show
  1. package/out/ArrayLib.sol/ArrayLib.json +255 -255
  2. package/out/CallboundDelegationControl.sol/CallboundDelegationControl.json +220 -220
  3. package/out/CallboundDelegations.sol/CallboundDelegations.json +4463 -4463
  4. package/out/DecodeSlice.sol/DecodeSlice.json +3250 -3250
  5. package/out/DelegationControl.sol/DelegationControl.json +98 -98
  6. package/out/EncodeArray.sol/EncodeArray.json +3345 -3345
  7. package/out/FieldLayout.sol/FieldLayoutInstance.json +47 -47
  8. package/out/FieldLayout.sol/FieldLayoutLib.json +47 -47
  9. package/out/Hook.sol/HookInstance.json +13 -13
  10. package/out/Hook.sol/HookLib.json +13 -13
  11. package/out/Hooks.sol/Hooks.json +3186 -3186
  12. package/out/IAccessManagementSystem.sol/IAccessManagementSystem.json +106 -100
  13. package/out/IBalanceTransferSystem.sol/IBalanceTransferSystem.json +98 -92
  14. package/out/IBaseWorld.sol/IBaseWorld.json +79 -79
  15. package/out/IBatchCallSystem.sol/IBatchCallSystem.json +92 -86
  16. package/out/ICoreSystem.sol/ICoreSystem.json +19 -13
  17. package/out/IDelegationControl.sol/IDelegationControl.json +62 -62
  18. package/out/IModule.sol/IModule.json +78 -78
  19. package/out/IModuleInstallationSystem.sol/IModuleInstallationSystem.json +52 -46
  20. package/out/ISystemHook.sol/ISystemHook.json +86 -86
  21. package/out/IUniqueEntitySystem.sol/IUniqueEntitySystem.json +13 -13
  22. package/out/IWorldContextConsumer.sol/IWorldContextConsumer.json +71 -71
  23. package/out/IWorldErrors.sol/IWorldErrors.json +152 -152
  24. package/out/IWorldKernel.sol/IWorldCall.json +154 -154
  25. package/out/IWorldKernel.sol/IWorldKernel.json +154 -154
  26. package/out/IWorldKernel.sol/IWorldModuleInstallation.json +154 -154
  27. package/out/IWorldRegistrationSystem.sol/IWorldRegistrationSystem.json +329 -323
  28. package/out/KeysInTable.sol/KeysInTable.json +18239 -18239
  29. package/out/KeysInTableHook.sol/KeysInTableHook.json +882 -882
  30. package/out/KeysInTableModule.sol/KeysInTableModule.json +564 -564
  31. package/out/KeysWithValue.sol/KeysWithValue.json +6661 -6661
  32. package/out/KeysWithValueHook.sol/KeysWithValueHook.json +1023 -1023
  33. package/out/KeysWithValueModule.sol/KeysWithValueModule.json +450 -450
  34. package/out/Memory.sol/Memory.json +4 -4
  35. package/out/Module.sol/Module.json +88 -88
  36. package/out/ResourceIds.sol/ResourceIds.json +1237 -1231
  37. package/out/Schema.sol/SchemaInstance.json +72 -72
  38. package/out/Schema.sol/SchemaLib.json +72 -72
  39. package/out/SchemaType.sol/SchemaType.json +276 -276
  40. package/out/Slice.sol/SliceInstance.json +4 -4
  41. package/out/Slice.sol/SliceLib.json +4 -4
  42. package/out/StandardDelegationsModule.sol/StandardDelegationsModule.json +330 -330
  43. package/out/Storage.sol/Storage.json +7 -7
  44. package/out/StoreCore.sol/StoreCore.json +101 -101
  45. package/out/StoreCore.sol/StoreCoreInternal.json +101 -101
  46. package/out/StoreHook.sol/StoreHook.json +368 -368
  47. package/out/StoreHooks.sol/StoreHooks.json +6042 -6042
  48. package/out/StoreSwitch.sol/StoreSwitch.json +13 -13
  49. package/out/System.sol/System.json +32 -32
  50. package/out/Tables.sol/Tables.json +10401 -10401
  51. package/out/TightCoder.sol/TightCoder.json +124 -124
  52. package/out/TimeboundDelegationControl.sol/TimeboundDelegationControl.json +124 -124
  53. package/out/TimeboundDelegations.sol/TimeboundDelegations.json +3442 -3442
  54. package/out/UniqueEntity.sol/UniqueEntity.json +2344 -2344
  55. package/out/UniqueEntityModule.sol/UniqueEntityModule.json +351 -351
  56. package/out/UniqueEntitySystem.sol/UniqueEntitySystem.json +98 -98
  57. package/out/UsedKeysIndex.sol/UsedKeysIndex.json +4568 -4562
  58. package/out/WorldContext.sol/WorldContextConsumer.json +376 -376
  59. package/out/WorldContext.sol/WorldContextProvider.json +376 -376
  60. package/out/WorldResourceId.sol/WorldResourceIdInstance.json +476 -476
  61. package/out/WorldResourceId.sol/WorldResourceIdLib.json +476 -476
  62. package/out/constants.sol/LayoutOffsets.json +79 -79
  63. package/out/constants.sol/constants.json +115 -115
  64. package/out/getKeysInTable.sol/getKeysInTable.json +564 -564
  65. package/out/getKeysWithValue.sol/getKeysWithValue.json +264 -264
  66. package/out/getTargetTableId.sol/getTargetTableId.json +163 -163
  67. package/out/getUniqueEntity.sol/getUniqueEntity.json +88 -88
  68. package/out/hasKey.sol/hasKey.json +130 -130
  69. package/out/index.sol/index.json +53 -53
  70. package/out/interfaces/IBaseWorld.sol/IBaseWorld.json +186 -186
  71. package/out/leftMask.sol/leftMask.json +31 -31
  72. package/out/query.sol/query.json +1154 -1154
  73. package/out/revertWithBytes.sol/revertWithBytes.json +15 -15
  74. package/out/src/Bytes.sol/Bytes.json +1338 -1338
  75. package/out/src/FieldLayout.sol/FieldLayoutInstance.json +698 -698
  76. package/out/src/FieldLayout.sol/FieldLayoutLib.json +698 -698
  77. package/out/src/IStore.sol/IStore.json +52 -52
  78. package/out/src/IWorldKernel.sol/IWorldCall.json +154 -154
  79. package/out/src/IWorldKernel.sol/IWorldKernel.json +154 -154
  80. package/out/src/IWorldKernel.sol/IWorldModuleInstallation.json +154 -154
  81. package/out/src/Memory.sol/Memory.json +91 -91
  82. package/out/src/PackedCounter.sol/PackedCounterInstance.json +929 -929
  83. package/out/src/PackedCounter.sol/PackedCounterLib.json +929 -929
  84. package/out/src/ResourceId.sol/ResourceIdInstance.json +116 -116
  85. package/out/src/ResourceId.sol/ResourceIdLib.json +116 -116
  86. package/out/src/Schema.sol/SchemaInstance.json +790 -790
  87. package/out/src/Schema.sol/SchemaLib.json +790 -790
  88. package/out/src/Slice.sol/SliceInstance.json +430 -430
  89. package/out/src/Slice.sol/SliceLib.json +430 -430
  90. package/out/src/StoreCore.sol/StoreCore.json +4473 -4473
  91. package/out/src/StoreCore.sol/StoreCoreInternal.json +4473 -4473
  92. package/out/src/StoreSwitch.sol/StoreSwitch.json +2496 -2496
  93. package/out/src/WorldContext.sol/WorldContextConsumer.json +376 -376
  94. package/out/src/WorldContext.sol/WorldContextProvider.json +376 -376
  95. package/out/src/WorldResourceId.sol/WorldResourceIdInstance.json +476 -476
  96. package/out/src/WorldResourceId.sol/WorldResourceIdLib.json +476 -476
  97. package/out/storeHookTypes.sol/storeHookTypes.json +115 -115
  98. package/out/storeResourceTypes.sol/storeResourceTypes.json +12 -12
  99. package/out/tables/ResourceIds.sol/ResourceIds.json +2889 -2883
  100. package/out/tables/Tables.sol/Tables.json +12187 -12187
  101. package/out/tightcoder/EncodeArray.sol/EncodeArray.json +3345 -3345
  102. package/out/types.sol/types.json +41 -41
  103. package/out/version.sol/version.json +7 -7
  104. package/out/world/src/IERC165.sol/IERC165.json +28 -28
  105. package/out/worldResourceTypes.sol/worldResourceTypes.json +53 -53
  106. package/package.json +8 -8
  107. package/src/interfaces/IBaseWorld.sol +4 -2
  108. package/src/modules/keysintable/tables/KeysInTable.sol +357 -163
  109. package/src/modules/keysintable/tables/UsedKeysIndex.sol +116 -36
  110. package/src/modules/keyswithvalue/tables/KeysWithValue.sol +163 -69
  111. package/src/modules/std-delegations/tables/CallboundDelegations.sol +87 -26
  112. package/src/modules/std-delegations/tables/TimeboundDelegations.sol +87 -26
  113. package/src/modules/uniqueentity/tables/UniqueEntity.sol +87 -26
@@ -25,12 +25,18 @@ FieldLayout constant _fieldLayout = FieldLayout.wrap(
25
25
  );
26
26
 
27
27
  library KeysWithValue {
28
- /** Get the table values' field layout */
28
+ /**
29
+ * @notice Get the table values' field layout.
30
+ * @return _fieldLayout The field layout for the table.
31
+ */
29
32
  function getFieldLayout() internal pure returns (FieldLayout) {
30
33
  return _fieldLayout;
31
34
  }
32
35
 
33
- /** Get the table's key schema */
36
+ /**
37
+ * @notice Get the table's key schema.
38
+ * @return _keySchema The key schema for the table.
39
+ */
34
40
  function getKeySchema() internal pure returns (Schema) {
35
41
  SchemaType[] memory _keySchema = new SchemaType[](1);
36
42
  _keySchema[0] = SchemaType.BYTES32;
@@ -38,7 +44,10 @@ library KeysWithValue {
38
44
  return SchemaLib.encode(_keySchema);
39
45
  }
40
46
 
41
- /** Get the table's value schema */
47
+ /**
48
+ * @notice Get the table's value schema.
49
+ * @return _valueSchema The value schema for the table.
50
+ */
42
51
  function getValueSchema() internal pure returns (Schema) {
43
52
  SchemaType[] memory _valueSchema = new SchemaType[](1);
44
53
  _valueSchema[0] = SchemaType.BYTES32_ARRAY;
@@ -46,34 +55,48 @@ library KeysWithValue {
46
55
  return SchemaLib.encode(_valueSchema);
47
56
  }
48
57
 
49
- /** Get the table's key names */
58
+ /**
59
+ * @notice Get the table's key field names.
60
+ * @return keyNames An array of strings with the names of key fields.
61
+ */
50
62
  function getKeyNames() internal pure returns (string[] memory keyNames) {
51
63
  keyNames = new string[](1);
52
64
  keyNames[0] = "valueHash";
53
65
  }
54
66
 
55
- /** Get the table's field names */
67
+ /**
68
+ * @notice Get the table's value field names.
69
+ * @return fieldNames An array of strings with the names of value fields.
70
+ */
56
71
  function getFieldNames() internal pure returns (string[] memory fieldNames) {
57
72
  fieldNames = new string[](1);
58
73
  fieldNames[0] = "keysWithValue";
59
74
  }
60
75
 
61
- /** Register the table with its config */
76
+ /**
77
+ * @notice Register the table with its config.
78
+ */
62
79
  function register(ResourceId _tableId) internal {
63
80
  StoreSwitch.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
64
81
  }
65
82
 
66
- /** Register the table with its config */
83
+ /**
84
+ * @notice Register the table with its config.
85
+ */
67
86
  function _register(ResourceId _tableId) internal {
68
87
  StoreCore.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
69
88
  }
70
89
 
71
- /** Register the table with its config (using the specified store) */
90
+ /**
91
+ * @notice Register the table with its config (using the specified store).
92
+ */
72
93
  function register(IStore _store, ResourceId _tableId) internal {
73
94
  _store.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames());
74
95
  }
75
96
 
76
- /** Get keysWithValue */
97
+ /**
98
+ * @notice Get keysWithValue.
99
+ */
77
100
  function getKeysWithValue(
78
101
  ResourceId _tableId,
79
102
  bytes32 valueHash
@@ -85,7 +108,9 @@ library KeysWithValue {
85
108
  return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_bytes32());
86
109
  }
87
110
 
88
- /** Get keysWithValue */
111
+ /**
112
+ * @notice Get keysWithValue.
113
+ */
89
114
  function _getKeysWithValue(
90
115
  ResourceId _tableId,
91
116
  bytes32 valueHash
@@ -97,7 +122,9 @@ library KeysWithValue {
97
122
  return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_bytes32());
98
123
  }
99
124
 
100
- /** Get keysWithValue (using the specified store) */
125
+ /**
126
+ * @notice Get keysWithValue (using the specified store).
127
+ */
101
128
  function getKeysWithValue(
102
129
  IStore _store,
103
130
  ResourceId _tableId,
@@ -110,7 +137,9 @@ library KeysWithValue {
110
137
  return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_bytes32());
111
138
  }
112
139
 
113
- /** Get keysWithValue */
140
+ /**
141
+ * @notice Get keysWithValue.
142
+ */
114
143
  function get(ResourceId _tableId, bytes32 valueHash) internal view returns (bytes32[] memory keysWithValue) {
115
144
  bytes32[] memory _keyTuple = new bytes32[](1);
116
145
  _keyTuple[0] = valueHash;
@@ -119,7 +148,9 @@ library KeysWithValue {
119
148
  return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_bytes32());
120
149
  }
121
150
 
122
- /** Get keysWithValue */
151
+ /**
152
+ * @notice Get keysWithValue.
153
+ */
123
154
  function _get(ResourceId _tableId, bytes32 valueHash) internal view returns (bytes32[] memory keysWithValue) {
124
155
  bytes32[] memory _keyTuple = new bytes32[](1);
125
156
  _keyTuple[0] = valueHash;
@@ -128,7 +159,9 @@ library KeysWithValue {
128
159
  return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_bytes32());
129
160
  }
130
161
 
131
- /** Get keysWithValue (using the specified store) */
162
+ /**
163
+ * @notice Get keysWithValue (using the specified store).
164
+ */
132
165
  function get(
133
166
  IStore _store,
134
167
  ResourceId _tableId,
@@ -141,7 +174,9 @@ library KeysWithValue {
141
174
  return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_bytes32());
142
175
  }
143
176
 
144
- /** Set keysWithValue */
177
+ /**
178
+ * @notice Set keysWithValue.
179
+ */
145
180
  function setKeysWithValue(ResourceId _tableId, bytes32 valueHash, bytes32[] memory keysWithValue) internal {
146
181
  bytes32[] memory _keyTuple = new bytes32[](1);
147
182
  _keyTuple[0] = valueHash;
@@ -149,7 +184,9 @@ library KeysWithValue {
149
184
  StoreSwitch.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((keysWithValue)));
150
185
  }
151
186
 
152
- /** Set keysWithValue */
187
+ /**
188
+ * @notice Set keysWithValue.
189
+ */
153
190
  function _setKeysWithValue(ResourceId _tableId, bytes32 valueHash, bytes32[] memory keysWithValue) internal {
154
191
  bytes32[] memory _keyTuple = new bytes32[](1);
155
192
  _keyTuple[0] = valueHash;
@@ -157,7 +194,9 @@ library KeysWithValue {
157
194
  StoreCore.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((keysWithValue)));
158
195
  }
159
196
 
160
- /** Set keysWithValue (using the specified store) */
197
+ /**
198
+ * @notice Set keysWithValue (using the specified store).
199
+ */
161
200
  function setKeysWithValue(
162
201
  IStore _store,
163
202
  ResourceId _tableId,
@@ -170,7 +209,9 @@ library KeysWithValue {
170
209
  _store.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((keysWithValue)));
171
210
  }
172
211
 
173
- /** Set keysWithValue */
212
+ /**
213
+ * @notice Set keysWithValue.
214
+ */
174
215
  function set(ResourceId _tableId, bytes32 valueHash, bytes32[] memory keysWithValue) internal {
175
216
  bytes32[] memory _keyTuple = new bytes32[](1);
176
217
  _keyTuple[0] = valueHash;
@@ -178,7 +219,9 @@ library KeysWithValue {
178
219
  StoreSwitch.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((keysWithValue)));
179
220
  }
180
221
 
181
- /** Set keysWithValue */
222
+ /**
223
+ * @notice Set keysWithValue.
224
+ */
182
225
  function _set(ResourceId _tableId, bytes32 valueHash, bytes32[] memory keysWithValue) internal {
183
226
  bytes32[] memory _keyTuple = new bytes32[](1);
184
227
  _keyTuple[0] = valueHash;
@@ -186,7 +229,9 @@ library KeysWithValue {
186
229
  StoreCore.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((keysWithValue)));
187
230
  }
188
231
 
189
- /** Set keysWithValue (using the specified store) */
232
+ /**
233
+ * @notice Set keysWithValue (using the specified store).
234
+ */
190
235
  function set(IStore _store, ResourceId _tableId, bytes32 valueHash, bytes32[] memory keysWithValue) internal {
191
236
  bytes32[] memory _keyTuple = new bytes32[](1);
192
237
  _keyTuple[0] = valueHash;
@@ -194,7 +239,9 @@ library KeysWithValue {
194
239
  _store.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((keysWithValue)));
195
240
  }
196
241
 
197
- /** Get the length of keysWithValue */
242
+ /**
243
+ * @notice Get the length of keysWithValue.
244
+ */
198
245
  function lengthKeysWithValue(ResourceId _tableId, bytes32 valueHash) internal view returns (uint256) {
199
246
  bytes32[] memory _keyTuple = new bytes32[](1);
200
247
  _keyTuple[0] = valueHash;
@@ -205,7 +252,9 @@ library KeysWithValue {
205
252
  }
206
253
  }
207
254
 
208
- /** Get the length of keysWithValue */
255
+ /**
256
+ * @notice Get the length of keysWithValue.
257
+ */
209
258
  function _lengthKeysWithValue(ResourceId _tableId, bytes32 valueHash) internal view returns (uint256) {
210
259
  bytes32[] memory _keyTuple = new bytes32[](1);
211
260
  _keyTuple[0] = valueHash;
@@ -216,7 +265,9 @@ library KeysWithValue {
216
265
  }
217
266
  }
218
267
 
219
- /** Get the length of keysWithValue (using the specified store) */
268
+ /**
269
+ * @notice Get the length of keysWithValue (using the specified store).
270
+ */
220
271
  function lengthKeysWithValue(IStore _store, ResourceId _tableId, bytes32 valueHash) internal view returns (uint256) {
221
272
  bytes32[] memory _keyTuple = new bytes32[](1);
222
273
  _keyTuple[0] = valueHash;
@@ -227,7 +278,9 @@ library KeysWithValue {
227
278
  }
228
279
  }
229
280
 
230
- /** Get the length of keysWithValue */
281
+ /**
282
+ * @notice Get the length of keysWithValue.
283
+ */
231
284
  function length(ResourceId _tableId, bytes32 valueHash) internal view returns (uint256) {
232
285
  bytes32[] memory _keyTuple = new bytes32[](1);
233
286
  _keyTuple[0] = valueHash;
@@ -238,7 +291,9 @@ library KeysWithValue {
238
291
  }
239
292
  }
240
293
 
241
- /** Get the length of keysWithValue */
294
+ /**
295
+ * @notice Get the length of keysWithValue.
296
+ */
242
297
  function _length(ResourceId _tableId, bytes32 valueHash) internal view returns (uint256) {
243
298
  bytes32[] memory _keyTuple = new bytes32[](1);
244
299
  _keyTuple[0] = valueHash;
@@ -249,7 +304,9 @@ library KeysWithValue {
249
304
  }
250
305
  }
251
306
 
252
- /** Get the length of keysWithValue (using the specified store) */
307
+ /**
308
+ * @notice Get the length of keysWithValue (using the specified store).
309
+ */
253
310
  function length(IStore _store, ResourceId _tableId, bytes32 valueHash) internal view returns (uint256) {
254
311
  bytes32[] memory _keyTuple = new bytes32[](1);
255
312
  _keyTuple[0] = valueHash;
@@ -261,8 +318,8 @@ library KeysWithValue {
261
318
  }
262
319
 
263
320
  /**
264
- * Get an item of keysWithValue
265
- * (unchecked, returns invalid data if index overflows)
321
+ * @notice Get an item of keysWithValue.
322
+ * @dev Reverts with Store_IndexOutOfBounds if `_index` is out of bounds for the array.
266
323
  */
267
324
  function getItemKeysWithValue(
268
325
  ResourceId _tableId,
@@ -279,8 +336,8 @@ library KeysWithValue {
279
336
  }
280
337
 
281
338
  /**
282
- * Get an item of keysWithValue
283
- * (unchecked, returns invalid data if index overflows)
339
+ * @notice Get an item of keysWithValue.
340
+ * @dev Reverts with Store_IndexOutOfBounds if `_index` is out of bounds for the array.
284
341
  */
285
342
  function _getItemKeysWithValue(
286
343
  ResourceId _tableId,
@@ -297,8 +354,8 @@ library KeysWithValue {
297
354
  }
298
355
 
299
356
  /**
300
- * Get an item of keysWithValue (using the specified store)
301
- * (unchecked, returns invalid data if index overflows)
357
+ * @notice Get an item of keysWithValue (using the specified store).
358
+ * @dev Reverts with Store_IndexOutOfBounds if `_index` is out of bounds for the array.
302
359
  */
303
360
  function getItemKeysWithValue(
304
361
  IStore _store,
@@ -316,8 +373,8 @@ library KeysWithValue {
316
373
  }
317
374
 
318
375
  /**
319
- * Get an item of keysWithValue
320
- * (unchecked, returns invalid data if index overflows)
376
+ * @notice Get an item of keysWithValue.
377
+ * @dev Reverts with Store_IndexOutOfBounds if `_index` is out of bounds for the array.
321
378
  */
322
379
  function getItem(ResourceId _tableId, bytes32 valueHash, uint256 _index) internal view returns (bytes32) {
323
380
  bytes32[] memory _keyTuple = new bytes32[](1);
@@ -330,8 +387,8 @@ library KeysWithValue {
330
387
  }
331
388
 
332
389
  /**
333
- * Get an item of keysWithValue
334
- * (unchecked, returns invalid data if index overflows)
390
+ * @notice Get an item of keysWithValue.
391
+ * @dev Reverts with Store_IndexOutOfBounds if `_index` is out of bounds for the array.
335
392
  */
336
393
  function _getItem(ResourceId _tableId, bytes32 valueHash, uint256 _index) internal view returns (bytes32) {
337
394
  bytes32[] memory _keyTuple = new bytes32[](1);
@@ -344,8 +401,8 @@ library KeysWithValue {
344
401
  }
345
402
 
346
403
  /**
347
- * Get an item of keysWithValue (using the specified store)
348
- * (unchecked, returns invalid data if index overflows)
404
+ * @notice Get an item of keysWithValue (using the specified store).
405
+ * @dev Reverts with Store_IndexOutOfBounds if `_index` is out of bounds for the array.
349
406
  */
350
407
  function getItem(
351
408
  IStore _store,
@@ -362,7 +419,9 @@ library KeysWithValue {
362
419
  }
363
420
  }
364
421
 
365
- /** Push an element to keysWithValue */
422
+ /**
423
+ * @notice Push an element to keysWithValue.
424
+ */
366
425
  function pushKeysWithValue(ResourceId _tableId, bytes32 valueHash, bytes32 _element) internal {
367
426
  bytes32[] memory _keyTuple = new bytes32[](1);
368
427
  _keyTuple[0] = valueHash;
@@ -370,7 +429,9 @@ library KeysWithValue {
370
429
  StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element)));
371
430
  }
372
431
 
373
- /** Push an element to keysWithValue */
432
+ /**
433
+ * @notice Push an element to keysWithValue.
434
+ */
374
435
  function _pushKeysWithValue(ResourceId _tableId, bytes32 valueHash, bytes32 _element) internal {
375
436
  bytes32[] memory _keyTuple = new bytes32[](1);
376
437
  _keyTuple[0] = valueHash;
@@ -378,7 +439,9 @@ library KeysWithValue {
378
439
  StoreCore.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element)));
379
440
  }
380
441
 
381
- /** Push an element to keysWithValue (using the specified store) */
442
+ /**
443
+ * @notice Push an element to keysWithValue (using the specified store).
444
+ */
382
445
  function pushKeysWithValue(IStore _store, ResourceId _tableId, bytes32 valueHash, bytes32 _element) internal {
383
446
  bytes32[] memory _keyTuple = new bytes32[](1);
384
447
  _keyTuple[0] = valueHash;
@@ -386,7 +449,9 @@ library KeysWithValue {
386
449
  _store.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element)));
387
450
  }
388
451
 
389
- /** Push an element to keysWithValue */
452
+ /**
453
+ * @notice Push an element to keysWithValue.
454
+ */
390
455
  function push(ResourceId _tableId, bytes32 valueHash, bytes32 _element) internal {
391
456
  bytes32[] memory _keyTuple = new bytes32[](1);
392
457
  _keyTuple[0] = valueHash;
@@ -394,7 +459,9 @@ library KeysWithValue {
394
459
  StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element)));
395
460
  }
396
461
 
397
- /** Push an element to keysWithValue */
462
+ /**
463
+ * @notice Push an element to keysWithValue.
464
+ */
398
465
  function _push(ResourceId _tableId, bytes32 valueHash, bytes32 _element) internal {
399
466
  bytes32[] memory _keyTuple = new bytes32[](1);
400
467
  _keyTuple[0] = valueHash;
@@ -402,7 +469,9 @@ library KeysWithValue {
402
469
  StoreCore.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element)));
403
470
  }
404
471
 
405
- /** Push an element to keysWithValue (using the specified store) */
472
+ /**
473
+ * @notice Push an element to keysWithValue (using the specified store).
474
+ */
406
475
  function push(IStore _store, ResourceId _tableId, bytes32 valueHash, bytes32 _element) internal {
407
476
  bytes32[] memory _keyTuple = new bytes32[](1);
408
477
  _keyTuple[0] = valueHash;
@@ -410,7 +479,9 @@ library KeysWithValue {
410
479
  _store.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element)));
411
480
  }
412
481
 
413
- /** Pop an element from keysWithValue */
482
+ /**
483
+ * @notice Pop an element from keysWithValue.
484
+ */
414
485
  function popKeysWithValue(ResourceId _tableId, bytes32 valueHash) internal {
415
486
  bytes32[] memory _keyTuple = new bytes32[](1);
416
487
  _keyTuple[0] = valueHash;
@@ -418,7 +489,9 @@ library KeysWithValue {
418
489
  StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 0, 32);
419
490
  }
420
491
 
421
- /** Pop an element from keysWithValue */
492
+ /**
493
+ * @notice Pop an element from keysWithValue.
494
+ */
422
495
  function _popKeysWithValue(ResourceId _tableId, bytes32 valueHash) internal {
423
496
  bytes32[] memory _keyTuple = new bytes32[](1);
424
497
  _keyTuple[0] = valueHash;
@@ -426,7 +499,9 @@ library KeysWithValue {
426
499
  StoreCore.popFromDynamicField(_tableId, _keyTuple, 0, 32);
427
500
  }
428
501
 
429
- /** Pop an element from keysWithValue (using the specified store) */
502
+ /**
503
+ * @notice Pop an element from keysWithValue (using the specified store).
504
+ */
430
505
  function popKeysWithValue(IStore _store, ResourceId _tableId, bytes32 valueHash) internal {
431
506
  bytes32[] memory _keyTuple = new bytes32[](1);
432
507
  _keyTuple[0] = valueHash;
@@ -434,7 +509,9 @@ library KeysWithValue {
434
509
  _store.popFromDynamicField(_tableId, _keyTuple, 0, 32);
435
510
  }
436
511
 
437
- /** Pop an element from keysWithValue */
512
+ /**
513
+ * @notice Pop an element from keysWithValue.
514
+ */
438
515
  function pop(ResourceId _tableId, bytes32 valueHash) internal {
439
516
  bytes32[] memory _keyTuple = new bytes32[](1);
440
517
  _keyTuple[0] = valueHash;
@@ -442,7 +519,9 @@ library KeysWithValue {
442
519
  StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 0, 32);
443
520
  }
444
521
 
445
- /** Pop an element from keysWithValue */
522
+ /**
523
+ * @notice Pop an element from keysWithValue.
524
+ */
446
525
  function _pop(ResourceId _tableId, bytes32 valueHash) internal {
447
526
  bytes32[] memory _keyTuple = new bytes32[](1);
448
527
  _keyTuple[0] = valueHash;
@@ -450,7 +529,9 @@ library KeysWithValue {
450
529
  StoreCore.popFromDynamicField(_tableId, _keyTuple, 0, 32);
451
530
  }
452
531
 
453
- /** Pop an element from keysWithValue (using the specified store) */
532
+ /**
533
+ * @notice Pop an element from keysWithValue (using the specified store).
534
+ */
454
535
  function pop(IStore _store, ResourceId _tableId, bytes32 valueHash) internal {
455
536
  bytes32[] memory _keyTuple = new bytes32[](1);
456
537
  _keyTuple[0] = valueHash;
@@ -459,8 +540,7 @@ library KeysWithValue {
459
540
  }
460
541
 
461
542
  /**
462
- * Update an element of keysWithValue at `_index`
463
- * (checked only to prevent modifying other tables; can corrupt own data if index overflows)
543
+ * @notice Update an element of keysWithValue at `_index`.
464
544
  */
465
545
  function updateKeysWithValue(ResourceId _tableId, bytes32 valueHash, uint256 _index, bytes32 _element) internal {
466
546
  bytes32[] memory _keyTuple = new bytes32[](1);
@@ -473,8 +553,7 @@ library KeysWithValue {
473
553
  }
474
554
 
475
555
  /**
476
- * Update an element of keysWithValue at `_index`
477
- * (checked only to prevent modifying other tables; can corrupt own data if index overflows)
556
+ * @notice Update an element of keysWithValue at `_index`.
478
557
  */
479
558
  function _updateKeysWithValue(ResourceId _tableId, bytes32 valueHash, uint256 _index, bytes32 _element) internal {
480
559
  bytes32[] memory _keyTuple = new bytes32[](1);
@@ -487,8 +566,7 @@ library KeysWithValue {
487
566
  }
488
567
 
489
568
  /**
490
- * Update an element of keysWithValue (using the specified store) at `_index`
491
- * (checked only to prevent modifying other tables; can corrupt own data if index overflows)
569
+ * @notice Update an element of keysWithValue (using the specified store) at `_index`.
492
570
  */
493
571
  function updateKeysWithValue(
494
572
  IStore _store,
@@ -507,8 +585,7 @@ library KeysWithValue {
507
585
  }
508
586
 
509
587
  /**
510
- * Update an element of keysWithValue at `_index`
511
- * (checked only to prevent modifying other tables; can corrupt own data if index overflows)
588
+ * @notice Update an element of keysWithValue at `_index`.
512
589
  */
513
590
  function update(ResourceId _tableId, bytes32 valueHash, uint256 _index, bytes32 _element) internal {
514
591
  bytes32[] memory _keyTuple = new bytes32[](1);
@@ -521,8 +598,7 @@ library KeysWithValue {
521
598
  }
522
599
 
523
600
  /**
524
- * Update an element of keysWithValue at `_index`
525
- * (checked only to prevent modifying other tables; can corrupt own data if index overflows)
601
+ * @notice Update an element of keysWithValue at `_index`.
526
602
  */
527
603
  function _update(ResourceId _tableId, bytes32 valueHash, uint256 _index, bytes32 _element) internal {
528
604
  bytes32[] memory _keyTuple = new bytes32[](1);
@@ -535,8 +611,7 @@ library KeysWithValue {
535
611
  }
536
612
 
537
613
  /**
538
- * Update an element of keysWithValue (using the specified store) at `_index`
539
- * (checked only to prevent modifying other tables; can corrupt own data if index overflows)
614
+ * @notice Update an element of keysWithValue (using the specified store) at `_index`.
540
615
  */
541
616
  function update(IStore _store, ResourceId _tableId, bytes32 valueHash, uint256 _index, bytes32 _element) internal {
542
617
  bytes32[] memory _keyTuple = new bytes32[](1);
@@ -548,7 +623,9 @@ library KeysWithValue {
548
623
  }
549
624
  }
550
625
 
551
- /** Delete all data for given keys */
626
+ /**
627
+ * @notice Delete all data for given keys.
628
+ */
552
629
  function deleteRecord(ResourceId _tableId, bytes32 valueHash) internal {
553
630
  bytes32[] memory _keyTuple = new bytes32[](1);
554
631
  _keyTuple[0] = valueHash;
@@ -556,7 +633,9 @@ library KeysWithValue {
556
633
  StoreSwitch.deleteRecord(_tableId, _keyTuple);
557
634
  }
558
635
 
559
- /** Delete all data for given keys */
636
+ /**
637
+ * @notice Delete all data for given keys.
638
+ */
560
639
  function _deleteRecord(ResourceId _tableId, bytes32 valueHash) internal {
561
640
  bytes32[] memory _keyTuple = new bytes32[](1);
562
641
  _keyTuple[0] = valueHash;
@@ -564,7 +643,9 @@ library KeysWithValue {
564
643
  StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout);
565
644
  }
566
645
 
567
- /** Delete all data for given keys (using the specified store) */
646
+ /**
647
+ * @notice Delete all data for given keys (using the specified store).
648
+ */
568
649
  function deleteRecord(IStore _store, ResourceId _tableId, bytes32 valueHash) internal {
569
650
  bytes32[] memory _keyTuple = new bytes32[](1);
570
651
  _keyTuple[0] = valueHash;
@@ -572,7 +653,10 @@ library KeysWithValue {
572
653
  _store.deleteRecord(_tableId, _keyTuple);
573
654
  }
574
655
 
575
- /** Tightly pack dynamic data using this table's schema */
656
+ /**
657
+ * @notice Tightly pack dynamic data lengths using this table's schema.
658
+ * @return _encodedLengths The lengths of the dynamic fields (packed into a single bytes32 value).
659
+ */
576
660
  function encodeLengths(bytes32[] memory keysWithValue) internal pure returns (PackedCounter _encodedLengths) {
577
661
  // Lengths are effectively checked during copy by 2**40 bytes exceeding gas limits
578
662
  unchecked {
@@ -580,12 +664,20 @@ library KeysWithValue {
580
664
  }
581
665
  }
582
666
 
583
- /** Tightly pack dynamic data using this table's schema */
667
+ /**
668
+ * @notice Tightly pack dynamic (variable length) data using this table's schema.
669
+ * @return The dynamic data, encoded into a sequence of bytes.
670
+ */
584
671
  function encodeDynamic(bytes32[] memory keysWithValue) internal pure returns (bytes memory) {
585
672
  return abi.encodePacked(EncodeArray.encode((keysWithValue)));
586
673
  }
587
674
 
588
- /** Tightly pack full data using this table's field layout */
675
+ /**
676
+ * @notice Encode all of a record's fields.
677
+ * @return The static (fixed length) data, encoded into a sequence of bytes.
678
+ * @return The lengths of the dynamic fields (packed into a single bytes32 value).
679
+ * @return The dyanmic (variable length) data, encoded into a sequence of bytes.
680
+ */
589
681
  function encode(bytes32[] memory keysWithValue) internal pure returns (bytes memory, PackedCounter, bytes memory) {
590
682
  bytes memory _staticData;
591
683
  PackedCounter _encodedLengths = encodeLengths(keysWithValue);
@@ -594,7 +686,9 @@ library KeysWithValue {
594
686
  return (_staticData, _encodedLengths, _dynamicData);
595
687
  }
596
688
 
597
- /** Encode keys as a bytes32 array using this table's field layout */
689
+ /**
690
+ * @notice Encode keys as a bytes32 array using this table's field layout.
691
+ */
598
692
  function encodeKeyTuple(bytes32 valueHash) internal pure returns (bytes32[] memory) {
599
693
  bytes32[] memory _keyTuple = new bytes32[](1);
600
694
  _keyTuple[0] = valueHash;