@latticexyz/world-modules 2.0.12-main-ecc8f658 → 2.0.12-type-resolutions-effc7ab1

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 (91) hide show
  1. package/cache/solidity-files-cache.json +1 -0
  2. package/dist/mud.config.d.ts +0 -2
  3. package/package.json +9 -9
  4. package/src/index.sol +0 -25
  5. package/src/interfaces/IBaseWorld.sol +0 -16
  6. package/src/interfaces/IERC20System.sol +0 -33
  7. package/src/interfaces/IERC721System.sol +0 -43
  8. package/src/interfaces/IPuppetFactorySystem.sol +0 -15
  9. package/src/interfaces/IUniqueEntitySystem.sol +0 -13
  10. package/src/interfaces/IUnstable_CallWithSignatureSystem.sol +0 -20
  11. package/src/modules/callwithsignature/ECDSA.sol +0 -174
  12. package/src/modules/callwithsignature/IERC1271.sol +0 -17
  13. package/src/modules/callwithsignature/IUnstable_CallWithSignatureErrors.sol +0 -9
  14. package/src/modules/callwithsignature/SignatureChecker.sol +0 -50
  15. package/src/modules/callwithsignature/Unstable_CallWithSignatureModule.sol +0 -48
  16. package/src/modules/callwithsignature/Unstable_CallWithSignatureSystem.sol +0 -36
  17. package/src/modules/callwithsignature/constants.sol +0 -10
  18. package/src/modules/callwithsignature/getSignedMessageHash.sol +0 -54
  19. package/src/modules/callwithsignature/tables/CallWithSignatureNonces.sol +0 -199
  20. package/src/modules/callwithsignature/validateCallWithSignature.sol +0 -31
  21. package/src/modules/erc20-puppet/ERC20Module.sol +0 -88
  22. package/src/modules/erc20-puppet/ERC20System.sol +0 -286
  23. package/src/modules/erc20-puppet/IERC20.sol +0 -94
  24. package/src/modules/erc20-puppet/IERC20Errors.sol +0 -49
  25. package/src/modules/erc20-puppet/IERC20Events.sol +0 -18
  26. package/src/modules/erc20-puppet/IERC20Mintable.sol +0 -25
  27. package/src/modules/erc20-puppet/constants.sol +0 -20
  28. package/src/modules/erc20-puppet/registerERC20.sol +0 -35
  29. package/src/modules/erc20-puppet/tables/Allowances.sol +0 -208
  30. package/src/modules/erc20-puppet/tables/ERC20Metadata.sol +0 -604
  31. package/src/modules/erc20-puppet/tables/ERC20Registry.sol +0 -199
  32. package/src/modules/erc20-puppet/tables/TotalSupply.sol +0 -184
  33. package/src/modules/erc20-puppet/utils.sol +0 -30
  34. package/src/modules/erc721-puppet/ERC721Module.sol +0 -95
  35. package/src/modules/erc721-puppet/ERC721System.sol +0 -531
  36. package/src/modules/erc721-puppet/IERC721.sol +0 -120
  37. package/src/modules/erc721-puppet/IERC721Errors.sol +0 -61
  38. package/src/modules/erc721-puppet/IERC721Events.sol +0 -23
  39. package/src/modules/erc721-puppet/IERC721Metadata.sol +0 -27
  40. package/src/modules/erc721-puppet/IERC721Mintable.sol +0 -53
  41. package/src/modules/erc721-puppet/IERC721Receiver.sol +0 -28
  42. package/src/modules/erc721-puppet/constants.sol +0 -23
  43. package/src/modules/erc721-puppet/libraries/LibString.sol +0 -77
  44. package/src/modules/erc721-puppet/registerERC721.sol +0 -37
  45. package/src/modules/erc721-puppet/tables/ERC721Metadata.sol +0 -703
  46. package/src/modules/erc721-puppet/tables/ERC721Registry.sol +0 -199
  47. package/src/modules/erc721-puppet/tables/OperatorApproval.sol +0 -220
  48. package/src/modules/erc721-puppet/tables/Owners.sol +0 -196
  49. package/src/modules/erc721-puppet/tables/TokenApproval.sol +0 -196
  50. package/src/modules/erc721-puppet/tables/TokenURI.sol +0 -450
  51. package/src/modules/erc721-puppet/utils.sol +0 -38
  52. package/src/modules/keysintable/KeysInTableHook.sol +0 -141
  53. package/src/modules/keysintable/KeysInTableModule.sol +0 -110
  54. package/src/modules/keysintable/constants.sol +0 -7
  55. package/src/modules/keysintable/getKeysInTable.sol +0 -81
  56. package/src/modules/keysintable/hasKey.sol +0 -28
  57. package/src/modules/keysintable/query.sol +0 -200
  58. package/src/modules/keysintable/tables/KeysInTable.sol +0 -1638
  59. package/src/modules/keysintable/tables/UsedKeysIndex.sol +0 -414
  60. package/src/modules/keyswithvalue/KeysWithValueHook.sol +0 -158
  61. package/src/modules/keyswithvalue/KeysWithValueModule.sol +0 -103
  62. package/src/modules/keyswithvalue/constants.sol +0 -7
  63. package/src/modules/keyswithvalue/getKeysWithValue.sol +0 -58
  64. package/src/modules/keyswithvalue/getTargetTableId.sol +0 -32
  65. package/src/modules/keyswithvalue/tables/KeysWithValue.sol +0 -668
  66. package/src/modules/puppet/Puppet.sol +0 -80
  67. package/src/modules/puppet/PuppetDelegationControl.sol +0 -17
  68. package/src/modules/puppet/PuppetFactorySystem.sol +0 -25
  69. package/src/modules/puppet/PuppetMaster.sol +0 -19
  70. package/src/modules/puppet/PuppetModule.sol +0 -64
  71. package/src/modules/puppet/constants.sol +0 -23
  72. package/src/modules/puppet/createPuppet.sol +0 -24
  73. package/src/modules/puppet/tables/PuppetRegistry.sol +0 -199
  74. package/src/modules/puppet/utils.sol +0 -10
  75. package/src/modules/std-delegations/CallboundDelegationControl.sol +0 -64
  76. package/src/modules/std-delegations/StandardDelegationsModule.sol +0 -55
  77. package/src/modules/std-delegations/SystemboundDelegationControl.sol +0 -54
  78. package/src/modules/std-delegations/TimeboundDelegationControl.sol +0 -27
  79. package/src/modules/std-delegations/constants.sol +0 -21
  80. package/src/modules/std-delegations/tables/CallboundDelegations.sol +0 -287
  81. package/src/modules/std-delegations/tables/SystemboundDelegations.sol +0 -256
  82. package/src/modules/std-delegations/tables/TimeboundDelegations.sol +0 -211
  83. package/src/modules/tokens/tables/Balances.sol +0 -196
  84. package/src/modules/uniqueentity/UniqueEntityModule.sol +0 -73
  85. package/src/modules/uniqueentity/UniqueEntitySystem.sol +0 -18
  86. package/src/modules/uniqueentity/constants.sol +0 -13
  87. package/src/modules/uniqueentity/getUniqueEntity.sol +0 -26
  88. package/src/modules/uniqueentity/tables/UniqueEntity.sol +0 -238
  89. package/src/modules/utils/ArrayLib.sol +0 -55
  90. package/src/utils/AccessControlLib.sol +0 -55
  91. package/src/utils/SystemSwitch.sol +0 -80
@@ -1,604 +0,0 @@
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
- struct ERC20MetadataData {
20
- uint8 decimals;
21
- string name;
22
- string symbol;
23
- }
24
-
25
- library ERC20Metadata {
26
- FieldLayout constant _fieldLayout =
27
- FieldLayout.wrap(0x0001010201000000000000000000000000000000000000000000000000000000);
28
-
29
- // Hex-encoded key schema of ()
30
- Schema constant _keySchema = Schema.wrap(0x0000000000000000000000000000000000000000000000000000000000000000);
31
- // Hex-encoded value schema of (uint8, string, string)
32
- Schema constant _valueSchema = Schema.wrap(0x0001010200c5c500000000000000000000000000000000000000000000000000);
33
-
34
- /**
35
- * @notice Get the table's key field names.
36
- * @return keyNames An array of strings with the names of key fields.
37
- */
38
- function getKeyNames() internal pure returns (string[] memory keyNames) {
39
- keyNames = new string[](0);
40
- }
41
-
42
- /**
43
- * @notice Get the table's value field names.
44
- * @return fieldNames An array of strings with the names of value fields.
45
- */
46
- function getFieldNames() internal pure returns (string[] memory fieldNames) {
47
- fieldNames = new string[](3);
48
- fieldNames[0] = "decimals";
49
- fieldNames[1] = "name";
50
- fieldNames[2] = "symbol";
51
- }
52
-
53
- /**
54
- * @notice Register the table with its config.
55
- */
56
- function register(ResourceId _tableId) internal {
57
- StoreSwitch.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
58
- }
59
-
60
- /**
61
- * @notice Register the table with its config.
62
- */
63
- function _register(ResourceId _tableId) internal {
64
- StoreCore.registerTable(_tableId, _fieldLayout, _keySchema, _valueSchema, getKeyNames(), getFieldNames());
65
- }
66
-
67
- /**
68
- * @notice Get decimals.
69
- */
70
- function getDecimals(ResourceId _tableId) internal view returns (uint8 decimals) {
71
- bytes32[] memory _keyTuple = new bytes32[](0);
72
-
73
- bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout);
74
- return (uint8(bytes1(_blob)));
75
- }
76
-
77
- /**
78
- * @notice Get decimals.
79
- */
80
- function _getDecimals(ResourceId _tableId) internal view returns (uint8 decimals) {
81
- bytes32[] memory _keyTuple = new bytes32[](0);
82
-
83
- bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout);
84
- return (uint8(bytes1(_blob)));
85
- }
86
-
87
- /**
88
- * @notice Set decimals.
89
- */
90
- function setDecimals(ResourceId _tableId, uint8 decimals) internal {
91
- bytes32[] memory _keyTuple = new bytes32[](0);
92
-
93
- StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((decimals)), _fieldLayout);
94
- }
95
-
96
- /**
97
- * @notice Set decimals.
98
- */
99
- function _setDecimals(ResourceId _tableId, uint8 decimals) internal {
100
- bytes32[] memory _keyTuple = new bytes32[](0);
101
-
102
- StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((decimals)), _fieldLayout);
103
- }
104
-
105
- /**
106
- * @notice Get name.
107
- */
108
- function getName(ResourceId _tableId) internal view returns (string memory name) {
109
- bytes32[] memory _keyTuple = new bytes32[](0);
110
-
111
- bytes memory _blob = StoreSwitch.getDynamicField(_tableId, _keyTuple, 0);
112
- return (string(_blob));
113
- }
114
-
115
- /**
116
- * @notice Get name.
117
- */
118
- function _getName(ResourceId _tableId) internal view returns (string memory name) {
119
- bytes32[] memory _keyTuple = new bytes32[](0);
120
-
121
- bytes memory _blob = StoreCore.getDynamicField(_tableId, _keyTuple, 0);
122
- return (string(_blob));
123
- }
124
-
125
- /**
126
- * @notice Set name.
127
- */
128
- function setName(ResourceId _tableId, string memory name) internal {
129
- bytes32[] memory _keyTuple = new bytes32[](0);
130
-
131
- StoreSwitch.setDynamicField(_tableId, _keyTuple, 0, bytes((name)));
132
- }
133
-
134
- /**
135
- * @notice Set name.
136
- */
137
- function _setName(ResourceId _tableId, string memory name) internal {
138
- bytes32[] memory _keyTuple = new bytes32[](0);
139
-
140
- StoreCore.setDynamicField(_tableId, _keyTuple, 0, bytes((name)));
141
- }
142
-
143
- /**
144
- * @notice Get the length of name.
145
- */
146
- function lengthName(ResourceId _tableId) internal view returns (uint256) {
147
- bytes32[] memory _keyTuple = new bytes32[](0);
148
-
149
- uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 0);
150
- unchecked {
151
- return _byteLength / 1;
152
- }
153
- }
154
-
155
- /**
156
- * @notice Get the length of name.
157
- */
158
- function _lengthName(ResourceId _tableId) internal view returns (uint256) {
159
- bytes32[] memory _keyTuple = new bytes32[](0);
160
-
161
- uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 0);
162
- unchecked {
163
- return _byteLength / 1;
164
- }
165
- }
166
-
167
- /**
168
- * @notice Get an item of name.
169
- * @dev Reverts with Store_IndexOutOfBounds if `_index` is out of bounds for the array.
170
- */
171
- function getItemName(ResourceId _tableId, uint256 _index) internal view returns (string memory) {
172
- bytes32[] memory _keyTuple = new bytes32[](0);
173
-
174
- unchecked {
175
- bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 1, (_index + 1) * 1);
176
- return (string(_blob));
177
- }
178
- }
179
-
180
- /**
181
- * @notice Get an item of name.
182
- * @dev Reverts with Store_IndexOutOfBounds if `_index` is out of bounds for the array.
183
- */
184
- function _getItemName(ResourceId _tableId, uint256 _index) internal view returns (string memory) {
185
- bytes32[] memory _keyTuple = new bytes32[](0);
186
-
187
- unchecked {
188
- bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 1, (_index + 1) * 1);
189
- return (string(_blob));
190
- }
191
- }
192
-
193
- /**
194
- * @notice Push a slice to name.
195
- */
196
- function pushName(ResourceId _tableId, string memory _slice) internal {
197
- bytes32[] memory _keyTuple = new bytes32[](0);
198
-
199
- StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 0, bytes((_slice)));
200
- }
201
-
202
- /**
203
- * @notice Push a slice to name.
204
- */
205
- function _pushName(ResourceId _tableId, string memory _slice) internal {
206
- bytes32[] memory _keyTuple = new bytes32[](0);
207
-
208
- StoreCore.pushToDynamicField(_tableId, _keyTuple, 0, bytes((_slice)));
209
- }
210
-
211
- /**
212
- * @notice Pop a slice from name.
213
- */
214
- function popName(ResourceId _tableId) internal {
215
- bytes32[] memory _keyTuple = new bytes32[](0);
216
-
217
- StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 0, 1);
218
- }
219
-
220
- /**
221
- * @notice Pop a slice from name.
222
- */
223
- function _popName(ResourceId _tableId) internal {
224
- bytes32[] memory _keyTuple = new bytes32[](0);
225
-
226
- StoreCore.popFromDynamicField(_tableId, _keyTuple, 0, 1);
227
- }
228
-
229
- /**
230
- * @notice Update a slice of name at `_index`.
231
- */
232
- function updateName(ResourceId _tableId, uint256 _index, string memory _slice) internal {
233
- bytes32[] memory _keyTuple = new bytes32[](0);
234
-
235
- unchecked {
236
- bytes memory _encoded = bytes((_slice));
237
- StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 1), uint40(_encoded.length), _encoded);
238
- }
239
- }
240
-
241
- /**
242
- * @notice Update a slice of name at `_index`.
243
- */
244
- function _updateName(ResourceId _tableId, uint256 _index, string memory _slice) internal {
245
- bytes32[] memory _keyTuple = new bytes32[](0);
246
-
247
- unchecked {
248
- bytes memory _encoded = bytes((_slice));
249
- StoreCore.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 1), uint40(_encoded.length), _encoded);
250
- }
251
- }
252
-
253
- /**
254
- * @notice Get symbol.
255
- */
256
- function getSymbol(ResourceId _tableId) internal view returns (string memory symbol) {
257
- bytes32[] memory _keyTuple = new bytes32[](0);
258
-
259
- bytes memory _blob = StoreSwitch.getDynamicField(_tableId, _keyTuple, 1);
260
- return (string(_blob));
261
- }
262
-
263
- /**
264
- * @notice Get symbol.
265
- */
266
- function _getSymbol(ResourceId _tableId) internal view returns (string memory symbol) {
267
- bytes32[] memory _keyTuple = new bytes32[](0);
268
-
269
- bytes memory _blob = StoreCore.getDynamicField(_tableId, _keyTuple, 1);
270
- return (string(_blob));
271
- }
272
-
273
- /**
274
- * @notice Set symbol.
275
- */
276
- function setSymbol(ResourceId _tableId, string memory symbol) internal {
277
- bytes32[] memory _keyTuple = new bytes32[](0);
278
-
279
- StoreSwitch.setDynamicField(_tableId, _keyTuple, 1, bytes((symbol)));
280
- }
281
-
282
- /**
283
- * @notice Set symbol.
284
- */
285
- function _setSymbol(ResourceId _tableId, string memory symbol) internal {
286
- bytes32[] memory _keyTuple = new bytes32[](0);
287
-
288
- StoreCore.setDynamicField(_tableId, _keyTuple, 1, bytes((symbol)));
289
- }
290
-
291
- /**
292
- * @notice Get the length of symbol.
293
- */
294
- function lengthSymbol(ResourceId _tableId) internal view returns (uint256) {
295
- bytes32[] memory _keyTuple = new bytes32[](0);
296
-
297
- uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 1);
298
- unchecked {
299
- return _byteLength / 1;
300
- }
301
- }
302
-
303
- /**
304
- * @notice Get the length of symbol.
305
- */
306
- function _lengthSymbol(ResourceId _tableId) internal view returns (uint256) {
307
- bytes32[] memory _keyTuple = new bytes32[](0);
308
-
309
- uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 1);
310
- unchecked {
311
- return _byteLength / 1;
312
- }
313
- }
314
-
315
- /**
316
- * @notice Get an item of symbol.
317
- * @dev Reverts with Store_IndexOutOfBounds if `_index` is out of bounds for the array.
318
- */
319
- function getItemSymbol(ResourceId _tableId, uint256 _index) internal view returns (string memory) {
320
- bytes32[] memory _keyTuple = new bytes32[](0);
321
-
322
- unchecked {
323
- bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 1, _index * 1, (_index + 1) * 1);
324
- return (string(_blob));
325
- }
326
- }
327
-
328
- /**
329
- * @notice Get an item of symbol.
330
- * @dev Reverts with Store_IndexOutOfBounds if `_index` is out of bounds for the array.
331
- */
332
- function _getItemSymbol(ResourceId _tableId, uint256 _index) internal view returns (string memory) {
333
- bytes32[] memory _keyTuple = new bytes32[](0);
334
-
335
- unchecked {
336
- bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 1, _index * 1, (_index + 1) * 1);
337
- return (string(_blob));
338
- }
339
- }
340
-
341
- /**
342
- * @notice Push a slice to symbol.
343
- */
344
- function pushSymbol(ResourceId _tableId, string memory _slice) internal {
345
- bytes32[] memory _keyTuple = new bytes32[](0);
346
-
347
- StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 1, bytes((_slice)));
348
- }
349
-
350
- /**
351
- * @notice Push a slice to symbol.
352
- */
353
- function _pushSymbol(ResourceId _tableId, string memory _slice) internal {
354
- bytes32[] memory _keyTuple = new bytes32[](0);
355
-
356
- StoreCore.pushToDynamicField(_tableId, _keyTuple, 1, bytes((_slice)));
357
- }
358
-
359
- /**
360
- * @notice Pop a slice from symbol.
361
- */
362
- function popSymbol(ResourceId _tableId) internal {
363
- bytes32[] memory _keyTuple = new bytes32[](0);
364
-
365
- StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 1, 1);
366
- }
367
-
368
- /**
369
- * @notice Pop a slice from symbol.
370
- */
371
- function _popSymbol(ResourceId _tableId) internal {
372
- bytes32[] memory _keyTuple = new bytes32[](0);
373
-
374
- StoreCore.popFromDynamicField(_tableId, _keyTuple, 1, 1);
375
- }
376
-
377
- /**
378
- * @notice Update a slice of symbol at `_index`.
379
- */
380
- function updateSymbol(ResourceId _tableId, uint256 _index, string memory _slice) internal {
381
- bytes32[] memory _keyTuple = new bytes32[](0);
382
-
383
- unchecked {
384
- bytes memory _encoded = bytes((_slice));
385
- StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 1, uint40(_index * 1), uint40(_encoded.length), _encoded);
386
- }
387
- }
388
-
389
- /**
390
- * @notice Update a slice of symbol at `_index`.
391
- */
392
- function _updateSymbol(ResourceId _tableId, uint256 _index, string memory _slice) internal {
393
- bytes32[] memory _keyTuple = new bytes32[](0);
394
-
395
- unchecked {
396
- bytes memory _encoded = bytes((_slice));
397
- StoreCore.spliceDynamicData(_tableId, _keyTuple, 1, uint40(_index * 1), uint40(_encoded.length), _encoded);
398
- }
399
- }
400
-
401
- /**
402
- * @notice Get the full data.
403
- */
404
- function get(ResourceId _tableId) internal view returns (ERC20MetadataData memory _table) {
405
- bytes32[] memory _keyTuple = new bytes32[](0);
406
-
407
- (bytes memory _staticData, EncodedLengths _encodedLengths, bytes memory _dynamicData) = StoreSwitch.getRecord(
408
- _tableId,
409
- _keyTuple,
410
- _fieldLayout
411
- );
412
- return decode(_staticData, _encodedLengths, _dynamicData);
413
- }
414
-
415
- /**
416
- * @notice Get the full data.
417
- */
418
- function _get(ResourceId _tableId) internal view returns (ERC20MetadataData memory _table) {
419
- bytes32[] memory _keyTuple = new bytes32[](0);
420
-
421
- (bytes memory _staticData, EncodedLengths _encodedLengths, bytes memory _dynamicData) = StoreCore.getRecord(
422
- _tableId,
423
- _keyTuple,
424
- _fieldLayout
425
- );
426
- return decode(_staticData, _encodedLengths, _dynamicData);
427
- }
428
-
429
- /**
430
- * @notice Set the full data using individual values.
431
- */
432
- function set(ResourceId _tableId, uint8 decimals, string memory name, string memory symbol) internal {
433
- bytes memory _staticData = encodeStatic(decimals);
434
-
435
- EncodedLengths _encodedLengths = encodeLengths(name, symbol);
436
- bytes memory _dynamicData = encodeDynamic(name, symbol);
437
-
438
- bytes32[] memory _keyTuple = new bytes32[](0);
439
-
440
- StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData);
441
- }
442
-
443
- /**
444
- * @notice Set the full data using individual values.
445
- */
446
- function _set(ResourceId _tableId, uint8 decimals, string memory name, string memory symbol) internal {
447
- bytes memory _staticData = encodeStatic(decimals);
448
-
449
- EncodedLengths _encodedLengths = encodeLengths(name, symbol);
450
- bytes memory _dynamicData = encodeDynamic(name, symbol);
451
-
452
- bytes32[] memory _keyTuple = new bytes32[](0);
453
-
454
- StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout);
455
- }
456
-
457
- /**
458
- * @notice Set the full data using the data struct.
459
- */
460
- function set(ResourceId _tableId, ERC20MetadataData memory _table) internal {
461
- bytes memory _staticData = encodeStatic(_table.decimals);
462
-
463
- EncodedLengths _encodedLengths = encodeLengths(_table.name, _table.symbol);
464
- bytes memory _dynamicData = encodeDynamic(_table.name, _table.symbol);
465
-
466
- bytes32[] memory _keyTuple = new bytes32[](0);
467
-
468
- StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData);
469
- }
470
-
471
- /**
472
- * @notice Set the full data using the data struct.
473
- */
474
- function _set(ResourceId _tableId, ERC20MetadataData memory _table) internal {
475
- bytes memory _staticData = encodeStatic(_table.decimals);
476
-
477
- EncodedLengths _encodedLengths = encodeLengths(_table.name, _table.symbol);
478
- bytes memory _dynamicData = encodeDynamic(_table.name, _table.symbol);
479
-
480
- bytes32[] memory _keyTuple = new bytes32[](0);
481
-
482
- StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout);
483
- }
484
-
485
- /**
486
- * @notice Decode the tightly packed blob of static data using this table's field layout.
487
- */
488
- function decodeStatic(bytes memory _blob) internal pure returns (uint8 decimals) {
489
- decimals = (uint8(Bytes.getBytes1(_blob, 0)));
490
- }
491
-
492
- /**
493
- * @notice Decode the tightly packed blob of dynamic data using the encoded lengths.
494
- */
495
- function decodeDynamic(
496
- EncodedLengths _encodedLengths,
497
- bytes memory _blob
498
- ) internal pure returns (string memory name, string memory symbol) {
499
- uint256 _start;
500
- uint256 _end;
501
- unchecked {
502
- _end = _encodedLengths.atIndex(0);
503
- }
504
- name = (string(SliceLib.getSubslice(_blob, _start, _end).toBytes()));
505
-
506
- _start = _end;
507
- unchecked {
508
- _end += _encodedLengths.atIndex(1);
509
- }
510
- symbol = (string(SliceLib.getSubslice(_blob, _start, _end).toBytes()));
511
- }
512
-
513
- /**
514
- * @notice Decode the tightly packed blobs using this table's field layout.
515
- * @param _staticData Tightly packed static fields.
516
- * @param _encodedLengths Encoded lengths of dynamic fields.
517
- * @param _dynamicData Tightly packed dynamic fields.
518
- */
519
- function decode(
520
- bytes memory _staticData,
521
- EncodedLengths _encodedLengths,
522
- bytes memory _dynamicData
523
- ) internal pure returns (ERC20MetadataData memory _table) {
524
- (_table.decimals) = decodeStatic(_staticData);
525
-
526
- (_table.name, _table.symbol) = decodeDynamic(_encodedLengths, _dynamicData);
527
- }
528
-
529
- /**
530
- * @notice Delete all data for given keys.
531
- */
532
- function deleteRecord(ResourceId _tableId) internal {
533
- bytes32[] memory _keyTuple = new bytes32[](0);
534
-
535
- StoreSwitch.deleteRecord(_tableId, _keyTuple);
536
- }
537
-
538
- /**
539
- * @notice Delete all data for given keys.
540
- */
541
- function _deleteRecord(ResourceId _tableId) internal {
542
- bytes32[] memory _keyTuple = new bytes32[](0);
543
-
544
- StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout);
545
- }
546
-
547
- /**
548
- * @notice Tightly pack static (fixed length) data using this table's schema.
549
- * @return The static data, encoded into a sequence of bytes.
550
- */
551
- function encodeStatic(uint8 decimals) internal pure returns (bytes memory) {
552
- return abi.encodePacked(decimals);
553
- }
554
-
555
- /**
556
- * @notice Tightly pack dynamic data lengths using this table's schema.
557
- * @return _encodedLengths The lengths of the dynamic fields (packed into a single bytes32 value).
558
- */
559
- function encodeLengths(
560
- string memory name,
561
- string memory symbol
562
- ) internal pure returns (EncodedLengths _encodedLengths) {
563
- // Lengths are effectively checked during copy by 2**40 bytes exceeding gas limits
564
- unchecked {
565
- _encodedLengths = EncodedLengthsLib.pack(bytes(name).length, bytes(symbol).length);
566
- }
567
- }
568
-
569
- /**
570
- * @notice Tightly pack dynamic (variable length) data using this table's schema.
571
- * @return The dynamic data, encoded into a sequence of bytes.
572
- */
573
- function encodeDynamic(string memory name, string memory symbol) internal pure returns (bytes memory) {
574
- return abi.encodePacked(bytes((name)), bytes((symbol)));
575
- }
576
-
577
- /**
578
- * @notice Encode all of a record's fields.
579
- * @return The static (fixed length) data, encoded into a sequence of bytes.
580
- * @return The lengths of the dynamic fields (packed into a single bytes32 value).
581
- * @return The dynamic (variable length) data, encoded into a sequence of bytes.
582
- */
583
- function encode(
584
- uint8 decimals,
585
- string memory name,
586
- string memory symbol
587
- ) internal pure returns (bytes memory, EncodedLengths, bytes memory) {
588
- bytes memory _staticData = encodeStatic(decimals);
589
-
590
- EncodedLengths _encodedLengths = encodeLengths(name, symbol);
591
- bytes memory _dynamicData = encodeDynamic(name, symbol);
592
-
593
- return (_staticData, _encodedLengths, _dynamicData);
594
- }
595
-
596
- /**
597
- * @notice Encode keys as a bytes32 array using this table's field layout.
598
- */
599
- function encodeKeyTuple() internal pure returns (bytes32[] memory) {
600
- bytes32[] memory _keyTuple = new bytes32[](0);
601
-
602
- return _keyTuple;
603
- }
604
- }