Last active
January 21, 2019 08:56
-
-
Save Arachnid/6a5c8ff96869fbdf0736a3a7be91b84e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// WHATEVER YOU DO, DON'T USE THIS. | |
// This is a bit of demo code posted to illustrate a principle. It is unaudited, | |
// probably full of bugs, and definintely not production ready. | |
// https://twitter.com/nicksdjohnson/status/1041642345467404291 | |
import "./DumbWallet.sol"; | |
contract WalletDelegator { | |
mapping(address=>uint) public nonces; | |
function callFor(DumbWallet wallet, address target, uint value, bytes data, bytes32 r, bytes32 s, uint8 v) payable { | |
bytes32 sigHash = keccak256(abi.encodePacked(wallet, target, value, data, nonces[wallet])); | |
address signer = ecrecover(sigHash, v, r, s); | |
require(wallet.authorised(signer)); | |
wallet.invoke.value(msg.value)(target, value, data); | |
nonces[wallet]++; | |
} | |
} |
I would call nonces[wallet]++;
right after generating sigHash
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is not reentrancy safe, right?