@lukso/lsp-smart-contracts 0.9.0 → 0.10.1

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 (177) hide show
  1. package/README.md +29 -7
  2. package/artifacts/LSP0ERC725Account.json +63 -69
  3. package/artifacts/LSP0ERC725AccountInit.json +63 -69
  4. package/artifacts/LSP11BasicSocialRecovery.json +2 -2
  5. package/artifacts/LSP11BasicSocialRecoveryInit.json +2 -2
  6. package/artifacts/LSP16UniversalFactory.json +27 -21
  7. package/artifacts/LSP1UniversalReceiverDelegateUP.json +2 -2
  8. package/artifacts/LSP1UniversalReceiverDelegateVault.json +2 -2
  9. package/artifacts/LSP4Compatibility.json +32 -38
  10. package/artifacts/LSP4DigitalAssetMetadata.json +32 -38
  11. package/artifacts/LSP4DigitalAssetMetadataInitAbstract.json +32 -38
  12. package/artifacts/LSP6KeyManager.json +29 -15
  13. package/artifacts/LSP6KeyManagerInit.json +29 -15
  14. package/artifacts/LSP7CappedSupply.json +71 -36
  15. package/artifacts/LSP7CappedSupplyInitAbstract.json +71 -36
  16. package/artifacts/LSP7CompatibleERC20.json +71 -36
  17. package/artifacts/LSP7CompatibleERC20InitAbstract.json +71 -36
  18. package/artifacts/LSP7CompatibleERC20Mintable.json +73 -38
  19. package/artifacts/LSP7CompatibleERC20MintableInit.json +73 -38
  20. package/artifacts/LSP7DigitalAsset.json +71 -36
  21. package/artifacts/LSP7DigitalAssetInitAbstract.json +71 -36
  22. package/artifacts/LSP7Mintable.json +73 -38
  23. package/artifacts/LSP7MintableInit.json +73 -38
  24. package/artifacts/LSP8CappedSupply.json +32 -38
  25. package/artifacts/LSP8CappedSupplyInitAbstract.json +32 -38
  26. package/artifacts/LSP8CompatibleERC721.json +35 -41
  27. package/artifacts/LSP8CompatibleERC721InitAbstract.json +35 -41
  28. package/artifacts/LSP8CompatibleERC721Mintable.json +37 -43
  29. package/artifacts/LSP8CompatibleERC721MintableInit.json +37 -43
  30. package/artifacts/LSP8IdentifiableDigitalAsset.json +32 -38
  31. package/artifacts/LSP8IdentifiableDigitalAssetInitAbstract.json +32 -38
  32. package/artifacts/LSP8Mintable.json +34 -40
  33. package/artifacts/LSP8MintableInit.json +34 -40
  34. package/artifacts/LSP9Vault.json +61 -67
  35. package/artifacts/LSP9VaultInit.json +61 -67
  36. package/artifacts/UniversalProfile.json +63 -69
  37. package/artifacts/UniversalProfileInit.json +63 -69
  38. package/contracts/LSP0ERC725Account/ILSP0ERC725Account.sol +45 -10
  39. package/contracts/LSP0ERC725Account/LSP0Constants.sol +1 -1
  40. package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +43 -8
  41. package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +361 -124
  42. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +44 -8
  43. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +45 -6
  44. package/contracts/LSP0ERC725Account/LSP0Utils.sol +0 -1
  45. package/contracts/LSP10ReceivedVaults/LSP10Utils.sol +30 -15
  46. package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryCore.sol +0 -1
  47. package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryInit.sol +0 -1
  48. package/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol +5 -7
  49. package/contracts/LSP16UniversalFactory/LSP16UniversalFactory.sol +262 -115
  50. package/contracts/LSP17ContractExtension/LSP17Extendable.sol +10 -5
  51. package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiver.sol +0 -4
  52. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +91 -34
  53. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +27 -8
  54. package/contracts/LSP20CallVerification/LSP20CallVerification.sol +18 -9
  55. package/contracts/LSP20CallVerification/LSP20Constants.sol +17 -0
  56. package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +26 -12
  57. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +0 -1
  58. package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +32 -16
  59. package/contracts/LSP6KeyManager/ILSP6KeyManager.sol +11 -2
  60. package/contracts/LSP6KeyManager/LSP6Constants.sol +5 -5
  61. package/contracts/LSP6KeyManager/LSP6Errors.sol +10 -6
  62. package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +140 -68
  63. package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +0 -1
  64. package/contracts/LSP6KeyManager/LSP6Modules/LSP6ExecuteModule.sol +30 -38
  65. package/contracts/LSP6KeyManager/LSP6Modules/LSP6SetDataModule.sol +153 -60
  66. package/contracts/LSP6KeyManager/LSP6Utils.sol +1 -5
  67. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +67 -13
  68. package/contracts/LSP7DigitalAsset/LSP7Errors.sol +5 -0
  69. package/contracts/LSP7DigitalAsset/extensions/LSP7Burnable.sol +2 -2
  70. package/contracts/LSP7DigitalAsset/extensions/LSP7BurnableInitAbstract.sol +24 -0
  71. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupply.sol +1 -2
  72. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInitAbstract.sol +1 -2
  73. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.sol +3 -5
  74. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20InitAbstract.sol +3 -5
  75. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +15 -12
  76. package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CompatibleERC721.sol +1 -1
  77. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.sol +1 -2
  78. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInitAbstract.sol +1 -2
  79. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +5 -5
  80. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +6 -6
  81. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.sol +2 -2
  82. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableInitAbstract.sol +2 -2
  83. package/contracts/LSP9Vault/ILSP9Vault.sol +9 -1
  84. package/contracts/LSP9Vault/LSP9Constants.sol +1 -1
  85. package/contracts/LSP9Vault/LSP9Vault.sol +0 -6
  86. package/contracts/LSP9Vault/LSP9VaultCore.sol +17 -15
  87. package/contracts/LSP9Vault/LSP9VaultInit.sol +2 -1
  88. package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +8 -5
  89. package/contracts/UniversalProfile.sol +10 -4
  90. package/contracts/UniversalProfileInit.sol +15 -5
  91. package/contracts/UniversalProfileInitAbstract.sol +7 -3
  92. package/devdocs/Create2Factory.json +16 -0
  93. package/devdocs/LSP0ERC725Account.json +200 -0
  94. package/devdocs/LSP0ERC725AccountInit.json +203 -0
  95. package/devdocs/LSP11BasicSocialRecovery.json +146 -0
  96. package/devdocs/LSP11BasicSocialRecoveryInit.json +146 -0
  97. package/devdocs/LSP16UniversalFactory.json +116 -0
  98. package/devdocs/LSP1UniversalReceiverDelegateUP.json +80 -0
  99. package/devdocs/LSP1UniversalReceiverDelegateVault.json +62 -0
  100. package/devdocs/LSP4Compatibility.json +79 -0
  101. package/devdocs/LSP4DigitalAssetMetadata.json +84 -0
  102. package/devdocs/LSP4DigitalAssetMetadataInitAbstract.json +77 -0
  103. package/devdocs/LSP6KeyManager.json +257 -0
  104. package/devdocs/LSP6KeyManagerInit.json +260 -0
  105. package/devdocs/LSP7CappedSupply.json +211 -0
  106. package/devdocs/LSP7CappedSupplyInitAbstract.json +206 -0
  107. package/devdocs/LSP7CompatibleERC20.json +225 -0
  108. package/devdocs/LSP7CompatibleERC20InitAbstract.json +218 -0
  109. package/devdocs/LSP7CompatibleERC20Mintable.json +217 -0
  110. package/devdocs/LSP7CompatibleERC20MintableInit.json +227 -0
  111. package/devdocs/LSP7DigitalAsset.json +210 -0
  112. package/devdocs/LSP7DigitalAssetInitAbstract.json +202 -0
  113. package/devdocs/LSP7Mintable.json +219 -0
  114. package/devdocs/LSP7MintableInit.json +220 -0
  115. package/devdocs/LSP8CappedSupply.json +232 -0
  116. package/devdocs/LSP8CappedSupplyInitAbstract.json +227 -0
  117. package/devdocs/LSP8CompatibleERC721.json +298 -0
  118. package/devdocs/LSP8CompatibleERC721InitAbstract.json +291 -0
  119. package/devdocs/LSP8CompatibleERC721Mintable.json +290 -0
  120. package/devdocs/LSP8CompatibleERC721MintableInit.json +300 -0
  121. package/devdocs/LSP8IdentifiableDigitalAsset.json +230 -0
  122. package/devdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +223 -0
  123. package/devdocs/LSP8Mintable.json +242 -0
  124. package/devdocs/LSP8MintableInit.json +245 -0
  125. package/devdocs/LSP9Vault.json +171 -0
  126. package/devdocs/LSP9VaultInit.json +175 -0
  127. package/devdocs/UniversalProfile.json +200 -0
  128. package/devdocs/UniversalProfileInit.json +203 -0
  129. package/devdocs/UniversalReceiverAddressStore.json +9 -0
  130. package/dist/constants.cjs.js +31657 -0
  131. package/dist/constants.d.ts +31759 -0
  132. package/dist/constants.es.js +31638 -0
  133. package/package.json +71 -53
  134. package/userdocs/Create2Factory.json +5 -0
  135. package/userdocs/LSP0ERC725Account.json +50 -0
  136. package/userdocs/LSP0ERC725AccountInit.json +53 -0
  137. package/userdocs/LSP11BasicSocialRecovery.json +29 -0
  138. package/userdocs/LSP11BasicSocialRecoveryInit.json +29 -0
  139. package/userdocs/LSP16UniversalFactory.json +5 -0
  140. package/userdocs/LSP1UniversalReceiverDelegateUP.json +10 -0
  141. package/userdocs/LSP1UniversalReceiverDelegateVault.json +10 -0
  142. package/userdocs/LSP4Compatibility.json +20 -0
  143. package/userdocs/LSP4DigitalAssetMetadata.json +23 -0
  144. package/userdocs/LSP4DigitalAssetMetadataInitAbstract.json +20 -0
  145. package/userdocs/LSP6KeyManager.json +18 -0
  146. package/userdocs/LSP6KeyManagerInit.json +18 -0
  147. package/userdocs/LSP7CappedSupply.json +29 -0
  148. package/userdocs/LSP7CappedSupplyInitAbstract.json +26 -0
  149. package/userdocs/LSP7CompatibleERC20.json +35 -0
  150. package/userdocs/LSP7CompatibleERC20InitAbstract.json +32 -0
  151. package/userdocs/LSP7CompatibleERC20Mintable.json +32 -0
  152. package/userdocs/LSP7CompatibleERC20MintableInit.json +35 -0
  153. package/userdocs/LSP7DigitalAsset.json +29 -0
  154. package/userdocs/LSP7DigitalAssetInitAbstract.json +26 -0
  155. package/userdocs/LSP7Mintable.json +29 -0
  156. package/userdocs/LSP7MintableInit.json +29 -0
  157. package/userdocs/LSP8CappedSupply.json +23 -0
  158. package/userdocs/LSP8CappedSupplyInitAbstract.json +20 -0
  159. package/userdocs/LSP8CompatibleERC721.json +29 -0
  160. package/userdocs/LSP8CompatibleERC721InitAbstract.json +26 -0
  161. package/userdocs/LSP8CompatibleERC721Mintable.json +26 -0
  162. package/userdocs/LSP8CompatibleERC721MintableInit.json +29 -0
  163. package/userdocs/LSP8IdentifiableDigitalAsset.json +23 -0
  164. package/userdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +20 -0
  165. package/userdocs/LSP8Mintable.json +23 -0
  166. package/userdocs/LSP8MintableInit.json +23 -0
  167. package/userdocs/LSP9Vault.json +38 -0
  168. package/userdocs/LSP9VaultInit.json +38 -0
  169. package/userdocs/UniversalProfile.json +50 -0
  170. package/userdocs/UniversalProfileInit.json +53 -0
  171. package/userdocs/UniversalReceiverAddressStore.json +5 -0
  172. package/CONTRIBUTING.md +0 -57
  173. package/common/constants.d.ts +0 -461
  174. package/common/constants.js +0 -789
  175. package/contracts/Utils/GasLib.sol +0 -17
  176. package/module/constants.d.ts +0 -461
  177. package/module/constants.js +0 -786
@@ -4,12 +4,10 @@ pragma solidity ^0.8.12;
4
4
  // interfaces
5
5
  import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
6
6
  import {ILSP7CompatibleERC20} from "./ILSP7CompatibleERC20.sol";
7
- import {ILSP7DigitalAsset} from "../ILSP7DigitalAsset.sol";
8
7
 
9
8
  // modules
10
9
  import {LSP4Compatibility} from "../../LSP4DigitalAssetMetadata/LSP4Compatibility.sol";
11
10
  import {LSP7DigitalAsset, LSP4DigitalAssetMetadata, ERC725YCore} from "../LSP7DigitalAsset.sol";
12
- import {LSP7DigitalAssetCore} from "../LSP7DigitalAssetCore.sol";
13
11
 
14
12
  /**
15
13
  * @dev LSP7 extension, for compatibility for clients / tools that expect ERC20.
@@ -101,8 +99,8 @@ abstract contract LSP7CompatibleERC20 is ILSP7CompatibleERC20, LSP4Compatibility
101
99
  bool allowNonLSP1Recipient,
102
100
  bytes memory data
103
101
  ) internal virtual override {
104
- super._transfer(from, to, amount, allowNonLSP1Recipient, data);
105
102
  emit Transfer(from, to, amount);
103
+ super._transfer(from, to, amount, allowNonLSP1Recipient, data);
106
104
  }
107
105
 
108
106
  function _mint(
@@ -111,8 +109,8 @@ abstract contract LSP7CompatibleERC20 is ILSP7CompatibleERC20, LSP4Compatibility
111
109
  bool allowNonLSP1Recipient,
112
110
  bytes memory data
113
111
  ) internal virtual override {
114
- super._mint(to, amount, allowNonLSP1Recipient, data);
115
112
  emit Transfer(address(0), to, amount);
113
+ super._mint(to, amount, allowNonLSP1Recipient, data);
116
114
  }
117
115
 
118
116
  function _burn(
@@ -120,8 +118,8 @@ abstract contract LSP7CompatibleERC20 is ILSP7CompatibleERC20, LSP4Compatibility
120
118
  uint256 amount,
121
119
  bytes memory data
122
120
  ) internal virtual override {
123
- super._burn(from, amount, data);
124
121
  emit Transfer(from, address(0), amount);
122
+ super._burn(from, amount, data);
125
123
  }
126
124
 
127
125
  function _setData(bytes32 key, bytes memory value)
@@ -4,7 +4,6 @@ pragma solidity ^0.8.12;
4
4
  // interfaces
5
5
  import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
6
6
  import {ILSP7CompatibleERC20} from "./ILSP7CompatibleERC20.sol";
7
- import {ILSP7DigitalAsset} from "../ILSP7DigitalAsset.sol";
8
7
 
9
8
  // modules
10
9
  import {LSP4Compatibility} from "../../LSP4DigitalAssetMetadata/LSP4Compatibility.sol";
@@ -13,7 +12,6 @@ import {
13
12
  LSP4DigitalAssetMetadataInitAbstract,
14
13
  ERC725YCore
15
14
  } from "../LSP7DigitalAssetInitAbstract.sol";
16
- import {LSP7DigitalAssetCore} from "../LSP7DigitalAssetCore.sol";
17
15
 
18
16
  /**
19
17
  * @dev LSP7 extension, for compatibility for clients / tools that expect ERC20.
@@ -112,8 +110,8 @@ abstract contract LSP7CompatibleERC20InitAbstract is
112
110
  bool allowNonLSP1Recipient,
113
111
  bytes memory data
114
112
  ) internal virtual override {
115
- super._transfer(from, to, amount, allowNonLSP1Recipient, data);
116
113
  emit Transfer(from, to, amount);
114
+ super._transfer(from, to, amount, allowNonLSP1Recipient, data);
117
115
  }
118
116
 
119
117
  function _mint(
@@ -122,8 +120,8 @@ abstract contract LSP7CompatibleERC20InitAbstract is
122
120
  bool allowNonLSP1Recipient,
123
121
  bytes memory data
124
122
  ) internal virtual override {
125
- super._mint(to, amount, allowNonLSP1Recipient, data);
126
123
  emit Transfer(address(0), to, amount);
124
+ super._mint(to, amount, allowNonLSP1Recipient, data);
127
125
  }
128
126
 
129
127
  function _burn(
@@ -131,8 +129,8 @@ abstract contract LSP7CompatibleERC20InitAbstract is
131
129
  uint256 amount,
132
130
  bytes memory data
133
131
  ) internal virtual override {
134
- super._burn(from, amount, data);
135
132
  emit Transfer(from, address(0), amount);
133
+ super._burn(from, amount, data);
136
134
  }
137
135
 
138
136
  function _setData(bytes32 key, bytes memory value)
@@ -8,11 +8,6 @@ import {ILSP8IdentifiableDigitalAsset} from "./ILSP8IdentifiableDigitalAsset.sol
8
8
  // libraries
9
9
  import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
10
10
  import {ERC165Checker} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
11
- import {GasLib} from "../Utils/GasLib.sol";
12
-
13
- // modules
14
-
15
- import {ERC725Y} from "@erc725/smart-contracts/contracts/ERC725Y.sol";
16
11
 
17
12
  // errors
18
13
  import "./LSP8Errors.sol";
@@ -32,18 +27,18 @@ abstract contract LSP8IdentifiableDigitalAssetCore is ILSP8IdentifiableDigitalAs
32
27
 
33
28
  // --- Storage
34
29
 
35
- uint256 internal _existingTokens;
30
+ uint256 private _existingTokens;
36
31
 
37
32
  // Mapping from `tokenId` to `tokenOwner`
38
- mapping(bytes32 => address) internal _tokenOwners;
33
+ mapping(bytes32 => address) private _tokenOwners;
39
34
 
40
35
  // Mapping `tokenOwner` to owned tokenIds
41
- mapping(address => EnumerableSet.Bytes32Set) internal _ownedTokens;
36
+ mapping(address => EnumerableSet.Bytes32Set) private _ownedTokens;
42
37
 
43
38
  // Mapping a `tokenId` to its authorized operator addresses.
44
- mapping(bytes32 => EnumerableSet.AddressSet) internal _operators;
39
+ mapping(bytes32 => EnumerableSet.AddressSet) private _operators;
45
40
 
46
- mapping(address => EnumerableSet.Bytes32Set) internal _tokenIdsForOperator;
41
+ mapping(address => EnumerableSet.Bytes32Set) private _tokenIdsForOperator;
47
42
 
48
43
  // --- Token queries
49
44
 
@@ -204,8 +199,12 @@ abstract contract LSP8IdentifiableDigitalAssetCore is ILSP8IdentifiableDigitalAs
204
199
  revert LSP8InvalidTransferBatch();
205
200
  }
206
201
 
207
- for (uint256 i = 0; i < fromLength; i = GasLib.uncheckedIncrement(i)) {
202
+ for (uint256 i = 0; i < fromLength; ) {
208
203
  transfer(from[i], to[i], tokenId[i], allowNonLSP1Recipient[i], data[i]);
204
+
205
+ unchecked {
206
+ ++i;
207
+ }
209
208
  }
210
209
  }
211
210
 
@@ -235,10 +234,14 @@ abstract contract LSP8IdentifiableDigitalAssetCore is ILSP8IdentifiableDigitalAs
235
234
  EnumerableSet.AddressSet storage operatorsForTokenId = _operators[tokenId];
236
235
 
237
236
  uint256 operatorListLength = operatorsForTokenId.length();
238
- for (uint256 i = 0; i < operatorListLength; i = GasLib.uncheckedIncrement(i)) {
237
+ for (uint256 i = 0; i < operatorListLength; ) {
239
238
  // we are emptying the list, always remove from index 0
240
239
  address operator = operatorsForTokenId.at(0);
241
240
  _revokeOperator(operator, tokenOwner, tokenId);
241
+
242
+ unchecked {
243
+ ++i;
244
+ }
242
245
  }
243
246
  }
244
247
 
@@ -34,7 +34,7 @@ interface ILSP8CompatibleERC721 is ILSP8IdentifiableDigitalAsset {
34
34
  * @dev This emits when an operator is enabled or disabled for an owner.
35
35
  * The operator can manage all NFTs of the owner.
36
36
  */
37
- event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved);
37
+ event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
38
38
 
39
39
  /**
40
40
  * @dev Compatible with ERC721 transferFrom.
@@ -4,7 +4,6 @@ pragma solidity ^0.8.4;
4
4
 
5
5
  // modules
6
6
  import {LSP8IdentifiableDigitalAsset} from "../LSP8IdentifiableDigitalAsset.sol";
7
- import {LSP8IdentifiableDigitalAssetCore} from "../LSP8IdentifiableDigitalAssetCore.sol";
8
7
 
9
8
  /**
10
9
  * @dev LSP8 extension, adds token supply cap.
@@ -15,7 +14,7 @@ abstract contract LSP8CappedSupply is LSP8IdentifiableDigitalAsset {
15
14
  error LSP8CappedSupplyCannotMintOverCap();
16
15
 
17
16
  // --- Storage
18
- uint256 internal _tokenSupplyCap;
17
+ uint256 private immutable _tokenSupplyCap;
19
18
 
20
19
  /**
21
20
  * @notice Sets the token max supply
@@ -3,7 +3,6 @@
3
3
  pragma solidity ^0.8.4;
4
4
 
5
5
  // modules
6
- import {LSP8IdentifiableDigitalAssetCore} from "../LSP8IdentifiableDigitalAssetCore.sol";
7
6
  import {
8
7
  LSP8IdentifiableDigitalAssetInitAbstract
9
8
  } from "../LSP8IdentifiableDigitalAssetInitAbstract.sol";
@@ -17,7 +16,7 @@ abstract contract LSP8CappedSupplyInitAbstract is LSP8IdentifiableDigitalAssetIn
17
16
  error LSP8CappedSupplyCannotMintOverCap();
18
17
 
19
18
  // --- Storage
20
- uint256 internal _tokenSupplyCap;
19
+ uint256 private _tokenSupplyCap;
21
20
 
22
21
  function _initialize(uint256 tokenSupplyCap_) internal virtual onlyInitializing {
23
22
  if (tokenSupplyCap_ == 0) {
@@ -100,8 +100,8 @@ abstract contract LSP8CompatibleERC721 is
100
100
  bytes32 tokenIdAsBytes32 = bytes32(tokenId);
101
101
  _existsOrError(tokenIdAsBytes32);
102
102
 
103
- EnumerableSet.AddressSet storage operatorsForTokenId = _operators[tokenIdAsBytes32];
104
- uint256 operatorListLength = operatorsForTokenId.length();
103
+ address[] memory operatorsForTokenId = getOperatorsOf(tokenIdAsBytes32);
104
+ uint256 operatorListLength = operatorsForTokenId.length;
105
105
 
106
106
  if (operatorListLength == 0) {
107
107
  return address(0);
@@ -112,7 +112,7 @@ abstract contract LSP8CompatibleERC721 is
112
112
  // compatibility version the same is true, when the authorized operators were not previously
113
113
  // authorized. If addresses are removed, then `getApproved` returned address can change due
114
114
  // to implementation of `EnumberableSet._remove`.
115
- return operatorsForTokenId.at(operatorListLength - 1);
115
+ return operatorsForTokenId[operatorListLength - 1];
116
116
  }
117
117
  }
118
118
 
@@ -232,15 +232,15 @@ abstract contract LSP8CompatibleERC721 is
232
232
  bool allowNonLSP1Recipient,
233
233
  bytes memory data
234
234
  ) internal virtual override {
235
- super._mint(to, tokenId, allowNonLSP1Recipient, data);
236
235
  emit Transfer(address(0), to, uint256(tokenId));
236
+ super._mint(to, tokenId, allowNonLSP1Recipient, data);
237
237
  }
238
238
 
239
239
  function _burn(bytes32 tokenId, bytes memory data) internal virtual override {
240
240
  address tokenOwner = tokenOwnerOf(tokenId);
241
241
 
242
- super._burn(tokenId, data);
243
242
  emit Transfer(tokenOwner, address(0), uint256(tokenId));
243
+ super._burn(tokenId, data);
244
244
  }
245
245
 
246
246
  /**
@@ -96,8 +96,8 @@ abstract contract LSP8CompatibleERC721InitAbstract is
96
96
  bytes32 tokenIdAsBytes32 = bytes32(tokenId);
97
97
  _existsOrError(tokenIdAsBytes32);
98
98
 
99
- EnumerableSet.AddressSet storage operatorsForTokenId = _operators[tokenIdAsBytes32];
100
- uint256 operatorListLength = operatorsForTokenId.length();
99
+ address[] memory operatorsForTokenId = getOperatorsOf(tokenIdAsBytes32);
100
+ uint256 operatorListLength = operatorsForTokenId.length;
101
101
 
102
102
  if (operatorListLength == 0) {
103
103
  return address(0);
@@ -108,7 +108,7 @@ abstract contract LSP8CompatibleERC721InitAbstract is
108
108
  // compatibility version the same is true, when the authorized operators were not previously
109
109
  // authorized. If addresses are removed, then `getApproved` returned address can change due
110
110
  // to implementation of `EnumberableSet._remove`.
111
- return operatorsForTokenId.at(operatorListLength - 1);
111
+ return operatorsForTokenId[operatorListLength - 1];
112
112
  }
113
113
  }
114
114
 
@@ -205,8 +205,8 @@ abstract contract LSP8CompatibleERC721InitAbstract is
205
205
  revert LSP8NotTokenOperator(tokenId, operator);
206
206
  }
207
207
 
208
- super._transfer(from, to, tokenId, allowNonLSP1Recipient, data);
209
208
  emit Transfer(from, to, uint256(tokenId));
209
+ super._transfer(from, to, tokenId, allowNonLSP1Recipient, data);
210
210
  }
211
211
 
212
212
  function _safeTransfer(
@@ -228,15 +228,15 @@ abstract contract LSP8CompatibleERC721InitAbstract is
228
228
  bool allowNonLSP1Recipient,
229
229
  bytes memory data
230
230
  ) internal virtual override {
231
- super._mint(to, tokenId, allowNonLSP1Recipient, data);
232
231
  emit Transfer(address(0), to, uint256(tokenId));
232
+ super._mint(to, tokenId, allowNonLSP1Recipient, data);
233
233
  }
234
234
 
235
235
  function _burn(bytes32 tokenId, bytes memory data) internal virtual override {
236
236
  address tokenOwner = tokenOwnerOf(tokenId);
237
237
 
238
- super._burn(tokenId, data);
239
238
  emit Transfer(tokenOwner, address(0), uint256(tokenId));
239
+ super._burn(tokenId, data);
240
240
  }
241
241
 
242
242
  /**
@@ -30,11 +30,11 @@ abstract contract LSP8Enumerable is LSP8IdentifiableDigitalAsset {
30
30
  bytes32 tokenId
31
31
  ) internal virtual override(LSP8IdentifiableDigitalAssetCore) {
32
32
  if (from == address(0)) {
33
- uint256 index = _existingTokens;
33
+ uint256 index = totalSupply();
34
34
  _indexToken[index] = tokenId;
35
35
  _tokenIndex[tokenId] = index;
36
36
  } else if (to == address(0)) {
37
- uint256 lastIndex = _existingTokens - 1;
37
+ uint256 lastIndex = totalSupply() - 1;
38
38
  uint256 index = _tokenIndex[tokenId];
39
39
  if (index < lastIndex) {
40
40
  bytes32 lastTokenId = _indexToken[lastIndex];
@@ -32,11 +32,11 @@ abstract contract LSP8EnumerableInitAbstract is LSP8IdentifiableDigitalAssetInit
32
32
  bytes32 tokenId
33
33
  ) internal virtual override(LSP8IdentifiableDigitalAssetCore) {
34
34
  if (from == address(0)) {
35
- uint256 index = _existingTokens;
35
+ uint256 index = totalSupply();
36
36
  _indexToken[index] = tokenId;
37
37
  _tokenIndex[tokenId] = index;
38
38
  } else if (to == address(0)) {
39
- uint256 lastIndex = _existingTokens - 1;
39
+ uint256 lastIndex = totalSupply() - 1;
40
40
  uint256 index = _tokenIndex[tokenId];
41
41
  if (index < lastIndex) {
42
42
  bytes32 lastTokenId = _indexToken[lastIndex];
@@ -10,8 +10,16 @@ import {ILSP14Ownable2Step} from "../LSP14Ownable2Step/ILSP14Ownable2Step.sol";
10
10
 
11
11
  /**
12
12
  * @title Interface of LSP9Vault built on top of ERC725, LSP1UniversalReceiver
13
+ * @dev this interface implicitly inherits: IERC165, IERC725X, IERC725Y, ILSP1UniversalReceiver, ILSP14Ownable2Step
13
14
  */
14
- interface ILSP9Vault is IERC165, IERC725X, IERC725Y, ILSP1UniversalReceiver, ILSP14Ownable2Step {
15
+ interface ILSP9Vault {
16
+ /**
17
+ * @notice Emitted when receiving native tokens
18
+ * @param sender The address of the sender
19
+ * @param value The amount of native tokens received
20
+ */
21
+ event ValueReceived(address indexed sender, uint256 indexed value);
22
+
15
23
  /**
16
24
  * @dev Receives and executes a batch of function calls on this contract.
17
25
  */
@@ -2,7 +2,7 @@
2
2
  pragma solidity ^0.8.4;
3
3
 
4
4
  // --- ERC165 interface ids
5
- bytes4 constant _INTERFACEID_LSP9 = 0x19331ad1;
5
+ bytes4 constant _INTERFACEID_LSP9 = 0x28af17e6;
6
6
 
7
7
  // --- ERC725Y Data Keys
8
8
 
@@ -1,21 +1,15 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.4;
3
3
 
4
- // interfaces
5
- import {IERC725Y} from "@erc725/smart-contracts/contracts/interfaces/IERC725Y.sol";
6
-
7
4
  // modules
8
5
  import {OwnableUnset} from "@erc725/smart-contracts/contracts/custom/OwnableUnset.sol";
9
- import {ERC725} from "@erc725/smart-contracts/contracts/ERC725.sol";
10
6
  import {LSP9VaultCore} from "./LSP9VaultCore.sol";
11
7
 
12
8
  // libraries
13
9
  import {LSP1Utils} from "../LSP1UniversalReceiver/LSP1Utils.sol";
14
10
 
15
11
  // constants
16
- import {_INTERFACEID_LSP1} from "../LSP1UniversalReceiver/LSP1Constants.sol";
17
12
  import {
18
- _INTERFACEID_LSP9,
19
13
  _LSP9_SUPPORTED_STANDARDS_KEY,
20
14
  _LSP9_SUPPORTED_STANDARDS_VALUE,
21
15
  _TYPEID_LSP9_OwnershipTransferred_RecipientNotification
@@ -3,10 +3,10 @@ pragma solidity ^0.8.4;
3
3
 
4
4
  // interfaces
5
5
  import {ILSP1UniversalReceiver} from "../LSP1UniversalReceiver/ILSP1UniversalReceiver.sol";
6
+ import {ILSP9Vault} from "./ILSP9Vault.sol";
6
7
 
7
8
  // libraries
8
9
  import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol";
9
- import {GasLib} from "../Utils/GasLib.sol";
10
10
 
11
11
  import {Address} from "@openzeppelin/contracts/utils/Address.sol";
12
12
  import {ERC165Checker} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
@@ -58,20 +58,14 @@ contract LSP9VaultCore is
58
58
  ERC725YCore,
59
59
  LSP14Ownable2Step,
60
60
  LSP17Extendable,
61
- ILSP1UniversalReceiver
61
+ ILSP1UniversalReceiver,
62
+ ILSP9Vault
62
63
  {
63
64
  using ERC165Checker for address;
64
65
  using LSP1Utils for address;
65
66
 
66
67
  address private _reentrantDelegate;
67
68
 
68
- /**
69
- * @notice Emitted when receiving native tokens
70
- * @param sender The address of the sender
71
- * @param value The amount of native tokens received
72
- */
73
- event ValueReceived(address indexed sender, uint256 indexed value);
74
-
75
69
  /**
76
70
  * @dev Emits an event when receiving native tokens
77
71
  *
@@ -216,7 +210,7 @@ contract LSP9VaultCore is
216
210
  */
217
211
  function batchCalls(bytes[] calldata data) public returns (bytes[] memory results) {
218
212
  results = new bytes[](data.length);
219
- for (uint256 i; i < data.length; i = GasLib.uncheckedIncrement(i)) {
213
+ for (uint256 i; i < data.length; ) {
220
214
  (bool success, bytes memory result) = address(this).delegatecall(data[i]);
221
215
 
222
216
  if (!success) {
@@ -235,6 +229,10 @@ contract LSP9VaultCore is
235
229
  }
236
230
 
237
231
  results[i] = result;
232
+
233
+ unchecked {
234
+ ++i;
235
+ }
238
236
  }
239
237
  }
240
238
 
@@ -263,14 +261,14 @@ contract LSP9VaultCore is
263
261
  *
264
262
  * @dev Emits a {ValueReceived} event when receiving native tokens.
265
263
  */
266
- function execute(
264
+ function executeBatch(
267
265
  uint256[] memory operationsType,
268
266
  address[] memory targets,
269
267
  uint256[] memory values,
270
268
  bytes[] memory datas
271
269
  ) public payable virtual override onlyOwner returns (bytes[] memory) {
272
270
  if (msg.value != 0) emit ValueReceived(msg.sender, msg.value);
273
- return _execute(operationsType, targets, values, datas);
271
+ return _executeBatch(operationsType, targets, values, datas);
274
272
  }
275
273
 
276
274
  /**
@@ -305,7 +303,7 @@ contract LSP9VaultCore is
305
303
  *
306
304
  * Emits a {DataChanged} event.
307
305
  */
308
- function setData(bytes32[] memory dataKeys, bytes[] memory dataValues)
306
+ function setDataBatch(bytes32[] memory dataKeys, bytes[] memory dataValues)
309
307
  public
310
308
  payable
311
309
  virtual
@@ -313,12 +311,12 @@ contract LSP9VaultCore is
313
311
  {
314
312
  bool isURD = _validateAndIdentifyCaller();
315
313
  if (dataKeys.length != dataValues.length) {
316
- revert ERC725Y_DataKeysValuesLengthMismatch(dataKeys.length, dataValues.length);
314
+ revert ERC725Y_DataKeysValuesLengthMismatch();
317
315
  }
318
316
 
319
317
  if (msg.value != 0) revert ERC725Y_MsgValueDisallowed();
320
318
 
321
- for (uint256 i = 0; i < dataKeys.length; i = GasLib.uncheckedIncrement(i)) {
319
+ for (uint256 i = 0; i < dataKeys.length; ) {
322
320
  if (isURD) {
323
321
  if (
324
322
  bytes12(dataKeys[i]) == _LSP1_UNIVERSAL_RECEIVER_DELEGATE_PREFIX ||
@@ -329,6 +327,10 @@ contract LSP9VaultCore is
329
327
  }
330
328
  }
331
329
  _setData(dataKeys[i], dataValues[i]);
330
+
331
+ unchecked {
332
+ ++i;
333
+ }
332
334
  }
333
335
  }
334
336
 
@@ -18,7 +18,8 @@ contract LSP9VaultInit is LSP9VaultInitAbstract {
18
18
  }
19
19
 
20
20
  /**
21
- * @notice Sets the owner of the contract and sets the SupportedStandards:LSP9Vault key
21
+ * @notice Initializing the contract owner to: `newOwner`
22
+ * @dev Sets the owner of the contract and sets the SupportedStandards:LSP9Vault key
22
23
  * @param newOwner the owner of the contract
23
24
  */
24
25
  function initialize(address newOwner) external payable virtual initializer {
@@ -1,9 +1,6 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.4;
3
3
 
4
- // interfaces
5
- import {IERC725Y} from "@erc725/smart-contracts/contracts/interfaces/IERC725Y.sol";
6
-
7
4
  // modules
8
5
  import {OwnableUnset} from "@erc725/smart-contracts/contracts/custom/OwnableUnset.sol";
9
6
  import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
@@ -13,9 +10,7 @@ import {LSP9VaultCore} from "./LSP9VaultCore.sol";
13
10
  import {LSP1Utils} from "../LSP1UniversalReceiver/LSP1Utils.sol";
14
11
 
15
12
  // constants
16
- import {_INTERFACEID_LSP1} from "../LSP1UniversalReceiver/LSP1Constants.sol";
17
13
  import {
18
- _INTERFACEID_LSP9,
19
14
  _LSP9_SUPPORTED_STANDARDS_KEY,
20
15
  _LSP9_SUPPORTED_STANDARDS_VALUE,
21
16
  _TYPEID_LSP9_OwnershipTransferred_RecipientNotification
@@ -29,6 +24,14 @@ import {
29
24
  abstract contract LSP9VaultInitAbstract is Initializable, LSP9VaultCore {
30
25
  using LSP1Utils for address;
31
26
 
27
+ /**
28
+ * @notice Initializing the contract owner to: `newOwner`
29
+ * @dev Sets the owner of the contract and sets the SupportedStandards:LSP9Vault key.
30
+ * ERC725X & ERC725Y parent contracts are not initialised as they don't have
31
+ * non-zero initial state. If you decide to add non-zero initial state to any of those
32
+ * contracts, you MUST initialize them here
33
+ * @param newOwner the owner of the contract
34
+ */
32
35
  function _initialize(address newOwner) internal virtual onlyInitializing {
33
36
  if (msg.value != 0) emit ValueReceived(msg.sender, msg.value);
34
37
  OwnableUnset._setOwner(newOwner);
@@ -17,11 +17,17 @@ import {
17
17
  */
18
18
  contract UniversalProfile is LSP0ERC725Account {
19
19
  /**
20
- * @notice Sets the owner of the contract and sets the SupportedStandards:LSP3UniversalProfile key
21
- * @param newOwner the owner of the contract
20
+ * @notice Deploying the contract with owner set to: `initialOwner`
21
+ * @dev Set `initialOwner` as the contract owner and set the `SupportedStandards:LSP3UniversalProfile` data key
22
+ * in the ERC725Y data key/value store. The `constructor` also allows funding the contract on deployment.
23
+ *
24
+ * Emitted Events:
25
+ * - ValueReceived: when the contract is funded on deployment.
26
+ *
27
+ * @param initialOwner the owner of the contract
22
28
  */
23
- constructor(address newOwner) payable LSP0ERC725Account(newOwner) {
24
- // set key SupportedStandards:LSP3UniversalProfile
29
+ constructor(address initialOwner) payable LSP0ERC725Account(initialOwner) {
30
+ // set data key SupportedStandards:LSP3UniversalProfile
25
31
  _setData(_LSP3_SUPPORTED_STANDARDS_KEY, _LSP3_SUPPORTED_STANDARDS_VALUE);
26
32
  }
27
33
  }
@@ -11,17 +11,27 @@ import {UniversalProfileInitAbstract} from "./UniversalProfileInitAbstract.sol";
11
11
  */
12
12
  contract UniversalProfileInit is UniversalProfileInitAbstract {
13
13
  /**
14
- * @dev initialize (= lock) base implementation contract on deployment
14
+ * @notice deploying a `UniversalProfileInit` base contract to be used behind proxy
15
+ * @dev Locks the base contract on deployment, so that it cannot be initialized, owned and controlled by anyone
16
+ * after it has been deployed. This is intended so that the sole purpose of this contract is to be used as a base
17
+ * contract behind a proxy.
15
18
  */
16
19
  constructor() {
17
20
  _disableInitializers();
18
21
  }
19
22
 
20
23
  /**
21
- * @notice Sets the owner of the contract and sets the SupportedStandards:LSP3UniversalProfile key
22
- * @param newOwner the owner of the contract
24
+ * @notice Initializing the contract owner to: `initialOwner`
25
+ * @dev Set `initialOwner` as the contract owner and set the `SupportedStandards:LSP3UniversalProfile` data key in the ERC725Y data key/value store.
26
+ * The `initialOwner` will then be allowed to call protected functions marked with the `onlyOwner` modifier.
27
+ * The `initialize(address)` function also allows funding the contract on initialization.
28
+ *
29
+ * Emitted Events:
30
+ * - ValueReceived: when the contract is funded on initialization.
31
+ *
32
+ * @param initialOwner the owner of the contract
23
33
  */
24
- function initialize(address newOwner) external payable virtual initializer {
25
- UniversalProfileInitAbstract._initialize(newOwner);
34
+ function initialize(address initialOwner) external payable virtual initializer {
35
+ UniversalProfileInitAbstract._initialize(initialOwner);
26
36
  }
27
37
  }
@@ -16,10 +16,14 @@ import {
16
16
  * @dev Implementation of the ERC725Account + LSP1 universalReceiver
17
17
  */
18
18
  abstract contract UniversalProfileInitAbstract is LSP0ERC725AccountInitAbstract {
19
- function _initialize(address newOwner) internal virtual override onlyInitializing {
20
- LSP0ERC725AccountInitAbstract._initialize(newOwner);
19
+ /**
20
+ * @inheritdoc LSP0ERC725AccountInitAbstract
21
+ * @dev Set the `SupportedStandards:LSP3UniversalProfile` data key in the ERC725Y data key/value store.
22
+ */
23
+ function _initialize(address initialOwner) internal virtual override onlyInitializing {
24
+ LSP0ERC725AccountInitAbstract._initialize(initialOwner);
21
25
 
22
- // set key SupportedStandards:LSP3UniversalProfile
26
+ // set data key SupportedStandards:LSP3UniversalProfile
23
27
  _setData(_LSP3_SUPPORTED_STANDARDS_KEY, _LSP3_SUPPORTED_STANDARDS_VALUE);
24
28
  }
25
29
  }
@@ -0,0 +1,16 @@
1
+ {
2
+ "kind": "dev",
3
+ "methods": {
4
+ "computeAddress(bytes32,bytes32)": {
5
+ "details": "Returns the address where a contract will be stored if deployed via {deploy}. Any change in the `bytecodeHash` or `salt` will result in a new destination address."
6
+ },
7
+ "computeAddress(bytes32,bytes32,address)": {
8
+ "details": "Returns the address where a contract will be stored if deployed via {deploy} from a contract located at `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}."
9
+ },
10
+ "deploy(bytes32,bytes)": {
11
+ "details": "Deploys a contract using `CREATE2`. The address where the contract will be deployed can be known in advance via {computeAddress}. The bytecode for a contract can be obtained from Solidity with `type(contractName).creationCode`. Requirements: - `bytecode` must not be empty. - `salt` must have not been used for `bytecode` already."
12
+ }
13
+ },
14
+ "title": "contract to deploy contracts with precomputed addresses, using create2 opcode based on https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Create2.sol DO NOT TOUCH",
15
+ "version": 1
16
+ }