Commit da17f609 authored by Maurelian's avatar Maurelian

feat(ctb): Working signature recording

parent 0d9784bf
......@@ -15,12 +15,11 @@ contract LivenessGuard is SignatureDecoder, BaseGuard {
}
/// @notice We just need to satisfy the BaseGuard interfae, but we don't actually need to use this method.
function checkAfterExecution(bytes32 txHash, bool success) external {
function checkAfterExecution(bytes32, bool) external pure {
return;
}
/// @notice This checkTransaction implementation records the most recent time which any owner has signed a
/// transaction.
/// @notice Records the most recent time which any owner has signed a transaction.
function checkTransaction(
address to,
uint256 value,
......@@ -32,7 +31,7 @@ contract LivenessGuard is SignatureDecoder, BaseGuard {
address gasToken,
address payable refundReceiver,
bytes memory signatures,
address msgSender
address
)
external
{
......@@ -43,7 +42,7 @@ contract LivenessGuard is SignatureDecoder, BaseGuard {
}
// This is a bit of a hack, maybe just replicate the functionality here rather than calling home
bytes memory txHashData = Safe(payable(msg.sender)).encodeTransactionData(
bytes32 txHash = Safe(payable(msg.sender)).getTransactionHash(
// Transaction info
to,
value,
......@@ -56,23 +55,22 @@ contract LivenessGuard is SignatureDecoder, BaseGuard {
gasToken,
refundReceiver,
// Signature info
Safe(payable(msg.sender)).nonce() // check that this works
);
address[] memory signers = _getNSigners(keccak256(txHashData), signatures);
address[] memory signers = _getNSigners(txHash, signatures);
for (uint256 i = 0; i < signers.length; i++) {
lastSigned[signers[i]] = block.timestamp;
}
}
function _getNSigners(bytes32 dataHash, bytes memory signatures) internal returns (address[] memory _owners) {
uint256 numSignatures = signatures.length / 65; // division OK?
/// @notice Exctract the signers from a set of signatures.
function _getNSigners(bytes32 dataHash, bytes memory signatures) internal pure returns (address[] memory _owners) {
uint256 numSignatures = signatures.length / 65;
_owners = new address[](numSignatures);
// The following code is extracted from the Safe.checkNSignatures() method. It removes the signature validation
// code,
// and keeps only the parsing code necessary to extract the owner addresses from the signatures.
// We do not double check if the owner derived from a signature is valid. As tHis is handled in
// the final require statement of Safe.checkNSignatures().
/// The following code is extracted from the Safe.checkNSignatures() method. It removes the signature
/// validation code, and keeps only the parsing code necessary to extract the owner addresses from the
/// signatures. We do not double check if the owner derived from a signature is valid. As this is handled
/// in the final require statement of Safe.checkNSignatures().
address currentOwner;
uint8 v;
bytes32 r;
......
......@@ -27,7 +27,7 @@ contract LivnessGuard_TestInit is Test, SafeTestTools {
function setUp() public {
safeInstance = _setupSafe();
livenessGuard = new LivenessGuard(safeInstance.safe);
safeInstance.enableModule(address(livenessGuard));
safeInstance.setGuard(address(livenessGuard));
}
}
......@@ -37,7 +37,6 @@ contract LivnessGuard_TestCheckTx is LivnessGuard_TestInit {
function test_checkTransaction_succeeds() external {
safeInstance.execTransaction({ to: address(1111), value: 0, data: hex"abba" });
// bug signers need to be sorted from low to high
for (uint256 i; i < safeInstance.owners.length; i++) {
assertEq(livenessGuard.lastSigned(safeInstance.owners[i]), block.timestamp);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment