@lukso/lsp7-contracts 0.16.8 → 0.17.3
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/LICENSE +201 -0
- package/README.md +55 -5
- package/artifacts/IAccessControlExtended.json +285 -0
- package/artifacts/ILSP7CappedBalance.json +27 -0
- package/artifacts/ILSP7CappedSupply.json +27 -0
- package/artifacts/ILSP7DigitalAsset.json +6 -3
- package/artifacts/ILSP7Mintable.json +62 -0
- package/artifacts/ILSP7NonTransferable.json +110 -0
- package/artifacts/ILSP7Revokable.json +75 -0
- package/artifacts/LSP7Burnable.json +7 -4
- package/artifacts/LSP7BurnableInitAbstract.json +7 -4
- package/artifacts/LSP7CappedBalanceAbstract.json +1159 -0
- package/artifacts/LSP7CappedBalanceInitAbstract.json +1167 -0
- package/artifacts/{LSP7CappedSupply.json → LSP7CappedSupplyAbstract.json} +8 -15
- package/artifacts/LSP7CappedSupplyInitAbstract.json +7 -14
- package/artifacts/LSP7CustomizableToken.json +1604 -0
- package/artifacts/LSP7CustomizableTokenInit.json +1601 -0
- package/artifacts/LSP7DigitalAsset.json +6 -3
- package/artifacts/LSP7DigitalAssetInitAbstract.json +6 -3
- package/artifacts/LSP7Mintable.json +376 -5
- package/artifacts/LSP7MintableAbstract.json +1186 -0
- package/artifacts/LSP7MintableInit.json +369 -5
- package/artifacts/LSP7MintableInitAbstract.json +1194 -0
- package/artifacts/LSP7NonTransferableAbstract.json +1236 -0
- package/artifacts/LSP7NonTransferableInitAbstract.json +1244 -0
- package/artifacts/LSP7RevokableAbstract.json +1186 -0
- package/artifacts/LSP7RevokableInitAbstract.json +1194 -0
- package/artifacts/LSP7Votes.json +66 -4
- package/artifacts/LSP7VotesInitAbstract.json +66 -4
- package/contracts/LSP7DigitalAsset.sol +56 -65
- package/contracts/LSP7DigitalAssetInitAbstract.sol +49 -71
- package/contracts/extensions/AccessControlExtended/AccessControlExtendedAbstract.sol +368 -0
- package/contracts/extensions/AccessControlExtended/AccessControlExtendedConstants.sol +13 -0
- package/contracts/extensions/AccessControlExtended/AccessControlExtendedErrors.sol +23 -0
- package/contracts/extensions/AccessControlExtended/AccessControlExtendedInitAbstract.sol +389 -0
- package/contracts/extensions/AccessControlExtended/IAccessControlExtended.sol +51 -0
- package/contracts/extensions/{LSP7Burnable.sol → LSP7Burnable/LSP7Burnable.sol} +2 -2
- package/contracts/extensions/{LSP7BurnableInitAbstract.sol → LSP7Burnable/LSP7BurnableInitAbstract.sol} +2 -4
- package/contracts/extensions/LSP7CappedBalance/ILSP7CappedBalance.sol +11 -0
- package/contracts/extensions/LSP7CappedBalance/LSP7CappedBalanceAbstract.sol +129 -0
- package/contracts/extensions/LSP7CappedBalance/LSP7CappedBalanceErrors.sol +10 -0
- package/contracts/extensions/LSP7CappedBalance/LSP7CappedBalanceInitAbstract.sol +179 -0
- package/contracts/extensions/LSP7CappedSupply/ILSP7CappedSupply.sol +11 -0
- package/contracts/extensions/LSP7CappedSupply/LSP7CappedSupplyAbstract.sol +56 -0
- package/contracts/extensions/LSP7CappedSupply/LSP7CappedSupplyErrors.sol +6 -0
- package/contracts/extensions/LSP7CappedSupply/LSP7CappedSupplyInitAbstract.sol +96 -0
- package/contracts/extensions/LSP7Mintable/ILSP7Mintable.sol +27 -0
- package/contracts/extensions/LSP7Mintable/LSP7MintableAbstract.sol +105 -0
- package/contracts/extensions/LSP7Mintable/LSP7MintableErrors.sol +5 -0
- package/contracts/extensions/LSP7Mintable/LSP7MintableInitAbstract.sol +156 -0
- package/contracts/extensions/LSP7NonTransferable/ILSP7NonTransferable.sol +48 -0
- package/contracts/extensions/LSP7NonTransferable/LSP7NonTransferableAbstract.sol +183 -0
- package/contracts/extensions/LSP7NonTransferable/LSP7NonTransferableErrors.sol +14 -0
- package/contracts/extensions/LSP7NonTransferable/LSP7NonTransferableInitAbstract.sol +240 -0
- package/contracts/extensions/LSP7Revokable/ILSP7Revokable.sol +28 -0
- package/contracts/extensions/LSP7Revokable/LSP7RevokableAbstract.sol +130 -0
- package/contracts/extensions/LSP7Revokable/LSP7RevokableErrors.sol +4 -0
- package/contracts/extensions/LSP7Revokable/LSP7RevokableInitAbstract.sol +183 -0
- package/contracts/extensions/{LSP7Votes.sol → LSP7Votes/LSP7Votes.sol} +37 -20
- package/contracts/extensions/LSP7Votes/LSP7VotesErrors.sol +24 -0
- package/contracts/extensions/{LSP7VotesInitAbstract.sol → LSP7Votes/LSP7VotesInitAbstract.sol} +37 -21
- package/contracts/presets/LSP7CustomizableToken.sol +262 -0
- package/contracts/presets/LSP7CustomizableTokenConstants.sol +32 -0
- package/contracts/presets/LSP7CustomizableTokenInit.sol +294 -0
- package/contracts/presets/LSP7Mintable.sol +14 -23
- package/contracts/presets/LSP7MintableInit.sol +16 -11
- package/dist/abi.cjs +7519 -54
- package/dist/abi.d.cts +11109 -338
- package/dist/abi.d.mts +11109 -338
- package/dist/abi.d.ts +11109 -338
- package/dist/abi.mjs +7503 -54
- package/dist/constants.cjs +21 -0
- package/dist/constants.d.cts +12 -1
- package/dist/constants.d.mts +12 -1
- package/dist/constants.d.ts +12 -1
- package/dist/constants.mjs +16 -1
- package/package.json +33 -9
- package/contracts/extensions/LSP7CappedSupply.sol +0 -83
- package/contracts/extensions/LSP7CappedSupplyInitAbstract.sol +0 -86
- package/contracts/presets/ILSP7Mintable.sol +0 -32
- package/contracts/presets/LSP7MintableInitAbstract.sol +0 -57
- /package/contracts/extensions/{LSP7VotesConstants.sol → LSP7Votes/LSP7VotesConstants.sol} +0 -0
package/artifacts/LSP7Votes.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"_format": "
|
|
2
|
+
"_format": "hh3-artifact-1",
|
|
3
3
|
"contractName": "LSP7Votes",
|
|
4
|
-
"sourceName": "contracts/extensions/LSP7Votes.sol",
|
|
4
|
+
"sourceName": "contracts/extensions/LSP7Votes/LSP7Votes.sol",
|
|
5
5
|
"abi": [
|
|
6
6
|
{
|
|
7
7
|
"inputs": [],
|
|
@@ -212,6 +212,65 @@
|
|
|
212
212
|
"name": "LSP7TokenOwnerCannotBeOperator",
|
|
213
213
|
"type": "error"
|
|
214
214
|
},
|
|
215
|
+
{
|
|
216
|
+
"inputs": [],
|
|
217
|
+
"name": "LSP7VotesBrokenClockMode",
|
|
218
|
+
"type": "error"
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
"inputs": [
|
|
222
|
+
{
|
|
223
|
+
"internalType": "uint256",
|
|
224
|
+
"name": "supply",
|
|
225
|
+
"type": "uint256"
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
"internalType": "uint256",
|
|
229
|
+
"name": "cap",
|
|
230
|
+
"type": "uint256"
|
|
231
|
+
}
|
|
232
|
+
],
|
|
233
|
+
"name": "LSP7VotesExceededSafeSupply",
|
|
234
|
+
"type": "error"
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
"inputs": [
|
|
238
|
+
{
|
|
239
|
+
"internalType": "uint256",
|
|
240
|
+
"name": "timepoint",
|
|
241
|
+
"type": "uint256"
|
|
242
|
+
}
|
|
243
|
+
],
|
|
244
|
+
"name": "LSP7VotesFutureLookup",
|
|
245
|
+
"type": "error"
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
"inputs": [
|
|
249
|
+
{
|
|
250
|
+
"internalType": "address",
|
|
251
|
+
"name": "signer",
|
|
252
|
+
"type": "address"
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
"internalType": "uint256",
|
|
256
|
+
"name": "nonce",
|
|
257
|
+
"type": "uint256"
|
|
258
|
+
}
|
|
259
|
+
],
|
|
260
|
+
"name": "LSP7VotesInvalidNonce",
|
|
261
|
+
"type": "error"
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
"inputs": [
|
|
265
|
+
{
|
|
266
|
+
"internalType": "uint256",
|
|
267
|
+
"name": "expiry",
|
|
268
|
+
"type": "uint256"
|
|
269
|
+
}
|
|
270
|
+
],
|
|
271
|
+
"name": "LSP7VotesSignatureExpired",
|
|
272
|
+
"type": "error"
|
|
273
|
+
},
|
|
215
274
|
{
|
|
216
275
|
"inputs": [
|
|
217
276
|
{
|
|
@@ -1150,5 +1209,8 @@
|
|
|
1150
1209
|
"bytecode": "0x",
|
|
1151
1210
|
"deployedBytecode": "0x",
|
|
1152
1211
|
"linkReferences": {},
|
|
1153
|
-
"deployedLinkReferences": {}
|
|
1154
|
-
}
|
|
1212
|
+
"deployedLinkReferences": {},
|
|
1213
|
+
"immutableReferences": {},
|
|
1214
|
+
"inputSourceName": "project/contracts/extensions/LSP7Votes/LSP7Votes.sol",
|
|
1215
|
+
"buildInfoId": "solc-0_8_28-02f211569dac97f8d48f774b05c17d2fd78020fb"
|
|
1216
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"_format": "
|
|
2
|
+
"_format": "hh3-artifact-1",
|
|
3
3
|
"contractName": "LSP7VotesInitAbstract",
|
|
4
|
-
"sourceName": "contracts/extensions/LSP7VotesInitAbstract.sol",
|
|
4
|
+
"sourceName": "contracts/extensions/LSP7Votes/LSP7VotesInitAbstract.sol",
|
|
5
5
|
"abi": [
|
|
6
6
|
{
|
|
7
7
|
"inputs": [],
|
|
@@ -207,6 +207,65 @@
|
|
|
207
207
|
"name": "LSP7TokenOwnerCannotBeOperator",
|
|
208
208
|
"type": "error"
|
|
209
209
|
},
|
|
210
|
+
{
|
|
211
|
+
"inputs": [],
|
|
212
|
+
"name": "LSP7VotesBrokenClockMode",
|
|
213
|
+
"type": "error"
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
"inputs": [
|
|
217
|
+
{
|
|
218
|
+
"internalType": "uint256",
|
|
219
|
+
"name": "supply",
|
|
220
|
+
"type": "uint256"
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
"internalType": "uint256",
|
|
224
|
+
"name": "cap",
|
|
225
|
+
"type": "uint256"
|
|
226
|
+
}
|
|
227
|
+
],
|
|
228
|
+
"name": "LSP7VotesExceededSafeSupply",
|
|
229
|
+
"type": "error"
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
"inputs": [
|
|
233
|
+
{
|
|
234
|
+
"internalType": "uint256",
|
|
235
|
+
"name": "timepoint",
|
|
236
|
+
"type": "uint256"
|
|
237
|
+
}
|
|
238
|
+
],
|
|
239
|
+
"name": "LSP7VotesFutureLookup",
|
|
240
|
+
"type": "error"
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
"inputs": [
|
|
244
|
+
{
|
|
245
|
+
"internalType": "address",
|
|
246
|
+
"name": "signer",
|
|
247
|
+
"type": "address"
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
"internalType": "uint256",
|
|
251
|
+
"name": "nonce",
|
|
252
|
+
"type": "uint256"
|
|
253
|
+
}
|
|
254
|
+
],
|
|
255
|
+
"name": "LSP7VotesInvalidNonce",
|
|
256
|
+
"type": "error"
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
"inputs": [
|
|
260
|
+
{
|
|
261
|
+
"internalType": "uint256",
|
|
262
|
+
"name": "expiry",
|
|
263
|
+
"type": "uint256"
|
|
264
|
+
}
|
|
265
|
+
],
|
|
266
|
+
"name": "LSP7VotesSignatureExpired",
|
|
267
|
+
"type": "error"
|
|
268
|
+
},
|
|
210
269
|
{
|
|
211
270
|
"inputs": [
|
|
212
271
|
{
|
|
@@ -1142,5 +1201,8 @@
|
|
|
1142
1201
|
"bytecode": "0x",
|
|
1143
1202
|
"deployedBytecode": "0x",
|
|
1144
1203
|
"linkReferences": {},
|
|
1145
|
-
"deployedLinkReferences": {}
|
|
1146
|
-
}
|
|
1204
|
+
"deployedLinkReferences": {},
|
|
1205
|
+
"immutableReferences": {},
|
|
1206
|
+
"inputSourceName": "project/contracts/extensions/LSP7Votes/LSP7VotesInitAbstract.sol",
|
|
1207
|
+
"buildInfoId": "solc-0_8_28-02f211569dac97f8d48f774b05c17d2fd78020fb"
|
|
1208
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
pragma solidity ^0.8.
|
|
2
|
+
pragma solidity ^0.8.27;
|
|
3
3
|
|
|
4
4
|
// interfaces
|
|
5
5
|
import {
|
|
@@ -8,12 +8,6 @@ import {
|
|
|
8
8
|
import {ILSP7DigitalAsset} from "./ILSP7DigitalAsset.sol";
|
|
9
9
|
|
|
10
10
|
// modules
|
|
11
|
-
import {
|
|
12
|
-
EnumerableSet
|
|
13
|
-
} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
|
14
|
-
import {
|
|
15
|
-
ERC165Checker
|
|
16
|
-
} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
|
|
17
11
|
import {
|
|
18
12
|
LSP4DigitalAssetMetadata,
|
|
19
13
|
ERC725Y
|
|
@@ -23,6 +17,12 @@ import {
|
|
|
23
17
|
} from "@lukso/lsp17contractextension-contracts/contracts/LSP17Extendable.sol";
|
|
24
18
|
|
|
25
19
|
// libraries
|
|
20
|
+
import {
|
|
21
|
+
EnumerableSet
|
|
22
|
+
} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
|
23
|
+
import {
|
|
24
|
+
ERC165Checker
|
|
25
|
+
} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
|
|
26
26
|
import {LSP1Utils} from "@lukso/lsp1-contracts/contracts/LSP1Utils.sol";
|
|
27
27
|
import {LSP2Utils} from "@lukso/lsp2-contracts/contracts/LSP2Utils.sol";
|
|
28
28
|
|
|
@@ -76,7 +76,7 @@ abstract contract LSP7DigitalAsset is
|
|
|
76
76
|
|
|
77
77
|
// --- Storage
|
|
78
78
|
|
|
79
|
-
bool internal
|
|
79
|
+
bool internal immutable _IS_NON_DIVISIBLE;
|
|
80
80
|
|
|
81
81
|
uint256 internal _existingTokens;
|
|
82
82
|
|
|
@@ -105,7 +105,7 @@ abstract contract LSP7DigitalAsset is
|
|
|
105
105
|
uint256 lsp4TokenType_,
|
|
106
106
|
bool isNonDivisible_
|
|
107
107
|
) LSP4DigitalAssetMetadata(name_, symbol_, newOwner_, lsp4TokenType_) {
|
|
108
|
-
|
|
108
|
+
_IS_NON_DIVISIBLE = isNonDivisible_;
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
// fallback functions
|
|
@@ -133,9 +133,7 @@ abstract contract LSP7DigitalAsset is
|
|
|
133
133
|
fallback(
|
|
134
134
|
bytes calldata callData
|
|
135
135
|
) external payable virtual returns (bytes memory) {
|
|
136
|
-
|
|
137
|
-
revert InvalidFunctionSelector(callData);
|
|
138
|
-
}
|
|
136
|
+
require(msg.data.length >= 4, InvalidFunctionSelector(callData));
|
|
139
137
|
return _fallbackLSP17Extendable(callData);
|
|
140
138
|
}
|
|
141
139
|
|
|
@@ -176,8 +174,10 @@ abstract contract LSP7DigitalAsset is
|
|
|
176
174
|
(address extension, ) = _getExtensionAndForwardValue(msg.sig);
|
|
177
175
|
|
|
178
176
|
// if no extension was found, revert
|
|
179
|
-
|
|
180
|
-
|
|
177
|
+
require(
|
|
178
|
+
extension != address(0),
|
|
179
|
+
NoExtensionFoundForFunctionSelector(msg.sig)
|
|
180
|
+
);
|
|
181
181
|
|
|
182
182
|
(bool success, bytes memory result) = extension.call{value: msg.value}(
|
|
183
183
|
abi.encodePacked(callData, msg.sender, msg.value)
|
|
@@ -214,8 +214,10 @@ abstract contract LSP7DigitalAsset is
|
|
|
214
214
|
|
|
215
215
|
// Check if there is an extension stored under the generated data key
|
|
216
216
|
bytes memory extensionAddress = _getData(mappedExtensionDataKey);
|
|
217
|
-
|
|
218
|
-
|
|
217
|
+
require(
|
|
218
|
+
extensionAddress.length == 20 || extensionAddress.length == 0,
|
|
219
|
+
InvalidExtensionAddress(extensionAddress)
|
|
220
|
+
);
|
|
219
221
|
|
|
220
222
|
return (address(bytes20(extensionAddress)), true);
|
|
221
223
|
}
|
|
@@ -238,7 +240,7 @@ abstract contract LSP7DigitalAsset is
|
|
|
238
240
|
* @inheritdoc ILSP7DigitalAsset
|
|
239
241
|
*/
|
|
240
242
|
function decimals() public view virtual override returns (uint8) {
|
|
241
|
-
return
|
|
243
|
+
return _IS_NON_DIVISIBLE ? 0 : 18;
|
|
242
244
|
}
|
|
243
245
|
|
|
244
246
|
/**
|
|
@@ -341,13 +343,10 @@ abstract contract LSP7DigitalAsset is
|
|
|
341
343
|
bool notify,
|
|
342
344
|
bytes memory operatorNotificationData
|
|
343
345
|
) public virtual override {
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
operator
|
|
349
|
-
);
|
|
350
|
-
}
|
|
346
|
+
require(
|
|
347
|
+
msg.sender == tokenOwner || msg.sender == operator,
|
|
348
|
+
LSP7RevokeOperatorNotAuthorized(msg.sender, tokenOwner, operator)
|
|
349
|
+
);
|
|
351
350
|
|
|
352
351
|
_updateOperator(
|
|
353
352
|
tokenOwner,
|
|
@@ -400,8 +399,10 @@ abstract contract LSP7DigitalAsset is
|
|
|
400
399
|
bytes memory operatorNotificationData
|
|
401
400
|
) public virtual override {
|
|
402
401
|
uint256 oldAllowance = authorizedAmountFor(operator, msg.sender);
|
|
403
|
-
|
|
404
|
-
|
|
402
|
+
require(
|
|
403
|
+
oldAllowance > 0,
|
|
404
|
+
OperatorAllowanceCannotBeIncreasedFromZero(operator)
|
|
405
|
+
);
|
|
405
406
|
|
|
406
407
|
uint256 newAllowance = oldAllowance + addedAmount;
|
|
407
408
|
|
|
@@ -431,18 +432,16 @@ abstract contract LSP7DigitalAsset is
|
|
|
431
432
|
uint256 subtractedAmount,
|
|
432
433
|
bytes memory operatorNotificationData
|
|
433
434
|
) public virtual override {
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
operator
|
|
439
|
-
);
|
|
440
|
-
}
|
|
435
|
+
require(
|
|
436
|
+
msg.sender == tokenOwner || msg.sender == operator,
|
|
437
|
+
LSP7DecreaseAllowanceNotAuthorized(msg.sender, tokenOwner, operator)
|
|
438
|
+
);
|
|
441
439
|
|
|
442
440
|
uint256 currentAllowance = authorizedAmountFor(operator, tokenOwner);
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
441
|
+
require(
|
|
442
|
+
currentAllowance >= subtractedAmount,
|
|
443
|
+
LSP7DecreasedAllowanceBelowZero()
|
|
444
|
+
);
|
|
446
445
|
|
|
447
446
|
uint256 newAllowance;
|
|
448
447
|
unchecked {
|
|
@@ -499,14 +498,13 @@ abstract contract LSP7DigitalAsset is
|
|
|
499
498
|
bytes[] memory data
|
|
500
499
|
) public virtual override {
|
|
501
500
|
uint256 fromLength = from.length;
|
|
502
|
-
|
|
503
|
-
fromLength
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
}
|
|
501
|
+
require(
|
|
502
|
+
fromLength == to.length &&
|
|
503
|
+
fromLength == amount.length &&
|
|
504
|
+
fromLength == force.length &&
|
|
505
|
+
fromLength == data.length,
|
|
506
|
+
LSP7InvalidTransferBatch()
|
|
507
|
+
);
|
|
510
508
|
|
|
511
509
|
for (uint256 i; i < fromLength; ) {
|
|
512
510
|
// using the public transfer function to handle updates to operator authorized amounts
|
|
@@ -544,13 +542,8 @@ abstract contract LSP7DigitalAsset is
|
|
|
544
542
|
bool notified,
|
|
545
543
|
bytes memory operatorNotificationData
|
|
546
544
|
) internal virtual {
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
if (operator == tokenOwner) {
|
|
552
|
-
revert LSP7TokenOwnerCannotBeOperator();
|
|
553
|
-
}
|
|
545
|
+
require(operator != address(0), LSP7CannotUseAddressZeroAsOperator());
|
|
546
|
+
require(operator != tokenOwner, LSP7TokenOwnerCannotBeOperator());
|
|
554
547
|
|
|
555
548
|
_operatorAuthorizedAmount[tokenOwner][operator] = allowance;
|
|
556
549
|
|
|
@@ -596,9 +589,7 @@ abstract contract LSP7DigitalAsset is
|
|
|
596
589
|
bool force,
|
|
597
590
|
bytes memory data
|
|
598
591
|
) internal virtual {
|
|
599
|
-
|
|
600
|
-
revert LSP7CannotSendWithAddressZero();
|
|
601
|
-
}
|
|
592
|
+
require(to != address(0), LSP7CannotSendWithAddressZero());
|
|
602
593
|
|
|
603
594
|
_beforeTokenTransfer(address(0), to, amount, force, data);
|
|
604
595
|
|
|
@@ -646,9 +637,7 @@ abstract contract LSP7DigitalAsset is
|
|
|
646
637
|
uint256 amount,
|
|
647
638
|
bytes memory data
|
|
648
639
|
) internal virtual {
|
|
649
|
-
|
|
650
|
-
revert LSP7CannotSendWithAddressZero();
|
|
651
|
-
}
|
|
640
|
+
require(from != address(0), LSP7CannotSendWithAddressZero());
|
|
652
641
|
|
|
653
642
|
_beforeTokenTransfer(from, address(0), amount, false, data);
|
|
654
643
|
|
|
@@ -741,9 +730,10 @@ abstract contract LSP7DigitalAsset is
|
|
|
741
730
|
bool force,
|
|
742
731
|
bytes memory data
|
|
743
732
|
) internal virtual {
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
733
|
+
require(
|
|
734
|
+
from != address(0) && to != address(0),
|
|
735
|
+
LSP7CannotSendWithAddressZero()
|
|
736
|
+
);
|
|
747
737
|
|
|
748
738
|
_beforeTokenTransfer(from, to, amount, force, data);
|
|
749
739
|
|
|
@@ -778,9 +768,10 @@ abstract contract LSP7DigitalAsset is
|
|
|
778
768
|
} else {
|
|
779
769
|
uint256 fromBalance = _tokenOwnerBalances[from];
|
|
780
770
|
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
771
|
+
require(
|
|
772
|
+
fromBalance >= amount,
|
|
773
|
+
LSP7AmountExceedsBalance(fromBalance, from, amount)
|
|
774
|
+
);
|
|
784
775
|
|
|
785
776
|
unchecked {
|
|
786
777
|
// Overflow not possible: amount <= fromBalance <= totalSupply.
|
|
@@ -850,7 +841,7 @@ abstract contract LSP7DigitalAsset is
|
|
|
850
841
|
* @dev Attempt to notify the operator `operator` about the `amount` tokens being authorized with.
|
|
851
842
|
* This is done by calling its {universalReceiver} function with the `_TYPEID_LSP7_TOKENOPERATOR` as typeId, if `operator` is a contract that supports the LSP1 interface.
|
|
852
843
|
* If `operator` is an EOA or a contract that does not support the LSP1 interface, nothing will happen and no notification will be sent.
|
|
853
|
-
|
|
844
|
+
*
|
|
854
845
|
* @param operator The address to call the {universalReceiver} function on.
|
|
855
846
|
* @param lsp1Data the data to be sent to the `operator` address in the `universalReceiver` call.
|
|
856
847
|
*/
|
|
@@ -869,7 +860,7 @@ abstract contract LSP7DigitalAsset is
|
|
|
869
860
|
* @dev Attempt to notify the token sender `from` about the `amount` of tokens being transferred.
|
|
870
861
|
* This is done by calling its {universalReceiver} function with the `_TYPEID_LSP7_TOKENSSENDER` as typeId, if `from` is a contract that supports the LSP1 interface.
|
|
871
862
|
* If `from` is an EOA or a contract that does not support the LSP1 interface, nothing will happen and no notification will be sent.
|
|
872
|
-
|
|
863
|
+
*
|
|
873
864
|
* @param from The address to call the {universalReceiver} function on.
|
|
874
865
|
* @param lsp1Data the data to be sent to the `from` address in the `universalReceiver` call.
|
|
875
866
|
*/
|
|
@@ -1,38 +1,26 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
pragma solidity ^0.8.
|
|
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
|
|
11
|
-
import {
|
|
12
|
-
EnumerableSet
|
|
13
|
-
} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
|
14
|
-
import {
|
|
15
|
-
ERC165Checker
|
|
16
|
-
} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
|
|
17
9
|
import {
|
|
18
10
|
LSP4DigitalAssetMetadataInitAbstract,
|
|
19
11
|
ERC725YInitAbstract
|
|
20
12
|
} from "@lukso/lsp4-contracts/contracts/LSP4DigitalAssetMetadataInitAbstract.sol";
|
|
21
|
-
import {
|
|
22
|
-
LSP17ExtendableInitAbstract
|
|
23
|
-
} from "@lukso/lsp17contractextension-contracts/contracts/LSP17ExtendableInitAbstract.sol";
|
|
13
|
+
import {LSP17ExtendableInitAbstract} from "@lukso/lsp17contractextension-contracts/contracts/LSP17ExtendableInitAbstract.sol";
|
|
24
14
|
|
|
25
15
|
// libraries
|
|
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,
|
|
@@ -139,9 +127,7 @@ abstract contract LSP7DigitalAssetInitAbstract is
|
|
|
139
127
|
fallback(
|
|
140
128
|
bytes calldata callData
|
|
141
129
|
) external payable virtual returns (bytes memory) {
|
|
142
|
-
|
|
143
|
-
revert InvalidFunctionSelector(callData);
|
|
144
|
-
}
|
|
130
|
+
require(msg.data.length >= 4, InvalidFunctionSelector(callData));
|
|
145
131
|
return _fallbackLSP17Extendable(callData);
|
|
146
132
|
}
|
|
147
133
|
|
|
@@ -181,8 +167,10 @@ abstract contract LSP7DigitalAssetInitAbstract is
|
|
|
181
167
|
(address extension, ) = _getExtensionAndForwardValue(msg.sig);
|
|
182
168
|
|
|
183
169
|
// if no extension was found, revert
|
|
184
|
-
|
|
185
|
-
|
|
170
|
+
require(
|
|
171
|
+
extension != address(0),
|
|
172
|
+
NoExtensionFoundForFunctionSelector(msg.sig)
|
|
173
|
+
);
|
|
186
174
|
|
|
187
175
|
(bool success, bytes memory result) = extension.call{value: msg.value}(
|
|
188
176
|
abi.encodePacked(callData, msg.sender, msg.value)
|
|
@@ -221,8 +209,10 @@ abstract contract LSP7DigitalAssetInitAbstract is
|
|
|
221
209
|
bytes memory extensionAddress = ERC725YInitAbstract._getData(
|
|
222
210
|
mappedExtensionDataKey
|
|
223
211
|
);
|
|
224
|
-
|
|
225
|
-
|
|
212
|
+
require(
|
|
213
|
+
extensionAddress.length == 20 || extensionAddress.length == 0,
|
|
214
|
+
InvalidExtensionAddress(extensionAddress)
|
|
215
|
+
);
|
|
226
216
|
|
|
227
217
|
return (address(bytes20(extensionAddress)), true);
|
|
228
218
|
}
|
|
@@ -356,13 +346,10 @@ abstract contract LSP7DigitalAssetInitAbstract is
|
|
|
356
346
|
bool notify,
|
|
357
347
|
bytes memory operatorNotificationData
|
|
358
348
|
) public virtual override {
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
operator
|
|
364
|
-
);
|
|
365
|
-
}
|
|
349
|
+
require(
|
|
350
|
+
msg.sender == tokenOwner || msg.sender == operator,
|
|
351
|
+
LSP7RevokeOperatorNotAuthorized(msg.sender, tokenOwner, operator)
|
|
352
|
+
);
|
|
366
353
|
|
|
367
354
|
_updateOperator(
|
|
368
355
|
tokenOwner,
|
|
@@ -415,8 +402,10 @@ abstract contract LSP7DigitalAssetInitAbstract is
|
|
|
415
402
|
bytes memory operatorNotificationData
|
|
416
403
|
) public virtual override {
|
|
417
404
|
uint256 oldAllowance = authorizedAmountFor(operator, msg.sender);
|
|
418
|
-
|
|
419
|
-
|
|
405
|
+
require(
|
|
406
|
+
oldAllowance > 0,
|
|
407
|
+
OperatorAllowanceCannotBeIncreasedFromZero(operator)
|
|
408
|
+
);
|
|
420
409
|
|
|
421
410
|
uint256 newAllowance = oldAllowance + addedAmount;
|
|
422
411
|
|
|
@@ -446,13 +435,10 @@ abstract contract LSP7DigitalAssetInitAbstract is
|
|
|
446
435
|
uint256 subtractedAmount,
|
|
447
436
|
bytes memory operatorNotificationData
|
|
448
437
|
) public virtual override {
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
operator
|
|
454
|
-
);
|
|
455
|
-
}
|
|
438
|
+
require(
|
|
439
|
+
msg.sender == tokenOwner || msg.sender == operator,
|
|
440
|
+
LSP7DecreaseAllowanceNotAuthorized(msg.sender, tokenOwner, operator)
|
|
441
|
+
);
|
|
456
442
|
|
|
457
443
|
uint256 currentAllowance = authorizedAmountFor(operator, tokenOwner);
|
|
458
444
|
if (currentAllowance < subtractedAmount) {
|
|
@@ -514,14 +500,13 @@ abstract contract LSP7DigitalAssetInitAbstract is
|
|
|
514
500
|
bytes[] memory data
|
|
515
501
|
) public virtual override {
|
|
516
502
|
uint256 fromLength = from.length;
|
|
517
|
-
|
|
518
|
-
fromLength
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
}
|
|
503
|
+
require(
|
|
504
|
+
fromLength == to.length &&
|
|
505
|
+
fromLength == amount.length &&
|
|
506
|
+
fromLength == force.length &&
|
|
507
|
+
fromLength == data.length,
|
|
508
|
+
LSP7InvalidTransferBatch()
|
|
509
|
+
);
|
|
525
510
|
|
|
526
511
|
for (uint256 i; i < fromLength; ) {
|
|
527
512
|
// using the public transfer function to handle updates to operator authorized amounts
|
|
@@ -559,13 +544,8 @@ abstract contract LSP7DigitalAssetInitAbstract is
|
|
|
559
544
|
bool notified,
|
|
560
545
|
bytes memory operatorNotificationData
|
|
561
546
|
) internal virtual {
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
if (operator == tokenOwner) {
|
|
567
|
-
revert LSP7TokenOwnerCannotBeOperator();
|
|
568
|
-
}
|
|
547
|
+
require(operator != address(0), LSP7CannotUseAddressZeroAsOperator());
|
|
548
|
+
require(operator != tokenOwner, LSP7TokenOwnerCannotBeOperator());
|
|
569
549
|
|
|
570
550
|
_operatorAuthorizedAmount[tokenOwner][operator] = allowance;
|
|
571
551
|
|
|
@@ -611,9 +591,7 @@ abstract contract LSP7DigitalAssetInitAbstract is
|
|
|
611
591
|
bool force,
|
|
612
592
|
bytes memory data
|
|
613
593
|
) internal virtual {
|
|
614
|
-
|
|
615
|
-
revert LSP7CannotSendWithAddressZero();
|
|
616
|
-
}
|
|
594
|
+
require(to != address(0), LSP7CannotSendWithAddressZero());
|
|
617
595
|
|
|
618
596
|
_beforeTokenTransfer(address(0), to, amount, force, data);
|
|
619
597
|
|
|
@@ -661,9 +639,7 @@ abstract contract LSP7DigitalAssetInitAbstract is
|
|
|
661
639
|
uint256 amount,
|
|
662
640
|
bytes memory data
|
|
663
641
|
) internal virtual {
|
|
664
|
-
|
|
665
|
-
revert LSP7CannotSendWithAddressZero();
|
|
666
|
-
}
|
|
642
|
+
require(from != address(0), LSP7CannotSendWithAddressZero());
|
|
667
643
|
|
|
668
644
|
_beforeTokenTransfer(from, address(0), amount, false, data);
|
|
669
645
|
|
|
@@ -756,9 +732,10 @@ abstract contract LSP7DigitalAssetInitAbstract is
|
|
|
756
732
|
bool force,
|
|
757
733
|
bytes memory data
|
|
758
734
|
) internal virtual {
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
735
|
+
require(
|
|
736
|
+
from != address(0) && to != address(0),
|
|
737
|
+
LSP7CannotSendWithAddressZero()
|
|
738
|
+
);
|
|
762
739
|
|
|
763
740
|
_beforeTokenTransfer(from, to, amount, force, data);
|
|
764
741
|
|
|
@@ -793,9 +770,10 @@ abstract contract LSP7DigitalAssetInitAbstract is
|
|
|
793
770
|
} else {
|
|
794
771
|
uint256 fromBalance = _tokenOwnerBalances[from];
|
|
795
772
|
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
773
|
+
require(
|
|
774
|
+
fromBalance >= amount,
|
|
775
|
+
LSP7AmountExceedsBalance(fromBalance, from, amount)
|
|
776
|
+
);
|
|
799
777
|
|
|
800
778
|
unchecked {
|
|
801
779
|
// Overflow not possible: amount <= fromBalance <= totalSupply.
|
|
@@ -865,7 +843,7 @@ abstract contract LSP7DigitalAssetInitAbstract is
|
|
|
865
843
|
* @dev Attempt to notify the operator `operator` about the `amount` tokens being authorized with.
|
|
866
844
|
* This is done by calling its {universalReceiver} function with the `_TYPEID_LSP7_TOKENOPERATOR` as typeId, if `operator` is a contract that supports the LSP1 interface.
|
|
867
845
|
* If `operator` is an EOA or a contract that does not support the LSP1 interface, nothing will happen and no notification will be sent.
|
|
868
|
-
|
|
846
|
+
*
|
|
869
847
|
* @param operator The address to call the {universalReceiver} function on.
|
|
870
848
|
* @param lsp1Data the data to be sent to the `operator` address in the `universalReceiver` call.
|
|
871
849
|
*/
|
|
@@ -884,7 +862,7 @@ abstract contract LSP7DigitalAssetInitAbstract is
|
|
|
884
862
|
* @dev Attempt to notify the token sender `from` about the `amount` of tokens being transferred.
|
|
885
863
|
* This is done by calling its {universalReceiver} function with the `_TYPEID_LSP7_TOKENSSENDER` as typeId, if `from` is a contract that supports the LSP1 interface.
|
|
886
864
|
* If `from` is an EOA or a contract that does not support the LSP1 interface, nothing will happen and no notification will be sent.
|
|
887
|
-
|
|
865
|
+
*
|
|
888
866
|
* @param from The address to call the {universalReceiver} function on.
|
|
889
867
|
* @param lsp1Data the data to be sent to the `from` address in the `universalReceiver` call.
|
|
890
868
|
*/
|