Commit 3ba35fab authored by Maurelian's avatar Maurelian Committed by GitHub

feat: Scaffolding for DeployAuthSystemInput (#11889)

* feat: Scaffolding for DeployAuthSystemInput

* fix: Remove undefined import

* feat: Address feedback
parent d4321859
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
import { Script } from "forge-std/Script.sol";
import { CommonBase } from "forge-std/Base.sol";
import { stdToml } from "forge-std/StdToml.sol";
import { GnosisSafe as Safe } from "safe-contracts/GnosisSafe.sol";
import { DeployUtils } from "scripts/libraries/DeployUtils.sol";
import { Solarray } from "scripts/libraries/Solarray.sol";
// This file follows the pattern of Superchain.s.sol. Refer to that file for more details.
contract DeployAuthSystemInput is CommonBase {
using stdToml for string;
// Generic safe inputs
// Note: these will need to be replaced with settings specific to the different Safes in the system.
uint256 internal _threshold;
address[] internal _owners;
function set(bytes4 _sel, uint256 _value) public {
if (_sel == this.threshold.selector) _threshold = _value;
else revert("DeployAuthSystemInput: unknown selector");
}
function set(bytes4 _sel, address[] memory _addrs) public {
if (_sel == this.owners.selector) {
require(_owners.length == 0, "DeployAuthSystemInput: owners already set");
for (uint256 i = 0; i < _addrs.length; i++) {
_owners.push(_addrs[i]);
}
} else {
revert("DeployAuthSystemInput: unknown selector");
}
}
function loadInputFile(string memory _infile) public {
string memory toml = vm.readFile(_infile);
set(this.threshold.selector, toml.readUint(".safe.threshold"));
set(this.owners.selector, toml.readAddressArray(".safe.owners"));
}
function threshold() public view returns (uint256) {
require(_threshold != 0, "DeployAuthSystemInput: threshold not set");
return _threshold;
}
function owners() public view returns (address[] memory) {
require(_owners.length != 0, "DeployAuthSystemInput: owners not set");
return _owners;
}
}
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;
import { Test } from "forge-std/Test.sol";
import { stdToml } from "forge-std/StdToml.sol";
import { Solarray } from "scripts/libraries/Solarray.sol";
import { DeployAuthSystemInput } from "scripts/DeployAuthSystem.s.sol";
contract DeployAuthSystemInput_Test is Test {
DeployAuthSystemInput dasi;
uint256 threshold = 5;
address[] owners;
function setUp() public {
dasi = new DeployAuthSystemInput();
address[] memory _owners = Solarray.addresses(
0x1111111111111111111111111111111111111111,
0x2222222222222222222222222222222222222222,
0x3333333333333333333333333333333333333333,
0x4444444444444444444444444444444444444444,
0x5555555555555555555555555555555555555555,
0x6666666666666666666666666666666666666666,
0x7777777777777777777777777777777777777777
);
for (uint256 i = 0; i < _owners.length; i++) {
owners.push(_owners[i]);
}
}
function test_loadInputFile_succeeds() public {
string memory root = vm.projectRoot();
string memory path = string.concat(root, "/test/fixtures/test-deploy-auth-system-in.toml");
dasi.loadInputFile(path);
assertEq(threshold, dasi.threshold(), "100");
assertEq(owners.length, dasi.owners().length, "200");
}
function test_getters_whenNotSet_revert() public {
vm.expectRevert("DeployAuthSystemInput: threshold not set");
dasi.threshold();
vm.expectRevert("DeployAuthSystemInput: owners not set");
dasi.owners();
}
function test_setters_ownerAlreadySet_revert() public {
dasi.set(dasi.owners.selector, owners);
vm.expectRevert("DeployAuthSystemInput: owners already set");
dasi.set(dasi.owners.selector, owners);
}
}
[safe]
threshold = 5
owners = [
"0x1111111111111111111111111111111111111111",
"0x2222222222222222222222222222222222222222",
"0x3333333333333333333333333333333333333333",
"0x4444444444444444444444444444444444444444",
"0x5555555555555555555555555555555555555555",
"0x6666666666666666666666666666666666666666",
"0x7777777777777777777777777777777777777777"
]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment