@lukso/lsp-smart-contracts 0.7.0 → 0.8.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.
- package/CONTRIBUTING.md +31 -0
- package/README.md +73 -20
- package/artifacts/Create2Factory.json +2 -2
- package/artifacts/LSP0ERC725Account.json +194 -15
- package/artifacts/LSP0ERC725AccountInit.json +194 -15
- package/artifacts/LSP11BasicSocialRecovery.json +493 -0
- package/artifacts/LSP11BasicSocialRecoveryInit.json +513 -0
- package/artifacts/LSP16UniversalFactory.json +236 -0
- package/artifacts/LSP1UniversalReceiverDelegateUP.json +134 -15
- package/artifacts/LSP1UniversalReceiverDelegateVault.json +80 -15
- package/artifacts/LSP4Compatibility.json +16 -0
- package/artifacts/LSP4DigitalAssetMetadata.json +16 -0
- package/artifacts/LSP4DigitalAssetMetadataInitAbstract.json +16 -0
- package/artifacts/LSP6KeyManager.json +177 -33
- package/artifacts/LSP6KeyManagerInit.json +177 -33
- package/artifacts/LSP7CappedSupply.json +21 -5
- package/artifacts/LSP7CappedSupplyInitAbstract.json +21 -5
- package/artifacts/LSP7CompatibleERC20.json +21 -5
- package/artifacts/LSP7CompatibleERC20InitAbstract.json +23 -7
- package/artifacts/LSP7CompatibleERC20Mintable.json +24 -8
- package/artifacts/LSP7CompatibleERC20MintableInit.json +24 -8
- package/artifacts/LSP7DigitalAsset.json +21 -5
- package/artifacts/LSP7DigitalAssetInitAbstract.json +21 -5
- package/artifacts/LSP7Mintable.json +24 -8
- package/artifacts/LSP7MintableInit.json +24 -8
- package/artifacts/LSP8CappedSupply.json +22 -6
- package/artifacts/LSP8CappedSupplyInitAbstract.json +22 -6
- package/artifacts/LSP8CompatibleERC721.json +23 -7
- package/artifacts/LSP8CompatibleERC721InitAbstract.json +25 -9
- package/artifacts/LSP8CompatibleERC721Mintable.json +26 -10
- package/artifacts/LSP8CompatibleERC721MintableInit.json +26 -10
- package/artifacts/LSP8IdentifiableDigitalAsset.json +22 -6
- package/artifacts/LSP8IdentifiableDigitalAssetInitAbstract.json +22 -6
- package/artifacts/LSP8Mintable.json +25 -9
- package/artifacts/LSP8MintableInit.json +25 -9
- package/artifacts/LSP9Vault.json +202 -17
- package/artifacts/LSP9VaultInit.json +202 -17
- package/artifacts/UniversalProfile.json +194 -15
- package/artifacts/UniversalProfileInit.json +194 -15
- package/artifacts/UniversalReceiverAddressStore.json +3 -3
- package/constants.js +377 -115
- package/contracts/Custom/EIP191Signer.sol +12 -0
- package/contracts/Factories/Create2Factory.sol +1 -3
- package/contracts/LSP0ERC725Account/LSP0Constants.sol +13 -2
- package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +2 -1
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +261 -63
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +2 -2
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +2 -1
- package/contracts/LSP10ReceivedVaults/LSP10Constants.sol +2 -2
- package/contracts/LSP10ReceivedVaults/LSP10Utils.sol +214 -0
- package/contracts/LSP11BasicSocialRecovery/ILSP11BasicSocialRecovery.sol +177 -0
- package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecovery.sol +23 -0
- package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryCore.sol +258 -0
- package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryInit.sol +26 -0
- package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryInitAbstract.sol +19 -0
- package/contracts/LSP11BasicSocialRecovery/LSP11Constants.sol +6 -0
- package/contracts/LSP11BasicSocialRecovery/LSP11Errors.sol +60 -0
- package/contracts/LSP14Ownable2Step/ILSP14Ownable2Step.sol +53 -0
- package/contracts/LSP14Ownable2Step/LSP14Constants.sol +15 -0
- package/contracts/LSP14Ownable2Step/LSP14Errors.sol +12 -0
- package/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol +212 -0
- package/contracts/LSP16UniversalFactory/LSP16UniversalFactory.sol +246 -0
- package/contracts/LSP17ContractExtension/LSP17Constants.sol +17 -0
- package/contracts/LSP17ContractExtension/LSP17Errors.sol +7 -0
- package/contracts/LSP17ContractExtension/LSP17Extendable.sol +104 -0
- package/contracts/LSP17ContractExtension/LSP17Extension.sol +45 -0
- package/contracts/LSP17ContractExtension/LSP17Utils.sol +20 -0
- package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiver.sol +5 -5
- package/contracts/LSP1UniversalReceiver/LSP1Constants.sol +5 -3
- package/contracts/LSP1UniversalReceiver/LSP1Errors.sol +21 -0
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +157 -37
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +64 -31
- package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +53 -40
- package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +45 -23
- package/contracts/LSP3UniversalProfile/LSP3Constants.sol +1 -1
- package/contracts/LSP4DigitalAssetMetadata/ILSP4Compatibility.sol +1 -1
- package/contracts/LSP4DigitalAssetMetadata/LSP4Compatibility.sol +1 -1
- package/contracts/LSP4DigitalAssetMetadata/LSP4Constants.sol +1 -1
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol +2 -2
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +2 -2
- package/contracts/LSP4DigitalAssetMetadata/LSP4Errors.sol +3 -3
- package/contracts/LSP5ReceivedAssets/LSP5Constants.sol +2 -2
- package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +102 -114
- package/contracts/LSP6KeyManager/ILSP6KeyManager.sol +25 -7
- package/contracts/LSP6KeyManager/LSP6Constants.sol +43 -38
- package/contracts/LSP6KeyManager/LSP6Errors.sol +90 -21
- package/contracts/LSP6KeyManager/LSP6KeyManager.sol +2 -1
- package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +772 -364
- package/contracts/LSP6KeyManager/LSP6KeyManagerInit.sol +1 -1
- package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +3 -2
- package/contracts/LSP6KeyManager/LSP6Utils.sol +125 -34
- package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +8 -8
- package/contracts/LSP7DigitalAsset/LSP7Constants.sol +6 -6
- package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +1 -1
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +38 -34
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +1 -1
- package/contracts/LSP7DigitalAsset/LSP7Errors.sol +28 -1
- package/contracts/LSP7DigitalAsset/extensions/ILSP7CompatibleERC20.sol +1 -1
- package/contracts/LSP7DigitalAsset/extensions/LSP7Burnable.sol +24 -0
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupply.sol +28 -8
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInitAbstract.sol +28 -11
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.sol +87 -20
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20InitAbstract.sol +97 -19
- package/contracts/LSP7DigitalAsset/presets/ILSP7Mintable.sol +3 -3
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.sol +3 -4
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInit.sol +2 -2
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInitAbstract.sol +3 -3
- package/contracts/LSP7DigitalAsset/presets/LSP7Mintable.sol +3 -5
- package/contracts/LSP7DigitalAsset/presets/LSP7MintableInit.sol +2 -2
- package/contracts/LSP7DigitalAsset/presets/LSP7MintableInitAbstract.sol +3 -3
- package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +7 -7
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol +7 -7
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol +40 -2
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +2 -2
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +53 -50
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +1 -1
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CompatibleERC721.sol +5 -2
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Burnable.sol +20 -0
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.sol +27 -7
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInitAbstract.sol +27 -10
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +236 -30
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +240 -30
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.sol +32 -4
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableInitAbstract.sol +35 -8
- package/contracts/LSP8IdentifiableDigitalAsset/presets/ILSP8Mintable.sol +3 -3
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.sol +3 -4
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInit.sol +3 -3
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInitAbstract.sol +3 -3
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.sol +3 -4
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInit.sol +2 -2
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +3 -3
- package/contracts/LSP9Vault/LSP9Constants.sol +10 -10
- package/contracts/LSP9Vault/LSP9Errors.sol +8 -0
- package/contracts/LSP9Vault/LSP9Vault.sol +6 -4
- package/contracts/LSP9Vault/LSP9VaultCore.sol +289 -126
- package/contracts/LSP9Vault/LSP9VaultInit.sol +2 -2
- package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +4 -3
- package/contracts/Legacy/Registries/AddressRegistry.sol +1 -1
- package/contracts/Legacy/Registries/AddressRegistryRequiresERC725.sol +1 -1
- package/contracts/Legacy/UniversalReceiverAddressStore.sol +4 -14
- package/contracts/UniversalProfile.sol +2 -2
- package/contracts/UniversalProfileInit.sol +2 -2
- package/contracts/UniversalProfileInitAbstract.sol +1 -1
- package/contracts/Utils/GasLib.sol +1 -1
- package/package.json +17 -9
- package/artifacts/UniversalFactory.json +0 -127
- package/contracts/Custom/ClaimOwnership.sol +0 -96
- package/contracts/Custom/ERC165Checker.sol +0 -130
- package/contracts/Custom/IClaimOwnership.sol +0 -12
- package/contracts/Factories/UniversalFactory.sol +0 -159
- package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiverDelegate.sol +0 -24
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/Handling/TokenAndVaultHandling.sol +0 -82
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/Handling/TokenHandling.sol +0 -73
- package/contracts/LSP2ERC725YJSONSchema/LSP2Errors.sol +0 -9
- package/contracts/LSP7DigitalAsset/extensions/ILSP7CappedSupply.sol +0 -17
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyCore.sol +0 -57
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20Core.sol +0 -111
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CappedSupply.sol +0 -17
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8Enumerable.sol +0 -17
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyCore.sol +0 -58
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleConstants.sol +0 -6
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721Core.sol +0 -211
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableCore.sol +0 -50
- package/contracts/Utils/UtilsLib.sol +0 -31
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
// modules
|
|
5
|
+
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
|
|
6
|
+
import {OwnableUnset} from "@erc725/smart-contracts/contracts/custom/OwnableUnset.sol";
|
|
7
|
+
import {LSP11BasicSocialRecoveryCore} from "./LSP11BasicSocialRecoveryCore.sol";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @title Inheritable 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 LSP11BasicSocialRecoveryInitAbstract is Initializable, LSP11BasicSocialRecoveryCore {
|
|
15
|
+
function _initialize(address _owner, address target_) internal virtual onlyInitializing {
|
|
16
|
+
OwnableUnset._setOwner(_owner);
|
|
17
|
+
_target = target_;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// SPDX-License-Identifier: CC0-1.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(uint256 thresholdGiven, uint256 guardianNumber);
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @dev reverts when the secret hash provided is equal to bytes32(0)
|
|
35
|
+
*/
|
|
36
|
+
error SecretHashCannotBeZero();
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @dev reverts when `recoverOwnership(..)` is called with a recoverer that didn't reach
|
|
40
|
+
* the guardians threshold
|
|
41
|
+
* @param recoverer The address of the recoverer
|
|
42
|
+
* @param selections The number of selections that the recoverer have
|
|
43
|
+
* @param guardiansThreshold The minimum number of selection needed
|
|
44
|
+
*/
|
|
45
|
+
error ThresholdNotReachedForRecoverer(
|
|
46
|
+
address recoverer,
|
|
47
|
+
uint256 selections,
|
|
48
|
+
uint256 guardiansThreshold
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @dev reverts when the plain secret produce a different hash than the
|
|
53
|
+
* secret hash originally set
|
|
54
|
+
*/
|
|
55
|
+
error WrongPlainSecret();
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @dev reverts when the address zero calls `recoverOwnership(..)` function
|
|
59
|
+
*/
|
|
60
|
+
error AddressZeroNotAllowed();
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.4;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @dev Extended version of Ownable (EIP173) in which, transferring or renouncing ownership
|
|
6
|
+
* of the contract works in 2 steps.
|
|
7
|
+
*/
|
|
8
|
+
interface ILSP14Ownable2Step {
|
|
9
|
+
/**
|
|
10
|
+
* @dev emitted when starting the `transferOwnership(..)` 2-step process.
|
|
11
|
+
*/
|
|
12
|
+
event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @inheritdoc OwnableUnset
|
|
16
|
+
* event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @dev emitted when starting the `renounceOwnership(..)` 2-step process.
|
|
21
|
+
*/
|
|
22
|
+
event RenounceOwnershipStarted();
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @dev emitted when the ownership of the contract has been renounced.
|
|
26
|
+
*/
|
|
27
|
+
event OwnershipRenounced();
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @inheritdoc OwnableUnset
|
|
31
|
+
* function owner() external view returns (address);
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @dev Returns the address of the current pending owner.
|
|
36
|
+
*/
|
|
37
|
+
function pendingOwner() external view returns (address);
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @dev Initiate the process of transferring ownership of the contract by setting the pending owner.
|
|
41
|
+
*/
|
|
42
|
+
function transferOwnership(address newOwner) external;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @dev Complete the process of transferring ownership. MUST be called by the pendingOwner.
|
|
46
|
+
*/
|
|
47
|
+
function acceptOwnership() external;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @dev Initiate the process of renouncing ownerhsip on the first call and confirm the renouncement of the ownership on the second call.
|
|
51
|
+
*/
|
|
52
|
+
function renounceOwnership() external;
|
|
53
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.4;
|
|
3
|
+
|
|
4
|
+
bytes4 constant _INTERFACEID_LSP14 = 0x94be5999;
|
|
5
|
+
|
|
6
|
+
// --- Type IDs
|
|
7
|
+
|
|
8
|
+
// keccak256('LSP14OwnershipTransferStarted')
|
|
9
|
+
bytes32 constant _TYPEID_LSP14_OwnershipTransferStarted = 0xee9a7c0924f740a2ca33d59b7f0c2929821ea9837ce043ce91c1823e9c4e52c0;
|
|
10
|
+
|
|
11
|
+
// keccak256('LSP14OwnershipTransferred_SenderNotification')
|
|
12
|
+
bytes32 constant _TYPEID_LSP14_OwnershipTransferred_SenderNotification = 0xa124442e1cc7b52d8e2ede2787d43527dc1f3ae0de87f50dd03e27a71834f74c;
|
|
13
|
+
|
|
14
|
+
// keccak256('LSP14OwnershipTransferred_RecipientNotification')
|
|
15
|
+
bytes32 constant _TYPEID_LSP14_OwnershipTransferred_RecipientNotification = 0xe32c7debcb817925ba4883fdbfc52797187f28f73f860641dab1a68d9b32902c;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.4;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @dev reverts when trying to renounce ownership before the initial confirmation delay
|
|
6
|
+
*/
|
|
7
|
+
error NotInRenounceOwnershipInterval(uint256 renounceOwnershipStart, uint256 renounceOwnershipEnd);
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @dev reverts when trying to transfer ownership to the address(this)
|
|
11
|
+
*/
|
|
12
|
+
error CannotTransferOwnershipToSelf();
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.4;
|
|
3
|
+
|
|
4
|
+
// interfaces
|
|
5
|
+
import {ILSP14Ownable2Step} from "./ILSP14Ownable2Step.sol";
|
|
6
|
+
import {ILSP1UniversalReceiver} from "../LSP1UniversalReceiver/ILSP1UniversalReceiver.sol";
|
|
7
|
+
|
|
8
|
+
// modules
|
|
9
|
+
import {OwnableUnset} from "@erc725/smart-contracts/contracts/custom/OwnableUnset.sol";
|
|
10
|
+
import {ERC165Checker} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
|
|
11
|
+
|
|
12
|
+
// errors
|
|
13
|
+
import "./LSP14Errors.sol";
|
|
14
|
+
|
|
15
|
+
// constants
|
|
16
|
+
import {
|
|
17
|
+
_TYPEID_LSP14_OwnershipTransferStarted,
|
|
18
|
+
_TYPEID_LSP14_OwnershipTransferred_SenderNotification,
|
|
19
|
+
_TYPEID_LSP14_OwnershipTransferred_RecipientNotification
|
|
20
|
+
} from "./LSP14Constants.sol";
|
|
21
|
+
import {_INTERFACEID_LSP1} from "../LSP1UniversalReceiver/LSP1Constants.sol";
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @title LSP14Ownable2Step
|
|
25
|
+
* @author Fabian Vogelsteller <fabian@lukso.network>, Jean Cavallera (CJ42), Yamen Merhi (YamenMerhi), Daniel Afteni (B00ste)
|
|
26
|
+
* @dev This contract is a modified version of the OwnableUnset implementation, where transferring and renouncing ownership
|
|
27
|
+
* works as a 2 steps process. This can be used as a confirmation mechanism to prevent potential mistakes when
|
|
28
|
+
* transferring ownership of the contract, where the control of the contract could be lost forever.
|
|
29
|
+
*/
|
|
30
|
+
abstract contract LSP14Ownable2Step is ILSP14Ownable2Step, OwnableUnset {
|
|
31
|
+
/**
|
|
32
|
+
* @dev The number of block that MUST pass before one is able to
|
|
33
|
+
* confirm renouncing ownership
|
|
34
|
+
*/
|
|
35
|
+
uint256 public constant RENOUNCE_OWNERSHIP_CONFIRMATION_DELAY = 100;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @dev The number of blocks during which one can renounce ownership
|
|
39
|
+
*/
|
|
40
|
+
uint256 public constant RENOUNCE_OWNERSHIP_CONFIRMATION_PERIOD = 100;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @dev The block number saved when initiating the process of
|
|
44
|
+
* renouncing ownerhsip
|
|
45
|
+
*/
|
|
46
|
+
uint256 private _renounceOwnershipStartedAt;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @dev The address that ownership of the contract is transferred to.
|
|
50
|
+
* This address may use `acceptOwnership()` to gain ownership of the contract.
|
|
51
|
+
* Meaning that the current owner will lose access to the methods marked as
|
|
52
|
+
* `onlyOwner` in favor to the `_pendingOwner`.
|
|
53
|
+
*/
|
|
54
|
+
address private _pendingOwner;
|
|
55
|
+
|
|
56
|
+
// --- General Methods
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @inheritdoc ILSP14Ownable2Step
|
|
60
|
+
*/
|
|
61
|
+
function pendingOwner() public view virtual returns (address) {
|
|
62
|
+
return _pendingOwner;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @inheritdoc ILSP14Ownable2Step
|
|
67
|
+
*/
|
|
68
|
+
function transferOwnership(address newOwner)
|
|
69
|
+
public
|
|
70
|
+
virtual
|
|
71
|
+
override(OwnableUnset, ILSP14Ownable2Step)
|
|
72
|
+
onlyOwner
|
|
73
|
+
{
|
|
74
|
+
_transferOwnership(newOwner);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @inheritdoc ILSP14Ownable2Step
|
|
79
|
+
*/
|
|
80
|
+
function acceptOwnership() public virtual {
|
|
81
|
+
_acceptOwnership();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* @inheritdoc ILSP14Ownable2Step
|
|
86
|
+
*/
|
|
87
|
+
function renounceOwnership()
|
|
88
|
+
public
|
|
89
|
+
virtual
|
|
90
|
+
override(OwnableUnset, ILSP14Ownable2Step)
|
|
91
|
+
onlyOwner
|
|
92
|
+
{
|
|
93
|
+
_renounceOwnership();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// --- Internal methods
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @dev Start the process of transferring ownership of the contract
|
|
100
|
+
* and notify the new owner about it.
|
|
101
|
+
*
|
|
102
|
+
* Requirements:
|
|
103
|
+
* - `newOwner` MUST NOT accept ownership of the contract in the same transaction.
|
|
104
|
+
*/
|
|
105
|
+
function _transferOwnership(address newOwner) internal virtual {
|
|
106
|
+
if (newOwner == address(this)) revert CannotTransferOwnershipToSelf();
|
|
107
|
+
|
|
108
|
+
_pendingOwner = newOwner;
|
|
109
|
+
delete _renounceOwnershipStartedAt;
|
|
110
|
+
address currentOwner = owner();
|
|
111
|
+
emit OwnershipTransferStarted(currentOwner, newOwner);
|
|
112
|
+
|
|
113
|
+
_notifyLSP1SenderOnOwnershipTransferStart(newOwner, "");
|
|
114
|
+
require(
|
|
115
|
+
currentOwner == owner(),
|
|
116
|
+
"LSP14: newOwner MUST accept ownership in a separate transaction"
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* @dev Accept ownership of the contract and notify
|
|
122
|
+
* previous owner and the new owner that ownership has been transferred.
|
|
123
|
+
*/
|
|
124
|
+
function _acceptOwnership() internal virtual {
|
|
125
|
+
require(msg.sender == pendingOwner(), "LSP14: caller is not the pendingOwner");
|
|
126
|
+
|
|
127
|
+
address previousOwner = owner();
|
|
128
|
+
_setOwner(msg.sender);
|
|
129
|
+
delete _pendingOwner;
|
|
130
|
+
|
|
131
|
+
_notifyLSP1SenderOnOwnershipTransferCompletion(previousOwner, "");
|
|
132
|
+
_notifyLSP1RecipientOnOwnershipTransferCompletion(msg.sender, "");
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* @dev initiate or confirm the process of renouncing ownership. Leaves the contract
|
|
137
|
+
* without an owner, making functions marked as `onlyOwner` not callable anymore.
|
|
138
|
+
*/
|
|
139
|
+
function _renounceOwnership() internal virtual {
|
|
140
|
+
uint256 currentBlock = block.number;
|
|
141
|
+
uint256 confirmationPeriodStart = _renounceOwnershipStartedAt +
|
|
142
|
+
RENOUNCE_OWNERSHIP_CONFIRMATION_DELAY;
|
|
143
|
+
uint256 confirmationPeriodEnd = confirmationPeriodStart +
|
|
144
|
+
RENOUNCE_OWNERSHIP_CONFIRMATION_PERIOD;
|
|
145
|
+
|
|
146
|
+
if (currentBlock > confirmationPeriodEnd) {
|
|
147
|
+
_renounceOwnershipStartedAt = currentBlock;
|
|
148
|
+
delete _pendingOwner;
|
|
149
|
+
emit RenounceOwnershipStarted();
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (currentBlock < confirmationPeriodStart) {
|
|
154
|
+
revert NotInRenounceOwnershipInterval(confirmationPeriodStart, confirmationPeriodEnd);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
_setOwner(address(0));
|
|
158
|
+
delete _renounceOwnershipStartedAt;
|
|
159
|
+
delete _pendingOwner;
|
|
160
|
+
emit OwnershipRenounced();
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// --- URD Hooks
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* @dev Calls the universalReceiver function of the sender when ownership transfer starts
|
|
167
|
+
* if supports LSP1 InterfaceId
|
|
168
|
+
*/
|
|
169
|
+
function _notifyLSP1SenderOnOwnershipTransferStart(address notifiedContract, bytes memory data)
|
|
170
|
+
internal
|
|
171
|
+
virtual
|
|
172
|
+
{
|
|
173
|
+
if (ERC165Checker.supportsERC165InterfaceUnchecked(notifiedContract, _INTERFACEID_LSP1)) {
|
|
174
|
+
ILSP1UniversalReceiver(notifiedContract).universalReceiver(
|
|
175
|
+
_TYPEID_LSP14_OwnershipTransferStarted,
|
|
176
|
+
data
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* @dev Calls the universalReceiver function of the sender when ownerhsip transfer is complete
|
|
183
|
+
* if supports LSP1 InterfaceId
|
|
184
|
+
*/
|
|
185
|
+
function _notifyLSP1SenderOnOwnershipTransferCompletion(
|
|
186
|
+
address notifiedContract,
|
|
187
|
+
bytes memory data
|
|
188
|
+
) internal virtual {
|
|
189
|
+
if (ERC165Checker.supportsERC165InterfaceUnchecked(notifiedContract, _INTERFACEID_LSP1)) {
|
|
190
|
+
ILSP1UniversalReceiver(notifiedContract).universalReceiver(
|
|
191
|
+
_TYPEID_LSP14_OwnershipTransferred_SenderNotification,
|
|
192
|
+
data
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* @dev Calls the universalReceiver function of the recipient when ownerhsip transfer is complete
|
|
199
|
+
* if supports LSP1 InterfaceId
|
|
200
|
+
*/
|
|
201
|
+
function _notifyLSP1RecipientOnOwnershipTransferCompletion(
|
|
202
|
+
address notifiedContract,
|
|
203
|
+
bytes memory data
|
|
204
|
+
) internal virtual {
|
|
205
|
+
if (ERC165Checker.supportsERC165InterfaceUnchecked(notifiedContract, _INTERFACEID_LSP1)) {
|
|
206
|
+
ILSP1UniversalReceiver(notifiedContract).universalReceiver(
|
|
207
|
+
_TYPEID_LSP14_OwnershipTransferred_RecipientNotification,
|
|
208
|
+
data
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.4;
|
|
3
|
+
|
|
4
|
+
// libraries
|
|
5
|
+
import {Create2} from "@openzeppelin/contracts/utils/Create2.sol";
|
|
6
|
+
import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";
|
|
7
|
+
|
|
8
|
+
// errors
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @dev reverts with this error when there is no revert reason bubbled up by the target contract when initializing
|
|
12
|
+
*/
|
|
13
|
+
error CannotInitializeContract();
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @dev reverts when msg.value sent to {deployCreate2Init} function is not equal to the sum of the
|
|
17
|
+
* `initializeCalldataMsgValue` and `constructorMsgValue`
|
|
18
|
+
*/
|
|
19
|
+
error InvalidMsgValueDistribution();
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @dev UniversalFactory contract can be used to deploy normal or minimal proxy contracts (EIP-1167) using CREATE2.
|
|
23
|
+
* This gives the ability to deploy the same contract at the same address on different chains.
|
|
24
|
+
* If the contract has a constructor, the arguments will be part of the bytecode
|
|
25
|
+
* If the contract has an `initialize` function, the parameters of this function will be included in
|
|
26
|
+
* the salt to ensure that the parameters of the contract should be the same on each chain.
|
|
27
|
+
*
|
|
28
|
+
* When initializeCallData or the constructor includes non-crosschain parameters, the deployed contract
|
|
29
|
+
* will not be recreated at the same address on another network, thus defeating the purpose of LSP16UniversalFactory.
|
|
30
|
+
|
|
31
|
+
* Therefore, the initializeCallData and the constructor must not include any network-specific parameters,
|
|
32
|
+
* such as a local non-crosschain token contract address, chain-id, etc ..
|
|
33
|
+
*
|
|
34
|
+
* One way to solve this problem is to set an EOA owner in the initializeCallData/constructor
|
|
35
|
+
* that can later call functions that set these parameters as variables in the contract.
|
|
36
|
+
*
|
|
37
|
+
* This contract should be deployed using Nick's Method.
|
|
38
|
+
* More information: https://weka.medium.com/how-to-send-ether-to-11-440-people-187e332566b7
|
|
39
|
+
*/
|
|
40
|
+
contract LSP16UniversalFactory {
|
|
41
|
+
bytes private constant _EMPTY_BYTE = "";
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @dev Emitted whenever a contract is created
|
|
45
|
+
* @param contractCreated The address of the contract created
|
|
46
|
+
* @param providedSalt The bytes32 salt provided by the deployer
|
|
47
|
+
* @param initializable The Boolean that specifies if the contract is a initializable or not
|
|
48
|
+
* @param initializeCalldata The bytes provided as initializeCalldata
|
|
49
|
+
*/
|
|
50
|
+
event ContractCreated(
|
|
51
|
+
address indexed contractCreated,
|
|
52
|
+
bytes32 indexed providedSalt,
|
|
53
|
+
bool indexed initializable,
|
|
54
|
+
bytes initializeCalldata
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @dev Returns the address where a contract will be stored if deployed via `CREATE2`. The address is
|
|
59
|
+
* constructed using the parameters below. Any change in one of them will result in a new destination address.
|
|
60
|
+
*/
|
|
61
|
+
function calculateAddress(
|
|
62
|
+
bytes32 byteCodeHash,
|
|
63
|
+
bytes32 providedSalt,
|
|
64
|
+
bool initializable,
|
|
65
|
+
bytes calldata initializeCallData
|
|
66
|
+
) public view virtual returns (address) {
|
|
67
|
+
bytes32 generatedSalt = _generateSalt(initializable, initializeCallData, providedSalt);
|
|
68
|
+
return Create2.computeAddress(generatedSalt, byteCodeHash);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @dev Returns the address of an EIP1167 proxy contract. The address is constructed using
|
|
73
|
+
* the parameters below. Any change in one of them will result in a new destination address.
|
|
74
|
+
*/
|
|
75
|
+
function calculateProxyAddress(
|
|
76
|
+
address baseContract,
|
|
77
|
+
bytes32 providedSalt,
|
|
78
|
+
bool initializable,
|
|
79
|
+
bytes calldata initializeCallData
|
|
80
|
+
) public view virtual returns (address) {
|
|
81
|
+
bytes32 generatedSalt = _generateSalt(initializable, initializeCallData, providedSalt);
|
|
82
|
+
return Clones.predictDeterministicAddress(baseContract, generatedSalt);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @dev Deploys a contract using `CREATE2`. The address where the contract will be deployed
|
|
87
|
+
* can be known in advance via {calculateAddress}. The salt is a hash of the `providedSalt`
|
|
88
|
+
* together with an empty byte, to prevent mimicing the `deployCreate2Init()` and other functions.
|
|
89
|
+
*
|
|
90
|
+
* This method allow users to have the same contracts at the same address across different
|
|
91
|
+
* chains with the same parameters.
|
|
92
|
+
*
|
|
93
|
+
* Using the same `byteCode` and salt multiple time will revert, since
|
|
94
|
+
* the contract cannot be deployed twice at the same address.
|
|
95
|
+
*/
|
|
96
|
+
function deployCreate2(bytes calldata byteCode, bytes32 providedSalt)
|
|
97
|
+
public
|
|
98
|
+
payable
|
|
99
|
+
virtual
|
|
100
|
+
returns (address)
|
|
101
|
+
{
|
|
102
|
+
bytes32 generatedSalt = _generateSalt(false, _EMPTY_BYTE, providedSalt);
|
|
103
|
+
address contractCreated = Create2.deploy(msg.value, generatedSalt, byteCode);
|
|
104
|
+
emit ContractCreated(contractCreated, providedSalt, false, _EMPTY_BYTE);
|
|
105
|
+
|
|
106
|
+
return contractCreated;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* @dev Deploys a contract using `CREATE2`. The address where the contract will be deployed
|
|
111
|
+
* can be known in advance via {calculateAddress}. The salt is a hash of the `providedSalt` and
|
|
112
|
+
* and the `initializeCallData`.
|
|
113
|
+
*
|
|
114
|
+
* This method allow users
|
|
115
|
+
* to have the same contracts at the same address across different chains with the same parameters.
|
|
116
|
+
*
|
|
117
|
+
* The msg.value is split according to the parameters of the function
|
|
118
|
+
*
|
|
119
|
+
* The msg.value sent to this contract MUST be the sum of the two parameters: `constructorMsgValue`
|
|
120
|
+
* and `initializeCalldataMsgValue`
|
|
121
|
+
*
|
|
122
|
+
* Using the same `byteCode` and salt multiple time will revert, since
|
|
123
|
+
* the contract cannot be deployed twice at the same address.
|
|
124
|
+
*/
|
|
125
|
+
function deployCreate2Init(
|
|
126
|
+
bytes calldata byteCode,
|
|
127
|
+
bytes32 providedSalt,
|
|
128
|
+
bytes calldata initializeCalldata,
|
|
129
|
+
uint256 constructorMsgValue,
|
|
130
|
+
uint256 initializeCalldataMsgValue
|
|
131
|
+
) public payable virtual returns (address) {
|
|
132
|
+
if (constructorMsgValue + initializeCalldataMsgValue != msg.value)
|
|
133
|
+
revert InvalidMsgValueDistribution();
|
|
134
|
+
|
|
135
|
+
bytes32 generatedSalt = _generateSalt(true, initializeCalldata, providedSalt);
|
|
136
|
+
address contractCreated = Create2.deploy(constructorMsgValue, generatedSalt, byteCode);
|
|
137
|
+
emit ContractCreated(contractCreated, providedSalt, true, initializeCalldata);
|
|
138
|
+
|
|
139
|
+
(bool success, bytes memory returndata) = contractCreated.call{
|
|
140
|
+
value: initializeCalldataMsgValue
|
|
141
|
+
}(initializeCalldata);
|
|
142
|
+
_verifyCallResult(success, returndata);
|
|
143
|
+
|
|
144
|
+
return contractCreated;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* @dev Deploys and returns the address of a clone that mimics the behaviour of `baseContract`.
|
|
149
|
+
* The address where the contract will be deployed can be known in advance via {calculateProxyAddress}.
|
|
150
|
+
*
|
|
151
|
+
* This function uses the CREATE2 opcode and a salt to deterministically deploy
|
|
152
|
+
* the clone. The salt is a hash of the `providedSalt`
|
|
153
|
+
* toegther with an empty byte, to prevent mimicing the `deployCreate2ProxyInit()` and other functions.
|
|
154
|
+
*
|
|
155
|
+
* This method allow users to have the same contracts at the same address across different
|
|
156
|
+
* chains with the same parameters.
|
|
157
|
+
*
|
|
158
|
+
* Using the same `baseContract` and salt multiple time will revert, since
|
|
159
|
+
* the clones cannot be deployed twice at the same address.
|
|
160
|
+
*/
|
|
161
|
+
function deployCreate2Proxy(address baseContract, bytes32 providedSalt)
|
|
162
|
+
public
|
|
163
|
+
virtual
|
|
164
|
+
returns (address)
|
|
165
|
+
{
|
|
166
|
+
bytes32 generatedSalt = _generateSalt(false, _EMPTY_BYTE, providedSalt);
|
|
167
|
+
|
|
168
|
+
address proxy = Clones.cloneDeterministic(baseContract, generatedSalt);
|
|
169
|
+
emit ContractCreated(proxy, providedSalt, false, _EMPTY_BYTE);
|
|
170
|
+
|
|
171
|
+
return proxy;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* @dev Deploys and returns the address of a clone that mimics the behaviour of `baseContract`.
|
|
176
|
+
* The address where the contract will be deployed can be known in advance via {calculateProxyAddress}.
|
|
177
|
+
*
|
|
178
|
+
* This function uses the CREATE2 opcode and a salt to deterministically deploy
|
|
179
|
+
* the clone. The salt is a hash of the `providedSalt` and
|
|
180
|
+
* and the `initializeCallData`.
|
|
181
|
+
*
|
|
182
|
+
* This method allow users to have the same contracts at the same address
|
|
183
|
+
* across different chains with the same parameters.
|
|
184
|
+
*
|
|
185
|
+
* Using the same `baseContract` and salt multiple time will revert, since
|
|
186
|
+
* the clones cannot be deployed twice at the same address.
|
|
187
|
+
*/
|
|
188
|
+
function deployCreate2ProxyInit(
|
|
189
|
+
address baseContract,
|
|
190
|
+
bytes32 providedSalt,
|
|
191
|
+
bytes calldata initializeCalldata
|
|
192
|
+
) public payable virtual returns (address) {
|
|
193
|
+
bytes32 generatedSalt = _generateSalt(true, initializeCalldata, providedSalt);
|
|
194
|
+
|
|
195
|
+
address proxy = Clones.cloneDeterministic(baseContract, generatedSalt);
|
|
196
|
+
emit ContractCreated(proxy, providedSalt, true, initializeCalldata);
|
|
197
|
+
|
|
198
|
+
(bool success, bytes memory returndata) = proxy.call{value: msg.value}(initializeCalldata);
|
|
199
|
+
_verifyCallResult(success, returndata);
|
|
200
|
+
|
|
201
|
+
return proxy;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* @dev Calculates the salt used to deploy the contract by hashing (Keccak256) the following parameters
|
|
206
|
+
* as packed encoded respectively: an initializable boolean, the initializeCallData if and only if
|
|
207
|
+
* the contract is initializable, and the salt provided by the deployer.
|
|
208
|
+
*
|
|
209
|
+
* The initializable boolean was added before the provided arguments as if it was not used,
|
|
210
|
+
* and we are deploying proxies on another chain, people can use the `deployCreate2(..)` function
|
|
211
|
+
* to deploy the same bytecode + the same salt to get the same address of the contract on
|
|
212
|
+
* another chain without applying the effect of initializing.
|
|
213
|
+
*/
|
|
214
|
+
function _generateSalt(
|
|
215
|
+
bool initializable,
|
|
216
|
+
bytes memory initializeCallData,
|
|
217
|
+
bytes32 providedSalt
|
|
218
|
+
) internal pure virtual returns (bytes32) {
|
|
219
|
+
if (initializable) {
|
|
220
|
+
return keccak256(abi.encodePacked(initializable, initializeCallData, providedSalt));
|
|
221
|
+
} else {
|
|
222
|
+
return keccak256(abi.encodePacked(initializable, providedSalt));
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* @dev Verifies that the contract created was initialized correctly
|
|
228
|
+
* Bubble the revert reason if present, revert with `CannotInitializeContract` otherwise
|
|
229
|
+
*/
|
|
230
|
+
function _verifyCallResult(bool success, bytes memory returndata) internal pure virtual {
|
|
231
|
+
if (!success) {
|
|
232
|
+
// Look for revert reason and bubble it up if present
|
|
233
|
+
if (returndata.length != 0) {
|
|
234
|
+
// The easiest way to bubble the revert reason is using memory via assembly
|
|
235
|
+
// solhint-disable no-inline-assembly
|
|
236
|
+
/// @solidity memory-safe-assembly
|
|
237
|
+
assembly {
|
|
238
|
+
let returndata_size := mload(returndata)
|
|
239
|
+
revert(add(32, returndata), returndata_size)
|
|
240
|
+
}
|
|
241
|
+
} else {
|
|
242
|
+
revert CannotInitializeContract();
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
pragma solidity ^0.8.4;
|
|
3
|
+
|
|
4
|
+
// --- ERC165 interface ids
|
|
5
|
+
|
|
6
|
+
// bytes4(keccack256("LSP17Extendable"))
|
|
7
|
+
bytes4 constant _INTERFACEID_LSP17_EXTENDABLE = 0xa918fa6b;
|
|
8
|
+
|
|
9
|
+
// bytes4(keccack256("LSP17Extension"))
|
|
10
|
+
bytes4 constant _INTERFACEID_LSP17_EXTENSION = 0xcee78b40;
|
|
11
|
+
|
|
12
|
+
// --- ERC725Y Data Keys
|
|
13
|
+
|
|
14
|
+
// Extension Handler Prefix
|
|
15
|
+
|
|
16
|
+
// bytes10(keccak256('LSP17Extension'))
|
|
17
|
+
bytes10 constant _LSP17_EXTENSION_PREFIX = 0xcee78b4094da86011096;
|