Skip to content

Commit

Permalink
runtime code
Browse files Browse the repository at this point in the history
  • Loading branch information
zemse committed Nov 19, 2023
1 parent 7648faf commit 220e9ab
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/HuffConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,20 @@ contract HuffConfig {

/// @notice Get the creation bytecode of a contract
function creation_code(string memory file) public payable returns (bytes memory bytecode) {
return get_code({file: file, is_creation: true});
}

/// @notice Get the runtime bytecode of a contract
function runtime_code(string memory file) public payable returns (bytes memory bytecode) {
return get_code({file: file, is_creation: false});
}

/// @notice Get the bytecode of a contract
function get_code(string memory file, bool is_creation)
public
payable
returns (bytes memory bytecode)
{
binary_check();

// Split the file into its parts
Expand Down Expand Up @@ -201,7 +215,11 @@ contract HuffConfig {

cmds[0] = "huffc";
cmds[1] = string(string.concat("src/", tempFile, ".huff"));
cmds[2] = "-b";
if (is_creation) {
cmds[2] = "-b";
} else {
cmds[2] = "-r";
}
cmds[3] = "-e";
cmds[4] = get_evm_version();

Expand All @@ -216,7 +234,6 @@ contract HuffConfig {
// set `msg.sender` for upcoming create context
vm.prank(deployer);


vm.ffi(cleanup);
}

Expand Down

0 comments on commit 220e9ab

Please sign in to comment.