Skip to content

Prevent Duplicate Role Registration in Smart Contracts#363

Merged
fishonamos merged 2 commits intoNoshonNetworks:developfrom
AryanGodara:feature/prevent-duplicate-role-reg
May 4, 2025
Merged

Prevent Duplicate Role Registration in Smart Contracts#363
fishonamos merged 2 commits intoNoshonNetworks:developfrom
AryanGodara:feature/prevent-duplicate-role-reg

Conversation

@AryanGodara
Copy link
Copy Markdown
Contributor

@AryanGodara AryanGodara commented May 2, 2025

Detailed Information

The original issue was to prevent duplicate role registrations (e.g., registering as Inspector multiple times with the same wallet). The contract already had checks in place to prevent duplicate Inspector registrations, so that part was essentially fixed.

What’s Changed

Role Exclusivity:

  • I added logic to enforce the fact that a wallet address can only have one role at a time.
  • If a user is already an Inspector, they cannot register land (become a Land Owner).
    = If a user already owns land, they cannot register as an Inspector.

New Error Message:

  • Added a specific revert message (Already registered for role) for attempts to register for a new role when already assigned another.

Tests:

  • Added new tests to ensure users cannot register for a second role if they already have one.

Cairo Optimization:

  • Replaced all while i < count loops with while i != count for better Cairo performance, (IDE suggestion; made sure that business logic doesn't change in any of them)

Related Issues

Closes #357


Type of Change

  • 🐛 Bug fix or ⚙️ enhancement
  • ✨ New feature or Chore (change with no new features or fixes)
  • 📚 Documentation update

Checklist (select as many as applicable)

  • The code follows the style guidelines of this project.
  • All new and existing tests pass.
  • This pull request is ready to be merged and reviewed.

Copy link
Copy Markdown
Member

@fishonamos fishonamos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm!

@fishonamos
Copy link
Copy Markdown
Member

LGTM!. There is an issue with the ci unrelated to your pr. Will fix them.

@fishonamos fishonamos merged commit 852785a into NoshonNetworks:develop May 4, 2025
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prevent Duplicate Role Registrations Using Same Wallet Address

2 participants