@lukso/lsp-smart-contracts 0.5.0 → 0.6.2
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 +38 -9
- package/artifacts/Create2Factory.json +2 -2
- package/artifacts/LSP0ERC725Account.json +398 -0
- package/artifacts/LSP0ERC725AccountInit.json +444 -0
- package/artifacts/LSP1UniversalReceiverDelegateUP.json +21 -5
- package/artifacts/LSP1UniversalReceiverDelegateVault.json +21 -5
- package/artifacts/LSP4Compatibility.json +195 -0
- package/artifacts/LSP4DigitalAssetMetadata.json +179 -0
- package/artifacts/LSP4DigitalAssetMetadataInit.json +241 -0
- package/artifacts/LSP6KeyManager.json +110 -35
- package/artifacts/LSP6KeyManagerInit.json +123 -30
- package/artifacts/LSP7CappedSupply.json +146 -11
- package/artifacts/LSP7CappedSupplyInit.json +167 -57
- package/artifacts/LSP7CompatibleERC20.json +714 -0
- package/artifacts/LSP7CompatibleERC20Init.json +760 -0
- package/artifacts/LSP7CompatibleERC20Mintable.json +742 -0
- package/artifacts/LSP7CompatibleERC20MintableInit.json +783 -0
- package/artifacts/LSP7DigitalAsset.json +138 -13
- package/artifacts/LSP7DigitalAssetInit.json +167 -34
- package/artifacts/LSP7Mintable.json +139 -14
- package/artifacts/LSP7MintableInit.json +168 -35
- package/artifacts/LSP8CappedSupply.json +147 -11
- package/artifacts/LSP8CappedSupplyInit.json +176 -37
- package/artifacts/LSP8CompatibleERC721.json +842 -0
- package/artifacts/LSP8CompatibleERC721Init.json +883 -0
- package/artifacts/LSP8CompatibleERC721Mintable.json +881 -0
- package/artifacts/LSP8CompatibleERC721MintableInit.json +922 -0
- package/artifacts/LSP8IdentifiableDigitalAsset.json +139 -13
- package/artifacts/LSP8IdentifiableDigitalAssetInit.json +176 -19
- package/artifacts/LSP8Mintable.json +151 -14
- package/artifacts/LSP8MintableInit.json +188 -20
- package/artifacts/LSP9Vault.json +374 -0
- package/artifacts/LSP9VaultInit.json +420 -0
- package/artifacts/UniversalFactory.json +127 -0
- package/artifacts/UniversalProfile.json +89 -32
- package/artifacts/UniversalProfileInit.json +133 -32
- package/artifacts/UniversalReceiverAddressStore.json +209 -0
- package/constants.js +535 -0
- package/contracts/Custom/ClaimOwnership.sol +34 -0
- package/contracts/Custom/ERC165Checker.sol +130 -0
- package/contracts/Custom/IClaimOwnership.sol +10 -0
- package/contracts/Factories/Create2Factory.sol +3 -13
- package/contracts/Factories/UniversalFactory.sol +164 -0
- package/contracts/LSP0ERC725Account/LSP0Constants.sol +5 -9
- package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +7 -9
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +108 -55
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +11 -4
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +6 -21
- package/contracts/LSP10ReceivedVaults/LSP10Constants.sol +10 -0
- package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiver.sol +3 -0
- package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiverDelegate.sol +4 -2
- package/contracts/LSP1UniversalReceiver/LSP1Constants.sol +3 -9
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/Handling/TokenAndVaultHandling.sol +67 -184
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +58 -6
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/Handling/TokenHandling.sol +51 -89
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +46 -6
- package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +62 -0
- package/contracts/LSP2ERC725YJSONSchema/LSP2Errors.sol +9 -0
- package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +201 -0
- package/contracts/LSP3UniversalProfile/LSP3Constants.sol +11 -0
- package/contracts/LSP4DigitalAssetMetadata/ILSP4Compatibility.sol +1 -1
- package/contracts/LSP4DigitalAssetMetadata/LSP4Compatibility.sol +5 -14
- package/contracts/LSP4DigitalAssetMetadata/LSP4Constants.sol +10 -4
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol +22 -8
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInit.sol +9 -13
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +26 -20
- package/contracts/LSP4DigitalAssetMetadata/LSP4Errors.sol +16 -0
- package/contracts/LSP5ReceivedAssets/LSP5Constants.sol +10 -0
- package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +231 -0
- package/contracts/LSP6KeyManager/ILSP6KeyManager.sol +28 -25
- package/contracts/LSP6KeyManager/LSP6Constants.sol +61 -25
- package/contracts/LSP6KeyManager/LSP6Errors.sol +66 -0
- package/contracts/LSP6KeyManager/LSP6KeyManager.sol +7 -6
- package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +465 -378
- package/contracts/LSP6KeyManager/LSP6KeyManagerInit.sol +13 -5
- package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +9 -15
- package/contracts/LSP6KeyManager/LSP6Utils.sol +107 -0
- package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +3 -8
- package/contracts/LSP7DigitalAsset/LSP7Constants.sol +5 -4
- package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +27 -9
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +73 -95
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInit.sol +19 -9
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +27 -23
- package/contracts/LSP7DigitalAsset/LSP7Errors.sol +23 -0
- package/contracts/LSP7DigitalAsset/extensions/ILSP7CappedSupply.sol +1 -1
- package/contracts/LSP7DigitalAsset/extensions/{ILSP7CompatibilityForERC20.sol → ILSP7CompatibleERC20.sol} +7 -9
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupply.sol +8 -7
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyCore.sol +14 -12
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInit.sol +3 -8
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInitAbstract.sol +10 -15
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.sol +67 -0
- package/contracts/LSP7DigitalAsset/extensions/{LSP7CompatibilityForERC20Core.sol → LSP7CompatibleERC20Core.sol} +36 -50
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20Init.sol +29 -0
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20InitAbstract.sol +67 -0
- package/contracts/LSP7DigitalAsset/{extensions → presets}/ILSP7Mintable.sol +1 -1
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.sol +22 -0
- package/contracts/LSP7DigitalAsset/{extensions/LSP7CompatibilityForERC20Init.sol → presets/LSP7CompatibleERC20MintableInit.sol} +6 -5
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInitAbstract.sol +27 -0
- package/contracts/LSP7DigitalAsset/{extensions → presets}/LSP7Mintable.sol +4 -3
- package/contracts/LSP7DigitalAsset/{extensions → presets}/LSP7MintableCore.sol +5 -5
- package/contracts/LSP7DigitalAsset/{extensions → presets}/LSP7MintableInit.sol +11 -3
- package/contracts/LSP7DigitalAsset/presets/LSP7MintableInitAbstract.sol +34 -0
- package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +5 -16
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol +6 -3
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol +22 -0
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +23 -10
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +103 -136
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInit.sol +17 -11
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +26 -21
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CappedSupply.sol +1 -1
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/{ILSP8CompatibilityForERC721.sol → ILSP8CompatibleERC721.sol} +4 -12
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.sol +9 -15
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyCore.sol +14 -12
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInit.sol +3 -8
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInitAbstract.sol +13 -20
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/{LSP8CompatibilityConstants.sol → LSP8CompatibleConstants.sol} +0 -0
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +101 -0
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/{LSP8CompatibilityForERC721Core.sol → LSP8CompatibleERC721Core.sol} +38 -95
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/{LSP8CompatibilityForERC721Init.sol → LSP8CompatibleERC721Init.sol} +4 -6
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +93 -0
- package/contracts/LSP8IdentifiableDigitalAsset/{extensions → presets}/ILSP8Mintable.sol +1 -1
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.sol +22 -0
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInit.sol +23 -0
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInitAbstract.sol +27 -0
- package/contracts/LSP8IdentifiableDigitalAsset/{extensions → presets}/LSP8Mintable.sol +4 -3
- package/contracts/LSP8IdentifiableDigitalAsset/{extensions → presets}/LSP8MintableCore.sol +5 -8
- package/contracts/LSP8IdentifiableDigitalAsset/{extensions → presets}/LSP8MintableInit.sol +11 -3
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +37 -0
- package/contracts/LSP9Vault/LSP9Constants.sol +14 -5
- package/contracts/LSP9Vault/LSP9Vault.sol +20 -38
- package/contracts/LSP9Vault/LSP9VaultCore.sol +123 -92
- package/contracts/LSP9Vault/LSP9VaultInit.sol +12 -4
- package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +20 -46
- package/contracts/Legacy/Registries/AddressRegistry.sol +43 -0
- package/contracts/Legacy/Registries/AddressRegistryRequiresERC725.sol +33 -0
- package/contracts/Legacy/UniversalReceiverAddressStore.sol +62 -0
- package/contracts/UniversalProfile.sol +11 -7
- package/contracts/UniversalProfileInit.sol +12 -4
- package/contracts/UniversalProfileInitAbstract.sol +12 -20
- package/contracts/Utils/UtilsLib.sol +21 -13
- package/package.json +23 -9
- package/artifacts/LSP1UniversalReceiverDelegateUPInit.json +0 -66
- package/artifacts/LSP1UniversalReceiverDelegateVaultInit.json +0 -66
- package/artifacts/LSP7CompatibilityForERC20.json +0 -571
- package/artifacts/LSP8CompatibilityForERC721.json +0 -716
- package/constants.ts +0 -356
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUPCore.sol +0 -52
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUPInit.sol +0 -26
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUPInitAbstract.sol +0 -28
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVaultCore.sol +0 -41
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVaultInit.sol +0 -23
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVaultInitAbstract.sol +0 -25
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibilityForERC20.sol +0 -56
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibilityForERC20InitAbstract.sol +0 -55
- package/contracts/LSP7DigitalAsset/extensions/LSP7MintableInitAbstract.sol +0 -47
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibilityForERC721.sol +0 -92
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibilityForERC721InitAbstract.sol +0 -90
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8MintableInitAbstract.sol +0 -44
- package/contracts/Utils/ERC725Utils.sol +0 -169
- package/contracts/Utils/LSP2Utils.sol +0 -127
- package/contracts/Utils/LSP6Utils.sol +0 -63
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
// SPDX-License-Identifier: CC0-1.0
|
|
2
2
|
pragma solidity ^0.8.0;
|
|
3
3
|
|
|
4
|
-
//
|
|
5
|
-
import "
|
|
6
|
-
import "../LSP4DigitalAssetMetadata/LSP4Constants.sol";
|
|
4
|
+
// interfaces
|
|
5
|
+
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
|
|
7
6
|
|
|
8
7
|
// modules
|
|
9
|
-
import "
|
|
10
|
-
import
|
|
8
|
+
import {ERC725YCore} from "@erc725/smart-contracts/contracts/ERC725YCore.sol";
|
|
9
|
+
import {
|
|
10
|
+
LSP4DigitalAssetMetadataInitAbstract
|
|
11
|
+
} from "../LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol";
|
|
12
|
+
import {LSP7DigitalAssetCore} from "./LSP7DigitalAssetCore.sol";
|
|
13
|
+
|
|
14
|
+
// constants
|
|
15
|
+
import {_INTERFACEID_LSP7} from "./LSP7Constants.sol";
|
|
11
16
|
|
|
12
17
|
/**
|
|
13
18
|
* @title LSP7DigitalAsset contract
|
|
@@ -15,30 +20,29 @@ import "../LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol";
|
|
|
15
20
|
* @dev Proxy Implementation of a LSP7 compliant contract.
|
|
16
21
|
*/
|
|
17
22
|
abstract contract LSP7DigitalAssetInitAbstract is
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
LSP4DigitalAssetMetadataInitAbstract
|
|
23
|
+
LSP4DigitalAssetMetadataInitAbstract,
|
|
24
|
+
LSP7DigitalAssetCore
|
|
21
25
|
{
|
|
22
|
-
|
|
23
|
-
* @notice Sets the token-Metadata and register LSP7InterfaceId
|
|
24
|
-
* @param name_ The name of the token
|
|
25
|
-
* @param symbol_ The symbol of the token
|
|
26
|
-
* @param newOwner_ The owner of the the token-Metadata
|
|
27
|
-
* @param isNFT_ Specify if the LSP7 token is a fungible or non-fungible token
|
|
28
|
-
*/
|
|
29
|
-
function initialize(
|
|
26
|
+
function _initialize(
|
|
30
27
|
string memory name_,
|
|
31
28
|
string memory symbol_,
|
|
32
29
|
address newOwner_,
|
|
33
30
|
bool isNFT_
|
|
34
|
-
)
|
|
31
|
+
) internal virtual onlyInitializing {
|
|
35
32
|
_isNFT = isNFT_;
|
|
36
|
-
LSP4DigitalAssetMetadataInitAbstract.
|
|
37
|
-
|
|
38
|
-
symbol_,
|
|
39
|
-
newOwner_
|
|
40
|
-
);
|
|
33
|
+
LSP4DigitalAssetMetadataInitAbstract._initialize(name_, symbol_, newOwner_);
|
|
34
|
+
}
|
|
41
35
|
|
|
42
|
-
|
|
36
|
+
/**
|
|
37
|
+
* @dev See {IERC165-supportsInterface}.
|
|
38
|
+
*/
|
|
39
|
+
function supportsInterface(bytes4 interfaceId)
|
|
40
|
+
public
|
|
41
|
+
view
|
|
42
|
+
virtual
|
|
43
|
+
override(IERC165, ERC725YCore)
|
|
44
|
+
returns (bool)
|
|
45
|
+
{
|
|
46
|
+
return interfaceId == _INTERFACEID_LSP7 || super.supportsInterface(interfaceId);
|
|
43
47
|
}
|
|
44
48
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// SPDX-License-Identifier: CC0-1.0
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
// --- Errors
|
|
5
|
+
|
|
6
|
+
error LSP7AmountExceedsBalance(uint256 balance, address tokenOwner, uint256 amount);
|
|
7
|
+
|
|
8
|
+
error LSP7AmountExceedsAuthorizedAmount(
|
|
9
|
+
address tokenOwner,
|
|
10
|
+
uint256 authorizedAmount,
|
|
11
|
+
address operator,
|
|
12
|
+
uint256 amount
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
error LSP7CannotUseAddressZeroAsOperator();
|
|
16
|
+
|
|
17
|
+
error LSP7CannotSendWithAddressZero();
|
|
18
|
+
|
|
19
|
+
error LSP7InvalidTransferBatch();
|
|
20
|
+
|
|
21
|
+
error LSP7NotifyTokenReceiverContractMissingLSP1Interface(address tokenReceiver);
|
|
22
|
+
|
|
23
|
+
error LSP7NotifyTokenReceiverIsEOA(address tokenReceiver);
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
pragma solidity ^0.8.0;
|
|
4
4
|
|
|
5
5
|
// interfaces
|
|
6
|
-
import "../ILSP7DigitalAsset.sol";
|
|
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,7 +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)
|
|
63
|
-
external
|
|
64
|
-
returns (uint256);
|
|
62
|
+
function allowance(address tokenOwner, address operator) external view returns (uint256);
|
|
65
63
|
}
|
|
@@ -3,22 +3,23 @@
|
|
|
3
3
|
pragma solidity ^0.8.0;
|
|
4
4
|
|
|
5
5
|
// modules
|
|
6
|
-
import "
|
|
7
|
-
import "../
|
|
6
|
+
import {LSP7DigitalAsset} from "../LSP7DigitalAsset.sol";
|
|
7
|
+
import {LSP7DigitalAssetCore} from "../LSP7DigitalAssetCore.sol";
|
|
8
|
+
import {LSP7CappedSupplyCore} from "./LSP7CappedSupplyCore.sol";
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* @dev LSP7 extension, adds token supply cap.
|
|
11
12
|
*/
|
|
12
|
-
abstract contract LSP7CappedSupply is
|
|
13
|
+
abstract contract LSP7CappedSupply is LSP7DigitalAsset, LSP7CappedSupplyCore {
|
|
13
14
|
/**
|
|
14
15
|
* @notice Sets the token max supply
|
|
15
16
|
* @param tokenSupplyCap_ The Token max supply
|
|
16
17
|
*/
|
|
17
18
|
constructor(uint256 tokenSupplyCap_) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
if (tokenSupplyCap_ == 0) {
|
|
20
|
+
revert LSP7CappedSupplyRequired();
|
|
21
|
+
}
|
|
22
|
+
|
|
22
23
|
_tokenSupplyCap = tokenSupplyCap_;
|
|
23
24
|
}
|
|
24
25
|
|
|
@@ -2,19 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
pragma solidity ^0.8.0;
|
|
4
4
|
|
|
5
|
-
// modules
|
|
6
|
-
import "../LSP7DigitalAssetCore.sol";
|
|
7
|
-
|
|
8
5
|
// interfaces
|
|
9
|
-
import "./ILSP7CappedSupply.sol";
|
|
6
|
+
import {ILSP7CappedSupply} from "./ILSP7CappedSupply.sol";
|
|
7
|
+
|
|
8
|
+
// modules
|
|
9
|
+
import {LSP7DigitalAssetCore} from "../LSP7DigitalAssetCore.sol";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* @dev LSP7 extension, adds token supply cap.
|
|
13
13
|
*/
|
|
14
|
-
abstract contract LSP7CappedSupplyCore is
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
abstract contract LSP7CappedSupplyCore is LSP7DigitalAssetCore, ILSP7CappedSupply {
|
|
15
|
+
// --- Errors
|
|
16
|
+
|
|
17
|
+
error LSP7CappedSupplyRequired();
|
|
18
|
+
error LSP7CappedSupplyCannotMintOverCap();
|
|
19
|
+
|
|
18
20
|
// --- Storage
|
|
19
21
|
|
|
20
22
|
uint256 internal _tokenSupplyCap;
|
|
@@ -46,10 +48,10 @@ abstract contract LSP7CappedSupplyCore is
|
|
|
46
48
|
bool force,
|
|
47
49
|
bytes memory data
|
|
48
50
|
) internal virtual override {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
if (totalSupply() + amount > tokenSupplyCap()) {
|
|
52
|
+
revert LSP7CappedSupplyCannotMintOverCap();
|
|
53
|
+
}
|
|
54
|
+
|
|
53
55
|
super._mint(to, amount, force, data);
|
|
54
56
|
}
|
|
55
57
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
pragma solidity ^0.8.0;
|
|
4
4
|
|
|
5
5
|
// modules
|
|
6
|
-
import "./LSP7CappedSupplyInitAbstract.sol";
|
|
6
|
+
import {LSP7CappedSupplyInitAbstract} from "./LSP7CappedSupplyInitAbstract.sol";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @dev LSP7 extension, adds token supply cap.
|
|
@@ -13,12 +13,7 @@ abstract contract LSP7CappedSupplyInit is LSP7CappedSupplyInitAbstract {
|
|
|
13
13
|
* @notice Sets the token max supply
|
|
14
14
|
* @param tokenSupplyCap_ The Token max supply
|
|
15
15
|
*/
|
|
16
|
-
function initialize(uint256 tokenSupplyCap_)
|
|
17
|
-
|
|
18
|
-
virtual
|
|
19
|
-
override
|
|
20
|
-
initializer
|
|
21
|
-
{
|
|
22
|
-
LSP7CappedSupplyInitAbstract.initialize(tokenSupplyCap_);
|
|
16
|
+
function initialize(uint256 tokenSupplyCap_) public virtual initializer {
|
|
17
|
+
LSP7CappedSupplyInitAbstract._initialize(tokenSupplyCap_);
|
|
23
18
|
}
|
|
24
19
|
}
|
|
@@ -3,27 +3,22 @@
|
|
|
3
3
|
pragma solidity ^0.8.0;
|
|
4
4
|
|
|
5
5
|
// modules
|
|
6
|
-
import "
|
|
7
|
-
import "../
|
|
6
|
+
import {LSP7DigitalAssetInitAbstract} from "../LSP7DigitalAssetInitAbstract.sol";
|
|
7
|
+
import {LSP7DigitalAssetCore} from "../LSP7DigitalAssetCore.sol";
|
|
8
|
+
import {LSP7CappedSupplyCore} from "./LSP7CappedSupplyCore.sol";
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* @dev LSP7 extension, adds token supply cap.
|
|
11
12
|
*/
|
|
12
13
|
abstract contract LSP7CappedSupplyInitAbstract is
|
|
13
|
-
|
|
14
|
-
LSP7CappedSupplyCore
|
|
15
|
-
LSP7DigitalAssetInit
|
|
14
|
+
LSP7DigitalAssetInitAbstract,
|
|
15
|
+
LSP7CappedSupplyCore
|
|
16
16
|
{
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
public
|
|
23
|
-
virtual
|
|
24
|
-
onlyInitializing
|
|
25
|
-
{
|
|
26
|
-
require(tokenSupplyCap_ > 0, "LSP7Capped: tokenSupplyCap is zero");
|
|
17
|
+
function _initialize(uint256 tokenSupplyCap_) internal virtual onlyInitializing {
|
|
18
|
+
if (tokenSupplyCap_ == 0) {
|
|
19
|
+
revert LSP7CappedSupplyRequired();
|
|
20
|
+
}
|
|
21
|
+
|
|
27
22
|
_tokenSupplyCap = tokenSupplyCap_;
|
|
28
23
|
}
|
|
29
24
|
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
// modules
|
|
5
|
+
import {LSP7DigitalAsset, LSP4DigitalAssetMetadata, ERC725YCore} from "../LSP7DigitalAsset.sol";
|
|
6
|
+
import {LSP7DigitalAssetCore} from "../LSP7DigitalAssetCore.sol";
|
|
7
|
+
import {LSP7CompatibleERC20Core} from "./LSP7CompatibleERC20Core.sol";
|
|
8
|
+
|
|
9
|
+
contract LSP7CompatibleERC20 is LSP7DigitalAsset, LSP7CompatibleERC20Core {
|
|
10
|
+
/* solhint-disable no-empty-blocks */
|
|
11
|
+
/**
|
|
12
|
+
* @notice Sets the name, the symbol and the owner of the token
|
|
13
|
+
* @param name_ The name of the token
|
|
14
|
+
* @param symbol_ The symbol of the token
|
|
15
|
+
* @param newOwner_ The owner of the token
|
|
16
|
+
*/
|
|
17
|
+
constructor(
|
|
18
|
+
string memory name_,
|
|
19
|
+
string memory symbol_,
|
|
20
|
+
address newOwner_
|
|
21
|
+
) LSP7DigitalAsset(name_, symbol_, newOwner_, false) {}
|
|
22
|
+
|
|
23
|
+
// --- Overrides
|
|
24
|
+
|
|
25
|
+
function authorizeOperator(address operator, uint256 amount)
|
|
26
|
+
public
|
|
27
|
+
virtual
|
|
28
|
+
override(LSP7DigitalAssetCore, LSP7CompatibleERC20Core)
|
|
29
|
+
{
|
|
30
|
+
super.authorizeOperator(operator, amount);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function _burn(
|
|
34
|
+
address from,
|
|
35
|
+
uint256 amount,
|
|
36
|
+
bytes memory data
|
|
37
|
+
) internal virtual override(LSP7DigitalAssetCore, LSP7CompatibleERC20Core) {
|
|
38
|
+
super._burn(from, amount, data);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function _mint(
|
|
42
|
+
address to,
|
|
43
|
+
uint256 amount,
|
|
44
|
+
bool force,
|
|
45
|
+
bytes memory data
|
|
46
|
+
) internal virtual override(LSP7DigitalAssetCore, LSP7CompatibleERC20Core) {
|
|
47
|
+
super._mint(to, amount, force, data);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function _transfer(
|
|
51
|
+
address from,
|
|
52
|
+
address to,
|
|
53
|
+
uint256 amount,
|
|
54
|
+
bool force,
|
|
55
|
+
bytes memory data
|
|
56
|
+
) internal virtual override(LSP7DigitalAssetCore, LSP7CompatibleERC20Core) {
|
|
57
|
+
super._transfer(from, to, amount, force, data);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function _setData(bytes32 key, bytes memory value)
|
|
61
|
+
internal
|
|
62
|
+
virtual
|
|
63
|
+
override(LSP4DigitalAssetMetadata, ERC725YCore)
|
|
64
|
+
{
|
|
65
|
+
super._setData(key, value);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -2,37 +2,37 @@
|
|
|
2
2
|
|
|
3
3
|
pragma solidity ^0.8.0;
|
|
4
4
|
|
|
5
|
-
// modules
|
|
6
|
-
import "../../LSP4DigitalAssetMetadata/LSP4Compatibility.sol";
|
|
7
|
-
import "../LSP7DigitalAssetCore.sol";
|
|
8
|
-
|
|
9
5
|
// interfaces
|
|
10
|
-
import "
|
|
6
|
+
import {ILSP7DigitalAsset} from "../ILSP7DigitalAsset.sol";
|
|
7
|
+
import {ILSP7CompatibleERC20} from "./ILSP7CompatibleERC20.sol";
|
|
8
|
+
|
|
9
|
+
// modules
|
|
10
|
+
import {LSP4Compatibility} from "../../LSP4DigitalAssetMetadata/LSP4Compatibility.sol";
|
|
11
|
+
import {LSP7DigitalAssetCore} from "../LSP7DigitalAssetCore.sol";
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* @dev LSP7 extension, for compatibility for clients / tools that expect ERC20.
|
|
14
15
|
*/
|
|
15
|
-
abstract contract
|
|
16
|
-
|
|
16
|
+
abstract contract LSP7CompatibleERC20Core is
|
|
17
|
+
LSP4Compatibility,
|
|
17
18
|
LSP7DigitalAssetCore,
|
|
18
|
-
|
|
19
|
+
ILSP7CompatibleERC20
|
|
19
20
|
{
|
|
21
|
+
// --- Overrides
|
|
22
|
+
|
|
20
23
|
/**
|
|
21
|
-
* @inheritdoc
|
|
24
|
+
* @inheritdoc ILSP7CompatibleERC20
|
|
22
25
|
*/
|
|
23
|
-
function approve(address operator, uint256 amount)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
override
|
|
27
|
-
{
|
|
28
|
-
return authorizeOperator(operator, amount);
|
|
26
|
+
function approve(address operator, uint256 amount) public virtual override returns (bool) {
|
|
27
|
+
authorizeOperator(operator, amount);
|
|
28
|
+
return true;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
|
-
* @inheritdoc
|
|
32
|
+
* @inheritdoc ILSP7CompatibleERC20
|
|
33
33
|
*/
|
|
34
34
|
function allowance(address tokenOwner, address operator)
|
|
35
|
-
|
|
35
|
+
public
|
|
36
36
|
view
|
|
37
37
|
virtual
|
|
38
38
|
override
|
|
@@ -42,16 +42,17 @@ abstract contract LSP7CompatibilityForERC20Core is
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
|
-
* @inheritdoc
|
|
45
|
+
* @inheritdoc ILSP7CompatibleERC20
|
|
46
46
|
* @dev Compatible with ERC20 transfer.
|
|
47
47
|
* Using force=true so that EOA and any contract may receive the tokens.
|
|
48
48
|
*/
|
|
49
|
-
function transfer(address to, uint256 amount)
|
|
50
|
-
|
|
49
|
+
function transfer(address to, uint256 amount) public virtual override returns (bool) {
|
|
50
|
+
transfer(_msgSender(), to, amount, true, "");
|
|
51
|
+
return true;
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
/**
|
|
54
|
-
* @inheritdoc
|
|
55
|
+
* @inheritdoc ILSP7CompatibleERC20
|
|
55
56
|
* @dev Compatible with ERC20 transferFrom.
|
|
56
57
|
* Using force=true so that EOA and any contract may receive the tokens.
|
|
57
58
|
*/
|
|
@@ -59,12 +60,11 @@ abstract contract LSP7CompatibilityForERC20Core is
|
|
|
59
60
|
address from,
|
|
60
61
|
address to,
|
|
61
62
|
uint256 amount
|
|
62
|
-
)
|
|
63
|
-
|
|
63
|
+
) public virtual override returns (bool) {
|
|
64
|
+
transfer(from, to, amount, true, "");
|
|
65
|
+
return true;
|
|
64
66
|
}
|
|
65
67
|
|
|
66
|
-
// --- Overrides
|
|
67
|
-
|
|
68
68
|
function authorizeOperator(address operator, uint256 amount)
|
|
69
69
|
public
|
|
70
70
|
virtual
|
|
@@ -72,13 +72,11 @@ abstract contract LSP7CompatibilityForERC20Core is
|
|
|
72
72
|
{
|
|
73
73
|
super.authorizeOperator(operator, amount);
|
|
74
74
|
|
|
75
|
-
emit Approval(
|
|
76
|
-
_msgSender(),
|
|
77
|
-
operator,
|
|
78
|
-
amount
|
|
79
|
-
);
|
|
75
|
+
emit Approval(_msgSender(), operator, amount);
|
|
80
76
|
}
|
|
81
77
|
|
|
78
|
+
// --- Internals
|
|
79
|
+
|
|
82
80
|
function _transfer(
|
|
83
81
|
address from,
|
|
84
82
|
address to,
|
|
@@ -88,11 +86,7 @@ abstract contract LSP7CompatibilityForERC20Core is
|
|
|
88
86
|
) internal virtual override {
|
|
89
87
|
super._transfer(from, to, amount, force, data);
|
|
90
88
|
|
|
91
|
-
emit Transfer(
|
|
92
|
-
from,
|
|
93
|
-
to,
|
|
94
|
-
amount
|
|
95
|
-
);
|
|
89
|
+
emit Transfer(from, to, amount);
|
|
96
90
|
}
|
|
97
91
|
|
|
98
92
|
function _mint(
|
|
@@ -103,24 +97,16 @@ abstract contract LSP7CompatibilityForERC20Core is
|
|
|
103
97
|
) internal virtual override {
|
|
104
98
|
super._mint(to, amount, force, data);
|
|
105
99
|
|
|
106
|
-
emit Transfer(
|
|
107
|
-
address(0),
|
|
108
|
-
to,
|
|
109
|
-
amount
|
|
110
|
-
);
|
|
100
|
+
emit Transfer(address(0), to, amount);
|
|
111
101
|
}
|
|
112
102
|
|
|
113
|
-
function _burn(
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
{
|
|
103
|
+
function _burn(
|
|
104
|
+
address from,
|
|
105
|
+
uint256 amount,
|
|
106
|
+
bytes memory data
|
|
107
|
+
) internal virtual override {
|
|
118
108
|
super._burn(from, amount, data);
|
|
119
109
|
|
|
120
|
-
emit Transfer(
|
|
121
|
-
from,
|
|
122
|
-
address(0),
|
|
123
|
-
amount
|
|
124
|
-
);
|
|
110
|
+
emit Transfer(from, address(0), amount);
|
|
125
111
|
}
|
|
126
112
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
|
|
3
|
+
pragma solidity ^0.8.0;
|
|
4
|
+
|
|
5
|
+
// modules
|
|
6
|
+
import {LSP7CompatibleERC20InitAbstract} from "./LSP7CompatibleERC20InitAbstract.sol";
|
|
7
|
+
|
|
8
|
+
contract LSP7CompatibleERC20Init is LSP7CompatibleERC20InitAbstract {
|
|
9
|
+
/**
|
|
10
|
+
* @dev initialize (= lock) base implementation contract on deployment
|
|
11
|
+
*/
|
|
12
|
+
constructor() {
|
|
13
|
+
_disableInitializers();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @notice Sets the name, the symbol and the owner of the token
|
|
18
|
+
* @param name_ The name of the token
|
|
19
|
+
* @param symbol_ The symbol of the token
|
|
20
|
+
* @param newOwner_ The owner of the token
|
|
21
|
+
*/
|
|
22
|
+
function initialize(
|
|
23
|
+
string memory name_,
|
|
24
|
+
string memory symbol_,
|
|
25
|
+
address newOwner_
|
|
26
|
+
) public virtual initializer {
|
|
27
|
+
LSP7CompatibleERC20InitAbstract._initialize(name_, symbol_, newOwner_);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
|
|
3
|
+
pragma solidity ^0.8.0;
|
|
4
|
+
|
|
5
|
+
// modules
|
|
6
|
+
import {
|
|
7
|
+
LSP7DigitalAssetInitAbstract,
|
|
8
|
+
LSP4DigitalAssetMetadataInitAbstract,
|
|
9
|
+
ERC725YCore
|
|
10
|
+
} from "../LSP7DigitalAssetInitAbstract.sol";
|
|
11
|
+
import {LSP7DigitalAssetCore} from "../LSP7DigitalAssetCore.sol";
|
|
12
|
+
import {LSP7CompatibleERC20Core} from "./LSP7CompatibleERC20Core.sol";
|
|
13
|
+
|
|
14
|
+
contract LSP7CompatibleERC20InitAbstract is LSP7DigitalAssetInitAbstract, LSP7CompatibleERC20Core {
|
|
15
|
+
function _initialize(
|
|
16
|
+
string memory name_,
|
|
17
|
+
string memory symbol_,
|
|
18
|
+
address newOwner_
|
|
19
|
+
) internal virtual override onlyInitializing {
|
|
20
|
+
LSP7DigitalAssetInitAbstract._initialize(name_, symbol_, newOwner_, false);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// --- Overrides
|
|
24
|
+
|
|
25
|
+
function authorizeOperator(address operator, uint256 amount)
|
|
26
|
+
public
|
|
27
|
+
virtual
|
|
28
|
+
override(LSP7DigitalAssetCore, LSP7CompatibleERC20Core)
|
|
29
|
+
{
|
|
30
|
+
super.authorizeOperator(operator, amount);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function _burn(
|
|
34
|
+
address from,
|
|
35
|
+
uint256 amount,
|
|
36
|
+
bytes memory data
|
|
37
|
+
) internal virtual override(LSP7DigitalAssetCore, LSP7CompatibleERC20Core) {
|
|
38
|
+
super._burn(from, amount, data);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function _mint(
|
|
42
|
+
address to,
|
|
43
|
+
uint256 amount,
|
|
44
|
+
bool force,
|
|
45
|
+
bytes memory data
|
|
46
|
+
) internal virtual override(LSP7DigitalAssetCore, LSP7CompatibleERC20Core) {
|
|
47
|
+
super._mint(to, amount, force, data);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function _transfer(
|
|
51
|
+
address from,
|
|
52
|
+
address to,
|
|
53
|
+
uint256 amount,
|
|
54
|
+
bool force,
|
|
55
|
+
bytes memory data
|
|
56
|
+
) internal virtual override(LSP7DigitalAssetCore, LSP7CompatibleERC20Core) {
|
|
57
|
+
super._transfer(from, to, amount, force, data);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function _setData(bytes32 key, bytes memory value)
|
|
61
|
+
internal
|
|
62
|
+
virtual
|
|
63
|
+
override(LSP4DigitalAssetMetadataInitAbstract, ERC725YCore)
|
|
64
|
+
{
|
|
65
|
+
super._setData(key, value);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
import {LSP7CompatibleERC20} from "../extensions/LSP7CompatibleERC20.sol";
|
|
5
|
+
|
|
6
|
+
contract LSP7CompatibleERC20Mintable is LSP7CompatibleERC20 {
|
|
7
|
+
/* solhint-disable no-empty-blocks */
|
|
8
|
+
constructor(
|
|
9
|
+
string memory name_,
|
|
10
|
+
string memory symbol_,
|
|
11
|
+
address newOwner_
|
|
12
|
+
) LSP7CompatibleERC20(name_, symbol_, newOwner_) {}
|
|
13
|
+
|
|
14
|
+
function mint(
|
|
15
|
+
address to,
|
|
16
|
+
uint256 amount,
|
|
17
|
+
bool force,
|
|
18
|
+
bytes memory data
|
|
19
|
+
) public onlyOwner {
|
|
20
|
+
_mint(to, amount, force, data);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
|
|
3
2
|
pragma solidity ^0.8.0;
|
|
4
3
|
|
|
5
4
|
// modules
|
|
6
|
-
import
|
|
5
|
+
import {
|
|
6
|
+
LSP7CompatibleERC20MintableInitAbstract
|
|
7
|
+
} from "./LSP7CompatibleERC20MintableInitAbstract.sol";
|
|
7
8
|
|
|
8
|
-
contract
|
|
9
|
+
contract LSP7CompatibleERC20MintableInit is LSP7CompatibleERC20MintableInitAbstract {
|
|
9
10
|
/**
|
|
10
11
|
* @notice Sets the name, the symbol and the owner of the token
|
|
11
12
|
* @param name_ The name of the token
|
|
@@ -16,7 +17,7 @@ contract LSP7CompatibilityForERC20Init is LSP7CompatibilityForERC20InitAbstract
|
|
|
16
17
|
string memory name_,
|
|
17
18
|
string memory symbol_,
|
|
18
19
|
address newOwner_
|
|
19
|
-
) public virtual
|
|
20
|
-
|
|
20
|
+
) public virtual initializer {
|
|
21
|
+
LSP7CompatibleERC20MintableInitAbstract._initialize(name_, symbol_, newOwner_);
|
|
21
22
|
}
|
|
22
23
|
}
|