@lukso/lsp-smart-contracts 0.14.0 → 0.15.0-rc.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 (300) hide show
  1. package/README.md +2 -192
  2. package/artifacts/LSP0ERC725Account.json +3 -3
  3. package/artifacts/LSP0ERC725AccountInit.json +3 -3
  4. package/artifacts/LSP11BasicSocialRecovery.json +2 -2
  5. package/artifacts/LSP11BasicSocialRecoveryInit.json +2 -2
  6. package/artifacts/LSP1UniversalReceiverDelegateUP.json +3 -3
  7. package/artifacts/LSP1UniversalReceiverDelegateVault.json +3 -3
  8. package/artifacts/LSP23LinkedContractsFactory.json +3 -3
  9. package/artifacts/LSP4DigitalAssetMetadata.json +1 -1
  10. package/artifacts/LSP4DigitalAssetMetadataInitAbstract.json +1 -1
  11. package/artifacts/LSP6KeyManager.json +3 -3
  12. package/artifacts/LSP6KeyManagerInit.json +3 -3
  13. package/artifacts/LSP7CappedSupply.json +53 -6
  14. package/artifacts/LSP7CappedSupplyInitAbstract.json +53 -6
  15. package/artifacts/LSP7DigitalAsset.json +52 -5
  16. package/artifacts/LSP7DigitalAssetInitAbstract.json +52 -5
  17. package/artifacts/LSP7Mintable.json +54 -7
  18. package/artifacts/LSP7MintableInit.json +54 -7
  19. package/artifacts/LSP8CappedSupply.json +43 -6
  20. package/artifacts/LSP8CappedSupplyInitAbstract.json +43 -6
  21. package/artifacts/LSP8IdentifiableDigitalAsset.json +43 -6
  22. package/artifacts/LSP8IdentifiableDigitalAssetInitAbstract.json +43 -6
  23. package/artifacts/LSP8Mintable.json +45 -8
  24. package/artifacts/LSP8MintableInit.json +45 -8
  25. package/artifacts/LSP9Vault.json +3 -3
  26. package/artifacts/LSP9VaultInit.json +3 -3
  27. package/artifacts/UniversalProfile.json +3 -3
  28. package/artifacts/UniversalProfileInit.json +3 -3
  29. package/contracts/LSP0ERC725Account/ILSP0ERC725Account.sol +1 -17
  30. package/contracts/LSP0ERC725Account/LSP0Constants.sol +1 -23
  31. package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +1 -53
  32. package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +1 -873
  33. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +1 -47
  34. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +1 -49
  35. package/contracts/LSP10ReceivedVaults/LSP10Constants.sol +1 -7
  36. package/contracts/LSP10ReceivedVaults/LSP10Utils.sol +1 -208
  37. package/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryCore.sol +4 -2
  38. package/contracts/LSP12IssuedAssets/LSP12Constants.sol +4 -0
  39. package/contracts/LSP14Ownable2Step/ILSP14Ownable2Step.sol +1 -75
  40. package/contracts/LSP14Ownable2Step/LSP14Constants.sol +1 -12
  41. package/contracts/LSP14Ownable2Step/LSP14Errors.sol +1 -29
  42. package/contracts/LSP14Ownable2Step/LSP14Ownable2Step.sol +1 -212
  43. package/contracts/LSP16UniversalFactory/LSP16UniversalFactory.sol +1 -417
  44. package/contracts/LSP17ContractExtension/LSP17Constants.sol +1 -14
  45. package/contracts/LSP17ContractExtension/LSP17Errors.sol +1 -14
  46. package/contracts/LSP17ContractExtension/LSP17Extendable.sol +1 -117
  47. package/contracts/LSP17ContractExtension/LSP17Extension.sol +1 -55
  48. package/contracts/LSP17ContractExtension/LSP17Utils.sol +1 -16
  49. package/contracts/LSP17Extensions/Extension4337.sol +1 -123
  50. package/contracts/LSP17Extensions/OnERC721ReceivedExtension.sol +1 -13
  51. package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiver.sol +1 -37
  52. package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiverDelegate.sol +1 -21
  53. package/contracts/LSP1UniversalReceiver/LSP1Constants.sol +1 -11
  54. package/contracts/LSP1UniversalReceiver/LSP1Errors.sol +1 -7
  55. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +1 -292
  56. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +1 -217
  57. package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +1 -84
  58. package/contracts/LSP20CallVerification/ILSP20CallVerifier.sol +1 -36
  59. package/contracts/LSP20CallVerification/LSP20CallVerification.sol +1 -117
  60. package/contracts/LSP20CallVerification/LSP20Constants.sol +1 -14
  61. package/contracts/LSP20CallVerification/LSP20Errors.sol +1 -18
  62. package/contracts/LSP23LinkedContractsFactory/ILSP23LinkedContractsFactory.sol +1 -189
  63. package/contracts/LSP23LinkedContractsFactory/IPostDeploymentModule.sol +1 -15
  64. package/contracts/LSP23LinkedContractsFactory/LSP23Errors.sol +1 -21
  65. package/contracts/LSP23LinkedContractsFactory/LSP23LinkedContractsFactory.sol +1 -393
  66. package/contracts/LSP23LinkedContractsFactory/modules/README.md +23 -0
  67. package/contracts/LSP23LinkedContractsFactory/modules/UniversalProfileInitPostDeploymentModule.sol +1 -60
  68. package/contracts/LSP23LinkedContractsFactory/modules/UniversalProfilePostDeploymentModule.sol +1 -58
  69. package/contracts/LSP25ExecuteRelayCall/ILSP25ExecuteRelayCall.sol +1 -65
  70. package/contracts/LSP25ExecuteRelayCall/LSP25Constants.sol +1 -5
  71. package/contracts/LSP25ExecuteRelayCall/LSP25Errors.sol +1 -14
  72. package/contracts/LSP25ExecuteRelayCall/LSP25MultiChannelNonce.sol +1 -141
  73. package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +1 -445
  74. package/contracts/LSP3ProfileMetadata/LSP3Constants.sol +1 -8
  75. package/contracts/LSP4DigitalAssetMetadata/LSP4Constants.sol +1 -30
  76. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol +1 -59
  77. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataCore.sol +1 -44
  78. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +1 -65
  79. package/contracts/LSP4DigitalAssetMetadata/LSP4Errors.sol +1 -20
  80. package/contracts/LSP5ReceivedAssets/LSP5Constants.sol +1 -7
  81. package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +1 -206
  82. package/contracts/LSP6KeyManager/ILSP6KeyManager.sol +1 -60
  83. package/contracts/LSP6KeyManager/LSP6Constants.sol +1 -61
  84. package/contracts/LSP6KeyManager/LSP6Errors.sol +1 -222
  85. package/contracts/LSP6KeyManager/LSP6KeyManager.sol +1 -23
  86. package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +1 -694
  87. package/contracts/LSP6KeyManager/LSP6KeyManagerInit.sol +1 -29
  88. package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +1 -21
  89. package/contracts/LSP6KeyManager/LSP6Modules/LSP6ExecuteModule.sol +1 -411
  90. package/contracts/LSP6KeyManager/LSP6Modules/LSP6ExecuteRelayCallModule.sol +1 -24
  91. package/contracts/LSP6KeyManager/LSP6Modules/LSP6OwnershipModule.sol +1 -27
  92. package/contracts/LSP6KeyManager/LSP6Modules/LSP6SetDataModule.sol +1 -848
  93. package/contracts/LSP6KeyManager/LSP6Utils.sol +1 -293
  94. package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +1 -302
  95. package/contracts/LSP7DigitalAsset/LSP7Constants.sol +1 -13
  96. package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +1 -193
  97. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +1 -728
  98. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +1 -189
  99. package/contracts/LSP7DigitalAsset/LSP7Errors.sol +1 -87
  100. package/contracts/LSP7DigitalAsset/extensions/LSP7Burnable.sol +1 -23
  101. package/contracts/LSP7DigitalAsset/extensions/LSP7BurnableInitAbstract.sol +1 -24
  102. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupply.sol +1 -80
  103. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInitAbstract.sol +1 -83
  104. package/contracts/LSP7DigitalAsset/presets/ILSP7Mintable.sol +1 -29
  105. package/contracts/LSP7DigitalAsset/presets/LSP7Mintable.sol +1 -50
  106. package/contracts/LSP7DigitalAsset/presets/LSP7MintableInit.sol +1 -41
  107. package/contracts/LSP7DigitalAsset/presets/LSP7MintableInitAbstract.sol +1 -54
  108. package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +1 -325
  109. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol +1 -38
  110. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol +1 -102
  111. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +1 -236
  112. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +1 -787
  113. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +1 -243
  114. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Burnable.sol +1 -27
  115. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8BurnableInitAbstract.sol +1 -21
  116. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.sol +1 -82
  117. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInitAbstract.sol +1 -85
  118. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.sol +1 -66
  119. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableInitAbstract.sol +1 -61
  120. package/contracts/LSP8IdentifiableDigitalAsset/presets/ILSP8Mintable.sol +1 -30
  121. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.sol +1 -57
  122. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInit.sol +1 -40
  123. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +1 -59
  124. package/contracts/LSP9Vault/ILSP9Vault.sol +1 -16
  125. package/contracts/LSP9Vault/LSP9Constants.sol +1 -26
  126. package/contracts/LSP9Vault/LSP9Errors.sol +1 -6
  127. package/contracts/LSP9Vault/LSP9Vault.sol +1 -63
  128. package/contracts/LSP9Vault/LSP9VaultCore.sol +1 -684
  129. package/contracts/LSP9Vault/LSP9VaultInit.sol +1 -33
  130. package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +1 -65
  131. package/contracts/UniversalProfile.sol +1 -37
  132. package/contracts/UniversalProfileInit.sol +1 -39
  133. package/contracts/UniversalProfileInitAbstract.sol +1 -44
  134. package/dist/constants.cjs +75 -0
  135. package/dist/constants.d.cts +121 -0
  136. package/dist/constants.d.mts +121 -0
  137. package/dist/constants.d.ts +107 -40105
  138. package/dist/constants.mjs +70 -0
  139. package/package.json +58 -116
  140. package/types/@lukso/lsp0-contracts/contracts/LSP0ERC725Account.ts +694 -0
  141. package/types/@lukso/lsp0-contracts/contracts/LSP0ERC725AccountInit.ts +740 -0
  142. package/types/@lukso/lsp1delegate-contracts/contracts/LSP1UniversalReceiverDelegateUP.ts +139 -0
  143. package/types/@lukso/lsp1delegate-contracts/contracts/LSP1UniversalReceiverDelegateVault.ts +139 -0
  144. package/types/@lukso/lsp23-contracts/contracts/LSP23LinkedContractsFactory.ts +448 -0
  145. package/types/@lukso/lsp4-contracts/contracts/LSP4DigitalAssetMetadata.ts +274 -0
  146. package/types/@lukso/lsp4-contracts/contracts/LSP4DigitalAssetMetadataInitAbstract.ts +309 -0
  147. package/types/@lukso/lsp6-contracts/contracts/LSP6KeyManager.ts +355 -0
  148. package/types/@lukso/lsp6-contracts/contracts/LSP6KeyManagerInit.ts +398 -0
  149. package/types/@lukso/lsp7-contracts/contracts/LSP7DigitalAsset.ts +698 -0
  150. package/types/@lukso/lsp7-contracts/contracts/LSP7DigitalAssetInitAbstract.ts +729 -0
  151. package/types/@lukso/lsp7-contracts/contracts/extensions/LSP7CappedSupply.ts +712 -0
  152. package/types/@lukso/lsp7-contracts/contracts/extensions/LSP7CappedSupplyInitAbstract.ts +743 -0
  153. package/types/@lukso/lsp7-contracts/contracts/presets/LSP7Mintable.ts +717 -0
  154. package/types/@lukso/lsp7-contracts/contracts/presets/LSP7MintableInit.ts +779 -0
  155. package/types/@lukso/lsp8-contracts/contracts/LSP8IdentifiableDigitalAsset.ts +778 -0
  156. package/types/@lukso/lsp8-contracts/contracts/LSP8IdentifiableDigitalAssetInitAbstract.ts +813 -0
  157. package/types/@lukso/lsp8-contracts/contracts/extensions/LSP8CappedSupply.ts +792 -0
  158. package/types/@lukso/lsp8-contracts/contracts/extensions/LSP8CappedSupplyInitAbstract.ts +824 -0
  159. package/types/@lukso/lsp8-contracts/contracts/presets/LSP8Mintable.ts +797 -0
  160. package/types/@lukso/lsp8-contracts/contracts/presets/LSP8MintableInit.ts +860 -0
  161. package/types/@lukso/lsp9-contracts/contracts/LSP9Vault.ts +672 -0
  162. package/types/@lukso/lsp9-contracts/contracts/LSP9VaultInit.ts +714 -0
  163. package/types/@lukso/universalprofile-contracts/contracts/UniversalProfile.ts +694 -0
  164. package/types/@lukso/universalprofile-contracts/contracts/UniversalProfileInit.ts +740 -0
  165. package/types/LSP0ERC725Account.ts +694 -0
  166. package/types/LSP0ERC725AccountInit.ts +740 -0
  167. package/types/LSP11BasicSocialRecovery.ts +596 -0
  168. package/types/LSP11BasicSocialRecoveryInit.ts +646 -0
  169. package/types/LSP1UniversalReceiverDelegateUP.ts +139 -0
  170. package/types/LSP1UniversalReceiverDelegateVault.ts +139 -0
  171. package/types/LSP23LinkedContractsFactory.ts +448 -0
  172. package/types/LSP4DigitalAssetMetadata.ts +274 -0
  173. package/types/LSP4DigitalAssetMetadataInitAbstract.ts +309 -0
  174. package/types/LSP6KeyManager.ts +355 -0
  175. package/types/LSP6KeyManagerInit.ts +398 -0
  176. package/types/LSP7CappedSupply.ts +712 -0
  177. package/types/LSP7CappedSupplyInitAbstract.ts +743 -0
  178. package/types/LSP7DigitalAsset.ts +698 -0
  179. package/types/LSP7DigitalAssetInitAbstract.ts +729 -0
  180. package/types/LSP7Mintable.ts +717 -0
  181. package/types/LSP7MintableInit.ts +779 -0
  182. package/types/LSP8CappedSupply.ts +792 -0
  183. package/types/LSP8CappedSupplyInitAbstract.ts +824 -0
  184. package/types/LSP8IdentifiableDigitalAsset.ts +778 -0
  185. package/types/LSP8IdentifiableDigitalAssetInitAbstract.ts +813 -0
  186. package/types/LSP8Mintable.ts +797 -0
  187. package/types/LSP8MintableInit.ts +860 -0
  188. package/types/LSP9Vault.ts +672 -0
  189. package/types/LSP9VaultInit.ts +714 -0
  190. package/types/UniversalProfile.ts +694 -0
  191. package/types/UniversalProfileInit.ts +740 -0
  192. package/types/common.ts +131 -0
  193. package/types/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecovery.ts +596 -0
  194. package/types/contracts/LSP11BasicSocialRecovery/LSP11BasicSocialRecoveryInit.ts +646 -0
  195. package/types/index.ts +58 -0
  196. package/LICENSE +0 -201
  197. package/artifacts/Create2Factory.json +0 -107
  198. package/artifacts/LSP16UniversalFactory.json +0 -271
  199. package/artifacts/LSP7CompatibleERC20.json +0 -935
  200. package/artifacts/LSP7CompatibleERC20InitAbstract.json +0 -948
  201. package/artifacts/LSP7CompatibleERC20Mintable.json +0 -989
  202. package/artifacts/LSP7CompatibleERC20MintableInit.json +0 -1009
  203. package/artifacts/LSP8CompatibleERC721.json +0 -1191
  204. package/artifacts/LSP8CompatibleERC721InitAbstract.json +0 -1204
  205. package/artifacts/LSP8CompatibleERC721Mintable.json +0 -1261
  206. package/artifacts/LSP8CompatibleERC721MintableInit.json +0 -1281
  207. package/artifacts/UniversalReceiverAddressStore.json +0 -209
  208. package/contracts/Factories/Create2Factory.sol +0 -88
  209. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20.sol +0 -260
  210. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibleERC20InitAbstract.sol +0 -273
  211. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.sol +0 -37
  212. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInit.sol +0 -44
  213. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInitAbstract.sol +0 -43
  214. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +0 -512
  215. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +0 -514
  216. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.sol +0 -54
  217. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInit.sol +0 -47
  218. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInitAbstract.sol +0 -52
  219. package/contracts/Legacy/Registries/AddressRegistry.sol +0 -52
  220. package/contracts/Legacy/Registries/AddressRegistryRequiresERC725.sol +0 -37
  221. package/contracts/Legacy/UniversalReceiverAddressStore.sol +0 -64
  222. package/contracts/Version.sol +0 -17
  223. package/devdocs/Create2Factory.json +0 -16
  224. package/devdocs/LSP0ERC725Account.json +0 -260
  225. package/devdocs/LSP0ERC725AccountInit.json +0 -263
  226. package/devdocs/LSP11BasicSocialRecovery.json +0 -159
  227. package/devdocs/LSP11BasicSocialRecoveryInit.json +0 -159
  228. package/devdocs/LSP16UniversalFactory.json +0 -116
  229. package/devdocs/LSP1UniversalReceiverDelegateUP.json +0 -34
  230. package/devdocs/LSP1UniversalReceiverDelegateVault.json +0 -33
  231. package/devdocs/LSP23LinkedContractsFactory.json +0 -81
  232. package/devdocs/LSP4DigitalAssetMetadata.json +0 -112
  233. package/devdocs/LSP4DigitalAssetMetadataInitAbstract.json +0 -104
  234. package/devdocs/LSP6KeyManager.json +0 -305
  235. package/devdocs/LSP6KeyManagerInit.json +0 -308
  236. package/devdocs/LSP7CappedSupply.json +0 -306
  237. package/devdocs/LSP7CappedSupplyInitAbstract.json +0 -299
  238. package/devdocs/LSP7CompatibleERC20.json +0 -346
  239. package/devdocs/LSP7CompatibleERC20InitAbstract.json +0 -338
  240. package/devdocs/LSP7CompatibleERC20Mintable.json +0 -349
  241. package/devdocs/LSP7CompatibleERC20MintableInit.json +0 -352
  242. package/devdocs/LSP7DigitalAsset.json +0 -294
  243. package/devdocs/LSP7DigitalAssetInitAbstract.json +0 -285
  244. package/devdocs/LSP7Mintable.json +0 -296
  245. package/devdocs/LSP7MintableInit.json +0 -298
  246. package/devdocs/LSP8CappedSupply.json +0 -356
  247. package/devdocs/LSP8CappedSupplyInitAbstract.json +0 -349
  248. package/devdocs/LSP8CompatibleERC721.json +0 -437
  249. package/devdocs/LSP8CompatibleERC721InitAbstract.json +0 -428
  250. package/devdocs/LSP8CompatibleERC721Mintable.json +0 -446
  251. package/devdocs/LSP8CompatibleERC721MintableInit.json +0 -449
  252. package/devdocs/LSP8IdentifiableDigitalAsset.json +0 -346
  253. package/devdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +0 -335
  254. package/devdocs/LSP8Mintable.json +0 -356
  255. package/devdocs/LSP8MintableInit.json +0 -359
  256. package/devdocs/LSP9Vault.json +0 -236
  257. package/devdocs/LSP9VaultInit.json +0 -239
  258. package/devdocs/UniversalProfile.json +0 -260
  259. package/devdocs/UniversalProfileInit.json +0 -263
  260. package/devdocs/UniversalReceiverAddressStore.json +0 -9
  261. package/dist/constants.cjs.js +0 -40758
  262. package/dist/constants.es.js +0 -40737
  263. package/userdocs/Create2Factory.json +0 -5
  264. package/userdocs/LSP0ERC725Account.json +0 -91
  265. package/userdocs/LSP0ERC725AccountInit.json +0 -94
  266. package/userdocs/LSP11BasicSocialRecovery.json +0 -29
  267. package/userdocs/LSP11BasicSocialRecoveryInit.json +0 -29
  268. package/userdocs/LSP16UniversalFactory.json +0 -30
  269. package/userdocs/LSP1UniversalReceiverDelegateUP.json +0 -19
  270. package/userdocs/LSP1UniversalReceiverDelegateVault.json +0 -19
  271. package/userdocs/LSP23LinkedContractsFactory.json +0 -29
  272. package/userdocs/LSP4DigitalAssetMetadata.json +0 -26
  273. package/userdocs/LSP4DigitalAssetMetadataInitAbstract.json +0 -23
  274. package/userdocs/LSP6KeyManager.json +0 -154
  275. package/userdocs/LSP6KeyManagerInit.json +0 -157
  276. package/userdocs/LSP7CappedSupply.json +0 -60
  277. package/userdocs/LSP7CappedSupplyInitAbstract.json +0 -57
  278. package/userdocs/LSP7CompatibleERC20.json +0 -47
  279. package/userdocs/LSP7CompatibleERC20InitAbstract.json +0 -44
  280. package/userdocs/LSP7CompatibleERC20Mintable.json +0 -47
  281. package/userdocs/LSP7CompatibleERC20MintableInit.json +0 -47
  282. package/userdocs/LSP7DigitalAsset.json +0 -47
  283. package/userdocs/LSP7DigitalAssetInitAbstract.json +0 -44
  284. package/userdocs/LSP7Mintable.json +0 -47
  285. package/userdocs/LSP7MintableInit.json +0 -47
  286. package/userdocs/LSP8CappedSupply.json +0 -66
  287. package/userdocs/LSP8CappedSupplyInitAbstract.json +0 -63
  288. package/userdocs/LSP8CompatibleERC721.json +0 -80
  289. package/userdocs/LSP8CompatibleERC721InitAbstract.json +0 -77
  290. package/userdocs/LSP8CompatibleERC721Mintable.json +0 -83
  291. package/userdocs/LSP8CompatibleERC721MintableInit.json +0 -83
  292. package/userdocs/LSP8IdentifiableDigitalAsset.json +0 -53
  293. package/userdocs/LSP8IdentifiableDigitalAssetInitAbstract.json +0 -50
  294. package/userdocs/LSP8Mintable.json +0 -56
  295. package/userdocs/LSP8MintableInit.json +0 -56
  296. package/userdocs/LSP9Vault.json +0 -93
  297. package/userdocs/LSP9VaultInit.json +0 -93
  298. package/userdocs/UniversalProfile.json +0 -91
  299. package/userdocs/UniversalProfileInit.json +0 -94
  300. package/userdocs/UniversalReceiverAddressStore.json +0 -5
@@ -1,851 +1,4 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  pragma solidity ^0.8.5;
3
3
 
4
- // interfaces
5
- import {
6
- ILSP20CallVerifier as ILSP20
7
- } from "../../LSP20CallVerification/ILSP20CallVerifier.sol";
8
-
9
- // modules
10
- import {ERC725Y} from "@erc725/smart-contracts/contracts/ERC725Y.sol";
11
-
12
- // libraries
13
- import {LSP6Utils} from "../LSP6Utils.sol";
14
-
15
- // constants
16
- import {
17
- _LSP6KEY_ADDRESSPERMISSIONS_ARRAY,
18
- _LSP6KEY_ADDRESSPERMISSIONS_ARRAY_PREFIX,
19
- _LSP6KEY_ADDRESSPERMISSIONS_PREFIX,
20
- _LSP6KEY_ADDRESSPERMISSIONS_PERMISSIONS_PREFIX,
21
- _LSP6KEY_ADDRESSPERMISSIONS_ALLOWEDCALLS_PREFIX,
22
- _LSP6KEY_ADDRESSPERMISSIONS_AllowedERC725YDataKeys_PREFIX,
23
- _PERMISSION_SETDATA,
24
- _PERMISSION_SUPER_SETDATA,
25
- _PERMISSION_ADDCONTROLLER,
26
- _PERMISSION_EDITPERMISSIONS,
27
- _PERMISSION_ADDEXTENSIONS,
28
- _PERMISSION_CHANGEEXTENSIONS,
29
- _PERMISSION_ADDUNIVERSALRECEIVERDELEGATE,
30
- _PERMISSION_CHANGEUNIVERSALRECEIVERDELEGATE
31
- } from "../LSP6Constants.sol";
32
- import {
33
- _LSP1_UNIVERSAL_RECEIVER_DELEGATE_PREFIX,
34
- _LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY
35
- } from "../../LSP1UniversalReceiver/LSP1Constants.sol";
36
- import {
37
- _LSP17_EXTENSION_PREFIX
38
- } from "../../LSP17ContractExtension/LSP17Constants.sol";
39
-
40
- // errors
41
- import {
42
- ERC725Y_DataKeysValuesLengthMismatch
43
- } from "@erc725/smart-contracts/contracts/errors.sol";
44
- import {
45
- NotRecognisedPermissionKey,
46
- InvalidEncodedAllowedCalls,
47
- InvalidEncodedAllowedERC725YDataKeys,
48
- NoERC725YDataKeysAllowed,
49
- NotAllowedERC725YDataKey,
50
- NotAuthorised,
51
- KeyManagerCannotBeSetAsExtensionForLSP20Functions,
52
- InvalidDataValuesForDataKeys
53
- } from "../LSP6Errors.sol";
54
-
55
- abstract contract LSP6SetDataModule {
56
- using LSP6Utils for *;
57
-
58
- /**
59
- * @dev verify if the `controllerAddress` has the permissions required to set a data key on the ERC725Y storage of the `controlledContract`.
60
- * @param controlledContract the address of the ERC725Y contract where the data key is set.
61
- * @param controllerAddress the address of the controller who wants to set the data key.
62
- * @param controllerPermissions the permissions of the controller address.
63
- * @param inputDataKey the data key to set on the `controlledContract`.
64
- * @param inputDataValue the data value to set for the `inputDataKey`.
65
- */
66
- function _verifyCanSetData(
67
- address controlledContract,
68
- address controllerAddress,
69
- bytes32 controllerPermissions,
70
- bytes32 inputDataKey,
71
- bytes memory inputDataValue
72
- ) internal view virtual {
73
- bytes32 requiredPermission = _getPermissionRequiredToSetDataKey(
74
- controlledContract,
75
- controllerPermissions,
76
- inputDataKey,
77
- inputDataValue
78
- );
79
-
80
- // CHECK if allowed to set an ERC725Y Data Key
81
- if (requiredPermission == _PERMISSION_SETDATA) {
82
- // Skip if caller has SUPER permissions
83
- if (controllerPermissions.hasPermission(_PERMISSION_SUPER_SETDATA))
84
- return;
85
-
86
- _requirePermissions(
87
- controllerAddress,
88
- controllerPermissions,
89
- _PERMISSION_SETDATA
90
- );
91
-
92
- _verifyAllowedERC725YSingleKey(
93
- controllerAddress,
94
- inputDataKey,
95
- ERC725Y(controlledContract).getAllowedERC725YDataKeysFor(
96
- controllerAddress
97
- )
98
- );
99
- } else {
100
- // Do not check again if we already checked that the controller had the permissions inside `_getPermissionRequiredToSetDataKey(...)`
101
- if (requiredPermission == bytes32(0)) return;
102
-
103
- // Otherwise CHECK the required permission if setting LSP6 permissions, LSP1 Delegate or LSP17 Extensions.
104
- _requirePermissions(
105
- controllerAddress,
106
- controllerPermissions,
107
- requiredPermission
108
- );
109
- }
110
- }
111
-
112
- /**
113
- * @dev verify if the `controllerAddress` has the permissions required to set an array of data keys on the ERC725Y storage of the `controlledContract`.
114
- * @param controlledContract the address of the ERC725Y contract where the data key is set.
115
- * @param controller the address of the controller who wants to set the data key.
116
- * @param permissions the permissions of the controller address.
117
- * @param inputDataKeys an array of data keys to set on the `controlledContract`.
118
- * @param inputDataValues an array of data values to set for the `inputDataKeys`.
119
- */
120
- function _verifyCanSetData(
121
- address controlledContract,
122
- address controller,
123
- bytes32 permissions,
124
- bytes32[] memory inputDataKeys,
125
- bytes[] memory inputDataValues
126
- ) internal view virtual {
127
- if (inputDataKeys.length != inputDataValues.length) {
128
- revert ERC725Y_DataKeysValuesLengthMismatch();
129
- }
130
-
131
- bool isSettingERC725YKeys = false;
132
- bool[] memory validatedInputDataKeys = new bool[](inputDataKeys.length);
133
- uint256 inputDataKeysAllowed = 0;
134
-
135
- bytes32 requiredPermission;
136
-
137
- uint256 ii = 0;
138
- do {
139
- requiredPermission = _getPermissionRequiredToSetDataKey(
140
- controlledContract,
141
- permissions,
142
- inputDataKeys[ii],
143
- inputDataValues[ii]
144
- );
145
-
146
- if (requiredPermission == _PERMISSION_SETDATA) {
147
- isSettingERC725YKeys = true;
148
- } else {
149
- // if we did not check already the permissions of the controller inside `_getPermissionRequiredToSetDataKey(...)`
150
- if (requiredPermission != bytes32(0)) {
151
- // CHECK the required permissions for setting LSP6 permissions, LSP1 Delegate or LSP17 Extensions.
152
- _requirePermissions(
153
- controller,
154
- permissions,
155
- requiredPermission
156
- );
157
- }
158
-
159
- validatedInputDataKeys[ii] = true;
160
- inputDataKeysAllowed++;
161
- }
162
-
163
- unchecked {
164
- ++ii;
165
- }
166
- } while (ii < inputDataKeys.length);
167
-
168
- // CHECK if allowed to set one (or multiple) ERC725Y Data Keys
169
- if (isSettingERC725YKeys) {
170
- // Skip if caller has SUPER permissions
171
- if (permissions.hasPermission(_PERMISSION_SUPER_SETDATA)) return;
172
-
173
- _requirePermissions(controller, permissions, _PERMISSION_SETDATA);
174
-
175
- _verifyAllowedERC725YDataKeys(
176
- controller,
177
- inputDataKeys,
178
- ERC725Y(controlledContract).getAllowedERC725YDataKeysFor(
179
- controller
180
- ),
181
- validatedInputDataKeys,
182
- inputDataKeysAllowed
183
- );
184
- }
185
- }
186
-
187
- /**
188
- * @dev retrieve the permission required based on the data key to be set on the `controlledContract`.
189
- * @param controlledContract the address of the ERC725Y contract where the data key is verified.
190
- * @param inputDataKey the data key to set on the `controlledContract`. Can be related to LSP6 Permissions, LSP1 Delegate or LSP17 Extensions.
191
- * @param inputDataValue the data value to set for the `inputDataKey`.
192
- * @return the permission required to set the `inputDataKey` on the `controlledContract`.
193
- */
194
- function _getPermissionRequiredToSetDataKey(
195
- address controlledContract,
196
- bytes32 controllerPermissions,
197
- bytes32 inputDataKey,
198
- bytes memory inputDataValue
199
- ) internal view virtual returns (bytes32) {
200
- // AddressPermissions[] or AddressPermissions[index]
201
- if (bytes16(inputDataKey) == _LSP6KEY_ADDRESSPERMISSIONS_ARRAY_PREFIX) {
202
- // this is our best attempt to save gas to avoid reading the `target` storage multiple times
203
- // to know if we need the permission `ADDCONTROLLER` or `EDITPERMISSIONS`.
204
- // Even if `getData(...)` is `view`, multiple external calls to fetch values from storage add to the total gas used.
205
- bool hasBothAddControllerAndEditPermissions = controllerPermissions
206
- .hasPermission(
207
- _PERMISSION_ADDCONTROLLER | _PERMISSION_EDITPERMISSIONS
208
- );
209
-
210
- return
211
- _getPermissionToSetPermissionsArray(
212
- controlledContract,
213
- inputDataKey,
214
- inputDataValue,
215
- hasBothAddControllerAndEditPermissions
216
- );
217
-
218
- // AddressPermissions:...
219
- } else if (bytes6(inputDataKey) == _LSP6KEY_ADDRESSPERMISSIONS_PREFIX) {
220
- // same as above, save gas by avoiding redundants or unecessary external calls to fetch values from the `target` storage.
221
- bool hasBothAddControllerAndEditPermissions = controllerPermissions
222
- .hasPermission(
223
- _PERMISSION_ADDCONTROLLER | _PERMISSION_EDITPERMISSIONS
224
- );
225
-
226
- // AddressPermissions:Permissions:<address>
227
- if (
228
- bytes12(inputDataKey) ==
229
- _LSP6KEY_ADDRESSPERMISSIONS_PERMISSIONS_PREFIX
230
- ) {
231
- // CHECK that `dataValue` contains exactly 32 bytes, which is the required length for a permission BitArray
232
- if (inputDataValue.length != 32 && inputDataValue.length != 0) {
233
- revert InvalidDataValuesForDataKeys(
234
- inputDataKey,
235
- inputDataValue
236
- );
237
- }
238
-
239
- // controller already has the permissions needed. Do not run internal function.
240
- if (hasBothAddControllerAndEditPermissions) return (bytes32(0));
241
-
242
- return
243
- _getPermissionToSetControllerPermissions(
244
- controlledContract,
245
- inputDataKey
246
- );
247
-
248
- // AddressPermissions:AllowedCalls:<address>
249
- } else if (
250
- bytes12(inputDataKey) ==
251
- _LSP6KEY_ADDRESSPERMISSIONS_ALLOWEDCALLS_PREFIX
252
- ) {
253
- return
254
- _getPermissionToSetAllowedCalls(
255
- controlledContract,
256
- inputDataKey,
257
- inputDataValue,
258
- hasBothAddControllerAndEditPermissions
259
- );
260
-
261
- // AddressPermissions:AllowedERC725YKeys:<address>
262
- } else if (
263
- bytes12(inputDataKey) ==
264
- _LSP6KEY_ADDRESSPERMISSIONS_AllowedERC725YDataKeys_PREFIX
265
- ) {
266
- return
267
- _getPermissionToSetAllowedERC725YDataKeys(
268
- controlledContract,
269
- inputDataKey,
270
- inputDataValue,
271
- hasBothAddControllerAndEditPermissions
272
- );
273
-
274
- // if the first 6 bytes of the input data key are "AddressPermissions:..." but did not match
275
- // with anything above, this is not a standard LSP6 permission data key so we revert.
276
- } else {
277
- /**
278
- * @dev more permissions types starting with `AddressPermissions:...` can be implemented by overriding this function.
279
- *
280
- * // AddressPermissions:MyCustomPermissions:<address>
281
- * bytes10 CUSTOM_PERMISSION_PREFIX = 0x4b80742de2bf9e659ba4
282
- *
283
- * if (bytes10(dataKey) == CUSTOM_PERMISSION_PREFIX) {
284
- * // custom logic
285
- * }
286
- *
287
- * super._getPermissionRequiredToSetDataKey(...)
288
- */
289
- revert NotRecognisedPermissionKey(inputDataKey);
290
- }
291
-
292
- // LSP1UniversalReceiverDelegate or LSP1UniversalReceiverDelegate:<typeId>
293
- } else if (
294
- inputDataKey == _LSP1_UNIVERSAL_RECEIVER_DELEGATE_KEY ||
295
- bytes12(inputDataKey) == _LSP1_UNIVERSAL_RECEIVER_DELEGATE_PREFIX
296
- ) {
297
- // CHECK that `dataValue` contains exactly 20 bytes, which corresponds to an address for a LSP1 Delegate contract
298
- if (inputDataValue.length != 20 && inputDataValue.length != 0) {
299
- revert InvalidDataValuesForDataKeys(
300
- inputDataKey,
301
- inputDataValue
302
- );
303
- }
304
-
305
- // same as above. If controller has both permissions, do not read the `target` storage
306
- // to save gas by avoiding an extra external `view` call.
307
- if (
308
- controllerPermissions.hasPermission(
309
- _PERMISSION_ADDUNIVERSALRECEIVERDELEGATE |
310
- _PERMISSION_CHANGEUNIVERSALRECEIVERDELEGATE
311
- )
312
- ) {
313
- return bytes32(0);
314
- }
315
-
316
- return
317
- _getPermissionToSetLSP1Delegate(
318
- controlledContract,
319
- inputDataKey
320
- );
321
-
322
- // LSP17Extension:<bytes4>
323
- } else if (bytes12(inputDataKey) == _LSP17_EXTENSION_PREFIX) {
324
- // CHECK that `dataValue` contains exactly 20 or 21 bytes (if setting to forward value), which corresponds to an address for a LSP17 Extension
325
- if (
326
- inputDataValue.length != 20 &&
327
- inputDataValue.length != 21 &&
328
- inputDataValue.length != 0
329
- ) {
330
- revert InvalidDataValuesForDataKeys(
331
- inputDataKey,
332
- inputDataValue
333
- );
334
- }
335
-
336
- // reverts when the address of the Key Manager is being set as extensions for lsp20 functions
337
- bytes4 selector = bytes4(inputDataKey << 96);
338
-
339
- if (
340
- (selector == ILSP20.lsp20VerifyCall.selector ||
341
- selector == ILSP20.lsp20VerifyCallResult.selector)
342
- ) {
343
- if (address(bytes20(inputDataValue)) == address(this)) {
344
- revert KeyManagerCannotBeSetAsExtensionForLSP20Functions();
345
- }
346
- }
347
-
348
- // same as above. If controller has both permissions, do not read the `target` storage
349
- // to save gas by avoiding an extra external `view` call.
350
- if (
351
- controllerPermissions.hasPermission(
352
- _PERMISSION_ADDEXTENSIONS | _PERMISSION_CHANGEEXTENSIONS
353
- )
354
- ) {
355
- return bytes32(0);
356
- }
357
-
358
- return
359
- _getPermissionToSetLSP17Extension(
360
- controlledContract,
361
- inputDataKey
362
- );
363
- } else {
364
- return _PERMISSION_SETDATA;
365
- }
366
- }
367
-
368
- /**
369
- * @dev retrieve the permission required to update the `AddressPermissions[]` array data key defined in LSP6.
370
- * @param controlledContract the address of the ERC725Y contract where the data key is verified.
371
- * @param inputDataKey either `AddressPermissions[]` (array length) or `AddressPermissions[index]` (array index)
372
- * @param inputDataValue the updated value for the `inputDataKey`. MUST be:
373
- * - a `uint256` for `AddressPermissions[]` (array length)
374
- * - an `address` or `0x` for `AddressPermissions[index]` (array entry).
375
- *
376
- * @return either ADD or CHANGE PERMISSIONS.
377
- */
378
- function _getPermissionToSetPermissionsArray(
379
- address controlledContract,
380
- bytes32 inputDataKey,
381
- bytes memory inputDataValue,
382
- bool hasBothAddControllerAndEditPermissions
383
- ) internal view virtual returns (bytes32) {
384
- // AddressPermissions[] -> array length
385
- if (inputDataKey == _LSP6KEY_ADDRESSPERMISSIONS_ARRAY) {
386
- // CHECK that `dataValue` is exactly 16 bytes long or `0x` (= not set), as the array length of `AddressPermissions[]` MUST be a `uint128` value.
387
- if (inputDataValue.length != 16 && inputDataValue.length != 0) {
388
- revert InvalidDataValuesForDataKeys(
389
- inputDataKey,
390
- inputDataValue
391
- );
392
- }
393
-
394
- // if the controller already has both permissions from one of the two required,
395
- // No permission required as CHECK is already done. We don't need to read `target` storage.
396
- if (hasBothAddControllerAndEditPermissions) return bytes32(0);
397
-
398
- uint128 newLength = uint128(bytes16(inputDataValue));
399
-
400
- return
401
- newLength >
402
- uint128(
403
- bytes16(
404
- ERC725Y(controlledContract).getData(inputDataKey)
405
- )
406
- )
407
- ? _PERMISSION_ADDCONTROLLER
408
- : _PERMISSION_EDITPERMISSIONS;
409
- }
410
-
411
- // AddressPermissions[index] -> array index
412
-
413
- // CHECK that we either ADD an address (20 bytes long) or REMOVE an address (0x)
414
- if (inputDataValue.length != 0 && inputDataValue.length != 20) {
415
- revert InvalidDataValuesForDataKeys(inputDataKey, inputDataValue);
416
- }
417
-
418
- // if the controller already has both permissions from one of the two required below,
419
- // No permission required as CHECK is already done. We don't need to read `target` storage.
420
- if (hasBothAddControllerAndEditPermissions) return bytes32(0);
421
-
422
- return
423
- ERC725Y(controlledContract).getData(inputDataKey).length == 0
424
- ? _PERMISSION_ADDCONTROLLER
425
- : _PERMISSION_EDITPERMISSIONS;
426
- }
427
-
428
- /**
429
- * @dev retrieve the permission required to set permissions for a controller address.
430
- * @param controlledContract the address of the ERC725Y contract where the data key is verified.
431
- * @param inputPermissionDataKey `AddressPermissions:Permissions:<controller-address>`.
432
- * @return either ADD or CHANGE PERMISSIONS.
433
- */
434
- function _getPermissionToSetControllerPermissions(
435
- address controlledContract,
436
- bytes32 inputPermissionDataKey
437
- ) internal view virtual returns (bytes32) {
438
- // extract the address of the controller from the data key `AddressPermissions:Permissions:<controller>`
439
- address controller = address(bytes20(inputPermissionDataKey << 96));
440
-
441
- bytes32 controllerPermissions = ERC725Y(controlledContract)
442
- .getPermissionsFor(controller);
443
-
444
- return
445
- // if there is nothing stored under the data key, we are trying to ADD a new controller.
446
- // if there are already some permissions set under the data key, we are trying to CHANGE the permissions of a controller.
447
- controllerPermissions == bytes32(0)
448
- ? _PERMISSION_ADDCONTROLLER
449
- : _PERMISSION_EDITPERMISSIONS;
450
- }
451
-
452
- /**
453
- * @dev Retrieve the permission required to set some AllowedCalls for a controller.
454
- * @param controlledContract The address of the ERC725Y contract from which to fetch the value of `dataKey`.
455
- * @param dataKey A data key ion the format `AddressPermissions:AllowedCalls:<controller-address>`.
456
- * @param dataValue The updated value for the `dataKey`. MUST be a bytes32[CompactBytesArray] of Allowed Calls.
457
- * @return Either ADD or EDIT PERMISSIONS.
458
- */
459
- function _getPermissionToSetAllowedCalls(
460
- address controlledContract,
461
- bytes32 dataKey,
462
- bytes memory dataValue,
463
- bool hasBothAddControllerAndEditPermissions
464
- ) internal view virtual returns (bytes32) {
465
- if (!LSP6Utils.isCompactBytesArrayOfAllowedCalls(dataValue)) {
466
- revert InvalidEncodedAllowedCalls(dataValue);
467
- }
468
-
469
- // if the controller already has both permissions from one of the two required below,
470
- // No permission required as CHECK is already done. We don't need to read `target` storage.
471
- if (hasBothAddControllerAndEditPermissions) return bytes32(0);
472
-
473
- // extract the address of the controller from the data key `AddressPermissions:AllowedCalls:<controller>`
474
- address controller = address(bytes20(dataKey << 96));
475
-
476
- // if the controller exists and has some permissions set, this is considered as EDIT a "sub-set" of its permissions.
477
- // (even if the controller does not have any allowed calls set).
478
- return
479
- ERC725Y(controlledContract).getPermissionsFor(controller) ==
480
- bytes32(0)
481
- ? _PERMISSION_ADDCONTROLLER
482
- : _PERMISSION_EDITPERMISSIONS;
483
- }
484
-
485
- /**
486
- * @dev Retrieve the permission required to set some Allowed ERC725Y Data Keys for a controller.
487
- * @param controlledContract the address of the ERC725Y contract from which to fetch the value of `dataKey`.
488
- * @param dataKey A data key in the format `AddressPermissions:AllowedERC725YDataKeys:<controller-address>`.
489
- * @param dataValue The updated value for the `dataKey`. MUST be a bytes[CompactBytesArray] of Allowed ERC725Y Data Keys.
490
- * @return Either ADD or EDIT PERMISSIONS.
491
- */
492
- function _getPermissionToSetAllowedERC725YDataKeys(
493
- address controlledContract,
494
- bytes32 dataKey,
495
- bytes memory dataValue,
496
- bool hasBothAddControllerAndEditPermissions
497
- ) internal view virtual returns (bytes32) {
498
- if (!LSP6Utils.isCompactBytesArrayOfAllowedERC725YDataKeys(dataValue)) {
499
- revert InvalidEncodedAllowedERC725YDataKeys(
500
- dataValue,
501
- "couldn't VALIDATE the data value"
502
- );
503
- }
504
-
505
- // if the controller already has both permissions from one of the two required below,
506
- // CHECK is already done. We don't need to read `target` storage.
507
- if (hasBothAddControllerAndEditPermissions) return bytes32(0);
508
-
509
- // extract the address of the controller from the data key `AddressPermissions:AllowedERC725YDataKeys:<controller>`
510
- address controller = address(bytes20(dataKey << 96));
511
-
512
- // if the controller exists and has some permissions set, this is considered as EDIT a "sub-set" of its permissions.
513
- // (even if the controller does not have any allowed ERC725Y data keys set).
514
- return
515
- ERC725Y(controlledContract).getPermissionsFor(controller) ==
516
- bytes32(0)
517
- ? _PERMISSION_ADDCONTROLLER
518
- : _PERMISSION_EDITPERMISSIONS;
519
- }
520
-
521
- /**
522
- * @dev retrieve the permission required to either add or change the address
523
- * of a LSP1 Universal Receiver Delegate stored under a specific LSP1 data key.
524
- * @param controlledContract the address of the ERC725Y contract where the data key is verified.
525
- * @param lsp1DelegateDataKey either the data key for the default `LSP1UniversalReceiverDelegate`,
526
- * or a data key for a specific `LSP1UniversalReceiverDelegate:<typeId>`, starting with `_LSP1_UNIVERSAL_RECEIVER_DELEGATE_PREFIX`.
527
- * @return either ADD or CHANGE UNIVERSALRECEIVERDELEGATE.
528
- */
529
- function _getPermissionToSetLSP1Delegate(
530
- address controlledContract,
531
- bytes32 lsp1DelegateDataKey
532
- ) internal view virtual returns (bytes32) {
533
- return
534
- ERC725Y(controlledContract).getData(lsp1DelegateDataKey).length == 0
535
- ? _PERMISSION_ADDUNIVERSALRECEIVERDELEGATE
536
- : _PERMISSION_CHANGEUNIVERSALRECEIVERDELEGATE;
537
- }
538
-
539
- /**
540
- * @dev Verify if `controller` has the required permissions to either add or change the address
541
- * of an LSP0 Extension stored under a specific LSP17Extension data key
542
- * @param controlledContract the address of the ERC725Y contract where the data key is verified.
543
- * @param lsp17ExtensionDataKey the dataKey to set with `_LSP17_EXTENSION_PREFIX` as prefix.
544
- */
545
- function _getPermissionToSetLSP17Extension(
546
- address controlledContract,
547
- bytes32 lsp17ExtensionDataKey
548
- ) internal view virtual returns (bytes32) {
549
- return
550
- ERC725Y(controlledContract).getData(lsp17ExtensionDataKey).length ==
551
- 0
552
- ? _PERMISSION_ADDEXTENSIONS
553
- : _PERMISSION_CHANGEEXTENSIONS;
554
- }
555
-
556
- /**
557
- * @dev Verify if the `inputKey` is present in the list of `allowedERC725KeysCompacted` for the `controllerAddress`.
558
- * @param controllerAddress the address of the controller.
559
- * @param inputDataKey the data key to verify against the allowed ERC725Y Data Keys for the `controllerAddress`.
560
- * @param allowedERC725YDataKeysCompacted a CompactBytesArray of allowed ERC725Y Data Keys for the `controllerAddress`.
561
- */
562
- function _verifyAllowedERC725YSingleKey(
563
- address controllerAddress,
564
- bytes32 inputDataKey,
565
- bytes memory allowedERC725YDataKeysCompacted
566
- ) internal pure virtual {
567
- if (allowedERC725YDataKeysCompacted.length == 0)
568
- revert NoERC725YDataKeysAllowed(controllerAddress);
569
-
570
- /**
571
- * The pointer will always land on the length of each bytes value:
572
- *
573
- * ↓↓↓↓
574
- * 0003 a00000
575
- * 0005 fff83a0011
576
- * 0020 aa0000000000000000000000000000000000000000000000000000000000cafe
577
- * 0012 bb000000000000000000000000000000beef
578
- * 0019 cc00000000000000000000000000000000000000000000deed
579
- * ↑↑↑↑
580
- *
581
- */
582
- uint256 pointer;
583
-
584
- // information extracted from each Allowed ERC725Y Data Key.
585
- uint256 length;
586
- bytes32 allowedKey;
587
- bytes32 mask;
588
-
589
- /**
590
- * iterate over each data key and update the `pointer` variable with the index where to find the length of each data key.
591
- *
592
- * 0x 0003 a00000 0003 fff83a 0020 aa00...00cafe
593
- * ↑↑↑↑ ↑↑↑↑ ↑↑↑↑
594
- * first | second | third
595
- * length | length | length
596
- */
597
- while (pointer < allowedERC725YDataKeysCompacted.length) {
598
- // save the length of the allowed data key to calculate the `mask`.
599
- length = uint16(
600
- bytes2(
601
- abi.encodePacked(
602
- allowedERC725YDataKeysCompacted[pointer],
603
- allowedERC725YDataKeysCompacted[pointer + 1]
604
- )
605
- )
606
- );
607
-
608
- /**
609
- * The length of a data key is 32 bytes.
610
- * Therefore we can have a fixed allowed data key which has
611
- * a length of 32 bytes or we can have a dynamic data key
612
- * which can have a length from 1 up to 31 bytes.
613
- */
614
- if (length == 0 || length > 32) {
615
- revert InvalidEncodedAllowedERC725YDataKeys(
616
- allowedERC725YDataKeysCompacted,
617
- "couldn't DECODE from storage"
618
- );
619
- }
620
-
621
- /**
622
- * The bitmask discard the last `32 - length` bytes of the input data key via ANDing &
623
- * It is used to compare only the relevant parts of each input data key against dynamic allowed data keys.
624
- *
625
- * E.g.:
626
- *
627
- * allowed data key = 0xa00000
628
- *
629
- * compare this part
630
- * vvvvvv
631
- * input data key = 0xa00000cafecafecafecafecafecafecafe000000000000000000000011223344
632
- *
633
- * & discard this part
634
- * vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
635
- * mask = 0xffffff0000000000000000000000000000000000000000000000000000000000
636
- */
637
- mask =
638
- bytes32(
639
- 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
640
- ) <<
641
- (8 * (32 - length));
642
-
643
- /*
644
- * transform the allowed data key situated from `pointer + 1` until `pointer + 1 + length` to a bytes32 value.
645
- * E.g. 0xfff83a -> 0xfff83a0000000000000000000000000000000000000000000000000000000000
646
- */
647
- // solhint-disable-next-line no-inline-assembly
648
- assembly {
649
- // the first 32 bytes word in memory (where allowedERC725YDataKeysCompacted is stored)
650
- // correspond to the total number of bytes in `allowedERC725YDataKeysCompacted`
651
- let offset := add(add(pointer, 2), 32)
652
- let memoryAt := mload(
653
- add(allowedERC725YDataKeysCompacted, offset)
654
- )
655
- // MLOAD loads 32 bytes word, so we need to keep only the `length` number of bytes that makes up the allowed data key.
656
- allowedKey := and(memoryAt, mask)
657
- }
658
-
659
- if (allowedKey == (inputDataKey & mask)) return;
660
-
661
- // move the pointer to the index of the next allowed data key
662
- unchecked {
663
- pointer = pointer + (length + 2);
664
- }
665
- }
666
-
667
- revert NotAllowedERC725YDataKey(controllerAddress, inputDataKey);
668
- }
669
-
670
- /**
671
- * @dev Verify if all the `inputDataKeys` are present in the list of `allowedERC725KeysCompacted` of the `controllerAddress`.
672
- * @param controllerAddress the address of the controller.
673
- * @param inputDataKeys the data keys to verify against the allowed ERC725Y Data Keys of the `controllerAddress`.
674
- * @param allowedERC725YDataKeysCompacted a CompactBytesArray of allowed ERC725Y Data Keys of the `controllerAddress`.
675
- * @param validatedInputKeysList an array of booleans to store the result of the verification of each data keys checked.
676
- * @param allowedDataKeysFound the number of data keys that were previously validated for other permissions like `ADDCONTROLLER`, `EDITPERMISSIONS`, etc...
677
- */
678
- function _verifyAllowedERC725YDataKeys(
679
- address controllerAddress,
680
- bytes32[] memory inputDataKeys,
681
- bytes memory allowedERC725YDataKeysCompacted,
682
- bool[] memory validatedInputKeysList,
683
- uint256 allowedDataKeysFound
684
- ) internal pure virtual {
685
- if (allowedERC725YDataKeysCompacted.length == 0)
686
- revert NoERC725YDataKeysAllowed(controllerAddress);
687
-
688
- // cache the input data keys from the start
689
- uint256 inputKeysLength = inputDataKeys.length;
690
-
691
- /**
692
- * The pointer will always land on the length of each bytes value:
693
- *
694
- * ↓↓↓↓
695
- * 0003 a00000
696
- * 0005 fff83a0011
697
- * 0020 aa0000000000000000000000000000000000000000000000000000000000cafe
698
- * 0012 bb000000000000000000000000000000beef
699
- * 0019 cc00000000000000000000000000000000000000000000deed
700
- * ↑↑↑↑
701
- *
702
- */
703
- uint256 pointer;
704
-
705
- // information extracted from each Allowed ERC725Y Data Key.
706
- uint256 length;
707
- bytes32 allowedKey;
708
- bytes32 mask;
709
-
710
- /**
711
- * iterate over each data key and update the `pointer` variable with the index where to find the length of each data key.
712
- *
713
- * 0x 0003 a00000 0003 fff83a 0020 aa00...00cafe
714
- * ↑↑↑↑ ↑↑↑↑ ↑↑↑↑
715
- * first | second | third
716
- * length | length | length
717
- */
718
- while (pointer < allowedERC725YDataKeysCompacted.length) {
719
- // save the length of the allowed data key to calculate the `mask`.
720
- length = uint16(
721
- bytes2(
722
- abi.encodePacked(
723
- allowedERC725YDataKeysCompacted[pointer],
724
- allowedERC725YDataKeysCompacted[pointer + 1]
725
- )
726
- )
727
- );
728
-
729
- /**
730
- * The length of a data key is 32 bytes.
731
- * Therefore we can have a fixed allowed data key which has
732
- * a length of 32 bytes or we can have a dynamic data key
733
- * which can have a length from 1 up to 31 bytes.
734
- */
735
- if (length == 0 || length > 32) {
736
- revert InvalidEncodedAllowedERC725YDataKeys(
737
- allowedERC725YDataKeysCompacted,
738
- "couldn't DECODE from storage"
739
- );
740
- }
741
-
742
- /**
743
- * The bitmask discard the last `32 - length` bytes of the input data key via ANDing &
744
- * It is used to compare only the relevant parts of each input data key against dynamic allowed data keys.
745
- *
746
- * E.g.:
747
- *
748
- * allowed data key = 0xa00000
749
- *
750
- * compare this part
751
- * vvvvvv
752
- * input data key = 0xa00000cafecafecafecafecafecafecafe000000000000000000000011223344
753
- *
754
- * & discard this part
755
- * vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
756
- * mask = 0xffffff0000000000000000000000000000000000000000000000000000000000
757
- */
758
- mask =
759
- bytes32(
760
- 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
761
- ) <<
762
- (8 * (32 - length));
763
-
764
- /*
765
- * transform the allowed data key situated from `pointer + 1` until `pointer + 1 + length` to a bytes32 value.
766
- * E.g. 0xfff83a -> 0xfff83a0000000000000000000000000000000000000000000000000000000000
767
- */
768
- // solhint-disable-next-line no-inline-assembly
769
- assembly {
770
- // the first 32 bytes word in memory (where allowedERC725YDataKeysCompacted is stored)
771
- // correspond to the length of allowedERC725YDataKeysCompacted (= total number of bytes)
772
- let offset := add(add(pointer, 2), 32)
773
- let memoryAt := mload(
774
- add(allowedERC725YDataKeysCompacted, offset)
775
- )
776
- allowedKey := and(memoryAt, mask)
777
- }
778
-
779
- /**
780
- * Iterate over the `inputDataKeys` to check them against the allowed data keys.
781
- * This until we have validated them all.
782
- */
783
- for (uint256 ii; ii < inputKeysLength; ) {
784
- // if the input data key has been marked as allowed previously,
785
- // SKIP it and move to the next input data key.
786
- if (validatedInputKeysList[ii]) {
787
- unchecked {
788
- ++ii;
789
- }
790
- continue;
791
- }
792
-
793
- // CHECK if the input data key is allowed.
794
- if ((inputDataKeys[ii] & mask) == allowedKey) {
795
- // if the input data key is allowed, mark it as allowed
796
- // and increment the number of allowed keys found.
797
- validatedInputKeysList[ii] = true;
798
-
799
- unchecked {
800
- allowedDataKeysFound++;
801
- }
802
-
803
- // Continue checking until all the inputKeys` have been found.
804
- if (allowedDataKeysFound == inputKeysLength) return;
805
- }
806
-
807
- unchecked {
808
- ++ii;
809
- }
810
- }
811
-
812
- // Move the pointer to the next AllowedERC725YKey
813
- unchecked {
814
- pointer = pointer + (length + 2);
815
- }
816
- }
817
-
818
- // if we did not find all the input data keys, search for the first not allowed data key to revert.
819
- for (uint256 jj; jj < inputKeysLength; ) {
820
- if (!validatedInputKeysList[jj]) {
821
- revert NotAllowedERC725YDataKey(
822
- controllerAddress,
823
- inputDataKeys[jj]
824
- );
825
- }
826
-
827
- unchecked {
828
- jj++;
829
- }
830
- }
831
- }
832
-
833
- /**
834
- * @dev revert if `controller`'s `addressPermissions` doesn't contain `permissionsRequired`
835
- * @param controller the caller address
836
- * @param addressPermissions the caller's permissions BitArray
837
- * @param permissionRequired the required permission
838
- */
839
- function _requirePermissions(
840
- address controller,
841
- bytes32 addressPermissions,
842
- bytes32 permissionRequired
843
- ) internal pure virtual {
844
- if (!LSP6Utils.hasPermission(addressPermissions, permissionRequired)) {
845
- string memory permissionErrorString = LSP6Utils.getPermissionName(
846
- permissionRequired
847
- );
848
- revert NotAuthorised(controller, permissionErrorString);
849
- }
850
- }
851
- }
4
+ import "@lukso/lsp6-contracts/contracts/LSP6Modules/LSP6SetDataModule.sol";