@lukso/lsp-smart-contracts 0.5.0 → 0.6.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 (138) hide show
  1. package/README.md +29 -9
  2. package/artifacts/LSP0ERC725Account.json +392 -0
  3. package/artifacts/LSP0ERC725AccountInit.json +433 -0
  4. package/artifacts/LSP1UniversalReceiverDelegateUP.json +2 -7
  5. package/artifacts/LSP1UniversalReceiverDelegateVault.json +2 -7
  6. package/artifacts/LSP4Compatibility.json +195 -0
  7. package/artifacts/LSP4DigitalAssetMetadata.json +169 -0
  8. package/artifacts/LSP4DigitalAssetMetadataInit.json +231 -0
  9. package/artifacts/LSP6KeyManager.json +34 -28
  10. package/artifacts/LSP6KeyManagerInit.json +42 -23
  11. package/artifacts/LSP7CappedSupply.json +133 -8
  12. package/artifacts/LSP7CappedSupplyInit.json +160 -32
  13. package/artifacts/LSP7CompatibilityForERC20.json +125 -10
  14. package/artifacts/LSP7CompatibilityForERC20Init.json +727 -0
  15. package/artifacts/LSP7DigitalAsset.json +125 -10
  16. package/artifacts/LSP7DigitalAssetInit.json +149 -31
  17. package/artifacts/LSP7Mintable.json +126 -11
  18. package/artifacts/LSP7MintableInit.json +150 -32
  19. package/artifacts/LSP8CappedSupply.json +134 -8
  20. package/artifacts/LSP8CappedSupplyInit.json +169 -17
  21. package/artifacts/LSP8CompatibilityForERC721.json +126 -10
  22. package/artifacts/LSP8CompatibilityForERC721Init.json +873 -0
  23. package/artifacts/LSP8IdentifiableDigitalAsset.json +126 -10
  24. package/artifacts/LSP8IdentifiableDigitalAssetInit.json +158 -16
  25. package/artifacts/LSP8Mintable.json +138 -11
  26. package/artifacts/LSP8MintableInit.json +170 -17
  27. package/artifacts/LSP9Vault.json +368 -0
  28. package/artifacts/LSP9VaultInit.json +409 -0
  29. package/artifacts/UniversalFactory.json +127 -0
  30. package/artifacts/UniversalProfile.json +65 -14
  31. package/artifacts/UniversalProfileInit.json +104 -14
  32. package/artifacts/UniversalReceiverAddressStore.json +204 -0
  33. package/constants.js +352 -0
  34. package/contracts/Custom/ClaimOwnership.sol +31 -0
  35. package/contracts/Custom/ERC165Checker.sol +130 -0
  36. package/contracts/Custom/IClaimOwnership.sol +10 -0
  37. package/contracts/Factories/UniversalFactory.sol +155 -0
  38. package/contracts/LSP0ERC725Account/LSP0Constants.sol +5 -9
  39. package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +6 -8
  40. package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +89 -46
  41. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +5 -5
  42. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +6 -21
  43. package/contracts/LSP10ReceivedVaults/LSP10Constants.sol +10 -0
  44. package/contracts/LSP1UniversalReceiver/LSP1Constants.sol +2 -8
  45. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/Handling/TokenAndVaultHandling.sol +59 -185
  46. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +48 -6
  47. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/Handling/TokenHandling.sol +45 -92
  48. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +39 -6
  49. package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +47 -0
  50. package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +205 -0
  51. package/contracts/LSP3UniversalProfile/LSP3Constants.sol +11 -0
  52. package/contracts/LSP4DigitalAssetMetadata/ILSP4Compatibility.sol +1 -1
  53. package/contracts/LSP4DigitalAssetMetadata/LSP4Compatibility.sol +5 -14
  54. package/contracts/LSP4DigitalAssetMetadata/LSP4Constants.sol +10 -4
  55. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol +11 -8
  56. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInit.sol +9 -13
  57. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +14 -20
  58. package/contracts/LSP5ReceivedAssets/LSP5Constants.sol +10 -0
  59. package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +157 -0
  60. package/contracts/LSP6KeyManager/ILSP6KeyManager.sol +21 -18
  61. package/contracts/LSP6KeyManager/LSP6Constants.sol +61 -25
  62. package/contracts/LSP6KeyManager/LSP6Errors.sol +37 -0
  63. package/contracts/LSP6KeyManager/LSP6KeyManager.sol +3 -4
  64. package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +429 -332
  65. package/contracts/LSP6KeyManager/LSP6KeyManagerInit.sol +6 -5
  66. package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +7 -15
  67. package/contracts/LSP6KeyManager/LSP6Utils.sol +111 -0
  68. package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +3 -8
  69. package/contracts/LSP7DigitalAsset/LSP7Constants.sol +5 -4
  70. package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +23 -9
  71. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +70 -94
  72. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInit.sol +8 -9
  73. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +25 -23
  74. package/contracts/LSP7DigitalAsset/LSP7Errors.sol +23 -0
  75. package/contracts/LSP7DigitalAsset/extensions/ILSP7CappedSupply.sol +1 -1
  76. package/contracts/LSP7DigitalAsset/extensions/ILSP7CompatibilityForERC20.sol +2 -4
  77. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupply.sol +8 -7
  78. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyCore.sol +14 -12
  79. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInit.sol +3 -8
  80. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInitAbstract.sol +9 -17
  81. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibilityForERC20.sol +33 -21
  82. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibilityForERC20Core.sol +20 -39
  83. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibilityForERC20Init.sol +3 -3
  84. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibilityForERC20InitAbstract.sol +39 -28
  85. package/contracts/LSP7DigitalAsset/{extensions → presets}/ILSP7Mintable.sol +1 -1
  86. package/contracts/LSP7DigitalAsset/{extensions → presets}/LSP7Mintable.sol +4 -3
  87. package/contracts/LSP7DigitalAsset/{extensions → presets}/LSP7MintableCore.sol +5 -5
  88. package/contracts/LSP7DigitalAsset/{extensions → presets}/LSP7MintableInit.sol +3 -2
  89. package/contracts/LSP7DigitalAsset/presets/LSP7MintableInitAbstract.sol +34 -0
  90. package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +5 -16
  91. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol +6 -3
  92. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol +22 -0
  93. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +23 -10
  94. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +102 -135
  95. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInit.sol +8 -11
  96. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +24 -21
  97. package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CappedSupply.sol +1 -1
  98. package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CompatibilityForERC721.sol +3 -11
  99. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.sol +9 -15
  100. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyCore.sol +14 -12
  101. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInit.sol +3 -8
  102. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInitAbstract.sol +11 -20
  103. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibilityForERC721.sol +41 -33
  104. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibilityForERC721Core.sol +27 -84
  105. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibilityForERC721Init.sol +4 -6
  106. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibilityForERC721InitAbstract.sol +40 -41
  107. package/contracts/LSP8IdentifiableDigitalAsset/{extensions → presets}/ILSP8Mintable.sol +1 -1
  108. package/contracts/LSP8IdentifiableDigitalAsset/{extensions → presets}/LSP8Mintable.sol +4 -3
  109. package/contracts/LSP8IdentifiableDigitalAsset/{extensions → presets}/LSP8MintableCore.sol +5 -8
  110. package/contracts/LSP8IdentifiableDigitalAsset/{extensions → presets}/LSP8MintableInit.sol +4 -3
  111. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +35 -0
  112. package/contracts/LSP9Vault/LSP9Constants.sol +13 -4
  113. package/contracts/LSP9Vault/LSP9Vault.sol +15 -37
  114. package/contracts/LSP9Vault/LSP9VaultCore.sol +101 -82
  115. package/contracts/LSP9Vault/LSP9VaultInit.sol +5 -4
  116. package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +15 -45
  117. package/contracts/Legacy/Registries/AddressRegistry.sol +43 -0
  118. package/contracts/Legacy/Registries/AddressRegistryRequiresERC725.sol +33 -0
  119. package/contracts/Legacy/UniversalReceiverAddressStore.sol +59 -0
  120. package/contracts/UniversalProfile.sol +10 -5
  121. package/contracts/UniversalProfileInit.sol +5 -4
  122. package/contracts/UniversalProfileInitAbstract.sol +14 -20
  123. package/contracts/Utils/UtilsLib.sol +47 -11
  124. package/package.json +23 -9
  125. package/artifacts/LSP1UniversalReceiverDelegateUPInit.json +0 -66
  126. package/artifacts/LSP1UniversalReceiverDelegateVaultInit.json +0 -66
  127. package/constants.ts +0 -356
  128. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUPCore.sol +0 -52
  129. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUPInit.sol +0 -26
  130. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUPInitAbstract.sol +0 -28
  131. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVaultCore.sol +0 -41
  132. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVaultInit.sol +0 -23
  133. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVaultInitAbstract.sol +0 -25
  134. package/contracts/LSP7DigitalAsset/extensions/LSP7MintableInitAbstract.sol +0 -47
  135. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8MintableInitAbstract.sol +0 -44
  136. package/contracts/Utils/ERC725Utils.sol +0 -169
  137. package/contracts/Utils/LSP2Utils.sol +0 -127
  138. package/contracts/Utils/LSP6Utils.sol +0 -63
@@ -0,0 +1,23 @@
1
+ // SPDX-License-Identifier: CC0-1.0
2
+ pragma solidity ^0.8.0;
3
+
4
+ // --- Errors
5
+
6
+ error LSP7AmountExceedsBalance(uint256 balance, address tokenOwner, uint256 amount);
7
+
8
+ error LSP7AmountExceedsAuthorizedAmount(
9
+ address tokenOwner,
10
+ uint256 authorizedAmount,
11
+ address operator,
12
+ uint256 amount
13
+ );
14
+
15
+ error LSP7CannotUseAddressZeroAsOperator();
16
+
17
+ error LSP7CannotSendWithAddressZero();
18
+
19
+ error LSP7InvalidTransferBatch();
20
+
21
+ error LSP7NotifyTokenReceiverContractMissingLSP1Interface(address tokenReceiver);
22
+
23
+ error LSP7NotifyTokenReceiverIsEOA(address tokenReceiver);
@@ -3,7 +3,7 @@
3
3
  pragma solidity ^0.8.0;
4
4
 
5
5
  // interfaces
6
- import "../ILSP7DigitalAsset.sol";
6
+ import {ILSP7DigitalAsset} from "../ILSP7DigitalAsset.sol";
7
7
 
8
8
  /**
9
9
  * @dev LSP7 extension, adds token supply cap.
@@ -3,7 +3,7 @@
3
3
  pragma solidity ^0.8.0;
4
4
 
5
5
  // interfaces
6
- import "../ILSP7DigitalAsset.sol";
6
+ import {ILSP7DigitalAsset} from "../ILSP7DigitalAsset.sol";
7
7
 
8
8
  /**
9
9
  * @dev LSP8 extension, for compatibility for clients / tools that expect ERC20.
@@ -59,7 +59,5 @@ interface ILSP7CompatibilityForERC20 is ILSP7DigitalAsset {
59
59
  * @param operator The address approved by the `tokenOwner`
60
60
  * @return The amount `operator` is approved by `tokenOwner`
61
61
  */
62
- function allowance(address tokenOwner, address operator)
63
- external
64
- returns (uint256);
62
+ function allowance(address tokenOwner, address operator) external returns (uint256);
65
63
  }
@@ -3,22 +3,23 @@
3
3
  pragma solidity ^0.8.0;
4
4
 
5
5
  // modules
6
- import "./LSP7CappedSupplyCore.sol";
7
- import "../LSP7DigitalAsset.sol";
6
+ import {LSP7DigitalAsset} from "../LSP7DigitalAsset.sol";
7
+ import {LSP7DigitalAssetCore} from "../LSP7DigitalAssetCore.sol";
8
+ import {LSP7CappedSupplyCore} from "./LSP7CappedSupplyCore.sol";
8
9
 
9
10
  /**
10
11
  * @dev LSP7 extension, adds token supply cap.
11
12
  */
12
- abstract contract LSP7CappedSupply is LSP7CappedSupplyCore, LSP7DigitalAsset {
13
+ abstract contract LSP7CappedSupply is LSP7DigitalAsset, LSP7CappedSupplyCore {
13
14
  /**
14
15
  * @notice Sets the token max supply
15
16
  * @param tokenSupplyCap_ The Token max supply
16
17
  */
17
18
  constructor(uint256 tokenSupplyCap_) {
18
- require(
19
- tokenSupplyCap_ > 0,
20
- "LSP7CappedSupply: tokenSupplyCap is zero"
21
- );
19
+ if (tokenSupplyCap_ == 0) {
20
+ revert LSP7CappedSupplyRequired();
21
+ }
22
+
22
23
  _tokenSupplyCap = tokenSupplyCap_;
23
24
  }
24
25
 
@@ -2,19 +2,21 @@
2
2
 
3
3
  pragma solidity ^0.8.0;
4
4
 
5
- // modules
6
- import "../LSP7DigitalAssetCore.sol";
7
-
8
5
  // interfaces
9
- import "./ILSP7CappedSupply.sol";
6
+ import {ILSP7CappedSupply} from "./ILSP7CappedSupply.sol";
7
+
8
+ // modules
9
+ import {LSP7DigitalAssetCore} from "../LSP7DigitalAssetCore.sol";
10
10
 
11
11
  /**
12
12
  * @dev LSP7 extension, adds token supply cap.
13
13
  */
14
- abstract contract LSP7CappedSupplyCore is
15
- ILSP7CappedSupply,
16
- LSP7DigitalAssetCore
17
- {
14
+ abstract contract LSP7CappedSupplyCore is LSP7DigitalAssetCore, ILSP7CappedSupply {
15
+ // --- Errors
16
+
17
+ error LSP7CappedSupplyRequired();
18
+ error LSP7CappedSupplyCannotMintOverCap();
19
+
18
20
  // --- Storage
19
21
 
20
22
  uint256 internal _tokenSupplyCap;
@@ -46,10 +48,10 @@ abstract contract LSP7CappedSupplyCore is
46
48
  bool force,
47
49
  bytes memory data
48
50
  ) internal virtual override {
49
- require(
50
- totalSupply() + amount <= tokenSupplyCap(),
51
- "LSP7CappedSupply: tokenSupplyCap reached"
52
- );
51
+ if (totalSupply() + amount > tokenSupplyCap()) {
52
+ revert LSP7CappedSupplyCannotMintOverCap();
53
+ }
54
+
53
55
  super._mint(to, amount, force, data);
54
56
  }
55
57
  }
@@ -3,7 +3,7 @@
3
3
  pragma solidity ^0.8.0;
4
4
 
5
5
  // modules
6
- import "./LSP7CappedSupplyInitAbstract.sol";
6
+ import {LSP7CappedSupplyInitAbstract} from "./LSP7CappedSupplyInitAbstract.sol";
7
7
 
8
8
  /**
9
9
  * @dev LSP7 extension, adds token supply cap.
@@ -13,12 +13,7 @@ abstract contract LSP7CappedSupplyInit is LSP7CappedSupplyInitAbstract {
13
13
  * @notice Sets the token max supply
14
14
  * @param tokenSupplyCap_ The Token max supply
15
15
  */
16
- function initialize(uint256 tokenSupplyCap_)
17
- public
18
- virtual
19
- override
20
- initializer
21
- {
22
- LSP7CappedSupplyInitAbstract.initialize(tokenSupplyCap_);
16
+ function initialize(uint256 tokenSupplyCap_) public virtual initializer {
17
+ LSP7CappedSupplyInitAbstract._initialize(tokenSupplyCap_);
23
18
  }
24
19
  }
@@ -3,27 +3,19 @@
3
3
  pragma solidity ^0.8.0;
4
4
 
5
5
  // modules
6
- import "./LSP7CappedSupplyCore.sol";
7
- import "../LSP7DigitalAssetInit.sol";
6
+ import {LSP7DigitalAssetInit} from "../LSP7DigitalAssetInit.sol";
7
+ import {LSP7DigitalAssetCore} from "../LSP7DigitalAssetCore.sol";
8
+ import {LSP7CappedSupplyCore} from "./LSP7CappedSupplyCore.sol";
8
9
 
9
10
  /**
10
11
  * @dev LSP7 extension, adds token supply cap.
11
12
  */
12
- abstract contract LSP7CappedSupplyInitAbstract is
13
- Initializable,
14
- LSP7CappedSupplyCore,
15
- LSP7DigitalAssetInit
16
- {
17
- /**
18
- * @notice Sets the token max supply
19
- * @param tokenSupplyCap_ The Token max supply
20
- */
21
- function initialize(uint256 tokenSupplyCap_)
22
- public
23
- virtual
24
- onlyInitializing
25
- {
26
- require(tokenSupplyCap_ > 0, "LSP7Capped: tokenSupplyCap is zero");
13
+ abstract contract LSP7CappedSupplyInitAbstract is LSP7DigitalAssetInit, LSP7CappedSupplyCore {
14
+ function _initialize(uint256 tokenSupplyCap_) internal virtual onlyInitializing {
15
+ if (tokenSupplyCap_ == 0) {
16
+ revert LSP7CappedSupplyRequired();
17
+ }
18
+
27
19
  _tokenSupplyCap = tokenSupplyCap_;
28
20
  }
29
21
 
@@ -3,10 +3,11 @@
3
3
  pragma solidity ^0.8.0;
4
4
 
5
5
  // modules
6
- import "../LSP7DigitalAsset.sol";
7
- import "./LSP7CompatibilityForERC20Core.sol";
6
+ import {LSP7DigitalAsset, LSP4DigitalAssetMetadata, ERC725YCore} from "../LSP7DigitalAsset.sol";
7
+ import {LSP7DigitalAssetCore} from "../LSP7DigitalAssetCore.sol";
8
+ import {LSP7CompatibilityForERC20Core} from "./LSP7CompatibilityForERC20Core.sol";
8
9
 
9
- contract LSP7CompatibilityForERC20 is LSP7CompatibilityForERC20Core, LSP7DigitalAsset {
10
+ contract LSP7CompatibilityForERC20 is LSP7DigitalAsset, LSP7CompatibilityForERC20Core {
10
11
  /* solhint-disable no-empty-blocks */
11
12
  /**
12
13
  * @notice Sets the name, the symbol and the owner of the token
@@ -18,39 +19,50 @@ contract LSP7CompatibilityForERC20 is LSP7CompatibilityForERC20Core, LSP7Digital
18
19
  string memory name_,
19
20
  string memory symbol_,
20
21
  address newOwner_
21
- ) LSP7DigitalAsset(name_, symbol_, newOwner_, false) {
22
-
23
- }
22
+ ) LSP7DigitalAsset(name_, symbol_, newOwner_, false) {}
24
23
 
25
24
  // --- Overrides
26
25
 
27
26
  function authorizeOperator(address operator, uint256 amount)
28
- public
27
+ public
29
28
  virtual
30
29
  override(LSP7DigitalAssetCore, LSP7CompatibilityForERC20Core)
31
30
  {
32
31
  super.authorizeOperator(operator, amount);
33
32
  }
34
33
 
35
- function _burn(address from, uint256 amount, bytes memory data)
36
- internal
37
- virtual
38
- override(LSP7DigitalAssetCore, LSP7CompatibilityForERC20Core)
39
- {
34
+ function _burn(
35
+ address from,
36
+ uint256 amount,
37
+ bytes memory data
38
+ ) internal virtual override(LSP7DigitalAssetCore, LSP7CompatibilityForERC20Core) {
40
39
  super._burn(from, amount, data);
41
40
  }
42
41
 
43
- function _mint(address to, uint256 amount, bool force, bytes memory data)
44
- internal
45
- virtual
46
- override(LSP7DigitalAssetCore, LSP7CompatibilityForERC20Core) {
47
- super._mint(to, amount, force, data);
42
+ function _mint(
43
+ address to,
44
+ uint256 amount,
45
+ bool force,
46
+ bytes memory data
47
+ ) internal virtual override(LSP7DigitalAssetCore, LSP7CompatibilityForERC20Core) {
48
+ super._mint(to, amount, force, data);
49
+ }
50
+
51
+ function _transfer(
52
+ address from,
53
+ address to,
54
+ uint256 amount,
55
+ bool force,
56
+ bytes memory data
57
+ ) internal virtual override(LSP7DigitalAssetCore, LSP7CompatibilityForERC20Core) {
58
+ super._transfer(from, to, amount, force, data);
48
59
  }
49
60
 
50
- function _transfer(address from, address to, uint256 amount, bool force, bytes memory data)
51
- internal
61
+ function _setData(bytes32 key, bytes memory value)
62
+ internal
52
63
  virtual
53
- override(LSP7DigitalAssetCore, LSP7CompatibilityForERC20Core) {
54
- super._transfer(from, to, amount, force, data);
64
+ override(LSP4DigitalAssetMetadata, ERC725YCore)
65
+ {
66
+ super._setData(key, value);
55
67
  }
56
68
  }
@@ -2,29 +2,26 @@
2
2
 
3
3
  pragma solidity ^0.8.0;
4
4
 
5
- // modules
6
- import "../../LSP4DigitalAssetMetadata/LSP4Compatibility.sol";
7
- import "../LSP7DigitalAssetCore.sol";
8
-
9
5
  // interfaces
10
- import "./ILSP7CompatibilityForERC20.sol";
6
+ import {ILSP7DigitalAsset} from "../ILSP7DigitalAsset.sol";
7
+ import {ILSP7CompatibilityForERC20} from "./ILSP7CompatibilityForERC20.sol";
8
+
9
+ // modules
10
+ import {LSP4Compatibility} from "../../LSP4DigitalAssetMetadata/LSP4Compatibility.sol";
11
+ import {LSP7DigitalAssetCore} from "../LSP7DigitalAssetCore.sol";
11
12
 
12
13
  /**
13
14
  * @dev LSP7 extension, for compatibility for clients / tools that expect ERC20.
14
15
  */
15
16
  abstract contract LSP7CompatibilityForERC20Core is
16
- ILSP7CompatibilityForERC20,
17
+ LSP4Compatibility,
17
18
  LSP7DigitalAssetCore,
18
- LSP4Compatibility
19
+ ILSP7CompatibilityForERC20
19
20
  {
20
21
  /**
21
22
  * @inheritdoc ILSP7CompatibilityForERC20
22
23
  */
23
- function approve(address operator, uint256 amount)
24
- external
25
- virtual
26
- override
27
- {
24
+ function approve(address operator, uint256 amount) external virtual override {
28
25
  return authorizeOperator(operator, amount);
29
26
  }
30
27
 
@@ -47,7 +44,7 @@ abstract contract LSP7CompatibilityForERC20Core is
47
44
  * Using force=true so that EOA and any contract may receive the tokens.
48
45
  */
49
46
  function transfer(address to, uint256 amount) external virtual override {
50
- return transfer(_msgSender(), to, amount, true, "compat-transfer");
47
+ return transfer(_msgSender(), to, amount, true, "");
51
48
  }
52
49
 
53
50
  /**
@@ -60,7 +57,7 @@ abstract contract LSP7CompatibilityForERC20Core is
60
57
  address to,
61
58
  uint256 amount
62
59
  ) external virtual override {
63
- return transfer(from, to, amount, true, "compat-transferFrom");
60
+ return transfer(from, to, amount, true, "");
64
61
  }
65
62
 
66
63
  // --- Overrides
@@ -72,11 +69,7 @@ abstract contract LSP7CompatibilityForERC20Core is
72
69
  {
73
70
  super.authorizeOperator(operator, amount);
74
71
 
75
- emit Approval(
76
- _msgSender(),
77
- operator,
78
- amount
79
- );
72
+ emit Approval(_msgSender(), operator, amount);
80
73
  }
81
74
 
82
75
  function _transfer(
@@ -88,11 +81,7 @@ abstract contract LSP7CompatibilityForERC20Core is
88
81
  ) internal virtual override {
89
82
  super._transfer(from, to, amount, force, data);
90
83
 
91
- emit Transfer(
92
- from,
93
- to,
94
- amount
95
- );
84
+ emit Transfer(from, to, amount);
96
85
  }
97
86
 
98
87
  function _mint(
@@ -103,24 +92,16 @@ abstract contract LSP7CompatibilityForERC20Core is
103
92
  ) internal virtual override {
104
93
  super._mint(to, amount, force, data);
105
94
 
106
- emit Transfer(
107
- address(0),
108
- to,
109
- amount
110
- );
95
+ emit Transfer(address(0), to, amount);
111
96
  }
112
97
 
113
- function _burn(address from, uint256 amount, bytes memory data)
114
- internal
115
- virtual
116
- override
117
- {
98
+ function _burn(
99
+ address from,
100
+ uint256 amount,
101
+ bytes memory data
102
+ ) internal virtual override {
118
103
  super._burn(from, amount, data);
119
104
 
120
- emit Transfer(
121
- from,
122
- address(0),
123
- amount
124
- );
105
+ emit Transfer(from, address(0), amount);
125
106
  }
126
107
  }
@@ -3,7 +3,7 @@
3
3
  pragma solidity ^0.8.0;
4
4
 
5
5
  // modules
6
- import "./LSP7CompatibilityForERC20InitAbstract.sol";
6
+ import {LSP7CompatibilityForERC20InitAbstract} from "./LSP7CompatibilityForERC20InitAbstract.sol";
7
7
 
8
8
  contract LSP7CompatibilityForERC20Init is LSP7CompatibilityForERC20InitAbstract {
9
9
  /**
@@ -16,7 +16,7 @@ contract LSP7CompatibilityForERC20Init is LSP7CompatibilityForERC20InitAbstract
16
16
  string memory name_,
17
17
  string memory symbol_,
18
18
  address newOwner_
19
- ) public virtual override initializer {
20
- LSP7CompatibilityForERC20InitAbstract.initialize(name_, symbol_, newOwner_);
19
+ ) public virtual initializer {
20
+ LSP7CompatibilityForERC20InitAbstract._initialize(name_, symbol_, newOwner_);
21
21
  }
22
22
  }
@@ -3,53 +3,64 @@
3
3
  pragma solidity ^0.8.0;
4
4
 
5
5
  // modules
6
- import "../LSP7DigitalAssetInitAbstract.sol";
7
- import "./LSP7CompatibilityForERC20Core.sol";
8
-
9
- contract LSP7CompatibilityForERC20InitAbstract is LSP7CompatibilityForERC20Core, LSP7DigitalAssetInitAbstract {
10
- /**
11
- * @notice Sets the name, the symbol and the owner of the token
12
- * @param name_ The name of the token
13
- * @param symbol_ The symbol of the token
14
- * @param newOwner_ The owner of the token
15
- */
16
- function initialize(
6
+ import {LSP7DigitalAssetInitAbstract, LSP4DigitalAssetMetadataInitAbstract, ERC725YCore} from "../LSP7DigitalAssetInitAbstract.sol";
7
+ import {LSP7DigitalAssetCore} from "../LSP7DigitalAssetCore.sol";
8
+ import {LSP7CompatibilityForERC20Core} from "./LSP7CompatibilityForERC20Core.sol";
9
+
10
+ contract LSP7CompatibilityForERC20InitAbstract is
11
+ LSP7DigitalAssetInitAbstract,
12
+ LSP7CompatibilityForERC20Core
13
+ {
14
+ function _initialize(
17
15
  string memory name_,
18
16
  string memory symbol_,
19
17
  address newOwner_
20
- ) public virtual override onlyInitializing {
21
- LSP7DigitalAssetInitAbstract.initialize(name_, symbol_, newOwner_, false);
18
+ ) internal virtual override onlyInitializing {
19
+ LSP7DigitalAssetInitAbstract._initialize(name_, symbol_, newOwner_, false);
22
20
  }
23
21
 
24
22
  // --- Overrides
25
23
 
26
24
  function authorizeOperator(address operator, uint256 amount)
27
- public
25
+ public
28
26
  virtual
29
27
  override(LSP7DigitalAssetCore, LSP7CompatibilityForERC20Core)
30
28
  {
31
29
  super.authorizeOperator(operator, amount);
32
30
  }
33
31
 
34
- function _burn(address from, uint256 amount, bytes memory data)
35
- internal
36
- virtual
37
- override(LSP7DigitalAssetCore, LSP7CompatibilityForERC20Core)
38
- {
32
+ function _burn(
33
+ address from,
34
+ uint256 amount,
35
+ bytes memory data
36
+ ) internal virtual override(LSP7DigitalAssetCore, LSP7CompatibilityForERC20Core) {
39
37
  super._burn(from, amount, data);
40
38
  }
41
39
 
42
- function _mint(address to, uint256 amount, bool force, bytes memory data)
43
- internal
44
- virtual
45
- override(LSP7DigitalAssetCore, LSP7CompatibilityForERC20Core) {
46
- super._mint(to, amount, force, data);
40
+ function _mint(
41
+ address to,
42
+ uint256 amount,
43
+ bool force,
44
+ bytes memory data
45
+ ) internal virtual override(LSP7DigitalAssetCore, LSP7CompatibilityForERC20Core) {
46
+ super._mint(to, amount, force, data);
47
+ }
48
+
49
+ function _transfer(
50
+ address from,
51
+ address to,
52
+ uint256 amount,
53
+ bool force,
54
+ bytes memory data
55
+ ) internal virtual override(LSP7DigitalAssetCore, LSP7CompatibilityForERC20Core) {
56
+ super._transfer(from, to, amount, force, data);
47
57
  }
48
58
 
49
- function _transfer(address from, address to, uint256 amount, bool force, bytes memory data)
50
- internal
59
+ function _setData(bytes32 key, bytes memory value)
60
+ internal
51
61
  virtual
52
- override(LSP7DigitalAssetCore, LSP7CompatibilityForERC20Core) {
53
- super._transfer(from, to, amount, force, data);
62
+ override(LSP4DigitalAssetMetadataInitAbstract, ERC725YCore)
63
+ {
64
+ super._setData(key, value);
54
65
  }
55
66
  }
@@ -3,7 +3,7 @@
3
3
  pragma solidity ^0.8.0;
4
4
 
5
5
  // interfaces
6
- import "../ILSP7DigitalAsset.sol";
6
+ import {ILSP7DigitalAsset} from "../ILSP7DigitalAsset.sol";
7
7
 
8
8
  /**
9
9
  * @dev LSP7 extension, Mintable version.
@@ -2,15 +2,16 @@
2
2
 
3
3
  pragma solidity ^0.8.0;
4
4
 
5
- import "./LSP7MintableCore.sol";
6
- import "../LSP7DigitalAsset.sol";
5
+ // modules
6
+ import {LSP7DigitalAsset} from "../LSP7DigitalAsset.sol";
7
+ import {LSP7MintableCore} from "./LSP7MintableCore.sol";
7
8
 
8
9
  /**
9
10
  * @title LSP7Mintable
10
11
  * @author Jean Cavallera, Yamen Merhi
11
12
  * @dev LSP7 extension, mintable.
12
13
  */
13
- contract LSP7Mintable is LSP7MintableCore, LSP7DigitalAsset {
14
+ contract LSP7Mintable is LSP7DigitalAsset, LSP7MintableCore {
14
15
  // solhint-disable no-empty-blocks
15
16
 
16
17
  /**
@@ -2,16 +2,16 @@
2
2
 
3
3
  pragma solidity ^0.8.0;
4
4
 
5
- // modules
6
- import "../LSP7DigitalAssetCore.sol";
7
-
8
5
  // interfaces
9
- import "./ILSP7Mintable.sol";
6
+ import {ILSP7Mintable} from "./ILSP7Mintable.sol";
7
+
8
+ // modules
9
+ import {LSP7DigitalAssetCore} from "../LSP7DigitalAssetCore.sol";
10
10
 
11
11
  /**
12
12
  * @dev LSP7 extension, mintable .
13
13
  */
14
- abstract contract LSP7MintableCore is ILSP7Mintable, LSP7DigitalAssetCore {
14
+ abstract contract LSP7MintableCore is LSP7DigitalAssetCore, ILSP7Mintable {
15
15
  /**
16
16
  * @inheritdoc ILSP7Mintable
17
17
  */
@@ -2,7 +2,8 @@
2
2
 
3
3
  pragma solidity ^0.8.0;
4
4
 
5
- import "./LSP7MintableInitAbstract.sol";
5
+ // modules
6
+ import {LSP7MintableInitAbstract} from "./LSP7MintableInitAbstract.sol";
6
7
 
7
8
  /**
8
9
  * @dev LSP7 extension, mintable.
@@ -21,6 +22,6 @@ contract LSP7MintableInit is LSP7MintableInitAbstract {
21
22
  address newOwner_,
22
23
  bool isNFT_
23
24
  ) public virtual override initializer {
24
- LSP7MintableInitAbstract.initialize(name_, symbol_, newOwner_, isNFT_);
25
+ LSP7MintableInitAbstract._initialize(name_, symbol_, newOwner_, isNFT_);
25
26
  }
26
27
  }
@@ -0,0 +1,34 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ pragma solidity ^0.8.0;
4
+
5
+ // modules
6
+ import {LSP7DigitalAssetInit} from "../LSP7DigitalAssetInit.sol";
7
+ import {LSP7DigitalAssetInitAbstract} from "../LSP7DigitalAssetInitAbstract.sol";
8
+ import {LSP7MintableCore} from "./LSP7MintableCore.sol";
9
+
10
+ /**
11
+ * @dev LSP7 extension, mintable.
12
+ */
13
+ abstract contract LSP7MintableInitAbstract is LSP7DigitalAssetInit, LSP7MintableCore {
14
+ function _initialize(
15
+ string memory name_,
16
+ string memory symbol_,
17
+ address newOwner_,
18
+ bool isNFT_
19
+ ) internal virtual override onlyInitializing {
20
+ LSP7DigitalAssetInitAbstract._initialize(name_, symbol_, newOwner_, isNFT_);
21
+ }
22
+
23
+ /**
24
+ * @inheritdoc LSP7MintableCore
25
+ */
26
+ function mint(
27
+ address to,
28
+ uint256 amount,
29
+ bool force,
30
+ bytes memory data
31
+ ) public override onlyOwner {
32
+ _mint(to, amount, force, data);
33
+ }
34
+ }
@@ -3,8 +3,8 @@
3
3
  pragma solidity ^0.8.0;
4
4
 
5
5
  // interfaces
6
- import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
7
- import "@erc725/smart-contracts/contracts/interfaces/IERC725Y.sol";
6
+ import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
7
+ import {IERC725Y} from "@erc725/smart-contracts/contracts/interfaces/IERC725Y.sol";
8
8
 
9
9
  /**
10
10
  * @dev Required interface of a LSP8 compliant contract.
@@ -90,10 +90,7 @@ interface ILSP8IdentifiableDigitalAsset is IERC165, IERC725Y {
90
90
  * @param tokenOwner The address to query owned tokens
91
91
  * @return List of owned tokens by `tokenOwner` address
92
92
  */
93
- function tokenIdsOf(address tokenOwner)
94
- external
95
- view
96
- returns (bytes32[] memory);
93
+ function tokenIdsOf(address tokenOwner) external view returns (bytes32[] memory);
97
94
 
98
95
  // --- Operator functionality
99
96
 
@@ -108,7 +105,6 @@ interface ILSP8IdentifiableDigitalAsset is IERC165, IERC725Y {
108
105
  *
109
106
  * - `tokenId` must exist.
110
107
  * - caller must be current `tokenOwner` of `tokenId`.
111
- * - `operator` cannot be calling address.
112
108
  * - `operator` cannot be the zero address.
113
109
  *
114
110
  * Emits an {AuthorizedOperator} event.
@@ -126,7 +122,6 @@ interface ILSP8IdentifiableDigitalAsset is IERC165, IERC725Y {
126
122
  *
127
123
  * - `tokenId` must exist.
128
124
  * - caller must be current `tokenOwner` of `tokenId`.
129
- * - `operator` cannot be calling address.
130
125
  * - `operator` cannot be the zero address.
131
126
  *
132
127
  * Emits a {RevokedOperator} event.
@@ -145,10 +140,7 @@ interface ILSP8IdentifiableDigitalAsset is IERC165, IERC725Y {
145
140
  *
146
141
  * - `tokenId` must exist.
147
142
  */
148
- function isOperatorFor(address operator, bytes32 tokenId)
149
- external
150
- view
151
- returns (bool);
143
+ function isOperatorFor(address operator, bytes32 tokenId) external view returns (bool);
152
144
 
153
145
  /**
154
146
  * @param tokenId The tokenId to query
@@ -159,10 +151,7 @@ interface ILSP8IdentifiableDigitalAsset is IERC165, IERC725Y {
159
151
  *
160
152
  * - `tokenId` must exist.
161
153
  */
162
- function getOperatorsOf(bytes32 tokenId)
163
- external
164
- view
165
- returns (address[] memory);
154
+ function getOperatorsOf(bytes32 tokenId) external view returns (address[] memory);
166
155
 
167
156
  // --- Transfer functionality
168
157