@lukso/lsp-smart-contracts 0.12.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/README.md +2 -2
  2. package/artifacts/LSP0ERC725Account.json +19 -19
  3. package/artifacts/LSP0ERC725AccountInit.json +19 -19
  4. package/artifacts/LSP11BasicSocialRecovery.json +2 -2
  5. package/artifacts/LSP11BasicSocialRecoveryInit.json +2 -2
  6. package/artifacts/LSP1UniversalReceiverDelegateUP.json +15 -15
  7. package/artifacts/LSP1UniversalReceiverDelegateVault.json +15 -15
  8. package/artifacts/LSP4DigitalAssetMetadata.json +5 -0
  9. package/artifacts/LSP4DigitalAssetMetadataInitAbstract.json +5 -0
  10. package/artifacts/LSP6KeyManager.json +15 -15
  11. package/artifacts/LSP6KeyManagerInit.json +15 -15
  12. package/artifacts/LSP7CappedSupply.json +71 -49
  13. package/artifacts/LSP7CappedSupplyInitAbstract.json +71 -49
  14. package/artifacts/LSP7CompatibleERC20.json +71 -49
  15. package/artifacts/LSP7CompatibleERC20InitAbstract.json +71 -49
  16. package/artifacts/LSP7CompatibleERC20Mintable.json +78 -51
  17. package/artifacts/LSP7CompatibleERC20MintableInit.json +78 -51
  18. package/artifacts/LSP7DigitalAsset.json +71 -49
  19. package/artifacts/LSP7DigitalAssetInitAbstract.json +71 -49
  20. package/artifacts/LSP7Mintable.json +78 -51
  21. package/artifacts/LSP7MintableInit.json +78 -51
  22. package/artifacts/LSP8CappedSupply.json +187 -36
  23. package/artifacts/LSP8CappedSupplyInitAbstract.json +200 -49
  24. package/artifacts/LSP8CompatibleERC721.json +187 -36
  25. package/artifacts/LSP8CompatibleERC721InitAbstract.json +200 -49
  26. package/artifacts/LSP8CompatibleERC721Mintable.json +195 -39
  27. package/artifacts/LSP8CompatibleERC721MintableInit.json +208 -52
  28. package/artifacts/LSP8IdentifiableDigitalAsset.json +187 -36
  29. package/artifacts/LSP8IdentifiableDigitalAssetInitAbstract.json +200 -49
  30. package/artifacts/LSP8Mintable.json +195 -39
  31. package/artifacts/LSP8MintableInit.json +208 -52
  32. package/artifacts/LSP9Vault.json +19 -19
  33. package/artifacts/LSP9VaultInit.json +19 -19
  34. package/artifacts/UniversalProfile.json +19 -19
  35. package/artifacts/UniversalProfileInit.json +19 -19
  36. package/contracts/LSP0ERC725Account/LSP0Constants.sol +1 -1
  37. package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +7 -3
  38. package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +62 -62
  39. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +2 -1
  40. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +3 -1
  41. package/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol +11 -10
  42. package/contracts/LSP17Extensions/Extension4337.sol +26 -1
  43. package/contracts/LSP17Extensions/OnERC721ReceivedExtension.sol +2 -1
  44. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +31 -33
  45. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +24 -17
  46. package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +1 -1
  47. package/contracts/LSP25ExecuteRelayCall/LSP25MultiChannelNonce.sol +1 -5
  48. package/contracts/LSP4DigitalAssetMetadata/LSP4Constants.sol +9 -0
  49. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol +20 -34
  50. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataCore.sol +47 -0
  51. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +19 -31
  52. package/contracts/LSP4DigitalAssetMetadata/LSP4Errors.sol +13 -6
  53. package/contracts/LSP6KeyManager/LSP6KeyManager.sol +2 -1
  54. package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +16 -10
  55. package/contracts/LSP6KeyManager/LSP6KeyManagerInit.sol +2 -1
  56. package/contracts/LSP6KeyManager/LSP6Modules/LSP6ExecuteModule.sol +14 -16
  57. package/contracts/LSP6KeyManager/LSP6Modules/LSP6SetDataModule.sol +6 -2
  58. package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +20 -9
  59. package/contracts/LSP7DigitalAsset/LSP7Constants.sol +1 -1
  60. package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +7 -5
  61. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +129 -36
  62. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +5 -2
  63. package/contracts/LSP7DigitalAsset/LSP7Errors.sol +6 -0
  64. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.sol +4 -2
  65. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20InitAbstract.sol +7 -4
  66. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.sol +4 -2
  67. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInit.sol +5 -2
  68. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInitAbstract.sol +8 -2
  69. package/contracts/LSP7DigitalAsset/presets/LSP7Mintable.sol +12 -1
  70. package/contracts/LSP7DigitalAsset/presets/LSP7MintableInit.sol +4 -0
  71. package/contracts/LSP7DigitalAsset/presets/LSP7MintableInitAbstract.sol +4 -0
  72. package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +77 -4
  73. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol +15 -12
  74. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol +19 -3
  75. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +25 -16
  76. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +222 -28
  77. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +28 -15
  78. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +16 -8
  79. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +9 -8
  80. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.sol +13 -2
  81. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInit.sol +6 -2
  82. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInitAbstract.sol +4 -2
  83. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.sol +13 -2
  84. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInit.sol +6 -2
  85. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +6 -2
  86. package/contracts/LSP9Vault/LSP9Constants.sol +1 -1
  87. package/contracts/LSP9Vault/LSP9Vault.sol +3 -2
  88. package/contracts/LSP9Vault/LSP9VaultCore.sol +22 -37
  89. package/contracts/LSP9Vault/LSP9VaultInit.sol +2 -1
  90. package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +1 -1
  91. package/contracts/UniversalProfile.sol +4 -2
  92. package/contracts/UniversalProfileInit.sol +8 -5
  93. package/contracts/UniversalProfileInitAbstract.sol +4 -2
  94. package/contracts/Version.sol +6 -5
  95. package/devdocs/LSP0ERC725Account.json +3 -8
  96. package/devdocs/LSP0ERC725AccountInit.json +2 -7
  97. package/devdocs/LSP1UniversalReceiverDelegateUP.json +0 -6
  98. package/devdocs/LSP1UniversalReceiverDelegateVault.json +0 -6
  99. package/devdocs/LSP4DigitalAssetMetadata.json +11 -5
  100. package/devdocs/LSP4DigitalAssetMetadataInitAbstract.json +7 -2
  101. package/devdocs/LSP6KeyManager.json +2 -7
  102. package/devdocs/LSP6KeyManagerInit.json +2 -7
  103. package/devdocs/LSP7CappedSupply.json +22 -8
  104. package/devdocs/LSP7CappedSupplyInitAbstract.json +22 -8
  105. package/devdocs/LSP7CompatibleERC20.json +23 -8
  106. package/devdocs/LSP7CompatibleERC20InitAbstract.json +22 -8
  107. package/devdocs/LSP7CompatibleERC20Mintable.json +23 -8
  108. package/devdocs/LSP7CompatibleERC20MintableInit.json +24 -9
  109. package/devdocs/LSP7DigitalAsset.json +27 -12
  110. package/devdocs/LSP7DigitalAssetInitAbstract.json +22 -8
  111. package/devdocs/LSP7Mintable.json +24 -8
  112. package/devdocs/LSP7MintableInit.json +25 -9
  113. package/devdocs/LSP8CappedSupply.json +66 -10
  114. package/devdocs/LSP8CappedSupplyInitAbstract.json +66 -10
  115. package/devdocs/LSP8CompatibleERC721.json +69 -11
  116. package/devdocs/LSP8CompatibleERC721InitAbstract.json +67 -11
  117. package/devdocs/LSP8CompatibleERC721Mintable.json +69 -11
  118. package/devdocs/LSP8CompatibleERC721MintableInit.json +70 -12
  119. package/devdocs/LSP8IdentifiableDigitalAsset.json +71 -14
  120. package/devdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +66 -10
  121. package/devdocs/LSP8Mintable.json +68 -10
  122. package/devdocs/LSP8MintableInit.json +69 -11
  123. package/devdocs/LSP9Vault.json +0 -6
  124. package/devdocs/LSP9VaultInit.json +0 -6
  125. package/devdocs/UniversalProfile.json +3 -8
  126. package/devdocs/UniversalProfileInit.json +4 -9
  127. package/dist/constants.cjs.js +4552 -1859
  128. package/dist/constants.d.ts +4143 -1371
  129. package/dist/constants.es.js +4551 -1859
  130. package/package.json +2 -2
  131. package/userdocs/LSP0ERC725Account.json +3 -3
  132. package/userdocs/LSP0ERC725AccountInit.json +3 -3
  133. package/userdocs/LSP1UniversalReceiverDelegateUP.json +3 -3
  134. package/userdocs/LSP1UniversalReceiverDelegateVault.json +3 -3
  135. package/userdocs/LSP6KeyManager.json +3 -3
  136. package/userdocs/LSP6KeyManagerInit.json +3 -3
  137. package/userdocs/LSP7CappedSupply.json +8 -3
  138. package/userdocs/LSP7CappedSupplyInitAbstract.json +8 -3
  139. package/userdocs/LSP7CompatibleERC20.json +8 -3
  140. package/userdocs/LSP7CompatibleERC20InitAbstract.json +8 -3
  141. package/userdocs/LSP7CompatibleERC20Mintable.json +8 -3
  142. package/userdocs/LSP7CompatibleERC20MintableInit.json +9 -4
  143. package/userdocs/LSP7DigitalAsset.json +8 -3
  144. package/userdocs/LSP7DigitalAssetInitAbstract.json +8 -3
  145. package/userdocs/LSP7Mintable.json +8 -3
  146. package/userdocs/LSP7MintableInit.json +9 -4
  147. package/userdocs/LSP8CappedSupply.json +20 -3
  148. package/userdocs/LSP8CappedSupplyInitAbstract.json +20 -3
  149. package/userdocs/LSP8CompatibleERC721.json +20 -3
  150. package/userdocs/LSP8CompatibleERC721InitAbstract.json +20 -3
  151. package/userdocs/LSP8CompatibleERC721Mintable.json +20 -3
  152. package/userdocs/LSP8CompatibleERC721MintableInit.json +21 -4
  153. package/userdocs/LSP8IdentifiableDigitalAsset.json +20 -3
  154. package/userdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +19 -2
  155. package/userdocs/LSP8Mintable.json +19 -2
  156. package/userdocs/LSP8MintableInit.json +20 -3
  157. package/userdocs/LSP9Vault.json +3 -3
  158. package/userdocs/LSP9VaultInit.json +3 -3
  159. package/userdocs/UniversalProfile.json +3 -3
  160. package/userdocs/UniversalProfileInit.json +3 -3
@@ -13,7 +13,6 @@ import {
13
13
  } from "../LSP1UniversalReceiver/ILSP1UniversalReceiverDelegate.sol";
14
14
 
15
15
  // libraries
16
- import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol";
17
16
  import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
18
17
  import {
19
18
  ERC165Checker
@@ -23,7 +22,6 @@ import {LSP1Utils} from "../LSP1UniversalReceiver/LSP1Utils.sol";
23
22
  import {LSP2Utils} from "../LSP2ERC725YJSONSchema/LSP2Utils.sol";
24
23
 
25
24
  // modules
26
- import {Version} from "../Version.sol";
27
25
  import {ERC725YCore} from "@erc725/smart-contracts/contracts/ERC725YCore.sol";
28
26
  import {ERC725XCore} from "@erc725/smart-contracts/contracts/ERC725XCore.sol";
29
27
  import {
@@ -78,7 +76,6 @@ import {
78
76
  abstract contract LSP0ERC725AccountCore is
79
77
  ERC725XCore,
80
78
  ERC725YCore,
81
- Version,
82
79
  IERC1271,
83
80
  ILSP0ERC725Account,
84
81
  ILSP1UniversalReceiver,
@@ -95,7 +92,10 @@ abstract contract LSP0ERC725AccountCore is
95
92
  * - When receiving some native tokens without any additional data.
96
93
  * - On empty calls to the contract.
97
94
  *
98
- * @custom:events {UniversalReceiver} event when receiving native tokens.
95
+ * @custom:info This function internally delegates the handling of native tokens to the {universalReceiver} function
96
+ * passing `_TYPEID_LSP0_VALUE_RECEIVED` as typeId and an empty bytes array as received data.
97
+ *
98
+ * @custom:events Emits a {UniversalReceiver} event when the `universalReceiver` logic is executed upon receiving native tokens.
99
99
  */
100
100
  receive() external payable virtual {
101
101
  if (msg.value != 0) {
@@ -122,6 +122,9 @@ abstract contract LSP0ERC725AccountCore is
122
122
  *
123
123
  * 2. If the data sent to this function is of length less than 4 bytes (not a function selector), return.
124
124
  *
125
+ * @custom:info Whenever the call is associated with native tokens, the function will delegate the handling of native tokens internally to the {universalReceiver} function
126
+ * 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.
127
+ *
125
128
  * @custom:events {UniversalReceiver} event when receiving native tokens and extension function selector is not found or not payable.
126
129
  */
127
130
  // solhint-disable-next-line no-complex-fallback
@@ -130,8 +133,9 @@ abstract contract LSP0ERC725AccountCore is
130
133
  ) external payable virtual returns (bytes memory) {
131
134
  if (msg.data.length < 4) {
132
135
  // if value is associated with the extension call, use the universalReceiver
133
- if (msg.value != 0)
136
+ if (msg.value != 0) {
134
137
  universalReceiver(_TYPEID_LSP0_VALUE_RECEIVED, callData);
138
+ }
135
139
  return "";
136
140
  }
137
141
 
@@ -434,6 +438,8 @@ abstract contract LSP0ERC725AccountCore is
434
438
  *
435
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.
436
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
+ *
437
443
  * @param typeId The type of call received.
438
444
  * @param receivedData The data received.
439
445
  *
@@ -541,9 +547,9 @@ abstract contract LSP0ERC725AccountCore is
541
547
  emit OwnershipTransferStarted(currentOwner, pendingNewOwner);
542
548
 
543
549
  // notify the pending owner through LSP1
544
- pendingNewOwner.tryNotifyUniversalReceiver(
550
+ pendingNewOwner.notifyUniversalReceiver(
545
551
  _TYPEID_LSP0_OwnershipTransferStarted,
546
- ""
552
+ abi.encode(currentOwner, pendingNewOwner)
547
553
  );
548
554
 
549
555
  // reset the transfer ownership lock
@@ -561,9 +567,9 @@ abstract contract LSP0ERC725AccountCore is
561
567
  emit OwnershipTransferStarted(currentOwner, pendingNewOwner);
562
568
 
563
569
  // notify the pending owner through LSP1
564
- pendingNewOwner.tryNotifyUniversalReceiver(
570
+ pendingNewOwner.notifyUniversalReceiver(
565
571
  _TYPEID_LSP0_OwnershipTransferStarted,
566
- ""
572
+ abi.encode(currentOwner, pendingNewOwner)
567
573
  );
568
574
 
569
575
  // reset the transfer ownership lock
@@ -585,7 +591,7 @@ abstract contract LSP0ERC725AccountCore is
585
591
  * - When notifying the previous owner via LSP1, the typeId used must be the `keccak256(...)` hash of [LSP0OwnershipTransferred_SenderNotification].
586
592
  * - When notifying the new owner via LSP1, the typeId used must be the `keccak256(...)` hash of [LSP0OwnershipTransferred_RecipientNotification].
587
593
  */
588
- function acceptOwnership() public virtual override NotInTransferOwnership {
594
+ function acceptOwnership() public virtual override notInTransferOwnership {
589
595
  address previousOwner = owner();
590
596
  address pendingOwnerAddress = pendingOwner();
591
597
 
@@ -598,20 +604,21 @@ abstract contract LSP0ERC725AccountCore is
598
604
 
599
605
  _setOwner(pendingOwnerAddress);
600
606
  delete _pendingOwner;
607
+ delete _renounceOwnershipStartedAt;
601
608
  } else {
602
609
  _acceptOwnership();
603
610
  }
604
611
 
605
612
  // notify the previous owner if supports LSP1
606
- previousOwner.tryNotifyUniversalReceiver(
613
+ previousOwner.notifyUniversalReceiver(
607
614
  _TYPEID_LSP0_OwnershipTransferred_SenderNotification,
608
- ""
615
+ abi.encode(previousOwner, pendingOwnerAddress)
609
616
  );
610
617
 
611
618
  // notify the pending owner if supports LSP1
612
- pendingOwnerAddress.tryNotifyUniversalReceiver(
619
+ pendingOwnerAddress.notifyUniversalReceiver(
613
620
  _TYPEID_LSP0_OwnershipTransferred_RecipientNotification,
614
- ""
621
+ abi.encode(previousOwner, pendingOwnerAddress)
615
622
  );
616
623
 
617
624
  // If msg.sender != pendingOwnerAddress & verifyAfter is true, Call {lsp20VerifyCallResult} on the new owner
@@ -638,27 +645,35 @@ abstract contract LSP0ERC725AccountCore is
638
645
 
639
646
  // If the caller is the owner perform renounceOwnership directly
640
647
  if (msg.sender == accountOwner) {
641
- return LSP14Ownable2Step._renounceOwnership();
642
- }
648
+ address previousOwner = owner();
649
+ LSP14Ownable2Step._renounceOwnership();
643
650
 
644
- // If the caller is not the owner, call {lsp20VerifyCall} on the owner
645
- // Depending on the returnedStatus, a second call is done after transferring ownership
646
- bool verifyAfter = _verifyCall(accountOwner);
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);
647
661
 
648
- address previousOwner = owner();
649
- LSP14Ownable2Step._renounceOwnership();
662
+ address previousOwner = owner();
663
+ LSP14Ownable2Step._renounceOwnership();
650
664
 
651
- if (owner() == address(0)) {
652
- previousOwner.tryNotifyUniversalReceiver(
653
- _TYPEID_LSP0_OwnershipTransferred_SenderNotification,
654
- ""
655
- );
656
- }
665
+ if (owner() == address(0)) {
666
+ previousOwner.notifyUniversalReceiver(
667
+ _TYPEID_LSP0_OwnershipTransferred_SenderNotification,
668
+ abi.encode(accountOwner, address(0))
669
+ );
670
+ }
657
671
 
658
- // If verifyAfter is true, Call {lsp20VerifyCallResult} on the owner
659
- // The transferOwnership function does not return, second parameter of {_verifyCallResult} will be empty
660
- if (verifyAfter) {
661
- _verifyCallResult(accountOwner, "");
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
+ }
662
677
  }
663
678
  }
664
679
 
@@ -717,6 +732,11 @@ abstract contract LSP0ERC725AccountCore is
717
732
  * @param signature A signature that can validate the previous parameter (Hash).
718
733
  *
719
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.
720
740
  */
721
741
  function isValidSignature(
722
742
  bytes32 dataHash,
@@ -775,14 +795,7 @@ abstract contract LSP0ERC725AccountCore is
775
795
  * If there is an extension for the function selector being called, it calls the extension with the
776
796
  * `CALL` opcode, passing the `msg.data` appended with the 20 bytes of the {msg.sender} and 32 bytes of the `msg.value`.
777
797
  *
778
- * @custom:hint This function does not forward to the extension contract the `msg.value` received by the contract that inherits `LSP17Extendable`.
779
- * If you would like to forward the `msg.value` to the extension contract, you can override the code of this internal function as follow:
780
- *
781
- * ```solidity
782
- * (bool success, bytes memory result) = extension.call{value: msg.value}(
783
- * abi.encodePacked(callData, msg.sender, msg.value)
784
- * );
785
- * ```
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.
786
799
  */
787
800
  function _fallbackLSP17Extendable(
788
801
  bytes calldata callData
@@ -794,8 +807,9 @@ abstract contract LSP0ERC725AccountCore is
794
807
  ) = _getExtensionAndForwardValue(msg.sig);
795
808
 
796
809
  // if value is associated with the extension call and extension function selector is not payable, use the universalReceiver
797
- if (msg.value != 0 && !isForwardingValue)
810
+ if (msg.value != 0 && !isForwardingValue) {
798
811
  universalReceiver(_TYPEID_LSP0_VALUE_RECEIVED, callData);
812
+ }
799
813
 
800
814
  // if no extension was found for bytes4(0) return don't revert
801
815
  if (msg.sig == bytes4(0) && extension == address(0)) return "";
@@ -821,9 +835,10 @@ abstract contract LSP0ERC725AccountCore is
821
835
  }
822
836
 
823
837
  /**
824
- * @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:
825
839
  * - {_LSP17_EXTENSION_PREFIX} + `<bytes4>` (Check [LSP2-ERC725YJSONSchema] for encoding the data key).
826
840
  * - If no extension is stored, returns the address(0).
841
+ * - If the stored value is 20 bytes, return false for the boolean
827
842
  */
828
843
  function _getExtensionAndForwardValue(
829
844
  bytes4 functionSelector
@@ -838,6 +853,12 @@ abstract contract LSP0ERC725AccountCore is
838
853
  mappedExtensionDataKey
839
854
  );
840
855
 
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
+
841
862
  // CHECK if the `extensionData` is 21 bytes long
842
863
  // - 20 bytes = extension's address
843
864
  // - 1 byte `0x01` as a boolean indicating if the contract should forward the value to the extension or not
@@ -852,25 +873,4 @@ abstract contract LSP0ERC725AccountCore is
852
873
 
853
874
  return (address(bytes20(extensionData)), false);
854
875
  }
855
-
856
- /**
857
- * @dev This function overrides the {ERC725YCore} internal {_setData} function to optimize gas usage by emitting only the first 256 bytes of the `dataValue`.
858
- *
859
- * @custom:events {DataChanged} event with only the first 256 bytes of {dataValue}.
860
- *
861
- * @param dataKey The key to store the data value under.
862
- * @param dataValue The data value to be stored.
863
- */
864
- function _setData(
865
- bytes32 dataKey,
866
- bytes memory dataValue
867
- ) internal virtual override {
868
- ERC725YCore._store[dataKey] = dataValue;
869
- emit DataChanged(
870
- dataKey,
871
- dataValue.length <= 256
872
- ? dataValue
873
- : BytesLib.slice(dataValue, 0, 256)
874
- );
875
- }
876
876
  }
@@ -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.
@@ -24,10 +24,12 @@ abstract contract LSP0ERC725AccountInitAbstract is
24
24
  {
25
25
  /**
26
26
  * @dev Set `initialOwner` as the contract owner.
27
+ * The `initialOwner` will then be allowed to call protected functions marked with the `onlyOwner` modifier.
27
28
  *
28
29
  * @param initialOwner The owner of the contract.
29
30
  *
30
- * @custom:warning ERC725X & ERC725Y parent contracts are not initialised as they don't have non-zero initial state. If you decide to add non-zero initial state to any of those contracts, you must initialize them here.
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.
31
33
  *
32
34
  * @custom:events
33
35
  * - {UniversalReceiver} event when funding the contract on deployment.
@@ -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 NotInTransferOwnership() virtual {
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.tryNotifyUniversalReceiver(
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 NotInTransferOwnership {
114
+ function acceptOwnership() public virtual override notInTransferOwnership {
115
115
  address previousOwner = owner();
116
116
 
117
117
  _acceptOwnership();
118
118
 
119
- previousOwner.tryNotifyUniversalReceiver(
119
+ previousOwner.notifyUniversalReceiver(
120
120
  _TYPEID_LSP14_OwnershipTransferred_SenderNotification,
121
- ""
121
+ abi.encode(previousOwner, msg.sender)
122
122
  );
123
123
 
124
- msg.sender.tryNotifyUniversalReceiver(
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.tryNotifyUniversalReceiver(
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
  /**
@@ -41,7 +41,32 @@ contract Extension4337 is LSP17Extension, IAccount {
41
41
  }
42
42
 
43
43
  /**
44
- * @inheritdoc IAccount
44
+ * @dev Validate user's signature and nonce.
45
+ * The entryPoint will make the call to the recipient only if this validation call returns successfully.
46
+ * Signature failure should be reported by returning `SIG_VALIDATION_FAILED` (`1`).
47
+ * This allows making a "simulation call" without a valid signature.
48
+ * Other failures (_e.g. nonce mismatch, or invalid signature format_) should still revert to signal failure.
49
+ *
50
+ * The third parameter (not mentioned but `missingAccountFunds` from the `IAccount` interface)
51
+ * describes the missing funds on the account's deposit in the entrypoint.
52
+ * This is the minimum amount to transfer to the sender(entryPoint) to be able to make the call.
53
+ * The excess is left as a deposit in the entrypoint, for future calls. Can be withdrawn anytime using "entryPoint.withdrawTo()"
54
+ * In case there is a paymaster in the request (or the current deposit is high enough), this value will be zero.
55
+ *
56
+ * @return validationData packaged ValidationData structure. use `_packValidationData` and `_unpackValidationData` to encode and decode
57
+ * - `<20-byte>` sigAuthorizer - 0 for valid signature, 1 to mark signature failure, otherwise, an address of an "authorizer" contract.
58
+ * - `<6-byte>` validUntil - last timestamp this operation is valid. 0 for "indefinite"
59
+ * - `<6-byte>` validAfter - first timestamp this operation is valid
60
+ * If an account doesn't use time-range, it is enough to return SIG_VALIDATION_FAILED value (1) for signature failure.
61
+ * Note that the validation code cannot use block.timestamp (or block.number) directly.
62
+ *
63
+ * @custom:info In addition to the logic of the `IAccount` interface from 4337, the permissions of the address that signed the user operation
64
+ * are checked to ensure that it has the permission `_4337_PERMISSION`.
65
+ *
66
+ * @custom:requirements
67
+ * - caller MUST be the **entrypoint contract**.
68
+ * - the signature and nonce must be valid.
69
+ *
45
70
  */
46
71
  function validateUserOp(
47
72
  UserOperation calldata userOp,
@@ -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(address notifier) internal returns (bytes memory) {
127
- // The notifier is supposed to be either the LSP7 or LSP8 or LSP9 contract
128
- // If it's EOA we revert (spam protection)
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(address notifier) internal returns (bytes memory) {
217
- // The notifier is supposed to be either the LSP7 or LSP8 or LSP9 contract
218
- // If it's EOA we revert (spam protection)
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(address notifier) internal returns (bytes memory) {
247
- // The notifier is supposed to be either the LSP7 or LSP8 or LSP9 contract
248
- // If it's EOA we revert to avoid registering the EOA as asset or vault (spam protection)
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(address notifier) internal returns (bytes memory) {
103
- // The notifier is supposed to be either the LSP7 or LSP8 contract
104
- // If it's EOA we revert to avoid registering the EOA as asset (spam protection)
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 tryNotifyUniversalReceiver(
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
- uint256 mask = ~uint128(0);
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
  }
@@ -1,6 +1,12 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.4;
3
3
 
4
+ // Token types
5
+
6
+ uint256 constant _LSP4_TOKEN_TYPE_TOKEN = 0;
7
+ uint256 constant _LSP4_TOKEN_TYPE_NFT = 1;
8
+ uint256 constant _LSP4_TOKEN_TYPE_COLLECTION = 2;
9
+
4
10
  // --- ERC725Y entries
5
11
 
6
12
  // bytes10(keccak256('SupportedStandards')) + bytes2(0) + bytes20(keccak256('LSP4DigitalAsset'))
@@ -15,6 +21,9 @@ bytes32 constant _LSP4_TOKEN_NAME_KEY = 0xdeba1e292f8ba88238e10ab3c7f88bd4be4fac
15
21
  // keccak256('LSP4TokenSymbol')
16
22
  bytes32 constant _LSP4_TOKEN_SYMBOL_KEY = 0x2f0a68ab07768e01943a599e73362a0e17a63a72e94dd2e384d2c1d4db932756;
17
23
 
24
+ // keccak256('LSP4TokenType')
25
+ bytes32 constant _LSP4_TOKEN_TYPE_KEY = 0xe0261fa95db2eb3b5439bd033cda66d56b96f92f243a8228fd87550ed7bdfdb3;
26
+
18
27
  // keccak256('LSP4Creators[]')
19
28
  bytes32 constant _LSP4_CREATORS_ARRAY_KEY = 0x114bd03b3a46d48759680d81ebb2b414fda7d030a7105a851867accf1c2352e7;
20
29