UNPKG

@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

22 lines 934 B
import { AccountNotFoundError } from "../../errors/account.js"; import { ChainNotFoundError } from "../../errors/client.js"; import { InvalidUserOperationError } from "../../errors/useroperation.js"; import { deepHexlify, isValidRequest, resolveProperties, } from "../../utils/index.js"; export const defaultUserOpSigner = async (struct, { client, account = client.account }) => { if (!account) { throw new AccountNotFoundError(); } if (!client?.chain) { throw new ChainNotFoundError(); } const resolvedStruct = await resolveProperties(struct); const request = deepHexlify(resolvedStruct); if (!isValidRequest(request)) { throw new InvalidUserOperationError(resolvedStruct); } return { ...resolvedStruct, signature: await account.signUserOperationHash(account.getEntryPoint().getUserOperationHash(request)), }; }; //# sourceMappingURL=userOpSigner.js.map