@lukso/lsp-smart-contracts 0.8.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 +8 -0
- package/README.md +21 -21
- package/artifacts/LSP0ERC725Account.json +2 -2
- package/artifacts/LSP0ERC725AccountInit.json +2 -2
- package/artifacts/LSP11BasicSocialRecovery.json +2 -2
- package/artifacts/LSP11BasicSocialRecoveryInit.json +2 -2
- package/artifacts/LSP1UniversalReceiverDelegateUP.json +2 -2
- package/artifacts/LSP1UniversalReceiverDelegateVault.json +2 -2
- package/artifacts/LSP6KeyManager.json +2 -2
- package/artifacts/LSP6KeyManagerInit.json +2 -2
- package/artifacts/LSP7CappedSupply.json +5 -0
- package/artifacts/LSP7CappedSupplyInitAbstract.json +5 -0
- package/artifacts/LSP7CompatibleERC20.json +5 -0
- package/artifacts/LSP7CompatibleERC20InitAbstract.json +5 -0
- package/artifacts/LSP7CompatibleERC20Mintable.json +7 -2
- package/artifacts/LSP7CompatibleERC20MintableInit.json +7 -2
- package/artifacts/LSP7DigitalAsset.json +5 -0
- package/artifacts/LSP7DigitalAssetInitAbstract.json +5 -0
- package/artifacts/LSP7Mintable.json +7 -2
- package/artifacts/LSP7MintableInit.json +7 -2
- package/artifacts/LSP8CappedSupply.json +5 -0
- package/artifacts/LSP8CappedSupplyInitAbstract.json +5 -0
- package/artifacts/LSP8CompatibleERC721.json +5 -0
- package/artifacts/LSP8CompatibleERC721InitAbstract.json +5 -0
- package/artifacts/LSP8CompatibleERC721Mintable.json +7 -2
- package/artifacts/LSP8CompatibleERC721MintableInit.json +7 -2
- package/artifacts/LSP8IdentifiableDigitalAsset.json +5 -0
- package/artifacts/LSP8IdentifiableDigitalAssetInitAbstract.json +5 -0
- package/artifacts/LSP8Mintable.json +7 -2
- package/artifacts/LSP8MintableInit.json +7 -2
- package/artifacts/LSP9Vault.json +2 -2
- package/artifacts/LSP9VaultInit.json +2 -2
- package/artifacts/UniversalProfile.json +2 -2
- package/artifacts/UniversalProfileInit.json +2 -2
- package/common/constants.d.ts +738 -0
- package/common/constants.js +785 -0
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +87 -28
- package/contracts/LSP0ERC725Account/LSP0Utils.sol +50 -0
- package/contracts/LSP10ReceivedVaults/LSP10Utils.sol +3 -5
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +2 -4
- package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +7 -7
- package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +44 -734
- 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 +31 -1
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +2 -6
- package/contracts/LSP7DigitalAsset/LSP7Errors.sol +5 -0
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol +5 -0
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +7 -13
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +1 -3
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +1 -3
- package/contracts/LSP9Vault/LSP9VaultCore.sol +85 -25
- package/module/constants.d.ts +738 -0
- package/module/constants.js +782 -0
- package/package.json +26 -4
- package/constants.js +0 -856
|
@@ -50,3 +50,8 @@ error LSP7NotifyTokenReceiverContractMissingLSP1Interface(address tokenReceiver)
|
|
|
50
50
|
* when minting or transferring tokens with `bool allowNonLSP1Recipient` set as `false`.
|
|
51
51
|
*/
|
|
52
52
|
error LSP7NotifyTokenReceiverIsEOA(address tokenReceiver);
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @dev reverts when trying to authorize or revoke the token's owner as an operator.
|
|
56
|
+
*/
|
|
57
|
+
error LSP7TokenOwnerCannotBeOperator();
|
|
@@ -64,3 +64,8 @@ error LSP8NotifyTokenReceiverContractMissingLSP1Interface(address tokenReceiver)
|
|
|
64
64
|
* when minting or transferring tokens with `bool allowNonLSP1Recipient` set as `false`.
|
|
65
65
|
*/
|
|
66
66
|
error LSP8NotifyTokenReceiverIsEOA(address tokenReceiver);
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @dev reverts when trying to authorize or revoke the token's owner as an operator.
|
|
70
|
+
*/
|
|
71
|
+
error LSP8TokenOwnerCannotBeOperator();
|
|
@@ -6,7 +6,6 @@ import {ILSP1UniversalReceiver} from "../LSP1UniversalReceiver/ILSP1UniversalRec
|
|
|
6
6
|
import {ILSP8IdentifiableDigitalAsset} from "./ILSP8IdentifiableDigitalAsset.sol";
|
|
7
7
|
|
|
8
8
|
// libraries
|
|
9
|
-
import {Address} from "@openzeppelin/contracts/utils/Address.sol";
|
|
10
9
|
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
|
11
10
|
import {ERC165Checker} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
|
|
12
11
|
import {GasLib} from "../Utils/GasLib.sol";
|
|
@@ -30,7 +29,6 @@ import {_TYPEID_LSP8_TOKENSSENDER, _TYPEID_LSP8_TOKENSRECIPIENT} from "./LSP8Con
|
|
|
30
29
|
abstract contract LSP8IdentifiableDigitalAssetCore is ILSP8IdentifiableDigitalAsset {
|
|
31
30
|
using EnumerableSet for EnumerableSet.AddressSet;
|
|
32
31
|
using EnumerableSet for EnumerableSet.Bytes32Set;
|
|
33
|
-
using Address for address;
|
|
34
32
|
|
|
35
33
|
// --- Storage
|
|
36
34
|
|
|
@@ -92,19 +90,17 @@ abstract contract LSP8IdentifiableDigitalAssetCore is ILSP8IdentifiableDigitalAs
|
|
|
92
90
|
*/
|
|
93
91
|
function authorizeOperator(address operator, bytes32 tokenId) public virtual {
|
|
94
92
|
address tokenOwner = tokenOwnerOf(tokenId);
|
|
95
|
-
address caller = msg.sender;
|
|
96
93
|
|
|
97
|
-
if (tokenOwner !=
|
|
98
|
-
revert LSP8NotTokenOwner(tokenOwner, tokenId,
|
|
94
|
+
if (tokenOwner != msg.sender) {
|
|
95
|
+
revert LSP8NotTokenOwner(tokenOwner, tokenId, msg.sender);
|
|
99
96
|
}
|
|
100
97
|
|
|
101
98
|
if (operator == address(0)) {
|
|
102
99
|
revert LSP8CannotUseAddressZeroAsOperator();
|
|
103
100
|
}
|
|
104
101
|
|
|
105
|
-
// tokenOwner is always their own operator, no update required
|
|
106
102
|
if (tokenOwner == operator) {
|
|
107
|
-
|
|
103
|
+
revert LSP8TokenOwnerCannotBeOperator();
|
|
108
104
|
}
|
|
109
105
|
|
|
110
106
|
bool isAdded = _operators[tokenId].add(operator);
|
|
@@ -118,19 +114,17 @@ abstract contract LSP8IdentifiableDigitalAssetCore is ILSP8IdentifiableDigitalAs
|
|
|
118
114
|
*/
|
|
119
115
|
function revokeOperator(address operator, bytes32 tokenId) public virtual {
|
|
120
116
|
address tokenOwner = tokenOwnerOf(tokenId);
|
|
121
|
-
address caller = msg.sender;
|
|
122
117
|
|
|
123
|
-
if (tokenOwner !=
|
|
124
|
-
revert LSP8NotTokenOwner(tokenOwner, tokenId,
|
|
118
|
+
if (tokenOwner != msg.sender) {
|
|
119
|
+
revert LSP8NotTokenOwner(tokenOwner, tokenId, msg.sender);
|
|
125
120
|
}
|
|
126
121
|
|
|
127
122
|
if (operator == address(0)) {
|
|
128
123
|
revert LSP8CannotUseAddressZeroAsOperator();
|
|
129
124
|
}
|
|
130
125
|
|
|
131
|
-
// tokenOwner is always their own operator, no update required
|
|
132
126
|
if (tokenOwner == operator) {
|
|
133
|
-
|
|
127
|
+
revert LSP8TokenOwnerCannotBeOperator();
|
|
134
128
|
}
|
|
135
129
|
|
|
136
130
|
_revokeOperator(operator, tokenOwner, tokenId);
|
|
@@ -431,7 +425,7 @@ abstract contract LSP8IdentifiableDigitalAssetCore is ILSP8IdentifiableDigitalAs
|
|
|
431
425
|
bytes memory packedData = abi.encodePacked(from, to, tokenId, data);
|
|
432
426
|
ILSP1UniversalReceiver(to).universalReceiver(_TYPEID_LSP8_TOKENSRECIPIENT, packedData);
|
|
433
427
|
} else if (!allowNonLSP1Recipient) {
|
|
434
|
-
if (to.
|
|
428
|
+
if (to.code.length > 0) {
|
|
435
429
|
revert LSP8NotifyTokenReceiverContractMissingLSP1Interface(to);
|
|
436
430
|
} else {
|
|
437
431
|
revert LSP8NotifyTokenReceiverIsEOA(to);
|
|
@@ -8,7 +8,6 @@ import {ILSP8CompatibleERC721} from "./ILSP8CompatibleERC721.sol";
|
|
|
8
8
|
import {ILSP8IdentifiableDigitalAsset} from "../ILSP8IdentifiableDigitalAsset.sol";
|
|
9
9
|
|
|
10
10
|
// libraries
|
|
11
|
-
import {Address} from "@openzeppelin/contracts/utils/Address.sol";
|
|
12
11
|
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
|
13
12
|
import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol";
|
|
14
13
|
|
|
@@ -36,7 +35,6 @@ abstract contract LSP8CompatibleERC721 is
|
|
|
36
35
|
LSP4Compatibility,
|
|
37
36
|
LSP8IdentifiableDigitalAsset
|
|
38
37
|
{
|
|
39
|
-
using Address for address;
|
|
40
38
|
using EnumerableSet for EnumerableSet.AddressSet;
|
|
41
39
|
|
|
42
40
|
/**
|
|
@@ -276,7 +274,7 @@ abstract contract LSP8CompatibleERC721 is
|
|
|
276
274
|
uint256 tokenId,
|
|
277
275
|
bytes memory data
|
|
278
276
|
) private returns (bool) {
|
|
279
|
-
if (to.
|
|
277
|
+
if (to.code.length > 0) {
|
|
280
278
|
try IERC721Receiver(to).onERC721Received(msg.sender, from, tokenId, data) returns (
|
|
281
279
|
bytes4 retval
|
|
282
280
|
) {
|
package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol
CHANGED
|
@@ -8,7 +8,6 @@ import {ILSP8CompatibleERC721} from "./ILSP8CompatibleERC721.sol";
|
|
|
8
8
|
import {ILSP8IdentifiableDigitalAsset} from "../ILSP8IdentifiableDigitalAsset.sol";
|
|
9
9
|
|
|
10
10
|
// libraries
|
|
11
|
-
import {Address} from "@openzeppelin/contracts/utils/Address.sol";
|
|
12
11
|
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
|
13
12
|
import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol";
|
|
14
13
|
|
|
@@ -36,7 +35,6 @@ abstract contract LSP8CompatibleERC721InitAbstract is
|
|
|
36
35
|
LSP8IdentifiableDigitalAssetInitAbstract,
|
|
37
36
|
LSP4Compatibility
|
|
38
37
|
{
|
|
39
|
-
using Address for address;
|
|
40
38
|
using EnumerableSet for EnumerableSet.AddressSet;
|
|
41
39
|
|
|
42
40
|
/**
|
|
@@ -272,7 +270,7 @@ abstract contract LSP8CompatibleERC721InitAbstract is
|
|
|
272
270
|
uint256 tokenId,
|
|
273
271
|
bytes memory data
|
|
274
272
|
) private returns (bool) {
|
|
275
|
-
if (to.
|
|
273
|
+
if (to.code.length > 0) {
|
|
276
274
|
try IERC721Receiver(to).onERC721Received(msg.sender, from, tokenId, data) returns (
|
|
277
275
|
bytes4 retval
|
|
278
276
|
) {
|
|
@@ -46,6 +46,7 @@ import {_LSP17_EXTENSION_PREFIX} from "../LSP17ContractExtension/LSP17Constants.
|
|
|
46
46
|
|
|
47
47
|
// errors
|
|
48
48
|
import "./LSP9Errors.sol";
|
|
49
|
+
import "../LSP17ContractExtension/LSP17Errors.sol";
|
|
49
50
|
|
|
50
51
|
/**
|
|
51
52
|
* @title Core Implementation of LSP9Vault built on top of ERC725, LSP1UniversalReceiver
|
|
@@ -74,12 +75,95 @@ contract LSP9VaultCore is
|
|
|
74
75
|
/**
|
|
75
76
|
* @dev Emits an event when receiving native tokens
|
|
76
77
|
*
|
|
77
|
-
* Executed
|
|
78
|
+
* Executed:
|
|
79
|
+
* - when receiving some native tokens without any additional data.
|
|
80
|
+
* - on empty calls to the contract.
|
|
78
81
|
*/
|
|
79
82
|
receive() external payable virtual {
|
|
80
83
|
if (msg.value > 0) emit ValueReceived(msg.sender, msg.value);
|
|
81
84
|
}
|
|
82
85
|
|
|
86
|
+
// solhint-disable no-complex-fallback
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @dev Emits an event when receiving native tokens
|
|
90
|
+
*
|
|
91
|
+
* Forwards the call to an extension contract (address). This address can be retrieved from
|
|
92
|
+
* the ERC725Y data key-value store using the data key below (function selector appended to the prefix):
|
|
93
|
+
*_LSP17_FALLBACK_EXTENSIONS_HANDLER_ + <function-selector>
|
|
94
|
+
* If there is no extension stored under the data key, return.
|
|
95
|
+
*
|
|
96
|
+
* The call to the extension is appended with bytes20 (msg.sender) and bytes32 (msg.value).
|
|
97
|
+
* Returns the return value on success and revert in case of failure.
|
|
98
|
+
*
|
|
99
|
+
* If the msg.data is shorter than 4 bytes do not check for an extension and return
|
|
100
|
+
*
|
|
101
|
+
* Executed when:
|
|
102
|
+
* - the first 4 bytes of the calldata do not match any publicly callable functions from the contract ABI.
|
|
103
|
+
* - receiving native tokens with some calldata.
|
|
104
|
+
*/
|
|
105
|
+
fallback() external payable virtual {
|
|
106
|
+
if (msg.value != 0) emit ValueReceived(msg.sender, msg.value);
|
|
107
|
+
if (msg.data.length < 4) return;
|
|
108
|
+
|
|
109
|
+
_fallbackLSP17Extendable();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* @dev Forwards the call to an extension mapped to a function selector. If no extension address
|
|
114
|
+
* is mapped to the function selector (address(0)), then revert.
|
|
115
|
+
*
|
|
116
|
+
* The bytes4(0) msg.sig is an exception, the function won't revert if there is no extension found
|
|
117
|
+
* mapped to bytes4(0), but will execute the call to the extension in case it existed.
|
|
118
|
+
*
|
|
119
|
+
* The call to the extension is appended with bytes20 (msg.sender) and bytes32 (msg.value).
|
|
120
|
+
* Returns the return value on success and revert in case of failure.
|
|
121
|
+
*
|
|
122
|
+
* Because the function uses assembly {return()/revert()} to terminate the call, it cannot be
|
|
123
|
+
* called before other codes in fallback().
|
|
124
|
+
*
|
|
125
|
+
* Otherwise, the codes after _fallbackLSP17Extendable() may never be reached.
|
|
126
|
+
*/
|
|
127
|
+
function _fallbackLSP17Extendable() internal virtual override {
|
|
128
|
+
// If there is a function selector
|
|
129
|
+
address extension = _getExtension(msg.sig);
|
|
130
|
+
|
|
131
|
+
// if no extension was found for bytes4(0) return don't revert
|
|
132
|
+
if (msg.sig == bytes4(0) && extension == address(0)) return;
|
|
133
|
+
|
|
134
|
+
// if no extension was found, revert
|
|
135
|
+
if (extension == address(0)) revert NoExtensionFoundForFunctionSelector(msg.sig);
|
|
136
|
+
|
|
137
|
+
// solhint-disable no-inline-assembly
|
|
138
|
+
// if the extension was found, call the extension with the msg.data
|
|
139
|
+
// appended with bytes20(address) and bytes32(msg.value)
|
|
140
|
+
assembly {
|
|
141
|
+
calldatacopy(0, 0, calldatasize())
|
|
142
|
+
|
|
143
|
+
// The msg.sender address is shifted to the left by 12 bytes to remove the padding
|
|
144
|
+
// Then the address without padding is stored right after the calldata
|
|
145
|
+
mstore(calldatasize(), shl(96, caller()))
|
|
146
|
+
|
|
147
|
+
// The msg.value is stored right after the calldata + msg.sender
|
|
148
|
+
mstore(add(calldatasize(), 20), callvalue())
|
|
149
|
+
|
|
150
|
+
// Add 52 bytes for the msg.sender and msg.value appended at the end of the calldata
|
|
151
|
+
let success := call(gas(), extension, 0, 0, add(calldatasize(), 52), 0, 0)
|
|
152
|
+
|
|
153
|
+
// Copy the returned data
|
|
154
|
+
returndatacopy(0, 0, returndatasize())
|
|
155
|
+
|
|
156
|
+
switch success
|
|
157
|
+
// call returns 0 on failed calls
|
|
158
|
+
case 0 {
|
|
159
|
+
revert(0, returndatasize())
|
|
160
|
+
}
|
|
161
|
+
default {
|
|
162
|
+
return(0, returndatasize())
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
83
167
|
/**
|
|
84
168
|
* @dev Returns the extension stored under the `_LSP17_EXTENSION_PREFIX` data key
|
|
85
169
|
* mapped to the functionSelector provided.
|
|
@@ -104,30 +188,6 @@ contract LSP9VaultCore is
|
|
|
104
188
|
return extension;
|
|
105
189
|
}
|
|
106
190
|
|
|
107
|
-
// solhint-disable no-complex-fallback
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* @dev Emits an event when receiving native tokens
|
|
111
|
-
*
|
|
112
|
-
* Forwards the call to an extension (address) stored under a _LSP17_FALLBACK_EXTENSIONS_HANDLER_ appended
|
|
113
|
-
* to a function selector. If there is no extension stored under the data key, return.
|
|
114
|
-
*
|
|
115
|
-
* The call to the extension is appended with bytes20 (msg.sender) and bytes32 (msg.value).
|
|
116
|
-
* Returns the return value on success and revert in case of failure.
|
|
117
|
-
*
|
|
118
|
-
* If the msg.data is shorter than 4 bytes or the first 4 bytes are 0s
|
|
119
|
-
* do not check for an extension and return
|
|
120
|
-
*
|
|
121
|
-
* Executed when:
|
|
122
|
-
* - the first 4 bytes of the calldata do not match any publicly callable functions from the contract ABI.
|
|
123
|
-
* - receiving native tokens with some calldata.
|
|
124
|
-
*/
|
|
125
|
-
fallback() external payable virtual {
|
|
126
|
-
if (msg.value != 0) emit ValueReceived(msg.sender, msg.value);
|
|
127
|
-
if (msg.data.length < 4 || msg.sig == bytes4(0)) return;
|
|
128
|
-
_fallbackLSP17Extendable();
|
|
129
|
-
}
|
|
130
|
-
|
|
131
191
|
/**
|
|
132
192
|
* @dev Returns true if this contract implements the interface defined by
|
|
133
193
|
* `interfaceId`.
|