Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(role): add revoke proposed roles #205

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/selfish-llamas-raise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@axelar-network/axelar-gmp-sdk-solidity': patch
---

feat(role): add revoke proposed roles
12 changes: 11 additions & 1 deletion contracts/utils/RolesBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,16 @@ contract RolesBase is IRolesBase {
}
}

/**
* @notice Internal function to revoke any proposed roles between two accounts.
* @dev Sets the proposed roles from `fromAccount` to `toAccount` to zero, effectively canceling any pending role transfer.
* @param fromAccount The address proposing the role transfer.
* @param toAccount The address set to receive the proposed roles.
*/
function _revokeProposedRoles(address fromAccount, address toAccount) internal {
_setProposedRoles(fromAccount, toAccount, 0);
}

/**
* @notice Internal function to add a role to an account.
* @dev emits a RolesAdded event.
Expand Down Expand Up @@ -342,7 +352,6 @@ contract RolesBase is IRolesBase {
revert InvalidProposedRoles(fromAccount, toAccount, accountRoles);
}

_setProposedRoles(fromAccount, toAccount, 0);
_transferAccountRoles(fromAccount, toAccount, accountRoles);
}

Expand Down Expand Up @@ -390,6 +399,7 @@ contract RolesBase is IRolesBase {
) internal {
if (!_hasAllTheRoles(_getRoles(fromAccount), accountRoles)) revert MissingAllRoles(fromAccount, accountRoles);

_revokeProposedRoles(fromAccount, toAccount);
_removeAccountRoles(fromAccount, accountRoles);
_addAccountRoles(toAccount, accountRoles);
}
Expand Down
Loading