@lukso/lsp-smart-contracts 0.4.3

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 (109) hide show
  1. package/CONTRIBUTING.md +18 -0
  2. package/LICENSE +201 -0
  3. package/README.md +75 -0
  4. package/artifacts/Create2Factory.json +107 -0
  5. package/artifacts/LSP1UniversalReceiverDelegateUP.json +64 -0
  6. package/artifacts/LSP1UniversalReceiverDelegateUPInit.json +66 -0
  7. package/artifacts/LSP1UniversalReceiverDelegateVault.json +64 -0
  8. package/artifacts/LSP1UniversalReceiverDelegateVaultInit.json +66 -0
  9. package/artifacts/LSP6KeyManager.json +222 -0
  10. package/artifacts/LSP6KeyManagerInit.json +224 -0
  11. package/artifacts/LSP7CappedSupply.json +404 -0
  12. package/artifacts/LSP7CappedSupplyInit.json +481 -0
  13. package/artifacts/LSP7CompatibilityForERC20.json +495 -0
  14. package/artifacts/LSP7DigitalAsset.json +417 -0
  15. package/artifacts/LSP7DigitalAssetInit.json +455 -0
  16. package/artifacts/LSP7Mintable.json +445 -0
  17. package/artifacts/LSP7MintableInit.json +483 -0
  18. package/artifacts/LSP8CappedSupply.json +459 -0
  19. package/artifacts/LSP8CappedSupplyInit.json +508 -0
  20. package/artifacts/LSP8CompatibilityForERC721.json +711 -0
  21. package/artifacts/LSP8IdentifiableDigitalAsset.json +467 -0
  22. package/artifacts/LSP8IdentifiableDigitalAssetInit.json +482 -0
  23. package/artifacts/LSP8Mintable.json +495 -0
  24. package/artifacts/LSP8MintableInit.json +510 -0
  25. package/artifacts/UniversalProfile.json +373 -0
  26. package/artifacts/UniversalProfileInit.json +375 -0
  27. package/constants.ts +350 -0
  28. package/contracts/Factories/Create2Factory.sol +92 -0
  29. package/contracts/LSP0ERC725Account/LSP0Constants.sol +14 -0
  30. package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +23 -0
  31. package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +119 -0
  32. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +20 -0
  33. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +33 -0
  34. package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiver.sol +37 -0
  35. package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiverDelegate.sol +22 -0
  36. package/contracts/LSP1UniversalReceiver/LSP1Constants.sol +17 -0
  37. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/Handling/TokenAndVaultHandling.sol +189 -0
  38. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +26 -0
  39. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUPCore.sol +52 -0
  40. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUPInit.sol +26 -0
  41. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUPInitAbstract.sol +28 -0
  42. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/Handling/TokenHandling.sol +114 -0
  43. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +23 -0
  44. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVaultCore.sol +41 -0
  45. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVaultInit.sol +23 -0
  46. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVaultInitAbstract.sol +25 -0
  47. package/contracts/LSP4DigitalAssetMetadata/ILSP4Compatibility.sol +23 -0
  48. package/contracts/LSP4DigitalAssetMetadata/LSP4Compatibility.sol +47 -0
  49. package/contracts/LSP4DigitalAssetMetadata/LSP4Constants.sol +19 -0
  50. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol +36 -0
  51. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInit.sol +30 -0
  52. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +41 -0
  53. package/contracts/LSP6KeyManager/ILSP6KeyManager.sol +52 -0
  54. package/contracts/LSP6KeyManager/LSP6Constants.sol +28 -0
  55. package/contracts/LSP6KeyManager/LSP6KeyManager.sol +21 -0
  56. package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +444 -0
  57. package/contracts/LSP6KeyManager/LSP6KeyManagerInit.sol +19 -0
  58. package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +26 -0
  59. package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +186 -0
  60. package/contracts/LSP7DigitalAsset/LSP7Constants.sol +12 -0
  61. package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +35 -0
  62. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +394 -0
  63. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInit.sol +29 -0
  64. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +44 -0
  65. package/contracts/LSP7DigitalAsset/extensions/ILSP7CappedSupply.sol +17 -0
  66. package/contracts/LSP7DigitalAsset/extensions/ILSP7CompatibilityForERC20.sol +47 -0
  67. package/contracts/LSP7DigitalAsset/extensions/ILSP7Mintable.sol +32 -0
  68. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupply.sol +45 -0
  69. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyCore.sol +55 -0
  70. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInit.sol +24 -0
  71. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInitAbstract.sol +50 -0
  72. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibilityForERC20.sol +76 -0
  73. package/contracts/LSP7DigitalAsset/extensions/LSP7Mintable.sol +41 -0
  74. package/contracts/LSP7DigitalAsset/extensions/LSP7MintableCore.sol +26 -0
  75. package/contracts/LSP7DigitalAsset/extensions/LSP7MintableInit.sol +26 -0
  76. package/contracts/LSP7DigitalAsset/extensions/LSP7MintableInitAbstract.sol +47 -0
  77. package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +223 -0
  78. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol +18 -0
  79. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +35 -0
  80. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +470 -0
  81. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInit.sol +29 -0
  82. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +41 -0
  83. package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CappedSupply.sol +17 -0
  84. package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CompatibilityForERC721.sol +108 -0
  85. package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8Mintable.sol +32 -0
  86. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.sol +53 -0
  87. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyCore.sol +56 -0
  88. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInit.sol +24 -0
  89. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInitAbstract.sol +55 -0
  90. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibilityConstants.sol +6 -0
  91. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibilityForERC721.sol +252 -0
  92. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Mintable.sol +36 -0
  93. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8MintableCore.sol +29 -0
  94. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8MintableInit.sol +24 -0
  95. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8MintableInitAbstract.sol +44 -0
  96. package/contracts/LSP9Vault/LSP9Constants.sol +12 -0
  97. package/contracts/LSP9Vault/LSP9Vault.sol +56 -0
  98. package/contracts/LSP9Vault/LSP9VaultCore.sol +174 -0
  99. package/contracts/LSP9Vault/LSP9VaultInit.sol +19 -0
  100. package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +60 -0
  101. package/contracts/UniversalProfile.sol +37 -0
  102. package/contracts/UniversalProfileCore.sol +56 -0
  103. package/contracts/UniversalProfileInit.sol +19 -0
  104. package/contracts/UniversalProfileInitAbstract.sol +48 -0
  105. package/contracts/Utils/ERC725Utils.sol +169 -0
  106. package/contracts/Utils/LSP2Utils.sol +127 -0
  107. package/contracts/Utils/LSP6Utils.sol +77 -0
  108. package/contracts/Utils/UtilsLib.sol +23 -0
  109. package/package.json +84 -0
@@ -0,0 +1,53 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ pragma solidity ^0.8.0;
4
+
5
+ // modules
6
+ import "./LSP8CappedSupplyCore.sol";
7
+ import "../LSP8IdentifiableDigitalAsset.sol";
8
+
9
+ /**
10
+ * @dev LSP8 extension, adds token supply cap.
11
+ */
12
+ abstract contract LSP8CappedSupply is
13
+ LSP8IdentifiableDigitalAsset,
14
+ LSP8CappedSupplyCore
15
+ {
16
+ /**
17
+ * @notice Sets the token max supply
18
+ * @param tokenSupplyCap_ The Token max supply
19
+ */
20
+ constructor(uint256 tokenSupplyCap_) {
21
+ require(
22
+ tokenSupplyCap_ > 0,
23
+ "LSP8CappedSupply: tokenSupplyCap is zero"
24
+ );
25
+ _tokenSupplyCap = tokenSupplyCap_;
26
+ }
27
+
28
+ // --- Overrides
29
+
30
+ /**
31
+ * @dev Mints `tokenId` and transfers it to `to`.
32
+ *
33
+ * Requirements:
34
+ *
35
+ * - `tokenSupplyCap() - totalSupply()` must be greater than zero.
36
+ * - `tokenId` must not exist.
37
+ * - `to` cannot be the zero address.
38
+ *
39
+ * Emits a {Transfer} event.
40
+ */
41
+ function _mint(
42
+ address to,
43
+ bytes32 tokenId,
44
+ bool force,
45
+ bytes memory data
46
+ )
47
+ internal
48
+ virtual
49
+ override(LSP8IdentifiableDigitalAssetCore, LSP8CappedSupplyCore)
50
+ {
51
+ super._mint(to, tokenId, force, data);
52
+ }
53
+ }
@@ -0,0 +1,56 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ pragma solidity ^0.8.0;
4
+
5
+ // modules
6
+ import "../LSP8IdentifiableDigitalAssetCore.sol";
7
+
8
+ // interfaces
9
+ import "./ILSP8CappedSupply.sol";
10
+
11
+ /**
12
+ * @dev LSP8 extension, adds token supply cap.
13
+ */
14
+ abstract contract LSP8CappedSupplyCore is
15
+ ILSP8CappedSupply,
16
+ LSP8IdentifiableDigitalAssetCore
17
+ {
18
+ // --- Storage
19
+
20
+ uint256 internal _tokenSupplyCap;
21
+
22
+ // --- Token queries
23
+
24
+ /**
25
+ * @inheritdoc ILSP8CappedSupply
26
+ */
27
+ function tokenSupplyCap() public view virtual override returns (uint256) {
28
+ return _tokenSupplyCap;
29
+ }
30
+
31
+ // --- Transfer functionality
32
+
33
+ /**
34
+ * @dev Mints `tokenId` and transfers it to `to`.
35
+ *
36
+ * Requirements:
37
+ *
38
+ * - `tokenSupplyCap() - totalSupply()` must be greater than zero.
39
+ * - `tokenId` must not exist.
40
+ * - `to` cannot be the zero address.
41
+ *
42
+ * Emits a {Transfer} event.
43
+ */
44
+ function _mint(
45
+ address to,
46
+ bytes32 tokenId,
47
+ bool force,
48
+ bytes memory data
49
+ ) internal virtual override {
50
+ require(
51
+ totalSupply() + 1 <= tokenSupplyCap(),
52
+ "LSP8CappedSupply: tokenSupplyCap reached"
53
+ );
54
+ super._mint(to, tokenId, force, data);
55
+ }
56
+ }
@@ -0,0 +1,24 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ pragma solidity ^0.8.0;
4
+
5
+ // modules
6
+ import "./LSP8CappedSupplyInitAbstract.sol";
7
+
8
+ /**
9
+ * @dev LSP8 extension, adds token supply cap.
10
+ */
11
+ abstract contract LSP8CappedSupplyInit is LSP8CappedSupplyInitAbstract {
12
+ /**
13
+ * @notice Sets the token max supply
14
+ * @param tokenSupplyCap_ The Token max supply
15
+ */
16
+ function initialize(uint256 tokenSupplyCap_)
17
+ public
18
+ virtual
19
+ override
20
+ initializer
21
+ {
22
+ LSP8CappedSupplyInitAbstract.initialize(tokenSupplyCap_);
23
+ }
24
+ }
@@ -0,0 +1,55 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ pragma solidity ^0.8.0;
4
+
5
+ // modules
6
+ import "./LSP8CappedSupplyCore.sol";
7
+ import "../LSP8IdentifiableDigitalAssetInit.sol";
8
+
9
+ /**
10
+ * @dev LSP8 extension, adds token supply cap.
11
+ */
12
+ abstract contract LSP8CappedSupplyInitAbstract is
13
+ Initializable,
14
+ LSP8IdentifiableDigitalAssetInit,
15
+ LSP8CappedSupplyCore
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, "LSP8Capped: tokenSupplyCap is zero");
27
+ _tokenSupplyCap = tokenSupplyCap_;
28
+ }
29
+
30
+ // --- Overrides
31
+
32
+ /**
33
+ * @dev Mints `tokenId` and transfers it to `to`.
34
+ *
35
+ * Requirements:
36
+ *
37
+ * - `tokenSupplyCap() - totalSupply()` must be greater than zero.
38
+ * - `tokenId` must not exist.
39
+ * - `to` cannot be the zero address.
40
+ *
41
+ * Emits a {Transfer} event.
42
+ */
43
+ function _mint(
44
+ address to,
45
+ bytes32 tokenId,
46
+ bool force,
47
+ bytes memory data
48
+ )
49
+ internal
50
+ virtual
51
+ override(LSP8IdentifiableDigitalAssetCore, LSP8CappedSupplyCore)
52
+ {
53
+ super._mint(to, tokenId, force, data);
54
+ }
55
+ }
@@ -0,0 +1,6 @@
1
+ // SPDX-License-Identifier: CC0-1.0
2
+ pragma solidity ^0.8.0;
3
+
4
+ // --- ERC165 interface ids
5
+ bytes4 constant _INTERFACEID_ERC721 = 0x80ac58cd;
6
+ bytes4 constant _INTERFACEID_ERC721METADATA = 0x5b5e139f;
@@ -0,0 +1,252 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ pragma solidity ^0.8.0;
4
+
5
+ // modules
6
+ import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
7
+ import "../LSP8IdentifiableDigitalAsset.sol";
8
+ import "../../LSP4DigitalAssetMetadata/LSP4Compatibility.sol";
9
+
10
+ // libraries
11
+ import "solidity-bytes-utils/contracts/BytesLib.sol";
12
+
13
+ // interfaces
14
+ import "./ILSP8CompatibilityForERC721.sol";
15
+
16
+ // constants
17
+ import "./LSP8CompatibilityConstants.sol";
18
+
19
+ /**
20
+ * @dev LSP8 extension, for compatibility for clients / tools that expect ERC721.
21
+ */
22
+ contract LSP8CompatibilityForERC721 is
23
+ ILSP8CompatibilityForERC721,
24
+ LSP8IdentifiableDigitalAsset,
25
+ LSP4Compatibility
26
+ {
27
+ using EnumerableSet for EnumerableSet.AddressSet;
28
+
29
+ /* solhint-disable no-empty-blocks */
30
+ /**
31
+ * @notice Sets the name, the symbol and the owner of the token
32
+ * @param name_ The name of the token
33
+ * @param symbol_ The symbol of the token
34
+ * @param newOwner_ The owner of the token
35
+ */
36
+ constructor(
37
+ string memory name_,
38
+ string memory symbol_,
39
+ address newOwner_
40
+ ) LSP8IdentifiableDigitalAsset(name_, symbol_, newOwner_) {
41
+ _registerInterface(_INTERFACEID_ERC721);
42
+ _registerInterface(_INTERFACEID_ERC721METADATA);
43
+ }
44
+
45
+ // solhint-disable no-unused-vars
46
+ /*
47
+ * @inheritdoc ILSP8CompatibilityForERC721
48
+ */
49
+ function tokenURI(uint256 tokenId)
50
+ public
51
+ view
52
+ virtual
53
+ override
54
+ returns (string memory)
55
+ {
56
+ bytes memory data = ERC725Utils.getDataSingle(this, _LSP4_METADATA_KEY);
57
+
58
+ // offset = bytes4(hashSig) + bytes32(contentHash) -> 4 + 32 = 36
59
+ uint256 offset = 36;
60
+
61
+ bytes memory uriBytes = BytesLib.slice(
62
+ data,
63
+ offset,
64
+ data.length - offset
65
+ );
66
+ return string(uriBytes);
67
+ }
68
+
69
+ /**
70
+ * @inheritdoc ILSP8CompatibilityForERC721
71
+ */
72
+ function ownerOf(uint256 tokenId)
73
+ external
74
+ view
75
+ virtual
76
+ override
77
+ returns (address)
78
+ {
79
+ return tokenOwnerOf(bytes32(tokenId));
80
+ }
81
+
82
+ /**
83
+ * @inheritdoc ILSP8CompatibilityForERC721
84
+ */
85
+ function approve(address operator, uint256 tokenId)
86
+ external
87
+ virtual
88
+ override
89
+ {
90
+ authorizeOperator(operator, bytes32(tokenId));
91
+
92
+ emit Approval(tokenOwnerOf(bytes32(tokenId)), operator, tokenId);
93
+ }
94
+
95
+ /**
96
+ * @inheritdoc ILSP8CompatibilityForERC721
97
+ */
98
+ function getApproved(uint256 tokenId)
99
+ external
100
+ view
101
+ virtual
102
+ override
103
+ returns (address)
104
+ {
105
+ require(
106
+ _exists(bytes32(tokenId)),
107
+ "LSP8: can not query operator for non existent token"
108
+ );
109
+
110
+ EnumerableSet.AddressSet storage operatorsForTokenId = _operators[
111
+ bytes32(tokenId)
112
+ ];
113
+ uint256 operatorListLength = operatorsForTokenId.length();
114
+
115
+ if (operatorListLength == 0) {
116
+ return address(0);
117
+ } else {
118
+ // Read the last added operator authorized to provide "best" compatibility.
119
+ // In ERC721 there is one operator address at a time for a tokenId, so multiple calls to
120
+ // `approve` would cause `getApproved` to return the last added operator. In this
121
+ // compatibility version the same is true, when the authorized operators were not previously
122
+ // authorized. If addresses are removed, then `getApproved` returned address can change due
123
+ // to implementation of `EnumberableSet._remove`.
124
+ return operatorsForTokenId.at(operatorListLength - 1);
125
+ }
126
+ }
127
+
128
+ // solhint-disable no-unused-vars
129
+ /*
130
+ * @inheritdoc ILSP8CompatibilityForERC721
131
+ */
132
+ function isApprovedForAll(uint256 tokenId)
133
+ public
134
+ virtual
135
+ override
136
+ returns (bool)
137
+ {
138
+ return false;
139
+ }
140
+
141
+ /**
142
+ * @inheritdoc ILSP8CompatibilityForERC721
143
+ * @dev Compatible with ERC721 transferFrom.
144
+ * Using force=true so that EOA and any contract may receive the tokenId.
145
+ */
146
+ function transferFrom(
147
+ address from,
148
+ address to,
149
+ uint256 tokenId
150
+ ) external virtual override {
151
+ return
152
+ transfer(from, to, bytes32(tokenId), true, "compat-transferFrom");
153
+ }
154
+
155
+ /**
156
+ * @inheritdoc ILSP8CompatibilityForERC721
157
+ * @dev Compatible with ERC721 safeTransferFrom.
158
+ * Using force=false so that no EOA and only contracts supporting LSP1 interface may receive the tokenId.
159
+ */
160
+ function safeTransferFrom(
161
+ address from,
162
+ address to,
163
+ uint256 tokenId
164
+ ) external virtual override {
165
+ return
166
+ transfer(
167
+ from,
168
+ to,
169
+ bytes32(tokenId),
170
+ false,
171
+ "compat-safeTransferFrom"
172
+ );
173
+ }
174
+
175
+ /*
176
+ * @dev Compatible with ERC721 safeTransferFrom.
177
+ * Using force=false so that no EOA and only contracts supporting LSP1 interface may receive the tokenId.
178
+ */
179
+ function safeTransferFrom(
180
+ address from,
181
+ address to,
182
+ uint256 tokenId,
183
+ bytes memory data
184
+ ) external virtual override {
185
+ return transfer(from, to, bytes32(tokenId), false, data);
186
+ }
187
+
188
+ // --- Overrides
189
+
190
+ function authorizeOperator(address operator, bytes32 tokenId)
191
+ public
192
+ virtual
193
+ override(
194
+ ILSP8IdentifiableDigitalAsset,
195
+ LSP8IdentifiableDigitalAssetCore
196
+ )
197
+ {
198
+ super.authorizeOperator(operator, tokenId);
199
+
200
+ emit Approval(
201
+ tokenOwnerOf(tokenId),
202
+ operator,
203
+ abi.decode(abi.encodePacked(tokenId), (uint256))
204
+ );
205
+ }
206
+
207
+ function _transfer(
208
+ address from,
209
+ address to,
210
+ bytes32 tokenId,
211
+ bool force,
212
+ bytes memory data
213
+ ) internal virtual override {
214
+ super._transfer(from, to, tokenId, force, data);
215
+
216
+ emit Transfer(
217
+ from,
218
+ to,
219
+ abi.decode(abi.encodePacked(tokenId), (uint256))
220
+ );
221
+ }
222
+
223
+ function _mint(
224
+ address to,
225
+ bytes32 tokenId,
226
+ bool force,
227
+ bytes memory data
228
+ ) internal virtual override {
229
+ super._mint(to, tokenId, force, data);
230
+
231
+ emit Transfer(
232
+ address(0),
233
+ to,
234
+ abi.decode(abi.encodePacked(tokenId), (uint256))
235
+ );
236
+ }
237
+
238
+ function _burn(bytes32 tokenId, bytes memory data)
239
+ internal
240
+ virtual
241
+ override
242
+ {
243
+ super._burn(tokenId, data);
244
+
245
+ address tokenOwner = tokenOwnerOf(tokenId);
246
+ emit Transfer(
247
+ tokenOwner,
248
+ address(0),
249
+ abi.decode(abi.encodePacked(tokenId), (uint256))
250
+ );
251
+ }
252
+ }
@@ -0,0 +1,36 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ pragma solidity ^0.8.0;
4
+
5
+ import "./LSP8MintableCore.sol";
6
+ import "../LSP8IdentifiableDigitalAsset.sol";
7
+
8
+ /**
9
+ * @dev LSP8 extension.
10
+ */
11
+ contract LSP8Mintable is LSP8MintableCore, LSP8IdentifiableDigitalAsset {
12
+ // solhint-disable no-empty-blocks
13
+ /**
14
+ * @notice Sets the token-Metadata and register LSP8InterfaceId
15
+ * @param name_ The name of the token
16
+ * @param symbol_ The symbol of the token
17
+ * @param newOwner_ The owner of the the token-Metadata
18
+ */
19
+ constructor(
20
+ string memory name_,
21
+ string memory symbol_,
22
+ address newOwner_
23
+ ) LSP8IdentifiableDigitalAsset(name_, symbol_, newOwner_) {}
24
+
25
+ /**
26
+ * @inheritdoc LSP8MintableCore
27
+ */
28
+ function mint(
29
+ address to,
30
+ bytes32 tokenId,
31
+ bool force,
32
+ bytes memory data
33
+ ) public override onlyOwner {
34
+ _mint(to, tokenId, force, data);
35
+ }
36
+ }
@@ -0,0 +1,29 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ pragma solidity ^0.8.0;
4
+
5
+ // modules
6
+ import "../LSP8IdentifiableDigitalAssetCore.sol";
7
+
8
+ // interfaces
9
+ import "./ILSP8Mintable.sol";
10
+
11
+ /**
12
+ * @dev LSP8 extension
13
+ */
14
+ abstract contract LSP8MintableCore is
15
+ ILSP8Mintable,
16
+ LSP8IdentifiableDigitalAssetCore
17
+ {
18
+ /**
19
+ * @inheritdoc ILSP8Mintable
20
+ */
21
+ function mint(
22
+ address to,
23
+ bytes32 tokenId,
24
+ bool force,
25
+ bytes memory data
26
+ ) public virtual override {
27
+ _mint(to, tokenId, force, data);
28
+ }
29
+ }
@@ -0,0 +1,24 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ pragma solidity ^0.8.0;
4
+
5
+ import "./LSP8MintableInitAbstract.sol";
6
+
7
+ /**
8
+ * @dev LSP8 extension.
9
+ */
10
+ contract LSP8MintableInit is LSP8MintableInitAbstract {
11
+ /**
12
+ * @notice Sets the token-Metadata and register LSP8InterfaceId
13
+ * @param name_ The name of the token
14
+ * @param symbol_ The symbol of the token
15
+ * @param newOwner_ The owner of the the token-Metadata
16
+ */
17
+ function initialize(
18
+ string memory name_,
19
+ string memory symbol_,
20
+ address newOwner_
21
+ ) public virtual override initializer {
22
+ LSP8MintableInitAbstract.initialize(name_, symbol_, newOwner_);
23
+ }
24
+ }
@@ -0,0 +1,44 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ pragma solidity ^0.8.0;
4
+
5
+ import "./LSP8MintableCore.sol";
6
+ import "../LSP8IdentifiableDigitalAssetInit.sol";
7
+
8
+ /**
9
+ * @dev LSP8 extension.
10
+ */
11
+ abstract contract LSP8MintableInitAbstract is
12
+ LSP8MintableCore,
13
+ LSP8IdentifiableDigitalAssetInit
14
+ {
15
+ /**
16
+ * @notice Sets the token-Metadata and register LSP8InterfaceId
17
+ * @param name_ The name of the token
18
+ * @param symbol_ The symbol of the token
19
+ * @param newOwner_ The owner of the the token-Metadata
20
+ */
21
+ function initialize(
22
+ string memory name_,
23
+ string memory symbol_,
24
+ address newOwner_
25
+ ) public virtual override onlyInitializing {
26
+ LSP8IdentifiableDigitalAssetInitAbstract.initialize(
27
+ name_,
28
+ symbol_,
29
+ newOwner_
30
+ );
31
+ }
32
+
33
+ /**
34
+ * @inheritdoc LSP8MintableCore
35
+ */
36
+ function mint(
37
+ address to,
38
+ bytes32 tokenId,
39
+ bool force,
40
+ bytes memory data
41
+ ) public virtual override onlyOwner {
42
+ _mint(to, tokenId, force, data);
43
+ }
44
+ }
@@ -0,0 +1,12 @@
1
+ // SPDX-License-Identifier: CC0-1.0
2
+ pragma solidity ^0.8.0;
3
+
4
+ // --- ERC165 interface ids
5
+ bytes4 constant _INTERFACEID_LSP9 = 0x75edcee5;
6
+
7
+ // --- ERC725Y entries
8
+
9
+ // --- Token Hooks
10
+ bytes32 constant _TYPEID_LSP9_VAULTSENDER = 0x3ca9f769340018257ac15b3a00e502e8fb730d66086f774210f84d0205af31e7; // keccak256("LSP9VaultSender")
11
+
12
+ bytes32 constant _TYPEID_LSP9_VAULTRECIPIENT = 0x09aaf55960715d8d86b57af40be36b0bfd469c9a3643445d8c65d39e27b4c56f; // keccak256("LSP9VaultRecipient")
@@ -0,0 +1,56 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.0;
3
+
4
+ // modules
5
+ import "@erc725/smart-contracts/contracts/ERC725.sol";
6
+ import "./LSP9VaultCore.sol";
7
+
8
+ // constants
9
+ import "../LSP1UniversalReceiver/LSP1Constants.sol";
10
+
11
+ /**
12
+ * @title Implementation of LSP9Vault built on top of ERC725, LSP1UniversalReceiver
13
+ * @author Fabian Vogelsteller, Yamen Merhi, Jean Cavallera
14
+ * @dev Could be owned by a UniversalProfile and able to register received asset with UniversalReceiverDelegateVault
15
+ */
16
+ contract LSP9Vault is LSP9VaultCore, ERC725 {
17
+ /**
18
+ * @notice Sets the owner of the contract and sets the SupportedStandards:LSP9Vault key and register
19
+ * LSP1UniversalReceiver and LSP9Vault InterfaceId
20
+ * @param _newOwner the owner of the contract
21
+ */
22
+ constructor(address _newOwner) ERC725(_newOwner) {
23
+ // set SupportedStandards:LSP9Vault
24
+ bytes32 key = 0xeafec4d89fa9619884b6b891356264550000000000000000000000007c0334a1;
25
+ bytes memory value = hex"7c0334a1";
26
+ _setData(key, value);
27
+
28
+ _notifyVaultReceiver(_newOwner);
29
+
30
+ _registerInterface(_INTERFACEID_LSP1);
31
+ _registerInterface(_INTERFACEID_LSP9);
32
+ }
33
+
34
+ /**
35
+ * @inheritdoc OwnableUnset
36
+ */
37
+ function transferOwnership(address newOwner)
38
+ public
39
+ override(OwnableUnset, LSP9VaultCore)
40
+ onlyOwner
41
+ {
42
+ LSP9VaultCore.transferOwnership(newOwner);
43
+ }
44
+
45
+ /**
46
+ * @inheritdoc LSP9VaultCore
47
+ */
48
+ function setData(bytes32[] memory _keys, bytes[] memory _values)
49
+ public
50
+ virtual
51
+ override(ERC725YCore, LSP9VaultCore)
52
+ onlyAllowed
53
+ {
54
+ LSP9VaultCore.setData(_keys, _values);
55
+ }
56
+ }