Skip to content

Commit 833a172

Browse files
committed
Refactor MCBase Contracts
1 parent 7455ce7 commit 833a172

14 files changed

+45
-59
lines changed

devkit/MCBase.sol

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,49 +7,32 @@ import {Script as ForgeScript} from "forge-std/Script.sol";
77
import {Test as ForgeTest} from "forge-std/Test.sol";
88

99
import {MCDevKit} from "devkit/MCDevKit.sol";
10-
import {ForgeHelper} from "devkit/utils/ForgeHelper.sol";
10+
import {System} from "devkit/system/System.sol";
1111

1212

1313
abstract contract MCBase is CommonBase {
1414
MCDevKit internal mc;
1515
uint256 internal deployerKey;
1616
address internal deployer;
17+
18+
constructor() {
19+
System.Config().load();
20+
}
1721
}
1822

1923
abstract contract MCScriptBase is MCBase, ForgeScript {
2024
modifier startBroadcastWith(string memory envKey) {
21-
_startBroadcastWith(envKey);
22-
_;
23-
}
24-
25-
modifier startBroadcastWithDeployerPrivKey() {
26-
_startBroadcastWith("DEPLOYER_PRIV_KEY");
27-
_;
28-
}
29-
30-
function _startBroadcastWith(string memory envKey) internal {
3125
deployerKey = mc.loadPrivateKey(envKey);
3226
deployer = vm.addr(deployerKey);
3327
vm.startBroadcast(deployerKey);
28+
_;
3429
}
3530
}
3631

3732
abstract contract MCTestBase is MCBase, ForgeTest {
3833
modifier startPrankWith(string memory envKey) {
39-
_startPrankWith(envKey);
40-
_;
41-
}
42-
modifier startPrankWithDeployer() {
43-
_startPrankWith("DEPLOYER");
44-
_;
45-
}
46-
function _startPrankWith(string memory envKey) internal {
4734
deployer = vm.envOr(envKey, makeAddr(envKey));
4835
vm.startPrank(deployer);
49-
}
50-
51-
modifier assumeAddressIsNotReserved(address addr) {
52-
ForgeHelper.assumeAddressIsNotReserved(addr);
5336
_;
5437
}
5538
}

devkit/MCScript.sol

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,6 @@ import {MCScriptBase} from "./MCBase.sol";
1212
// ⭐️ MC SCRIPT
1313
abstract contract MCScript is MCScriptBase {
1414
constructor() {
15-
System.Config().load();
1615
if (System.Config().SETUP.STD_FUNCS) mc.setupStdFunctions();
1716
}
1817
}
19-
20-
// ⭐️ MC SCRIPT without Setup
21-
abstract contract MCScriptWithoutSetup is MCScriptBase {
22-
constructor() {
23-
System.Config().load();
24-
}
25-
}

devkit/MCTest.sol

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {MCTestBase} from "./MCBase.sol";
1818
// ⭐️ MC TEST
1919
abstract contract MCTest is MCTestBase {
2020
constructor() {
21-
System.Config().load();
2221
if (System.Config().SETUP.STD_FUNCS) mc.setupStdFunctions();
2322
}
2423
}
@@ -36,7 +35,7 @@ abstract contract MCStateFuzzingTest is MCTestBase, OZProxy { // solhint-disable
3635
address dictionary;
3736

3837
constructor() {
39-
System.Config().load();
38+
// System.Config().load();
4039
implementations[bytes4(0)] = address(new Receive());
4140
}
4241

@@ -55,10 +54,3 @@ abstract contract MCStateFuzzingTest is MCTestBase, OZProxy { // solhint-disable
5554
}
5655

5756
}
58-
59-
// 🌟 MC TEST for DevKit
60-
abstract contract MCDevKitTest is MCTestBase {
61-
constructor() {
62-
System.Config().load();
63-
}
64-
}

script/DeployStdDictionary.s.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.24;
33

4-
import {MCScriptWithoutSetup} from "devkit/MCScript.sol";
4+
import {MCScriptBase} from "devkit/MCBase.sol";
55
import {DeployLib} from "./DeployLib.sol";
66
import {MCDevKit} from "devkit/MCDevKit.sol";
77

8-
contract DeployStdDictionary is MCScriptWithoutSetup {
8+
contract DeployStdDictionary is MCScriptBase {
99
using DeployLib for MCDevKit;
1010

1111
function setUp() public {

script/DeployStdFunctions.s.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.24;
33

4-
import {MCScriptWithoutSetup} from "devkit/MCScript.sol";
4+
import {MCScriptBase} from "devkit/MCBase.sol";
55
import {DeployLib} from "./DeployLib.sol";
66
import {MCDevKit} from "devkit/MCDevKit.sol";
77

8-
contract DeployStdFunctions is MCScriptWithoutSetup {
8+
contract DeployStdFunctions is MCScriptBase {
99
using DeployLib for MCDevKit;
1010

1111
function setUp() public {

test/devkit/MCDevKit.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
// import {StringUtils} from "devkit/utils/primitive/StringUtils.sol";
1111
// using StringUtils for string;
1212

13-
// contract MCDevKitTest is Test {
13+
// contract MCTestBase is Test {
1414
// MCDevKit internal mc;
1515
// function setUp() public {
1616
// mc.stopLog();

test/devkit/global/MCBundle.t.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.24;
33

4-
import {MCDevKitTest} from "devkit/MCTest.sol";
4+
import {MCTestBase} from "devkit/MCBase.sol";
55

66
import {Inspector} from "devkit/types/Inspector.sol";
77
using Inspector for string;
@@ -15,7 +15,7 @@ import {Function} from "devkit/core/Function.sol";
1515
import {DummyFunction} from "test/utils/DummyFunction.sol";
1616
import {DummyFacade} from "test/utils/DummyFacade.sol";
1717

18-
contract DevKitTest_MCBundle is MCDevKitTest {
18+
contract DevKitTest_MCBundle is MCTestBase {
1919
/**---------------------------
2020
🌱 Init Custom Bundle
2121
-----------------------------*/

test/devkit/global/MCContext.t.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.24;
33

4-
import {MCDevKitTest} from "devkit/MCTest.sol";
4+
import {MCTestBase} from "devkit/MCBase.sol";
55

66
import {Inspector} from "devkit/types/Inspector.sol";
77
using Inspector for string;
88

99
import {MessageHead as HEAD} from "devkit/system/message/MessageHead.sol";
1010

11-
contract DevKitTest_MCContext is MCDevKitTest {
11+
contract DevKitTest_MCContext is MCTestBase {
1212
/**-----------------------------
1313
♻️ Reset Current Context
1414
-------------------------------*/

test/devkit/global/MCDeploy.t.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.24;
33

4-
import {MCDevKitTest} from "devkit/MCTest.sol";
4+
import {MCTestBase} from "devkit/MCBase.sol";
55

66
import {Inspector} from "devkit/types/Inspector.sol";
77
using Inspector for string;
@@ -15,7 +15,7 @@ import {Function} from "devkit/core/Function.sol";
1515
import {DummyFunction} from "test/utils/DummyFunction.sol";
1616
import {DummyFacade} from "test/utils/DummyFacade.sol";
1717

18-
contract DevKitTest_MCDeploy is MCDevKitTest {
18+
contract DevKitTest_MCDeploy is MCTestBase {
1919
/**-----------------------------
2020
🌞 Deploy Meta Contract
2121
-------------------------------*/

test/devkit/global/MCFinder.t.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.24;
33

4-
import {MCDevKitTest} from "devkit/MCTest.sol";
4+
import {MCTestBase} from "devkit/MCBase.sol";
55
import {MessageHead as HEAD} from "devkit/system/message/MessageHead.sol";
66
import {Formatter} from "devkit/types/Formatter.sol";
77
using Formatter for string;
88
import {DummyFunction} from "../../utils/DummyFunction.sol";
99
import {DummyFacade} from "../../utils/DummyFacade.sol";
1010

11-
contract DevKitTest_MCFinder is MCDevKitTest {
11+
contract DevKitTest_MCFinder is MCTestBase {
1212

1313
/**-------------------
1414
🏠 Find Proxy

test/devkit/global/MCSetup.t.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.24;
33

4-
import {MCDevKitTest} from "devkit/MCTest.sol";
4+
import {MCTestBase} from "devkit/MCBase.sol";
55

66
import {Function} from "devkit/core/Function.sol";
77
import {TestHelper} from "test/utils/TestHelper.sol";
88
using TestHelper for Function;
99

10-
contract DevKitTest_MCSetup is MCDevKitTest {
10+
contract DevKitTest_MCSetup is MCTestBase {
1111

1212
/**----------------------------
1313
🧩 Setup Standard Funcs

test/devkit/global/MCTest.t.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.24;
33

4-
import {MCDevKitTest} from "devkit/MCTest.sol";
4+
import {MCTestBase} from "devkit/MCBase.sol";
55

66
import {Inspector} from "devkit/types/Inspector.sol";
77
using Inspector for string;
@@ -15,7 +15,7 @@ import {Function} from "devkit/core/Function.sol";
1515
import {DummyFunction} from "test/utils/DummyFunction.sol";
1616
import {DummyFacade} from "test/utils/DummyFacade.sol";
1717

18-
contract DevKitTest_MCTest is MCDevKitTest {
18+
contract DevKitTest_MCTest is MCTestBase {
1919
function setUp() public {
2020
mc.setupStdFunctions();
2121
}

test/script/DeployStdDictionary.t.sol

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.22;
3+
4+
import {MCTestBase} from "devkit/MCBase.sol";
5+
import {DeployLib} from "../../script/DeployLib.sol";
6+
import {MCDevKit} from "devkit/MCDevKit.sol";
7+
8+
contract DeployStdDictionaryTest is MCTestBase {
9+
using DeployLib for MCDevKit;
10+
11+
function setUp() public {
12+
mc.std.functions.fetch();
13+
}
14+
15+
function test_Run_Success() public startPrankWith("DEPLOYER_PRIV_KEY") {
16+
mc.deployStdDictionary();
17+
}
18+
19+
}

test/std/bundles/Std.t.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity ^0.8.24;
33

4-
import {MCDevKitTest} from "devkit/MCTest.sol";
4+
import {MCTestBase} from "devkit/MCBase.sol";
55
import {DeployLib} from "script/DeployLib.sol";
66
import {MCDevKit} from "devkit/MCDevKit.sol";
77

88
import {Clone} from "mc-std/functions/Clone.sol";
99

10-
contract StdTest is MCDevKitTest {
10+
contract StdTest is MCTestBase {
1111
using DeployLib for MCDevKit;
1212
function setUp() public {
1313
// mc.startDebug();

0 commit comments

Comments
 (0)