@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,12 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
pragma solidity ^0.8.5;
|
|
3
|
+
|
|
4
|
+
library EIP191Signer {
|
|
5
|
+
function toDataWithIntendedValidator(address validator, bytes memory dataToSign)
|
|
6
|
+
internal
|
|
7
|
+
pure
|
|
8
|
+
returns (bytes32)
|
|
9
|
+
{
|
|
10
|
+
return keccak256(abi.encodePacked("\x19\x00", validator, dataToSign));
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
pragma solidity ^0.8.
|
|
2
|
+
pragma solidity ^0.8.4;
|
|
3
3
|
|
|
4
|
-
/* solhint-disable */
|
|
5
4
|
// DO NOT TOUCH
|
|
6
5
|
// --------------------
|
|
7
6
|
// bytecode
|
|
@@ -14,7 +13,6 @@ pragma solidity ^0.8.0;
|
|
|
14
13
|
// cost 0.0801
|
|
15
14
|
// RAW Tx:
|
|
16
15
|
// 0xf9059380852e90edd0008306f2cc8080b90540608060405234801561001057600080fd5b50610520806100206000396000f3fe6080604052600436106100345760003560e01c8063481286e61461003957806378065306146100be578063cdcb760a14610163575b600080fd5b34801561004557600080fd5b5061007c6004803603604081101561005c57600080fd5b810190808035906020019092919080359060200190929190505050610268565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b3480156100ca57600080fd5b50610121600480360360608110156100e157600080fd5b810190808035906020019092919080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061027d565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6102266004803603604081101561017957600080fd5b8101908080359060200190929190803590602001906401000000008111156101a057600080fd5b8201836020820111156101b257600080fd5b803590602001918460018302840111640100000000831117156101d457600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050509192919290505050610346565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b600061027583833061027d565b905092915050565b60008060ff60f81b83868660405160200180857effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19167effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191681526001018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660601b81526014018381526020018281526020019450505050506040516020818303038152906040528051906020012090508060001c9150509392505050565b60008060003490506000845114156103c6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f437265617465323a2062797465636f6465206c656e677468206973207a65726f81525060200191505060405180910390fd5b8484516020860183f59150600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610474576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260198152602001807f437265617465323a204661696c6564206f6e206465706c6f790000000000000081525060200191505060405180910390fd5b7fc16bb3dbd36917c7aa3e76b988c2cd35e74bb230a02fef61e7376d8b4bfaea778286604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a181925050509291505056fea26469706673582212208e45d684157bfc10076a3d284f8c3899cd5ecf31abade0a086223e0886a8a68164736f6c634300060100331ba01234123412341234123412341234123412341234123412341234123412341234a01234123412341234123412341234123412341234123412341234123412341234
|
|
17
|
-
/* solhint-enable */
|
|
18
16
|
|
|
19
17
|
/**
|
|
20
18
|
* @title contract to deploy contracts with precomputed addresses, using create2 opcode
|
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
pragma solidity ^0.8.
|
|
2
|
+
pragma solidity ^0.8.4;
|
|
3
3
|
|
|
4
4
|
// --- ERC165 interface ids
|
|
5
|
-
bytes4 constant _INTERFACEID_LSP0 =
|
|
5
|
+
bytes4 constant _INTERFACEID_LSP0 = 0x66767497;
|
|
6
6
|
bytes4 constant _INTERFACEID_ERC1271 = 0x1626ba7e;
|
|
7
7
|
|
|
8
8
|
// ERC1271 - Standard Signature Validation
|
|
9
9
|
bytes4 constant _ERC1271_MAGICVALUE = 0x1626ba7e;
|
|
10
10
|
bytes4 constant _ERC1271_FAILVALUE = 0xffffffff;
|
|
11
|
+
|
|
12
|
+
// Ownerhsip Transfer Type IDs
|
|
13
|
+
|
|
14
|
+
// keccak256('LSP0OwnershipTransferStarted')
|
|
15
|
+
bytes32 constant _TYPEID_LSP0_OwnershipTransferStarted = 0xe17117c9d2665d1dbeb479ed8058bbebde3c50ac50e2e65619f60006caac6926;
|
|
16
|
+
|
|
17
|
+
// keccak256('LSP0OwnershipTransferred_SenderNotification')
|
|
18
|
+
bytes32 constant _TYPEID_LSP0_OwnershipTransferred_SenderNotification = 0xa4e59c931d14f7c8a7a35027f92ee40b5f2886b9fdcdb78f30bc5ecce5a2f814;
|
|
19
|
+
|
|
20
|
+
// keccak256('LSP0OwnershipTransferred_RecipientNotification')
|
|
21
|
+
bytes32 constant _TYPEID_LSP0_OwnershipTransferred_RecipientNotification = 0xceca317f109c43507871523e82dc2a3cc64dfa18f12da0b6db14f6e23f995538;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
pragma solidity ^0.8.
|
|
2
|
+
pragma solidity ^0.8.4;
|
|
3
3
|
|
|
4
4
|
// modules
|
|
5
5
|
import {LSP0ERC725AccountCore} from "./LSP0ERC725AccountCore.sol";
|
|
@@ -16,6 +16,7 @@ contract LSP0ERC725Account is LSP0ERC725AccountCore {
|
|
|
16
16
|
* @param newOwner the owner of the contract
|
|
17
17
|
*/
|
|
18
18
|
constructor(address newOwner) payable {
|
|
19
|
+
if (msg.value != 0) emit ValueReceived(msg.sender, msg.value);
|
|
19
20
|
OwnableUnset._setOwner(newOwner);
|
|
20
21
|
}
|
|
21
22
|
}
|
|
@@ -1,36 +1,45 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
pragma solidity ^0.8.
|
|
2
|
+
pragma solidity ^0.8.4;
|
|
3
3
|
|
|
4
4
|
// interfaces
|
|
5
5
|
import {IERC1271} from "@openzeppelin/contracts/interfaces/IERC1271.sol";
|
|
6
6
|
import {ILSP1UniversalReceiver} from "../LSP1UniversalReceiver/ILSP1UniversalReceiver.sol";
|
|
7
|
-
import {
|
|
8
|
-
ILSP1UniversalReceiverDelegate
|
|
9
|
-
} from "../LSP1UniversalReceiver/ILSP1UniversalReceiverDelegate.sol";
|
|
10
7
|
|
|
11
8
|
// libraries
|
|
12
9
|
import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol";
|
|
13
10
|
import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
|
|
14
|
-
import {ERC165Checker} from "
|
|
11
|
+
import {ERC165Checker} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
|
|
12
|
+
import {Address} from "@openzeppelin/contracts/utils/Address.sol";
|
|
13
|
+
import {LSP1Utils} from "../LSP1UniversalReceiver/LSP1Utils.sol";
|
|
14
|
+
import {LSP2Utils} from "../LSP2ERC725YJSONSchema/LSP2Utils.sol";
|
|
15
15
|
|
|
16
16
|
// modules
|
|
17
17
|
import {ERC725YCore} from "@erc725/smart-contracts/contracts/ERC725YCore.sol";
|
|
18
18
|
import {ERC725XCore} from "@erc725/smart-contracts/contracts/ERC725XCore.sol";
|
|
19
19
|
import {OwnableUnset} from "@erc725/smart-contracts/contracts/custom/OwnableUnset.sol";
|
|
20
|
-
import {
|
|
20
|
+
import {LSP14Ownable2Step} from "../LSP14Ownable2Step/LSP14Ownable2Step.sol";
|
|
21
|
+
import {LSP17Extendable} from "../LSP17ContractExtension/LSP17Extendable.sol";
|
|
21
22
|
|
|
22
23
|
// constants
|
|
24
|
+
import "@erc725/smart-contracts/contracts/constants.sol";
|
|
25
|
+
import "@erc725/smart-contracts/contracts/errors.sol";
|
|
23
26
|
import {
|
|
24
27
|
_INTERFACEID_LSP0,
|
|
25
28
|
_INTERFACEID_ERC1271,
|
|
26
|
-
|
|
29
|
+
_ERC1271_MAGICVALUE,
|
|
30
|
+
_ERC1271_FAILVALUE,
|
|
31
|
+
_TYPEID_LSP0_OwnershipTransferStarted,
|
|
32
|
+
_TYPEID_LSP0_OwnershipTransferred_SenderNotification,
|
|
33
|
+
_TYPEID_LSP0_OwnershipTransferred_RecipientNotification
|
|
27
34
|
} from "../LSP0ERC725Account/LSP0Constants.sol";
|
|
28
35
|
import {
|
|
29
36
|
_INTERFACEID_LSP1,
|
|
30
|
-
|
|
37
|
+
_LSP1_UNIVERSAL_RECEIVER_DELEGATE_PREFIX,
|
|
31
38
|
_LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY
|
|
32
39
|
} from "../LSP1UniversalReceiver/LSP1Constants.sol";
|
|
33
|
-
import {
|
|
40
|
+
import {_INTERFACEID_LSP14} from "../LSP14Ownable2Step/LSP14Constants.sol";
|
|
41
|
+
|
|
42
|
+
import {_LSP17_EXTENSION_PREFIX} from "../LSP17ContractExtension/LSP17Constants.sol";
|
|
34
43
|
|
|
35
44
|
/**
|
|
36
45
|
* @title Core Implementation of ERC725Account
|
|
@@ -40,67 +49,106 @@ import {_INTERFACEID_CLAIM_OWNERSHIP} from "../Custom/IClaimOwnership.sol";
|
|
|
40
49
|
abstract contract LSP0ERC725AccountCore is
|
|
41
50
|
ERC725XCore,
|
|
42
51
|
ERC725YCore,
|
|
43
|
-
|
|
52
|
+
LSP14Ownable2Step,
|
|
53
|
+
LSP17Extendable,
|
|
44
54
|
IERC1271,
|
|
45
55
|
ILSP1UniversalReceiver
|
|
46
56
|
{
|
|
57
|
+
using ERC165Checker for address;
|
|
58
|
+
using LSP1Utils for address;
|
|
59
|
+
using Address for address;
|
|
60
|
+
|
|
47
61
|
/**
|
|
48
62
|
* @notice Emitted when receiving native tokens
|
|
49
63
|
* @param sender The address of the sender
|
|
50
|
-
* @param value The amount of
|
|
64
|
+
* @param value The amount of native tokens received
|
|
51
65
|
*/
|
|
52
66
|
event ValueReceived(address indexed sender, uint256 indexed value);
|
|
53
67
|
|
|
54
68
|
/**
|
|
55
69
|
* @dev Emits an event when receiving native tokens
|
|
70
|
+
*
|
|
71
|
+
* Executed when receiving native tokens with empty calldata.
|
|
56
72
|
*/
|
|
57
|
-
|
|
73
|
+
receive() external payable virtual {
|
|
58
74
|
if (msg.value != 0) emit ValueReceived(msg.sender, msg.value);
|
|
59
75
|
}
|
|
60
76
|
|
|
61
|
-
// ERC165
|
|
62
|
-
|
|
63
77
|
/**
|
|
64
|
-
* @dev
|
|
78
|
+
* @dev Returns the extension stored under the `_LSP17_EXTENSION_PREFIX` data key
|
|
79
|
+
* mapped to the functionSelector provided.
|
|
80
|
+
*
|
|
81
|
+
* If no extension is stored, returns the address(0)
|
|
65
82
|
*/
|
|
66
|
-
function
|
|
67
|
-
|
|
83
|
+
function _getExtension(bytes4 functionSelector)
|
|
84
|
+
internal
|
|
68
85
|
view
|
|
69
86
|
virtual
|
|
70
|
-
override
|
|
71
|
-
returns (
|
|
87
|
+
override
|
|
88
|
+
returns (address)
|
|
72
89
|
{
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
90
|
+
bytes32 mappedExtensionDataKey = LSP2Utils.generateMappingKey(
|
|
91
|
+
_LSP17_EXTENSION_PREFIX,
|
|
92
|
+
functionSelector
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
// Check if there is an extension for the function selector provided
|
|
96
|
+
address extension = address(bytes20(_getData(mappedExtensionDataKey)));
|
|
97
|
+
|
|
98
|
+
return extension;
|
|
79
99
|
}
|
|
80
100
|
|
|
81
|
-
//
|
|
101
|
+
// solhint-disable no-complex-fallback
|
|
82
102
|
|
|
83
103
|
/**
|
|
84
|
-
* @dev
|
|
104
|
+
* @dev Emits an event when receiving native tokens
|
|
105
|
+
*
|
|
106
|
+
* Forwards the call to an extension contract (address). This address can be retrieved from
|
|
107
|
+
* the ERC725Y data key-value store using the data key below (function selector appended to the prefix):
|
|
108
|
+
*_LSP17_FALLBACK_EXTENSIONS_HANDLER_ + <function-selector>
|
|
109
|
+
* If there is no extension stored under the data key, return.
|
|
110
|
+
*
|
|
111
|
+
* The call to the extension is appended with bytes20 (msg.sender) and bytes32 (msg.value).
|
|
112
|
+
* Returns the return value on success and revert in case of failure.
|
|
113
|
+
*
|
|
114
|
+
* If the msg.data is shorter than 4 bytes or the first 4 bytes are 0s
|
|
115
|
+
* do not check for an extension and return
|
|
116
|
+
*
|
|
117
|
+
* Executed when:
|
|
118
|
+
* - the first 4 bytes of the calldata do not match any publicly callable functions from the contract ABI.
|
|
119
|
+
* - receiving native tokens with some calldata.
|
|
85
120
|
*/
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
{
|
|
92
|
-
ClaimOwnership._transferOwnership(_newOwner);
|
|
121
|
+
fallback() external payable virtual {
|
|
122
|
+
if (msg.value != 0) emit ValueReceived(msg.sender, msg.value);
|
|
123
|
+
if (msg.data.length < 4 || msg.sig == bytes4(0)) return;
|
|
124
|
+
|
|
125
|
+
_fallbackLSP17Extendable();
|
|
93
126
|
}
|
|
94
127
|
|
|
95
128
|
/**
|
|
96
|
-
* @dev
|
|
129
|
+
* @dev Returns true if this contract implements the interface defined by
|
|
130
|
+
* `interfaceId`.
|
|
131
|
+
*
|
|
132
|
+
* If the contract doesn't support the `interfaceId`, it forwards the call to the
|
|
133
|
+
* `supportsInterface` extension according to LSP17, and checks if the extension
|
|
134
|
+
* implements the interface defined by `interfaceId`.
|
|
97
135
|
*/
|
|
98
|
-
function
|
|
99
|
-
|
|
136
|
+
function supportsInterface(bytes4 interfaceId)
|
|
137
|
+
public
|
|
138
|
+
view
|
|
139
|
+
virtual
|
|
140
|
+
override(ERC725XCore, ERC725YCore, LSP17Extendable)
|
|
141
|
+
returns (bool)
|
|
142
|
+
{
|
|
143
|
+
return
|
|
144
|
+
interfaceId == _INTERFACEID_ERC1271 ||
|
|
145
|
+
interfaceId == _INTERFACEID_LSP0 ||
|
|
146
|
+
interfaceId == _INTERFACEID_LSP1 ||
|
|
147
|
+
interfaceId == _INTERFACEID_LSP14 ||
|
|
148
|
+
super.supportsInterface(interfaceId) ||
|
|
149
|
+
_supportsInterfaceInERC165Extension(interfaceId);
|
|
100
150
|
}
|
|
101
151
|
|
|
102
|
-
// ERC1271
|
|
103
|
-
|
|
104
152
|
/**
|
|
105
153
|
* @notice Checks if an owner signed `_data`.
|
|
106
154
|
* ERC1271 interface.
|
|
@@ -111,64 +159,214 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
111
159
|
function isValidSignature(bytes32 dataHash, bytes memory signature)
|
|
112
160
|
public
|
|
113
161
|
view
|
|
162
|
+
virtual
|
|
114
163
|
returns (bytes4 magicValue)
|
|
115
164
|
{
|
|
116
165
|
address _owner = owner();
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
166
|
+
|
|
167
|
+
// If owner is a contract
|
|
168
|
+
if (_owner.code.length > 0) {
|
|
169
|
+
(bool success, bytes memory result) = _owner.staticcall(
|
|
170
|
+
abi.encodeWithSelector(IERC1271.isValidSignature.selector, dataHash, signature)
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
bool isValid = (success &&
|
|
174
|
+
result.length == 32 &&
|
|
175
|
+
abi.decode(result, (bytes32)) == bytes32(_ERC1271_MAGICVALUE));
|
|
176
|
+
|
|
177
|
+
return isValid ? _ERC1271_MAGICVALUE : _ERC1271_FAILVALUE;
|
|
178
|
+
}
|
|
179
|
+
// If owner is an EOA
|
|
180
|
+
else {
|
|
125
181
|
return
|
|
126
182
|
_owner == ECDSA.recover(dataHash, signature)
|
|
127
|
-
?
|
|
183
|
+
? _ERC1271_MAGICVALUE
|
|
128
184
|
: _ERC1271_FAILVALUE;
|
|
129
185
|
}
|
|
130
186
|
}
|
|
131
187
|
|
|
132
|
-
|
|
188
|
+
/**
|
|
189
|
+
* @param operationType The operation to execute: CALL = 0 CREATE = 1 CREATE2 = 2 STATICCALL = 3 DELEGATECALL = 4
|
|
190
|
+
* @param target The smart contract or address to interact with, `to` will be unused if a contract is created (operation 1 and 2)
|
|
191
|
+
* @param value The amount of native tokens to transfer (in Wei).
|
|
192
|
+
* @param data The call data, or the bytecode of the contract to deploy
|
|
193
|
+
* @dev Executes any other smart contract.
|
|
194
|
+
* SHOULD only be callable by the owner of the contract set via ERC173
|
|
195
|
+
*
|
|
196
|
+
* Emits a {Executed} event, when a call is executed under `operationType` 0, 3 and 4
|
|
197
|
+
* Emits a {ContractCreated} event, when a contract is created under `operationType` 1 and 2
|
|
198
|
+
* Emits a {ValueReceived} event, when receives native token
|
|
199
|
+
*/
|
|
200
|
+
function execute(
|
|
201
|
+
uint256 operationType,
|
|
202
|
+
address target,
|
|
203
|
+
uint256 value,
|
|
204
|
+
bytes memory data
|
|
205
|
+
) public payable virtual override onlyOwner returns (bytes memory) {
|
|
206
|
+
if (msg.value != 0) emit ValueReceived(msg.sender, msg.value);
|
|
207
|
+
return _execute(operationType, target, value, data);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* @inheritdoc ERC725XCore
|
|
212
|
+
*
|
|
213
|
+
* @dev Emits a {ValueReceived} event when receiving native tokens.
|
|
214
|
+
*/
|
|
215
|
+
function execute(
|
|
216
|
+
uint256[] memory operationsType,
|
|
217
|
+
address[] memory targets,
|
|
218
|
+
uint256[] memory values,
|
|
219
|
+
bytes[] memory datas
|
|
220
|
+
) public payable virtual override onlyOwner returns (bytes[] memory) {
|
|
221
|
+
if (msg.value != 0) emit ValueReceived(msg.sender, msg.value);
|
|
222
|
+
return _execute(operationsType, targets, values, datas);
|
|
223
|
+
}
|
|
133
224
|
|
|
134
225
|
/**
|
|
135
226
|
* @notice Triggers the UniversalReceiver event when this function gets executed successfully.
|
|
136
|
-
*
|
|
227
|
+
* Forwards the call to the addresses stored in the ERC725Y storage under the LSP1UniversalReceiverDelegate
|
|
228
|
+
* Key and the typeId Key (param) respectively. The call will be discarded if no addresses were set.
|
|
229
|
+
*
|
|
137
230
|
* @param typeId The type of call received.
|
|
138
|
-
* @param
|
|
231
|
+
* @param receivedData The data received.
|
|
232
|
+
* @return returnedValues The ABI encoded return value of the LSP1UniversalReceiverDelegate call
|
|
233
|
+
* and the LSP1TypeIdDelegate call.
|
|
139
234
|
*/
|
|
140
|
-
function universalReceiver(bytes32 typeId, bytes calldata
|
|
235
|
+
function universalReceiver(bytes32 typeId, bytes calldata receivedData)
|
|
141
236
|
public
|
|
142
237
|
payable
|
|
143
238
|
virtual
|
|
144
|
-
returns (bytes memory
|
|
239
|
+
returns (bytes memory returnedValues)
|
|
145
240
|
{
|
|
241
|
+
if (msg.value != 0) emit ValueReceived(msg.sender, msg.value);
|
|
146
242
|
bytes memory lsp1DelegateValue = _getData(_LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY);
|
|
243
|
+
bytes memory resultDefaultDelegate;
|
|
147
244
|
|
|
148
245
|
if (lsp1DelegateValue.length >= 20) {
|
|
149
246
|
address universalReceiverDelegate = address(bytes20(lsp1DelegateValue));
|
|
150
247
|
|
|
151
|
-
if (
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
248
|
+
if (universalReceiverDelegate.supportsERC165InterfaceUnchecked(_INTERFACEID_LSP1)) {
|
|
249
|
+
resultDefaultDelegate = universalReceiverDelegate
|
|
250
|
+
.callUniversalReceiverWithCallerInfos(
|
|
251
|
+
typeId,
|
|
252
|
+
receivedData,
|
|
253
|
+
msg.sender,
|
|
254
|
+
msg.value
|
|
255
|
+
);
|
|
159
256
|
}
|
|
160
257
|
}
|
|
161
|
-
|
|
258
|
+
|
|
259
|
+
bytes32 lsp1typeIdDelegateKey = LSP2Utils.generateMappingKey(
|
|
260
|
+
_LSP1_UNIVERSAL_RECEIVER_DELEGATE_PREFIX,
|
|
261
|
+
bytes20(typeId)
|
|
262
|
+
);
|
|
263
|
+
|
|
264
|
+
bytes memory lsp1TypeIdDelegateValue = _getData(lsp1typeIdDelegateKey);
|
|
265
|
+
bytes memory resultTypeIdDelegate;
|
|
266
|
+
|
|
267
|
+
if (lsp1TypeIdDelegateValue.length >= 20) {
|
|
268
|
+
address universalReceiverDelegate = address(bytes20(lsp1TypeIdDelegateValue));
|
|
269
|
+
|
|
270
|
+
if (universalReceiverDelegate.supportsERC165InterfaceUnchecked(_INTERFACEID_LSP1)) {
|
|
271
|
+
resultTypeIdDelegate = universalReceiverDelegate
|
|
272
|
+
.callUniversalReceiverWithCallerInfos(
|
|
273
|
+
typeId,
|
|
274
|
+
receivedData,
|
|
275
|
+
msg.sender,
|
|
276
|
+
msg.value
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
returnedValues = abi.encode(resultDefaultDelegate, resultTypeIdDelegate);
|
|
282
|
+
emit UniversalReceiver(msg.sender, msg.value, typeId, receivedData, returnedValues);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* @dev Sets the pending owner and notifies the pending owner
|
|
287
|
+
*
|
|
288
|
+
* @param _newOwner The address nofied and set as `pendingOwner`
|
|
289
|
+
*/
|
|
290
|
+
function transferOwnership(address _newOwner)
|
|
291
|
+
public
|
|
292
|
+
virtual
|
|
293
|
+
override(LSP14Ownable2Step, OwnableUnset)
|
|
294
|
+
onlyOwner
|
|
295
|
+
{
|
|
296
|
+
LSP14Ownable2Step._transferOwnership(_newOwner);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* @dev Renounce ownership of the contract in a 2-step process
|
|
301
|
+
*/
|
|
302
|
+
function renounceOwnership()
|
|
303
|
+
public
|
|
304
|
+
virtual
|
|
305
|
+
override(LSP14Ownable2Step, OwnableUnset)
|
|
306
|
+
onlyOwner
|
|
307
|
+
{
|
|
308
|
+
LSP14Ownable2Step._renounceOwnership();
|
|
162
309
|
}
|
|
163
310
|
|
|
164
311
|
/**
|
|
165
312
|
* @dev SAVE GAS by emitting the DataChanged event with only the first 256 bytes of dataValue
|
|
166
313
|
*/
|
|
167
314
|
function _setData(bytes32 dataKey, bytes memory dataValue) internal virtual override {
|
|
168
|
-
|
|
315
|
+
_store[dataKey] = dataValue;
|
|
169
316
|
emit DataChanged(
|
|
170
317
|
dataKey,
|
|
171
318
|
dataValue.length <= 256 ? dataValue : BytesLib.slice(dataValue, 0, 256)
|
|
172
319
|
);
|
|
173
320
|
}
|
|
321
|
+
|
|
322
|
+
// --- LSP14 URD Hooks
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* @dev Calls the universalReceiver function of the sender when ownerhsip transfer starts
|
|
326
|
+
* if supports LSP1 InterfaceId
|
|
327
|
+
*/
|
|
328
|
+
function _notifyLSP1SenderOnOwnershipTransferStart(address notifiedContract, bytes memory data)
|
|
329
|
+
internal
|
|
330
|
+
virtual
|
|
331
|
+
override
|
|
332
|
+
{
|
|
333
|
+
if (ERC165Checker.supportsERC165InterfaceUnchecked(notifiedContract, _INTERFACEID_LSP1)) {
|
|
334
|
+
ILSP1UniversalReceiver(notifiedContract).universalReceiver(
|
|
335
|
+
_TYPEID_LSP0_OwnershipTransferStarted,
|
|
336
|
+
data
|
|
337
|
+
);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* @dev Calls the universalReceiver function of the sender when ownerhsip transfer is complete
|
|
343
|
+
* if supports LSP1 InterfaceId
|
|
344
|
+
*/
|
|
345
|
+
function _notifyLSP1SenderOnOwnershipTransferCompletion(
|
|
346
|
+
address notifiedContract,
|
|
347
|
+
bytes memory data
|
|
348
|
+
) internal virtual override {
|
|
349
|
+
if (ERC165Checker.supportsERC165InterfaceUnchecked(notifiedContract, _INTERFACEID_LSP1)) {
|
|
350
|
+
ILSP1UniversalReceiver(notifiedContract).universalReceiver(
|
|
351
|
+
_TYPEID_LSP0_OwnershipTransferred_SenderNotification,
|
|
352
|
+
data
|
|
353
|
+
);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* @dev Calls the universalReceiver function of the recipient when ownerhsip transfer is complete
|
|
359
|
+
* if supports LSP1 InterfaceId
|
|
360
|
+
*/
|
|
361
|
+
function _notifyLSP1RecipientOnOwnershipTransferCompletion(
|
|
362
|
+
address notifiedContract,
|
|
363
|
+
bytes memory data
|
|
364
|
+
) internal virtual override {
|
|
365
|
+
if (ERC165Checker.supportsERC165InterfaceUnchecked(notifiedContract, _INTERFACEID_LSP1)) {
|
|
366
|
+
ILSP1UniversalReceiver(notifiedContract).universalReceiver(
|
|
367
|
+
_TYPEID_LSP0_OwnershipTransferred_RecipientNotification,
|
|
368
|
+
data
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
174
372
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
pragma solidity ^0.8.
|
|
2
|
+
pragma solidity ^0.8.4;
|
|
3
3
|
|
|
4
4
|
// modules
|
|
5
5
|
import {LSP0ERC725AccountInitAbstract} from "./LSP0ERC725AccountInitAbstract.sol";
|
|
@@ -21,7 +21,7 @@ contract LSP0ERC725AccountInit is LSP0ERC725AccountInitAbstract {
|
|
|
21
21
|
* @notice Sets the owner of the contract
|
|
22
22
|
* @param newOwner the owner of the contract
|
|
23
23
|
*/
|
|
24
|
-
function initialize(address newOwner)
|
|
24
|
+
function initialize(address newOwner) external payable virtual initializer {
|
|
25
25
|
LSP0ERC725AccountInitAbstract._initialize(newOwner);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
pragma solidity ^0.8.
|
|
2
|
+
pragma solidity ^0.8.4;
|
|
3
3
|
|
|
4
4
|
// modules
|
|
5
5
|
import {LSP0ERC725AccountCore} from "./LSP0ERC725AccountCore.sol";
|
|
@@ -13,6 +13,7 @@ import {OwnableUnset} from "@erc725/smart-contracts/contracts/custom/OwnableUnse
|
|
|
13
13
|
*/
|
|
14
14
|
abstract contract LSP0ERC725AccountInitAbstract is Initializable, LSP0ERC725AccountCore {
|
|
15
15
|
function _initialize(address newOwner) internal virtual onlyInitializing {
|
|
16
|
+
if (msg.value != 0) emit ValueReceived(msg.sender, msg.value);
|
|
16
17
|
OwnableUnset._setOwner(newOwner);
|
|
17
18
|
}
|
|
18
19
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
pragma solidity ^0.8.
|
|
2
|
+
pragma solidity ^0.8.4;
|
|
3
3
|
|
|
4
|
-
// --- ERC725Y Keys
|
|
4
|
+
// --- ERC725Y Data Keys
|
|
5
5
|
|
|
6
6
|
// keccak256('LSP10Vaults[]')
|
|
7
7
|
bytes32 constant _LSP10_VAULTS_ARRAY_KEY = 0x55482936e01da86729a45d2b87a6b1d3bc582bea0ec00e38bdb340e3af6f9f06;
|