@lukso/lsp-smart-contracts 0.5.0 → 0.6.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 (138) hide show
  1. package/README.md +29 -9
  2. package/artifacts/LSP0ERC725Account.json +392 -0
  3. package/artifacts/LSP0ERC725AccountInit.json +433 -0
  4. package/artifacts/LSP1UniversalReceiverDelegateUP.json +2 -7
  5. package/artifacts/LSP1UniversalReceiverDelegateVault.json +2 -7
  6. package/artifacts/LSP4Compatibility.json +195 -0
  7. package/artifacts/LSP4DigitalAssetMetadata.json +169 -0
  8. package/artifacts/LSP4DigitalAssetMetadataInit.json +231 -0
  9. package/artifacts/LSP6KeyManager.json +34 -28
  10. package/artifacts/LSP6KeyManagerInit.json +42 -23
  11. package/artifacts/LSP7CappedSupply.json +133 -8
  12. package/artifacts/LSP7CappedSupplyInit.json +160 -32
  13. package/artifacts/LSP7CompatibilityForERC20.json +125 -10
  14. package/artifacts/LSP7CompatibilityForERC20Init.json +727 -0
  15. package/artifacts/LSP7DigitalAsset.json +125 -10
  16. package/artifacts/LSP7DigitalAssetInit.json +149 -31
  17. package/artifacts/LSP7Mintable.json +126 -11
  18. package/artifacts/LSP7MintableInit.json +150 -32
  19. package/artifacts/LSP8CappedSupply.json +134 -8
  20. package/artifacts/LSP8CappedSupplyInit.json +169 -17
  21. package/artifacts/LSP8CompatibilityForERC721.json +126 -10
  22. package/artifacts/LSP8CompatibilityForERC721Init.json +873 -0
  23. package/artifacts/LSP8IdentifiableDigitalAsset.json +126 -10
  24. package/artifacts/LSP8IdentifiableDigitalAssetInit.json +158 -16
  25. package/artifacts/LSP8Mintable.json +138 -11
  26. package/artifacts/LSP8MintableInit.json +170 -17
  27. package/artifacts/LSP9Vault.json +368 -0
  28. package/artifacts/LSP9VaultInit.json +409 -0
  29. package/artifacts/UniversalFactory.json +127 -0
  30. package/artifacts/UniversalProfile.json +65 -14
  31. package/artifacts/UniversalProfileInit.json +104 -14
  32. package/artifacts/UniversalReceiverAddressStore.json +204 -0
  33. package/constants.js +352 -0
  34. package/contracts/Custom/ClaimOwnership.sol +31 -0
  35. package/contracts/Custom/ERC165Checker.sol +130 -0
  36. package/contracts/Custom/IClaimOwnership.sol +10 -0
  37. package/contracts/Factories/UniversalFactory.sol +155 -0
  38. package/contracts/LSP0ERC725Account/LSP0Constants.sol +5 -9
  39. package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +6 -8
  40. package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +89 -46
  41. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +5 -5
  42. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +6 -21
  43. package/contracts/LSP10ReceivedVaults/LSP10Constants.sol +10 -0
  44. package/contracts/LSP1UniversalReceiver/LSP1Constants.sol +2 -8
  45. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/Handling/TokenAndVaultHandling.sol +59 -185
  46. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +48 -6
  47. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/Handling/TokenHandling.sol +45 -92
  48. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +39 -6
  49. package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +47 -0
  50. package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +205 -0
  51. package/contracts/LSP3UniversalProfile/LSP3Constants.sol +11 -0
  52. package/contracts/LSP4DigitalAssetMetadata/ILSP4Compatibility.sol +1 -1
  53. package/contracts/LSP4DigitalAssetMetadata/LSP4Compatibility.sol +5 -14
  54. package/contracts/LSP4DigitalAssetMetadata/LSP4Constants.sol +10 -4
  55. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol +11 -8
  56. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInit.sol +9 -13
  57. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +14 -20
  58. package/contracts/LSP5ReceivedAssets/LSP5Constants.sol +10 -0
  59. package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +157 -0
  60. package/contracts/LSP6KeyManager/ILSP6KeyManager.sol +21 -18
  61. package/contracts/LSP6KeyManager/LSP6Constants.sol +61 -25
  62. package/contracts/LSP6KeyManager/LSP6Errors.sol +37 -0
  63. package/contracts/LSP6KeyManager/LSP6KeyManager.sol +3 -4
  64. package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +429 -332
  65. package/contracts/LSP6KeyManager/LSP6KeyManagerInit.sol +6 -5
  66. package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +7 -15
  67. package/contracts/LSP6KeyManager/LSP6Utils.sol +111 -0
  68. package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +3 -8
  69. package/contracts/LSP7DigitalAsset/LSP7Constants.sol +5 -4
  70. package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +23 -9
  71. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +70 -94
  72. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInit.sol +8 -9
  73. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +25 -23
  74. package/contracts/LSP7DigitalAsset/LSP7Errors.sol +23 -0
  75. package/contracts/LSP7DigitalAsset/extensions/ILSP7CappedSupply.sol +1 -1
  76. package/contracts/LSP7DigitalAsset/extensions/ILSP7CompatibilityForERC20.sol +2 -4
  77. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupply.sol +8 -7
  78. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyCore.sol +14 -12
  79. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInit.sol +3 -8
  80. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInitAbstract.sol +9 -17
  81. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibilityForERC20.sol +33 -21
  82. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibilityForERC20Core.sol +20 -39
  83. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibilityForERC20Init.sol +3 -3
  84. package/contracts/LSP7DigitalAsset/extensions/LSP7CompatibilityForERC20InitAbstract.sol +39 -28
  85. package/contracts/LSP7DigitalAsset/{extensions → presets}/ILSP7Mintable.sol +1 -1
  86. package/contracts/LSP7DigitalAsset/{extensions → presets}/LSP7Mintable.sol +4 -3
  87. package/contracts/LSP7DigitalAsset/{extensions → presets}/LSP7MintableCore.sol +5 -5
  88. package/contracts/LSP7DigitalAsset/{extensions → presets}/LSP7MintableInit.sol +3 -2
  89. package/contracts/LSP7DigitalAsset/presets/LSP7MintableInitAbstract.sol +34 -0
  90. package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +5 -16
  91. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol +6 -3
  92. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol +22 -0
  93. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +23 -10
  94. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +102 -135
  95. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInit.sol +8 -11
  96. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +24 -21
  97. package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CappedSupply.sol +1 -1
  98. package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8CompatibilityForERC721.sol +3 -11
  99. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupply.sol +9 -15
  100. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyCore.sol +14 -12
  101. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInit.sol +3 -8
  102. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInitAbstract.sol +11 -20
  103. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibilityForERC721.sol +41 -33
  104. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibilityForERC721Core.sol +27 -84
  105. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibilityForERC721Init.sol +4 -6
  106. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibilityForERC721InitAbstract.sol +40 -41
  107. package/contracts/LSP8IdentifiableDigitalAsset/{extensions → presets}/ILSP8Mintable.sol +1 -1
  108. package/contracts/LSP8IdentifiableDigitalAsset/{extensions → presets}/LSP8Mintable.sol +4 -3
  109. package/contracts/LSP8IdentifiableDigitalAsset/{extensions → presets}/LSP8MintableCore.sol +5 -8
  110. package/contracts/LSP8IdentifiableDigitalAsset/{extensions → presets}/LSP8MintableInit.sol +4 -3
  111. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +35 -0
  112. package/contracts/LSP9Vault/LSP9Constants.sol +13 -4
  113. package/contracts/LSP9Vault/LSP9Vault.sol +15 -37
  114. package/contracts/LSP9Vault/LSP9VaultCore.sol +101 -82
  115. package/contracts/LSP9Vault/LSP9VaultInit.sol +5 -4
  116. package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +15 -45
  117. package/contracts/Legacy/Registries/AddressRegistry.sol +43 -0
  118. package/contracts/Legacy/Registries/AddressRegistryRequiresERC725.sol +33 -0
  119. package/contracts/Legacy/UniversalReceiverAddressStore.sol +59 -0
  120. package/contracts/UniversalProfile.sol +10 -5
  121. package/contracts/UniversalProfileInit.sol +5 -4
  122. package/contracts/UniversalProfileInitAbstract.sol +14 -20
  123. package/contracts/Utils/UtilsLib.sol +47 -11
  124. package/package.json +23 -9
  125. package/artifacts/LSP1UniversalReceiverDelegateUPInit.json +0 -66
  126. package/artifacts/LSP1UniversalReceiverDelegateVaultInit.json +0 -66
  127. package/constants.ts +0 -356
  128. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUPCore.sol +0 -52
  129. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUPInit.sol +0 -26
  130. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUPInitAbstract.sol +0 -28
  131. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVaultCore.sol +0 -41
  132. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVaultInit.sol +0 -23
  133. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVaultInitAbstract.sol +0 -25
  134. package/contracts/LSP7DigitalAsset/extensions/LSP7MintableInitAbstract.sol +0 -47
  135. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8MintableInitAbstract.sol +0 -44
  136. package/contracts/Utils/ERC725Utils.sol +0 -169
  137. package/contracts/Utils/LSP2Utils.sol +0 -127
  138. package/contracts/Utils/LSP6Utils.sol +0 -63
package/constants.js ADDED
@@ -0,0 +1,352 @@
1
+ /**
2
+ * Set of constants values as defined in each LUKSO Standards Proposals (LSPs).
3
+ * @see https://github.com/lukso-network/LIPs/tree/main/LSPs
4
+ */
5
+
6
+ // ERC165
7
+ // ----------
8
+
9
+ const INTERFACE_IDS = {
10
+ ERC165: '0x01ffc9a7',
11
+ ERC1271: '0x1626ba7e',
12
+ ERC20: '0x36372b07',
13
+ ERC223: '0x87d43052',
14
+ ERC721: '0x80ac58cd',
15
+ ERC721Metadata: '0x5b5e139f',
16
+ ERC777: '0xe58e113c',
17
+ ERC1155: '0xd9b67a26',
18
+ ERC725X: '0x44c028fe',
19
+ ERC725Y: '0x714df77c',
20
+ LSP0ERC725Account: '0x9a3bfe88',
21
+ LSP1UniversalReceiver: '0x6bb56a14',
22
+ LSP1UniversalReceiverDelegate: '0xc2d7bcc1',
23
+ LSP6KeyManager: '0xc403d48f',
24
+ LSP7DigitalAsset: '0xe33f65c3',
25
+ LSP8IdentifiableDigitalAsset: '0x49399145',
26
+ LSP9Vault: '0x8c1d44f6',
27
+ ClaimOwnership: '0xad7dd9b0',
28
+ };
29
+
30
+ // ERC1271
31
+ // ----------
32
+
33
+ const ERC1271_VALUES = {
34
+ MAGIC_VALUE: '0x1626ba7e',
35
+ FAIL_VALUE: '0xffffffff',
36
+ };
37
+
38
+ // ERC725X
39
+ // ----------
40
+
41
+ const OPERATION_TYPES = {
42
+ CALL: 0,
43
+ CREATE: 1,
44
+ CREATE2: 2,
45
+ STATICCALL: 3,
46
+ DELEGATECALL: 4,
47
+ };
48
+
49
+ // ERC725Y
50
+ // ----------
51
+
52
+ const SupportedStandards = {
53
+ LSP3UniversalProfile: {
54
+ key: '0xeafec4d89fa9619884b60000abe425d64acd861a49b8ddf5c0b6962110481f38',
55
+ value: '0xabe425d6',
56
+ },
57
+ LSP4DigitalAsset: {
58
+ key: '0xeafec4d89fa9619884b60000a4d96624a38f7ac2d8d9a604ecf07c12c77e480c',
59
+ value: '0xa4d96624',
60
+ },
61
+ LSP9Vault: {
62
+ key: '0xeafec4d89fa9619884b600007c0334a14085fefa8b51ae5a40895018882bdb90',
63
+ value: '0x7c0334a1',
64
+ },
65
+ };
66
+
67
+ /**
68
+ * For more infos on the type of each keys
69
+ * @see https://github.com/lukso-network/LIPs/blob/main/LSPs/LSP-2-ERC725YJSONSchema.md
70
+ */
71
+ const ERC725YKeys = {
72
+ LSP0: {
73
+ // keccak256('LSP1UniversalReceiverDelegate')
74
+ LSP1UniversalReceiverDelegate:
75
+ '0x0cfc51aec37c55a4d0b1a65c6255c4bf2fbdf6277f3cc0730c45b828b6db8b47',
76
+ },
77
+ LSP3: {
78
+ // keccak256('LSP3Profile')
79
+ LSP3Profile: '0x5ef83ad9559033e6e941db7d7c495acdce616347d28e90c7ce47cbfcfcad3bc5',
80
+ },
81
+ LSP4: {
82
+ // keccak256('LSP4TokenName')
83
+ LSP4TokenName: '0xdeba1e292f8ba88238e10ab3c7f88bd4be4fac56cad5194b6ecceaf653468af1',
84
+ // keccak256('LSP4TokenSymbol')
85
+ LSP4TokenSymbol: '0x2f0a68ab07768e01943a599e73362a0e17a63a72e94dd2e384d2c1d4db932756',
86
+ // keccak256('LSP4Metadata')
87
+ LSP4Metadata: '0x9afb95cacc9f95858ec44aa8c3b685511002e30ae54415823f406128b85b238e',
88
+ // keccak256('"LSP4Creators[]')
89
+ 'LSP4Creators[]': '0x114bd03b3a46d48759680d81ebb2b414fda7d030a7105a851867accf1c2352e7',
90
+ },
91
+ LSP5: {
92
+ // LSP5ReceivedAssetsMap:<address>
93
+ LSP5ReceivedAssetsMap: '0x812c4334633eb816c80d0000',
94
+ // keccak256('LSP5ReceivedAssets[]')
95
+ 'LSP5ReceivedAssets[]':
96
+ '0x6460ee3c0aac563ccbf76d6e1d07bada78e3a9514e6382b736ed3f478ab7b90b',
97
+ },
98
+ LSP6: {
99
+ // keccak256('AddressPermissions[]')
100
+ 'AddressPermissions[]':
101
+ '0xdf30dba06db6a30e65354d9a64c609861f089545ca58c6b4dbe31a5f338cb0e3',
102
+ // AddressPermissions:Permissions:<address>
103
+ 'AddressPermissions:Permissions': '0x4b80742de2bf82acb3630000',
104
+ // AddressPermissions:AllowedAddresses:<address>
105
+ 'AddressPermissions:AllowedAddresses': '0x4b80742de2bfc6dd6b3c0000',
106
+ // AddressPermissions:AllowedFunctions:<address>
107
+ 'AddressPermissions:AllowedFunctions': '0x4b80742de2bf8efea1e80000',
108
+ // AddressPermissions:AllowedStandards:<address>
109
+ 'AddressPermissions:AllowedStandards': '0x4b80742de2bf3efa94a30000',
110
+ // AddressPermissions:AllowedERC725YKeys:<address>
111
+ 'AddressPermissions:AllowedERC725YKeys': '0x4b80742de2bf90b8b4850000',
112
+ },
113
+ LSP10: {
114
+ // keccak256('LSP10VaultsMap')
115
+ LSP10VaultsMap: '0x192448c3c0f88c7f238c0000',
116
+ // keccak256('LSP10Vaults[]')
117
+ 'LSP10Vaults[]': '0x55482936e01da86729a45d2b87a6b1d3bc582bea0ec00e38bdb340e3af6f9f06',
118
+ },
119
+ LSP12: {
120
+ // LSP12IssuedAssetsMap:<address>
121
+ LSP12IssuedAssetsMap: '0x74ac2555c10b9349e78f0000',
122
+ // keccak256('LSP12IssuedAssets[]')
123
+ 'LSP12IssuedAssets[]': '0x7c8c3416d6cda87cd42c71ea1843df28ac4850354f988d55ee2eaa47b6dc05cd',
124
+ },
125
+ };
126
+
127
+ const BasicUPSetup_Schema = [
128
+ {
129
+ name: 'LSP3Profile',
130
+ key: ERC725YKeys.LSP3['LSP3Profile'],
131
+ keyType: 'Singleton',
132
+ valueContent: 'JSONURL',
133
+ valueType: 'bytes',
134
+ },
135
+ {
136
+ name: 'LSP1UniversalReceiverDelegate',
137
+ key: ERC725YKeys.LSP0['LSP1UniversalReceiverDelegate'],
138
+ keyType: 'Singleton',
139
+ valueContent: 'Address',
140
+ valueType: 'address',
141
+ },
142
+ {
143
+ name: 'LSP12IssuedAssets[]',
144
+ key: ERC725YKeys.LSP12['LSP12IssuedAssets[]'],
145
+ keyType: 'Array',
146
+ valueContent: 'Number',
147
+ valueType: 'uint256',
148
+ },
149
+ ];
150
+
151
+ // LSP6
152
+ // ----------
153
+
154
+ // All Permissions currently exclude DELEGATECALL for security
155
+ const ALL_PERMISSIONS = '0x0000000000000000000000000000000000000000000000000000000000007fbf';
156
+
157
+ // prettier-ignore
158
+ const PERMISSIONS = {
159
+ CHANGEOWNER: "0x0000000000000000000000000000000000000000000000000000000000000001", // .... .... .... 0001
160
+ CHANGEPERMISSIONS: "0x0000000000000000000000000000000000000000000000000000000000000002", // .... .... .... 0010
161
+ ADDPERMISSIONS: "0x0000000000000000000000000000000000000000000000000000000000000004", // .... .... .... 0100
162
+ SETDATA: "0x0000000000000000000000000000000000000000000000000000000000000008", // .... .... .... 1000
163
+ CALL: "0x0000000000000000000000000000000000000000000000000000000000000010", // .... .... 0001 ....
164
+ STATICCALL: "0x0000000000000000000000000000000000000000000000000000000000000020", // .... .... 0010 ....
165
+ DELEGATECALL: "0x0000000000000000000000000000000000000000000000000000000000000040", // .... .... 0100 ....
166
+ DEPLOY: "0x0000000000000000000000000000000000000000000000000000000000000080", // .... .... 1000 ....
167
+ TRANSFERVALUE: "0x0000000000000000000000000000000000000000000000000000000000000100", // .... 0001 .... ....
168
+ SIGN: "0x0000000000000000000000000000000000000000000000000000000000000200", // .... 0010 .... ....
169
+ SUPER_SETDATA: "0x0000000000000000000000000000000000000000000000000000000000000400", // .... 0100 .... ....
170
+ SUPER_TRANSFERVALUE: "0x0000000000000000000000000000000000000000000000000000000000000800", // .... 1000 .... ....
171
+ SUPER_CALL: "0x0000000000000000000000000000000000000000000000000000000000001000", // 0001 .... .... ....
172
+ SUPER_STATICCALL: "0x0000000000000000000000000000000000000000000000000000000000002000", // 0010 .... .... ....
173
+ SUPER_DELEGATECALL: "0x0000000000000000000000000000000000000000000000000000000000004000", // 0100 .... .... ....
174
+ }
175
+
176
+ // ----------
177
+
178
+ const EventSignatures = {
179
+ ERC173: {
180
+ /**
181
+ * event OwnershipTransferred(
182
+ * address indexed previousOwner,
183
+ * address indexed newOwner,
184
+ * );
185
+ *
186
+ * signature = keccak256('OwnershipTransferred(address,address)')
187
+ */
188
+ OwnershipTransfered: '0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0',
189
+ },
190
+ ERC725X: {
191
+ /**
192
+ * event ContractCreated(
193
+ * uint256 indexed _operation,
194
+ * address indexed _contractAddress,
195
+ * uint256 indexed _value
196
+ * );
197
+ *
198
+ * signature = keccak256('ContractCreated(uint256,address,uint256)')
199
+ */
200
+ ContractCreated: '0x01c42bd7e97a66166063b02fce6924e6656b6c2c61966630165095c4fb0b7b2f',
201
+ /**
202
+ * event Executed(
203
+ * uint256 indexed _operation,
204
+ * address indexed _to,
205
+ * uint256 indexed _value,
206
+ * bytes _data
207
+ * );
208
+ *
209
+ * signature = keccak256('Executed(uint256,address,uint256,bytes)')
210
+ */
211
+ Executed: '0x1f920dbda597d7bf95035464170fa58d0a4b57f13a1c315ace6793b9f63688b8',
212
+ },
213
+ ERC725Y: {
214
+ /**
215
+ * event DataChanged(bytes32 indexed key);
216
+ *
217
+ * signature = keccak256('DataChanged(bytes32)')
218
+ */
219
+ DataChanged: '0xcdf4e344c0d23d4cdd0474039d176c55b19d531070dbe17856bfb993a5b5720b',
220
+ },
221
+ // ERC725Account
222
+ LSP0: {
223
+ /**
224
+ * event ValueReceived(
225
+ * address indexed sender,
226
+ * uint256 indexed value
227
+ * );
228
+ *
229
+ * signature = keccak256('ValueReceived(address,uint256)')
230
+ */
231
+ ValueReceived: '0x7e71433ddf847725166244795048ecf3e3f9f35628254ecbf736056664233493',
232
+ },
233
+ LSP1: {
234
+ /**
235
+ * event UniversalReceiver(
236
+ * address indexed from,
237
+ * bytes32 indexed typeId,
238
+ * bytes indexed returnedValue,
239
+ * bytes receivedData
240
+ * );
241
+ *
242
+ * signature = keccak256('UniversalReceiver(address,bytes32,bytes,bytes)')
243
+ */
244
+ UniversalReceiver: '0x8187df79ab47ad16102e7bc8760349a115b3ba9869b8cedd78996f930ac9cac3',
245
+ },
246
+ LSP6: {
247
+ /**
248
+ * event Executed(
249
+ * uint256 indexed _value,
250
+ * bytes _data
251
+ * );
252
+ *
253
+ * signature = keccak256('Executed(uint256,bytes)')
254
+ */
255
+ Executed: '0x2e733a17851169f232b3859260eb3ad2a086afd54e999eb4ea9afb7791702e41',
256
+ },
257
+ LSP7: {
258
+ /**
259
+ * event Transfer(
260
+ * address indexed operator,
261
+ * address indexed from,
262
+ * address indexed to,
263
+ * uint256 amount,
264
+ * bool force,
265
+ * bytes data
266
+ * );
267
+ *
268
+ * signature = keccak256('Transfer(address,address,address,uint256,bool,bytes)')
269
+ */
270
+ Transfer: '0x3997e418d2cef0b3b0e907b1e39605c3f7d32dbd061e82ea5b4a770d46a160a6',
271
+ /**
272
+ * event AuthorizedOperator(
273
+ * address indexed operator,
274
+ * address indexed tokenOwner,
275
+ * uint256 indexed amount
276
+ * );
277
+ *
278
+ * signature = keccak256('AuthorizedOperator(address,address,uint256)')
279
+ */
280
+ AuthorizedOperator: '0xd66aff874162a96578e919097b6f6d153dfd89a5cec41bb331fdb0c4aec16e2c',
281
+ /**
282
+ * event RevokedOperator(
283
+ * address indexed operator,
284
+ * address indexed tokenOwner
285
+ * );
286
+ *
287
+ * signature = keccak256('RevokedOperator(address,address)')
288
+ */
289
+ RevokedOperator: '0x50546e66e5f44d728365dc3908c63bc5cfeeab470722c1677e3073a6ac294aa1',
290
+ },
291
+ LSP8: {
292
+ /**
293
+ * event Transfer(
294
+ * address operator,
295
+ * address indexed from,
296
+ * address indexed to,
297
+ * bytes32 indexed tokenId,
298
+ * bool force,
299
+ * bytes data
300
+ * );
301
+ *
302
+ * signature = keccak256('Transfer(address,address,address,bytes32,bool,bytes)')
303
+ */
304
+ Transfer: 'b333c813a7426a7a11e2b190cad52c44119421594b47f6f32ace6d8c7207b2bf',
305
+ /**
306
+ * event AuthorizedOperator(
307
+ * address indexed operator,
308
+ * address indexed tokenOwner,
309
+ * bytes32 indexed tokenId
310
+ * );
311
+ *
312
+ * signature = keccak256('AuthorizedOperator(address,address,bytes32)')
313
+ */
314
+ AuthorizedOperator: '34b797fc5a526f7bf1d2b5de25f6564fd85ae364e3ee939aee7c1ac27871a988',
315
+ /**
316
+ * event RevokedOperator(
317
+ * address indexed operator,
318
+ * address indexed tokenOwner,
319
+ * bytes32 indexed tokenId
320
+ * );
321
+ *
322
+ * signature = keccak256('RevokedOperator(address,address,bytes32)')
323
+ */
324
+ RevokedOperator: '17d5389f6ab6adb2647dfa0aa365c323d37adacc30b33a65310b6158ce1373d5',
325
+ },
326
+ Helpers: {
327
+ /**
328
+ * event ReceivedERC777(
329
+ * address indexed token,
330
+ * address indexed _operator,
331
+ * address indexed _from,
332
+ * address _to,
333
+ * uint256 _amount
334
+ * );
335
+ *
336
+ * signature = keccak256('ReceivedERC777(address,address,address,address,uint256)')
337
+ */
338
+ ReceivedERC777: '0xdc38539587ea4d67f9f649ad9269646bab26927bad175bdcdfdab5dd297d5e1c',
339
+ },
340
+ };
341
+
342
+ module.exports = {
343
+ INTERFACE_IDS,
344
+ ERC1271_VALUES,
345
+ OPERATION_TYPES,
346
+ SupportedStandards,
347
+ ERC725YKeys,
348
+ BasicUPSetup_Schema,
349
+ ALL_PERMISSIONS,
350
+ PERMISSIONS,
351
+ EventSignatures,
352
+ };
@@ -0,0 +1,31 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.0;
3
+
4
+ // This contract is a modified version of the OwnableUnset implementation, where we transfer Ownership as a 2 step
5
+ // process, this allows to prevent for mistakes during ownership transfer,and so prevent control of a contract from
6
+ // potentially being lost forever.
7
+
8
+ // interfaces
9
+ import {IClaimOwnership} from "./IClaimOwnership.sol";
10
+
11
+ // modules
12
+ import {OwnableUnset} from "@erc725/smart-contracts/contracts/custom/OwnableUnset.sol";
13
+
14
+ abstract contract ClaimOwnership is IClaimOwnership, OwnableUnset {
15
+ address public override pendingOwner;
16
+
17
+ function claimOwnership() public virtual override {
18
+ require(msg.sender == pendingOwner, "OwnableClaim: caller is not the pendingOwner");
19
+
20
+ _setOwner(pendingOwner);
21
+ pendingOwner = address(0);
22
+ }
23
+
24
+ function transferOwnership(address _newOwner) public virtual override onlyOwner {
25
+ _transferOwnership(_newOwner);
26
+ }
27
+
28
+ function _transferOwnership(address _newOwner) internal virtual {
29
+ pendingOwner = _newOwner;
30
+ }
31
+ }
@@ -0,0 +1,130 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165Checker.sol)
3
+
4
+ pragma solidity ^0.8.0;
5
+
6
+ // This contract is a modified version of OpenZeppelin implementation, where we modify the visibility of
7
+ // `supportsERC165Interface`, which check the given interfaceId, to internal and to be used in contract implementations,
8
+ // instead of `supportsInterface` to save gas, as the latter check for 3 interfaceIds; InterfaceId of ERC165, 0xffffffff
9
+ // and the given interfaceId.
10
+
11
+ // interfaces
12
+ import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
13
+
14
+ /**
15
+ * @dev Library used to query support of an interface declared via {IERC165}.
16
+ *
17
+ * Note that these functions return the actual result of the query: they do not
18
+ * `revert` if an interface is not supported. It is up to the caller to decide
19
+ * what to do in these cases.
20
+ */
21
+ library ERC165Checker {
22
+ // As per the EIP-165 spec, no interface should ever match 0xffffffff
23
+ bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff;
24
+
25
+ /**
26
+ * @dev Returns true if `account` supports the {IERC165} interface,
27
+ */
28
+ function supportsERC165(address account) internal view returns (bool) {
29
+ // Any contract that implements ERC165 must explicitly indicate support of
30
+ // InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid
31
+ return
32
+ supportsERC165Interface(account, type(IERC165).interfaceId) &&
33
+ !supportsERC165Interface(account, _INTERFACE_ID_INVALID);
34
+ }
35
+
36
+ /**
37
+ * @dev Returns true if `account` supports the interface defined by
38
+ * `interfaceId`. Support for {IERC165} itself is queried automatically.
39
+ *
40
+ * See {IERC165-supportsInterface}.
41
+ */
42
+ function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) {
43
+ // query support of both ERC165 as per the spec and support of _interfaceId
44
+ return supportsERC165(account) && supportsERC165Interface(account, interfaceId);
45
+ }
46
+
47
+ /**
48
+ * @dev Returns a boolean array where each value corresponds to the
49
+ * interfaces passed in and whether they're supported or not. This allows
50
+ * you to batch check interfaces for a contract where your expectation
51
+ * is that some interfaces may not be supported.
52
+ *
53
+ * See {IERC165-supportsInterface}.
54
+ *
55
+ * _Available since v3.4._
56
+ */
57
+ function getSupportedInterfaces(address account, bytes4[] memory interfaceIds)
58
+ internal
59
+ view
60
+ returns (bool[] memory)
61
+ {
62
+ // an array of booleans corresponding to interfaceIds and whether they're supported or not
63
+ bool[] memory interfaceIdsSupported = new bool[](interfaceIds.length);
64
+
65
+ // query support of ERC165 itself
66
+ if (supportsERC165(account)) {
67
+ // query support of each interface in interfaceIds
68
+ for (uint256 i = 0; i < interfaceIds.length; i++) {
69
+ interfaceIdsSupported[i] = supportsERC165Interface(account, interfaceIds[i]);
70
+ }
71
+ }
72
+
73
+ return interfaceIdsSupported;
74
+ }
75
+
76
+ /**
77
+ * @dev Returns true if `account` supports all the interfaces defined in
78
+ * `interfaceIds`. Support for {IERC165} itself is queried automatically.
79
+ *
80
+ * Batch-querying can lead to gas savings by skipping repeated checks for
81
+ * {IERC165} support.
82
+ *
83
+ * See {IERC165-supportsInterface}.
84
+ */
85
+ function supportsAllInterfaces(address account, bytes4[] memory interfaceIds)
86
+ internal
87
+ view
88
+ returns (bool)
89
+ {
90
+ // query support of ERC165 itself
91
+ if (!supportsERC165(account)) {
92
+ return false;
93
+ }
94
+
95
+ // query support of each interface in _interfaceIds
96
+ for (uint256 i = 0; i < interfaceIds.length; i++) {
97
+ if (!supportsERC165Interface(account, interfaceIds[i])) {
98
+ return false;
99
+ }
100
+ }
101
+
102
+ // all interfaces supported
103
+ return true;
104
+ }
105
+
106
+ /**
107
+ * @notice Query if a contract implements an interface, does not check ERC165 support
108
+ * @param account The address of the contract to query for support of an interface
109
+ * @param interfaceId The interface identifier, as specified in ERC-165
110
+ * @return true if the contract at account indicates support of the interface with
111
+ * identifier interfaceId, false otherwise
112
+ * @dev Assumes that account contains a contract that supports ERC165, otherwise
113
+ * the behavior of this method is undefined. This precondition can be checked
114
+ * with {supportsERC165}.
115
+ * Interface identification is specified in ERC-165.
116
+ */
117
+ function supportsERC165Interface(address account, bytes4 interfaceId)
118
+ internal
119
+ view
120
+ returns (bool)
121
+ {
122
+ bytes memory encodedParams = abi.encodeWithSelector(
123
+ IERC165.supportsInterface.selector,
124
+ interfaceId
125
+ );
126
+ (bool success, bytes memory result) = account.staticcall{gas: 30000}(encodedParams);
127
+ if (result.length < 32) return false;
128
+ return success && abi.decode(result, (bool));
129
+ }
130
+ }
@@ -0,0 +1,10 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.0;
3
+
4
+ bytes4 constant _INTERFACEID_CLAIM_OWNERSHIP = 0xad7dd9b0;
5
+
6
+ interface IClaimOwnership {
7
+ function pendingOwner() external view returns (address);
8
+
9
+ function claimOwnership() external;
10
+ }
@@ -0,0 +1,155 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.0;
3
+
4
+ // libraries
5
+ import {Create2} from "@openzeppelin/contracts/utils/Create2.sol";
6
+ import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";
7
+ import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol";
8
+ import {ErrorHandlerLib} from "@erc725/smart-contracts/contracts/utils/ErrorHandlerLib.sol";
9
+
10
+ /**
11
+ * @dev UniversalFactory contract can be used to deploy CREATE2 contracts; normal contracts and minimal
12
+ * proxies (EIP-1167) with the ability to deploy the same contract at the same address on different chains.
13
+ * If the contract has a constructor, the arguments will be part of the byteCode
14
+ * If the contract has an `initialize` function, the parameters of this function will be included in
15
+ * the salt to ensure that the parameters of the contract should be the same on each chain.
16
+ *
17
+ * Security measures were taken to avoid deploying proxies from the `deployCreate2(..)` function
18
+ * to prevent the problem mentioned above.
19
+ *
20
+ * This contract should be deployed using Nick's Method.
21
+ * More information: https://weka.medium.com/how-to-send-ether-to-11-440-people-187e332566b7
22
+ */
23
+ contract UniversalFactory {
24
+ using BytesLib for bytes;
25
+
26
+ // The bytecode hash of EIP-1167 Minimal Proxy
27
+ bytes32 private constant _MINIMAL_PROXY_BYTECODE_HASH_PT1 =
28
+ 0x72307939328b75c6e301a012c75e0a4e690a99036b95f6e6f4f1b5aba02a9ce4;
29
+
30
+ bytes32 private constant _MINIMAL_PROXY_BYTECODE_HASH_PT2 =
31
+ 0x11a195f66c9175f46895bae2006d40848a680c7068b9fc4af248ff9a54a47e45;
32
+
33
+ /**
34
+ * @dev Throws if the `byteCode` passed to the function is the EIP-1167 Minimal Proxy bytecode
35
+ */
36
+ modifier notMinimalProxy(bytes memory byteCode) virtual {
37
+ if (byteCode.length == 55) {
38
+ if (
39
+ keccak256(byteCode.slice(0, 20)) == _MINIMAL_PROXY_BYTECODE_HASH_PT1 &&
40
+ keccak256(byteCode.slice(40, 15)) == _MINIMAL_PROXY_BYTECODE_HASH_PT2
41
+ ) {
42
+ revert("Minimal Proxies deployment not allowed");
43
+ }
44
+ }
45
+ _;
46
+ }
47
+
48
+ /**
49
+ * @dev Returns the address where a contract will be stored if deployed via `CREATE2`. The address is
50
+ * constructed using the parameters below. Any change in one of them will result in a new destination address.
51
+ */
52
+ function calculateAddress(
53
+ bytes32 byteCodeHash,
54
+ bytes32 salt,
55
+ bytes memory initializeCallData
56
+ ) public view returns (address) {
57
+ bytes32 generatedSalt = _generateSalt(initializeCallData, salt);
58
+ return Create2.computeAddress(generatedSalt, byteCodeHash);
59
+ }
60
+
61
+ /**
62
+ * @dev Returns the address of an EIP1167 proxy contract. The address is constructed using
63
+ * the parameters below. Any change in one of them will result in a new destination address.
64
+ */
65
+ function calculateProxyAddress(
66
+ address baseContract,
67
+ bytes32 salt,
68
+ bytes memory initializeCallData
69
+ ) public view returns (address) {
70
+ bytes32 generatedSalt = _generateSalt(initializeCallData, salt);
71
+ return Clones.predictDeterministicAddress(baseContract, generatedSalt);
72
+ }
73
+
74
+ /**
75
+ * @dev Deploys a contract using `CREATE2`. The address where the contract will be deployed
76
+ * can be known in advance via {calculateAddress}. The salt is a combination between an initializable
77
+ * boolean, `salt` and the `initializeCallData` if the contract is initializable. This method allow users
78
+ * to have the same contracts at the same address across different chains with the same parameters.
79
+ *
80
+ * Using the same `byteCode` and salt multiple time will revert, since
81
+ * the contract cannot be deployed twice at the same address.
82
+ *
83
+ * Deploying a minimal proxy from this function will revert.
84
+ */
85
+ function deployCreate2(
86
+ bytes memory byteCode,
87
+ bytes32 salt,
88
+ bytes memory initializeCallData
89
+ ) public payable notMinimalProxy(byteCode) returns (address contractCreated) {
90
+ bytes32 generatedSalt = _generateSalt(initializeCallData, salt);
91
+ contractCreated = Create2.deploy(msg.value, generatedSalt, byteCode);
92
+
93
+ if (initializeCallData.length > 0) {
94
+ // solhint-disable avoid-low-level-calls
95
+ (bool success, bytes memory returnedData) = contractCreated.call(initializeCallData);
96
+ if (!success) ErrorHandlerLib.revertWithParsedError(returnedData);
97
+ }
98
+ }
99
+
100
+ /**
101
+ * @dev Deploys and returns the address of a clone that mimics the behaviour of `baseContract`.
102
+ * The address where the contract will be deployed can be known in advance via {calculateProxyAddress}.
103
+ *
104
+ * This function uses the CREATE2 opcode and a salt to deterministically deploy
105
+ * the clone. The salt is a combination between an initializable boolean, `salt`
106
+ * and the `initializeCallData` if the contract is initializable. This method allow users
107
+ * to have the same contracts at the same address across different chains with the same parameters.
108
+ *
109
+ * Using the same `baseContract` and salt multiple time will revert, since
110
+ * the clones cannot be deployed twice at the same address.
111
+ */
112
+ function deployCreate2Proxy(
113
+ address baseContract,
114
+ bytes32 salt,
115
+ bytes memory initializeCallData
116
+ ) public payable returns (address proxy) {
117
+ bytes32 generatedSalt = _generateSalt(initializeCallData, salt);
118
+ proxy = Clones.cloneDeterministic(baseContract, generatedSalt);
119
+
120
+ if (initializeCallData.length > 0) {
121
+ // solhint-disable avoid-low-level-calls
122
+ (bool success, bytes memory returnedData) = proxy.call{value: msg.value}(
123
+ initializeCallData
124
+ );
125
+ if (!success) ErrorHandlerLib.revertWithParsedError(returnedData);
126
+ } else {
127
+ // Return value sent
128
+ if (msg.value > 0) {
129
+ // solhint-disable avoid-low-level-calls
130
+ (bool success, bytes memory returnedData) = payable(msg.sender).call{
131
+ value: msg.value
132
+ }("");
133
+ if (!success) ErrorHandlerLib.revertWithParsedError(returnedData);
134
+ }
135
+ }
136
+ }
137
+
138
+ /** internal functions */
139
+
140
+ /**
141
+ * @dev Calculates the salt including the initializeCallData, or without but hashing it with a zero bytes padding.
142
+ */
143
+ function _generateSalt(bytes memory initializeCallData, bytes32 salt)
144
+ internal
145
+ pure
146
+ returns (bytes32)
147
+ {
148
+ bool initializable = initializeCallData.length > 0;
149
+ if (initializable) {
150
+ return keccak256(abi.encodePacked(initializable, initializeCallData, salt));
151
+ } else {
152
+ return keccak256(abi.encodePacked(initializable, salt));
153
+ }
154
+ }
155
+ }