@lukso/lsp-smart-contracts 0.6.2 → 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 (175) hide show
  1. package/CONTRIBUTING.md +31 -0
  2. package/README.md +73 -28
  3. package/artifacts/Create2Factory.json +2 -2
  4. package/artifacts/LSP0ERC725Account.json +227 -15
  5. package/artifacts/LSP0ERC725AccountInit.json +227 -41
  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 +22 -0
  12. package/artifacts/LSP4DigitalAssetMetadata.json +22 -0
  13. package/artifacts/{LSP4DigitalAssetMetadataInit.json → LSP4DigitalAssetMetadataInitAbstract.json} +24 -51
  14. package/artifacts/LSP6KeyManager.json +188 -33
  15. package/artifacts/LSP6KeyManagerInit.json +188 -33
  16. package/artifacts/LSP7CappedSupply.json +58 -31
  17. package/artifacts/{LSP7CappedSupplyInit.json → LSP7CappedSupplyInitAbstract.json} +60 -72
  18. package/artifacts/LSP7CompatibleERC20.json +52 -46
  19. package/artifacts/LSP7CompatibleERC20InitAbstract.json +733 -0
  20. package/artifacts/LSP7CompatibleERC20Mintable.json +61 -34
  21. package/artifacts/LSP7CompatibleERC20MintableInit.json +66 -60
  22. package/artifacts/LSP7DigitalAsset.json +52 -51
  23. package/artifacts/LSP7DigitalAssetInitAbstract.json +556 -0
  24. package/artifacts/LSP7Mintable.json +62 -35
  25. package/artifacts/LSP7MintableInit.json +62 -61
  26. package/artifacts/LSP8CappedSupply.json +64 -5
  27. package/artifacts/LSP8CappedSupplyInitAbstract.json +667 -0
  28. package/artifacts/LSP8CompatibleERC721.json +102 -21
  29. package/artifacts/LSP8CompatibleERC721InitAbstract.json +936 -0
  30. package/artifacts/LSP8CompatibleERC721Mintable.json +111 -9
  31. package/artifacts/LSP8CompatibleERC721MintableInit.json +116 -35
  32. package/artifacts/LSP8IdentifiableDigitalAsset.json +58 -20
  33. package/artifacts/{LSP8CappedSupplyInit.json → LSP8IdentifiableDigitalAssetInitAbstract.json} +62 -65
  34. package/artifacts/LSP8Mintable.json +67 -8
  35. package/artifacts/LSP8MintableInit.json +67 -34
  36. package/artifacts/LSP9Vault.json +235 -17
  37. package/artifacts/LSP9VaultInit.json +235 -43
  38. package/artifacts/UniversalProfile.json +227 -15
  39. package/artifacts/UniversalProfileInit.json +227 -41
  40. package/artifacts/UniversalReceiverAddressStore.json +3 -3
  41. package/constants.js +416 -95
  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 +274 -74
  47. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +2 -2
  48. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +3 -2
  49. package/contracts/LSP10ReceivedVaults/LSP10Constants.sol +4 -4
  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 +156 -42
  72. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +64 -31
  73. package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +54 -41
  74. package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +136 -28
  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 +16 -7
  80. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +16 -7
  81. package/contracts/LSP4DigitalAssetMetadata/LSP4Errors.sol +3 -3
  82. package/contracts/LSP5ReceivedAssets/LSP5Constants.sol +4 -4
  83. package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +103 -115
  84. package/contracts/LSP6KeyManager/ILSP6KeyManager.sol +26 -8
  85. package/contracts/LSP6KeyManager/LSP6Constants.sol +45 -45
  86. package/contracts/LSP6KeyManager/LSP6Errors.sol +97 -20
  87. package/contracts/LSP6KeyManager/LSP6KeyManager.sol +3 -2
  88. package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +786 -359
  89. package/contracts/LSP6KeyManager/LSP6KeyManagerInit.sol +2 -2
  90. package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +4 -3
  91. package/contracts/LSP6KeyManager/LSP6Utils.sol +127 -35
  92. package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +26 -13
  93. package/contracts/LSP7DigitalAsset/LSP7Constants.sol +6 -6
  94. package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +5 -5
  95. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +65 -52
  96. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +3 -3
  97. package/contracts/LSP7DigitalAsset/LSP7Errors.sol +30 -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 +9 -2
  107. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInitAbstract.sol +3 -3
  108. package/contracts/LSP7DigitalAsset/presets/LSP7Mintable.sol +12 -12
  109. package/contracts/LSP7DigitalAsset/presets/LSP7MintableInit.sol +5 -5
  110. package/contracts/LSP7DigitalAsset/presets/LSP7MintableInitAbstract.sol +11 -10
  111. package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +10 -8
  112. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol +11 -11
  113. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol +45 -1
  114. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +3 -3
  115. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +75 -71
  116. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +1 -1
  117. package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CompatibleERC721.sol +20 -3
  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 +49 -0
  124. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableInitAbstract.sol +51 -0
  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 +9 -2
  128. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInitAbstract.sol +3 -3
  129. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.sol +9 -8
  130. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInit.sol +2 -2
  131. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +8 -7
  132. package/contracts/LSP9Vault/LSP9Constants.sol +11 -8
  133. package/contracts/LSP9Vault/LSP9Errors.sol +8 -0
  134. package/contracts/LSP9Vault/LSP9Vault.sol +6 -4
  135. package/contracts/LSP9Vault/LSP9VaultCore.sol +324 -90
  136. package/contracts/LSP9Vault/LSP9VaultInit.sol +2 -2
  137. package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +5 -4
  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 -13
  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 +17 -0
  145. package/package.json +37 -32
  146. package/artifacts/LSP7CompatibleERC20Init.json +0 -760
  147. package/artifacts/LSP7DigitalAssetInit.json +0 -588
  148. package/artifacts/LSP8CompatibleERC721Init.json +0 -883
  149. package/artifacts/LSP8IdentifiableDigitalAssetInit.json +0 -639
  150. package/artifacts/UniversalFactory.json +0 -127
  151. package/contracts/Custom/ClaimOwnership.sol +0 -34
  152. package/contracts/Custom/ERC165Checker.sol +0 -130
  153. package/contracts/Custom/IClaimOwnership.sol +0 -10
  154. package/contracts/Factories/UniversalFactory.sol +0 -164
  155. package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiverDelegate.sol +0 -24
  156. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/Handling/TokenAndVaultHandling.sol +0 -85
  157. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/Handling/TokenHandling.sol +0 -76
  158. package/contracts/LSP2ERC725YJSONSchema/LSP2Errors.sol +0 -9
  159. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInit.sol +0 -26
  160. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInit.sol +0 -39
  161. package/contracts/LSP7DigitalAsset/extensions/ILSP7CappedSupply.sol +0 -17
  162. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyCore.sol +0 -57
  163. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInit.sol +0 -19
  164. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20Core.sol +0 -112
  165. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20Init.sol +0 -29
  166. package/contracts/LSP7DigitalAsset/presets/LSP7MintableCore.sol +0 -26
  167. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInit.sol +0 -35
  168. package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CappedSupply.sol +0 -17
  169. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyCore.sol +0 -58
  170. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInit.sol +0 -19
  171. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleConstants.sol +0 -6
  172. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721Core.sol +0 -187
  173. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721Init.sol +0 -25
  174. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableCore.sol +0 -26
  175. package/contracts/Utils/UtilsLib.sol +0 -31
@@ -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
- 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 @@ contract LSP7CompatibleERC20 is LSP7DigitalAsset, LSP7CompatibleERC20Core {
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 {
@@ -7,6 +7,13 @@ import {
7
7
  } from "./LSP7CompatibleERC20MintableInitAbstract.sol";
8
8
 
9
9
  contract LSP7CompatibleERC20MintableInit is LSP7CompatibleERC20MintableInitAbstract {
10
+ /**
11
+ * @dev initialize (= lock) base implementation contract on deployment
12
+ */
13
+ constructor() {
14
+ _disableInitializers();
15
+ }
16
+
10
17
  /**
11
18
  * @notice Sets the name, the symbol and the owner of the token
12
19
  * @param name_ The name of the token
@@ -17,7 +24,7 @@ contract LSP7CompatibleERC20MintableInit is LSP7CompatibleERC20MintableInitAbstr
17
24
  string memory name_,
18
25
  string memory symbol_,
19
26
  address newOwner_
20
- ) public virtual initializer {
27
+ ) external virtual initializer {
21
28
  LSP7CompatibleERC20MintableInitAbstract._initialize(name_, symbol_, newOwner_);
22
29
  }
23
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,42 +1,42 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
 
3
- pragma solidity ^0.8.0;
3
+ pragma solidity ^0.8.4;
4
+
5
+ // interfaces
6
+ import {ILSP7Mintable} from "./ILSP7Mintable.sol";
4
7
 
5
8
  // modules
6
9
  import {LSP7DigitalAsset} from "../LSP7DigitalAsset.sol";
7
- import {LSP7MintableCore} from "./LSP7MintableCore.sol";
8
10
 
9
11
  /**
10
12
  * @title LSP7Mintable
11
13
  * @author Jean Cavallera, Yamen Merhi
12
14
  * @dev LSP7 extension, mintable.
13
15
  */
14
- contract LSP7Mintable is LSP7DigitalAsset, LSP7MintableCore {
15
- // solhint-disable no-empty-blocks
16
-
16
+ contract LSP7Mintable is LSP7DigitalAsset, ILSP7Mintable {
17
17
  /**
18
18
  * @notice Sets the token-Metadata and register LSP7InterfaceId
19
19
  * @param name_ The name of the token
20
20
  * @param symbol_ The symbol of the token
21
21
  * @param newOwner_ The owner of the the token-Metadata
22
- * @param isNFT_ Specify if the LSP7 token is a fungible or non-fungible token
22
+ * @param isNonDivisible_ Specify if the LSP7 token is a fungible or non-fungible token
23
23
  */
24
24
  constructor(
25
25
  string memory name_,
26
26
  string memory symbol_,
27
27
  address newOwner_,
28
- bool isNFT_
29
- ) LSP7DigitalAsset(name_, symbol_, newOwner_, isNFT_) {}
28
+ bool isNonDivisible_
29
+ ) LSP7DigitalAsset(name_, symbol_, newOwner_, isNonDivisible_) {}
30
30
 
31
31
  /**
32
- * @inheritdoc LSP7MintableCore
32
+ * @inheritdoc ILSP7Mintable
33
33
  */
34
34
  function mint(
35
35
  address to,
36
36
  uint256 amount,
37
- bool force,
37
+ bool allowNonLSP1Recipient,
38
38
  bytes memory data
39
- ) public override onlyOwner {
40
- _mint(to, amount, force, data);
39
+ ) public virtual onlyOwner {
40
+ _mint(to, amount, allowNonLSP1Recipient, data);
41
41
  }
42
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";
@@ -21,14 +21,14 @@ contract LSP7MintableInit is LSP7MintableInitAbstract {
21
21
  * @param name_ The name of the token
22
22
  * @param symbol_ The symbol of the token
23
23
  * @param newOwner_ The owner of the the token-Metadata
24
- * @param isNFT_ Specify if the LSP7 token is a fungible or non-fungible token
24
+ * @param isNonDivisible_ Specify if the LSP7 token is a fungible or non-fungible token
25
25
  */
26
26
  function initialize(
27
27
  string memory name_,
28
28
  string memory symbol_,
29
29
  address newOwner_,
30
- bool isNFT_
31
- ) public virtual initializer {
32
- LSP7MintableInitAbstract._initialize(name_, symbol_, newOwner_, isNFT_);
30
+ bool isNonDivisible_
31
+ ) external virtual initializer {
32
+ LSP7MintableInitAbstract._initialize(name_, symbol_, newOwner_, isNonDivisible_);
33
33
  }
34
34
  }
@@ -1,34 +1,35 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
 
3
- pragma solidity ^0.8.0;
3
+ pragma solidity ^0.8.4;
4
+
5
+ // interfaces
6
+ import {ILSP7Mintable} from "./ILSP7Mintable.sol";
4
7
 
5
8
  // modules
6
- import {LSP7DigitalAssetInit} from "../LSP7DigitalAssetInit.sol";
7
9
  import {LSP7DigitalAssetInitAbstract} from "../LSP7DigitalAssetInitAbstract.sol";
8
- import {LSP7MintableCore} from "./LSP7MintableCore.sol";
9
10
 
10
11
  /**
11
12
  * @dev LSP7 extension, mintable.
12
13
  */
13
- abstract contract LSP7MintableInitAbstract is LSP7DigitalAssetInitAbstract, LSP7MintableCore {
14
+ abstract contract LSP7MintableInitAbstract is LSP7DigitalAssetInitAbstract, ILSP7Mintable {
14
15
  function _initialize(
15
16
  string memory name_,
16
17
  string memory symbol_,
17
18
  address newOwner_,
18
- bool isNFT_
19
+ bool isNonDivisible_
19
20
  ) internal virtual override onlyInitializing {
20
- LSP7DigitalAssetInitAbstract._initialize(name_, symbol_, newOwner_, isNFT_);
21
+ LSP7DigitalAssetInitAbstract._initialize(name_, symbol_, newOwner_, isNonDivisible_);
21
22
  }
22
23
 
23
24
  /**
24
- * @inheritdoc LSP7MintableCore
25
+ * @inheritdoc ILSP7Mintable
25
26
  */
26
27
  function mint(
27
28
  address to,
28
29
  uint256 amount,
29
- bool force,
30
+ bool allowNonLSP1Recipient,
30
31
  bytes memory data
31
- ) public override onlyOwner {
32
- _mint(to, amount, force, data);
32
+ ) public virtual onlyOwner {
33
+ _mint(to, amount, allowNonLSP1Recipient, data);
33
34
  }
34
35
  }
@@ -1,13 +1,13 @@
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";
7
7
  import {IERC725Y} from "@erc725/smart-contracts/contracts/interfaces/IERC725Y.sol";
8
8
 
9
9
  /**
10
- * @dev Required interface of a LSP8 compliant contract.
10
+ * @title interface of the LSP8 - Identifiable Digital Asset standard.
11
11
  */
12
12
  interface ILSP8IdentifiableDigitalAsset is IERC165, IERC725Y {
13
13
  // --- Events
@@ -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`.
@@ -168,6 +168,7 @@ interface ILSP8IdentifiableDigitalAsset is IERC165, IERC725Y {
168
168
  *
169
169
  * - `from` cannot be the zero address.
170
170
  * - `to` cannot be the zero address.
171
+ * - `from` and `to` cannot be the same address.
171
172
  * - `tokenId` token must be owned by `from`.
172
173
  * - If the caller is not `from`, it must be an operator of `tokenId`.
173
174
  *
@@ -177,7 +178,7 @@ interface ILSP8IdentifiableDigitalAsset is IERC165, IERC725Y {
177
178
  address from,
178
179
  address to,
179
180
  bytes32 tokenId,
180
- bool force,
181
+ bool allowNonLSP1Recipient,
181
182
  bytes memory data
182
183
  ) external;
183
184
 
@@ -185,7 +186,7 @@ interface ILSP8IdentifiableDigitalAsset is IERC165, IERC725Y {
185
186
  * @param from The list of sending addresses.
186
187
  * @param to The list of receiving addresses.
187
188
  * @param tokenId The list of tokenId to transfer.
188
- * @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
189
190
  * when set to FALSE to must be a contract that supports LSP1 UniversalReceiver
190
191
  * @param data Additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses.
191
192
  *
@@ -197,6 +198,7 @@ interface ILSP8IdentifiableDigitalAsset is IERC165, IERC725Y {
197
198
  * - `from`, `to`, `tokenId` lists are the same length.
198
199
  * - no values in `from` can be the zero address.
199
200
  * - no values in `to` can be the zero address.
201
+ * - `from` and `to` cannot be the same address at the same index of each lists.
200
202
  * - each `tokenId` token must be owned by `from`.
201
203
  * - If the caller is not `from`, it must be an operator of each `tokenId`.
202
204
  *
@@ -206,7 +208,7 @@ interface ILSP8IdentifiableDigitalAsset is IERC165, IERC725Y {
206
208
  address[] memory from,
207
209
  address[] memory to,
208
210
  bytes32[] memory tokenId,
209
- bool force,
211
+ bool[] memory allowNonLSP1Recipient,
210
212
  bytes[] memory data
211
213
  ) external;
212
214
  }
@@ -1,21 +1,21 @@
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
- // bytes8('LSP8MetadataAddress') + bytes4(0)
10
- bytes12 constant _LSP8_METADATA_ADDRESS_KEY_PREFIX = 0x73dcc7c3c4096cdc00000000;
9
+ // bytes10(keccak256('LSP8MetadataAddress')) + bytes2(0)
10
+ bytes12 constant _LSP8_METADATA_ADDRESS_KEY_PREFIX = 0x73dcc7c3c4096cdc7f8a0000;
11
11
 
12
- // bytes8('LSP8MetadataJSON') + bytes4(0)
13
- bytes12 constant _LSP8_METADATA_JSON_KEY_PREFIX = 0x9a26b4060ae7f7d500000000;
12
+ // bytes10(keccak256('LSP8MetadataJSON')) + bytes2(0)
13
+ 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;