@lukso/lsp7-contracts 0.15.0-rc.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 (41) hide show
  1. package/README.md +3 -0
  2. package/artifacts/LSP7CappedSupply.json +828 -0
  3. package/artifacts/LSP7CappedSupplyInitAbstract.json +841 -0
  4. package/artifacts/LSP7DigitalAsset.json +805 -0
  5. package/artifacts/LSP7DigitalAssetInitAbstract.json +818 -0
  6. package/artifacts/LSP7Mintable.json +864 -0
  7. package/artifacts/LSP7MintableInit.json +884 -0
  8. package/contracts/ILSP7DigitalAsset.sol +309 -0
  9. package/contracts/LSP7Constants.sol +16 -0
  10. package/contracts/LSP7DigitalAsset.sol +198 -0
  11. package/contracts/LSP7DigitalAssetCore.sol +744 -0
  12. package/contracts/LSP7DigitalAssetInitAbstract.sol +194 -0
  13. package/contracts/LSP7Errors.sol +103 -0
  14. package/contracts/extensions/LSP7Burnable.sol +26 -0
  15. package/contracts/extensions/LSP7BurnableInitAbstract.sol +27 -0
  16. package/contracts/extensions/LSP7CappedSupply.sol +83 -0
  17. package/contracts/extensions/LSP7CappedSupplyInitAbstract.sol +86 -0
  18. package/contracts/presets/ILSP7Mintable.sol +32 -0
  19. package/contracts/presets/LSP7Mintable.sol +53 -0
  20. package/contracts/presets/LSP7MintableInit.sol +44 -0
  21. package/contracts/presets/LSP7MintableInitAbstract.sol +57 -0
  22. package/dist/index.cjs +14 -0
  23. package/dist/index.d.cts +8 -0
  24. package/dist/index.d.mts +8 -0
  25. package/dist/index.d.ts +8 -0
  26. package/dist/index.mjs +11 -0
  27. package/package.json +54 -0
  28. package/types/LSP7CappedSupply.ts +712 -0
  29. package/types/LSP7CappedSupplyInitAbstract.ts +743 -0
  30. package/types/LSP7DigitalAsset.ts +698 -0
  31. package/types/LSP7DigitalAssetInitAbstract.ts +729 -0
  32. package/types/LSP7Mintable.ts +717 -0
  33. package/types/LSP7MintableInit.ts +779 -0
  34. package/types/common.ts +131 -0
  35. package/types/contracts/LSP7DigitalAsset.ts +698 -0
  36. package/types/contracts/LSP7DigitalAssetInitAbstract.ts +729 -0
  37. package/types/contracts/extensions/LSP7CappedSupply.ts +712 -0
  38. package/types/contracts/extensions/LSP7CappedSupplyInitAbstract.ts +743 -0
  39. package/types/contracts/presets/LSP7Mintable.ts +717 -0
  40. package/types/contracts/presets/LSP7MintableInit.ts +779 -0
  41. package/types/index.ts +16 -0
@@ -0,0 +1,194 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.4;
3
+
4
+ // interfaces
5
+ import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
6
+
7
+ // modules
8
+ import {ERC725YCore} from "@erc725/smart-contracts/contracts/ERC725YCore.sol";
9
+ import {
10
+ LSP4DigitalAssetMetadataInitAbstract
11
+ } from "@lukso/lsp4-contracts/contracts/LSP4DigitalAssetMetadataInitAbstract.sol";
12
+ import {LSP7DigitalAssetCore} from "./LSP7DigitalAssetCore.sol";
13
+
14
+ import {
15
+ LSP17Extendable
16
+ } from "@lukso/lsp17contractextension-contracts/contracts/LSP17Extendable.sol";
17
+
18
+ // libraries
19
+ import {LSP2Utils} from "@lukso/lsp2-contracts/contracts/LSP2Utils.sol";
20
+
21
+ // constants
22
+ import {_INTERFACEID_LSP7} from "./LSP7Constants.sol";
23
+ import {LSP7TokenContractCannotHoldValue} from "./LSP7Errors.sol";
24
+
25
+ import {
26
+ _LSP17_EXTENSION_PREFIX
27
+ } from "@lukso/lsp17contractextension-contracts/contracts/LSP17Constants.sol";
28
+
29
+ // errors
30
+
31
+ import {
32
+ NoExtensionFoundForFunctionSelector,
33
+ InvalidFunctionSelector,
34
+ InvalidExtensionAddress
35
+ } from "@lukso/lsp17contractextension-contracts/contracts/LSP17Errors.sol";
36
+
37
+ /**
38
+ * @title LSP7DigitalAsset contract
39
+ * @author Matthew Stevens
40
+ * @dev Proxy Implementation of a LSP7 compliant contract.
41
+ */
42
+ abstract contract LSP7DigitalAssetInitAbstract is
43
+ LSP4DigitalAssetMetadataInitAbstract,
44
+ LSP7DigitalAssetCore,
45
+ LSP17Extendable
46
+ {
47
+ function _initialize(
48
+ string memory name_,
49
+ string memory symbol_,
50
+ address newOwner_,
51
+ uint256 lsp4TokenType_,
52
+ bool isNonDivisible_
53
+ ) internal virtual onlyInitializing {
54
+ LSP4DigitalAssetMetadataInitAbstract._initialize(
55
+ name_,
56
+ symbol_,
57
+ newOwner_,
58
+ lsp4TokenType_
59
+ );
60
+
61
+ _isNonDivisible = isNonDivisible_;
62
+ }
63
+
64
+ // fallback function
65
+
66
+ /**
67
+ * @notice The `fallback` function was called with the following amount of native tokens: `msg.value`; and the following calldata: `callData`.
68
+ *
69
+ * @dev Achieves the goal of [LSP-17-ContractExtension] standard by extending the contract to handle calls of functions that do not exist natively,
70
+ * forwarding the function call to the extension address mapped to the function being called.
71
+ *
72
+ * This function is executed when:
73
+ * - Sending data of length less than 4 bytes to the contract.
74
+ * - The first 4 bytes of the calldata do not match any publicly callable functions from the contract ABI.
75
+ * - Receiving native tokens
76
+ *
77
+ * 1. If the data is equal or longer than 4 bytes, the [ERC-725Y] storage is queried with the following data key: [_LSP17_EXTENSION_PREFIX] + `bytes4(msg.sig)` (Check [LSP-2-ERC725YJSONSchema] for encoding the data key)
78
+ *
79
+ * - If there is no address stored under the following data key, revert with {NoExtensionFoundForFunctionSelector(bytes4)}. The data key relative to `bytes4(0)` is an exception, where no reverts occurs if there is no extension address stored under. This exception is made to allow users to send random data (graffiti) to the account and to be able to react on it.
80
+ *
81
+ * - If there is an address, forward the `msg.data` to the extension using the CALL opcode, appending 52 bytes (20 bytes of `msg.sender` and 32 bytes of `msg.value`). Return what the calls returns, or revert if the call failed.
82
+ *
83
+ * 2. If the data sent to this function is of length less than 4 bytes (not a function selector), revert.
84
+ */
85
+ // solhint-disable-next-line no-complex-fallback
86
+ fallback(
87
+ bytes calldata callData
88
+ ) external payable virtual returns (bytes memory) {
89
+ if (msg.data.length < 4) {
90
+ revert InvalidFunctionSelector(callData);
91
+ }
92
+ return _fallbackLSP17Extendable(callData);
93
+ }
94
+
95
+ /**
96
+ * @dev Reverts whenever someone tries to send native tokens to a LSP7 contract.
97
+ * @notice LSP7 contract cannot receive native tokens.
98
+ */
99
+ receive() external payable virtual {
100
+ // revert on empty calls with no value
101
+ if (msg.value == 0) {
102
+ revert InvalidFunctionSelector(hex"00000000");
103
+ }
104
+
105
+ revert LSP7TokenContractCannotHoldValue();
106
+ }
107
+
108
+ /**
109
+ * @dev Forwards the call with the received value to an extension mapped to a function selector.
110
+ *
111
+ * Calls {_getExtensionAndForwardValue} to get the address of the extension mapped to the function selector being
112
+ * called on the account. If there is no extension, the address(0) will be returned.
113
+ * Forwards the value if the extension is payable.
114
+ *
115
+ * Reverts if there is no extension for the function being called.
116
+ *
117
+ * If there is an extension for the function selector being called, it calls the extension with the
118
+ * CALL opcode, passing the {msg.data} appended with the 20 bytes of the {msg.sender} and
119
+ * 32 bytes of the {msg.value}
120
+ *
121
+ * @custom:info The LSP7 Token contract should not hold any native tokens. Any native tokens received by the contract
122
+ * will be forwarded to the extension address mapped to the selector from `msg.sig`.
123
+ */
124
+ function _fallbackLSP17Extendable(
125
+ bytes calldata callData
126
+ ) internal virtual override returns (bytes memory) {
127
+ // If there is a function selector
128
+ (address extension, ) = _getExtensionAndForwardValue(msg.sig);
129
+
130
+ // if no extension was found, revert
131
+ if (extension == address(0))
132
+ revert NoExtensionFoundForFunctionSelector(msg.sig);
133
+
134
+ (bool success, bytes memory result) = extension.call{value: msg.value}(
135
+ abi.encodePacked(callData, msg.sender, msg.value)
136
+ );
137
+
138
+ if (success) {
139
+ return result;
140
+ } else {
141
+ // `mload(result)` -> offset in memory where `result.length` is located
142
+ // `add(result, 32)` -> offset in memory where `result` data starts
143
+ // solhint-disable no-inline-assembly
144
+ /// @solidity memory-safe-assembly
145
+ assembly {
146
+ let resultdata_size := mload(result)
147
+ revert(add(result, 32), resultdata_size)
148
+ }
149
+ }
150
+ }
151
+
152
+ /**
153
+ * @dev Returns the extension address stored under the following data key:
154
+ * - {_LSP17_EXTENSION_PREFIX} + `<bytes4>` (Check [LSP2-ERC725YJSONSchema] for encoding the data key).
155
+ * - If no extension is stored, returns the address(0).
156
+ * - We do not check that payable bool as in lsp7 standard we will always forward the value to the extension
157
+ */
158
+ function _getExtensionAndForwardValue(
159
+ bytes4 functionSelector
160
+ ) internal view virtual override returns (address, bool) {
161
+ // Generate the data key relevant for the functionSelector being called
162
+ bytes32 mappedExtensionDataKey = LSP2Utils.generateMappingKey(
163
+ _LSP17_EXTENSION_PREFIX,
164
+ functionSelector
165
+ );
166
+
167
+ // Check if there is an extension stored under the generated data key
168
+ bytes memory extensionAddress = ERC725YCore._getData(
169
+ mappedExtensionDataKey
170
+ );
171
+ if (extensionAddress.length != 20 && extensionAddress.length != 0)
172
+ revert InvalidExtensionAddress(extensionAddress);
173
+
174
+ return (address(bytes20(extensionAddress)), true);
175
+ }
176
+
177
+ /**
178
+ * @dev See {IERC165-supportsInterface}.
179
+ */
180
+ function supportsInterface(
181
+ bytes4 interfaceId
182
+ )
183
+ public
184
+ view
185
+ virtual
186
+ override(IERC165, ERC725YCore, LSP17Extendable)
187
+ returns (bool)
188
+ {
189
+ return
190
+ interfaceId == _INTERFACEID_LSP7 ||
191
+ super.supportsInterface(interfaceId) ||
192
+ LSP17Extendable._supportsInterfaceInERC165Extension(interfaceId);
193
+ }
194
+ }
@@ -0,0 +1,103 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.4;
3
+
4
+ // --- Errors
5
+
6
+ /**
7
+ * @dev reverts when sending an `amount` of tokens larger than the current `balance` of the `tokenOwner`.
8
+ */
9
+ error LSP7AmountExceedsBalance(
10
+ uint256 balance,
11
+ address tokenOwner,
12
+ uint256 amount
13
+ );
14
+
15
+ /**
16
+ * @dev reverts when `operator` of `tokenOwner` send an `amount` of tokens
17
+ * larger than the `authorizedAmount`.
18
+ */
19
+ error LSP7AmountExceedsAuthorizedAmount(
20
+ address tokenOwner,
21
+ uint256 authorizedAmount,
22
+ address operator,
23
+ uint256 amount
24
+ );
25
+
26
+ /**
27
+ * @dev reverts when trying to set the zero address as an operator.
28
+ */
29
+ error LSP7CannotUseAddressZeroAsOperator();
30
+
31
+ /**
32
+ * @dev reverts when trying to:
33
+ * - mint tokens to the zero address.
34
+ * - burn tokens from the zero address.
35
+ * - transfer tokens from or to the zero address.
36
+ */
37
+ error LSP7CannotSendWithAddressZero();
38
+
39
+ /**
40
+ * @dev reverts when the array parameters used in {transferBatch} have different lengths.
41
+ */
42
+ error LSP7InvalidTransferBatch();
43
+
44
+ /**
45
+ * @dev reverts if the `tokenReceiver` does not implement LSP1
46
+ * when minting or transferring tokens with `bool force` set as `false`.
47
+ */
48
+ error LSP7NotifyTokenReceiverContractMissingLSP1Interface(
49
+ address tokenReceiver
50
+ );
51
+
52
+ /**
53
+ * @dev reverts if the `tokenReceiver` is an EOA when minting or transferring tokens with `bool force` set as `false`.
54
+ */
55
+ error LSP7NotifyTokenReceiverIsEOA(address tokenReceiver);
56
+
57
+ /**
58
+ * @dev reverts when trying to authorize or revoke the token's owner as an operator.
59
+ */
60
+ error LSP7TokenOwnerCannotBeOperator();
61
+
62
+ /**
63
+ * @dev Reverts when trying to decrease an operator's allowance to more than its current allowance.
64
+ */
65
+ error LSP7DecreasedAllowanceBelowZero();
66
+
67
+ /**
68
+ * @dev Error occurs when sending native tokens to the LSP7 contract without sending any data.
69
+ *
70
+ * E.g. Sending value without passing a bytes4 function selector to call a LSP17 Extension.
71
+ *
72
+ * @notice LSP7 contract cannot receive native tokens.
73
+ */
74
+ error LSP7TokenContractCannotHoldValue();
75
+
76
+ /**
77
+ * @dev Reverts when token owner call {increaseAllowance} for an operator that does not have any allowance
78
+ */
79
+ error OperatorAllowanceCannotBeIncreasedFromZero(address operator);
80
+
81
+ /**
82
+ * @dev Reverts when a batch call failed.
83
+ * @notice Batch call failed.
84
+ */
85
+ error LSP7BatchCallFailed(uint256 callIndex);
86
+
87
+ /**
88
+ * @dev Reverts when the call to revoke operator is not authorized.
89
+ */
90
+ error LSP7RevokeOperatorNotAuthorized(
91
+ address caller,
92
+ address tokenOwner,
93
+ address operator
94
+ );
95
+
96
+ /**
97
+ * @dev Reverts when the call to decrease allowance is not authorized.
98
+ */
99
+ error LSP7DecreaseAllowanceNotAuthorized(
100
+ address caller,
101
+ address tokenOwner,
102
+ address operator
103
+ );
@@ -0,0 +1,26 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.4;
3
+
4
+ // modules
5
+ import {LSP7DigitalAsset} from "../LSP7DigitalAsset.sol";
6
+
7
+ /**
8
+ * @title LSP7 token extension that allows token holders to destroy both
9
+ * their own tokens and those that they have an allowance for as an operator.
10
+ */
11
+ abstract contract LSP7Burnable is LSP7DigitalAsset {
12
+ /**
13
+ * @dev See internal {_burn} function for details.
14
+ */
15
+ function burn(
16
+ address from,
17
+ uint256 amount,
18
+ bytes memory data
19
+ ) public virtual {
20
+ if (msg.sender != from) {
21
+ _spendAllowance(msg.sender, from, amount);
22
+ }
23
+
24
+ _burn(from, amount, data);
25
+ }
26
+ }
@@ -0,0 +1,27 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ pragma solidity ^0.8.4;
3
+
4
+ // modules
5
+ import {
6
+ LSP7DigitalAssetInitAbstract
7
+ } from "../LSP7DigitalAssetInitAbstract.sol";
8
+
9
+ /**
10
+ * @title LSP7 token extension that allows token holders to destroy both
11
+ * their own tokens and those that they have an allowance for as an operator.
12
+ */
13
+ abstract contract LSP7BurnableInitAbstract is LSP7DigitalAssetInitAbstract {
14
+ /**
15
+ * @dev See internal {_burn} function for details.
16
+ */
17
+ function burn(
18
+ address from,
19
+ uint256 amount,
20
+ bytes memory data
21
+ ) public virtual {
22
+ if (msg.sender != from) {
23
+ _spendAllowance(msg.sender, from, amount);
24
+ }
25
+ _burn(from, amount, data);
26
+ }
27
+ }
@@ -0,0 +1,83 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+
3
+ pragma solidity ^0.8.4;
4
+
5
+ // modules
6
+ import {LSP7DigitalAsset} from "../LSP7DigitalAsset.sol";
7
+
8
+ /**
9
+ * @dev LSP7 token extension to add a max token supply cap.
10
+ */
11
+ abstract contract LSP7CappedSupply is LSP7DigitalAsset {
12
+ // --- Errors
13
+
14
+ /**
15
+ * @notice The `tokenSupplyCap` must be set and cannot be `0`.
16
+ * @dev Reverts when setting `0` for the {tokenSupplyCap}. The max token supply MUST be set to a number greater than 0.
17
+ */
18
+ error LSP7CappedSupplyRequired();
19
+
20
+ /**
21
+ * @notice Cannot mint anymore as total supply reached the maximum cap.
22
+ * @dev Reverts when trying to mint tokens but the {totalSupply} has reached the maximum {tokenSupplyCap}.
23
+ */
24
+ error LSP7CappedSupplyCannotMintOverCap();
25
+
26
+ // --- Storage
27
+ uint256 private immutable _TOKEN_SUPPLY_CAP;
28
+
29
+ /**
30
+ * @notice Deploying a `LSP7CappedSupply` token contract with max token supply cap set to `tokenSupplyCap_`.
31
+ * @dev Deploy a `LSP7CappedSupply` token contract and set the maximum token supply token cap up to which
32
+ * it is not possible to mint more tokens.
33
+ *
34
+ * @param tokenSupplyCap_ The maximum token supply.
35
+ *
36
+ * @custom:requirements
37
+ * - `tokenSupplyCap_` MUST NOT be 0.
38
+ */
39
+ constructor(uint256 tokenSupplyCap_) {
40
+ if (tokenSupplyCap_ == 0) {
41
+ revert LSP7CappedSupplyRequired();
42
+ }
43
+
44
+ _TOKEN_SUPPLY_CAP = tokenSupplyCap_;
45
+ }
46
+
47
+ // --- Token queries
48
+
49
+ /**
50
+ * @notice The maximum supply amount of tokens allowed to exist is `_TOKEN_SUPPLY_CAP`.
51
+ *
52
+ * @dev Get the maximum number of tokens that can exist to circulate. Once {totalSupply} reaches
53
+ * reaches {totalSuuplyCap}, it is not possible to mint more tokens.
54
+ *
55
+ * @return The maximum number of tokens that can exist in the contract.
56
+ */
57
+ function tokenSupplyCap() public view virtual returns (uint256) {
58
+ return _TOKEN_SUPPLY_CAP;
59
+ }
60
+
61
+ // --- Transfer functionality
62
+
63
+ /**
64
+ * @dev Same as {_mint} but allows to mint only if the {totalSupply} does not exceed the {tokenSupplyCap}
65
+ * after `amount` of tokens have been minted.
66
+ *
67
+ * @custom:requirements
68
+ * - {tokenSupplyCap} - {totalSupply} must be greater than zero.
69
+ * - `to` cannot be the zero address.
70
+ */
71
+ function _mint(
72
+ address to,
73
+ uint256 amount,
74
+ bool force,
75
+ bytes memory data
76
+ ) internal virtual override {
77
+ if (totalSupply() + amount > tokenSupplyCap()) {
78
+ revert LSP7CappedSupplyCannotMintOverCap();
79
+ }
80
+
81
+ super._mint(to, amount, force, data);
82
+ }
83
+ }
@@ -0,0 +1,86 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+
3
+ pragma solidity ^0.8.4;
4
+
5
+ // modules
6
+ import {
7
+ LSP7DigitalAssetInitAbstract
8
+ } from "../LSP7DigitalAssetInitAbstract.sol";
9
+
10
+ /**
11
+ * @dev LSP7 token extension to add a max token supply cap (proxy version).
12
+ */
13
+ abstract contract LSP7CappedSupplyInitAbstract is LSP7DigitalAssetInitAbstract {
14
+ // --- Errors
15
+
16
+ /**
17
+ * @notice The `tokenSupplyCap` must be set and cannot be `0`.
18
+ * @dev Reverts when setting `0` for the {tokenSupplyCap}. The max token supply MUST be set to a number greater than 0.
19
+ */
20
+ error LSP7CappedSupplyRequired();
21
+
22
+ /**
23
+ * @notice Cannot mint anymore as total supply reached the maximum cap.
24
+ * @dev Reverts when trying to mint tokens but the {totalSupply} has reached the maximum {tokenSupplyCap}.
25
+ */
26
+ error LSP7CappedSupplyCannotMintOverCap();
27
+
28
+ // --- Storage
29
+ uint256 private _tokenSupplyCap;
30
+
31
+ /**
32
+ * @notice Deploying a `LSP7CappedSupply` token contract with max token supply cap set to `tokenSupplyCap_`.
33
+ * @dev Deploy a `LSP7CappedSupply` token contract and set the maximum token supply token cap up to which
34
+ * it is not possible to mint more tokens.
35
+ *
36
+ * @param tokenSupplyCap_ The maximum token supply.
37
+ *
38
+ * @custom:requirements
39
+ * - `tokenSupplyCap_` MUST NOT be 0.
40
+ */
41
+ function _initialize(
42
+ uint256 tokenSupplyCap_
43
+ ) internal virtual onlyInitializing {
44
+ if (tokenSupplyCap_ == 0) {
45
+ revert LSP7CappedSupplyRequired();
46
+ }
47
+
48
+ _tokenSupplyCap = tokenSupplyCap_;
49
+ }
50
+
51
+ // --- Token queries
52
+
53
+ /**
54
+ * @notice The maximum supply amount of tokens allowed to exist is `_tokenSupplyCap`.
55
+ * @dev Get the maximum number of tokens that can exist to circulate. Once {totalSupply} reaches
56
+ * reaches {totalSuuplyCap}, it is not possible to mint more tokens.
57
+ *
58
+ * @return The maximum number of tokens that can exist in the contract.
59
+ */
60
+ function tokenSupplyCap() public view virtual returns (uint256) {
61
+ return _tokenSupplyCap;
62
+ }
63
+
64
+ // --- Transfer functionality
65
+
66
+ /**
67
+ * @dev Same as {_mint} but allows to mint only if the {totalSupply} does not exceed the {tokenSupplyCap}
68
+ * after `amount` of tokens have been minted.
69
+ *
70
+ * @custom:requirements
71
+ * - {tokenSupplyCap} - {totalSupply} must be greater than zero.
72
+ * - `to` cannot be the zero address.
73
+ */
74
+ function _mint(
75
+ address to,
76
+ uint256 amount,
77
+ bool force,
78
+ bytes memory data
79
+ ) internal virtual override {
80
+ if (totalSupply() + amount > tokenSupplyCap()) {
81
+ revert LSP7CappedSupplyCannotMintOverCap();
82
+ }
83
+
84
+ super._mint(to, amount, force, data);
85
+ }
86
+ }
@@ -0,0 +1,32 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+
3
+ pragma solidity ^0.8.4;
4
+
5
+ // interfaces
6
+ import {ILSP7DigitalAsset} from "../ILSP7DigitalAsset.sol";
7
+
8
+ /**
9
+ * @dev LSP7 extension, Mintable version.
10
+ */
11
+ interface ILSP7Mintable is ILSP7DigitalAsset {
12
+ /**
13
+ * @param to The address to mint tokens
14
+ * @param amount The amount to mint
15
+ * @param force When set to TRUE, to may be any address but
16
+ * when set to FALSE to must be a contract that supports LSP1 UniversalReceiver
17
+ * @param data Additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses.
18
+ * @dev Mints `amount` tokens and transfers it to `to`.
19
+ *
20
+ * Requirements:
21
+ *
22
+ * - `to` cannot be the zero address.
23
+ *
24
+ * Emits a {Transfer} event.
25
+ */
26
+ function mint(
27
+ address to,
28
+ uint256 amount,
29
+ bool force,
30
+ bytes memory data
31
+ ) external;
32
+ }
@@ -0,0 +1,53 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+
3
+ pragma solidity ^0.8.4;
4
+
5
+ // interfaces
6
+ import {ILSP7Mintable} from "./ILSP7Mintable.sol";
7
+
8
+ // modules
9
+ import {LSP7DigitalAsset} from "../LSP7DigitalAsset.sol";
10
+
11
+ /**
12
+ * @title LSP7DigitalAsset deployable preset contract with a public {mint} function callable only by the contract {owner}.
13
+ * @author Jean Cavallera, Yamen Merhi
14
+ */
15
+ contract LSP7Mintable is LSP7DigitalAsset, ILSP7Mintable {
16
+ /**
17
+ * @notice Deploying a `LSP7Mintable` token contract with: token name = `name_`, token symbol = `symbol_`, and
18
+ * address `newOwner_` as the token contract owner.
19
+ *
20
+ * @param name_ The name of the token.
21
+ * @param symbol_ The symbol of the token.
22
+ * @param newOwner_ The owner of the token contract.
23
+ * @param lsp4TokenType_ The type of token this digital asset contract represents (`0` = Token, `1` = NFT, `2` = Collection).
24
+ * @param isNonDivisible_ Specify if the LSP7 token is a fungible or non-fungible token.
25
+ */
26
+ constructor(
27
+ string memory name_,
28
+ string memory symbol_,
29
+ address newOwner_,
30
+ uint256 lsp4TokenType_,
31
+ bool isNonDivisible_
32
+ )
33
+ LSP7DigitalAsset(
34
+ name_,
35
+ symbol_,
36
+ newOwner_,
37
+ lsp4TokenType_,
38
+ isNonDivisible_
39
+ )
40
+ {}
41
+
42
+ /**
43
+ * @dev Public {_mint} function only callable by the {owner}.
44
+ */
45
+ function mint(
46
+ address to,
47
+ uint256 amount,
48
+ bool force,
49
+ bytes memory data
50
+ ) public virtual override onlyOwner {
51
+ _mint(to, amount, force, data);
52
+ }
53
+ }
@@ -0,0 +1,44 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+
3
+ pragma solidity ^0.8.4;
4
+
5
+ // modules
6
+ import {LSP7MintableInitAbstract} from "./LSP7MintableInitAbstract.sol";
7
+
8
+ /**
9
+ * @dev LSP7DigitalAsset deployable preset contract (proxy version) with a public {mint} function callable only by the contract {owner}.
10
+ */
11
+ contract LSP7MintableInit is LSP7MintableInitAbstract {
12
+ /**
13
+ * @dev initialize (= lock) base implementation contract on deployment
14
+ */
15
+ constructor() {
16
+ _disableInitializers();
17
+ }
18
+
19
+ /**
20
+ * @notice Initializing a `LSP7MintableInit` token contract with: token name = `name_`, token symbol = `symbol_`, and
21
+ * address `newOwner_` as the token contract owner.
22
+ *
23
+ * @param name_ The name of the token.
24
+ * @param symbol_ The symbol of the token.
25
+ * @param newOwner_ The owner of the token contract.
26
+ * @param lsp4TokenType_ The type of token this digital asset contract represents (`0` = Token, `1` = NFT, `2` = Collection).
27
+ * @param isNonDivisible_ Specify if the LSP7 token is a fungible or non-fungible token.
28
+ */
29
+ function initialize(
30
+ string memory name_,
31
+ string memory symbol_,
32
+ address newOwner_,
33
+ uint256 lsp4TokenType_,
34
+ bool isNonDivisible_
35
+ ) external virtual initializer {
36
+ LSP7MintableInitAbstract._initialize(
37
+ name_,
38
+ symbol_,
39
+ newOwner_,
40
+ lsp4TokenType_,
41
+ isNonDivisible_
42
+ );
43
+ }
44
+ }