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

53 lines 2.16 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getEntryPoint = exports.isEntryPointVersion = exports.entryPointRegistry = exports.defaultEntryPointVersion = void 0; const entrypoint_js_1 = require("../errors/entrypoint.js"); const _0_6_js_1 = __importDefault(require("./0.6.js")); const _0_7_js_1 = __importDefault(require("./0.7.js")); exports.defaultEntryPointVersion = "0.6.0"; exports.entryPointRegistry = { "0.6.0": _0_6_js_1.default, "0.7.0": _0_7_js_1.default, }; const isEntryPointVersion = (value) => { return Object.keys(exports.entryPointRegistry).includes(value); }; exports.isEntryPointVersion = isEntryPointVersion; function getEntryPoint(chain, options) { const { version = exports.defaultEntryPointVersion, addressOverride } = options ?? { version: exports.defaultEntryPointVersion, }; const entryPoint = exports.entryPointRegistry[version ?? exports.defaultEntryPointVersion]; const address = addressOverride ?? entryPoint.address[chain.id] ?? entryPoint.address.default; if (!address) { throw new entrypoint_js_1.EntryPointNotFoundError(chain, version); } if (entryPoint.version === "0.6.0") { return { version: entryPoint.version, address, chain, abi: entryPoint.abi, getUserOperationHash: (r) => entryPoint.getUserOperationHash(r, address, chain.id), packUserOperation: entryPoint.packUserOperation, }; } else if (entryPoint.version === "0.7.0") { return { version: entryPoint.version, address, chain, abi: entryPoint.abi, getUserOperationHash: (r) => entryPoint.getUserOperationHash(r, address, chain.id), packUserOperation: entryPoint.packUserOperation, }; } throw new entrypoint_js_1.EntryPointNotFoundError(chain, version); } exports.getEntryPoint = getEntryPoint; //# sourceMappingURL=index.js.map