@lukso/lsp-smart-contracts 0.11.1 → 0.12.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 (224) hide show
  1. package/README.md +10 -2
  2. package/artifacts/Create2Factory.json +2 -2
  3. package/artifacts/LSP0ERC725Account.json +68 -47
  4. package/artifacts/LSP0ERC725AccountInit.json +68 -47
  5. package/artifacts/LSP11BasicSocialRecovery.json +18 -2
  6. package/artifacts/LSP11BasicSocialRecoveryInit.json +18 -2
  7. package/artifacts/LSP16UniversalFactory.json +3 -3
  8. package/artifacts/LSP1UniversalReceiverDelegateUP.json +27 -46
  9. package/artifacts/LSP1UniversalReceiverDelegateVault.json +27 -46
  10. package/artifacts/LSP23LinkedContractsFactory.json +3 -3
  11. package/artifacts/LSP4DigitalAssetMetadata.json +16 -0
  12. package/artifacts/LSP4DigitalAssetMetadataInitAbstract.json +16 -0
  13. package/artifacts/LSP6KeyManager.json +34 -6
  14. package/artifacts/LSP6KeyManagerInit.json +34 -6
  15. package/artifacts/LSP7CappedSupply.json +64 -4
  16. package/artifacts/LSP7CappedSupplyInitAbstract.json +64 -4
  17. package/artifacts/LSP7CompatibleERC20.json +83 -23
  18. package/artifacts/LSP7CompatibleERC20InitAbstract.json +83 -23
  19. package/artifacts/LSP7CompatibleERC20Mintable.json +86 -26
  20. package/artifacts/LSP7CompatibleERC20MintableInit.json +86 -26
  21. package/artifacts/LSP7DigitalAsset.json +64 -4
  22. package/artifacts/LSP7DigitalAssetInitAbstract.json +64 -4
  23. package/artifacts/LSP7Mintable.json +67 -7
  24. package/artifacts/LSP7MintableInit.json +67 -7
  25. package/artifacts/LSP8CappedSupply.json +57 -3
  26. package/artifacts/LSP8CappedSupplyInitAbstract.json +57 -3
  27. package/artifacts/LSP8CompatibleERC721.json +79 -25
  28. package/artifacts/LSP8CompatibleERC721InitAbstract.json +79 -25
  29. package/artifacts/LSP8CompatibleERC721Mintable.json +87 -28
  30. package/artifacts/LSP8CompatibleERC721MintableInit.json +87 -28
  31. package/artifacts/LSP8IdentifiableDigitalAsset.json +57 -3
  32. package/artifacts/LSP8IdentifiableDigitalAssetInitAbstract.json +57 -3
  33. package/artifacts/LSP8Mintable.json +65 -6
  34. package/artifacts/LSP8MintableInit.json +65 -6
  35. package/artifacts/LSP9Vault.json +51 -35
  36. package/artifacts/LSP9VaultInit.json +51 -35
  37. package/artifacts/UniversalProfile.json +68 -47
  38. package/artifacts/UniversalProfileInit.json +68 -47
  39. package/contracts/Factories/Create2Factory.sol +1 -1
  40. package/contracts/LSP0ERC725Account/ILSP0ERC725Account.sol +0 -22
  41. package/contracts/LSP0ERC725Account/LSP0Constants.sol +6 -1
  42. package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +12 -2
  43. package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +196 -123
  44. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +1 -1
  45. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +11 -2
  46. package/contracts/LSP10ReceivedVaults/LSP10Utils.sol +5 -3
  47. package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryCore.sol +54 -14
  48. package/contracts/LSP11BasicSocialRecovery/LSP11Constants.sol +1 -1
  49. package/contracts/LSP11BasicSocialRecovery/LSP11Errors.sol +1 -1
  50. package/contracts/LSP14Ownable2Step/ILSP14Ownable2Step.sol +2 -2
  51. package/contracts/LSP14Ownable2Step/LSP14Constants.sol +1 -1
  52. package/contracts/LSP14Ownable2Step/LSP14Errors.sol +9 -3
  53. package/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol +16 -12
  54. package/contracts/LSP16UniversalFactory/LSP16UniversalFactory.sol +65 -96
  55. package/contracts/LSP17ContractExtension/LSP17Errors.sol +1 -1
  56. package/contracts/LSP17ContractExtension/LSP17Extendable.sol +22 -15
  57. package/contracts/LSP17ContractExtension/LSP17Extension.sol +6 -5
  58. package/contracts/LSP17Extensions/Extension4337.sol +101 -0
  59. package/contracts/LSP17Extensions/OnERC721ReceivedExtension.sol +15 -0
  60. package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiver.sol +1 -2
  61. package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiverDelegate.sol +24 -0
  62. package/contracts/LSP1UniversalReceiver/LSP1Constants.sol +1 -0
  63. package/contracts/LSP1UniversalReceiver/LSP1Errors.sol +0 -6
  64. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +49 -33
  65. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +33 -27
  66. package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +5 -48
  67. package/contracts/LSP20CallVerification/ILSP20CallVerifier.sol +13 -9
  68. package/contracts/LSP20CallVerification/LSP20CallVerification.sol +64 -45
  69. package/contracts/LSP20CallVerification/LSP20Constants.sol +6 -6
  70. package/contracts/LSP20CallVerification/LSP20Errors.sol +10 -4
  71. package/contracts/{LSP23LinkedContractsDeployment → LSP23LinkedContractsFactory}/ILSP23LinkedContractsFactory.sol +1 -1
  72. package/contracts/{LSP23LinkedContractsDeployment → LSP23LinkedContractsFactory}/IPostDeploymentModule.sol +1 -1
  73. package/contracts/{LSP23LinkedContractsDeployment → LSP23LinkedContractsFactory}/LSP23Errors.sol +1 -1
  74. package/contracts/{LSP23LinkedContractsDeployment → LSP23LinkedContractsFactory}/LSP23LinkedContractsFactory.sol +5 -1
  75. package/contracts/{LSP23LinkedContractsDeployment → LSP23LinkedContractsFactory}/modules/UniversalProfileInitPostDeploymentModule.sol +1 -1
  76. package/contracts/{LSP23LinkedContractsDeployment → LSP23LinkedContractsFactory}/modules/UniversalProfilePostDeploymentModule.sol +1 -1
  77. package/contracts/LSP25ExecuteRelayCall/LSP25Constants.sol +1 -1
  78. package/contracts/LSP25ExecuteRelayCall/LSP25MultiChannelNonce.sol +8 -3
  79. package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +1 -97
  80. package/contracts/LSP3ProfileMetadata/LSP3Constants.sol +1 -1
  81. package/contracts/LSP4DigitalAssetMetadata/LSP4Constants.sol +1 -1
  82. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol +8 -3
  83. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +8 -3
  84. package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +4 -3
  85. package/contracts/LSP6KeyManager/LSP6Constants.sol +4 -3
  86. package/contracts/LSP6KeyManager/LSP6Errors.sol +2 -23
  87. package/contracts/LSP6KeyManager/LSP6KeyManager.sol +0 -1
  88. package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +176 -101
  89. package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +0 -1
  90. package/contracts/LSP6KeyManager/LSP6Modules/LSP6ExecuteModule.sol +1 -2
  91. package/contracts/LSP6KeyManager/LSP6Modules/LSP6ExecuteRelayCallModule.sol +27 -0
  92. package/contracts/LSP6KeyManager/LSP6Modules/LSP6SetDataModule.sol +34 -28
  93. package/contracts/LSP6KeyManager/LSP6Utils.sol +29 -2
  94. package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +70 -10
  95. package/contracts/LSP7DigitalAsset/LSP7Constants.sol +2 -2
  96. package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +29 -13
  97. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +273 -265
  98. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +28 -12
  99. package/contracts/LSP7DigitalAsset/LSP7Errors.sol +17 -3
  100. package/contracts/LSP7DigitalAsset/extensions/LSP7Burnable.sol +5 -1
  101. package/contracts/LSP7DigitalAsset/extensions/LSP7BurnableInitAbstract.sol +4 -1
  102. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupply.sol +7 -7
  103. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInitAbstract.sol +3 -3
  104. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.sol +128 -54
  105. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20InitAbstract.sol +129 -54
  106. package/contracts/LSP7DigitalAsset/presets/ILSP7Mintable.sol +3 -3
  107. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.sol +4 -4
  108. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInit.sol +2 -2
  109. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInitAbstract.sol +4 -4
  110. package/contracts/LSP7DigitalAsset/presets/LSP7Mintable.sol +4 -4
  111. package/contracts/LSP7DigitalAsset/presets/LSP7MintableInit.sol +1 -1
  112. package/contracts/LSP7DigitalAsset/presets/LSP7MintableInitAbstract.sol +4 -4
  113. package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +16 -11
  114. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol +20 -6
  115. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol +32 -16
  116. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +67 -16
  117. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +143 -137
  118. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +69 -15
  119. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Burnable.sol +1 -1
  120. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8BurnableInitAbstract.sol +1 -1
  121. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.sol +7 -7
  122. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInitAbstract.sol +3 -3
  123. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +172 -80
  124. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +178 -91
  125. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.sol +7 -7
  126. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableInitAbstract.sol +7 -7
  127. package/contracts/LSP8IdentifiableDigitalAsset/presets/ILSP8Mintable.sol +3 -3
  128. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.sol +8 -7
  129. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInit.sol +5 -3
  130. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInitAbstract.sol +13 -7
  131. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.sol +9 -8
  132. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInit.sol +9 -3
  133. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +10 -8
  134. package/contracts/LSP9Vault/ILSP9Vault.sol +0 -21
  135. package/contracts/LSP9Vault/LSP9Constants.sol +6 -1
  136. package/contracts/LSP9Vault/LSP9Errors.sol +1 -1
  137. package/contracts/LSP9Vault/LSP9Vault.sol +11 -2
  138. package/contracts/LSP9Vault/LSP9VaultCore.sol +119 -66
  139. package/contracts/LSP9Vault/LSP9VaultInit.sol +1 -1
  140. package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +11 -2
  141. package/contracts/UniversalProfile.sol +1 -1
  142. package/contracts/UniversalProfileInit.sol +1 -1
  143. package/contracts/UniversalProfileInitAbstract.sol +1 -1
  144. package/contracts/Version.sol +16 -0
  145. package/devdocs/LSP0ERC725Account.json +86 -52
  146. package/devdocs/LSP0ERC725AccountInit.json +86 -52
  147. package/devdocs/LSP11BasicSocialRecovery.json +13 -0
  148. package/devdocs/LSP11BasicSocialRecoveryInit.json +13 -0
  149. package/devdocs/LSP16UniversalFactory.json +9 -9
  150. package/devdocs/LSP1UniversalReceiverDelegateUP.json +7 -6
  151. package/devdocs/LSP1UniversalReceiverDelegateVault.json +7 -6
  152. package/devdocs/LSP4DigitalAssetMetadata.json +32 -10
  153. package/devdocs/LSP4DigitalAssetMetadataInitAbstract.json +32 -10
  154. package/devdocs/LSP6KeyManager.json +27 -13
  155. package/devdocs/LSP6KeyManagerInit.json +27 -13
  156. package/devdocs/LSP7CappedSupply.json +61 -28
  157. package/devdocs/LSP7CappedSupplyInitAbstract.json +61 -28
  158. package/devdocs/LSP7CompatibleERC20.json +102 -32
  159. package/devdocs/LSP7CompatibleERC20InitAbstract.json +102 -32
  160. package/devdocs/LSP7CompatibleERC20Mintable.json +102 -32
  161. package/devdocs/LSP7CompatibleERC20MintableInit.json +102 -32
  162. package/devdocs/LSP7DigitalAsset.json +61 -28
  163. package/devdocs/LSP7DigitalAssetInitAbstract.json +61 -28
  164. package/devdocs/LSP7Mintable.json +61 -28
  165. package/devdocs/LSP7MintableInit.json +61 -28
  166. package/devdocs/LSP8CappedSupply.json +66 -27
  167. package/devdocs/LSP8CappedSupplyInitAbstract.json +66 -27
  168. package/devdocs/LSP8CompatibleERC721.json +93 -33
  169. package/devdocs/LSP8CompatibleERC721InitAbstract.json +93 -33
  170. package/devdocs/LSP8CompatibleERC721Mintable.json +95 -35
  171. package/devdocs/LSP8CompatibleERC721MintableInit.json +96 -36
  172. package/devdocs/LSP8IdentifiableDigitalAsset.json +70 -28
  173. package/devdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +66 -27
  174. package/devdocs/LSP8Mintable.json +68 -29
  175. package/devdocs/LSP8MintableInit.json +69 -30
  176. package/devdocs/LSP9Vault.json +69 -41
  177. package/devdocs/LSP9VaultInit.json +69 -41
  178. package/devdocs/UniversalProfile.json +86 -52
  179. package/devdocs/UniversalProfileInit.json +86 -52
  180. package/dist/constants.cjs.js +5565 -2846
  181. package/dist/constants.d.ts +3996 -1182
  182. package/dist/constants.es.js +5564 -2846
  183. package/package.json +8 -8
  184. package/userdocs/LSP0ERC725Account.json +20 -11
  185. package/userdocs/LSP0ERC725AccountInit.json +20 -11
  186. package/userdocs/LSP16UniversalFactory.json +26 -1
  187. package/userdocs/LSP1UniversalReceiverDelegateUP.json +4 -11
  188. package/userdocs/LSP1UniversalReceiverDelegateVault.json +4 -11
  189. package/userdocs/LSP4DigitalAssetMetadata.json +7 -4
  190. package/userdocs/LSP4DigitalAssetMetadataInitAbstract.json +7 -4
  191. package/userdocs/LSP6KeyManager.json +3 -5
  192. package/userdocs/LSP6KeyManagerInit.json +3 -5
  193. package/userdocs/LSP7CappedSupply.json +17 -6
  194. package/userdocs/LSP7CappedSupplyInitAbstract.json +16 -5
  195. package/userdocs/LSP7CompatibleERC20.json +18 -5
  196. package/userdocs/LSP7CompatibleERC20InitAbstract.json +18 -5
  197. package/userdocs/LSP7CompatibleERC20Mintable.json +18 -5
  198. package/userdocs/LSP7CompatibleERC20MintableInit.json +18 -5
  199. package/userdocs/LSP7DigitalAsset.json +18 -5
  200. package/userdocs/LSP7DigitalAssetInitAbstract.json +18 -5
  201. package/userdocs/LSP7Mintable.json +18 -5
  202. package/userdocs/LSP7MintableInit.json +18 -5
  203. package/userdocs/LSP8CappedSupply.json +16 -5
  204. package/userdocs/LSP8CappedSupplyInitAbstract.json +15 -4
  205. package/userdocs/LSP8CompatibleERC721.json +30 -17
  206. package/userdocs/LSP8CompatibleERC721InitAbstract.json +30 -17
  207. package/userdocs/LSP8CompatibleERC721Mintable.json +31 -18
  208. package/userdocs/LSP8CompatibleERC721MintableInit.json +32 -19
  209. package/userdocs/LSP8IdentifiableDigitalAsset.json +18 -5
  210. package/userdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +17 -4
  211. package/userdocs/LSP8Mintable.json +18 -5
  212. package/userdocs/LSP8MintableInit.json +19 -6
  213. package/userdocs/LSP9Vault.json +23 -14
  214. package/userdocs/LSP9VaultInit.json +23 -14
  215. package/userdocs/UniversalProfile.json +20 -11
  216. package/userdocs/UniversalProfileInit.json +20 -11
  217. package/CONTRIBUTING.md +0 -184
  218. package/artifacts/LSP4Compatibility.json +0 -216
  219. package/contracts/LSP4DigitalAssetMetadata/ILSP4Compatibility.sol +0 -25
  220. package/contracts/LSP4DigitalAssetMetadata/LSP4Compatibility.sol +0 -38
  221. package/contracts/LSP7DigitalAsset/extensions/ILSP7CompatibleERC20.sol +0 -83
  222. package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CompatibleERC721.sol +0 -175
  223. package/devdocs/LSP4Compatibility.json +0 -79
  224. package/userdocs/LSP4Compatibility.json +0 -20
@@ -1,14 +1,17 @@
1
- // SPDX-License-Identifier: CC0-1.0
1
+ // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.4;
3
3
 
4
4
  // interfaces
5
5
  import {
6
- ILSP1UniversalReceiver
6
+ ILSP1UniversalReceiver as ILSP1
7
7
  } from "../LSP1UniversalReceiver/ILSP1UniversalReceiver.sol";
8
8
  import {
9
9
  ILSP8IdentifiableDigitalAsset
10
10
  } from "./ILSP8IdentifiableDigitalAsset.sol";
11
11
 
12
+ // modules
13
+ import {Version} from "../Version.sol";
14
+
12
15
  // libraries
13
16
  import {
14
17
  EnumerableSet
@@ -16,9 +19,24 @@ import {
16
19
  import {
17
20
  ERC165Checker
18
21
  } from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
22
+ import {LSP1Utils} from "../LSP1UniversalReceiver/LSP1Utils.sol";
19
23
 
20
24
  // errors
21
- import "./LSP8Errors.sol";
25
+ import {
26
+ LSP8NonExistentTokenId,
27
+ LSP8NotTokenOwner,
28
+ LSP8CannotUseAddressZeroAsOperator,
29
+ LSP8TokenOwnerCannotBeOperator,
30
+ LSP8OperatorAlreadyAuthorized,
31
+ LSP8NotTokenOperator,
32
+ LSP8InvalidTransferBatch,
33
+ LSP8NonExistingOperator,
34
+ LSP8CannotSendToAddressZero,
35
+ LSP8TokenIdAlreadyMinted,
36
+ LSP8CannotSendToSelf,
37
+ LSP8NotifyTokenReceiverContractMissingLSP1Interface,
38
+ LSP8NotifyTokenReceiverIsEOA
39
+ } from "./LSP8Errors.sol";
22
40
 
23
41
  // constants
24
42
  import {_INTERFACEID_LSP1} from "../LSP1UniversalReceiver/LSP1Constants.sol";
@@ -34,10 +52,13 @@ import {
34
52
  * @dev Core Implementation of a LSP8 compliant contract.
35
53
  */
36
54
  abstract contract LSP8IdentifiableDigitalAssetCore is
37
- ILSP8IdentifiableDigitalAsset
55
+ ILSP8IdentifiableDigitalAsset,
56
+ Version
38
57
  {
39
58
  using EnumerableSet for EnumerableSet.AddressSet;
40
59
  using EnumerableSet for EnumerableSet.Bytes32Set;
60
+ using ERC165Checker for address;
61
+ using LSP1Utils for address;
41
62
 
42
63
  // --- Storage
43
64
 
@@ -59,7 +80,7 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
59
80
  /**
60
81
  * @inheritdoc ILSP8IdentifiableDigitalAsset
61
82
  */
62
- function totalSupply() public view virtual returns (uint256) {
83
+ function totalSupply() public view virtual override returns (uint256) {
63
84
  return _existingTokens;
64
85
  }
65
86
 
@@ -70,7 +91,7 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
70
91
  */
71
92
  function balanceOf(
72
93
  address tokenOwner
73
- ) public view virtual returns (uint256) {
94
+ ) public view virtual override returns (uint256) {
74
95
  return _ownedTokens[tokenOwner].length();
75
96
  }
76
97
 
@@ -79,7 +100,7 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
79
100
  */
80
101
  function tokenOwnerOf(
81
102
  bytes32 tokenId
82
- ) public view virtual returns (address) {
103
+ ) public view virtual override returns (address) {
83
104
  address tokenOwner = _tokenOwners[tokenId];
84
105
 
85
106
  if (tokenOwner == address(0)) {
@@ -94,7 +115,7 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
94
115
  */
95
116
  function tokenIdsOf(
96
117
  address tokenOwner
97
- ) public view virtual returns (bytes32[] memory) {
118
+ ) public view virtual override returns (bytes32[] memory) {
98
119
  return _ownedTokens[tokenOwner].values();
99
120
  }
100
121
 
@@ -107,7 +128,7 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
107
128
  address operator,
108
129
  bytes32 tokenId,
109
130
  bytes memory operatorNotificationData
110
- ) public virtual {
131
+ ) public virtual override {
111
132
  address tokenOwner = tokenOwnerOf(tokenId);
112
133
 
113
134
  if (tokenOwner != msg.sender) {
@@ -135,9 +156,14 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
135
156
  bytes memory lsp1Data = abi.encode(
136
157
  msg.sender,
137
158
  tokenId,
159
+ true, // authorized
138
160
  operatorNotificationData
139
161
  );
140
- _notifyTokenOperator(operator, lsp1Data);
162
+
163
+ operator.tryNotifyUniversalReceiver(
164
+ _TYPEID_LSP8_TOKENOPERATOR,
165
+ lsp1Data
166
+ );
141
167
  }
142
168
 
143
169
  /**
@@ -146,8 +172,9 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
146
172
  function revokeOperator(
147
173
  address operator,
148
174
  bytes32 tokenId,
175
+ bool notify,
149
176
  bytes memory operatorNotificationData
150
- ) public virtual {
177
+ ) public virtual override {
151
178
  address tokenOwner = tokenOwnerOf(tokenId);
152
179
 
153
180
  if (tokenOwner != msg.sender) {
@@ -166,15 +193,23 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
166
193
  operator,
167
194
  tokenOwner,
168
195
  tokenId,
196
+ notify,
169
197
  operatorNotificationData
170
198
  );
171
199
 
172
- bytes memory lsp1Data = abi.encode(
173
- msg.sender,
174
- tokenId,
175
- operatorNotificationData
176
- );
177
- _notifyTokenOperator(operator, lsp1Data);
200
+ if (notify) {
201
+ bytes memory lsp1Data = abi.encode(
202
+ msg.sender,
203
+ tokenId,
204
+ false, // unauthorized
205
+ operatorNotificationData
206
+ );
207
+
208
+ operator.tryNotifyUniversalReceiver(
209
+ _TYPEID_LSP8_TOKENOPERATOR,
210
+ lsp1Data
211
+ );
212
+ }
178
213
  }
179
214
 
180
215
  /**
@@ -183,7 +218,7 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
183
218
  function isOperatorFor(
184
219
  address operator,
185
220
  bytes32 tokenId
186
- ) public view virtual returns (bool) {
221
+ ) public view virtual override returns (bool) {
187
222
  _existsOrError(tokenId);
188
223
 
189
224
  return _isOperatorOrOwner(operator, tokenId);
@@ -194,7 +229,7 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
194
229
  */
195
230
  function getOperatorsOf(
196
231
  bytes32 tokenId
197
- ) public view virtual returns (address[] memory) {
232
+ ) public view virtual override returns (address[] memory) {
198
233
  _existsOrError(tokenId);
199
234
 
200
235
  return _operators[tokenId].values();
@@ -208,9 +243,8 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
208
243
  address caller,
209
244
  bytes32 tokenId
210
245
  ) internal view virtual returns (bool) {
211
- address tokenOwner = tokenOwnerOf(tokenId);
212
-
213
- return (caller == tokenOwner || _operators[tokenId].contains(caller));
246
+ return (caller == tokenOwnerOf(tokenId) ||
247
+ _operators[tokenId].contains(caller));
214
248
  }
215
249
 
216
250
  // --- Transfer functionality
@@ -222,16 +256,14 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
222
256
  address from,
223
257
  address to,
224
258
  bytes32 tokenId,
225
- bool allowNonLSP1Recipient,
259
+ bool force,
226
260
  bytes memory data
227
- ) public virtual {
228
- address operator = msg.sender;
229
-
230
- if (!_isOperatorOrOwner(operator, tokenId)) {
231
- revert LSP8NotTokenOperator(tokenId, operator);
261
+ ) public virtual override {
262
+ if (!_isOperatorOrOwner(msg.sender, tokenId)) {
263
+ revert LSP8NotTokenOperator(tokenId, msg.sender);
232
264
  }
233
265
 
234
- _transfer(from, to, tokenId, allowNonLSP1Recipient, data);
266
+ _transfer(from, to, tokenId, force, data);
235
267
  }
236
268
 
237
269
  /**
@@ -241,27 +273,21 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
241
273
  address[] memory from,
242
274
  address[] memory to,
243
275
  bytes32[] memory tokenId,
244
- bool[] memory allowNonLSP1Recipient,
276
+ bool[] memory force,
245
277
  bytes[] memory data
246
- ) public virtual {
278
+ ) public virtual override {
247
279
  uint256 fromLength = from.length;
248
280
  if (
249
281
  fromLength != to.length ||
250
282
  fromLength != tokenId.length ||
251
- fromLength != allowNonLSP1Recipient.length ||
283
+ fromLength != force.length ||
252
284
  fromLength != data.length
253
285
  ) {
254
286
  revert LSP8InvalidTransferBatch();
255
287
  }
256
288
 
257
- for (uint256 i = 0; i < fromLength; ) {
258
- transfer(
259
- from[i],
260
- to[i],
261
- tokenId[i],
262
- allowNonLSP1Recipient[i],
263
- data[i]
264
- );
289
+ for (uint256 i; i < fromLength; ) {
290
+ transfer(from[i], to[i], tokenId[i], force[i], data[i]);
265
291
 
266
292
  unchecked {
267
293
  ++i;
@@ -276,14 +302,17 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
276
302
  address operator,
277
303
  address tokenOwner,
278
304
  bytes32 tokenId,
305
+ bool notified,
279
306
  bytes memory operatorNotificationData
280
307
  ) internal virtual {
281
308
  bool isRemoved = _operators[tokenId].remove(operator);
282
309
  if (!isRemoved) revert LSP8NonExistingOperator(operator, tokenId);
310
+
283
311
  emit RevokedOperator(
284
312
  operator,
285
313
  tokenOwner,
286
314
  tokenId,
315
+ notified,
287
316
  operatorNotificationData
288
317
  );
289
318
  }
@@ -309,10 +338,11 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
309
338
  ];
310
339
 
311
340
  uint256 operatorListLength = operatorsForTokenId.length();
312
- for (uint256 i = 0; i < operatorListLength; ) {
341
+ address operator;
342
+ for (uint256 i; i < operatorListLength; ) {
313
343
  // we are emptying the list, always remove from index 0
314
- address operator = operatorsForTokenId.at(0);
315
- _revokeOperator(operator, tokenOwner, tokenId, "");
344
+ operator = operatorsForTokenId.at(0);
345
+ _revokeOperator(operator, tokenOwner, tokenId, false, "");
316
346
 
317
347
  unchecked {
318
348
  ++i;
@@ -341,52 +371,50 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
341
371
  /**
342
372
  * @dev Create `tokenId` by minting it and transfers it to `to`.
343
373
  *
344
- * @custom:requirements
345
- * - `tokenId` must not exist and not have been already minted.
346
- * - `to` cannot be the zero address.
374
+ * @custom:info Any logic in the:
375
+ * - {_beforeTokenTransfer} function will run before updating the balances and ownership of `tokenId`s.
376
+ * - {_afterTokenTransfer} function will run after updating the balances and ownership of `tokenId`s, **but before notifying the recipient via LSP1**.
347
377
  *
348
378
  * @param to The address that will receive the minted `tokenId`.
349
379
  * @param tokenId The token ID to create (= mint).
350
- * @param allowNonLSP1Recipient When set to `true`, `to` may be any address. When set to `false`, `to` must be a contract that supports the LSP1 standard.
380
+ * @param force When set to `true`, `to` may be any address. When set to `false`, `to` must be a contract that supports the LSP1 standard.
351
381
  * @param data Any additional data the caller wants included in the emitted event, and sent in the hook of the `to` address.
352
382
  *
383
+ * @custom:requirements
384
+ * - `tokenId` must not exist and not have been already minted.
385
+ * - `to` cannot be the zero address.
386
+
353
387
  * @custom:events {Transfer} event with `address(0)` as `from` address.
354
388
  */
355
389
  function _mint(
356
390
  address to,
357
391
  bytes32 tokenId,
358
- bool allowNonLSP1Recipient,
392
+ bool force,
359
393
  bytes memory data
360
394
  ) internal virtual {
361
395
  if (to == address(0)) {
362
396
  revert LSP8CannotSendToAddressZero();
363
397
  }
364
398
 
399
+ _beforeTokenTransfer(address(0), to, tokenId, data);
400
+
401
+ // Check that `tokenId` was not minted inside the `_beforeTokenTransfer` hook
365
402
  if (_exists(tokenId)) {
366
403
  revert LSP8TokenIdAlreadyMinted(tokenId);
367
404
  }
368
405
 
369
- address operator = msg.sender;
370
-
371
- _beforeTokenTransfer(address(0), to, tokenId);
372
-
373
406
  // token being minted
374
- _existingTokens += 1;
407
+ ++_existingTokens;
375
408
 
376
409
  _ownedTokens[to].add(tokenId);
377
410
  _tokenOwners[tokenId] = to;
378
411
 
379
- emit Transfer(
380
- operator,
381
- address(0),
382
- to,
383
- tokenId,
384
- allowNonLSP1Recipient,
385
- data
386
- );
412
+ emit Transfer(msg.sender, address(0), to, tokenId, force, data);
413
+
414
+ _afterTokenTransfer(address(0), to, tokenId, data);
387
415
 
388
416
  bytes memory lsp1Data = abi.encode(address(0), to, tokenId, data);
389
- _notifyTokenReceiver(to, allowNonLSP1Recipient, lsp1Data);
417
+ _notifyTokenReceiver(to, force, lsp1Data);
390
418
  }
391
419
 
392
420
  /**
@@ -397,7 +425,9 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
397
425
  * function, if it is a contract that supports the LSP1 interface. Its {universalReceiver} function will receive
398
426
  * all the parameters in the calldata packed encoded.
399
427
  *
400
- * Any logic in the {_beforeTokenTransfer} function will run before burning `tokenId` and updating the balances.
428
+ * @custom:info Any logic in the:
429
+ * - {_beforeTokenTransfer} function will run before updating the balances and ownership of `tokenId`s.
430
+ * - {_afterTokenTransfer} function will run after updating the balances and ownership of `tokenId`s, **but before notifying the sender via LSP1**.
401
431
  *
402
432
  * @param tokenId The token to burn.
403
433
  * @param data Any additional data the caller wants included in the emitted event, and sent in the LSP1 hook on the token owner's address.
@@ -411,19 +441,24 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
411
441
  */
412
442
  function _burn(bytes32 tokenId, bytes memory data) internal virtual {
413
443
  address tokenOwner = tokenOwnerOf(tokenId);
414
- address operator = msg.sender;
415
444
 
416
- _beforeTokenTransfer(tokenOwner, address(0), tokenId);
445
+ _beforeTokenTransfer(tokenOwner, address(0), tokenId, data);
446
+
447
+ // Re-fetch and update `tokenOwner` in case `tokenId`
448
+ // was transferred inside the `_beforeTokenTransfer` hook
449
+ tokenOwner = tokenOwnerOf(tokenId);
417
450
 
418
451
  // token being burned
419
- _existingTokens -= 1;
452
+ --_existingTokens;
420
453
 
421
454
  _clearOperators(tokenOwner, tokenId);
422
455
 
423
456
  _ownedTokens[tokenOwner].remove(tokenId);
424
457
  delete _tokenOwners[tokenId];
425
458
 
426
- emit Transfer(operator, tokenOwner, address(0), tokenId, false, data);
459
+ emit Transfer(msg.sender, tokenOwner, address(0), tokenId, false, data);
460
+
461
+ _afterTokenTransfer(tokenOwner, address(0), tokenId, data);
427
462
 
428
463
  bytes memory lsp1Data = abi.encode(
429
464
  tokenOwner,
@@ -431,7 +466,11 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
431
466
  tokenId,
432
467
  data
433
468
  );
434
- _notifyTokenSender(tokenOwner, lsp1Data);
469
+
470
+ tokenOwner.tryNotifyUniversalReceiver(
471
+ _TYPEID_LSP8_TOKENSSENDER,
472
+ lsp1Data
473
+ );
435
474
  }
436
475
 
437
476
  /**
@@ -441,12 +480,14 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
441
480
  * function, if they are contracts that support the LSP1 interface. Their `universalReceiver` function will receive
442
481
  * all the parameters in the calldata packed encoded.
443
482
  *
444
- * Any logic in the {_beforeTokenTransfer} function will run before changing the owner of `tokenId`.
483
+ * @custom:info Any logic in the:
484
+ * - {_beforeTokenTransfer} function will run before updating the balances and ownership of `tokenId`s.
485
+ * - {_afterTokenTransfer} function will run after updating the balances and ownership of `tokenId`s, **but before notifying the sender/recipient via LSP1**.
445
486
  *
446
487
  * @param from The sender address.
447
488
  * @param to The recipient address.
448
489
  * @param tokenId The token to transfer.
449
- * @param allowNonLSP1Recipient When set to `true`, `to` may be any address. When set to `false`, `to` must be a contract that supports the LSP1 standard.
490
+ * @param force When set to `true`, `to` may be any address. When set to `false`, `to` must be a contract that supports the LSP1 standard.
450
491
  * @param data Additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses.
451
492
  *
452
493
  * @custom:requirements
@@ -461,7 +502,7 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
461
502
  address from,
462
503
  address to,
463
504
  bytes32 tokenId,
464
- bool allowNonLSP1Recipient,
505
+ bool force,
465
506
  bytes memory data
466
507
  ) internal virtual {
467
508
  if (from == to) {
@@ -477,9 +518,11 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
477
518
  revert LSP8CannotSendToAddressZero();
478
519
  }
479
520
 
480
- address operator = msg.sender;
521
+ _beforeTokenTransfer(from, to, tokenId, data);
481
522
 
482
- _beforeTokenTransfer(from, to, tokenId);
523
+ // Re-fetch and update `tokenOwner` in case `tokenId`
524
+ // was transferred inside the `_beforeTokenTransfer` hook
525
+ tokenOwner = tokenOwnerOf(tokenId);
483
526
 
484
527
  _clearOperators(from, tokenId);
485
528
 
@@ -487,100 +530,63 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
487
530
  _ownedTokens[to].add(tokenId);
488
531
  _tokenOwners[tokenId] = to;
489
532
 
490
- emit Transfer(operator, from, to, tokenId, allowNonLSP1Recipient, data);
533
+ emit Transfer(msg.sender, from, to, tokenId, force, data);
534
+
535
+ _afterTokenTransfer(from, to, tokenId, data);
491
536
 
492
537
  bytes memory lsp1Data = abi.encode(from, to, tokenId, data);
493
538
 
494
- _notifyTokenSender(from, lsp1Data);
495
- _notifyTokenReceiver(to, allowNonLSP1Recipient, lsp1Data);
539
+ from.tryNotifyUniversalReceiver(_TYPEID_LSP8_TOKENSSENDER, lsp1Data);
540
+ _notifyTokenReceiver(to, force, lsp1Data);
496
541
  }
497
542
 
498
543
  /**
499
544
  * @dev Hook that is called before any token transfer, including minting and burning.
500
- * * Allows to run custom logic before updating balances and notifiying sender/recipient by overriding this function.
545
+ * Allows to run custom logic before updating balances and notifiying sender/recipient by overriding this function.
501
546
  *
502
547
  * @param from The sender address
503
548
  * @param to The recipient address
504
549
  * @param tokenId The tokenId to transfer
550
+ * @param data The data sent alongside the transfer
505
551
  */
506
552
  function _beforeTokenTransfer(
507
553
  address from,
508
554
  address to,
509
- bytes32 tokenId
555
+ bytes32 tokenId,
556
+ bytes memory data // solhint-disable-next-line no-empty-blocks
510
557
  ) internal virtual {}
511
558
 
512
559
  /**
513
- * @dev Attempt to notify the operator `operator` about the `tokenId` tokens being authorized.
514
- * This is done by calling its {universalReceiver} function with the `_TYPEID_LSP8_TOKENOPERATOR` as typeId, if `operator` is a contract that supports the LSP1 interface.
515
- * If `operator` is an EOA or a contract that does not support the LSP1 interface, nothing will happen and no notification will be sent.
516
-
517
- * @param operator The address to call the {universalReceiver} function on.
518
- * @param lsp1Data the data to be sent to the `operator` address in the `universalReceiver` call.
519
- */
520
- function _notifyTokenOperator(
521
- address operator,
522
- bytes memory lsp1Data
523
- ) internal virtual {
524
- if (
525
- ERC165Checker.supportsERC165InterfaceUnchecked(
526
- operator,
527
- _INTERFACEID_LSP1
528
- )
529
- ) {
530
- operator.call(
531
- abi.encodeWithSelector(
532
- ILSP1UniversalReceiver.universalReceiver.selector,
533
- _TYPEID_LSP8_TOKENOPERATOR,
534
- lsp1Data
535
- )
536
- );
537
- }
538
- }
539
-
540
- /**
541
- * @dev An attempt is made to notify the token sender about the `tokenId` changing owners using
542
- * LSP1 interface.
560
+ * @dev Hook that is called after any token transfer, including minting and burning.
561
+ * Allows to run custom logic after updating balances, but **before notifiying sender/recipient via LSP1** by overriding this function.
562
+ *
563
+ * @param from The sender address
564
+ * @param to The recipient address
565
+ * @param tokenId The tokenId to transfer
566
+ * @param data The data sent alongside the transfer
543
567
  */
544
- function _notifyTokenSender(
568
+ function _afterTokenTransfer(
545
569
  address from,
546
- bytes memory lsp1Data
547
- ) internal virtual {
548
- if (
549
- ERC165Checker.supportsERC165InterfaceUnchecked(
550
- from,
551
- _INTERFACEID_LSP1
552
- )
553
- ) {
554
- ILSP1UniversalReceiver(from).universalReceiver(
555
- _TYPEID_LSP8_TOKENSSENDER,
556
- lsp1Data
557
- );
558
- }
559
- }
570
+ address to,
571
+ bytes32 tokenId,
572
+ bytes memory data // solhint-disable-next-line no-empty-blocks
573
+ ) internal virtual {}
560
574
 
561
575
  /**
562
576
  * @dev An attempt is made to notify the token receiver about the `tokenId` changing owners
563
- * using LSP1 interface. When allowNonLSP1Recipient is FALSE the token receiver MUST support LSP1.
577
+ * using LSP1 interface. When force is FALSE the token receiver MUST support LSP1.
564
578
  *
565
579
  * The receiver may revert when the token being sent is not wanted.
566
580
  */
567
581
  function _notifyTokenReceiver(
568
582
  address to,
569
- bool allowNonLSP1Recipient,
583
+ bool force,
570
584
  bytes memory lsp1Data
571
585
  ) internal virtual {
572
- if (
573
- ERC165Checker.supportsERC165InterfaceUnchecked(
574
- to,
575
- _INTERFACEID_LSP1
576
- )
577
- ) {
578
- ILSP1UniversalReceiver(to).universalReceiver(
579
- _TYPEID_LSP8_TOKENSRECIPIENT,
580
- lsp1Data
581
- );
582
- } else if (!allowNonLSP1Recipient) {
583
- if (to.code.length > 0) {
586
+ if (to.supportsERC165InterfaceUnchecked(_INTERFACEID_LSP1)) {
587
+ ILSP1(to).universalReceiver(_TYPEID_LSP8_TOKENSRECIPIENT, lsp1Data);
588
+ } else if (!force) {
589
+ if (to.code.length != 0) {
584
590
  revert LSP8NotifyTokenReceiverContractMissingLSP1Interface(to);
585
591
  } else {
586
592
  revert LSP8NotifyTokenReceiverIsEOA(to);