@lukso/lsp-smart-contracts 0.12.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 +15 -15
- package/artifacts/LSP0ERC725AccountInit.json +15 -15
- package/artifacts/LSP1UniversalReceiverDelegateUP.json +15 -15
- package/artifacts/LSP1UniversalReceiverDelegateVault.json +15 -15
- package/artifacts/LSP6KeyManager.json +15 -15
- package/artifacts/LSP6KeyManagerInit.json +15 -15
- package/artifacts/LSP7CappedSupply.json +0 -13
- package/artifacts/LSP7CappedSupplyInitAbstract.json +0 -13
- package/artifacts/LSP7CompatibleERC20.json +0 -13
- package/artifacts/LSP7CompatibleERC20InitAbstract.json +0 -13
- package/artifacts/LSP7CompatibleERC20Mintable.json +2 -15
- package/artifacts/LSP7CompatibleERC20MintableInit.json +2 -15
- package/artifacts/LSP7DigitalAsset.json +0 -13
- package/artifacts/LSP7DigitalAssetInitAbstract.json +0 -13
- package/artifacts/LSP7Mintable.json +2 -15
- package/artifacts/LSP7MintableInit.json +2 -15
- package/artifacts/LSP8CappedSupply.json +0 -13
- package/artifacts/LSP8CappedSupplyInitAbstract.json +0 -13
- package/artifacts/LSP8CompatibleERC721.json +0 -13
- package/artifacts/LSP8CompatibleERC721InitAbstract.json +0 -13
- package/artifacts/LSP8CompatibleERC721Mintable.json +2 -15
- package/artifacts/LSP8CompatibleERC721MintableInit.json +2 -15
- package/artifacts/LSP8IdentifiableDigitalAsset.json +0 -13
- package/artifacts/LSP8IdentifiableDigitalAssetInitAbstract.json +0 -13
- package/artifacts/LSP8Mintable.json +2 -15
- package/artifacts/LSP8MintableInit.json +2 -15
- package/artifacts/LSP9Vault.json +15 -15
- package/artifacts/LSP9VaultInit.json +15 -15
- package/artifacts/UniversalProfile.json +15 -15
- package/artifacts/UniversalProfileInit.json +15 -15
- package/contracts/LSP0ERC725Account/LSP0Constants.sol +1 -1
- package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +7 -3
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +62 -41
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +2 -1
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +3 -1
- package/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol +11 -10
- package/contracts/LSP17Extensions/OnERC721ReceivedExtension.sol +2 -1
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +31 -33
- package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +24 -17
- package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +1 -1
- package/contracts/LSP25ExecuteRelayCall/LSP25MultiChannelNonce.sol +1 -5
- package/contracts/LSP6KeyManager/LSP6KeyManager.sol +2 -1
- package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +15 -9
- package/contracts/LSP6KeyManager/LSP6KeyManagerInit.sol +2 -1
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6ExecuteModule.sol +14 -16
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6SetDataModule.sol +6 -2
- package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +7 -17
- package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +5 -15
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +1 -4
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +1 -4
- package/contracts/LSP9Vault/LSP9Constants.sol +1 -1
- package/contracts/LSP9Vault/LSP9Vault.sol +3 -2
- package/contracts/LSP9Vault/LSP9VaultCore.sol +22 -15
- package/contracts/LSP9Vault/LSP9VaultInit.sol +2 -1
- package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +1 -1
- package/contracts/UniversalProfile.sol +4 -2
- package/contracts/UniversalProfileInit.sol +8 -5
- package/contracts/UniversalProfileInitAbstract.sol +4 -2
- package/contracts/Version.sol +6 -5
- package/devdocs/LSP0ERC725Account.json +3 -8
- package/devdocs/LSP0ERC725AccountInit.json +2 -7
- package/devdocs/LSP1UniversalReceiverDelegateUP.json +0 -6
- package/devdocs/LSP1UniversalReceiverDelegateVault.json +0 -6
- package/devdocs/LSP6KeyManager.json +1 -6
- package/devdocs/LSP6KeyManagerInit.json +1 -6
- package/devdocs/LSP7CappedSupply.json +0 -6
- package/devdocs/LSP7CappedSupplyInitAbstract.json +0 -6
- package/devdocs/LSP7CompatibleERC20.json +0 -6
- package/devdocs/LSP7CompatibleERC20InitAbstract.json +0 -6
- package/devdocs/LSP7CompatibleERC20Mintable.json +0 -6
- package/devdocs/LSP7CompatibleERC20MintableInit.json +0 -6
- package/devdocs/LSP7DigitalAsset.json +0 -6
- package/devdocs/LSP7DigitalAssetInitAbstract.json +0 -6
- package/devdocs/LSP7Mintable.json +0 -6
- package/devdocs/LSP7MintableInit.json +0 -6
- package/devdocs/LSP8CappedSupply.json +0 -6
- package/devdocs/LSP8CappedSupplyInitAbstract.json +0 -6
- package/devdocs/LSP8CompatibleERC721.json +0 -6
- package/devdocs/LSP8CompatibleERC721InitAbstract.json +0 -6
- package/devdocs/LSP8CompatibleERC721Mintable.json +0 -6
- package/devdocs/LSP8CompatibleERC721MintableInit.json +0 -6
- package/devdocs/LSP8IdentifiableDigitalAsset.json +0 -6
- package/devdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +0 -6
- package/devdocs/LSP8Mintable.json +0 -6
- package/devdocs/LSP8MintableInit.json +0 -6
- package/devdocs/LSP9Vault.json +0 -6
- package/devdocs/LSP9VaultInit.json +0 -6
- package/devdocs/UniversalProfile.json +3 -8
- package/devdocs/UniversalProfileInit.json +4 -9
- package/dist/constants.cjs.js +142 -536
- package/dist/constants.d.ts +166 -734
- package/dist/constants.es.js +142 -536
- package/package.json +1 -1
- package/userdocs/LSP0ERC725Account.json +3 -3
- package/userdocs/LSP0ERC725AccountInit.json +3 -3
- package/userdocs/LSP1UniversalReceiverDelegateUP.json +3 -3
- package/userdocs/LSP1UniversalReceiverDelegateVault.json +3 -3
- package/userdocs/LSP6KeyManager.json +3 -3
- package/userdocs/LSP6KeyManagerInit.json +3 -3
- package/userdocs/LSP7CappedSupply.json +0 -3
- package/userdocs/LSP7CappedSupplyInitAbstract.json +0 -3
- package/userdocs/LSP7CompatibleERC20.json +0 -3
- package/userdocs/LSP7CompatibleERC20InitAbstract.json +0 -3
- package/userdocs/LSP7CompatibleERC20Mintable.json +0 -3
- package/userdocs/LSP7CompatibleERC20MintableInit.json +0 -3
- package/userdocs/LSP7DigitalAsset.json +0 -3
- package/userdocs/LSP7DigitalAssetInitAbstract.json +0 -3
- package/userdocs/LSP7Mintable.json +0 -3
- package/userdocs/LSP7MintableInit.json +0 -3
- package/userdocs/LSP8CappedSupply.json +0 -3
- package/userdocs/LSP8CappedSupplyInitAbstract.json +0 -3
- package/userdocs/LSP8CompatibleERC721.json +0 -3
- package/userdocs/LSP8CompatibleERC721InitAbstract.json +0 -3
- package/userdocs/LSP8CompatibleERC721Mintable.json +0 -3
- package/userdocs/LSP8CompatibleERC721MintableInit.json +0 -3
- package/userdocs/LSP8IdentifiableDigitalAsset.json +0 -3
- package/userdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +0 -3
- package/userdocs/LSP8Mintable.json +0 -3
- package/userdocs/LSP8MintableInit.json +0 -3
- package/userdocs/LSP9Vault.json +3 -3
- package/userdocs/LSP9VaultInit.json +3 -3
- package/userdocs/UniversalProfile.json +3 -3
- package/userdocs/UniversalProfileInit.json +3 -3
|
@@ -65,7 +65,7 @@ abstract contract LSP14Ownable2Step is ILSP14Ownable2Step, OwnableUnset {
|
|
|
65
65
|
/**
|
|
66
66
|
* @dev reverts when {_inTransferOwnership} variable is true
|
|
67
67
|
*/
|
|
68
|
-
modifier
|
|
68
|
+
modifier notInTransferOwnership() virtual {
|
|
69
69
|
if (_inTransferOwnership) {
|
|
70
70
|
revert LSP14MustAcceptOwnershipInSeparateTransaction();
|
|
71
71
|
}
|
|
@@ -97,9 +97,9 @@ abstract contract LSP14Ownable2Step is ILSP14Ownable2Step, OwnableUnset {
|
|
|
97
97
|
address currentOwner = owner();
|
|
98
98
|
emit OwnershipTransferStarted(currentOwner, newOwner);
|
|
99
99
|
|
|
100
|
-
newOwner.
|
|
100
|
+
newOwner.notifyUniversalReceiver(
|
|
101
101
|
_TYPEID_LSP14_OwnershipTransferStarted,
|
|
102
|
-
|
|
102
|
+
abi.encode(currentOwner, newOwner)
|
|
103
103
|
);
|
|
104
104
|
|
|
105
105
|
// reset the transfer ownership lock
|
|
@@ -111,19 +111,19 @@ abstract contract LSP14Ownable2Step is ILSP14Ownable2Step, OwnableUnset {
|
|
|
111
111
|
*
|
|
112
112
|
* @custom:requirements This function can only be called by the {pendingOwner()}.
|
|
113
113
|
*/
|
|
114
|
-
function acceptOwnership() public virtual override
|
|
114
|
+
function acceptOwnership() public virtual override notInTransferOwnership {
|
|
115
115
|
address previousOwner = owner();
|
|
116
116
|
|
|
117
117
|
_acceptOwnership();
|
|
118
118
|
|
|
119
|
-
previousOwner.
|
|
119
|
+
previousOwner.notifyUniversalReceiver(
|
|
120
120
|
_TYPEID_LSP14_OwnershipTransferred_SenderNotification,
|
|
121
|
-
|
|
121
|
+
abi.encode(previousOwner, msg.sender)
|
|
122
122
|
);
|
|
123
123
|
|
|
124
|
-
msg.sender.
|
|
124
|
+
msg.sender.notifyUniversalReceiver(
|
|
125
125
|
_TYPEID_LSP14_OwnershipTransferred_RecipientNotification,
|
|
126
|
-
|
|
126
|
+
abi.encode(previousOwner, msg.sender)
|
|
127
127
|
);
|
|
128
128
|
}
|
|
129
129
|
|
|
@@ -142,9 +142,9 @@ abstract contract LSP14Ownable2Step is ILSP14Ownable2Step, OwnableUnset {
|
|
|
142
142
|
_renounceOwnership();
|
|
143
143
|
|
|
144
144
|
if (owner() == address(0)) {
|
|
145
|
-
previousOwner.
|
|
145
|
+
previousOwner.notifyUniversalReceiver(
|
|
146
146
|
_TYPEID_LSP14_OwnershipTransferred_SenderNotification,
|
|
147
|
-
|
|
147
|
+
abi.encode(previousOwner, address(0))
|
|
148
148
|
);
|
|
149
149
|
}
|
|
150
150
|
}
|
|
@@ -175,6 +175,7 @@ abstract contract LSP14Ownable2Step is ILSP14Ownable2Step, OwnableUnset {
|
|
|
175
175
|
|
|
176
176
|
_setOwner(msg.sender);
|
|
177
177
|
delete _pendingOwner;
|
|
178
|
+
delete _renounceOwnershipStartedAt;
|
|
178
179
|
}
|
|
179
180
|
|
|
180
181
|
/**
|
|
@@ -4,12 +4,13 @@ pragma solidity ^0.8.4;
|
|
|
4
4
|
import {
|
|
5
5
|
ERC721Holder
|
|
6
6
|
} from "@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol";
|
|
7
|
+
import {LSP17Extension} from "../LSP17ContractExtension/LSP17Extension.sol";
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* @dev LSP17 Extension that can be attached to a LSP17Extendable contract
|
|
10
11
|
* to allow it to receive ERC721 tokens via `safeTransferFrom`.
|
|
11
12
|
*/
|
|
12
13
|
// solhint-disable-next-line no-empty-blocks
|
|
13
|
-
contract OnERC721ReceivedExtension is ERC721Holder {
|
|
14
|
+
contract OnERC721ReceivedExtension is ERC721Holder, LSP17Extension {
|
|
14
15
|
|
|
15
16
|
}
|
|
@@ -11,8 +11,8 @@ import {
|
|
|
11
11
|
import {ILSP7DigitalAsset} from "../../LSP7DigitalAsset/ILSP7DigitalAsset.sol";
|
|
12
12
|
|
|
13
13
|
// modules
|
|
14
|
-
import {Version} from "../../Version.sol";
|
|
15
14
|
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
|
|
15
|
+
import {Version} from "../../Version.sol";
|
|
16
16
|
|
|
17
17
|
// libraries
|
|
18
18
|
import {
|
|
@@ -60,6 +60,26 @@ contract LSP1UniversalReceiverDelegateUP is
|
|
|
60
60
|
{
|
|
61
61
|
using ERC165Checker for address;
|
|
62
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
|
+
|
|
63
83
|
/**
|
|
64
84
|
* @dev
|
|
65
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.
|
|
@@ -123,14 +143,9 @@ contract LSP1UniversalReceiverDelegateUP is
|
|
|
123
143
|
*
|
|
124
144
|
* @param notifier The LSP7 or LSP8 token address.
|
|
125
145
|
*/
|
|
126
|
-
function _tokenSender(
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
// solhint-disable-next-line avoid-tx-origin
|
|
130
|
-
if (notifier == tx.origin) {
|
|
131
|
-
revert CannotRegisterEOAsAsAssets(notifier);
|
|
132
|
-
}
|
|
133
|
-
|
|
146
|
+
function _tokenSender(
|
|
147
|
+
address notifier
|
|
148
|
+
) internal notEOA(notifier) returns (bytes memory) {
|
|
134
149
|
// if the amount sent is not the full balance, then do not update the keys
|
|
135
150
|
try ILSP7DigitalAsset(notifier).balanceOf(msg.sender) returns (
|
|
136
151
|
uint256 balance
|
|
@@ -168,14 +183,7 @@ contract LSP1UniversalReceiverDelegateUP is
|
|
|
168
183
|
function _tokenRecipient(
|
|
169
184
|
address notifier,
|
|
170
185
|
bytes4 interfaceId
|
|
171
|
-
) internal returns (bytes memory) {
|
|
172
|
-
// The notifier is supposed to be either the LSP7 or LSP8 or LSP9 contract
|
|
173
|
-
// If it's EOA we revert to avoid registering the EOA as asset or vault (spam protection)
|
|
174
|
-
// solhint-disable-next-line avoid-tx-origin
|
|
175
|
-
if (notifier == tx.origin) {
|
|
176
|
-
revert CannotRegisterEOAsAsAssets(notifier);
|
|
177
|
-
}
|
|
178
|
-
|
|
186
|
+
) internal notEOA(notifier) returns (bytes memory) {
|
|
179
187
|
// CHECK balance only when the Token contract is already deployed,
|
|
180
188
|
// not when tokens are being transferred on deployment through the `constructor`
|
|
181
189
|
if (notifier.code.length != 0) {
|
|
@@ -213,14 +221,9 @@ contract LSP1UniversalReceiverDelegateUP is
|
|
|
213
221
|
*
|
|
214
222
|
* @param notifier The LSP9 vault address.
|
|
215
223
|
*/
|
|
216
|
-
function _vaultSender(
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
// solhint-disable-next-line avoid-tx-origin
|
|
220
|
-
if (notifier == tx.origin) {
|
|
221
|
-
revert CannotRegisterEOAsAsAssets(notifier);
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
+
function _vaultSender(
|
|
225
|
+
address notifier
|
|
226
|
+
) internal notEOA(notifier) returns (bytes memory) {
|
|
224
227
|
(bytes32[] memory dataKeys, bytes[] memory dataValues) = LSP10Utils
|
|
225
228
|
.generateSentVaultKeys(msg.sender, notifier);
|
|
226
229
|
|
|
@@ -243,14 +246,9 @@ contract LSP1UniversalReceiverDelegateUP is
|
|
|
243
246
|
*
|
|
244
247
|
* @param notifier The LSP9 vault address.
|
|
245
248
|
*/
|
|
246
|
-
function _vaultRecipient(
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
// solhint-disable-next-line avoid-tx-origin
|
|
250
|
-
if (notifier == tx.origin) {
|
|
251
|
-
revert CannotRegisterEOAsAsAssets(notifier);
|
|
252
|
-
}
|
|
253
|
-
|
|
249
|
+
function _vaultRecipient(
|
|
250
|
+
address notifier
|
|
251
|
+
) internal notEOA(notifier) returns (bytes memory) {
|
|
254
252
|
(bytes32[] memory dataKeys, bytes[] memory dataValues) = LSP10Utils
|
|
255
253
|
.generateReceivedVaultKeys(msg.sender, notifier);
|
|
256
254
|
|
|
@@ -11,8 +11,8 @@ import {
|
|
|
11
11
|
import {ILSP7DigitalAsset} from "../../LSP7DigitalAsset/ILSP7DigitalAsset.sol";
|
|
12
12
|
|
|
13
13
|
// modules
|
|
14
|
-
import {Version} from "../../Version.sol";
|
|
15
14
|
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
|
|
15
|
+
import {Version} from "../../Version.sol";
|
|
16
16
|
|
|
17
17
|
// libraries
|
|
18
18
|
import {LSP5Utils} from "../../LSP5ReceivedAssets/LSP5Utils.sol";
|
|
@@ -48,6 +48,25 @@ contract LSP1UniversalReceiverDelegateVault is
|
|
|
48
48
|
Version,
|
|
49
49
|
ILSP1UniversalReceiverDelegate
|
|
50
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
|
+
|
|
51
70
|
/**
|
|
52
71
|
* @inheritdoc ILSP1UniversalReceiverDelegate
|
|
53
72
|
* @dev Handles two cases:
|
|
@@ -99,14 +118,9 @@ contract LSP1UniversalReceiverDelegateVault is
|
|
|
99
118
|
*
|
|
100
119
|
* @param notifier The LSP7 or LSP8 token address.
|
|
101
120
|
*/
|
|
102
|
-
function _tokenSender(
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
// solhint-disable-next-line avoid-tx-origin
|
|
106
|
-
if (notifier == tx.origin) {
|
|
107
|
-
revert CannotRegisterEOAsAsAssets(notifier);
|
|
108
|
-
}
|
|
109
|
-
|
|
121
|
+
function _tokenSender(
|
|
122
|
+
address notifier
|
|
123
|
+
) internal notEOA(notifier) returns (bytes memory) {
|
|
110
124
|
// if the amount sent is not the full balance, then do not update the keys
|
|
111
125
|
try ILSP7DigitalAsset(notifier).balanceOf(msg.sender) returns (
|
|
112
126
|
uint256 balance
|
|
@@ -144,14 +158,7 @@ contract LSP1UniversalReceiverDelegateVault is
|
|
|
144
158
|
function _tokenRecipient(
|
|
145
159
|
address notifier,
|
|
146
160
|
bytes4 interfaceId
|
|
147
|
-
) internal returns (bytes memory) {
|
|
148
|
-
// The notifier is supposed to be either the LSP7 or LSP8 contract
|
|
149
|
-
// If it's EOA we revert to avoid registering the EOA as asset (spam protection)
|
|
150
|
-
// solhint-disable-next-line avoid-tx-origin
|
|
151
|
-
if (notifier == tx.origin) {
|
|
152
|
-
revert CannotRegisterEOAsAsAssets(notifier);
|
|
153
|
-
}
|
|
154
|
-
|
|
161
|
+
) internal notEOA(notifier) returns (bytes memory) {
|
|
155
162
|
// CHECK balance only when the Token contract is already deployed,
|
|
156
163
|
// not when tokens are being transferred on deployment through the `constructor`
|
|
157
164
|
if (notifier.code.length != 0) {
|
|
@@ -35,7 +35,7 @@ library LSP1Utils {
|
|
|
35
35
|
* @param typeId A `bytes32` typeId.
|
|
36
36
|
* @param data Any optional data to send to the `universalReceiver` function to the `lsp1Implementation` address.
|
|
37
37
|
*/
|
|
38
|
-
function
|
|
38
|
+
function notifyUniversalReceiver(
|
|
39
39
|
address lsp1Implementation,
|
|
40
40
|
bytes32 typeId,
|
|
41
41
|
bytes memory data
|
|
@@ -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,
|
|
@@ -18,7 +18,6 @@ import {
|
|
|
18
18
|
} from "../LSP25ExecuteRelayCall/ILSP25ExecuteRelayCall.sol";
|
|
19
19
|
|
|
20
20
|
// modules
|
|
21
|
-
import {Version} from "../Version.sol";
|
|
22
21
|
import {ILSP14Ownable2Step} from "../LSP14Ownable2Step/ILSP14Ownable2Step.sol";
|
|
23
22
|
import {ERC725Y} from "@erc725/smart-contracts/contracts/ERC725Y.sol";
|
|
24
23
|
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
|
|
@@ -88,7 +87,6 @@ abstract contract LSP6KeyManagerCore is
|
|
|
88
87
|
ILSP6,
|
|
89
88
|
ILSP20,
|
|
90
89
|
ILSP25,
|
|
91
|
-
Version,
|
|
92
90
|
LSP6SetDataModule,
|
|
93
91
|
LSP6ExecuteModule,
|
|
94
92
|
LSP6ExecuteRelayCallModule,
|
|
@@ -152,6 +150,11 @@ abstract contract LSP6KeyManagerCore is
|
|
|
152
150
|
* If the signer is a controller with the permission `SIGN`, it will return the ERC1271 success value.
|
|
153
151
|
*
|
|
154
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.
|
|
155
158
|
*/
|
|
156
159
|
function isValidSignature(
|
|
157
160
|
bytes32 dataHash,
|
|
@@ -510,13 +513,14 @@ abstract contract LSP6KeyManagerCore is
|
|
|
510
513
|
value: msgValue,
|
|
511
514
|
gas: gasleft()
|
|
512
515
|
}(payload);
|
|
516
|
+
|
|
513
517
|
bytes memory result = Address.verifyCallResult(
|
|
514
518
|
success,
|
|
515
519
|
returnData,
|
|
516
520
|
"LSP6: failed executing payload"
|
|
517
521
|
);
|
|
518
522
|
|
|
519
|
-
return result
|
|
523
|
+
return result;
|
|
520
524
|
}
|
|
521
525
|
|
|
522
526
|
/**
|
|
@@ -612,7 +616,7 @@ abstract contract LSP6KeyManagerCore is
|
|
|
612
616
|
revert ERC725X_ExecuteParametersEmptyArray();
|
|
613
617
|
}
|
|
614
618
|
|
|
615
|
-
for (uint256 ii
|
|
619
|
+
for (uint256 ii; ii < operationTypes.length; ii++) {
|
|
616
620
|
LSP6ExecuteModule._verifyCanExecute(
|
|
617
621
|
targetContract,
|
|
618
622
|
from,
|
|
@@ -635,9 +639,11 @@ abstract contract LSP6KeyManagerCore is
|
|
|
635
639
|
}
|
|
636
640
|
|
|
637
641
|
/**
|
|
638
|
-
* @dev
|
|
639
|
-
* the status is `
|
|
640
|
-
*
|
|
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
|
+
*
|
|
641
647
|
*/
|
|
642
648
|
function _nonReentrantBefore(
|
|
643
649
|
address targetContract,
|
|
@@ -661,8 +667,8 @@ abstract contract LSP6KeyManagerCore is
|
|
|
661
667
|
}
|
|
662
668
|
|
|
663
669
|
/**
|
|
664
|
-
* @dev Resets the status to `false`
|
|
665
|
-
* 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.
|
|
666
672
|
*/
|
|
667
673
|
function _nonReentrantAfter(address targetContract) internal virtual {
|
|
668
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
|
|
@@ -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
|
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
import {ILSP7DigitalAsset} from "./ILSP7DigitalAsset.sol";
|
|
9
9
|
|
|
10
10
|
// modules
|
|
11
|
-
import {Version} from "../Version.sol";
|
|
12
11
|
|
|
13
12
|
// libraries
|
|
14
13
|
import {
|
|
@@ -52,7 +51,7 @@ import {
|
|
|
52
51
|
* Similar to ERC20, the non-standard {increaseAllowance} and {decreaseAllowance} functions
|
|
53
52
|
* have been added to mitigate the well-known issues around setting allowances.
|
|
54
53
|
*/
|
|
55
|
-
abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset
|
|
54
|
+
abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset {
|
|
56
55
|
using EnumerableSet for EnumerableSet.AddressSet;
|
|
57
56
|
using ERC165Checker for address;
|
|
58
57
|
using LSP1Utils for address;
|
|
@@ -133,10 +132,7 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset, Version {
|
|
|
133
132
|
operatorNotificationData
|
|
134
133
|
);
|
|
135
134
|
|
|
136
|
-
operator.
|
|
137
|
-
_TYPEID_LSP7_TOKENOPERATOR,
|
|
138
|
-
lsp1Data
|
|
139
|
-
);
|
|
135
|
+
operator.notifyUniversalReceiver(_TYPEID_LSP7_TOKENOPERATOR, lsp1Data);
|
|
140
136
|
}
|
|
141
137
|
|
|
142
138
|
/**
|
|
@@ -162,7 +158,7 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset, Version {
|
|
|
162
158
|
operatorNotificationData
|
|
163
159
|
);
|
|
164
160
|
|
|
165
|
-
operator.
|
|
161
|
+
operator.notifyUniversalReceiver(
|
|
166
162
|
_TYPEID_LSP7_TOKENOPERATOR,
|
|
167
163
|
lsp1Data
|
|
168
164
|
);
|
|
@@ -220,10 +216,7 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset, Version {
|
|
|
220
216
|
operatorNotificationData
|
|
221
217
|
);
|
|
222
218
|
|
|
223
|
-
operator.
|
|
224
|
-
_TYPEID_LSP7_TOKENOPERATOR,
|
|
225
|
-
lsp1Data
|
|
226
|
-
);
|
|
219
|
+
operator.notifyUniversalReceiver(_TYPEID_LSP7_TOKENOPERATOR, lsp1Data);
|
|
227
220
|
}
|
|
228
221
|
|
|
229
222
|
/**
|
|
@@ -257,10 +250,7 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset, Version {
|
|
|
257
250
|
operatorNotificationData
|
|
258
251
|
);
|
|
259
252
|
|
|
260
|
-
operator.
|
|
261
|
-
_TYPEID_LSP7_TOKENOPERATOR,
|
|
262
|
-
lsp1Data
|
|
263
|
-
);
|
|
253
|
+
operator.notifyUniversalReceiver(_TYPEID_LSP7_TOKENOPERATOR, lsp1Data);
|
|
264
254
|
}
|
|
265
255
|
|
|
266
256
|
// --- Transfer functionality
|
|
@@ -474,7 +464,7 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset, Version {
|
|
|
474
464
|
_afterTokenTransfer(from, address(0), amount, data);
|
|
475
465
|
|
|
476
466
|
bytes memory lsp1Data = abi.encode(from, address(0), amount, data);
|
|
477
|
-
from.
|
|
467
|
+
from.notifyUniversalReceiver(_TYPEID_LSP7_TOKENSSENDER, lsp1Data);
|
|
478
468
|
}
|
|
479
469
|
|
|
480
470
|
/**
|
|
@@ -572,7 +562,7 @@ abstract contract LSP7DigitalAssetCore is ILSP7DigitalAsset, Version {
|
|
|
572
562
|
|
|
573
563
|
bytes memory lsp1Data = abi.encode(from, to, amount, data);
|
|
574
564
|
|
|
575
|
-
from.
|
|
565
|
+
from.notifyUniversalReceiver(_TYPEID_LSP7_TOKENSSENDER, lsp1Data);
|
|
576
566
|
_notifyTokenReceiver(to, force, lsp1Data);
|
|
577
567
|
}
|
|
578
568
|
|
|
@@ -9,9 +9,6 @@ import {
|
|
|
9
9
|
ILSP8IdentifiableDigitalAsset
|
|
10
10
|
} from "./ILSP8IdentifiableDigitalAsset.sol";
|
|
11
11
|
|
|
12
|
-
// modules
|
|
13
|
-
import {Version} from "../Version.sol";
|
|
14
|
-
|
|
15
12
|
// libraries
|
|
16
13
|
import {
|
|
17
14
|
EnumerableSet
|
|
@@ -52,8 +49,7 @@ import {
|
|
|
52
49
|
* @dev Core Implementation of a LSP8 compliant contract.
|
|
53
50
|
*/
|
|
54
51
|
abstract contract LSP8IdentifiableDigitalAssetCore is
|
|
55
|
-
ILSP8IdentifiableDigitalAsset
|
|
56
|
-
Version
|
|
52
|
+
ILSP8IdentifiableDigitalAsset
|
|
57
53
|
{
|
|
58
54
|
using EnumerableSet for EnumerableSet.AddressSet;
|
|
59
55
|
using EnumerableSet for EnumerableSet.Bytes32Set;
|
|
@@ -160,10 +156,7 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
|
|
|
160
156
|
operatorNotificationData
|
|
161
157
|
);
|
|
162
158
|
|
|
163
|
-
operator.
|
|
164
|
-
_TYPEID_LSP8_TOKENOPERATOR,
|
|
165
|
-
lsp1Data
|
|
166
|
-
);
|
|
159
|
+
operator.notifyUniversalReceiver(_TYPEID_LSP8_TOKENOPERATOR, lsp1Data);
|
|
167
160
|
}
|
|
168
161
|
|
|
169
162
|
/**
|
|
@@ -205,7 +198,7 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
|
|
|
205
198
|
operatorNotificationData
|
|
206
199
|
);
|
|
207
200
|
|
|
208
|
-
operator.
|
|
201
|
+
operator.notifyUniversalReceiver(
|
|
209
202
|
_TYPEID_LSP8_TOKENOPERATOR,
|
|
210
203
|
lsp1Data
|
|
211
204
|
);
|
|
@@ -467,10 +460,7 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
|
|
|
467
460
|
data
|
|
468
461
|
);
|
|
469
462
|
|
|
470
|
-
tokenOwner.
|
|
471
|
-
_TYPEID_LSP8_TOKENSSENDER,
|
|
472
|
-
lsp1Data
|
|
473
|
-
);
|
|
463
|
+
tokenOwner.notifyUniversalReceiver(_TYPEID_LSP8_TOKENSSENDER, lsp1Data);
|
|
474
464
|
}
|
|
475
465
|
|
|
476
466
|
/**
|
|
@@ -536,7 +526,7 @@ abstract contract LSP8IdentifiableDigitalAssetCore is
|
|
|
536
526
|
|
|
537
527
|
bytes memory lsp1Data = abi.encode(from, to, tokenId, data);
|
|
538
528
|
|
|
539
|
-
from.
|
|
529
|
+
from.notifyUniversalReceiver(_TYPEID_LSP8_TOKENSSENDER, lsp1Data);
|
|
540
530
|
_notifyTokenReceiver(to, force, lsp1Data);
|
|
541
531
|
}
|
|
542
532
|
|
|
@@ -357,10 +357,7 @@ abstract contract LSP8CompatibleERC721 is
|
|
|
357
357
|
tokenId,
|
|
358
358
|
operatorNotificationData
|
|
359
359
|
);
|
|
360
|
-
operator.
|
|
361
|
-
_TYPEID_LSP8_TOKENOPERATOR,
|
|
362
|
-
lsp1Data
|
|
363
|
-
);
|
|
360
|
+
operator.notifyUniversalReceiver(_TYPEID_LSP8_TOKENOPERATOR, lsp1Data);
|
|
364
361
|
}
|
|
365
362
|
|
|
366
363
|
/**
|
package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol
CHANGED
|
@@ -366,10 +366,7 @@ abstract contract LSP8CompatibleERC721InitAbstract is
|
|
|
366
366
|
tokenId,
|
|
367
367
|
operatorNotificationData
|
|
368
368
|
);
|
|
369
|
-
operator.
|
|
370
|
-
_TYPEID_LSP8_TOKENOPERATOR,
|
|
371
|
-
lsp1Data
|
|
372
|
-
);
|
|
369
|
+
operator.notifyUniversalReceiver(_TYPEID_LSP8_TOKENOPERATOR, lsp1Data);
|
|
373
370
|
}
|
|
374
371
|
|
|
375
372
|
/**
|
|
@@ -17,7 +17,7 @@ bytes constant _LSP9_SUPPORTED_STANDARDS_VALUE = hex"7c0334a1";
|
|
|
17
17
|
// keccak256('LSP9ValueReceived')
|
|
18
18
|
bytes32 constant _TYPEID_LSP9_VALUE_RECEIVED = 0x468cd1581d7bc001c3b685513d2b929b55437be34700410383d58f3aa1ea0abc;
|
|
19
19
|
|
|
20
|
-
//
|
|
20
|
+
// Ownership Transfer Type IDs
|
|
21
21
|
|
|
22
22
|
// keccak256('LSP9OwnershipTransferStarted')
|
|
23
23
|
bytes32 constant _TYPEID_LSP9_OwnershipTransferStarted = 0xaefd43f45fed1bcd8992f23c803b6f4ec45cf6b62b0d404d565f290a471e763f;
|