@lukso/lsp-smart-contracts 0.7.0 → 0.8.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 (164) hide show
  1. package/CONTRIBUTING.md +31 -0
  2. package/README.md +73 -20
  3. package/artifacts/Create2Factory.json +2 -2
  4. package/artifacts/LSP0ERC725Account.json +194 -15
  5. package/artifacts/LSP0ERC725AccountInit.json +194 -15
  6. package/artifacts/LSP11BasicSocialRecovery.json +493 -0
  7. package/artifacts/LSP11BasicSocialRecoveryInit.json +513 -0
  8. package/artifacts/LSP16UniversalFactory.json +236 -0
  9. package/artifacts/LSP1UniversalReceiverDelegateUP.json +134 -15
  10. package/artifacts/LSP1UniversalReceiverDelegateVault.json +80 -15
  11. package/artifacts/LSP4Compatibility.json +16 -0
  12. package/artifacts/LSP4DigitalAssetMetadata.json +16 -0
  13. package/artifacts/LSP4DigitalAssetMetadataInitAbstract.json +16 -0
  14. package/artifacts/LSP6KeyManager.json +177 -33
  15. package/artifacts/LSP6KeyManagerInit.json +177 -33
  16. package/artifacts/LSP7CappedSupply.json +21 -5
  17. package/artifacts/LSP7CappedSupplyInitAbstract.json +21 -5
  18. package/artifacts/LSP7CompatibleERC20.json +21 -5
  19. package/artifacts/LSP7CompatibleERC20InitAbstract.json +23 -7
  20. package/artifacts/LSP7CompatibleERC20Mintable.json +24 -8
  21. package/artifacts/LSP7CompatibleERC20MintableInit.json +24 -8
  22. package/artifacts/LSP7DigitalAsset.json +21 -5
  23. package/artifacts/LSP7DigitalAssetInitAbstract.json +21 -5
  24. package/artifacts/LSP7Mintable.json +24 -8
  25. package/artifacts/LSP7MintableInit.json +24 -8
  26. package/artifacts/LSP8CappedSupply.json +22 -6
  27. package/artifacts/LSP8CappedSupplyInitAbstract.json +22 -6
  28. package/artifacts/LSP8CompatibleERC721.json +23 -7
  29. package/artifacts/LSP8CompatibleERC721InitAbstract.json +25 -9
  30. package/artifacts/LSP8CompatibleERC721Mintable.json +26 -10
  31. package/artifacts/LSP8CompatibleERC721MintableInit.json +26 -10
  32. package/artifacts/LSP8IdentifiableDigitalAsset.json +22 -6
  33. package/artifacts/LSP8IdentifiableDigitalAssetInitAbstract.json +22 -6
  34. package/artifacts/LSP8Mintable.json +25 -9
  35. package/artifacts/LSP8MintableInit.json +25 -9
  36. package/artifacts/LSP9Vault.json +202 -17
  37. package/artifacts/LSP9VaultInit.json +202 -17
  38. package/artifacts/UniversalProfile.json +194 -15
  39. package/artifacts/UniversalProfileInit.json +194 -15
  40. package/artifacts/UniversalReceiverAddressStore.json +3 -3
  41. package/constants.js +377 -115
  42. package/contracts/Custom/EIP191Signer.sol +12 -0
  43. package/contracts/Factories/Create2Factory.sol +1 -3
  44. package/contracts/LSP0ERC725Account/LSP0Constants.sol +13 -2
  45. package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +2 -1
  46. package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +261 -63
  47. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +2 -2
  48. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +2 -1
  49. package/contracts/LSP10ReceivedVaults/LSP10Constants.sol +2 -2
  50. package/contracts/LSP10ReceivedVaults/LSP10Utils.sol +214 -0
  51. package/contracts/LSP11BasicSocialRecovery/ILSP11BasicSocialRecovery.sol +177 -0
  52. package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecovery.sol +23 -0
  53. package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryCore.sol +258 -0
  54. package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryInit.sol +26 -0
  55. package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryInitAbstract.sol +19 -0
  56. package/contracts/LSP11BasicSocialRecovery/LSP11Constants.sol +6 -0
  57. package/contracts/LSP11BasicSocialRecovery/LSP11Errors.sol +60 -0
  58. package/contracts/LSP14Ownable2Step/ILSP14Ownable2Step.sol +53 -0
  59. package/contracts/LSP14Ownable2Step/LSP14Constants.sol +15 -0
  60. package/contracts/LSP14Ownable2Step/LSP14Errors.sol +12 -0
  61. package/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol +212 -0
  62. package/contracts/LSP16UniversalFactory/LSP16UniversalFactory.sol +246 -0
  63. package/contracts/LSP17ContractExtension/LSP17Constants.sol +17 -0
  64. package/contracts/LSP17ContractExtension/LSP17Errors.sol +7 -0
  65. package/contracts/LSP17ContractExtension/LSP17Extendable.sol +104 -0
  66. package/contracts/LSP17ContractExtension/LSP17Extension.sol +45 -0
  67. package/contracts/LSP17ContractExtension/LSP17Utils.sol +20 -0
  68. package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiver.sol +5 -5
  69. package/contracts/LSP1UniversalReceiver/LSP1Constants.sol +5 -3
  70. package/contracts/LSP1UniversalReceiver/LSP1Errors.sol +21 -0
  71. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +157 -37
  72. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +64 -31
  73. package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +53 -40
  74. package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +45 -23
  75. package/contracts/LSP3UniversalProfile/LSP3Constants.sol +1 -1
  76. package/contracts/LSP4DigitalAssetMetadata/ILSP4Compatibility.sol +1 -1
  77. package/contracts/LSP4DigitalAssetMetadata/LSP4Compatibility.sol +1 -1
  78. package/contracts/LSP4DigitalAssetMetadata/LSP4Constants.sol +1 -1
  79. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol +2 -2
  80. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +2 -2
  81. package/contracts/LSP4DigitalAssetMetadata/LSP4Errors.sol +3 -3
  82. package/contracts/LSP5ReceivedAssets/LSP5Constants.sol +2 -2
  83. package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +102 -114
  84. package/contracts/LSP6KeyManager/ILSP6KeyManager.sol +25 -7
  85. package/contracts/LSP6KeyManager/LSP6Constants.sol +43 -38
  86. package/contracts/LSP6KeyManager/LSP6Errors.sol +90 -21
  87. package/contracts/LSP6KeyManager/LSP6KeyManager.sol +2 -1
  88. package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +772 -364
  89. package/contracts/LSP6KeyManager/LSP6KeyManagerInit.sol +1 -1
  90. package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +3 -2
  91. package/contracts/LSP6KeyManager/LSP6Utils.sol +125 -34
  92. package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +8 -8
  93. package/contracts/LSP7DigitalAsset/LSP7Constants.sol +6 -6
  94. package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +1 -1
  95. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +38 -34
  96. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +1 -1
  97. package/contracts/LSP7DigitalAsset/LSP7Errors.sol +28 -1
  98. package/contracts/LSP7DigitalAsset/extensions/ILSP7CompatibleERC20.sol +1 -1
  99. package/contracts/LSP7DigitalAsset/extensions/LSP7Burnable.sol +24 -0
  100. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupply.sol +28 -8
  101. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInitAbstract.sol +28 -11
  102. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.sol +87 -20
  103. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20InitAbstract.sol +97 -19
  104. package/contracts/LSP7DigitalAsset/presets/ILSP7Mintable.sol +3 -3
  105. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.sol +3 -4
  106. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInit.sol +2 -2
  107. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInitAbstract.sol +3 -3
  108. package/contracts/LSP7DigitalAsset/presets/LSP7Mintable.sol +3 -5
  109. package/contracts/LSP7DigitalAsset/presets/LSP7MintableInit.sol +2 -2
  110. package/contracts/LSP7DigitalAsset/presets/LSP7MintableInitAbstract.sol +3 -3
  111. package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +7 -7
  112. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol +7 -7
  113. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol +40 -2
  114. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +2 -2
  115. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +53 -50
  116. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +1 -1
  117. package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CompatibleERC721.sol +5 -2
  118. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Burnable.sol +20 -0
  119. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.sol +27 -7
  120. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInitAbstract.sol +27 -10
  121. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +236 -30
  122. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +240 -30
  123. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.sol +32 -4
  124. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableInitAbstract.sol +35 -8
  125. package/contracts/LSP8IdentifiableDigitalAsset/presets/ILSP8Mintable.sol +3 -3
  126. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.sol +3 -4
  127. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInit.sol +3 -3
  128. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInitAbstract.sol +3 -3
  129. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.sol +3 -4
  130. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInit.sol +2 -2
  131. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +3 -3
  132. package/contracts/LSP9Vault/LSP9Constants.sol +10 -10
  133. package/contracts/LSP9Vault/LSP9Errors.sol +8 -0
  134. package/contracts/LSP9Vault/LSP9Vault.sol +6 -4
  135. package/contracts/LSP9Vault/LSP9VaultCore.sol +289 -126
  136. package/contracts/LSP9Vault/LSP9VaultInit.sol +2 -2
  137. package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +4 -3
  138. package/contracts/Legacy/Registries/AddressRegistry.sol +1 -1
  139. package/contracts/Legacy/Registries/AddressRegistryRequiresERC725.sol +1 -1
  140. package/contracts/Legacy/UniversalReceiverAddressStore.sol +4 -14
  141. package/contracts/UniversalProfile.sol +2 -2
  142. package/contracts/UniversalProfileInit.sol +2 -2
  143. package/contracts/UniversalProfileInitAbstract.sol +1 -1
  144. package/contracts/Utils/GasLib.sol +1 -1
  145. package/package.json +17 -9
  146. package/artifacts/UniversalFactory.json +0 -127
  147. package/contracts/Custom/ClaimOwnership.sol +0 -96
  148. package/contracts/Custom/ERC165Checker.sol +0 -130
  149. package/contracts/Custom/IClaimOwnership.sol +0 -12
  150. package/contracts/Factories/UniversalFactory.sol +0 -159
  151. package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiverDelegate.sol +0 -24
  152. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/Handling/TokenAndVaultHandling.sol +0 -82
  153. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/Handling/TokenHandling.sol +0 -73
  154. package/contracts/LSP2ERC725YJSONSchema/LSP2Errors.sol +0 -9
  155. package/contracts/LSP7DigitalAsset/extensions/ILSP7CappedSupply.sol +0 -17
  156. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyCore.sol +0 -57
  157. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20Core.sol +0 -111
  158. package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CappedSupply.sol +0 -17
  159. package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8Enumerable.sol +0 -17
  160. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyCore.sol +0 -58
  161. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleConstants.sol +0 -6
  162. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721Core.sol +0 -211
  163. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableCore.sol +0 -50
  164. package/contracts/Utils/UtilsLib.sol +0 -31
@@ -1,16 +1,22 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
 
3
- pragma solidity ^0.8.0;
3
+ pragma solidity ^0.8.4;
4
4
 
5
5
  // modules
6
6
  import {LSP7DigitalAsset} from "../LSP7DigitalAsset.sol";
7
7
  import {LSP7DigitalAssetCore} from "../LSP7DigitalAssetCore.sol";
8
- import {LSP7CappedSupplyCore} from "./LSP7CappedSupplyCore.sol";
9
8
 
10
9
  /**
11
10
  * @dev LSP7 extension, adds token supply cap.
12
11
  */
13
- abstract contract LSP7CappedSupply is LSP7DigitalAsset, LSP7CappedSupplyCore {
12
+ abstract contract LSP7CappedSupply is LSP7DigitalAsset {
13
+ // --- Errors
14
+ error LSP7CappedSupplyRequired();
15
+ error LSP7CappedSupplyCannotMintOverCap();
16
+
17
+ // --- Storage
18
+ uint256 internal _tokenSupplyCap;
19
+
14
20
  /**
15
21
  * @notice Sets the token max supply
16
22
  * @param tokenSupplyCap_ The Token max supply
@@ -23,10 +29,20 @@ abstract contract LSP7CappedSupply is LSP7DigitalAsset, LSP7CappedSupplyCore {
23
29
  _tokenSupplyCap = tokenSupplyCap_;
24
30
  }
25
31
 
26
- // --- Overrides
32
+ // --- Token queries
27
33
 
28
34
  /**
29
- * @dev Mints `amount` tokens and transfers it to `to`.
35
+ * @dev Returns the number of tokens that can be minted
36
+ * @return The number of tokens that can be minted
37
+ */
38
+ function tokenSupplyCap() public view virtual returns (uint256) {
39
+ return _tokenSupplyCap;
40
+ }
41
+
42
+ // --- Transfer functionality
43
+
44
+ /**
45
+ * @dev Mints `amount` and transfers it to `to`.
30
46
  *
31
47
  * Requirements:
32
48
  *
@@ -38,9 +54,13 @@ abstract contract LSP7CappedSupply is LSP7DigitalAsset, LSP7CappedSupplyCore {
38
54
  function _mint(
39
55
  address to,
40
56
  uint256 amount,
41
- bool force,
57
+ bool allowNonLSP1Recipient,
42
58
  bytes memory data
43
- ) internal virtual override(LSP7DigitalAssetCore, LSP7CappedSupplyCore) {
44
- super._mint(to, amount, force, data);
59
+ ) internal virtual override {
60
+ if (totalSupply() + amount > tokenSupplyCap()) {
61
+ revert LSP7CappedSupplyCannotMintOverCap();
62
+ }
63
+
64
+ super._mint(to, amount, allowNonLSP1Recipient, data);
45
65
  }
46
66
  }
@@ -1,19 +1,22 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
 
3
- pragma solidity ^0.8.0;
3
+ pragma solidity ^0.8.4;
4
4
 
5
5
  // modules
6
6
  import {LSP7DigitalAssetInitAbstract} from "../LSP7DigitalAssetInitAbstract.sol";
7
7
  import {LSP7DigitalAssetCore} from "../LSP7DigitalAssetCore.sol";
8
- import {LSP7CappedSupplyCore} from "./LSP7CappedSupplyCore.sol";
9
8
 
10
9
  /**
11
10
  * @dev LSP7 extension, adds token supply cap.
12
11
  */
13
- abstract contract LSP7CappedSupplyInitAbstract is
14
- LSP7DigitalAssetInitAbstract,
15
- LSP7CappedSupplyCore
16
- {
12
+ abstract contract LSP7CappedSupplyInitAbstract is LSP7DigitalAssetInitAbstract {
13
+ // --- Errors
14
+ error LSP7CappedSupplyRequired();
15
+ error LSP7CappedSupplyCannotMintOverCap();
16
+
17
+ // --- Storage
18
+ uint256 internal _tokenSupplyCap;
19
+
17
20
  function _initialize(uint256 tokenSupplyCap_) internal virtual onlyInitializing {
18
21
  if (tokenSupplyCap_ == 0) {
19
22
  revert LSP7CappedSupplyRequired();
@@ -22,10 +25,20 @@ abstract contract LSP7CappedSupplyInitAbstract is
22
25
  _tokenSupplyCap = tokenSupplyCap_;
23
26
  }
24
27
 
25
- // --- Overrides
28
+ // --- Token queries
26
29
 
27
30
  /**
28
- * @dev Mints `amount` tokens and transfers it to `to`.
31
+ * @dev Returns the number of tokens that can be minted
32
+ * @return The number of tokens that can be minted
33
+ */
34
+ function tokenSupplyCap() public view virtual returns (uint256) {
35
+ return _tokenSupplyCap;
36
+ }
37
+
38
+ // --- Transfer functionality
39
+
40
+ /**
41
+ * @dev Mints `amount` and transfers it to `to`.
29
42
  *
30
43
  * Requirements:
31
44
  *
@@ -37,9 +50,13 @@ abstract contract LSP7CappedSupplyInitAbstract is
37
50
  function _mint(
38
51
  address to,
39
52
  uint256 amount,
40
- bool force,
53
+ bool allowNonLSP1Recipient,
41
54
  bytes memory data
42
- ) internal virtual override(LSP7DigitalAssetCore, LSP7CappedSupplyCore) {
43
- super._mint(to, amount, force, data);
55
+ ) internal virtual override {
56
+ if (totalSupply() + amount > tokenSupplyCap()) {
57
+ revert LSP7CappedSupplyCannotMintOverCap();
58
+ }
59
+
60
+ super._mint(to, amount, allowNonLSP1Recipient, data);
44
61
  }
45
62
  }
@@ -1,13 +1,20 @@
1
1
  // SPDX-License-Identifier: MIT
2
- pragma solidity ^0.8.0;
2
+ pragma solidity ^0.8.12;
3
+
4
+ // interfaces
5
+ import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
6
+ import {ILSP7CompatibleERC20} from "./ILSP7CompatibleERC20.sol";
7
+ import {ILSP7DigitalAsset} from "../ILSP7DigitalAsset.sol";
3
8
 
4
9
  // modules
10
+ import {LSP4Compatibility} from "../../LSP4DigitalAssetMetadata/LSP4Compatibility.sol";
5
11
  import {LSP7DigitalAsset, LSP4DigitalAssetMetadata, ERC725YCore} from "../LSP7DigitalAsset.sol";
6
12
  import {LSP7DigitalAssetCore} from "../LSP7DigitalAssetCore.sol";
7
- import {LSP7CompatibleERC20Core} from "./LSP7CompatibleERC20Core.sol";
8
13
 
9
- abstract contract LSP7CompatibleERC20 is LSP7DigitalAsset, LSP7CompatibleERC20Core {
10
- /* solhint-disable no-empty-blocks */
14
+ /**
15
+ * @dev LSP7 extension, for compatibility for clients / tools that expect ERC20.
16
+ */
17
+ abstract contract LSP7CompatibleERC20 is ILSP7CompatibleERC20, LSP4Compatibility, LSP7DigitalAsset {
11
18
  /**
12
19
  * @notice Sets the name, the symbol and the owner of the token
13
20
  * @param name_ The name of the token
@@ -20,41 +27,101 @@ abstract contract LSP7CompatibleERC20 is LSP7DigitalAsset, LSP7CompatibleERC20Co
20
27
  address newOwner_
21
28
  ) LSP7DigitalAsset(name_, symbol_, newOwner_, false) {}
22
29
 
23
- // --- Overrides
24
-
25
- function authorizeOperator(address operator, uint256 amount)
30
+ /**
31
+ * @dev See {IERC165-supportsInterface}.
32
+ */
33
+ function supportsInterface(bytes4 interfaceId)
26
34
  public
35
+ view
27
36
  virtual
28
- override(LSP7DigitalAssetCore, LSP7CompatibleERC20Core)
37
+ override(IERC165, ERC725YCore, LSP7DigitalAsset)
38
+ returns (bool)
29
39
  {
30
- super.authorizeOperator(operator, amount);
40
+ return super.supportsInterface(interfaceId);
31
41
  }
32
42
 
33
- function _burn(
43
+ /**
44
+ * @inheritdoc ILSP7CompatibleERC20
45
+ */
46
+ function allowance(address tokenOwner, address operator) public view virtual returns (uint256) {
47
+ return authorizedAmountFor(operator, tokenOwner);
48
+ }
49
+
50
+ /**
51
+ * @inheritdoc ILSP7CompatibleERC20
52
+ */
53
+ function approve(address operator, uint256 amount) public virtual returns (bool) {
54
+ authorizeOperator(operator, amount);
55
+ return true;
56
+ }
57
+
58
+ /**
59
+ * @inheritdoc ILSP7CompatibleERC20
60
+ * @dev Compatible with ERC20 transferFrom.
61
+ * Using allowNonLSP1Recipient=true so that EOA and any contract may receive the tokens.
62
+ */
63
+ function transferFrom(
34
64
  address from,
65
+ address to,
66
+ uint256 amount
67
+ ) public virtual returns (bool) {
68
+ transfer(from, to, amount, true, "");
69
+ return true;
70
+ }
71
+
72
+ // --- Overrides
73
+
74
+ /**
75
+ * @inheritdoc ILSP7CompatibleERC20
76
+ * @dev Compatible with ERC20 transfer.
77
+ * Using allowNonLSP1Recipient=true so that EOA and any contract may receive the tokens.
78
+ */
79
+ function transfer(address to, uint256 amount) public virtual override returns (bool) {
80
+ transfer(msg.sender, to, amount, true, "");
81
+ return true;
82
+ }
83
+
84
+ /**
85
+ * @dev same behaviour as LSP7DigitalAssetCore
86
+ * with the addition of emitting ERC20 Approval event.
87
+ */
88
+ function _updateOperator(
89
+ address tokenOwner,
90
+ address operator,
91
+ uint256 amount
92
+ ) internal virtual override {
93
+ super._updateOperator(tokenOwner, operator, amount);
94
+ emit Approval(tokenOwner, operator, amount);
95
+ }
96
+
97
+ function _transfer(
98
+ address from,
99
+ address to,
35
100
  uint256 amount,
101
+ bool allowNonLSP1Recipient,
36
102
  bytes memory data
37
- ) internal virtual override(LSP7DigitalAssetCore, LSP7CompatibleERC20Core) {
38
- super._burn(from, amount, data);
103
+ ) internal virtual override {
104
+ super._transfer(from, to, amount, allowNonLSP1Recipient, data);
105
+ emit Transfer(from, to, amount);
39
106
  }
40
107
 
41
108
  function _mint(
42
109
  address to,
43
110
  uint256 amount,
44
- bool force,
111
+ bool allowNonLSP1Recipient,
45
112
  bytes memory data
46
- ) internal virtual override(LSP7DigitalAssetCore, LSP7CompatibleERC20Core) {
47
- super._mint(to, amount, force, data);
113
+ ) internal virtual override {
114
+ super._mint(to, amount, allowNonLSP1Recipient, data);
115
+ emit Transfer(address(0), to, amount);
48
116
  }
49
117
 
50
- function _transfer(
118
+ function _burn(
51
119
  address from,
52
- address to,
53
120
  uint256 amount,
54
- bool force,
55
121
  bytes memory data
56
- ) internal virtual override(LSP7DigitalAssetCore, LSP7CompatibleERC20Core) {
57
- super._transfer(from, to, amount, force, data);
122
+ ) internal virtual override {
123
+ super._burn(from, amount, data);
124
+ emit Transfer(from, address(0), amount);
58
125
  }
59
126
 
60
127
  function _setData(bytes32 key, bytes memory value)
@@ -1,17 +1,35 @@
1
1
  // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.12;
2
3
 
3
- pragma solidity ^0.8.0;
4
+ // interfaces
5
+ import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
6
+ import {ILSP7CompatibleERC20} from "./ILSP7CompatibleERC20.sol";
7
+ import {ILSP7DigitalAsset} from "../ILSP7DigitalAsset.sol";
4
8
 
5
9
  // modules
10
+ import {LSP4Compatibility} from "../../LSP4DigitalAssetMetadata/LSP4Compatibility.sol";
6
11
  import {
7
12
  LSP7DigitalAssetInitAbstract,
8
13
  LSP4DigitalAssetMetadataInitAbstract,
9
14
  ERC725YCore
10
15
  } from "../LSP7DigitalAssetInitAbstract.sol";
11
16
  import {LSP7DigitalAssetCore} from "../LSP7DigitalAssetCore.sol";
12
- import {LSP7CompatibleERC20Core} from "./LSP7CompatibleERC20Core.sol";
13
17
 
14
- contract LSP7CompatibleERC20InitAbstract is LSP7DigitalAssetInitAbstract, LSP7CompatibleERC20Core {
18
+ /**
19
+ * @dev LSP7 extension, for compatibility for clients / tools that expect ERC20.
20
+ */
21
+ abstract contract LSP7CompatibleERC20InitAbstract is
22
+ ILSP7CompatibleERC20,
23
+ LSP4Compatibility,
24
+ LSP7DigitalAssetInitAbstract
25
+ {
26
+ /**
27
+ * @notice Sets the name, the symbol and the owner of the token
28
+ * @param name_ The name of the token
29
+ * @param symbol_ The symbol of the token
30
+ * @param newOwner_ The owner of the token
31
+ */
32
+
15
33
  function _initialize(
16
34
  string memory name_,
17
35
  string memory symbol_,
@@ -20,41 +38,101 @@ contract LSP7CompatibleERC20InitAbstract is LSP7DigitalAssetInitAbstract, LSP7Co
20
38
  LSP7DigitalAssetInitAbstract._initialize(name_, symbol_, newOwner_, false);
21
39
  }
22
40
 
23
- // --- Overrides
24
-
25
- function authorizeOperator(address operator, uint256 amount)
41
+ /**
42
+ * @dev See {IERC165-supportsInterface}.
43
+ */
44
+ function supportsInterface(bytes4 interfaceId)
26
45
  public
46
+ view
27
47
  virtual
28
- override(LSP7DigitalAssetCore, LSP7CompatibleERC20Core)
48
+ override(IERC165, ERC725YCore, LSP7DigitalAssetInitAbstract)
49
+ returns (bool)
29
50
  {
30
- super.authorizeOperator(operator, amount);
51
+ return super.supportsInterface(interfaceId);
31
52
  }
32
53
 
33
- function _burn(
54
+ /**
55
+ * @inheritdoc ILSP7CompatibleERC20
56
+ */
57
+ function allowance(address tokenOwner, address operator) public view virtual returns (uint256) {
58
+ return authorizedAmountFor(operator, tokenOwner);
59
+ }
60
+
61
+ /**
62
+ * @inheritdoc ILSP7CompatibleERC20
63
+ */
64
+ function approve(address operator, uint256 amount) public virtual returns (bool) {
65
+ authorizeOperator(operator, amount);
66
+ return true;
67
+ }
68
+
69
+ /**
70
+ * @inheritdoc ILSP7CompatibleERC20
71
+ * @dev Compatible with ERC20 transferFrom.
72
+ * Using allowNonLSP1Recipient=true so that EOA and any contract may receive the tokens.
73
+ */
74
+ function transferFrom(
34
75
  address from,
76
+ address to,
77
+ uint256 amount
78
+ ) public virtual returns (bool) {
79
+ transfer(from, to, amount, true, "");
80
+ return true;
81
+ }
82
+
83
+ // --- Overrides
84
+
85
+ /**
86
+ * @inheritdoc ILSP7CompatibleERC20
87
+ * @dev Compatible with ERC20 transfer.
88
+ * Using allowNonLSP1Recipient=true so that EOA and any contract may receive the tokens.
89
+ */
90
+ function transfer(address to, uint256 amount) public virtual override returns (bool) {
91
+ transfer(msg.sender, to, amount, true, "");
92
+ return true;
93
+ }
94
+
95
+ /**
96
+ * @dev same behaviour as LSP7DigitalAssetCore
97
+ * with the addition of emitting ERC20 Approval event.
98
+ */
99
+ function _updateOperator(
100
+ address tokenOwner,
101
+ address operator,
102
+ uint256 amount
103
+ ) internal virtual override {
104
+ super._updateOperator(tokenOwner, operator, amount);
105
+ emit Approval(tokenOwner, operator, amount);
106
+ }
107
+
108
+ function _transfer(
109
+ address from,
110
+ address to,
35
111
  uint256 amount,
112
+ bool allowNonLSP1Recipient,
36
113
  bytes memory data
37
- ) internal virtual override(LSP7DigitalAssetCore, LSP7CompatibleERC20Core) {
38
- super._burn(from, amount, data);
114
+ ) internal virtual override {
115
+ super._transfer(from, to, amount, allowNonLSP1Recipient, data);
116
+ emit Transfer(from, to, amount);
39
117
  }
40
118
 
41
119
  function _mint(
42
120
  address to,
43
121
  uint256 amount,
44
- bool force,
122
+ bool allowNonLSP1Recipient,
45
123
  bytes memory data
46
- ) internal virtual override(LSP7DigitalAssetCore, LSP7CompatibleERC20Core) {
47
- super._mint(to, amount, force, data);
124
+ ) internal virtual override {
125
+ super._mint(to, amount, allowNonLSP1Recipient, data);
126
+ emit Transfer(address(0), to, amount);
48
127
  }
49
128
 
50
- function _transfer(
129
+ function _burn(
51
130
  address from,
52
- address to,
53
131
  uint256 amount,
54
- bool force,
55
132
  bytes memory data
56
- ) internal virtual override(LSP7DigitalAssetCore, LSP7CompatibleERC20Core) {
57
- super._transfer(from, to, amount, force, data);
133
+ ) internal virtual override {
134
+ super._burn(from, amount, data);
135
+ emit Transfer(from, address(0), amount);
58
136
  }
59
137
 
60
138
  function _setData(bytes32 key, bytes memory value)
@@ -1,6 +1,6 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
 
3
- pragma solidity ^0.8.0;
3
+ pragma solidity ^0.8.4;
4
4
 
5
5
  // interfaces
6
6
  import {ILSP7DigitalAsset} from "../ILSP7DigitalAsset.sol";
@@ -12,7 +12,7 @@ interface ILSP7Mintable is ILSP7DigitalAsset {
12
12
  /**
13
13
  * @param to The address to mint tokens
14
14
  * @param amount The amount to mint
15
- * @param force When set to TRUE, to may be any address but
15
+ * @param allowNonLSP1Recipient When set to TRUE, to may be any address but
16
16
  * when set to FALSE to must be a contract that supports LSP1 UniversalReceiver
17
17
  * @param data Additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses.
18
18
  * @dev Mints `amount` tokens and transfers it to `to`.
@@ -26,7 +26,7 @@ interface ILSP7Mintable is ILSP7DigitalAsset {
26
26
  function mint(
27
27
  address to,
28
28
  uint256 amount,
29
- bool force,
29
+ bool allowNonLSP1Recipient,
30
30
  bytes memory data
31
31
  ) external;
32
32
  }
@@ -1,10 +1,9 @@
1
1
  // SPDX-License-Identifier: MIT
2
- pragma solidity ^0.8.0;
2
+ pragma solidity ^0.8.12;
3
3
 
4
4
  import {LSP7CompatibleERC20} from "../extensions/LSP7CompatibleERC20.sol";
5
5
 
6
6
  contract LSP7CompatibleERC20Mintable is LSP7CompatibleERC20 {
7
- /* solhint-disable no-empty-blocks */
8
7
  constructor(
9
8
  string memory name_,
10
9
  string memory symbol_,
@@ -14,9 +13,9 @@ contract LSP7CompatibleERC20Mintable is LSP7CompatibleERC20 {
14
13
  function mint(
15
14
  address to,
16
15
  uint256 amount,
17
- bool force,
16
+ bool allowNonLSP1Recipient,
18
17
  bytes memory data
19
18
  ) public onlyOwner {
20
- _mint(to, amount, force, data);
19
+ _mint(to, amount, allowNonLSP1Recipient, data);
21
20
  }
22
21
  }
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: MIT
2
- pragma solidity ^0.8.0;
2
+ pragma solidity ^0.8.12;
3
3
 
4
4
  // modules
5
5
  import {
@@ -24,7 +24,7 @@ contract LSP7CompatibleERC20MintableInit is LSP7CompatibleERC20MintableInitAbstr
24
24
  string memory name_,
25
25
  string memory symbol_,
26
26
  address newOwner_
27
- ) public virtual initializer {
27
+ ) external virtual initializer {
28
28
  LSP7CompatibleERC20MintableInitAbstract._initialize(name_, symbol_, newOwner_);
29
29
  }
30
30
  }
@@ -1,5 +1,5 @@
1
1
  // SPDX-License-Identifier: MIT
2
- pragma solidity ^0.8.0;
2
+ pragma solidity ^0.8.12;
3
3
 
4
4
  // modules
5
5
  import {LSP7CompatibleERC20InitAbstract} from "../extensions/LSP7CompatibleERC20InitAbstract.sol";
@@ -19,9 +19,9 @@ contract LSP7CompatibleERC20MintableInitAbstract is LSP7CompatibleERC20InitAbstr
19
19
  function mint(
20
20
  address to,
21
21
  uint256 amount,
22
- bool force,
22
+ bool allowNonLSP1Recipient,
23
23
  bytes memory data
24
24
  ) public onlyOwner {
25
- _mint(to, amount, force, data);
25
+ _mint(to, amount, allowNonLSP1Recipient, data);
26
26
  }
27
27
  }
@@ -1,6 +1,6 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
 
3
- pragma solidity ^0.8.0;
3
+ pragma solidity ^0.8.4;
4
4
 
5
5
  // interfaces
6
6
  import {ILSP7Mintable} from "./ILSP7Mintable.sol";
@@ -14,8 +14,6 @@ import {LSP7DigitalAsset} from "../LSP7DigitalAsset.sol";
14
14
  * @dev LSP7 extension, mintable.
15
15
  */
16
16
  contract LSP7Mintable is LSP7DigitalAsset, ILSP7Mintable {
17
- // solhint-disable no-empty-blocks
18
-
19
17
  /**
20
18
  * @notice Sets the token-Metadata and register LSP7InterfaceId
21
19
  * @param name_ The name of the token
@@ -36,9 +34,9 @@ contract LSP7Mintable is LSP7DigitalAsset, ILSP7Mintable {
36
34
  function mint(
37
35
  address to,
38
36
  uint256 amount,
39
- bool force,
37
+ bool allowNonLSP1Recipient,
40
38
  bytes memory data
41
39
  ) public virtual onlyOwner {
42
- _mint(to, amount, force, data);
40
+ _mint(to, amount, allowNonLSP1Recipient, data);
43
41
  }
44
42
  }
@@ -1,6 +1,6 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
 
3
- pragma solidity ^0.8.0;
3
+ pragma solidity ^0.8.4;
4
4
 
5
5
  // modules
6
6
  import {LSP7MintableInitAbstract} from "./LSP7MintableInitAbstract.sol";
@@ -28,7 +28,7 @@ contract LSP7MintableInit is LSP7MintableInitAbstract {
28
28
  string memory symbol_,
29
29
  address newOwner_,
30
30
  bool isNonDivisible_
31
- ) public virtual initializer {
31
+ ) external virtual initializer {
32
32
  LSP7MintableInitAbstract._initialize(name_, symbol_, newOwner_, isNonDivisible_);
33
33
  }
34
34
  }
@@ -1,6 +1,6 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
 
3
- pragma solidity ^0.8.0;
3
+ pragma solidity ^0.8.4;
4
4
 
5
5
  // interfaces
6
6
  import {ILSP7Mintable} from "./ILSP7Mintable.sol";
@@ -27,9 +27,9 @@ abstract contract LSP7MintableInitAbstract is LSP7DigitalAssetInitAbstract, ILSP
27
27
  function mint(
28
28
  address to,
29
29
  uint256 amount,
30
- bool force,
30
+ bool allowNonLSP1Recipient,
31
31
  bytes memory data
32
32
  ) public virtual onlyOwner {
33
- _mint(to, amount, force, data);
33
+ _mint(to, amount, allowNonLSP1Recipient, data);
34
34
  }
35
35
  }
@@ -1,6 +1,6 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
 
3
- pragma solidity ^0.8.0;
3
+ pragma solidity ^0.8.4;
4
4
 
5
5
  // interfaces
6
6
  import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
@@ -18,7 +18,7 @@ interface ILSP8IdentifiableDigitalAsset is IERC165, IERC725Y {
18
18
  * @param from The address which tokens are sent
19
19
  * @param to The receiving address
20
20
  * @param tokenId The tokenId transferred
21
- * @param force When set to TRUE, `to` may be any address but
21
+ * @param allowNonLSP1Recipient When set to TRUE, `to` may be any address but
22
22
  * when set to FALSE `to` must be a contract that supports LSP1 UniversalReceiver
23
23
  * @param data Additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses
24
24
  */
@@ -27,7 +27,7 @@ interface ILSP8IdentifiableDigitalAsset is IERC165, IERC725Y {
27
27
  address indexed from,
28
28
  address indexed to,
29
29
  bytes32 indexed tokenId,
30
- bool force,
30
+ bool allowNonLSP1Recipient,
31
31
  bytes data
32
32
  );
33
33
 
@@ -159,7 +159,7 @@ interface ILSP8IdentifiableDigitalAsset is IERC165, IERC725Y {
159
159
  * @param from The sending address.
160
160
  * @param to The receiving address.
161
161
  * @param tokenId The tokenId to transfer.
162
- * @param force When set to TRUE, to may be any address but
162
+ * @param allowNonLSP1Recipient When set to TRUE, to may be any address but
163
163
  * when set to FALSE to must be a contract that supports LSP1 UniversalReceiver
164
164
  * @param data Additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses.
165
165
  * @dev Transfers `tokenId` token from `from` to `to`.
@@ -178,7 +178,7 @@ interface ILSP8IdentifiableDigitalAsset is IERC165, IERC725Y {
178
178
  address from,
179
179
  address to,
180
180
  bytes32 tokenId,
181
- bool force,
181
+ bool allowNonLSP1Recipient,
182
182
  bytes memory data
183
183
  ) external;
184
184
 
@@ -186,7 +186,7 @@ interface ILSP8IdentifiableDigitalAsset is IERC165, IERC725Y {
186
186
  * @param from The list of sending addresses.
187
187
  * @param to The list of receiving addresses.
188
188
  * @param tokenId The list of tokenId to transfer.
189
- * @param force When set to TRUE, to may be any address but
189
+ * @param allowNonLSP1Recipient When set to TRUE, to may be any address but
190
190
  * when set to FALSE to must be a contract that supports LSP1 UniversalReceiver
191
191
  * @param data Additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses.
192
192
  *
@@ -208,7 +208,7 @@ interface ILSP8IdentifiableDigitalAsset is IERC165, IERC725Y {
208
208
  address[] memory from,
209
209
  address[] memory to,
210
210
  bytes32[] memory tokenId,
211
- bool force,
211
+ bool[] memory allowNonLSP1Recipient,
212
212
  bytes[] memory data
213
213
  ) external;
214
214
  }
@@ -1,10 +1,10 @@
1
1
  // SPDX-License-Identifier: CC0-1.0
2
- pragma solidity ^0.8.0;
2
+ pragma solidity ^0.8.4;
3
3
 
4
4
  // --- ERC165 interface ids
5
- bytes4 constant _INTERFACEID_LSP8 = 0x49399145;
5
+ bytes4 constant _INTERFACEID_LSP8 = 0x622e7a01;
6
6
 
7
- // --- ERC725Y Keys
7
+ // --- ERC725Y Data Keys
8
8
 
9
9
  // bytes10(keccak256('LSP8MetadataAddress')) + bytes2(0)
10
10
  bytes12 constant _LSP8_METADATA_ADDRESS_KEY_PREFIX = 0x73dcc7c3c4096cdc7f8a0000;
@@ -14,8 +14,8 @@ bytes12 constant _LSP8_METADATA_JSON_KEY_PREFIX = 0x9a26b4060ae7f7d5e3cd0000;
14
14
 
15
15
  // --- Token Hooks
16
16
 
17
- // keccak256('LSP8TokensSender')
18
- bytes32 constant _TYPEID_LSP8_TOKENSSENDER = 0x3724c94f0815e936299cca424da4140752198e0beb7931a6e0925d11bc97544c;
17
+ // keccak256('LSP8Tokens_SenderNotification')
18
+ bytes32 constant _TYPEID_LSP8_TOKENSSENDER = 0xb23eae7e6d1564b295b4c3e3be402d9a2f0776c57bdf365903496f6fa481ab00;
19
19
 
20
- // keccak256('LSP8TokensRecipient')
21
- bytes32 constant _TYPEID_LSP8_TOKENSRECIPIENT = 0xc7a120a42b6057a0cbed111fbbfbd52fcd96748c04394f77fc2c3adbe0391e01;
20
+ // keccak256('LSP8Tokens_RecipientNotification')
21
+ bytes32 constant _TYPEID_LSP8_TOKENSRECIPIENT = 0x0b084a55ebf70fd3c06fd755269dac2212c4d3f0f4d09079780bfa50c1b2984d;