-
Notifications
You must be signed in to change notification settings - Fork 950
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
Adding ISafe
interface for CompatibilityFallbackHandler
#722
Merged
Changes from 10 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
4b9eb4a
Adding ISafe and changing CompatibilityFallbackHandler
remedcu 9efc0b1
Added codesize script in package.json
remedcu f50e204
IEnum added for interface inheritance
remedcu bf617f5
ISafe updated with IEnum and some more functions
remedcu 4918270
Using ISafe from interfaces for contracts
remedcu 2c4a9d0
Merge branch 'main' into ISafe
remedcu cc89e43
solhint warning rectified
remedcu 0de7d32
Merge branch 'ISafe' of https://github.com/safe-global/safe-contracts…
remedcu 95e247d
abstract Enum replaced with interface Enum
remedcu e10bb96
Author added to ISafe
remedcu 70e12c9
Updating author
remedcu 0ccc4a2
Created ISafeExtended by splitting ISafe
remedcu ce6e554
Harness patch updated
remedcu c46d5bd
Using harness patch to remove getTransactionHash(...) in ISafe
remedcu c637ab5
Creating nonce in ISafe and using ISafe for examples and libraries
remedcu 1eb8e96
Merge branch 'main' into ISafe
remedcu f090084
Removed ISafeExtended and created individual interfaces
remedcu 615383a
Removed Enum use in IGuardManager
remedcu 7e7deeb
Enum file name changed
remedcu d765019
Changed Interface Enum to Library Enum
remedcu 4e7649d
Adding approvedHashes into ISafe
remedcu bb1662e
Natspec for ISafe getter functions
remedcu 33bca3d
Moved Events to Interfaces
remedcu 2401405
Certora Harness Patch Updated
remedcu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
pragma solidity >=0.7.0 <0.9.0; | ||
|
||
import {Enum} from "./IEnum.sol"; | ||
|
||
/** | ||
* @title ISafe - A multisignature wallet interface with support for confirmations using signed messages based on EIP-712. | ||
* @author Shebin John - @remedcu | ||
*/ | ||
interface ISafe { | ||
/** | ||
* @notice Sets an initial storage of the Safe contract. | ||
* @dev This method can only be called once. | ||
* If a proxy was created without setting up, anyone can call setup and claim the proxy. | ||
* @param _owners List of Safe owners. | ||
* @param _threshold Number of required confirmations for a Safe transaction. | ||
* @param to Contract address for optional delegate call. | ||
* @param data Data payload for optional delegate call. | ||
* @param fallbackHandler Handler for fallback calls to this contract | ||
* @param paymentToken Token that should be used for the payment (0 is ETH) | ||
* @param payment Value that should be paid | ||
* @param paymentReceiver Address that should receive the payment (or 0 if tx.origin) | ||
*/ | ||
function setup( | ||
remedcu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
address[] calldata _owners, | ||
uint256 _threshold, | ||
address to, | ||
bytes calldata data, | ||
address fallbackHandler, | ||
address paymentToken, | ||
uint256 payment, | ||
address payable paymentReceiver | ||
) external; | ||
|
||
/** @notice Executes a `operation` {0: Call, 1: DelegateCall}} transaction to `to` with `value` (Native Currency) | ||
* and pays `gasPrice` * `gasLimit` in `gasToken` token to `refundReceiver`. | ||
* @dev The fees are always transferred, even if the user transaction fails. | ||
* This method doesn't perform any sanity check of the transaction, such as: | ||
* - if the contract at `to` address has code or not | ||
* - if the `gasToken` is a contract or not | ||
* It is the responsibility of the caller to perform such checks. | ||
* @param to Destination address of Safe transaction. | ||
* @param value Ether value of Safe transaction. | ||
* @param data Data payload of Safe transaction. | ||
* @param operation Operation type of Safe transaction. | ||
* @param safeTxGas Gas that should be used for the Safe transaction. | ||
* @param baseGas Gas costs that are independent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund) | ||
* @param gasPrice Gas price that should be used for the payment calculation. | ||
* @param gasToken Token address (or 0 if ETH) that is used for the payment. | ||
* @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin). | ||
* @param signatures Signature data that should be verified. | ||
* Can be packed ECDSA signature ({bytes32 r}{bytes32 s}{uint8 v}), contract signature (EIP-1271) or approved hash. | ||
* @return success Boolean indicating transaction's success. | ||
*/ | ||
function execTransaction( | ||
address to, | ||
uint256 value, | ||
bytes calldata data, | ||
Enum.Operation operation, | ||
uint256 safeTxGas, | ||
uint256 baseGas, | ||
uint256 gasPrice, | ||
address gasToken, | ||
address payable refundReceiver, | ||
bytes memory signatures | ||
) external payable returns (bool success); | ||
|
||
/** | ||
* @notice Checks whether the signature provided is valid for the provided data and hash. Reverts otherwise. | ||
* @param dataHash Hash of the data (could be either a message hash or transaction hash) | ||
* @param signatures Signature data that should be verified. | ||
* Can be packed ECDSA signature ({bytes32 r}{bytes32 s}{uint8 v}), contract signature (EIP-1271) or approved hash. | ||
*/ | ||
function checkSignatures(bytes32 dataHash, bytes memory signatures) external view; | ||
|
||
/** | ||
* @notice Checks whether the signature provided is valid for the provided data and hash. Reverts otherwise. | ||
* @dev Since the EIP-1271 does an external call, be mindful of reentrancy attacks. | ||
* @param executor Address that executing the transaction. | ||
* ⚠️⚠️⚠️ Make sure that the executor address is a legitmate executor. | ||
* Incorrectly passed the executor might reduce the threshold by 1 signature. ⚠️⚠️⚠️ | ||
* @param dataHash Hash of the data (could be either a message hash or transaction hash) | ||
* @param signatures Signature data that should be verified. | ||
* Can be packed ECDSA signature ({bytes32 r}{bytes32 s}{uint8 v}), contract signature (EIP-1271) or approved hash. | ||
* @param requiredSignatures Amount of required valid signatures. | ||
*/ | ||
function checkNSignatures(address executor, bytes32 dataHash, bytes memory signatures, uint256 requiredSignatures) external view; | ||
|
||
/** | ||
* @notice Marks hash `hashToApprove` as approved. | ||
* @dev This can be used with a pre-approved hash transaction signature. | ||
* IMPORTANT: The approved hash stays approved forever. There's no revocation mechanism, so it behaves similarly to ECDSA signatures | ||
* @param hashToApprove The hash to mark as approved for signatures that are verified by this contract. | ||
*/ | ||
function approveHash(bytes32 hashToApprove) external; | ||
|
||
/** | ||
* @dev Returns the domain separator for this contract, as defined in the EIP-712 standard. | ||
* @return bytes32 The domain separator hash. | ||
*/ | ||
function domainSeparator() external view returns (bytes32); | ||
|
||
/** | ||
* @notice Returns transaction hash to be signed by owners. | ||
* @param to Destination address. | ||
* @param value Ether value. | ||
* @param data Data payload. | ||
* @param operation Operation type. | ||
* @param safeTxGas Gas that should be used for the safe transaction. | ||
* @param baseGas Gas costs for data used to trigger the safe transaction. | ||
* @param gasPrice Maximum gas price that should be used for this transaction. | ||
* @param gasToken Token address (or 0 if ETH) that is used for the payment. | ||
* @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin). | ||
* @param _nonce Transaction nonce. | ||
* @return Transaction hash. | ||
*/ | ||
function getTransactionHash( | ||
address to, | ||
uint256 value, | ||
bytes calldata data, | ||
Enum.Operation operation, | ||
uint256 safeTxGas, | ||
uint256 baseGas, | ||
uint256 gasPrice, | ||
address gasToken, | ||
address refundReceiver, | ||
uint256 _nonce | ||
) external view returns (bytes32); | ||
|
||
/** | ||
* @dev External getter function for state variables. | ||
remedcu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
*/ | ||
// solhint-disable-next-line | ||
function VERSION() external view returns (string memory); | ||
remedcu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
function signedMessages(bytes32 messageHash) external view returns (uint256); | ||
|
||
/** | ||
* @dev External getter function for inherited functions. | ||
*/ | ||
function getModulesPaginated(address start, uint256 pageSize) external view returns (address[] memory array, address next); | ||
function getThreshold() external view returns (uint256); | ||
function isOwner(address owner) external view returns (bool); | ||
function getOwners() external view returns (address[] memory); | ||
function setFallbackHandler(address handler) external; | ||
function setGuard(address guard) external; | ||
} | ||
remedcu marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we import it as
Safe
? then it would not trigger any additional code changes (same was done forEnum
)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think keeping it with an
I
is significant to notify the user that it is aninterface
and to follow a usual standard of interfaces. Also, using the same name will lead toHardhatError: HH701: There are multiple artifacts for contract "Safe", please use a fully qualified name.
in tests (though it could be avoided by using the entire path to the contract I believe).For
Enum
, the decision was taken to avoid the changes within the contract likeEnum.Operation operation
->IEnum.Operation operation