Skip to content

Commit d05341e

Browse files
authored
Merge pull request #87 from neutiyoo/style/fmt
style: format contract codes
2 parents dc6ebff + 2d84e54 commit d05341e

7 files changed

+146
-413
lines changed

contracts/script/IncredibleSquaringDeployer.s.sol

Lines changed: 69 additions & 199 deletions
Large diffs are not rendered by default.

contracts/script/utils/Utils.sol

Lines changed: 18 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -10,90 +10,56 @@ import "forge-std/StdJson.sol";
1010

1111
contract Utils is Script {
1212
// Note that this fct will only work for the ERC20Mock that has a public mint function
13-
function _mintTokens(
14-
address strategyAddress,
15-
address[] memory tos,
16-
uint256[] memory amounts
17-
) internal {
13+
function _mintTokens(address strategyAddress, address[] memory tos, uint256[] memory amounts) internal {
1814
for (uint256 i = 0; i < tos.length; i++) {
19-
ERC20Mock underlyingToken = ERC20Mock(
20-
address(StrategyBase(strategyAddress).underlyingToken())
21-
);
15+
ERC20Mock underlyingToken = ERC20Mock(address(StrategyBase(strategyAddress).underlyingToken()));
2216
underlyingToken.mint(tos[i], amounts[i]);
2317
}
2418
}
2519

26-
function convertBoolToString(
27-
bool input
28-
) public pure returns (string memory) {
20+
function convertBoolToString(bool input) public pure returns (string memory) {
2921
if (input) {
3022
return "true";
3123
} else {
3224
return "false";
3325
}
3426
}
3527

36-
function convertOperatorStatusToString(
37-
IRegistryCoordinator.OperatorStatus operatorStatus
38-
) public pure returns (string memory) {
39-
if (
40-
operatorStatus ==
41-
IRegistryCoordinator.OperatorStatus.NEVER_REGISTERED
42-
) {
28+
function convertOperatorStatusToString(IRegistryCoordinator.OperatorStatus operatorStatus)
29+
public
30+
pure
31+
returns (string memory)
32+
{
33+
if (operatorStatus == IRegistryCoordinator.OperatorStatus.NEVER_REGISTERED) {
4334
return "NEVER_REGISTERED";
44-
} else if (
45-
operatorStatus == IRegistryCoordinator.OperatorStatus.REGISTERED
46-
) {
35+
} else if (operatorStatus == IRegistryCoordinator.OperatorStatus.REGISTERED) {
4736
return "REGISTERED";
48-
} else if (
49-
operatorStatus == IRegistryCoordinator.OperatorStatus.DEREGISTERED
50-
) {
37+
} else if (operatorStatus == IRegistryCoordinator.OperatorStatus.DEREGISTERED) {
5138
return "DEREGISTERED";
5239
} else {
5340
return "UNKNOWN";
5441
}
5542
}
5643

5744
// Forge scripts best practice: https://book.getfoundry.sh/tutorials/best-practices#scripts
58-
function readInput(
59-
string memory inputFileName
60-
) internal view returns (string memory) {
61-
string memory inputDir = string.concat(
62-
vm.projectRoot(),
63-
"/script/input/"
64-
);
45+
function readInput(string memory inputFileName) internal view returns (string memory) {
46+
string memory inputDir = string.concat(vm.projectRoot(), "/script/input/");
6547
string memory chainDir = string.concat(vm.toString(block.chainid), "/");
6648
string memory file = string.concat(inputFileName, ".json");
6749
return vm.readFile(string.concat(inputDir, chainDir, file));
6850
}
6951

70-
function readOutput(
71-
string memory outputFileName
72-
) internal view returns (string memory) {
73-
string memory inputDir = string.concat(
74-
vm.projectRoot(),
75-
"/script/output/"
76-
);
52+
function readOutput(string memory outputFileName) internal view returns (string memory) {
53+
string memory inputDir = string.concat(vm.projectRoot(), "/script/output/");
7754
string memory chainDir = string.concat(vm.toString(block.chainid), "/");
7855
string memory file = string.concat(outputFileName, ".json");
7956
return vm.readFile(string.concat(inputDir, chainDir, file));
8057
}
8158

82-
function writeOutput(
83-
string memory outputJson,
84-
string memory outputFileName
85-
) internal {
86-
string memory outputDir = string.concat(
87-
vm.projectRoot(),
88-
"/script/output/"
89-
);
59+
function writeOutput(string memory outputJson, string memory outputFileName) internal {
60+
string memory outputDir = string.concat(vm.projectRoot(), "/script/output/");
9061
string memory chainDir = string.concat(vm.toString(block.chainid), "/");
91-
string memory outputFilePath = string.concat(
92-
outputDir,
93-
chainDir,
94-
outputFileName,
95-
".json"
96-
);
62+
string memory outputFilePath = string.concat(outputDir, chainDir, outputFileName, ".json");
9763
vm.writeJson(outputJson, outputFilePath);
9864
}
9965
}

contracts/src/ERC20Mock.sol

Lines changed: 14 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ contract ERC20Mock is Context, IERC20 {
5151
/**
5252
* @dev See {IERC20-balanceOf}.
5353
*/
54-
function balanceOf(
55-
address account
56-
) public view virtual override returns (uint256) {
54+
function balanceOf(address account) public view virtual override returns (uint256) {
5755
return _balances[account];
5856
}
5957

@@ -69,10 +67,7 @@ contract ERC20Mock is Context, IERC20 {
6967
* - `to` cannot be the zero address.
7068
* - the caller must have a balance of at least `amount`.
7169
*/
72-
function transfer(
73-
address to,
74-
uint256 amount
75-
) public virtual override returns (bool) {
70+
function transfer(address to, uint256 amount) public virtual override returns (bool) {
7671
address owner = _msgSender();
7772
_transfer(owner, to, amount);
7873
return true;
@@ -81,10 +76,7 @@ contract ERC20Mock is Context, IERC20 {
8176
/**
8277
* @dev See {IERC20-allowance}.
8378
*/
84-
function allowance(
85-
address owner,
86-
address spender
87-
) public view virtual override returns (uint256) {
79+
function allowance(address owner, address spender) public view virtual override returns (uint256) {
8880
return _allowances[owner][spender];
8981
}
9082

@@ -98,10 +90,7 @@ contract ERC20Mock is Context, IERC20 {
9890
*
9991
* - `spender` cannot be the zero address.
10092
*/
101-
function approve(
102-
address /*spender*/,
103-
uint256 /*amount*/
104-
) public virtual override returns (bool) {
93+
function approve(address, /*spender*/ uint256 /*amount*/ ) public virtual override returns (bool) {
10594
return true;
10695
}
10796

@@ -121,11 +110,7 @@ contract ERC20Mock is Context, IERC20 {
121110
* - the caller must have allowance for ``from``'s tokens of at least
122111
* `amount`.
123112
*/
124-
function transferFrom(
125-
address from,
126-
address to,
127-
uint256 amount
128-
) public virtual override returns (bool) {
113+
function transferFrom(address from, address to, uint256 amount) public virtual override returns (bool) {
129114
_transfer(from, to, amount);
130115
return true;
131116
}
@@ -144,20 +129,13 @@ contract ERC20Mock is Context, IERC20 {
144129
* - `to` cannot be the zero address.
145130
* - `from` must have a balance of at least `amount`.
146131
*/
147-
function _transfer(
148-
address from,
149-
address to,
150-
uint256 amount
151-
) internal virtual {
132+
function _transfer(address from, address to, uint256 amount) internal virtual {
152133
require(from != address(0), "ERC20: transfer from the zero address");
153134
require(to != address(0), "ERC20: transfer to the zero address");
154135

155136
_beforeTokenTransfer(from, to, amount);
156137

157-
require(
158-
_balances[from] >= amount,
159-
"ERC20: transfer amount exceeds balance"
160-
);
138+
require(_balances[from] >= amount, "ERC20: transfer amount exceeds balance");
161139
unchecked {
162140
_balances[from] = _balances[from] - amount;
163141
// Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
@@ -170,7 +148,8 @@ contract ERC20Mock is Context, IERC20 {
170148
_afterTokenTransfer(from, to, amount);
171149
}
172150

173-
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
151+
/**
152+
* @dev Creates `amount` tokens and assigns them to `account`, increasing
174153
* the total supply.
175154
*
176155
* Emits a {Transfer} event with `from` set to the zero address.
@@ -232,11 +211,7 @@ contract ERC20Mock is Context, IERC20 {
232211
* - `owner` cannot be the zero address.
233212
* - `spender` cannot be the zero address.
234213
*/
235-
function _approve(
236-
address owner,
237-
address spender,
238-
uint256 amount
239-
) internal virtual {
214+
function _approve(address owner, address spender, uint256 amount) internal virtual {
240215
require(owner != address(0), "ERC20: approve from the zero address");
241216
require(spender != address(0), "ERC20: approve to the zero address");
242217

@@ -252,17 +227,10 @@ contract ERC20Mock is Context, IERC20 {
252227
*
253228
* Might emit an {Approval} event.
254229
*/
255-
function _spendAllowance(
256-
address owner,
257-
address spender,
258-
uint256 amount
259-
) internal virtual {
230+
function _spendAllowance(address owner, address spender, uint256 amount) internal virtual {
260231
uint256 currentAllowance = allowance(owner, spender);
261232
if (currentAllowance != type(uint256).max) {
262-
require(
263-
currentAllowance >= amount,
264-
"ERC20: insufficient allowance"
265-
);
233+
require(currentAllowance >= amount, "ERC20: insufficient allowance");
266234
}
267235
}
268236

@@ -280,11 +248,7 @@ contract ERC20Mock is Context, IERC20 {
280248
*
281249
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
282250
*/
283-
function _beforeTokenTransfer(
284-
address from,
285-
address to,
286-
uint256 amount
287-
) internal virtual {}
251+
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual {}
288252

289253
/**
290254
* @dev Hook that is called after any transfer of tokens. This includes
@@ -300,9 +264,5 @@ contract ERC20Mock is Context, IERC20 {
300264
*
301265
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
302266
*/
303-
function _afterTokenTransfer(
304-
address from,
305-
address to,
306-
uint256 amount
307-
) internal virtual {}
267+
function _afterTokenTransfer(address from, address to, uint256 amount) internal virtual {}
308268
}

contracts/src/IIncredibleSquaringTaskManager.sol

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,16 @@ interface IIncredibleSquaringTaskManager {
77
// EVENTS
88
event NewTaskCreated(uint32 indexed taskIndex, Task task);
99

10-
event TaskResponded(
11-
TaskResponse taskResponse,
12-
TaskResponseMetadata taskResponseMetadata
13-
);
10+
event TaskResponded(TaskResponse taskResponse, TaskResponseMetadata taskResponseMetadata);
1411

1512
event TaskCompleted(uint32 indexed taskIndex);
1613

17-
event TaskChallengedSuccessfully(
18-
uint32 indexed taskIndex,
19-
address indexed challenger
20-
);
14+
event TaskChallengedSuccessfully(uint32 indexed taskIndex, address indexed challenger);
2115

22-
event TaskChallengedUnsuccessfully(
23-
uint32 indexed taskIndex,
24-
address indexed challenger
25-
);
16+
event TaskChallengedUnsuccessfully(uint32 indexed taskIndex, address indexed challenger);
2617

2718
event AggregatorUpdated(address indexed oldAggregator, address indexed newAggregator);
28-
19+
2920
event GeneratorUpdated(address indexed oldGenerator, address indexed newGenerator);
3021

3122
// STRUCTS
@@ -61,11 +52,8 @@ interface IIncredibleSquaringTaskManager {
6152

6253
// FUNCTIONS
6354
// NOTE: this function creates new task.
64-
function createNewTask(
65-
uint256 numberToBeSquared,
66-
uint32 quorumThresholdPercentage,
67-
bytes calldata quorumNumbers
68-
) external;
55+
function createNewTask(uint256 numberToBeSquared, uint32 quorumThresholdPercentage, bytes calldata quorumNumbers)
56+
external;
6957

7058
/// @notice Returns the current 'taskNumber' for the middleware
7159
function taskNumber() external view returns (uint32);

contracts/src/IncredibleSquaringServiceManager.sol

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ import "@eigenlayer-middleware/src/ServiceManagerBase.sol";
1212
contract IncredibleSquaringServiceManager is ServiceManagerBase {
1313
using BytesLib for bytes;
1414

15-
IIncredibleSquaringTaskManager
16-
public immutable incredibleSquaringTaskManager;
15+
IIncredibleSquaringTaskManager public immutable incredibleSquaringTaskManager;
1716

1817
/// @notice when applied to a function, ensures that the function is only callable by the `registryCoordinator`.
1918
modifier onlyIncredibleSquaringTaskManager() {
@@ -43,9 +42,7 @@ contract IncredibleSquaringServiceManager is ServiceManagerBase {
4342
/// @notice Called in the event of challenge resolution, in order to forward a call to the Slasher, which 'freezes' the `operator`.
4443
/// @dev The Slasher contract is under active development and its interface expected to change.
4544
/// We recommend writing slashing logic without integrating with the Slasher at this point in time.
46-
function freezeOperator(
47-
address operatorAddr
48-
) external onlyIncredibleSquaringTaskManager {
45+
function freezeOperator(address operatorAddr) external onlyIncredibleSquaringTaskManager {
4946
// slasher.freezeOperator(operatorAddr);
5047
}
5148
}

0 commit comments

Comments
 (0)