@lukso/lsp-smart-contracts 0.6.0 → 0.7.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 (140) hide show
  1. package/README.md +13 -12
  2. package/artifacts/Create2Factory.json +2 -2
  3. package/artifacts/LSP0ERC725Account.json +66 -27
  4. package/artifacts/LSP0ERC725AccountInit.json +71 -53
  5. package/artifacts/LSP1UniversalReceiverDelegateUP.json +23 -2
  6. package/artifacts/LSP1UniversalReceiverDelegateVault.json +23 -2
  7. package/artifacts/LSP4Compatibility.json +15 -9
  8. package/artifacts/LSP4DigitalAssetMetadata.json +25 -9
  9. package/artifacts/{LSP4DigitalAssetMetadataInit.json → LSP4DigitalAssetMetadataInitAbstract.json} +27 -60
  10. package/artifacts/LSP6KeyManager.json +93 -13
  11. package/artifacts/LSP6KeyManagerInit.json +98 -13
  12. package/artifacts/LSP7CappedSupply.json +56 -35
  13. package/artifacts/{LSP7CappedSupplyInit.json → LSP7CappedSupplyInitAbstract.json} +58 -104
  14. package/artifacts/LSP7CompatibleERC20.json +704 -0
  15. package/artifacts/LSP7CompatibleERC20InitAbstract.json +717 -0
  16. package/artifacts/LSP7CompatibleERC20Mintable.json +753 -0
  17. package/artifacts/LSP7CompatibleERC20MintableInit.json +773 -0
  18. package/artifacts/LSP7DigitalAsset.json +56 -61
  19. package/artifacts/LSP7DigitalAssetInitAbstract.json +540 -0
  20. package/artifacts/LSP7Mintable.json +59 -38
  21. package/artifacts/LSP7MintableInit.json +64 -64
  22. package/artifacts/LSP8CappedSupply.json +62 -9
  23. package/artifacts/{LSP8CappedSupplyInit.json → LSP8CappedSupplyInitAbstract.json} +64 -73
  24. package/artifacts/LSP8CompatibleERC721.json +907 -0
  25. package/artifacts/LSP8CompatibleERC721InitAbstract.json +920 -0
  26. package/artifacts/LSP8CompatibleERC721Mintable.json +967 -0
  27. package/artifacts/LSP8CompatibleERC721MintableInit.json +987 -0
  28. package/artifacts/LSP8IdentifiableDigitalAsset.json +62 -30
  29. package/artifacts/LSP8IdentifiableDigitalAssetInitAbstract.json +628 -0
  30. package/artifacts/LSP8Mintable.json +64 -11
  31. package/artifacts/LSP8MintableInit.json +69 -37
  32. package/artifacts/LSP9Vault.json +63 -24
  33. package/artifacts/LSP9VaultInit.json +68 -50
  34. package/artifacts/UniversalFactory.json +2 -2
  35. package/artifacts/UniversalProfile.json +66 -27
  36. package/artifacts/UniversalProfileInit.json +71 -53
  37. package/artifacts/UniversalReceiverAddressStore.json +7 -2
  38. package/constants.js +273 -31
  39. package/contracts/Custom/ClaimOwnership.sol +74 -9
  40. package/contracts/Custom/ERC165Checker.sol +1 -1
  41. package/contracts/Custom/IClaimOwnership.sol +3 -1
  42. package/contracts/Factories/Create2Factory.sol +3 -13
  43. package/contracts/Factories/UniversalFactory.sol +20 -16
  44. package/contracts/LSP0ERC725Account/LSP0Constants.sol +1 -1
  45. package/contracts/LSP0ERC725Account/LSP0ERC725Account.sol +3 -3
  46. package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +49 -37
  47. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInit.sol +10 -3
  48. package/contracts/LSP0ERC725Account/LSP0ERC725AccountInitAbstract.sol +3 -3
  49. package/contracts/LSP10ReceivedVaults/LSP10Constants.sol +2 -2
  50. package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiver.sol +3 -0
  51. package/contracts/LSP1UniversalReceiver/ILSP1UniversalReceiverDelegate.sol +4 -2
  52. package/contracts/LSP1UniversalReceiver/LSP1Constants.sol +1 -1
  53. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/Handling/TokenAndVaultHandling.sol +22 -16
  54. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateUP/LSP1UniversalReceiverDelegateUP.sol +14 -10
  55. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/Handling/TokenHandling.sol +35 -29
  56. package/contracts/LSP1UniversalReceiver/LSP1UniversalReceiverDelegateVault/LSP1UniversalReceiverDelegateVault.sol +10 -3
  57. package/contracts/LSP1UniversalReceiver/LSP1Utils.sol +24 -9
  58. package/contracts/LSP2ERC725YJSONSchema/LSP2Errors.sol +9 -0
  59. package/contracts/LSP2ERC725YJSONSchema/LSP2Utils.sol +157 -75
  60. package/contracts/LSP3UniversalProfile/LSP3Constants.sol +1 -1
  61. package/contracts/LSP4DigitalAssetMetadata/LSP4Constants.sol +1 -1
  62. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadata.sol +24 -4
  63. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInitAbstract.sol +26 -5
  64. package/contracts/LSP4DigitalAssetMetadata/LSP4Errors.sol +16 -0
  65. package/contracts/LSP5ReceivedAssets/LSP5Constants.sol +2 -2
  66. package/contracts/LSP5ReceivedAssets/LSP5Utils.sol +151 -77
  67. package/contracts/LSP6KeyManager/ILSP6KeyManager.sol +16 -16
  68. package/contracts/LSP6KeyManager/LSP6Constants.sol +16 -21
  69. package/contracts/LSP6KeyManager/LSP6Errors.sol +42 -5
  70. package/contracts/LSP6KeyManager/LSP6KeyManager.sol +6 -4
  71. package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +293 -284
  72. package/contracts/LSP6KeyManager/LSP6KeyManagerInit.sol +11 -4
  73. package/contracts/LSP6KeyManager/LSP6KeyManagerInitAbstract.sol +5 -3
  74. package/contracts/LSP6KeyManager/LSP6Utils.sol +24 -27
  75. package/contracts/LSP7DigitalAsset/ILSP7DigitalAsset.sol +18 -5
  76. package/contracts/LSP7DigitalAsset/LSP7Constants.sol +1 -1
  77. package/contracts/LSP7DigitalAsset/LSP7DigitalAsset.sol +8 -4
  78. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetCore.sol +35 -24
  79. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInitAbstract.sol +5 -3
  80. package/contracts/LSP7DigitalAsset/LSP7Errors.sol +2 -0
  81. package/contracts/LSP7DigitalAsset/extensions/{ILSP7CompatibilityForERC20.sol → ILSP7CompatibleERC20.sol} +6 -6
  82. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyCore.sol +1 -1
  83. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInitAbstract.sol +5 -2
  84. package/contracts/LSP7DigitalAsset/extensions/{LSP7CompatibilityForERC20.sol → LSP7CompatibleERC20.sol} +6 -7
  85. package/contracts/LSP7DigitalAsset/extensions/{LSP7CompatibilityForERC20Core.sol → LSP7CompatibleERC20Core.sol} +23 -19
  86. package/contracts/LSP7DigitalAsset/extensions/{LSP7CompatibilityForERC20InitAbstract.sol → LSP7CompatibleERC20InitAbstract.sol} +11 -10
  87. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.sol +22 -0
  88. package/contracts/{LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibilityForERC721Init.sol → LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInit.sol} +12 -7
  89. package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInitAbstract.sol +27 -0
  90. package/contracts/LSP7DigitalAsset/presets/LSP7Mintable.sol +9 -7
  91. package/contracts/LSP7DigitalAsset/presets/LSP7MintableInit.sol +11 -4
  92. package/contracts/LSP7DigitalAsset/presets/LSP7MintableInitAbstract.sol +8 -7
  93. package/contracts/LSP8IdentifiableDigitalAsset/ILSP8IdentifiableDigitalAsset.sol +3 -1
  94. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Constants.sol +4 -4
  95. package/contracts/LSP8IdentifiableDigitalAsset/LSP8Errors.sol +6 -0
  96. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAsset.sol +1 -1
  97. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetCore.sol +31 -30
  98. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInitAbstract.sol +3 -1
  99. package/contracts/LSP8IdentifiableDigitalAsset/extensions/{ILSP8CompatibilityForERC721.sol → ILSP8CompatibleERC721.sol} +16 -2
  100. package/contracts/LSP8IdentifiableDigitalAsset/extensions/ILSP8Enumerable.sol +17 -0
  101. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyCore.sol +1 -1
  102. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInitAbstract.sol +4 -2
  103. package/contracts/LSP8IdentifiableDigitalAsset/extensions/{LSP8CompatibilityConstants.sol → LSP8CompatibleConstants.sol} +0 -0
  104. package/contracts/LSP8IdentifiableDigitalAsset/extensions/{LSP8CompatibilityForERC721.sol → LSP8CompatibleERC721.sol} +12 -11
  105. package/contracts/LSP8IdentifiableDigitalAsset/extensions/{LSP8CompatibilityForERC721Core.sol → LSP8CompatibleERC721Core.sol} +61 -37
  106. package/contracts/LSP8IdentifiableDigitalAsset/extensions/{LSP8CompatibilityForERC721InitAbstract.sol → LSP8CompatibleERC721InitAbstract.sol} +13 -9
  107. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Enumerable.sol +21 -0
  108. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableCore.sol +50 -0
  109. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8EnumerableInitAbstract.sol +24 -0
  110. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.sol +22 -0
  111. package/contracts/{LSP7DigitalAsset/extensions/LSP7CompatibilityForERC20Init.sol → LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInit.sol} +12 -4
  112. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInitAbstract.sol +27 -0
  113. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8Mintable.sol +6 -4
  114. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInit.sol +7 -0
  115. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableInitAbstract.sol +8 -5
  116. package/contracts/LSP9Vault/LSP9Constants.sol +6 -3
  117. package/contracts/LSP9Vault/LSP9Vault.sol +9 -5
  118. package/contracts/LSP9Vault/LSP9VaultCore.sol +152 -69
  119. package/contracts/LSP9Vault/LSP9VaultInit.sol +10 -3
  120. package/contracts/LSP9Vault/LSP9VaultInitAbstract.sol +9 -5
  121. package/contracts/Legacy/UniversalReceiverAddressStore.sol +6 -2
  122. package/contracts/UniversalProfile.sol +3 -4
  123. package/contracts/UniversalProfileInit.sol +10 -3
  124. package/contracts/UniversalProfileInitAbstract.sol +3 -5
  125. package/contracts/Utils/GasLib.sol +17 -0
  126. package/contracts/Utils/UtilsLib.sol +6 -34
  127. package/package.json +27 -30
  128. package/artifacts/LSP7CompatibilityForERC20.json +0 -686
  129. package/artifacts/LSP7CompatibilityForERC20Init.json +0 -727
  130. package/artifacts/LSP7DigitalAssetInit.json +0 -573
  131. package/artifacts/LSP8CompatibilityForERC721.json +0 -832
  132. package/artifacts/LSP8CompatibilityForERC721Init.json +0 -873
  133. package/artifacts/LSP8IdentifiableDigitalAssetInit.json +0 -624
  134. package/contracts/LSP4DigitalAssetMetadata/LSP4DigitalAssetMetadataInit.sol +0 -26
  135. package/contracts/LSP7DigitalAsset/LSP7DigitalAssetInit.sol +0 -28
  136. package/contracts/LSP7DigitalAsset/extensions/LSP7CappedSupplyInit.sol +0 -19
  137. package/contracts/LSP7DigitalAsset/presets/LSP7MintableCore.sol +0 -26
  138. package/contracts/LSP8IdentifiableDigitalAsset/LSP8IdentifiableDigitalAssetInit.sol +0 -26
  139. package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CappedSupplyInit.sol +0 -19
  140. package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8MintableCore.sol +0 -26
package/constants.js CHANGED
@@ -17,14 +17,14 @@ const INTERFACE_IDS = {
17
17
  ERC1155: '0xd9b67a26',
18
18
  ERC725X: '0x44c028fe',
19
19
  ERC725Y: '0x714df77c',
20
- LSP0ERC725Account: '0x9a3bfe88',
20
+ LSP0ERC725Account: '0xeb6be62e',
21
21
  LSP1UniversalReceiver: '0x6bb56a14',
22
- LSP1UniversalReceiverDelegate: '0xc2d7bcc1',
22
+ LSP1UniversalReceiverDelegate: '0xa245bbda',
23
23
  LSP6KeyManager: '0xc403d48f',
24
- LSP7DigitalAsset: '0xe33f65c3',
24
+ LSP7DigitalAsset: '0x5fcaac27',
25
25
  LSP8IdentifiableDigitalAsset: '0x49399145',
26
- LSP9Vault: '0x8c1d44f6',
27
- ClaimOwnership: '0xad7dd9b0',
26
+ LSP9Vault: '0xfd4d5c50',
27
+ ClaimOwnership: '0xa375e9c6',
28
28
  };
29
29
 
30
30
  // ERC1271
@@ -69,36 +69,49 @@ const SupportedStandards = {
69
69
  * @see https://github.com/lukso-network/LIPs/blob/main/LSPs/LSP-2-ERC725YJSONSchema.md
70
70
  */
71
71
  const ERC725YKeys = {
72
- LSP0: {
72
+ LSP1: {
73
73
  // keccak256('LSP1UniversalReceiverDelegate')
74
74
  LSP1UniversalReceiverDelegate:
75
75
  '0x0cfc51aec37c55a4d0b1a65c6255c4bf2fbdf6277f3cc0730c45b828b6db8b47',
76
76
  },
77
77
  LSP3: {
78
+ SupportedStandards_LSP3: SupportedStandards.LSP3UniversalProfile,
78
79
  // keccak256('LSP3Profile')
79
80
  LSP3Profile: '0x5ef83ad9559033e6e941db7d7c495acdce616347d28e90c7ce47cbfcfcad3bc5',
80
81
  },
81
82
  LSP4: {
83
+ SupportedStandards_LSP4: SupportedStandards.LSP4DigitalAsset,
82
84
  // keccak256('LSP4TokenName')
83
85
  LSP4TokenName: '0xdeba1e292f8ba88238e10ab3c7f88bd4be4fac56cad5194b6ecceaf653468af1',
84
86
  // keccak256('LSP4TokenSymbol')
85
87
  LSP4TokenSymbol: '0x2f0a68ab07768e01943a599e73362a0e17a63a72e94dd2e384d2c1d4db932756',
86
88
  // keccak256('LSP4Metadata')
87
89
  LSP4Metadata: '0x9afb95cacc9f95858ec44aa8c3b685511002e30ae54415823f406128b85b238e',
90
+ // LSP4CreatorsMap:<address>
91
+ LSP4CreatorsMap: '0x6de85eaf5d982b4e5da00000',
88
92
  // keccak256('"LSP4Creators[]')
89
- 'LSP4Creators[]': '0x114bd03b3a46d48759680d81ebb2b414fda7d030a7105a851867accf1c2352e7',
93
+ 'LSP4Creators[]': {
94
+ // use this key to get the number of elements in the array
95
+ length: '0x114bd03b3a46d48759680d81ebb2b414fda7d030a7105a851867accf1c2352e7',
96
+ // use this key + bytes16(index) to access an index in the array
97
+ index: '0x114bd03b3a46d48759680d81ebb2b414',
98
+ },
90
99
  },
91
100
  LSP5: {
92
101
  // LSP5ReceivedAssetsMap:<address>
93
102
  LSP5ReceivedAssetsMap: '0x812c4334633eb816c80d0000',
94
103
  // keccak256('LSP5ReceivedAssets[]')
95
- 'LSP5ReceivedAssets[]':
96
- '0x6460ee3c0aac563ccbf76d6e1d07bada78e3a9514e6382b736ed3f478ab7b90b',
104
+ 'LSP5ReceivedAssets[]': {
105
+ length: '0x6460ee3c0aac563ccbf76d6e1d07bada78e3a9514e6382b736ed3f478ab7b90b',
106
+ index: '0x6460ee3c0aac563ccbf76d6e1d07bada',
107
+ },
97
108
  },
98
109
  LSP6: {
99
110
  // keccak256('AddressPermissions[]')
100
- 'AddressPermissions[]':
101
- '0xdf30dba06db6a30e65354d9a64c609861f089545ca58c6b4dbe31a5f338cb0e3',
111
+ 'AddressPermissions[]': {
112
+ length: '0xdf30dba06db6a30e65354d9a64c609861f089545ca58c6b4dbe31a5f338cb0e3',
113
+ index: '0xdf30dba06db6a30e65354d9a64c60986',
114
+ },
102
115
  // AddressPermissions:Permissions:<address>
103
116
  'AddressPermissions:Permissions': '0x4b80742de2bf82acb3630000',
104
117
  // AddressPermissions:AllowedAddresses:<address>
@@ -110,17 +123,26 @@ const ERC725YKeys = {
110
123
  // AddressPermissions:AllowedERC725YKeys:<address>
111
124
  'AddressPermissions:AllowedERC725YKeys': '0x4b80742de2bf90b8b4850000',
112
125
  },
126
+ LSP9: {
127
+ SupportedStandards_LSP9: SupportedStandards.LSP9Vault,
128
+ },
113
129
  LSP10: {
114
130
  // keccak256('LSP10VaultsMap')
115
131
  LSP10VaultsMap: '0x192448c3c0f88c7f238c0000',
116
132
  // keccak256('LSP10Vaults[]')
117
- 'LSP10Vaults[]': '0x55482936e01da86729a45d2b87a6b1d3bc582bea0ec00e38bdb340e3af6f9f06',
133
+ 'LSP10Vaults[]': {
134
+ length: '0x55482936e01da86729a45d2b87a6b1d3bc582bea0ec00e38bdb340e3af6f9f06',
135
+ index: '0x55482936e01da86729a45d2b87a6b1d3',
136
+ },
118
137
  },
119
138
  LSP12: {
120
139
  // LSP12IssuedAssetsMap:<address>
121
140
  LSP12IssuedAssetsMap: '0x74ac2555c10b9349e78f0000',
122
141
  // keccak256('LSP12IssuedAssets[]')
123
- 'LSP12IssuedAssets[]': '0x7c8c3416d6cda87cd42c71ea1843df28ac4850354f988d55ee2eaa47b6dc05cd',
142
+ 'LSP12IssuedAssets[]': {
143
+ length: '0x7c8c3416d6cda87cd42c71ea1843df28ac4850354f988d55ee2eaa47b6dc05cd',
144
+ index: '0x7c8c3416d6cda87cd42c71ea1843df28',
145
+ },
124
146
  },
125
147
  };
126
148
 
@@ -134,14 +156,14 @@ const BasicUPSetup_Schema = [
134
156
  },
135
157
  {
136
158
  name: 'LSP1UniversalReceiverDelegate',
137
- key: ERC725YKeys.LSP0['LSP1UniversalReceiverDelegate'],
159
+ key: ERC725YKeys.LSP1.LSP1UniversalReceiverDelegate,
138
160
  keyType: 'Singleton',
139
161
  valueContent: 'Address',
140
162
  valueType: 'address',
141
163
  },
142
164
  {
143
165
  name: 'LSP12IssuedAssets[]',
144
- key: ERC725YKeys.LSP12['LSP12IssuedAssets[]'],
166
+ key: ERC725YKeys.LSP12['LSP12IssuedAssets[]'].length,
145
167
  keyType: 'Array',
146
168
  valueContent: 'Number',
147
169
  valueType: 'uint256',
@@ -166,13 +188,207 @@ const PERMISSIONS = {
166
188
  DEPLOY: "0x0000000000000000000000000000000000000000000000000000000000000080", // .... .... 1000 ....
167
189
  TRANSFERVALUE: "0x0000000000000000000000000000000000000000000000000000000000000100", // .... 0001 .... ....
168
190
  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 .... .... ....
191
+ ENCRYPT: "0x0000000000000000000000000000000000000000000000000000000000000400", // .... 0100 .... ....
192
+ SUPER_SETDATA: "0x0000000000000000000000000000000000000000000000000000000000000800", // .... 1000 .... ....
193
+ SUPER_TRANSFERVALUE: "0x0000000000000000000000000000000000000000000000000000000000001000", // 0001 .... .... ....
194
+ SUPER_CALL: "0x0000000000000000000000000000000000000000000000000000000000002000", // 0010 .... .... ....
195
+ SUPER_STATICCALL: "0x0000000000000000000000000000000000000000000000000000000000004000", // 0100 .... .... ....
196
+ SUPER_DELEGATECALL: "0x0000000000000000000000000000000000000000000000000000000000008000", // 1000 .... .... ....
174
197
  }
175
198
 
199
+ const LSP1_TYPE_IDS = {
200
+ // keccak256('LSP7TokensSender')
201
+ LSP7_TOKENSENDER: '0x40b8bec57d7b5ff0dbd9e9acd0a47dfeb0101e1a203766f5ccab00445fbf39e9',
202
+ // keccak256('LSP7TokensRecipient')
203
+ LSP7_TOKENRECIPIENT: '0xdbe2c314e1aee2970c72666f2ebe8933a8575263ea71e5ff6a9178e95d47a26f',
204
+ // keccak256('LSP8TokensSender')
205
+ LSP8_TOKENSENDER: '0x3724c94f0815e936299cca424da4140752198e0beb7931a6e0925d11bc97544c',
206
+ // keccak256('LSP8TokensRecipient')
207
+ LSP8_TOKENRECIPIENT: '0xc7a120a42b6057a0cbed111fbbfbd52fcd96748c04394f77fc2c3adbe0391e01',
208
+ // keccak256("LSP9VaultSender")
209
+ LSP9_VAULTSENDER: '0x3ca9f769340018257ac15b3a00e502e8fb730d66086f774210f84d0205af31e7',
210
+ // keccak256("LSP9VaultRecipient")
211
+ LSP9_VAULTRECIPIENT: '0x09aaf55960715d8d86b57af40be36b0bfd469c9a3643445d8c65d39e27b4c56f',
212
+ // keccak256("LSP9VaultPendingOwner")
213
+ LSP9_VAULTPENDINGOWNER: '0x50d401f7017708f51f2a7a1c24146f786926c831079107140037b8ebef9fd326',
214
+ };
215
+
216
+ // ----------
217
+
218
+ const Errors = {
219
+ ClaimOwnership: {
220
+ '0x8b9bf507': {
221
+ error: 'NotInRenounceOwnershipInterval(uint256,uint256)',
222
+ message: 'ClaimOwnership: Second renounce ownership call available after 100 block delay from the first call',
223
+ },
224
+ '0x43b248cd': {
225
+ error: 'CannotTransferOwnershipToSelf()',
226
+ message: 'ClaimOwnership: Cannot transfer ownership to address(this)',
227
+ },
228
+ },
229
+ LSP2: {
230
+ '0xb614e91e': {
231
+ error: 'InvalidABIEncodedArray(bytes,string)',
232
+ message: 'LSP2Utils: Invalid ABI encoded array',
233
+ },
234
+ },
235
+ LSP4: {
236
+ '0x85c169bd': {
237
+ error: 'LSP4TokenNameNotEditable()',
238
+ message: 'LSP4: Token name cannot be edited',
239
+ },
240
+ '0x76755b38': {
241
+ error: 'LSP4TokenSymbolNotEditable()',
242
+ message: 'LSP4: Token symbol cannot be edited',
243
+ },
244
+ },
245
+ LSP5: {
246
+ '0xecba7af8': {
247
+ error: 'InvalidLSP5ReceivedAssetsArrayLength(bytes,uint256)',
248
+ message: 'LSP5: Invalid value for `LSP5ReceivedAssets[]` (array length)',
249
+ },
250
+ },
251
+ LSP6: {
252
+ '0xf292052a': {
253
+ error: 'NoPermissionsSet(address)',
254
+ message: 'LSP6: No permissions are set for this address.',
255
+ },
256
+ '0x3bdad6e6': {
257
+ error: 'NotAuthorised(address,string)',
258
+ message: 'LSP6: Not authorized (missing permission).',
259
+ },
260
+ '0x2879b128': {
261
+ error: 'NotAllowedAddress(address,address)',
262
+ message: 'LSP6: not allowed to interact with address.',
263
+ },
264
+ '0x42013ee4': {
265
+ error: 'NotAllowedStandard(address,address)',
266
+ message:
267
+ 'LSP6: cannot interact with a contract that does not implement an allowed standard.',
268
+ },
269
+ '0x84135110': {
270
+ error: 'NotAllowedFunction(address,bytes4)',
271
+ message: 'LSP6: not allowed to run the function.',
272
+ },
273
+ '0x3003e7ae': {
274
+ error: 'NotAllowedERC725YKey(address,bytes32)',
275
+ message: 'LSP6: not allowed to set the ERC725Y data key.',
276
+ },
277
+ '0x0f7d735b': {
278
+ error: 'NotRecognisedPermissionKey(bytes32)',
279
+ message: 'LSP6: could not recognise the permission data key being set.',
280
+ },
281
+ '0xfc854579': {
282
+ error: 'InvalidLSP6Target()',
283
+ message: 'LSP6: cannot linked the Key Manager to address(0).',
284
+ },
285
+ '0xc9bd9eb9': {
286
+ error: 'InvalidRelayNonce(address,uint256,bytes)',
287
+ message: 'LSP6: invalid nonce provided for signer address',
288
+ },
289
+ '0x2ba8851c': {
290
+ error: 'InvalidERC725Function(bytes4)',
291
+ message: 'LSP6: unknown or invalid ERC725 function selector',
292
+ },
293
+ },
294
+ LSP7: {
295
+ '0xc5e194ab': {
296
+ error: 'LSP7AmountExceedsBalance(address,address,uint256)',
297
+ message: "LSP7: token amount exceeds sender's balance.",
298
+ },
299
+ '0xf3a6b691': {
300
+ error: 'LSP7AmountExceedsAuthorizedAmount(address,uint256,address,uint256)',
301
+ message: "LSP7: token amount exceeds operator's allowance.",
302
+ },
303
+ '0x6355e766': {
304
+ error: 'LSP7CannotUseAddressZeroAsOperator()',
305
+ message: 'LSP7: cannot authorize address(0) as operator for LSP7 token.',
306
+ },
307
+ '0xd2d5ec30': {
308
+ error: 'LSP7CannotSendWithAddressZero()',
309
+ message: 'LSP7: cannot send token with address(0).',
310
+ },
311
+ '0xb9afb000': {
312
+ error: 'LSP7CannotSendToSelf()',
313
+ message: 'LSP7: `from` and `to` address cannot be the same',
314
+ },
315
+ '0x263eee8d': {
316
+ error: 'LSP7InvalidTransferBatch()',
317
+ message: 'LSP7: invalid transfer batch.',
318
+ },
319
+ '0xa608fbb6': {
320
+ error: 'LSP7NotifyTokenReceiverContractMissingLSP1Interface(address)',
321
+ message: 'LSP7: token recipient does not implement LSP1 standard.',
322
+ },
323
+ '0x26c247f4': {
324
+ error: 'LSP7NotifyTokenReceiverIsEOA(address)',
325
+ message: 'LSP7: token recipient is an Externally Owned Account.',
326
+ },
327
+ },
328
+ LSP7CappedSupply: {
329
+ '0xacf1d8c5': {
330
+ error: 'LSP7CappedSupplyRequired()',
331
+ message: 'LSP7CappedSupply: cap supply number required',
332
+ },
333
+ '0xeacbf0d1': {
334
+ error: 'LSP7CappedSupplyCannotMintOverCap()',
335
+ message: 'LSP7CappedSupply: cannot mint over the max cap supply',
336
+ },
337
+ },
338
+ LSP8: {
339
+ '0xae8f9a36': {
340
+ error: 'LSP8NonExistentTokenId(bytes32)',
341
+ message: 'LSP8: token id does not exist.',
342
+ },
343
+ '0x5b271ea2': {
344
+ error: 'LSP8NotTokenOwner(address,bytes32,address)',
345
+ message: 'LSP8: tokenOwner given as parameter does not own this token id.',
346
+ },
347
+ '0x1294d2a9': {
348
+ error: 'LSP8NotTokenOperator(bytes32,address)',
349
+ message: 'LSP8: caller is not an operator for this token id.',
350
+ },
351
+ '0x9577b8b3': {
352
+ error: 'LSP8CannotUseAddressZeroAsOperator()',
353
+ message: 'LSP8: cannot use address(0) as an operator for token id.',
354
+ },
355
+ '0x24ecef4d': {
356
+ error: 'LSP8CannotSendToAddressZero()',
357
+ message: 'LSP8: cannot send to address(0).',
358
+ },
359
+ '0x5d67d6c1': {
360
+ error: 'LSP8CannotSendToSelf()',
361
+ message: 'LSP8: the `from` and `to` address cannot be the same on transfer.',
362
+ },
363
+ '0x34c7b511': {
364
+ error: 'LSP8TokenIdAlreadyMinted(bytes32)',
365
+ message: 'LSP8: tokenId already exist (= already minted).',
366
+ },
367
+ '0x93a83119': {
368
+ error: 'LSP8InvalidTransferBatch()',
369
+ message: 'LSP8: invalid transfer batch.',
370
+ },
371
+ '0x4349776d': {
372
+ error: 'LSP8NotifyTokenReceiverContractMissingLSP1Interface(address)',
373
+ message: 'LSP8: token recipient does not implement LSP1 standard.',
374
+ },
375
+ '0x03173137': {
376
+ error: 'LSP8NotifyTokenReceiverIsEOA(address)',
377
+ message: 'LSP8: token recipient is an Externally Owned Account.',
378
+ },
379
+ },
380
+ LSP8CappedSupply: {
381
+ '0x38d9fc30': {
382
+ error: 'LSP8CappedSupplyRequired()',
383
+ message: 'LSP8CappedSupply: cap supply number required',
384
+ },
385
+ '0xe8ba2291': {
386
+ error: 'LSP8CappedSupplyCannotMintOverCap()',
387
+ message: 'LSP8CappedSupply: cannot mint over the max cap supply',
388
+ },
389
+ },
390
+ };
391
+
176
392
  // ----------
177
393
 
178
394
  const EventSignatures = {
@@ -187,6 +403,15 @@ const EventSignatures = {
187
403
  */
188
404
  OwnershipTransfered: '0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0',
189
405
  },
406
+ ClaimOwnership: {
407
+ /**
408
+ * event RenounceOwnershipInitiated();
409
+ *
410
+ * signature = keccak256('RenounceOwnershipInitiated()')
411
+ */
412
+ RenounceOwnershipInitiated:
413
+ '0X56272768d104766ae5e663c58927d0a9e47effb40b9a8f6644ac5dfbc9e56f84',
414
+ },
190
415
  ERC725X: {
191
416
  /**
192
417
  * event ContractCreated(
@@ -203,20 +428,23 @@ const EventSignatures = {
203
428
  * uint256 indexed _operation,
204
429
  * address indexed _to,
205
430
  * uint256 indexed _value,
206
- * bytes _data
431
+ * bytes4 _data
207
432
  * );
208
433
  *
209
- * signature = keccak256('Executed(uint256,address,uint256,bytes)')
434
+ * signature = keccak256('Executed(uint256,address,uint256,bytes4)')
210
435
  */
211
- Executed: '0x1f920dbda597d7bf95035464170fa58d0a4b57f13a1c315ace6793b9f63688b8',
436
+ Executed: '0x4810874456b8e6487bd861375cf6abd8e1c8bb5858c8ce36a86a04dabfac199e',
212
437
  },
213
438
  ERC725Y: {
214
439
  /**
215
- * event DataChanged(bytes32 indexed key);
440
+ * event DataChanged(
441
+ * bytes32 indexed dataKey,
442
+ * bytes dataValue
443
+ * );
216
444
  *
217
- * signature = keccak256('DataChanged(bytes32)')
445
+ * signature = keccak256('DataChanged(bytes32,bytes)')
218
446
  */
219
- DataChanged: '0xcdf4e344c0d23d4cdd0474039d176c55b19d531070dbe17856bfb993a5b5720b',
447
+ DataChanged: '0xece574603820d07bc9b91f2a932baadf4628aabcb8afba49776529c14a6104b2',
220
448
  },
221
449
  // ERC725Account
222
450
  LSP0: {
@@ -234,25 +462,26 @@ const EventSignatures = {
234
462
  /**
235
463
  * event UniversalReceiver(
236
464
  * address indexed from,
465
+ * uint256 value,
237
466
  * bytes32 indexed typeId,
238
467
  * bytes indexed returnedValue,
239
468
  * bytes receivedData
240
469
  * );
241
470
  *
242
- * signature = keccak256('UniversalReceiver(address,bytes32,bytes,bytes)')
471
+ * signature = keccak256('UniversalReceiver(address,uint256,bytes32,bytes,bytes)')
243
472
  */
244
- UniversalReceiver: '0x8187df79ab47ad16102e7bc8760349a115b3ba9869b8cedd78996f930ac9cac3',
473
+ UniversalReceiver: '0x9c3ba68eb5742b8e3961aea0afc7371a71bf433c8a67a831803b64c064a178c2',
245
474
  },
246
475
  LSP6: {
247
476
  /**
248
477
  * event Executed(
249
478
  * uint256 indexed _value,
250
- * bytes _data
479
+ * bytes4 _data
251
480
  * );
252
481
  *
253
- * signature = keccak256('Executed(uint256,bytes)')
482
+ * signature = keccak256('Executed(uint256,bytes4)')
254
483
  */
255
- Executed: '0x2e733a17851169f232b3859260eb3ad2a086afd54e999eb4ea9afb7791702e41',
484
+ Executed: '0x6b9340454526f665e369d7ac17353d0b73774a4a80f746b959ece8130e0f1d72',
256
485
  },
257
486
  LSP7: {
258
487
  /**
@@ -323,6 +552,17 @@ const EventSignatures = {
323
552
  */
324
553
  RevokedOperator: '17d5389f6ab6adb2647dfa0aa365c323d37adacc30b33a65310b6158ce1373d5',
325
554
  },
555
+ LSP9: {
556
+ /**
557
+ * event ValueReceived(
558
+ * address indexed sender,
559
+ * uint256 indexed value
560
+ * );
561
+ *
562
+ * signature = keccak256('ValueReceived(address,uint256)')
563
+ */
564
+ ValueReceived: '0x7e71433ddf847725166244795048ecf3e3f9f35628254ecbf736056664233493',
565
+ },
326
566
  Helpers: {
327
567
  /**
328
568
  * event ReceivedERC777(
@@ -348,5 +588,7 @@ module.exports = {
348
588
  BasicUPSetup_Schema,
349
589
  ALL_PERMISSIONS,
350
590
  PERMISSIONS,
591
+ LSP1_TYPE_IDS,
592
+ Errors,
351
593
  EventSignatures,
352
594
  };
@@ -1,31 +1,96 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  pragma solidity ^0.8.0;
3
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
4
  // interfaces
9
5
  import {IClaimOwnership} from "./IClaimOwnership.sol";
10
6
 
11
7
  // modules
12
8
  import {OwnableUnset} from "@erc725/smart-contracts/contracts/custom/OwnableUnset.sol";
13
9
 
10
+ /**
11
+ * @dev reverts when trying to renounce ownership before the initial confirmation delay
12
+ */
13
+ error NotInRenounceOwnershipInterval(uint256 renounceOwnershipStart, uint256 renounceOwnershipEnd);
14
+
15
+ /**
16
+ * @dev reverts when trying to transfer ownership to the address(this)
17
+ */
18
+ error CannotTransferOwnershipToSelf();
19
+
20
+ /**
21
+ * @title ClaimOwnership
22
+ * @author Fabian Vogelsteller <fabian@lukso.network>, Jean Cavallera (CJ42), Yamen Merhi (YamenMerhi), Daniel Afteni (B00ste)
23
+ * @dev This contract is a modified version of the OwnableUnset implementation, where transferring and renouncing ownership
24
+ * works as a 2 steps process. This can be used as a confirmation mechanism to prevent potential mistakes when
25
+ * transferring ownership of the contract, where the control of the contract could be lost forever.
26
+ */
14
27
  abstract contract ClaimOwnership is IClaimOwnership, OwnableUnset {
28
+
29
+ /**
30
+ * @dev The number of block that need to pass before one is able to
31
+ * confirm renouncing ownership
32
+ */
33
+ uint256 private constant _RENOUNCE_OWNERSHIP_CONFIRMATION_DELAY = 100;
34
+
35
+ /**
36
+ * @dev The number of blocks during which one can renounce ownership
37
+ */
38
+ uint256 private constant _RENOUNCE_OWNERSHIP_CONFIRMATION_PERIOD = 100;
39
+
40
+ /**
41
+ * @dev The block number saved when initiating the process of
42
+ * renouncing ownerhsip
43
+ */
44
+ uint256 private _renounceOwnershipStartedAt;
45
+
46
+ /**
47
+ * @dev The address that may use `claimOwnership()`
48
+ */
15
49
  address public override pendingOwner;
16
50
 
17
51
  function claimOwnership() public virtual override {
18
- require(msg.sender == pendingOwner, "OwnableClaim: caller is not the pendingOwner");
52
+ _claimOwnership();
53
+ }
19
54
 
55
+ function transferOwnership(address newOwner) public virtual override onlyOwner {
56
+ _transferOwnership(newOwner);
57
+ }
58
+
59
+ function renounceOwnership() public virtual override onlyOwner {
60
+ _renounceOwnership();
61
+ }
62
+
63
+ function _claimOwnership() internal virtual {
64
+ require(msg.sender == pendingOwner, "ClaimOwnership: caller is not the pendingOwner");
20
65
  _setOwner(pendingOwner);
21
66
  pendingOwner = address(0);
22
67
  }
23
68
 
24
- function transferOwnership(address _newOwner) public virtual override onlyOwner {
25
- _transferOwnership(_newOwner);
69
+ function _transferOwnership(address newOwner) internal virtual {
70
+ if (newOwner == address(this)) revert CannotTransferOwnershipToSelf();
71
+ pendingOwner = newOwner;
26
72
  }
27
73
 
28
- function _transferOwnership(address _newOwner) internal virtual {
29
- pendingOwner = _newOwner;
74
+ /**
75
+ * @dev This method is used to initiate or confirm the process of
76
+ * renouncing ownership.
77
+ */
78
+ function _renounceOwnership() internal virtual {
79
+ uint256 currentBlock = block.number;
80
+ uint256 confirmationPeriodStart = _renounceOwnershipStartedAt + _RENOUNCE_OWNERSHIP_CONFIRMATION_DELAY;
81
+ uint256 confirmationPeriodEnd = confirmationPeriodStart + _RENOUNCE_OWNERSHIP_CONFIRMATION_PERIOD;
82
+
83
+ if (currentBlock > confirmationPeriodEnd) {
84
+ _renounceOwnershipStartedAt = currentBlock;
85
+ emit RenounceOwnershipInitiated();
86
+ return;
87
+ }
88
+
89
+ if (currentBlock < confirmationPeriodStart) {
90
+ revert NotInRenounceOwnershipInterval(confirmationPeriodStart, confirmationPeriodEnd);
91
+ }
92
+
93
+ _setOwner(address(0));
94
+ delete _renounceOwnershipStartedAt;
30
95
  }
31
96
  }
@@ -125,6 +125,6 @@ library ERC165Checker {
125
125
  );
126
126
  (bool success, bytes memory result) = account.staticcall{gas: 30000}(encodedParams);
127
127
  if (result.length < 32) return false;
128
- return success && abi.decode(result, (bool));
128
+ return success && abi.decode(result, (uint256)) > 0;
129
129
  }
130
130
  }
@@ -1,9 +1,11 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  pragma solidity ^0.8.0;
3
3
 
4
- bytes4 constant _INTERFACEID_CLAIM_OWNERSHIP = 0xad7dd9b0;
4
+ bytes4 constant _INTERFACEID_CLAIM_OWNERSHIP = 0xa375e9c6;
5
5
 
6
6
  interface IClaimOwnership {
7
+ event RenounceOwnershipInitiated();
8
+
7
9
  function pendingOwner() external view returns (address);
8
10
 
9
11
  function claimOwnership() external;
@@ -43,11 +43,7 @@ contract Create2Factory {
43
43
  * - `bytecode` must not be empty.
44
44
  * - `salt` must have not been used for `bytecode` already.
45
45
  */
46
- function deploy(bytes32 salt, bytes memory bytecode)
47
- public
48
- payable
49
- returns (address)
50
- {
46
+ function deploy(bytes32 salt, bytes memory bytecode) public payable returns (address) {
51
47
  address addr;
52
48
  uint256 amount = msg.value;
53
49
 
@@ -67,11 +63,7 @@ contract Create2Factory {
67
63
  * @dev Returns the address where a contract will be stored if deployed via {deploy}. Any change in the
68
64
  * `bytecodeHash` or `salt` will result in a new destination address.
69
65
  */
70
- function computeAddress(bytes32 salt, bytes32 bytecodeHash)
71
- public
72
- view
73
- returns (address)
74
- {
66
+ function computeAddress(bytes32 salt, bytes32 bytecodeHash) public view returns (address) {
75
67
  return computeAddress(salt, bytecodeHash, address(this));
76
68
  }
77
69
 
@@ -84,9 +76,7 @@ contract Create2Factory {
84
76
  bytes32 bytecodeHash,
85
77
  address deployer
86
78
  ) public pure returns (address) {
87
- bytes32 _data = keccak256(
88
- abi.encodePacked(bytes1(0xff), deployer, salt, bytecodeHash)
89
- );
79
+ bytes32 _data = keccak256(abi.encodePacked(bytes1(0xff), deployer, salt, bytecodeHash));
90
80
  return address(uint160(uint256(_data)));
91
81
  }
92
82
  }
@@ -5,7 +5,7 @@ pragma solidity ^0.8.0;
5
5
  import {Create2} from "@openzeppelin/contracts/utils/Create2.sol";
6
6
  import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";
7
7
  import {BytesLib} from "solidity-bytes-utils/contracts/BytesLib.sol";
8
- import {ErrorHandlerLib} from "@erc725/smart-contracts/contracts/utils/ErrorHandlerLib.sol";
8
+ import {Address} from "@openzeppelin/contracts/utils/Address.sol";
9
9
 
10
10
  /**
11
11
  * @dev UniversalFactory contract can be used to deploy CREATE2 contracts; normal contracts and minimal
@@ -90,10 +90,14 @@ contract UniversalFactory {
90
90
  bytes32 generatedSalt = _generateSalt(initializeCallData, salt);
91
91
  contractCreated = Create2.deploy(msg.value, generatedSalt, byteCode);
92
92
 
93
- if (initializeCallData.length > 0) {
93
+ if (initializeCallData.length != 0) {
94
94
  // solhint-disable avoid-low-level-calls
95
- (bool success, bytes memory returnedData) = contractCreated.call(initializeCallData);
96
- if (!success) ErrorHandlerLib.revertWithParsedError(returnedData);
95
+ (bool success, bytes memory returnData) = contractCreated.call(initializeCallData);
96
+ Address.verifyCallResult(
97
+ success,
98
+ returnData,
99
+ "UniversalFactory: could not initialize the created contract"
100
+ );
97
101
  }
98
102
  }
99
103
 
@@ -117,21 +121,21 @@ contract UniversalFactory {
117
121
  bytes32 generatedSalt = _generateSalt(initializeCallData, salt);
118
122
  proxy = Clones.cloneDeterministic(baseContract, generatedSalt);
119
123
 
120
- if (initializeCallData.length > 0) {
124
+ if (initializeCallData.length != 0) {
121
125
  // solhint-disable avoid-low-level-calls
122
- (bool success, bytes memory returnedData) = proxy.call{value: msg.value}(
126
+ (bool success, bytes memory returnData) = proxy.call{value: msg.value}(
123
127
  initializeCallData
124
128
  );
125
- if (!success) ErrorHandlerLib.revertWithParsedError(returnedData);
129
+ Address.verifyCallResult(
130
+ success,
131
+ returnData,
132
+ "UniversalFactory: could not initialize the created contract"
133
+ );
126
134
  } 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
+ require(
136
+ msg.value == 0,
137
+ "UniversalFactory: value cannot be sent to the factory if initializeCallData is empty"
138
+ );
135
139
  }
136
140
  }
137
141
 
@@ -145,7 +149,7 @@ contract UniversalFactory {
145
149
  pure
146
150
  returns (bytes32)
147
151
  {
148
- bool initializable = initializeCallData.length > 0;
152
+ bool initializable = initializeCallData.length != 0;
149
153
  if (initializable) {
150
154
  return keccak256(abi.encodePacked(initializable, initializeCallData, salt));
151
155
  } else {
@@ -2,7 +2,7 @@
2
2
  pragma solidity ^0.8.0;
3
3
 
4
4
  // --- ERC165 interface ids
5
- bytes4 constant _INTERFACEID_LSP0 = 0x9a3bfe88;
5
+ bytes4 constant _INTERFACEID_LSP0 = 0xeb6be62e;
6
6
  bytes4 constant _INTERFACEID_ERC1271 = 0x1626ba7e;
7
7
 
8
8
  // ERC1271 - Standard Signature Validation