@lukso/lsp-smart-contracts 0.6.2 → 0.8.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/CONTRIBUTING.md +31 -0
- package/README.md +73 -28
- package/artifacts/Create2Factory.json +2 -2
- package/artifacts/LSP0ERC725Account.json +227 -15
- package/artifacts/LSP0ERC725AccountInit.json +227 -41
- 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 +22 -0
- package/artifacts/LSP4DigitalAssetMetadata.json +22 -0
- package/artifacts/{LSP4DigitalAssetMetadataInit.json → LSP4DigitalAssetMetadataInitAbstract.json} +24 -51
- package/artifacts/LSP6KeyManager.json +188 -33
- package/artifacts/LSP6KeyManagerInit.json +188 -33
- package/artifacts/LSP7CappedSupply.json +58 -31
- package/artifacts/{LSP7CappedSupplyInit.json → LSP7CappedSupplyInitAbstract.json} +60 -72
- package/artifacts/LSP7CompatibleERC20.json +52 -46
- package/artifacts/LSP7CompatibleERC20InitAbstract.json +733 -0
- package/artifacts/LSP7CompatibleERC20Mintable.json +61 -34
- package/artifacts/LSP7CompatibleERC20MintableInit.json +66 -60
- package/artifacts/LSP7DigitalAsset.json +52 -51
- package/artifacts/LSP7DigitalAssetInitAbstract.json +556 -0
- package/artifacts/LSP7Mintable.json +62 -35
- package/artifacts/LSP7MintableInit.json +62 -61
- package/artifacts/LSP8CappedSupply.json +64 -5
- package/artifacts/LSP8CappedSupplyInitAbstract.json +667 -0
- package/artifacts/LSP8CompatibleERC721.json +102 -21
- package/artifacts/LSP8CompatibleERC721InitAbstract.json +936 -0
- package/artifacts/LSP8CompatibleERC721Mintable.json +111 -9
- package/artifacts/LSP8CompatibleERC721MintableInit.json +116 -35
- package/artifacts/LSP8IdentifiableDigitalAsset.json +58 -20
- package/artifacts/{LSP8CappedSupplyInit.json → LSP8IdentifiableDigitalAssetInitAbstract.json} +62 -65
- package/artifacts/LSP8Mintable.json +67 -8
- package/artifacts/LSP8MintableInit.json +67 -34
- package/artifacts/LSP9Vault.json +235 -17
- package/artifacts/LSP9VaultInit.json +235 -43
- package/artifacts/UniversalProfile.json +227 -15
- package/artifacts/UniversalProfileInit.json +227 -41
- package/artifacts/UniversalReceiverAddressStore.json +3 -3
- package/constants.js +416 -95
- 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 +274 -74
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +2 -2
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +3 -2
- package/contracts/LSP10ReceivedVaults/LSP10Constants.sol +4 -4
- package/contracts/LSP10ReceivedVaults/LSP10Utils.sol +214 -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 +156 -42
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +64 -31
- package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +54 -41
- package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +136 -28
- 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 +16 -7
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +16 -7
- package/contracts/LSP4DigitalAssetMetadata/LSP4Errors.sol +3 -3
- package/contracts/LSP5ReceivedAssets/LSP5Constants.sol +4 -4
- package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +103 -115
- package/contracts/LSP6KeyManager/ILSP6KeyManager.sol +26 -8
- package/contracts/LSP6KeyManager/LSP6Constants.sol +45 -45
- package/contracts/LSP6KeyManager/LSP6Errors.sol +97 -20
- package/contracts/LSP6KeyManager/LSP6KeyManager.sol +3 -2
- package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +786 -359
- package/contracts/LSP6KeyManager/LSP6KeyManagerInit.sol +2 -2
- package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +4 -3
- package/contracts/LSP6KeyManager/LSP6Utils.sol +127 -35
- package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +26 -13
- package/contracts/LSP7DigitalAsset/LSP7Constants.sol +6 -6
- package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +5 -5
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +65 -52
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +3 -3
- package/contracts/LSP7DigitalAsset/LSP7Errors.sol +30 -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 +9 -2
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInitAbstract.sol +3 -3
- package/contracts/LSP7DigitalAsset/presets/LSP7Mintable.sol +12 -12
- package/contracts/LSP7DigitalAsset/presets/LSP7MintableInit.sol +5 -5
- package/contracts/LSP7DigitalAsset/presets/LSP7MintableInitAbstract.sol +11 -10
- package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +10 -8
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol +11 -11
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol +45 -1
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +3 -3
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +75 -71
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +1 -1
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CompatibleERC721.sol +20 -3
- 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 +236 -30
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +240 -30
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.sol +49 -0
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableInitAbstract.sol +51 -0
- package/contracts/LSP8IdentifiableDigitalAsset/presets/ILSP8Mintable.sol +3 -3
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.sol +3 -4
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInit.sol +9 -2
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInitAbstract.sol +3 -3
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.sol +9 -8
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInit.sol +2 -2
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +8 -7
- package/contracts/LSP9Vault/LSP9Constants.sol +11 -8
- package/contracts/LSP9Vault/LSP9Errors.sol +8 -0
- package/contracts/LSP9Vault/LSP9Vault.sol +6 -4
- package/contracts/LSP9Vault/LSP9VaultCore.sol +324 -90
- package/contracts/LSP9Vault/LSP9VaultInit.sol +2 -2
- package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +5 -4
- package/contracts/Legacy/Registries/AddressRegistry.sol +1 -1
- package/contracts/Legacy/Registries/AddressRegistryRequiresERC725.sol +1 -1
- package/contracts/Legacy/UniversalReceiverAddressStore.sol +4 -13
- package/contracts/UniversalProfile.sol +2 -2
- package/contracts/UniversalProfileInit.sol +2 -2
- package/contracts/UniversalProfileInitAbstract.sol +1 -1
- package/contracts/Utils/GasLib.sol +17 -0
- package/package.json +37 -32
- package/artifacts/LSP7CompatibleERC20Init.json +0 -760
- package/artifacts/LSP7DigitalAssetInit.json +0 -588
- package/artifacts/LSP8CompatibleERC721Init.json +0 -883
- package/artifacts/LSP8IdentifiableDigitalAssetInit.json +0 -639
- package/artifacts/UniversalFactory.json +0 -127
- package/contracts/Custom/ClaimOwnership.sol +0 -34
- package/contracts/Custom/ERC165Checker.sol +0 -130
- package/contracts/Custom/IClaimOwnership.sol +0 -10
- package/contracts/Factories/UniversalFactory.sol +0 -164
- package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiverDelegate.sol +0 -24
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/Handling/TokenAndVaultHandling.sol +0 -85
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/Handling/TokenHandling.sol +0 -76
- package/contracts/LSP2ERC725YJSONSchema/LSP2Errors.sol +0 -9
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInit.sol +0 -26
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInit.sol +0 -39
- package/contracts/LSP7DigitalAsset/extensions/ILSP7CappedSupply.sol +0 -17
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyCore.sol +0 -57
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInit.sol +0 -19
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20Core.sol +0 -112
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20Init.sol +0 -29
- package/contracts/LSP7DigitalAsset/presets/LSP7MintableCore.sol +0 -26
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInit.sol +0 -35
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CappedSupply.sol +0 -17
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyCore.sol +0 -58
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInit.sol +0 -19
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleConstants.sol +0 -6
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721Core.sol +0 -187
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721Init.sol +0 -25
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableCore.sol +0 -26
- package/contracts/Utils/UtilsLib.sol +0 -31
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
pragma solidity ^0.8.
|
|
2
|
+
pragma solidity ^0.8.5;
|
|
3
3
|
|
|
4
4
|
// modules
|
|
5
5
|
import {LSP6KeyManagerInitAbstract} from "./LSP6KeyManagerInitAbstract.sol";
|
|
@@ -21,7 +21,7 @@ contract LSP6KeyManagerInit is LSP6KeyManagerInitAbstract {
|
|
|
21
21
|
* @notice Initiate the account with the address of the ERC725Account contract and sets LSP6KeyManager InterfaceId
|
|
22
22
|
* @param target_ The address of the ER725Account to control
|
|
23
23
|
*/
|
|
24
|
-
function initialize(address target_)
|
|
24
|
+
function initialize(address target_) external virtual initializer {
|
|
25
25
|
LSP6KeyManagerInitAbstract._initialize(target_);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
pragma solidity ^0.8.
|
|
2
|
+
pragma solidity ^0.8.5;
|
|
3
3
|
|
|
4
4
|
// modules
|
|
5
5
|
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
|
|
6
|
-
import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";
|
|
6
|
+
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
|
|
7
7
|
import {LSP6KeyManagerCore} from "./LSP6KeyManagerCore.sol";
|
|
8
8
|
import {InvalidLSP6Target} from "./LSP6Errors.sol";
|
|
9
9
|
|
|
@@ -15,6 +15,7 @@ import {InvalidLSP6Target} from "./LSP6Errors.sol";
|
|
|
15
15
|
abstract contract LSP6KeyManagerInitAbstract is Initializable, LSP6KeyManagerCore {
|
|
16
16
|
function _initialize(address target_) internal virtual onlyInitializing {
|
|
17
17
|
if (target_ == address(0)) revert InvalidLSP6Target();
|
|
18
|
-
|
|
18
|
+
_target = target_;
|
|
19
|
+
_setupLSP6ReentrancyGuard();
|
|
19
20
|
}
|
|
20
21
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
pragma solidity ^0.8.
|
|
2
|
+
pragma solidity ^0.8.4;
|
|
3
3
|
|
|
4
4
|
// interfaces
|
|
5
5
|
import {IERC725Y} from "@erc725/smart-contracts/contracts/interfaces/IERC725Y.sol";
|
|
@@ -9,11 +9,18 @@ import {ILSP6KeyManager} from "./ILSP6KeyManager.sol";
|
|
|
9
9
|
import {LSP2Utils} from "../LSP2ERC725YJSONSchema/LSP2Utils.sol";
|
|
10
10
|
|
|
11
11
|
// constants
|
|
12
|
+
import {SETDATA_ARRAY_SELECTOR} from "@erc725/smart-contracts/contracts/constants.sol";
|
|
12
13
|
import "../LSP6KeyManager/LSP6Constants.sol";
|
|
13
14
|
|
|
14
15
|
library LSP6Utils {
|
|
15
16
|
using LSP2Utils for bytes12;
|
|
16
17
|
|
|
18
|
+
/**
|
|
19
|
+
* @dev read the permissions of a `caller` on an ERC725Y `target` contract.
|
|
20
|
+
* @param target an `IERC725Y` contract where to read the permissions.
|
|
21
|
+
* @param caller the controller address to read the permissions from.
|
|
22
|
+
* @return a `bytes32` BitArray containing the permissions of a controller address.
|
|
23
|
+
*/
|
|
17
24
|
function getPermissionsFor(IERC725Y target, address caller) internal view returns (bytes32) {
|
|
18
25
|
bytes memory permissions = target.getData(
|
|
19
26
|
LSP2Utils.generateMappingWithGroupingKey(
|
|
@@ -25,21 +32,7 @@ library LSP6Utils {
|
|
|
25
32
|
return bytes32(permissions);
|
|
26
33
|
}
|
|
27
34
|
|
|
28
|
-
function
|
|
29
|
-
internal
|
|
30
|
-
view
|
|
31
|
-
returns (bytes memory)
|
|
32
|
-
{
|
|
33
|
-
return
|
|
34
|
-
target.getData(
|
|
35
|
-
LSP2Utils.generateMappingWithGroupingKey(
|
|
36
|
-
_LSP6KEY_ADDRESSPERMISSIONS_ALLOWEDADDRESSES_PREFIX,
|
|
37
|
-
bytes20(caller)
|
|
38
|
-
)
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function getAllowedFunctionsFor(IERC725Y target, address caller)
|
|
35
|
+
function getAllowedCallsFor(IERC725Y target, address from)
|
|
43
36
|
internal
|
|
44
37
|
view
|
|
45
38
|
returns (bytes memory)
|
|
@@ -47,27 +40,19 @@ library LSP6Utils {
|
|
|
47
40
|
return
|
|
48
41
|
target.getData(
|
|
49
42
|
LSP2Utils.generateMappingWithGroupingKey(
|
|
50
|
-
|
|
51
|
-
bytes20(
|
|
43
|
+
_LSP6KEY_ADDRESSPERMISSIONS_ALLOWEDCALLS_PREFIX,
|
|
44
|
+
bytes20(from)
|
|
52
45
|
)
|
|
53
46
|
);
|
|
54
47
|
}
|
|
55
48
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
LSP2Utils.generateMappingWithGroupingKey(
|
|
64
|
-
_LSP6KEY_ADDRESSPERMISSIONS_ALLOWEDSTANDARDS_PREFIX,
|
|
65
|
-
bytes20(caller)
|
|
66
|
-
)
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function getAllowedERC725YKeysFor(IERC725Y target, address caller)
|
|
49
|
+
/**
|
|
50
|
+
* @dev read the Allowed ERC725Y data keys of a `caller` on an ERC725Y `target` contract.
|
|
51
|
+
* @param target an `IERC725Y` contract where to read the permissions.
|
|
52
|
+
* @param caller the controller address to read the permissions from.
|
|
53
|
+
* @return an abi-encoded array of allowed ERC725 keys that the controller address is allowed to interact with.
|
|
54
|
+
*/
|
|
55
|
+
function getAllowedERC725YDataKeysFor(IERC725Y target, address caller)
|
|
71
56
|
internal
|
|
72
57
|
view
|
|
73
58
|
returns (bytes memory)
|
|
@@ -75,7 +60,7 @@ library LSP6Utils {
|
|
|
75
60
|
return
|
|
76
61
|
target.getData(
|
|
77
62
|
LSP2Utils.generateMappingWithGroupingKey(
|
|
78
|
-
|
|
63
|
+
_LSP6KEY_ADDRESSPERMISSIONS_AllowedERC725YDataKeys_PREFIX,
|
|
79
64
|
bytes20(caller)
|
|
80
65
|
)
|
|
81
66
|
);
|
|
@@ -96,12 +81,119 @@ library LSP6Utils {
|
|
|
96
81
|
return (addressPermission & permissionToCheck) == permissionToCheck;
|
|
97
82
|
}
|
|
98
83
|
|
|
84
|
+
/**
|
|
85
|
+
* @dev same as LSP2Utils.isCompactBytesArray with the additional requirement that each element must be 28 bytes long.
|
|
86
|
+
*
|
|
87
|
+
* @param allowedCallsCompacted a compact bytes array of tuples (bytes4,address,bytes4) to check.
|
|
88
|
+
* @return true if the value passed is a valid compact bytes array of bytes28 elements according to LSP2, false otherwise.
|
|
89
|
+
*/
|
|
90
|
+
function isCompactBytesArrayOfAllowedCalls(bytes memory allowedCallsCompacted)
|
|
91
|
+
internal
|
|
92
|
+
pure
|
|
93
|
+
returns (bool)
|
|
94
|
+
{
|
|
95
|
+
uint256 pointer;
|
|
96
|
+
|
|
97
|
+
while (pointer < allowedCallsCompacted.length) {
|
|
98
|
+
if (pointer + 1 >= allowedCallsCompacted.length) return false;
|
|
99
|
+
uint256 elementLength = uint16(
|
|
100
|
+
bytes2(
|
|
101
|
+
abi.encodePacked(
|
|
102
|
+
allowedCallsCompacted[pointer],
|
|
103
|
+
allowedCallsCompacted[pointer + 1]
|
|
104
|
+
)
|
|
105
|
+
)
|
|
106
|
+
);
|
|
107
|
+
// each entries in the allowedCalls (compact) array must be 28 bytes long
|
|
108
|
+
if (elementLength != 28) return false;
|
|
109
|
+
pointer += elementLength + 2;
|
|
110
|
+
}
|
|
111
|
+
if (pointer == allowedCallsCompacted.length) return true;
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* @dev same as LSP2Utils.isCompactBytesArray with the additional requirement that each element must be from 1 to 32 bytes long.
|
|
117
|
+
*
|
|
118
|
+
* @param allowedERC725YDataKeysCompacted a compact bytes array of ERC725Y Data Keys (full bytes32 data keys or bytesN prefix) to check.
|
|
119
|
+
* @return true if the value passed is a valid compact bytes array of ERC725Y Data Keys, false otherwise.
|
|
120
|
+
*/
|
|
121
|
+
function isCompactBytesArrayOfAllowedERC725YDataKeys(
|
|
122
|
+
bytes memory allowedERC725YDataKeysCompacted
|
|
123
|
+
) internal pure returns (bool) {
|
|
124
|
+
uint256 pointer;
|
|
125
|
+
|
|
126
|
+
while (pointer < allowedERC725YDataKeysCompacted.length) {
|
|
127
|
+
if (pointer + 1 >= allowedERC725YDataKeysCompacted.length) return false;
|
|
128
|
+
uint256 elementLength = uint16(
|
|
129
|
+
bytes2(
|
|
130
|
+
abi.encodePacked(
|
|
131
|
+
allowedERC725YDataKeysCompacted[pointer],
|
|
132
|
+
allowedERC725YDataKeysCompacted[pointer + 1]
|
|
133
|
+
)
|
|
134
|
+
)
|
|
135
|
+
);
|
|
136
|
+
// the length of the allowed data key must be not under 33 bytes and not 0
|
|
137
|
+
if (elementLength == 0 || elementLength > 32) return false;
|
|
138
|
+
pointer += elementLength + 2;
|
|
139
|
+
}
|
|
140
|
+
if (pointer == allowedERC725YDataKeysCompacted.length) return true;
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* @dev use the `setData(bytes32[],bytes[])` via the KeyManager of the target
|
|
146
|
+
* @param keyManagerAddress the address of the KeyManager
|
|
147
|
+
* @param keys the array of data keys
|
|
148
|
+
* @param values the array of data values
|
|
149
|
+
*/
|
|
99
150
|
function setDataViaKeyManager(
|
|
100
151
|
address keyManagerAddress,
|
|
101
152
|
bytes32[] memory keys,
|
|
102
153
|
bytes[] memory values
|
|
103
154
|
) internal returns (bytes memory result) {
|
|
104
|
-
bytes memory payload = abi.encodeWithSelector(
|
|
155
|
+
bytes memory payload = abi.encodeWithSelector(SETDATA_ARRAY_SELECTOR, keys, values);
|
|
105
156
|
result = ILSP6KeyManager(keyManagerAddress).execute(payload);
|
|
106
157
|
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* @dev combine multiple permissions into a single bytes32
|
|
161
|
+
* Make sure that the sum of the values of the input array is less than 2^256-1 to avoid overflow.
|
|
162
|
+
* @param _permissions the array of permissions to combine
|
|
163
|
+
* @return a bytes32 containing the combined permissions
|
|
164
|
+
*/
|
|
165
|
+
function combinePermissions(bytes32[] memory _permissions) internal pure returns (bytes32) {
|
|
166
|
+
uint256 result = 0;
|
|
167
|
+
for (uint256 i = 0; i < _permissions.length; i++) {
|
|
168
|
+
result += uint256(_permissions[i]);
|
|
169
|
+
}
|
|
170
|
+
return bytes32(result);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function generatePermissionsKeysForController(
|
|
174
|
+
IERC725Y _account,
|
|
175
|
+
address _address,
|
|
176
|
+
bytes32 permissions
|
|
177
|
+
) internal view returns (bytes32[] memory keys, bytes[] memory values) {
|
|
178
|
+
keys = new bytes32[](3);
|
|
179
|
+
values = new bytes[](3);
|
|
180
|
+
|
|
181
|
+
uint256 arrayLength = uint256(bytes32(_account.getData(_LSP6KEY_ADDRESSPERMISSIONS_ARRAY)));
|
|
182
|
+
uint256 newArrayLength = arrayLength + 1;
|
|
183
|
+
|
|
184
|
+
keys[0] = _LSP6KEY_ADDRESSPERMISSIONS_ARRAY;
|
|
185
|
+
values[0] = abi.encodePacked(newArrayLength);
|
|
186
|
+
|
|
187
|
+
keys[1] = LSP2Utils.generateArrayElementKeyAtIndex(
|
|
188
|
+
_LSP6KEY_ADDRESSPERMISSIONS_ARRAY,
|
|
189
|
+
uint128(arrayLength)
|
|
190
|
+
);
|
|
191
|
+
values[1] = abi.encodePacked(_address);
|
|
192
|
+
|
|
193
|
+
keys[2] = LSP2Utils.generateMappingWithGroupingKey(
|
|
194
|
+
_LSP6KEY_ADDRESSPERMISSIONS_PERMISSIONS_PREFIX,
|
|
195
|
+
bytes20(_address)
|
|
196
|
+
);
|
|
197
|
+
values[2] = abi.encodePacked(permissions);
|
|
198
|
+
}
|
|
107
199
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
|
|
3
|
-
pragma solidity ^0.8.
|
|
3
|
+
pragma solidity ^0.8.4;
|
|
4
4
|
|
|
5
5
|
// interfaces
|
|
6
6
|
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
|
|
7
7
|
import {IERC725Y} from "@erc725/smart-contracts/contracts/interfaces/IERC725Y.sol";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* @
|
|
10
|
+
* @title interface of the LSP7 - Digital Asset standard.
|
|
11
11
|
*/
|
|
12
12
|
interface ILSP7DigitalAsset is IERC165, IERC725Y {
|
|
13
13
|
// --- Events
|
|
@@ -18,7 +18,7 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
|
|
|
18
18
|
* @param from The address which tokens are sent
|
|
19
19
|
* @param to The receiving address
|
|
20
20
|
* @param amount The amount of tokens transferred
|
|
21
|
-
* @param
|
|
21
|
+
* @param allowNonLSP1Recipient When set to TRUE, `to` may be any address but
|
|
22
22
|
* when set to FALSE `to` must be a contract that supports LSP1 UniversalReceiver
|
|
23
23
|
* @param data Additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses
|
|
24
24
|
*/
|
|
@@ -27,7 +27,7 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
|
|
|
27
27
|
address indexed from,
|
|
28
28
|
address indexed to,
|
|
29
29
|
uint256 amount,
|
|
30
|
-
bool
|
|
30
|
+
bool allowNonLSP1Recipient,
|
|
31
31
|
bytes data
|
|
32
32
|
);
|
|
33
33
|
|
|
@@ -60,7 +60,7 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
|
|
|
60
60
|
* no way affects any of the arithmetic of the contract, including
|
|
61
61
|
* {balanceOf} and {transfer}.
|
|
62
62
|
*/
|
|
63
|
-
function decimals() external view returns (
|
|
63
|
+
function decimals() external view returns (uint8);
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
66
|
* @dev Returns the number of existing tokens.
|
|
@@ -84,7 +84,17 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
|
|
|
84
84
|
* @param amount The amount of tokens operator has access to.
|
|
85
85
|
* @dev Sets `amount` as the amount of tokens `operator` address has access to from callers tokens.
|
|
86
86
|
*
|
|
87
|
-
*
|
|
87
|
+
* To avoid front-running and Allowance Double-Spend Exploit when
|
|
88
|
+
* increasing or decreasing the authorized amount of an operator,
|
|
89
|
+
* it is advised to:
|
|
90
|
+
* 1. call {revokeOperator} first, and
|
|
91
|
+
* 2. then re-call {authorizeOperator} with the new amount
|
|
92
|
+
*
|
|
93
|
+
* for more information, see:
|
|
94
|
+
* https://docs.google.com/document/d/1YLPtQxZu1UAvO9cZ1O2RPXBbT0mooh4DYKjA_jp-RLM/
|
|
95
|
+
*
|
|
96
|
+
*
|
|
97
|
+
* See {authorizedAmountFor}.
|
|
88
98
|
*
|
|
89
99
|
* Requirements
|
|
90
100
|
*
|
|
@@ -98,7 +108,7 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
|
|
|
98
108
|
* @param operator The address to revoke as an operator.
|
|
99
109
|
* @dev Removes `operator` address as an operator of callers tokens.
|
|
100
110
|
*
|
|
101
|
-
* See {
|
|
111
|
+
* See {authorizedAmountFor}.
|
|
102
112
|
*
|
|
103
113
|
* Requirements
|
|
104
114
|
*
|
|
@@ -116,7 +126,10 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
|
|
|
116
126
|
* Operators can send and burn tokens on behalf of their owners. The tokenOwner is their own
|
|
117
127
|
* operator.
|
|
118
128
|
*/
|
|
119
|
-
function
|
|
129
|
+
function authorizedAmountFor(address operator, address tokenOwner)
|
|
130
|
+
external
|
|
131
|
+
view
|
|
132
|
+
returns (uint256);
|
|
120
133
|
|
|
121
134
|
// --- Transfer functionality
|
|
122
135
|
|
|
@@ -124,11 +137,11 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
|
|
|
124
137
|
* @param from The sending address.
|
|
125
138
|
* @param to The receiving address.
|
|
126
139
|
* @param amount The amount of tokens to transfer.
|
|
127
|
-
* @param
|
|
140
|
+
* @param allowNonLSP1Recipient When set to TRUE, to may be any address but
|
|
128
141
|
* when set to FALSE to must be a contract that supports LSP1 UniversalReceiver
|
|
129
142
|
* @param data Additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses.
|
|
130
143
|
*
|
|
131
|
-
* @dev Transfers `amount` of tokens from `from` to `to`. The `
|
|
144
|
+
* @dev Transfers `amount` of tokens from `from` to `to`. The `allowNonLSP1Recipient` parameter will be used
|
|
132
145
|
* when notifying the token sender and receiver.
|
|
133
146
|
*
|
|
134
147
|
* Requirements:
|
|
@@ -145,7 +158,7 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
|
|
|
145
158
|
address from,
|
|
146
159
|
address to,
|
|
147
160
|
uint256 amount,
|
|
148
|
-
bool
|
|
161
|
+
bool allowNonLSP1Recipient,
|
|
149
162
|
bytes memory data
|
|
150
163
|
) external;
|
|
151
164
|
|
|
@@ -153,7 +166,7 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
|
|
|
153
166
|
* @param from The list of sending addresses.
|
|
154
167
|
* @param to The list of receiving addresses.
|
|
155
168
|
* @param amount The amount of tokens to transfer.
|
|
156
|
-
* @param
|
|
169
|
+
* @param allowNonLSP1Recipient When set to TRUE, to may be any address but
|
|
157
170
|
* when set to FALSE to must be a contract that supports LSP1 UniversalReceiver
|
|
158
171
|
* @param data Additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses.
|
|
159
172
|
*
|
|
@@ -175,7 +188,7 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
|
|
|
175
188
|
address[] memory from,
|
|
176
189
|
address[] memory to,
|
|
177
190
|
uint256[] memory amount,
|
|
178
|
-
bool
|
|
191
|
+
bool[] memory allowNonLSP1Recipient,
|
|
179
192
|
bytes[] memory data
|
|
180
193
|
) external;
|
|
181
194
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// SPDX-License-Identifier: CC0-1.0
|
|
2
|
-
pragma solidity ^0.8.
|
|
2
|
+
pragma solidity ^0.8.4;
|
|
3
3
|
|
|
4
4
|
// --- ERC165 interface ids
|
|
5
|
-
bytes4 constant _INTERFACEID_LSP7 =
|
|
5
|
+
bytes4 constant _INTERFACEID_LSP7 = 0xda1f85e4;
|
|
6
6
|
|
|
7
7
|
// --- Token Hooks
|
|
8
8
|
|
|
9
|
-
// keccak256('
|
|
10
|
-
bytes32 constant _TYPEID_LSP7_TOKENSSENDER =
|
|
9
|
+
// keccak256('LSP7Tokens_SenderNotification')
|
|
10
|
+
bytes32 constant _TYPEID_LSP7_TOKENSSENDER = 0x429ac7a06903dbc9c13dfcb3c9d11df8194581fa047c96d7a4171fc7402958ea;
|
|
11
11
|
|
|
12
|
-
// keccak256('
|
|
13
|
-
bytes32 constant _TYPEID_LSP7_TOKENSRECIPIENT =
|
|
12
|
+
// keccak256('LSP7Tokens_RecipientNotification')
|
|
13
|
+
bytes32 constant _TYPEID_LSP7_TOKENSRECIPIENT = 0x20804611b3e2ea21c480dc465142210acf4a2485947541770ec1fb87dee4a55c;
|
|
@@ -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
|
// interfaces
|
|
5
5
|
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
|
|
@@ -21,21 +21,21 @@ import {_INTERFACEID_LSP7} from "./LSP7Constants.sol";
|
|
|
21
21
|
* A supply mechanism has to be added in a derived contract using {_mint}
|
|
22
22
|
* For a generic mechanism, see {LSP7Mintable}.
|
|
23
23
|
*/
|
|
24
|
-
contract LSP7DigitalAsset is LSP4DigitalAssetMetadata, LSP7DigitalAssetCore {
|
|
24
|
+
abstract contract LSP7DigitalAsset is LSP4DigitalAssetMetadata, LSP7DigitalAssetCore {
|
|
25
25
|
/**
|
|
26
26
|
* @notice Sets the token-Metadata
|
|
27
27
|
* @param name_ The name of the token
|
|
28
28
|
* @param symbol_ The symbol of the token
|
|
29
29
|
* @param newOwner_ The owner of the the token-Metadata
|
|
30
|
-
* @param
|
|
30
|
+
* @param isNonDivisible_ Specify if the LSP7 token is a fungible or non-fungible token
|
|
31
31
|
*/
|
|
32
32
|
constructor(
|
|
33
33
|
string memory name_,
|
|
34
34
|
string memory symbol_,
|
|
35
35
|
address newOwner_,
|
|
36
|
-
bool
|
|
36
|
+
bool isNonDivisible_
|
|
37
37
|
) LSP4DigitalAssetMetadata(name_, symbol_, newOwner_) {
|
|
38
|
-
|
|
38
|
+
_isNonDivisible = isNonDivisible_;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
/**
|