@@ -106,6 +106,26 @@ contract StudentManagerImpl is IStudentManager, Initializable, SwMileageTokenFac
106106 emit AccountChanged (studentId, currentAccount, targetAccount);
107107 }
108108
109+ function changeStudentId (
110+ bytes32 nextId
111+ ) external whenNotPaused {
112+ require (nextId != bytes32 (0 ), "empty new student ID " );
113+
114+ bytes32 currentId = _validateAccount ();
115+ require (currentId != nextId, "student IDs must be different " );
116+ require (students[nextId] == address (0 ), "new student ID already exists " );
117+
118+ if (pendingAccountChanges[currentId].targetAccount != address (0 )) {
119+ delete pendingAccountChanges[currentId];
120+ }
121+
122+ delete students[currentId];
123+ students[nextId] = msg .sender ;
124+ studentByAddr[msg .sender ] = nextId;
125+
126+ emit StudentIdChanged (currentId, nextId, msg .sender );
127+ }
128+
109129 function getPendingAccountChange (
110130 bytes32 studentId
111131 ) external view returns (AccountChangeProposal memory ) {
@@ -232,6 +252,25 @@ contract StudentManagerImpl is IStudentManager, Initializable, SwMileageTokenFac
232252 emit AccountChanged (studentId, currentAccount, targetAccount);
233253 }
234254
255+ function migrateStudentId (bytes32 currentId , bytes32 nextId ) external onlyAdmin {
256+ require (currentId != bytes32 (0 ) && nextId != bytes32 (0 ), "empty student ID " );
257+ require (currentId != nextId, "student IDs must be different " );
258+
259+ address account = students[currentId];
260+ require (account != address (0 ), "student ID not registered " );
261+ require (students[nextId] == address (0 ), "next student ID already exists " );
262+
263+ if (pendingAccountChanges[currentId].targetAccount != address (0 )) {
264+ delete pendingAccountChanges[currentId];
265+ }
266+
267+ delete students[currentId];
268+ students[nextId] = account;
269+ studentByAddr[account] = nextId;
270+
271+ emit StudentIdChanged (currentId, nextId, account);
272+ }
273+
235274 // Imediately update student record
236275 function updateStudentRecord (bytes32 studentId , address targetAccount , bool _clear ) external onlyAdmin {
237276 require (studentId != bytes32 (0 ), "empty student ID " );
0 commit comments