@lukso/lsp-smart-contracts 0.8.2 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -8
- package/artifacts/LSP0ERC725Account.json +90 -50
- package/artifacts/LSP0ERC725AccountInit.json +90 -50
- package/artifacts/LSP11BasicSocialRecovery.json +2 -2
- package/artifacts/LSP11BasicSocialRecoveryInit.json +2 -2
- package/artifacts/LSP16UniversalFactory.json +31 -2
- package/artifacts/LSP1UniversalReceiverDelegateUP.json +19 -35
- package/artifacts/LSP1UniversalReceiverDelegateVault.json +13 -13
- package/artifacts/LSP4Compatibility.json +39 -40
- package/artifacts/LSP4DigitalAssetMetadata.json +39 -40
- package/artifacts/LSP4DigitalAssetMetadataInitAbstract.json +39 -40
- package/artifacts/LSP6KeyManager.json +107 -8
- package/artifacts/LSP6KeyManagerInit.json +119 -20
- package/artifacts/LSP7CappedSupply.json +78 -38
- package/artifacts/LSP7CappedSupplyInitAbstract.json +78 -38
- package/artifacts/LSP7CompatibleERC20.json +78 -38
- package/artifacts/LSP7CompatibleERC20InitAbstract.json +78 -38
- package/artifacts/LSP7CompatibleERC20Mintable.json +80 -40
- package/artifacts/LSP7CompatibleERC20MintableInit.json +80 -40
- package/artifacts/LSP7DigitalAsset.json +78 -38
- package/artifacts/LSP7DigitalAssetInitAbstract.json +78 -38
- package/artifacts/LSP7Mintable.json +80 -40
- package/artifacts/LSP7MintableInit.json +80 -40
- package/artifacts/LSP8CappedSupply.json +39 -40
- package/artifacts/LSP8CappedSupplyInitAbstract.json +39 -40
- package/artifacts/LSP8CompatibleERC721.json +42 -43
- package/artifacts/LSP8CompatibleERC721InitAbstract.json +42 -43
- package/artifacts/LSP8CompatibleERC721Mintable.json +44 -45
- package/artifacts/LSP8CompatibleERC721MintableInit.json +44 -45
- package/artifacts/LSP8IdentifiableDigitalAsset.json +39 -40
- package/artifacts/LSP8IdentifiableDigitalAssetInitAbstract.json +39 -40
- package/artifacts/LSP8Mintable.json +41 -42
- package/artifacts/LSP8MintableInit.json +41 -42
- package/artifacts/LSP9Vault.json +73 -55
- package/artifacts/LSP9VaultInit.json +73 -55
- package/artifacts/UniversalProfile.json +90 -50
- package/artifacts/UniversalProfileInit.json +90 -50
- package/contracts/LSP0ERC725Account/ILSP0ERC725Account.sol +62 -0
- package/contracts/LSP0ERC725Account/LSP0Constants.sol +1 -1
- package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +36 -6
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +605 -219
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +31 -5
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +37 -3
- package/contracts/LSP0ERC725Account/LSP0Utils.sol +0 -1
- package/contracts/LSP10ReceivedVaults/LSP10Utils.sol +71 -60
- package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryCore.sol +5 -7
- package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryInit.sol +0 -1
- package/contracts/LSP14Ownable2Step/ILSP14Ownable2Step.sol +27 -4
- package/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol +41 -84
- package/contracts/LSP16UniversalFactory/LSP16UniversalFactory.sol +8 -8
- package/contracts/LSP17ContractExtension/LSP17Extendable.sol +10 -5
- package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiver.sol +0 -4
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +129 -77
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +45 -16
- package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +12 -0
- package/contracts/LSP20CallVerification/ILSP20CallVerification.sol +30 -0
- package/contracts/LSP20CallVerification/LSP20CallVerification.sol +83 -0
- package/contracts/LSP20CallVerification/LSP20Constants.sol +17 -0
- package/contracts/LSP20CallVerification/LSP20Errors.sol +15 -0
- package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +26 -12
- package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +0 -1
- package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +76 -66
- package/contracts/LSP6KeyManager/ILSP6KeyManager.sol +12 -3
- package/contracts/LSP6KeyManager/LSP6Constants.sol +9 -3
- package/contracts/LSP6KeyManager/LSP6Errors.sol +22 -1
- package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +172 -29
- package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +0 -1
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6ExecuteModule.sol +270 -100
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6SetDataModule.sol +187 -67
- package/contracts/LSP6KeyManager/LSP6Utils.sol +31 -20
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +79 -30
- package/contracts/LSP7DigitalAsset/LSP7Errors.sol +5 -0
- package/contracts/LSP7DigitalAsset/extensions/LSP7Burnable.sol +2 -2
- package/contracts/LSP7DigitalAsset/extensions/LSP7BurnableInitAbstract.sol +24 -0
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupply.sol +1 -2
- package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInitAbstract.sol +1 -2
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.sol +3 -5
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20InitAbstract.sol +3 -5
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +27 -29
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CompatibleERC721.sol +1 -1
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.sol +1 -2
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInitAbstract.sol +1 -2
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +5 -5
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +6 -6
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.sol +2 -2
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableInitAbstract.sol +2 -2
- package/contracts/LSP9Vault/ILSP9Vault.sol +27 -0
- package/contracts/LSP9Vault/LSP9Constants.sol +1 -1
- package/contracts/LSP9Vault/LSP9Vault.sol +11 -8
- package/contracts/LSP9Vault/LSP9VaultCore.sol +96 -71
- package/contracts/LSP9Vault/LSP9VaultInit.sol +2 -1
- package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +19 -7
- package/contracts/UniversalProfileInitAbstract.sol +5 -0
- package/devdocs/Create2Factory.json +16 -0
- package/devdocs/LSP0ERC725Account.json +200 -0
- package/devdocs/LSP0ERC725AccountInit.json +203 -0
- package/devdocs/LSP11BasicSocialRecovery.json +146 -0
- package/devdocs/LSP11BasicSocialRecoveryInit.json +146 -0
- package/devdocs/LSP16UniversalFactory.json +51 -0
- package/devdocs/LSP1UniversalReceiverDelegateUP.json +80 -0
- package/devdocs/LSP1UniversalReceiverDelegateVault.json +62 -0
- package/devdocs/LSP4Compatibility.json +79 -0
- package/devdocs/LSP4DigitalAssetMetadata.json +84 -0
- package/devdocs/LSP4DigitalAssetMetadataInitAbstract.json +77 -0
- package/devdocs/LSP6KeyManager.json +257 -0
- package/devdocs/LSP6KeyManagerInit.json +260 -0
- package/devdocs/LSP7CappedSupply.json +211 -0
- package/devdocs/LSP7CappedSupplyInitAbstract.json +206 -0
- package/devdocs/LSP7CompatibleERC20.json +225 -0
- package/devdocs/LSP7CompatibleERC20InitAbstract.json +218 -0
- package/devdocs/LSP7CompatibleERC20Mintable.json +217 -0
- package/devdocs/LSP7CompatibleERC20MintableInit.json +227 -0
- package/devdocs/LSP7DigitalAsset.json +210 -0
- package/devdocs/LSP7DigitalAssetInitAbstract.json +202 -0
- package/devdocs/LSP7Mintable.json +219 -0
- package/devdocs/LSP7MintableInit.json +220 -0
- package/devdocs/LSP8CappedSupply.json +232 -0
- package/devdocs/LSP8CappedSupplyInitAbstract.json +227 -0
- package/devdocs/LSP8CompatibleERC721.json +298 -0
- package/devdocs/LSP8CompatibleERC721InitAbstract.json +291 -0
- package/devdocs/LSP8CompatibleERC721Mintable.json +290 -0
- package/devdocs/LSP8CompatibleERC721MintableInit.json +300 -0
- package/devdocs/LSP8IdentifiableDigitalAsset.json +230 -0
- package/devdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +223 -0
- package/devdocs/LSP8Mintable.json +242 -0
- package/devdocs/LSP8MintableInit.json +245 -0
- package/devdocs/LSP9Vault.json +171 -0
- package/devdocs/LSP9VaultInit.json +175 -0
- package/devdocs/UniversalProfile.json +199 -0
- package/devdocs/UniversalProfileInit.json +202 -0
- package/devdocs/UniversalReceiverAddressStore.json +9 -0
- package/dist/constants.cjs.js +31569 -0
- package/dist/constants.d.ts +31681 -0
- package/dist/constants.es.js +31550 -0
- package/package.json +70 -52
- package/userdocs/Create2Factory.json +5 -0
- package/userdocs/LSP0ERC725Account.json +47 -0
- package/userdocs/LSP0ERC725AccountInit.json +47 -0
- package/userdocs/LSP11BasicSocialRecovery.json +29 -0
- package/userdocs/LSP11BasicSocialRecoveryInit.json +29 -0
- package/userdocs/LSP16UniversalFactory.json +5 -0
- package/userdocs/LSP1UniversalReceiverDelegateUP.json +10 -0
- package/userdocs/LSP1UniversalReceiverDelegateVault.json +10 -0
- package/userdocs/LSP4Compatibility.json +20 -0
- package/userdocs/LSP4DigitalAssetMetadata.json +23 -0
- package/userdocs/LSP4DigitalAssetMetadataInitAbstract.json +20 -0
- package/userdocs/LSP6KeyManager.json +18 -0
- package/userdocs/LSP6KeyManagerInit.json +18 -0
- package/userdocs/LSP7CappedSupply.json +29 -0
- package/userdocs/LSP7CappedSupplyInitAbstract.json +26 -0
- package/userdocs/LSP7CompatibleERC20.json +35 -0
- package/userdocs/LSP7CompatibleERC20InitAbstract.json +32 -0
- package/userdocs/LSP7CompatibleERC20Mintable.json +32 -0
- package/userdocs/LSP7CompatibleERC20MintableInit.json +35 -0
- package/userdocs/LSP7DigitalAsset.json +29 -0
- package/userdocs/LSP7DigitalAssetInitAbstract.json +26 -0
- package/userdocs/LSP7Mintable.json +29 -0
- package/userdocs/LSP7MintableInit.json +29 -0
- package/userdocs/LSP8CappedSupply.json +23 -0
- package/userdocs/LSP8CappedSupplyInitAbstract.json +20 -0
- package/userdocs/LSP8CompatibleERC721.json +29 -0
- package/userdocs/LSP8CompatibleERC721InitAbstract.json +26 -0
- package/userdocs/LSP8CompatibleERC721Mintable.json +26 -0
- package/userdocs/LSP8CompatibleERC721MintableInit.json +29 -0
- package/userdocs/LSP8IdentifiableDigitalAsset.json +23 -0
- package/userdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +20 -0
- package/userdocs/LSP8Mintable.json +23 -0
- package/userdocs/LSP8MintableInit.json +23 -0
- package/userdocs/LSP9Vault.json +38 -0
- package/userdocs/LSP9VaultInit.json +38 -0
- package/userdocs/UniversalProfile.json +50 -0
- package/userdocs/UniversalProfileInit.json +50 -0
- package/userdocs/UniversalReceiverAddressStore.json +5 -0
- package/CONTRIBUTING.md +0 -57
- package/common/constants.d.ts +0 -738
- package/common/constants.js +0 -785
- package/contracts/Utils/GasLib.sol +0 -17
- package/module/constants.d.ts +0 -738
- package/module/constants.js +0 -782
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.4;
|
|
3
|
+
|
|
4
|
+
// bytes4(keccak256("LSP20CallVerification"))
|
|
5
|
+
bytes4 constant _INTERFACEID_LSP20_CALL_VERIFICATION = 0x1a0eb6a5;
|
|
6
|
+
|
|
7
|
+
// `lsp20VerifyCall(address,uint256,bytes)` selector XOR `lsp20VerifyCallResult(bytes32,bytes)` selector
|
|
8
|
+
bytes4 constant _INTERFACEID_LSP20_CALL_VERIFIER = 0x480c0ec2;
|
|
9
|
+
|
|
10
|
+
// bytes4(bytes.concat(bytes3(ILSP20.lsp20VerifyCall.selector), hex"01"))
|
|
11
|
+
bytes4 constant _LSP20_VERIFY_CALL_MAGIC_VALUE_WITH_POST_VERIFICATION = 0x9bf04b01;
|
|
12
|
+
|
|
13
|
+
// bytes4(bytes.concat(bytes3(ILSP20.lsp20VerifyCall.selector), hex"00"))
|
|
14
|
+
bytes4 constant _LSP20_VERIFY_CALL_MAGIC_VALUE_WITHOUT_POST_VERIFICATION = 0x9bf04b00;
|
|
15
|
+
|
|
16
|
+
// bytes4(ILSP20.lsp20VerifyCallResult.selector)
|
|
17
|
+
bytes4 constant _LSP20_VERIFY_CALL_RESULT_MAGIC_VALUE = 0xd3fc45d3;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.4;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @dev reverts when the call to the owner fail with no revert reason
|
|
6
|
+
* @param postCall True if the execution call was done, False otherwise
|
|
7
|
+
*/
|
|
8
|
+
error LSP20CallingVerifierFailed(bool postCall);
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @dev reverts when the call to the owner does not return the magic value
|
|
12
|
+
* @param postCall True if the execution call was done, False otherwise
|
|
13
|
+
* @param postCall The data returned by the call to the logic verifier
|
|
14
|
+
*/
|
|
15
|
+
error LSP20InvalidMagicValue(bool postCall, bytes returnedData);
|
|
@@ -144,6 +144,22 @@ library LSP2Utils {
|
|
|
144
144
|
return bytes32(temporaryBytes);
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
+
/**
|
|
148
|
+
* @dev Generate a data key of keyType MappingWithGrouping
|
|
149
|
+
* <bytes6keyPrefix>:<bytes4mapPrefix>:<bytes2(0)>:<subMapKey>
|
|
150
|
+
* @param keyPrefix the first part of the data key of keyType MappingWithGrouping
|
|
151
|
+
* @param mapPrefix Used for the second part (bytes4) of the data key of keyType MappingWithGrouping
|
|
152
|
+
* @param subMapKey Used for the last part (bytes20) of the data key of keyType MappingWithGrouping
|
|
153
|
+
*/
|
|
154
|
+
function generateMappingWithGroupingKey(
|
|
155
|
+
bytes6 keyPrefix,
|
|
156
|
+
bytes4 mapPrefix,
|
|
157
|
+
bytes20 subMapKey
|
|
158
|
+
) internal pure returns (bytes32) {
|
|
159
|
+
bytes memory generatedKey = bytes.concat(keyPrefix, mapPrefix, bytes2(0), subMapKey);
|
|
160
|
+
return bytes32(generatedKey);
|
|
161
|
+
}
|
|
162
|
+
|
|
147
163
|
/**
|
|
148
164
|
* @dev Generate a data key of keyType MappingWithGrouping
|
|
149
165
|
* <bytes10keyPrefix>:<bytes2(0)>:<bytes20Value>
|
|
@@ -225,7 +241,7 @@ library LSP2Utils {
|
|
|
225
241
|
|
|
226
242
|
uint256 pointer = offset + 32;
|
|
227
243
|
|
|
228
|
-
for (uint256 ii = 0; ii < arrayLength;
|
|
244
|
+
for (uint256 ii = 0; ii < arrayLength; ) {
|
|
229
245
|
bytes32 key = data.toBytes32(pointer);
|
|
230
246
|
|
|
231
247
|
// check that the leading bytes are zero bytes "00"
|
|
@@ -234,6 +250,10 @@ library LSP2Utils {
|
|
|
234
250
|
|
|
235
251
|
// increment the pointer
|
|
236
252
|
pointer += 32;
|
|
253
|
+
|
|
254
|
+
unchecked {
|
|
255
|
+
++ii;
|
|
256
|
+
}
|
|
237
257
|
}
|
|
238
258
|
|
|
239
259
|
return true;
|
|
@@ -250,7 +270,7 @@ library LSP2Utils {
|
|
|
250
270
|
uint256 arrayLength = data.toUint256(offset);
|
|
251
271
|
uint256 pointer = offset + 32;
|
|
252
272
|
|
|
253
|
-
for (uint256 ii = 0; ii < arrayLength;
|
|
273
|
+
for (uint256 ii = 0; ii < arrayLength; ) {
|
|
254
274
|
bytes32 key = data.toBytes32(pointer);
|
|
255
275
|
|
|
256
276
|
// check that the trailing bytes are zero bytes "00"
|
|
@@ -258,6 +278,10 @@ library LSP2Utils {
|
|
|
258
278
|
|
|
259
279
|
// increment the pointer
|
|
260
280
|
pointer += 32;
|
|
281
|
+
|
|
282
|
+
unchecked {
|
|
283
|
+
++ii;
|
|
284
|
+
}
|
|
261
285
|
}
|
|
262
286
|
|
|
263
287
|
return true;
|
|
@@ -296,14 +320,4 @@ library LSP2Utils {
|
|
|
296
320
|
if (pointer == compactBytesArray.length) return true;
|
|
297
321
|
return false;
|
|
298
322
|
}
|
|
299
|
-
|
|
300
|
-
/**
|
|
301
|
-
* @dev Will return unchecked incremented uint256
|
|
302
|
-
* can be used to save gas when iterating over loops
|
|
303
|
-
*/
|
|
304
|
-
function uncheckedIncrement(uint256 i) internal pure returns (uint256) {
|
|
305
|
-
unchecked {
|
|
306
|
-
return i + 1;
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
323
|
}
|
|
@@ -3,7 +3,6 @@ pragma solidity ^0.8.4;
|
|
|
3
3
|
|
|
4
4
|
// modules
|
|
5
5
|
import {ERC725YInitAbstract} from "@erc725/smart-contracts/contracts/ERC725YInitAbstract.sol";
|
|
6
|
-
import {ERC725YCore} from "@erc725/smart-contracts/contracts/ERC725YCore.sol";
|
|
7
6
|
|
|
8
7
|
// libraries
|
|
9
8
|
import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol";
|
|
@@ -14,25 +14,25 @@ import "../LSP7DigitalAsset/LSP7Constants.sol";
|
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* @dev reverts when the value stored under the 'LSP5ReceivedAssets[]' data key is not valid.
|
|
17
|
-
* The value stored under this data key should be exactly
|
|
17
|
+
* The value stored under this data key should be exactly 16 bytes long.
|
|
18
18
|
*
|
|
19
19
|
* Only possible valid values are:
|
|
20
|
-
* - any valid
|
|
21
|
-
* i.e.
|
|
22
|
-
* i.e.
|
|
20
|
+
* - any valid uint128 values
|
|
21
|
+
* i.e. 0x00000000000000000000000000000000 (zero), empty array, no assets received.
|
|
22
|
+
* i.e. 0x00000000000000000000000000000005 (non-zero), 5 array elements, 5 assets received.
|
|
23
23
|
*
|
|
24
24
|
* - 0x (nothing stored under this data key, equivalent to empty array)
|
|
25
25
|
*
|
|
26
|
-
* @param
|
|
27
|
-
* @param invalidValueLength the invalid number of bytes stored under the LSP5ReceivedAssets[] data key (MUST be
|
|
26
|
+
* @param invalidValueStored the invalid value stored under the LSP5ReceivedAssets[] data key
|
|
27
|
+
* @param invalidValueLength the invalid number of bytes stored under the LSP5ReceivedAssets[] data key (MUST be exactly 16 bytes long)
|
|
28
28
|
*/
|
|
29
|
-
error InvalidLSP5ReceivedAssetsArrayLength(bytes
|
|
29
|
+
error InvalidLSP5ReceivedAssetsArrayLength(bytes invalidValueStored, uint256 invalidValueLength);
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
|
-
* @dev reverts when the
|
|
33
|
-
* @param
|
|
32
|
+
* @dev reverts when the `LSP5ReceivedAssets[]` array reaches its maximum limit (max(uint128))
|
|
33
|
+
* @param notRegisteredAsset the address of the asset that could not be registered
|
|
34
34
|
*/
|
|
35
|
-
error
|
|
35
|
+
error MaxLSP5ReceivedAssetsCountReached(address notRegisteredAsset);
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* @dev reverts when the received assets index is superior to uint128
|
|
@@ -68,44 +68,36 @@ library LSP5Utils {
|
|
|
68
68
|
IERC725Y account = IERC725Y(receiver);
|
|
69
69
|
bytes memory encodedArrayLength = getLSP5ReceivedAssetsCount(account);
|
|
70
70
|
|
|
71
|
-
//
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
keys[2] = assetMapKey;
|
|
80
|
-
values[2] = bytes.concat(interfaceID, bytes8(0));
|
|
81
|
-
|
|
82
|
-
// If the storage is already initiated
|
|
83
|
-
} else if (encodedArrayLength.length == 32) {
|
|
84
|
-
uint256 oldArrayLength = uint256(bytes32(encodedArrayLength));
|
|
71
|
+
// CHECK it's either the first asset received,
|
|
72
|
+
// or the storage is already set with a valid `uint128` value
|
|
73
|
+
if (encodedArrayLength.length != 0 && encodedArrayLength.length != 16) {
|
|
74
|
+
revert InvalidLSP5ReceivedAssetsArrayLength({
|
|
75
|
+
invalidValueStored: encodedArrayLength,
|
|
76
|
+
invalidValueLength: encodedArrayLength.length
|
|
77
|
+
});
|
|
78
|
+
}
|
|
85
79
|
|
|
86
|
-
|
|
87
|
-
revert ReceivedAssetsIndexSuperiorToUint64(oldArrayLength);
|
|
88
|
-
}
|
|
80
|
+
uint128 oldArrayLength = uint128(bytes16(encodedArrayLength));
|
|
89
81
|
|
|
90
|
-
|
|
82
|
+
if (oldArrayLength == type(uint128).max) {
|
|
83
|
+
revert MaxLSP5ReceivedAssetsCountReached({notRegisteredAsset: asset});
|
|
84
|
+
}
|
|
91
85
|
|
|
92
|
-
|
|
93
|
-
|
|
86
|
+
// store the number of received assets incremented by 1
|
|
87
|
+
keys[0] = _LSP5_RECEIVED_ASSETS_ARRAY_KEY;
|
|
88
|
+
values[0] = bytes.concat(bytes16(oldArrayLength + 1));
|
|
94
89
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
90
|
+
// store the address of the asset under the element key in the array
|
|
91
|
+
keys[1] = LSP2Utils.generateArrayElementKeyAtIndex(
|
|
92
|
+
_LSP5_RECEIVED_ASSETS_ARRAY_KEY,
|
|
93
|
+
oldArrayLength
|
|
94
|
+
);
|
|
95
|
+
values[1] = bytes.concat(bytes20(asset));
|
|
100
96
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
encodedArrayLength,
|
|
106
|
-
encodedArrayLength.length
|
|
107
|
-
);
|
|
108
|
-
}
|
|
97
|
+
// store the interfaceId and the location in the array of the asset
|
|
98
|
+
// under the LSP5ReceivedAssetMap key
|
|
99
|
+
keys[2] = assetMapKey;
|
|
100
|
+
values[2] = bytes.concat(interfaceID, bytes16(oldArrayLength));
|
|
109
101
|
}
|
|
110
102
|
|
|
111
103
|
/**
|
|
@@ -113,26 +105,36 @@ library LSP5Utils {
|
|
|
113
105
|
* @param sender The address sending the asset and where the Keys should be updated
|
|
114
106
|
* @param assetMapKey The map key of the asset being received containing the interfaceId of the
|
|
115
107
|
* asset and the index in the array
|
|
116
|
-
* @param
|
|
108
|
+
* @param assetIndex The index in the LSP5ReceivedAssets[] array
|
|
117
109
|
*/
|
|
118
110
|
function generateSentAssetKeys(
|
|
119
111
|
address sender,
|
|
120
112
|
bytes32 assetMapKey,
|
|
121
|
-
|
|
113
|
+
uint128 assetIndex
|
|
122
114
|
) internal view returns (bytes32[] memory keys, bytes[] memory values) {
|
|
123
115
|
IERC725Y account = IERC725Y(sender);
|
|
116
|
+
bytes memory lsp5ReceivedAssetsCountValue = getLSP5ReceivedAssetsCount(account);
|
|
124
117
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
118
|
+
if (lsp5ReceivedAssetsCountValue.length != 16) {
|
|
119
|
+
revert InvalidLSP5ReceivedAssetsArrayLength({
|
|
120
|
+
invalidValueStored: lsp5ReceivedAssetsCountValue,
|
|
121
|
+
invalidValueLength: lsp5ReceivedAssetsCountValue.length
|
|
122
|
+
});
|
|
123
|
+
}
|
|
128
124
|
|
|
129
|
-
|
|
125
|
+
uint128 oldArrayLength = uint128(bytes16(lsp5ReceivedAssetsCountValue));
|
|
126
|
+
|
|
127
|
+
// Updating the number of the received assets (decrementing by 1
|
|
128
|
+
uint128 newArrayLength = oldArrayLength - 1;
|
|
129
|
+
|
|
130
|
+
// Generate the element key in the array of the asset
|
|
130
131
|
bytes32 assetInArrayKey = LSP2Utils.generateArrayElementKeyAtIndex(
|
|
131
132
|
_LSP5_RECEIVED_ASSETS_ARRAY_KEY,
|
|
132
|
-
|
|
133
|
+
assetIndex
|
|
133
134
|
);
|
|
134
135
|
|
|
135
|
-
|
|
136
|
+
// If the asset to remove is the last element in the array
|
|
137
|
+
if (assetIndex == newArrayLength) {
|
|
136
138
|
/**
|
|
137
139
|
* We will be updating/removing 3 keys:
|
|
138
140
|
* - Keys[0]: [Update] The arrayLengthKey to contain the new number of the received assets
|
|
@@ -142,18 +144,21 @@ library LSP5Utils {
|
|
|
142
144
|
keys = new bytes32[](3);
|
|
143
145
|
values = new bytes[](3);
|
|
144
146
|
|
|
147
|
+
// store the number of received assets decremented by 1
|
|
145
148
|
keys[0] = _LSP5_RECEIVED_ASSETS_ARRAY_KEY;
|
|
146
|
-
values[0] = bytes.concat(
|
|
149
|
+
values[0] = bytes.concat(bytes16(newArrayLength));
|
|
147
150
|
|
|
151
|
+
// remove the address of the asset from the element key
|
|
148
152
|
keys[1] = assetInArrayKey;
|
|
149
153
|
values[1] = "";
|
|
150
154
|
|
|
155
|
+
// remove the interfaceId and the location in the array of the asset
|
|
151
156
|
keys[2] = assetMapKey;
|
|
152
157
|
values[2] = "";
|
|
153
158
|
|
|
154
159
|
// Swapping last element in ArrayKey with the element in ArrayKey to remove || {Swap and pop} method;
|
|
155
160
|
// check https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/structs/EnumerableSet.sol#L80
|
|
156
|
-
} else {
|
|
161
|
+
} else if (assetIndex < newArrayLength) {
|
|
157
162
|
/**
|
|
158
163
|
* We will be updating/removing 5 keys:
|
|
159
164
|
* - Keys[0]: [Update] The arrayLengthKey to contain the new number of the received assets
|
|
@@ -165,9 +170,11 @@ library LSP5Utils {
|
|
|
165
170
|
keys = new bytes32[](5);
|
|
166
171
|
values = new bytes[](5);
|
|
167
172
|
|
|
173
|
+
// store the number of received assets decremented by 1
|
|
168
174
|
keys[0] = _LSP5_RECEIVED_ASSETS_ARRAY_KEY;
|
|
169
|
-
values[0] = bytes.concat(
|
|
175
|
+
values[0] = bytes.concat(bytes16(newArrayLength));
|
|
170
176
|
|
|
177
|
+
// remove the interfaceId and the location in the array of the asset
|
|
171
178
|
keys[1] = assetMapKey;
|
|
172
179
|
values[1] = "";
|
|
173
180
|
|
|
@@ -175,45 +182,48 @@ library LSP5Utils {
|
|
|
175
182
|
revert ReceivedAssetsIndexSuperiorToUint128(newArrayLength);
|
|
176
183
|
}
|
|
177
184
|
|
|
178
|
-
uint128 newArrayLength128 = uint128(newArrayLength);
|
|
179
|
-
|
|
180
185
|
// Generate all data Keys/values of the last element in Array to swap
|
|
181
186
|
// with data Keys/values of the asset to remove
|
|
187
|
+
|
|
188
|
+
// Generate the element key of the last asset in the array
|
|
182
189
|
bytes32 lastAssetInArrayKey = LSP2Utils.generateArrayElementKeyAtIndex(
|
|
183
190
|
_LSP5_RECEIVED_ASSETS_ARRAY_KEY,
|
|
184
|
-
|
|
191
|
+
newArrayLength
|
|
185
192
|
);
|
|
186
193
|
|
|
194
|
+
// Get the address of the asset from the element key of the last asset in the array
|
|
187
195
|
bytes20 lastAssetInArrayAddress = bytes20(account.getData(lastAssetInArrayKey));
|
|
188
196
|
|
|
197
|
+
// Generate the map key of the last asset in the array
|
|
189
198
|
bytes32 lastAssetInArrayMapKey = LSP2Utils.generateMappingKey(
|
|
190
199
|
_LSP5_RECEIVED_ASSETS_MAP_KEY_PREFIX,
|
|
191
200
|
lastAssetInArrayAddress
|
|
192
201
|
);
|
|
193
202
|
|
|
203
|
+
// Get the interfaceId and the location in the array of the last asset
|
|
194
204
|
bytes memory lastAssetInterfaceIdAndIndex = account.getData(lastAssetInArrayMapKey);
|
|
195
205
|
bytes memory interfaceID = BytesLib.slice(lastAssetInterfaceIdAndIndex, 0, 4);
|
|
196
206
|
|
|
207
|
+
// Set the address of the last asset instead of the asset to be sent
|
|
208
|
+
// under the element data key in the array
|
|
197
209
|
keys[2] = assetInArrayKey;
|
|
198
210
|
values[2] = bytes.concat(lastAssetInArrayAddress);
|
|
199
211
|
|
|
212
|
+
// Remove the address swapped from the last element data key in the array
|
|
200
213
|
keys[3] = lastAssetInArrayKey;
|
|
201
214
|
values[3] = "";
|
|
202
215
|
|
|
216
|
+
// Update the index and the interfaceId of the address swapped (last element in the array)
|
|
217
|
+
// to point to the new location in the LSP5ReceivedAssets array
|
|
203
218
|
keys[4] = lastAssetInArrayMapKey;
|
|
204
|
-
values[4] = bytes.concat(interfaceID,
|
|
219
|
+
values[4] = bytes.concat(interfaceID, bytes16(assetIndex));
|
|
220
|
+
} else {
|
|
221
|
+
// If index is bigger than the array length, out of bounds
|
|
222
|
+
return (keys, values);
|
|
205
223
|
}
|
|
206
224
|
}
|
|
207
225
|
|
|
208
226
|
function getLSP5ReceivedAssetsCount(IERC725Y account) internal view returns (bytes memory) {
|
|
209
227
|
return account.getData(_LSP5_RECEIVED_ASSETS_ARRAY_KEY);
|
|
210
228
|
}
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* @dev returns the index from a maping
|
|
214
|
-
*/
|
|
215
|
-
function extractIndexFromMap(bytes memory mapValue) internal pure returns (uint64) {
|
|
216
|
-
bytes memory val = BytesLib.slice(mapValue, 4, 8);
|
|
217
|
-
return BytesLib.toUint64(val, 0);
|
|
218
|
-
}
|
|
219
229
|
}
|
|
@@ -11,7 +11,13 @@ interface ILSP6KeyManager is
|
|
|
11
11
|
IERC1271
|
|
12
12
|
/* is ERC165 */
|
|
13
13
|
{
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* @dev Emitted when a calldata payload that includes `selector` and `value` as msg.value was verified for `signer`
|
|
16
|
+
* @param signer the address of the controller that executed the calldata payload.
|
|
17
|
+
* @param value the amount of native token to be transferred in the calldata payload.
|
|
18
|
+
* @param selector the bytes4 function of the function to run in the calldata payload.
|
|
19
|
+
*/
|
|
20
|
+
event VerifiedCall(address indexed signer, uint256 indexed value, bytes4 indexed selector);
|
|
15
21
|
|
|
16
22
|
/**
|
|
17
23
|
* @notice returns the address of the account linked to this KeyManager
|
|
@@ -43,7 +49,7 @@ interface ILSP6KeyManager is
|
|
|
43
49
|
/**
|
|
44
50
|
* @dev batch `execute(bytes)`
|
|
45
51
|
*/
|
|
46
|
-
function
|
|
52
|
+
function executeBatch(uint256[] calldata values, bytes[] calldata payloads)
|
|
47
53
|
external
|
|
48
54
|
payable
|
|
49
55
|
returns (bytes[] memory);
|
|
@@ -52,21 +58,24 @@ interface ILSP6KeyManager is
|
|
|
52
58
|
* @dev allows anybody to execute given they have a signed message from an executor
|
|
53
59
|
* @param signature bytes32 ethereum signature
|
|
54
60
|
* @param nonce the address' nonce (in a specific `_channel`), obtained via `getNonce(...)`. Used to prevent replay attack
|
|
61
|
+
* @param validityTimestamps two `uint128` timestamps concatenated, the first timestamp determines from when the payload can be executed, the second timestamp delimits the end of the validity of the payload. If `validityTimestamps` is 0, the checks regardin the timestamps are skipped
|
|
55
62
|
* @param payload obtained via encodeABI() in web3
|
|
56
63
|
* @return the data being returned by the ERC725 Account
|
|
57
64
|
*/
|
|
58
65
|
function executeRelayCall(
|
|
59
66
|
bytes calldata signature,
|
|
60
67
|
uint256 nonce,
|
|
68
|
+
uint256 validityTimestamps,
|
|
61
69
|
bytes calldata payload
|
|
62
70
|
) external payable returns (bytes memory);
|
|
63
71
|
|
|
64
72
|
/**
|
|
65
73
|
* @dev batch `executeRelayCall(...)`
|
|
66
74
|
*/
|
|
67
|
-
function
|
|
75
|
+
function executeRelayCallBatch(
|
|
68
76
|
bytes[] calldata signatures,
|
|
69
77
|
uint256[] calldata nonces,
|
|
78
|
+
uint256[] calldata validityTimestamps,
|
|
70
79
|
uint256[] calldata values,
|
|
71
80
|
bytes[] calldata payloads
|
|
72
81
|
) external payable returns (bytes[] memory);
|
|
@@ -4,7 +4,7 @@ pragma solidity ^0.8.4;
|
|
|
4
4
|
uint256 constant LSP6_VERSION = 6;
|
|
5
5
|
|
|
6
6
|
// --- ERC165 interface ids
|
|
7
|
-
bytes4 constant _INTERFACEID_LSP6 =
|
|
7
|
+
bytes4 constant _INTERFACEID_LSP6 = 0x38bb3cdb;
|
|
8
8
|
|
|
9
9
|
// --- ERC725Y Data Keys
|
|
10
10
|
|
|
@@ -33,8 +33,8 @@ bytes10 constant _LSP6KEY_ADDRESSPERMISSIONS_ALLOWEDCALLS_PREFIX = 0x4b80742de2b
|
|
|
33
33
|
// - AddressPermissions:AllowedERC725YDataKeys:...
|
|
34
34
|
// - AddressPermissions:AllowedCalls
|
|
35
35
|
bytes32 constant _PERMISSION_CHANGEOWNER = 0x0000000000000000000000000000000000000000000000000000000000000001;
|
|
36
|
-
bytes32 constant _PERMISSION_ADDCONTROLLER
|
|
37
|
-
bytes32 constant
|
|
36
|
+
bytes32 constant _PERMISSION_ADDCONTROLLER = 0x0000000000000000000000000000000000000000000000000000000000000002;
|
|
37
|
+
bytes32 constant _PERMISSION_EDITPERMISSIONS = 0x0000000000000000000000000000000000000000000000000000000000000004;
|
|
38
38
|
bytes32 constant _PERMISSION_ADDEXTENSIONS = 0x0000000000000000000000000000000000000000000000000000000000000008;
|
|
39
39
|
bytes32 constant _PERMISSION_CHANGEEXTENSIONS = 0x0000000000000000000000000000000000000000000000000000000000000010;
|
|
40
40
|
bytes32 constant _PERMISSION_ADDUNIVERSALRECEIVERDELEGATE = 0x0000000000000000000000000000000000000000000000000000000000000020;
|
|
@@ -63,3 +63,9 @@ bytes4 constant _LSP6_EXECUTE_SELECTOR = 0x09c5eabe;
|
|
|
63
63
|
bytes4 constant _LSP6_EXECUTE_BATCH_SELECTOR = 0xbf3e1f7b;
|
|
64
64
|
bytes4 constant _LSP6_EXECUTE_RELAYCALL_SELECTOR = 0x902d5fa0;
|
|
65
65
|
bytes4 constant _LSP6_EXECUTE_RELAYCALL_BATCH_SELECTOR = 0xbd68663a;
|
|
66
|
+
|
|
67
|
+
// AllowedCalls types
|
|
68
|
+
bytes4 constant _ALLOWEDCALLS_TRANSFERVALUE = 0x00000001; // 0000 0001
|
|
69
|
+
bytes4 constant _ALLOWEDCALLS_CALL = 0x00000002; // 0000 0010
|
|
70
|
+
bytes4 constant _ALLOWEDCALLS_STATICCALL = 0x00000004; // 0000 0100
|
|
71
|
+
bytes4 constant _ALLOWEDCALLS_DELEGATECALL = 0x00000008; // 0000 1000
|
|
@@ -88,8 +88,9 @@ error NoCallsAllowed(address from);
|
|
|
88
88
|
/**
|
|
89
89
|
* @dev reverts when `value` is not encoded properly using the CompactBytesArray
|
|
90
90
|
* @param value the value to check for an CompactBytesArray
|
|
91
|
+
* @param context a brief description of where the error occured
|
|
91
92
|
*/
|
|
92
|
-
error InvalidEncodedAllowedERC725YDataKeys(bytes value);
|
|
93
|
+
error InvalidEncodedAllowedERC725YDataKeys(bytes value, string context);
|
|
93
94
|
|
|
94
95
|
/**
|
|
95
96
|
* @dev a `from` address is not allowed to have 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
|
@@ -141,3 +142,23 @@ error DelegateCallDisallowedViaKeyManager();
|
|
|
141
142
|
* @dev reverts when the payload is invalid.
|
|
142
143
|
*/
|
|
143
144
|
error InvalidPayload(bytes payload);
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* @dev reverts when sending value to the `setData(..)` functions
|
|
148
|
+
*/
|
|
149
|
+
error CannotSendValueToSetData();
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* @dev reverts when calling the KeyManager through execute(..)
|
|
153
|
+
*/
|
|
154
|
+
error CallingKeyManagerNotAllowed();
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* @dev reverts when relay call start timestamp is bigger than the current timestamp
|
|
158
|
+
*/
|
|
159
|
+
error RelayCallBeforeStartTime();
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* @dev reverts when the period to execute the relay call has expired
|
|
163
|
+
*/
|
|
164
|
+
error RelayCallExpired();
|