@lukso/lsp-smart-contracts 0.7.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +39 -0
- package/README.md +93 -40
- package/artifacts/Create2Factory.json +2 -2
- package/artifacts/LSP0ERC725Account.json +194 -15
- package/artifacts/LSP0ERC725AccountInit.json +194 -15
- package/artifacts/LSP11BasicSocialRecovery.json +493 -0
- package/artifacts/LSP11BasicSocialRecoveryInit.json +513 -0
- package/artifacts/LSP16UniversalFactory.json +236 -0
- package/artifacts/LSP1UniversalReceiverDelegateUP.json +134 -15
- package/artifacts/LSP1UniversalReceiverDelegateVault.json +80 -15
- package/artifacts/LSP4Compatibility.json +16 -0
- package/artifacts/LSP4DigitalAssetMetadata.json +16 -0
- package/artifacts/LSP4DigitalAssetMetadataInitAbstract.json +16 -0
- package/artifacts/LSP6KeyManager.json +177 -33
- package/artifacts/LSP6KeyManagerInit.json +177 -33
- package/artifacts/LSP7CappedSupply.json +26 -5
- package/artifacts/LSP7CappedSupplyInitAbstract.json +26 -5
- package/artifacts/LSP7CompatibleERC20.json +26 -5
- package/artifacts/LSP7CompatibleERC20InitAbstract.json +28 -7
- package/artifacts/LSP7CompatibleERC20Mintable.json +29 -8
- package/artifacts/LSP7CompatibleERC20MintableInit.json +29 -8
- package/artifacts/LSP7DigitalAsset.json +26 -5
- package/artifacts/LSP7DigitalAssetInitAbstract.json +26 -5
- package/artifacts/LSP7Mintable.json +29 -8
- package/artifacts/LSP7MintableInit.json +29 -8
- package/artifacts/LSP8CappedSupply.json +27 -6
- package/artifacts/LSP8CappedSupplyInitAbstract.json +27 -6
- package/artifacts/LSP8CompatibleERC721.json +28 -7
- package/artifacts/LSP8CompatibleERC721InitAbstract.json +30 -9
- package/artifacts/LSP8CompatibleERC721Mintable.json +31 -10
- package/artifacts/LSP8CompatibleERC721MintableInit.json +31 -10
- package/artifacts/LSP8IdentifiableDigitalAsset.json +27 -6
- package/artifacts/LSP8IdentifiableDigitalAssetInitAbstract.json +27 -6
- package/artifacts/LSP8Mintable.json +30 -9
- package/artifacts/LSP8MintableInit.json +30 -9
- package/artifacts/LSP9Vault.json +202 -17
- package/artifacts/LSP9VaultInit.json +202 -17
- package/artifacts/UniversalProfile.json +194 -15
- package/artifacts/UniversalProfileInit.json +194 -15
- package/artifacts/UniversalReceiverAddressStore.json +3 -3
- package/common/constants.d.ts +738 -0
- package/common/constants.js +785 -0
- package/contracts/Custom/EIP191Signer.sol +12 -0
- package/contracts/Factories/Create2Factory.sol +1 -3
- package/contracts/LSP0ERC725Account/LSP0Constants.sol +13 -2
- package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +2 -1
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +320 -63
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +2 -2
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +2 -1
- package/contracts/LSP0ERC725Account/LSP0Utils.sol +50 -0
- package/contracts/LSP10ReceivedVaults/LSP10Constants.sol +2 -2
- package/contracts/LSP10ReceivedVaults/LSP10Utils.sol +212 -0
- package/contracts/LSP11BasicSocialRecovery/ILSP11BasicSocialRecovery.sol +177 -0
- package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecovery.sol +23 -0
- package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryCore.sol +258 -0
- package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryInit.sol +26 -0
- package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryInitAbstract.sol +19 -0
- package/contracts/LSP11BasicSocialRecovery/LSP11Constants.sol +6 -0
- package/contracts/LSP11BasicSocialRecovery/LSP11Errors.sol +60 -0
- package/contracts/LSP14Ownable2Step/ILSP14Ownable2Step.sol +53 -0
- package/contracts/LSP14Ownable2Step/LSP14Constants.sol +15 -0
- package/contracts/LSP14Ownable2Step/LSP14Errors.sol +12 -0
- package/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol +212 -0
- package/contracts/LSP16UniversalFactory/LSP16UniversalFactory.sol +246 -0
- package/contracts/LSP17ContractExtension/LSP17Constants.sol +17 -0
- package/contracts/LSP17ContractExtension/LSP17Errors.sol +7 -0
- package/contracts/LSP17ContractExtension/LSP17Extendable.sol +104 -0
- package/contracts/LSP17ContractExtension/LSP17Extension.sol +45 -0
- package/contracts/LSP17ContractExtension/LSP17Utils.sol +20 -0
- package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiver.sol +5 -5
- package/contracts/LSP1UniversalReceiver/LSP1Constants.sol +5 -3
- package/contracts/LSP1UniversalReceiver/LSP1Errors.sol +21 -0
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +155 -37
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +64 -31
- package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +53 -40
- package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +45 -23
- package/contracts/LSP3UniversalProfile/LSP3Constants.sol +1 -1
- package/contracts/LSP4DigitalAssetMetadata/ILSP4Compatibility.sol +1 -1
- package/contracts/LSP4DigitalAssetMetadata/LSP4Compatibility.sol +1 -1
- package/contracts/LSP4DigitalAssetMetadata/LSP4Constants.sol +1 -1
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol +2 -2
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +2 -2
- package/contracts/LSP4DigitalAssetMetadata/LSP4Errors.sol +3 -3
- package/contracts/LSP5ReceivedAssets/LSP5Constants.sol +2 -2
- package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +102 -114
- package/contracts/LSP6KeyManager/ILSP6KeyManager.sol +25 -7
- package/contracts/LSP6KeyManager/LSP6Constants.sol +43 -38
- package/contracts/LSP6KeyManager/LSP6Errors.sol +90 -21
- package/contracts/LSP6KeyManager/LSP6KeyManager.sol +2 -1
- package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +224 -506
- package/contracts/LSP6KeyManager/LSP6KeyManagerInit.sol +1 -1
- package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +3 -2
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6ExecuteModule.sol +229 -0
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6OwnershipModule.sol +25 -0
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6SetDataModule.sol +606 -0
- package/contracts/LSP6KeyManager/LSP6Utils.sol +156 -35
- package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +8 -8
- package/contracts/LSP7DigitalAsset/LSP7Constants.sol +6 -6
- package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +1 -1
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +36 -36
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +1 -1
- package/contracts/LSP7DigitalAsset/LSP7Errors.sol +33 -1
- package/contracts/LSP7DigitalAsset/extensions/ILSP7CompatibleERC20.sol +1 -1
- package/contracts/LSP7DigitalAsset/extensions/LSP7Burnable.sol +24 -0
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupply.sol +28 -8
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInitAbstract.sol +28 -11
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.sol +87 -20
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20InitAbstract.sol +97 -19
- package/contracts/LSP7DigitalAsset/presets/ILSP7Mintable.sol +3 -3
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.sol +3 -4
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInit.sol +2 -2
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInitAbstract.sol +3 -3
- package/contracts/LSP7DigitalAsset/presets/LSP7Mintable.sol +3 -5
- package/contracts/LSP7DigitalAsset/presets/LSP7MintableInit.sol +2 -2
- package/contracts/LSP7DigitalAsset/presets/LSP7MintableInitAbstract.sol +3 -3
- package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +7 -7
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol +7 -7
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol +45 -2
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +2 -2
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +57 -60
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +1 -1
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CompatibleERC721.sol +5 -2
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Burnable.sol +20 -0
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.sol +27 -7
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInitAbstract.sol +27 -10
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +234 -30
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +238 -30
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.sol +32 -4
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableInitAbstract.sol +35 -8
- package/contracts/LSP8IdentifiableDigitalAsset/presets/ILSP8Mintable.sol +3 -3
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.sol +3 -4
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInit.sol +3 -3
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInitAbstract.sol +3 -3
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.sol +3 -4
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInit.sol +2 -2
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +3 -3
- package/contracts/LSP9Vault/LSP9Constants.sol +10 -10
- package/contracts/LSP9Vault/LSP9Errors.sol +8 -0
- package/contracts/LSP9Vault/LSP9Vault.sol +6 -4
- package/contracts/LSP9Vault/LSP9VaultCore.sol +350 -127
- package/contracts/LSP9Vault/LSP9VaultInit.sol +2 -2
- package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +4 -3
- package/contracts/Legacy/Registries/AddressRegistry.sol +1 -1
- package/contracts/Legacy/Registries/AddressRegistryRequiresERC725.sol +1 -1
- package/contracts/Legacy/UniversalReceiverAddressStore.sol +4 -14
- package/contracts/UniversalProfile.sol +2 -2
- package/contracts/UniversalProfileInit.sol +2 -2
- package/contracts/UniversalProfileInitAbstract.sol +1 -1
- package/contracts/Utils/GasLib.sol +1 -1
- package/module/constants.d.ts +738 -0
- package/module/constants.js +782 -0
- package/package.json +42 -12
- package/artifacts/UniversalFactory.json +0 -127
- package/constants.js +0 -594
- package/contracts/Custom/ClaimOwnership.sol +0 -96
- package/contracts/Custom/ERC165Checker.sol +0 -130
- package/contracts/Custom/IClaimOwnership.sol +0 -12
- package/contracts/Factories/UniversalFactory.sol +0 -159
- package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiverDelegate.sol +0 -24
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/Handling/TokenAndVaultHandling.sol +0 -82
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/Handling/TokenHandling.sol +0 -73
- package/contracts/LSP2ERC725YJSONSchema/LSP2Errors.sol +0 -9
- package/contracts/LSP7DigitalAsset/extensions/ILSP7CappedSupply.sol +0 -17
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyCore.sol +0 -57
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20Core.sol +0 -111
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CappedSupply.sol +0 -17
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8Enumerable.sol +0 -17
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyCore.sol +0 -58
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleConstants.sol +0 -6
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721Core.sol +0 -211
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableCore.sol +0 -50
- package/contracts/Utils/UtilsLib.sol +0 -31
|
@@ -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";
|
|
@@ -10,11 +10,20 @@ import {LSP2Utils} from "../LSP2ERC725YJSONSchema/LSP2Utils.sol";
|
|
|
10
10
|
|
|
11
11
|
// constants
|
|
12
12
|
import {SETDATA_ARRAY_SELECTOR} from "@erc725/smart-contracts/contracts/constants.sol";
|
|
13
|
-
import "
|
|
13
|
+
import "./LSP6Constants.sol";
|
|
14
|
+
|
|
15
|
+
// errors
|
|
16
|
+
import {NotAuthorised} from "./LSP6Errors.sol";
|
|
14
17
|
|
|
15
18
|
library LSP6Utils {
|
|
16
19
|
using LSP2Utils for bytes12;
|
|
17
20
|
|
|
21
|
+
/**
|
|
22
|
+
* @dev read the permissions of a `caller` on an ERC725Y `target` contract.
|
|
23
|
+
* @param target an `IERC725Y` contract where to read the permissions.
|
|
24
|
+
* @param caller the controller address to read the permissions from.
|
|
25
|
+
* @return a `bytes32` BitArray containing the permissions of a controller address.
|
|
26
|
+
*/
|
|
18
27
|
function getPermissionsFor(IERC725Y target, address caller) internal view returns (bytes32) {
|
|
19
28
|
bytes memory permissions = target.getData(
|
|
20
29
|
LSP2Utils.generateMappingWithGroupingKey(
|
|
@@ -26,21 +35,7 @@ library LSP6Utils {
|
|
|
26
35
|
return bytes32(permissions);
|
|
27
36
|
}
|
|
28
37
|
|
|
29
|
-
function
|
|
30
|
-
internal
|
|
31
|
-
view
|
|
32
|
-
returns (bytes memory)
|
|
33
|
-
{
|
|
34
|
-
return
|
|
35
|
-
target.getData(
|
|
36
|
-
LSP2Utils.generateMappingWithGroupingKey(
|
|
37
|
-
_LSP6KEY_ADDRESSPERMISSIONS_ALLOWEDADDRESSES_PREFIX,
|
|
38
|
-
bytes20(caller)
|
|
39
|
-
)
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function getAllowedFunctionsFor(IERC725Y target, address caller)
|
|
38
|
+
function getAllowedCallsFor(IERC725Y target, address from)
|
|
44
39
|
internal
|
|
45
40
|
view
|
|
46
41
|
returns (bytes memory)
|
|
@@ -48,27 +43,19 @@ library LSP6Utils {
|
|
|
48
43
|
return
|
|
49
44
|
target.getData(
|
|
50
45
|
LSP2Utils.generateMappingWithGroupingKey(
|
|
51
|
-
|
|
52
|
-
bytes20(
|
|
46
|
+
_LSP6KEY_ADDRESSPERMISSIONS_ALLOWEDCALLS_PREFIX,
|
|
47
|
+
bytes20(from)
|
|
53
48
|
)
|
|
54
49
|
);
|
|
55
50
|
}
|
|
56
51
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
LSP2Utils.generateMappingWithGroupingKey(
|
|
65
|
-
_LSP6KEY_ADDRESSPERMISSIONS_ALLOWEDSTANDARDS_PREFIX,
|
|
66
|
-
bytes20(caller)
|
|
67
|
-
)
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function getAllowedERC725YKeysFor(IERC725Y target, address caller)
|
|
52
|
+
/**
|
|
53
|
+
* @dev read the Allowed ERC725Y data keys of a `caller` on an ERC725Y `target` contract.
|
|
54
|
+
* @param target an `IERC725Y` contract where to read the permissions.
|
|
55
|
+
* @param caller the controller address to read the permissions from.
|
|
56
|
+
* @return an abi-encoded array of allowed ERC725 keys that the controller address is allowed to interact with.
|
|
57
|
+
*/
|
|
58
|
+
function getAllowedERC725YDataKeysFor(IERC725Y target, address caller)
|
|
72
59
|
internal
|
|
73
60
|
view
|
|
74
61
|
returns (bytes memory)
|
|
@@ -76,7 +63,7 @@ library LSP6Utils {
|
|
|
76
63
|
return
|
|
77
64
|
target.getData(
|
|
78
65
|
LSP2Utils.generateMappingWithGroupingKey(
|
|
79
|
-
|
|
66
|
+
_LSP6KEY_ADDRESSPERMISSIONS_AllowedERC725YDataKeys_PREFIX,
|
|
80
67
|
bytes20(caller)
|
|
81
68
|
)
|
|
82
69
|
);
|
|
@@ -97,6 +84,72 @@ library LSP6Utils {
|
|
|
97
84
|
return (addressPermission & permissionToCheck) == permissionToCheck;
|
|
98
85
|
}
|
|
99
86
|
|
|
87
|
+
/**
|
|
88
|
+
* @dev same as LSP2Utils.isCompactBytesArray with the additional requirement that each element must be 28 bytes long.
|
|
89
|
+
*
|
|
90
|
+
* @param allowedCallsCompacted a compact bytes array of tuples (bytes4,address,bytes4) to check.
|
|
91
|
+
* @return true if the value passed is a valid compact bytes array of bytes28 elements according to LSP2, false otherwise.
|
|
92
|
+
*/
|
|
93
|
+
function isCompactBytesArrayOfAllowedCalls(bytes memory allowedCallsCompacted)
|
|
94
|
+
internal
|
|
95
|
+
pure
|
|
96
|
+
returns (bool)
|
|
97
|
+
{
|
|
98
|
+
uint256 pointer;
|
|
99
|
+
|
|
100
|
+
while (pointer < allowedCallsCompacted.length) {
|
|
101
|
+
if (pointer + 1 >= allowedCallsCompacted.length) return false;
|
|
102
|
+
uint256 elementLength = uint16(
|
|
103
|
+
bytes2(
|
|
104
|
+
abi.encodePacked(
|
|
105
|
+
allowedCallsCompacted[pointer],
|
|
106
|
+
allowedCallsCompacted[pointer + 1]
|
|
107
|
+
)
|
|
108
|
+
)
|
|
109
|
+
);
|
|
110
|
+
// each entries in the allowedCalls (compact) array must be 28 bytes long
|
|
111
|
+
if (elementLength != 28) return false;
|
|
112
|
+
pointer += elementLength + 2;
|
|
113
|
+
}
|
|
114
|
+
if (pointer == allowedCallsCompacted.length) return true;
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* @dev same as LSP2Utils.isCompactBytesArray with the additional requirement that each element must be from 1 to 32 bytes long.
|
|
120
|
+
*
|
|
121
|
+
* @param allowedERC725YDataKeysCompacted a compact bytes array of ERC725Y Data Keys (full bytes32 data keys or bytesN prefix) to check.
|
|
122
|
+
* @return true if the value passed is a valid compact bytes array of ERC725Y Data Keys, false otherwise.
|
|
123
|
+
*/
|
|
124
|
+
function isCompactBytesArrayOfAllowedERC725YDataKeys(
|
|
125
|
+
bytes memory allowedERC725YDataKeysCompacted
|
|
126
|
+
) internal pure returns (bool) {
|
|
127
|
+
uint256 pointer;
|
|
128
|
+
|
|
129
|
+
while (pointer < allowedERC725YDataKeysCompacted.length) {
|
|
130
|
+
if (pointer + 1 >= allowedERC725YDataKeysCompacted.length) return false;
|
|
131
|
+
uint256 elementLength = uint16(
|
|
132
|
+
bytes2(
|
|
133
|
+
abi.encodePacked(
|
|
134
|
+
allowedERC725YDataKeysCompacted[pointer],
|
|
135
|
+
allowedERC725YDataKeysCompacted[pointer + 1]
|
|
136
|
+
)
|
|
137
|
+
)
|
|
138
|
+
);
|
|
139
|
+
// the length of the allowed data key must be not under 33 bytes and not 0
|
|
140
|
+
if (elementLength == 0 || elementLength > 32) return false;
|
|
141
|
+
pointer += elementLength + 2;
|
|
142
|
+
}
|
|
143
|
+
if (pointer == allowedERC725YDataKeysCompacted.length) return true;
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* @dev use the `setData(bytes32[],bytes[])` via the KeyManager of the target
|
|
149
|
+
* @param keyManagerAddress the address of the KeyManager
|
|
150
|
+
* @param keys the array of data keys
|
|
151
|
+
* @param values the array of data values
|
|
152
|
+
*/
|
|
100
153
|
function setDataViaKeyManager(
|
|
101
154
|
address keyManagerAddress,
|
|
102
155
|
bytes32[] memory keys,
|
|
@@ -105,4 +158,72 @@ library LSP6Utils {
|
|
|
105
158
|
bytes memory payload = abi.encodeWithSelector(SETDATA_ARRAY_SELECTOR, keys, values);
|
|
106
159
|
result = ILSP6KeyManager(keyManagerAddress).execute(payload);
|
|
107
160
|
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* @dev combine multiple permissions into a single bytes32
|
|
164
|
+
* Make sure that the sum of the values of the input array is less than 2^256-1 to avoid overflow.
|
|
165
|
+
* @param _permissions the array of permissions to combine
|
|
166
|
+
* @return a bytes32 containing the combined permissions
|
|
167
|
+
*/
|
|
168
|
+
function combinePermissions(bytes32[] memory _permissions) internal pure returns (bytes32) {
|
|
169
|
+
uint256 result = 0;
|
|
170
|
+
for (uint256 i = 0; i < _permissions.length; i++) {
|
|
171
|
+
result += uint256(_permissions[i]);
|
|
172
|
+
}
|
|
173
|
+
return bytes32(result);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function generatePermissionsKeysForController(
|
|
177
|
+
IERC725Y _account,
|
|
178
|
+
address _address,
|
|
179
|
+
bytes32 permissions
|
|
180
|
+
) internal view returns (bytes32[] memory keys, bytes[] memory values) {
|
|
181
|
+
keys = new bytes32[](3);
|
|
182
|
+
values = new bytes[](3);
|
|
183
|
+
|
|
184
|
+
uint256 arrayLength = uint256(bytes32(_account.getData(_LSP6KEY_ADDRESSPERMISSIONS_ARRAY)));
|
|
185
|
+
uint256 newArrayLength = arrayLength + 1;
|
|
186
|
+
|
|
187
|
+
keys[0] = _LSP6KEY_ADDRESSPERMISSIONS_ARRAY;
|
|
188
|
+
values[0] = abi.encodePacked(newArrayLength);
|
|
189
|
+
|
|
190
|
+
keys[1] = LSP2Utils.generateArrayElementKeyAtIndex(
|
|
191
|
+
_LSP6KEY_ADDRESSPERMISSIONS_ARRAY,
|
|
192
|
+
uint128(arrayLength)
|
|
193
|
+
);
|
|
194
|
+
values[1] = abi.encodePacked(_address);
|
|
195
|
+
|
|
196
|
+
keys[2] = LSP2Utils.generateMappingWithGroupingKey(
|
|
197
|
+
_LSP6KEY_ADDRESSPERMISSIONS_PERMISSIONS_PREFIX,
|
|
198
|
+
bytes20(_address)
|
|
199
|
+
);
|
|
200
|
+
values[2] = abi.encodePacked(permissions);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* @dev returns the name of the permission as a string
|
|
205
|
+
*/
|
|
206
|
+
function getPermissionName(bytes32 permission)
|
|
207
|
+
internal
|
|
208
|
+
pure
|
|
209
|
+
returns (string memory errorMessage)
|
|
210
|
+
{
|
|
211
|
+
if (permission == _PERMISSION_CHANGEOWNER) return "TRANSFEROWNERSHIP";
|
|
212
|
+
if (permission == _PERMISSION_CHANGEPERMISSIONS) return "CHANGEPERMISSIONS";
|
|
213
|
+
if (permission == _PERMISSION_ADDCONTROLLER) return "ADDCONTROLLER";
|
|
214
|
+
if (permission == _PERMISSION_ADDEXTENSIONS) return "ADDEXTENSIONS";
|
|
215
|
+
if (permission == _PERMISSION_CHANGEEXTENSIONS) return "CHANGEEXTENSIONS";
|
|
216
|
+
if (permission == _PERMISSION_ADDUNIVERSALRECEIVERDELEGATE)
|
|
217
|
+
return "ADDUNIVERSALRECEIVERDELEGATE";
|
|
218
|
+
if (permission == _PERMISSION_CHANGEUNIVERSALRECEIVERDELEGATE)
|
|
219
|
+
return "CHANGEUNIVERSALRECEIVERDELEGATE";
|
|
220
|
+
if (permission == _PERMISSION_REENTRANCY) return "REENTRANCY";
|
|
221
|
+
if (permission == _PERMISSION_SETDATA) return "SETDATA";
|
|
222
|
+
if (permission == _PERMISSION_CALL) return "CALL";
|
|
223
|
+
if (permission == _PERMISSION_STATICCALL) return "STATICCALL";
|
|
224
|
+
if (permission == _PERMISSION_DELEGATECALL) return "DELEGATECALL";
|
|
225
|
+
if (permission == _PERMISSION_DEPLOY) return "DEPLOY";
|
|
226
|
+
if (permission == _PERMISSION_TRANSFERVALUE) return "TRANSFERVALUE";
|
|
227
|
+
if (permission == _PERMISSION_SIGN) return "SIGN";
|
|
228
|
+
}
|
|
108
229
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
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";
|
|
@@ -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
|
|
|
@@ -137,11 +137,11 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
|
|
|
137
137
|
* @param from The sending address.
|
|
138
138
|
* @param to The receiving address.
|
|
139
139
|
* @param amount The amount of tokens to transfer.
|
|
140
|
-
* @param
|
|
140
|
+
* @param allowNonLSP1Recipient When set to TRUE, to may be any address but
|
|
141
141
|
* when set to FALSE to must be a contract that supports LSP1 UniversalReceiver
|
|
142
142
|
* @param data Additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses.
|
|
143
143
|
*
|
|
144
|
-
* @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
|
|
145
145
|
* when notifying the token sender and receiver.
|
|
146
146
|
*
|
|
147
147
|
* Requirements:
|
|
@@ -158,7 +158,7 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
|
|
|
158
158
|
address from,
|
|
159
159
|
address to,
|
|
160
160
|
uint256 amount,
|
|
161
|
-
bool
|
|
161
|
+
bool allowNonLSP1Recipient,
|
|
162
162
|
bytes memory data
|
|
163
163
|
) external;
|
|
164
164
|
|
|
@@ -166,7 +166,7 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
|
|
|
166
166
|
* @param from The list of sending addresses.
|
|
167
167
|
* @param to The list of receiving addresses.
|
|
168
168
|
* @param amount The amount of tokens to transfer.
|
|
169
|
-
* @param
|
|
169
|
+
* @param allowNonLSP1Recipient When set to TRUE, to may be any address but
|
|
170
170
|
* when set to FALSE to must be a contract that supports LSP1 UniversalReceiver
|
|
171
171
|
* @param data Additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses.
|
|
172
172
|
*
|
|
@@ -188,7 +188,7 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
|
|
|
188
188
|
address[] memory from,
|
|
189
189
|
address[] memory to,
|
|
190
190
|
uint256[] memory amount,
|
|
191
|
-
bool
|
|
191
|
+
bool[] memory allowNonLSP1Recipient,
|
|
192
192
|
bytes[] memory data
|
|
193
193
|
) external;
|
|
194
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,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
|
// interfaces
|
|
5
5
|
import {ILSP1UniversalReceiver} from "../LSP1UniversalReceiver/ILSP1UniversalReceiver.sol";
|
|
6
6
|
import {ILSP7DigitalAsset} from "./ILSP7DigitalAsset.sol";
|
|
7
7
|
|
|
8
8
|
// libraries
|
|
9
|
+
import {ERC165Checker} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
|
|
9
10
|
import {GasLib} from "../Utils/GasLib.sol";
|
|
10
|
-
import {ERC165Checker} from "../Custom/ERC165Checker.sol";
|
|
11
11
|
|
|
12
12
|
// modules
|
|
13
13
|
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
|
@@ -46,14 +46,14 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
|
|
|
46
46
|
/**
|
|
47
47
|
* @inheritdoc ILSP7DigitalAsset
|
|
48
48
|
*/
|
|
49
|
-
function decimals() public view returns (uint8) {
|
|
49
|
+
function decimals() public view virtual returns (uint8) {
|
|
50
50
|
return _isNonDivisible ? 0 : 18;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
54
|
* @inheritdoc ILSP7DigitalAsset
|
|
55
55
|
*/
|
|
56
|
-
function totalSupply() public view returns (uint256) {
|
|
56
|
+
function totalSupply() public view virtual returns (uint256) {
|
|
57
57
|
return _existingTokens;
|
|
58
58
|
}
|
|
59
59
|
|
|
@@ -62,7 +62,7 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
|
|
|
62
62
|
/**
|
|
63
63
|
* @inheritdoc ILSP7DigitalAsset
|
|
64
64
|
*/
|
|
65
|
-
function balanceOf(address tokenOwner) public view returns (uint256) {
|
|
65
|
+
function balanceOf(address tokenOwner) public view virtual returns (uint256) {
|
|
66
66
|
return _tokenOwnerBalances[tokenOwner];
|
|
67
67
|
}
|
|
68
68
|
|
|
@@ -117,7 +117,7 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
|
|
|
117
117
|
address from,
|
|
118
118
|
address to,
|
|
119
119
|
uint256 amount,
|
|
120
|
-
bool
|
|
120
|
+
bool allowNonLSP1Recipient,
|
|
121
121
|
bytes memory data
|
|
122
122
|
) public virtual {
|
|
123
123
|
if (from == to) revert LSP7CannotSendToSelf();
|
|
@@ -132,7 +132,7 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
|
|
|
132
132
|
_updateOperator(from, operator, operatorAmount - amount);
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
_transfer(from, to, amount,
|
|
135
|
+
_transfer(from, to, amount, allowNonLSP1Recipient, data);
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
/**
|
|
@@ -142,18 +142,22 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
|
|
|
142
142
|
address[] memory from,
|
|
143
143
|
address[] memory to,
|
|
144
144
|
uint256[] memory amount,
|
|
145
|
-
bool
|
|
145
|
+
bool[] memory allowNonLSP1Recipient,
|
|
146
146
|
bytes[] memory data
|
|
147
147
|
) public virtual {
|
|
148
|
+
uint256 fromLength = from.length;
|
|
148
149
|
if (
|
|
149
|
-
|
|
150
|
+
fromLength != to.length ||
|
|
151
|
+
fromLength != amount.length ||
|
|
152
|
+
fromLength != allowNonLSP1Recipient.length ||
|
|
153
|
+
fromLength != data.length
|
|
150
154
|
) {
|
|
151
155
|
revert LSP7InvalidTransferBatch();
|
|
152
156
|
}
|
|
153
157
|
|
|
154
|
-
for (uint256 i = 0; i <
|
|
158
|
+
for (uint256 i = 0; i < fromLength; i = GasLib.uncheckedIncrement(i)) {
|
|
155
159
|
// using the public transfer function to handle updates to operator authorized amounts
|
|
156
|
-
transfer(from[i], to[i], amount[i],
|
|
160
|
+
transfer(from[i], to[i], amount[i], allowNonLSP1Recipient[i], data[i]);
|
|
157
161
|
}
|
|
158
162
|
}
|
|
159
163
|
|
|
@@ -179,9 +183,8 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
|
|
|
179
183
|
revert LSP7CannotUseAddressZeroAsOperator();
|
|
180
184
|
}
|
|
181
185
|
|
|
182
|
-
// tokenOwner is always their own operator, no update required
|
|
183
186
|
if (operator == tokenOwner) {
|
|
184
|
-
|
|
187
|
+
revert LSP7TokenOwnerCannotBeOperator();
|
|
185
188
|
}
|
|
186
189
|
|
|
187
190
|
_operatorAuthorizedAmount[tokenOwner][operator] = amount;
|
|
@@ -205,7 +208,7 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
|
|
|
205
208
|
function _mint(
|
|
206
209
|
address to,
|
|
207
210
|
uint256 amount,
|
|
208
|
-
bool
|
|
211
|
+
bool allowNonLSP1Recipient,
|
|
209
212
|
bytes memory data
|
|
210
213
|
) internal virtual {
|
|
211
214
|
if (to == address(0)) {
|
|
@@ -216,11 +219,14 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
|
|
|
216
219
|
|
|
217
220
|
_beforeTokenTransfer(address(0), to, amount);
|
|
218
221
|
|
|
222
|
+
// tokens being minted
|
|
223
|
+
_existingTokens += amount;
|
|
224
|
+
|
|
219
225
|
_tokenOwnerBalances[to] += amount;
|
|
220
226
|
|
|
221
|
-
emit Transfer(operator, address(0), to, amount,
|
|
227
|
+
emit Transfer(operator, address(0), to, amount, allowNonLSP1Recipient, data);
|
|
222
228
|
|
|
223
|
-
_notifyTokenReceiver(address(0), to, amount,
|
|
229
|
+
_notifyTokenReceiver(address(0), to, amount, allowNonLSP1Recipient, data);
|
|
224
230
|
}
|
|
225
231
|
|
|
226
232
|
/**
|
|
@@ -260,6 +266,9 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
|
|
|
260
266
|
|
|
261
267
|
_beforeTokenTransfer(from, address(0), amount);
|
|
262
268
|
|
|
269
|
+
// tokens being burned
|
|
270
|
+
_existingTokens -= amount;
|
|
271
|
+
|
|
263
272
|
_tokenOwnerBalances[from] -= amount;
|
|
264
273
|
|
|
265
274
|
emit Transfer(operator, from, address(0), amount, false, data);
|
|
@@ -284,7 +293,7 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
|
|
|
284
293
|
address from,
|
|
285
294
|
address to,
|
|
286
295
|
uint256 amount,
|
|
287
|
-
bool
|
|
296
|
+
bool allowNonLSP1Recipient,
|
|
288
297
|
bytes memory data
|
|
289
298
|
) internal virtual {
|
|
290
299
|
if (from == address(0) || to == address(0)) {
|
|
@@ -303,10 +312,10 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
|
|
|
303
312
|
_tokenOwnerBalances[from] -= amount;
|
|
304
313
|
_tokenOwnerBalances[to] += amount;
|
|
305
314
|
|
|
306
|
-
emit Transfer(operator, from, to, amount,
|
|
315
|
+
emit Transfer(operator, from, to, amount, allowNonLSP1Recipient, data);
|
|
307
316
|
|
|
308
317
|
_notifyTokenSender(from, to, amount, data);
|
|
309
|
-
_notifyTokenReceiver(from, to, amount,
|
|
318
|
+
_notifyTokenReceiver(from, to, amount, allowNonLSP1Recipient, data);
|
|
310
319
|
}
|
|
311
320
|
|
|
312
321
|
/**
|
|
@@ -319,22 +328,13 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
|
|
|
319
328
|
* transferred to `to`.
|
|
320
329
|
* - When `from` is zero, `amount` tokens will be minted for `to`.
|
|
321
330
|
* - When `to` is zero, ``from``'s `amount` tokens will be burned.
|
|
331
|
+
* - `from` and `to` are never both zero.
|
|
322
332
|
*/
|
|
323
333
|
function _beforeTokenTransfer(
|
|
324
334
|
address from,
|
|
325
335
|
address to,
|
|
326
336
|
uint256 amount
|
|
327
|
-
) internal virtual {
|
|
328
|
-
// tokens being minted
|
|
329
|
-
if (from == address(0)) {
|
|
330
|
-
_existingTokens += amount;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
// tokens being burned
|
|
334
|
-
if (to == address(0)) {
|
|
335
|
-
_existingTokens -= amount;
|
|
336
|
-
}
|
|
337
|
-
}
|
|
337
|
+
) internal virtual {}
|
|
338
338
|
|
|
339
339
|
/**
|
|
340
340
|
* @dev An attempt is made to notify the token sender about the `amount` tokens changing owners using
|
|
@@ -346,7 +346,7 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
|
|
|
346
346
|
uint256 amount,
|
|
347
347
|
bytes memory data
|
|
348
348
|
) internal virtual {
|
|
349
|
-
if (ERC165Checker.
|
|
349
|
+
if (ERC165Checker.supportsERC165InterfaceUnchecked(from, _INTERFACEID_LSP1)) {
|
|
350
350
|
bytes memory packedData = abi.encodePacked(from, to, amount, data);
|
|
351
351
|
ILSP1UniversalReceiver(from).universalReceiver(_TYPEID_LSP7_TOKENSSENDER, packedData);
|
|
352
352
|
}
|
|
@@ -354,7 +354,7 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
|
|
|
354
354
|
|
|
355
355
|
/**
|
|
356
356
|
* @dev An attempt is made to notify the token receiver about the `amount` tokens changing owners
|
|
357
|
-
* using LSP1 interface. When
|
|
357
|
+
* using LSP1 interface. When allowNonLSP1Recipient is FALSE the token receiver MUST support LSP1.
|
|
358
358
|
*
|
|
359
359
|
* The receiver may revert when the token being sent is not wanted.
|
|
360
360
|
*/
|
|
@@ -362,14 +362,14 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
|
|
|
362
362
|
address from,
|
|
363
363
|
address to,
|
|
364
364
|
uint256 amount,
|
|
365
|
-
bool
|
|
365
|
+
bool allowNonLSP1Recipient,
|
|
366
366
|
bytes memory data
|
|
367
367
|
) internal virtual {
|
|
368
|
-
if (ERC165Checker.
|
|
368
|
+
if (ERC165Checker.supportsERC165InterfaceUnchecked(to, _INTERFACEID_LSP1)) {
|
|
369
369
|
bytes memory packedData = abi.encodePacked(from, to, amount, data);
|
|
370
370
|
ILSP1UniversalReceiver(to).universalReceiver(_TYPEID_LSP7_TOKENSRECIPIENT, packedData);
|
|
371
|
-
} else if (!
|
|
372
|
-
if (to.code.length
|
|
371
|
+
} else if (!allowNonLSP1Recipient) {
|
|
372
|
+
if (to.code.length > 0) {
|
|
373
373
|
revert LSP7NotifyTokenReceiverContractMissingLSP1Interface(to);
|
|
374
374
|
} else {
|
|
375
375
|
revert LSP7NotifyTokenReceiverIsEOA(to);
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
// SPDX-License-Identifier: CC0-1.0
|
|
2
|
-
pragma solidity ^0.8.
|
|
2
|
+
pragma solidity ^0.8.4;
|
|
3
3
|
|
|
4
4
|
// --- Errors
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* @dev reverts when sending an `amount` of tokens larger than the current `balance` of the `tokenOwner`.
|
|
8
|
+
*/
|
|
6
9
|
error LSP7AmountExceedsBalance(uint256 balance, address tokenOwner, uint256 amount);
|
|
7
10
|
|
|
11
|
+
/**
|
|
12
|
+
* @dev reverts when `operator` of `tokenOwner` send an `amount` of tokens
|
|
13
|
+
* larger than the `authorizedAmount`.
|
|
14
|
+
*/
|
|
8
15
|
error LSP7AmountExceedsAuthorizedAmount(
|
|
9
16
|
address tokenOwner,
|
|
10
17
|
uint256 authorizedAmount,
|
|
@@ -12,14 +19,39 @@ error LSP7AmountExceedsAuthorizedAmount(
|
|
|
12
19
|
uint256 amount
|
|
13
20
|
);
|
|
14
21
|
|
|
22
|
+
/**
|
|
23
|
+
* @dev reverts when trying to set the zero address as an operator.
|
|
24
|
+
*/
|
|
15
25
|
error LSP7CannotUseAddressZeroAsOperator();
|
|
16
26
|
|
|
27
|
+
/**
|
|
28
|
+
* @dev reverts when one tries to send tokens to or from the zero address.
|
|
29
|
+
*/
|
|
17
30
|
error LSP7CannotSendWithAddressZero();
|
|
18
31
|
|
|
32
|
+
/**
|
|
33
|
+
* @dev reverts when specifying the same address for `from` or `to` in a token transfer.
|
|
34
|
+
*/
|
|
19
35
|
error LSP7CannotSendToSelf();
|
|
20
36
|
|
|
37
|
+
/**
|
|
38
|
+
* @dev reverts when the parameters used for `transferBatch` have different lengths.
|
|
39
|
+
*/
|
|
21
40
|
error LSP7InvalidTransferBatch();
|
|
22
41
|
|
|
42
|
+
/**
|
|
43
|
+
* @dev reverts if the `tokenReceiver` does not implement LSP1
|
|
44
|
+
* when minting or transferring tokens with `bool allowNonLSP1Recipient` set as `false`.
|
|
45
|
+
*/
|
|
23
46
|
error LSP7NotifyTokenReceiverContractMissingLSP1Interface(address tokenReceiver);
|
|
24
47
|
|
|
48
|
+
/**
|
|
49
|
+
* @dev reverts if the `tokenReceiver` is an EOA
|
|
50
|
+
* when minting or transferring tokens with `bool allowNonLSP1Recipient` set as `false`.
|
|
51
|
+
*/
|
|
25
52
|
error LSP7NotifyTokenReceiverIsEOA(address tokenReceiver);
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @dev reverts when trying to authorize or revoke the token's owner as an operator.
|
|
56
|
+
*/
|
|
57
|
+
error LSP7TokenOwnerCannotBeOperator();
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.4;
|
|
3
|
+
|
|
4
|
+
// modules
|
|
5
|
+
import {LSP7DigitalAssetCore} from "../LSP7DigitalAssetCore.sol";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @dev LSP7 extension that allows token holders to destroy both
|
|
9
|
+
* their own tokens and those that they have an allowance for as an operator.
|
|
10
|
+
*/
|
|
11
|
+
abstract contract LSP7Burnable is LSP7DigitalAssetCore {
|
|
12
|
+
/**
|
|
13
|
+
* @dev Destroys `amount` tokens from the `from` address.
|
|
14
|
+
*
|
|
15
|
+
* See internal _burn function for more details
|
|
16
|
+
*/
|
|
17
|
+
function burn(
|
|
18
|
+
address from,
|
|
19
|
+
uint256 amount,
|
|
20
|
+
bytes memory data
|
|
21
|
+
) public {
|
|
22
|
+
_burn(from, amount, data);
|
|
23
|
+
}
|
|
24
|
+
}
|