@lukso/lsp7-contracts 0.17.3 → 0.19.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.
- package/README.md +69 -24
- package/artifacts/IAccessControlExtended.json +1 -1
- package/artifacts/ILSP7CappedBalance.json +1 -1
- package/artifacts/ILSP7CappedSupply.json +1 -1
- package/artifacts/ILSP7DigitalAsset.json +1 -1
- package/artifacts/ILSP7Mintable.json +1 -1
- package/artifacts/ILSP7NonTransferable.json +8 -2
- package/artifacts/ILSP7Revokable.json +38 -1
- package/artifacts/LSP7Burnable.json +1 -1
- package/artifacts/LSP7BurnableInitAbstract.json +1 -1
- package/artifacts/LSP7CappedBalanceAbstract.json +1 -1
- package/artifacts/LSP7CappedBalanceInitAbstract.json +1 -1
- package/artifacts/LSP7CappedSupplyAbstract.json +1 -1
- package/artifacts/LSP7CappedSupplyInitAbstract.json +1 -1
- package/artifacts/LSP7CustomizableToken.json +63 -20
- package/artifacts/LSP7CustomizableTokenInit.json +59 -16
- package/artifacts/LSP7DigitalAsset.json +1 -1
- package/artifacts/LSP7DigitalAssetInitAbstract.json +1 -1
- package/artifacts/LSP7Mintable.json +27 -4
- package/artifacts/LSP7MintableAbstract.json +1 -1
- package/artifacts/LSP7MintableInit.json +26 -3
- package/artifacts/LSP7MintableInitAbstract.json +1 -1
- package/artifacts/LSP7NonTransferableAbstract.json +20 -14
- package/artifacts/LSP7NonTransferableInitAbstract.json +20 -14
- package/artifacts/LSP7RevokableAbstract.json +38 -1
- package/artifacts/LSP7RevokableInitAbstract.json +38 -1
- package/artifacts/LSP7Votes.json +1 -1
- package/artifacts/LSP7VotesInitAbstract.json +1 -1
- package/contracts/LSP7DigitalAsset.sol +6 -18
- package/contracts/extensions/AccessControlExtended/AccessControlExtendedAbstract.sol +3 -9
- package/contracts/extensions/AccessControlExtended/AccessControlExtendedInitAbstract.sol +4 -12
- package/contracts/extensions/AccessControlExtended/IAccessControlExtended.sol +1 -3
- package/contracts/extensions/LSP7CappedBalance/LSP7CappedBalanceAbstract.sol +1 -3
- package/contracts/extensions/LSP7CappedBalance/LSP7CappedBalanceInitAbstract.sol +3 -9
- package/contracts/extensions/LSP7CappedSupply/LSP7CappedSupplyInitAbstract.sol +1 -3
- package/contracts/extensions/LSP7Mintable/LSP7MintableAbstract.sol +1 -3
- package/contracts/extensions/LSP7Mintable/LSP7MintableInitAbstract.sol +3 -9
- package/contracts/extensions/LSP7MusicNDT/LSP7MusicNDTAbstract.sol +126 -0
- package/contracts/extensions/LSP7MusicNDT/LSP7MusicNDTConstants.sol +16 -0
- package/contracts/extensions/LSP7MusicNDT/LSP7MusicNDTErrors.sol +7 -0
- package/contracts/extensions/LSP7NonTransferable/ILSP7NonTransferable.sol +10 -4
- package/contracts/extensions/LSP7NonTransferable/LSP7NonTransferableAbstract.sol +24 -11
- package/contracts/extensions/LSP7NonTransferable/LSP7NonTransferableInitAbstract.sol +26 -17
- package/contracts/extensions/LSP7Revokable/ILSP7Revokable.sol +15 -1
- package/contracts/extensions/LSP7Revokable/LSP7RevokableAbstract.sol +10 -6
- package/contracts/extensions/LSP7Revokable/LSP7RevokableInitAbstract.sol +12 -12
- package/contracts/extensions/LSP7Votes/LSP7VotesInitAbstract.sol +2 -6
- package/contracts/presets/LSP7CustomizableToken.sol +8 -24
- package/contracts/presets/LSP7CustomizableTokenInit.sol +10 -30
- package/contracts/presets/LSP7Mintable.sol +49 -19
- package/contracts/presets/LSP7MintableInit.sol +57 -22
- package/dist/abi.cjs +191 -29
- package/dist/abi.d.cts +252 -41
- package/dist/abi.d.mts +252 -41
- package/dist/abi.d.ts +252 -41
- package/dist/abi.mjs +191 -29
- package/package.json +5 -1
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
pragma solidity ^0.8.27;
|
|
3
3
|
|
|
4
4
|
// interfaces
|
|
5
|
-
import {
|
|
6
|
-
ILSP1UniversalReceiver as ILSP1
|
|
7
|
-
} from "@lukso/lsp1-contracts/contracts/ILSP1UniversalReceiver.sol";
|
|
5
|
+
import {ILSP1UniversalReceiver as ILSP1} from "@lukso/lsp1-contracts/contracts/ILSP1UniversalReceiver.sol";
|
|
8
6
|
import {ILSP7DigitalAsset} from "./ILSP7DigitalAsset.sol";
|
|
9
7
|
|
|
10
8
|
// modules
|
|
@@ -12,27 +10,17 @@ import {
|
|
|
12
10
|
LSP4DigitalAssetMetadata,
|
|
13
11
|
ERC725Y
|
|
14
12
|
} from "@lukso/lsp4-contracts/contracts/LSP4DigitalAssetMetadata.sol";
|
|
15
|
-
import {
|
|
16
|
-
LSP17Extendable
|
|
17
|
-
} from "@lukso/lsp17contractextension-contracts/contracts/LSP17Extendable.sol";
|
|
13
|
+
import {LSP17Extendable} from "@lukso/lsp17contractextension-contracts/contracts/LSP17Extendable.sol";
|
|
18
14
|
|
|
19
15
|
// libraries
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
-
} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
|
23
|
-
import {
|
|
24
|
-
ERC165Checker
|
|
25
|
-
} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
|
|
16
|
+
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
|
17
|
+
import {ERC165Checker} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
|
|
26
18
|
import {LSP1Utils} from "@lukso/lsp1-contracts/contracts/LSP1Utils.sol";
|
|
27
19
|
import {LSP2Utils} from "@lukso/lsp2-contracts/contracts/LSP2Utils.sol";
|
|
28
20
|
|
|
29
21
|
// constants
|
|
30
|
-
import {
|
|
31
|
-
|
|
32
|
-
} from "@lukso/lsp1-contracts/contracts/LSP1Constants.sol";
|
|
33
|
-
import {
|
|
34
|
-
_LSP17_EXTENSION_PREFIX
|
|
35
|
-
} from "@lukso/lsp17contractextension-contracts/contracts/LSP17Constants.sol";
|
|
22
|
+
import {_INTERFACEID_LSP1} from "@lukso/lsp1-contracts/contracts/LSP1Constants.sol";
|
|
23
|
+
import {_LSP17_EXTENSION_PREFIX} from "@lukso/lsp17contractextension-contracts/contracts/LSP17Constants.sol";
|
|
36
24
|
import {
|
|
37
25
|
_INTERFACEID_LSP7,
|
|
38
26
|
_TYPEID_LSP7_TOKENOPERATOR,
|
|
@@ -2,21 +2,15 @@
|
|
|
2
2
|
pragma solidity ^0.8.27;
|
|
3
3
|
|
|
4
4
|
// interfaces
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
} from "@openzeppelin/contracts/access/IAccessControl.sol";
|
|
8
|
-
import {
|
|
9
|
-
IAccessControlEnumerable
|
|
10
|
-
} from "@openzeppelin/contracts/access/IAccessControlEnumerable.sol";
|
|
5
|
+
import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol";
|
|
6
|
+
import {IAccessControlEnumerable} from "@openzeppelin/contracts/access/IAccessControlEnumerable.sol";
|
|
11
7
|
import {IAccessControlExtended} from "./IAccessControlExtended.sol";
|
|
12
8
|
|
|
13
9
|
// modules
|
|
14
10
|
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
|
|
15
11
|
|
|
16
12
|
// libraries
|
|
17
|
-
import {
|
|
18
|
-
EnumerableSet
|
|
19
|
-
} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
|
13
|
+
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
|
20
14
|
|
|
21
15
|
// constants
|
|
22
16
|
import {
|
|
@@ -2,23 +2,15 @@
|
|
|
2
2
|
pragma solidity ^0.8.27;
|
|
3
3
|
|
|
4
4
|
// interfaces
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
} from "@openzeppelin/contracts/access/IAccessControl.sol";
|
|
8
|
-
import {
|
|
9
|
-
IAccessControlEnumerable
|
|
10
|
-
} from "@openzeppelin/contracts/access/IAccessControlEnumerable.sol";
|
|
5
|
+
import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol";
|
|
6
|
+
import {IAccessControlEnumerable} from "@openzeppelin/contracts/access/IAccessControlEnumerable.sol";
|
|
11
7
|
import {IAccessControlExtended} from "./IAccessControlExtended.sol";
|
|
12
8
|
|
|
13
9
|
// modules
|
|
14
|
-
import {
|
|
15
|
-
OwnableUpgradeable
|
|
16
|
-
} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
|
|
10
|
+
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
|
|
17
11
|
|
|
18
12
|
// libraries
|
|
19
|
-
import {
|
|
20
|
-
EnumerableSet
|
|
21
|
-
} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
|
13
|
+
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
|
22
14
|
|
|
23
15
|
// constants
|
|
24
16
|
import {
|
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
pragma solidity ^0.8.27;
|
|
3
3
|
|
|
4
4
|
// interfaces
|
|
5
|
-
import {
|
|
6
|
-
IAccessControlEnumerable
|
|
7
|
-
} from "@openzeppelin/contracts/access/IAccessControlEnumerable.sol";
|
|
5
|
+
import {IAccessControlEnumerable} from "@openzeppelin/contracts/access/IAccessControlEnumerable.sol";
|
|
8
6
|
|
|
9
7
|
/**
|
|
10
8
|
* @title IAccessControlExtended
|
|
@@ -4,9 +4,7 @@ pragma solidity ^0.8.27;
|
|
|
4
4
|
// modules
|
|
5
5
|
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
|
|
6
6
|
import {LSP7DigitalAsset} from "../../LSP7DigitalAsset.sol";
|
|
7
|
-
import {
|
|
8
|
-
AccessControlExtendedAbstract
|
|
9
|
-
} from "../AccessControlExtended/AccessControlExtendedAbstract.sol";
|
|
7
|
+
import {AccessControlExtendedAbstract} from "../AccessControlExtended/AccessControlExtendedAbstract.sol";
|
|
10
8
|
|
|
11
9
|
// interfaces
|
|
12
10
|
import {ILSP7CappedBalance} from "./ILSP7CappedBalance.sol";
|
|
@@ -2,15 +2,9 @@
|
|
|
2
2
|
pragma solidity ^0.8.27;
|
|
3
3
|
|
|
4
4
|
// modules
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
} from "
|
|
8
|
-
import {
|
|
9
|
-
LSP7DigitalAssetInitAbstract
|
|
10
|
-
} from "../../LSP7DigitalAssetInitAbstract.sol";
|
|
11
|
-
import {
|
|
12
|
-
AccessControlExtendedInitAbstract
|
|
13
|
-
} from "../AccessControlExtended/AccessControlExtendedInitAbstract.sol";
|
|
5
|
+
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
|
|
6
|
+
import {LSP7DigitalAssetInitAbstract} from "../../LSP7DigitalAssetInitAbstract.sol";
|
|
7
|
+
import {AccessControlExtendedInitAbstract} from "../AccessControlExtended/AccessControlExtendedInitAbstract.sol";
|
|
14
8
|
|
|
15
9
|
// interfaces
|
|
16
10
|
import {ILSP7CappedBalance} from "./ILSP7CappedBalance.sol";
|
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
pragma solidity ^0.8.27;
|
|
3
3
|
|
|
4
4
|
// modules
|
|
5
|
-
import {
|
|
6
|
-
LSP7DigitalAssetInitAbstract
|
|
7
|
-
} from "../../LSP7DigitalAssetInitAbstract.sol";
|
|
5
|
+
import {LSP7DigitalAssetInitAbstract} from "../../LSP7DigitalAssetInitAbstract.sol";
|
|
8
6
|
|
|
9
7
|
// errors
|
|
10
8
|
import {LSP7CappedSupplyCannotMintOverCap} from "./LSP7CappedSupplyErrors.sol";
|
|
@@ -4,9 +4,7 @@ pragma solidity ^0.8.27;
|
|
|
4
4
|
// modules
|
|
5
5
|
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
|
|
6
6
|
import {LSP7DigitalAsset} from "../../LSP7DigitalAsset.sol";
|
|
7
|
-
import {
|
|
8
|
-
AccessControlExtendedAbstract
|
|
9
|
-
} from "../AccessControlExtended/AccessControlExtendedAbstract.sol";
|
|
7
|
+
import {AccessControlExtendedAbstract} from "../AccessControlExtended/AccessControlExtendedAbstract.sol";
|
|
10
8
|
|
|
11
9
|
// interfaces
|
|
12
10
|
import {ILSP7Mintable} from "./ILSP7Mintable.sol";
|
|
@@ -2,16 +2,10 @@
|
|
|
2
2
|
pragma solidity ^0.8.27;
|
|
3
3
|
|
|
4
4
|
// modules
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
|
|
8
|
-
import {
|
|
9
|
-
AccessControlExtendedInitAbstract
|
|
10
|
-
} from "../AccessControlExtended/AccessControlExtendedInitAbstract.sol";
|
|
5
|
+
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
|
|
6
|
+
import {AccessControlExtendedInitAbstract} from "../AccessControlExtended/AccessControlExtendedInitAbstract.sol";
|
|
11
7
|
|
|
12
|
-
import {
|
|
13
|
-
LSP7DigitalAssetInitAbstract
|
|
14
|
-
} from "../../LSP7DigitalAssetInitAbstract.sol";
|
|
8
|
+
import {LSP7DigitalAssetInitAbstract} from "../../LSP7DigitalAssetInitAbstract.sol";
|
|
15
9
|
|
|
16
10
|
// interfaces
|
|
17
11
|
import {ILSP7Mintable} from "./ILSP7Mintable.sol";
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
pragma solidity ^0.8.27;
|
|
3
|
+
|
|
4
|
+
// modules
|
|
5
|
+
import {LSP7DigitalAsset} from "../../LSP7DigitalAsset.sol";
|
|
6
|
+
|
|
7
|
+
import {ERC725Y} from "@erc725/smart-contracts-v8/contracts/ERC725Y.sol";
|
|
8
|
+
|
|
9
|
+
// constants
|
|
10
|
+
import {
|
|
11
|
+
_LSP33_SUPPORTED_STANDARDS_KEY,
|
|
12
|
+
_LSP33_SUPPORTED_STANDARDS_VALUE,
|
|
13
|
+
_LSP34_OWNERSHIP_SOURCE_KEY
|
|
14
|
+
} from "./LSP7MusicNDTConstants.sol";
|
|
15
|
+
|
|
16
|
+
import {_LSP4_TOKEN_TYPE_NFT} from "@lukso/lsp4-contracts/contracts/LSP4Constants.sol";
|
|
17
|
+
|
|
18
|
+
// errors
|
|
19
|
+
import {LSP34NotAuthorizedToMint} from "./LSP7MusicNDTErrors.sol";
|
|
20
|
+
|
|
21
|
+
/// @dev Minimal ERC173 interface used to resolve the minter when
|
|
22
|
+
/// `LSP34OwnershipSource` points to a plain owned contract
|
|
23
|
+
/// (i.e. `tokenId == bytes32(0)`).
|
|
24
|
+
interface IERC173 {
|
|
25
|
+
function owner() external view returns (address);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/// @dev Minimal LSP8 interface used to resolve the minter when
|
|
29
|
+
/// `LSP34OwnershipSource` points to an LSP8 tokenId
|
|
30
|
+
/// (i.e. `tokenId != bytes32(0)`). Declared locally, like `IERC173`, so
|
|
31
|
+
/// that the LSP7 package does not need the LSP8 package as a dependency.
|
|
32
|
+
interface ILSP8TokenOwnerOf {
|
|
33
|
+
function tokenOwnerOf(bytes32 tokenId) external view returns (address);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/// @title LSP7MusicNDTAbstract
|
|
37
|
+
/// @dev LSP33 music carrier for an LSP7 Music NDT (Non-Divisible Token): a
|
|
38
|
+
/// track token whose supply consists of multiple units, combined with LSP34
|
|
39
|
+
/// minting-rights delegation. Unlike an LSP8 collection, where every item is
|
|
40
|
+
/// a unique `tokenId`, the units of one LSP7 Music NDT are interchangeable.
|
|
41
|
+
///
|
|
42
|
+
/// The `isNonDivisible_` constructor argument is forwarded unchanged to
|
|
43
|
+
/// `LSP7DigitalAsset`; deploy with `isNonDivisible_ = true` (`decimals()` = 0)
|
|
44
|
+
/// so that each unit is a whole, non-divisible token.
|
|
45
|
+
///
|
|
46
|
+
/// The contract sets the `SupportedStandards:LSP33MusicNFT` marker at
|
|
47
|
+
/// construction and exposes a `mint` function that honours LSP34: in addition
|
|
48
|
+
/// to the ERC173 `owner()`, minting is allowed by the address resolved from
|
|
49
|
+
/// `LSP34OwnershipSource` when it has been set. Everything else — ownership
|
|
50
|
+
/// transfer, renouncement, and ERC725Y access control for `setData` — follows
|
|
51
|
+
/// the standard LSP7 / ERC725Y rules as required by LSP34.
|
|
52
|
+
abstract contract LSP7MusicNDTAbstract is LSP7DigitalAsset {
|
|
53
|
+
constructor(
|
|
54
|
+
string memory name_,
|
|
55
|
+
string memory symbol_,
|
|
56
|
+
address initialOwner_,
|
|
57
|
+
bool isNonDivisible_
|
|
58
|
+
)
|
|
59
|
+
LSP7DigitalAsset(
|
|
60
|
+
name_,
|
|
61
|
+
symbol_,
|
|
62
|
+
initialOwner_,
|
|
63
|
+
_LSP4_TOKEN_TYPE_NFT,
|
|
64
|
+
isNonDivisible_
|
|
65
|
+
)
|
|
66
|
+
{
|
|
67
|
+
ERC725Y._setData(
|
|
68
|
+
_LSP33_SUPPORTED_STANDARDS_KEY,
|
|
69
|
+
_LSP33_SUPPORTED_STANDARDS_VALUE
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/// @notice Mint `amount` tokens to `to`.
|
|
74
|
+
/// @dev Authorisation follows LSP34: callable by the contract's own ERC173
|
|
75
|
+
/// `owner()` or, when `LSP34OwnershipSource` is set, by the address
|
|
76
|
+
/// resolved from that source.
|
|
77
|
+
function mint(
|
|
78
|
+
address to,
|
|
79
|
+
uint256 amount,
|
|
80
|
+
bool force,
|
|
81
|
+
bytes memory data
|
|
82
|
+
) public virtual {
|
|
83
|
+
if (msg.sender != owner() && msg.sender != _resolveLSP34Minter()) {
|
|
84
|
+
revert LSP34NotAuthorizedToMint(msg.sender);
|
|
85
|
+
}
|
|
86
|
+
_mint(to, amount, force, data);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/// @dev Returns the address authorised to mint via `LSP34OwnershipSource`.
|
|
90
|
+
/// The value is the packed LSP2 `(address,bytes32)` tuple
|
|
91
|
+
/// `abi.encodePacked(address sourceContract, bytes32 tokenId)`: exactly
|
|
92
|
+
/// 52 bytes, `sourceContract` in bytes 0..19 and `tokenId` in bytes
|
|
93
|
+
/// 20..51. Returns `address(0)` when the source is unset or its value is
|
|
94
|
+
/// not exactly 52 bytes long (e.g. the 64-byte `abi.encode` form).
|
|
95
|
+
/// Reverts, granting no minting rights, when the source query reverts
|
|
96
|
+
/// (e.g. burned or nonexistent `tokenId`, source without code). `mint`
|
|
97
|
+
/// only calls this for callers other than `owner()`.
|
|
98
|
+
///
|
|
99
|
+
/// Resolution rules per LSP34:
|
|
100
|
+
/// - If `tokenId != bytes32(0)`, query `tokenOwnerOf(tokenId)` on the source.
|
|
101
|
+
/// - If `tokenId == bytes32(0)`, query `owner()` on the source.
|
|
102
|
+
function _resolveLSP34Minter() internal view returns (address) {
|
|
103
|
+
bytes memory source = _getData(_LSP34_OWNERSHIP_SOURCE_KEY);
|
|
104
|
+
if (source.length != 52) {
|
|
105
|
+
return address(0);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
address sourceContract;
|
|
109
|
+
bytes32 tokenId;
|
|
110
|
+
// `add(source, 32)` -> offset in memory where `source` data starts.
|
|
111
|
+
// Both reads stay within the 52 bytes of `source`: the first word
|
|
112
|
+
// holds `sourceContract` in its upper 20 bytes, the word starting at
|
|
113
|
+
// byte 20 is `tokenId`.
|
|
114
|
+
/// @solidity memory-safe-assembly
|
|
115
|
+
// solhint-disable-next-line no-inline-assembly
|
|
116
|
+
assembly {
|
|
117
|
+
sourceContract := shr(96, mload(add(source, 32)))
|
|
118
|
+
tokenId := mload(add(source, 52))
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (tokenId == bytes32(0)) {
|
|
122
|
+
return IERC173(sourceContract).owner();
|
|
123
|
+
}
|
|
124
|
+
return ILSP8TokenOwnerOf(sourceContract).tokenOwnerOf(tokenId);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
pragma solidity ^0.8.27;
|
|
3
|
+
|
|
4
|
+
// bytes10(keccak256('SupportedStandards')) + bytes2(0) + bytes20(keccak256('LSP33MusicNFT'))
|
|
5
|
+
// LSP2 Mapping: bytes20(...) keeps the first 20 bytes of keccak256('LSP33MusicNFT').
|
|
6
|
+
// The legacy draft key ...0000f43ae543...ff2ca4 (last 20 bytes) is mis-derived and is not written.
|
|
7
|
+
bytes32 constant _LSP33_SUPPORTED_STANDARDS_KEY = 0xeafec4d89fa9619884b600003cd4661761f237efa2fead11f43ae543d533ae73;
|
|
8
|
+
|
|
9
|
+
// bytes4(keccak256('LSP33MusicNFT'))
|
|
10
|
+
bytes constant _LSP33_SUPPORTED_STANDARDS_VALUE = hex"3cd46617";
|
|
11
|
+
|
|
12
|
+
// keccak256('LSP33Metadata')
|
|
13
|
+
bytes32 constant _LSP33_METADATA_KEY = 0xbecee5b67fa43fb2e96c7c6ccdc23007fffc2b24205416b2122cd7b8d8ef48fa;
|
|
14
|
+
|
|
15
|
+
// keccak256('LSP34OwnershipSource')
|
|
16
|
+
bytes32 constant _LSP34_OWNERSHIP_SOURCE_KEY = 0xa8bc5aea0671308a0920eb016db4108c486ef117a7cd18bf3a9dfcadab6232e1;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
pragma solidity ^0.8.27;
|
|
3
|
+
|
|
4
|
+
/// @dev Reverts when an address that is neither the contract's ERC173 `owner()`
|
|
5
|
+
/// nor the address resolved via `LSP34OwnershipSource` attempts to call `mint()`.
|
|
6
|
+
/// @param caller The address that attempted the mint call.
|
|
7
|
+
error LSP34NotAuthorizedToMint(address caller);
|
|
@@ -5,9 +5,14 @@ pragma solidity ^0.8.27;
|
|
|
5
5
|
/// @dev Interface for a non-transferable LSP7 token, enabling control over transferability, lock periods, and allowlist exemptions.
|
|
6
6
|
interface ILSP7NonTransferable {
|
|
7
7
|
/// @dev Emitted when the transfer lock period is updated.
|
|
8
|
+
/// @param nonTransferabilityEnabled Whether the non-transferability feature is enabled or not.
|
|
8
9
|
/// @param start The new start timestamp of the transfer lock period.
|
|
9
10
|
/// @param end The new end timestamp of the transfer lock period.
|
|
10
|
-
event TransferLockPeriodChanged(
|
|
11
|
+
event TransferLockPeriodChanged(
|
|
12
|
+
bool indexed nonTransferabilityEnabled,
|
|
13
|
+
uint256 indexed start,
|
|
14
|
+
uint256 indexed end
|
|
15
|
+
);
|
|
11
16
|
|
|
12
17
|
/// @notice The start timestamp of the transfer lock period, at which point the token becomes non-transferable.
|
|
13
18
|
function transferLockStart() external view returns (uint256);
|
|
@@ -17,10 +22,10 @@ interface ILSP7NonTransferable {
|
|
|
17
22
|
|
|
18
23
|
/// @notice Returns whether the transfer lock feature is still enabled.
|
|
19
24
|
/// @dev When this returns `false`, the token has been permanently made transferable and the lock period can no longer be updated.
|
|
20
|
-
function
|
|
25
|
+
function nonTransferabilityEnabled() external view returns (bool);
|
|
21
26
|
|
|
22
27
|
/// @notice Checks if the token is currently transferable.
|
|
23
|
-
/// @dev Returns true if the token is currently transferable. When `
|
|
28
|
+
/// @dev Returns true if the token is currently transferable. When `nonTransferabilityEnabled` is true, this is derived from the configured lock period. When `nonTransferabilityEnabled` is false, this always returns true. Note that transfers from allowlisted addresses and burning (transfers to address(0)) is always allowed, regardless of transferability status.
|
|
24
29
|
/// @return A `true` or `false` boolean indicating if the token is transferable or not.
|
|
25
30
|
function isTransferable() external view returns (bool);
|
|
26
31
|
|
|
@@ -34,7 +39,8 @@ interface ILSP7NonTransferable {
|
|
|
34
39
|
/// - When `transferLockStart` is set to a value and `transferLockEnd` is 0, it means the tokens becomes non-transferable at a certain point in time and indefinitely (no end time).
|
|
35
40
|
///
|
|
36
41
|
/// - To make the token always non-transferable, set `transferLockStart` to 0 and `transferLockEnd` to type(uint256).max.
|
|
37
|
-
/// - To
|
|
42
|
+
/// - To remove the active lock while keeping the non-transferability feature configurable, set both `newTransferLockStart` and `newTransferLockEnd` to 0. In this state, transfers are currently unrestricted, but the owner can still configure a new lock period later.
|
|
43
|
+
/// - To permanently disable the non-transferability feature and prevent future lock-period updates, use the {makeTransferable} function.
|
|
38
44
|
///
|
|
39
45
|
/// @dev Can only be called by the contract owner. Reverts once {makeTransferable} has been called.
|
|
40
46
|
///
|
|
@@ -4,9 +4,7 @@ pragma solidity ^0.8.27;
|
|
|
4
4
|
// modules
|
|
5
5
|
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
|
|
6
6
|
import {LSP7DigitalAsset} from "../../LSP7DigitalAsset.sol";
|
|
7
|
-
import {
|
|
8
|
-
AccessControlExtendedAbstract
|
|
9
|
-
} from "../AccessControlExtended/AccessControlExtendedAbstract.sol";
|
|
7
|
+
import {AccessControlExtendedAbstract} from "../AccessControlExtended/AccessControlExtendedAbstract.sol";
|
|
10
8
|
|
|
11
9
|
// interfaces
|
|
12
10
|
import {ILSP7NonTransferable} from "./ILSP7NonTransferable.sol";
|
|
@@ -37,7 +35,7 @@ abstract contract LSP7NonTransferableAbstract is
|
|
|
37
35
|
uint256 public transferLockEnd;
|
|
38
36
|
|
|
39
37
|
/// @inheritdoc ILSP7NonTransferable
|
|
40
|
-
bool public
|
|
38
|
+
bool public nonTransferabilityEnabled;
|
|
41
39
|
|
|
42
40
|
/// @notice Initializes the contract with non-transferable locking period.
|
|
43
41
|
/// @param transferLockStart_ The start timestamp of the transfer lock period, 0 to disable.
|
|
@@ -49,9 +47,13 @@ abstract contract LSP7NonTransferableAbstract is
|
|
|
49
47
|
);
|
|
50
48
|
transferLockStart = transferLockStart_;
|
|
51
49
|
transferLockEnd = transferLockEnd_;
|
|
52
|
-
|
|
50
|
+
nonTransferabilityEnabled = true;
|
|
53
51
|
|
|
54
|
-
emit TransferLockPeriodChanged(
|
|
52
|
+
emit TransferLockPeriodChanged({
|
|
53
|
+
nonTransferabilityEnabled: true,
|
|
54
|
+
start: transferLockStart_,
|
|
55
|
+
end: transferLockEnd_
|
|
56
|
+
});
|
|
55
57
|
_grantRole(NON_TRANSFERABLE_BYPASS_ROLE, owner());
|
|
56
58
|
}
|
|
57
59
|
|
|
@@ -70,8 +72,10 @@ abstract contract LSP7NonTransferableAbstract is
|
|
|
70
72
|
}
|
|
71
73
|
|
|
72
74
|
/// @inheritdoc ILSP7NonTransferable
|
|
75
|
+
// solhint-disable not-rely-on-time
|
|
76
|
+
// Transfer-lock windows are inherently time-based; `block.timestamp` is the intended source.
|
|
73
77
|
function isTransferable() public view virtual override returns (bool) {
|
|
74
|
-
if (!
|
|
78
|
+
if (!nonTransferabilityEnabled) return true;
|
|
75
79
|
|
|
76
80
|
bool isTransferLockStartEnabled = transferLockStart != 0;
|
|
77
81
|
bool isTransferLockEndEnabled = transferLockEnd != 0;
|
|
@@ -96,17 +100,22 @@ abstract contract LSP7NonTransferableAbstract is
|
|
|
96
100
|
transferLockStart > block.timestamp ||
|
|
97
101
|
transferLockEnd < block.timestamp;
|
|
98
102
|
}
|
|
103
|
+
// solhint-enable not-rely-on-time
|
|
99
104
|
|
|
100
105
|
/// @inheritdoc ILSP7NonTransferable
|
|
101
106
|
/// @custom:info The list of addresses holding the `NON_TRANSFERABLE_BYPASS_ROLE` remains populated after the non-transferable feature is switched off.
|
|
102
107
|
function makeTransferable() public virtual override onlyOwner {
|
|
103
|
-
require(
|
|
108
|
+
require(nonTransferabilityEnabled, LSP7TokenAlreadyTransferable());
|
|
104
109
|
|
|
105
|
-
|
|
110
|
+
nonTransferabilityEnabled = false;
|
|
106
111
|
transferLockStart = 0;
|
|
107
112
|
transferLockEnd = 0;
|
|
108
113
|
|
|
109
|
-
emit TransferLockPeriodChanged({
|
|
114
|
+
emit TransferLockPeriodChanged({
|
|
115
|
+
nonTransferabilityEnabled: false,
|
|
116
|
+
start: 0,
|
|
117
|
+
end: 0
|
|
118
|
+
});
|
|
110
119
|
}
|
|
111
120
|
|
|
112
121
|
/// @inheritdoc ILSP7NonTransferable
|
|
@@ -114,7 +123,10 @@ abstract contract LSP7NonTransferableAbstract is
|
|
|
114
123
|
uint256 newTransferLockStart,
|
|
115
124
|
uint256 newTransferLockEnd
|
|
116
125
|
) public virtual override onlyOwner {
|
|
117
|
-
require(
|
|
126
|
+
require(
|
|
127
|
+
nonTransferabilityEnabled,
|
|
128
|
+
LSP7CannotUpdateTransferLockPeriod()
|
|
129
|
+
);
|
|
118
130
|
|
|
119
131
|
// When `transferLockEnd` is 0, it means no end time is set (transfers locked indefinitely since `transferLockStart`)
|
|
120
132
|
// When `transferLockStart` is 0, it means no start time is set (transfers locked up until `transferLockEnd`)
|
|
@@ -129,6 +141,7 @@ abstract contract LSP7NonTransferableAbstract is
|
|
|
129
141
|
transferLockEnd = newTransferLockEnd;
|
|
130
142
|
|
|
131
143
|
emit TransferLockPeriodChanged({
|
|
144
|
+
nonTransferabilityEnabled: true,
|
|
132
145
|
start: newTransferLockStart,
|
|
133
146
|
end: newTransferLockEnd
|
|
134
147
|
});
|
|
@@ -2,15 +2,9 @@
|
|
|
2
2
|
pragma solidity ^0.8.4;
|
|
3
3
|
|
|
4
4
|
// modules
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
} from "
|
|
8
|
-
import {
|
|
9
|
-
LSP7DigitalAssetInitAbstract
|
|
10
|
-
} from "../../LSP7DigitalAssetInitAbstract.sol";
|
|
11
|
-
import {
|
|
12
|
-
AccessControlExtendedInitAbstract
|
|
13
|
-
} from "../AccessControlExtended/AccessControlExtendedInitAbstract.sol";
|
|
5
|
+
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
|
|
6
|
+
import {LSP7DigitalAssetInitAbstract} from "../../LSP7DigitalAssetInitAbstract.sol";
|
|
7
|
+
import {AccessControlExtendedInitAbstract} from "../AccessControlExtended/AccessControlExtendedInitAbstract.sol";
|
|
14
8
|
|
|
15
9
|
// interfaces
|
|
16
10
|
import {ILSP7NonTransferable} from "./ILSP7NonTransferable.sol";
|
|
@@ -42,7 +36,7 @@ abstract contract LSP7NonTransferableInitAbstract is
|
|
|
42
36
|
uint256 public transferLockEnd;
|
|
43
37
|
|
|
44
38
|
/// @inheritdoc ILSP7NonTransferable
|
|
45
|
-
bool public
|
|
39
|
+
bool public nonTransferabilityEnabled;
|
|
46
40
|
|
|
47
41
|
/// @notice Initializes the LSP7NonTransferable contract with base token params, allowlist, and transfer settings.
|
|
48
42
|
/// @dev Initializes the LSP7Allowlist (which initializes LSP7DigitalAsset) and sets the lock period.
|
|
@@ -89,9 +83,13 @@ abstract contract LSP7NonTransferableInitAbstract is
|
|
|
89
83
|
);
|
|
90
84
|
transferLockStart = transferLockStart_;
|
|
91
85
|
transferLockEnd = transferLockEnd_;
|
|
92
|
-
|
|
86
|
+
nonTransferabilityEnabled = true;
|
|
93
87
|
|
|
94
|
-
emit TransferLockPeriodChanged(
|
|
88
|
+
emit TransferLockPeriodChanged({
|
|
89
|
+
nonTransferabilityEnabled: true,
|
|
90
|
+
start: transferLockStart_,
|
|
91
|
+
end: transferLockEnd_
|
|
92
|
+
});
|
|
95
93
|
_grantRole(NON_TRANSFERABLE_BYPASS_ROLE, owner());
|
|
96
94
|
}
|
|
97
95
|
|
|
@@ -113,8 +111,10 @@ abstract contract LSP7NonTransferableInitAbstract is
|
|
|
113
111
|
}
|
|
114
112
|
|
|
115
113
|
/// @inheritdoc ILSP7NonTransferable
|
|
114
|
+
// solhint-disable not-rely-on-time
|
|
115
|
+
// Transfer-lock windows are inherently time-based; `block.timestamp` is the intended source.
|
|
116
116
|
function isTransferable() public view virtual override returns (bool) {
|
|
117
|
-
if (!
|
|
117
|
+
if (!nonTransferabilityEnabled) return true;
|
|
118
118
|
|
|
119
119
|
bool isTransferLockStartEnabled = transferLockStart != 0;
|
|
120
120
|
bool isTransferLockEndEnabled = transferLockEnd != 0;
|
|
@@ -139,17 +139,22 @@ abstract contract LSP7NonTransferableInitAbstract is
|
|
|
139
139
|
transferLockStart > block.timestamp ||
|
|
140
140
|
transferLockEnd < block.timestamp;
|
|
141
141
|
}
|
|
142
|
+
// solhint-enable not-rely-on-time
|
|
142
143
|
|
|
143
144
|
/// @inheritdoc ILSP7NonTransferable
|
|
144
145
|
/// @custom:info The list of addresses holding the `NON_TRANSFERABLE_BYPASS_ROLE` remains populated after the non-transferable feature is switched off.
|
|
145
146
|
function makeTransferable() public virtual override onlyOwner {
|
|
146
|
-
require(
|
|
147
|
+
require(nonTransferabilityEnabled, LSP7TokenAlreadyTransferable());
|
|
147
148
|
|
|
148
|
-
|
|
149
|
+
nonTransferabilityEnabled = false;
|
|
149
150
|
transferLockStart = 0;
|
|
150
151
|
transferLockEnd = 0;
|
|
151
152
|
|
|
152
|
-
emit TransferLockPeriodChanged({
|
|
153
|
+
emit TransferLockPeriodChanged({
|
|
154
|
+
nonTransferabilityEnabled: false,
|
|
155
|
+
start: 0,
|
|
156
|
+
end: 0
|
|
157
|
+
});
|
|
153
158
|
}
|
|
154
159
|
|
|
155
160
|
/// @inheritdoc ILSP7NonTransferable
|
|
@@ -157,7 +162,10 @@ abstract contract LSP7NonTransferableInitAbstract is
|
|
|
157
162
|
uint256 newTransferLockStart,
|
|
158
163
|
uint256 newTransferLockEnd
|
|
159
164
|
) public virtual override onlyOwner {
|
|
160
|
-
require(
|
|
165
|
+
require(
|
|
166
|
+
nonTransferabilityEnabled,
|
|
167
|
+
LSP7CannotUpdateTransferLockPeriod()
|
|
168
|
+
);
|
|
161
169
|
|
|
162
170
|
// When transferLockEnd is 0, it means no end time is set (transfers locked indefinitely after transferLockStart)
|
|
163
171
|
// When transferLockStart is 0, it means no start time is set (transfers locked up until transferLockEnd)
|
|
@@ -172,6 +180,7 @@ abstract contract LSP7NonTransferableInitAbstract is
|
|
|
172
180
|
transferLockEnd = newTransferLockEnd;
|
|
173
181
|
|
|
174
182
|
emit TransferLockPeriodChanged({
|
|
183
|
+
nonTransferabilityEnabled: true,
|
|
175
184
|
start: newTransferLockStart,
|
|
176
185
|
end: newTransferLockEnd
|
|
177
186
|
});
|
|
@@ -9,6 +9,15 @@ interface ILSP7Revokable {
|
|
|
9
9
|
/// @dev Emitted when revokable status is changed.
|
|
10
10
|
event RevokableStatusChanged(bool indexed enabled);
|
|
11
11
|
|
|
12
|
+
/// @dev Emitted when tokens are revoked from a holder.
|
|
13
|
+
event TokenRevoked(
|
|
14
|
+
address indexed revoker,
|
|
15
|
+
address indexed from,
|
|
16
|
+
address indexed to,
|
|
17
|
+
uint256 amount,
|
|
18
|
+
bytes data
|
|
19
|
+
);
|
|
20
|
+
|
|
12
21
|
/// @notice Returns whether the feature to revoke tokens from users is enabled or not.
|
|
13
22
|
function isRevokable() external view returns (bool);
|
|
14
23
|
|
|
@@ -24,5 +33,10 @@ interface ILSP7Revokable {
|
|
|
24
33
|
/// @param to The address receiving the revoked tokens.
|
|
25
34
|
/// @param amount The amount of tokens to revoke.
|
|
26
35
|
/// @param data Additional data to include in the transfer notification.
|
|
27
|
-
function revoke(
|
|
36
|
+
function revoke(
|
|
37
|
+
address from,
|
|
38
|
+
address to,
|
|
39
|
+
uint256 amount,
|
|
40
|
+
bytes memory data
|
|
41
|
+
) external;
|
|
28
42
|
}
|
|
@@ -4,17 +4,13 @@ pragma solidity ^0.8.27;
|
|
|
4
4
|
// modules
|
|
5
5
|
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
|
|
6
6
|
import {LSP7DigitalAsset} from "../../LSP7DigitalAsset.sol";
|
|
7
|
-
import {
|
|
8
|
-
AccessControlExtendedAbstract
|
|
9
|
-
} from "../AccessControlExtended/AccessControlExtendedAbstract.sol";
|
|
7
|
+
import {AccessControlExtendedAbstract} from "../AccessControlExtended/AccessControlExtendedAbstract.sol";
|
|
10
8
|
|
|
11
9
|
// interfaces
|
|
12
10
|
import {ILSP7Revokable} from "./ILSP7Revokable.sol";
|
|
13
11
|
|
|
14
12
|
// errors
|
|
15
|
-
import {
|
|
16
|
-
AccessControlUnauthorizedAccount
|
|
17
|
-
} from "../AccessControlExtended/AccessControlExtendedErrors.sol";
|
|
13
|
+
import {AccessControlUnauthorizedAccount} from "../AccessControlExtended/AccessControlExtendedErrors.sol";
|
|
18
14
|
import {LSP7RevokableFeatureDisabled} from "./LSP7RevokableErrors.sol";
|
|
19
15
|
|
|
20
16
|
/// @title LSP7RevokableAbstract
|
|
@@ -73,6 +69,14 @@ abstract contract LSP7RevokableAbstract is
|
|
|
73
69
|
AccessControlUnauthorizedAccount(to, REVOKER_ROLE)
|
|
74
70
|
);
|
|
75
71
|
|
|
72
|
+
emit TokenRevoked({
|
|
73
|
+
revoker: msg.sender,
|
|
74
|
+
from: from,
|
|
75
|
+
to: to,
|
|
76
|
+
amount: amount,
|
|
77
|
+
data: data
|
|
78
|
+
});
|
|
79
|
+
|
|
76
80
|
// We assume revokers are trusted when specifying revocation destinations.
|
|
77
81
|
// Therefore, we bypass LSP1 receiver checks.
|
|
78
82
|
_transfer({
|