@lukso/lsp-smart-contracts 0.5.0 → 0.6.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 +38 -9
- package/artifacts/Create2Factory.json +2 -2
- package/artifacts/LSP0ERC725Account.json +398 -0
- package/artifacts/LSP0ERC725AccountInit.json +444 -0
- package/artifacts/LSP1UniversalReceiverDelegateUP.json +21 -5
- package/artifacts/LSP1UniversalReceiverDelegateVault.json +21 -5
- package/artifacts/LSP4Compatibility.json +195 -0
- package/artifacts/LSP4DigitalAssetMetadata.json +179 -0
- package/artifacts/LSP4DigitalAssetMetadataInit.json +241 -0
- package/artifacts/LSP6KeyManager.json +110 -35
- package/artifacts/LSP6KeyManagerInit.json +123 -30
- package/artifacts/LSP7CappedSupply.json +146 -11
- package/artifacts/LSP7CappedSupplyInit.json +167 -57
- package/artifacts/LSP7CompatibleERC20.json +714 -0
- package/artifacts/LSP7CompatibleERC20Init.json +760 -0
- package/artifacts/LSP7CompatibleERC20Mintable.json +742 -0
- package/artifacts/LSP7CompatibleERC20MintableInit.json +783 -0
- package/artifacts/LSP7DigitalAsset.json +138 -13
- package/artifacts/LSP7DigitalAssetInit.json +167 -34
- package/artifacts/LSP7Mintable.json +139 -14
- package/artifacts/LSP7MintableInit.json +168 -35
- package/artifacts/LSP8CappedSupply.json +147 -11
- package/artifacts/LSP8CappedSupplyInit.json +176 -37
- package/artifacts/LSP8CompatibleERC721.json +842 -0
- package/artifacts/LSP8CompatibleERC721Init.json +883 -0
- package/artifacts/LSP8CompatibleERC721Mintable.json +881 -0
- package/artifacts/LSP8CompatibleERC721MintableInit.json +922 -0
- package/artifacts/LSP8IdentifiableDigitalAsset.json +139 -13
- package/artifacts/LSP8IdentifiableDigitalAssetInit.json +176 -19
- package/artifacts/LSP8Mintable.json +151 -14
- package/artifacts/LSP8MintableInit.json +188 -20
- package/artifacts/LSP9Vault.json +374 -0
- package/artifacts/LSP9VaultInit.json +420 -0
- package/artifacts/UniversalFactory.json +127 -0
- package/artifacts/UniversalProfile.json +89 -32
- package/artifacts/UniversalProfileInit.json +133 -32
- package/artifacts/UniversalReceiverAddressStore.json +209 -0
- package/constants.js +535 -0
- package/contracts/Custom/ClaimOwnership.sol +34 -0
- package/contracts/Custom/ERC165Checker.sol +130 -0
- package/contracts/Custom/IClaimOwnership.sol +10 -0
- package/contracts/Factories/Create2Factory.sol +3 -13
- package/contracts/Factories/UniversalFactory.sol +164 -0
- package/contracts/LSP0ERC725Account/LSP0Constants.sol +5 -9
- package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +7 -9
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +108 -55
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +11 -4
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +6 -21
- package/contracts/LSP10ReceivedVaults/LSP10Constants.sol +10 -0
- package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiver.sol +3 -0
- package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiverDelegate.sol +4 -2
- package/contracts/LSP1UniversalReceiver/LSP1Constants.sol +3 -9
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/Handling/TokenAndVaultHandling.sol +67 -184
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +58 -6
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/Handling/TokenHandling.sol +51 -89
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +46 -6
- package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +62 -0
- package/contracts/LSP2ERC725YJSONSchema/LSP2Errors.sol +9 -0
- package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +201 -0
- package/contracts/LSP3UniversalProfile/LSP3Constants.sol +11 -0
- package/contracts/LSP4DigitalAssetMetadata/ILSP4Compatibility.sol +1 -1
- package/contracts/LSP4DigitalAssetMetadata/LSP4Compatibility.sol +5 -14
- package/contracts/LSP4DigitalAssetMetadata/LSP4Constants.sol +10 -4
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol +22 -8
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInit.sol +9 -13
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +26 -20
- package/contracts/LSP4DigitalAssetMetadata/LSP4Errors.sol +16 -0
- package/contracts/LSP5ReceivedAssets/LSP5Constants.sol +10 -0
- package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +231 -0
- package/contracts/LSP6KeyManager/ILSP6KeyManager.sol +28 -25
- package/contracts/LSP6KeyManager/LSP6Constants.sol +61 -25
- package/contracts/LSP6KeyManager/LSP6Errors.sol +66 -0
- package/contracts/LSP6KeyManager/LSP6KeyManager.sol +7 -6
- package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +465 -378
- package/contracts/LSP6KeyManager/LSP6KeyManagerInit.sol +13 -5
- package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +9 -15
- package/contracts/LSP6KeyManager/LSP6Utils.sol +107 -0
- package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +3 -8
- package/contracts/LSP7DigitalAsset/LSP7Constants.sol +5 -4
- package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +27 -9
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +73 -95
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInit.sol +19 -9
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +27 -23
- package/contracts/LSP7DigitalAsset/LSP7Errors.sol +23 -0
- package/contracts/LSP7DigitalAsset/extensions/ILSP7CappedSupply.sol +1 -1
- package/contracts/LSP7DigitalAsset/extensions/{ILSP7CompatibilityForERC20.sol → ILSP7CompatibleERC20.sol} +7 -9
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupply.sol +8 -7
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyCore.sol +14 -12
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInit.sol +3 -8
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInitAbstract.sol +10 -15
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.sol +67 -0
- package/contracts/LSP7DigitalAsset/extensions/{LSP7CompatibilityForERC20Core.sol → LSP7CompatibleERC20Core.sol} +36 -50
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20Init.sol +29 -0
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20InitAbstract.sol +67 -0
- package/contracts/LSP7DigitalAsset/{extensions → presets}/ILSP7Mintable.sol +1 -1
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.sol +22 -0
- package/contracts/LSP7DigitalAsset/{extensions/LSP7CompatibilityForERC20Init.sol → presets/LSP7CompatibleERC20MintableInit.sol} +6 -5
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInitAbstract.sol +27 -0
- package/contracts/LSP7DigitalAsset/{extensions → presets}/LSP7Mintable.sol +4 -3
- package/contracts/LSP7DigitalAsset/{extensions → presets}/LSP7MintableCore.sol +5 -5
- package/contracts/LSP7DigitalAsset/{extensions → presets}/LSP7MintableInit.sol +11 -3
- package/contracts/LSP7DigitalAsset/presets/LSP7MintableInitAbstract.sol +34 -0
- package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +5 -16
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol +6 -3
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol +22 -0
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +23 -10
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +103 -136
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInit.sol +17 -11
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +26 -21
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CappedSupply.sol +1 -1
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/{ILSP8CompatibilityForERC721.sol → ILSP8CompatibleERC721.sol} +4 -12
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.sol +9 -15
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyCore.sol +14 -12
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInit.sol +3 -8
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInitAbstract.sol +13 -20
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/{LSP8CompatibilityConstants.sol → LSP8CompatibleConstants.sol} +0 -0
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +101 -0
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/{LSP8CompatibilityForERC721Core.sol → LSP8CompatibleERC721Core.sol} +38 -95
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/{LSP8CompatibilityForERC721Init.sol → LSP8CompatibleERC721Init.sol} +4 -6
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +93 -0
- package/contracts/LSP8IdentifiableDigitalAsset/{extensions → presets}/ILSP8Mintable.sol +1 -1
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.sol +22 -0
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInit.sol +23 -0
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInitAbstract.sol +27 -0
- package/contracts/LSP8IdentifiableDigitalAsset/{extensions → presets}/LSP8Mintable.sol +4 -3
- package/contracts/LSP8IdentifiableDigitalAsset/{extensions → presets}/LSP8MintableCore.sol +5 -8
- package/contracts/LSP8IdentifiableDigitalAsset/{extensions → presets}/LSP8MintableInit.sol +11 -3
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +37 -0
- package/contracts/LSP9Vault/LSP9Constants.sol +14 -5
- package/contracts/LSP9Vault/LSP9Vault.sol +20 -38
- package/contracts/LSP9Vault/LSP9VaultCore.sol +123 -92
- package/contracts/LSP9Vault/LSP9VaultInit.sol +12 -4
- package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +20 -46
- package/contracts/Legacy/Registries/AddressRegistry.sol +43 -0
- package/contracts/Legacy/Registries/AddressRegistryRequiresERC725.sol +33 -0
- package/contracts/Legacy/UniversalReceiverAddressStore.sol +62 -0
- package/contracts/UniversalProfile.sol +11 -7
- package/contracts/UniversalProfileInit.sol +12 -4
- package/contracts/UniversalProfileInitAbstract.sol +12 -20
- package/contracts/Utils/UtilsLib.sol +21 -13
- package/package.json +23 -9
- package/artifacts/LSP1UniversalReceiverDelegateUPInit.json +0 -66
- package/artifacts/LSP1UniversalReceiverDelegateVaultInit.json +0 -66
- package/artifacts/LSP7CompatibilityForERC20.json +0 -571
- package/artifacts/LSP8CompatibilityForERC721.json +0 -716
- package/constants.ts +0 -356
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUPCore.sol +0 -52
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUPInit.sol +0 -26
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUPInitAbstract.sol +0 -28
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVaultCore.sol +0 -41
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVaultInit.sol +0 -23
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVaultInitAbstract.sol +0 -25
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibilityForERC20.sol +0 -56
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibilityForERC20InitAbstract.sol +0 -55
- package/contracts/LSP7DigitalAsset/extensions/LSP7MintableInitAbstract.sol +0 -47
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibilityForERC721.sol +0 -92
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibilityForERC721InitAbstract.sol +0 -90
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8MintableInitAbstract.sol +0 -44
- package/contracts/Utils/ERC725Utils.sol +0 -169
- package/contracts/Utils/LSP2Utils.sol +0 -127
- package/contracts/Utils/LSP6Utils.sol +0 -63
|
@@ -1,202 +1,85 @@
|
|
|
1
1
|
// SPDX-License-Identifier: CC0-1.0
|
|
2
2
|
pragma solidity ^0.8.0;
|
|
3
3
|
|
|
4
|
-
// modules
|
|
5
|
-
import "@erc725/smart-contracts/contracts/ERC725Y.sol";
|
|
6
|
-
import "../../../LSP6KeyManager/LSP6KeyManager.sol";
|
|
7
|
-
import "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
|
|
8
|
-
|
|
9
4
|
// interfaces
|
|
10
|
-
import "
|
|
11
|
-
import "../../../LSP7DigitalAsset/ILSP7DigitalAsset.sol";
|
|
5
|
+
import {IERC725Y} from "@erc725/smart-contracts/contracts/interfaces/IERC725Y.sol";
|
|
6
|
+
import {ILSP7DigitalAsset} from "../../../LSP7DigitalAsset/ILSP7DigitalAsset.sol";
|
|
7
|
+
import {ILSP6KeyManager} from "../../../LSP6KeyManager/ILSP6KeyManager.sol";
|
|
12
8
|
|
|
13
9
|
// libraries
|
|
14
|
-
import "../../../
|
|
10
|
+
import {ERC165Checker} from "../../../Custom/ERC165Checker.sol";
|
|
11
|
+
import {LSP1Utils} from "../../LSP1Utils.sol";
|
|
12
|
+
import {LSP2Utils} from "../../../LSP2ERC725YJSONSchema/LSP2Utils.sol";
|
|
13
|
+
import {LSP5Utils} from "../../../LSP5ReceivedAssets/LSP5Utils.sol";
|
|
14
|
+
|
|
15
|
+
// modules
|
|
16
|
+
import {ERC725Y} from "@erc725/smart-contracts/contracts/ERC725Y.sol";
|
|
17
|
+
import {LSP6KeyManager} from "../../../LSP6KeyManager/LSP6KeyManager.sol";
|
|
15
18
|
|
|
16
19
|
// constants
|
|
17
|
-
import "
|
|
18
|
-
import "../../../
|
|
19
|
-
import "../../../LSP7DigitalAsset/LSP7Constants.sol";
|
|
20
|
-
import "../../../LSP8IdentifiableDigitalAsset/LSP8Constants.sol";
|
|
21
|
-
import "../../../LSP9Vault/LSP9Constants.sol";
|
|
20
|
+
import {_INTERFACEID_LSP6} from "../../../LSP6KeyManager/LSP6Constants.sol";
|
|
21
|
+
import {_TYPEID_LSP9_VAULTSENDER} from "../../../LSP9Vault/LSP9Constants.sol";
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* @dev Function logic to add and remove the MapAndArrayKey of incoming assets and vaults
|
|
25
25
|
*/
|
|
26
|
-
abstract contract
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
address sender,
|
|
31
|
-
bytes32 typeId,
|
|
32
|
-
bytes memory data
|
|
33
|
-
) internal returns (bytes memory result) {
|
|
34
|
-
address keyManagerAddress = ERC725Y(msg.sender).owner();
|
|
35
|
-
_profileChecker(keyManagerAddress);
|
|
36
|
-
|
|
37
|
-
if (
|
|
38
|
-
ERC165Checker.supportsInterface(
|
|
39
|
-
keyManagerAddress,
|
|
40
|
-
_INTERFACEID_LSP6
|
|
41
|
-
)
|
|
42
|
-
) {
|
|
43
|
-
(
|
|
44
|
-
bytes32 arrayKey,
|
|
45
|
-
bytes32 mapHash,
|
|
46
|
-
bytes4 interfaceID
|
|
47
|
-
) = _getTransferData(typeId);
|
|
48
|
-
bytes32 mapKey = ERC725Utils.generateMapKey(
|
|
49
|
-
mapHash,
|
|
50
|
-
abi.encodePacked(sender)
|
|
51
|
-
);
|
|
52
|
-
bytes memory mapValue = IERC725Y(msg.sender).getDataSingle(mapKey);
|
|
53
|
-
|
|
54
|
-
if (
|
|
55
|
-
typeId == _TYPEID_LSP7_TOKENSRECIPIENT ||
|
|
56
|
-
typeId == _TYPEID_LSP8_TOKENSRECIPIENT ||
|
|
57
|
-
typeId == _TYPEID_LSP9_VAULTRECIPIENT
|
|
58
|
-
) {
|
|
59
|
-
if (bytes12(mapValue) == bytes12(0)) {
|
|
60
|
-
(bytes32[] memory keys, bytes[] memory values) = ERC725Utils
|
|
61
|
-
.addMapAndArrayKey(
|
|
62
|
-
IERC725Y(msg.sender),
|
|
63
|
-
arrayKey,
|
|
64
|
-
mapKey,
|
|
65
|
-
sender,
|
|
66
|
-
interfaceID
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
result = _executeViaKeyManager(
|
|
70
|
-
ILSP6KeyManager(keyManagerAddress),
|
|
71
|
-
keys,
|
|
72
|
-
values
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
} else if (
|
|
76
|
-
typeId == _TYPEID_LSP7_TOKENSSENDER ||
|
|
77
|
-
typeId == _TYPEID_LSP8_TOKENSSENDER ||
|
|
78
|
-
typeId == _TYPEID_LSP9_VAULTSENDER
|
|
79
|
-
) {
|
|
80
|
-
if (bytes12(mapValue) != bytes12(0)) {
|
|
81
|
-
if (typeId == _TYPEID_LSP9_VAULTSENDER) {
|
|
82
|
-
(
|
|
83
|
-
bytes32[] memory keys,
|
|
84
|
-
bytes[] memory values
|
|
85
|
-
) = ERC725Utils.removeMapAndArrayKey(
|
|
86
|
-
IERC725Y(msg.sender),
|
|
87
|
-
arrayKey,
|
|
88
|
-
mapHash,
|
|
89
|
-
mapKey
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
result = _executeViaKeyManager(
|
|
93
|
-
ILSP6KeyManager(keyManagerAddress),
|
|
94
|
-
keys,
|
|
95
|
-
values
|
|
96
|
-
);
|
|
97
|
-
} else if (
|
|
98
|
-
typeId == _TYPEID_LSP7_TOKENSSENDER ||
|
|
99
|
-
typeId == _TYPEID_LSP8_TOKENSSENDER
|
|
100
|
-
) {
|
|
101
|
-
uint256 balance = ILSP7DigitalAsset(sender).balanceOf(
|
|
102
|
-
msg.sender
|
|
103
|
-
);
|
|
104
|
-
if ((balance - _tokenAmount(typeId, data)) == 0) {
|
|
105
|
-
(
|
|
106
|
-
bytes32[] memory keys,
|
|
107
|
-
bytes[] memory values
|
|
108
|
-
) = ERC725Utils.removeMapAndArrayKey(
|
|
109
|
-
IERC725Y(msg.sender),
|
|
110
|
-
arrayKey,
|
|
111
|
-
mapHash,
|
|
112
|
-
mapKey
|
|
113
|
-
);
|
|
114
|
-
|
|
115
|
-
result = _executeViaKeyManager(
|
|
116
|
-
ILSP6KeyManager(keyManagerAddress),
|
|
117
|
-
keys,
|
|
118
|
-
values
|
|
119
|
-
);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// helper functions
|
|
128
|
-
|
|
129
|
-
function _getTransferData(bytes32 _typeId)
|
|
130
|
-
private
|
|
131
|
-
pure
|
|
132
|
-
returns (
|
|
133
|
-
bytes32 _arrayKey,
|
|
134
|
-
bytes32 _mapHash,
|
|
135
|
-
bytes4 _interfaceID
|
|
136
|
-
)
|
|
26
|
+
abstract contract TokenAndVaultHandling {
|
|
27
|
+
function _tokenAndVaultHandling(address caller, bytes32 typeId)
|
|
28
|
+
internal
|
|
29
|
+
returns (bytes memory result)
|
|
137
30
|
{
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
31
|
+
// avoid EOAs spamming the storage
|
|
32
|
+
if (caller.code.length == 0) return "";
|
|
33
|
+
|
|
34
|
+
address keyManager = ERC725Y(msg.sender).owner();
|
|
35
|
+
if (!ERC165Checker.supportsERC165Interface(keyManager, _INTERFACEID_LSP6)) return "";
|
|
36
|
+
|
|
37
|
+
address target = ILSP6KeyManager(keyManager).target();
|
|
38
|
+
|
|
39
|
+
// check if the caller is the same account controlled by the keyManager
|
|
40
|
+
if (msg.sender != target) return "";
|
|
41
|
+
|
|
42
|
+
(
|
|
43
|
+
bool isReceiving,
|
|
44
|
+
bytes32 arrayLengthKey,
|
|
45
|
+
bytes12 mapPrefix,
|
|
46
|
+
bytes4 interfaceID
|
|
47
|
+
) = LSP1Utils.getTransferDetails(typeId);
|
|
48
|
+
|
|
49
|
+
bytes32 mapKey = LSP2Utils.generateMappingKey(mapPrefix, bytes20(caller));
|
|
50
|
+
bytes memory mapValue = IERC725Y(msg.sender).getData(mapKey);
|
|
51
|
+
|
|
52
|
+
if (isReceiving) {
|
|
53
|
+
// if the map value is already set, then do nothing
|
|
54
|
+
if (bytes12(mapValue) != bytes12(0)) return "";
|
|
55
|
+
|
|
56
|
+
result = LSP5Utils.addMapAndArrayKeyViaKeyManager(
|
|
57
|
+
IERC725Y(msg.sender),
|
|
58
|
+
arrayLengthKey,
|
|
59
|
+
mapKey,
|
|
60
|
+
caller,
|
|
61
|
+
interfaceID,
|
|
62
|
+
keyManager
|
|
63
|
+
);
|
|
64
|
+
} else {
|
|
65
|
+
// if there is no map value for the asset to remove, then do nothing
|
|
66
|
+
if (bytes12(mapValue) == bytes12(0)) return "";
|
|
67
|
+
|
|
68
|
+
// if it's a token transfer (LSP7/LSP8)
|
|
69
|
+
if (typeId != _TYPEID_LSP9_VAULTSENDER) {
|
|
70
|
+
// if the amount sent is not the full balance, then do not remove the keys
|
|
71
|
+
uint256 balance = ILSP7DigitalAsset(caller).balanceOf(msg.sender);
|
|
72
|
+
if (balance != 0) return "";
|
|
153
73
|
}
|
|
154
|
-
} else if (
|
|
155
|
-
_typeId == _TYPEID_LSP9_VAULTSENDER ||
|
|
156
|
-
_typeId == _TYPEID_LSP9_VAULTRECIPIENT
|
|
157
|
-
) {
|
|
158
|
-
_arrayKey = _ARRAYKEY_LSP10;
|
|
159
|
-
_mapHash = _MAPHASH_LSP10;
|
|
160
|
-
_interfaceID = _INTERFACEID_LSP9;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
function _executeViaKeyManager(
|
|
165
|
-
ILSP6KeyManager _keyManagerAdd,
|
|
166
|
-
bytes32[] memory _keys,
|
|
167
|
-
bytes[] memory _values
|
|
168
|
-
) private returns (bytes memory result) {
|
|
169
|
-
bytes memory payload = abi.encodeWithSelector(
|
|
170
|
-
IERC725Y.setData.selector,
|
|
171
|
-
_keys,
|
|
172
|
-
_values
|
|
173
|
-
);
|
|
174
|
-
result = ILSP6KeyManager(_keyManagerAdd).execute(payload);
|
|
175
|
-
}
|
|
176
74
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
amount := mload(add(add(_data, 0x20), 0x28))
|
|
186
|
-
}
|
|
187
|
-
/* solhint-enable */
|
|
188
|
-
} else {
|
|
189
|
-
amount = 1;
|
|
75
|
+
result = LSP5Utils.removeMapAndArrayKeyViaKeyManager(
|
|
76
|
+
IERC725Y(msg.sender),
|
|
77
|
+
arrayLengthKey,
|
|
78
|
+
mapPrefix,
|
|
79
|
+
mapKey,
|
|
80
|
+
mapValue,
|
|
81
|
+
keyManager
|
|
82
|
+
);
|
|
190
83
|
}
|
|
191
84
|
}
|
|
192
|
-
|
|
193
|
-
function _profileChecker(address keyManagerAddress) private {
|
|
194
|
-
address profileAddress = address(
|
|
195
|
-
LSP6KeyManager(keyManagerAddress).account()
|
|
196
|
-
);
|
|
197
|
-
require(
|
|
198
|
-
profileAddress == msg.sender,
|
|
199
|
-
"Security: The called Key Manager belongs to a different account"
|
|
200
|
-
);
|
|
201
|
-
}
|
|
202
85
|
}
|
|
@@ -1,11 +1,30 @@
|
|
|
1
1
|
// SPDX-License-Identifier: CC0-1.0
|
|
2
2
|
pragma solidity ^0.8.0;
|
|
3
3
|
|
|
4
|
+
// interfaces
|
|
5
|
+
import {ILSP1UniversalReceiverDelegate} from "../ILSP1UniversalReceiverDelegate.sol";
|
|
6
|
+
|
|
4
7
|
// modules
|
|
5
|
-
import "
|
|
8
|
+
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
|
|
9
|
+
import {TokenAndVaultHandling} from "./Handling/TokenAndVaultHandling.sol";
|
|
10
|
+
|
|
11
|
+
// constants
|
|
12
|
+
import {_INTERFACEID_LSP1_DELEGATE} from "../LSP1Constants.sol";
|
|
13
|
+
import {
|
|
14
|
+
_TYPEID_LSP7_TOKENSSENDER,
|
|
15
|
+
_TYPEID_LSP7_TOKENSRECIPIENT
|
|
16
|
+
} from "../../LSP7DigitalAsset/LSP7Constants.sol";
|
|
17
|
+
import {
|
|
18
|
+
_TYPEID_LSP8_TOKENSSENDER,
|
|
19
|
+
_TYPEID_LSP8_TOKENSRECIPIENT
|
|
20
|
+
} from "../../LSP8IdentifiableDigitalAsset/LSP8Constants.sol";
|
|
21
|
+
import {
|
|
22
|
+
_TYPEID_LSP9_VAULTSENDER,
|
|
23
|
+
_TYPEID_LSP9_VAULTRECIPIENT
|
|
24
|
+
} from "../../LSP9Vault/LSP9Constants.sol";
|
|
6
25
|
|
|
7
26
|
/**
|
|
8
|
-
* @title Implementation of contract writing the received Vaults and LSP7, LSP8 assets into your ERC725Account using
|
|
27
|
+
* @title Core Implementation of contract writing the received Vaults and LSP7, LSP8 assets into your ERC725Account using
|
|
9
28
|
* the LSP5-ReceivedAsset and LSP10-ReceivedVaults standard and removing the sent vaults and assets.
|
|
10
29
|
*
|
|
11
30
|
* @author Fabian Vogelsteller, Yamen Merhi, Jean Cavallera
|
|
@@ -15,12 +34,45 @@ import "./LSP1UniversalReceiverDelegateUPCore.sol";
|
|
|
15
34
|
*
|
|
16
35
|
*/
|
|
17
36
|
contract LSP1UniversalReceiverDelegateUP is
|
|
18
|
-
|
|
37
|
+
ERC165,
|
|
38
|
+
ILSP1UniversalReceiverDelegate,
|
|
39
|
+
TokenAndVaultHandling
|
|
19
40
|
{
|
|
20
41
|
/**
|
|
21
|
-
* @
|
|
42
|
+
* @inheritdoc ILSP1UniversalReceiverDelegate
|
|
43
|
+
* @dev Allows to register arrayKeys and Map of incoming vaults and assets and removing them after being sent
|
|
44
|
+
* @return result the return value of keyManager's execute function
|
|
45
|
+
*/
|
|
46
|
+
function universalReceiverDelegate(
|
|
47
|
+
address sender,
|
|
48
|
+
uint256 value,
|
|
49
|
+
bytes32 typeId,
|
|
50
|
+
bytes memory data // solhint-disable no-unused-vars
|
|
51
|
+
) public virtual override returns (bytes memory result) {
|
|
52
|
+
if (
|
|
53
|
+
typeId == _TYPEID_LSP7_TOKENSSENDER ||
|
|
54
|
+
typeId == _TYPEID_LSP7_TOKENSRECIPIENT ||
|
|
55
|
+
typeId == _TYPEID_LSP8_TOKENSSENDER ||
|
|
56
|
+
typeId == _TYPEID_LSP8_TOKENSRECIPIENT ||
|
|
57
|
+
typeId == _TYPEID_LSP9_VAULTSENDER ||
|
|
58
|
+
typeId == _TYPEID_LSP9_VAULTRECIPIENT
|
|
59
|
+
) {
|
|
60
|
+
result = _tokenAndVaultHandling(sender, typeId);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* @TODO
|
|
64
|
+
else if() {
|
|
65
|
+
result = FollowerHandling(sender, typeId, data);
|
|
66
|
+
}
|
|
67
|
+
*/
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// --- Overrides
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @inheritdoc ERC165
|
|
22
74
|
*/
|
|
23
|
-
|
|
24
|
-
|
|
75
|
+
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
|
|
76
|
+
return interfaceId == _INTERFACEID_LSP1_DELEGATE || super.supportsInterface(interfaceId);
|
|
25
77
|
}
|
|
26
78
|
}
|
|
@@ -1,114 +1,76 @@
|
|
|
1
1
|
// SPDX-License-Identifier: CC0-1.0
|
|
2
2
|
pragma solidity ^0.8.0;
|
|
3
3
|
|
|
4
|
-
// modules
|
|
5
|
-
import "@erc725/smart-contracts/contracts/ERC725Y.sol";
|
|
6
|
-
|
|
7
4
|
// interfaces
|
|
8
|
-
import "
|
|
5
|
+
import {IERC725Y} from "@erc725/smart-contracts/contracts/interfaces/IERC725Y.sol";
|
|
6
|
+
import {ILSP7DigitalAsset} from "../../../LSP7DigitalAsset/ILSP7DigitalAsset.sol";
|
|
9
7
|
|
|
10
8
|
// libraries
|
|
11
|
-
import "../../../
|
|
9
|
+
import {ERC165Checker} from "../../../Custom/ERC165Checker.sol";
|
|
10
|
+
import {LSP1Utils} from "../../LSP1Utils.sol";
|
|
11
|
+
import {LSP2Utils} from "../../../LSP2ERC725YJSONSchema/LSP2Utils.sol";
|
|
12
|
+
import {LSP5Utils} from "../../../LSP5ReceivedAssets/LSP5Utils.sol";
|
|
13
|
+
|
|
14
|
+
// modules
|
|
15
|
+
import {ERC725Y} from "@erc725/smart-contracts/contracts/ERC725Y.sol";
|
|
16
|
+
import {LSP6KeyManager} from "../../../LSP6KeyManager/LSP6KeyManager.sol";
|
|
12
17
|
|
|
13
18
|
// constants
|
|
14
19
|
import "../../LSP1Constants.sol";
|
|
15
|
-
import "../../../LSP7DigitalAsset/LSP7Constants.sol";
|
|
16
|
-
import "../../../LSP8IdentifiableDigitalAsset/LSP8Constants.sol";
|
|
17
20
|
import "../../../LSP9Vault/LSP9Constants.sol";
|
|
18
21
|
|
|
19
22
|
/**
|
|
20
|
-
* @dev Function logic to add and remove the MapAndArrayKey of incoming assets
|
|
23
|
+
* @dev Function logic to add and remove the MapAndArrayKey of incoming assets and vaults
|
|
21
24
|
*/
|
|
22
|
-
abstract contract
|
|
23
|
-
|
|
25
|
+
abstract contract TokenHandling {
|
|
26
|
+
function _tokenHandling(address caller, bytes32 typeId) internal returns (bytes memory result) {
|
|
27
|
+
// avoid EOAs spamming the storage
|
|
28
|
+
if (caller.code.length == 0) return "";
|
|
29
|
+
|
|
30
|
+
if (!ERC165Checker.supportsERC165Interface(msg.sender, _INTERFACEID_LSP9)) return "";
|
|
24
31
|
|
|
25
|
-
function _tokenHandling(
|
|
26
|
-
address sender,
|
|
27
|
-
bytes32 typeId,
|
|
28
|
-
bytes memory data
|
|
29
|
-
) internal returns (bytes memory) {
|
|
30
32
|
(
|
|
31
|
-
|
|
32
|
-
bytes32
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
mapHash,
|
|
37
|
-
abi.encodePacked(sender)
|
|
38
|
-
);
|
|
39
|
-
IERC725Y vault = IERC725Y(msg.sender);
|
|
40
|
-
bytes memory mapValue = vault.getDataSingle(mapKey);
|
|
33
|
+
bool isReceiving,
|
|
34
|
+
bytes32 arrayLengthKey,
|
|
35
|
+
bytes12 mapPrefix,
|
|
36
|
+
bytes4 interfaceID
|
|
37
|
+
) = LSP1Utils.getTransferDetails(typeId);
|
|
41
38
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
typeId == _TYPEID_LSP8_TOKENSRECIPIENT
|
|
45
|
-
) {
|
|
46
|
-
if (bytes12(mapValue) == bytes12(0)) {
|
|
47
|
-
(bytes32[] memory keys, bytes[] memory values) = ERC725Utils
|
|
48
|
-
.addMapAndArrayKey(
|
|
49
|
-
vault,
|
|
50
|
-
arrayKey,
|
|
51
|
-
mapKey,
|
|
52
|
-
sender,
|
|
53
|
-
interfaceId
|
|
54
|
-
);
|
|
39
|
+
bytes32 mapKey = LSP2Utils.generateMappingKey(mapPrefix, bytes20(caller));
|
|
40
|
+
bytes memory mapValue = IERC725Y(msg.sender).getData(mapKey);
|
|
55
41
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
42
|
+
if (isReceiving) {
|
|
43
|
+
// if the map value is already set, then do nothing
|
|
44
|
+
if (bytes12(mapValue) != bytes12(0)) return "";
|
|
45
|
+
|
|
46
|
+
(bytes32[] memory receiverDataKeys, bytes[] memory receiverDataValues) = LSP5Utils
|
|
47
|
+
.addMapAndArrayKey(
|
|
48
|
+
IERC725Y(msg.sender),
|
|
49
|
+
arrayLengthKey,
|
|
50
|
+
mapKey,
|
|
51
|
+
caller,
|
|
52
|
+
interfaceID
|
|
65
53
|
);
|
|
66
|
-
if ((balance - _tokenAmount(typeId, data)) == 0) {
|
|
67
|
-
(bytes32[] memory keys, bytes[] memory values) = ERC725Utils
|
|
68
|
-
.removeMapAndArrayKey(vault, arrayKey, mapHash, mapKey);
|
|
69
54
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
55
|
+
IERC725Y(msg.sender).setData(receiverDataKeys, receiverDataValues);
|
|
56
|
+
} else {
|
|
57
|
+
// if there is no map value for the asset to remove, then do nothing
|
|
58
|
+
if (bytes12(mapValue) == bytes12(0)) return "";
|
|
75
59
|
|
|
76
|
-
|
|
60
|
+
// if the amount sent is not the full balance, then do not remove the keys
|
|
61
|
+
uint256 balance = ILSP7DigitalAsset(caller).balanceOf(msg.sender);
|
|
62
|
+
if (balance != 0) return "";
|
|
77
63
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
{
|
|
87
|
-
arrayKey = _ARRAYKEY_LSP5;
|
|
88
|
-
mapHash = _MAPHASH_LSP5;
|
|
89
|
-
if (
|
|
90
|
-
_typeId == _TYPEID_LSP7_TOKENSSENDER ||
|
|
91
|
-
_typeId == _TYPEID_LSP7_TOKENSRECIPIENT
|
|
92
|
-
) {
|
|
93
|
-
interfaceID = _INTERFACEID_LSP7;
|
|
94
|
-
} else {
|
|
95
|
-
interfaceID = _INTERFACEID_LSP8;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
64
|
+
(bytes32[] memory senderDataKeys, bytes[] memory senderDataValues) = LSP5Utils
|
|
65
|
+
.removeMapAndArrayKey(
|
|
66
|
+
IERC725Y(msg.sender),
|
|
67
|
+
arrayLengthKey,
|
|
68
|
+
mapPrefix,
|
|
69
|
+
mapKey,
|
|
70
|
+
mapValue
|
|
71
|
+
);
|
|
98
72
|
|
|
99
|
-
|
|
100
|
-
private
|
|
101
|
-
pure
|
|
102
|
-
returns (uint256 amount)
|
|
103
|
-
{
|
|
104
|
-
if (_typeId == _TYPEID_LSP7_TOKENSSENDER) {
|
|
105
|
-
/* solhint-disable */
|
|
106
|
-
assembly {
|
|
107
|
-
amount := mload(add(add(_data, 0x20), 0x28))
|
|
108
|
-
}
|
|
109
|
-
/* solhint-enable */
|
|
110
|
-
} else {
|
|
111
|
-
amount = 1;
|
|
73
|
+
IERC725Y(msg.sender).setData(senderDataKeys, senderDataValues);
|
|
112
74
|
}
|
|
113
75
|
}
|
|
114
76
|
}
|
|
@@ -1,23 +1,63 @@
|
|
|
1
1
|
// SPDX-License-Identifier: CC0-1.0
|
|
2
2
|
pragma solidity ^0.8.0;
|
|
3
3
|
|
|
4
|
+
// interfaces
|
|
5
|
+
import {ILSP1UniversalReceiverDelegate} from "../ILSP1UniversalReceiverDelegate.sol";
|
|
6
|
+
|
|
4
7
|
// modules
|
|
5
|
-
import "
|
|
8
|
+
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
|
|
9
|
+
import {TokenHandling} from "./Handling/TokenHandling.sol";
|
|
10
|
+
|
|
11
|
+
// constants
|
|
12
|
+
import {_INTERFACEID_LSP1_DELEGATE} from "../LSP1Constants.sol";
|
|
13
|
+
import {
|
|
14
|
+
_TYPEID_LSP7_TOKENSSENDER,
|
|
15
|
+
_TYPEID_LSP7_TOKENSRECIPIENT
|
|
16
|
+
} from "../../LSP7DigitalAsset/LSP7Constants.sol";
|
|
17
|
+
import {
|
|
18
|
+
_TYPEID_LSP8_TOKENSSENDER,
|
|
19
|
+
_TYPEID_LSP8_TOKENSRECIPIENT
|
|
20
|
+
} from "../../LSP8IdentifiableDigitalAsset/LSP8Constants.sol";
|
|
6
21
|
|
|
7
22
|
/**
|
|
8
|
-
* @title Implementation of contract writing the received LSP7 and LSP8 assets into your Vault using
|
|
23
|
+
* @title Core Implementation of contract writing the received LSP7 and LSP8 assets into your Vault using
|
|
9
24
|
* the LSP5-ReceivedAsset standard and removing the sent assets.
|
|
10
25
|
*
|
|
11
26
|
* @author Fabian Vogelsteller, Yamen Merhi, Jean Cavallera
|
|
12
27
|
* @dev Delegate contract of the initial universal receiver
|
|
13
28
|
*/
|
|
14
29
|
contract LSP1UniversalReceiverDelegateVault is
|
|
15
|
-
|
|
30
|
+
ERC165,
|
|
31
|
+
ILSP1UniversalReceiverDelegate,
|
|
32
|
+
TokenHandling
|
|
16
33
|
{
|
|
17
34
|
/**
|
|
18
|
-
* @
|
|
35
|
+
* @inheritdoc ILSP1UniversalReceiverDelegate
|
|
36
|
+
* @dev allows to register arrayKeys and Map of incoming assets and remove after being sent
|
|
37
|
+
* @return result The return value
|
|
38
|
+
*/
|
|
39
|
+
function universalReceiverDelegate(
|
|
40
|
+
address sender,
|
|
41
|
+
uint256 value,
|
|
42
|
+
bytes32 typeId,
|
|
43
|
+
bytes memory data // solhint-disable no-unused-vars
|
|
44
|
+
) public virtual override returns (bytes memory result) {
|
|
45
|
+
if (
|
|
46
|
+
typeId == _TYPEID_LSP7_TOKENSSENDER ||
|
|
47
|
+
typeId == _TYPEID_LSP7_TOKENSRECIPIENT ||
|
|
48
|
+
typeId == _TYPEID_LSP8_TOKENSSENDER ||
|
|
49
|
+
typeId == _TYPEID_LSP8_TOKENSRECIPIENT
|
|
50
|
+
) {
|
|
51
|
+
result = _tokenHandling(sender, typeId);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// --- Overrides
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @inheritdoc ERC165
|
|
19
59
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
60
|
+
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
|
|
61
|
+
return interfaceId == _INTERFACEID_LSP1_DELEGATE || super.supportsInterface(interfaceId);
|
|
22
62
|
}
|
|
23
63
|
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
// constants
|
|
5
|
+
import {
|
|
6
|
+
_LSP5_RECEIVED_ASSETS_ARRAY_KEY,
|
|
7
|
+
_LSP5_RECEIVED_ASSETS_MAP_KEY_PREFIX
|
|
8
|
+
} from "../LSP5ReceivedAssets/LSP5Constants.sol";
|
|
9
|
+
import {
|
|
10
|
+
_INTERFACEID_LSP7,
|
|
11
|
+
_TYPEID_LSP7_TOKENSSENDER,
|
|
12
|
+
_TYPEID_LSP7_TOKENSRECIPIENT
|
|
13
|
+
} from "../LSP7DigitalAsset/LSP7Constants.sol";
|
|
14
|
+
import {
|
|
15
|
+
_INTERFACEID_LSP8,
|
|
16
|
+
_TYPEID_LSP8_TOKENSRECIPIENT,
|
|
17
|
+
_TYPEID_LSP8_TOKENSSENDER
|
|
18
|
+
} from "../LSP8IdentifiableDigitalAsset/LSP8Constants.sol";
|
|
19
|
+
import {_INTERFACEID_LSP9, _TYPEID_LSP9_VAULTRECIPIENT} from "../LSP9Vault/LSP9Constants.sol";
|
|
20
|
+
import {
|
|
21
|
+
_LSP10_VAULTS_ARRAY_KEY,
|
|
22
|
+
_LSP10_VAULTS_MAP_KEY_PREFIX
|
|
23
|
+
} from "../LSP10ReceivedVaults/LSP10Constants.sol";
|
|
24
|
+
|
|
25
|
+
library LSP1Utils {
|
|
26
|
+
/**
|
|
27
|
+
* @dev Gets all the transfer details depending on the `typeId`
|
|
28
|
+
*/
|
|
29
|
+
function getTransferDetails(bytes32 typeId)
|
|
30
|
+
internal
|
|
31
|
+
pure
|
|
32
|
+
returns (
|
|
33
|
+
bool isReceiving,
|
|
34
|
+
bytes32 arrayKey,
|
|
35
|
+
bytes12 mapPrefix,
|
|
36
|
+
bytes4 interfaceId
|
|
37
|
+
)
|
|
38
|
+
{
|
|
39
|
+
if (
|
|
40
|
+
typeId == _TYPEID_LSP7_TOKENSSENDER ||
|
|
41
|
+
typeId == _TYPEID_LSP7_TOKENSRECIPIENT ||
|
|
42
|
+
typeId == _TYPEID_LSP8_TOKENSRECIPIENT ||
|
|
43
|
+
typeId == _TYPEID_LSP8_TOKENSSENDER
|
|
44
|
+
) {
|
|
45
|
+
arrayKey = _LSP5_RECEIVED_ASSETS_ARRAY_KEY;
|
|
46
|
+
mapPrefix = _LSP5_RECEIVED_ASSETS_MAP_KEY_PREFIX;
|
|
47
|
+
interfaceId = typeId == _TYPEID_LSP7_TOKENSSENDER ||
|
|
48
|
+
typeId == _TYPEID_LSP7_TOKENSRECIPIENT
|
|
49
|
+
? _INTERFACEID_LSP7
|
|
50
|
+
: _INTERFACEID_LSP8;
|
|
51
|
+
isReceiving = typeId == _TYPEID_LSP7_TOKENSRECIPIENT ||
|
|
52
|
+
typeId == _TYPEID_LSP8_TOKENSRECIPIENT
|
|
53
|
+
? true
|
|
54
|
+
: false;
|
|
55
|
+
} else {
|
|
56
|
+
arrayKey = _LSP10_VAULTS_ARRAY_KEY;
|
|
57
|
+
mapPrefix = _LSP10_VAULTS_MAP_KEY_PREFIX;
|
|
58
|
+
interfaceId = _INTERFACEID_LSP9;
|
|
59
|
+
isReceiving = typeId == _TYPEID_LSP9_VAULTRECIPIENT ? true : false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @dev reverts when `value` is not a properly ABI encoded array
|
|
6
|
+
* @param value the value to check for an abi-encoded array
|
|
7
|
+
* @param valueType the type of the value to check for an abi-encoded array
|
|
8
|
+
*/
|
|
9
|
+
error InvalidABIEncodedArray(bytes value, string valueType);
|