@biconomy-devx/modules
Version:
This package provides different validation modules/plugins for ERC4337 compatible modular account
44 lines • 1.92 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getUserOpHash = void 0;
const viem_1 = require("viem");
function packUserOp(op, forSignature = true) {
if (!op.initCode || !op.callData || !op.paymasterAndData)
throw new Error("Missing userOp properties");
if (forSignature) {
return (0, viem_1.encodeAbiParameters)((0, viem_1.parseAbiParameters)("address, uint256, bytes32, bytes32, uint256, uint256, uint256, uint256, uint256, bytes32"), [
op.sender,
BigInt(op.nonce),
(0, viem_1.keccak256)(op.initCode),
(0, viem_1.keccak256)(op.callData),
BigInt(op.callGasLimit),
BigInt(op.verificationGasLimit),
BigInt(op.preVerificationGas),
BigInt(op.maxFeePerGas),
BigInt(op.maxPriorityFeePerGas),
(0, viem_1.keccak256)(op.paymasterAndData),
]);
}
else {
return (0, viem_1.encodeAbiParameters)((0, viem_1.parseAbiParameters)("address, uint256, bytes, bytes, uint256, uint256, uint256, uint256, uint256, bytes, bytes"), [
op.sender,
BigInt(op.nonce),
op.initCode,
op.callData,
BigInt(op.callGasLimit),
BigInt(op.verificationGasLimit),
BigInt(op.preVerificationGas),
BigInt(op.maxFeePerGas),
BigInt(op.maxPriorityFeePerGas),
op.paymasterAndData,
op.signature,
]);
}
}
const getUserOpHash = (userOp, entryPointAddress, chainId) => {
const userOpHash = (0, viem_1.keccak256)(packUserOp(userOp, true));
const enc = (0, viem_1.encodeAbiParameters)((0, viem_1.parseAbiParameters)("bytes32, address, uint256"), [userOpHash, entryPointAddress, BigInt(chainId)]);
return (0, viem_1.keccak256)(enc);
};
exports.getUserOpHash = getUserOpHash;
//# sourceMappingURL=Helper.js.map