UNPKG

@owlprotocol/contracts-account-abstraction

Version:

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

482 lines (467 loc) 13.2 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 IStakeManager_exports = {}; __export(IStakeManager_exports, { IStakeManager: () => IStakeManager }); module.exports = __toCommonJS(IStakeManager_exports); const IStakeManager = { compiler: { version: "0.8.23+commit.f704f362" }, language: "Solidity", output: { abi: [ { anonymous: false, inputs: [ { indexed: true, internalType: "address", name: "account", type: "address" }, { indexed: false, internalType: "uint256", name: "totalDeposit", type: "uint256" } ], name: "Deposited", type: "event" }, { anonymous: false, inputs: [ { indexed: true, internalType: "address", name: "account", type: "address" }, { indexed: false, internalType: "uint256", name: "totalStaked", type: "uint256" }, { indexed: false, internalType: "uint256", name: "unstakeDelaySec", type: "uint256" } ], name: "StakeLocked", type: "event" }, { anonymous: false, inputs: [ { indexed: true, internalType: "address", name: "account", type: "address" }, { indexed: false, internalType: "uint256", name: "withdrawTime", type: "uint256" } ], name: "StakeUnlocked", type: "event" }, { anonymous: false, inputs: [ { indexed: true, internalType: "address", name: "account", type: "address" }, { indexed: false, internalType: "address", name: "withdrawAddress", type: "address" }, { indexed: false, internalType: "uint256", name: "amount", type: "uint256" } ], name: "StakeWithdrawn", type: "event" }, { anonymous: false, inputs: [ { indexed: true, internalType: "address", name: "account", type: "address" }, { indexed: false, internalType: "address", name: "withdrawAddress", type: "address" }, { indexed: false, internalType: "uint256", name: "amount", type: "uint256" } ], name: "Withdrawn", type: "event" }, { inputs: [ { internalType: "uint32", name: "_unstakeDelaySec", type: "uint32" } ], name: "addStake", outputs: [], stateMutability: "payable", type: "function" }, { inputs: [ { internalType: "address", name: "account", type: "address" } ], name: "balanceOf", outputs: [ { internalType: "uint256", name: "", type: "uint256" } ], stateMutability: "view", type: "function" }, { inputs: [ { internalType: "address", name: "account", type: "address" } ], name: "depositTo", outputs: [], stateMutability: "payable", type: "function" }, { inputs: [ { internalType: "address", name: "account", type: "address" } ], name: "getDepositInfo", outputs: [ { components: [ { internalType: "uint256", name: "deposit", type: "uint256" }, { internalType: "bool", name: "staked", type: "bool" }, { internalType: "uint112", name: "stake", type: "uint112" }, { internalType: "uint32", name: "unstakeDelaySec", type: "uint32" }, { internalType: "uint48", name: "withdrawTime", type: "uint48" } ], internalType: "struct IStakeManager.DepositInfo", name: "info", type: "tuple" } ], stateMutability: "view", type: "function" }, { inputs: [], name: "unlockStake", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "address payable", name: "withdrawAddress", type: "address" } ], name: "withdrawStake", outputs: [], stateMutability: "nonpayable", type: "function" }, { inputs: [ { internalType: "address payable", name: "withdrawAddress", type: "address" }, { internalType: "uint256", name: "withdrawAmount", type: "uint256" } ], name: "withdrawTo", outputs: [], stateMutability: "nonpayable", type: "function" } ], devdoc: { kind: "dev", methods: { "addStake(uint32)": { params: { _unstakeDelaySec: "- The new lock duration before the deposit can be withdrawn." } }, "balanceOf(address)": { params: { account: "- The account to query." }, returns: { _0: "- The deposit (for gas payment) of the account." } }, "depositTo(address)": { params: { account: "- The account to add to." } }, "getDepositInfo(address)": { params: { account: "- The account to query." }, returns: { info: " - Full deposit information of given account." } }, "withdrawStake(address)": { params: { withdrawAddress: "- The address to send withdrawn value." } }, "withdrawTo(address,uint256)": { params: { withdrawAddress: "- The address to send withdrawn value.", withdrawAmount: "- The amount to withdraw." } } }, version: 1 }, userdoc: { kind: "user", methods: { "addStake(uint32)": { notice: "Add to the account's stake - amount and delay any pending unstake is first cancelled." }, "balanceOf(address)": { notice: "Get account balance." }, "depositTo(address)": { notice: "Add to the deposit of the given account." }, "getDepositInfo(address)": { notice: "Get deposit info." }, "unlockStake()": { notice: "Attempt to unlock the stake. The value can be withdrawn (using withdrawStake) after the unstake delay." }, "withdrawStake(address)": { notice: "Withdraw from the (unlocked) stake. Must first call unlockStake and wait for the unstakeDelay to pass." }, "withdrawTo(address,uint256)": { notice: "Withdraw from the deposit." } }, notice: 'Manage deposits and stakes. Deposit is just a balance used to pay for UserOperations (either by a paymaster or an account). Stake is value locked for at least "unstakeDelay" by the staked entity.', version: 1 } }, settings: { compilationTarget: { "@account-abstraction/contracts/interfaces/IStakeManager.sol": "IStakeManager" }, evmVersion: "paris", libraries: {}, metadata: { bytecodeHash: "ipfs", useLiteralContent: true }, optimizer: { enabled: true, runs: 1e6 }, remappings: [], viaIR: true }, sources: { "@account-abstraction/contracts/interfaces/IStakeManager.sol": { content: `// SPDX-License-Identifier: GPL-3.0-only pragma solidity >=0.7.5; /** * Manage deposits and stakes. * Deposit is just a balance used to pay for UserOperations (either by a paymaster or an account). * Stake is value locked for at least "unstakeDelay" by the staked entity. */ interface IStakeManager { event Deposited(address indexed account, uint256 totalDeposit); event Withdrawn( address indexed account, address withdrawAddress, uint256 amount ); // Emitted when stake or unstake delay are modified. event StakeLocked( address indexed account, uint256 totalStaked, uint256 unstakeDelaySec ); // Emitted once a stake is scheduled for withdrawal. event StakeUnlocked(address indexed account, uint256 withdrawTime); event StakeWithdrawn( address indexed account, address withdrawAddress, uint256 amount ); /** * @param deposit - The entity's deposit. * @param staked - True if this entity is staked. * @param stake - Actual amount of ether staked for this entity. * @param unstakeDelaySec - Minimum delay to withdraw the stake. * @param withdrawTime - First block timestamp where 'withdrawStake' will be callable, or zero if already locked. * @dev Sizes were chosen so that deposit fits into one cell (used during handleOp) * and the rest fit into a 2nd cell (used during stake/unstake) * - 112 bit allows for 10^15 eth * - 48 bit for full timestamp * - 32 bit allows 150 years for unstake delay */ struct DepositInfo { uint256 deposit; bool staked; uint112 stake; uint32 unstakeDelaySec; uint48 withdrawTime; } // API struct used by getStakeInfo and simulateValidation. struct StakeInfo { uint256 stake; uint256 unstakeDelaySec; } /** * Get deposit info. * @param account - The account to query. * @return info - Full deposit information of given account. */ function getDepositInfo( address account ) external view returns (DepositInfo memory info); /** * Get account balance. * @param account - The account to query. * @return - The deposit (for gas payment) of the account. */ function balanceOf(address account) external view returns (uint256); /** * Add to the deposit of the given account. * @param account - The account to add to. */ function depositTo(address account) external payable; /** * Add to the account's stake - amount and delay * any pending unstake is first cancelled. * @param _unstakeDelaySec - The new lock duration before the deposit can be withdrawn. */ function addStake(uint32 _unstakeDelaySec) external payable; /** * Attempt to unlock the stake. * The value can be withdrawn (using withdrawStake) after the unstake delay. */ function unlockStake() external; /** * Withdraw from the (unlocked) stake. * Must first call unlockStake and wait for the unstakeDelay to pass. * @param withdrawAddress - The address to send withdrawn value. */ function withdrawStake(address payable withdrawAddress) external; /** * Withdraw from the deposit. * @param withdrawAddress - The address to send withdrawn value. * @param withdrawAmount - The amount to withdraw. */ function withdrawTo( address payable withdrawAddress, uint256 withdrawAmount ) external; } `, keccak256: "0xbe5ca9e7f254d031687419e7b96ef48c9c63e9398bbe992dc72ffc6dc14e0a04", license: "GPL-3.0-only" } }, version: 1 };