Skip to content

Commit

Permalink
feat(RunTimeConfig): skip artifact generation while post checking
Browse files Browse the repository at this point in the history
  • Loading branch information
TuDo1403 committed Feb 2, 2024
1 parent 0c15281 commit 379bdb3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion script/ArtifactFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ contract ArtifactFactory is IArtifactFactory {
).green(),
string.concat("(nonce: ", nonce.toString(), ")")
);
if (!CONFIG.getRuntimeConfig().log) {
if (!CONFIG.getRuntimeConfig().log || CONFIG.isPostChecking()) {
console.log("Skipping artifact generation for:", vm.getLabel(contractAddr), "\n");
return;
}
Expand Down
9 changes: 9 additions & 0 deletions script/configs/RuntimeConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,20 @@ abstract contract RuntimeConfig is IRuntimeConfig {
bool internal _resolved;
Option internal _option;
string internal _rawCommand;
bool internal _isPostChecking;

function getCommand() public view virtual returns (string memory) {
return _rawCommand;
}

function isPostChecking() public view virtual returns (bool) {
return _isPostChecking;
}

function setPostCheckingStatus(bool status) public virtual {
_isPostChecking = status;
}

function resolveCommand(string calldata command) external virtual {
if (_resolved) return;
if (bytes(command).length != 0) {
Expand Down
4 changes: 4 additions & 0 deletions script/extensions/ScriptExtended.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ abstract contract ScriptExtended is Script, StdAssertions, IScriptExtended {

bytes public constant EMPTY_ARGS = "";
IGeneralConfig public constant CONFIG = IGeneralConfig(LibSharedAddress.CONFIG);
bool internal _isPostChecking;

modifier logFn(string memory fnName) {
_logFn(fnName);
Expand Down Expand Up @@ -48,7 +49,10 @@ abstract contract ScriptExtended is Script, StdAssertions, IScriptExtended {
CONFIG.resolveCommand(command);
(bool success, bytes memory data) = address(this).delegatecall(callData);
success.handleRevert(msg.sig, data);

CONFIG.setPostCheckingStatus({ status: true });
_postCheck();
CONFIG.setPostCheckingStatus({ status: false });
}

function network() public view virtual returns (TNetwork) {
Expand Down
4 changes: 4 additions & 0 deletions script/interfaces/configs/IRuntimeConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ interface IRuntimeConfig {
bool trezor;
}

function isPostChecking() external view returns (bool);

function setPostCheckingStatus(bool status) external;

function getCommand() external view returns (string memory);

function resolveCommand(string calldata command) external;
Expand Down

0 comments on commit 379bdb3

Please sign in to comment.