@lukso/lsp-smart-contracts 0.12.0-rc.0 → 0.12.1
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/LSP0ERC725Account.json +18 -24
- package/artifacts/LSP0ERC725AccountInit.json +18 -24
- package/artifacts/LSP1UniversalReceiverDelegateUP.json +15 -2
- package/artifacts/LSP1UniversalReceiverDelegateVault.json +15 -2
- package/artifacts/LSP6KeyManager.json +25 -2
- package/artifacts/LSP6KeyManagerInit.json +25 -2
- package/artifacts/LSP7CappedSupply.json +22 -0
- package/artifacts/LSP7CappedSupplyInitAbstract.json +22 -0
- package/artifacts/LSP7CompatibleERC20.json +22 -0
- package/artifacts/LSP7CompatibleERC20InitAbstract.json +22 -0
- package/artifacts/LSP7CompatibleERC20Mintable.json +24 -2
- package/artifacts/LSP7CompatibleERC20MintableInit.json +24 -2
- package/artifacts/LSP7DigitalAsset.json +22 -0
- package/artifacts/LSP7DigitalAssetInitAbstract.json +22 -0
- package/artifacts/LSP7Mintable.json +24 -2
- package/artifacts/LSP7MintableInit.json +24 -2
- package/artifacts/LSP8CappedSupply.json +11 -0
- package/artifacts/LSP8CappedSupplyInitAbstract.json +11 -0
- package/artifacts/LSP8CompatibleERC721.json +11 -0
- package/artifacts/LSP8CompatibleERC721InitAbstract.json +11 -0
- package/artifacts/LSP8CompatibleERC721Mintable.json +13 -2
- package/artifacts/LSP8CompatibleERC721MintableInit.json +13 -2
- package/artifacts/LSP8IdentifiableDigitalAsset.json +11 -0
- package/artifacts/LSP8IdentifiableDigitalAssetInitAbstract.json +11 -0
- package/artifacts/LSP8Mintable.json +13 -2
- package/artifacts/LSP8MintableInit.json +13 -2
- package/artifacts/LSP9Vault.json +15 -21
- package/artifacts/LSP9VaultInit.json +15 -21
- package/artifacts/UniversalProfile.json +18 -24
- package/artifacts/UniversalProfileInit.json +18 -24
- package/contracts/LSP0ERC725Account/ILSP0ERC725Account.sol +0 -8
- package/contracts/LSP0ERC725Account/LSP0Constants.sol +6 -1
- package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +18 -4
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +132 -66
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +3 -2
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +14 -3
- package/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol +11 -10
- package/contracts/LSP17ContractExtension/LSP17Extendable.sol +12 -8
- package/contracts/LSP17ContractExtension/LSP17Extension.sol +2 -1
- package/contracts/LSP17Extensions/OnERC721ReceivedExtension.sol +2 -1
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +32 -11
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +25 -9
- package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +4 -3
- package/contracts/LSP20CallVerification/LSP20CallVerification.sol +43 -49
- package/contracts/LSP20CallVerification/LSP20Errors.sol +2 -2
- package/contracts/LSP25ExecuteRelayCall/LSP25MultiChannelNonce.sol +1 -5
- package/contracts/LSP6KeyManager/LSP6KeyManager.sol +2 -1
- package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +54 -8
- package/contracts/LSP6KeyManager/LSP6KeyManagerInit.sol +2 -1
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6ExecuteModule.sol +14 -16
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6SetDataModule.sol +9 -5
- package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +60 -0
- package/contracts/LSP7DigitalAsset/LSP7Constants.sol +1 -1
- package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +7 -5
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +111 -175
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +7 -5
- package/contracts/LSP7DigitalAsset/LSP7Errors.sol +5 -0
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.sol +8 -1
- package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20InitAbstract.sol +7 -1
- package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +5 -0
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol +8 -5
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +6 -5
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +30 -73
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +6 -5
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +7 -7
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +7 -7
- package/contracts/LSP9Vault/ILSP9Vault.sol +0 -8
- package/contracts/LSP9Vault/LSP9Constants.sol +6 -1
- package/contracts/LSP9Vault/LSP9Vault.sol +14 -4
- package/contracts/LSP9Vault/LSP9VaultCore.sol +80 -37
- package/contracts/LSP9Vault/LSP9VaultInit.sol +3 -2
- package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +12 -3
- package/contracts/UniversalProfile.sol +5 -3
- package/contracts/UniversalProfileInit.sol +9 -6
- package/contracts/UniversalProfileInitAbstract.sol +5 -3
- package/contracts/Version.sol +17 -0
- package/devdocs/LSP0ERC725Account.json +11 -10
- package/devdocs/LSP0ERC725AccountInit.json +10 -9
- package/devdocs/LSP6KeyManager.json +11 -0
- package/devdocs/LSP6KeyManagerInit.json +11 -0
- package/devdocs/LSP7CappedSupply.json +10 -10
- package/devdocs/LSP7CappedSupplyInitAbstract.json +10 -10
- package/devdocs/LSP7CompatibleERC20.json +10 -10
- package/devdocs/LSP7CompatibleERC20InitAbstract.json +10 -10
- package/devdocs/LSP7CompatibleERC20Mintable.json +10 -10
- package/devdocs/LSP7CompatibleERC20MintableInit.json +10 -10
- package/devdocs/LSP7DigitalAsset.json +10 -10
- package/devdocs/LSP7DigitalAssetInitAbstract.json +10 -10
- package/devdocs/LSP7Mintable.json +10 -10
- package/devdocs/LSP7MintableInit.json +10 -10
- package/devdocs/LSP8CappedSupply.json +3 -2
- package/devdocs/LSP8CappedSupplyInitAbstract.json +3 -2
- package/devdocs/LSP8CompatibleERC721.json +3 -2
- package/devdocs/LSP8CompatibleERC721InitAbstract.json +3 -2
- package/devdocs/LSP8CompatibleERC721Mintable.json +3 -2
- package/devdocs/LSP8CompatibleERC721MintableInit.json +3 -2
- package/devdocs/LSP8IdentifiableDigitalAsset.json +3 -2
- package/devdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +3 -2
- package/devdocs/LSP8Mintable.json +3 -2
- package/devdocs/LSP8MintableInit.json +3 -2
- package/devdocs/LSP9Vault.json +6 -6
- package/devdocs/LSP9VaultInit.json +6 -6
- package/devdocs/UniversalProfile.json +11 -10
- package/devdocs/UniversalProfileInit.json +11 -10
- package/dist/constants.cjs.js +822 -459
- package/dist/constants.d.ts +633 -298
- package/dist/constants.es.js +822 -459
- package/package.json +1 -3
- package/userdocs/LSP0ERC725Account.json +3 -3
- package/userdocs/LSP0ERC725AccountInit.json +3 -3
- package/userdocs/LSP1UniversalReceiverDelegateUP.json +3 -0
- package/userdocs/LSP1UniversalReceiverDelegateVault.json +3 -0
- package/userdocs/LSP6KeyManager.json +3 -0
- package/userdocs/LSP6KeyManagerInit.json +3 -0
- package/userdocs/LSP9Vault.json +3 -3
- package/userdocs/LSP9VaultInit.json +3 -3
- package/userdocs/UniversalProfile.json +3 -3
- package/userdocs/UniversalProfileInit.json +3 -3
- package/CONTRIBUTING.md +0 -188
|
@@ -12,6 +12,7 @@ import {ILSP7DigitalAsset} from "../../LSP7DigitalAsset/ILSP7DigitalAsset.sol";
|
|
|
12
12
|
|
|
13
13
|
// modules
|
|
14
14
|
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
|
|
15
|
+
import {Version} from "../../Version.sol";
|
|
15
16
|
|
|
16
17
|
// libraries
|
|
17
18
|
import {
|
|
@@ -54,10 +55,31 @@ import {CannotRegisterEOAsAsAssets} from "../LSP1Errors.sol";
|
|
|
54
55
|
*/
|
|
55
56
|
contract LSP1UniversalReceiverDelegateUP is
|
|
56
57
|
ERC165,
|
|
58
|
+
Version,
|
|
57
59
|
ILSP1UniversalReceiverDelegate
|
|
58
60
|
{
|
|
59
61
|
using ERC165Checker for address;
|
|
60
62
|
|
|
63
|
+
/**
|
|
64
|
+
* @dev When receiving notifications about:
|
|
65
|
+
* - LSP7 Tokens sent or received
|
|
66
|
+
* - LSP8 Tokens sent or received
|
|
67
|
+
* - LSP9 Vaults sent or received
|
|
68
|
+
* The notifier should be either the LSP7 or LSP8 or LSP9 contract.
|
|
69
|
+
*
|
|
70
|
+
* We revert to avoid registering the EOA as asset (spam protection)
|
|
71
|
+
* if we received a typeId associated with tokens or vaults transfers.
|
|
72
|
+
*
|
|
73
|
+
* @param notifier The address that notified.
|
|
74
|
+
*/
|
|
75
|
+
modifier notEOA(address notifier) {
|
|
76
|
+
// solhint-disable-next-line avoid-tx-origin
|
|
77
|
+
if (notifier == tx.origin) {
|
|
78
|
+
revert CannotRegisterEOAsAsAssets(notifier);
|
|
79
|
+
}
|
|
80
|
+
_;
|
|
81
|
+
}
|
|
82
|
+
|
|
61
83
|
/**
|
|
62
84
|
* @dev
|
|
63
85
|
* 1. Writes the data keys of the received [LSP-7-DigitalAsset], [LSP-8-IdentifiableDigitalAsset] and [LSP-9-Vault] contract addresses into the account storage according to the [LSP-5-ReceivedAssets] and [LSP-10-ReceivedVaults] Standard.
|
|
@@ -84,13 +106,6 @@ contract LSP1UniversalReceiverDelegateUP is
|
|
|
84
106
|
bytes32 typeId,
|
|
85
107
|
bytes memory /* data */
|
|
86
108
|
) public virtual override returns (bytes memory) {
|
|
87
|
-
// The notifier is supposed to be either the LSP7 or LSP8 or LSP9 contract
|
|
88
|
-
// If it's EOA we revert to avoid registering the EOA as asset or vault (spam protection)
|
|
89
|
-
// solhint-disable-next-line avoid-tx-origin
|
|
90
|
-
if (notifier == tx.origin) {
|
|
91
|
-
revert CannotRegisterEOAsAsAssets(notifier);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
109
|
if (typeId == _TYPEID_LSP7_TOKENSSENDER) {
|
|
95
110
|
return _tokenSender(notifier);
|
|
96
111
|
}
|
|
@@ -128,7 +143,9 @@ contract LSP1UniversalReceiverDelegateUP is
|
|
|
128
143
|
*
|
|
129
144
|
* @param notifier The LSP7 or LSP8 token address.
|
|
130
145
|
*/
|
|
131
|
-
function _tokenSender(
|
|
146
|
+
function _tokenSender(
|
|
147
|
+
address notifier
|
|
148
|
+
) internal notEOA(notifier) returns (bytes memory) {
|
|
132
149
|
// if the amount sent is not the full balance, then do not update the keys
|
|
133
150
|
try ILSP7DigitalAsset(notifier).balanceOf(msg.sender) returns (
|
|
134
151
|
uint256 balance
|
|
@@ -166,7 +183,7 @@ contract LSP1UniversalReceiverDelegateUP is
|
|
|
166
183
|
function _tokenRecipient(
|
|
167
184
|
address notifier,
|
|
168
185
|
bytes4 interfaceId
|
|
169
|
-
) internal returns (bytes memory) {
|
|
186
|
+
) internal notEOA(notifier) returns (bytes memory) {
|
|
170
187
|
// CHECK balance only when the Token contract is already deployed,
|
|
171
188
|
// not when tokens are being transferred on deployment through the `constructor`
|
|
172
189
|
if (notifier.code.length != 0) {
|
|
@@ -204,7 +221,9 @@ contract LSP1UniversalReceiverDelegateUP is
|
|
|
204
221
|
*
|
|
205
222
|
* @param notifier The LSP9 vault address.
|
|
206
223
|
*/
|
|
207
|
-
function _vaultSender(
|
|
224
|
+
function _vaultSender(
|
|
225
|
+
address notifier
|
|
226
|
+
) internal notEOA(notifier) returns (bytes memory) {
|
|
208
227
|
(bytes32[] memory dataKeys, bytes[] memory dataValues) = LSP10Utils
|
|
209
228
|
.generateSentVaultKeys(msg.sender, notifier);
|
|
210
229
|
|
|
@@ -227,7 +246,9 @@ contract LSP1UniversalReceiverDelegateUP is
|
|
|
227
246
|
*
|
|
228
247
|
* @param notifier The LSP9 vault address.
|
|
229
248
|
*/
|
|
230
|
-
function _vaultRecipient(
|
|
249
|
+
function _vaultRecipient(
|
|
250
|
+
address notifier
|
|
251
|
+
) internal notEOA(notifier) returns (bytes memory) {
|
|
231
252
|
(bytes32[] memory dataKeys, bytes[] memory dataValues) = LSP10Utils
|
|
232
253
|
.generateReceivedVaultKeys(msg.sender, notifier);
|
|
233
254
|
|
|
@@ -12,6 +12,7 @@ import {ILSP7DigitalAsset} from "../../LSP7DigitalAsset/ILSP7DigitalAsset.sol";
|
|
|
12
12
|
|
|
13
13
|
// modules
|
|
14
14
|
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
|
|
15
|
+
import {Version} from "../../Version.sol";
|
|
15
16
|
|
|
16
17
|
// libraries
|
|
17
18
|
import {LSP5Utils} from "../../LSP5ReceivedAssets/LSP5Utils.sol";
|
|
@@ -44,8 +45,28 @@ import {CannotRegisterEOAsAsAssets} from "../LSP1Errors.sol";
|
|
|
44
45
|
*/
|
|
45
46
|
contract LSP1UniversalReceiverDelegateVault is
|
|
46
47
|
ERC165,
|
|
48
|
+
Version,
|
|
47
49
|
ILSP1UniversalReceiverDelegate
|
|
48
50
|
{
|
|
51
|
+
/**
|
|
52
|
+
* @dev When receiving notifications about:
|
|
53
|
+
* - LSP7 Tokens sent or received
|
|
54
|
+
* - LSP8 Tokens sent or received
|
|
55
|
+
* The notifier should be either the LSP7 or LSP8 contract.
|
|
56
|
+
*
|
|
57
|
+
* We revert to avoid registering the EOA as asset (spam protection)
|
|
58
|
+
* if we received a typeId associated with tokens transfers.
|
|
59
|
+
*
|
|
60
|
+
* @param notifier The address that notified.
|
|
61
|
+
*/
|
|
62
|
+
modifier notEOA(address notifier) {
|
|
63
|
+
// solhint-disable-next-line avoid-tx-origin
|
|
64
|
+
if (notifier == tx.origin) {
|
|
65
|
+
revert CannotRegisterEOAsAsAssets(notifier);
|
|
66
|
+
}
|
|
67
|
+
_;
|
|
68
|
+
}
|
|
69
|
+
|
|
49
70
|
/**
|
|
50
71
|
* @inheritdoc ILSP1UniversalReceiverDelegate
|
|
51
72
|
* @dev Handles two cases:
|
|
@@ -68,13 +89,6 @@ contract LSP1UniversalReceiverDelegateVault is
|
|
|
68
89
|
bytes32 typeId,
|
|
69
90
|
bytes memory /* data */
|
|
70
91
|
) public virtual override returns (bytes memory) {
|
|
71
|
-
// The notifier is supposed to be either the LSP7 or LSP8 contract
|
|
72
|
-
// If it's EOA we revert to avoid registering the EOA as asset (spam protection)
|
|
73
|
-
// solhint-disable-next-line avoid-tx-origin
|
|
74
|
-
if (notifier == tx.origin) {
|
|
75
|
-
revert CannotRegisterEOAsAsAssets(notifier);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
92
|
if (typeId == _TYPEID_LSP7_TOKENSSENDER) {
|
|
79
93
|
return _tokenSender(notifier);
|
|
80
94
|
}
|
|
@@ -104,7 +118,9 @@ contract LSP1UniversalReceiverDelegateVault is
|
|
|
104
118
|
*
|
|
105
119
|
* @param notifier The LSP7 or LSP8 token address.
|
|
106
120
|
*/
|
|
107
|
-
function _tokenSender(
|
|
121
|
+
function _tokenSender(
|
|
122
|
+
address notifier
|
|
123
|
+
) internal notEOA(notifier) returns (bytes memory) {
|
|
108
124
|
// if the amount sent is not the full balance, then do not update the keys
|
|
109
125
|
try ILSP7DigitalAsset(notifier).balanceOf(msg.sender) returns (
|
|
110
126
|
uint256 balance
|
|
@@ -142,7 +158,7 @@ contract LSP1UniversalReceiverDelegateVault is
|
|
|
142
158
|
function _tokenRecipient(
|
|
143
159
|
address notifier,
|
|
144
160
|
bytes4 interfaceId
|
|
145
|
-
) internal returns (bytes memory) {
|
|
161
|
+
) internal notEOA(notifier) returns (bytes memory) {
|
|
146
162
|
// CHECK balance only when the Token contract is already deployed,
|
|
147
163
|
// not when tokens are being transferred on deployment through the `constructor`
|
|
148
164
|
if (notifier.code.length != 0) {
|
|
@@ -25,6 +25,8 @@ import {
|
|
|
25
25
|
* Based on LSP1 Universal Receiver standard.
|
|
26
26
|
*/
|
|
27
27
|
library LSP1Utils {
|
|
28
|
+
using ERC165Checker for address;
|
|
29
|
+
|
|
28
30
|
/**
|
|
29
31
|
* @dev Notify a contract at `lsp1Implementation` address by calling its `universalReceiver` function if this contract
|
|
30
32
|
* supports the LSP1 interface.
|
|
@@ -33,14 +35,13 @@ library LSP1Utils {
|
|
|
33
35
|
* @param typeId A `bytes32` typeId.
|
|
34
36
|
* @param data Any optional data to send to the `universalReceiver` function to the `lsp1Implementation` address.
|
|
35
37
|
*/
|
|
36
|
-
function
|
|
38
|
+
function notifyUniversalReceiver(
|
|
37
39
|
address lsp1Implementation,
|
|
38
40
|
bytes32 typeId,
|
|
39
41
|
bytes memory data
|
|
40
42
|
) internal {
|
|
41
43
|
if (
|
|
42
|
-
|
|
43
|
-
lsp1Implementation,
|
|
44
|
+
lsp1Implementation.supportsERC165InterfaceUnchecked(
|
|
44
45
|
_INTERFACEID_LSP1
|
|
45
46
|
)
|
|
46
47
|
) {
|
|
@@ -20,48 +20,61 @@ import {
|
|
|
20
20
|
abstract contract LSP20CallVerification {
|
|
21
21
|
/**
|
|
22
22
|
* @dev Calls {lsp20VerifyCall} function on the logicVerifier.
|
|
23
|
-
*
|
|
24
|
-
*
|
|
23
|
+
*
|
|
24
|
+
* @custom:info
|
|
25
|
+
* - Reverts in case the value returned does not match the returned status (lsp20VerifyCall selector).
|
|
26
|
+
* - Returns whether a verification after the execution should happen based on the last byte of the `returnedStatus`.
|
|
27
|
+
* - Reverts with no reason if the data returned by `ILSP20(logicVerifier).lsp20VerifyCall(...)` cannot be decoded (_e.g:_ any other data type besides `bytes4`).
|
|
28
|
+
* See this link for more info: https://forum.soliditylang.org/t/call-for-feedback-the-future-of-try-catch-in-solidity/1497.
|
|
25
29
|
*/
|
|
26
30
|
function _verifyCall(
|
|
27
31
|
address logicVerifier
|
|
28
32
|
) internal virtual returns (bool verifyAfter) {
|
|
29
|
-
if (logicVerifier.code.length == 0)
|
|
33
|
+
if (logicVerifier.code.length == 0) {
|
|
30
34
|
revert LSP20EOACannotVerifyCall(logicVerifier);
|
|
35
|
+
}
|
|
31
36
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
// Reverts with no reason if the returned data type is not a `bytes4` value
|
|
38
|
+
try
|
|
39
|
+
ILSP20(logicVerifier).lsp20VerifyCall(
|
|
35
40
|
msg.sender,
|
|
36
41
|
address(this),
|
|
37
42
|
msg.sender,
|
|
38
43
|
msg.value,
|
|
39
44
|
msg.data
|
|
40
45
|
)
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
returns (bytes4 returnedStatus) {
|
|
47
|
+
if (
|
|
48
|
+
bytes3(returnedStatus) !=
|
|
49
|
+
bytes3(ILSP20.lsp20VerifyCall.selector)
|
|
50
|
+
) {
|
|
51
|
+
revert LSP20CallVerificationFailed({
|
|
52
|
+
postCall: false,
|
|
53
|
+
returnedStatus: returnedStatus
|
|
54
|
+
});
|
|
55
|
+
}
|
|
46
56
|
|
|
47
|
-
|
|
48
|
-
|
|
57
|
+
return returnedStatus[3] == 0x01;
|
|
58
|
+
} catch (bytes memory errorData) {
|
|
59
|
+
_revertWithLSP20DefaultError(false, errorData);
|
|
49
60
|
}
|
|
50
|
-
|
|
51
|
-
return returnedStatus[3] == 0x01;
|
|
52
61
|
}
|
|
53
62
|
|
|
54
63
|
/**
|
|
55
64
|
* @dev Calls {lsp20VerifyCallResult} function on the logicVerifier.
|
|
56
|
-
*
|
|
65
|
+
*
|
|
66
|
+
* @custom:info
|
|
67
|
+
* - Reverts in case the value returned does not match the returned status (lsp20VerifyCallResult selector).
|
|
68
|
+
* - Reverts with no reason if the data returned by `ILSP20(logicVerifier).lsp20VerifyCallResult(...)` cannot be decoded (_e.g:_ any other data type besides `bytes4`).
|
|
69
|
+
* See this link for more info: https://forum.soliditylang.org/t/call-for-feedback-the-future-of-try-catch-in-solidity/1497.
|
|
57
70
|
*/
|
|
58
71
|
function _verifyCallResult(
|
|
59
72
|
address logicVerifier,
|
|
60
73
|
bytes memory callResult
|
|
61
74
|
) internal virtual {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
75
|
+
// Reverts with no reason if the returned data type is not a `bytes4` value
|
|
76
|
+
try
|
|
77
|
+
ILSP20(logicVerifier).lsp20VerifyCallResult(
|
|
65
78
|
keccak256(
|
|
66
79
|
abi.encodePacked(
|
|
67
80
|
msg.sender,
|
|
@@ -73,37 +86,18 @@ abstract contract LSP20CallVerification {
|
|
|
73
86
|
),
|
|
74
87
|
callResult
|
|
75
88
|
)
|
|
76
|
-
)
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
)
|
|
84
|
-
revert LSP20CallVerificationFailed({
|
|
85
|
-
postCall: true,
|
|
86
|
-
returnedData: returnedData
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function _validateCall(
|
|
91
|
-
bool postCall,
|
|
92
|
-
bool success,
|
|
93
|
-
bytes memory returnedData
|
|
94
|
-
) internal pure virtual {
|
|
95
|
-
if (!success) _revertWithLSP20DefaultError(postCall, returnedData);
|
|
89
|
+
returns (bytes4 returnedStatus) {
|
|
90
|
+
if (returnedStatus != ILSP20.lsp20VerifyCallResult.selector) {
|
|
91
|
+
revert LSP20CallVerificationFailed({
|
|
92
|
+
postCall: true,
|
|
93
|
+
returnedStatus: returnedStatus
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
96
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
bytes28(bytes32(returnedData) << 32) != bytes28(0)
|
|
102
|
-
)
|
|
103
|
-
revert LSP20CallVerificationFailed({
|
|
104
|
-
postCall: postCall,
|
|
105
|
-
returnedData: returnedData
|
|
106
|
-
});
|
|
97
|
+
return;
|
|
98
|
+
} catch (bytes memory errorData) {
|
|
99
|
+
_revertWithLSP20DefaultError(true, errorData);
|
|
100
|
+
}
|
|
107
101
|
}
|
|
108
102
|
|
|
109
103
|
function _revertWithLSP20DefaultError(
|
|
@@ -10,9 +10,9 @@ error LSP20CallingVerifierFailed(bool postCall);
|
|
|
10
10
|
/**
|
|
11
11
|
* @dev reverts when the call to the owner does not return the LSP20 success value
|
|
12
12
|
* @param postCall True if the execution call was done, False otherwise
|
|
13
|
-
* @param
|
|
13
|
+
* @param returnedStatus The bytes4 decoded data returned by the logic verifier.
|
|
14
14
|
*/
|
|
15
|
-
error LSP20CallVerificationFailed(bool postCall,
|
|
15
|
+
error LSP20CallVerificationFailed(bool postCall, bytes4 returnedStatus);
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* @dev Reverts when the logic verifier is an Externally Owned Account (EOA) that cannot return the LSP20 success value.
|
|
@@ -139,10 +139,6 @@ abstract contract LSP25MultiChannelNonce {
|
|
|
139
139
|
address from,
|
|
140
140
|
uint256 idx
|
|
141
141
|
) internal view virtual returns (bool) {
|
|
142
|
-
|
|
143
|
-
// Alternatively:
|
|
144
|
-
// uint256 mask = (1<<128)-1;
|
|
145
|
-
// uint256 mask = 0xffffffffffffffffffffffffffffffff;
|
|
146
|
-
return (idx & mask) == _nonceStore[from][idx >> 128];
|
|
142
|
+
return uint128(idx) == _nonceStore[from][idx >> 128];
|
|
147
143
|
}
|
|
148
144
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
pragma solidity ^0.8.5;
|
|
3
3
|
|
|
4
4
|
// modules
|
|
5
|
+
import {Version} from "../Version.sol";
|
|
5
6
|
import {LSP6KeyManagerCore} from "./LSP6KeyManagerCore.sol";
|
|
6
7
|
import {InvalidLSP6Target} from "./LSP6Errors.sol";
|
|
7
8
|
|
|
@@ -10,7 +11,7 @@ import {InvalidLSP6Target} from "./LSP6Errors.sol";
|
|
|
10
11
|
* @author Fabian Vogelsteller <frozeman>, Jean Cavallera (CJ42), Yamen Merhi (YamenMerhi)
|
|
11
12
|
* @dev All the permissions can be set on the ERC725 Account using `setData(bytes32,bytes)` or `setData(bytes32[],bytes[])`.
|
|
12
13
|
*/
|
|
13
|
-
contract LSP6KeyManager is LSP6KeyManagerCore {
|
|
14
|
+
contract LSP6KeyManager is LSP6KeyManagerCore, Version {
|
|
14
15
|
/**
|
|
15
16
|
* @notice Deploying a LSP6KeyManager linked to the contract at address `target_`.
|
|
16
17
|
* @dev Deploy a Key Manager and set the `target_` address in the contract storage,
|
|
@@ -38,6 +38,10 @@ import {Address} from "@openzeppelin/contracts/utils/Address.sol";
|
|
|
38
38
|
import {LSP6Utils} from "./LSP6Utils.sol";
|
|
39
39
|
|
|
40
40
|
// errors
|
|
41
|
+
import {
|
|
42
|
+
ERC725X_ExecuteParametersLengthMismatch,
|
|
43
|
+
ERC725X_ExecuteParametersEmptyArray
|
|
44
|
+
} from "@erc725/smart-contracts/contracts/errors.sol";
|
|
41
45
|
import {
|
|
42
46
|
BatchExecuteParamsLengthMismatch,
|
|
43
47
|
BatchExecuteRelayCallParamsLengthMismatch,
|
|
@@ -146,6 +150,11 @@ abstract contract LSP6KeyManagerCore is
|
|
|
146
150
|
* If the signer is a controller with the permission `SIGN`, it will return the ERC1271 success value.
|
|
147
151
|
*
|
|
148
152
|
* @return returnedStatus `0x1626ba7e` on success, or `0xffffffff` on failure.
|
|
153
|
+
*
|
|
154
|
+
* @custom:warning This function does not enforce by default the inclusion of the address of this contract in the signature digest.
|
|
155
|
+
* It is recommended that protocols or applications using this contract include the targeted address (= this contract) in the data to sign.
|
|
156
|
+
* To ensure that a signature is valid for a specific LSP6KeyManager and prevent signatures from the same EOA to be replayed
|
|
157
|
+
* across different LSP6KeyManager.
|
|
149
158
|
*/
|
|
150
159
|
function isValidSignature(
|
|
151
160
|
bytes32 dataHash,
|
|
@@ -504,13 +513,14 @@ abstract contract LSP6KeyManagerCore is
|
|
|
504
513
|
value: msgValue,
|
|
505
514
|
gas: gasleft()
|
|
506
515
|
}(payload);
|
|
516
|
+
|
|
507
517
|
bytes memory result = Address.verifyCallResult(
|
|
508
518
|
success,
|
|
509
519
|
returnData,
|
|
510
520
|
"LSP6: failed executing payload"
|
|
511
521
|
);
|
|
512
522
|
|
|
513
|
-
return result
|
|
523
|
+
return result;
|
|
514
524
|
}
|
|
515
525
|
|
|
516
526
|
/**
|
|
@@ -571,7 +581,7 @@ abstract contract LSP6KeyManagerCore is
|
|
|
571
581
|
uint256 operationType,
|
|
572
582
|
address to,
|
|
573
583
|
uint256 value,
|
|
574
|
-
bytes memory
|
|
584
|
+
bytes memory callData
|
|
575
585
|
) = abi.decode(payload[4:], (uint256, address, uint256, bytes));
|
|
576
586
|
|
|
577
587
|
LSP6ExecuteModule._verifyCanExecute(
|
|
@@ -581,8 +591,42 @@ abstract contract LSP6KeyManagerCore is
|
|
|
581
591
|
operationType,
|
|
582
592
|
to,
|
|
583
593
|
value,
|
|
584
|
-
|
|
594
|
+
callData
|
|
585
595
|
);
|
|
596
|
+
} else if (erc725Function == IERC725X.executeBatch.selector) {
|
|
597
|
+
(
|
|
598
|
+
uint256[] memory operationTypes,
|
|
599
|
+
address[] memory targets,
|
|
600
|
+
uint256[] memory values,
|
|
601
|
+
bytes[] memory callDatas
|
|
602
|
+
) = abi.decode(
|
|
603
|
+
payload[4:],
|
|
604
|
+
(uint256[], address[], uint256[], bytes[])
|
|
605
|
+
);
|
|
606
|
+
|
|
607
|
+
if (
|
|
608
|
+
operationTypes.length != targets.length ||
|
|
609
|
+
targets.length != values.length ||
|
|
610
|
+
values.length != callDatas.length
|
|
611
|
+
) {
|
|
612
|
+
revert ERC725X_ExecuteParametersLengthMismatch();
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
if (operationTypes.length == 0) {
|
|
616
|
+
revert ERC725X_ExecuteParametersEmptyArray();
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
for (uint256 ii; ii < operationTypes.length; ii++) {
|
|
620
|
+
LSP6ExecuteModule._verifyCanExecute(
|
|
621
|
+
targetContract,
|
|
622
|
+
from,
|
|
623
|
+
permissions,
|
|
624
|
+
operationTypes[ii],
|
|
625
|
+
targets[ii],
|
|
626
|
+
values[ii],
|
|
627
|
+
callDatas[ii]
|
|
628
|
+
);
|
|
629
|
+
}
|
|
586
630
|
} else if (
|
|
587
631
|
erc725Function == ILSP14Ownable2Step.transferOwnership.selector ||
|
|
588
632
|
erc725Function == ILSP14Ownable2Step.acceptOwnership.selector ||
|
|
@@ -595,9 +639,11 @@ abstract contract LSP6KeyManagerCore is
|
|
|
595
639
|
}
|
|
596
640
|
|
|
597
641
|
/**
|
|
598
|
-
* @dev
|
|
599
|
-
* the status is `
|
|
600
|
-
*
|
|
642
|
+
* @dev Check if we are in the context of a reentrant call, by checking if the reentrancy status is `true`.
|
|
643
|
+
* - If the status is `true`, the caller (or signer for relay call) MUST have the `REENTRANCY` permission. Otherwise, the call is reverted.
|
|
644
|
+
* - If the status is `false`, it is set to `true` only if we are not dealing with a call to the functions `setData` or `setDataBatch`.
|
|
645
|
+
* Used at the beginning of the {`lsp20VerifyCall`}, {`_execute`} and {`_executeRelayCall`} functions, before the methods execution starts.
|
|
646
|
+
*
|
|
601
647
|
*/
|
|
602
648
|
function _nonReentrantBefore(
|
|
603
649
|
address targetContract,
|
|
@@ -621,8 +667,8 @@ abstract contract LSP6KeyManagerCore is
|
|
|
621
667
|
}
|
|
622
668
|
|
|
623
669
|
/**
|
|
624
|
-
* @dev Resets the status to `false`
|
|
625
|
-
* Used
|
|
670
|
+
* @dev Resets the reentrancy status to `false`
|
|
671
|
+
* Used at the end of the {`lsp20VerifyCall`}, {`_execute`} and {`_executeRelayCall`} functions after the functions' execution is terminated.
|
|
626
672
|
*/
|
|
627
673
|
function _nonReentrantAfter(address targetContract) internal virtual {
|
|
628
674
|
// By storing the original value once again, a refund is triggered (see
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
pragma solidity ^0.8.5;
|
|
3
3
|
|
|
4
4
|
// modules
|
|
5
|
+
import {Version} from "../Version.sol";
|
|
5
6
|
import {LSP6KeyManagerInitAbstract} from "./LSP6KeyManagerInitAbstract.sol";
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -9,7 +10,7 @@ import {LSP6KeyManagerInitAbstract} from "./LSP6KeyManagerInitAbstract.sol";
|
|
|
9
10
|
* @author Fabian Vogelsteller <frozeman>, Jean Cavallera (CJ42), Yamen Merhi (YamenMerhi)
|
|
10
11
|
* @dev All the permissions can be set on the ERC725 Account using `setData(...)` with the keys constants below
|
|
11
12
|
*/
|
|
12
|
-
contract LSP6KeyManagerInit is LSP6KeyManagerInitAbstract {
|
|
13
|
+
contract LSP6KeyManagerInit is LSP6KeyManagerInitAbstract, Version {
|
|
13
14
|
/**
|
|
14
15
|
* @notice Deploying a LSP6KeyManagerInit to be used as base contract behind proxy.
|
|
15
16
|
* @dev Initialize (= lock) base implementation contract on deployment.
|
|
@@ -250,16 +250,7 @@ abstract contract LSP6ExecuteModule {
|
|
|
250
250
|
revert NoCallsAllowed(controllerAddress);
|
|
251
251
|
}
|
|
252
252
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
// CHECK if there is at least a 4 bytes function selector
|
|
256
|
-
bytes4 selector = data.length >= 4 ? bytes4(data) : bytes4(0);
|
|
257
|
-
|
|
258
|
-
bytes4 requiredCallTypes = _extractCallType(
|
|
259
|
-
operationType,
|
|
260
|
-
value,
|
|
261
|
-
isEmptyCall
|
|
262
|
-
);
|
|
253
|
+
bytes4 requiredCallTypes = _extractCallType(operationType, value, data);
|
|
263
254
|
|
|
264
255
|
for (uint256 ii; ii < allowedCalls.length; ii += 34) {
|
|
265
256
|
/// @dev structure of an AllowedCall
|
|
@@ -294,11 +285,11 @@ abstract contract LSP6ExecuteModule {
|
|
|
294
285
|
_isAllowedCallType(allowedCall, requiredCallTypes) &&
|
|
295
286
|
_isAllowedAddress(allowedCall, to) &&
|
|
296
287
|
_isAllowedStandard(allowedCall, to) &&
|
|
297
|
-
_isAllowedFunction(allowedCall,
|
|
288
|
+
_isAllowedFunction(allowedCall, data)
|
|
298
289
|
) return;
|
|
299
290
|
}
|
|
300
291
|
|
|
301
|
-
revert NotAllowedCall(controllerAddress, to,
|
|
292
|
+
revert NotAllowedCall(controllerAddress, to, bytes4(data));
|
|
302
293
|
}
|
|
303
294
|
|
|
304
295
|
/**
|
|
@@ -309,7 +300,7 @@ abstract contract LSP6ExecuteModule {
|
|
|
309
300
|
function _extractCallType(
|
|
310
301
|
uint256 operationType,
|
|
311
302
|
uint256 value,
|
|
312
|
-
|
|
303
|
+
bytes memory data
|
|
313
304
|
) internal pure returns (bytes4 requiredCallTypes) {
|
|
314
305
|
// if there is value being transferred, add the extra bit
|
|
315
306
|
// for the first bit for Value Transfer in the `requiredCallTypes`
|
|
@@ -317,7 +308,12 @@ abstract contract LSP6ExecuteModule {
|
|
|
317
308
|
requiredCallTypes |= _ALLOWEDCALLS_TRANSFERVALUE;
|
|
318
309
|
}
|
|
319
310
|
|
|
320
|
-
|
|
311
|
+
bool isCallDataPresent = data.length != 0;
|
|
312
|
+
bool isEmptyCallWithoutValue = !isCallDataPresent && value == 0;
|
|
313
|
+
|
|
314
|
+
// if we are doing a message call with some data
|
|
315
|
+
// or if we are doing an empty call without value
|
|
316
|
+
if (isCallDataPresent || isEmptyCallWithoutValue) {
|
|
321
317
|
if (operationType == OPERATION_0_CALL) {
|
|
322
318
|
requiredCallTypes |= _ALLOWEDCALLS_CALL;
|
|
323
319
|
} else if (operationType == OPERATION_3_STATICCALL) {
|
|
@@ -363,7 +359,7 @@ abstract contract LSP6ExecuteModule {
|
|
|
363
359
|
|
|
364
360
|
function _isAllowedFunction(
|
|
365
361
|
bytes memory allowedCall,
|
|
366
|
-
|
|
362
|
+
bytes memory data
|
|
367
363
|
) internal pure virtual returns (bool) {
|
|
368
364
|
// <offset> = 28 bytes x 8 bits = 224 bits
|
|
369
365
|
//
|
|
@@ -372,7 +368,9 @@ abstract contract LSP6ExecuteModule {
|
|
|
372
368
|
// 0000000ncafecafecafecafecafecafecafecafecafecafe5a5a5a5af1f1f1f1
|
|
373
369
|
bytes4 allowedFunction = bytes4(bytes32(allowedCall) << 224);
|
|
374
370
|
|
|
375
|
-
bool isFunctionCall =
|
|
371
|
+
bool isFunctionCall = data.length >= 4;
|
|
372
|
+
|
|
373
|
+
bytes4 requiredFunction = bytes4(data);
|
|
376
374
|
|
|
377
375
|
// ANY function = 0xffffffff
|
|
378
376
|
return
|
|
@@ -8,9 +8,6 @@ import {
|
|
|
8
8
|
|
|
9
9
|
// modules
|
|
10
10
|
import {ERC725Y} from "@erc725/smart-contracts/contracts/ERC725Y.sol";
|
|
11
|
-
import {
|
|
12
|
-
ERC725Y_DataKeysValuesLengthMismatch
|
|
13
|
-
} from "@erc725/smart-contracts/contracts/errors.sol";
|
|
14
11
|
|
|
15
12
|
// libraries
|
|
16
13
|
import {LSP6Utils} from "../LSP6Utils.sol";
|
|
@@ -41,6 +38,9 @@ import {
|
|
|
41
38
|
} from "../../LSP17ContractExtension/LSP17Constants.sol";
|
|
42
39
|
|
|
43
40
|
// errors
|
|
41
|
+
import {
|
|
42
|
+
ERC725Y_DataKeysValuesLengthMismatch
|
|
43
|
+
} from "@erc725/smart-contracts/contracts/errors.sol";
|
|
44
44
|
import {
|
|
45
45
|
NotRecognisedPermissionKey,
|
|
46
46
|
InvalidEncodedAllowedCalls,
|
|
@@ -321,8 +321,12 @@ abstract contract LSP6SetDataModule {
|
|
|
321
321
|
|
|
322
322
|
// LSP17Extension:<bytes4>
|
|
323
323
|
} else if (bytes12(inputDataKey) == _LSP17_EXTENSION_PREFIX) {
|
|
324
|
-
// CHECK that `dataValue` contains exactly 20 bytes, which corresponds to an address for a LSP17 Extension
|
|
325
|
-
if (
|
|
324
|
+
// CHECK that `dataValue` contains exactly 20 or 21 bytes (if setting to forward value), which corresponds to an address for a LSP17 Extension
|
|
325
|
+
if (
|
|
326
|
+
inputDataValue.length != 20 &&
|
|
327
|
+
inputDataValue.length != 21 &&
|
|
328
|
+
inputDataValue.length != 0
|
|
329
|
+
) {
|
|
326
330
|
revert InvalidDataValuesForDataKeys(
|
|
327
331
|
inputDataKey,
|
|
328
332
|
inputDataValue
|