@lukso/lsp-smart-contracts 0.11.1 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -2
- package/artifacts/Create2Factory.json +2 -2
- package/artifacts/LSP0ERC725Account.json +68 -47
- package/artifacts/LSP0ERC725AccountInit.json +68 -47
- package/artifacts/LSP11BasicSocialRecovery.json +18 -2
- package/artifacts/LSP11BasicSocialRecoveryInit.json +18 -2
- package/artifacts/LSP16UniversalFactory.json +3 -3
- package/artifacts/LSP1UniversalReceiverDelegateUP.json +27 -46
- package/artifacts/LSP1UniversalReceiverDelegateVault.json +27 -46
- package/artifacts/LSP23LinkedContractsFactory.json +3 -3
- package/artifacts/LSP4DigitalAssetMetadata.json +16 -0
- package/artifacts/LSP4DigitalAssetMetadataInitAbstract.json +16 -0
- package/artifacts/LSP6KeyManager.json +34 -6
- package/artifacts/LSP6KeyManagerInit.json +34 -6
- package/artifacts/LSP7CappedSupply.json +64 -4
- package/artifacts/LSP7CappedSupplyInitAbstract.json +64 -4
- package/artifacts/LSP7CompatibleERC20.json +83 -23
- package/artifacts/LSP7CompatibleERC20InitAbstract.json +83 -23
- package/artifacts/LSP7CompatibleERC20Mintable.json +86 -26
- package/artifacts/LSP7CompatibleERC20MintableInit.json +86 -26
- package/artifacts/LSP7DigitalAsset.json +64 -4
- package/artifacts/LSP7DigitalAssetInitAbstract.json +64 -4
- package/artifacts/LSP7Mintable.json +67 -7
- package/artifacts/LSP7MintableInit.json +67 -7
- package/artifacts/LSP8CappedSupply.json +57 -3
- package/artifacts/LSP8CappedSupplyInitAbstract.json +57 -3
- package/artifacts/LSP8CompatibleERC721.json +79 -25
- package/artifacts/LSP8CompatibleERC721InitAbstract.json +79 -25
- package/artifacts/LSP8CompatibleERC721Mintable.json +87 -28
- package/artifacts/LSP8CompatibleERC721MintableInit.json +87 -28
- package/artifacts/LSP8IdentifiableDigitalAsset.json +57 -3
- package/artifacts/LSP8IdentifiableDigitalAssetInitAbstract.json +57 -3
- package/artifacts/LSP8Mintable.json +65 -6
- package/artifacts/LSP8MintableInit.json +65 -6
- package/artifacts/LSP9Vault.json +51 -35
- package/artifacts/LSP9VaultInit.json +51 -35
- package/artifacts/UniversalProfile.json +68 -47
- package/artifacts/UniversalProfileInit.json +68 -47
- package/contracts/Factories/Create2Factory.sol +1 -1
- package/contracts/LSP0ERC725Account/ILSP0ERC725Account.sol +0 -22
- package/contracts/LSP0ERC725Account/LSP0Constants.sol +6 -1
- package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +12 -2
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +196 -123
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +1 -1
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +11 -2
- package/contracts/LSP10ReceivedVaults/LSP10Utils.sol +5 -3
- package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryCore.sol +54 -14
- package/contracts/LSP11BasicSocialRecovery/LSP11Constants.sol +1 -1
- package/contracts/LSP11BasicSocialRecovery/LSP11Errors.sol +1 -1
- package/contracts/LSP14Ownable2Step/ILSP14Ownable2Step.sol +2 -2
- package/contracts/LSP14Ownable2Step/LSP14Constants.sol +1 -1
- package/contracts/LSP14Ownable2Step/LSP14Errors.sol +9 -3
- package/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol +16 -12
- package/contracts/LSP16UniversalFactory/LSP16UniversalFactory.sol +65 -96
- package/contracts/LSP17ContractExtension/LSP17Errors.sol +1 -1
- package/contracts/LSP17ContractExtension/LSP17Extendable.sol +22 -15
- package/contracts/LSP17ContractExtension/LSP17Extension.sol +6 -5
- package/contracts/LSP17Extensions/Extension4337.sol +101 -0
- package/contracts/LSP17Extensions/OnERC721ReceivedExtension.sol +15 -0
- package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiver.sol +1 -2
- package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiverDelegate.sol +24 -0
- package/contracts/LSP1UniversalReceiver/LSP1Constants.sol +1 -0
- package/contracts/LSP1UniversalReceiver/LSP1Errors.sol +0 -6
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +49 -33
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +33 -27
- package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +5 -48
- package/contracts/LSP20CallVerification/ILSP20CallVerifier.sol +13 -9
- package/contracts/LSP20CallVerification/LSP20CallVerification.sol +64 -45
- package/contracts/LSP20CallVerification/LSP20Constants.sol +6 -6
- package/contracts/LSP20CallVerification/LSP20Errors.sol +10 -4
- package/contracts/{LSP23LinkedContractsDeployment → LSP23LinkedContractsFactory}/ILSP23LinkedContractsFactory.sol +1 -1
- package/contracts/{LSP23LinkedContractsDeployment → LSP23LinkedContractsFactory}/IPostDeploymentModule.sol +1 -1
- package/contracts/{LSP23LinkedContractsDeployment → LSP23LinkedContractsFactory}/LSP23Errors.sol +1 -1
- package/contracts/{LSP23LinkedContractsDeployment → LSP23LinkedContractsFactory}/LSP23LinkedContractsFactory.sol +5 -1
- package/contracts/{LSP23LinkedContractsDeployment → LSP23LinkedContractsFactory}/modules/UniversalProfileInitPostDeploymentModule.sol +1 -1
- package/contracts/{LSP23LinkedContractsDeployment → LSP23LinkedContractsFactory}/modules/UniversalProfilePostDeploymentModule.sol +1 -1
- package/contracts/LSP25ExecuteRelayCall/LSP25Constants.sol +1 -1
- package/contracts/LSP25ExecuteRelayCall/LSP25MultiChannelNonce.sol +8 -3
- package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +1 -97
- package/contracts/LSP3ProfileMetadata/LSP3Constants.sol +1 -1
- package/contracts/LSP4DigitalAssetMetadata/LSP4Constants.sol +1 -1
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol +8 -3
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +8 -3
- package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +4 -3
- package/contracts/LSP6KeyManager/LSP6Constants.sol +4 -3
- package/contracts/LSP6KeyManager/LSP6Errors.sol +2 -23
- package/contracts/LSP6KeyManager/LSP6KeyManager.sol +0 -1
- package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +176 -101
- package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +0 -1
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6ExecuteModule.sol +1 -2
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6ExecuteRelayCallModule.sol +27 -0
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6SetDataModule.sol +34 -28
- package/contracts/LSP6KeyManager/LSP6Utils.sol +29 -2
- package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +70 -10
- package/contracts/LSP7DigitalAsset/LSP7Constants.sol +2 -2
- package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +29 -13
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +273 -265
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +28 -12
- package/contracts/LSP7DigitalAsset/LSP7Errors.sol +17 -3
- package/contracts/LSP7DigitalAsset/extensions/LSP7Burnable.sol +5 -1
- package/contracts/LSP7DigitalAsset/extensions/LSP7BurnableInitAbstract.sol +4 -1
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupply.sol +7 -7
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInitAbstract.sol +3 -3
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.sol +128 -54
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20InitAbstract.sol +129 -54
- package/contracts/LSP7DigitalAsset/presets/ILSP7Mintable.sol +3 -3
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.sol +4 -4
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInit.sol +2 -2
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInitAbstract.sol +4 -4
- package/contracts/LSP7DigitalAsset/presets/LSP7Mintable.sol +4 -4
- package/contracts/LSP7DigitalAsset/presets/LSP7MintableInit.sol +1 -1
- package/contracts/LSP7DigitalAsset/presets/LSP7MintableInitAbstract.sol +4 -4
- package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +16 -11
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol +20 -6
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol +32 -16
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +67 -16
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +143 -137
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +69 -15
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Burnable.sol +1 -1
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8BurnableInitAbstract.sol +1 -1
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.sol +7 -7
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInitAbstract.sol +3 -3
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +172 -80
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +178 -91
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.sol +7 -7
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableInitAbstract.sol +7 -7
- package/contracts/LSP8IdentifiableDigitalAsset/presets/ILSP8Mintable.sol +3 -3
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.sol +8 -7
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInit.sol +5 -3
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInitAbstract.sol +13 -7
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.sol +9 -8
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInit.sol +9 -3
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +10 -8
- package/contracts/LSP9Vault/ILSP9Vault.sol +0 -21
- package/contracts/LSP9Vault/LSP9Constants.sol +6 -1
- package/contracts/LSP9Vault/LSP9Errors.sol +1 -1
- package/contracts/LSP9Vault/LSP9Vault.sol +11 -2
- package/contracts/LSP9Vault/LSP9VaultCore.sol +119 -66
- package/contracts/LSP9Vault/LSP9VaultInit.sol +1 -1
- package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +11 -2
- package/contracts/UniversalProfile.sol +1 -1
- package/contracts/UniversalProfileInit.sol +1 -1
- package/contracts/UniversalProfileInitAbstract.sol +1 -1
- package/contracts/Version.sol +16 -0
- package/devdocs/LSP0ERC725Account.json +86 -52
- package/devdocs/LSP0ERC725AccountInit.json +86 -52
- package/devdocs/LSP11BasicSocialRecovery.json +13 -0
- package/devdocs/LSP11BasicSocialRecoveryInit.json +13 -0
- package/devdocs/LSP16UniversalFactory.json +9 -9
- package/devdocs/LSP1UniversalReceiverDelegateUP.json +7 -6
- package/devdocs/LSP1UniversalReceiverDelegateVault.json +7 -6
- package/devdocs/LSP4DigitalAssetMetadata.json +32 -10
- package/devdocs/LSP4DigitalAssetMetadataInitAbstract.json +32 -10
- package/devdocs/LSP6KeyManager.json +27 -13
- package/devdocs/LSP6KeyManagerInit.json +27 -13
- package/devdocs/LSP7CappedSupply.json +61 -28
- package/devdocs/LSP7CappedSupplyInitAbstract.json +61 -28
- package/devdocs/LSP7CompatibleERC20.json +102 -32
- package/devdocs/LSP7CompatibleERC20InitAbstract.json +102 -32
- package/devdocs/LSP7CompatibleERC20Mintable.json +102 -32
- package/devdocs/LSP7CompatibleERC20MintableInit.json +102 -32
- package/devdocs/LSP7DigitalAsset.json +61 -28
- package/devdocs/LSP7DigitalAssetInitAbstract.json +61 -28
- package/devdocs/LSP7Mintable.json +61 -28
- package/devdocs/LSP7MintableInit.json +61 -28
- package/devdocs/LSP8CappedSupply.json +66 -27
- package/devdocs/LSP8CappedSupplyInitAbstract.json +66 -27
- package/devdocs/LSP8CompatibleERC721.json +93 -33
- package/devdocs/LSP8CompatibleERC721InitAbstract.json +93 -33
- package/devdocs/LSP8CompatibleERC721Mintable.json +95 -35
- package/devdocs/LSP8CompatibleERC721MintableInit.json +96 -36
- package/devdocs/LSP8IdentifiableDigitalAsset.json +70 -28
- package/devdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +66 -27
- package/devdocs/LSP8Mintable.json +68 -29
- package/devdocs/LSP8MintableInit.json +69 -30
- package/devdocs/LSP9Vault.json +69 -41
- package/devdocs/LSP9VaultInit.json +69 -41
- package/devdocs/UniversalProfile.json +86 -52
- package/devdocs/UniversalProfileInit.json +86 -52
- package/dist/constants.cjs.js +5565 -2846
- package/dist/constants.d.ts +3996 -1182
- package/dist/constants.es.js +5564 -2846
- package/package.json +8 -8
- package/userdocs/LSP0ERC725Account.json +20 -11
- package/userdocs/LSP0ERC725AccountInit.json +20 -11
- package/userdocs/LSP16UniversalFactory.json +26 -1
- package/userdocs/LSP1UniversalReceiverDelegateUP.json +4 -11
- package/userdocs/LSP1UniversalReceiverDelegateVault.json +4 -11
- package/userdocs/LSP4DigitalAssetMetadata.json +7 -4
- package/userdocs/LSP4DigitalAssetMetadataInitAbstract.json +7 -4
- package/userdocs/LSP6KeyManager.json +3 -5
- package/userdocs/LSP6KeyManagerInit.json +3 -5
- package/userdocs/LSP7CappedSupply.json +17 -6
- package/userdocs/LSP7CappedSupplyInitAbstract.json +16 -5
- package/userdocs/LSP7CompatibleERC20.json +18 -5
- package/userdocs/LSP7CompatibleERC20InitAbstract.json +18 -5
- package/userdocs/LSP7CompatibleERC20Mintable.json +18 -5
- package/userdocs/LSP7CompatibleERC20MintableInit.json +18 -5
- package/userdocs/LSP7DigitalAsset.json +18 -5
- package/userdocs/LSP7DigitalAssetInitAbstract.json +18 -5
- package/userdocs/LSP7Mintable.json +18 -5
- package/userdocs/LSP7MintableInit.json +18 -5
- package/userdocs/LSP8CappedSupply.json +16 -5
- package/userdocs/LSP8CappedSupplyInitAbstract.json +15 -4
- package/userdocs/LSP8CompatibleERC721.json +30 -17
- package/userdocs/LSP8CompatibleERC721InitAbstract.json +30 -17
- package/userdocs/LSP8CompatibleERC721Mintable.json +31 -18
- package/userdocs/LSP8CompatibleERC721MintableInit.json +32 -19
- package/userdocs/LSP8IdentifiableDigitalAsset.json +18 -5
- package/userdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +17 -4
- package/userdocs/LSP8Mintable.json +18 -5
- package/userdocs/LSP8MintableInit.json +19 -6
- package/userdocs/LSP9Vault.json +23 -14
- package/userdocs/LSP9VaultInit.json +23 -14
- package/userdocs/UniversalProfile.json +20 -11
- package/userdocs/UniversalProfileInit.json +20 -11
- package/CONTRIBUTING.md +0 -184
- package/artifacts/LSP4Compatibility.json +0 -216
- package/contracts/LSP4DigitalAssetMetadata/ILSP4Compatibility.sol +0 -25
- package/contracts/LSP4DigitalAssetMetadata/LSP4Compatibility.sol +0 -38
- package/contracts/LSP7DigitalAsset/extensions/ILSP7CompatibleERC20.sol +0 -83
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CompatibleERC721.sol +0 -175
- package/devdocs/LSP4Compatibility.json +0 -79
- package/userdocs/LSP4Compatibility.json +0 -20
|
@@ -1,23 +1,28 @@
|
|
|
1
|
-
// SPDX-License-Identifier:
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
pragma solidity ^0.8.4;
|
|
3
3
|
|
|
4
4
|
// interfaces
|
|
5
5
|
import {
|
|
6
6
|
IERC725Y
|
|
7
7
|
} from "@erc725/smart-contracts/contracts/interfaces/IERC725Y.sol";
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
ILSP1UniversalReceiverDelegate
|
|
10
|
+
} from "../ILSP1UniversalReceiverDelegate.sol";
|
|
9
11
|
import {ILSP7DigitalAsset} from "../../LSP7DigitalAsset/ILSP7DigitalAsset.sol";
|
|
10
12
|
|
|
11
13
|
// modules
|
|
14
|
+
import {Version} from "../../Version.sol";
|
|
12
15
|
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
|
|
13
16
|
|
|
14
17
|
// libraries
|
|
15
18
|
import {
|
|
16
19
|
ERC165Checker
|
|
17
20
|
} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
|
|
18
|
-
import {LSP1Utils} from "../LSP1Utils.sol";
|
|
19
|
-
import {LSP2Utils} from "../../LSP2ERC725YJSONSchema/LSP2Utils.sol";
|
|
20
21
|
import {LSP5Utils} from "../../LSP5ReceivedAssets/LSP5Utils.sol";
|
|
22
|
+
import {LSP10Utils} from "../../LSP10ReceivedVaults/LSP10Utils.sol";
|
|
23
|
+
|
|
24
|
+
// constants
|
|
25
|
+
import {_INTERFACEID_LSP1_DELEGATE} from "../LSP1Constants.sol";
|
|
21
26
|
import {
|
|
22
27
|
_TYPEID_LSP7_TOKENSSENDER,
|
|
23
28
|
_TYPEID_LSP7_TOKENSRECIPIENT,
|
|
@@ -32,18 +37,9 @@ import {
|
|
|
32
37
|
_TYPEID_LSP9_OwnershipTransferred_SenderNotification,
|
|
33
38
|
_TYPEID_LSP9_OwnershipTransferred_RecipientNotification
|
|
34
39
|
} from "../../LSP9Vault/LSP9Constants.sol";
|
|
35
|
-
import {LSP10Utils} from "../../LSP10ReceivedVaults/LSP10Utils.sol";
|
|
36
|
-
|
|
37
|
-
// constants
|
|
38
|
-
import "../LSP1Constants.sol";
|
|
39
|
-
import "../../LSP0ERC725Account/LSP0Constants.sol";
|
|
40
|
-
import "../../LSP6KeyManager/LSP6Constants.sol";
|
|
41
|
-
import "../../LSP9Vault/LSP9Constants.sol";
|
|
42
|
-
import "../../LSP10ReceivedVaults/LSP10Constants.sol";
|
|
43
|
-
import "../../LSP14Ownable2Step/LSP14Constants.sol";
|
|
44
40
|
|
|
45
41
|
// errors
|
|
46
|
-
import "../LSP1Errors.sol";
|
|
42
|
+
import {CannotRegisterEOAsAsAssets} from "../LSP1Errors.sol";
|
|
47
43
|
|
|
48
44
|
/**
|
|
49
45
|
* @title Implementation of a UniversalReceiverDelegate for the [LSP-0-ERC725Account]
|
|
@@ -57,7 +53,11 @@ import "../LSP1Errors.sol";
|
|
|
57
53
|
* - Writes the data keys representing the owned vaults from type [LSP-9-Vault] into your account storage, and removes them when transferring ownership to other accounts according to the [LSP-10-ReceivedVaults] Standard.
|
|
58
54
|
*
|
|
59
55
|
*/
|
|
60
|
-
contract LSP1UniversalReceiverDelegateUP is
|
|
56
|
+
contract LSP1UniversalReceiverDelegateUP is
|
|
57
|
+
ERC165,
|
|
58
|
+
Version,
|
|
59
|
+
ILSP1UniversalReceiverDelegate
|
|
60
|
+
{
|
|
61
61
|
using ERC165Checker for address;
|
|
62
62
|
|
|
63
63
|
/**
|
|
@@ -80,24 +80,12 @@ contract LSP1UniversalReceiverDelegateUP is ERC165, ILSP1UniversalReceiver {
|
|
|
80
80
|
* @param typeId Unique identifier for a specific notification.
|
|
81
81
|
* @return The result of the reaction for `typeId`.
|
|
82
82
|
*/
|
|
83
|
-
function
|
|
83
|
+
function universalReceiverDelegate(
|
|
84
|
+
address notifier,
|
|
85
|
+
uint256 /*value*/,
|
|
84
86
|
bytes32 typeId,
|
|
85
87
|
bytes memory /* data */
|
|
86
|
-
) public
|
|
87
|
-
// CHECK that we did not send any native tokens to the LSP1 Delegate, as it cannot transfer them back.
|
|
88
|
-
if (msg.value != 0) {
|
|
89
|
-
revert NativeTokensNotAccepted();
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
address notifier = address(bytes20(msg.data[msg.data.length - 52:]));
|
|
93
|
-
|
|
94
|
-
// The notifier is supposed to be either the LSP7 or LSP8 or LSP9 contract
|
|
95
|
-
// If it's EOA we revert to avoid registering the EOA as asset or vault (spam protection)
|
|
96
|
-
// solhint-disable avoid-tx-origin
|
|
97
|
-
if (notifier == tx.origin) {
|
|
98
|
-
revert CannotRegisterEOAsAsAssets(notifier);
|
|
99
|
-
}
|
|
100
|
-
|
|
88
|
+
) public virtual override returns (bytes memory) {
|
|
101
89
|
if (typeId == _TYPEID_LSP7_TOKENSSENDER) {
|
|
102
90
|
return _tokenSender(notifier);
|
|
103
91
|
}
|
|
@@ -136,6 +124,13 @@ contract LSP1UniversalReceiverDelegateUP is ERC165, ILSP1UniversalReceiver {
|
|
|
136
124
|
* @param notifier The LSP7 or LSP8 token address.
|
|
137
125
|
*/
|
|
138
126
|
function _tokenSender(address notifier) internal returns (bytes memory) {
|
|
127
|
+
// The notifier is supposed to be either the LSP7 or LSP8 or LSP9 contract
|
|
128
|
+
// If it's EOA we revert (spam protection)
|
|
129
|
+
// solhint-disable-next-line avoid-tx-origin
|
|
130
|
+
if (notifier == tx.origin) {
|
|
131
|
+
revert CannotRegisterEOAsAsAssets(notifier);
|
|
132
|
+
}
|
|
133
|
+
|
|
139
134
|
// if the amount sent is not the full balance, then do not update the keys
|
|
140
135
|
try ILSP7DigitalAsset(notifier).balanceOf(msg.sender) returns (
|
|
141
136
|
uint256 balance
|
|
@@ -174,9 +169,16 @@ contract LSP1UniversalReceiverDelegateUP is ERC165, ILSP1UniversalReceiver {
|
|
|
174
169
|
address notifier,
|
|
175
170
|
bytes4 interfaceId
|
|
176
171
|
) internal returns (bytes memory) {
|
|
172
|
+
// The notifier is supposed to be either the LSP7 or LSP8 or LSP9 contract
|
|
173
|
+
// If it's EOA we revert to avoid registering the EOA as asset or vault (spam protection)
|
|
174
|
+
// solhint-disable-next-line avoid-tx-origin
|
|
175
|
+
if (notifier == tx.origin) {
|
|
176
|
+
revert CannotRegisterEOAsAsAssets(notifier);
|
|
177
|
+
}
|
|
178
|
+
|
|
177
179
|
// CHECK balance only when the Token contract is already deployed,
|
|
178
180
|
// not when tokens are being transferred on deployment through the `constructor`
|
|
179
|
-
if (notifier.code.length
|
|
181
|
+
if (notifier.code.length != 0) {
|
|
180
182
|
// if the amount sent is 0, then do not update the keys
|
|
181
183
|
try ILSP7DigitalAsset(notifier).balanceOf(msg.sender) returns (
|
|
182
184
|
uint256 balance
|
|
@@ -212,6 +214,13 @@ contract LSP1UniversalReceiverDelegateUP is ERC165, ILSP1UniversalReceiver {
|
|
|
212
214
|
* @param notifier The LSP9 vault address.
|
|
213
215
|
*/
|
|
214
216
|
function _vaultSender(address notifier) internal returns (bytes memory) {
|
|
217
|
+
// The notifier is supposed to be either the LSP7 or LSP8 or LSP9 contract
|
|
218
|
+
// If it's EOA we revert (spam protection)
|
|
219
|
+
// solhint-disable-next-line avoid-tx-origin
|
|
220
|
+
if (notifier == tx.origin) {
|
|
221
|
+
revert CannotRegisterEOAsAsAssets(notifier);
|
|
222
|
+
}
|
|
223
|
+
|
|
215
224
|
(bytes32[] memory dataKeys, bytes[] memory dataValues) = LSP10Utils
|
|
216
225
|
.generateSentVaultKeys(msg.sender, notifier);
|
|
217
226
|
|
|
@@ -235,6 +244,13 @@ contract LSP1UniversalReceiverDelegateUP is ERC165, ILSP1UniversalReceiver {
|
|
|
235
244
|
* @param notifier The LSP9 vault address.
|
|
236
245
|
*/
|
|
237
246
|
function _vaultRecipient(address notifier) internal returns (bytes memory) {
|
|
247
|
+
// The notifier is supposed to be either the LSP7 or LSP8 or LSP9 contract
|
|
248
|
+
// If it's EOA we revert to avoid registering the EOA as asset or vault (spam protection)
|
|
249
|
+
// solhint-disable-next-line avoid-tx-origin
|
|
250
|
+
if (notifier == tx.origin) {
|
|
251
|
+
revert CannotRegisterEOAsAsAssets(notifier);
|
|
252
|
+
}
|
|
253
|
+
|
|
238
254
|
(bytes32[] memory dataKeys, bytes[] memory dataValues) = LSP10Utils
|
|
239
255
|
.generateReceivedVaultKeys(msg.sender, notifier);
|
|
240
256
|
|
|
@@ -275,7 +291,7 @@ contract LSP1UniversalReceiverDelegateUP is ERC165, ILSP1UniversalReceiver {
|
|
|
275
291
|
bytes4 interfaceId
|
|
276
292
|
) public view virtual override returns (bool) {
|
|
277
293
|
return
|
|
278
|
-
interfaceId ==
|
|
294
|
+
interfaceId == _INTERFACEID_LSP1_DELEGATE ||
|
|
279
295
|
super.supportsInterface(interfaceId);
|
|
280
296
|
}
|
|
281
297
|
}
|
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
// SPDX-License-Identifier:
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
pragma solidity ^0.8.4;
|
|
3
3
|
|
|
4
4
|
// interfaces
|
|
5
5
|
import {
|
|
6
6
|
IERC725Y
|
|
7
7
|
} from "@erc725/smart-contracts/contracts/interfaces/IERC725Y.sol";
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
ILSP1UniversalReceiverDelegate
|
|
10
|
+
} from "../ILSP1UniversalReceiverDelegate.sol";
|
|
9
11
|
import {ILSP7DigitalAsset} from "../../LSP7DigitalAsset/ILSP7DigitalAsset.sol";
|
|
10
12
|
|
|
11
13
|
// modules
|
|
14
|
+
import {Version} from "../../Version.sol";
|
|
12
15
|
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
|
|
13
16
|
|
|
14
17
|
// libraries
|
|
15
|
-
import {LSP1Utils} from "../LSP1Utils.sol";
|
|
16
|
-
import {LSP2Utils} from "../../LSP2ERC725YJSONSchema/LSP2Utils.sol";
|
|
17
18
|
import {LSP5Utils} from "../../LSP5ReceivedAssets/LSP5Utils.sol";
|
|
18
19
|
|
|
19
20
|
// constants
|
|
20
|
-
import "../LSP1Constants.sol";
|
|
21
|
+
import {_INTERFACEID_LSP1_DELEGATE} from "../LSP1Constants.sol";
|
|
21
22
|
import {
|
|
22
23
|
_TYPEID_LSP7_TOKENSSENDER,
|
|
23
24
|
_TYPEID_LSP7_TOKENSRECIPIENT,
|
|
@@ -28,10 +29,9 @@ import {
|
|
|
28
29
|
_TYPEID_LSP8_TOKENSRECIPIENT,
|
|
29
30
|
_INTERFACEID_LSP8
|
|
30
31
|
} from "../../LSP8IdentifiableDigitalAsset/LSP8Constants.sol";
|
|
31
|
-
import "../../LSP9Vault/LSP9Constants.sol";
|
|
32
32
|
|
|
33
33
|
// errors
|
|
34
|
-
import "../LSP1Errors.sol";
|
|
34
|
+
import {CannotRegisterEOAsAsAssets} from "../LSP1Errors.sol";
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* @title Implementation of a UniversalReceiverDelegate for the [LSP9Vault]
|
|
@@ -43,9 +43,13 @@ import "../LSP1Errors.sol";
|
|
|
43
43
|
*
|
|
44
44
|
* - Writes the data keys representing assets received from type [LSP-7-DigitalAsset] and [LSP-8-IdentifiableDigitalAsset] into the account storage, and removes them when the balance is zero according to the [LSP-5-ReceivedAssets] Standard.
|
|
45
45
|
*/
|
|
46
|
-
contract LSP1UniversalReceiverDelegateVault is
|
|
46
|
+
contract LSP1UniversalReceiverDelegateVault is
|
|
47
|
+
ERC165,
|
|
48
|
+
Version,
|
|
49
|
+
ILSP1UniversalReceiverDelegate
|
|
50
|
+
{
|
|
47
51
|
/**
|
|
48
|
-
* @inheritdoc
|
|
52
|
+
* @inheritdoc ILSP1UniversalReceiverDelegate
|
|
49
53
|
* @dev Handles two cases:
|
|
50
54
|
*
|
|
51
55
|
* Writes the received [LSP-7-DigitalAsset] or [LSP-8-IdentifiableDigitalAsset] assets into the vault storage according to the [LSP-5-ReceivedAssets] standard.
|
|
@@ -60,24 +64,12 @@ contract LSP1UniversalReceiverDelegateVault is ERC165, ILSP1UniversalReceiver {
|
|
|
60
64
|
* @param typeId Unique identifier for a specific notification.
|
|
61
65
|
* @return The result of the reaction for `typeId`.
|
|
62
66
|
*/
|
|
63
|
-
function
|
|
67
|
+
function universalReceiverDelegate(
|
|
68
|
+
address notifier,
|
|
69
|
+
uint256 /*value*/,
|
|
64
70
|
bytes32 typeId,
|
|
65
71
|
bytes memory /* data */
|
|
66
|
-
) public
|
|
67
|
-
// CHECK that we did not send any native tokens to the LSP1 Delegate, as it cannot transfer them back.
|
|
68
|
-
if (msg.value != 0) {
|
|
69
|
-
revert NativeTokensNotAccepted();
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
address notifier = address(bytes20(msg.data[msg.data.length - 52:]));
|
|
73
|
-
|
|
74
|
-
// The notifier is supposed to be either the LSP7 or LSP8 contract
|
|
75
|
-
// If it's EOA we revert to avoid registering the EOA as asset (spam protection)
|
|
76
|
-
// solhint-disable avoid-tx-origin
|
|
77
|
-
if (notifier == tx.origin) {
|
|
78
|
-
revert CannotRegisterEOAsAsAssets(notifier);
|
|
79
|
-
}
|
|
80
|
-
|
|
72
|
+
) public virtual override returns (bytes memory) {
|
|
81
73
|
if (typeId == _TYPEID_LSP7_TOKENSSENDER) {
|
|
82
74
|
return _tokenSender(notifier);
|
|
83
75
|
}
|
|
@@ -108,6 +100,13 @@ contract LSP1UniversalReceiverDelegateVault is ERC165, ILSP1UniversalReceiver {
|
|
|
108
100
|
* @param notifier The LSP7 or LSP8 token address.
|
|
109
101
|
*/
|
|
110
102
|
function _tokenSender(address notifier) internal returns (bytes memory) {
|
|
103
|
+
// The notifier is supposed to be either the LSP7 or LSP8 contract
|
|
104
|
+
// If it's EOA we revert to avoid registering the EOA as asset (spam protection)
|
|
105
|
+
// solhint-disable-next-line avoid-tx-origin
|
|
106
|
+
if (notifier == tx.origin) {
|
|
107
|
+
revert CannotRegisterEOAsAsAssets(notifier);
|
|
108
|
+
}
|
|
109
|
+
|
|
111
110
|
// if the amount sent is not the full balance, then do not update the keys
|
|
112
111
|
try ILSP7DigitalAsset(notifier).balanceOf(msg.sender) returns (
|
|
113
112
|
uint256 balance
|
|
@@ -146,9 +145,16 @@ contract LSP1UniversalReceiverDelegateVault is ERC165, ILSP1UniversalReceiver {
|
|
|
146
145
|
address notifier,
|
|
147
146
|
bytes4 interfaceId
|
|
148
147
|
) internal returns (bytes memory) {
|
|
148
|
+
// The notifier is supposed to be either the LSP7 or LSP8 contract
|
|
149
|
+
// If it's EOA we revert to avoid registering the EOA as asset (spam protection)
|
|
150
|
+
// solhint-disable-next-line avoid-tx-origin
|
|
151
|
+
if (notifier == tx.origin) {
|
|
152
|
+
revert CannotRegisterEOAsAsAssets(notifier);
|
|
153
|
+
}
|
|
154
|
+
|
|
149
155
|
// CHECK balance only when the Token contract is already deployed,
|
|
150
156
|
// not when tokens are being transferred on deployment through the `constructor`
|
|
151
|
-
if (notifier.code.length
|
|
157
|
+
if (notifier.code.length != 0) {
|
|
152
158
|
// if the amount sent is 0, then do not update the keys
|
|
153
159
|
try ILSP7DigitalAsset(notifier).balanceOf(msg.sender) returns (
|
|
154
160
|
uint256 balance
|
|
@@ -201,7 +207,7 @@ contract LSP1UniversalReceiverDelegateVault is ERC165, ILSP1UniversalReceiver {
|
|
|
201
207
|
bytes4 interfaceId
|
|
202
208
|
) public view virtual override returns (bool) {
|
|
203
209
|
return
|
|
204
|
-
interfaceId ==
|
|
210
|
+
interfaceId == _INTERFACEID_LSP1_DELEGATE ||
|
|
205
211
|
super.supportsInterface(interfaceId);
|
|
206
212
|
}
|
|
207
213
|
}
|
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
pragma solidity ^0.8.4;
|
|
3
3
|
|
|
4
4
|
// libraries
|
|
5
|
-
import {Address} from "@openzeppelin/contracts/utils/Address.sol";
|
|
6
5
|
import {
|
|
7
6
|
ERC165Checker
|
|
8
7
|
} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
|
|
9
8
|
import {LSP2Utils} from "../LSP2ERC725YJSONSchema/LSP2Utils.sol";
|
|
10
9
|
|
|
11
10
|
// constants
|
|
12
|
-
import "./ILSP1UniversalReceiver.sol";
|
|
11
|
+
import {ILSP1UniversalReceiver as ILSP1} from "./ILSP1UniversalReceiver.sol";
|
|
13
12
|
|
|
14
13
|
// constants
|
|
15
14
|
import {
|
|
@@ -26,6 +25,8 @@ import {
|
|
|
26
25
|
* Based on LSP1 Universal Receiver standard.
|
|
27
26
|
*/
|
|
28
27
|
library LSP1Utils {
|
|
28
|
+
using ERC165Checker for address;
|
|
29
|
+
|
|
29
30
|
/**
|
|
30
31
|
* @dev Notify a contract at `lsp1Implementation` address by calling its `universalReceiver` function if this contract
|
|
31
32
|
* supports the LSP1 interface.
|
|
@@ -40,58 +41,14 @@ library LSP1Utils {
|
|
|
40
41
|
bytes memory data
|
|
41
42
|
) internal {
|
|
42
43
|
if (
|
|
43
|
-
|
|
44
|
-
lsp1Implementation,
|
|
44
|
+
lsp1Implementation.supportsERC165InterfaceUnchecked(
|
|
45
45
|
_INTERFACEID_LSP1
|
|
46
46
|
)
|
|
47
47
|
) {
|
|
48
|
-
|
|
49
|
-
typeId,
|
|
50
|
-
data
|
|
51
|
-
);
|
|
48
|
+
ILSP1(lsp1Implementation).universalReceiver(typeId, data);
|
|
52
49
|
}
|
|
53
50
|
}
|
|
54
51
|
|
|
55
|
-
/**
|
|
56
|
-
* @dev Call a LSP1UniversalReceiverDelegate contract at `universalReceiverDelegate` address and append `msgSender` and `msgValue`
|
|
57
|
-
* as additional informations in the calldata.
|
|
58
|
-
*
|
|
59
|
-
* @param universalReceiverDelegate The address of the LSP1UniversalReceiverDelegate to delegate the `universalReceiver` function to.
|
|
60
|
-
* @param typeId A `bytes32` typeId.
|
|
61
|
-
* @param receivedData The data sent initially to the `universalReceiver` function.
|
|
62
|
-
* @param msgSender The address that initially called the `universalReceiver` function.
|
|
63
|
-
* @param msgValue The amount of native token received initially by the `universalReceiver` function.
|
|
64
|
-
*
|
|
65
|
-
* @return The data returned by the LSP1UniversalReceiverDelegate contract.
|
|
66
|
-
*/
|
|
67
|
-
function callUniversalReceiverWithCallerInfos(
|
|
68
|
-
address universalReceiverDelegate,
|
|
69
|
-
bytes32 typeId,
|
|
70
|
-
bytes calldata receivedData,
|
|
71
|
-
address msgSender,
|
|
72
|
-
uint256 msgValue
|
|
73
|
-
) internal returns (bytes memory) {
|
|
74
|
-
bytes memory callData = abi.encodePacked(
|
|
75
|
-
abi.encodeWithSelector(
|
|
76
|
-
ILSP1UniversalReceiver.universalReceiver.selector,
|
|
77
|
-
typeId,
|
|
78
|
-
receivedData
|
|
79
|
-
),
|
|
80
|
-
msgSender,
|
|
81
|
-
msgValue
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
(bool success, bytes memory result) = universalReceiverDelegate.call(
|
|
85
|
-
callData
|
|
86
|
-
);
|
|
87
|
-
Address.verifyCallResult(
|
|
88
|
-
success,
|
|
89
|
-
result,
|
|
90
|
-
"Call to universalReceiver failed"
|
|
91
|
-
);
|
|
92
|
-
return result.length != 0 ? abi.decode(result, (bytes)) : result;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
52
|
/**
|
|
96
53
|
* @notice Retrieving the value stored under the ERC725Y data key `LSP1UniversalReceiverDelegate`.
|
|
97
54
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// SPDX-License-Identifier:
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
pragma solidity ^0.8.4;
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -8,28 +8,32 @@ pragma solidity ^0.8.4;
|
|
|
8
8
|
*/
|
|
9
9
|
interface ILSP20CallVerifier {
|
|
10
10
|
/**
|
|
11
|
-
* @return
|
|
11
|
+
* @return returnedStatus MUST return the first 3 bytes of `lsp20VerifyCall(address,uint256,bytes)` function selector if the call to
|
|
12
12
|
* the function is allowed, concatened with a byte that determines if the lsp20VerifyCallResult function should
|
|
13
13
|
* be called after the original function call. The byte that invoke the lsp20VerifyCallResult function is strictly `0x01`.
|
|
14
14
|
*
|
|
15
|
-
* @param
|
|
15
|
+
* @param requestor The address that requested to make the call to `target`.
|
|
16
|
+
* @param target The address of the contract that implements the `LSP20CallVerification` interface.
|
|
17
|
+
* @param caller The address who called the function on the `target` contract.
|
|
16
18
|
* @param value The value sent by the caller to the function called on the msg.sender
|
|
17
|
-
* @param
|
|
19
|
+
* @param callData The calldata sent by the caller to the msg.sender
|
|
18
20
|
*/
|
|
19
21
|
function lsp20VerifyCall(
|
|
22
|
+
address requestor,
|
|
23
|
+
address target,
|
|
20
24
|
address caller,
|
|
21
25
|
uint256 value,
|
|
22
|
-
bytes memory
|
|
23
|
-
) external returns (bytes4
|
|
26
|
+
bytes memory callData
|
|
27
|
+
) external returns (bytes4 returnedStatus);
|
|
24
28
|
|
|
25
29
|
/**
|
|
26
30
|
* @return MUST return the lsp20VerifyCallResult function selector if the call to the function is allowed
|
|
27
31
|
*
|
|
28
|
-
* @param callHash The keccak256 of the parameters of {lsp20VerifyCall} concatenated
|
|
29
|
-
* @param
|
|
32
|
+
* @param callHash The keccak256 hash of the parameters of {lsp20VerifyCall} concatenated
|
|
33
|
+
* @param callResult The value result of the function called on the msg.sender
|
|
30
34
|
*/
|
|
31
35
|
function lsp20VerifyCallResult(
|
|
32
36
|
bytes32 callHash,
|
|
33
|
-
bytes memory
|
|
37
|
+
bytes memory callResult
|
|
34
38
|
) external returns (bytes4);
|
|
35
39
|
}
|
|
@@ -2,83 +2,102 @@
|
|
|
2
2
|
pragma solidity ^0.8.4;
|
|
3
3
|
|
|
4
4
|
// interfaces
|
|
5
|
-
|
|
6
5
|
import {ILSP20CallVerifier as ILSP20} from "./ILSP20CallVerifier.sol";
|
|
7
6
|
|
|
8
7
|
// errors
|
|
9
|
-
import
|
|
8
|
+
import {
|
|
9
|
+
LSP20CallVerificationFailed,
|
|
10
|
+
LSP20CallingVerifierFailed,
|
|
11
|
+
LSP20EOACannotVerifyCall
|
|
12
|
+
} from "./LSP20Errors.sol";
|
|
10
13
|
|
|
11
14
|
/**
|
|
12
15
|
* @title Implementation of a contract calling the verification functions according to LSP20 - Call Verification standard.
|
|
13
16
|
*
|
|
14
17
|
* @dev Module to be inherited used to verify the execution of functions according to a verifier address.
|
|
15
|
-
* Verification can happen before or after execution based on a
|
|
18
|
+
* Verification can happen before or after execution based on a returnedStatus.
|
|
16
19
|
*/
|
|
17
20
|
abstract contract LSP20CallVerification {
|
|
18
21
|
/**
|
|
19
22
|
* @dev Calls {lsp20VerifyCall} function on the logicVerifier.
|
|
20
|
-
*
|
|
21
|
-
*
|
|
23
|
+
*
|
|
24
|
+
* @custom:info
|
|
25
|
+
* - Reverts in case the value returned does not match the returned status (lsp20VerifyCall selector).
|
|
26
|
+
* - Returns whether a verification after the execution should happen based on the last byte of the `returnedStatus`.
|
|
27
|
+
* - Reverts with no reason if the data returned by `ILSP20(logicVerifier).lsp20VerifyCall(...)` cannot be decoded (_e.g:_ any other data type besides `bytes4`).
|
|
28
|
+
* See this link for more info: https://forum.soliditylang.org/t/call-for-feedback-the-future-of-try-catch-in-solidity/1497.
|
|
22
29
|
*/
|
|
23
30
|
function _verifyCall(
|
|
24
31
|
address logicVerifier
|
|
25
32
|
) internal virtual returns (bool verifyAfter) {
|
|
26
|
-
(
|
|
27
|
-
|
|
28
|
-
|
|
33
|
+
if (logicVerifier.code.length == 0) {
|
|
34
|
+
revert LSP20EOACannotVerifyCall(logicVerifier);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Reverts with no reason if the returned data type is not a `bytes4` value
|
|
38
|
+
try
|
|
39
|
+
ILSP20(logicVerifier).lsp20VerifyCall(
|
|
40
|
+
msg.sender,
|
|
41
|
+
address(this),
|
|
29
42
|
msg.sender,
|
|
30
43
|
msg.value,
|
|
31
44
|
msg.data
|
|
32
45
|
)
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
46
|
+
returns (bytes4 returnedStatus) {
|
|
47
|
+
if (
|
|
48
|
+
bytes3(returnedStatus) !=
|
|
49
|
+
bytes3(ILSP20.lsp20VerifyCall.selector)
|
|
50
|
+
) {
|
|
51
|
+
revert LSP20CallVerificationFailed({
|
|
52
|
+
postCall: false,
|
|
53
|
+
returnedStatus: returnedStatus
|
|
54
|
+
});
|
|
55
|
+
}
|
|
41
56
|
|
|
42
|
-
|
|
57
|
+
return returnedStatus[3] == 0x01;
|
|
58
|
+
} catch (bytes memory errorData) {
|
|
59
|
+
_revertWithLSP20DefaultError(false, errorData);
|
|
60
|
+
}
|
|
43
61
|
}
|
|
44
62
|
|
|
45
63
|
/**
|
|
46
64
|
* @dev Calls {lsp20VerifyCallResult} function on the logicVerifier.
|
|
47
|
-
*
|
|
65
|
+
*
|
|
66
|
+
* @custom:info
|
|
67
|
+
* - Reverts in case the value returned does not match the returned status (lsp20VerifyCallResult selector).
|
|
68
|
+
* - Reverts with no reason if the data returned by `ILSP20(logicVerifier).lsp20VerifyCallResult(...)` cannot be decoded (_e.g:_ any other data type besides `bytes4`).
|
|
69
|
+
* See this link for more info: https://forum.soliditylang.org/t/call-for-feedback-the-future-of-try-catch-in-solidity/1497.
|
|
48
70
|
*/
|
|
49
71
|
function _verifyCallResult(
|
|
50
72
|
address logicVerifier,
|
|
51
73
|
bytes memory callResult
|
|
52
74
|
) internal virtual {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
keccak256(
|
|
75
|
+
// Reverts with no reason if the returned data type is not a `bytes4` value
|
|
76
|
+
try
|
|
77
|
+
ILSP20(logicVerifier).lsp20VerifyCallResult(
|
|
78
|
+
keccak256(
|
|
79
|
+
abi.encodePacked(
|
|
80
|
+
msg.sender,
|
|
81
|
+
address(this),
|
|
82
|
+
msg.sender,
|
|
83
|
+
msg.value,
|
|
84
|
+
msg.data
|
|
85
|
+
)
|
|
86
|
+
),
|
|
57
87
|
callResult
|
|
58
88
|
)
|
|
59
|
-
)
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
) revert LSP20InvalidMagicValue(true, returnedData);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function _validateCall(
|
|
70
|
-
bool postCall,
|
|
71
|
-
bool success,
|
|
72
|
-
bytes memory returnedData
|
|
73
|
-
) internal pure virtual {
|
|
74
|
-
if (!success) _revertWithLSP20DefaultError(postCall, returnedData);
|
|
89
|
+
returns (bytes4 returnedStatus) {
|
|
90
|
+
if (returnedStatus != ILSP20.lsp20VerifyCallResult.selector) {
|
|
91
|
+
revert LSP20CallVerificationFailed({
|
|
92
|
+
postCall: true,
|
|
93
|
+
returnedStatus: returnedStatus
|
|
94
|
+
});
|
|
95
|
+
}
|
|
75
96
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
bytes28(bytes32(returnedData) << 32) != bytes28(0)
|
|
81
|
-
) revert LSP20InvalidMagicValue(postCall, returnedData);
|
|
97
|
+
return;
|
|
98
|
+
} catch (bytes memory errorData) {
|
|
99
|
+
_revertWithLSP20DefaultError(true, errorData);
|
|
100
|
+
}
|
|
82
101
|
}
|
|
83
102
|
|
|
84
103
|
function _revertWithLSP20DefaultError(
|
|
@@ -86,7 +105,7 @@ abstract contract LSP20CallVerification {
|
|
|
86
105
|
bytes memory returnedData
|
|
87
106
|
) internal pure virtual {
|
|
88
107
|
// Look for revert reason and bubble it up if present
|
|
89
|
-
if (returnedData.length
|
|
108
|
+
if (returnedData.length != 0) {
|
|
90
109
|
// The easiest way to bubble the revert reason is using memory via assembly
|
|
91
110
|
// solhint-disable no-inline-assembly
|
|
92
111
|
/// @solidity memory-safe-assembly
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
// SPDX-License-Identifier:
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
pragma solidity ^0.8.4;
|
|
3
3
|
|
|
4
4
|
// bytes4(keccak256("LSP20CallVerification"))
|
|
5
5
|
bytes4 constant _INTERFACEID_LSP20_CALL_VERIFICATION = 0x1a0eb6a5;
|
|
6
6
|
|
|
7
|
-
// `lsp20VerifyCall(address,uint256,bytes)` selector XOR `lsp20VerifyCallResult(bytes32,bytes)` selector
|
|
8
|
-
bytes4 constant _INTERFACEID_LSP20_CALL_VERIFIER =
|
|
7
|
+
// `lsp20VerifyCall(address,address,address,uint256,bytes)` selector XOR `lsp20VerifyCallResult(bytes32,bytes)` selector
|
|
8
|
+
bytes4 constant _INTERFACEID_LSP20_CALL_VERIFIER = 0x0d6ecac7;
|
|
9
9
|
|
|
10
10
|
// bytes4(bytes.concat(bytes3(ILSP20.lsp20VerifyCall.selector), hex"01"))
|
|
11
|
-
bytes4 constant
|
|
11
|
+
bytes4 constant _LSP20_VERIFY_CALL_SUCCESS_VALUE_WITH_POST_VERIFICATION = 0xde928f01;
|
|
12
12
|
|
|
13
13
|
// bytes4(bytes.concat(bytes3(ILSP20.lsp20VerifyCall.selector), hex"00"))
|
|
14
|
-
bytes4 constant
|
|
14
|
+
bytes4 constant _LSP20_VERIFY_CALL_SUCCESS_VALUE_WITHOUT_POST_VERIFICATION = 0xde928f00;
|
|
15
15
|
|
|
16
16
|
// bytes4(ILSP20.lsp20VerifyCallResult.selector)
|
|
17
|
-
bytes4 constant
|
|
17
|
+
bytes4 constant _LSP20_VERIFY_CALL_RESULT_SUCCESS_VALUE = 0xd3fc45d3;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// SPDX-License-Identifier:
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
pragma solidity ^0.8.4;
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -8,8 +8,14 @@ pragma solidity ^0.8.4;
|
|
|
8
8
|
error LSP20CallingVerifierFailed(bool postCall);
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* @dev reverts when the call to the owner does not return the
|
|
11
|
+
* @dev reverts when the call to the owner does not return the LSP20 success value
|
|
12
12
|
* @param postCall True if the execution call was done, False otherwise
|
|
13
|
-
* @param
|
|
13
|
+
* @param returnedStatus The bytes4 decoded data returned by the logic verifier.
|
|
14
14
|
*/
|
|
15
|
-
error
|
|
15
|
+
error LSP20CallVerificationFailed(bool postCall, bytes4 returnedStatus);
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @dev Reverts when the logic verifier is an Externally Owned Account (EOA) that cannot return the LSP20 success value.
|
|
19
|
+
* @param logicVerifier The address of the logic verifier
|
|
20
|
+
*/
|
|
21
|
+
error LSP20EOACannotVerifyCall(address logicVerifier);
|