@lukso/lsp-smart-contracts 0.5.0 → 0.6.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 +29 -9
- package/artifacts/LSP0ERC725Account.json +392 -0
- package/artifacts/LSP0ERC725AccountInit.json +433 -0
- package/artifacts/LSP1UniversalReceiverDelegateUP.json +2 -7
- package/artifacts/LSP1UniversalReceiverDelegateVault.json +2 -7
- package/artifacts/LSP4Compatibility.json +195 -0
- package/artifacts/LSP4DigitalAssetMetadata.json +169 -0
- package/artifacts/LSP4DigitalAssetMetadataInit.json +231 -0
- package/artifacts/LSP6KeyManager.json +34 -28
- package/artifacts/LSP6KeyManagerInit.json +42 -23
- package/artifacts/LSP7CappedSupply.json +133 -8
- package/artifacts/LSP7CappedSupplyInit.json +160 -32
- package/artifacts/LSP7CompatibilityForERC20.json +125 -10
- package/artifacts/LSP7CompatibilityForERC20Init.json +727 -0
- package/artifacts/LSP7DigitalAsset.json +125 -10
- package/artifacts/LSP7DigitalAssetInit.json +149 -31
- package/artifacts/LSP7Mintable.json +126 -11
- package/artifacts/LSP7MintableInit.json +150 -32
- package/artifacts/LSP8CappedSupply.json +134 -8
- package/artifacts/LSP8CappedSupplyInit.json +169 -17
- package/artifacts/LSP8CompatibilityForERC721.json +126 -10
- package/artifacts/LSP8CompatibilityForERC721Init.json +873 -0
- package/artifacts/LSP8IdentifiableDigitalAsset.json +126 -10
- package/artifacts/LSP8IdentifiableDigitalAssetInit.json +158 -16
- package/artifacts/LSP8Mintable.json +138 -11
- package/artifacts/LSP8MintableInit.json +170 -17
- package/artifacts/LSP9Vault.json +368 -0
- package/artifacts/LSP9VaultInit.json +409 -0
- package/artifacts/UniversalFactory.json +127 -0
- package/artifacts/UniversalProfile.json +65 -14
- package/artifacts/UniversalProfileInit.json +104 -14
- package/artifacts/UniversalReceiverAddressStore.json +204 -0
- package/constants.js +352 -0
- package/contracts/Custom/ClaimOwnership.sol +31 -0
- package/contracts/Custom/ERC165Checker.sol +130 -0
- package/contracts/Custom/IClaimOwnership.sol +10 -0
- package/contracts/Factories/UniversalFactory.sol +155 -0
- package/contracts/LSP0ERC725Account/LSP0Constants.sol +5 -9
- package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +6 -8
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +89 -46
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +5 -5
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +6 -21
- package/contracts/LSP10ReceivedVaults/LSP10Constants.sol +10 -0
- package/contracts/LSP1UniversalReceiver/LSP1Constants.sol +2 -8
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/Handling/TokenAndVaultHandling.sol +59 -185
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +48 -6
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/Handling/TokenHandling.sol +45 -92
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +39 -6
- package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +47 -0
- package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +205 -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 +11 -8
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInit.sol +9 -13
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +14 -20
- package/contracts/LSP5ReceivedAssets/LSP5Constants.sol +10 -0
- package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +157 -0
- package/contracts/LSP6KeyManager/ILSP6KeyManager.sol +21 -18
- package/contracts/LSP6KeyManager/LSP6Constants.sol +61 -25
- package/contracts/LSP6KeyManager/LSP6Errors.sol +37 -0
- package/contracts/LSP6KeyManager/LSP6KeyManager.sol +3 -4
- package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +429 -332
- package/contracts/LSP6KeyManager/LSP6KeyManagerInit.sol +6 -5
- package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +7 -15
- package/contracts/LSP6KeyManager/LSP6Utils.sol +111 -0
- package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +3 -8
- package/contracts/LSP7DigitalAsset/LSP7Constants.sol +5 -4
- package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +23 -9
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +70 -94
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInit.sol +8 -9
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +25 -23
- package/contracts/LSP7DigitalAsset/LSP7Errors.sol +23 -0
- package/contracts/LSP7DigitalAsset/extensions/ILSP7CappedSupply.sol +1 -1
- package/contracts/LSP7DigitalAsset/extensions/ILSP7CompatibilityForERC20.sol +2 -4
- 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 +9 -17
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibilityForERC20.sol +33 -21
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibilityForERC20Core.sol +20 -39
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibilityForERC20Init.sol +3 -3
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibilityForERC20InitAbstract.sol +39 -28
- package/contracts/LSP7DigitalAsset/{extensions → presets}/ILSP7Mintable.sol +1 -1
- 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 +3 -2
- 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 +102 -135
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInit.sol +8 -11
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +24 -21
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CappedSupply.sol +1 -1
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CompatibilityForERC721.sol +3 -11
- 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 +11 -20
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibilityForERC721.sol +41 -33
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibilityForERC721Core.sol +27 -84
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibilityForERC721Init.sol +4 -6
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibilityForERC721InitAbstract.sol +40 -41
- package/contracts/LSP8IdentifiableDigitalAsset/{extensions → presets}/ILSP8Mintable.sol +1 -1
- 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 +4 -3
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +35 -0
- package/contracts/LSP9Vault/LSP9Constants.sol +13 -4
- package/contracts/LSP9Vault/LSP9Vault.sol +15 -37
- package/contracts/LSP9Vault/LSP9VaultCore.sol +101 -82
- package/contracts/LSP9Vault/LSP9VaultInit.sol +5 -4
- package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +15 -45
- package/contracts/Legacy/Registries/AddressRegistry.sol +43 -0
- package/contracts/Legacy/Registries/AddressRegistryRequiresERC725.sol +33 -0
- package/contracts/Legacy/UniversalReceiverAddressStore.sol +59 -0
- package/contracts/UniversalProfile.sol +10 -5
- package/contracts/UniversalProfileInit.sol +5 -4
- package/contracts/UniversalProfileInitAbstract.sol +14 -20
- package/contracts/Utils/UtilsLib.sol +47 -11
- package/package.json +23 -9
- package/artifacts/LSP1UniversalReceiverDelegateUPInit.json +0 -66
- package/artifacts/LSP1UniversalReceiverDelegateVaultInit.json +0 -66
- 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/LSP7MintableInitAbstract.sol +0 -47
- 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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
pragma solidity ^0.8.0;
|
|
3
3
|
|
|
4
4
|
// modules
|
|
5
|
-
import "@erc725/smart-contracts/contracts/ERC725YInitAbstract.sol";
|
|
5
|
+
import {ERC725YInitAbstract, ERC725YCore} from "@erc725/smart-contracts/contracts/ERC725YInitAbstract.sol";
|
|
6
6
|
|
|
7
7
|
// constants
|
|
8
8
|
import "./LSP4Constants.sol";
|
|
@@ -12,30 +12,24 @@ import "./LSP4Constants.sol";
|
|
|
12
12
|
* @author Matthew Stevens
|
|
13
13
|
* @dev Inheritable Proxy Implementation of a LSP8 compliant contract.
|
|
14
14
|
*/
|
|
15
|
-
abstract contract LSP4DigitalAssetMetadataInitAbstract is
|
|
16
|
-
|
|
17
|
-
ERC725YInitAbstract
|
|
18
|
-
{
|
|
19
|
-
/**
|
|
20
|
-
* @notice Sets the name, symbol of the token and the owner, and sets the SupportedStandards:LSP4DigitalAsset key
|
|
21
|
-
* @param name_ The name of the token
|
|
22
|
-
* @param symbol_ The symbol of the token
|
|
23
|
-
* @param newOwner_ The owner of the token contract
|
|
24
|
-
*/
|
|
25
|
-
function initialize(
|
|
15
|
+
abstract contract LSP4DigitalAssetMetadataInitAbstract is ERC725YInitAbstract {
|
|
16
|
+
function _initialize(
|
|
26
17
|
string memory name_,
|
|
27
18
|
string memory symbol_,
|
|
28
19
|
address newOwner_
|
|
29
|
-
)
|
|
30
|
-
ERC725YInitAbstract.
|
|
20
|
+
) internal virtual onlyInitializing {
|
|
21
|
+
ERC725YInitAbstract._initialize(newOwner_);
|
|
31
22
|
|
|
32
23
|
// set SupportedStandards:LSP4DigitalAsset
|
|
33
|
-
_setData(
|
|
34
|
-
_LSP4_SUPPORTED_STANDARDS_KEY,
|
|
35
|
-
_LSP4_SUPPORTED_STANDARDS_VALUE
|
|
36
|
-
);
|
|
24
|
+
super._setData(_LSP4_SUPPORTED_STANDARDS_KEY, _LSP4_SUPPORTED_STANDARDS_VALUE);
|
|
37
25
|
|
|
38
|
-
_setData(
|
|
39
|
-
_setData(
|
|
26
|
+
super._setData(_LSP4_TOKEN_NAME_KEY, bytes(name_));
|
|
27
|
+
super._setData(_LSP4_TOKEN_SYMBOL_KEY, bytes(symbol_));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function _setData(bytes32 key, bytes memory value) internal virtual override {
|
|
31
|
+
require(key != _LSP4_TOKEN_NAME_KEY, "LSP4: cannot edit Token Name after deployment");
|
|
32
|
+
require(key != _LSP4_TOKEN_SYMBOL_KEY, "LSP4: cannot edit Token Symbol after deployment");
|
|
33
|
+
super._setData(key, value);
|
|
40
34
|
}
|
|
41
35
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
// --- ERC725Y Keys
|
|
5
|
+
|
|
6
|
+
// keccak256('LSP5ReceivedAssets[]')
|
|
7
|
+
bytes32 constant _LSP5_RECEIVED_ASSETS_ARRAY_KEY = 0x6460ee3c0aac563ccbf76d6e1d07bada78e3a9514e6382b736ed3f478ab7b90b;
|
|
8
|
+
|
|
9
|
+
// bytes10(keccak256('LSP5ReceivedAssetsMap')) + bytes2(0)
|
|
10
|
+
bytes12 constant _LSP5_RECEIVED_ASSETS_MAP_KEY_PREFIX = 0x812c4334633eb816c80d0000;
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
// interfaces
|
|
5
|
+
import {IERC725Y} from "@erc725/smart-contracts/contracts/interfaces/IERC725Y.sol";
|
|
6
|
+
|
|
7
|
+
// libraries
|
|
8
|
+
import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol";
|
|
9
|
+
import {LSP2Utils} from "../LSP2ERC725YJSONSchema/LSP2Utils.sol";
|
|
10
|
+
import {LSP6Utils} from "../LSP6KeyManager/LSP6Utils.sol";
|
|
11
|
+
import {UtilsLib} from "../Utils/UtilsLib.sol";
|
|
12
|
+
|
|
13
|
+
// constants
|
|
14
|
+
import {_TYPEID_LSP7_TOKENSSENDER} from "../LSP7DigitalAsset/LSP7Constants.sol";
|
|
15
|
+
|
|
16
|
+
library LSP5Utils {
|
|
17
|
+
/**
|
|
18
|
+
* @dev Initiates Map and ArrayKey and sets the length of the Array to `1` if it's not set before,
|
|
19
|
+
* If it's already set, it decodes the arrayLength, increment it and adds Map and ArrayKey
|
|
20
|
+
*/
|
|
21
|
+
function addMapAndArrayKey(
|
|
22
|
+
IERC725Y _account,
|
|
23
|
+
bytes32 _arrayKey,
|
|
24
|
+
bytes32 _mapKey,
|
|
25
|
+
address _sender,
|
|
26
|
+
bytes4 _appendix
|
|
27
|
+
) internal view returns (bytes32[] memory keys, bytes[] memory values) {
|
|
28
|
+
keys = new bytes32[](3);
|
|
29
|
+
values = new bytes[](3);
|
|
30
|
+
|
|
31
|
+
bytes memory rawArrayLength = _account.getData(_arrayKey);
|
|
32
|
+
|
|
33
|
+
keys[0] = _arrayKey;
|
|
34
|
+
keys[2] = _mapKey;
|
|
35
|
+
|
|
36
|
+
values[1] = UtilsLib.addressToBytes(_sender);
|
|
37
|
+
|
|
38
|
+
if (rawArrayLength.length != 32) {
|
|
39
|
+
keys[1] = LSP2Utils.generateArrayKeyAtIndex(_arrayKey, 0);
|
|
40
|
+
|
|
41
|
+
values[0] = UtilsLib.uint256ToBytes(1);
|
|
42
|
+
values[2] = bytes.concat(_appendix, bytes8(0));
|
|
43
|
+
} else if (rawArrayLength.length == 32) {
|
|
44
|
+
uint256 arrayLength = abi.decode(rawArrayLength, (uint256));
|
|
45
|
+
uint256 newArrayLength = arrayLength + 1;
|
|
46
|
+
|
|
47
|
+
keys[1] = LSP2Utils.generateArrayKeyAtIndex(_arrayKey, newArrayLength - 1);
|
|
48
|
+
|
|
49
|
+
values[0] = UtilsLib.uint256ToBytes(newArrayLength);
|
|
50
|
+
values[2] = bytes.concat(_appendix, bytes8(uint64(arrayLength)));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @dev Decrements the arrayLength, removes the Map, swaps the arrayKey that need to be removed with
|
|
56
|
+
* the last `arrayKey` in the array and removes the last arrayKey with updating all modified entries
|
|
57
|
+
*/
|
|
58
|
+
function removeMapAndArrayKey(
|
|
59
|
+
IERC725Y _account,
|
|
60
|
+
bytes32 _arrayKey,
|
|
61
|
+
bytes12 mapPrefix,
|
|
62
|
+
bytes32 _mapKeyToRemove,
|
|
63
|
+
bytes memory mapValue
|
|
64
|
+
) internal view returns (bytes32[] memory keys, bytes[] memory values) {
|
|
65
|
+
uint64 index = extractIndexFromMap(mapValue);
|
|
66
|
+
bytes32 arrayKeyToRemove = LSP2Utils.generateArrayKeyAtIndex(_arrayKey, index);
|
|
67
|
+
|
|
68
|
+
bytes memory rawArrayLength = _account.getData(_arrayKey);
|
|
69
|
+
|
|
70
|
+
uint256 arrayLength = abi.decode(rawArrayLength, (uint256));
|
|
71
|
+
|
|
72
|
+
uint256 newLength = arrayLength - 1;
|
|
73
|
+
|
|
74
|
+
if (index == (arrayLength - 1)) {
|
|
75
|
+
keys = new bytes32[](3);
|
|
76
|
+
values = new bytes[](3);
|
|
77
|
+
|
|
78
|
+
keys[0] = _arrayKey;
|
|
79
|
+
values[0] = UtilsLib.uint256ToBytes(newLength);
|
|
80
|
+
|
|
81
|
+
keys[1] = _mapKeyToRemove;
|
|
82
|
+
values[1] = "";
|
|
83
|
+
|
|
84
|
+
keys[2] = arrayKeyToRemove;
|
|
85
|
+
values[2] = "";
|
|
86
|
+
} else {
|
|
87
|
+
keys = new bytes32[](5);
|
|
88
|
+
values = new bytes[](5);
|
|
89
|
+
|
|
90
|
+
keys[0] = _arrayKey;
|
|
91
|
+
values[0] = UtilsLib.uint256ToBytes(newLength);
|
|
92
|
+
|
|
93
|
+
keys[1] = _mapKeyToRemove;
|
|
94
|
+
values[1] = "";
|
|
95
|
+
|
|
96
|
+
bytes32 lastKey = LSP2Utils.generateArrayKeyAtIndex(_arrayKey, newLength);
|
|
97
|
+
|
|
98
|
+
bytes memory lastKeyValue = _account.getData(lastKey);
|
|
99
|
+
|
|
100
|
+
bytes32 mapOfLastkey = LSP2Utils.generateMappingKey(mapPrefix, bytes20(lastKeyValue));
|
|
101
|
+
|
|
102
|
+
bytes memory mapValueOfLastkey = _account.getData(mapOfLastkey);
|
|
103
|
+
|
|
104
|
+
bytes memory appendix = BytesLib.slice(mapValueOfLastkey, 0, 4);
|
|
105
|
+
|
|
106
|
+
keys[2] = arrayKeyToRemove;
|
|
107
|
+
values[2] = lastKeyValue;
|
|
108
|
+
|
|
109
|
+
keys[3] = lastKey;
|
|
110
|
+
values[3] = "";
|
|
111
|
+
|
|
112
|
+
keys[4] = mapOfLastkey;
|
|
113
|
+
values[4] = bytes.concat(appendix, bytes8(index));
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function addMapAndArrayKeyViaKeyManager(
|
|
118
|
+
IERC725Y _account,
|
|
119
|
+
bytes32 _arrayKey,
|
|
120
|
+
bytes32 _mapKey,
|
|
121
|
+
address _sender,
|
|
122
|
+
bytes4 _appendix,
|
|
123
|
+
address _keyManager
|
|
124
|
+
) internal returns (bytes memory result) {
|
|
125
|
+
(bytes32[] memory _keys, bytes[] memory _values) = addMapAndArrayKey(
|
|
126
|
+
_account,
|
|
127
|
+
_arrayKey,
|
|
128
|
+
_mapKey,
|
|
129
|
+
_sender,
|
|
130
|
+
_appendix
|
|
131
|
+
);
|
|
132
|
+
result = LSP6Utils.setDataViaKeyManager(_keyManager, _keys, _values);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function removeMapAndArrayKeyViaKeyManager(
|
|
136
|
+
IERC725Y _account,
|
|
137
|
+
bytes32 _arrayKey,
|
|
138
|
+
bytes12 mapPrefix,
|
|
139
|
+
bytes32 _mapKeyToRemove,
|
|
140
|
+
bytes memory mapValue,
|
|
141
|
+
address keyManager
|
|
142
|
+
) internal returns (bytes memory result) {
|
|
143
|
+
(bytes32[] memory _keys, bytes[] memory _values) = removeMapAndArrayKey(
|
|
144
|
+
_account,
|
|
145
|
+
_arrayKey,
|
|
146
|
+
mapPrefix,
|
|
147
|
+
_mapKeyToRemove,
|
|
148
|
+
mapValue
|
|
149
|
+
);
|
|
150
|
+
result = LSP6Utils.setDataViaKeyManager(keyManager, _keys, _values);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function extractIndexFromMap(bytes memory mapValue) internal pure returns (uint64) {
|
|
154
|
+
bytes memory val = BytesLib.slice(mapValue, 4, 8);
|
|
155
|
+
return BytesLib.toUint64(val, 0);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
pragma solidity ^0.8.0;
|
|
3
3
|
|
|
4
4
|
// interfaces
|
|
5
|
-
import "@openzeppelin/contracts/interfaces/IERC1271.sol";
|
|
5
|
+
import {IERC1271} from "@openzeppelin/contracts/interfaces/IERC1271.sol";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @dev Contract acting as a controller of an ERC725 Account, using permissions stored in the ERC725Y storage
|
|
@@ -11,7 +11,18 @@ interface ILSP6KeyManager is
|
|
|
11
11
|
IERC1271
|
|
12
12
|
/* is ERC165 */
|
|
13
13
|
{
|
|
14
|
-
event Executed(uint256 indexed _value,
|
|
14
|
+
event Executed(uint256 indexed _value, bytes4 _selector);
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @notice returns the address of the account linked to this KeyManager
|
|
18
|
+
* @dev this can be a contract that implements
|
|
19
|
+
* - ERC725X only
|
|
20
|
+
* - ERC725Y only
|
|
21
|
+
* - any ERC725 based contract (so implementing both ERC725X and ERC725Y)
|
|
22
|
+
*
|
|
23
|
+
* @return the address of the linked account
|
|
24
|
+
*/
|
|
25
|
+
function target() external view returns (address);
|
|
15
26
|
|
|
16
27
|
/**
|
|
17
28
|
* @notice get latest nonce for `_from` for channel ID: `_channel`
|
|
@@ -19,34 +30,26 @@ interface ILSP6KeyManager is
|
|
|
19
30
|
* @param _address caller address
|
|
20
31
|
* @param _channel channel id
|
|
21
32
|
*/
|
|
22
|
-
function getNonce(address _address, uint256 _channel)
|
|
23
|
-
external
|
|
24
|
-
view
|
|
25
|
-
returns (uint256);
|
|
33
|
+
function getNonce(address _address, uint256 _channel) external view returns (uint256);
|
|
26
34
|
|
|
27
35
|
/**
|
|
28
|
-
* @notice execute the following payload on the ERC725Account: `
|
|
36
|
+
* @notice execute the following payload on the ERC725Account: `_calldata`
|
|
29
37
|
* @dev the ERC725Account will return some data on successful call, or revert on failure
|
|
30
|
-
* @param
|
|
38
|
+
* @param _calldata the payload to execute. Obtained in web3 via encodeABI()
|
|
31
39
|
* @return result_ the data being returned by the ERC725 Account
|
|
32
40
|
*/
|
|
33
|
-
function execute(bytes calldata
|
|
34
|
-
external
|
|
35
|
-
payable
|
|
36
|
-
returns (bytes memory);
|
|
41
|
+
function execute(bytes calldata _calldata) external payable returns (bytes memory);
|
|
37
42
|
|
|
38
43
|
/**
|
|
39
44
|
* @dev allows anybody to execute given they have a signed message from an executor
|
|
40
|
-
* @param _signedFor this KeyManager
|
|
41
|
-
* @param _nonce the address' nonce (in a specific `_channel`), obtained via `getNonce(...)`. Used to prevent replay attack
|
|
42
|
-
* @param _data obtained via encodeABI() in web3
|
|
43
45
|
* @param _signature bytes32 ethereum signature
|
|
46
|
+
* @param _nonce the address' nonce (in a specific `_channel`), obtained via `getNonce(...)`. Used to prevent replay attack
|
|
47
|
+
* @param _calldata obtained via encodeABI() in web3
|
|
44
48
|
* @return result_ the data being returned by the ERC725 Account
|
|
45
49
|
*/
|
|
46
50
|
function executeRelayCall(
|
|
47
|
-
|
|
51
|
+
bytes memory _signature,
|
|
48
52
|
uint256 _nonce,
|
|
49
|
-
bytes calldata
|
|
50
|
-
bytes memory _signature
|
|
53
|
+
bytes calldata _calldata
|
|
51
54
|
) external payable returns (bytes memory);
|
|
52
55
|
}
|
|
@@ -2,28 +2,64 @@
|
|
|
2
2
|
pragma solidity ^0.8.0;
|
|
3
3
|
|
|
4
4
|
// --- ERC165 interface ids
|
|
5
|
-
bytes4 constant _INTERFACEID_LSP6 =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
//
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
5
|
+
bytes4 constant _INTERFACEID_LSP6 = 0xc403d48f;
|
|
6
|
+
|
|
7
|
+
// --- ERC725Y Keys
|
|
8
|
+
|
|
9
|
+
// PERMISSIONS KEYS
|
|
10
|
+
|
|
11
|
+
// keccak256('AddressPermissions[]')
|
|
12
|
+
bytes32 constant _LSP6KEY_ADDRESSPERMISSIONS_ARRAY = 0xdf30dba06db6a30e65354d9a64c609861f089545ca58c6b4dbe31a5f338cb0e3;
|
|
13
|
+
|
|
14
|
+
// AddressPermissions[index]
|
|
15
|
+
bytes16 constant _LSP6KEY_ADDRESSPERMISSIONS_ARRAY_PREFIX = 0xdf30dba06db6a30e65354d9a64c60986;
|
|
16
|
+
|
|
17
|
+
// AddressPermissions:...
|
|
18
|
+
bytes6 constant _LSP6KEY_ADDRESSPERMISSIONS_PREFIX = 0x4b80742de2bf;
|
|
19
|
+
|
|
20
|
+
// bytes6(keccak256('AddressPermissions')) + bytes4(keccak256('Permissions')) + bytes2(0)
|
|
21
|
+
bytes12 constant _LSP6KEY_ADDRESSPERMISSIONS_PERMISSIONS_PREFIX = 0x4b80742de2bf82acb3630000; // AddressPermissions:Permissions:<address> --> bytes32
|
|
22
|
+
|
|
23
|
+
// bytes6(keccak256('AddressPermissions')) + bytes4(keccak256('AllowedAddresses')) + bytes2(0)
|
|
24
|
+
bytes12 constant _LSP6KEY_ADDRESSPERMISSIONS_ALLOWEDADDRESSES_PREFIX = 0x4b80742de2bfc6dd6b3c0000; // AddressPermissions:AllowedAddresses:<address> --> address[]
|
|
25
|
+
|
|
26
|
+
// bytes6(keccak256('AddressPermissions')) + bytes4(keccak256('AllowedFunctions')) + bytes2(0)
|
|
27
|
+
bytes12 constant _LSP6KEY_ADDRESSPERMISSIONS_ALLOWEDFUNCTIONS_PREFIX = 0x4b80742de2bf8efea1e80000; // AddressPermissions:AllowedFunctions:<address> --> bytes4[]
|
|
28
|
+
|
|
29
|
+
// bytes6(keccak256('AddressPermissions')) + bytes4(keccak256('AllowedStandards')) + bytes2(0)
|
|
30
|
+
bytes12 constant _LSP6KEY_ADDRESSPERMISSIONS_ALLOWEDSTANDARDS_PREFIX = 0x4b80742de2bf3efa94a30000; // AddressPermissions:AllowedStandards:<address> --> bytes4[]
|
|
31
|
+
|
|
32
|
+
// bytes6(keccak256('AddressPermissions')) + bytes4(keccak256('AllowedERC725YKeys')) + bytes2(0)
|
|
33
|
+
bytes12 constant _LSP6KEY_ADDRESSPERMISSIONS_ALLOWEDERC725YKEYS_PREFIX = 0x4b80742de2bf90b8b4850000; // AddressPermissions:AllowedERC725YKeys:<address> --> bytes32[]
|
|
34
|
+
|
|
35
|
+
// DEFAULT PERMISSIONS VALUES
|
|
36
|
+
bytes32 constant _PERMISSION_CHANGEOWNER = 0x0000000000000000000000000000000000000000000000000000000000000001;
|
|
37
|
+
bytes32 constant _PERMISSION_CHANGEPERMISSIONS = 0x0000000000000000000000000000000000000000000000000000000000000002;
|
|
38
|
+
bytes32 constant _PERMISSION_ADDPERMISSIONS = 0x0000000000000000000000000000000000000000000000000000000000000004;
|
|
39
|
+
bytes32 constant _PERMISSION_SETDATA = 0x0000000000000000000000000000000000000000000000000000000000000008;
|
|
40
|
+
bytes32 constant _PERMISSION_CALL = 0x0000000000000000000000000000000000000000000000000000000000000010;
|
|
41
|
+
bytes32 constant _PERMISSION_STATICCALL = 0x0000000000000000000000000000000000000000000000000000000000000020;
|
|
42
|
+
bytes32 constant _PERMISSION_DELEGATECALL = 0x0000000000000000000000000000000000000000000000000000000000000040;
|
|
43
|
+
bytes32 constant _PERMISSION_DEPLOY = 0x0000000000000000000000000000000000000000000000000000000000000080;
|
|
44
|
+
bytes32 constant _PERMISSION_TRANSFERVALUE = 0x0000000000000000000000000000000000000000000000000000000000000100;
|
|
45
|
+
bytes32 constant _PERMISSION_SIGN = 0x0000000000000000000000000000000000000000000000000000000000000200;
|
|
46
|
+
|
|
47
|
+
// SUPER PERMISSIONS
|
|
48
|
+
// -----
|
|
49
|
+
// allow to not check for AddressPermissions:AllowedERC725YKeys:...
|
|
50
|
+
bytes32 constant _PERMISSION_SUPER_SETDATA = 0x0000000000000000000000000000000000000000000000000000000000000400;
|
|
51
|
+
|
|
52
|
+
// allow to not check for:
|
|
53
|
+
// - AddressPermissions:AllowedAddress:...
|
|
54
|
+
// - AddressPermissions:AllowedStandards:...
|
|
55
|
+
// - AddressPermissions:AllowedFunctions:...
|
|
56
|
+
bytes32 constant _PERMISSION_SUPER_TRANSFERVALUE = 0x0000000000000000000000000000000000000000000000000000000000000800;
|
|
57
|
+
bytes32 constant _PERMISSION_SUPER_CALL = 0x0000000000000000000000000000000000000000000000000000000000001000;
|
|
58
|
+
bytes32 constant _PERMISSION_SUPER_STATICCALL = 0x0000000000000000000000000000000000000000000000000000000000002000;
|
|
59
|
+
bytes32 constant _PERMISSION_SUPER_DELEGATECALL = 0x0000000000000000000000000000000000000000000000000000000000004000;
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
/// @dev see IERC725Y interface
|
|
63
|
+
/// https://github.com/ERC725Alliance/ERC725/blob/main/implementations/contracts/interfaces/IERC725Y.sol
|
|
64
|
+
bytes4 constant setDataSingleSelector = bytes4(keccak256("setData(bytes32,bytes)"));
|
|
65
|
+
bytes4 constant setDataMultipleSelector = bytes4(keccak256("setData(bytes32[],bytes[])"));
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @dev revert when address `from` does not have any permissions set
|
|
6
|
+
* on the account linked to this Key Manager
|
|
7
|
+
* @param from the address that does not have permissions
|
|
8
|
+
*/
|
|
9
|
+
error NoPermissionsSet(address from);
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @dev address `from` is not authorised to `permission`
|
|
13
|
+
* @param permission permission required
|
|
14
|
+
* @param from address not-authorised
|
|
15
|
+
*/
|
|
16
|
+
error NotAuthorised(address from, string permission);
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @dev address `from` is not authorised to interact with `disallowedAddress` via account
|
|
20
|
+
* @param from address making the request
|
|
21
|
+
* @param disallowedAddress address that `from` is not authorised to call
|
|
22
|
+
*/
|
|
23
|
+
error NotAllowedAddress(address from, address disallowedAddress);
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @dev address `from` is not authorised to run `disallowedFunction` via account
|
|
27
|
+
* @param from address making the request
|
|
28
|
+
* @param disallowedFunction bytes4 function selector that `from` is not authorised to run
|
|
29
|
+
*/
|
|
30
|
+
error NotAllowedFunction(address from, bytes4 disallowedFunction);
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @dev address `from` is not authorised to set the key `disallowedKey` on the account
|
|
34
|
+
* @param from address making the request
|
|
35
|
+
* @param disallowedKey a bytes32 key that `from` is not authorised to set on the ERC725Y storage
|
|
36
|
+
*/
|
|
37
|
+
error NotAllowedERC725YKey(address from, bytes32 disallowedKey);
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
pragma solidity ^0.8.6;
|
|
3
3
|
|
|
4
4
|
// modules
|
|
5
|
-
import "./LSP6KeyManagerCore.sol";
|
|
5
|
+
import {LSP6KeyManagerCore} from "./LSP6KeyManagerCore.sol";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @title Implementation of a contract acting as a controller of an ERC725 Account, using permissions stored in the ERC725Y storage
|
|
9
|
-
* @author Fabian Vogelsteller
|
|
9
|
+
* @author Fabian Vogelsteller <frozeman>, Jean Cavallera (CJ42), Yamen Merhi (YamenMerhi)
|
|
10
10
|
* @dev all the permissions can be set on the ERC725 Account using `setData(...)` with the keys constants below
|
|
11
11
|
*/
|
|
12
12
|
contract LSP6KeyManager is LSP6KeyManagerCore {
|
|
@@ -15,7 +15,6 @@ contract LSP6KeyManager is LSP6KeyManagerCore {
|
|
|
15
15
|
* @param _account The address of the ER725Account to control
|
|
16
16
|
*/
|
|
17
17
|
constructor(address _account) {
|
|
18
|
-
|
|
19
|
-
_registerInterface(_INTERFACEID_LSP6);
|
|
18
|
+
target = _account;
|
|
20
19
|
}
|
|
21
20
|
}
|