@lukso/lsp-smart-contracts 0.6.1 → 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/artifacts/Create2Factory.json +2 -2
- package/artifacts/LSP0ERC725Account.json +8 -8
- package/artifacts/LSP0ERC725AccountInit.json +13 -8
- package/artifacts/LSP1UniversalReceiverDelegateUP.json +18 -2
- package/artifacts/LSP1UniversalReceiverDelegateVault.json +18 -2
- package/artifacts/LSP4DigitalAssetMetadata.json +10 -0
- package/artifacts/LSP4DigitalAssetMetadataInit.json +10 -0
- package/artifacts/LSP6KeyManager.json +82 -13
- package/artifacts/LSP6KeyManagerInit.json +87 -13
- package/artifacts/LSP7CappedSupply.json +10 -0
- package/artifacts/LSP7CappedSupplyInit.json +10 -28
- 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 +12 -2
- package/artifacts/LSP7DigitalAssetInit.json +17 -2
- package/artifacts/LSP7Mintable.json +12 -2
- package/artifacts/LSP7MintableInit.json +17 -2
- package/artifacts/LSP8CappedSupply.json +10 -0
- package/artifacts/LSP8CappedSupplyInit.json +10 -23
- 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 +12 -2
- package/artifacts/LSP8IdentifiableDigitalAssetInit.json +17 -2
- package/artifacts/LSP8Mintable.json +12 -2
- package/artifacts/LSP8MintableInit.json +17 -2
- package/artifacts/LSP9Vault.json +9 -9
- package/artifacts/LSP9VaultInit.json +14 -9
- package/artifacts/UniversalFactory.json +2 -2
- package/artifacts/UniversalProfile.json +8 -8
- package/artifacts/UniversalProfileInit.json +13 -8
- package/artifacts/UniversalReceiverAddressStore.json +2 -2
- package/constants.js +49 -14
- package/contracts/Custom/ClaimOwnership.sol +10 -7
- package/contracts/Custom/IClaimOwnership.sol +1 -1
- package/contracts/Factories/Create2Factory.sol +3 -13
- package/contracts/Factories/UniversalFactory.sol +16 -7
- package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +3 -3
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +28 -19
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +10 -3
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +2 -2
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +12 -3
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/Handling/TokenHandling.sol +18 -16
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +8 -2
- package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +18 -4
- package/contracts/LSP2ERC725YJSONSchema/LSP2Errors.sol +9 -0
- package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +69 -73
- package/contracts/LSP3UniversalProfile/LSP3Constants.sol +1 -1
- package/contracts/LSP4DigitalAssetMetadata/LSP4Constants.sol +1 -1
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol +14 -3
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +16 -4
- package/contracts/LSP4DigitalAssetMetadata/LSP4Errors.sol +16 -0
- package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +27 -1
- package/contracts/LSP6KeyManager/ILSP6KeyManager.sol +15 -15
- package/contracts/LSP6KeyManager/LSP6Errors.sol +34 -5
- package/contracts/LSP6KeyManager/LSP6KeyManager.sol +5 -3
- package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +224 -234
- package/contracts/LSP6KeyManager/LSP6KeyManagerInit.sol +10 -3
- package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +4 -2
- package/contracts/LSP6KeyManager/LSP6Utils.sol +22 -26
- package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +4 -0
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +3 -1
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInit.sol +11 -0
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +3 -1
- package/contracts/LSP7DigitalAsset/extensions/{ILSP7CompatibilityForERC20.sol → ILSP7CompatibleERC20.sol} +6 -6
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInitAbstract.sol +5 -2
- package/contracts/LSP7DigitalAsset/extensions/{LSP7CompatibilityForERC20.sol → LSP7CompatibleERC20.sol} +6 -7
- package/contracts/LSP7DigitalAsset/extensions/{LSP7CompatibilityForERC20Core.sol → LSP7CompatibleERC20Core.sol} +21 -16
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20Init.sol +29 -0
- package/contracts/LSP7DigitalAsset/extensions/{LSP7CompatibilityForERC20InitAbstract.sol → LSP7CompatibleERC20InitAbstract.sol} +11 -10
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.sol +22 -0
- package/contracts/LSP7DigitalAsset/{extensions/LSP7CompatibilityForERC20Init.sol → presets/LSP7CompatibleERC20MintableInit.sol} +5 -4
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInitAbstract.sol +27 -0
- package/contracts/LSP7DigitalAsset/presets/LSP7MintableInit.sol +8 -1
- package/contracts/LSP7DigitalAsset/presets/LSP7MintableInitAbstract.sol +1 -1
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +1 -1
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInit.sol +10 -1
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +3 -1
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/{ILSP8CompatibilityForERC721.sol → ILSP8CompatibleERC721.sol} +1 -1
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInitAbstract.sol +4 -2
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/{LSP8CompatibilityConstants.sol → LSP8CompatibleConstants.sol} +0 -0
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/{LSP8CompatibilityForERC721.sol → LSP8CompatibleERC721.sol} +12 -11
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/{LSP8CompatibilityForERC721Core.sol → LSP8CompatibleERC721Core.sol} +16 -16
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/{LSP8CompatibilityForERC721Init.sol → LSP8CompatibleERC721Init.sol} +3 -3
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/{LSP8CompatibilityForERC721InitAbstract.sol → LSP8CompatibleERC721InitAbstract.sol} +13 -9
- 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/presets/LSP8MintableInit.sol +7 -0
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +3 -1
- package/contracts/LSP9Vault/LSP9Constants.sol +1 -1
- package/contracts/LSP9Vault/LSP9Vault.sol +9 -5
- package/contracts/LSP9Vault/LSP9VaultCore.sol +37 -26
- package/contracts/LSP9Vault/LSP9VaultInit.sol +10 -3
- package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +8 -4
- package/contracts/Legacy/UniversalReceiverAddressStore.sol +3 -1
- package/contracts/UniversalProfile.sol +3 -4
- package/contracts/UniversalProfileInit.sol +10 -3
- package/contracts/UniversalProfileInitAbstract.sol +3 -5
- package/contracts/Utils/UtilsLib.sol +6 -34
- package/package.json +2 -2
- package/artifacts/LSP7CompatibilityForERC20.json +0 -686
- package/artifacts/LSP7CompatibilityForERC20Init.json +0 -727
- package/artifacts/LSP8CompatibilityForERC721.json +0 -832
- package/artifacts/LSP8CompatibilityForERC721Init.json +0 -873
|
@@ -4,7 +4,9 @@ pragma solidity ^0.8.0;
|
|
|
4
4
|
// interfaces
|
|
5
5
|
import {IERC1271} from "@openzeppelin/contracts/interfaces/IERC1271.sol";
|
|
6
6
|
import {ILSP1UniversalReceiver} from "../LSP1UniversalReceiver/ILSP1UniversalReceiver.sol";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
ILSP1UniversalReceiverDelegate
|
|
9
|
+
} from "../LSP1UniversalReceiver/ILSP1UniversalReceiverDelegate.sol";
|
|
8
10
|
|
|
9
11
|
// libraries
|
|
10
12
|
import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
|
|
@@ -17,8 +19,16 @@ import {OwnableUnset} from "@erc725/smart-contracts/contracts/custom/OwnableUnse
|
|
|
17
19
|
import {ClaimOwnership} from "../Custom/ClaimOwnership.sol";
|
|
18
20
|
|
|
19
21
|
// constants
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
+
import {
|
|
23
|
+
_INTERFACEID_LSP0,
|
|
24
|
+
_INTERFACEID_ERC1271,
|
|
25
|
+
_ERC1271_FAILVALUE
|
|
26
|
+
} from "../LSP0ERC725Account/LSP0Constants.sol";
|
|
27
|
+
import {
|
|
28
|
+
_INTERFACEID_LSP1,
|
|
29
|
+
_INTERFACEID_LSP1_DELEGATE,
|
|
30
|
+
_LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY
|
|
31
|
+
} from "../LSP1UniversalReceiver/LSP1Constants.sol";
|
|
22
32
|
import {_INTERFACEID_CLAIM_OWNERSHIP} from "../Custom/IClaimOwnership.sol";
|
|
23
33
|
|
|
24
34
|
/**
|
|
@@ -43,7 +53,7 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
43
53
|
/**
|
|
44
54
|
* @dev Emits an event when receiving native tokens
|
|
45
55
|
*/
|
|
46
|
-
fallback() external payable {
|
|
56
|
+
fallback() external payable virtual {
|
|
47
57
|
if (msg.value > 0) emit ValueReceived(msg.sender, msg.value);
|
|
48
58
|
}
|
|
49
59
|
|
|
@@ -102,27 +112,26 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
102
112
|
* @notice Checks if an owner signed `_data`.
|
|
103
113
|
* ERC1271 interface.
|
|
104
114
|
*
|
|
105
|
-
* @param
|
|
106
|
-
* @param
|
|
115
|
+
* @param dataHash hash of the data signed//Arbitrary length data signed on the behalf of address(this)
|
|
116
|
+
* @param signature owner's signature(s) of the data
|
|
107
117
|
*/
|
|
108
|
-
function isValidSignature(bytes32
|
|
118
|
+
function isValidSignature(bytes32 dataHash, bytes memory signature)
|
|
109
119
|
public
|
|
110
120
|
view
|
|
111
121
|
override
|
|
112
122
|
returns (bytes4 magicValue)
|
|
113
123
|
{
|
|
114
|
-
// prettier-ignore
|
|
115
124
|
address _owner = owner();
|
|
116
125
|
// if OWNER is a contract
|
|
117
126
|
if (_owner.code.length != 0) {
|
|
118
127
|
return
|
|
119
128
|
ERC165Checker.supportsERC165Interface(_owner, _INTERFACEID_ERC1271)
|
|
120
|
-
? IERC1271(_owner).isValidSignature(
|
|
129
|
+
? IERC1271(_owner).isValidSignature(dataHash, signature)
|
|
121
130
|
: _ERC1271_FAILVALUE;
|
|
122
131
|
// if OWNER is a key
|
|
123
132
|
} else {
|
|
124
133
|
return
|
|
125
|
-
_owner == ECDSA.recover(
|
|
134
|
+
_owner == ECDSA.recover(dataHash, signature)
|
|
126
135
|
? _INTERFACEID_ERC1271
|
|
127
136
|
: _ERC1271_FAILVALUE;
|
|
128
137
|
}
|
|
@@ -133,20 +142,20 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
133
142
|
/**
|
|
134
143
|
* @notice Triggers the UniversalReceiver event when this function gets executed successfully.
|
|
135
144
|
* @dev Forwards the call to the UniversalReceiverDelegate if set.
|
|
136
|
-
* @param
|
|
137
|
-
* @param
|
|
145
|
+
* @param typeId The type of call received.
|
|
146
|
+
* @param data The data received.
|
|
138
147
|
*/
|
|
139
|
-
function universalReceiver(bytes32
|
|
140
|
-
|
|
148
|
+
function universalReceiver(bytes32 typeId, bytes calldata data)
|
|
149
|
+
public
|
|
141
150
|
payable
|
|
142
151
|
virtual
|
|
143
152
|
override
|
|
144
153
|
returns (bytes memory returnValue)
|
|
145
154
|
{
|
|
146
|
-
bytes memory
|
|
155
|
+
bytes memory lsp1DelegateValue = _getData(_LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY);
|
|
147
156
|
|
|
148
|
-
if (
|
|
149
|
-
address universalReceiverDelegate = address(bytes20(
|
|
157
|
+
if (lsp1DelegateValue.length >= 20) {
|
|
158
|
+
address universalReceiverDelegate = address(bytes20(lsp1DelegateValue));
|
|
150
159
|
|
|
151
160
|
if (
|
|
152
161
|
ERC165Checker.supportsERC165Interface(
|
|
@@ -155,9 +164,9 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
155
164
|
)
|
|
156
165
|
) {
|
|
157
166
|
returnValue = ILSP1UniversalReceiverDelegate(universalReceiverDelegate)
|
|
158
|
-
.universalReceiverDelegate(msg.sender, msg.value,
|
|
167
|
+
.universalReceiverDelegate(msg.sender, msg.value, typeId, data);
|
|
159
168
|
}
|
|
160
169
|
}
|
|
161
|
-
emit UniversalReceiver(msg.sender, msg.value,
|
|
170
|
+
emit UniversalReceiver(msg.sender, msg.value, typeId, returnValue, data);
|
|
162
171
|
}
|
|
163
172
|
}
|
|
@@ -10,11 +10,18 @@ import {LSP0ERC725AccountInitAbstract} from "./LSP0ERC725AccountInitAbstract.sol
|
|
|
10
10
|
* @dev Bundles ERC725X and ERC725Y, ERC1271 and LSP1UniversalReceiver and allows receiving native tokens
|
|
11
11
|
*/
|
|
12
12
|
contract LSP0ERC725AccountInit is LSP0ERC725AccountInitAbstract {
|
|
13
|
+
/**
|
|
14
|
+
* @dev @dev initialize (= lock) base implementation contract on deployment
|
|
15
|
+
*/
|
|
16
|
+
constructor() {
|
|
17
|
+
_disableInitializers();
|
|
18
|
+
}
|
|
19
|
+
|
|
13
20
|
/**
|
|
14
21
|
* @notice Sets the owner of the contract
|
|
15
|
-
* @param
|
|
22
|
+
* @param newOwner the owner of the contract
|
|
16
23
|
*/
|
|
17
|
-
function initialize(address
|
|
18
|
-
LSP0ERC725AccountInitAbstract._initialize(
|
|
24
|
+
function initialize(address newOwner) public payable virtual initializer {
|
|
25
|
+
LSP0ERC725AccountInitAbstract._initialize(newOwner);
|
|
19
26
|
}
|
|
20
27
|
}
|
|
@@ -12,7 +12,7 @@ import {OwnableUnset} from "@erc725/smart-contracts/contracts/custom/OwnableUnse
|
|
|
12
12
|
* @dev Bundles ERC725X and ERC725Y, ERC1271 and LSP1UniversalReceiver and allows receiving native tokens
|
|
13
13
|
*/
|
|
14
14
|
abstract contract LSP0ERC725AccountInitAbstract is Initializable, LSP0ERC725AccountCore {
|
|
15
|
-
function _initialize(address
|
|
16
|
-
OwnableUnset._setOwner(
|
|
15
|
+
function _initialize(address newOwner) internal virtual onlyInitializing {
|
|
16
|
+
OwnableUnset._setOwner(newOwner);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -10,9 +10,18 @@ import {TokenAndVaultHandling} from "./Handling/TokenAndVaultHandling.sol";
|
|
|
10
10
|
|
|
11
11
|
// constants
|
|
12
12
|
import {_INTERFACEID_LSP1_DELEGATE} from "../LSP1Constants.sol";
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
import {
|
|
14
|
+
_TYPEID_LSP7_TOKENSSENDER,
|
|
15
|
+
_TYPEID_LSP7_TOKENSRECIPIENT
|
|
16
|
+
} from "../../LSP7DigitalAsset/LSP7Constants.sol";
|
|
17
|
+
import {
|
|
18
|
+
_TYPEID_LSP8_TOKENSSENDER,
|
|
19
|
+
_TYPEID_LSP8_TOKENSRECIPIENT
|
|
20
|
+
} from "../../LSP8IdentifiableDigitalAsset/LSP8Constants.sol";
|
|
21
|
+
import {
|
|
22
|
+
_TYPEID_LSP9_VAULTSENDER,
|
|
23
|
+
_TYPEID_LSP9_VAULTRECIPIENT
|
|
24
|
+
} from "../../LSP9Vault/LSP9Constants.sol";
|
|
16
25
|
|
|
17
26
|
/**
|
|
18
27
|
* @title Core Implementation of contract writing the received Vaults and LSP7, LSP8 assets into your ERC725Account using
|
|
@@ -43,15 +43,16 @@ abstract contract TokenHandling {
|
|
|
43
43
|
// if the map value is already set, then do nothing
|
|
44
44
|
if (bytes12(mapValue) != bytes12(0)) return "";
|
|
45
45
|
|
|
46
|
-
(bytes32[] memory
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
46
|
+
(bytes32[] memory receiverDataKeys, bytes[] memory receiverDataValues) = LSP5Utils
|
|
47
|
+
.addMapAndArrayKey(
|
|
48
|
+
IERC725Y(msg.sender),
|
|
49
|
+
arrayLengthKey,
|
|
50
|
+
mapKey,
|
|
51
|
+
caller,
|
|
52
|
+
interfaceID
|
|
53
|
+
);
|
|
53
54
|
|
|
54
|
-
IERC725Y(msg.sender).setData(
|
|
55
|
+
IERC725Y(msg.sender).setData(receiverDataKeys, receiverDataValues);
|
|
55
56
|
} else {
|
|
56
57
|
// if there is no map value for the asset to remove, then do nothing
|
|
57
58
|
if (bytes12(mapValue) == bytes12(0)) return "";
|
|
@@ -60,15 +61,16 @@ abstract contract TokenHandling {
|
|
|
60
61
|
uint256 balance = ILSP7DigitalAsset(caller).balanceOf(msg.sender);
|
|
61
62
|
if (balance != 0) return "";
|
|
62
63
|
|
|
63
|
-
(bytes32[] memory
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
64
|
+
(bytes32[] memory senderDataKeys, bytes[] memory senderDataValues) = LSP5Utils
|
|
65
|
+
.removeMapAndArrayKey(
|
|
66
|
+
IERC725Y(msg.sender),
|
|
67
|
+
arrayLengthKey,
|
|
68
|
+
mapPrefix,
|
|
69
|
+
mapKey,
|
|
70
|
+
mapValue
|
|
71
|
+
);
|
|
70
72
|
|
|
71
|
-
IERC725Y(msg.sender).setData(
|
|
73
|
+
IERC725Y(msg.sender).setData(senderDataKeys, senderDataValues);
|
|
72
74
|
}
|
|
73
75
|
}
|
|
74
76
|
}
|
|
@@ -10,8 +10,14 @@ import {TokenHandling} from "./Handling/TokenHandling.sol";
|
|
|
10
10
|
|
|
11
11
|
// constants
|
|
12
12
|
import {_INTERFACEID_LSP1_DELEGATE} from "../LSP1Constants.sol";
|
|
13
|
-
import {
|
|
14
|
-
|
|
13
|
+
import {
|
|
14
|
+
_TYPEID_LSP7_TOKENSSENDER,
|
|
15
|
+
_TYPEID_LSP7_TOKENSRECIPIENT
|
|
16
|
+
} from "../../LSP7DigitalAsset/LSP7Constants.sol";
|
|
17
|
+
import {
|
|
18
|
+
_TYPEID_LSP8_TOKENSSENDER,
|
|
19
|
+
_TYPEID_LSP8_TOKENSRECIPIENT
|
|
20
|
+
} from "../../LSP8IdentifiableDigitalAsset/LSP8Constants.sol";
|
|
15
21
|
|
|
16
22
|
/**
|
|
17
23
|
* @title Core Implementation of contract writing the received LSP7 and LSP8 assets into your Vault using
|
|
@@ -2,11 +2,25 @@
|
|
|
2
2
|
pragma solidity ^0.8.0;
|
|
3
3
|
|
|
4
4
|
// constants
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
import {
|
|
6
|
+
_LSP5_RECEIVED_ASSETS_ARRAY_KEY,
|
|
7
|
+
_LSP5_RECEIVED_ASSETS_MAP_KEY_PREFIX
|
|
8
|
+
} from "../LSP5ReceivedAssets/LSP5Constants.sol";
|
|
9
|
+
import {
|
|
10
|
+
_INTERFACEID_LSP7,
|
|
11
|
+
_TYPEID_LSP7_TOKENSSENDER,
|
|
12
|
+
_TYPEID_LSP7_TOKENSRECIPIENT
|
|
13
|
+
} from "../LSP7DigitalAsset/LSP7Constants.sol";
|
|
14
|
+
import {
|
|
15
|
+
_INTERFACEID_LSP8,
|
|
16
|
+
_TYPEID_LSP8_TOKENSRECIPIENT,
|
|
17
|
+
_TYPEID_LSP8_TOKENSSENDER
|
|
18
|
+
} from "../LSP8IdentifiableDigitalAsset/LSP8Constants.sol";
|
|
8
19
|
import {_INTERFACEID_LSP9, _TYPEID_LSP9_VAULTRECIPIENT} from "../LSP9Vault/LSP9Constants.sol";
|
|
9
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
_LSP10_VAULTS_ARRAY_KEY,
|
|
22
|
+
_LSP10_VAULTS_MAP_KEY_PREFIX
|
|
23
|
+
} from "../LSP10ReceivedVaults/LSP10Constants.sol";
|
|
10
24
|
|
|
11
25
|
library LSP1Utils {
|
|
12
26
|
/**
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @dev reverts when `value` is not a properly ABI encoded array
|
|
6
|
+
* @param value the value to check for an abi-encoded array
|
|
7
|
+
* @param valueType the type of the value to check for an abi-encoded array
|
|
8
|
+
*/
|
|
9
|
+
error InvalidABIEncodedArray(bytes value, string valueType);
|
|
@@ -16,142 +16,138 @@ library LSP2Utils {
|
|
|
16
16
|
|
|
17
17
|
/* solhint-disable no-inline-assembly */
|
|
18
18
|
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
assembly {
|
|
22
|
-
key := mload(add(_rawKey, 32))
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function generateSingletonKey(string memory _keyName) internal pure returns (bytes32) {
|
|
27
|
-
return keccak256(bytes(_keyName));
|
|
19
|
+
function generateSingletonKey(string memory keyName) internal pure returns (bytes32) {
|
|
20
|
+
return keccak256(bytes(keyName));
|
|
28
21
|
}
|
|
29
22
|
|
|
30
|
-
function generateArrayKey(string memory
|
|
31
|
-
bytes memory
|
|
23
|
+
function generateArrayKey(string memory keyName) internal pure returns (bytes32) {
|
|
24
|
+
bytes memory dataKey = bytes(keyName);
|
|
32
25
|
|
|
33
|
-
// prettier-ignore
|
|
34
26
|
require(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"Missing empty square brackets
|
|
27
|
+
dataKey[dataKey.length - 2] == 0x5b && // "[" in utf8 encoded
|
|
28
|
+
dataKey[dataKey.length - 1] == 0x5d, // "]" in utf8
|
|
29
|
+
"Missing empty square brackets '[]' at the end of the key name"
|
|
38
30
|
);
|
|
39
31
|
|
|
40
|
-
return keccak256(
|
|
32
|
+
return keccak256(dataKey);
|
|
41
33
|
}
|
|
42
34
|
|
|
43
|
-
function generateArrayElementKeyAtIndex(bytes32
|
|
35
|
+
function generateArrayElementKeyAtIndex(bytes32 arrayKey, uint256 index)
|
|
44
36
|
internal
|
|
45
37
|
pure
|
|
46
38
|
returns (bytes32)
|
|
47
39
|
{
|
|
48
40
|
bytes memory elementInArray = UtilsLib.concatTwoBytes16(
|
|
49
|
-
bytes16(
|
|
50
|
-
bytes16(uint128(
|
|
41
|
+
bytes16(arrayKey),
|
|
42
|
+
bytes16(uint128(index))
|
|
51
43
|
);
|
|
52
|
-
return
|
|
44
|
+
return bytes32(elementInArray);
|
|
53
45
|
}
|
|
54
46
|
|
|
55
|
-
function generateMappingKey(string memory
|
|
47
|
+
function generateMappingKey(string memory firstWord, string memory lastWord)
|
|
56
48
|
internal
|
|
57
49
|
pure
|
|
58
50
|
returns (bytes32)
|
|
59
51
|
{
|
|
60
|
-
bytes32 firstWordHash = keccak256(bytes(
|
|
61
|
-
bytes32 lastWordHash = keccak256(bytes(
|
|
52
|
+
bytes32 firstWordHash = keccak256(bytes(firstWord));
|
|
53
|
+
bytes32 lastWordHash = keccak256(bytes(lastWord));
|
|
62
54
|
|
|
63
|
-
bytes memory temporaryBytes =
|
|
55
|
+
bytes memory temporaryBytes = bytes.concat(
|
|
64
56
|
bytes10(firstWordHash),
|
|
65
57
|
bytes2(0),
|
|
66
58
|
bytes20(lastWordHash)
|
|
67
59
|
);
|
|
68
60
|
|
|
69
|
-
return
|
|
61
|
+
return bytes32(temporaryBytes);
|
|
70
62
|
}
|
|
71
63
|
|
|
72
|
-
function generateMappingKey(string memory
|
|
64
|
+
function generateMappingKey(string memory firstWord, address addr)
|
|
73
65
|
internal
|
|
74
66
|
pure
|
|
75
67
|
returns (bytes32)
|
|
76
68
|
{
|
|
77
|
-
bytes32 firstWordHash = keccak256(bytes(
|
|
69
|
+
bytes32 firstWordHash = keccak256(bytes(firstWord));
|
|
78
70
|
|
|
79
|
-
bytes memory temporaryBytes =
|
|
71
|
+
bytes memory temporaryBytes = bytes.concat(
|
|
72
|
+
bytes10(firstWordHash),
|
|
73
|
+
bytes2(0),
|
|
74
|
+
bytes20(addr)
|
|
75
|
+
);
|
|
80
76
|
|
|
81
|
-
return
|
|
77
|
+
return bytes32(temporaryBytes);
|
|
82
78
|
}
|
|
83
79
|
|
|
84
|
-
function generateMappingKey(bytes12
|
|
80
|
+
function generateMappingKey(bytes12 keyPrefix, bytes20 bytes20Value)
|
|
85
81
|
internal
|
|
86
82
|
pure
|
|
87
83
|
returns (bytes32)
|
|
88
84
|
{
|
|
89
|
-
bytes memory generatedKey = bytes.concat(
|
|
90
|
-
return
|
|
85
|
+
bytes memory generatedKey = bytes.concat(keyPrefix, bytes20Value);
|
|
86
|
+
return bytes32(generatedKey);
|
|
91
87
|
}
|
|
92
88
|
|
|
93
89
|
function generateMappingWithGroupingKey(
|
|
94
|
-
string memory
|
|
95
|
-
string memory
|
|
96
|
-
address
|
|
90
|
+
string memory firstWord,
|
|
91
|
+
string memory secondWord,
|
|
92
|
+
address addr
|
|
97
93
|
) internal pure returns (bytes32) {
|
|
98
|
-
bytes32 firstWordHash = keccak256(bytes(
|
|
99
|
-
bytes32 secondWordHash = keccak256(bytes(
|
|
94
|
+
bytes32 firstWordHash = keccak256(bytes(firstWord));
|
|
95
|
+
bytes32 secondWordHash = keccak256(bytes(secondWord));
|
|
100
96
|
|
|
101
|
-
bytes memory temporaryBytes =
|
|
97
|
+
bytes memory temporaryBytes = bytes.concat(
|
|
102
98
|
bytes6(firstWordHash),
|
|
103
99
|
bytes4(secondWordHash),
|
|
104
100
|
bytes2(0),
|
|
105
|
-
|
|
101
|
+
bytes20(addr)
|
|
106
102
|
);
|
|
107
103
|
|
|
108
|
-
return
|
|
104
|
+
return bytes32(temporaryBytes);
|
|
109
105
|
}
|
|
110
106
|
|
|
111
|
-
function generateMappingWithGroupingKey(bytes12
|
|
107
|
+
function generateMappingWithGroupingKey(bytes12 keyPrefix, bytes20 bytes20Value)
|
|
112
108
|
internal
|
|
113
109
|
pure
|
|
114
110
|
returns (bytes32)
|
|
115
111
|
{
|
|
116
|
-
bytes memory generatedKey = bytes.concat(
|
|
117
|
-
return
|
|
112
|
+
bytes memory generatedKey = bytes.concat(keyPrefix, bytes20Value);
|
|
113
|
+
return bytes32(generatedKey);
|
|
118
114
|
}
|
|
119
115
|
|
|
120
116
|
function generateJSONURLValue(
|
|
121
|
-
string memory
|
|
122
|
-
string memory
|
|
123
|
-
string memory
|
|
124
|
-
) internal pure returns (bytes memory
|
|
125
|
-
bytes32 hashFunctionDigest = keccak256(bytes(
|
|
126
|
-
bytes32 jsonDigest = keccak256(bytes(
|
|
127
|
-
|
|
128
|
-
|
|
117
|
+
string memory hashFunction,
|
|
118
|
+
string memory json,
|
|
119
|
+
string memory url
|
|
120
|
+
) internal pure returns (bytes memory key) {
|
|
121
|
+
bytes32 hashFunctionDigest = keccak256(bytes(hashFunction));
|
|
122
|
+
bytes32 jsonDigest = keccak256(bytes(json));
|
|
123
|
+
|
|
124
|
+
key = abi.encodePacked(bytes4(hashFunctionDigest), jsonDigest, url);
|
|
129
125
|
}
|
|
130
126
|
|
|
131
127
|
function generateASSETURLValue(
|
|
132
|
-
string memory
|
|
133
|
-
string memory
|
|
134
|
-
string memory
|
|
135
|
-
) internal pure returns (bytes memory
|
|
136
|
-
bytes32 hashFunctionDigest = keccak256(bytes(
|
|
137
|
-
bytes32 jsonDigest = keccak256(bytes(
|
|
138
|
-
|
|
139
|
-
|
|
128
|
+
string memory hashFunction,
|
|
129
|
+
string memory assetBytes,
|
|
130
|
+
string memory url
|
|
131
|
+
) internal pure returns (bytes memory key) {
|
|
132
|
+
bytes32 hashFunctionDigest = keccak256(bytes(hashFunction));
|
|
133
|
+
bytes32 jsonDigest = keccak256(bytes(assetBytes));
|
|
134
|
+
|
|
135
|
+
key = abi.encodePacked(bytes4(hashFunctionDigest), jsonDigest, url);
|
|
140
136
|
}
|
|
141
137
|
|
|
142
|
-
function isEncodedArray(bytes memory
|
|
143
|
-
uint256 nbOfBytes =
|
|
138
|
+
function isEncodedArray(bytes memory data) internal pure returns (bool) {
|
|
139
|
+
uint256 nbOfBytes = data.length;
|
|
144
140
|
|
|
145
141
|
// 1) there must be at least 32 bytes to store the offset
|
|
146
142
|
if (nbOfBytes < 32) return false;
|
|
147
143
|
|
|
148
144
|
// 2) there must be at least the same number of bytes specified by
|
|
149
145
|
// the offset value (otherwise, the offset points to nowhere)
|
|
150
|
-
uint256 offset = uint256(bytes32(
|
|
146
|
+
uint256 offset = uint256(bytes32(data));
|
|
151
147
|
if (nbOfBytes < offset) return false;
|
|
152
148
|
|
|
153
149
|
// 3) there must be at least 32 x length bytes after offset
|
|
154
|
-
uint256 arrayLength =
|
|
150
|
+
uint256 arrayLength = data.toUint256(offset);
|
|
155
151
|
|
|
156
152
|
// 32 bytes word (= offset)
|
|
157
153
|
// + 32 bytes word (= array length)
|
|
@@ -161,16 +157,16 @@ library LSP2Utils {
|
|
|
161
157
|
return true;
|
|
162
158
|
}
|
|
163
159
|
|
|
164
|
-
function isEncodedArrayOfAddresses(bytes memory
|
|
165
|
-
if (!isEncodedArray(
|
|
160
|
+
function isEncodedArrayOfAddresses(bytes memory data) internal pure returns (bool) {
|
|
161
|
+
if (!isEncodedArray(data)) return false;
|
|
166
162
|
|
|
167
|
-
uint256 offset = uint256(bytes32(
|
|
168
|
-
uint256 arrayLength =
|
|
163
|
+
uint256 offset = uint256(bytes32(data));
|
|
164
|
+
uint256 arrayLength = data.toUint256(offset);
|
|
169
165
|
|
|
170
166
|
uint256 pointer = offset + 32;
|
|
171
167
|
|
|
172
168
|
for (uint256 ii = 0; ii < arrayLength; ii++) {
|
|
173
|
-
bytes32 key =
|
|
169
|
+
bytes32 key = data.toBytes32(pointer);
|
|
174
170
|
|
|
175
171
|
// check that the leading bytes are zero bytes "00"
|
|
176
172
|
// NB: address type is padded on the left (unlike bytes20 type that is padded on the right)
|
|
@@ -183,15 +179,15 @@ library LSP2Utils {
|
|
|
183
179
|
return true;
|
|
184
180
|
}
|
|
185
181
|
|
|
186
|
-
function isBytes4EncodedArray(bytes memory
|
|
187
|
-
if (!isEncodedArray(
|
|
182
|
+
function isBytes4EncodedArray(bytes memory data) internal pure returns (bool) {
|
|
183
|
+
if (!isEncodedArray(data)) return false;
|
|
188
184
|
|
|
189
|
-
uint256 offset = uint256(bytes32(
|
|
190
|
-
uint256 arrayLength =
|
|
185
|
+
uint256 offset = uint256(bytes32(data));
|
|
186
|
+
uint256 arrayLength = data.toUint256(offset);
|
|
191
187
|
uint256 pointer = offset + 32;
|
|
192
188
|
|
|
193
189
|
for (uint256 ii = 0; ii < arrayLength; ii++) {
|
|
194
|
-
bytes32 key =
|
|
190
|
+
bytes32 key = data.toBytes32(pointer);
|
|
195
191
|
|
|
196
192
|
// check that the trailing bytes are zero bytes "00"
|
|
197
193
|
if (uint224(uint256(key)) != 0) return false;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// SPDX-License-Identifier: CC0-1.0
|
|
2
2
|
pragma solidity ^0.8.0;
|
|
3
3
|
|
|
4
|
-
// bytes10(keccak256('
|
|
4
|
+
// bytes10(keccak256('SupportedStandards')) + bytes2(0) + bytes20(keccak256('LSP3UniversalProfile'))
|
|
5
5
|
bytes32 constant _LSP3_SUPPORTED_STANDARDS_KEY = 0xeafec4d89fa9619884b60000abe425d64acd861a49b8ddf5c0b6962110481f38;
|
|
6
6
|
|
|
7
7
|
// bytes4(keccak256('LSP3UniversalProfile'))
|
|
@@ -3,7 +3,7 @@ pragma solidity ^0.8.0;
|
|
|
3
3
|
|
|
4
4
|
// --- ERC725Y entries
|
|
5
5
|
|
|
6
|
-
// bytes10(keccak256('
|
|
6
|
+
// bytes10(keccak256('SupportedStandards')) + bytes2(0) + bytes20(keccak256('LSP4DigitalAsset'))
|
|
7
7
|
bytes32 constant _LSP4_SUPPORTED_STANDARDS_KEY = 0xeafec4d89fa9619884b60000a4d96624a38f7ac2d8d9a604ecf07c12c77e480c;
|
|
8
8
|
|
|
9
9
|
// bytes4(keccak256('LSP4DigitalAsset'))
|
|
@@ -7,6 +7,9 @@ import {ERC725Y} from "@erc725/smart-contracts/contracts/ERC725Y.sol";
|
|
|
7
7
|
// constants
|
|
8
8
|
import "./LSP4Constants.sol";
|
|
9
9
|
|
|
10
|
+
// errors
|
|
11
|
+
import {LSP4TokenNameNotEditable, LSP4TokenSymbolNotEditable} from "./LSP4Errors.sol";
|
|
12
|
+
|
|
10
13
|
/**
|
|
11
14
|
* @title LSP4DigitalAssetMetadata
|
|
12
15
|
* @author Matthew Stevens
|
|
@@ -31,9 +34,17 @@ abstract contract LSP4DigitalAssetMetadata is ERC725Y {
|
|
|
31
34
|
super._setData(_LSP4_TOKEN_SYMBOL_KEY, bytes(symbol_));
|
|
32
35
|
}
|
|
33
36
|
|
|
37
|
+
/**
|
|
38
|
+
* @dev the ERC725Y data keys `LSP4TokenName` and `LSP4TokenSymbol` cannot be changed via this function
|
|
39
|
+
* once the digital asset contract has been deployed
|
|
40
|
+
*/
|
|
34
41
|
function _setData(bytes32 key, bytes memory value) internal virtual override {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
42
|
+
if (key == _LSP4_TOKEN_NAME_KEY) {
|
|
43
|
+
revert LSP4TokenNameNotEditable();
|
|
44
|
+
} else if (key == _LSP4_TOKEN_SYMBOL_KEY) {
|
|
45
|
+
revert LSP4TokenSymbolNotEditable();
|
|
46
|
+
} else {
|
|
47
|
+
super._setData(key, value);
|
|
48
|
+
}
|
|
38
49
|
}
|
|
39
50
|
}
|
|
@@ -2,11 +2,15 @@
|
|
|
2
2
|
pragma solidity ^0.8.0;
|
|
3
3
|
|
|
4
4
|
// modules
|
|
5
|
-
import {ERC725YInitAbstract
|
|
5
|
+
import {ERC725YInitAbstract} from "@erc725/smart-contracts/contracts/ERC725YInitAbstract.sol";
|
|
6
|
+
import {ERC725YCore} from "@erc725/smart-contracts/contracts/ERC725YCore.sol";
|
|
6
7
|
|
|
7
8
|
// constants
|
|
8
9
|
import "./LSP4Constants.sol";
|
|
9
10
|
|
|
11
|
+
// errors
|
|
12
|
+
import {LSP4TokenNameNotEditable, LSP4TokenSymbolNotEditable} from "./LSP4Errors.sol";
|
|
13
|
+
|
|
10
14
|
/**
|
|
11
15
|
* @title LSP4DigitalAssetMetadata
|
|
12
16
|
* @author Matthew Stevens
|
|
@@ -27,9 +31,17 @@ abstract contract LSP4DigitalAssetMetadataInitAbstract is ERC725YInitAbstract {
|
|
|
27
31
|
super._setData(_LSP4_TOKEN_SYMBOL_KEY, bytes(symbol_));
|
|
28
32
|
}
|
|
29
33
|
|
|
34
|
+
/**
|
|
35
|
+
* @dev the ERC725Y data keys `LSP4TokenName` and `LSP4TokenSymbol` cannot be changed via this function
|
|
36
|
+
* once the digital asset contract has been deployed
|
|
37
|
+
*/
|
|
30
38
|
function _setData(bytes32 key, bytes memory value) internal virtual override {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
39
|
+
if (key == _LSP4_TOKEN_NAME_KEY) {
|
|
40
|
+
revert LSP4TokenNameNotEditable();
|
|
41
|
+
} else if (key == _LSP4_TOKEN_SYMBOL_KEY) {
|
|
42
|
+
revert LSP4TokenSymbolNotEditable();
|
|
43
|
+
} else {
|
|
44
|
+
super._setData(key, value);
|
|
45
|
+
}
|
|
34
46
|
}
|
|
35
47
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @dev Reverts when trying to edit the data key `LSP4TokenName` after the digital asset contract has been deployed.
|
|
6
|
+
* The `LSP4TokenName` data key is located inside the ERC725Y key-value store of the digital asset contract.
|
|
7
|
+
* It can be set only once inside the constructor/initializer when the digital asset contract is being deployed.
|
|
8
|
+
*/
|
|
9
|
+
error LSP4TokenNameNotEditable();
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @dev Reverts when trying to edit the data key `LSP4TokenSymbol` after the digital asset contract has been deployed.
|
|
13
|
+
* The `LSP4TokenSymbol` data key is located inside the ERC725Y key-value store of the digital asset contract.
|
|
14
|
+
* It can be set only once inside the constructor/initializer when the digital asset contract is being deployed.
|
|
15
|
+
*/
|
|
16
|
+
error LSP4TokenSymbolNotEditable();
|