@lukso/lsp-smart-contracts 0.10.2 → 0.11.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.
- package/CONTRIBUTING.md +184 -0
- package/artifacts/LSP0ERC725Account.json +2 -2
- package/artifacts/LSP0ERC725AccountInit.json +2 -2
- package/artifacts/LSP6KeyManager.json +2 -2
- package/artifacts/LSP6KeyManagerInit.json +2 -2
- package/artifacts/LSP7CompatibleERC20Mintable.json +2 -2
- package/artifacts/LSP7CompatibleERC20MintableInit.json +2 -2
- package/artifacts/LSP8CompatibleERC721Mintable.json +2 -2
- package/artifacts/LSP8CompatibleERC721MintableInit.json +2 -2
- package/artifacts/LSP9Vault.json +2 -2
- package/artifacts/LSP9VaultInit.json +2 -2
- package/artifacts/UniversalProfile.json +2 -2
- package/artifacts/UniversalProfileInit.json +2 -2
- package/contracts/LSP0ERC725Account/LSP0ERC725AccountCore.sol +1 -1
- package/contracts/LSP20CallVerification/LSP20CallVerification.sol +6 -3
- package/contracts/LSP23MultiChainDeployment/IOwnerControlledContractDeployer.sol +174 -0
- package/contracts/LSP23MultiChainDeployment/IPostDeploymentModule.sol +10 -0
- package/contracts/LSP23MultiChainDeployment/LSP23Errors.sol +24 -0
- package/contracts/LSP23MultiChainDeployment/OwnerControlledContractDeployer.sol +388 -0
- package/contracts/LSP23MultiChainDeployment/modules/UniversalProfileInitPostDeploymentModule.sol +59 -0
- package/contracts/LSP6KeyManager/LSP6KeyManagerCore.sol +5 -5
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6ExecuteModule.sol +4 -4
- package/contracts/LSP6KeyManager/LSP6Modules/LSP6SetDataModule.sol +1 -1
- package/contracts/LSP7DigitalAsset/extensions/LSP7Burnable.sol +5 -1
- package/contracts/LSP7DigitalAsset/extensions/LSP7BurnableInitAbstract.sol +5 -1
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20Mintable.sol +1 -1
- package/contracts/LSP7DigitalAsset/presets/LSP7CompatibleERC20MintableInitAbstract.sol +1 -1
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8Burnable.sol +1 -1
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721.sol +23 -23
- package/contracts/LSP8IdentifiableDigitalAsset/extensions/LSP8CompatibleERC721InitAbstract.sol +23 -23
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721Mintable.sol +1 -1
- package/contracts/LSP8IdentifiableDigitalAsset/presets/LSP8CompatibleERC721MintableInitAbstract.sol +1 -1
- package/contracts/LSP9Vault/LSP9VaultCore.sol +7 -2
- package/package.json +11 -8
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.4;
|
|
3
|
+
|
|
4
|
+
import {Create2} from "@openzeppelin/contracts/utils/Create2.sol";
|
|
5
|
+
import {Clones} from "@openzeppelin/contracts/proxy/Clones.sol";
|
|
6
|
+
import {IPostDeploymentModule} from "./IPostDeploymentModule.sol";
|
|
7
|
+
import {
|
|
8
|
+
IOwnerControlledContractDeployer
|
|
9
|
+
} from "./IOwnerControlledContractDeployer.sol";
|
|
10
|
+
import {
|
|
11
|
+
InvalidValueSum,
|
|
12
|
+
ControlledContractProxyInitFailureError,
|
|
13
|
+
OwnerContractProxyInitFailureError
|
|
14
|
+
} from "./LSP23Errors.sol";
|
|
15
|
+
|
|
16
|
+
contract OwnerControlledContractDeployer is IOwnerControlledContractDeployer {
|
|
17
|
+
/**
|
|
18
|
+
* @inheritdoc IOwnerControlledContractDeployer
|
|
19
|
+
*/
|
|
20
|
+
function deployContracts(
|
|
21
|
+
ControlledContractDeployment calldata controlledContractDeployment,
|
|
22
|
+
OwnerContractDeployment calldata ownerContractDeployment,
|
|
23
|
+
address postDeploymentModule,
|
|
24
|
+
bytes calldata postDeploymentModuleCalldata
|
|
25
|
+
)
|
|
26
|
+
public
|
|
27
|
+
payable
|
|
28
|
+
returns (
|
|
29
|
+
address controlledContractAddress,
|
|
30
|
+
address ownerContractAddress
|
|
31
|
+
)
|
|
32
|
+
{
|
|
33
|
+
/* check that the msg.value is equal to the sum of the values of the controlled and owner contracts */
|
|
34
|
+
if (
|
|
35
|
+
msg.value !=
|
|
36
|
+
controlledContractDeployment.fundingAmount +
|
|
37
|
+
ownerContractDeployment.fundingAmount
|
|
38
|
+
) {
|
|
39
|
+
revert InvalidValueSum();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
controlledContractAddress = _deployControlledContract(
|
|
43
|
+
controlledContractDeployment,
|
|
44
|
+
ownerContractDeployment,
|
|
45
|
+
postDeploymentModule,
|
|
46
|
+
postDeploymentModuleCalldata
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
ownerContractAddress = _deployOwnerContract(
|
|
50
|
+
ownerContractDeployment,
|
|
51
|
+
controlledContractAddress
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
emit DeployedContracts(
|
|
55
|
+
controlledContractAddress,
|
|
56
|
+
ownerContractAddress,
|
|
57
|
+
controlledContractDeployment,
|
|
58
|
+
ownerContractDeployment,
|
|
59
|
+
postDeploymentModule,
|
|
60
|
+
postDeploymentModuleCalldata
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
/* execute the post deployment module logic in the postDeploymentModule */
|
|
64
|
+
IPostDeploymentModule(postDeploymentModule).executePostDeployment(
|
|
65
|
+
controlledContractAddress,
|
|
66
|
+
ownerContractAddress,
|
|
67
|
+
postDeploymentModuleCalldata
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @inheritdoc IOwnerControlledContractDeployer
|
|
73
|
+
*/
|
|
74
|
+
function deployERC1167Proxies(
|
|
75
|
+
ControlledContractDeploymentInit
|
|
76
|
+
calldata controlledContractDeploymentInit,
|
|
77
|
+
OwnerContractDeploymentInit calldata ownerContractDeploymentInit,
|
|
78
|
+
address postDeploymentModule,
|
|
79
|
+
bytes calldata postDeploymentModuleCalldata
|
|
80
|
+
)
|
|
81
|
+
public
|
|
82
|
+
payable
|
|
83
|
+
returns (
|
|
84
|
+
address controlledContractAddress,
|
|
85
|
+
address ownerContractAddress
|
|
86
|
+
)
|
|
87
|
+
{
|
|
88
|
+
/* check that the msg.value is equal to the sum of the values of the controlled and owner contracts */
|
|
89
|
+
if (
|
|
90
|
+
msg.value !=
|
|
91
|
+
controlledContractDeploymentInit.fundingAmount +
|
|
92
|
+
ownerContractDeploymentInit.fundingAmount
|
|
93
|
+
) {
|
|
94
|
+
revert InvalidValueSum();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/* deploy the controlled contract proxy with the controlledContractGeneratedSalt */
|
|
98
|
+
controlledContractAddress = _deployAndInitializeControlledContractProxy(
|
|
99
|
+
controlledContractDeploymentInit,
|
|
100
|
+
ownerContractDeploymentInit,
|
|
101
|
+
postDeploymentModule,
|
|
102
|
+
postDeploymentModuleCalldata
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
/* deploy the owner contract proxy */
|
|
106
|
+
ownerContractAddress = _deployAndInitializeOwnerContractProxy(
|
|
107
|
+
ownerContractDeploymentInit,
|
|
108
|
+
controlledContractAddress
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
emit DeployedERC1167Proxies(
|
|
112
|
+
controlledContractAddress,
|
|
113
|
+
ownerContractAddress,
|
|
114
|
+
controlledContractDeploymentInit,
|
|
115
|
+
ownerContractDeploymentInit,
|
|
116
|
+
postDeploymentModule,
|
|
117
|
+
postDeploymentModuleCalldata
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
/* execute the post deployment logic in the postDeploymentModule */
|
|
121
|
+
IPostDeploymentModule(postDeploymentModule).executePostDeployment(
|
|
122
|
+
controlledContractAddress,
|
|
123
|
+
ownerContractAddress,
|
|
124
|
+
postDeploymentModuleCalldata
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* @inheritdoc IOwnerControlledContractDeployer
|
|
130
|
+
*/
|
|
131
|
+
function computeAddresses(
|
|
132
|
+
ControlledContractDeployment calldata controlledContractDeployment,
|
|
133
|
+
OwnerContractDeployment calldata ownerContractDeployment,
|
|
134
|
+
address postDeploymentModule,
|
|
135
|
+
bytes calldata postDeploymentModuleCalldata
|
|
136
|
+
)
|
|
137
|
+
public
|
|
138
|
+
view
|
|
139
|
+
returns (
|
|
140
|
+
address controlledContractAddress,
|
|
141
|
+
address ownerContractAddress
|
|
142
|
+
)
|
|
143
|
+
{
|
|
144
|
+
bytes32 controlledContractGeneratedSalt = _generateControlledContractSalt(
|
|
145
|
+
controlledContractDeployment,
|
|
146
|
+
ownerContractDeployment,
|
|
147
|
+
postDeploymentModule,
|
|
148
|
+
postDeploymentModuleCalldata
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
controlledContractAddress = Create2.computeAddress(
|
|
152
|
+
controlledContractGeneratedSalt,
|
|
153
|
+
keccak256(controlledContractDeployment.creationBytecode)
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
bytes memory ownerContractByteCodeWithAllParams;
|
|
157
|
+
if (ownerContractDeployment.addControlledContractAddress) {
|
|
158
|
+
ownerContractByteCodeWithAllParams = abi.encodePacked(
|
|
159
|
+
ownerContractDeployment.creationBytecode,
|
|
160
|
+
abi.encode(controlledContractAddress),
|
|
161
|
+
ownerContractDeployment.extraConstructorParams
|
|
162
|
+
);
|
|
163
|
+
} else {
|
|
164
|
+
ownerContractByteCodeWithAllParams = ownerContractDeployment
|
|
165
|
+
.creationBytecode;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
ownerContractAddress = Create2.computeAddress(
|
|
169
|
+
keccak256(abi.encodePacked(controlledContractAddress)),
|
|
170
|
+
keccak256(ownerContractByteCodeWithAllParams)
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* @inheritdoc IOwnerControlledContractDeployer
|
|
176
|
+
*/
|
|
177
|
+
function computeERC1167Addresses(
|
|
178
|
+
ControlledContractDeploymentInit
|
|
179
|
+
calldata controlledContractDeploymentInit,
|
|
180
|
+
OwnerContractDeploymentInit calldata ownerContractDeploymentInit,
|
|
181
|
+
address postDeploymentModule,
|
|
182
|
+
bytes calldata postDeploymentModuleCalldata
|
|
183
|
+
)
|
|
184
|
+
public
|
|
185
|
+
view
|
|
186
|
+
returns (
|
|
187
|
+
address controlledContractAddress,
|
|
188
|
+
address ownerContractAddress
|
|
189
|
+
)
|
|
190
|
+
{
|
|
191
|
+
bytes32 controlledContractGeneratedSalt = _generateControlledProxyContractSalt(
|
|
192
|
+
controlledContractDeploymentInit,
|
|
193
|
+
ownerContractDeploymentInit,
|
|
194
|
+
postDeploymentModule,
|
|
195
|
+
postDeploymentModuleCalldata
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
controlledContractAddress = Clones.predictDeterministicAddress(
|
|
199
|
+
controlledContractDeploymentInit.implementationContract,
|
|
200
|
+
controlledContractGeneratedSalt
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
ownerContractAddress = Clones.predictDeterministicAddress(
|
|
204
|
+
ownerContractDeploymentInit.implementationContract,
|
|
205
|
+
keccak256(abi.encodePacked(controlledContractAddress))
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function _deployControlledContract(
|
|
210
|
+
ControlledContractDeployment calldata controlledContractDeployment,
|
|
211
|
+
OwnerContractDeployment calldata ownerContractDeployment,
|
|
212
|
+
address postDeploymentModule,
|
|
213
|
+
bytes calldata postDeploymentModuleCalldata
|
|
214
|
+
) internal returns (address controlledContractAddress) {
|
|
215
|
+
bytes32 controlledContractGeneratedSalt = _generateControlledContractSalt(
|
|
216
|
+
controlledContractDeployment,
|
|
217
|
+
ownerContractDeployment,
|
|
218
|
+
postDeploymentModule,
|
|
219
|
+
postDeploymentModuleCalldata
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
/* deploy the controlled contract */
|
|
223
|
+
controlledContractAddress = Create2.deploy(
|
|
224
|
+
controlledContractDeployment.fundingAmount,
|
|
225
|
+
controlledContractGeneratedSalt,
|
|
226
|
+
controlledContractDeployment.creationBytecode
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function _deployOwnerContract(
|
|
231
|
+
OwnerContractDeployment calldata ownerContractDeployment,
|
|
232
|
+
address controlledContractAddress
|
|
233
|
+
) internal returns (address ownerContractAddress) {
|
|
234
|
+
/**
|
|
235
|
+
* If `addControlledContractAddress` is `true`, the following will be appended to the constructor params:
|
|
236
|
+
* - The controlled contract address
|
|
237
|
+
* - `extraConstructorParams`
|
|
238
|
+
*/
|
|
239
|
+
bytes memory ownerContractByteCode = ownerContractDeployment
|
|
240
|
+
.creationBytecode;
|
|
241
|
+
|
|
242
|
+
if (ownerContractDeployment.addControlledContractAddress) {
|
|
243
|
+
ownerContractByteCode = abi.encodePacked(
|
|
244
|
+
ownerContractByteCode,
|
|
245
|
+
abi.encode(controlledContractAddress),
|
|
246
|
+
ownerContractDeployment.extraConstructorParams
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/* Here owner refers to the future owner of the controlled contract at the end of the transaction */
|
|
251
|
+
ownerContractAddress = Create2.deploy(
|
|
252
|
+
ownerContractDeployment.fundingAmount,
|
|
253
|
+
keccak256(abi.encodePacked(controlledContractAddress)),
|
|
254
|
+
ownerContractByteCode
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function _deployAndInitializeControlledContractProxy(
|
|
259
|
+
ControlledContractDeploymentInit
|
|
260
|
+
calldata controlledContractDeploymentInit,
|
|
261
|
+
OwnerContractDeploymentInit calldata ownerContractDeploymentInit,
|
|
262
|
+
address postDeploymentModule,
|
|
263
|
+
bytes calldata postDeploymentModuleCalldata
|
|
264
|
+
) internal returns (address controlledContractAddress) {
|
|
265
|
+
bytes32 controlledContractGeneratedSalt = _generateControlledProxyContractSalt(
|
|
266
|
+
controlledContractDeploymentInit,
|
|
267
|
+
ownerContractDeploymentInit,
|
|
268
|
+
postDeploymentModule,
|
|
269
|
+
postDeploymentModuleCalldata
|
|
270
|
+
);
|
|
271
|
+
|
|
272
|
+
/* deploy the controlled contract proxy with the controlledContractGeneratedSalt */
|
|
273
|
+
controlledContractAddress = Clones.cloneDeterministic(
|
|
274
|
+
controlledContractDeploymentInit.implementationContract,
|
|
275
|
+
controlledContractGeneratedSalt
|
|
276
|
+
);
|
|
277
|
+
|
|
278
|
+
/* initialize the controlled contract proxy */
|
|
279
|
+
(bool success, bytes memory returnedData) = controlledContractAddress
|
|
280
|
+
.call{value: msg.value}(
|
|
281
|
+
controlledContractDeploymentInit.initializationCalldata
|
|
282
|
+
);
|
|
283
|
+
if (!success) {
|
|
284
|
+
revert ControlledContractProxyInitFailureError(returnedData);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
function _deployAndInitializeOwnerContractProxy(
|
|
289
|
+
OwnerContractDeploymentInit calldata ownerContractDeploymentInit,
|
|
290
|
+
address controlledContractAddress
|
|
291
|
+
) internal returns (address ownerContractAddress) {
|
|
292
|
+
/* deploy the controlled contract proxy with the controlledContractGeneratedSalt */
|
|
293
|
+
ownerContractAddress = Clones.cloneDeterministic(
|
|
294
|
+
ownerContractDeploymentInit.implementationContract,
|
|
295
|
+
keccak256(abi.encodePacked(controlledContractAddress))
|
|
296
|
+
);
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* If `addControlledContractAddress` is `true`, the following will be appended to the `initializationCalldata`:
|
|
300
|
+
* - The controlled contract address
|
|
301
|
+
* - `extraInitialisationBytes`
|
|
302
|
+
*/
|
|
303
|
+
bytes memory ownerInitializationBytes = ownerContractDeploymentInit
|
|
304
|
+
.initializationCalldata;
|
|
305
|
+
|
|
306
|
+
if (ownerContractDeploymentInit.addControlledContractAddress) {
|
|
307
|
+
ownerInitializationBytes = abi.encodePacked(
|
|
308
|
+
ownerInitializationBytes,
|
|
309
|
+
abi.encode(controlledContractAddress),
|
|
310
|
+
ownerContractDeploymentInit.extraInitializationParams
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/* initialize the controlled contract proxy */
|
|
315
|
+
(bool success, bytes memory returnedData) = ownerContractAddress.call{
|
|
316
|
+
value: msg.value
|
|
317
|
+
}(ownerInitializationBytes);
|
|
318
|
+
if (!success) {
|
|
319
|
+
revert OwnerContractProxyInitFailureError(returnedData);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
function _generateControlledContractSalt(
|
|
324
|
+
ControlledContractDeployment calldata controlledContractDeployment,
|
|
325
|
+
OwnerContractDeployment calldata ownerContractDeployment,
|
|
326
|
+
address postDeploymentModule,
|
|
327
|
+
bytes calldata postDeploymentModuleCalldata
|
|
328
|
+
) internal pure virtual returns (bytes32 controlledContractGeneratedSalt) {
|
|
329
|
+
/* generate salt for the controlled contract
|
|
330
|
+
* the salt is generated by hashing the following elements:
|
|
331
|
+
* - the salt
|
|
332
|
+
* - the owner contract bytecode
|
|
333
|
+
* - the owner addControlledContractAddress boolean
|
|
334
|
+
* - the owner extraConstructorParams
|
|
335
|
+
* - the postDeploymentModule address
|
|
336
|
+
* - the postDeploymentModuleCalldata
|
|
337
|
+
*
|
|
338
|
+
*/
|
|
339
|
+
controlledContractGeneratedSalt = keccak256(
|
|
340
|
+
abi.encode(
|
|
341
|
+
controlledContractDeployment.salt,
|
|
342
|
+
controlledContractDeployment.creationBytecode,
|
|
343
|
+
ownerContractDeployment.creationBytecode,
|
|
344
|
+
ownerContractDeployment.addControlledContractAddress,
|
|
345
|
+
ownerContractDeployment.extraConstructorParams,
|
|
346
|
+
postDeploymentModule,
|
|
347
|
+
postDeploymentModuleCalldata
|
|
348
|
+
)
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
function _generateControlledProxyContractSalt(
|
|
353
|
+
ControlledContractDeploymentInit
|
|
354
|
+
calldata controlledContractDeploymentInit,
|
|
355
|
+
OwnerContractDeploymentInit calldata ownerContractDeploymentInit,
|
|
356
|
+
address postDeploymentModule,
|
|
357
|
+
bytes calldata postDeploymentModuleCalldata
|
|
358
|
+
)
|
|
359
|
+
internal
|
|
360
|
+
pure
|
|
361
|
+
virtual
|
|
362
|
+
returns (bytes32 controlledProxyContractGeneratedSalt)
|
|
363
|
+
{
|
|
364
|
+
/**
|
|
365
|
+
* Generate the salt for the controlled contract
|
|
366
|
+
* The salt is generated by hashing the following elements:
|
|
367
|
+
* - the salt
|
|
368
|
+
* - the owner implementation contract address
|
|
369
|
+
* - the owner contract addControlledContractAddress boolean
|
|
370
|
+
* - the owner contract initialization calldata
|
|
371
|
+
* - the owner contract extra initialization params (if any)
|
|
372
|
+
* - the postDeploymentModule address
|
|
373
|
+
* - the callda to the post deployment module
|
|
374
|
+
*
|
|
375
|
+
*/
|
|
376
|
+
controlledProxyContractGeneratedSalt = keccak256(
|
|
377
|
+
abi.encode(
|
|
378
|
+
controlledContractDeploymentInit.salt,
|
|
379
|
+
ownerContractDeploymentInit.implementationContract,
|
|
380
|
+
ownerContractDeploymentInit.initializationCalldata,
|
|
381
|
+
ownerContractDeploymentInit.addControlledContractAddress,
|
|
382
|
+
ownerContractDeploymentInit.extraInitializationParams,
|
|
383
|
+
postDeploymentModule,
|
|
384
|
+
postDeploymentModuleCalldata
|
|
385
|
+
)
|
|
386
|
+
);
|
|
387
|
+
}
|
|
388
|
+
}
|
package/contracts/LSP23MultiChainDeployment/modules/UniversalProfileInitPostDeploymentModule.sol
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.4;
|
|
3
|
+
|
|
4
|
+
import {UniversalProfileInit} from "../../UniversalProfileInit.sol";
|
|
5
|
+
|
|
6
|
+
contract UniversalProfileInitPostDeploymentModule is UniversalProfileInit {
|
|
7
|
+
constructor() {
|
|
8
|
+
_disableInitializers();
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function setDataAndTransferOwnership(
|
|
12
|
+
bytes32[] memory dataKeys,
|
|
13
|
+
bytes[] memory dataValues,
|
|
14
|
+
address newOwner
|
|
15
|
+
) public payable {
|
|
16
|
+
// check that the msg.sender is the owner
|
|
17
|
+
require(
|
|
18
|
+
msg.sender == owner(),
|
|
19
|
+
"UniversalProfileInitPostDeploymentModule: setDataAndTransferOwnership only allowed through delegate call"
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
// update the dataKeys and dataValues in the UniversalProfile contract
|
|
23
|
+
for (uint256 i = 0; i < dataKeys.length; ) {
|
|
24
|
+
_setData(dataKeys[i], dataValues[i]);
|
|
25
|
+
|
|
26
|
+
unchecked {
|
|
27
|
+
++i;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// transfer the ownership of the UniversalProfile contract to the newOwner
|
|
32
|
+
_setOwner(newOwner);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function executePostDeployment(
|
|
36
|
+
address universalProfile,
|
|
37
|
+
address keyManager,
|
|
38
|
+
bytes calldata setDataBatchBytes
|
|
39
|
+
) public {
|
|
40
|
+
// retrieve the dataKeys and dataValues to setData from the initializationCalldata bytes
|
|
41
|
+
(bytes32[] memory dataKeys, bytes[] memory dataValues) = abi.decode(
|
|
42
|
+
setDataBatchBytes,
|
|
43
|
+
(bytes32[], bytes[])
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
// call the execute function with delegate_call on the universalProfile contract to setData and transferOwnership
|
|
47
|
+
UniversalProfileInit(payable(universalProfile)).execute(
|
|
48
|
+
4,
|
|
49
|
+
address(this),
|
|
50
|
+
0,
|
|
51
|
+
abi.encodeWithSignature(
|
|
52
|
+
"setDataAndTransferOwnership(bytes32[],bytes[],address)",
|
|
53
|
+
dataKeys,
|
|
54
|
+
dataValues,
|
|
55
|
+
keyManager
|
|
56
|
+
)
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -78,11 +78,11 @@ abstract contract LSP6KeyManagerCore is
|
|
|
78
78
|
|
|
79
79
|
// Variables, methods and modifier used for ReentrancyGuard are taken from the link below and modified accordingly.
|
|
80
80
|
// https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v4.8/contracts/security/ReentrancyGuard.sol
|
|
81
|
-
bool
|
|
81
|
+
bool internal _reentrancyStatus;
|
|
82
82
|
|
|
83
83
|
mapping(address => mapping(uint256 => uint256)) internal _nonceStore;
|
|
84
84
|
|
|
85
|
-
function target() public view returns (address) {
|
|
85
|
+
function target() public view virtual returns (address) {
|
|
86
86
|
return _target;
|
|
87
87
|
}
|
|
88
88
|
|
|
@@ -116,7 +116,7 @@ abstract contract LSP6KeyManagerCore is
|
|
|
116
116
|
function isValidSignature(
|
|
117
117
|
bytes32 dataHash,
|
|
118
118
|
bytes memory signature
|
|
119
|
-
) public view returns (bytes4 magicValue) {
|
|
119
|
+
) public view virtual returns (bytes4 magicValue) {
|
|
120
120
|
// if isValidSignature fail, the error is catched in returnedError
|
|
121
121
|
(address recoveredAddress, ECDSA.RecoverError returnedError) = ECDSA
|
|
122
122
|
.tryRecover(dataHash, signature);
|
|
@@ -250,7 +250,7 @@ abstract contract LSP6KeyManagerCore is
|
|
|
250
250
|
address caller,
|
|
251
251
|
uint256 msgValue,
|
|
252
252
|
bytes calldata data
|
|
253
|
-
) external returns (bytes4) {
|
|
253
|
+
) external virtual returns (bytes4) {
|
|
254
254
|
bool isSetData = false;
|
|
255
255
|
if (
|
|
256
256
|
bytes4(data) == IERC725Y.setData.selector ||
|
|
@@ -301,7 +301,7 @@ abstract contract LSP6KeyManagerCore is
|
|
|
301
301
|
function lsp20VerifyCallResult(
|
|
302
302
|
bytes32 /*callHash*/,
|
|
303
303
|
bytes memory /*result*/
|
|
304
|
-
) external returns (bytes4) {
|
|
304
|
+
) external virtual returns (bytes4) {
|
|
305
305
|
// If it's the target calling, set back the reentrancy guard
|
|
306
306
|
// to false, if not return the magic value
|
|
307
307
|
if (msg.sender == _target) {
|
|
@@ -364,7 +364,7 @@ abstract contract LSP6ExecuteModule {
|
|
|
364
364
|
function _isAllowedAddress(
|
|
365
365
|
bytes memory allowedCall,
|
|
366
366
|
address to
|
|
367
|
-
) internal pure returns (bool) {
|
|
367
|
+
) internal pure virtual returns (bool) {
|
|
368
368
|
// <offset> = 4 bytes x 8 bits = 32 bits
|
|
369
369
|
//
|
|
370
370
|
// <offset>v----------------address---------------v
|
|
@@ -380,7 +380,7 @@ abstract contract LSP6ExecuteModule {
|
|
|
380
380
|
function _isAllowedStandard(
|
|
381
381
|
bytes memory allowedCall,
|
|
382
382
|
address to
|
|
383
|
-
) internal view returns (bool) {
|
|
383
|
+
) internal view virtual returns (bool) {
|
|
384
384
|
// <offset> = 24 bytes x 8 bits = 192 bits
|
|
385
385
|
//
|
|
386
386
|
// standard
|
|
@@ -397,7 +397,7 @@ abstract contract LSP6ExecuteModule {
|
|
|
397
397
|
function _isAllowedFunction(
|
|
398
398
|
bytes memory allowedCall,
|
|
399
399
|
bytes4 requiredFunction
|
|
400
|
-
) internal pure returns (bool) {
|
|
400
|
+
) internal pure virtual returns (bool) {
|
|
401
401
|
// <offset> = 28 bytes x 8 bits = 224 bits
|
|
402
402
|
//
|
|
403
403
|
// function
|
|
@@ -416,7 +416,7 @@ abstract contract LSP6ExecuteModule {
|
|
|
416
416
|
function _isAllowedCallType(
|
|
417
417
|
bytes memory allowedCall,
|
|
418
418
|
bytes4 requiredCallTypes
|
|
419
|
-
) internal pure returns (bool) {
|
|
419
|
+
) internal pure virtual returns (bool) {
|
|
420
420
|
// extract callType
|
|
421
421
|
//
|
|
422
422
|
// <offset> = 0
|
|
@@ -438,7 +438,7 @@ abstract contract LSP6SetDataModule {
|
|
|
438
438
|
bytes32 dataKey,
|
|
439
439
|
bytes memory dataValue,
|
|
440
440
|
bool hasBothAddControllerAndEditPermissions
|
|
441
|
-
) internal view returns (bytes32) {
|
|
441
|
+
) internal view virtual returns (bytes32) {
|
|
442
442
|
if (!LSP6Utils.isCompactBytesArrayOfAllowedERC725YDataKeys(dataValue)) {
|
|
443
443
|
revert InvalidEncodedAllowedERC725YDataKeys(
|
|
444
444
|
dataValue,
|
|
@@ -14,7 +14,11 @@ abstract contract LSP7Burnable is LSP7DigitalAsset {
|
|
|
14
14
|
*
|
|
15
15
|
* See internal _burn function for more details
|
|
16
16
|
*/
|
|
17
|
-
function burn(
|
|
17
|
+
function burn(
|
|
18
|
+
address from,
|
|
19
|
+
uint256 amount,
|
|
20
|
+
bytes memory data
|
|
21
|
+
) public virtual {
|
|
18
22
|
_burn(from, amount, data);
|
|
19
23
|
}
|
|
20
24
|
}
|
|
@@ -16,7 +16,11 @@ abstract contract LSP7BurnableInitAbstract is LSP7DigitalAssetInitAbstract {
|
|
|
16
16
|
*
|
|
17
17
|
* See internal _burn function for more details
|
|
18
18
|
*/
|
|
19
|
-
function burn(
|
|
19
|
+
function burn(
|
|
20
|
+
address from,
|
|
21
|
+
uint256 amount,
|
|
22
|
+
bytes memory data
|
|
23
|
+
) public virtual {
|
|
20
24
|
_burn(from, amount, data);
|
|
21
25
|
}
|
|
22
26
|
}
|
|
@@ -13,7 +13,7 @@ import {LSP8NotTokenOperator} from "../LSP8Errors.sol";
|
|
|
13
13
|
* their own tokens and those that they have an allowance for as an operator.
|
|
14
14
|
*/
|
|
15
15
|
abstract contract LSP8Burnable is LSP8IdentifiableDigitalAssetCore {
|
|
16
|
-
function burn(bytes32 tokenId, bytes memory data) public {
|
|
16
|
+
function burn(bytes32 tokenId, bytes memory data) public virtual {
|
|
17
17
|
if (!_isOperatorOrOwner(msg.sender, tokenId)) {
|
|
18
18
|
revert LSP8NotTokenOperator(tokenId, msg.sender);
|
|
19
19
|
}
|
|
@@ -310,31 +310,31 @@ abstract contract LSP8CompatibleERC721 is
|
|
|
310
310
|
uint256 tokenId,
|
|
311
311
|
bytes memory data
|
|
312
312
|
) private returns (bool) {
|
|
313
|
-
if (to.code.length
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
313
|
+
if (to.code.length == 0) {
|
|
314
|
+
return true;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
try
|
|
318
|
+
IERC721Receiver(to).onERC721Received(
|
|
319
|
+
msg.sender,
|
|
320
|
+
from,
|
|
321
|
+
tokenId,
|
|
322
|
+
data
|
|
323
|
+
)
|
|
324
|
+
returns (bytes4 retval) {
|
|
325
|
+
return retval == IERC721Receiver.onERC721Received.selector;
|
|
326
|
+
} catch (bytes memory reason) {
|
|
327
|
+
if (reason.length == 0) {
|
|
328
|
+
revert(
|
|
329
|
+
"LSP8CompatibleERC721: transfer to non ERC721Receiver implementer"
|
|
330
|
+
);
|
|
331
|
+
} else {
|
|
332
|
+
// solhint-disable no-inline-assembly
|
|
333
|
+
/// @solidity memory-safe-assembly
|
|
334
|
+
assembly {
|
|
335
|
+
revert(add(32, reason), mload(reason))
|
|
334
336
|
}
|
|
335
337
|
}
|
|
336
|
-
} else {
|
|
337
|
-
return true;
|
|
338
338
|
}
|
|
339
339
|
}
|
|
340
340
|
|