@lukso/lsp-smart-contracts 0.12.1 → 0.14.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 (131) hide show
  1. package/README.md +3 -2
  2. package/artifacts/LSP0ERC725Account.json +6 -6
  3. package/artifacts/LSP0ERC725AccountInit.json +6 -6
  4. package/artifacts/LSP11BasicSocialRecovery.json +2 -2
  5. package/artifacts/LSP11BasicSocialRecoveryInit.json +2 -2
  6. package/artifacts/LSP1UniversalReceiverDelegateUP.json +2 -2
  7. package/artifacts/LSP1UniversalReceiverDelegateVault.json +2 -2
  8. package/artifacts/LSP4DigitalAssetMetadata.json +5 -0
  9. package/artifacts/LSP4DigitalAssetMetadataInitAbstract.json +5 -0
  10. package/artifacts/LSP6KeyManager.json +2 -2
  11. package/artifacts/LSP6KeyManagerInit.json +2 -2
  12. package/artifacts/LSP7CappedSupply.json +71 -36
  13. package/artifacts/LSP7CappedSupplyInitAbstract.json +71 -36
  14. package/artifacts/LSP7CompatibleERC20.json +71 -36
  15. package/artifacts/LSP7CompatibleERC20InitAbstract.json +71 -36
  16. package/artifacts/LSP7CompatibleERC20Mintable.json +78 -38
  17. package/artifacts/LSP7CompatibleERC20MintableInit.json +78 -38
  18. package/artifacts/LSP7DigitalAsset.json +71 -36
  19. package/artifacts/LSP7DigitalAssetInitAbstract.json +71 -36
  20. package/artifacts/LSP7Mintable.json +78 -38
  21. package/artifacts/LSP7MintableInit.json +78 -38
  22. package/artifacts/LSP8CappedSupply.json +187 -23
  23. package/artifacts/LSP8CappedSupplyInitAbstract.json +200 -36
  24. package/artifacts/LSP8CompatibleERC721.json +187 -23
  25. package/artifacts/LSP8CompatibleERC721InitAbstract.json +200 -36
  26. package/artifacts/LSP8CompatibleERC721Mintable.json +195 -26
  27. package/artifacts/LSP8CompatibleERC721MintableInit.json +208 -39
  28. package/artifacts/LSP8IdentifiableDigitalAsset.json +187 -23
  29. package/artifacts/LSP8IdentifiableDigitalAssetInitAbstract.json +200 -36
  30. package/artifacts/LSP8Mintable.json +195 -26
  31. package/artifacts/LSP8MintableInit.json +208 -39
  32. package/artifacts/LSP9Vault.json +6 -6
  33. package/artifacts/LSP9VaultInit.json +6 -6
  34. package/artifacts/UniversalProfile.json +6 -6
  35. package/artifacts/UniversalProfileInit.json +6 -6
  36. package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +1 -22
  37. package/contracts/LSP17Extensions/Extension4337.sol +26 -1
  38. package/contracts/LSP3ProfileMetadata/LSP3Constants.sol +1 -1
  39. package/contracts/LSP4DigitalAssetMetadata/LSP4Constants.sol +10 -2
  40. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol +20 -34
  41. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataCore.sol +47 -0
  42. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +19 -31
  43. package/contracts/LSP4DigitalAssetMetadata/LSP4Errors.sol +13 -6
  44. package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +1 -1
  45. package/contracts/LSP6KeyManager/LSP6Modules/LSP6SetDataModule.sol +2 -2
  46. package/contracts/LSP6KeyManager/LSP6Utils.sol +1 -1
  47. package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +20 -9
  48. package/contracts/LSP7DigitalAsset/LSP7Constants.sol +1 -1
  49. package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +7 -5
  50. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +128 -25
  51. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +5 -2
  52. package/contracts/LSP7DigitalAsset/LSP7Errors.sol +6 -0
  53. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.sol +4 -2
  54. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20InitAbstract.sol +7 -4
  55. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.sol +4 -2
  56. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInit.sol +5 -2
  57. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInitAbstract.sol +8 -2
  58. package/contracts/LSP7DigitalAsset/presets/LSP7Mintable.sol +12 -1
  59. package/contracts/LSP7DigitalAsset/presets/LSP7MintableInit.sol +4 -0
  60. package/contracts/LSP7DigitalAsset/presets/LSP7MintableInitAbstract.sol +4 -0
  61. package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +77 -5
  62. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol +15 -12
  63. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol +19 -3
  64. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +25 -16
  65. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +223 -19
  66. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +28 -15
  67. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Burnable.sol +1 -1
  68. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8BurnableInitAbstract.sol +1 -1
  69. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.sol +1 -2
  70. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInitAbstract.sol +1 -2
  71. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +15 -4
  72. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +8 -4
  73. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.sol +1 -2
  74. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableInitAbstract.sol +1 -2
  75. package/contracts/LSP8IdentifiableDigitalAsset/presets/ILSP8Mintable.sol +0 -1
  76. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.sol +13 -2
  77. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInit.sol +6 -2
  78. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInitAbstract.sol +4 -2
  79. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.sol +14 -4
  80. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInit.sol +7 -4
  81. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +7 -4
  82. package/contracts/LSP9Vault/LSP9VaultCore.sol +0 -22
  83. package/contracts/Version.sol +1 -1
  84. package/devdocs/LSP4DigitalAssetMetadata.json +11 -5
  85. package/devdocs/LSP4DigitalAssetMetadataInitAbstract.json +7 -2
  86. package/devdocs/LSP6KeyManager.json +1 -1
  87. package/devdocs/LSP6KeyManagerInit.json +1 -1
  88. package/devdocs/LSP7CappedSupply.json +22 -2
  89. package/devdocs/LSP7CappedSupplyInitAbstract.json +22 -2
  90. package/devdocs/LSP7CompatibleERC20.json +23 -2
  91. package/devdocs/LSP7CompatibleERC20InitAbstract.json +22 -2
  92. package/devdocs/LSP7CompatibleERC20Mintable.json +23 -2
  93. package/devdocs/LSP7CompatibleERC20MintableInit.json +24 -3
  94. package/devdocs/LSP7DigitalAsset.json +27 -6
  95. package/devdocs/LSP7DigitalAssetInitAbstract.json +22 -2
  96. package/devdocs/LSP7Mintable.json +24 -2
  97. package/devdocs/LSP7MintableInit.json +25 -3
  98. package/devdocs/LSP8CappedSupply.json +66 -4
  99. package/devdocs/LSP8CappedSupplyInitAbstract.json +66 -4
  100. package/devdocs/LSP8CompatibleERC721.json +69 -5
  101. package/devdocs/LSP8CompatibleERC721InitAbstract.json +67 -5
  102. package/devdocs/LSP8CompatibleERC721Mintable.json +69 -5
  103. package/devdocs/LSP8CompatibleERC721MintableInit.json +70 -6
  104. package/devdocs/LSP8IdentifiableDigitalAsset.json +71 -8
  105. package/devdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +66 -4
  106. package/devdocs/LSP8Mintable.json +68 -4
  107. package/devdocs/LSP8MintableInit.json +69 -5
  108. package/dist/constants.cjs.js +4406 -1319
  109. package/dist/constants.d.ts +4158 -818
  110. package/dist/constants.es.js +4405 -1319
  111. package/package.json +2 -2
  112. package/userdocs/LSP7CappedSupply.json +8 -0
  113. package/userdocs/LSP7CappedSupplyInitAbstract.json +8 -0
  114. package/userdocs/LSP7CompatibleERC20.json +8 -0
  115. package/userdocs/LSP7CompatibleERC20InitAbstract.json +8 -0
  116. package/userdocs/LSP7CompatibleERC20Mintable.json +8 -0
  117. package/userdocs/LSP7CompatibleERC20MintableInit.json +9 -1
  118. package/userdocs/LSP7DigitalAsset.json +8 -0
  119. package/userdocs/LSP7DigitalAssetInitAbstract.json +8 -0
  120. package/userdocs/LSP7Mintable.json +8 -0
  121. package/userdocs/LSP7MintableInit.json +9 -1
  122. package/userdocs/LSP8CappedSupply.json +20 -0
  123. package/userdocs/LSP8CappedSupplyInitAbstract.json +20 -0
  124. package/userdocs/LSP8CompatibleERC721.json +20 -0
  125. package/userdocs/LSP8CompatibleERC721InitAbstract.json +20 -0
  126. package/userdocs/LSP8CompatibleERC721Mintable.json +20 -0
  127. package/userdocs/LSP8CompatibleERC721MintableInit.json +21 -1
  128. package/userdocs/LSP8IdentifiableDigitalAsset.json +21 -1
  129. package/userdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +20 -0
  130. package/userdocs/LSP8Mintable.json +20 -0
  131. package/userdocs/LSP8MintableInit.json +21 -1
@@ -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();
@@ -236,7 +236,7 @@ abstract contract LSP6KeyManagerCore is
236
236
  * @custom:events {PermissionsVerified} event when the permissions related to `payload` have been verified successfully.
237
237
  *
238
238
  * @custom:hint If you are looking to learn how to sign and execute relay transactions via the Key Manager,
239
- * 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).
240
240
  * See the LSP6 Standard page for more details on how to
241
241
  * [generate a valid signature for Execute Relay Call](../../../standards/universal-profile/lsp6-key-manager.md#how-to-sign-relay-transactions).
242
242
  */
@@ -278,9 +278,9 @@ abstract contract LSP6SetDataModule {
278
278
  * @dev more permissions types starting with `AddressPermissions:...` can be implemented by overriding this function.
279
279
  *
280
280
  * // AddressPermissions:MyCustomPermissions:<address>
281
- * bytes12 CUSTOM_PERMISSION_PREFIX = 0x4b80742de2bf9e659ba40000
281
+ * bytes10 CUSTOM_PERMISSION_PREFIX = 0x4b80742de2bf9e659ba4
282
282
  *
283
- * if (bytes12(dataKey) == CUSTOM_PERMISSION_PREFIX) {
283
+ * if (bytes10(dataKey) == CUSTOM_PERMISSION_PREFIX) {
284
284
  * // custom logic
285
285
  * }
286
286
  *
@@ -41,7 +41,7 @@ import {
41
41
  * Based on the LSP6 Key Manager standard.
42
42
  */
43
43
  library LSP6Utils {
44
- using LSP2Utils for bytes12;
44
+ using LSP2Utils for bytes10;
45
45
 
46
46
  /**
47
47
  * @dev Read the permissions of a `caller` on an ERC725Y `target` contract.
@@ -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 (`0` = Token, `1` = NFT, `2` = 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
 
@@ -30,7 +30,8 @@ import {
30
30
  LSP7CannotSendWithAddressZero,
31
31
  LSP7NotifyTokenReceiverContractMissingLSP1Interface,
32
32
  LSP7NotifyTokenReceiverIsEOA,
33
- OperatorAllowanceCannotBeIncreasedFromZero
33
+ OperatorAllowanceCannotBeIncreasedFromZero,
34
+ LSP7BatchCallFailed
34
35
  } from "./LSP7Errors.sol";
35
36
 
36
37
  // constants
@@ -53,8 +54,6 @@ import {
53
54
  */
54
55
  abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
55
56
  using EnumerableSet for EnumerableSet.AddressSet;
56
- using ERC165Checker for address;
57
- using LSP1Utils for address;
58
57
 
59
58
  // --- Storage
60
59
 
@@ -99,6 +98,45 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
99
98
  return _tokenOwnerBalances[tokenOwner];
100
99
  }
101
100
 
101
+ // --- General functionality
102
+
103
+ /**
104
+ * @inheritdoc ILSP7DigitalAsset
105
+ *
106
+ * @custom:info It's not possible to send value along the functions call due to the use of `delegatecall`.
107
+ */
108
+ function batchCalls(
109
+ bytes[] calldata data
110
+ ) public virtual override returns (bytes[] memory results) {
111
+ results = new bytes[](data.length);
112
+ for (uint256 i; i < data.length; ) {
113
+ (bool success, bytes memory result) = address(this).delegatecall(
114
+ data[i]
115
+ );
116
+
117
+ if (!success) {
118
+ // Look for revert reason and bubble it up if present
119
+ if (result.length != 0) {
120
+ // The easiest way to bubble the revert reason is using memory via assembly
121
+ // solhint-disable no-inline-assembly
122
+ /// @solidity memory-safe-assembly
123
+ assembly {
124
+ let returndata_size := mload(result)
125
+ revert(add(32, result), returndata_size)
126
+ }
127
+ } else {
128
+ revert LSP7BatchCallFailed({callIndex: i});
129
+ }
130
+ }
131
+
132
+ results[i] = result;
133
+
134
+ unchecked {
135
+ ++i;
136
+ }
137
+ }
138
+ }
139
+
102
140
  // --- Operator functionality
103
141
 
104
142
  /**
@@ -132,7 +170,7 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
132
170
  operatorNotificationData
133
171
  );
134
172
 
135
- operator.notifyUniversalReceiver(_TYPEID_LSP7_TOKENOPERATOR, lsp1Data);
173
+ _notifyTokenOperator(operator, lsp1Data);
136
174
  }
137
175
 
138
176
  /**
@@ -158,10 +196,7 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
158
196
  operatorNotificationData
159
197
  );
160
198
 
161
- operator.notifyUniversalReceiver(
162
- _TYPEID_LSP7_TOKENOPERATOR,
163
- lsp1Data
164
- );
199
+ _notifyTokenOperator(operator, lsp1Data);
165
200
  }
166
201
  }
167
202
 
@@ -216,7 +251,7 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
216
251
  operatorNotificationData
217
252
  );
218
253
 
219
- operator.notifyUniversalReceiver(_TYPEID_LSP7_TOKENOPERATOR, lsp1Data);
254
+ _notifyTokenOperator(operator, lsp1Data);
220
255
  }
221
256
 
222
257
  /**
@@ -250,7 +285,7 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
250
285
  operatorNotificationData
251
286
  );
252
287
 
253
- operator.notifyUniversalReceiver(_TYPEID_LSP7_TOKENOPERATOR, lsp1Data);
288
+ _notifyTokenOperator(operator, lsp1Data);
254
289
  }
255
290
 
256
291
  // --- Transfer functionality
@@ -320,8 +355,8 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
320
355
  * @param operatorNotificationData The data to send to the universalReceiver function of the operator in case of notifying
321
356
  *
322
357
  * @custom:events
323
- * - {RevokedOperator} event when operator's allowance is set to `0`.
324
- * - {AuthorizedOperator} event when operator's allowance is set to any other amount.
358
+ * - {OperatorRevoked} event when operator's allowance is set to `0`.
359
+ * - {OperatorAuthorizationChanged} event when operator's allowance is set to any other amount.
325
360
  *
326
361
  * @custom:requirements
327
362
  * - `operator` cannot be the zero address.
@@ -346,7 +381,7 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
346
381
 
347
382
  if (allowance != 0) {
348
383
  _operators[tokenOwner].add(operator);
349
- emit AuthorizedOperator(
384
+ emit OperatorAuthorizationChanged(
350
385
  operator,
351
386
  tokenOwner,
352
387
  allowance,
@@ -354,7 +389,7 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
354
389
  );
355
390
  } else {
356
391
  _operators[tokenOwner].remove(operator);
357
- emit RevokedOperator(
392
+ emit OperatorRevoked(
358
393
  operator,
359
394
  tokenOwner,
360
395
  notified,
@@ -397,11 +432,24 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
397
432
 
398
433
  _tokenOwnerBalances[to] += amount;
399
434
 
400
- emit Transfer(msg.sender, address(0), to, amount, force, data);
435
+ emit Transfer({
436
+ operator: msg.sender,
437
+ from: address(0),
438
+ to: to,
439
+ amount: amount,
440
+ force: force,
441
+ data: data
442
+ });
401
443
 
402
444
  _afterTokenTransfer(address(0), to, amount, data);
403
445
 
404
- bytes memory lsp1Data = abi.encode(address(0), to, amount, data);
446
+ bytes memory lsp1Data = abi.encode(
447
+ msg.sender,
448
+ address(0),
449
+ to,
450
+ amount,
451
+ data
452
+ );
405
453
  _notifyTokenReceiver(to, force, lsp1Data);
406
454
  }
407
455
 
@@ -451,7 +499,6 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
451
499
 
452
500
  _tokenOwnerBalances[from] -= amount;
453
501
 
454
- emit Transfer(msg.sender, from, address(0), amount, false, data);
455
502
  emit Transfer({
456
503
  operator: msg.sender,
457
504
  from: from,
@@ -463,8 +510,14 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
463
510
 
464
511
  _afterTokenTransfer(from, address(0), amount, data);
465
512
 
466
- bytes memory lsp1Data = abi.encode(from, address(0), amount, data);
467
- from.notifyUniversalReceiver(_TYPEID_LSP7_TOKENSSENDER, lsp1Data);
513
+ bytes memory lsp1Data = abi.encode(
514
+ msg.sender,
515
+ from,
516
+ address(0),
517
+ amount,
518
+ data
519
+ );
520
+ _notifyTokenSender(from, lsp1Data);
468
521
  }
469
522
 
470
523
  /**
@@ -475,8 +528,8 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
475
528
  * @param amountToSpend The amount of tokens to substract in allowance of `operator`.
476
529
  *
477
530
  * @custom:events
478
- * - {RevokedOperator} event when operator's allowance is set to `0`.
479
- * - {AuthorizedOperator} event when operator's allowance is set to any other amount.
531
+ * - {OperatorRevoked} event when operator's allowance is set to `0`.
532
+ * - {OperatorAuthorizationChanged} event when operator's allowance is set to any other amount.
480
533
  *
481
534
  * @custom:requirements
482
535
  * - The `amountToSpend` MUST be at least the allowance granted to `operator` (accessible via {`authorizedAmountFor}`)
@@ -556,13 +609,20 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
556
609
  _tokenOwnerBalances[from] -= amount;
557
610
  _tokenOwnerBalances[to] += amount;
558
611
 
559
- emit Transfer(msg.sender, from, to, amount, force, data);
612
+ emit Transfer({
613
+ operator: msg.sender,
614
+ from: from,
615
+ to: to,
616
+ amount: amount,
617
+ force: force,
618
+ data: data
619
+ });
560
620
 
561
621
  _afterTokenTransfer(from, to, amount, data);
562
622
 
563
- bytes memory lsp1Data = abi.encode(from, to, amount, data);
623
+ bytes memory lsp1Data = abi.encode(msg.sender, from, to, amount, data);
564
624
 
565
- from.notifyUniversalReceiver(_TYPEID_LSP7_TOKENSSENDER, lsp1Data);
625
+ _notifyTokenSender(from, lsp1Data);
566
626
  _notifyTokenReceiver(to, force, lsp1Data);
567
627
  }
568
628
 
@@ -598,6 +658,44 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
598
658
  bytes memory data // solhint-disable-next-line no-empty-blocks
599
659
  ) internal virtual {}
600
660
 
661
+ /**
662
+ * @dev Attempt to notify the operator `operator` about the `amount` tokens being authorized with.
663
+ * This is done by calling its {universalReceiver} function with the `_TYPEID_LSP7_TOKENOPERATOR` as typeId, if `operator` is a contract that supports the LSP1 interface.
664
+ * If `operator` is an EOA or a contract that does not support the LSP1 interface, nothing will happen and no notification will be sent.
665
+
666
+ * @param operator The address to call the {universalReceiver} function on.
667
+ * @param lsp1Data the data to be sent to the `operator` address in the `universalReceiver` call.
668
+ */
669
+ function _notifyTokenOperator(
670
+ address operator,
671
+ bytes memory lsp1Data
672
+ ) internal virtual {
673
+ LSP1Utils.notifyUniversalReceiver(
674
+ operator,
675
+ _TYPEID_LSP7_TOKENOPERATOR,
676
+ lsp1Data
677
+ );
678
+ }
679
+
680
+ /**
681
+ * @dev Attempt to notify the token sender `from` about the `amount` of tokens being transferred.
682
+ * This is done by calling its {universalReceiver} function with the `_TYPEID_LSP7_TOKENSSENDER` as typeId, if `from` is a contract that supports the LSP1 interface.
683
+ * If `from` is an EOA or a contract that does not support the LSP1 interface, nothing will happen and no notification will be sent.
684
+
685
+ * @param from The address to call the {universalReceiver} function on.
686
+ * @param lsp1Data the data to be sent to the `from` address in the `universalReceiver` call.
687
+ */
688
+ function _notifyTokenSender(
689
+ address from,
690
+ bytes memory lsp1Data
691
+ ) internal virtual {
692
+ LSP1Utils.notifyUniversalReceiver(
693
+ from,
694
+ _TYPEID_LSP7_TOKENSSENDER,
695
+ lsp1Data
696
+ );
697
+ }
698
+
601
699
  /**
602
700
  * @dev Attempt to notify the token receiver `to` about the `amount` tokens being received.
603
701
  * This is done by calling its {universalReceiver} function with the `_TYPEID_LSP7_TOKENSRECIPIENT` as typeId, if `to` is a contract that supports the LSP1 interface.
@@ -615,7 +713,12 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
615
713
  bool force,
616
714
  bytes memory lsp1Data
617
715
  ) internal virtual {
618
- if (to.supportsERC165InterfaceUnchecked(_INTERFACEID_LSP1)) {
716
+ if (
717
+ ERC165Checker.supportsERC165InterfaceUnchecked(
718
+ to,
719
+ _INTERFACEID_LSP1
720
+ )
721
+ ) {
619
722
  ILSP1(to).universalReceiver(_TYPEID_LSP7_TOKENSRECIPIENT, lsp1Data);
620
723
  } else if (!force) {
621
724
  if (to.code.length != 0) {
@@ -46,14 +46,17 @@ abstract contract LSP7DigitalAssetInitAbstract is
46
46
  string memory name_,
47
47
  string memory symbol_,
48
48
  address newOwner_,
49
+ uint256 lsp4TokenType_,
49
50
  bool isNonDivisible_
50
51
  ) internal virtual onlyInitializing {
51
- _isNonDivisible = isNonDivisible_;
52
52
  LSP4DigitalAssetMetadataInitAbstract._initialize(
53
53
  name_,
54
54
  symbol_,
55
- newOwner_
55
+ newOwner_,
56
+ lsp4TokenType_
56
57
  );
58
+
59
+ _isNonDivisible = isNonDivisible_;
57
60
  }
58
61
 
59
62
  // fallback function
@@ -82,3 +82,9 @@ error LSP7TokenContractCannotHoldValue();
82
82
  * @dev Reverts when token owner call {increaseAllowance} for an operator that does not have any allowance
83
83
  */
84
84
  error OperatorAllowanceCannotBeIncreasedFromZero(address operator);
85
+
86
+ /**
87
+ * @dev Reverts when a batch call failed.
88
+ * @notice Batch call failed.
89
+ */
90
+ error LSP7BatchCallFailed(uint256 callIndex);
@@ -27,12 +27,14 @@ abstract contract LSP7CompatibleERC20 is IERC20Metadata, LSP7DigitalAsset {
27
27
  * @param name_ The name of the token.
28
28
  * @param symbol_ The symbol of the token.
29
29
  * @param newOwner_ The owner of the token contract.
30
+ * @param lsp4TokenType_ The type of token this digital asset contract represents (`0` = Token, `1` = NFT, `2` = Collection).
30
31
  */
31
32
  constructor(
32
33
  string memory name_,
33
34
  string memory symbol_,
34
- address newOwner_
35
- ) LSP7DigitalAsset(name_, symbol_, newOwner_, false) {}
35
+ address newOwner_,
36
+ uint256 lsp4TokenType_
37
+ ) LSP7DigitalAsset(name_, symbol_, newOwner_, lsp4TokenType_, false) {}
36
38
 
37
39
  /**
38
40
  * @inheritdoc IERC20Metadata
@@ -30,19 +30,22 @@ abstract contract LSP7CompatibleERC20InitAbstract is
30
30
  * @notice Initializing a `LSP7CompatibleERC20` token contract with: token name = `name_`, token symbol = `symbol_`, and
31
31
  * address `newOwner_` as the token contract owner.
32
32
  *
33
- * @param name_ The name of the token
34
- * @param symbol_ The symbol of the token
35
- * @param newOwner_ The owner of the token
33
+ * @param name_ The name of the token.
34
+ * @param symbol_ The symbol of the token.
35
+ * @param newOwner_ The owner of the token.
36
+ * @param lsp4TokenType_ The type of token this digital asset contract represents (`0` = Token, `1` = NFT, `2` = Collection).
36
37
  */
37
38
  function _initialize(
38
39
  string memory name_,
39
40
  string memory symbol_,
40
- address newOwner_
41
+ address newOwner_,
42
+ uint256 lsp4TokenType_
41
43
  ) internal virtual override onlyInitializing {
42
44
  LSP7DigitalAssetInitAbstract._initialize(
43
45
  name_,
44
46
  symbol_,
45
47
  newOwner_,
48
+ lsp4TokenType_,
46
49
  false
47
50
  );
48
51
  }
@@ -14,12 +14,14 @@ contract LSP7CompatibleERC20Mintable is LSP7CompatibleERC20 {
14
14
  * @param name_ The name of the token.
15
15
  * @param symbol_ The symbol of the token.
16
16
  * @param newOwner_ The owner of the token contract.
17
+ * @param lsp4TokenType_ The type of token this digital asset contract represents (`0` = Token, `1` = NFT, `2` = Collection).
17
18
  */
18
19
  constructor(
19
20
  string memory name_,
20
21
  string memory symbol_,
21
- address newOwner_
22
- ) LSP7CompatibleERC20(name_, symbol_, newOwner_) {}
22
+ address newOwner_,
23
+ uint256 lsp4TokenType_
24
+ ) LSP7CompatibleERC20(name_, symbol_, newOwner_, lsp4TokenType_) {}
23
25
 
24
26
  /**
25
27
  * @dev Public {_mint} function only callable by the {owner}.
@@ -26,16 +26,19 @@ contract LSP7CompatibleERC20MintableInit is
26
26
  * @param name_ The name of the token.
27
27
  * @param symbol_ The symbol of the token.
28
28
  * @param newOwner_ The owner of the token contract.
29
+ * @param lsp4TokenType_ The type of token this digital asset contract represents (`0` = Token, `1` = NFT, `2` = Collection).
29
30
  */
30
31
  function initialize(
31
32
  string memory name_,
32
33
  string memory symbol_,
33
- address newOwner_
34
+ address newOwner_,
35
+ uint256 lsp4TokenType_
34
36
  ) external virtual initializer {
35
37
  LSP7CompatibleERC20MintableInitAbstract._initialize(
36
38
  name_,
37
39
  symbol_,
38
- newOwner_
40
+ newOwner_,
41
+ lsp4TokenType_
39
42
  );
40
43
  }
41
44
  }