@lukso/lsp-smart-contracts 0.11.1 → 0.12.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 +10 -2
- package/artifacts/Create2Factory.json +2 -2
- package/artifacts/LSP0ERC725Account.json +68 -47
- package/artifacts/LSP0ERC725AccountInit.json +68 -47
- package/artifacts/LSP11BasicSocialRecovery.json +18 -2
- package/artifacts/LSP11BasicSocialRecoveryInit.json +18 -2
- package/artifacts/LSP16UniversalFactory.json +3 -3
- package/artifacts/LSP1UniversalReceiverDelegateUP.json +27 -46
- package/artifacts/LSP1UniversalReceiverDelegateVault.json +27 -46
- package/artifacts/LSP23LinkedContractsFactory.json +3 -3
- package/artifacts/LSP4DigitalAssetMetadata.json +16 -0
- package/artifacts/LSP4DigitalAssetMetadataInitAbstract.json +16 -0
- package/artifacts/LSP6KeyManager.json +34 -6
- package/artifacts/LSP6KeyManagerInit.json +34 -6
- package/artifacts/LSP7CappedSupply.json +64 -4
- package/artifacts/LSP7CappedSupplyInitAbstract.json +64 -4
- package/artifacts/LSP7CompatibleERC20.json +83 -23
- package/artifacts/LSP7CompatibleERC20InitAbstract.json +83 -23
- package/artifacts/LSP7CompatibleERC20Mintable.json +86 -26
- package/artifacts/LSP7CompatibleERC20MintableInit.json +86 -26
- package/artifacts/LSP7DigitalAsset.json +64 -4
- package/artifacts/LSP7DigitalAssetInitAbstract.json +64 -4
- package/artifacts/LSP7Mintable.json +67 -7
- package/artifacts/LSP7MintableInit.json +67 -7
- package/artifacts/LSP8CappedSupply.json +57 -3
- package/artifacts/LSP8CappedSupplyInitAbstract.json +57 -3
- package/artifacts/LSP8CompatibleERC721.json +79 -25
- package/artifacts/LSP8CompatibleERC721InitAbstract.json +79 -25
- package/artifacts/LSP8CompatibleERC721Mintable.json +87 -28
- package/artifacts/LSP8CompatibleERC721MintableInit.json +87 -28
- package/artifacts/LSP8IdentifiableDigitalAsset.json +57 -3
- package/artifacts/LSP8IdentifiableDigitalAssetInitAbstract.json +57 -3
- package/artifacts/LSP8Mintable.json +65 -6
- package/artifacts/LSP8MintableInit.json +65 -6
- package/artifacts/LSP9Vault.json +51 -35
- package/artifacts/LSP9VaultInit.json +51 -35
- package/artifacts/UniversalProfile.json +68 -47
- package/artifacts/UniversalProfileInit.json +68 -47
- package/contracts/Factories/Create2Factory.sol +1 -1
- package/contracts/LSP0ERC725Account/ILSP0ERC725Account.sol +0 -22
- package/contracts/LSP0ERC725Account/LSP0Constants.sol +6 -1
- package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +12 -2
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +196 -123
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +1 -1
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +11 -2
- package/contracts/LSP10ReceivedVaults/LSP10Utils.sol +5 -3
- package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryCore.sol +54 -14
- package/contracts/LSP11BasicSocialRecovery/LSP11Constants.sol +1 -1
- package/contracts/LSP11BasicSocialRecovery/LSP11Errors.sol +1 -1
- package/contracts/LSP14Ownable2Step/ILSP14Ownable2Step.sol +2 -2
- package/contracts/LSP14Ownable2Step/LSP14Constants.sol +1 -1
- package/contracts/LSP14Ownable2Step/LSP14Errors.sol +9 -3
- package/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol +16 -12
- package/contracts/LSP16UniversalFactory/LSP16UniversalFactory.sol +65 -96
- package/contracts/LSP17ContractExtension/LSP17Errors.sol +1 -1
- package/contracts/LSP17ContractExtension/LSP17Extendable.sol +22 -15
- package/contracts/LSP17ContractExtension/LSP17Extension.sol +6 -5
- package/contracts/LSP17Extensions/Extension4337.sol +101 -0
- package/contracts/LSP17Extensions/OnERC721ReceivedExtension.sol +15 -0
- package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiver.sol +1 -2
- package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiverDelegate.sol +24 -0
- package/contracts/LSP1UniversalReceiver/LSP1Constants.sol +1 -0
- package/contracts/LSP1UniversalReceiver/LSP1Errors.sol +0 -6
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +49 -33
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +33 -27
- package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +5 -48
- package/contracts/LSP20CallVerification/ILSP20CallVerifier.sol +13 -9
- package/contracts/LSP20CallVerification/LSP20CallVerification.sol +64 -45
- package/contracts/LSP20CallVerification/LSP20Constants.sol +6 -6
- package/contracts/LSP20CallVerification/LSP20Errors.sol +10 -4
- package/contracts/{LSP23LinkedContractsDeployment → LSP23LinkedContractsFactory}/ILSP23LinkedContractsFactory.sol +1 -1
- package/contracts/{LSP23LinkedContractsDeployment → LSP23LinkedContractsFactory}/IPostDeploymentModule.sol +1 -1
- package/contracts/{LSP23LinkedContractsDeployment → LSP23LinkedContractsFactory}/LSP23Errors.sol +1 -1
- package/contracts/{LSP23LinkedContractsDeployment → LSP23LinkedContractsFactory}/LSP23LinkedContractsFactory.sol +5 -1
- package/contracts/{LSP23LinkedContractsDeployment → LSP23LinkedContractsFactory}/modules/UniversalProfileInitPostDeploymentModule.sol +1 -1
- package/contracts/{LSP23LinkedContractsDeployment → LSP23LinkedContractsFactory}/modules/UniversalProfilePostDeploymentModule.sol +1 -1
- package/contracts/LSP25ExecuteRelayCall/LSP25Constants.sol +1 -1
- package/contracts/LSP25ExecuteRelayCall/LSP25MultiChannelNonce.sol +8 -3
- package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +1 -97
- package/contracts/LSP3ProfileMetadata/LSP3Constants.sol +1 -1
- package/contracts/LSP4DigitalAssetMetadata/LSP4Constants.sol +1 -1
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol +8 -3
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +8 -3
- package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +4 -3
- package/contracts/LSP6KeyManager/LSP6Constants.sol +4 -3
- package/contracts/LSP6KeyManager/LSP6Errors.sol +2 -23
- package/contracts/LSP6KeyManager/LSP6KeyManager.sol +0 -1
- package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +176 -101
- package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +0 -1
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6ExecuteModule.sol +1 -2
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6ExecuteRelayCallModule.sol +27 -0
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6SetDataModule.sol +34 -28
- package/contracts/LSP6KeyManager/LSP6Utils.sol +29 -2
- package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +70 -10
- package/contracts/LSP7DigitalAsset/LSP7Constants.sol +2 -2
- package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +29 -13
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +273 -265
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +28 -12
- package/contracts/LSP7DigitalAsset/LSP7Errors.sol +17 -3
- package/contracts/LSP7DigitalAsset/extensions/LSP7Burnable.sol +5 -1
- package/contracts/LSP7DigitalAsset/extensions/LSP7BurnableInitAbstract.sol +4 -1
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupply.sol +7 -7
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInitAbstract.sol +3 -3
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.sol +128 -54
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20InitAbstract.sol +129 -54
- package/contracts/LSP7DigitalAsset/presets/ILSP7Mintable.sol +3 -3
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.sol +4 -4
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInit.sol +2 -2
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInitAbstract.sol +4 -4
- package/contracts/LSP7DigitalAsset/presets/LSP7Mintable.sol +4 -4
- package/contracts/LSP7DigitalAsset/presets/LSP7MintableInit.sol +1 -1
- package/contracts/LSP7DigitalAsset/presets/LSP7MintableInitAbstract.sol +4 -4
- package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +16 -11
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol +20 -6
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol +32 -16
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +67 -16
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +143 -137
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +69 -15
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Burnable.sol +1 -1
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8BurnableInitAbstract.sol +1 -1
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.sol +7 -7
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInitAbstract.sol +3 -3
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +172 -80
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +178 -91
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.sol +7 -7
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableInitAbstract.sol +7 -7
- package/contracts/LSP8IdentifiableDigitalAsset/presets/ILSP8Mintable.sol +3 -3
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.sol +8 -7
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInit.sol +5 -3
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInitAbstract.sol +13 -7
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.sol +9 -8
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInit.sol +9 -3
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +10 -8
- package/contracts/LSP9Vault/ILSP9Vault.sol +0 -21
- package/contracts/LSP9Vault/LSP9Constants.sol +6 -1
- package/contracts/LSP9Vault/LSP9Errors.sol +1 -1
- package/contracts/LSP9Vault/LSP9Vault.sol +11 -2
- package/contracts/LSP9Vault/LSP9VaultCore.sol +119 -66
- package/contracts/LSP9Vault/LSP9VaultInit.sol +1 -1
- package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +11 -2
- package/contracts/UniversalProfile.sol +1 -1
- package/contracts/UniversalProfileInit.sol +1 -1
- package/contracts/UniversalProfileInitAbstract.sol +1 -1
- package/contracts/Version.sol +16 -0
- package/devdocs/LSP0ERC725Account.json +86 -52
- package/devdocs/LSP0ERC725AccountInit.json +86 -52
- package/devdocs/LSP11BasicSocialRecovery.json +13 -0
- package/devdocs/LSP11BasicSocialRecoveryInit.json +13 -0
- package/devdocs/LSP16UniversalFactory.json +9 -9
- package/devdocs/LSP1UniversalReceiverDelegateUP.json +7 -6
- package/devdocs/LSP1UniversalReceiverDelegateVault.json +7 -6
- package/devdocs/LSP4DigitalAssetMetadata.json +32 -10
- package/devdocs/LSP4DigitalAssetMetadataInitAbstract.json +32 -10
- package/devdocs/LSP6KeyManager.json +27 -13
- package/devdocs/LSP6KeyManagerInit.json +27 -13
- package/devdocs/LSP7CappedSupply.json +61 -28
- package/devdocs/LSP7CappedSupplyInitAbstract.json +61 -28
- package/devdocs/LSP7CompatibleERC20.json +102 -32
- package/devdocs/LSP7CompatibleERC20InitAbstract.json +102 -32
- package/devdocs/LSP7CompatibleERC20Mintable.json +102 -32
- package/devdocs/LSP7CompatibleERC20MintableInit.json +102 -32
- package/devdocs/LSP7DigitalAsset.json +61 -28
- package/devdocs/LSP7DigitalAssetInitAbstract.json +61 -28
- package/devdocs/LSP7Mintable.json +61 -28
- package/devdocs/LSP7MintableInit.json +61 -28
- package/devdocs/LSP8CappedSupply.json +66 -27
- package/devdocs/LSP8CappedSupplyInitAbstract.json +66 -27
- package/devdocs/LSP8CompatibleERC721.json +93 -33
- package/devdocs/LSP8CompatibleERC721InitAbstract.json +93 -33
- package/devdocs/LSP8CompatibleERC721Mintable.json +95 -35
- package/devdocs/LSP8CompatibleERC721MintableInit.json +96 -36
- package/devdocs/LSP8IdentifiableDigitalAsset.json +70 -28
- package/devdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +66 -27
- package/devdocs/LSP8Mintable.json +68 -29
- package/devdocs/LSP8MintableInit.json +69 -30
- package/devdocs/LSP9Vault.json +69 -41
- package/devdocs/LSP9VaultInit.json +69 -41
- package/devdocs/UniversalProfile.json +86 -52
- package/devdocs/UniversalProfileInit.json +86 -52
- package/dist/constants.cjs.js +5565 -2846
- package/dist/constants.d.ts +3996 -1182
- package/dist/constants.es.js +5564 -2846
- package/package.json +8 -8
- package/userdocs/LSP0ERC725Account.json +20 -11
- package/userdocs/LSP0ERC725AccountInit.json +20 -11
- package/userdocs/LSP16UniversalFactory.json +26 -1
- package/userdocs/LSP1UniversalReceiverDelegateUP.json +4 -11
- package/userdocs/LSP1UniversalReceiverDelegateVault.json +4 -11
- package/userdocs/LSP4DigitalAssetMetadata.json +7 -4
- package/userdocs/LSP4DigitalAssetMetadataInitAbstract.json +7 -4
- package/userdocs/LSP6KeyManager.json +3 -5
- package/userdocs/LSP6KeyManagerInit.json +3 -5
- package/userdocs/LSP7CappedSupply.json +17 -6
- package/userdocs/LSP7CappedSupplyInitAbstract.json +16 -5
- package/userdocs/LSP7CompatibleERC20.json +18 -5
- package/userdocs/LSP7CompatibleERC20InitAbstract.json +18 -5
- package/userdocs/LSP7CompatibleERC20Mintable.json +18 -5
- package/userdocs/LSP7CompatibleERC20MintableInit.json +18 -5
- package/userdocs/LSP7DigitalAsset.json +18 -5
- package/userdocs/LSP7DigitalAssetInitAbstract.json +18 -5
- package/userdocs/LSP7Mintable.json +18 -5
- package/userdocs/LSP7MintableInit.json +18 -5
- package/userdocs/LSP8CappedSupply.json +16 -5
- package/userdocs/LSP8CappedSupplyInitAbstract.json +15 -4
- package/userdocs/LSP8CompatibleERC721.json +30 -17
- package/userdocs/LSP8CompatibleERC721InitAbstract.json +30 -17
- package/userdocs/LSP8CompatibleERC721Mintable.json +31 -18
- package/userdocs/LSP8CompatibleERC721MintableInit.json +32 -19
- package/userdocs/LSP8IdentifiableDigitalAsset.json +18 -5
- package/userdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +17 -4
- package/userdocs/LSP8Mintable.json +18 -5
- package/userdocs/LSP8MintableInit.json +19 -6
- package/userdocs/LSP9Vault.json +23 -14
- package/userdocs/LSP9VaultInit.json +23 -14
- package/userdocs/UniversalProfile.json +20 -11
- package/userdocs/UniversalProfileInit.json +20 -11
- package/CONTRIBUTING.md +0 -184
- package/artifacts/LSP4Compatibility.json +0 -216
- package/contracts/LSP4DigitalAssetMetadata/ILSP4Compatibility.sol +0 -25
- package/contracts/LSP4DigitalAssetMetadata/LSP4Compatibility.sol +0 -38
- package/contracts/LSP7DigitalAsset/extensions/ILSP7CompatibleERC20.sol +0 -83
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CompatibleERC721.sol +0 -175
- package/devdocs/LSP4Compatibility.json +0 -79
- package/userdocs/LSP4Compatibility.json +0 -20
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// SPDX-License-Identifier:
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
pragma solidity ^0.8.4;
|
|
3
3
|
|
|
4
4
|
// interfaces
|
|
@@ -18,8 +18,11 @@ import {LSP2Utils} from "../LSP2ERC725YJSONSchema/LSP2Utils.sol";
|
|
|
18
18
|
|
|
19
19
|
// constants
|
|
20
20
|
import {_INTERFACEID_LSP7} from "./LSP7Constants.sol";
|
|
21
|
+
import {LSP7TokenContractCannotHoldValue} from "./LSP7Errors.sol";
|
|
21
22
|
|
|
22
|
-
import
|
|
23
|
+
import {
|
|
24
|
+
_LSP17_EXTENSION_PREFIX
|
|
25
|
+
} from "../LSP17ContractExtension/LSP17Constants.sol";
|
|
23
26
|
|
|
24
27
|
// errors
|
|
25
28
|
|
|
@@ -55,7 +58,6 @@ abstract contract LSP7DigitalAssetInitAbstract is
|
|
|
55
58
|
|
|
56
59
|
// fallback function
|
|
57
60
|
|
|
58
|
-
// solhint-disable no-complex-fallback
|
|
59
61
|
/**
|
|
60
62
|
* @notice The `fallback` function was called with the following amount of native tokens: `msg.value`; and the following calldata: `callData`.
|
|
61
63
|
*
|
|
@@ -75,6 +77,7 @@ abstract contract LSP7DigitalAssetInitAbstract is
|
|
|
75
77
|
*
|
|
76
78
|
* 2. If the data sent to this function is of length less than 4 bytes (not a function selector), revert.
|
|
77
79
|
*/
|
|
80
|
+
// solhint-disable-next-line no-complex-fallback
|
|
78
81
|
fallback(
|
|
79
82
|
bytes calldata callData
|
|
80
83
|
) external payable virtual returns (bytes memory) {
|
|
@@ -84,11 +87,25 @@ abstract contract LSP7DigitalAssetInitAbstract is
|
|
|
84
87
|
return _fallbackLSP17Extendable(callData);
|
|
85
88
|
}
|
|
86
89
|
|
|
90
|
+
/**
|
|
91
|
+
* @dev Reverts whenever someone tries to send native tokens to a LSP7 contract.
|
|
92
|
+
* @notice LSP7 contract cannot receive native tokens.
|
|
93
|
+
*/
|
|
94
|
+
receive() external payable virtual {
|
|
95
|
+
// revert on empty calls with no value
|
|
96
|
+
if (msg.value == 0) {
|
|
97
|
+
revert InvalidFunctionSelector(hex"00000000");
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
revert LSP7TokenContractCannotHoldValue();
|
|
101
|
+
}
|
|
102
|
+
|
|
87
103
|
/**
|
|
88
104
|
* @dev Forwards the call with the received value to an extension mapped to a function selector.
|
|
89
105
|
*
|
|
90
|
-
* Calls {
|
|
106
|
+
* Calls {_getExtensionAndForwardValue} to get the address of the extension mapped to the function selector being
|
|
91
107
|
* called on the account. If there is no extension, the address(0) will be returned.
|
|
108
|
+
* Forwards the value if the extension is payable.
|
|
92
109
|
*
|
|
93
110
|
* Reverts if there is no extension for the function being called.
|
|
94
111
|
*
|
|
@@ -96,16 +113,14 @@ abstract contract LSP7DigitalAssetInitAbstract is
|
|
|
96
113
|
* CALL opcode, passing the {msg.data} appended with the 20 bytes of the {msg.sender} and
|
|
97
114
|
* 32 bytes of the {msg.value}
|
|
98
115
|
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
* Otherwise, the codes after _fallbackLSP17Extendable() may never be reached.
|
|
116
|
+
* @custom:info The LSP7 Token contract should not hold any native tokens. Any native tokens received by the contract
|
|
117
|
+
* will be forwarded to the extension address mapped to the selector from `msg.sig`.
|
|
103
118
|
*/
|
|
104
119
|
function _fallbackLSP17Extendable(
|
|
105
120
|
bytes calldata callData
|
|
106
121
|
) internal virtual override returns (bytes memory) {
|
|
107
122
|
// If there is a function selector
|
|
108
|
-
address extension =
|
|
123
|
+
(address extension, ) = _getExtensionAndForwardValue(msg.sig);
|
|
109
124
|
|
|
110
125
|
// if no extension was found, revert
|
|
111
126
|
if (extension == address(0))
|
|
@@ -133,10 +148,11 @@ abstract contract LSP7DigitalAssetInitAbstract is
|
|
|
133
148
|
* @dev Returns the extension address stored under the following data key:
|
|
134
149
|
* - {_LSP17_EXTENSION_PREFIX} + `<bytes4>` (Check [LSP2-ERC725YJSONSchema] for encoding the data key).
|
|
135
150
|
* - If no extension is stored, returns the address(0).
|
|
151
|
+
* - We do not check that payable bool as in lsp7 standard we will always forward the value to the extension
|
|
136
152
|
*/
|
|
137
|
-
function
|
|
153
|
+
function _getExtensionAndForwardValue(
|
|
138
154
|
bytes4 functionSelector
|
|
139
|
-
) internal view virtual override returns (address) {
|
|
155
|
+
) internal view virtual override returns (address, bool) {
|
|
140
156
|
// Generate the data key relevant for the functionSelector being called
|
|
141
157
|
bytes32 mappedExtensionDataKey = LSP2Utils.generateMappingKey(
|
|
142
158
|
_LSP17_EXTENSION_PREFIX,
|
|
@@ -150,7 +166,7 @@ abstract contract LSP7DigitalAssetInitAbstract is
|
|
|
150
166
|
if (extensionAddress.length != 20 && extensionAddress.length != 0)
|
|
151
167
|
revert InvalidExtensionAddress(extensionAddress);
|
|
152
168
|
|
|
153
|
-
return address(bytes20(extensionAddress));
|
|
169
|
+
return (address(bytes20(extensionAddress)), true);
|
|
154
170
|
}
|
|
155
171
|
|
|
156
172
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// SPDX-License-Identifier:
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
pragma solidity ^0.8.4;
|
|
3
3
|
|
|
4
4
|
// --- Errors
|
|
@@ -48,14 +48,14 @@ error LSP7InvalidTransferBatch();
|
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
50
|
* @dev reverts if the `tokenReceiver` does not implement LSP1
|
|
51
|
-
* when minting or transferring tokens with `bool
|
|
51
|
+
* when minting or transferring tokens with `bool force` set as `false`.
|
|
52
52
|
*/
|
|
53
53
|
error LSP7NotifyTokenReceiverContractMissingLSP1Interface(
|
|
54
54
|
address tokenReceiver
|
|
55
55
|
);
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
|
-
* @dev reverts if the `tokenReceiver` is an EOA when minting or transferring tokens with `bool
|
|
58
|
+
* @dev reverts if the `tokenReceiver` is an EOA when minting or transferring tokens with `bool force` set as `false`.
|
|
59
59
|
*/
|
|
60
60
|
error LSP7NotifyTokenReceiverIsEOA(address tokenReceiver);
|
|
61
61
|
|
|
@@ -68,3 +68,17 @@ error LSP7TokenOwnerCannotBeOperator();
|
|
|
68
68
|
* @dev Reverts when trying to decrease an operator's allowance to more than its current allowance.
|
|
69
69
|
*/
|
|
70
70
|
error LSP7DecreasedAllowanceBelowZero();
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @dev Error occurs when sending native tokens to the LSP7 contract without sending any data.
|
|
74
|
+
*
|
|
75
|
+
* E.g. Sending value without passing a bytes4 function selector to call a LSP17 Extension.
|
|
76
|
+
*
|
|
77
|
+
* @notice LSP7 contract cannot receive native tokens.
|
|
78
|
+
*/
|
|
79
|
+
error LSP7TokenContractCannotHoldValue();
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @dev Reverts when token owner call {increaseAllowance} for an operator that does not have any allowance
|
|
83
|
+
*/
|
|
84
|
+
error OperatorAllowanceCannotBeIncreasedFromZero(address operator);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// SPDX-License-Identifier:
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
pragma solidity ^0.8.4;
|
|
3
3
|
|
|
4
4
|
// modules
|
|
@@ -17,6 +17,10 @@ abstract contract LSP7Burnable is LSP7DigitalAsset {
|
|
|
17
17
|
uint256 amount,
|
|
18
18
|
bytes memory data
|
|
19
19
|
) public virtual {
|
|
20
|
+
if (msg.sender != from) {
|
|
21
|
+
_spendAllowance(msg.sender, from, amount);
|
|
22
|
+
}
|
|
23
|
+
|
|
20
24
|
_burn(from, amount, data);
|
|
21
25
|
}
|
|
22
26
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// SPDX-License-Identifier:
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
pragma solidity ^0.8.4;
|
|
3
3
|
|
|
4
4
|
// modules
|
|
@@ -19,6 +19,9 @@ abstract contract LSP7BurnableInitAbstract is LSP7DigitalAssetInitAbstract {
|
|
|
19
19
|
uint256 amount,
|
|
20
20
|
bytes memory data
|
|
21
21
|
) public virtual {
|
|
22
|
+
if (msg.sender != from) {
|
|
23
|
+
_spendAllowance(msg.sender, from, amount);
|
|
24
|
+
}
|
|
22
25
|
_burn(from, amount, data);
|
|
23
26
|
}
|
|
24
27
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// SPDX-License-Identifier:
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
|
|
3
3
|
pragma solidity ^0.8.4;
|
|
4
4
|
|
|
@@ -24,7 +24,7 @@ abstract contract LSP7CappedSupply is LSP7DigitalAsset {
|
|
|
24
24
|
error LSP7CappedSupplyCannotMintOverCap();
|
|
25
25
|
|
|
26
26
|
// --- Storage
|
|
27
|
-
uint256 private immutable
|
|
27
|
+
uint256 private immutable _TOKEN_SUPPLY_CAP;
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* @notice Deploying a `LSP7CappedSupply` token contract with max token supply cap set to `tokenSupplyCap_`.
|
|
@@ -41,13 +41,13 @@ abstract contract LSP7CappedSupply is LSP7DigitalAsset {
|
|
|
41
41
|
revert LSP7CappedSupplyRequired();
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
_TOKEN_SUPPLY_CAP = tokenSupplyCap_;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
// --- Token queries
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
|
-
* @notice The maximum supply amount of tokens allowed to exist is `
|
|
50
|
+
* @notice The maximum supply amount of tokens allowed to exist is `_TOKEN_SUPPLY_CAP`.
|
|
51
51
|
*
|
|
52
52
|
* @dev Get the maximum number of tokens that can exist to circulate. Once {totalSupply} reaches
|
|
53
53
|
* reaches {totalSuuplyCap}, it is not possible to mint more tokens.
|
|
@@ -55,7 +55,7 @@ abstract contract LSP7CappedSupply is LSP7DigitalAsset {
|
|
|
55
55
|
* @return The maximum number of tokens that can exist in the contract.
|
|
56
56
|
*/
|
|
57
57
|
function tokenSupplyCap() public view virtual returns (uint256) {
|
|
58
|
-
return
|
|
58
|
+
return _TOKEN_SUPPLY_CAP;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
// --- Transfer functionality
|
|
@@ -71,13 +71,13 @@ abstract contract LSP7CappedSupply is LSP7DigitalAsset {
|
|
|
71
71
|
function _mint(
|
|
72
72
|
address to,
|
|
73
73
|
uint256 amount,
|
|
74
|
-
bool
|
|
74
|
+
bool force,
|
|
75
75
|
bytes memory data
|
|
76
76
|
) internal virtual override {
|
|
77
77
|
if (totalSupply() + amount > tokenSupplyCap()) {
|
|
78
78
|
revert LSP7CappedSupplyCannotMintOverCap();
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
super._mint(to, amount,
|
|
81
|
+
super._mint(to, amount, force, data);
|
|
82
82
|
}
|
|
83
83
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// SPDX-License-Identifier:
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
|
|
3
3
|
pragma solidity ^0.8.4;
|
|
4
4
|
|
|
@@ -74,13 +74,13 @@ abstract contract LSP7CappedSupplyInitAbstract is LSP7DigitalAssetInitAbstract {
|
|
|
74
74
|
function _mint(
|
|
75
75
|
address to,
|
|
76
76
|
uint256 amount,
|
|
77
|
-
bool
|
|
77
|
+
bool force,
|
|
78
78
|
bytes memory data
|
|
79
79
|
) internal virtual override {
|
|
80
80
|
if (totalSupply() + amount > tokenSupplyCap()) {
|
|
81
81
|
revert LSP7CappedSupplyCannotMintOverCap();
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
super._mint(to, amount,
|
|
84
|
+
super._mint(to, amount, force, data);
|
|
85
85
|
}
|
|
86
86
|
}
|
|
@@ -1,29 +1,25 @@
|
|
|
1
|
-
// SPDX-License-Identifier:
|
|
2
|
-
pragma solidity ^0.8.
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
pragma solidity ^0.8.7;
|
|
3
3
|
|
|
4
4
|
// interfaces
|
|
5
|
-
import {
|
|
6
|
-
|
|
5
|
+
import {
|
|
6
|
+
IERC20Metadata,
|
|
7
|
+
IERC20
|
|
8
|
+
} from "@openzeppelin/contracts/interfaces/IERC20Metadata.sol";
|
|
7
9
|
|
|
8
10
|
// modules
|
|
11
|
+
import {LSP7DigitalAssetCore, LSP7DigitalAsset} from "../LSP7DigitalAsset.sol";
|
|
12
|
+
|
|
13
|
+
// constants
|
|
9
14
|
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
LSP7DigitalAsset,
|
|
14
|
-
LSP7DigitalAssetCore,
|
|
15
|
-
LSP4DigitalAssetMetadata,
|
|
16
|
-
ERC725YCore
|
|
17
|
-
} from "../LSP7DigitalAsset.sol";
|
|
15
|
+
_LSP4_TOKEN_NAME_KEY,
|
|
16
|
+
_LSP4_TOKEN_SYMBOL_KEY
|
|
17
|
+
} from "../../LSP4DigitalAssetMetadata/LSP4Constants.sol";
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* @dev LSP7 extension, for compatibility for clients / tools that expect ERC20.
|
|
21
21
|
*/
|
|
22
|
-
abstract contract LSP7CompatibleERC20 is
|
|
23
|
-
ILSP7CompatibleERC20,
|
|
24
|
-
LSP4Compatibility,
|
|
25
|
-
LSP7DigitalAsset
|
|
26
|
-
{
|
|
22
|
+
abstract contract LSP7CompatibleERC20 is IERC20Metadata, LSP7DigitalAsset {
|
|
27
23
|
/**
|
|
28
24
|
* @notice Deploying a `LSP7CompatibleERC20` token contract with: token name = `name_`, token symbol = `symbol_`, and
|
|
29
25
|
* address `newOwner_` as the token contract owner.
|
|
@@ -39,22 +35,90 @@ abstract contract LSP7CompatibleERC20 is
|
|
|
39
35
|
) LSP7DigitalAsset(name_, symbol_, newOwner_, false) {}
|
|
40
36
|
|
|
41
37
|
/**
|
|
42
|
-
* @inheritdoc
|
|
38
|
+
* @inheritdoc IERC20Metadata
|
|
39
|
+
* @dev Returns the name of the token.
|
|
40
|
+
* For compatibility with clients & tools that expect ERC20.
|
|
41
|
+
*
|
|
42
|
+
* @return The name of the token
|
|
43
43
|
*/
|
|
44
|
-
function
|
|
45
|
-
|
|
44
|
+
function name() public view virtual override returns (string memory) {
|
|
45
|
+
bytes memory data = _getData(_LSP4_TOKEN_NAME_KEY);
|
|
46
|
+
return string(data);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @inheritdoc IERC20Metadata
|
|
51
|
+
* @dev Returns the symbol of the token, usually a shorter version of the name.
|
|
52
|
+
* For compatibility with clients & tools that expect ERC20.
|
|
53
|
+
*
|
|
54
|
+
* @return The symbol of the token
|
|
55
|
+
*/
|
|
56
|
+
function symbol() public view virtual override returns (string memory) {
|
|
57
|
+
bytes memory data = _getData(_LSP4_TOKEN_SYMBOL_KEY);
|
|
58
|
+
return string(data);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @inheritdoc LSP7DigitalAssetCore
|
|
63
|
+
*/
|
|
64
|
+
function decimals()
|
|
65
|
+
public
|
|
66
|
+
view
|
|
67
|
+
virtual
|
|
68
|
+
override(IERC20Metadata, LSP7DigitalAssetCore)
|
|
69
|
+
returns (uint8)
|
|
70
|
+
{
|
|
71
|
+
return super.decimals();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @inheritdoc LSP7DigitalAssetCore
|
|
76
|
+
*/
|
|
77
|
+
function totalSupply()
|
|
78
|
+
public
|
|
79
|
+
view
|
|
80
|
+
virtual
|
|
81
|
+
override(IERC20, LSP7DigitalAssetCore)
|
|
82
|
+
returns (uint256)
|
|
83
|
+
{
|
|
84
|
+
return super.totalSupply();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @inheritdoc LSP7DigitalAssetCore
|
|
89
|
+
*/
|
|
90
|
+
function balanceOf(
|
|
91
|
+
address tokenOwner
|
|
46
92
|
)
|
|
47
93
|
public
|
|
48
94
|
view
|
|
49
95
|
virtual
|
|
50
|
-
override(
|
|
51
|
-
returns (
|
|
96
|
+
override(IERC20, LSP7DigitalAssetCore)
|
|
97
|
+
returns (uint256)
|
|
52
98
|
{
|
|
53
|
-
return super.
|
|
99
|
+
return super.balanceOf(tokenOwner);
|
|
54
100
|
}
|
|
55
101
|
|
|
56
102
|
/**
|
|
57
|
-
* @inheritdoc
|
|
103
|
+
* @inheritdoc LSP7DigitalAsset
|
|
104
|
+
*/
|
|
105
|
+
function supportsInterface(
|
|
106
|
+
bytes4 interfaceId
|
|
107
|
+
) public view virtual override returns (bool) {
|
|
108
|
+
return
|
|
109
|
+
interfaceId == type(IERC20).interfaceId ||
|
|
110
|
+
interfaceId == type(IERC20Metadata).interfaceId ||
|
|
111
|
+
super.supportsInterface(interfaceId);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* @inheritdoc IERC20
|
|
116
|
+
* @dev Function to get operator allowance allowed to spend on behalf of `tokenOwner` from the ERC20 standard interface.
|
|
117
|
+
*
|
|
118
|
+
* @param tokenOwner The address of the token owner
|
|
119
|
+
* @param operator The address approved by the `tokenOwner`
|
|
120
|
+
*
|
|
121
|
+
* @return The amount `operator` is approved by `tokenOwner`
|
|
58
122
|
*/
|
|
59
123
|
function allowance(
|
|
60
124
|
address tokenOwner,
|
|
@@ -64,20 +128,38 @@ abstract contract LSP7CompatibleERC20 is
|
|
|
64
128
|
}
|
|
65
129
|
|
|
66
130
|
/**
|
|
67
|
-
* @inheritdoc
|
|
131
|
+
* @inheritdoc IERC20
|
|
132
|
+
* @dev Approval function from th ERC20 standard interface.
|
|
133
|
+
*
|
|
134
|
+
* @param operator The address to approve for `amount`
|
|
135
|
+
* @param amount The amount to approve.
|
|
136
|
+
*
|
|
137
|
+
* @return `true` on successful approval.
|
|
68
138
|
*/
|
|
69
139
|
function approve(
|
|
70
140
|
address operator,
|
|
71
141
|
uint256 amount
|
|
72
142
|
) public virtual returns (bool) {
|
|
73
|
-
|
|
143
|
+
if (amount != 0) {
|
|
144
|
+
authorizeOperator(operator, amount, "");
|
|
145
|
+
} else {
|
|
146
|
+
revokeOperator(operator, false, "");
|
|
147
|
+
}
|
|
148
|
+
|
|
74
149
|
return true;
|
|
75
150
|
}
|
|
76
151
|
|
|
77
152
|
/**
|
|
78
|
-
* @inheritdoc
|
|
153
|
+
* @inheritdoc IERC20
|
|
154
|
+
* @dev Transfer functions for operators from the ERC20 standard interface.
|
|
155
|
+
*
|
|
156
|
+
* @param from The address sending tokens.
|
|
157
|
+
* @param to The address receiving tokens.
|
|
158
|
+
* @param amount The amount of tokens to transfer.
|
|
159
|
+
*
|
|
160
|
+
* @return `true` on successful transfer.
|
|
79
161
|
*
|
|
80
|
-
* @custom:info This function uses the `
|
|
162
|
+
* @custom:info This function uses the `force` parameter as `true` so that EOA and any contract can receive tokens.
|
|
81
163
|
*/
|
|
82
164
|
function transferFrom(
|
|
83
165
|
address from,
|
|
@@ -91,9 +173,15 @@ abstract contract LSP7CompatibleERC20 is
|
|
|
91
173
|
// --- Overrides
|
|
92
174
|
|
|
93
175
|
/**
|
|
94
|
-
* @inheritdoc
|
|
176
|
+
* @inheritdoc IERC20
|
|
177
|
+
* @dev Transfer function from the ERC20 standard interface.
|
|
178
|
+
|
|
179
|
+
* @param to The address receiving tokens.
|
|
180
|
+
* @param amount The amount of tokens to transfer.
|
|
181
|
+
*
|
|
182
|
+
* @return `true` on successful transfer.
|
|
95
183
|
*
|
|
96
|
-
* @custom:info This function uses the `
|
|
184
|
+
* @custom:info This function uses the `force` parameter as `true` so that EOA and any contract can receive tokens.
|
|
97
185
|
*/
|
|
98
186
|
function transfer(
|
|
99
187
|
address to,
|
|
@@ -110,20 +198,20 @@ abstract contract LSP7CompatibleERC20 is
|
|
|
110
198
|
address tokenOwner,
|
|
111
199
|
address operator,
|
|
112
200
|
uint256 amount,
|
|
201
|
+
bool notified,
|
|
113
202
|
bytes memory operatorNotificationData
|
|
114
203
|
) internal virtual override {
|
|
115
204
|
super._updateOperator(
|
|
116
205
|
tokenOwner,
|
|
117
206
|
operator,
|
|
118
207
|
amount,
|
|
208
|
+
notified,
|
|
119
209
|
operatorNotificationData
|
|
120
210
|
);
|
|
121
|
-
emit Approval(tokenOwner, operator, amount);
|
|
211
|
+
emit IERC20.Approval(tokenOwner, operator, amount);
|
|
122
212
|
}
|
|
123
213
|
|
|
124
214
|
/**
|
|
125
|
-
* @inheritdoc LSP7DigitalAssetCore
|
|
126
|
-
*
|
|
127
215
|
* @custom:events
|
|
128
216
|
* - LSP7 {Transfer} event.
|
|
129
217
|
* - ERC20 {Transfer} event.
|
|
@@ -132,16 +220,14 @@ abstract contract LSP7CompatibleERC20 is
|
|
|
132
220
|
address from,
|
|
133
221
|
address to,
|
|
134
222
|
uint256 amount,
|
|
135
|
-
bool
|
|
223
|
+
bool force,
|
|
136
224
|
bytes memory data
|
|
137
225
|
) internal virtual override {
|
|
138
|
-
emit Transfer(from, to, amount);
|
|
139
|
-
super._transfer(from, to, amount,
|
|
226
|
+
emit IERC20.Transfer(from, to, amount);
|
|
227
|
+
super._transfer(from, to, amount, force, data);
|
|
140
228
|
}
|
|
141
229
|
|
|
142
230
|
/**
|
|
143
|
-
* @inheritdoc LSP7DigitalAssetCore
|
|
144
|
-
*
|
|
145
231
|
* @custom:events
|
|
146
232
|
* - LSP7 {Transfer} event with `address(0)` as `from`.
|
|
147
233
|
* - ERC20 {Transfer} event with `address(0)` as `from`.
|
|
@@ -149,16 +235,14 @@ abstract contract LSP7CompatibleERC20 is
|
|
|
149
235
|
function _mint(
|
|
150
236
|
address to,
|
|
151
237
|
uint256 amount,
|
|
152
|
-
bool
|
|
238
|
+
bool force,
|
|
153
239
|
bytes memory data
|
|
154
240
|
) internal virtual override {
|
|
155
|
-
emit Transfer(address(0), to, amount);
|
|
156
|
-
super._mint(to, amount,
|
|
241
|
+
emit IERC20.Transfer(address(0), to, amount);
|
|
242
|
+
super._mint(to, amount, force, data);
|
|
157
243
|
}
|
|
158
244
|
|
|
159
245
|
/**
|
|
160
|
-
* @inheritdoc LSP7DigitalAssetCore
|
|
161
|
-
*
|
|
162
246
|
* @custom:events
|
|
163
247
|
* - LSP7 {Transfer} event with `address(0)` as the `to` address.
|
|
164
248
|
* - ERC20 {Transfer} event with `address(0)` as the `to` address.
|
|
@@ -168,17 +252,7 @@ abstract contract LSP7CompatibleERC20 is
|
|
|
168
252
|
uint256 amount,
|
|
169
253
|
bytes memory data
|
|
170
254
|
) internal virtual override {
|
|
171
|
-
emit Transfer(from, address(0), amount);
|
|
255
|
+
emit IERC20.Transfer(from, address(0), amount);
|
|
172
256
|
super._burn(from, amount, data);
|
|
173
257
|
}
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* @inheritdoc LSP4DigitalAssetMetadata
|
|
177
|
-
*/
|
|
178
|
-
function _setData(
|
|
179
|
-
bytes32 key,
|
|
180
|
-
bytes memory value
|
|
181
|
-
) internal virtual override(LSP4DigitalAssetMetadata, ERC725YCore) {
|
|
182
|
-
super._setData(key, value);
|
|
183
|
-
}
|
|
184
258
|
}
|