-
Notifications
You must be signed in to change notification settings - Fork 349
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into ahmad-foreign-assets-migration
- Loading branch information
Showing
7 changed files
with
183 additions
and
48 deletions.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// SPDX-License-Identifier: GPL-3.0-only | ||
pragma solidity ^0.8.24; | ||
|
||
contract SelfDestructable { | ||
constructor() { | ||
selfdestruct(payable(address(0))); | ||
} | ||
} | ||
|
||
contract SelfDestructAfterCreate2 { | ||
uint constant SALT = 1; | ||
|
||
address public deployed1; | ||
address public deployed2; | ||
|
||
function step1() public { | ||
bytes memory bytecode = type(SelfDestructable).creationCode; | ||
address contractAddress; | ||
uint contractSize; | ||
assembly { | ||
contractAddress := create2(0, add(bytecode, 32), mload(bytecode), SALT) | ||
contractSize := extcodesize(contractAddress) | ||
} | ||
require(contractSize == 0, "Contract size should be zero"); | ||
deployed1 = contractAddress; | ||
} | ||
|
||
|
||
function step2() public { | ||
bytes memory bytecode = type(SelfDestructable).creationCode; | ||
address contractAddress; | ||
uint contractSize; | ||
assembly { | ||
contractAddress := create2(0, add(bytecode, 32), mload(bytecode), SALT) | ||
contractSize := extcodesize(contractAddress) | ||
} | ||
require(contractSize == 0, "Contract size should be zero"); | ||
deployed2 = contractAddress; | ||
require(deployed1 == deployed2, "Addresses not equal"); | ||
} | ||
|
||
function cannotRecreateInTheSameCall() public { | ||
bytes memory bytecode = type(SelfDestructable).creationCode; | ||
address contractAddress1; | ||
address contractAddress2; | ||
assembly { | ||
contractAddress1 := create2(0, add(bytecode, 32), mload(bytecode), SALT) | ||
contractAddress2 := create2(0, add(bytecode, 32), mload(bytecode), SALT) | ||
} | ||
require(contractAddress1 != address(0), "First address must not be null"); | ||
require(contractAddress2 == address(0), "Second address must be null"); | ||
} | ||
} |
Oops, something went wrong.