@@ -24,6 +24,10 @@ library Clones {
24
24
* @dev Deploys and returns the address of a clone that mimics the behavior of `implementation`.
25
25
*
26
26
* This function uses the create opcode, which should never revert.
27
+ *
28
+ * WARNING: This function does not check if `implementation` has code. A clone that points to an address
29
+ * without code cannot be initialized. Initialization calls may appear to be successful when, in reality, they
30
+ * have no effect and leave the clone uninitialized, allowing a third party to initialize it later.
27
31
*/
28
32
function clone (address implementation ) internal returns (address instance ) {
29
33
return clone (implementation, 0 );
@@ -33,6 +37,10 @@ library Clones {
33
37
* @dev Same as {xref-Clones-clone-address-}[clone], but with a `value` parameter to send native currency
34
38
* to the new contract.
35
39
*
40
+ * WARNING: This function does not check if `implementation` has code. A clone that points to an address
41
+ * without code cannot be initialized. Initialization calls may appear to be successful when, in reality, they
42
+ * have no effect and leave the clone uninitialized, allowing a third party to initialize it later.
43
+ *
36
44
* NOTE: Using a non-zero value at creation will require the contract using this function (e.g. a factory)
37
45
* to always have enough balance for new deployments. Consider exposing this function under a payable method.
38
46
*/
@@ -59,6 +67,10 @@ library Clones {
59
67
* This function uses the create2 opcode and a `salt` to deterministically deploy
60
68
* the clone. Using the same `implementation` and `salt` multiple times will revert, since
61
69
* the clones cannot be deployed twice at the same address.
70
+ *
71
+ * WARNING: This function does not check if `implementation` has code. A clone that points to an address
72
+ * without code cannot be initialized. Initialization calls may appear to be successful when, in reality, they
73
+ * have no effect and leave the clone uninitialized, allowing a third party to initialize it later.
62
74
*/
63
75
function cloneDeterministic (address implementation , bytes32 salt ) internal returns (address instance ) {
64
76
return cloneDeterministic (implementation, salt, 0 );
@@ -68,6 +80,10 @@ library Clones {
68
80
* @dev Same as {xref-Clones-cloneDeterministic-address-bytes32-}[cloneDeterministic], but with
69
81
* a `value` parameter to send native currency to the new contract.
70
82
*
83
+ * WARNING: This function does not check if `implementation` has code. A clone that points to an address
84
+ * without code cannot be initialized. Initialization calls may appear to be successful when, in reality, they
85
+ * have no effect and leave the clone uninitialized, allowing a third party to initialize it later.
86
+ *
71
87
* NOTE: Using a non-zero value at creation will require the contract using this function (e.g. a factory)
72
88
* to always have enough balance for new deployments. Consider exposing this function under a payable method.
73
89
*/
@@ -128,6 +144,10 @@ library Clones {
128
144
* access the arguments within the implementation, use {fetchCloneArgs}.
129
145
*
130
146
* This function uses the create opcode, which should never revert.
147
+ *
148
+ * WARNING: This function does not check if `implementation` has code. A clone that points to an address
149
+ * without code cannot be initialized. Initialization calls may appear to be successful when, in reality, they
150
+ * have no effect and leave the clone uninitialized, allowing a third party to initialize it later.
131
151
*/
132
152
function cloneWithImmutableArgs (address implementation , bytes memory args ) internal returns (address instance ) {
133
153
return cloneWithImmutableArgs (implementation, args, 0 );
@@ -137,6 +157,10 @@ library Clones {
137
157
* @dev Same as {xref-Clones-cloneWithImmutableArgs-address-bytes-}[cloneWithImmutableArgs], but with a `value`
138
158
* parameter to send native currency to the new contract.
139
159
*
160
+ * WARNING: This function does not check if `implementation` has code. A clone that points to an address
161
+ * without code cannot be initialized. Initialization calls may appear to be successful when, in reality, they
162
+ * have no effect and leave the clone uninitialized, allowing a third party to initialize it later.
163
+ *
140
164
* NOTE: Using a non-zero value at creation will require the contract using this function (e.g. a factory)
141
165
* to always have enough balance for new deployments. Consider exposing this function under a payable method.
142
166
*/
@@ -165,6 +189,10 @@ library Clones {
165
189
* This function uses the create2 opcode and a `salt` to deterministically deploy the clone. Using the same
166
190
* `implementation`, `args` and `salt` multiple times will revert, since the clones cannot be deployed twice
167
191
* at the same address.
192
+ *
193
+ * WARNING: This function does not check if `implementation` has code. A clone that points to an address
194
+ * without code cannot be initialized. Initialization calls may appear to be successful when, in reality, they
195
+ * have no effect and leave the clone uninitialized, allowing a third party to initialize it later.
168
196
*/
169
197
function cloneDeterministicWithImmutableArgs (
170
198
address implementation ,
@@ -178,6 +206,10 @@ library Clones {
178
206
* @dev Same as {xref-Clones-cloneDeterministicWithImmutableArgs-address-bytes-bytes32-}[cloneDeterministicWithImmutableArgs],
179
207
* but with a `value` parameter to send native currency to the new contract.
180
208
*
209
+ * WARNING: This function does not check if `implementation` has code. A clone that points to an address
210
+ * without code cannot be initialized. Initialization calls may appear to be successful when, in reality, they
211
+ * have no effect and leave the clone uninitialized, allowing a third party to initialize it later.
212
+ *
181
213
* NOTE: Using a non-zero value at creation will require the contract using this function (e.g. a factory)
182
214
* to always have enough balance for new deployments. Consider exposing this function under a payable method.
183
215
*/
0 commit comments