@lukso/lsp-smart-contracts 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +18 -0
- package/LICENSE +201 -0
- package/README.md +75 -0
- package/artifacts/Create2Factory.json +107 -0
- package/artifacts/LSP1UniversalReceiverDelegateUP.json +64 -0
- package/artifacts/LSP1UniversalReceiverDelegateUPInit.json +66 -0
- package/artifacts/LSP1UniversalReceiverDelegateVault.json +64 -0
- package/artifacts/LSP1UniversalReceiverDelegateVaultInit.json +66 -0
- package/artifacts/LSP6KeyManager.json +222 -0
- package/artifacts/LSP6KeyManagerInit.json +224 -0
- package/artifacts/LSP7CappedSupply.json +404 -0
- package/artifacts/LSP7CappedSupplyInit.json +481 -0
- package/artifacts/LSP7CompatibilityForERC20.json +495 -0
- package/artifacts/LSP7DigitalAsset.json +417 -0
- package/artifacts/LSP7DigitalAssetInit.json +455 -0
- package/artifacts/LSP7Mintable.json +445 -0
- package/artifacts/LSP7MintableInit.json +483 -0
- package/artifacts/LSP8CappedSupply.json +459 -0
- package/artifacts/LSP8CappedSupplyInit.json +508 -0
- package/artifacts/LSP8CompatibilityForERC721.json +711 -0
- package/artifacts/LSP8IdentifiableDigitalAsset.json +467 -0
- package/artifacts/LSP8IdentifiableDigitalAssetInit.json +482 -0
- package/artifacts/LSP8Mintable.json +495 -0
- package/artifacts/LSP8MintableInit.json +510 -0
- package/artifacts/UniversalProfile.json +373 -0
- package/artifacts/UniversalProfileInit.json +375 -0
- package/constants.ts +350 -0
- package/contracts/Factories/Create2Factory.sol +92 -0
- package/contracts/LSP0ERC725Account/LSP0Constants.sol +14 -0
- package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +23 -0
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +119 -0
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +20 -0
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +33 -0
- package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiver.sol +37 -0
- package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiverDelegate.sol +22 -0
- package/contracts/LSP1UniversalReceiver/LSP1Constants.sol +17 -0
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/Handling/TokenAndVaultHandling.sol +189 -0
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +26 -0
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUPCore.sol +52 -0
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUPInit.sol +26 -0
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUPInitAbstract.sol +28 -0
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/Handling/TokenHandling.sol +114 -0
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +23 -0
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVaultCore.sol +41 -0
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVaultInit.sol +23 -0
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVaultInitAbstract.sol +25 -0
- package/contracts/LSP4DigitalAssetMetadata/ILSP4Compatibility.sol +23 -0
- package/contracts/LSP4DigitalAssetMetadata/LSP4Compatibility.sol +47 -0
- package/contracts/LSP4DigitalAssetMetadata/LSP4Constants.sol +19 -0
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol +36 -0
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInit.sol +30 -0
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +41 -0
- package/contracts/LSP6KeyManager/ILSP6KeyManager.sol +52 -0
- package/contracts/LSP6KeyManager/LSP6Constants.sol +28 -0
- package/contracts/LSP6KeyManager/LSP6KeyManager.sol +21 -0
- package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +444 -0
- package/contracts/LSP6KeyManager/LSP6KeyManagerInit.sol +19 -0
- package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +26 -0
- package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +186 -0
- package/contracts/LSP7DigitalAsset/LSP7Constants.sol +12 -0
- package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +35 -0
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +394 -0
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInit.sol +29 -0
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +44 -0
- package/contracts/LSP7DigitalAsset/extensions/ILSP7CappedSupply.sol +17 -0
- package/contracts/LSP7DigitalAsset/extensions/ILSP7CompatibilityForERC20.sol +47 -0
- package/contracts/LSP7DigitalAsset/extensions/ILSP7Mintable.sol +32 -0
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupply.sol +45 -0
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyCore.sol +55 -0
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInit.sol +24 -0
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInitAbstract.sol +50 -0
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibilityForERC20.sol +76 -0
- package/contracts/LSP7DigitalAsset/extensions/LSP7Mintable.sol +41 -0
- package/contracts/LSP7DigitalAsset/extensions/LSP7MintableCore.sol +26 -0
- package/contracts/LSP7DigitalAsset/extensions/LSP7MintableInit.sol +26 -0
- package/contracts/LSP7DigitalAsset/extensions/LSP7MintableInitAbstract.sol +47 -0
- package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +223 -0
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol +18 -0
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +35 -0
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +470 -0
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInit.sol +29 -0
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +41 -0
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CappedSupply.sol +17 -0
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CompatibilityForERC721.sol +108 -0
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8Mintable.sol +32 -0
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.sol +53 -0
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyCore.sol +56 -0
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInit.sol +24 -0
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInitAbstract.sol +55 -0
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibilityConstants.sol +6 -0
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibilityForERC721.sol +252 -0
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Mintable.sol +36 -0
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8MintableCore.sol +29 -0
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8MintableInit.sol +24 -0
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8MintableInitAbstract.sol +44 -0
- package/contracts/LSP9Vault/LSP9Constants.sol +12 -0
- package/contracts/LSP9Vault/LSP9Vault.sol +56 -0
- package/contracts/LSP9Vault/LSP9VaultCore.sol +174 -0
- package/contracts/LSP9Vault/LSP9VaultInit.sol +19 -0
- package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +60 -0
- package/contracts/UniversalProfile.sol +37 -0
- package/contracts/UniversalProfileCore.sol +56 -0
- package/contracts/UniversalProfileInit.sol +19 -0
- package/contracts/UniversalProfileInitAbstract.sol +48 -0
- package/contracts/Utils/ERC725Utils.sol +169 -0
- package/contracts/Utils/LSP2Utils.sol +127 -0
- package/contracts/Utils/LSP6Utils.sol +77 -0
- package/contracts/Utils/UtilsLib.sol +23 -0
- package/package.json +84 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
|
|
3
|
+
pragma solidity ^0.8.0;
|
|
4
|
+
|
|
5
|
+
// modules
|
|
6
|
+
import "./LSP7CappedSupplyInitAbstract.sol";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @dev LSP7 extension, adds token supply cap.
|
|
10
|
+
*/
|
|
11
|
+
abstract contract LSP7CappedSupplyInit is LSP7CappedSupplyInitAbstract {
|
|
12
|
+
/**
|
|
13
|
+
* @notice Sets the token max supply
|
|
14
|
+
* @param tokenSupplyCap_ The Token max supply
|
|
15
|
+
*/
|
|
16
|
+
function initialize(uint256 tokenSupplyCap_)
|
|
17
|
+
public
|
|
18
|
+
virtual
|
|
19
|
+
override
|
|
20
|
+
initializer
|
|
21
|
+
{
|
|
22
|
+
LSP7CappedSupplyInitAbstract.initialize(tokenSupplyCap_);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
|
|
3
|
+
pragma solidity ^0.8.0;
|
|
4
|
+
|
|
5
|
+
// modules
|
|
6
|
+
import "./LSP7CappedSupplyCore.sol";
|
|
7
|
+
import "../LSP7DigitalAssetInit.sol";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @dev LSP7 extension, adds token supply cap.
|
|
11
|
+
*/
|
|
12
|
+
abstract contract LSP7CappedSupplyInitAbstract is
|
|
13
|
+
Initializable,
|
|
14
|
+
LSP7DigitalAssetInit,
|
|
15
|
+
LSP7CappedSupplyCore
|
|
16
|
+
{
|
|
17
|
+
/**
|
|
18
|
+
* @notice Sets the token max supply
|
|
19
|
+
* @param tokenSupplyCap_ The Token max supply
|
|
20
|
+
*/
|
|
21
|
+
function initialize(uint256 tokenSupplyCap_)
|
|
22
|
+
public
|
|
23
|
+
virtual
|
|
24
|
+
onlyInitializing
|
|
25
|
+
{
|
|
26
|
+
require(tokenSupplyCap_ > 0, "LSP7Capped: tokenSupplyCap is zero");
|
|
27
|
+
_tokenSupplyCap = tokenSupplyCap_;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// --- Overrides
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @dev Mints `amount` tokens and transfers it to `to`.
|
|
34
|
+
*
|
|
35
|
+
* Requirements:
|
|
36
|
+
*
|
|
37
|
+
* - `tokenSupplyCap() - totalSupply()` must be greater than zero.
|
|
38
|
+
* - `to` cannot be the zero address.
|
|
39
|
+
*
|
|
40
|
+
* Emits a {Transfer} event.
|
|
41
|
+
*/
|
|
42
|
+
function _mint(
|
|
43
|
+
address to,
|
|
44
|
+
uint256 amount,
|
|
45
|
+
bool force,
|
|
46
|
+
bytes memory data
|
|
47
|
+
) internal virtual override(LSP7DigitalAssetCore, LSP7CappedSupplyCore) {
|
|
48
|
+
super._mint(to, amount, force, data);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
|
|
3
|
+
pragma solidity ^0.8.0;
|
|
4
|
+
|
|
5
|
+
// modules
|
|
6
|
+
import "../LSP7DigitalAsset.sol";
|
|
7
|
+
|
|
8
|
+
// interfaces
|
|
9
|
+
import "./ILSP7CompatibilityForERC20.sol";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @dev LSP7 extension, for compatibility for clients / tools that expect ERC20.
|
|
13
|
+
*/
|
|
14
|
+
contract LSP7CompatibilityForERC20 is
|
|
15
|
+
ILSP7CompatibilityForERC20,
|
|
16
|
+
LSP7DigitalAsset
|
|
17
|
+
{
|
|
18
|
+
/* solhint-disable no-empty-blocks */
|
|
19
|
+
/**
|
|
20
|
+
* @notice Sets the name, the symbol and the owner of the token
|
|
21
|
+
* @param name_ The name of the token
|
|
22
|
+
* @param symbol_ The symbol of the token
|
|
23
|
+
* @param newOwner_ The owner of the token
|
|
24
|
+
*/
|
|
25
|
+
constructor(
|
|
26
|
+
string memory name_,
|
|
27
|
+
string memory symbol_,
|
|
28
|
+
address newOwner_
|
|
29
|
+
) LSP7DigitalAsset(name_, symbol_, newOwner_, false) {}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @inheritdoc ILSP7CompatibilityForERC20
|
|
33
|
+
*/
|
|
34
|
+
function approve(address operator, uint256 amount)
|
|
35
|
+
external
|
|
36
|
+
virtual
|
|
37
|
+
override
|
|
38
|
+
{
|
|
39
|
+
return authorizeOperator(operator, amount);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @inheritdoc ILSP7CompatibilityForERC20
|
|
44
|
+
*/
|
|
45
|
+
function allowance(address tokenOwner, address operator)
|
|
46
|
+
external
|
|
47
|
+
view
|
|
48
|
+
virtual
|
|
49
|
+
override
|
|
50
|
+
returns (uint256)
|
|
51
|
+
{
|
|
52
|
+
return isOperatorFor(operator, tokenOwner);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @inheritdoc ILSP7CompatibilityForERC20
|
|
57
|
+
* @dev Compatible with ERC20 transfer.
|
|
58
|
+
* Using force=true so that EOA and any contract may receive the tokens.
|
|
59
|
+
*/
|
|
60
|
+
function transfer(address to, uint256 amount) external virtual override {
|
|
61
|
+
return transfer(_msgSender(), to, amount, true, "compat-transfer");
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @inheritdoc ILSP7CompatibilityForERC20
|
|
66
|
+
* @dev Compatible with ERC20 transferFrom.
|
|
67
|
+
* Using force=true so that EOA and any contract may receive the tokens.
|
|
68
|
+
*/
|
|
69
|
+
function transferFrom(
|
|
70
|
+
address from,
|
|
71
|
+
address to,
|
|
72
|
+
uint256 amount
|
|
73
|
+
) external virtual override {
|
|
74
|
+
return transfer(from, to, amount, true, "compat-transferFrom");
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
|
|
3
|
+
pragma solidity ^0.8.0;
|
|
4
|
+
|
|
5
|
+
import "./LSP7MintableCore.sol";
|
|
6
|
+
import "../LSP7DigitalAsset.sol";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @title LSP7Mintable
|
|
10
|
+
* @author Jean Cavallera, Yamen Merhi
|
|
11
|
+
* @dev LSP7 extension, mintable.
|
|
12
|
+
*/
|
|
13
|
+
contract LSP7Mintable is LSP7MintableCore, LSP7DigitalAsset {
|
|
14
|
+
// solhint-disable no-empty-blocks
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @notice Sets the token-Metadata and register LSP7InterfaceId
|
|
18
|
+
* @param name_ The name of the token
|
|
19
|
+
* @param symbol_ The symbol of the token
|
|
20
|
+
* @param newOwner_ The owner of the the token-Metadata
|
|
21
|
+
* @param isNFT_ Specify if the LSP7 token is a fungible or non-fungible token
|
|
22
|
+
*/
|
|
23
|
+
constructor(
|
|
24
|
+
string memory name_,
|
|
25
|
+
string memory symbol_,
|
|
26
|
+
address newOwner_,
|
|
27
|
+
bool isNFT_
|
|
28
|
+
) LSP7DigitalAsset(name_, symbol_, newOwner_, isNFT_) {}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @inheritdoc LSP7MintableCore
|
|
32
|
+
*/
|
|
33
|
+
function mint(
|
|
34
|
+
address to,
|
|
35
|
+
uint256 amount,
|
|
36
|
+
bool force,
|
|
37
|
+
bytes memory data
|
|
38
|
+
) public override onlyOwner {
|
|
39
|
+
_mint(to, amount, force, data);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
|
|
3
|
+
pragma solidity ^0.8.0;
|
|
4
|
+
|
|
5
|
+
// modules
|
|
6
|
+
import "../LSP7DigitalAssetCore.sol";
|
|
7
|
+
|
|
8
|
+
// interfaces
|
|
9
|
+
import "./ILSP7Mintable.sol";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @dev LSP7 extension, mintable .
|
|
13
|
+
*/
|
|
14
|
+
abstract contract LSP7MintableCore is ILSP7Mintable, LSP7DigitalAssetCore {
|
|
15
|
+
/**
|
|
16
|
+
* @inheritdoc ILSP7Mintable
|
|
17
|
+
*/
|
|
18
|
+
function mint(
|
|
19
|
+
address to,
|
|
20
|
+
uint256 amount,
|
|
21
|
+
bool force,
|
|
22
|
+
bytes memory data
|
|
23
|
+
) public virtual override {
|
|
24
|
+
_mint(to, amount, force, data);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
|
|
3
|
+
pragma solidity ^0.8.0;
|
|
4
|
+
|
|
5
|
+
import "./LSP7MintableInitAbstract.sol";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @dev LSP7 extension, mintable.
|
|
9
|
+
*/
|
|
10
|
+
contract LSP7MintableInit is LSP7MintableInitAbstract {
|
|
11
|
+
/**
|
|
12
|
+
* @notice Sets the token-Metadata and register LSP7InterfaceId
|
|
13
|
+
* @param name_ The name of the token
|
|
14
|
+
* @param symbol_ The symbol of the token
|
|
15
|
+
* @param newOwner_ The owner of the the token-Metadata
|
|
16
|
+
* @param isNFT_ Specify if the LSP7 token is a fungible or non-fungible token
|
|
17
|
+
*/
|
|
18
|
+
function initialize(
|
|
19
|
+
string memory name_,
|
|
20
|
+
string memory symbol_,
|
|
21
|
+
address newOwner_,
|
|
22
|
+
bool isNFT_
|
|
23
|
+
) public virtual override initializer {
|
|
24
|
+
LSP7MintableInitAbstract.initialize(name_, symbol_, newOwner_, isNFT_);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
|
|
3
|
+
pragma solidity ^0.8.0;
|
|
4
|
+
|
|
5
|
+
import "./LSP7MintableCore.sol";
|
|
6
|
+
import "../LSP7DigitalAssetInit.sol";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @dev LSP7 extension, mintable.
|
|
10
|
+
*/
|
|
11
|
+
abstract contract LSP7MintableInitAbstract is
|
|
12
|
+
LSP7MintableCore,
|
|
13
|
+
LSP7DigitalAssetInit
|
|
14
|
+
{
|
|
15
|
+
/**
|
|
16
|
+
* @notice Sets the token-Metadata and register LSP7InterfaceId
|
|
17
|
+
* @param name_ The name of the token
|
|
18
|
+
* @param symbol_ The symbol of the token
|
|
19
|
+
* @param newOwner_ The owner of the the token-Metadata
|
|
20
|
+
* @param isNFT_ Specify if the LSP7 token is a fungible or non-fungible token
|
|
21
|
+
*/
|
|
22
|
+
function initialize(
|
|
23
|
+
string memory name_,
|
|
24
|
+
string memory symbol_,
|
|
25
|
+
address newOwner_,
|
|
26
|
+
bool isNFT_
|
|
27
|
+
) public virtual override onlyInitializing {
|
|
28
|
+
LSP7DigitalAssetInitAbstract.initialize(
|
|
29
|
+
name_,
|
|
30
|
+
symbol_,
|
|
31
|
+
newOwner_,
|
|
32
|
+
isNFT_
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @inheritdoc LSP7MintableCore
|
|
38
|
+
*/
|
|
39
|
+
function mint(
|
|
40
|
+
address to,
|
|
41
|
+
uint256 amount,
|
|
42
|
+
bool force,
|
|
43
|
+
bytes memory data
|
|
44
|
+
) public override onlyOwner {
|
|
45
|
+
_mint(to, amount, force, data);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
|
|
3
|
+
pragma solidity ^0.8.0;
|
|
4
|
+
|
|
5
|
+
// interfaces
|
|
6
|
+
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
|
|
7
|
+
import "@erc725/smart-contracts/contracts/interfaces/IERC725Y.sol";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @dev Required interface of a LSP8 compliant contract.
|
|
11
|
+
*/
|
|
12
|
+
interface ILSP8IdentifiableDigitalAsset is IERC165, IERC725Y {
|
|
13
|
+
// --- Events
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
|
|
17
|
+
* @param operator The address of operator sending tokens
|
|
18
|
+
* @param from The address which tokens are sent
|
|
19
|
+
* @param to The receiving address
|
|
20
|
+
* @param tokenId The tokenId transferred
|
|
21
|
+
* @param force When set to TRUE, `to` may be any address but
|
|
22
|
+
* when set to FALSE `to` must be a contract that supports LSP1 UniversalReceiver
|
|
23
|
+
* @param data Additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses
|
|
24
|
+
*/
|
|
25
|
+
event Transfer(
|
|
26
|
+
address operator,
|
|
27
|
+
address indexed from,
|
|
28
|
+
address indexed to,
|
|
29
|
+
bytes32 indexed tokenId,
|
|
30
|
+
bool force,
|
|
31
|
+
bytes data
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @dev Emitted when `tokenOwner` enables `operator` for `tokenId`.
|
|
36
|
+
* @param operator The address authorized as an operator
|
|
37
|
+
* @param tokenOwner The token owner
|
|
38
|
+
* @param tokenId The tokenId `operator` address has access to from `tokenOwner`
|
|
39
|
+
*/
|
|
40
|
+
event AuthorizedOperator(
|
|
41
|
+
address indexed operator,
|
|
42
|
+
address indexed tokenOwner,
|
|
43
|
+
bytes32 indexed tokenId
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @dev Emitted when `tokenOwner` disables `operator` for `tokenId`.
|
|
48
|
+
* @param operator The address revoked from operating
|
|
49
|
+
* @param tokenOwner The token owner
|
|
50
|
+
* @param tokenId The tokenId `operator` is revoked from operating
|
|
51
|
+
*/
|
|
52
|
+
event RevokedOperator(
|
|
53
|
+
address indexed operator,
|
|
54
|
+
address indexed tokenOwner,
|
|
55
|
+
bytes32 indexed tokenId
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
// --- Token queries
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* @dev Returns the number of existing tokens.
|
|
62
|
+
* @return The number of existing tokens
|
|
63
|
+
*/
|
|
64
|
+
function totalSupply() external view returns (uint256);
|
|
65
|
+
|
|
66
|
+
//
|
|
67
|
+
// --- Token owner queries
|
|
68
|
+
//
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @dev Returns the number of tokens owned by `tokenOwner`.
|
|
72
|
+
* @param tokenOwner The address to query
|
|
73
|
+
* @return The number of tokens owned by this address
|
|
74
|
+
*/
|
|
75
|
+
function balanceOf(address tokenOwner) external view returns (uint256);
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @param tokenId The tokenId to query
|
|
79
|
+
* @return The address owning the `tokenId`
|
|
80
|
+
* @dev Returns the `tokenOwner` address of the `tokenId` token.
|
|
81
|
+
*
|
|
82
|
+
* Requirements:
|
|
83
|
+
*
|
|
84
|
+
* - `tokenId` must exist.
|
|
85
|
+
*/
|
|
86
|
+
function tokenOwnerOf(bytes32 tokenId) external view returns (address);
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @dev Returns the list of `tokenIds` for the `tokenOwner` address.
|
|
90
|
+
* @param tokenOwner The address to query owned tokens
|
|
91
|
+
* @return List of owned tokens by `tokenOwner` address
|
|
92
|
+
*/
|
|
93
|
+
function tokenIdsOf(address tokenOwner)
|
|
94
|
+
external
|
|
95
|
+
view
|
|
96
|
+
returns (bytes32[] memory);
|
|
97
|
+
|
|
98
|
+
// --- Operator functionality
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* @param operator The address to authorize as an operator.
|
|
102
|
+
* @param tokenId The tokenId operator has access to.
|
|
103
|
+
* @dev Makes `operator` address an operator of `tokenId`.
|
|
104
|
+
*
|
|
105
|
+
* See {isOperatorFor}.
|
|
106
|
+
*
|
|
107
|
+
* Requirements
|
|
108
|
+
*
|
|
109
|
+
* - `tokenId` must exist.
|
|
110
|
+
* - caller must be current `tokenOwner` of `tokenId`.
|
|
111
|
+
* - `operator` cannot be calling address.
|
|
112
|
+
* - `operator` cannot be the zero address.
|
|
113
|
+
*
|
|
114
|
+
* Emits an {AuthorizedOperator} event.
|
|
115
|
+
*/
|
|
116
|
+
function authorizeOperator(address operator, bytes32 tokenId) external;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* @param operator The address to revoke as an operator.
|
|
120
|
+
* @param tokenId The tokenId `operator` is revoked from operating
|
|
121
|
+
* @dev Removes `operator` address as an operator of `tokenId`.
|
|
122
|
+
*
|
|
123
|
+
* See {isOperatorFor}.
|
|
124
|
+
*
|
|
125
|
+
* Requirements
|
|
126
|
+
*
|
|
127
|
+
* - `tokenId` must exist.
|
|
128
|
+
* - caller must be current `tokenOwner` of `tokenId`.
|
|
129
|
+
* - `operator` cannot be calling address.
|
|
130
|
+
* - `operator` cannot be the zero address.
|
|
131
|
+
*
|
|
132
|
+
* Emits a {RevokedOperator} event.
|
|
133
|
+
*/
|
|
134
|
+
function revokeOperator(address operator, bytes32 tokenId) external;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* @param operator The address to query
|
|
138
|
+
* @param tokenId The tokenId to query
|
|
139
|
+
* @return True if the owner of `tokenId` is `operator` address, false otherwise
|
|
140
|
+
* @dev Returns whether `operator` address is an operator of `tokenId`.
|
|
141
|
+
* Operators can send and burn tokens on behalf of their owners. The tokenOwner is their own
|
|
142
|
+
* operator.
|
|
143
|
+
*
|
|
144
|
+
* Requirements
|
|
145
|
+
*
|
|
146
|
+
* - `tokenId` must exist.
|
|
147
|
+
*/
|
|
148
|
+
function isOperatorFor(address operator, bytes32 tokenId)
|
|
149
|
+
external
|
|
150
|
+
view
|
|
151
|
+
returns (bool);
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* @param tokenId The tokenId to query
|
|
155
|
+
* @return The list of operators for the `tokenId`
|
|
156
|
+
* @dev Returns all `operator` addresses of `tokenId`.
|
|
157
|
+
*
|
|
158
|
+
* Requirements
|
|
159
|
+
*
|
|
160
|
+
* - `tokenId` must exist.
|
|
161
|
+
*/
|
|
162
|
+
function getOperatorsOf(bytes32 tokenId)
|
|
163
|
+
external
|
|
164
|
+
view
|
|
165
|
+
returns (address[] memory);
|
|
166
|
+
|
|
167
|
+
// --- Transfer functionality
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* @param from The sending address.
|
|
171
|
+
* @param to The receiving address.
|
|
172
|
+
* @param tokenId The tokenId to transfer.
|
|
173
|
+
* @param force When set to TRUE, to may be any address but
|
|
174
|
+
* when set to FALSE to must be a contract that supports LSP1 UniversalReceiver
|
|
175
|
+
* @param data Additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses.
|
|
176
|
+
* @dev Transfers `tokenId` token from `from` to `to`.
|
|
177
|
+
*
|
|
178
|
+
* Requirements:
|
|
179
|
+
*
|
|
180
|
+
* - `from` cannot be the zero address.
|
|
181
|
+
* - `to` cannot be the zero address.
|
|
182
|
+
* - `tokenId` token must be owned by `from`.
|
|
183
|
+
* - If the caller is not `from`, it must be an operator of `tokenId`.
|
|
184
|
+
*
|
|
185
|
+
* Emits a {Transfer} event.
|
|
186
|
+
*/
|
|
187
|
+
function transfer(
|
|
188
|
+
address from,
|
|
189
|
+
address to,
|
|
190
|
+
bytes32 tokenId,
|
|
191
|
+
bool force,
|
|
192
|
+
bytes memory data
|
|
193
|
+
) external;
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* @param from The list of sending addresses.
|
|
197
|
+
* @param to The list of receiving addresses.
|
|
198
|
+
* @param tokenId The list of tokenId to transfer.
|
|
199
|
+
* @param force When set to TRUE, to may be any address but
|
|
200
|
+
* when set to FALSE to must be a contract that supports LSP1 UniversalReceiver
|
|
201
|
+
* @param data Additional data the caller wants included in the emitted event, and sent in the hooks to `from` and `to` addresses.
|
|
202
|
+
*
|
|
203
|
+
* @dev Transfers many tokens based on the list `from`, `to`, `tokenId`. If any transfer fails
|
|
204
|
+
* the call will revert.
|
|
205
|
+
*
|
|
206
|
+
* Requirements:
|
|
207
|
+
*
|
|
208
|
+
* - `from`, `to`, `tokenId` lists are the same length.
|
|
209
|
+
* - no values in `from` can be the zero address.
|
|
210
|
+
* - no values in `to` can be the zero address.
|
|
211
|
+
* - each `tokenId` token must be owned by `from`.
|
|
212
|
+
* - If the caller is not `from`, it must be an operator of each `tokenId`.
|
|
213
|
+
*
|
|
214
|
+
* Emits {Transfer} events.
|
|
215
|
+
*/
|
|
216
|
+
function transferBatch(
|
|
217
|
+
address[] memory from,
|
|
218
|
+
address[] memory to,
|
|
219
|
+
bytes32[] memory tokenId,
|
|
220
|
+
bool force,
|
|
221
|
+
bytes[] memory data
|
|
222
|
+
) external;
|
|
223
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// SPDX-License-Identifier: CC0-1.0
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
// --- ERC165 interface ids
|
|
5
|
+
bytes4 constant _INTERFACEID_LSP8 = 0x49399145;
|
|
6
|
+
|
|
7
|
+
// --- ERC725Y entries
|
|
8
|
+
|
|
9
|
+
// bytes8('LSP8MetadataAddress') + bytes4(0)
|
|
10
|
+
bytes12 constant _LSP8_METADATA_ADDRESS_KEY_PREFIX = 0x73dcc7c3c4096cdc00000000;
|
|
11
|
+
|
|
12
|
+
// bytes8('LSP8MetadataJSON') + bytes4(0)
|
|
13
|
+
bytes12 constant _LSP8_METADATA_JSON_KEY_PREFIX = 0x9a26b4060ae7f7d500000000;
|
|
14
|
+
|
|
15
|
+
// --- Token Hooks
|
|
16
|
+
bytes32 constant _TYPEID_LSP8_TOKENSSENDER = 0x3724c94f0815e936299cca424da4140752198e0beb7931a6e0925d11bc97544c; // keccak256("LSP8TokensSender")
|
|
17
|
+
|
|
18
|
+
bytes32 constant _TYPEID_LSP8_TOKENSRECIPIENT = 0xc7a120a42b6057a0cbed111fbbfbd52fcd96748c04394f77fc2c3adbe0391e01; // keccak256("LSP8TokensRecipient")
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// SPDX-License-Identifier: CC0-1.0
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
// modules
|
|
5
|
+
import "./LSP8IdentifiableDigitalAssetCore.sol";
|
|
6
|
+
import "../LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol";
|
|
7
|
+
import "@erc725/smart-contracts/contracts/ERC725Y.sol";
|
|
8
|
+
|
|
9
|
+
// constants
|
|
10
|
+
import "./LSP8Constants.sol";
|
|
11
|
+
import "../LSP4DigitalAssetMetadata/LSP4Constants.sol";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @title LSP8IdentifiableDigitalAsset contract
|
|
15
|
+
* @author Matthew Stevens
|
|
16
|
+
* @dev Implementation of a LSP8 compliant contract.
|
|
17
|
+
*/
|
|
18
|
+
contract LSP8IdentifiableDigitalAsset is
|
|
19
|
+
LSP4DigitalAssetMetadata,
|
|
20
|
+
LSP8IdentifiableDigitalAssetCore
|
|
21
|
+
{
|
|
22
|
+
/**
|
|
23
|
+
* @notice Sets the token-Metadata and register LSP8InterfaceId
|
|
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
|
+
*/
|
|
28
|
+
constructor(
|
|
29
|
+
string memory name_,
|
|
30
|
+
string memory symbol_,
|
|
31
|
+
address newOwner_
|
|
32
|
+
) LSP4DigitalAssetMetadata(name_, symbol_, newOwner_) {
|
|
33
|
+
_registerInterface(_INTERFACEID_LSP8);
|
|
34
|
+
}
|
|
35
|
+
}
|