@lukso/lsp-smart-contracts 0.7.0 → 0.8.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.
- package/CONTRIBUTING.md +31 -0
- package/README.md +73 -20
- 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 +21 -5
- package/artifacts/LSP7CappedSupplyInitAbstract.json +21 -5
- package/artifacts/LSP7CompatibleERC20.json +21 -5
- package/artifacts/LSP7CompatibleERC20InitAbstract.json +23 -7
- package/artifacts/LSP7CompatibleERC20Mintable.json +24 -8
- package/artifacts/LSP7CompatibleERC20MintableInit.json +24 -8
- package/artifacts/LSP7DigitalAsset.json +21 -5
- package/artifacts/LSP7DigitalAssetInitAbstract.json +21 -5
- package/artifacts/LSP7Mintable.json +24 -8
- package/artifacts/LSP7MintableInit.json +24 -8
- package/artifacts/LSP8CappedSupply.json +22 -6
- package/artifacts/LSP8CappedSupplyInitAbstract.json +22 -6
- package/artifacts/LSP8CompatibleERC721.json +23 -7
- package/artifacts/LSP8CompatibleERC721InitAbstract.json +25 -9
- package/artifacts/LSP8CompatibleERC721Mintable.json +26 -10
- package/artifacts/LSP8CompatibleERC721MintableInit.json +26 -10
- package/artifacts/LSP8IdentifiableDigitalAsset.json +22 -6
- package/artifacts/LSP8IdentifiableDigitalAssetInitAbstract.json +22 -6
- package/artifacts/LSP8Mintable.json +25 -9
- package/artifacts/LSP8MintableInit.json +25 -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/constants.js +377 -115
- 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 +261 -63
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +2 -2
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +2 -1
- package/contracts/LSP10ReceivedVaults/LSP10Constants.sol +2 -2
- package/contracts/LSP10ReceivedVaults/LSP10Utils.sol +214 -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 +157 -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 +772 -364
- package/contracts/LSP6KeyManager/LSP6KeyManagerInit.sol +1 -1
- package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +3 -2
- package/contracts/LSP6KeyManager/LSP6Utils.sol +125 -34
- 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 +38 -34
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +1 -1
- package/contracts/LSP7DigitalAsset/LSP7Errors.sol +28 -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 +40 -2
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +2 -2
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +53 -50
- 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 +236 -30
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +240 -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 +289 -126
- 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/package.json +17 -9
- package/artifacts/UniversalFactory.json +0 -127
- 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,31 +1,50 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
|
|
3
|
-
pragma solidity ^0.8.0;
|
|
2
|
+
pragma solidity ^0.8.12;
|
|
4
3
|
|
|
5
4
|
// interfaces
|
|
6
5
|
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
|
|
6
|
+
import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
|
|
7
|
+
import {ILSP8CompatibleERC721} from "./ILSP8CompatibleERC721.sol";
|
|
8
|
+
import {ILSP8IdentifiableDigitalAsset} from "../ILSP8IdentifiableDigitalAsset.sol";
|
|
7
9
|
|
|
8
10
|
// libraries
|
|
11
|
+
import {Address} from "@openzeppelin/contracts/utils/Address.sol";
|
|
9
12
|
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
|
13
|
+
import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol";
|
|
10
14
|
|
|
11
15
|
// modules
|
|
16
|
+
import {LSP4Compatibility} from "../../LSP4DigitalAssetMetadata/LSP4Compatibility.sol";
|
|
12
17
|
import {
|
|
13
18
|
LSP8IdentifiableDigitalAsset,
|
|
14
19
|
LSP4DigitalAssetMetadata,
|
|
15
20
|
ERC725YCore
|
|
16
21
|
} from "../LSP8IdentifiableDigitalAsset.sol";
|
|
17
22
|
import {LSP8IdentifiableDigitalAssetCore} from "../LSP8IdentifiableDigitalAssetCore.sol";
|
|
18
|
-
|
|
23
|
+
|
|
24
|
+
// errors
|
|
25
|
+
import "../LSP8Errors.sol";
|
|
19
26
|
|
|
20
27
|
// constants
|
|
21
|
-
import {
|
|
28
|
+
import {_LSP4_METADATA_KEY} from "../../LSP4DigitalAssetMetadata/LSP4Constants.sol";
|
|
29
|
+
import {_INTERFACEID_ERC721, _INTERFACEID_ERC721METADATA} from "././ILSP8CompatibleERC721.sol";
|
|
22
30
|
|
|
23
31
|
/**
|
|
24
32
|
* @dev LSP8 extension, for compatibility for clients / tools that expect ERC721.
|
|
25
33
|
*/
|
|
26
|
-
abstract contract LSP8CompatibleERC721 is
|
|
34
|
+
abstract contract LSP8CompatibleERC721 is
|
|
35
|
+
ILSP8CompatibleERC721,
|
|
36
|
+
LSP4Compatibility,
|
|
37
|
+
LSP8IdentifiableDigitalAsset
|
|
38
|
+
{
|
|
39
|
+
using Address for address;
|
|
27
40
|
using EnumerableSet for EnumerableSet.AddressSet;
|
|
28
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Mapping from owner to operator approvals
|
|
44
|
+
* @dev for backward compatibility with ERC721
|
|
45
|
+
*/
|
|
46
|
+
mapping(address => mapping(address => bool)) private _operatorApprovals;
|
|
47
|
+
|
|
29
48
|
/**
|
|
30
49
|
* @notice Sets the name, the symbol and the owner of the token
|
|
31
50
|
* @param name_ The name of the token
|
|
@@ -36,59 +55,246 @@ abstract contract LSP8CompatibleERC721 is LSP8IdentifiableDigitalAsset, LSP8Comp
|
|
|
36
55
|
string memory name_,
|
|
37
56
|
string memory symbol_,
|
|
38
57
|
address newOwner_
|
|
39
|
-
) LSP8IdentifiableDigitalAsset(name_, symbol_, newOwner_) {}
|
|
58
|
+
) LSP8IdentifiableDigitalAsset(name_, symbol_, newOwner_) {}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* @dev See {IERC165-supportsInterface}.
|
|
62
|
+
*/
|
|
63
|
+
function supportsInterface(bytes4 interfaceId)
|
|
64
|
+
public
|
|
65
|
+
view
|
|
66
|
+
virtual
|
|
67
|
+
override(IERC165, ERC725YCore, LSP8IdentifiableDigitalAsset)
|
|
68
|
+
returns (bool)
|
|
69
|
+
{
|
|
70
|
+
return
|
|
71
|
+
interfaceId == _INTERFACEID_ERC721 ||
|
|
72
|
+
interfaceId == _INTERFACEID_ERC721METADATA ||
|
|
73
|
+
super.supportsInterface(interfaceId);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/*
|
|
77
|
+
* @inheritdoc ILSP8CompatibleERC721
|
|
78
|
+
*/
|
|
79
|
+
function tokenURI(
|
|
80
|
+
uint256 /* tokenId */
|
|
81
|
+
) public view virtual returns (string memory) {
|
|
82
|
+
bytes memory data = _getData(_LSP4_METADATA_KEY);
|
|
83
|
+
|
|
84
|
+
// offset = bytes4(hashSig) + bytes32(contentHash) -> 4 + 32 = 36
|
|
85
|
+
uint256 offset = 36;
|
|
86
|
+
|
|
87
|
+
bytes memory uriBytes = BytesLib.slice(data, offset, data.length - offset);
|
|
88
|
+
return string(uriBytes);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @inheritdoc ILSP8CompatibleERC721
|
|
93
|
+
*/
|
|
94
|
+
function ownerOf(uint256 tokenId) public view virtual returns (address) {
|
|
95
|
+
return tokenOwnerOf(bytes32(tokenId));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @inheritdoc ILSP8CompatibleERC721
|
|
100
|
+
*/
|
|
101
|
+
function getApproved(uint256 tokenId) public view virtual returns (address) {
|
|
102
|
+
bytes32 tokenIdAsBytes32 = bytes32(tokenId);
|
|
103
|
+
_existsOrError(tokenIdAsBytes32);
|
|
104
|
+
|
|
105
|
+
EnumerableSet.AddressSet storage operatorsForTokenId = _operators[tokenIdAsBytes32];
|
|
106
|
+
uint256 operatorListLength = operatorsForTokenId.length();
|
|
107
|
+
|
|
108
|
+
if (operatorListLength == 0) {
|
|
109
|
+
return address(0);
|
|
110
|
+
} else {
|
|
111
|
+
// Read the last added operator authorized to provide "best" compatibility.
|
|
112
|
+
// In ERC721 there is one operator address at a time for a tokenId, so multiple calls to
|
|
113
|
+
// `approve` would cause `getApproved` to return the last added operator. In this
|
|
114
|
+
// compatibility version the same is true, when the authorized operators were not previously
|
|
115
|
+
// authorized. If addresses are removed, then `getApproved` returned address can change due
|
|
116
|
+
// to implementation of `EnumberableSet._remove`.
|
|
117
|
+
return operatorsForTokenId.at(operatorListLength - 1);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/*
|
|
122
|
+
* @inheritdoc ILSP8CompatibleERC721
|
|
123
|
+
*/
|
|
124
|
+
function isApprovedForAll(address tokenOwner, address operator)
|
|
125
|
+
public
|
|
126
|
+
view
|
|
127
|
+
virtual
|
|
128
|
+
returns (bool)
|
|
129
|
+
{
|
|
130
|
+
return _operatorApprovals[tokenOwner][operator];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* @inheritdoc ILSP8CompatibleERC721
|
|
135
|
+
*/
|
|
136
|
+
function approve(address operator, uint256 tokenId) public virtual {
|
|
137
|
+
authorizeOperator(operator, bytes32(tokenId));
|
|
138
|
+
emit Approval(tokenOwnerOf(bytes32(tokenId)), operator, tokenId);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* @dev See _setApprovalForAll
|
|
143
|
+
*/
|
|
144
|
+
function setApprovalForAll(address operator, bool approved) public virtual {
|
|
145
|
+
_setApprovalForAll(msg.sender, operator, approved);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* @inheritdoc ILSP8CompatibleERC721
|
|
150
|
+
* @dev Compatible with ERC721 transferFrom.
|
|
151
|
+
* Using allowNonLSP1Recipient=true so that EOA and any contract may receive the tokenId.
|
|
152
|
+
*/
|
|
153
|
+
function transferFrom(
|
|
154
|
+
address from,
|
|
155
|
+
address to,
|
|
156
|
+
uint256 tokenId
|
|
157
|
+
) public virtual {
|
|
158
|
+
_transfer(from, to, bytes32(tokenId), true, "");
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* @inheritdoc ILSP8CompatibleERC721
|
|
163
|
+
* @dev Compatible with ERC721 safeTransferFrom (without optional data).
|
|
164
|
+
* Using allowNonLSP1Recipient=false so that no EOA and only contracts supporting LSP1 interface may receive the tokenId.
|
|
165
|
+
*/
|
|
166
|
+
function safeTransferFrom(
|
|
167
|
+
address from,
|
|
168
|
+
address to,
|
|
169
|
+
uint256 tokenId
|
|
170
|
+
) public virtual {
|
|
171
|
+
_safeTransfer(from, to, tokenId, "");
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/*
|
|
175
|
+
* @dev Compatible with ERC721 safeTransferFrom (with optional data).
|
|
176
|
+
* Using allowNonLSP1Recipient=false so that no EOA and only contracts supporting LSP1 interface may receive the tokenId.
|
|
177
|
+
*/
|
|
178
|
+
function safeTransferFrom(
|
|
179
|
+
address from,
|
|
180
|
+
address to,
|
|
181
|
+
uint256 tokenId,
|
|
182
|
+
bytes memory data
|
|
183
|
+
) public virtual {
|
|
184
|
+
_safeTransfer(from, to, tokenId, data);
|
|
185
|
+
}
|
|
40
186
|
|
|
41
187
|
// --- Overrides
|
|
42
188
|
|
|
189
|
+
/**
|
|
190
|
+
* @inheritdoc ILSP8IdentifiableDigitalAsset
|
|
191
|
+
*/
|
|
43
192
|
function authorizeOperator(address operator, bytes32 tokenId)
|
|
44
193
|
public
|
|
45
194
|
virtual
|
|
46
|
-
override(
|
|
195
|
+
override(ILSP8IdentifiableDigitalAsset, LSP8IdentifiableDigitalAssetCore)
|
|
47
196
|
{
|
|
48
197
|
super.authorizeOperator(operator, tokenId);
|
|
198
|
+
emit Approval(tokenOwnerOf(tokenId), operator, uint256(tokenId));
|
|
49
199
|
}
|
|
50
200
|
|
|
51
201
|
function _transfer(
|
|
52
202
|
address from,
|
|
53
203
|
address to,
|
|
54
204
|
bytes32 tokenId,
|
|
55
|
-
bool
|
|
205
|
+
bool allowNonLSP1Recipient,
|
|
206
|
+
bytes memory data
|
|
207
|
+
) internal virtual override {
|
|
208
|
+
address operator = msg.sender;
|
|
209
|
+
|
|
210
|
+
if (!isApprovedForAll(from, operator) && !_isOperatorOrOwner(operator, tokenId)) {
|
|
211
|
+
revert LSP8NotTokenOperator(tokenId, operator);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
emit Transfer(from, to, uint256(tokenId));
|
|
215
|
+
super._transfer(from, to, tokenId, allowNonLSP1Recipient, data);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function _safeTransfer(
|
|
219
|
+
address from,
|
|
220
|
+
address to,
|
|
221
|
+
uint256 tokenId,
|
|
56
222
|
bytes memory data
|
|
57
|
-
) internal virtual
|
|
58
|
-
|
|
223
|
+
) internal virtual {
|
|
224
|
+
_transfer(from, to, bytes32(tokenId), true, data);
|
|
225
|
+
require(
|
|
226
|
+
_checkOnERC721Received(from, to, tokenId, data),
|
|
227
|
+
"LSP8CompatibleERC721: transfer to non ERC721Receiver implementer"
|
|
228
|
+
);
|
|
59
229
|
}
|
|
60
230
|
|
|
61
231
|
function _mint(
|
|
62
232
|
address to,
|
|
63
233
|
bytes32 tokenId,
|
|
64
|
-
bool
|
|
234
|
+
bool allowNonLSP1Recipient,
|
|
65
235
|
bytes memory data
|
|
66
|
-
) internal virtual override
|
|
67
|
-
super._mint(to, tokenId,
|
|
236
|
+
) internal virtual override {
|
|
237
|
+
super._mint(to, tokenId, allowNonLSP1Recipient, data);
|
|
238
|
+
emit Transfer(address(0), to, uint256(tokenId));
|
|
68
239
|
}
|
|
69
240
|
|
|
70
|
-
function _burn(bytes32 tokenId, bytes memory data)
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
override(LSP8IdentifiableDigitalAssetCore, LSP8CompatibleERC721Core)
|
|
74
|
-
{
|
|
241
|
+
function _burn(bytes32 tokenId, bytes memory data) internal virtual override {
|
|
242
|
+
address tokenOwner = tokenOwnerOf(tokenId);
|
|
243
|
+
|
|
75
244
|
super._burn(tokenId, data);
|
|
245
|
+
emit Transfer(tokenOwner, address(0), uint256(tokenId));
|
|
76
246
|
}
|
|
77
247
|
|
|
78
248
|
/**
|
|
79
|
-
* @dev
|
|
249
|
+
* @dev Approve `operator` to operate on all tokens of `tokensOwner`
|
|
250
|
+
*
|
|
251
|
+
* Emits an {ApprovalForAll} event.
|
|
80
252
|
*/
|
|
81
|
-
function
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
253
|
+
function _setApprovalForAll(
|
|
254
|
+
address tokensOwner,
|
|
255
|
+
address operator,
|
|
256
|
+
bool approved
|
|
257
|
+
) internal virtual {
|
|
258
|
+
require(tokensOwner != operator, "LSP8CompatibleERC721: approve to caller");
|
|
259
|
+
_operatorApprovals[tokensOwner][operator] = approved;
|
|
260
|
+
emit ApprovalForAll(tokensOwner, operator, approved);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
|
|
265
|
+
* The call is not executed if the target address is not a contract.
|
|
266
|
+
*
|
|
267
|
+
* @param from address representing the previous owner of the given token ID
|
|
268
|
+
* @param to target address that will receive the token
|
|
269
|
+
* @param tokenId uint256 ID of the token to be transferred
|
|
270
|
+
* @param data bytes optional data to send along with the call
|
|
271
|
+
* @return bool whether the call correctly returned the expected magic value
|
|
272
|
+
*/
|
|
273
|
+
function _checkOnERC721Received(
|
|
274
|
+
address from,
|
|
275
|
+
address to,
|
|
276
|
+
uint256 tokenId,
|
|
277
|
+
bytes memory data
|
|
278
|
+
) private returns (bool) {
|
|
279
|
+
if (to.isContract()) {
|
|
280
|
+
try IERC721Receiver(to).onERC721Received(msg.sender, from, tokenId, data) returns (
|
|
281
|
+
bytes4 retval
|
|
282
|
+
) {
|
|
283
|
+
return retval == IERC721Receiver.onERC721Received.selector;
|
|
284
|
+
} catch (bytes memory reason) {
|
|
285
|
+
if (reason.length == 0) {
|
|
286
|
+
revert("LSP8CompatibleERC721: transfer to non ERC721Receiver implementer");
|
|
287
|
+
} else {
|
|
288
|
+
// solhint-disable no-inline-assembly
|
|
289
|
+
/// @solidity memory-safe-assembly
|
|
290
|
+
assembly {
|
|
291
|
+
revert(add(32, reason), mload(reason))
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
} else {
|
|
296
|
+
return true;
|
|
297
|
+
}
|
|
92
298
|
}
|
|
93
299
|
|
|
94
300
|
function _setData(bytes32 key, bytes memory value)
|
package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol
CHANGED
|
@@ -1,29 +1,50 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
|
|
3
|
-
pragma solidity ^0.8.0;
|
|
2
|
+
pragma solidity ^0.8.12;
|
|
4
3
|
|
|
5
4
|
// interfaces
|
|
6
5
|
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
|
|
6
|
+
import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
|
|
7
|
+
import {ILSP8CompatibleERC721} from "./ILSP8CompatibleERC721.sol";
|
|
8
|
+
import {ILSP8IdentifiableDigitalAsset} from "../ILSP8IdentifiableDigitalAsset.sol";
|
|
9
|
+
|
|
10
|
+
// libraries
|
|
11
|
+
import {Address} from "@openzeppelin/contracts/utils/Address.sol";
|
|
12
|
+
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
|
13
|
+
import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol";
|
|
7
14
|
|
|
8
15
|
// modules
|
|
16
|
+
import {LSP4Compatibility} from "../../LSP4DigitalAssetMetadata/LSP4Compatibility.sol";
|
|
9
17
|
import {
|
|
10
18
|
LSP8IdentifiableDigitalAssetInitAbstract,
|
|
11
19
|
LSP4DigitalAssetMetadataInitAbstract,
|
|
12
20
|
ERC725YCore
|
|
13
21
|
} from "../LSP8IdentifiableDigitalAssetInitAbstract.sol";
|
|
14
22
|
import {LSP8IdentifiableDigitalAssetCore} from "../LSP8IdentifiableDigitalAssetCore.sol";
|
|
15
|
-
|
|
23
|
+
|
|
24
|
+
// errors
|
|
25
|
+
import "../LSP8Errors.sol";
|
|
16
26
|
|
|
17
27
|
// constants
|
|
18
|
-
import {
|
|
28
|
+
import {_LSP4_METADATA_KEY} from "../../LSP4DigitalAssetMetadata/LSP4Constants.sol";
|
|
29
|
+
import {_INTERFACEID_ERC721, _INTERFACEID_ERC721METADATA} from "./ILSP8CompatibleERC721.sol";
|
|
19
30
|
|
|
20
31
|
/**
|
|
21
32
|
* @dev LSP8 extension, for compatibility for clients / tools that expect ERC721.
|
|
22
33
|
*/
|
|
23
|
-
contract LSP8CompatibleERC721InitAbstract is
|
|
34
|
+
abstract contract LSP8CompatibleERC721InitAbstract is
|
|
35
|
+
ILSP8CompatibleERC721,
|
|
24
36
|
LSP8IdentifiableDigitalAssetInitAbstract,
|
|
25
|
-
|
|
37
|
+
LSP4Compatibility
|
|
26
38
|
{
|
|
39
|
+
using Address for address;
|
|
40
|
+
using EnumerableSet for EnumerableSet.AddressSet;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Mapping from owner to operator approvals
|
|
44
|
+
* @dev for backward compatibility with ERC721
|
|
45
|
+
*/
|
|
46
|
+
mapping(address => mapping(address => bool)) private _operatorApprovals;
|
|
47
|
+
|
|
27
48
|
function _initialize(
|
|
28
49
|
string memory name_,
|
|
29
50
|
string memory symbol_,
|
|
@@ -32,55 +53,244 @@ contract LSP8CompatibleERC721InitAbstract is
|
|
|
32
53
|
LSP8IdentifiableDigitalAssetInitAbstract._initialize(name_, symbol_, newOwner_);
|
|
33
54
|
}
|
|
34
55
|
|
|
56
|
+
/**
|
|
57
|
+
* @dev See {IERC165-supportsInterface}.
|
|
58
|
+
*/
|
|
59
|
+
function supportsInterface(bytes4 interfaceId)
|
|
60
|
+
public
|
|
61
|
+
view
|
|
62
|
+
virtual
|
|
63
|
+
override(IERC165, ERC725YCore, LSP8IdentifiableDigitalAssetInitAbstract)
|
|
64
|
+
returns (bool)
|
|
65
|
+
{
|
|
66
|
+
return
|
|
67
|
+
interfaceId == _INTERFACEID_ERC721 ||
|
|
68
|
+
interfaceId == _INTERFACEID_ERC721METADATA ||
|
|
69
|
+
super.supportsInterface(interfaceId);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/*
|
|
73
|
+
* @inheritdoc ILSP8CompatibleERC721
|
|
74
|
+
*/
|
|
75
|
+
function tokenURI(
|
|
76
|
+
uint256 /* tokenId */
|
|
77
|
+
) public view virtual returns (string memory) {
|
|
78
|
+
bytes memory data = _getData(_LSP4_METADATA_KEY);
|
|
79
|
+
|
|
80
|
+
// offset = bytes4(hashSig) + bytes32(contentHash) -> 4 + 32 = 36
|
|
81
|
+
uint256 offset = 36;
|
|
82
|
+
|
|
83
|
+
bytes memory uriBytes = BytesLib.slice(data, offset, data.length - offset);
|
|
84
|
+
return string(uriBytes);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @inheritdoc ILSP8CompatibleERC721
|
|
89
|
+
*/
|
|
90
|
+
function ownerOf(uint256 tokenId) public view virtual returns (address) {
|
|
91
|
+
return tokenOwnerOf(bytes32(tokenId));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* @inheritdoc ILSP8CompatibleERC721
|
|
96
|
+
*/
|
|
97
|
+
function getApproved(uint256 tokenId) public view virtual returns (address) {
|
|
98
|
+
bytes32 tokenIdAsBytes32 = bytes32(tokenId);
|
|
99
|
+
_existsOrError(tokenIdAsBytes32);
|
|
100
|
+
|
|
101
|
+
EnumerableSet.AddressSet storage operatorsForTokenId = _operators[tokenIdAsBytes32];
|
|
102
|
+
uint256 operatorListLength = operatorsForTokenId.length();
|
|
103
|
+
|
|
104
|
+
if (operatorListLength == 0) {
|
|
105
|
+
return address(0);
|
|
106
|
+
} else {
|
|
107
|
+
// Read the last added operator authorized to provide "best" compatibility.
|
|
108
|
+
// In ERC721 there is one operator address at a time for a tokenId, so multiple calls to
|
|
109
|
+
// `approve` would cause `getApproved` to return the last added operator. In this
|
|
110
|
+
// compatibility version the same is true, when the authorized operators were not previously
|
|
111
|
+
// authorized. If addresses are removed, then `getApproved` returned address can change due
|
|
112
|
+
// to implementation of `EnumberableSet._remove`.
|
|
113
|
+
return operatorsForTokenId.at(operatorListLength - 1);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/*
|
|
118
|
+
* @inheritdoc ILSP8CompatibleERC721
|
|
119
|
+
*/
|
|
120
|
+
function isApprovedForAll(address tokenOwner, address operator)
|
|
121
|
+
public
|
|
122
|
+
view
|
|
123
|
+
virtual
|
|
124
|
+
returns (bool)
|
|
125
|
+
{
|
|
126
|
+
return _operatorApprovals[tokenOwner][operator];
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* @inheritdoc ILSP8CompatibleERC721
|
|
131
|
+
*/
|
|
132
|
+
function approve(address operator, uint256 tokenId) public virtual {
|
|
133
|
+
authorizeOperator(operator, bytes32(tokenId));
|
|
134
|
+
emit Approval(tokenOwnerOf(bytes32(tokenId)), operator, tokenId);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* @dev See _setApprovalForAll
|
|
139
|
+
*/
|
|
140
|
+
function setApprovalForAll(address operator, bool approved) public virtual {
|
|
141
|
+
_setApprovalForAll(msg.sender, operator, approved);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* @inheritdoc ILSP8CompatibleERC721
|
|
146
|
+
* @dev Compatible with ERC721 transferFrom.
|
|
147
|
+
* Using allowNonLSP1Recipient=true so that EOA and any contract may receive the tokenId.
|
|
148
|
+
*/
|
|
149
|
+
function transferFrom(
|
|
150
|
+
address from,
|
|
151
|
+
address to,
|
|
152
|
+
uint256 tokenId
|
|
153
|
+
) public virtual {
|
|
154
|
+
_transfer(from, to, bytes32(tokenId), true, "");
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* @inheritdoc ILSP8CompatibleERC721
|
|
159
|
+
* @dev Compatible with ERC721 safeTransferFrom (without optional data).
|
|
160
|
+
* Using allowNonLSP1Recipient=false so that no EOA and only contracts supporting LSP1 interface may receive the tokenId.
|
|
161
|
+
*/
|
|
162
|
+
function safeTransferFrom(
|
|
163
|
+
address from,
|
|
164
|
+
address to,
|
|
165
|
+
uint256 tokenId
|
|
166
|
+
) public virtual {
|
|
167
|
+
_safeTransfer(from, to, tokenId, "");
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/*
|
|
171
|
+
* @dev Compatible with ERC721 safeTransferFrom (with optional data).
|
|
172
|
+
* Using allowNonLSP1Recipient=false so that no EOA and only contracts supporting LSP1 interface may receive the tokenId.
|
|
173
|
+
*/
|
|
174
|
+
function safeTransferFrom(
|
|
175
|
+
address from,
|
|
176
|
+
address to,
|
|
177
|
+
uint256 tokenId,
|
|
178
|
+
bytes memory data
|
|
179
|
+
) public virtual {
|
|
180
|
+
_safeTransfer(from, to, tokenId, data);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// --- Overrides
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* @inheritdoc ILSP8IdentifiableDigitalAsset
|
|
187
|
+
*/
|
|
35
188
|
function authorizeOperator(address operator, bytes32 tokenId)
|
|
36
189
|
public
|
|
37
190
|
virtual
|
|
38
|
-
override(
|
|
191
|
+
override(ILSP8IdentifiableDigitalAsset, LSP8IdentifiableDigitalAssetCore)
|
|
39
192
|
{
|
|
40
193
|
super.authorizeOperator(operator, tokenId);
|
|
194
|
+
emit Approval(tokenOwnerOf(tokenId), operator, uint256(tokenId));
|
|
41
195
|
}
|
|
42
196
|
|
|
43
197
|
function _transfer(
|
|
44
198
|
address from,
|
|
45
199
|
address to,
|
|
46
200
|
bytes32 tokenId,
|
|
47
|
-
bool
|
|
201
|
+
bool allowNonLSP1Recipient,
|
|
48
202
|
bytes memory data
|
|
49
|
-
) internal virtual override
|
|
50
|
-
|
|
203
|
+
) internal virtual override {
|
|
204
|
+
address operator = msg.sender;
|
|
205
|
+
|
|
206
|
+
if (!isApprovedForAll(from, operator) && !_isOperatorOrOwner(operator, tokenId)) {
|
|
207
|
+
revert LSP8NotTokenOperator(tokenId, operator);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
super._transfer(from, to, tokenId, allowNonLSP1Recipient, data);
|
|
211
|
+
emit Transfer(from, to, uint256(tokenId));
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function _safeTransfer(
|
|
215
|
+
address from,
|
|
216
|
+
address to,
|
|
217
|
+
uint256 tokenId,
|
|
218
|
+
bytes memory data
|
|
219
|
+
) internal virtual {
|
|
220
|
+
_transfer(from, to, bytes32(tokenId), true, data);
|
|
221
|
+
require(
|
|
222
|
+
_checkOnERC721Received(from, to, tokenId, data),
|
|
223
|
+
"LSP8CompatibleERC721: transfer to non ERC721Receiver implementer"
|
|
224
|
+
);
|
|
51
225
|
}
|
|
52
226
|
|
|
53
227
|
function _mint(
|
|
54
228
|
address to,
|
|
55
229
|
bytes32 tokenId,
|
|
56
|
-
bool
|
|
230
|
+
bool allowNonLSP1Recipient,
|
|
57
231
|
bytes memory data
|
|
58
|
-
) internal virtual override
|
|
59
|
-
super._mint(to, tokenId,
|
|
232
|
+
) internal virtual override {
|
|
233
|
+
super._mint(to, tokenId, allowNonLSP1Recipient, data);
|
|
234
|
+
emit Transfer(address(0), to, uint256(tokenId));
|
|
60
235
|
}
|
|
61
236
|
|
|
62
|
-
function _burn(bytes32 tokenId, bytes memory data)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
override(LSP8IdentifiableDigitalAssetCore, LSP8CompatibleERC721Core)
|
|
66
|
-
{
|
|
237
|
+
function _burn(bytes32 tokenId, bytes memory data) internal virtual override {
|
|
238
|
+
address tokenOwner = tokenOwnerOf(tokenId);
|
|
239
|
+
|
|
67
240
|
super._burn(tokenId, data);
|
|
241
|
+
emit Transfer(tokenOwner, address(0), uint256(tokenId));
|
|
68
242
|
}
|
|
69
243
|
|
|
70
244
|
/**
|
|
71
|
-
* @dev
|
|
245
|
+
* @dev Approve `operator` to operate on all of `owner` tokens
|
|
246
|
+
*
|
|
247
|
+
* Emits an {ApprovalForAll} event.
|
|
72
248
|
*/
|
|
73
|
-
function
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
249
|
+
function _setApprovalForAll(
|
|
250
|
+
address tokensOwner,
|
|
251
|
+
address operator,
|
|
252
|
+
bool approved
|
|
253
|
+
) internal virtual {
|
|
254
|
+
require(tokensOwner != operator, "LSP8CompatibleERC721: approve to caller");
|
|
255
|
+
_operatorApprovals[tokensOwner][operator] = approved;
|
|
256
|
+
emit ApprovalForAll(tokensOwner, operator, approved);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
|
|
261
|
+
* The call is not executed if the target address is not a contract.
|
|
262
|
+
*
|
|
263
|
+
* @param from address representing the previous owner of the given token ID
|
|
264
|
+
* @param to target address that will receive the token
|
|
265
|
+
* @param tokenId uint256 ID of the token to be transferred
|
|
266
|
+
* @param data bytes optional data to send along with the call
|
|
267
|
+
* @return bool whether the call correctly returned the expected magic value
|
|
268
|
+
*/
|
|
269
|
+
function _checkOnERC721Received(
|
|
270
|
+
address from,
|
|
271
|
+
address to,
|
|
272
|
+
uint256 tokenId,
|
|
273
|
+
bytes memory data
|
|
274
|
+
) private returns (bool) {
|
|
275
|
+
if (to.isContract()) {
|
|
276
|
+
try IERC721Receiver(to).onERC721Received(msg.sender, from, tokenId, data) returns (
|
|
277
|
+
bytes4 retval
|
|
278
|
+
) {
|
|
279
|
+
return retval == IERC721Receiver.onERC721Received.selector;
|
|
280
|
+
} catch (bytes memory reason) {
|
|
281
|
+
if (reason.length == 0) {
|
|
282
|
+
revert("LSP8CompatibleERC721: transfer to non ERC721Receiver implementer");
|
|
283
|
+
} else {
|
|
284
|
+
// solhint-disable no-inline-assembly
|
|
285
|
+
/// @solidity memory-safe-assembly
|
|
286
|
+
assembly {
|
|
287
|
+
revert(add(32, reason), mload(reason))
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
} else {
|
|
292
|
+
return true;
|
|
293
|
+
}
|
|
84
294
|
}
|
|
85
295
|
|
|
86
296
|
function _setData(bytes32 key, bytes memory value)
|