Skip to content

Commit b6c2adc

Browse files
committed
Finished
1 parent 7b19d53 commit b6c2adc

28 files changed

Lines changed: 377 additions & 265 deletions

contracts/common/Singleton.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pragma solidity >=0.7.0 <0.9.0;
1111
abstract contract Singleton {
1212
/**
1313
* @dev `singleton` must be the first declared variable to ensure it has the same storage location as in the {SafeProxy} contract.
14-
* The address must be stored alone: it must use a full 32-byte word and cannot be packed with other storage variables.
14+
* The address must be stored alone: it must use a full 32-byte word and cannot be packed with other storage variables.
1515
*/
1616
address private singleton;
1717
}

contracts/handler/ExtensibleFallbackHandler.sol

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ import {ERC1271, ISignatureVerifierMuxer, SignatureVerifierMuxer} from "./extens
77
import {ERC721TokenReceiver, ERC1155TokenReceiver, TokenCallbacks} from "./extensible/TokenCallbacks.sol";
88

99
/**
10-
* @title ExtensibleFallbackHandler - A fully extensible fallback handler for Safes
10+
* @title Extensible Fallback Handler
11+
* @notice A fully extensible fallback handler for Safes.
1112
* @dev Designed to be used with Safe >= 1.3.0.
1213
* @author mfw78 <mfw78@rndlabs.xyz>
1314
*/
1415
contract ExtensibleFallbackHandler is FallbackHandler, SignatureVerifierMuxer, TokenCallbacks, ERC165Handler {
1516
/**
16-
* Specify specific interfaces (ERC721 + ERC1155) that this contract supports.
17-
* @param interfaceId The interface ID to check for support
17+
* @notice Specify specific interfaces (ERC-721 + ERC-1155) that this contract supports.
18+
* @param interfaceId The interface ID to check for support.
1819
*/
1920
function _supportsInterface(bytes4 interfaceId) internal pure override returns (bool) {
2021
return

contracts/handler/HandlerContext.sol

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22
pragma solidity >=0.7.0 <0.9.0;
33

44
/**
5-
* @title Handler Context - Allows the fallback handler to extract additional context from the calldata
5+
* @title Handler Context
6+
* @notice Allows the fallback handler to extract additional context from the calldata.
67
* @dev The fallback manager appends the following context to the calldata:
78
* 1. Fallback manager caller address (non-padded)
8-
* based on https://github.com/OpenZeppelin/openzeppelin-contracts/blob/f8cc8b844a9f92f63dc55aa581f7d643a1bc5ac1/contracts/metatx/ERC2771Context.sol
9+
* Based on <https://github.com/OpenZeppelin/openzeppelin-contracts/blob/f8cc8b844a9f92f63dc55aa581f7d643a1bc5ac1/contracts/metatx/ERC2771Context.sol>
910
* @author Richard Meissner - @rmeissner
1011
*/
1112
abstract contract HandlerContext {
1213
/**
1314
* @notice Allows fetching the original caller address.
14-
* @dev This is only reliable with a FallbackManager supporting this (e.g. Safe contract >=1.3.0).
15+
* @dev This is only reliable with a {FallbackManager} supporting this (e.g. Safe contract >=1.3.0).
1516
* When using this functionality, ensure that the linked _manager (aka msg.sender) supports this.
1617
* This function does not rely on a trusted forwarder. Use the returned value only to
1718
* check information against the calling manager.
@@ -29,8 +30,8 @@ abstract contract HandlerContext {
2930
}
3031

3132
/**
32-
* @notice Returns the FallbackManager address
33-
* @return Fallback manager address
33+
* @notice Returns the FallbackManager address.
34+
* @return Fallback manager address.
3435
*/
3536
function _manager() internal view returns (address) {
3637
return msg.sender;

contracts/handler/TokenCallbackHandler.sol

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,20 @@ import {ERC777TokensRecipient} from "../interfaces/ERC777TokensRecipient.sol";
77
import {IERC165} from "../interfaces/IERC165.sol";
88

99
/**
10-
* @title Default Callback Handler - Handles supported tokens' callbacks, allowing Safes to receive these tokens.
10+
* @title Token Callback Handler
11+
* @notice Handles supported tokens' callbacks, allowing Safes to receive these tokens.
1112
* @author Richard Meissner - @rmeissner
1213
*/
1314
contract TokenCallbackHandler is ERC1155TokenReceiver, ERC777TokensRecipient, ERC721TokenReceiver, IERC165 {
1415
/**
15-
* @notice Handles ERC1155 Token callback.
16-
* @return Standardized onERC1155Received return value.
16+
* @inheritdoc ERC1155TokenReceiver
1717
*/
1818
function onERC1155Received(address, address, uint256, uint256, bytes calldata) external pure override returns (bytes4) {
1919
return 0xf23a6e61;
2020
}
2121

2222
/**
23-
* @notice Handles ERC1155 Token batch callback.
24-
* @return Standardized onERC1155BatchReceived return value.
23+
* @inheritdoc ERC1155TokenReceiver
2524
*/
2625
function onERC1155BatchReceived(
2726
address,
@@ -34,15 +33,14 @@ contract TokenCallbackHandler is ERC1155TokenReceiver, ERC777TokensRecipient, ER
3433
}
3534

3635
/**
37-
* @notice Handles ERC721 Token callback.
38-
* @return Standardized onERC721Received return value.
36+
* @inheritdoc ERC721TokenReceiver
3937
*/
4038
function onERC721Received(address, address, uint256, bytes calldata) external pure override returns (bytes4) {
4139
return 0x150b7a02;
4240
}
4341

4442
/**
45-
* @notice Handles ERC777 Token callback.
43+
* @inheritdoc ERC777TokensRecipient
4644
* @dev Account that wishes to receive the tokens also needs to register the implementer (this contract) via the ERC-1820 interface registry.
4745
* From the standard: "This is done by calling the setInterfaceImplementer function on the ERC-1820 registry with the holder address as
4846
* the address, the keccak256 hash of ERC777TokensSender (0x29ddb589b1fb5fc7cf394961c1adf5f8c6454761adf795e67fe149f658abe895) as the
@@ -53,9 +51,7 @@ contract TokenCallbackHandler is ERC1155TokenReceiver, ERC777TokensRecipient, ER
5351
}
5452

5553
/**
56-
* @notice Implements ERC165 interface support for ERC1155TokenReceiver, ERC721TokenReceiver and IERC165.
57-
* @param interfaceId Id of the interface.
58-
* @return if the interface is supported.
54+
* @inheritdoc IERC165
5955
*/
6056
function supportsInterface(bytes4 interfaceId) external view virtual override returns (bool) {
6157
return

contracts/interfaces/ERC1155TokenReceiver.sol

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
// SPDX-License-Identifier: LGPL-3.0-only
22
pragma solidity >=0.7.0 <0.9.0;
33

4-
// Note: The ERC-165 identifier for this interface is 0x4e2312e0.
4+
/**
5+
* @title ERC-1155 Token Receiver Interface
6+
* @dev The ERC-165 identifier for this interface is 0x4e2312e0.
7+
*/
58
interface ERC1155TokenReceiver {
69
/**
7-
* @notice Handle the receipt of a single ERC1155 token type.
8-
* @dev An ERC1155-compliant smart contract MUST call this function on the token recipient contract, at the end of a `safeTransferFrom` after the balance has been updated.
10+
* @notice Handle the receipt of a single ERC-1155 token type.
11+
* @dev An ERC-1155-compliant smart contract MUST call this function on the token recipient contract, at the end of a `safeTransferFrom` after the balance has been updated.
912
* This function MUST return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` (i.e. 0xf23a6e61) if it accepts the transfer.
1013
* This function MUST revert if it rejects the transfer.
1114
* Return of any other value than the prescribed keccak256 generated value MUST result in the transaction being reverted by the caller.
@@ -25,8 +28,8 @@ interface ERC1155TokenReceiver {
2528
) external returns (bytes4);
2629

2730
/**
28-
* @notice Handle the receipt of multiple ERC1155 token types.
29-
* @dev An ERC1155-compliant smart contract MUST call this function on the token recipient contract, at the end of a `safeBatchTransferFrom` after the balances have been updated.
31+
* @notice Handle the receipt of multiple ERC-1155 token types.
32+
* @dev An ERC-1155-compliant smart contract MUST call this function on the token recipient contract, at the end of a `safeBatchTransferFrom` after the balances have been updated.
3033
* This function MUST return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` (i.e. 0xbc197c81) if it accepts the transfer(s).
3134
* This function MUST revert if it rejects the transfer(s).
3235
* Return of any other value than the prescribed keccak256 generated value MUST result in the transaction being reverted by the caller.

contracts/interfaces/ERC721TokenReceiver.sol

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
// SPDX-License-Identifier: LGPL-3.0-only
22
pragma solidity >=0.7.0 <0.9.0;
33

4-
/// @dev Note: the ERC-165 identifier for this interface is 0x150b7a02.
4+
/**
5+
* @title ERC-721 Token Receiver Interface
6+
* @dev Note: the ERC-165 identifier for this interface is 0x150b7a02.
7+
*/
58
interface ERC721TokenReceiver {
69
/**
710
* @notice Handle the receipt of an NFT

contracts/interfaces/ERC777TokensRecipient.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
pragma solidity >=0.7.0 <0.9.0;
33

44
/**
5-
* @title ERC777TokensRecipient
6-
* @dev Interface for contracts that will be called with the ERC777 token's `tokensReceived` method.
7-
* The contract receiving the tokens must implement this interface to receive the tokens.
5+
* @title ERC-777 Tokens Recipient Interface
6+
* @dev Interface for contracts that will be called with the ERC-777 token's `tokensReceived` method.
7+
* The contract receiving the tokens must implement this interface to receive the tokens.
88
*/
99
interface ERC777TokensRecipient {
1010
/**
11-
* @dev Called by the ERC777 token contract after a successful transfer or a minting operation.
11+
* @dev Called by the ERC-777 token contract after a successful transfer or a minting operation.
1212
* @param operator The address of the operator performing the transfer or minting operation.
1313
* @param from The address of the sender.
1414
* @param to The address of the recipient.

contracts/interfaces/IERC165.sol

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
// SPDX-License-Identifier: LGPL-3.0-only
22
pragma solidity >=0.7.0 <0.9.0;
33

4-
/// @notice More details at https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/introspection/IERC165.sol
4+
/**
5+
* @title ERC-165 Inteface
6+
* @dev More details at <https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/introspection/IERC165.sol>
7+
*/
58
interface IERC165 {
69
/**
7-
* @dev Returns true if this contract implements the interface defined by `interfaceId`.
8-
* See the corresponding EIP section
9-
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified
10-
* to learn more about how these ids are created.
11-
*
12-
* This function call must use less than 30 000 gas.
10+
* @notice Returns true if this contract implements the interface defined by `interfaceId`.
11+
* @dev See the corresponding EIP section <https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified>
12+
* to learn more about how these ids are created.
13+
* This function call must use less than 30.000 gas.
14+
* @param interfaceId The ID of the interface to check support for.
15+
* @return Whether or not the interface is supported.
1316
*/
1417
function supportsInterface(bytes4 interfaceId) external view returns (bool);
1518
}

contracts/interfaces/IFallbackManager.sol

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,25 @@
22
pragma solidity >=0.7.0 <0.9.0;
33

44
/**
5-
* @title IFallbackManager - A contract interface managing fallback calls made to this contract.
5+
* @title Fallback Manager Interface
6+
* @notice Interface for managing how fallback calls made to this contract.
67
* @author @safe-global/safe-protocol
78
*/
89
interface IFallbackManager {
10+
/**
11+
* @notice The fallback handler has changed.
12+
* @param handler The address of the new fallback handler.
13+
*/
914
event ChangedFallbackHandler(address indexed handler);
1015

1116
/**
1217
* @notice Set Fallback Handler to `handler` for the Safe.
1318
* @dev 1. Only fallback calls without value and with data will be forwarded.
1419
* 2. Changing the fallback handler can only be done via a Safe transaction.
1520
* 3. Cannot be set to the Safe itself.
16-
* 4. IMPORTANT! SECURITY RISK! The fallback handler can be set to any address and all the calls will be forwarded to it,
21+
* 4. ⚠️⚠️⚠️ IMPORTANT! SECURITY RISK! The fallback handler can be set to any address and all the calls will be forwarded to it,
1722
* bypassing all the Safe's access control mechanisms. When setting the fallback handler, make sure to check the address
18-
* is a trusted contract and if it supports state changes, it implements the necessary checks.
23+
* is a trusted contract and if it supports state changes, it implements the necessary checks. ⚠️⚠️⚠️
1924
* @param handler contract to handle fallback calls.
2025
*/
2126
function setFallbackHandler(address handler) external;

contracts/interfaces/IGuardManager.sol

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,19 @@ pragma solidity >=0.7.0 <0.9.0;
77
* @author @safe-global/safe-protocol
88
*/
99
interface IGuardManager {
10+
/**
11+
* @notice Transaction guard changed.
12+
* @param guard The address of the new transaction guard.
13+
*/
1014
event ChangedGuard(address indexed guard);
1115

1216
/**
13-
* @dev Set a guard that checks transactions before execution
14-
* This can only be done via a Safe transaction.
15-
* ⚠️ IMPORTANT: Since a guard has full power to block Safe transaction execution,
16-
* a broken guard can cause a denial of service for the Safe. Make sure to carefully
17-
* audit the guard code and design recovery mechanisms.
1817
* @notice Set Transaction Guard `guard` for the Safe. Make sure you trust the guard.
18+
* @dev Set a guard that checks Safe transactions before and after execution.
19+
* This can only be done via a Safe transaction.
20+
* ⚠️⚠️⚠️ IMPORTANT: Since a guard has full power to block Safe transaction execution,
21+
* a broken guard can cause a denial of service for the Safe. Make sure to carefully
22+
* audit the guard code and design recovery mechanisms. ⚠️⚠️⚠️
1923
* @param guard The address of the guard to be used or the 0 address to disable the guard
2024
*/
2125
function setGuard(address guard) external;

0 commit comments

Comments
 (0)