Skip to content

Commit

Permalink
Merge pull request #170 from rhinestonewtf/feat/support-fork-isinit
Browse files Browse the repository at this point in the history
feat: add isInit per chainId
  • Loading branch information
kopy-kat authored Dec 30, 2024
2 parents 29f63a0 + 1b046f3 commit 22f5cbc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/test/RhinestoneModuleKit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ contract RhinestoneModuleKit is AuxiliaryFactory {
MockValidator public _defaultValidator;
/// @notice The default stateless validator used for testing smart sessions
MockStatelessValidator public _defaultSessionValidator;
/// @notice Whether the module kit has been initialized
bool public isInit;
/// @notice Whether the module kit has been initialized on a specific chain
mapping(uint256 chainId => bool initialized) public isInit;

/*//////////////////////////////////////////////////////////////
INIT
Expand All @@ -135,7 +135,7 @@ contract RhinestoneModuleKit is AuxiliaryFactory {
function _initializeModuleKit(string memory _env) internal {
// Init
super.init();
isInit = true;
isInit[block.chainid] = true;

// Factories
writeFactory(address(new ERC7579Factory()), DEFAULT);
Expand Down Expand Up @@ -391,7 +391,7 @@ contract RhinestoneModuleKit is AuxiliaryFactory {

/// @dev Initialize the module kit with the provided environment if it has not been initialized
modifier initializeModuleKit() {
if (!isInit) {
if (!isInit[block.chainid]) {
string memory _env = envOr("ACCOUNT_TYPE", DEFAULT);
_initializeModuleKit(_env);
}
Expand All @@ -403,7 +403,7 @@ contract RhinestoneModuleKit is AuxiliaryFactory {
/// @param env The account type to set
modifier usingAccountEnv(AccountType env) {
// If the module kit is not initialized, initialize it
if (!isInit) {
if (!isInit[block.chainid]) {
_initializeModuleKit(env.toString());
} else {
// Cache the current env to restore it after the function call
Expand Down
2 changes: 1 addition & 1 deletion test/Diff.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ contract ERC7579DifferentialModuleKitLibTest is BaseTest {
}

function testUsingAccountEnv_ModuleKitUninitialized() public {
isInit = false;
isInit[block.chainid] = false;
_usingAccountEnv("DEFAULT");
}

Expand Down

0 comments on commit 22f5cbc

Please sign in to comment.