@lukso/lsp-smart-contracts 0.12.0 → 0.13.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.
Files changed (160) hide show
  1. package/README.md +2 -2
  2. package/artifacts/LSP0ERC725Account.json +19 -19
  3. package/artifacts/LSP0ERC725AccountInit.json +19 -19
  4. package/artifacts/LSP11BasicSocialRecovery.json +2 -2
  5. package/artifacts/LSP11BasicSocialRecoveryInit.json +2 -2
  6. package/artifacts/LSP1UniversalReceiverDelegateUP.json +15 -15
  7. package/artifacts/LSP1UniversalReceiverDelegateVault.json +15 -15
  8. package/artifacts/LSP4DigitalAssetMetadata.json +5 -0
  9. package/artifacts/LSP4DigitalAssetMetadataInitAbstract.json +5 -0
  10. package/artifacts/LSP6KeyManager.json +15 -15
  11. package/artifacts/LSP6KeyManagerInit.json +15 -15
  12. package/artifacts/LSP7CappedSupply.json +71 -49
  13. package/artifacts/LSP7CappedSupplyInitAbstract.json +71 -49
  14. package/artifacts/LSP7CompatibleERC20.json +71 -49
  15. package/artifacts/LSP7CompatibleERC20InitAbstract.json +71 -49
  16. package/artifacts/LSP7CompatibleERC20Mintable.json +78 -51
  17. package/artifacts/LSP7CompatibleERC20MintableInit.json +78 -51
  18. package/artifacts/LSP7DigitalAsset.json +71 -49
  19. package/artifacts/LSP7DigitalAssetInitAbstract.json +71 -49
  20. package/artifacts/LSP7Mintable.json +78 -51
  21. package/artifacts/LSP7MintableInit.json +78 -51
  22. package/artifacts/LSP8CappedSupply.json +187 -36
  23. package/artifacts/LSP8CappedSupplyInitAbstract.json +200 -49
  24. package/artifacts/LSP8CompatibleERC721.json +187 -36
  25. package/artifacts/LSP8CompatibleERC721InitAbstract.json +200 -49
  26. package/artifacts/LSP8CompatibleERC721Mintable.json +195 -39
  27. package/artifacts/LSP8CompatibleERC721MintableInit.json +208 -52
  28. package/artifacts/LSP8IdentifiableDigitalAsset.json +187 -36
  29. package/artifacts/LSP8IdentifiableDigitalAssetInitAbstract.json +200 -49
  30. package/artifacts/LSP8Mintable.json +195 -39
  31. package/artifacts/LSP8MintableInit.json +208 -52
  32. package/artifacts/LSP9Vault.json +19 -19
  33. package/artifacts/LSP9VaultInit.json +19 -19
  34. package/artifacts/UniversalProfile.json +19 -19
  35. package/artifacts/UniversalProfileInit.json +19 -19
  36. package/contracts/LSP0ERC725Account/LSP0Constants.sol +1 -1
  37. package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +7 -3
  38. package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +62 -62
  39. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +2 -1
  40. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +3 -1
  41. package/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol +11 -10
  42. package/contracts/LSP17Extensions/Extension4337.sol +26 -1
  43. package/contracts/LSP17Extensions/OnERC721ReceivedExtension.sol +2 -1
  44. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +31 -33
  45. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +24 -17
  46. package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +1 -1
  47. package/contracts/LSP25ExecuteRelayCall/LSP25MultiChannelNonce.sol +1 -5
  48. package/contracts/LSP4DigitalAssetMetadata/LSP4Constants.sol +9 -0
  49. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol +20 -34
  50. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataCore.sol +47 -0
  51. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +19 -31
  52. package/contracts/LSP4DigitalAssetMetadata/LSP4Errors.sol +13 -6
  53. package/contracts/LSP6KeyManager/LSP6KeyManager.sol +2 -1
  54. package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +16 -10
  55. package/contracts/LSP6KeyManager/LSP6KeyManagerInit.sol +2 -1
  56. package/contracts/LSP6KeyManager/LSP6Modules/LSP6ExecuteModule.sol +14 -16
  57. package/contracts/LSP6KeyManager/LSP6Modules/LSP6SetDataModule.sol +6 -2
  58. package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +20 -9
  59. package/contracts/LSP7DigitalAsset/LSP7Constants.sol +1 -1
  60. package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +7 -5
  61. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +129 -36
  62. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +5 -2
  63. package/contracts/LSP7DigitalAsset/LSP7Errors.sol +6 -0
  64. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.sol +4 -2
  65. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20InitAbstract.sol +7 -4
  66. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.sol +4 -2
  67. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInit.sol +5 -2
  68. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInitAbstract.sol +8 -2
  69. package/contracts/LSP7DigitalAsset/presets/LSP7Mintable.sol +12 -1
  70. package/contracts/LSP7DigitalAsset/presets/LSP7MintableInit.sol +4 -0
  71. package/contracts/LSP7DigitalAsset/presets/LSP7MintableInitAbstract.sol +4 -0
  72. package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +77 -4
  73. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol +15 -12
  74. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol +19 -3
  75. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +25 -16
  76. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +222 -28
  77. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +28 -15
  78. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +16 -8
  79. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +9 -8
  80. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.sol +13 -2
  81. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInit.sol +6 -2
  82. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInitAbstract.sol +4 -2
  83. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.sol +13 -2
  84. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInit.sol +6 -2
  85. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +6 -2
  86. package/contracts/LSP9Vault/LSP9Constants.sol +1 -1
  87. package/contracts/LSP9Vault/LSP9Vault.sol +3 -2
  88. package/contracts/LSP9Vault/LSP9VaultCore.sol +22 -37
  89. package/contracts/LSP9Vault/LSP9VaultInit.sol +2 -1
  90. package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +1 -1
  91. package/contracts/UniversalProfile.sol +4 -2
  92. package/contracts/UniversalProfileInit.sol +8 -5
  93. package/contracts/UniversalProfileInitAbstract.sol +4 -2
  94. package/contracts/Version.sol +6 -5
  95. package/devdocs/LSP0ERC725Account.json +3 -8
  96. package/devdocs/LSP0ERC725AccountInit.json +2 -7
  97. package/devdocs/LSP1UniversalReceiverDelegateUP.json +0 -6
  98. package/devdocs/LSP1UniversalReceiverDelegateVault.json +0 -6
  99. package/devdocs/LSP4DigitalAssetMetadata.json +11 -5
  100. package/devdocs/LSP4DigitalAssetMetadataInitAbstract.json +7 -2
  101. package/devdocs/LSP6KeyManager.json +2 -7
  102. package/devdocs/LSP6KeyManagerInit.json +2 -7
  103. package/devdocs/LSP7CappedSupply.json +22 -8
  104. package/devdocs/LSP7CappedSupplyInitAbstract.json +22 -8
  105. package/devdocs/LSP7CompatibleERC20.json +23 -8
  106. package/devdocs/LSP7CompatibleERC20InitAbstract.json +22 -8
  107. package/devdocs/LSP7CompatibleERC20Mintable.json +23 -8
  108. package/devdocs/LSP7CompatibleERC20MintableInit.json +24 -9
  109. package/devdocs/LSP7DigitalAsset.json +27 -12
  110. package/devdocs/LSP7DigitalAssetInitAbstract.json +22 -8
  111. package/devdocs/LSP7Mintable.json +24 -8
  112. package/devdocs/LSP7MintableInit.json +25 -9
  113. package/devdocs/LSP8CappedSupply.json +66 -10
  114. package/devdocs/LSP8CappedSupplyInitAbstract.json +66 -10
  115. package/devdocs/LSP8CompatibleERC721.json +69 -11
  116. package/devdocs/LSP8CompatibleERC721InitAbstract.json +67 -11
  117. package/devdocs/LSP8CompatibleERC721Mintable.json +69 -11
  118. package/devdocs/LSP8CompatibleERC721MintableInit.json +70 -12
  119. package/devdocs/LSP8IdentifiableDigitalAsset.json +71 -14
  120. package/devdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +66 -10
  121. package/devdocs/LSP8Mintable.json +68 -10
  122. package/devdocs/LSP8MintableInit.json +69 -11
  123. package/devdocs/LSP9Vault.json +0 -6
  124. package/devdocs/LSP9VaultInit.json +0 -6
  125. package/devdocs/UniversalProfile.json +3 -8
  126. package/devdocs/UniversalProfileInit.json +4 -9
  127. package/dist/constants.cjs.js +4552 -1859
  128. package/dist/constants.d.ts +4143 -1371
  129. package/dist/constants.es.js +4551 -1859
  130. package/package.json +2 -2
  131. package/userdocs/LSP0ERC725Account.json +3 -3
  132. package/userdocs/LSP0ERC725AccountInit.json +3 -3
  133. package/userdocs/LSP1UniversalReceiverDelegateUP.json +3 -3
  134. package/userdocs/LSP1UniversalReceiverDelegateVault.json +3 -3
  135. package/userdocs/LSP6KeyManager.json +3 -3
  136. package/userdocs/LSP6KeyManagerInit.json +3 -3
  137. package/userdocs/LSP7CappedSupply.json +8 -3
  138. package/userdocs/LSP7CappedSupplyInitAbstract.json +8 -3
  139. package/userdocs/LSP7CompatibleERC20.json +8 -3
  140. package/userdocs/LSP7CompatibleERC20InitAbstract.json +8 -3
  141. package/userdocs/LSP7CompatibleERC20Mintable.json +8 -3
  142. package/userdocs/LSP7CompatibleERC20MintableInit.json +9 -4
  143. package/userdocs/LSP7DigitalAsset.json +8 -3
  144. package/userdocs/LSP7DigitalAssetInitAbstract.json +8 -3
  145. package/userdocs/LSP7Mintable.json +8 -3
  146. package/userdocs/LSP7MintableInit.json +9 -4
  147. package/userdocs/LSP8CappedSupply.json +20 -3
  148. package/userdocs/LSP8CappedSupplyInitAbstract.json +20 -3
  149. package/userdocs/LSP8CompatibleERC721.json +20 -3
  150. package/userdocs/LSP8CompatibleERC721InitAbstract.json +20 -3
  151. package/userdocs/LSP8CompatibleERC721Mintable.json +20 -3
  152. package/userdocs/LSP8CompatibleERC721MintableInit.json +21 -4
  153. package/userdocs/LSP8IdentifiableDigitalAsset.json +20 -3
  154. package/userdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +19 -2
  155. package/userdocs/LSP8Mintable.json +19 -2
  156. package/userdocs/LSP8MintableInit.json +20 -3
  157. package/userdocs/LSP9Vault.json +3 -3
  158. package/userdocs/LSP9VaultInit.json +3 -3
  159. package/userdocs/UniversalProfile.json +3 -3
  160. package/userdocs/UniversalProfileInit.json +3 -3
@@ -3,74 +3,60 @@ pragma solidity ^0.8.4;
3
3
 
4
4
  // modules
5
5
  import {ERC725Y} from "@erc725/smart-contracts/contracts/ERC725Y.sol";
6
-
7
- // libraries
8
- import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol";
6
+ import {ERC725YCore} from "@erc725/smart-contracts/contracts/ERC725YCore.sol";
7
+ import {LSP4DigitalAssetMetadataCore} from "./LSP4DigitalAssetMetadataCore.sol";
9
8
 
10
9
  // constants
11
10
  import {
12
11
  _LSP4_SUPPORTED_STANDARDS_KEY,
13
12
  _LSP4_SUPPORTED_STANDARDS_VALUE,
14
13
  _LSP4_TOKEN_NAME_KEY,
15
- _LSP4_TOKEN_SYMBOL_KEY
14
+ _LSP4_TOKEN_SYMBOL_KEY,
15
+ _LSP4_TOKEN_TYPE_KEY
16
16
  } from "./LSP4Constants.sol";
17
17
 
18
- // errors
19
- import {
20
- LSP4TokenNameNotEditable,
21
- LSP4TokenSymbolNotEditable
22
- } from "./LSP4Errors.sol";
23
-
24
18
  /**
25
19
  * @title Implementation of a LSP4DigitalAssetMetadata contract that stores the **Token-Metadata** (`LSP4TokenName` and `LSP4TokenSymbol`) in its ERC725Y data store.
26
20
  * @author Matthew Stevens
27
21
  * @dev Standard Implementation of the LSP4 standard.
28
22
  */
29
- abstract contract LSP4DigitalAssetMetadata is ERC725Y {
23
+ abstract contract LSP4DigitalAssetMetadata is
24
+ ERC725Y,
25
+ LSP4DigitalAssetMetadataCore
26
+ {
30
27
  /**
31
28
  * @notice Deploying a digital asset `name_` with the `symbol_` symbol.
32
29
  *
33
- * @param name_ The name of the token
34
- * @param symbol_ The symbol of the token
35
- * @param initialOwner_ The owner of the token contract
30
+ * @param name_ The name of the token.
31
+ * @param symbol_ The symbol of the token.
32
+ * @param initialOwner_ The owner of the token contract.
33
+ * @param lsp4TokenType_ The type of token this digital asset contract represents (`1` = Token, `2` = NFT, `3` = Collection).
36
34
  */
37
35
  constructor(
38
36
  string memory name_,
39
37
  string memory symbol_,
40
- address initialOwner_
38
+ address initialOwner_,
39
+ uint256 lsp4TokenType_
41
40
  ) ERC725Y(initialOwner_) {
42
41
  // set data key SupportedStandards:LSP4DigitalAsset
43
- super._setData(
42
+ ERC725YCore._setData(
44
43
  _LSP4_SUPPORTED_STANDARDS_KEY,
45
44
  _LSP4_SUPPORTED_STANDARDS_VALUE
46
45
  );
47
46
 
48
- super._setData(_LSP4_TOKEN_NAME_KEY, bytes(name_));
49
- super._setData(_LSP4_TOKEN_SYMBOL_KEY, bytes(symbol_));
47
+ ERC725YCore._setData(_LSP4_TOKEN_NAME_KEY, bytes(name_));
48
+ ERC725YCore._setData(_LSP4_TOKEN_SYMBOL_KEY, bytes(symbol_));
49
+ ERC725YCore._setData(_LSP4_TOKEN_TYPE_KEY, abi.encode(lsp4TokenType_));
50
50
  }
51
51
 
52
52
  /**
53
53
  * @dev The ERC725Y data keys `LSP4TokenName` and `LSP4TokenSymbol` cannot be changed
54
54
  * via this function once the digital asset contract has been deployed.
55
- *
56
- * @dev Save gas by emitting the {DataChanged} event with only the first 256 bytes of dataValue
57
55
  */
58
56
  function _setData(
59
57
  bytes32 dataKey,
60
58
  bytes memory dataValue
61
- ) internal virtual override {
62
- if (dataKey == _LSP4_TOKEN_NAME_KEY) {
63
- revert LSP4TokenNameNotEditable();
64
- } else if (dataKey == _LSP4_TOKEN_SYMBOL_KEY) {
65
- revert LSP4TokenSymbolNotEditable();
66
- } else {
67
- _store[dataKey] = dataValue;
68
- emit DataChanged(
69
- dataKey,
70
- dataValue.length <= 256
71
- ? dataValue
72
- : BytesLib.slice(dataValue, 0, 256)
73
- );
74
- }
59
+ ) internal virtual override(ERC725YCore, LSP4DigitalAssetMetadataCore) {
60
+ LSP4DigitalAssetMetadataCore._setData(dataKey, dataValue);
75
61
  }
76
62
  }
@@ -0,0 +1,47 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.4;
3
+
4
+ // modules
5
+ import {ERC725YCore} from "@erc725/smart-contracts/contracts/ERC725YCore.sol";
6
+
7
+ // constants
8
+ import {
9
+ _LSP4_TOKEN_NAME_KEY,
10
+ _LSP4_TOKEN_SYMBOL_KEY,
11
+ _LSP4_TOKEN_TYPE_KEY
12
+ } from "./LSP4Constants.sol";
13
+
14
+ // errors
15
+ import {
16
+ LSP4TokenNameNotEditable,
17
+ LSP4TokenSymbolNotEditable,
18
+ LSP4TokenTypeNotEditable
19
+ } from "./LSP4Errors.sol";
20
+
21
+ /**
22
+ * @title Implementation of a LSP4DigitalAssetMetadata contract that stores the **Token-Metadata** (`LSP4TokenName` and `LSP4TokenSymbol`) in its ERC725Y data store.
23
+ * @author Matthew Stevens
24
+ * @dev Standard Implementation of the LSP4 standard.
25
+ */
26
+ abstract contract LSP4DigitalAssetMetadataCore is ERC725YCore {
27
+ /**
28
+ * @dev The ERC725Y data keys `LSP4TokenName` and `LSP4TokenSymbol` cannot be changed
29
+ * via this function once the digital asset contract has been deployed.
30
+ */
31
+ function _setData(
32
+ bytes32 dataKey,
33
+ bytes memory dataValue
34
+ ) internal virtual override {
35
+ if (dataKey == _LSP4_TOKEN_NAME_KEY) {
36
+ revert LSP4TokenNameNotEditable();
37
+ } else if (dataKey == _LSP4_TOKEN_SYMBOL_KEY) {
38
+ revert LSP4TokenSymbolNotEditable();
39
+ } else if (dataKey == _LSP4_TOKEN_TYPE_KEY) {
40
+ revert LSP4TokenTypeNotEditable();
41
+ } else {
42
+ _store[dataKey] = dataValue;
43
+
44
+ emit DataChanged(dataKey, dataValue);
45
+ }
46
+ }
47
+ }
@@ -6,75 +6,63 @@ import {
6
6
  ERC725YInitAbstract
7
7
  } from "@erc725/smart-contracts/contracts/ERC725YInitAbstract.sol";
8
8
 
9
- // libraries
10
- import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol";
9
+ import {ERC725YCore} from "@erc725/smart-contracts/contracts/ERC725YCore.sol";
10
+
11
+ import {LSP4DigitalAssetMetadataCore} from "./LSP4DigitalAssetMetadataCore.sol";
11
12
 
12
13
  // constants
13
14
  import {
14
15
  _LSP4_SUPPORTED_STANDARDS_KEY,
15
16
  _LSP4_SUPPORTED_STANDARDS_VALUE,
16
17
  _LSP4_TOKEN_NAME_KEY,
17
- _LSP4_TOKEN_SYMBOL_KEY
18
+ _LSP4_TOKEN_SYMBOL_KEY,
19
+ _LSP4_TOKEN_TYPE_KEY
18
20
  } from "./LSP4Constants.sol";
19
21
 
20
- // errors
21
- import {
22
- LSP4TokenNameNotEditable,
23
- LSP4TokenSymbolNotEditable
24
- } from "./LSP4Errors.sol";
25
-
26
22
  /**
27
23
  * @title Implementation of a LSP4DigitalAssetMetadata contract that stores the **Token-Metadata** (`LSP4TokenName` and `LSP4TokenSymbol`) in its ERC725Y data store.
28
24
  * @author Matthew Stevens
29
25
  * @dev Inheritable Proxy Implementation of the LSP4 standard.
30
26
  */
31
- abstract contract LSP4DigitalAssetMetadataInitAbstract is ERC725YInitAbstract {
27
+ abstract contract LSP4DigitalAssetMetadataInitAbstract is
28
+ LSP4DigitalAssetMetadataCore,
29
+ ERC725YInitAbstract
30
+ {
32
31
  /**
33
32
  * @notice Initializing a digital asset `name_` with the `symbol_` symbol.
34
33
  *
35
34
  * @param name_ The name of the token
36
35
  * @param symbol_ The symbol of the token
37
36
  * @param initialOwner_ The owner of the token contract
37
+ * @param lsp4TokenType_ The type of token this digital asset contract represents (`1` = Token, `2` = NFT, `3` = Collection)
38
38
  */
39
39
  function _initialize(
40
40
  string memory name_,
41
41
  string memory symbol_,
42
- address initialOwner_
42
+ address initialOwner_,
43
+ uint256 lsp4TokenType_
43
44
  ) internal virtual onlyInitializing {
44
45
  ERC725YInitAbstract._initialize(initialOwner_);
45
46
 
46
47
  // set data key SupportedStandards:LSP4DigitalAsset
47
- super._setData(
48
+ ERC725YCore._setData(
48
49
  _LSP4_SUPPORTED_STANDARDS_KEY,
49
50
  _LSP4_SUPPORTED_STANDARDS_VALUE
50
51
  );
51
52
 
52
- super._setData(_LSP4_TOKEN_NAME_KEY, bytes(name_));
53
- super._setData(_LSP4_TOKEN_SYMBOL_KEY, bytes(symbol_));
53
+ ERC725YCore._setData(_LSP4_TOKEN_NAME_KEY, bytes(name_));
54
+ ERC725YCore._setData(_LSP4_TOKEN_SYMBOL_KEY, bytes(symbol_));
55
+ ERC725YCore._setData(_LSP4_TOKEN_TYPE_KEY, abi.encode(lsp4TokenType_));
54
56
  }
55
57
 
56
58
  /**
57
- * @dev the ERC725Y data keys `LSP4TokenName` and `LSP4TokenSymbol` cannot be changed
59
+ * @dev The ERC725Y data keys `LSP4TokenName` and `LSP4TokenSymbol` cannot be changed
58
60
  * via this function once the digital asset contract has been deployed.
59
- *
60
- * @dev Save gas by emitting the {DataChanged} event with only the first 256 bytes of dataValue
61
61
  */
62
62
  function _setData(
63
63
  bytes32 dataKey,
64
64
  bytes memory dataValue
65
- ) internal virtual override {
66
- if (dataKey == _LSP4_TOKEN_NAME_KEY) {
67
- revert LSP4TokenNameNotEditable();
68
- } else if (dataKey == _LSP4_TOKEN_SYMBOL_KEY) {
69
- revert LSP4TokenSymbolNotEditable();
70
- } else {
71
- _store[dataKey] = dataValue;
72
- emit DataChanged(
73
- dataKey,
74
- dataValue.length <= 256
75
- ? dataValue
76
- : BytesLib.slice(dataValue, 0, 256)
77
- );
78
- }
65
+ ) internal virtual override(ERC725YCore, LSP4DigitalAssetMetadataCore) {
66
+ LSP4DigitalAssetMetadataCore._setData(dataKey, dataValue);
79
67
  }
80
68
  }
@@ -2,15 +2,22 @@
2
2
  pragma solidity ^0.8.4;
3
3
 
4
4
  /**
5
- * @dev Reverts when trying to edit the data key `LSP4TokenName` after the digital asset contract has been deployed.
6
- * The `LSP4TokenName` data key is located inside the ERC725Y Data key-value store of the digital asset contract.
7
- * It can be set only once inside the constructor/initializer when the digital asset contract is being deployed.
5
+ * @dev Reverts when trying to edit the data key `LSP4TokenName` after the digital asset contract has been deployed / initialized.
6
+ * The `LSP4TokenName` data key is located inside the ERC725Y data key-value store of the digital asset contract.
7
+ * It can be set only once inside the constructor/initializer when the digital asset contract is being deployed / initialized.
8
8
  */
9
9
  error LSP4TokenNameNotEditable();
10
10
 
11
11
  /**
12
- * @dev Reverts when trying to edit the data key `LSP4TokenSymbol` after the digital asset contract has been deployed.
13
- * The `LSP4TokenSymbol` data key is located inside the ERC725Y Data key-value store of the digital asset contract.
14
- * It can be set only once inside the constructor/initializer when the digital asset contract is being deployed.
12
+ * @dev Reverts when trying to edit the data key `LSP4TokenSymbol` after the digital asset contract has been deployed / initialized.
13
+ * The `LSP4TokenSymbol` data key is located inside the ERC725Y data key-value store of the digital asset contract.
14
+ * It can be set only once inside the constructor/initializer when the digital asset contract is being deployed / initialized.
15
15
  */
16
16
  error LSP4TokenSymbolNotEditable();
17
+
18
+ /**
19
+ * @dev Reverts when trying to edit the data key `LSP4TokenType` after the digital asset contract has been deployed / initialized.
20
+ * The `LSP4TokenType` data key is located inside the ERC725Y data key-value store of the digital asset contract.
21
+ * It can be set only once inside the constructor / initializer when the digital asset contract is being deployed / initialized.
22
+ */
23
+ error LSP4TokenTypeNotEditable();
@@ -2,6 +2,7 @@
2
2
  pragma solidity ^0.8.5;
3
3
 
4
4
  // modules
5
+ import {Version} from "../Version.sol";
5
6
  import {LSP6KeyManagerCore} from "./LSP6KeyManagerCore.sol";
6
7
  import {InvalidLSP6Target} from "./LSP6Errors.sol";
7
8
 
@@ -10,7 +11,7 @@ import {InvalidLSP6Target} from "./LSP6Errors.sol";
10
11
  * @author Fabian Vogelsteller <frozeman>, Jean Cavallera (CJ42), Yamen Merhi (YamenMerhi)
11
12
  * @dev All the permissions can be set on the ERC725 Account using `setData(bytes32,bytes)` or `setData(bytes32[],bytes[])`.
12
13
  */
13
- contract LSP6KeyManager is LSP6KeyManagerCore {
14
+ contract LSP6KeyManager is LSP6KeyManagerCore, Version {
14
15
  /**
15
16
  * @notice Deploying a LSP6KeyManager linked to the contract at address `target_`.
16
17
  * @dev Deploy a Key Manager and set the `target_` address in the contract storage,
@@ -18,7 +18,6 @@ import {
18
18
  } from "../LSP25ExecuteRelayCall/ILSP25ExecuteRelayCall.sol";
19
19
 
20
20
  // modules
21
- import {Version} from "../Version.sol";
22
21
  import {ILSP14Ownable2Step} from "../LSP14Ownable2Step/ILSP14Ownable2Step.sol";
23
22
  import {ERC725Y} from "@erc725/smart-contracts/contracts/ERC725Y.sol";
24
23
  import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
@@ -88,7 +87,6 @@ abstract contract LSP6KeyManagerCore is
88
87
  ILSP6,
89
88
  ILSP20,
90
89
  ILSP25,
91
- Version,
92
90
  LSP6SetDataModule,
93
91
  LSP6ExecuteModule,
94
92
  LSP6ExecuteRelayCallModule,
@@ -152,6 +150,11 @@ abstract contract LSP6KeyManagerCore is
152
150
  * If the signer is a controller with the permission `SIGN`, it will return the ERC1271 success value.
153
151
  *
154
152
  * @return returnedStatus `0x1626ba7e` on success, or `0xffffffff` on failure.
153
+ *
154
+ * @custom:warning This function does not enforce by default the inclusion of the address of this contract in the signature digest.
155
+ * It is recommended that protocols or applications using this contract include the targeted address (= this contract) in the data to sign.
156
+ * To ensure that a signature is valid for a specific LSP6KeyManager and prevent signatures from the same EOA to be replayed
157
+ * across different LSP6KeyManager.
155
158
  */
156
159
  function isValidSignature(
157
160
  bytes32 dataHash,
@@ -233,7 +236,7 @@ abstract contract LSP6KeyManagerCore is
233
236
  * @custom:events {PermissionsVerified} event when the permissions related to `payload` have been verified successfully.
234
237
  *
235
238
  * @custom:hint If you are looking to learn how to sign and execute relay transactions via the Key Manager,
236
- * see our Javascript step by step guide [_"Execute Relay Transactions"_](../../../guides/key-manager/execute-relay-transactions.md).
239
+ * see our Javascript step by step guide [_"Execute Relay Transactions"_](../../../learn/expert-guides/key-manager/execute-relay-transactions.md).
237
240
  * See the LSP6 Standard page for more details on how to
238
241
  * [generate a valid signature for Execute Relay Call](../../../standards/universal-profile/lsp6-key-manager.md#how-to-sign-relay-transactions).
239
242
  */
@@ -510,13 +513,14 @@ abstract contract LSP6KeyManagerCore is
510
513
  value: msgValue,
511
514
  gas: gasleft()
512
515
  }(payload);
516
+
513
517
  bytes memory result = Address.verifyCallResult(
514
518
  success,
515
519
  returnData,
516
520
  "LSP6: failed executing payload"
517
521
  );
518
522
 
519
- return result.length != 0 ? abi.decode(result, (bytes)) : result;
523
+ return result;
520
524
  }
521
525
 
522
526
  /**
@@ -612,7 +616,7 @@ abstract contract LSP6KeyManagerCore is
612
616
  revert ERC725X_ExecuteParametersEmptyArray();
613
617
  }
614
618
 
615
- for (uint256 ii = 0; ii < operationTypes.length; ii++) {
619
+ for (uint256 ii; ii < operationTypes.length; ii++) {
616
620
  LSP6ExecuteModule._verifyCanExecute(
617
621
  targetContract,
618
622
  from,
@@ -635,9 +639,11 @@ abstract contract LSP6KeyManagerCore is
635
639
  }
636
640
 
637
641
  /**
638
- * @dev Update the status from `_NON_ENTERED` to `_ENTERED` and checks if
639
- * the status is `_ENTERED` in order to revert the call unless the caller has the REENTRANCY permission
640
- * Used in the beginning of the `nonReentrant` modifier, before the method execution starts.
642
+ * @dev Check if we are in the context of a reentrant call, by checking if the reentrancy status is `true`.
643
+ * - If the status is `true`, the caller (or signer for relay call) MUST have the `REENTRANCY` permission. Otherwise, the call is reverted.
644
+ * - If the status is `false`, it is set to `true` only if we are not dealing with a call to the functions `setData` or `setDataBatch`.
645
+ * Used at the beginning of the {`lsp20VerifyCall`}, {`_execute`} and {`_executeRelayCall`} functions, before the methods execution starts.
646
+ *
641
647
  */
642
648
  function _nonReentrantBefore(
643
649
  address targetContract,
@@ -661,8 +667,8 @@ abstract contract LSP6KeyManagerCore is
661
667
  }
662
668
 
663
669
  /**
664
- * @dev Resets the status to `false`
665
- * Used in the end of the `nonReentrant` modifier after the method execution is terminated
670
+ * @dev Resets the reentrancy status to `false`
671
+ * Used at the end of the {`lsp20VerifyCall`}, {`_execute`} and {`_executeRelayCall`} functions after the functions' execution is terminated.
666
672
  */
667
673
  function _nonReentrantAfter(address targetContract) internal virtual {
668
674
  // By storing the original value once again, a refund is triggered (see
@@ -2,6 +2,7 @@
2
2
  pragma solidity ^0.8.5;
3
3
 
4
4
  // modules
5
+ import {Version} from "../Version.sol";
5
6
  import {LSP6KeyManagerInitAbstract} from "./LSP6KeyManagerInitAbstract.sol";
6
7
 
7
8
  /**
@@ -9,7 +10,7 @@ import {LSP6KeyManagerInitAbstract} from "./LSP6KeyManagerInitAbstract.sol";
9
10
  * @author Fabian Vogelsteller <frozeman>, Jean Cavallera (CJ42), Yamen Merhi (YamenMerhi)
10
11
  * @dev All the permissions can be set on the ERC725 Account using `setData(...)` with the keys constants below
11
12
  */
12
- contract LSP6KeyManagerInit is LSP6KeyManagerInitAbstract {
13
+ contract LSP6KeyManagerInit is LSP6KeyManagerInitAbstract, Version {
13
14
  /**
14
15
  * @notice Deploying a LSP6KeyManagerInit to be used as base contract behind proxy.
15
16
  * @dev Initialize (= lock) base implementation contract on deployment.
@@ -250,16 +250,7 @@ abstract contract LSP6ExecuteModule {
250
250
  revert NoCallsAllowed(controllerAddress);
251
251
  }
252
252
 
253
- bool isEmptyCall = data.length == 0;
254
-
255
- // CHECK if there is at least a 4 bytes function selector
256
- bytes4 selector = data.length >= 4 ? bytes4(data) : bytes4(0);
257
-
258
- bytes4 requiredCallTypes = _extractCallType(
259
- operationType,
260
- value,
261
- isEmptyCall
262
- );
253
+ bytes4 requiredCallTypes = _extractCallType(operationType, value, data);
263
254
 
264
255
  for (uint256 ii; ii < allowedCalls.length; ii += 34) {
265
256
  /// @dev structure of an AllowedCall
@@ -294,11 +285,11 @@ abstract contract LSP6ExecuteModule {
294
285
  _isAllowedCallType(allowedCall, requiredCallTypes) &&
295
286
  _isAllowedAddress(allowedCall, to) &&
296
287
  _isAllowedStandard(allowedCall, to) &&
297
- _isAllowedFunction(allowedCall, selector)
288
+ _isAllowedFunction(allowedCall, data)
298
289
  ) return;
299
290
  }
300
291
 
301
- revert NotAllowedCall(controllerAddress, to, selector);
292
+ revert NotAllowedCall(controllerAddress, to, bytes4(data));
302
293
  }
303
294
 
304
295
  /**
@@ -309,7 +300,7 @@ abstract contract LSP6ExecuteModule {
309
300
  function _extractCallType(
310
301
  uint256 operationType,
311
302
  uint256 value,
312
- bool isEmptyCall
303
+ bytes memory data
313
304
  ) internal pure returns (bytes4 requiredCallTypes) {
314
305
  // if there is value being transferred, add the extra bit
315
306
  // for the first bit for Value Transfer in the `requiredCallTypes`
@@ -317,7 +308,12 @@ abstract contract LSP6ExecuteModule {
317
308
  requiredCallTypes |= _ALLOWEDCALLS_TRANSFERVALUE;
318
309
  }
319
310
 
320
- if (!isEmptyCall) {
311
+ bool isCallDataPresent = data.length != 0;
312
+ bool isEmptyCallWithoutValue = !isCallDataPresent && value == 0;
313
+
314
+ // if we are doing a message call with some data
315
+ // or if we are doing an empty call without value
316
+ if (isCallDataPresent || isEmptyCallWithoutValue) {
321
317
  if (operationType == OPERATION_0_CALL) {
322
318
  requiredCallTypes |= _ALLOWEDCALLS_CALL;
323
319
  } else if (operationType == OPERATION_3_STATICCALL) {
@@ -363,7 +359,7 @@ abstract contract LSP6ExecuteModule {
363
359
 
364
360
  function _isAllowedFunction(
365
361
  bytes memory allowedCall,
366
- bytes4 requiredFunction
362
+ bytes memory data
367
363
  ) internal pure virtual returns (bool) {
368
364
  // <offset> = 28 bytes x 8 bits = 224 bits
369
365
  //
@@ -372,7 +368,9 @@ abstract contract LSP6ExecuteModule {
372
368
  // 0000000ncafecafecafecafecafecafecafecafecafecafe5a5a5a5af1f1f1f1
373
369
  bytes4 allowedFunction = bytes4(bytes32(allowedCall) << 224);
374
370
 
375
- bool isFunctionCall = requiredFunction != bytes4(0);
371
+ bool isFunctionCall = data.length >= 4;
372
+
373
+ bytes4 requiredFunction = bytes4(data);
376
374
 
377
375
  // ANY function = 0xffffffff
378
376
  return
@@ -321,8 +321,12 @@ abstract contract LSP6SetDataModule {
321
321
 
322
322
  // LSP17Extension:<bytes4>
323
323
  } else if (bytes12(inputDataKey) == _LSP17_EXTENSION_PREFIX) {
324
- // CHECK that `dataValue` contains exactly 20 bytes, which corresponds to an address for a LSP17 Extension
325
- if (inputDataValue.length != 20 && inputDataValue.length != 0) {
324
+ // CHECK that `dataValue` contains exactly 20 or 21 bytes (if setting to forward value), which corresponds to an address for a LSP17 Extension
325
+ if (
326
+ inputDataValue.length != 20 &&
327
+ inputDataValue.length != 21 &&
328
+ inputDataValue.length != 0
329
+ ) {
326
330
  revert InvalidDataValuesForDataKeys(
327
331
  inputDataKey,
328
332
  inputDataValue
@@ -39,7 +39,7 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
39
39
  * @param amount The amount of tokens `operator` address has access to from `tokenOwner`
40
40
  * @param operatorNotificationData The data to notify the operator about via LSP1.
41
41
  */
42
- event AuthorizedOperator(
42
+ event OperatorAuthorizationChanged(
43
43
  address indexed operator,
44
44
  address indexed tokenOwner,
45
45
  uint256 indexed amount,
@@ -53,10 +53,10 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
53
53
  * @param notified Bool indicating whether the operator has been notified or not
54
54
  * @param operatorNotificationData The data to notify the operator about via LSP1.
55
55
  */
56
- event RevokedOperator(
56
+ event OperatorRevoked(
57
57
  address indexed operator,
58
58
  address indexed tokenOwner,
59
- bool notified,
59
+ bool indexed notified,
60
60
  bytes operatorNotificationData
61
61
  );
62
62
 
@@ -112,7 +112,7 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
112
112
  * @custom:requirements
113
113
  * - `operator` cannot be the zero address.
114
114
  *
115
- * @custom:events {AuthorizedOperator} when allowance is given to a new operator or
115
+ * @custom:events {OperatorAuthorizationChanged} when allowance is given to a new operator or
116
116
  * an existing operator's allowance is updated.
117
117
  */
118
118
  function authorizeOperator(
@@ -133,7 +133,7 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
133
133
  * - `operator` cannot be calling address.
134
134
  * - `operator` cannot be the zero address.
135
135
  *
136
- * @custom:events {RevokedOperator} event with address of the operator being revoked for the caller (token holder).
136
+ * @custom:events {OperatorRevoked} event with address of the operator being revoked for the caller (token holder).
137
137
  */
138
138
  function revokeOperator(
139
139
  address operator,
@@ -159,7 +159,7 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
159
159
  * - `operator` cannot be the same address as `msg.sender`
160
160
  * - `operator` cannot be the zero address.
161
161
  *
162
- * @custom:events {AuthorizedOperator} indicating the updated allowance
162
+ * @custom:events {OperatorAuthorizationChanged} indicating the updated allowance
163
163
  */
164
164
  function increaseAllowance(
165
165
  address operator,
@@ -179,8 +179,8 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
179
179
  * Notify the operator based on the LSP1-UniversalReceiver standard
180
180
  *
181
181
  * @custom:events
182
- * - {AuthorizedOperator} event indicating the updated allowance after decreasing it.
183
- * - {RevokeOperator} event if `subtractedAmount` is the full allowance,
182
+ * - {OperatorAuthorizationChanged} event indicating the updated allowance after decreasing it.
183
+ * - {OperatorRevoked} event if `subtractedAmount` is the full allowance,
184
184
  * indicating `operator` does not have any alauthorizedAmountForlowance left for `msg.sender`.
185
185
  *
186
186
  * @param operator The operator to decrease allowance for `msg.sender`
@@ -245,7 +245,7 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
245
245
  *
246
246
  * @custom:events
247
247
  * - {Transfer} event when tokens get successfully transferred.
248
- * - if the transfer is triggered by an operator, either the {AuthorizedOperator} event will be emitted with the updated allowance or the {RevokedOperator}
248
+ * - if the transfer is triggered by an operator, either the {OperatorAuthorizationChanged} event will be emitted with the updated allowance or the {OperatorRevoked}
249
249
  * event will be emitted if the operator has no more allowance left.
250
250
  *
251
251
  * @custom:hint The `force` parameter **MUST be set to `true`** to transfer tokens to Externally Owned Accounts (EOAs)
@@ -291,4 +291,15 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
291
291
  bool[] memory force,
292
292
  bytes[] memory data
293
293
  ) external;
294
+
295
+ /**
296
+ * @notice Executing the following batch of abi-encoded function calls on the contract: `data`.
297
+ *
298
+ * @dev Allows a caller to batch different function calls in one call. Perform a `delegatecall` on self, to call different functions with preserving the context.
299
+ * @param data An array of ABI encoded function calls to be called on the contract.
300
+ * @return results An array of abi-encoded data returned by the functions executed.
301
+ */
302
+ function batchCalls(
303
+ bytes[] calldata data
304
+ ) external returns (bytes[] memory results);
294
305
  }
@@ -2,7 +2,7 @@
2
2
  pragma solidity ^0.8.4;
3
3
 
4
4
  // --- ERC165 interface ids
5
- bytes4 constant _INTERFACEID_LSP7 = 0xdaa746b7;
5
+ bytes4 constant _INTERFACEID_LSP7 = 0xb3c4928f;
6
6
 
7
7
  // --- Token Hooks
8
8
 
@@ -47,17 +47,19 @@ abstract contract LSP7DigitalAsset is
47
47
  {
48
48
  /**
49
49
  * @notice Sets the token-Metadata
50
- * @param name_ The name of the token
51
- * @param symbol_ The symbol of the token
52
- * @param newOwner_ The owner of the the token-Metadata
53
- * @param isNonDivisible_ Specify if the LSP7 token is a fungible or non-fungible token
50
+ * @param name_ The name of the token.
51
+ * @param symbol_ The symbol of the token.
52
+ * @param newOwner_ The owner of the the token-Metadata.
53
+ * @param lsp4TokenType_ The type of token this digital asset contract represents (`1` = Token, `2` = NFT, `3` = Collection).
54
+ * @param isNonDivisible_ Specify if the LSP7 token is a fungible or non-fungible token.
54
55
  */
55
56
  constructor(
56
57
  string memory name_,
57
58
  string memory symbol_,
58
59
  address newOwner_,
60
+ uint256 lsp4TokenType_,
59
61
  bool isNonDivisible_
60
- ) LSP4DigitalAssetMetadata(name_, symbol_, newOwner_) {
62
+ ) LSP4DigitalAssetMetadata(name_, symbol_, newOwner_, lsp4TokenType_) {
61
63
  _isNonDivisible = isNonDivisible_;
62
64
  }
63
65