@lukso/lsp-smart-contracts 0.8.0 → 0.9.0

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 (81) hide show
  1. package/CONTRIBUTING.md +8 -0
  2. package/README.md +34 -21
  3. package/artifacts/LSP0ERC725Account.json +51 -5
  4. package/artifacts/LSP0ERC725AccountInit.json +51 -5
  5. package/artifacts/LSP11BasicSocialRecovery.json +2 -2
  6. package/artifacts/LSP11BasicSocialRecoveryInit.json +2 -2
  7. package/artifacts/LSP16UniversalFactory.json +31 -2
  8. package/artifacts/LSP1UniversalReceiverDelegateUP.json +19 -35
  9. package/artifacts/LSP1UniversalReceiverDelegateVault.json +13 -13
  10. package/artifacts/LSP4Compatibility.json +7 -2
  11. package/artifacts/LSP4DigitalAssetMetadata.json +7 -2
  12. package/artifacts/LSP4DigitalAssetMetadataInitAbstract.json +7 -2
  13. package/artifacts/LSP6KeyManager.json +91 -6
  14. package/artifacts/LSP6KeyManagerInit.json +103 -18
  15. package/artifacts/LSP7CappedSupply.json +12 -2
  16. package/artifacts/LSP7CappedSupplyInitAbstract.json +12 -2
  17. package/artifacts/LSP7CompatibleERC20.json +12 -2
  18. package/artifacts/LSP7CompatibleERC20InitAbstract.json +12 -2
  19. package/artifacts/LSP7CompatibleERC20Mintable.json +14 -4
  20. package/artifacts/LSP7CompatibleERC20MintableInit.json +14 -4
  21. package/artifacts/LSP7DigitalAsset.json +12 -2
  22. package/artifacts/LSP7DigitalAssetInitAbstract.json +12 -2
  23. package/artifacts/LSP7Mintable.json +14 -4
  24. package/artifacts/LSP7MintableInit.json +14 -4
  25. package/artifacts/LSP8CappedSupply.json +12 -2
  26. package/artifacts/LSP8CappedSupplyInitAbstract.json +12 -2
  27. package/artifacts/LSP8CompatibleERC721.json +12 -2
  28. package/artifacts/LSP8CompatibleERC721InitAbstract.json +12 -2
  29. package/artifacts/LSP8CompatibleERC721Mintable.json +14 -4
  30. package/artifacts/LSP8CompatibleERC721MintableInit.json +14 -4
  31. package/artifacts/LSP8IdentifiableDigitalAsset.json +12 -2
  32. package/artifacts/LSP8IdentifiableDigitalAssetInitAbstract.json +12 -2
  33. package/artifacts/LSP8Mintable.json +14 -4
  34. package/artifacts/LSP8MintableInit.json +14 -4
  35. package/artifacts/LSP9Vault.json +29 -5
  36. package/artifacts/LSP9VaultInit.json +29 -5
  37. package/artifacts/UniversalProfile.json +51 -5
  38. package/artifacts/UniversalProfileInit.json +51 -5
  39. package/common/constants.d.ts +461 -0
  40. package/common/constants.js +789 -0
  41. package/contracts/LSP0ERC725Account/ILSP0ERC725Account.sol +27 -0
  42. package/contracts/LSP0ERC725Account/LSP0Constants.sol +1 -1
  43. package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +353 -145
  44. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +1 -1
  45. package/contracts/LSP0ERC725Account/LSP0Utils.sol +50 -0
  46. package/contracts/LSP10ReceivedVaults/LSP10Utils.sol +48 -54
  47. package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryCore.sol +5 -6
  48. package/contracts/LSP14Ownable2Step/ILSP14Ownable2Step.sol +27 -4
  49. package/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol +36 -77
  50. package/contracts/LSP16UniversalFactory/LSP16UniversalFactory.sol +8 -8
  51. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +50 -57
  52. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +18 -8
  53. package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +12 -0
  54. package/contracts/LSP20CallVerification/ILSP20CallVerification.sol +30 -0
  55. package/contracts/LSP20CallVerification/LSP20CallVerification.sol +74 -0
  56. package/contracts/LSP20CallVerification/LSP20Errors.sol +15 -0
  57. package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +7 -7
  58. package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +50 -56
  59. package/contracts/LSP6KeyManager/ILSP6KeyManager.sol +1 -1
  60. package/contracts/LSP6KeyManager/LSP6Constants.sol +8 -2
  61. package/contracts/LSP6KeyManager/LSP6Errors.sol +18 -1
  62. package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +126 -745
  63. package/contracts/LSP6KeyManager/LSP6Modules/LSP6ExecuteModule.sol +407 -0
  64. package/contracts/LSP6KeyManager/LSP6Modules/LSP6OwnershipModule.sol +25 -0
  65. package/contracts/LSP6KeyManager/LSP6Modules/LSP6SetDataModule.sol +633 -0
  66. package/contracts/LSP6KeyManager/LSP6Utils.sol +60 -15
  67. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +14 -23
  68. package/contracts/LSP7DigitalAsset/LSP7Errors.sol +5 -0
  69. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol +5 -0
  70. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +19 -30
  71. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +1 -3
  72. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +1 -3
  73. package/contracts/LSP9Vault/ILSP9Vault.sol +19 -0
  74. package/contracts/LSP9Vault/LSP9Constants.sol +1 -1
  75. package/contracts/LSP9Vault/LSP9Vault.sol +11 -2
  76. package/contracts/LSP9Vault/LSP9VaultCore.sol +166 -83
  77. package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +11 -2
  78. package/module/constants.d.ts +461 -0
  79. package/module/constants.js +786 -0
  80. package/package.json +30 -6
  81. package/constants.js +0 -856
@@ -0,0 +1,407 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.5;
3
+
4
+ // interfaces
5
+ import {
6
+ ILSP20CallVerification as ILSP20
7
+ } from "../../LSP20CallVerification/ILSP20CallVerification.sol";
8
+
9
+ // modules
10
+ import {ERC725Y} from "@erc725/smart-contracts/contracts/ERC725Y.sol";
11
+
12
+ // libraries
13
+ import {LSP6Utils} from "../LSP6Utils.sol";
14
+ import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol";
15
+ import {ERC165Checker} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
16
+
17
+ // constants
18
+ import {
19
+ _PERMISSION_TRANSFERVALUE,
20
+ _PERMISSION_SUPER_TRANSFERVALUE,
21
+ _PERMISSION_DEPLOY,
22
+ _PERMISSION_CALL,
23
+ _PERMISSION_SUPER_CALL,
24
+ _PERMISSION_STATICCALL,
25
+ _PERMISSION_SUPER_STATICCALL,
26
+ _PERMISSION_DELEGATECALL,
27
+ _PERMISSION_SUPER_DELEGATECALL,
28
+ _ALLOWEDCALLS_VALUE,
29
+ _ALLOWEDCALLS_WRITE,
30
+ _ALLOWEDCALLS_READ,
31
+ _ALLOWEDCALLS_EXECUTE
32
+ } from "../LSP6Constants.sol";
33
+ import {
34
+ OPERATION_0_CALL,
35
+ OPERATION_1_CREATE,
36
+ OPERATION_2_CREATE2,
37
+ OPERATION_3_STATICCALL,
38
+ OPERATION_4_DELEGATECALL
39
+ } from "@erc725/smart-contracts/contracts/constants.sol";
40
+
41
+ // errors
42
+ import {
43
+ DelegateCallDisallowedViaKeyManager,
44
+ NoCallsAllowed,
45
+ NotAllowedCall,
46
+ InvalidEncodedAllowedCalls,
47
+ InvalidWhitelistedCall,
48
+ NotAuthorised,
49
+ InvalidPayload,
50
+ CallingKeyManagerNotAllowed
51
+ } from "../LSP6Errors.sol";
52
+
53
+ abstract contract LSP6ExecuteModule {
54
+ using ERC165Checker for address;
55
+ using LSP6Utils for *;
56
+
57
+ /**
58
+ * @dev verify if `controllerAddress` has the required permissions to interact with other addresses using the controlledContract.
59
+ * @param controlledContract the address of the ERC725 contract where the payload is executed and where the permissions are verified.
60
+ * @param controller the address who want to run the execute function on the ERC725Account.
61
+ * @param permissions the permissions of the controller address.
62
+ * @param payload the ABI encoded payload `controlledContract.execute(...)`.
63
+ */
64
+ function _verifyCanExecute(
65
+ address controlledContract,
66
+ address controller,
67
+ bytes32 permissions,
68
+ bytes calldata payload
69
+ ) internal view virtual {
70
+ // CHECK the offset of `data` is not pointing to the previous parameters
71
+ if (
72
+ bytes32(payload[100:132]) !=
73
+ 0x0000000000000000000000000000000000000000000000000000000000000080
74
+ ) {
75
+ revert InvalidPayload(payload);
76
+ }
77
+
78
+ // MUST be one of the ERC725X operation types.
79
+ uint256 operationType = uint256(bytes32(payload[4:36]));
80
+
81
+ address to = address(bytes20(payload[48:68]));
82
+
83
+ // if to is the KeyManager address revert
84
+ if (to == address(this)) {
85
+ revert CallingKeyManagerNotAllowed();
86
+ }
87
+
88
+ // Future versions of the KeyManager willing to allow LSP0 to call the KeyManager
89
+ // may need to implement this check to avoid inconsistent state of reentrancy
90
+ // that may lead to lock the use of the KeyManager
91
+
92
+ // Check to restrict controllers with execute permissions to call lsp20 functions
93
+ // to avoid setting the reentrancy guard to a non-valid state
94
+
95
+ // if (payload.length >= 168 && to == address(this)) {
96
+ // if (
97
+ // bytes4(payload[164:168]) == ILSP20.lsp20VerifyCall.selector ||
98
+ // bytes4(payload[164:168]) == ILSP20.lsp20VerifyCallResult.selector
99
+ // ) {
100
+ // revert CallingLSP20FunctionsOnLSP6NotAllowed();
101
+ // }
102
+ // }
103
+
104
+ // if it is a message call
105
+ if (operationType == OPERATION_0_CALL) {
106
+ return _verifyCanCall(controlledContract, controller, permissions, payload);
107
+ }
108
+
109
+ // if it is a contract creation
110
+ if (operationType == OPERATION_1_CREATE || operationType == OPERATION_2_CREATE2) {
111
+ // required to check for permission TRANSFERVALUE if we are funding
112
+ // the contract on deployment via a payable constructor
113
+ bool isFundingContract = uint256(bytes32(payload[68:100])) != 0;
114
+
115
+ return _verifyCanDeployContract(controller, permissions, isFundingContract);
116
+ }
117
+
118
+ // if it is a STATICALL
119
+ // we do not check for TRANSFERVALUE permission,
120
+ // as ERC725X will revert if a value is provided with operation type STATICCALL.
121
+ if (operationType == OPERATION_3_STATICCALL) {
122
+ return _verifyCanStaticCall(controlledContract, controller, permissions, payload);
123
+ }
124
+
125
+ // DELEGATECALL is disallowed by default on the Key Manager.
126
+ if (operationType == OPERATION_4_DELEGATECALL) {
127
+ revert DelegateCallDisallowedViaKeyManager();
128
+ }
129
+ }
130
+
131
+ function _verifyCanDeployContract(
132
+ address controller,
133
+ bytes32 permissions,
134
+ bool isFundingContract
135
+ ) internal view virtual {
136
+ _requirePermissions(controller, permissions, _PERMISSION_DEPLOY);
137
+
138
+ bool hasSuperTransferValue = permissions.hasPermission(_PERMISSION_SUPER_TRANSFERVALUE);
139
+
140
+ // CHECK if we are funding the contract
141
+ if (isFundingContract && !hasSuperTransferValue) {
142
+ revert NotAuthorised(controller, "SUPER_TRANSFERVALUE");
143
+ }
144
+ }
145
+
146
+ function _verifyCanStaticCall(
147
+ address controlledContract,
148
+ address controller,
149
+ bytes32 permissions,
150
+ bytes calldata payload
151
+ ) internal view virtual {
152
+ bool hasSuperStaticCall = permissions.hasPermission(_PERMISSION_SUPER_STATICCALL);
153
+
154
+ // Skip if caller has SUPER permission for static calls
155
+ if (hasSuperStaticCall) return;
156
+
157
+ _requirePermissions(controller, permissions, _PERMISSION_STATICCALL);
158
+
159
+ _verifyAllowedCall(controlledContract, controller, payload);
160
+ }
161
+
162
+ function _verifyCanCall(
163
+ address controlledContract,
164
+ address controller,
165
+ bytes32 permissions,
166
+ bytes calldata payload
167
+ ) internal view virtual {
168
+ bool isTransferringValue = uint256(bytes32(payload[68:100])) != 0;
169
+
170
+ bool hasSuperTransferValue = permissions.hasPermission(_PERMISSION_SUPER_TRANSFERVALUE);
171
+
172
+ // all the parameters are abi-encoded (padded to 32 bytes words)
173
+ //
174
+ // 4 (ERC725X.execute selector)
175
+ // + 32 (uint256 operationType)
176
+ // + 32 (address to/target)
177
+ // + 32 (uint256 value)
178
+ // + 32 (`data` offset)
179
+ // + 32 (`data` length)
180
+ // --------------------
181
+ // = 164 bytes in total
182
+ bool isCallDataPresent = payload.length > 164;
183
+
184
+ bool hasSuperCall = permissions.hasPermission(_PERMISSION_SUPER_CALL);
185
+
186
+ if (isTransferringValue && !hasSuperTransferValue) {
187
+ _requirePermissions(controller, permissions, _PERMISSION_TRANSFERVALUE);
188
+ }
189
+
190
+ // CHECK if we are doing an empty call, as the receive() or fallback() function
191
+ // of the controlledContract could run some code.
192
+ if (!hasSuperCall && !isCallDataPresent && !isTransferringValue) {
193
+ _requirePermissions(controller, permissions, _PERMISSION_CALL);
194
+ }
195
+
196
+ if (isCallDataPresent && !hasSuperCall) {
197
+ _requirePermissions(controller, permissions, _PERMISSION_CALL);
198
+ }
199
+
200
+ // Skip if caller has SUPER permissions for external calls, with or without calldata (empty calls)
201
+ if (hasSuperCall && !isTransferringValue) return;
202
+
203
+ // Skip if caller has SUPER permission for value transfers
204
+ if (hasSuperTransferValue && !isCallDataPresent && isTransferringValue) return;
205
+
206
+ // Skip if both SUPER permissions are present
207
+ if (hasSuperCall && hasSuperTransferValue) return;
208
+
209
+ _verifyAllowedCall(controlledContract, controller, payload);
210
+ }
211
+
212
+ function _verifyAllowedCall(
213
+ address controlledContract,
214
+ address controllerAddress,
215
+ bytes calldata payload
216
+ ) internal view virtual {
217
+ (
218
+ uint256 operationType,
219
+ address to,
220
+ uint256 value,
221
+ bytes4 selector
222
+ ) = _extractExecuteParameters(payload);
223
+
224
+ // CHECK for ALLOWED CALLS
225
+ bytes memory allowedCalls = ERC725Y(controlledContract).getAllowedCallsFor(
226
+ controllerAddress
227
+ );
228
+
229
+ if (allowedCalls.length == 0) {
230
+ revert NoCallsAllowed(controllerAddress);
231
+ }
232
+
233
+ bytes4 requiredCallTypes = _extractCallType(operationType, selector, value);
234
+
235
+ for (uint256 ii; ii < allowedCalls.length; ii += 34) {
236
+ /// @dev structure of an AllowedCall
237
+ //
238
+ /// AllowedCall = 0x00200000000ncafecafecafecafecafecafecafecafecafecafe5a5a5a5af1f1f1f1
239
+ ///
240
+ /// 0020 = hex for '32' bytes long
241
+ /// 0000000n = call type(s)
242
+ /// cafecafecafecafecafecafecafecafecafecafe = address
243
+ /// 5a5a5a5a = standard
244
+ /// f1f1f1f1 = function
245
+
246
+ // CHECK that we can extract an AllowedCall
247
+ if (ii + 34 > allowedCalls.length) {
248
+ revert InvalidEncodedAllowedCalls(allowedCalls);
249
+ }
250
+
251
+ // extract one AllowedCall at a time
252
+ bytes memory allowedCall = BytesLib.slice(allowedCalls, ii + 2, 32);
253
+
254
+ // 0xxxxxxxxxffffffffffffffffffffffffffffffffffffffffffffffffffffffff
255
+ // (excluding the callTypes) not allowed
256
+ // as equivalent to whitelisting any call (= SUPER permission)
257
+ if (bytes28(bytes32(allowedCall) << 32) == bytes28(type(uint224).max)) {
258
+ revert InvalidWhitelistedCall(controllerAddress);
259
+ }
260
+
261
+ if (
262
+ _isAllowedCallType(allowedCall, requiredCallTypes) &&
263
+ _isAllowedAddress(allowedCall, to) &&
264
+ _isAllowedStandard(allowedCall, to) &&
265
+ _isAllowedFunction(allowedCall, selector)
266
+ ) return;
267
+ }
268
+
269
+ revert NotAllowedCall(controllerAddress, to, selector);
270
+ }
271
+
272
+ /**
273
+ * @dev extract the bytes4 representation of a single bit for the type of call according to the `operationType`
274
+ * @param operationType 0 = CALL, 3 = STATICCALL or 3 = DELEGATECALL
275
+ * @return a bytes4 value containing a single 1 bit for the callType
276
+ */
277
+ function _extractCallType(
278
+ uint256 operationType,
279
+ bytes4 selector,
280
+ uint256 value
281
+ ) internal pure returns (bytes4) {
282
+ bytes4 requiredCallTypes;
283
+
284
+ if (operationType == OPERATION_0_CALL) {
285
+ if (
286
+ // CHECK if we are doing an empty call
287
+ (selector == bytes4(0) && value == 0) ||
288
+ // we do not require callType CALL
289
+ // if we are just transferring value without `data`
290
+ selector != bytes4(0)
291
+ ) {
292
+ requiredCallTypes = _ALLOWEDCALLS_WRITE;
293
+ }
294
+ }
295
+
296
+ if (operationType == OPERATION_3_STATICCALL) requiredCallTypes = _ALLOWEDCALLS_READ;
297
+ if (operationType == OPERATION_4_DELEGATECALL) requiredCallTypes = _ALLOWEDCALLS_EXECUTE;
298
+
299
+ // if there is value being transferred, add the extra bit
300
+ // for the first bit for Value Transfer in the `requiredCallTypes`
301
+ if (value != 0) {
302
+ requiredCallTypes |= _ALLOWEDCALLS_VALUE;
303
+ }
304
+
305
+ return requiredCallTypes;
306
+ }
307
+
308
+ function _extractExecuteParameters(bytes calldata executeCalldata)
309
+ internal
310
+ pure
311
+ returns (
312
+ uint256,
313
+ address,
314
+ uint256,
315
+ bytes4
316
+ )
317
+ {
318
+ uint256 operationType = uint256(bytes32(executeCalldata[4:36]));
319
+ address to = address(bytes20(executeCalldata[48:68]));
320
+ uint256 value = uint256(bytes32(executeCalldata[68:100]));
321
+
322
+ // CHECK if there is at least a 4 bytes function selector
323
+ bytes4 selector = executeCalldata.length >= 168
324
+ ? bytes4(executeCalldata[164:168])
325
+ : bytes4(0);
326
+
327
+ return (operationType, to, value, selector);
328
+ }
329
+
330
+ function _isAllowedAddress(bytes memory allowedCall, address to) internal pure returns (bool) {
331
+ // <offset> = 4 bytes x 8 bits = 32 bits
332
+ //
333
+ // <offset>v----------------address---------------v
334
+ // 0000000ncafecafecafecafecafecafecafecafecafecafe5a5a5a5af1f1f1f1
335
+ address allowedAddress = address(bytes20(bytes32(allowedCall) << 32));
336
+
337
+ // ANY address = 0xffffffffffffffffffffffffffffffffffffffff
338
+ return allowedAddress == address(bytes20(type(uint160).max)) || to == allowedAddress;
339
+ }
340
+
341
+ function _isAllowedStandard(bytes memory allowedCall, address to) internal view returns (bool) {
342
+ // <offset> = 24 bytes x 8 bits = 192 bits
343
+ //
344
+ // standard
345
+ // <----------------<offset>---------------------->v------v
346
+ // 0000000ncafecafecafecafecafecafecafecafecafecafe5a5a5a5af1f1f1f1
347
+ bytes4 allowedStandard = bytes4(bytes32(allowedCall) << 192);
348
+
349
+ // ANY Standard = 0xffffffff
350
+ return
351
+ allowedStandard == bytes4(type(uint32).max) ||
352
+ to.supportsERC165InterfaceUnchecked(allowedStandard);
353
+ }
354
+
355
+ function _isAllowedFunction(bytes memory allowedCall, bytes4 requiredFunction)
356
+ internal
357
+ pure
358
+ returns (bool)
359
+ {
360
+ // <offset> = 28 bytes x 8 bits = 224 bits
361
+ //
362
+ // function
363
+ // <------------------------<offset>---------------------->v------v
364
+ // 0000000ncafecafecafecafecafecafecafecafecafecafe5a5a5a5af1f1f1f1
365
+ bytes4 allowedFunction = bytes4(bytes32(allowedCall) << 224);
366
+
367
+ bool isFunctionCall = requiredFunction != bytes4(0);
368
+
369
+ // ANY function = 0xffffffff
370
+ return
371
+ allowedFunction == bytes4(type(uint32).max) ||
372
+ (isFunctionCall && (requiredFunction == allowedFunction));
373
+ }
374
+
375
+ function _isAllowedCallType(bytes memory allowedCall, bytes4 requiredCallTypes)
376
+ internal
377
+ pure
378
+ returns (bool)
379
+ {
380
+ // extract callType
381
+ //
382
+ // <offset> = 0
383
+ //
384
+ // callType
385
+ // v------v
386
+ // 0000000ncafecafecafecafecafecafecafecafecafecafe5a5a5a5af1f1f1f1
387
+ bytes4 allowedCallType = bytes4(allowedCall);
388
+ return (allowedCallType & requiredCallTypes == requiredCallTypes);
389
+ }
390
+
391
+ /**
392
+ * @dev revert if `controller`'s `addressPermissions` doesn't contain `permissionsRequired`
393
+ * @param controller the caller address
394
+ * @param addressPermissions the caller's permissions BitArray
395
+ * @param permissionRequired the required permission
396
+ */
397
+ function _requirePermissions(
398
+ address controller,
399
+ bytes32 addressPermissions,
400
+ bytes32 permissionRequired
401
+ ) internal pure virtual {
402
+ if (!LSP6Utils.hasPermission(addressPermissions, permissionRequired)) {
403
+ string memory permissionErrorString = LSP6Utils.getPermissionName(permissionRequired);
404
+ revert NotAuthorised(controller, permissionErrorString);
405
+ }
406
+ }
407
+ }
@@ -0,0 +1,25 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.5;
3
+
4
+ // libraries
5
+ import {LSP6Utils} from "../LSP6Utils.sol";
6
+
7
+ // constants
8
+ import {_PERMISSION_CHANGEOWNER} from "../LSP6Constants.sol";
9
+
10
+ // errors
11
+ import {NotAuthorised} from "../LSP6Errors.sol";
12
+
13
+ abstract contract LSP6OwnershipModule {
14
+ function _verifyOwnershipPermissions(address controllerAddress, bytes32 controllerPermissions)
15
+ internal
16
+ pure
17
+ {
18
+ if (!LSP6Utils.hasPermission(controllerPermissions, _PERMISSION_CHANGEOWNER)) {
19
+ string memory permissionErrorString = LSP6Utils.getPermissionName(
20
+ _PERMISSION_CHANGEOWNER
21
+ );
22
+ revert NotAuthorised(controllerAddress, permissionErrorString);
23
+ }
24
+ }
25
+ }