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