@lukso/lsp-smart-contracts 0.11.1 → 0.12.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 (224) hide show
  1. package/README.md +10 -2
  2. package/artifacts/Create2Factory.json +2 -2
  3. package/artifacts/LSP0ERC725Account.json +68 -47
  4. package/artifacts/LSP0ERC725AccountInit.json +68 -47
  5. package/artifacts/LSP11BasicSocialRecovery.json +18 -2
  6. package/artifacts/LSP11BasicSocialRecoveryInit.json +18 -2
  7. package/artifacts/LSP16UniversalFactory.json +3 -3
  8. package/artifacts/LSP1UniversalReceiverDelegateUP.json +27 -46
  9. package/artifacts/LSP1UniversalReceiverDelegateVault.json +27 -46
  10. package/artifacts/LSP23LinkedContractsFactory.json +3 -3
  11. package/artifacts/LSP4DigitalAssetMetadata.json +16 -0
  12. package/artifacts/LSP4DigitalAssetMetadataInitAbstract.json +16 -0
  13. package/artifacts/LSP6KeyManager.json +34 -6
  14. package/artifacts/LSP6KeyManagerInit.json +34 -6
  15. package/artifacts/LSP7CappedSupply.json +64 -4
  16. package/artifacts/LSP7CappedSupplyInitAbstract.json +64 -4
  17. package/artifacts/LSP7CompatibleERC20.json +83 -23
  18. package/artifacts/LSP7CompatibleERC20InitAbstract.json +83 -23
  19. package/artifacts/LSP7CompatibleERC20Mintable.json +86 -26
  20. package/artifacts/LSP7CompatibleERC20MintableInit.json +86 -26
  21. package/artifacts/LSP7DigitalAsset.json +64 -4
  22. package/artifacts/LSP7DigitalAssetInitAbstract.json +64 -4
  23. package/artifacts/LSP7Mintable.json +67 -7
  24. package/artifacts/LSP7MintableInit.json +67 -7
  25. package/artifacts/LSP8CappedSupply.json +57 -3
  26. package/artifacts/LSP8CappedSupplyInitAbstract.json +57 -3
  27. package/artifacts/LSP8CompatibleERC721.json +79 -25
  28. package/artifacts/LSP8CompatibleERC721InitAbstract.json +79 -25
  29. package/artifacts/LSP8CompatibleERC721Mintable.json +87 -28
  30. package/artifacts/LSP8CompatibleERC721MintableInit.json +87 -28
  31. package/artifacts/LSP8IdentifiableDigitalAsset.json +57 -3
  32. package/artifacts/LSP8IdentifiableDigitalAssetInitAbstract.json +57 -3
  33. package/artifacts/LSP8Mintable.json +65 -6
  34. package/artifacts/LSP8MintableInit.json +65 -6
  35. package/artifacts/LSP9Vault.json +51 -35
  36. package/artifacts/LSP9VaultInit.json +51 -35
  37. package/artifacts/UniversalProfile.json +68 -47
  38. package/artifacts/UniversalProfileInit.json +68 -47
  39. package/contracts/Factories/Create2Factory.sol +1 -1
  40. package/contracts/LSP0ERC725Account/ILSP0ERC725Account.sol +0 -22
  41. package/contracts/LSP0ERC725Account/LSP0Constants.sol +6 -1
  42. package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +12 -2
  43. package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +196 -123
  44. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +1 -1
  45. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +11 -2
  46. package/contracts/LSP10ReceivedVaults/LSP10Utils.sol +5 -3
  47. package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryCore.sol +54 -14
  48. package/contracts/LSP11BasicSocialRecovery/LSP11Constants.sol +1 -1
  49. package/contracts/LSP11BasicSocialRecovery/LSP11Errors.sol +1 -1
  50. package/contracts/LSP14Ownable2Step/ILSP14Ownable2Step.sol +2 -2
  51. package/contracts/LSP14Ownable2Step/LSP14Constants.sol +1 -1
  52. package/contracts/LSP14Ownable2Step/LSP14Errors.sol +9 -3
  53. package/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol +16 -12
  54. package/contracts/LSP16UniversalFactory/LSP16UniversalFactory.sol +65 -96
  55. package/contracts/LSP17ContractExtension/LSP17Errors.sol +1 -1
  56. package/contracts/LSP17ContractExtension/LSP17Extendable.sol +22 -15
  57. package/contracts/LSP17ContractExtension/LSP17Extension.sol +6 -5
  58. package/contracts/LSP17Extensions/Extension4337.sol +101 -0
  59. package/contracts/LSP17Extensions/OnERC721ReceivedExtension.sol +15 -0
  60. package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiver.sol +1 -2
  61. package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiverDelegate.sol +24 -0
  62. package/contracts/LSP1UniversalReceiver/LSP1Constants.sol +1 -0
  63. package/contracts/LSP1UniversalReceiver/LSP1Errors.sol +0 -6
  64. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +49 -33
  65. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +33 -27
  66. package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +5 -48
  67. package/contracts/LSP20CallVerification/ILSP20CallVerifier.sol +13 -9
  68. package/contracts/LSP20CallVerification/LSP20CallVerification.sol +64 -45
  69. package/contracts/LSP20CallVerification/LSP20Constants.sol +6 -6
  70. package/contracts/LSP20CallVerification/LSP20Errors.sol +10 -4
  71. package/contracts/{LSP23LinkedContractsDeployment → LSP23LinkedContractsFactory}/ILSP23LinkedContractsFactory.sol +1 -1
  72. package/contracts/{LSP23LinkedContractsDeployment → LSP23LinkedContractsFactory}/IPostDeploymentModule.sol +1 -1
  73. package/contracts/{LSP23LinkedContractsDeployment → LSP23LinkedContractsFactory}/LSP23Errors.sol +1 -1
  74. package/contracts/{LSP23LinkedContractsDeployment → LSP23LinkedContractsFactory}/LSP23LinkedContractsFactory.sol +5 -1
  75. package/contracts/{LSP23LinkedContractsDeployment → LSP23LinkedContractsFactory}/modules/UniversalProfileInitPostDeploymentModule.sol +1 -1
  76. package/contracts/{LSP23LinkedContractsDeployment → LSP23LinkedContractsFactory}/modules/UniversalProfilePostDeploymentModule.sol +1 -1
  77. package/contracts/LSP25ExecuteRelayCall/LSP25Constants.sol +1 -1
  78. package/contracts/LSP25ExecuteRelayCall/LSP25MultiChannelNonce.sol +8 -3
  79. package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +1 -97
  80. package/contracts/LSP3ProfileMetadata/LSP3Constants.sol +1 -1
  81. package/contracts/LSP4DigitalAssetMetadata/LSP4Constants.sol +1 -1
  82. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol +8 -3
  83. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +8 -3
  84. package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +4 -3
  85. package/contracts/LSP6KeyManager/LSP6Constants.sol +4 -3
  86. package/contracts/LSP6KeyManager/LSP6Errors.sol +2 -23
  87. package/contracts/LSP6KeyManager/LSP6KeyManager.sol +0 -1
  88. package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +176 -101
  89. package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +0 -1
  90. package/contracts/LSP6KeyManager/LSP6Modules/LSP6ExecuteModule.sol +1 -2
  91. package/contracts/LSP6KeyManager/LSP6Modules/LSP6ExecuteRelayCallModule.sol +27 -0
  92. package/contracts/LSP6KeyManager/LSP6Modules/LSP6SetDataModule.sol +34 -28
  93. package/contracts/LSP6KeyManager/LSP6Utils.sol +29 -2
  94. package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +70 -10
  95. package/contracts/LSP7DigitalAsset/LSP7Constants.sol +2 -2
  96. package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +29 -13
  97. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +273 -265
  98. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +28 -12
  99. package/contracts/LSP7DigitalAsset/LSP7Errors.sol +17 -3
  100. package/contracts/LSP7DigitalAsset/extensions/LSP7Burnable.sol +5 -1
  101. package/contracts/LSP7DigitalAsset/extensions/LSP7BurnableInitAbstract.sol +4 -1
  102. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupply.sol +7 -7
  103. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInitAbstract.sol +3 -3
  104. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.sol +128 -54
  105. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20InitAbstract.sol +129 -54
  106. package/contracts/LSP7DigitalAsset/presets/ILSP7Mintable.sol +3 -3
  107. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.sol +4 -4
  108. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInit.sol +2 -2
  109. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInitAbstract.sol +4 -4
  110. package/contracts/LSP7DigitalAsset/presets/LSP7Mintable.sol +4 -4
  111. package/contracts/LSP7DigitalAsset/presets/LSP7MintableInit.sol +1 -1
  112. package/contracts/LSP7DigitalAsset/presets/LSP7MintableInitAbstract.sol +4 -4
  113. package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +16 -11
  114. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol +20 -6
  115. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol +32 -16
  116. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +67 -16
  117. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +143 -137
  118. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +69 -15
  119. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Burnable.sol +1 -1
  120. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8BurnableInitAbstract.sol +1 -1
  121. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.sol +7 -7
  122. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInitAbstract.sol +3 -3
  123. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +172 -80
  124. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +178 -91
  125. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.sol +7 -7
  126. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableInitAbstract.sol +7 -7
  127. package/contracts/LSP8IdentifiableDigitalAsset/presets/ILSP8Mintable.sol +3 -3
  128. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.sol +8 -7
  129. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInit.sol +5 -3
  130. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInitAbstract.sol +13 -7
  131. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.sol +9 -8
  132. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInit.sol +9 -3
  133. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +10 -8
  134. package/contracts/LSP9Vault/ILSP9Vault.sol +0 -21
  135. package/contracts/LSP9Vault/LSP9Constants.sol +6 -1
  136. package/contracts/LSP9Vault/LSP9Errors.sol +1 -1
  137. package/contracts/LSP9Vault/LSP9Vault.sol +11 -2
  138. package/contracts/LSP9Vault/LSP9VaultCore.sol +119 -66
  139. package/contracts/LSP9Vault/LSP9VaultInit.sol +1 -1
  140. package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +11 -2
  141. package/contracts/UniversalProfile.sol +1 -1
  142. package/contracts/UniversalProfileInit.sol +1 -1
  143. package/contracts/UniversalProfileInitAbstract.sol +1 -1
  144. package/contracts/Version.sol +16 -0
  145. package/devdocs/LSP0ERC725Account.json +86 -52
  146. package/devdocs/LSP0ERC725AccountInit.json +86 -52
  147. package/devdocs/LSP11BasicSocialRecovery.json +13 -0
  148. package/devdocs/LSP11BasicSocialRecoveryInit.json +13 -0
  149. package/devdocs/LSP16UniversalFactory.json +9 -9
  150. package/devdocs/LSP1UniversalReceiverDelegateUP.json +7 -6
  151. package/devdocs/LSP1UniversalReceiverDelegateVault.json +7 -6
  152. package/devdocs/LSP4DigitalAssetMetadata.json +32 -10
  153. package/devdocs/LSP4DigitalAssetMetadataInitAbstract.json +32 -10
  154. package/devdocs/LSP6KeyManager.json +27 -13
  155. package/devdocs/LSP6KeyManagerInit.json +27 -13
  156. package/devdocs/LSP7CappedSupply.json +61 -28
  157. package/devdocs/LSP7CappedSupplyInitAbstract.json +61 -28
  158. package/devdocs/LSP7CompatibleERC20.json +102 -32
  159. package/devdocs/LSP7CompatibleERC20InitAbstract.json +102 -32
  160. package/devdocs/LSP7CompatibleERC20Mintable.json +102 -32
  161. package/devdocs/LSP7CompatibleERC20MintableInit.json +102 -32
  162. package/devdocs/LSP7DigitalAsset.json +61 -28
  163. package/devdocs/LSP7DigitalAssetInitAbstract.json +61 -28
  164. package/devdocs/LSP7Mintable.json +61 -28
  165. package/devdocs/LSP7MintableInit.json +61 -28
  166. package/devdocs/LSP8CappedSupply.json +66 -27
  167. package/devdocs/LSP8CappedSupplyInitAbstract.json +66 -27
  168. package/devdocs/LSP8CompatibleERC721.json +93 -33
  169. package/devdocs/LSP8CompatibleERC721InitAbstract.json +93 -33
  170. package/devdocs/LSP8CompatibleERC721Mintable.json +95 -35
  171. package/devdocs/LSP8CompatibleERC721MintableInit.json +96 -36
  172. package/devdocs/LSP8IdentifiableDigitalAsset.json +70 -28
  173. package/devdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +66 -27
  174. package/devdocs/LSP8Mintable.json +68 -29
  175. package/devdocs/LSP8MintableInit.json +69 -30
  176. package/devdocs/LSP9Vault.json +69 -41
  177. package/devdocs/LSP9VaultInit.json +69 -41
  178. package/devdocs/UniversalProfile.json +86 -52
  179. package/devdocs/UniversalProfileInit.json +86 -52
  180. package/dist/constants.cjs.js +5565 -2846
  181. package/dist/constants.d.ts +3996 -1182
  182. package/dist/constants.es.js +5564 -2846
  183. package/package.json +8 -8
  184. package/userdocs/LSP0ERC725Account.json +20 -11
  185. package/userdocs/LSP0ERC725AccountInit.json +20 -11
  186. package/userdocs/LSP16UniversalFactory.json +26 -1
  187. package/userdocs/LSP1UniversalReceiverDelegateUP.json +4 -11
  188. package/userdocs/LSP1UniversalReceiverDelegateVault.json +4 -11
  189. package/userdocs/LSP4DigitalAssetMetadata.json +7 -4
  190. package/userdocs/LSP4DigitalAssetMetadataInitAbstract.json +7 -4
  191. package/userdocs/LSP6KeyManager.json +3 -5
  192. package/userdocs/LSP6KeyManagerInit.json +3 -5
  193. package/userdocs/LSP7CappedSupply.json +17 -6
  194. package/userdocs/LSP7CappedSupplyInitAbstract.json +16 -5
  195. package/userdocs/LSP7CompatibleERC20.json +18 -5
  196. package/userdocs/LSP7CompatibleERC20InitAbstract.json +18 -5
  197. package/userdocs/LSP7CompatibleERC20Mintable.json +18 -5
  198. package/userdocs/LSP7CompatibleERC20MintableInit.json +18 -5
  199. package/userdocs/LSP7DigitalAsset.json +18 -5
  200. package/userdocs/LSP7DigitalAssetInitAbstract.json +18 -5
  201. package/userdocs/LSP7Mintable.json +18 -5
  202. package/userdocs/LSP7MintableInit.json +18 -5
  203. package/userdocs/LSP8CappedSupply.json +16 -5
  204. package/userdocs/LSP8CappedSupplyInitAbstract.json +15 -4
  205. package/userdocs/LSP8CompatibleERC721.json +30 -17
  206. package/userdocs/LSP8CompatibleERC721InitAbstract.json +30 -17
  207. package/userdocs/LSP8CompatibleERC721Mintable.json +31 -18
  208. package/userdocs/LSP8CompatibleERC721MintableInit.json +32 -19
  209. package/userdocs/LSP8IdentifiableDigitalAsset.json +18 -5
  210. package/userdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +17 -4
  211. package/userdocs/LSP8Mintable.json +18 -5
  212. package/userdocs/LSP8MintableInit.json +19 -6
  213. package/userdocs/LSP9Vault.json +23 -14
  214. package/userdocs/LSP9VaultInit.json +23 -14
  215. package/userdocs/UniversalProfile.json +20 -11
  216. package/userdocs/UniversalProfileInit.json +20 -11
  217. package/CONTRIBUTING.md +0 -184
  218. package/artifacts/LSP4Compatibility.json +0 -216
  219. package/contracts/LSP4DigitalAssetMetadata/ILSP4Compatibility.sol +0 -25
  220. package/contracts/LSP4DigitalAssetMetadata/LSP4Compatibility.sol +0 -38
  221. package/contracts/LSP7DigitalAsset/extensions/ILSP7CompatibleERC20.sol +0 -83
  222. package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CompatibleERC721.sol +0 -175
  223. package/devdocs/LSP4Compatibility.json +0 -79
  224. package/userdocs/LSP4Compatibility.json +0 -20
@@ -8,6 +8,10 @@ import {
8
8
  ILSP1UniversalReceiver
9
9
  } from "../LSP1UniversalReceiver/ILSP1UniversalReceiver.sol";
10
10
 
11
+ import {
12
+ ILSP1UniversalReceiverDelegate as ILSP1Delegate
13
+ } from "../LSP1UniversalReceiver/ILSP1UniversalReceiverDelegate.sol";
14
+
11
15
  // libraries
12
16
  import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol";
13
17
  import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
@@ -19,14 +23,9 @@ import {LSP1Utils} from "../LSP1UniversalReceiver/LSP1Utils.sol";
19
23
  import {LSP2Utils} from "../LSP2ERC725YJSONSchema/LSP2Utils.sol";
20
24
 
21
25
  // modules
22
- import {
23
- ERC725YCore,
24
- IERC725Y
25
- } from "@erc725/smart-contracts/contracts/ERC725YCore.sol";
26
- import {
27
- ERC725XCore,
28
- IERC725X
29
- } from "@erc725/smart-contracts/contracts/ERC725XCore.sol";
26
+ import {Version} from "../Version.sol";
27
+ import {ERC725YCore} from "@erc725/smart-contracts/contracts/ERC725YCore.sol";
28
+ import {ERC725XCore} from "@erc725/smart-contracts/contracts/ERC725XCore.sol";
30
29
  import {
31
30
  OwnableUnset
32
31
  } from "@erc725/smart-contracts/contracts/custom/OwnableUnset.sol";
@@ -37,18 +36,19 @@ import {
37
36
  } from "../LSP20CallVerification/LSP20CallVerification.sol";
38
37
 
39
38
  // constants
40
- import "@erc725/smart-contracts/contracts/constants.sol";
41
39
  import {
42
40
  _INTERFACEID_LSP0,
43
41
  _INTERFACEID_ERC1271,
44
- _ERC1271_MAGICVALUE,
42
+ _ERC1271_SUCCESSVALUE,
45
43
  _ERC1271_FAILVALUE,
44
+ _TYPEID_LSP0_VALUE_RECEIVED,
46
45
  _TYPEID_LSP0_OwnershipTransferStarted,
47
46
  _TYPEID_LSP0_OwnershipTransferred_SenderNotification,
48
47
  _TYPEID_LSP0_OwnershipTransferred_RecipientNotification
49
- } from "../LSP0ERC725Account/LSP0Constants.sol";
48
+ } from "./LSP0Constants.sol";
50
49
  import {
51
50
  _INTERFACEID_LSP1,
51
+ _INTERFACEID_LSP1_DELEGATE,
52
52
  _LSP1_UNIVERSAL_RECEIVER_DELEGATE_PREFIX,
53
53
  _LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY
54
54
  } from "../LSP1UniversalReceiver/LSP1Constants.sol";
@@ -63,16 +63,13 @@ import {
63
63
 
64
64
  // errors
65
65
  import {
66
- ERC725Y_DataKeysValuesLengthMismatch
66
+ ERC725Y_DataKeysValuesLengthMismatch,
67
+ ERC725Y_DataKeysValuesEmptyArray
67
68
  } from "@erc725/smart-contracts/contracts/errors.sol";
68
69
  import {
69
70
  NoExtensionFoundForFunctionSelector
70
71
  } from "../LSP17ContractExtension/LSP17Errors.sol";
71
72
 
72
- import {
73
- LSP14MustAcceptOwnershipInSeparateTransaction
74
- } from "../LSP14Ownable2Step/LSP14Errors.sol";
75
-
76
73
  /**
77
74
  * @title The Core Implementation of [LSP-0-ERC725Account] Standard.
78
75
  *
@@ -81,6 +78,7 @@ import {
81
78
  abstract contract LSP0ERC725AccountCore is
82
79
  ERC725XCore,
83
80
  ERC725YCore,
81
+ Version,
84
82
  IERC1271,
85
83
  ILSP0ERC725Account,
86
84
  ILSP1UniversalReceiver,
@@ -97,16 +95,14 @@ abstract contract LSP0ERC725AccountCore is
97
95
  * - When receiving some native tokens without any additional data.
98
96
  * - On empty calls to the contract.
99
97
  *
100
- * @custom:events {ValueReceived} event when receiving native tokens.
98
+ * @custom:events {UniversalReceiver} event when receiving native tokens.
101
99
  */
102
100
  receive() external payable virtual {
103
101
  if (msg.value != 0) {
104
- emit ValueReceived(msg.sender, msg.value);
102
+ universalReceiver(_TYPEID_LSP0_VALUE_RECEIVED, "");
105
103
  }
106
104
  }
107
105
 
108
- // solhint-disable no-complex-fallback
109
-
110
106
  /**
111
107
  * @notice The `fallback` function was called with the following amount of native tokens: `msg.value`; and the following calldata: `callData`.
112
108
  *
@@ -126,16 +122,16 @@ abstract contract LSP0ERC725AccountCore is
126
122
  *
127
123
  * 2. If the data sent to this function is of length less than 4 bytes (not a function selector), return.
128
124
  *
129
- * @custom:events {ValueReceived} event when receiving native tokens.
125
+ * @custom:events {UniversalReceiver} event when receiving native tokens and extension function selector is not found or not payable.
130
126
  */
127
+ // solhint-disable-next-line no-complex-fallback
131
128
  fallback(
132
129
  bytes calldata callData
133
130
  ) external payable virtual returns (bytes memory) {
134
- if (msg.value != 0) {
135
- emit ValueReceived(msg.sender, msg.value);
136
- }
137
-
138
131
  if (msg.data.length < 4) {
132
+ // if value is associated with the extension call, use the universalReceiver
133
+ if (msg.value != 0)
134
+ universalReceiver(_TYPEID_LSP0_VALUE_RECEIVED, callData);
139
135
  return "";
140
136
  }
141
137
 
@@ -149,7 +145,7 @@ abstract contract LSP0ERC725AccountCore is
149
145
  */
150
146
  function batchCalls(
151
147
  bytes[] calldata data
152
- ) public virtual returns (bytes[] memory results) {
148
+ ) public virtual override returns (bytes[] memory results) {
153
149
  results = new bytes[](data.length);
154
150
  for (uint256 i; i < data.length; ) {
155
151
  (bool success, bytes memory result) = address(this).delegatecall(
@@ -158,7 +154,7 @@ abstract contract LSP0ERC725AccountCore is
158
154
 
159
155
  if (!success) {
160
156
  // Look for revert reason and bubble it up if present
161
- if (result.length > 0) {
157
+ if (result.length != 0) {
162
158
  // The easiest way to bubble the revert reason is using memory via assembly
163
159
  // solhint-disable no-inline-assembly
164
160
  /// @solidity memory-safe-assembly
@@ -180,7 +176,7 @@ abstract contract LSP0ERC725AccountCore is
180
176
  }
181
177
 
182
178
  /**
183
- * @inheritdoc IERC725X
179
+ * @inheritdoc ERC725XCore
184
180
  *
185
181
  * @custom:requirements
186
182
  * - Can be only called by the {owner} or by an authorised address that pass the verification check performed on the owner.
@@ -191,7 +187,7 @@ abstract contract LSP0ERC725AccountCore is
191
187
  * @custom:events
192
188
  * - {Executed} event for each call that uses under `operationType`: `CALL` (0), `STATICCALL` (3) and `DELEGATECALL` (4).
193
189
  * - {ContractCreated} event, when a contract is created under `operationType`: `CREATE` (1) and `CREATE2` (2).
194
- * - {ValueReceived} event when receiving native tokens.
190
+ * - {UniversalReceiver} event when receiving native tokens.
195
191
  */
196
192
  function execute(
197
193
  uint256 operationType,
@@ -200,19 +196,25 @@ abstract contract LSP0ERC725AccountCore is
200
196
  bytes memory data
201
197
  ) public payable virtual override returns (bytes memory) {
202
198
  if (msg.value != 0) {
203
- emit ValueReceived(msg.sender, msg.value);
199
+ emit UniversalReceiver(
200
+ msg.sender,
201
+ msg.value,
202
+ _TYPEID_LSP0_VALUE_RECEIVED,
203
+ abi.encodePacked(msg.sig),
204
+ ""
205
+ );
204
206
  }
205
207
 
206
- address _owner = owner();
208
+ address accountOwner = owner();
207
209
 
208
210
  // If the caller is the owner perform execute directly
209
- if (msg.sender == _owner) {
211
+ if (msg.sender == accountOwner) {
210
212
  return ERC725XCore._execute(operationType, target, value, data);
211
213
  }
212
214
 
213
215
  // If the caller is not the owner, call {lsp20VerifyCall} on the owner
214
- // Depending on the magicValue returned, a second call is done after execution
215
- bool verifyAfter = LSP20CallVerification._verifyCall(_owner);
216
+ // Depending on the returnedStatus, a second call is done after execution
217
+ bool verifyAfter = LSP20CallVerification._verifyCall(accountOwner);
216
218
 
217
219
  // Perform the execution
218
220
  bytes memory result = ERC725XCore._execute(
@@ -224,14 +226,17 @@ abstract contract LSP0ERC725AccountCore is
224
226
 
225
227
  // if verifyAfter is true, Call {lsp20VerifyCallResult} on the owner
226
228
  if (verifyAfter) {
227
- LSP20CallVerification._verifyCallResult(_owner, abi.encode(result));
229
+ LSP20CallVerification._verifyCallResult(
230
+ accountOwner,
231
+ abi.encode(result)
232
+ );
228
233
  }
229
234
 
230
235
  return result;
231
236
  }
232
237
 
233
238
  /**
234
- * @inheritdoc IERC725X
239
+ * @inheritdoc ERC725XCore
235
240
  *
236
241
  * @custom:requirements
237
242
  * - The length of the parameters provided must be equal.
@@ -240,10 +245,13 @@ abstract contract LSP0ERC725AccountCore is
240
245
  * - If the operation type is `CREATE` (1) or `CREATE2` (2), `target` must be `address(0)`.
241
246
  * - If the operation type is `STATICCALL` (3) or `DELEGATECALL` (4), `value` transfer is disallowed and must be 0.
242
247
  *
248
+ * @custom:warning
249
+ * - The `msg.value` should not be trusted for any method called within the batch with `operationType`: `DELEGATECALL` (4).
250
+ *
243
251
  * @custom:events
244
252
  * - {Executed} event for each call that uses under `operationType`: `CALL` (0), `STATICCALL` (3) and `DELEGATECALL` (4). (each iteration)
245
253
  * - {ContractCreated} event, when a contract is created under `operationType`: `CREATE` (1) and `CREATE2` (2) (each iteration)
246
- * - {ValueReceived} event when receiving native tokens.
254
+ * - {UniversalReceiver} event when receiving native tokens.
247
255
  */
248
256
  function executeBatch(
249
257
  uint256[] memory operationsType,
@@ -252,13 +260,19 @@ abstract contract LSP0ERC725AccountCore is
252
260
  bytes[] memory datas
253
261
  ) public payable virtual override returns (bytes[] memory) {
254
262
  if (msg.value != 0) {
255
- emit ValueReceived(msg.sender, msg.value);
263
+ emit UniversalReceiver(
264
+ msg.sender,
265
+ msg.value,
266
+ _TYPEID_LSP0_VALUE_RECEIVED,
267
+ abi.encodePacked(msg.sig),
268
+ ""
269
+ );
256
270
  }
257
271
 
258
- address _owner = owner();
272
+ address accountOwner = owner();
259
273
 
260
274
  // If the caller is the owner perform execute directly
261
- if (msg.sender == _owner) {
275
+ if (msg.sender == accountOwner) {
262
276
  return
263
277
  ERC725XCore._executeBatch(
264
278
  operationsType,
@@ -269,8 +283,8 @@ abstract contract LSP0ERC725AccountCore is
269
283
  }
270
284
 
271
285
  // If the caller is not the owner, call {lsp20VerifyCall} on the owner
272
- // Depending on the magicValue returned, a second call is done after execution
273
- bool verifyAfter = LSP20CallVerification._verifyCall(_owner);
286
+ // Depending on the returnedStatus, a second call is done after execution
287
+ bool verifyAfter = LSP20CallVerification._verifyCall(accountOwner);
274
288
 
275
289
  // Perform the execution
276
290
  bytes[] memory results = ERC725XCore._executeBatch(
@@ -283,7 +297,7 @@ abstract contract LSP0ERC725AccountCore is
283
297
  // if verifyAfter is true, Call {lsp20VerifyCallResult} on the owner
284
298
  if (verifyAfter) {
285
299
  LSP20CallVerification._verifyCallResult(
286
- _owner,
300
+ accountOwner,
287
301
  abi.encode(results)
288
302
  );
289
303
  }
@@ -292,12 +306,12 @@ abstract contract LSP0ERC725AccountCore is
292
306
  }
293
307
 
294
308
  /**
295
- * @inheritdoc IERC725Y
309
+ * @inheritdoc ERC725YCore
296
310
  *
297
311
  * @custom:requirements Can be only called by the {owner} or by an authorised address that pass the verification check performed on the owner.
298
312
  *
299
313
  * @custom:events
300
- * - {ValueReceived} event when receiving native tokens.
314
+ * - {UniversalReceiver} event when receiving native tokens.
301
315
  * - {DataChanged} event.
302
316
  */
303
317
  function setData(
@@ -305,36 +319,42 @@ abstract contract LSP0ERC725AccountCore is
305
319
  bytes memory dataValue
306
320
  ) public payable virtual override {
307
321
  if (msg.value != 0) {
308
- emit ValueReceived(msg.sender, msg.value);
322
+ emit UniversalReceiver(
323
+ msg.sender,
324
+ msg.value,
325
+ _TYPEID_LSP0_VALUE_RECEIVED,
326
+ abi.encodePacked(msg.sig),
327
+ ""
328
+ );
309
329
  }
310
330
 
311
- address _owner = owner();
331
+ address accountOwner = owner();
312
332
 
313
333
  // If the caller is the owner perform setData directly
314
- if (msg.sender == _owner) {
334
+ if (msg.sender == accountOwner) {
315
335
  return _setData(dataKey, dataValue);
316
336
  }
317
337
 
318
338
  // If the caller is not the owner, call {lsp20VerifyCall} on the owner
319
- // Depending on the magicValue returned, a second call is done after setting data
320
- bool verifyAfter = _verifyCall(_owner);
339
+ // Depending on the returnedStatus, a second call is done after setting data
340
+ bool verifyAfter = _verifyCall(accountOwner);
321
341
 
322
342
  _setData(dataKey, dataValue);
323
343
 
324
344
  // If verifyAfter is true, Call {lsp20VerifyCallResult} on the owner
325
345
  // The setData function does not return, second parameter of {_verifyCallResult} will be empty
326
346
  if (verifyAfter) {
327
- _verifyCallResult(_owner, "");
347
+ _verifyCallResult(accountOwner, "");
328
348
  }
329
349
  }
330
350
 
331
351
  /**
332
- * @inheritdoc IERC725Y
352
+ * @inheritdoc ERC725YCore
333
353
  *
334
354
  * @custom:requirements Can be only called by the {owner} or by an authorised address that pass the verification check performed on the owner.
335
355
  *
336
356
  * @custom:events
337
- * - {ValueReceived} event when receiving native tokens.
357
+ * - {UniversalReceiver} event when receiving native tokens.
338
358
  * - {DataChanged} event. (on each iteration of setting data)
339
359
  */
340
360
  function setDataBatch(
@@ -342,18 +362,28 @@ abstract contract LSP0ERC725AccountCore is
342
362
  bytes[] memory dataValues
343
363
  ) public payable virtual override {
344
364
  if (msg.value != 0) {
345
- emit ValueReceived(msg.sender, msg.value);
365
+ emit UniversalReceiver(
366
+ msg.sender,
367
+ msg.value,
368
+ _TYPEID_LSP0_VALUE_RECEIVED,
369
+ abi.encodePacked(msg.sig),
370
+ ""
371
+ );
346
372
  }
347
373
 
348
374
  if (dataKeys.length != dataValues.length) {
349
375
  revert ERC725Y_DataKeysValuesLengthMismatch();
350
376
  }
351
377
 
352
- address _owner = owner();
378
+ if (dataKeys.length == 0) {
379
+ revert ERC725Y_DataKeysValuesEmptyArray();
380
+ }
381
+
382
+ address accountOwner = owner();
353
383
 
354
384
  // If the caller is the owner perform setData directly
355
- if (msg.sender == _owner) {
356
- for (uint256 i = 0; i < dataKeys.length; ) {
385
+ if (msg.sender == accountOwner) {
386
+ for (uint256 i; i < dataKeys.length; ) {
357
387
  _setData(dataKeys[i], dataValues[i]);
358
388
 
359
389
  unchecked {
@@ -365,10 +395,10 @@ abstract contract LSP0ERC725AccountCore is
365
395
  }
366
396
 
367
397
  // If the caller is not the owner, call {lsp20VerifyCall} on the owner
368
- // Depending on the magicValue returned, a second call is done after setting data
369
- bool verifyAfter = _verifyCall(_owner);
398
+ // Depending on the returnedStatus, a second call is done after setting data
399
+ bool verifyAfter = _verifyCall(accountOwner);
370
400
 
371
- for (uint256 i = 0; i < dataKeys.length; ) {
401
+ for (uint256 i; i < dataKeys.length; ) {
372
402
  _setData(dataKeys[i], dataValues[i]);
373
403
 
374
404
  unchecked {
@@ -379,7 +409,7 @@ abstract contract LSP0ERC725AccountCore is
379
409
  // If verifyAfter is true, Call {lsp20VerifyCallResult} on the owner
380
410
  // The setData function does not return, second parameter of {_verifyCallResult} will be empty
381
411
  if (verifyAfter) {
382
- _verifyCallResult(_owner, "");
412
+ _verifyCallResult(accountOwner, "");
383
413
  }
384
414
  }
385
415
 
@@ -410,15 +440,15 @@ abstract contract LSP0ERC725AccountCore is
410
440
  * @return returnedValues The ABI encoded return value of the LSP1UniversalReceiverDelegate call and the LSP1TypeIdDelegate call.
411
441
  *
412
442
  * @custom:events
413
- * - {ValueReceived} when receiving native tokens.
443
+ * - {UniversalReceiver} when receiving native tokens.
414
444
  * - {UniversalReceiver} event with the function parameters, call options, and the response of the UniversalReceiverDelegates (URD) contract that was called.
415
445
  */
416
446
  function universalReceiver(
417
447
  bytes32 typeId,
418
- bytes calldata receivedData
419
- ) public payable virtual returns (bytes memory returnedValues) {
420
- if (msg.value != 0) {
421
- emit ValueReceived(msg.sender, msg.value);
448
+ bytes memory receivedData
449
+ ) public payable virtual override returns (bytes memory returnedValues) {
450
+ if (msg.value != 0 && (typeId != _TYPEID_LSP0_VALUE_RECEIVED)) {
451
+ universalReceiver(_TYPEID_LSP0_VALUE_RECEIVED, msg.data);
422
452
  }
423
453
 
424
454
  // Query the ERC725Y storage with the data key {_LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY}
@@ -428,55 +458,49 @@ abstract contract LSP0ERC725AccountCore is
428
458
  bytes memory resultDefaultDelegate;
429
459
 
430
460
  if (lsp1DelegateValue.length >= 20) {
431
- address universalReceiverDelegate = address(
432
- bytes20(lsp1DelegateValue)
433
- );
461
+ address lsp1Delegate = address(bytes20(lsp1DelegateValue));
434
462
 
435
463
  // Checking LSP1 InterfaceId support
436
464
  if (
437
- universalReceiverDelegate.supportsERC165InterfaceUnchecked(
438
- _INTERFACEID_LSP1
465
+ lsp1Delegate.supportsERC165InterfaceUnchecked(
466
+ _INTERFACEID_LSP1_DELEGATE
439
467
  )
440
468
  ) {
441
- // calling {universalReceiver} function on URD appending the caller and the value sent
442
- resultDefaultDelegate = universalReceiverDelegate
443
- .callUniversalReceiverWithCallerInfos(
444
- typeId,
445
- receivedData,
469
+ resultDefaultDelegate = ILSP1Delegate(lsp1Delegate)
470
+ .universalReceiverDelegate(
446
471
  msg.sender,
447
- msg.value
472
+ msg.value,
473
+ typeId,
474
+ receivedData
448
475
  );
449
476
  }
450
477
  }
451
478
 
452
- // Generate the data key {_LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY + <bytes32 typeId>}
479
+ // Generate the data key {_LSP1_UNIVERSAL_RECEIVER_DELEGATE_PREFIX + <bytes32 typeId>}
453
480
  bytes32 lsp1typeIdDelegateKey = LSP2Utils.generateMappingKey(
454
481
  _LSP1_UNIVERSAL_RECEIVER_DELEGATE_PREFIX,
455
482
  bytes20(typeId)
456
483
  );
457
484
 
458
- // Query the ERC725Y storage with the data key {_LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY + <bytes32 typeId>}
485
+ // Query the ERC725Y storage with the data key {_LSP1_UNIVERSAL_RECEIVER_DELEGATE_PREFIX + <bytes32 typeId>}
459
486
  bytes memory lsp1TypeIdDelegateValue = _getData(lsp1typeIdDelegateKey);
460
487
  bytes memory resultTypeIdDelegate;
461
488
 
462
489
  if (lsp1TypeIdDelegateValue.length >= 20) {
463
- address universalReceiverDelegate = address(
464
- bytes20(lsp1TypeIdDelegateValue)
465
- );
490
+ address lsp1Delegate = address(bytes20(lsp1TypeIdDelegateValue));
466
491
 
467
492
  // Checking LSP1 InterfaceId support
468
493
  if (
469
- universalReceiverDelegate.supportsERC165InterfaceUnchecked(
470
- _INTERFACEID_LSP1
494
+ lsp1Delegate.supportsERC165InterfaceUnchecked(
495
+ _INTERFACEID_LSP1_DELEGATE
471
496
  )
472
497
  ) {
473
- // calling {universalReceiver} function on URD appending the caller and the value sent
474
- resultTypeIdDelegate = universalReceiverDelegate
475
- .callUniversalReceiverWithCallerInfos(
476
- typeId,
477
- receivedData,
498
+ resultTypeIdDelegate = ILSP1Delegate(lsp1Delegate)
499
+ .universalReceiverDelegate(
478
500
  msg.sender,
479
- msg.value
501
+ msg.value,
502
+ typeId,
503
+ receivedData
480
504
  );
481
505
  }
482
506
  }
@@ -526,7 +550,7 @@ abstract contract LSP0ERC725AccountCore is
526
550
  _inTransferOwnership = false;
527
551
  } else {
528
552
  // If the caller is not the owner, call {lsp20VerifyCall} on the owner
529
- // Depending on the magicValue returned, a second call is done after transferring ownership
553
+ // Depending on the returnedStatus, a second call is done after transferring ownership
530
554
  bool verifyAfter = _verifyCall(currentOwner);
531
555
 
532
556
  // set the transfer ownership lock
@@ -563,8 +587,20 @@ abstract contract LSP0ERC725AccountCore is
563
587
  */
564
588
  function acceptOwnership() public virtual override NotInTransferOwnership {
565
589
  address previousOwner = owner();
590
+ address pendingOwnerAddress = pendingOwner();
566
591
 
567
- _acceptOwnership();
592
+ bool verifyAfter;
593
+
594
+ if (msg.sender != pendingOwnerAddress) {
595
+ // If the caller is not the owner, call {lsp20VerifyCall} on the pending owner
596
+ // Depending on the successStatus returned, a second call is done after transferring ownership
597
+ verifyAfter = _verifyCall(pendingOwnerAddress);
598
+
599
+ _setOwner(pendingOwnerAddress);
600
+ delete _pendingOwner;
601
+ } else {
602
+ _acceptOwnership();
603
+ }
568
604
 
569
605
  // notify the previous owner if supports LSP1
570
606
  previousOwner.tryNotifyUniversalReceiver(
@@ -573,10 +609,16 @@ abstract contract LSP0ERC725AccountCore is
573
609
  );
574
610
 
575
611
  // notify the pending owner if supports LSP1
576
- msg.sender.tryNotifyUniversalReceiver(
612
+ pendingOwnerAddress.tryNotifyUniversalReceiver(
577
613
  _TYPEID_LSP0_OwnershipTransferred_RecipientNotification,
578
614
  ""
579
615
  );
616
+
617
+ // If msg.sender != pendingOwnerAddress & verifyAfter is true, Call {lsp20VerifyCallResult} on the new owner
618
+ // The transferOwnership function does not return, second parameter of {_verifyCallResult} will be empty
619
+ if (verifyAfter) {
620
+ _verifyCallResult(pendingOwnerAddress, "");
621
+ }
580
622
  }
581
623
 
582
624
  /**
@@ -584,7 +626,7 @@ abstract contract LSP0ERC725AccountCore is
584
626
  *
585
627
  * @custom:requirements Can be only called by the {owner} or by an authorised address that pass the verification check performed on the owner.
586
628
  *
587
- * @custom:danger Leaves the contract without an owner. Once ownership of the contract has been renounced, any functions that are restricted to be called by the owner will be permanently inaccessible, making these functions not callable anymore and unusable.
629
+ * @custom:danger Leaves the contract without an owner. Once ownership of the contract has been renounced, any functions that are restricted to be called by the owner or an address allowed by the owner will be permanently inaccessible, making these functions not callable anymore and unusable.
588
630
  *
589
631
  */
590
632
  function renounceOwnership()
@@ -592,16 +634,16 @@ abstract contract LSP0ERC725AccountCore is
592
634
  virtual
593
635
  override(LSP14Ownable2Step, OwnableUnset)
594
636
  {
595
- address _owner = owner();
637
+ address accountOwner = owner();
596
638
 
597
639
  // If the caller is the owner perform renounceOwnership directly
598
- if (msg.sender == _owner) {
640
+ if (msg.sender == accountOwner) {
599
641
  return LSP14Ownable2Step._renounceOwnership();
600
642
  }
601
643
 
602
644
  // If the caller is not the owner, call {lsp20VerifyCall} on the owner
603
- // Depending on the magicValue returned, a second call is done after transferring ownership
604
- bool verifyAfter = _verifyCall(_owner);
645
+ // Depending on the returnedStatus, a second call is done after transferring ownership
646
+ bool verifyAfter = _verifyCall(accountOwner);
605
647
 
606
648
  address previousOwner = owner();
607
649
  LSP14Ownable2Step._renounceOwnership();
@@ -616,7 +658,7 @@ abstract contract LSP0ERC725AccountCore is
616
658
  // If verifyAfter is true, Call {lsp20VerifyCallResult} on the owner
617
659
  // The transferOwnership function does not return, second parameter of {_verifyCallResult} will be empty
618
660
  if (verifyAfter) {
619
- _verifyCallResult(_owner, "");
661
+ _verifyCallResult(accountOwner, "");
620
662
  }
621
663
  }
622
664
 
@@ -661,29 +703,29 @@ abstract contract LSP0ERC725AccountCore is
661
703
  *
662
704
  * 1. If the owner is an EOA, recovers an address from the hash and the signature provided:
663
705
  *
664
- * - Returns the `magicValue` if the address recovered is the same as the owner, indicating that it was a valid signature.
706
+ * - Returns the `_ERC1271_SUCCESSVALUE` if the address recovered is the same as the owner, indicating that it was a valid signature.
665
707
  *
666
- * - If the address is different, it returns the fail value indicating that the signature is not valid.
708
+ * - If the address is different, it returns the `_ERC1271_FAILVALUE` indicating that the signature is not valid.
667
709
  *
668
710
  * 2. If the owner is a smart contract, it forwards the call of {isValidSignature()} to the owner contract:
669
711
  *
670
- * - If the contract fails or returns the fail value, the {isValidSignature()} on the account returns the fail value, indicating that the signature is not valid.
712
+ * - If the contract fails or returns the `_ERC1271_FAILVALUE`, the {isValidSignature()} on the account returns the `_ERC1271_FAILVALUE`, indicating that the signature is not valid.
671
713
  *
672
- * - If the {isValidSignature()} on the owner returned the `magicValue`, the {isValidSignature()} on the account returns the `magicValue`, indicating that it's a valid signature.
714
+ * - If the {isValidSignature()} on the owner returned the `_ERC1271_SUCCESSVALUE`, the {isValidSignature()} on the account returns the `_ERC1271_SUCCESSVALUE`, indicating that it's a valid signature.
673
715
  *
674
716
  * @param dataHash The hash of the data to be validated.
675
717
  * @param signature A signature that can validate the previous parameter (Hash).
676
718
  *
677
- * @return magicValue A `bytes4` value that indicates if the signature is valid or not.
719
+ * @return returnedStatus A `bytes4` value that indicates if the signature is valid or not.
678
720
  */
679
721
  function isValidSignature(
680
722
  bytes32 dataHash,
681
723
  bytes memory signature
682
- ) public view virtual returns (bytes4 magicValue) {
724
+ ) public view virtual override returns (bytes4 returnedStatus) {
683
725
  address _owner = owner();
684
726
 
685
727
  // If owner is a contract
686
- if (_owner.code.length > 0) {
728
+ if (_owner.code.length != 0) {
687
729
  (bool success, bytes memory result) = _owner.staticcall(
688
730
  abi.encodeWithSelector(
689
731
  IERC1271.isValidSignature.selector,
@@ -694,9 +736,10 @@ abstract contract LSP0ERC725AccountCore is
694
736
 
695
737
  bool isValid = (success &&
696
738
  result.length == 32 &&
697
- abi.decode(result, (bytes32)) == bytes32(_ERC1271_MAGICVALUE));
739
+ abi.decode(result, (bytes32)) ==
740
+ bytes32(_ERC1271_SUCCESSVALUE));
698
741
 
699
- return isValid ? _ERC1271_MAGICVALUE : _ERC1271_FAILVALUE;
742
+ return isValid ? _ERC1271_SUCCESSVALUE : _ERC1271_FAILVALUE;
700
743
  }
701
744
  // If owner is an EOA
702
745
  else {
@@ -709,11 +752,11 @@ abstract contract LSP0ERC725AccountCore is
709
752
  return _ERC1271_FAILVALUE;
710
753
 
711
754
  // if recovering is successful and the recovered address matches the owner's address,
712
- // return the ERC1271 magic value. Otherwise, return the ERC1271 fail value
755
+ // return the ERC1271 success value. Otherwise, return the ERC1271 fail value
713
756
  // matches the address of the owner, otherwise return fail value
714
757
  return
715
758
  recoveredAddress == _owner
716
- ? _ERC1271_MAGICVALUE
759
+ ? _ERC1271_SUCCESSVALUE
717
760
  : _ERC1271_FAILVALUE;
718
761
  }
719
762
  }
@@ -723,17 +766,36 @@ abstract contract LSP0ERC725AccountCore is
723
766
  /**
724
767
  * @dev Forwards the call to an extension mapped to a function selector.
725
768
  *
726
- * Calls {_getExtension} to get the address of the extension mapped to the function selector being called on the account. If there is no extension, the `address(0)` will be returned.
769
+ * Calls {_getExtensionAndForwardValue} to get the address of the extension mapped to the function selector being
770
+ * called on the account. If there is no extension, the `address(0)` will be returned.
771
+ * Forwards the value sent with the call to the extension if the function selector is mapped to a payable extension.
772
+ *
773
+ * 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.
727
774
  *
728
- * 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.
775
+ * If there is an extension for the function selector being called, it calls the extension with the
776
+ * `CALL` opcode, passing the `msg.data` appended with the 20 bytes of the {msg.sender} and 32 bytes of the `msg.value`.
729
777
  *
730
- * If there is an extension for the function selector being called, it calls the extension with the CALL opcode, passing the `msg.data` appended with the 20 bytes of the `msg.sender` and 32 bytes of the `msg.value`
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
+ * ```
731
786
  */
732
787
  function _fallbackLSP17Extendable(
733
788
  bytes calldata callData
734
789
  ) internal virtual override returns (bytes memory) {
735
790
  // If there is a function selector
736
- address extension = _getExtension(msg.sig);
791
+ (
792
+ address extension,
793
+ bool isForwardingValue
794
+ ) = _getExtensionAndForwardValue(msg.sig);
795
+
796
+ // if value is associated with the extension call and extension function selector is not payable, use the universalReceiver
797
+ if (msg.value != 0 && !isForwardingValue)
798
+ universalReceiver(_TYPEID_LSP0_VALUE_RECEIVED, callData);
737
799
 
738
800
  // if no extension was found for bytes4(0) return don't revert
739
801
  if (msg.sig == bytes4(0) && extension == address(0)) return "";
@@ -742,9 +804,9 @@ abstract contract LSP0ERC725AccountCore is
742
804
  if (extension == address(0))
743
805
  revert NoExtensionFoundForFunctionSelector(msg.sig);
744
806
 
745
- (bool success, bytes memory result) = extension.call(
746
- abi.encodePacked(callData, msg.sender, msg.value)
747
- );
807
+ (bool success, bytes memory result) = extension.call{
808
+ value: isForwardingValue ? msg.value : 0
809
+ }(abi.encodePacked(callData, msg.sender, msg.value));
748
810
 
749
811
  if (success) {
750
812
  return result;
@@ -763,21 +825,32 @@ abstract contract LSP0ERC725AccountCore is
763
825
  * - {_LSP17_EXTENSION_PREFIX} + `<bytes4>` (Check [LSP2-ERC725YJSONSchema] for encoding the data key).
764
826
  * - If no extension is stored, returns the address(0).
765
827
  */
766
- function _getExtension(
828
+ function _getExtensionAndForwardValue(
767
829
  bytes4 functionSelector
768
- ) internal view virtual override returns (address) {
830
+ ) internal view virtual override returns (address, bool) {
769
831
  // Generate the data key relevant for the functionSelector being called
770
832
  bytes32 mappedExtensionDataKey = LSP2Utils.generateMappingKey(
771
833
  _LSP17_EXTENSION_PREFIX,
772
834
  functionSelector
773
835
  );
774
836
 
775
- // Check if there is an extension stored under the generated data key
776
- address extension = address(
777
- bytes20(ERC725YCore._getData(mappedExtensionDataKey))
837
+ bytes memory extensionData = ERC725YCore._getData(
838
+ mappedExtensionDataKey
778
839
  );
779
840
 
780
- return extension;
841
+ // CHECK if the `extensionData` is 21 bytes long
842
+ // - 20 bytes = extension's address
843
+ // - 1 byte `0x01` as a boolean indicating if the contract should forward the value to the extension or not
844
+ if (extensionData.length == 21) {
845
+ // If the last byte is set to `0x01` (`true`)
846
+ // this indicates that the contract should forward the value to the extension
847
+ if (extensionData[20] == 0x01) {
848
+ // Return the address of the extension
849
+ return (address(bytes20(extensionData)), true);
850
+ }
851
+ }
852
+
853
+ return (address(bytes20(extensionData)), false);
781
854
  }
782
855
 
783
856
  /**