Skip to content

Commit

Permalink
Merge pull request #75 from axieinfinity/feature/misc
Browse files Browse the repository at this point in the history
feat: build raw shared argument once
  • Loading branch information
TuDo1403 authored Jan 24, 2024
2 parents 30f7fa4 + f9ffd4b commit 29f0afa
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions script/BaseMigration.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ abstract contract BaseMigration is ScriptExtended {
}

function _storeRawSharedArguments() internal virtual {
if (CONFIG.areSharedArgumentsStored()) return;
CONFIG.setRawSharedArguments(_sharedArguments());
}

Expand Down
6 changes: 5 additions & 1 deletion script/configs/MigrationConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ abstract contract MigrationConfig is IMigrationConfig {
bytes internal _migrationConfig;

function setRawSharedArguments(bytes memory config) public virtual {
if (_migrationConfig.length != 0) return;
if (areSharedArgumentsStored()) return;
_migrationConfig = config;
}

function areSharedArgumentsStored() public view virtual returns (bool) {
return _migrationConfig.length != 0;
}

function getRawSharedArguments() public view virtual returns (bytes memory) {
return _migrationConfig;
}
Expand Down
2 changes: 2 additions & 0 deletions script/interfaces/configs/IMigrationConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
pragma solidity ^0.8.19;

interface IMigrationConfig {
function areSharedArgumentsStored() external view returns (bool);

function setRawSharedArguments(bytes calldata migrationConfig) external;

function getRawSharedArguments() external view returns (bytes memory);
Expand Down

0 comments on commit 29f0afa

Please sign in to comment.