-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleDeployment.s.sol
More file actions
55 lines (45 loc) · 1.7 KB
/
SimpleDeployment.s.sol
File metadata and controls
55 lines (45 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {DeployHelper} from "../../src/DeployHelper.sol";
import {Versionable} from "../../src/Versionable.sol";
import {Ownable} from "solady/auth/Ownable.sol";
/**
* @title MyContract
* @notice Example contract that implements IVersionable
* @dev Constructor-based ownership: owner is set in the constructor,
* so no post-deploy initialization is needed. This is the simplest pattern.
*/
contract MyContract is Versionable, Ownable {
uint256 public value;
constructor(string memory evmSuffix_, address owner_) Versionable(evmSuffix_) {
_initializeOwner(owner_);
}
function setValue(uint256 _value) external onlyOwner {
value = _value;
}
function _baseVersion() internal pure override returns (string memory) {
return "1.0.0-MyContract";
}
}
/**
* @title SimpleDeployment
* @notice Basic single-contract deployment with constructor-based ownership
*/
contract SimpleDeployment is DeployHelper {
function setUp() public override {
// Use DEPLOYER env var if set, otherwise use msg.sender (script contract)
// When broadcasting, DEPLOYER should be set to the broadcaster EOA
address broadcaster = vm.envOr("DEPLOYER", msg.sender);
_setUp("examples", broadcaster);
}
function run() public {
vm.startBroadcast(_deployer);
_assertBroadcastSenderMatchesDeployer();
bytes memory creationCode =
abi.encodePacked(type(MyContract).creationCode, abi.encode(_getEvmSuffix(), _deployer));
address deployed = deploy(creationCode);
_checkChainAndSetOwner(deployed);
_afterAll();
vm.stopBroadcast();
}
}