@lukso/lsp-smart-contracts 0.7.0 → 0.8.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/CONTRIBUTING.md +39 -0
- package/README.md +93 -40
- package/artifacts/Create2Factory.json +2 -2
- package/artifacts/LSP0ERC725Account.json +194 -15
- package/artifacts/LSP0ERC725AccountInit.json +194 -15
- package/artifacts/LSP11BasicSocialRecovery.json +493 -0
- package/artifacts/LSP11BasicSocialRecoveryInit.json +513 -0
- package/artifacts/LSP16UniversalFactory.json +236 -0
- package/artifacts/LSP1UniversalReceiverDelegateUP.json +134 -15
- package/artifacts/LSP1UniversalReceiverDelegateVault.json +80 -15
- package/artifacts/LSP4Compatibility.json +16 -0
- package/artifacts/LSP4DigitalAssetMetadata.json +16 -0
- package/artifacts/LSP4DigitalAssetMetadataInitAbstract.json +16 -0
- package/artifacts/LSP6KeyManager.json +177 -33
- package/artifacts/LSP6KeyManagerInit.json +177 -33
- package/artifacts/LSP7CappedSupply.json +26 -5
- package/artifacts/LSP7CappedSupplyInitAbstract.json +26 -5
- package/artifacts/LSP7CompatibleERC20.json +26 -5
- package/artifacts/LSP7CompatibleERC20InitAbstract.json +28 -7
- package/artifacts/LSP7CompatibleERC20Mintable.json +29 -8
- package/artifacts/LSP7CompatibleERC20MintableInit.json +29 -8
- package/artifacts/LSP7DigitalAsset.json +26 -5
- package/artifacts/LSP7DigitalAssetInitAbstract.json +26 -5
- package/artifacts/LSP7Mintable.json +29 -8
- package/artifacts/LSP7MintableInit.json +29 -8
- package/artifacts/LSP8CappedSupply.json +27 -6
- package/artifacts/LSP8CappedSupplyInitAbstract.json +27 -6
- package/artifacts/LSP8CompatibleERC721.json +28 -7
- package/artifacts/LSP8CompatibleERC721InitAbstract.json +30 -9
- package/artifacts/LSP8CompatibleERC721Mintable.json +31 -10
- package/artifacts/LSP8CompatibleERC721MintableInit.json +31 -10
- package/artifacts/LSP8IdentifiableDigitalAsset.json +27 -6
- package/artifacts/LSP8IdentifiableDigitalAssetInitAbstract.json +27 -6
- package/artifacts/LSP8Mintable.json +30 -9
- package/artifacts/LSP8MintableInit.json +30 -9
- package/artifacts/LSP9Vault.json +202 -17
- package/artifacts/LSP9VaultInit.json +202 -17
- package/artifacts/UniversalProfile.json +194 -15
- package/artifacts/UniversalProfileInit.json +194 -15
- package/artifacts/UniversalReceiverAddressStore.json +3 -3
- package/common/constants.d.ts +738 -0
- package/common/constants.js +785 -0
- package/contracts/Custom/EIP191Signer.sol +12 -0
- package/contracts/Factories/Create2Factory.sol +1 -3
- package/contracts/LSP0ERC725Account/LSP0Constants.sol +13 -2
- package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +2 -1
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +320 -63
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +2 -2
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +2 -1
- package/contracts/LSP0ERC725Account/LSP0Utils.sol +50 -0
- package/contracts/LSP10ReceivedVaults/LSP10Constants.sol +2 -2
- package/contracts/LSP10ReceivedVaults/LSP10Utils.sol +212 -0
- package/contracts/LSP11BasicSocialRecovery/ILSP11BasicSocialRecovery.sol +177 -0
- package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecovery.sol +23 -0
- package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryCore.sol +258 -0
- package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryInit.sol +26 -0
- package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryInitAbstract.sol +19 -0
- package/contracts/LSP11BasicSocialRecovery/LSP11Constants.sol +6 -0
- package/contracts/LSP11BasicSocialRecovery/LSP11Errors.sol +60 -0
- package/contracts/LSP14Ownable2Step/ILSP14Ownable2Step.sol +53 -0
- package/contracts/LSP14Ownable2Step/LSP14Constants.sol +15 -0
- package/contracts/LSP14Ownable2Step/LSP14Errors.sol +12 -0
- package/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol +212 -0
- package/contracts/LSP16UniversalFactory/LSP16UniversalFactory.sol +246 -0
- package/contracts/LSP17ContractExtension/LSP17Constants.sol +17 -0
- package/contracts/LSP17ContractExtension/LSP17Errors.sol +7 -0
- package/contracts/LSP17ContractExtension/LSP17Extendable.sol +104 -0
- package/contracts/LSP17ContractExtension/LSP17Extension.sol +45 -0
- package/contracts/LSP17ContractExtension/LSP17Utils.sol +20 -0
- package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiver.sol +5 -5
- package/contracts/LSP1UniversalReceiver/LSP1Constants.sol +5 -3
- package/contracts/LSP1UniversalReceiver/LSP1Errors.sol +21 -0
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +155 -37
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +64 -31
- package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +53 -40
- package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +45 -23
- package/contracts/LSP3UniversalProfile/LSP3Constants.sol +1 -1
- package/contracts/LSP4DigitalAssetMetadata/ILSP4Compatibility.sol +1 -1
- package/contracts/LSP4DigitalAssetMetadata/LSP4Compatibility.sol +1 -1
- package/contracts/LSP4DigitalAssetMetadata/LSP4Constants.sol +1 -1
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol +2 -2
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +2 -2
- package/contracts/LSP4DigitalAssetMetadata/LSP4Errors.sol +3 -3
- package/contracts/LSP5ReceivedAssets/LSP5Constants.sol +2 -2
- package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +102 -114
- package/contracts/LSP6KeyManager/ILSP6KeyManager.sol +25 -7
- package/contracts/LSP6KeyManager/LSP6Constants.sol +43 -38
- package/contracts/LSP6KeyManager/LSP6Errors.sol +90 -21
- package/contracts/LSP6KeyManager/LSP6KeyManager.sol +2 -1
- package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +224 -506
- package/contracts/LSP6KeyManager/LSP6KeyManagerInit.sol +1 -1
- package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +3 -2
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6ExecuteModule.sol +229 -0
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6OwnershipModule.sol +25 -0
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6SetDataModule.sol +606 -0
- package/contracts/LSP6KeyManager/LSP6Utils.sol +156 -35
- package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +8 -8
- package/contracts/LSP7DigitalAsset/LSP7Constants.sol +6 -6
- package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +1 -1
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +36 -36
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +1 -1
- package/contracts/LSP7DigitalAsset/LSP7Errors.sol +33 -1
- package/contracts/LSP7DigitalAsset/extensions/ILSP7CompatibleERC20.sol +1 -1
- package/contracts/LSP7DigitalAsset/extensions/LSP7Burnable.sol +24 -0
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupply.sol +28 -8
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInitAbstract.sol +28 -11
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.sol +87 -20
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20InitAbstract.sol +97 -19
- package/contracts/LSP7DigitalAsset/presets/ILSP7Mintable.sol +3 -3
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.sol +3 -4
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInit.sol +2 -2
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInitAbstract.sol +3 -3
- package/contracts/LSP7DigitalAsset/presets/LSP7Mintable.sol +3 -5
- package/contracts/LSP7DigitalAsset/presets/LSP7MintableInit.sol +2 -2
- package/contracts/LSP7DigitalAsset/presets/LSP7MintableInitAbstract.sol +3 -3
- package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +7 -7
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol +7 -7
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol +45 -2
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +2 -2
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +57 -60
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +1 -1
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CompatibleERC721.sol +5 -2
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Burnable.sol +20 -0
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.sol +27 -7
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInitAbstract.sol +27 -10
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +234 -30
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +238 -30
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.sol +32 -4
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableInitAbstract.sol +35 -8
- package/contracts/LSP8IdentifiableDigitalAsset/presets/ILSP8Mintable.sol +3 -3
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.sol +3 -4
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInit.sol +3 -3
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInitAbstract.sol +3 -3
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.sol +3 -4
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInit.sol +2 -2
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +3 -3
- package/contracts/LSP9Vault/LSP9Constants.sol +10 -10
- package/contracts/LSP9Vault/LSP9Errors.sol +8 -0
- package/contracts/LSP9Vault/LSP9Vault.sol +6 -4
- package/contracts/LSP9Vault/LSP9VaultCore.sol +350 -127
- package/contracts/LSP9Vault/LSP9VaultInit.sol +2 -2
- package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +4 -3
- package/contracts/Legacy/Registries/AddressRegistry.sol +1 -1
- package/contracts/Legacy/Registries/AddressRegistryRequiresERC725.sol +1 -1
- package/contracts/Legacy/UniversalReceiverAddressStore.sol +4 -14
- package/contracts/UniversalProfile.sol +2 -2
- package/contracts/UniversalProfileInit.sol +2 -2
- package/contracts/UniversalProfileInitAbstract.sol +1 -1
- package/contracts/Utils/GasLib.sol +1 -1
- package/module/constants.d.ts +738 -0
- package/module/constants.js +782 -0
- package/package.json +42 -12
- package/artifacts/UniversalFactory.json +0 -127
- package/constants.js +0 -594
- package/contracts/Custom/ClaimOwnership.sol +0 -96
- package/contracts/Custom/ERC165Checker.sol +0 -130
- package/contracts/Custom/IClaimOwnership.sol +0 -12
- package/contracts/Factories/UniversalFactory.sol +0 -159
- package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiverDelegate.sol +0 -24
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/Handling/TokenAndVaultHandling.sol +0 -82
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/Handling/TokenHandling.sol +0 -73
- package/contracts/LSP2ERC725YJSONSchema/LSP2Errors.sol +0 -9
- package/contracts/LSP7DigitalAsset/extensions/ILSP7CappedSupply.sol +0 -17
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyCore.sol +0 -57
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20Core.sol +0 -111
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CappedSupply.sol +0 -17
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8Enumerable.sol +0 -17
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyCore.sol +0 -58
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleConstants.sol +0 -6
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721Core.sol +0 -211
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableCore.sol +0 -50
- package/contracts/Utils/UtilsLib.sol +0 -31
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
|
|
3
|
-
pragma solidity ^0.8.0;
|
|
4
|
-
|
|
5
|
-
// interfaces
|
|
6
|
-
import {ILSP8IdentifiableDigitalAsset} from "../ILSP8IdentifiableDigitalAsset.sol";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @dev LSP8 extension, adds token supply cap.
|
|
10
|
-
*/
|
|
11
|
-
interface ILSP8CappedSupply is ILSP8IdentifiableDigitalAsset {
|
|
12
|
-
/**
|
|
13
|
-
* @dev Returns the number of tokens that can be minted.
|
|
14
|
-
* @return The token max supply
|
|
15
|
-
*/
|
|
16
|
-
function tokenSupplyCap() external view returns (uint256);
|
|
17
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
|
|
3
|
-
pragma solidity ^0.8.0;
|
|
4
|
-
|
|
5
|
-
// interfaces
|
|
6
|
-
import {ILSP8IdentifiableDigitalAsset} from "../ILSP8IdentifiableDigitalAsset.sol";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @dev LSP8 extension, adds access to a token id by an index.
|
|
10
|
-
*/
|
|
11
|
-
interface ILSP8Enumerable is ILSP8IdentifiableDigitalAsset {
|
|
12
|
-
/**
|
|
13
|
-
* @dev Returns a token id at index. See totalSupply() to get total number of minted tokens.
|
|
14
|
-
* @return TokenId or 0x00 if no token exist at the index `index`
|
|
15
|
-
*/
|
|
16
|
-
function tokenAt(uint256 index) external view returns (bytes32);
|
|
17
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
|
|
3
|
-
pragma solidity ^0.8.0;
|
|
4
|
-
|
|
5
|
-
// interfaces
|
|
6
|
-
import {ILSP8CappedSupply} from "./ILSP8CappedSupply.sol";
|
|
7
|
-
|
|
8
|
-
// modules
|
|
9
|
-
import {LSP8IdentifiableDigitalAssetCore} from "../LSP8IdentifiableDigitalAssetCore.sol";
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @dev LSP8 extension, adds token supply cap.
|
|
13
|
-
*/
|
|
14
|
-
abstract contract LSP8CappedSupplyCore is LSP8IdentifiableDigitalAssetCore, ILSP8CappedSupply {
|
|
15
|
-
// --- Errors
|
|
16
|
-
|
|
17
|
-
error LSP8CappedSupplyRequired();
|
|
18
|
-
error LSP8CappedSupplyCannotMintOverCap();
|
|
19
|
-
|
|
20
|
-
// --- Storage
|
|
21
|
-
|
|
22
|
-
uint256 internal _tokenSupplyCap;
|
|
23
|
-
|
|
24
|
-
// --- Token queries
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* @inheritdoc ILSP8CappedSupply
|
|
28
|
-
*/
|
|
29
|
-
function tokenSupplyCap() public view virtual returns (uint256) {
|
|
30
|
-
return _tokenSupplyCap;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// --- Transfer functionality
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* @dev Mints `tokenId` and transfers it to `to`.
|
|
37
|
-
*
|
|
38
|
-
* Requirements:
|
|
39
|
-
*
|
|
40
|
-
* - `tokenSupplyCap() - totalSupply()` must be greater than zero.
|
|
41
|
-
* - `tokenId` must not exist.
|
|
42
|
-
* - `to` cannot be the zero address.
|
|
43
|
-
*
|
|
44
|
-
* Emits a {Transfer} event.
|
|
45
|
-
*/
|
|
46
|
-
function _mint(
|
|
47
|
-
address to,
|
|
48
|
-
bytes32 tokenId,
|
|
49
|
-
bool force,
|
|
50
|
-
bytes memory data
|
|
51
|
-
) internal virtual override {
|
|
52
|
-
if (totalSupply() + 1 > tokenSupplyCap()) {
|
|
53
|
-
revert LSP8CappedSupplyCannotMintOverCap();
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
super._mint(to, tokenId, force, data);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
|
|
3
|
-
pragma solidity ^0.8.0;
|
|
4
|
-
|
|
5
|
-
// interfaces
|
|
6
|
-
import {ILSP8IdentifiableDigitalAsset} from "../ILSP8IdentifiableDigitalAsset.sol";
|
|
7
|
-
import {ILSP8CompatibleERC721} from "./ILSP8CompatibleERC721.sol";
|
|
8
|
-
|
|
9
|
-
// libraries
|
|
10
|
-
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
|
11
|
-
import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol";
|
|
12
|
-
|
|
13
|
-
// modules
|
|
14
|
-
import {LSP4Compatibility} from "../../LSP4DigitalAssetMetadata/LSP4Compatibility.sol";
|
|
15
|
-
import {LSP8IdentifiableDigitalAssetCore} from "../LSP8IdentifiableDigitalAssetCore.sol";
|
|
16
|
-
|
|
17
|
-
// errors
|
|
18
|
-
import "../LSP8Errors.sol";
|
|
19
|
-
|
|
20
|
-
// constants
|
|
21
|
-
import {_LSP4_METADATA_KEY} from "../../LSP4DigitalAssetMetadata/LSP4Constants.sol";
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* @dev LSP8 extension, for compatibility for clients / tools that expect ERC721.
|
|
25
|
-
*/
|
|
26
|
-
abstract contract LSP8CompatibleERC721Core is
|
|
27
|
-
LSP4Compatibility,
|
|
28
|
-
LSP8IdentifiableDigitalAssetCore,
|
|
29
|
-
ILSP8CompatibleERC721
|
|
30
|
-
{
|
|
31
|
-
using EnumerableSet for EnumerableSet.AddressSet;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Mapping from owner to operator approvals
|
|
35
|
-
* @dev for backward compatibility with ERC721
|
|
36
|
-
*/
|
|
37
|
-
mapping(address => mapping(address => bool)) private _operatorApprovals;
|
|
38
|
-
|
|
39
|
-
/*
|
|
40
|
-
* @inheritdoc ILSP8CompatibleERC721
|
|
41
|
-
*/
|
|
42
|
-
function tokenURI(
|
|
43
|
-
uint256 tokenId // solhint-disable no-unused-vars
|
|
44
|
-
) public view virtual returns (string memory) {
|
|
45
|
-
bytes memory data = _getData(_LSP4_METADATA_KEY);
|
|
46
|
-
|
|
47
|
-
// offset = bytes4(hashSig) + bytes32(contentHash) -> 4 + 32 = 36
|
|
48
|
-
uint256 offset = 36;
|
|
49
|
-
|
|
50
|
-
bytes memory uriBytes = BytesLib.slice(data, offset, data.length - offset);
|
|
51
|
-
return string(uriBytes);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* @inheritdoc ILSP8CompatibleERC721
|
|
56
|
-
*/
|
|
57
|
-
function ownerOf(uint256 tokenId) public view virtual returns (address) {
|
|
58
|
-
return tokenOwnerOf(bytes32(tokenId));
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* @inheritdoc ILSP8CompatibleERC721
|
|
63
|
-
*/
|
|
64
|
-
function approve(address operator, uint256 tokenId) public virtual {
|
|
65
|
-
authorizeOperator(operator, bytes32(tokenId));
|
|
66
|
-
|
|
67
|
-
emit Approval(tokenOwnerOf(bytes32(tokenId)), operator, tokenId);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function setApprovalForAll(address operator, bool approved) public virtual {
|
|
71
|
-
_setApprovalForAll(msg.sender, operator, approved);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* @inheritdoc ILSP8CompatibleERC721
|
|
76
|
-
*/
|
|
77
|
-
function getApproved(uint256 tokenId) public view virtual returns (address) {
|
|
78
|
-
bytes32 tokenIdAsBytes32 = bytes32(tokenId);
|
|
79
|
-
_existsOrError(tokenIdAsBytes32);
|
|
80
|
-
|
|
81
|
-
EnumerableSet.AddressSet storage operatorsForTokenId = _operators[tokenIdAsBytes32];
|
|
82
|
-
uint256 operatorListLength = operatorsForTokenId.length();
|
|
83
|
-
|
|
84
|
-
if (operatorListLength == 0) {
|
|
85
|
-
return address(0);
|
|
86
|
-
} else {
|
|
87
|
-
// Read the last added operator authorized to provide "best" compatibility.
|
|
88
|
-
// In ERC721 there is one operator address at a time for a tokenId, so multiple calls to
|
|
89
|
-
// `approve` would cause `getApproved` to return the last added operator. In this
|
|
90
|
-
// compatibility version the same is true, when the authorized operators were not previously
|
|
91
|
-
// authorized. If addresses are removed, then `getApproved` returned address can change due
|
|
92
|
-
// to implementation of `EnumberableSet._remove`.
|
|
93
|
-
return operatorsForTokenId.at(operatorListLength - 1);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/*
|
|
98
|
-
* @inheritdoc ILSP8CompatibleERC721
|
|
99
|
-
*/
|
|
100
|
-
function isApprovedForAll(address tokenOwner, address operator)
|
|
101
|
-
public
|
|
102
|
-
view
|
|
103
|
-
virtual
|
|
104
|
-
returns (bool)
|
|
105
|
-
{
|
|
106
|
-
return _operatorApprovals[tokenOwner][operator];
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* @inheritdoc ILSP8CompatibleERC721
|
|
111
|
-
* @dev Compatible with ERC721 transferFrom.
|
|
112
|
-
* Using force=true so that EOA and any contract may receive the tokenId.
|
|
113
|
-
*/
|
|
114
|
-
function transferFrom(
|
|
115
|
-
address from,
|
|
116
|
-
address to,
|
|
117
|
-
uint256 tokenId
|
|
118
|
-
) public virtual {
|
|
119
|
-
return _transfer(from, to, bytes32(tokenId), true, "");
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* @inheritdoc ILSP8CompatibleERC721
|
|
124
|
-
* @dev Compatible with ERC721 safeTransferFrom.
|
|
125
|
-
* Using force=false so that no EOA and only contracts supporting LSP1 interface may receive the tokenId.
|
|
126
|
-
*/
|
|
127
|
-
function safeTransferFrom(
|
|
128
|
-
address from,
|
|
129
|
-
address to,
|
|
130
|
-
uint256 tokenId
|
|
131
|
-
) public virtual {
|
|
132
|
-
return _transfer(from, to, bytes32(tokenId), false, "");
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/*
|
|
136
|
-
* @dev Compatible with ERC721 safeTransferFrom.
|
|
137
|
-
* Using force=false so that no EOA and only contracts supporting LSP1 interface may receive the tokenId.
|
|
138
|
-
*/
|
|
139
|
-
function safeTransferFrom(
|
|
140
|
-
address from,
|
|
141
|
-
address to,
|
|
142
|
-
uint256 tokenId,
|
|
143
|
-
bytes memory data
|
|
144
|
-
) public virtual {
|
|
145
|
-
return _transfer(from, to, bytes32(tokenId), false, data);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// --- Overrides
|
|
149
|
-
|
|
150
|
-
function authorizeOperator(address operator, bytes32 tokenId)
|
|
151
|
-
public
|
|
152
|
-
virtual
|
|
153
|
-
override(ILSP8IdentifiableDigitalAsset, LSP8IdentifiableDigitalAssetCore)
|
|
154
|
-
{
|
|
155
|
-
super.authorizeOperator(operator, tokenId);
|
|
156
|
-
|
|
157
|
-
emit Approval(tokenOwnerOf(tokenId), operator, uint256(tokenId));
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
function _transfer(
|
|
161
|
-
address from,
|
|
162
|
-
address to,
|
|
163
|
-
bytes32 tokenId,
|
|
164
|
-
bool force,
|
|
165
|
-
bytes memory data
|
|
166
|
-
) internal virtual override {
|
|
167
|
-
address operator = msg.sender;
|
|
168
|
-
|
|
169
|
-
if (!isApprovedForAll(from, operator) && !_isOperatorOrOwner(operator, tokenId)) {
|
|
170
|
-
revert LSP8NotTokenOperator(tokenId, operator);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
super._transfer(from, to, tokenId, force, data);
|
|
174
|
-
|
|
175
|
-
emit Transfer(from, to, uint256(tokenId));
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
function _mint(
|
|
179
|
-
address to,
|
|
180
|
-
bytes32 tokenId,
|
|
181
|
-
bool force,
|
|
182
|
-
bytes memory data
|
|
183
|
-
) internal virtual override {
|
|
184
|
-
super._mint(to, tokenId, force, data);
|
|
185
|
-
|
|
186
|
-
emit Transfer(address(0), to, uint256(tokenId));
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
function _burn(bytes32 tokenId, bytes memory data) internal virtual override {
|
|
190
|
-
address tokenOwner = tokenOwnerOf(tokenId);
|
|
191
|
-
|
|
192
|
-
super._burn(tokenId, data);
|
|
193
|
-
|
|
194
|
-
emit Transfer(tokenOwner, address(0), uint256(tokenId));
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* @dev Approve `operator` to operate on all of `owner` tokens
|
|
199
|
-
*
|
|
200
|
-
* Emits an {ApprovalForAll} event.
|
|
201
|
-
*/
|
|
202
|
-
function _setApprovalForAll(
|
|
203
|
-
address tokensOwner,
|
|
204
|
-
address operator,
|
|
205
|
-
bool approved
|
|
206
|
-
) internal virtual {
|
|
207
|
-
require(tokensOwner != operator, "LSP8CompatibleERC721: approve to caller");
|
|
208
|
-
_operatorApprovals[tokensOwner][operator] = approved;
|
|
209
|
-
emit ApprovalForAll(tokensOwner, operator, approved);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
|
|
3
|
-
pragma solidity ^0.8.0;
|
|
4
|
-
|
|
5
|
-
// interfaces
|
|
6
|
-
import {ILSP8Enumerable} from "./ILSP8Enumerable.sol";
|
|
7
|
-
|
|
8
|
-
// modules
|
|
9
|
-
import {LSP8IdentifiableDigitalAssetCore} from "../LSP8IdentifiableDigitalAssetCore.sol";
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @dev LSP8 extension, adds access to a token id by an index.
|
|
13
|
-
*/
|
|
14
|
-
abstract contract LSP8EnumerableCore is LSP8IdentifiableDigitalAssetCore, ILSP8Enumerable {
|
|
15
|
-
// Mapping from token index to token id
|
|
16
|
-
mapping(uint256 => bytes32) private _indexToken;
|
|
17
|
-
|
|
18
|
-
// Mapping from token id to index
|
|
19
|
-
mapping(bytes32 => uint256) private _tokenIndex;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* @inheritdoc ILSP8Enumerable
|
|
23
|
-
*/
|
|
24
|
-
function tokenAt(uint256 index) public view returns (bytes32) {
|
|
25
|
-
return _indexToken[index];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function _beforeTokenTransfer(
|
|
29
|
-
address from,
|
|
30
|
-
address to,
|
|
31
|
-
bytes32 tokenId
|
|
32
|
-
) internal virtual override(LSP8IdentifiableDigitalAssetCore) {
|
|
33
|
-
if (from == address(0)) {
|
|
34
|
-
uint256 index = _existingTokens;
|
|
35
|
-
_indexToken[index] = tokenId;
|
|
36
|
-
_tokenIndex[tokenId] = index;
|
|
37
|
-
} else if (to == address(0)) {
|
|
38
|
-
uint256 lastIndex = _existingTokens - 1;
|
|
39
|
-
uint256 index = _tokenIndex[tokenId];
|
|
40
|
-
if (index < lastIndex) {
|
|
41
|
-
bytes32 lastTokenId = _indexToken[lastIndex];
|
|
42
|
-
_indexToken[index] = lastTokenId;
|
|
43
|
-
_tokenIndex[lastTokenId] = index;
|
|
44
|
-
}
|
|
45
|
-
delete _indexToken[lastIndex];
|
|
46
|
-
delete _tokenIndex[tokenId];
|
|
47
|
-
}
|
|
48
|
-
super._beforeTokenTransfer(from, to, tokenId);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
pragma solidity ^0.8.0;
|
|
3
|
-
|
|
4
|
-
/*
|
|
5
|
-
* @dev Casting utility library for ethereum contracts written in Solidity.
|
|
6
|
-
* The library lets you concatenate, type cast efficiently. // To Test
|
|
7
|
-
*/
|
|
8
|
-
library UtilsLib {
|
|
9
|
-
// solhint-disable no-inline-assembly
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @dev concatenate two bytes16
|
|
13
|
-
*/
|
|
14
|
-
function concatTwoBytes16(bytes16 b1, bytes16 b2) internal pure returns (bytes memory result) {
|
|
15
|
-
result = bytes.concat(b1, b2);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @dev cast uint256 to bytes
|
|
20
|
-
*/
|
|
21
|
-
function uint256ToBytes(uint256 num) internal pure returns (bytes memory bytes_) {
|
|
22
|
-
bytes_ = bytes.concat(bytes32(num));
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* @dev cast address to bytes
|
|
27
|
-
*/
|
|
28
|
-
function addressToBytes(address addr) internal pure returns (bytes memory bytes_) {
|
|
29
|
-
bytes_ = bytes.concat(bytes20(addr));
|
|
30
|
-
}
|
|
31
|
-
}
|