UNPKG

@owlprotocol/contracts-account-abstraction

Version:

ERC4337 Account Abstraction support for deploying relevant smart contracts and interacting with UserOps.

53 lines (52 loc) 2.1 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var SimpleAccount_exports = {}; __export(SimpleAccount_exports, { getSimpleAccountAddress: () => getSimpleAccountAddress }); module.exports = __toCommonJS(SimpleAccount_exports); var import_viem2 = require("viem"); var import_SimpleAccount = require("./artifacts/SimpleAccount.js"); var import_ERC1967Proxy = require("./artifacts/ERC1967Proxy.js"); var import_constants = require("./constants.js"); function getSimpleAccountAddress(args, options) { const { factoryAddress, proxyBytecode } = options ?? { factoryAddress: import_constants.SIMPLE_ACCOUNT_FACTORY_ADDRESS, proxyBytecode: import_ERC1967Proxy.ERC1967Proxy.bytecode }; const simpleAccountImplementation = (0, import_viem2.getCreateAddress)({ from: factoryAddress, nonce: 1n }); const initData = (0, import_viem2.encodeFunctionData)({ abi: import_SimpleAccount.abi, functionName: "initialize", args: [args.owner] }); const proxyDeployData = (0, import_viem2.encodeDeployData)({ bytecode: proxyBytecode, abi: import_ERC1967Proxy.ERC1967Proxy.abi, args: [simpleAccountImplementation, initData] }); const salt = args.salt ?? 0n; return (0, import_viem2.getCreate2Address)({ from: factoryAddress, salt: (0, import_viem2.numberToBytes)(salt, { size: 32 }), bytecode: proxyDeployData }); }