-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
31 additions
and
25 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
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,22 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
import {PackedUserOperation} from "../interfaces/PackedUserOperation.sol"; | ||
|
||
function calldataKeccak(bytes calldata data) pure returns (bytes32 ret) { | ||
assembly ("memory-safe") { | ||
let mem := mload(0x40) | ||
let len := data.length | ||
calldatacopy(mem, data.offset, len) | ||
ret := keccak256(mem, len) | ||
} | ||
} | ||
|
||
function getSender(PackedUserOperation calldata userOp) pure returns (address) { | ||
address data; | ||
//read sender from userOp, which is first userOp member (saves 800 gas...) | ||
assembly { | ||
data := calldataload(userOp) | ||
} | ||
return address(uint160(data)); | ||
} |