forked from OpenZeppelin/openzeppelin-contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bubble up
returndata
from reverted Create2 deployments (OpenZeppeli…
…n#5052) Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com> Co-authored-by: ernestognw <ernestognw@gmail.com>
- Loading branch information
1 parent
52e0e3e
commit 984233d
Showing
4 changed files
with
101 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'openzeppelin-solidity': minor | ||
--- | ||
|
||
`Create2`: Bubbles up returndata from a deployed contract that reverted during construction. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.20; | ||
|
||
contract ConstructorMock { | ||
bool foo; | ||
|
||
enum RevertType { | ||
None, | ||
RevertWithoutMessage, | ||
RevertWithMessage, | ||
RevertWithCustomError, | ||
Panic | ||
} | ||
|
||
error CustomError(); | ||
|
||
constructor(RevertType error) { | ||
// After transpilation to upgradeable contract, the constructor will become an initializer | ||
// To silence the `... can be restricted to view` warning, we write to state | ||
foo = true; | ||
|
||
if (error == RevertType.RevertWithoutMessage) { | ||
revert(); | ||
} else if (error == RevertType.RevertWithMessage) { | ||
revert("ConstructorMock: reverting"); | ||
} else if (error == RevertType.RevertWithCustomError) { | ||
revert CustomError(); | ||
} else if (error == RevertType.Panic) { | ||
uint256 a = uint256(0) / uint256(0); | ||
a; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters