@lukso/lsp-smart-contracts 0.15.0 → 0.16.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.
Files changed (90) hide show
  1. package/README.md +98 -3
  2. package/contracts/LSP11SocialRecovery/ILSP11SocialRecovery.sol +4 -0
  3. package/contracts/LSP11SocialRecovery/LSP11Constants.sol +4 -0
  4. package/contracts/LSP11SocialRecovery/LSP11Errors.sol +4 -0
  5. package/contracts/LSP11SocialRecovery/LSP11SocialRecovery.sol +4 -0
  6. package/contracts/LSP26FollowerSystem/ILSP26FollowerSystem.sol +4 -0
  7. package/contracts/LSP26FollowerSystem/LSP26Constants.sol +4 -0
  8. package/contracts/LSP26FollowerSystem/LSP26Errors.sol +4 -0
  9. package/contracts/LSP26FollowerSystem/LSP26FollowerSystem.sol +4 -0
  10. package/contracts/LSP4DigitalAssetMetadata/LSP4Utils.sol +1 -1
  11. package/contracts/LSP7DigitalAsset/{LSP7DigitalAssetCore.sol → extensions/LSP7Votes.sol} +1 -1
  12. package/contracts/LSP7DigitalAsset/extensions/LSP7VotesInitAbstract.sol +4 -0
  13. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Votes.sol +4 -0
  14. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8VotesInitAbstract.sol +4 -0
  15. package/dist/abi.cjs +13834 -0
  16. package/dist/abi.d.cts +19732 -0
  17. package/dist/abi.d.mts +19732 -0
  18. package/dist/abi.d.ts +19732 -0
  19. package/dist/abi.mjs +13799 -0
  20. package/dist/constants.cjs +20689 -10211
  21. package/dist/constants.d.cts +17476 -6994
  22. package/dist/constants.d.mts +17476 -6994
  23. package/dist/constants.d.ts +17476 -6994
  24. package/dist/constants.mjs +20691 -10213
  25. package/package.json +19 -17
  26. package/artifacts/LSP0ERC725Account.json +0 -676
  27. package/artifacts/LSP0ERC725AccountInit.json +0 -696
  28. package/artifacts/LSP11BasicSocialRecovery.json +0 -509
  29. package/artifacts/LSP11BasicSocialRecoveryInit.json +0 -529
  30. package/artifacts/LSP1UniversalReceiverDelegateUP.json +0 -88
  31. package/artifacts/LSP1UniversalReceiverDelegateVault.json +0 -88
  32. package/artifacts/LSP23LinkedContractsFactory.json +0 -544
  33. package/artifacts/LSP4DigitalAssetMetadata.json +0 -221
  34. package/artifacts/LSP4DigitalAssetMetadataInitAbstract.json +0 -234
  35. package/artifacts/LSP6KeyManager.json +0 -600
  36. package/artifacts/LSP6KeyManagerInit.json +0 -620
  37. package/artifacts/LSP7CappedSupply.json +0 -828
  38. package/artifacts/LSP7CappedSupplyInitAbstract.json +0 -841
  39. package/artifacts/LSP7DigitalAsset.json +0 -805
  40. package/artifacts/LSP7DigitalAssetInitAbstract.json +0 -818
  41. package/artifacts/LSP7Mintable.json +0 -864
  42. package/artifacts/LSP7MintableInit.json +0 -884
  43. package/artifacts/LSP8CappedSupply.json +0 -959
  44. package/artifacts/LSP8CappedSupplyInitAbstract.json +0 -972
  45. package/artifacts/LSP8IdentifiableDigitalAsset.json +0 -936
  46. package/artifacts/LSP8IdentifiableDigitalAssetInitAbstract.json +0 -949
  47. package/artifacts/LSP8Mintable.json +0 -1006
  48. package/artifacts/LSP8MintableInit.json +0 -1026
  49. package/artifacts/LSP9Vault.json +0 -631
  50. package/artifacts/LSP9VaultInit.json +0 -651
  51. package/artifacts/UniversalProfile.json +0 -676
  52. package/artifacts/UniversalProfileInit.json +0 -696
  53. package/contracts/LSP11BasicSocialRecovery/ILSP11BasicSocialRecovery.sol +0 -179
  54. package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecovery.sol +0 -25
  55. package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryCore.sol +0 -340
  56. package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryInit.sol +0 -30
  57. package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryInitAbstract.sol +0 -29
  58. package/contracts/LSP11BasicSocialRecovery/LSP11Constants.sol +0 -6
  59. package/contracts/LSP11BasicSocialRecovery/LSP11Errors.sol +0 -63
  60. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataCore.sol +0 -4
  61. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +0 -4
  62. package/types/@lukso/lsp0-contracts/contracts/LSP0ERC725Account.ts +0 -694
  63. package/types/@lukso/lsp0-contracts/contracts/LSP0ERC725AccountInit.ts +0 -740
  64. package/types/@lukso/lsp1delegate-contracts/contracts/LSP1UniversalReceiverDelegateUP.ts +0 -139
  65. package/types/@lukso/lsp1delegate-contracts/contracts/LSP1UniversalReceiverDelegateVault.ts +0 -139
  66. package/types/@lukso/lsp23-contracts/contracts/LSP23LinkedContractsFactory.ts +0 -448
  67. package/types/@lukso/lsp4-contracts/contracts/LSP4DigitalAssetMetadata.ts +0 -274
  68. package/types/@lukso/lsp4-contracts/contracts/LSP4DigitalAssetMetadataInitAbstract.ts +0 -309
  69. package/types/@lukso/lsp6-contracts/contracts/LSP6KeyManager.ts +0 -355
  70. package/types/@lukso/lsp6-contracts/contracts/LSP6KeyManagerInit.ts +0 -398
  71. package/types/@lukso/lsp7-contracts/contracts/LSP7DigitalAsset.ts +0 -698
  72. package/types/@lukso/lsp7-contracts/contracts/LSP7DigitalAssetInitAbstract.ts +0 -729
  73. package/types/@lukso/lsp7-contracts/contracts/extensions/LSP7CappedSupply.ts +0 -712
  74. package/types/@lukso/lsp7-contracts/contracts/extensions/LSP7CappedSupplyInitAbstract.ts +0 -743
  75. package/types/@lukso/lsp7-contracts/contracts/presets/LSP7Mintable.ts +0 -717
  76. package/types/@lukso/lsp7-contracts/contracts/presets/LSP7MintableInit.ts +0 -779
  77. package/types/@lukso/lsp8-contracts/contracts/LSP8IdentifiableDigitalAsset.ts +0 -778
  78. package/types/@lukso/lsp8-contracts/contracts/LSP8IdentifiableDigitalAssetInitAbstract.ts +0 -813
  79. package/types/@lukso/lsp8-contracts/contracts/extensions/LSP8CappedSupply.ts +0 -792
  80. package/types/@lukso/lsp8-contracts/contracts/extensions/LSP8CappedSupplyInitAbstract.ts +0 -824
  81. package/types/@lukso/lsp8-contracts/contracts/presets/LSP8Mintable.ts +0 -797
  82. package/types/@lukso/lsp8-contracts/contracts/presets/LSP8MintableInit.ts +0 -860
  83. package/types/@lukso/lsp9-contracts/contracts/LSP9Vault.ts +0 -672
  84. package/types/@lukso/lsp9-contracts/contracts/LSP9VaultInit.ts +0 -714
  85. package/types/@lukso/universalprofile-contracts/contracts/UniversalProfile.ts +0 -694
  86. package/types/@lukso/universalprofile-contracts/contracts/UniversalProfileInit.ts +0 -740
  87. package/types/common.ts +0 -131
  88. package/types/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecovery.ts +0 -596
  89. package/types/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryInit.ts +0 -646
  90. package/types/index.ts +0 -18446
@@ -1,179 +0,0 @@
1
- // SPDX-License-Identifier: Apache-2.0
2
- pragma solidity ^0.8.0;
3
-
4
- /**
5
- * @title Interface of the LSP11 - Basic Social Recovery standard, a contract to recover access control into an account.
6
- * @dev Sets permission for a controller address after a recovery process to interact with an ERC725
7
- * contract via the LSP6KeyManager
8
- */
9
- interface ILSP11BasicSocialRecovery {
10
- /**
11
- * @notice Emitted when setting a new guardian for the target
12
- * @param newGuardian The address of the added guardian
13
- */
14
- event GuardianAdded(address indexed newGuardian);
15
-
16
- /**
17
- * @notice Emitted when removing an existing guardian for the target
18
- * @param removedGuardian The address of the guardian removed
19
- */
20
- event GuardianRemoved(address indexed removedGuardian);
21
-
22
- /**
23
- * @notice Emitted when changing the guardian threshold
24
- * @param guardianThreshold The minimum number of selection by guardians needed by a controller to start
25
- * a recovery process
26
- */
27
- event GuardiansThresholdChanged(uint256 indexed guardianThreshold);
28
-
29
- /**
30
- * @notice Emitted when changing the secret hash
31
- * @param secretHash The secret hash used to finish the recovery process
32
- */
33
- event SecretHashChanged(bytes32 indexed secretHash);
34
-
35
- /**
36
- * @notice Emitted when a guardian select a new potentiel controller address for the target
37
- * @param recoveryCounter The current recovery process counter
38
- * @param guardian The address of the guardian
39
- * @param addressSelected The address selected by the guardian
40
- */
41
- event SelectedNewController(
42
- uint256 indexed recoveryCounter,
43
- address indexed guardian,
44
- address indexed addressSelected
45
- );
46
-
47
- /**
48
- * @notice Emitted when the recovery process is finished by the controller who
49
- * reached the guardian threshold and submitted the string that produce the secretHash
50
- * @param recoveryCounter The current recovery process
51
- * @param newController The address of the new controller controlling the target by the KeyManager
52
- * @param guardians The array of addresses containing the guardians of the target
53
- */
54
- event RecoveryProcessSuccessful(
55
- uint256 indexed recoveryCounter,
56
- address indexed newController,
57
- bytes32 indexed newSecretHash,
58
- address[] guardians
59
- );
60
-
61
- /**
62
- * @dev The address of an ERC725 contract where we want to recover
63
- * and set permissions for a controller address
64
- */
65
- function target() external view returns (address);
66
-
67
- /**
68
- * @dev Returns the current recovery counter
69
- * When a recovery process is successfully finished the recovery counter is incremented
70
- */
71
- function getRecoveryCounter() external view returns (uint256);
72
-
73
- /**
74
- * @dev Returns the addresses of all guardians
75
- * The guardians will select an address to be added as a controller
76
- * key for the linked `target` if he reaches the guardian threshold and
77
- * provide the correct string that produce the secretHash
78
- */
79
- function getGuardians() external view returns (address[] memory);
80
-
81
- /**
82
- * @dev Returns TRUE if the address provided is a guardian, FALSE otherwise
83
- * @param _address The address to query
84
- */
85
- function isGuardian(address _address) external view returns (bool);
86
-
87
- /**
88
- * @dev Returns the recovery secret hash
89
- */
90
- function getRecoverySecretHash() external view returns (bytes32);
91
-
92
- /**
93
- * @dev Returns the guardian threshold
94
- * The guardian threshold represents the minimum number of selection by guardians required
95
- * for an address to start a recovery process
96
- */
97
- function getGuardiansThreshold() external view returns (uint256);
98
-
99
- /**
100
- * @dev Returns the address of a controller that a `guardian` selected for in order to recover the target
101
- * @param guardian the address of a guardian to query his selection
102
- * @return the address that `guardian` selected
103
- */
104
- function getGuardianChoice(
105
- address guardian
106
- ) external view returns (address);
107
-
108
- /**
109
- * @dev Adds a guardian of the target
110
- * @dev Can be called only by the owner
111
- * @param newGuardian The address to add as a guardian
112
- */
113
- function addGuardian(address newGuardian) external;
114
-
115
- /**
116
- * @dev Removes a guardian of the target
117
- * @dev Can be called only by the owner
118
- * @param currentGuardian The address of the existing guardian to remove
119
- *
120
- * Requirements:
121
- *
122
- * - The guardians count should be higher or equal to the guardain threshold
123
- */
124
- function removeGuardian(address currentGuardian) external;
125
-
126
- /**
127
- * @dev Sets the hash of the secret string to be provided in `recoverOwnership(..)` function
128
- * @dev Can be called only by the owner
129
- * @param newRecoverSecretHash The hash of the secret string
130
- *
131
- * Requirements:
132
- *
133
- * - `secretHash` cannot be bytes32(0)
134
- */
135
- function setRecoverySecretHash(bytes32 newRecoverSecretHash) external;
136
-
137
- /**
138
- * @dev Sets the minimum number of selection by the guardians required so that an
139
- * address can recover ownership
140
- *
141
- * @dev Can be called only by the owner
142
- * @param guardiansThreshold The threshold to set
143
- *
144
- * Requirements:
145
- * - `guardiansThreshold` cannot be more than the guardians count.
146
- */
147
- function setGuardiansThreshold(uint256 guardiansThreshold) external;
148
-
149
- /**
150
- * @dev select an address to be a potentiel controller address if he reaches
151
- * the guardian threshold and provide the correct secret string
152
- *
153
- * Requirements:
154
- * - only guardians can select an address
155
- *
156
- * @param addressSelected The address selected by the guardian
157
- */
158
- function selectNewController(address addressSelected) external;
159
-
160
- /**
161
- * @dev Recovers the ownership permissions of an address in the linked target
162
- * and increment the recover counter
163
- *
164
- * Requirements
165
- * - the address of the recoverer must have a selection equal or higher than the threshold
166
- * defined in `getGuardiansThreshold(...)`
167
- *
168
- * - must have provided the right `plainSecret` that produces the secret Hash
169
- *
170
- * @param recoverer The address of the recoverer
171
- * @param plainSecret The secret word that produce the secret Hash
172
- * @param newHash The new secret Hash to be used in the next recovery process
173
- */
174
- function recoverOwnership(
175
- address recoverer,
176
- string memory plainSecret,
177
- bytes32 newHash
178
- ) external;
179
- }
@@ -1,25 +0,0 @@
1
- // SPDX-License-Identifier: Apache-2.0
2
- pragma solidity ^0.8.0;
3
-
4
- // modules
5
- import {
6
- OwnableUnset
7
- } from "@erc725/smart-contracts/contracts/custom/OwnableUnset.sol";
8
- import {LSP11BasicSocialRecoveryCore} from "./LSP11BasicSocialRecoveryCore.sol";
9
-
10
- /**
11
- * @title Implementation of LSP11 - Basic Social Recovery standard
12
- * @dev Sets permission for a controller address after a recovery process to interact with an ERC725
13
- * contract via the LSP6KeyManager
14
- */
15
- contract LSP11BasicSocialRecovery is LSP11BasicSocialRecoveryCore {
16
- /**
17
- * @notice Sets the target and the owner addresses
18
- * @param _owner The owner of the LSP11 contract
19
- * @param target_ The address of the ER725 contract to recover
20
- */
21
- constructor(address _owner, address target_) {
22
- OwnableUnset._setOwner(_owner);
23
- _target = target_;
24
- }
25
- }
@@ -1,340 +0,0 @@
1
- // SPDX-License-Identifier: Apache-2.0
2
- pragma solidity ^0.8.4;
3
-
4
- // interfaces
5
- import {ILSP11BasicSocialRecovery} from "./ILSP11BasicSocialRecovery.sol";
6
-
7
- // libraries
8
- import {LSP6Utils} from "@lukso/lsp6-contracts/contracts/LSP6Utils.sol";
9
-
10
- // modules
11
- import {ERC725} from "@erc725/smart-contracts/contracts/ERC725.sol";
12
- import {
13
- OwnableUnset
14
- } from "@erc725/smart-contracts/contracts/custom/OwnableUnset.sol";
15
- import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
16
- import {
17
- EnumerableSet
18
- } from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
19
-
20
- // constants
21
- import {
22
- ALL_REGULAR_PERMISSIONS
23
- } from "@lukso/lsp6-contracts/contracts/LSP6Constants.sol";
24
- import {_INTERFACEID_LSP11} from "./LSP11Constants.sol";
25
- import {
26
- CallerIsNotGuardian,
27
- GuardianAlreadyExist,
28
- GuardianDoNotExist,
29
- GuardiansNumberCannotGoBelowThreshold,
30
- ThresholdCannotBeHigherThanGuardiansNumber,
31
- SecretHashCannotBeZero,
32
- AddressZeroNotAllowed,
33
- ThresholdNotReachedForRecoverer,
34
- WrongPlainSecret
35
- } from "./LSP11Errors.sol";
36
-
37
- /**
38
- * @title Core Implementation of LSP11-BasicSocialRecovery standard
39
- * @dev Sets permission for a controller address after a recovery process to interact with an ERC725
40
- * contract via the LSP6KeyManager
41
- */
42
- abstract contract LSP11BasicSocialRecoveryCore is
43
- OwnableUnset,
44
- ERC165,
45
- ILSP11BasicSocialRecovery
46
- {
47
- using EnumerableSet for EnumerableSet.AddressSet;
48
-
49
- address internal _target;
50
-
51
- // The guardians threshold
52
- uint256 internal _guardiansThreshold;
53
-
54
- // The number of successfull recovery processes
55
- uint256 internal _recoveryCounter;
56
-
57
- // The secret hash to be set by the owner
58
- bytes32 internal _recoverySecretHash;
59
-
60
- // Stores the address selected by a guardian
61
- // in the current `_recoveryCounter`
62
- mapping(uint256 => mapping(address => address)) internal _guardiansChoice;
63
-
64
- // List of guardians addresses
65
- EnumerableSet.AddressSet internal _guardians;
66
-
67
- /**
68
- * @dev Throws if called by any account other than the guardians
69
- */
70
- modifier onlyGuardians() virtual {
71
- if (!_guardians.contains(msg.sender))
72
- revert CallerIsNotGuardian(msg.sender);
73
- _;
74
- }
75
-
76
- /**
77
- * @inheritdoc ERC165
78
- */
79
- function supportsInterface(
80
- bytes4 _interfaceId
81
- ) public view virtual override returns (bool) {
82
- return
83
- _interfaceId == _INTERFACEID_LSP11 ||
84
- super.supportsInterface(_interfaceId);
85
- }
86
-
87
- /**
88
- * @inheritdoc ILSP11BasicSocialRecovery
89
- */
90
- function target() public view virtual override returns (address) {
91
- return _target;
92
- }
93
-
94
- /**
95
- * @inheritdoc ILSP11BasicSocialRecovery
96
- */
97
- function getRecoveryCounter()
98
- public
99
- view
100
- virtual
101
- override
102
- returns (uint256)
103
- {
104
- return _recoveryCounter;
105
- }
106
-
107
- /**
108
- * @inheritdoc ILSP11BasicSocialRecovery
109
- */
110
- function getGuardians()
111
- public
112
- view
113
- virtual
114
- override
115
- returns (address[] memory)
116
- {
117
- return _guardians.values();
118
- }
119
-
120
- /**
121
- * @inheritdoc ILSP11BasicSocialRecovery
122
- */
123
- function isGuardian(
124
- address _address
125
- ) public view virtual override returns (bool) {
126
- return _guardians.contains(_address);
127
- }
128
-
129
- /**
130
- * @inheritdoc ILSP11BasicSocialRecovery
131
- */
132
- function getGuardiansThreshold()
133
- public
134
- view
135
- virtual
136
- override
137
- returns (uint256)
138
- {
139
- return _guardiansThreshold;
140
- }
141
-
142
- /**
143
- * @inheritdoc ILSP11BasicSocialRecovery
144
- */
145
- function getRecoverySecretHash()
146
- public
147
- view
148
- virtual
149
- override
150
- returns (bytes32)
151
- {
152
- return _recoverySecretHash;
153
- }
154
-
155
- /**
156
- * @inheritdoc ILSP11BasicSocialRecovery
157
- */
158
- function getGuardianChoice(
159
- address guardian
160
- ) public view virtual override returns (address) {
161
- return _guardiansChoice[_recoveryCounter][guardian];
162
- }
163
-
164
- /**
165
- * @inheritdoc ILSP11BasicSocialRecovery
166
- */
167
- function addGuardian(
168
- address newGuardian
169
- ) public virtual override onlyOwner {
170
- if (_guardians.contains(newGuardian))
171
- revert GuardianAlreadyExist(newGuardian);
172
-
173
- _guardians.add(newGuardian);
174
- emit GuardianAdded(newGuardian);
175
- }
176
-
177
- /**
178
- * @inheritdoc ILSP11BasicSocialRecovery
179
- */
180
- function removeGuardian(
181
- address existingGuardian
182
- ) public virtual override onlyOwner {
183
- if (!_guardians.contains(existingGuardian))
184
- revert GuardianDoNotExist(existingGuardian);
185
- if (_guardians.length() == _guardiansThreshold)
186
- revert GuardiansNumberCannotGoBelowThreshold(_guardiansThreshold);
187
-
188
- _guardians.remove(existingGuardian);
189
- emit GuardianRemoved(existingGuardian);
190
- }
191
-
192
- /**
193
- * @inheritdoc ILSP11BasicSocialRecovery
194
- */
195
- function setGuardiansThreshold(
196
- uint256 newThreshold
197
- ) public virtual override onlyOwner {
198
- if (newThreshold > _guardians.length())
199
- revert ThresholdCannotBeHigherThanGuardiansNumber(
200
- newThreshold,
201
- _guardians.length()
202
- );
203
-
204
- _guardiansThreshold = newThreshold;
205
- emit GuardiansThresholdChanged(newThreshold);
206
- }
207
-
208
- /**
209
- * @inheritdoc ILSP11BasicSocialRecovery
210
- * @dev Throws if hash provided is bytes32(0)
211
- */
212
- function setRecoverySecretHash(
213
- bytes32 newRecoverSecretHash
214
- ) public virtual override onlyOwner {
215
- if (newRecoverSecretHash == bytes32(0)) revert SecretHashCannotBeZero();
216
-
217
- _recoverySecretHash = newRecoverSecretHash;
218
- emit SecretHashChanged(newRecoverSecretHash);
219
- }
220
-
221
- /**
222
- * @inheritdoc ILSP11BasicSocialRecovery
223
- */
224
- function selectNewController(
225
- address addressSelected
226
- ) public virtual override onlyGuardians {
227
- uint256 currentRecoveryCounter = _recoveryCounter;
228
-
229
- _guardiansChoice[currentRecoveryCounter][msg.sender] = addressSelected;
230
- emit SelectedNewController(
231
- currentRecoveryCounter,
232
- msg.sender,
233
- addressSelected
234
- );
235
- }
236
-
237
- /**
238
- * @inheritdoc ILSP11BasicSocialRecovery
239
- */
240
- function recoverOwnership(
241
- address recoverer,
242
- string memory plainSecret,
243
- bytes32 newSecretHash
244
- ) public virtual override {
245
- // caching storage variables
246
- uint256 currentRecoveryCounter = _recoveryCounter;
247
- address[] memory guardians = _guardians.values();
248
- address target_ = _target;
249
-
250
- _validateRequirements(
251
- recoverer,
252
- currentRecoveryCounter,
253
- plainSecret,
254
- newSecretHash,
255
- guardians
256
- );
257
-
258
- _recoveryCounter++;
259
- _recoverySecretHash = newSecretHash;
260
- emit SecretHashChanged(newSecretHash);
261
-
262
- address keyManager = ERC725(target_).owner();
263
-
264
- // Setting permissions for `recoverer`
265
- (bytes32[] memory keys, bytes[] memory values) = LSP6Utils
266
- .generateNewPermissionsKeys(
267
- ERC725(target_),
268
- recoverer,
269
- ALL_REGULAR_PERMISSIONS
270
- );
271
-
272
- LSP6Utils.setDataViaKeyManager(keyManager, keys, values);
273
-
274
- emit RecoveryProcessSuccessful(
275
- currentRecoveryCounter,
276
- recoverer,
277
- newSecretHash,
278
- guardians
279
- );
280
-
281
- _cleanStorage(currentRecoveryCounter, guardians.length, guardians);
282
- }
283
-
284
- /**
285
- * @dev The number of guardians should be reasonable, as the validation method
286
- * is using a loop to check the selection of each guardian
287
- *
288
- * Throws if:
289
- * - The address trying to recover didn't reach the guardiansThreshold
290
- * - The new hash being set is bytes32(0)
291
- * - The secret word provided is incorrect
292
- */
293
- function _validateRequirements(
294
- address recoverer,
295
- uint256 currentRecoveryCounter,
296
- string memory plainSecret,
297
- bytes32 newHash,
298
- address[] memory guardians
299
- ) internal view virtual {
300
- if (recoverer == address(0)) revert AddressZeroNotAllowed();
301
- uint256 callerSelections;
302
-
303
- unchecked {
304
- for (uint256 i; i < guardians.length; i++) {
305
- if (
306
- _guardiansChoice[currentRecoveryCounter][guardians[i]] ==
307
- recoverer
308
- ) callerSelections++;
309
- }
310
- }
311
-
312
- uint256 guardiansThreshold = _guardiansThreshold;
313
-
314
- if (callerSelections < guardiansThreshold)
315
- revert ThresholdNotReachedForRecoverer(
316
- recoverer,
317
- callerSelections,
318
- guardiansThreshold
319
- );
320
- if (newHash == bytes32(0)) revert SecretHashCannotBeZero();
321
- if (keccak256(abi.encodePacked(plainSecret)) != _recoverySecretHash)
322
- revert WrongPlainSecret();
323
- }
324
-
325
- /**
326
- * @dev Remove the guardians choice after a successfull recovery process
327
- * To avoid keeping unnecessary state
328
- */
329
- function _cleanStorage(
330
- uint256 recoveryCounter,
331
- uint256 guardiansLength,
332
- address[] memory guardians
333
- ) internal virtual {
334
- unchecked {
335
- for (uint256 i; i < guardiansLength; i++) {
336
- delete _guardiansChoice[recoveryCounter][guardians[i]];
337
- }
338
- }
339
- }
340
- }
@@ -1,30 +0,0 @@
1
- // SPDX-License-Identifier: Apache-2.0
2
- pragma solidity ^0.8.0;
3
-
4
- // modules
5
- import {
6
- LSP11BasicSocialRecoveryInitAbstract
7
- } from "./LSP11BasicSocialRecoveryInitAbstract.sol";
8
-
9
- /**
10
- * @title Deployable Proxy Implementation of LSP11 - Basic Social Recovery standard
11
- * @dev Sets permission for a controller address after a recovery process to interact with an ERC725
12
- * contract via the LSP6KeyManager
13
- */
14
- contract LSP11BasicSocialRecoveryInit is LSP11BasicSocialRecoveryInitAbstract {
15
- constructor() {
16
- _disableInitializers();
17
- }
18
-
19
- /**
20
- * @notice Sets the target and the owner addresses
21
- * @param _owner The owner of the LSP11 contract
22
- * @param target_ The address of the ER725 contract to recover
23
- */
24
- function initialize(
25
- address target_,
26
- address _owner
27
- ) public virtual initializer {
28
- LSP11BasicSocialRecoveryInitAbstract._initialize(target_, _owner);
29
- }
30
- }
@@ -1,29 +0,0 @@
1
- // SPDX-License-Identifier: Apache-2.0
2
- pragma solidity ^0.8.0;
3
-
4
- // modules
5
- import {
6
- Initializable
7
- } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
8
- import {
9
- OwnableUnset
10
- } from "@erc725/smart-contracts/contracts/custom/OwnableUnset.sol";
11
- import {LSP11BasicSocialRecoveryCore} from "./LSP11BasicSocialRecoveryCore.sol";
12
-
13
- /**
14
- * @title Inheritable Proxy Implementation of LSP11 - Basic Social Recovery standard
15
- * @dev Sets permission for a controller address after a recovery process to interact with an ERC725
16
- * contract via the LSP6KeyManager
17
- */
18
- contract LSP11BasicSocialRecoveryInitAbstract is
19
- Initializable,
20
- LSP11BasicSocialRecoveryCore
21
- {
22
- function _initialize(
23
- address _owner,
24
- address target_
25
- ) internal virtual onlyInitializing {
26
- OwnableUnset._setOwner(_owner);
27
- _target = target_;
28
- }
29
- }
@@ -1,6 +0,0 @@
1
- // SPDX-License-Identifier: Apache-2.0
2
- pragma solidity ^0.8.0;
3
-
4
- // --- ERC165 interface ids
5
-
6
- bytes4 constant _INTERFACEID_LSP11 = 0x049a28f1;
@@ -1,63 +0,0 @@
1
- // SPDX-License-Identifier: Apache-2.0
2
- pragma solidity ^0.8.0;
3
-
4
- // --- Errors
5
-
6
- /**
7
- * @dev reverts when the caller is not a guardian
8
- */
9
- error CallerIsNotGuardian(address caller);
10
-
11
- /**
12
- * @dev reverts when adding an already existing guardian
13
- */
14
- error GuardianAlreadyExist(address addressToAdd);
15
-
16
- /**
17
- * @dev reverts when removing a non-existing guardian
18
- */
19
- error GuardianDoNotExist(address addressToRemove);
20
-
21
- /**
22
- * @dev reverts when removing a guardian and the threshold
23
- * is equal to the number of guardians
24
- */
25
- error GuardiansNumberCannotGoBelowThreshold(uint256 guardianThreshold);
26
-
27
- /**
28
- * @dev reverts when setting the guardians threshold to a number
29
- * higher than the guardians number
30
- */
31
- error ThresholdCannotBeHigherThanGuardiansNumber(
32
- uint256 thresholdGiven,
33
- uint256 guardianNumber
34
- );
35
-
36
- /**
37
- * @dev reverts when the secret hash provided is equal to bytes32(0)
38
- */
39
- error SecretHashCannotBeZero();
40
-
41
- /**
42
- * @dev reverts when `recoverOwnership(..)` is called with a recoverer that didn't reach
43
- * the guardians threshold
44
- * @param recoverer The address of the recoverer
45
- * @param selections The number of selections that the recoverer have
46
- * @param guardiansThreshold The minimum number of selection needed
47
- */
48
- error ThresholdNotReachedForRecoverer(
49
- address recoverer,
50
- uint256 selections,
51
- uint256 guardiansThreshold
52
- );
53
-
54
- /**
55
- * @dev reverts when the plain secret produce a different hash than the
56
- * secret hash originally set
57
- */
58
- error WrongPlainSecret();
59
-
60
- /**
61
- * @dev reverts when the address zero calls `recoverOwnership(..)` function
62
- */
63
- error AddressZeroNotAllowed();
@@ -1,4 +0,0 @@
1
- // SPDX-License-Identifier: Apache-2.0
2
- pragma solidity ^0.8.4;
3
-
4
- import "@lukso/lsp4-contracts/contracts/LSP4DigitalAssetMetadataCore.sol";
@@ -1,4 +0,0 @@
1
- // SPDX-License-Identifier: Apache-2.0
2
- pragma solidity ^0.8.12;
3
-
4
- import "@lukso/lsp8-contracts/contracts/LSP8IdentifiableDigitalAssetCore.sol";