@lukso/lsp-smart-contracts 0.10.1 → 0.10.3
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/README.md +0 -1
- package/artifacts/Create2Factory.json +2 -2
- package/artifacts/LSP0ERC725Account.json +3 -3
- package/artifacts/LSP0ERC725AccountInit.json +3 -3
- package/artifacts/LSP11BasicSocialRecovery.json +2 -2
- package/artifacts/LSP11BasicSocialRecoveryInit.json +2 -2
- package/artifacts/LSP16UniversalFactory.json +2 -2
- package/artifacts/LSP1UniversalReceiverDelegateUP.json +2 -2
- package/artifacts/LSP1UniversalReceiverDelegateVault.json +2 -2
- package/artifacts/LSP6KeyManager.json +2 -2
- package/artifacts/LSP6KeyManagerInit.json +2 -2
- package/artifacts/LSP7CompatibleERC20Mintable.json +2 -2
- package/artifacts/LSP7CompatibleERC20MintableInit.json +2 -2
- package/artifacts/LSP7Mintable.json +2 -2
- package/artifacts/LSP7MintableInit.json +2 -2
- package/artifacts/LSP8CompatibleERC721Mintable.json +2 -2
- package/artifacts/LSP8CompatibleERC721MintableInit.json +2 -2
- package/artifacts/LSP8Mintable.json +2 -2
- package/artifacts/LSP8MintableInit.json +2 -2
- package/artifacts/LSP9Vault.json +2 -2
- package/artifacts/LSP9VaultInit.json +2 -2
- package/artifacts/UniversalProfile.json +3 -3
- package/artifacts/UniversalProfileInit.json +3 -3
- package/artifacts/UniversalReceiverAddressStore.json +2 -2
- package/contracts/Factories/Create2Factory.sol +11 -3
- package/contracts/LSP0ERC725Account/ILSP0ERC725Account.sol +13 -5
- package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +5 -5
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +256 -186
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +6 -2
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +13 -4
- package/contracts/LSP0ERC725Account/LSP0Utils.sol +3 -5
- package/contracts/LSP10ReceivedVaults/LSP10Utils.sol +25 -10
- package/contracts/LSP11BasicSocialRecovery/ILSP11BasicSocialRecovery.sol +4 -2
- package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecovery.sol +3 -1
- package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryCore.sol +65 -23
- package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryInit.sol +7 -2
- package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryInitAbstract.sol +14 -4
- package/contracts/LSP11BasicSocialRecovery/LSP11Errors.sol +4 -1
- package/contracts/LSP14Ownable2Step/ILSP14Ownable2Step.sol +17 -16
- package/contracts/LSP14Ownable2Step/LSP14Errors.sol +4 -1
- package/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol +22 -11
- package/contracts/LSP16UniversalFactory/LSP16UniversalFactory.sol +85 -27
- package/contracts/LSP17ContractExtension/LSP17Extendable.sol +38 -16
- package/contracts/LSP17ContractExtension/LSP17Extension.sol +20 -8
- package/contracts/LSP17ContractExtension/LSP17Utils.sol +4 -5
- package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiver.sol +5 -5
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +38 -14
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +31 -11
- package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +34 -9
- package/contracts/LSP20CallVerification/{ILSP20CallVerification.sol → ILSP20CallVerifier.sol} +7 -2
- package/contracts/LSP20CallVerification/LSP20CallVerification.sol +24 -9
- package/contracts/LSP20CallVerification/LSP20Errors.sol +1 -1
- package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +62 -36
- package/contracts/LSP4DigitalAssetMetadata/ILSP4Compatibility.sol +3 -1
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol +15 -4
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +18 -5
- package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +32 -12
- package/contracts/LSP6KeyManager/ILSP6KeyManager.sol +17 -8
- package/contracts/LSP6KeyManager/LSP6Constants.sol +3 -9
- package/contracts/LSP6KeyManager/LSP6Errors.sol +4 -1
- package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +114 -72
- package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +7 -2
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6ExecuteModule.sol +96 -46
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6OwnershipModule.sol +10 -5
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6SetDataModule.sol +98 -32
- package/contracts/LSP6KeyManager/LSP6Utils.sol +42 -34
- package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +8 -6
- package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +13 -10
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +96 -26
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +11 -9
- package/contracts/LSP7DigitalAsset/LSP7Errors.sol +8 -2
- package/contracts/LSP7DigitalAsset/extensions/ILSP7CompatibleERC20.sol +9 -2
- package/contracts/LSP7DigitalAsset/extensions/LSP7Burnable.sol +1 -5
- package/contracts/LSP7DigitalAsset/extensions/LSP7BurnableInitAbstract.sol +4 -6
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInitAbstract.sol +6 -2
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.sol +32 -12
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20InitAbstract.sol +28 -7
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInit.sol +8 -2
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInitAbstract.sol +6 -2
- package/contracts/LSP7DigitalAsset/presets/LSP7MintableInit.sol +6 -1
- package/contracts/LSP7DigitalAsset/presets/LSP7MintableInitAbstract.sol +13 -3
- package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +14 -5
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol +3 -1
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +12 -10
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +95 -28
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +14 -10
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CompatibleERC721.sol +23 -10
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Burnable.sol +3 -1
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.sol +3 -1
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInitAbstract.sol +6 -2
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +72 -30
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +77 -27
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.sol +6 -2
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableInitAbstract.sol +6 -2
- package/contracts/LSP8IdentifiableDigitalAsset/presets/ILSP8Mintable.sol +3 -1
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInit.sol +8 -2
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInitAbstract.sol +6 -2
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.sol +3 -1
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +5 -1
- package/contracts/LSP9Vault/ILSP9Vault.sol +13 -5
- package/contracts/LSP9Vault/LSP9Vault.sol +7 -2
- package/contracts/LSP9Vault/LSP9VaultCore.sol +108 -51
- package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +10 -3
- package/contracts/Legacy/Registries/AddressRegistry.sol +13 -4
- package/contracts/Legacy/Registries/AddressRegistryRequiresERC725.sol +6 -2
- package/contracts/Legacy/UniversalReceiverAddressStore.sol +17 -6
- package/contracts/UniversalProfile.sol +4 -1
- package/contracts/UniversalProfileInit.sol +3 -1
- package/contracts/UniversalProfileInitAbstract.sol +13 -4
- package/devdocs/LSP0ERC725Account.json +33 -19
- package/devdocs/LSP0ERC725AccountInit.json +30 -17
- package/devdocs/LSP9Vault.json +3 -3
- package/devdocs/LSP9VaultInit.json +3 -3
- package/devdocs/UniversalProfile.json +30 -17
- package/devdocs/UniversalProfileInit.json +30 -17
- package/dist/constants.cjs.js +142 -102
- package/dist/constants.d.ts +62 -10
- package/dist/constants.es.js +142 -102
- package/package.json +26 -23
- package/userdocs/LSP0ERC725Account.json +2 -2
- package/userdocs/LSP0ERC725AccountInit.json +2 -2
- package/userdocs/UniversalProfile.json +2 -2
- package/userdocs/UniversalProfileInit.json +2 -2
- package/contracts/Custom/EIP191Signer.sol +0 -12
|
@@ -3,7 +3,9 @@ pragma solidity ^0.8.5;
|
|
|
3
3
|
|
|
4
4
|
// modules
|
|
5
5
|
import {ERC725Y} from "@erc725/smart-contracts/contracts/ERC725Y.sol";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
ERC725Y_DataKeysValuesLengthMismatch
|
|
8
|
+
} from "@erc725/smart-contracts/contracts/errors.sol";
|
|
7
9
|
|
|
8
10
|
// libraries
|
|
9
11
|
import {LSP6Utils} from "../LSP6Utils.sol";
|
|
@@ -29,7 +31,9 @@ import {
|
|
|
29
31
|
_LSP1_UNIVERSAL_RECEIVER_DELEGATE_PREFIX,
|
|
30
32
|
_LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY
|
|
31
33
|
} from "../../LSP1UniversalReceiver/LSP1Constants.sol";
|
|
32
|
-
import {
|
|
34
|
+
import {
|
|
35
|
+
_LSP17_EXTENSION_PREFIX
|
|
36
|
+
} from "../../LSP17ContractExtension/LSP17Constants.sol";
|
|
33
37
|
|
|
34
38
|
// errors
|
|
35
39
|
import {
|
|
@@ -70,21 +74,32 @@ abstract contract LSP6SetDataModule {
|
|
|
70
74
|
// CHECK if allowed to set an ERC725Y Data Key
|
|
71
75
|
if (requiredPermission == _PERMISSION_SETDATA) {
|
|
72
76
|
// Skip if caller has SUPER permissions
|
|
73
|
-
if (controllerPermissions.hasPermission(_PERMISSION_SUPER_SETDATA))
|
|
77
|
+
if (controllerPermissions.hasPermission(_PERMISSION_SUPER_SETDATA))
|
|
78
|
+
return;
|
|
74
79
|
|
|
75
|
-
_requirePermissions(
|
|
80
|
+
_requirePermissions(
|
|
81
|
+
controllerAddress,
|
|
82
|
+
controllerPermissions,
|
|
83
|
+
_PERMISSION_SETDATA
|
|
84
|
+
);
|
|
76
85
|
|
|
77
86
|
_verifyAllowedERC725YSingleKey(
|
|
78
87
|
controllerAddress,
|
|
79
88
|
inputDataKey,
|
|
80
|
-
ERC725Y(controlledContract).getAllowedERC725YDataKeysFor(
|
|
89
|
+
ERC725Y(controlledContract).getAllowedERC725YDataKeysFor(
|
|
90
|
+
controllerAddress
|
|
91
|
+
)
|
|
81
92
|
);
|
|
82
93
|
} else {
|
|
83
94
|
// Do not check again if we already checked that the controller had the permissions inside `_getPermissionRequiredToSetDataKey(...)`
|
|
84
95
|
if (requiredPermission == bytes32(0)) return;
|
|
85
96
|
|
|
86
97
|
// Otherwise CHECK the required permission if setting LSP6 permissions, LSP1 Delegate or LSP17 Extensions.
|
|
87
|
-
_requirePermissions(
|
|
98
|
+
_requirePermissions(
|
|
99
|
+
controllerAddress,
|
|
100
|
+
controllerPermissions,
|
|
101
|
+
requiredPermission
|
|
102
|
+
);
|
|
88
103
|
}
|
|
89
104
|
}
|
|
90
105
|
|
|
@@ -107,13 +122,13 @@ abstract contract LSP6SetDataModule {
|
|
|
107
122
|
revert ERC725Y_DataKeysValuesLengthMismatch();
|
|
108
123
|
}
|
|
109
124
|
|
|
110
|
-
bool isSettingERC725YKeys;
|
|
125
|
+
bool isSettingERC725YKeys = false;
|
|
111
126
|
bool[] memory validatedInputDataKeys = new bool[](inputDataKeys.length);
|
|
112
127
|
uint256 inputDataKeysAllowed = 0;
|
|
113
128
|
|
|
114
129
|
bytes32 requiredPermission;
|
|
115
130
|
|
|
116
|
-
uint256 ii;
|
|
131
|
+
uint256 ii = 0;
|
|
117
132
|
do {
|
|
118
133
|
requiredPermission = _getPermissionRequiredToSetDataKey(
|
|
119
134
|
controlledContract,
|
|
@@ -128,7 +143,11 @@ abstract contract LSP6SetDataModule {
|
|
|
128
143
|
// if we did not check already the permissions of the controller inside `_getPermissionRequiredToSetDataKey(...)`
|
|
129
144
|
if (requiredPermission != bytes32(0)) {
|
|
130
145
|
// CHECK the required permissions for setting LSP6 permissions, LSP1 Delegate or LSP17 Extensions.
|
|
131
|
-
_requirePermissions(
|
|
146
|
+
_requirePermissions(
|
|
147
|
+
controller,
|
|
148
|
+
permissions,
|
|
149
|
+
requiredPermission
|
|
150
|
+
);
|
|
132
151
|
}
|
|
133
152
|
|
|
134
153
|
validatedInputDataKeys[ii] = true;
|
|
@@ -150,7 +169,9 @@ abstract contract LSP6SetDataModule {
|
|
|
150
169
|
_verifyAllowedERC725YDataKeys(
|
|
151
170
|
controller,
|
|
152
171
|
inputDataKeys,
|
|
153
|
-
ERC725Y(controlledContract).getAllowedERC725YDataKeysFor(
|
|
172
|
+
ERC725Y(controlledContract).getAllowedERC725YDataKeysFor(
|
|
173
|
+
controller
|
|
174
|
+
),
|
|
154
175
|
validatedInputDataKeys,
|
|
155
176
|
inputDataKeysAllowed
|
|
156
177
|
);
|
|
@@ -175,9 +196,10 @@ abstract contract LSP6SetDataModule {
|
|
|
175
196
|
// this is our best attempt to save gas to avoid reading the `target` storage multiple times
|
|
176
197
|
// to know if we need the permission `ADDCONTROLLER` or `EDITPERMISSIONS`.
|
|
177
198
|
// Even if `getData(...)` is `view`, multiple external calls to fetch values from storage add to the total gas used.
|
|
178
|
-
bool hasBothAddControllerAndEditPermissions = controllerPermissions
|
|
179
|
-
|
|
180
|
-
|
|
199
|
+
bool hasBothAddControllerAndEditPermissions = controllerPermissions
|
|
200
|
+
.hasPermission(
|
|
201
|
+
_PERMISSION_ADDCONTROLLER | _PERMISSION_EDITPERMISSIONS
|
|
202
|
+
);
|
|
181
203
|
|
|
182
204
|
return
|
|
183
205
|
_getPermissionToSetPermissionsArray(
|
|
@@ -190,19 +212,30 @@ abstract contract LSP6SetDataModule {
|
|
|
190
212
|
// AddressPermissions:...
|
|
191
213
|
} else if (bytes6(inputDataKey) == _LSP6KEY_ADDRESSPERMISSIONS_PREFIX) {
|
|
192
214
|
// same as above, save gas by avoiding redundants or unecessary external calls to fetch values from the `target` storage.
|
|
193
|
-
bool hasBothAddControllerAndEditPermissions = controllerPermissions
|
|
194
|
-
|
|
195
|
-
|
|
215
|
+
bool hasBothAddControllerAndEditPermissions = controllerPermissions
|
|
216
|
+
.hasPermission(
|
|
217
|
+
_PERMISSION_ADDCONTROLLER | _PERMISSION_EDITPERMISSIONS
|
|
218
|
+
);
|
|
196
219
|
|
|
197
220
|
// AddressPermissions:Permissions:<address>
|
|
198
|
-
if (
|
|
221
|
+
if (
|
|
222
|
+
bytes12(inputDataKey) ==
|
|
223
|
+
_LSP6KEY_ADDRESSPERMISSIONS_PERMISSIONS_PREFIX
|
|
224
|
+
) {
|
|
199
225
|
// controller already has the permissions needed. Do not run internal function.
|
|
200
226
|
if (hasBothAddControllerAndEditPermissions) return (bytes32(0));
|
|
201
227
|
|
|
202
|
-
return
|
|
228
|
+
return
|
|
229
|
+
_getPermissionToSetControllerPermissions(
|
|
230
|
+
controlledContract,
|
|
231
|
+
inputDataKey
|
|
232
|
+
);
|
|
203
233
|
|
|
204
234
|
// AddressPermissions:AllowedCalls:<address>
|
|
205
|
-
} else if (
|
|
235
|
+
} else if (
|
|
236
|
+
bytes12(inputDataKey) ==
|
|
237
|
+
_LSP6KEY_ADDRESSPERMISSIONS_ALLOWEDCALLS_PREFIX
|
|
238
|
+
) {
|
|
206
239
|
return
|
|
207
240
|
_getPermissionToSetAllowedCalls(
|
|
208
241
|
controlledContract,
|
|
@@ -213,7 +246,8 @@ abstract contract LSP6SetDataModule {
|
|
|
213
246
|
|
|
214
247
|
// AddressPermissions:AllowedERC725YKeys:<address>
|
|
215
248
|
} else if (
|
|
216
|
-
bytes12(inputDataKey) ==
|
|
249
|
+
bytes12(inputDataKey) ==
|
|
250
|
+
_LSP6KEY_ADDRESSPERMISSIONS_AllowedERC725YDataKeys_PREFIX
|
|
217
251
|
) {
|
|
218
252
|
return
|
|
219
253
|
_getPermissionToSetAllowedERC725YDataKeys(
|
|
@@ -257,7 +291,11 @@ abstract contract LSP6SetDataModule {
|
|
|
257
291
|
return bytes32(0);
|
|
258
292
|
}
|
|
259
293
|
|
|
260
|
-
return
|
|
294
|
+
return
|
|
295
|
+
_getPermissionToSetLSP1Delegate(
|
|
296
|
+
controlledContract,
|
|
297
|
+
inputDataKey
|
|
298
|
+
);
|
|
261
299
|
|
|
262
300
|
// LSP17Extension:<bytes4>
|
|
263
301
|
} else if (bytes12(inputDataKey) == _LSP17_EXTENSION_PREFIX) {
|
|
@@ -271,7 +309,11 @@ abstract contract LSP6SetDataModule {
|
|
|
271
309
|
return bytes32(0);
|
|
272
310
|
}
|
|
273
311
|
|
|
274
|
-
return
|
|
312
|
+
return
|
|
313
|
+
_getPermissionToSetLSP17Extension(
|
|
314
|
+
controlledContract,
|
|
315
|
+
inputDataKey
|
|
316
|
+
);
|
|
275
317
|
} else {
|
|
276
318
|
return _PERMISSION_SETDATA;
|
|
277
319
|
}
|
|
@@ -302,7 +344,12 @@ abstract contract LSP6SetDataModule {
|
|
|
302
344
|
uint128 newLength = uint128(bytes16(inputDataValue));
|
|
303
345
|
|
|
304
346
|
return
|
|
305
|
-
newLength >
|
|
347
|
+
newLength >
|
|
348
|
+
uint128(
|
|
349
|
+
bytes16(
|
|
350
|
+
ERC725Y(controlledContract).getData(inputDataKey)
|
|
351
|
+
)
|
|
352
|
+
)
|
|
306
353
|
? _PERMISSION_ADDCONTROLLER
|
|
307
354
|
: _PERMISSION_EDITPERMISSIONS;
|
|
308
355
|
}
|
|
@@ -311,7 +358,10 @@ abstract contract LSP6SetDataModule {
|
|
|
311
358
|
|
|
312
359
|
// CHECK that we either ADD an address (20 bytes long) or REMOVE an address (0x)
|
|
313
360
|
if (inputDataValue.length != 0 && inputDataValue.length != 20) {
|
|
314
|
-
revert AddressPermissionArrayIndexValueNotAnAddress(
|
|
361
|
+
revert AddressPermissionArrayIndexValueNotAnAddress(
|
|
362
|
+
inputDataKey,
|
|
363
|
+
inputDataValue
|
|
364
|
+
);
|
|
315
365
|
}
|
|
316
366
|
|
|
317
367
|
// if the controller already has both permissions from one of the two required below,
|
|
@@ -337,7 +387,9 @@ abstract contract LSP6SetDataModule {
|
|
|
337
387
|
return
|
|
338
388
|
// if there is nothing stored under the data key, we are trying to ADD a new controller.
|
|
339
389
|
// if there are already some permissions set under the data key, we are trying to CHANGE the permissions of a controller.
|
|
340
|
-
bytes32(
|
|
390
|
+
bytes32(
|
|
391
|
+
ERC725Y(controlledContract).getData(inputPermissionDataKey)
|
|
392
|
+
) == bytes32(0)
|
|
341
393
|
? _PERMISSION_ADDCONTROLLER
|
|
342
394
|
: _PERMISSION_EDITPERMISSIONS;
|
|
343
395
|
}
|
|
@@ -438,7 +490,8 @@ abstract contract LSP6SetDataModule {
|
|
|
438
490
|
bytes32 lsp17ExtensionDataKey
|
|
439
491
|
) internal view virtual returns (bytes32) {
|
|
440
492
|
return
|
|
441
|
-
ERC725Y(controlledContract).getData(lsp17ExtensionDataKey).length ==
|
|
493
|
+
ERC725Y(controlledContract).getData(lsp17ExtensionDataKey).length ==
|
|
494
|
+
0
|
|
442
495
|
? _PERMISSION_ADDEXTENSIONS
|
|
443
496
|
: _PERMISSION_CHANGEEXTENSIONS;
|
|
444
497
|
}
|
|
@@ -524,7 +577,9 @@ abstract contract LSP6SetDataModule {
|
|
|
524
577
|
* mask = 0xffffff0000000000000000000000000000000000000000000000000000000000
|
|
525
578
|
*/
|
|
526
579
|
mask =
|
|
527
|
-
bytes32(
|
|
580
|
+
bytes32(
|
|
581
|
+
0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
|
582
|
+
) <<
|
|
528
583
|
(8 * (32 - length));
|
|
529
584
|
|
|
530
585
|
/*
|
|
@@ -536,7 +591,9 @@ abstract contract LSP6SetDataModule {
|
|
|
536
591
|
// the first 32 bytes word in memory (where allowedERC725YDataKeysCompacted is stored)
|
|
537
592
|
// correspond to the total number of bytes in `allowedERC725YDataKeysCompacted`
|
|
538
593
|
let offset := add(add(pointer, 2), 32)
|
|
539
|
-
let memoryAt := mload(
|
|
594
|
+
let memoryAt := mload(
|
|
595
|
+
add(allowedERC725YDataKeysCompacted, offset)
|
|
596
|
+
)
|
|
540
597
|
// MLOAD loads 32 bytes word, so we need to keep only the `length` number of bytes that makes up the allowed data key.
|
|
541
598
|
allowedKey := and(memoryAt, mask)
|
|
542
599
|
}
|
|
@@ -640,7 +697,9 @@ abstract contract LSP6SetDataModule {
|
|
|
640
697
|
* mask = 0xffffff0000000000000000000000000000000000000000000000000000000000
|
|
641
698
|
*/
|
|
642
699
|
mask =
|
|
643
|
-
bytes32(
|
|
700
|
+
bytes32(
|
|
701
|
+
0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
|
702
|
+
) <<
|
|
644
703
|
(8 * (32 - length));
|
|
645
704
|
|
|
646
705
|
/*
|
|
@@ -652,7 +711,9 @@ abstract contract LSP6SetDataModule {
|
|
|
652
711
|
// the first 32 bytes word in memory (where allowedERC725YDataKeysCompacted is stored)
|
|
653
712
|
// correspond to the length of allowedERC725YDataKeysCompacted (= total number of bytes)
|
|
654
713
|
let offset := add(add(pointer, 2), 32)
|
|
655
|
-
let memoryAt := mload(
|
|
714
|
+
let memoryAt := mload(
|
|
715
|
+
add(allowedERC725YDataKeysCompacted, offset)
|
|
716
|
+
)
|
|
656
717
|
allowedKey := and(memoryAt, mask)
|
|
657
718
|
}
|
|
658
719
|
|
|
@@ -698,7 +759,10 @@ abstract contract LSP6SetDataModule {
|
|
|
698
759
|
// if we did not find all the input data keys, search for the first not allowed data key to revert.
|
|
699
760
|
for (uint256 jj; jj < inputKeysLength; ) {
|
|
700
761
|
if (!validatedInputKeysList[jj]) {
|
|
701
|
-
revert NotAllowedERC725YDataKey(
|
|
762
|
+
revert NotAllowedERC725YDataKey(
|
|
763
|
+
controllerAddress,
|
|
764
|
+
inputDataKeys[jj]
|
|
765
|
+
);
|
|
702
766
|
}
|
|
703
767
|
|
|
704
768
|
unchecked {
|
|
@@ -719,7 +783,9 @@ abstract contract LSP6SetDataModule {
|
|
|
719
783
|
bytes32 permissionRequired
|
|
720
784
|
) internal pure virtual {
|
|
721
785
|
if (!LSP6Utils.hasPermission(addressPermissions, permissionRequired)) {
|
|
722
|
-
string memory permissionErrorString = LSP6Utils.getPermissionName(
|
|
786
|
+
string memory permissionErrorString = LSP6Utils.getPermissionName(
|
|
787
|
+
permissionRequired
|
|
788
|
+
);
|
|
723
789
|
revert NotAuthorised(controller, permissionErrorString);
|
|
724
790
|
}
|
|
725
791
|
}
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
pragma solidity ^0.8.4;
|
|
3
3
|
|
|
4
4
|
// interfaces
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
IERC725Y
|
|
7
|
+
} from "@erc725/smart-contracts/contracts/interfaces/IERC725Y.sol";
|
|
6
8
|
import {ILSP6KeyManager} from "./ILSP6KeyManager.sol";
|
|
7
9
|
|
|
8
10
|
// libraries
|
|
@@ -20,7 +22,10 @@ library LSP6Utils {
|
|
|
20
22
|
* @param caller the controller address to read the permissions from.
|
|
21
23
|
* @return a `bytes32` BitArray containing the permissions of a controller address.
|
|
22
24
|
*/
|
|
23
|
-
function getPermissionsFor(
|
|
25
|
+
function getPermissionsFor(
|
|
26
|
+
IERC725Y target,
|
|
27
|
+
address caller
|
|
28
|
+
) internal view returns (bytes32) {
|
|
24
29
|
bytes memory permissions = target.getData(
|
|
25
30
|
LSP2Utils.generateMappingWithGroupingKey(
|
|
26
31
|
_LSP6KEY_ADDRESSPERMISSIONS_PERMISSIONS_PREFIX,
|
|
@@ -31,11 +36,10 @@ library LSP6Utils {
|
|
|
31
36
|
return bytes32(permissions);
|
|
32
37
|
}
|
|
33
38
|
|
|
34
|
-
function getAllowedCallsFor(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
{
|
|
39
|
+
function getAllowedCallsFor(
|
|
40
|
+
IERC725Y target,
|
|
41
|
+
address from
|
|
42
|
+
) internal view returns (bytes memory) {
|
|
39
43
|
return
|
|
40
44
|
target.getData(
|
|
41
45
|
LSP2Utils.generateMappingWithGroupingKey(
|
|
@@ -51,11 +55,10 @@ library LSP6Utils {
|
|
|
51
55
|
* @param caller the controller address to read the permissions from.
|
|
52
56
|
* @return an abi-encoded array of allowed ERC725 keys that the controller address is allowed to interact with.
|
|
53
57
|
*/
|
|
54
|
-
function getAllowedERC725YDataKeysFor(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
{
|
|
58
|
+
function getAllowedERC725YDataKeysFor(
|
|
59
|
+
IERC725Y target,
|
|
60
|
+
address caller
|
|
61
|
+
) internal view returns (bytes memory) {
|
|
59
62
|
return
|
|
60
63
|
target.getData(
|
|
61
64
|
LSP2Utils.generateMappingWithGroupingKey(
|
|
@@ -72,11 +75,10 @@ library LSP6Utils {
|
|
|
72
75
|
* @param permissionToCheck the permissions to check
|
|
73
76
|
* @return true if `addressPermissions` includes `permissionToCheck`, false otherwise
|
|
74
77
|
*/
|
|
75
|
-
function hasPermission(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
{
|
|
78
|
+
function hasPermission(
|
|
79
|
+
bytes32 addressPermission,
|
|
80
|
+
bytes32 permissionToCheck
|
|
81
|
+
) internal pure returns (bool) {
|
|
80
82
|
return (addressPermission & permissionToCheck) == permissionToCheck;
|
|
81
83
|
}
|
|
82
84
|
|
|
@@ -86,12 +88,10 @@ library LSP6Utils {
|
|
|
86
88
|
* @param allowedCallsCompacted a compact bytes array of tuples (bytes4,address,bytes4) to check.
|
|
87
89
|
* @return true if the value passed is a valid compact bytes array of bytes28 elements according to LSP2, false otherwise.
|
|
88
90
|
*/
|
|
89
|
-
function isCompactBytesArrayOfAllowedCalls(
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
{
|
|
94
|
-
uint256 pointer;
|
|
91
|
+
function isCompactBytesArrayOfAllowedCalls(
|
|
92
|
+
bytes memory allowedCallsCompacted
|
|
93
|
+
) internal pure returns (bool) {
|
|
94
|
+
uint256 pointer = 0;
|
|
95
95
|
|
|
96
96
|
while (pointer < allowedCallsCompacted.length) {
|
|
97
97
|
if (pointer + 1 >= allowedCallsCompacted.length) return false;
|
|
@@ -120,10 +120,11 @@ library LSP6Utils {
|
|
|
120
120
|
function isCompactBytesArrayOfAllowedERC725YDataKeys(
|
|
121
121
|
bytes memory allowedERC725YDataKeysCompacted
|
|
122
122
|
) internal pure returns (bool) {
|
|
123
|
-
uint256 pointer;
|
|
123
|
+
uint256 pointer = 0;
|
|
124
124
|
|
|
125
125
|
while (pointer < allowedERC725YDataKeysCompacted.length) {
|
|
126
|
-
if (pointer + 1 >= allowedERC725YDataKeysCompacted.length)
|
|
126
|
+
if (pointer + 1 >= allowedERC725YDataKeysCompacted.length)
|
|
127
|
+
return false;
|
|
127
128
|
uint256 elementLength = uint16(
|
|
128
129
|
bytes2(
|
|
129
130
|
abi.encodePacked(
|
|
@@ -151,7 +152,11 @@ library LSP6Utils {
|
|
|
151
152
|
bytes32[] memory keys,
|
|
152
153
|
bytes[] memory values
|
|
153
154
|
) internal returns (bytes memory result) {
|
|
154
|
-
bytes memory payload = abi.encodeWithSelector(
|
|
155
|
+
bytes memory payload = abi.encodeWithSelector(
|
|
156
|
+
IERC725Y.setDataBatch.selector,
|
|
157
|
+
keys,
|
|
158
|
+
values
|
|
159
|
+
);
|
|
155
160
|
result = ILSP6KeyManager(keyManagerAddress).execute(payload);
|
|
156
161
|
}
|
|
157
162
|
|
|
@@ -161,7 +166,9 @@ library LSP6Utils {
|
|
|
161
166
|
* @param permissions the array of permissions to combine
|
|
162
167
|
* @return a bytes32 containing the combined permissions
|
|
163
168
|
*/
|
|
164
|
-
function combinePermissions(
|
|
169
|
+
function combinePermissions(
|
|
170
|
+
bytes32[] memory permissions
|
|
171
|
+
) internal pure returns (bytes32) {
|
|
165
172
|
uint256 result = 0;
|
|
166
173
|
for (uint256 i = 0; i < permissions.length; i++) {
|
|
167
174
|
result += uint256(permissions[i]);
|
|
@@ -192,7 +199,9 @@ library LSP6Utils {
|
|
|
192
199
|
keys = new bytes32[](3);
|
|
193
200
|
values = new bytes[](3);
|
|
194
201
|
|
|
195
|
-
uint128 arrayLength = uint128(
|
|
202
|
+
uint128 arrayLength = uint128(
|
|
203
|
+
bytes16(account.getData(_LSP6KEY_ADDRESSPERMISSIONS_ARRAY))
|
|
204
|
+
);
|
|
196
205
|
uint128 newArrayLength = arrayLength + 1;
|
|
197
206
|
|
|
198
207
|
keys[0] = _LSP6KEY_ADDRESSPERMISSIONS_ARRAY;
|
|
@@ -214,16 +223,15 @@ library LSP6Utils {
|
|
|
214
223
|
/**
|
|
215
224
|
* @dev returns the name of the permission as a string
|
|
216
225
|
*/
|
|
217
|
-
function getPermissionName(
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
returns (string memory errorMessage)
|
|
221
|
-
{
|
|
226
|
+
function getPermissionName(
|
|
227
|
+
bytes32 permission
|
|
228
|
+
) internal pure returns (string memory errorMessage) {
|
|
222
229
|
if (permission == _PERMISSION_CHANGEOWNER) return "TRANSFEROWNERSHIP";
|
|
223
230
|
if (permission == _PERMISSION_EDITPERMISSIONS) return "EDITPERMISSIONS";
|
|
224
231
|
if (permission == _PERMISSION_ADDCONTROLLER) return "ADDCONTROLLER";
|
|
225
232
|
if (permission == _PERMISSION_ADDEXTENSIONS) return "ADDEXTENSIONS";
|
|
226
|
-
if (permission == _PERMISSION_CHANGEEXTENSIONS)
|
|
233
|
+
if (permission == _PERMISSION_CHANGEEXTENSIONS)
|
|
234
|
+
return "CHANGEEXTENSIONS";
|
|
227
235
|
if (permission == _PERMISSION_ADDUNIVERSALRECEIVERDELEGATE)
|
|
228
236
|
return "ADDUNIVERSALRECEIVERDELEGATE";
|
|
229
237
|
if (permission == _PERMISSION_CHANGEUNIVERSALRECEIVERDELEGATE)
|
|
@@ -4,10 +4,12 @@ pragma solidity ^0.8.4;
|
|
|
4
4
|
|
|
5
5
|
// interfaces
|
|
6
6
|
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
IERC725Y
|
|
9
|
+
} from "@erc725/smart-contracts/contracts/interfaces/IERC725Y.sol";
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
|
-
* @title
|
|
12
|
+
* @title Interface of the LSP7 - Digital Asset standard, a fungible digital asset.
|
|
11
13
|
*/
|
|
12
14
|
interface ILSP7DigitalAsset is IERC165, IERC725Y {
|
|
13
15
|
// --- Events
|
|
@@ -126,10 +128,10 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
|
|
|
126
128
|
* Operators can send and burn tokens on behalf of their owners. The tokenOwner is their own
|
|
127
129
|
* operator.
|
|
128
130
|
*/
|
|
129
|
-
function authorizedAmountFor(
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
131
|
+
function authorizedAmountFor(
|
|
132
|
+
address operator,
|
|
133
|
+
address tokenOwner
|
|
134
|
+
) external view returns (uint256);
|
|
133
135
|
|
|
134
136
|
// --- Transfer functionality
|
|
135
137
|
|
|
@@ -6,7 +6,9 @@ import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
|
|
|
6
6
|
|
|
7
7
|
// modules
|
|
8
8
|
import {ERC725YCore} from "@erc725/smart-contracts/contracts/ERC725YCore.sol";
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
LSP4DigitalAssetMetadata
|
|
11
|
+
} from "../LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol";
|
|
10
12
|
import {LSP7DigitalAssetCore} from "./LSP7DigitalAssetCore.sol";
|
|
11
13
|
|
|
12
14
|
// constants
|
|
@@ -21,7 +23,10 @@ import {_INTERFACEID_LSP7} from "./LSP7Constants.sol";
|
|
|
21
23
|
* A supply mechanism has to be added in a derived contract using {_mint}
|
|
22
24
|
* For a generic mechanism, see {LSP7Mintable}.
|
|
23
25
|
*/
|
|
24
|
-
abstract contract LSP7DigitalAsset is
|
|
26
|
+
abstract contract LSP7DigitalAsset is
|
|
27
|
+
LSP4DigitalAssetMetadata,
|
|
28
|
+
LSP7DigitalAssetCore
|
|
29
|
+
{
|
|
25
30
|
/**
|
|
26
31
|
* @notice Sets the token-Metadata
|
|
27
32
|
* @param name_ The name of the token
|
|
@@ -41,13 +46,11 @@ abstract contract LSP7DigitalAsset is LSP4DigitalAssetMetadata, LSP7DigitalAsset
|
|
|
41
46
|
/**
|
|
42
47
|
* @dev See {IERC165-supportsInterface}.
|
|
43
48
|
*/
|
|
44
|
-
function supportsInterface(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
{
|
|
51
|
-
return interfaceId == _INTERFACEID_LSP7 || super.supportsInterface(interfaceId);
|
|
49
|
+
function supportsInterface(
|
|
50
|
+
bytes4 interfaceId
|
|
51
|
+
) public view virtual override(IERC165, ERC725YCore) returns (bool) {
|
|
52
|
+
return
|
|
53
|
+
interfaceId == _INTERFACEID_LSP7 ||
|
|
54
|
+
super.supportsInterface(interfaceId);
|
|
52
55
|
}
|
|
53
56
|
}
|