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: add agent address for validators #568

Merged
merged 5 commits into from
Jul 17, 2024
Merged

feat: add agent address for validators #568

merged 5 commits into from
Jul 17, 2024

Conversation

cosinlink
Copy link
Collaborator

Description

add agent address for validators

Rationale

Agent can execute editConsensusAddress, editCommissionRate, editDescription, editVoteAddress for his operator.

Changes

Notable changes:

  • add agent address for validators
  • ...

@@ -1179,4 +1208,12 @@ contract StakeHub is System, Initializable, Protectable {
uint256 bnbAmount = IStakeCredit(_validators[operatorAddress].creditContract).claim(msg.sender, requestNumber);
emit Claimed(operatorAddress, msg.sender, bnbAmount);
}

function _getMsgSender() internal view returns (address) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It may be better use _getOperatorFromMsgSender

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

_getOperatorFromMsgSender may be inaccurate. In most cases, msg.sender is returned directly, and in rare cases, the agent can appear as a msg.sender replacement for the operatorAddress.

Copy link
Contributor

Choose a reason for hiding this comment

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

_getOperatorByMsgSender?

Copy link
Collaborator Author

@cosinlink cosinlink Jul 12, 2024

Choose a reason for hiding this comment

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

This method is not to get operator address, it's to get the real msg.sender for all address. Only in some scenarios, the agent can be the msg.sender of the operatorAddress .

Copy link
Collaborator Author

@cosinlink cosinlink Jul 12, 2024

Choose a reason for hiding this comment

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

we can refer to the similar code here: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/05f218fb6617932e56bf5388c3b389c3028a7b73/contracts/metatx/ERC2771Context.sol#L55

_msgSender is used to replace the msg.sender and
_getMsgSender is also used to replace the msg.sender

@cosinlink cosinlink enabled auto-merge July 17, 2024 03:54
@cosinlink cosinlink added this pull request to the merge queue Jul 17, 2024
Merged via the queue into develop with commit f2617f8 Jul 17, 2024
2 checks passed
MoharshBoru

This comment was marked as resolved.

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.

5 participants