From 79ba1d0b8f4e9d5262a8cd5cb7dfdff52f5128c1 Mon Sep 17 00:00:00 2001 From: Daniel Lim Date: Wed, 22 Jan 2025 13:10:24 -0800 Subject: [PATCH 1/2] chore: Add contracts deployment logs for EPv6 for SingleOwnerMSCAFactory Signed-off-by: Daniel Lim --- .../003_DeploySingleOwnerMSCAFactory.s.sol/1/run-1737572400.md | 3 +++ .../11155111/run-1737572400.md | 3 +++ .../130/run-1737572400.md | 3 +++ .../1301/run-1737572400.md | 3 +++ .../137/run-1737572400.md | 3 +++ .../42161/run-1737572400.md | 3 +++ .../421614/run-1737572400.md | 3 +++ .../80002/run-1737572400.md | 3 +++ .../SingleOwnerMSCAFactory | 0 .../SingleOwnerMSCAFactory | 1 + .../SingleOwnerMSCAFactory.json | 1 + .../abiEncodedConstructorArgs | 1 + .../ERC1967Proxy/ERC1967Proxy.json | 0 .../ERC1967Proxy/abiEncodedConstructorArgs | 0 .../SingleOwnerMSCA.json | 0 .../abiEncodedConstructorArgs | 0 .../SingleOwnerMSCAFactory.json | 0 .../abiEncodedConstructorArgs | 0 .../SingleOwnerMSCAFactory.json | 1 + .../abiEncodedConstructorArgs | 1 + 20 files changed, 29 insertions(+) create mode 100644 broadcast/003_DeploySingleOwnerMSCAFactory.s.sol/1/run-1737572400.md create mode 100644 broadcast/003_DeploySingleOwnerMSCAFactory.s.sol/11155111/run-1737572400.md create mode 100644 broadcast/003_DeploySingleOwnerMSCAFactory.s.sol/130/run-1737572400.md create mode 100644 broadcast/003_DeploySingleOwnerMSCAFactory.s.sol/1301/run-1737572400.md create mode 100644 broadcast/003_DeploySingleOwnerMSCAFactory.s.sol/137/run-1737572400.md create mode 100644 broadcast/003_DeploySingleOwnerMSCAFactory.s.sol/42161/run-1737572400.md create mode 100644 broadcast/003_DeploySingleOwnerMSCAFactory.s.sol/421614/run-1737572400.md create mode 100644 broadcast/003_DeploySingleOwnerMSCAFactory.s.sol/80002/run-1737572400.md rename script/cmd/{ => SingleOwnerMSCAFactory/0xa233b124D7b9CFF2D38cB62319e1A3f79144B490}/SingleOwnerMSCAFactory (100%) create mode 100644 script/cmd/SingleOwnerMSCAFactory/0xf61023061ed45fa9eAC4D2670649cE1FD37ce536/SingleOwnerMSCAFactory create mode 100644 script/verify/SingleOwnerMSCA/0xd206ac7fef53d83ed4563e770b28dba90d0d9ec8/SingleOwnerMSCAFactory.json create mode 100644 script/verify/SingleOwnerMSCA/0xd206ac7fef53d83ed4563e770b28dba90d0d9ec8/abiEncodedConstructorArgs rename script/verify/SingleOwnerMSCA/{ => 0xeF3d10Df6e8eeAa925dA46ea12a6F17aB7F43B70}/ERC1967Proxy/ERC1967Proxy.json (100%) rename script/verify/SingleOwnerMSCA/{ => 0xeF3d10Df6e8eeAa925dA46ea12a6F17aB7F43B70}/ERC1967Proxy/abiEncodedConstructorArgs (100%) rename script/verify/SingleOwnerMSCA/{ => 0xeF3d10Df6e8eeAa925dA46ea12a6F17aB7F43B70}/SingleOwnerMSCA.json (100%) rename script/verify/SingleOwnerMSCA/{ => 0xeF3d10Df6e8eeAa925dA46ea12a6F17aB7F43B70}/abiEncodedConstructorArgs (100%) rename script/verify/SingleOwnerMSCAFactory/{ => 0xa233b124D7b9CFF2D38cB62319e1A3f79144B490}/SingleOwnerMSCAFactory.json (100%) rename script/verify/SingleOwnerMSCAFactory/{ => 0xa233b124D7b9CFF2D38cB62319e1A3f79144B490}/abiEncodedConstructorArgs (100%) create mode 100644 script/verify/SingleOwnerMSCAFactory/0xf61023061ed45fa9eAC4D2670649cE1FD37ce536/SingleOwnerMSCAFactory.json create mode 100644 script/verify/SingleOwnerMSCAFactory/0xf61023061ed45fa9eAC4D2670649cE1FD37ce536/abiEncodedConstructorArgs diff --git a/broadcast/003_DeploySingleOwnerMSCAFactory.s.sol/1/run-1737572400.md b/broadcast/003_DeploySingleOwnerMSCAFactory.s.sol/1/run-1737572400.md new file mode 100644 index 0000000..7eec384 --- /dev/null +++ b/broadcast/003_DeploySingleOwnerMSCAFactory.s.sol/1/run-1737572400.md @@ -0,0 +1,3 @@ +- This chain used cast send to deploy so there's no corresponding run json +- Ran command in script/cmd/SingleOwnerMSCAFactory/0xf61023061ed45fa9eAC4D2670649cE1FD37ce536/SingleOwnerMSCAFactory +- tx hash: 0xbe9d1311397eac006c444a1d2f9a1ffc2f9d77607eeaf97562a93c738675d386 diff --git a/broadcast/003_DeploySingleOwnerMSCAFactory.s.sol/11155111/run-1737572400.md b/broadcast/003_DeploySingleOwnerMSCAFactory.s.sol/11155111/run-1737572400.md new file mode 100644 index 0000000..37c2209 --- /dev/null +++ b/broadcast/003_DeploySingleOwnerMSCAFactory.s.sol/11155111/run-1737572400.md @@ -0,0 +1,3 @@ +- This chain used cast send to deploy so there's no corresponding run json +- Ran command in script/cmd/SingleOwnerMSCAFactory/0xf61023061ed45fa9eAC4D2670649cE1FD37ce536/SingleOwnerMSCAFactory +- tx hash: 0xd28546c12461e5c8c80f9419efa4362693c39052a518baaf7828cbd46896c14f diff --git a/broadcast/003_DeploySingleOwnerMSCAFactory.s.sol/130/run-1737572400.md b/broadcast/003_DeploySingleOwnerMSCAFactory.s.sol/130/run-1737572400.md new file mode 100644 index 0000000..b93ee10 --- /dev/null +++ b/broadcast/003_DeploySingleOwnerMSCAFactory.s.sol/130/run-1737572400.md @@ -0,0 +1,3 @@ +- This chain used cast send to deploy so there's no corresponding run json +- Ran command in script/cmd/SingleOwnerMSCAFactory/0xf61023061ed45fa9eAC4D2670649cE1FD37ce536/SingleOwnerMSCAFactory +- tx hash: 0xc86a1c2408bcba2f5c323bb2cbdb0267488f5ef9ce5ca6794d0d2917b75c783e diff --git a/broadcast/003_DeploySingleOwnerMSCAFactory.s.sol/1301/run-1737572400.md b/broadcast/003_DeploySingleOwnerMSCAFactory.s.sol/1301/run-1737572400.md new file mode 100644 index 0000000..de8cffa --- /dev/null +++ b/broadcast/003_DeploySingleOwnerMSCAFactory.s.sol/1301/run-1737572400.md @@ -0,0 +1,3 @@ +- This chain used cast send to deploy so there's no corresponding run json +- Ran command in script/cmd/SingleOwnerMSCAFactory/0xf61023061ed45fa9eAC4D2670649cE1FD37ce536/SingleOwnerMSCAFactory +- tx hash: 0x450424cb9fc06040f9b1b7dd1d8b31058f77bdd090773066f757043d6375736c diff --git a/broadcast/003_DeploySingleOwnerMSCAFactory.s.sol/137/run-1737572400.md b/broadcast/003_DeploySingleOwnerMSCAFactory.s.sol/137/run-1737572400.md new file mode 100644 index 0000000..82c74cc --- /dev/null +++ b/broadcast/003_DeploySingleOwnerMSCAFactory.s.sol/137/run-1737572400.md @@ -0,0 +1,3 @@ +- This chain used cast send to deploy so there's no corresponding run json +- Ran command in script/cmd/SingleOwnerMSCAFactory/0xf61023061ed45fa9eAC4D2670649cE1FD37ce536/SingleOwnerMSCAFactory +- tx hash: 0x686ee24b2a91374e2e86ae29927d2935f1ff2abe7ad05d72b58a79d53f8dc095 diff --git a/broadcast/003_DeploySingleOwnerMSCAFactory.s.sol/42161/run-1737572400.md b/broadcast/003_DeploySingleOwnerMSCAFactory.s.sol/42161/run-1737572400.md new file mode 100644 index 0000000..7589376 --- /dev/null +++ b/broadcast/003_DeploySingleOwnerMSCAFactory.s.sol/42161/run-1737572400.md @@ -0,0 +1,3 @@ +- This chain used cast send to deploy so there's no corresponding run json +- Ran command in script/cmd/SingleOwnerMSCAFactory/0xf61023061ed45fa9eAC4D2670649cE1FD37ce536/SingleOwnerMSCAFactory +- tx hash: 0x7722d4a8e52034d81dc27e66518a0d2a3ab89b42dc622f553eec445d0a1b3957 diff --git a/broadcast/003_DeploySingleOwnerMSCAFactory.s.sol/421614/run-1737572400.md b/broadcast/003_DeploySingleOwnerMSCAFactory.s.sol/421614/run-1737572400.md new file mode 100644 index 0000000..d835445 --- /dev/null +++ b/broadcast/003_DeploySingleOwnerMSCAFactory.s.sol/421614/run-1737572400.md @@ -0,0 +1,3 @@ +- This chain used cast send to deploy so there's no corresponding run json +- Ran command in script/cmd/SingleOwnerMSCAFactory/0xf61023061ed45fa9eAC4D2670649cE1FD37ce536/SingleOwnerMSCAFactory +- tx hash: 0x65d1439ec8b7fc967c28f15c05b063167a90ded5f65207e24376e680b465aa4c diff --git a/broadcast/003_DeploySingleOwnerMSCAFactory.s.sol/80002/run-1737572400.md b/broadcast/003_DeploySingleOwnerMSCAFactory.s.sol/80002/run-1737572400.md new file mode 100644 index 0000000..f1139f7 --- /dev/null +++ b/broadcast/003_DeploySingleOwnerMSCAFactory.s.sol/80002/run-1737572400.md @@ -0,0 +1,3 @@ +- This chain used cast send to deploy so there's no corresponding run json +- Ran command in script/cmd/SingleOwnerMSCAFactory/0xf61023061ed45fa9eAC4D2670649cE1FD37ce536/SingleOwnerMSCAFactory +- tx hash: 0x0f42a1c9d4b73629def32ced0d96aa01ae7f0f48fdce372fe1da1125e9af5611 diff --git a/script/cmd/SingleOwnerMSCAFactory b/script/cmd/SingleOwnerMSCAFactory/0xa233b124D7b9CFF2D38cB62319e1A3f79144B490/SingleOwnerMSCAFactory similarity index 100% rename from script/cmd/SingleOwnerMSCAFactory rename to script/cmd/SingleOwnerMSCAFactory/0xa233b124D7b9CFF2D38cB62319e1A3f79144B490/SingleOwnerMSCAFactory diff --git a/script/cmd/SingleOwnerMSCAFactory/0xf61023061ed45fa9eAC4D2670649cE1FD37ce536/SingleOwnerMSCAFactory b/script/cmd/SingleOwnerMSCAFactory/0xf61023061ed45fa9eAC4D2670649cE1FD37ce536/SingleOwnerMSCAFactory new file mode 100644 index 0000000..3dbbe4a --- /dev/null +++ b/script/cmd/SingleOwnerMSCAFactory/0xf61023061ed45fa9eAC4D2670649cE1FD37ce536/SingleOwnerMSCAFactory @@ -0,0 +1 @@ +cast send --rpc-url $RPC_URL --private-key $DEPLOYER_PRIVATE_KEY 0x4e59b44847b379578588920cA78FbF26c0B4956C 0x000000000000000000000000000000000000000000000000000000000000000060c03461011f57615788906001600160401b03601f38849003908101601f191683019082821184831017610109578084916040968794855283398101031261011f57610056602061004f84610124565b9301610124565b6001600160a01b0392831660a0819052845190929091614cc89182840190811184821017610109578584928894610ac085398683521660208201520301906000f09182156100fe578260805283519216825260208201527fcb6d2c666b098c711fa0f2ce20b6863cc2b92e5378301100a4b2731b50516d5f823092a251610987908161013982396080518181816101270152818161033d01526104aa015260a0518160b80152f35b83513d6000823e3d90fd5b634e487b7160e01b600052604160045260246000fd5b600080fd5b51906001600160a01b038216820361011f5756fe608080604052600436101561001357600080fd5b600090813560e01c908163290ab98414610113575080634534137e146100e757806394430fa5146100a25763a7adc79f1461004d57600080fd5b3461009f5761008261005e366101ae565b80516001600160a01b039161007b9181016020908101910161023c565b16916103e2565b604080516001600160a01b03939093168352602083019190915290f35b80fd5b503461009f578060031936011261009f576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b503461009f5760206101016100fb366101ae565b916102b9565b6040516001600160a01b039091168152f35b9050346101565781600319360112610156577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b5080fd5b6060810190811067ffffffffffffffff82111761017657604052565b634e487b7160e01b600052604160045260246000fd5b90601f8019910116810190811067ffffffffffffffff82111761017657604052565b6060600319820112610237576004356001600160a01b038116810361023757916024359167ffffffffffffffff60443581811161023757826023820112156102375780600401359182116101765760405192610214601f8401601f19166020018561018c565b828452602483830101116102375781600092602460209301838601378301015290565b600080fd5b9081602091031261023757516001600160a01b03811681036102375790565b60005b83811061026e5750506000910152565b818101518382015260200161025e565b909160609260018060a01b03168252604060208301526102ad815180928160408601526020868601910161025b565b601f01601f1916010190565b82516001600160a01b03949385916102d99160209181018201910161023c565b16936102e68584846103e2565b9095863b6103d757604051906336cf06ff60e01b60208301526024820152602481526103118161015a565b604051906104168083019183831067ffffffffffffffff8411176101765783926103639261053c8539867f0000000000000000000000000000000000000000000000000000000000000000169061027e565b03906000f580156103cb5781169416918285036103b957604080516001600160a01b0393909316835260208301919091527ff66707ae2820569ece31cb5ac7cfcdd4d076c3f31ed9e28bf94394bedc0f329d91a2565b604051633a0ba96160e11b8152600490fd5b6040513d6000823e3d90fd5b505092939150501690565b9092916001600160a01b0391828216801561052957604091825196602091828901956bffffffffffffffffffffffff19809260601b16875260601b166034890152604888015260488752608087019680881067ffffffffffffffff89111761017657610504610510838a6055996104d0600b9a6104de9e8b52875190209d8e9960a061041699610474888c018861018c565b8a8752019861053c8a398b51906336cf06ff60e01b8783015260248201526024815261049f8161015a565b8b51928391878301957f0000000000000000000000000000000000000000000000000000000000000000168661027e565b03601f19810183528261018c565b89519586936104f5868601998a925192839161025b565b8401915180938684019061025b565b0103808452018261018c565b5190208351938401528201523081520160ff8153209190565b604051635297bbdb60e11b8152600490fdfe604060808152610416908138038061001681610218565b93843982019181818403126102135780516001600160a01b038116808203610213576020838101516001600160401b0394919391858211610213570186601f820112156102135780519061007161006c83610253565b610218565b918083528583019886828401011161021357888661008f930161026e565b813b156101b9577f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b031916841790556000927fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b8480a28051158015906101b2575b61010b575b855160d190816103458239f35b855194606086019081118682101761019e578697849283926101889952602788527f416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c87890152660819985a5b195960ca1b8a8901525190845af4913d15610194573d9061017a61006c83610253565b91825281943d92013e610291565b508038808080806100fe565b5060609250610291565b634e487b7160e01b84526041600452602484fd5b50826100f9565b855162461bcd60e51b815260048101859052602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608490fd5b600080fd5b6040519190601f01601f191682016001600160401b0381118382101761023d57604052565b634e487b7160e01b600052604160045260246000fd5b6001600160401b03811161023d57601f01601f191660200190565b60005b8381106102815750506000910152565b8181015183820152602001610271565b919290156102f357508151156102a5575090565b3b156102ae5790565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b8251909150156103065750805190602001fd5b6044604051809262461bcd60e51b825260206004830152610336815180928160248601526020868601910161026e565b601f01601f19168101030190fdfe608060405236156054577f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc54600090819081906001600160a01b0316368280378136915af43d82803e156050573d90f35b3d90fd5b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc54600090819081906001600160a01b0316368280378136915af43d82803e156050573d90f3fea26469706673582212203a03c53e62063406d2b425c2ed497305ba7a6718e884d256aeb3ce0f4965111264736f6c63430008180033a2646970667358221220f2c5f442a7458b74c258a8e2e512b4736349aaad6698856cae7e69a8f31d792064736f6c6343000818003360e0346200017757601f62004cc838819003918201601f19168301916001600160401b038311848410176200017c578084926040948552833981010312620001775780516001600160a01b039182821682036200017757602001519182168203620001775760805260a0527fc6a0cc20c824c4eecc4b0fbb7fb297d07492a7bd12c83d4fa4d27b4249f9bfd0805460ff8160081c16620001655760ff808216036200012f575b3060c052604051614b359081620001938239608051818181610f3d01528181611263015281816112a10152818161133601528181611f0e0152818161205f0152818161263b015281816127e701528181612a0701528181613030015261352f015260a0518181816105f60152611e92015260c05181818161087a015281816114c101526115e00152f35b60ff191660ff1790557f80bd505c666aa4feeb94643343d3e5acfd6d0b8c43c826331f5d543cbfa7e575600080a13880620000a5565b604051630a87f6e360e31b8152600490fd5b600080fd5b634e487b7160e01b600052604160045260246000fdfe60806040526004361015610026575b36156100245761001c6127d5565b602081519101f35b005b60003560e01c806223de291461025057806301ffc9a71461024b578063150b7a02146102465780631626ba7e1461024157806316feeab71461023c578063291220d21461023757806334fcd5be146102325780633659cfe61461022d57806336cf06ff1461022857806338997b11146102235780633a0cac561461021e5780633a871cdd1461021957806344ab613f146101ec5780634a58db19146102145780634d44560d1461020f5780634ee53c761461020a5780634f1ef2861461020557806352d1902d14610200578063642f9dd4146101fb57806366b46a7a146101f65780638d112184146101f157806394430fa5146101ec57806394ed11e7146101e7578063a3f4df7e146101e2578063a7be85c6146101dd578063b61d27f6146101d8578063bc197c81146101d3578063c1a221f3146101ce578063c399ec88146101c9578063ceaf1309146101c4578063d087d288146101bf578063f23a6e61146101ba578063f85730f4146101b5578063f95d04b0146101b05763ffa1ad740361000e576122b6565b612226565b61213b565b6120ca565b61202c565b611fc5565b611ee2565b611dc9565b611d3a565b611ce1565b611c83565b611c53565b611aad565b61124d565b6119b3565b611979565b61171d565b6115cd565b61147f565b6113c4565b61130d565b611292565b610ef3565b610d9c565b610b09565b6109a5565b610853565b610727565b610625565b6105e0565b610585565b6103bd565b610323565b6102a5565b6001600160a01b0381160361026657565b600080fd5b359061027682610255565b565b9181601f84011215610266578235916001600160401b038311610266576020838186019501011161026657565b346102665760c0366003190112610266576102c1600435610255565b6102cc602435610255565b6102d7604435610255565b6001600160401b03608435818111610266576102f7903690600401610278565b505060a43590811161026657610024903690600401610278565b6001600160e01b031981160361026657565b3461026657602036600319011261026657602060043561034281610311565b61034b816128b3565b9081156103a2575b8115610387575b811561036c575b506040519015158152f35b6001600160e01b031916630b135d3f60e11b14905038610361565b6001600160e01b03198116630271189760e51b14915061035a565b6001600160e01b03198116630a85bd0160e11b149150610353565b34610266576080366003190112610266576103d9600435610255565b6103e4602435610255565b6064356001600160401b03811161026657610403903690600401610278565b5050604051630a85bd0160e11b8152602090f35b634e487b7160e01b600052604160045260246000fd5b6001600160401b03811161044057604052565b610417565b606081019081106001600160401b0382111761044057604052565b604081019081106001600160401b0382111761044057604052565b602081019081106001600160401b0382111761044057604052565b61016081019081106001600160401b0382111761044057604052565b90601f801991011681019081106001600160401b0382111761044057604052565b6040519061027682610445565b6001600160401b03811161044057601f01601f191660200190565b919091610507816104e0565b61051460405191826104b2565b8093828252821161026657818160009384602080950137010152565b92919261053c826104e0565b9161054a60405193846104b2565b829481845281830111610266578281602093846000960137010152565b9080601f830112156102665781602061058293359101610530565b90565b34610266576040366003190112610266576024356001600160401b038111610266576105c26105ba6020923690600401610567565b600435612354565b6040516001600160e01b03199091168152f35b600091031261026657565b34610266576000366003190112610266576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b34610266576020366003190112610266576020610643600435612473565b604051908152f35b9181601f84011215610266578235916001600160401b038311610266576020808501948460051b01011161026657565b60005b83811061068e5750506000910152565b818101518382015260200161067e565b906020916106b78151809281855285808601910161067b565b601f01601f1916010190565b6020808201906020835283518092526040830192602060408460051b8301019501936000915b8483106106f95750505050505090565b9091929394958480610717600193603f198682030187528a5161069e565b98019301930191949392906106e9565b602080600319360112610266576004906004356001600160401b0381116102665761075690369060040161064b565b9290916107616129e4565b9261076b85612cae565b9460005b8181106107935761078f8761078388612ba7565b604051918291826106c3565b0390f35b6107ae6107a96107a4838587612cf8565b612d1a565b613c31565b61081857806107fc6107c66107a46001948688612cf8565b866107d2848789612cf8565b01356107f66107ef6107e586898b612cf8565b6040810190612d24565b3691610530565b91613bcb565b610806828a612b4d565b526108118189612b4d565b500161076f565b9061082793506107a492612cf8565b604051632738731760e21b81526001600160a01b039091169181019182529081906020010390fd5b0390fd5b346102665760203660031901126102665760043561087081610255565b6001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081166108a730821415612556565b6108c4600080516020614ae08339815191529183835416146125b7565b6108cc6129e4565b91604051906108da8261047b565b600082527f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff161561091c5750505061091761002492613e1b565b612ba7565b936020600495604051968780926352d1902d60e01b825285165afa60009581610974575b5061095e5760405162461bcd60e51b81528061084f60048201612db4565b61096f610917936100249614612d56565b613d0c565b61099791965060203d60201161099e575b61098f81836104b2565b8101906126fa565b9438610940565b503d610985565b34610266576020366003190112610266576004356109c281610255565b600080516020614aa0833981519152549060ff808360081c1615921680159081610ab1575b6001149081610aa7575b159081610a9e575b50610a8c57600080516020614aa0833981519152805460ff19166001179055610a269082610a6b57612618565b610a2c57005b600080516020614aa0833981519152805461ff00191690557f80bd505c666aa4feeb94643343d3e5acfd6d0b8c43c826331f5d543cbfa7e575600080a1005b600080516020614aa0833981519152805461ff001916610100179055612618565b60405163281f483d60e11b8152600490fd5b905015386109f9565b303b1591506109f1565b8391506109e7565b606060031982011261026657600435610ad181610255565b9160243591604435906001600160401b03821161026657610af491600401610278565b9091565b90602061058292818152019061069e565b610b1236610ab9565b91906001600160a01b03841630148015610d48575b610d365781151580610d2d575b80610ce3575b610ccb573360009081527fc6a0cc20c824c4eecc4b0fbb7fb297d07492a7bd12c83d4fa4d27b4249f9bfcd602090815260408083206001600160a01b03881684529091529020610b8a8483612e6f565b9081815460ff8116600014610c8c5760081c60ff16918215610c59575b50508015610c51575b15610c2757506338997b1160e01b600052600080516020614ac083398151915260205261078f93610c1b92610c15926107f690610c0d367f07eda5375f0c0049cbc1df9c13c9a2a93f42195e5d3aa188c59b49f74f3e5e5161391e565b963691610530565b91612ba7565b60405191829182610af8565b60405163415b1b4960e01b81523360048201526001600160e01b0319919091166024820152604490fd5b508315610bb0565b610c859250906001610c7e92019063ffffffff60e01b16600052602052604060002090565b5460ff1690565b8138610ba7565b50503360009081527fc6a0cc20c824c4eecc4b0fbb7fb297d07492a7bd12c83d4fa4d27b4249f9bfcb60205260409020610cc69150610c7e565b610bb0565b60405163171b202760e11b8152336004820152602490fd5b503360009081527fc6a0cc20c824c4eecc4b0fbb7fb297d07492a7bd12c83d4fa4d27b4249f9bfcb60205260409020610d2890610d24905460081c60ff1690565b1590565b610b3a565b50348211610b34565b6040516305d2fdc960e41b8152600490fd5b50610d5284613c31565b610b27565b602090602060408183019282815285518094520193019160005b828110610d7f575050505090565b83516001600160a01b031685529381019392810192600101610d71565b34610266576000366003190112610266577fc6a0cc20c824c4eecc4b0fbb7fb297d07492a7bd12c83d4fa4d27b4249f9bfca54610dd881612124565b90610de660405192836104b2565b808252601f19610df582612124565b0136602084013760008080527fc6a0cc20c824c4eecc4b0fbb7fb297d07492a7bd12c83d4fa4d27b4249f9bfc86020527fd594a02d3fda915a830c228e795b44eb4af5dfc9cc085b4c42f40bccd958a910546001600160a01b039081165b83831080610ee8575b15610eda57610ece610ec182610e88610ed494610e79888b612b4d565b6001600160a01b039091169052565b6001600160a01b031660009081527fc6a0cc20c824c4eecc4b0fbb7fb297d07492a7bd12c83d4fa4d27b4249f9bfc86020526040902090565b546001600160a01b031690565b92612eb1565b91610e53565b6040518061078f8782610d57565b508181161515610e5c565b3461026657600319606036820112610266576004908135916001600160401b03831161026657610160838201928436030112610266576001600160a01b03926044359290602435907f00000000000000000000000000000000000000000000000000000000000000008616330361123c576064810184610f738286612d24565b90501061122b57610f90610f8a610f969286612d24565b90612ec5565b90612e6f565b6001600160e01b031981161561122b5790610fb28493926122d2565b906001820191610fc1836126d2565b600080516020614aa08339815191525490929060101c6001600160a01b031691858b84161597886111ac575b610ff692613ef1565b95156111425750505161105694602093929160009061103a9061102f90611023906001600160a01b031681565b6001600160a01b031690565b935460a01c60ff1690565b60405163af87348360e01b8152978895869485938c8501612f25565b03925af1801561113d576110739260009161111e575b50906140e7565b60408101519093166001600160a01b03168015159081611112575b5061110357506110d161078f9260018060a01b0360408201511665ffffffffffff60a01b602083015160a01b16179065ffffffffffff60d01b905160d01b161790565b90806110e9575b506040519081529081906020820190565b600080808093338219f1506110fc61230f565b50386110d8565b6040516310b1cc1760e31b8152fd5b6001915014153861108e565b611137915060203d60201161099e5761098f81836104b2565b3861106c565b6126ad565b915091506111916107ef61107396610144611189611197977f19457468657265756d205369676e6564204d6573736167653a0a333200000000600052601c52603c60002090565b940190612d24565b91612912565b156111a4576000906140e7565b6001906140e7565b50506001600160581b03196111c085613eab565b16801590811561121d575b811561120f575b506111de578588610fed565b886111ed602086015160ff1690565b6040516314d291c760e21b815260ff9091169181019182529081906020010390fd5b600160591b149050386111d2565b600160581b811491506111cb565b60405163aedb4d1360e01b81528590fd5b604051635c427cd960e01b81528490fd5b34610266576000366003190112610266576040517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03168152602090f35b60008060031936011261130a577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031681813b1561130a5760405163b760faf960e01b8152306004820152918290602490829034905af1801561113d576112fe575080f35b6113079061042d565b80f35b80fd5b34610266576000604036600319011261130a5760043561132c81610255565b6001600160a01b037f00000000000000000000000000000000000000000000000000000000000000008116919033831415806113ba575b6113a8578391833b156113a45760449083604051958694859363040b850f60e31b855216600484015260243560248401525af1801561113d576112fe575080f35b8280fd5b604051635c427cd960e01b8152600490fd5b5030331415611363565b346102665760008060031936011261130a576113de613026565b6113e66129e4565b630b135d3f60e11b8252600080516020614ac083398151915260205260408220546001600160a01b03919082161561146d57600080516020614aa0833981519152805462010000600160b01b0319811690915561130792849160101c16307fc8894f26f396ce8c004245c8b7cd1b92103a6e4302fcbab883987149ac01b7ec8380a4612ba7565b60405163501ca72f60e11b8152600490fd5b60403660031901126102665760043561149781610255565b6024356001600160401b038111610266576114b6903690600401610567565b6001600160a01b03907f00000000000000000000000000000000000000000000000000000000000000008216906114ef30831415612556565b61150c600080516020614ae08339815191529284845416146125b7565b6115146129e4565b926115407f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1690565b156115545750505061091761002492613e1b565b936020600495604051968780926352d1902d60e01b825285165afa600095816115ac575b506115965760405162461bcd60e51b81528061084f60048201612db4565b6115a7610917936100249614612d56565b613dc8565b6115c691965060203d60201161099e5761098f81836104b2565b9438611578565b34610266576000366003190112610266577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316300361162757604051600080516020614ae08339815191528152602090f35b60405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608490fd5b602080820190602083528351809252602060408094019401926000905b8382106116be57505050505090565b9091929394836080600192611710838a516116ef84825160ff6020809260018060a01b038151168552015116910152565b015180516001600160a01b031683880190815260209182015160ff16910152565b01960194939201906116af565b34610266576020806003193601126102665761174360043561173e81610311565b6122d2565b600d810160108201546013830192601681015494611765601183015487613090565b9561177160009761309d565b9561177a61430a565b9088915b8383106118e8575b5050505061179261430a565b601260009301905b8484106117b3575b8787526040518061078f8982611692565b6117c4908692969897949598614357565b6000969196975b87518910156118a75761180c6118076117ed6117e78c8c612b4d565b51613eab565b85906001600160581b031916600052602052604060002090565b61339c565b80519094901561187a576000915b85518310156118665761185e6001916118338d8d612b4d565b5161183e828c612b4d565b515261184a8589612b4d565b5189611856838d612b4d565b510152612eb1565b92019161181a565b9a92945098600191505b01979290986117cb565b986001919a92945061188c818a612b4d565b516118a06118998d612eb1565b9c89612b4d565b5152611870565b965090979396509391936118ca6118bd82613eab565b6001600160581b03191690565b156118e05760019092019293919690949661179a565b8597506117a2565b6118fa90829998999796939597614357565b9390996000905b8b5182101561194557816001918a6119358f8e9c9b9a9998979661192491612b4d565b519261192f81612eb1565b9c612b4d565b5101520190919293949596611901565b98999593969a50509261195a6118bd82613eab565b1561196f57600190920191989593969861177e565b9895939698611786565b3461026657600036600319011261026657600080516020614aa08339815191525460405160109190911c6001600160a01b03168152602090f35b346102665760203660031901126102665761078f6004356119d381610311565b604051906119e082610445565b60008252611a376007611a2a60208501936119f96126b9565b85526040860194611a086126b9565b8652611a138261310a565b15611a8c573087525b611a306001611a2a846122d2565b016126d2565b90526122d2565b90526040519182918281516001600160a01b039081168252602080840151805183168285015281015160ff90811660408086019190915290940151805190921660608401520151909116608082015260a00190565b611aa8611a9b610ec1846122d2565b6001600160a01b03168852565b611a1c565b602036600319011261026657600480356001600160401b03811161026657611ad89036908301610278565b9190818310611c1157611aee610f908483612ec5565b6001600160e01b0319811615611c00573360009081527fc6a0cc20c824c4eecc4b0fbb7fb297d07492a7bd12c83d4fa4d27b4249f9bfcc602090815260408083206001600160e01b0319851684529091529020611b4e90610d2490610c7e565b611bd257611b5b816122d2565b80549093906001600160a01b031615611baa5761078f84610c1b610c1588611ba488611b9c611b8e8483600d8a01613ab3565b96546001600160a01b031690565b923691610530565b90613b94565b604051632d71321b60e11b81526001600160e01b031990921690820190815281906020010390fd5b6040805163415b1b4960e01b8152338186019081526001600160e01b03199093166020840152918291010390fd5b60405163aedb4d1360e01b81528390fd5b5060405163aedb4d1360e01b8152fd5b60405190611c2e82610460565b6016825275436972636c655f53696e676c654f776e65724d53434160501b6020830152565b346102665760003660031901126102665761078f611c6f611c21565b60405191829160208352602083019061069e565b346102665760003660031901126102665761078f604051611ca381610460565b601981527f436972636c6520496e7465726e65742046696e616e6369616c00000000000000602082015260405191829160208352602083019061069e565b611cea36610ab9565b9190611cf46129e4565b92611cfe85613c31565b611d195793611c6f926107f6610c159361078f973691610530565b604051632738731760e21b81526001600160a01b0386166004820152602490fd5b346102665760a036600319011261026657611d56600435610255565b611d61602435610255565b6001600160401b0360443581811161026657611d8190369060040161064b565b505060643581811161026657611d9b90369060040161064b565b505060843590811161026657611db5903690600401610278565b505060405163bc197c8160e01b8152602090f35b3461026657606036600319011261026657600435611de681610255565b6001600160401b039060243582811161026657611e07903690600401610567565b916044359081116102665761002492611eb7611e82611e2c6001943690600401610567565b94611e90611e386129e4565b9660405193849163b58bb5cb60e01b6020840152611e70898060a01b038096169889602486015260606044860152608485019061069e565b8381036023190160648501529061069e565b03601f1981018452836104b2565b7f000000000000000000000000000000000000000000000000000000000000000016613375565b507feb7551bad8fd10038dee62a958c2b6f45624499dc800ff8936bb0a4904bdd2fe600080a3612ba7565b34610266576000366003190112610266576040516370a0823160e01b81523060048201526020816024817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165afa801561113d57602091600091611f52575b50604051908152f35b611f699150823d841161099e5761098f81836104b2565b38611f49565b90815180825260208080930193019160005b828110611f8f575050505090565b9091929382604082611fb9600194895160ff6020809260018060a01b038151168552015116910152565b01950193929101611f81565b346102665760203660031901126102665761201e600435611fe581610311565b61078f61200a6008611ffe6120046002611ffe876122d2565b0161339c565b946122d2565b604051938493604085526040850190611f6f565b908382036020850152611f6f565b3461026657600036600319011261026657604051631aab3f0d60e11b8152306004820152600060248201526020816044817f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165afa801561113d5761078f916000916120ab57506040519081529081906020820190565b6120c4915060203d60201161099e5761098f81836104b2565b386110d8565b346102665760a0366003190112610266576120e6600435610255565b6120f1602435610255565b6084356001600160401b03811161026657612110903690600401610278565b505060405163f23a6e6160e01b8152602090f35b6001600160401b0381116104405760051b60200190565b346102665760803660031901126102665760043561215881610255565b6001600160401b0360443581811161026657612178903690600401610567565b60643591821161026657366023830112156102665781600401359261219c84612124565b926040946121ad60405195866104b2565b8085526020906024602087019160061b8401019236841161026657602401905b8382106121e257610024878760243588612709565b8782360312610266578751906121f782610460565b823561220281610255565b8252838301359060ff8216820361026657828592838c9501528152019101906121cd565b346102665760203660031901126102665760043561224381610255565b61224b613026565b6122536129e4565b6001600160a01b0382161561226e5761091761002492612e03565b6040516317c34cad60e01b81523060048201526001600160a01b0383166024820152604490fd5b604051906122a282610460565b60058252640312e302e360dc1b6020830152565b346102665760003660031901126102665761078f611c6f612295565b63ffffffff60e01b16600052600080516020614ac0833981519152602052604060002090565b60409061058293928152816020820152019061069e565b3d1561233a573d90612320826104e0565b9161232e60405193846104b2565b82523d6000602084013e565b606090565b90816020910312610266575161058281610311565b600080516020614aa0833981519152549091906001600160a01b039060101c8116806124445750630b135d3f60e11b600052600080516020614ac08339815191526020527fdd9229e5df2d5a19f89aca56c9c5f0120c005d627694c233e51b66fa569ffd50546001600160a01b031690811615612434576000926123f461240285946040519283916020830195630b135d3f60e11b8752602484016122f8565b03601f1981018352826104b2565b51915afa61240e61230f565b901561242757806020806105829351830101910161233f565b506001600160e01b031990565b506001600160e01b031992915050565b905061245261245893612473565b90612912565b612468576001600160e01b031990565b630b135d3f60e11b90565b61247b611c21565b602081519101209061248b612295565b602081519101206040519060208201937f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f8552604083015260608201524660808201523060a082015260a0815260c081018181106001600160401b03821117610440576105829381604052825190209261010060e08401937f8cef25043de9df9b2df1065df9275eeb89fb0ca4e5146e86fc2d13883a54676d855201526040815261253581610445565b519020906042916040519161190160f01b8352600283015260228201522090565b1561255d57565b60405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b19195b1959d85d1958d85b1b60a21b6064820152608490fd5b156125be57565b60405162461bcd60e51b815260206004820152602c60248201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060448201526b6163746976652070726f787960a01b6064820152608490fd5b6001600160a01b038181169182156126845761263390612e03565b6040519182527f000000000000000000000000000000000000000000000000000000000000000016907fb9a2e77405e16894f62a69f7bd6a34b8ca7647b6f5d5408d7c577d275691fde360203092a3565b6040516317c34cad60e01b81523060048201526001600160a01b03919091166024820152604490fd5b6040513d6000823e3d90fd5b604051906126c682610460565b60006020838281520152565b906040516126df81610460565b91546001600160a01b038116835260a01c60ff166020830152565b90816020910312610266575190565b9190610276937fbd807faaec7a357be5390445b7efef4a0ca92fa66300ee4827dde3d9387ffb51916127a661273c6129e4565b956040519063c877ea6360e01b6020830152611e908261279261278060018060a01b038095169a8b602485015288604485015260a0606485015260c484019061069e565b82810360231901608484015288611f6f565b3060a483015203601f1981018452836104b2565b506127b6604051928392836127be565b0390a2612ba7565b604090610582939281528160208201520190611f6f565b600436106128a1576001600160a01b037f000000000000000000000000000000000000000000000000000000000000000081163303612887575b6000356001600160e01b031916612825816122d2565b80549091906001600160a01b0316928316156128635750610c1561285061058292600d3691016139f5565b9261285b36366104fb565b903490613bcb565b604051632d71321b60e11b81526001600160e01b0319919091166004820152602490fd5b61289c6000356001600160e01b031916613523565b61280f565b60405163aedb4d1360e01b8152600490fd5b6001600160e01b031990811690811461290c576301ffc9a760e01b8114612906576000527fc6a0cc20c824c4eecc4b0fbb7fb297d07492a7bd12c83d4fa4d27b4249f9bfce602052604060002054151590565b50600190565b50600090565b61291c8383613bfd565b60058195929510156129ce571593846129b8575b50831561293e575b50505090565b600092935090829160405161296a816123f46020820194630b135d3f60e11b998a8752602484016122f8565b51915afa9061297761230f565b826129aa575b8261298d575b5050388080612938565b6129a2919250602080825183010191016126fa565b143880612983565b91506020825110159161297d565b6001600160a01b03838116911614935038612930565b634e487b7160e01b600052602160045260246000fd5b60009081356001600160e01b0319166129fc8161310a565b15612b1f57612a3a907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03163303612b16576122d2565b6013810190601681015493612a53601183015486613090565b92612a5f60009461389d565b91612a6861430a565b916000925b888410612a9f575b50505050612a99939450612a87613904565b9283526020830152600d369101614451565b90815290565b612aae90829895979698614357565b929098815b8a51811015612ae85780612ac96001928d612b4d565b516020612adf612ad88c612eb1565b9b8d612b4d565b51015201612ab3565b5093929098509694959396612aff6118bd82613eab565b15612b11576001909201929791612a6d565b612a75565b61173e81613523565b602490604051906350f2762560e11b82526004820152fd5b634e487b7160e01b600052603260045260246000fd5b8051821015612b615760209160051b010190565b612b37565b60409060ff6105829493168152816020820152019061069e565b60ff610582949360609360018060a01b03168352166020820152816040820152019061069e565b80516000905b808210612bb957505050565b90919260209081612bca8587612b4d565b5101518051909390612be690611023906001600160a01b031681565b92840195612bf5875160ff1690565b95612c008183612b4d565b515196853b15610266576040958651808093631128186d60e01b825260049b8c830191612c2c92612b66565b03815a6000948591f19081612c95575b50612c8257878761084f8888612c6c612c64612c5661230f565b93516001600160a01b031690565b955160ff1690565b9051638342a64960e01b81529485948501612b80565b9296509350935060019150019091612bad565b80612ca2612ca89261042d565b806105d5565b38612c3c565b90612cb882612124565b612cc560405191826104b2565b8281528092612cd6601f1991612124565b019060005b828110612ce757505050565b806060602080938501015201612cdb565b9190811015612b615760051b81013590605e1981360301821215610266570190565b3561058281610255565b903590601e198136030182121561026657018035906001600160401b0382116102665760200191813603831361026657565b15612d5d57565b60405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608490fd5b60809060208152602e60208201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960408201526d6f6e206973206e6f74205555505360901b60608201520190565b600080516020614aa0833981519152805462010000600160b01b03198116601084811b62010000600160b01b0316919091179092556001600160a01b0392831692911c16307fc8894f26f396ce8c004245c8b7cd1b92103a6e4302fcbab883987149ac01b7ec600080a4565b6001600160e01b03199035818116939260048110612e8c57505050565b60040360031b82901b16169150565b634e487b7160e01b600052601160045260246000fd5b6000198114612ec05760010190565b612e9b565b906004116102665790600490565b9035601e19823603018112156102665701602081359101916001600160401b03821161026657813603831361026657565b908060209392818452848401376000828201840152601f01601f1916010190565b939291612f8b6130219160ff60409416875260606020880152612f5b60608801612f4e8361026b565b6001600160a01b03169052565b60208101356080880152613011612f7485830183612ed3565b9390610160948560a08c01526101c08b0191612f04565b91613008612fb3612f9f6060840184612ed3565b605f198d8803810160c08f01529691612f04565b608083013560e08c0152612ff7610100968c8860a08701359101528c6101209160c0870135838301526101409960e08801358b840152870135910152840184612ed3565b8c830387016101808e015290612f04565b93810190612ed3565b91888403016101a0890152612f04565b930152565b60018060a01b03807f0000000000000000000000000000000000000000000000000000000000000000163314159081613071575b5080613067575b6113a857565b5030331415613061565b9050600080516020614aa08339815191525460101c163314153861305a565b91908201809211612ec057565b906130a782612124565b6040906130b760405191826104b2565b83815280936130c8601f1991612124565b019160005b8381106130da5750505050565b60209082516130e881610460565b6130f06126b9565b8152826130fb6126b9565b818301528286010152016130cd565b63ffffffff60e01b16635b0e93fb60e11b8114908115613364575b8115613353575b8115613342575b8115613331575b8115613320575b811561330f575b81156132fe575b81156132ed575b81156132dc575b81156132cb575b81156132ba575b81156132a9575b8115613298575b8115613287575b8115613276575b8115613265575b8115613254575b8115613243575b8115613232575b8115613221575b8115613210575b81156131ff575b81156131ee575b81156131dd575b81156131d0575090565b6223de2960e01b14919050565b630a85bd0160e11b811491506131c6565b63bc197c8160e01b811491506131bf565b63f23a6e6160e01b811491506131b8565b63335a353d60e11b811491506131b1565b6327729e3b60e11b811491506131aa565b630f95d04b60e41b811491506131a3565b6336cf06ff60e01b8114915061319c565b6370c321eb60e01b81149150613195565b631a10fa5160e31b8114915061318e565b6344ab613f60e01b81149150613187565b633a871cdd60e01b81149150613180565b631d06562b60e11b81149150613179565b63ceaf130960e01b81149150613172565b63190be77560e21b8114915061316b565b632344486160e21b81149150613164565b6338997b1160e01b8114915061315d565b6394ed11e760e01b81149150613156565b6301ffc9a760e01b8114915061314f565b6352d1902d60e01b81149150613148565b63278f794360e11b81149150613141565b631b2ce7f360e11b8114915061313a565b63c1a221f360e01b81149150613133565b633e15cc3d60e21b8114915061312c565b631a7e6adf60e11b81149150613125565b6000918291602082519201905af461338b61230f565b90156133945790565b602081519101fd5b6003810154906133ab82612124565b906133b960405192836104b2565b828252601f196133c884612124565b0160005b81811061346957505060008052806020526040600020549160589260581b946000955b85871080613456575b1561344c5761343d8161340d6134469361432d565b6134178a87612b4d565b526134228986612b4d565b5085906001600160581b031916600052602052604060002090565b54851b96612eb1565b956133ef565b5094509250505090565b506001600160581b0319811615156133f8565b6020906134746126b9565b828287010152016133cc565b92909160ff60a09593168452600180861b03166020840152604083015260806060830152806080830152806000848401376000828201840152601f01601f1916010190565b909260809260ff610582969516835260018060a01b03166020830152604082015281606082015201906000612f04565b909260809260ff610582979516835260018060a01b0316602083015260408201528160608201520191612f04565b6001600160a01b0390337f00000000000000000000000000000000000000000000000000000000000000008316146138995761355e906122d2565b9061356b600783016126d2565b600b830154909260080161357d61430a565b6135856126b9565b506000905b838210613708575b5050600080516020614aa08339815191525460101c6001600160a01b031691506135b99050565b16806136ed57506135cc6118bd82613eab565b801580156136e0575b6136ae57600160581b036135e65750565b80519091906135ff90611023906001600160a01b031681565b906020830191613610835160ff1690565b90803b156102665760405163bfd151c160e01b81529160009183918290849082906136449036903490339060048601613480565b03925af1908161369b575b50613696575061084f61367c61367461366661230f565b94516001600160a01b031690565b925160ff1690565b92604051938493636d4fdb0960e01b855260048501612b80565b915050565b80612ca26136a89261042d565b3861364f565b61084f6136bf602084015160ff1690565b6040516314d291c760e21b815260ff90911660048201529081906024820190565b50600160591b81146135d5565b9050331480156136ff575b156113a857565b503033146136f8565b6137189083979495969297614357565b9290966000965b885188101561386f576137386118bd6117e78a8c612b4d565b8015908115613861575b8115613853575b5061384157908795949392916137766110236110236137688a8e612b4d565b51516001600160a01b031690565b956137918b61378860209c8d92612b4d565b51015160ff1690565b98873b156102665760409788519063031fb36160e21b8252818060049d8e3690349033908501936137c194613480565b03815a6000948591f1908161382e575b5061381757508a8961084f8a8a6138018f6137886137ed61230f565b946137fb613768828b612b4d565b98612b4d565b90516340b788e360e01b81529485948501612b80565b60019098019950969750939450919290919061371f565b80612ca261383b9261042d565b386137d1565b61084f6136bf60206137888b8d612b4d565b600160591b14905038613749565b600160581b81149150613742565b9594975092909195506138846118bd82613eab565b156138945790916001019061358a565b613592565b5050565b906138a782612124565b6040906138b760405191826104b2565b83815280936138c8601f1991612124565b019160005b8381106138da5750505050565b60209082516138e881610460565b60608152826138f56126b9565b818301528286010152016138cd565b6040519061391182610460565b6060602083600081520152565b919091600681019260098201549161393a600482015484613090565b9261394660009461389d565b9061394f61430a565b906000915b818310613980575b50505061397a94955061396d613904565b9384526020840152614451565b91908252565b6139939089989598979692939497614357565b92909860005b8a518110156139c757806139af6001928d612b4d565b5160206139be612ad88c612eb1565b51015201613999565b5098509196939695929094956139df6118bd82613eab565b156139f05760019091019190613954565b61395c565b9190916006810192600982015491613a11600482015484613090565b92613a1d60009461389d565b90613a2661430a565b906000915b818310613a435750505061397a94955061396d613904565b613a569089989598979692939497614357565b92909860005b8a51811015613a8a5780613a726001928d612b4d565b516020613a81612ad88c612eb1565b51015201613a5c565b509850919693969592909495613aa26118bd82613eab565b156139f05760019091019190613a2b565b9092916006820193600983015492613acf600482015485613090565b93613adb60009561389d565b90613ae461430a565b906000915b818310613b0f575b50505061397a959650613b02613904565b94855260208501526145d2565b613b22908a99969294979395989a614357565b93909860005b8a51811015613b6757808b9c6020613b59613b488d9e9f95600196612b4d565b5192613b5381612eb1565b9d612b4d565b510152019a9998979a613b28565b5099979491959850919592613b7e6118bd82613eab565b15613b8f5760019091019190613ae9565b613af1565b600091829182602083519301915af13d6040519160208284010160405281835260208301916000833e15613bc6575090565b905190fd5b916000928392602083519301915af13d6040519160208284010160405281835260208301916000833e15613bc6575090565b906041815114600014613c2757610af4916020820151906060604084015193015160001a9061475b565b5050600090600290565b6040519060208083018160006301ffc9a760e01b9586845286602482015260248152613c5c81610445565b51617530938685fa933d6000519086613d01575b5085613cf7575b5084613c94575b50505081613c8a575090565b61058291506147d7565b83945090600091839460405185810192835263ffffffff60e01b602482015260248152613cc081610445565b5192fa60005190913d83613cec575b505081613ce2575b501590388080613c7e565b9050151538613cd7565b101591503880613ccf565b1515945038613c77565b841115955038613c70565b90613d1682613e1b565b6001600160a01b0382167fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b600080a2805115801590613dc0575b613d58575050565b613dbd9160008060405193613d6c85610445565b602785527f416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c6020860152660819985a5b195960ca1b6040860152602081519101845af4613db761230f565b91614a0e565b50565b506000613d50565b90613dd282613e1b565b6001600160a01b0382167fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b600080a2805115801590613e1357613d58575050565b506001613d50565b803b15613e5057600080516020614ae083398151915280546001600160a01b0319166001600160a01b03909216919091179055565b60405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608490fd5b6bffffffffffffffffffffffff19815160601b1690602060ff60581b91015160581b161790565b60405190613edf82610445565b60006040838281528260208201520152565b91613efa613ed2565b50613f036104d3565b90600090818352602090613f1e82850165ffffffffffff9052565b6040938360408201529560056002820191015490613f3a61430a565b90613f436126b9565b5085915b838310613f5b575b50505050505050505090565b613f6e90829b949a95969798999b614357565b99909488905b86518210156140bb57613f8d6118bd6117e7848a612b4d565b80159081156140ad575b811561409f575b5061406d5790613fee8b93928a8f8a8c918f613fd1856137888a613fcb611023611023613768848b612b4d565b96612b4d565b9951809781958294632238633960e21b845260049d8e8501612f25565b03925af190811561113d5761400a928d9261404e575b506140e7565b808c01519093906001600160a01b03168015159081614042575b5061403457506001019091613f74565b8b516310b1cc1760e31b8152fd5b60019150141538614024565b6140669192508c8d3d1061099e5761098f81836104b2565b9038614004565b61084f8b61407f8b613788868c612b4d565b905163520c50ef60e01b815260ff90911660048201529081906024820190565b600160591b14905038613f9e565b600160581b81149150613f97565b9a91949b999897969550506140d26118bd82613eab565b156140e257600190920191613f47565b613f4f565b6140f86140f2613ed2565b92614834565b90614109815165ffffffffffff1690565b90602081019061412d614122835165ffffffffffff1690565b65ffffffffffff1690565b65ffffffffffff809416116142f857835165ffffffffffff1690602085019184614160614122855165ffffffffffff1690565b9116116142f857604081810180519196916001600160a01b0316614186610d2482614886565b156142875750516141aa906001600160a01b03165b6001600160a01b031688880152565b6141ca6141bd835165ffffffffffff1690565b915165ffffffffffff1690565b90858216908616111561427757505165ffffffffffff1685525b6141f76141bd835165ffffffffffff1690565b90838216908416101561426457505165ffffffffffff1660208401525b825165ffffffffffff1690614235614122602086015165ffffffffffff1690565b9116101580614250575b614247575090565b60019082015290565b50808201516001600160a01b03161561423f565b65ffffffffffff16602085015250614214565b65ffffffffffff168652506141e4565b82880180519092506142a590610d24906001600160a01b0316614886565b156142c35750516142be906001600160a01b031661419b565b6141aa565b6001600160a01b0381166142e55750516142be906001600160a01b031661419b565b6001600160a01b031688880152506141aa565b60405163a45d8f5360e01b8152600490fd5b6143126126b9565b5060405161431f81610460565b600081526000602082015290565b6143356126b9565b5060ff6040519161434583610460565b8060601c835260581c16602082015290565b919061436b906143656126b9565b50613eab565b6040519261437884610496565b600a92600a855260005b610140811061443a57506001600160581b031980841615614421575b6000935b85851080614416575b15614406576143fa6143f3826143c36144009461432d565b6143cd898c612b4d565b526143d8888b612b4d565b5086906001600160581b031916600052602052604060002090565b5460581b90565b94612eb1565b936143a2565b925050925061058291845261432d565b5081811615156143ab565b9250600080528160205260406000205460581b9261439e565b6020906144456126b9565b82828901015201614382565b92919261445c61430a565b916003820154926000905b84821061447e575b50505050506020825192015190565b61448b9084979597614357565b909660005b88518110156145ad576144a66117e7828b612b4d565b6001600160581b03198116801590811561459f575b8115614591575b5061457f576144ff6118076144e1886144db868f612b4d565b51614902565b9260058a01906001600160581b031916600052602052604060002090565b8051614510575b5050600101614490565b95919893999490969260005b875181101561456b5780896145578c6145376001958d612b4d565b51602061454b818401938451905190612b4d565b510152518d5190612b4d565b51526145638b51612eb1565b8b520161451c565b509296509398929760019195509038614506565b61084f6136bf6020613788858e612b4d565b600160591b149050386144c2565b600160581b811491506144bb565b509496506145bd6118bd82613eab565b156145cd57600190910190614467565b61446f565b909392936145de61430a565b926003830154936000905b858210614601575b5050505050506020825192015190565b61460e9085989698614357565b909760005b8951811015614736576146296117e7828c612b4d565b6001600160581b031981168015908115614728575b811561471a575b5061470857614684611807614666888a8f8761466091612b4d565b516149bc565b9260058b01906001600160581b031916600052602052604060002090565b8051614695575b5050600101614613565b969260009b96929a959198949b5b88518110156146f357808a6146df8d6146be6001958e612b4d565b51602090818301916146d38351855190612b4d565b51015251905190612b4d565b51526146eb8c51612eb1565b8c52016146a3565b509296509398600191959a939750903861468b565b61084f6136bf6020613788858f612b4d565b600160591b14905038614645565b600160581b8114915061463e565b509597506147466118bd82613eab565b15614756576001909101906145e9565b6145f1565b9291907f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083116147cb5791608094939160ff602094604051948552168484015260408301526060820152600093849182805260015afa1561113d5781516001600160a01b03811615612906579190565b50505050600090600390565b6000602091604051838101906301ffc9a760e01b825263f23b1ed760e01b60248201526024815261480781610445565b5191617530fa6000513d82614828575b5081614821575090565b9050151590565b60201115915038614817565b61483c613ed2565b5065ffffffffffff90818160a01c1691821561487e575b6040519261486084610445565b60d083901c84521660208301526001600160a01b0316604082015290565b915081614853565b6001600160a01b0316801590811561489c575090565b600191501490565b602081830312610266578051906001600160401b038211610266570181601f820112156102665780516148d6816104e0565b926148e460405194856104b2565b8184526020828401011161026657610582916020808501910161067b565b805190929061495290600090614920906001600160a01b0316611023565b936020860194614931865160ff1690565b8360405180968195829463236b075960e11b845234903390600486016134c5565b03925af160009181614997575b5061499157505061084f61497761367461366661230f565b92604051938493636d1fbba160e11b855260048501612b80565b92509050565b6149b59192503d806000833e6149ad81836104b2565b8101906148a4565b903861495f565b80519093919261495291600091906149dc906001600160a01b0316611023565b6020870195836149ed885160ff1690565b60405163236b075960e11b81529687958694859334903390600487016134f5565b91929015614a705750815115614a22575090565b3b15614a2b5790565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b825190915015614a835750805190602001fd5b60405162461bcd60e51b815290819061084f9060048301610af856fec6a0cc20c824c4eecc4b0fbb7fb297d07492a7bd12c83d4fa4d27b4249f9bfd0c6a0cc20c824c4eecc4b0fbb7fb297d07492a7bd12c83d4fa4d27b4249f9bfcf360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbca2646970667358221220b3394957b45d33fd9c2bb3db0d7f214a5d03b90725f0afc54d5ab25ba0b4d3dd64736f6c634300081800330000000000000000000000005ff137d4b0fdcd49dca30c7cf57e578a026d2789000000000000000000000000c93d6559fe4db59742751a857d11a04861a50ccc diff --git a/script/verify/SingleOwnerMSCA/0xd206ac7fef53d83ed4563e770b28dba90d0d9ec8/SingleOwnerMSCAFactory.json b/script/verify/SingleOwnerMSCA/0xd206ac7fef53d83ed4563e770b28dba90d0d9ec8/SingleOwnerMSCAFactory.json new file mode 100644 index 0000000..4040ac6 --- /dev/null +++ b/script/verify/SingleOwnerMSCA/0xd206ac7fef53d83ed4563e770b28dba90d0d9ec8/SingleOwnerMSCAFactory.json @@ -0,0 +1 @@ +{"language":"Solidity","sources":{"src/msca/6900/v0.7/factories/semi/SingleOwnerMSCAFactory.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\nimport {Create2FailedDeployment, InvalidInitializationInput} from \"../../../shared/common/Errors.sol\";\nimport {SingleOwnerMSCA} from \"../../account/semi/SingleOwnerMSCA.sol\";\nimport {PluginManager} from \"../../managers/PluginManager.sol\";\nimport {IEntryPoint} from \"@account-abstraction/contracts/interfaces/IEntryPoint.sol\";\nimport {ERC1967Proxy} from \"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\";\nimport {Create2} from \"@openzeppelin/contracts/utils/Create2.sol\";\n\n/**\n * @dev Account factory that creates the semi-MSCA that enshrines single owner into the account storage.\n * No plugin installation is required during account creation.\n */\ncontract SingleOwnerMSCAFactory {\n // logic implementation\n SingleOwnerMSCA public immutable ACCOUNT_IMPLEMENTATION;\n IEntryPoint public immutable ENTRY_POINT;\n\n event FactoryDeployed(address indexed factory, address accountImplementation, address entryPoint);\n event AccountCreated(address indexed proxy, address sender, bytes32 salt);\n\n /**\n * @dev Salted deterministic deployment using create2 and a specific logic SingleOwnerMSCA implementation.\n * Tx/userOp is either gated by userOpValidationFunction or runtimeValidationFunction, and SingleOwnerMSCA\n * is a minimum account with a pre built-in owner validation, so we do not require the user to install any\n * plugins\n * during the deployment. No hooks can be injected during the account deployment, so for a future installation\n * of more complicated plugins, please call installPlugin via a separate tx/userOp after account deployment.\n */\n constructor(address _entryPointAddr, address _pluginManagerAddr) {\n ENTRY_POINT = IEntryPoint(_entryPointAddr);\n PluginManager _pluginManager = PluginManager(_pluginManagerAddr);\n ACCOUNT_IMPLEMENTATION = new SingleOwnerMSCA(ENTRY_POINT, _pluginManager);\n emit FactoryDeployed(address(this), address(ACCOUNT_IMPLEMENTATION), _entryPointAddr);\n }\n\n /**\n * @dev Salted deterministic deployment using create2 and a specific logic SingleOwnerMSCA implementation.\n * Tx/userOp is either gated by userOpValidationFunction or runtimeValidationFunction, and SingleOwnerMSCA\n * is a minimum account with a pre built-in owner validation, so we do not require the user to install any\n * plugins\n * during the deployment. No hooks can be injected during the account deployment, so for a future installation\n * of more complicated plugins, please call installPlugin via a separate tx/userOp after account deployment.\n * @param _sender sender of the account deployment tx, it could be set to owner. If you don't have the owner\n * information during account creation,\n * please use something unique, consistent and private to yourself. In the context of single owner\n * semi-MSCA, this field is mostly\n * for consistency because we also use owner to mix the salt.\n * @param _salt salt that allows for deterministic deployment\n * @param _initializingData abi.encode(address), address should not be zero\n */\n function createAccount(address _sender, bytes32 _salt, bytes memory _initializingData)\n public\n returns (SingleOwnerMSCA account)\n {\n address owner = abi.decode(_initializingData, (address));\n (address counterfactualAddr, bytes32 mixedSalt) = _getAddress(_sender, _salt, owner);\n if (counterfactualAddr.code.length > 0) {\n return SingleOwnerMSCA(payable(counterfactualAddr));\n }\n // only perform implementation upgrade by setting empty _data in ERC1967Proxy\n // meanwhile we also initialize proxy storage, which calls PluginManager._installPlugin directly to bypass\n // validateNativeFunction checks\n account = SingleOwnerMSCA(\n payable(\n new ERC1967Proxy{salt: mixedSalt}(\n address(ACCOUNT_IMPLEMENTATION), abi.encodeCall(SingleOwnerMSCA.initializeSingleOwnerMSCA, (owner))\n )\n )\n );\n if (address(account) != counterfactualAddr) {\n revert Create2FailedDeployment();\n }\n emit AccountCreated(counterfactualAddr, _sender, _salt);\n }\n\n /**\n * @dev Pre-compute the counterfactual address prior to calling createAccount.\n * After decoding, owner is used in salt, byteCodeHash and func init call to minimize the front-running risk.\n * @param _sender sender of the account deployment tx, it could be set to owner. If you don't have the owner\n * information during account creation,\n * please use something unique, consistent and private to yourself. In the context of single owner\n * semi-MSCA, this field is mostly\n * for consistency because we also use owner to mix the salt.\n * @param _salt salt that allows for deterministic deployment\n * @param _initializingData abi.encode(address), address should not be zero\n */\n function getAddress(address _sender, bytes32 _salt, bytes memory _initializingData)\n public\n view\n returns (address addr, bytes32 mixedSalt)\n {\n address owner = abi.decode(_initializingData, (address));\n return _getAddress(_sender, _salt, owner);\n }\n\n /**\n * @dev Pre-compute the counterfactual address prior to calling createAccount.\n * After decoding, owner is used in salt, byteCodeHash and func init call to minimize the front-running risk.\n * @param _sender sender of the account deployment tx, it could be set to owner. If you don't have the owner\n * information during account creation,\n * please use something unique, consistent and private to yourself. In the context of single owner\n * semi-MSCA, this field is mostly\n * for consistency because we also use owner to mix the salt.\n * @param _salt salt that allows for deterministic deployment\n * @param _owner owner of the semi MSCA\n */\n function _getAddress(address _sender, bytes32 _salt, address _owner)\n internal\n view\n returns (address addr, bytes32 mixedSalt)\n {\n if (_owner == address(0)) {\n revert InvalidInitializationInput();\n }\n mixedSalt = keccak256(abi.encodePacked(_sender, _owner, _salt));\n bytes32 code = keccak256(\n abi.encodePacked(\n type(ERC1967Proxy).creationCode,\n abi.encode(\n address(ACCOUNT_IMPLEMENTATION), abi.encodeCall(SingleOwnerMSCA.initializeSingleOwnerMSCA, (_owner))\n )\n )\n );\n addr = Create2.computeAddress(mixedSalt, code, address(this));\n return (addr, mixedSalt);\n }\n}\n"},"src/msca/6900/shared/common/Errors.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\n/**\n * @notice Throws when the selector is not found.\n */\nerror NotFoundSelector();\n\n/**\n * @notice Throws when authorizer is invalid.\n */\nerror InvalidAuthorizer();\n\nerror InvalidValidationFunctionId(uint8 functionId);\n\nerror InvalidFunctionReference();\n\nerror ItemAlreadyExists();\n\nerror ItemDoesNotExist();\n\nerror InvalidLimit();\n\nerror InvalidExecutionFunction(bytes4 selector);\n\nerror InvalidInitializationInput();\n\nerror Create2FailedDeployment();\n\nerror NotImplemented(bytes4 selector, uint8 functionId);\n\nerror InvalidItem();\n\n// v2 NotImplemented\nerror NotImplementedFunction(bytes4 selector, uint32 entityId);\n"},"src/msca/6900/v0.7/account/semi/SingleOwnerMSCA.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\nimport {DefaultCallbackHandler} from \"../../../../../callback/DefaultCallbackHandler.sol\";\n\nimport {\n EIP1271_INVALID_SIGNATURE,\n EIP1271_VALID_SIGNATURE,\n EMPTY_FUNCTION_REFERENCE,\n EMPTY_FUNCTION_REFERENCE,\n SENTINEL_BYTES21,\n SIG_VALIDATION_FAILED,\n SIG_VALIDATION_SUCCEEDED,\n WALLET_VERSION_1\n} from \"../../../../../common/Constants.sol\";\n\nimport {UnauthorizedCaller} from \"../../../../../common/Errors.sol\";\nimport {ExecutionUtils} from \"../../../../../utils/ExecutionUtils.sol\";\nimport {InvalidAuthorizer, InvalidValidationFunctionId, NotFoundSelector} from \"../../../shared/common/Errors.sol\";\nimport {ValidationData} from \"../../../shared/common/Structs.sol\";\nimport {ValidationDataLib} from \"../../../shared/libs/ValidationDataLib.sol\";\nimport {\n PRE_HOOK_ALWAYS_DENY_FUNCTION_REFERENCE,\n RUNTIME_VALIDATION_ALWAYS_ALLOW_FUNCTION_REFERENCE\n} from \"../../common/Constants.sol\";\nimport {ExecutionDetail, FunctionReference, RepeatableBytes21DLL} from \"../../common/Structs.sol\";\nimport {IPlugin} from \"../../interfaces/IPlugin.sol\";\nimport {FunctionReferenceLib} from \"../../libs/FunctionReferenceLib.sol\";\nimport {RepeatableFunctionReferenceDLLLib} from \"../../libs/RepeatableFunctionReferenceDLLLib.sol\";\nimport {WalletStorageV1Lib} from \"../../libs/WalletStorageV1Lib.sol\";\nimport {PluginManager} from \"../../managers/PluginManager.sol\";\nimport {BaseMSCA} from \"../BaseMSCA.sol\";\nimport {IEntryPoint} from \"@account-abstraction/contracts/interfaces/IEntryPoint.sol\";\nimport {UserOperation} from \"@account-abstraction/contracts/interfaces/UserOperation.sol\";\nimport {UUPSUpgradeable} from \"@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol\";\nimport {IERC1271} from \"@openzeppelin/contracts/interfaces/IERC1271.sol\";\n\nimport {IERC1155Receiver} from \"@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol\";\nimport {IERC721Receiver} from \"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\";\nimport {ECDSA} from \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\n\nimport {BaseERC712CompliantAccount} from \"../../../../../erc712/BaseERC712CompliantAccount.sol\";\nimport {SignatureChecker} from \"@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol\";\n\n/**\n * @dev Semi-MSCA that enshrines single owner into the account storage.\n */\ncontract SingleOwnerMSCA is BaseMSCA, DefaultCallbackHandler, UUPSUpgradeable, IERC1271, BaseERC712CompliantAccount {\n using ExecutionUtils for address;\n using ECDSA for bytes32;\n using RepeatableFunctionReferenceDLLLib for RepeatableBytes21DLL;\n using FunctionReferenceLib for bytes21;\n using FunctionReferenceLib for FunctionReference;\n using ValidationDataLib for ValidationData;\n\n enum FunctionId {\n NATIVE_RUNTIME_VALIDATION_OWNER_OR_SELF,\n NATIVE_USER_OP_VALIDATION_OWNER\n }\n\n string public constant NAME = \"Circle_SingleOwnerMSCA\";\n bytes32 private constant _HASHED_NAME = keccak256(bytes(NAME));\n bytes32 private constant _HASHED_VERSION = keccak256(bytes(WALLET_VERSION_1));\n bytes32 private constant _MESSAGE_TYPEHASH = keccak256(\"CircleSingleOwnerMSCAMessage(bytes32 hash)\");\n\n event SingleOwnerMSCAInitialized(address indexed account, address indexed entryPointAddress, address owner);\n event OwnershipTransferred(address indexed account, address indexed previousOwner, address indexed newOwner);\n\n error InvalidOwnerForMSCA(address account, address owner);\n error NoOwnershipPluginDefined();\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyFromEntryPointOrOwnerOrSelf() {\n _checkFromEPOrOwnerOrSelf();\n _;\n }\n\n constructor(IEntryPoint _newEntryPoint, PluginManager _newPluginManager)\n BaseMSCA(_newEntryPoint, _newPluginManager)\n {}\n\n /// @notice Initializes the account with a set of plugins\n /// @dev No dependencies or hooks can be injected with this installation. For a full installation, please use\n /// installPlugin.\n /// @param owner The initial owner\n function initializeSingleOwnerMSCA(address owner) external walletStorageInitializer {\n if (owner == address(0)) {\n revert InvalidOwnerForMSCA(address(this), owner);\n }\n _transferNativeOwnership(owner);\n emit SingleOwnerMSCAInitialized(address(this), address(ENTRY_POINT), owner);\n }\n\n /// @inheritdoc IERC1271\n function isValidSignature(bytes32 hash, bytes memory signature) external view override returns (bytes4) {\n address owner = WalletStorageV1Lib.getLayout().owner;\n if (owner == address(0)) {\n ExecutionDetail storage executionDetail =\n WalletStorageV1Lib.getLayout().executionDetails[IERC1271.isValidSignature.selector];\n // this is a sanity check only, as using address(0) as a plugin is not permitted during installation\n if (executionDetail.plugin == address(0)) {\n return EIP1271_INVALID_SIGNATURE;\n }\n // isValidSignature is installed via plugin, so it should fallback to the plugin\n (bool success, bytes memory returnData) =\n executionDetail.plugin.staticcall(abi.encodeCall(IERC1271.isValidSignature, (hash, signature)));\n if (!success) {\n return EIP1271_INVALID_SIGNATURE;\n }\n return abi.decode(returnData, (bytes4));\n } else {\n // use address(this) to prevent replay attacks\n bytes32 replaySafeHash = getReplaySafeMessageHash(hash);\n if (SignatureChecker.isValidSignatureNow(owner, replaySafeHash, signature)) {\n return EIP1271_VALID_SIGNATURE;\n }\n return EIP1271_INVALID_SIGNATURE;\n }\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current msg.sender.\n */\n function transferNativeOwnership(address newOwner) public onlyFromEntryPointOrOwnerOrSelf validateNativeFunction {\n if (newOwner == address(0)) {\n revert InvalidOwnerForMSCA(address(this), newOwner);\n }\n _transferNativeOwnership(newOwner);\n }\n\n /**\n * @dev Leaves the contract without owner. Can only be initiated by the current owner.\n *\n * NOTE: Irreversible. Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner. Please\n * make sure you've already have other backup validations before calling this method.\n * If the user wants to switch to the validations provided by plugins, please call this\n * function after you install the plugin, so owner will be disabled.\n */\n function renounceNativeOwnership() public onlyFromEntryPointOrOwnerOrSelf validateNativeFunction {\n // we need a ownership plugin in place before renouncing native ownership\n if (WalletStorageV1Lib.getLayout().executionDetails[IERC1271.isValidSignature.selector].plugin == address(0)) {\n revert NoOwnershipPluginDefined();\n }\n _transferNativeOwnership(address(0));\n }\n\n /**\n * @dev Returns the current owner.\n */\n function getNativeOwner() public view returns (address) {\n return WalletStorageV1Lib.getLayout().owner;\n }\n\n function supportsInterface(bytes4 interfaceId)\n public\n view\n override(BaseMSCA, DefaultCallbackHandler)\n returns (bool)\n {\n // BaseMSCA has already implemented ERC165\n return BaseMSCA.supportsInterface(interfaceId) || interfaceId == type(IERC721Receiver).interfaceId\n || interfaceId == type(IERC1155Receiver).interfaceId || interfaceId == type(IERC1271).interfaceId;\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferNativeOwnership(address newOwner) internal {\n address oldOwner = WalletStorageV1Lib.getLayout().owner;\n WalletStorageV1Lib.getLayout().owner = newOwner;\n emit OwnershipTransferred(address(this), oldOwner, newOwner);\n }\n\n /**\n * @dev We run the native validation function if it's enabled, otherwise we fallback to the plugin validation\n * functions.\n * In either case, we run the hooks from plugins if there's any.\n */\n function _authenticateAndAuthorizeUserOp(UserOperation calldata userOp, bytes32 userOpHash)\n internal\n override\n returns (uint256 validationData)\n {\n // onlyFromEntryPoint is applied in the caller\n // if there is no function defined for the selector, or if userOp.callData.length < 4, then execution MUST\n // revert\n if (userOp.callData.length < 4) {\n revert NotFoundSelector();\n }\n bytes4 selector = bytes4(userOp.callData[0:4]);\n if (selector == bytes4(0)) {\n revert NotFoundSelector();\n }\n ExecutionDetail storage executionDetail = WalletStorageV1Lib.getLayout().executionDetails[selector];\n // check validation function for non native case first\n FunctionReference memory validationFunction = executionDetail.userOpValidationFunction;\n address owner = WalletStorageV1Lib.getLayout().owner;\n if (owner == address(0)) {\n bytes21 packedValidationFunction = validationFunction.pack();\n if (\n packedValidationFunction == EMPTY_FUNCTION_REFERENCE\n || packedValidationFunction == RUNTIME_VALIDATION_ALWAYS_ALLOW_FUNCTION_REFERENCE\n || packedValidationFunction == PRE_HOOK_ALWAYS_DENY_FUNCTION_REFERENCE\n ) {\n revert InvalidValidationFunctionId(validationFunction.functionId);\n }\n }\n // pre hook\n ValidationData memory unpackedValidationData =\n _processPreUserOpValidationHooks(executionDetail, userOp, userOpHash);\n uint256 currentValidationData;\n // userOp validation\n // no native validation function\n if (owner == address(0)) {\n IPlugin userOpValidatorPlugin = IPlugin(validationFunction.plugin);\n // execute the validation function with the user operation and its hash as parameters using the call opcode\n currentValidationData = userOpValidatorPlugin.userOpValidationFunction(\n executionDetail.userOpValidationFunction.functionId, userOp, userOpHash\n );\n } else {\n if (SignatureChecker.isValidSignatureNow(owner, userOpHash.toEthSignedMessageHash(), userOp.signature)) {\n currentValidationData = SIG_VALIDATION_SUCCEEDED;\n } else {\n currentValidationData = SIG_VALIDATION_FAILED;\n }\n }\n\n // intercept with last result\n unpackedValidationData = unpackedValidationData._intersectValidationData(currentValidationData);\n if (unpackedValidationData.authorizer != address(0) && unpackedValidationData.authorizer != address(1)) {\n // only revert on unexpected values\n revert InvalidAuthorizer();\n }\n validationData = unpackedValidationData._packValidationData();\n }\n\n function _processPreRuntimeHooksAndValidation(bytes4 selector) internal override {\n if (msg.sender == address(ENTRY_POINT)) {\n // ENTRY_POINT should go through validateUserOp flow which calls userOpValidationFunction\n return;\n }\n ExecutionDetail storage executionDetail = WalletStorageV1Lib.getLayout().executionDetails[selector];\n FunctionReference memory validationFunction = executionDetail.runtimeValidationFunction;\n RepeatableBytes21DLL storage preRuntimeValidationHooksDLL = executionDetail.preRuntimeValidationHooks;\n uint256 totalUniqueHookCount = preRuntimeValidationHooksDLL.getUniqueItems();\n FunctionReference memory startHook = EMPTY_FUNCTION_REFERENCE.unpack();\n FunctionReference[] memory preRuntimeValidationHooks;\n FunctionReference memory nextHook;\n for (uint256 i = 0; i < totalUniqueHookCount; ++i) {\n (preRuntimeValidationHooks, nextHook) = preRuntimeValidationHooksDLL.getPaginated(startHook, 10);\n for (uint256 j = 0; j < preRuntimeValidationHooks.length; ++j) {\n // revert on EMPTY_FUNCTION_REFERENCE, RUNTIME_VALIDATION_ALWAYS_ALLOW_FUNCTION_REFERENCE,\n // PRE_HOOK_ALWAYS_DENY_FUNCTION_REFERENCE\n // if any revert, the outer call MUST revert\n bytes21 packedPreRuntimeValidationHook = preRuntimeValidationHooks[j].pack();\n if (\n packedPreRuntimeValidationHook == EMPTY_FUNCTION_REFERENCE\n || packedPreRuntimeValidationHook == RUNTIME_VALIDATION_ALWAYS_ALLOW_FUNCTION_REFERENCE\n || packedPreRuntimeValidationHook == PRE_HOOK_ALWAYS_DENY_FUNCTION_REFERENCE\n ) {\n revert InvalidValidationFunctionId(preRuntimeValidationHooks[j].functionId);\n }\n IPlugin preRuntimeValidationHookPlugin = IPlugin(preRuntimeValidationHooks[j].plugin);\n // solhint-disable no-empty-blocks\n try preRuntimeValidationHookPlugin.preRuntimeValidationHook(\n preRuntimeValidationHooks[j].functionId, msg.sender, msg.value, msg.data\n ) {} catch (bytes memory revertReason) {\n revert PreRuntimeValidationHookFailed(\n preRuntimeValidationHooks[j].plugin, preRuntimeValidationHooks[j].functionId, revertReason\n );\n }\n // solhint-enable no-empty-blocks\n }\n if (nextHook.pack() == SENTINEL_BYTES21) {\n break;\n }\n startHook = nextHook;\n }\n address owner = WalletStorageV1Lib.getLayout().owner;\n // no native validation function\n if (owner == address(0)) {\n bytes21 packedValidationFunction = validationFunction.pack();\n if (\n packedValidationFunction == EMPTY_FUNCTION_REFERENCE\n || packedValidationFunction == PRE_HOOK_ALWAYS_DENY_FUNCTION_REFERENCE\n ) {\n revert InvalidValidationFunctionId(validationFunction.functionId);\n }\n // call runtimeValidationFunction if it's not always allowed\n if (packedValidationFunction != RUNTIME_VALIDATION_ALWAYS_ALLOW_FUNCTION_REFERENCE) {\n // solhint-disable no-empty-blocks\n try IPlugin(validationFunction.plugin).runtimeValidationFunction(\n validationFunction.functionId, msg.sender, msg.value, msg.data\n ) {} catch (bytes memory revertReason) {\n revert RuntimeValidationFailed(\n validationFunction.plugin, validationFunction.functionId, revertReason\n );\n }\n // solhint-enable no-empty-blocks\n }\n return;\n } else {\n // the msg.sender should be the owner of the account or itself\n if (msg.sender == owner || msg.sender == address(this)) {\n return;\n } else {\n revert UnauthorizedCaller();\n }\n }\n }\n\n /// @inheritdoc UUPSUpgradeable\n function upgradeTo(address newImplementation) public override onlyProxy validateNativeFunction {\n _authorizeUpgrade(newImplementation);\n _upgradeToAndCallUUPS(newImplementation, new bytes(0), false);\n }\n\n /// @inheritdoc UUPSUpgradeable\n function upgradeToAndCall(address newImplementation, bytes memory data)\n public\n payable\n override\n onlyProxy\n validateNativeFunction\n {\n _authorizeUpgrade(newImplementation);\n _upgradeToAndCallUUPS(newImplementation, data, true);\n }\n\n /**\n * @dev The function is overridden here so more granular ACLs to the upgrade mechanism should be enforced by\n * plugins.\n */\n // solhint-disable-next-line no-empty-blocks\n function _authorizeUpgrade(address newImplementation) internal override {}\n\n function _processPreUserOpValidationHooks(\n ExecutionDetail storage executionDetail,\n UserOperation calldata userOp,\n bytes32 userOpHash\n ) internal override returns (ValidationData memory unpackedValidationData) {\n unpackedValidationData = ValidationData(0, 0xFFFFFFFFFFFF, address(0));\n // if the function selector has associated pre user operation validation hooks, then those hooks MUST be run\n // sequentially\n uint256 totalUniqueHookCount = executionDetail.preUserOpValidationHooks.getUniqueItems();\n FunctionReference memory startHook = EMPTY_FUNCTION_REFERENCE.unpack();\n FunctionReference[] memory preUserOpValidatorHooks;\n FunctionReference memory nextHook;\n uint256 currentValidationData;\n for (uint256 i = 0; i < totalUniqueHookCount; ++i) {\n (preUserOpValidatorHooks, nextHook) = executionDetail.preUserOpValidationHooks.getPaginated(startHook, 10);\n for (uint256 j = 0; j < preUserOpValidatorHooks.length; ++j) {\n bytes21 packedUserOpValidatorHook = preUserOpValidatorHooks[j].pack();\n // if any revert, the outer call MUST revert\n if (\n packedUserOpValidatorHook == EMPTY_FUNCTION_REFERENCE\n || packedUserOpValidatorHook == RUNTIME_VALIDATION_ALWAYS_ALLOW_FUNCTION_REFERENCE\n || packedUserOpValidatorHook == PRE_HOOK_ALWAYS_DENY_FUNCTION_REFERENCE\n ) {\n revert InvalidHookFunctionId(preUserOpValidatorHooks[j].functionId);\n }\n IPlugin preUserOpValidationHookPlugin = IPlugin(preUserOpValidatorHooks[j].plugin);\n currentValidationData = preUserOpValidationHookPlugin.preUserOpValidationHook(\n preUserOpValidatorHooks[j].functionId, userOp, userOpHash\n );\n unpackedValidationData = unpackedValidationData._intersectValidationData(currentValidationData);\n // if any return an authorizer value other than 0 or 1, execution MUST revert\n if (unpackedValidationData.authorizer != address(0) && unpackedValidationData.authorizer != address(1))\n {\n revert InvalidAuthorizer();\n }\n }\n if (nextHook.pack() == SENTINEL_BYTES21) {\n break;\n }\n startHook = nextHook;\n }\n return unpackedValidationData;\n }\n\n function _checkFromEPOrOwnerOrSelf() internal view {\n // all need to go through validation first, which means being initiated by the owner or account\n if (\n msg.sender != address(ENTRY_POINT) && msg.sender != WalletStorageV1Lib.getLayout().owner\n && msg.sender != address(this)\n ) {\n revert UnauthorizedCaller();\n }\n }\n\n /// @inheritdoc BaseERC712CompliantAccount\n function _getAccountTypeHash() internal pure override returns (bytes32) {\n return _MESSAGE_TYPEHASH;\n }\n\n /// @inheritdoc BaseERC712CompliantAccount\n function _getAccountName() internal pure override returns (bytes32) {\n return _HASHED_NAME;\n }\n\n /// @inheritdoc BaseERC712CompliantAccount\n function _getAccountVersion() internal pure override returns (bytes32) {\n return _HASHED_VERSION;\n }\n}\n"},"src/msca/6900/v0.7/managers/PluginManager.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\nimport {EMPTY_FUNCTION_REFERENCE} from \"../../../../common/Constants.sol\";\nimport {InvalidFunctionReference} from \"../../shared/common/Errors.sol\";\nimport {AddressDLL} from \"../../shared/common/Structs.sol\";\nimport {AddressDLLLib} from \"../../shared/libs/AddressDLLLib.sol\";\nimport {\n PRE_HOOK_ALWAYS_DENY_FUNCTION_REFERENCE,\n RUNTIME_VALIDATION_ALWAYS_ALLOW_FUNCTION_REFERENCE\n} from \"../common/Constants.sol\";\nimport {\n ManifestAssociatedFunctionType,\n ManifestExecutionHook,\n ManifestExternalCallPermission,\n ManifestFunction,\n PluginManifest\n} from \"../common/PluginManifest.sol\";\nimport {\n Bytes21DLL,\n FunctionReference,\n HookGroup,\n PermittedExternalCall,\n RepeatableBytes21DLL\n} from \"../common/Structs.sol\";\nimport {IPlugin} from \"../interfaces/IPlugin.sol\";\nimport {FunctionReferenceDLLLib} from \"../libs/FunctionReferenceDLLLib.sol\";\nimport {FunctionReferenceLib} from \"../libs/FunctionReferenceLib.sol\";\nimport {RepeatableFunctionReferenceDLLLib} from \"../libs/RepeatableFunctionReferenceDLLLib.sol\";\nimport {SelectorRegistryLib} from \"../libs/SelectorRegistryLib.sol\";\nimport {WalletStorageV1Lib} from \"../libs/WalletStorageV1Lib.sol\";\nimport {ERC165Checker} from \"@openzeppelin/contracts/utils/introspection/ERC165Checker.sol\";\n\n/**\n * @dev Default implementation of https://eips.ethereum.org/EIPS/eip-6900. MSCAs must implement this interface to\n * support installing and uninstalling plugins.\n */\ncontract PluginManager {\n using AddressDLLLib for AddressDLL;\n using FunctionReferenceDLLLib for Bytes21DLL;\n using RepeatableFunctionReferenceDLLLib for RepeatableBytes21DLL;\n using FunctionReferenceLib for FunctionReference;\n using FunctionReferenceLib for bytes21;\n using SelectorRegistryLib for bytes4;\n\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment\n address private immutable SELF = address(this);\n\n enum AssociatedFunctionType {\n HOOK,\n VALIDATION_FUNCTION\n }\n\n error PluginNotImplementInterface();\n error InvalidPluginManifest();\n error InvalidPluginManifestHash();\n error InvalidPluginDependency(address plugin);\n error PluginUsedByOthers(address plugin);\n error ExecutionDetailAlreadySet(address plugin, bytes4 selector);\n error ExecuteFromPluginExternalAlreadySet(address plugin, address externalAddress);\n error ExecuteFromPluginExternalAlreadyUnset(address plugin, address externalAddress);\n error ValidationFunctionAlreadySet(bytes4 selector);\n error FailToCallOnInstall(address plugin, bytes revertReason);\n error OnlyDelegated();\n error HookDependencyNotPermitted();\n error InvalidExecutionSelector(address plugin, bytes4 selector);\n\n modifier onlyDelegated() {\n if (address(this) == SELF) {\n revert OnlyDelegated();\n }\n _;\n }\n\n /// @dev Refer to IPluginManager\n function install(\n address plugin,\n bytes32 manifestHash,\n bytes memory pluginInstallData,\n FunctionReference[] memory dependencies,\n address msca\n ) external onlyDelegated {\n // revert if the plugin does not implement ERC-165 or does not support the IPlugin interface\n if (!ERC165Checker.supportsInterface(plugin, type(IPlugin).interfaceId)) {\n revert PluginNotImplementInterface();\n }\n WalletStorageV1Lib.Layout storage storageLayout = WalletStorageV1Lib.getLayout();\n // revert internally if the plugin has already been installed on the modular account\n storageLayout.installedPlugins.append(plugin);\n IPlugin pluginToInstall = IPlugin(plugin);\n // revert if manifestHash does not match the computed Keccak-256 hash of the plugin’s returned manifest\n PluginManifest memory pluginManifest = pluginToInstall.pluginManifest();\n if (manifestHash != keccak256(abi.encode(pluginManifest))) {\n revert InvalidPluginManifestHash();\n }\n uint256 length = pluginManifest.interfaceIds.length;\n for (uint256 i = 0; i < length; ++i) {\n storageLayout.supportedInterfaces[pluginManifest.interfaceIds[i]] += 1;\n }\n // revert if any address in dependencies does not support the interface at its matching index in the manifest’s\n // dependencyInterfaceIds,\n // or if the two array lengths do not match,\n // or if any of the dependencies are not already installed on the modular account\n length = dependencies.length;\n if (length != pluginManifest.dependencyInterfaceIds.length) {\n revert InvalidPluginDependency(plugin);\n }\n for (uint256 i = 0; i < length; ++i) {\n address dependencyPluginAddr = dependencies[i].plugin;\n // if dependencyPluginAddr is msca address, then we don't actually introduce any new plugin dependency\n // other than native dependency, so we do not need to perform any plugin dependency related logic\n if (dependencyPluginAddr == msca) {\n continue;\n }\n // verify that the dependency is installed, which also prevents self-dependencies\n if (storageLayout.pluginDetails[dependencyPluginAddr].manifestHash == bytes32(0)) {\n revert InvalidPluginDependency(dependencyPluginAddr);\n }\n if (!ERC165Checker.supportsInterface(dependencyPluginAddr, pluginManifest.dependencyInterfaceIds[i])) {\n revert InvalidPluginDependency(dependencyPluginAddr);\n }\n // each dependency’s record MUST also be updated to reflect that it has a new dependent\n // record the plugin dependency, will revert if it's already installed\n storageLayout.pluginDetails[plugin].dependencies.append(dependencies[i]);\n // increment the dependency's dependentCounter since the current plugin is dependent on dependencyPlugin\n storageLayout.pluginDetails[dependencyPluginAddr].dependentCounter += 1;\n }\n\n // record if this plugin is allowed to spend native token\n if (pluginManifest.canSpendNativeToken) {\n storageLayout.pluginDetails[plugin].canSpendNativeToken = true;\n }\n\n // record execution details\n //////////////////////////////////////////////\n // install execution functions and hooks\n //////////////////////////////////////////////\n length = pluginManifest.executionFunctions.length;\n for (uint256 i = 0; i < length; ++i) {\n bytes4 selector = pluginManifest.executionFunctions[i];\n if (storageLayout.executionDetails[selector].plugin != address(0)) {\n revert ExecutionDetailAlreadySet(plugin, selector);\n }\n if (\n selector._isNativeFunctionSelector() || selector._isErc4337FunctionSelector()\n || selector._isIPluginFunctionSelector()\n ) {\n revert InvalidExecutionSelector(plugin, selector);\n }\n storageLayout.executionDetails[selector].plugin = plugin;\n }\n\n // install pre and post execution hooks\n length = pluginManifest.executionHooks.length;\n for (uint256 i = 0; i < length; ++i) {\n bytes4 selector = pluginManifest.executionHooks[i].selector;\n FunctionReference memory preExecHook = _resolveManifestFunction(\n pluginManifest.executionHooks[i].preExecHook,\n plugin,\n dependencies,\n ManifestAssociatedFunctionType.PRE_HOOK_ALWAYS_DENY,\n AssociatedFunctionType.HOOK\n );\n FunctionReference memory postExecHook = _resolveManifestFunction(\n pluginManifest.executionHooks[i].postExecHook,\n plugin,\n dependencies,\n ManifestAssociatedFunctionType.NONE,\n AssociatedFunctionType.HOOK\n );\n _addHookGroup(storageLayout.executionDetails[selector].executionHooks, preExecHook, postExecHook);\n }\n\n //////////////////////////////////////////////\n // install validation functions and hooks\n //////////////////////////////////////////////\n // install userOpValidationFunctions\n length = pluginManifest.userOpValidationFunctions.length;\n for (uint256 i = 0; i < length; ++i) {\n bytes4 selector = pluginManifest.userOpValidationFunctions[i].executionSelector;\n if (storageLayout.executionDetails[selector].userOpValidationFunction.pack() != EMPTY_FUNCTION_REFERENCE) {\n revert ValidationFunctionAlreadySet(selector);\n }\n storageLayout.executionDetails[selector].userOpValidationFunction = _resolveManifestFunction(\n pluginManifest.userOpValidationFunctions[i].associatedFunction,\n plugin,\n dependencies,\n ManifestAssociatedFunctionType.NONE,\n AssociatedFunctionType.VALIDATION_FUNCTION\n );\n }\n // install runtimeValidationFunctions\n length = pluginManifest.runtimeValidationFunctions.length;\n for (uint256 i = 0; i < length; ++i) {\n bytes4 selector = pluginManifest.runtimeValidationFunctions[i].executionSelector;\n if (storageLayout.executionDetails[selector].runtimeValidationFunction.pack() != EMPTY_FUNCTION_REFERENCE) {\n revert ValidationFunctionAlreadySet(selector);\n }\n storageLayout.executionDetails[selector].runtimeValidationFunction = _resolveManifestFunction(\n pluginManifest.runtimeValidationFunctions[i].associatedFunction,\n plugin,\n dependencies,\n ManifestAssociatedFunctionType.RUNTIME_VALIDATION_ALWAYS_ALLOW, // risk burning gas from the account\n AssociatedFunctionType.VALIDATION_FUNCTION\n );\n }\n // install preUserOpValidationHooks\n length = pluginManifest.preUserOpValidationHooks.length;\n // force override to be safe\n FunctionReference[] memory emptyDependencies = new FunctionReference[](0);\n for (uint256 i = 0; i < length; ++i) {\n bytes4 selector = pluginManifest.preUserOpValidationHooks[i].executionSelector;\n // revert internally\n storageLayout.executionDetails[selector].preUserOpValidationHooks.append(\n _resolveManifestFunction(\n pluginManifest.preUserOpValidationHooks[i].associatedFunction,\n plugin,\n emptyDependencies,\n ManifestAssociatedFunctionType.PRE_HOOK_ALWAYS_DENY,\n AssociatedFunctionType.HOOK\n )\n );\n }\n // install preRuntimeValidationHooks\n length = pluginManifest.preRuntimeValidationHooks.length;\n for (uint256 i = 0; i < length; ++i) {\n // revert internally\n storageLayout.executionDetails[pluginManifest.preRuntimeValidationHooks[i].executionSelector]\n .preRuntimeValidationHooks\n .append(\n _resolveManifestFunction(\n pluginManifest.preRuntimeValidationHooks[i].associatedFunction,\n plugin,\n emptyDependencies,\n ManifestAssociatedFunctionType.PRE_HOOK_ALWAYS_DENY,\n AssociatedFunctionType.HOOK\n )\n );\n }\n\n // store the plugin’s permitted function selectors and external contract calls to be able to validate calls\n // to executeFromPlugin and executeFromPluginExternal\n //////////////////////////////////////////////\n // permissions for executeFromPlugin\n //////////////////////////////////////////////\n // native functions or execution functions already installed on the MSCA that this plugin will be able to call\n length = pluginManifest.permittedExecutionSelectors.length;\n for (uint256 i = 0; i < length; ++i) {\n // enable PermittedPluginCall\n storageLayout.permittedPluginCalls[plugin][pluginManifest.permittedExecutionSelectors[i]] = true;\n }\n\n //////////////////////////////////////////////\n // permissions for executeFromPluginExternal\n //////////////////////////////////////////////\n // is the plugin permitted to call any external contracts and selectors\n if (pluginManifest.permitAnyExternalAddress) {\n storageLayout.pluginDetails[plugin].anyExternalAddressPermitted = true;\n } else {\n // more limited access - record external contract calls that this plugin will be able to make\n length = pluginManifest.permittedExternalCalls.length;\n for (uint256 i = 0; i < length; ++i) {\n ManifestExternalCallPermission memory externalCallPermission = pluginManifest.permittedExternalCalls[i];\n PermittedExternalCall storage permittedExternalCall =\n storageLayout.permittedExternalCalls[plugin][externalCallPermission.externalAddress];\n if (permittedExternalCall.addressPermitted) {\n revert ExecuteFromPluginExternalAlreadySet(plugin, externalCallPermission.externalAddress);\n }\n permittedExternalCall.addressPermitted = true;\n if (externalCallPermission.permitAnySelector) {\n permittedExternalCall.anySelector = true;\n } else {\n uint256 permittedExternalCallSelectorsLength = externalCallPermission.selectors.length;\n for (uint256 j = 0; j < permittedExternalCallSelectorsLength; ++j) {\n permittedExternalCall.selectors[externalCallPermission.selectors[j]] = true;\n }\n }\n }\n }\n\n // store the plugin manifest hash at the end, which serves to prevent self-dependencies\n storageLayout.pluginDetails[plugin].manifestHash = manifestHash;\n // call onInstall to initialize plugin data for the modular account\n // solhint-disable-next-line no-empty-blocks\n try IPlugin(plugin).onInstall(pluginInstallData) {}\n catch (bytes memory revertReason) {\n revert FailToCallOnInstall(plugin, revertReason);\n }\n }\n\n /// @dev Refer to IPluginManager\n function uninstall(address plugin, bytes memory config, bytes memory pluginUninstallData)\n external\n onlyDelegated\n returns (bool)\n {\n WalletStorageV1Lib.Layout storage storageLayout = WalletStorageV1Lib.getLayout();\n // revert internally if plugin was not installed before\n storageLayout.installedPlugins.remove(plugin);\n PluginManifest memory pluginManifest;\n if (config.length > 0) {\n // the modular account MAY implement the capability for the manifest to be encoded in the config field as a\n // parameter\n pluginManifest = abi.decode(config, (PluginManifest));\n } else {\n pluginManifest = IPlugin(plugin).pluginManifest();\n }\n // revert if the hash of the manifest used at install time does not match the computed Keccak-256 hash of the\n // plugin’s current manifest\n if (storageLayout.pluginDetails[plugin].manifestHash != keccak256(abi.encode(pluginManifest))) {\n revert InvalidPluginManifestHash();\n }\n // revert if there is at least 1 other installed plugin that depends on validation functions or hooks added by\n // this plugin;\n // plugins used as dependencies must not be uninstalled while dependent plugins exist\n if (storageLayout.pluginDetails[plugin].dependentCounter != 0) {\n revert PluginUsedByOthers(plugin);\n }\n // each dependency’s record SHOULD be updated to reflect that it has no longer has this plugin as a dependent\n _removeDependencies(plugin, storageLayout);\n // remove records for the plugin’s dependencies, injected permitted call hooks, permitted function selectors,\n // and permitted external contract calls\n // uninstall the components in reverse order (by component type) of their installation\n //////////////////////////////////////////////\n // permissions for executeFromPluginExternal\n //////////////////////////////////////////////\n if (pluginManifest.permitAnyExternalAddress) {\n storageLayout.pluginDetails[plugin].anyExternalAddressPermitted = false;\n }\n uint256 length;\n if (!pluginManifest.permitAnyExternalAddress) {\n length = pluginManifest.permittedExternalCalls.length;\n for (uint256 i = 0; i < length; ++i) {\n ManifestExternalCallPermission memory externalCallPermission = pluginManifest.permittedExternalCalls[i];\n PermittedExternalCall storage permittedExternalCall =\n storageLayout.permittedExternalCalls[plugin][externalCallPermission.externalAddress];\n if (!permittedExternalCall.addressPermitted) {\n revert ExecuteFromPluginExternalAlreadyUnset(plugin, externalCallPermission.externalAddress);\n }\n permittedExternalCall.addressPermitted = false;\n if (externalCallPermission.permitAnySelector) {\n permittedExternalCall.anySelector = false;\n } else {\n uint256 permittedExternalCallSelectorsLength = externalCallPermission.selectors.length;\n for (uint256 j = 0; j < permittedExternalCallSelectorsLength; ++j) {\n permittedExternalCall.selectors[externalCallPermission.selectors[j]] = false;\n }\n }\n }\n }\n\n length = pluginManifest.permittedExecutionSelectors.length;\n for (uint256 i = 0; i < length; ++i) {\n // disable PermittedPluginCall\n storageLayout.permittedPluginCalls[plugin][pluginManifest.permittedExecutionSelectors[i]] = false;\n }\n\n //////////////////////////////////////////////\n // uninstall validation functions and hooks\n //////////////////////////////////////////////\n // uninstall preRuntimeValidationHooks\n FunctionReference[] memory emptyDependencies = new FunctionReference[](0);\n length = pluginManifest.preRuntimeValidationHooks.length;\n for (uint256 i = 0; i < length; ++i) {\n // revert internally\n storageLayout.executionDetails[pluginManifest.preRuntimeValidationHooks[i].executionSelector]\n .preRuntimeValidationHooks\n .remove(\n _resolveManifestFunction(\n pluginManifest.preRuntimeValidationHooks[i].associatedFunction,\n plugin,\n emptyDependencies,\n ManifestAssociatedFunctionType.PRE_HOOK_ALWAYS_DENY,\n AssociatedFunctionType.HOOK\n )\n );\n }\n // uninstall preUserOpValidationHooks\n length = pluginManifest.preUserOpValidationHooks.length;\n for (uint256 i = 0; i < length; ++i) {\n // revert internally\n storageLayout.executionDetails[pluginManifest.preUserOpValidationHooks[i].executionSelector]\n .preUserOpValidationHooks\n .remove(\n _resolveManifestFunction(\n pluginManifest.preUserOpValidationHooks[i].associatedFunction,\n plugin,\n emptyDependencies,\n ManifestAssociatedFunctionType.PRE_HOOK_ALWAYS_DENY,\n AssociatedFunctionType.HOOK\n )\n );\n }\n // uninstall runtimeValidationFunctions\n FunctionReference memory emptyFunctionReference = EMPTY_FUNCTION_REFERENCE.unpack();\n length = pluginManifest.runtimeValidationFunctions.length;\n for (uint256 i = 0; i < length; ++i) {\n storageLayout.executionDetails[pluginManifest.runtimeValidationFunctions[i].executionSelector]\n .runtimeValidationFunction = emptyFunctionReference;\n }\n // uninstall userOpValidationFunctions\n length = pluginManifest.userOpValidationFunctions.length;\n for (uint256 i = 0; i < length; ++i) {\n storageLayout.executionDetails[pluginManifest.userOpValidationFunctions[i].executionSelector]\n .userOpValidationFunction = emptyFunctionReference;\n }\n\n //////////////////////////////////////////////\n // uninstall execution functions and hooks\n //////////////////////////////////////////////\n _removeExecutionHooks(plugin, pluginManifest.executionHooks, storageLayout);\n length = pluginManifest.executionFunctions.length;\n for (uint256 i = 0; i < length; ++i) {\n storageLayout.executionDetails[pluginManifest.executionFunctions[i]].plugin = address(0);\n }\n\n length = pluginManifest.interfaceIds.length;\n for (uint256 i = 0; i < length; ++i) {\n storageLayout.supportedInterfaces[pluginManifest.interfaceIds[i]] -= 1;\n }\n // reset all members that are not mappings and also recurse into the members unless they're mappings\n delete storageLayout.pluginDetails[plugin];\n // call the plugin’s onUninstall callback with the data provided in the uninstallData parameter;\n // This serves to clear the plugin state for the modular account;\n // If onUninstall reverts, execution SHOULD continue to allow the uninstall to complete\n bool onUninstallSucceeded = true;\n // solhint-disable-next-line no-empty-blocks\n try IPlugin(plugin).onUninstall(pluginUninstallData) {}\n catch {\n // leave it up to the caller if we want to revert if the plugin storage isn't cleaned up\n onUninstallSucceeded = false;\n }\n return onUninstallSucceeded;\n }\n\n /**\n * @dev Resolve manifest function.\n * For functions of type `ManifestAssociatedFunctionType.DEPENDENCY`, the MSCA MUST find the plugin address\n * of the function at `dependencies[dependencyIndex]` during the call to `installPlugin(config)`.\n * A plugin can no longer use hooks from other plugins to be added on Execution and/or Validation function\n * selectors\n * in its own manifest. We'll revert if hook is provided as dependency from an external plugin.\n * @param allowedMagicValue which magic value (if any) is permissible for the function type to resolve.\n * @param associatedFunctionType the type of associated function, either a validation function or a hook, as opposed\n * to execution functions\n */\n function _resolveManifestFunction(\n ManifestFunction memory manifestFunction,\n address plugin,\n FunctionReference[] memory dependencies,\n ManifestAssociatedFunctionType allowedMagicValue,\n AssociatedFunctionType associatedFunctionType\n ) internal pure returns (FunctionReference memory) {\n // revert if it's hook and provided as dependency\n if (\n associatedFunctionType == AssociatedFunctionType.HOOK\n && manifestFunction.functionType == ManifestAssociatedFunctionType.DEPENDENCY\n ) {\n revert HookDependencyNotPermitted();\n }\n if (manifestFunction.functionType == ManifestAssociatedFunctionType.SELF) {\n return FunctionReference(plugin, manifestFunction.functionId);\n } else if (manifestFunction.functionType == ManifestAssociatedFunctionType.DEPENDENCY) {\n // out of boundary\n if (manifestFunction.dependencyIndex >= dependencies.length) {\n revert InvalidPluginManifest();\n }\n return dependencies[manifestFunction.dependencyIndex];\n } else if (manifestFunction.functionType == ManifestAssociatedFunctionType.RUNTIME_VALIDATION_ALWAYS_ALLOW) {\n if (allowedMagicValue == ManifestAssociatedFunctionType.RUNTIME_VALIDATION_ALWAYS_ALLOW) {\n return RUNTIME_VALIDATION_ALWAYS_ALLOW_FUNCTION_REFERENCE.unpack();\n } else {\n revert InvalidPluginManifest();\n }\n } else if (manifestFunction.functionType == ManifestAssociatedFunctionType.PRE_HOOK_ALWAYS_DENY) {\n if (allowedMagicValue == ManifestAssociatedFunctionType.PRE_HOOK_ALWAYS_DENY) {\n return PRE_HOOK_ALWAYS_DENY_FUNCTION_REFERENCE.unpack();\n } else {\n revert InvalidPluginManifest();\n }\n } else {\n return EMPTY_FUNCTION_REFERENCE.unpack();\n }\n }\n\n function _addHookGroup(\n HookGroup storage hookGroup,\n FunctionReference memory preExecHook,\n FunctionReference memory postExecHook\n ) internal {\n bytes21 packedPreExecHook = preExecHook.pack();\n if (packedPreExecHook == EMPTY_FUNCTION_REFERENCE) {\n if (postExecHook.pack() == EMPTY_FUNCTION_REFERENCE) {\n // pre and post hooks cannot be null at the same time\n revert InvalidFunctionReference();\n }\n hookGroup.postOnlyHooks.append(postExecHook);\n } else {\n hookGroup.preHooks.append(preExecHook);\n if (postExecHook.pack() != EMPTY_FUNCTION_REFERENCE) {\n hookGroup.preToPostHooks[packedPreExecHook].append(postExecHook);\n }\n }\n }\n\n function _removeHookGroup(\n HookGroup storage hookGroup,\n FunctionReference memory preExecHook,\n FunctionReference memory postExecHook\n ) internal {\n bytes21 packedPreExecHook = preExecHook.pack();\n if (packedPreExecHook == EMPTY_FUNCTION_REFERENCE) {\n // pre and post hooks cannot be null at the same time\n hookGroup.postOnlyHooks.remove(postExecHook);\n } else {\n hookGroup.preHooks.remove(preExecHook);\n // remove postExecHook if any\n if (postExecHook.pack() != EMPTY_FUNCTION_REFERENCE) {\n hookGroup.preToPostHooks[packedPreExecHook].remove(postExecHook);\n }\n }\n }\n\n function _removeDependencies(address plugin, WalletStorageV1Lib.Layout storage storageLayout) internal {\n Bytes21DLL storage pluginDependencies = storageLayout.pluginDetails[plugin].dependencies;\n uint256 length = pluginDependencies.size();\n FunctionReference memory startFR = EMPTY_FUNCTION_REFERENCE.unpack();\n FunctionReference[] memory dependencies;\n for (uint256 i = 0; i < length; ++i) {\n // if the max length of dependencies is reached, the loop will break early\n (dependencies, startFR) = pluginDependencies.getPaginated(startFR, 10);\n for (uint256 j = 0; j < dependencies.length; ++j) {\n storageLayout.pluginDetails[dependencies[j].plugin].dependentCounter -= 1;\n storageLayout.pluginDetails[plugin].dependencies.remove(dependencies[j]);\n }\n if (startFR.pack() == EMPTY_FUNCTION_REFERENCE) {\n break;\n }\n }\n }\n\n function _removeExecutionHooks(\n address plugin,\n ManifestExecutionHook[] memory executionHooks,\n WalletStorageV1Lib.Layout storage storageLayout\n ) internal {\n uint256 length = executionHooks.length;\n FunctionReference[] memory dependencies = new FunctionReference[](0);\n for (uint256 i = 0; i < length; ++i) {\n bytes4 selector = executionHooks[i].selector;\n FunctionReference memory preExecHook = _resolveManifestFunction(\n executionHooks[i].preExecHook,\n plugin,\n dependencies,\n ManifestAssociatedFunctionType.PRE_HOOK_ALWAYS_DENY,\n AssociatedFunctionType.HOOK\n );\n FunctionReference memory postExecHookToRemove = _resolveManifestFunction(\n executionHooks[i].postExecHook,\n plugin,\n dependencies,\n ManifestAssociatedFunctionType.NONE,\n AssociatedFunctionType.HOOK\n );\n _removeHookGroup(storageLayout.executionDetails[selector].executionHooks, preExecHook, postExecHookToRemove);\n }\n }\n}\n"},"lib/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.8.12;\n\n/* solhint-disable avoid-low-level-calls */\n/* solhint-disable no-inline-assembly */\n/* solhint-disable reason-string */\n\nimport \"./UserOperation.sol\";\nimport \"./IStakeManager.sol\";\nimport \"./IAggregator.sol\";\nimport \"./INonceManager.sol\";\n\ninterface IEntryPoint is IStakeManager, INonceManager {\n\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, validation and execution).\n */\n event UserOperationEvent(bytes32 indexed userOpHash, address indexed sender, address indexed paymaster, uint256 nonce, bool success, uint256 actualGasCost, uint256 actualGasUsed);\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(bytes32 indexed userOpHash, address indexed sender, address factory, address paymaster);\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(bytes32 indexed userOpHash, address indexed sender, uint256 nonce, bytes revertReason);\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 */\n event SignatureAggregatorChanged(address indexed aggregator);\n\n /**\n * a custom revert error of handleOps, to identify the offending op.\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\n * The string starts with a unique code \"AAmn\", 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 * 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 */\n error FailedOp(uint256 opIndex, string reason);\n\n /**\n * error case when a signature aggregator fails to verify the aggregated signature it had created.\n */\n error SignatureValidationFailed(address aggregator);\n\n /**\n * Successful result from simulateValidation.\n * @param returnInfo gas and time-range returned values\n * @param senderInfo stake information about the sender\n * @param factoryInfo stake information about the factory (if any)\n * @param paymasterInfo stake information about the paymaster (if any)\n */\n error ValidationResult(ReturnInfo returnInfo,\n StakeInfo senderInfo, StakeInfo factoryInfo, StakeInfo paymasterInfo);\n\n /**\n * Successful result from simulateValidation, if the account returns a signature aggregator\n * @param returnInfo gas and time-range returned values\n * @param senderInfo stake information about the sender\n * @param factoryInfo stake information about the factory (if any)\n * @param paymasterInfo stake information about the paymaster (if any)\n * @param aggregatorInfo signature aggregation info (if the account requires signature aggregator)\n * bundler MUST use it to verify the signature, or reject the UserOperation\n */\n error ValidationResultWithAggregation(ReturnInfo returnInfo,\n StakeInfo senderInfo, StakeInfo factoryInfo, StakeInfo paymasterInfo,\n AggregatorStakeInfo aggregatorInfo);\n\n /**\n * return value of getSenderAddress\n */\n error SenderAddressResult(address sender);\n\n /**\n * return value of simulateHandleOp\n */\n error ExecutionResult(uint256 preOpGas, uint256 paid, uint48 validAfter, uint48 validUntil, bool targetSuccess, bytes targetResult);\n\n //UserOps handled, per aggregator\n struct UserOpsPerAggregator {\n UserOperation[] userOps;\n\n // aggregator address\n IAggregator aggregator;\n // aggregated signature\n bytes signature;\n }\n\n /**\n * Execute a batch of UserOperation.\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(UserOperation[] calldata ops, address payable beneficiary) 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 */\n function getUserOpHash(UserOperation calldata userOp) external view returns (bytes32);\n\n /**\n * Simulate a call to account.validateUserOp and paymaster.validatePaymasterUserOp.\n * @dev this method always revert. Successful result is ValidationResult error. other errors are failures.\n * @dev The node must also verify it doesn't use banned opcodes, and that it doesn't reference storage outside the account's data.\n * @param userOp the user operation to validate.\n */\n function simulateValidation(UserOperation calldata userOp) external;\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 sigFailed validateUserOp's (or paymaster's) signature check failed\n * @param validAfter - first timestamp this UserOp is valid (merging account and paymaster time-range)\n * @param validUntil - last timestamp this UserOp is valid (merging account and paymaster time-range)\n * @param paymasterContext returned by validatePaymasterUserOp (to be passed into postOp)\n */\n struct ReturnInfo {\n uint256 preOpGas;\n uint256 prefund;\n bool sigFailed;\n uint48 validAfter;\n uint48 validUntil;\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\n /**\n * simulate full execution of a UserOperation (including both validation and target execution)\n * this method will always revert with \"ExecutionResult\".\n * it performs full validation of the UserOperation, but ignores signature error.\n * an optional target address is called after the userop succeeds, and its value is returned\n * (before the entire call is reverted)\n * Note that in order to collect the the success/failure of the target call, it must be executed\n * with trace enabled to track the emitted events.\n * @param op the UserOperation to simulate\n * @param target if nonzero, a target address to call after userop simulation. If called, the targetSuccess and targetResult\n * are set to the return from that call.\n * @param targetCallData callData to pass to target address\n */\n function simulateHandleOp(UserOperation calldata op, address target, bytes calldata targetCallData) external;\n}\n\n"},"node_modules/@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Proxy.sol\";\nimport \"./ERC1967Upgrade.sol\";\n\n/**\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\n * implementation address that can be changed. This address is stored in storage in the location specified by\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\n * implementation behind the proxy.\n */\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\n /**\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\n *\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\n */\n constructor(address _logic, bytes memory _data) payable {\n _upgradeToAndCall(_logic, _data, false);\n }\n\n /**\n * @dev Returns the current implementation address.\n */\n function _implementation() internal view virtual override returns (address impl) {\n return ERC1967Upgrade._getImplementation();\n }\n}\n"},"node_modules/@openzeppelin/contracts/utils/Create2.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Create2.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Helper to make usage of the `CREATE2` EVM opcode easier and safer.\n * `CREATE2` can be used to compute in advance the address where a smart\n * contract will be deployed, which allows for interesting new mechanisms known\n * as 'counterfactual interactions'.\n *\n * See the https://eips.ethereum.org/EIPS/eip-1014#motivation[EIP] for more\n * information.\n */\nlibrary Create2 {\n /**\n * @dev Deploys a contract using `CREATE2`. The address where the contract\n * will be deployed can be known in advance via {computeAddress}.\n *\n * The bytecode for a contract can be obtained from Solidity with\n * `type(contractName).creationCode`.\n *\n * Requirements:\n *\n * - `bytecode` must not be empty.\n * - `salt` must have not been used for `bytecode` already.\n * - the factory must have a balance of at least `amount`.\n * - if `amount` is non-zero, `bytecode` must have a `payable` constructor.\n */\n function deploy(uint256 amount, bytes32 salt, bytes memory bytecode) internal returns (address addr) {\n require(address(this).balance >= amount, \"Create2: insufficient balance\");\n require(bytecode.length != 0, \"Create2: bytecode length is zero\");\n /// @solidity memory-safe-assembly\n assembly {\n addr := create2(amount, add(bytecode, 0x20), mload(bytecode), salt)\n }\n require(addr != address(0), \"Create2: Failed on deploy\");\n }\n\n /**\n * @dev Returns the address where a contract will be stored if deployed via {deploy}. Any change in the\n * `bytecodeHash` or `salt` will result in a new destination address.\n */\n function computeAddress(bytes32 salt, bytes32 bytecodeHash) internal view returns (address) {\n return computeAddress(salt, bytecodeHash, address(this));\n }\n\n /**\n * @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at\n * `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}.\n */\n function computeAddress(bytes32 salt, bytes32 bytecodeHash, address deployer) internal pure returns (address addr) {\n /// @solidity memory-safe-assembly\n assembly {\n let ptr := mload(0x40) // Get free memory pointer\n\n // | | ↓ ptr ... ↓ ptr + 0x0B (start) ... ↓ ptr + 0x20 ... ↓ ptr + 0x40 ... |\n // |-------------------|---------------------------------------------------------------------------|\n // | bytecodeHash | CCCCCCCCCCCCC...CC |\n // | salt | BBBBBBBBBBBBB...BB |\n // | deployer | 000000...0000AAAAAAAAAAAAAAAAAAA...AA |\n // | 0xFF | FF |\n // |-------------------|---------------------------------------------------------------------------|\n // | memory | 000000...00FFAAAAAAAAAAAAAAAAAAA...AABBBBBBBBBBBBB...BBCCCCCCCCCCCCC...CC |\n // | keccak(start, 85) | ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ |\n\n mstore(add(ptr, 0x40), bytecodeHash)\n mstore(add(ptr, 0x20), salt)\n mstore(ptr, deployer) // Right-aligned with 12 preceding garbage bytes\n let start := add(ptr, 0x0b) // The hashed data starts at the final garbage byte which we will set to 0xff\n mstore8(start, 0xff)\n addr := keccak256(start, 85)\n }\n }\n}\n"},"src/callback/DefaultCallbackHandler.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\nimport {IERC777Recipient} from \"@openzeppelin/contracts/interfaces/IERC777Recipient.sol\";\nimport {IERC1155Receiver} from \"@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol\";\nimport {IERC721Receiver} from \"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\";\nimport {IERC165} from \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\n\n/**\n * @dev Token callback handler. Allowing account receiving these tokens.\n * @notice The user will have to register itself in the ERC1820 global registry\n * in order to fully support ERC777 token operations upon the installation of this plugin.\n */\ncontract DefaultCallbackHandler is IERC721Receiver, IERC1155Receiver, IERC777Recipient {\n function supportsInterface(bytes4 interfaceId) external view virtual override returns (bool) {\n return interfaceId == type(IERC721Receiver).interfaceId || interfaceId == type(IERC1155Receiver).interfaceId\n || interfaceId == type(IERC165).interfaceId;\n }\n\n function onERC1155Received(address, address, uint256, uint256, bytes calldata)\n external\n pure\n override\n returns (bytes4)\n {\n return IERC1155Receiver.onERC1155Received.selector;\n }\n\n function onERC1155BatchReceived(address, address, uint256[] calldata, uint256[] calldata, bytes calldata)\n external\n pure\n override\n returns (bytes4)\n {\n return IERC1155Receiver.onERC1155BatchReceived.selector;\n }\n\n function onERC721Received(address, address, uint256, bytes calldata) external pure override returns (bytes4) {\n return IERC721Receiver.onERC721Received.selector;\n }\n\n // ERC777\n function tokensReceived(\n address operator,\n address from,\n address to,\n uint256 amount,\n bytes calldata userData,\n bytes calldata operatorData\n ) external pure override \n // solhint-disable-next-line no-empty-blocks\n {}\n}\n"},"src/common/Constants.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\n// ERC4337 constants\n\n// return value in case of signature failure, with no time-range.\n// equivalent to _packValidationData(true,0,0);\nuint256 constant SIG_VALIDATION_FAILED = 1;\nuint256 constant SIG_VALIDATION_SUCCEEDED = 0;\n\n// sentinel values\n// any values less than or equal to this will not be allowed in storage\nbytes21 constant SENTINEL_BYTES21 = bytes21(0);\nbytes23 constant SENTINEL_BYTES23 = bytes23(0);\nbytes32 constant SENTINEL_BYTES32 = bytes32(0);\n\n// empty or unset function reference\n// we don't store the empty function reference\nbytes21 constant EMPTY_FUNCTION_REFERENCE = bytes21(0);\n\n// wallet constants\nstring constant WALLET_AUTHOR = \"Circle Internet Financial\";\nstring constant WALLET_VERSION_1 = \"1.0.0\";\n\n// plugin constants\nstring constant PLUGIN_AUTHOR = \"Circle Internet Financial\";\nstring constant PLUGIN_VERSION_1 = \"1.0.0\";\n\n// bytes4(keccak256(\"isValidSignature(bytes32,bytes)\")\nbytes4 constant EIP1271_VALID_SIGNATURE = 0x1626ba7e;\nbytes4 constant EIP1271_INVALID_SIGNATURE = 0xffffffff;\n\n// keccak256('')\nbytes32 constant EMPTY_HASH = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;\n\nuint256 constant ZERO = 0;\n\nbytes32 constant ZERO_BYTES32 = bytes32(0);\nbytes24 constant EMPTY_MODULE_ENTITY = bytes24(0);\n"},"src/common/Errors.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\n/**\n * @notice Throws when the caller is unexpected.\n */\nerror UnauthorizedCaller();\n\nerror InvalidLength();\n\nerror Unsupported();\n"},"src/utils/ExecutionUtils.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\n/**\n * Utility functions helpful when making different kinds of contract calls in Solidity.\n * For inline assembly, please refer to https://docs.soliditylang.org/en/latest/assembly.html\n * For opcodes, please refer to https://ethereum.org/en/developers/docs/evm/opcodes/ and https://www.evm.codes/\n */\nlibrary ExecutionUtils {\n function call(address to, uint256 value, bytes memory data)\n internal\n returns (bool success, bytes memory returnData)\n {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n success := call(gas(), to, value, add(data, 0x20), mload(data), 0, 0)\n let len := returndatasize()\n let ptr := mload(0x40)\n mstore(0x40, add(ptr, add(len, 0x20)))\n mstore(ptr, len)\n returndatacopy(add(ptr, 0x20), 0, len)\n returnData := ptr\n }\n }\n\n function revertWithData(bytes memory returnData) internal pure {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n revert(add(returnData, 32), mload(returnData))\n }\n }\n\n function callAndRevert(address to, uint256 value, bytes memory data) internal {\n (bool success, bytes memory returnData) = call(to, value, data);\n if (!success) {\n revertWithData(returnData);\n }\n }\n\n function callWithReturnDataOrRevert(address to, uint256 value, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returnData) = call(to, value, data);\n if (!success) {\n // bubble up revert reason\n revertWithData(returnData);\n }\n return returnData;\n }\n\n /// @dev Return data or revert.\n function delegateCall(address to, bytes memory data) internal returns (bytes memory) {\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory returnData) = to.delegatecall(data);\n if (!success) {\n // bubble up revert reason\n revertWithData(returnData);\n }\n return returnData;\n }\n\n /// @dev Allocates memory for and retrieves return data from the previous external function call. The end of the\n /// allocated data may not be aligned to 32 bytes, which means the next free memory slot might fall somewhere\n /// between two 32-byte words. Therefore the memory address is aligned to the next 32-byte boundary to ensure\n /// efficient memory usage. The function also stores the size of the return data and copies the return data\n /// itself into the allocated memory.\n /// @return returnData the data returned by the last external function call.\n /// @notice The function ensures memory alignment by adding 63 (0x3f = 0x1f + 0x20) and clearing the last 5 bits,\n /// ensuring the memory is pushed to the nearest multiple of 32 bytes. This avoids unaligned memory access,\n /// which can lead to inefficiencies.\n function fetchReturnData() internal pure returns (bytes memory returnData) {\n // solhint-disable-next-line no-inline-assembly\n assembly (\"memory-safe\") {\n // allocate memory for the return data starting at the free memory pointer\n returnData := mload(0x40)\n // update the free memory pointer after adding the size of the return data and ensuring it is aligned to the\n // next 32-byte boundary\n mstore(0x40, add(returnData, and(add(returndatasize(), 0x3f), not(0x1f))))\n // store the size of the return data at the start of the allocated memory\n mstore(returnData, returndatasize())\n // copy the return data to the allocated memory space\n returndatacopy(add(returnData, 0x20), 0, returndatasize())\n }\n }\n}\n"},"src/msca/6900/shared/common/Structs.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\n/**\n * @dev Returned data from validateUserOp.\n * validateUserOp returns a uint256, with is created by `_packedValidationData` and parsed by `_parseValidationData`\n * @param validAfter - this UserOp is valid only after this timestamp.\n * @param validaUntil - this UserOp is valid only up to this timestamp.\n * @param authorizer - 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 be used to validate the\n * signature.\n */\nstruct ValidationData {\n uint48 validAfter;\n uint48 validUntil;\n address authorizer;\n}\n\nstruct AddressDLL {\n mapping(address => address) next;\n mapping(address => address) prev;\n uint256 count;\n}\n\nstruct Bytes4DLL {\n mapping(bytes4 => bytes4) next;\n mapping(bytes4 => bytes4) prev;\n uint256 count;\n}\n\nstruct Bytes32DLL {\n mapping(bytes32 => bytes32) next;\n mapping(bytes32 => bytes32) prev;\n uint256 count;\n}\n"},"src/msca/6900/shared/libs/ValidationDataLib.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\nimport {ValidationData} from \"../common/Structs.sol\";\n\nlibrary ValidationDataLib {\n error WrongTimeBounds();\n\n /**\n * @dev Intercept the time bounds `[validAfter, validUntil]` and the signature validation result,\n * prioritizing the invalid authorizer (`!=0 && !=1`), followed by prioritizing failure (`==1`),\n * and finally returning success (`==0`). Please note that both `authorizer(2)` and `authorizer(3)` are invalid,\n * and calling this function with `(2, 3)` ensures that only one invalid authorizer will be returned.\n * @notice address(0) is a successful validation, address(1) is a failed validation,\n * and address(2), address(3) and others are invalid authorizers (also failed).\n */\n function _intersectValidationData(ValidationData memory a, uint256 uintb)\n internal\n pure\n returns (ValidationData memory validationData)\n {\n ValidationData memory b = _unpackValidationData(uintb);\n if (a.validAfter > a.validUntil) {\n revert WrongTimeBounds();\n }\n if (b.validAfter > b.validUntil) {\n revert WrongTimeBounds();\n }\n // 0 is successful validation\n if (!_isValidAuthorizer(a.authorizer)) {\n validationData.authorizer = a.authorizer;\n } else if (!_isValidAuthorizer(b.authorizer)) {\n validationData.authorizer = b.authorizer;\n } else {\n if (a.authorizer == address(0)) {\n validationData.authorizer = b.authorizer;\n } else {\n validationData.authorizer = a.authorizer;\n }\n }\n if (a.validAfter > b.validAfter) {\n validationData.validAfter = a.validAfter;\n } else {\n validationData.validAfter = b.validAfter;\n }\n if (a.validUntil < b.validUntil) {\n validationData.validUntil = a.validUntil;\n } else {\n validationData.validUntil = b.validUntil;\n }\n // make sure the caller (e.g. entryPoint) reverts\n // set to address(1) if and only if the authorizer is address(0) (successful validation)\n // we don't want to set to address(1) if the authorizer is invalid such as address(2)\n if (validationData.validAfter >= validationData.validUntil && validationData.authorizer == address(0)) {\n validationData.authorizer = address(1);\n }\n return validationData;\n }\n\n /**\n * @dev Unpack into the deserialized packed format from validAfter | validUntil | authorizer.\n */\n function _unpackValidationData(uint256 validationDataInt)\n internal\n pure\n returns (ValidationData memory validationData)\n {\n address authorizer = address(uint160(validationDataInt));\n uint48 validUntil = uint48(validationDataInt >> 160);\n if (validUntil == 0) {\n validUntil = type(uint48).max;\n }\n uint48 validAfter = uint48(validationDataInt >> (48 + 160));\n return ValidationData(validAfter, validUntil, authorizer);\n }\n\n function _packValidationData(ValidationData memory data) internal pure returns (uint256) {\n return uint160(data.authorizer) | (uint256(data.validUntil) << 160) | (uint256(data.validAfter) << (160 + 48));\n }\n\n function _isValidAuthorizer(address authorizer) internal pure returns (bool) {\n return authorizer == address(0) || authorizer == address(1);\n }\n}\n"},"src/msca/6900/v0.7/common/Constants.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\n// magic value for runtime validation functions that always allow access\nbytes21 constant RUNTIME_VALIDATION_ALWAYS_ALLOW_FUNCTION_REFERENCE = bytes21(uint168(1));\n\n// magic value for hooks that should always revert\nbytes21 constant PRE_HOOK_ALWAYS_DENY_FUNCTION_REFERENCE = bytes21(uint168(2));\n"},"src/msca/6900/v0.7/common/Structs.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\n// Standard executor\nstruct Call {\n // The target address for the account to call.\n address target;\n // The value to send with the call.\n uint256 value;\n // The calldata for the call.\n bytes data;\n}\n\nstruct FunctionReference {\n address plugin;\n uint8 functionId;\n}\n\n// Account loupe\n// @notice Config for an execution function, given a selector\nstruct ExecutionFunctionConfig {\n address plugin;\n FunctionReference userOpValidationFunction;\n FunctionReference runtimeValidationFunction;\n}\n\n/// @notice Pre and post hooks for a given selector\n/// @dev It's possible for one of either `preExecHook` or `postExecHook` to be empty\nstruct ExecutionHooks {\n FunctionReference preExecHook;\n FunctionReference postExecHook;\n}\n\n// internal data structure\nstruct Bytes21DLL {\n mapping(bytes21 => bytes21) next;\n mapping(bytes21 => bytes21) prev;\n uint256 count;\n}\n\nstruct RepeatableBytes21DLL {\n mapping(bytes21 => bytes21) next;\n mapping(bytes21 => bytes21) prev;\n mapping(bytes21 => uint256) counter;\n // unique items\n uint256 uniqueItems;\n // total items with repeatable ones\n uint256 totalItems;\n}\n\n// Represents a set of pre and post hooks. Used to store execution hooks.\nstruct HookGroup {\n RepeatableBytes21DLL preHooks;\n // key = preExecHook.pack()\n mapping(bytes21 => RepeatableBytes21DLL) preToPostHooks;\n RepeatableBytes21DLL postOnlyHooks;\n}\n\n// plugin's permission to call external (to the account and its plugins) contracts and addresses\n// through `executeFromPluginExternal`\nstruct PermittedExternalCall {\n bool addressPermitted;\n // either anySelector or selectors permitted\n bool anySelector;\n mapping(bytes4 => bool) selectors;\n}\n\nstruct PostExecHookToRun {\n bytes preExecHookReturnData;\n FunctionReference postExecHook;\n}\n\n// plugin detail stored in wallet storage\nstruct PluginDetail {\n // permitted to call any external contracts and selectors\n bool anyExternalAddressPermitted;\n // boolean to indicate if the plugin can spend native tokens, if any of the execution function can spend\n // native tokens, a plugin is considered to be able to spend native tokens of the accounts\n bool canSpendNativeToken;\n // tracks the count this plugin has been used as a dependency function\n uint256 dependentCounter;\n bytes32 manifestHash;\n Bytes21DLL dependencies;\n}\n\n// execution detail associated with selector\nstruct ExecutionDetail {\n address plugin; // plugin address that implements the execution function, for native functions, the value should be\n // address(0)\n FunctionReference userOpValidationFunction;\n RepeatableBytes21DLL preUserOpValidationHooks;\n FunctionReference runtimeValidationFunction;\n RepeatableBytes21DLL preRuntimeValidationHooks;\n HookGroup executionHooks;\n}\n"},"src/msca/6900/v0.7/interfaces/IPlugin.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\nimport {PluginManifest, PluginMetadata} from \"../common/PluginManifest.sol\";\nimport {UserOperation} from \"@account-abstraction/contracts/interfaces/UserOperation.sol\";\n\n/**\n * @dev Implements https://eips.ethereum.org/EIPS/eip-6900. Plugins must implement this interface to support plugin\n * management and interactions with MSCAs.\n */\ninterface IPlugin {\n /// @notice Initialize plugin data for the modular account.\n /// @dev Called by the modular account during `installPlugin`.\n /// @param data Optional bytes array to be decoded and used by the plugin to setup initial plugin data for the\n /// modular account.\n function onInstall(bytes calldata data) external;\n\n /// @notice Clear plugin data for the modular account.\n /// @dev Called by the modular account during `uninstallPlugin`.\n /// @param data Optional bytes array to be decoded and used by the plugin to clear plugin data for the modular\n /// account.\n function onUninstall(bytes calldata data) external;\n\n /// @notice Run the pre user operation validation hook specified by the `functionId`.\n /// @dev Pre user operation validation hooks MUST NOT return an authorizer value other than 0 or 1.\n /// @param functionId An identifier that routes the call to different internal implementations, should there be more\n /// than one.\n /// @param userOp The user operation.\n /// @param userOpHash The user operation hash.\n /// @return Packed validation data for validAfter (6 bytes), validUntil (6 bytes), and authorizer (20 bytes).\n function preUserOpValidationHook(uint8 functionId, UserOperation calldata userOp, bytes32 userOpHash)\n external\n returns (uint256);\n\n /// @notice Run the user operation validationFunction specified by the `functionId`.\n /// @param functionId An identifier that routes the call to different internal implementations, should there be\n /// more than one.\n /// @param userOp The user operation.\n /// @param userOpHash The user operation hash.\n /// @return Packed validation data for validAfter (6 bytes), validUntil (6 bytes), and authorizer (20 bytes).\n function userOpValidationFunction(uint8 functionId, UserOperation calldata userOp, bytes32 userOpHash)\n external\n returns (uint256);\n\n /// @notice Run the pre runtime validation hook specified by the `functionId`.\n /// @dev To indicate the entire call should revert, the function MUST revert.\n /// @param functionId An identifier that routes the call to different internal implementations, should there be more\n /// than one.\n /// @param sender The caller address.\n /// @param value The call value.\n /// @param data The calldata sent.\n function preRuntimeValidationHook(uint8 functionId, address sender, uint256 value, bytes calldata data) external;\n\n /// @notice Run the runtime validationFunction specified by the `functionId`.\n /// @dev To indicate the entire call should revert, the function MUST revert.\n /// @param functionId An identifier that routes the call to different internal implementations, should there be\n /// more than one.\n /// @param sender The caller address.\n /// @param value The call value.\n /// @param data The calldata sent.\n function runtimeValidationFunction(uint8 functionId, address sender, uint256 value, bytes calldata data) external;\n\n /// @notice Run the pre execution hook specified by the `functionId`.\n /// @dev To indicate the entire call should revert, the function MUST revert.\n /// @param functionId An identifier that routes the call to different internal implementations, should there be more\n /// than one.\n /// @param sender The caller address.\n /// @param value The call value.\n /// @param data The calldata sent.\n /// @return context Context to pass to a post execution hook, if present. An empty bytes array MAY be returned.\n function preExecutionHook(uint8 functionId, address sender, uint256 value, bytes calldata data)\n external\n returns (bytes memory context);\n\n /// @notice Run the post execution hook specified by the `functionId`.\n /// @dev To indicate the entire call should revert, the function MUST revert.\n /// @param functionId An identifier that routes the call to different internal implementations, should there be more\n /// than one.\n /// @param preExecHookData The context returned by its associated pre execution hook.\n function postExecutionHook(uint8 functionId, bytes calldata preExecHookData) external;\n\n /// @notice Describe the contents and intended configuration of the plugin.\n /// @dev This manifest MUST stay constant over time.\n /// @return A manifest describing the contents and intended configuration of the plugin.\n function pluginManifest() external pure returns (PluginManifest memory);\n\n /// @notice Describe the metadata of the plugin.\n /// @dev This metadata MUST stay constant over time.\n /// @return A metadata struct describing the plugin.\n function pluginMetadata() external pure returns (PluginMetadata memory);\n}\n"},"src/msca/6900/v0.7/libs/FunctionReferenceLib.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\nimport {FunctionReference} from \"../common/Structs.sol\";\n\nlibrary FunctionReferenceLib {\n function unpack(bytes21 frBytes) internal pure returns (FunctionReference memory) {\n return FunctionReference(address(bytes20(frBytes)), uint8(bytes1(frBytes << 160)));\n }\n\n function pack(FunctionReference memory functionReference) internal pure returns (bytes21) {\n return (bytes21(bytes20(functionReference.plugin)) | bytes21(uint168(functionReference.functionId)));\n }\n}\n"},"src/msca/6900/v0.7/libs/RepeatableFunctionReferenceDLLLib.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\nimport {SENTINEL_BYTES21} from \"../../../../common/Constants.sol\";\nimport {InvalidFunctionReference, InvalidLimit, ItemDoesNotExist} from \"../../shared/common/Errors.sol\";\nimport {FunctionReference, RepeatableBytes21DLL} from \"../common/Structs.sol\";\nimport {FunctionReferenceLib} from \"./FunctionReferenceLib.sol\";\n\n/**\n * @dev Enumerable & ordered doubly linked list built using RepeatableBytes21DLL.\n * Item is expected to be have a counter that tracks repeated number.\n */\nlibrary RepeatableFunctionReferenceDLLLib {\n using FunctionReferenceLib for FunctionReference;\n using FunctionReferenceLib for bytes21;\n\n modifier validFunctionReference(FunctionReference memory fr) {\n if (fr.pack() <= SENTINEL_BYTES21) {\n revert InvalidFunctionReference();\n }\n _;\n }\n\n /**\n * @dev Check the counter of an item. O(1).\n * @return the counter\n */\n function getRepeatedCount(RepeatableBytes21DLL storage dll, FunctionReference memory fr)\n internal\n view\n returns (uint256)\n {\n bytes21 item = fr.pack();\n if (item == SENTINEL_BYTES21) {\n // sentinel should not considered as the value of the list\n return 0;\n }\n return dll.counter[item];\n }\n\n /**\n * @dev Get the total items of dll. O(1).\n */\n function getTotalItems(RepeatableBytes21DLL storage dll) internal view returns (uint256) {\n return dll.totalItems;\n }\n\n /**\n * @dev Get the unique items of dll. O(1).\n */\n function getUniqueItems(RepeatableBytes21DLL storage dll) internal view returns (uint256) {\n return dll.uniqueItems;\n }\n\n /**\n * @dev Add an new item. O(1).\n */\n function append(RepeatableBytes21DLL storage dll, FunctionReference memory fr)\n internal\n validFunctionReference(fr)\n returns (uint256)\n {\n bytes21 item = fr.pack();\n uint256 currentCount = getRepeatedCount(dll, fr);\n if (currentCount == 0) {\n bytes21 prev = getTailWithoutUnpack(dll);\n bytes21 next = SENTINEL_BYTES21;\n // prev.next = item\n dll.next[prev] = item;\n // item.next = next\n dll.next[item] = next;\n // next.prev = item\n dll.prev[next] = item;\n // item.prev = prev\n dll.prev[item] = prev;\n dll.uniqueItems++;\n }\n dll.counter[item]++;\n dll.totalItems++;\n return dll.counter[item];\n }\n\n /**\n * @dev Remove or decrease the counter of already existing item. Otherwise the function reverts. O(1).\n */\n function remove(RepeatableBytes21DLL storage dll, FunctionReference memory fr)\n internal\n validFunctionReference(fr)\n returns (uint256)\n {\n uint256 currentCount = getRepeatedCount(dll, fr);\n if (currentCount == 0) {\n revert ItemDoesNotExist();\n }\n bytes21 item = fr.pack();\n if (currentCount == 1) {\n // delete the item\n // item.prev.next = item.next\n dll.next[dll.prev[item]] = dll.next[item];\n // item.next.prev = item.prev\n dll.prev[dll.next[item]] = dll.prev[item];\n delete dll.next[item];\n delete dll.prev[item];\n delete dll.counter[item];\n dll.uniqueItems--;\n } else {\n dll.counter[item]--;\n }\n dll.totalItems--;\n return dll.counter[item];\n }\n\n /**\n * @dev Remove all copies of already existing items. O(1).\n */\n function removeAllRepeated(RepeatableBytes21DLL storage dll, FunctionReference memory fr)\n internal\n validFunctionReference(fr)\n returns (bool)\n {\n uint256 currentCount = getRepeatedCount(dll, fr);\n if (currentCount == 0) {\n revert ItemDoesNotExist();\n }\n bytes21 item = fr.pack();\n // item.prev.next = item.next\n dll.next[dll.prev[item]] = dll.next[item];\n // item.next.prev = item.prev\n dll.prev[dll.next[item]] = dll.prev[item];\n delete dll.next[item];\n delete dll.prev[item];\n delete dll.counter[item];\n dll.uniqueItems--;\n dll.totalItems -= currentCount;\n return true;\n }\n\n /**\n * @dev Return paginated results and next pointer without counter information. O(n).\n * In order to get counter information (which our current use case does not need), please call\n * getRepeatedCount.\n * @param startFR Starting item, inclusive, if start == bytes21(0), this method searches from the head.\n */\n function getPaginated(RepeatableBytes21DLL storage dll, FunctionReference memory startFR, uint256 limit)\n internal\n view\n returns (FunctionReference[] memory, FunctionReference memory)\n {\n if (limit == 0) {\n revert InvalidLimit();\n }\n bytes21 start = startFR.pack();\n FunctionReference[] memory results = new FunctionReference[](limit);\n bytes21 current = start;\n if (start == SENTINEL_BYTES21) {\n current = getHeadWithoutUnpack(dll);\n }\n uint256 count = 0;\n for (; count < limit && current > SENTINEL_BYTES21; ++count) {\n results[count] = current.unpack();\n current = dll.next[current];\n }\n // solhint-disable-next-line no-inline-assembly\n assembly (\"memory-safe\") {\n mstore(results, count)\n }\n return (results, current.unpack());\n }\n\n /**\n * @dev Return all the unique items without counter information. O(n).\n * In order to get counter information (which our current use case does not need), please call\n * getRepeatedCount.\n */\n function getAll(RepeatableBytes21DLL storage dll) internal view returns (FunctionReference[] memory results) {\n uint256 totalUniqueCount = getUniqueItems(dll);\n results = new FunctionReference[](totalUniqueCount);\n bytes21 current = getHeadWithoutUnpack(dll);\n uint256 count = 0;\n for (; count < totalUniqueCount && current > SENTINEL_BYTES21; ++count) {\n results[count] = current.unpack();\n current = dll.next[current];\n }\n return results;\n }\n\n function getHead(RepeatableBytes21DLL storage dll) internal view returns (FunctionReference memory) {\n return dll.next[SENTINEL_BYTES21].unpack();\n }\n\n function getTail(RepeatableBytes21DLL storage dll) internal view returns (FunctionReference memory) {\n return dll.prev[SENTINEL_BYTES21].unpack();\n }\n\n function getHeadWithoutUnpack(RepeatableBytes21DLL storage dll) private view returns (bytes21) {\n return dll.next[SENTINEL_BYTES21];\n }\n\n function getTailWithoutUnpack(RepeatableBytes21DLL storage dll) private view returns (bytes21) {\n return dll.prev[SENTINEL_BYTES21];\n }\n}\n"},"src/msca/6900/v0.7/libs/WalletStorageV1Lib.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\nimport {AddressDLL} from \"../../shared/common/Structs.sol\";\nimport {ExecutionDetail, PermittedExternalCall, PluginDetail} from \"../common/Structs.sol\";\n\n/// @dev The same storage will be used for v1.x.y of MSCAs.\nlibrary WalletStorageV1Lib {\n // @notice When we initially calculated the storage slot, EIP-7201 was still under active discussion,\n // so we didn’t fully adopt the storage alignment proposed by the EIP, which reduces gas costs\n // for subsequent operations, as a single cold storage access warms all 256 slots within the group.\n // To avoid introducing breaking changes and the complexity of migration, we chose not to make changes midway.\n // For v2 accounts, which will feature a different storage layout, we will adopt EIP-7201.\n // keccak256(abi.encode(uint256(keccak256(abi.encode(\"circle.msca.v1.storage\"))) - 1))\n bytes32 internal constant WALLET_STORAGE_SLOT = 0xc6a0cc20c824c4eecc4b0fbb7fb297d07492a7bd12c83d4fa4d27b4249f9bfc8;\n\n struct Layout {\n // installed plugin addresses for quick query\n AddressDLL installedPlugins;\n // installed plugin details such as manifest, dependencies\n mapping(address => PluginDetail) pluginDetails;\n // permissions for executeFromPlugin into another plugin\n // callingPluginAddress => callingExecutionSelector => permittedOrNot\n mapping(address => mapping(bytes4 => bool)) permittedPluginCalls;\n // permissions for executeFromPluginExternal into external contract\n // callingPluginAddress => targetContractAddress => permission\n mapping(address => mapping(address => PermittedExternalCall)) permittedExternalCalls;\n // list of ERC-165 interfaceIds to add to account to support introspection checks\n // interfaceId => counter\n mapping(bytes4 => uint256) supportedInterfaces;\n // find plugin or native function execution detail by selector\n mapping(bytes4 => ExecutionDetail) executionDetails;\n /// indicates that the contract has been initialized\n uint8 initialized;\n /// indicates that the contract is in the process of being initialized\n bool initializing;\n // optional fields\n address owner;\n }\n\n /**\n * @dev Function to read structured wallet storage.\n */\n function getLayout() internal pure returns (Layout storage walletStorage) {\n // solhint-disable-next-line no-inline-assembly\n assembly (\"memory-safe\") {\n walletStorage.slot := WALLET_STORAGE_SLOT\n }\n }\n}\n"},"src/msca/6900/v0.7/account/BaseMSCA.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\nimport {\n EMPTY_FUNCTION_REFERENCE,\n SENTINEL_BYTES21,\n WALLET_AUTHOR,\n WALLET_VERSION_1\n} from \"../../../../common/Constants.sol\";\n\nimport {UnauthorizedCaller} from \"../../../../common/Errors.sol\";\nimport {ExecutionUtils} from \"../../../../utils/ExecutionUtils.sol\";\nimport {\n InvalidAuthorizer,\n InvalidExecutionFunction,\n InvalidValidationFunctionId,\n NotFoundSelector\n} from \"../../shared/common/Errors.sol\";\nimport {AddressDLL, ValidationData} from \"../../shared/common/Structs.sol\";\nimport {AddressDLLLib} from \"../../shared/libs/AddressDLLLib.sol\";\nimport {ValidationDataLib} from \"../../shared/libs/ValidationDataLib.sol\";\nimport {\n PRE_HOOK_ALWAYS_DENY_FUNCTION_REFERENCE,\n RUNTIME_VALIDATION_ALWAYS_ALLOW_FUNCTION_REFERENCE\n} from \"../common/Constants.sol\";\nimport {\n Call,\n ExecutionDetail,\n ExecutionFunctionConfig,\n ExecutionHooks,\n FunctionReference,\n HookGroup,\n PostExecHookToRun,\n RepeatableBytes21DLL\n} from \"../common/Structs.sol\";\nimport {IAccountLoupe} from \"../interfaces/IAccountLoupe.sol\";\nimport {IPlugin} from \"../interfaces/IPlugin.sol\";\nimport {IPluginExecutor} from \"../interfaces/IPluginExecutor.sol\";\nimport {IPluginManager} from \"../interfaces/IPluginManager.sol\";\nimport {IStandardExecutor} from \"../interfaces/IStandardExecutor.sol\";\nimport {ExecutionHookLib} from \"../libs/ExecutionHookLib.sol\";\nimport {FunctionReferenceLib} from \"../libs/FunctionReferenceLib.sol\";\nimport {RepeatableFunctionReferenceDLLLib} from \"../libs/RepeatableFunctionReferenceDLLLib.sol\";\n\nimport {SelectorRegistryLib} from \"../libs/SelectorRegistryLib.sol\";\nimport {WalletStorageV1Lib} from \"../libs/WalletStorageV1Lib.sol\";\nimport {PluginExecutor} from \"../managers/PluginExecutor.sol\";\nimport {PluginManager} from \"../managers/PluginManager.sol\";\nimport {StandardExecutor} from \"../managers/StandardExecutor.sol\";\n\nimport {WalletStorageInitializable} from \"./WalletStorageInitializable.sol\";\nimport {IEntryPoint} from \"@account-abstraction/contracts/interfaces/IEntryPoint.sol\";\nimport {UserOperation} from \"@account-abstraction/contracts/interfaces/UserOperation.sol\";\nimport {IERC165} from \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\n\n/**\n * @dev Base MSCA implementation with **authentication**.\n * This contract provides the basic logic for implementing the MSCA interfaces;\n * specific account implementation should inherit this contract.\n */\nabstract contract BaseMSCA is\n WalletStorageInitializable,\n IPluginManager,\n IAccountLoupe,\n IStandardExecutor,\n IPluginExecutor,\n IERC165\n{\n using RepeatableFunctionReferenceDLLLib for RepeatableBytes21DLL;\n using FunctionReferenceLib for bytes21;\n using FunctionReferenceLib for FunctionReference;\n using ExecutionHookLib for HookGroup;\n using ExecutionHookLib for PostExecHookToRun[];\n using ExecutionUtils for address;\n using PluginExecutor for bytes;\n using StandardExecutor for address;\n using StandardExecutor for Call[];\n using AddressDLLLib for AddressDLL;\n using ValidationDataLib for ValidationData;\n using SelectorRegistryLib for bytes4;\n\n string public constant AUTHOR = WALLET_AUTHOR;\n string public constant VERSION = WALLET_VERSION_1;\n // 4337 related immutable storage\n IEntryPoint public immutable ENTRY_POINT;\n PluginManager public immutable PLUGIN_MANAGER;\n\n error NotNativeFunctionSelector(bytes4 selector);\n error InvalidHookFunctionId(uint8 functionId);\n error PreRuntimeValidationHookFailed(address plugin, uint8 functionId, bytes revertReason);\n error RuntimeValidationFailed(address plugin, uint8 functionId, bytes revertReason);\n\n /**\n * @dev Wraps execution of a native function (as opposed to a function added by plugins) with runtime validations\n * (not from EP)\n * and hooks. Used by execute, executeBatch, installPlugin, uninstallPlugin, upgradeTo and upgradeToAndCall.\n * If the call is from entry point, then validateUserOp will run.\n * https://eips.ethereum.org/assets/eip-6900/Modular_Account_Call_Flow.svg\n */\n modifier validateNativeFunction() {\n PostExecHookToRun[] memory postExecHooks = _processPreExecHooks();\n _;\n postExecHooks._processPostExecHooks();\n }\n\n /**\n * @dev This function allows entry point or SA itself to execute certain actions.\n * If the caller is not authorized, the function will revert with an error message.\n */\n modifier onlyFromEntryPointOrSelf() {\n _checkAccessRuleFromEPOrAcctItself();\n _;\n }\n\n constructor(IEntryPoint _newEntryPoint, PluginManager _newPluginManager) {\n ENTRY_POINT = _newEntryPoint;\n PLUGIN_MANAGER = _newPluginManager;\n // lock the implementation contract so it can only be called from proxies\n _disableWalletStorageInitializers();\n }\n\n receive() external payable {}\n\n /// @notice Manage fallback calls made to the plugins.\n /// @dev Route calls to execution functions based on incoming msg.sig\n /// If there's no plugin associated with this function selector, revert\n // solhint-disable-next-line no-complex-fallback\n fallback(bytes calldata) external payable returns (bytes memory result) {\n if (msg.data.length < 4) {\n revert NotFoundSelector();\n }\n // run runtime validation before we load the executionDetail because validation may update account state\n if (msg.sender != address(ENTRY_POINT)) {\n // ENTRY_POINT should go through validateUserOp flow which calls userOpValidationFunction\n _processPreRuntimeHooksAndValidation(msg.sig);\n }\n // load the executionDetail before we run the preExecHooks because they may modify the plugins\n ExecutionDetail storage executionDetail = WalletStorageV1Lib.getLayout().executionDetails[msg.sig];\n address executionFunctionPlugin = executionDetail.plugin;\n // valid plugin address should not be 0\n if (executionFunctionPlugin == address(0)) {\n revert InvalidExecutionFunction(msg.sig);\n }\n PostExecHookToRun[] memory postExecHooks = executionDetail.executionHooks._processPreExecHooks(msg.data);\n result = ExecutionUtils.callWithReturnDataOrRevert(executionFunctionPlugin, msg.value, msg.data);\n postExecHooks._processPostExecHooks();\n return result;\n }\n\n /**\n * @dev Return the ENTRY_POINT used by this account.\n * subclass should return the current ENTRY_POINT used by this account.\n */\n function getEntryPoint() external view returns (IEntryPoint) {\n return ENTRY_POINT;\n }\n\n /**\n * @dev Validate user's signature and nonce.\n * subclass doesn't need to override this method. Instead, it should override the specific internal validation\n * methods.\n */\n function validateUserOp(UserOperation calldata userOp, bytes32 userOpHash, uint256 missingAccountFunds)\n external\n virtual\n returns (uint256 validationData)\n {\n if (msg.sender != address(ENTRY_POINT)) {\n revert UnauthorizedCaller();\n }\n validationData = _authenticateAndAuthorizeUserOp(userOp, userOpHash);\n if (missingAccountFunds != 0) {\n (bool success,) = payable(msg.sender).call{value: missingAccountFunds, gas: type(uint256).max}(\"\");\n (success);\n // ignore failure (its EntryPoint's job to verify, not account.)\n }\n }\n\n /// @notice ERC165 introspection https://eips.ethereum.org/EIPS/eip-165\n /// @dev returns true for `IERC165.interfaceId` and false for `0xFFFFFFFF`\n /// @param interfaceId interface id to check against\n /// @return bool support for specific interface\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n if (interfaceId == 0xffffffff) {\n return false;\n }\n if (interfaceId == type(IERC165).interfaceId) {\n return true;\n }\n return WalletStorageV1Lib.getLayout().supportedInterfaces[interfaceId] > 0;\n }\n\n /**\n * @dev 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 ENTRY_POINT.getNonce(address(this), 0);\n }\n\n function installPlugin(\n address plugin,\n bytes32 manifestHash,\n bytes memory pluginInstallData,\n FunctionReference[] memory dependencies\n ) external override validateNativeFunction {\n bytes memory data = abi.encodeCall(\n PluginManager.install, (plugin, manifestHash, pluginInstallData, dependencies, address(this))\n );\n address(PLUGIN_MANAGER).delegateCall(data);\n emit PluginInstalled(plugin, manifestHash, dependencies);\n }\n\n function uninstallPlugin(address plugin, bytes memory config, bytes memory pluginUninstallData)\n external\n override\n validateNativeFunction\n {\n bytes memory data = abi.encodeCall(PluginManager.uninstall, (plugin, config, pluginUninstallData));\n address(PLUGIN_MANAGER).delegateCall(data);\n emit PluginUninstalled(plugin, true);\n }\n\n function execute(address target, uint256 value, bytes calldata data)\n external\n payable\n override\n validateNativeFunction\n returns (bytes memory returnData)\n {\n return target.execute(value, data);\n }\n\n function executeBatch(Call[] calldata calls)\n external\n payable\n override\n validateNativeFunction\n returns (bytes[] memory returnData)\n {\n return calls.executeBatch();\n }\n\n function executeFromPlugin(bytes calldata data) external payable override returns (bytes memory) {\n return data.executeFromPlugin();\n }\n\n function executeFromPluginExternal(address target, uint256 value, bytes calldata data)\n external\n payable\n override\n returns (bytes memory)\n {\n return data.executeFromPluginToExternal(target, value);\n }\n\n /// @notice Gets the validation functions and plugin address for a selector\n /// @dev If the selector is a native function, the plugin address will be the address of the account\n /// @param selector The selector to get the configuration for\n /// @return executionFunctionConfig The configuration for this selector\n function getExecutionFunctionConfig(bytes4 selector)\n external\n view\n returns (ExecutionFunctionConfig memory executionFunctionConfig)\n {\n WalletStorageV1Lib.Layout storage walletStorage = WalletStorageV1Lib.getLayout();\n if (selector._isNativeFunctionSelector()) {\n executionFunctionConfig.plugin = address(this);\n } else {\n executionFunctionConfig.plugin = walletStorage.executionDetails[selector].plugin;\n }\n executionFunctionConfig.userOpValidationFunction =\n walletStorage.executionDetails[selector].userOpValidationFunction;\n executionFunctionConfig.runtimeValidationFunction =\n walletStorage.executionDetails[selector].runtimeValidationFunction;\n return executionFunctionConfig;\n }\n\n /// @notice Gets the pre and post execution hooks for a selector\n /// @param selector The selector to get the hooks for\n /// @return executionHooks The pre and post execution hooks for this selector\n function getExecutionHooks(bytes4 selector) external view returns (ExecutionHooks[] memory executionHooks) {\n return WalletStorageV1Lib.getLayout().executionDetails[selector].executionHooks._getExecutionHooks();\n }\n\n /// @notice Gets the pre user op and runtime validation hooks associated with a selector\n /// @param selector The selector to get the hooks for\n /// @return preUserOpValidationHooks The pre user op validation hooks for this selector\n /// @return preRuntimeValidationHooks The pre runtime validation hooks for this selector\n function getPreValidationHooks(bytes4 selector)\n external\n view\n returns (\n FunctionReference[] memory preUserOpValidationHooks,\n FunctionReference[] memory preRuntimeValidationHooks\n )\n {\n preUserOpValidationHooks =\n WalletStorageV1Lib.getLayout().executionDetails[selector].preUserOpValidationHooks.getAll();\n preRuntimeValidationHooks =\n WalletStorageV1Lib.getLayout().executionDetails[selector].preRuntimeValidationHooks.getAll();\n return (preUserOpValidationHooks, preRuntimeValidationHooks);\n }\n\n /// @notice Gets an array of all installed plugins\n /// @return pluginAddresses The addresses of all installed plugins\n function getInstalledPlugins() external view returns (address[] memory pluginAddresses) {\n return WalletStorageV1Lib.getLayout().installedPlugins.getAll();\n }\n\n /**\n * Check current account deposit in the ENTRY_POINT.\n */\n function getDeposit() public view returns (uint256) {\n return ENTRY_POINT.balanceOf(address(this));\n }\n\n /**\n * Deposit more funds for this account in the ENTRY_POINT.\n */\n function addDeposit() public payable {\n ENTRY_POINT.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(address payable withdrawAddress, uint256 amount) public onlyFromEntryPointOrSelf {\n ENTRY_POINT.withdrawTo(withdrawAddress, amount);\n }\n\n /**\n * @dev Authenticate and authorize this userOp. OnlyFromEntryPoint is applied in the caller.\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> 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 the account doesn't use time-range, it is enough to return SIG_VALIDATION_FAILED value (1) for signature\n * failure.\n * Note that the validation code cannot use block.timestamp (or block.number) directly due to the storage rule.\n */\n function _authenticateAndAuthorizeUserOp(UserOperation calldata userOp, bytes32 userOpHash)\n internal\n virtual\n returns (uint256 validationData)\n {\n // onlyFromEntryPoint is applied in the caller\n // if there is no function defined for the selector, or if userOp.callData.length < 4, then execution MUST\n // revert\n if (userOp.callData.length < 4) {\n revert NotFoundSelector();\n }\n bytes4 selector = bytes4(userOp.callData[0:4]);\n if (selector == bytes4(0)) {\n revert NotFoundSelector();\n }\n ExecutionDetail storage executionDetail = WalletStorageV1Lib.getLayout().executionDetails[selector];\n FunctionReference memory validationFunction = executionDetail.userOpValidationFunction;\n bytes21 packedValidationFunction = validationFunction.pack();\n if (\n packedValidationFunction == EMPTY_FUNCTION_REFERENCE\n || packedValidationFunction == RUNTIME_VALIDATION_ALWAYS_ALLOW_FUNCTION_REFERENCE\n || packedValidationFunction == PRE_HOOK_ALWAYS_DENY_FUNCTION_REFERENCE\n ) {\n revert InvalidValidationFunctionId(validationFunction.functionId);\n }\n // pre hook\n ValidationData memory unpackedValidationData =\n _processPreUserOpValidationHooks(executionDetail, userOp, userOpHash);\n IPlugin userOpValidatorPlugin = IPlugin(validationFunction.plugin);\n // execute the validation function with the user operation and its hash as parameters using the call opcode\n uint256 currentValidationData = userOpValidatorPlugin.userOpValidationFunction(\n executionDetail.userOpValidationFunction.functionId, userOp, userOpHash\n );\n // intercept with validation function call\n unpackedValidationData = unpackedValidationData._intersectValidationData(currentValidationData);\n if (unpackedValidationData.authorizer != address(0) && unpackedValidationData.authorizer != address(1)) {\n // only revert on unexpected values\n revert InvalidAuthorizer();\n }\n validationData = unpackedValidationData._packValidationData();\n }\n\n /**\n * @dev Default validation logic is from installed plugins. However, you can override this validation logic in MSCA\n * implementations. For instance, semi MSCA such as single owner semi MSCA may want to honor the validation\n * from native owner.\n */\n function _processPreRuntimeHooksAndValidation(bytes4 selector) internal virtual {\n FunctionReference memory validationFunction =\n WalletStorageV1Lib.getLayout().executionDetails[selector].runtimeValidationFunction;\n bytes21 packedValidationFunction = validationFunction.pack();\n if (\n packedValidationFunction == EMPTY_FUNCTION_REFERENCE\n || packedValidationFunction == PRE_HOOK_ALWAYS_DENY_FUNCTION_REFERENCE\n ) {\n revert InvalidValidationFunctionId(validationFunction.functionId);\n }\n RepeatableBytes21DLL storage preRuntimeValidationHooksDLL =\n WalletStorageV1Lib.getLayout().executionDetails[selector].preRuntimeValidationHooks;\n uint256 totalUniqueHookCount = preRuntimeValidationHooksDLL.getUniqueItems();\n FunctionReference memory startHook = EMPTY_FUNCTION_REFERENCE.unpack();\n FunctionReference[] memory preRuntimeValidationHooks;\n FunctionReference memory nextHook;\n for (uint256 i = 0; i < totalUniqueHookCount; ++i) {\n (preRuntimeValidationHooks, nextHook) = preRuntimeValidationHooksDLL.getPaginated(startHook, 10);\n for (uint256 j = 0; j < preRuntimeValidationHooks.length; ++j) {\n // revert on EMPTY_FUNCTION_REFERENCE, RUNTIME_VALIDATION_ALWAYS_ALLOW_FUNCTION_REFERENCE,\n // PRE_HOOK_ALWAYS_DENY_FUNCTION_REFERENCE\n // if any revert, the outer call MUST revert\n bytes21 packedPreRuntimeValidationHook = preRuntimeValidationHooks[j].pack();\n if (\n packedPreRuntimeValidationHook == EMPTY_FUNCTION_REFERENCE\n || packedPreRuntimeValidationHook == RUNTIME_VALIDATION_ALWAYS_ALLOW_FUNCTION_REFERENCE\n || packedPreRuntimeValidationHook == PRE_HOOK_ALWAYS_DENY_FUNCTION_REFERENCE\n ) {\n revert InvalidValidationFunctionId(preRuntimeValidationHooks[j].functionId);\n }\n IPlugin preRuntimeValidationHookPlugin = IPlugin(preRuntimeValidationHooks[j].plugin);\n // solhint-disable no-empty-blocks\n try preRuntimeValidationHookPlugin.preRuntimeValidationHook(\n preRuntimeValidationHooks[j].functionId, msg.sender, msg.value, msg.data\n ) {} catch (bytes memory revertReason) {\n revert PreRuntimeValidationHookFailed(\n preRuntimeValidationHooks[j].plugin, preRuntimeValidationHooks[j].functionId, revertReason\n );\n }\n // solhint-enable no-empty-blocks\n }\n if (nextHook.pack() == SENTINEL_BYTES21) {\n break;\n }\n startHook = nextHook;\n }\n // call runtimeValidationFunction if it's not always allowed\n if (packedValidationFunction != RUNTIME_VALIDATION_ALWAYS_ALLOW_FUNCTION_REFERENCE) {\n // solhint-disable no-empty-blocks\n try IPlugin(validationFunction.plugin).runtimeValidationFunction(\n validationFunction.functionId, msg.sender, msg.value, msg.data\n ) {} catch (bytes memory revertReason) {\n revert RuntimeValidationFailed(validationFunction.plugin, validationFunction.functionId, revertReason);\n }\n // solhint-enable no-empty-blocks\n }\n }\n\n /// @dev Also runs runtime hooks and validation if msg.sender is not from entry point.\n function _processPreExecHooks() internal returns (PostExecHookToRun[] memory) {\n if (!msg.sig._isNativeFunctionSelector()) {\n revert NotNativeFunctionSelector(msg.sig);\n }\n if (msg.sender != address(ENTRY_POINT)) {\n // ENTRY_POINT should go through validateUserOp flow which calls userOpValidationFunction\n _processPreRuntimeHooksAndValidation(msg.sig);\n }\n return WalletStorageV1Lib.getLayout().executionDetails[msg.sig].executionHooks._processPreExecHooks(msg.data);\n }\n\n function _processPreUserOpValidationHooks(\n ExecutionDetail storage executionDetail,\n UserOperation calldata userOp,\n bytes32 userOpHash\n ) internal virtual returns (ValidationData memory unpackedValidationData) {\n unpackedValidationData = ValidationData(0, 0xFFFFFFFFFFFF, address(0));\n // if the function selector has associated pre user operation validation hooks, then those hooks MUST be run\n // sequentially\n uint256 totalUniqueHookCount = executionDetail.preUserOpValidationHooks.getUniqueItems();\n FunctionReference memory startHook = EMPTY_FUNCTION_REFERENCE.unpack();\n FunctionReference[] memory preUserOpValidatorHooks;\n FunctionReference memory nextHook;\n uint256 currentValidationData;\n for (uint256 i = 0; i < totalUniqueHookCount; ++i) {\n (preUserOpValidatorHooks, nextHook) = executionDetail.preUserOpValidationHooks.getPaginated(startHook, 10);\n for (uint256 j = 0; j < preUserOpValidatorHooks.length; ++j) {\n bytes21 packedUserOpValidatorHook = preUserOpValidatorHooks[j].pack();\n // if any revert, the outer call MUST revert\n if (\n packedUserOpValidatorHook == EMPTY_FUNCTION_REFERENCE\n || packedUserOpValidatorHook == RUNTIME_VALIDATION_ALWAYS_ALLOW_FUNCTION_REFERENCE\n || packedUserOpValidatorHook == PRE_HOOK_ALWAYS_DENY_FUNCTION_REFERENCE\n ) {\n revert InvalidHookFunctionId(preUserOpValidatorHooks[j].functionId);\n }\n IPlugin preUserOpValidationHookPlugin = IPlugin(preUserOpValidatorHooks[j].plugin);\n currentValidationData = preUserOpValidationHookPlugin.preUserOpValidationHook(\n preUserOpValidatorHooks[j].functionId, userOp, userOpHash\n );\n unpackedValidationData = unpackedValidationData._intersectValidationData(currentValidationData);\n // if any return an authorizer value other than 0 or 1, execution MUST revert\n if (unpackedValidationData.authorizer != address(0) && unpackedValidationData.authorizer != address(1))\n {\n revert InvalidAuthorizer();\n }\n }\n if (nextHook.pack() == SENTINEL_BYTES21) {\n break;\n }\n startHook = nextHook;\n }\n return unpackedValidationData;\n }\n\n function _checkAccessRuleFromEPOrAcctItself() internal view {\n if (msg.sender != address(ENTRY_POINT) && msg.sender != address(this)) {\n revert UnauthorizedCaller();\n }\n }\n}\n"},"lib/account-abstraction/contracts/interfaces/UserOperation.sol":{"content":"// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.12;\n\n/* solhint-disable no-inline-assembly */\n\nimport {calldataKeccak} from \"../core/Helpers.sol\";\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 callGasLimit the gas limit passed to the callData method call.\n * @param verificationGasLimit gas used for validateUserOp and validatePaymasterUserOp.\n * @param preVerificationGas gas not calculated by the handleOps method, but added to the gas paid. Covers batch overhead.\n * @param maxFeePerGas same as EIP-1559 gas parameter.\n * @param maxPriorityFeePerGas same as EIP-1559 gas parameter.\n * @param paymasterAndData if set, this field holds the paymaster address and paymaster-specific data. 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 */\n struct UserOperation {\n\n address sender;\n uint256 nonce;\n bytes initCode;\n bytes callData;\n uint256 callGasLimit;\n uint256 verificationGasLimit;\n uint256 preVerificationGas;\n uint256 maxFeePerGas;\n uint256 maxPriorityFeePerGas;\n bytes paymasterAndData;\n bytes signature;\n }\n\n/**\n * Utility functions helpful when working with UserOperation structs.\n */\nlibrary UserOperationLib {\n\n function getSender(UserOperation calldata userOp) internal pure returns (address) {\n address data;\n //read sender from userOp, which is first userOp member (saves 800 gas...)\n assembly {data := calldataload(userOp)}\n return address(uint160(data));\n }\n\n //relayer/block builder might submit the TX with higher priorityFee, but the user should not\n // pay above what he signed for.\n function gasPrice(UserOperation calldata userOp) internal view returns (uint256) {\n unchecked {\n uint256 maxFeePerGas = userOp.maxFeePerGas;\n uint256 maxPriorityFeePerGas = userOp.maxPriorityFeePerGas;\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 function pack(UserOperation calldata userOp) 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 uint256 callGasLimit = userOp.callGasLimit;\n uint256 verificationGasLimit = userOp.verificationGasLimit;\n uint256 preVerificationGas = userOp.preVerificationGas;\n uint256 maxFeePerGas = userOp.maxFeePerGas;\n uint256 maxPriorityFeePerGas = userOp.maxPriorityFeePerGas;\n bytes32 hashPaymasterAndData = calldataKeccak(userOp.paymasterAndData);\n\n return abi.encode(\n sender, nonce,\n hashInitCode, hashCallData,\n callGasLimit, verificationGasLimit, preVerificationGas,\n maxFeePerGas, maxPriorityFeePerGas,\n hashPaymasterAndData\n );\n }\n\n function hash(UserOperation calldata userOp) internal pure returns (bytes32) {\n return keccak256(pack(userOp));\n }\n\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n}\n"},"node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/UUPSUpgradeable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../interfaces/draft-IERC1822Upgradeable.sol\";\nimport \"../ERC1967/ERC1967UpgradeUpgradeable.sol\";\nimport {Initializable} from \"./Initializable.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 *\n * _Available since v4.1._\n */\nabstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable {\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment\n address private immutable __self = address(this);\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 require(address(this) != __self, \"Function must be called through delegatecall\");\n require(_getImplementation() == __self, \"Function must be called through active proxy\");\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 require(address(this) == __self, \"UUPSUpgradeable: must not be called through delegatecall\");\n _;\n }\n\n function __UUPSUpgradeable_init() internal onlyInitializing {\n }\n\n function __UUPSUpgradeable_init_unchained() internal onlyInitializing {\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 override notDelegated returns (bytes32) {\n return _IMPLEMENTATION_SLOT;\n }\n\n /**\n * @dev Upgrade the implementation of the proxy to `newImplementation`.\n *\n * Calls {_authorizeUpgrade}.\n *\n * Emits an {Upgraded} event.\n *\n * @custom:oz-upgrades-unsafe-allow-reachable delegatecall\n */\n function upgradeTo(address newImplementation) public virtual onlyProxy {\n _authorizeUpgrade(newImplementation);\n _upgradeToAndCallUUPS(newImplementation, new bytes(0), false);\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, true);\n }\n\n /**\n * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by\n * {upgradeTo} and {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 override onlyOwner {}\n * ```\n */\n function _authorizeUpgrade(address newImplementation) internal virtual;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n"},"node_modules/@openzeppelin/contracts/interfaces/IERC1271.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC1271.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC1271 standard signature validation method for\n * contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271].\n *\n * _Available since v4.1._\n */\ninterface IERC1271 {\n /**\n * @dev Should return whether the signature provided is valid for the provided data\n * @param hash Hash of the data to be signed\n * @param signature Signature byte array associated with _data\n */\n function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue);\n}\n"},"node_modules/@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev _Available since v3.1._\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"},"node_modules/@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\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 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"},"node_modules/@openzeppelin/contracts/utils/cryptography/ECDSA.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Strings.sol\";\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 InvalidSignatureV // Deprecated in v4.8\n }\n\n function _throwError(RecoverError error) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert(\"ECDSA: invalid signature\");\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert(\"ECDSA: invalid signature length\");\n } else if (error == RecoverError.InvalidSignatureS) {\n revert(\"ECDSA: invalid signature 's' value\");\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature` or error string. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode 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 {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 * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\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);\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 opcode 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 {toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, signature);\n _throwError(error);\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 * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError) {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n *\n * _Available since v4.2._\n */\n function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n _throwError(error);\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 * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address, RecoverError) {\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);\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);\n }\n\n return (signer, RecoverError.NoError);\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) = tryRecover(hash, v, r, s);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 message) {\n // 32 is the length in bytes of hash,\n // enforced by the type signature above\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x00, \"\\x19Ethereum Signed Message:\\n32\")\n mstore(0x1c, hash)\n message := keccak256(0x00, 0x3c)\n }\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from `s`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", Strings.toString(s.length), s));\n }\n\n /**\n * @dev Returns an Ethereum Signed Typed Data, created from a\n * `domainSeparator` and a `structHash`. This produces hash corresponding\n * to the one signed with the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n * JSON-RPC method as part of EIP-712.\n *\n * See {recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 data) {\n /// @solidity memory-safe-assembly\n assembly {\n let ptr := mload(0x40)\n mstore(ptr, \"\\x19\\x01\")\n mstore(add(ptr, 0x02), domainSeparator)\n mstore(add(ptr, 0x22), structHash)\n data := keccak256(ptr, 0x42)\n }\n }\n\n /**\n * @dev Returns an Ethereum Signed Data with intended validator, created from a\n * `validator` and `data` according to the version 0 of EIP-191.\n *\n * See {recover}.\n */\n function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19\\x00\", validator, data));\n }\n}\n"},"src/erc712/BaseERC712CompliantAccount.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\nimport {MessageHashUtils} from \"../libs/MessageHashUtils.sol\";\n\nabstract contract BaseERC712CompliantAccount {\n // keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\")\n bytes32 private constant _DOMAIN_SEPARATOR_TYPEHASH =\n keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\");\n\n /// @notice Wraps a replay safe hash in an EIP-712 envelope to prevent cross-account replay attacks.\n /// domainSeparator = hashStruct(eip712Domain).\n /// eip712Domain = (string name,string version,uint256 chainId,address verifyingContract)\n /// hashStruct(s) = keccak256(typeHash ‖ encodeData(s)) where typeHash = keccak256(encodeType(typeOf(s)))\n /// @param hash Message that should be hashed.\n /// @return Replay safe message hash.\n function getReplaySafeMessageHash(bytes32 hash) public view returns (bytes32) {\n return MessageHashUtils.toTypedDataHash({\n domainSeparator: keccak256(\n abi.encode(\n _DOMAIN_SEPARATOR_TYPEHASH, _getAccountName(), _getAccountVersion(), block.chainid, address(this)\n )\n ),\n structHash: keccak256(abi.encode(_getAccountTypeHash(), hash))\n });\n }\n\n /// @dev Returns the account message typehash.\n function _getAccountTypeHash() internal pure virtual returns (bytes32);\n\n /// @dev Returns the account name.\n function _getAccountName() internal pure virtual returns (bytes32);\n\n /// @dev Returns the account version.\n function _getAccountVersion() internal pure virtual returns (bytes32);\n}\n"},"node_modules/@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/SignatureChecker.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./ECDSA.sol\";\nimport \"../../interfaces/IERC1271.sol\";\n\n/**\n * @dev Signature verification helper that can be used instead of `ECDSA.recover` to seamlessly support both ECDSA\n * signatures from externally owned accounts (EOAs) as well as ERC1271 signatures from smart contract wallets like\n * Argent and Gnosis Safe.\n *\n * _Available since v4.1._\n */\nlibrary SignatureChecker {\n /**\n * @dev Checks if a signature is valid for a given signer and data hash. If the signer is a smart contract, the\n * signature is validated against that smart contract using ERC1271, otherwise it's validated using `ECDSA.recover`.\n *\n * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus\n * change through time. It could return true at block N and false at block N+1 (or the opposite).\n */\n function isValidSignatureNow(address signer, bytes32 hash, bytes memory signature) internal view returns (bool) {\n (address recovered, ECDSA.RecoverError error) = ECDSA.tryRecover(hash, signature);\n return\n (error == ECDSA.RecoverError.NoError && recovered == signer) ||\n isValidERC1271SignatureNow(signer, hash, signature);\n }\n\n /**\n * @dev Checks if a signature is valid for a given signer and data hash. The signature is validated\n * against the signer smart contract using ERC1271.\n *\n * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus\n * change through time. It could return true at block N and false at block N+1 (or the opposite).\n */\n function isValidERC1271SignatureNow(\n address signer,\n bytes32 hash,\n bytes memory signature\n ) internal view returns (bool) {\n (bool success, bytes memory result) = signer.staticcall(\n abi.encodeWithSelector(IERC1271.isValidSignature.selector, hash, signature)\n );\n return (success &&\n result.length >= 32 &&\n abi.decode(result, (bytes32)) == bytes32(IERC1271.isValidSignature.selector));\n }\n}\n"},"src/msca/6900/shared/libs/AddressDLLLib.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\nimport {InvalidLimit, ItemAlreadyExists, ItemDoesNotExist} from \"../common/Errors.sol\";\nimport {AddressDLL} from \"../common/Structs.sol\";\n\n/**\n * @dev Enumerable & ordered doubly linked list built using mapping(address => address).\n * Item is expected to be unique.\n */\nlibrary AddressDLLLib {\n address internal constant SENTINEL_ADDRESS = address(0x0);\n uint160 internal constant SENTINEL_ADDRESS_UINT = 0;\n\n event AddressAdded(address indexed addr);\n event AddressRemoved(address indexed addr);\n\n error InvalidAddress();\n\n modifier validAddress(address addr) {\n if (uint160(addr) <= SENTINEL_ADDRESS_UINT) {\n revert InvalidAddress();\n }\n _;\n }\n\n /**\n * @dev Check if an item exists or not. O(1).\n */\n function contains(AddressDLL storage dll, address item) internal view returns (bool) {\n if (item == SENTINEL_ADDRESS) {\n // SENTINEL_ADDRESS is not a valid item\n return false;\n }\n return getHead(dll) == item || dll.next[item] != SENTINEL_ADDRESS || dll.prev[item] != SENTINEL_ADDRESS;\n }\n\n /**\n * @dev Get the count of dll. O(1).\n */\n function size(AddressDLL storage dll) internal view returns (uint256) {\n return dll.count;\n }\n\n /**\n * @dev Add an new item which did not exist before. Otherwise the function reverts. O(1).\n */\n function append(AddressDLL storage dll, address item) internal validAddress(item) returns (bool) {\n if (contains(dll, item)) {\n revert ItemAlreadyExists();\n }\n address prev = getTail(dll);\n address next = SENTINEL_ADDRESS;\n // prev.next = item\n dll.next[prev] = item;\n // item.next = next\n dll.next[item] = next;\n // next.prev = item\n dll.prev[next] = item;\n // item.prev = prev\n dll.prev[item] = prev;\n dll.count++;\n emit AddressAdded(item);\n return true;\n }\n\n /**\n * @dev Remove an already existing item. Otherwise the function reverts. O(1).\n */\n function remove(AddressDLL storage dll, address item) internal validAddress(item) returns (bool) {\n if (!contains(dll, item)) {\n revert ItemDoesNotExist();\n }\n // item.prev.next = item.next\n dll.next[dll.prev[item]] = dll.next[item];\n // item.next.prev = item.prev\n dll.prev[dll.next[item]] = dll.prev[item];\n delete dll.next[item];\n delete dll.prev[item];\n dll.count--;\n emit AddressRemoved(item);\n return true;\n }\n\n /**\n * @dev Return paginated addresses and next pointer address. O(n).\n * @param start Starting address, inclusive, if start == address(0x0), this method searches from the head.\n */\n function getPaginated(AddressDLL storage dll, address start, uint256 limit)\n internal\n view\n returns (address[] memory, address)\n {\n if (limit == 0) {\n revert InvalidLimit();\n }\n address[] memory results = new address[](limit);\n address current = start;\n if (start == SENTINEL_ADDRESS) {\n current = getHead(dll);\n }\n uint256 count = 0;\n for (; count < limit && uint160(current) > SENTINEL_ADDRESS_UINT; ++count) {\n results[count] = current;\n current = dll.next[current];\n }\n\n // solhint-disable-next-line no-inline-assembly\n assembly (\"memory-safe\") {\n mstore(results, count)\n }\n return (results, current);\n }\n\n /**\n * @dev Return all the data. O(n).\n */\n function getAll(AddressDLL storage dll) internal view returns (address[] memory results) {\n uint256 totalCount = size(dll);\n results = new address[](totalCount);\n address current = getHead(dll);\n uint256 count = 0;\n for (; count < totalCount && uint160(current) > SENTINEL_ADDRESS_UINT; ++count) {\n results[count] = current;\n current = dll.next[current];\n }\n return results;\n }\n\n function getHead(AddressDLL storage dll) internal view returns (address) {\n return dll.next[SENTINEL_ADDRESS];\n }\n\n function getTail(AddressDLL storage dll) internal view returns (address) {\n return dll.prev[SENTINEL_ADDRESS];\n }\n}\n"},"src/msca/6900/v0.7/common/PluginManifest.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\n// Plugin Manifest\nenum ManifestAssociatedFunctionType {\n // Function is not defined.\n NONE,\n // Function belongs to this plugin.\n SELF,\n // Function belongs to an external plugin provided as a dependency during plugin installation.\n DEPENDENCY,\n // Resolves to a magic value to always bypass runtime validation for a given function.\n // This is only assignable on runtime validation functions. If it were to be used on a user op validation function,\n // it would risk burning gas from the account. When used as a hook in any hook location, it is equivalent to not\n // setting a hook and is therefore disallowed.\n RUNTIME_VALIDATION_ALWAYS_ALLOW,\n // Resolves to a magic value to always fail in a hook for a given function.\n // This is only assignable to pre hooks (pre validation and pre execution). It should not be used on\n // validation functions themselves, because this is equivalent to leaving the validation functions unset.\n // It should not be used in post-exec hooks, because if it is known to always revert, that should happen\n // as early as possible to save gas.\n PRE_HOOK_ALWAYS_DENY\n}\n\n/// @dev For functions of type `ManifestAssociatedFunctionType.DEPENDENCY`, the MSCA MUST find the plugin address\n/// of the function at `dependencies[dependencyIndex]` during the call to `installPlugin(config)`.\nstruct ManifestFunction {\n ManifestAssociatedFunctionType functionType;\n uint8 functionId;\n uint256 dependencyIndex;\n}\n\nstruct ManifestAssociatedFunction {\n bytes4 executionSelector;\n ManifestFunction associatedFunction;\n}\n\nstruct ManifestExecutionHook {\n bytes4 selector;\n ManifestFunction preExecHook;\n ManifestFunction postExecHook;\n}\n\nstruct ManifestExternalCallPermission {\n address externalAddress;\n bool permitAnySelector;\n bytes4[] selectors;\n}\n\nstruct SelectorPermission {\n bytes4 functionSelector;\n string permissionDescription;\n}\n\n/// @dev A struct holding fields to describe the plugin in a purely view context. Intended for front end clients.\nstruct PluginMetadata {\n // A human-readable name of the plugin.\n string name;\n // The version of the plugin, following the semantic versioning scheme.\n string version;\n // The author field SHOULD be a username representing the identity of the user or organization\n // that created this plugin.\n string author;\n // String descriptions of the relative sensitivity of specific functions. The selectors MUST be selectors for\n // functions implemented by this plugin.\n SelectorPermission[] permissionDescriptors;\n}\n\n/// @dev A struct describing how the plugin should be installed on a modular account.\nstruct PluginManifest {\n // List of ERC-165 interface IDs to add to account to support introspection checks. This MUST NOT include\n // IPlugin's interface ID.\n bytes4[] interfaceIds;\n // If this plugin depends on other plugins' validation functions, the interface IDs of those plugins MUST be\n // provided here, with its position in the array matching the `dependencyIndex` members of `ManifestFunction`\n bytes4[] dependencyInterfaceIds;\n // Execution functions defined in this plugin to be installed on the MSCA.\n bytes4[] executionFunctions;\n // Plugin execution functions already installed on the MSCA that this plugin will be able to call.\n bytes4[] permittedExecutionSelectors;\n // Boolean to indicate whether the plugin can call any external address.\n bool permitAnyExternalAddress;\n // Boolean to indicate whether the plugin needs access to spend native tokens of the account. If false, the\n // plugin MUST still be able to spend up to the balance that it sends to the account in the same call.\n bool canSpendNativeToken;\n // More granular control\n ManifestExternalCallPermission[] permittedExternalCalls;\n ManifestAssociatedFunction[] userOpValidationFunctions;\n ManifestAssociatedFunction[] runtimeValidationFunctions;\n ManifestAssociatedFunction[] preUserOpValidationHooks;\n ManifestAssociatedFunction[] preRuntimeValidationHooks;\n // for executionFunctions\n ManifestExecutionHook[] executionHooks;\n}\n"},"src/msca/6900/v0.7/libs/FunctionReferenceDLLLib.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\nimport {SENTINEL_BYTES21} from \"../../../../common/Constants.sol\";\nimport {\n InvalidFunctionReference, InvalidLimit, ItemAlreadyExists, ItemDoesNotExist\n} from \"../../shared/common/Errors.sol\";\nimport {Bytes21DLL, FunctionReference} from \"../common/Structs.sol\";\nimport {FunctionReferenceLib} from \"./FunctionReferenceLib.sol\";\n\n/**\n * @dev Enumerable & ordered doubly linked list built using mapping(bytes21 => bytes21) for function reference.\n * Item is expected to be unique.\n */\nlibrary FunctionReferenceDLLLib {\n using FunctionReferenceLib for FunctionReference;\n using FunctionReferenceLib for bytes21;\n\n modifier validFunctionReference(FunctionReference memory fr) {\n if (fr.pack() <= SENTINEL_BYTES21) {\n revert InvalidFunctionReference();\n }\n _;\n }\n\n /**\n * @dev Check if an item exists or not. O(1).\n */\n function contains(Bytes21DLL storage dll, FunctionReference memory fr) internal view returns (bool) {\n return contains(dll, fr.pack());\n }\n\n function contains(Bytes21DLL storage dll, bytes21 item) internal view returns (bool) {\n if (item == SENTINEL_BYTES21) {\n return false;\n }\n return getHeadWithoutUnpack(dll) == item || dll.next[item] != SENTINEL_BYTES21\n || dll.prev[item] != SENTINEL_BYTES21;\n }\n\n /**\n * @dev Get the count of dll. O(1).\n */\n function size(Bytes21DLL storage dll) internal view returns (uint256) {\n return dll.count;\n }\n\n /**\n * @dev Add an new item which did not exist before. Otherwise the function reverts. O(1).\n */\n function append(Bytes21DLL storage dll, FunctionReference memory fr)\n internal\n validFunctionReference(fr)\n returns (bool)\n {\n bytes21 item = fr.pack();\n if (contains(dll, item)) {\n revert ItemAlreadyExists();\n }\n bytes21 prev = getTailWithoutUnpack(dll);\n bytes21 next = SENTINEL_BYTES21;\n // prev.next = item\n dll.next[prev] = item;\n // item.next = next\n dll.next[item] = next;\n // next.prev = item\n dll.prev[next] = item;\n // item.prev = prev\n dll.prev[item] = prev;\n dll.count++;\n return true;\n }\n\n /**\n * @dev Remove an already existing item. Otherwise the function reverts. O(1).\n */\n function remove(Bytes21DLL storage dll, FunctionReference memory fr)\n internal\n validFunctionReference(fr)\n returns (bool)\n {\n bytes21 item = fr.pack();\n if (!contains(dll, item)) {\n revert ItemDoesNotExist();\n }\n // item.prev.next = item.next\n dll.next[dll.prev[item]] = dll.next[item];\n // item.next.prev = item.prev\n dll.prev[dll.next[item]] = dll.prev[item];\n delete dll.next[item];\n delete dll.prev[item];\n dll.count--;\n return true;\n }\n\n /**\n * @dev Return paginated bytes21s and next pointer bytes21. O(n).\n * @param startFR Starting bytes21, inclusive, if start == bytes21(0), this method searches from the head.\n */\n function getPaginated(Bytes21DLL storage dll, FunctionReference memory startFR, uint256 limit)\n internal\n view\n returns (FunctionReference[] memory, FunctionReference memory)\n {\n if (limit == 0) {\n revert InvalidLimit();\n }\n bytes21 start = startFR.pack();\n FunctionReference[] memory results = new FunctionReference[](limit);\n bytes21 current = start;\n if (start == SENTINEL_BYTES21) {\n current = getHeadWithoutUnpack(dll);\n }\n uint256 count = 0;\n for (; count < limit && current > SENTINEL_BYTES21; ++count) {\n results[count] = current.unpack();\n current = dll.next[current];\n }\n // solhint-disable-next-line no-inline-assembly\n assembly (\"memory-safe\") {\n mstore(results, count)\n }\n return (results, current.unpack());\n }\n\n /**\n * @dev Return all the data. O(n).\n */\n function getAll(Bytes21DLL storage dll) internal view returns (FunctionReference[] memory results) {\n uint256 totalCount = size(dll);\n results = new FunctionReference[](totalCount);\n bytes21 current = getHeadWithoutUnpack(dll);\n uint256 count = 0;\n for (; count < totalCount && current > SENTINEL_BYTES21; ++count) {\n results[count] = current.unpack();\n current = dll.next[current];\n }\n return results;\n }\n\n function getHead(Bytes21DLL storage dll) internal view returns (FunctionReference memory) {\n return dll.next[SENTINEL_BYTES21].unpack();\n }\n\n function getTail(Bytes21DLL storage dll) internal view returns (FunctionReference memory) {\n return dll.prev[SENTINEL_BYTES21].unpack();\n }\n\n function getHeadWithoutUnpack(Bytes21DLL storage dll) private view returns (bytes21) {\n return dll.next[SENTINEL_BYTES21];\n }\n\n function getTailWithoutUnpack(Bytes21DLL storage dll) private view returns (bytes21) {\n return dll.prev[SENTINEL_BYTES21];\n }\n}\n"},"src/msca/6900/v0.7/libs/SelectorRegistryLib.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\nimport {IAccountLoupe} from \"../interfaces/IAccountLoupe.sol\";\n\nimport {IPlugin} from \"../interfaces/IPlugin.sol\";\nimport {IPluginExecutor} from \"../interfaces/IPluginExecutor.sol\";\nimport {IPluginManager} from \"../interfaces/IPluginManager.sol\";\nimport {IStandardExecutor} from \"../interfaces/IStandardExecutor.sol\";\n\nimport {IAccount} from \"@account-abstraction/contracts/interfaces/IAccount.sol\";\nimport {IAggregator} from \"@account-abstraction/contracts/interfaces/IAggregator.sol\";\nimport {IPaymaster} from \"@account-abstraction/contracts/interfaces/IPaymaster.sol\";\nimport {UUPSUpgradeable} from \"@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol\";\n\nimport {IERC777Recipient} from \"@openzeppelin/contracts/interfaces/IERC777Recipient.sol\";\nimport {IERC1155Receiver} from \"@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol\";\nimport {IERC721Receiver} from \"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\";\nimport {IERC165} from \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\n\nlibrary SelectorRegistryLib {\n bytes4 internal constant INITIALIZE_UPGRADABLE_MSCA =\n bytes4(keccak256(\"initializeUpgradableMSCA(address[],bytes32[],bytes[])\"));\n bytes4 internal constant INITIALIZE_SINGLE_OWNER_MSCA = bytes4(keccak256(\"initializeSingleOwnerMSCA(address)\"));\n bytes4 internal constant TRANSFER_NATIVE_OWNERSHIP = bytes4(keccak256(\"transferNativeOwnership(address)\"));\n bytes4 internal constant RENOUNCE_NATIVE_OWNERSHIP = bytes4(keccak256(\"renounceNativeOwnership()\"));\n bytes4 internal constant GET_NATIVE_OWNER = bytes4(keccak256(\"getNativeOwner()\"));\n bytes4 internal constant GET_ENTRYPOINT = bytes4(keccak256(\"getEntryPoint()\"));\n bytes4 internal constant GET_NONCE = bytes4(keccak256(\"getNonce()\"));\n\n /**\n * @dev Check if the selector is for native function.\n * @param selector the function selector.\n */\n function _isNativeFunctionSelector(bytes4 selector) internal pure returns (bool) {\n return selector == IStandardExecutor.execute.selector || selector == IStandardExecutor.executeBatch.selector\n || selector == IPluginManager.installPlugin.selector || selector == IPluginManager.uninstallPlugin.selector\n || selector == UUPSUpgradeable.upgradeTo.selector || selector == UUPSUpgradeable.upgradeToAndCall.selector\n || selector == UUPSUpgradeable.proxiableUUID.selector\n // check against IERC165 methods\n || selector == IERC165.supportsInterface.selector\n // check against IPluginExecutor methods\n || selector == IPluginExecutor.executeFromPlugin.selector\n || selector == IPluginExecutor.executeFromPluginExternal.selector\n // check against IAccountLoupe methods\n || selector == IAccountLoupe.getExecutionFunctionConfig.selector\n || selector == IAccountLoupe.getExecutionHooks.selector\n || selector == IAccountLoupe.getPreValidationHooks.selector\n || selector == IAccountLoupe.getInstalledPlugins.selector || selector == IAccount.validateUserOp.selector\n || selector == GET_ENTRYPOINT || selector == GET_NONCE || selector == INITIALIZE_UPGRADABLE_MSCA\n || selector == INITIALIZE_SINGLE_OWNER_MSCA || selector == TRANSFER_NATIVE_OWNERSHIP\n || selector == RENOUNCE_NATIVE_OWNERSHIP || selector == GET_NATIVE_OWNER\n || selector == IERC1155Receiver.onERC1155Received.selector\n || selector == IERC1155Receiver.onERC1155BatchReceived.selector\n || selector == IERC721Receiver.onERC721Received.selector || selector == IERC777Recipient.tokensReceived.selector;\n }\n\n function _isErc4337FunctionSelector(bytes4 selector) internal pure returns (bool) {\n return selector == IAggregator.validateSignatures.selector\n || selector == IAggregator.validateUserOpSignature.selector\n || selector == IAggregator.aggregateSignatures.selector\n || selector == IPaymaster.validatePaymasterUserOp.selector || selector == IPaymaster.postOp.selector;\n }\n\n function _isIPluginFunctionSelector(bytes4 selector) internal pure returns (bool) {\n return selector == IPlugin.onInstall.selector || selector == IPlugin.onUninstall.selector\n || selector == IPlugin.preUserOpValidationHook.selector || selector == IPlugin.userOpValidationFunction.selector\n || selector == IPlugin.preRuntimeValidationHook.selector\n || selector == IPlugin.runtimeValidationFunction.selector || selector == IPlugin.preExecutionHook.selector\n || selector == IPlugin.postExecutionHook.selector || selector == IPlugin.pluginManifest.selector\n || selector == IPlugin.pluginMetadata.selector;\n }\n}\n"},"node_modules/@openzeppelin/contracts/utils/introspection/ERC165Checker.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/introspection/ERC165Checker.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Library used to query support of an interface declared via {IERC165}.\n *\n * Note that these functions return the actual result of the query: they do not\n * `revert` if an interface is not supported. It is up to the caller to decide\n * what to do in these cases.\n */\nlibrary ERC165Checker {\n // As per the EIP-165 spec, no interface should ever match 0xffffffff\n bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff;\n\n /**\n * @dev Returns true if `account` supports the {IERC165} interface.\n */\n function supportsERC165(address account) internal view returns (bool) {\n // Any contract that implements ERC165 must explicitly indicate support of\n // InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid\n return\n supportsERC165InterfaceUnchecked(account, type(IERC165).interfaceId) &&\n !supportsERC165InterfaceUnchecked(account, _INTERFACE_ID_INVALID);\n }\n\n /**\n * @dev Returns true if `account` supports the interface defined by\n * `interfaceId`. Support for {IERC165} itself is queried automatically.\n *\n * See {IERC165-supportsInterface}.\n */\n function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) {\n // query support of both ERC165 as per the spec and support of _interfaceId\n return supportsERC165(account) && supportsERC165InterfaceUnchecked(account, interfaceId);\n }\n\n /**\n * @dev Returns a boolean array where each value corresponds to the\n * interfaces passed in and whether they're supported or not. This allows\n * you to batch check interfaces for a contract where your expectation\n * is that some interfaces may not be supported.\n *\n * See {IERC165-supportsInterface}.\n *\n * _Available since v3.4._\n */\n function getSupportedInterfaces(\n address account,\n bytes4[] memory interfaceIds\n ) internal view returns (bool[] memory) {\n // an array of booleans corresponding to interfaceIds and whether they're supported or not\n bool[] memory interfaceIdsSupported = new bool[](interfaceIds.length);\n\n // query support of ERC165 itself\n if (supportsERC165(account)) {\n // query support of each interface in interfaceIds\n for (uint256 i = 0; i < interfaceIds.length; i++) {\n interfaceIdsSupported[i] = supportsERC165InterfaceUnchecked(account, interfaceIds[i]);\n }\n }\n\n return interfaceIdsSupported;\n }\n\n /**\n * @dev Returns true if `account` supports all the interfaces defined in\n * `interfaceIds`. Support for {IERC165} itself is queried automatically.\n *\n * Batch-querying can lead to gas savings by skipping repeated checks for\n * {IERC165} support.\n *\n * See {IERC165-supportsInterface}.\n */\n function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) {\n // query support of ERC165 itself\n if (!supportsERC165(account)) {\n return false;\n }\n\n // query support of each interface in interfaceIds\n for (uint256 i = 0; i < interfaceIds.length; i++) {\n if (!supportsERC165InterfaceUnchecked(account, interfaceIds[i])) {\n return false;\n }\n }\n\n // all interfaces supported\n return true;\n }\n\n /**\n * @notice Query if a contract implements an interface, does not check ERC165 support\n * @param account The address of the contract to query for support of an interface\n * @param interfaceId The interface identifier, as specified in ERC-165\n * @return true if the contract at account indicates support of the interface with\n * identifier interfaceId, false otherwise\n * @dev Assumes that account contains a contract that supports ERC165, otherwise\n * the behavior of this method is undefined. This precondition can be checked\n * with {supportsERC165}.\n *\n * Some precompiled contracts will falsely indicate support for a given interface, so caution\n * should be exercised when using this function.\n *\n * Interface identification is specified in ERC-165.\n */\n function supportsERC165InterfaceUnchecked(address account, bytes4 interfaceId) internal view returns (bool) {\n // prepare call\n bytes memory encodedParams = abi.encodeWithSelector(IERC165.supportsInterface.selector, interfaceId);\n\n // perform static call\n bool success;\n uint256 returnSize;\n uint256 returnValue;\n assembly {\n success := staticcall(30000, account, add(encodedParams, 0x20), mload(encodedParams), 0x00, 0x20)\n returnSize := returndatasize()\n returnValue := mload(0x00)\n }\n\n return success && returnSize >= 0x20 && returnValue > 0;\n }\n}\n"},"lib/account-abstraction/contracts/interfaces/IStakeManager.sol":{"content":"// SPDX-License-Identifier: GPL-3.0-only\npragma solidity ^0.8.12;\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\n event Deposited(\n address indexed account,\n uint256 totalDeposit\n );\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(\n address indexed account,\n uint256 withdrawTime\n );\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,staked, stake) fit into one cell (used during handleOps)\n * and the rest fit into a 2nd cell.\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 uint112 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 /// @return info - full deposit information of given account\n function getDepositInfo(address account) external view returns (DepositInfo memory info);\n\n /// @return the deposit (for gas payment) of the account\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * add to the deposit of the given account\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(address payable withdrawAddress, uint256 withdrawAmount) external;\n}\n"},"lib/account-abstraction/contracts/interfaces/IAggregator.sol":{"content":"// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.12;\n\nimport \"./UserOperation.sol\";\n\n/**\n * Aggregated Signatures validator.\n */\ninterface IAggregator {\n\n /**\n * validate aggregated signature.\n * revert if the aggregated signature does not match the given list of operations.\n */\n function validateSignatures(UserOperation[] calldata userOps, bytes calldata signature) external view;\n\n /**\n * validate signature of a single userOp\n * This method is should be called by bundler after EntryPoint.simulateValidation() returns (reverts) with ValidationResultWithAggregation\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(UserOperation 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(UserOperation[] calldata userOps) external view returns (bytes memory aggregatedSignature);\n}\n"},"lib/account-abstraction/contracts/interfaces/INonceManager.sol":{"content":"// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.12;\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"},"node_modules/@openzeppelin/contracts/proxy/Proxy.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\n * be specified by overriding the virtual {_implementation} function.\n *\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\n * different contract through the {_delegate} function.\n *\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\n */\nabstract contract Proxy {\n /**\n * @dev Delegates the current call to `implementation`.\n *\n * This function does not return to its internal call site, it will return directly to the external caller.\n */\n function _delegate(address implementation) internal virtual {\n assembly {\n // Copy msg.data. We take full control of memory in this inline assembly\n // block because it will not return to Solidity code. We overwrite the\n // Solidity scratch pad at memory position 0.\n calldatacopy(0, 0, calldatasize())\n\n // Call the implementation.\n // out and outsize are 0 because we don't know the size yet.\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\n\n // Copy the returned data.\n returndatacopy(0, 0, returndatasize())\n\n switch result\n // delegatecall returns 0 on error.\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n\n /**\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\n * and {_fallback} should delegate.\n */\n function _implementation() internal view virtual returns (address);\n\n /**\n * @dev Delegates the current call to the address returned by `_implementation()`.\n *\n * This function does not return to its internal call site, it will return directly to the external caller.\n */\n function _fallback() internal virtual {\n _beforeFallback();\n _delegate(_implementation());\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\n * function in the contract matches the call data.\n */\n fallback() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\n * is empty.\n */\n receive() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\n * call, or as part of the Solidity `fallback` or `receive` functions.\n *\n * If overridden should call `super._beforeFallback()`.\n */\n function _beforeFallback() internal virtual {}\n}\n"},"node_modules/@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/ERC1967/ERC1967Upgrade.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../beacon/IBeacon.sol\";\nimport \"../../interfaces/IERC1967.sol\";\nimport \"../../interfaces/draft-IERC1822.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../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 *\n * _Available since v4.1._\n */\nabstract contract ERC1967Upgrade is IERC1967 {\n // This is the keccak-256 hash of \"eip1967.proxy.rollback\" subtracted by 1\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\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, and is\n * validated in the constructor.\n */\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\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 require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n }\n\n /**\n * @dev Perform implementation upgrade\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeTo(address newImplementation) internal {\n _setImplementation(newImplementation);\n emit Upgraded(newImplementation);\n }\n\n /**\n * @dev Perform implementation upgrade with additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCall(address newImplementation, bytes memory data, bool forceCall) internal {\n _upgradeTo(newImplementation);\n if (data.length > 0 || forceCall) {\n Address.functionDelegateCall(newImplementation, data);\n }\n }\n\n /**\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCallUUPS(address newImplementation, bytes memory data, bool forceCall) internal {\n // Upgrades from old implementations will perform a rollback test. This test requires the new\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\n // this special case will break upgrade paths from old UUPS implementation to new ones.\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\n _setImplementation(newImplementation);\n } else {\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\n require(slot == _IMPLEMENTATION_SLOT, \"ERC1967Upgrade: unsupported proxiableUUID\");\n } catch {\n revert(\"ERC1967Upgrade: new implementation is not UUPS\");\n }\n _upgradeToAndCall(newImplementation, data, forceCall);\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, and is\n * validated in the constructor.\n */\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n /**\n * @dev Returns the current admin.\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 require(newAdmin != address(0), \"ERC1967: new admin is the zero address\");\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\n }\n\n /**\n * @dev Changes the admin of the proxy.\n *\n * Emits an {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 bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\n */\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 require(Address.isContract(newBeacon), \"ERC1967: new beacon is not a contract\");\n require(\n Address.isContract(IBeacon(newBeacon).implementation()),\n \"ERC1967: beacon implementation is not a contract\"\n );\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\n }\n\n /**\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\n *\n * Emits a {BeaconUpgraded} event.\n */\n function _upgradeBeaconToAndCall(address newBeacon, bytes memory data, bool forceCall) internal {\n _setBeacon(newBeacon);\n emit BeaconUpgraded(newBeacon);\n if (data.length > 0 || forceCall) {\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\n }\n }\n}\n"},"node_modules/@openzeppelin/contracts/interfaces/IERC777Recipient.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC777Recipient.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../token/ERC777/IERC777Recipient.sol\";\n"},"node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\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"},"src/msca/6900/v0.7/interfaces/IAccountLoupe.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\nimport {ExecutionFunctionConfig, ExecutionHooks, FunctionReference} from \"../common/Structs.sol\";\n\n/**\n * @dev Implements https://eips.ethereum.org/EIPS/eip-6900. MSCAs may implement this interface to support visibility in\n * plugin configurations on-chain.\n */\ninterface IAccountLoupe {\n /// @notice Get the validation functions and plugin address for a selector.\n /// @dev If the selector is a native function, the plugin address will be the address of the account.\n /// @param selector The selector to get the configuration for.\n /// @return The configuration for this selector.\n function getExecutionFunctionConfig(bytes4 selector) external view returns (ExecutionFunctionConfig memory);\n\n /// @notice Get the pre and post execution hooks for a selector.\n /// @param selector The selector to get the hooks for.\n /// @return The pre and post execution hooks for this selector.\n function getExecutionHooks(bytes4 selector) external view returns (ExecutionHooks[] memory);\n\n /// @notice Get the pre user op and runtime validation hooks associated with a selector.\n /// @param selector The selector to get the hooks for.\n /// @return preUserOpValidationHooks The pre user op validation hooks for this selector.\n /// @return preRuntimeValidationHooks The pre runtime validation hooks for this selector.\n function getPreValidationHooks(bytes4 selector)\n external\n view\n returns (FunctionReference[] memory, FunctionReference[] memory);\n\n /// @notice Get an array of all installed plugins.\n /// @return pluginAddresses The addresses of all installed plugins.\n function getInstalledPlugins() external view returns (address[] memory);\n}\n"},"src/msca/6900/v0.7/interfaces/IPluginExecutor.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\n/**\n * @dev Implements https://eips.ethereum.org/EIPS/eip-6900. MSCAs must implement this interface to support execution\n * from plugins.\n */\ninterface IPluginExecutor {\n /// @notice Execute a call from a plugin through the account.\n /// @dev Permissions must be granted to the calling plugin for the call to go through.\n /// @param data The calldata to send to the account.\n function executeFromPlugin(bytes calldata data) external payable returns (bytes memory);\n\n /// @notice Execute a call from a plugin to a non-plugin address.\n /// @dev If the target is a plugin, the call SHOULD revert. Permissions must be granted to the calling plugin\n /// for the call to go through.\n /// @param target The address to be called.\n /// @param value The value to send with the call.\n /// @param data The calldata to send to the target.\n /// @return The return data from the call.\n function executeFromPluginExternal(address target, uint256 value, bytes calldata data)\n external\n payable\n returns (bytes memory);\n}\n"},"src/msca/6900/v0.7/interfaces/IPluginManager.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\nimport {FunctionReference} from \"../common/Structs.sol\";\n\n/**\n * @dev Implements https://eips.ethereum.org/EIPS/eip-6900. MSCAs must implement this interface to support installing\n * and uninstalling plugins.\n */\ninterface IPluginManager {\n event PluginInstalled(address indexed plugin, bytes32 manifestHash, FunctionReference[] dependencies);\n event PluginUninstalled(address indexed plugin, bool indexed onUninstallSucceeded);\n\n /// @notice Install a plugin to the modular account.\n /// @param plugin The plugin to install.\n /// @param manifestHash The hash of the plugin manifest.\n /// @param pluginInstallData Optional data to be decoded and used by the plugin to setup initial plugin data\n /// for the modular account.\n /// @param dependencies The dependencies of the plugin, as described in the manifest. Each FunctionReference\n /// MUST be composed of an installed plugin's address and a function ID of its validation function.\n function installPlugin(\n address plugin,\n bytes32 manifestHash,\n bytes calldata pluginInstallData,\n FunctionReference[] calldata dependencies\n ) external;\n\n /// @notice Uninstall a plugin from the modular account.\n /// @param plugin The plugin to uninstall.\n /// @param config An optional, implementation-specific field that accounts may use to ensure consistency\n /// guarantees.\n /// @param pluginUninstallData Optional data to be decoded and used by the plugin to clear plugin data for the\n /// modular account.\n function uninstallPlugin(address plugin, bytes calldata config, bytes calldata pluginUninstallData) external;\n}\n"},"src/msca/6900/v0.7/interfaces/IStandardExecutor.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\nimport {Call} from \"../common/Structs.sol\";\n\n/**\n * @dev Implements https://eips.ethereum.org/EIPS/eip-6900. MSCAs must implement this interface to support open-ended\n * execution.\n */\ninterface IStandardExecutor {\n /// @notice Standard execute method.\n /// @dev If the target is a plugin, the call SHOULD revert.\n /// @param target The target address for the account to call.\n /// @param value The value to send with the call.\n /// @param data The calldata for the call.\n /// @return The return data from the call.\n function execute(address target, uint256 value, bytes calldata data) external payable returns (bytes memory);\n\n /// @notice Standard executeBatch method.\n /// @dev If the target is a plugin, the call SHOULD revert. If any of the calls revert, the entire batch MUST\n /// revert.\n /// @param calls The array of calls.\n /// @return An array containing the return data from the calls.\n function executeBatch(Call[] calldata calls) external payable returns (bytes[] memory);\n}\n"},"src/msca/6900/v0.7/libs/ExecutionHookLib.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\nimport {EMPTY_FUNCTION_REFERENCE, SENTINEL_BYTES21} from \"../../../../common/Constants.sol\";\nimport {InvalidValidationFunctionId} from \"../../shared/common/Errors.sol\";\nimport {\n PRE_HOOK_ALWAYS_DENY_FUNCTION_REFERENCE,\n RUNTIME_VALIDATION_ALWAYS_ALLOW_FUNCTION_REFERENCE\n} from \"../common/Constants.sol\";\nimport {\n ExecutionHooks,\n FunctionReference,\n HookGroup,\n PostExecHookToRun,\n RepeatableBytes21DLL\n} from \"../common/Structs.sol\";\nimport {IPlugin} from \"../interfaces/IPlugin.sol\";\nimport {FunctionReferenceLib} from \"./FunctionReferenceLib.sol\";\nimport {RepeatableFunctionReferenceDLLLib} from \"./RepeatableFunctionReferenceDLLLib.sol\";\n\n/**\n * @dev Process pre or post execution hooks.\n */\nlibrary ExecutionHookLib {\n using RepeatableFunctionReferenceDLLLib for RepeatableBytes21DLL;\n using FunctionReferenceLib for FunctionReference;\n using FunctionReferenceLib for bytes21;\n\n error PreExecHookFailed(address plugin, uint8 functionId, bytes revertReason);\n error PostExecHookFailed(address plugin, uint8 functionId, bytes revertReason);\n\n // avoid stack too deep\n struct SetPostExecHooksFromPreHooksParam {\n uint256 totalPostExecHooksToRunCount;\n PostExecHookToRun[] postExecHooksToRun;\n }\n\n function _processPreExecHooks(HookGroup storage hookGroup, bytes calldata data)\n internal\n returns (PostExecHookToRun[] memory postExecHooksToRun)\n {\n uint256 postOnlyHooksCount = hookGroup.postOnlyHooks.getUniqueItems();\n // hooks have three categories a. preOnlyHook b. preToPostHook c. postOnlyHook\n // 1. add repeated preHook into postHook 2. add postOnlyHooks\n uint256 maxPostHooksCount = postOnlyHooksCount + hookGroup.preHooks.getTotalItems();\n uint256 totalPostExecHooksToRunCount = 0;\n postExecHooksToRun = new PostExecHookToRun[](maxPostHooksCount);\n // copy postOnlyHooks into result first\n FunctionReference memory startHook = EMPTY_FUNCTION_REFERENCE.unpack();\n for (uint256 i = 0; i < postOnlyHooksCount; ++i) {\n (FunctionReference[] memory resultPostOnlyHooks, FunctionReference memory nextHook) =\n hookGroup.postOnlyHooks.getPaginated(startHook, 10);\n for (uint256 j = 0; j < resultPostOnlyHooks.length; ++j) {\n postExecHooksToRun[totalPostExecHooksToRunCount++].postExecHook = resultPostOnlyHooks[j];\n }\n if (nextHook.pack() == SENTINEL_BYTES21) {\n break;\n }\n startHook = nextHook;\n }\n // then run the preHooks and copy associated postHooks\n SetPostExecHooksFromPreHooksParam memory input;\n input.totalPostExecHooksToRunCount = totalPostExecHooksToRunCount;\n input.postExecHooksToRun = postExecHooksToRun;\n (totalPostExecHooksToRunCount, postExecHooksToRun) = _setPostExecHooksFromPreHooks(hookGroup, data, input);\n // solhint-disable-next-line no-inline-assembly\n assembly (\"memory-safe\") {\n mstore(postExecHooksToRun, totalPostExecHooksToRunCount)\n }\n }\n\n function _processPreExecHook(FunctionReference memory preExecHook, bytes calldata data)\n internal\n returns (bytes memory preExecHookReturnData)\n {\n try IPlugin(preExecHook.plugin).preExecutionHook(preExecHook.functionId, msg.sender, msg.value, data) returns (\n bytes memory returnData\n ) {\n preExecHookReturnData = returnData;\n } catch (bytes memory revertReason) {\n revert PreExecHookFailed(preExecHook.plugin, preExecHook.functionId, revertReason);\n }\n return preExecHookReturnData;\n }\n\n function _processPostExecHooks(PostExecHookToRun[] memory postExecHooksToRun) internal {\n uint256 length = postExecHooksToRun.length;\n for (uint256 i = 0; i < length; ++i) {\n FunctionReference memory postExecHook = postExecHooksToRun[i].postExecHook;\n // solhint-disable no-empty-blocks\n try IPlugin(postExecHook.plugin).postExecutionHook(\n postExecHook.functionId, postExecHooksToRun[i].preExecHookReturnData\n ) {} catch (bytes memory revertReason) {\n revert PostExecHookFailed(postExecHook.plugin, postExecHook.functionId, revertReason);\n }\n // solhint-enable no-empty-blocks\n }\n }\n\n function _getExecutionHooks(HookGroup storage hookGroup) internal view returns (ExecutionHooks[] memory hooks) {\n uint256 preHooksCount = hookGroup.preHooks.getUniqueItems();\n uint256 postOnlyHooksCount = hookGroup.postOnlyHooks.getUniqueItems();\n // hooks have three categories a. preOnlyHook b. preToPostHook c. postOnlyHook\n // 1. add repeated preHook into postHook 2. add postOnlyHooks\n uint256 maxExecHooksCount = postOnlyHooksCount + hookGroup.preHooks.getTotalItems();\n uint256 totalExecHooksCount = 0;\n hooks = new ExecutionHooks[](maxExecHooksCount);\n // copy postOnlyHooks into result first\n FunctionReference memory startHook = EMPTY_FUNCTION_REFERENCE.unpack();\n for (uint256 i = 0; i < postOnlyHooksCount; ++i) {\n (FunctionReference[] memory resultPostOnlyHooks, FunctionReference memory nextHook) =\n hookGroup.postOnlyHooks.getPaginated(startHook, 10);\n for (uint256 j = 0; j < resultPostOnlyHooks.length; ++j) {\n hooks[totalExecHooksCount++].postExecHook = resultPostOnlyHooks[j];\n }\n if (nextHook.pack() == SENTINEL_BYTES21) {\n break;\n }\n startHook = nextHook;\n }\n // then copy preOnlyHooks or preToPostHooks\n startHook = EMPTY_FUNCTION_REFERENCE.unpack();\n for (uint256 i = 0; i < preHooksCount; ++i) {\n (FunctionReference[] memory resultPreExecHooks, FunctionReference memory nextHook) =\n hookGroup.preHooks.getPaginated(startHook, 10);\n for (uint256 j = 0; j < resultPreExecHooks.length; ++j) {\n // if any revert, the outer call MUST revert\n bytes21 packedPreExecHook = resultPreExecHooks[j].pack();\n // getAll can handle 1000+ hooks\n FunctionReference[] memory preToPostHooks = hookGroup.preToPostHooks[packedPreExecHook].getAll();\n if (preToPostHooks.length > 0) {\n for (uint256 k = 0; k < preToPostHooks.length; ++k) {\n hooks[totalExecHooksCount].preExecHook = resultPreExecHooks[j];\n hooks[totalExecHooksCount].postExecHook = preToPostHooks[k];\n totalExecHooksCount++;\n }\n } else {\n // no associated postHook\n hooks[totalExecHooksCount++].preExecHook = resultPreExecHooks[j];\n }\n }\n if (nextHook.pack() == SENTINEL_BYTES21) {\n break;\n }\n startHook = nextHook;\n }\n // solhint-disable-next-line no-inline-assembly\n assembly (\"memory-safe\") {\n mstore(hooks, totalExecHooksCount)\n }\n return hooks;\n }\n\n /// @dev The caller would expect both input.totalPostExecHooksToRunCount and input.postExecHooksToRun to be assigned\n /// back to original values.\n function _setPostExecHooksFromPreHooks(\n HookGroup storage hookGroup,\n bytes calldata data,\n SetPostExecHooksFromPreHooksParam memory input\n ) internal returns (uint256, PostExecHookToRun[] memory) {\n FunctionReference memory startHook = EMPTY_FUNCTION_REFERENCE.unpack();\n uint256 preHooksCount = hookGroup.preHooks.getUniqueItems();\n for (uint256 i = 0; i < preHooksCount; ++i) {\n (FunctionReference[] memory resultPreExecHooks, FunctionReference memory nextHook) =\n hookGroup.preHooks.getPaginated(startHook, 10);\n for (uint256 j = 0; j < resultPreExecHooks.length; ++j) {\n // if any revert, the outer call MUST revert\n bytes21 packedPreExecHook = resultPreExecHooks[j].pack();\n if (\n packedPreExecHook == EMPTY_FUNCTION_REFERENCE\n || packedPreExecHook == RUNTIME_VALIDATION_ALWAYS_ALLOW_FUNCTION_REFERENCE\n || packedPreExecHook == PRE_HOOK_ALWAYS_DENY_FUNCTION_REFERENCE\n ) {\n revert InvalidValidationFunctionId(resultPreExecHooks[j].functionId);\n }\n // getAll can handle 1000+ hooks\n // run duplicated (if any) preHooks only once\n bytes memory preExecHookReturnData = _processPreExecHook(resultPreExecHooks[j], data);\n FunctionReference[] memory preToPostHooks = hookGroup.preToPostHooks[packedPreExecHook].getAll();\n if (preToPostHooks.length > 0) {\n for (uint256 k = 0; k < preToPostHooks.length; ++k) {\n input.postExecHooksToRun[input.totalPostExecHooksToRunCount].postExecHook = preToPostHooks[k];\n input.postExecHooksToRun[input.totalPostExecHooksToRunCount].preExecHookReturnData =\n preExecHookReturnData;\n input.totalPostExecHooksToRunCount++;\n }\n }\n }\n if (nextHook.pack() == SENTINEL_BYTES21) {\n break;\n }\n startHook = nextHook;\n }\n return (input.totalPostExecHooksToRunCount, input.postExecHooksToRun);\n }\n}\n"},"src/msca/6900/v0.7/managers/PluginExecutor.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\nimport {ExecutionUtils} from \"../../../../utils/ExecutionUtils.sol\";\nimport {InvalidExecutionFunction, NotFoundSelector} from \"../../shared/common/Errors.sol\";\nimport {ExecutionDetail, HookGroup, PermittedExternalCall, PostExecHookToRun} from \"../common/Structs.sol\";\nimport {IPlugin} from \"../interfaces/IPlugin.sol\";\nimport {IPluginExecutor} from \"../interfaces/IPluginExecutor.sol\";\nimport {ExecutionHookLib} from \"../libs/ExecutionHookLib.sol\";\nimport {WalletStorageV1Lib} from \"../libs/WalletStorageV1Lib.sol\";\nimport {ERC165Checker} from \"@openzeppelin/contracts/utils/introspection/ERC165Checker.sol\";\n\n/**\n * @dev Default implementation of https://eips.ethereum.org/EIPS/eip-6900. MSCAs must implement this interface to\n * support execution from plugins.\n * https://eips.ethereum.org/assets/eip-6900/Plugin_Execution_Flow.svg\n */\nlibrary PluginExecutor {\n using ExecutionHookLib for HookGroup;\n using ExecutionHookLib for PostExecHookToRun[];\n using ExecutionUtils for address;\n\n error ExecuteFromPluginToExternalNotPermitted();\n error ExecFromPluginToSelectorNotPermitted(address plugin, bytes4 selector);\n error NativeTokenSpendingNotPermitted(address plugin);\n\n /// @dev Refer to IPluginExecutor\n function executeFromPlugin(bytes calldata data) internal returns (bytes memory) {\n if (data.length < 4) {\n revert NotFoundSelector();\n }\n bytes4 selector = bytes4(data[0:4]);\n if (selector == bytes4(0)) {\n revert NotFoundSelector();\n }\n address callingPlugin = msg.sender;\n WalletStorageV1Lib.Layout storage walletStorage = WalletStorageV1Lib.getLayout();\n // permission check\n if (!walletStorage.permittedPluginCalls[callingPlugin][selector]) {\n revert ExecFromPluginToSelectorNotPermitted(callingPlugin, selector);\n }\n // this function call emulates a call to the fallback that routes calls into another plugin;\n // we use inner data here instead of the entire msg.data that includes the complete calldata of\n // executeFromPlugin\n ExecutionDetail storage executionDetail = walletStorage.executionDetails[selector];\n if (executionDetail.plugin == address(0)) {\n revert InvalidExecutionFunction(selector);\n }\n // pre execution hooks\n PostExecHookToRun[] memory postExecHooks = executionDetail.executionHooks._processPreExecHooks(data);\n // permitted to call the other plugin\n bytes memory returnData = executionDetail.plugin.callWithReturnDataOrRevert(0, data);\n // post execution hooks\n postExecHooks._processPostExecHooks();\n return returnData;\n }\n\n /// @dev Refer to IPluginExecutor\n function executeFromPluginToExternal(bytes calldata data, address target, uint256 value)\n internal\n returns (bytes memory)\n {\n if (target == address(this) || ERC165Checker.supportsInterface(target, type(IPlugin).interfaceId)) {\n revert ExecuteFromPluginToExternalNotPermitted();\n }\n WalletStorageV1Lib.Layout storage walletStorage = WalletStorageV1Lib.getLayout();\n address callingPlugin = msg.sender;\n // revert if the plugin can't cover the value and is not permitted to spend MSCA's native token\n if (value > 0 && value > msg.value && !walletStorage.pluginDetails[callingPlugin].canSpendNativeToken) {\n revert NativeTokenSpendingNotPermitted(callingPlugin);\n }\n PermittedExternalCall storage permittedExternalCall =\n walletStorage.permittedExternalCalls[callingPlugin][target];\n // permission check\n // addressPermitted can only be true if anyExternalAddressPermitted is false\n bool targetContractCallPermitted;\n // external call might not have function selector\n bytes4 selector = bytes4(data);\n if (permittedExternalCall.addressPermitted) {\n targetContractCallPermitted =\n permittedExternalCall.anySelector || permittedExternalCall.selectors[selector] || data.length == 0;\n } else {\n // also need to check the default permission in plugin detail\n targetContractCallPermitted = walletStorage.pluginDetails[callingPlugin].anyExternalAddressPermitted;\n }\n if (!targetContractCallPermitted) {\n revert ExecFromPluginToSelectorNotPermitted(callingPlugin, selector);\n }\n // we use msg.data here so the complete calldata of current function call executeFromPluginToExternalContract\n // can be passed\n // pre executeFromPluginToExternalContract hooks\n // process any pre exec hooks for IPluginExecutor.executeFromPluginExternal.selector during runtime\n PostExecHookToRun[] memory postExecHooks = walletStorage.executionDetails[IPluginExecutor\n .executeFromPluginExternal\n .selector].executionHooks._processPreExecHooks(msg.data);\n // call externally\n bytes memory returnData = target.callWithReturnDataOrRevert(value, data);\n // post executeFromPluginToExternalContract hooks\n postExecHooks._processPostExecHooks();\n return returnData;\n }\n}\n"},"src/msca/6900/v0.7/managers/StandardExecutor.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\nimport {ExecutionUtils} from \"../../../../utils/ExecutionUtils.sol\";\nimport {Call} from \"../common/Structs.sol\";\nimport {IPlugin} from \"../interfaces/IPlugin.sol\";\nimport {ERC165Checker} from \"@openzeppelin/contracts/utils/introspection/ERC165Checker.sol\";\n\n/**\n * @dev Default implementation of https://eips.ethereum.org/EIPS/eip-6900. MSCAs must implement this interface to\n * support open-ended execution.\n */\nlibrary StandardExecutor {\n using ExecutionUtils for address;\n\n error TargetIsPlugin(address plugin);\n\n /// @dev Refer to IStandardExecutor\n function execute(address target, uint256 value, bytes calldata data) internal returns (bytes memory returnData) {\n // reverts if the target is a plugin because modular account should be calling plugin via execution functions\n // defined in IPluginExecutor\n if (ERC165Checker.supportsInterface(target, type(IPlugin).interfaceId)) {\n revert TargetIsPlugin(target);\n }\n return target.callWithReturnDataOrRevert(value, data);\n }\n\n /// @dev Refer to IStandardExecutor\n function executeBatch(Call[] calldata calls) internal returns (bytes[] memory returnData) {\n returnData = new bytes[](calls.length);\n for (uint256 i = 0; i < calls.length; ++i) {\n if (ERC165Checker.supportsInterface(calls[i].target, type(IPlugin).interfaceId)) {\n revert TargetIsPlugin(calls[i].target);\n }\n returnData[i] = calls[i].target.callWithReturnDataOrRevert(calls[i].value, calls[i].data);\n }\n return returnData;\n }\n}\n"},"src/msca/6900/v0.7/account/WalletStorageInitializable.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\nimport {WalletStorageV1Lib} from \"../libs/WalletStorageV1Lib.sol\";\n\n/// @notice Forked from OpenZeppelin (proxy/utils/Initializable.sol) with wallet storage access.\n/// Reinitialization is removed.\n/// For V1 MSCA.\nabstract contract WalletStorageInitializable {\n /**\n * @dev Triggered when the contract has been initialized.\n */\n event WalletStorageInitialized();\n\n error WalletStorageIsInitializing();\n error WalletStorageIsNotInitializing();\n error WalletStorageIsInitialized();\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyWalletStorageInitializing` functions can be used to initialize parent contracts.\n *\n * Functions marked with `walletStorageInitializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {WalletStorageInitialized} event.\n */\n modifier walletStorageInitializer() {\n bool isTopLevelCall = !WalletStorageV1Lib.getLayout().initializing;\n uint8 initialized = WalletStorageV1Lib.getLayout().initialized;\n\n // Allowed calls:\n // - initialSetup: the contract is not in the initializing state and no previous version was\n // initialized\n // - deploying: 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 deploying = initialized == 1 && address(this).code.length == 0;\n if (!initialSetup && !deploying) {\n revert WalletStorageIsInitialized();\n }\n WalletStorageV1Lib.getLayout().initialized = 1;\n if (isTopLevelCall) {\n WalletStorageV1Lib.getLayout().initializing = true;\n }\n _;\n if (isTopLevelCall) {\n WalletStorageV1Lib.getLayout().initializing = false;\n emit WalletStorageInitialized();\n }\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {walletStorageInitializer} modifier, directly or indirectly.\n */\n modifier onlyWalletStorageInitializing() {\n if (!WalletStorageV1Lib.getLayout().initializing) {\n revert WalletStorageIsNotInitializing();\n }\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 {WalletStorageInitialized} event the first time it is successfully executed.\n */\n function _disableWalletStorageInitializers() internal virtual {\n if (WalletStorageV1Lib.getLayout().initializing) {\n revert WalletStorageIsInitializing();\n }\n if (WalletStorageV1Lib.getLayout().initialized != type(uint8).max) {\n WalletStorageV1Lib.getLayout().initialized = type(uint8).max;\n emit WalletStorageInitialized();\n }\n }\n}\n"},"lib/account-abstraction/contracts/core/Helpers.sol":{"content":"// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.12;\n\n/* solhint-disable no-inline-assembly */\n\n/**\n * returned data from validateUserOp.\n * validateUserOp returns a uint256, with is created by `_packedValidationData` and 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 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 */\n struct ValidationData {\n address aggregator;\n uint48 validAfter;\n uint48 validUntil;\n }\n\n//extract sigFailed, validAfter, validUntil.\n// also convert zero validUntil to type(uint48).max\n function _parseValidationData(uint validationData) 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// intersect account and paymaster ranges.\n function _intersectTimeRange(uint256 validationData, uint256 paymasterValidationData) pure returns (ValidationData memory) {\n ValidationData memory accountValidationData = _parseValidationData(validationData);\n ValidationData memory pmValidationData = _parseValidationData(paymasterValidationData);\n address aggregator = accountValidationData.aggregator;\n if (aggregator == address(0)) {\n aggregator = pmValidationData.aggregator;\n }\n uint48 validAfter = accountValidationData.validAfter;\n uint48 validUntil = accountValidationData.validUntil;\n uint48 pmValidAfter = pmValidationData.validAfter;\n uint48 pmValidUntil = pmValidationData.validUntil;\n\n if (validAfter < pmValidAfter) validAfter = pmValidAfter;\n if (validUntil > pmValidUntil) validUntil = pmValidUntil;\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 */\n function _packValidationData(ValidationData memory data) pure returns (uint256) {\n return uint160(data.aggregator) | (uint256(data.validUntil) << 160) | (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 */\n function _packValidationData(bool sigFailed, uint48 validUntil, uint48 validAfter) pure returns (uint256) {\n return (sigFailed ? 1 : 0) | (uint256(validUntil) << 160) | (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 {\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"},"node_modules/@openzeppelin/contracts-upgradeable/interfaces/draft-IERC1822Upgradeable.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\n\npragma solidity ^0.8.0;\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 IERC1822ProxiableUpgradeable {\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"},"node_modules/@openzeppelin/contracts-upgradeable/proxy/ERC1967/ERC1967UpgradeUpgradeable.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/ERC1967/ERC1967Upgrade.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../beacon/IBeaconUpgradeable.sol\";\nimport \"../../interfaces/IERC1967Upgradeable.sol\";\nimport \"../../interfaces/draft-IERC1822Upgradeable.sol\";\nimport \"../../utils/AddressUpgradeable.sol\";\nimport \"../../utils/StorageSlotUpgradeable.sol\";\nimport {Initializable} from \"../utils/Initializable.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 *\n * _Available since v4.1._\n */\nabstract contract ERC1967UpgradeUpgradeable is Initializable, IERC1967Upgradeable {\n // This is the keccak-256 hash of \"eip1967.proxy.rollback\" subtracted by 1\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\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, and is\n * validated in the constructor.\n */\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n\n function __ERC1967Upgrade_init() internal onlyInitializing {\n }\n\n function __ERC1967Upgrade_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev Returns the current implementation address.\n */\n function _getImplementation() internal view returns (address) {\n return StorageSlotUpgradeable.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 require(AddressUpgradeable.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n }\n\n /**\n * @dev Perform implementation upgrade\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeTo(address newImplementation) internal {\n _setImplementation(newImplementation);\n emit Upgraded(newImplementation);\n }\n\n /**\n * @dev Perform implementation upgrade with additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCall(address newImplementation, bytes memory data, bool forceCall) internal {\n _upgradeTo(newImplementation);\n if (data.length > 0 || forceCall) {\n AddressUpgradeable.functionDelegateCall(newImplementation, data);\n }\n }\n\n /**\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCallUUPS(address newImplementation, bytes memory data, bool forceCall) internal {\n // Upgrades from old implementations will perform a rollback test. This test requires the new\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\n // this special case will break upgrade paths from old UUPS implementation to new ones.\n if (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) {\n _setImplementation(newImplementation);\n } else {\n try IERC1822ProxiableUpgradeable(newImplementation).proxiableUUID() returns (bytes32 slot) {\n require(slot == _IMPLEMENTATION_SLOT, \"ERC1967Upgrade: unsupported proxiableUUID\");\n } catch {\n revert(\"ERC1967Upgrade: new implementation is not UUPS\");\n }\n _upgradeToAndCall(newImplementation, data, forceCall);\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, and is\n * validated in the constructor.\n */\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n /**\n * @dev Returns the current admin.\n */\n function _getAdmin() internal view returns (address) {\n return StorageSlotUpgradeable.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 require(newAdmin != address(0), \"ERC1967: new admin is the zero address\");\n StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\n }\n\n /**\n * @dev Changes the admin of the proxy.\n *\n * Emits an {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 bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\n */\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 StorageSlotUpgradeable.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 require(AddressUpgradeable.isContract(newBeacon), \"ERC1967: new beacon is not a contract\");\n require(\n AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()),\n \"ERC1967: beacon implementation is not a contract\"\n );\n StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon;\n }\n\n /**\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\n *\n * Emits a {BeaconUpgraded} event.\n */\n function _upgradeBeaconToAndCall(address newBeacon, bytes memory data, bool forceCall) internal {\n _setBeacon(newBeacon);\n emit BeaconUpgraded(newBeacon);\n if (data.length > 0 || forceCall) {\n AddressUpgradeable.functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data);\n }\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n"},"node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/AddressUpgradeable.sol\";\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 Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 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 functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\n \"Initializable: contract is already initialized\"\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 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\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 require(_initializing, \"Initializable: contract is not initializing\");\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 require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized != type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _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 _initializing;\n }\n}\n"},"node_modules/@openzeppelin/contracts/utils/Strings.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./math/Math.sol\";\nimport \"./math/SignedMath.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\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), _SYMBOLS))\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 toString(int256 value) internal pure returns (string memory) {\n return string(abi.encodePacked(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 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] = _SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\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 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 keccak256(bytes(a)) == keccak256(bytes(b));\n }\n}\n"},"src/libs/MessageHashUtils.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\n/**\n * @notice Forked from OZ V5 as it doesn't exist in V4.\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-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 // solhint-disable-next-line no-inline-assembly\n assembly {\n let ptr := mload(0x40)\n mstore(ptr, hex\"1901\")\n mstore(add(ptr, 0x02), domainSeparator)\n mstore(add(ptr, 0x22), structHash)\n digest := keccak256(ptr, 0x42)\n }\n }\n}\n"},"lib/account-abstraction/contracts/interfaces/IAccount.sol":{"content":"// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.12;\n\nimport \"./UserOperation.sol\";\n\ninterface IAccount {\n\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 able to make the call.\n * The excess is left as a deposit in the entrypoint, for future calls.\n * can be withdrawn anytime using \"entryPoint.withdrawTo()\"\n * In case there is a paymaster in the request (or the current deposit is high enough), this value will be zero.\n * @return validationData packaged ValidationData structure. use `_packValidationData` and `_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 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(UserOperation calldata userOp, bytes32 userOpHash, uint256 missingAccountFunds)\n external returns (uint256 validationData);\n}\n"},"lib/account-abstraction/contracts/interfaces/IPaymaster.sol":{"content":"// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.12;\n\nimport \"./UserOperation.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\n enum PostOpMode {\n opSucceeded, // user op succeeded\n opReverted, // user op reverted. still has to pay for gas.\n postOpReverted //user op succeeded, but caused postOp to revert. Now it's a 2nd call, after user's op was deliberately reverted.\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\n * zero length to signify postOp is not required.\n * @return validationData signature and time-range of this operation, encoded the same as the return value of validateUserOperation\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 * Note that the validation code cannot use block.timestamp (or block.number) directly.\n */\n function validatePaymasterUserOp(UserOperation calldata userOp, bytes32 userOpHash, 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. still has to pay for gas.\n * postOpReverted - user op succeeded, but caused postOp (in mode=opSucceeded) to revert.\n * Now this is the 2nd call, after user's op was deliberately reverted.\n * @param context - the context value returned by validatePaymasterUserOp\n * @param actualGasCost - actual gas used so far (without this postOp call).\n */\n function postOp(PostOpMode mode, bytes calldata context, uint256 actualGasCost) external;\n}\n"},"node_modules/@openzeppelin/contracts/proxy/beacon/IBeacon.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\n\npragma solidity ^0.8.0;\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 * {BeaconProxy} will check that this address is a contract.\n */\n function implementation() external view returns (address);\n}\n"},"node_modules/@openzeppelin/contracts/interfaces/IERC1967.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC1967.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.\n *\n * _Available since v4.8.3._\n */\ninterface IERC1967 {\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"},"node_modules/@openzeppelin/contracts/interfaces/draft-IERC1822.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\n\npragma solidity ^0.8.0;\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"},"node_modules/@openzeppelin/contracts/utils/Address.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n *\n * Furthermore, `isContract` will also return true if the target contract within\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n * which only has an effect at the end of a transaction.\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\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.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\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, it is bubbled up by this\n * function (like regular Solidity function calls).\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 * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\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 * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) 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(errorMessage);\n }\n }\n}\n"},"node_modules/@openzeppelin/contracts/utils/StorageSlot.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/StorageSlot.sol)\n// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.\n\npragma solidity ^0.8.0;\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(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, `uint256`._\n * _Available since v4.9 for `string`, `bytes`._\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"},"node_modules/@openzeppelin/contracts/token/ERC777/IERC777Recipient.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC777/IERC777Recipient.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC777TokensRecipient standard as defined in the EIP.\n *\n * Accounts can be notified of {IERC777} tokens being sent to them by having a\n * contract implement this interface (contract holders can be their own\n * implementer) and registering it on the\n * https://eips.ethereum.org/EIPS/eip-1820[ERC1820 global registry].\n *\n * See {IERC1820Registry} and {ERC1820Implementer}.\n */\ninterface IERC777Recipient {\n /**\n * @dev Called by an {IERC777} token contract whenever tokens are being\n * moved or created into a registered account (`to`). The type of operation\n * is conveyed by `from` being the zero address or not.\n *\n * This call occurs _after_ the token contract's state is updated, so\n * {IERC777-balanceOf}, etc., can be used to query the post-operation state.\n *\n * This function may revert to prevent the operation from being executed.\n */\n function tokensReceived(\n address operator,\n address from,\n address to,\n uint256 amount,\n bytes calldata userData,\n bytes calldata operatorData\n ) external;\n}\n"},"node_modules/@openzeppelin/contracts-upgradeable/proxy/beacon/IBeaconUpgradeable.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\n */\ninterface IBeaconUpgradeable {\n /**\n * @dev Must return an address that can be used as a delegate call target.\n *\n * {BeaconProxy} will check that this address is a contract.\n */\n function implementation() external view returns (address);\n}\n"},"node_modules/@openzeppelin/contracts-upgradeable/interfaces/IERC1967Upgradeable.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC1967.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.\n *\n * _Available since v4.8.3._\n */\ninterface IERC1967Upgradeable {\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"},"node_modules/@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n *\n * Furthermore, `isContract` will also return true if the target contract within\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n * which only has an effect at the end of a transaction.\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\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.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\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, it is bubbled up by this\n * function (like regular Solidity function calls).\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 * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\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 * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) 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(errorMessage);\n }\n }\n}\n"},"node_modules/@openzeppelin/contracts-upgradeable/utils/StorageSlotUpgradeable.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/StorageSlot.sol)\n// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.\n\npragma solidity ^0.8.0;\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(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, `uint256`._\n * _Available since v4.9 for `string`, `bytes`._\n */\nlibrary StorageSlotUpgradeable {\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"},"node_modules/@openzeppelin/contracts/utils/math/Math.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n enum Rounding {\n Down, // Toward negative infinity\n Up, // Toward infinity\n Zero // Toward zero\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 up instead\n * of rounding down.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\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 denominator == 0\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n * with further edits by 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; // 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 prod0 := mul(x, y)\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 require(denominator > prod1, \"Math: mulDiv overflow\");\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. Always >= 1.\n // See https://cs.stackexchange.com/q/138556/92363.\n\n // Does not overflow because the denominator cannot be zero at this stage in the function.\n uint256 twos = denominator & (~denominator + 1);\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 works\n // 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 (rounding == Rounding.Up && 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 down.\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 + (rounding == Rounding.Up && result * result < a ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 2, rounded down, of a positive value.\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 + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 10, rounded down, of a positive value.\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 + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 256, rounded down, of a positive value.\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 + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);\n }\n }\n}\n"},"node_modules/@openzeppelin/contracts/utils/math/SignedMath.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)\n\npragma solidity ^0.8.0;\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"}},"settings":{"remappings":["@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/","@openzeppelin/contracts-upgradeable/=node_modules/@openzeppelin/contracts-upgradeable/","@account-abstraction/=lib/account-abstraction/","@modular-account-libs/=node_modules/@modular-account-libs/src/","@solady/=node_modules/solady/src/","@fcl/=node_modules/fcl/solidity/src/","forge-std/=node_modules/forge-std/"],"optimizer":{"enabled":true,"runs":200},"metadata":{"useLiteralContent":false,"bytecodeHash":"ipfs","appendCBOR":true},"outputSelection":{"*":{"*":["abi","evm.bytecode.object","evm.bytecode.sourceMap","evm.bytecode.linkReferences","evm.deployedBytecode.object","evm.deployedBytecode.sourceMap","evm.deployedBytecode.linkReferences","evm.deployedBytecode.immutableReferences","evm.methodIdentifiers","metadata"]}},"evmVersion":"paris","viaIR":true,"libraries":{}}} diff --git a/script/verify/SingleOwnerMSCA/0xd206ac7fef53d83ed4563e770b28dba90d0d9ec8/abiEncodedConstructorArgs b/script/verify/SingleOwnerMSCA/0xd206ac7fef53d83ed4563e770b28dba90d0d9ec8/abiEncodedConstructorArgs new file mode 100644 index 0000000..04ff399 --- /dev/null +++ b/script/verify/SingleOwnerMSCA/0xd206ac7fef53d83ed4563e770b28dba90d0d9ec8/abiEncodedConstructorArgs @@ -0,0 +1 @@ +0000000000000000000000005ff137d4b0fdcd49dca30c7cf57e578a026d2789000000000000000000000000c93d6559fe4db59742751a857d11a04861a50ccc diff --git a/script/verify/SingleOwnerMSCA/ERC1967Proxy/ERC1967Proxy.json b/script/verify/SingleOwnerMSCA/0xeF3d10Df6e8eeAa925dA46ea12a6F17aB7F43B70/ERC1967Proxy/ERC1967Proxy.json similarity index 100% rename from script/verify/SingleOwnerMSCA/ERC1967Proxy/ERC1967Proxy.json rename to script/verify/SingleOwnerMSCA/0xeF3d10Df6e8eeAa925dA46ea12a6F17aB7F43B70/ERC1967Proxy/ERC1967Proxy.json diff --git a/script/verify/SingleOwnerMSCA/ERC1967Proxy/abiEncodedConstructorArgs b/script/verify/SingleOwnerMSCA/0xeF3d10Df6e8eeAa925dA46ea12a6F17aB7F43B70/ERC1967Proxy/abiEncodedConstructorArgs similarity index 100% rename from script/verify/SingleOwnerMSCA/ERC1967Proxy/abiEncodedConstructorArgs rename to script/verify/SingleOwnerMSCA/0xeF3d10Df6e8eeAa925dA46ea12a6F17aB7F43B70/ERC1967Proxy/abiEncodedConstructorArgs diff --git a/script/verify/SingleOwnerMSCA/SingleOwnerMSCA.json b/script/verify/SingleOwnerMSCA/0xeF3d10Df6e8eeAa925dA46ea12a6F17aB7F43B70/SingleOwnerMSCA.json similarity index 100% rename from script/verify/SingleOwnerMSCA/SingleOwnerMSCA.json rename to script/verify/SingleOwnerMSCA/0xeF3d10Df6e8eeAa925dA46ea12a6F17aB7F43B70/SingleOwnerMSCA.json diff --git a/script/verify/SingleOwnerMSCA/abiEncodedConstructorArgs b/script/verify/SingleOwnerMSCA/0xeF3d10Df6e8eeAa925dA46ea12a6F17aB7F43B70/abiEncodedConstructorArgs similarity index 100% rename from script/verify/SingleOwnerMSCA/abiEncodedConstructorArgs rename to script/verify/SingleOwnerMSCA/0xeF3d10Df6e8eeAa925dA46ea12a6F17aB7F43B70/abiEncodedConstructorArgs diff --git a/script/verify/SingleOwnerMSCAFactory/SingleOwnerMSCAFactory.json b/script/verify/SingleOwnerMSCAFactory/0xa233b124D7b9CFF2D38cB62319e1A3f79144B490/SingleOwnerMSCAFactory.json similarity index 100% rename from script/verify/SingleOwnerMSCAFactory/SingleOwnerMSCAFactory.json rename to script/verify/SingleOwnerMSCAFactory/0xa233b124D7b9CFF2D38cB62319e1A3f79144B490/SingleOwnerMSCAFactory.json diff --git a/script/verify/SingleOwnerMSCAFactory/abiEncodedConstructorArgs b/script/verify/SingleOwnerMSCAFactory/0xa233b124D7b9CFF2D38cB62319e1A3f79144B490/abiEncodedConstructorArgs similarity index 100% rename from script/verify/SingleOwnerMSCAFactory/abiEncodedConstructorArgs rename to script/verify/SingleOwnerMSCAFactory/0xa233b124D7b9CFF2D38cB62319e1A3f79144B490/abiEncodedConstructorArgs diff --git a/script/verify/SingleOwnerMSCAFactory/0xf61023061ed45fa9eAC4D2670649cE1FD37ce536/SingleOwnerMSCAFactory.json b/script/verify/SingleOwnerMSCAFactory/0xf61023061ed45fa9eAC4D2670649cE1FD37ce536/SingleOwnerMSCAFactory.json new file mode 100644 index 0000000..4040ac6 --- /dev/null +++ b/script/verify/SingleOwnerMSCAFactory/0xf61023061ed45fa9eAC4D2670649cE1FD37ce536/SingleOwnerMSCAFactory.json @@ -0,0 +1 @@ +{"language":"Solidity","sources":{"src/msca/6900/v0.7/factories/semi/SingleOwnerMSCAFactory.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\nimport {Create2FailedDeployment, InvalidInitializationInput} from \"../../../shared/common/Errors.sol\";\nimport {SingleOwnerMSCA} from \"../../account/semi/SingleOwnerMSCA.sol\";\nimport {PluginManager} from \"../../managers/PluginManager.sol\";\nimport {IEntryPoint} from \"@account-abstraction/contracts/interfaces/IEntryPoint.sol\";\nimport {ERC1967Proxy} from \"@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol\";\nimport {Create2} from \"@openzeppelin/contracts/utils/Create2.sol\";\n\n/**\n * @dev Account factory that creates the semi-MSCA that enshrines single owner into the account storage.\n * No plugin installation is required during account creation.\n */\ncontract SingleOwnerMSCAFactory {\n // logic implementation\n SingleOwnerMSCA public immutable ACCOUNT_IMPLEMENTATION;\n IEntryPoint public immutable ENTRY_POINT;\n\n event FactoryDeployed(address indexed factory, address accountImplementation, address entryPoint);\n event AccountCreated(address indexed proxy, address sender, bytes32 salt);\n\n /**\n * @dev Salted deterministic deployment using create2 and a specific logic SingleOwnerMSCA implementation.\n * Tx/userOp is either gated by userOpValidationFunction or runtimeValidationFunction, and SingleOwnerMSCA\n * is a minimum account with a pre built-in owner validation, so we do not require the user to install any\n * plugins\n * during the deployment. No hooks can be injected during the account deployment, so for a future installation\n * of more complicated plugins, please call installPlugin via a separate tx/userOp after account deployment.\n */\n constructor(address _entryPointAddr, address _pluginManagerAddr) {\n ENTRY_POINT = IEntryPoint(_entryPointAddr);\n PluginManager _pluginManager = PluginManager(_pluginManagerAddr);\n ACCOUNT_IMPLEMENTATION = new SingleOwnerMSCA(ENTRY_POINT, _pluginManager);\n emit FactoryDeployed(address(this), address(ACCOUNT_IMPLEMENTATION), _entryPointAddr);\n }\n\n /**\n * @dev Salted deterministic deployment using create2 and a specific logic SingleOwnerMSCA implementation.\n * Tx/userOp is either gated by userOpValidationFunction or runtimeValidationFunction, and SingleOwnerMSCA\n * is a minimum account with a pre built-in owner validation, so we do not require the user to install any\n * plugins\n * during the deployment. No hooks can be injected during the account deployment, so for a future installation\n * of more complicated plugins, please call installPlugin via a separate tx/userOp after account deployment.\n * @param _sender sender of the account deployment tx, it could be set to owner. If you don't have the owner\n * information during account creation,\n * please use something unique, consistent and private to yourself. In the context of single owner\n * semi-MSCA, this field is mostly\n * for consistency because we also use owner to mix the salt.\n * @param _salt salt that allows for deterministic deployment\n * @param _initializingData abi.encode(address), address should not be zero\n */\n function createAccount(address _sender, bytes32 _salt, bytes memory _initializingData)\n public\n returns (SingleOwnerMSCA account)\n {\n address owner = abi.decode(_initializingData, (address));\n (address counterfactualAddr, bytes32 mixedSalt) = _getAddress(_sender, _salt, owner);\n if (counterfactualAddr.code.length > 0) {\n return SingleOwnerMSCA(payable(counterfactualAddr));\n }\n // only perform implementation upgrade by setting empty _data in ERC1967Proxy\n // meanwhile we also initialize proxy storage, which calls PluginManager._installPlugin directly to bypass\n // validateNativeFunction checks\n account = SingleOwnerMSCA(\n payable(\n new ERC1967Proxy{salt: mixedSalt}(\n address(ACCOUNT_IMPLEMENTATION), abi.encodeCall(SingleOwnerMSCA.initializeSingleOwnerMSCA, (owner))\n )\n )\n );\n if (address(account) != counterfactualAddr) {\n revert Create2FailedDeployment();\n }\n emit AccountCreated(counterfactualAddr, _sender, _salt);\n }\n\n /**\n * @dev Pre-compute the counterfactual address prior to calling createAccount.\n * After decoding, owner is used in salt, byteCodeHash and func init call to minimize the front-running risk.\n * @param _sender sender of the account deployment tx, it could be set to owner. If you don't have the owner\n * information during account creation,\n * please use something unique, consistent and private to yourself. In the context of single owner\n * semi-MSCA, this field is mostly\n * for consistency because we also use owner to mix the salt.\n * @param _salt salt that allows for deterministic deployment\n * @param _initializingData abi.encode(address), address should not be zero\n */\n function getAddress(address _sender, bytes32 _salt, bytes memory _initializingData)\n public\n view\n returns (address addr, bytes32 mixedSalt)\n {\n address owner = abi.decode(_initializingData, (address));\n return _getAddress(_sender, _salt, owner);\n }\n\n /**\n * @dev Pre-compute the counterfactual address prior to calling createAccount.\n * After decoding, owner is used in salt, byteCodeHash and func init call to minimize the front-running risk.\n * @param _sender sender of the account deployment tx, it could be set to owner. If you don't have the owner\n * information during account creation,\n * please use something unique, consistent and private to yourself. In the context of single owner\n * semi-MSCA, this field is mostly\n * for consistency because we also use owner to mix the salt.\n * @param _salt salt that allows for deterministic deployment\n * @param _owner owner of the semi MSCA\n */\n function _getAddress(address _sender, bytes32 _salt, address _owner)\n internal\n view\n returns (address addr, bytes32 mixedSalt)\n {\n if (_owner == address(0)) {\n revert InvalidInitializationInput();\n }\n mixedSalt = keccak256(abi.encodePacked(_sender, _owner, _salt));\n bytes32 code = keccak256(\n abi.encodePacked(\n type(ERC1967Proxy).creationCode,\n abi.encode(\n address(ACCOUNT_IMPLEMENTATION), abi.encodeCall(SingleOwnerMSCA.initializeSingleOwnerMSCA, (_owner))\n )\n )\n );\n addr = Create2.computeAddress(mixedSalt, code, address(this));\n return (addr, mixedSalt);\n }\n}\n"},"src/msca/6900/shared/common/Errors.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\n/**\n * @notice Throws when the selector is not found.\n */\nerror NotFoundSelector();\n\n/**\n * @notice Throws when authorizer is invalid.\n */\nerror InvalidAuthorizer();\n\nerror InvalidValidationFunctionId(uint8 functionId);\n\nerror InvalidFunctionReference();\n\nerror ItemAlreadyExists();\n\nerror ItemDoesNotExist();\n\nerror InvalidLimit();\n\nerror InvalidExecutionFunction(bytes4 selector);\n\nerror InvalidInitializationInput();\n\nerror Create2FailedDeployment();\n\nerror NotImplemented(bytes4 selector, uint8 functionId);\n\nerror InvalidItem();\n\n// v2 NotImplemented\nerror NotImplementedFunction(bytes4 selector, uint32 entityId);\n"},"src/msca/6900/v0.7/account/semi/SingleOwnerMSCA.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\nimport {DefaultCallbackHandler} from \"../../../../../callback/DefaultCallbackHandler.sol\";\n\nimport {\n EIP1271_INVALID_SIGNATURE,\n EIP1271_VALID_SIGNATURE,\n EMPTY_FUNCTION_REFERENCE,\n EMPTY_FUNCTION_REFERENCE,\n SENTINEL_BYTES21,\n SIG_VALIDATION_FAILED,\n SIG_VALIDATION_SUCCEEDED,\n WALLET_VERSION_1\n} from \"../../../../../common/Constants.sol\";\n\nimport {UnauthorizedCaller} from \"../../../../../common/Errors.sol\";\nimport {ExecutionUtils} from \"../../../../../utils/ExecutionUtils.sol\";\nimport {InvalidAuthorizer, InvalidValidationFunctionId, NotFoundSelector} from \"../../../shared/common/Errors.sol\";\nimport {ValidationData} from \"../../../shared/common/Structs.sol\";\nimport {ValidationDataLib} from \"../../../shared/libs/ValidationDataLib.sol\";\nimport {\n PRE_HOOK_ALWAYS_DENY_FUNCTION_REFERENCE,\n RUNTIME_VALIDATION_ALWAYS_ALLOW_FUNCTION_REFERENCE\n} from \"../../common/Constants.sol\";\nimport {ExecutionDetail, FunctionReference, RepeatableBytes21DLL} from \"../../common/Structs.sol\";\nimport {IPlugin} from \"../../interfaces/IPlugin.sol\";\nimport {FunctionReferenceLib} from \"../../libs/FunctionReferenceLib.sol\";\nimport {RepeatableFunctionReferenceDLLLib} from \"../../libs/RepeatableFunctionReferenceDLLLib.sol\";\nimport {WalletStorageV1Lib} from \"../../libs/WalletStorageV1Lib.sol\";\nimport {PluginManager} from \"../../managers/PluginManager.sol\";\nimport {BaseMSCA} from \"../BaseMSCA.sol\";\nimport {IEntryPoint} from \"@account-abstraction/contracts/interfaces/IEntryPoint.sol\";\nimport {UserOperation} from \"@account-abstraction/contracts/interfaces/UserOperation.sol\";\nimport {UUPSUpgradeable} from \"@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol\";\nimport {IERC1271} from \"@openzeppelin/contracts/interfaces/IERC1271.sol\";\n\nimport {IERC1155Receiver} from \"@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol\";\nimport {IERC721Receiver} from \"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\";\nimport {ECDSA} from \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\n\nimport {BaseERC712CompliantAccount} from \"../../../../../erc712/BaseERC712CompliantAccount.sol\";\nimport {SignatureChecker} from \"@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol\";\n\n/**\n * @dev Semi-MSCA that enshrines single owner into the account storage.\n */\ncontract SingleOwnerMSCA is BaseMSCA, DefaultCallbackHandler, UUPSUpgradeable, IERC1271, BaseERC712CompliantAccount {\n using ExecutionUtils for address;\n using ECDSA for bytes32;\n using RepeatableFunctionReferenceDLLLib for RepeatableBytes21DLL;\n using FunctionReferenceLib for bytes21;\n using FunctionReferenceLib for FunctionReference;\n using ValidationDataLib for ValidationData;\n\n enum FunctionId {\n NATIVE_RUNTIME_VALIDATION_OWNER_OR_SELF,\n NATIVE_USER_OP_VALIDATION_OWNER\n }\n\n string public constant NAME = \"Circle_SingleOwnerMSCA\";\n bytes32 private constant _HASHED_NAME = keccak256(bytes(NAME));\n bytes32 private constant _HASHED_VERSION = keccak256(bytes(WALLET_VERSION_1));\n bytes32 private constant _MESSAGE_TYPEHASH = keccak256(\"CircleSingleOwnerMSCAMessage(bytes32 hash)\");\n\n event SingleOwnerMSCAInitialized(address indexed account, address indexed entryPointAddress, address owner);\n event OwnershipTransferred(address indexed account, address indexed previousOwner, address indexed newOwner);\n\n error InvalidOwnerForMSCA(address account, address owner);\n error NoOwnershipPluginDefined();\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyFromEntryPointOrOwnerOrSelf() {\n _checkFromEPOrOwnerOrSelf();\n _;\n }\n\n constructor(IEntryPoint _newEntryPoint, PluginManager _newPluginManager)\n BaseMSCA(_newEntryPoint, _newPluginManager)\n {}\n\n /// @notice Initializes the account with a set of plugins\n /// @dev No dependencies or hooks can be injected with this installation. For a full installation, please use\n /// installPlugin.\n /// @param owner The initial owner\n function initializeSingleOwnerMSCA(address owner) external walletStorageInitializer {\n if (owner == address(0)) {\n revert InvalidOwnerForMSCA(address(this), owner);\n }\n _transferNativeOwnership(owner);\n emit SingleOwnerMSCAInitialized(address(this), address(ENTRY_POINT), owner);\n }\n\n /// @inheritdoc IERC1271\n function isValidSignature(bytes32 hash, bytes memory signature) external view override returns (bytes4) {\n address owner = WalletStorageV1Lib.getLayout().owner;\n if (owner == address(0)) {\n ExecutionDetail storage executionDetail =\n WalletStorageV1Lib.getLayout().executionDetails[IERC1271.isValidSignature.selector];\n // this is a sanity check only, as using address(0) as a plugin is not permitted during installation\n if (executionDetail.plugin == address(0)) {\n return EIP1271_INVALID_SIGNATURE;\n }\n // isValidSignature is installed via plugin, so it should fallback to the plugin\n (bool success, bytes memory returnData) =\n executionDetail.plugin.staticcall(abi.encodeCall(IERC1271.isValidSignature, (hash, signature)));\n if (!success) {\n return EIP1271_INVALID_SIGNATURE;\n }\n return abi.decode(returnData, (bytes4));\n } else {\n // use address(this) to prevent replay attacks\n bytes32 replaySafeHash = getReplaySafeMessageHash(hash);\n if (SignatureChecker.isValidSignatureNow(owner, replaySafeHash, signature)) {\n return EIP1271_VALID_SIGNATURE;\n }\n return EIP1271_INVALID_SIGNATURE;\n }\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current msg.sender.\n */\n function transferNativeOwnership(address newOwner) public onlyFromEntryPointOrOwnerOrSelf validateNativeFunction {\n if (newOwner == address(0)) {\n revert InvalidOwnerForMSCA(address(this), newOwner);\n }\n _transferNativeOwnership(newOwner);\n }\n\n /**\n * @dev Leaves the contract without owner. Can only be initiated by the current owner.\n *\n * NOTE: Irreversible. Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner. Please\n * make sure you've already have other backup validations before calling this method.\n * If the user wants to switch to the validations provided by plugins, please call this\n * function after you install the plugin, so owner will be disabled.\n */\n function renounceNativeOwnership() public onlyFromEntryPointOrOwnerOrSelf validateNativeFunction {\n // we need a ownership plugin in place before renouncing native ownership\n if (WalletStorageV1Lib.getLayout().executionDetails[IERC1271.isValidSignature.selector].plugin == address(0)) {\n revert NoOwnershipPluginDefined();\n }\n _transferNativeOwnership(address(0));\n }\n\n /**\n * @dev Returns the current owner.\n */\n function getNativeOwner() public view returns (address) {\n return WalletStorageV1Lib.getLayout().owner;\n }\n\n function supportsInterface(bytes4 interfaceId)\n public\n view\n override(BaseMSCA, DefaultCallbackHandler)\n returns (bool)\n {\n // BaseMSCA has already implemented ERC165\n return BaseMSCA.supportsInterface(interfaceId) || interfaceId == type(IERC721Receiver).interfaceId\n || interfaceId == type(IERC1155Receiver).interfaceId || interfaceId == type(IERC1271).interfaceId;\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferNativeOwnership(address newOwner) internal {\n address oldOwner = WalletStorageV1Lib.getLayout().owner;\n WalletStorageV1Lib.getLayout().owner = newOwner;\n emit OwnershipTransferred(address(this), oldOwner, newOwner);\n }\n\n /**\n * @dev We run the native validation function if it's enabled, otherwise we fallback to the plugin validation\n * functions.\n * In either case, we run the hooks from plugins if there's any.\n */\n function _authenticateAndAuthorizeUserOp(UserOperation calldata userOp, bytes32 userOpHash)\n internal\n override\n returns (uint256 validationData)\n {\n // onlyFromEntryPoint is applied in the caller\n // if there is no function defined for the selector, or if userOp.callData.length < 4, then execution MUST\n // revert\n if (userOp.callData.length < 4) {\n revert NotFoundSelector();\n }\n bytes4 selector = bytes4(userOp.callData[0:4]);\n if (selector == bytes4(0)) {\n revert NotFoundSelector();\n }\n ExecutionDetail storage executionDetail = WalletStorageV1Lib.getLayout().executionDetails[selector];\n // check validation function for non native case first\n FunctionReference memory validationFunction = executionDetail.userOpValidationFunction;\n address owner = WalletStorageV1Lib.getLayout().owner;\n if (owner == address(0)) {\n bytes21 packedValidationFunction = validationFunction.pack();\n if (\n packedValidationFunction == EMPTY_FUNCTION_REFERENCE\n || packedValidationFunction == RUNTIME_VALIDATION_ALWAYS_ALLOW_FUNCTION_REFERENCE\n || packedValidationFunction == PRE_HOOK_ALWAYS_DENY_FUNCTION_REFERENCE\n ) {\n revert InvalidValidationFunctionId(validationFunction.functionId);\n }\n }\n // pre hook\n ValidationData memory unpackedValidationData =\n _processPreUserOpValidationHooks(executionDetail, userOp, userOpHash);\n uint256 currentValidationData;\n // userOp validation\n // no native validation function\n if (owner == address(0)) {\n IPlugin userOpValidatorPlugin = IPlugin(validationFunction.plugin);\n // execute the validation function with the user operation and its hash as parameters using the call opcode\n currentValidationData = userOpValidatorPlugin.userOpValidationFunction(\n executionDetail.userOpValidationFunction.functionId, userOp, userOpHash\n );\n } else {\n if (SignatureChecker.isValidSignatureNow(owner, userOpHash.toEthSignedMessageHash(), userOp.signature)) {\n currentValidationData = SIG_VALIDATION_SUCCEEDED;\n } else {\n currentValidationData = SIG_VALIDATION_FAILED;\n }\n }\n\n // intercept with last result\n unpackedValidationData = unpackedValidationData._intersectValidationData(currentValidationData);\n if (unpackedValidationData.authorizer != address(0) && unpackedValidationData.authorizer != address(1)) {\n // only revert on unexpected values\n revert InvalidAuthorizer();\n }\n validationData = unpackedValidationData._packValidationData();\n }\n\n function _processPreRuntimeHooksAndValidation(bytes4 selector) internal override {\n if (msg.sender == address(ENTRY_POINT)) {\n // ENTRY_POINT should go through validateUserOp flow which calls userOpValidationFunction\n return;\n }\n ExecutionDetail storage executionDetail = WalletStorageV1Lib.getLayout().executionDetails[selector];\n FunctionReference memory validationFunction = executionDetail.runtimeValidationFunction;\n RepeatableBytes21DLL storage preRuntimeValidationHooksDLL = executionDetail.preRuntimeValidationHooks;\n uint256 totalUniqueHookCount = preRuntimeValidationHooksDLL.getUniqueItems();\n FunctionReference memory startHook = EMPTY_FUNCTION_REFERENCE.unpack();\n FunctionReference[] memory preRuntimeValidationHooks;\n FunctionReference memory nextHook;\n for (uint256 i = 0; i < totalUniqueHookCount; ++i) {\n (preRuntimeValidationHooks, nextHook) = preRuntimeValidationHooksDLL.getPaginated(startHook, 10);\n for (uint256 j = 0; j < preRuntimeValidationHooks.length; ++j) {\n // revert on EMPTY_FUNCTION_REFERENCE, RUNTIME_VALIDATION_ALWAYS_ALLOW_FUNCTION_REFERENCE,\n // PRE_HOOK_ALWAYS_DENY_FUNCTION_REFERENCE\n // if any revert, the outer call MUST revert\n bytes21 packedPreRuntimeValidationHook = preRuntimeValidationHooks[j].pack();\n if (\n packedPreRuntimeValidationHook == EMPTY_FUNCTION_REFERENCE\n || packedPreRuntimeValidationHook == RUNTIME_VALIDATION_ALWAYS_ALLOW_FUNCTION_REFERENCE\n || packedPreRuntimeValidationHook == PRE_HOOK_ALWAYS_DENY_FUNCTION_REFERENCE\n ) {\n revert InvalidValidationFunctionId(preRuntimeValidationHooks[j].functionId);\n }\n IPlugin preRuntimeValidationHookPlugin = IPlugin(preRuntimeValidationHooks[j].plugin);\n // solhint-disable no-empty-blocks\n try preRuntimeValidationHookPlugin.preRuntimeValidationHook(\n preRuntimeValidationHooks[j].functionId, msg.sender, msg.value, msg.data\n ) {} catch (bytes memory revertReason) {\n revert PreRuntimeValidationHookFailed(\n preRuntimeValidationHooks[j].plugin, preRuntimeValidationHooks[j].functionId, revertReason\n );\n }\n // solhint-enable no-empty-blocks\n }\n if (nextHook.pack() == SENTINEL_BYTES21) {\n break;\n }\n startHook = nextHook;\n }\n address owner = WalletStorageV1Lib.getLayout().owner;\n // no native validation function\n if (owner == address(0)) {\n bytes21 packedValidationFunction = validationFunction.pack();\n if (\n packedValidationFunction == EMPTY_FUNCTION_REFERENCE\n || packedValidationFunction == PRE_HOOK_ALWAYS_DENY_FUNCTION_REFERENCE\n ) {\n revert InvalidValidationFunctionId(validationFunction.functionId);\n }\n // call runtimeValidationFunction if it's not always allowed\n if (packedValidationFunction != RUNTIME_VALIDATION_ALWAYS_ALLOW_FUNCTION_REFERENCE) {\n // solhint-disable no-empty-blocks\n try IPlugin(validationFunction.plugin).runtimeValidationFunction(\n validationFunction.functionId, msg.sender, msg.value, msg.data\n ) {} catch (bytes memory revertReason) {\n revert RuntimeValidationFailed(\n validationFunction.plugin, validationFunction.functionId, revertReason\n );\n }\n // solhint-enable no-empty-blocks\n }\n return;\n } else {\n // the msg.sender should be the owner of the account or itself\n if (msg.sender == owner || msg.sender == address(this)) {\n return;\n } else {\n revert UnauthorizedCaller();\n }\n }\n }\n\n /// @inheritdoc UUPSUpgradeable\n function upgradeTo(address newImplementation) public override onlyProxy validateNativeFunction {\n _authorizeUpgrade(newImplementation);\n _upgradeToAndCallUUPS(newImplementation, new bytes(0), false);\n }\n\n /// @inheritdoc UUPSUpgradeable\n function upgradeToAndCall(address newImplementation, bytes memory data)\n public\n payable\n override\n onlyProxy\n validateNativeFunction\n {\n _authorizeUpgrade(newImplementation);\n _upgradeToAndCallUUPS(newImplementation, data, true);\n }\n\n /**\n * @dev The function is overridden here so more granular ACLs to the upgrade mechanism should be enforced by\n * plugins.\n */\n // solhint-disable-next-line no-empty-blocks\n function _authorizeUpgrade(address newImplementation) internal override {}\n\n function _processPreUserOpValidationHooks(\n ExecutionDetail storage executionDetail,\n UserOperation calldata userOp,\n bytes32 userOpHash\n ) internal override returns (ValidationData memory unpackedValidationData) {\n unpackedValidationData = ValidationData(0, 0xFFFFFFFFFFFF, address(0));\n // if the function selector has associated pre user operation validation hooks, then those hooks MUST be run\n // sequentially\n uint256 totalUniqueHookCount = executionDetail.preUserOpValidationHooks.getUniqueItems();\n FunctionReference memory startHook = EMPTY_FUNCTION_REFERENCE.unpack();\n FunctionReference[] memory preUserOpValidatorHooks;\n FunctionReference memory nextHook;\n uint256 currentValidationData;\n for (uint256 i = 0; i < totalUniqueHookCount; ++i) {\n (preUserOpValidatorHooks, nextHook) = executionDetail.preUserOpValidationHooks.getPaginated(startHook, 10);\n for (uint256 j = 0; j < preUserOpValidatorHooks.length; ++j) {\n bytes21 packedUserOpValidatorHook = preUserOpValidatorHooks[j].pack();\n // if any revert, the outer call MUST revert\n if (\n packedUserOpValidatorHook == EMPTY_FUNCTION_REFERENCE\n || packedUserOpValidatorHook == RUNTIME_VALIDATION_ALWAYS_ALLOW_FUNCTION_REFERENCE\n || packedUserOpValidatorHook == PRE_HOOK_ALWAYS_DENY_FUNCTION_REFERENCE\n ) {\n revert InvalidHookFunctionId(preUserOpValidatorHooks[j].functionId);\n }\n IPlugin preUserOpValidationHookPlugin = IPlugin(preUserOpValidatorHooks[j].plugin);\n currentValidationData = preUserOpValidationHookPlugin.preUserOpValidationHook(\n preUserOpValidatorHooks[j].functionId, userOp, userOpHash\n );\n unpackedValidationData = unpackedValidationData._intersectValidationData(currentValidationData);\n // if any return an authorizer value other than 0 or 1, execution MUST revert\n if (unpackedValidationData.authorizer != address(0) && unpackedValidationData.authorizer != address(1))\n {\n revert InvalidAuthorizer();\n }\n }\n if (nextHook.pack() == SENTINEL_BYTES21) {\n break;\n }\n startHook = nextHook;\n }\n return unpackedValidationData;\n }\n\n function _checkFromEPOrOwnerOrSelf() internal view {\n // all need to go through validation first, which means being initiated by the owner or account\n if (\n msg.sender != address(ENTRY_POINT) && msg.sender != WalletStorageV1Lib.getLayout().owner\n && msg.sender != address(this)\n ) {\n revert UnauthorizedCaller();\n }\n }\n\n /// @inheritdoc BaseERC712CompliantAccount\n function _getAccountTypeHash() internal pure override returns (bytes32) {\n return _MESSAGE_TYPEHASH;\n }\n\n /// @inheritdoc BaseERC712CompliantAccount\n function _getAccountName() internal pure override returns (bytes32) {\n return _HASHED_NAME;\n }\n\n /// @inheritdoc BaseERC712CompliantAccount\n function _getAccountVersion() internal pure override returns (bytes32) {\n return _HASHED_VERSION;\n }\n}\n"},"src/msca/6900/v0.7/managers/PluginManager.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\nimport {EMPTY_FUNCTION_REFERENCE} from \"../../../../common/Constants.sol\";\nimport {InvalidFunctionReference} from \"../../shared/common/Errors.sol\";\nimport {AddressDLL} from \"../../shared/common/Structs.sol\";\nimport {AddressDLLLib} from \"../../shared/libs/AddressDLLLib.sol\";\nimport {\n PRE_HOOK_ALWAYS_DENY_FUNCTION_REFERENCE,\n RUNTIME_VALIDATION_ALWAYS_ALLOW_FUNCTION_REFERENCE\n} from \"../common/Constants.sol\";\nimport {\n ManifestAssociatedFunctionType,\n ManifestExecutionHook,\n ManifestExternalCallPermission,\n ManifestFunction,\n PluginManifest\n} from \"../common/PluginManifest.sol\";\nimport {\n Bytes21DLL,\n FunctionReference,\n HookGroup,\n PermittedExternalCall,\n RepeatableBytes21DLL\n} from \"../common/Structs.sol\";\nimport {IPlugin} from \"../interfaces/IPlugin.sol\";\nimport {FunctionReferenceDLLLib} from \"../libs/FunctionReferenceDLLLib.sol\";\nimport {FunctionReferenceLib} from \"../libs/FunctionReferenceLib.sol\";\nimport {RepeatableFunctionReferenceDLLLib} from \"../libs/RepeatableFunctionReferenceDLLLib.sol\";\nimport {SelectorRegistryLib} from \"../libs/SelectorRegistryLib.sol\";\nimport {WalletStorageV1Lib} from \"../libs/WalletStorageV1Lib.sol\";\nimport {ERC165Checker} from \"@openzeppelin/contracts/utils/introspection/ERC165Checker.sol\";\n\n/**\n * @dev Default implementation of https://eips.ethereum.org/EIPS/eip-6900. MSCAs must implement this interface to\n * support installing and uninstalling plugins.\n */\ncontract PluginManager {\n using AddressDLLLib for AddressDLL;\n using FunctionReferenceDLLLib for Bytes21DLL;\n using RepeatableFunctionReferenceDLLLib for RepeatableBytes21DLL;\n using FunctionReferenceLib for FunctionReference;\n using FunctionReferenceLib for bytes21;\n using SelectorRegistryLib for bytes4;\n\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment\n address private immutable SELF = address(this);\n\n enum AssociatedFunctionType {\n HOOK,\n VALIDATION_FUNCTION\n }\n\n error PluginNotImplementInterface();\n error InvalidPluginManifest();\n error InvalidPluginManifestHash();\n error InvalidPluginDependency(address plugin);\n error PluginUsedByOthers(address plugin);\n error ExecutionDetailAlreadySet(address plugin, bytes4 selector);\n error ExecuteFromPluginExternalAlreadySet(address plugin, address externalAddress);\n error ExecuteFromPluginExternalAlreadyUnset(address plugin, address externalAddress);\n error ValidationFunctionAlreadySet(bytes4 selector);\n error FailToCallOnInstall(address plugin, bytes revertReason);\n error OnlyDelegated();\n error HookDependencyNotPermitted();\n error InvalidExecutionSelector(address plugin, bytes4 selector);\n\n modifier onlyDelegated() {\n if (address(this) == SELF) {\n revert OnlyDelegated();\n }\n _;\n }\n\n /// @dev Refer to IPluginManager\n function install(\n address plugin,\n bytes32 manifestHash,\n bytes memory pluginInstallData,\n FunctionReference[] memory dependencies,\n address msca\n ) external onlyDelegated {\n // revert if the plugin does not implement ERC-165 or does not support the IPlugin interface\n if (!ERC165Checker.supportsInterface(plugin, type(IPlugin).interfaceId)) {\n revert PluginNotImplementInterface();\n }\n WalletStorageV1Lib.Layout storage storageLayout = WalletStorageV1Lib.getLayout();\n // revert internally if the plugin has already been installed on the modular account\n storageLayout.installedPlugins.append(plugin);\n IPlugin pluginToInstall = IPlugin(plugin);\n // revert if manifestHash does not match the computed Keccak-256 hash of the plugin’s returned manifest\n PluginManifest memory pluginManifest = pluginToInstall.pluginManifest();\n if (manifestHash != keccak256(abi.encode(pluginManifest))) {\n revert InvalidPluginManifestHash();\n }\n uint256 length = pluginManifest.interfaceIds.length;\n for (uint256 i = 0; i < length; ++i) {\n storageLayout.supportedInterfaces[pluginManifest.interfaceIds[i]] += 1;\n }\n // revert if any address in dependencies does not support the interface at its matching index in the manifest’s\n // dependencyInterfaceIds,\n // or if the two array lengths do not match,\n // or if any of the dependencies are not already installed on the modular account\n length = dependencies.length;\n if (length != pluginManifest.dependencyInterfaceIds.length) {\n revert InvalidPluginDependency(plugin);\n }\n for (uint256 i = 0; i < length; ++i) {\n address dependencyPluginAddr = dependencies[i].plugin;\n // if dependencyPluginAddr is msca address, then we don't actually introduce any new plugin dependency\n // other than native dependency, so we do not need to perform any plugin dependency related logic\n if (dependencyPluginAddr == msca) {\n continue;\n }\n // verify that the dependency is installed, which also prevents self-dependencies\n if (storageLayout.pluginDetails[dependencyPluginAddr].manifestHash == bytes32(0)) {\n revert InvalidPluginDependency(dependencyPluginAddr);\n }\n if (!ERC165Checker.supportsInterface(dependencyPluginAddr, pluginManifest.dependencyInterfaceIds[i])) {\n revert InvalidPluginDependency(dependencyPluginAddr);\n }\n // each dependency’s record MUST also be updated to reflect that it has a new dependent\n // record the plugin dependency, will revert if it's already installed\n storageLayout.pluginDetails[plugin].dependencies.append(dependencies[i]);\n // increment the dependency's dependentCounter since the current plugin is dependent on dependencyPlugin\n storageLayout.pluginDetails[dependencyPluginAddr].dependentCounter += 1;\n }\n\n // record if this plugin is allowed to spend native token\n if (pluginManifest.canSpendNativeToken) {\n storageLayout.pluginDetails[plugin].canSpendNativeToken = true;\n }\n\n // record execution details\n //////////////////////////////////////////////\n // install execution functions and hooks\n //////////////////////////////////////////////\n length = pluginManifest.executionFunctions.length;\n for (uint256 i = 0; i < length; ++i) {\n bytes4 selector = pluginManifest.executionFunctions[i];\n if (storageLayout.executionDetails[selector].plugin != address(0)) {\n revert ExecutionDetailAlreadySet(plugin, selector);\n }\n if (\n selector._isNativeFunctionSelector() || selector._isErc4337FunctionSelector()\n || selector._isIPluginFunctionSelector()\n ) {\n revert InvalidExecutionSelector(plugin, selector);\n }\n storageLayout.executionDetails[selector].plugin = plugin;\n }\n\n // install pre and post execution hooks\n length = pluginManifest.executionHooks.length;\n for (uint256 i = 0; i < length; ++i) {\n bytes4 selector = pluginManifest.executionHooks[i].selector;\n FunctionReference memory preExecHook = _resolveManifestFunction(\n pluginManifest.executionHooks[i].preExecHook,\n plugin,\n dependencies,\n ManifestAssociatedFunctionType.PRE_HOOK_ALWAYS_DENY,\n AssociatedFunctionType.HOOK\n );\n FunctionReference memory postExecHook = _resolveManifestFunction(\n pluginManifest.executionHooks[i].postExecHook,\n plugin,\n dependencies,\n ManifestAssociatedFunctionType.NONE,\n AssociatedFunctionType.HOOK\n );\n _addHookGroup(storageLayout.executionDetails[selector].executionHooks, preExecHook, postExecHook);\n }\n\n //////////////////////////////////////////////\n // install validation functions and hooks\n //////////////////////////////////////////////\n // install userOpValidationFunctions\n length = pluginManifest.userOpValidationFunctions.length;\n for (uint256 i = 0; i < length; ++i) {\n bytes4 selector = pluginManifest.userOpValidationFunctions[i].executionSelector;\n if (storageLayout.executionDetails[selector].userOpValidationFunction.pack() != EMPTY_FUNCTION_REFERENCE) {\n revert ValidationFunctionAlreadySet(selector);\n }\n storageLayout.executionDetails[selector].userOpValidationFunction = _resolveManifestFunction(\n pluginManifest.userOpValidationFunctions[i].associatedFunction,\n plugin,\n dependencies,\n ManifestAssociatedFunctionType.NONE,\n AssociatedFunctionType.VALIDATION_FUNCTION\n );\n }\n // install runtimeValidationFunctions\n length = pluginManifest.runtimeValidationFunctions.length;\n for (uint256 i = 0; i < length; ++i) {\n bytes4 selector = pluginManifest.runtimeValidationFunctions[i].executionSelector;\n if (storageLayout.executionDetails[selector].runtimeValidationFunction.pack() != EMPTY_FUNCTION_REFERENCE) {\n revert ValidationFunctionAlreadySet(selector);\n }\n storageLayout.executionDetails[selector].runtimeValidationFunction = _resolveManifestFunction(\n pluginManifest.runtimeValidationFunctions[i].associatedFunction,\n plugin,\n dependencies,\n ManifestAssociatedFunctionType.RUNTIME_VALIDATION_ALWAYS_ALLOW, // risk burning gas from the account\n AssociatedFunctionType.VALIDATION_FUNCTION\n );\n }\n // install preUserOpValidationHooks\n length = pluginManifest.preUserOpValidationHooks.length;\n // force override to be safe\n FunctionReference[] memory emptyDependencies = new FunctionReference[](0);\n for (uint256 i = 0; i < length; ++i) {\n bytes4 selector = pluginManifest.preUserOpValidationHooks[i].executionSelector;\n // revert internally\n storageLayout.executionDetails[selector].preUserOpValidationHooks.append(\n _resolveManifestFunction(\n pluginManifest.preUserOpValidationHooks[i].associatedFunction,\n plugin,\n emptyDependencies,\n ManifestAssociatedFunctionType.PRE_HOOK_ALWAYS_DENY,\n AssociatedFunctionType.HOOK\n )\n );\n }\n // install preRuntimeValidationHooks\n length = pluginManifest.preRuntimeValidationHooks.length;\n for (uint256 i = 0; i < length; ++i) {\n // revert internally\n storageLayout.executionDetails[pluginManifest.preRuntimeValidationHooks[i].executionSelector]\n .preRuntimeValidationHooks\n .append(\n _resolveManifestFunction(\n pluginManifest.preRuntimeValidationHooks[i].associatedFunction,\n plugin,\n emptyDependencies,\n ManifestAssociatedFunctionType.PRE_HOOK_ALWAYS_DENY,\n AssociatedFunctionType.HOOK\n )\n );\n }\n\n // store the plugin’s permitted function selectors and external contract calls to be able to validate calls\n // to executeFromPlugin and executeFromPluginExternal\n //////////////////////////////////////////////\n // permissions for executeFromPlugin\n //////////////////////////////////////////////\n // native functions or execution functions already installed on the MSCA that this plugin will be able to call\n length = pluginManifest.permittedExecutionSelectors.length;\n for (uint256 i = 0; i < length; ++i) {\n // enable PermittedPluginCall\n storageLayout.permittedPluginCalls[plugin][pluginManifest.permittedExecutionSelectors[i]] = true;\n }\n\n //////////////////////////////////////////////\n // permissions for executeFromPluginExternal\n //////////////////////////////////////////////\n // is the plugin permitted to call any external contracts and selectors\n if (pluginManifest.permitAnyExternalAddress) {\n storageLayout.pluginDetails[plugin].anyExternalAddressPermitted = true;\n } else {\n // more limited access - record external contract calls that this plugin will be able to make\n length = pluginManifest.permittedExternalCalls.length;\n for (uint256 i = 0; i < length; ++i) {\n ManifestExternalCallPermission memory externalCallPermission = pluginManifest.permittedExternalCalls[i];\n PermittedExternalCall storage permittedExternalCall =\n storageLayout.permittedExternalCalls[plugin][externalCallPermission.externalAddress];\n if (permittedExternalCall.addressPermitted) {\n revert ExecuteFromPluginExternalAlreadySet(plugin, externalCallPermission.externalAddress);\n }\n permittedExternalCall.addressPermitted = true;\n if (externalCallPermission.permitAnySelector) {\n permittedExternalCall.anySelector = true;\n } else {\n uint256 permittedExternalCallSelectorsLength = externalCallPermission.selectors.length;\n for (uint256 j = 0; j < permittedExternalCallSelectorsLength; ++j) {\n permittedExternalCall.selectors[externalCallPermission.selectors[j]] = true;\n }\n }\n }\n }\n\n // store the plugin manifest hash at the end, which serves to prevent self-dependencies\n storageLayout.pluginDetails[plugin].manifestHash = manifestHash;\n // call onInstall to initialize plugin data for the modular account\n // solhint-disable-next-line no-empty-blocks\n try IPlugin(plugin).onInstall(pluginInstallData) {}\n catch (bytes memory revertReason) {\n revert FailToCallOnInstall(plugin, revertReason);\n }\n }\n\n /// @dev Refer to IPluginManager\n function uninstall(address plugin, bytes memory config, bytes memory pluginUninstallData)\n external\n onlyDelegated\n returns (bool)\n {\n WalletStorageV1Lib.Layout storage storageLayout = WalletStorageV1Lib.getLayout();\n // revert internally if plugin was not installed before\n storageLayout.installedPlugins.remove(plugin);\n PluginManifest memory pluginManifest;\n if (config.length > 0) {\n // the modular account MAY implement the capability for the manifest to be encoded in the config field as a\n // parameter\n pluginManifest = abi.decode(config, (PluginManifest));\n } else {\n pluginManifest = IPlugin(plugin).pluginManifest();\n }\n // revert if the hash of the manifest used at install time does not match the computed Keccak-256 hash of the\n // plugin’s current manifest\n if (storageLayout.pluginDetails[plugin].manifestHash != keccak256(abi.encode(pluginManifest))) {\n revert InvalidPluginManifestHash();\n }\n // revert if there is at least 1 other installed plugin that depends on validation functions or hooks added by\n // this plugin;\n // plugins used as dependencies must not be uninstalled while dependent plugins exist\n if (storageLayout.pluginDetails[plugin].dependentCounter != 0) {\n revert PluginUsedByOthers(plugin);\n }\n // each dependency’s record SHOULD be updated to reflect that it has no longer has this plugin as a dependent\n _removeDependencies(plugin, storageLayout);\n // remove records for the plugin’s dependencies, injected permitted call hooks, permitted function selectors,\n // and permitted external contract calls\n // uninstall the components in reverse order (by component type) of their installation\n //////////////////////////////////////////////\n // permissions for executeFromPluginExternal\n //////////////////////////////////////////////\n if (pluginManifest.permitAnyExternalAddress) {\n storageLayout.pluginDetails[plugin].anyExternalAddressPermitted = false;\n }\n uint256 length;\n if (!pluginManifest.permitAnyExternalAddress) {\n length = pluginManifest.permittedExternalCalls.length;\n for (uint256 i = 0; i < length; ++i) {\n ManifestExternalCallPermission memory externalCallPermission = pluginManifest.permittedExternalCalls[i];\n PermittedExternalCall storage permittedExternalCall =\n storageLayout.permittedExternalCalls[plugin][externalCallPermission.externalAddress];\n if (!permittedExternalCall.addressPermitted) {\n revert ExecuteFromPluginExternalAlreadyUnset(plugin, externalCallPermission.externalAddress);\n }\n permittedExternalCall.addressPermitted = false;\n if (externalCallPermission.permitAnySelector) {\n permittedExternalCall.anySelector = false;\n } else {\n uint256 permittedExternalCallSelectorsLength = externalCallPermission.selectors.length;\n for (uint256 j = 0; j < permittedExternalCallSelectorsLength; ++j) {\n permittedExternalCall.selectors[externalCallPermission.selectors[j]] = false;\n }\n }\n }\n }\n\n length = pluginManifest.permittedExecutionSelectors.length;\n for (uint256 i = 0; i < length; ++i) {\n // disable PermittedPluginCall\n storageLayout.permittedPluginCalls[plugin][pluginManifest.permittedExecutionSelectors[i]] = false;\n }\n\n //////////////////////////////////////////////\n // uninstall validation functions and hooks\n //////////////////////////////////////////////\n // uninstall preRuntimeValidationHooks\n FunctionReference[] memory emptyDependencies = new FunctionReference[](0);\n length = pluginManifest.preRuntimeValidationHooks.length;\n for (uint256 i = 0; i < length; ++i) {\n // revert internally\n storageLayout.executionDetails[pluginManifest.preRuntimeValidationHooks[i].executionSelector]\n .preRuntimeValidationHooks\n .remove(\n _resolveManifestFunction(\n pluginManifest.preRuntimeValidationHooks[i].associatedFunction,\n plugin,\n emptyDependencies,\n ManifestAssociatedFunctionType.PRE_HOOK_ALWAYS_DENY,\n AssociatedFunctionType.HOOK\n )\n );\n }\n // uninstall preUserOpValidationHooks\n length = pluginManifest.preUserOpValidationHooks.length;\n for (uint256 i = 0; i < length; ++i) {\n // revert internally\n storageLayout.executionDetails[pluginManifest.preUserOpValidationHooks[i].executionSelector]\n .preUserOpValidationHooks\n .remove(\n _resolveManifestFunction(\n pluginManifest.preUserOpValidationHooks[i].associatedFunction,\n plugin,\n emptyDependencies,\n ManifestAssociatedFunctionType.PRE_HOOK_ALWAYS_DENY,\n AssociatedFunctionType.HOOK\n )\n );\n }\n // uninstall runtimeValidationFunctions\n FunctionReference memory emptyFunctionReference = EMPTY_FUNCTION_REFERENCE.unpack();\n length = pluginManifest.runtimeValidationFunctions.length;\n for (uint256 i = 0; i < length; ++i) {\n storageLayout.executionDetails[pluginManifest.runtimeValidationFunctions[i].executionSelector]\n .runtimeValidationFunction = emptyFunctionReference;\n }\n // uninstall userOpValidationFunctions\n length = pluginManifest.userOpValidationFunctions.length;\n for (uint256 i = 0; i < length; ++i) {\n storageLayout.executionDetails[pluginManifest.userOpValidationFunctions[i].executionSelector]\n .userOpValidationFunction = emptyFunctionReference;\n }\n\n //////////////////////////////////////////////\n // uninstall execution functions and hooks\n //////////////////////////////////////////////\n _removeExecutionHooks(plugin, pluginManifest.executionHooks, storageLayout);\n length = pluginManifest.executionFunctions.length;\n for (uint256 i = 0; i < length; ++i) {\n storageLayout.executionDetails[pluginManifest.executionFunctions[i]].plugin = address(0);\n }\n\n length = pluginManifest.interfaceIds.length;\n for (uint256 i = 0; i < length; ++i) {\n storageLayout.supportedInterfaces[pluginManifest.interfaceIds[i]] -= 1;\n }\n // reset all members that are not mappings and also recurse into the members unless they're mappings\n delete storageLayout.pluginDetails[plugin];\n // call the plugin’s onUninstall callback with the data provided in the uninstallData parameter;\n // This serves to clear the plugin state for the modular account;\n // If onUninstall reverts, execution SHOULD continue to allow the uninstall to complete\n bool onUninstallSucceeded = true;\n // solhint-disable-next-line no-empty-blocks\n try IPlugin(plugin).onUninstall(pluginUninstallData) {}\n catch {\n // leave it up to the caller if we want to revert if the plugin storage isn't cleaned up\n onUninstallSucceeded = false;\n }\n return onUninstallSucceeded;\n }\n\n /**\n * @dev Resolve manifest function.\n * For functions of type `ManifestAssociatedFunctionType.DEPENDENCY`, the MSCA MUST find the plugin address\n * of the function at `dependencies[dependencyIndex]` during the call to `installPlugin(config)`.\n * A plugin can no longer use hooks from other plugins to be added on Execution and/or Validation function\n * selectors\n * in its own manifest. We'll revert if hook is provided as dependency from an external plugin.\n * @param allowedMagicValue which magic value (if any) is permissible for the function type to resolve.\n * @param associatedFunctionType the type of associated function, either a validation function or a hook, as opposed\n * to execution functions\n */\n function _resolveManifestFunction(\n ManifestFunction memory manifestFunction,\n address plugin,\n FunctionReference[] memory dependencies,\n ManifestAssociatedFunctionType allowedMagicValue,\n AssociatedFunctionType associatedFunctionType\n ) internal pure returns (FunctionReference memory) {\n // revert if it's hook and provided as dependency\n if (\n associatedFunctionType == AssociatedFunctionType.HOOK\n && manifestFunction.functionType == ManifestAssociatedFunctionType.DEPENDENCY\n ) {\n revert HookDependencyNotPermitted();\n }\n if (manifestFunction.functionType == ManifestAssociatedFunctionType.SELF) {\n return FunctionReference(plugin, manifestFunction.functionId);\n } else if (manifestFunction.functionType == ManifestAssociatedFunctionType.DEPENDENCY) {\n // out of boundary\n if (manifestFunction.dependencyIndex >= dependencies.length) {\n revert InvalidPluginManifest();\n }\n return dependencies[manifestFunction.dependencyIndex];\n } else if (manifestFunction.functionType == ManifestAssociatedFunctionType.RUNTIME_VALIDATION_ALWAYS_ALLOW) {\n if (allowedMagicValue == ManifestAssociatedFunctionType.RUNTIME_VALIDATION_ALWAYS_ALLOW) {\n return RUNTIME_VALIDATION_ALWAYS_ALLOW_FUNCTION_REFERENCE.unpack();\n } else {\n revert InvalidPluginManifest();\n }\n } else if (manifestFunction.functionType == ManifestAssociatedFunctionType.PRE_HOOK_ALWAYS_DENY) {\n if (allowedMagicValue == ManifestAssociatedFunctionType.PRE_HOOK_ALWAYS_DENY) {\n return PRE_HOOK_ALWAYS_DENY_FUNCTION_REFERENCE.unpack();\n } else {\n revert InvalidPluginManifest();\n }\n } else {\n return EMPTY_FUNCTION_REFERENCE.unpack();\n }\n }\n\n function _addHookGroup(\n HookGroup storage hookGroup,\n FunctionReference memory preExecHook,\n FunctionReference memory postExecHook\n ) internal {\n bytes21 packedPreExecHook = preExecHook.pack();\n if (packedPreExecHook == EMPTY_FUNCTION_REFERENCE) {\n if (postExecHook.pack() == EMPTY_FUNCTION_REFERENCE) {\n // pre and post hooks cannot be null at the same time\n revert InvalidFunctionReference();\n }\n hookGroup.postOnlyHooks.append(postExecHook);\n } else {\n hookGroup.preHooks.append(preExecHook);\n if (postExecHook.pack() != EMPTY_FUNCTION_REFERENCE) {\n hookGroup.preToPostHooks[packedPreExecHook].append(postExecHook);\n }\n }\n }\n\n function _removeHookGroup(\n HookGroup storage hookGroup,\n FunctionReference memory preExecHook,\n FunctionReference memory postExecHook\n ) internal {\n bytes21 packedPreExecHook = preExecHook.pack();\n if (packedPreExecHook == EMPTY_FUNCTION_REFERENCE) {\n // pre and post hooks cannot be null at the same time\n hookGroup.postOnlyHooks.remove(postExecHook);\n } else {\n hookGroup.preHooks.remove(preExecHook);\n // remove postExecHook if any\n if (postExecHook.pack() != EMPTY_FUNCTION_REFERENCE) {\n hookGroup.preToPostHooks[packedPreExecHook].remove(postExecHook);\n }\n }\n }\n\n function _removeDependencies(address plugin, WalletStorageV1Lib.Layout storage storageLayout) internal {\n Bytes21DLL storage pluginDependencies = storageLayout.pluginDetails[plugin].dependencies;\n uint256 length = pluginDependencies.size();\n FunctionReference memory startFR = EMPTY_FUNCTION_REFERENCE.unpack();\n FunctionReference[] memory dependencies;\n for (uint256 i = 0; i < length; ++i) {\n // if the max length of dependencies is reached, the loop will break early\n (dependencies, startFR) = pluginDependencies.getPaginated(startFR, 10);\n for (uint256 j = 0; j < dependencies.length; ++j) {\n storageLayout.pluginDetails[dependencies[j].plugin].dependentCounter -= 1;\n storageLayout.pluginDetails[plugin].dependencies.remove(dependencies[j]);\n }\n if (startFR.pack() == EMPTY_FUNCTION_REFERENCE) {\n break;\n }\n }\n }\n\n function _removeExecutionHooks(\n address plugin,\n ManifestExecutionHook[] memory executionHooks,\n WalletStorageV1Lib.Layout storage storageLayout\n ) internal {\n uint256 length = executionHooks.length;\n FunctionReference[] memory dependencies = new FunctionReference[](0);\n for (uint256 i = 0; i < length; ++i) {\n bytes4 selector = executionHooks[i].selector;\n FunctionReference memory preExecHook = _resolveManifestFunction(\n executionHooks[i].preExecHook,\n plugin,\n dependencies,\n ManifestAssociatedFunctionType.PRE_HOOK_ALWAYS_DENY,\n AssociatedFunctionType.HOOK\n );\n FunctionReference memory postExecHookToRemove = _resolveManifestFunction(\n executionHooks[i].postExecHook,\n plugin,\n dependencies,\n ManifestAssociatedFunctionType.NONE,\n AssociatedFunctionType.HOOK\n );\n _removeHookGroup(storageLayout.executionDetails[selector].executionHooks, preExecHook, postExecHookToRemove);\n }\n }\n}\n"},"lib/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.8.12;\n\n/* solhint-disable avoid-low-level-calls */\n/* solhint-disable no-inline-assembly */\n/* solhint-disable reason-string */\n\nimport \"./UserOperation.sol\";\nimport \"./IStakeManager.sol\";\nimport \"./IAggregator.sol\";\nimport \"./INonceManager.sol\";\n\ninterface IEntryPoint is IStakeManager, INonceManager {\n\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, validation and execution).\n */\n event UserOperationEvent(bytes32 indexed userOpHash, address indexed sender, address indexed paymaster, uint256 nonce, bool success, uint256 actualGasCost, uint256 actualGasUsed);\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(bytes32 indexed userOpHash, address indexed sender, address factory, address paymaster);\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(bytes32 indexed userOpHash, address indexed sender, uint256 nonce, bytes revertReason);\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 */\n event SignatureAggregatorChanged(address indexed aggregator);\n\n /**\n * a custom revert error of handleOps, to identify the offending op.\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\n * The string starts with a unique code \"AAmn\", 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 * 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 */\n error FailedOp(uint256 opIndex, string reason);\n\n /**\n * error case when a signature aggregator fails to verify the aggregated signature it had created.\n */\n error SignatureValidationFailed(address aggregator);\n\n /**\n * Successful result from simulateValidation.\n * @param returnInfo gas and time-range returned values\n * @param senderInfo stake information about the sender\n * @param factoryInfo stake information about the factory (if any)\n * @param paymasterInfo stake information about the paymaster (if any)\n */\n error ValidationResult(ReturnInfo returnInfo,\n StakeInfo senderInfo, StakeInfo factoryInfo, StakeInfo paymasterInfo);\n\n /**\n * Successful result from simulateValidation, if the account returns a signature aggregator\n * @param returnInfo gas and time-range returned values\n * @param senderInfo stake information about the sender\n * @param factoryInfo stake information about the factory (if any)\n * @param paymasterInfo stake information about the paymaster (if any)\n * @param aggregatorInfo signature aggregation info (if the account requires signature aggregator)\n * bundler MUST use it to verify the signature, or reject the UserOperation\n */\n error ValidationResultWithAggregation(ReturnInfo returnInfo,\n StakeInfo senderInfo, StakeInfo factoryInfo, StakeInfo paymasterInfo,\n AggregatorStakeInfo aggregatorInfo);\n\n /**\n * return value of getSenderAddress\n */\n error SenderAddressResult(address sender);\n\n /**\n * return value of simulateHandleOp\n */\n error ExecutionResult(uint256 preOpGas, uint256 paid, uint48 validAfter, uint48 validUntil, bool targetSuccess, bytes targetResult);\n\n //UserOps handled, per aggregator\n struct UserOpsPerAggregator {\n UserOperation[] userOps;\n\n // aggregator address\n IAggregator aggregator;\n // aggregated signature\n bytes signature;\n }\n\n /**\n * Execute a batch of UserOperation.\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(UserOperation[] calldata ops, address payable beneficiary) 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 */\n function getUserOpHash(UserOperation calldata userOp) external view returns (bytes32);\n\n /**\n * Simulate a call to account.validateUserOp and paymaster.validatePaymasterUserOp.\n * @dev this method always revert. Successful result is ValidationResult error. other errors are failures.\n * @dev The node must also verify it doesn't use banned opcodes, and that it doesn't reference storage outside the account's data.\n * @param userOp the user operation to validate.\n */\n function simulateValidation(UserOperation calldata userOp) external;\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 sigFailed validateUserOp's (or paymaster's) signature check failed\n * @param validAfter - first timestamp this UserOp is valid (merging account and paymaster time-range)\n * @param validUntil - last timestamp this UserOp is valid (merging account and paymaster time-range)\n * @param paymasterContext returned by validatePaymasterUserOp (to be passed into postOp)\n */\n struct ReturnInfo {\n uint256 preOpGas;\n uint256 prefund;\n bool sigFailed;\n uint48 validAfter;\n uint48 validUntil;\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\n /**\n * simulate full execution of a UserOperation (including both validation and target execution)\n * this method will always revert with \"ExecutionResult\".\n * it performs full validation of the UserOperation, but ignores signature error.\n * an optional target address is called after the userop succeeds, and its value is returned\n * (before the entire call is reverted)\n * Note that in order to collect the the success/failure of the target call, it must be executed\n * with trace enabled to track the emitted events.\n * @param op the UserOperation to simulate\n * @param target if nonzero, a target address to call after userop simulation. If called, the targetSuccess and targetResult\n * are set to the return from that call.\n * @param targetCallData callData to pass to target address\n */\n function simulateHandleOp(UserOperation calldata op, address target, bytes calldata targetCallData) external;\n}\n\n"},"node_modules/@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Proxy.sol\";\nimport \"./ERC1967Upgrade.sol\";\n\n/**\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\n * implementation address that can be changed. This address is stored in storage in the location specified by\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\n * implementation behind the proxy.\n */\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\n /**\n * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\n *\n * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\n * function call, and allows initializing the storage of the proxy like a Solidity constructor.\n */\n constructor(address _logic, bytes memory _data) payable {\n _upgradeToAndCall(_logic, _data, false);\n }\n\n /**\n * @dev Returns the current implementation address.\n */\n function _implementation() internal view virtual override returns (address impl) {\n return ERC1967Upgrade._getImplementation();\n }\n}\n"},"node_modules/@openzeppelin/contracts/utils/Create2.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Create2.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Helper to make usage of the `CREATE2` EVM opcode easier and safer.\n * `CREATE2` can be used to compute in advance the address where a smart\n * contract will be deployed, which allows for interesting new mechanisms known\n * as 'counterfactual interactions'.\n *\n * See the https://eips.ethereum.org/EIPS/eip-1014#motivation[EIP] for more\n * information.\n */\nlibrary Create2 {\n /**\n * @dev Deploys a contract using `CREATE2`. The address where the contract\n * will be deployed can be known in advance via {computeAddress}.\n *\n * The bytecode for a contract can be obtained from Solidity with\n * `type(contractName).creationCode`.\n *\n * Requirements:\n *\n * - `bytecode` must not be empty.\n * - `salt` must have not been used for `bytecode` already.\n * - the factory must have a balance of at least `amount`.\n * - if `amount` is non-zero, `bytecode` must have a `payable` constructor.\n */\n function deploy(uint256 amount, bytes32 salt, bytes memory bytecode) internal returns (address addr) {\n require(address(this).balance >= amount, \"Create2: insufficient balance\");\n require(bytecode.length != 0, \"Create2: bytecode length is zero\");\n /// @solidity memory-safe-assembly\n assembly {\n addr := create2(amount, add(bytecode, 0x20), mload(bytecode), salt)\n }\n require(addr != address(0), \"Create2: Failed on deploy\");\n }\n\n /**\n * @dev Returns the address where a contract will be stored if deployed via {deploy}. Any change in the\n * `bytecodeHash` or `salt` will result in a new destination address.\n */\n function computeAddress(bytes32 salt, bytes32 bytecodeHash) internal view returns (address) {\n return computeAddress(salt, bytecodeHash, address(this));\n }\n\n /**\n * @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at\n * `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}.\n */\n function computeAddress(bytes32 salt, bytes32 bytecodeHash, address deployer) internal pure returns (address addr) {\n /// @solidity memory-safe-assembly\n assembly {\n let ptr := mload(0x40) // Get free memory pointer\n\n // | | ↓ ptr ... ↓ ptr + 0x0B (start) ... ↓ ptr + 0x20 ... ↓ ptr + 0x40 ... |\n // |-------------------|---------------------------------------------------------------------------|\n // | bytecodeHash | CCCCCCCCCCCCC...CC |\n // | salt | BBBBBBBBBBBBB...BB |\n // | deployer | 000000...0000AAAAAAAAAAAAAAAAAAA...AA |\n // | 0xFF | FF |\n // |-------------------|---------------------------------------------------------------------------|\n // | memory | 000000...00FFAAAAAAAAAAAAAAAAAAA...AABBBBBBBBBBBBB...BBCCCCCCCCCCCCC...CC |\n // | keccak(start, 85) | ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ |\n\n mstore(add(ptr, 0x40), bytecodeHash)\n mstore(add(ptr, 0x20), salt)\n mstore(ptr, deployer) // Right-aligned with 12 preceding garbage bytes\n let start := add(ptr, 0x0b) // The hashed data starts at the final garbage byte which we will set to 0xff\n mstore8(start, 0xff)\n addr := keccak256(start, 85)\n }\n }\n}\n"},"src/callback/DefaultCallbackHandler.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\nimport {IERC777Recipient} from \"@openzeppelin/contracts/interfaces/IERC777Recipient.sol\";\nimport {IERC1155Receiver} from \"@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol\";\nimport {IERC721Receiver} from \"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\";\nimport {IERC165} from \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\n\n/**\n * @dev Token callback handler. Allowing account receiving these tokens.\n * @notice The user will have to register itself in the ERC1820 global registry\n * in order to fully support ERC777 token operations upon the installation of this plugin.\n */\ncontract DefaultCallbackHandler is IERC721Receiver, IERC1155Receiver, IERC777Recipient {\n function supportsInterface(bytes4 interfaceId) external view virtual override returns (bool) {\n return interfaceId == type(IERC721Receiver).interfaceId || interfaceId == type(IERC1155Receiver).interfaceId\n || interfaceId == type(IERC165).interfaceId;\n }\n\n function onERC1155Received(address, address, uint256, uint256, bytes calldata)\n external\n pure\n override\n returns (bytes4)\n {\n return IERC1155Receiver.onERC1155Received.selector;\n }\n\n function onERC1155BatchReceived(address, address, uint256[] calldata, uint256[] calldata, bytes calldata)\n external\n pure\n override\n returns (bytes4)\n {\n return IERC1155Receiver.onERC1155BatchReceived.selector;\n }\n\n function onERC721Received(address, address, uint256, bytes calldata) external pure override returns (bytes4) {\n return IERC721Receiver.onERC721Received.selector;\n }\n\n // ERC777\n function tokensReceived(\n address operator,\n address from,\n address to,\n uint256 amount,\n bytes calldata userData,\n bytes calldata operatorData\n ) external pure override \n // solhint-disable-next-line no-empty-blocks\n {}\n}\n"},"src/common/Constants.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\n// ERC4337 constants\n\n// return value in case of signature failure, with no time-range.\n// equivalent to _packValidationData(true,0,0);\nuint256 constant SIG_VALIDATION_FAILED = 1;\nuint256 constant SIG_VALIDATION_SUCCEEDED = 0;\n\n// sentinel values\n// any values less than or equal to this will not be allowed in storage\nbytes21 constant SENTINEL_BYTES21 = bytes21(0);\nbytes23 constant SENTINEL_BYTES23 = bytes23(0);\nbytes32 constant SENTINEL_BYTES32 = bytes32(0);\n\n// empty or unset function reference\n// we don't store the empty function reference\nbytes21 constant EMPTY_FUNCTION_REFERENCE = bytes21(0);\n\n// wallet constants\nstring constant WALLET_AUTHOR = \"Circle Internet Financial\";\nstring constant WALLET_VERSION_1 = \"1.0.0\";\n\n// plugin constants\nstring constant PLUGIN_AUTHOR = \"Circle Internet Financial\";\nstring constant PLUGIN_VERSION_1 = \"1.0.0\";\n\n// bytes4(keccak256(\"isValidSignature(bytes32,bytes)\")\nbytes4 constant EIP1271_VALID_SIGNATURE = 0x1626ba7e;\nbytes4 constant EIP1271_INVALID_SIGNATURE = 0xffffffff;\n\n// keccak256('')\nbytes32 constant EMPTY_HASH = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;\n\nuint256 constant ZERO = 0;\n\nbytes32 constant ZERO_BYTES32 = bytes32(0);\nbytes24 constant EMPTY_MODULE_ENTITY = bytes24(0);\n"},"src/common/Errors.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\n/**\n * @notice Throws when the caller is unexpected.\n */\nerror UnauthorizedCaller();\n\nerror InvalidLength();\n\nerror Unsupported();\n"},"src/utils/ExecutionUtils.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\n/**\n * Utility functions helpful when making different kinds of contract calls in Solidity.\n * For inline assembly, please refer to https://docs.soliditylang.org/en/latest/assembly.html\n * For opcodes, please refer to https://ethereum.org/en/developers/docs/evm/opcodes/ and https://www.evm.codes/\n */\nlibrary ExecutionUtils {\n function call(address to, uint256 value, bytes memory data)\n internal\n returns (bool success, bytes memory returnData)\n {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n success := call(gas(), to, value, add(data, 0x20), mload(data), 0, 0)\n let len := returndatasize()\n let ptr := mload(0x40)\n mstore(0x40, add(ptr, add(len, 0x20)))\n mstore(ptr, len)\n returndatacopy(add(ptr, 0x20), 0, len)\n returnData := ptr\n }\n }\n\n function revertWithData(bytes memory returnData) internal pure {\n // solhint-disable-next-line no-inline-assembly\n assembly {\n revert(add(returnData, 32), mload(returnData))\n }\n }\n\n function callAndRevert(address to, uint256 value, bytes memory data) internal {\n (bool success, bytes memory returnData) = call(to, value, data);\n if (!success) {\n revertWithData(returnData);\n }\n }\n\n function callWithReturnDataOrRevert(address to, uint256 value, bytes memory data) internal returns (bytes memory) {\n (bool success, bytes memory returnData) = call(to, value, data);\n if (!success) {\n // bubble up revert reason\n revertWithData(returnData);\n }\n return returnData;\n }\n\n /// @dev Return data or revert.\n function delegateCall(address to, bytes memory data) internal returns (bytes memory) {\n // solhint-disable-next-line avoid-low-level-calls\n (bool success, bytes memory returnData) = to.delegatecall(data);\n if (!success) {\n // bubble up revert reason\n revertWithData(returnData);\n }\n return returnData;\n }\n\n /// @dev Allocates memory for and retrieves return data from the previous external function call. The end of the\n /// allocated data may not be aligned to 32 bytes, which means the next free memory slot might fall somewhere\n /// between two 32-byte words. Therefore the memory address is aligned to the next 32-byte boundary to ensure\n /// efficient memory usage. The function also stores the size of the return data and copies the return data\n /// itself into the allocated memory.\n /// @return returnData the data returned by the last external function call.\n /// @notice The function ensures memory alignment by adding 63 (0x3f = 0x1f + 0x20) and clearing the last 5 bits,\n /// ensuring the memory is pushed to the nearest multiple of 32 bytes. This avoids unaligned memory access,\n /// which can lead to inefficiencies.\n function fetchReturnData() internal pure returns (bytes memory returnData) {\n // solhint-disable-next-line no-inline-assembly\n assembly (\"memory-safe\") {\n // allocate memory for the return data starting at the free memory pointer\n returnData := mload(0x40)\n // update the free memory pointer after adding the size of the return data and ensuring it is aligned to the\n // next 32-byte boundary\n mstore(0x40, add(returnData, and(add(returndatasize(), 0x3f), not(0x1f))))\n // store the size of the return data at the start of the allocated memory\n mstore(returnData, returndatasize())\n // copy the return data to the allocated memory space\n returndatacopy(add(returnData, 0x20), 0, returndatasize())\n }\n }\n}\n"},"src/msca/6900/shared/common/Structs.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\n/**\n * @dev Returned data from validateUserOp.\n * validateUserOp returns a uint256, with is created by `_packedValidationData` and parsed by `_parseValidationData`\n * @param validAfter - this UserOp is valid only after this timestamp.\n * @param validaUntil - this UserOp is valid only up to this timestamp.\n * @param authorizer - 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 be used to validate the\n * signature.\n */\nstruct ValidationData {\n uint48 validAfter;\n uint48 validUntil;\n address authorizer;\n}\n\nstruct AddressDLL {\n mapping(address => address) next;\n mapping(address => address) prev;\n uint256 count;\n}\n\nstruct Bytes4DLL {\n mapping(bytes4 => bytes4) next;\n mapping(bytes4 => bytes4) prev;\n uint256 count;\n}\n\nstruct Bytes32DLL {\n mapping(bytes32 => bytes32) next;\n mapping(bytes32 => bytes32) prev;\n uint256 count;\n}\n"},"src/msca/6900/shared/libs/ValidationDataLib.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\nimport {ValidationData} from \"../common/Structs.sol\";\n\nlibrary ValidationDataLib {\n error WrongTimeBounds();\n\n /**\n * @dev Intercept the time bounds `[validAfter, validUntil]` and the signature validation result,\n * prioritizing the invalid authorizer (`!=0 && !=1`), followed by prioritizing failure (`==1`),\n * and finally returning success (`==0`). Please note that both `authorizer(2)` and `authorizer(3)` are invalid,\n * and calling this function with `(2, 3)` ensures that only one invalid authorizer will be returned.\n * @notice address(0) is a successful validation, address(1) is a failed validation,\n * and address(2), address(3) and others are invalid authorizers (also failed).\n */\n function _intersectValidationData(ValidationData memory a, uint256 uintb)\n internal\n pure\n returns (ValidationData memory validationData)\n {\n ValidationData memory b = _unpackValidationData(uintb);\n if (a.validAfter > a.validUntil) {\n revert WrongTimeBounds();\n }\n if (b.validAfter > b.validUntil) {\n revert WrongTimeBounds();\n }\n // 0 is successful validation\n if (!_isValidAuthorizer(a.authorizer)) {\n validationData.authorizer = a.authorizer;\n } else if (!_isValidAuthorizer(b.authorizer)) {\n validationData.authorizer = b.authorizer;\n } else {\n if (a.authorizer == address(0)) {\n validationData.authorizer = b.authorizer;\n } else {\n validationData.authorizer = a.authorizer;\n }\n }\n if (a.validAfter > b.validAfter) {\n validationData.validAfter = a.validAfter;\n } else {\n validationData.validAfter = b.validAfter;\n }\n if (a.validUntil < b.validUntil) {\n validationData.validUntil = a.validUntil;\n } else {\n validationData.validUntil = b.validUntil;\n }\n // make sure the caller (e.g. entryPoint) reverts\n // set to address(1) if and only if the authorizer is address(0) (successful validation)\n // we don't want to set to address(1) if the authorizer is invalid such as address(2)\n if (validationData.validAfter >= validationData.validUntil && validationData.authorizer == address(0)) {\n validationData.authorizer = address(1);\n }\n return validationData;\n }\n\n /**\n * @dev Unpack into the deserialized packed format from validAfter | validUntil | authorizer.\n */\n function _unpackValidationData(uint256 validationDataInt)\n internal\n pure\n returns (ValidationData memory validationData)\n {\n address authorizer = address(uint160(validationDataInt));\n uint48 validUntil = uint48(validationDataInt >> 160);\n if (validUntil == 0) {\n validUntil = type(uint48).max;\n }\n uint48 validAfter = uint48(validationDataInt >> (48 + 160));\n return ValidationData(validAfter, validUntil, authorizer);\n }\n\n function _packValidationData(ValidationData memory data) internal pure returns (uint256) {\n return uint160(data.authorizer) | (uint256(data.validUntil) << 160) | (uint256(data.validAfter) << (160 + 48));\n }\n\n function _isValidAuthorizer(address authorizer) internal pure returns (bool) {\n return authorizer == address(0) || authorizer == address(1);\n }\n}\n"},"src/msca/6900/v0.7/common/Constants.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\n// magic value for runtime validation functions that always allow access\nbytes21 constant RUNTIME_VALIDATION_ALWAYS_ALLOW_FUNCTION_REFERENCE = bytes21(uint168(1));\n\n// magic value for hooks that should always revert\nbytes21 constant PRE_HOOK_ALWAYS_DENY_FUNCTION_REFERENCE = bytes21(uint168(2));\n"},"src/msca/6900/v0.7/common/Structs.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\n// Standard executor\nstruct Call {\n // The target address for the account to call.\n address target;\n // The value to send with the call.\n uint256 value;\n // The calldata for the call.\n bytes data;\n}\n\nstruct FunctionReference {\n address plugin;\n uint8 functionId;\n}\n\n// Account loupe\n// @notice Config for an execution function, given a selector\nstruct ExecutionFunctionConfig {\n address plugin;\n FunctionReference userOpValidationFunction;\n FunctionReference runtimeValidationFunction;\n}\n\n/// @notice Pre and post hooks for a given selector\n/// @dev It's possible for one of either `preExecHook` or `postExecHook` to be empty\nstruct ExecutionHooks {\n FunctionReference preExecHook;\n FunctionReference postExecHook;\n}\n\n// internal data structure\nstruct Bytes21DLL {\n mapping(bytes21 => bytes21) next;\n mapping(bytes21 => bytes21) prev;\n uint256 count;\n}\n\nstruct RepeatableBytes21DLL {\n mapping(bytes21 => bytes21) next;\n mapping(bytes21 => bytes21) prev;\n mapping(bytes21 => uint256) counter;\n // unique items\n uint256 uniqueItems;\n // total items with repeatable ones\n uint256 totalItems;\n}\n\n// Represents a set of pre and post hooks. Used to store execution hooks.\nstruct HookGroup {\n RepeatableBytes21DLL preHooks;\n // key = preExecHook.pack()\n mapping(bytes21 => RepeatableBytes21DLL) preToPostHooks;\n RepeatableBytes21DLL postOnlyHooks;\n}\n\n// plugin's permission to call external (to the account and its plugins) contracts and addresses\n// through `executeFromPluginExternal`\nstruct PermittedExternalCall {\n bool addressPermitted;\n // either anySelector or selectors permitted\n bool anySelector;\n mapping(bytes4 => bool) selectors;\n}\n\nstruct PostExecHookToRun {\n bytes preExecHookReturnData;\n FunctionReference postExecHook;\n}\n\n// plugin detail stored in wallet storage\nstruct PluginDetail {\n // permitted to call any external contracts and selectors\n bool anyExternalAddressPermitted;\n // boolean to indicate if the plugin can spend native tokens, if any of the execution function can spend\n // native tokens, a plugin is considered to be able to spend native tokens of the accounts\n bool canSpendNativeToken;\n // tracks the count this plugin has been used as a dependency function\n uint256 dependentCounter;\n bytes32 manifestHash;\n Bytes21DLL dependencies;\n}\n\n// execution detail associated with selector\nstruct ExecutionDetail {\n address plugin; // plugin address that implements the execution function, for native functions, the value should be\n // address(0)\n FunctionReference userOpValidationFunction;\n RepeatableBytes21DLL preUserOpValidationHooks;\n FunctionReference runtimeValidationFunction;\n RepeatableBytes21DLL preRuntimeValidationHooks;\n HookGroup executionHooks;\n}\n"},"src/msca/6900/v0.7/interfaces/IPlugin.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\nimport {PluginManifest, PluginMetadata} from \"../common/PluginManifest.sol\";\nimport {UserOperation} from \"@account-abstraction/contracts/interfaces/UserOperation.sol\";\n\n/**\n * @dev Implements https://eips.ethereum.org/EIPS/eip-6900. Plugins must implement this interface to support plugin\n * management and interactions with MSCAs.\n */\ninterface IPlugin {\n /// @notice Initialize plugin data for the modular account.\n /// @dev Called by the modular account during `installPlugin`.\n /// @param data Optional bytes array to be decoded and used by the plugin to setup initial plugin data for the\n /// modular account.\n function onInstall(bytes calldata data) external;\n\n /// @notice Clear plugin data for the modular account.\n /// @dev Called by the modular account during `uninstallPlugin`.\n /// @param data Optional bytes array to be decoded and used by the plugin to clear plugin data for the modular\n /// account.\n function onUninstall(bytes calldata data) external;\n\n /// @notice Run the pre user operation validation hook specified by the `functionId`.\n /// @dev Pre user operation validation hooks MUST NOT return an authorizer value other than 0 or 1.\n /// @param functionId An identifier that routes the call to different internal implementations, should there be more\n /// than one.\n /// @param userOp The user operation.\n /// @param userOpHash The user operation hash.\n /// @return Packed validation data for validAfter (6 bytes), validUntil (6 bytes), and authorizer (20 bytes).\n function preUserOpValidationHook(uint8 functionId, UserOperation calldata userOp, bytes32 userOpHash)\n external\n returns (uint256);\n\n /// @notice Run the user operation validationFunction specified by the `functionId`.\n /// @param functionId An identifier that routes the call to different internal implementations, should there be\n /// more than one.\n /// @param userOp The user operation.\n /// @param userOpHash The user operation hash.\n /// @return Packed validation data for validAfter (6 bytes), validUntil (6 bytes), and authorizer (20 bytes).\n function userOpValidationFunction(uint8 functionId, UserOperation calldata userOp, bytes32 userOpHash)\n external\n returns (uint256);\n\n /// @notice Run the pre runtime validation hook specified by the `functionId`.\n /// @dev To indicate the entire call should revert, the function MUST revert.\n /// @param functionId An identifier that routes the call to different internal implementations, should there be more\n /// than one.\n /// @param sender The caller address.\n /// @param value The call value.\n /// @param data The calldata sent.\n function preRuntimeValidationHook(uint8 functionId, address sender, uint256 value, bytes calldata data) external;\n\n /// @notice Run the runtime validationFunction specified by the `functionId`.\n /// @dev To indicate the entire call should revert, the function MUST revert.\n /// @param functionId An identifier that routes the call to different internal implementations, should there be\n /// more than one.\n /// @param sender The caller address.\n /// @param value The call value.\n /// @param data The calldata sent.\n function runtimeValidationFunction(uint8 functionId, address sender, uint256 value, bytes calldata data) external;\n\n /// @notice Run the pre execution hook specified by the `functionId`.\n /// @dev To indicate the entire call should revert, the function MUST revert.\n /// @param functionId An identifier that routes the call to different internal implementations, should there be more\n /// than one.\n /// @param sender The caller address.\n /// @param value The call value.\n /// @param data The calldata sent.\n /// @return context Context to pass to a post execution hook, if present. An empty bytes array MAY be returned.\n function preExecutionHook(uint8 functionId, address sender, uint256 value, bytes calldata data)\n external\n returns (bytes memory context);\n\n /// @notice Run the post execution hook specified by the `functionId`.\n /// @dev To indicate the entire call should revert, the function MUST revert.\n /// @param functionId An identifier that routes the call to different internal implementations, should there be more\n /// than one.\n /// @param preExecHookData The context returned by its associated pre execution hook.\n function postExecutionHook(uint8 functionId, bytes calldata preExecHookData) external;\n\n /// @notice Describe the contents and intended configuration of the plugin.\n /// @dev This manifest MUST stay constant over time.\n /// @return A manifest describing the contents and intended configuration of the plugin.\n function pluginManifest() external pure returns (PluginManifest memory);\n\n /// @notice Describe the metadata of the plugin.\n /// @dev This metadata MUST stay constant over time.\n /// @return A metadata struct describing the plugin.\n function pluginMetadata() external pure returns (PluginMetadata memory);\n}\n"},"src/msca/6900/v0.7/libs/FunctionReferenceLib.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\nimport {FunctionReference} from \"../common/Structs.sol\";\n\nlibrary FunctionReferenceLib {\n function unpack(bytes21 frBytes) internal pure returns (FunctionReference memory) {\n return FunctionReference(address(bytes20(frBytes)), uint8(bytes1(frBytes << 160)));\n }\n\n function pack(FunctionReference memory functionReference) internal pure returns (bytes21) {\n return (bytes21(bytes20(functionReference.plugin)) | bytes21(uint168(functionReference.functionId)));\n }\n}\n"},"src/msca/6900/v0.7/libs/RepeatableFunctionReferenceDLLLib.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\nimport {SENTINEL_BYTES21} from \"../../../../common/Constants.sol\";\nimport {InvalidFunctionReference, InvalidLimit, ItemDoesNotExist} from \"../../shared/common/Errors.sol\";\nimport {FunctionReference, RepeatableBytes21DLL} from \"../common/Structs.sol\";\nimport {FunctionReferenceLib} from \"./FunctionReferenceLib.sol\";\n\n/**\n * @dev Enumerable & ordered doubly linked list built using RepeatableBytes21DLL.\n * Item is expected to be have a counter that tracks repeated number.\n */\nlibrary RepeatableFunctionReferenceDLLLib {\n using FunctionReferenceLib for FunctionReference;\n using FunctionReferenceLib for bytes21;\n\n modifier validFunctionReference(FunctionReference memory fr) {\n if (fr.pack() <= SENTINEL_BYTES21) {\n revert InvalidFunctionReference();\n }\n _;\n }\n\n /**\n * @dev Check the counter of an item. O(1).\n * @return the counter\n */\n function getRepeatedCount(RepeatableBytes21DLL storage dll, FunctionReference memory fr)\n internal\n view\n returns (uint256)\n {\n bytes21 item = fr.pack();\n if (item == SENTINEL_BYTES21) {\n // sentinel should not considered as the value of the list\n return 0;\n }\n return dll.counter[item];\n }\n\n /**\n * @dev Get the total items of dll. O(1).\n */\n function getTotalItems(RepeatableBytes21DLL storage dll) internal view returns (uint256) {\n return dll.totalItems;\n }\n\n /**\n * @dev Get the unique items of dll. O(1).\n */\n function getUniqueItems(RepeatableBytes21DLL storage dll) internal view returns (uint256) {\n return dll.uniqueItems;\n }\n\n /**\n * @dev Add an new item. O(1).\n */\n function append(RepeatableBytes21DLL storage dll, FunctionReference memory fr)\n internal\n validFunctionReference(fr)\n returns (uint256)\n {\n bytes21 item = fr.pack();\n uint256 currentCount = getRepeatedCount(dll, fr);\n if (currentCount == 0) {\n bytes21 prev = getTailWithoutUnpack(dll);\n bytes21 next = SENTINEL_BYTES21;\n // prev.next = item\n dll.next[prev] = item;\n // item.next = next\n dll.next[item] = next;\n // next.prev = item\n dll.prev[next] = item;\n // item.prev = prev\n dll.prev[item] = prev;\n dll.uniqueItems++;\n }\n dll.counter[item]++;\n dll.totalItems++;\n return dll.counter[item];\n }\n\n /**\n * @dev Remove or decrease the counter of already existing item. Otherwise the function reverts. O(1).\n */\n function remove(RepeatableBytes21DLL storage dll, FunctionReference memory fr)\n internal\n validFunctionReference(fr)\n returns (uint256)\n {\n uint256 currentCount = getRepeatedCount(dll, fr);\n if (currentCount == 0) {\n revert ItemDoesNotExist();\n }\n bytes21 item = fr.pack();\n if (currentCount == 1) {\n // delete the item\n // item.prev.next = item.next\n dll.next[dll.prev[item]] = dll.next[item];\n // item.next.prev = item.prev\n dll.prev[dll.next[item]] = dll.prev[item];\n delete dll.next[item];\n delete dll.prev[item];\n delete dll.counter[item];\n dll.uniqueItems--;\n } else {\n dll.counter[item]--;\n }\n dll.totalItems--;\n return dll.counter[item];\n }\n\n /**\n * @dev Remove all copies of already existing items. O(1).\n */\n function removeAllRepeated(RepeatableBytes21DLL storage dll, FunctionReference memory fr)\n internal\n validFunctionReference(fr)\n returns (bool)\n {\n uint256 currentCount = getRepeatedCount(dll, fr);\n if (currentCount == 0) {\n revert ItemDoesNotExist();\n }\n bytes21 item = fr.pack();\n // item.prev.next = item.next\n dll.next[dll.prev[item]] = dll.next[item];\n // item.next.prev = item.prev\n dll.prev[dll.next[item]] = dll.prev[item];\n delete dll.next[item];\n delete dll.prev[item];\n delete dll.counter[item];\n dll.uniqueItems--;\n dll.totalItems -= currentCount;\n return true;\n }\n\n /**\n * @dev Return paginated results and next pointer without counter information. O(n).\n * In order to get counter information (which our current use case does not need), please call\n * getRepeatedCount.\n * @param startFR Starting item, inclusive, if start == bytes21(0), this method searches from the head.\n */\n function getPaginated(RepeatableBytes21DLL storage dll, FunctionReference memory startFR, uint256 limit)\n internal\n view\n returns (FunctionReference[] memory, FunctionReference memory)\n {\n if (limit == 0) {\n revert InvalidLimit();\n }\n bytes21 start = startFR.pack();\n FunctionReference[] memory results = new FunctionReference[](limit);\n bytes21 current = start;\n if (start == SENTINEL_BYTES21) {\n current = getHeadWithoutUnpack(dll);\n }\n uint256 count = 0;\n for (; count < limit && current > SENTINEL_BYTES21; ++count) {\n results[count] = current.unpack();\n current = dll.next[current];\n }\n // solhint-disable-next-line no-inline-assembly\n assembly (\"memory-safe\") {\n mstore(results, count)\n }\n return (results, current.unpack());\n }\n\n /**\n * @dev Return all the unique items without counter information. O(n).\n * In order to get counter information (which our current use case does not need), please call\n * getRepeatedCount.\n */\n function getAll(RepeatableBytes21DLL storage dll) internal view returns (FunctionReference[] memory results) {\n uint256 totalUniqueCount = getUniqueItems(dll);\n results = new FunctionReference[](totalUniqueCount);\n bytes21 current = getHeadWithoutUnpack(dll);\n uint256 count = 0;\n for (; count < totalUniqueCount && current > SENTINEL_BYTES21; ++count) {\n results[count] = current.unpack();\n current = dll.next[current];\n }\n return results;\n }\n\n function getHead(RepeatableBytes21DLL storage dll) internal view returns (FunctionReference memory) {\n return dll.next[SENTINEL_BYTES21].unpack();\n }\n\n function getTail(RepeatableBytes21DLL storage dll) internal view returns (FunctionReference memory) {\n return dll.prev[SENTINEL_BYTES21].unpack();\n }\n\n function getHeadWithoutUnpack(RepeatableBytes21DLL storage dll) private view returns (bytes21) {\n return dll.next[SENTINEL_BYTES21];\n }\n\n function getTailWithoutUnpack(RepeatableBytes21DLL storage dll) private view returns (bytes21) {\n return dll.prev[SENTINEL_BYTES21];\n }\n}\n"},"src/msca/6900/v0.7/libs/WalletStorageV1Lib.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\nimport {AddressDLL} from \"../../shared/common/Structs.sol\";\nimport {ExecutionDetail, PermittedExternalCall, PluginDetail} from \"../common/Structs.sol\";\n\n/// @dev The same storage will be used for v1.x.y of MSCAs.\nlibrary WalletStorageV1Lib {\n // @notice When we initially calculated the storage slot, EIP-7201 was still under active discussion,\n // so we didn’t fully adopt the storage alignment proposed by the EIP, which reduces gas costs\n // for subsequent operations, as a single cold storage access warms all 256 slots within the group.\n // To avoid introducing breaking changes and the complexity of migration, we chose not to make changes midway.\n // For v2 accounts, which will feature a different storage layout, we will adopt EIP-7201.\n // keccak256(abi.encode(uint256(keccak256(abi.encode(\"circle.msca.v1.storage\"))) - 1))\n bytes32 internal constant WALLET_STORAGE_SLOT = 0xc6a0cc20c824c4eecc4b0fbb7fb297d07492a7bd12c83d4fa4d27b4249f9bfc8;\n\n struct Layout {\n // installed plugin addresses for quick query\n AddressDLL installedPlugins;\n // installed plugin details such as manifest, dependencies\n mapping(address => PluginDetail) pluginDetails;\n // permissions for executeFromPlugin into another plugin\n // callingPluginAddress => callingExecutionSelector => permittedOrNot\n mapping(address => mapping(bytes4 => bool)) permittedPluginCalls;\n // permissions for executeFromPluginExternal into external contract\n // callingPluginAddress => targetContractAddress => permission\n mapping(address => mapping(address => PermittedExternalCall)) permittedExternalCalls;\n // list of ERC-165 interfaceIds to add to account to support introspection checks\n // interfaceId => counter\n mapping(bytes4 => uint256) supportedInterfaces;\n // find plugin or native function execution detail by selector\n mapping(bytes4 => ExecutionDetail) executionDetails;\n /// indicates that the contract has been initialized\n uint8 initialized;\n /// indicates that the contract is in the process of being initialized\n bool initializing;\n // optional fields\n address owner;\n }\n\n /**\n * @dev Function to read structured wallet storage.\n */\n function getLayout() internal pure returns (Layout storage walletStorage) {\n // solhint-disable-next-line no-inline-assembly\n assembly (\"memory-safe\") {\n walletStorage.slot := WALLET_STORAGE_SLOT\n }\n }\n}\n"},"src/msca/6900/v0.7/account/BaseMSCA.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\nimport {\n EMPTY_FUNCTION_REFERENCE,\n SENTINEL_BYTES21,\n WALLET_AUTHOR,\n WALLET_VERSION_1\n} from \"../../../../common/Constants.sol\";\n\nimport {UnauthorizedCaller} from \"../../../../common/Errors.sol\";\nimport {ExecutionUtils} from \"../../../../utils/ExecutionUtils.sol\";\nimport {\n InvalidAuthorizer,\n InvalidExecutionFunction,\n InvalidValidationFunctionId,\n NotFoundSelector\n} from \"../../shared/common/Errors.sol\";\nimport {AddressDLL, ValidationData} from \"../../shared/common/Structs.sol\";\nimport {AddressDLLLib} from \"../../shared/libs/AddressDLLLib.sol\";\nimport {ValidationDataLib} from \"../../shared/libs/ValidationDataLib.sol\";\nimport {\n PRE_HOOK_ALWAYS_DENY_FUNCTION_REFERENCE,\n RUNTIME_VALIDATION_ALWAYS_ALLOW_FUNCTION_REFERENCE\n} from \"../common/Constants.sol\";\nimport {\n Call,\n ExecutionDetail,\n ExecutionFunctionConfig,\n ExecutionHooks,\n FunctionReference,\n HookGroup,\n PostExecHookToRun,\n RepeatableBytes21DLL\n} from \"../common/Structs.sol\";\nimport {IAccountLoupe} from \"../interfaces/IAccountLoupe.sol\";\nimport {IPlugin} from \"../interfaces/IPlugin.sol\";\nimport {IPluginExecutor} from \"../interfaces/IPluginExecutor.sol\";\nimport {IPluginManager} from \"../interfaces/IPluginManager.sol\";\nimport {IStandardExecutor} from \"../interfaces/IStandardExecutor.sol\";\nimport {ExecutionHookLib} from \"../libs/ExecutionHookLib.sol\";\nimport {FunctionReferenceLib} from \"../libs/FunctionReferenceLib.sol\";\nimport {RepeatableFunctionReferenceDLLLib} from \"../libs/RepeatableFunctionReferenceDLLLib.sol\";\n\nimport {SelectorRegistryLib} from \"../libs/SelectorRegistryLib.sol\";\nimport {WalletStorageV1Lib} from \"../libs/WalletStorageV1Lib.sol\";\nimport {PluginExecutor} from \"../managers/PluginExecutor.sol\";\nimport {PluginManager} from \"../managers/PluginManager.sol\";\nimport {StandardExecutor} from \"../managers/StandardExecutor.sol\";\n\nimport {WalletStorageInitializable} from \"./WalletStorageInitializable.sol\";\nimport {IEntryPoint} from \"@account-abstraction/contracts/interfaces/IEntryPoint.sol\";\nimport {UserOperation} from \"@account-abstraction/contracts/interfaces/UserOperation.sol\";\nimport {IERC165} from \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\n\n/**\n * @dev Base MSCA implementation with **authentication**.\n * This contract provides the basic logic for implementing the MSCA interfaces;\n * specific account implementation should inherit this contract.\n */\nabstract contract BaseMSCA is\n WalletStorageInitializable,\n IPluginManager,\n IAccountLoupe,\n IStandardExecutor,\n IPluginExecutor,\n IERC165\n{\n using RepeatableFunctionReferenceDLLLib for RepeatableBytes21DLL;\n using FunctionReferenceLib for bytes21;\n using FunctionReferenceLib for FunctionReference;\n using ExecutionHookLib for HookGroup;\n using ExecutionHookLib for PostExecHookToRun[];\n using ExecutionUtils for address;\n using PluginExecutor for bytes;\n using StandardExecutor for address;\n using StandardExecutor for Call[];\n using AddressDLLLib for AddressDLL;\n using ValidationDataLib for ValidationData;\n using SelectorRegistryLib for bytes4;\n\n string public constant AUTHOR = WALLET_AUTHOR;\n string public constant VERSION = WALLET_VERSION_1;\n // 4337 related immutable storage\n IEntryPoint public immutable ENTRY_POINT;\n PluginManager public immutable PLUGIN_MANAGER;\n\n error NotNativeFunctionSelector(bytes4 selector);\n error InvalidHookFunctionId(uint8 functionId);\n error PreRuntimeValidationHookFailed(address plugin, uint8 functionId, bytes revertReason);\n error RuntimeValidationFailed(address plugin, uint8 functionId, bytes revertReason);\n\n /**\n * @dev Wraps execution of a native function (as opposed to a function added by plugins) with runtime validations\n * (not from EP)\n * and hooks. Used by execute, executeBatch, installPlugin, uninstallPlugin, upgradeTo and upgradeToAndCall.\n * If the call is from entry point, then validateUserOp will run.\n * https://eips.ethereum.org/assets/eip-6900/Modular_Account_Call_Flow.svg\n */\n modifier validateNativeFunction() {\n PostExecHookToRun[] memory postExecHooks = _processPreExecHooks();\n _;\n postExecHooks._processPostExecHooks();\n }\n\n /**\n * @dev This function allows entry point or SA itself to execute certain actions.\n * If the caller is not authorized, the function will revert with an error message.\n */\n modifier onlyFromEntryPointOrSelf() {\n _checkAccessRuleFromEPOrAcctItself();\n _;\n }\n\n constructor(IEntryPoint _newEntryPoint, PluginManager _newPluginManager) {\n ENTRY_POINT = _newEntryPoint;\n PLUGIN_MANAGER = _newPluginManager;\n // lock the implementation contract so it can only be called from proxies\n _disableWalletStorageInitializers();\n }\n\n receive() external payable {}\n\n /// @notice Manage fallback calls made to the plugins.\n /// @dev Route calls to execution functions based on incoming msg.sig\n /// If there's no plugin associated with this function selector, revert\n // solhint-disable-next-line no-complex-fallback\n fallback(bytes calldata) external payable returns (bytes memory result) {\n if (msg.data.length < 4) {\n revert NotFoundSelector();\n }\n // run runtime validation before we load the executionDetail because validation may update account state\n if (msg.sender != address(ENTRY_POINT)) {\n // ENTRY_POINT should go through validateUserOp flow which calls userOpValidationFunction\n _processPreRuntimeHooksAndValidation(msg.sig);\n }\n // load the executionDetail before we run the preExecHooks because they may modify the plugins\n ExecutionDetail storage executionDetail = WalletStorageV1Lib.getLayout().executionDetails[msg.sig];\n address executionFunctionPlugin = executionDetail.plugin;\n // valid plugin address should not be 0\n if (executionFunctionPlugin == address(0)) {\n revert InvalidExecutionFunction(msg.sig);\n }\n PostExecHookToRun[] memory postExecHooks = executionDetail.executionHooks._processPreExecHooks(msg.data);\n result = ExecutionUtils.callWithReturnDataOrRevert(executionFunctionPlugin, msg.value, msg.data);\n postExecHooks._processPostExecHooks();\n return result;\n }\n\n /**\n * @dev Return the ENTRY_POINT used by this account.\n * subclass should return the current ENTRY_POINT used by this account.\n */\n function getEntryPoint() external view returns (IEntryPoint) {\n return ENTRY_POINT;\n }\n\n /**\n * @dev Validate user's signature and nonce.\n * subclass doesn't need to override this method. Instead, it should override the specific internal validation\n * methods.\n */\n function validateUserOp(UserOperation calldata userOp, bytes32 userOpHash, uint256 missingAccountFunds)\n external\n virtual\n returns (uint256 validationData)\n {\n if (msg.sender != address(ENTRY_POINT)) {\n revert UnauthorizedCaller();\n }\n validationData = _authenticateAndAuthorizeUserOp(userOp, userOpHash);\n if (missingAccountFunds != 0) {\n (bool success,) = payable(msg.sender).call{value: missingAccountFunds, gas: type(uint256).max}(\"\");\n (success);\n // ignore failure (its EntryPoint's job to verify, not account.)\n }\n }\n\n /// @notice ERC165 introspection https://eips.ethereum.org/EIPS/eip-165\n /// @dev returns true for `IERC165.interfaceId` and false for `0xFFFFFFFF`\n /// @param interfaceId interface id to check against\n /// @return bool support for specific interface\n function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n if (interfaceId == 0xffffffff) {\n return false;\n }\n if (interfaceId == type(IERC165).interfaceId) {\n return true;\n }\n return WalletStorageV1Lib.getLayout().supportedInterfaces[interfaceId] > 0;\n }\n\n /**\n * @dev 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 ENTRY_POINT.getNonce(address(this), 0);\n }\n\n function installPlugin(\n address plugin,\n bytes32 manifestHash,\n bytes memory pluginInstallData,\n FunctionReference[] memory dependencies\n ) external override validateNativeFunction {\n bytes memory data = abi.encodeCall(\n PluginManager.install, (plugin, manifestHash, pluginInstallData, dependencies, address(this))\n );\n address(PLUGIN_MANAGER).delegateCall(data);\n emit PluginInstalled(plugin, manifestHash, dependencies);\n }\n\n function uninstallPlugin(address plugin, bytes memory config, bytes memory pluginUninstallData)\n external\n override\n validateNativeFunction\n {\n bytes memory data = abi.encodeCall(PluginManager.uninstall, (plugin, config, pluginUninstallData));\n address(PLUGIN_MANAGER).delegateCall(data);\n emit PluginUninstalled(plugin, true);\n }\n\n function execute(address target, uint256 value, bytes calldata data)\n external\n payable\n override\n validateNativeFunction\n returns (bytes memory returnData)\n {\n return target.execute(value, data);\n }\n\n function executeBatch(Call[] calldata calls)\n external\n payable\n override\n validateNativeFunction\n returns (bytes[] memory returnData)\n {\n return calls.executeBatch();\n }\n\n function executeFromPlugin(bytes calldata data) external payable override returns (bytes memory) {\n return data.executeFromPlugin();\n }\n\n function executeFromPluginExternal(address target, uint256 value, bytes calldata data)\n external\n payable\n override\n returns (bytes memory)\n {\n return data.executeFromPluginToExternal(target, value);\n }\n\n /// @notice Gets the validation functions and plugin address for a selector\n /// @dev If the selector is a native function, the plugin address will be the address of the account\n /// @param selector The selector to get the configuration for\n /// @return executionFunctionConfig The configuration for this selector\n function getExecutionFunctionConfig(bytes4 selector)\n external\n view\n returns (ExecutionFunctionConfig memory executionFunctionConfig)\n {\n WalletStorageV1Lib.Layout storage walletStorage = WalletStorageV1Lib.getLayout();\n if (selector._isNativeFunctionSelector()) {\n executionFunctionConfig.plugin = address(this);\n } else {\n executionFunctionConfig.plugin = walletStorage.executionDetails[selector].plugin;\n }\n executionFunctionConfig.userOpValidationFunction =\n walletStorage.executionDetails[selector].userOpValidationFunction;\n executionFunctionConfig.runtimeValidationFunction =\n walletStorage.executionDetails[selector].runtimeValidationFunction;\n return executionFunctionConfig;\n }\n\n /// @notice Gets the pre and post execution hooks for a selector\n /// @param selector The selector to get the hooks for\n /// @return executionHooks The pre and post execution hooks for this selector\n function getExecutionHooks(bytes4 selector) external view returns (ExecutionHooks[] memory executionHooks) {\n return WalletStorageV1Lib.getLayout().executionDetails[selector].executionHooks._getExecutionHooks();\n }\n\n /// @notice Gets the pre user op and runtime validation hooks associated with a selector\n /// @param selector The selector to get the hooks for\n /// @return preUserOpValidationHooks The pre user op validation hooks for this selector\n /// @return preRuntimeValidationHooks The pre runtime validation hooks for this selector\n function getPreValidationHooks(bytes4 selector)\n external\n view\n returns (\n FunctionReference[] memory preUserOpValidationHooks,\n FunctionReference[] memory preRuntimeValidationHooks\n )\n {\n preUserOpValidationHooks =\n WalletStorageV1Lib.getLayout().executionDetails[selector].preUserOpValidationHooks.getAll();\n preRuntimeValidationHooks =\n WalletStorageV1Lib.getLayout().executionDetails[selector].preRuntimeValidationHooks.getAll();\n return (preUserOpValidationHooks, preRuntimeValidationHooks);\n }\n\n /// @notice Gets an array of all installed plugins\n /// @return pluginAddresses The addresses of all installed plugins\n function getInstalledPlugins() external view returns (address[] memory pluginAddresses) {\n return WalletStorageV1Lib.getLayout().installedPlugins.getAll();\n }\n\n /**\n * Check current account deposit in the ENTRY_POINT.\n */\n function getDeposit() public view returns (uint256) {\n return ENTRY_POINT.balanceOf(address(this));\n }\n\n /**\n * Deposit more funds for this account in the ENTRY_POINT.\n */\n function addDeposit() public payable {\n ENTRY_POINT.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(address payable withdrawAddress, uint256 amount) public onlyFromEntryPointOrSelf {\n ENTRY_POINT.withdrawTo(withdrawAddress, amount);\n }\n\n /**\n * @dev Authenticate and authorize this userOp. OnlyFromEntryPoint is applied in the caller.\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> 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 the account doesn't use time-range, it is enough to return SIG_VALIDATION_FAILED value (1) for signature\n * failure.\n * Note that the validation code cannot use block.timestamp (or block.number) directly due to the storage rule.\n */\n function _authenticateAndAuthorizeUserOp(UserOperation calldata userOp, bytes32 userOpHash)\n internal\n virtual\n returns (uint256 validationData)\n {\n // onlyFromEntryPoint is applied in the caller\n // if there is no function defined for the selector, or if userOp.callData.length < 4, then execution MUST\n // revert\n if (userOp.callData.length < 4) {\n revert NotFoundSelector();\n }\n bytes4 selector = bytes4(userOp.callData[0:4]);\n if (selector == bytes4(0)) {\n revert NotFoundSelector();\n }\n ExecutionDetail storage executionDetail = WalletStorageV1Lib.getLayout().executionDetails[selector];\n FunctionReference memory validationFunction = executionDetail.userOpValidationFunction;\n bytes21 packedValidationFunction = validationFunction.pack();\n if (\n packedValidationFunction == EMPTY_FUNCTION_REFERENCE\n || packedValidationFunction == RUNTIME_VALIDATION_ALWAYS_ALLOW_FUNCTION_REFERENCE\n || packedValidationFunction == PRE_HOOK_ALWAYS_DENY_FUNCTION_REFERENCE\n ) {\n revert InvalidValidationFunctionId(validationFunction.functionId);\n }\n // pre hook\n ValidationData memory unpackedValidationData =\n _processPreUserOpValidationHooks(executionDetail, userOp, userOpHash);\n IPlugin userOpValidatorPlugin = IPlugin(validationFunction.plugin);\n // execute the validation function with the user operation and its hash as parameters using the call opcode\n uint256 currentValidationData = userOpValidatorPlugin.userOpValidationFunction(\n executionDetail.userOpValidationFunction.functionId, userOp, userOpHash\n );\n // intercept with validation function call\n unpackedValidationData = unpackedValidationData._intersectValidationData(currentValidationData);\n if (unpackedValidationData.authorizer != address(0) && unpackedValidationData.authorizer != address(1)) {\n // only revert on unexpected values\n revert InvalidAuthorizer();\n }\n validationData = unpackedValidationData._packValidationData();\n }\n\n /**\n * @dev Default validation logic is from installed plugins. However, you can override this validation logic in MSCA\n * implementations. For instance, semi MSCA such as single owner semi MSCA may want to honor the validation\n * from native owner.\n */\n function _processPreRuntimeHooksAndValidation(bytes4 selector) internal virtual {\n FunctionReference memory validationFunction =\n WalletStorageV1Lib.getLayout().executionDetails[selector].runtimeValidationFunction;\n bytes21 packedValidationFunction = validationFunction.pack();\n if (\n packedValidationFunction == EMPTY_FUNCTION_REFERENCE\n || packedValidationFunction == PRE_HOOK_ALWAYS_DENY_FUNCTION_REFERENCE\n ) {\n revert InvalidValidationFunctionId(validationFunction.functionId);\n }\n RepeatableBytes21DLL storage preRuntimeValidationHooksDLL =\n WalletStorageV1Lib.getLayout().executionDetails[selector].preRuntimeValidationHooks;\n uint256 totalUniqueHookCount = preRuntimeValidationHooksDLL.getUniqueItems();\n FunctionReference memory startHook = EMPTY_FUNCTION_REFERENCE.unpack();\n FunctionReference[] memory preRuntimeValidationHooks;\n FunctionReference memory nextHook;\n for (uint256 i = 0; i < totalUniqueHookCount; ++i) {\n (preRuntimeValidationHooks, nextHook) = preRuntimeValidationHooksDLL.getPaginated(startHook, 10);\n for (uint256 j = 0; j < preRuntimeValidationHooks.length; ++j) {\n // revert on EMPTY_FUNCTION_REFERENCE, RUNTIME_VALIDATION_ALWAYS_ALLOW_FUNCTION_REFERENCE,\n // PRE_HOOK_ALWAYS_DENY_FUNCTION_REFERENCE\n // if any revert, the outer call MUST revert\n bytes21 packedPreRuntimeValidationHook = preRuntimeValidationHooks[j].pack();\n if (\n packedPreRuntimeValidationHook == EMPTY_FUNCTION_REFERENCE\n || packedPreRuntimeValidationHook == RUNTIME_VALIDATION_ALWAYS_ALLOW_FUNCTION_REFERENCE\n || packedPreRuntimeValidationHook == PRE_HOOK_ALWAYS_DENY_FUNCTION_REFERENCE\n ) {\n revert InvalidValidationFunctionId(preRuntimeValidationHooks[j].functionId);\n }\n IPlugin preRuntimeValidationHookPlugin = IPlugin(preRuntimeValidationHooks[j].plugin);\n // solhint-disable no-empty-blocks\n try preRuntimeValidationHookPlugin.preRuntimeValidationHook(\n preRuntimeValidationHooks[j].functionId, msg.sender, msg.value, msg.data\n ) {} catch (bytes memory revertReason) {\n revert PreRuntimeValidationHookFailed(\n preRuntimeValidationHooks[j].plugin, preRuntimeValidationHooks[j].functionId, revertReason\n );\n }\n // solhint-enable no-empty-blocks\n }\n if (nextHook.pack() == SENTINEL_BYTES21) {\n break;\n }\n startHook = nextHook;\n }\n // call runtimeValidationFunction if it's not always allowed\n if (packedValidationFunction != RUNTIME_VALIDATION_ALWAYS_ALLOW_FUNCTION_REFERENCE) {\n // solhint-disable no-empty-blocks\n try IPlugin(validationFunction.plugin).runtimeValidationFunction(\n validationFunction.functionId, msg.sender, msg.value, msg.data\n ) {} catch (bytes memory revertReason) {\n revert RuntimeValidationFailed(validationFunction.plugin, validationFunction.functionId, revertReason);\n }\n // solhint-enable no-empty-blocks\n }\n }\n\n /// @dev Also runs runtime hooks and validation if msg.sender is not from entry point.\n function _processPreExecHooks() internal returns (PostExecHookToRun[] memory) {\n if (!msg.sig._isNativeFunctionSelector()) {\n revert NotNativeFunctionSelector(msg.sig);\n }\n if (msg.sender != address(ENTRY_POINT)) {\n // ENTRY_POINT should go through validateUserOp flow which calls userOpValidationFunction\n _processPreRuntimeHooksAndValidation(msg.sig);\n }\n return WalletStorageV1Lib.getLayout().executionDetails[msg.sig].executionHooks._processPreExecHooks(msg.data);\n }\n\n function _processPreUserOpValidationHooks(\n ExecutionDetail storage executionDetail,\n UserOperation calldata userOp,\n bytes32 userOpHash\n ) internal virtual returns (ValidationData memory unpackedValidationData) {\n unpackedValidationData = ValidationData(0, 0xFFFFFFFFFFFF, address(0));\n // if the function selector has associated pre user operation validation hooks, then those hooks MUST be run\n // sequentially\n uint256 totalUniqueHookCount = executionDetail.preUserOpValidationHooks.getUniqueItems();\n FunctionReference memory startHook = EMPTY_FUNCTION_REFERENCE.unpack();\n FunctionReference[] memory preUserOpValidatorHooks;\n FunctionReference memory nextHook;\n uint256 currentValidationData;\n for (uint256 i = 0; i < totalUniqueHookCount; ++i) {\n (preUserOpValidatorHooks, nextHook) = executionDetail.preUserOpValidationHooks.getPaginated(startHook, 10);\n for (uint256 j = 0; j < preUserOpValidatorHooks.length; ++j) {\n bytes21 packedUserOpValidatorHook = preUserOpValidatorHooks[j].pack();\n // if any revert, the outer call MUST revert\n if (\n packedUserOpValidatorHook == EMPTY_FUNCTION_REFERENCE\n || packedUserOpValidatorHook == RUNTIME_VALIDATION_ALWAYS_ALLOW_FUNCTION_REFERENCE\n || packedUserOpValidatorHook == PRE_HOOK_ALWAYS_DENY_FUNCTION_REFERENCE\n ) {\n revert InvalidHookFunctionId(preUserOpValidatorHooks[j].functionId);\n }\n IPlugin preUserOpValidationHookPlugin = IPlugin(preUserOpValidatorHooks[j].plugin);\n currentValidationData = preUserOpValidationHookPlugin.preUserOpValidationHook(\n preUserOpValidatorHooks[j].functionId, userOp, userOpHash\n );\n unpackedValidationData = unpackedValidationData._intersectValidationData(currentValidationData);\n // if any return an authorizer value other than 0 or 1, execution MUST revert\n if (unpackedValidationData.authorizer != address(0) && unpackedValidationData.authorizer != address(1))\n {\n revert InvalidAuthorizer();\n }\n }\n if (nextHook.pack() == SENTINEL_BYTES21) {\n break;\n }\n startHook = nextHook;\n }\n return unpackedValidationData;\n }\n\n function _checkAccessRuleFromEPOrAcctItself() internal view {\n if (msg.sender != address(ENTRY_POINT) && msg.sender != address(this)) {\n revert UnauthorizedCaller();\n }\n }\n}\n"},"lib/account-abstraction/contracts/interfaces/UserOperation.sol":{"content":"// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.12;\n\n/* solhint-disable no-inline-assembly */\n\nimport {calldataKeccak} from \"../core/Helpers.sol\";\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 callGasLimit the gas limit passed to the callData method call.\n * @param verificationGasLimit gas used for validateUserOp and validatePaymasterUserOp.\n * @param preVerificationGas gas not calculated by the handleOps method, but added to the gas paid. Covers batch overhead.\n * @param maxFeePerGas same as EIP-1559 gas parameter.\n * @param maxPriorityFeePerGas same as EIP-1559 gas parameter.\n * @param paymasterAndData if set, this field holds the paymaster address and paymaster-specific data. 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 */\n struct UserOperation {\n\n address sender;\n uint256 nonce;\n bytes initCode;\n bytes callData;\n uint256 callGasLimit;\n uint256 verificationGasLimit;\n uint256 preVerificationGas;\n uint256 maxFeePerGas;\n uint256 maxPriorityFeePerGas;\n bytes paymasterAndData;\n bytes signature;\n }\n\n/**\n * Utility functions helpful when working with UserOperation structs.\n */\nlibrary UserOperationLib {\n\n function getSender(UserOperation calldata userOp) internal pure returns (address) {\n address data;\n //read sender from userOp, which is first userOp member (saves 800 gas...)\n assembly {data := calldataload(userOp)}\n return address(uint160(data));\n }\n\n //relayer/block builder might submit the TX with higher priorityFee, but the user should not\n // pay above what he signed for.\n function gasPrice(UserOperation calldata userOp) internal view returns (uint256) {\n unchecked {\n uint256 maxFeePerGas = userOp.maxFeePerGas;\n uint256 maxPriorityFeePerGas = userOp.maxPriorityFeePerGas;\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 function pack(UserOperation calldata userOp) 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 uint256 callGasLimit = userOp.callGasLimit;\n uint256 verificationGasLimit = userOp.verificationGasLimit;\n uint256 preVerificationGas = userOp.preVerificationGas;\n uint256 maxFeePerGas = userOp.maxFeePerGas;\n uint256 maxPriorityFeePerGas = userOp.maxPriorityFeePerGas;\n bytes32 hashPaymasterAndData = calldataKeccak(userOp.paymasterAndData);\n\n return abi.encode(\n sender, nonce,\n hashInitCode, hashCallData,\n callGasLimit, verificationGasLimit, preVerificationGas,\n maxFeePerGas, maxPriorityFeePerGas,\n hashPaymasterAndData\n );\n }\n\n function hash(UserOperation calldata userOp) internal pure returns (bytes32) {\n return keccak256(pack(userOp));\n }\n\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n}\n"},"node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/UUPSUpgradeable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../interfaces/draft-IERC1822Upgradeable.sol\";\nimport \"../ERC1967/ERC1967UpgradeUpgradeable.sol\";\nimport {Initializable} from \"./Initializable.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 *\n * _Available since v4.1._\n */\nabstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable {\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment\n address private immutable __self = address(this);\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 require(address(this) != __self, \"Function must be called through delegatecall\");\n require(_getImplementation() == __self, \"Function must be called through active proxy\");\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 require(address(this) == __self, \"UUPSUpgradeable: must not be called through delegatecall\");\n _;\n }\n\n function __UUPSUpgradeable_init() internal onlyInitializing {\n }\n\n function __UUPSUpgradeable_init_unchained() internal onlyInitializing {\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 override notDelegated returns (bytes32) {\n return _IMPLEMENTATION_SLOT;\n }\n\n /**\n * @dev Upgrade the implementation of the proxy to `newImplementation`.\n *\n * Calls {_authorizeUpgrade}.\n *\n * Emits an {Upgraded} event.\n *\n * @custom:oz-upgrades-unsafe-allow-reachable delegatecall\n */\n function upgradeTo(address newImplementation) public virtual onlyProxy {\n _authorizeUpgrade(newImplementation);\n _upgradeToAndCallUUPS(newImplementation, new bytes(0), false);\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, true);\n }\n\n /**\n * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by\n * {upgradeTo} and {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 override onlyOwner {}\n * ```\n */\n function _authorizeUpgrade(address newImplementation) internal virtual;\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n"},"node_modules/@openzeppelin/contracts/interfaces/IERC1271.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC1271.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC1271 standard signature validation method for\n * contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271].\n *\n * _Available since v4.1._\n */\ninterface IERC1271 {\n /**\n * @dev Should return whether the signature provided is valid for the provided data\n * @param hash Hash of the data to be signed\n * @param signature Signature byte array associated with _data\n */\n function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue);\n}\n"},"node_modules/@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev _Available since v3.1._\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"},"node_modules/@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\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 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"},"node_modules/@openzeppelin/contracts/utils/cryptography/ECDSA.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Strings.sol\";\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 InvalidSignatureV // Deprecated in v4.8\n }\n\n function _throwError(RecoverError error) private pure {\n if (error == RecoverError.NoError) {\n return; // no error: do nothing\n } else if (error == RecoverError.InvalidSignature) {\n revert(\"ECDSA: invalid signature\");\n } else if (error == RecoverError.InvalidSignatureLength) {\n revert(\"ECDSA: invalid signature length\");\n } else if (error == RecoverError.InvalidSignatureS) {\n revert(\"ECDSA: invalid signature 's' value\");\n }\n }\n\n /**\n * @dev Returns the address that signed a hashed message (`hash`) with\n * `signature` or error string. This address can then be used for verification purposes.\n *\n * The `ecrecover` EVM opcode 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 {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 * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\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);\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 opcode 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 {toEthSignedMessageHash} on it.\n */\n function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, signature);\n _throwError(error);\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 * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError) {\n bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n uint8 v = uint8((uint256(vs) >> 255) + 27);\n return tryRecover(hash, v, r, s);\n }\n\n /**\n * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n *\n * _Available since v4.2._\n */\n function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {\n (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n _throwError(error);\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 * _Available since v4.3._\n */\n function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address, RecoverError) {\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);\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);\n }\n\n return (signer, RecoverError.NoError);\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) = tryRecover(hash, v, r, s);\n _throwError(error);\n return recovered;\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 message) {\n // 32 is the length in bytes of hash,\n // enforced by the type signature above\n /// @solidity memory-safe-assembly\n assembly {\n mstore(0x00, \"\\x19Ethereum Signed Message:\\n32\")\n mstore(0x1c, hash)\n message := keccak256(0x00, 0x3c)\n }\n }\n\n /**\n * @dev Returns an Ethereum Signed Message, created from `s`. This\n * produces hash corresponding to the one signed with the\n * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n * JSON-RPC method as part of EIP-191.\n *\n * See {recover}.\n */\n function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", Strings.toString(s.length), s));\n }\n\n /**\n * @dev Returns an Ethereum Signed Typed Data, created from a\n * `domainSeparator` and a `structHash`. This produces hash corresponding\n * to the one signed with the\n * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n * JSON-RPC method as part of EIP-712.\n *\n * See {recover}.\n */\n function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 data) {\n /// @solidity memory-safe-assembly\n assembly {\n let ptr := mload(0x40)\n mstore(ptr, \"\\x19\\x01\")\n mstore(add(ptr, 0x02), domainSeparator)\n mstore(add(ptr, 0x22), structHash)\n data := keccak256(ptr, 0x42)\n }\n }\n\n /**\n * @dev Returns an Ethereum Signed Data with intended validator, created from a\n * `validator` and `data` according to the version 0 of EIP-191.\n *\n * See {recover}.\n */\n function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {\n return keccak256(abi.encodePacked(\"\\x19\\x00\", validator, data));\n }\n}\n"},"src/erc712/BaseERC712CompliantAccount.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\nimport {MessageHashUtils} from \"../libs/MessageHashUtils.sol\";\n\nabstract contract BaseERC712CompliantAccount {\n // keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\")\n bytes32 private constant _DOMAIN_SEPARATOR_TYPEHASH =\n keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\");\n\n /// @notice Wraps a replay safe hash in an EIP-712 envelope to prevent cross-account replay attacks.\n /// domainSeparator = hashStruct(eip712Domain).\n /// eip712Domain = (string name,string version,uint256 chainId,address verifyingContract)\n /// hashStruct(s) = keccak256(typeHash ‖ encodeData(s)) where typeHash = keccak256(encodeType(typeOf(s)))\n /// @param hash Message that should be hashed.\n /// @return Replay safe message hash.\n function getReplaySafeMessageHash(bytes32 hash) public view returns (bytes32) {\n return MessageHashUtils.toTypedDataHash({\n domainSeparator: keccak256(\n abi.encode(\n _DOMAIN_SEPARATOR_TYPEHASH, _getAccountName(), _getAccountVersion(), block.chainid, address(this)\n )\n ),\n structHash: keccak256(abi.encode(_getAccountTypeHash(), hash))\n });\n }\n\n /// @dev Returns the account message typehash.\n function _getAccountTypeHash() internal pure virtual returns (bytes32);\n\n /// @dev Returns the account name.\n function _getAccountName() internal pure virtual returns (bytes32);\n\n /// @dev Returns the account version.\n function _getAccountVersion() internal pure virtual returns (bytes32);\n}\n"},"node_modules/@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/SignatureChecker.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./ECDSA.sol\";\nimport \"../../interfaces/IERC1271.sol\";\n\n/**\n * @dev Signature verification helper that can be used instead of `ECDSA.recover` to seamlessly support both ECDSA\n * signatures from externally owned accounts (EOAs) as well as ERC1271 signatures from smart contract wallets like\n * Argent and Gnosis Safe.\n *\n * _Available since v4.1._\n */\nlibrary SignatureChecker {\n /**\n * @dev Checks if a signature is valid for a given signer and data hash. If the signer is a smart contract, the\n * signature is validated against that smart contract using ERC1271, otherwise it's validated using `ECDSA.recover`.\n *\n * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus\n * change through time. It could return true at block N and false at block N+1 (or the opposite).\n */\n function isValidSignatureNow(address signer, bytes32 hash, bytes memory signature) internal view returns (bool) {\n (address recovered, ECDSA.RecoverError error) = ECDSA.tryRecover(hash, signature);\n return\n (error == ECDSA.RecoverError.NoError && recovered == signer) ||\n isValidERC1271SignatureNow(signer, hash, signature);\n }\n\n /**\n * @dev Checks if a signature is valid for a given signer and data hash. The signature is validated\n * against the signer smart contract using ERC1271.\n *\n * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus\n * change through time. It could return true at block N and false at block N+1 (or the opposite).\n */\n function isValidERC1271SignatureNow(\n address signer,\n bytes32 hash,\n bytes memory signature\n ) internal view returns (bool) {\n (bool success, bytes memory result) = signer.staticcall(\n abi.encodeWithSelector(IERC1271.isValidSignature.selector, hash, signature)\n );\n return (success &&\n result.length >= 32 &&\n abi.decode(result, (bytes32)) == bytes32(IERC1271.isValidSignature.selector));\n }\n}\n"},"src/msca/6900/shared/libs/AddressDLLLib.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\nimport {InvalidLimit, ItemAlreadyExists, ItemDoesNotExist} from \"../common/Errors.sol\";\nimport {AddressDLL} from \"../common/Structs.sol\";\n\n/**\n * @dev Enumerable & ordered doubly linked list built using mapping(address => address).\n * Item is expected to be unique.\n */\nlibrary AddressDLLLib {\n address internal constant SENTINEL_ADDRESS = address(0x0);\n uint160 internal constant SENTINEL_ADDRESS_UINT = 0;\n\n event AddressAdded(address indexed addr);\n event AddressRemoved(address indexed addr);\n\n error InvalidAddress();\n\n modifier validAddress(address addr) {\n if (uint160(addr) <= SENTINEL_ADDRESS_UINT) {\n revert InvalidAddress();\n }\n _;\n }\n\n /**\n * @dev Check if an item exists or not. O(1).\n */\n function contains(AddressDLL storage dll, address item) internal view returns (bool) {\n if (item == SENTINEL_ADDRESS) {\n // SENTINEL_ADDRESS is not a valid item\n return false;\n }\n return getHead(dll) == item || dll.next[item] != SENTINEL_ADDRESS || dll.prev[item] != SENTINEL_ADDRESS;\n }\n\n /**\n * @dev Get the count of dll. O(1).\n */\n function size(AddressDLL storage dll) internal view returns (uint256) {\n return dll.count;\n }\n\n /**\n * @dev Add an new item which did not exist before. Otherwise the function reverts. O(1).\n */\n function append(AddressDLL storage dll, address item) internal validAddress(item) returns (bool) {\n if (contains(dll, item)) {\n revert ItemAlreadyExists();\n }\n address prev = getTail(dll);\n address next = SENTINEL_ADDRESS;\n // prev.next = item\n dll.next[prev] = item;\n // item.next = next\n dll.next[item] = next;\n // next.prev = item\n dll.prev[next] = item;\n // item.prev = prev\n dll.prev[item] = prev;\n dll.count++;\n emit AddressAdded(item);\n return true;\n }\n\n /**\n * @dev Remove an already existing item. Otherwise the function reverts. O(1).\n */\n function remove(AddressDLL storage dll, address item) internal validAddress(item) returns (bool) {\n if (!contains(dll, item)) {\n revert ItemDoesNotExist();\n }\n // item.prev.next = item.next\n dll.next[dll.prev[item]] = dll.next[item];\n // item.next.prev = item.prev\n dll.prev[dll.next[item]] = dll.prev[item];\n delete dll.next[item];\n delete dll.prev[item];\n dll.count--;\n emit AddressRemoved(item);\n return true;\n }\n\n /**\n * @dev Return paginated addresses and next pointer address. O(n).\n * @param start Starting address, inclusive, if start == address(0x0), this method searches from the head.\n */\n function getPaginated(AddressDLL storage dll, address start, uint256 limit)\n internal\n view\n returns (address[] memory, address)\n {\n if (limit == 0) {\n revert InvalidLimit();\n }\n address[] memory results = new address[](limit);\n address current = start;\n if (start == SENTINEL_ADDRESS) {\n current = getHead(dll);\n }\n uint256 count = 0;\n for (; count < limit && uint160(current) > SENTINEL_ADDRESS_UINT; ++count) {\n results[count] = current;\n current = dll.next[current];\n }\n\n // solhint-disable-next-line no-inline-assembly\n assembly (\"memory-safe\") {\n mstore(results, count)\n }\n return (results, current);\n }\n\n /**\n * @dev Return all the data. O(n).\n */\n function getAll(AddressDLL storage dll) internal view returns (address[] memory results) {\n uint256 totalCount = size(dll);\n results = new address[](totalCount);\n address current = getHead(dll);\n uint256 count = 0;\n for (; count < totalCount && uint160(current) > SENTINEL_ADDRESS_UINT; ++count) {\n results[count] = current;\n current = dll.next[current];\n }\n return results;\n }\n\n function getHead(AddressDLL storage dll) internal view returns (address) {\n return dll.next[SENTINEL_ADDRESS];\n }\n\n function getTail(AddressDLL storage dll) internal view returns (address) {\n return dll.prev[SENTINEL_ADDRESS];\n }\n}\n"},"src/msca/6900/v0.7/common/PluginManifest.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\n// Plugin Manifest\nenum ManifestAssociatedFunctionType {\n // Function is not defined.\n NONE,\n // Function belongs to this plugin.\n SELF,\n // Function belongs to an external plugin provided as a dependency during plugin installation.\n DEPENDENCY,\n // Resolves to a magic value to always bypass runtime validation for a given function.\n // This is only assignable on runtime validation functions. If it were to be used on a user op validation function,\n // it would risk burning gas from the account. When used as a hook in any hook location, it is equivalent to not\n // setting a hook and is therefore disallowed.\n RUNTIME_VALIDATION_ALWAYS_ALLOW,\n // Resolves to a magic value to always fail in a hook for a given function.\n // This is only assignable to pre hooks (pre validation and pre execution). It should not be used on\n // validation functions themselves, because this is equivalent to leaving the validation functions unset.\n // It should not be used in post-exec hooks, because if it is known to always revert, that should happen\n // as early as possible to save gas.\n PRE_HOOK_ALWAYS_DENY\n}\n\n/// @dev For functions of type `ManifestAssociatedFunctionType.DEPENDENCY`, the MSCA MUST find the plugin address\n/// of the function at `dependencies[dependencyIndex]` during the call to `installPlugin(config)`.\nstruct ManifestFunction {\n ManifestAssociatedFunctionType functionType;\n uint8 functionId;\n uint256 dependencyIndex;\n}\n\nstruct ManifestAssociatedFunction {\n bytes4 executionSelector;\n ManifestFunction associatedFunction;\n}\n\nstruct ManifestExecutionHook {\n bytes4 selector;\n ManifestFunction preExecHook;\n ManifestFunction postExecHook;\n}\n\nstruct ManifestExternalCallPermission {\n address externalAddress;\n bool permitAnySelector;\n bytes4[] selectors;\n}\n\nstruct SelectorPermission {\n bytes4 functionSelector;\n string permissionDescription;\n}\n\n/// @dev A struct holding fields to describe the plugin in a purely view context. Intended for front end clients.\nstruct PluginMetadata {\n // A human-readable name of the plugin.\n string name;\n // The version of the plugin, following the semantic versioning scheme.\n string version;\n // The author field SHOULD be a username representing the identity of the user or organization\n // that created this plugin.\n string author;\n // String descriptions of the relative sensitivity of specific functions. The selectors MUST be selectors for\n // functions implemented by this plugin.\n SelectorPermission[] permissionDescriptors;\n}\n\n/// @dev A struct describing how the plugin should be installed on a modular account.\nstruct PluginManifest {\n // List of ERC-165 interface IDs to add to account to support introspection checks. This MUST NOT include\n // IPlugin's interface ID.\n bytes4[] interfaceIds;\n // If this plugin depends on other plugins' validation functions, the interface IDs of those plugins MUST be\n // provided here, with its position in the array matching the `dependencyIndex` members of `ManifestFunction`\n bytes4[] dependencyInterfaceIds;\n // Execution functions defined in this plugin to be installed on the MSCA.\n bytes4[] executionFunctions;\n // Plugin execution functions already installed on the MSCA that this plugin will be able to call.\n bytes4[] permittedExecutionSelectors;\n // Boolean to indicate whether the plugin can call any external address.\n bool permitAnyExternalAddress;\n // Boolean to indicate whether the plugin needs access to spend native tokens of the account. If false, the\n // plugin MUST still be able to spend up to the balance that it sends to the account in the same call.\n bool canSpendNativeToken;\n // More granular control\n ManifestExternalCallPermission[] permittedExternalCalls;\n ManifestAssociatedFunction[] userOpValidationFunctions;\n ManifestAssociatedFunction[] runtimeValidationFunctions;\n ManifestAssociatedFunction[] preUserOpValidationHooks;\n ManifestAssociatedFunction[] preRuntimeValidationHooks;\n // for executionFunctions\n ManifestExecutionHook[] executionHooks;\n}\n"},"src/msca/6900/v0.7/libs/FunctionReferenceDLLLib.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\nimport {SENTINEL_BYTES21} from \"../../../../common/Constants.sol\";\nimport {\n InvalidFunctionReference, InvalidLimit, ItemAlreadyExists, ItemDoesNotExist\n} from \"../../shared/common/Errors.sol\";\nimport {Bytes21DLL, FunctionReference} from \"../common/Structs.sol\";\nimport {FunctionReferenceLib} from \"./FunctionReferenceLib.sol\";\n\n/**\n * @dev Enumerable & ordered doubly linked list built using mapping(bytes21 => bytes21) for function reference.\n * Item is expected to be unique.\n */\nlibrary FunctionReferenceDLLLib {\n using FunctionReferenceLib for FunctionReference;\n using FunctionReferenceLib for bytes21;\n\n modifier validFunctionReference(FunctionReference memory fr) {\n if (fr.pack() <= SENTINEL_BYTES21) {\n revert InvalidFunctionReference();\n }\n _;\n }\n\n /**\n * @dev Check if an item exists or not. O(1).\n */\n function contains(Bytes21DLL storage dll, FunctionReference memory fr) internal view returns (bool) {\n return contains(dll, fr.pack());\n }\n\n function contains(Bytes21DLL storage dll, bytes21 item) internal view returns (bool) {\n if (item == SENTINEL_BYTES21) {\n return false;\n }\n return getHeadWithoutUnpack(dll) == item || dll.next[item] != SENTINEL_BYTES21\n || dll.prev[item] != SENTINEL_BYTES21;\n }\n\n /**\n * @dev Get the count of dll. O(1).\n */\n function size(Bytes21DLL storage dll) internal view returns (uint256) {\n return dll.count;\n }\n\n /**\n * @dev Add an new item which did not exist before. Otherwise the function reverts. O(1).\n */\n function append(Bytes21DLL storage dll, FunctionReference memory fr)\n internal\n validFunctionReference(fr)\n returns (bool)\n {\n bytes21 item = fr.pack();\n if (contains(dll, item)) {\n revert ItemAlreadyExists();\n }\n bytes21 prev = getTailWithoutUnpack(dll);\n bytes21 next = SENTINEL_BYTES21;\n // prev.next = item\n dll.next[prev] = item;\n // item.next = next\n dll.next[item] = next;\n // next.prev = item\n dll.prev[next] = item;\n // item.prev = prev\n dll.prev[item] = prev;\n dll.count++;\n return true;\n }\n\n /**\n * @dev Remove an already existing item. Otherwise the function reverts. O(1).\n */\n function remove(Bytes21DLL storage dll, FunctionReference memory fr)\n internal\n validFunctionReference(fr)\n returns (bool)\n {\n bytes21 item = fr.pack();\n if (!contains(dll, item)) {\n revert ItemDoesNotExist();\n }\n // item.prev.next = item.next\n dll.next[dll.prev[item]] = dll.next[item];\n // item.next.prev = item.prev\n dll.prev[dll.next[item]] = dll.prev[item];\n delete dll.next[item];\n delete dll.prev[item];\n dll.count--;\n return true;\n }\n\n /**\n * @dev Return paginated bytes21s and next pointer bytes21. O(n).\n * @param startFR Starting bytes21, inclusive, if start == bytes21(0), this method searches from the head.\n */\n function getPaginated(Bytes21DLL storage dll, FunctionReference memory startFR, uint256 limit)\n internal\n view\n returns (FunctionReference[] memory, FunctionReference memory)\n {\n if (limit == 0) {\n revert InvalidLimit();\n }\n bytes21 start = startFR.pack();\n FunctionReference[] memory results = new FunctionReference[](limit);\n bytes21 current = start;\n if (start == SENTINEL_BYTES21) {\n current = getHeadWithoutUnpack(dll);\n }\n uint256 count = 0;\n for (; count < limit && current > SENTINEL_BYTES21; ++count) {\n results[count] = current.unpack();\n current = dll.next[current];\n }\n // solhint-disable-next-line no-inline-assembly\n assembly (\"memory-safe\") {\n mstore(results, count)\n }\n return (results, current.unpack());\n }\n\n /**\n * @dev Return all the data. O(n).\n */\n function getAll(Bytes21DLL storage dll) internal view returns (FunctionReference[] memory results) {\n uint256 totalCount = size(dll);\n results = new FunctionReference[](totalCount);\n bytes21 current = getHeadWithoutUnpack(dll);\n uint256 count = 0;\n for (; count < totalCount && current > SENTINEL_BYTES21; ++count) {\n results[count] = current.unpack();\n current = dll.next[current];\n }\n return results;\n }\n\n function getHead(Bytes21DLL storage dll) internal view returns (FunctionReference memory) {\n return dll.next[SENTINEL_BYTES21].unpack();\n }\n\n function getTail(Bytes21DLL storage dll) internal view returns (FunctionReference memory) {\n return dll.prev[SENTINEL_BYTES21].unpack();\n }\n\n function getHeadWithoutUnpack(Bytes21DLL storage dll) private view returns (bytes21) {\n return dll.next[SENTINEL_BYTES21];\n }\n\n function getTailWithoutUnpack(Bytes21DLL storage dll) private view returns (bytes21) {\n return dll.prev[SENTINEL_BYTES21];\n }\n}\n"},"src/msca/6900/v0.7/libs/SelectorRegistryLib.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\nimport {IAccountLoupe} from \"../interfaces/IAccountLoupe.sol\";\n\nimport {IPlugin} from \"../interfaces/IPlugin.sol\";\nimport {IPluginExecutor} from \"../interfaces/IPluginExecutor.sol\";\nimport {IPluginManager} from \"../interfaces/IPluginManager.sol\";\nimport {IStandardExecutor} from \"../interfaces/IStandardExecutor.sol\";\n\nimport {IAccount} from \"@account-abstraction/contracts/interfaces/IAccount.sol\";\nimport {IAggregator} from \"@account-abstraction/contracts/interfaces/IAggregator.sol\";\nimport {IPaymaster} from \"@account-abstraction/contracts/interfaces/IPaymaster.sol\";\nimport {UUPSUpgradeable} from \"@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol\";\n\nimport {IERC777Recipient} from \"@openzeppelin/contracts/interfaces/IERC777Recipient.sol\";\nimport {IERC1155Receiver} from \"@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol\";\nimport {IERC721Receiver} from \"@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol\";\nimport {IERC165} from \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\n\nlibrary SelectorRegistryLib {\n bytes4 internal constant INITIALIZE_UPGRADABLE_MSCA =\n bytes4(keccak256(\"initializeUpgradableMSCA(address[],bytes32[],bytes[])\"));\n bytes4 internal constant INITIALIZE_SINGLE_OWNER_MSCA = bytes4(keccak256(\"initializeSingleOwnerMSCA(address)\"));\n bytes4 internal constant TRANSFER_NATIVE_OWNERSHIP = bytes4(keccak256(\"transferNativeOwnership(address)\"));\n bytes4 internal constant RENOUNCE_NATIVE_OWNERSHIP = bytes4(keccak256(\"renounceNativeOwnership()\"));\n bytes4 internal constant GET_NATIVE_OWNER = bytes4(keccak256(\"getNativeOwner()\"));\n bytes4 internal constant GET_ENTRYPOINT = bytes4(keccak256(\"getEntryPoint()\"));\n bytes4 internal constant GET_NONCE = bytes4(keccak256(\"getNonce()\"));\n\n /**\n * @dev Check if the selector is for native function.\n * @param selector the function selector.\n */\n function _isNativeFunctionSelector(bytes4 selector) internal pure returns (bool) {\n return selector == IStandardExecutor.execute.selector || selector == IStandardExecutor.executeBatch.selector\n || selector == IPluginManager.installPlugin.selector || selector == IPluginManager.uninstallPlugin.selector\n || selector == UUPSUpgradeable.upgradeTo.selector || selector == UUPSUpgradeable.upgradeToAndCall.selector\n || selector == UUPSUpgradeable.proxiableUUID.selector\n // check against IERC165 methods\n || selector == IERC165.supportsInterface.selector\n // check against IPluginExecutor methods\n || selector == IPluginExecutor.executeFromPlugin.selector\n || selector == IPluginExecutor.executeFromPluginExternal.selector\n // check against IAccountLoupe methods\n || selector == IAccountLoupe.getExecutionFunctionConfig.selector\n || selector == IAccountLoupe.getExecutionHooks.selector\n || selector == IAccountLoupe.getPreValidationHooks.selector\n || selector == IAccountLoupe.getInstalledPlugins.selector || selector == IAccount.validateUserOp.selector\n || selector == GET_ENTRYPOINT || selector == GET_NONCE || selector == INITIALIZE_UPGRADABLE_MSCA\n || selector == INITIALIZE_SINGLE_OWNER_MSCA || selector == TRANSFER_NATIVE_OWNERSHIP\n || selector == RENOUNCE_NATIVE_OWNERSHIP || selector == GET_NATIVE_OWNER\n || selector == IERC1155Receiver.onERC1155Received.selector\n || selector == IERC1155Receiver.onERC1155BatchReceived.selector\n || selector == IERC721Receiver.onERC721Received.selector || selector == IERC777Recipient.tokensReceived.selector;\n }\n\n function _isErc4337FunctionSelector(bytes4 selector) internal pure returns (bool) {\n return selector == IAggregator.validateSignatures.selector\n || selector == IAggregator.validateUserOpSignature.selector\n || selector == IAggregator.aggregateSignatures.selector\n || selector == IPaymaster.validatePaymasterUserOp.selector || selector == IPaymaster.postOp.selector;\n }\n\n function _isIPluginFunctionSelector(bytes4 selector) internal pure returns (bool) {\n return selector == IPlugin.onInstall.selector || selector == IPlugin.onUninstall.selector\n || selector == IPlugin.preUserOpValidationHook.selector || selector == IPlugin.userOpValidationFunction.selector\n || selector == IPlugin.preRuntimeValidationHook.selector\n || selector == IPlugin.runtimeValidationFunction.selector || selector == IPlugin.preExecutionHook.selector\n || selector == IPlugin.postExecutionHook.selector || selector == IPlugin.pluginManifest.selector\n || selector == IPlugin.pluginMetadata.selector;\n }\n}\n"},"node_modules/@openzeppelin/contracts/utils/introspection/ERC165Checker.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/introspection/ERC165Checker.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Library used to query support of an interface declared via {IERC165}.\n *\n * Note that these functions return the actual result of the query: they do not\n * `revert` if an interface is not supported. It is up to the caller to decide\n * what to do in these cases.\n */\nlibrary ERC165Checker {\n // As per the EIP-165 spec, no interface should ever match 0xffffffff\n bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff;\n\n /**\n * @dev Returns true if `account` supports the {IERC165} interface.\n */\n function supportsERC165(address account) internal view returns (bool) {\n // Any contract that implements ERC165 must explicitly indicate support of\n // InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid\n return\n supportsERC165InterfaceUnchecked(account, type(IERC165).interfaceId) &&\n !supportsERC165InterfaceUnchecked(account, _INTERFACE_ID_INVALID);\n }\n\n /**\n * @dev Returns true if `account` supports the interface defined by\n * `interfaceId`. Support for {IERC165} itself is queried automatically.\n *\n * See {IERC165-supportsInterface}.\n */\n function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) {\n // query support of both ERC165 as per the spec and support of _interfaceId\n return supportsERC165(account) && supportsERC165InterfaceUnchecked(account, interfaceId);\n }\n\n /**\n * @dev Returns a boolean array where each value corresponds to the\n * interfaces passed in and whether they're supported or not. This allows\n * you to batch check interfaces for a contract where your expectation\n * is that some interfaces may not be supported.\n *\n * See {IERC165-supportsInterface}.\n *\n * _Available since v3.4._\n */\n function getSupportedInterfaces(\n address account,\n bytes4[] memory interfaceIds\n ) internal view returns (bool[] memory) {\n // an array of booleans corresponding to interfaceIds and whether they're supported or not\n bool[] memory interfaceIdsSupported = new bool[](interfaceIds.length);\n\n // query support of ERC165 itself\n if (supportsERC165(account)) {\n // query support of each interface in interfaceIds\n for (uint256 i = 0; i < interfaceIds.length; i++) {\n interfaceIdsSupported[i] = supportsERC165InterfaceUnchecked(account, interfaceIds[i]);\n }\n }\n\n return interfaceIdsSupported;\n }\n\n /**\n * @dev Returns true if `account` supports all the interfaces defined in\n * `interfaceIds`. Support for {IERC165} itself is queried automatically.\n *\n * Batch-querying can lead to gas savings by skipping repeated checks for\n * {IERC165} support.\n *\n * See {IERC165-supportsInterface}.\n */\n function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) {\n // query support of ERC165 itself\n if (!supportsERC165(account)) {\n return false;\n }\n\n // query support of each interface in interfaceIds\n for (uint256 i = 0; i < interfaceIds.length; i++) {\n if (!supportsERC165InterfaceUnchecked(account, interfaceIds[i])) {\n return false;\n }\n }\n\n // all interfaces supported\n return true;\n }\n\n /**\n * @notice Query if a contract implements an interface, does not check ERC165 support\n * @param account The address of the contract to query for support of an interface\n * @param interfaceId The interface identifier, as specified in ERC-165\n * @return true if the contract at account indicates support of the interface with\n * identifier interfaceId, false otherwise\n * @dev Assumes that account contains a contract that supports ERC165, otherwise\n * the behavior of this method is undefined. This precondition can be checked\n * with {supportsERC165}.\n *\n * Some precompiled contracts will falsely indicate support for a given interface, so caution\n * should be exercised when using this function.\n *\n * Interface identification is specified in ERC-165.\n */\n function supportsERC165InterfaceUnchecked(address account, bytes4 interfaceId) internal view returns (bool) {\n // prepare call\n bytes memory encodedParams = abi.encodeWithSelector(IERC165.supportsInterface.selector, interfaceId);\n\n // perform static call\n bool success;\n uint256 returnSize;\n uint256 returnValue;\n assembly {\n success := staticcall(30000, account, add(encodedParams, 0x20), mload(encodedParams), 0x00, 0x20)\n returnSize := returndatasize()\n returnValue := mload(0x00)\n }\n\n return success && returnSize >= 0x20 && returnValue > 0;\n }\n}\n"},"lib/account-abstraction/contracts/interfaces/IStakeManager.sol":{"content":"// SPDX-License-Identifier: GPL-3.0-only\npragma solidity ^0.8.12;\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\n event Deposited(\n address indexed account,\n uint256 totalDeposit\n );\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(\n address indexed account,\n uint256 withdrawTime\n );\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,staked, stake) fit into one cell (used during handleOps)\n * and the rest fit into a 2nd cell.\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 uint112 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 /// @return info - full deposit information of given account\n function getDepositInfo(address account) external view returns (DepositInfo memory info);\n\n /// @return the deposit (for gas payment) of the account\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * add to the deposit of the given account\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(address payable withdrawAddress, uint256 withdrawAmount) external;\n}\n"},"lib/account-abstraction/contracts/interfaces/IAggregator.sol":{"content":"// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.12;\n\nimport \"./UserOperation.sol\";\n\n/**\n * Aggregated Signatures validator.\n */\ninterface IAggregator {\n\n /**\n * validate aggregated signature.\n * revert if the aggregated signature does not match the given list of operations.\n */\n function validateSignatures(UserOperation[] calldata userOps, bytes calldata signature) external view;\n\n /**\n * validate signature of a single userOp\n * This method is should be called by bundler after EntryPoint.simulateValidation() returns (reverts) with ValidationResultWithAggregation\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(UserOperation 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(UserOperation[] calldata userOps) external view returns (bytes memory aggregatedSignature);\n}\n"},"lib/account-abstraction/contracts/interfaces/INonceManager.sol":{"content":"// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.12;\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"},"node_modules/@openzeppelin/contracts/proxy/Proxy.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\n * be specified by overriding the virtual {_implementation} function.\n *\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\n * different contract through the {_delegate} function.\n *\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\n */\nabstract contract Proxy {\n /**\n * @dev Delegates the current call to `implementation`.\n *\n * This function does not return to its internal call site, it will return directly to the external caller.\n */\n function _delegate(address implementation) internal virtual {\n assembly {\n // Copy msg.data. We take full control of memory in this inline assembly\n // block because it will not return to Solidity code. We overwrite the\n // Solidity scratch pad at memory position 0.\n calldatacopy(0, 0, calldatasize())\n\n // Call the implementation.\n // out and outsize are 0 because we don't know the size yet.\n let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\n\n // Copy the returned data.\n returndatacopy(0, 0, returndatasize())\n\n switch result\n // delegatecall returns 0 on error.\n case 0 {\n revert(0, returndatasize())\n }\n default {\n return(0, returndatasize())\n }\n }\n }\n\n /**\n * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\n * and {_fallback} should delegate.\n */\n function _implementation() internal view virtual returns (address);\n\n /**\n * @dev Delegates the current call to the address returned by `_implementation()`.\n *\n * This function does not return to its internal call site, it will return directly to the external caller.\n */\n function _fallback() internal virtual {\n _beforeFallback();\n _delegate(_implementation());\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\n * function in the contract matches the call data.\n */\n fallback() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\n * is empty.\n */\n receive() external payable virtual {\n _fallback();\n }\n\n /**\n * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\n * call, or as part of the Solidity `fallback` or `receive` functions.\n *\n * If overridden should call `super._beforeFallback()`.\n */\n function _beforeFallback() internal virtual {}\n}\n"},"node_modules/@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/ERC1967/ERC1967Upgrade.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../beacon/IBeacon.sol\";\nimport \"../../interfaces/IERC1967.sol\";\nimport \"../../interfaces/draft-IERC1822.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../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 *\n * _Available since v4.1._\n */\nabstract contract ERC1967Upgrade is IERC1967 {\n // This is the keccak-256 hash of \"eip1967.proxy.rollback\" subtracted by 1\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\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, and is\n * validated in the constructor.\n */\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\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 require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n }\n\n /**\n * @dev Perform implementation upgrade\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeTo(address newImplementation) internal {\n _setImplementation(newImplementation);\n emit Upgraded(newImplementation);\n }\n\n /**\n * @dev Perform implementation upgrade with additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCall(address newImplementation, bytes memory data, bool forceCall) internal {\n _upgradeTo(newImplementation);\n if (data.length > 0 || forceCall) {\n Address.functionDelegateCall(newImplementation, data);\n }\n }\n\n /**\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCallUUPS(address newImplementation, bytes memory data, bool forceCall) internal {\n // Upgrades from old implementations will perform a rollback test. This test requires the new\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\n // this special case will break upgrade paths from old UUPS implementation to new ones.\n if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\n _setImplementation(newImplementation);\n } else {\n try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\n require(slot == _IMPLEMENTATION_SLOT, \"ERC1967Upgrade: unsupported proxiableUUID\");\n } catch {\n revert(\"ERC1967Upgrade: new implementation is not UUPS\");\n }\n _upgradeToAndCall(newImplementation, data, forceCall);\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, and is\n * validated in the constructor.\n */\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n /**\n * @dev Returns the current admin.\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 require(newAdmin != address(0), \"ERC1967: new admin is the zero address\");\n StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\n }\n\n /**\n * @dev Changes the admin of the proxy.\n *\n * Emits an {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 bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\n */\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 require(Address.isContract(newBeacon), \"ERC1967: new beacon is not a contract\");\n require(\n Address.isContract(IBeacon(newBeacon).implementation()),\n \"ERC1967: beacon implementation is not a contract\"\n );\n StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\n }\n\n /**\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\n *\n * Emits a {BeaconUpgraded} event.\n */\n function _upgradeBeaconToAndCall(address newBeacon, bytes memory data, bool forceCall) internal {\n _setBeacon(newBeacon);\n emit BeaconUpgraded(newBeacon);\n if (data.length > 0 || forceCall) {\n Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\n }\n }\n}\n"},"node_modules/@openzeppelin/contracts/interfaces/IERC777Recipient.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC777Recipient.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../token/ERC777/IERC777Recipient.sol\";\n"},"node_modules/@openzeppelin/contracts/utils/introspection/IERC165.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\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"},"src/msca/6900/v0.7/interfaces/IAccountLoupe.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\nimport {ExecutionFunctionConfig, ExecutionHooks, FunctionReference} from \"../common/Structs.sol\";\n\n/**\n * @dev Implements https://eips.ethereum.org/EIPS/eip-6900. MSCAs may implement this interface to support visibility in\n * plugin configurations on-chain.\n */\ninterface IAccountLoupe {\n /// @notice Get the validation functions and plugin address for a selector.\n /// @dev If the selector is a native function, the plugin address will be the address of the account.\n /// @param selector The selector to get the configuration for.\n /// @return The configuration for this selector.\n function getExecutionFunctionConfig(bytes4 selector) external view returns (ExecutionFunctionConfig memory);\n\n /// @notice Get the pre and post execution hooks for a selector.\n /// @param selector The selector to get the hooks for.\n /// @return The pre and post execution hooks for this selector.\n function getExecutionHooks(bytes4 selector) external view returns (ExecutionHooks[] memory);\n\n /// @notice Get the pre user op and runtime validation hooks associated with a selector.\n /// @param selector The selector to get the hooks for.\n /// @return preUserOpValidationHooks The pre user op validation hooks for this selector.\n /// @return preRuntimeValidationHooks The pre runtime validation hooks for this selector.\n function getPreValidationHooks(bytes4 selector)\n external\n view\n returns (FunctionReference[] memory, FunctionReference[] memory);\n\n /// @notice Get an array of all installed plugins.\n /// @return pluginAddresses The addresses of all installed plugins.\n function getInstalledPlugins() external view returns (address[] memory);\n}\n"},"src/msca/6900/v0.7/interfaces/IPluginExecutor.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\n/**\n * @dev Implements https://eips.ethereum.org/EIPS/eip-6900. MSCAs must implement this interface to support execution\n * from plugins.\n */\ninterface IPluginExecutor {\n /// @notice Execute a call from a plugin through the account.\n /// @dev Permissions must be granted to the calling plugin for the call to go through.\n /// @param data The calldata to send to the account.\n function executeFromPlugin(bytes calldata data) external payable returns (bytes memory);\n\n /// @notice Execute a call from a plugin to a non-plugin address.\n /// @dev If the target is a plugin, the call SHOULD revert. Permissions must be granted to the calling plugin\n /// for the call to go through.\n /// @param target The address to be called.\n /// @param value The value to send with the call.\n /// @param data The calldata to send to the target.\n /// @return The return data from the call.\n function executeFromPluginExternal(address target, uint256 value, bytes calldata data)\n external\n payable\n returns (bytes memory);\n}\n"},"src/msca/6900/v0.7/interfaces/IPluginManager.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\nimport {FunctionReference} from \"../common/Structs.sol\";\n\n/**\n * @dev Implements https://eips.ethereum.org/EIPS/eip-6900. MSCAs must implement this interface to support installing\n * and uninstalling plugins.\n */\ninterface IPluginManager {\n event PluginInstalled(address indexed plugin, bytes32 manifestHash, FunctionReference[] dependencies);\n event PluginUninstalled(address indexed plugin, bool indexed onUninstallSucceeded);\n\n /// @notice Install a plugin to the modular account.\n /// @param plugin The plugin to install.\n /// @param manifestHash The hash of the plugin manifest.\n /// @param pluginInstallData Optional data to be decoded and used by the plugin to setup initial plugin data\n /// for the modular account.\n /// @param dependencies The dependencies of the plugin, as described in the manifest. Each FunctionReference\n /// MUST be composed of an installed plugin's address and a function ID of its validation function.\n function installPlugin(\n address plugin,\n bytes32 manifestHash,\n bytes calldata pluginInstallData,\n FunctionReference[] calldata dependencies\n ) external;\n\n /// @notice Uninstall a plugin from the modular account.\n /// @param plugin The plugin to uninstall.\n /// @param config An optional, implementation-specific field that accounts may use to ensure consistency\n /// guarantees.\n /// @param pluginUninstallData Optional data to be decoded and used by the plugin to clear plugin data for the\n /// modular account.\n function uninstallPlugin(address plugin, bytes calldata config, bytes calldata pluginUninstallData) external;\n}\n"},"src/msca/6900/v0.7/interfaces/IStandardExecutor.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\nimport {Call} from \"../common/Structs.sol\";\n\n/**\n * @dev Implements https://eips.ethereum.org/EIPS/eip-6900. MSCAs must implement this interface to support open-ended\n * execution.\n */\ninterface IStandardExecutor {\n /// @notice Standard execute method.\n /// @dev If the target is a plugin, the call SHOULD revert.\n /// @param target The target address for the account to call.\n /// @param value The value to send with the call.\n /// @param data The calldata for the call.\n /// @return The return data from the call.\n function execute(address target, uint256 value, bytes calldata data) external payable returns (bytes memory);\n\n /// @notice Standard executeBatch method.\n /// @dev If the target is a plugin, the call SHOULD revert. If any of the calls revert, the entire batch MUST\n /// revert.\n /// @param calls The array of calls.\n /// @return An array containing the return data from the calls.\n function executeBatch(Call[] calldata calls) external payable returns (bytes[] memory);\n}\n"},"src/msca/6900/v0.7/libs/ExecutionHookLib.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\nimport {EMPTY_FUNCTION_REFERENCE, SENTINEL_BYTES21} from \"../../../../common/Constants.sol\";\nimport {InvalidValidationFunctionId} from \"../../shared/common/Errors.sol\";\nimport {\n PRE_HOOK_ALWAYS_DENY_FUNCTION_REFERENCE,\n RUNTIME_VALIDATION_ALWAYS_ALLOW_FUNCTION_REFERENCE\n} from \"../common/Constants.sol\";\nimport {\n ExecutionHooks,\n FunctionReference,\n HookGroup,\n PostExecHookToRun,\n RepeatableBytes21DLL\n} from \"../common/Structs.sol\";\nimport {IPlugin} from \"../interfaces/IPlugin.sol\";\nimport {FunctionReferenceLib} from \"./FunctionReferenceLib.sol\";\nimport {RepeatableFunctionReferenceDLLLib} from \"./RepeatableFunctionReferenceDLLLib.sol\";\n\n/**\n * @dev Process pre or post execution hooks.\n */\nlibrary ExecutionHookLib {\n using RepeatableFunctionReferenceDLLLib for RepeatableBytes21DLL;\n using FunctionReferenceLib for FunctionReference;\n using FunctionReferenceLib for bytes21;\n\n error PreExecHookFailed(address plugin, uint8 functionId, bytes revertReason);\n error PostExecHookFailed(address plugin, uint8 functionId, bytes revertReason);\n\n // avoid stack too deep\n struct SetPostExecHooksFromPreHooksParam {\n uint256 totalPostExecHooksToRunCount;\n PostExecHookToRun[] postExecHooksToRun;\n }\n\n function _processPreExecHooks(HookGroup storage hookGroup, bytes calldata data)\n internal\n returns (PostExecHookToRun[] memory postExecHooksToRun)\n {\n uint256 postOnlyHooksCount = hookGroup.postOnlyHooks.getUniqueItems();\n // hooks have three categories a. preOnlyHook b. preToPostHook c. postOnlyHook\n // 1. add repeated preHook into postHook 2. add postOnlyHooks\n uint256 maxPostHooksCount = postOnlyHooksCount + hookGroup.preHooks.getTotalItems();\n uint256 totalPostExecHooksToRunCount = 0;\n postExecHooksToRun = new PostExecHookToRun[](maxPostHooksCount);\n // copy postOnlyHooks into result first\n FunctionReference memory startHook = EMPTY_FUNCTION_REFERENCE.unpack();\n for (uint256 i = 0; i < postOnlyHooksCount; ++i) {\n (FunctionReference[] memory resultPostOnlyHooks, FunctionReference memory nextHook) =\n hookGroup.postOnlyHooks.getPaginated(startHook, 10);\n for (uint256 j = 0; j < resultPostOnlyHooks.length; ++j) {\n postExecHooksToRun[totalPostExecHooksToRunCount++].postExecHook = resultPostOnlyHooks[j];\n }\n if (nextHook.pack() == SENTINEL_BYTES21) {\n break;\n }\n startHook = nextHook;\n }\n // then run the preHooks and copy associated postHooks\n SetPostExecHooksFromPreHooksParam memory input;\n input.totalPostExecHooksToRunCount = totalPostExecHooksToRunCount;\n input.postExecHooksToRun = postExecHooksToRun;\n (totalPostExecHooksToRunCount, postExecHooksToRun) = _setPostExecHooksFromPreHooks(hookGroup, data, input);\n // solhint-disable-next-line no-inline-assembly\n assembly (\"memory-safe\") {\n mstore(postExecHooksToRun, totalPostExecHooksToRunCount)\n }\n }\n\n function _processPreExecHook(FunctionReference memory preExecHook, bytes calldata data)\n internal\n returns (bytes memory preExecHookReturnData)\n {\n try IPlugin(preExecHook.plugin).preExecutionHook(preExecHook.functionId, msg.sender, msg.value, data) returns (\n bytes memory returnData\n ) {\n preExecHookReturnData = returnData;\n } catch (bytes memory revertReason) {\n revert PreExecHookFailed(preExecHook.plugin, preExecHook.functionId, revertReason);\n }\n return preExecHookReturnData;\n }\n\n function _processPostExecHooks(PostExecHookToRun[] memory postExecHooksToRun) internal {\n uint256 length = postExecHooksToRun.length;\n for (uint256 i = 0; i < length; ++i) {\n FunctionReference memory postExecHook = postExecHooksToRun[i].postExecHook;\n // solhint-disable no-empty-blocks\n try IPlugin(postExecHook.plugin).postExecutionHook(\n postExecHook.functionId, postExecHooksToRun[i].preExecHookReturnData\n ) {} catch (bytes memory revertReason) {\n revert PostExecHookFailed(postExecHook.plugin, postExecHook.functionId, revertReason);\n }\n // solhint-enable no-empty-blocks\n }\n }\n\n function _getExecutionHooks(HookGroup storage hookGroup) internal view returns (ExecutionHooks[] memory hooks) {\n uint256 preHooksCount = hookGroup.preHooks.getUniqueItems();\n uint256 postOnlyHooksCount = hookGroup.postOnlyHooks.getUniqueItems();\n // hooks have three categories a. preOnlyHook b. preToPostHook c. postOnlyHook\n // 1. add repeated preHook into postHook 2. add postOnlyHooks\n uint256 maxExecHooksCount = postOnlyHooksCount + hookGroup.preHooks.getTotalItems();\n uint256 totalExecHooksCount = 0;\n hooks = new ExecutionHooks[](maxExecHooksCount);\n // copy postOnlyHooks into result first\n FunctionReference memory startHook = EMPTY_FUNCTION_REFERENCE.unpack();\n for (uint256 i = 0; i < postOnlyHooksCount; ++i) {\n (FunctionReference[] memory resultPostOnlyHooks, FunctionReference memory nextHook) =\n hookGroup.postOnlyHooks.getPaginated(startHook, 10);\n for (uint256 j = 0; j < resultPostOnlyHooks.length; ++j) {\n hooks[totalExecHooksCount++].postExecHook = resultPostOnlyHooks[j];\n }\n if (nextHook.pack() == SENTINEL_BYTES21) {\n break;\n }\n startHook = nextHook;\n }\n // then copy preOnlyHooks or preToPostHooks\n startHook = EMPTY_FUNCTION_REFERENCE.unpack();\n for (uint256 i = 0; i < preHooksCount; ++i) {\n (FunctionReference[] memory resultPreExecHooks, FunctionReference memory nextHook) =\n hookGroup.preHooks.getPaginated(startHook, 10);\n for (uint256 j = 0; j < resultPreExecHooks.length; ++j) {\n // if any revert, the outer call MUST revert\n bytes21 packedPreExecHook = resultPreExecHooks[j].pack();\n // getAll can handle 1000+ hooks\n FunctionReference[] memory preToPostHooks = hookGroup.preToPostHooks[packedPreExecHook].getAll();\n if (preToPostHooks.length > 0) {\n for (uint256 k = 0; k < preToPostHooks.length; ++k) {\n hooks[totalExecHooksCount].preExecHook = resultPreExecHooks[j];\n hooks[totalExecHooksCount].postExecHook = preToPostHooks[k];\n totalExecHooksCount++;\n }\n } else {\n // no associated postHook\n hooks[totalExecHooksCount++].preExecHook = resultPreExecHooks[j];\n }\n }\n if (nextHook.pack() == SENTINEL_BYTES21) {\n break;\n }\n startHook = nextHook;\n }\n // solhint-disable-next-line no-inline-assembly\n assembly (\"memory-safe\") {\n mstore(hooks, totalExecHooksCount)\n }\n return hooks;\n }\n\n /// @dev The caller would expect both input.totalPostExecHooksToRunCount and input.postExecHooksToRun to be assigned\n /// back to original values.\n function _setPostExecHooksFromPreHooks(\n HookGroup storage hookGroup,\n bytes calldata data,\n SetPostExecHooksFromPreHooksParam memory input\n ) internal returns (uint256, PostExecHookToRun[] memory) {\n FunctionReference memory startHook = EMPTY_FUNCTION_REFERENCE.unpack();\n uint256 preHooksCount = hookGroup.preHooks.getUniqueItems();\n for (uint256 i = 0; i < preHooksCount; ++i) {\n (FunctionReference[] memory resultPreExecHooks, FunctionReference memory nextHook) =\n hookGroup.preHooks.getPaginated(startHook, 10);\n for (uint256 j = 0; j < resultPreExecHooks.length; ++j) {\n // if any revert, the outer call MUST revert\n bytes21 packedPreExecHook = resultPreExecHooks[j].pack();\n if (\n packedPreExecHook == EMPTY_FUNCTION_REFERENCE\n || packedPreExecHook == RUNTIME_VALIDATION_ALWAYS_ALLOW_FUNCTION_REFERENCE\n || packedPreExecHook == PRE_HOOK_ALWAYS_DENY_FUNCTION_REFERENCE\n ) {\n revert InvalidValidationFunctionId(resultPreExecHooks[j].functionId);\n }\n // getAll can handle 1000+ hooks\n // run duplicated (if any) preHooks only once\n bytes memory preExecHookReturnData = _processPreExecHook(resultPreExecHooks[j], data);\n FunctionReference[] memory preToPostHooks = hookGroup.preToPostHooks[packedPreExecHook].getAll();\n if (preToPostHooks.length > 0) {\n for (uint256 k = 0; k < preToPostHooks.length; ++k) {\n input.postExecHooksToRun[input.totalPostExecHooksToRunCount].postExecHook = preToPostHooks[k];\n input.postExecHooksToRun[input.totalPostExecHooksToRunCount].preExecHookReturnData =\n preExecHookReturnData;\n input.totalPostExecHooksToRunCount++;\n }\n }\n }\n if (nextHook.pack() == SENTINEL_BYTES21) {\n break;\n }\n startHook = nextHook;\n }\n return (input.totalPostExecHooksToRunCount, input.postExecHooksToRun);\n }\n}\n"},"src/msca/6900/v0.7/managers/PluginExecutor.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\nimport {ExecutionUtils} from \"../../../../utils/ExecutionUtils.sol\";\nimport {InvalidExecutionFunction, NotFoundSelector} from \"../../shared/common/Errors.sol\";\nimport {ExecutionDetail, HookGroup, PermittedExternalCall, PostExecHookToRun} from \"../common/Structs.sol\";\nimport {IPlugin} from \"../interfaces/IPlugin.sol\";\nimport {IPluginExecutor} from \"../interfaces/IPluginExecutor.sol\";\nimport {ExecutionHookLib} from \"../libs/ExecutionHookLib.sol\";\nimport {WalletStorageV1Lib} from \"../libs/WalletStorageV1Lib.sol\";\nimport {ERC165Checker} from \"@openzeppelin/contracts/utils/introspection/ERC165Checker.sol\";\n\n/**\n * @dev Default implementation of https://eips.ethereum.org/EIPS/eip-6900. MSCAs must implement this interface to\n * support execution from plugins.\n * https://eips.ethereum.org/assets/eip-6900/Plugin_Execution_Flow.svg\n */\nlibrary PluginExecutor {\n using ExecutionHookLib for HookGroup;\n using ExecutionHookLib for PostExecHookToRun[];\n using ExecutionUtils for address;\n\n error ExecuteFromPluginToExternalNotPermitted();\n error ExecFromPluginToSelectorNotPermitted(address plugin, bytes4 selector);\n error NativeTokenSpendingNotPermitted(address plugin);\n\n /// @dev Refer to IPluginExecutor\n function executeFromPlugin(bytes calldata data) internal returns (bytes memory) {\n if (data.length < 4) {\n revert NotFoundSelector();\n }\n bytes4 selector = bytes4(data[0:4]);\n if (selector == bytes4(0)) {\n revert NotFoundSelector();\n }\n address callingPlugin = msg.sender;\n WalletStorageV1Lib.Layout storage walletStorage = WalletStorageV1Lib.getLayout();\n // permission check\n if (!walletStorage.permittedPluginCalls[callingPlugin][selector]) {\n revert ExecFromPluginToSelectorNotPermitted(callingPlugin, selector);\n }\n // this function call emulates a call to the fallback that routes calls into another plugin;\n // we use inner data here instead of the entire msg.data that includes the complete calldata of\n // executeFromPlugin\n ExecutionDetail storage executionDetail = walletStorage.executionDetails[selector];\n if (executionDetail.plugin == address(0)) {\n revert InvalidExecutionFunction(selector);\n }\n // pre execution hooks\n PostExecHookToRun[] memory postExecHooks = executionDetail.executionHooks._processPreExecHooks(data);\n // permitted to call the other plugin\n bytes memory returnData = executionDetail.plugin.callWithReturnDataOrRevert(0, data);\n // post execution hooks\n postExecHooks._processPostExecHooks();\n return returnData;\n }\n\n /// @dev Refer to IPluginExecutor\n function executeFromPluginToExternal(bytes calldata data, address target, uint256 value)\n internal\n returns (bytes memory)\n {\n if (target == address(this) || ERC165Checker.supportsInterface(target, type(IPlugin).interfaceId)) {\n revert ExecuteFromPluginToExternalNotPermitted();\n }\n WalletStorageV1Lib.Layout storage walletStorage = WalletStorageV1Lib.getLayout();\n address callingPlugin = msg.sender;\n // revert if the plugin can't cover the value and is not permitted to spend MSCA's native token\n if (value > 0 && value > msg.value && !walletStorage.pluginDetails[callingPlugin].canSpendNativeToken) {\n revert NativeTokenSpendingNotPermitted(callingPlugin);\n }\n PermittedExternalCall storage permittedExternalCall =\n walletStorage.permittedExternalCalls[callingPlugin][target];\n // permission check\n // addressPermitted can only be true if anyExternalAddressPermitted is false\n bool targetContractCallPermitted;\n // external call might not have function selector\n bytes4 selector = bytes4(data);\n if (permittedExternalCall.addressPermitted) {\n targetContractCallPermitted =\n permittedExternalCall.anySelector || permittedExternalCall.selectors[selector] || data.length == 0;\n } else {\n // also need to check the default permission in plugin detail\n targetContractCallPermitted = walletStorage.pluginDetails[callingPlugin].anyExternalAddressPermitted;\n }\n if (!targetContractCallPermitted) {\n revert ExecFromPluginToSelectorNotPermitted(callingPlugin, selector);\n }\n // we use msg.data here so the complete calldata of current function call executeFromPluginToExternalContract\n // can be passed\n // pre executeFromPluginToExternalContract hooks\n // process any pre exec hooks for IPluginExecutor.executeFromPluginExternal.selector during runtime\n PostExecHookToRun[] memory postExecHooks = walletStorage.executionDetails[IPluginExecutor\n .executeFromPluginExternal\n .selector].executionHooks._processPreExecHooks(msg.data);\n // call externally\n bytes memory returnData = target.callWithReturnDataOrRevert(value, data);\n // post executeFromPluginToExternalContract hooks\n postExecHooks._processPostExecHooks();\n return returnData;\n }\n}\n"},"src/msca/6900/v0.7/managers/StandardExecutor.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\nimport {ExecutionUtils} from \"../../../../utils/ExecutionUtils.sol\";\nimport {Call} from \"../common/Structs.sol\";\nimport {IPlugin} from \"../interfaces/IPlugin.sol\";\nimport {ERC165Checker} from \"@openzeppelin/contracts/utils/introspection/ERC165Checker.sol\";\n\n/**\n * @dev Default implementation of https://eips.ethereum.org/EIPS/eip-6900. MSCAs must implement this interface to\n * support open-ended execution.\n */\nlibrary StandardExecutor {\n using ExecutionUtils for address;\n\n error TargetIsPlugin(address plugin);\n\n /// @dev Refer to IStandardExecutor\n function execute(address target, uint256 value, bytes calldata data) internal returns (bytes memory returnData) {\n // reverts if the target is a plugin because modular account should be calling plugin via execution functions\n // defined in IPluginExecutor\n if (ERC165Checker.supportsInterface(target, type(IPlugin).interfaceId)) {\n revert TargetIsPlugin(target);\n }\n return target.callWithReturnDataOrRevert(value, data);\n }\n\n /// @dev Refer to IStandardExecutor\n function executeBatch(Call[] calldata calls) internal returns (bytes[] memory returnData) {\n returnData = new bytes[](calls.length);\n for (uint256 i = 0; i < calls.length; ++i) {\n if (ERC165Checker.supportsInterface(calls[i].target, type(IPlugin).interfaceId)) {\n revert TargetIsPlugin(calls[i].target);\n }\n returnData[i] = calls[i].target.callWithReturnDataOrRevert(calls[i].value, calls[i].data);\n }\n return returnData;\n }\n}\n"},"src/msca/6900/v0.7/account/WalletStorageInitializable.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\nimport {WalletStorageV1Lib} from \"../libs/WalletStorageV1Lib.sol\";\n\n/// @notice Forked from OpenZeppelin (proxy/utils/Initializable.sol) with wallet storage access.\n/// Reinitialization is removed.\n/// For V1 MSCA.\nabstract contract WalletStorageInitializable {\n /**\n * @dev Triggered when the contract has been initialized.\n */\n event WalletStorageInitialized();\n\n error WalletStorageIsInitializing();\n error WalletStorageIsNotInitializing();\n error WalletStorageIsInitialized();\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyWalletStorageInitializing` functions can be used to initialize parent contracts.\n *\n * Functions marked with `walletStorageInitializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {WalletStorageInitialized} event.\n */\n modifier walletStorageInitializer() {\n bool isTopLevelCall = !WalletStorageV1Lib.getLayout().initializing;\n uint8 initialized = WalletStorageV1Lib.getLayout().initialized;\n\n // Allowed calls:\n // - initialSetup: the contract is not in the initializing state and no previous version was\n // initialized\n // - deploying: 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 deploying = initialized == 1 && address(this).code.length == 0;\n if (!initialSetup && !deploying) {\n revert WalletStorageIsInitialized();\n }\n WalletStorageV1Lib.getLayout().initialized = 1;\n if (isTopLevelCall) {\n WalletStorageV1Lib.getLayout().initializing = true;\n }\n _;\n if (isTopLevelCall) {\n WalletStorageV1Lib.getLayout().initializing = false;\n emit WalletStorageInitialized();\n }\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {walletStorageInitializer} modifier, directly or indirectly.\n */\n modifier onlyWalletStorageInitializing() {\n if (!WalletStorageV1Lib.getLayout().initializing) {\n revert WalletStorageIsNotInitializing();\n }\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 {WalletStorageInitialized} event the first time it is successfully executed.\n */\n function _disableWalletStorageInitializers() internal virtual {\n if (WalletStorageV1Lib.getLayout().initializing) {\n revert WalletStorageIsInitializing();\n }\n if (WalletStorageV1Lib.getLayout().initialized != type(uint8).max) {\n WalletStorageV1Lib.getLayout().initialized = type(uint8).max;\n emit WalletStorageInitialized();\n }\n }\n}\n"},"lib/account-abstraction/contracts/core/Helpers.sol":{"content":"// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.12;\n\n/* solhint-disable no-inline-assembly */\n\n/**\n * returned data from validateUserOp.\n * validateUserOp returns a uint256, with is created by `_packedValidationData` and 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 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 */\n struct ValidationData {\n address aggregator;\n uint48 validAfter;\n uint48 validUntil;\n }\n\n//extract sigFailed, validAfter, validUntil.\n// also convert zero validUntil to type(uint48).max\n function _parseValidationData(uint validationData) 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// intersect account and paymaster ranges.\n function _intersectTimeRange(uint256 validationData, uint256 paymasterValidationData) pure returns (ValidationData memory) {\n ValidationData memory accountValidationData = _parseValidationData(validationData);\n ValidationData memory pmValidationData = _parseValidationData(paymasterValidationData);\n address aggregator = accountValidationData.aggregator;\n if (aggregator == address(0)) {\n aggregator = pmValidationData.aggregator;\n }\n uint48 validAfter = accountValidationData.validAfter;\n uint48 validUntil = accountValidationData.validUntil;\n uint48 pmValidAfter = pmValidationData.validAfter;\n uint48 pmValidUntil = pmValidationData.validUntil;\n\n if (validAfter < pmValidAfter) validAfter = pmValidAfter;\n if (validUntil > pmValidUntil) validUntil = pmValidUntil;\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 */\n function _packValidationData(ValidationData memory data) pure returns (uint256) {\n return uint160(data.aggregator) | (uint256(data.validUntil) << 160) | (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 */\n function _packValidationData(bool sigFailed, uint48 validUntil, uint48 validAfter) pure returns (uint256) {\n return (sigFailed ? 1 : 0) | (uint256(validUntil) << 160) | (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 {\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"},"node_modules/@openzeppelin/contracts-upgradeable/interfaces/draft-IERC1822Upgradeable.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\n\npragma solidity ^0.8.0;\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 IERC1822ProxiableUpgradeable {\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"},"node_modules/@openzeppelin/contracts-upgradeable/proxy/ERC1967/ERC1967UpgradeUpgradeable.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/ERC1967/ERC1967Upgrade.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../beacon/IBeaconUpgradeable.sol\";\nimport \"../../interfaces/IERC1967Upgradeable.sol\";\nimport \"../../interfaces/draft-IERC1822Upgradeable.sol\";\nimport \"../../utils/AddressUpgradeable.sol\";\nimport \"../../utils/StorageSlotUpgradeable.sol\";\nimport {Initializable} from \"../utils/Initializable.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 *\n * _Available since v4.1._\n */\nabstract contract ERC1967UpgradeUpgradeable is Initializable, IERC1967Upgradeable {\n // This is the keccak-256 hash of \"eip1967.proxy.rollback\" subtracted by 1\n bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\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, and is\n * validated in the constructor.\n */\n bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n\n function __ERC1967Upgrade_init() internal onlyInitializing {\n }\n\n function __ERC1967Upgrade_init_unchained() internal onlyInitializing {\n }\n /**\n * @dev Returns the current implementation address.\n */\n function _getImplementation() internal view returns (address) {\n return StorageSlotUpgradeable.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 require(AddressUpgradeable.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n }\n\n /**\n * @dev Perform implementation upgrade\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeTo(address newImplementation) internal {\n _setImplementation(newImplementation);\n emit Upgraded(newImplementation);\n }\n\n /**\n * @dev Perform implementation upgrade with additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCall(address newImplementation, bytes memory data, bool forceCall) internal {\n _upgradeTo(newImplementation);\n if (data.length > 0 || forceCall) {\n AddressUpgradeable.functionDelegateCall(newImplementation, data);\n }\n }\n\n /**\n * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\n *\n * Emits an {Upgraded} event.\n */\n function _upgradeToAndCallUUPS(address newImplementation, bytes memory data, bool forceCall) internal {\n // Upgrades from old implementations will perform a rollback test. This test requires the new\n // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\n // this special case will break upgrade paths from old UUPS implementation to new ones.\n if (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) {\n _setImplementation(newImplementation);\n } else {\n try IERC1822ProxiableUpgradeable(newImplementation).proxiableUUID() returns (bytes32 slot) {\n require(slot == _IMPLEMENTATION_SLOT, \"ERC1967Upgrade: unsupported proxiableUUID\");\n } catch {\n revert(\"ERC1967Upgrade: new implementation is not UUPS\");\n }\n _upgradeToAndCall(newImplementation, data, forceCall);\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, and is\n * validated in the constructor.\n */\n bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n /**\n * @dev Returns the current admin.\n */\n function _getAdmin() internal view returns (address) {\n return StorageSlotUpgradeable.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 require(newAdmin != address(0), \"ERC1967: new admin is the zero address\");\n StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\n }\n\n /**\n * @dev Changes the admin of the proxy.\n *\n * Emits an {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 bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\n */\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 StorageSlotUpgradeable.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 require(AddressUpgradeable.isContract(newBeacon), \"ERC1967: new beacon is not a contract\");\n require(\n AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()),\n \"ERC1967: beacon implementation is not a contract\"\n );\n StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon;\n }\n\n /**\n * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\n * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\n *\n * Emits a {BeaconUpgraded} event.\n */\n function _upgradeBeaconToAndCall(address newBeacon, bytes memory data, bool forceCall) internal {\n _setBeacon(newBeacon);\n emit BeaconUpgraded(newBeacon);\n if (data.length > 0 || forceCall) {\n AddressUpgradeable.functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data);\n }\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n"},"node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/AddressUpgradeable.sol\";\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 Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 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 functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\n \"Initializable: contract is already initialized\"\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 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\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 require(_initializing, \"Initializable: contract is not initializing\");\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 require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized != type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _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 _initializing;\n }\n}\n"},"node_modules/@openzeppelin/contracts/utils/Strings.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./math/Math.sol\";\nimport \"./math/SignedMath.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n bytes16 private constant _SYMBOLS = \"0123456789abcdef\";\n uint8 private constant _ADDRESS_LENGTH = 20;\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), _SYMBOLS))\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 toString(int256 value) internal pure returns (string memory) {\n return string(abi.encodePacked(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 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] = _SYMBOLS[value & 0xf];\n value >>= 4;\n }\n require(value == 0, \"Strings: hex length insufficient\");\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 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 keccak256(bytes(a)) == keccak256(bytes(b));\n }\n}\n"},"src/libs/MessageHashUtils.sol":{"content":"/*\n * Copyright 2024 Circle Internet Group, Inc. All rights reserved.\n\n * SPDX-License-Identifier: GPL-3.0-or-later\n\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\npragma solidity 0.8.24;\n\n/**\n * @notice Forked from OZ V5 as it doesn't exist in V4.\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-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 // solhint-disable-next-line no-inline-assembly\n assembly {\n let ptr := mload(0x40)\n mstore(ptr, hex\"1901\")\n mstore(add(ptr, 0x02), domainSeparator)\n mstore(add(ptr, 0x22), structHash)\n digest := keccak256(ptr, 0x42)\n }\n }\n}\n"},"lib/account-abstraction/contracts/interfaces/IAccount.sol":{"content":"// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.12;\n\nimport \"./UserOperation.sol\";\n\ninterface IAccount {\n\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 able to make the call.\n * The excess is left as a deposit in the entrypoint, for future calls.\n * can be withdrawn anytime using \"entryPoint.withdrawTo()\"\n * In case there is a paymaster in the request (or the current deposit is high enough), this value will be zero.\n * @return validationData packaged ValidationData structure. use `_packValidationData` and `_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 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(UserOperation calldata userOp, bytes32 userOpHash, uint256 missingAccountFunds)\n external returns (uint256 validationData);\n}\n"},"lib/account-abstraction/contracts/interfaces/IPaymaster.sol":{"content":"// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.12;\n\nimport \"./UserOperation.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\n enum PostOpMode {\n opSucceeded, // user op succeeded\n opReverted, // user op reverted. still has to pay for gas.\n postOpReverted //user op succeeded, but caused postOp to revert. Now it's a 2nd call, after user's op was deliberately reverted.\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\n * zero length to signify postOp is not required.\n * @return validationData signature and time-range of this operation, encoded the same as the return value of validateUserOperation\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 * Note that the validation code cannot use block.timestamp (or block.number) directly.\n */\n function validatePaymasterUserOp(UserOperation calldata userOp, bytes32 userOpHash, 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. still has to pay for gas.\n * postOpReverted - user op succeeded, but caused postOp (in mode=opSucceeded) to revert.\n * Now this is the 2nd call, after user's op was deliberately reverted.\n * @param context - the context value returned by validatePaymasterUserOp\n * @param actualGasCost - actual gas used so far (without this postOp call).\n */\n function postOp(PostOpMode mode, bytes calldata context, uint256 actualGasCost) external;\n}\n"},"node_modules/@openzeppelin/contracts/proxy/beacon/IBeacon.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\n\npragma solidity ^0.8.0;\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 * {BeaconProxy} will check that this address is a contract.\n */\n function implementation() external view returns (address);\n}\n"},"node_modules/@openzeppelin/contracts/interfaces/IERC1967.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC1967.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.\n *\n * _Available since v4.8.3._\n */\ninterface IERC1967 {\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"},"node_modules/@openzeppelin/contracts/interfaces/draft-IERC1822.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\n\npragma solidity ^0.8.0;\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"},"node_modules/@openzeppelin/contracts/utils/Address.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n *\n * Furthermore, `isContract` will also return true if the target contract within\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n * which only has an effect at the end of a transaction.\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\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.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\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, it is bubbled up by this\n * function (like regular Solidity function calls).\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 * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\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 * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) 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(errorMessage);\n }\n }\n}\n"},"node_modules/@openzeppelin/contracts/utils/StorageSlot.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/StorageSlot.sol)\n// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.\n\npragma solidity ^0.8.0;\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(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, `uint256`._\n * _Available since v4.9 for `string`, `bytes`._\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"},"node_modules/@openzeppelin/contracts/token/ERC777/IERC777Recipient.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC777/IERC777Recipient.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC777TokensRecipient standard as defined in the EIP.\n *\n * Accounts can be notified of {IERC777} tokens being sent to them by having a\n * contract implement this interface (contract holders can be their own\n * implementer) and registering it on the\n * https://eips.ethereum.org/EIPS/eip-1820[ERC1820 global registry].\n *\n * See {IERC1820Registry} and {ERC1820Implementer}.\n */\ninterface IERC777Recipient {\n /**\n * @dev Called by an {IERC777} token contract whenever tokens are being\n * moved or created into a registered account (`to`). The type of operation\n * is conveyed by `from` being the zero address or not.\n *\n * This call occurs _after_ the token contract's state is updated, so\n * {IERC777-balanceOf}, etc., can be used to query the post-operation state.\n *\n * This function may revert to prevent the operation from being executed.\n */\n function tokensReceived(\n address operator,\n address from,\n address to,\n uint256 amount,\n bytes calldata userData,\n bytes calldata operatorData\n ) external;\n}\n"},"node_modules/@openzeppelin/contracts-upgradeable/proxy/beacon/IBeaconUpgradeable.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\n */\ninterface IBeaconUpgradeable {\n /**\n * @dev Must return an address that can be used as a delegate call target.\n *\n * {BeaconProxy} will check that this address is a contract.\n */\n function implementation() external view returns (address);\n}\n"},"node_modules/@openzeppelin/contracts-upgradeable/interfaces/IERC1967Upgradeable.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC1967.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.\n *\n * _Available since v4.8.3._\n */\ninterface IERC1967Upgradeable {\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"},"node_modules/@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n *\n * Furthermore, `isContract` will also return true if the target contract within\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n * which only has an effect at the end of a transaction.\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\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.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\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, it is bubbled up by this\n * function (like regular Solidity function calls).\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 * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\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 * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) 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(errorMessage);\n }\n }\n}\n"},"node_modules/@openzeppelin/contracts-upgradeable/utils/StorageSlotUpgradeable.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/StorageSlot.sol)\n// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.\n\npragma solidity ^0.8.0;\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(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n * }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, `uint256`._\n * _Available since v4.9 for `string`, `bytes`._\n */\nlibrary StorageSlotUpgradeable {\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"},"node_modules/@openzeppelin/contracts/utils/math/Math.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n enum Rounding {\n Down, // Toward negative infinity\n Up, // Toward infinity\n Zero // Toward zero\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 up instead\n * of rounding down.\n */\n function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\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 denominator == 0\n * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n * with further edits by 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; // 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 prod0 := mul(x, y)\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 require(denominator > prod1, \"Math: mulDiv overflow\");\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. Always >= 1.\n // See https://cs.stackexchange.com/q/138556/92363.\n\n // Does not overflow because the denominator cannot be zero at this stage in the function.\n uint256 twos = denominator & (~denominator + 1);\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 works\n // 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 (rounding == Rounding.Up && 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 down.\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 + (rounding == Rounding.Up && result * result < a ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 2, rounded down, of a positive value.\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 + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 10, rounded down, of a positive value.\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 + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);\n }\n }\n\n /**\n * @dev Return the log in base 256, rounded down, of a positive value.\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 + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);\n }\n }\n}\n"},"node_modules/@openzeppelin/contracts/utils/math/SignedMath.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)\n\npragma solidity ^0.8.0;\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"}},"settings":{"remappings":["@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/","@openzeppelin/contracts-upgradeable/=node_modules/@openzeppelin/contracts-upgradeable/","@account-abstraction/=lib/account-abstraction/","@modular-account-libs/=node_modules/@modular-account-libs/src/","@solady/=node_modules/solady/src/","@fcl/=node_modules/fcl/solidity/src/","forge-std/=node_modules/forge-std/"],"optimizer":{"enabled":true,"runs":200},"metadata":{"useLiteralContent":false,"bytecodeHash":"ipfs","appendCBOR":true},"outputSelection":{"*":{"*":["abi","evm.bytecode.object","evm.bytecode.sourceMap","evm.bytecode.linkReferences","evm.deployedBytecode.object","evm.deployedBytecode.sourceMap","evm.deployedBytecode.linkReferences","evm.deployedBytecode.immutableReferences","evm.methodIdentifiers","metadata"]}},"evmVersion":"paris","viaIR":true,"libraries":{}}} diff --git a/script/verify/SingleOwnerMSCAFactory/0xf61023061ed45fa9eAC4D2670649cE1FD37ce536/abiEncodedConstructorArgs b/script/verify/SingleOwnerMSCAFactory/0xf61023061ed45fa9eAC4D2670649cE1FD37ce536/abiEncodedConstructorArgs new file mode 100644 index 0000000..04ff399 --- /dev/null +++ b/script/verify/SingleOwnerMSCAFactory/0xf61023061ed45fa9eAC4D2670649cE1FD37ce536/abiEncodedConstructorArgs @@ -0,0 +1 @@ +0000000000000000000000005ff137d4b0fdcd49dca30c7cf57e578a026d2789000000000000000000000000c93d6559fe4db59742751a857d11a04861a50ccc From 0b48e5ce852bb3b4b7a6d6e0fc43726949a51e92 Mon Sep 17 00:00:00 2001 From: Daniel Lim Date: Wed, 22 Jan 2025 15:42:45 -0800 Subject: [PATCH 2/2] Update contract address Signed-off-by: Daniel Lim --- script/000_ContractAddress.sol | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/script/000_ContractAddress.sol b/script/000_ContractAddress.sol index 0a26536..d3c0b28 100644 --- a/script/000_ContractAddress.sol +++ b/script/000_ContractAddress.sol @@ -21,11 +21,11 @@ pragma solidity 0.8.24; address constant ENTRY_POINT = 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789; // Use address(0) if unknown or deploying a new version of a contract. -address constant PLUGIN_MANAGER_ADDRESS = 0x3169Ad878021B87C9CaA9b5CDA740ff3ca270Ce9; -address constant SINGLE_OWNER_MSCA_FACTORY_ADDRESS = 0xa233b124D7b9CFF2D38cB62319e1A3f79144B490; +address constant PLUGIN_MANAGER_ADDRESS = 0xc93D6559Fe4dB59742751A857d11a04861a50CCC; +address constant SINGLE_OWNER_MSCA_FACTORY_ADDRESS = 0xf61023061ed45fa9eAC4D2670649cE1FD37ce536; address constant UPGRADABLE_MSCA_FACTORY_ADDRESS = 0x3e6b66A72B76850c372FBDf29f53268ad636B320; address constant SINGLE_OWNER_PLUGIN_ADDRESS = 0x7af5E9DBe3e50F023a5b99f44002697cF8e1de2e; -address constant COLD_STORAGE_ADDRESS_BOOK_PLUGIN_ADDRESS = 0x3c95978Af08B6B2Fd82659B393be86AfB4bd3D6F; +address constant COLD_STORAGE_ADDRESS_BOOK_PLUGIN_ADDRESS = 0x11BACb0F0C9D04A28A2043b54c0C3C2CE15F0Af4; address constant WEIGHTED_MULTISIG_PLUGIN_ADDRESS = 0x558498E7CD325b17be8c8A79884A1cAcfD72a4AA; address constant DEFAULT_TOKEN_CALLBACK_PLUGIN_ADDRESS = 0x03431Fb00fB2e26b5bC502DFeF8dA30E1C8643b8;