@lukso/lsp-smart-contracts 0.6.0 → 0.7.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/README.md +13 -12
- package/artifacts/Create2Factory.json +2 -2
- package/artifacts/LSP0ERC725Account.json +66 -27
- package/artifacts/LSP0ERC725AccountInit.json +71 -53
- package/artifacts/LSP1UniversalReceiverDelegateUP.json +23 -2
- package/artifacts/LSP1UniversalReceiverDelegateVault.json +23 -2
- package/artifacts/LSP4Compatibility.json +15 -9
- package/artifacts/LSP4DigitalAssetMetadata.json +25 -9
- package/artifacts/{LSP4DigitalAssetMetadataInit.json → LSP4DigitalAssetMetadataInitAbstract.json} +27 -60
- package/artifacts/LSP6KeyManager.json +93 -13
- package/artifacts/LSP6KeyManagerInit.json +98 -13
- package/artifacts/LSP7CappedSupply.json +56 -35
- package/artifacts/{LSP7CappedSupplyInit.json → LSP7CappedSupplyInitAbstract.json} +58 -104
- package/artifacts/LSP7CompatibleERC20.json +704 -0
- package/artifacts/LSP7CompatibleERC20InitAbstract.json +717 -0
- package/artifacts/LSP7CompatibleERC20Mintable.json +753 -0
- package/artifacts/LSP7CompatibleERC20MintableInit.json +773 -0
- package/artifacts/LSP7DigitalAsset.json +56 -61
- package/artifacts/LSP7DigitalAssetInitAbstract.json +540 -0
- package/artifacts/LSP7Mintable.json +59 -38
- package/artifacts/LSP7MintableInit.json +64 -64
- package/artifacts/LSP8CappedSupply.json +62 -9
- package/artifacts/{LSP8CappedSupplyInit.json → LSP8CappedSupplyInitAbstract.json} +64 -73
- package/artifacts/LSP8CompatibleERC721.json +907 -0
- package/artifacts/LSP8CompatibleERC721InitAbstract.json +920 -0
- package/artifacts/LSP8CompatibleERC721Mintable.json +967 -0
- package/artifacts/LSP8CompatibleERC721MintableInit.json +987 -0
- package/artifacts/LSP8IdentifiableDigitalAsset.json +62 -30
- package/artifacts/LSP8IdentifiableDigitalAssetInitAbstract.json +628 -0
- package/artifacts/LSP8Mintable.json +64 -11
- package/artifacts/LSP8MintableInit.json +69 -37
- package/artifacts/LSP9Vault.json +63 -24
- package/artifacts/LSP9VaultInit.json +68 -50
- package/artifacts/UniversalFactory.json +2 -2
- package/artifacts/UniversalProfile.json +66 -27
- package/artifacts/UniversalProfileInit.json +71 -53
- package/artifacts/UniversalReceiverAddressStore.json +7 -2
- package/constants.js +273 -31
- package/contracts/Custom/ClaimOwnership.sol +74 -9
- package/contracts/Custom/ERC165Checker.sol +1 -1
- package/contracts/Custom/IClaimOwnership.sol +3 -1
- package/contracts/Factories/Create2Factory.sol +3 -13
- package/contracts/Factories/UniversalFactory.sol +20 -16
- package/contracts/LSP0ERC725Account/LSP0Constants.sol +1 -1
- package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +3 -3
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +49 -37
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +10 -3
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +3 -3
- package/contracts/LSP10ReceivedVaults/LSP10Constants.sol +2 -2
- package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiver.sol +3 -0
- package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiverDelegate.sol +4 -2
- package/contracts/LSP1UniversalReceiver/LSP1Constants.sol +1 -1
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/Handling/TokenAndVaultHandling.sol +22 -16
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +14 -10
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/Handling/TokenHandling.sol +35 -29
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +10 -3
- package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +24 -9
- package/contracts/LSP2ERC725YJSONSchema/LSP2Errors.sol +9 -0
- package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +157 -75
- package/contracts/LSP3UniversalProfile/LSP3Constants.sol +1 -1
- package/contracts/LSP4DigitalAssetMetadata/LSP4Constants.sol +1 -1
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol +24 -4
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +26 -5
- package/contracts/LSP4DigitalAssetMetadata/LSP4Errors.sol +16 -0
- package/contracts/LSP5ReceivedAssets/LSP5Constants.sol +2 -2
- package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +151 -77
- package/contracts/LSP6KeyManager/ILSP6KeyManager.sol +16 -16
- package/contracts/LSP6KeyManager/LSP6Constants.sol +16 -21
- package/contracts/LSP6KeyManager/LSP6Errors.sol +42 -5
- package/contracts/LSP6KeyManager/LSP6KeyManager.sol +6 -4
- package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +293 -284
- package/contracts/LSP6KeyManager/LSP6KeyManagerInit.sol +11 -4
- package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +5 -3
- package/contracts/LSP6KeyManager/LSP6Utils.sol +24 -27
- package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +18 -5
- package/contracts/LSP7DigitalAsset/LSP7Constants.sol +1 -1
- package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +8 -4
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +35 -24
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +5 -3
- package/contracts/LSP7DigitalAsset/LSP7Errors.sol +2 -0
- package/contracts/LSP7DigitalAsset/extensions/{ILSP7CompatibilityForERC20.sol → ILSP7CompatibleERC20.sol} +6 -6
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyCore.sol +1 -1
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInitAbstract.sol +5 -2
- package/contracts/LSP7DigitalAsset/extensions/{LSP7CompatibilityForERC20.sol → LSP7CompatibleERC20.sol} +6 -7
- package/contracts/LSP7DigitalAsset/extensions/{LSP7CompatibilityForERC20Core.sol → LSP7CompatibleERC20Core.sol} +23 -19
- package/contracts/LSP7DigitalAsset/extensions/{LSP7CompatibilityForERC20InitAbstract.sol → LSP7CompatibleERC20InitAbstract.sol} +11 -10
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.sol +22 -0
- package/contracts/{LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibilityForERC721Init.sol → LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInit.sol} +12 -7
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInitAbstract.sol +27 -0
- package/contracts/LSP7DigitalAsset/presets/LSP7Mintable.sol +9 -7
- package/contracts/LSP7DigitalAsset/presets/LSP7MintableInit.sol +11 -4
- package/contracts/LSP7DigitalAsset/presets/LSP7MintableInitAbstract.sol +8 -7
- package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +3 -1
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol +4 -4
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol +6 -0
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +1 -1
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +31 -30
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +3 -1
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/{ILSP8CompatibilityForERC721.sol → ILSP8CompatibleERC721.sol} +16 -2
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8Enumerable.sol +17 -0
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyCore.sol +1 -1
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInitAbstract.sol +4 -2
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/{LSP8CompatibilityConstants.sol → LSP8CompatibleConstants.sol} +0 -0
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/{LSP8CompatibilityForERC721.sol → LSP8CompatibleERC721.sol} +12 -11
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/{LSP8CompatibilityForERC721Core.sol → LSP8CompatibleERC721Core.sol} +61 -37
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/{LSP8CompatibilityForERC721InitAbstract.sol → LSP8CompatibleERC721InitAbstract.sol} +13 -9
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.sol +21 -0
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableCore.sol +50 -0
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableInitAbstract.sol +24 -0
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.sol +22 -0
- package/contracts/{LSP7DigitalAsset/extensions/LSP7CompatibilityForERC20Init.sol → LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInit.sol} +12 -4
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInitAbstract.sol +27 -0
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.sol +6 -4
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInit.sol +7 -0
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +8 -5
- package/contracts/LSP9Vault/LSP9Constants.sol +6 -3
- package/contracts/LSP9Vault/LSP9Vault.sol +9 -5
- package/contracts/LSP9Vault/LSP9VaultCore.sol +152 -69
- package/contracts/LSP9Vault/LSP9VaultInit.sol +10 -3
- package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +9 -5
- package/contracts/Legacy/UniversalReceiverAddressStore.sol +6 -2
- package/contracts/UniversalProfile.sol +3 -4
- package/contracts/UniversalProfileInit.sol +10 -3
- package/contracts/UniversalProfileInitAbstract.sol +3 -5
- package/contracts/Utils/GasLib.sol +17 -0
- package/contracts/Utils/UtilsLib.sol +6 -34
- package/package.json +27 -30
- package/artifacts/LSP7CompatibilityForERC20.json +0 -686
- package/artifacts/LSP7CompatibilityForERC20Init.json +0 -727
- package/artifacts/LSP7DigitalAssetInit.json +0 -573
- package/artifacts/LSP8CompatibilityForERC721.json +0 -832
- package/artifacts/LSP8CompatibilityForERC721Init.json +0 -873
- package/artifacts/LSP8IdentifiableDigitalAssetInit.json +0 -624
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInit.sol +0 -26
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInit.sol +0 -28
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInit.sol +0 -19
- package/contracts/LSP7DigitalAsset/presets/LSP7MintableCore.sol +0 -26
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInit.sol +0 -26
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInit.sol +0 -19
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableCore.sol +0 -26
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
pragma solidity ^0.8.
|
|
2
|
+
pragma solidity ^0.8.5;
|
|
3
3
|
|
|
4
4
|
// modules
|
|
5
5
|
import {LSP6KeyManagerInitAbstract} from "./LSP6KeyManagerInitAbstract.sol";
|
|
@@ -10,11 +10,18 @@ import {LSP6KeyManagerInitAbstract} from "./LSP6KeyManagerInitAbstract.sol";
|
|
|
10
10
|
* @dev all the permissions can be set on the ERC725 Account using `setData(...)` with the keys constants below
|
|
11
11
|
*/
|
|
12
12
|
contract LSP6KeyManagerInit is LSP6KeyManagerInitAbstract {
|
|
13
|
+
/**
|
|
14
|
+
* @dev initialize (= lock) base implementation contract on deployment
|
|
15
|
+
*/
|
|
16
|
+
constructor() {
|
|
17
|
+
_disableInitializers();
|
|
18
|
+
}
|
|
19
|
+
|
|
13
20
|
/**
|
|
14
21
|
* @notice Initiate the account with the address of the ERC725Account contract and sets LSP6KeyManager InterfaceId
|
|
15
|
-
* @param
|
|
22
|
+
* @param target_ The address of the ER725Account to control
|
|
16
23
|
*/
|
|
17
|
-
function initialize(address
|
|
18
|
-
LSP6KeyManagerInitAbstract._initialize(
|
|
24
|
+
function initialize(address target_) public virtual initializer {
|
|
25
|
+
LSP6KeyManagerInitAbstract._initialize(target_);
|
|
19
26
|
}
|
|
20
27
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
pragma solidity ^0.8.
|
|
2
|
+
pragma solidity ^0.8.5;
|
|
3
3
|
|
|
4
4
|
// modules
|
|
5
5
|
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
|
|
6
6
|
import {Initializable} from "@openzeppelin/contracts/proxy/utils/Initializable.sol";
|
|
7
7
|
import {LSP6KeyManagerCore} from "./LSP6KeyManagerCore.sol";
|
|
8
|
+
import {InvalidLSP6Target} from "./LSP6Errors.sol";
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* @title Proxy implementation of a contract acting as a controller of an ERC725 Account, using permissions stored in the ERC725Y storage
|
|
@@ -12,7 +13,8 @@ import {LSP6KeyManagerCore} from "./LSP6KeyManagerCore.sol";
|
|
|
12
13
|
* @dev all the permissions can be set on the ERC725 Account using `setData(...)` with the keys constants below
|
|
13
14
|
*/
|
|
14
15
|
abstract contract LSP6KeyManagerInitAbstract is Initializable, LSP6KeyManagerCore {
|
|
15
|
-
function _initialize(address
|
|
16
|
-
|
|
16
|
+
function _initialize(address target_) internal virtual onlyInitializing {
|
|
17
|
+
if (target_ == address(0)) revert InvalidLSP6Target();
|
|
18
|
+
target = target_;
|
|
17
19
|
}
|
|
18
20
|
}
|
|
@@ -9,95 +9,92 @@ import {ILSP6KeyManager} from "./ILSP6KeyManager.sol";
|
|
|
9
9
|
import {LSP2Utils} from "../LSP2ERC725YJSONSchema/LSP2Utils.sol";
|
|
10
10
|
|
|
11
11
|
// constants
|
|
12
|
+
import {SETDATA_ARRAY_SELECTOR} from "@erc725/smart-contracts/contracts/constants.sol";
|
|
12
13
|
import "../LSP6KeyManager/LSP6Constants.sol";
|
|
13
14
|
|
|
14
15
|
library LSP6Utils {
|
|
15
16
|
using LSP2Utils for bytes12;
|
|
16
17
|
|
|
17
|
-
function getPermissionsFor(IERC725Y
|
|
18
|
-
|
|
19
|
-
view
|
|
20
|
-
returns (bytes32)
|
|
21
|
-
{
|
|
22
|
-
bytes memory permissions = _account.getData(
|
|
18
|
+
function getPermissionsFor(IERC725Y target, address caller) internal view returns (bytes32) {
|
|
19
|
+
bytes memory permissions = target.getData(
|
|
23
20
|
LSP2Utils.generateMappingWithGroupingKey(
|
|
24
21
|
_LSP6KEY_ADDRESSPERMISSIONS_PERMISSIONS_PREFIX,
|
|
25
|
-
bytes20(
|
|
22
|
+
bytes20(caller)
|
|
26
23
|
)
|
|
27
24
|
);
|
|
28
25
|
|
|
29
26
|
return bytes32(permissions);
|
|
30
27
|
}
|
|
31
28
|
|
|
32
|
-
function getAllowedAddressesFor(IERC725Y
|
|
29
|
+
function getAllowedAddressesFor(IERC725Y target, address caller)
|
|
33
30
|
internal
|
|
34
31
|
view
|
|
35
32
|
returns (bytes memory)
|
|
36
33
|
{
|
|
37
34
|
return
|
|
38
|
-
|
|
35
|
+
target.getData(
|
|
39
36
|
LSP2Utils.generateMappingWithGroupingKey(
|
|
40
37
|
_LSP6KEY_ADDRESSPERMISSIONS_ALLOWEDADDRESSES_PREFIX,
|
|
41
|
-
bytes20(
|
|
38
|
+
bytes20(caller)
|
|
42
39
|
)
|
|
43
40
|
);
|
|
44
41
|
}
|
|
45
42
|
|
|
46
|
-
function getAllowedFunctionsFor(IERC725Y
|
|
43
|
+
function getAllowedFunctionsFor(IERC725Y target, address caller)
|
|
47
44
|
internal
|
|
48
45
|
view
|
|
49
46
|
returns (bytes memory)
|
|
50
47
|
{
|
|
51
48
|
return
|
|
52
|
-
|
|
49
|
+
target.getData(
|
|
53
50
|
LSP2Utils.generateMappingWithGroupingKey(
|
|
54
51
|
_LSP6KEY_ADDRESSPERMISSIONS_ALLOWEDFUNCTIONS_PREFIX,
|
|
55
|
-
bytes20(
|
|
52
|
+
bytes20(caller)
|
|
56
53
|
)
|
|
57
54
|
);
|
|
58
55
|
}
|
|
59
56
|
|
|
60
|
-
function getAllowedStandardsFor(IERC725Y
|
|
57
|
+
function getAllowedStandardsFor(IERC725Y target, address caller)
|
|
61
58
|
internal
|
|
62
59
|
view
|
|
63
60
|
returns (bytes memory)
|
|
64
61
|
{
|
|
65
62
|
return
|
|
66
|
-
|
|
63
|
+
target.getData(
|
|
67
64
|
LSP2Utils.generateMappingWithGroupingKey(
|
|
68
65
|
_LSP6KEY_ADDRESSPERMISSIONS_ALLOWEDSTANDARDS_PREFIX,
|
|
69
|
-
bytes20(
|
|
66
|
+
bytes20(caller)
|
|
70
67
|
)
|
|
71
68
|
);
|
|
72
69
|
}
|
|
73
70
|
|
|
74
|
-
function getAllowedERC725YKeysFor(IERC725Y
|
|
71
|
+
function getAllowedERC725YKeysFor(IERC725Y target, address caller)
|
|
75
72
|
internal
|
|
76
73
|
view
|
|
77
74
|
returns (bytes memory)
|
|
78
75
|
{
|
|
79
76
|
return
|
|
80
|
-
|
|
77
|
+
target.getData(
|
|
81
78
|
LSP2Utils.generateMappingWithGroupingKey(
|
|
82
79
|
_LSP6KEY_ADDRESSPERMISSIONS_ALLOWEDERC725YKEYS_PREFIX,
|
|
83
|
-
bytes20(
|
|
80
|
+
bytes20(caller)
|
|
84
81
|
)
|
|
85
82
|
);
|
|
86
83
|
}
|
|
87
84
|
|
|
88
85
|
/**
|
|
89
|
-
* @dev compare the permissions `
|
|
90
|
-
* to check if they includes the permissions `
|
|
91
|
-
* @param
|
|
92
|
-
* @param
|
|
93
|
-
* @return true if `
|
|
86
|
+
* @dev compare the permissions `addressPermissions` of an address
|
|
87
|
+
* to check if they includes the permissions `permissionToCheck`
|
|
88
|
+
* @param addressPermission the permissions of an address stored on an ERC725 account
|
|
89
|
+
* @param permissionToCheck the permissions to check
|
|
90
|
+
* @return true if `addressPermissions` includes `permissionToCheck`, false otherwise
|
|
94
91
|
*/
|
|
95
|
-
function hasPermission(bytes32
|
|
92
|
+
function hasPermission(bytes32 addressPermission, bytes32 permissionToCheck)
|
|
96
93
|
internal
|
|
97
94
|
pure
|
|
98
95
|
returns (bool)
|
|
99
96
|
{
|
|
100
|
-
return (
|
|
97
|
+
return (addressPermission & permissionToCheck) == permissionToCheck;
|
|
101
98
|
}
|
|
102
99
|
|
|
103
100
|
function setDataViaKeyManager(
|
|
@@ -105,7 +102,7 @@ library LSP6Utils {
|
|
|
105
102
|
bytes32[] memory keys,
|
|
106
103
|
bytes[] memory values
|
|
107
104
|
) internal returns (bytes memory result) {
|
|
108
|
-
bytes memory payload = abi.encodeWithSelector(
|
|
105
|
+
bytes memory payload = abi.encodeWithSelector(SETDATA_ARRAY_SELECTOR, keys, values);
|
|
109
106
|
result = ILSP6KeyManager(keyManagerAddress).execute(payload);
|
|
110
107
|
}
|
|
111
108
|
}
|
|
@@ -7,7 +7,7 @@ import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
|
|
|
7
7
|
import {IERC725Y} from "@erc725/smart-contracts/contracts/interfaces/IERC725Y.sol";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* @
|
|
10
|
+
* @title interface of the LSP7 - Digital Asset standard.
|
|
11
11
|
*/
|
|
12
12
|
interface ILSP7DigitalAsset is IERC165, IERC725Y {
|
|
13
13
|
// --- Events
|
|
@@ -60,7 +60,7 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
|
|
|
60
60
|
* no way affects any of the arithmetic of the contract, including
|
|
61
61
|
* {balanceOf} and {transfer}.
|
|
62
62
|
*/
|
|
63
|
-
function decimals() external view returns (
|
|
63
|
+
function decimals() external view returns (uint8);
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
66
|
* @dev Returns the number of existing tokens.
|
|
@@ -84,7 +84,17 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
|
|
|
84
84
|
* @param amount The amount of tokens operator has access to.
|
|
85
85
|
* @dev Sets `amount` as the amount of tokens `operator` address has access to from callers tokens.
|
|
86
86
|
*
|
|
87
|
-
*
|
|
87
|
+
* To avoid front-running and Allowance Double-Spend Exploit when
|
|
88
|
+
* increasing or decreasing the authorized amount of an operator,
|
|
89
|
+
* it is advised to:
|
|
90
|
+
* 1. call {revokeOperator} first, and
|
|
91
|
+
* 2. then re-call {authorizeOperator} with the new amount
|
|
92
|
+
*
|
|
93
|
+
* for more information, see:
|
|
94
|
+
* https://docs.google.com/document/d/1YLPtQxZu1UAvO9cZ1O2RPXBbT0mooh4DYKjA_jp-RLM/
|
|
95
|
+
*
|
|
96
|
+
*
|
|
97
|
+
* See {authorizedAmountFor}.
|
|
88
98
|
*
|
|
89
99
|
* Requirements
|
|
90
100
|
*
|
|
@@ -98,7 +108,7 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
|
|
|
98
108
|
* @param operator The address to revoke as an operator.
|
|
99
109
|
* @dev Removes `operator` address as an operator of callers tokens.
|
|
100
110
|
*
|
|
101
|
-
* See {
|
|
111
|
+
* See {authorizedAmountFor}.
|
|
102
112
|
*
|
|
103
113
|
* Requirements
|
|
104
114
|
*
|
|
@@ -116,7 +126,10 @@ interface ILSP7DigitalAsset is IERC165, IERC725Y {
|
|
|
116
126
|
* Operators can send and burn tokens on behalf of their owners. The tokenOwner is their own
|
|
117
127
|
* operator.
|
|
118
128
|
*/
|
|
119
|
-
function
|
|
129
|
+
function authorizedAmountFor(address operator, address tokenOwner)
|
|
130
|
+
external
|
|
131
|
+
view
|
|
132
|
+
returns (uint256);
|
|
120
133
|
|
|
121
134
|
// --- Transfer functionality
|
|
122
135
|
|
|
@@ -16,22 +16,26 @@ import {_INTERFACEID_LSP7} from "./LSP7Constants.sol";
|
|
|
16
16
|
* @title LSP7DigitalAsset contract
|
|
17
17
|
* @author Matthew Stevens
|
|
18
18
|
* @dev Implementation of a LSP7 compliant contract.
|
|
19
|
+
*
|
|
20
|
+
* This implementation is agnostic to the way tokens are created.
|
|
21
|
+
* A supply mechanism has to be added in a derived contract using {_mint}
|
|
22
|
+
* For a generic mechanism, see {LSP7Mintable}.
|
|
19
23
|
*/
|
|
20
|
-
contract LSP7DigitalAsset is LSP4DigitalAssetMetadata, LSP7DigitalAssetCore {
|
|
24
|
+
abstract contract LSP7DigitalAsset is LSP4DigitalAssetMetadata, LSP7DigitalAssetCore {
|
|
21
25
|
/**
|
|
22
26
|
* @notice Sets the token-Metadata
|
|
23
27
|
* @param name_ The name of the token
|
|
24
28
|
* @param symbol_ The symbol of the token
|
|
25
29
|
* @param newOwner_ The owner of the the token-Metadata
|
|
26
|
-
* @param
|
|
30
|
+
* @param isNonDivisible_ Specify if the LSP7 token is a fungible or non-fungible token
|
|
27
31
|
*/
|
|
28
32
|
constructor(
|
|
29
33
|
string memory name_,
|
|
30
34
|
string memory symbol_,
|
|
31
35
|
address newOwner_,
|
|
32
|
-
bool
|
|
36
|
+
bool isNonDivisible_
|
|
33
37
|
) LSP4DigitalAssetMetadata(name_, symbol_, newOwner_) {
|
|
34
|
-
|
|
38
|
+
_isNonDivisible = isNonDivisible_;
|
|
35
39
|
}
|
|
36
40
|
|
|
37
41
|
/**
|
|
@@ -6,12 +6,12 @@ import {ILSP1UniversalReceiver} from "../LSP1UniversalReceiver/ILSP1UniversalRec
|
|
|
6
6
|
import {ILSP7DigitalAsset} from "./ILSP7DigitalAsset.sol";
|
|
7
7
|
|
|
8
8
|
// libraries
|
|
9
|
+
import {GasLib} from "../Utils/GasLib.sol";
|
|
9
10
|
import {ERC165Checker} from "../Custom/ERC165Checker.sol";
|
|
10
11
|
|
|
11
12
|
// modules
|
|
12
13
|
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
|
13
|
-
|
|
14
|
-
import {Context} from "@openzeppelin/contracts/utils/Context.sol";
|
|
14
|
+
|
|
15
15
|
import {ERC725Y} from "@erc725/smart-contracts/contracts/ERC725Y.sol";
|
|
16
16
|
|
|
17
17
|
// errors
|
|
@@ -25,13 +25,13 @@ import {_TYPEID_LSP7_TOKENSSENDER, _TYPEID_LSP7_TOKENSRECIPIENT} from "./LSP7Con
|
|
|
25
25
|
* @title LSP7DigitalAsset contract
|
|
26
26
|
* @author Matthew Stevens
|
|
27
27
|
* @dev Core Implementation of a LSP7 compliant contract.
|
|
28
|
+
*
|
|
29
|
+
* This contract implement the core logic of the functions for the {ILSP7DigitalAsset} interface.
|
|
28
30
|
*/
|
|
29
|
-
abstract contract LSP7DigitalAssetCore is
|
|
30
|
-
using Address for address;
|
|
31
|
-
|
|
31
|
+
abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
|
|
32
32
|
// --- Storage
|
|
33
33
|
|
|
34
|
-
bool internal
|
|
34
|
+
bool internal _isNonDivisible;
|
|
35
35
|
|
|
36
36
|
uint256 internal _existingTokens;
|
|
37
37
|
|
|
@@ -46,14 +46,14 @@ abstract contract LSP7DigitalAssetCore is Context, ILSP7DigitalAsset {
|
|
|
46
46
|
/**
|
|
47
47
|
* @inheritdoc ILSP7DigitalAsset
|
|
48
48
|
*/
|
|
49
|
-
function decimals() public view
|
|
50
|
-
return
|
|
49
|
+
function decimals() public view returns (uint8) {
|
|
50
|
+
return _isNonDivisible ? 0 : 18;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
54
|
* @inheritdoc ILSP7DigitalAsset
|
|
55
55
|
*/
|
|
56
|
-
function totalSupply() public view
|
|
56
|
+
function totalSupply() public view returns (uint256) {
|
|
57
57
|
return _existingTokens;
|
|
58
58
|
}
|
|
59
59
|
|
|
@@ -62,7 +62,7 @@ abstract contract LSP7DigitalAssetCore is Context, ILSP7DigitalAsset {
|
|
|
62
62
|
/**
|
|
63
63
|
* @inheritdoc ILSP7DigitalAsset
|
|
64
64
|
*/
|
|
65
|
-
function balanceOf(address tokenOwner) public view
|
|
65
|
+
function balanceOf(address tokenOwner) public view returns (uint256) {
|
|
66
66
|
return _tokenOwnerBalances[tokenOwner];
|
|
67
67
|
}
|
|
68
68
|
|
|
@@ -70,26 +70,35 @@ abstract contract LSP7DigitalAssetCore is Context, ILSP7DigitalAsset {
|
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
72
|
* @inheritdoc ILSP7DigitalAsset
|
|
73
|
+
*
|
|
74
|
+
* @dev To avoid front-running and Allowance Double-Spend Exploit when
|
|
75
|
+
* increasing or decreasing the authorized amount of an operator,
|
|
76
|
+
* it is advised to:
|
|
77
|
+
* 1. call {revokeOperator} first, and
|
|
78
|
+
* 2. then re-call {authorizeOperator} with the new amount
|
|
79
|
+
*
|
|
80
|
+
* for more information, see:
|
|
81
|
+
* https://docs.google.com/document/d/1YLPtQxZu1UAvO9cZ1O2RPXBbT0mooh4DYKjA_jp-RLM/
|
|
82
|
+
*
|
|
73
83
|
*/
|
|
74
|
-
function authorizeOperator(address operator, uint256 amount) public virtual
|
|
75
|
-
_updateOperator(
|
|
84
|
+
function authorizeOperator(address operator, uint256 amount) public virtual {
|
|
85
|
+
_updateOperator(msg.sender, operator, amount);
|
|
76
86
|
}
|
|
77
87
|
|
|
78
88
|
/**
|
|
79
89
|
* @inheritdoc ILSP7DigitalAsset
|
|
80
90
|
*/
|
|
81
|
-
function revokeOperator(address operator) public virtual
|
|
82
|
-
_updateOperator(
|
|
91
|
+
function revokeOperator(address operator) public virtual {
|
|
92
|
+
_updateOperator(msg.sender, operator, 0);
|
|
83
93
|
}
|
|
84
94
|
|
|
85
95
|
/**
|
|
86
96
|
* @inheritdoc ILSP7DigitalAsset
|
|
87
97
|
*/
|
|
88
|
-
function
|
|
98
|
+
function authorizedAmountFor(address operator, address tokenOwner)
|
|
89
99
|
public
|
|
90
100
|
view
|
|
91
101
|
virtual
|
|
92
|
-
override
|
|
93
102
|
returns (uint256)
|
|
94
103
|
{
|
|
95
104
|
if (tokenOwner == operator) {
|
|
@@ -110,8 +119,10 @@ abstract contract LSP7DigitalAssetCore is Context, ILSP7DigitalAsset {
|
|
|
110
119
|
uint256 amount,
|
|
111
120
|
bool force,
|
|
112
121
|
bytes memory data
|
|
113
|
-
) public virtual
|
|
114
|
-
|
|
122
|
+
) public virtual {
|
|
123
|
+
if (from == to) revert LSP7CannotSendToSelf();
|
|
124
|
+
|
|
125
|
+
address operator = msg.sender;
|
|
115
126
|
if (operator != from) {
|
|
116
127
|
uint256 operatorAmount = _operatorAuthorizedAmount[from][operator];
|
|
117
128
|
if (amount > operatorAmount) {
|
|
@@ -133,14 +144,14 @@ abstract contract LSP7DigitalAssetCore is Context, ILSP7DigitalAsset {
|
|
|
133
144
|
uint256[] memory amount,
|
|
134
145
|
bool force,
|
|
135
146
|
bytes[] memory data
|
|
136
|
-
)
|
|
147
|
+
) public virtual {
|
|
137
148
|
if (
|
|
138
149
|
from.length != to.length || from.length != amount.length || from.length != data.length
|
|
139
150
|
) {
|
|
140
151
|
revert LSP7InvalidTransferBatch();
|
|
141
152
|
}
|
|
142
153
|
|
|
143
|
-
for (uint256 i = 0; i < from.length; i
|
|
154
|
+
for (uint256 i = 0; i < from.length; i = GasLib.uncheckedIncrement(i)) {
|
|
144
155
|
// using the public transfer function to handle updates to operator authorized amounts
|
|
145
156
|
transfer(from[i], to[i], amount[i], force, data[i]);
|
|
146
157
|
}
|
|
@@ -151,7 +162,7 @@ abstract contract LSP7DigitalAssetCore is Context, ILSP7DigitalAsset {
|
|
|
151
162
|
* amount is zero then the operator is being revoked, otherwise the operator amount is being
|
|
152
163
|
* modified.
|
|
153
164
|
*
|
|
154
|
-
* See {
|
|
165
|
+
* See {authorizedAmountFor}.
|
|
155
166
|
*
|
|
156
167
|
* Emits either {AuthorizedOperator} or {RevokedOperator} event.
|
|
157
168
|
*
|
|
@@ -201,7 +212,7 @@ abstract contract LSP7DigitalAssetCore is Context, ILSP7DigitalAsset {
|
|
|
201
212
|
revert LSP7CannotSendWithAddressZero();
|
|
202
213
|
}
|
|
203
214
|
|
|
204
|
-
address operator =
|
|
215
|
+
address operator = msg.sender;
|
|
205
216
|
|
|
206
217
|
_beforeTokenTransfer(address(0), to, amount);
|
|
207
218
|
|
|
@@ -238,7 +249,7 @@ abstract contract LSP7DigitalAssetCore is Context, ILSP7DigitalAsset {
|
|
|
238
249
|
revert LSP7AmountExceedsBalance(balance, from, amount);
|
|
239
250
|
}
|
|
240
251
|
|
|
241
|
-
address operator =
|
|
252
|
+
address operator = msg.sender;
|
|
242
253
|
if (operator != from) {
|
|
243
254
|
uint256 authorizedAmount = _operatorAuthorizedAmount[from][operator];
|
|
244
255
|
if (amount > authorizedAmount) {
|
|
@@ -285,7 +296,7 @@ abstract contract LSP7DigitalAssetCore is Context, ILSP7DigitalAsset {
|
|
|
285
296
|
revert LSP7AmountExceedsBalance(balance, from, amount);
|
|
286
297
|
}
|
|
287
298
|
|
|
288
|
-
address operator =
|
|
299
|
+
address operator = msg.sender;
|
|
289
300
|
|
|
290
301
|
_beforeTokenTransfer(from, to, amount);
|
|
291
302
|
|
|
@@ -6,7 +6,9 @@ import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
|
|
|
6
6
|
|
|
7
7
|
// modules
|
|
8
8
|
import {ERC725YCore} from "@erc725/smart-contracts/contracts/ERC725YCore.sol";
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
LSP4DigitalAssetMetadataInitAbstract
|
|
11
|
+
} from "../LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol";
|
|
10
12
|
import {LSP7DigitalAssetCore} from "./LSP7DigitalAssetCore.sol";
|
|
11
13
|
|
|
12
14
|
// constants
|
|
@@ -25,9 +27,9 @@ abstract contract LSP7DigitalAssetInitAbstract is
|
|
|
25
27
|
string memory name_,
|
|
26
28
|
string memory symbol_,
|
|
27
29
|
address newOwner_,
|
|
28
|
-
bool
|
|
30
|
+
bool isNonDivisible_
|
|
29
31
|
) internal virtual onlyInitializing {
|
|
30
|
-
|
|
32
|
+
_isNonDivisible = isNonDivisible_;
|
|
31
33
|
LSP4DigitalAssetMetadataInitAbstract._initialize(name_, symbol_, newOwner_);
|
|
32
34
|
}
|
|
33
35
|
|
|
@@ -6,9 +6,9 @@ pragma solidity ^0.8.0;
|
|
|
6
6
|
import {ILSP7DigitalAsset} from "../ILSP7DigitalAsset.sol";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* @dev
|
|
9
|
+
* @dev LSP7 extension, for compatibility for clients / tools that expect ERC20.
|
|
10
10
|
*/
|
|
11
|
-
interface
|
|
11
|
+
interface ILSP7CompatibleERC20 is ILSP7DigitalAsset {
|
|
12
12
|
/**
|
|
13
13
|
* @notice To provide compatibility with indexing ERC20 events.
|
|
14
14
|
* @dev Emitted when `amount` tokens is transferred from `from` to `to`.
|
|
@@ -32,7 +32,7 @@ interface ILSP7CompatibilityForERC20 is ILSP7DigitalAsset {
|
|
|
32
32
|
* @param to The receiving address
|
|
33
33
|
* @param amount The amount of tokens to transfer
|
|
34
34
|
*/
|
|
35
|
-
function transfer(address to, uint256 amount) external;
|
|
35
|
+
function transfer(address to, uint256 amount) external returns (bool);
|
|
36
36
|
|
|
37
37
|
/*
|
|
38
38
|
* @dev Compatible with ERC20 transferFrom
|
|
@@ -44,14 +44,14 @@ interface ILSP7CompatibilityForERC20 is ILSP7DigitalAsset {
|
|
|
44
44
|
address from,
|
|
45
45
|
address to,
|
|
46
46
|
uint256 amount
|
|
47
|
-
) external;
|
|
47
|
+
) external returns (bool);
|
|
48
48
|
|
|
49
49
|
/*
|
|
50
50
|
* @dev Compatible with ERC20 approve
|
|
51
51
|
* @param operator The address to approve for `amount`
|
|
52
52
|
* @param amount The amount to approve
|
|
53
53
|
*/
|
|
54
|
-
function approve(address operator, uint256 amount) external;
|
|
54
|
+
function approve(address operator, uint256 amount) external returns (bool);
|
|
55
55
|
|
|
56
56
|
/*
|
|
57
57
|
* @dev Compatible with ERC20 allowance
|
|
@@ -59,5 +59,5 @@ interface ILSP7CompatibilityForERC20 is ILSP7DigitalAsset {
|
|
|
59
59
|
* @param operator The address approved by the `tokenOwner`
|
|
60
60
|
* @return The amount `operator` is approved by `tokenOwner`
|
|
61
61
|
*/
|
|
62
|
-
function allowance(address tokenOwner, address operator) external returns (uint256);
|
|
62
|
+
function allowance(address tokenOwner, address operator) external view returns (uint256);
|
|
63
63
|
}
|
|
@@ -26,7 +26,7 @@ abstract contract LSP7CappedSupplyCore is LSP7DigitalAssetCore, ILSP7CappedSuppl
|
|
|
26
26
|
/**
|
|
27
27
|
* @inheritdoc ILSP7CappedSupply
|
|
28
28
|
*/
|
|
29
|
-
function tokenSupplyCap() public view virtual
|
|
29
|
+
function tokenSupplyCap() public view virtual returns (uint256) {
|
|
30
30
|
return _tokenSupplyCap;
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -3,14 +3,17 @@
|
|
|
3
3
|
pragma solidity ^0.8.0;
|
|
4
4
|
|
|
5
5
|
// modules
|
|
6
|
-
import {
|
|
6
|
+
import {LSP7DigitalAssetInitAbstract} from "../LSP7DigitalAssetInitAbstract.sol";
|
|
7
7
|
import {LSP7DigitalAssetCore} from "../LSP7DigitalAssetCore.sol";
|
|
8
8
|
import {LSP7CappedSupplyCore} from "./LSP7CappedSupplyCore.sol";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* @dev LSP7 extension, adds token supply cap.
|
|
12
12
|
*/
|
|
13
|
-
abstract contract LSP7CappedSupplyInitAbstract is
|
|
13
|
+
abstract contract LSP7CappedSupplyInitAbstract is
|
|
14
|
+
LSP7DigitalAssetInitAbstract,
|
|
15
|
+
LSP7CappedSupplyCore
|
|
16
|
+
{
|
|
14
17
|
function _initialize(uint256 tokenSupplyCap_) internal virtual onlyInitializing {
|
|
15
18
|
if (tokenSupplyCap_ == 0) {
|
|
16
19
|
revert LSP7CappedSupplyRequired();
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
|
|
3
2
|
pragma solidity ^0.8.0;
|
|
4
3
|
|
|
5
4
|
// modules
|
|
6
5
|
import {LSP7DigitalAsset, LSP4DigitalAssetMetadata, ERC725YCore} from "../LSP7DigitalAsset.sol";
|
|
7
6
|
import {LSP7DigitalAssetCore} from "../LSP7DigitalAssetCore.sol";
|
|
8
|
-
import {
|
|
7
|
+
import {LSP7CompatibleERC20Core} from "./LSP7CompatibleERC20Core.sol";
|
|
9
8
|
|
|
10
|
-
contract
|
|
9
|
+
abstract contract LSP7CompatibleERC20 is LSP7DigitalAsset, LSP7CompatibleERC20Core {
|
|
11
10
|
/* solhint-disable no-empty-blocks */
|
|
12
11
|
/**
|
|
13
12
|
* @notice Sets the name, the symbol and the owner of the token
|
|
@@ -26,7 +25,7 @@ contract LSP7CompatibilityForERC20 is LSP7DigitalAsset, LSP7CompatibilityForERC2
|
|
|
26
25
|
function authorizeOperator(address operator, uint256 amount)
|
|
27
26
|
public
|
|
28
27
|
virtual
|
|
29
|
-
override(LSP7DigitalAssetCore,
|
|
28
|
+
override(LSP7DigitalAssetCore, LSP7CompatibleERC20Core)
|
|
30
29
|
{
|
|
31
30
|
super.authorizeOperator(operator, amount);
|
|
32
31
|
}
|
|
@@ -35,7 +34,7 @@ contract LSP7CompatibilityForERC20 is LSP7DigitalAsset, LSP7CompatibilityForERC2
|
|
|
35
34
|
address from,
|
|
36
35
|
uint256 amount,
|
|
37
36
|
bytes memory data
|
|
38
|
-
) internal virtual override(LSP7DigitalAssetCore,
|
|
37
|
+
) internal virtual override(LSP7DigitalAssetCore, LSP7CompatibleERC20Core) {
|
|
39
38
|
super._burn(from, amount, data);
|
|
40
39
|
}
|
|
41
40
|
|
|
@@ -44,7 +43,7 @@ contract LSP7CompatibilityForERC20 is LSP7DigitalAsset, LSP7CompatibilityForERC2
|
|
|
44
43
|
uint256 amount,
|
|
45
44
|
bool force,
|
|
46
45
|
bytes memory data
|
|
47
|
-
) internal virtual override(LSP7DigitalAssetCore,
|
|
46
|
+
) internal virtual override(LSP7DigitalAssetCore, LSP7CompatibleERC20Core) {
|
|
48
47
|
super._mint(to, amount, force, data);
|
|
49
48
|
}
|
|
50
49
|
|
|
@@ -54,7 +53,7 @@ contract LSP7CompatibilityForERC20 is LSP7DigitalAsset, LSP7CompatibilityForERC2
|
|
|
54
53
|
uint256 amount,
|
|
55
54
|
bool force,
|
|
56
55
|
bytes memory data
|
|
57
|
-
) internal virtual override(LSP7DigitalAssetCore,
|
|
56
|
+
) internal virtual override(LSP7DigitalAssetCore, LSP7CompatibleERC20Core) {
|
|
58
57
|
super._transfer(from, to, amount, force, data);
|
|
59
58
|
}
|
|
60
59
|
|