Skip to content

Commit

Permalink
Merge branch 'main' into i02-keccak256
Browse files Browse the repository at this point in the history
  • Loading branch information
mmv08 authored Jan 9, 2025
2 parents ffae978 + c92ddef commit 3012a6c
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion contracts/Safe.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {Enum} from "./libraries/Enum.sol";
* 1. Transaction Guard: managed in `GuardManager` for transactions executed with `execTransaction`.
* 2. Module Guard: managed in `ModuleManager` for transactions executed with `execTransactionFromModule`
* - Modules: Modules are contracts that can be used to extend the write functionality of a Safe. Managed in `ModuleManager`.
* - Fallback: Fallback handler is a contract that can provide additional read-only functionality for Safe. Managed in `FallbackManager`.
* - Fallback: Fallback handler is a contract that can provide additional functionality for Safe. Managed in `FallbackManager`. Please read the security risks in the `IFallbackManager` interface.
* Note: This version of the implementation contract doesn't emit events for the sake of gas efficiency and therefore requires a tracing node for indexing/
* For the events-based implementation see `SafeL2.sol`.
* @author Stefan George - @Georgi87
Expand Down
2 changes: 1 addition & 1 deletion contracts/base/OwnerManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ abstract contract OwnerManager is SelfAuthorized, IOwnerManager {
// There has to be at least one Safe owner.
if (_threshold == 0) revertWithError("GS202");
threshold = _threshold;
emit ChangedThreshold(threshold);
emit ChangedThreshold(_threshold);
}

/**
Expand Down
11 changes: 7 additions & 4 deletions contracts/handler/TokenCallbackHandler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ import {IERC165} from "../interfaces/IERC165.sol";
contract TokenCallbackHandler is ERC1155TokenReceiver, ERC777TokensRecipient, ERC721TokenReceiver, IERC165 {
/**
* @notice Handles ERC1155 Token callback.
* return Standardized onERC1155Received return value.
* @return Standardized onERC1155Received return value.
*/
function onERC1155Received(address, address, uint256, uint256, bytes calldata) external pure override returns (bytes4) {
return 0xf23a6e61;
}

/**
* @notice Handles ERC1155 Token batch callback.
* return Standardized onERC1155BatchReceived return value.
* @return Standardized onERC1155BatchReceived return value.
*/
function onERC1155BatchReceived(
address,
Expand All @@ -35,15 +35,18 @@ contract TokenCallbackHandler is ERC1155TokenReceiver, ERC777TokensRecipient, ER

/**
* @notice Handles ERC721 Token callback.
* return Standardized onERC721Received return value.
* @return Standardized onERC721Received return value.
*/
function onERC721Received(address, address, uint256, bytes calldata) external pure override returns (bytes4) {
return 0x150b7a02;
}

/**
* @notice Handles ERC777 Token callback.
* return nothing (not standardized)
* @dev Account that wishes to receive the tokens also needs to register the implementer (this contract) via the ERC-1820 interface registry.
* From the standard: "This is done by calling the setInterfaceImplementer function on the ERC-1820 registry with the holder address as
* the address, the keccak256 hash of ERC777TokensSender (0x29ddb589b1fb5fc7cf394961c1adf5f8c6454761adf795e67fe149f658abe895) as the
* interface hash, and the address of the contract implementing the ERC777TokensSender as the implementer."
*/
function tokensReceived(address, address, address, uint256, bytes calldata, bytes calldata) external pure override {
// We implement this for completeness, doesn't really have any value
Expand Down
14 changes: 7 additions & 7 deletions contracts/handler/extensible/SignatureVerifierMuxer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ abstract contract SignatureVerifierMuxer is ExtensibleBase, ERC1271, ISignatureV
if (sigSelector == SAFE_SIGNATURE_MAGIC_VALUE && signature.length >= 68) {
// Signature is for an `ISafeSignatureVerifier` - decode the signature.
// Layout of the `signature`:
// 0x00 - 0x04: selector
// 0x04 - 0x36: domainSeparator
// 0x36 - 0x68: typeHash
// 0x68 - 0x6C: encodeData length
// 0x6C - 0x6C + encodeData length: encodeData
// 0x6C + encodeData length - 0x6C + encodeData length + 0x20: payload length
// 0x6C + encodeData length + 0x20 - end: payload
// 0x00 to 0x04: selector
// 0x04 to 0x36: domainSeparator
// 0x36 to 0x68: typeHash
// 0x68 to 0x88: encodeData length
// 0x88 to 0x88 + encodeData length: encodeData
// 0x88 + encodeData length to 0x88 + encodeData length + 0x20: payload length
// 0x88 + encodeData length + 0x20 to end: payload
//
// Get the domainSeparator from the signature.
(bytes32 domainSeparator, bytes32 typeHash) = abi.decode(signature[4:68], (bytes32, bytes32));
Expand Down
9 changes: 6 additions & 3 deletions contracts/interfaces/IFallbackManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ interface IFallbackManager {

/**
* @notice Set Fallback Handler to `handler` for the Safe.
* @dev Only fallback calls without value and with data will be forwarded.
* This can only be done via a Safe transaction.
* Cannot be set to the Safe itself.
* @dev 1. Only fallback calls without value and with data will be forwarded.
* 2. Changing the fallback handler can only be done via a Safe transaction.
* 3. Cannot be set to the Safe itself.
* 4. IMPORTANT! SECURITY RISK! The fallback handler can be set to any address and all the calls will be forwarded to it,
* bypassing all the Safe's access control mechanisms. When setting the fallback handler, make sure to check the address
* is a trusted contract and if it supports state changes, it implements the necessary checks.
* @param handler contract to handle fallback calls.
*/
function setFallbackHandler(address handler) external;
Expand Down

0 comments on commit 3012a6c

Please sign in to comment.