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

Error in solidity code #14527

Open
YakshitAgarwal opened this issue Dec 18, 2024 · 5 comments
Open

Error in solidity code #14527

YakshitAgarwal opened this issue Dec 18, 2024 · 5 comments
Labels
needs triage 📥 This issue needs triaged before being worked on

Comments

@YakshitAgarwal
Copy link
Contributor

Original solidity code:

pragma solidity ^0.7.0;

contract MutexPattern {
bool locked = false;
mapping(address => uint256) public balances;

modifier noReentrancy() {
    require(!locked, "Blocked from reentrancy.");
    locked = true;
    _;
    locked = false;
}
// This function is protected by a mutex, so reentrant calls from within `msg.sender.call` cannot call `withdraw` again.
//  The `return` statement evaluates to `true` but still evaluates the `locked = false` statement in the modifier
function withdraw(uint _amount) public payable noReentrancy returns(bool) {
    require(balances[msg.sender] >= _amount, "No balance to withdraw.");

    balances[msg.sender] -= _amount;
    bool (success, ) = msg.sender.call{value: _amount}("");
    require(success);

    return true;
}

}

Error in the above code:
bool (success, ) = msg.sender.call{value: _amount}("");

Changed to:
(bool success, ) = msg.sender.call{value: _amount}("");

@github-actions github-actions bot added the needs triage 📥 This issue needs triaged before being worked on label Dec 18, 2024
@YakshitAgarwal
Copy link
Contributor Author

Can someone assign me this issue please?

@konopkja
Copy link
Contributor

konopkja commented Dec 19, 2024

this is ethereum.org repo how is this related to our site? or Should this be in solidity? should this be https://github.com/ethereum/solidity ?

@YakshitAgarwal
Copy link
Contributor Author

oh it was a code display in public/content/developers/docs/smart-contracts/security/index.md

@YakshitAgarwal
Copy link
Contributor Author

YakshitAgarwal commented Dec 19, 2024

the code there was incorrect so I corrected it.

@konopkja
Copy link
Contributor

the code there was incorrect so I correct it.

ah ok, ty for clarification

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage 📥 This issue needs triaged before being worked on
Projects
None yet
Development

No branches or pull requests

2 participants