-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
40 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,32 +25,39 @@ contract ApplicationManager is | |
} | ||
|
||
function createApplication( | ||
Application memory newApplication | ||
ApplicationDto memory dto | ||
) external nonReentrant restricted { | ||
require( | ||
!addressUsed[newApplication.account], | ||
!addressUsed[dto.account], | ||
"Address already used for another application" | ||
); | ||
applications[nextApplicationId] = newApplication; | ||
addressUsed[newApplication.account] = true; | ||
emit ApplicationCreated( | ||
nextApplicationId, | ||
applications[nextApplicationId] | ||
); | ||
uint id = nextApplicationId; | ||
nextApplicationId++; | ||
Application memory newApplication = Application({ | ||
id: id, | ||
name: dto.name, | ||
account: dto.account | ||
}); | ||
applications[id] = newApplication; | ||
addressUsed[newApplication.account] = true; | ||
emit ApplicationCreated(id, applications[id]); | ||
} | ||
Check notice Code scanning / Slither Reentrancy vulnerabilities Low
Reentrancy in ApplicationManager.createApplication(IApplicationManager.ApplicationDto):
External calls: - restricted() - IAccessManager(authority()).consumeScheduledOp(caller,data) State variables written after the call(s): - addressUsed[newApplication.account] = true - applications[id] = newApplication - nextApplicationId ++ |
||
|
||
function updateApplication( | ||
uint id, | ||
Application memory updatedApplication | ||
ApplicationDto memory dto | ||
) external nonReentrant restricted { | ||
require(applicationExists(id), "Application does not exist"); | ||
require( | ||
!addressUsed[updatedApplication.account] || | ||
applications[id].account == updatedApplication.account, | ||
!addressUsed[dto.account] || | ||
applications[id].account == dto.account, | ||
"Account used by another application" | ||
); | ||
applications[id] = updatedApplication; | ||
applications[id] = Application({ | ||
id: id, | ||
name: dto.name, | ||
account: dto.account | ||
}); | ||
emit ApplicationUpdated(id, applications[id]); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters