@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,104 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
pragma solidity ^0.8.4;
|
|
3
|
+
|
|
4
|
+
// modules
|
|
5
|
+
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
|
|
6
|
+
import {ERC165Checker} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
|
|
7
|
+
|
|
8
|
+
// constants
|
|
9
|
+
import {_INTERFACEID_LSP17_EXTENDABLE} from "./LSP17Constants.sol";
|
|
10
|
+
|
|
11
|
+
// errors
|
|
12
|
+
import "./LSP17Errors.sol";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @title Implementation of the fallback logic according to LSP17ContractExtension
|
|
16
|
+
* @dev Module to be inherited used to extend the functionality of the parent contract when
|
|
17
|
+
* calling a function that doesn't exist on the parent contract via forwarding the call
|
|
18
|
+
* to an extension mapped to the function selector being called, set originally by the parent contract
|
|
19
|
+
*/
|
|
20
|
+
abstract contract LSP17Extendable is ERC165 {
|
|
21
|
+
/**
|
|
22
|
+
* @dev See {IERC165-supportsInterface}.
|
|
23
|
+
*/
|
|
24
|
+
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
|
|
25
|
+
return interfaceId == _INTERFACEID_LSP17_EXTENDABLE || super.supportsInterface(interfaceId);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @dev Returns whether the interfaceId being checked is supported in the extension of the
|
|
30
|
+
* {supportsInterface} selector.
|
|
31
|
+
*
|
|
32
|
+
* To be used by extendable contracts wishing to extend the ERC165 interfaceIds originally
|
|
33
|
+
* supported by reading whether the interfaceId queried is supported in the `supportsInterface`
|
|
34
|
+
* extension if the extension is set, if not it returns false.
|
|
35
|
+
*/
|
|
36
|
+
function _supportsInterfaceInERC165Extension(bytes4 interfaceId)
|
|
37
|
+
internal
|
|
38
|
+
view
|
|
39
|
+
virtual
|
|
40
|
+
returns (bool)
|
|
41
|
+
{
|
|
42
|
+
address erc165Extension = _getExtension(ERC165.supportsInterface.selector);
|
|
43
|
+
if (erc165Extension == address(0)) return false;
|
|
44
|
+
|
|
45
|
+
return ERC165Checker.supportsERC165InterfaceUnchecked(erc165Extension, interfaceId);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @dev Returns the extension mapped to a specific function selector
|
|
50
|
+
* If no extension was found, return the address(0)
|
|
51
|
+
* To be overrided.
|
|
52
|
+
* Up to the implementor contract to return an extension based on a function selector
|
|
53
|
+
*/
|
|
54
|
+
function _getExtension(bytes4 functionSelector) internal view virtual returns (address);
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @dev Forwards the call to an extension mapped to a function selector. If no extension address
|
|
58
|
+
* is mapped to the function selector (address(0)), then revert.
|
|
59
|
+
*
|
|
60
|
+
* The call to the extension is appended with bytes20 (msg.sender) and bytes32 (msg.value).
|
|
61
|
+
* Returns the return value on success and revert in case of failure.
|
|
62
|
+
*
|
|
63
|
+
* As the function uses assembly {return()/revert()} to terminate the call, it cannot be
|
|
64
|
+
* called before other codes in fallback().
|
|
65
|
+
*
|
|
66
|
+
* Otherwise, the codes after _fallbackLSP17Extendable() may never be reached.
|
|
67
|
+
*/
|
|
68
|
+
function _fallbackLSP17Extendable() internal virtual {
|
|
69
|
+
// If there is a function selector
|
|
70
|
+
address extension = _getExtension(msg.sig);
|
|
71
|
+
|
|
72
|
+
// if no extension was found, revert
|
|
73
|
+
if (extension == address(0)) revert NoExtensionFoundForFunctionSelector(msg.sig);
|
|
74
|
+
|
|
75
|
+
// solhint-disable no-inline-assembly
|
|
76
|
+
// if the extension was found, call the extension with the msg.data
|
|
77
|
+
// appended with bytes20(address) and bytes32(msg.value)
|
|
78
|
+
assembly {
|
|
79
|
+
calldatacopy(0, 0, calldatasize())
|
|
80
|
+
|
|
81
|
+
// The msg.sender address is shifted to the left by 12 bytes to remove the padding
|
|
82
|
+
// Then the address without padding is stored right after the calldata
|
|
83
|
+
mstore(calldatasize(), shl(96, caller()))
|
|
84
|
+
|
|
85
|
+
// The msg.value is stored right after the calldata + msg.sender
|
|
86
|
+
mstore(add(calldatasize(), 20), callvalue())
|
|
87
|
+
|
|
88
|
+
// Add 52 bytes for the msg.sender and msg.value appended at the end of the calldata
|
|
89
|
+
let success := call(gas(), extension, 0, 0, add(calldatasize(), 52), 0, 0)
|
|
90
|
+
|
|
91
|
+
// Copy the returned data
|
|
92
|
+
returndatacopy(0, 0, returndatasize())
|
|
93
|
+
|
|
94
|
+
switch success
|
|
95
|
+
// call returns 0 on failed calls
|
|
96
|
+
case 0 {
|
|
97
|
+
revert(0, returndatasize())
|
|
98
|
+
}
|
|
99
|
+
default {
|
|
100
|
+
return(0, returndatasize())
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
pragma solidity ^0.8.4;
|
|
3
|
+
|
|
4
|
+
// modules
|
|
5
|
+
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
|
|
6
|
+
|
|
7
|
+
// constants
|
|
8
|
+
import {_INTERFACEID_LSP17_EXTENSION} from "./LSP17Constants.sol";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @title Implementation of the extension logic according to LSP17ContractExtension
|
|
12
|
+
* @dev To be inherited to provide context of the msg variable related to the extendable contract
|
|
13
|
+
*/
|
|
14
|
+
abstract contract LSP17Extension is ERC165 {
|
|
15
|
+
// solhint-disable
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @dev See {IERC165-supportsInterface}.
|
|
19
|
+
*/
|
|
20
|
+
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
|
|
21
|
+
return interfaceId == _INTERFACEID_LSP17_EXTENSION || super.supportsInterface(interfaceId);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @dev Returns the original msg.data passed to the extendable contract
|
|
26
|
+
* without the appended msg.sender and msg.value
|
|
27
|
+
*/
|
|
28
|
+
function _extendableMsgData() internal view virtual returns (bytes calldata) {
|
|
29
|
+
return msg.data[:msg.data.length - 52];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @dev Returns the original msg.sender calling the extendable contract
|
|
34
|
+
*/
|
|
35
|
+
function _extendableMsgSender() internal view virtual returns (address) {
|
|
36
|
+
return address(bytes20(msg.data[msg.data.length - 52:msg.data.length - 32]));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @dev Returns the original msg.value sent to the extendable contract
|
|
41
|
+
*/
|
|
42
|
+
function _extendableMsgValue() internal view virtual returns (uint256) {
|
|
43
|
+
return uint256(bytes32(msg.data[msg.data.length - 32:]));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
pragma solidity ^0.8.4;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @title LSP17 Utility library to check an extension
|
|
6
|
+
*/
|
|
7
|
+
library LSP17Utils {
|
|
8
|
+
/**
|
|
9
|
+
* @dev Returns whether the call is a normal call or an extension call by checking if
|
|
10
|
+
* the parametersLength with offset with an additional of 52 bytes supposed msg.sender
|
|
11
|
+
* and msg.value appended is equal to the msgDataLength
|
|
12
|
+
*/
|
|
13
|
+
function isExtension(uint256 parametersLengthWithOffset, uint256 msgDataLength)
|
|
14
|
+
internal
|
|
15
|
+
pure
|
|
16
|
+
returns (bool)
|
|
17
|
+
{
|
|
18
|
+
return (parametersLengthWithOffset + 52) == msgDataLength;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: CC0-1.0
|
|
2
|
-
pragma solidity ^0.8.
|
|
2
|
+
pragma solidity ^0.8.4;
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @title The interface for LSP1UniversalReceiver
|
|
@@ -11,15 +11,15 @@ interface ILSP1UniversalReceiver {
|
|
|
11
11
|
* @param from The address calling the universalReceiver function
|
|
12
12
|
* @param value The amount sent to the universalReceiver function
|
|
13
13
|
* @param typeId The hash of a specific standard or a hook
|
|
14
|
-
* @param returnedValue The return value of universalReceiver function
|
|
15
14
|
* @param receivedData The arbitrary data passed to universalReceiver function
|
|
15
|
+
* @param returnedValue The value returned by the universalReceiver function
|
|
16
16
|
*/
|
|
17
17
|
event UniversalReceiver(
|
|
18
18
|
address indexed from,
|
|
19
|
-
uint256 value,
|
|
19
|
+
uint256 indexed value,
|
|
20
20
|
bytes32 indexed typeId,
|
|
21
|
-
bytes
|
|
22
|
-
bytes
|
|
21
|
+
bytes receivedData,
|
|
22
|
+
bytes returnedValue
|
|
23
23
|
);
|
|
24
24
|
|
|
25
25
|
/**
|
|
@@ -1,11 +1,13 @@
|
|
|
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
5
|
bytes4 constant _INTERFACEID_LSP1 = 0x6bb56a14;
|
|
6
|
-
bytes4 constant _INTERFACEID_LSP1_DELEGATE = 0xa245bbda;
|
|
7
6
|
|
|
8
|
-
// --- ERC725Y Keys
|
|
7
|
+
// --- ERC725Y Data Keys
|
|
8
|
+
|
|
9
|
+
// bytes10(keccak256('LSP1UniversalReceiverDelegate'))
|
|
10
|
+
bytes10 constant _LSP1_UNIVERSAL_RECEIVER_DELEGATE_PREFIX = 0x0cfc51aec37c55a4d0b1;
|
|
9
11
|
|
|
10
12
|
// keccak256('LSP1UniversalReceiverDelegate')
|
|
11
13
|
bytes32 constant _LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY = 0x0cfc51aec37c55a4d0b1a65c6255c4bf2fbdf6277f3cc0730c45b828b6db8b47;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
pragma solidity ^0.8.4;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @dev reverts when EOA calls the `universalReceiver(..)` function with an asset/vault typeId
|
|
6
|
+
* @param caller The address of the EOA
|
|
7
|
+
*/
|
|
8
|
+
error CannotRegisterEOAsAsAssets(address caller);
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @dev reverts when the account calling the UniversalReceiverDelegate is not the same account
|
|
12
|
+
* linked as target in the KeyManager -- Security Check
|
|
13
|
+
* @param account The address of the account implementing the `universalReceiver(..)` function
|
|
14
|
+
* @param target The address of the target linked to the KeyManager
|
|
15
|
+
*/
|
|
16
|
+
error CallerNotLSP6LinkedTarget(address account, address target);
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @dev reverts when `universalReceiver(...)` is called with a value different than 0
|
|
20
|
+
*/
|
|
21
|
+
error NativeTokensNotAccepted();
|
|
@@ -1,27 +1,34 @@
|
|
|
1
1
|
// SPDX-License-Identifier: CC0-1.0
|
|
2
|
-
pragma solidity ^0.8.
|
|
2
|
+
pragma solidity ^0.8.4;
|
|
3
3
|
|
|
4
4
|
// interfaces
|
|
5
|
-
import {
|
|
5
|
+
import {IERC725Y} from "@erc725/smart-contracts/contracts/interfaces/IERC725Y.sol";
|
|
6
|
+
import {ILSP1UniversalReceiver} from "../ILSP1UniversalReceiver.sol";
|
|
7
|
+
import {ILSP6KeyManager} from "../../LSP6KeyManager/ILSP6KeyManager.sol";
|
|
8
|
+
import {ILSP7DigitalAsset} from "../../LSP7DigitalAsset/ILSP7DigitalAsset.sol";
|
|
6
9
|
|
|
7
10
|
// modules
|
|
8
11
|
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
|
|
9
|
-
import {
|
|
12
|
+
import {ERC725Y} from "@erc725/smart-contracts/contracts/ERC725Y.sol";
|
|
13
|
+
|
|
14
|
+
// libraries
|
|
15
|
+
import {ERC165Checker} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
|
|
16
|
+
import {LSP1Utils} from "../LSP1Utils.sol";
|
|
17
|
+
import {LSP2Utils} from "../../LSP2ERC725YJSONSchema/LSP2Utils.sol";
|
|
18
|
+
import {LSP6Utils} from "../../LSP6KeyManager/LSP6Utils.sol";
|
|
19
|
+
import {LSP5Utils} from "../../LSP5ReceivedAssets/LSP5Utils.sol";
|
|
20
|
+
import {LSP10Utils} from "../../LSP10ReceivedVaults/LSP10Utils.sol";
|
|
10
21
|
|
|
11
22
|
// constants
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
import
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
import {
|
|
22
|
-
_TYPEID_LSP9_VAULTSENDER,
|
|
23
|
-
_TYPEID_LSP9_VAULTRECIPIENT
|
|
24
|
-
} from "../../LSP9Vault/LSP9Constants.sol";
|
|
23
|
+
import "../LSP1Constants.sol";
|
|
24
|
+
import "../../LSP0ERC725Account/LSP0Constants.sol";
|
|
25
|
+
import "../../LSP6KeyManager/LSP6Constants.sol";
|
|
26
|
+
import "../../LSP9Vault/LSP9Constants.sol";
|
|
27
|
+
import "../../LSP10ReceivedVaults/LSP10Constants.sol";
|
|
28
|
+
import "../../LSP14Ownable2Step/LSP14Constants.sol";
|
|
29
|
+
|
|
30
|
+
// errors
|
|
31
|
+
import "../LSP1Errors.sol";
|
|
25
32
|
|
|
26
33
|
/**
|
|
27
34
|
* @title Core Implementation of contract writing the received Vaults and LSP7, LSP8 assets into your ERC725Account using
|
|
@@ -33,31 +40,142 @@ import {
|
|
|
33
40
|
* Owner of the UniversalProfile MUST be a KeyManager that allows (this) address to setData on the UniversalProfile
|
|
34
41
|
*
|
|
35
42
|
*/
|
|
36
|
-
contract LSP1UniversalReceiverDelegateUP is
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
TokenAndVaultHandling
|
|
40
|
-
{
|
|
43
|
+
contract LSP1UniversalReceiverDelegateUP is ERC165, ILSP1UniversalReceiver {
|
|
44
|
+
using ERC165Checker for address;
|
|
45
|
+
|
|
41
46
|
/**
|
|
42
|
-
* @inheritdoc
|
|
47
|
+
* @inheritdoc ILSP1UniversalReceiver
|
|
43
48
|
* @dev Allows to register arrayKeys and Map of incoming vaults and assets and removing them after being sent
|
|
44
49
|
* @return result the return value of keyManager's execute function
|
|
45
50
|
*/
|
|
46
|
-
function
|
|
47
|
-
address sender,
|
|
48
|
-
uint256 value, // solhint-disable no-unused-vars
|
|
51
|
+
function universalReceiver(
|
|
49
52
|
bytes32 typeId,
|
|
50
|
-
bytes memory data
|
|
51
|
-
) public virtual returns (bytes memory result) {
|
|
52
|
-
if (
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
)
|
|
60
|
-
|
|
53
|
+
bytes memory /* data */
|
|
54
|
+
) public payable virtual returns (bytes memory result) {
|
|
55
|
+
if (msg.value != 0) revert NativeTokensNotAccepted();
|
|
56
|
+
|
|
57
|
+
// This contract acts like a UniversalReceiverDelegate of a UP where we append the
|
|
58
|
+
// address and the value, sent to the universalReceiver function of the LSP0, to the msg.data
|
|
59
|
+
// Check https://github.com/lukso-network/LIPs/blob/main/LSPs/LSP-0-ERC725Account.md#universalreceiver
|
|
60
|
+
address notifier = address(bytes20(msg.data[msg.data.length - 52:]));
|
|
61
|
+
|
|
62
|
+
(bool invalid, bytes10 mapPrefix, bytes4 interfaceID, bool isReceiving) = LSP1Utils
|
|
63
|
+
.getTransferDetails(typeId);
|
|
64
|
+
|
|
65
|
+
if (invalid) return "LSP1: typeId out of scope";
|
|
66
|
+
|
|
67
|
+
// solhint-disable avoid-tx-origin
|
|
68
|
+
if (notifier == tx.origin) revert CannotRegisterEOAsAsAssets(notifier);
|
|
69
|
+
|
|
70
|
+
(address keyManager, bool ownerIsKeyManager) = _validateCallerViaKeyManager();
|
|
71
|
+
if (!ownerIsKeyManager) return "LSP1: account owner is not a LSP6KeyManager";
|
|
72
|
+
|
|
73
|
+
// if the contract being transferred doesn't support LSP9, do not register it as a received vault
|
|
74
|
+
if (mapPrefix == _LSP10_VAULTS_MAP_KEY_PREFIX) {
|
|
75
|
+
if (notifier.code.length > 0) {
|
|
76
|
+
if (!notifier.supportsERC165InterfaceUnchecked(_INTERFACEID_LSP9))
|
|
77
|
+
return "LSP1: not an LSP9Vault ownership transfer";
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
bytes32 notifierMapKey = LSP2Utils.generateMappingKey(mapPrefix, bytes20(notifier));
|
|
82
|
+
bytes memory notifierMapValue = IERC725Y(msg.sender).getData(notifierMapKey);
|
|
83
|
+
|
|
84
|
+
if (isReceiving) {
|
|
85
|
+
// if the map value is already set, then do nothing
|
|
86
|
+
if (bytes12(notifierMapValue) != bytes12(0))
|
|
87
|
+
return "LSP1: asset received is already registered";
|
|
88
|
+
|
|
89
|
+
result = _whenReceiving(typeId, notifier, keyManager, notifierMapKey, interfaceID);
|
|
90
|
+
} else {
|
|
91
|
+
// if there is no map value for the asset/vault to remove, then do nothing
|
|
92
|
+
if (bytes12(notifierMapValue) == bytes12(0))
|
|
93
|
+
return "LSP1: asset sent is not registered";
|
|
94
|
+
|
|
95
|
+
result = _whenSending(typeId, notifier, keyManager, notifierMapKey, notifierMapValue);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// --- Internal functions
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @dev To avoid stack too deep error
|
|
103
|
+
* Generate the keys/values of the asset/vault received to set and set them
|
|
104
|
+
* on the Key Manager depending on the type of the transfer (asset/vault)
|
|
105
|
+
*/
|
|
106
|
+
function _whenReceiving(
|
|
107
|
+
bytes32 typeId,
|
|
108
|
+
address notifier,
|
|
109
|
+
address keyManager,
|
|
110
|
+
bytes32 notifierMapKey,
|
|
111
|
+
bytes4 interfaceID
|
|
112
|
+
) internal virtual returns (bytes memory result) {
|
|
113
|
+
// if it's a token transfer (LSP7/LSP8)
|
|
114
|
+
if (typeId != _TYPEID_LSP9_OwnershipTransferred_RecipientNotification) {
|
|
115
|
+
// if the amount sent is 0, then do not update the keys
|
|
116
|
+
uint256 balance = ILSP7DigitalAsset(notifier).balanceOf(msg.sender);
|
|
117
|
+
if (balance == 0) return "LSP1: balance not updated";
|
|
118
|
+
|
|
119
|
+
(bytes32[] memory dataKeys, bytes[] memory dataValues) = LSP5Utils
|
|
120
|
+
.generateReceivedAssetKeys(msg.sender, notifier, notifierMapKey, interfaceID);
|
|
121
|
+
|
|
122
|
+
result = LSP6Utils.setDataViaKeyManager(keyManager, dataKeys, dataValues);
|
|
123
|
+
} else {
|
|
124
|
+
(bytes32[] memory dataKeys, bytes[] memory dataValues) = LSP10Utils
|
|
125
|
+
.generateReceivedVaultKeys(msg.sender, notifier, notifierMapKey);
|
|
126
|
+
|
|
127
|
+
result = LSP6Utils.setDataViaKeyManager(keyManager, dataKeys, dataValues);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* @dev To avoid stack too deep error
|
|
133
|
+
* Generate the keys/values of the asset/vault sent to set and set them
|
|
134
|
+
* on the Key Manager depending on the type of the transfer (asset/vault)
|
|
135
|
+
*/
|
|
136
|
+
function _whenSending(
|
|
137
|
+
bytes32 typeId,
|
|
138
|
+
address notifier,
|
|
139
|
+
address keyManager,
|
|
140
|
+
bytes32 notifierMapKey,
|
|
141
|
+
bytes memory notifierMapValue
|
|
142
|
+
) internal virtual returns (bytes memory result) {
|
|
143
|
+
// if it's a token transfer (LSP7/LSP8)
|
|
144
|
+
if (typeId != _TYPEID_LSP9_OwnershipTransferred_SenderNotification) {
|
|
145
|
+
// if the amount sent is not the full balance, then do not update the keys
|
|
146
|
+
uint256 balance = ILSP7DigitalAsset(notifier).balanceOf(msg.sender);
|
|
147
|
+
if (balance != 0) return "LSP1: full balance is not sent";
|
|
148
|
+
|
|
149
|
+
(bytes32[] memory dataKeys, bytes[] memory dataValues) = LSP5Utils
|
|
150
|
+
.generateSentAssetKeys(msg.sender, notifierMapKey, notifierMapValue);
|
|
151
|
+
|
|
152
|
+
result = LSP6Utils.setDataViaKeyManager(keyManager, dataKeys, dataValues);
|
|
153
|
+
} else {
|
|
154
|
+
(bytes32[] memory dataKeys, bytes[] memory dataValues) = LSP10Utils
|
|
155
|
+
.generateSentVaultKeys(msg.sender, notifierMapKey, notifierMapValue);
|
|
156
|
+
|
|
157
|
+
result = LSP6Utils.setDataViaKeyManager(keyManager, dataKeys, dataValues);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* @dev Check if the caller is owned by an LSP6KeyManager and linked to
|
|
163
|
+
* the owner returned
|
|
164
|
+
*/
|
|
165
|
+
function _validateCallerViaKeyManager()
|
|
166
|
+
internal
|
|
167
|
+
view
|
|
168
|
+
virtual
|
|
169
|
+
returns (address accountOwner, bool ownerIsKeyManager)
|
|
170
|
+
{
|
|
171
|
+
accountOwner = ERC725Y(msg.sender).owner();
|
|
172
|
+
if (accountOwner.supportsERC165InterfaceUnchecked(_INTERFACEID_LSP6))
|
|
173
|
+
ownerIsKeyManager = true;
|
|
174
|
+
|
|
175
|
+
if (ownerIsKeyManager) {
|
|
176
|
+
address target = ILSP6KeyManager(accountOwner).target();
|
|
177
|
+
// check if the caller is the same account controlled by the keyManager
|
|
178
|
+
if (target != msg.sender) revert CallerNotLSP6LinkedTarget(msg.sender, target);
|
|
61
179
|
}
|
|
62
180
|
}
|
|
63
181
|
|
|
@@ -67,6 +185,6 @@ contract LSP1UniversalReceiverDelegateUP is
|
|
|
67
185
|
* @inheritdoc ERC165
|
|
68
186
|
*/
|
|
69
187
|
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
|
|
70
|
-
return interfaceId ==
|
|
188
|
+
return interfaceId == _INTERFACEID_LSP1 || super.supportsInterface(interfaceId);
|
|
71
189
|
}
|
|
72
190
|
}
|
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
// SPDX-License-Identifier: CC0-1.0
|
|
2
|
-
pragma solidity ^0.8.
|
|
2
|
+
pragma solidity ^0.8.4;
|
|
3
3
|
|
|
4
4
|
// interfaces
|
|
5
|
-
import {
|
|
5
|
+
import {IERC725Y} from "@erc725/smart-contracts/contracts/interfaces/IERC725Y.sol";
|
|
6
|
+
import {ILSP1UniversalReceiver} from "../ILSP1UniversalReceiver.sol";
|
|
7
|
+
import {ILSP7DigitalAsset} from "../../LSP7DigitalAsset/ILSP7DigitalAsset.sol";
|
|
6
8
|
|
|
7
9
|
// modules
|
|
8
10
|
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
|
|
9
|
-
import {
|
|
11
|
+
import {ERC725Y} from "@erc725/smart-contracts/contracts/ERC725Y.sol";
|
|
12
|
+
|
|
13
|
+
// libraries
|
|
14
|
+
import {ERC165Checker} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
|
|
15
|
+
import {LSP1Utils} from "../LSP1Utils.sol";
|
|
16
|
+
import {LSP2Utils} from "../../LSP2ERC725YJSONSchema/LSP2Utils.sol";
|
|
17
|
+
import {LSP5Utils} from "../../LSP5ReceivedAssets/LSP5Utils.sol";
|
|
10
18
|
|
|
11
19
|
// constants
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
import {
|
|
18
|
-
_TYPEID_LSP8_TOKENSSENDER,
|
|
19
|
-
_TYPEID_LSP8_TOKENSRECIPIENT
|
|
20
|
-
} from "../../LSP8IdentifiableDigitalAsset/LSP8Constants.sol";
|
|
20
|
+
import "../LSP1Constants.sol";
|
|
21
|
+
import "../../LSP9Vault/LSP9Constants.sol";
|
|
22
|
+
|
|
23
|
+
// errors
|
|
24
|
+
import "../LSP1Errors.sol";
|
|
21
25
|
|
|
22
26
|
/**
|
|
23
27
|
* @title Core Implementation of contract writing the received LSP7 and LSP8 assets into your Vault using
|
|
@@ -26,29 +30,58 @@ import {
|
|
|
26
30
|
* @author Fabian Vogelsteller, Yamen Merhi, Jean Cavallera
|
|
27
31
|
* @dev Delegate contract of the initial universal receiver
|
|
28
32
|
*/
|
|
29
|
-
contract LSP1UniversalReceiverDelegateVault is
|
|
30
|
-
ERC165,
|
|
31
|
-
ILSP1UniversalReceiverDelegate,
|
|
32
|
-
TokenHandling
|
|
33
|
-
{
|
|
33
|
+
contract LSP1UniversalReceiverDelegateVault is ERC165, ILSP1UniversalReceiver {
|
|
34
34
|
/**
|
|
35
|
-
* @inheritdoc
|
|
35
|
+
* @inheritdoc ILSP1UniversalReceiver
|
|
36
36
|
* @dev allows to register arrayKeys and Map of incoming assets and remove after being sent
|
|
37
37
|
* @return result The return value
|
|
38
38
|
*/
|
|
39
|
-
function
|
|
40
|
-
address sender,
|
|
41
|
-
uint256 value, // solhint-disable no-unused-vars
|
|
39
|
+
function universalReceiver(
|
|
42
40
|
bytes32 typeId,
|
|
43
|
-
bytes memory data
|
|
44
|
-
) public virtual returns (bytes memory result) {
|
|
45
|
-
if (
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
41
|
+
bytes memory /* data */
|
|
42
|
+
) public payable virtual returns (bytes memory result) {
|
|
43
|
+
if (msg.value != 0) revert NativeTokensNotAccepted();
|
|
44
|
+
// This contract acts like a UniversalReceiverDelegate of a Vault where we append the
|
|
45
|
+
// address and the value, sent to the universalReceiver function of the LSP9, to the msg.data
|
|
46
|
+
// Check https://github.com/lukso-network/LIPs/blob/main/LSPs/LSP-9-Vault.md#universalreceiver
|
|
47
|
+
address notifier = address(bytes20(msg.data[msg.data.length - 52:]));
|
|
48
|
+
|
|
49
|
+
(bool invalid, bytes10 mapPrefix, bytes4 interfaceID, bool isReceiving) = LSP1Utils
|
|
50
|
+
.getTransferDetails(typeId);
|
|
51
|
+
|
|
52
|
+
if (invalid || interfaceID == _INTERFACEID_LSP9) return "LSP1: typeId out of scope";
|
|
53
|
+
|
|
54
|
+
// solhint-disable avoid-tx-origin
|
|
55
|
+
if (notifier == tx.origin) revert CannotRegisterEOAsAsAssets(notifier);
|
|
56
|
+
|
|
57
|
+
bytes32 notifierMapKey = LSP2Utils.generateMappingKey(mapPrefix, bytes20(notifier));
|
|
58
|
+
bytes memory notifierMapValue = IERC725Y(msg.sender).getData(notifierMapKey);
|
|
59
|
+
|
|
60
|
+
if (isReceiving) {
|
|
61
|
+
// if the map value is already set, then do nothing
|
|
62
|
+
if (bytes12(notifierMapValue) != bytes12(0))
|
|
63
|
+
return "URD: asset received is already registered";
|
|
64
|
+
|
|
65
|
+
// if the amount sent is 0, then do not update the keys
|
|
66
|
+
uint256 balance = ILSP7DigitalAsset(notifier).balanceOf(msg.sender);
|
|
67
|
+
if (balance == 0) return "LSP1: balance not updated";
|
|
68
|
+
|
|
69
|
+
(bytes32[] memory receiverDataKeys, bytes[] memory receiverDataValues) = LSP5Utils
|
|
70
|
+
.generateReceivedAssetKeys(msg.sender, notifier, notifierMapKey, interfaceID);
|
|
71
|
+
|
|
72
|
+
IERC725Y(msg.sender).setData(receiverDataKeys, receiverDataValues);
|
|
73
|
+
} else {
|
|
74
|
+
// if there is no map value for the asset to remove, then do nothing
|
|
75
|
+
if (bytes12(notifierMapValue) == bytes12(0))
|
|
76
|
+
return "LSP1: asset sent is not registered";
|
|
77
|
+
// if it's a token transfer (LSP7/LSP8)
|
|
78
|
+
uint256 balance = ILSP7DigitalAsset(notifier).balanceOf(msg.sender);
|
|
79
|
+
if (balance != 0) return "LSP1: full balance is not sent";
|
|
80
|
+
|
|
81
|
+
(bytes32[] memory senderDataKeys, bytes[] memory senderDataValues) = LSP5Utils
|
|
82
|
+
.generateSentAssetKeys(msg.sender, notifierMapKey, notifierMapValue);
|
|
83
|
+
|
|
84
|
+
IERC725Y(msg.sender).setData(senderDataKeys, senderDataValues);
|
|
52
85
|
}
|
|
53
86
|
}
|
|
54
87
|
|
|
@@ -58,6 +91,6 @@ contract LSP1UniversalReceiverDelegateVault is
|
|
|
58
91
|
* @inheritdoc ERC165
|
|
59
92
|
*/
|
|
60
93
|
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
|
|
61
|
-
return interfaceId ==
|
|
94
|
+
return interfaceId == _INTERFACEID_LSP1 || super.supportsInterface(interfaceId);
|
|
62
95
|
}
|
|
63
96
|
}
|