-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Independent paymaster mode validation
- Loading branch information
1 parent
e747ec7
commit a4d56bb
Showing
5 changed files
with
117 additions
and
29 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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity ^0.8.26; | ||
|
||
import { IBiconomyTokenPaymaster } from "../interfaces/IBiconomyTokenPaymaster.sol"; | ||
import "@account-abstraction/contracts/core/UserOperationLib.sol"; | ||
|
||
// A helper library to parse paymaster and data | ||
library PaymasterParser { | ||
uint256 private constant PAYMASTER_MODE_OFFSET = UserOperationLib.PAYMASTER_DATA_OFFSET; // Start offset of mode in | ||
// PND | ||
|
||
function parsePaymasterAndData(bytes calldata paymasterAndData) | ||
external | ||
pure | ||
returns (IBiconomyTokenPaymaster.PaymasterMode mode, bytes memory modeSpecificData) | ||
{ | ||
unchecked { | ||
mode = IBiconomyTokenPaymaster.PaymasterMode( | ||
uint8(bytes1(paymasterAndData[PAYMASTER_MODE_OFFSET:PAYMASTER_MODE_OFFSET + 8])) | ||
); | ||
modeSpecificData = paymasterAndData[PAYMASTER_MODE_OFFSET + 8:]; | ||
} | ||
} | ||
|
||
function parseExternalModeSpecificData(bytes calldata modeSpecificData) external pure { } | ||
|
||
function parseIndependentModeSpecificData(bytes calldata modeSpecificData) | ||
external | ||
pure | ||
returns (address tokenAddress) | ||
{ | ||
tokenAddress = address(bytes20(modeSpecificData[:20])); | ||
} | ||
} |
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