Skip to content

Commit a971fac

Browse files
author
Ryan
committed
Updated foundry formatter configuration
1 parent d49c919 commit a971fac

14 files changed

Lines changed: 1393 additions & 1408 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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ docs/
1313
# Dotenv file
1414
.env
1515

16+
# OS files
1617
.DS_Store

.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": ["*.ts", "*.js", "*.json"],
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
@@ -19,6 +19,14 @@ fs_permissions = [
1919

2020
gas_reports = ["CreateXFactory"]
2121

22+
[fmt]
23+
line_length = 120
24+
tab_width = 4
25+
quote_style = "double"
26+
func_attrs_with_params_multiline = true
27+
inline_attribute_style = "compact"
28+
return_statement = "inline"
29+
2230
[fuzz]
2331
runs = 5000
2432
max_test_rejects = 1000000

script/BaseScript.sol

Lines changed: 112 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -6,116 +6,116 @@ import {ICreateXFactory} from "src/ICreateXFactory.sol";
66
import {VmSafe} from "forge-std/Vm.sol";
77

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

0 commit comments

Comments
 (0)