Skip to content

Commit 8a94963

Browse files
author
Ryan
committed
Updated foundry formatter configuration
1 parent ed64da7 commit 8a94963

22 files changed

Lines changed: 1966 additions & 1961 deletions

.github/workflows/test.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ jobs:
2424
run: |
2525
forge --version
2626
27+
- name: Run Forge fmt
28+
run: |
29+
forge fmt --check
30+
id: fmt
31+
2732
- name: Run Forge build
2833
run: |
2934
forge build --sizes

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ docs/
1212

1313
# Dotenv file
1414
.env
15+
16+
# OS files
17+
.DS_Store

.prettierignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1+
.github/
12
foundry.toml
23
out/
34
lib/
4-
cache/
5+
cache/

.prettierrc.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
{
22
"printWidth": 120,
33
"tabWidth": 4,
4-
"useTabs": true,
54
"singleQuote": false,
65
"trailingComma": "all",
76
"overrides": [
87
{
98
"files": "*.sol",
109
"options": {
10+
"useTabs": false,
1111
"bracketSpacing": false
1212
}
1313
},
1414
{
15-
"files": ["*.json", "*.js", "*.ts"],
16-
"options": {}
15+
"files": "*.json",
16+
"options": {
17+
"useTabs": true,
18+
"bracketSpacing": true
19+
}
1720
}
1821
]
1922
}

foundry.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ remappings = [
2929
"createx/=lib/createx/src"
3030
]
3131

32+
[fmt]
33+
line_length = 120
34+
tab_width = 4
35+
quote_style = "double"
36+
func_attrs_with_params_multiline = true
37+
inline_attribute_style = "compact"
38+
return_statement = "inline"
39+
3240
[fuzz]
3341
runs = 5000
3442
max_test_rejects = 1000000

script/BaseScript.sol

Lines changed: 97 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -2,104 +2,103 @@
22
pragma solidity ^0.8.30;
33

44
import {Script, stdJson} from "forge-std/Script.sol";
5-
import {ProxyForge} from "src/ProxyForge.sol";
65

76
abstract contract BaseScript is Script {
8-
using stdJson for string;
9-
10-
string private constant DEFAULT_MNEMONIC = "test test test test test test test test test test test junk";
11-
12-
address internal broadcaster;
13-
14-
modifier broadcast() {
15-
vm.startBroadcast(broadcaster);
16-
_;
17-
vm.stopBroadcast();
18-
}
19-
20-
modifier fork(string memory chainAlias) {
21-
vm.createSelectFork(chainAlias);
22-
_;
23-
}
24-
25-
function setUp() public virtual {
26-
broadcaster = vm.rememberKey(configurePrivateKey());
27-
}
28-
29-
function configurePrivateKey() internal view virtual returns (uint256 privateKey) {
30-
privateKey = vm.envOr({
31-
name: "PRIVATE_KEY",
32-
defaultValue: vm.deriveKey({
33-
mnemonic: vm.envOr({name: "MNEMONIC", defaultValue: DEFAULT_MNEMONIC}),
34-
index: uint8(vm.envOr({name: "EOA_INDEX", defaultValue: uint256(0)}))
35-
})
36-
});
37-
}
38-
39-
function generateJson(string memory path, string memory name, address instance, bytes32 salt) internal {
40-
string memory json = "json";
41-
json.serialize("address", instance);
42-
json.serialize("blockNumber", vm.getBlockNumber());
43-
json.serialize("name", name);
44-
json.serialize("salt", salt);
45-
json = json.serialize("timestamp", vm.getBlockTimestamp());
46-
json.write(path);
47-
}
48-
49-
function prompt(string memory promptText) internal returns (string memory input) {
50-
return prompt(promptText, new string(0));
51-
}
52-
53-
function prompt(string memory promptText, string memory defaultValue) internal returns (string memory input) {
54-
input = vm.prompt(string.concat(promptText, " (default: `", defaultValue, "`)"));
55-
if (bytes(input).length == 0) input = defaultValue;
56-
}
57-
58-
function promptAddress(string memory promptText, address defaultValue) internal returns (address) {
59-
return vm.parseAddress(prompt(promptText, vm.toString(defaultValue)));
60-
}
61-
62-
function promptAddress(string memory promptText) internal returns (address) {
63-
return promptAddress(promptText, address(0));
64-
}
65-
66-
function promptBool(string memory promptText, bool defaultValue) internal returns (bool) {
67-
return vm.parseBool(prompt(promptText, vm.toString(defaultValue)));
68-
}
69-
70-
function promptBool(string memory promptText) internal returns (bool) {
71-
return promptBool(promptText, false);
72-
}
73-
74-
function promptUint256(string memory promptText, uint256 defaultValue) internal returns (uint256) {
75-
return vm.parseUint(prompt(promptText, vm.toString(defaultValue)));
76-
}
77-
78-
function promptUint256(string memory promptText) internal returns (uint256) {
79-
return promptUint256(promptText, uint256(0));
80-
}
81-
82-
function promptInt256(string memory promptText, int256 defaultValue) internal returns (int256) {
83-
return vm.parseInt(prompt(promptText, vm.toString(defaultValue)));
84-
}
85-
86-
function promptInt256(string memory promptText) internal returns (int256) {
87-
return promptInt256(promptText, int256(0));
88-
}
89-
90-
function promptBytes32(string memory promptText, bytes32 defaultValue) internal returns (bytes32) {
91-
return vm.parseBytes32(prompt(promptText, vm.toString(defaultValue)));
92-
}
93-
94-
function promptBytes32(string memory promptText) internal returns (bytes32) {
95-
return promptBytes32(promptText, bytes32(0));
96-
}
97-
98-
function promptBytes(string memory promptText, bytes memory defaultValue) internal returns (bytes memory) {
99-
return vm.parseBytes(prompt(promptText, vm.toString(defaultValue)));
100-
}
101-
102-
function promptBytes(string memory promptText) internal returns (bytes memory) {
103-
return promptBytes(promptText, new bytes(0));
104-
}
7+
using stdJson for string;
8+
9+
string private constant DEFAULT_MNEMONIC = "test test test test test test test test test test test junk";
10+
11+
address internal broadcaster;
12+
13+
modifier broadcast() {
14+
vm.startBroadcast(broadcaster);
15+
_;
16+
vm.stopBroadcast();
17+
}
18+
19+
modifier fork(string memory chainAlias) {
20+
vm.createSelectFork(chainAlias);
21+
_;
22+
}
23+
24+
function setUp() public virtual {
25+
broadcaster = vm.rememberKey(configurePrivateKey());
26+
}
27+
28+
function configurePrivateKey() internal view virtual returns (uint256 privateKey) {
29+
privateKey = vm.envOr({
30+
name: "PRIVATE_KEY",
31+
defaultValue: vm.deriveKey({
32+
mnemonic: vm.envOr({name: "MNEMONIC", defaultValue: DEFAULT_MNEMONIC}),
33+
index: uint8(vm.envOr({name: "EOA_INDEX", defaultValue: uint256(0)}))
34+
})
35+
});
36+
}
37+
38+
function generateJson(string memory path, string memory name, address instance, bytes32 salt) internal {
39+
string memory json = "json";
40+
json.serialize("address", instance);
41+
json.serialize("blockNumber", vm.getBlockNumber());
42+
json.serialize("name", name);
43+
json.serialize("salt", salt);
44+
json = json.serialize("timestamp", vm.getBlockTimestamp());
45+
json.write(path);
46+
}
47+
48+
function prompt(string memory promptText) internal returns (string memory input) {
49+
return prompt(promptText, new string(0));
50+
}
51+
52+
function prompt(string memory promptText, string memory defaultValue) internal returns (string memory input) {
53+
input = vm.prompt(string.concat(promptText, " (default: `", defaultValue, "`)"));
54+
if (bytes(input).length == 0) input = defaultValue;
55+
}
56+
57+
function promptAddress(string memory promptText, address defaultValue) internal returns (address) {
58+
return vm.parseAddress(prompt(promptText, vm.toString(defaultValue)));
59+
}
60+
61+
function promptAddress(string memory promptText) internal returns (address) {
62+
return promptAddress(promptText, address(0));
63+
}
64+
65+
function promptBool(string memory promptText, bool defaultValue) internal returns (bool) {
66+
return vm.parseBool(prompt(promptText, vm.toString(defaultValue)));
67+
}
68+
69+
function promptBool(string memory promptText) internal returns (bool) {
70+
return promptBool(promptText, false);
71+
}
72+
73+
function promptUint256(string memory promptText, uint256 defaultValue) internal returns (uint256) {
74+
return vm.parseUint(prompt(promptText, vm.toString(defaultValue)));
75+
}
76+
77+
function promptUint256(string memory promptText) internal returns (uint256) {
78+
return promptUint256(promptText, uint256(0));
79+
}
80+
81+
function promptInt256(string memory promptText, int256 defaultValue) internal returns (int256) {
82+
return vm.parseInt(prompt(promptText, vm.toString(defaultValue)));
83+
}
84+
85+
function promptInt256(string memory promptText) internal returns (int256) {
86+
return promptInt256(promptText, int256(0));
87+
}
88+
89+
function promptBytes32(string memory promptText, bytes32 defaultValue) internal returns (bytes32) {
90+
return vm.parseBytes32(prompt(promptText, vm.toString(defaultValue)));
91+
}
92+
93+
function promptBytes32(string memory promptText) internal returns (bytes32) {
94+
return promptBytes32(promptText, bytes32(0));
95+
}
96+
97+
function promptBytes(string memory promptText, bytes memory defaultValue) internal returns (bytes memory) {
98+
return vm.parseBytes(prompt(promptText, vm.toString(defaultValue)));
99+
}
100+
101+
function promptBytes(string memory promptText) internal returns (bytes memory) {
102+
return promptBytes(promptText, new bytes(0));
103+
}
105104
}

script/Deploy.s.sol

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,27 @@ import {ProxyForge} from "src/ProxyForge.sol";
55
import {BaseScript} from "./BaseScript.sol";
66

77
contract Deploy is BaseScript {
8-
string internal constant DEFAULT_CHAINS = "ethereum, optimism, polygon, base, arbitrum";
8+
string internal constant DEFAULT_CHAINS = "ethereum, optimism, polygon, base, arbitrum";
99

10-
bytes32 internal constant DEFAULT_SALT = 0x0000000000000000000000000000000000000000000050726f7879466f726765;
10+
bytes32 internal constant DEFAULT_SALT = 0x0000000000000000000000000000000000000000000050726f7879466f726765;
1111

12-
bytes32 internal salt;
12+
bytes32 internal salt;
1313

14-
function setUp() public virtual override {
15-
super.setUp();
16-
salt = vm.envOr({name: "SALT", defaultValue: DEFAULT_SALT});
17-
}
14+
function setUp() public virtual override {
15+
super.setUp();
16+
salt = vm.envOr({name: "SALT", defaultValue: DEFAULT_SALT});
17+
}
1818

19-
function run() external {
20-
string memory input = prompt("Chains separated by ','", DEFAULT_CHAINS);
21-
string[] memory chains = vm.split(vm.replace(input, " ", ""), ",");
22-
for (uint256 i; i < chains.length; ++i) deployOnChain(chains[i]);
23-
}
19+
function run() external {
20+
string memory input = prompt("Chains separated by ','", DEFAULT_CHAINS);
21+
string[] memory chains = vm.split(vm.replace(input, " ", ""), ",");
22+
for (uint256 i; i < chains.length; ++i) {
23+
deployOnChain(chains[i]);
24+
}
25+
}
2426

25-
function deployOnChain(string memory chainAlias) internal fork(chainAlias) broadcast {
26-
string memory path = string.concat("./deployments/", vm.toString(block.chainid), ".json");
27-
generateJson(path, "ProxyForge", address(new ProxyForge{salt: salt}()), salt);
28-
}
27+
function deployOnChain(string memory chainAlias) internal fork(chainAlias) broadcast {
28+
string memory path = string.concat("./deployments/", vm.toString(block.chainid), ".json");
29+
generateJson(path, "ProxyForge", address(new ProxyForge{salt: salt}()), salt);
30+
}
2931
}

script/DeployProxy.s.sol

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,24 @@ import {IProxyForge} from "src/interfaces/IProxyForge.sol";
55
import {BaseScript} from "./BaseScript.sol";
66

77
contract DeployProxy is BaseScript {
8-
IProxyForge internal constant FORGE = IProxyForge(0x58b819827cB18Ba425906C69E1Bfb22F27Cb1bCe);
8+
IProxyForge internal constant FORGE = IProxyForge(0x58b819827cB18Ba425906C69E1Bfb22F27Cb1bCe);
99

10-
function run() external broadcast returns (address proxy) {
11-
require(address(FORGE).code.length != 0, "ProxyForge not exists");
10+
function run() external broadcast returns (address proxy) {
11+
require(address(FORGE).code.length != 0, "ProxyForge not exists");
1212

13-
address implementation = vm.promptAddress("Implementation");
14-
address owner = promptAddress("Owner", broadcaster);
13+
address implementation = vm.promptAddress("Implementation");
14+
address owner = promptAddress("Owner", broadcaster);
1515

16-
bool isDeterministic = promptBool("Is Deterministic");
17-
bytes32 salt;
18-
if (isDeterministic) salt = promptBytes32("Salt");
16+
bool isDeterministic = promptBool("Is Deterministic");
17+
bytes32 salt;
18+
if (isDeterministic) salt = promptBytes32("Salt");
1919

20-
bytes memory data = promptBytes("Data");
21-
uint256 value;
22-
if (data.length != 0) value = promptUint256("msg.value");
20+
bytes memory data = promptBytes("Data");
21+
uint256 value;
22+
if (data.length != 0) value = promptUint256("msg.value");
2323

24-
proxy = isDeterministic
25-
? FORGE.deployDeterministicAndCall{value: value}(implementation, owner, salt, data)
26-
: FORGE.deployAndCall{value: value}(implementation, owner, data);
27-
}
24+
proxy = isDeterministic
25+
? FORGE.deployDeterministicAndCall{value: value}(implementation, owner, salt, data)
26+
: FORGE.deployAndCall{value: value}(implementation, owner, data);
27+
}
2828
}

script/UpgradeProxy.s.sol

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ import {IProxyForge} from "src/interfaces/IProxyForge.sol";
55
import {BaseScript} from "./BaseScript.sol";
66

77
contract UpgradeProxy is BaseScript {
8-
IProxyForge internal constant FORGE = IProxyForge(0x58b819827cB18Ba425906C69E1Bfb22F27Cb1bCe);
8+
IProxyForge internal constant FORGE = IProxyForge(0x58b819827cB18Ba425906C69E1Bfb22F27Cb1bCe);
99

10-
function run() external broadcast {
11-
require(address(FORGE).code.length != 0, "ProxyForge not exists");
10+
function run() external broadcast {
11+
require(address(FORGE).code.length != 0, "ProxyForge not exists");
1212

13-
address proxy = vm.promptAddress("Proxy");
14-
address implementation = vm.promptAddress("Implementation");
13+
address proxy = vm.promptAddress("Proxy");
14+
address implementation = vm.promptAddress("Implementation");
1515

16-
bytes memory data = promptBytes("Data");
17-
uint256 value;
18-
if (data.length != 0) value = promptUint256("msg.value");
16+
bytes memory data = promptBytes("Data");
17+
uint256 value;
18+
if (data.length != 0) value = promptUint256("msg.value");
1919

20-
FORGE.upgradeAndCall{value: value}(proxy, implementation, data);
21-
}
20+
FORGE.upgradeAndCall{value: value}(proxy, implementation, data);
21+
}
2222
}

0 commit comments

Comments
 (0)