diff --git a/DEPLOYMENTS.md b/DEPLOYMENTS.md index 8e24538..75c830a 100644 --- a/DEPLOYMENTS.md +++ b/DEPLOYMENTS.md @@ -159,3 +159,4 @@ | `EtherspotWallet` | `mantleSepolia` | [0xfB32cef50CfB0A0F9f6d37A05828b2F56EfdfE20](https://explorer.sepolia.mantle.xyz/address/0xfB32cef50CfB0A0F9f6d37A05828b2F56EfdfE20) | [0x1b3172f91340874c9878e9ab9c191fadb4090a33c27536f2c338542195735e9a](https://explorer.sepolia.mantle.xyz/tx/0x1b3172f91340874c9878e9ab9c191fadb4090a33c27536f2c338542195735e9a) | | `VerifyingPaymaster` | `mantleSepolia` | [0x42963C58DE382D34CB5a7f77b703e645FcE6DD26](https://explorer.sepolia.mantle.xyz/address/0x42963C58DE382D34CB5a7f77b703e645FcE6DD26) | [0x61660cc6345b39f80c5033857affeee48ee18771fd4e497b12d7d4eba29647fa](https://explorer.sepolia.mantle.xyz/tx/0x61660cc6345b39f80c5033857affeee48ee18771fd4e497b12d7d4eba29647fa) | | `VerifyingPaymaster` | `xdcApothem` | [0x2b7cBFA523E0D0546C6d1F706b79dB7B6d910bdA]() | [0xb461afbbd90ab7f43c1fa9e4d8bb0a70587854a87aa04bef5253599ba53071ca]() | +| `VerifyingPaymaster` | `suaveToliman` | [0x898c530A5fA37720DcF1843AeCC34b6B0cBaEB8a](https://explorer.toliman.suave.flashbots.net/address/0x898c530A5fA37720DcF1843AeCC34b6B0cBaEB8a) | [0xd4452631f3d6cde65b5a475a34a8b4691bc03fb01f38a3f42ac067667e066a31](https://explorer.toliman.suave.flashbots.net/tx/0xd4452631f3d6cde65b5a475a34a8b4691bc03fb01f38a3f42ac067667e066a31) | diff --git a/config/etherscan.ts b/config/etherscan.ts index f4ab341..c647181 100644 --- a/config/etherscan.ts +++ b/config/etherscan.ts @@ -44,6 +44,7 @@ const etherscan: HardhatUserConfig['etherscan'] = { amoy: process.env.POLYSCAN_API_KEY!, mantleSepolia: process.env.BASEGOERLI_BLOCKSCOUT_API_KEY!, // works with same key xdcApothem: process.env.XDC_API_KEY!, + suaveToliman: process.env.BASEGOERLI_BLOCKSCOUT_API_KEY!, // works with same key }, customChains: [ { @@ -274,10 +275,18 @@ const etherscan: HardhatUserConfig['etherscan'] = { network: 'odyssey', chainId: 911867, urls: { - apiURL: "https://odyssey-explorer.ithaca.xyz/api", - browserURL: "https://odyssey-explorer.ithaca.xyz/" - } - } + apiURL: 'https://odyssey-explorer.ithaca.xyz/api', + browserURL: 'https://odyssey-explorer.ithaca.xyz/', + }, + }, + { + network: 'suaveToliman', + chainId: 33626250, + urls: { + apiURL: 'https://explorer.toliman.suave.flashbots.net/api', + browserURL: 'https://explorer.toliman.suave.flashbots.net/', + }, + }, ], }; diff --git a/config/networks.ts b/config/networks.ts index b321c67..de6ee25 100644 --- a/config/networks.ts +++ b/config/networks.ts @@ -238,6 +238,11 @@ const networks: HardhatUserConfig['networks'] = { url: 'https://odyssey.ithaca.xyz', accounts: [process.env.DEPLOYER_PRIVATE_KEY!], }, + suaveToliman: { + chainId: 33626250, + url: 'https://rpc.toliman.suave.flashbots.net', + accounts: [process.env.DEPLOYER_PRIVATE_KEY!], + }, dev: { url: 'http://localhost:8545' }, }; export default networks; diff --git a/deploy/011_verify_verifying_paymaster.ts b/deploy/011_verify_verifying_paymaster.ts index 352afb2..8953cb5 100644 --- a/deploy/011_verify_verifying_paymaster.ts +++ b/deploy/011_verify_verifying_paymaster.ts @@ -12,8 +12,7 @@ const verifyVerifyingPaymaster: DeployFunction = async function ( await hre.run('verify:verify', { address: PAYMASTER_ADDRESS, - contract: - 'src/etherspot-wallet-v1/paymaster/VerifyingPaymaster.sol:VerifyingPaymaster', + contract: 'src/paymaster/VerifyingPaymaster.sol:VerifyingPaymaster', constructorArguments: [ENTRY_POINT_ADDRESS, VERIFYING_SIGNER_ADDRESS], }); }; diff --git a/deployments/suaveToliman/.chainId b/deployments/suaveToliman/.chainId new file mode 100644 index 0000000..f3f9808 --- /dev/null +++ b/deployments/suaveToliman/.chainId @@ -0,0 +1 @@ +33626250 \ No newline at end of file diff --git a/deployments/suaveToliman/VerifyingPaymaster.json b/deployments/suaveToliman/VerifyingPaymaster.json new file mode 100644 index 0000000..a7265d6 --- /dev/null +++ b/deployments/suaveToliman/VerifyingPaymaster.json @@ -0,0 +1,637 @@ +{ + "address": "0x898c530A5fA37720DcF1843AeCC34b6B0cBaEB8a", + "abi": [ + { + "inputs": [ + { + "internalType": "contract IEntryPoint", + "name": "_entryPoint", + "type": "address" + }, + { + "internalType": "address", + "name": "_verifyingSigner", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "ECDSAInvalidSignature", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "length", + "type": "uint256" + } + ], + "name": "ECDSAInvalidSignatureLength", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "ECDSAInvalidSignatureS", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "OwnableInvalidOwner", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "OwnableUnauthorizedAccount", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "newVerifyingSigner", + "type": "address" + } + ], + "name": "VerifyingSignerUpdated", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "uint32", + "name": "unstakeDelaySec", + "type": "uint32" + } + ], + "name": "addStake", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "deposit", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "entryPoint", + "outputs": [ + { + "internalType": "contract IEntryPoint", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getDeposit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "initCode", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "callData", + "type": "bytes" + }, + { + "internalType": "bytes32", + "name": "accountGasLimits", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "preVerificationGas", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "gasFees", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "paymasterAndData", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + } + ], + "internalType": "struct PackedUserOperation", + "name": "userOp", + "type": "tuple" + }, + { + "internalType": "uint48", + "name": "validUntil", + "type": "uint48" + }, + { + "internalType": "uint48", + "name": "validAfter", + "type": "uint48" + } + ], + "name": "getHash", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "paymasterAndData", + "type": "bytes" + } + ], + "name": "parsePaymasterAndData", + "outputs": [ + { + "internalType": "uint48", + "name": "validUntil", + "type": "uint48" + }, + { + "internalType": "uint48", + "name": "validAfter", + "type": "uint48" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "enum IPaymaster.PostOpMode", + "name": "mode", + "type": "uint8" + }, + { + "internalType": "bytes", + "name": "context", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "actualGasCost", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "actualUserOpFeePerGas", + "type": "uint256" + } + ], + "name": "postOp", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "unlockStake", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_newVerifyingSigner", + "type": "address" + } + ], + "name": "updateVerifyingSigner", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "initCode", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "callData", + "type": "bytes" + }, + { + "internalType": "bytes32", + "name": "accountGasLimits", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "preVerificationGas", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "gasFees", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "paymasterAndData", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + } + ], + "internalType": "struct PackedUserOperation", + "name": "userOp", + "type": "tuple" + }, + { + "internalType": "bytes32", + "name": "userOpHash", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "maxCost", + "type": "uint256" + } + ], + "name": "validatePaymasterUserOp", + "outputs": [ + { + "internalType": "bytes", + "name": "context", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "validationData", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "verifyingSigner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "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": "amount", + "type": "uint256" + } + ], + "name": "withdrawTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } + ], + "transactionHash": "0xd4452631f3d6cde65b5a475a34a8b4691bc03fb01f38a3f42ac067667e066a31", + "receipt": { + "to": null, + "from": "0x09FD4F6088f2025427AB1e89257A44747081Ed59", + "contractAddress": "0x898c530A5fA37720DcF1843AeCC34b6B0cBaEB8a", + "transactionIndex": 1, + "gasUsed": "1081672", + "logsBloom": "0x00000000000000000000000000000000000000000008000000800000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000100000000000001000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000400000000000000000000000000000000004000000000004000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0xdc32bb49106a683cd0dea0e98eb6938db84368c3ecc8d2ea57aa7dfa7ee21d3b", + "transactionHash": "0xd4452631f3d6cde65b5a475a34a8b4691bc03fb01f38a3f42ac067667e066a31", + "logs": [ + { + "transactionIndex": 1, + "blockNumber": 5206004, + "transactionHash": "0xd4452631f3d6cde65b5a475a34a8b4691bc03fb01f38a3f42ac067667e066a31", + "address": "0x898c530A5fA37720DcF1843AeCC34b6B0cBaEB8a", + "topics": [ + "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", + "0x0000000000000000000000000000000000000000000000000000000000000000", + "0x00000000000000000000000009fd4f6088f2025427ab1e89257a44747081ed59" + ], + "data": "0x", + "logIndex": 0, + "blockHash": "0xdc32bb49106a683cd0dea0e98eb6938db84368c3ecc8d2ea57aa7dfa7ee21d3b" + } + ], + "blockNumber": 5206004, + "cumulativeGasUsed": "1102672", + "status": 1, + "byzantium": true + }, + "args": [ + "0xe1078568F094308749AE9833ba8160b9E8bd909f", + "0x09FD4F6088f2025427AB1e89257A44747081Ed59" + ], + "numDeployments": 1, + "solcInputHash": "d3577e83208e9ea218cee1e51dba2e35", + "metadata": "{\"compiler\":{\"version\":\"0.8.23+commit.f704f362\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[{\"internalType\":\"contract IEntryPoint\",\"name\":\"_entryPoint\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_verifyingSigner\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"ECDSAInvalidSignature\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"length\",\"type\":\"uint256\"}],\"name\":\"ECDSAInvalidSignatureLength\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"name\":\"ECDSAInvalidSignatureS\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"OwnableInvalidOwner\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"OwnableUnauthorizedAccount\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newVerifyingSigner\",\"type\":\"address\"}],\"name\":\"VerifyingSignerUpdated\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"unstakeDelaySec\",\"type\":\"uint32\"}],\"name\":\"addStake\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"deposit\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"entryPoint\",\"outputs\":[{\"internalType\":\"contract IEntryPoint\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getDeposit\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"initCode\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"callData\",\"type\":\"bytes\"},{\"internalType\":\"bytes32\",\"name\":\"accountGasLimits\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"preVerificationGas\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"gasFees\",\"type\":\"bytes32\"},{\"internalType\":\"bytes\",\"name\":\"paymasterAndData\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"signature\",\"type\":\"bytes\"}],\"internalType\":\"struct PackedUserOperation\",\"name\":\"userOp\",\"type\":\"tuple\"},{\"internalType\":\"uint48\",\"name\":\"validUntil\",\"type\":\"uint48\"},{\"internalType\":\"uint48\",\"name\":\"validAfter\",\"type\":\"uint48\"}],\"name\":\"getHash\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"paymasterAndData\",\"type\":\"bytes\"}],\"name\":\"parsePaymasterAndData\",\"outputs\":[{\"internalType\":\"uint48\",\"name\":\"validUntil\",\"type\":\"uint48\"},{\"internalType\":\"uint48\",\"name\":\"validAfter\",\"type\":\"uint48\"},{\"internalType\":\"bytes\",\"name\":\"signature\",\"type\":\"bytes\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"enum IPaymaster.PostOpMode\",\"name\":\"mode\",\"type\":\"uint8\"},{\"internalType\":\"bytes\",\"name\":\"context\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"actualGasCost\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"actualUserOpFeePerGas\",\"type\":\"uint256\"}],\"name\":\"postOp\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"unlockStake\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_newVerifyingSigner\",\"type\":\"address\"}],\"name\":\"updateVerifyingSigner\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"nonce\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"initCode\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"callData\",\"type\":\"bytes\"},{\"internalType\":\"bytes32\",\"name\":\"accountGasLimits\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"preVerificationGas\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"gasFees\",\"type\":\"bytes32\"},{\"internalType\":\"bytes\",\"name\":\"paymasterAndData\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"signature\",\"type\":\"bytes\"}],\"internalType\":\"struct PackedUserOperation\",\"name\":\"userOp\",\"type\":\"tuple\"},{\"internalType\":\"bytes32\",\"name\":\"userOpHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"maxCost\",\"type\":\"uint256\"}],\"name\":\"validatePaymasterUserOp\",\"outputs\":[{\"internalType\":\"bytes\",\"name\":\"context\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"validationData\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"verifyingSigner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"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\":\"amount\",\"type\":\"uint256\"}],\"name\":\"withdrawTo\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"errors\":{\"ECDSAInvalidSignature()\":[{\"details\":\"The signature derives the `address(0)`.\"}],\"ECDSAInvalidSignatureLength(uint256)\":[{\"details\":\"The signature has an invalid length.\"}],\"ECDSAInvalidSignatureS(bytes32)\":[{\"details\":\"The signature has an S value that is in the upper half order.\"}],\"OwnableInvalidOwner(address)\":[{\"details\":\"The owner is not a valid owner account. (eg. `address(0)`)\"}],\"OwnableUnauthorizedAccount(address)\":[{\"details\":\"The caller account is not authorized to perform an operation.\"}]},\"kind\":\"dev\",\"methods\":{\"addStake(uint32)\":{\"params\":{\"unstakeDelaySec\":\"- The unstake delay for this paymaster. Can only be increased.\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"postOp(uint8,bytes,uint256,uint256)\":{\"params\":{\"actualGasCost\":\"- Actual gas used so far (without this postOp call).\",\"actualUserOpFeePerGas\":\"- the gas price this UserOp pays. This value is based on the UserOp's maxFeePerGas and maxPriorityFee (and basefee) It is not the same as tx.gasprice, which is what the bundler pays.\",\"context\":\"- The context value returned by validatePaymasterUserOp\",\"mode\":\"- Enum with the following options: opSucceeded - User operation succeeded. opReverted - User op reverted. The paymaster still has to pay for gas. postOpReverted - never passed in a call to postOp().\"}},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner.\"},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"},\"validatePaymasterUserOp((address,uint256,bytes,bytes,bytes32,uint256,bytes32,bytes,bytes),bytes32,uint256)\":{\"params\":{\"maxCost\":\"- The maximum cost of this transaction (based on maximum gas and gas price from userOp).\",\"userOp\":\"- The user operation.\",\"userOpHash\":\"- Hash of the user's request data.\"},\"returns\":{\"context\":\" - Value to send to a postOp. Zero length to signify postOp is not required.\",\"validationData\":\"- Signature and time-range of this operation, encoded the same as the return value of validateUserOperation. <20-byte> sigAuthorizer - 0 for valid signature, 1 to mark signature failure, other values are invalid for paymaster. <6-byte> validUntil - last timestamp this operation is valid. 0 for \\\"indefinite\\\" <6-byte> validAfter - first timestamp this operation is valid Note that the validation code cannot use block.timestamp (or block.number) directly.\"}},\"withdrawStake(address)\":{\"params\":{\"withdrawAddress\":\"- The address to send withdrawn value.\"}},\"withdrawTo(address,uint256)\":{\"params\":{\"amount\":\"- Amount to withdraw.\",\"withdrawAddress\":\"- Target to send to.\"}}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{\"addStake(uint32)\":{\"notice\":\"Add stake for this paymaster. This method can also carry eth value to add to the current stake.\"},\"deposit()\":{\"notice\":\"Add a deposit for this paymaster, used for paying for transaction fees.\"},\"getDeposit()\":{\"notice\":\"Return current paymaster's deposit on the entryPoint.\"},\"getHash((address,uint256,bytes,bytes,bytes32,uint256,bytes32,bytes,bytes),uint48,uint48)\":{\"notice\":\"return the hash we're going to sign off-chain (and validate on-chain) this method is called by the off-chain service, to sign the request. it is called on-chain from the validatePaymasterUserOp, to validate the signature. note that this signature covers all fields of the UserOperation, except the \\\"paymasterAndData\\\", which will carry the signature itself.\"},\"postOp(uint8,bytes,uint256,uint256)\":{\"notice\":\"Post-operation handler. Must verify sender is the entryPoint.\"},\"unlockStake()\":{\"notice\":\"Unlock the stake, in order to withdraw it. The paymaster can't serve requests once unlocked, until it calls addStake again\"},\"validatePaymasterUserOp((address,uint256,bytes,bytes,bytes32,uint256,bytes32,bytes,bytes),bytes32,uint256)\":{\"notice\":\"Payment validation: check if paymaster agrees to pay. Must verify sender is the entryPoint. Revert to reject this request. Note that bundlers will reject this method if it changes the state, unless the paymaster is trusted (whitelisted). The paymaster pre-pays using its deposit, and receive back a refund after the postOp method returns.\"},\"withdrawStake(address)\":{\"notice\":\"Withdraw the entire paymaster's stake. stake must be unlocked first (and then wait for the unstakeDelay to be over)\"},\"withdrawTo(address,uint256)\":{\"notice\":\"Withdraw value from the deposit.\"}},\"notice\":\"A sample paymaster that uses external service to decide whether to pay for the UserOp. The paymaster trusts an external signer to sign the transaction. The calling user must pass the UserOp to that external signer first, which performs whatever off-chain verification before signing the UserOp. Note that this signature is NOT a replacement for the account-specific signature: - the paymaster checks a signature to agree to PAY for GAS. - the account checks a signature to prove identity and account ownership.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"src/paymaster/VerifyingPaymaster.sol\":\"VerifyingPaymaster\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\",\"useLiteralContent\":true},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[]},\"sources\":{\"@openzeppelin/contracts/access/Ownable.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {Context} from \\\"../utils/Context.sol\\\";\\n\\n/**\\n * @dev Contract module which provides a basic access control mechanism, where\\n * there is an account (an owner) that can be granted exclusive access to\\n * specific functions.\\n *\\n * The initial owner is set to the address provided by the deployer. This can\\n * later be changed with {transferOwnership}.\\n *\\n * This module is used through inheritance. It will make available the modifier\\n * `onlyOwner`, which can be applied to your functions to restrict their use to\\n * the owner.\\n */\\nabstract contract Ownable is Context {\\n address private _owner;\\n\\n /**\\n * @dev The caller account is not authorized to perform an operation.\\n */\\n error OwnableUnauthorizedAccount(address account);\\n\\n /**\\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\\n */\\n error OwnableInvalidOwner(address owner);\\n\\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\\n\\n /**\\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\\n */\\n constructor(address initialOwner) {\\n if (initialOwner == address(0)) {\\n revert OwnableInvalidOwner(address(0));\\n }\\n _transferOwnership(initialOwner);\\n }\\n\\n /**\\n * @dev Throws if called by any account other than the owner.\\n */\\n modifier onlyOwner() {\\n _checkOwner();\\n _;\\n }\\n\\n /**\\n * @dev Returns the address of the current owner.\\n */\\n function owner() public view virtual returns (address) {\\n return _owner;\\n }\\n\\n /**\\n * @dev Throws if the sender is not the owner.\\n */\\n function _checkOwner() internal view virtual {\\n if (owner() != _msgSender()) {\\n revert OwnableUnauthorizedAccount(_msgSender());\\n }\\n }\\n\\n /**\\n * @dev Leaves the contract without owner. It will not be possible to call\\n * `onlyOwner` functions. Can only be called by the current owner.\\n *\\n * NOTE: Renouncing ownership will leave the contract without an owner,\\n * thereby disabling any functionality that is only available to the owner.\\n */\\n function renounceOwnership() public virtual onlyOwner {\\n _transferOwnership(address(0));\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Can only be called by the current owner.\\n */\\n function transferOwnership(address newOwner) public virtual onlyOwner {\\n if (newOwner == address(0)) {\\n revert OwnableInvalidOwner(address(0));\\n }\\n _transferOwnership(newOwner);\\n }\\n\\n /**\\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\\n * Internal function without access restriction.\\n */\\n function _transferOwnership(address newOwner) internal virtual {\\n address oldOwner = _owner;\\n _owner = newOwner;\\n emit OwnershipTransferred(oldOwner, newOwner);\\n }\\n}\\n\",\"keccak256\":\"0xff6d0bb2e285473e5311d9d3caacb525ae3538a80758c10649a4d61029b017bb\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Context.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Context.sol)\\n\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Provides information about the current execution context, including the\\n * sender of the transaction and its data. While these are generally available\\n * via msg.sender and msg.data, they should not be accessed in such a direct\\n * manner, since when dealing with meta-transactions the account sending and\\n * paying for execution may not be the actual sender (as far as an application\\n * is concerned).\\n *\\n * This contract is only required for intermediate, library-like contracts.\\n */\\nabstract contract Context {\\n function _msgSender() internal view virtual returns (address) {\\n return msg.sender;\\n }\\n\\n function _msgData() internal view virtual returns (bytes calldata) {\\n return msg.data;\\n }\\n}\\n\",\"keccak256\":\"0x75a4ee64c68dbd5f38bddd06e664a64c8271b4caa554fb6f0607dfd672bb4bf3\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/Strings.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {Math} from \\\"./math/Math.sol\\\";\\nimport {SignedMath} from \\\"./math/SignedMath.sol\\\";\\n\\n/**\\n * @dev String operations.\\n */\\nlibrary Strings {\\n bytes16 private constant HEX_DIGITS = \\\"0123456789abcdef\\\";\\n uint8 private constant ADDRESS_LENGTH = 20;\\n\\n /**\\n * @dev The `value` string doesn't fit in the specified `length`.\\n */\\n error StringsInsufficientHexLength(uint256 value, uint256 length);\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\\n */\\n function toString(uint256 value) internal pure returns (string memory) {\\n unchecked {\\n uint256 length = Math.log10(value) + 1;\\n string memory buffer = new string(length);\\n uint256 ptr;\\n /// @solidity memory-safe-assembly\\n assembly {\\n ptr := add(buffer, add(32, length))\\n }\\n while (true) {\\n ptr--;\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))\\n }\\n value /= 10;\\n if (value == 0) break;\\n }\\n return buffer;\\n }\\n }\\n\\n /**\\n * @dev Converts a `int256` to its ASCII `string` decimal representation.\\n */\\n function toStringSigned(int256 value) internal pure returns (string memory) {\\n return string.concat(value < 0 ? \\\"-\\\" : \\\"\\\", toString(SignedMath.abs(value)));\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\\n */\\n function toHexString(uint256 value) internal pure returns (string memory) {\\n unchecked {\\n return toHexString(value, Math.log256(value) + 1);\\n }\\n }\\n\\n /**\\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\\n */\\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\\n uint256 localValue = value;\\n bytes memory buffer = new bytes(2 * length + 2);\\n buffer[0] = \\\"0\\\";\\n buffer[1] = \\\"x\\\";\\n for (uint256 i = 2 * length + 1; i > 1; --i) {\\n buffer[i] = HEX_DIGITS[localValue & 0xf];\\n localValue >>= 4;\\n }\\n if (localValue != 0) {\\n revert StringsInsufficientHexLength(value, length);\\n }\\n return string(buffer);\\n }\\n\\n /**\\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal\\n * representation.\\n */\\n function toHexString(address addr) internal pure returns (string memory) {\\n return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);\\n }\\n\\n /**\\n * @dev Returns true if the two strings are equal.\\n */\\n function equal(string memory a, string memory b) internal pure returns (bool) {\\n return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));\\n }\\n}\\n\",\"keccak256\":\"0x55f102ea785d8399c0e58d1108e2d289506dde18abc6db1b7f68c1f9f9bc5792\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/ECDSA.sol)\\n\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\\n *\\n * These functions can be used to verify that a message was signed by the holder\\n * of the private keys of a given address.\\n */\\nlibrary ECDSA {\\n enum RecoverError {\\n NoError,\\n InvalidSignature,\\n InvalidSignatureLength,\\n InvalidSignatureS\\n }\\n\\n /**\\n * @dev The signature derives the `address(0)`.\\n */\\n error ECDSAInvalidSignature();\\n\\n /**\\n * @dev The signature has an invalid length.\\n */\\n error ECDSAInvalidSignatureLength(uint256 length);\\n\\n /**\\n * @dev The signature has an S value that is in the upper half order.\\n */\\n error ECDSAInvalidSignatureS(bytes32 s);\\n\\n /**\\n * @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not\\n * return address(0) without also returning an error description. Errors are documented using an enum (error type)\\n * and a bytes32 providing additional information about the error.\\n *\\n * If no error is returned, then the address can be used for verification purposes.\\n *\\n * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:\\n * this function rejects them by requiring the `s` value to be in the lower\\n * half order, and the `v` value to be either 27 or 28.\\n *\\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\\n * verification to be secure: it is possible to craft signatures that\\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\\n * this is by receiving a hash of the original message (which may otherwise\\n * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.\\n *\\n * Documentation for signature generation:\\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\\n */\\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError, bytes32) {\\n if (signature.length == 65) {\\n bytes32 r;\\n bytes32 s;\\n uint8 v;\\n // ecrecover takes the signature parameters, and the only way to get them\\n // currently is to use assembly.\\n /// @solidity memory-safe-assembly\\n assembly {\\n r := mload(add(signature, 0x20))\\n s := mload(add(signature, 0x40))\\n v := byte(0, mload(add(signature, 0x60)))\\n }\\n return tryRecover(hash, v, r, s);\\n } else {\\n return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length));\\n }\\n }\\n\\n /**\\n * @dev Returns the address that signed a hashed message (`hash`) with\\n * `signature`. This address can then be used for verification purposes.\\n *\\n * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:\\n * this function rejects them by requiring the `s` value to be in the lower\\n * half order, and the `v` value to be either 27 or 28.\\n *\\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\\n * verification to be secure: it is possible to craft signatures that\\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\\n * this is by receiving a hash of the original message (which may otherwise\\n * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.\\n */\\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\\n (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature);\\n _throwError(error, errorArg);\\n return recovered;\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\\n *\\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\\n */\\n function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError, bytes32) {\\n unchecked {\\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\\n // We do not check for an overflow here since the shift operation results in 0 or 1.\\n uint8 v = uint8((uint256(vs) >> 255) + 27);\\n return tryRecover(hash, v, r, s);\\n }\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\\n */\\n function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {\\n (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs);\\n _throwError(error, errorArg);\\n return recovered;\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\\n * `r` and `s` signature fields separately.\\n */\\n function tryRecover(\\n bytes32 hash,\\n uint8 v,\\n bytes32 r,\\n bytes32 s\\n ) internal pure returns (address, RecoverError, bytes32) {\\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\\n // the valid range for s in (301): 0 < s < secp256k1n \\u00f7 2 + 1, and for v in (302): v \\u2208 {27, 28}. Most\\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\\n //\\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\\n // these malleable signatures as well.\\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\\n return (address(0), RecoverError.InvalidSignatureS, s);\\n }\\n\\n // If the signature is valid (and not malleable), return the signer address\\n address signer = ecrecover(hash, v, r, s);\\n if (signer == address(0)) {\\n return (address(0), RecoverError.InvalidSignature, bytes32(0));\\n }\\n\\n return (signer, RecoverError.NoError, bytes32(0));\\n }\\n\\n /**\\n * @dev Overload of {ECDSA-recover} that receives the `v`,\\n * `r` and `s` signature fields separately.\\n */\\n function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {\\n (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s);\\n _throwError(error, errorArg);\\n return recovered;\\n }\\n\\n /**\\n * @dev Optionally reverts with the corresponding custom error according to the `error` argument provided.\\n */\\n function _throwError(RecoverError error, bytes32 errorArg) private pure {\\n if (error == RecoverError.NoError) {\\n return; // no error: do nothing\\n } else if (error == RecoverError.InvalidSignature) {\\n revert ECDSAInvalidSignature();\\n } else if (error == RecoverError.InvalidSignatureLength) {\\n revert ECDSAInvalidSignatureLength(uint256(errorArg));\\n } else if (error == RecoverError.InvalidSignatureS) {\\n revert ECDSAInvalidSignatureS(errorArg);\\n }\\n }\\n}\\n\",\"keccak256\":\"0xeed0a08b0b091f528356cbc7245891a4c748682d4f6a18055e8e6ca77d12a6cf\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MessageHashUtils.sol)\\n\\npragma solidity ^0.8.20;\\n\\nimport {Strings} from \\\"../Strings.sol\\\";\\n\\n/**\\n * @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing.\\n *\\n * The library provides methods for generating a hash of a message that conforms to the\\n * https://eips.ethereum.org/EIPS/eip-191[EIP 191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712]\\n * specifications.\\n */\\nlibrary MessageHashUtils {\\n /**\\n * @dev Returns the keccak256 digest of an EIP-191 signed data with version\\n * `0x45` (`personal_sign` messages).\\n *\\n * The digest is calculated by prefixing a bytes32 `messageHash` with\\n * `\\\"\\\\x19Ethereum Signed Message:\\\\n32\\\"` and hashing the result. It corresponds with the\\n * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.\\n *\\n * NOTE: The `messageHash` parameter is intended to be the result of hashing a raw message with\\n * keccak256, although any bytes32 value can be safely used because the final digest will\\n * be re-hashed.\\n *\\n * See {ECDSA-recover}.\\n */\\n function toEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32 digest) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n mstore(0x00, \\\"\\\\x19Ethereum Signed Message:\\\\n32\\\") // 32 is the bytes-length of messageHash\\n mstore(0x1c, messageHash) // 0x1c (28) is the length of the prefix\\n digest := keccak256(0x00, 0x3c) // 0x3c is the length of the prefix (0x1c) + messageHash (0x20)\\n }\\n }\\n\\n /**\\n * @dev Returns the keccak256 digest of an EIP-191 signed data with version\\n * `0x45` (`personal_sign` messages).\\n *\\n * The digest is calculated by prefixing an arbitrary `message` with\\n * `\\\"\\\\x19Ethereum Signed Message:\\\\n\\\" + len(message)` and hashing the result. It corresponds with the\\n * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.\\n *\\n * See {ECDSA-recover}.\\n */\\n function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32) {\\n return\\n keccak256(bytes.concat(\\\"\\\\x19Ethereum Signed Message:\\\\n\\\", bytes(Strings.toString(message.length)), message));\\n }\\n\\n /**\\n * @dev Returns the keccak256 digest of an EIP-191 signed data with version\\n * `0x00` (data with intended validator).\\n *\\n * The digest is calculated by prefixing an arbitrary `data` with `\\\"\\\\x19\\\\x00\\\"` and the intended\\n * `validator` address. Then hashing the result.\\n *\\n * See {ECDSA-recover}.\\n */\\n function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {\\n return keccak256(abi.encodePacked(hex\\\"19_00\\\", validator, data));\\n }\\n\\n /**\\n * @dev Returns the keccak256 digest of an EIP-712 typed data (EIP-191 version `0x01`).\\n *\\n * The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with\\n * `\\\\x19\\\\x01` and hashing the result. It corresponds to the hash signed by the\\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712.\\n *\\n * See {ECDSA-recover}.\\n */\\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) {\\n /// @solidity memory-safe-assembly\\n assembly {\\n let ptr := mload(0x40)\\n mstore(ptr, hex\\\"19_01\\\")\\n mstore(add(ptr, 0x02), domainSeparator)\\n mstore(add(ptr, 0x22), structHash)\\n digest := keccak256(ptr, 0x42)\\n }\\n }\\n}\\n\",\"keccak256\":\"0xba333517a3add42cd35fe877656fc3dfcc9de53baa4f3aabbd6d12a92e4ea435\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/introspection/IERC165.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\\n\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Interface of the ERC165 standard, as defined in the\\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\\n *\\n * Implementers can declare support of contract interfaces, which can then be\\n * queried by others ({ERC165Checker}).\\n *\\n * For an implementation, see {ERC165}.\\n */\\ninterface IERC165 {\\n /**\\n * @dev Returns true if this contract implements the interface defined by\\n * `interfaceId`. See the corresponding\\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\\n * to learn more about how these ids are created.\\n *\\n * This function call must use less than 30 000 gas.\\n */\\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\\n}\\n\",\"keccak256\":\"0x4296879f55019b23e135000eb36896057e7101fb7fb859c5ef690cf14643757b\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/Math.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)\\n\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Standard math utilities missing in the Solidity language.\\n */\\nlibrary Math {\\n /**\\n * @dev Muldiv operation overflow.\\n */\\n error MathOverflowedMulDiv();\\n\\n enum Rounding {\\n Floor, // Toward negative infinity\\n Ceil, // Toward positive infinity\\n Trunc, // Toward zero\\n Expand // Away from zero\\n }\\n\\n /**\\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\\n */\\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n uint256 c = a + b;\\n if (c < a) return (false, 0);\\n return (true, c);\\n }\\n }\\n\\n /**\\n * @dev Returns the subtraction of two unsigned integers, with an overflow flag.\\n */\\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n if (b > a) return (false, 0);\\n return (true, a - b);\\n }\\n }\\n\\n /**\\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\\n */\\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\\n // benefit is lost if 'b' is also tested.\\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\\n if (a == 0) return (true, 0);\\n uint256 c = a * b;\\n if (c / a != b) return (false, 0);\\n return (true, c);\\n }\\n }\\n\\n /**\\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\\n */\\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a / b);\\n }\\n }\\n\\n /**\\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\\n */\\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\\n unchecked {\\n if (b == 0) return (false, 0);\\n return (true, a % b);\\n }\\n }\\n\\n /**\\n * @dev Returns the largest of two numbers.\\n */\\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two numbers.\\n */\\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two numbers. The result is rounded towards\\n * zero.\\n */\\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\\n // (a + b) / 2 can overflow.\\n return (a & b) + (a ^ b) / 2;\\n }\\n\\n /**\\n * @dev Returns the ceiling of the division of two numbers.\\n *\\n * This differs from standard division with `/` in that it rounds towards infinity instead\\n * of rounding towards zero.\\n */\\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\\n if (b == 0) {\\n // Guarantee the same behavior as in a regular Solidity division.\\n return a / b;\\n }\\n\\n // (a + b - 1) / b can overflow on addition, so we distribute.\\n return a == 0 ? 0 : (a - 1) / b + 1;\\n }\\n\\n /**\\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or\\n * denominator == 0.\\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by\\n * Uniswap Labs also under MIT license.\\n */\\n function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\\n unchecked {\\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\\n // variables such that product = prod1 * 2^256 + prod0.\\n uint256 prod0 = x * y; // Least significant 256 bits of the product\\n uint256 prod1; // Most significant 256 bits of the product\\n assembly {\\n let mm := mulmod(x, y, not(0))\\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\\n }\\n\\n // Handle non-overflow cases, 256 by 256 division.\\n if (prod1 == 0) {\\n // Solidity will revert if denominator == 0, unlike the div opcode on its own.\\n // The surrounding unchecked block does not change this fact.\\n // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\\n return prod0 / denominator;\\n }\\n\\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\\n if (denominator <= prod1) {\\n revert MathOverflowedMulDiv();\\n }\\n\\n ///////////////////////////////////////////////\\n // 512 by 256 division.\\n ///////////////////////////////////////////////\\n\\n // Make division exact by subtracting the remainder from [prod1 prod0].\\n uint256 remainder;\\n assembly {\\n // Compute remainder using mulmod.\\n remainder := mulmod(x, y, denominator)\\n\\n // Subtract 256 bit number from 512 bit number.\\n prod1 := sub(prod1, gt(remainder, prod0))\\n prod0 := sub(prod0, remainder)\\n }\\n\\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator.\\n // Always >= 1. See https://cs.stackexchange.com/q/138556/92363.\\n\\n uint256 twos = denominator & (0 - denominator);\\n assembly {\\n // Divide denominator by twos.\\n denominator := div(denominator, twos)\\n\\n // Divide [prod1 prod0] by twos.\\n prod0 := div(prod0, twos)\\n\\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\\n twos := add(div(sub(0, twos), twos), 1)\\n }\\n\\n // Shift in bits from prod1 into prod0.\\n prod0 |= prod1 * twos;\\n\\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\\n // four bits. That is, denominator * inv = 1 mod 2^4.\\n uint256 inverse = (3 * denominator) ^ 2;\\n\\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also\\n // works in modular arithmetic, doubling the correct bits in each step.\\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\\n\\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\\n // is no longer required.\\n result = prod0 * inverse;\\n return result;\\n }\\n }\\n\\n /**\\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\\n */\\n function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\\n uint256 result = mulDiv(x, y, denominator);\\n if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {\\n result += 1;\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded\\n * towards zero.\\n *\\n * Inspired by Henry S. Warren, Jr.'s \\\"Hacker's Delight\\\" (Chapter 11).\\n */\\n function sqrt(uint256 a) internal pure returns (uint256) {\\n if (a == 0) {\\n return 0;\\n }\\n\\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\\n //\\n // We know that the \\\"msb\\\" (most significant bit) of our target number `a` is a power of 2 such that we have\\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\\n //\\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\\n // \\u2192 `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\\n // \\u2192 `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\\n //\\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\\n uint256 result = 1 << (log2(a) >> 1);\\n\\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\\n // into the expected uint128 result.\\n unchecked {\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n result = (result + a / result) >> 1;\\n return min(result, a / result);\\n }\\n }\\n\\n /**\\n * @notice Calculates sqrt(a), following the selected rounding direction.\\n */\\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = sqrt(a);\\n return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 2 of a positive value rounded towards zero.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 128;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 64;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 32;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 16;\\n }\\n if (value >> 8 > 0) {\\n value >>= 8;\\n result += 8;\\n }\\n if (value >> 4 > 0) {\\n value >>= 4;\\n result += 4;\\n }\\n if (value >> 2 > 0) {\\n value >>= 2;\\n result += 2;\\n }\\n if (value >> 1 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log2(value);\\n return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 10 of a positive value rounded towards zero.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >= 10 ** 64) {\\n value /= 10 ** 64;\\n result += 64;\\n }\\n if (value >= 10 ** 32) {\\n value /= 10 ** 32;\\n result += 32;\\n }\\n if (value >= 10 ** 16) {\\n value /= 10 ** 16;\\n result += 16;\\n }\\n if (value >= 10 ** 8) {\\n value /= 10 ** 8;\\n result += 8;\\n }\\n if (value >= 10 ** 4) {\\n value /= 10 ** 4;\\n result += 4;\\n }\\n if (value >= 10 ** 2) {\\n value /= 10 ** 2;\\n result += 2;\\n }\\n if (value >= 10 ** 1) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log10(value);\\n return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Return the log in base 256 of a positive value rounded towards zero.\\n * Returns 0 if given 0.\\n *\\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\\n */\\n function log256(uint256 value) internal pure returns (uint256) {\\n uint256 result = 0;\\n unchecked {\\n if (value >> 128 > 0) {\\n value >>= 128;\\n result += 16;\\n }\\n if (value >> 64 > 0) {\\n value >>= 64;\\n result += 8;\\n }\\n if (value >> 32 > 0) {\\n value >>= 32;\\n result += 4;\\n }\\n if (value >> 16 > 0) {\\n value >>= 16;\\n result += 2;\\n }\\n if (value >> 8 > 0) {\\n result += 1;\\n }\\n }\\n return result;\\n }\\n\\n /**\\n * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\\n * Returns 0 if given 0.\\n */\\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\\n unchecked {\\n uint256 result = log256(value);\\n return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);\\n }\\n }\\n\\n /**\\n * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.\\n */\\n function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {\\n return uint8(rounding) % 2 == 1;\\n }\\n}\\n\",\"keccak256\":\"0x005ec64c6313f0555d59e278f9a7a5ab2db5bdc72a027f255a37c327af1ec02d\",\"license\":\"MIT\"},\"@openzeppelin/contracts/utils/math/SignedMath.sol\":{\"content\":\"// SPDX-License-Identifier: MIT\\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol)\\n\\npragma solidity ^0.8.20;\\n\\n/**\\n * @dev Standard signed math utilities missing in the Solidity language.\\n */\\nlibrary SignedMath {\\n /**\\n * @dev Returns the largest of two signed numbers.\\n */\\n function max(int256 a, int256 b) internal pure returns (int256) {\\n return a > b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the smallest of two signed numbers.\\n */\\n function min(int256 a, int256 b) internal pure returns (int256) {\\n return a < b ? a : b;\\n }\\n\\n /**\\n * @dev Returns the average of two signed numbers without overflow.\\n * The result is rounded towards zero.\\n */\\n function average(int256 a, int256 b) internal pure returns (int256) {\\n // Formula from the book \\\"Hacker's Delight\\\"\\n int256 x = (a & b) + ((a ^ b) >> 1);\\n return x + (int256(uint256(x) >> 255) & (a ^ b));\\n }\\n\\n /**\\n * @dev Returns the absolute unsigned value of a signed value.\\n */\\n function abs(int256 n) internal pure returns (uint256) {\\n unchecked {\\n // must be unchecked in order to support `n = type(int256).min`\\n return uint256(n >= 0 ? n : -n);\\n }\\n }\\n}\\n\",\"keccak256\":\"0x5f7e4076e175393767754387c962926577f1660dd9b810187b9002407656be72\",\"license\":\"MIT\"},\"account-abstraction/contracts/core/BasePaymaster.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\npragma solidity ^0.8.23;\\n\\n/* solhint-disable reason-string */\\n\\nimport \\\"@openzeppelin/contracts/access/Ownable.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/introspection/IERC165.sol\\\";\\nimport \\\"../interfaces/IPaymaster.sol\\\";\\nimport \\\"../interfaces/IEntryPoint.sol\\\";\\nimport \\\"./UserOperationLib.sol\\\";\\n/**\\n * Helper class for creating a paymaster.\\n * provides helper methods for staking.\\n * Validates that the postOp is called only by the entryPoint.\\n */\\nabstract contract BasePaymaster is IPaymaster, Ownable {\\n IEntryPoint public immutable entryPoint;\\n\\n uint256 internal constant PAYMASTER_VALIDATION_GAS_OFFSET = UserOperationLib.PAYMASTER_VALIDATION_GAS_OFFSET;\\n uint256 internal constant PAYMASTER_POSTOP_GAS_OFFSET = UserOperationLib.PAYMASTER_POSTOP_GAS_OFFSET;\\n uint256 internal constant PAYMASTER_DATA_OFFSET = UserOperationLib.PAYMASTER_DATA_OFFSET;\\n\\n constructor(IEntryPoint _entryPoint) Ownable(msg.sender) {\\n _validateEntryPointInterface(_entryPoint);\\n entryPoint = _entryPoint;\\n }\\n\\n //sanity check: make sure this EntryPoint was compiled against the same\\n // IEntryPoint of this paymaster\\n function _validateEntryPointInterface(IEntryPoint _entryPoint) internal virtual {\\n require(IERC165(address(_entryPoint)).supportsInterface(type(IEntryPoint).interfaceId), \\\"IEntryPoint interface mismatch\\\");\\n }\\n\\n /// @inheritdoc IPaymaster\\n function validatePaymasterUserOp(\\n PackedUserOperation calldata userOp,\\n bytes32 userOpHash,\\n uint256 maxCost\\n ) external override returns (bytes memory context, uint256 validationData) {\\n _requireFromEntryPoint();\\n return _validatePaymasterUserOp(userOp, userOpHash, maxCost);\\n }\\n\\n /**\\n * Validate a user operation.\\n * @param userOp - The user operation.\\n * @param userOpHash - The hash of the user operation.\\n * @param maxCost - The maximum cost of the user operation.\\n */\\n function _validatePaymasterUserOp(\\n PackedUserOperation calldata userOp,\\n bytes32 userOpHash,\\n uint256 maxCost\\n ) internal virtual returns (bytes memory context, uint256 validationData);\\n\\n /// @inheritdoc IPaymaster\\n function postOp(\\n PostOpMode mode,\\n bytes calldata context,\\n uint256 actualGasCost,\\n uint256 actualUserOpFeePerGas\\n ) external override {\\n _requireFromEntryPoint();\\n _postOp(mode, context, actualGasCost, actualUserOpFeePerGas);\\n }\\n\\n /**\\n * Post-operation handler.\\n * (verified to be called only through the entryPoint)\\n * @dev If subclass returns a non-empty context from validatePaymasterUserOp,\\n * it must also implement this method.\\n * @param mode - Enum with the following options:\\n * opSucceeded - User operation succeeded.\\n * opReverted - User op reverted. The paymaster still has to pay for gas.\\n * postOpReverted - never passed in a call to postOp().\\n * @param context - The context value returned by validatePaymasterUserOp\\n * @param actualGasCost - Actual gas used so far (without this postOp call).\\n * @param actualUserOpFeePerGas - the gas price this UserOp pays. This value is based on the UserOp's maxFeePerGas\\n * and maxPriorityFee (and basefee)\\n * It is not the same as tx.gasprice, which is what the bundler pays.\\n */\\n function _postOp(\\n PostOpMode mode,\\n bytes calldata context,\\n uint256 actualGasCost,\\n uint256 actualUserOpFeePerGas\\n ) internal virtual {\\n (mode, context, actualGasCost, actualUserOpFeePerGas); // unused params\\n // subclass must override this method if validatePaymasterUserOp returns a context\\n revert(\\\"must override\\\");\\n }\\n\\n /**\\n * Add a deposit for this paymaster, used for paying for transaction fees.\\n */\\n function deposit() public payable {\\n entryPoint.depositTo{value: msg.value}(address(this));\\n }\\n\\n /**\\n * Withdraw value from the deposit.\\n * @param withdrawAddress - Target to send to.\\n * @param amount - Amount to withdraw.\\n */\\n function withdrawTo(\\n address payable withdrawAddress,\\n uint256 amount\\n ) public onlyOwner {\\n entryPoint.withdrawTo(withdrawAddress, amount);\\n }\\n\\n /**\\n * Add stake for this paymaster.\\n * This method can also carry eth value to add to the current stake.\\n * @param unstakeDelaySec - The unstake delay for this paymaster. Can only be increased.\\n */\\n function addStake(uint32 unstakeDelaySec) external payable onlyOwner {\\n entryPoint.addStake{value: msg.value}(unstakeDelaySec);\\n }\\n\\n /**\\n * Return current paymaster's deposit on the entryPoint.\\n */\\n function getDeposit() public view returns (uint256) {\\n return entryPoint.balanceOf(address(this));\\n }\\n\\n /**\\n * Unlock the stake, in order to withdraw it.\\n * The paymaster can't serve requests once unlocked, until it calls addStake again\\n */\\n function unlockStake() external onlyOwner {\\n entryPoint.unlockStake();\\n }\\n\\n /**\\n * Withdraw the entire paymaster's stake.\\n * stake must be unlocked first (and then wait for the unstakeDelay to be over)\\n * @param withdrawAddress - The address to send withdrawn value.\\n */\\n function withdrawStake(address payable withdrawAddress) external onlyOwner {\\n entryPoint.withdrawStake(withdrawAddress);\\n }\\n\\n /**\\n * Validate the call is made from a valid entrypoint\\n */\\n function _requireFromEntryPoint() internal virtual {\\n require(msg.sender == address(entryPoint), \\\"Sender not EntryPoint\\\");\\n }\\n}\\n\",\"keccak256\":\"0x156dd80127599c02937985a4fe44dd6424e29445af9aae886aff0f1993af43ab\",\"license\":\"GPL-3.0\"},\"account-abstraction/contracts/core/Helpers.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\npragma solidity ^0.8.23;\\n\\n/* solhint-disable no-inline-assembly */\\n\\n\\n /*\\n * For simulation purposes, validateUserOp (and validatePaymasterUserOp)\\n * must return this value in case of signature failure, instead of revert.\\n */\\nuint256 constant SIG_VALIDATION_FAILED = 1;\\n\\n\\n/*\\n * For simulation purposes, validateUserOp (and validatePaymasterUserOp)\\n * return this value on success.\\n */\\nuint256 constant SIG_VALIDATION_SUCCESS = 0;\\n\\n\\n/**\\n * Returned data from validateUserOp.\\n * validateUserOp returns a uint256, which is created by `_packedValidationData` and\\n * parsed by `_parseValidationData`.\\n * @param aggregator - address(0) - The account validated the signature by itself.\\n * address(1) - The account failed to validate the signature.\\n * otherwise - This is an address of a signature aggregator that must\\n * be used to validate the signature.\\n * @param validAfter - This UserOp is valid only after this timestamp.\\n * @param validaUntil - This UserOp is valid only up to this timestamp.\\n */\\nstruct ValidationData {\\n address aggregator;\\n uint48 validAfter;\\n uint48 validUntil;\\n}\\n\\n/**\\n * Extract sigFailed, validAfter, validUntil.\\n * Also convert zero validUntil to type(uint48).max.\\n * @param validationData - The packed validation data.\\n */\\nfunction _parseValidationData(\\n uint256 validationData\\n) pure returns (ValidationData memory data) {\\n address aggregator = address(uint160(validationData));\\n uint48 validUntil = uint48(validationData >> 160);\\n if (validUntil == 0) {\\n validUntil = type(uint48).max;\\n }\\n uint48 validAfter = uint48(validationData >> (48 + 160));\\n return ValidationData(aggregator, validAfter, validUntil);\\n}\\n\\n/**\\n * Helper to pack the return value for validateUserOp.\\n * @param data - The ValidationData to pack.\\n */\\nfunction _packValidationData(\\n ValidationData memory data\\n) pure returns (uint256) {\\n return\\n uint160(data.aggregator) |\\n (uint256(data.validUntil) << 160) |\\n (uint256(data.validAfter) << (160 + 48));\\n}\\n\\n/**\\n * Helper to pack the return value for validateUserOp, when not using an aggregator.\\n * @param sigFailed - True for signature failure, false for success.\\n * @param validUntil - Last timestamp this UserOperation is valid (or zero for infinite).\\n * @param validAfter - First timestamp this UserOperation is valid.\\n */\\nfunction _packValidationData(\\n bool sigFailed,\\n uint48 validUntil,\\n uint48 validAfter\\n) pure returns (uint256) {\\n return\\n (sigFailed ? 1 : 0) |\\n (uint256(validUntil) << 160) |\\n (uint256(validAfter) << (160 + 48));\\n}\\n\\n/**\\n * keccak function over calldata.\\n * @dev copy calldata into memory, do keccak and drop allocated memory. Strangely, this is more efficient than letting solidity do it.\\n */\\n function calldataKeccak(bytes calldata data) pure returns (bytes32 ret) {\\n assembly (\\\"memory-safe\\\") {\\n let mem := mload(0x40)\\n let len := data.length\\n calldatacopy(mem, data.offset, len)\\n ret := keccak256(mem, len)\\n }\\n }\\n\\n\\n/**\\n * The minimum of two numbers.\\n * @param a - First number.\\n * @param b - Second number.\\n */\\n function min(uint256 a, uint256 b) pure returns (uint256) {\\n return a < b ? a : b;\\n }\\n\",\"keccak256\":\"0x6247e011a6cb0b263b3aa098822977181674d91b62e5bdfe04c6e66f72da25d6\",\"license\":\"GPL-3.0\"},\"account-abstraction/contracts/core/UserOperationLib.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\npragma solidity ^0.8.23;\\n\\n/* solhint-disable no-inline-assembly */\\n\\nimport \\\"../interfaces/PackedUserOperation.sol\\\";\\nimport {calldataKeccak, min} from \\\"./Helpers.sol\\\";\\n\\n/**\\n * Utility functions helpful when working with UserOperation structs.\\n */\\nlibrary UserOperationLib {\\n\\n uint256 public constant PAYMASTER_VALIDATION_GAS_OFFSET = 20;\\n uint256 public constant PAYMASTER_POSTOP_GAS_OFFSET = 36;\\n uint256 public constant PAYMASTER_DATA_OFFSET = 52;\\n /**\\n * Get sender from user operation data.\\n * @param userOp - The user operation data.\\n */\\n function getSender(\\n PackedUserOperation calldata userOp\\n ) internal pure returns (address) {\\n address data;\\n //read sender from userOp, which is first userOp member (saves 800 gas...)\\n assembly {\\n data := calldataload(userOp)\\n }\\n return address(uint160(data));\\n }\\n\\n /**\\n * Relayer/block builder might submit the TX with higher priorityFee,\\n * but the user should not pay above what he signed for.\\n * @param userOp - The user operation data.\\n */\\n function gasPrice(\\n PackedUserOperation calldata userOp\\n ) internal view returns (uint256) {\\n unchecked {\\n (uint256 maxPriorityFeePerGas, uint256 maxFeePerGas) = unpackUints(userOp.gasFees);\\n if (maxFeePerGas == maxPriorityFeePerGas) {\\n //legacy mode (for networks that don't support basefee opcode)\\n return maxFeePerGas;\\n }\\n return min(maxFeePerGas, maxPriorityFeePerGas + block.basefee);\\n }\\n }\\n\\n /**\\n * Pack the user operation data into bytes for hashing.\\n * @param userOp - The user operation data.\\n */\\n function encode(\\n PackedUserOperation calldata userOp\\n ) internal pure returns (bytes memory ret) {\\n address sender = getSender(userOp);\\n uint256 nonce = userOp.nonce;\\n bytes32 hashInitCode = calldataKeccak(userOp.initCode);\\n bytes32 hashCallData = calldataKeccak(userOp.callData);\\n bytes32 accountGasLimits = userOp.accountGasLimits;\\n uint256 preVerificationGas = userOp.preVerificationGas;\\n bytes32 gasFees = userOp.gasFees;\\n bytes32 hashPaymasterAndData = calldataKeccak(userOp.paymasterAndData);\\n\\n return abi.encode(\\n sender, nonce,\\n hashInitCode, hashCallData,\\n accountGasLimits, preVerificationGas, gasFees,\\n hashPaymasterAndData\\n );\\n }\\n\\n function unpackUints(\\n bytes32 packed\\n ) internal pure returns (uint256 high128, uint256 low128) {\\n return (uint128(bytes16(packed)), uint128(uint256(packed)));\\n }\\n\\n //unpack just the high 128-bits from a packed value\\n function unpackHigh128(bytes32 packed) internal pure returns (uint256) {\\n return uint256(packed) >> 128;\\n }\\n\\n // unpack just the low 128-bits from a packed value\\n function unpackLow128(bytes32 packed) internal pure returns (uint256) {\\n return uint128(uint256(packed));\\n }\\n\\n function unpackMaxPriorityFeePerGas(PackedUserOperation calldata userOp)\\n internal pure returns (uint256) {\\n return unpackHigh128(userOp.gasFees);\\n }\\n\\n function unpackMaxFeePerGas(PackedUserOperation calldata userOp)\\n internal pure returns (uint256) {\\n return unpackLow128(userOp.gasFees);\\n }\\n\\n function unpackVerificationGasLimit(PackedUserOperation calldata userOp)\\n internal pure returns (uint256) {\\n return unpackHigh128(userOp.accountGasLimits);\\n }\\n\\n function unpackCallGasLimit(PackedUserOperation calldata userOp)\\n internal pure returns (uint256) {\\n return unpackLow128(userOp.accountGasLimits);\\n }\\n\\n function unpackPaymasterVerificationGasLimit(PackedUserOperation calldata userOp)\\n internal pure returns (uint256) {\\n return uint128(bytes16(userOp.paymasterAndData[PAYMASTER_VALIDATION_GAS_OFFSET : PAYMASTER_POSTOP_GAS_OFFSET]));\\n }\\n\\n function unpackPostOpGasLimit(PackedUserOperation calldata userOp)\\n internal pure returns (uint256) {\\n return uint128(bytes16(userOp.paymasterAndData[PAYMASTER_POSTOP_GAS_OFFSET : PAYMASTER_DATA_OFFSET]));\\n }\\n\\n function unpackPaymasterStaticFields(\\n bytes calldata paymasterAndData\\n ) internal pure returns (address paymaster, uint256 validationGasLimit, uint256 postOpGasLimit) {\\n return (\\n address(bytes20(paymasterAndData[: PAYMASTER_VALIDATION_GAS_OFFSET])),\\n uint128(bytes16(paymasterAndData[PAYMASTER_VALIDATION_GAS_OFFSET : PAYMASTER_POSTOP_GAS_OFFSET])),\\n uint128(bytes16(paymasterAndData[PAYMASTER_POSTOP_GAS_OFFSET : PAYMASTER_DATA_OFFSET]))\\n );\\n }\\n\\n /**\\n * Hash the user operation data.\\n * @param userOp - The user operation data.\\n */\\n function hash(\\n PackedUserOperation calldata userOp\\n ) internal pure returns (bytes32) {\\n return keccak256(encode(userOp));\\n }\\n}\\n\",\"keccak256\":\"0x9d50ece985d35f82e33e5da417595c86fac10449e3d10895d08363d33aad454b\",\"license\":\"GPL-3.0\"},\"account-abstraction/contracts/interfaces/IAggregator.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\npragma solidity >=0.7.5;\\n\\nimport \\\"./PackedUserOperation.sol\\\";\\n\\n/**\\n * Aggregated Signatures validator.\\n */\\ninterface IAggregator {\\n /**\\n * Validate aggregated signature.\\n * Revert if the aggregated signature does not match the given list of operations.\\n * @param userOps - Array of UserOperations to validate the signature for.\\n * @param signature - The aggregated signature.\\n */\\n function validateSignatures(\\n PackedUserOperation[] calldata userOps,\\n bytes calldata signature\\n ) external view;\\n\\n /**\\n * Validate signature of a single userOp.\\n * This method should be called by bundler after EntryPointSimulation.simulateValidation() returns\\n * the aggregator this account uses.\\n * First it validates the signature over the userOp. Then it returns data to be used when creating the handleOps.\\n * @param userOp - The userOperation received from the user.\\n * @return sigForUserOp - The value to put into the signature field of the userOp when calling handleOps.\\n * (usually empty, unless account and aggregator support some kind of \\\"multisig\\\".\\n */\\n function validateUserOpSignature(\\n PackedUserOperation calldata userOp\\n ) external view returns (bytes memory sigForUserOp);\\n\\n /**\\n * Aggregate multiple signatures into a single value.\\n * This method is called off-chain to calculate the signature to pass with handleOps()\\n * bundler MAY use optimized custom code perform this aggregation.\\n * @param userOps - Array of UserOperations to collect the signatures from.\\n * @return aggregatedSignature - The aggregated signature.\\n */\\n function aggregateSignatures(\\n PackedUserOperation[] calldata userOps\\n ) external view returns (bytes memory aggregatedSignature);\\n}\\n\",\"keccak256\":\"0xf100d6fcc0c3b450b13e979b6a42c628c292a1bc340eccc2e7796b80e3975588\",\"license\":\"GPL-3.0\"},\"account-abstraction/contracts/interfaces/IEntryPoint.sol\":{\"content\":\"/**\\n ** Account-Abstraction (EIP-4337) singleton EntryPoint implementation.\\n ** Only one instance required on each chain.\\n **/\\n// SPDX-License-Identifier: GPL-3.0\\npragma solidity >=0.7.5;\\n\\n/* solhint-disable avoid-low-level-calls */\\n/* solhint-disable no-inline-assembly */\\n/* solhint-disable reason-string */\\n\\nimport \\\"./PackedUserOperation.sol\\\";\\nimport \\\"./IStakeManager.sol\\\";\\nimport \\\"./IAggregator.sol\\\";\\nimport \\\"./INonceManager.sol\\\";\\n\\ninterface IEntryPoint is IStakeManager, INonceManager {\\n /***\\n * An event emitted after each successful request.\\n * @param userOpHash - Unique identifier for the request (hash its entire content, except signature).\\n * @param sender - The account that generates this request.\\n * @param paymaster - If non-null, the paymaster that pays for this request.\\n * @param nonce - The nonce value from the request.\\n * @param success - True if the sender transaction succeeded, false if reverted.\\n * @param actualGasCost - Actual amount paid (by account or paymaster) for this UserOperation.\\n * @param actualGasUsed - Total gas used by this UserOperation (including preVerification, creation,\\n * validation and execution).\\n */\\n event UserOperationEvent(\\n bytes32 indexed userOpHash,\\n address indexed sender,\\n address indexed paymaster,\\n uint256 nonce,\\n bool success,\\n uint256 actualGasCost,\\n uint256 actualGasUsed\\n );\\n\\n /**\\n * Account \\\"sender\\\" was deployed.\\n * @param userOpHash - The userOp that deployed this account. UserOperationEvent will follow.\\n * @param sender - The account that is deployed\\n * @param factory - The factory used to deploy this account (in the initCode)\\n * @param paymaster - The paymaster used by this UserOp\\n */\\n event AccountDeployed(\\n bytes32 indexed userOpHash,\\n address indexed sender,\\n address factory,\\n address paymaster\\n );\\n\\n /**\\n * An event emitted if the UserOperation \\\"callData\\\" reverted with non-zero length.\\n * @param userOpHash - The request unique identifier.\\n * @param sender - The sender of this request.\\n * @param nonce - The nonce used in the request.\\n * @param revertReason - The return bytes from the (reverted) call to \\\"callData\\\".\\n */\\n event UserOperationRevertReason(\\n bytes32 indexed userOpHash,\\n address indexed sender,\\n uint256 nonce,\\n bytes revertReason\\n );\\n\\n /**\\n * An event emitted if the UserOperation Paymaster's \\\"postOp\\\" call reverted with non-zero length.\\n * @param userOpHash - The request unique identifier.\\n * @param sender - The sender of this request.\\n * @param nonce - The nonce used in the request.\\n * @param revertReason - The return bytes from the (reverted) call to \\\"callData\\\".\\n */\\n event PostOpRevertReason(\\n bytes32 indexed userOpHash,\\n address indexed sender,\\n uint256 nonce,\\n bytes revertReason\\n );\\n\\n /**\\n * UserOp consumed more than prefund. The UserOperation is reverted, and no refund is made.\\n * @param userOpHash - The request unique identifier.\\n * @param sender - The sender of this request.\\n * @param nonce - The nonce used in the request.\\n */\\n event UserOperationPrefundTooLow(\\n bytes32 indexed userOpHash,\\n address indexed sender,\\n uint256 nonce\\n );\\n\\n /**\\n * An event emitted by handleOps(), before starting the execution loop.\\n * Any event emitted before this event, is part of the validation.\\n */\\n event BeforeExecution();\\n\\n /**\\n * Signature aggregator used by the following UserOperationEvents within this bundle.\\n * @param aggregator - The aggregator used for the following UserOperationEvents.\\n */\\n event SignatureAggregatorChanged(address indexed aggregator);\\n\\n /**\\n * A custom revert error of handleOps, to identify the offending op.\\n * Should be caught in off-chain handleOps simulation and not happen on-chain.\\n * Useful for mitigating DoS attempts against batchers or for troubleshooting of factory/account/paymaster reverts.\\n * NOTE: If simulateValidation passes successfully, there should be no reason for handleOps to fail on it.\\n * @param opIndex - Index into the array of ops to the failed one (in simulateValidation, this is always zero).\\n * @param reason - Revert reason. The string starts with a unique code \\\"AAmn\\\",\\n * where \\\"m\\\" is \\\"1\\\" for factory, \\\"2\\\" for account and \\\"3\\\" for paymaster issues,\\n * so a failure can be attributed to the correct entity.\\n */\\n error FailedOp(uint256 opIndex, string reason);\\n\\n /**\\n * A custom revert error of handleOps, to report a revert by account or paymaster.\\n * @param opIndex - Index into the array of ops to the failed one (in simulateValidation, this is always zero).\\n * @param reason - Revert reason. see FailedOp(uint256,string), above\\n * @param inner - data from inner cought revert reason\\n * @dev note that inner is truncated to 2048 bytes\\n */\\n error FailedOpWithRevert(uint256 opIndex, string reason, bytes inner);\\n\\n error PostOpReverted(bytes returnData);\\n\\n /**\\n * Error case when a signature aggregator fails to verify the aggregated signature it had created.\\n * @param aggregator The aggregator that failed to verify the signature\\n */\\n error SignatureValidationFailed(address aggregator);\\n\\n // Return value of getSenderAddress.\\n error SenderAddressResult(address sender);\\n\\n // UserOps handled, per aggregator.\\n struct UserOpsPerAggregator {\\n PackedUserOperation[] userOps;\\n // Aggregator address\\n IAggregator aggregator;\\n // Aggregated signature\\n bytes signature;\\n }\\n\\n /**\\n * Execute a batch of UserOperations.\\n * No signature aggregator is used.\\n * If any account requires an aggregator (that is, it returned an aggregator when\\n * performing simulateValidation), then handleAggregatedOps() must be used instead.\\n * @param ops - The operations to execute.\\n * @param beneficiary - The address to receive the fees.\\n */\\n function handleOps(\\n PackedUserOperation[] calldata ops,\\n address payable beneficiary\\n ) external;\\n\\n /**\\n * Execute a batch of UserOperation with Aggregators\\n * @param opsPerAggregator - The operations to execute, grouped by aggregator (or address(0) for no-aggregator accounts).\\n * @param beneficiary - The address to receive the fees.\\n */\\n function handleAggregatedOps(\\n UserOpsPerAggregator[] calldata opsPerAggregator,\\n address payable beneficiary\\n ) external;\\n\\n /**\\n * Generate a request Id - unique identifier for this request.\\n * The request ID is a hash over the content of the userOp (except the signature), the entrypoint and the chainid.\\n * @param userOp - The user operation to generate the request ID for.\\n * @return hash the hash of this UserOperation\\n */\\n function getUserOpHash(\\n PackedUserOperation calldata userOp\\n ) external view returns (bytes32);\\n\\n /**\\n * Gas and return values during simulation.\\n * @param preOpGas - The gas used for validation (including preValidationGas)\\n * @param prefund - The required prefund for this operation\\n * @param accountValidationData - returned validationData from account.\\n * @param paymasterValidationData - return validationData from paymaster.\\n * @param paymasterContext - Returned by validatePaymasterUserOp (to be passed into postOp)\\n */\\n struct ReturnInfo {\\n uint256 preOpGas;\\n uint256 prefund;\\n uint256 accountValidationData;\\n uint256 paymasterValidationData;\\n bytes paymasterContext;\\n }\\n\\n /**\\n * Returned aggregated signature info:\\n * The aggregator returned by the account, and its current stake.\\n */\\n struct AggregatorStakeInfo {\\n address aggregator;\\n StakeInfo stakeInfo;\\n }\\n\\n /**\\n * Get counterfactual sender address.\\n * Calculate the sender contract address that will be generated by the initCode and salt in the UserOperation.\\n * This method always revert, and returns the address in SenderAddressResult error\\n * @param initCode - The constructor code to be passed into the UserOperation.\\n */\\n function getSenderAddress(bytes memory initCode) external;\\n\\n error DelegateAndRevert(bool success, bytes ret);\\n\\n /**\\n * Helper method for dry-run testing.\\n * @dev calling this method, the EntryPoint will make a delegatecall to the given data, and report (via revert) the result.\\n * The method always revert, so is only useful off-chain for dry run calls, in cases where state-override to replace\\n * actual EntryPoint code is less convenient.\\n * @param target a target contract to make a delegatecall from entrypoint\\n * @param data data to pass to target in a delegatecall\\n */\\n function delegateAndRevert(address target, bytes calldata data) external;\\n}\\n\",\"keccak256\":\"0x1972a5fcb3a808b58c85af5741949ef6af11ab0debd3ae8c708171ae1ae0d0c4\",\"license\":\"GPL-3.0\"},\"account-abstraction/contracts/interfaces/INonceManager.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\npragma solidity >=0.7.5;\\n\\ninterface INonceManager {\\n\\n /**\\n * Return the next nonce for this sender.\\n * Within a given key, the nonce values are sequenced (starting with zero, and incremented by one on each userop)\\n * But UserOp with different keys can come with arbitrary order.\\n *\\n * @param sender the account address\\n * @param key the high 192 bit of the nonce\\n * @return nonce a full nonce to pass for next UserOp with this sender.\\n */\\n function getNonce(address sender, uint192 key)\\n external view returns (uint256 nonce);\\n\\n /**\\n * Manually increment the nonce of the sender.\\n * This method is exposed just for completeness..\\n * Account does NOT need to call it, neither during validation, nor elsewhere,\\n * as the EntryPoint will update the nonce regardless.\\n * Possible use-case is call it with various keys to \\\"initialize\\\" their nonces to one, so that future\\n * UserOperations will not pay extra for the first transaction with a given key.\\n */\\n function incrementNonce(uint192 key) external;\\n}\\n\",\"keccak256\":\"0xd575af0f6ebbd5f0b2933307d44cd7b4e03a69f4b817a67db5409bd3c89aeecb\",\"license\":\"GPL-3.0\"},\"account-abstraction/contracts/interfaces/IPaymaster.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\npragma solidity >=0.7.5;\\n\\nimport \\\"./PackedUserOperation.sol\\\";\\n\\n/**\\n * The interface exposed by a paymaster contract, who agrees to pay the gas for user's operations.\\n * A paymaster must hold a stake to cover the required entrypoint stake and also the gas for the transaction.\\n */\\ninterface IPaymaster {\\n enum PostOpMode {\\n // User op succeeded.\\n opSucceeded,\\n // User op reverted. Still has to pay for gas.\\n opReverted,\\n // Only used internally in the EntryPoint (cleanup after postOp reverts). Never calling paymaster with this value\\n postOpReverted\\n }\\n\\n /**\\n * Payment validation: check if paymaster agrees to pay.\\n * Must verify sender is the entryPoint.\\n * Revert to reject this request.\\n * Note that bundlers will reject this method if it changes the state, unless the paymaster is trusted (whitelisted).\\n * The paymaster pre-pays using its deposit, and receive back a refund after the postOp method returns.\\n * @param userOp - The user operation.\\n * @param userOpHash - Hash of the user's request data.\\n * @param maxCost - The maximum cost of this transaction (based on maximum gas and gas price from userOp).\\n * @return context - Value to send to a postOp. Zero length to signify postOp is not required.\\n * @return validationData - Signature and time-range of this operation, encoded the same as the return\\n * value of validateUserOperation.\\n * <20-byte> sigAuthorizer - 0 for valid signature, 1 to mark signature failure,\\n * other values are invalid for paymaster.\\n * <6-byte> validUntil - last timestamp this operation is valid. 0 for \\\"indefinite\\\"\\n * <6-byte> validAfter - first timestamp this operation is valid\\n * Note that the validation code cannot use block.timestamp (or block.number) directly.\\n */\\n function validatePaymasterUserOp(\\n PackedUserOperation calldata userOp,\\n bytes32 userOpHash,\\n uint256 maxCost\\n ) external returns (bytes memory context, uint256 validationData);\\n\\n /**\\n * Post-operation handler.\\n * Must verify sender is the entryPoint.\\n * @param mode - Enum with the following options:\\n * opSucceeded - User operation succeeded.\\n * opReverted - User op reverted. The paymaster still has to pay for gas.\\n * postOpReverted - never passed in a call to postOp().\\n * @param context - The context value returned by validatePaymasterUserOp\\n * @param actualGasCost - Actual gas used so far (without this postOp call).\\n * @param actualUserOpFeePerGas - the gas price this UserOp pays. This value is based on the UserOp's maxFeePerGas\\n * and maxPriorityFee (and basefee)\\n * It is not the same as tx.gasprice, which is what the bundler pays.\\n */\\n function postOp(\\n PostOpMode mode,\\n bytes calldata context,\\n uint256 actualGasCost,\\n uint256 actualUserOpFeePerGas\\n ) external;\\n}\\n\",\"keccak256\":\"0x49d8dbf8a85b006bcd89bbc40e4e9e113997cc016007de85263bdae70572d07f\",\"license\":\"GPL-3.0\"},\"account-abstraction/contracts/interfaces/IStakeManager.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0-only\\npragma solidity >=0.7.5;\\n\\n/**\\n * Manage deposits and stakes.\\n * Deposit is just a balance used to pay for UserOperations (either by a paymaster or an account).\\n * Stake is value locked for at least \\\"unstakeDelay\\\" by the staked entity.\\n */\\ninterface IStakeManager {\\n event Deposited(address indexed account, uint256 totalDeposit);\\n\\n event Withdrawn(\\n address indexed account,\\n address withdrawAddress,\\n uint256 amount\\n );\\n\\n // Emitted when stake or unstake delay are modified.\\n event StakeLocked(\\n address indexed account,\\n uint256 totalStaked,\\n uint256 unstakeDelaySec\\n );\\n\\n // Emitted once a stake is scheduled for withdrawal.\\n event StakeUnlocked(address indexed account, uint256 withdrawTime);\\n\\n event StakeWithdrawn(\\n address indexed account,\\n address withdrawAddress,\\n uint256 amount\\n );\\n\\n /**\\n * @param deposit - The entity's deposit.\\n * @param staked - True if this entity is staked.\\n * @param stake - Actual amount of ether staked for this entity.\\n * @param unstakeDelaySec - Minimum delay to withdraw the stake.\\n * @param withdrawTime - First block timestamp where 'withdrawStake' will be callable, or zero if already locked.\\n * @dev Sizes were chosen so that deposit fits into one cell (used during handleOp)\\n * and the rest fit into a 2nd cell (used during stake/unstake)\\n * - 112 bit allows for 10^15 eth\\n * - 48 bit for full timestamp\\n * - 32 bit allows 150 years for unstake delay\\n */\\n struct DepositInfo {\\n uint256 deposit;\\n bool staked;\\n uint112 stake;\\n uint32 unstakeDelaySec;\\n uint48 withdrawTime;\\n }\\n\\n // API struct used by getStakeInfo and simulateValidation.\\n struct StakeInfo {\\n uint256 stake;\\n uint256 unstakeDelaySec;\\n }\\n\\n /**\\n * Get deposit info.\\n * @param account - The account to query.\\n * @return info - Full deposit information of given account.\\n */\\n function getDepositInfo(\\n address account\\n ) external view returns (DepositInfo memory info);\\n\\n /**\\n * Get account balance.\\n * @param account - The account to query.\\n * @return - The deposit (for gas payment) of the account.\\n */\\n function balanceOf(address account) external view returns (uint256);\\n\\n /**\\n * Add to the deposit of the given account.\\n * @param account - The account to add to.\\n */\\n function depositTo(address account) external payable;\\n\\n /**\\n * Add to the account's stake - amount and delay\\n * any pending unstake is first cancelled.\\n * @param _unstakeDelaySec - The new lock duration before the deposit can be withdrawn.\\n */\\n function addStake(uint32 _unstakeDelaySec) external payable;\\n\\n /**\\n * Attempt to unlock the stake.\\n * The value can be withdrawn (using withdrawStake) after the unstake delay.\\n */\\n function unlockStake() external;\\n\\n /**\\n * Withdraw from the (unlocked) stake.\\n * Must first call unlockStake and wait for the unstakeDelay to pass.\\n * @param withdrawAddress - The address to send withdrawn value.\\n */\\n function withdrawStake(address payable withdrawAddress) external;\\n\\n /**\\n * Withdraw from the deposit.\\n * @param withdrawAddress - The address to send withdrawn value.\\n * @param withdrawAmount - The amount to withdraw.\\n */\\n function withdrawTo(\\n address payable withdrawAddress,\\n uint256 withdrawAmount\\n ) external;\\n}\\n\",\"keccak256\":\"0xbe5ca9e7f254d031687419e7b96ef48c9c63e9398bbe992dc72ffc6dc14e0a04\",\"license\":\"GPL-3.0-only\"},\"account-abstraction/contracts/interfaces/PackedUserOperation.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\npragma solidity >=0.7.5;\\n\\n/**\\n * User Operation struct\\n * @param sender - The sender account of this request.\\n * @param nonce - Unique value the sender uses to verify it is not a replay.\\n * @param initCode - If set, the account contract will be created by this constructor/\\n * @param callData - The method call to execute on this account.\\n * @param accountGasLimits - Packed gas limits for validateUserOp and gas limit passed to the callData method call.\\n * @param preVerificationGas - Gas not calculated by the handleOps method, but added to the gas paid.\\n * Covers batch overhead.\\n * @param gasFees - packed gas fields maxPriorityFeePerGas and maxFeePerGas - Same as EIP-1559 gas parameters.\\n * @param paymasterAndData - If set, this field holds the paymaster address, verification gas limit, postOp gas limit and paymaster-specific extra data\\n * The paymaster will pay for the transaction instead of the sender.\\n * @param signature - Sender-verified signature over the entire request, the EntryPoint address and the chain ID.\\n */\\nstruct PackedUserOperation {\\n address sender;\\n uint256 nonce;\\n bytes initCode;\\n bytes callData;\\n bytes32 accountGasLimits;\\n uint256 preVerificationGas;\\n bytes32 gasFees;\\n bytes paymasterAndData;\\n bytes signature;\\n}\\n\",\"keccak256\":\"0x1129b46381db68eddbc5cb49e50664667b66b03c480453858e7b25eabe444359\",\"license\":\"GPL-3.0\"},\"src/paymaster/VerifyingPaymaster.sol\":{\"content\":\"// SPDX-License-Identifier: GPL-3.0\\npragma solidity ^0.8.23;\\n\\n// @dev eth-infinitism/account-abstraction contract with addition of updating verifying signer.\\n\\n/* solhint-disable reason-string */\\n/* solhint-disable no-inline-assembly */\\n\\nimport \\\"../../account-abstraction/contracts/core/BasePaymaster.sol\\\";\\nimport \\\"../../account-abstraction/contracts/core/UserOperationLib.sol\\\";\\nimport \\\"../../account-abstraction/contracts/core/Helpers.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\\\";\\nimport \\\"@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol\\\";\\n/**\\n * A sample paymaster that uses external service to decide whether to pay for the UserOp.\\n * The paymaster trusts an external signer to sign the transaction.\\n * The calling user must pass the UserOp to that external signer first, which performs\\n * whatever off-chain verification before signing the UserOp.\\n * Note that this signature is NOT a replacement for the account-specific signature:\\n * - the paymaster checks a signature to agree to PAY for GAS.\\n * - the account checks a signature to prove identity and account ownership.\\n */\\ncontract VerifyingPaymaster is BasePaymaster {\\n using UserOperationLib for PackedUserOperation;\\n\\n address public verifyingSigner;\\n\\n uint256 private constant VALID_TIMESTAMP_OFFSET = PAYMASTER_DATA_OFFSET;\\n\\n uint256 private constant SIGNATURE_OFFSET = VALID_TIMESTAMP_OFFSET + 64;\\n\\n event VerifyingSignerUpdated(address newVerifyingSigner);\\n\\n constructor(\\n IEntryPoint _entryPoint,\\n address _verifyingSigner\\n ) BasePaymaster(_entryPoint) {\\n verifyingSigner = _verifyingSigner;\\n }\\n\\n /**\\n * return the hash we're going to sign off-chain (and validate on-chain)\\n * this method is called by the off-chain service, to sign the request.\\n * it is called on-chain from the validatePaymasterUserOp, to validate the signature.\\n * note that this signature covers all fields of the UserOperation, except the \\\"paymasterAndData\\\",\\n * which will carry the signature itself.\\n */\\n function getHash(\\n PackedUserOperation calldata userOp,\\n uint48 validUntil,\\n uint48 validAfter\\n ) public view returns (bytes32) {\\n //can't use userOp.hash(), since it contains also the paymasterAndData itself.\\n address sender = userOp.getSender();\\n return\\n keccak256(\\n abi.encode(\\n sender,\\n userOp.nonce,\\n keccak256(userOp.initCode),\\n keccak256(userOp.callData),\\n userOp.accountGasLimits,\\n uint256(\\n bytes32(\\n userOp\\n .paymasterAndData[PAYMASTER_VALIDATION_GAS_OFFSET:PAYMASTER_DATA_OFFSET]\\n )\\n ),\\n userOp.preVerificationGas,\\n userOp.gasFees,\\n block.chainid,\\n address(this),\\n validUntil,\\n validAfter\\n )\\n );\\n }\\n\\n /**\\n * verify our external signer signed this request.\\n * the \\\"paymasterAndData\\\" is expected to be the paymaster and a signature over the entire request params\\n * paymasterAndData[:20] : address(this)\\n * paymasterAndData[20:84] : abi.encode(validUntil, validAfter)\\n * paymasterAndData[84:] : signature\\n */\\n function _validatePaymasterUserOp(\\n PackedUserOperation calldata userOp,\\n bytes32 /*userOpHash*/,\\n uint256 requiredPreFund\\n )\\n internal\\n view\\n override\\n returns (bytes memory context, uint256 validationData)\\n {\\n (requiredPreFund);\\n\\n (\\n uint48 validUntil,\\n uint48 validAfter,\\n bytes calldata signature\\n ) = parsePaymasterAndData(userOp.paymasterAndData);\\n //ECDSA library supports both 64 and 65-byte long signatures.\\n // we only \\\"require\\\" it here so that the revert reason on invalid signature will be of \\\"VerifyingPaymaster\\\", and not \\\"ECDSA\\\"\\n require(\\n signature.length == 64 || signature.length == 65,\\n \\\"VerifyingPaymaster: invalid signature length in paymasterAndData\\\"\\n );\\n bytes32 hash = MessageHashUtils.toEthSignedMessageHash(\\n getHash(userOp, validUntil, validAfter)\\n );\\n\\n //don't revert on signature failure: return SIG_VALIDATION_FAILED\\n if (verifyingSigner != ECDSA.recover(hash, signature)) {\\n return (\\\"\\\", _packValidationData(true, validUntil, validAfter));\\n }\\n\\n //no need for other on-chain validation: entire UserOp should have been checked\\n // by the external service prior to signing it.\\n return (\\\"\\\", _packValidationData(false, validUntil, validAfter));\\n }\\n\\n function parsePaymasterAndData(\\n bytes calldata paymasterAndData\\n )\\n public\\n pure\\n returns (uint48 validUntil, uint48 validAfter, bytes calldata signature)\\n {\\n (validUntil, validAfter) = abi.decode(\\n paymasterAndData[VALID_TIMESTAMP_OFFSET:],\\n (uint48, uint48)\\n );\\n signature = paymasterAndData[SIGNATURE_OFFSET:];\\n }\\n\\n function updateVerifyingSigner(\\n address _newVerifyingSigner\\n ) public onlyOwner {\\n verifyingSigner = _newVerifyingSigner;\\n emit VerifyingSignerUpdated(_newVerifyingSigner);\\n }\\n}\\n\",\"keccak256\":\"0x51d9476d711b86e70029840786077df04c71198e5a79a5dd51ff1fd3be6a408b\",\"license\":\"GPL-3.0\"}},\"version\":1}", + "bytecode": "0x60a06040523480156200001157600080fd5b5060405162001417380380620014178339810160408190526200003491620001ca565b8133806200005d57604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b6200006881620000a1565b506200007481620000f1565b6001600160a01b03908116608052600180546001600160a01b031916929091169190911790555062000234565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6040516301ffc9a760e01b815263122a0e9b60e31b60048201526001600160a01b038216906301ffc9a790602401602060405180830381865afa1580156200013d573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000163919062000209565b620001b15760405162461bcd60e51b815260206004820152601e60248201527f49456e747279506f696e7420696e74657266616365206d69736d617463680000604482015260640162000054565b50565b6001600160a01b0381168114620001b157600080fd5b60008060408385031215620001de57600080fd5b8251620001eb81620001b4565b6020840151909250620001fe81620001b4565b809150509250929050565b6000602082840312156200021c57600080fd5b815180151581146200022d57600080fd5b9392505050565b608051611196620002816000396000818161027b01528181610331015281816103c80152818161061e015281816106b801528181610728015281816107b5015261087d01526111966000f3fe6080604052600436106100f35760003560e01c806393b941211161008a578063c23a5cea11610059578063c23a5cea146102b2578063c399ec88146102d2578063d0e30db0146102e7578063f2fde38b146102ef57600080fd5b806393b941211461021957806394d4ad6014610239578063b0d691fe14610269578063bb9fe6bf1461029d57600080fd5b80635829c5f5116100c65780635829c5f514610198578063715018a6146101c65780637c627b21146101db5780638da5cb5b146101fb57600080fd5b80630396cb60146100f8578063205c28781461010d57806323d9ac9b1461012d57806352b7512c1461016a575b600080fd5b61010b610106366004610d3c565b61030f565b005b34801561011957600080fd5b5061010b610128366004610d7e565b61039a565b34801561013957600080fd5b5060015461014d906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561017657600080fd5b5061018a610185366004610dc3565b61040c565b604051610161929190610e11565b3480156101a457600080fd5b506101b86101b3366004610e81565b610430565b604051908152602001610161565b3480156101d257600080fd5b5061010b610540565b3480156101e757600080fd5b5061010b6101f6366004610f28565b610554565b34801561020757600080fd5b506000546001600160a01b031661014d565b34801561022557600080fd5b5061010b610234366004610f93565b610570565b34801561024557600080fd5b50610259610254366004610fb0565b6105cc565b6040516101619493929190610ff2565b34801561027557600080fd5b5061014d7f000000000000000000000000000000000000000000000000000000000000000081565b3480156102a957600080fd5b5061010b610614565b3480156102be57600080fd5b5061010b6102cd366004610f93565b610691565b3480156102de57600080fd5b506101b8610710565b61010b6107a0565b3480156102fb57600080fd5b5061010b61030a366004610f93565b610802565b610317610845565b604051621cb65b60e51b815263ffffffff821660048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690630396cb609034906024016000604051808303818588803b15801561037e57600080fd5b505af1158015610392573d6000803e3d6000fd5b505050505050565b6103a2610845565b60405163040b850f60e31b81526001600160a01b038381166004830152602482018390527f0000000000000000000000000000000000000000000000000000000000000000169063205c287890604401600060405180830381600087803b15801561037e57600080fd5b60606000610418610872565b6104238585856108e2565b915091505b935093915050565b60008335806020860135610447604088018861103e565b604051610455929190611085565b60405190819003902061046b606089018961103e565b604051610479929190611085565b604051908190039020608089013561049460e08b018b61103e565b6104a391603491601491611095565b6104ac916110bf565b604080516001600160a01b0390971660208801528601949094526060850192909252608084015260a08084019190915260c08084019290925287013560e0830152860135610100820152466101208201523061014082015265ffffffffffff80861661016083015284166101808201526101a001604051602081830303815290604052805190602001209150509392505050565b610548610845565b6105526000610a77565b565b61055c610872565b6105698585858585610ac7565b5050505050565b610578610845565b600180546001600160a01b0319166001600160a01b0383169081179091556040519081527f51d754ac8f7adf515a023f2c423e01ef97817c1af33cb63b36f1fe12fde2d91a9060200160405180910390a150565b60008036816105de8560348189611095565b8101906105eb91906110dd565b909450925085856105fe60346040611110565b610609928290611095565b949793965094505050565b61061c610845565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663bb9fe6bf6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561067757600080fd5b505af115801561068b573d6000803e3d6000fd5b50505050565b610699610845565b60405163611d2e7560e11b81526001600160a01b0382811660048301527f0000000000000000000000000000000000000000000000000000000000000000169063c23a5cea90602401600060405180830381600087803b1580156106fc57600080fd5b505af1158015610569573d6000803e3d6000fd5b6040516370a0823160e01b81523060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa158015610777573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061079b9190611131565b905090565b60405163b760faf960e01b81523060048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063b760faf99034906024016000604051808303818588803b1580156106fc57600080fd5b61080a610845565b6001600160a01b03811661083957604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b61084281610a77565b50565b6000546001600160a01b031633146105525760405163118cdaa760e01b8152336004820152602401610830565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146105525760405162461bcd60e51b815260206004820152601560248201527414d95b99195c881b9bdd08115b9d1c9e541bda5b9d605a1b6044820152606401610830565b60606000808036816108fa61025460e08b018b61103e565b9296509094509250905060408114806109135750604181145b610987576040805162461bcd60e51b81526020600482015260248101919091527f566572696679696e675061796d61737465723a20696e76616c6964207369676e60448201527f6174757265206c656e67746820696e207061796d6173746572416e64446174616064820152608401610830565b60006109ca6109978b8787610430565b7f19457468657265756d205369676e6564204d6573736167653a0a3332000000006000908152601c91909152603c902090565b9050610a0c8184848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610aff92505050565b6001546001600160a01b03908116911614610a4c57610a2d60018686610b2b565b6040518060200160405280600081525090965096505050505050610428565b610a5860008686610b2b565b6040805160208101909152600081529b909a5098505050505050505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60405162461bcd60e51b815260206004820152600d60248201526c6d757374206f7665727269646560981b6044820152606401610830565b600080600080610b0f8686610b63565b925092509250610b1f8282610bb0565b50909150505b92915050565b600060d08265ffffffffffff16901b60a08465ffffffffffff16901b85610b53576000610b56565b60015b60ff161717949350505050565b60008060008351604103610b9d5760208401516040850151606086015160001a610b8f88828585610c6d565b955095509550505050610ba9565b50508151600091506002905b9250925092565b6000826003811115610bc457610bc461114a565b03610bcd575050565b6001826003811115610be157610be161114a565b03610bff5760405163f645eedf60e01b815260040160405180910390fd5b6002826003811115610c1357610c1361114a565b03610c345760405163fce698f760e01b815260048101829052602401610830565b6003826003811115610c4857610c4861114a565b03610c69576040516335e2f38360e21b815260048101829052602401610830565b5050565b600080807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0841115610ca85750600091506003905082610d32565b604080516000808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa158015610cfc573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116610d2857506000925060019150829050610d32565b9250600091508190505b9450945094915050565b600060208284031215610d4e57600080fd5b813563ffffffff81168114610d6257600080fd5b9392505050565b6001600160a01b038116811461084257600080fd5b60008060408385031215610d9157600080fd5b8235610d9c81610d69565b946020939093013593505050565b60006101208284031215610dbd57600080fd5b50919050565b600080600060608486031215610dd857600080fd5b833567ffffffffffffffff811115610def57600080fd5b610dfb86828701610daa565b9660208601359650604090950135949350505050565b604081526000835180604084015260005b81811015610e3f5760208187018101516060868401015201610e22565b506000606082850101526060601f19601f8301168401019150508260208301529392505050565b803565ffffffffffff81168114610e7c57600080fd5b919050565b600080600060608486031215610e9657600080fd5b833567ffffffffffffffff811115610ead57600080fd5b610eb986828701610daa565b935050610ec860208501610e66565b9150610ed660408501610e66565b90509250925092565b60008083601f840112610ef157600080fd5b50813567ffffffffffffffff811115610f0957600080fd5b602083019150836020828501011115610f2157600080fd5b9250929050565b600080600080600060808688031215610f4057600080fd5b853560038110610f4f57600080fd5b9450602086013567ffffffffffffffff811115610f6b57600080fd5b610f7788828901610edf565b9699909850959660408101359660609091013595509350505050565b600060208284031215610fa557600080fd5b8135610d6281610d69565b60008060208385031215610fc357600080fd5b823567ffffffffffffffff811115610fda57600080fd5b610fe685828601610edf565b90969095509350505050565b600065ffffffffffff808716835280861660208401525060606040830152826060830152828460808401376000608084840101526080601f19601f850116830101905095945050505050565b6000808335601e1984360301811261105557600080fd5b83018035915067ffffffffffffffff82111561107057600080fd5b602001915036819003821315610f2157600080fd5b8183823760009101908152919050565b600080858511156110a557600080fd5b838611156110b257600080fd5b5050820193919092039150565b80356020831015610b2557600019602084900360031b1b1692915050565b600080604083850312156110f057600080fd5b6110f983610e66565b915061110760208401610e66565b90509250929050565b80820180821115610b2557634e487b7160e01b600052601160045260246000fd5b60006020828403121561114357600080fd5b5051919050565b634e487b7160e01b600052602160045260246000fdfea2646970667358221220c0b0e23d7a5c7f85952d0cc00029b567ca0b096cf89131df5d1d60aa8481c2ad64736f6c63430008170033", + "deployedBytecode": "0x6080604052600436106100f35760003560e01c806393b941211161008a578063c23a5cea11610059578063c23a5cea146102b2578063c399ec88146102d2578063d0e30db0146102e7578063f2fde38b146102ef57600080fd5b806393b941211461021957806394d4ad6014610239578063b0d691fe14610269578063bb9fe6bf1461029d57600080fd5b80635829c5f5116100c65780635829c5f514610198578063715018a6146101c65780637c627b21146101db5780638da5cb5b146101fb57600080fd5b80630396cb60146100f8578063205c28781461010d57806323d9ac9b1461012d57806352b7512c1461016a575b600080fd5b61010b610106366004610d3c565b61030f565b005b34801561011957600080fd5b5061010b610128366004610d7e565b61039a565b34801561013957600080fd5b5060015461014d906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561017657600080fd5b5061018a610185366004610dc3565b61040c565b604051610161929190610e11565b3480156101a457600080fd5b506101b86101b3366004610e81565b610430565b604051908152602001610161565b3480156101d257600080fd5b5061010b610540565b3480156101e757600080fd5b5061010b6101f6366004610f28565b610554565b34801561020757600080fd5b506000546001600160a01b031661014d565b34801561022557600080fd5b5061010b610234366004610f93565b610570565b34801561024557600080fd5b50610259610254366004610fb0565b6105cc565b6040516101619493929190610ff2565b34801561027557600080fd5b5061014d7f000000000000000000000000000000000000000000000000000000000000000081565b3480156102a957600080fd5b5061010b610614565b3480156102be57600080fd5b5061010b6102cd366004610f93565b610691565b3480156102de57600080fd5b506101b8610710565b61010b6107a0565b3480156102fb57600080fd5b5061010b61030a366004610f93565b610802565b610317610845565b604051621cb65b60e51b815263ffffffff821660048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690630396cb609034906024016000604051808303818588803b15801561037e57600080fd5b505af1158015610392573d6000803e3d6000fd5b505050505050565b6103a2610845565b60405163040b850f60e31b81526001600160a01b038381166004830152602482018390527f0000000000000000000000000000000000000000000000000000000000000000169063205c287890604401600060405180830381600087803b15801561037e57600080fd5b60606000610418610872565b6104238585856108e2565b915091505b935093915050565b60008335806020860135610447604088018861103e565b604051610455929190611085565b60405190819003902061046b606089018961103e565b604051610479929190611085565b604051908190039020608089013561049460e08b018b61103e565b6104a391603491601491611095565b6104ac916110bf565b604080516001600160a01b0390971660208801528601949094526060850192909252608084015260a08084019190915260c08084019290925287013560e0830152860135610100820152466101208201523061014082015265ffffffffffff80861661016083015284166101808201526101a001604051602081830303815290604052805190602001209150509392505050565b610548610845565b6105526000610a77565b565b61055c610872565b6105698585858585610ac7565b5050505050565b610578610845565b600180546001600160a01b0319166001600160a01b0383169081179091556040519081527f51d754ac8f7adf515a023f2c423e01ef97817c1af33cb63b36f1fe12fde2d91a9060200160405180910390a150565b60008036816105de8560348189611095565b8101906105eb91906110dd565b909450925085856105fe60346040611110565b610609928290611095565b949793965094505050565b61061c610845565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663bb9fe6bf6040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561067757600080fd5b505af115801561068b573d6000803e3d6000fd5b50505050565b610699610845565b60405163611d2e7560e11b81526001600160a01b0382811660048301527f0000000000000000000000000000000000000000000000000000000000000000169063c23a5cea90602401600060405180830381600087803b1580156106fc57600080fd5b505af1158015610569573d6000803e3d6000fd5b6040516370a0823160e01b81523060048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906370a0823190602401602060405180830381865afa158015610777573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061079b9190611131565b905090565b60405163b760faf960e01b81523060048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063b760faf99034906024016000604051808303818588803b1580156106fc57600080fd5b61080a610845565b6001600160a01b03811661083957604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b61084281610a77565b50565b6000546001600160a01b031633146105525760405163118cdaa760e01b8152336004820152602401610830565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146105525760405162461bcd60e51b815260206004820152601560248201527414d95b99195c881b9bdd08115b9d1c9e541bda5b9d605a1b6044820152606401610830565b60606000808036816108fa61025460e08b018b61103e565b9296509094509250905060408114806109135750604181145b610987576040805162461bcd60e51b81526020600482015260248101919091527f566572696679696e675061796d61737465723a20696e76616c6964207369676e60448201527f6174757265206c656e67746820696e207061796d6173746572416e64446174616064820152608401610830565b60006109ca6109978b8787610430565b7f19457468657265756d205369676e6564204d6573736167653a0a3332000000006000908152601c91909152603c902090565b9050610a0c8184848080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250610aff92505050565b6001546001600160a01b03908116911614610a4c57610a2d60018686610b2b565b6040518060200160405280600081525090965096505050505050610428565b610a5860008686610b2b565b6040805160208101909152600081529b909a5098505050505050505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60405162461bcd60e51b815260206004820152600d60248201526c6d757374206f7665727269646560981b6044820152606401610830565b600080600080610b0f8686610b63565b925092509250610b1f8282610bb0565b50909150505b92915050565b600060d08265ffffffffffff16901b60a08465ffffffffffff16901b85610b53576000610b56565b60015b60ff161717949350505050565b60008060008351604103610b9d5760208401516040850151606086015160001a610b8f88828585610c6d565b955095509550505050610ba9565b50508151600091506002905b9250925092565b6000826003811115610bc457610bc461114a565b03610bcd575050565b6001826003811115610be157610be161114a565b03610bff5760405163f645eedf60e01b815260040160405180910390fd5b6002826003811115610c1357610c1361114a565b03610c345760405163fce698f760e01b815260048101829052602401610830565b6003826003811115610c4857610c4861114a565b03610c69576040516335e2f38360e21b815260048101829052602401610830565b5050565b600080807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0841115610ca85750600091506003905082610d32565b604080516000808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa158015610cfc573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116610d2857506000925060019150829050610d32565b9250600091508190505b9450945094915050565b600060208284031215610d4e57600080fd5b813563ffffffff81168114610d6257600080fd5b9392505050565b6001600160a01b038116811461084257600080fd5b60008060408385031215610d9157600080fd5b8235610d9c81610d69565b946020939093013593505050565b60006101208284031215610dbd57600080fd5b50919050565b600080600060608486031215610dd857600080fd5b833567ffffffffffffffff811115610def57600080fd5b610dfb86828701610daa565b9660208601359650604090950135949350505050565b604081526000835180604084015260005b81811015610e3f5760208187018101516060868401015201610e22565b506000606082850101526060601f19601f8301168401019150508260208301529392505050565b803565ffffffffffff81168114610e7c57600080fd5b919050565b600080600060608486031215610e9657600080fd5b833567ffffffffffffffff811115610ead57600080fd5b610eb986828701610daa565b935050610ec860208501610e66565b9150610ed660408501610e66565b90509250925092565b60008083601f840112610ef157600080fd5b50813567ffffffffffffffff811115610f0957600080fd5b602083019150836020828501011115610f2157600080fd5b9250929050565b600080600080600060808688031215610f4057600080fd5b853560038110610f4f57600080fd5b9450602086013567ffffffffffffffff811115610f6b57600080fd5b610f7788828901610edf565b9699909850959660408101359660609091013595509350505050565b600060208284031215610fa557600080fd5b8135610d6281610d69565b60008060208385031215610fc357600080fd5b823567ffffffffffffffff811115610fda57600080fd5b610fe685828601610edf565b90969095509350505050565b600065ffffffffffff808716835280861660208401525060606040830152826060830152828460808401376000608084840101526080601f19601f850116830101905095945050505050565b6000808335601e1984360301811261105557600080fd5b83018035915067ffffffffffffffff82111561107057600080fd5b602001915036819003821315610f2157600080fd5b8183823760009101908152919050565b600080858511156110a557600080fd5b838611156110b257600080fd5b5050820193919092039150565b80356020831015610b2557600019602084900360031b1b1692915050565b600080604083850312156110f057600080fd5b6110f983610e66565b915061110760208401610e66565b90509250929050565b80820180821115610b2557634e487b7160e01b600052601160045260246000fd5b60006020828403121561114357600080fd5b5051919050565b634e487b7160e01b600052602160045260246000fdfea2646970667358221220c0b0e23d7a5c7f85952d0cc00029b567ca0b096cf89131df5d1d60aa8481c2ad64736f6c63430008170033", + "devdoc": { + "errors": { + "ECDSAInvalidSignature()": [ + { + "details": "The signature derives the `address(0)`." + } + ], + "ECDSAInvalidSignatureLength(uint256)": [ + { + "details": "The signature has an invalid length." + } + ], + "ECDSAInvalidSignatureS(bytes32)": [ + { + "details": "The signature has an S value that is in the upper half order." + } + ], + "OwnableInvalidOwner(address)": [ + { + "details": "The owner is not a valid owner account. (eg. `address(0)`)" + } + ], + "OwnableUnauthorizedAccount(address)": [ + { + "details": "The caller account is not authorized to perform an operation." + } + ] + }, + "kind": "dev", + "methods": { + "addStake(uint32)": { + "params": { + "unstakeDelaySec": "- The unstake delay for this paymaster. Can only be increased." + } + }, + "owner()": { + "details": "Returns the address of the current owner." + }, + "postOp(uint8,bytes,uint256,uint256)": { + "params": { + "actualGasCost": "- Actual gas used so far (without this postOp call).", + "actualUserOpFeePerGas": "- the gas price this UserOp pays. This value is based on the UserOp's maxFeePerGas and maxPriorityFee (and basefee) It is not the same as tx.gasprice, which is what the bundler pays.", + "context": "- The context value returned by validatePaymasterUserOp", + "mode": "- Enum with the following options: opSucceeded - User operation succeeded. opReverted - User op reverted. The paymaster still has to pay for gas. postOpReverted - never passed in a call to postOp()." + } + }, + "renounceOwnership()": { + "details": "Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner." + }, + "transferOwnership(address)": { + "details": "Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner." + }, + "validatePaymasterUserOp((address,uint256,bytes,bytes,bytes32,uint256,bytes32,bytes,bytes),bytes32,uint256)": { + "params": { + "maxCost": "- The maximum cost of this transaction (based on maximum gas and gas price from userOp).", + "userOp": "- The user operation.", + "userOpHash": "- Hash of the user's request data." + }, + "returns": { + "context": " - Value to send to a postOp. Zero length to signify postOp is not required.", + "validationData": "- Signature and time-range of this operation, encoded the same as the return value of validateUserOperation. <20-byte> sigAuthorizer - 0 for valid signature, 1 to mark signature failure, other values are invalid for paymaster. <6-byte> validUntil - last timestamp this operation is valid. 0 for \"indefinite\" <6-byte> validAfter - first timestamp this operation is valid Note that the validation code cannot use block.timestamp (or block.number) directly." + } + }, + "withdrawStake(address)": { + "params": { + "withdrawAddress": "- The address to send withdrawn value." + } + }, + "withdrawTo(address,uint256)": { + "params": { + "amount": "- Amount to withdraw.", + "withdrawAddress": "- Target to send to." + } + } + }, + "version": 1 + }, + "userdoc": { + "kind": "user", + "methods": { + "addStake(uint32)": { + "notice": "Add stake for this paymaster. This method can also carry eth value to add to the current stake." + }, + "deposit()": { + "notice": "Add a deposit for this paymaster, used for paying for transaction fees." + }, + "getDeposit()": { + "notice": "Return current paymaster's deposit on the entryPoint." + }, + "getHash((address,uint256,bytes,bytes,bytes32,uint256,bytes32,bytes,bytes),uint48,uint48)": { + "notice": "return the hash we're going to sign off-chain (and validate on-chain) this method is called by the off-chain service, to sign the request. it is called on-chain from the validatePaymasterUserOp, to validate the signature. note that this signature covers all fields of the UserOperation, except the \"paymasterAndData\", which will carry the signature itself." + }, + "postOp(uint8,bytes,uint256,uint256)": { + "notice": "Post-operation handler. Must verify sender is the entryPoint." + }, + "unlockStake()": { + "notice": "Unlock the stake, in order to withdraw it. The paymaster can't serve requests once unlocked, until it calls addStake again" + }, + "validatePaymasterUserOp((address,uint256,bytes,bytes,bytes32,uint256,bytes32,bytes,bytes),bytes32,uint256)": { + "notice": "Payment validation: check if paymaster agrees to pay. Must verify sender is the entryPoint. Revert to reject this request. Note that bundlers will reject this method if it changes the state, unless the paymaster is trusted (whitelisted). The paymaster pre-pays using its deposit, and receive back a refund after the postOp method returns." + }, + "withdrawStake(address)": { + "notice": "Withdraw the entire paymaster's stake. stake must be unlocked first (and then wait for the unstakeDelay to be over)" + }, + "withdrawTo(address,uint256)": { + "notice": "Withdraw value from the deposit." + } + }, + "notice": "A sample paymaster that uses external service to decide whether to pay for the UserOp. The paymaster trusts an external signer to sign the transaction. The calling user must pass the UserOp to that external signer first, which performs whatever off-chain verification before signing the UserOp. Note that this signature is NOT a replacement for the account-specific signature: - the paymaster checks a signature to agree to PAY for GAS. - the account checks a signature to prove identity and account ownership.", + "version": 1 + }, + "storageLayout": { + "storage": [ + { + "astId": 8, + "contract": "src/paymaster/VerifyingPaymaster.sol:VerifyingPaymaster", + "label": "_owner", + "offset": 0, + "slot": "0", + "type": "t_address" + }, + { + "astId": 7155, + "contract": "src/paymaster/VerifyingPaymaster.sol:VerifyingPaymaster", + "label": "verifyingSigner", + "offset": 0, + "slot": "1", + "type": "t_address" + } + ], + "types": { + "t_address": { + "encoding": "inplace", + "label": "address", + "numberOfBytes": "20" + } + } + } +} \ No newline at end of file diff --git a/deployments/suaveToliman/solcInputs/d3577e83208e9ea218cee1e51dba2e35.json b/deployments/suaveToliman/solcInputs/d3577e83208e9ea218cee1e51dba2e35.json new file mode 100644 index 0000000..11c25de --- /dev/null +++ b/deployments/suaveToliman/solcInputs/d3577e83208e9ea218cee1e51dba2e35.json @@ -0,0 +1,171 @@ +{ + "language": "Solidity", + "sources": { + "@openzeppelin/contracts/access/Ownable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\npragma solidity ^0.8.20;\n\nimport {Context} from \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n /**\n * @dev The caller account is not authorized to perform an operation.\n */\n error OwnableUnauthorizedAccount(address account);\n\n /**\n * @dev The owner is not a valid owner account. (eg. `address(0)`)\n */\n error OwnableInvalidOwner(address owner);\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n */\n constructor(address initialOwner) {\n if (initialOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(initialOwner);\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n if (owner() != _msgSender()) {\n revert OwnableUnauthorizedAccount(_msgSender());\n }\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n if (newOwner == address(0)) {\n revert OwnableInvalidOwner(address(0));\n }\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n" + }, + "@openzeppelin/contracts/interfaces/draft-IERC1822.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC1822.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\n * proxy whose upgrades are fully controlled by the current implementation.\n */\ninterface IERC1822Proxiable {\n /**\n * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\n * address.\n *\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\n * function revert if invoked through a proxy.\n */\n function proxiableUUID() external view returns (bytes32);\n}\n" + }, + "@openzeppelin/contracts/proxy/beacon/IBeacon.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (proxy/beacon/IBeacon.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\n */\ninterface IBeacon {\n /**\n * @dev Must return an address that can be used as a delegate call target.\n *\n * {UpgradeableBeacon} will check that this address is a contract.\n */\n function implementation() external view returns (address);\n}\n" + }, + "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (proxy/ERC1967/ERC1967Utils.sol)\n\npragma solidity ^0.8.20;\n\nimport {IBeacon} from \"../beacon/IBeacon.sol\";\nimport {Address} from \"../../utils/Address.sol\";\nimport {StorageSlot} from \"../../utils/StorageSlot.sol\";\n\n/**\n * @dev This abstract contract provides getters and event emitting update functions for\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\n */\nlibrary ERC1967Utils {\n // We re-declare ERC-1967 events here because they can't be used directly from IERC1967.\n // This will be fixed in Solidity 0.8.21. At that point we should remove these events.\n /**\n * @dev Emitted when the implementation is upgraded.\n */\n event Upgraded(address indexed implementation);\n\n /**\n * @dev Emitted when the admin account has changed.\n */\n event AdminChanged(address previousAdmin, address newAdmin);\n\n /**\n * @dev Emitted when the beacon is changed.\n */\n event BeaconUpgraded(address indexed beacon);\n\n /**\n * @dev Storage slot with the address of the current implementation.\n * This is the keccak-256 hash of \"eip1967.proxy.implementation\" subtracted by 1.\n */\n // solhint-disable-next-line private-vars-leading-underscore\n bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n\n /**\n * @dev The `implementation` of the proxy is invalid.\n */\n error ERC1967InvalidImplementation(address implementation);\n\n /**\n * @dev The `admin` of the proxy is invalid.\n */\n error ERC1967InvalidAdmin(address admin);\n\n /**\n * @dev The `beacon` of the proxy is invalid.\n */\n error ERC1967InvalidBeacon(address beacon);\n\n /**\n * @dev An upgrade function sees `msg.value > 0` that may be lost.\n */\n error ERC1967NonPayable();\n\n /**\n * @dev Returns the current implementation address.\n */\n function getImplementation() internal view returns (address) {\n return StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the EIP1967 implementation slot.\n */\n function _setImplementation(address newImplementation) private {\n if (newImplementation.code.length == 0) {\n revert ERC1967InvalidImplementation(newImplementation);\n }\n StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation;\n }\n\n /**\n * @dev Performs implementation upgrade with additional setup call if data is nonempty.\n * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected\n * to avoid stuck value in the contract.\n *\n * Emits an {IERC1967-Upgraded} event.\n */\n function upgradeToAndCall(address newImplementation, bytes memory data) internal {\n _setImplementation(newImplementation);\n emit Upgraded(newImplementation);\n\n if (data.length > 0) {\n Address.functionDelegateCall(newImplementation, data);\n } else {\n _checkNonPayable();\n }\n }\n\n /**\n * @dev Storage slot with the admin of the contract.\n * This is the keccak-256 hash of \"eip1967.proxy.admin\" subtracted by 1.\n */\n // solhint-disable-next-line private-vars-leading-underscore\n bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n /**\n * @dev Returns the current admin.\n *\n * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using\n * the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\n */\n function getAdmin() internal view returns (address) {\n return StorageSlot.getAddressSlot(ADMIN_SLOT).value;\n }\n\n /**\n * @dev Stores a new address in the EIP1967 admin slot.\n */\n function _setAdmin(address newAdmin) private {\n if (newAdmin == address(0)) {\n revert ERC1967InvalidAdmin(address(0));\n }\n StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin;\n }\n\n /**\n * @dev Changes the admin of the proxy.\n *\n * Emits an {IERC1967-AdminChanged} event.\n */\n function changeAdmin(address newAdmin) internal {\n emit AdminChanged(getAdmin(), newAdmin);\n _setAdmin(newAdmin);\n }\n\n /**\n * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\n * This is the keccak-256 hash of \"eip1967.proxy.beacon\" subtracted by 1.\n */\n // solhint-disable-next-line private-vars-leading-underscore\n bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\n\n /**\n * @dev Returns the current beacon.\n */\n function getBeacon() internal view returns (address) {\n return StorageSlot.getAddressSlot(BEACON_SLOT).value;\n }\n\n /**\n * @dev Stores a new beacon in the EIP1967 beacon slot.\n */\n function _setBeacon(address newBeacon) private {\n if (newBeacon.code.length == 0) {\n revert ERC1967InvalidBeacon(newBeacon);\n }\n\n StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon;\n\n address beaconImplementation = IBeacon(newBeacon).implementation();\n if (beaconImplementation.code.length == 0) {\n revert ERC1967InvalidImplementation(beaconImplementation);\n }\n }\n\n /**\n * @dev Change the beacon and trigger a setup call if data is nonempty.\n * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected\n * to avoid stuck value in the contract.\n *\n * Emits an {IERC1967-BeaconUpgraded} event.\n *\n * CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since\n * it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for\n * efficiency.\n */\n function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal {\n _setBeacon(newBeacon);\n emit BeaconUpgraded(newBeacon);\n\n if (data.length > 0) {\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\n } else {\n _checkNonPayable();\n }\n }\n\n /**\n * @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract\n * if an upgrade doesn't perform an initialization call.\n */\n function _checkNonPayable() private {\n if (msg.value > 0) {\n revert ERC1967NonPayable();\n }\n }\n}\n" + }, + "@openzeppelin/contracts/proxy/utils/Initializable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Storage of the initializable contract.\n *\n * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions\n * when using with upgradeable contracts.\n *\n * @custom:storage-location erc7201:openzeppelin.storage.Initializable\n */\n struct InitializableStorage {\n /**\n * @dev Indicates that the contract has been initialized.\n */\n uint64 _initialized;\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool _initializing;\n }\n\n // keccak256(abi.encode(uint256(keccak256(\"openzeppelin.storage.Initializable\")) - 1)) & ~bytes32(uint256(0xff))\n bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;\n\n /**\n * @dev The contract is already initialized.\n */\n error InvalidInitialization();\n\n /**\n * @dev The contract is not initializing.\n */\n error NotInitializing();\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint64 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any\n * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in\n * production.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n // Cache values to avoid duplicated sloads\n bool isTopLevelCall = !$._initializing;\n uint64 initialized = $._initialized;\n\n // Allowed calls:\n // - initialSetup: the contract is not in the initializing state and no previous version was\n // initialized\n // - construction: the contract is initialized at version 1 (no reininitialization) and the\n // current contract is just being deployed\n bool initialSetup = initialized == 0 && isTopLevelCall;\n bool construction = initialized == 1 && address(this).code.length == 0;\n\n if (!initialSetup && !construction) {\n revert InvalidInitialization();\n }\n $._initialized = 1;\n if (isTopLevelCall) {\n $._initializing = true;\n }\n _;\n if (isTopLevelCall) {\n $._initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint64 version) {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing || $._initialized >= version) {\n revert InvalidInitialization();\n }\n $._initialized = version;\n $._initializing = true;\n _;\n $._initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n _checkInitializing();\n _;\n }\n\n /**\n * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.\n */\n function _checkInitializing() internal view virtual {\n if (!_isInitializing()) {\n revert NotInitializing();\n }\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n // solhint-disable-next-line var-name-mixedcase\n InitializableStorage storage $ = _getInitializableStorage();\n\n if ($._initializing) {\n revert InvalidInitialization();\n }\n if ($._initialized != type(uint64).max) {\n $._initialized = type(uint64).max;\n emit Initialized(type(uint64).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint64) {\n return _getInitializableStorage()._initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _getInitializableStorage()._initializing;\n }\n\n /**\n * @dev Returns a pointer to the storage namespace.\n */\n // solhint-disable-next-line var-name-mixedcase\n function _getInitializableStorage() private pure returns (InitializableStorage storage $) {\n assembly {\n $.slot := INITIALIZABLE_STORAGE\n }\n }\n}\n" + }, + "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/UUPSUpgradeable.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC1822Proxiable} from \"../../interfaces/draft-IERC1822.sol\";\nimport {ERC1967Utils} from \"../ERC1967/ERC1967Utils.sol\";\n\n/**\n * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an\n * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.\n *\n * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is\n * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing\n * `UUPSUpgradeable` with a custom implementation of upgrades.\n *\n * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.\n */\nabstract contract UUPSUpgradeable is IERC1822Proxiable {\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address private immutable __self = address(this);\n\n /**\n * @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgradeTo(address)`\n * and `upgradeToAndCall(address,bytes)` are present, and `upgradeTo` must be used if no function should be called,\n * while `upgradeToAndCall` will invoke the `receive` function if the second argument is the empty byte string.\n * If the getter returns `\"5.0.0\"`, only `upgradeToAndCall(address,bytes)` is present, and the second argument must\n * be the empty byte string if no function should be called, making it impossible to invoke the `receive` function\n * during an upgrade.\n */\n string public constant UPGRADE_INTERFACE_VERSION = \"5.0.0\";\n\n /**\n * @dev The call is from an unauthorized context.\n */\n error UUPSUnauthorizedCallContext();\n\n /**\n * @dev The storage `slot` is unsupported as a UUID.\n */\n error UUPSUnsupportedProxiableUUID(bytes32 slot);\n\n /**\n * @dev Check that the execution is being performed through a delegatecall call and that the execution context is\n * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case\n * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a\n * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to\n * fail.\n */\n modifier onlyProxy() {\n _checkProxy();\n _;\n }\n\n /**\n * @dev Check that the execution is not being performed through a delegate call. This allows a function to be\n * callable on the implementing contract but not through proxies.\n */\n modifier notDelegated() {\n _checkNotDelegated();\n _;\n }\n\n /**\n * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the\n * implementation. It is used to validate the implementation's compatibility when performing an upgrade.\n *\n * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\n * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\n * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.\n */\n function proxiableUUID() external view virtual notDelegated returns (bytes32) {\n return ERC1967Utils.IMPLEMENTATION_SLOT;\n }\n\n /**\n * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call\n * encoded in `data`.\n *\n * Calls {_authorizeUpgrade}.\n *\n * Emits an {Upgraded} event.\n *\n * @custom:oz-upgrades-unsafe-allow-reachable delegatecall\n */\n function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy {\n _authorizeUpgrade(newImplementation);\n _upgradeToAndCallUUPS(newImplementation, data);\n }\n\n /**\n * @dev Reverts if the execution is not performed via delegatecall or the execution\n * context is not of a proxy with an ERC1967-compliant implementation pointing to self.\n * See {_onlyProxy}.\n */\n function _checkProxy() internal view virtual {\n if (\n address(this) == __self || // Must be called through delegatecall\n ERC1967Utils.getImplementation() != __self // Must be called through an active proxy\n ) {\n revert UUPSUnauthorizedCallContext();\n }\n }\n\n /**\n * @dev Reverts if the execution is performed via delegatecall.\n * See {notDelegated}.\n */\n function _checkNotDelegated() internal view virtual {\n if (address(this) != __self) {\n // Must not be called through delegatecall\n revert UUPSUnauthorizedCallContext();\n }\n }\n\n /**\n * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by\n * {upgradeToAndCall}.\n *\n * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.\n *\n * ```solidity\n * function _authorizeUpgrade(address) internal onlyOwner {}\n * ```\n */\n function _authorizeUpgrade(address newImplementation) internal virtual;\n\n /**\n * @dev Performs an implementation upgrade with a security check for UUPS proxies, and additional setup call.\n *\n * As a security check, {proxiableUUID} is invoked in the new implementation, and the return value\n * is expected to be the implementation slot in ERC1967.\n *\n * Emits an {IERC1967-Upgraded} event.\n */\n function _upgradeToAndCallUUPS(address newImplementation, bytes memory data) private {\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\n if (slot != ERC1967Utils.IMPLEMENTATION_SLOT) {\n revert UUPSUnsupportedProxiableUUID(slot);\n }\n ERC1967Utils.upgradeToAndCall(newImplementation, data);\n } catch {\n // The implementation is not UUPS\n revert ERC1967Utils.ERC1967InvalidImplementation(newImplementation);\n }\n }\n}\n" + }, + "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/IERC1155Receiver.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC165} from \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Interface that must be implemented by smart contracts in order to receive\n * ERC-1155 token transfers.\n */\ninterface IERC1155Receiver is IERC165 {\n /**\n * @dev Handles the receipt of a single ERC1155 token type. This function is\n * called at the end of a `safeTransferFrom` after the balance has been updated.\n *\n * NOTE: To accept the transfer, this must return\n * `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))`\n * (i.e. 0xf23a6e61, or its own function selector).\n *\n * @param operator The address which initiated the transfer (i.e. msg.sender)\n * @param from The address which previously owned the token\n * @param id The ID of the token being transferred\n * @param value The amount of tokens being transferred\n * @param data Additional data with no specified format\n * @return `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))` if transfer is allowed\n */\n function onERC1155Received(\n address operator,\n address from,\n uint256 id,\n uint256 value,\n bytes calldata data\n ) external returns (bytes4);\n\n /**\n * @dev Handles the receipt of a multiple ERC1155 token types. This function\n * is called at the end of a `safeBatchTransferFrom` after the balances have\n * been updated.\n *\n * NOTE: To accept the transfer(s), this must return\n * `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))`\n * (i.e. 0xbc197c81, or its own function selector).\n *\n * @param operator The address which initiated the batch transfer (i.e. msg.sender)\n * @param from The address which previously owned the token\n * @param ids An array containing ids of each token being transferred (order and length must match values array)\n * @param values An array containing amounts of each token being transferred (order and length must match ids array)\n * @param data Additional data with no specified format\n * @return `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))` if transfer is allowed\n */\n function onERC1155BatchReceived(\n address operator,\n address from,\n uint256[] calldata ids,\n uint256[] calldata values,\n bytes calldata data\n ) external returns (bytes4);\n}\n" + }, + "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n /**\n * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n * by `operator` from `from`, this function is called.\n *\n * It must return its Solidity selector to confirm the token transfer.\n * If any other value is returned or the interface is not implemented by the recipient, the transfer will be\n * reverted.\n *\n * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n */\n function onERC721Received(\n address operator,\n address from,\n uint256 tokenId,\n bytes calldata data\n ) external returns (bytes4);\n}\n" + }, + "@openzeppelin/contracts/utils/Address.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev The ETH balance of the account is not enough to perform the operation.\n */\n error AddressInsufficientBalance(address account);\n\n /**\n * @dev There's no code at `target` (it is not a contract).\n */\n error AddressEmptyCode(address target);\n\n /**\n * @dev A call to an address target failed. The target may have reverted.\n */\n error FailedInnerCall();\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n if (address(this).balance < amount) {\n revert AddressInsufficientBalance(address(this));\n }\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n if (!success) {\n revert FailedInnerCall();\n }\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason or custom error, it is bubbled\n * up by this function (like regular Solidity function calls). However, if\n * the call reverted with no returned reason, this function reverts with a\n * {FailedInnerCall} error.\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n if (address(this).balance < value) {\n revert AddressInsufficientBalance(address(this));\n }\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target\n * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an\n * unsuccessful call.\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata\n ) internal view returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n // only check if target is a contract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n if (returndata.length == 0 && target.code.length == 0) {\n revert AddressEmptyCode(target);\n }\n return returndata;\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the\n * revert reason or with a default {FailedInnerCall} error.\n */\n function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {\n if (!success) {\n _revert(returndata);\n } else {\n return returndata;\n }\n }\n\n /**\n * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.\n */\n function _revert(bytes memory returndata) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert FailedInnerCall();\n }\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Context.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Context.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/cryptography/ECDSA.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n enum RecoverError {\n NoError,\n InvalidSignature,\n InvalidSignatureLength,\n InvalidSignatureS\n }\n\n /**\n * @dev The signature derives the `address(0)`.\n */\n error ECDSAInvalidSignature();\n\n /**\n * @dev The signature has an invalid length.\n */\n error ECDSAInvalidSignatureLength(uint256 length);\n\n /**\n * @dev The signature has an S value that is in the upper half order.\n */\n error ECDSAInvalidSignatureS(bytes32 s);\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not\n * return address(0) without also returning an error description. Errors are documented using an enum (error type)\n * and a bytes32 providing additional information about the error.\n *\n * If no error is returned, then the address can be used for verification purposes.\n *\n * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.\n *\n * Documentation for signature generation:\n * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError, bytes32) {\n if (signature.length == 65) {\n bytes32 r;\n bytes32 s;\n uint8 v;\n // ecrecover takes the signature parameters, and the only way to get them\n // currently is to use assembly.\n /// @solidity memory-safe-assembly\n assembly {\n r := mload(add(signature, 0x20))\n s := mload(add(signature, 0x40))\n v := byte(0, mload(add(signature, 0x60)))\n }\n return tryRecover(hash, v, r, s);\n } else {\n return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length));\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature`. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:\n * this function rejects them by requiring the `s` value to be in the lower\n * half order, and the `v` value to be either 27 or 28.\n *\n * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n * verification to be secure: it is possible to craft signatures that\n * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n * this is by receiving a hash of the original message (which may otherwise\n * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature);\n _throwError(error, errorArg);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n *\n * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n */\n function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError, bytes32) {\n unchecked {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n // We do not check for an overflow here since the shift operation results in 0 or 1.\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n */\n function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {\n (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs);\n _throwError(error, errorArg);\n return recovered;\n }\n\n /**\n * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function tryRecover(\n bytes32 hash,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal pure returns (address, RecoverError, bytes32) {\n // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n //\n // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n // these malleable signatures as well.\n if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n return (address(0), RecoverError.InvalidSignatureS, s);\n }\n\n // If the signature is valid (and not malleable), return the signer address\n address signer = ecrecover(hash, v, r, s);\n if (signer == address(0)) {\n return (address(0), RecoverError.InvalidSignature, bytes32(0));\n }\n\n return (signer, RecoverError.NoError, bytes32(0));\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `v`,\n * `r` and `s` signature fields separately.\n */\n function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {\n (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s);\n _throwError(error, errorArg);\n return recovered;\n }\n\n /**\n * @dev Optionally reverts with the corresponding custom error according to the `error` argument provided.\n */\n function _throwError(RecoverError error, bytes32 errorArg) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert ECDSAInvalidSignature();\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert ECDSAInvalidSignatureLength(uint256(errorArg));\n } else if (error == RecoverError.InvalidSignatureS) {\n revert ECDSAInvalidSignatureS(errorArg);\n }\n }\n}\n" + }, + "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MessageHashUtils.sol)\n\npragma solidity ^0.8.20;\n\nimport {Strings} from \"../Strings.sol\";\n\n/**\n * @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing.\n *\n * The library provides methods for generating a hash of a message that conforms to the\n * https://eips.ethereum.org/EIPS/eip-191[EIP 191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712]\n * specifications.\n */\nlibrary MessageHashUtils {\n /**\n * @dev Returns the keccak256 digest of an EIP-191 signed data with version\n * `0x45` (`personal_sign` messages).\n *\n * The digest is calculated by prefixing a bytes32 `messageHash` with\n * `\"\\x19Ethereum Signed Message:\\n32\"` and hashing the result. It corresponds with the\n * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.\n *\n * NOTE: The `messageHash` parameter is intended to be the result of hashing a raw message with\n * keccak256, although any bytes32 value can be safely used because the final digest will\n * be re-hashed.\n *\n * See {ECDSA-recover}.\n */\n function toEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32 digest) {\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x00, \"\\x19Ethereum Signed Message:\\n32\") // 32 is the bytes-length of messageHash\n mstore(0x1c, messageHash) // 0x1c (28) is the length of the prefix\n digest := keccak256(0x00, 0x3c) // 0x3c is the length of the prefix (0x1c) + messageHash (0x20)\n }\n }\n\n /**\n * @dev Returns the keccak256 digest of an EIP-191 signed data with version\n * `0x45` (`personal_sign` messages).\n *\n * The digest is calculated by prefixing an arbitrary `message` with\n * `\"\\x19Ethereum Signed Message:\\n\" + len(message)` and hashing the result. It corresponds with the\n * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method.\n *\n * See {ECDSA-recover}.\n */\n function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32) {\n return\n keccak256(bytes.concat(\"\\x19Ethereum Signed Message:\\n\", bytes(Strings.toString(message.length)), message));\n }\n\n /**\n * @dev Returns the keccak256 digest of an EIP-191 signed data with version\n * `0x00` (data with intended validator).\n *\n * The digest is calculated by prefixing an arbitrary `data` with `\"\\x19\\x00\"` and the intended\n * `validator` address. Then hashing the result.\n *\n * See {ECDSA-recover}.\n */\n function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(hex\"19_00\", validator, data));\n }\n\n /**\n * @dev Returns the keccak256 digest of an EIP-712 typed data (EIP-191 version `0x01`).\n *\n * The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with\n * `\\x19\\x01` and hashing the result. It corresponds to the hash signed by the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712.\n *\n * See {ECDSA-recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) {\n /// @solidity memory-safe-assembly\n assembly {\n let ptr := mload(0x40)\n mstore(ptr, hex\"19_01\")\n mstore(add(ptr, 0x02), domainSeparator)\n mstore(add(ptr, 0x22), structHash)\n digest := keccak256(ptr, 0x42)\n }\n }\n}\n" + }, + "@openzeppelin/contracts/utils/introspection/IERC165.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n /**\n * @dev Returns true if this contract implements the interface defined by\n * `interfaceId`. See the corresponding\n * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n * to learn more about how these ids are created.\n *\n * This function call must use less than 30 000 gas.\n */\n function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n" + }, + "@openzeppelin/contracts/utils/math/Math.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n /**\n * @dev Muldiv operation overflow.\n */\n error MathOverflowedMulDiv();\n\n enum Rounding {\n Floor, // Toward negative infinity\n Ceil, // Toward positive infinity\n Trunc, // Toward zero\n Expand // Away from zero\n }\n\n /**\n * @dev Returns the addition of two unsigned integers, with an overflow flag.\n */\n function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n uint256 c = a + b;\n if (c < a) return (false, 0);\n return (true, c);\n }\n }\n\n /**\n * @dev Returns the subtraction of two unsigned integers, with an overflow flag.\n */\n function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b > a) return (false, 0);\n return (true, a - b);\n }\n }\n\n /**\n * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\n */\n function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n // benefit is lost if 'b' is also tested.\n // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n if (a == 0) return (true, 0);\n uint256 c = a * b;\n if (c / a != b) return (false, 0);\n return (true, c);\n }\n }\n\n /**\n * @dev Returns the division of two unsigned integers, with a division by zero flag.\n */\n function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n return (true, a / b);\n }\n }\n\n /**\n * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\n */\n function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n unchecked {\n if (b == 0) return (false, 0);\n return (true, a % b);\n }\n }\n\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two numbers.\n */\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two numbers. The result is rounded towards\n * zero.\n */\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b) / 2 can overflow.\n return (a & b) + (a ^ b) / 2;\n }\n\n /**\n * @dev Returns the ceiling of the division of two numbers.\n *\n * This differs from standard division with `/` in that it rounds towards infinity instead\n * of rounding towards zero.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n if (b == 0) {\n // Guarantee the same behavior as in a regular Solidity division.\n return a / b;\n }\n\n // (a + b - 1) / b can overflow on addition, so we distribute.\n return a == 0 ? 0 : (a - 1) / b + 1;\n }\n\n /**\n * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or\n * denominator == 0.\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by\n * Uniswap Labs also under MIT license.\n */\n function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\n unchecked {\n // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n // variables such that product = prod1 * 2^256 + prod0.\n uint256 prod0 = x * y; // Least significant 256 bits of the product\n uint256 prod1; // Most significant 256 bits of the product\n assembly {\n let mm := mulmod(x, y, not(0))\n prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n }\n\n // Handle non-overflow cases, 256 by 256 division.\n if (prod1 == 0) {\n // Solidity will revert if denominator == 0, unlike the div opcode on its own.\n // The surrounding unchecked block does not change this fact.\n // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\n return prod0 / denominator;\n }\n\n // Make sure the result is less than 2^256. Also prevents denominator == 0.\n if (denominator <= prod1) {\n revert MathOverflowedMulDiv();\n }\n\n ///////////////////////////////////////////////\n // 512 by 256 division.\n ///////////////////////////////////////////////\n\n // Make division exact by subtracting the remainder from [prod1 prod0].\n uint256 remainder;\n assembly {\n // Compute remainder using mulmod.\n remainder := mulmod(x, y, denominator)\n\n // Subtract 256 bit number from 512 bit number.\n prod1 := sub(prod1, gt(remainder, prod0))\n prod0 := sub(prod0, remainder)\n }\n\n // Factor powers of two out of denominator and compute largest power of two divisor of denominator.\n // Always >= 1. See https://cs.stackexchange.com/q/138556/92363.\n\n uint256 twos = denominator & (0 - denominator);\n assembly {\n // Divide denominator by twos.\n denominator := div(denominator, twos)\n\n // Divide [prod1 prod0] by twos.\n prod0 := div(prod0, twos)\n\n // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n twos := add(div(sub(0, twos), twos), 1)\n }\n\n // Shift in bits from prod1 into prod0.\n prod0 |= prod1 * twos;\n\n // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n // four bits. That is, denominator * inv = 1 mod 2^4.\n uint256 inverse = (3 * denominator) ^ 2;\n\n // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also\n // works in modular arithmetic, doubling the correct bits in each step.\n inverse *= 2 - denominator * inverse; // inverse mod 2^8\n inverse *= 2 - denominator * inverse; // inverse mod 2^16\n inverse *= 2 - denominator * inverse; // inverse mod 2^32\n inverse *= 2 - denominator * inverse; // inverse mod 2^64\n inverse *= 2 - denominator * inverse; // inverse mod 2^128\n inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n // is no longer required.\n result = prod0 * inverse;\n return result;\n }\n }\n\n /**\n * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n */\n function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\n uint256 result = mulDiv(x, y, denominator);\n if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {\n result += 1;\n }\n return result;\n }\n\n /**\n * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded\n * towards zero.\n *\n * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n */\n function sqrt(uint256 a) internal pure returns (uint256) {\n if (a == 0) {\n return 0;\n }\n\n // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n //\n // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n //\n // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n //\n // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n uint256 result = 1 << (log2(a) >> 1);\n\n // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n // into the expected uint128 result.\n unchecked {\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n result = (result + a / result) >> 1;\n return min(result, a / result);\n }\n }\n\n /**\n * @notice Calculates sqrt(a), following the selected rounding direction.\n */\n function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = sqrt(a);\n return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 2 of a positive value rounded towards zero.\n * Returns 0 if given 0.\n */\n function log2(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 128;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 64;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 32;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 16;\n }\n if (value >> 8 > 0) {\n value >>= 8;\n result += 8;\n }\n if (value >> 4 > 0) {\n value >>= 4;\n result += 4;\n }\n if (value >> 2 > 0) {\n value >>= 2;\n result += 2;\n }\n if (value >> 1 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log2(value);\n return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 10 of a positive value rounded towards zero.\n * Returns 0 if given 0.\n */\n function log10(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >= 10 ** 64) {\n value /= 10 ** 64;\n result += 64;\n }\n if (value >= 10 ** 32) {\n value /= 10 ** 32;\n result += 32;\n }\n if (value >= 10 ** 16) {\n value /= 10 ** 16;\n result += 16;\n }\n if (value >= 10 ** 8) {\n value /= 10 ** 8;\n result += 8;\n }\n if (value >= 10 ** 4) {\n value /= 10 ** 4;\n result += 4;\n }\n if (value >= 10 ** 2) {\n value /= 10 ** 2;\n result += 2;\n }\n if (value >= 10 ** 1) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log10(value);\n return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 256 of a positive value rounded towards zero.\n * Returns 0 if given 0.\n *\n * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n */\n function log256(uint256 value) internal pure returns (uint256) {\n uint256 result = 0;\n unchecked {\n if (value >> 128 > 0) {\n value >>= 128;\n result += 16;\n }\n if (value >> 64 > 0) {\n value >>= 64;\n result += 8;\n }\n if (value >> 32 > 0) {\n value >>= 32;\n result += 4;\n }\n if (value >> 16 > 0) {\n value >>= 16;\n result += 2;\n }\n if (value >> 8 > 0) {\n result += 1;\n }\n }\n return result;\n }\n\n /**\n * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\n * Returns 0 if given 0.\n */\n function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n unchecked {\n uint256 result = log256(value);\n return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.\n */\n function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {\n return uint8(rounding) % 2 == 1;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/math/SignedMath.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Standard signed math utilities missing in the Solidity language.\n */\nlibrary SignedMath {\n /**\n * @dev Returns the largest of two signed numbers.\n */\n function max(int256 a, int256 b) internal pure returns (int256) {\n return a > b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two signed numbers.\n */\n function min(int256 a, int256 b) internal pure returns (int256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two signed numbers without overflow.\n * The result is rounded towards zero.\n */\n function average(int256 a, int256 b) internal pure returns (int256) {\n // Formula from the book \"Hacker's Delight\"\n int256 x = (a & b) + ((a ^ b) >> 1);\n return x + (int256(uint256(x) >> 255) & (a ^ b));\n }\n\n /**\n * @dev Returns the absolute unsigned value of a signed value.\n */\n function abs(int256 n) internal pure returns (uint256) {\n unchecked {\n // must be unchecked in order to support `n = type(int256).min`\n return uint256(n >= 0 ? n : -n);\n }\n }\n}\n" + }, + "@openzeppelin/contracts/utils/ReentrancyGuard.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuard {\n // Booleans are more expensive than uint256 or any type that takes up a full\n // word because each write operation emits an extra SLOAD to first read the\n // slot's contents, replace the bits taken up by the boolean, and then write\n // back. This is the compiler's defense against contract upgrades and\n // pointer aliasing, and it cannot be disabled.\n\n // The values being non-zero value makes deployment a bit more expensive,\n // but in exchange the refund on every call to nonReentrant will be lower in\n // amount. Since refunds are capped to a percentage of the total\n // transaction's gas, it is best to keep them low in cases like this one, to\n // increase the likelihood of the full refund coming into effect.\n uint256 private constant NOT_ENTERED = 1;\n uint256 private constant ENTERED = 2;\n\n uint256 private _status;\n\n /**\n * @dev Unauthorized reentrant call.\n */\n error ReentrancyGuardReentrantCall();\n\n constructor() {\n _status = NOT_ENTERED;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant`\n * function is not supported. It is possible to prevent this from happening\n * by making the `nonReentrant` function external, and making it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n _nonReentrantBefore();\n _;\n _nonReentrantAfter();\n }\n\n function _nonReentrantBefore() private {\n // On the first call to nonReentrant, _status will be NOT_ENTERED\n if (_status == ENTERED) {\n revert ReentrancyGuardReentrantCall();\n }\n\n // Any calls to nonReentrant after this point will fail\n _status = ENTERED;\n }\n\n function _nonReentrantAfter() private {\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _status = NOT_ENTERED;\n }\n\n /**\n * @dev Returns true if the reentrancy guard is currently set to \"entered\", which indicates there is a\n * `nonReentrant` function in the call stack.\n */\n function _reentrancyGuardEntered() internal view returns (bool) {\n return _status == ENTERED;\n }\n}\n" + }, + "@openzeppelin/contracts/utils/StorageSlot.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/StorageSlot.sol)\n// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```solidity\n * contract ERC1967 {\n * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n * function _getImplementation() internal view returns (address) {\n * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n * }\n *\n * function _setImplementation(address newImplementation) internal {\n * require(newImplementation.code.length > 0);\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n */\nlibrary StorageSlot {\n struct AddressSlot {\n address value;\n }\n\n struct BooleanSlot {\n bool value;\n }\n\n struct Bytes32Slot {\n bytes32 value;\n }\n\n struct Uint256Slot {\n uint256 value;\n }\n\n struct StringSlot {\n string value;\n }\n\n struct BytesSlot {\n bytes value;\n }\n\n /**\n * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n */\n function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n */\n function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n */\n function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n */\n function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `StringSlot` with member `value` located at `slot`.\n */\n function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `StringSlot` representation of the string storage pointer `store`.\n */\n function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := store.slot\n }\n }\n\n /**\n * @dev Returns an `BytesSlot` with member `value` located at `slot`.\n */\n function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := slot\n }\n }\n\n /**\n * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.\n */\n function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {\n /// @solidity memory-safe-assembly\n assembly {\n r.slot := store.slot\n }\n }\n}\n" + }, + "@openzeppelin/contracts/utils/Strings.sol": { + "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol)\n\npragma solidity ^0.8.20;\n\nimport {Math} from \"./math/Math.sol\";\nimport {SignedMath} from \"./math/SignedMath.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant HEX_DIGITS = \"0123456789abcdef\";\n uint8 private constant ADDRESS_LENGTH = 20;\n\n /**\n * @dev The `value` string doesn't fit in the specified `length`.\n */\n error StringsInsufficientHexLength(uint256 value, uint256 length);\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n */\n function toString(uint256 value) internal pure returns (string memory) {\n unchecked {\n uint256 length = Math.log10(value) + 1;\n string memory buffer = new string(length);\n uint256 ptr;\n /// @solidity memory-safe-assembly\n assembly {\n ptr := add(buffer, add(32, length))\n }\n while (true) {\n ptr--;\n /// @solidity memory-safe-assembly\n assembly {\n mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))\n }\n value /= 10;\n if (value == 0) break;\n }\n return buffer;\n }\n }\n\n /**\n * @dev Converts a `int256` to its ASCII `string` decimal representation.\n */\n function toStringSigned(int256 value) internal pure returns (string memory) {\n return string.concat(value < 0 ? \"-\" : \"\", toString(SignedMath.abs(value)));\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n */\n function toHexString(uint256 value) internal pure returns (string memory) {\n unchecked {\n return toHexString(value, Math.log256(value) + 1);\n }\n }\n\n /**\n * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n */\n function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n uint256 localValue = value;\n bytes memory buffer = new bytes(2 * length + 2);\n buffer[0] = \"0\";\n buffer[1] = \"x\";\n for (uint256 i = 2 * length + 1; i > 1; --i) {\n buffer[i] = HEX_DIGITS[localValue & 0xf];\n localValue >>= 4;\n }\n if (localValue != 0) {\n revert StringsInsufficientHexLength(value, length);\n }\n return string(buffer);\n }\n\n /**\n * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal\n * representation.\n */\n function toHexString(address addr) internal pure returns (string memory) {\n return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);\n }\n\n /**\n * @dev Returns true if the two strings are equal.\n */\n function equal(string memory a, string memory b) internal pure returns (bool) {\n return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));\n }\n}\n" + }, + "account-abstraction/contracts/core/BaseAccount.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.23;\n\n/* solhint-disable avoid-low-level-calls */\n/* solhint-disable no-empty-blocks */\n\nimport \"../interfaces/IAccount.sol\";\nimport \"../interfaces/IEntryPoint.sol\";\nimport \"./UserOperationLib.sol\";\n\n/**\n * Basic account implementation.\n * This contract provides the basic logic for implementing the IAccount interface - validateUserOp\n * Specific account implementation should inherit it and provide the account-specific logic.\n */\nabstract contract BaseAccount is IAccount {\n using UserOperationLib for PackedUserOperation;\n\n /**\n * Return the account nonce.\n * This method returns the next sequential nonce.\n * For a nonce of a specific key, use `entrypoint.getNonce(account, key)`\n */\n function getNonce() public view virtual returns (uint256) {\n return entryPoint().getNonce(address(this), 0);\n }\n\n /**\n * Return the entryPoint used by this account.\n * Subclass should return the current entryPoint used by this account.\n */\n function entryPoint() public view virtual returns (IEntryPoint);\n\n /// @inheritdoc IAccount\n function validateUserOp(\n PackedUserOperation calldata userOp,\n bytes32 userOpHash,\n uint256 missingAccountFunds\n ) external virtual override returns (uint256 validationData) {\n _requireFromEntryPoint();\n validationData = _validateSignature(userOp, userOpHash);\n _validateNonce(userOp.nonce);\n _payPrefund(missingAccountFunds);\n }\n\n /**\n * Ensure the request comes from the known entrypoint.\n */\n function _requireFromEntryPoint() internal view virtual {\n require(\n msg.sender == address(entryPoint()),\n \"account: not from EntryPoint\"\n );\n }\n\n /**\n * Validate the signature is valid for this message.\n * @param userOp - Validate the userOp.signature field.\n * @param userOpHash - Convenient field: the hash of the request, to check the signature against.\n * (also hashes the entrypoint and chain id)\n * @return validationData - Signature and time-range of this operation.\n * <20-byte> aggregatorOrSigFail - 0 for valid signature, 1 to mark signature failure,\n * otherwise, an address of an aggregator contract.\n * <6-byte> validUntil - last timestamp this operation is valid. 0 for \"indefinite\"\n * <6-byte> validAfter - first timestamp this operation is valid\n * If the account doesn't use time-range, it is enough to return\n * SIG_VALIDATION_FAILED value (1) for signature failure.\n * Note that the validation code cannot use block.timestamp (or block.number) directly.\n */\n function _validateSignature(\n PackedUserOperation calldata userOp,\n bytes32 userOpHash\n ) internal virtual returns (uint256 validationData);\n\n /**\n * Validate the nonce of the UserOperation.\n * This method may validate the nonce requirement of this account.\n * e.g.\n * To limit the nonce to use sequenced UserOps only (no \"out of order\" UserOps):\n * `require(nonce < type(uint64).max)`\n * For a hypothetical account that *requires* the nonce to be out-of-order:\n * `require(nonce & type(uint64).max == 0)`\n *\n * The actual nonce uniqueness is managed by the EntryPoint, and thus no other\n * action is needed by the account itself.\n *\n * @param nonce to validate\n *\n * solhint-disable-next-line no-empty-blocks\n */\n function _validateNonce(uint256 nonce) internal view virtual {\n }\n\n /**\n * Sends to the entrypoint (msg.sender) the missing funds for this transaction.\n * SubClass MAY override this method for better funds management\n * (e.g. send to the entryPoint more than the minimum required, so that in future transactions\n * it will not be required to send again).\n * @param missingAccountFunds - The minimum value this method should send the entrypoint.\n * This value MAY be zero, in case there is enough deposit,\n * or the userOp has a paymaster.\n */\n function _payPrefund(uint256 missingAccountFunds) internal virtual {\n if (missingAccountFunds != 0) {\n (bool success, ) = payable(msg.sender).call{\n value: missingAccountFunds,\n gas: type(uint256).max\n }(\"\");\n (success);\n //ignore failure (its EntryPoint's job to verify, not account.)\n }\n }\n}\n" + }, + "account-abstraction/contracts/core/BasePaymaster.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.23;\n\n/* solhint-disable reason-string */\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\nimport \"../interfaces/IPaymaster.sol\";\nimport \"../interfaces/IEntryPoint.sol\";\nimport \"./UserOperationLib.sol\";\n/**\n * Helper class for creating a paymaster.\n * provides helper methods for staking.\n * Validates that the postOp is called only by the entryPoint.\n */\nabstract contract BasePaymaster is IPaymaster, Ownable {\n IEntryPoint public immutable entryPoint;\n\n uint256 internal constant PAYMASTER_VALIDATION_GAS_OFFSET = UserOperationLib.PAYMASTER_VALIDATION_GAS_OFFSET;\n uint256 internal constant PAYMASTER_POSTOP_GAS_OFFSET = UserOperationLib.PAYMASTER_POSTOP_GAS_OFFSET;\n uint256 internal constant PAYMASTER_DATA_OFFSET = UserOperationLib.PAYMASTER_DATA_OFFSET;\n\n constructor(IEntryPoint _entryPoint) Ownable(msg.sender) {\n _validateEntryPointInterface(_entryPoint);\n entryPoint = _entryPoint;\n }\n\n //sanity check: make sure this EntryPoint was compiled against the same\n // IEntryPoint of this paymaster\n function _validateEntryPointInterface(IEntryPoint _entryPoint) internal virtual {\n require(IERC165(address(_entryPoint)).supportsInterface(type(IEntryPoint).interfaceId), \"IEntryPoint interface mismatch\");\n }\n\n /// @inheritdoc IPaymaster\n function validatePaymasterUserOp(\n PackedUserOperation calldata userOp,\n bytes32 userOpHash,\n uint256 maxCost\n ) external override returns (bytes memory context, uint256 validationData) {\n _requireFromEntryPoint();\n return _validatePaymasterUserOp(userOp, userOpHash, maxCost);\n }\n\n /**\n * Validate a user operation.\n * @param userOp - The user operation.\n * @param userOpHash - The hash of the user operation.\n * @param maxCost - The maximum cost of the user operation.\n */\n function _validatePaymasterUserOp(\n PackedUserOperation calldata userOp,\n bytes32 userOpHash,\n uint256 maxCost\n ) internal virtual returns (bytes memory context, uint256 validationData);\n\n /// @inheritdoc IPaymaster\n function postOp(\n PostOpMode mode,\n bytes calldata context,\n uint256 actualGasCost,\n uint256 actualUserOpFeePerGas\n ) external override {\n _requireFromEntryPoint();\n _postOp(mode, context, actualGasCost, actualUserOpFeePerGas);\n }\n\n /**\n * Post-operation handler.\n * (verified to be called only through the entryPoint)\n * @dev If subclass returns a non-empty context from validatePaymasterUserOp,\n * it must also implement this method.\n * @param mode - Enum with the following options:\n * opSucceeded - User operation succeeded.\n * opReverted - User op reverted. The paymaster still has to pay for gas.\n * postOpReverted - never passed in a call to postOp().\n * @param context - The context value returned by validatePaymasterUserOp\n * @param actualGasCost - Actual gas used so far (without this postOp call).\n * @param actualUserOpFeePerGas - the gas price this UserOp pays. This value is based on the UserOp's maxFeePerGas\n * and maxPriorityFee (and basefee)\n * It is not the same as tx.gasprice, which is what the bundler pays.\n */\n function _postOp(\n PostOpMode mode,\n bytes calldata context,\n uint256 actualGasCost,\n uint256 actualUserOpFeePerGas\n ) internal virtual {\n (mode, context, actualGasCost, actualUserOpFeePerGas); // unused params\n // subclass must override this method if validatePaymasterUserOp returns a context\n revert(\"must override\");\n }\n\n /**\n * Add a deposit for this paymaster, used for paying for transaction fees.\n */\n function deposit() public payable {\n entryPoint.depositTo{value: msg.value}(address(this));\n }\n\n /**\n * Withdraw value from the deposit.\n * @param withdrawAddress - Target to send to.\n * @param amount - Amount to withdraw.\n */\n function withdrawTo(\n address payable withdrawAddress,\n uint256 amount\n ) public onlyOwner {\n entryPoint.withdrawTo(withdrawAddress, amount);\n }\n\n /**\n * Add stake for this paymaster.\n * This method can also carry eth value to add to the current stake.\n * @param unstakeDelaySec - The unstake delay for this paymaster. Can only be increased.\n */\n function addStake(uint32 unstakeDelaySec) external payable onlyOwner {\n entryPoint.addStake{value: msg.value}(unstakeDelaySec);\n }\n\n /**\n * Return current paymaster's deposit on the entryPoint.\n */\n function getDeposit() public view returns (uint256) {\n return entryPoint.balanceOf(address(this));\n }\n\n /**\n * Unlock the stake, in order to withdraw it.\n * The paymaster can't serve requests once unlocked, until it calls addStake again\n */\n function unlockStake() external onlyOwner {\n entryPoint.unlockStake();\n }\n\n /**\n * Withdraw the entire paymaster's stake.\n * stake must be unlocked first (and then wait for the unstakeDelay to be over)\n * @param withdrawAddress - The address to send withdrawn value.\n */\n function withdrawStake(address payable withdrawAddress) external onlyOwner {\n entryPoint.withdrawStake(withdrawAddress);\n }\n\n /**\n * Validate the call is made from a valid entrypoint\n */\n function _requireFromEntryPoint() internal virtual {\n require(msg.sender == address(entryPoint), \"Sender not EntryPoint\");\n }\n}\n" + }, + "account-abstraction/contracts/core/Helpers.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.23;\n\n/* solhint-disable no-inline-assembly */\n\n\n /*\n * For simulation purposes, validateUserOp (and validatePaymasterUserOp)\n * must return this value in case of signature failure, instead of revert.\n */\nuint256 constant SIG_VALIDATION_FAILED = 1;\n\n\n/*\n * For simulation purposes, validateUserOp (and validatePaymasterUserOp)\n * return this value on success.\n */\nuint256 constant SIG_VALIDATION_SUCCESS = 0;\n\n\n/**\n * Returned data from validateUserOp.\n * validateUserOp returns a uint256, which is created by `_packedValidationData` and\n * parsed by `_parseValidationData`.\n * @param aggregator - address(0) - The account validated the signature by itself.\n * address(1) - The account failed to validate the signature.\n * otherwise - This is an address of a signature aggregator that must\n * be used to validate the signature.\n * @param validAfter - This UserOp is valid only after this timestamp.\n * @param validaUntil - This UserOp is valid only up to this timestamp.\n */\nstruct ValidationData {\n address aggregator;\n uint48 validAfter;\n uint48 validUntil;\n}\n\n/**\n * Extract sigFailed, validAfter, validUntil.\n * Also convert zero validUntil to type(uint48).max.\n * @param validationData - The packed validation data.\n */\nfunction _parseValidationData(\n uint256 validationData\n) pure returns (ValidationData memory data) {\n address aggregator = address(uint160(validationData));\n uint48 validUntil = uint48(validationData >> 160);\n if (validUntil == 0) {\n validUntil = type(uint48).max;\n }\n uint48 validAfter = uint48(validationData >> (48 + 160));\n return ValidationData(aggregator, validAfter, validUntil);\n}\n\n/**\n * Helper to pack the return value for validateUserOp.\n * @param data - The ValidationData to pack.\n */\nfunction _packValidationData(\n ValidationData memory data\n) pure returns (uint256) {\n return\n uint160(data.aggregator) |\n (uint256(data.validUntil) << 160) |\n (uint256(data.validAfter) << (160 + 48));\n}\n\n/**\n * Helper to pack the return value for validateUserOp, when not using an aggregator.\n * @param sigFailed - True for signature failure, false for success.\n * @param validUntil - Last timestamp this UserOperation is valid (or zero for infinite).\n * @param validAfter - First timestamp this UserOperation is valid.\n */\nfunction _packValidationData(\n bool sigFailed,\n uint48 validUntil,\n uint48 validAfter\n) pure returns (uint256) {\n return\n (sigFailed ? 1 : 0) |\n (uint256(validUntil) << 160) |\n (uint256(validAfter) << (160 + 48));\n}\n\n/**\n * keccak function over calldata.\n * @dev copy calldata into memory, do keccak and drop allocated memory. Strangely, this is more efficient than letting solidity do it.\n */\n function calldataKeccak(bytes calldata data) pure returns (bytes32 ret) {\n assembly (\"memory-safe\") {\n let mem := mload(0x40)\n let len := data.length\n calldatacopy(mem, data.offset, len)\n ret := keccak256(mem, len)\n }\n }\n\n\n/**\n * The minimum of two numbers.\n * @param a - First number.\n * @param b - Second number.\n */\n function min(uint256 a, uint256 b) pure returns (uint256) {\n return a < b ? a : b;\n }\n" + }, + "account-abstraction/contracts/core/UserOperationLib.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.23;\n\n/* solhint-disable no-inline-assembly */\n\nimport \"../interfaces/PackedUserOperation.sol\";\nimport {calldataKeccak, min} from \"./Helpers.sol\";\n\n/**\n * Utility functions helpful when working with UserOperation structs.\n */\nlibrary UserOperationLib {\n\n uint256 public constant PAYMASTER_VALIDATION_GAS_OFFSET = 20;\n uint256 public constant PAYMASTER_POSTOP_GAS_OFFSET = 36;\n uint256 public constant PAYMASTER_DATA_OFFSET = 52;\n /**\n * Get sender from user operation data.\n * @param userOp - The user operation data.\n */\n function getSender(\n PackedUserOperation calldata userOp\n ) internal pure returns (address) {\n address data;\n //read sender from userOp, which is first userOp member (saves 800 gas...)\n assembly {\n data := calldataload(userOp)\n }\n return address(uint160(data));\n }\n\n /**\n * Relayer/block builder might submit the TX with higher priorityFee,\n * but the user should not pay above what he signed for.\n * @param userOp - The user operation data.\n */\n function gasPrice(\n PackedUserOperation calldata userOp\n ) internal view returns (uint256) {\n unchecked {\n (uint256 maxPriorityFeePerGas, uint256 maxFeePerGas) = unpackUints(userOp.gasFees);\n if (maxFeePerGas == maxPriorityFeePerGas) {\n //legacy mode (for networks that don't support basefee opcode)\n return maxFeePerGas;\n }\n return min(maxFeePerGas, maxPriorityFeePerGas + block.basefee);\n }\n }\n\n /**\n * Pack the user operation data into bytes for hashing.\n * @param userOp - The user operation data.\n */\n function encode(\n PackedUserOperation calldata userOp\n ) internal pure returns (bytes memory ret) {\n address sender = getSender(userOp);\n uint256 nonce = userOp.nonce;\n bytes32 hashInitCode = calldataKeccak(userOp.initCode);\n bytes32 hashCallData = calldataKeccak(userOp.callData);\n bytes32 accountGasLimits = userOp.accountGasLimits;\n uint256 preVerificationGas = userOp.preVerificationGas;\n bytes32 gasFees = userOp.gasFees;\n bytes32 hashPaymasterAndData = calldataKeccak(userOp.paymasterAndData);\n\n return abi.encode(\n sender, nonce,\n hashInitCode, hashCallData,\n accountGasLimits, preVerificationGas, gasFees,\n hashPaymasterAndData\n );\n }\n\n function unpackUints(\n bytes32 packed\n ) internal pure returns (uint256 high128, uint256 low128) {\n return (uint128(bytes16(packed)), uint128(uint256(packed)));\n }\n\n //unpack just the high 128-bits from a packed value\n function unpackHigh128(bytes32 packed) internal pure returns (uint256) {\n return uint256(packed) >> 128;\n }\n\n // unpack just the low 128-bits from a packed value\n function unpackLow128(bytes32 packed) internal pure returns (uint256) {\n return uint128(uint256(packed));\n }\n\n function unpackMaxPriorityFeePerGas(PackedUserOperation calldata userOp)\n internal pure returns (uint256) {\n return unpackHigh128(userOp.gasFees);\n }\n\n function unpackMaxFeePerGas(PackedUserOperation calldata userOp)\n internal pure returns (uint256) {\n return unpackLow128(userOp.gasFees);\n }\n\n function unpackVerificationGasLimit(PackedUserOperation calldata userOp)\n internal pure returns (uint256) {\n return unpackHigh128(userOp.accountGasLimits);\n }\n\n function unpackCallGasLimit(PackedUserOperation calldata userOp)\n internal pure returns (uint256) {\n return unpackLow128(userOp.accountGasLimits);\n }\n\n function unpackPaymasterVerificationGasLimit(PackedUserOperation calldata userOp)\n internal pure returns (uint256) {\n return uint128(bytes16(userOp.paymasterAndData[PAYMASTER_VALIDATION_GAS_OFFSET : PAYMASTER_POSTOP_GAS_OFFSET]));\n }\n\n function unpackPostOpGasLimit(PackedUserOperation calldata userOp)\n internal pure returns (uint256) {\n return uint128(bytes16(userOp.paymasterAndData[PAYMASTER_POSTOP_GAS_OFFSET : PAYMASTER_DATA_OFFSET]));\n }\n\n function unpackPaymasterStaticFields(\n bytes calldata paymasterAndData\n ) internal pure returns (address paymaster, uint256 validationGasLimit, uint256 postOpGasLimit) {\n return (\n address(bytes20(paymasterAndData[: PAYMASTER_VALIDATION_GAS_OFFSET])),\n uint128(bytes16(paymasterAndData[PAYMASTER_VALIDATION_GAS_OFFSET : PAYMASTER_POSTOP_GAS_OFFSET])),\n uint128(bytes16(paymasterAndData[PAYMASTER_POSTOP_GAS_OFFSET : PAYMASTER_DATA_OFFSET]))\n );\n }\n\n /**\n * Hash the user operation data.\n * @param userOp - The user operation data.\n */\n function hash(\n PackedUserOperation calldata userOp\n ) internal pure returns (bytes32) {\n return keccak256(encode(userOp));\n }\n}\n" + }, + "account-abstraction/contracts/interfaces/IAccount.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.7.5;\n\nimport \"./PackedUserOperation.sol\";\n\ninterface IAccount {\n /**\n * Validate user's signature and nonce\n * the entryPoint will make the call to the recipient only if this validation call returns successfully.\n * signature failure should be reported by returning SIG_VALIDATION_FAILED (1).\n * This allows making a \"simulation call\" without a valid signature\n * Other failures (e.g. nonce mismatch, or invalid signature format) should still revert to signal failure.\n *\n * @dev Must validate caller is the entryPoint.\n * Must validate the signature and nonce\n * @param userOp - The operation that is about to be executed.\n * @param userOpHash - Hash of the user's request data. can be used as the basis for signature.\n * @param missingAccountFunds - Missing funds on the account's deposit in the entrypoint.\n * This is the minimum amount to transfer to the sender(entryPoint) to be\n * able to make the call. The excess is left as a deposit in the entrypoint\n * for future calls. Can be withdrawn anytime using \"entryPoint.withdrawTo()\".\n * In case there is a paymaster in the request (or the current deposit is high\n * enough), this value will be zero.\n * @return validationData - Packaged ValidationData structure. use `_packValidationData` and\n * `_unpackValidationData` to encode and decode.\n * <20-byte> sigAuthorizer - 0 for valid signature, 1 to mark signature failure,\n * otherwise, an address of an \"authorizer\" contract.\n * <6-byte> validUntil - Last timestamp this operation is valid. 0 for \"indefinite\"\n * <6-byte> validAfter - First timestamp this operation is valid\n * If an account doesn't use time-range, it is enough to\n * return SIG_VALIDATION_FAILED value (1) for signature failure.\n * Note that the validation code cannot use block.timestamp (or block.number) directly.\n */\n function validateUserOp(\n PackedUserOperation calldata userOp,\n bytes32 userOpHash,\n uint256 missingAccountFunds\n ) external returns (uint256 validationData);\n}\n" + }, + "account-abstraction/contracts/interfaces/IAggregator.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.7.5;\n\nimport \"./PackedUserOperation.sol\";\n\n/**\n * Aggregated Signatures validator.\n */\ninterface IAggregator {\n /**\n * Validate aggregated signature.\n * Revert if the aggregated signature does not match the given list of operations.\n * @param userOps - Array of UserOperations to validate the signature for.\n * @param signature - The aggregated signature.\n */\n function validateSignatures(\n PackedUserOperation[] calldata userOps,\n bytes calldata signature\n ) external view;\n\n /**\n * Validate signature of a single userOp.\n * This method should be called by bundler after EntryPointSimulation.simulateValidation() returns\n * the aggregator this account uses.\n * First it validates the signature over the userOp. Then it returns data to be used when creating the handleOps.\n * @param userOp - The userOperation received from the user.\n * @return sigForUserOp - The value to put into the signature field of the userOp when calling handleOps.\n * (usually empty, unless account and aggregator support some kind of \"multisig\".\n */\n function validateUserOpSignature(\n PackedUserOperation calldata userOp\n ) external view returns (bytes memory sigForUserOp);\n\n /**\n * Aggregate multiple signatures into a single value.\n * This method is called off-chain to calculate the signature to pass with handleOps()\n * bundler MAY use optimized custom code perform this aggregation.\n * @param userOps - Array of UserOperations to collect the signatures from.\n * @return aggregatedSignature - The aggregated signature.\n */\n function aggregateSignatures(\n PackedUserOperation[] calldata userOps\n ) external view returns (bytes memory aggregatedSignature);\n}\n" + }, + "account-abstraction/contracts/interfaces/IEntryPoint.sol": { + "content": "/**\n ** Account-Abstraction (EIP-4337) singleton EntryPoint implementation.\n ** Only one instance required on each chain.\n **/\n// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.7.5;\n\n/* solhint-disable avoid-low-level-calls */\n/* solhint-disable no-inline-assembly */\n/* solhint-disable reason-string */\n\nimport \"./PackedUserOperation.sol\";\nimport \"./IStakeManager.sol\";\nimport \"./IAggregator.sol\";\nimport \"./INonceManager.sol\";\n\ninterface IEntryPoint is IStakeManager, INonceManager {\n /***\n * An event emitted after each successful request.\n * @param userOpHash - Unique identifier for the request (hash its entire content, except signature).\n * @param sender - The account that generates this request.\n * @param paymaster - If non-null, the paymaster that pays for this request.\n * @param nonce - The nonce value from the request.\n * @param success - True if the sender transaction succeeded, false if reverted.\n * @param actualGasCost - Actual amount paid (by account or paymaster) for this UserOperation.\n * @param actualGasUsed - Total gas used by this UserOperation (including preVerification, creation,\n * validation and execution).\n */\n event UserOperationEvent(\n bytes32 indexed userOpHash,\n address indexed sender,\n address indexed paymaster,\n uint256 nonce,\n bool success,\n uint256 actualGasCost,\n uint256 actualGasUsed\n );\n\n /**\n * Account \"sender\" was deployed.\n * @param userOpHash - The userOp that deployed this account. UserOperationEvent will follow.\n * @param sender - The account that is deployed\n * @param factory - The factory used to deploy this account (in the initCode)\n * @param paymaster - The paymaster used by this UserOp\n */\n event AccountDeployed(\n bytes32 indexed userOpHash,\n address indexed sender,\n address factory,\n address paymaster\n );\n\n /**\n * An event emitted if the UserOperation \"callData\" reverted with non-zero length.\n * @param userOpHash - The request unique identifier.\n * @param sender - The sender of this request.\n * @param nonce - The nonce used in the request.\n * @param revertReason - The return bytes from the (reverted) call to \"callData\".\n */\n event UserOperationRevertReason(\n bytes32 indexed userOpHash,\n address indexed sender,\n uint256 nonce,\n bytes revertReason\n );\n\n /**\n * An event emitted if the UserOperation Paymaster's \"postOp\" call reverted with non-zero length.\n * @param userOpHash - The request unique identifier.\n * @param sender - The sender of this request.\n * @param nonce - The nonce used in the request.\n * @param revertReason - The return bytes from the (reverted) call to \"callData\".\n */\n event PostOpRevertReason(\n bytes32 indexed userOpHash,\n address indexed sender,\n uint256 nonce,\n bytes revertReason\n );\n\n /**\n * UserOp consumed more than prefund. The UserOperation is reverted, and no refund is made.\n * @param userOpHash - The request unique identifier.\n * @param sender - The sender of this request.\n * @param nonce - The nonce used in the request.\n */\n event UserOperationPrefundTooLow(\n bytes32 indexed userOpHash,\n address indexed sender,\n uint256 nonce\n );\n\n /**\n * An event emitted by handleOps(), before starting the execution loop.\n * Any event emitted before this event, is part of the validation.\n */\n event BeforeExecution();\n\n /**\n * Signature aggregator used by the following UserOperationEvents within this bundle.\n * @param aggregator - The aggregator used for the following UserOperationEvents.\n */\n event SignatureAggregatorChanged(address indexed aggregator);\n\n /**\n * A custom revert error of handleOps, to identify the offending op.\n * Should be caught in off-chain handleOps simulation and not happen on-chain.\n * Useful for mitigating DoS attempts against batchers or for troubleshooting of factory/account/paymaster reverts.\n * NOTE: If simulateValidation passes successfully, there should be no reason for handleOps to fail on it.\n * @param opIndex - Index into the array of ops to the failed one (in simulateValidation, this is always zero).\n * @param reason - Revert reason. The string starts with a unique code \"AAmn\",\n * where \"m\" is \"1\" for factory, \"2\" for account and \"3\" for paymaster issues,\n * so a failure can be attributed to the correct entity.\n */\n error FailedOp(uint256 opIndex, string reason);\n\n /**\n * A custom revert error of handleOps, to report a revert by account or paymaster.\n * @param opIndex - Index into the array of ops to the failed one (in simulateValidation, this is always zero).\n * @param reason - Revert reason. see FailedOp(uint256,string), above\n * @param inner - data from inner cought revert reason\n * @dev note that inner is truncated to 2048 bytes\n */\n error FailedOpWithRevert(uint256 opIndex, string reason, bytes inner);\n\n error PostOpReverted(bytes returnData);\n\n /**\n * Error case when a signature aggregator fails to verify the aggregated signature it had created.\n * @param aggregator The aggregator that failed to verify the signature\n */\n error SignatureValidationFailed(address aggregator);\n\n // Return value of getSenderAddress.\n error SenderAddressResult(address sender);\n\n // UserOps handled, per aggregator.\n struct UserOpsPerAggregator {\n PackedUserOperation[] userOps;\n // Aggregator address\n IAggregator aggregator;\n // Aggregated signature\n bytes signature;\n }\n\n /**\n * Execute a batch of UserOperations.\n * No signature aggregator is used.\n * If any account requires an aggregator (that is, it returned an aggregator when\n * performing simulateValidation), then handleAggregatedOps() must be used instead.\n * @param ops - The operations to execute.\n * @param beneficiary - The address to receive the fees.\n */\n function handleOps(\n PackedUserOperation[] calldata ops,\n address payable beneficiary\n ) external;\n\n /**\n * Execute a batch of UserOperation with Aggregators\n * @param opsPerAggregator - The operations to execute, grouped by aggregator (or address(0) for no-aggregator accounts).\n * @param beneficiary - The address to receive the fees.\n */\n function handleAggregatedOps(\n UserOpsPerAggregator[] calldata opsPerAggregator,\n address payable beneficiary\n ) external;\n\n /**\n * Generate a request Id - unique identifier for this request.\n * The request ID is a hash over the content of the userOp (except the signature), the entrypoint and the chainid.\n * @param userOp - The user operation to generate the request ID for.\n * @return hash the hash of this UserOperation\n */\n function getUserOpHash(\n PackedUserOperation calldata userOp\n ) external view returns (bytes32);\n\n /**\n * Gas and return values during simulation.\n * @param preOpGas - The gas used for validation (including preValidationGas)\n * @param prefund - The required prefund for this operation\n * @param accountValidationData - returned validationData from account.\n * @param paymasterValidationData - return validationData from paymaster.\n * @param paymasterContext - Returned by validatePaymasterUserOp (to be passed into postOp)\n */\n struct ReturnInfo {\n uint256 preOpGas;\n uint256 prefund;\n uint256 accountValidationData;\n uint256 paymasterValidationData;\n bytes paymasterContext;\n }\n\n /**\n * Returned aggregated signature info:\n * The aggregator returned by the account, and its current stake.\n */\n struct AggregatorStakeInfo {\n address aggregator;\n StakeInfo stakeInfo;\n }\n\n /**\n * Get counterfactual sender address.\n * Calculate the sender contract address that will be generated by the initCode and salt in the UserOperation.\n * This method always revert, and returns the address in SenderAddressResult error\n * @param initCode - The constructor code to be passed into the UserOperation.\n */\n function getSenderAddress(bytes memory initCode) external;\n\n error DelegateAndRevert(bool success, bytes ret);\n\n /**\n * Helper method for dry-run testing.\n * @dev calling this method, the EntryPoint will make a delegatecall to the given data, and report (via revert) the result.\n * The method always revert, so is only useful off-chain for dry run calls, in cases where state-override to replace\n * actual EntryPoint code is less convenient.\n * @param target a target contract to make a delegatecall from entrypoint\n * @param data data to pass to target in a delegatecall\n */\n function delegateAndRevert(address target, bytes calldata data) external;\n}\n" + }, + "account-abstraction/contracts/interfaces/INonceManager.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.7.5;\n\ninterface INonceManager {\n\n /**\n * Return the next nonce for this sender.\n * Within a given key, the nonce values are sequenced (starting with zero, and incremented by one on each userop)\n * But UserOp with different keys can come with arbitrary order.\n *\n * @param sender the account address\n * @param key the high 192 bit of the nonce\n * @return nonce a full nonce to pass for next UserOp with this sender.\n */\n function getNonce(address sender, uint192 key)\n external view returns (uint256 nonce);\n\n /**\n * Manually increment the nonce of the sender.\n * This method is exposed just for completeness..\n * Account does NOT need to call it, neither during validation, nor elsewhere,\n * as the EntryPoint will update the nonce regardless.\n * Possible use-case is call it with various keys to \"initialize\" their nonces to one, so that future\n * UserOperations will not pay extra for the first transaction with a given key.\n */\n function incrementNonce(uint192 key) external;\n}\n" + }, + "account-abstraction/contracts/interfaces/IPaymaster.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.7.5;\n\nimport \"./PackedUserOperation.sol\";\n\n/**\n * The interface exposed by a paymaster contract, who agrees to pay the gas for user's operations.\n * A paymaster must hold a stake to cover the required entrypoint stake and also the gas for the transaction.\n */\ninterface IPaymaster {\n enum PostOpMode {\n // User op succeeded.\n opSucceeded,\n // User op reverted. Still has to pay for gas.\n opReverted,\n // Only used internally in the EntryPoint (cleanup after postOp reverts). Never calling paymaster with this value\n postOpReverted\n }\n\n /**\n * Payment validation: check if paymaster agrees to pay.\n * Must verify sender is the entryPoint.\n * Revert to reject this request.\n * Note that bundlers will reject this method if it changes the state, unless the paymaster is trusted (whitelisted).\n * The paymaster pre-pays using its deposit, and receive back a refund after the postOp method returns.\n * @param userOp - The user operation.\n * @param userOpHash - Hash of the user's request data.\n * @param maxCost - The maximum cost of this transaction (based on maximum gas and gas price from userOp).\n * @return context - Value to send to a postOp. Zero length to signify postOp is not required.\n * @return validationData - Signature and time-range of this operation, encoded the same as the return\n * value of validateUserOperation.\n * <20-byte> sigAuthorizer - 0 for valid signature, 1 to mark signature failure,\n * other values are invalid for paymaster.\n * <6-byte> validUntil - last timestamp this operation is valid. 0 for \"indefinite\"\n * <6-byte> validAfter - first timestamp this operation is valid\n * Note that the validation code cannot use block.timestamp (or block.number) directly.\n */\n function validatePaymasterUserOp(\n PackedUserOperation calldata userOp,\n bytes32 userOpHash,\n uint256 maxCost\n ) external returns (bytes memory context, uint256 validationData);\n\n /**\n * Post-operation handler.\n * Must verify sender is the entryPoint.\n * @param mode - Enum with the following options:\n * opSucceeded - User operation succeeded.\n * opReverted - User op reverted. The paymaster still has to pay for gas.\n * postOpReverted - never passed in a call to postOp().\n * @param context - The context value returned by validatePaymasterUserOp\n * @param actualGasCost - Actual gas used so far (without this postOp call).\n * @param actualUserOpFeePerGas - the gas price this UserOp pays. This value is based on the UserOp's maxFeePerGas\n * and maxPriorityFee (and basefee)\n * It is not the same as tx.gasprice, which is what the bundler pays.\n */\n function postOp(\n PostOpMode mode,\n bytes calldata context,\n uint256 actualGasCost,\n uint256 actualUserOpFeePerGas\n ) external;\n}\n" + }, + "account-abstraction/contracts/interfaces/IStakeManager.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0-only\npragma solidity >=0.7.5;\n\n/**\n * Manage deposits and stakes.\n * Deposit is just a balance used to pay for UserOperations (either by a paymaster or an account).\n * Stake is value locked for at least \"unstakeDelay\" by the staked entity.\n */\ninterface IStakeManager {\n event Deposited(address indexed account, uint256 totalDeposit);\n\n event Withdrawn(\n address indexed account,\n address withdrawAddress,\n uint256 amount\n );\n\n // Emitted when stake or unstake delay are modified.\n event StakeLocked(\n address indexed account,\n uint256 totalStaked,\n uint256 unstakeDelaySec\n );\n\n // Emitted once a stake is scheduled for withdrawal.\n event StakeUnlocked(address indexed account, uint256 withdrawTime);\n\n event StakeWithdrawn(\n address indexed account,\n address withdrawAddress,\n uint256 amount\n );\n\n /**\n * @param deposit - The entity's deposit.\n * @param staked - True if this entity is staked.\n * @param stake - Actual amount of ether staked for this entity.\n * @param unstakeDelaySec - Minimum delay to withdraw the stake.\n * @param withdrawTime - First block timestamp where 'withdrawStake' will be callable, or zero if already locked.\n * @dev Sizes were chosen so that deposit fits into one cell (used during handleOp)\n * and the rest fit into a 2nd cell (used during stake/unstake)\n * - 112 bit allows for 10^15 eth\n * - 48 bit for full timestamp\n * - 32 bit allows 150 years for unstake delay\n */\n struct DepositInfo {\n uint256 deposit;\n bool staked;\n uint112 stake;\n uint32 unstakeDelaySec;\n uint48 withdrawTime;\n }\n\n // API struct used by getStakeInfo and simulateValidation.\n struct StakeInfo {\n uint256 stake;\n uint256 unstakeDelaySec;\n }\n\n /**\n * Get deposit info.\n * @param account - The account to query.\n * @return info - Full deposit information of given account.\n */\n function getDepositInfo(\n address account\n ) external view returns (DepositInfo memory info);\n\n /**\n * Get account balance.\n * @param account - The account to query.\n * @return - The deposit (for gas payment) of the account.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * Add to the deposit of the given account.\n * @param account - The account to add to.\n */\n function depositTo(address account) external payable;\n\n /**\n * Add to the account's stake - amount and delay\n * any pending unstake is first cancelled.\n * @param _unstakeDelaySec - The new lock duration before the deposit can be withdrawn.\n */\n function addStake(uint32 _unstakeDelaySec) external payable;\n\n /**\n * Attempt to unlock the stake.\n * The value can be withdrawn (using withdrawStake) after the unstake delay.\n */\n function unlockStake() external;\n\n /**\n * Withdraw from the (unlocked) stake.\n * Must first call unlockStake and wait for the unstakeDelay to pass.\n * @param withdrawAddress - The address to send withdrawn value.\n */\n function withdrawStake(address payable withdrawAddress) external;\n\n /**\n * Withdraw from the deposit.\n * @param withdrawAddress - The address to send withdrawn value.\n * @param withdrawAmount - The amount to withdraw.\n */\n function withdrawTo(\n address payable withdrawAddress,\n uint256 withdrawAmount\n ) external;\n}\n" + }, + "account-abstraction/contracts/interfaces/PackedUserOperation.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.7.5;\n\n/**\n * User Operation struct\n * @param sender - The sender account of this request.\n * @param nonce - Unique value the sender uses to verify it is not a replay.\n * @param initCode - If set, the account contract will be created by this constructor/\n * @param callData - The method call to execute on this account.\n * @param accountGasLimits - Packed gas limits for validateUserOp and gas limit passed to the callData method call.\n * @param preVerificationGas - Gas not calculated by the handleOps method, but added to the gas paid.\n * Covers batch overhead.\n * @param gasFees - packed gas fields maxPriorityFeePerGas and maxFeePerGas - Same as EIP-1559 gas parameters.\n * @param paymasterAndData - If set, this field holds the paymaster address, verification gas limit, postOp gas limit and paymaster-specific extra data\n * The paymaster will pay for the transaction instead of the sender.\n * @param signature - Sender-verified signature over the entire request, the EntryPoint address and the chain ID.\n */\nstruct PackedUserOperation {\n address sender;\n uint256 nonce;\n bytes initCode;\n bytes callData;\n bytes32 accountGasLimits;\n uint256 preVerificationGas;\n bytes32 gasFees;\n bytes paymasterAndData;\n bytes signature;\n}\n" + }, + "account-abstraction/contracts/samples/callback/TokenCallbackHandler.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.23;\n\n/* solhint-disable no-empty-blocks */\n\nimport \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\nimport \"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\";\nimport \"@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol\";\n\n/**\n * Token callback handler.\n * Handles supported tokens' callbacks, allowing account receiving these tokens.\n */\nabstract contract TokenCallbackHandler is IERC721Receiver, IERC1155Receiver {\n\n function onERC721Received(\n address,\n address,\n uint256,\n bytes calldata\n ) external pure override returns (bytes4) {\n return IERC721Receiver.onERC721Received.selector;\n }\n\n function onERC1155Received(\n address,\n address,\n uint256,\n uint256,\n bytes calldata\n ) external pure override returns (bytes4) {\n return IERC1155Receiver.onERC1155Received.selector;\n }\n\n function onERC1155BatchReceived(\n address,\n address,\n uint256[] calldata,\n uint256[] calldata,\n bytes calldata\n ) external pure override returns (bytes4) {\n return IERC1155Receiver.onERC1155BatchReceived.selector;\n }\n\n function supportsInterface(bytes4 interfaceId) external view virtual override returns (bool) {\n return\n interfaceId == type(IERC721Receiver).interfaceId ||\n interfaceId == type(IERC1155Receiver).interfaceId ||\n interfaceId == type(IERC165).interfaceId;\n }\n}\n" + }, + "solady/src/utils/EIP712.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\n/// @notice Contract for EIP-712 typed structured data hashing and signing.\n/// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/EIP712.sol)\n/// @author Modified from Solbase (https://github.com/Sol-DAO/solbase/blob/main/src/utils/EIP712.sol)\n/// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/EIP712.sol)\n///\n/// @dev Note, this implementation:\n/// - Uses `address(this)` for the `verifyingContract` field.\n/// - Does NOT use the optional EIP-712 salt.\n/// - Does NOT use any EIP-712 extensions.\n/// This is for simplicity and to save gas.\n/// If you need to customize, please fork / modify accordingly.\nabstract contract EIP712 {\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* CONSTANTS AND IMMUTABLES */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev `keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\")`.\n bytes32 internal constant _DOMAIN_TYPEHASH =\n 0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f;\n\n uint256 private immutable _cachedThis;\n uint256 private immutable _cachedChainId;\n bytes32 private immutable _cachedNameHash;\n bytes32 private immutable _cachedVersionHash;\n bytes32 private immutable _cachedDomainSeparator;\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* CONSTRUCTOR */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Cache the hashes for cheaper runtime gas costs.\n /// In the case of upgradeable contracts (i.e. proxies),\n /// or if the chain id changes due to a hard fork,\n /// the domain separator will be seamlessly calculated on-the-fly.\n constructor() {\n _cachedThis = uint256(uint160(address(this)));\n _cachedChainId = block.chainid;\n\n string memory name;\n string memory version;\n if (!_domainNameAndVersionMayChange()) (name, version) = _domainNameAndVersion();\n bytes32 nameHash = _domainNameAndVersionMayChange() ? bytes32(0) : keccak256(bytes(name));\n bytes32 versionHash =\n _domainNameAndVersionMayChange() ? bytes32(0) : keccak256(bytes(version));\n _cachedNameHash = nameHash;\n _cachedVersionHash = versionHash;\n\n bytes32 separator;\n if (!_domainNameAndVersionMayChange()) {\n /// @solidity memory-safe-assembly\n assembly {\n let m := mload(0x40) // Load the free memory pointer.\n mstore(m, _DOMAIN_TYPEHASH)\n mstore(add(m, 0x20), nameHash)\n mstore(add(m, 0x40), versionHash)\n mstore(add(m, 0x60), chainid())\n mstore(add(m, 0x80), address())\n separator := keccak256(m, 0xa0)\n }\n }\n _cachedDomainSeparator = separator;\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* FUNCTIONS TO OVERRIDE */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Please override this function to return the domain name and version.\n /// ```\n /// function _domainNameAndVersion()\n /// internal\n /// pure\n /// virtual\n /// returns (string memory name, string memory version)\n /// {\n /// name = \"Solady\";\n /// version = \"1\";\n /// }\n /// ```\n ///\n /// Note: If the returned result may change after the contract has been deployed,\n /// you must override `_domainNameAndVersionMayChange()` to return true.\n function _domainNameAndVersion()\n internal\n view\n virtual\n returns (string memory name, string memory version);\n\n /// @dev Returns if `_domainNameAndVersion()` may change\n /// after the contract has been deployed (i.e. after the constructor).\n /// Default: false.\n function _domainNameAndVersionMayChange() internal pure virtual returns (bool result) {}\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* HASHING OPERATIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Returns the EIP-712 domain separator.\n function _domainSeparator() internal view virtual returns (bytes32 separator) {\n if (_domainNameAndVersionMayChange()) {\n separator = _buildDomainSeparator();\n } else {\n separator = _cachedDomainSeparator;\n if (_cachedDomainSeparatorInvalidated()) separator = _buildDomainSeparator();\n }\n }\n\n /// @dev Returns the hash of the fully encoded EIP-712 message for this domain,\n /// given `structHash`, as defined in\n /// https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct.\n ///\n /// The hash can be used together with {ECDSA-recover} to obtain the signer of a message:\n /// ```\n /// bytes32 digest = _hashTypedData(keccak256(abi.encode(\n /// keccak256(\"Mail(address to,string contents)\"),\n /// mailTo,\n /// keccak256(bytes(mailContents))\n /// )));\n /// address signer = ECDSA.recover(digest, signature);\n /// ```\n function _hashTypedData(bytes32 structHash) internal view virtual returns (bytes32 digest) {\n // We will use `digest` to store the domain separator to save a bit of gas.\n if (_domainNameAndVersionMayChange()) {\n digest = _buildDomainSeparator();\n } else {\n digest = _cachedDomainSeparator;\n if (_cachedDomainSeparatorInvalidated()) digest = _buildDomainSeparator();\n }\n /// @solidity memory-safe-assembly\n assembly {\n // Compute the digest.\n mstore(0x00, 0x1901000000000000) // Store \"\\x19\\x01\".\n mstore(0x1a, digest) // Store the domain separator.\n mstore(0x3a, structHash) // Store the struct hash.\n digest := keccak256(0x18, 0x42)\n // Restore the part of the free memory slot that was overwritten.\n mstore(0x3a, 0)\n }\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* EIP-5267 OPERATIONS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev See: https://eips.ethereum.org/EIPS/eip-5267\n function eip712Domain()\n public\n view\n virtual\n returns (\n bytes1 fields,\n string memory name,\n string memory version,\n uint256 chainId,\n address verifyingContract,\n bytes32 salt,\n uint256[] memory extensions\n )\n {\n fields = hex\"0f\"; // `0b01111`.\n (name, version) = _domainNameAndVersion();\n chainId = block.chainid;\n verifyingContract = address(this);\n salt = salt; // `bytes32(0)`.\n extensions = extensions; // `new uint256[](0)`.\n }\n\n /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n /* PRIVATE HELPERS */\n /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n /// @dev Returns the EIP-712 domain separator.\n function _buildDomainSeparator() private view returns (bytes32 separator) {\n // We will use `separator` to store the name hash to save a bit of gas.\n bytes32 versionHash;\n if (_domainNameAndVersionMayChange()) {\n (string memory name, string memory version) = _domainNameAndVersion();\n separator = keccak256(bytes(name));\n versionHash = keccak256(bytes(version));\n } else {\n separator = _cachedNameHash;\n versionHash = _cachedVersionHash;\n }\n /// @solidity memory-safe-assembly\n assembly {\n let m := mload(0x40) // Load the free memory pointer.\n mstore(m, _DOMAIN_TYPEHASH)\n mstore(add(m, 0x20), separator) // Name hash.\n mstore(add(m, 0x40), versionHash)\n mstore(add(m, 0x60), chainid())\n mstore(add(m, 0x80), address())\n separator := keccak256(m, 0xa0)\n }\n }\n\n /// @dev Returns if the cached domain separator has been invalidated.\n function _cachedDomainSeparatorInvalidated() private view returns (bool result) {\n uint256 cachedChainId = _cachedChainId;\n uint256 cachedThis = _cachedThis;\n /// @solidity memory-safe-assembly\n assembly {\n result := iszero(and(eq(chainid(), cachedChainId), eq(address(), cachedThis)))\n }\n }\n}\n" + }, + "src/access/AccessController.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.12;\n\nimport \"../interfaces/IAccessController.sol\";\n\nabstract contract AccessController is IAccessController {\n uint128 immutable MULTIPLY_FACTOR = 1000;\n uint16 immutable SIXTY_PERCENT = 600;\n uint24 immutable INITIAL_PROPOSAL_TIMELOCK = 24 hours;\n\n uint256 public ownerCount;\n uint256 public guardianCount;\n uint256 public proposalId;\n uint256 public proposalTimelock;\n mapping(address => bool) private owners;\n mapping(address => bool) private guardians;\n mapping(uint256 => NewOwnerProposal) private proposals;\n\n struct NewOwnerProposal {\n address newOwnerProposed;\n bool resolved;\n uint256 approvalCount;\n address[] guardiansApproved;\n uint256 proposedAt;\n }\n\n modifier onlyOwner() {\n require(\n isOwner(msg.sender) || msg.sender == address(this),\n \"ACL:: only owner\"\n );\n _;\n }\n\n modifier onlyGuardian() {\n require(isGuardian(msg.sender), \"ACL:: only guardian\");\n _;\n }\n\n modifier onlyOwnerOrGuardian() {\n require(\n isOwner(msg.sender) || isGuardian(msg.sender),\n \"ACL:: only owner or guardian\"\n );\n _;\n }\n\n modifier onlyOwnerOrEntryPoint(address _entryPoint) {\n require(\n msg.sender == _entryPoint || isOwner(msg.sender),\n \"ACL:: not owner or entryPoint\"\n );\n _;\n }\n\n function isOwner(address _address) public view returns (bool) {\n return owners[_address];\n }\n\n function isGuardian(address _address) public view returns (bool) {\n return guardians[_address];\n }\n\n function addOwner(address _newOwner) external onlyOwner {\n _addOwner(_newOwner);\n }\n\n function removeOwner(address _owner) external onlyOwner {\n _removeOwner(_owner);\n }\n\n function addGuardian(address _newGuardian) external onlyOwner {\n _addGuardian(_newGuardian);\n }\n\n function removeGuardian(address _guardian) external onlyOwner {\n _removeGuardian(_guardian);\n }\n\n function changeProposalTimelock(uint256 _newTimelock) external onlyOwner {\n proposalTimelock = _newTimelock;\n emit ProposalTimelockChanged(_newTimelock);\n }\n\n function getProposal(\n uint256 _proposalId\n )\n public\n view\n returns (\n address ownerProposed_,\n uint256 approvalCount_,\n address[] memory guardiansApproved_,\n bool resolved_,\n uint256 proposedAt_\n )\n {\n require(\n _proposalId != 0 && _proposalId <= proposalId,\n \"ACL:: invalid proposal id\"\n );\n NewOwnerProposal memory proposal = proposals[_proposalId];\n return (\n proposal.newOwnerProposed,\n proposal.approvalCount,\n proposal.guardiansApproved,\n proposal.resolved,\n proposal.proposedAt\n );\n }\n\n function discardCurrentProposal() external onlyOwnerOrGuardian {\n require(\n !proposals[proposalId].resolved,\n \"ACL:: proposal already resolved\"\n );\n if (isGuardian(msg.sender) && proposalTimelock > 0)\n require(\n (proposals[proposalId].proposedAt + proposalTimelock) <\n block.timestamp,\n \"ACL:: guardian cannot discard proposal until timelock relased\"\n );\n if (isGuardian(msg.sender) && proposalTimelock == 0)\n require(\n (proposals[proposalId].proposedAt + INITIAL_PROPOSAL_TIMELOCK) <\n block.timestamp,\n \"ACL:: guardian cannot discard proposal until timelock relased\"\n );\n proposals[proposalId].resolved = true;\n emit ProposalDiscarded(proposalId, msg.sender);\n }\n\n function guardianPropose(address _newOwner) external onlyGuardian {\n require(\n guardianCount >= 3,\n \"ACL:: not enough guardians to propose new owner (minimum 3)\"\n );\n if (\n proposals[proposalId].guardiansApproved.length != 0 &&\n proposals[proposalId].resolved == false\n ) revert(\"ACL:: latest proposal not yet resolved\");\n\n proposalId = proposalId + 1;\n proposals[proposalId].newOwnerProposed = _newOwner;\n proposals[proposalId].guardiansApproved.push(msg.sender);\n proposals[proposalId].approvalCount += 1;\n proposals[proposalId].resolved = false;\n proposals[proposalId].proposedAt = block.timestamp;\n emit ProposalSubmitted(proposalId, _newOwner, msg.sender);\n }\n\n function guardianCosign() external onlyGuardian {\n require(proposalId != 0, \"ACL:: invalid proposal id\");\n require(\n !_checkIfSigned(proposalId),\n \"ACL:: guardian already signed proposal\"\n );\n require(\n !proposals[proposalId].resolved,\n \"ACL:: proposal already resolved\"\n );\n proposals[proposalId].guardiansApproved.push(msg.sender);\n proposals[proposalId].approvalCount += 1;\n address newOwner = proposals[proposalId].newOwnerProposed;\n if (_checkQuorumReached(proposalId)) {\n proposals[proposalId].resolved = true;\n _addOwner(newOwner);\n } else {\n emit QuorumNotReached(\n proposalId,\n newOwner,\n proposals[proposalId].approvalCount\n );\n }\n }\n\n // INTERNAL\n\n function _addOwner(address _newOwner) internal {\n // no check for address(0) as used when creating wallet via BLS.\n require(_newOwner != address(0), \"ACL:: zero address\");\n require(!owners[_newOwner], \"ACL:: already owner\");\n if (isGuardian(_newOwner)) revert(\"ACL:: guardian cannot be owner\");\n emit OwnerAdded(_newOwner);\n owners[_newOwner] = true;\n ownerCount = ownerCount + 1;\n }\n\n function _addGuardian(address _newGuardian) internal {\n require(_newGuardian != address(0), \"ACL:: zero address\");\n require(!guardians[_newGuardian], \"ACL:: already guardian\");\n require(!isOwner(_newGuardian), \"ACL:: guardian cannot be owner\");\n emit GuardianAdded(_newGuardian);\n guardians[_newGuardian] = true;\n guardianCount = guardianCount + 1;\n }\n\n function _removeOwner(address _owner) internal {\n require(owners[_owner], \"ACL:: non-existant owner\");\n require(ownerCount > 1, \"ACL:: wallet cannot be ownerless\");\n emit OwnerRemoved(_owner);\n owners[_owner] = false;\n ownerCount = ownerCount - 1;\n }\n\n function _removeGuardian(address _guardian) internal {\n require(guardians[_guardian], \"ACL:: non-existant guardian\");\n emit GuardianRemoved(_guardian);\n guardians[_guardian] = false;\n guardianCount = guardianCount - 1;\n }\n\n function _checkIfSigned(uint256 _proposalId) internal view returns (bool) {\n for (uint i; i < proposals[_proposalId].guardiansApproved.length; i++) {\n if (proposals[_proposalId].guardiansApproved[i] == msg.sender) {\n return true;\n }\n }\n return false;\n }\n\n function _checkQuorumReached(\n uint256 _proposalId\n ) internal view returns (bool) {\n return ((proposals[_proposalId].approvalCount * MULTIPLY_FACTOR) /\n guardianCount >=\n SIXTY_PERCENT);\n }\n}\n" + }, + "src/helpers/UniversalSignatureValidator.sol": { + "content": "// As per ERC-6492 example\n// SPDX-License-Identifier: MIT\npragma solidity ^0.8.12;\n\nimport \"../interfaces/IERC1271Wallet.sol\";\n\nerror ERC1271Revert(bytes error);\nerror ERC6492DeployFailed(bytes error);\n\ncontract UniversalSigValidator {\n bytes32 private constant ERC6492_DETECTION_SUFFIX =\n 0x6492649264926492649264926492649264926492649264926492649264926492;\n bytes4 private constant ERC1271_SUCCESS = 0x1626ba7e;\n\n function isValidSigImpl(\n address _signer,\n bytes32 _hash,\n bytes calldata _signature,\n bool allowSideEffects\n ) public returns (bool) {\n uint contractCodeLen = address(_signer).code.length;\n bytes memory sigToValidate;\n // The order here is striclty defined in https://eips.ethereum.org/EIPS/eip-6492\n // - ERC-6492 suffix check and verification first, while being permissive in case the contract is already deployed; if the contract is deployed we will check the sig against the deployed version, this allows 6492 signatures to still be validated while taking into account potential key rotation\n // - ERC-1271 verification if there's contract code\n // - finally, ecrecover\n bool isCounterfactual = bytes32(\n _signature[_signature.length - 32:_signature.length]\n ) == ERC6492_DETECTION_SUFFIX;\n if (isCounterfactual) {\n address create2Factory;\n bytes memory factoryCalldata;\n (create2Factory, factoryCalldata, sigToValidate) = abi.decode(\n _signature[0:_signature.length - 32],\n (address, bytes, bytes)\n );\n\n if (contractCodeLen == 0) {\n (bool success, bytes memory err) = create2Factory.call(\n factoryCalldata\n );\n if (!success) revert ERC6492DeployFailed(err);\n }\n } else {\n sigToValidate = _signature;\n }\n\n // Try ERC-1271 verification\n if (isCounterfactual || contractCodeLen > 0) {\n try\n IERC1271Wallet(_signer).isValidSignature(_hash, sigToValidate)\n returns (bytes4 magicValue) {\n bool isValid = magicValue == ERC1271_SUCCESS;\n\n if (\n contractCodeLen == 0 &&\n isCounterfactual &&\n !allowSideEffects\n ) {\n // if the call had side effects we need to return the\n // result using a `revert` (to undo the state changes)\n assembly {\n mstore(0, isValid)\n revert(31, 1)\n }\n }\n\n return isValid;\n } catch (bytes memory err) {\n revert ERC1271Revert(err);\n }\n }\n\n // ecrecover verification\n require(\n _signature.length == 65,\n \"SignatureValidator#recoverSigner: invalid signature length\"\n );\n bytes32 r = bytes32(_signature[0:32]);\n bytes32 s = bytes32(_signature[32:64]);\n uint8 v = uint8(_signature[64]);\n if (v != 27 && v != 28) {\n revert(\"SignatureValidator: invalid signature v value\");\n }\n return ecrecover(_hash, v, r, s) == _signer;\n }\n\n function isValidSigWithSideEffects(\n address _signer,\n bytes32 _hash,\n bytes calldata _signature\n ) external returns (bool) {\n return this.isValidSigImpl(_signer, _hash, _signature, true);\n }\n\n function isValidSig(\n address _signer,\n bytes32 _hash,\n bytes calldata _signature\n ) external returns (bool) {\n try this.isValidSigImpl(_signer, _hash, _signature, false) returns (\n bool isValid\n ) {\n return isValid;\n } catch (bytes memory error) {\n // in order to avoid side effects from the contract getting deployed, the entire call will revert with a single byte result\n uint len = error.length;\n if (len == 1) return error[0] == 0x01;\n // all other errors are simply forwarded, but in custom formats so that nothing else can revert with a single byte in the call\n else\n assembly {\n revert(error, len)\n }\n }\n }\n}\n\n// this is a helper so we can perform validation in a single eth_call without pre-deploying a singleton\ncontract ValidateSigOffchain {\n constructor(address _signer, bytes32 _hash, bytes memory _signature) {\n UniversalSigValidator validator = new UniversalSigValidator();\n bool isValidSig = validator.isValidSigWithSideEffects(\n _signer,\n _hash,\n _signature\n );\n assembly {\n mstore(0, isValidSig)\n return(31, 1)\n }\n }\n}\n" + }, + "src/interfaces/IAccessController.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.12;\n\ninterface IAccessController {\n event OwnerAdded(address newOwner);\n event OwnerRemoved(address removedOwner);\n event GuardianAdded(address newGuardian);\n event GuardianRemoved(address removedGuardian);\n event ProposalSubmitted(\n uint256 proposalId,\n address newOwnerProposed,\n address proposer\n );\n event QuorumNotReached(\n uint256 proposalId,\n address newOwnerProposed,\n uint256 approvalCount\n );\n event ProposalDiscarded(uint256 proposalId, address discardedBy);\n event ProposalTimelockChanged(uint256 newTimelock);\n\n function isOwner(address _address) external view returns (bool);\n\n function isGuardian(address _address) external view returns (bool);\n\n function addOwner(address _newOwner) external;\n\n function removeOwner(address _owner) external;\n\n function addGuardian(address _newGuardian) external;\n\n function removeGuardian(address _guardian) external;\n\n function changeProposalTimelock(uint256 _newTimelock) external;\n\n function getProposal(\n uint256 _proposalId\n )\n external\n view\n returns (\n address ownerProposed_,\n uint256 approvalCount_,\n address[] memory guardiansApproved_,\n bool resolved_,\n uint256 proposedAt_\n );\n\n function discardCurrentProposal() external;\n\n function guardianPropose(address _newOwner) external;\n\n function guardianCosign() external;\n}\n" + }, + "src/interfaces/IERC1271Wallet.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.12;\n\ninterface IERC1271Wallet {\n function isValidSignature(\n bytes32 hash,\n bytes calldata signature\n ) external view returns (bytes4 magicValue);\n}\n" + }, + "src/interfaces/IEtherspotPaymaster.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.12;\n\nimport \"../../account-abstraction/contracts/interfaces/PackedUserOperation.sol\";\nimport \"../interfaces/IWhitelist.sol\";\n\ninterface IEtherspotPaymaster is IWhitelist {\n enum PostOpMode {\n opSucceeded,\n opReverted,\n postOpReverted\n }\n\n event SponsorSuccessful(address paymaster, address sender);\n\n function depositFunds() external payable;\n\n function withdrawFunds(address payable _sponsor, uint256 _amount) external;\n\n function getSponsorBalance(\n address _sponsor\n ) external view returns (uint256);\n\n function addStake(uint32 unstakeDelaySec) external payable;\n\n function unlockStake() external;\n\n function withdrawStake(address payable withdrawAddress) external;\n\n function getDeposit() external view returns (uint256);\n\n function validatePaymasterUserOp(\n PackedUserOperation calldata userOp,\n bytes32 userOpHash,\n uint256 maxCost\n ) external returns (bytes memory context, uint256 validationData);\n\n function parsePaymasterAndData(\n bytes calldata paymasterAndData\n )\n external\n pure\n returns (\n uint48 validUntil,\n uint48 validAfter,\n bytes calldata signature\n );\n\n function postOp(\n PostOpMode mode,\n bytes calldata context,\n uint256 actualGasCost\n ) external;\n\n function getHash(\n PackedUserOperation calldata userOp,\n uint48 validUntil,\n uint48 validAfter\n ) external view returns (bytes32);\n}\n" + }, + "src/interfaces/IEtherspotWallet.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.12;\n\nimport {IEntryPoint} from \"../../account-abstraction/contracts/interfaces/IEntryPoint.sol\";\nimport \"../interfaces/IAccessController.sol\";\nimport \"../interfaces/IERC1271Wallet.sol\";\n\ninterface IEtherspotWallet is IAccessController, IERC1271Wallet {\n event EtherspotWalletInitialized(\n IEntryPoint indexed entryPoint,\n address indexed owner\n );\n event EtherspotWalletReceived(address indexed from, uint256 indexed amount);\n\n function entryPoint() external view returns (IEntryPoint);\n\n function execute(address dest, uint256 value, bytes calldata func) external;\n\n function executeBatch(\n address[] calldata dest,\n uint256[] calldata value,\n bytes[] calldata func\n ) external;\n\n function isValidSignature(\n bytes32 hash,\n bytes calldata signature\n ) external view returns (bytes4 magicValue);\n\n function getDeposit() external view returns (uint256);\n\n function addDeposit() external payable;\n\n function withdrawDepositTo(\n address payable withdrawAddress,\n uint256 amount\n ) external;\n\n receive() external payable;\n}\n" + }, + "src/interfaces/IEtherspotWalletFactory.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.12;\n\ninterface IEtherspotWalletFactory {\n event AccountCreation(\n address indexed wallet,\n address indexed owner,\n uint256 index\n );\n event ImplementationSet(address newImplementation);\n\n function accountCreationCode() external pure returns (bytes memory);\n\n function createAccount(\n address _owner,\n uint256 _index\n ) external returns (address ret);\n\n function getAddress(\n address _owner,\n uint256 _index\n ) external view returns (address proxy);\n\n function checkImplementation(address _impl) external view returns (bool);\n}\n" + }, + "src/interfaces/IWhitelist.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.12;\n\ninterface IWhitelist {\n event AddedToWhitelist(address indexed paymaster, address indexed account);\n event AddedBatchToWhitelist(\n address indexed paymaster,\n address[] indexed accounts\n );\n event RemovedFromWhitelist(\n address indexed paymaster,\n address indexed account\n );\n event RemovedBatchFromWhitelist(\n address indexed paymaster,\n address[] indexed accounts\n );\n\n function check(\n address _sponsor,\n address _account\n ) external view returns (bool);\n\n function addToWhitelist(address _account) external;\n\n function addBatchToWhitelist(address[] calldata _accounts) external;\n\n function removeFromWhitelist(address _account) external;\n\n function removeBatchFromWhitelist(address[] calldata _accounts) external;\n}\n" + }, + "src/paymaster/BasePaymaster.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.23;\n\n/* solhint-disable reason-string */\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\nimport \"../../account-abstraction/contracts/interfaces/IPaymaster.sol\";\nimport \"../../account-abstraction/contracts/interfaces/IEntryPoint.sol\";\nimport \"../../account-abstraction/contracts/core/UserOperationLib.sol\";\n\n/**\n * Helper class for creating a paymaster.\n * provides helper methods for staking.\n * Validates that the postOp is called only by the entryPoint.\n */\nabstract contract BasePaymaster is IPaymaster, Ownable {\n IEntryPoint public immutable entryPoint;\n\n uint256 internal constant PAYMASTER_VALIDATION_GAS_OFFSET =\n UserOperationLib.PAYMASTER_VALIDATION_GAS_OFFSET;\n uint256 internal constant PAYMASTER_POSTOP_GAS_OFFSET =\n UserOperationLib.PAYMASTER_POSTOP_GAS_OFFSET;\n uint256 internal constant PAYMASTER_DATA_OFFSET =\n UserOperationLib.PAYMASTER_DATA_OFFSET;\n\n constructor(IEntryPoint _entryPoint) Ownable(msg.sender) {\n _validateEntryPointInterface(_entryPoint);\n entryPoint = _entryPoint;\n }\n\n //sanity check: make sure this EntryPoint was compiled against the same\n // IEntryPoint of this paymaster\n function _validateEntryPointInterface(\n IEntryPoint _entryPoint\n ) internal virtual returns (bool) {\n require(\n IERC165(address(_entryPoint)).supportsInterface(\n type(IEntryPoint).interfaceId\n ),\n \"IEntryPoint interface mismatch\"\n );\n }\n\n /// @inheritdoc IPaymaster\n function validatePaymasterUserOp(\n PackedUserOperation calldata userOp,\n bytes32 userOpHash,\n uint256 maxCost\n ) external override returns (bytes memory context, uint256 validationData) {\n _requireFromEntryPoint();\n return _validatePaymasterUserOp(userOp, userOpHash, maxCost);\n }\n\n /**\n * Validate a user operation.\n * @param userOp - The user operation.\n * @param userOpHash - The hash of the user operation.\n * @param maxCost - The maximum cost of the user operation.\n */\n function _validatePaymasterUserOp(\n PackedUserOperation calldata userOp,\n bytes32 userOpHash,\n uint256 maxCost\n ) internal virtual returns (bytes memory context, uint256 validationData);\n\n /// @inheritdoc IPaymaster\n function postOp(\n PostOpMode mode,\n bytes calldata context,\n uint256 actualGasCost,\n uint256 actualUserOpFeePerGas\n ) external override {\n _requireFromEntryPoint();\n _postOp(mode, context, actualGasCost, actualUserOpFeePerGas);\n }\n\n /**\n * Post-operation handler.\n * (verified to be called only through the entryPoint)\n * @dev If subclass returns a non-empty context from validatePaymasterUserOp,\n * it must also implement this method.\n * @param mode - Enum with the following options:\n * opSucceeded - User operation succeeded.\n * opReverted - User op reverted. The paymaster still has to pay for gas.\n * postOpReverted - never passed in a call to postOp().\n * @param context - The context value returned by validatePaymasterUserOp\n * @param actualGasCost - Actual gas used so far (without this postOp call).\n * @param actualUserOpFeePerGas - the gas price this UserOp pays. This value is based on the UserOp's maxFeePerGas\n * and maxPriorityFee (and basefee)\n * It is not the same as tx.gasprice, which is what the bundler pays.\n */\n function _postOp(\n PostOpMode mode,\n bytes calldata context,\n uint256 actualGasCost,\n uint256 actualUserOpFeePerGas\n ) internal virtual {\n (mode, context, actualGasCost, actualUserOpFeePerGas); // unused params\n // subclass must override this method if validatePaymasterUserOp returns a context\n revert(\"must override\");\n }\n\n // /**\n // * Add a deposit for this paymaster, used for paying for transaction fees.\n // */\n // function deposit() public payable {\n // entryPoint.depositTo{value: msg.value}(address(this));\n // }\n\n // /**\n // * Withdraw value from the deposit.\n // * @param withdrawAddress - Target to send to.\n // * @param amount - Amount to withdraw.\n // */\n // function withdrawTo(\n // address payable withdrawAddress,\n // uint256 amount\n // ) public onlyOwner {\n // entryPoint.withdrawTo(withdrawAddress, amount);\n // }\n\n /**\n * Add stake for this paymaster.\n * This method can also carry eth value to add to the current stake.\n * @param unstakeDelaySec - The unstake delay for this paymaster. Can only be increased.\n */\n function addStake(uint32 unstakeDelaySec) external payable onlyOwner {\n entryPoint.addStake{value: msg.value}(unstakeDelaySec);\n }\n\n /**\n * Return current paymaster's deposit on the entryPoint.\n */\n function getDeposit() public view returns (uint256) {\n return entryPoint.balanceOf(address(this));\n }\n\n /**\n * Unlock the stake, in order to withdraw it.\n * The paymaster can't serve requests once unlocked, until it calls addStake again\n */\n function unlockStake() external onlyOwner {\n entryPoint.unlockStake();\n }\n\n /**\n * Withdraw the entire paymaster's stake.\n * stake must be unlocked first (and then wait for the unstakeDelay to be over)\n * @param withdrawAddress - The address to send withdrawn value.\n */\n function withdrawStake(address payable withdrawAddress) external onlyOwner {\n entryPoint.withdrawStake(withdrawAddress);\n }\n\n /**\n * Validate the call is made from a valid entrypoint\n */\n function _requireFromEntryPoint() internal virtual {\n require(msg.sender == address(entryPoint), \"Sender not EntryPoint\");\n }\n}\n" + }, + "src/paymaster/EtherspotPaymaster.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.23;\n\n/* solhint-disable reason-string */\n\nimport \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\nimport \"@openzeppelin/contracts/utils/ReentrancyGuard.sol\";\nimport \"@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol\";\nimport \"../../account-abstraction/contracts/core/UserOperationLib.sol\";\nimport \"../../account-abstraction/contracts/core/Helpers.sol\";\nimport \"./BasePaymaster.sol\";\nimport \"./Whitelist.sol\";\n\n/**\n * A sample paymaster that uses external service to decide whether to pay for the UserOp.\n * The paymaster trusts an external signer to sign the transaction.\n * The calling user must pass the UserOp to that external signer first, which performs\n * whatever off-chain verification before signing the UserOp.\n * Note that this signature is NOT a replacement for wallet signature:\n * - the paymaster signs to agree to PAY for GAS.\n * - the wallet signs to prove identity and account ownership.\n */\ncontract EtherspotPaymaster is BasePaymaster, Whitelist, ReentrancyGuard {\n using UserOperationLib for PackedUserOperation;\n\n uint256 private constant VALID_TIMESTAMP_OFFSET = PAYMASTER_DATA_OFFSET;\n uint256 private constant SIGNATURE_OFFSET = VALID_TIMESTAMP_OFFSET + 64;\n // calculated cost of the postOp\n uint256 private constant COST_OF_POST = 40000;\n\n mapping(address => uint256) private _sponsorBalances;\n\n event SponsorSuccessful(address paymaster, address sender);\n\n constructor(IEntryPoint _entryPoint) BasePaymaster(_entryPoint) {}\n\n function depositFunds() external payable nonReentrant {\n _creditSponsor(msg.sender, msg.value);\n entryPoint.depositTo{value: msg.value}(address(this));\n }\n\n function withdrawFunds(uint256 _amount) external nonReentrant {\n require(\n getSponsorBalance(msg.sender) >= _amount,\n \"EtherspotPaymaster:: not enough deposited funds\"\n );\n _debitSponsor(msg.sender, _amount);\n entryPoint.withdrawTo(payable(msg.sender), _amount);\n }\n\n function getSponsorBalance(address _sponsor) public view returns (uint256) {\n return _sponsorBalances[_sponsor];\n }\n\n function _debitSponsor(address _sponsor, uint256 _amount) internal {\n _sponsorBalances[_sponsor] -= _amount;\n }\n\n function _creditSponsor(address _sponsor, uint256 _amount) internal {\n _sponsorBalances[_sponsor] += _amount;\n }\n\n /**\n * return the hash we're going to sign off-chain (and validate on-chain)\n * this method is called by the off-chain service, to sign the request.\n * it is called on-chain from the validatePaymasterUserOp, to validate the signature.\n * note that this signature covers all fields of the UserOperation, except the \"paymasterAndData\",\n * which will carry the signature itself.\n */\n function getHash(\n PackedUserOperation calldata userOp,\n uint48 validUntil,\n uint48 validAfter\n ) public view returns (bytes32) {\n //can't use userOp.hash(), since it contains also the paymasterAndData itself.\n address sender = userOp.getSender();\n return\n keccak256(\n abi.encode(\n sender,\n userOp.nonce,\n keccak256(userOp.initCode),\n keccak256(userOp.callData),\n userOp.accountGasLimits,\n uint256(\n bytes32(\n userOp\n .paymasterAndData[PAYMASTER_VALIDATION_GAS_OFFSET:PAYMASTER_DATA_OFFSET]\n )\n ),\n userOp.preVerificationGas,\n userOp.gasFees,\n block.chainid,\n address(this),\n validUntil,\n validAfter\n )\n );\n }\n\n /**\n * verify our external signer signed this request.\n * the \"paymasterAndData\" is expected to be the paymaster and a signature over the entire request params\n * paymasterAndData[:20] : address(this)\n * paymasterAndData[20:84] : abi.encode(validUntil, validAfter)\n * paymasterAndData[84:] : signature\n */\n function _validatePaymasterUserOp(\n PackedUserOperation calldata userOp,\n bytes32 /*userOpHash*/,\n uint256 requiredPreFund\n ) internal override returns (bytes memory context, uint256 validationData) {\n (requiredPreFund);\n\n (\n uint48 validUntil,\n uint48 validAfter,\n bytes calldata signature\n ) = parsePaymasterAndData(userOp.paymasterAndData);\n // ECDSA library supports both 64 and 65-byte long signatures.\n // we only \"require\" it here so that the revert reason on invalid signature will be of \"EtherspotPaymaster\", and not \"ECDSA\"\n require(\n signature.length == 64 || signature.length == 65,\n \"EtherspotPaymaster:: invalid signature length in paymasterAndData\"\n );\n bytes32 hash = MessageHashUtils.toEthSignedMessageHash(\n getHash(userOp, validUntil, validAfter)\n );\n address sig = userOp.getSender();\n\n // check for valid paymaster\n address sponsorSig = ECDSA.recover(hash, signature);\n\n // don't revert on signature failure: return SIG_VALIDATION_FAILED\n if (!_check(sponsorSig, sig)) {\n return (\"\", _packValidationData(true, validUntil, validAfter));\n }\n\n (, uint256 maxFeePerGas) = (\n uint128(bytes16(userOp.gasFees)),\n uint128(uint256(userOp.gasFees))\n );\n uint256 costOfPost = maxFeePerGas * COST_OF_POST;\n uint256 totalPreFund = requiredPreFund + costOfPost;\n\n // check sponsor has enough funds deposited to pay for gas\n require(\n getSponsorBalance(sponsorSig) >= totalPreFund,\n \"EtherspotPaymaster:: Sponsor paymaster funds too low\"\n );\n\n // debit requiredPreFund amount\n _debitSponsor(sponsorSig, totalPreFund);\n\n // no need for other on-chain validation: entire UserOp should have been checked\n // by the external service prior to signing it.\n return (\n abi.encode(sponsorSig, sig, totalPreFund, costOfPost),\n _packValidationData(false, validUntil, validAfter)\n );\n }\n\n function parsePaymasterAndData(\n bytes calldata paymasterAndData\n )\n public\n pure\n returns (uint48 validUntil, uint48 validAfter, bytes calldata signature)\n {\n (validUntil, validAfter) = abi.decode(\n paymasterAndData[VALID_TIMESTAMP_OFFSET:],\n (uint48, uint48)\n );\n signature = paymasterAndData[SIGNATURE_OFFSET:];\n }\n\n function _postOp(\n PostOpMode,\n bytes calldata context,\n uint256 actualGasCost,\n uint256 actualUserOpFeePerGas\n ) internal override {\n (\n address paymaster,\n address sender,\n uint256 totalPrefund,\n uint256 costOfPost\n ) = abi.decode(context, (address, address, uint256, uint256));\n _creditSponsor(paymaster, totalPrefund - (actualGasCost + costOfPost));\n emit SponsorSuccessful(paymaster, sender);\n }\n}\n" + }, + "src/paymaster/VerifyingPaymaster.sol": { + "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.23;\n\n// @dev eth-infinitism/account-abstraction contract with addition of updating verifying signer.\n\n/* solhint-disable reason-string */\n/* solhint-disable no-inline-assembly */\n\nimport \"../../account-abstraction/contracts/core/BasePaymaster.sol\";\nimport \"../../account-abstraction/contracts/core/UserOperationLib.sol\";\nimport \"../../account-abstraction/contracts/core/Helpers.sol\";\nimport \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\nimport \"@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol\";\n/**\n * A sample paymaster that uses external service to decide whether to pay for the UserOp.\n * The paymaster trusts an external signer to sign the transaction.\n * The calling user must pass the UserOp to that external signer first, which performs\n * whatever off-chain verification before signing the UserOp.\n * Note that this signature is NOT a replacement for the account-specific signature:\n * - the paymaster checks a signature to agree to PAY for GAS.\n * - the account checks a signature to prove identity and account ownership.\n */\ncontract VerifyingPaymaster is BasePaymaster {\n using UserOperationLib for PackedUserOperation;\n\n address public verifyingSigner;\n\n uint256 private constant VALID_TIMESTAMP_OFFSET = PAYMASTER_DATA_OFFSET;\n\n uint256 private constant SIGNATURE_OFFSET = VALID_TIMESTAMP_OFFSET + 64;\n\n event VerifyingSignerUpdated(address newVerifyingSigner);\n\n constructor(\n IEntryPoint _entryPoint,\n address _verifyingSigner\n ) BasePaymaster(_entryPoint) {\n verifyingSigner = _verifyingSigner;\n }\n\n /**\n * return the hash we're going to sign off-chain (and validate on-chain)\n * this method is called by the off-chain service, to sign the request.\n * it is called on-chain from the validatePaymasterUserOp, to validate the signature.\n * note that this signature covers all fields of the UserOperation, except the \"paymasterAndData\",\n * which will carry the signature itself.\n */\n function getHash(\n PackedUserOperation calldata userOp,\n uint48 validUntil,\n uint48 validAfter\n ) public view returns (bytes32) {\n //can't use userOp.hash(), since it contains also the paymasterAndData itself.\n address sender = userOp.getSender();\n return\n keccak256(\n abi.encode(\n sender,\n userOp.nonce,\n keccak256(userOp.initCode),\n keccak256(userOp.callData),\n userOp.accountGasLimits,\n uint256(\n bytes32(\n userOp\n .paymasterAndData[PAYMASTER_VALIDATION_GAS_OFFSET:PAYMASTER_DATA_OFFSET]\n )\n ),\n userOp.preVerificationGas,\n userOp.gasFees,\n block.chainid,\n address(this),\n validUntil,\n validAfter\n )\n );\n }\n\n /**\n * verify our external signer signed this request.\n * the \"paymasterAndData\" is expected to be the paymaster and a signature over the entire request params\n * paymasterAndData[:20] : address(this)\n * paymasterAndData[20:84] : abi.encode(validUntil, validAfter)\n * paymasterAndData[84:] : signature\n */\n function _validatePaymasterUserOp(\n PackedUserOperation calldata userOp,\n bytes32 /*userOpHash*/,\n uint256 requiredPreFund\n )\n internal\n view\n override\n returns (bytes memory context, uint256 validationData)\n {\n (requiredPreFund);\n\n (\n uint48 validUntil,\n uint48 validAfter,\n bytes calldata signature\n ) = parsePaymasterAndData(userOp.paymasterAndData);\n //ECDSA library supports both 64 and 65-byte long signatures.\n // we only \"require\" it here so that the revert reason on invalid signature will be of \"VerifyingPaymaster\", and not \"ECDSA\"\n require(\n signature.length == 64 || signature.length == 65,\n \"VerifyingPaymaster: invalid signature length in paymasterAndData\"\n );\n bytes32 hash = MessageHashUtils.toEthSignedMessageHash(\n getHash(userOp, validUntil, validAfter)\n );\n\n //don't revert on signature failure: return SIG_VALIDATION_FAILED\n if (verifyingSigner != ECDSA.recover(hash, signature)) {\n return (\"\", _packValidationData(true, validUntil, validAfter));\n }\n\n //no need for other on-chain validation: entire UserOp should have been checked\n // by the external service prior to signing it.\n return (\"\", _packValidationData(false, validUntil, validAfter));\n }\n\n function parsePaymasterAndData(\n bytes calldata paymasterAndData\n )\n public\n pure\n returns (uint48 validUntil, uint48 validAfter, bytes calldata signature)\n {\n (validUntil, validAfter) = abi.decode(\n paymasterAndData[VALID_TIMESTAMP_OFFSET:],\n (uint48, uint48)\n );\n signature = paymasterAndData[SIGNATURE_OFFSET:];\n }\n\n function updateVerifyingSigner(\n address _newVerifyingSigner\n ) public onlyOwner {\n verifyingSigner = _newVerifyingSigner;\n emit VerifyingSignerUpdated(_newVerifyingSigner);\n }\n}\n" + }, + "src/paymaster/Whitelist.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.12;\n\nimport \"../interfaces/IWhitelist.sol\";\n\ncontract Whitelist is IWhitelist {\n // Mappings\n mapping(address => mapping(address => bool)) private whitelist;\n\n // External\n function check(\n address _sponsor,\n address _account\n ) external view returns (bool) {\n return _check(_sponsor, _account);\n }\n\n function addToWhitelist(address _account) external {\n _add(_account);\n emit AddedToWhitelist(msg.sender, _account);\n }\n\n function addBatchToWhitelist(address[] calldata _accounts) external {\n _addBatch(_accounts);\n emit AddedBatchToWhitelist(msg.sender, _accounts);\n }\n\n function removeFromWhitelist(address _account) external {\n _remove(_account);\n emit RemovedFromWhitelist(msg.sender, _account);\n }\n\n function removeBatchFromWhitelist(address[] calldata _accounts) external {\n _removeBatch(_accounts);\n emit RemovedBatchFromWhitelist(msg.sender, _accounts);\n }\n\n // Internal\n function _check(\n address _sponsor,\n address _account\n ) internal view returns (bool) {\n return whitelist[_sponsor][_account];\n }\n\n function _add(address _account) internal {\n require(_account != address(0), \"Whitelist:: Zero address\");\n require(\n !_check(msg.sender, _account),\n \"Whitelist:: Account is already whitelisted\"\n );\n whitelist[msg.sender][_account] = true;\n }\n\n function _addBatch(address[] calldata _accounts) internal {\n for (uint256 ii; ii < _accounts.length; ++ii) {\n _add(_accounts[ii]);\n }\n }\n\n function _remove(address _account) internal {\n require(_account != address(0), \"Whitelist:: Zero address\");\n require(\n _check(msg.sender, _account),\n \"Whitelist:: Account is not whitelisted\"\n );\n whitelist[msg.sender][_account] = false;\n }\n\n function _removeBatch(address[] calldata _accounts) internal {\n for (uint256 ii; ii < _accounts.length; ++ii) {\n _remove(_accounts[ii]);\n }\n }\n}\n" + }, + "src/wallet/EtherspotWallet.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.23;\n\n/* solhint-disable avoid-low-level-calls */\n/* solhint-disable no-inline-assembly */\n/* solhint-disable reason-string */\n\nimport \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\nimport \"@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol\";\nimport \"@openzeppelin/contracts/proxy/utils/Initializable.sol\";\nimport \"@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol\";\nimport {EIP712} from \"solady/src/utils/EIP712.sol\";\nimport \"../../account-abstraction/contracts/core/BaseAccount.sol\";\nimport \"../../account-abstraction/contracts/core/Helpers.sol\";\nimport \"../../account-abstraction/contracts/samples/callback/TokenCallbackHandler.sol\";\nimport \"../interfaces/IEtherspotWallet.sol\";\nimport \"../interfaces/IEtherspotWalletFactory.sol\";\nimport \"../access/AccessController.sol\";\n\ncontract EtherspotWallet is\n EIP712,\n BaseAccount,\n UUPSUpgradeable,\n Initializable,\n TokenCallbackHandler,\n AccessController,\n IEtherspotWallet\n{\n /// STORAGE\n IEntryPoint private immutable _entryPoint;\n IEtherspotWalletFactory private immutable _walletFactory;\n bytes32 internal constant EIP712_DOMAIN_TYPEHASH =\n 0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f;\n string constant NAME = \"EtherspotWallet\";\n string constant VERSION = \"2.0.0\";\n\n /// EXTERNAL METHODS\n constructor(\n IEntryPoint anEntryPoint,\n IEtherspotWalletFactory anWalletFactory\n ) {\n require(\n address(anEntryPoint) != address(0) &&\n address(anWalletFactory) != address(0),\n \"EtherspotWallet:: invalid constructor parameter\"\n );\n _entryPoint = anEntryPoint;\n _walletFactory = anWalletFactory;\n _disableInitializers();\n // solhint-disable-previous-line no-empty-blocks\n }\n\n function execute(\n address dest,\n uint256 value,\n bytes calldata func\n ) external onlyOwnerOrEntryPoint(address(entryPoint())) {\n _call(dest, value, func);\n }\n\n /**\n * execute a sequence of transactions\n * @dev to reduce gas consumption for trivial case (no value), use a zero-length array to mean zero value\n * @param dest an array of destination addresses\n * @param value an array of values to pass to each call. can be zero-length for no-value calls\n * @param func an array of calldata to pass to each call\n */\n function executeBatch(\n address[] calldata dest,\n uint256[] calldata value,\n bytes[] calldata func\n ) external onlyOwnerOrEntryPoint(address(entryPoint())) {\n require(\n dest.length == func.length &&\n (value.length == 0 || value.length == func.length),\n \"EtherspotWallet:: executeBatch: wrong array lengths\"\n );\n if (value.length == 0) {\n for (uint256 i = 0; i < dest.length; i++) {\n _call(dest[i], 0, func[i]);\n }\n } else {\n for (uint256 i = 0; i < dest.length; i++) {\n _call(dest[i], value[i], func[i]);\n }\n }\n }\n\n /**\n * Implementation of ISignatureValidator\n * @dev doesn't allow the owner to be a smart contract, SCW should use {isValidSig}\n * @param hash 32 bytes hash of the data signed on the behalf of address(msg.sender)\n * @param signature Signature byte array associated with _dataHash\n * @return ERC1271 magic value.\n */\n function isValidSignature(\n bytes32 hash,\n bytes calldata signature\n ) external view returns (bytes4) {\n bytes32 domainSeparator = _domainSeparator();\n bytes32 signedMessageHash = keccak256(\n abi.encodePacked(\"\\x19\\x01\", domainSeparator, hash)\n );\n bytes32 ethHash = MessageHashUtils.toEthSignedMessageHash(\n signedMessageHash\n );\n address owner = ECDSA.recover(ethHash, signature);\n if (isOwner(owner)) {\n return 0x1626ba7e;\n }\n return 0xffffffff;\n }\n\n receive() external payable {\n emit EtherspotWalletReceived(msg.sender, msg.value);\n }\n\n /// PUBLIC\n\n /// @inheritdoc BaseAccount\n function entryPoint()\n public\n view\n virtual\n override(BaseAccount, IEtherspotWallet)\n returns (IEntryPoint)\n {\n return _entryPoint;\n }\n\n /**\n * check current account deposit in the entryPoint\n */\n function getDeposit() public view returns (uint256) {\n return entryPoint().balanceOf(address(this));\n }\n\n function initialize(address anOwner) public virtual initializer {\n _initialize(anOwner);\n }\n\n /**\n * deposit more funds for this account in the entryPoint\n */\n function addDeposit() external payable {\n entryPoint().depositTo{value: msg.value}(address(this));\n }\n\n /**\n * withdraw value from the account's deposit\n * @param withdrawAddress target to send to\n * @param amount to withdraw\n */\n function withdrawDepositTo(\n address payable withdrawAddress,\n uint256 amount\n ) external onlyOwner {\n entryPoint().withdrawTo(withdrawAddress, amount);\n }\n\n /// INTERNAL\n\n function _initialize(address anOwner) internal virtual {\n _addOwner(anOwner);\n emit EtherspotWalletInitialized(_entryPoint, anOwner);\n }\n\n function _call(address target, uint256 value, bytes memory data) internal {\n (bool success, bytes memory result) = target.call{value: value}(data);\n if (!success) {\n assembly {\n revert(add(result, 32), mload(result))\n }\n }\n }\n\n function _validateSignature(\n PackedUserOperation calldata userOp,\n bytes32 userOpHash\n ) internal virtual override returns (uint256 validationData) {\n bytes32 hash = MessageHashUtils.toEthSignedMessageHash(userOpHash);\n if (!isOwner(ECDSA.recover(hash, userOp.signature)))\n return SIG_VALIDATION_FAILED;\n return SIG_VALIDATION_SUCCESS;\n }\n\n /// @dev EIP-712 compliant domain separator\n function _domainSeparator() internal view override returns (bytes32) {\n (string memory _name, string memory _version) = _domainNameAndVersion();\n bytes32 nameHash = keccak256(bytes(_name));\n bytes32 versionHash = keccak256(bytes(_version));\n // Use proxy address for the EIP-712 domain separator.\n address proxyAddress = address(this);\n // Construct domain separator with name, version, chainId, and proxy address.\n return\n keccak256(\n abi.encode(\n EIP712_DOMAIN_TYPEHASH,\n nameHash,\n versionHash,\n block.chainid,\n proxyAddress\n )\n );\n }\n\n function _domainNameAndVersion()\n internal\n pure\n override\n returns (string memory, string memory)\n {\n return (NAME, VERSION);\n }\n\n function _authorizeUpgrade(\n address newImplementation\n ) internal view override onlyOwner {\n require(\n _walletFactory.checkImplementation(newImplementation),\n \"EtherspotWallet:: upgrade implementation invalid\"\n );\n }\n}\n" + }, + "src/wallet/EtherspotWalletFactory.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport \"./EtherspotWallet.sol\";\nimport \"./Proxy.sol\";\nimport \"../interfaces/IEtherspotWalletFactory.sol\";\n\n/**\n * @title Proxy Factory - Allows to create a new proxy contract and execute a message call to the new proxy within one transaction.\n */\ncontract EtherspotWalletFactory is IEtherspotWalletFactory {\n address public accountImplementation;\n address public owner;\n\n event OwnerChanged(address newOwner);\n\n modifier onlyOwner() {\n require(owner == msg.sender, \"EtherspotWalletFactory:: only owner\");\n _;\n }\n\n constructor(address _owner) {\n owner = _owner;\n }\n\n /// @dev Allows to retrieve the creation code used for the Proxy deployment. With this it is easily possible to calculate predicted address.\n function accountCreationCode() public pure returns (bytes memory) {\n return type(Proxy).creationCode;\n }\n\n /**\n * @notice Creates a new account\n * @param _owner owner of the account to be deployed\n * @param _index extra salt that allows to deploy more account if needed for same owner\n * @return ret the address of the deployed account\n */\n function createAccount(\n address _owner,\n uint256 _index\n ) external returns (address ret) {\n require(\n accountImplementation != address(0),\n \"EtherspotWalletFactory:: implementation not set\"\n );\n address account = getAddress(_owner, _index);\n if (account.code.length > 0) {\n return account;\n }\n\n bytes memory initializer = getInitializer(_owner);\n\n bytes32 salt = keccak256(\n abi.encodePacked(keccak256(initializer), _index)\n );\n\n bytes memory deploymentData = abi.encodePacked(\n type(Proxy).creationCode,\n uint256(uint160(accountImplementation))\n );\n\n // solhint-disable-next-line no-inline-assembly\n assembly {\n ret := create2(\n 0x0,\n add(0x20, deploymentData),\n mload(deploymentData),\n salt\n )\n }\n require(address(ret) != address(0), \"Create2 call failed\");\n\n // calldata for init method\n if (initializer.length > 0) {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n if eq(\n call(\n gas(),\n ret,\n 0,\n add(initializer, 0x20),\n mload(initializer),\n 0,\n 0\n ),\n 0\n ) {\n revert(0, 0)\n }\n }\n }\n emit AccountCreation(ret, _owner, _index);\n }\n\n /**\n * @notice Deploys account using create2\n * @param _owner owner of the account to be deployed\n * @param _index extra salt that allows to deploy more account if needed for same owner\n */\n function getAddress(\n address _owner,\n uint256 _index\n ) public view returns (address proxy) {\n require(\n accountImplementation != address(0),\n \"EtherspotWalletFactory:: implementation not set\"\n );\n bytes memory initializer = getInitializer(_owner);\n bytes32 salt = keccak256(\n abi.encodePacked(keccak256(initializer), _index)\n );\n bytes memory code = abi.encodePacked(\n type(Proxy).creationCode,\n uint256(uint160(accountImplementation))\n );\n bytes32 hash = keccak256(\n abi.encodePacked(bytes1(0xff), address(this), salt, keccak256(code))\n );\n proxy = address(uint160(uint256(hash)));\n }\n\n /**\n * @dev Allows to retrieve the initializer data for the account.\n * @param _owner EOA signatory for the account to be deployed\n * @return initializer bytes for init method\n */\n function getInitializer(\n address _owner\n ) internal pure returns (bytes memory) {\n return abi.encodeCall(EtherspotWallet.initialize, (_owner));\n }\n\n /**\n * @dev Allows to set a new implementation contract address\n * @param _newImpl new implementation EtherspotWalletContract\n */\n function setImplementation(EtherspotWallet _newImpl) external onlyOwner {\n accountImplementation = address(_newImpl);\n emit ImplementationSet(accountImplementation);\n }\n\n /**\n * @dev Checks implementation address matches address\n * @param _impl address to check against\n * @return boolean (true if accountImplementation == address)\n */\n function checkImplementation(address _impl) external view returns (bool) {\n return accountImplementation == _impl;\n }\n\n function changeOwner(address _newOwner) external onlyOwner {\n require(\n _newOwner != address(0),\n \"EtherspotWalletFactory:: new owner cannot be zero address\"\n );\n owner = _newOwner;\n emit OwnerChanged(_newOwner);\n }\n}\n" + }, + "src/wallet/Proxy.sol": { + "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/**\n * @title Generic proxy contract allows to execute all transactions applying the code of a master contract.\n */\ncontract Proxy {\n bytes32 internal constant _IMPLEMENTATION_SLOT =\n 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n\n /**\n * @notice Constructor function sets address of singleton contract.\n * @param _singleton Singleton address.\n */\n constructor(address _singleton) {\n require(_singleton != address(0), \"Invalid address provided\");\n assembly {\n sstore(_IMPLEMENTATION_SLOT, _singleton)\n }\n }\n\n fallback() external payable {\n address target;\n // solhint-disable-next-line no-inline-assembly\n assembly {\n target := sload(_IMPLEMENTATION_SLOT)\n calldatacopy(0, 0, calldatasize())\n let success := delegatecall(gas(), target, 0, calldatasize(), 0, 0)\n returndatacopy(0, 0, returndatasize())\n if eq(success, 0) {\n revert(0, returndatasize())\n }\n return(0, returndatasize())\n }\n }\n}\n" + } + }, + "settings": { + "optimizer": { + "enabled": true, + "runs": 200 + }, + "evmVersion": "london", + "outputSelection": { + "*": { + "*": [ + "abi", + "evm.bytecode", + "evm.deployedBytecode", + "evm.methodIdentifiers", + "metadata", + "storageLayout", + "devdoc", + "userdoc", + "evm.gasEstimates" + ], + "": [ + "ast" + ] + } + }, + "metadata": { + "useLiteralContent": true + } + } +} \ No newline at end of file