forked from safe-global/safe-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'safe-global:master' into patch-1
- Loading branch information
Showing
19 changed files
with
4,351 additions
and
8,076 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
pragma solidity >=0.8.0 <0.9.0; | ||
|
||
import {ISafe} from "./interfaces/Safe.sol"; | ||
|
||
/// @title AddModulesLib | ||
contract AddModulesLib { | ||
function enableModules(address[] calldata modules) external { | ||
for (uint256 i = modules.length; i > 0; i--) { | ||
// This call will only work properly if used via a delegatecall | ||
ISafe(address(this)).enableModule(modules[i - 1]); | ||
} | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
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,59 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity >=0.7.0 <0.9.0; | ||
|
||
import {UserOperation} from "../UserOperation.sol"; | ||
|
||
interface INonceManager { | ||
/** | ||
* Return the next nonce for this sender. | ||
* Within a given key, the nonce values are sequenced (starting with zero, and incremented by one on each userop) | ||
* But UserOp with different keys can come with arbitrary order. | ||
* | ||
* @param sender the account address | ||
* @param key the high 192 bit of the nonce | ||
* @return nonce a full nonce to pass for next UserOp with this sender. | ||
*/ | ||
function getNonce(address sender, uint192 key) external view returns (uint256 nonce); | ||
|
||
/** | ||
* Manually increment the nonce of the sender. | ||
* This method is exposed just for completeness.. | ||
* Account does NOT need to call it, neither during validation, nor elsewhere, | ||
* as the EntryPoint will update the nonce regardless. | ||
* Possible use-case is call it with various keys to "initialize" their nonces to one, so that future | ||
* UserOperations will not pay extra for the first transaction with a given key. | ||
*/ | ||
function incrementNonce(uint192 key) external; | ||
} | ||
|
||
interface IAccount { | ||
/** | ||
* Validate user's signature and nonce | ||
* the entryPoint will make the call to the recipient only if this validation call returns successfully. | ||
* signature failure should be reported by returning SIG_VALIDATION_FAILED (1). | ||
* This allows making a "simulation call" without a valid signature | ||
* Other failures (e.g. nonce mismatch, or invalid signature format) should still revert to signal failure. | ||
* | ||
* @dev Must validate caller is the entryPoint. | ||
* Must validate the signature and nonce | ||
* @param userOp the operation that is about to be executed. | ||
* @param userOpHash hash of the user's request data. can be used as the basis for signature. | ||
* @param missingAccountFunds missing funds on the account's deposit in the entrypoint. | ||
* This is the minimum amount to transfer to the sender(entryPoint) to be able to make the call. | ||
* The excess is left as a deposit in the entrypoint, for future calls. | ||
* can be withdrawn anytime using "entryPoint.withdrawTo()" | ||
* In case there is a paymaster in the request (or the current deposit is high enough), this value will be zero. | ||
* @return validationData packaged ValidationData structure. use `_packValidationData` and `_unpackValidationData` to encode and decode | ||
* <20-byte> sigAuthorizer - 0 for valid signature, 1 to mark signature failure, | ||
* otherwise, an address of an "authorizer" contract. | ||
* <6-byte> validUntil - last timestamp this operation is valid. 0 for "indefinite" | ||
* <6-byte> validAfter - first timestamp this operation is valid | ||
* If an account doesn't use time-range, it is enough to return SIG_VALIDATION_FAILED value (1) for signature failure. | ||
* Note that the validation code cannot use block.timestamp (or block.number) directly. | ||
*/ | ||
function validateUserOp( | ||
UserOperation calldata userOp, | ||
bytes32 userOpHash, | ||
uint256 missingAccountFunds | ||
) external returns (uint256 validationData); | ||
} |
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.