@alchemy/aa-core
Version:
viem based SDK that enables interactions with ERC-4337 Smart Accounts. ABIs are based off the definitions generated in @account-abstraction/contracts
47 lines • 1.63 kB
JavaScript
import { encodeAbiParameters, hexToBigInt, keccak256, } from "viem";
import { EntryPointAbi_v6 } from "../abis/EntryPointAbi_v6.js";
const packUserOperation = (request) => {
const hashedInitCode = keccak256(request.initCode);
const hashedCallData = keccak256(request.callData);
const hashedPaymasterAndData = keccak256(request.paymasterAndData);
return encodeAbiParameters([
{ type: "address" },
{ type: "uint256" },
{ type: "bytes32" },
{ type: "bytes32" },
{ type: "uint256" },
{ type: "uint256" },
{ type: "uint256" },
{ type: "uint256" },
{ type: "uint256" },
{ type: "bytes32" },
], [
request.sender,
hexToBigInt(request.nonce),
hashedInitCode,
hashedCallData,
hexToBigInt(request.callGasLimit),
hexToBigInt(request.verificationGasLimit),
hexToBigInt(request.preVerificationGas),
hexToBigInt(request.maxFeePerGas),
hexToBigInt(request.maxPriorityFeePerGas),
hashedPaymasterAndData,
]);
};
export default {
version: "0.6.0",
address: {
default: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
},
abi: EntryPointAbi_v6,
getUserOperationHash: (request, entryPointAddress, chainId) => {
const encoded = encodeAbiParameters([{ type: "bytes32" }, { type: "address" }, { type: "uint256" }], [
keccak256(packUserOperation(request)),
entryPointAddress,
BigInt(chainId),
]);
return keccak256(encoded);
},
packUserOperation,
};
//# sourceMappingURL=0.6.js.map