From 1cff070ddf6c451b2006612a347dc45f1f6f987e Mon Sep 17 00:00:00 2001 From: zer0dot Date: Thu, 9 May 2024 23:55:20 +0800 Subject: [PATCH 1/6] feat: Install modular-account-libs --- package.json | 3 + pnpm-lock.yaml | 577 ++++++++++++++++++++++++++++--------------------- remappings.txt | 1 + 3 files changed, 331 insertions(+), 250 deletions(-) diff --git a/package.json b/package.json index c05f78ad..2c7a82b9 100644 --- a/package.json +++ b/package.json @@ -9,5 +9,8 @@ "lint": "pnpm lint:src && pnpm lint:test", "lint:src": "solhint -c .solhint-src.json ./src/**/*.sol", "lint:test": "solhint -c .solhint-test.json ./test/**/*.sol" + }, + "dependencies": { + "modular-account-libs": "github:erc6900/modular-account-libs#v0.7.0" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 393efc6e..333f7aa8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,165 +1,112 @@ -lockfileVersion: '6.0' +lockfileVersion: '9.0' settings: autoInstallPeers: true excludeLinksFromLockfile: false -devDependencies: - pnpm: - specifier: ^8.7.5 - version: 8.7.5 - solhint: - specifier: ^3.6.2 - version: 3.6.2 +importers: + + .: + dependencies: + modular-account-libs: + specifier: github:erc6900/modular-account-libs#v0.7.0 + version: https://codeload.github.com/erc6900/modular-account-libs/tar.gz/52ab7c2b2f1abf327a8612945788f1b0c899ade6 + devDependencies: + pnpm: + specifier: ^8.7.5 + version: 8.7.5 + solhint: + specifier: ^3.6.2 + version: 3.6.2 packages: - /@babel/code-frame@7.22.13: + '@babel/code-frame@7.22.13': resolution: {integrity: sha512-XktuhWlJ5g+3TJXc5upd9Ks1HutSArik6jf2eAjYFyIOf4ej3RN+184cZbzDvbPnuTJIUhPKKJE3cIsYTiAT3w==} engines: {node: '>=6.9.0'} - dependencies: - '@babel/highlight': 7.22.13 - chalk: 2.4.2 - dev: true - /@babel/helper-validator-identifier@7.22.15: + '@babel/helper-validator-identifier@7.22.15': resolution: {integrity: sha512-4E/F9IIEi8WR94324mbDUMo074YTheJmd7eZF5vITTeYchqAi6sYXRLHUVsmkdmY4QjfKTcB2jB7dVP3NaBElQ==} engines: {node: '>=6.9.0'} - dev: true - /@babel/highlight@7.22.13: + '@babel/highlight@7.22.13': resolution: {integrity: sha512-C/BaXcnnvBCmHTpz/VGZ8jgtE2aYlW4hxDhseJAWZb7gqGM/qtCK6iZUb0TyKFf7BOUsBH7Q7fkRsDRhg1XklQ==} engines: {node: '>=6.9.0'} - dependencies: - '@babel/helper-validator-identifier': 7.22.15 - chalk: 2.4.2 - js-tokens: 4.0.0 - dev: true - /@solidity-parser/parser@0.16.1: + '@solidity-parser/parser@0.16.1': resolution: {integrity: sha512-PdhRFNhbTtu3x8Axm0uYpqOy/lODYQK+MlYSgqIsq2L8SFYEHJPHNUiOTAJbDGzNjjr1/n9AcIayxafR/fWmYw==} - dependencies: - antlr4ts: 0.5.0-alpha.4 - dev: true - /ajv@6.12.6: + ajv@6.12.6: resolution: {integrity: sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==} - dependencies: - fast-deep-equal: 3.1.3 - fast-json-stable-stringify: 2.1.0 - json-schema-traverse: 0.4.1 - uri-js: 4.4.1 - dev: true - /ajv@8.12.0: + ajv@8.12.0: resolution: {integrity: sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==} - dependencies: - fast-deep-equal: 3.1.3 - json-schema-traverse: 1.0.0 - require-from-string: 2.0.2 - uri-js: 4.4.1 - dev: true - /ansi-regex@5.0.1: + ansi-regex@5.0.1: resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==} engines: {node: '>=8'} - dev: true - /ansi-styles@3.2.1: + ansi-styles@3.2.1: resolution: {integrity: sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==} engines: {node: '>=4'} - dependencies: - color-convert: 1.9.3 - dev: true - /ansi-styles@4.3.0: + ansi-styles@4.3.0: resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==} engines: {node: '>=8'} - dependencies: - color-convert: 2.0.1 - dev: true - /antlr4@4.13.1: + antlr4@4.13.1: resolution: {integrity: sha512-kiXTspaRYvnIArgE97z5YVVf/cDVQABr3abFRR6mE7yesLMkgu4ujuyV/sgxafQ8wgve0DJQUJ38Z8tkgA2izA==} engines: {node: '>=16'} - dev: true - /antlr4ts@0.5.0-alpha.4: + antlr4ts@0.5.0-alpha.4: resolution: {integrity: sha512-WPQDt1B74OfPv/IMS2ekXAKkTZIHl88uMetg6q3OTqgFxZ/dxDXI0EWLyZid/1Pe6hTftyg5N7gel5wNAGxXyQ==} - dev: true - /argparse@2.0.1: + argparse@2.0.1: resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==} - dev: true - /ast-parents@0.0.1: + ast-parents@0.0.1: resolution: {integrity: sha512-XHusKxKz3zoYk1ic8Un640joHbFMhbqneyoZfoKnEGtf2ey9Uh/IdpcQplODdO/kENaMIWsD0nJm4+wX3UNLHA==} - dev: true - /astral-regex@2.0.0: + astral-regex@2.0.0: resolution: {integrity: sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==} engines: {node: '>=8'} - dev: true - /balanced-match@1.0.2: + balanced-match@1.0.2: resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} - dev: true - /brace-expansion@2.0.1: + brace-expansion@2.0.1: resolution: {integrity: sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==} - dependencies: - balanced-match: 1.0.2 - dev: true - /callsites@3.1.0: + callsites@3.1.0: resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==} engines: {node: '>=6'} - dev: true - /chalk@2.4.2: + chalk@2.4.2: resolution: {integrity: sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==} engines: {node: '>=4'} - dependencies: - ansi-styles: 3.2.1 - escape-string-regexp: 1.0.5 - supports-color: 5.5.0 - dev: true - /chalk@4.1.2: + chalk@4.1.2: resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==} engines: {node: '>=10'} - dependencies: - ansi-styles: 4.3.0 - supports-color: 7.2.0 - dev: true - /color-convert@1.9.3: + color-convert@1.9.3: resolution: {integrity: sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==} - dependencies: - color-name: 1.1.3 - dev: true - /color-convert@2.0.1: + color-convert@2.0.1: resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==} engines: {node: '>=7.0.0'} - dependencies: - color-name: 1.1.4 - dev: true - /color-name@1.1.3: + color-name@1.1.3: resolution: {integrity: sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==} - dev: true - /color-name@1.1.4: + color-name@1.1.4: resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} - dev: true - /commander@10.0.1: + commander@10.0.1: resolution: {integrity: sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==} engines: {node: '>=14'} - dev: true - /cosmiconfig@8.3.6: + cosmiconfig@8.3.6: resolution: {integrity: sha512-kcZ6+W5QzcJ3P1Mt+83OUv/oHFqZHIx8DuxG6eZ5RGMERoLqp4BuGjhHLYGK+Kf5XVkQvqBSmAy/nGWN3qDgEA==} engines: {node: '>=14'} peerDependencies: @@ -167,229 +114,385 @@ packages: peerDependenciesMeta: typescript: optional: true - dependencies: - import-fresh: 3.3.0 - js-yaml: 4.1.0 - parse-json: 5.2.0 - path-type: 4.0.0 - dev: true - /emoji-regex@8.0.0: + emoji-regex@8.0.0: resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} - dev: true - /error-ex@1.3.2: + error-ex@1.3.2: resolution: {integrity: sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==} - dependencies: - is-arrayish: 0.2.1 - dev: true - /escape-string-regexp@1.0.5: + escape-string-regexp@1.0.5: resolution: {integrity: sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==} engines: {node: '>=0.8.0'} - dev: true - /fast-deep-equal@3.1.3: + fast-deep-equal@3.1.3: resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} - dev: true - /fast-diff@1.3.0: + fast-diff@1.3.0: resolution: {integrity: sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==} - dev: true - /fast-json-stable-stringify@2.1.0: + fast-json-stable-stringify@2.1.0: resolution: {integrity: sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==} - dev: true - /fs.realpath@1.0.0: + fs.realpath@1.0.0: resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==} - dev: true - /glob@8.1.0: + glob@8.1.0: resolution: {integrity: sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==} engines: {node: '>=12'} - dependencies: - fs.realpath: 1.0.0 - inflight: 1.0.6 - inherits: 2.0.4 - minimatch: 5.1.6 - once: 1.4.0 - dev: true - /has-flag@3.0.0: + has-flag@3.0.0: resolution: {integrity: sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==} engines: {node: '>=4'} - dev: true - /has-flag@4.0.0: + has-flag@4.0.0: resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==} engines: {node: '>=8'} - dev: true - /ignore@5.2.4: + ignore@5.2.4: resolution: {integrity: sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==} engines: {node: '>= 4'} - dev: true - /import-fresh@3.3.0: + import-fresh@3.3.0: resolution: {integrity: sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==} engines: {node: '>=6'} - dependencies: - parent-module: 1.0.1 - resolve-from: 4.0.0 - dev: true - /inflight@1.0.6: + inflight@1.0.6: resolution: {integrity: sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==} - dependencies: - once: 1.4.0 - wrappy: 1.0.2 - dev: true - /inherits@2.0.4: + inherits@2.0.4: resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} - dev: true - /is-arrayish@0.2.1: + is-arrayish@0.2.1: resolution: {integrity: sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==} - dev: true - /is-fullwidth-code-point@3.0.0: + is-fullwidth-code-point@3.0.0: resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==} engines: {node: '>=8'} - dev: true - /js-tokens@4.0.0: + js-tokens@4.0.0: resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} - dev: true - /js-yaml@4.1.0: + js-yaml@4.1.0: resolution: {integrity: sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==} hasBin: true - dependencies: - argparse: 2.0.1 - dev: true - /json-parse-even-better-errors@2.3.1: + json-parse-even-better-errors@2.3.1: resolution: {integrity: sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==} - dev: true - /json-schema-traverse@0.4.1: + json-schema-traverse@0.4.1: resolution: {integrity: sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==} - dev: true - /json-schema-traverse@1.0.0: + json-schema-traverse@1.0.0: resolution: {integrity: sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==} - dev: true - /lines-and-columns@1.2.4: + lines-and-columns@1.2.4: resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==} - dev: true - /lodash.truncate@4.4.2: + lodash.truncate@4.4.2: resolution: {integrity: sha512-jttmRe7bRse52OsWIMDLaXxWqRAmtIUccAQ3garviCqJjafXOfNMO0yMfNpdD6zbGaTU0P5Nz7e7gAT6cKmJRw==} - dev: true - /lodash@4.17.21: + lodash@4.17.21: resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==} - dev: true - /lru-cache@6.0.0: + lru-cache@6.0.0: resolution: {integrity: sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==} engines: {node: '>=10'} - dependencies: - yallist: 4.0.0 - dev: true - /minimatch@5.1.6: + minimatch@5.1.6: resolution: {integrity: sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==} engines: {node: '>=10'} - dependencies: - brace-expansion: 2.0.1 - dev: true - /once@1.4.0: + modular-account-libs@https://codeload.github.com/erc6900/modular-account-libs/tar.gz/52ab7c2b2f1abf327a8612945788f1b0c899ade6: + resolution: {tarball: https://codeload.github.com/erc6900/modular-account-libs/tar.gz/52ab7c2b2f1abf327a8612945788f1b0c899ade6} + version: 0.7.0 + + once@1.4.0: resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==} - dependencies: - wrappy: 1.0.2 - dev: true - /parent-module@1.0.1: + parent-module@1.0.1: resolution: {integrity: sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==} engines: {node: '>=6'} - dependencies: - callsites: 3.1.0 - dev: true - /parse-json@5.2.0: + parse-json@5.2.0: resolution: {integrity: sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==} engines: {node: '>=8'} - dependencies: - '@babel/code-frame': 7.22.13 - error-ex: 1.3.2 - json-parse-even-better-errors: 2.3.1 - lines-and-columns: 1.2.4 - dev: true - /path-type@4.0.0: + path-type@4.0.0: resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==} engines: {node: '>=8'} - dev: true - /pluralize@8.0.0: + pluralize@8.0.0: resolution: {integrity: sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==} engines: {node: '>=4'} - dev: true - /pnpm@8.7.5: + pnpm@8.7.5: resolution: {integrity: sha512-WI8WZb89Uiq5x2jdz4PcQMG9ovTnXcDCEpoEckPYIT2zD8/+dEhVozPlT7bu3WkBgE0uTARtgyIKAFt+IpW2cQ==} engines: {node: '>=16.14'} hasBin: true - dev: true - - /prettier@2.8.8: - resolution: {integrity: sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==} - engines: {node: '>=10.13.0'} - hasBin: true - requiresBuild: true - dev: true - optional: true - /punycode@2.3.0: + punycode@2.3.0: resolution: {integrity: sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==} engines: {node: '>=6'} - dev: true - /require-from-string@2.0.2: + require-from-string@2.0.2: resolution: {integrity: sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==} engines: {node: '>=0.10.0'} - dev: true - /resolve-from@4.0.0: + resolve-from@4.0.0: resolution: {integrity: sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==} engines: {node: '>=4'} - dev: true - /semver@7.5.4: + semver@7.5.4: resolution: {integrity: sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==} engines: {node: '>=10'} hasBin: true - dependencies: - lru-cache: 6.0.0 - dev: true - /slice-ansi@4.0.0: + slice-ansi@4.0.0: resolution: {integrity: sha512-qMCMfhY040cVHT43K9BFygqYbUPFZKHOg7K73mtTWJRb8pyP3fzf4Ixd5SzdEJQ6MRUg/WBnOLxghZtKKurENQ==} engines: {node: '>=10'} + + solhint@3.6.2: + resolution: {integrity: sha512-85EeLbmkcPwD+3JR7aEMKsVC9YrRSxd4qkXuMzrlf7+z2Eqdfm1wHWq1ffTuo5aDhoZxp2I9yF3QkxZOxOL7aQ==} + hasBin: true + + string-width@4.2.3: + resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==} + engines: {node: '>=8'} + + strip-ansi@6.0.1: + resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==} + engines: {node: '>=8'} + + supports-color@5.5.0: + resolution: {integrity: sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==} + engines: {node: '>=4'} + + supports-color@7.2.0: + resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==} + engines: {node: '>=8'} + + table@6.8.1: + resolution: {integrity: sha512-Y4X9zqrCftUhMeH2EptSSERdVKt/nEdijTOacGD/97EKjhQ/Qs8RTlEGABSJNNN8lac9kheH+af7yAkEWlgneA==} + engines: {node: '>=10.0.0'} + + text-table@0.2.0: + resolution: {integrity: sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==} + + uri-js@4.4.1: + resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} + + wrappy@1.0.2: + resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} + + yallist@4.0.0: + resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==} + +snapshots: + + '@babel/code-frame@7.22.13': + dependencies: + '@babel/highlight': 7.22.13 + chalk: 2.4.2 + + '@babel/helper-validator-identifier@7.22.15': {} + + '@babel/highlight@7.22.13': + dependencies: + '@babel/helper-validator-identifier': 7.22.15 + chalk: 2.4.2 + js-tokens: 4.0.0 + + '@solidity-parser/parser@0.16.1': + dependencies: + antlr4ts: 0.5.0-alpha.4 + + ajv@6.12.6: + dependencies: + fast-deep-equal: 3.1.3 + fast-json-stable-stringify: 2.1.0 + json-schema-traverse: 0.4.1 + uri-js: 4.4.1 + + ajv@8.12.0: + dependencies: + fast-deep-equal: 3.1.3 + json-schema-traverse: 1.0.0 + require-from-string: 2.0.2 + uri-js: 4.4.1 + + ansi-regex@5.0.1: {} + + ansi-styles@3.2.1: + dependencies: + color-convert: 1.9.3 + + ansi-styles@4.3.0: + dependencies: + color-convert: 2.0.1 + + antlr4@4.13.1: {} + + antlr4ts@0.5.0-alpha.4: {} + + argparse@2.0.1: {} + + ast-parents@0.0.1: {} + + astral-regex@2.0.0: {} + + balanced-match@1.0.2: {} + + brace-expansion@2.0.1: + dependencies: + balanced-match: 1.0.2 + + callsites@3.1.0: {} + + chalk@2.4.2: + dependencies: + ansi-styles: 3.2.1 + escape-string-regexp: 1.0.5 + supports-color: 5.5.0 + + chalk@4.1.2: + dependencies: + ansi-styles: 4.3.0 + supports-color: 7.2.0 + + color-convert@1.9.3: + dependencies: + color-name: 1.1.3 + + color-convert@2.0.1: + dependencies: + color-name: 1.1.4 + + color-name@1.1.3: {} + + color-name@1.1.4: {} + + commander@10.0.1: {} + + cosmiconfig@8.3.6: + dependencies: + import-fresh: 3.3.0 + js-yaml: 4.1.0 + parse-json: 5.2.0 + path-type: 4.0.0 + + emoji-regex@8.0.0: {} + + error-ex@1.3.2: + dependencies: + is-arrayish: 0.2.1 + + escape-string-regexp@1.0.5: {} + + fast-deep-equal@3.1.3: {} + + fast-diff@1.3.0: {} + + fast-json-stable-stringify@2.1.0: {} + + fs.realpath@1.0.0: {} + + glob@8.1.0: + dependencies: + fs.realpath: 1.0.0 + inflight: 1.0.6 + inherits: 2.0.4 + minimatch: 5.1.6 + once: 1.4.0 + + has-flag@3.0.0: {} + + has-flag@4.0.0: {} + + ignore@5.2.4: {} + + import-fresh@3.3.0: + dependencies: + parent-module: 1.0.1 + resolve-from: 4.0.0 + + inflight@1.0.6: + dependencies: + once: 1.4.0 + wrappy: 1.0.2 + + inherits@2.0.4: {} + + is-arrayish@0.2.1: {} + + is-fullwidth-code-point@3.0.0: {} + + js-tokens@4.0.0: {} + + js-yaml@4.1.0: + dependencies: + argparse: 2.0.1 + + json-parse-even-better-errors@2.3.1: {} + + json-schema-traverse@0.4.1: {} + + json-schema-traverse@1.0.0: {} + + lines-and-columns@1.2.4: {} + + lodash.truncate@4.4.2: {} + + lodash@4.17.21: {} + + lru-cache@6.0.0: + dependencies: + yallist: 4.0.0 + + minimatch@5.1.6: + dependencies: + brace-expansion: 2.0.1 + + modular-account-libs@https://codeload.github.com/erc6900/modular-account-libs/tar.gz/52ab7c2b2f1abf327a8612945788f1b0c899ade6: {} + + once@1.4.0: + dependencies: + wrappy: 1.0.2 + + parent-module@1.0.1: + dependencies: + callsites: 3.1.0 + + parse-json@5.2.0: + dependencies: + '@babel/code-frame': 7.22.13 + error-ex: 1.3.2 + json-parse-even-better-errors: 2.3.1 + lines-and-columns: 1.2.4 + + path-type@4.0.0: {} + + pluralize@8.0.0: {} + + pnpm@8.7.5: {} + + punycode@2.3.0: {} + + require-from-string@2.0.2: {} + + resolve-from@4.0.0: {} + + semver@7.5.4: + dependencies: + lru-cache: 6.0.0 + + slice-ansi@4.0.0: dependencies: ansi-styles: 4.3.0 astral-regex: 2.0.0 is-fullwidth-code-point: 3.0.0 - dev: true - /solhint@3.6.2: - resolution: {integrity: sha512-85EeLbmkcPwD+3JR7aEMKsVC9YrRSxd4qkXuMzrlf7+z2Eqdfm1wHWq1ffTuo5aDhoZxp2I9yF3QkxZOxOL7aQ==} - hasBin: true + solhint@3.6.2: dependencies: '@solidity-parser/parser': 0.16.1 ajv: 6.12.6 @@ -408,67 +511,41 @@ packages: strip-ansi: 6.0.1 table: 6.8.1 text-table: 0.2.0 - optionalDependencies: - prettier: 2.8.8 transitivePeerDependencies: - typescript - dev: true - /string-width@4.2.3: - resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==} - engines: {node: '>=8'} + string-width@4.2.3: dependencies: emoji-regex: 8.0.0 is-fullwidth-code-point: 3.0.0 strip-ansi: 6.0.1 - dev: true - /strip-ansi@6.0.1: - resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==} - engines: {node: '>=8'} + strip-ansi@6.0.1: dependencies: ansi-regex: 5.0.1 - dev: true - /supports-color@5.5.0: - resolution: {integrity: sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==} - engines: {node: '>=4'} + supports-color@5.5.0: dependencies: has-flag: 3.0.0 - dev: true - /supports-color@7.2.0: - resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==} - engines: {node: '>=8'} + supports-color@7.2.0: dependencies: has-flag: 4.0.0 - dev: true - /table@6.8.1: - resolution: {integrity: sha512-Y4X9zqrCftUhMeH2EptSSERdVKt/nEdijTOacGD/97EKjhQ/Qs8RTlEGABSJNNN8lac9kheH+af7yAkEWlgneA==} - engines: {node: '>=10.0.0'} + table@6.8.1: dependencies: ajv: 8.12.0 lodash.truncate: 4.4.2 slice-ansi: 4.0.0 string-width: 4.2.3 strip-ansi: 6.0.1 - dev: true - /text-table@0.2.0: - resolution: {integrity: sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==} - dev: true + text-table@0.2.0: {} - /uri-js@4.4.1: - resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} + uri-js@4.4.1: dependencies: punycode: 2.3.0 - dev: true - /wrappy@1.0.2: - resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} - dev: true + wrappy@1.0.2: {} - /yallist@4.0.0: - resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==} - dev: true + yallist@4.0.0: {} diff --git a/remappings.txt b/remappings.txt index dd9c13a7..b82d3304 100644 --- a/remappings.txt +++ b/remappings.txt @@ -1,5 +1,6 @@ ds-test/=lib/forge-std/lib/ds-test/src/ forge-std/=lib/forge-std/src/ +modular-account-libs/=node_modules/modular-account-libs/src/ @eth-infinitism/account-abstraction/=lib/account-abstraction/contracts/ @openzeppelin/=lib/openzeppelin-contracts/ @alchemy/light-account/=lib/light-account/ From fd8aa73f7a0ff800c445bc3e7c8d3e09115a04d3 Mon Sep 17 00:00:00 2001 From: zer0dot Date: Fri, 10 May 2024 18:33:03 +0800 Subject: [PATCH 2/6] refactor: Refactor to use modular-account-libs --- src/account/AccountExecutor.sol | 4 +- src/account/AccountLoupe.sol | 8 +- src/account/AccountStorageV1.sol | 6 +- src/account/PluginManagerInternals.sol | 28 +- src/account/UpgradeableModularAccount.sol | 21 +- src/helpers/CastLib.sol | 4 +- ...ceLib.sol => FunctionReferenceHelpers.sol} | 30 +- src/helpers/KnownSelectors.sol | 12 +- src/helpers/ValidationDataHelpers.sol | 2 +- src/interfaces/IAccountLoupe.sol | 53 -- src/interfaces/IPlugin.sol | 189 ------- src/interfaces/IPluginExecutor.sol | 29 - src/interfaces/IPluginManager.sol | 39 -- src/interfaces/IStandardExecutor.sol | 34 -- src/interfaces/erc4337/IAccount.sol | 30 - src/interfaces/erc4337/IAggregator.sol | 2 +- src/interfaces/erc4337/IEntryPoint.sol | 2 +- src/interfaces/erc4337/IPaymaster.sol | 2 +- src/interfaces/erc4337/UserOperation.sol | 22 - src/libraries/AssociatedLinkedListSetLib.sol | 513 ------------------ src/libraries/Constants.sol | 22 - src/libraries/CountableLinkedListSetLib.sol | 80 --- src/libraries/LinkedListSetLib.sol | 325 ----------- src/libraries/PluginStorageLib.sol | 67 --- src/plugins/BasePlugin.sol | 4 +- src/plugins/owner/IMultiOwnerPlugin.sol | 2 +- src/plugins/owner/MultiOwnerPlugin.sol | 15 +- src/plugins/session/ISessionKeyPlugin.sol | 4 +- src/plugins/session/SessionKeyPlugin.sol | 24 +- .../permissions/SessionKeyPermissions.sol | 8 +- .../permissions/SessionKeyPermissionsBase.sol | 2 +- test/account/AccountExecHooks.t.sol | 6 +- test/account/AccountLoupe.t.sol | 20 +- test/account/AccountPreValidationHooks.t.sol | 8 +- test/account/AccountReturnData.t.sol | 4 +- .../ExecuteFromPluginPermissions.t.sol | 4 +- test/account/ManifestValidity.t.sol | 2 +- test/account/TokenReceiver.t.sol | 4 +- test/account/UpgradeableModularAccount.t.sol | 8 +- ...gradeableModularAccountPluginManager.t.sol | 14 +- test/account/ValidationIntersection.t.sol | 6 +- test/account/phases/AccountStatePhases.t.sol | 10 +- .../phases/AccountStatePhasesExec.t.sol | 6 +- .../AccountStatePhasesRTValidation.t.sol | 6 +- .../AccountStatePhasesUOValidation.t.sol | 6 +- test/comparison/CompareSimpleAccount.t.sol | 2 +- test/helpers/FunctionReferenceLib.t.sol | 56 -- test/helpers/KnownSelectors.t.sol | 10 +- ...AssociatedLinkedListSetLibInvariants.t.sol | 122 ----- test/invariant/LLSLRepro.t.sol | 6 +- .../LinkedListSetLibInvariants.t.sol | 94 ---- .../AssociatedLinkedListSetHandler.sol | 431 --------------- .../handlers/LinkedListSetHandler.sol | 352 ------------ .../AssociatedLinkedListSetLib.t.sol | 240 -------- .../libraries/CountableLinkedListSetLib.t.sol | 84 --- test/libraries/LinkedListSetLib.t.sol | 318 ----------- test/libraries/PluginStorageLib.t.sol | 107 ---- test/mocks/MockPlugin.sol | 2 +- .../plugins/AccountStateMutatingPlugin.sol | 4 +- .../plugins/BadTransferOwnershipPlugin.sol | 6 +- test/mocks/plugins/BaseTestPlugin.sol | 2 +- test/mocks/plugins/ChangingManifestPlugin.sol | 2 +- test/mocks/plugins/ComprehensivePlugin.sol | 6 +- .../ExecFromPluginPermissionsMocks.sol | 10 +- test/mocks/plugins/ManifestValidityMocks.sol | 10 +- test/mocks/plugins/ReturnDataPluginMocks.sol | 10 +- test/mocks/plugins/UninstallErrorsPlugin.sol | 2 +- test/mocks/plugins/ValidationPluginMocks.sol | 4 +- test/plugin/owner/MultiOwnerPlugin.t.sol | 4 +- .../owner/MultiOwnerPluginIntegration.t.sol | 6 +- .../SessionKeyPluginWithMultiOwner.t.sol | 8 +- .../SessionKeyERC20SpendLimits.t.sol | 8 +- .../permissions/SessionKeyGasLimits.t.sol | 8 +- .../SessionKeyNativeTokenSpendLimits.t.sol | 8 +- .../permissions/SessionKeyPermissions.t.sol | 8 +- test/upgrade/MAToMA.t.sol | 2 +- 76 files changed, 201 insertions(+), 3418 deletions(-) rename src/helpers/{FunctionReferenceLib.sol => FunctionReferenceHelpers.sol} (52%) delete mode 100644 src/interfaces/IAccountLoupe.sol delete mode 100644 src/interfaces/IPlugin.sol delete mode 100644 src/interfaces/IPluginExecutor.sol delete mode 100644 src/interfaces/IPluginManager.sol delete mode 100644 src/interfaces/IStandardExecutor.sol delete mode 100644 src/interfaces/erc4337/IAccount.sol delete mode 100644 src/interfaces/erc4337/UserOperation.sol delete mode 100644 src/libraries/AssociatedLinkedListSetLib.sol delete mode 100644 src/libraries/Constants.sol delete mode 100644 src/libraries/CountableLinkedListSetLib.sol delete mode 100644 src/libraries/LinkedListSetLib.sol delete mode 100644 src/libraries/PluginStorageLib.sol delete mode 100644 test/helpers/FunctionReferenceLib.t.sol delete mode 100644 test/invariant/AssociatedLinkedListSetLibInvariants.t.sol delete mode 100644 test/invariant/LinkedListSetLibInvariants.t.sol delete mode 100644 test/invariant/handlers/AssociatedLinkedListSetHandler.sol delete mode 100644 test/invariant/handlers/LinkedListSetHandler.sol delete mode 100644 test/libraries/AssociatedLinkedListSetLib.t.sol delete mode 100644 test/libraries/CountableLinkedListSetLib.t.sol delete mode 100644 test/libraries/LinkedListSetLib.t.sol delete mode 100644 test/libraries/PluginStorageLib.t.sol diff --git a/src/account/AccountExecutor.sol b/src/account/AccountExecutor.sol index f835ca99..05db6779 100644 --- a/src/account/AccountExecutor.sol +++ b/src/account/AccountExecutor.sol @@ -19,8 +19,8 @@ pragma solidity ^0.8.22; import {ERC165Checker} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol"; -import {UserOperation} from "../interfaces/erc4337/UserOperation.sol"; -import {IPlugin} from "../interfaces/IPlugin.sol"; +import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; +import {IPlugin} from "modular-account-libs/interfaces/IPlugin.sol"; /// @title Account Executor /// @author Alchemy diff --git a/src/account/AccountLoupe.sol b/src/account/AccountLoupe.sol index 3bcfbe2a..c51e81d9 100644 --- a/src/account/AccountLoupe.sol +++ b/src/account/AccountLoupe.sol @@ -20,10 +20,10 @@ pragma solidity ^0.8.22; import {AccountStorageV1} from "../account/AccountStorageV1.sol"; import {CastLib} from "../helpers/CastLib.sol"; import {KnownSelectors} from "../helpers/KnownSelectors.sol"; -import {IAccountLoupe} from "../interfaces/IAccountLoupe.sol"; -import {FunctionReference} from "../interfaces/IPluginManager.sol"; -import {CountableLinkedListSetLib} from "../libraries/CountableLinkedListSetLib.sol"; -import {LinkedListSet, LinkedListSetLib} from "../libraries/LinkedListSetLib.sol"; +import {IAccountLoupe} from "modular-account-libs/interfaces/IAccountLoupe.sol"; +import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; +import {CountableLinkedListSetLib} from "modular-account-libs/libraries/CountableLinkedListSetLib.sol"; +import {LinkedListSet, LinkedListSetLib} from "modular-account-libs/libraries/LinkedListSetLib.sol"; /// @title Account Loupe /// @author Alchemy diff --git a/src/account/AccountStorageV1.sol b/src/account/AccountStorageV1.sol index 526c1b50..7c0fe2c8 100644 --- a/src/account/AccountStorageV1.sol +++ b/src/account/AccountStorageV1.sol @@ -17,9 +17,9 @@ pragma solidity ^0.8.22; -import {IPlugin} from "../interfaces/IPlugin.sol"; -import {FunctionReference} from "../interfaces/IPluginManager.sol"; -import {LinkedListSet} from "../libraries/LinkedListSetLib.sol"; +import {IPlugin} from "modular-account-libs/interfaces/IPlugin.sol"; +import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; +import {LinkedListSet} from "modular-account-libs/libraries/LinkedListSetLib.sol"; /// @title Account Storage V1 /// @author Alchemy diff --git a/src/account/PluginManagerInternals.sol b/src/account/PluginManagerInternals.sol index 9c4e4f50..b1dfa5d5 100644 --- a/src/account/PluginManagerInternals.sol +++ b/src/account/PluginManagerInternals.sol @@ -19,10 +19,7 @@ pragma solidity ^0.8.22; import {ERC165Checker} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol"; -import {AccountStorageV1} from "../account/AccountStorageV1.sol"; -import {CastLib} from "../helpers/CastLib.sol"; -import {FunctionReferenceLib} from "../helpers/FunctionReferenceLib.sol"; -import {KnownSelectors} from "../helpers/KnownSelectors.sol"; +import {FunctionReferenceLib} from "modular-account-libs/libraries/FunctionReferenceLib.sol"; import { IPlugin, ManifestAssociatedFunction, @@ -31,10 +28,15 @@ import { ManifestExternalCallPermission, ManifestFunction, PluginManifest -} from "../interfaces/IPlugin.sol"; -import {FunctionReference, IPluginManager} from "../interfaces/IPluginManager.sol"; -import {CountableLinkedListSetLib} from "../libraries/CountableLinkedListSetLib.sol"; -import {LinkedListSet, LinkedListSetLib} from "../libraries/LinkedListSetLib.sol"; +} from "modular-account-libs/interfaces/IPlugin.sol"; +import {FunctionReference, IPluginManager} from "modular-account-libs/interfaces/IPluginManager.sol"; +import {CountableLinkedListSetLib} from "modular-account-libs/libraries/CountableLinkedListSetLib.sol"; +import {LinkedListSet, LinkedListSetLib} from "modular-account-libs/libraries/LinkedListSetLib.sol"; + +import {KnownSelectors} from "../helpers/KnownSelectors.sol"; +import {AccountStorageV1} from "../account/AccountStorageV1.sol"; +import {CastLib} from "../helpers/CastLib.sol"; +import {FunctionReferenceHelpers} from "../helpers/FunctionReferenceHelpers.sol"; /// @title Plugin Manager Internals /// @author Alchemy @@ -574,7 +576,7 @@ abstract contract PluginManagerInternals is IPluginManager, AccountStorageV1 { for (uint256 i = 0; i < length; ++i) { bytes4 executionSelector = args.manifest.runtimeValidationFunctions[i].executionSelector; storage_.selectorData[executionSelector].runtimeValidation = - FunctionReferenceLib._EMPTY_FUNCTION_REFERENCE; + FunctionReferenceLib.EMPTY_FUNCTION_REFERENCE; } // Remove user op validation function hooks @@ -582,7 +584,7 @@ abstract contract PluginManagerInternals is IPluginManager, AccountStorageV1 { for (uint256 i = 0; i < length; ++i) { bytes4 executionSelector = args.manifest.userOpValidationFunctions[i].executionSelector; storage_.selectorData[executionSelector].userOpValidation = - FunctionReferenceLib._EMPTY_FUNCTION_REFERENCE; + FunctionReferenceLib.EMPTY_FUNCTION_REFERENCE; } // Remove permitted external call permissions, anyExternalAddressPermitted is cleared when pluginData being @@ -672,17 +674,17 @@ abstract contract PluginManagerInternals is IPluginManager, AccountStorageV1 { } if (manifestFunction.functionType == ManifestAssociatedFunctionType.RUNTIME_VALIDATION_ALWAYS_ALLOW) { if (allowedMagicValue == ManifestAssociatedFunctionType.RUNTIME_VALIDATION_ALWAYS_ALLOW) { - return FunctionReferenceLib._RUNTIME_VALIDATION_ALWAYS_ALLOW; + return FunctionReferenceHelpers._RUNTIME_VALIDATION_ALWAYS_ALLOW; } revert InvalidPluginManifest(); } if (manifestFunction.functionType == ManifestAssociatedFunctionType.PRE_HOOK_ALWAYS_DENY) { if (allowedMagicValue == ManifestAssociatedFunctionType.PRE_HOOK_ALWAYS_DENY) { - return FunctionReferenceLib._PRE_HOOK_ALWAYS_DENY; + return FunctionReferenceHelpers._PRE_HOOK_ALWAYS_DENY; } revert InvalidPluginManifest(); } - return FunctionReferenceLib._EMPTY_FUNCTION_REFERENCE; // Empty checks are done elsewhere + return FunctionReferenceLib.EMPTY_FUNCTION_REFERENCE; // Empty checks are done elsewhere } function _assertNotNullFunction(FunctionReference functionReference) internal pure { diff --git a/src/account/UpgradeableModularAccount.sol b/src/account/UpgradeableModularAccount.sol index bbf23644..e292ef19 100644 --- a/src/account/UpgradeableModularAccount.sol +++ b/src/account/UpgradeableModularAccount.sol @@ -22,25 +22,27 @@ import {IERC777Recipient} from "@openzeppelin/contracts/interfaces/IERC777Recipi import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; +import {IAccount} from "modular-account-libs/interfaces/IAccount.sol"; +import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; +import {IPlugin, PluginManifest} from "modular-account-libs/interfaces/IPlugin.sol"; +import {FunctionReferenceLib} from "modular-account-libs/libraries/FunctionReferenceLib.sol"; +import {IPluginExecutor} from "modular-account-libs/interfaces/IPluginExecutor.sol"; +import {Call, IStandardExecutor} from "modular-account-libs/interfaces/IStandardExecutor.sol"; +import {CountableLinkedListSetLib} from "modular-account-libs/libraries/CountableLinkedListSetLib.sol"; +import {LinkedListSet, LinkedListSetLib} from "modular-account-libs/libraries/LinkedListSetLib.sol"; +import {FunctionReference, IPluginManager} from "modular-account-libs/interfaces/IPluginManager.sol"; + import {UUPSUpgradeable} from "../../ext/UUPSUpgradeable.sol"; import {CastLib} from "../helpers/CastLib.sol"; -import {FunctionReferenceLib} from "../helpers/FunctionReferenceLib.sol"; import {_coalescePreValidation, _coalesceValidation} from "../helpers/ValidationDataHelpers.sol"; -import {IAccount} from "../interfaces/erc4337/IAccount.sol"; import {IEntryPoint} from "../interfaces/erc4337/IEntryPoint.sol"; -import {UserOperation} from "../interfaces/erc4337/UserOperation.sol"; import {IAccountInitializable} from "../interfaces/IAccountInitializable.sol"; import {IAccountView} from "../interfaces/IAccountView.sol"; -import {IPlugin, PluginManifest} from "../interfaces/IPlugin.sol"; -import {IPluginExecutor} from "../interfaces/IPluginExecutor.sol"; -import {FunctionReference, IPluginManager} from "../interfaces/IPluginManager.sol"; -import {Call, IStandardExecutor} from "../interfaces/IStandardExecutor.sol"; -import {CountableLinkedListSetLib} from "../libraries/CountableLinkedListSetLib.sol"; -import {LinkedListSet, LinkedListSetLib} from "../libraries/LinkedListSetLib.sol"; import {AccountExecutor} from "./AccountExecutor.sol"; import {AccountLoupe} from "./AccountLoupe.sol"; import {AccountStorageInitializable} from "./AccountStorageInitializable.sol"; import {PluginManagerInternals} from "./PluginManagerInternals.sol"; +import {FunctionReferenceHelpers} from "../helpers/FunctionReferenceHelpers.sol"; /// @title Upgradeable Modular Account /// @author Alchemy @@ -64,6 +66,7 @@ contract UpgradeableModularAccount is using CountableLinkedListSetLib for LinkedListSet; using LinkedListSetLib for LinkedListSet; using FunctionReferenceLib for FunctionReference; + using FunctionReferenceHelpers for FunctionReference; /// @dev Struct to hold optional configuration data for uninstalling a plugin. This should be encoded and /// passed to the `config` parameter of `uninstallPlugin`. diff --git a/src/helpers/CastLib.sol b/src/helpers/CastLib.sol index 9e7e466c..8c2b0942 100644 --- a/src/helpers/CastLib.sol +++ b/src/helpers/CastLib.sol @@ -17,8 +17,8 @@ pragma solidity ^0.8.22; -import {SetValue} from "../libraries/Constants.sol"; -import {FunctionReference} from "./FunctionReferenceLib.sol"; +import {SetValue} from "modular-account-libs/libraries/Constants.sol"; +import {FunctionReference} from "modular-account-libs/libraries/FunctionReferenceLib.sol"; /// @title Cast Library /// @author Alchemy diff --git a/src/helpers/FunctionReferenceLib.sol b/src/helpers/FunctionReferenceHelpers.sol similarity index 52% rename from src/helpers/FunctionReferenceLib.sol rename to src/helpers/FunctionReferenceHelpers.sol index bf4bd74d..19b9b190 100644 --- a/src/helpers/FunctionReferenceLib.sol +++ b/src/helpers/FunctionReferenceHelpers.sol @@ -17,42 +17,18 @@ pragma solidity ^0.8.22; -import {FunctionReference} from "../interfaces/IPluginManager.sol"; +import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; -/// @title Function Reference Lib +/// @title Function Reference Helpers /// @author Alchemy -library FunctionReferenceLib { - // Empty or unset function reference. - FunctionReference internal constant _EMPTY_FUNCTION_REFERENCE = FunctionReference.wrap(bytes21(0)); +library FunctionReferenceHelpers { // Magic value for runtime validation functions that always allow access. FunctionReference internal constant _RUNTIME_VALIDATION_ALWAYS_ALLOW = FunctionReference.wrap(bytes21(uint168(1))); // Magic value for hooks that should always revert. FunctionReference internal constant _PRE_HOOK_ALWAYS_DENY = FunctionReference.wrap(bytes21(uint168(2))); - function pack(address addr, uint8 functionId) internal pure returns (FunctionReference) { - return FunctionReference.wrap(bytes21(bytes20(addr)) | bytes21(uint168(functionId))); - } - - function unpack(FunctionReference fr) internal pure returns (address addr, uint8 functionId) { - bytes21 underlying = FunctionReference.unwrap(fr); - addr = address(bytes20(underlying)); - functionId = uint8(bytes1(underlying << 160)); - } - function isEmptyOrMagicValue(FunctionReference fr) internal pure returns (bool) { return FunctionReference.unwrap(fr) <= bytes21(uint168(2)); } - - function isEmpty(FunctionReference fr) internal pure returns (bool) { - return FunctionReference.unwrap(fr) == bytes21(0); - } - - function eq(FunctionReference a, FunctionReference b) internal pure returns (bool) { - return FunctionReference.unwrap(a) == FunctionReference.unwrap(b); - } - - function notEq(FunctionReference a, FunctionReference b) internal pure returns (bool) { - return FunctionReference.unwrap(a) != FunctionReference.unwrap(b); - } } diff --git a/src/helpers/KnownSelectors.sol b/src/helpers/KnownSelectors.sol index ba677486..163363f9 100644 --- a/src/helpers/KnownSelectors.sol +++ b/src/helpers/KnownSelectors.sol @@ -23,16 +23,16 @@ import {IERC777Recipient} from "@openzeppelin/contracts/interfaces/IERC777Recipi import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; -import {IAccount} from "../../src/interfaces/erc4337/IAccount.sol"; +import {IAccount} from "modular-account-libs/interfaces/IAccount.sol"; import {IAggregator} from "../../src/interfaces/erc4337/IAggregator.sol"; import {IPaymaster} from "../../src/interfaces/erc4337/IPaymaster.sol"; -import {IAccountLoupe} from "../../src/interfaces/IAccountLoupe.sol"; +import {IAccountLoupe} from "modular-account-libs/interfaces/IAccountLoupe.sol"; import {IAccountView} from "../../src/interfaces/IAccountView.sol"; -import {IPluginManager} from "../../src/interfaces/IPluginManager.sol"; +import {IPluginManager} from "modular-account-libs/interfaces/IPluginManager.sol"; import {IAccountInitializable} from "../interfaces/IAccountInitializable.sol"; -import {IPlugin} from "../interfaces/IPlugin.sol"; -import {IPluginExecutor} from "../interfaces/IPluginExecutor.sol"; -import {IStandardExecutor} from "../interfaces/IStandardExecutor.sol"; +import {IPlugin} from "modular-account-libs/interfaces/IPlugin.sol"; +import {IPluginExecutor} from "modular-account-libs/interfaces/IPluginExecutor.sol"; +import {IStandardExecutor} from "modular-account-libs/interfaces/IStandardExecutor.sol"; /// @title Known Selectors /// @author Alchemy diff --git a/src/helpers/ValidationDataHelpers.sol b/src/helpers/ValidationDataHelpers.sol index 4a7a5ba2..4ce4eed4 100644 --- a/src/helpers/ValidationDataHelpers.sol +++ b/src/helpers/ValidationDataHelpers.sol @@ -17,7 +17,7 @@ pragma solidity ^0.8.22; -import {SIG_VALIDATION_FAILED} from "../libraries/Constants.sol"; +import {SIG_VALIDATION_FAILED} from "modular-account-libs/libraries/Constants.sol"; /// @dev This helper function assumes that uint160(validationData1) and uint160(validationData2) can only be 0 or 1 // solhint-disable-next-line private-vars-leading-underscore diff --git a/src/interfaces/IAccountLoupe.sol b/src/interfaces/IAccountLoupe.sol deleted file mode 100644 index 7a519abd..00000000 --- a/src/interfaces/IAccountLoupe.sol +++ /dev/null @@ -1,53 +0,0 @@ -// This work is marked with CC0 1.0 Universal. -// -// SPDX-License-Identifier: CC0-1.0 -// -// To view a copy of this license, visit http://creativecommons.org/publicdomain/zero/1.0 - -pragma solidity ^0.8.22; - -import {FunctionReference} from "./IPluginManager.sol"; - -/// @title Account Loupe Interface -interface IAccountLoupe { - /// @notice Config for an execution function, given a selector. - struct ExecutionFunctionConfig { - address plugin; - FunctionReference userOpValidationFunction; - FunctionReference runtimeValidationFunction; - } - - /// @notice Pre and post hooks for a given selector. - /// @dev It's possible for one of either `preExecHook` or `postExecHook` to be empty. - struct ExecutionHooks { - FunctionReference preExecHook; - FunctionReference postExecHook; - } - - /// @notice Get the validation functions and plugin address for a selector. - /// @dev If the selector is a native function, the plugin address will be the address of the account. - /// @param selector The selector to get the configuration for. - /// @return The configuration for this selector. - function getExecutionFunctionConfig(bytes4 selector) external view returns (ExecutionFunctionConfig memory); - - /// @notice Get the pre and post execution hooks for a selector. - /// @param selector The selector to get the hooks for. - /// @return The pre and post execution hooks for this selector. - function getExecutionHooks(bytes4 selector) external view returns (ExecutionHooks[] memory); - - /// @notice Get the pre user op and runtime validation hooks associated with a selector. - /// @param selector The selector to get the hooks for. - /// @return preUserOpValidationHooks The pre user op validation hooks for this selector. - /// @return preRuntimeValidationHooks The pre runtime validation hooks for this selector. - function getPreValidationHooks(bytes4 selector) - external - view - returns ( - FunctionReference[] memory preUserOpValidationHooks, - FunctionReference[] memory preRuntimeValidationHooks - ); - - /// @notice Get an array of all installed plugins. - /// @return The addresses of all installed plugins. - function getInstalledPlugins() external view returns (address[] memory); -} diff --git a/src/interfaces/IPlugin.sol b/src/interfaces/IPlugin.sol deleted file mode 100644 index 0b74df86..00000000 --- a/src/interfaces/IPlugin.sol +++ /dev/null @@ -1,189 +0,0 @@ -// This work is marked with CC0 1.0 Universal. -// -// SPDX-License-Identifier: CC0-1.0 -// -// To view a copy of this license, visit http://creativecommons.org/publicdomain/zero/1.0 - -pragma solidity ^0.8.22; - -import {UserOperation} from "../interfaces/erc4337/UserOperation.sol"; - -// Forge formatter will displace the first comment for the enum field out of the enum itself, -// so annotating here to prevent that. -// forgefmt: disable-start -enum ManifestAssociatedFunctionType { - // Function is not defined. - NONE, - // Function belongs to this plugin. - SELF, - // Function belongs to an external plugin provided as a dependency during plugin installation. Plugins MAY depend - // on external validation functions. It MUST NOT depend on external hooks, or installation will fail. - DEPENDENCY, - // Resolves to a magic value to always bypass runtime validation for a given function. - // This is only assignable on runtime validation functions. If it were to be used on a user op validation function, - // it would risk burning gas from the account. When used as a hook in any hook location, it is equivalent to not - // setting a hook and is therefore disallowed. - RUNTIME_VALIDATION_ALWAYS_ALLOW, - // Resolves to a magic value to always fail in a hook for a given function. - // This is only assignable to pre hooks (pre validation and pre execution). It should not be used on - // validation functions themselves, because this is equivalent to leaving the validation functions unset. - // It should not be used in post-exec hooks, because if it is known to always revert, that should happen - // as early as possible to save gas. - PRE_HOOK_ALWAYS_DENY -} -// forgefmt: disable-end - -/// @dev For functions of type `ManifestAssociatedFunctionType.DEPENDENCY`, the MSCA MUST find the plugin address -/// of the function at `dependencies[dependencyIndex]` during the call to `installPlugin(config)`. -struct ManifestFunction { - ManifestAssociatedFunctionType functionType; - uint8 functionId; - uint256 dependencyIndex; -} - -struct ManifestAssociatedFunction { - bytes4 executionSelector; - ManifestFunction associatedFunction; -} - -struct ManifestExecutionHook { - bytes4 executionSelector; - ManifestFunction preExecHook; - ManifestFunction postExecHook; -} - -struct ManifestExternalCallPermission { - address externalAddress; - bool permitAnySelector; - bytes4[] selectors; -} - -struct SelectorPermission { - bytes4 functionSelector; - string permissionDescription; -} - -/// @dev A struct holding fields to describe the plugin in a purely view context. Intended for front end clients. -struct PluginMetadata { - // A human-readable name of the plugin. - string name; - // The version of the plugin, following the semantic versioning scheme. - string version; - // The author field SHOULD be a username representing the identity of the user or organization - // that created this plugin. - string author; - // String descriptions of the relative sensitivity of specific functions. The selectors MUST be selectors for - // functions implemented by this plugin. - SelectorPermission[] permissionDescriptors; -} - -/// @dev A struct describing how the plugin should be installed on a modular account. -struct PluginManifest { - // List of ERC-165 interface IDs to add to account to support introspection checks. This MUST NOT include - // IPlugin's interface ID. - bytes4[] interfaceIds; - // If this plugin depends on other plugins' validation functions, the interface IDs of those plugins MUST be - // provided here, with its position in the array matching the `dependencyIndex` members of `ManifestFunction` - // structs used in the manifest. - bytes4[] dependencyInterfaceIds; - // Execution functions defined in this plugin to be installed on the MSCA. - bytes4[] executionFunctions; - // Plugin execution functions already installed on the MSCA that this plugin will be able to call. - bytes4[] permittedExecutionSelectors; - // Boolean to indicate whether the plugin can call any external address. - bool permitAnyExternalAddress; - // Boolean to indicate whether the plugin needs access to spend native tokens of the account. If false, the - // plugin MUST still be able to spend up to the balance that it sends to the account in the same call. - bool canSpendNativeToken; - ManifestExternalCallPermission[] permittedExternalCalls; - ManifestAssociatedFunction[] userOpValidationFunctions; - ManifestAssociatedFunction[] runtimeValidationFunctions; - ManifestAssociatedFunction[] preUserOpValidationHooks; - ManifestAssociatedFunction[] preRuntimeValidationHooks; - ManifestExecutionHook[] executionHooks; -} - -/// @title Plugin Interface -interface IPlugin { - /// @notice Initialize plugin data for the modular account. - /// @dev Called by the modular account during `installPlugin`. - /// @param data Optional bytes array to be decoded and used by the plugin to setup initial plugin data for the - /// modular account. - function onInstall(bytes calldata data) external; - - /// @notice Clear plugin data for the modular account. - /// @dev Called by the modular account during `uninstallPlugin`. - /// @param data Optional bytes array to be decoded and used by the plugin to clear plugin data for the modular - /// account. - function onUninstall(bytes calldata data) external; - - /// @notice Run the pre user operation validation hook specified by the `functionId`. - /// @dev Pre user operation validation hooks MUST NOT return an authorizer value other than 0 or 1. - /// @param functionId An identifier that routes the call to different internal implementations, should there be - /// more than one. - /// @param userOp The user operation. - /// @param userOpHash The user operation hash. - /// @return Packed validation data for validAfter (6 bytes), validUntil (6 bytes), and authorizer (20 bytes). - function preUserOpValidationHook(uint8 functionId, UserOperation calldata userOp, bytes32 userOpHash) - external - returns (uint256); - - /// @notice Run the user operation validationFunction specified by the `functionId`. - /// @param functionId An identifier that routes the call to different internal implementations, should there be - /// more than one. - /// @param userOp The user operation. - /// @param userOpHash The user operation hash. - /// @return Packed validation data for validAfter (6 bytes), validUntil (6 bytes), and authorizer (20 bytes). - function userOpValidationFunction(uint8 functionId, UserOperation calldata userOp, bytes32 userOpHash) - external - returns (uint256); - - /// @notice Run the pre runtime validation hook specified by the `functionId`. - /// @dev To indicate the entire call should revert, the function MUST revert. - /// @param functionId An identifier that routes the call to different internal implementations, should there be - /// more than one. - /// @param sender The caller address. - /// @param value The call value. - /// @param data The calldata sent. - function preRuntimeValidationHook(uint8 functionId, address sender, uint256 value, bytes calldata data) - external; - - /// @notice Run the runtime validationFunction specified by the `functionId`. - /// @dev To indicate the entire call should revert, the function MUST revert. - /// @param functionId An identifier that routes the call to different internal implementations, should there be - /// more than one. - /// @param sender The caller address. - /// @param value The call value. - /// @param data The calldata sent. - function runtimeValidationFunction(uint8 functionId, address sender, uint256 value, bytes calldata data) - external; - - /// @notice Run the pre execution hook specified by the `functionId`. - /// @dev To indicate the entire call should revert, the function MUST revert. - /// @param functionId An identifier that routes the call to different internal implementations, should there be - /// more than one. - /// @param sender The caller address. - /// @param value The call value. - /// @param data The calldata sent. - /// @return Context to pass to a post execution hook, if present. An empty bytes array MAY be returned. - function preExecutionHook(uint8 functionId, address sender, uint256 value, bytes calldata data) - external - returns (bytes memory); - - /// @notice Run the post execution hook specified by the `functionId`. - /// @dev To indicate the entire call should revert, the function MUST revert. - /// @param functionId An identifier that routes the call to different internal implementations, should there be - /// more than one. - /// @param preExecHookData The context returned by its associated pre execution hook. - function postExecutionHook(uint8 functionId, bytes calldata preExecHookData) external; - - /// @notice Describe the contents and intended configuration of the plugin. - /// @dev This manifest MUST stay constant over time. - /// @return A manifest describing the contents and intended configuration of the plugin. - function pluginManifest() external pure returns (PluginManifest memory); - - /// @notice Describe the metadata of the plugin. - /// @dev This metadata MUST stay constant over time. - /// @return A metadata struct describing the plugin. - function pluginMetadata() external pure returns (PluginMetadata memory); -} diff --git a/src/interfaces/IPluginExecutor.sol b/src/interfaces/IPluginExecutor.sol deleted file mode 100644 index 907917f1..00000000 --- a/src/interfaces/IPluginExecutor.sol +++ /dev/null @@ -1,29 +0,0 @@ -// This work is marked with CC0 1.0 Universal. -// -// SPDX-License-Identifier: CC0-1.0 -// -// To view a copy of this license, visit http://creativecommons.org/publicdomain/zero/1.0 - -pragma solidity ^0.8.22; - -/// @title Plugin Executor Interface -interface IPluginExecutor { - /// @notice Execute a call from a plugin to another plugin, via an execution function installed on the account. - /// @dev Plugins are not allowed to call native functions on the account. Permissions must be granted to the - /// calling plugin for the call to go through. - /// @param data The calldata to send to the plugin. - /// @return The return data from the call. - function executeFromPlugin(bytes calldata data) external payable returns (bytes memory); - - /// @notice Execute a call from a plugin to a non-plugin address. - /// @dev If the target is a plugin, the call SHOULD revert. Permissions must be granted to the calling plugin - /// for the call to go through. - /// @param target The address to be called. - /// @param value The value to send with the call. - /// @param data The calldata to send to the target. - /// @return The return data from the call. - function executeFromPluginExternal(address target, uint256 value, bytes calldata data) - external - payable - returns (bytes memory); -} diff --git a/src/interfaces/IPluginManager.sol b/src/interfaces/IPluginManager.sol deleted file mode 100644 index 16648c9b..00000000 --- a/src/interfaces/IPluginManager.sol +++ /dev/null @@ -1,39 +0,0 @@ -// This work is marked with CC0 1.0 Universal. -// -// SPDX-License-Identifier: CC0-1.0 -// -// To view a copy of this license, visit http://creativecommons.org/publicdomain/zero/1.0 - -pragma solidity ^0.8.22; - -// Treats the first 20 bytes as an address, and the last byte as a function identifier. -type FunctionReference is bytes21; - -/// @title Plugin Manager Interface -interface IPluginManager { - event PluginInstalled(address indexed plugin, bytes32 manifestHash, FunctionReference[] dependencies); - event PluginUninstalled(address indexed plugin, bool indexed onUninstallSucceeded); - - /// @notice Install a plugin to the modular account. - /// @param plugin The plugin to install. - /// @param manifestHash The hash of the plugin manifest. - /// @param pluginInstallData Optional data to be decoded and used by the plugin to setup initial plugin data - /// for the modular account. - /// @param dependencies The dependencies of the plugin, as described in the manifest. Each FunctionReference - /// MUST be composed of an installed plugin's address and a function ID of its validation function. - function installPlugin( - address plugin, - bytes32 manifestHash, - bytes calldata pluginInstallData, - FunctionReference[] calldata dependencies - ) external; - - /// @notice Uninstall a plugin from the modular account. - /// @dev Uninstalling owner plugins outside of a replace operation via executeBatch risks losing the account! - /// @param plugin The plugin to uninstall. - /// @param config An optional, implementation-specific field that accounts may use to ensure consistency - /// guarantees. - /// @param pluginUninstallData Optional data to be decoded and used by the plugin to clear plugin data for the - /// modular account. - function uninstallPlugin(address plugin, bytes calldata config, bytes calldata pluginUninstallData) external; -} diff --git a/src/interfaces/IStandardExecutor.sol b/src/interfaces/IStandardExecutor.sol deleted file mode 100644 index 4bdda531..00000000 --- a/src/interfaces/IStandardExecutor.sol +++ /dev/null @@ -1,34 +0,0 @@ -// This work is marked with CC0 1.0 Universal. -// -// SPDX-License-Identifier: CC0-1.0 -// -// To view a copy of this license, visit http://creativecommons.org/publicdomain/zero/1.0 - -pragma solidity ^0.8.22; - -struct Call { - // The target address for the account to call. - address target; - // The value to send with the call. - uint256 value; - // The calldata for the call. - bytes data; -} - -/// @title Standard Executor Interface -interface IStandardExecutor { - /// @notice Standard execute method. - /// @dev If the target is a plugin, the call SHOULD revert. - /// @param target The target address for the account to call. - /// @param value The value to send with the call. - /// @param data The calldata for the call. - /// @return The return data from the call. - function execute(address target, uint256 value, bytes calldata data) external payable returns (bytes memory); - - /// @notice Standard executeBatch method. - /// @dev If the target is a plugin, the call SHOULD revert. If any of the calls revert, the entire batch MUST - /// revert. - /// @param calls The array of calls. - /// @return An array containing the return data from the calls. - function executeBatch(Call[] calldata calls) external payable returns (bytes[] memory); -} diff --git a/src/interfaces/erc4337/IAccount.sol b/src/interfaces/erc4337/IAccount.sol deleted file mode 100644 index 907e7b5b..00000000 --- a/src/interfaces/erc4337/IAccount.sol +++ /dev/null @@ -1,30 +0,0 @@ -// This work is marked with CC0 1.0 Universal. -// -// SPDX-License-Identifier: CC0-1.0 -// -// To view a copy of this license, visit http://creativecommons.org/publicdomain/zero/1.0 - -pragma solidity ^0.8.22; - -import {IEntryPoint} from "./IEntryPoint.sol"; -import {UserOperation} from "./UserOperation.sol"; - -/// @notice Interface for the ERC-4337 account -interface IAccount { - /// @notice Validates a user operation, presumably by checking the signature and nonce. The entry point will - /// call this function to ensure that a user operation sent to it has been authorized, and thus that it should - /// call the account with the operation's call data and charge the account for gas in the absense of a - /// paymaster. If the signature is correctly formatted but invalid, this should return 1; other failures may - /// revert instead. In the case of a success, this can optionally return a signature aggregator and/or a time - /// range during which the operation is valid. - /// @param userOp the operation to be validated - /// @param userOpHash hash of the operation - /// @param missingAccountFunds amount that the account must send to the entry point as part of validation to - /// pay for gas - /// @return validationData Either 1 for an invalid signature, or a packed structure containing an optional - /// aggregator address in the first 20 bytes followed by two 6-byte timestamps representing the "validUntil" - /// and "validAfter" times at which the operation is valid (a "validUntil" of 0 means it is valid forever). - function validateUserOp(UserOperation calldata userOp, bytes32 userOpHash, uint256 missingAccountFunds) - external - returns (uint256 validationData); -} diff --git a/src/interfaces/erc4337/IAggregator.sol b/src/interfaces/erc4337/IAggregator.sol index de00ca5d..7d287b2f 100644 --- a/src/interfaces/erc4337/IAggregator.sol +++ b/src/interfaces/erc4337/IAggregator.sol @@ -6,7 +6,7 @@ pragma solidity ^0.8.22; -import {UserOperation} from "./UserOperation.sol"; +import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; /// @notice Interface for the ERC-4337 aggregator interface IAggregator { diff --git a/src/interfaces/erc4337/IEntryPoint.sol b/src/interfaces/erc4337/IEntryPoint.sol index 54056c08..af28332f 100644 --- a/src/interfaces/erc4337/IEntryPoint.sol +++ b/src/interfaces/erc4337/IEntryPoint.sol @@ -6,7 +6,7 @@ pragma solidity ^0.8.22; -import {UserOperation} from "./UserOperation.sol"; +import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; /// @notice Interface for the ERC-4337 entry point interface IEntryPoint { diff --git a/src/interfaces/erc4337/IPaymaster.sol b/src/interfaces/erc4337/IPaymaster.sol index 1fdf939f..4a02405a 100644 --- a/src/interfaces/erc4337/IPaymaster.sol +++ b/src/interfaces/erc4337/IPaymaster.sol @@ -6,7 +6,7 @@ pragma solidity ^0.8.22; -import {UserOperation} from "./UserOperation.sol"; +import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; /// @notice Interface for the ERC-4337 paymaster interface IPaymaster { diff --git a/src/interfaces/erc4337/UserOperation.sol b/src/interfaces/erc4337/UserOperation.sol deleted file mode 100644 index 1cad3743..00000000 --- a/src/interfaces/erc4337/UserOperation.sol +++ /dev/null @@ -1,22 +0,0 @@ -// This work is marked with CC0 1.0 Universal. -// -// SPDX-License-Identifier: CC0-1.0 -// -// To view a copy of this license, visit http://creativecommons.org/publicdomain/zero/1.0 - -pragma solidity ^0.8.22; - -/// @notice User Operation struct as defined in ERC-4337 -struct UserOperation { - address sender; - uint256 nonce; - bytes initCode; - bytes callData; - uint256 callGasLimit; - uint256 verificationGasLimit; - uint256 preVerificationGas; - uint256 maxFeePerGas; - uint256 maxPriorityFeePerGas; - bytes paymasterAndData; - bytes signature; -} diff --git a/src/libraries/AssociatedLinkedListSetLib.sol b/src/libraries/AssociatedLinkedListSetLib.sol deleted file mode 100644 index 5e827af0..00000000 --- a/src/libraries/AssociatedLinkedListSetLib.sol +++ /dev/null @@ -1,513 +0,0 @@ -// This file is part of Modular Account. -// -// Copyright 2024 Alchemy Insights, Inc. -// -// SPDX-License-Identifier: MIT -// -// See LICENSE-MIT file for more information - -pragma solidity ^0.8.22; - -import {SetValue, SENTINEL_VALUE, HAS_NEXT_FLAG} from "./Constants.sol"; - -/// @dev Type representing the set, which is just a storage slot placeholder like the solidity mapping type. -struct AssociatedLinkedListSet { - bytes32 placeholder; -} - -/// @title Associated Linked List Set Library -/// @author Alchemy -/// @notice Provides a set data structure that is enumerable and held in address-associated storage (per the -/// ERC-4337 spec) -library AssociatedLinkedListSetLib { - // Mapping Entry Byte Layout - // | value | 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA____ | - // | meta | 0x____________________________________________________________BBBB | - - // Bit-layout of the meta bytes (2 bytes) - // | user flags | 11111111 11111100 | - // | has next | 00000000 00000010 | - // | sentinel | 00000000 00000001 | - - // Mapping keys exclude the upper 15 bits of the meta bytes, which allows keys to be either a value or the - // sentinel. - - // This cannot be evaluated at compile time because of its use in inline assembly. - bytes4 internal constant _ASSOCIATED_STORAGE_PREFIX = 0xf938c976; // bytes4(keccak256("AssociatedLinkedListSet")) - - // A custom type representing the index of a storage slot - type StoragePointer is bytes32; - - // A custom type representing a pointer to a location in memory beyond the current free memory pointer. - // Holds a fixed-size buffer similar to "bytes memory", but without a length field. - // Care must be taken when using these, as they may be overwritten if ANY memory is allocated after allocating - // a TempBytesMemory. - type TempBytesMemory is bytes32; - - // INTERNAL METHODS - - /// @notice Adds a value to a set. - /// @param set The set to add the value to. - /// @param associated The address the set is associated with. - /// @param value The value to add. - /// @return True if the value was added, false if the value cannot be added (already exists or is zero). - function tryAdd(AssociatedLinkedListSet storage set, address associated, SetValue value) - internal - returns (bool) - { - bytes32 unwrappedKey = bytes32(SetValue.unwrap(value)); - if (unwrappedKey == bytes32(0)) { - // Cannot add the zero value - return false; - } - - TempBytesMemory keyBuffer = _allocateTempKeyBuffer(set, associated); - - StoragePointer valueSlot = _mapLookup(keyBuffer, unwrappedKey); - if (_load(valueSlot) != bytes32(0)) { - // Entry already exists - return false; - } - - // Load the head of the set - StoragePointer sentinelSlot = _mapLookup(keyBuffer, SENTINEL_VALUE); - bytes32 prev = _load(sentinelSlot); - if (prev == bytes32(0) || isSentinel(prev)) { - // set is empty, need to do: - // map[SENTINEL_VALUE] = unwrappedKey; - // map[unwrappedKey] = SENTINEL_VALUE; - _store(sentinelSlot, unwrappedKey); - _store(valueSlot, SENTINEL_VALUE); - } else { - // set is not empty, need to do: - // map[SENTINEL_VALUE] = unwrappedKey | HAS_NEXT_FLAG; - // map[unwrappedKey] = prev; - _store(sentinelSlot, unwrappedKey | HAS_NEXT_FLAG); - _store(valueSlot, prev); - } - - return true; - } - - /// @notice Removes a value from a set. - /// @dev This is an O(n) operation, where n is the number of elements in the set. - /// @param set The set to remove the value from - /// @param associated The address the set is associated with - /// @param value The value to remove - /// @return True if the value was removed, false if the value does not exist - function tryRemove(AssociatedLinkedListSet storage set, address associated, SetValue value) - internal - returns (bool) - { - bytes32 unwrappedKey = bytes32(SetValue.unwrap(value)); - TempBytesMemory keyBuffer = _allocateTempKeyBuffer(set, associated); - - StoragePointer valueSlot = _mapLookup(keyBuffer, unwrappedKey); - bytes32 nextValue = _load(valueSlot); - if (unwrappedKey == bytes32(0) || nextValue == bytes32(0)) { - // Entry does not exist - return false; - } - - bytes32 prevKey = SENTINEL_VALUE; - bytes32 currentVal; - do { - // Load the current entry - StoragePointer prevSlot = _mapLookup(keyBuffer, prevKey); - currentVal = _load(prevSlot); - bytes32 currentKey = clearFlags(currentVal); - if (currentKey == unwrappedKey) { - // Found the entry - // Set the previous value's next value to the next value, - // and the flags to the current value's flags. - // and the next value's `hasNext` flag to determine whether or not the next value is (or points to) - // the sentinel value. - - // Need to do: - // map[prevKey] = clearFlags(nextValue) | getUserFlags(currentVal) | (nextValue & HAS_NEXT_FLAG); - // map[currentKey] = bytes32(0); - - _store(prevSlot, clearFlags(nextValue) | getUserFlags(currentVal) | (nextValue & HAS_NEXT_FLAG)); - _store(valueSlot, bytes32(0)); - - return true; - } - prevKey = currentKey; - } while (!isSentinel(currentVal) && currentVal != bytes32(0)); - return false; - } - - /// @notice Removes a value from a set, given the previous value in the set. - /// @dev This is an O(1) operation but requires additional knowledge. - /// @param set The set to remove the value from - /// @param associated The address the set is associated with - /// @param value The value to remove - /// @param prev The previous value in the set - /// @return True if the value was removed, false if the value does not exist - function tryRemoveKnown(AssociatedLinkedListSet storage set, address associated, SetValue value, bytes32 prev) - internal - returns (bool) - { - bytes32 unwrappedKey = bytes32(SetValue.unwrap(value)); - TempBytesMemory keyBuffer = _allocateTempKeyBuffer(set, associated); - - prev = clearFlags(prev); - - if (prev == bytes32(0) || unwrappedKey == bytes32(0)) { - return false; - } - - // assert that the previous key's next value is the value to be removed - StoragePointer prevSlot = _mapLookup(keyBuffer, prev); - bytes32 currentValue = _load(prevSlot); - if (clearFlags(currentValue) != unwrappedKey) { - return false; - } - - StoragePointer valueSlot = _mapLookup(keyBuffer, unwrappedKey); - bytes32 next = _load(valueSlot); - if (next == bytes32(0)) { - // The set didn't actually contain the value - return false; - } - - // Need to do: - // map[prev] = clearUserFlags(next) | getUserFlags(currentValue); - // map[unwrappedKey] = bytes32(0); - _store(prevSlot, clearUserFlags(next) | getUserFlags(currentValue)); - _store(valueSlot, bytes32(0)); - - return true; - } - - /// @notice Removes all values from a set. - /// @dev This is an O(n) operation, where n is the number of elements in the set. - /// @param set The set to remove the values from - /// @param associated The address the set is associated with - function clear(AssociatedLinkedListSet storage set, address associated) internal { - TempBytesMemory keyBuffer = _allocateTempKeyBuffer(set, associated); - - bytes32 cursor = SENTINEL_VALUE; - - do { - StoragePointer cursorSlot = _mapLookup(keyBuffer, cursor); - bytes32 next = clearFlags(_load(cursorSlot)); - _store(cursorSlot, bytes32(0)); - cursor = next; - } while (!isSentinel(cursor) && cursor != bytes32(0)); - } - - /// @notice Set the flags on a value in the set. - /// @dev The user flags can only be set on the upper 14 bits, because the lower two are reserved for the - /// sentinel and has next bit. - /// @param set The set containing the value. - /// @param associated The address the set is associated with. - /// @param value The value to set the flags on. - /// @param flags The flags to set. - /// @return True if the set contains the value and the operation succeeds, false otherwise. - function trySetFlags(AssociatedLinkedListSet storage set, address associated, SetValue value, uint16 flags) - internal - returns (bool) - { - bytes32 unwrappedKey = SetValue.unwrap(value); - TempBytesMemory keyBuffer = _allocateTempKeyBuffer(set, associated); - - // Ignore the lower 2 bits. - flags &= 0xFFFC; - - // If the set doesn't actually contain the value, return false; - StoragePointer valueSlot = _mapLookup(keyBuffer, unwrappedKey); - bytes32 next = _load(valueSlot); - if (next == bytes32(0)) { - return false; - } - - // Set the flags - _store(valueSlot, clearUserFlags(next) | bytes32(uint256(flags))); - - return true; - } - - /// @notice Set the given flags on a value in the set, preserving the values of other flags. - /// @dev The user flags can only be set on the upper 14 bits, because the lower two are reserved for the - /// sentinel and has next bit. - /// Short-circuits if the flags are already enabled, returning true. - /// @param set The set containing the value. - /// @param associated The address the set is associated with. - /// @param value The value to enable the flags on. - /// @param flags The flags to enable. - /// @return True if the operation succeeds or short-circuits due to the flags already being enabled. False - /// otherwise. - function tryEnableFlags(AssociatedLinkedListSet storage set, address associated, SetValue value, uint16 flags) - internal - returns (bool) - { - flags &= 0xFFFC; // Allow short-circuit if lower bits are accidentally set - uint16 currFlags = getFlags(set, associated, value); - if (currFlags & flags == flags) return true; // flags are already enabled - return trySetFlags(set, associated, value, currFlags | flags); - } - - /// @notice Clear the given flags on a value in the set, preserving the values of other flags. - /// @notice If the value is not in the set, this function will still return true. - /// @dev The user flags can only be set on the upper 14 bits, because the lower two are reserved for the - /// sentinel and has next bit. - /// Short-circuits if the flags are already disabled, or if set does not contain the value. Short-circuits - /// return true. - /// @param set The set containing the value. - /// @param associated The address the set is associated with. - /// @param value The value to disable the flags on. - /// @param flags The flags to disable. - /// @return True if the operation succeeds, or short-circuits due to the flags already being disabled or if the - /// set does not contain the value. False otherwise. - function tryDisableFlags(AssociatedLinkedListSet storage set, address associated, SetValue value, uint16 flags) - internal - returns (bool) - { - flags &= 0xFFFC; // Allow short-circuit if lower bits are accidentally set - uint16 currFlags = getFlags(set, associated, value); - if (currFlags & flags == 0) return true; // flags are already disabled - return trySetFlags(set, associated, value, currFlags & ~flags); - } - - /// @notice Checks if a set contains a value - /// @dev This method does not clear the upper bits of `value`, that is expected to be done as part of casting - /// to the correct type. If this function is provided the sentinel value by using the upper bits, this function - /// may returns `true`. - /// @param set The set to check - /// @param associated The address the set is associated with - /// @param value The value to check for - /// @return True if the set contains the value, false otherwise - function contains(AssociatedLinkedListSet storage set, address associated, SetValue value) - internal - view - returns (bool) - { - bytes32 unwrappedKey = bytes32(SetValue.unwrap(value)); - TempBytesMemory keyBuffer = _allocateTempKeyBuffer(set, associated); - - StoragePointer slot = _mapLookup(keyBuffer, unwrappedKey); - return _load(slot) != bytes32(0); - } - - /// @notice Checks if a set is empty - /// @param set The set to check - /// @param associated The address the set is associated with - /// @return True if the set is empty, false otherwise - function isEmpty(AssociatedLinkedListSet storage set, address associated) internal view returns (bool) { - TempBytesMemory keyBuffer = _allocateTempKeyBuffer(set, associated); - - StoragePointer sentinelSlot = _mapLookup(keyBuffer, SENTINEL_VALUE); - bytes32 val = _load(sentinelSlot); - return val == bytes32(0) || isSentinel(val); // either the sentinel is unset, or points to itself - } - - /// @notice Get the flags on a value in the set. - /// @dev The reserved lower 2 bits will not be returned, as those are reserved for the sentinel and has next - /// bit. - /// @param set The set containing the value. - /// @param associated The address the set is associated with. - /// @param value The value to get the flags from. - /// @return The flags set on the value. - function getFlags(AssociatedLinkedListSet storage set, address associated, SetValue value) - internal - view - returns (uint16) - { - bytes32 unwrappedKey = SetValue.unwrap(value); - TempBytesMemory keyBuffer = _allocateTempKeyBuffer(set, associated); - return uint16(uint256(_load(_mapLookup(keyBuffer, unwrappedKey))) & 0xFFFC); - } - - /// @notice Check if the flags on a value are enabled. - /// @dev The reserved lower 2 bits will be ignored, as those are reserved for the sentinel and has next bit. - /// @param set The set containing the value. - /// @param associated The address the set is associated with. - /// @param value The value to check the flags on. - /// @param flags The flags to check. - /// @return True if all of the flags are enabled, false otherwise. - function flagsEnabled(AssociatedLinkedListSet storage set, address associated, SetValue value, uint16 flags) - internal - view - returns (bool) - { - flags &= 0xFFFC; - return getFlags(set, associated, value) & flags == flags; - } - - /// @notice Check if the flags on a value are disabled. - /// @dev The reserved lower 2 bits will be ignored, as those are reserved for the sentinel and has next bit. - /// @param set The set containing the value. - /// @param associated The address the set is associated with. - /// @param value The value to check the flags on. - /// @param flags The flags to check. - /// @return True if all of the flags are disabled, false otherwise. - function flagsDisabled(AssociatedLinkedListSet storage set, address associated, SetValue value, uint16 flags) - internal - view - returns (bool) - { - flags &= 0xFFFC; - return ~(getFlags(set, associated, value)) & flags == flags; - } - - /// @notice Gets all elements in a set. - /// @dev This is an O(n) operation, where n is the number of elements in the set. - /// @param set The set to get the elements of. - /// @return ret An array of all elements in the set. - function getAll(AssociatedLinkedListSet storage set, address associated) - internal - view - returns (SetValue[] memory ret) - { - TempBytesMemory keyBuffer = _allocateTempKeyBuffer(set, associated); - uint256 size; - bytes32 cursor = _load(_mapLookup(keyBuffer, SENTINEL_VALUE)); - - // Dynamically allocate the returned array as we iterate through the set, since we don't know the size - // beforehand. - // This is accomplished by first writing to memory after the free memory pointer, - // then updating the free memory pointer to cover the newly-allocated data. - // To the compiler, writes to memory after the free memory pointer are considered "memory safe". - // See https://docs.soliditylang.org/en/v0.8.22/assembly.html#memory-safety - // Stack variable lifting done when compiling with via-ir will only ever place variables into memory - // locations below the current free memory pointer, so it is safe to compile this library with via-ir. - // See https://docs.soliditylang.org/en/v0.8.22/yul.html#memoryguard - assembly ("memory-safe") { - // It is critical that no other memory allocations occur between: - // - loading the value of the free memory pointer into `ret` - // - updating the free memory pointer to point to the newly-allocated data, which is done after all - // the values have been written. - ret := mload(0x40) - // Add an extra offset of 4 words to account for the length of the keyBuffer, since it will be used - // for each lookup. If this value were written back to the free memory pointer, it would effectively - // convert the keyBuffer into a "bytes memory" type. However, we don't actually write to the free - // memory pointer until after all we've also allocated the entire return array. - ret := add(ret, 0x80) - } - - while (!isSentinel(cursor) && cursor != bytes32(0)) { - unchecked { - ++size; - } - bytes32 cleared = clearFlags(cursor); - // Place the item into the return array manually. Since the size was just incremented, it will point to - // the next location to write to. - assembly ("memory-safe") { - mstore(add(ret, mul(size, 0x20)), cleared) - } - if (hasNext(cursor)) { - cursor = _load(_mapLookup(keyBuffer, cleared)); - } else { - cursor = bytes32(0); - } - } - - assembly ("memory-safe") { - // Update the free memory pointer with the now-known length of the array. - mstore(0x40, add(ret, mul(add(size, 1), 0x20))) - // Set the length of the array. - mstore(ret, size) - } - } - - function isSentinel(bytes32 value) internal pure returns (bool ret) { - assembly ("memory-safe") { - ret := and(value, 1) - } - } - - function hasNext(bytes32 value) internal pure returns (bool) { - return value & HAS_NEXT_FLAG != 0; - } - - function clearFlags(bytes32 val) internal pure returns (bytes32) { - return val & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0001; - } - - /// @dev Preserves the lower two bits - function clearUserFlags(bytes32 val) internal pure returns (bytes32) { - return val & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0003; - } - - function getUserFlags(bytes32 val) internal pure returns (bytes32) { - return val & bytes32(uint256(0xFFFC)); - } - - // PRIVATE METHODS - - /// @notice Given an allocated key buffer, returns the storage slot for a given key - function _mapLookup(TempBytesMemory keyBuffer, bytes32 value) private pure returns (StoragePointer slot) { - assembly ("memory-safe") { - // Store the value in the last word. - mstore(add(keyBuffer, 0x60), value) - slot := keccak256(keyBuffer, 0x80) - } - } - - /// @notice Allocates a key buffer for a given ID and associated address into scratch space memory. - /// @dev The returned buffer must not be used if any additional memory is allocated after calling this - /// function. - /// @param set The set to allocate the key buffer for. - /// @param associated The address the set is associated with. - /// @return key A key buffer that can be used to lookup values in the set - function _allocateTempKeyBuffer(AssociatedLinkedListSet storage set, address associated) - private - pure - returns (TempBytesMemory key) - { - // Key derivation for an entry - // Note: `||` refers to the concat operator - // associated addr (left-padded) || prefix || uint224(0) batchIndex || set storage slot || entry - // Word 1: - // | zeros | 0x000000000000000000000000________________________________________ | - // | address | 0x________________________AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA | - // Word 2: - // | prefix | 0xPPPPPPPP________________________________________________________ | - // | batch index (zero) | 0x________00000000000000000000000000000000000000000000000000000000 | - // Word 3: - // | set storage slot | 0xSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS | - // Word 4: - // | entry value | 0xVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV____ | - // | entry meta | 0x____________________________________________________________MMMM | - - // The batch index is for consistency with PluginStorageLib, and the prefix in front of it is - // to prevent any potential crafted collisions where the batch index may be equal to storage slot - // of the ALLS. The prefix is set to the upper bits of the batch index to make it infeasible to - // reach from just incrementing the value. - - // This segment is memory-safe because it only uses the scratch space memory after the value of the free - // memory pointer. - // See https://docs.soliditylang.org/en/v0.8.22/assembly.html#memory-safety - assembly ("memory-safe") { - // Clean upper bits of arguments - associated := and(associated, 0xffffffffffffffffffffffffffffffffffffffff) - - // Use memory past-the-free-memory-pointer without updating it, as this is just scratch space - key := mload(0x40) - // Store the associated address in the first word, left-padded with zeroes - mstore(key, associated) - // Store the prefix and a batch index of 0 - mstore(add(key, 0x20), _ASSOCIATED_STORAGE_PREFIX) - // Store the list's storage slot in the third word - mstore(add(key, 0x40), set.slot) - // Leaves the last word open for the value entry - } - - return key; - } - - /// @dev Loads a value from storage - function _load(StoragePointer ptr) private view returns (bytes32 val) { - assembly ("memory-safe") { - val := sload(ptr) - } - } - - /// @dev Writes a value into storage - function _store(StoragePointer ptr, bytes32 val) private { - assembly ("memory-safe") { - sstore(ptr, val) - } - } -} diff --git a/src/libraries/Constants.sol b/src/libraries/Constants.sol deleted file mode 100644 index 192a095d..00000000 --- a/src/libraries/Constants.sol +++ /dev/null @@ -1,22 +0,0 @@ -// This file is part of Modular Account. -// -// Copyright 2024 Alchemy Insights, Inc. -// -// SPDX-License-Identifier: MIT -// -// See LICENSE-MIT file for more information - -pragma solidity ^0.8.22; - -type SetValue is bytes30; - -/// @dev The sentinel value is used to indicate the head and tail of the list. -bytes32 constant SENTINEL_VALUE = bytes32(uint256(1)); - -/// @dev Removing the last element will result in this flag not being set correctly, but all operations will -/// function normally, albeit with one extra sload for getAll. -bytes32 constant HAS_NEXT_FLAG = bytes32(uint256(2)); - -/// @dev As defined by ERC-4337. -uint256 constant SIG_VALIDATION_PASSED = 0; -uint256 constant SIG_VALIDATION_FAILED = 1; diff --git a/src/libraries/CountableLinkedListSetLib.sol b/src/libraries/CountableLinkedListSetLib.sol deleted file mode 100644 index a29a5aa8..00000000 --- a/src/libraries/CountableLinkedListSetLib.sol +++ /dev/null @@ -1,80 +0,0 @@ -// This file is part of Modular Account. -// -// Copyright 2024 Alchemy Insights, Inc. -// -// SPDX-License-Identifier: MIT -// -// See LICENSE-MIT file for more information - -pragma solidity ^0.8.22; - -import {SetValue} from "./Constants.sol"; -import {LinkedListSet, LinkedListSetLib} from "./LinkedListSetLib.sol"; - -/// @title Countable Linked List Set Library -/// @author Alchemy -/// @notice This library adds the ability to count the number of occurrences of a value in a linked list set. -/// @dev The counter is stored in the upper 8 bits of the the flag bytes, so the maximum value of the counter -/// is 255. This means each value can be included a maximum of 256 times in the set, as the counter is 0 when -/// the value is first added. -library CountableLinkedListSetLib { - using LinkedListSetLib for LinkedListSet; - - /// @notice Increment an existing value in the set, or add it if it doesn't exist. - /// @dev The counter is stored in the upper 8 bits of the the flag bytes. Because this library repurposes a - /// portion of the flag bytes to store the counter, it's important to not use the upper 8 bits to store flags. - /// Any existing flags on the upper 8 bits will be interpreted as part of the counter. - /// @param set The set to increment (or add) the value in. - /// @param value The value to increment (or add). - /// @return True if the value was incremented or added, false otherwise. - function tryIncrement(LinkedListSet storage set, SetValue value) internal returns (bool) { - if (!set.contains(value)) { - return set.tryAdd(value); - } - uint16 flags = set.getFlags(value); - if (flags > 0xFEFF) { - // The counter is at its maximum value, so don't increment it. - return false; - } - unchecked { - flags += 0x100; - } - return set.trySetFlags(value, flags); - } - - /// @notice Decrement an existing value in the set, or remove it if the count has reached 0. - /// @dev The counter is stored in the upper 8 bits of the the flag bytes. Because this library repurposes a - /// portion of the flag bytes to store the counter, it's important to not use the upper 8 bits to store flags. - /// Any existing flags on the upper 8 bits will be interpreted as part of the counter. - /// @param set The set to decrement (or remove) the value in. - /// @param value The value to decrement (or remove). - /// @return True if the value was decremented or removed, false otherwise. - function tryDecrement(LinkedListSet storage set, SetValue value) internal returns (bool) { - if (!set.contains(value)) { - return false; - } - uint16 flags = set.getFlags(value); - if (flags < 0x100) { - // The counter is 0, so remove the value. - return set.tryRemove(value); - } - unchecked { - flags -= 0x100; - } - return set.trySetFlags(value, flags); - } - - /// @notice Get the number of occurrences of a value in the set. - /// @dev The counter is stored in the upper 8 bits of the the flag bytes. Because this library repurposes a - /// portion of the flag bytes to store the counter, it's important to not use the upper 8 bits to store flags. - /// Any existing flags on the upper 8 bits will be interpreted as part of the counter. - /// @return The number of occurrences of the value in the set. - function getCount(LinkedListSet storage set, SetValue value) internal view returns (uint256) { - if (!set.contains(value)) { - return 0; - } - unchecked { - return (set.getFlags(value) >> 8) + 1; - } - } -} diff --git a/src/libraries/LinkedListSetLib.sol b/src/libraries/LinkedListSetLib.sol deleted file mode 100644 index 5cbace09..00000000 --- a/src/libraries/LinkedListSetLib.sol +++ /dev/null @@ -1,325 +0,0 @@ -// This file is part of Modular Account. -// -// Copyright 2024 Alchemy Insights, Inc. -// -// SPDX-License-Identifier: MIT -// -// See LICENSE-MIT file for more information - -pragma solidity ^0.8.22; - -import {SetValue, SENTINEL_VALUE, HAS_NEXT_FLAG} from "./Constants.sol"; - -struct LinkedListSet { - // Byte Layout - // | value | 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA____ | - // | meta | 0x____________________________________________________________BBBB | - - // Bit-layout of the meta bytes (2 bytes) - // | user flags | 11111111 11111100 | - // | has next | 00000000 00000010 | - // | sentinel | 00000000 00000001 | - - // Key excludes the meta bytes, except for the sentinel value, which is 0x1 - mapping(bytes32 => bytes32) map; -} - -/// @title Linked List Set Library -/// @author Alchemy -/// @notice This library provides a set of functions for managing enumerable sets of bytes30 values. -library LinkedListSetLib { - // INTERNAL METHODS - - /// @notice Add a value to a set. - /// @param set The set to add the value to. - /// @param value The value to add. - /// @return True if the value was added, false if the value cannot be added (already exists or is zero). - function tryAdd(LinkedListSet storage set, SetValue value) internal returns (bool) { - mapping(bytes32 => bytes32) storage map = set.map; - bytes32 unwrappedKey = SetValue.unwrap(value); - if (unwrappedKey == bytes32(0) || map[unwrappedKey] != bytes32(0)) return false; - - bytes32 prev = map[SENTINEL_VALUE]; - if (prev == bytes32(0) || isSentinel(prev)) { - // Set is empty - map[SENTINEL_VALUE] = unwrappedKey; - map[unwrappedKey] = SENTINEL_VALUE; - } else { - // set is not empty - map[SENTINEL_VALUE] = unwrappedKey | HAS_NEXT_FLAG; - map[unwrappedKey] = prev; - } - - return true; - } - - /// @notice Remove a value from a set. - /// @dev This is an O(n) operation, where n is the number of elements in the set. - /// @param set The set to remove the value from. - /// @param value The value to remove. - /// @return True if the value was removed, false if the value does not exist. - function tryRemove(LinkedListSet storage set, SetValue value) internal returns (bool) { - mapping(bytes32 => bytes32) storage map = set.map; - bytes32 unwrappedKey = SetValue.unwrap(value); - - bytes32 nextValue = map[unwrappedKey]; - if (unwrappedKey == bytes32(0) || nextValue == bytes32(0)) return false; - - bytes32 prevKey = SENTINEL_VALUE; - bytes32 currentVal; - do { - currentVal = map[prevKey]; - bytes32 currentKey = clearFlags(currentVal); - if (currentKey == unwrappedKey) { - // Set the previous value's next value to the next value, - // and the flags to the current value's flags. - // and the next value's `hasNext` flag to determine whether or not the next value is (or points to) - // the sentinel value. - map[prevKey] = clearFlags(nextValue) | getUserFlags(currentVal) | (nextValue & HAS_NEXT_FLAG); - map[currentKey] = bytes32(0); - - return true; - } - prevKey = currentKey; - } while (!isSentinel(currentVal) && currentVal != bytes32(0)); - return false; - } - - /// @notice Remove a value from a set, given the previous value in the set. - /// @dev This is an O(1) operation but requires additional knowledge. - /// @param set The set to remove the value from. - /// @param value The value to remove. - /// @param prev The previous value in the set. - /// @return True if the value was removed, false if the value does not exist. - function tryRemoveKnown(LinkedListSet storage set, SetValue value, bytes32 prev) internal returns (bool) { - mapping(bytes32 => bytes32) storage map = set.map; - bytes32 unwrappedKey = SetValue.unwrap(value); - - // Clear the flag bits of prev - prev = clearFlags(prev); - - if (prev == bytes32(0) || unwrappedKey == bytes32(0)) { - return false; - } - - // assert that the previous value's next value is the value to be removed - bytes32 currentValue = map[prev]; - if (clearFlags(currentValue) != unwrappedKey) { - return false; - } - - bytes32 next = map[unwrappedKey]; - if (next == bytes32(0)) { - // The set didn't actually contain the value - return false; - } - - map[prev] = clearUserFlags(next) | getUserFlags(currentValue); - map[unwrappedKey] = bytes32(0); - return true; - } - - /// @notice Remove all values from a set. - /// @dev This is an O(n) operation, where n is the number of elements in the set. - /// @param set The set to remove the values from. - function clear(LinkedListSet storage set) internal { - mapping(bytes32 => bytes32) storage map = set.map; - bytes32 cursor = SENTINEL_VALUE; - - do { - bytes32 next = clearFlags(map[cursor]); - map[cursor] = bytes32(0); - cursor = next; - } while (!isSentinel(cursor) && cursor != bytes32(0)); - } - - /// @notice Set the flags on a value in the set. - /// @dev The user flags can only be set on the upper 14 bits, because the lower two are reserved for the - /// sentinel and has next bit. - /// @param set The set containing the value. - /// @param value The value to set the flags on. - /// @param flags The flags to set. - /// @return True if the set contains the value and the operation succeeds, false otherwise. - function trySetFlags(LinkedListSet storage set, SetValue value, uint16 flags) internal returns (bool) { - mapping(bytes32 => bytes32) storage map = set.map; - bytes32 unwrappedKey = SetValue.unwrap(value); - - // Ignore the lower 2 bits. - flags &= 0xFFFC; - - // If the set doesn't actually contain the value, return false; - bytes32 next = map[unwrappedKey]; - if (next == bytes32(0)) { - return false; - } - - // Set the flags - map[unwrappedKey] = clearUserFlags(next) | bytes32(uint256(flags)); - - return true; - } - - /// @notice Set the given flags on a value in the set, preserving the values of other flags. - /// @dev The user flags can only be set on the upper 14 bits, because the lower two are reserved for the - /// sentinel and has next bit. - /// Short-circuits if the flags are already enabled, returning true. - /// @param set The set containing the value. - /// @param value The value to enable the flags on. - /// @param flags The flags to enable. - /// @return True if the operation succeeds or short-circuits due to the flags already being enabled. False - /// otherwise. - function tryEnableFlags(LinkedListSet storage set, SetValue value, uint16 flags) internal returns (bool) { - flags &= 0xFFFC; // Allow short-circuit if lower bits are accidentally set - uint16 currFlags = getFlags(set, value); - if (currFlags & flags == flags) return true; // flags are already enabled - return trySetFlags(set, value, currFlags | flags); - } - - /// @notice Clear the given flags on a value in the set, preserving the values of other flags. - /// @notice If the value is not in the set, this function will still return true. - /// @dev The user flags can only be set on the upper 14 bits, because the lower two are reserved for the - /// sentinel and has next bit. - /// Short-circuits if the flags are already disabled, or if set does not contain the value. Short-circuits - /// return true. - /// @param set The set containing the value. - /// @param value The value to disable the flags on. - /// @param flags The flags to disable. - /// @return True if the operation succeeds, or short-circuits due to the flags already being disabled or if the - /// set does not contain the value. False otherwise. - function tryDisableFlags(LinkedListSet storage set, SetValue value, uint16 flags) internal returns (bool) { - flags &= 0xFFFC; // Allow short-circuit if lower bits are accidentally set - uint16 currFlags = getFlags(set, value); - if (currFlags & flags == 0) return true; // flags are already disabled - return trySetFlags(set, value, currFlags & ~flags); - } - - /// @notice Check if a set contains a value. - /// @dev This method does not clear the upper bits of `value`, that is expected to be done as part of casting - /// to the correct type. If this function is provided the sentinel value by using the upper bits, this function - /// may returns `true`. - /// @param set The set to check. - /// @param value The value to check for. - /// @return True if the set contains the value, false otherwise. - function contains(LinkedListSet storage set, SetValue value) internal view returns (bool) { - mapping(bytes32 => bytes32) storage map = set.map; - return map[SetValue.unwrap(value)] != bytes32(0); - } - - /// @notice Check if a set is empty. - /// @param set The set to check. - /// @return True if the set is empty, false otherwise. - function isEmpty(LinkedListSet storage set) internal view returns (bool) { - mapping(bytes32 => bytes32) storage map = set.map; - bytes32 val = map[SENTINEL_VALUE]; - return val == bytes32(0) || isSentinel(val); // either the sentinel is unset, or points to itself - } - - /// @notice Get the flags on a value in the set. - /// @dev The reserved lower 2 bits will not be returned, as those are reserved for the sentinel and has next - /// bit. - /// @param set The set containing the value. - /// @param value The value to get the flags from. - /// @return The flags set on the value. - function getFlags(LinkedListSet storage set, SetValue value) internal view returns (uint16) { - mapping(bytes32 => bytes32) storage map = set.map; - bytes32 unwrappedKey = SetValue.unwrap(value); - - return uint16(uint256(map[unwrappedKey]) & 0xFFFC); - } - - /// @notice Check if the flags on a value are enabled. - /// @dev The reserved lower 2 bits will be ignored, as those are reserved for the sentinel and has next bit. - /// @param set The set containing the value. - /// @param value The value to check the flags on. - /// @param flags The flags to check. - /// @return True if all of the flags are enabled, false otherwise. - function flagsEnabled(LinkedListSet storage set, SetValue value, uint16 flags) internal view returns (bool) { - flags &= 0xFFFC; - return getFlags(set, value) & flags == flags; - } - - /// @notice Check if the flags on a value are disabled. - /// @dev The reserved lower 2 bits will be ignored, as those are reserved for the sentinel and has next bit. - /// @param set The set containing the value. - /// @param value The value to check the flags on. - /// @param flags The flags to check. - /// @return True if all of the flags are disabled, false otherwise. - function flagsDisabled(LinkedListSet storage set, SetValue value, uint16 flags) internal view returns (bool) { - flags &= 0xFFFC; - return ~(getFlags(set, value)) & flags == flags; - } - - /// @notice Get all elements in a set. - /// @dev This is an O(n) operation, where n is the number of elements in the set. - /// @param set The set to get the elements of. - /// @return ret An array of all elements in the set. - function getAll(LinkedListSet storage set) internal view returns (SetValue[] memory ret) { - mapping(bytes32 => bytes32) storage map = set.map; - uint256 size; - bytes32 cursor = map[SENTINEL_VALUE]; - - // Dynamically allocate the returned array as we iterate through the set, since we don't know the size - // beforehand. - // This is accomplished by first writing to memory after the free memory pointer, - // then updating the free memory pointer to cover the newly-allocated data. - // To the compiler, writes to memory after the free memory pointer are considered "memory safe". - // See https://docs.soliditylang.org/en/v0.8.22/assembly.html#memory-safety - // Stack variable lifting done when compiling with via-ir will only ever place variables into memory - // locations below the current free memory pointer, so it is safe to compile this library with via-ir. - // See https://docs.soliditylang.org/en/v0.8.22/yul.html#memoryguard - assembly ("memory-safe") { - // It is critical that no other memory allocations occur between: - // - loading the value of the free memory pointer into `ret` - // - updating the free memory pointer to point to the newly-allocated data, which is done after all - // the values have been written. - ret := mload(0x40) - } - - while (!isSentinel(cursor) && cursor != bytes32(0)) { - unchecked { - ++size; - } - bytes32 cleared = clearFlags(cursor); - // Place the item into the return array manually. Since the size was just incremented, it will point to - // the next location to write to. - assembly ("memory-safe") { - mstore(add(ret, mul(size, 0x20)), cleared) - } - if (hasNext(cursor)) { - cursor = map[cleared]; - } else { - cursor = bytes32(0); - } - } - - assembly ("memory-safe") { - // Update the free memory pointer with the now-known length of the array. - mstore(0x40, add(ret, mul(add(size, 1), 0x20))) - // Set the length of the array. - mstore(ret, size) - } - } - - function isSentinel(bytes32 value) internal pure returns (bool ret) { - assembly ("memory-safe") { - ret := and(value, 1) - } - } - - function hasNext(bytes32 value) internal pure returns (bool) { - return value & HAS_NEXT_FLAG != 0; - } - - function clearFlags(bytes32 val) internal pure returns (bytes32) { - return val & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0001; - } - - /// @dev Preserves the lower two bits - function clearUserFlags(bytes32 val) internal pure returns (bytes32) { - return val & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0003; - } - - function getUserFlags(bytes32 val) internal pure returns (bytes32) { - return val & bytes32(uint256(0xFFFC)); - } -} diff --git a/src/libraries/PluginStorageLib.sol b/src/libraries/PluginStorageLib.sol deleted file mode 100644 index 25f952c8..00000000 --- a/src/libraries/PluginStorageLib.sol +++ /dev/null @@ -1,67 +0,0 @@ -// This file is part of Modular Account. -// -// Copyright 2024 Alchemy Insights, Inc. -// -// SPDX-License-Identifier: MIT -// -// See LICENSE-MIT file for more information - -pragma solidity ^0.8.22; - -type StoragePointer is bytes32; - -/// @title Plugin Storage Library -/// @author Alchemy -/// @notice Library for allocating and accessing ERC-4337 address-associated storage within plugins. -library PluginStorageLib { - /// @notice Allocates a memory buffer for an associated storage key, and sets the associated address and batch - /// index. - /// @param addr The address to associate with the storage key. - /// @param batchIndex The batch index to associate with the storage key. - /// @param keySize The size of the key in words, where each word is 32 bytes. Not inclusive of the address and - /// batch index. - /// @return key The allocated memory buffer. - function allocateAssociatedStorageKey(address addr, uint256 batchIndex, uint8 keySize) - internal - pure - returns (bytes memory key) - { - assembly ("memory-safe") { - // Clear any dirty upper bits of keySize to prevent overflow - keySize := and(keySize, 0xff) - - // compute the total size of the buffer, include the address and batch index - let totalSize := add(64, mul(32, keySize)) - - // Allocate memory for the key - key := mload(0x40) - mstore(0x40, add(add(key, totalSize), 32)) - mstore(key, totalSize) - - // Clear any dirty upper bits of address - addr := and(addr, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF) - // Store the address and batch index in the key buffer - mstore(add(key, 32), addr) - mstore(add(key, 64), batchIndex) - } - } - - function associatedStorageLookup(bytes memory key, bytes32 input) internal pure returns (StoragePointer ptr) { - assembly ("memory-safe") { - mstore(add(key, 96), input) - ptr := keccak256(add(key, 32), mload(key)) - } - } - - function associatedStorageLookup(bytes memory key, bytes32 input1, bytes32 input2) - internal - pure - returns (StoragePointer ptr) - { - assembly ("memory-safe") { - mstore(add(key, 96), input1) - mstore(add(key, 128), input2) - ptr := keccak256(add(key, 32), mload(key)) - } - } -} diff --git a/src/plugins/BasePlugin.sol b/src/plugins/BasePlugin.sol index 2d4b44c3..24ca0d0c 100644 --- a/src/plugins/BasePlugin.sol +++ b/src/plugins/BasePlugin.sol @@ -19,8 +19,8 @@ pragma solidity ^0.8.22; import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol"; -import {UserOperation} from "../interfaces/erc4337/UserOperation.sol"; -import {IPlugin, PluginManifest, PluginMetadata} from "../interfaces/IPlugin.sol"; +import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; +import {IPlugin, PluginManifest, PluginMetadata} from "modular-account-libs/interfaces/IPlugin.sol"; /// @title Base contract for plugins /// @dev Implements ERC-165 to support IPlugin's interface, which is a requirement diff --git a/src/plugins/owner/IMultiOwnerPlugin.sol b/src/plugins/owner/IMultiOwnerPlugin.sol index 15427711..f19d95a8 100644 --- a/src/plugins/owner/IMultiOwnerPlugin.sol +++ b/src/plugins/owner/IMultiOwnerPlugin.sol @@ -17,7 +17,7 @@ pragma solidity ^0.8.22; -import {UserOperation} from "../../interfaces/erc4337/UserOperation.sol"; +import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; interface IMultiOwnerPlugin { enum FunctionId { diff --git a/src/plugins/owner/MultiOwnerPlugin.sol b/src/plugins/owner/MultiOwnerPlugin.sol index 5b09240c..3fd92265 100644 --- a/src/plugins/owner/MultiOwnerPlugin.sol +++ b/src/plugins/owner/MultiOwnerPlugin.sol @@ -23,7 +23,7 @@ import {SignatureChecker} from "@openzeppelin/contracts/utils/cryptography/Signa import {UpgradeableModularAccount, UUPSUpgradeable} from "../../account/UpgradeableModularAccount.sol"; import {CastLib} from "../../helpers/CastLib.sol"; -import {UserOperation} from "../../interfaces/erc4337/UserOperation.sol"; +import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; import { ManifestAssociatedFunction, ManifestAssociatedFunctionType, @@ -31,12 +31,15 @@ import { PluginManifest, PluginMetadata, SelectorPermission -} from "../../interfaces/IPlugin.sol"; -import {IStandardExecutor} from "../../interfaces/IStandardExecutor.sol"; +} from "modular-account-libs/interfaces/IPlugin.sol"; +import {IStandardExecutor} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import { - AssociatedLinkedListSet, AssociatedLinkedListSetLib -} from "../../libraries/AssociatedLinkedListSetLib.sol"; -import {SetValue, SIG_VALIDATION_PASSED, SIG_VALIDATION_FAILED} from "../../libraries/Constants.sol"; + AssociatedLinkedListSet, + AssociatedLinkedListSetLib +} from "modular-account-libs/libraries/AssociatedLinkedListSetLib.sol"; +import { + SetValue, SIG_VALIDATION_PASSED, SIG_VALIDATION_FAILED +} from "modular-account-libs/libraries/Constants.sol"; import {BasePlugin} from "../BasePlugin.sol"; import {IMultiOwnerPlugin} from "./IMultiOwnerPlugin.sol"; diff --git a/src/plugins/session/ISessionKeyPlugin.sol b/src/plugins/session/ISessionKeyPlugin.sol index d2a76467..a2cb06bc 100644 --- a/src/plugins/session/ISessionKeyPlugin.sol +++ b/src/plugins/session/ISessionKeyPlugin.sol @@ -17,8 +17,8 @@ pragma solidity ^0.8.22; -import {UserOperation} from "../../interfaces/erc4337/UserOperation.sol"; -import {Call} from "../../interfaces/IStandardExecutor.sol"; +import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; +import {Call} from "modular-account-libs/interfaces/IStandardExecutor.sol"; interface ISessionKeyPlugin { enum FunctionId { diff --git a/src/plugins/session/SessionKeyPlugin.sol b/src/plugins/session/SessionKeyPlugin.sol index 79f6a13d..2ed52af0 100644 --- a/src/plugins/session/SessionKeyPlugin.sol +++ b/src/plugins/session/SessionKeyPlugin.sol @@ -20,8 +20,8 @@ pragma solidity ^0.8.22; import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import {CastLib} from "../../helpers/CastLib.sol"; -import {UserOperation} from "../../interfaces/erc4337/UserOperation.sol"; -import {IPlugin} from "../../interfaces/IPlugin.sol"; +import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; +import {IPlugin} from "modular-account-libs/interfaces/IPlugin.sol"; import { ManifestFunction, ManifestAssociatedFunctionType, @@ -29,16 +29,20 @@ import { PluginManifest, PluginMetadata, SelectorPermission -} from "../../interfaces/IPlugin.sol"; -import {IPluginExecutor} from "../../interfaces/IPluginExecutor.sol"; -import {Call, IStandardExecutor} from "../../interfaces/IStandardExecutor.sol"; +} from "modular-account-libs/interfaces/IPlugin.sol"; +import {IPluginExecutor} from "modular-account-libs/interfaces/IPluginExecutor.sol"; +import {Call, IStandardExecutor} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import { - AssociatedLinkedListSet, AssociatedLinkedListSetLib -} from "../../libraries/AssociatedLinkedListSetLib.sol"; + AssociatedLinkedListSet, + AssociatedLinkedListSetLib +} from "modular-account-libs/libraries/AssociatedLinkedListSetLib.sol"; import { - SetValue, SENTINEL_VALUE, SIG_VALIDATION_PASSED, SIG_VALIDATION_FAILED -} from "../../libraries/Constants.sol"; -import {BasePlugin} from "../BasePlugin.sol"; + SetValue, + SENTINEL_VALUE, + SIG_VALIDATION_PASSED, + SIG_VALIDATION_FAILED +} from "modular-account-libs/libraries/Constants.sol"; +import {BasePlugin} from "modular-account-libs/plugins/BasePlugin.sol"; import {ISessionKeyPlugin} from "./ISessionKeyPlugin.sol"; import {SessionKeyPermissions} from "./permissions/SessionKeyPermissions.sol"; diff --git a/src/plugins/session/permissions/SessionKeyPermissions.sol b/src/plugins/session/permissions/SessionKeyPermissions.sol index 57cd17c8..34c5639a 100644 --- a/src/plugins/session/permissions/SessionKeyPermissions.sol +++ b/src/plugins/session/permissions/SessionKeyPermissions.sol @@ -19,10 +19,10 @@ pragma solidity ^0.8.22; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; -import {UserOperation} from "../../../interfaces/erc4337/UserOperation.sol"; -import {Call} from "../../../interfaces/IStandardExecutor.sol"; -import {IStandardExecutor} from "../../../interfaces/IStandardExecutor.sol"; -import {SIG_VALIDATION_PASSED, SIG_VALIDATION_FAILED} from "../../../libraries/Constants.sol"; +import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; +import {Call} from "modular-account-libs/interfaces/IStandardExecutor.sol"; +import {IStandardExecutor} from "modular-account-libs/interfaces/IStandardExecutor.sol"; +import {SIG_VALIDATION_PASSED, SIG_VALIDATION_FAILED} from "modular-account-libs/libraries/Constants.sol"; import {ISessionKeyPlugin} from "../ISessionKeyPlugin.sol"; import {ISessionKeyPermissionsUpdates} from "./ISessionKeyPermissionsUpdates.sol"; import {SessionKeyPermissionsLoupe} from "./SessionKeyPermissionsLoupe.sol"; diff --git a/src/plugins/session/permissions/SessionKeyPermissionsBase.sol b/src/plugins/session/permissions/SessionKeyPermissionsBase.sol index d19ab92a..4858daf6 100644 --- a/src/plugins/session/permissions/SessionKeyPermissionsBase.sol +++ b/src/plugins/session/permissions/SessionKeyPermissionsBase.sol @@ -17,7 +17,7 @@ pragma solidity ^0.8.22; -import {PluginStorageLib, StoragePointer} from "../../../libraries/PluginStorageLib.sol"; +import {PluginStorageLib, StoragePointer} from "modular-account-libs/libraries/PluginStorageLib.sol"; import {ISessionKeyPlugin} from "../ISessionKeyPlugin.sol"; abstract contract SessionKeyPermissionsBase is ISessionKeyPlugin { diff --git a/test/account/AccountExecHooks.t.sol b/test/account/AccountExecHooks.t.sol index 6843717b..655600e9 100644 --- a/test/account/AccountExecHooks.t.sol +++ b/test/account/AccountExecHooks.t.sol @@ -25,7 +25,7 @@ import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import {PluginManagerInternals} from "../../src/account/PluginManagerInternals.sol"; import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol"; import {MultiOwnerModularAccountFactory} from "../../src/factory/MultiOwnerModularAccountFactory.sol"; -import {FunctionReferenceLib} from "../../src/helpers/FunctionReferenceLib.sol"; +import {FunctionReferenceLib} from "modular-account-libs/libraries/FunctionReferenceLib.sol"; import {IEntryPoint} from "../../src/interfaces/erc4337/IEntryPoint.sol"; import { IPlugin, @@ -34,8 +34,8 @@ import { ManifestFunction, ManifestAssociatedFunctionType, ManifestAssociatedFunction -} from "../../src/interfaces/IPlugin.sol"; -import {FunctionReference} from "../../src/interfaces/IPluginManager.sol"; +} from "modular-account-libs/interfaces/IPlugin.sol"; +import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; import {MultiOwnerPlugin} from "../../src/plugins/owner/MultiOwnerPlugin.sol"; import {MockPlugin} from "../mocks/MockPlugin.sol"; diff --git a/test/account/AccountLoupe.t.sol b/test/account/AccountLoupe.t.sol index bdecc8c9..40d436ac 100644 --- a/test/account/AccountLoupe.t.sol +++ b/test/account/AccountLoupe.t.sol @@ -24,17 +24,17 @@ import {UUPSUpgradeable} from "@openzeppelin/contracts/proxy/utils/UUPSUpgradeab import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol"; import {MultiOwnerModularAccountFactory} from "../../src/factory/MultiOwnerModularAccountFactory.sol"; -import {FunctionReferenceLib} from "../../src/helpers/FunctionReferenceLib.sol"; +import {FunctionReferenceLib} from "modular-account-libs/libraries/FunctionReferenceLib.sol"; import {IEntryPoint} from "../../src/interfaces/erc4337/IEntryPoint.sol"; -import {IAccountLoupe} from "../../src/interfaces/IAccountLoupe.sol"; +import {IAccountLoupe} from "modular-account-libs/interfaces/IAccountLoupe.sol"; import { ManifestAssociatedFunctionType, ManifestExecutionHook, ManifestFunction, PluginManifest -} from "../../src/interfaces/IPlugin.sol"; -import {FunctionReference, IPluginManager} from "../../src/interfaces/IPluginManager.sol"; -import {IStandardExecutor} from "../../src/interfaces/IStandardExecutor.sol"; +} from "modular-account-libs/interfaces/IPlugin.sol"; +import {FunctionReference, IPluginManager} from "modular-account-libs/interfaces/IPluginManager.sol"; +import {IStandardExecutor} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import {IMultiOwnerPlugin} from "../../src/plugins/owner/IMultiOwnerPlugin.sol"; import {MultiOwnerPlugin} from "../../src/plugins/owner/MultiOwnerPlugin.sol"; import {MockPlugin} from "../mocks/MockPlugin.sol"; @@ -185,7 +185,7 @@ contract AccountLoupeTest is Test { _assertHookEq( hooks[1], - FunctionReferenceLib._EMPTY_FUNCTION_REFERENCE, + FunctionReferenceLib.EMPTY_FUNCTION_REFERENCE, FunctionReferenceLib.pack( address(comprehensivePlugin), uint8(ComprehensivePlugin.FunctionId.POST_EXECUTION_HOOK) ) @@ -242,7 +242,7 @@ contract AccountLoupeTest is Test { _assertHookEq( hooks[2], - FunctionReferenceLib._EMPTY_FUNCTION_REFERENCE, + FunctionReferenceLib.EMPTY_FUNCTION_REFERENCE, FunctionReferenceLib.pack( address(comprehensivePlugin), uint8(ComprehensivePlugin.FunctionId.POST_EXECUTION_HOOK) ) @@ -472,7 +472,7 @@ contract AccountLoupeTest is Test { _assertHookEq( hooks[3], FunctionReferenceLib.pack(address(mockPlugin), uint8(0)), - FunctionReferenceLib._EMPTY_FUNCTION_REFERENCE + FunctionReferenceLib.EMPTY_FUNCTION_REFERENCE ); _assertHookEq( @@ -488,13 +488,13 @@ contract AccountLoupeTest is Test { // [null, 2] _assertHookEq( hooks[5], - FunctionReferenceLib._EMPTY_FUNCTION_REFERENCE, + FunctionReferenceLib.EMPTY_FUNCTION_REFERENCE, FunctionReferenceLib.pack(address(mockPlugin), uint8(2)) ); _assertHookEq( hooks[6], - FunctionReferenceLib._EMPTY_FUNCTION_REFERENCE, + FunctionReferenceLib.EMPTY_FUNCTION_REFERENCE, FunctionReferenceLib.pack( address(comprehensivePlugin), uint8(ComprehensivePlugin.FunctionId.POST_EXECUTION_HOOK) ) diff --git a/test/account/AccountPreValidationHooks.t.sol b/test/account/AccountPreValidationHooks.t.sol index d6824247..dcee2207 100644 --- a/test/account/AccountPreValidationHooks.t.sol +++ b/test/account/AccountPreValidationHooks.t.sol @@ -25,17 +25,17 @@ import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import {PluginManagerInternals} from "../../src/account/PluginManagerInternals.sol"; import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol"; import {MultiOwnerModularAccountFactory} from "../../src/factory/MultiOwnerModularAccountFactory.sol"; -import {FunctionReferenceLib} from "../../src/helpers/FunctionReferenceLib.sol"; +import {FunctionReferenceLib} from "modular-account-libs/libraries/FunctionReferenceLib.sol"; import {IEntryPoint} from "../../src/interfaces/erc4337/IEntryPoint.sol"; -import {UserOperation} from "../../src/interfaces/erc4337/UserOperation.sol"; +import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; import { IPlugin, PluginManifest, ManifestFunction, ManifestAssociatedFunctionType, ManifestAssociatedFunction -} from "../../src/interfaces/IPlugin.sol"; -import {FunctionReference} from "../../src/interfaces/IPluginManager.sol"; +} from "modular-account-libs/interfaces/IPlugin.sol"; +import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; import {IMultiOwnerPlugin} from "../../src/plugins/owner/IMultiOwnerPlugin.sol"; import {MultiOwnerPlugin} from "../../src/plugins/owner/MultiOwnerPlugin.sol"; import {MockPlugin} from "../mocks/MockPlugin.sol"; diff --git a/test/account/AccountReturnData.t.sol b/test/account/AccountReturnData.t.sol index d1f0c03a..39ad6a29 100644 --- a/test/account/AccountReturnData.t.sol +++ b/test/account/AccountReturnData.t.sol @@ -24,8 +24,8 @@ import {EntryPoint} from "@eth-infinitism/account-abstraction/core/EntryPoint.so import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol"; import {MultiOwnerModularAccountFactory} from "../../src/factory/MultiOwnerModularAccountFactory.sol"; import {IEntryPoint} from "../../src/interfaces/erc4337/IEntryPoint.sol"; -import {FunctionReference} from "../../src/interfaces/IPluginManager.sol"; -import {Call} from "../../src/interfaces/IStandardExecutor.sol"; +import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; +import {Call} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import {MultiOwnerPlugin} from "../../src/plugins/owner/MultiOwnerPlugin.sol"; import { RegularResultContract, diff --git a/test/account/ExecuteFromPluginPermissions.t.sol b/test/account/ExecuteFromPluginPermissions.t.sol index 5f91aede..c71ab72b 100644 --- a/test/account/ExecuteFromPluginPermissions.t.sol +++ b/test/account/ExecuteFromPluginPermissions.t.sol @@ -24,8 +24,8 @@ import {EntryPoint} from "@eth-infinitism/account-abstraction/core/EntryPoint.so import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol"; import {MultiOwnerModularAccountFactory} from "../../src/factory/MultiOwnerModularAccountFactory.sol"; import {IEntryPoint} from "../../src/interfaces/erc4337/IEntryPoint.sol"; -import {IPlugin} from "../../src/interfaces/IPlugin.sol"; -import {FunctionReference} from "../../src/interfaces/IPluginManager.sol"; +import {IPlugin} from "modular-account-libs/interfaces/IPlugin.sol"; +import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; import {MultiOwnerPlugin} from "../../src/plugins/owner/MultiOwnerPlugin.sol"; import {Counter} from "../mocks/Counter.sol"; import { diff --git a/test/account/ManifestValidity.t.sol b/test/account/ManifestValidity.t.sol index 780e215f..2b4e0580 100644 --- a/test/account/ManifestValidity.t.sol +++ b/test/account/ManifestValidity.t.sol @@ -25,7 +25,7 @@ import {PluginManagerInternals} from "../../src/account/PluginManagerInternals.s import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol"; import {MultiOwnerModularAccountFactory} from "../../src/factory/MultiOwnerModularAccountFactory.sol"; import {IEntryPoint} from "../../src/interfaces/erc4337/IEntryPoint.sol"; -import {FunctionReference} from "../../src/interfaces/IPluginManager.sol"; +import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; import {MultiOwnerPlugin} from "../../src/plugins/owner/MultiOwnerPlugin.sol"; import { BadValidationMagicValue_UserOp_Plugin, diff --git a/test/account/TokenReceiver.t.sol b/test/account/TokenReceiver.t.sol index bd6b468b..4e84f4ac 100644 --- a/test/account/TokenReceiver.t.sol +++ b/test/account/TokenReceiver.t.sol @@ -35,8 +35,8 @@ import { ManifestAssociatedFunctionType, ManifestFunction, PluginManifest -} from "../../src/interfaces/IPlugin.sol"; -import {FunctionReference} from "../../src/interfaces/IPluginManager.sol"; +} from "modular-account-libs/interfaces/IPlugin.sol"; +import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; import {MultiOwnerPlugin} from "../../src/plugins/owner/MultiOwnerPlugin.sol"; import {MockPlugin} from "../mocks/MockPlugin.sol"; import {MockERC1155} from "../mocks/tokens/MockERC1155.sol"; diff --git a/test/account/UpgradeableModularAccount.t.sol b/test/account/UpgradeableModularAccount.t.sol index bddf368d..2c13fc44 100644 --- a/test/account/UpgradeableModularAccount.t.sol +++ b/test/account/UpgradeableModularAccount.t.sol @@ -28,11 +28,11 @@ import {PluginManagerInternals} from "../../src/account/PluginManagerInternals.s import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol"; import {MultiOwnerModularAccountFactory} from "../../src/factory/MultiOwnerModularAccountFactory.sol"; import {IEntryPoint} from "../../src/interfaces/erc4337/IEntryPoint.sol"; -import {UserOperation} from "../../src/interfaces/erc4337/UserOperation.sol"; +import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; import {IAccountInitializable} from "../../src/interfaces/IAccountInitializable.sol"; -import {IPlugin, PluginManifest} from "../../src/interfaces/IPlugin.sol"; -import {FunctionReference, IPluginManager} from "../../src/interfaces/IPluginManager.sol"; -import {Call} from "../../src/interfaces/IStandardExecutor.sol"; +import {IPlugin, PluginManifest} from "modular-account-libs/interfaces/IPlugin.sol"; +import {FunctionReference, IPluginManager} from "modular-account-libs/interfaces/IPluginManager.sol"; +import {Call} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import {IMultiOwnerPlugin} from "../../src/plugins/owner/IMultiOwnerPlugin.sol"; import {MultiOwnerPlugin} from "../../src/plugins/owner/MultiOwnerPlugin.sol"; import {SessionKeyPlugin} from "../../src/plugins/session/SessionKeyPlugin.sol"; diff --git a/test/account/UpgradeableModularAccountPluginManager.t.sol b/test/account/UpgradeableModularAccountPluginManager.t.sol index 757bb039..05ad6d67 100644 --- a/test/account/UpgradeableModularAccountPluginManager.t.sol +++ b/test/account/UpgradeableModularAccountPluginManager.t.sol @@ -26,14 +26,14 @@ import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import {PluginManagerInternals} from "../../src/account/PluginManagerInternals.sol"; import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol"; import {MultiOwnerModularAccountFactory} from "../../src/factory/MultiOwnerModularAccountFactory.sol"; -import {FunctionReferenceLib} from "../../src/helpers/FunctionReferenceLib.sol"; +import {FunctionReferenceLib} from "modular-account-libs/libraries/FunctionReferenceLib.sol"; import {IEntryPoint} from "../../src/interfaces/erc4337/IEntryPoint.sol"; -import {IAccountLoupe} from "../../src/interfaces/IAccountLoupe.sol"; -import {PluginManifest} from "../../src/interfaces/IPlugin.sol"; -import {IPlugin, PluginManifest} from "../../src/interfaces/IPlugin.sol"; -import {FunctionReference, IPluginManager} from "../../src/interfaces/IPluginManager.sol"; -import {IStandardExecutor} from "../../src/interfaces/IStandardExecutor.sol"; -import {Call} from "../../src/interfaces/IStandardExecutor.sol"; +import {IAccountLoupe} from "modular-account-libs/interfaces/IAccountLoupe.sol"; +import {PluginManifest} from "modular-account-libs/interfaces/IPlugin.sol"; +import {IPlugin, PluginManifest} from "modular-account-libs/interfaces/IPlugin.sol"; +import {FunctionReference, IPluginManager} from "modular-account-libs/interfaces/IPluginManager.sol"; +import {IStandardExecutor} from "modular-account-libs/interfaces/IStandardExecutor.sol"; +import {Call} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import {IMultiOwnerPlugin} from "../../src/plugins/owner/IMultiOwnerPlugin.sol"; import {MultiOwnerPlugin} from "../../src/plugins/owner/MultiOwnerPlugin.sol"; import {SessionKeyPlugin} from "../../src/plugins/session/SessionKeyPlugin.sol"; diff --git a/test/account/ValidationIntersection.t.sol b/test/account/ValidationIntersection.t.sol index ec062a10..8467fe6c 100644 --- a/test/account/ValidationIntersection.t.sol +++ b/test/account/ValidationIntersection.t.sol @@ -24,9 +24,9 @@ import {EntryPoint} from "@eth-infinitism/account-abstraction/core/EntryPoint.so import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol"; import {MultiOwnerModularAccountFactory} from "../../src/factory/MultiOwnerModularAccountFactory.sol"; import {IEntryPoint} from "../../src/interfaces/erc4337/IEntryPoint.sol"; -import {UserOperation} from "../../src/interfaces/erc4337/UserOperation.sol"; -import {FunctionReference} from "../../src/interfaces/IPluginManager.sol"; -import {SIG_VALIDATION_FAILED, SIG_VALIDATION_PASSED} from "../../src/libraries/Constants.sol"; +import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; +import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; +import {SIG_VALIDATION_FAILED, SIG_VALIDATION_PASSED} from "modular-account-libs/libraries/Constants.sol"; import {MultiOwnerPlugin} from "../../src/plugins/owner/MultiOwnerPlugin.sol"; import { MockBaseUserOpValidationPlugin, diff --git a/test/account/phases/AccountStatePhases.t.sol b/test/account/phases/AccountStatePhases.t.sol index 7d5d3106..08a226dc 100644 --- a/test/account/phases/AccountStatePhases.t.sol +++ b/test/account/phases/AccountStatePhases.t.sol @@ -24,9 +24,9 @@ import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import {UpgradeableModularAccount} from "../../../src/account/UpgradeableModularAccount.sol"; import {MultiOwnerModularAccountFactory} from "../../../src/factory/MultiOwnerModularAccountFactory.sol"; -import {FunctionReferenceLib} from "../../../src/helpers/FunctionReferenceLib.sol"; +import {FunctionReferenceLib} from "modular-account-libs/libraries/FunctionReferenceLib.sol"; import {IEntryPoint} from "../../../src/interfaces/erc4337/IEntryPoint.sol"; -import {UserOperation} from "../../../src/interfaces/erc4337/UserOperation.sol"; +import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; import { IPlugin, ManifestExecutionHook, @@ -34,9 +34,9 @@ import { ManifestFunction, ManifestAssociatedFunctionType, ManifestAssociatedFunction -} from "../../../src/interfaces/IPlugin.sol"; -import {FunctionReference, IPluginManager} from "../../../src/interfaces/IPluginManager.sol"; -import {IStandardExecutor, Call} from "../../../src/interfaces/IStandardExecutor.sol"; +} from "modular-account-libs/interfaces/IPlugin.sol"; +import {FunctionReference, IPluginManager} from "modular-account-libs/interfaces/IPluginManager.sol"; +import {IStandardExecutor, Call} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import {MultiOwnerPlugin} from "../../../src/plugins/owner/MultiOwnerPlugin.sol"; import {MockPlugin} from "../../mocks/MockPlugin.sol"; import {AccountStateMutatingPlugin} from "../../mocks/plugins/AccountStateMutatingPlugin.sol"; diff --git a/test/account/phases/AccountStatePhasesExec.t.sol b/test/account/phases/AccountStatePhasesExec.t.sol index 266da386..1ea13323 100644 --- a/test/account/phases/AccountStatePhasesExec.t.sol +++ b/test/account/phases/AccountStatePhasesExec.t.sol @@ -24,9 +24,9 @@ import { ManifestAssociatedFunction, ManifestAssociatedFunctionType, ManifestFunction -} from "../../../src/interfaces/IPlugin.sol"; -import {IPluginManager} from "../../../src/interfaces/IPluginManager.sol"; -import {IStandardExecutor, Call} from "../../../src/interfaces/IStandardExecutor.sol"; +} from "modular-account-libs/interfaces/IPlugin.sol"; +import {IPluginManager} from "modular-account-libs/interfaces/IPluginManager.sol"; +import {IStandardExecutor, Call} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import {MockPlugin} from "../../mocks/MockPlugin.sol"; import {AccountStateMutatingPlugin} from "../../mocks/plugins/AccountStateMutatingPlugin.sol"; import {AccountStatePhasesTest} from "./AccountStatePhases.t.sol"; diff --git a/test/account/phases/AccountStatePhasesRTValidation.t.sol b/test/account/phases/AccountStatePhasesRTValidation.t.sol index a49a1e81..72d8d127 100644 --- a/test/account/phases/AccountStatePhasesRTValidation.t.sol +++ b/test/account/phases/AccountStatePhasesRTValidation.t.sol @@ -18,9 +18,9 @@ pragma solidity ^0.8.22; import {UpgradeableModularAccount} from "../../../src/account/UpgradeableModularAccount.sol"; -import {IPlugin} from "../../../src/interfaces/IPlugin.sol"; -import {IPluginManager} from "../../../src/interfaces/IPluginManager.sol"; -import {IStandardExecutor, Call} from "../../../src/interfaces/IStandardExecutor.sol"; +import {IPlugin} from "modular-account-libs/interfaces/IPlugin.sol"; +import {IPluginManager} from "modular-account-libs/interfaces/IPluginManager.sol"; +import {IStandardExecutor, Call} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import {AccountStateMutatingPlugin} from "../../mocks/plugins/AccountStateMutatingPlugin.sol"; import {AccountStatePhasesTest} from "./AccountStatePhases.t.sol"; diff --git a/test/account/phases/AccountStatePhasesUOValidation.t.sol b/test/account/phases/AccountStatePhasesUOValidation.t.sol index ac56bf14..80584142 100644 --- a/test/account/phases/AccountStatePhasesUOValidation.t.sol +++ b/test/account/phases/AccountStatePhasesUOValidation.t.sol @@ -19,9 +19,9 @@ pragma solidity ^0.8.22; import {AccountStatePhasesTest} from "./AccountStatePhases.t.sol"; -import {IPluginManager} from "../../../src/interfaces/IPluginManager.sol"; -import {IPlugin} from "../../../src/interfaces/IPlugin.sol"; -import {IStandardExecutor, Call} from "../../../src/interfaces/IStandardExecutor.sol"; +import {IPluginManager} from "modular-account-libs/interfaces/IPluginManager.sol"; +import {IPlugin} from "modular-account-libs/interfaces/IPlugin.sol"; +import {IStandardExecutor, Call} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import {AccountStateMutatingPlugin} from "../../mocks/plugins/AccountStateMutatingPlugin.sol"; diff --git a/test/comparison/CompareSimpleAccount.t.sol b/test/comparison/CompareSimpleAccount.t.sol index 57de6d3a..36c0d91c 100644 --- a/test/comparison/CompareSimpleAccount.t.sol +++ b/test/comparison/CompareSimpleAccount.t.sol @@ -25,7 +25,7 @@ import {SimpleAccountFactory} from "@eth-infinitism/account-abstraction/samples/ import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import {IEntryPoint} from "../../src/interfaces/erc4337/IEntryPoint.sol"; -import {UserOperation} from "../../src/interfaces/erc4337/UserOperation.sol"; +import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; import {Counter} from "../mocks/Counter.sol"; contract CompareSimpleAccountTest is Test { diff --git a/test/helpers/FunctionReferenceLib.t.sol b/test/helpers/FunctionReferenceLib.t.sol deleted file mode 100644 index 31cff6be..00000000 --- a/test/helpers/FunctionReferenceLib.t.sol +++ /dev/null @@ -1,56 +0,0 @@ -// This file is part of Modular Account. -// -// Copyright 2024 Alchemy Insights, Inc. -// -// SPDX-License-Identifier: GPL-3.0-or-later -// -// This program is free software: you can redistribute it and/or modify it under the terms of the GNU General -// Public License as published by the Free Software Foundation, either version 3 of the License, or (at your -// option) any later version. -// -// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the -// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -// more details. -// -// You should have received a copy of the GNU General Public License along with this program. If not, see -// . - -pragma solidity ^0.8.22; - -import {Test} from "forge-std/Test.sol"; - -import {FunctionReferenceLib} from "../../src/helpers/FunctionReferenceLib.sol"; -import {FunctionReference} from "../../src/interfaces/IPluginManager.sol"; - -contract FunctionReferenceLibTest is Test { - using FunctionReferenceLib for FunctionReference; - - function testFuzz_functionReference_packing(address addr, uint8 functionId) public { - // console.log("addr: ", addr); - // console.log("functionId: ", vm.toString(functionId)); - FunctionReference fr = FunctionReferenceLib.pack(addr, functionId); - // console.log("packed: ", vm.toString(FunctionReference.unwrap(fr))); - (address addr2, uint8 functionId2) = FunctionReferenceLib.unpack(fr); - // console.log("addr2: ", addr2); - // console.log("functionId2: ", vm.toString(functionId2)); - assertEq(addr, addr2); - assertEq(functionId, functionId2); - } - - function testFuzz_functionReference_operators(FunctionReference a, FunctionReference b) public { - assertTrue(a.eq(a)); - assertTrue(b.eq(b)); - - if (FunctionReference.unwrap(a) == FunctionReference.unwrap(b)) { - assertTrue(a.eq(b)); - assertTrue(b.eq(a)); - assertFalse(a.notEq(b)); - assertFalse(b.notEq(a)); - } else { - assertTrue(a.notEq(b)); - assertTrue(b.notEq(a)); - assertFalse(a.eq(b)); - assertFalse(b.eq(a)); - } - } -} diff --git a/test/helpers/KnownSelectors.t.sol b/test/helpers/KnownSelectors.t.sol index 78e513f4..637cc179 100644 --- a/test/helpers/KnownSelectors.t.sol +++ b/test/helpers/KnownSelectors.t.sol @@ -30,11 +30,11 @@ import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import {KnownSelectors} from "../../src/helpers/KnownSelectors.sol"; import {IAccountInitializable} from "../../src/interfaces/IAccountInitializable.sol"; -import {IAccountLoupe} from "../../src/interfaces/IAccountLoupe.sol"; -import {IPlugin} from "../../src/interfaces/IPlugin.sol"; -import {IPluginExecutor} from "../../src/interfaces/IPluginExecutor.sol"; -import {IPluginManager} from "../../src/interfaces/IPluginManager.sol"; -import {IStandardExecutor} from "../../src/interfaces/IStandardExecutor.sol"; +import {IAccountLoupe} from "modular-account-libs/interfaces/IAccountLoupe.sol"; +import {IPlugin} from "modular-account-libs/interfaces/IPlugin.sol"; +import {IPluginExecutor} from "modular-account-libs/interfaces/IPluginExecutor.sol"; +import {IPluginManager} from "modular-account-libs/interfaces/IPluginManager.sol"; +import {IStandardExecutor} from "modular-account-libs/interfaces/IStandardExecutor.sol"; contract KnownSelectorsTest is Test { function test_isNativeFunction() public { diff --git a/test/invariant/AssociatedLinkedListSetLibInvariants.t.sol b/test/invariant/AssociatedLinkedListSetLibInvariants.t.sol deleted file mode 100644 index a0282c83..00000000 --- a/test/invariant/AssociatedLinkedListSetLibInvariants.t.sol +++ /dev/null @@ -1,122 +0,0 @@ -// This file is part of Modular Account. -// -// Copyright 2024 Alchemy Insights, Inc. -// -// SPDX-License-Identifier: GPL-3.0-or-later -// -// This program is free software: you can redistribute it and/or modify it under the terms of the GNU General -// Public License as published by the Free Software Foundation, either version 3 of the License, or (at your -// option) any later version. -// -// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the -// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -// more details. -// -// You should have received a copy of the GNU General Public License along with this program. If not, see -// . - -pragma solidity ^0.8.22; - -import {Test} from "forge-std/Test.sol"; - -import {AssociatedLinkedListSetHandler} from "./handlers/AssociatedLinkedListSetHandler.sol"; - -contract AssociatedLinkedListSetLibInvariantsTest is Test { - AssociatedLinkedListSetHandler public handler; - - // Only use these constants for testing. Enforces uniqueness across ID and associated address, - // Without reducing invariant call depth too much. - address public constant ASSOCIATED_1 = address(uint160(bytes20(keccak256("ASSOCIATED_1")))); - address public constant ASSOCIATED_2 = address(uint160(bytes20(keccak256("ASSOCIATED_2")))); - uint64 public constant ID_1 = 42; - uint64 public constant ID_2 = 115557777; - - function setUp() public { - handler = new AssociatedLinkedListSetHandler(); - - bytes4[] memory selectors = new bytes4[](8); - selectors[0] = handler.add.selector; - selectors[1] = handler.removeIterate.selector; - selectors[2] = handler.removeRandKeyIterate.selector; - selectors[3] = handler.clear.selector; - selectors[4] = handler.removeKnownPrevKey.selector; - selectors[5] = handler.removeRandKnownPrevKey.selector; - selectors[6] = handler.addFlagKnown.selector; - selectors[7] = handler.addFlagRandom.selector; - - targetSelector(FuzzSelector({addr: address(handler), selectors: selectors})); - } - - function invariant_shouldContain() public { - _shouldContain(ASSOCIATED_1, ID_1); - _shouldContain(ASSOCIATED_1, ID_2); - _shouldContain(ASSOCIATED_2, ID_1); - _shouldContain(ASSOCIATED_2, ID_2); - } - - // Doesn't test for no duplicates yet - function invariant_getAllEquivalence() public { - _getAllEquivalence(ASSOCIATED_1, ID_1); - _getAllEquivalence(ASSOCIATED_1, ID_2); - _getAllEquivalence(ASSOCIATED_2, ID_1); - _getAllEquivalence(ASSOCIATED_2, ID_2); - } - - function invariant_flagValidity() public { - _flagValidityCheck(ASSOCIATED_1, ID_1); - _flagValidityCheck(ASSOCIATED_1, ID_2); - _flagValidityCheck(ASSOCIATED_2, ID_1); - _flagValidityCheck(ASSOCIATED_2, ID_2); - } - - function _shouldContain(address associated, uint64 id) internal { - bytes32[] memory vals = handler.referenceEnumerate(associated, id); - - if (vals.length == 0) { - assertTrue(handler.referenceIsEmpty(associated, id)); - assertTrue(handler.associatedIsEmpty(associated, id)); - } else { - assertFalse(handler.referenceIsEmpty(associated, id)); - assertFalse(handler.associatedIsEmpty(associated, id)); - for (uint256 i = 0; i < vals.length; i++) { - bytes30 val = bytes30(vals[i]); - assertTrue(handler.associatedContains(associated, id, val)); - assertTrue(handler.referenceContains(associated, id, val)); - } - } - } - - function _flagValidityCheck(address associated, uint64 id) internal { - (bytes32[] memory keys, uint16[] memory metaFlags) = handler.referenceGetFlags(associated, id); - - for (uint256 i = 0; i < keys.length; i++) { - bytes30 key = bytes30(keys[i]); - uint16 metaFlag = metaFlags[i]; - assertEq(handler.associatedGetFlags(associated, id, key), metaFlag); - } - } - - function _getAllEquivalence(address associated, uint64 id) internal { - bytes32[] memory referenceEnumerate = handler.referenceEnumerate(associated, id); - bytes32[] memory associatedEnumerate = handler.associatedEnumerate(associated, id); - - assertTrue(referenceEnumerate.length == associatedEnumerate.length); - - for (uint256 i = 0; i < referenceEnumerate.length; i++) { - assertTrue(_contains(associatedEnumerate, referenceEnumerate[i])); - } - - for (uint256 i = 0; i < associatedEnumerate.length; i++) { - assertTrue(_contains(referenceEnumerate, associatedEnumerate[i])); - } - } - - function _contains(bytes32[] memory arr, bytes32 val) internal pure returns (bool) { - for (uint256 i = 0; i < arr.length; i++) { - if (arr[i] == val) { - return true; - } - } - return false; - } -} diff --git a/test/invariant/LLSLRepro.t.sol b/test/invariant/LLSLRepro.t.sol index cb7aecbd..f67d9383 100644 --- a/test/invariant/LLSLRepro.t.sol +++ b/test/invariant/LLSLRepro.t.sol @@ -19,8 +19,10 @@ pragma solidity ^0.8.22; import {Test} from "forge-std/Test.sol"; -import {AssociatedLinkedListSetHandler} from "./handlers/AssociatedLinkedListSetHandler.sol"; -import {LinkedListSetHandler} from "./handlers/LinkedListSetHandler.sol"; +import {AssociatedLinkedListSetHandler} from + "node_modules/modular-account-libs/test/invariant/handlers/AssociatedLinkedListSetHandler.sol"; +import {LinkedListSetHandler} from + "node_modules/modular-account-libs/test/invariant/handlers/LinkedListSetHandler.sol"; contract LLSLReproTest is Test { LinkedListSetHandler public handler; diff --git a/test/invariant/LinkedListSetLibInvariants.t.sol b/test/invariant/LinkedListSetLibInvariants.t.sol deleted file mode 100644 index c8f612ef..00000000 --- a/test/invariant/LinkedListSetLibInvariants.t.sol +++ /dev/null @@ -1,94 +0,0 @@ -// This file is part of Modular Account. -// -// Copyright 2024 Alchemy Insights, Inc. -// -// SPDX-License-Identifier: GPL-3.0-or-later -// -// This program is free software: you can redistribute it and/or modify it under the terms of the GNU General -// Public License as published by the Free Software Foundation, either version 3 of the License, or (at your -// option) any later version. -// -// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the -// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -// more details. -// -// You should have received a copy of the GNU General Public License along with this program. If not, see -// . - -pragma solidity ^0.8.22; - -import {Test} from "forge-std/Test.sol"; - -import {LinkedListSetHandler} from "./handlers/LinkedListSetHandler.sol"; - -contract LinkedListSetLibInvariantsTest is Test { - LinkedListSetHandler public handler; - - function setUp() public { - handler = new LinkedListSetHandler(); - - bytes4[] memory selectors = new bytes4[](8); - selectors[0] = handler.add.selector; - selectors[1] = handler.removeIterate.selector; - selectors[2] = handler.removeRandKeyIterate.selector; - selectors[3] = handler.clear.selector; - selectors[4] = handler.removeKnownPrevKey.selector; - selectors[5] = handler.removeRandKnownPrevKey.selector; - selectors[6] = handler.addFlagKnown.selector; - selectors[7] = handler.addFlagRandom.selector; - - targetSelector(FuzzSelector({addr: address(handler), selectors: selectors})); - } - - function invariant_shouldContain() public { - bytes32[] memory vals = handler.referenceEnumerate(); - - if (vals.length == 0) { - assertTrue(handler.referenceIsEmpty()); - assertTrue(handler.libIsEmpty()); - } else { - assertFalse(handler.referenceIsEmpty()); - assertFalse(handler.libIsEmpty()); - for (uint256 i = 0; i < vals.length; i++) { - bytes30 val = bytes30(vals[i]); - assertTrue(handler.libContains(val)); - assertTrue(handler.referenceContains(val)); - } - } - } - - // Doesn't test for no duplicates yet - function invariant_getAllEquivalence() public { - bytes32[] memory referenceEnumerate = handler.referenceEnumerate(); - bytes32[] memory libEnumerate = handler.libEnumerate(); - - assertTrue(referenceEnumerate.length == libEnumerate.length); - - for (uint256 i = 0; i < referenceEnumerate.length; i++) { - assertTrue(_contains(libEnumerate, referenceEnumerate[i])); - } - - for (uint256 i = 0; i < libEnumerate.length; i++) { - assertTrue(_contains(referenceEnumerate, libEnumerate[i])); - } - } - - function invariant_flagValidity() public { - (bytes32[] memory keys, uint16[] memory metaFlags) = handler.referenceGetFlags(); - - for (uint256 i = 0; i < keys.length; i++) { - bytes30 key = bytes30(keys[i]); - uint16 metaFlag = metaFlags[i]; - assertEq(handler.libGetFlags(key), metaFlag); - } - } - - function _contains(bytes32[] memory arr, bytes32 val) internal pure returns (bool) { - for (uint256 i = 0; i < arr.length; i++) { - if (arr[i] == val) { - return true; - } - } - return false; - } -} diff --git a/test/invariant/handlers/AssociatedLinkedListSetHandler.sol b/test/invariant/handlers/AssociatedLinkedListSetHandler.sol deleted file mode 100644 index 7e037c7b..00000000 --- a/test/invariant/handlers/AssociatedLinkedListSetHandler.sol +++ /dev/null @@ -1,431 +0,0 @@ -// This file is part of Modular Account. -// -// Copyright 2024 Alchemy Insights, Inc. -// -// SPDX-License-Identifier: GPL-3.0-or-later -// -// This program is free software: you can redistribute it and/or modify it under the terms of the GNU General -// Public License as published by the Free Software Foundation, either version 3 of the License, or (at your -// option) any later version. -// -// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the -// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -// more details. -// -// You should have received a copy of the GNU General Public License along with this program. If not, see -// . - -pragma solidity ^0.8.22; - -import {CommonBase} from "forge-std/Base.sol"; -import {StdCheats} from "forge-std/StdCheats.sol"; -import {StdUtils} from "forge-std/StdUtils.sol"; - -import {EnumerableMap} from "@openzeppelin/contracts/utils/structs/EnumerableMap.sol"; -import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; - -import { - AssociatedLinkedListSet, - AssociatedLinkedListSetLib -} from "../../../src/libraries/AssociatedLinkedListSetLib.sol"; -import {SetValue} from "../../../src/libraries/Constants.sol"; - -/// @notice A handler contract for differential invariant testing AssociatedLinkedListSetLib -/// This contract maps logic for adding, removeing, clearing, and inspecting a list -/// to a reference implementation using EnumerableSet.Bytes32Set, which the invariant -/// fuzzer can then use to test the library. -contract AssociatedLinkedListSetHandler is CommonBase, StdCheats, StdUtils { - using AssociatedLinkedListSetLib for AssociatedLinkedListSet; - using EnumerableSet for EnumerableSet.Bytes32Set; - using EnumerableMap for EnumerableMap.Bytes32ToUintMap; - - mapping(address => mapping(uint64 => EnumerableSet.Bytes32Set)) internal _referenceSets; - mapping(address => mapping(uint64 => EnumerableMap.Bytes32ToUintMap)) internal _referenceMeta; - - error FailedToAdd(bytes30 value); - error FailedToAddFlags(uint16 value); - error FailedToGetFlags(uint16 expected, uint16 actual); - error BadAddFlags(bytes30 value, uint16 flags); - error FailedToRemove(bytes30 value); - error ShouldNotRemove(bytes30 value); - error ContainsNotExpected(bytes30 value); - error DoesNotContain(bytes30 value); - error LengthMismatch(uint256 expected, uint256 actual); - - address public constant ASSOCIATED_1 = address(uint160(bytes20(keccak256("ASSOCIATED_1")))); - address public constant ASSOCIATED_2 = address(uint160(bytes20(keccak256("ASSOCIATED_2")))); - - AssociatedLinkedListSet public set1; - AssociatedLinkedListSet public set2; - - uint64 public constant ID_1 = 42; - uint64 public constant ID_2 = 115557777; - - bytes32 internal constant SENTINEL_VALUE = bytes32(uint256(1)); - - constructor() {} - - /// @notice Adds to both copies of the list - the associated one and the reference one - function add(bytes30 val, uint256 seedAddr, uint256 seedId) external { - AssociatedLinkedListSet storage associatedSet = seedId % 2 == 0 ? set1 : set2; - uint64 id = uint64(seedId % 2 == 0 ? ID_1 : ID_2); - address associated = address(seedAddr % 2 == 0 ? ASSOCIATED_1 : ASSOCIATED_2); - - EnumerableSet.Bytes32Set storage referenceSet = _referenceSets[associated][id]; - if (referenceSet.contains(bytes32(val)) || val == bytes30(0)) { - return; // Silently do nothing - } - - referenceSet.add(bytes32(val)); - - bool success = associatedSet.tryAdd(associated, SetValue.wrap(val)); - if (!success) { - revert FailedToAdd(val); - } - } - - /// @notice Removes a key from both sets by its index in the reference implementation. - /// Uses the O(n) iterating remove method. - function removeIterate(uint256 indexToRemove, uint256 seedAddr, uint256 seedId) external { - AssociatedLinkedListSet storage associatedSet = seedId % 2 == 0 ? set1 : set2; - uint64 id = uint64(seedId % 2 == 0 ? ID_1 : ID_2); - address associated = address(seedAddr % 2 == 0 ? ASSOCIATED_1 : ASSOCIATED_2); - EnumerableSet.Bytes32Set storage referenceSet = _referenceSets[associated][id]; - EnumerableMap.Bytes32ToUintMap storage referenceMeta = _referenceMeta[associated][id]; - - if (referenceSet.length() == 0) { - return; // Silently do nothing - } - - indexToRemove = bound(indexToRemove, 0, referenceSet.length() - 1); - - bytes30 value = bytes30(referenceSet.at(indexToRemove)); - - referenceSet.remove(bytes32(value)); - - // Remove the meta entry if it exists - referenceMeta.remove(bytes32(value)); - - if (!associatedSet.tryRemove(associated, SetValue.wrap(value))) { - revert FailedToRemove(value); - } - - if (associatedSet.contains(associated, SetValue.wrap(value))) { - revert ContainsNotExpected(value); - } - } - - /// @notice Removes a key from both sets by its index in the reference implementation. - /// Accepts an arbitrary value to attempt to remove that may or may not be in the list. - /// Uses the O(n) iterating remove method. - function removeRandKeyIterate(bytes30 val, uint256 seedAddr, uint256 seedId) external { - AssociatedLinkedListSet storage associatedSet = seedId % 2 == 0 ? set1 : set2; - uint64 id = uint64(seedId % 2 == 0 ? ID_1 : ID_2); - address associated = address(seedAddr % 2 == 0 ? ASSOCIATED_1 : ASSOCIATED_2); - - EnumerableSet.Bytes32Set storage referenceSet = _referenceSets[associated][id]; - EnumerableMap.Bytes32ToUintMap storage referenceMeta = _referenceMeta[associated][id]; - - if (!referenceSet.contains(bytes32(val))) { - if (associatedSet.contains(associated, SetValue.wrap(val))) { - revert ContainsNotExpected(val); - } - if (associatedSet.tryRemove(associated, SetValue.wrap(val))) { - revert ShouldNotRemove(val); - } - if (associatedSet.contains(associated, SetValue.wrap(val))) { - revert ContainsNotExpected(val); - } - return; // short-circuit after making assertions. - } - - referenceSet.remove(bytes32(val)); - - // Remove the meta entry if it exists - referenceMeta.remove(bytes32(val)); - - if (!associatedSet.tryRemove(associated, SetValue.wrap(val))) { - revert FailedToRemove(val); - } - - if (associatedSet.contains(associated, SetValue.wrap(val))) { - revert ContainsNotExpected(val); - } - } - - /// @notice Removes a key by looking up it's predecessor via getAll before submitting the call - /// Uses the O(1) remove method that has knowledge of the previous key. - function removeKnownPrevKey(uint256 index, uint256 seedAddr, uint256 seedId) external { - AssociatedLinkedListSet storage associatedSet = seedId % 2 == 0 ? set1 : set2; - uint64 id = uint64(seedId % 2 == 0 ? ID_1 : ID_2); - address associated = address(seedAddr % 2 == 0 ? ASSOCIATED_1 : ASSOCIATED_2); - - EnumerableSet.Bytes32Set storage referenceSet = _referenceSets[associated][id]; - EnumerableMap.Bytes32ToUintMap storage referenceMeta = _referenceMeta[associated][id]; - - if (referenceSet.length() == 0) { - return; // Silently do nothing - } - - index = bound(index, 0, referenceSet.length() - 1); - - bytes30 value = bytes30(referenceSet.at(index)); - - referenceSet.remove(bytes32(value)); - - // Remove the meta entry if it exists - referenceMeta.remove(bytes32(value)); - - // Get the previous entry via getAll - SetValue[] memory values = associatedSet.getAll(associated); - if (values.length == 0) { - revert LengthMismatch(0, values.length); - } - - bytes32 prev; - for (uint256 i = 0; i < values.length; i++) { - if (SetValue.unwrap(values[i]) == bytes30(value)) { - if (i == 0) { - prev = SENTINEL_VALUE; - } else { - prev = bytes32(SetValue.unwrap(values[i - 1])); - } - break; - } - } - - if (prev == bytes32(0)) { - revert DoesNotContain(value); - } - - if (!associatedSet.tryRemoveKnown(associated, SetValue.wrap(value), prev)) { - revert FailedToRemove(value); - } - - if (associatedSet.contains(associated, SetValue.wrap(value))) { - revert ContainsNotExpected(value); - } - } - - /// @notice Removes a key using the O(1) remove method that has knowledge of the previous key. - /// Accepts an arbitrary value for the remove and for prev that may or may not be in the list. - function removeRandKnownPrevKey(bytes30 val, bytes32 prev, uint256 seedAddr, uint256 seedId) external { - AssociatedLinkedListSet storage associatedSet = seedId % 2 == 0 ? set1 : set2; - uint64 id = uint64(seedId % 2 == 0 ? ID_1 : ID_2); - address associated = address(seedAddr % 2 == 0 ? ASSOCIATED_1 : ASSOCIATED_2); - - EnumerableSet.Bytes32Set storage referenceSet = _referenceSets[associated][id]; - EnumerableMap.Bytes32ToUintMap storage referenceMeta = _referenceMeta[associated][id]; - - if (!referenceSet.contains(bytes32(val))) { - if (associatedSet.contains(associated, SetValue.wrap(val))) { - revert ContainsNotExpected(val); - } - if (associatedSet.tryRemoveKnown(associated, SetValue.wrap(val), prev)) { - revert ShouldNotRemove(val); - } - if (associatedSet.contains(associated, SetValue.wrap(val))) { - revert ContainsNotExpected(val); - } - return; // short-circuit after making assertions. - } - - // Check to see in case it is actually the previous key - SetValue[] memory values = associatedSet.getAll(associated); - if (values.length == 0) { - revert LengthMismatch(0, values.length); - } - bytes32 realPrev; - for (uint256 i = 0; i < values.length; i++) { - if (SetValue.unwrap(values[i]) == bytes30(val)) { - if (i == 0) { - realPrev = SENTINEL_VALUE; - } else { - realPrev = bytes32(SetValue.unwrap(values[i - 1])); - } - break; - } - } - - // Clear the flags of prev to avoid any false test failures. This is ONLY safe to do if the library - // function also performs this clear, otherwise it will result in untested edge cases. - // This clearing is done after the prior check in the case where the value is not contained, to broaden the - // test cases. - prev = AssociatedLinkedListSetLib.clearFlags(prev); - - if (realPrev != prev) { - if (associatedSet.tryRemoveKnown(associated, SetValue.wrap(val), prev)) { - revert ShouldNotRemove(val); - } - return; // short-circuit after making assertions. - } else { - // Somehow, the invariant fuzzer actually generated a real prev value. Process the removal - referenceSet.remove(bytes32(val)); - - // Remove the meta entry if it exists - referenceMeta.remove(bytes32(val)); - - if (!associatedSet.tryRemoveKnown(associated, SetValue.wrap(val), prev)) { - revert FailedToRemove(val); - } - if (associatedSet.contains(associated, SetValue.wrap(val))) { - revert ContainsNotExpected(val); - } - } - } - - /// @notice Clears both copies of the list - the associated one and the reference one. - function clear(uint256 seedAddr, uint256 seedId) external { - AssociatedLinkedListSet storage associatedSet = seedId % 2 == 0 ? set1 : set2; - uint64 id = uint64(seedId % 2 == 0 ? ID_1 : ID_2); - address associated = address(seedAddr % 2 == 0 ? ASSOCIATED_1 : ASSOCIATED_2); - - EnumerableSet.Bytes32Set storage referenceSet = _referenceSets[associated][id]; - EnumerableMap.Bytes32ToUintMap storage referenceMeta = _referenceMeta[associated][id]; - - while (referenceSet.length() > 0) { - bytes30 value = bytes30(referenceSet.at(0)); - referenceSet.remove(bytes32(value)); - referenceMeta.remove(bytes32(value)); - } - - associatedSet.clear(associated); - } - - function addFlagKnown(uint256 seedAddr, uint256 seedId, uint256 indexToFlag, uint16 flags) external { - AssociatedLinkedListSet storage associatedSet = seedId % 2 == 0 ? set1 : set2; - uint64 id = uint64(seedId % 2 == 0 ? ID_1 : ID_2); - address associated = address(seedAddr % 2 == 0 ? ASSOCIATED_1 : ASSOCIATED_2); - - EnumerableSet.Bytes32Set storage referenceSet = _referenceSets[associated][id]; - EnumerableMap.Bytes32ToUintMap storage referenceMeta = _referenceMeta[associated][id]; - - if (referenceSet.length() == 0) { - return; // Silently do nothing - } - - flags &= 0xFFFC; // Clear the last two bits - - indexToFlag = bound(indexToFlag, 0, referenceSet.length() - 1); - - bytes30 value = bytes30(referenceSet.at(indexToFlag)); - - if (!associatedSet.trySetFlags(associated, SetValue.wrap(value), flags)) { - revert FailedToAddFlags(flags); - } - - uint16 returnedFlags = associatedSet.getFlags(associated, SetValue.wrap(value)); - if (returnedFlags != flags) { - revert FailedToGetFlags(flags, returnedFlags); - } - - // Add this entry to the reference set. - referenceMeta.set(bytes32(value), flags); - } - - function addFlagRandom(uint256 seedAddr, uint256 seedId, bytes30 key, uint16 flags) external { - AssociatedLinkedListSet storage associatedSet = seedId % 2 == 0 ? set1 : set2; - uint64 id = uint64(seedId % 2 == 0 ? ID_1 : ID_2); - address associated = address(seedAddr % 2 == 0 ? ASSOCIATED_1 : ASSOCIATED_2); - - EnumerableSet.Bytes32Set storage referenceSet = _referenceSets[associated][id]; - EnumerableMap.Bytes32ToUintMap storage referenceMeta = _referenceMeta[associated][id]; - - flags &= 0xFFFC; // Clear the last two bits - - if (!referenceSet.contains(bytes32(key))) { - if (associatedSet.trySetFlags(associated, SetValue.wrap(key), flags)) { - revert BadAddFlags(key, flags); - } - } else { - // The value actually exists, add the flags correctly - if (!associatedSet.trySetFlags(associated, SetValue.wrap(key), flags)) { - revert FailedToAddFlags(flags); - } - - uint16 returnedFlags = associatedSet.getFlags(associated, SetValue.wrap(key)); - if (returnedFlags != flags) { - revert FailedToGetFlags(flags, returnedFlags); - } - - // Add this entry to the reference set. - referenceMeta.set(bytes32(key), flags); - } - } - - /// @notice Checks if the associated set contains a value - function associatedContains(address associated, uint64 id, bytes30 val) external view returns (bool) { - AssociatedLinkedListSet storage associatedSet = _mapIdToSet(id); - - return associatedSet.contains(associated, SetValue.wrap(val)); - } - - /// @notice Checks if the reference set contains a value - function referenceContains(address associated, uint64 id, bytes30 val) external view returns (bool) { - EnumerableSet.Bytes32Set storage referenceSet = _referenceSets[associated][id]; - return referenceSet.contains(bytes32(val)); - } - - /// @notice Checks if the associated set is empty - function associatedIsEmpty(address associated, uint64 id) external view returns (bool) { - AssociatedLinkedListSet storage associatedSet = _mapIdToSet(id); - return associatedSet.isEmpty(associated); - } - - /// @notice Checks if the reference set is empty - function referenceIsEmpty(address associated, uint64 id) external view returns (bool) { - EnumerableSet.Bytes32Set storage referenceSet = _referenceSets[associated][id]; - return referenceSet.length() == 0; - } - - /// @notice Gets all contents of the reference set - function referenceEnumerate(address associated, uint64 id) external view returns (bytes32[] memory ret) { - EnumerableSet.Bytes32Set storage referenceSet = _referenceSets[associated][id]; - ret = new bytes32[](referenceSet.length()); - for (uint256 i = 0; i < referenceSet.length(); i++) { - ret[i] = referenceSet.at(i); - } - } - - /// @notice Gets all contents of the associated set - function associatedEnumerate(address associated, uint64 id) external view returns (bytes32[] memory ret) { - AssociatedLinkedListSet storage set = _mapIdToSet(id); - SetValue[] memory values = set.getAll(associated); - // Unsafe cast lol - assembly ("memory-safe") { - ret := values - } - } - - function referenceGetFlags(address associated, uint64 id) - external - view - returns (bytes32[] memory keys, uint16[] memory metas) - { - EnumerableMap.Bytes32ToUintMap storage referenceMeta = _referenceMeta[associated][id]; - - keys = new bytes32[](referenceMeta.length()); - metas = new uint16[](referenceMeta.length()); - - for (uint256 i = 0; i < referenceMeta.length(); i++) { - (bytes32 key, uint256 meta) = referenceMeta.at(i); - keys[i] = key; - metas[i] = uint16(meta); - } - } - - function associatedGetFlags(address associated, uint64 id, bytes30 key) external view returns (uint16 meta) { - AssociatedLinkedListSet storage associatedSet = _mapIdToSet(id); - meta = associatedSet.getFlags(associated, SetValue.wrap(key)); - } - - function _mapIdToSet(uint64 id) private view returns (AssociatedLinkedListSet storage associatedSet) { - if (id == ID_1) { - associatedSet = set1; - } else if (id == ID_2) { - associatedSet = set2; - } else { - revert("Invalid id"); - } - } -} diff --git a/test/invariant/handlers/LinkedListSetHandler.sol b/test/invariant/handlers/LinkedListSetHandler.sol deleted file mode 100644 index 649a2152..00000000 --- a/test/invariant/handlers/LinkedListSetHandler.sol +++ /dev/null @@ -1,352 +0,0 @@ -// This file is part of Modular Account. -// -// Copyright 2024 Alchemy Insights, Inc. -// -// SPDX-License-Identifier: GPL-3.0-or-later -// -// This program is free software: you can redistribute it and/or modify it under the terms of the GNU General -// Public License as published by the Free Software Foundation, either version 3 of the License, or (at your -// option) any later version. -// -// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the -// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -// more details. -// -// You should have received a copy of the GNU General Public License along with this program. If not, see -// . - -pragma solidity ^0.8.22; - -import {CommonBase} from "forge-std/Base.sol"; -import {StdCheats} from "forge-std/StdCheats.sol"; -import {StdUtils} from "forge-std/StdUtils.sol"; - -import {EnumerableMap} from "@openzeppelin/contracts/utils/structs/EnumerableMap.sol"; -import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; - -import {SetValue} from "../../../src/libraries/Constants.sol"; -import {LinkedListSetLib, LinkedListSet as EnumerableSetType} from "../../../src/libraries/LinkedListSetLib.sol"; - -/// @notice A handler contract for differential invariant testing LinkedListSetLib -/// This contract maps logic for adding, removeing, clearing, and inspecting a list -/// to a reference implementation using EnumerableSet.Bytes32Set, which the invariant -/// fuzzer can then use to test the library. -contract LinkedListSetHandler is CommonBase, StdCheats, StdUtils { - using LinkedListSetLib for EnumerableSetType; - using EnumerableSet for EnumerableSet.Bytes32Set; - using EnumerableMap for EnumerableMap.Bytes32ToUintMap; - - EnumerableSet.Bytes32Set internal referenceSet; - EnumerableMap.Bytes32ToUintMap internal referenceMeta; - - EnumerableSetType internal libSet; - - error FailedToAdd(bytes30 value); - error FailedToAddFlags(uint16 value); - error FailedToGetFlags(uint16 expected, uint16 actual); - error BadAddFlags(bytes30 value, uint16 flags); - error FailedToRemove(bytes30 value); - error ShouldNotRemove(bytes30 value); - error ContainsNotExpected(bytes30 value); - error DoesNotContain(bytes30 value); - error LengthMismatch(uint256 expected, uint256 actual); - error MetaDoesNotContain(bytes30 value); - - bytes32 internal constant SENTINEL_VALUE = bytes32(uint256(1)); - - constructor() {} - - /// @notice Adds to both copies of the list - the library one and the reference one - function add(bytes30 val) external { - if (referenceSet.contains(bytes32(val)) || val == bytes30(0)) { - return; // Silently do nothing - } - - referenceSet.add(bytes32(val)); - - bool success = libSet.tryAdd(SetValue.wrap(val)); - if (!success) { - revert FailedToAdd(val); - } - } - - /// @notice Removes a key from both sets by its index in the reference implementation. - /// Uses the O(n) iterating remove method. - function removeIterate(uint256 indexToRemove) external { - if (referenceSet.length() == 0) { - return; // Silently do nothing - } - - indexToRemove = bound(indexToRemove, 0, referenceSet.length() - 1); - - bytes30 value = bytes30(referenceSet.at(indexToRemove)); - - // Assert the value was in the reference set and is now removed. - if (!referenceSet.remove(bytes32(value))) { - revert DoesNotContain(value); - } - - // Remove the meta entry if it exists - referenceMeta.remove(bytes32(value)); - - if (!libSet.tryRemove(SetValue.wrap(value))) { - revert FailedToRemove(value); - } - - if (libSet.contains(SetValue.wrap(value))) { - revert ContainsNotExpected(value); - } - } - - /// @notice Removes a key from both sets. - /// Accepts an arbitrary value to attempt to remove that may or may not be in the list. - /// Uses the O(n) iterating remove method. - function removeRandKeyIterate(bytes30 val) external { - if (!referenceSet.contains(bytes32(val))) { - if (libSet.contains(SetValue.wrap(val))) { - revert ContainsNotExpected(val); - } - if (libSet.tryRemove(SetValue.wrap(val))) { - revert ShouldNotRemove(val); - } - if (libSet.contains(SetValue.wrap(val))) { - revert ContainsNotExpected(val); - } - return; // short-circuit after making assertions. - } - - if (!referenceSet.remove(bytes32(val))) { - revert DoesNotContain(val); - } - - // Remove the meta entry if it exists - referenceMeta.remove(bytes32(val)); - - if (!libSet.tryRemove(SetValue.wrap(val))) { - revert FailedToRemove(val); - } - - if (libSet.contains(SetValue.wrap(val))) { - revert ContainsNotExpected(val); - } - } - - /// @notice Removes a key by looking up it's predecessor via getAll before submitting the call - /// Uses the O(1) remove method that has knowledge of the previous key. - function removeKnownPrevKey(uint256 index) external { - if (referenceSet.length() == 0) { - return; // Silently do nothing - } - - index = bound(index, 0, referenceSet.length() - 1); - - bytes30 value = bytes30(referenceSet.at(index)); - - referenceSet.remove(bytes32(value)); - - // Remove the meta entry if it exists - referenceMeta.remove(bytes32(value)); - - // Get the previous entry via getAll - SetValue[] memory values = libSet.getAll(); - if (values.length == 0) { - revert LengthMismatch(0, values.length); - } - - bytes32 prev; - for (uint256 i = 0; i < values.length; i++) { - if (SetValue.unwrap(values[i]) == bytes30(value)) { - if (i == 0) { - prev = SENTINEL_VALUE; - } else { - prev = bytes32(SetValue.unwrap(values[i - 1])); - } - break; - } - } - - if (prev == bytes32(0)) { - revert DoesNotContain(value); - } - - if (!libSet.tryRemoveKnown(SetValue.wrap(value), prev)) { - revert FailedToRemove(value); - } - - if (libSet.contains(SetValue.wrap(value))) { - revert ContainsNotExpected(value); - } - } - - /// @notice Removes a key using the O(1) remove method that has knowledge of the previous key. - /// Accepts an arbitrary value for the remove and for prev that may or may not be in the list. - function removeRandKnownPrevKey(bytes30 val, bytes32 prev) external { - if (!referenceSet.contains(bytes32(val))) { - if (libSet.contains(SetValue.wrap(val))) { - revert ContainsNotExpected(val); - } - if (libSet.tryRemoveKnown(SetValue.wrap(val), prev)) { - revert ShouldNotRemove(val); - } - if (libSet.contains(SetValue.wrap(val))) { - revert ContainsNotExpected(val); - } - return; // short-circuit after making assertions. - } - - // Check to see in case it is actually the previous key - SetValue[] memory values = libSet.getAll(); - if (values.length == 0) { - revert LengthMismatch(0, values.length); - } - bytes32 realPrev; - for (uint256 i = 0; i < values.length; i++) { - if (SetValue.unwrap(values[i]) == bytes30(val)) { - if (i == 0) { - realPrev = SENTINEL_VALUE; - } else { - realPrev = bytes32(SetValue.unwrap(values[i - 1])); - } - break; - } - } - - // Clear the flags of prev to avoid any false test failures. This is ONLY safe to do if the library - // function also performs this clear, otherwise it will result in untested edge cases. - // This clearing is done after the prior check in the case where the value is not contained, to broaden the - // test cases. - prev = LinkedListSetLib.clearFlags(prev); - - if (realPrev != prev) { - if (libSet.tryRemoveKnown(SetValue.wrap(val), prev)) { - revert ShouldNotRemove(val); - } - return; // short-circuit after making assertions. - } else { - // Somehow, the invariant fuzzer actually generated a real prev value. Process the removal - if (!referenceSet.remove(bytes32(val))) { - revert DoesNotContain(val); - } - - // Remove the meta entry if it exists - referenceMeta.remove(bytes32(val)); - - if (!libSet.tryRemoveKnown(SetValue.wrap(val), prev)) { - revert FailedToRemove(val); - } - if (libSet.contains(SetValue.wrap(val))) { - revert ContainsNotExpected(val); - } - } - } - - /// @notice Clears both copies of the list - the library one and the reference one. - function clear() external { - while (referenceSet.length() > 0) { - bytes30 value = bytes30(referenceSet.at(0)); - referenceSet.remove(bytes32(value)); - referenceMeta.remove(bytes32(value)); - } - - libSet.clear(); - } - - function addFlagKnown(uint256 indexToFlag, uint16 flags) external { - if (referenceSet.length() == 0) { - return; // Silently do nothing - } - - flags &= 0xFFFC; // Clear the last two bits - - indexToFlag = bound(indexToFlag, 0, referenceSet.length() - 1); - - bytes30 value = bytes30(referenceSet.at(indexToFlag)); - - if (!libSet.trySetFlags(SetValue.wrap(value), flags)) { - revert FailedToAddFlags(flags); - } - - uint16 returnedFlags = libSet.getFlags(SetValue.wrap(value)); - if (returnedFlags != flags) { - revert FailedToGetFlags(flags, returnedFlags); - } - - // Add this entry to the reference set. - referenceMeta.set(bytes32(value), flags); - } - - function addFlagRandom(bytes30 key, uint16 flags) external { - flags &= 0xFFFC; // Clear the last two bits - - if (!referenceSet.contains(bytes32(key))) { - if (libSet.trySetFlags(SetValue.wrap(key), flags)) { - revert BadAddFlags(key, flags); - } - } else { - // The value actually exists, add the flags correctly - if (!libSet.trySetFlags(SetValue.wrap(key), flags)) { - revert FailedToAddFlags(flags); - } - - uint16 returnedFlags = libSet.getFlags(SetValue.wrap(key)); - if (returnedFlags != flags) { - revert FailedToGetFlags(flags, returnedFlags); - } - - // Add this entry to the reference set. - referenceMeta.set(bytes32(key), flags); - } - } - - /// @notice Checks if the library set contains a value - function libContains(bytes30 val) external view returns (bool) { - return libSet.contains(SetValue.wrap(val)); - } - - /// @notice Checks if the reference set contains a value - function referenceContains(bytes30 val) external view returns (bool) { - return referenceSet.contains(bytes32(val)); - } - - /// @notice Checks if the library set is empty - function libIsEmpty() external view returns (bool) { - return libSet.isEmpty(); - } - - /// @notice Checks if the reference set is empty - function referenceIsEmpty() external view returns (bool) { - return referenceSet.length() == 0; - } - - /// @notice Gets all contents of the reference set - function referenceEnumerate() external view returns (bytes32[] memory ret) { - ret = new bytes32[](referenceSet.length()); - for (uint256 i = 0; i < referenceSet.length(); i++) { - ret[i] = referenceSet.at(i); - } - } - - /// @notice Gets all contents of the library set - function libEnumerate() external view returns (bytes32[] memory ret) { - SetValue[] memory values = libSet.getAll(); - // Unsafe cast lol - assembly ("memory-safe") { - ret := values - } - } - - function referenceGetFlags() external view returns (bytes32[] memory keys, uint16[] memory metas) { - keys = new bytes32[](referenceMeta.length()); - metas = new uint16[](referenceMeta.length()); - - for (uint256 i = 0; i < referenceMeta.length(); i++) { - (bytes32 key, uint256 meta) = referenceMeta.at(i); - keys[i] = key; - metas[i] = uint16(meta); - } - } - - function libGetFlags(bytes30 key) external view returns (uint16 meta) { - meta = libSet.getFlags(SetValue.wrap(key)); - } -} diff --git a/test/libraries/AssociatedLinkedListSetLib.t.sol b/test/libraries/AssociatedLinkedListSetLib.t.sol deleted file mode 100644 index 7b295027..00000000 --- a/test/libraries/AssociatedLinkedListSetLib.t.sol +++ /dev/null @@ -1,240 +0,0 @@ -// This file is part of Modular Account. -// -// Copyright 2024 Alchemy Insights, Inc. -// -// SPDX-License-Identifier: GPL-3.0-or-later -// -// This program is free software: you can redistribute it and/or modify it under the terms of the GNU General -// Public License as published by the Free Software Foundation, either version 3 of the License, or (at your -// option) any later version. -// -// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the -// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -// more details. -// -// You should have received a copy of the GNU General Public License along with this program. If not, see -// . - -pragma solidity ^0.8.22; - -import {Test} from "forge-std/Test.sol"; - -import { - AssociatedLinkedListSet, - AssociatedLinkedListSetLib -} from "../../src/libraries/AssociatedLinkedListSetLib.sol"; -import {SetValue, SENTINEL_VALUE} from "../../src/libraries/Constants.sol"; - -contract AssociatedLinkedListSetLibTest is Test { - using AssociatedLinkedListSetLib for AssociatedLinkedListSet; - - AssociatedLinkedListSet internal _set1; - AssociatedLinkedListSet internal _set2; - - address internal _associated = address(this); - - // User-defined function for wrapping from bytes30 (uint240) to SetValue - // Can define a custom one for addresses, uints, etc. - function _getListValue(uint240 value) internal pure returns (SetValue) { - return SetValue.wrap(bytes30(value)); - } - - // A lot of these tests were auto-generated by copilot and manually inspected. - // In addition to these tests, there are also invariant tests in - // test/invariant/AssociatedLinkedListSetLibInvariants.t.sol - - function test_add_contains() public { - SetValue value = _getListValue(12); - - assertTrue(_set1.tryAdd(_associated, value)); - assertTrue(_set1.contains(_associated, value)); - } - - function test_empty() public { - SetValue value = _getListValue(12); - - assertFalse(_set1.contains(_associated, value)); - assertTrue(_set1.isEmpty(_associated)); - } - - function test_remove() public { - SetValue value = _getListValue(12); - - assertTrue(_set1.tryAdd(_associated, value)); - assertTrue(_set1.contains(_associated, value)); - - assertTrue(_set1.tryRemove(_associated, value)); - assertFalse(_set1.contains(_associated, value)); - } - - function test_remove_empty() public { - SetValue value = _getListValue(12); - - assertFalse(_set1.tryRemove(_associated, value)); - } - - function test_remove_nonexistent() public { - SetValue value = _getListValue(12); - - assertTrue(_set1.tryAdd(_associated, value)); - assertTrue(_set1.contains(_associated, value)); - - SetValue value2 = _getListValue(13); - assertFalse(_set1.tryRemove(_associated, value2)); - assertTrue(_set1.contains(_associated, value)); - } - - function test_remove_nonexistent_empty() public { - SetValue value = _getListValue(12); - - assertFalse(_set1.tryRemove(_associated, value)); - } - - function test_remove_nonexistent_empty2() public { - SetValue value = _getListValue(12); - - assertTrue(_set1.tryAdd(_associated, value)); - assertTrue(_set1.contains(_associated, value)); - - SetValue value2 = _getListValue(13); - assertFalse(_set1.tryRemove(_associated, value2)); - assertTrue(_set1.contains(_associated, value)); - } - - function test_add_remove_add() public { - SetValue value = _getListValue(12); - - assertTrue(_set1.tryAdd(_associated, value)); - assertTrue(_set1.contains(_associated, value)); - - assertTrue(_set1.tryRemove(_associated, value)); - assertFalse(_set1.contains(_associated, value)); - - assertTrue(_set1.tryAdd(_associated, value)); - assertTrue(_set1.contains(_associated, value)); - } - - function test_add_remove_add_empty() public { - SetValue value = _getListValue(12); - - assertTrue(_set1.tryAdd(_associated, value)); - assertTrue(_set1.contains(_associated, value)); - - assertTrue(_set1.tryRemove(_associated, value)); - assertFalse(_set1.contains(_associated, value)); - - assertTrue(_set1.tryAdd(_associated, value)); - assertTrue(_set1.contains(_associated, value)); - } - - function test_no_address_collision() public { - SetValue value = _getListValue(12); - - assertTrue(_set1.tryAdd(_associated, value)); - assertTrue(_set1.contains(_associated, value)); - assertFalse(_set2.contains(_associated, value)); - } - - function test_clear() public { - SetValue value = _getListValue(12); - - assertTrue(_set1.tryAdd(_associated, value)); - assertTrue(_set1.contains(_associated, value)); - - _set1.clear(_associated); - - assertFalse(_set1.contains(_associated, value)); - assertTrue(_set1.isEmpty(_associated)); - } - - function test_getAll() public { - SetValue value = _getListValue(12); - SetValue value2 = _getListValue(13); - - assertTrue(_set1.tryAdd(_associated, value)); - assertTrue(_set1.tryAdd(_associated, value2)); - - SetValue[] memory values = _set1.getAll(_associated); - assertEq(values.length, 2); - // Returned set will be in reverse order of added elements - assertEq(SetValue.unwrap(values[1]), SetValue.unwrap(value)); - assertEq(SetValue.unwrap(values[0]), SetValue.unwrap(value2)); - } - - function test_getAll2() public { - SetValue value = _getListValue(12); - SetValue value2 = _getListValue(13); - SetValue value3 = _getListValue(14); - - assertTrue(_set1.tryAdd(_associated, value)); - assertTrue(_set1.tryAdd(_associated, value2)); - assertTrue(_set1.tryAdd(_associated, value3)); - - SetValue[] memory values = _set1.getAll(_associated); - assertEq(values.length, 3); - // Returned set will be in reverse order of added elements - assertEq(SetValue.unwrap(values[2]), SetValue.unwrap(value)); - assertEq(SetValue.unwrap(values[1]), SetValue.unwrap(value2)); - assertEq(SetValue.unwrap(values[0]), SetValue.unwrap(value3)); - } - - function test_getAll_empty() public { - SetValue[] memory values = _set1.getAll(_associated); - assertEq(values.length, 0); - } - - function test_tryRemoveKnown1() public { - SetValue value = _getListValue(12); - - assertTrue(_set1.tryAdd(_associated, value)); - assertTrue(_set1.contains(_associated, value)); - - assertTrue(_set1.tryRemoveKnown(_associated, value, SENTINEL_VALUE)); - assertFalse(_set1.contains(_associated, value)); - assertTrue(_set1.isEmpty(_associated)); - } - - function test_tryRemoveKnown2() public { - SetValue value1 = _getListValue(12); - SetValue value2 = _getListValue(13); - - assertTrue(_set1.tryAdd(_associated, value1)); - assertTrue(_set1.tryAdd(_associated, value2)); - assertTrue(_set1.contains(_associated, value1)); - assertTrue(_set1.contains(_associated, value2)); - - // Assert that getAll returns the correct values - SetValue[] memory values = _set1.getAll(_associated); - assertEq(values.length, 2); - assertEq(SetValue.unwrap(values[1]), SetValue.unwrap(value1)); - assertEq(SetValue.unwrap(values[0]), SetValue.unwrap(value2)); - - assertTrue(_set1.tryRemoveKnown(_associated, value1, bytes32(SetValue.unwrap(value2)))); - assertFalse(_set1.contains(_associated, value1)); - assertTrue(_set1.contains(_associated, value2)); - - // Assert that getAll returns the correct values - values = _set1.getAll(_associated); - assertEq(values.length, 1); - assertEq(SetValue.unwrap(values[0]), SetValue.unwrap(value2)); - - assertTrue(_set1.tryRemoveKnown(_associated, value2, SENTINEL_VALUE)); - assertFalse(_set1.contains(_associated, value1)); - - assertTrue(_set1.isEmpty(_associated)); - } - - function test_tryRemoveKnown_invalid1() public { - SetValue value1 = _getListValue(12); - SetValue value2 = _getListValue(13); - - assertTrue(_set1.tryAdd(_associated, value1)); - assertTrue(_set1.tryAdd(_associated, value2)); - - assertFalse(_set1.tryRemoveKnown(_associated, value1, bytes32(SetValue.unwrap(value1)))); - assertTrue(_set1.contains(_associated, value1)); - - assertFalse(_set1.tryRemoveKnown(_associated, value2, bytes32(SetValue.unwrap(value2)))); - assertTrue(_set1.contains(_associated, value2)); - } -} diff --git a/test/libraries/CountableLinkedListSetLib.t.sol b/test/libraries/CountableLinkedListSetLib.t.sol deleted file mode 100644 index 267ad83f..00000000 --- a/test/libraries/CountableLinkedListSetLib.t.sol +++ /dev/null @@ -1,84 +0,0 @@ -// This file is part of Modular Account. -// -// Copyright 2024 Alchemy Insights, Inc. -// -// SPDX-License-Identifier: GPL-3.0-or-later -// -// This program is free software: you can redistribute it and/or modify it under the terms of the GNU General -// Public License as published by the Free Software Foundation, either version 3 of the License, or (at your -// option) any later version. -// -// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the -// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -// more details. -// -// You should have received a copy of the GNU General Public License along with this program. If not, see -// . - -pragma solidity ^0.8.22; - -import {Test} from "forge-std/Test.sol"; - -import {SetValue} from "../../src/libraries/Constants.sol"; -import {CountableLinkedListSetLib} from "../../src/libraries/CountableLinkedListSetLib.sol"; -import {LinkedListSet, LinkedListSetLib} from "../../src/libraries/LinkedListSetLib.sol"; - -contract CountableLinkedListSetLibTest is Test { - using LinkedListSetLib for LinkedListSet; - using CountableLinkedListSetLib for LinkedListSet; - - LinkedListSet internal _set; - - uint16 internal constant _MAX_COUNTER_VALUE = 255; - - // User-defined function for wrapping from bytes30 (uint240) to SetValue - // Can define a custom one for addresses, uints, etc. - function _getListValue(uint240 value) internal pure returns (SetValue) { - return SetValue.wrap(bytes30(value)); - } - - function test_getCount() public { - SetValue value = _getListValue(12); - assertTrue(_set.tryAdd(value)); - assertEq(_set.getCount(value), 1); - _set.tryEnableFlags(value, 0xFF00); - assertEq(_set.getCount(value), 256); - } - - function test_tryIncrement() public { - SetValue value = _getListValue(12); - assertEq(_set.getCount(value), 0); - - for (uint256 i = 0; i < _MAX_COUNTER_VALUE + 1; ++i) { - assertTrue(_set.tryIncrement(value)); - assertEq(_set.getCount(value), i + 1); - } - - assertFalse(_set.tryIncrement(value)); - assertEq(_set.getCount(value), 256); - - assertTrue(_set.contains(value)); - assertFalse(_set.tryAdd(value)); - } - - function test_tryDecrement() public { - SetValue value = _getListValue(12); - assertEq(_set.getCount(value), 0); - assertFalse(_set.tryDecrement(value)); - - for (uint256 i = 0; i < _MAX_COUNTER_VALUE + 1; ++i) { - _set.tryIncrement(value); - } - - for (uint256 i = _MAX_COUNTER_VALUE + 1; i > 0; --i) { - assertTrue(_set.tryDecrement(value)); - assertEq(_set.getCount(value), i - 1); - } - - assertFalse(_set.tryDecrement(value)); - assertEq(_set.getCount(value), 0); - - assertFalse(_set.contains(value)); - assertFalse(_set.tryRemove(value)); - } -} diff --git a/test/libraries/LinkedListSetLib.t.sol b/test/libraries/LinkedListSetLib.t.sol deleted file mode 100644 index 367fe950..00000000 --- a/test/libraries/LinkedListSetLib.t.sol +++ /dev/null @@ -1,318 +0,0 @@ -// This file is part of Modular Account. -// -// Copyright 2024 Alchemy Insights, Inc. -// -// SPDX-License-Identifier: GPL-3.0-or-later -// -// This program is free software: you can redistribute it and/or modify it under the terms of the GNU General -// Public License as published by the Free Software Foundation, either version 3 of the License, or (at your -// option) any later version. -// -// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the -// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -// more details. -// -// You should have received a copy of the GNU General Public License along with this program. If not, see -// . - -pragma solidity ^0.8.22; - -import {Test} from "forge-std/Test.sol"; - -import {SetValue, SENTINEL_VALUE} from "../../src/libraries/Constants.sol"; -import {LinkedListSet, LinkedListSetLib} from "../../src/libraries/LinkedListSetLib.sol"; - -// Ported over from test/AssociatedLinkedListSetLib.t.sol, dropping test_no_address_collision -contract LinkedListSetLibTest is Test { - using LinkedListSetLib for LinkedListSet; - - LinkedListSet internal _set; - - // User-defined function for wrapping from bytes30 (uint240) to SetValue - // Can define a custom one for addresses, uints, etc. - function _getListValue(uint240 value) internal pure returns (SetValue) { - return SetValue.wrap(bytes30(value)); - } - - // A lot of these tests were auto-generated by copilot and manually inspected. - // In addition to these tests, there are also invariant tests in - // test/invariant/LinkedListSetLibInvariants.t.sol - - function test_add_contains() public { - SetValue value = _getListValue(12); - assertTrue(_set.tryAdd(value)); - assertTrue(_set.contains(value)); - } - - function test_empty() public { - SetValue value = _getListValue(12); - assertFalse(_set.contains(value)); - assertTrue(_set.isEmpty()); - } - - function test_remove() public { - SetValue value = _getListValue(12); - assertTrue(_set.tryAdd(value)); - assertTrue(_set.contains(value)); - - assertTrue(_set.tryRemove(value)); - assertFalse(_set.contains(value)); - } - - function test_remove_empty() public { - SetValue value = _getListValue(12); - assertFalse(_set.tryRemove(value)); - } - - function test_remove_nonexistent() public { - SetValue value = _getListValue(12); - assertTrue(_set.tryAdd(value)); - assertTrue(_set.contains(value)); - - SetValue value2 = _getListValue(13); - assertFalse(_set.tryRemove(value2)); - assertTrue(_set.contains(value)); - } - - function test_remove_nonexistent_empty() public { - SetValue value = _getListValue(12); - assertFalse(_set.tryRemove(value)); - } - - function test_remove_nonexistent_empty2() public { - SetValue value = _getListValue(12); - assertTrue(_set.tryAdd(value)); - assertTrue(_set.contains(value)); - - SetValue value2 = _getListValue(13); - assertFalse(_set.tryRemove(value2)); - assertTrue(_set.contains(value)); - } - - function test_add_remove_add() public { - SetValue value = _getListValue(12); - assertTrue(_set.tryAdd(value)); - assertTrue(_set.contains(value)); - - assertTrue(_set.tryRemove(value)); - assertFalse(_set.contains(value)); - - assertTrue(_set.tryAdd(value)); - assertTrue(_set.contains(value)); - } - - function test_add_remove_add_empty() public { - SetValue value = _getListValue(12); - assertTrue(_set.tryAdd(value)); - assertTrue(_set.contains(value)); - - assertTrue(_set.tryRemove(value)); - assertFalse(_set.contains(value)); - - assertTrue(_set.tryAdd(value)); - assertTrue(_set.contains(value)); - } - - function test_clear() public { - SetValue value = _getListValue(12); - assertTrue(_set.tryAdd(value)); - assertTrue(_set.contains(value)); - - _set.clear(); - - assertFalse(_set.contains(value)); - assertTrue(_set.isEmpty()); - } - - function test_getAll() public { - SetValue value = _getListValue(12); - SetValue value2 = _getListValue(13); - assertTrue(_set.tryAdd(value)); - assertTrue(_set.tryAdd(value2)); - - SetValue[] memory values = _set.getAll(); - assertEq(values.length, 2); - // Returned set will be in reverse order of added elements - assertEq(SetValue.unwrap(values[1]), SetValue.unwrap(value)); - assertEq(SetValue.unwrap(values[0]), SetValue.unwrap(value2)); - } - - function test_getAll2() public { - SetValue value = _getListValue(12); - SetValue value2 = _getListValue(13); - SetValue value3 = _getListValue(14); - assertTrue(_set.tryAdd(value)); - assertTrue(_set.tryAdd(value2)); - assertTrue(_set.tryAdd(value3)); - - SetValue[] memory values = _set.getAll(); - assertEq(values.length, 3); - // Returned set will be in reverse order of added elements - assertEq(SetValue.unwrap(values[2]), SetValue.unwrap(value)); - assertEq(SetValue.unwrap(values[1]), SetValue.unwrap(value2)); - assertEq(SetValue.unwrap(values[0]), SetValue.unwrap(value3)); - } - - function test_getAll_empty() public { - SetValue[] memory values = _set.getAll(); - assertEq(values.length, 0); - } - - function test_tryRemoveKnown1() public { - SetValue value = _getListValue(12); - - assertTrue(_set.tryAdd(value)); - assertTrue(_set.contains(value)); - - assertTrue(_set.tryRemoveKnown(value, SENTINEL_VALUE)); - assertFalse(_set.contains(value)); - assertTrue(_set.isEmpty()); - } - - function test_tryRemoveKnown2() public { - SetValue value1 = _getListValue(12); - SetValue value2 = _getListValue(13); - - assertTrue(_set.tryAdd(value1)); - assertTrue(_set.tryAdd(value2)); - assertTrue(_set.contains(value1)); - assertTrue(_set.contains(value2)); - - // Assert that getAll returns the correct values - SetValue[] memory values = _set.getAll(); - assertEq(values.length, 2); - assertEq(SetValue.unwrap(values[1]), SetValue.unwrap(value1)); - assertEq(SetValue.unwrap(values[0]), SetValue.unwrap(value2)); - - assertTrue(_set.tryRemoveKnown(value1, bytes32(SetValue.unwrap(value2)))); - assertFalse(_set.contains(value1)); - assertTrue(_set.contains(value2)); - - // Assert that getAll returns the correct values - values = _set.getAll(); - assertEq(values.length, 1); - assertEq(SetValue.unwrap(values[0]), SetValue.unwrap(value2)); - - assertTrue(_set.tryRemoveKnown(value2, SENTINEL_VALUE)); - assertFalse(_set.contains(value1)); - - assertTrue(_set.isEmpty()); - } - - function test_tryRemoveKnown_invalid1() public { - SetValue value1 = _getListValue(12); - SetValue value2 = _getListValue(13); - - assertTrue(_set.tryAdd(value1)); - assertTrue(_set.tryAdd(value2)); - - assertFalse(_set.tryRemoveKnown(value1, bytes32(SetValue.unwrap(value1)))); - assertTrue(_set.contains(value1)); - - assertFalse(_set.tryRemoveKnown(value2, bytes32(SetValue.unwrap(value2)))); - assertTrue(_set.contains(value2)); - } - - function test_isSentinel() public { - bytes32 val1 = bytes32(uint256(0)); - assertFalse(LinkedListSetLib.isSentinel(val1)); - - bytes32 val2 = bytes32(uint256(1)); - assertTrue(LinkedListSetLib.isSentinel(val2)); - - bytes32 val3 = bytes32(uint256(3)); - assertTrue(LinkedListSetLib.isSentinel(val3)); - - bytes32 val4 = bytes32(uint256(2)); - assertFalse(LinkedListSetLib.isSentinel(val4)); - } - - function test_userFlags_fail_does_not_contain() public { - SetValue value1 = _getListValue(12); - SetValue value2 = _getListValue(13); - - assertTrue(_set.tryAdd(value1)); - assertTrue(_set.tryAdd(value2)); - - assertFalse(_set.trySetFlags(_getListValue(14), uint8(0xF0))); - } - - function test_userFlags_basic() public { - SetValue value1 = _getListValue(12); - SetValue value2 = _getListValue(13); - - assertTrue(_set.tryAdd(value1)); - assertTrue(_set.tryAdd(value2)); - - assertTrue(_set.trySetFlags(value1, uint8(0xF0))); - assertTrue(_set.trySetFlags(value2, uint8(0x0C))); - - assertEq(_set.getFlags(value1), uint8(0xF0)); - assertEq(_set.getFlags(value2), uint8(0x0C)); - } - - function test_userFlags_getAll() public { - SetValue value1 = _getListValue(12); - SetValue value2 = _getListValue(13); - - assertTrue(_set.tryAdd(value1)); - assertTrue(_set.tryAdd(value2)); - - assertTrue(_set.trySetFlags(value1, uint8(0xF0))); - assertTrue(_set.trySetFlags(value2, uint8(0x0C))); - - SetValue[] memory values = _set.getAll(); - assertEq(values.length, 2); - assertEq(SetValue.unwrap(values[0]), SetValue.unwrap(value2)); - assertEq(SetValue.unwrap(values[1]), SetValue.unwrap(value1)); - - assertEq(_set.getFlags(values[0]), uint8(0x0C)); - assertEq(_set.getFlags(values[1]), uint8(0xF0)); - } - - function test_userFlags_tryEnable() public { - SetValue value1 = _getListValue(12); - - assertTrue(_set.tryAdd(value1)); - - assertTrue(_set.trySetFlags(value1, uint8(0xF0))); - assertTrue(_set.tryEnableFlags(value1, uint8(0x0C))); - - assertEq(_set.getFlags(value1), uint8(0xFC)); - } - - function test_userFlags_tryDisable() public { - SetValue value1 = _getListValue(12); - - assertTrue(_set.tryAdd(value1)); - - assertTrue(_set.trySetFlags(value1, uint8(0xF0))); - assertTrue(_set.tryDisableFlags(value1, uint8(0xC0))); - - assertEq(_set.getFlags(value1), uint8(0x30)); - } - - function test_userFlags_flagsEnabled() public { - SetValue value1 = _getListValue(12); - - assertTrue(_set.tryAdd(value1)); - - assertTrue(_set.trySetFlags(value1, uint8(0xF0))); - - assertTrue(_set.flagsEnabled(value1, uint8(0x80))); - assertTrue(_set.flagsEnabled(value1, uint8(0xC0))); - assertFalse(_set.flagsEnabled(value1, uint8(0x0C))); - } - - function test_userFlags_flagsDisabled() public { - SetValue value1 = _getListValue(12); - - assertTrue(_set.tryAdd(value1)); - - assertTrue(_set.trySetFlags(value1, uint8(0xF0))); - - assertFalse(_set.flagsDisabled(value1, uint8(0x80))); - assertFalse(_set.flagsDisabled(value1, uint8(0xC0))); - assertTrue(_set.flagsDisabled(value1, uint8(0x0C))); - } -} diff --git a/test/libraries/PluginStorageLib.t.sol b/test/libraries/PluginStorageLib.t.sol deleted file mode 100644 index 473514f9..00000000 --- a/test/libraries/PluginStorageLib.t.sol +++ /dev/null @@ -1,107 +0,0 @@ -// This file is part of Modular Account. -// -// Copyright 2024 Alchemy Insights, Inc. -// -// SPDX-License-Identifier: GPL-3.0-or-later -// -// This program is free software: you can redistribute it and/or modify it under the terms of the GNU General -// Public License as published by the Free Software Foundation, either version 3 of the License, or (at your -// option) any later version. -// -// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the -// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -// more details. -// -// You should have received a copy of the GNU General Public License along with this program. If not, see -// . - -pragma solidity ^0.8.22; - -import {Test} from "forge-std/Test.sol"; - -import {PluginStorageLib, StoragePointer} from "../../src/libraries/PluginStorageLib.sol"; - -contract PluginStorageLibTest is Test { - using PluginStorageLib for bytes; - using PluginStorageLib for bytes32; - - uint256 public constant FUZZ_ARR_SIZE = 32; - - address public account1; - - struct TestStruct { - uint256 a; - uint256 b; - } - - function setUp() public { - account1 = makeAddr("account1"); - } - - function test_storagePointer() public { - bytes memory key = PluginStorageLib.allocateAssociatedStorageKey(account1, 0, 1); - - StoragePointer ptr = PluginStorageLib.associatedStorageLookup( - key, hex"00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff" - ); - TestStruct storage val = _castPtrToStruct(ptr); - - vm.record(); - val.a = 0xdeadbeef; - val.b = 123; - (, bytes32[] memory accountWrites) = vm.accesses(address(this)); - - // printStorageReadsAndWrites(address(this)); - - assertEq(accountWrites.length, 2); - bytes32 expectedKey = keccak256( - abi.encodePacked( - uint256(uint160(account1)), - uint256(0), - hex"00112233445566778899aabbccddeeff00112233445566778899aabbccddeeff" - ) - ); - assertEq(accountWrites[0], expectedKey); - assertEq(vm.load(address(this), expectedKey), bytes32(uint256(0xdeadbeef))); - assertEq(accountWrites[1], bytes32(uint256(expectedKey) + 1)); - assertEq(vm.load(address(this), bytes32(uint256(expectedKey) + 1)), bytes32(uint256(123))); - } - - function testFuzz_storagePointer( - address account, - uint256 batchIndex, - bytes32 inputKey, - uint256[FUZZ_ARR_SIZE] calldata values - ) public { - bytes memory key = PluginStorageLib.allocateAssociatedStorageKey(account, batchIndex, 1); - uint256[FUZZ_ARR_SIZE] storage val = - _castPtrToArray(PluginStorageLib.associatedStorageLookup(key, inputKey)); - // Write values to storage - vm.record(); - for (uint256 i = 0; i < FUZZ_ARR_SIZE; i++) { - val[i] = values[i]; - } - // Assert the writes took place in the right location, and the correct value is stored there - (, bytes32[] memory accountWrites) = vm.accesses(address(this)); - assertEq(accountWrites.length, FUZZ_ARR_SIZE); - for (uint256 i = 0; i < FUZZ_ARR_SIZE; i++) { - bytes32 expectedKey = bytes32( - uint256(keccak256(abi.encodePacked(uint256(uint160(account)), uint256(batchIndex), inputKey))) + i - ); - assertEq(accountWrites[i], expectedKey); - assertEq(vm.load(address(this), expectedKey), bytes32(uint256(values[i]))); - } - } - - function _castPtrToArray(StoragePointer ptr) internal pure returns (uint256[FUZZ_ARR_SIZE] storage val) { - assembly ("memory-safe") { - val.slot := ptr - } - } - - function _castPtrToStruct(StoragePointer ptr) internal pure returns (TestStruct storage val) { - assembly ("memory-safe") { - val.slot := ptr - } - } -} diff --git a/test/mocks/MockPlugin.sol b/test/mocks/MockPlugin.sol index 99ca5696..f58c52a5 100644 --- a/test/mocks/MockPlugin.sol +++ b/test/mocks/MockPlugin.sol @@ -19,7 +19,7 @@ pragma solidity ^0.8.22; import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol"; -import {PluginManifest, PluginMetadata, IPlugin} from "../../src/interfaces/IPlugin.sol"; +import {PluginManifest, PluginMetadata, IPlugin} from "modular-account-libs/interfaces/IPlugin.sol"; contract MockPlugin is ERC165 { // It's super inefficient to hold the entire abi-encoded manifest in storage, but this is fine since it's diff --git a/test/mocks/plugins/AccountStateMutatingPlugin.sol b/test/mocks/plugins/AccountStateMutatingPlugin.sol index 6f3193be..84691b6c 100644 --- a/test/mocks/plugins/AccountStateMutatingPlugin.sol +++ b/test/mocks/plugins/AccountStateMutatingPlugin.sol @@ -17,14 +17,14 @@ pragma solidity ^0.8.22; -import {UserOperation} from "../../../src/interfaces/erc4337/UserOperation.sol"; +import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; import { PluginManifest, ManifestExecutionHook, ManifestFunction, ManifestAssociatedFunctionType, ManifestAssociatedFunction -} from "../../../src/interfaces/IPlugin.sol"; +} from "modular-account-libs/interfaces/IPlugin.sol"; import {BaseTestPlugin} from "./BaseTestPlugin.sol"; // Used in conjunction with AccountStatePhasesTest to verify that the account state is consistent when plugins are diff --git a/test/mocks/plugins/BadTransferOwnershipPlugin.sol b/test/mocks/plugins/BadTransferOwnershipPlugin.sol index 237691ae..dee885a0 100644 --- a/test/mocks/plugins/BadTransferOwnershipPlugin.sol +++ b/test/mocks/plugins/BadTransferOwnershipPlugin.sol @@ -24,9 +24,9 @@ import { ManifestAssociatedFunction, PluginManifest, PluginMetadata -} from "../../../src/interfaces/IPlugin.sol"; -import {IPluginExecutor} from "../../../src/interfaces/IPluginExecutor.sol"; -import {IStandardExecutor} from "../../../src/interfaces/IStandardExecutor.sol"; +} from "modular-account-libs/interfaces/IPlugin.sol"; +import {IPluginExecutor} from "modular-account-libs/interfaces/IPluginExecutor.sol"; +import {IStandardExecutor} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import {IMultiOwnerPlugin} from "../../../src/plugins/owner/IMultiOwnerPlugin.sol"; import {BaseTestPlugin} from "./BaseTestPlugin.sol"; diff --git a/test/mocks/plugins/BaseTestPlugin.sol b/test/mocks/plugins/BaseTestPlugin.sol index 2dba09bc..07fcb80c 100644 --- a/test/mocks/plugins/BaseTestPlugin.sol +++ b/test/mocks/plugins/BaseTestPlugin.sol @@ -17,7 +17,7 @@ pragma solidity ^0.8.22; -import {PluginMetadata} from "../../../src/interfaces/IPlugin.sol"; +import {PluginMetadata} from "modular-account-libs/interfaces/IPlugin.sol"; import {BasePlugin} from "../../../src/plugins/BasePlugin.sol"; contract BaseTestPlugin is BasePlugin { diff --git a/test/mocks/plugins/ChangingManifestPlugin.sol b/test/mocks/plugins/ChangingManifestPlugin.sol index 0b6d0c57..39b763ce 100644 --- a/test/mocks/plugins/ChangingManifestPlugin.sol +++ b/test/mocks/plugins/ChangingManifestPlugin.sol @@ -26,7 +26,7 @@ import { ManifestAssociatedFunction, PluginManifest, PluginMetadata -} from "../../../src/interfaces/IPlugin.sol"; +} from "modular-account-libs/interfaces/IPlugin.sol"; import {BasePlugin} from "../../../src/plugins/BasePlugin.sol"; contract CanChangeManifestPluginFactory { diff --git a/test/mocks/plugins/ComprehensivePlugin.sol b/test/mocks/plugins/ComprehensivePlugin.sol index 2f588b4f..6512510d 100644 --- a/test/mocks/plugins/ComprehensivePlugin.sol +++ b/test/mocks/plugins/ComprehensivePlugin.sol @@ -17,7 +17,7 @@ pragma solidity ^0.8.22; -import {UserOperation} from "../../../src/interfaces/erc4337/UserOperation.sol"; +import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; import { ManifestExecutionHook, ManifestFunction, @@ -25,8 +25,8 @@ import { ManifestAssociatedFunction, PluginManifest, PluginMetadata -} from "../../../src/interfaces/IPlugin.sol"; -import {IStandardExecutor} from "../../../src/interfaces/IStandardExecutor.sol"; +} from "modular-account-libs/interfaces/IPlugin.sol"; +import {IStandardExecutor} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import {BaseTestPlugin} from "./BaseTestPlugin.sol"; contract ComprehensivePlugin is BaseTestPlugin { diff --git a/test/mocks/plugins/ExecFromPluginPermissionsMocks.sol b/test/mocks/plugins/ExecFromPluginPermissionsMocks.sol index ba778283..f7d48ef9 100644 --- a/test/mocks/plugins/ExecFromPluginPermissionsMocks.sol +++ b/test/mocks/plugins/ExecFromPluginPermissionsMocks.sol @@ -24,11 +24,11 @@ import { ManifestExternalCallPermission, ManifestExecutionHook, PluginManifest -} from "../../../src/interfaces/IPlugin.sol"; -import {IPlugin} from "../../../src/interfaces/IPlugin.sol"; -import {IPluginExecutor} from "../../../src/interfaces/IPluginExecutor.sol"; -import {FunctionReference} from "../../../src/interfaces/IPluginManager.sol"; -import {IStandardExecutor} from "../../../src/interfaces/IStandardExecutor.sol"; +} from "modular-account-libs/interfaces/IPlugin.sol"; +import {IPlugin} from "modular-account-libs/interfaces/IPlugin.sol"; +import {IPluginExecutor} from "modular-account-libs/interfaces/IPluginExecutor.sol"; +import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; +import {IStandardExecutor} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import {Counter} from "../Counter.sol"; import {BaseTestPlugin} from "./BaseTestPlugin.sol"; import {ResultCreatorPlugin} from "./ReturnDataPluginMocks.sol"; diff --git a/test/mocks/plugins/ManifestValidityMocks.sol b/test/mocks/plugins/ManifestValidityMocks.sol index 994a08b7..59105aa7 100644 --- a/test/mocks/plugins/ManifestValidityMocks.sol +++ b/test/mocks/plugins/ManifestValidityMocks.sol @@ -24,11 +24,11 @@ import { ManifestExecutionHook, ManifestExternalCallPermission, PluginManifest -} from "../../../src/interfaces/IPlugin.sol"; -import {IPlugin} from "../../../src/interfaces/IPlugin.sol"; -import {IPluginExecutor} from "../../../src/interfaces/IPluginExecutor.sol"; -import {FunctionReference} from "../../../src/interfaces/IPluginManager.sol"; -import {IStandardExecutor} from "../../../src/interfaces/IStandardExecutor.sol"; +} from "modular-account-libs/interfaces/IPlugin.sol"; +import {IPlugin} from "modular-account-libs/interfaces/IPlugin.sol"; +import {IPluginExecutor} from "modular-account-libs/interfaces/IPluginExecutor.sol"; +import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; +import {IStandardExecutor} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import {BaseTestPlugin} from "./BaseTestPlugin.sol"; contract BadValidationMagicValue_UserOp_Plugin is BaseTestPlugin { diff --git a/test/mocks/plugins/ReturnDataPluginMocks.sol b/test/mocks/plugins/ReturnDataPluginMocks.sol index ecdad152..ecb075cf 100644 --- a/test/mocks/plugins/ReturnDataPluginMocks.sol +++ b/test/mocks/plugins/ReturnDataPluginMocks.sol @@ -23,11 +23,11 @@ import { ManifestAssociatedFunction, ManifestExternalCallPermission, PluginManifest -} from "../../../src/interfaces/IPlugin.sol"; -import {IPlugin} from "../../../src/interfaces/IPlugin.sol"; -import {IPluginExecutor} from "../../../src/interfaces/IPluginExecutor.sol"; -import {FunctionReference} from "../../../src/interfaces/IPluginManager.sol"; -import {IStandardExecutor} from "../../../src/interfaces/IStandardExecutor.sol"; +} from "modular-account-libs/interfaces/IPlugin.sol"; +import {IPlugin} from "modular-account-libs/interfaces/IPlugin.sol"; +import {IPluginExecutor} from "modular-account-libs/interfaces/IPluginExecutor.sol"; +import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; +import {IStandardExecutor} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import {BaseTestPlugin} from "./BaseTestPlugin.sol"; contract RegularResultContract { diff --git a/test/mocks/plugins/UninstallErrorsPlugin.sol b/test/mocks/plugins/UninstallErrorsPlugin.sol index 9c339b1f..9271ec6f 100644 --- a/test/mocks/plugins/UninstallErrorsPlugin.sol +++ b/test/mocks/plugins/UninstallErrorsPlugin.sol @@ -25,7 +25,7 @@ import { ManifestAssociatedFunction, PluginManifest, PluginMetadata -} from "../../../src/interfaces/IPlugin.sol"; +} from "modular-account-libs/interfaces/IPlugin.sol"; import {BaseTestPlugin} from "./BaseTestPlugin.sol"; /// Mock plugin that reverts in its uninstall callbacks. Can be configured to diff --git a/test/mocks/plugins/ValidationPluginMocks.sol b/test/mocks/plugins/ValidationPluginMocks.sol index eb66d766..145d1ec1 100644 --- a/test/mocks/plugins/ValidationPluginMocks.sol +++ b/test/mocks/plugins/ValidationPluginMocks.sol @@ -17,13 +17,13 @@ pragma solidity ^0.8.22; -import {UserOperation} from "../../../src/interfaces/erc4337/UserOperation.sol"; +import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; import { ManifestFunction, ManifestAssociatedFunctionType, ManifestAssociatedFunction, PluginManifest -} from "../../../src/interfaces/IPlugin.sol"; +} from "modular-account-libs/interfaces/IPlugin.sol"; import {BaseTestPlugin} from "./BaseTestPlugin.sol"; abstract contract MockBaseUserOpValidationPlugin is BaseTestPlugin { diff --git a/test/plugin/owner/MultiOwnerPlugin.t.sol b/test/plugin/owner/MultiOwnerPlugin.t.sol index 2d48b5a0..ad476f53 100644 --- a/test/plugin/owner/MultiOwnerPlugin.t.sol +++ b/test/plugin/owner/MultiOwnerPlugin.t.sol @@ -23,8 +23,8 @@ import {EntryPoint} from "@eth-infinitism/account-abstraction/core/EntryPoint.so import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import {IEntryPoint} from "../../../src/interfaces/erc4337/IEntryPoint.sol"; -import {UserOperation} from "../../../src/interfaces/erc4337/UserOperation.sol"; -import {PluginManifest} from "../../../src/interfaces/IPlugin.sol"; +import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; +import {PluginManifest} from "modular-account-libs/interfaces/IPlugin.sol"; import {BasePlugin} from "../../../src/plugins/BasePlugin.sol"; import {IMultiOwnerPlugin} from "../../../src/plugins/owner/IMultiOwnerPlugin.sol"; import {MultiOwnerPlugin} from "../../../src/plugins/owner/MultiOwnerPlugin.sol"; diff --git a/test/plugin/owner/MultiOwnerPluginIntegration.t.sol b/test/plugin/owner/MultiOwnerPluginIntegration.t.sol index ee6894d9..5b019e54 100644 --- a/test/plugin/owner/MultiOwnerPluginIntegration.t.sol +++ b/test/plugin/owner/MultiOwnerPluginIntegration.t.sol @@ -26,9 +26,9 @@ import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import {UpgradeableModularAccount} from "../../../src/account/UpgradeableModularAccount.sol"; import {MultiOwnerModularAccountFactory} from "../../../src/factory/MultiOwnerModularAccountFactory.sol"; import {IEntryPoint} from "../../../src/interfaces/erc4337/IEntryPoint.sol"; -import {UserOperation} from "../../../src/interfaces/erc4337/UserOperation.sol"; -import {FunctionReference} from "../../../src/interfaces/IPluginManager.sol"; -import {Call} from "../../../src/interfaces/IStandardExecutor.sol"; +import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; +import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; +import {Call} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import {IMultiOwnerPlugin} from "../../../src/plugins/owner/IMultiOwnerPlugin.sol"; import {MultiOwnerPlugin} from "../../../src/plugins/owner/MultiOwnerPlugin.sol"; import {Counter} from "../../mocks/Counter.sol"; diff --git a/test/plugin/session/SessionKeyPluginWithMultiOwner.t.sol b/test/plugin/session/SessionKeyPluginWithMultiOwner.t.sol index 3bd55fcd..bd0cb7aa 100644 --- a/test/plugin/session/SessionKeyPluginWithMultiOwner.t.sol +++ b/test/plugin/session/SessionKeyPluginWithMultiOwner.t.sol @@ -26,11 +26,11 @@ import {ISessionKeyPermissionsUpdates} from "../../../src/plugins/session/permissions/ISessionKeyPermissionsUpdates.sol"; import {UpgradeableModularAccount} from "../../../src/account/UpgradeableModularAccount.sol"; import {MultiOwnerModularAccountFactory} from "../../../src/factory/MultiOwnerModularAccountFactory.sol"; -import {FunctionReferenceLib} from "../../../src/helpers/FunctionReferenceLib.sol"; +import {FunctionReferenceLib} from "modular-account-libs/libraries/FunctionReferenceLib.sol"; import {IEntryPoint} from "../../../src/interfaces/erc4337/IEntryPoint.sol"; -import {UserOperation} from "../../../src/interfaces/erc4337/UserOperation.sol"; -import {FunctionReference} from "../../../src/interfaces/IPluginManager.sol"; -import {Call} from "../../../src/interfaces/IStandardExecutor.sol"; +import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; +import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; +import {Call} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import {BasePlugin} from "../../../src/plugins/BasePlugin.sol"; import {IMultiOwnerPlugin} from "../../../src/plugins/owner/IMultiOwnerPlugin.sol"; import {MultiOwnerPlugin} from "../../../src/plugins/owner/MultiOwnerPlugin.sol"; diff --git a/test/plugin/session/permissions/SessionKeyERC20SpendLimits.t.sol b/test/plugin/session/permissions/SessionKeyERC20SpendLimits.t.sol index 8b3bf73c..0865df74 100644 --- a/test/plugin/session/permissions/SessionKeyERC20SpendLimits.t.sol +++ b/test/plugin/session/permissions/SessionKeyERC20SpendLimits.t.sol @@ -26,11 +26,11 @@ import {ISessionKeyPermissionsUpdates} from "../../../../src/plugins/session/permissions/ISessionKeyPermissionsUpdates.sol"; import {UpgradeableModularAccount} from "../../../../src/account/UpgradeableModularAccount.sol"; import {MultiOwnerModularAccountFactory} from "../../../../src/factory/MultiOwnerModularAccountFactory.sol"; -import {FunctionReferenceLib} from "../../../../src/helpers/FunctionReferenceLib.sol"; +import {FunctionReferenceLib} from "modular-account-libs/libraries/FunctionReferenceLib.sol"; import {IEntryPoint} from "../../../../src/interfaces/erc4337/IEntryPoint.sol"; -import {UserOperation} from "../../../../src/interfaces/erc4337/UserOperation.sol"; -import {FunctionReference} from "../../../../src/interfaces/IPluginManager.sol"; -import {Call} from "../../../../src/interfaces/IStandardExecutor.sol"; +import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; +import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; +import {Call} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import {IMultiOwnerPlugin} from "../../../../src/plugins/owner/IMultiOwnerPlugin.sol"; import {MultiOwnerPlugin} from "../../../../src/plugins/owner/MultiOwnerPlugin.sol"; import {ISessionKeyPlugin} from "../../../../src/plugins/session/ISessionKeyPlugin.sol"; diff --git a/test/plugin/session/permissions/SessionKeyGasLimits.t.sol b/test/plugin/session/permissions/SessionKeyGasLimits.t.sol index 825b6e90..96549ff9 100644 --- a/test/plugin/session/permissions/SessionKeyGasLimits.t.sol +++ b/test/plugin/session/permissions/SessionKeyGasLimits.t.sol @@ -26,11 +26,11 @@ import {ISessionKeyPermissionsUpdates} from "../../../../src/plugins/session/permissions/ISessionKeyPermissionsUpdates.sol"; import {UpgradeableModularAccount} from "../../../../src/account/UpgradeableModularAccount.sol"; import {MultiOwnerModularAccountFactory} from "../../../../src/factory/MultiOwnerModularAccountFactory.sol"; -import {FunctionReferenceLib} from "../../../../src/helpers/FunctionReferenceLib.sol"; +import {FunctionReferenceLib} from "modular-account-libs/libraries/FunctionReferenceLib.sol"; import {IEntryPoint} from "../../../../src/interfaces/erc4337/IEntryPoint.sol"; -import {UserOperation} from "../../../../src/interfaces/erc4337/UserOperation.sol"; -import {FunctionReference} from "../../../../src/interfaces/IPluginManager.sol"; -import {Call} from "../../../../src/interfaces/IStandardExecutor.sol"; +import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; +import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; +import {Call} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import {IMultiOwnerPlugin} from "../../../../src/plugins/owner/IMultiOwnerPlugin.sol"; import {MultiOwnerPlugin} from "../../../../src/plugins/owner/MultiOwnerPlugin.sol"; import {ISessionKeyPlugin} from "../../../../src/plugins/session/ISessionKeyPlugin.sol"; diff --git a/test/plugin/session/permissions/SessionKeyNativeTokenSpendLimits.t.sol b/test/plugin/session/permissions/SessionKeyNativeTokenSpendLimits.t.sol index 413c1d9a..c1b762fd 100644 --- a/test/plugin/session/permissions/SessionKeyNativeTokenSpendLimits.t.sol +++ b/test/plugin/session/permissions/SessionKeyNativeTokenSpendLimits.t.sol @@ -26,11 +26,11 @@ import {ISessionKeyPermissionsUpdates} from "../../../../src/plugins/session/permissions/ISessionKeyPermissionsUpdates.sol"; import {UpgradeableModularAccount} from "../../../../src/account/UpgradeableModularAccount.sol"; import {MultiOwnerModularAccountFactory} from "../../../../src/factory/MultiOwnerModularAccountFactory.sol"; -import {FunctionReferenceLib} from "../../../../src/helpers/FunctionReferenceLib.sol"; +import {FunctionReferenceLib} from "modular-account-libs/libraries/FunctionReferenceLib.sol"; import {IEntryPoint} from "../../../../src/interfaces/erc4337/IEntryPoint.sol"; -import {UserOperation} from "../../../../src/interfaces/erc4337/UserOperation.sol"; -import {FunctionReference} from "../../../../src/interfaces/IPluginManager.sol"; -import {Call} from "../../../../src/interfaces/IStandardExecutor.sol"; +import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; +import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; +import {Call} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import {IMultiOwnerPlugin} from "../../../../src/plugins/owner/IMultiOwnerPlugin.sol"; import {MultiOwnerPlugin} from "../../../../src/plugins/owner/MultiOwnerPlugin.sol"; import {ISessionKeyPlugin} from "../../../../src/plugins/session/ISessionKeyPlugin.sol"; diff --git a/test/plugin/session/permissions/SessionKeyPermissions.t.sol b/test/plugin/session/permissions/SessionKeyPermissions.t.sol index 7e01d31d..4033988b 100644 --- a/test/plugin/session/permissions/SessionKeyPermissions.t.sol +++ b/test/plugin/session/permissions/SessionKeyPermissions.t.sol @@ -26,11 +26,11 @@ import {ISessionKeyPermissionsUpdates} from "../../../../src/plugins/session/permissions/ISessionKeyPermissionsUpdates.sol"; import {UpgradeableModularAccount} from "../../../../src/account/UpgradeableModularAccount.sol"; import {MultiOwnerModularAccountFactory} from "../../../../src/factory/MultiOwnerModularAccountFactory.sol"; -import {FunctionReferenceLib} from "../../../../src/helpers/FunctionReferenceLib.sol"; +import {FunctionReferenceLib} from "modular-account-libs/libraries/FunctionReferenceLib.sol"; import {IEntryPoint} from "../../../../src/interfaces/erc4337/IEntryPoint.sol"; -import {UserOperation} from "../../../../src/interfaces/erc4337/UserOperation.sol"; -import {FunctionReference} from "../../../../src/interfaces/IPluginManager.sol"; -import {Call} from "../../../../src/interfaces/IStandardExecutor.sol"; +import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; +import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; +import {Call} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import {IMultiOwnerPlugin} from "../../../../src/plugins/owner/IMultiOwnerPlugin.sol"; import {MultiOwnerPlugin} from "../../../../src/plugins/owner/MultiOwnerPlugin.sol"; import {ISessionKeyPlugin} from "../../../../src/plugins/session/ISessionKeyPlugin.sol"; diff --git a/test/upgrade/MAToMA.t.sol b/test/upgrade/MAToMA.t.sol index 0331b674..b4c7c078 100644 --- a/test/upgrade/MAToMA.t.sol +++ b/test/upgrade/MAToMA.t.sol @@ -24,7 +24,7 @@ import {EntryPoint} from "@eth-infinitism/account-abstraction/core/EntryPoint.so import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol"; import {MultiOwnerModularAccountFactory} from "../../src/factory/MultiOwnerModularAccountFactory.sol"; import {IEntryPoint} from "../../src/interfaces/erc4337/IEntryPoint.sol"; -import {Call} from "../../src/interfaces/IStandardExecutor.sol"; +import {Call} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import {MultiOwnerPlugin} from "../../src/plugins/owner/MultiOwnerPlugin.sol"; import {MockERC20} from "../mocks/tokens/MockERC20.sol"; import {Utils} from "../Utils.sol"; From f1c5485eaccfddddc95d41188a88cd496fd4329a Mon Sep 17 00:00:00 2001 From: zer0dot Date: Fri, 10 May 2024 21:09:16 +0800 Subject: [PATCH 3/6] misc: Organized imports --- script/Deploy.s.sol | 1 - src/account/AccountExecutor.sol | 3 +-- src/account/AccountLoupe.sol | 7 ++++--- src/account/PluginManagerInternals.sol | 5 ++--- src/account/UpgradeableModularAccount.sol | 17 ++++++++--------- src/helpers/KnownSelectors.sol | 14 +++++++------- src/plugins/BasePlugin.sol | 3 +-- src/plugins/owner/MultiOwnerPlugin.sol | 12 ++++++------ src/plugins/session/SessionKeyPlugin.sol | 6 +++--- .../permissions/SessionKeyPermissions.sol | 4 ++-- .../permissions/SessionKeyPermissionsBase.sol | 1 + test/account/AccountExecHooks.t.sol | 13 ++++++------- test/account/AccountLoupe.t.sol | 11 +++++------ test/account/AccountPreValidationHooks.t.sol | 13 ++++++------- test/account/AccountReturnData.t.sol | 5 ++--- .../ExecuteFromPluginPermissions.t.sol | 5 ++--- test/account/ManifestValidity.t.sol | 3 +-- test/account/TokenReceiver.t.sol | 19 +++++++++---------- test/account/UpgradeableModularAccount.t.sol | 10 +++++----- ...gradeableModularAccountPluginManager.t.sol | 14 +++++++------- test/account/ValidationIntersection.t.sol | 7 +++---- test/account/phases/AccountStatePhases.t.sol | 11 +++++------ .../phases/AccountStatePhasesExec.t.sol | 1 + .../AccountStatePhasesRTValidation.t.sol | 3 ++- .../AccountStatePhasesUOValidation.t.sol | 3 +-- test/comparison/CompareSimpleAccount.t.sol | 2 +- test/factory/MultiOwnerMAFactoryTest.t.sol | 1 - test/helpers/KnownSelectors.t.sol | 11 +++++------ test/mocks/MockPlugin.sol | 3 +-- .../plugins/AccountStateMutatingPlugin.sol | 1 + .../plugins/BadTransferOwnershipPlugin.sol | 1 + test/mocks/plugins/BaseTestPlugin.sol | 1 + test/mocks/plugins/ComprehensivePlugin.sol | 1 + .../ExecFromPluginPermissionsMocks.sol | 1 + test/mocks/plugins/ManifestValidityMocks.sol | 1 + test/mocks/plugins/ReturnDataPluginMocks.sol | 1 + test/mocks/plugins/UninstallErrorsPlugin.sol | 4 ++-- test/mocks/plugins/ValidationPluginMocks.sol | 1 + test/plugin/owner/MultiOwnerPlugin.t.sol | 5 ++--- .../owner/MultiOwnerPluginIntegration.t.sol | 7 +++---- .../SessionKeyPluginWithMultiOwner.t.sol | 9 ++++----- .../SessionKeyERC20SpendLimits.t.sol | 9 ++++----- .../permissions/SessionKeyGasLimits.t.sol | 9 ++++----- .../SessionKeyNativeTokenSpendLimits.t.sol | 9 ++++----- .../permissions/SessionKeyPermissions.t.sol | 9 ++++----- .../LightAccountToModularAccount.t.sol | 1 - test/upgrade/MAToMA.t.sol | 3 +-- 47 files changed, 133 insertions(+), 148 deletions(-) diff --git a/script/Deploy.s.sol b/script/Deploy.s.sol index 52bd6433..bc11230a 100644 --- a/script/Deploy.s.sol +++ b/script/Deploy.s.sol @@ -19,7 +19,6 @@ pragma solidity ^0.8.22; import {Script} from "forge-std/Script.sol"; import {console} from "forge-std/Test.sol"; - import {IEntryPoint as I4337EntryPoint} from "@eth-infinitism/account-abstraction/interfaces/IEntryPoint.sol"; import {UpgradeableModularAccount} from "../src/account/UpgradeableModularAccount.sol"; diff --git a/src/account/AccountExecutor.sol b/src/account/AccountExecutor.sol index 05db6779..2761bf54 100644 --- a/src/account/AccountExecutor.sol +++ b/src/account/AccountExecutor.sol @@ -17,10 +17,9 @@ pragma solidity ^0.8.22; -import {ERC165Checker} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol"; - import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; import {IPlugin} from "modular-account-libs/interfaces/IPlugin.sol"; +import {ERC165Checker} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol"; /// @title Account Executor /// @author Alchemy diff --git a/src/account/AccountLoupe.sol b/src/account/AccountLoupe.sol index c51e81d9..5de5d742 100644 --- a/src/account/AccountLoupe.sol +++ b/src/account/AccountLoupe.sol @@ -17,14 +17,15 @@ pragma solidity ^0.8.22; -import {AccountStorageV1} from "../account/AccountStorageV1.sol"; -import {CastLib} from "../helpers/CastLib.sol"; -import {KnownSelectors} from "../helpers/KnownSelectors.sol"; import {IAccountLoupe} from "modular-account-libs/interfaces/IAccountLoupe.sol"; import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; import {CountableLinkedListSetLib} from "modular-account-libs/libraries/CountableLinkedListSetLib.sol"; import {LinkedListSet, LinkedListSetLib} from "modular-account-libs/libraries/LinkedListSetLib.sol"; +import {AccountStorageV1} from "../account/AccountStorageV1.sol"; +import {CastLib} from "../helpers/CastLib.sol"; +import {KnownSelectors} from "../helpers/KnownSelectors.sol"; + /// @title Account Loupe /// @author Alchemy /// @notice Provides view functions for querying the configuration of a modular account. diff --git a/src/account/PluginManagerInternals.sol b/src/account/PluginManagerInternals.sol index b1dfa5d5..5a36e238 100644 --- a/src/account/PluginManagerInternals.sol +++ b/src/account/PluginManagerInternals.sol @@ -17,8 +17,6 @@ pragma solidity ^0.8.22; -import {ERC165Checker} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol"; - import {FunctionReferenceLib} from "modular-account-libs/libraries/FunctionReferenceLib.sol"; import { IPlugin, @@ -32,9 +30,10 @@ import { import {FunctionReference, IPluginManager} from "modular-account-libs/interfaces/IPluginManager.sol"; import {CountableLinkedListSetLib} from "modular-account-libs/libraries/CountableLinkedListSetLib.sol"; import {LinkedListSet, LinkedListSetLib} from "modular-account-libs/libraries/LinkedListSetLib.sol"; +import {ERC165Checker} from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol"; -import {KnownSelectors} from "../helpers/KnownSelectors.sol"; import {AccountStorageV1} from "../account/AccountStorageV1.sol"; +import {KnownSelectors} from "../helpers/KnownSelectors.sol"; import {CastLib} from "../helpers/CastLib.sol"; import {FunctionReferenceHelpers} from "../helpers/FunctionReferenceHelpers.sol"; diff --git a/src/account/UpgradeableModularAccount.sol b/src/account/UpgradeableModularAccount.sol index e292ef19..fd336d32 100644 --- a/src/account/UpgradeableModularAccount.sol +++ b/src/account/UpgradeableModularAccount.sol @@ -17,11 +17,6 @@ pragma solidity ^0.8.22; -import {IERC1155Receiver} from "@openzeppelin/contracts/interfaces/IERC1155Receiver.sol"; -import {IERC777Recipient} from "@openzeppelin/contracts/interfaces/IERC777Recipient.sol"; -import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; -import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; - import {IAccount} from "modular-account-libs/interfaces/IAccount.sol"; import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; import {IPlugin, PluginManifest} from "modular-account-libs/interfaces/IPlugin.sol"; @@ -31,18 +26,22 @@ import {Call, IStandardExecutor} from "modular-account-libs/interfaces/IStandard import {CountableLinkedListSetLib} from "modular-account-libs/libraries/CountableLinkedListSetLib.sol"; import {LinkedListSet, LinkedListSetLib} from "modular-account-libs/libraries/LinkedListSetLib.sol"; import {FunctionReference, IPluginManager} from "modular-account-libs/interfaces/IPluginManager.sol"; +import {IERC1155Receiver} from "@openzeppelin/contracts/interfaces/IERC1155Receiver.sol"; +import {IERC777Recipient} from "@openzeppelin/contracts/interfaces/IERC777Recipient.sol"; +import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; +import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; -import {UUPSUpgradeable} from "../../ext/UUPSUpgradeable.sol"; -import {CastLib} from "../helpers/CastLib.sol"; -import {_coalescePreValidation, _coalesceValidation} from "../helpers/ValidationDataHelpers.sol"; import {IEntryPoint} from "../interfaces/erc4337/IEntryPoint.sol"; import {IAccountInitializable} from "../interfaces/IAccountInitializable.sol"; import {IAccountView} from "../interfaces/IAccountView.sol"; +import {CastLib} from "../helpers/CastLib.sol"; +import {_coalescePreValidation, _coalesceValidation} from "../helpers/ValidationDataHelpers.sol"; +import {FunctionReferenceHelpers} from "../helpers/FunctionReferenceHelpers.sol"; +import {UUPSUpgradeable} from "../../ext/UUPSUpgradeable.sol"; import {AccountExecutor} from "./AccountExecutor.sol"; import {AccountLoupe} from "./AccountLoupe.sol"; import {AccountStorageInitializable} from "./AccountStorageInitializable.sol"; import {PluginManagerInternals} from "./PluginManagerInternals.sol"; -import {FunctionReferenceHelpers} from "../helpers/FunctionReferenceHelpers.sol"; /// @title Upgradeable Modular Account /// @author Alchemy diff --git a/src/helpers/KnownSelectors.sol b/src/helpers/KnownSelectors.sol index 163363f9..37d6a4f1 100644 --- a/src/helpers/KnownSelectors.sol +++ b/src/helpers/KnownSelectors.sol @@ -17,22 +17,22 @@ pragma solidity ^0.8.22; -import {UUPSUpgradeable} from "../../ext/UUPSUpgradeable.sol"; +import {IAccount} from "modular-account-libs/interfaces/IAccount.sol"; +import {IAccountLoupe} from "modular-account-libs/interfaces/IAccountLoupe.sol"; +import {IPluginManager} from "modular-account-libs/interfaces/IPluginManager.sol"; +import {IPlugin} from "modular-account-libs/interfaces/IPlugin.sol"; +import {IPluginExecutor} from "modular-account-libs/interfaces/IPluginExecutor.sol"; +import {IStandardExecutor} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import {IERC1155Receiver} from "@openzeppelin/contracts/interfaces/IERC1155Receiver.sol"; import {IERC777Recipient} from "@openzeppelin/contracts/interfaces/IERC777Recipient.sol"; import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; -import {IAccount} from "modular-account-libs/interfaces/IAccount.sol"; +import {UUPSUpgradeable} from "../../ext/UUPSUpgradeable.sol"; import {IAggregator} from "../../src/interfaces/erc4337/IAggregator.sol"; import {IPaymaster} from "../../src/interfaces/erc4337/IPaymaster.sol"; -import {IAccountLoupe} from "modular-account-libs/interfaces/IAccountLoupe.sol"; import {IAccountView} from "../../src/interfaces/IAccountView.sol"; -import {IPluginManager} from "modular-account-libs/interfaces/IPluginManager.sol"; import {IAccountInitializable} from "../interfaces/IAccountInitializable.sol"; -import {IPlugin} from "modular-account-libs/interfaces/IPlugin.sol"; -import {IPluginExecutor} from "modular-account-libs/interfaces/IPluginExecutor.sol"; -import {IStandardExecutor} from "modular-account-libs/interfaces/IStandardExecutor.sol"; /// @title Known Selectors /// @author Alchemy diff --git a/src/plugins/BasePlugin.sol b/src/plugins/BasePlugin.sol index 24ca0d0c..d165a709 100644 --- a/src/plugins/BasePlugin.sol +++ b/src/plugins/BasePlugin.sol @@ -17,9 +17,8 @@ pragma solidity ^0.8.22; -import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol"; - import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; +import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol"; import {IPlugin, PluginManifest, PluginMetadata} from "modular-account-libs/interfaces/IPlugin.sol"; /// @title Base contract for plugins diff --git a/src/plugins/owner/MultiOwnerPlugin.sol b/src/plugins/owner/MultiOwnerPlugin.sol index 3fd92265..f6d155d8 100644 --- a/src/plugins/owner/MultiOwnerPlugin.sol +++ b/src/plugins/owner/MultiOwnerPlugin.sol @@ -17,12 +17,6 @@ pragma solidity ^0.8.22; -import {IERC1271} from "@openzeppelin/contracts/interfaces/IERC1271.sol"; -import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; -import {SignatureChecker} from "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol"; - -import {UpgradeableModularAccount, UUPSUpgradeable} from "../../account/UpgradeableModularAccount.sol"; -import {CastLib} from "../../helpers/CastLib.sol"; import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; import { ManifestAssociatedFunction, @@ -40,6 +34,12 @@ import { import { SetValue, SIG_VALIDATION_PASSED, SIG_VALIDATION_FAILED } from "modular-account-libs/libraries/Constants.sol"; +import {IERC1271} from "@openzeppelin/contracts/interfaces/IERC1271.sol"; +import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; +import {SignatureChecker} from "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol"; + +import {UpgradeableModularAccount, UUPSUpgradeable} from "../../account/UpgradeableModularAccount.sol"; +import {CastLib} from "../../helpers/CastLib.sol"; import {BasePlugin} from "../BasePlugin.sol"; import {IMultiOwnerPlugin} from "./IMultiOwnerPlugin.sol"; diff --git a/src/plugins/session/SessionKeyPlugin.sol b/src/plugins/session/SessionKeyPlugin.sol index 2ed52af0..c8519574 100644 --- a/src/plugins/session/SessionKeyPlugin.sol +++ b/src/plugins/session/SessionKeyPlugin.sol @@ -17,9 +17,6 @@ pragma solidity ^0.8.22; -import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; - -import {CastLib} from "../../helpers/CastLib.sol"; import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; import {IPlugin} from "modular-account-libs/interfaces/IPlugin.sol"; import { @@ -43,6 +40,9 @@ import { SIG_VALIDATION_FAILED } from "modular-account-libs/libraries/Constants.sol"; import {BasePlugin} from "modular-account-libs/plugins/BasePlugin.sol"; +import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; + +import {CastLib} from "../../helpers/CastLib.sol"; import {ISessionKeyPlugin} from "./ISessionKeyPlugin.sol"; import {SessionKeyPermissions} from "./permissions/SessionKeyPermissions.sol"; diff --git a/src/plugins/session/permissions/SessionKeyPermissions.sol b/src/plugins/session/permissions/SessionKeyPermissions.sol index 34c5639a..e036d702 100644 --- a/src/plugins/session/permissions/SessionKeyPermissions.sol +++ b/src/plugins/session/permissions/SessionKeyPermissions.sol @@ -17,12 +17,12 @@ pragma solidity ^0.8.22; -import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; - import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; import {Call} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import {IStandardExecutor} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import {SIG_VALIDATION_PASSED, SIG_VALIDATION_FAILED} from "modular-account-libs/libraries/Constants.sol"; +import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; + import {ISessionKeyPlugin} from "../ISessionKeyPlugin.sol"; import {ISessionKeyPermissionsUpdates} from "./ISessionKeyPermissionsUpdates.sol"; import {SessionKeyPermissionsLoupe} from "./SessionKeyPermissionsLoupe.sol"; diff --git a/src/plugins/session/permissions/SessionKeyPermissionsBase.sol b/src/plugins/session/permissions/SessionKeyPermissionsBase.sol index 4858daf6..05178d32 100644 --- a/src/plugins/session/permissions/SessionKeyPermissionsBase.sol +++ b/src/plugins/session/permissions/SessionKeyPermissionsBase.sol @@ -18,6 +18,7 @@ pragma solidity ^0.8.22; import {PluginStorageLib, StoragePointer} from "modular-account-libs/libraries/PluginStorageLib.sol"; + import {ISessionKeyPlugin} from "../ISessionKeyPlugin.sol"; abstract contract SessionKeyPermissionsBase is ISessionKeyPlugin { diff --git a/test/account/AccountExecHooks.t.sol b/test/account/AccountExecHooks.t.sol index 655600e9..526bc460 100644 --- a/test/account/AccountExecHooks.t.sol +++ b/test/account/AccountExecHooks.t.sol @@ -18,15 +18,8 @@ pragma solidity ^0.8.22; import {Test} from "forge-std/Test.sol"; - import {EntryPoint} from "@eth-infinitism/account-abstraction/core/EntryPoint.sol"; -import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; - -import {PluginManagerInternals} from "../../src/account/PluginManagerInternals.sol"; -import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol"; -import {MultiOwnerModularAccountFactory} from "../../src/factory/MultiOwnerModularAccountFactory.sol"; import {FunctionReferenceLib} from "modular-account-libs/libraries/FunctionReferenceLib.sol"; -import {IEntryPoint} from "../../src/interfaces/erc4337/IEntryPoint.sol"; import { IPlugin, ManifestExecutionHook, @@ -36,6 +29,12 @@ import { ManifestAssociatedFunction } from "modular-account-libs/interfaces/IPlugin.sol"; import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; +import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; + +import {PluginManagerInternals} from "../../src/account/PluginManagerInternals.sol"; +import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol"; +import {MultiOwnerModularAccountFactory} from "../../src/factory/MultiOwnerModularAccountFactory.sol"; +import {IEntryPoint} from "../../src/interfaces/erc4337/IEntryPoint.sol"; import {MultiOwnerPlugin} from "../../src/plugins/owner/MultiOwnerPlugin.sol"; import {MockPlugin} from "../mocks/MockPlugin.sol"; diff --git a/test/account/AccountLoupe.t.sol b/test/account/AccountLoupe.t.sol index 40d436ac..d35d84b5 100644 --- a/test/account/AccountLoupe.t.sol +++ b/test/account/AccountLoupe.t.sol @@ -18,14 +18,8 @@ pragma solidity ^0.8.22; import {Test} from "forge-std/Test.sol"; - import {EntryPoint} from "@eth-infinitism/account-abstraction/core/EntryPoint.sol"; -import {UUPSUpgradeable} from "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol"; - -import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol"; -import {MultiOwnerModularAccountFactory} from "../../src/factory/MultiOwnerModularAccountFactory.sol"; import {FunctionReferenceLib} from "modular-account-libs/libraries/FunctionReferenceLib.sol"; -import {IEntryPoint} from "../../src/interfaces/erc4337/IEntryPoint.sol"; import {IAccountLoupe} from "modular-account-libs/interfaces/IAccountLoupe.sol"; import { ManifestAssociatedFunctionType, @@ -35,6 +29,11 @@ import { } from "modular-account-libs/interfaces/IPlugin.sol"; import {FunctionReference, IPluginManager} from "modular-account-libs/interfaces/IPluginManager.sol"; import {IStandardExecutor} from "modular-account-libs/interfaces/IStandardExecutor.sol"; +import {UUPSUpgradeable} from "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol"; + +import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol"; +import {MultiOwnerModularAccountFactory} from "../../src/factory/MultiOwnerModularAccountFactory.sol"; +import {IEntryPoint} from "../../src/interfaces/erc4337/IEntryPoint.sol"; import {IMultiOwnerPlugin} from "../../src/plugins/owner/IMultiOwnerPlugin.sol"; import {MultiOwnerPlugin} from "../../src/plugins/owner/MultiOwnerPlugin.sol"; import {MockPlugin} from "../mocks/MockPlugin.sol"; diff --git a/test/account/AccountPreValidationHooks.t.sol b/test/account/AccountPreValidationHooks.t.sol index dcee2207..37006c75 100644 --- a/test/account/AccountPreValidationHooks.t.sol +++ b/test/account/AccountPreValidationHooks.t.sol @@ -18,15 +18,8 @@ pragma solidity ^0.8.22; import {Test} from "forge-std/Test.sol"; - import {EntryPoint} from "@eth-infinitism/account-abstraction/core/EntryPoint.sol"; -import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; - -import {PluginManagerInternals} from "../../src/account/PluginManagerInternals.sol"; -import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol"; -import {MultiOwnerModularAccountFactory} from "../../src/factory/MultiOwnerModularAccountFactory.sol"; import {FunctionReferenceLib} from "modular-account-libs/libraries/FunctionReferenceLib.sol"; -import {IEntryPoint} from "../../src/interfaces/erc4337/IEntryPoint.sol"; import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; import { IPlugin, @@ -36,6 +29,12 @@ import { ManifestAssociatedFunction } from "modular-account-libs/interfaces/IPlugin.sol"; import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; +import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; + +import {PluginManagerInternals} from "../../src/account/PluginManagerInternals.sol"; +import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol"; +import {MultiOwnerModularAccountFactory} from "../../src/factory/MultiOwnerModularAccountFactory.sol"; +import {IEntryPoint} from "../../src/interfaces/erc4337/IEntryPoint.sol"; import {IMultiOwnerPlugin} from "../../src/plugins/owner/IMultiOwnerPlugin.sol"; import {MultiOwnerPlugin} from "../../src/plugins/owner/MultiOwnerPlugin.sol"; import {MockPlugin} from "../mocks/MockPlugin.sol"; diff --git a/test/account/AccountReturnData.t.sol b/test/account/AccountReturnData.t.sol index 39ad6a29..66920fc4 100644 --- a/test/account/AccountReturnData.t.sol +++ b/test/account/AccountReturnData.t.sol @@ -18,14 +18,13 @@ pragma solidity ^0.8.22; import {Test} from "forge-std/Test.sol"; - import {EntryPoint} from "@eth-infinitism/account-abstraction/core/EntryPoint.sol"; +import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; +import {Call} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol"; import {MultiOwnerModularAccountFactory} from "../../src/factory/MultiOwnerModularAccountFactory.sol"; import {IEntryPoint} from "../../src/interfaces/erc4337/IEntryPoint.sol"; -import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; -import {Call} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import {MultiOwnerPlugin} from "../../src/plugins/owner/MultiOwnerPlugin.sol"; import { RegularResultContract, diff --git a/test/account/ExecuteFromPluginPermissions.t.sol b/test/account/ExecuteFromPluginPermissions.t.sol index c71ab72b..314c033c 100644 --- a/test/account/ExecuteFromPluginPermissions.t.sol +++ b/test/account/ExecuteFromPluginPermissions.t.sol @@ -18,14 +18,13 @@ pragma solidity ^0.8.22; import {Test, console} from "forge-std/Test.sol"; - import {EntryPoint} from "@eth-infinitism/account-abstraction/core/EntryPoint.sol"; +import {IPlugin} from "modular-account-libs/interfaces/IPlugin.sol"; +import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol"; import {MultiOwnerModularAccountFactory} from "../../src/factory/MultiOwnerModularAccountFactory.sol"; import {IEntryPoint} from "../../src/interfaces/erc4337/IEntryPoint.sol"; -import {IPlugin} from "modular-account-libs/interfaces/IPlugin.sol"; -import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; import {MultiOwnerPlugin} from "../../src/plugins/owner/MultiOwnerPlugin.sol"; import {Counter} from "../mocks/Counter.sol"; import { diff --git a/test/account/ManifestValidity.t.sol b/test/account/ManifestValidity.t.sol index 2b4e0580..69620957 100644 --- a/test/account/ManifestValidity.t.sol +++ b/test/account/ManifestValidity.t.sol @@ -18,14 +18,13 @@ pragma solidity ^0.8.22; import {Test} from "forge-std/Test.sol"; - import {EntryPoint} from "@eth-infinitism/account-abstraction/core/EntryPoint.sol"; +import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; import {PluginManagerInternals} from "../../src/account/PluginManagerInternals.sol"; import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol"; import {MultiOwnerModularAccountFactory} from "../../src/factory/MultiOwnerModularAccountFactory.sol"; import {IEntryPoint} from "../../src/interfaces/erc4337/IEntryPoint.sol"; -import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; import {MultiOwnerPlugin} from "../../src/plugins/owner/MultiOwnerPlugin.sol"; import { BadValidationMagicValue_UserOp_Plugin, diff --git a/test/account/TokenReceiver.t.sol b/test/account/TokenReceiver.t.sol index 4e84f4ac..3b88055c 100644 --- a/test/account/TokenReceiver.t.sol +++ b/test/account/TokenReceiver.t.sol @@ -18,10 +18,17 @@ pragma solidity ^0.8.22; import {Test} from "forge-std/Test.sol"; - +import {EntryPoint} from "@eth-infinitism/account-abstraction/core/EntryPoint.sol"; +import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; +import { + IPlugin, + ManifestExecutionHook, + ManifestAssociatedFunctionType, + ManifestFunction, + PluginManifest +} from "modular-account-libs/interfaces/IPlugin.sol"; import {ERC721PresetMinterPauserAutoId} from "@openzeppelin/contracts/token/ERC721/presets/ERC721PresetMinterPauserAutoId.sol"; -import {EntryPoint} from "@eth-infinitism/account-abstraction/core/EntryPoint.sol"; import {IERC1155Receiver} from "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol"; import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; import {IERC777Recipient} from "@openzeppelin/contracts/token/ERC777/IERC777Recipient.sol"; @@ -29,14 +36,6 @@ import {IERC777Recipient} from "@openzeppelin/contracts/token/ERC777/IERC777Reci import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol"; import {MultiOwnerModularAccountFactory} from "../../src/factory/MultiOwnerModularAccountFactory.sol"; import {IEntryPoint} from "../../src/interfaces/erc4337/IEntryPoint.sol"; -import { - IPlugin, - ManifestExecutionHook, - ManifestAssociatedFunctionType, - ManifestFunction, - PluginManifest -} from "modular-account-libs/interfaces/IPlugin.sol"; -import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; import {MultiOwnerPlugin} from "../../src/plugins/owner/MultiOwnerPlugin.sol"; import {MockPlugin} from "../mocks/MockPlugin.sol"; import {MockERC1155} from "../mocks/tokens/MockERC1155.sol"; diff --git a/test/account/UpgradeableModularAccount.t.sol b/test/account/UpgradeableModularAccount.t.sol index 2c13fc44..ca75f149 100644 --- a/test/account/UpgradeableModularAccount.t.sol +++ b/test/account/UpgradeableModularAccount.t.sol @@ -19,20 +19,20 @@ pragma solidity ^0.8.22; import {Test, console} from "forge-std/Test.sol"; +import {EntryPoint} from "@eth-infinitism/account-abstraction/core/EntryPoint.sol"; +import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; +import {IPlugin, PluginManifest} from "modular-account-libs/interfaces/IPlugin.sol"; +import {FunctionReference, IPluginManager} from "modular-account-libs/interfaces/IPluginManager.sol"; +import {Call} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; -import {EntryPoint} from "@eth-infinitism/account-abstraction/core/EntryPoint.sol"; import {AccountExecutor} from "../../src/account/AccountExecutor.sol"; import {PluginManagerInternals} from "../../src/account/PluginManagerInternals.sol"; import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol"; import {MultiOwnerModularAccountFactory} from "../../src/factory/MultiOwnerModularAccountFactory.sol"; import {IEntryPoint} from "../../src/interfaces/erc4337/IEntryPoint.sol"; -import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; import {IAccountInitializable} from "../../src/interfaces/IAccountInitializable.sol"; -import {IPlugin, PluginManifest} from "modular-account-libs/interfaces/IPlugin.sol"; -import {FunctionReference, IPluginManager} from "modular-account-libs/interfaces/IPluginManager.sol"; -import {Call} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import {IMultiOwnerPlugin} from "../../src/plugins/owner/IMultiOwnerPlugin.sol"; import {MultiOwnerPlugin} from "../../src/plugins/owner/MultiOwnerPlugin.sol"; import {SessionKeyPlugin} from "../../src/plugins/session/SessionKeyPlugin.sol"; diff --git a/test/account/UpgradeableModularAccountPluginManager.t.sol b/test/account/UpgradeableModularAccountPluginManager.t.sol index 05ad6d67..f0e871ff 100644 --- a/test/account/UpgradeableModularAccountPluginManager.t.sol +++ b/test/account/UpgradeableModularAccountPluginManager.t.sol @@ -21,19 +21,19 @@ import {Test} from "forge-std/Test.sol"; import {EntryPoint} from "@eth-infinitism/account-abstraction/core/EntryPoint.sol"; import {IPaymaster} from "@eth-infinitism/account-abstraction/interfaces/IPaymaster.sol"; -import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; - -import {PluginManagerInternals} from "../../src/account/PluginManagerInternals.sol"; -import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol"; -import {MultiOwnerModularAccountFactory} from "../../src/factory/MultiOwnerModularAccountFactory.sol"; -import {FunctionReferenceLib} from "modular-account-libs/libraries/FunctionReferenceLib.sol"; -import {IEntryPoint} from "../../src/interfaces/erc4337/IEntryPoint.sol"; import {IAccountLoupe} from "modular-account-libs/interfaces/IAccountLoupe.sol"; import {PluginManifest} from "modular-account-libs/interfaces/IPlugin.sol"; import {IPlugin, PluginManifest} from "modular-account-libs/interfaces/IPlugin.sol"; import {FunctionReference, IPluginManager} from "modular-account-libs/interfaces/IPluginManager.sol"; import {IStandardExecutor} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import {Call} from "modular-account-libs/interfaces/IStandardExecutor.sol"; +import {FunctionReferenceLib} from "modular-account-libs/libraries/FunctionReferenceLib.sol"; +import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; + +import {PluginManagerInternals} from "../../src/account/PluginManagerInternals.sol"; +import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol"; +import {MultiOwnerModularAccountFactory} from "../../src/factory/MultiOwnerModularAccountFactory.sol"; +import {IEntryPoint} from "../../src/interfaces/erc4337/IEntryPoint.sol"; import {IMultiOwnerPlugin} from "../../src/plugins/owner/IMultiOwnerPlugin.sol"; import {MultiOwnerPlugin} from "../../src/plugins/owner/MultiOwnerPlugin.sol"; import {SessionKeyPlugin} from "../../src/plugins/session/SessionKeyPlugin.sol"; diff --git a/test/account/ValidationIntersection.t.sol b/test/account/ValidationIntersection.t.sol index 8467fe6c..f810b4a3 100644 --- a/test/account/ValidationIntersection.t.sol +++ b/test/account/ValidationIntersection.t.sol @@ -18,15 +18,14 @@ pragma solidity ^0.8.22; import {Test} from "forge-std/Test.sol"; - import {EntryPoint} from "@eth-infinitism/account-abstraction/core/EntryPoint.sol"; +import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; +import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; +import {SIG_VALIDATION_FAILED, SIG_VALIDATION_PASSED} from "modular-account-libs/libraries/Constants.sol"; import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol"; import {MultiOwnerModularAccountFactory} from "../../src/factory/MultiOwnerModularAccountFactory.sol"; import {IEntryPoint} from "../../src/interfaces/erc4337/IEntryPoint.sol"; -import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; -import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; -import {SIG_VALIDATION_FAILED, SIG_VALIDATION_PASSED} from "modular-account-libs/libraries/Constants.sol"; import {MultiOwnerPlugin} from "../../src/plugins/owner/MultiOwnerPlugin.sol"; import { MockBaseUserOpValidationPlugin, diff --git a/test/account/phases/AccountStatePhases.t.sol b/test/account/phases/AccountStatePhases.t.sol index 08a226dc..0869c934 100644 --- a/test/account/phases/AccountStatePhases.t.sol +++ b/test/account/phases/AccountStatePhases.t.sol @@ -18,14 +18,8 @@ pragma solidity ^0.8.22; import {Test} from "forge-std/Test.sol"; - import {EntryPoint} from "@eth-infinitism/account-abstraction/core/EntryPoint.sol"; -import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; - -import {UpgradeableModularAccount} from "../../../src/account/UpgradeableModularAccount.sol"; -import {MultiOwnerModularAccountFactory} from "../../../src/factory/MultiOwnerModularAccountFactory.sol"; import {FunctionReferenceLib} from "modular-account-libs/libraries/FunctionReferenceLib.sol"; -import {IEntryPoint} from "../../../src/interfaces/erc4337/IEntryPoint.sol"; import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; import { IPlugin, @@ -37,6 +31,11 @@ import { } from "modular-account-libs/interfaces/IPlugin.sol"; import {FunctionReference, IPluginManager} from "modular-account-libs/interfaces/IPluginManager.sol"; import {IStandardExecutor, Call} from "modular-account-libs/interfaces/IStandardExecutor.sol"; +import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; + +import {UpgradeableModularAccount} from "../../../src/account/UpgradeableModularAccount.sol"; +import {MultiOwnerModularAccountFactory} from "../../../src/factory/MultiOwnerModularAccountFactory.sol"; +import {IEntryPoint} from "../../../src/interfaces/erc4337/IEntryPoint.sol"; import {MultiOwnerPlugin} from "../../../src/plugins/owner/MultiOwnerPlugin.sol"; import {MockPlugin} from "../../mocks/MockPlugin.sol"; import {AccountStateMutatingPlugin} from "../../mocks/plugins/AccountStateMutatingPlugin.sol"; diff --git a/test/account/phases/AccountStatePhasesExec.t.sol b/test/account/phases/AccountStatePhasesExec.t.sol index 1ea13323..b0b1f34f 100644 --- a/test/account/phases/AccountStatePhasesExec.t.sol +++ b/test/account/phases/AccountStatePhasesExec.t.sol @@ -27,6 +27,7 @@ import { } from "modular-account-libs/interfaces/IPlugin.sol"; import {IPluginManager} from "modular-account-libs/interfaces/IPluginManager.sol"; import {IStandardExecutor, Call} from "modular-account-libs/interfaces/IStandardExecutor.sol"; + import {MockPlugin} from "../../mocks/MockPlugin.sol"; import {AccountStateMutatingPlugin} from "../../mocks/plugins/AccountStateMutatingPlugin.sol"; import {AccountStatePhasesTest} from "./AccountStatePhases.t.sol"; diff --git a/test/account/phases/AccountStatePhasesRTValidation.t.sol b/test/account/phases/AccountStatePhasesRTValidation.t.sol index 72d8d127..2aba4954 100644 --- a/test/account/phases/AccountStatePhasesRTValidation.t.sol +++ b/test/account/phases/AccountStatePhasesRTValidation.t.sol @@ -17,10 +17,11 @@ pragma solidity ^0.8.22; -import {UpgradeableModularAccount} from "../../../src/account/UpgradeableModularAccount.sol"; import {IPlugin} from "modular-account-libs/interfaces/IPlugin.sol"; import {IPluginManager} from "modular-account-libs/interfaces/IPluginManager.sol"; import {IStandardExecutor, Call} from "modular-account-libs/interfaces/IStandardExecutor.sol"; + +import {UpgradeableModularAccount} from "../../../src/account/UpgradeableModularAccount.sol"; import {AccountStateMutatingPlugin} from "../../mocks/plugins/AccountStateMutatingPlugin.sol"; import {AccountStatePhasesTest} from "./AccountStatePhases.t.sol"; diff --git a/test/account/phases/AccountStatePhasesUOValidation.t.sol b/test/account/phases/AccountStatePhasesUOValidation.t.sol index 80584142..24768b0b 100644 --- a/test/account/phases/AccountStatePhasesUOValidation.t.sol +++ b/test/account/phases/AccountStatePhasesUOValidation.t.sol @@ -17,12 +17,11 @@ pragma solidity ^0.8.22; -import {AccountStatePhasesTest} from "./AccountStatePhases.t.sol"; - import {IPluginManager} from "modular-account-libs/interfaces/IPluginManager.sol"; import {IPlugin} from "modular-account-libs/interfaces/IPlugin.sol"; import {IStandardExecutor, Call} from "modular-account-libs/interfaces/IStandardExecutor.sol"; +import {AccountStatePhasesTest} from "./AccountStatePhases.t.sol"; import {AccountStateMutatingPlugin} from "../../mocks/plugins/AccountStateMutatingPlugin.sol"; // Tests the account state phase behavior when the source of the state modification diff --git a/test/comparison/CompareSimpleAccount.t.sol b/test/comparison/CompareSimpleAccount.t.sol index 36c0d91c..51abd020 100644 --- a/test/comparison/CompareSimpleAccount.t.sol +++ b/test/comparison/CompareSimpleAccount.t.sol @@ -22,10 +22,10 @@ import {Test} from "forge-std/Test.sol"; import {EntryPoint} from "@eth-infinitism/account-abstraction/core/EntryPoint.sol"; import {SimpleAccount} from "@eth-infinitism/account-abstraction/samples/SimpleAccount.sol"; import {SimpleAccountFactory} from "@eth-infinitism/account-abstraction/samples/SimpleAccountFactory.sol"; +import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import {IEntryPoint} from "../../src/interfaces/erc4337/IEntryPoint.sol"; -import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; import {Counter} from "../mocks/Counter.sol"; contract CompareSimpleAccountTest is Test { diff --git a/test/factory/MultiOwnerMAFactoryTest.t.sol b/test/factory/MultiOwnerMAFactoryTest.t.sol index 2f76a19c..5d9d510a 100644 --- a/test/factory/MultiOwnerMAFactoryTest.t.sol +++ b/test/factory/MultiOwnerMAFactoryTest.t.sol @@ -18,7 +18,6 @@ pragma solidity ^0.8.22; import {Test} from "forge-std/Test.sol"; - import {EntryPoint} from "@eth-infinitism/account-abstraction/core/EntryPoint.sol"; import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; diff --git a/test/helpers/KnownSelectors.t.sol b/test/helpers/KnownSelectors.t.sol index 637cc179..086efe40 100644 --- a/test/helpers/KnownSelectors.t.sol +++ b/test/helpers/KnownSelectors.t.sol @@ -18,10 +18,14 @@ pragma solidity ^0.8.22; import {Test} from "forge-std/Test.sol"; - import {BaseAccount} from "@eth-infinitism/account-abstraction/core/BaseAccount.sol"; import {IAggregator} from "@eth-infinitism/account-abstraction/interfaces/IAggregator.sol"; import {IPaymaster} from "@eth-infinitism/account-abstraction/interfaces/IPaymaster.sol"; +import {IAccountLoupe} from "modular-account-libs/interfaces/IAccountLoupe.sol"; +import {IPlugin} from "modular-account-libs/interfaces/IPlugin.sol"; +import {IPluginExecutor} from "modular-account-libs/interfaces/IPluginExecutor.sol"; +import {IPluginManager} from "modular-account-libs/interfaces/IPluginManager.sol"; +import {IStandardExecutor} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import {IERC1155Receiver} from "@openzeppelin/contracts/interfaces/IERC1155Receiver.sol"; import {IERC777Recipient} from "@openzeppelin/contracts/interfaces/IERC777Recipient.sol"; import {UUPSUpgradeable} from "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol"; @@ -30,11 +34,6 @@ import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import {KnownSelectors} from "../../src/helpers/KnownSelectors.sol"; import {IAccountInitializable} from "../../src/interfaces/IAccountInitializable.sol"; -import {IAccountLoupe} from "modular-account-libs/interfaces/IAccountLoupe.sol"; -import {IPlugin} from "modular-account-libs/interfaces/IPlugin.sol"; -import {IPluginExecutor} from "modular-account-libs/interfaces/IPluginExecutor.sol"; -import {IPluginManager} from "modular-account-libs/interfaces/IPluginManager.sol"; -import {IStandardExecutor} from "modular-account-libs/interfaces/IStandardExecutor.sol"; contract KnownSelectorsTest is Test { function test_isNativeFunction() public { diff --git a/test/mocks/MockPlugin.sol b/test/mocks/MockPlugin.sol index f58c52a5..92710ab1 100644 --- a/test/mocks/MockPlugin.sol +++ b/test/mocks/MockPlugin.sol @@ -17,9 +17,8 @@ pragma solidity ^0.8.22; -import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol"; - import {PluginManifest, PluginMetadata, IPlugin} from "modular-account-libs/interfaces/IPlugin.sol"; +import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol"; contract MockPlugin is ERC165 { // It's super inefficient to hold the entire abi-encoded manifest in storage, but this is fine since it's diff --git a/test/mocks/plugins/AccountStateMutatingPlugin.sol b/test/mocks/plugins/AccountStateMutatingPlugin.sol index 84691b6c..89438ca2 100644 --- a/test/mocks/plugins/AccountStateMutatingPlugin.sol +++ b/test/mocks/plugins/AccountStateMutatingPlugin.sol @@ -25,6 +25,7 @@ import { ManifestAssociatedFunctionType, ManifestAssociatedFunction } from "modular-account-libs/interfaces/IPlugin.sol"; + import {BaseTestPlugin} from "./BaseTestPlugin.sol"; // Used in conjunction with AccountStatePhasesTest to verify that the account state is consistent when plugins are diff --git a/test/mocks/plugins/BadTransferOwnershipPlugin.sol b/test/mocks/plugins/BadTransferOwnershipPlugin.sol index dee885a0..bfdd5814 100644 --- a/test/mocks/plugins/BadTransferOwnershipPlugin.sol +++ b/test/mocks/plugins/BadTransferOwnershipPlugin.sol @@ -27,6 +27,7 @@ import { } from "modular-account-libs/interfaces/IPlugin.sol"; import {IPluginExecutor} from "modular-account-libs/interfaces/IPluginExecutor.sol"; import {IStandardExecutor} from "modular-account-libs/interfaces/IStandardExecutor.sol"; + import {IMultiOwnerPlugin} from "../../../src/plugins/owner/IMultiOwnerPlugin.sol"; import {BaseTestPlugin} from "./BaseTestPlugin.sol"; diff --git a/test/mocks/plugins/BaseTestPlugin.sol b/test/mocks/plugins/BaseTestPlugin.sol index 07fcb80c..c8116c01 100644 --- a/test/mocks/plugins/BaseTestPlugin.sol +++ b/test/mocks/plugins/BaseTestPlugin.sol @@ -18,6 +18,7 @@ pragma solidity ^0.8.22; import {PluginMetadata} from "modular-account-libs/interfaces/IPlugin.sol"; + import {BasePlugin} from "../../../src/plugins/BasePlugin.sol"; contract BaseTestPlugin is BasePlugin { diff --git a/test/mocks/plugins/ComprehensivePlugin.sol b/test/mocks/plugins/ComprehensivePlugin.sol index 6512510d..05c19588 100644 --- a/test/mocks/plugins/ComprehensivePlugin.sol +++ b/test/mocks/plugins/ComprehensivePlugin.sol @@ -27,6 +27,7 @@ import { PluginMetadata } from "modular-account-libs/interfaces/IPlugin.sol"; import {IStandardExecutor} from "modular-account-libs/interfaces/IStandardExecutor.sol"; + import {BaseTestPlugin} from "./BaseTestPlugin.sol"; contract ComprehensivePlugin is BaseTestPlugin { diff --git a/test/mocks/plugins/ExecFromPluginPermissionsMocks.sol b/test/mocks/plugins/ExecFromPluginPermissionsMocks.sol index f7d48ef9..26d7088a 100644 --- a/test/mocks/plugins/ExecFromPluginPermissionsMocks.sol +++ b/test/mocks/plugins/ExecFromPluginPermissionsMocks.sol @@ -29,6 +29,7 @@ import {IPlugin} from "modular-account-libs/interfaces/IPlugin.sol"; import {IPluginExecutor} from "modular-account-libs/interfaces/IPluginExecutor.sol"; import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; import {IStandardExecutor} from "modular-account-libs/interfaces/IStandardExecutor.sol"; + import {Counter} from "../Counter.sol"; import {BaseTestPlugin} from "./BaseTestPlugin.sol"; import {ResultCreatorPlugin} from "./ReturnDataPluginMocks.sol"; diff --git a/test/mocks/plugins/ManifestValidityMocks.sol b/test/mocks/plugins/ManifestValidityMocks.sol index 59105aa7..238d88e6 100644 --- a/test/mocks/plugins/ManifestValidityMocks.sol +++ b/test/mocks/plugins/ManifestValidityMocks.sol @@ -29,6 +29,7 @@ import {IPlugin} from "modular-account-libs/interfaces/IPlugin.sol"; import {IPluginExecutor} from "modular-account-libs/interfaces/IPluginExecutor.sol"; import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; import {IStandardExecutor} from "modular-account-libs/interfaces/IStandardExecutor.sol"; + import {BaseTestPlugin} from "./BaseTestPlugin.sol"; contract BadValidationMagicValue_UserOp_Plugin is BaseTestPlugin { diff --git a/test/mocks/plugins/ReturnDataPluginMocks.sol b/test/mocks/plugins/ReturnDataPluginMocks.sol index ecb075cf..254ceb19 100644 --- a/test/mocks/plugins/ReturnDataPluginMocks.sol +++ b/test/mocks/plugins/ReturnDataPluginMocks.sol @@ -28,6 +28,7 @@ import {IPlugin} from "modular-account-libs/interfaces/IPlugin.sol"; import {IPluginExecutor} from "modular-account-libs/interfaces/IPluginExecutor.sol"; import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; import {IStandardExecutor} from "modular-account-libs/interfaces/IStandardExecutor.sol"; + import {BaseTestPlugin} from "./BaseTestPlugin.sol"; contract RegularResultContract { diff --git a/test/mocks/plugins/UninstallErrorsPlugin.sol b/test/mocks/plugins/UninstallErrorsPlugin.sol index 9271ec6f..894469ee 100644 --- a/test/mocks/plugins/UninstallErrorsPlugin.sol +++ b/test/mocks/plugins/UninstallErrorsPlugin.sol @@ -17,8 +17,6 @@ pragma solidity ^0.8.22; -import {StorageSlot} from "@openzeppelin/contracts/utils/StorageSlot.sol"; - import { ManifestFunction, ManifestAssociatedFunctionType, @@ -26,6 +24,8 @@ import { PluginManifest, PluginMetadata } from "modular-account-libs/interfaces/IPlugin.sol"; +import {StorageSlot} from "@openzeppelin/contracts/utils/StorageSlot.sol"; + import {BaseTestPlugin} from "./BaseTestPlugin.sol"; /// Mock plugin that reverts in its uninstall callbacks. Can be configured to diff --git a/test/mocks/plugins/ValidationPluginMocks.sol b/test/mocks/plugins/ValidationPluginMocks.sol index 145d1ec1..09369093 100644 --- a/test/mocks/plugins/ValidationPluginMocks.sol +++ b/test/mocks/plugins/ValidationPluginMocks.sol @@ -24,6 +24,7 @@ import { ManifestAssociatedFunction, PluginManifest } from "modular-account-libs/interfaces/IPlugin.sol"; + import {BaseTestPlugin} from "./BaseTestPlugin.sol"; abstract contract MockBaseUserOpValidationPlugin is BaseTestPlugin { diff --git a/test/plugin/owner/MultiOwnerPlugin.t.sol b/test/plugin/owner/MultiOwnerPlugin.t.sol index ad476f53..8a606a3c 100644 --- a/test/plugin/owner/MultiOwnerPlugin.t.sol +++ b/test/plugin/owner/MultiOwnerPlugin.t.sol @@ -18,13 +18,12 @@ pragma solidity ^0.8.22; import {Test} from "forge-std/Test.sol"; - import {EntryPoint} from "@eth-infinitism/account-abstraction/core/EntryPoint.sol"; +import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; +import {PluginManifest} from "modular-account-libs/interfaces/IPlugin.sol"; import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import {IEntryPoint} from "../../../src/interfaces/erc4337/IEntryPoint.sol"; -import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; -import {PluginManifest} from "modular-account-libs/interfaces/IPlugin.sol"; import {BasePlugin} from "../../../src/plugins/BasePlugin.sol"; import {IMultiOwnerPlugin} from "../../../src/plugins/owner/IMultiOwnerPlugin.sol"; import {MultiOwnerPlugin} from "../../../src/plugins/owner/MultiOwnerPlugin.sol"; diff --git a/test/plugin/owner/MultiOwnerPluginIntegration.t.sol b/test/plugin/owner/MultiOwnerPluginIntegration.t.sol index 5b019e54..b04e130b 100644 --- a/test/plugin/owner/MultiOwnerPluginIntegration.t.sol +++ b/test/plugin/owner/MultiOwnerPluginIntegration.t.sol @@ -18,17 +18,16 @@ pragma solidity ^0.8.22; import {Test} from "forge-std/Test.sol"; - import {EntryPoint} from "@eth-infinitism/account-abstraction/core/EntryPoint.sol"; +import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; +import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; +import {Call} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import {IERC1271} from "@openzeppelin/contracts/interfaces/IERC1271.sol"; import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import {UpgradeableModularAccount} from "../../../src/account/UpgradeableModularAccount.sol"; import {MultiOwnerModularAccountFactory} from "../../../src/factory/MultiOwnerModularAccountFactory.sol"; import {IEntryPoint} from "../../../src/interfaces/erc4337/IEntryPoint.sol"; -import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; -import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; -import {Call} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import {IMultiOwnerPlugin} from "../../../src/plugins/owner/IMultiOwnerPlugin.sol"; import {MultiOwnerPlugin} from "../../../src/plugins/owner/MultiOwnerPlugin.sol"; import {Counter} from "../../mocks/Counter.sol"; diff --git a/test/plugin/session/SessionKeyPluginWithMultiOwner.t.sol b/test/plugin/session/SessionKeyPluginWithMultiOwner.t.sol index bd0cb7aa..cd1c3426 100644 --- a/test/plugin/session/SessionKeyPluginWithMultiOwner.t.sol +++ b/test/plugin/session/SessionKeyPluginWithMultiOwner.t.sol @@ -18,19 +18,18 @@ pragma solidity ^0.8.22; import {Test} from "forge-std/Test.sol"; - import {EntryPoint} from "@eth-infinitism/account-abstraction/core/EntryPoint.sol"; +import {FunctionReferenceLib} from "modular-account-libs/libraries/FunctionReferenceLib.sol"; +import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; +import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; +import {Call} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import {ISessionKeyPermissionsUpdates} from "../../../src/plugins/session/permissions/ISessionKeyPermissionsUpdates.sol"; import {UpgradeableModularAccount} from "../../../src/account/UpgradeableModularAccount.sol"; import {MultiOwnerModularAccountFactory} from "../../../src/factory/MultiOwnerModularAccountFactory.sol"; -import {FunctionReferenceLib} from "modular-account-libs/libraries/FunctionReferenceLib.sol"; import {IEntryPoint} from "../../../src/interfaces/erc4337/IEntryPoint.sol"; -import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; -import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; -import {Call} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import {BasePlugin} from "../../../src/plugins/BasePlugin.sol"; import {IMultiOwnerPlugin} from "../../../src/plugins/owner/IMultiOwnerPlugin.sol"; import {MultiOwnerPlugin} from "../../../src/plugins/owner/MultiOwnerPlugin.sol"; diff --git a/test/plugin/session/permissions/SessionKeyERC20SpendLimits.t.sol b/test/plugin/session/permissions/SessionKeyERC20SpendLimits.t.sol index 0865df74..7082d516 100644 --- a/test/plugin/session/permissions/SessionKeyERC20SpendLimits.t.sol +++ b/test/plugin/session/permissions/SessionKeyERC20SpendLimits.t.sol @@ -18,19 +18,18 @@ pragma solidity ^0.8.22; import {Test, console} from "forge-std/Test.sol"; - import {EntryPoint} from "@eth-infinitism/account-abstraction/core/EntryPoint.sol"; +import {FunctionReferenceLib} from "modular-account-libs/libraries/FunctionReferenceLib.sol"; +import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; +import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; +import {Call} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import {ISessionKeyPermissionsUpdates} from "../../../../src/plugins/session/permissions/ISessionKeyPermissionsUpdates.sol"; import {UpgradeableModularAccount} from "../../../../src/account/UpgradeableModularAccount.sol"; import {MultiOwnerModularAccountFactory} from "../../../../src/factory/MultiOwnerModularAccountFactory.sol"; -import {FunctionReferenceLib} from "modular-account-libs/libraries/FunctionReferenceLib.sol"; import {IEntryPoint} from "../../../../src/interfaces/erc4337/IEntryPoint.sol"; -import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; -import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; -import {Call} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import {IMultiOwnerPlugin} from "../../../../src/plugins/owner/IMultiOwnerPlugin.sol"; import {MultiOwnerPlugin} from "../../../../src/plugins/owner/MultiOwnerPlugin.sol"; import {ISessionKeyPlugin} from "../../../../src/plugins/session/ISessionKeyPlugin.sol"; diff --git a/test/plugin/session/permissions/SessionKeyGasLimits.t.sol b/test/plugin/session/permissions/SessionKeyGasLimits.t.sol index 96549ff9..7d1d686e 100644 --- a/test/plugin/session/permissions/SessionKeyGasLimits.t.sol +++ b/test/plugin/session/permissions/SessionKeyGasLimits.t.sol @@ -18,19 +18,18 @@ pragma solidity ^0.8.22; import {Test, console} from "forge-std/Test.sol"; - import {EntryPoint} from "@eth-infinitism/account-abstraction/core/EntryPoint.sol"; +import {FunctionReferenceLib} from "modular-account-libs/libraries/FunctionReferenceLib.sol"; +import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; +import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; +import {Call} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import {ISessionKeyPermissionsUpdates} from "../../../../src/plugins/session/permissions/ISessionKeyPermissionsUpdates.sol"; import {UpgradeableModularAccount} from "../../../../src/account/UpgradeableModularAccount.sol"; import {MultiOwnerModularAccountFactory} from "../../../../src/factory/MultiOwnerModularAccountFactory.sol"; -import {FunctionReferenceLib} from "modular-account-libs/libraries/FunctionReferenceLib.sol"; import {IEntryPoint} from "../../../../src/interfaces/erc4337/IEntryPoint.sol"; -import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; -import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; -import {Call} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import {IMultiOwnerPlugin} from "../../../../src/plugins/owner/IMultiOwnerPlugin.sol"; import {MultiOwnerPlugin} from "../../../../src/plugins/owner/MultiOwnerPlugin.sol"; import {ISessionKeyPlugin} from "../../../../src/plugins/session/ISessionKeyPlugin.sol"; diff --git a/test/plugin/session/permissions/SessionKeyNativeTokenSpendLimits.t.sol b/test/plugin/session/permissions/SessionKeyNativeTokenSpendLimits.t.sol index c1b762fd..46486638 100644 --- a/test/plugin/session/permissions/SessionKeyNativeTokenSpendLimits.t.sol +++ b/test/plugin/session/permissions/SessionKeyNativeTokenSpendLimits.t.sol @@ -18,19 +18,18 @@ pragma solidity ^0.8.22; import {Test, console} from "forge-std/Test.sol"; - import {EntryPoint} from "@eth-infinitism/account-abstraction/core/EntryPoint.sol"; +import {FunctionReferenceLib} from "modular-account-libs/libraries/FunctionReferenceLib.sol"; +import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; +import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; +import {Call} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import {ISessionKeyPermissionsUpdates} from "../../../../src/plugins/session/permissions/ISessionKeyPermissionsUpdates.sol"; import {UpgradeableModularAccount} from "../../../../src/account/UpgradeableModularAccount.sol"; import {MultiOwnerModularAccountFactory} from "../../../../src/factory/MultiOwnerModularAccountFactory.sol"; -import {FunctionReferenceLib} from "modular-account-libs/libraries/FunctionReferenceLib.sol"; import {IEntryPoint} from "../../../../src/interfaces/erc4337/IEntryPoint.sol"; -import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; -import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; -import {Call} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import {IMultiOwnerPlugin} from "../../../../src/plugins/owner/IMultiOwnerPlugin.sol"; import {MultiOwnerPlugin} from "../../../../src/plugins/owner/MultiOwnerPlugin.sol"; import {ISessionKeyPlugin} from "../../../../src/plugins/session/ISessionKeyPlugin.sol"; diff --git a/test/plugin/session/permissions/SessionKeyPermissions.t.sol b/test/plugin/session/permissions/SessionKeyPermissions.t.sol index 4033988b..56e26dbb 100644 --- a/test/plugin/session/permissions/SessionKeyPermissions.t.sol +++ b/test/plugin/session/permissions/SessionKeyPermissions.t.sol @@ -18,19 +18,18 @@ pragma solidity ^0.8.22; import {Test} from "forge-std/Test.sol"; - import {EntryPoint} from "@eth-infinitism/account-abstraction/core/EntryPoint.sol"; +import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; +import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; +import {Call} from "modular-account-libs/interfaces/IStandardExecutor.sol"; +import {FunctionReferenceLib} from "modular-account-libs/libraries/FunctionReferenceLib.sol"; import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import {ISessionKeyPermissionsUpdates} from "../../../../src/plugins/session/permissions/ISessionKeyPermissionsUpdates.sol"; import {UpgradeableModularAccount} from "../../../../src/account/UpgradeableModularAccount.sol"; import {MultiOwnerModularAccountFactory} from "../../../../src/factory/MultiOwnerModularAccountFactory.sol"; -import {FunctionReferenceLib} from "modular-account-libs/libraries/FunctionReferenceLib.sol"; import {IEntryPoint} from "../../../../src/interfaces/erc4337/IEntryPoint.sol"; -import {UserOperation} from "modular-account-libs/interfaces/UserOperation.sol"; -import {FunctionReference} from "modular-account-libs/interfaces/IPluginManager.sol"; -import {Call} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import {IMultiOwnerPlugin} from "../../../../src/plugins/owner/IMultiOwnerPlugin.sol"; import {MultiOwnerPlugin} from "../../../../src/plugins/owner/MultiOwnerPlugin.sol"; import {ISessionKeyPlugin} from "../../../../src/plugins/session/ISessionKeyPlugin.sol"; diff --git a/test/upgrade/LightAccountToModularAccount.t.sol b/test/upgrade/LightAccountToModularAccount.t.sol index 8298006d..3b5ddcb9 100644 --- a/test/upgrade/LightAccountToModularAccount.t.sol +++ b/test/upgrade/LightAccountToModularAccount.t.sol @@ -18,7 +18,6 @@ pragma solidity ^0.8.22; import {Test} from "forge-std/Test.sol"; - import {LightAccount} from "@alchemy/light-account/src/LightAccount.sol"; import {LightAccountFactory} from "@alchemy/light-account/src/LightAccountFactory.sol"; import {EntryPoint} from "@eth-infinitism/account-abstraction/core/EntryPoint.sol"; diff --git a/test/upgrade/MAToMA.t.sol b/test/upgrade/MAToMA.t.sol index b4c7c078..2d8ced61 100644 --- a/test/upgrade/MAToMA.t.sol +++ b/test/upgrade/MAToMA.t.sol @@ -18,13 +18,12 @@ pragma solidity ^0.8.22; import {Test} from "forge-std/Test.sol"; - import {EntryPoint} from "@eth-infinitism/account-abstraction/core/EntryPoint.sol"; +import {Call} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import {UpgradeableModularAccount} from "../../src/account/UpgradeableModularAccount.sol"; import {MultiOwnerModularAccountFactory} from "../../src/factory/MultiOwnerModularAccountFactory.sol"; import {IEntryPoint} from "../../src/interfaces/erc4337/IEntryPoint.sol"; -import {Call} from "modular-account-libs/interfaces/IStandardExecutor.sol"; import {MultiOwnerPlugin} from "../../src/plugins/owner/MultiOwnerPlugin.sol"; import {MockERC20} from "../mocks/tokens/MockERC20.sol"; import {Utils} from "../Utils.sol"; From cefec12c3a2a6e68af576b9f9681c9571c7489a6 Mon Sep 17 00:00:00 2001 From: zer0dot Date: Sat, 11 May 2024 02:00:20 +0800 Subject: [PATCH 4/6] misc: Update CI to install dependencies with pnpm --- .github/workflows/test.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1bf9412d..7fc4970e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -73,6 +73,20 @@ jobs: - name: Install forge dependencies run: forge install + - name: "Install Pnpm" + uses: "pnpm/action-setup@v2" + with: + version: "8" + + # - name: "Install Node.js" + # uses: "actions/setup-node@v3" + # with: + # cache: "pnpm" + # node-version: "lts/*" + + - name: "Install Node.js dependencies" + run: "pnpm install" + - name: Build project run: forge build --sizes @@ -94,6 +108,20 @@ jobs: - name: Install forge dependencies run: forge install + - name: "Install Pnpm" + uses: "pnpm/action-setup@v2" + with: + version: "8" + + # - name: "Install Node.js" + # uses: "actions/setup-node@v3" + # with: + # cache: "pnpm" + # node-version: "lts/*" + + - name: "Install Node.js dependencies" + run: "pnpm install" + - name: Build project run: FOUNDRY_PROFILE=lite forge build From 84d1a4afd08376ab4be64a2723ce7a510994af62 Mon Sep 17 00:00:00 2001 From: zer0dot Date: Sat, 11 May 2024 02:16:04 +0800 Subject: [PATCH 5/6] misc: Removed unneeded comments --- .github/workflows/test.yml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7fc4970e..489e4df1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -78,12 +78,6 @@ jobs: with: version: "8" - # - name: "Install Node.js" - # uses: "actions/setup-node@v3" - # with: - # cache: "pnpm" - # node-version: "lts/*" - - name: "Install Node.js dependencies" run: "pnpm install" @@ -113,12 +107,6 @@ jobs: with: version: "8" - # - name: "Install Node.js" - # uses: "actions/setup-node@v3" - # with: - # cache: "pnpm" - # node-version: "lts/*" - - name: "Install Node.js dependencies" run: "pnpm install" From fc61502d41339b33b63c48af6f2180dad52ed031 Mon Sep 17 00:00:00 2001 From: zer0dot Date: Sat, 11 May 2024 02:20:36 +0800 Subject: [PATCH 6/6] misc: Removed unneeded test --- test/invariant/LLSLRepro.t.sol | 55 ---------------------------------- 1 file changed, 55 deletions(-) delete mode 100644 test/invariant/LLSLRepro.t.sol diff --git a/test/invariant/LLSLRepro.t.sol b/test/invariant/LLSLRepro.t.sol deleted file mode 100644 index f67d9383..00000000 --- a/test/invariant/LLSLRepro.t.sol +++ /dev/null @@ -1,55 +0,0 @@ -// This file is part of Modular Account. -// -// Copyright 2024 Alchemy Insights, Inc. -// -// SPDX-License-Identifier: GPL-3.0-or-later -// -// This program is free software: you can redistribute it and/or modify it under the terms of the GNU General -// Public License as published by the Free Software Foundation, either version 3 of the License, or (at your -// option) any later version. -// -// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the -// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -// more details. -// -// You should have received a copy of the GNU General Public License along with this program. If not, see -// . - -pragma solidity ^0.8.22; - -import {Test} from "forge-std/Test.sol"; - -import {AssociatedLinkedListSetHandler} from - "node_modules/modular-account-libs/test/invariant/handlers/AssociatedLinkedListSetHandler.sol"; -import {LinkedListSetHandler} from - "node_modules/modular-account-libs/test/invariant/handlers/LinkedListSetHandler.sol"; - -contract LLSLReproTest is Test { - LinkedListSetHandler public handler; - AssociatedLinkedListSetHandler public associatedHandler; - - function setUp() public { - handler = new LinkedListSetHandler(); - associatedHandler = new AssociatedLinkedListSetHandler(); - } - - function test_repro_1() public { - handler.removeRandKeyIterate(0); - handler.add(0xeeeb07e4676e566803e52fe9a102d0fe0c0ae5007215518bffb33d6c07e2); - handler.removeRandKnownPrevKey( - 0xeeeb07e4676e566803e52fe9a102d0fe0c0ae5007215518bffb33d6c07e2, - 0x0000000000000000000000000000000000000000000000000000000000001b01 - ); - } - - function test_repro_2() public { - associatedHandler.removeRandKeyIterate(0, 0, 0); - associatedHandler.add(0xeeeb07e4676e566803e52fe9a102d0fe0c0ae5007215518bffb33d6c07e2, 0, 0); - associatedHandler.removeRandKnownPrevKey( - 0xeeeb07e4676e566803e52fe9a102d0fe0c0ae5007215518bffb33d6c07e2, - 0x0000000000000000000000000000000000000000000000000000000000001b01, - 0, - 0 - ); - } -}