@lukso/lsp-smart-contracts 0.10.0 → 0.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -1
- package/artifacts/Create2Factory.json +2 -2
- package/artifacts/LSP0ERC725Account.json +4 -4
- package/artifacts/LSP0ERC725AccountInit.json +4 -4
- package/artifacts/LSP11BasicSocialRecovery.json +2 -2
- package/artifacts/LSP11BasicSocialRecoveryInit.json +2 -2
- package/artifacts/LSP16UniversalFactory.json +27 -21
- package/artifacts/LSP1UniversalReceiverDelegateUP.json +2 -2
- package/artifacts/LSP1UniversalReceiverDelegateVault.json +2 -2
- package/artifacts/LSP6KeyManager.json +2 -2
- package/artifacts/LSP6KeyManagerInit.json +2 -2
- package/artifacts/LSP7CompatibleERC20Mintable.json +2 -2
- package/artifacts/LSP7CompatibleERC20MintableInit.json +2 -2
- package/artifacts/LSP7Mintable.json +2 -2
- package/artifacts/LSP7MintableInit.json +2 -2
- package/artifacts/LSP8CompatibleERC721Mintable.json +2 -2
- package/artifacts/LSP8CompatibleERC721MintableInit.json +2 -2
- package/artifacts/LSP8Mintable.json +2 -2
- package/artifacts/LSP8MintableInit.json +2 -2
- package/artifacts/LSP9Vault.json +2 -2
- package/artifacts/LSP9VaultInit.json +2 -2
- package/artifacts/UniversalProfile.json +4 -4
- package/artifacts/UniversalProfileInit.json +4 -4
- package/artifacts/UniversalReceiverAddressStore.json +2 -2
- package/contracts/Factories/Create2Factory.sol +11 -3
- package/contracts/LSP0ERC725Account/ILSP0ERC725Account.sol +13 -5
- package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +11 -6
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +256 -186
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +20 -6
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +23 -9
- package/contracts/LSP0ERC725Account/LSP0Utils.sol +3 -5
- package/contracts/LSP10ReceivedVaults/LSP10Utils.sol +25 -10
- package/contracts/LSP11BasicSocialRecovery/ILSP11BasicSocialRecovery.sol +4 -2
- package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecovery.sol +3 -1
- package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryCore.sol +65 -23
- package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryInit.sol +7 -2
- package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryInitAbstract.sol +14 -4
- package/contracts/LSP11BasicSocialRecovery/LSP11Errors.sol +4 -1
- package/contracts/LSP14Ownable2Step/ILSP14Ownable2Step.sol +17 -16
- package/contracts/LSP14Ownable2Step/LSP14Errors.sol +4 -1
- package/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol +22 -11
- package/contracts/LSP16UniversalFactory/LSP16UniversalFactory.sol +333 -128
- package/contracts/LSP17ContractExtension/LSP17Extendable.sol +38 -16
- package/contracts/LSP17ContractExtension/LSP17Extension.sol +20 -8
- package/contracts/LSP17ContractExtension/LSP17Utils.sol +4 -5
- package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiver.sol +5 -5
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +38 -14
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +31 -11
- package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +34 -9
- package/contracts/LSP20CallVerification/{ILSP20CallVerification.sol → ILSP20CallVerifier.sol} +7 -2
- package/contracts/LSP20CallVerification/LSP20CallVerification.sol +24 -9
- package/contracts/LSP20CallVerification/LSP20Errors.sol +1 -1
- package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +62 -36
- package/contracts/LSP4DigitalAssetMetadata/ILSP4Compatibility.sol +3 -1
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol +15 -4
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +18 -5
- package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +32 -12
- package/contracts/LSP6KeyManager/ILSP6KeyManager.sol +17 -8
- package/contracts/LSP6KeyManager/LSP6Constants.sol +3 -9
- package/contracts/LSP6KeyManager/LSP6Errors.sol +4 -1
- package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +114 -72
- package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +7 -2
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6ExecuteModule.sol +96 -46
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6OwnershipModule.sol +10 -5
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6SetDataModule.sol +98 -32
- package/contracts/LSP6KeyManager/LSP6Utils.sol +42 -34
- package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +8 -6
- package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +13 -10
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +96 -26
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +11 -9
- package/contracts/LSP7DigitalAsset/LSP7Errors.sol +8 -2
- package/contracts/LSP7DigitalAsset/extensions/ILSP7CompatibleERC20.sol +9 -2
- package/contracts/LSP7DigitalAsset/extensions/LSP7Burnable.sol +1 -5
- package/contracts/LSP7DigitalAsset/extensions/LSP7BurnableInitAbstract.sol +4 -6
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInitAbstract.sol +6 -2
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.sol +32 -12
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20InitAbstract.sol +28 -7
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInit.sol +8 -2
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInitAbstract.sol +6 -2
- package/contracts/LSP7DigitalAsset/presets/LSP7MintableInit.sol +6 -1
- package/contracts/LSP7DigitalAsset/presets/LSP7MintableInitAbstract.sol +13 -3
- package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +14 -5
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol +3 -1
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +12 -10
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +95 -28
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +14 -10
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CompatibleERC721.sol +23 -10
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Burnable.sol +3 -1
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.sol +3 -1
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInitAbstract.sol +6 -2
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +72 -30
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +77 -27
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.sol +6 -2
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableInitAbstract.sol +6 -2
- package/contracts/LSP8IdentifiableDigitalAsset/presets/ILSP8Mintable.sol +3 -1
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInit.sol +8 -2
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInitAbstract.sol +6 -2
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.sol +3 -1
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +5 -1
- package/contracts/LSP9Vault/ILSP9Vault.sol +13 -5
- package/contracts/LSP9Vault/LSP9Vault.sol +7 -2
- package/contracts/LSP9Vault/LSP9VaultCore.sol +108 -51
- package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +10 -3
- package/contracts/Legacy/Registries/AddressRegistry.sol +13 -4
- package/contracts/Legacy/Registries/AddressRegistryRequiresERC725.sol +6 -2
- package/contracts/Legacy/UniversalReceiverAddressStore.sol +17 -6
- package/contracts/UniversalProfile.sol +14 -5
- package/contracts/UniversalProfileInit.sol +17 -5
- package/contracts/UniversalProfileInitAbstract.sol +17 -9
- package/devdocs/LSP0ERC725Account.json +33 -19
- package/devdocs/LSP0ERC725AccountInit.json +33 -20
- package/devdocs/LSP16UniversalFactory.json +87 -22
- package/devdocs/LSP9Vault.json +3 -3
- package/devdocs/LSP9VaultInit.json +3 -3
- package/devdocs/UniversalProfile.json +32 -18
- package/devdocs/UniversalProfileInit.json +33 -19
- package/dist/constants.cjs.js +310 -182
- package/dist/constants.d.ts +178 -48
- package/dist/constants.es.js +310 -182
- package/package.json +19 -17
- package/userdocs/LSP0ERC725Account.json +5 -2
- package/userdocs/LSP0ERC725AccountInit.json +8 -2
- package/userdocs/UniversalProfile.json +3 -3
- package/userdocs/UniversalProfileInit.json +6 -3
- package/contracts/Custom/EIP191Signer.sol +0 -12
|
@@ -3,7 +3,9 @@ pragma solidity ^0.8.4;
|
|
|
3
3
|
|
|
4
4
|
// modules
|
|
5
5
|
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
ERC165Checker
|
|
8
|
+
} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
|
|
7
9
|
|
|
8
10
|
// constants
|
|
9
11
|
import {_INTERFACEID_LSP17_EXTENDABLE} from "./LSP17Constants.sol";
|
|
@@ -12,8 +14,10 @@ import {_INTERFACEID_LSP17_EXTENDABLE} from "./LSP17Constants.sol";
|
|
|
12
14
|
import "./LSP17Errors.sol";
|
|
13
15
|
|
|
14
16
|
/**
|
|
15
|
-
* @title
|
|
16
|
-
*
|
|
17
|
+
* @title Module to add more functionalities to a contract using extensions.
|
|
18
|
+
*
|
|
19
|
+
* @dev Implementation of the `fallback(...)` logic according to LSP17 - Contract Extension standard.
|
|
20
|
+
* This module can be inherited to extend the functionality of the parent contract when
|
|
17
21
|
* calling a function that doesn't exist on the parent contract via forwarding the call
|
|
18
22
|
* to an extension mapped to the function selector being called, set originally by the parent contract
|
|
19
23
|
*/
|
|
@@ -21,8 +25,12 @@ abstract contract LSP17Extendable is ERC165 {
|
|
|
21
25
|
/**
|
|
22
26
|
* @dev See {IERC165-supportsInterface}.
|
|
23
27
|
*/
|
|
24
|
-
function supportsInterface(
|
|
25
|
-
|
|
28
|
+
function supportsInterface(
|
|
29
|
+
bytes4 interfaceId
|
|
30
|
+
) public view virtual override returns (bool) {
|
|
31
|
+
return
|
|
32
|
+
interfaceId == _INTERFACEID_LSP17_EXTENDABLE ||
|
|
33
|
+
super.supportsInterface(interfaceId);
|
|
26
34
|
}
|
|
27
35
|
|
|
28
36
|
/**
|
|
@@ -33,16 +41,19 @@ abstract contract LSP17Extendable is ERC165 {
|
|
|
33
41
|
* supported by reading whether the interfaceId queried is supported in the `supportsInterface`
|
|
34
42
|
* extension if the extension is set, if not it returns false.
|
|
35
43
|
*/
|
|
36
|
-
function _supportsInterfaceInERC165Extension(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
address erc165Extension = _getExtension(ERC165.supportsInterface.selector);
|
|
44
|
+
function _supportsInterfaceInERC165Extension(
|
|
45
|
+
bytes4 interfaceId
|
|
46
|
+
) internal view virtual returns (bool) {
|
|
47
|
+
address erc165Extension = _getExtension(
|
|
48
|
+
ERC165.supportsInterface.selector
|
|
49
|
+
);
|
|
43
50
|
if (erc165Extension == address(0)) return false;
|
|
44
51
|
|
|
45
|
-
return
|
|
52
|
+
return
|
|
53
|
+
ERC165Checker.supportsERC165InterfaceUnchecked(
|
|
54
|
+
erc165Extension,
|
|
55
|
+
interfaceId
|
|
56
|
+
);
|
|
46
57
|
}
|
|
47
58
|
|
|
48
59
|
/**
|
|
@@ -51,7 +62,9 @@ abstract contract LSP17Extendable is ERC165 {
|
|
|
51
62
|
* To be overrided.
|
|
52
63
|
* Up to the implementor contract to return an extension based on a function selector
|
|
53
64
|
*/
|
|
54
|
-
function _getExtension(
|
|
65
|
+
function _getExtension(
|
|
66
|
+
bytes4 functionSelector
|
|
67
|
+
) internal view virtual returns (address);
|
|
55
68
|
|
|
56
69
|
/**
|
|
57
70
|
* @dev Forwards the call to an extension mapped to a function selector.
|
|
@@ -75,7 +88,8 @@ abstract contract LSP17Extendable is ERC165 {
|
|
|
75
88
|
address extension = _getExtension(msg.sig);
|
|
76
89
|
|
|
77
90
|
// if no extension was found, revert
|
|
78
|
-
if (extension == address(0))
|
|
91
|
+
if (extension == address(0))
|
|
92
|
+
revert NoExtensionFoundForFunctionSelector(msg.sig);
|
|
79
93
|
|
|
80
94
|
// solhint-disable no-inline-assembly
|
|
81
95
|
// if the extension was found, call the extension with the msg.data
|
|
@@ -91,7 +105,15 @@ abstract contract LSP17Extendable is ERC165 {
|
|
|
91
105
|
mstore(add(calldatasize(), 20), callvalue())
|
|
92
106
|
|
|
93
107
|
// Add 52 bytes for the msg.sender and msg.value appended at the end of the calldata
|
|
94
|
-
let success := call(
|
|
108
|
+
let success := call(
|
|
109
|
+
gas(),
|
|
110
|
+
extension,
|
|
111
|
+
0,
|
|
112
|
+
0,
|
|
113
|
+
add(calldatasize(), 52),
|
|
114
|
+
0,
|
|
115
|
+
0
|
|
116
|
+
)
|
|
95
117
|
|
|
96
118
|
// Copy the returned data
|
|
97
119
|
returndatacopy(0, 0, returndatasize())
|
|
@@ -8,24 +8,33 @@ import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
|
|
|
8
8
|
import {_INTERFACEID_LSP17_EXTENSION} from "./LSP17Constants.sol";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* @title
|
|
12
|
-
*
|
|
11
|
+
* @title Module to create a contract that can act as an extension.
|
|
12
|
+
*
|
|
13
|
+
* @dev Implementation of the extension logic according to LSP17ContractExtension.
|
|
14
|
+
* This module can be inherited to provide context of the msg variable related to the extendable contract
|
|
13
15
|
*/
|
|
14
16
|
abstract contract LSP17Extension is ERC165 {
|
|
15
|
-
// solhint-disable
|
|
16
|
-
|
|
17
17
|
/**
|
|
18
18
|
* @dev See {IERC165-supportsInterface}.
|
|
19
19
|
*/
|
|
20
|
-
function supportsInterface(
|
|
21
|
-
|
|
20
|
+
function supportsInterface(
|
|
21
|
+
bytes4 interfaceId
|
|
22
|
+
) public view virtual override returns (bool) {
|
|
23
|
+
return
|
|
24
|
+
interfaceId == _INTERFACEID_LSP17_EXTENSION ||
|
|
25
|
+
super.supportsInterface(interfaceId);
|
|
22
26
|
}
|
|
23
27
|
|
|
24
28
|
/**
|
|
25
29
|
* @dev Returns the original msg.data passed to the extendable contract
|
|
26
30
|
* without the appended msg.sender and msg.value
|
|
27
31
|
*/
|
|
28
|
-
function _extendableMsgData()
|
|
32
|
+
function _extendableMsgData()
|
|
33
|
+
internal
|
|
34
|
+
view
|
|
35
|
+
virtual
|
|
36
|
+
returns (bytes calldata)
|
|
37
|
+
{
|
|
29
38
|
return msg.data[:msg.data.length - 52];
|
|
30
39
|
}
|
|
31
40
|
|
|
@@ -33,7 +42,10 @@ abstract contract LSP17Extension is ERC165 {
|
|
|
33
42
|
* @dev Returns the original msg.sender calling the extendable contract
|
|
34
43
|
*/
|
|
35
44
|
function _extendableMsgSender() internal view virtual returns (address) {
|
|
36
|
-
return
|
|
45
|
+
return
|
|
46
|
+
address(
|
|
47
|
+
bytes20(msg.data[msg.data.length - 52:msg.data.length - 32])
|
|
48
|
+
);
|
|
37
49
|
}
|
|
38
50
|
|
|
39
51
|
/**
|
|
@@ -10,11 +10,10 @@ library LSP17Utils {
|
|
|
10
10
|
* the parametersLength with offset with an additional of 52 bytes supposed msg.sender
|
|
11
11
|
* and msg.value appended is equal to the msgDataLength
|
|
12
12
|
*/
|
|
13
|
-
function isExtension(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
{
|
|
13
|
+
function isExtension(
|
|
14
|
+
uint256 parametersLengthWithOffset,
|
|
15
|
+
uint256 msgDataLength
|
|
16
|
+
) internal pure returns (bool) {
|
|
18
17
|
return (parametersLengthWithOffset + 52) == msgDataLength;
|
|
19
18
|
}
|
|
20
19
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
pragma solidity ^0.8.4;
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* @title
|
|
5
|
+
* @title Interface of the LSP1 - Universal Receiver standard, an entry function for a contract to receive arbitrary information.
|
|
6
6
|
* @dev LSP1UniversalReceiver allows to receive arbitrary messages and to be informed when assets are sent or received
|
|
7
7
|
*/
|
|
8
8
|
interface ILSP1UniversalReceiver {
|
|
@@ -29,8 +29,8 @@ interface ILSP1UniversalReceiver {
|
|
|
29
29
|
*
|
|
30
30
|
* Emits a {UniversalReceiver} event
|
|
31
31
|
*/
|
|
32
|
-
function universalReceiver(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
function universalReceiver(
|
|
33
|
+
bytes32 typeId,
|
|
34
|
+
bytes calldata data
|
|
35
|
+
) external payable returns (bytes memory);
|
|
36
36
|
}
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
pragma solidity ^0.8.4;
|
|
3
3
|
|
|
4
4
|
// interfaces
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
IERC725Y
|
|
7
|
+
} from "@erc725/smart-contracts/contracts/interfaces/IERC725Y.sol";
|
|
6
8
|
import {ILSP1UniversalReceiver} from "../ILSP1UniversalReceiver.sol";
|
|
7
9
|
import {ILSP7DigitalAsset} from "../../LSP7DigitalAsset/ILSP7DigitalAsset.sol";
|
|
8
10
|
|
|
@@ -10,7 +12,9 @@ import {ILSP7DigitalAsset} from "../../LSP7DigitalAsset/ILSP7DigitalAsset.sol";
|
|
|
10
12
|
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
|
|
11
13
|
|
|
12
14
|
// libraries
|
|
13
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
ERC165Checker
|
|
17
|
+
} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
|
|
14
18
|
import {LSP1Utils} from "../LSP1Utils.sol";
|
|
15
19
|
import {LSP2Utils} from "../../LSP2ERC725YJSONSchema/LSP2Utils.sol";
|
|
16
20
|
import {LSP5Utils} from "../../LSP5ReceivedAssets/LSP5Utils.sol";
|
|
@@ -83,8 +87,12 @@ contract LSP1UniversalReceiverDelegateUP is ERC165, ILSP1UniversalReceiver {
|
|
|
83
87
|
address notifier = address(bytes20(msg.data[msg.data.length - 52:]));
|
|
84
88
|
|
|
85
89
|
// Get the supposed mapPrefix and interfaceId based on the typeID
|
|
86
|
-
(
|
|
87
|
-
|
|
90
|
+
(
|
|
91
|
+
bool invalid,
|
|
92
|
+
bytes10 mapPrefix,
|
|
93
|
+
bytes4 interfaceID,
|
|
94
|
+
bool isReceiving
|
|
95
|
+
) = LSP1Utils.getTransferDetails(typeId);
|
|
88
96
|
|
|
89
97
|
// If it's a typeId different than LSP7/LSP8/LSP9 typeIds
|
|
90
98
|
if (invalid) return "LSP1: typeId out of scope";
|
|
@@ -95,19 +103,26 @@ contract LSP1UniversalReceiverDelegateUP is ERC165, ILSP1UniversalReceiver {
|
|
|
95
103
|
if (notifier == tx.origin) revert CannotRegisterEOAsAsAssets(notifier);
|
|
96
104
|
|
|
97
105
|
// Generate the LSP5ReceivedAssetsMap/LSP10VaultsMap based on the prefix and the notifier
|
|
98
|
-
bytes32 notifierMapKey = LSP2Utils.generateMappingKey(
|
|
106
|
+
bytes32 notifierMapKey = LSP2Utils.generateMappingKey(
|
|
107
|
+
mapPrefix,
|
|
108
|
+
bytes20(notifier)
|
|
109
|
+
);
|
|
99
110
|
|
|
100
111
|
// Query the ERC725Y storage of the LSP0-ERC725Account
|
|
101
|
-
bytes memory notifierMapValue = IERC725Y(msg.sender).getData(
|
|
112
|
+
bytes memory notifierMapValue = IERC725Y(msg.sender).getData(
|
|
113
|
+
notifierMapKey
|
|
114
|
+
);
|
|
102
115
|
|
|
103
116
|
bool isMapValueSet = bytes20(notifierMapValue) != bytes20(0);
|
|
104
117
|
|
|
105
118
|
if (isReceiving) {
|
|
106
119
|
// If the mapValue is set, we assume that all other data keys relevant to the asset/vault
|
|
107
120
|
// are registered in the account, we don't need to re register the asset being received
|
|
108
|
-
if (isMapValueSet)
|
|
121
|
+
if (isMapValueSet)
|
|
122
|
+
return "LSP1: asset received is already registered";
|
|
109
123
|
|
|
110
|
-
return
|
|
124
|
+
return
|
|
125
|
+
_whenReceiving(typeId, notifier, notifierMapKey, interfaceID);
|
|
111
126
|
} else {
|
|
112
127
|
// If the mapValue is not set, we assume that all other data keys relevant to the asset/vault
|
|
113
128
|
// are not registered in the account, we cannot remove non-existing data keys for the asset being sent
|
|
@@ -115,7 +130,8 @@ contract LSP1UniversalReceiverDelegateUP is ERC165, ILSP1UniversalReceiver {
|
|
|
115
130
|
|
|
116
131
|
// if the value under the `LSP5ReceivedAssetsMap:<asset-address>` or `LSP10VaultsMap:<vault-address>`
|
|
117
132
|
// is not a valid tuple as `(bytes4,uint128)`
|
|
118
|
-
if (notifierMapValue.length < 20)
|
|
133
|
+
if (notifierMapValue.length < 20)
|
|
134
|
+
return "LSP1: asset data corrupted";
|
|
119
135
|
|
|
120
136
|
// Identify where the asset/vault is located in the `LSP5ReceivedAssets[]` / `LSP10Vaults[]` Array
|
|
121
137
|
// by extracting the index from the tuple value `(bytes4,uint128)`
|
|
@@ -148,7 +164,9 @@ contract LSP1UniversalReceiverDelegateUP is ERC165, ILSP1UniversalReceiver {
|
|
|
148
164
|
// not when tokens are being transferred on deployment through the `constructor`
|
|
149
165
|
if (notifier.code.length > 0) {
|
|
150
166
|
// if the amount sent is 0, then do not update the keys
|
|
151
|
-
uint256 balance = ILSP7DigitalAsset(notifier).balanceOf(
|
|
167
|
+
uint256 balance = ILSP7DigitalAsset(notifier).balanceOf(
|
|
168
|
+
msg.sender
|
|
169
|
+
);
|
|
152
170
|
if (balance == 0) return "LSP1: balance not updated";
|
|
153
171
|
}
|
|
154
172
|
|
|
@@ -206,7 +224,8 @@ contract LSP1UniversalReceiverDelegateUP is ERC165, ILSP1UniversalReceiver {
|
|
|
206
224
|
* - the index returned from the data key `notifierMapKey` is bigger than
|
|
207
225
|
* the length of the `LSP5ReceivedAssets[]`, meaning, index is out of bounds.
|
|
208
226
|
*/
|
|
209
|
-
if (dataKeys.length == 0 && dataValues.length == 0)
|
|
227
|
+
if (dataKeys.length == 0 && dataValues.length == 0)
|
|
228
|
+
return "LSP1: asset data corrupted";
|
|
210
229
|
|
|
211
230
|
// Set the LSP5 generated data keys on the account
|
|
212
231
|
IERC725Y(msg.sender).setDataBatch(dataKeys, dataValues);
|
|
@@ -223,7 +242,8 @@ contract LSP1UniversalReceiverDelegateUP is ERC165, ILSP1UniversalReceiver {
|
|
|
223
242
|
* - the index returned from the data key `notifierMapKey` is bigger than
|
|
224
243
|
* the length of the `LSP10Vaults[]`, meaning, index is out of bounds.
|
|
225
244
|
*/
|
|
226
|
-
if (dataKeys.length == 0 && dataValues.length == 0)
|
|
245
|
+
if (dataKeys.length == 0 && dataValues.length == 0)
|
|
246
|
+
return "LSP1: asset data corrupted";
|
|
227
247
|
|
|
228
248
|
// Set the LSP10 generated data keys on the account
|
|
229
249
|
IERC725Y(msg.sender).setDataBatch(dataKeys, dataValues);
|
|
@@ -236,7 +256,11 @@ contract LSP1UniversalReceiverDelegateUP is ERC165, ILSP1UniversalReceiver {
|
|
|
236
256
|
/**
|
|
237
257
|
* @inheritdoc ERC165
|
|
238
258
|
*/
|
|
239
|
-
function supportsInterface(
|
|
240
|
-
|
|
259
|
+
function supportsInterface(
|
|
260
|
+
bytes4 interfaceId
|
|
261
|
+
) public view virtual override returns (bool) {
|
|
262
|
+
return
|
|
263
|
+
interfaceId == _INTERFACEID_LSP1 ||
|
|
264
|
+
super.supportsInterface(interfaceId);
|
|
241
265
|
}
|
|
242
266
|
}
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
pragma solidity ^0.8.4;
|
|
3
3
|
|
|
4
4
|
// interfaces
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
IERC725Y
|
|
7
|
+
} from "@erc725/smart-contracts/contracts/interfaces/IERC725Y.sol";
|
|
6
8
|
import {ILSP1UniversalReceiver} from "../ILSP1UniversalReceiver.sol";
|
|
7
9
|
import {ILSP7DigitalAsset} from "../../LSP7DigitalAsset/ILSP7DigitalAsset.sol";
|
|
8
10
|
|
|
@@ -44,16 +46,26 @@ contract LSP1UniversalReceiverDelegateVault is ERC165, ILSP1UniversalReceiver {
|
|
|
44
46
|
// Check https://github.com/lukso-network/LIPs/blob/main/LSPs/LSP-9-Vault.md#universalreceiver
|
|
45
47
|
address notifier = address(bytes20(msg.data[msg.data.length - 52:]));
|
|
46
48
|
|
|
47
|
-
(
|
|
48
|
-
|
|
49
|
+
(
|
|
50
|
+
bool invalid,
|
|
51
|
+
bytes10 mapPrefix,
|
|
52
|
+
bytes4 interfaceID,
|
|
53
|
+
bool isReceiving
|
|
54
|
+
) = LSP1Utils.getTransferDetails(typeId);
|
|
49
55
|
|
|
50
|
-
if (invalid || interfaceID == _INTERFACEID_LSP9)
|
|
56
|
+
if (invalid || interfaceID == _INTERFACEID_LSP9)
|
|
57
|
+
return "LSP1: typeId out of scope";
|
|
51
58
|
|
|
52
59
|
// solhint-disable avoid-tx-origin
|
|
53
60
|
if (notifier == tx.origin) revert CannotRegisterEOAsAsAssets(notifier);
|
|
54
61
|
|
|
55
|
-
bytes32 notifierMapKey = LSP2Utils.generateMappingKey(
|
|
56
|
-
|
|
62
|
+
bytes32 notifierMapKey = LSP2Utils.generateMappingKey(
|
|
63
|
+
mapPrefix,
|
|
64
|
+
bytes20(notifier)
|
|
65
|
+
);
|
|
66
|
+
bytes memory notifierMapValue = IERC725Y(msg.sender).getData(
|
|
67
|
+
notifierMapKey
|
|
68
|
+
);
|
|
57
69
|
|
|
58
70
|
bytes32[] memory dataKeys;
|
|
59
71
|
bytes[] memory dataValues;
|
|
@@ -67,7 +79,9 @@ contract LSP1UniversalReceiverDelegateVault is ERC165, ILSP1UniversalReceiver {
|
|
|
67
79
|
// not when tokens are being transferred on deployment through the `constructor`
|
|
68
80
|
if (notifier.code.length > 0) {
|
|
69
81
|
// if the amount sent is 0, then do not update the keys
|
|
70
|
-
uint256 balance = ILSP7DigitalAsset(notifier).balanceOf(
|
|
82
|
+
uint256 balance = ILSP7DigitalAsset(notifier).balanceOf(
|
|
83
|
+
msg.sender
|
|
84
|
+
);
|
|
71
85
|
if (balance == 0) return "LSP1: balance not updated";
|
|
72
86
|
}
|
|
73
87
|
|
|
@@ -90,7 +104,8 @@ contract LSP1UniversalReceiverDelegateVault is ERC165, ILSP1UniversalReceiver {
|
|
|
90
104
|
|
|
91
105
|
// if the value under the `LSP5ReceivedAssetsMap:<asset-address>`
|
|
92
106
|
// is not a valid tuple as `(bytes4,uint128)`
|
|
93
|
-
if (notifierMapValue.length < 20)
|
|
107
|
+
if (notifierMapValue.length < 20)
|
|
108
|
+
return "LSP1: asset data corrupted";
|
|
94
109
|
|
|
95
110
|
// Identify where the asset is located in the `LSP5ReceivedAssets[]` Array
|
|
96
111
|
// by extracting the index from the tuple value `(bytes4,uint128)`
|
|
@@ -108,7 +123,8 @@ contract LSP1UniversalReceiverDelegateVault is ERC165, ILSP1UniversalReceiver {
|
|
|
108
123
|
* - the index returned from the data key `notifierMapKey` is bigger than
|
|
109
124
|
* the length of the `LSP5ReceivedAssets[]`, meaning, index is out of bounds.
|
|
110
125
|
*/
|
|
111
|
-
if (dataKeys.length == 0 && dataValues.length == 0)
|
|
126
|
+
if (dataKeys.length == 0 && dataValues.length == 0)
|
|
127
|
+
return "LSP1: asset data corrupted";
|
|
112
128
|
|
|
113
129
|
IERC725Y(msg.sender).setDataBatch(dataKeys, dataValues);
|
|
114
130
|
}
|
|
@@ -119,7 +135,11 @@ contract LSP1UniversalReceiverDelegateVault is ERC165, ILSP1UniversalReceiver {
|
|
|
119
135
|
/**
|
|
120
136
|
* @inheritdoc ERC165
|
|
121
137
|
*/
|
|
122
|
-
function supportsInterface(
|
|
123
|
-
|
|
138
|
+
function supportsInterface(
|
|
139
|
+
bytes4 interfaceId
|
|
140
|
+
) public view virtual override returns (bool) {
|
|
141
|
+
return
|
|
142
|
+
interfaceId == _INTERFACEID_LSP1 ||
|
|
143
|
+
super.supportsInterface(interfaceId);
|
|
124
144
|
}
|
|
125
145
|
}
|
|
@@ -3,7 +3,9 @@ pragma solidity ^0.8.4;
|
|
|
3
3
|
|
|
4
4
|
// libraries
|
|
5
5
|
import {Address} from "@openzeppelin/contracts/utils/Address.sol";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
ERC165Checker
|
|
8
|
+
} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
|
|
7
9
|
|
|
8
10
|
// constants
|
|
9
11
|
import "./ILSP1UniversalReceiver.sol";
|
|
@@ -22,8 +24,16 @@ library LSP1Utils {
|
|
|
22
24
|
bytes32 typeId,
|
|
23
25
|
bytes memory data
|
|
24
26
|
) internal {
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
+
if (
|
|
28
|
+
ERC165Checker.supportsERC165InterfaceUnchecked(
|
|
29
|
+
lsp1Implementation,
|
|
30
|
+
_INTERFACEID_LSP1
|
|
31
|
+
)
|
|
32
|
+
) {
|
|
33
|
+
ILSP1UniversalReceiver(lsp1Implementation).universalReceiver(
|
|
34
|
+
typeId,
|
|
35
|
+
data
|
|
36
|
+
);
|
|
27
37
|
}
|
|
28
38
|
}
|
|
29
39
|
|
|
@@ -44,8 +54,14 @@ library LSP1Utils {
|
|
|
44
54
|
msgValue
|
|
45
55
|
);
|
|
46
56
|
|
|
47
|
-
(bool success, bytes memory result) = universalReceiverDelegate.call(
|
|
48
|
-
|
|
57
|
+
(bool success, bytes memory result) = universalReceiverDelegate.call(
|
|
58
|
+
callData
|
|
59
|
+
);
|
|
60
|
+
Address.verifyCallResult(
|
|
61
|
+
success,
|
|
62
|
+
result,
|
|
63
|
+
"Call to universalReceiver failed"
|
|
64
|
+
);
|
|
49
65
|
return result.length != 0 ? abi.decode(result, (bytes)) : result;
|
|
50
66
|
}
|
|
51
67
|
|
|
@@ -53,7 +69,9 @@ library LSP1Utils {
|
|
|
53
69
|
* @dev Gets all the transfer details depending on the `typeId`
|
|
54
70
|
* @param typeId A unique identifier for a specific action
|
|
55
71
|
*/
|
|
56
|
-
function getTransferDetails(
|
|
72
|
+
function getTransferDetails(
|
|
73
|
+
bytes32 typeId
|
|
74
|
+
)
|
|
57
75
|
internal
|
|
58
76
|
pure
|
|
59
77
|
returns (
|
|
@@ -63,11 +81,17 @@ library LSP1Utils {
|
|
|
63
81
|
bool isReceiving
|
|
64
82
|
)
|
|
65
83
|
{
|
|
66
|
-
if (
|
|
84
|
+
if (
|
|
85
|
+
typeId == _TYPEID_LSP7_TOKENSSENDER ||
|
|
86
|
+
typeId == _TYPEID_LSP7_TOKENSRECIPIENT
|
|
87
|
+
) {
|
|
67
88
|
mapPrefix = _LSP5_RECEIVED_ASSETS_MAP_KEY_PREFIX;
|
|
68
89
|
interfaceId = _INTERFACEID_LSP7;
|
|
69
90
|
isReceiving = typeId == _TYPEID_LSP7_TOKENSRECIPIENT ? true : false;
|
|
70
|
-
} else if (
|
|
91
|
+
} else if (
|
|
92
|
+
typeId == _TYPEID_LSP8_TOKENSSENDER ||
|
|
93
|
+
typeId == _TYPEID_LSP8_TOKENSRECIPIENT
|
|
94
|
+
) {
|
|
71
95
|
mapPrefix = _LSP5_RECEIVED_ASSETS_MAP_KEY_PREFIX;
|
|
72
96
|
interfaceId = _INTERFACEID_LSP8;
|
|
73
97
|
isReceiving = typeId == _TYPEID_LSP8_TOKENSRECIPIENT ? true : false;
|
|
@@ -77,7 +101,8 @@ library LSP1Utils {
|
|
|
77
101
|
) {
|
|
78
102
|
mapPrefix = _LSP10_VAULTS_MAP_KEY_PREFIX;
|
|
79
103
|
interfaceId = _INTERFACEID_LSP9;
|
|
80
|
-
isReceiving = (typeId ==
|
|
104
|
+
isReceiving = (typeId ==
|
|
105
|
+
_TYPEID_LSP9_OwnershipTransferred_RecipientNotification)
|
|
81
106
|
? true
|
|
82
107
|
: false;
|
|
83
108
|
} else {
|
package/contracts/LSP20CallVerification/{ILSP20CallVerification.sol → ILSP20CallVerifier.sol}
RENAMED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
pragma solidity ^0.8.4;
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
+
* @title Interface for the LSP20 Call Verification standard, a set of functions intended to perform verifications on behalf of another contract.
|
|
6
|
+
*
|
|
5
7
|
* @dev Interface to be inherited for contract supporting LSP20-CallVerification
|
|
6
8
|
*/
|
|
7
|
-
interface
|
|
9
|
+
interface ILSP20CallVerifier {
|
|
8
10
|
/**
|
|
9
11
|
* @return magicValue MUST return the first 3 bytes of `lsp20VerifyCall(address,uint256,bytes)` function selector if the call to
|
|
10
12
|
* the function is allowed, concatened with a byte that determines if the lsp20VerifyCallResult function should
|
|
@@ -26,5 +28,8 @@ interface ILSP20CallVerification {
|
|
|
26
28
|
* @param callHash The keccak256 of the parameters of {lsp20VerifyCall} concatenated
|
|
27
29
|
* @param result The value result of the function called on the msg.sender
|
|
28
30
|
*/
|
|
29
|
-
function lsp20VerifyCallResult(
|
|
31
|
+
function lsp20VerifyCallResult(
|
|
32
|
+
bytes32 callHash,
|
|
33
|
+
bytes memory result
|
|
34
|
+
) external returns (bytes4);
|
|
30
35
|
}
|
|
@@ -3,13 +3,14 @@ pragma solidity ^0.8.4;
|
|
|
3
3
|
|
|
4
4
|
// interfaces
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import {ILSP20CallVerifier as ILSP20} from "./ILSP20CallVerifier.sol";
|
|
7
7
|
|
|
8
8
|
// errors
|
|
9
9
|
import "./LSP20Errors.sol";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* @title Implementation of contract calling the verification functions according to
|
|
12
|
+
* @title Implementation of a contract calling the verification functions according to LSP20 - Call Verification standard.
|
|
13
|
+
*
|
|
13
14
|
* @dev Module to be inherited used to verify the execution of functions according to a verifier address.
|
|
14
15
|
* Verification can happen before or after execution based on a magicValue.
|
|
15
16
|
*/
|
|
@@ -19,9 +20,16 @@ abstract contract LSP20CallVerification {
|
|
|
19
20
|
* Reverts in case the value returned does not match the magic value (lsp20VerifyCall selector)
|
|
20
21
|
* Returns whether a verification after the execution should happen based on the last byte of the magicValue
|
|
21
22
|
*/
|
|
22
|
-
function _verifyCall(
|
|
23
|
+
function _verifyCall(
|
|
24
|
+
address logicVerifier
|
|
25
|
+
) internal virtual returns (bool verifyAfter) {
|
|
23
26
|
(bool success, bytes memory returnedData) = logicVerifier.call(
|
|
24
|
-
abi.encodeWithSelector(
|
|
27
|
+
abi.encodeWithSelector(
|
|
28
|
+
ILSP20.lsp20VerifyCall.selector,
|
|
29
|
+
msg.sender,
|
|
30
|
+
msg.value,
|
|
31
|
+
msg.data
|
|
32
|
+
)
|
|
25
33
|
);
|
|
26
34
|
|
|
27
35
|
_validateCall(false, success, returnedData);
|
|
@@ -38,7 +46,10 @@ abstract contract LSP20CallVerification {
|
|
|
38
46
|
* @dev Calls {lsp20VerifyCallResult} function on the logicVerifier.
|
|
39
47
|
* Reverts in case the value returned does not match the magic value (lsp20VerifyCallResult selector)
|
|
40
48
|
*/
|
|
41
|
-
function _verifyCallResult(
|
|
49
|
+
function _verifyCallResult(
|
|
50
|
+
address logicVerifier,
|
|
51
|
+
bytes memory callResult
|
|
52
|
+
) internal virtual {
|
|
42
53
|
(bool success, bytes memory returnedData) = logicVerifier.call(
|
|
43
54
|
abi.encodeWithSelector(
|
|
44
55
|
ILSP20.lsp20VerifyCallResult.selector,
|
|
@@ -49,8 +60,10 @@ abstract contract LSP20CallVerification {
|
|
|
49
60
|
|
|
50
61
|
_validateCall(true, success, returnedData);
|
|
51
62
|
|
|
52
|
-
if (
|
|
53
|
-
|
|
63
|
+
if (
|
|
64
|
+
abi.decode(returnedData, (bytes4)) !=
|
|
65
|
+
ILSP20.lsp20VerifyCallResult.selector
|
|
66
|
+
) revert LSP20InvalidMagicValue(true, returnedData);
|
|
54
67
|
}
|
|
55
68
|
|
|
56
69
|
function _validateCall(
|
|
@@ -62,8 +75,10 @@ abstract contract LSP20CallVerification {
|
|
|
62
75
|
|
|
63
76
|
// check if the returned data contains at least 32 bytes, potentially an abi encoded bytes4 value
|
|
64
77
|
// check if the returned data has in the first 32 bytes an abi encoded bytes4 value
|
|
65
|
-
if (
|
|
66
|
-
|
|
78
|
+
if (
|
|
79
|
+
returnedData.length < 32 ||
|
|
80
|
+
bytes28(bytes32(returnedData) << 32) != bytes28(0)
|
|
81
|
+
) revert LSP20InvalidMagicValue(postCall, returnedData);
|
|
67
82
|
}
|
|
68
83
|
|
|
69
84
|
function _revert(bool postCall, bytes memory returnedData) internal pure {
|
|
@@ -10,6 +10,6 @@ error LSP20CallingVerifierFailed(bool postCall);
|
|
|
10
10
|
/**
|
|
11
11
|
* @dev reverts when the call to the owner does not return the magic value
|
|
12
12
|
* @param postCall True if the execution call was done, False otherwise
|
|
13
|
-
* @param
|
|
13
|
+
* @param returnedData The data returned by the call to the logic verifier
|
|
14
14
|
*/
|
|
15
15
|
error LSP20InvalidMagicValue(bool postCall, bytes returnedData);
|