@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
|
@@ -40,6 +40,7 @@ import {
|
|
|
40
40
|
_INTERFACEID_ERC1271,
|
|
41
41
|
_ERC1271_SUCCESSVALUE,
|
|
42
42
|
_ERC1271_FAILVALUE,
|
|
43
|
+
_TYPEID_LSP0_VALUE_RECEIVED,
|
|
43
44
|
_TYPEID_LSP0_OwnershipTransferStarted,
|
|
44
45
|
_TYPEID_LSP0_OwnershipTransferred_SenderNotification,
|
|
45
46
|
_TYPEID_LSP0_OwnershipTransferred_RecipientNotification
|
|
@@ -92,11 +93,14 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
92
93
|
* - When receiving some native tokens without any additional data.
|
|
93
94
|
* - On empty calls to the contract.
|
|
94
95
|
*
|
|
95
|
-
* @custom:
|
|
96
|
+
* @custom:info This function internally delegates the handling of native tokens to the {universalReceiver} function
|
|
97
|
+
* passing `_TYPEID_LSP0_VALUE_RECEIVED` as typeId and an empty bytes array as received data.
|
|
98
|
+
*
|
|
99
|
+
* @custom:events Emits a {UniversalReceiver} event when the `universalReceiver` logic is executed upon receiving native tokens.
|
|
96
100
|
*/
|
|
97
101
|
receive() external payable virtual {
|
|
98
102
|
if (msg.value != 0) {
|
|
99
|
-
|
|
103
|
+
universalReceiver(_TYPEID_LSP0_VALUE_RECEIVED, "");
|
|
100
104
|
}
|
|
101
105
|
}
|
|
102
106
|
|
|
@@ -119,17 +123,19 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
119
123
|
*
|
|
120
124
|
* 2. If the data sent to this function is of length less than 4 bytes (not a function selector), return.
|
|
121
125
|
*
|
|
122
|
-
* @custom:
|
|
126
|
+
* @custom:info Whenever the call is associated with native tokens, the function will delegate the handling of native tokens internally to the {universalReceiver} function
|
|
127
|
+
* passing `_TYPEID_LSP0_VALUE_RECEIVED` as typeId and the calldata as received data, except when the native token will be sent directly to the extension.
|
|
128
|
+
*
|
|
129
|
+
* @custom:events {UniversalReceiver} event when receiving native tokens and extension function selector is not found or not payable.
|
|
123
130
|
*/
|
|
124
|
-
// solhint-disable-next-line no-complex-fallback
|
|
125
131
|
fallback(
|
|
126
132
|
bytes calldata callData
|
|
127
133
|
) external payable virtual returns (bytes memory) {
|
|
128
|
-
if (msg.value != 0) {
|
|
129
|
-
emit ValueReceived(msg.sender, msg.value);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
134
|
if (msg.data.length < 4) {
|
|
135
|
+
// if value is associated with the extension call, use the universalReceiver
|
|
136
|
+
if (msg.value != 0) {
|
|
137
|
+
universalReceiver(_TYPEID_LSP0_VALUE_RECEIVED, callData);
|
|
138
|
+
}
|
|
133
139
|
return "";
|
|
134
140
|
}
|
|
135
141
|
|
|
@@ -185,7 +191,7 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
185
191
|
* @custom:events
|
|
186
192
|
* - {Executed} event for each call that uses under `operationType`: `CALL` (0), `STATICCALL` (3) and `DELEGATECALL` (4).
|
|
187
193
|
* - {ContractCreated} event, when a contract is created under `operationType`: `CREATE` (1) and `CREATE2` (2).
|
|
188
|
-
* - {
|
|
194
|
+
* - {UniversalReceiver} event when receiving native tokens.
|
|
189
195
|
*/
|
|
190
196
|
function execute(
|
|
191
197
|
uint256 operationType,
|
|
@@ -194,7 +200,13 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
194
200
|
bytes memory data
|
|
195
201
|
) public payable virtual override returns (bytes memory) {
|
|
196
202
|
if (msg.value != 0) {
|
|
197
|
-
emit
|
|
203
|
+
emit UniversalReceiver(
|
|
204
|
+
msg.sender,
|
|
205
|
+
msg.value,
|
|
206
|
+
_TYPEID_LSP0_VALUE_RECEIVED,
|
|
207
|
+
abi.encodePacked(msg.sig),
|
|
208
|
+
""
|
|
209
|
+
);
|
|
198
210
|
}
|
|
199
211
|
|
|
200
212
|
address accountOwner = owner();
|
|
@@ -243,7 +255,7 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
243
255
|
* @custom:events
|
|
244
256
|
* - {Executed} event for each call that uses under `operationType`: `CALL` (0), `STATICCALL` (3) and `DELEGATECALL` (4). (each iteration)
|
|
245
257
|
* - {ContractCreated} event, when a contract is created under `operationType`: `CREATE` (1) and `CREATE2` (2) (each iteration)
|
|
246
|
-
* - {
|
|
258
|
+
* - {UniversalReceiver} event when receiving native tokens.
|
|
247
259
|
*/
|
|
248
260
|
function executeBatch(
|
|
249
261
|
uint256[] memory operationsType,
|
|
@@ -252,7 +264,13 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
252
264
|
bytes[] memory datas
|
|
253
265
|
) public payable virtual override returns (bytes[] memory) {
|
|
254
266
|
if (msg.value != 0) {
|
|
255
|
-
emit
|
|
267
|
+
emit UniversalReceiver(
|
|
268
|
+
msg.sender,
|
|
269
|
+
msg.value,
|
|
270
|
+
_TYPEID_LSP0_VALUE_RECEIVED,
|
|
271
|
+
abi.encodePacked(msg.sig),
|
|
272
|
+
""
|
|
273
|
+
);
|
|
256
274
|
}
|
|
257
275
|
|
|
258
276
|
address accountOwner = owner();
|
|
@@ -297,7 +315,7 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
297
315
|
* @custom:requirements Can be only called by the {owner} or by an authorised address that pass the verification check performed on the owner.
|
|
298
316
|
*
|
|
299
317
|
* @custom:events
|
|
300
|
-
* - {
|
|
318
|
+
* - {UniversalReceiver} event when receiving native tokens.
|
|
301
319
|
* - {DataChanged} event.
|
|
302
320
|
*/
|
|
303
321
|
function setData(
|
|
@@ -305,7 +323,13 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
305
323
|
bytes memory dataValue
|
|
306
324
|
) public payable virtual override {
|
|
307
325
|
if (msg.value != 0) {
|
|
308
|
-
emit
|
|
326
|
+
emit UniversalReceiver(
|
|
327
|
+
msg.sender,
|
|
328
|
+
msg.value,
|
|
329
|
+
_TYPEID_LSP0_VALUE_RECEIVED,
|
|
330
|
+
abi.encodePacked(msg.sig),
|
|
331
|
+
""
|
|
332
|
+
);
|
|
309
333
|
}
|
|
310
334
|
|
|
311
335
|
address accountOwner = owner();
|
|
@@ -334,7 +358,7 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
334
358
|
* @custom:requirements Can be only called by the {owner} or by an authorised address that pass the verification check performed on the owner.
|
|
335
359
|
*
|
|
336
360
|
* @custom:events
|
|
337
|
-
* - {
|
|
361
|
+
* - {UniversalReceiver} event when receiving native tokens.
|
|
338
362
|
* - {DataChanged} event. (on each iteration of setting data)
|
|
339
363
|
*/
|
|
340
364
|
function setDataBatch(
|
|
@@ -342,7 +366,13 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
342
366
|
bytes[] memory dataValues
|
|
343
367
|
) public payable virtual override {
|
|
344
368
|
if (msg.value != 0) {
|
|
345
|
-
emit
|
|
369
|
+
emit UniversalReceiver(
|
|
370
|
+
msg.sender,
|
|
371
|
+
msg.value,
|
|
372
|
+
_TYPEID_LSP0_VALUE_RECEIVED,
|
|
373
|
+
abi.encodePacked(msg.sig),
|
|
374
|
+
""
|
|
375
|
+
);
|
|
346
376
|
}
|
|
347
377
|
|
|
348
378
|
if (dataKeys.length != dataValues.length) {
|
|
@@ -408,21 +438,23 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
408
438
|
*
|
|
409
439
|
* - If yes, call this address with the typeId and data (params), along with additional calldata consisting of 20 bytes of `msg.sender` and 32 bytes of `msg.value`. If not, continue the execution of the function.
|
|
410
440
|
*
|
|
441
|
+
* This function delegates internally the handling of native tokens to the {universalReceiver} function itself passing `_TYPEID_LSP0_VALUE_RECEIVED` as typeId and the calldata as received data.
|
|
442
|
+
*
|
|
411
443
|
* @param typeId The type of call received.
|
|
412
444
|
* @param receivedData The data received.
|
|
413
445
|
*
|
|
414
446
|
* @return returnedValues The ABI encoded return value of the LSP1UniversalReceiverDelegate call and the LSP1TypeIdDelegate call.
|
|
415
447
|
*
|
|
416
448
|
* @custom:events
|
|
417
|
-
* - {
|
|
449
|
+
* - {UniversalReceiver} when receiving native tokens.
|
|
418
450
|
* - {UniversalReceiver} event with the function parameters, call options, and the response of the UniversalReceiverDelegates (URD) contract that was called.
|
|
419
451
|
*/
|
|
420
452
|
function universalReceiver(
|
|
421
453
|
bytes32 typeId,
|
|
422
|
-
bytes
|
|
454
|
+
bytes memory receivedData
|
|
423
455
|
) public payable virtual override returns (bytes memory returnedValues) {
|
|
424
|
-
if (msg.value != 0) {
|
|
425
|
-
|
|
456
|
+
if (msg.value != 0 && (typeId != _TYPEID_LSP0_VALUE_RECEIVED)) {
|
|
457
|
+
universalReceiver(_TYPEID_LSP0_VALUE_RECEIVED, msg.data);
|
|
426
458
|
}
|
|
427
459
|
|
|
428
460
|
// Query the ERC725Y storage with the data key {_LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY}
|
|
@@ -515,9 +547,9 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
515
547
|
emit OwnershipTransferStarted(currentOwner, pendingNewOwner);
|
|
516
548
|
|
|
517
549
|
// notify the pending owner through LSP1
|
|
518
|
-
pendingNewOwner.
|
|
550
|
+
pendingNewOwner.notifyUniversalReceiver(
|
|
519
551
|
_TYPEID_LSP0_OwnershipTransferStarted,
|
|
520
|
-
|
|
552
|
+
abi.encode(currentOwner, pendingNewOwner)
|
|
521
553
|
);
|
|
522
554
|
|
|
523
555
|
// reset the transfer ownership lock
|
|
@@ -535,9 +567,9 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
535
567
|
emit OwnershipTransferStarted(currentOwner, pendingNewOwner);
|
|
536
568
|
|
|
537
569
|
// notify the pending owner through LSP1
|
|
538
|
-
pendingNewOwner.
|
|
570
|
+
pendingNewOwner.notifyUniversalReceiver(
|
|
539
571
|
_TYPEID_LSP0_OwnershipTransferStarted,
|
|
540
|
-
|
|
572
|
+
abi.encode(currentOwner, pendingNewOwner)
|
|
541
573
|
);
|
|
542
574
|
|
|
543
575
|
// reset the transfer ownership lock
|
|
@@ -559,7 +591,7 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
559
591
|
* - When notifying the previous owner via LSP1, the typeId used must be the `keccak256(...)` hash of [LSP0OwnershipTransferred_SenderNotification].
|
|
560
592
|
* - When notifying the new owner via LSP1, the typeId used must be the `keccak256(...)` hash of [LSP0OwnershipTransferred_RecipientNotification].
|
|
561
593
|
*/
|
|
562
|
-
function acceptOwnership() public virtual override
|
|
594
|
+
function acceptOwnership() public virtual override notInTransferOwnership {
|
|
563
595
|
address previousOwner = owner();
|
|
564
596
|
address pendingOwnerAddress = pendingOwner();
|
|
565
597
|
|
|
@@ -572,20 +604,21 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
572
604
|
|
|
573
605
|
_setOwner(pendingOwnerAddress);
|
|
574
606
|
delete _pendingOwner;
|
|
607
|
+
delete _renounceOwnershipStartedAt;
|
|
575
608
|
} else {
|
|
576
609
|
_acceptOwnership();
|
|
577
610
|
}
|
|
578
611
|
|
|
579
612
|
// notify the previous owner if supports LSP1
|
|
580
|
-
previousOwner.
|
|
613
|
+
previousOwner.notifyUniversalReceiver(
|
|
581
614
|
_TYPEID_LSP0_OwnershipTransferred_SenderNotification,
|
|
582
|
-
|
|
615
|
+
abi.encode(previousOwner, pendingOwnerAddress)
|
|
583
616
|
);
|
|
584
617
|
|
|
585
618
|
// notify the pending owner if supports LSP1
|
|
586
|
-
pendingOwnerAddress.
|
|
619
|
+
pendingOwnerAddress.notifyUniversalReceiver(
|
|
587
620
|
_TYPEID_LSP0_OwnershipTransferred_RecipientNotification,
|
|
588
|
-
|
|
621
|
+
abi.encode(previousOwner, pendingOwnerAddress)
|
|
589
622
|
);
|
|
590
623
|
|
|
591
624
|
// If msg.sender != pendingOwnerAddress & verifyAfter is true, Call {lsp20VerifyCallResult} on the new owner
|
|
@@ -612,27 +645,35 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
612
645
|
|
|
613
646
|
// If the caller is the owner perform renounceOwnership directly
|
|
614
647
|
if (msg.sender == accountOwner) {
|
|
615
|
-
|
|
616
|
-
|
|
648
|
+
address previousOwner = owner();
|
|
649
|
+
LSP14Ownable2Step._renounceOwnership();
|
|
617
650
|
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
651
|
+
if (owner() == address(0)) {
|
|
652
|
+
previousOwner.notifyUniversalReceiver(
|
|
653
|
+
_TYPEID_LSP0_OwnershipTransferred_SenderNotification,
|
|
654
|
+
abi.encode(accountOwner, address(0))
|
|
655
|
+
);
|
|
656
|
+
}
|
|
657
|
+
} else {
|
|
658
|
+
// If the caller is not the owner, call {lsp20VerifyCall} on the owner
|
|
659
|
+
// Depending on the returnedStatus, a second call is done after transferring ownership
|
|
660
|
+
bool verifyAfter = _verifyCall(accountOwner);
|
|
621
661
|
|
|
622
|
-
|
|
623
|
-
|
|
662
|
+
address previousOwner = owner();
|
|
663
|
+
LSP14Ownable2Step._renounceOwnership();
|
|
624
664
|
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
665
|
+
if (owner() == address(0)) {
|
|
666
|
+
previousOwner.notifyUniversalReceiver(
|
|
667
|
+
_TYPEID_LSP0_OwnershipTransferred_SenderNotification,
|
|
668
|
+
abi.encode(accountOwner, address(0))
|
|
669
|
+
);
|
|
670
|
+
}
|
|
631
671
|
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
672
|
+
// If verifyAfter is true, Call {lsp20VerifyCallResult} on the owner
|
|
673
|
+
// The transferOwnership function does not return, second parameter of {_verifyCallResult} will be empty
|
|
674
|
+
if (verifyAfter) {
|
|
675
|
+
_verifyCallResult(accountOwner, "");
|
|
676
|
+
}
|
|
636
677
|
}
|
|
637
678
|
}
|
|
638
679
|
|
|
@@ -691,6 +732,11 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
691
732
|
* @param signature A signature that can validate the previous parameter (Hash).
|
|
692
733
|
*
|
|
693
734
|
* @return returnedStatus A `bytes4` value that indicates if the signature is valid or not.
|
|
735
|
+
*
|
|
736
|
+
* @custom:warning This function does not enforce by default the inclusion of the address of this contract in the signature digest.
|
|
737
|
+
* It is recommended that protocols or applications using this contract include the targeted address (= this contract) in the data to sign.
|
|
738
|
+
* To ensure that a signature is valid for a specific LSP0ERC725Account and prevent signatures from the same EOA to be replayed
|
|
739
|
+
* across different LSP0ERC725Accounts.
|
|
694
740
|
*/
|
|
695
741
|
function isValidSignature(
|
|
696
742
|
bytes32 dataHash,
|
|
@@ -740,28 +786,30 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
740
786
|
/**
|
|
741
787
|
* @dev Forwards the call to an extension mapped to a function selector.
|
|
742
788
|
*
|
|
743
|
-
* Calls {
|
|
789
|
+
* Calls {_getExtensionAndForwardValue} to get the address of the extension mapped to the function selector being
|
|
744
790
|
* called on the account. If there is no extension, the `address(0)` will be returned.
|
|
791
|
+
* Forwards the value sent with the call to the extension if the function selector is mapped to a payable extension.
|
|
745
792
|
*
|
|
746
793
|
* Reverts if there is no extension for the function being called, except for the `bytes4(0)` function selector, which passes even if there is no extension for it.
|
|
747
794
|
*
|
|
748
795
|
* If there is an extension for the function selector being called, it calls the extension with the
|
|
749
796
|
* `CALL` opcode, passing the `msg.data` appended with the 20 bytes of the {msg.sender} and 32 bytes of the `msg.value`.
|
|
750
797
|
*
|
|
751
|
-
* @custom:hint
|
|
752
|
-
* If you would like to forward the `msg.value` to the extension contract, you can override the code of this internal function as follow:
|
|
753
|
-
*
|
|
754
|
-
* ```solidity
|
|
755
|
-
* (bool success, bytes memory result) = extension.call{value: msg.value}(
|
|
756
|
-
* abi.encodePacked(callData, msg.sender, msg.value)
|
|
757
|
-
* );
|
|
758
|
-
* ```
|
|
798
|
+
* @custom:hint If you would like to forward the `msg.value` to the extension contract, you should store an additional `0x01` byte after the address of the extension under the corresponding LSP17 data key.
|
|
759
799
|
*/
|
|
760
800
|
function _fallbackLSP17Extendable(
|
|
761
801
|
bytes calldata callData
|
|
762
802
|
) internal virtual override returns (bytes memory) {
|
|
763
803
|
// If there is a function selector
|
|
764
|
-
|
|
804
|
+
(
|
|
805
|
+
address extension,
|
|
806
|
+
bool isForwardingValue
|
|
807
|
+
) = _getExtensionAndForwardValue(msg.sig);
|
|
808
|
+
|
|
809
|
+
// if value is associated with the extension call and extension function selector is not payable, use the universalReceiver
|
|
810
|
+
if (msg.value != 0 && !isForwardingValue) {
|
|
811
|
+
universalReceiver(_TYPEID_LSP0_VALUE_RECEIVED, callData);
|
|
812
|
+
}
|
|
765
813
|
|
|
766
814
|
// if no extension was found for bytes4(0) return don't revert
|
|
767
815
|
if (msg.sig == bytes4(0) && extension == address(0)) return "";
|
|
@@ -770,9 +818,9 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
770
818
|
if (extension == address(0))
|
|
771
819
|
revert NoExtensionFoundForFunctionSelector(msg.sig);
|
|
772
820
|
|
|
773
|
-
(bool success, bytes memory result) = extension.call
|
|
774
|
-
|
|
775
|
-
);
|
|
821
|
+
(bool success, bytes memory result) = extension.call{
|
|
822
|
+
value: isForwardingValue ? msg.value : 0
|
|
823
|
+
}(abi.encodePacked(callData, msg.sender, msg.value));
|
|
776
824
|
|
|
777
825
|
if (success) {
|
|
778
826
|
return result;
|
|
@@ -787,25 +835,43 @@ abstract contract LSP0ERC725AccountCore is
|
|
|
787
835
|
}
|
|
788
836
|
|
|
789
837
|
/**
|
|
790
|
-
* @dev Returns the extension address stored under the following data key:
|
|
838
|
+
* @dev Returns the extension address and the boolean indicating whether to forward the value received to the extension, stored under the following data key:
|
|
791
839
|
* - {_LSP17_EXTENSION_PREFIX} + `<bytes4>` (Check [LSP2-ERC725YJSONSchema] for encoding the data key).
|
|
792
840
|
* - If no extension is stored, returns the address(0).
|
|
841
|
+
* - If the stored value is 20 bytes, return false for the boolean
|
|
793
842
|
*/
|
|
794
|
-
function
|
|
843
|
+
function _getExtensionAndForwardValue(
|
|
795
844
|
bytes4 functionSelector
|
|
796
|
-
) internal view virtual override returns (address) {
|
|
845
|
+
) internal view virtual override returns (address, bool) {
|
|
797
846
|
// Generate the data key relevant for the functionSelector being called
|
|
798
847
|
bytes32 mappedExtensionDataKey = LSP2Utils.generateMappingKey(
|
|
799
848
|
_LSP17_EXTENSION_PREFIX,
|
|
800
849
|
functionSelector
|
|
801
850
|
);
|
|
802
851
|
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
bytes20(ERC725YCore._getData(mappedExtensionDataKey))
|
|
852
|
+
bytes memory extensionData = ERC725YCore._getData(
|
|
853
|
+
mappedExtensionDataKey
|
|
806
854
|
);
|
|
807
855
|
|
|
808
|
-
|
|
856
|
+
// Prevent casting data shorter than 20 bytes to an address to avoid
|
|
857
|
+
// unintentionally calling a different extension, return address(0) instead.
|
|
858
|
+
if (extensionData.length < 20) {
|
|
859
|
+
return (address(0), false);
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
// CHECK if the `extensionData` is 21 bytes long
|
|
863
|
+
// - 20 bytes = extension's address
|
|
864
|
+
// - 1 byte `0x01` as a boolean indicating if the contract should forward the value to the extension or not
|
|
865
|
+
if (extensionData.length == 21) {
|
|
866
|
+
// If the last byte is set to `0x01` (`true`)
|
|
867
|
+
// this indicates that the contract should forward the value to the extension
|
|
868
|
+
if (extensionData[20] == 0x01) {
|
|
869
|
+
// Return the address of the extension
|
|
870
|
+
return (address(bytes20(extensionData)), true);
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
return (address(bytes20(extensionData)), false);
|
|
809
875
|
}
|
|
810
876
|
|
|
811
877
|
/**
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
pragma solidity ^0.8.4;
|
|
3
3
|
|
|
4
4
|
// modules
|
|
5
|
+
import {Version} from "../Version.sol";
|
|
5
6
|
import {
|
|
6
7
|
LSP0ERC725AccountInitAbstract
|
|
7
8
|
} from "./LSP0ERC725AccountInitAbstract.sol";
|
|
@@ -21,7 +22,7 @@ import {
|
|
|
21
22
|
* - Extending the account with new functions and interfaceIds of future standards using [LSP-17-ContractExtension]
|
|
22
23
|
* - Verifying calls on the owner to make it easier to interact with the account directly using [LSP-20-CallVerification]
|
|
23
24
|
*/
|
|
24
|
-
contract LSP0ERC725AccountInit is LSP0ERC725AccountInitAbstract {
|
|
25
|
+
contract LSP0ERC725AccountInit is LSP0ERC725AccountInitAbstract, Version {
|
|
25
26
|
/**
|
|
26
27
|
* @notice deploying a `LSP0ERC725AccountInit` base contract to be used behind proxy
|
|
27
28
|
* @dev Locks the base contract on deployment, so that it cannot be initialized, owned and controlled by anyone after it has been deployed. This is intended so that the sole purpose of this contract is to be used as a base contract behind a proxy.
|
|
@@ -38,7 +39,7 @@ contract LSP0ERC725AccountInit is LSP0ERC725AccountInitAbstract {
|
|
|
38
39
|
* @param initialOwner The owner of the contract.
|
|
39
40
|
*
|
|
40
41
|
* @custom:events
|
|
41
|
-
* - {
|
|
42
|
+
* - {UniversalReceiver} event when funding the contract on deployment.
|
|
42
43
|
* - {OwnershipTransferred} event when `initialOwner` is set as the contract {owner}.
|
|
43
44
|
*/
|
|
44
45
|
function initialize(
|
|
@@ -10,6 +10,9 @@ import {
|
|
|
10
10
|
OwnableUnset
|
|
11
11
|
} from "@erc725/smart-contracts/contracts/custom/OwnableUnset.sol";
|
|
12
12
|
|
|
13
|
+
// constants
|
|
14
|
+
import {_TYPEID_LSP0_VALUE_RECEIVED} from "./LSP0Constants.sol";
|
|
15
|
+
|
|
13
16
|
/**
|
|
14
17
|
* @title Inheritable Proxy Implementation of [LSP-0-ERC725Account] Standard.
|
|
15
18
|
*
|
|
@@ -21,20 +24,28 @@ abstract contract LSP0ERC725AccountInitAbstract is
|
|
|
21
24
|
{
|
|
22
25
|
/**
|
|
23
26
|
* @dev Set `initialOwner` as the contract owner.
|
|
27
|
+
* The `initialOwner` will then be allowed to call protected functions marked with the `onlyOwner` modifier.
|
|
24
28
|
*
|
|
25
29
|
* @param initialOwner The owner of the contract.
|
|
26
30
|
*
|
|
27
|
-
* @custom:warning ERC725X & ERC725Y parent contracts are not
|
|
31
|
+
* @custom:warning ERC725X & ERC725Y parent contracts are not initialixed as they don't have non-zero initial state.
|
|
32
|
+
* If you decide to add non-zero initial state to any of those contracts, you MUST initialize them here.
|
|
28
33
|
*
|
|
29
34
|
* @custom:events
|
|
30
|
-
* - {
|
|
35
|
+
* - {UniversalReceiver} event when funding the contract on deployment.
|
|
31
36
|
* - {OwnershipTransferred} event when `initialOwner` is set as the contract {owner}.
|
|
32
37
|
*/
|
|
33
38
|
function _initialize(
|
|
34
39
|
address initialOwner
|
|
35
40
|
) internal virtual onlyInitializing {
|
|
36
41
|
if (msg.value != 0) {
|
|
37
|
-
emit
|
|
42
|
+
emit UniversalReceiver(
|
|
43
|
+
msg.sender,
|
|
44
|
+
msg.value,
|
|
45
|
+
_TYPEID_LSP0_VALUE_RECEIVED,
|
|
46
|
+
"",
|
|
47
|
+
""
|
|
48
|
+
);
|
|
38
49
|
}
|
|
39
50
|
OwnableUnset._setOwner(initialOwner);
|
|
40
51
|
}
|
|
@@ -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
|
/**
|
|
@@ -44,7 +44,7 @@ abstract contract LSP17Extendable is ERC165 {
|
|
|
44
44
|
function _supportsInterfaceInERC165Extension(
|
|
45
45
|
bytes4 interfaceId
|
|
46
46
|
) internal view virtual returns (bool) {
|
|
47
|
-
address erc165Extension =
|
|
47
|
+
(address erc165Extension, ) = _getExtensionAndForwardValue(
|
|
48
48
|
ERC165.supportsInterface.selector
|
|
49
49
|
);
|
|
50
50
|
if (erc165Extension == address(0)) return false;
|
|
@@ -62,15 +62,16 @@ abstract contract LSP17Extendable is ERC165 {
|
|
|
62
62
|
* To be overrided.
|
|
63
63
|
* Up to the implementor contract to return an extension based on a function selector
|
|
64
64
|
*/
|
|
65
|
-
function
|
|
65
|
+
function _getExtensionAndForwardValue(
|
|
66
66
|
bytes4 functionSelector
|
|
67
|
-
) internal view virtual returns (address);
|
|
67
|
+
) internal view virtual returns (address, bool);
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
70
|
* @dev Forwards the call to an extension mapped to a function selector.
|
|
71
71
|
*
|
|
72
|
-
* Calls {
|
|
72
|
+
* Calls {_getExtensionAndForwardValue} to get the address of the extension mapped to the function selector being
|
|
73
73
|
* called on the account. If there is no extension, the `address(0)` will be returned.
|
|
74
|
+
* Forwards the value if the extension is payable.
|
|
74
75
|
*
|
|
75
76
|
* Reverts if there is no extension for the function being called.
|
|
76
77
|
*
|
|
@@ -90,15 +91,18 @@ abstract contract LSP17Extendable is ERC165 {
|
|
|
90
91
|
bytes calldata callData
|
|
91
92
|
) internal virtual returns (bytes memory) {
|
|
92
93
|
// If there is a function selector
|
|
93
|
-
|
|
94
|
+
(
|
|
95
|
+
address extension,
|
|
96
|
+
bool shouldForwardValue
|
|
97
|
+
) = _getExtensionAndForwardValue(msg.sig);
|
|
94
98
|
|
|
95
99
|
// if no extension was found, revert
|
|
96
100
|
if (extension == address(0))
|
|
97
101
|
revert NoExtensionFoundForFunctionSelector(msg.sig);
|
|
98
102
|
|
|
99
|
-
(bool success, bytes memory result) = extension.call
|
|
100
|
-
|
|
101
|
-
);
|
|
103
|
+
(bool success, bytes memory result) = extension.call{
|
|
104
|
+
value: shouldForwardValue ? msg.value : 0
|
|
105
|
+
}(abi.encodePacked(callData, msg.sender, msg.value));
|
|
102
106
|
|
|
103
107
|
if (success) {
|
|
104
108
|
return result;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
pragma solidity ^0.8.4;
|
|
3
3
|
|
|
4
4
|
// modules
|
|
5
|
+
import {Version} from "../Version.sol";
|
|
5
6
|
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
|
|
6
7
|
|
|
7
8
|
// constants
|
|
@@ -13,7 +14,7 @@ import {_INTERFACEID_LSP17_EXTENSION} from "./LSP17Constants.sol";
|
|
|
13
14
|
* @dev Implementation of the extension logic according to LSP17ContractExtension.
|
|
14
15
|
* This module can be inherited to provide context of the msg variable related to the extendable contract
|
|
15
16
|
*/
|
|
16
|
-
abstract contract LSP17Extension is ERC165 {
|
|
17
|
+
abstract contract LSP17Extension is ERC165, Version {
|
|
17
18
|
/**
|
|
18
19
|
* @dev See {IERC165-supportsInterface}.
|
|
19
20
|
*/
|
|
@@ -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
|
}
|