@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
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
pragma solidity ^0.8.4;
|
|
3
3
|
|
|
4
4
|
// modules
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
LSP0ERC725AccountInitAbstract
|
|
7
|
+
} from "./LSP0ERC725AccountInitAbstract.sol";
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* @title Deployable Proxy Implementation of LSP0-ERC725Account Standard
|
|
@@ -57,7 +59,9 @@ contract LSP0ERC725AccountInit is LSP0ERC725AccountInitAbstract {
|
|
|
57
59
|
*
|
|
58
60
|
* @param initialOwner the owner of the contract
|
|
59
61
|
*/
|
|
60
|
-
function initialize(
|
|
62
|
+
function initialize(
|
|
63
|
+
address initialOwner
|
|
64
|
+
) external payable virtual initializer {
|
|
61
65
|
LSP0ERC725AccountInitAbstract._initialize(initialOwner);
|
|
62
66
|
}
|
|
63
67
|
}
|
|
@@ -3,8 +3,12 @@ pragma solidity ^0.8.4;
|
|
|
3
3
|
|
|
4
4
|
// modules
|
|
5
5
|
import {LSP0ERC725AccountCore} from "./LSP0ERC725AccountCore.sol";
|
|
6
|
-
import {
|
|
7
|
-
|
|
6
|
+
import {
|
|
7
|
+
Initializable
|
|
8
|
+
} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
|
|
9
|
+
import {
|
|
10
|
+
OwnableUnset
|
|
11
|
+
} from "@erc725/smart-contracts/contracts/custom/OwnableUnset.sol";
|
|
8
12
|
|
|
9
13
|
/**
|
|
10
14
|
* @title Inheritable Proxy Implementation of LSP0-ERC725Account Standard
|
|
@@ -37,7 +41,10 @@ import {OwnableUnset} from "@erc725/smart-contracts/contracts/custom/OwnableUnse
|
|
|
37
41
|
* - Verifying calls on the owner to allow unified and standard interaction with the account using LSP20
|
|
38
42
|
* https://github.com/lukso-network/LIPs/blob/main/LSPs/LSP-20-CallVerification.md
|
|
39
43
|
*/
|
|
40
|
-
abstract contract LSP0ERC725AccountInitAbstract is
|
|
44
|
+
abstract contract LSP0ERC725AccountInitAbstract is
|
|
45
|
+
Initializable,
|
|
46
|
+
LSP0ERC725AccountCore
|
|
47
|
+
{
|
|
41
48
|
/**
|
|
42
49
|
* @dev Set `initialOwner` as the contract owner. ERC725X & ERC725Y parent contracts
|
|
43
50
|
* are not initialised as they don't have non-zero initial state.
|
|
@@ -49,7 +56,9 @@ abstract contract LSP0ERC725AccountInitAbstract is Initializable, LSP0ERC725Acco
|
|
|
49
56
|
*
|
|
50
57
|
* @param initialOwner the owner of the contract
|
|
51
58
|
*/
|
|
52
|
-
function _initialize(
|
|
59
|
+
function _initialize(
|
|
60
|
+
address initialOwner
|
|
61
|
+
) internal virtual onlyInitializing {
|
|
53
62
|
if (msg.value != 0) {
|
|
54
63
|
emit ValueReceived(msg.sender, msg.value);
|
|
55
64
|
}
|
|
@@ -21,11 +21,9 @@ library LSP0Utils {
|
|
|
21
21
|
* @param erc725YStorage a reference to the ERC725Y storage mapping.
|
|
22
22
|
* @return the bytes value stored under the `LSP1UniversalReceiverDelegate` data key.
|
|
23
23
|
*/
|
|
24
|
-
function getLSP1DelegateValue(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
returns (bytes memory)
|
|
28
|
-
{
|
|
24
|
+
function getLSP1DelegateValue(
|
|
25
|
+
mapping(bytes32 => bytes) storage erc725YStorage
|
|
26
|
+
) internal view returns (bytes memory) {
|
|
29
27
|
return erc725YStorage[_LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY];
|
|
30
28
|
}
|
|
31
29
|
|
|
@@ -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
|
|
|
7
9
|
// libraries
|
|
8
10
|
import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol";
|
|
@@ -26,7 +28,10 @@ import "../LSP9Vault/LSP9Constants.sol";
|
|
|
26
28
|
* @param invalidValueStored the invalid value stored under the LSP10ReceivedVaults[] data key
|
|
27
29
|
* @param invalidValueLength the invalid number of bytes stored under the LSP10ReceivedVaults[] data key (MUST be 16 bytes long)
|
|
28
30
|
*/
|
|
29
|
-
error InvalidLSP10ReceivedVaultsArrayLength(
|
|
31
|
+
error InvalidLSP10ReceivedVaultsArrayLength(
|
|
32
|
+
bytes invalidValueStored,
|
|
33
|
+
uint256 invalidValueLength
|
|
34
|
+
);
|
|
30
35
|
|
|
31
36
|
/**
|
|
32
37
|
* @dev reverts when the `LSP10Vaults[]` array reaches its maximum limit (max(uint128))
|
|
@@ -88,7 +93,10 @@ library LSP10Utils {
|
|
|
88
93
|
values[0] = bytes.concat(bytes16(newArrayLength));
|
|
89
94
|
|
|
90
95
|
// store the address of the vault under the element key in the array
|
|
91
|
-
keys[1] = LSP2Utils.generateArrayElementKeyAtIndex(
|
|
96
|
+
keys[1] = LSP2Utils.generateArrayElementKeyAtIndex(
|
|
97
|
+
_LSP10_VAULTS_ARRAY_KEY,
|
|
98
|
+
oldArrayLength
|
|
99
|
+
);
|
|
92
100
|
values[1] = bytes.concat(bytes20(vault));
|
|
93
101
|
|
|
94
102
|
// store the interfaceId and the location in the array of the asset
|
|
@@ -110,7 +118,9 @@ library LSP10Utils {
|
|
|
110
118
|
uint128 vaultIndex
|
|
111
119
|
) internal view returns (bytes32[] memory keys, bytes[] memory values) {
|
|
112
120
|
IERC725Y account = IERC725Y(sender);
|
|
113
|
-
bytes memory lsp10VaultsCountValue = getLSP10ReceivedVaultsCount(
|
|
121
|
+
bytes memory lsp10VaultsCountValue = getLSP10ReceivedVaultsCount(
|
|
122
|
+
account
|
|
123
|
+
);
|
|
114
124
|
|
|
115
125
|
if (lsp10VaultsCountValue.length != 16) {
|
|
116
126
|
revert InvalidLSP10ReceivedVaultsArrayLength({
|
|
@@ -184,13 +194,16 @@ library LSP10Utils {
|
|
|
184
194
|
// with data Keys/values of the vault to remove
|
|
185
195
|
|
|
186
196
|
// Generate the element key of the last vault in the array
|
|
187
|
-
bytes32 lastVaultInArrayKey = LSP2Utils
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
197
|
+
bytes32 lastVaultInArrayKey = LSP2Utils
|
|
198
|
+
.generateArrayElementKeyAtIndex(
|
|
199
|
+
_LSP10_VAULTS_ARRAY_KEY,
|
|
200
|
+
newArrayLength
|
|
201
|
+
);
|
|
191
202
|
|
|
192
203
|
// Get the address of the vault from the element key of the last vault in the array
|
|
193
|
-
bytes20 lastVaultInArrayAddress = bytes20(
|
|
204
|
+
bytes20 lastVaultInArrayAddress = bytes20(
|
|
205
|
+
account.getData(lastVaultInArrayKey)
|
|
206
|
+
);
|
|
194
207
|
|
|
195
208
|
// Generate the map key of the last vault in the array
|
|
196
209
|
bytes32 lastVaultInArrayMapKey = LSP2Utils.generateMappingKey(
|
|
@@ -217,7 +230,9 @@ library LSP10Utils {
|
|
|
217
230
|
}
|
|
218
231
|
}
|
|
219
232
|
|
|
220
|
-
function getLSP10ReceivedVaultsCount(
|
|
233
|
+
function getLSP10ReceivedVaultsCount(
|
|
234
|
+
IERC725Y account
|
|
235
|
+
) internal view returns (bytes memory) {
|
|
221
236
|
return account.getData(_LSP10_VAULTS_ARRAY_KEY);
|
|
222
237
|
}
|
|
223
238
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
pragma solidity ^0.8.0;
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* @title
|
|
5
|
+
* @title Interface of the LSP11 - Basic Social Recovery standard, a contract to recover access control into an account.
|
|
6
6
|
* @dev Sets permission for a controller address after a recovery process to interact with an ERC725
|
|
7
7
|
* contract via the LSP6KeyManager
|
|
8
8
|
*/
|
|
@@ -101,7 +101,9 @@ interface ILSP11BasicSocialRecovery {
|
|
|
101
101
|
* @param guardian the address of a guardian to query his selection
|
|
102
102
|
* @return the address that `guardian` selected
|
|
103
103
|
*/
|
|
104
|
-
function getGuardianChoice(
|
|
104
|
+
function getGuardianChoice(
|
|
105
|
+
address guardian
|
|
106
|
+
) external view returns (address);
|
|
105
107
|
|
|
106
108
|
/**
|
|
107
109
|
* @dev Adds a guardian of the target
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
pragma solidity ^0.8.0;
|
|
3
3
|
|
|
4
4
|
// modules
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
OwnableUnset
|
|
7
|
+
} from "@erc725/smart-contracts/contracts/custom/OwnableUnset.sol";
|
|
6
8
|
import {LSP11BasicSocialRecoveryCore} from "./LSP11BasicSocialRecoveryCore.sol";
|
|
7
9
|
|
|
8
10
|
/**
|
|
@@ -9,9 +9,13 @@ import {LSP6Utils} from "../LSP6KeyManager/LSP6Utils.sol";
|
|
|
9
9
|
|
|
10
10
|
// modules
|
|
11
11
|
import {ERC725} from "@erc725/smart-contracts/contracts/ERC725.sol";
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
OwnableUnset
|
|
14
|
+
} from "@erc725/smart-contracts/contracts/custom/OwnableUnset.sol";
|
|
13
15
|
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
|
|
14
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
EnumerableSet
|
|
18
|
+
} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
|
15
19
|
|
|
16
20
|
// constants
|
|
17
21
|
import {ALL_REGULAR_PERMISSIONS} from "../LSP6KeyManager/LSP6Constants.sol";
|
|
@@ -23,7 +27,11 @@ import "./LSP11Errors.sol";
|
|
|
23
27
|
* @dev Sets permission for a controller address after a recovery process to interact with an ERC725
|
|
24
28
|
* contract via the LSP6KeyManager
|
|
25
29
|
*/
|
|
26
|
-
abstract contract LSP11BasicSocialRecoveryCore is
|
|
30
|
+
abstract contract LSP11BasicSocialRecoveryCore is
|
|
31
|
+
OwnableUnset,
|
|
32
|
+
ERC165,
|
|
33
|
+
ILSP11BasicSocialRecovery
|
|
34
|
+
{
|
|
27
35
|
using EnumerableSet for EnumerableSet.AddressSet;
|
|
28
36
|
|
|
29
37
|
address internal _target;
|
|
@@ -48,15 +56,20 @@ abstract contract LSP11BasicSocialRecoveryCore is OwnableUnset, ERC165, ILSP11Ba
|
|
|
48
56
|
* @dev Throws if called by any account other than the guardians
|
|
49
57
|
*/
|
|
50
58
|
modifier onlyGuardians() virtual {
|
|
51
|
-
if (!_guardians.contains(msg.sender))
|
|
59
|
+
if (!_guardians.contains(msg.sender))
|
|
60
|
+
revert CallerIsNotGuardian(msg.sender);
|
|
52
61
|
_;
|
|
53
62
|
}
|
|
54
63
|
|
|
55
64
|
/**
|
|
56
65
|
* @inheritdoc ERC165
|
|
57
66
|
*/
|
|
58
|
-
function supportsInterface(
|
|
59
|
-
|
|
67
|
+
function supportsInterface(
|
|
68
|
+
bytes4 _interfaceId
|
|
69
|
+
) public view virtual override returns (bool) {
|
|
70
|
+
return
|
|
71
|
+
_interfaceId == _INTERFACEID_LSP11 ||
|
|
72
|
+
super.supportsInterface(_interfaceId);
|
|
60
73
|
}
|
|
61
74
|
|
|
62
75
|
/**
|
|
@@ -104,7 +117,9 @@ abstract contract LSP11BasicSocialRecoveryCore is OwnableUnset, ERC165, ILSP11Ba
|
|
|
104
117
|
/**
|
|
105
118
|
* @inheritdoc ILSP11BasicSocialRecovery
|
|
106
119
|
*/
|
|
107
|
-
function getGuardianChoice(
|
|
120
|
+
function getGuardianChoice(
|
|
121
|
+
address guardian
|
|
122
|
+
) public view virtual returns (address) {
|
|
108
123
|
return _guardiansChoice[_recoveryCounter][guardian];
|
|
109
124
|
}
|
|
110
125
|
|
|
@@ -112,7 +127,8 @@ abstract contract LSP11BasicSocialRecoveryCore is OwnableUnset, ERC165, ILSP11Ba
|
|
|
112
127
|
* @inheritdoc ILSP11BasicSocialRecovery
|
|
113
128
|
*/
|
|
114
129
|
function addGuardian(address newGuardian) public virtual onlyOwner {
|
|
115
|
-
if (_guardians.contains(newGuardian))
|
|
130
|
+
if (_guardians.contains(newGuardian))
|
|
131
|
+
revert GuardianAlreadyExist(newGuardian);
|
|
116
132
|
|
|
117
133
|
_guardians.add(newGuardian);
|
|
118
134
|
emit GuardianAdded(newGuardian);
|
|
@@ -122,7 +138,8 @@ abstract contract LSP11BasicSocialRecoveryCore is OwnableUnset, ERC165, ILSP11Ba
|
|
|
122
138
|
* @inheritdoc ILSP11BasicSocialRecovery
|
|
123
139
|
*/
|
|
124
140
|
function removeGuardian(address existingGuardian) public virtual onlyOwner {
|
|
125
|
-
if (!_guardians.contains(existingGuardian))
|
|
141
|
+
if (!_guardians.contains(existingGuardian))
|
|
142
|
+
revert GuardianDoNotExist(existingGuardian);
|
|
126
143
|
if (_guardians.length() == _guardiansThreshold)
|
|
127
144
|
revert GuardiansNumberCannotGoBelowThreshold(_guardiansThreshold);
|
|
128
145
|
|
|
@@ -133,9 +150,14 @@ abstract contract LSP11BasicSocialRecoveryCore is OwnableUnset, ERC165, ILSP11Ba
|
|
|
133
150
|
/**
|
|
134
151
|
* @inheritdoc ILSP11BasicSocialRecovery
|
|
135
152
|
*/
|
|
136
|
-
function setGuardiansThreshold(
|
|
153
|
+
function setGuardiansThreshold(
|
|
154
|
+
uint256 newThreshold
|
|
155
|
+
) public virtual onlyOwner {
|
|
137
156
|
if (newThreshold > _guardians.length())
|
|
138
|
-
revert ThresholdCannotBeHigherThanGuardiansNumber(
|
|
157
|
+
revert ThresholdCannotBeHigherThanGuardiansNumber(
|
|
158
|
+
newThreshold,
|
|
159
|
+
_guardians.length()
|
|
160
|
+
);
|
|
139
161
|
|
|
140
162
|
_guardiansThreshold = newThreshold;
|
|
141
163
|
emit GuardiansThresholdChanged(newThreshold);
|
|
@@ -145,7 +167,9 @@ abstract contract LSP11BasicSocialRecoveryCore is OwnableUnset, ERC165, ILSP11Ba
|
|
|
145
167
|
* @inheritdoc ILSP11BasicSocialRecovery
|
|
146
168
|
* @dev Throws if hash provided is bytes32(0)
|
|
147
169
|
*/
|
|
148
|
-
function setRecoverySecretHash(
|
|
170
|
+
function setRecoverySecretHash(
|
|
171
|
+
bytes32 newRecoverSecretHash
|
|
172
|
+
) public virtual onlyOwner {
|
|
149
173
|
if (newRecoverSecretHash == bytes32(0)) revert SecretHashCannotBeZero();
|
|
150
174
|
|
|
151
175
|
_recoverySecretHash = newRecoverSecretHash;
|
|
@@ -155,11 +179,17 @@ abstract contract LSP11BasicSocialRecoveryCore is OwnableUnset, ERC165, ILSP11Ba
|
|
|
155
179
|
/**
|
|
156
180
|
* @inheritdoc ILSP11BasicSocialRecovery
|
|
157
181
|
*/
|
|
158
|
-
function selectNewController(
|
|
182
|
+
function selectNewController(
|
|
183
|
+
address addressSelected
|
|
184
|
+
) public virtual onlyGuardians {
|
|
159
185
|
uint256 currentRecoveryCounter = _recoveryCounter;
|
|
160
186
|
|
|
161
187
|
_guardiansChoice[currentRecoveryCounter][msg.sender] = addressSelected;
|
|
162
|
-
emit SelectedNewController(
|
|
188
|
+
emit SelectedNewController(
|
|
189
|
+
currentRecoveryCounter,
|
|
190
|
+
msg.sender,
|
|
191
|
+
addressSelected
|
|
192
|
+
);
|
|
163
193
|
}
|
|
164
194
|
|
|
165
195
|
/**
|
|
@@ -190,15 +220,21 @@ abstract contract LSP11BasicSocialRecoveryCore is OwnableUnset, ERC165, ILSP11Ba
|
|
|
190
220
|
address keyManager = ERC725(target_).owner();
|
|
191
221
|
|
|
192
222
|
// Setting permissions for `recoverer`
|
|
193
|
-
(bytes32[] memory keys, bytes[] memory values) = LSP6Utils
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
223
|
+
(bytes32[] memory keys, bytes[] memory values) = LSP6Utils
|
|
224
|
+
.generateNewPermissionsKeys(
|
|
225
|
+
ERC725(target_),
|
|
226
|
+
recoverer,
|
|
227
|
+
ALL_REGULAR_PERMISSIONS
|
|
228
|
+
);
|
|
198
229
|
|
|
199
230
|
LSP6Utils.setDataViaKeyManager(keyManager, keys, values);
|
|
200
231
|
|
|
201
|
-
emit RecoveryProcessSuccessful(
|
|
232
|
+
emit RecoveryProcessSuccessful(
|
|
233
|
+
currentRecoveryCounter,
|
|
234
|
+
recoverer,
|
|
235
|
+
newSecretHash,
|
|
236
|
+
guardians
|
|
237
|
+
);
|
|
202
238
|
|
|
203
239
|
_cleanStorage(currentRecoveryCounter, guardians.length, guardians);
|
|
204
240
|
}
|
|
@@ -224,15 +260,21 @@ abstract contract LSP11BasicSocialRecoveryCore is OwnableUnset, ERC165, ILSP11Ba
|
|
|
224
260
|
|
|
225
261
|
unchecked {
|
|
226
262
|
for (uint256 i; i < guardians.length; i++) {
|
|
227
|
-
if (
|
|
228
|
-
|
|
263
|
+
if (
|
|
264
|
+
_guardiansChoice[currentRecoveryCounter][guardians[i]] ==
|
|
265
|
+
recoverer
|
|
266
|
+
) callerSelections++;
|
|
229
267
|
}
|
|
230
268
|
}
|
|
231
269
|
|
|
232
270
|
uint256 guardiansThreshold = _guardiansThreshold;
|
|
233
271
|
|
|
234
272
|
if (callerSelections < guardiansThreshold)
|
|
235
|
-
revert ThresholdNotReachedForRecoverer(
|
|
273
|
+
revert ThresholdNotReachedForRecoverer(
|
|
274
|
+
recoverer,
|
|
275
|
+
callerSelections,
|
|
276
|
+
guardiansThreshold
|
|
277
|
+
);
|
|
236
278
|
if (newHash == bytes32(0)) revert SecretHashCannotBeZero();
|
|
237
279
|
if (keccak256(abi.encodePacked(plainSecret)) != _recoverySecretHash)
|
|
238
280
|
revert WrongPlainSecret();
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
pragma solidity ^0.8.0;
|
|
3
3
|
|
|
4
4
|
// modules
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
LSP11BasicSocialRecoveryInitAbstract
|
|
7
|
+
} from "./LSP11BasicSocialRecoveryInitAbstract.sol";
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* @title Deployable Proxy Implementation of LSP11 - Basic Social Recovery standard
|
|
@@ -19,7 +21,10 @@ contract LSP11BasicSocialRecoveryInit is LSP11BasicSocialRecoveryInitAbstract {
|
|
|
19
21
|
* @param _owner The owner of the LSP11 contract
|
|
20
22
|
* @param target_ The address of the ER725 contract to recover
|
|
21
23
|
*/
|
|
22
|
-
function initialize(
|
|
24
|
+
function initialize(
|
|
25
|
+
address target_,
|
|
26
|
+
address _owner
|
|
27
|
+
) public virtual initializer {
|
|
23
28
|
LSP11BasicSocialRecoveryInitAbstract._initialize(target_, _owner);
|
|
24
29
|
}
|
|
25
30
|
}
|
|
@@ -2,8 +2,12 @@
|
|
|
2
2
|
pragma solidity ^0.8.0;
|
|
3
3
|
|
|
4
4
|
// modules
|
|
5
|
-
import {
|
|
6
|
-
|
|
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";
|
|
7
11
|
import {LSP11BasicSocialRecoveryCore} from "./LSP11BasicSocialRecoveryCore.sol";
|
|
8
12
|
|
|
9
13
|
/**
|
|
@@ -11,8 +15,14 @@ import {LSP11BasicSocialRecoveryCore} from "./LSP11BasicSocialRecoveryCore.sol";
|
|
|
11
15
|
* @dev Sets permission for a controller address after a recovery process to interact with an ERC725
|
|
12
16
|
* contract via the LSP6KeyManager
|
|
13
17
|
*/
|
|
14
|
-
contract LSP11BasicSocialRecoveryInitAbstract is
|
|
15
|
-
|
|
18
|
+
contract LSP11BasicSocialRecoveryInitAbstract is
|
|
19
|
+
Initializable,
|
|
20
|
+
LSP11BasicSocialRecoveryCore
|
|
21
|
+
{
|
|
22
|
+
function _initialize(
|
|
23
|
+
address _owner,
|
|
24
|
+
address target_
|
|
25
|
+
) internal virtual onlyInitializing {
|
|
16
26
|
OwnableUnset._setOwner(_owner);
|
|
17
27
|
_target = target_;
|
|
18
28
|
}
|
|
@@ -28,7 +28,10 @@ error GuardiansNumberCannotGoBelowThreshold(uint256 guardianThreshold);
|
|
|
28
28
|
* @dev reverts when setting the guardians threshold to a number
|
|
29
29
|
* higher than the guardians number
|
|
30
30
|
*/
|
|
31
|
-
error ThresholdCannotBeHigherThanGuardiansNumber(
|
|
31
|
+
error ThresholdCannotBeHigherThanGuardiansNumber(
|
|
32
|
+
uint256 thresholdGiven,
|
|
33
|
+
uint256 guardianNumber
|
|
34
|
+
);
|
|
32
35
|
|
|
33
36
|
/**
|
|
34
37
|
* @dev reverts when the secret hash provided is equal to bytes32(0)
|
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
pragma solidity ^0.8.4;
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* @
|
|
6
|
-
* of the contract works in 2 steps.
|
|
5
|
+
* @title Interface of the LSP14 - Ownable 2-step standard, an extension of the EIP173 (Ownable) standard with 2-step process to transfer or renounce ownership.
|
|
7
6
|
*/
|
|
8
7
|
interface ILSP14Ownable2Step {
|
|
9
8
|
/**
|
|
10
9
|
* @dev emitted when starting the `transferOwnership(..)` 2-step process.
|
|
11
10
|
*/
|
|
12
|
-
event OwnershipTransferStarted(
|
|
11
|
+
event OwnershipTransferStarted(
|
|
12
|
+
address indexed previousOwner,
|
|
13
|
+
address indexed newOwner
|
|
14
|
+
);
|
|
13
15
|
|
|
14
16
|
/**
|
|
15
17
|
* @inheritdoc OwnableUnset
|
|
@@ -33,7 +35,9 @@ interface ILSP14Ownable2Step {
|
|
|
33
35
|
|
|
34
36
|
/**
|
|
35
37
|
* @dev The address that ownership of the contract is transferred to.
|
|
36
|
-
* This address may use
|
|
38
|
+
* This address may use {acceptOwnership()} to gain ownership of the contract.
|
|
39
|
+
*
|
|
40
|
+
* @custom:info If no ownership transfer is in progress, the pendingOwner will be `address(0)`.
|
|
37
41
|
*/
|
|
38
42
|
function pendingOwner() external view returns (address);
|
|
39
43
|
|
|
@@ -41,36 +45,33 @@ interface ILSP14Ownable2Step {
|
|
|
41
45
|
* @dev Initiate the process of transferring ownership of the contract by setting the new owner as the pending owner.
|
|
42
46
|
*
|
|
43
47
|
* If the new owner is a contract that supports + implements LSP1, this will also attempt to notify the new owner that
|
|
44
|
-
* ownership has been transferred to them by calling the `universalReceiver(
|
|
48
|
+
* ownership has been transferred to them by calling the {`universalReceiver()`} function on the `newOwner` contract.
|
|
45
49
|
*
|
|
46
50
|
* @param newOwner the address of the new owner.
|
|
47
51
|
*
|
|
48
|
-
*
|
|
49
|
-
* - `newOwner` MUST NOT accept ownership of the contract in the same transaction.
|
|
52
|
+
* @custom:requirements `newOwner` MUST NOT accept ownership of the contract in the same transaction.
|
|
50
53
|
*/
|
|
51
54
|
function transferOwnership(address newOwner) external;
|
|
52
55
|
|
|
53
56
|
/**
|
|
54
|
-
* @dev Transfer ownership of the contract from the current `owner()` to the `pendingOwner()
|
|
57
|
+
* @dev Transfer ownership of the contract from the current {`owner()`} to the {`pendingOwner()`}.
|
|
55
58
|
*
|
|
56
59
|
* Once this function is called:
|
|
57
|
-
* - the current `owner()` will loose access to the functions restricted to the `owner()` only.
|
|
58
|
-
* - the `pendingOwner()` will gain access to the functions restricted to the `owner()` only.
|
|
60
|
+
* - the current {`owner()`} will loose access to the functions restricted to the {`owner()`} only.
|
|
61
|
+
* - the {`pendingOwner()`} will gain access to the functions restricted to the {`owner()`} only.
|
|
59
62
|
*
|
|
60
|
-
*
|
|
61
|
-
* - MUST be called by the pendingOwner.
|
|
63
|
+
* @custom:requirements
|
|
64
|
+
* - MUST be called by the {`pendingOwner`}.
|
|
62
65
|
*/
|
|
63
66
|
function acceptOwnership() external;
|
|
64
67
|
|
|
65
68
|
/**
|
|
66
|
-
* @dev Renounce ownership of the contract in a
|
|
69
|
+
* @dev Renounce ownership of the contract in a two step process.
|
|
67
70
|
*
|
|
68
71
|
* 1. the first call will initiate the process of renouncing ownership.
|
|
69
72
|
* 2. the second is used as a confirmation and will leave the contract without an owner.
|
|
70
73
|
*
|
|
71
|
-
*
|
|
72
|
-
* that are restricted to be called by the owner will be permanently inaccessible,
|
|
73
|
-
* making these functions not callable anymore and unusable.
|
|
74
|
+
* @custom:danger Leaves the contract without an owner. Once ownership of the contract has been renounced, any functions that are restricted to be called by the owner will be permanently inaccessible, making these functions not callable anymore and unusable.
|
|
74
75
|
*/
|
|
75
76
|
function renounceOwnership() external;
|
|
76
77
|
}
|
|
@@ -4,7 +4,10 @@ pragma solidity ^0.8.4;
|
|
|
4
4
|
/**
|
|
5
5
|
* @dev reverts when trying to renounce ownership before the initial confirmation delay
|
|
6
6
|
*/
|
|
7
|
-
error NotInRenounceOwnershipInterval(
|
|
7
|
+
error NotInRenounceOwnershipInterval(
|
|
8
|
+
uint256 renounceOwnershipStart,
|
|
9
|
+
uint256 renounceOwnershipEnd
|
|
10
|
+
);
|
|
8
11
|
|
|
9
12
|
/**
|
|
10
13
|
* @dev reverts when trying to transfer ownership to the address(this)
|
|
@@ -5,7 +5,9 @@ pragma solidity ^0.8.4;
|
|
|
5
5
|
import {ILSP14Ownable2Step} from "./ILSP14Ownable2Step.sol";
|
|
6
6
|
|
|
7
7
|
// modules
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
OwnableUnset
|
|
10
|
+
} from "@erc725/smart-contracts/contracts/custom/OwnableUnset.sol";
|
|
9
11
|
|
|
10
12
|
// libraries
|
|
11
13
|
import {LSP1Utils} from "../LSP1UniversalReceiver/LSP1Utils.sol";
|
|
@@ -61,18 +63,18 @@ abstract contract LSP14Ownable2Step is ILSP14Ownable2Step, OwnableUnset {
|
|
|
61
63
|
/**
|
|
62
64
|
* @inheritdoc ILSP14Ownable2Step
|
|
63
65
|
*/
|
|
64
|
-
function transferOwnership(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
override(OwnableUnset, ILSP14Ownable2Step)
|
|
68
|
-
onlyOwner
|
|
69
|
-
{
|
|
66
|
+
function transferOwnership(
|
|
67
|
+
address newOwner
|
|
68
|
+
) public virtual override(OwnableUnset, ILSP14Ownable2Step) onlyOwner {
|
|
70
69
|
_transferOwnership(newOwner);
|
|
71
70
|
|
|
72
71
|
address currentOwner = owner();
|
|
73
72
|
emit OwnershipTransferStarted(currentOwner, newOwner);
|
|
74
73
|
|
|
75
|
-
newOwner.tryNotifyUniversalReceiver(
|
|
74
|
+
newOwner.tryNotifyUniversalReceiver(
|
|
75
|
+
_TYPEID_LSP14_OwnershipTransferStarted,
|
|
76
|
+
""
|
|
77
|
+
);
|
|
76
78
|
require(
|
|
77
79
|
currentOwner == owner(),
|
|
78
80
|
"LSP14: newOwner MUST accept ownership in a separate transaction"
|
|
@@ -132,7 +134,10 @@ abstract contract LSP14Ownable2Step is ILSP14Ownable2Step, OwnableUnset {
|
|
|
132
134
|
* @dev set the pending owner of the contract as the new owner.
|
|
133
135
|
*/
|
|
134
136
|
function _acceptOwnership() internal virtual {
|
|
135
|
-
require(
|
|
137
|
+
require(
|
|
138
|
+
msg.sender == pendingOwner(),
|
|
139
|
+
"LSP14: caller is not the pendingOwner"
|
|
140
|
+
);
|
|
136
141
|
|
|
137
142
|
_setOwner(msg.sender);
|
|
138
143
|
delete _pendingOwner;
|
|
@@ -151,7 +156,10 @@ abstract contract LSP14Ownable2Step is ILSP14Ownable2Step, OwnableUnset {
|
|
|
151
156
|
|
|
152
157
|
// On the creation of a new network, `currentBlock` will be smaller than `confirmationPeriodEnd`,
|
|
153
158
|
// `_renounceOwnershipStartedAt == 0` will indicate that a renounceOwnership call is happening for the first time
|
|
154
|
-
if (
|
|
159
|
+
if (
|
|
160
|
+
currentBlock > confirmationPeriodEnd ||
|
|
161
|
+
_renounceOwnershipStartedAt == 0
|
|
162
|
+
) {
|
|
155
163
|
_renounceOwnershipStartedAt = currentBlock;
|
|
156
164
|
delete _pendingOwner;
|
|
157
165
|
emit RenounceOwnershipStarted();
|
|
@@ -159,7 +167,10 @@ abstract contract LSP14Ownable2Step is ILSP14Ownable2Step, OwnableUnset {
|
|
|
159
167
|
}
|
|
160
168
|
|
|
161
169
|
if (currentBlock < confirmationPeriodStart) {
|
|
162
|
-
revert NotInRenounceOwnershipInterval(
|
|
170
|
+
revert NotInRenounceOwnershipInterval(
|
|
171
|
+
confirmationPeriodStart,
|
|
172
|
+
confirmationPeriodEnd
|
|
173
|
+
);
|
|
163
174
|
}
|
|
164
175
|
|
|
165
176
|
_setOwner(address(0));
|