Skip to content

Commit

Permalink
Merge pull request #180 from bcnmy/feat/sma-392-session-keys-v2
Browse files Browse the repository at this point in the history
SMA-392: Session Keys V2
  • Loading branch information
ankurdubey521 authored Mar 2, 2024
2 parents 21c9ff6 + 50ccc11 commit 3362262
Show file tree
Hide file tree
Showing 32 changed files with 5,845 additions and 718 deletions.
37 changes: 0 additions & 37 deletions .gas-snapshot

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ deployments/localhost
typings
forge-cache
out
.env.bak
2 changes: 1 addition & 1 deletion .solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"code-complexity": ["error", 7],
"function-max-lines": ["error", 80],
"max-line-length": ["warn", 120],
"max-states-count": ["error", 15],
"max-states-count": ["error", 20],
"no-empty-blocks": "error",
"no-unused-vars": "error",
"payable-fallback": "off",
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,4 @@ import {ISignatureValidator} from "../../interfaces/ISignatureValidator.sol";
interface IBaseAuthorizationModule is
IAuthorizationModule,
ISignatureValidator
{

}
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

/**
* @title Session Key Manager module for Biconomy Modular Smart Accounts.
* @dev Stores the Session Information explicity in the storage, instead of maintainting
* a merkle tree.
* This reduces the amount of calldata required to validate a session key, making it cheaper on
* L2s.
* Allows for a session to be enabled explicity, or being batched with the first usage of said session
* @author Ankur Dubey - <[email protected]>
*/
interface ISessionKeyManagerModuleHybrid {
struct SessionData {
uint48 validUntil;
uint48 validAfter;
address sessionValidationModule;
bytes sessionKeyData;
}

event SessionCreated(
address indexed sa,
bytes32 indexed sessionDataDigest,
SessionData data
);

event SessionDisabled(
address indexed sa,
bytes32 indexed sessionDataDigest
);

/**
* @dev creates a session for a smart account
* @param sessionData session data
*/
function enableSession(SessionData calldata sessionData) external;

/**
* @dev creates multiple sessions for a smart account
* @param sessionDatas session data corresponding to multiple sessions to be enabled
*/
function enableSessions(SessionData[] calldata sessionDatas) external;

/**
* @notice Explicitly disable a session. Can be useful in situations where a session
* needs to be disabled before it expires.
* @param _sessionDigest digest of session key data
*/
function disableSession(bytes32 _sessionDigest) external;

/**
* @notice Explicitly disable multiple sessions. Can be useful in situations where a session
* needs to be disabled before it expires.
* @param _sessionDigests digests of session key datas to be disabled
*/
function disableSessions(bytes32[] calldata _sessionDigests) external;

/**
* @notice Returns session data for a given session digest and smart account
* @param _sessionDataDigest digest of session key data
* @param _sa smart account for which session data is to be fetched
* @return data SessionData struct
*/
function enabledSessionsData(
bytes32 _sessionDataDigest,
address _sa
) external view returns (SessionData memory data);

/**
* @dev Returns session data digest
* @param _data session data
* @return digest of session data
*/
function sessionDataDigest(
SessionData calldata _data
) external pure returns (bytes32);
}
4 changes: 1 addition & 3 deletions contracts/smart-account/modules/BaseAuthorizationModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,4 @@ import {AuthorizationModulesConstants} from "./AuthorizationModulesConstants.sol
abstract contract BaseAuthorizationModule is
IBaseAuthorizationModule,
AuthorizationModulesConstants
{

}
{}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pragma solidity ^0.8.23;

import {BaseAuthorizationModule} from "./BaseAuthorizationModule.sol";
import {ISessionValidationModule} from "../interfaces/modules/ISessionValidationModule.sol";
import {ISessionKeyManagerModule} from "../interfaces/modules/ISessionKeyManagerModule.sol";
import {ISessionKeyManagerModule} from "../interfaces/modules/SessionKeyManagers/ISessionKeyManagerModule.sol";
import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import {_packValidationData} from "@account-abstraction/contracts/core/Helpers.sol";
import {UserOperation} from "@account-abstraction/contracts/interfaces/UserOperation.sol";
Expand Down
Loading

0 comments on commit 3362262

Please sign in to comment.