-
Notifications
You must be signed in to change notification settings - Fork 1
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
11 changed files
with
1,331 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity 0.8.20; | ||
pragma solidity ^0.8.20; | ||
|
||
/** | ||
* @author Matter Labs | ||
|
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,51 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.20; | ||
|
||
import "./IPaymaster.sol"; | ||
import "../libraries/EIP712.sol"; | ||
import "../libraries/ECDSA.sol"; | ||
|
||
contract TestPaymaster is IPaymaster, EIP712 { | ||
struct SignData { | ||
bytes32 suggestedSignedHash; | ||
} | ||
|
||
address public owner; | ||
|
||
constructor(string memory name, string memory version) EIP712(name, version) { | ||
owner = msg.sender; | ||
} | ||
|
||
function signDataTypeHash() internal pure returns (bytes32) { | ||
return keccak256("SignData(bytes32 suggestedSignedHash)"); | ||
} | ||
|
||
function signDataMessage(bytes32 suggestedSignedHash) internal view returns (bytes32) { | ||
return ECDSA.toTypedDataHash(_domainSeparatorV4(), keccak256(abi.encode( | ||
signDataTypeHash(), | ||
suggestedSignedHash | ||
))); | ||
} | ||
|
||
function validateAndPayForPaymasterTransaction( | ||
bytes32 _txHash, | ||
bytes32 _suggestedSignedHash, | ||
bytes memory _authenticationSignature, | ||
Transaction calldata _transaction | ||
) external payable returns (bytes4 magic, bytes memory context) { | ||
address recoverAddress = ECDSA.recover(signDataMessage(_suggestedSignedHash), _authenticationSignature); | ||
require(recoverAddress == owner, "Paymaster: Unauthorized signature"); | ||
return (PAYMASTER_VALIDATION_SUCCESS_MAGIC, context); | ||
} | ||
|
||
function postTransaction( | ||
bytes calldata _context, | ||
Transaction calldata _transaction, | ||
bytes32 _txHash, | ||
bytes32 _suggestedSignedHash, | ||
ExecutionResult _txResult, | ||
uint256 _maxRefundedGas | ||
) external payable { | ||
|
||
} | ||
} |
Oops, something went wrong.