/ script / DeploymentConfig.s.sol
DeploymentConfig.s.sol
 1  //// SPDX-License-Identifier: UNLICENSED
 2  
 3  pragma solidity ^0.8.17;
 4  
 5  import { Script } from "forge-std/Script.sol";
 6  
 7  contract DeploymentConfig is Script {
 8      error DeploymentConfig_InvalidDeployerAddress();
 9  
10      struct TokenConfig {
11          string name;
12          string symbol;
13          string baseURI;
14          bytes signerPublicKey;
15      }
16  
17      TokenConfig public ownerTokenConfig;
18      TokenConfig public masterTokenConfig;
19  
20      address public immutable deployer;
21  
22      constructor(address _broadcaster) {
23          if (_broadcaster == address(0)) {
24              revert DeploymentConfig_InvalidDeployerAddress();
25          }
26          deployer = _broadcaster;
27          if (block.chainid == 31_337) {
28              (ownerTokenConfig, masterTokenConfig) = getOrCreateAnvilEthConfig();
29          }
30      }
31  
32      function getOrCreateAnvilEthConfig() public pure returns (TokenConfig memory, TokenConfig memory) {
33          TokenConfig memory _ownerTokenConfig = TokenConfig({
34              name: "Owner",
35              symbol: "OWNR",
36              baseURI: "http://local.owner",
37              signerPublicKey: bytes("some public key")
38          });
39          TokenConfig memory _masterTokenConfig =
40              TokenConfig({ name: "Master", symbol: "MSTR", baseURI: "http://local.master", signerPublicKey: "" });
41          return (_ownerTokenConfig, _masterTokenConfig);
42      }
43  
44      function getOwnerTokenConfig() public view returns (TokenConfig memory) {
45          return ownerTokenConfig;
46      }
47  
48      function getMasterTokenConfig() public view returns (TokenConfig memory) {
49          return masterTokenConfig;
50      }
51  
52      // This function is a hack to have it excluded by `forge coverage` until
53      // https://github.com/foundry-rs/foundry/issues/2988 is fixed.
54      // See: https://github.com/foundry-rs/foundry/issues/2988#issuecomment-1437784542
55      // for more info.
56      // solhint-disable-next-line
57      function test() public { }
58  }