@lukso/lsp-smart-contracts 0.7.0 → 0.8.1
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 +39 -0
- package/README.md +93 -40
- 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 +26 -5
- package/artifacts/LSP7CappedSupplyInitAbstract.json +26 -5
- package/artifacts/LSP7CompatibleERC20.json +26 -5
- package/artifacts/LSP7CompatibleERC20InitAbstract.json +28 -7
- package/artifacts/LSP7CompatibleERC20Mintable.json +29 -8
- package/artifacts/LSP7CompatibleERC20MintableInit.json +29 -8
- package/artifacts/LSP7DigitalAsset.json +26 -5
- package/artifacts/LSP7DigitalAssetInitAbstract.json +26 -5
- package/artifacts/LSP7Mintable.json +29 -8
- package/artifacts/LSP7MintableInit.json +29 -8
- package/artifacts/LSP8CappedSupply.json +27 -6
- package/artifacts/LSP8CappedSupplyInitAbstract.json +27 -6
- package/artifacts/LSP8CompatibleERC721.json +28 -7
- package/artifacts/LSP8CompatibleERC721InitAbstract.json +30 -9
- package/artifacts/LSP8CompatibleERC721Mintable.json +31 -10
- package/artifacts/LSP8CompatibleERC721MintableInit.json +31 -10
- package/artifacts/LSP8IdentifiableDigitalAsset.json +27 -6
- package/artifacts/LSP8IdentifiableDigitalAssetInitAbstract.json +27 -6
- package/artifacts/LSP8Mintable.json +30 -9
- package/artifacts/LSP8MintableInit.json +30 -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/common/constants.d.ts +738 -0
- package/common/constants.js +785 -0
- 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 +320 -63
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +2 -2
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +2 -1
- package/contracts/LSP0ERC725Account/LSP0Utils.sol +50 -0
- package/contracts/LSP10ReceivedVaults/LSP10Constants.sol +2 -2
- package/contracts/LSP10ReceivedVaults/LSP10Utils.sol +212 -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 +155 -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 +224 -506
- package/contracts/LSP6KeyManager/LSP6KeyManagerInit.sol +1 -1
- package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +3 -2
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6ExecuteModule.sol +229 -0
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6OwnershipModule.sol +25 -0
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6SetDataModule.sol +606 -0
- package/contracts/LSP6KeyManager/LSP6Utils.sol +156 -35
- 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 +36 -36
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +1 -1
- package/contracts/LSP7DigitalAsset/LSP7Errors.sol +33 -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 +45 -2
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +2 -2
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +57 -60
- 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 +234 -30
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +238 -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 +350 -127
- 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/module/constants.d.ts +738 -0
- package/module/constants.js +782 -0
- package/package.json +42 -12
- package/artifacts/UniversalFactory.json +0 -127
- package/constants.js +0 -594
- 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,48 @@
|
|
|
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";
|
|
43
|
+
|
|
44
|
+
// errors
|
|
45
|
+
import "../LSP17ContractExtension/LSP17Errors.sol";
|
|
34
46
|
|
|
35
47
|
/**
|
|
36
48
|
* @title Core Implementation of ERC725Account
|
|
@@ -40,67 +52,162 @@ import {_INTERFACEID_CLAIM_OWNERSHIP} from "../Custom/IClaimOwnership.sol";
|
|
|
40
52
|
abstract contract LSP0ERC725AccountCore is
|
|
41
53
|
ERC725XCore,
|
|
42
54
|
ERC725YCore,
|
|
43
|
-
|
|
55
|
+
LSP14Ownable2Step,
|
|
56
|
+
LSP17Extendable,
|
|
44
57
|
IERC1271,
|
|
45
58
|
ILSP1UniversalReceiver
|
|
46
59
|
{
|
|
60
|
+
using ERC165Checker for address;
|
|
61
|
+
using LSP1Utils for address;
|
|
62
|
+
using Address for address;
|
|
63
|
+
|
|
47
64
|
/**
|
|
48
65
|
* @notice Emitted when receiving native tokens
|
|
49
66
|
* @param sender The address of the sender
|
|
50
|
-
* @param value The amount of
|
|
67
|
+
* @param value The amount of native tokens received
|
|
51
68
|
*/
|
|
52
69
|
event ValueReceived(address indexed sender, uint256 indexed value);
|
|
53
70
|
|
|
54
71
|
/**
|
|
55
72
|
* @dev Emits an event when receiving native tokens
|
|
73
|
+
*
|
|
74
|
+
* Executed:
|
|
75
|
+
* - when receiving some native tokens without any additional data.
|
|
76
|
+
* - on empty calls to the contract.
|
|
56
77
|
*/
|
|
57
|
-
|
|
78
|
+
receive() external payable virtual {
|
|
58
79
|
if (msg.value != 0) emit ValueReceived(msg.sender, msg.value);
|
|
59
80
|
}
|
|
60
81
|
|
|
61
|
-
//
|
|
82
|
+
// solhint-disable no-complex-fallback
|
|
62
83
|
|
|
63
84
|
/**
|
|
64
|
-
* @dev
|
|
85
|
+
* @dev Emits an event when receiving native tokens
|
|
86
|
+
*
|
|
87
|
+
* Forwards the call to an extension contract (address). This address can be retrieved from
|
|
88
|
+
* the ERC725Y data key-value store using the data key below (function selector appended to the prefix):
|
|
89
|
+
*_LSP17_FALLBACK_EXTENSIONS_HANDLER_ + <function-selector>
|
|
90
|
+
* If there is no extension stored under the data key, return.
|
|
91
|
+
*
|
|
92
|
+
* The call to the extension is appended with bytes20 (msg.sender) and bytes32 (msg.value).
|
|
93
|
+
* Returns the return value on success and revert in case of failure.
|
|
94
|
+
*
|
|
95
|
+
* If the msg.data is shorter than 4 bytes do not check for an extension and return
|
|
96
|
+
*
|
|
97
|
+
* Executed when:
|
|
98
|
+
* - the first 4 bytes of the calldata do not match any publicly callable functions from the contract ABI.
|
|
99
|
+
* - receiving native tokens with some calldata.
|
|
65
100
|
*/
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
returns (bool)
|
|
72
|
-
{
|
|
73
|
-
return
|
|
74
|
-
interfaceId == _INTERFACEID_ERC1271 ||
|
|
75
|
-
interfaceId == _INTERFACEID_LSP0 ||
|
|
76
|
-
interfaceId == _INTERFACEID_LSP1 ||
|
|
77
|
-
interfaceId == _INTERFACEID_CLAIM_OWNERSHIP ||
|
|
78
|
-
super.supportsInterface(interfaceId);
|
|
101
|
+
fallback() external payable virtual {
|
|
102
|
+
if (msg.value != 0) emit ValueReceived(msg.sender, msg.value);
|
|
103
|
+
if (msg.data.length < 4) return;
|
|
104
|
+
|
|
105
|
+
_fallbackLSP17Extendable();
|
|
79
106
|
}
|
|
80
107
|
|
|
81
|
-
|
|
108
|
+
/**
|
|
109
|
+
* @dev Forwards the call to an extension mapped to a function selector. If no extension address
|
|
110
|
+
* is mapped to the function selector (address(0)), then revert.
|
|
111
|
+
*
|
|
112
|
+
* The bytes4(0) msg.sig is an exception, the function won't revert if there is no extension found
|
|
113
|
+
* mapped to bytes4(0), but will execute the call to the extension in case it existed.
|
|
114
|
+
*
|
|
115
|
+
* The call to the extension is appended with bytes20 (msg.sender) and bytes32 (msg.value).
|
|
116
|
+
* Returns the return value on success and revert in case of failure.
|
|
117
|
+
*
|
|
118
|
+
* Because the function uses assembly {return()/revert()} to terminate the call, it cannot be
|
|
119
|
+
* called before other codes in fallback().
|
|
120
|
+
*
|
|
121
|
+
* Otherwise, the codes after _fallbackLSP17Extendable() may never be reached.
|
|
122
|
+
*/
|
|
123
|
+
function _fallbackLSP17Extendable() internal virtual override {
|
|
124
|
+
// If there is a function selector
|
|
125
|
+
address extension = _getExtension(msg.sig);
|
|
126
|
+
|
|
127
|
+
// if no extension was found for bytes4(0) return don't revert
|
|
128
|
+
if (msg.sig == bytes4(0) && extension == address(0)) return;
|
|
129
|
+
|
|
130
|
+
// if no extension was found, revert
|
|
131
|
+
if (extension == address(0)) revert NoExtensionFoundForFunctionSelector(msg.sig);
|
|
132
|
+
|
|
133
|
+
// solhint-disable no-inline-assembly
|
|
134
|
+
// if the extension was found, call the extension with the msg.data
|
|
135
|
+
// appended with bytes20(address) and bytes32(msg.value)
|
|
136
|
+
assembly {
|
|
137
|
+
calldatacopy(0, 0, calldatasize())
|
|
138
|
+
|
|
139
|
+
// The msg.sender address is shifted to the left by 12 bytes to remove the padding
|
|
140
|
+
// Then the address without padding is stored right after the calldata
|
|
141
|
+
mstore(calldatasize(), shl(96, caller()))
|
|
142
|
+
|
|
143
|
+
// The msg.value is stored right after the calldata + msg.sender
|
|
144
|
+
mstore(add(calldatasize(), 20), callvalue())
|
|
145
|
+
|
|
146
|
+
// Add 52 bytes for the msg.sender and msg.value appended at the end of the calldata
|
|
147
|
+
let success := call(gas(), extension, 0, 0, add(calldatasize(), 52), 0, 0)
|
|
148
|
+
|
|
149
|
+
// Copy the returned data
|
|
150
|
+
returndatacopy(0, 0, returndatasize())
|
|
151
|
+
|
|
152
|
+
switch success
|
|
153
|
+
// call returns 0 on failed calls
|
|
154
|
+
case 0 {
|
|
155
|
+
revert(0, returndatasize())
|
|
156
|
+
}
|
|
157
|
+
default {
|
|
158
|
+
return(0, returndatasize())
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
82
162
|
|
|
83
163
|
/**
|
|
84
|
-
* @dev
|
|
164
|
+
* @dev Returns the extension stored under the `_LSP17_EXTENSION_PREFIX` data key
|
|
165
|
+
* mapped to the functionSelector provided.
|
|
166
|
+
*
|
|
167
|
+
* If no extension is stored, returns the address(0)
|
|
85
168
|
*/
|
|
86
|
-
function
|
|
87
|
-
|
|
169
|
+
function _getExtension(bytes4 functionSelector)
|
|
170
|
+
internal
|
|
171
|
+
view
|
|
88
172
|
virtual
|
|
89
|
-
override
|
|
90
|
-
|
|
173
|
+
override
|
|
174
|
+
returns (address)
|
|
91
175
|
{
|
|
92
|
-
|
|
176
|
+
bytes32 mappedExtensionDataKey = LSP2Utils.generateMappingKey(
|
|
177
|
+
_LSP17_EXTENSION_PREFIX,
|
|
178
|
+
functionSelector
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
// Check if there is an extension for the function selector provided
|
|
182
|
+
address extension = address(bytes20(_getData(mappedExtensionDataKey)));
|
|
183
|
+
|
|
184
|
+
return extension;
|
|
93
185
|
}
|
|
94
186
|
|
|
95
187
|
/**
|
|
96
|
-
* @dev
|
|
188
|
+
* @dev Returns true if this contract implements the interface defined by
|
|
189
|
+
* `interfaceId`.
|
|
190
|
+
*
|
|
191
|
+
* If the contract doesn't support the `interfaceId`, it forwards the call to the
|
|
192
|
+
* `supportsInterface` extension according to LSP17, and checks if the extension
|
|
193
|
+
* implements the interface defined by `interfaceId`.
|
|
97
194
|
*/
|
|
98
|
-
function
|
|
99
|
-
|
|
195
|
+
function supportsInterface(bytes4 interfaceId)
|
|
196
|
+
public
|
|
197
|
+
view
|
|
198
|
+
virtual
|
|
199
|
+
override(ERC725XCore, ERC725YCore, LSP17Extendable)
|
|
200
|
+
returns (bool)
|
|
201
|
+
{
|
|
202
|
+
return
|
|
203
|
+
interfaceId == _INTERFACEID_ERC1271 ||
|
|
204
|
+
interfaceId == _INTERFACEID_LSP0 ||
|
|
205
|
+
interfaceId == _INTERFACEID_LSP1 ||
|
|
206
|
+
interfaceId == _INTERFACEID_LSP14 ||
|
|
207
|
+
super.supportsInterface(interfaceId) ||
|
|
208
|
+
_supportsInterfaceInERC165Extension(interfaceId);
|
|
100
209
|
}
|
|
101
210
|
|
|
102
|
-
// ERC1271
|
|
103
|
-
|
|
104
211
|
/**
|
|
105
212
|
* @notice Checks if an owner signed `_data`.
|
|
106
213
|
* ERC1271 interface.
|
|
@@ -111,64 +218,214 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
111
218
|
function isValidSignature(bytes32 dataHash, bytes memory signature)
|
|
112
219
|
public
|
|
113
220
|
view
|
|
221
|
+
virtual
|
|
114
222
|
returns (bytes4 magicValue)
|
|
115
223
|
{
|
|
116
224
|
address _owner = owner();
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
225
|
+
|
|
226
|
+
// If owner is a contract
|
|
227
|
+
if (_owner.code.length > 0) {
|
|
228
|
+
(bool success, bytes memory result) = _owner.staticcall(
|
|
229
|
+
abi.encodeWithSelector(IERC1271.isValidSignature.selector, dataHash, signature)
|
|
230
|
+
);
|
|
231
|
+
|
|
232
|
+
bool isValid = (success &&
|
|
233
|
+
result.length == 32 &&
|
|
234
|
+
abi.decode(result, (bytes32)) == bytes32(_ERC1271_MAGICVALUE));
|
|
235
|
+
|
|
236
|
+
return isValid ? _ERC1271_MAGICVALUE : _ERC1271_FAILVALUE;
|
|
237
|
+
}
|
|
238
|
+
// If owner is an EOA
|
|
239
|
+
else {
|
|
125
240
|
return
|
|
126
241
|
_owner == ECDSA.recover(dataHash, signature)
|
|
127
|
-
?
|
|
242
|
+
? _ERC1271_MAGICVALUE
|
|
128
243
|
: _ERC1271_FAILVALUE;
|
|
129
244
|
}
|
|
130
245
|
}
|
|
131
246
|
|
|
132
|
-
|
|
247
|
+
/**
|
|
248
|
+
* @param operationType The operation to execute: CALL = 0 CREATE = 1 CREATE2 = 2 STATICCALL = 3 DELEGATECALL = 4
|
|
249
|
+
* @param target The smart contract or address to interact with, `to` will be unused if a contract is created (operation 1 and 2)
|
|
250
|
+
* @param value The amount of native tokens to transfer (in Wei).
|
|
251
|
+
* @param data The call data, or the bytecode of the contract to deploy
|
|
252
|
+
* @dev Executes any other smart contract.
|
|
253
|
+
* SHOULD only be callable by the owner of the contract set via ERC173
|
|
254
|
+
*
|
|
255
|
+
* Emits a {Executed} event, when a call is executed under `operationType` 0, 3 and 4
|
|
256
|
+
* Emits a {ContractCreated} event, when a contract is created under `operationType` 1 and 2
|
|
257
|
+
* Emits a {ValueReceived} event, when receives native token
|
|
258
|
+
*/
|
|
259
|
+
function execute(
|
|
260
|
+
uint256 operationType,
|
|
261
|
+
address target,
|
|
262
|
+
uint256 value,
|
|
263
|
+
bytes memory data
|
|
264
|
+
) public payable virtual override onlyOwner returns (bytes memory) {
|
|
265
|
+
if (msg.value != 0) emit ValueReceived(msg.sender, msg.value);
|
|
266
|
+
return _execute(operationType, target, value, data);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* @inheritdoc ERC725XCore
|
|
271
|
+
*
|
|
272
|
+
* @dev Emits a {ValueReceived} event when receiving native tokens.
|
|
273
|
+
*/
|
|
274
|
+
function execute(
|
|
275
|
+
uint256[] memory operationsType,
|
|
276
|
+
address[] memory targets,
|
|
277
|
+
uint256[] memory values,
|
|
278
|
+
bytes[] memory datas
|
|
279
|
+
) public payable virtual override onlyOwner returns (bytes[] memory) {
|
|
280
|
+
if (msg.value != 0) emit ValueReceived(msg.sender, msg.value);
|
|
281
|
+
return _execute(operationsType, targets, values, datas);
|
|
282
|
+
}
|
|
133
283
|
|
|
134
284
|
/**
|
|
135
285
|
* @notice Triggers the UniversalReceiver event when this function gets executed successfully.
|
|
136
|
-
*
|
|
286
|
+
* Forwards the call to the addresses stored in the ERC725Y storage under the LSP1UniversalReceiverDelegate
|
|
287
|
+
* Key and the typeId Key (param) respectively. The call will be discarded if no addresses were set.
|
|
288
|
+
*
|
|
137
289
|
* @param typeId The type of call received.
|
|
138
|
-
* @param
|
|
290
|
+
* @param receivedData The data received.
|
|
291
|
+
* @return returnedValues The ABI encoded return value of the LSP1UniversalReceiverDelegate call
|
|
292
|
+
* and the LSP1TypeIdDelegate call.
|
|
139
293
|
*/
|
|
140
|
-
function universalReceiver(bytes32 typeId, bytes calldata
|
|
294
|
+
function universalReceiver(bytes32 typeId, bytes calldata receivedData)
|
|
141
295
|
public
|
|
142
296
|
payable
|
|
143
297
|
virtual
|
|
144
|
-
returns (bytes memory
|
|
298
|
+
returns (bytes memory returnedValues)
|
|
145
299
|
{
|
|
300
|
+
if (msg.value != 0) emit ValueReceived(msg.sender, msg.value);
|
|
146
301
|
bytes memory lsp1DelegateValue = _getData(_LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY);
|
|
302
|
+
bytes memory resultDefaultDelegate;
|
|
147
303
|
|
|
148
304
|
if (lsp1DelegateValue.length >= 20) {
|
|
149
305
|
address universalReceiverDelegate = address(bytes20(lsp1DelegateValue));
|
|
150
306
|
|
|
151
|
-
if (
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
307
|
+
if (universalReceiverDelegate.supportsERC165InterfaceUnchecked(_INTERFACEID_LSP1)) {
|
|
308
|
+
resultDefaultDelegate = universalReceiverDelegate
|
|
309
|
+
.callUniversalReceiverWithCallerInfos(
|
|
310
|
+
typeId,
|
|
311
|
+
receivedData,
|
|
312
|
+
msg.sender,
|
|
313
|
+
msg.value
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
bytes32 lsp1typeIdDelegateKey = LSP2Utils.generateMappingKey(
|
|
319
|
+
_LSP1_UNIVERSAL_RECEIVER_DELEGATE_PREFIX,
|
|
320
|
+
bytes20(typeId)
|
|
321
|
+
);
|
|
322
|
+
|
|
323
|
+
bytes memory lsp1TypeIdDelegateValue = _getData(lsp1typeIdDelegateKey);
|
|
324
|
+
bytes memory resultTypeIdDelegate;
|
|
325
|
+
|
|
326
|
+
if (lsp1TypeIdDelegateValue.length >= 20) {
|
|
327
|
+
address universalReceiverDelegate = address(bytes20(lsp1TypeIdDelegateValue));
|
|
328
|
+
|
|
329
|
+
if (universalReceiverDelegate.supportsERC165InterfaceUnchecked(_INTERFACEID_LSP1)) {
|
|
330
|
+
resultTypeIdDelegate = universalReceiverDelegate
|
|
331
|
+
.callUniversalReceiverWithCallerInfos(
|
|
332
|
+
typeId,
|
|
333
|
+
receivedData,
|
|
334
|
+
msg.sender,
|
|
335
|
+
msg.value
|
|
336
|
+
);
|
|
159
337
|
}
|
|
160
338
|
}
|
|
161
|
-
|
|
339
|
+
|
|
340
|
+
returnedValues = abi.encode(resultDefaultDelegate, resultTypeIdDelegate);
|
|
341
|
+
emit UniversalReceiver(msg.sender, msg.value, typeId, receivedData, returnedValues);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* @dev Sets the pending owner and notifies the pending owner
|
|
346
|
+
*
|
|
347
|
+
* @param _newOwner The address nofied and set as `pendingOwner`
|
|
348
|
+
*/
|
|
349
|
+
function transferOwnership(address _newOwner)
|
|
350
|
+
public
|
|
351
|
+
virtual
|
|
352
|
+
override(LSP14Ownable2Step, OwnableUnset)
|
|
353
|
+
onlyOwner
|
|
354
|
+
{
|
|
355
|
+
LSP14Ownable2Step._transferOwnership(_newOwner);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* @dev Renounce ownership of the contract in a 2-step process
|
|
360
|
+
*/
|
|
361
|
+
function renounceOwnership()
|
|
362
|
+
public
|
|
363
|
+
virtual
|
|
364
|
+
override(LSP14Ownable2Step, OwnableUnset)
|
|
365
|
+
onlyOwner
|
|
366
|
+
{
|
|
367
|
+
LSP14Ownable2Step._renounceOwnership();
|
|
162
368
|
}
|
|
163
369
|
|
|
164
370
|
/**
|
|
165
371
|
* @dev SAVE GAS by emitting the DataChanged event with only the first 256 bytes of dataValue
|
|
166
372
|
*/
|
|
167
373
|
function _setData(bytes32 dataKey, bytes memory dataValue) internal virtual override {
|
|
168
|
-
|
|
374
|
+
_store[dataKey] = dataValue;
|
|
169
375
|
emit DataChanged(
|
|
170
376
|
dataKey,
|
|
171
377
|
dataValue.length <= 256 ? dataValue : BytesLib.slice(dataValue, 0, 256)
|
|
172
378
|
);
|
|
173
379
|
}
|
|
380
|
+
|
|
381
|
+
// --- LSP14 URD Hooks
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* @dev Calls the universalReceiver function of the sender when ownerhsip transfer starts
|
|
385
|
+
* if supports LSP1 InterfaceId
|
|
386
|
+
*/
|
|
387
|
+
function _notifyLSP1SenderOnOwnershipTransferStart(address notifiedContract, bytes memory data)
|
|
388
|
+
internal
|
|
389
|
+
virtual
|
|
390
|
+
override
|
|
391
|
+
{
|
|
392
|
+
if (ERC165Checker.supportsERC165InterfaceUnchecked(notifiedContract, _INTERFACEID_LSP1)) {
|
|
393
|
+
ILSP1UniversalReceiver(notifiedContract).universalReceiver(
|
|
394
|
+
_TYPEID_LSP0_OwnershipTransferStarted,
|
|
395
|
+
data
|
|
396
|
+
);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* @dev Calls the universalReceiver function of the sender when ownerhsip transfer is complete
|
|
402
|
+
* if supports LSP1 InterfaceId
|
|
403
|
+
*/
|
|
404
|
+
function _notifyLSP1SenderOnOwnershipTransferCompletion(
|
|
405
|
+
address notifiedContract,
|
|
406
|
+
bytes memory data
|
|
407
|
+
) internal virtual override {
|
|
408
|
+
if (ERC165Checker.supportsERC165InterfaceUnchecked(notifiedContract, _INTERFACEID_LSP1)) {
|
|
409
|
+
ILSP1UniversalReceiver(notifiedContract).universalReceiver(
|
|
410
|
+
_TYPEID_LSP0_OwnershipTransferred_SenderNotification,
|
|
411
|
+
data
|
|
412
|
+
);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* @dev Calls the universalReceiver function of the recipient when ownerhsip transfer is complete
|
|
418
|
+
* if supports LSP1 InterfaceId
|
|
419
|
+
*/
|
|
420
|
+
function _notifyLSP1RecipientOnOwnershipTransferCompletion(
|
|
421
|
+
address notifiedContract,
|
|
422
|
+
bytes memory data
|
|
423
|
+
) internal virtual override {
|
|
424
|
+
if (ERC165Checker.supportsERC165InterfaceUnchecked(notifiedContract, _INTERFACEID_LSP1)) {
|
|
425
|
+
ILSP1UniversalReceiver(notifiedContract).universalReceiver(
|
|
426
|
+
_TYPEID_LSP0_OwnershipTransferred_RecipientNotification,
|
|
427
|
+
data
|
|
428
|
+
);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
174
431
|
}
|
|
@@ -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
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
pragma solidity ^0.8.4;
|
|
3
|
+
|
|
4
|
+
// libraries
|
|
5
|
+
import {LSP2Utils} from "../LSP2ERC725YJSONSchema/LSP2Utils.sol";
|
|
6
|
+
|
|
7
|
+
// constants
|
|
8
|
+
import {
|
|
9
|
+
_INTERFACEID_LSP1,
|
|
10
|
+
_LSP1_UNIVERSAL_RECEIVER_DELEGATE_PREFIX,
|
|
11
|
+
_LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY
|
|
12
|
+
} from "../LSP1UniversalReceiver/LSP1Constants.sol";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @title Utility functions to query the storage of an LSP0ERC725Account
|
|
16
|
+
* @author Jean Cavallera (CJ42), Yamen Merhi (YamenMerhi)
|
|
17
|
+
*/
|
|
18
|
+
library LSP0Utils {
|
|
19
|
+
/**
|
|
20
|
+
* @dev query internally the ERC725Y storage of a LSP0ERC725YContract to retrieve
|
|
21
|
+
* the value set for the `LSP1UniversalReceiverDelegate` data key.
|
|
22
|
+
* @param erc725YStorage a reference to the ERC725Y storage mapping.
|
|
23
|
+
* @return the bytes value stored under the `LSP1UniversalReceiverDelegate` data key.
|
|
24
|
+
*/
|
|
25
|
+
function getLSP1DelegateValue(mapping(bytes32 => bytes) storage erc725YStorage)
|
|
26
|
+
internal
|
|
27
|
+
view
|
|
28
|
+
returns (bytes memory)
|
|
29
|
+
{
|
|
30
|
+
return erc725YStorage[_LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @dev query internally the storage of a LSP0ERC725Account to retrieve
|
|
35
|
+
* the value set for the `LSP1UniversalReceiverDelegate:<bytes32>` data key for a specific typeId.
|
|
36
|
+
* @param erc725YStorage a reference to the ERC725Y storage mapping.
|
|
37
|
+
* @param typeId a bytes32 typeId;
|
|
38
|
+
* @return the bytes value stored under the `LSP1UniversalReceiverDelegate:<bytes32>` data key.
|
|
39
|
+
*/
|
|
40
|
+
function getLSP1DelegateValueForTypeId(
|
|
41
|
+
mapping(bytes32 => bytes) storage erc725YStorage,
|
|
42
|
+
bytes32 typeId
|
|
43
|
+
) internal view returns (bytes memory) {
|
|
44
|
+
bytes32 lsp1TypeIdDataKey = LSP2Utils.generateMappingKey(
|
|
45
|
+
_LSP1_UNIVERSAL_RECEIVER_DELEGATE_PREFIX,
|
|
46
|
+
bytes20(typeId)
|
|
47
|
+
);
|
|
48
|
+
return erc725YStorage[lsp1TypeIdDataKey];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -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;
|