Skip to content

Commit

Permalink
feat: deploy Foundry profile with deploy-script checking (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
ARR4N authored Aug 11, 2024
1 parent 68a36b8 commit 4ece5be
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
5 changes: 4 additions & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ optimize_runs = 20_000_000

bytecode_hash = "none"

# via_ir = true
via_ir = false

[profile.deploy] # See script/DeploymentBase.sol
via_ir = true

# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
20 changes: 20 additions & 0 deletions script/DeploymentBase.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// SPDX-License-Identifier: MIT
// Copyright 2024 Divergence Tech Ltd.
pragma solidity ^0.8.13;

import {Script, console} from "forge-std/Script.sol";

/**
* @notice Deployment script that confirms the current Foundry profile in setup.
* @dev Useful for turning off features during development (e.g. slow `via_ir`) that MUST be enabled for deployment.
*/
contract DeploymentBase is Script {
error NotDeployProfile(string);

function setUp() public view virtual {
string memory profile = vm.envString("FOUNDRY_PROFILE");
if (keccak256(abi.encode(profile)) != keccak256("deploy")) {
revert NotDeployProfile(profile);
}
}
}

0 comments on commit 4ece5be

Please sign in to comment.