UNPKG

@owlprotocol/contracts-account-abstraction

Version:

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

59 lines (58 loc) 2.13 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 getUserOperationGasPrice_exports = {}; __export(getUserOperationGasPrice_exports, { getUserOperationGasPrice: () => getUserOperationGasPrice }); module.exports = __toCommonJS(getUserOperationGasPrice_exports); var import_actions = require("viem/actions"); var import_utils = require("viem/utils"); async function getUserOperationGasPrice(client) { const eip1559 = client.eip1559 ?? client.chain?.custom?.eip1559 ?? false; const gasPrice = await (0, import_utils.getAction)( client, import_actions.estimateFeesPerGas, "estimateFeesPerGas" )({ type: eip1559 === false ? "legacy" : "eip1559", chain: client.chain }); if (gasPrice.gasPrice) { const userOperationGasPrice = { maxFeePerGas: gasPrice.gasPrice, maxPriorityFeePerGas: gasPrice.gasPrice }; return { slow: userOperationGasPrice, standard: userOperationGasPrice, fast: userOperationGasPrice }; } else if (gasPrice.maxFeePerGas && gasPrice.maxPriorityFeePerGas) { const userOperationGasPrice = { maxFeePerGas: gasPrice.maxFeePerGas, maxPriorityFeePerGas: gasPrice.maxPriorityFeePerGas }; return { slow: userOperationGasPrice, standard: userOperationGasPrice, fast: userOperationGasPrice }; } else { throw new Error("Invalid gas fee estimate"); } }