Skip to content

Commit 89c738d

Browse files
committed
fix: forge fmt
1 parent 6ca5f79 commit 89c738d

9 files changed

Lines changed: 181 additions & 45 deletions

src/IStudentManager.sol

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,11 @@ interface IStudentManager {
9797
bytes32 docHash
9898
) external returns (uint256);
9999

100-
function approveDocument(uint256 documentIndex, uint256 amount, bytes32 reasonHash) external;
100+
function approveDocument(
101+
uint256 documentIndex,
102+
uint256 amount,
103+
bytes32 reasonHash
104+
) external;
101105

102106
function getDocSubmission(
103107
uint256 documentIndex
@@ -107,11 +111,26 @@ interface IStudentManager {
107111
uint256 documentIndex
108112
) external view returns (DocumentResult memory);
109113

110-
function burnFrom(bytes32 studendtId, address account, uint256 amount) external;
114+
function burnFrom(
115+
bytes32 studendtId,
116+
address account,
117+
uint256 amount
118+
) external;
111119

112-
function changeAccount(bytes32 studentId, address targetAccount) external;
120+
function changeAccount(
121+
bytes32 studentId,
122+
address targetAccount
123+
) external;
113124

114-
function updateStudentRecord(bytes32 studentId, address targetAccount, bool _clear) external;
125+
function updateStudentRecord(
126+
bytes32 studentId,
127+
address targetAccount,
128+
bool _clear
129+
) external;
115130

116-
function transferFromToken(bytes32 fromStudentId, bytes32 toStudentId, uint256 amount) external;
131+
function transferFromToken(
132+
bytes32 fromStudentId,
133+
bytes32 toStudentId,
134+
uint256 amount
135+
) external;
117136
}

src/ISwMileageToken.sol

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ interface ISwMileageToken is IKIP7, IKIP7Burnable {
1414
uint256 balance;
1515
}
1616

17-
function mint(address account, uint256 amount) external;
18-
function getRankingRange(uint256 from, uint256 to) external view returns (Student[] memory);
17+
function mint(
18+
address account,
19+
uint256 amount
20+
) external;
21+
function getRankingRange(
22+
uint256 from,
23+
uint256 to
24+
) external view returns (Student[] memory);
1925
}

src/SortedList.sol

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ abstract contract SortedList is ISortedList {
3030
return _participated[addr];
3131
}
3232

33-
function _getElementRange(uint256 from, uint256 to) internal view virtual returns (bytes memory) {
33+
function _getElementRange(
34+
uint256 from,
35+
uint256 to
36+
) internal view virtual returns (bytes memory) {
3437
if (from == 0) revert InvalidRangeFrom();
3538
if (from > to) revert InvalidRangeTo(from, to);
3639

@@ -56,7 +59,10 @@ abstract contract SortedList is ISortedList {
5659
return abi.encode(result);
5760
}
5861

59-
function _updateElement(address target, uint256 newValue) internal virtual {
62+
function _updateElement(
63+
address target,
64+
uint256 newValue
65+
) internal virtual {
6066
uint256 prevValue = 0;
6167

6268
if (_participated[target]) {
@@ -69,7 +75,10 @@ abstract contract SortedList is ISortedList {
6975
emit UpdateElement(target, prevValue, newValue);
7076
}
7177

72-
function _insertElement(address addr, uint256 value) internal virtual {
78+
function _insertElement(
79+
address addr,
80+
uint256 value
81+
) internal virtual {
7382
address ptr = _head;
7483
address prev = DUMMY;
7584

@@ -90,7 +99,10 @@ abstract contract SortedList is ISortedList {
9099
++_listLength;
91100
}
92101

93-
function _removeElement(address target, bool _event) internal {
102+
function _removeElement(
103+
address target,
104+
bool _event
105+
) internal {
94106
if (!_participated[target]) revert AddressNotInList(target);
95107
if (_listLength == 0) revert ListIsEmpty();
96108

src/StudentManager.impl.sol

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,18 @@ contract StudentManagerImpl is Initializable, SwMileageTokenFactory, Admin, Paus
2020

2121
SwMileageTokenImpl public _mileageToken;
2222

23-
constructor(address mileageToken_, address tokenImpl) SwMileageTokenFactory(tokenImpl) {
23+
constructor(
24+
address mileageToken_,
25+
address tokenImpl
26+
) SwMileageTokenFactory(tokenImpl) {
2427
_mileageToken = SwMileageTokenImpl(mileageToken_);
2528
}
2629

27-
function initialize(address mileageToken_, address tokenImpl, address admin) external initializer {
30+
function initialize(
31+
address mileageToken_,
32+
address tokenImpl,
33+
address admin
34+
) external initializer {
2835
_mileageToken = SwMileageTokenImpl(mileageToken_);
2936
_addAdmin(admin);
3037
setImplementation(tokenImpl);
@@ -152,17 +159,18 @@ contract StudentManagerImpl is Initializable, SwMileageTokenFactory, Admin, Paus
152159

153160
uint256 documentIndex = documentsCount++;
154161
docSubmissions[documentIndex] = DocumentSubmission({
155-
studentId: studentId,
156-
docHash: docHash,
157-
createdAt: block.timestamp,
158-
status: SubmissionStatus.Pending
162+
studentId: studentId, docHash: docHash, createdAt: block.timestamp, status: SubmissionStatus.Pending
159163
});
160164

161165
emit DocSubmitted(documentIndex, studentId, docHash);
162166
return documentIndex;
163167
}
164168

165-
function approveDocument(uint256 documentIndex, uint256 amount, bytes32 reasonHash) external onlyAdmin {
169+
function approveDocument(
170+
uint256 documentIndex,
171+
uint256 amount,
172+
bytes32 reasonHash
173+
) external onlyAdmin {
166174
if (documentIndex >= documentsCount) revert InvalidDocIndex(documentIndex, documentsCount);
167175
DocumentSubmission storage document = docSubmissions[documentIndex];
168176
if (document.status != SubmissionStatus.Pending) revert NotPendingDocument();
@@ -197,7 +205,11 @@ contract StudentManagerImpl is Initializable, SwMileageTokenFactory, Admin, Paus
197205

198206
////////////////////////// admin utilities
199207

200-
function mint(bytes32 studentId, address account, uint256 amount) external onlyAdmin {
208+
function mint(
209+
bytes32 studentId,
210+
address account,
211+
uint256 amount
212+
) external onlyAdmin {
201213
// is valid account, studentId?
202214
if (account == address(0)) {
203215
account = students[studentId];
@@ -212,7 +224,11 @@ contract StudentManagerImpl is Initializable, SwMileageTokenFactory, Admin, Paus
212224
emit MileageMinted(studentId, account, msg.sender, amount);
213225
}
214226

215-
function burnFrom(bytes32 studentId, address account, uint256 amount) external onlyAdmin {
227+
function burnFrom(
228+
bytes32 studentId,
229+
address account,
230+
uint256 amount
231+
) external onlyAdmin {
216232
// is valid account, studentId?
217233
if (account == address(0)) {
218234
account = students[studentId];
@@ -227,7 +243,10 @@ contract StudentManagerImpl is Initializable, SwMileageTokenFactory, Admin, Paus
227243
emit MileageBurned(studentId, account, msg.sender, amount);
228244
}
229245

230-
function changeAccount(bytes32 studentId, address targetAccount) external onlyAdmin {
246+
function changeAccount(
247+
bytes32 studentId,
248+
address targetAccount
249+
) external onlyAdmin {
231250
if (studentByAddr[targetAccount] != bytes32(0)) revert TargetInUse();
232251
if (targetAccount == address(0)) revert InvalidTargetAccount();
233252
address currentAccount = students[studentId];
@@ -251,7 +270,10 @@ contract StudentManagerImpl is Initializable, SwMileageTokenFactory, Admin, Paus
251270
emit AccountChanged(studentId, currentAccount, targetAccount);
252271
}
253272

254-
function migrateStudentId(bytes32 currentId, bytes32 nextId) external onlyAdmin {
273+
function migrateStudentId(
274+
bytes32 currentId,
275+
bytes32 nextId
276+
) external onlyAdmin {
255277
if (currentId == bytes32(0) || nextId == bytes32(0)) revert EmptyStudentId();
256278
if (currentId == nextId) revert SameStudentId();
257279

@@ -271,7 +293,11 @@ contract StudentManagerImpl is Initializable, SwMileageTokenFactory, Admin, Paus
271293
}
272294

273295
// Imediately update student record
274-
function updateStudentRecord(bytes32 studentId, address targetAccount, bool _clear) external onlyAdmin {
296+
function updateStudentRecord(
297+
bytes32 studentId,
298+
address targetAccount,
299+
bool _clear
300+
) external onlyAdmin {
275301
if (studentId == bytes32(0)) revert EmptyStudentId();
276302

277303
address currentAccount = students[studentId];
@@ -290,7 +316,11 @@ contract StudentManagerImpl is Initializable, SwMileageTokenFactory, Admin, Paus
290316
emit StudentRecordUpdated(studentId, currentAccount, targetAccount);
291317
}
292318

293-
function transferFromToken(bytes32 fromStudentId, bytes32 toStudentId, uint256 amount) external onlyAdmin {
319+
function transferFromToken(
320+
bytes32 fromStudentId,
321+
bytes32 toStudentId,
322+
uint256 amount
323+
) external onlyAdmin {
294324
address from = students[fromStudentId];
295325
address to = students[toStudentId];
296326
if (from == address(0) || to == address(0)) revert StudentNotRegistered();
@@ -307,7 +337,10 @@ contract StudentManagerImpl is Initializable, SwMileageTokenFactory, Admin, Paus
307337
return studentId;
308338
}
309339

310-
function _rejectDocument(uint256 documentIndex, bytes32 reasonHash) internal {
340+
function _rejectDocument(
341+
uint256 documentIndex,
342+
bytes32 reasonHash
343+
) internal {
311344
DocumentSubmission storage document = docSubmissions[documentIndex];
312345
document.status = SubmissionStatus.Rejected;
313346

src/StudentManagerFactory.sol

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ pragma solidity ^0.8.13;
44
import {Clones} from "openzeppelin-contracts/contracts/proxy/Clones.sol";
55

66
interface IStudentManagerImpl {
7-
function initialize(address _mileageToken, address implementation, address admin) external;
7+
function initialize(
8+
address _mileageToken,
9+
address implementation,
10+
address admin
11+
) external;
812
}
913

1014
contract StudentManagerFactory {
@@ -30,7 +34,10 @@ contract StudentManagerFactory {
3034
_implementation = impl;
3135
}
3236

33-
function deploy(address mileageToken, address tokenImplementation) external returns (address) {
37+
function deploy(
38+
address mileageToken,
39+
address tokenImplementation
40+
) external returns (address) {
3441
address clone = _implementation.clone();
3542
IStudentManagerImpl(clone).initialize(mileageToken, tokenImplementation, msg.sender);
3643
emit StudentManagerCreated(clone);

src/SwMileageFactory.sol

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ import {Clones} from "openzeppelin-contracts/contracts/proxy/Clones.sol";
55
import {IAdmin} from "./IAdmin.sol";
66

77
interface ISwMileageTokenImpl is IAdmin {
8-
function initialize(string memory name_, string memory symbol_, address admin) external;
8+
function initialize(
9+
string memory name_,
10+
string memory symbol_,
11+
address admin
12+
) external;
913
}
1014

1115
contract SwMileageTokenFactory {
@@ -31,14 +35,21 @@ contract SwMileageTokenFactory {
3135
_implementation = impl;
3236
}
3337

34-
function deploy(string memory name, string memory symbol) external returns (address) {
38+
function deploy(
39+
string memory name,
40+
string memory symbol
41+
) external returns (address) {
3542
address clone = _implementation.clone();
3643
ISwMileageTokenImpl(clone).initialize(name, symbol, msg.sender);
3744
emit MileageTokenCreated(clone);
3845
return address(clone);
3946
}
4047

41-
function deployWithAdmin(string memory name, string memory symbol, address admin) external returns (address) {
48+
function deployWithAdmin(
49+
string memory name,
50+
string memory symbol,
51+
address admin
52+
) external returns (address) {
4253
address clone = _implementation.clone();
4354
ISwMileageTokenImpl(clone).initialize(name, symbol, admin);
4455
emit MileageTokenCreated(clone);

0 commit comments

Comments
 (0)