Skip to content

Commit

Permalink
feat: session key native token transfer support (#106)
Browse files Browse the repository at this point in the history
* feat: add native token transfer support in session key validator

* added paymasterAndData fix

---------

Co-authored-by: leekt <[email protected]>
  • Loading branch information
SahilVasava and leekt authored May 2, 2024
1 parent e00c66a commit dbfc881
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
url = https://github.com/leekt/I4337
[submodule "lib/FreshCryptoLib"]
path = lib/FreshCryptoLib
url = https://github.com/rdubois-crypto/FreshCryptoLib
url = https://github.com/rdubois-crypto/FreshCryptoLib
[submodule "lib/p256-verifier"]
path = lib/p256-verifier
url = https://github.com/daimo-eth/p256-verifier
path = lib/p256-verifier
url = https://github.com/daimo-eth/p256-verifier
[submodule "lib/solady"]
path = lib/solady
url = https://github.com/vectorized/solady
3 changes: 2 additions & 1 deletion src/validator/SessionKeyValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ contract SessionKeyValidator is IKernelValidator {
// to make this fully work with paymaster service, prepack the address of paymaster up front
if (session.paymaster == address(1)) {
// any paymaster
require(userOp.paymasterAndData.length != 0, "SessionKeyValidator: paymaster not set");
require(userOp.paymasterAndData.length != 0 && bytes20(userOp.paymasterAndData[0:20]) != bytes20(0), "SessionKeyValidator: paymaster not set");
} else if (session.paymaster != address(0)) {
// specific paymaster
require(
Expand Down Expand Up @@ -280,6 +280,7 @@ contract SessionKeyValidator is IKernelValidator {
}

function verifyPermission(bytes calldata data, Permission calldata permission) internal pure returns (bool) {
if(data.length == 0 && permission.sig == bytes4(0x0)) return true;
if (bytes4(data[0:4]) != permission.sig) return false;
for (uint256 i = 0; i < permission.rules.length; i++) {
ParamRule calldata rule = permission.rules[i];
Expand Down

0 comments on commit dbfc881

Please sign in to comment.