From d24b4addea899d7503ad64d3f4ca700041031de6 Mon Sep 17 00:00:00 2001 From: zeroknots Date: Mon, 19 Feb 2024 21:08:45 +0700 Subject: [PATCH] docs: adding nods --- .github/workflows/ci.yaml | 2 +- .github/workflows/slither.yaml | 8 + docs/.gitignore | 1 + docs/book.css | 13 + docs/book.toml | 12 + docs/solidity.min.js | 74 ++ docs/src/README.md | 111 +++ docs/src/SUMMARY.md | 51 ++ docs/src/src/Common.sol/constants.Common.md | 45 ++ .../src/Common.sol/function._isContract.md | 22 + docs/src/src/Common.sol/function._time.md | 11 + .../function.attestationDataRefEq.md | 8 + .../DataTypes.sol/function.moduleTypeEq.md | 8 + .../DataTypes.sol/function.moduleTypeNeq.md | 8 + .../src/DataTypes.sol/function.resolverEq.md | 8 + .../DataTypes.sol/function.resolverNotEq.md | 8 + .../src/DataTypes.sol/function.schemaEq.md | 8 + .../src/DataTypes.sol/function.schemaNotEq.md | 8 + .../DataTypes.sol/struct.AttestationRecord.md | 17 + .../struct.AttestationRequest.md | 15 + .../src/DataTypes.sol/struct.ModuleRecord.md | 12 + .../DataTypes.sol/struct.ResolverRecord.md | 11 + .../DataTypes.sol/struct.RevocationRequest.md | 12 + .../src/DataTypes.sol/struct.SchemaRecord.md | 12 + .../struct.TrustedAttesterRecord.md | 13 + .../DataTypes.sol/type.AttestationDataRef.md | 8 + docs/src/src/DataTypes.sol/type.ModuleType.md | 8 + .../DataTypes.sol/type.PackedModuleTypes.md | 8 + .../src/src/DataTypes.sol/type.ResolverUID.md | 8 + docs/src/src/DataTypes.sol/type.SchemaUID.md | 8 + .../src/IRegistry.sol/interface.IERC7484.md | 47 ++ .../src/IRegistry.sol/interface.IRegistry.md | 645 ++++++++++++++++++ docs/src/src/README.md | 31 + .../src/src/Registry.sol/contract.Registry.md | 10 + .../Attestation.sol/abstract.Attestation.md | 102 +++ .../abstract.AttestationManager.md | 146 ++++ .../abstract.ModuleManager.md | 145 ++++ docs/src/src/core/README.md | 11 + .../abstract.ResolverManager.md | 108 +++ .../abstract.SchemaManager.md | 69 ++ .../contract.SignedAttestation.md | 137 ++++ .../TrustManager.sol/abstract.TrustManager.md | 121 ++++ ...stract.TrustManagerExternalAttesterList.md | 33 + .../interface.IExternalResolver.md | 91 +++ .../interface.IExternalSchemaValidator.md | 26 + docs/src/src/external/README.md | 6 + .../contract.ERC7512SchemaValidator.md | 29 + .../ERC7512Schema.sol/interface.ERC7512.md | 66 ++ docs/src/src/external/examples/README.md | 7 + .../ResolverBase.sol/abstract.ResolverBase.md | 30 + .../contract.TokenizedResolver.md | 81 +++ .../library.AttestationLib.md | 72 ++ .../src/src/lib/Helpers.sol/library.UIDLib.md | 47 ++ .../library.ModuleDeploymentLib.md | 69 ++ .../library.ModuleTypeLib.md | 26 + docs/src/src/lib/README.md | 8 + .../src/lib/StubLib.sol/library.StubLib.md | 80 +++ foundry.toml | 3 + slither.config.json | 9 + src/core/AttestationManager.sol | 3 + 60 files changed, 2795 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/slither.yaml create mode 100644 docs/.gitignore create mode 100644 docs/book.css create mode 100644 docs/book.toml create mode 100644 docs/solidity.min.js create mode 100644 docs/src/README.md create mode 100644 docs/src/SUMMARY.md create mode 100644 docs/src/src/Common.sol/constants.Common.md create mode 100644 docs/src/src/Common.sol/function._isContract.md create mode 100644 docs/src/src/Common.sol/function._time.md create mode 100644 docs/src/src/DataTypes.sol/function.attestationDataRefEq.md create mode 100644 docs/src/src/DataTypes.sol/function.moduleTypeEq.md create mode 100644 docs/src/src/DataTypes.sol/function.moduleTypeNeq.md create mode 100644 docs/src/src/DataTypes.sol/function.resolverEq.md create mode 100644 docs/src/src/DataTypes.sol/function.resolverNotEq.md create mode 100644 docs/src/src/DataTypes.sol/function.schemaEq.md create mode 100644 docs/src/src/DataTypes.sol/function.schemaNotEq.md create mode 100644 docs/src/src/DataTypes.sol/struct.AttestationRecord.md create mode 100644 docs/src/src/DataTypes.sol/struct.AttestationRequest.md create mode 100644 docs/src/src/DataTypes.sol/struct.ModuleRecord.md create mode 100644 docs/src/src/DataTypes.sol/struct.ResolverRecord.md create mode 100644 docs/src/src/DataTypes.sol/struct.RevocationRequest.md create mode 100644 docs/src/src/DataTypes.sol/struct.SchemaRecord.md create mode 100644 docs/src/src/DataTypes.sol/struct.TrustedAttesterRecord.md create mode 100644 docs/src/src/DataTypes.sol/type.AttestationDataRef.md create mode 100644 docs/src/src/DataTypes.sol/type.ModuleType.md create mode 100644 docs/src/src/DataTypes.sol/type.PackedModuleTypes.md create mode 100644 docs/src/src/DataTypes.sol/type.ResolverUID.md create mode 100644 docs/src/src/DataTypes.sol/type.SchemaUID.md create mode 100644 docs/src/src/IRegistry.sol/interface.IERC7484.md create mode 100644 docs/src/src/IRegistry.sol/interface.IRegistry.md create mode 100644 docs/src/src/README.md create mode 100644 docs/src/src/Registry.sol/contract.Registry.md create mode 100644 docs/src/src/core/Attestation.sol/abstract.Attestation.md create mode 100644 docs/src/src/core/AttestationManager.sol/abstract.AttestationManager.md create mode 100644 docs/src/src/core/ModuleManager.sol/abstract.ModuleManager.md create mode 100644 docs/src/src/core/README.md create mode 100644 docs/src/src/core/ResolverManager.sol/abstract.ResolverManager.md create mode 100644 docs/src/src/core/SchemaManager.sol/abstract.SchemaManager.md create mode 100644 docs/src/src/core/SignedAttestation.sol/contract.SignedAttestation.md create mode 100644 docs/src/src/core/TrustManager.sol/abstract.TrustManager.md create mode 100644 docs/src/src/core/TrustManagerExternalAttesterList.sol/abstract.TrustManagerExternalAttesterList.md create mode 100644 docs/src/src/external/IExternalResolver.sol/interface.IExternalResolver.md create mode 100644 docs/src/src/external/IExternalSchemaValidator.sol/interface.IExternalSchemaValidator.md create mode 100644 docs/src/src/external/README.md create mode 100644 docs/src/src/external/examples/ERC7512Schema.sol/contract.ERC7512SchemaValidator.md create mode 100644 docs/src/src/external/examples/ERC7512Schema.sol/interface.ERC7512.md create mode 100644 docs/src/src/external/examples/README.md create mode 100644 docs/src/src/external/examples/ResolverBase.sol/abstract.ResolverBase.md create mode 100644 docs/src/src/external/examples/TokenizedResolver.sol/contract.TokenizedResolver.md create mode 100644 docs/src/src/lib/AttestationLib.sol/library.AttestationLib.md create mode 100644 docs/src/src/lib/Helpers.sol/library.UIDLib.md create mode 100644 docs/src/src/lib/ModuleDeploymentLib.sol/library.ModuleDeploymentLib.md create mode 100644 docs/src/src/lib/ModuleTypeLib.sol/library.ModuleTypeLib.md create mode 100644 docs/src/src/lib/README.md create mode 100644 docs/src/src/lib/StubLib.sol/library.StubLib.md create mode 100644 slither.config.json diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 44450bfc..99bb03c0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -10,7 +10,7 @@ jobs: uses: "rhinestonewtf/reusable-workflows/.github/workflows/forge-build.yaml@main" test-unit: - needs: ["build"] + needs: ["lint", "build"] uses: "rhinestonewtf/reusable-workflows/.github/workflows/forge-test.yaml@main" with: foundry-fuzz-runs: 5000 diff --git a/.github/workflows/slither.yaml b/.github/workflows/slither.yaml new file mode 100644 index 00000000..47e01e81 --- /dev/null +++ b/.github/workflows/slither.yaml @@ -0,0 +1,8 @@ +name: Slither Analysis +on: [push] +jobs: + analyze: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: crytic/slither-action@v0.3.1 diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 00000000..4e42a1bc --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1 @@ +book/ \ No newline at end of file diff --git a/docs/book.css b/docs/book.css new file mode 100644 index 00000000..b5ce903f --- /dev/null +++ b/docs/book.css @@ -0,0 +1,13 @@ +table { + margin: 0 auto; + border-collapse: collapse; + width: 100%; +} + +table td:first-child { + width: 15%; +} + +table td:nth-child(2) { + width: 25%; +} \ No newline at end of file diff --git a/docs/book.toml b/docs/book.toml new file mode 100644 index 00000000..50520fda --- /dev/null +++ b/docs/book.toml @@ -0,0 +1,12 @@ +[book] +src = "src" +title = "Rhinestone Registry" + +[output.html] +no-section-label = true +additional-js = ["solidity.min.js"] +additional-css = ["book.css"] +git-repository-url = "https://github.com/rhinestonewtf/registry" + +[output.html.fold] +enable = true diff --git a/docs/solidity.min.js b/docs/solidity.min.js new file mode 100644 index 00000000..19249329 --- /dev/null +++ b/docs/solidity.min.js @@ -0,0 +1,74 @@ +hljs.registerLanguage("solidity",(()=>{"use strict";function e(){try{return!0 +}catch(e){return!1}} +var a=/-?(\b0[xX]([a-fA-F0-9]_?)*[a-fA-F0-9]|(\b[1-9](_?\d)*(\.((\d_?)*\d)?)?|\.\d(_?\d)*)([eE][-+]?\d(_?\d)*)?|\b0)(?!\w|\$)/ +;e()&&(a=a.source.replace(/\\b/g,"(?{ +var a=r(e),o=l(e),c=/[A-Za-z_$][A-Za-z_$0-9.]*/,d=e.inherit(e.TITLE_MODE,{ +begin:/[A-Za-z$_][0-9A-Za-z$_]*/,lexemes:c,keywords:n}),u={className:"params", +begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,lexemes:c,keywords:n, +contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,a,o,s]},_={ +className:"operator",begin:/:=|->/};return{keywords:n,lexemes:c, +contains:[a,o,i,t,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,s,_,{ +className:"function",lexemes:c,beginKeywords:"function",end:"{",excludeEnd:!0, +contains:[d,u,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,_]}]}}, +solAposStringMode:r,solQuoteStringMode:l,HEX_APOS_STRING_MODE:i, +HEX_QUOTE_STRING_MODE:t,SOL_NUMBER:s,isNegativeLookbehindAvailable:e} +;const{baseAssembly:c,solAposStringMode:d,solQuoteStringMode:u,HEX_APOS_STRING_MODE:_,HEX_QUOTE_STRING_MODE:m,SOL_NUMBER:b,isNegativeLookbehindAvailable:E}=o +;return e=>{for(var a=d(e),s=u(e),n=[],i=0;i<32;i++)n[i]=i+1 +;var t=n.map((e=>8*e)),r=[];for(i=0;i<=80;i++)r[i]=i +;var l=n.map((e=>"bytes"+e)).join(" ")+" ",o=t.map((e=>"uint"+e)).join(" ")+" ",g=t.map((e=>"int"+e)).join(" ")+" ",M=[].concat.apply([],t.map((e=>r.map((a=>e+"x"+a))))),p={ +keyword:"var bool string int uint "+g+o+"byte bytes "+l+"fixed ufixed "+M.map((e=>"fixed"+e)).join(" ")+" "+M.map((e=>"ufixed"+e)).join(" ")+" enum struct mapping address new delete if else for while continue break return throw emit try catch revert unchecked _ function modifier event constructor fallback receive error virtual override constant immutable anonymous indexed storage memory calldata external public internal payable pure view private returns import from as using pragma contract interface library is abstract type assembly", +literal:"true false wei gwei szabo finney ether seconds minutes hours days weeks years", +built_in:"self this super selfdestruct suicide now msg block tx abi blockhash gasleft assert require Error Panic sha3 sha256 keccak256 ripemd160 ecrecover addmod mulmod log0 log1 log2 log3 log4" +},O={className:"operator",begin:/[+\-!~*\/%<>&^|=]/ +},C=/[A-Za-z_$][A-Za-z_$0-9]*/,N={className:"params",begin:/\(/,end:/\)/, +excludeBegin:!0,excludeEnd:!0,lexemes:C,keywords:p, +contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,a,s,b,"self"]},f={ +begin:/\.\s*/,end:/[^A-Za-z0-9$_\.]/,excludeBegin:!0,excludeEnd:!0,keywords:{ +built_in:"gas value selector address length push pop send transfer call callcode delegatecall staticcall balance code codehash wrap unwrap name creationCode runtimeCode interfaceId min max" +},relevance:2},y=e.inherit(e.TITLE_MODE,{begin:/[A-Za-z$_][0-9A-Za-z$_]*/, +lexemes:C,keywords:p}),w={className:"built_in", +begin:(E()?"(? + +# Registry [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) ![solidity](https://img.shields.io/badge/solidity-^0.8.22-lightgrey) [![Foundry][foundry-badge]][foundry] + +[foundry]: https://getfoundry.sh +[foundry-badge]: https://img.shields.io/badge/Built%20with-Foundry-FFDB1C.svg + +This Contract is in active development. Do not use this in Prod! + +## Overview + +Account abstraction (or smart accounts) will deliver three key enhancements for the Ethereum ecosystem: +improved UX, enhanced user security and greater wallet extensibility. Modular smart accounts are the next +frontier for achieving these goals. However, it also opens up a number of new challenges that +could drastically undermine the objective by opening up a plethora of new attack vectors and security concerns for accounts. + +The Registry aims to solve this concern by providing a means of verifying the legitimacy and +security of independently built smart account modules for installation and use across any integrated +smart account. It allows entities to attest to statements about modules and smart accounts to query these at module nstallation and/or execution time. The Registry is a Singleton that is free, open and permissionless. It also serves as the reference implementation for [ERC-7484](https://eips.ethereum.org/EIPS/eip-7484). + +## Core Concepts + +### Attestations + +Attestations on the Registry represent statements about Modules. An Attestation is made using a particular [Schema](./Schemas.md) that is used to encode and decode the Attestation data. The most important usecase for Attestations is to make statements about the security of a Module. + +An attestation consists of two primary elements: the Schema and the +Attestation data. The Schema acts as a standardized structure for +creating and validating Attestations, defining how the Attestation data is encoded and decoded. + +### Schemas + +[Schemas](./docs/Schema.md) represent predefined structures utilized for the formation and +verification of Attestation data. Using flexible Schemas rather than a single, fixed Schema allows Attesters to encode their data in a custom way, providing flexibility when creating Attestations. For example, the data of an Attestation about the outcome of the formal verification on a Module will have a very format than the data of an Attestation about what interfaces a Module supports. + +### Resolvers + +Resolvers are external contracts that are tied to Modules and called when specific Registry actions are executed. These actions are: + +- attestation +- revocation +- module registration / deployment + +This architectural design aims to provide entities like Smart Account vendors or DAOs, with the +flexibility to incorporate custom business logic while maintaining the +robustness and security of the core functionalities implemented by the Registry + +### Attesters + +Attesters are individuals or organizations responsible for +creating and signing Attestations. They add the Attestation to the +Registry, making it available for verification. + +### Modules + +Modules are smart contracts that act as modular components that can be added to Smart Accounts. +The registry is agnostic towards Smart Account or Module implementations. Only Module addresses and +deployment metadata are stored on the registry. + +Modules are registered on the Registry either during, using `CREATE2`, `CREATE3` or a custom deployment factory, or after deployment. + +## Architecture + +![Sequence Diagram](./public/docs/all.svg) + +## Gas comparison + +The following is a table of the gas differences between the Registry and a minimal [ERC-7484](https://eips.ethereum.org/EIPS/eip-7484) registry that only has one attester. As you can see, the gas difference is negligible for 1 or 2 attesters, but the Registry scales much better than using multiple single attester registries. + +To run the tests yourself, run `forge test --mc RegistryGasComparisonTest -vv`. + +_Note:_ The gas calculation numbers include the gas cost for `CALL` + +| # of Attesters | Registry | Minimal7484Registry | Difference | +| ----------------- | ------------ | ------------------- | ---------- | +| 1 | 7983 | 7706 | +277 | +| 2 | 15472 | 15418 | +54 | +| 3 | 20823 | 23124 | -2301 | +| n (approximation) | 5299n + 4901 | 7709n | | + +## Deployments + +Current address: [0x500684cBaa280aDf80d5ACf7A32Daebb23162e63](https://blockscan.com/address/0x500684cBaa280aDf80d5ACf7A32Daebb23162e63) + +## Contribute + +For feature or change requests, feel free to open a PR or get in touch with us. + +## Credits & Special Thanks + +For the continious support and constructive feedback, we would like to thank: + +- [Ethereum Foundation](https://erc4337.mirror.xyz/hRn_41cef8oKn44ZncN9pXvY3VID6LZOtpLlktXYtmA) +- ERC-4337 Team +- Richard Meissner (Safe) @rimeissner +- Taek @taek.eth +- Biconomy +- Heavily inspired by EAS + +## Authors ✨ + + + + + + + + + + +

zeroknots

💻

Konrad

💻
diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md new file mode 100644 index 00000000..4eb7b9b3 --- /dev/null +++ b/docs/src/SUMMARY.md @@ -0,0 +1,51 @@ +# Summary +- [Home](README.md) +# src + - [❱ core](src/core/README.md) + - [Attestation](src/core/Attestation.sol/abstract.Attestation.md) + - [AttestationManager](src/core/AttestationManager.sol/abstract.AttestationManager.md) + - [ModuleManager](src/core/ModuleManager.sol/abstract.ModuleManager.md) + - [ResolverManager](src/core/ResolverManager.sol/abstract.ResolverManager.md) + - [SchemaManager](src/core/SchemaManager.sol/abstract.SchemaManager.md) + - [SignedAttestation](src/core/SignedAttestation.sol/contract.SignedAttestation.md) + - [TrustManager](src/core/TrustManager.sol/abstract.TrustManager.md) + - [TrustManagerExternalAttesterList](src/core/TrustManagerExternalAttesterList.sol/abstract.TrustManagerExternalAttesterList.md) + - [❱ external](src/external/README.md) + - [❱ examples](src/external/examples/README.md) + - [ERC7512](src/external/examples/ERC7512Schema.sol/interface.ERC7512.md) + - [ERC7512SchemaValidator](src/external/examples/ERC7512Schema.sol/contract.ERC7512SchemaValidator.md) + - [ResolverBase](src/external/examples/ResolverBase.sol/abstract.ResolverBase.md) + - [TokenizedResolver](src/external/examples/TokenizedResolver.sol/contract.TokenizedResolver.md) + - [IExternalResolver](src/external/IExternalResolver.sol/interface.IExternalResolver.md) + - [IExternalSchemaValidator](src/external/IExternalSchemaValidator.sol/interface.IExternalSchemaValidator.md) + - [❱ lib](src/lib/README.md) + - [AttestationLib](src/lib/AttestationLib.sol/library.AttestationLib.md) + - [UIDLib](src/lib/Helpers.sol/library.UIDLib.md) + - [ModuleDeploymentLib](src/lib/ModuleDeploymentLib.sol/library.ModuleDeploymentLib.md) + - [ModuleTypeLib](src/lib/ModuleTypeLib.sol/library.ModuleTypeLib.md) + - [StubLib](src/lib/StubLib.sol/library.StubLib.md) + - [_isContract](src/Common.sol/function._isContract.md) + - [_time](src/Common.sol/function._time.md) + - [Common constants](src/Common.sol/constants.Common.md) + - [AttestationRecord](src/DataTypes.sol/struct.AttestationRecord.md) + - [ModuleRecord](src/DataTypes.sol/struct.ModuleRecord.md) + - [SchemaRecord](src/DataTypes.sol/struct.SchemaRecord.md) + - [ResolverRecord](src/DataTypes.sol/struct.ResolverRecord.md) + - [TrustedAttesterRecord](src/DataTypes.sol/struct.TrustedAttesterRecord.md) + - [AttestationRequest](src/DataTypes.sol/struct.AttestationRequest.md) + - [RevocationRequest](src/DataTypes.sol/struct.RevocationRequest.md) + - [SchemaUID](src/DataTypes.sol/type.SchemaUID.md) + - [ResolverUID](src/DataTypes.sol/type.ResolverUID.md) + - [AttestationDataRef](src/DataTypes.sol/type.AttestationDataRef.md) + - [PackedModuleTypes](src/DataTypes.sol/type.PackedModuleTypes.md) + - [ModuleType](src/DataTypes.sol/type.ModuleType.md) + - [attestationDataRefEq](src/DataTypes.sol/function.attestationDataRefEq.md) + - [resolverEq](src/DataTypes.sol/function.resolverEq.md) + - [schemaEq](src/DataTypes.sol/function.schemaEq.md) + - [moduleTypeEq](src/DataTypes.sol/function.moduleTypeEq.md) + - [resolverNotEq](src/DataTypes.sol/function.resolverNotEq.md) + - [moduleTypeNeq](src/DataTypes.sol/function.moduleTypeNeq.md) + - [schemaNotEq](src/DataTypes.sol/function.schemaNotEq.md) + - [IERC7484](src/IRegistry.sol/interface.IERC7484.md) + - [IRegistry](src/IRegistry.sol/interface.IRegistry.md) + - [Registry](src/Registry.sol/contract.Registry.md) diff --git a/docs/src/src/Common.sol/constants.Common.md b/docs/src/src/Common.sol/constants.Common.md new file mode 100644 index 00000000..b5424767 --- /dev/null +++ b/docs/src/src/Common.sol/constants.Common.md @@ -0,0 +1,45 @@ +# Constants +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/Common.sol) + +### EMPTY_UID + +```solidity +bytes32 constant EMPTY_UID = 0; +``` + +### EMPTY_RESOLVER_UID + +```solidity +ResolverUID constant EMPTY_RESOLVER_UID = ResolverUID.wrap(EMPTY_UID); +``` + +### EMPTY_SCHEMA_UID + +```solidity +SchemaUID constant EMPTY_SCHEMA_UID = SchemaUID.wrap(EMPTY_UID); +``` + +### ZERO_TIMESTAMP + +```solidity +uint256 constant ZERO_TIMESTAMP = 0; +``` + +### ZERO_ADDRESS + +```solidity +address constant ZERO_ADDRESS = address(0); +``` + +### ZERO_MODULE_TYPE + +```solidity +ModuleType constant ZERO_MODULE_TYPE = ModuleType.wrap(0); +``` + +### EMPTY_ATTESTATION_REF + +```solidity +AttestationDataRef constant EMPTY_ATTESTATION_REF = AttestationDataRef.wrap(address(0)); +``` + diff --git a/docs/src/src/Common.sol/function._isContract.md b/docs/src/src/Common.sol/function._isContract.md new file mode 100644 index 00000000..cdd7fc51 --- /dev/null +++ b/docs/src/src/Common.sol/function._isContract.md @@ -0,0 +1,22 @@ +# _isContract +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/Common.sol) + +*Returns whether an address is a contract.* + + +```solidity +function _isContract(address addr) view returns (bool); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`addr`|`address`|The address to check.| + +**Returns** + +|Name|Type|Description| +|----|----|-----------| +|``|`bool`|true if `account` is a contract, false otherwise.| + + diff --git a/docs/src/src/Common.sol/function._time.md b/docs/src/src/Common.sol/function._time.md new file mode 100644 index 00000000..f8a6e019 --- /dev/null +++ b/docs/src/src/Common.sol/function._time.md @@ -0,0 +1,11 @@ +# _time +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/Common.sol) + +*Returns the current's block timestamp. This method is overridden during tests and used to simulate the +current block time.* + + +```solidity +function _time() view returns (uint48); +``` + diff --git a/docs/src/src/DataTypes.sol/function.attestationDataRefEq.md b/docs/src/src/DataTypes.sol/function.attestationDataRefEq.md new file mode 100644 index 00000000..aa9ca0a7 --- /dev/null +++ b/docs/src/src/DataTypes.sol/function.attestationDataRefEq.md @@ -0,0 +1,8 @@ +# attestationDataRefEq +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/DataTypes.sol) + + +```solidity +function attestationDataRefEq(AttestationDataRef uid1, AttestationDataRef uid2) pure returns (bool); +``` + diff --git a/docs/src/src/DataTypes.sol/function.moduleTypeEq.md b/docs/src/src/DataTypes.sol/function.moduleTypeEq.md new file mode 100644 index 00000000..fe49717e --- /dev/null +++ b/docs/src/src/DataTypes.sol/function.moduleTypeEq.md @@ -0,0 +1,8 @@ +# moduleTypeEq +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/DataTypes.sol) + + +```solidity +function moduleTypeEq(ModuleType uid1, ModuleType uid2) pure returns (bool); +``` + diff --git a/docs/src/src/DataTypes.sol/function.moduleTypeNeq.md b/docs/src/src/DataTypes.sol/function.moduleTypeNeq.md new file mode 100644 index 00000000..51b28040 --- /dev/null +++ b/docs/src/src/DataTypes.sol/function.moduleTypeNeq.md @@ -0,0 +1,8 @@ +# moduleTypeNeq +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/DataTypes.sol) + + +```solidity +function moduleTypeNeq(ModuleType uid1, ModuleType uid2) pure returns (bool); +``` + diff --git a/docs/src/src/DataTypes.sol/function.resolverEq.md b/docs/src/src/DataTypes.sol/function.resolverEq.md new file mode 100644 index 00000000..cfac154e --- /dev/null +++ b/docs/src/src/DataTypes.sol/function.resolverEq.md @@ -0,0 +1,8 @@ +# resolverEq +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/DataTypes.sol) + + +```solidity +function resolverEq(ResolverUID uid1, ResolverUID uid2) pure returns (bool); +``` + diff --git a/docs/src/src/DataTypes.sol/function.resolverNotEq.md b/docs/src/src/DataTypes.sol/function.resolverNotEq.md new file mode 100644 index 00000000..5ef3a771 --- /dev/null +++ b/docs/src/src/DataTypes.sol/function.resolverNotEq.md @@ -0,0 +1,8 @@ +# resolverNotEq +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/DataTypes.sol) + + +```solidity +function resolverNotEq(ResolverUID uid1, ResolverUID uid2) pure returns (bool); +``` + diff --git a/docs/src/src/DataTypes.sol/function.schemaEq.md b/docs/src/src/DataTypes.sol/function.schemaEq.md new file mode 100644 index 00000000..7bda8a33 --- /dev/null +++ b/docs/src/src/DataTypes.sol/function.schemaEq.md @@ -0,0 +1,8 @@ +# schemaEq +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/DataTypes.sol) + + +```solidity +function schemaEq(SchemaUID uid1, SchemaUID uid) pure returns (bool); +``` + diff --git a/docs/src/src/DataTypes.sol/function.schemaNotEq.md b/docs/src/src/DataTypes.sol/function.schemaNotEq.md new file mode 100644 index 00000000..0548aa05 --- /dev/null +++ b/docs/src/src/DataTypes.sol/function.schemaNotEq.md @@ -0,0 +1,8 @@ +# schemaNotEq +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/DataTypes.sol) + + +```solidity +function schemaNotEq(SchemaUID uid1, SchemaUID uid) pure returns (bool); +``` + diff --git a/docs/src/src/DataTypes.sol/struct.AttestationRecord.md b/docs/src/src/DataTypes.sol/struct.AttestationRecord.md new file mode 100644 index 00000000..3d663e79 --- /dev/null +++ b/docs/src/src/DataTypes.sol/struct.AttestationRecord.md @@ -0,0 +1,17 @@ +# AttestationRecord +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/DataTypes.sol) + + +```solidity +struct AttestationRecord { + uint48 time; + uint48 expirationTime; + uint48 revocationTime; + PackedModuleTypes moduleTypes; + address moduleAddr; + address attester; + AttestationDataRef dataPointer; + SchemaUID schemaUID; +} +``` + diff --git a/docs/src/src/DataTypes.sol/struct.AttestationRequest.md b/docs/src/src/DataTypes.sol/struct.AttestationRequest.md new file mode 100644 index 00000000..33eeb91f --- /dev/null +++ b/docs/src/src/DataTypes.sol/struct.AttestationRequest.md @@ -0,0 +1,15 @@ +# AttestationRequest +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/DataTypes.sol) + +*A struct representing the arguments of the attestation request.* + + +```solidity +struct AttestationRequest { + address moduleAddr; + uint48 expirationTime; + bytes data; + ModuleType[] moduleTypes; +} +``` + diff --git a/docs/src/src/DataTypes.sol/struct.ModuleRecord.md b/docs/src/src/DataTypes.sol/struct.ModuleRecord.md new file mode 100644 index 00000000..b9bf67a2 --- /dev/null +++ b/docs/src/src/DataTypes.sol/struct.ModuleRecord.md @@ -0,0 +1,12 @@ +# ModuleRecord +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/DataTypes.sol) + + +```solidity +struct ModuleRecord { + ResolverUID resolverUID; + address sender; + bytes metadata; +} +``` + diff --git a/docs/src/src/DataTypes.sol/struct.ResolverRecord.md b/docs/src/src/DataTypes.sol/struct.ResolverRecord.md new file mode 100644 index 00000000..eda16b1b --- /dev/null +++ b/docs/src/src/DataTypes.sol/struct.ResolverRecord.md @@ -0,0 +1,11 @@ +# ResolverRecord +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/DataTypes.sol) + + +```solidity +struct ResolverRecord { + IExternalResolver resolver; + address resolverOwner; +} +``` + diff --git a/docs/src/src/DataTypes.sol/struct.RevocationRequest.md b/docs/src/src/DataTypes.sol/struct.RevocationRequest.md new file mode 100644 index 00000000..34ba0c5f --- /dev/null +++ b/docs/src/src/DataTypes.sol/struct.RevocationRequest.md @@ -0,0 +1,12 @@ +# RevocationRequest +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/DataTypes.sol) + +*A struct representing the arguments of the revocation request.* + + +```solidity +struct RevocationRequest { + address moduleAddr; +} +``` + diff --git a/docs/src/src/DataTypes.sol/struct.SchemaRecord.md b/docs/src/src/DataTypes.sol/struct.SchemaRecord.md new file mode 100644 index 00000000..d9b13ca8 --- /dev/null +++ b/docs/src/src/DataTypes.sol/struct.SchemaRecord.md @@ -0,0 +1,12 @@ +# SchemaRecord +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/DataTypes.sol) + + +```solidity +struct SchemaRecord { + uint48 registeredAt; + IExternalSchemaValidator validator; + string schema; +} +``` + diff --git a/docs/src/src/DataTypes.sol/struct.TrustedAttesterRecord.md b/docs/src/src/DataTypes.sol/struct.TrustedAttesterRecord.md new file mode 100644 index 00000000..f54dd620 --- /dev/null +++ b/docs/src/src/DataTypes.sol/struct.TrustedAttesterRecord.md @@ -0,0 +1,13 @@ +# TrustedAttesterRecord +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/DataTypes.sol) + + +```solidity +struct TrustedAttesterRecord { + uint8 attesterCount; + uint8 threshold; + address attester; + mapping(address attester => address linkedAttester) linkedAttesters; +} +``` + diff --git a/docs/src/src/DataTypes.sol/type.AttestationDataRef.md b/docs/src/src/DataTypes.sol/type.AttestationDataRef.md new file mode 100644 index 00000000..36a93cdb --- /dev/null +++ b/docs/src/src/DataTypes.sol/type.AttestationDataRef.md @@ -0,0 +1,8 @@ +# AttestationDataRef +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/DataTypes.sol) + + +```solidity +type AttestationDataRef is address; +``` + diff --git a/docs/src/src/DataTypes.sol/type.ModuleType.md b/docs/src/src/DataTypes.sol/type.ModuleType.md new file mode 100644 index 00000000..81167a93 --- /dev/null +++ b/docs/src/src/DataTypes.sol/type.ModuleType.md @@ -0,0 +1,8 @@ +# ModuleType +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/DataTypes.sol) + + +```solidity +type ModuleType is uint256; +``` + diff --git a/docs/src/src/DataTypes.sol/type.PackedModuleTypes.md b/docs/src/src/DataTypes.sol/type.PackedModuleTypes.md new file mode 100644 index 00000000..e44e1d91 --- /dev/null +++ b/docs/src/src/DataTypes.sol/type.PackedModuleTypes.md @@ -0,0 +1,8 @@ +# PackedModuleTypes +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/DataTypes.sol) + + +```solidity +type PackedModuleTypes is uint32; +``` + diff --git a/docs/src/src/DataTypes.sol/type.ResolverUID.md b/docs/src/src/DataTypes.sol/type.ResolverUID.md new file mode 100644 index 00000000..f9915362 --- /dev/null +++ b/docs/src/src/DataTypes.sol/type.ResolverUID.md @@ -0,0 +1,8 @@ +# ResolverUID +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/DataTypes.sol) + + +```solidity +type ResolverUID is bytes32; +``` + diff --git a/docs/src/src/DataTypes.sol/type.SchemaUID.md b/docs/src/src/DataTypes.sol/type.SchemaUID.md new file mode 100644 index 00000000..44f13e00 --- /dev/null +++ b/docs/src/src/DataTypes.sol/type.SchemaUID.md @@ -0,0 +1,8 @@ +# SchemaUID +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/DataTypes.sol) + + +```solidity +type SchemaUID is bytes32; +``` + diff --git a/docs/src/src/IRegistry.sol/interface.IERC7484.md b/docs/src/src/IRegistry.sol/interface.IERC7484.md new file mode 100644 index 00000000..a3ec35a0 --- /dev/null +++ b/docs/src/src/IRegistry.sol/interface.IERC7484.md @@ -0,0 +1,47 @@ +# IERC7484 +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/IRegistry.sol) + + +## Functions +### check + + +```solidity +function check(address module) external view; +``` + +### checkForAccount + + +```solidity +function checkForAccount(address smartAccount, address module) external view; +``` + +### check + + +```solidity +function check(address module, ModuleType moduleType) external view; +``` + +### checkForAccount + + +```solidity +function checkForAccount(address smartAccount, address module, ModuleType moduleType) external view; +``` + +### check + + +```solidity +function check(address module, address attester) external view returns (uint256 attestedAt); +``` + +### checkN + + +```solidity +function checkN(address module, address[] calldata attesters, uint256 threshold) external view returns (uint256[] memory attestedAtArray); +``` + diff --git a/docs/src/src/IRegistry.sol/interface.IRegistry.md b/docs/src/src/IRegistry.sol/interface.IRegistry.md new file mode 100644 index 00000000..62183bcf --- /dev/null +++ b/docs/src/src/IRegistry.sol/interface.IRegistry.md @@ -0,0 +1,645 @@ +# IRegistry +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/IRegistry.sol) + +**Inherits:** +[IERC7484](/src/IRegistry.sol/interface.IERC7484.md) + + +## Functions +### trustAttesters + +Allows smartaccounts - the end users of the registry - to appoint +one or many attesters as trusted. + +this function reverts, if address(0), or duplicates are provided in attesters[] + + +```solidity +function trustAttesters(uint8 threshold, address[] calldata attesters) external; +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`threshold`|`uint8`|The minimum number of attestations required for a module to be considered secure.| +|`attesters`|`address[]`|The addresses of the attesters to be trusted.| + + +### findTrustedAttesters + +Get trusted attester for a specific smartAccount + + +```solidity +function findTrustedAttesters(address smartAccount) external view returns (address[] memory attesters); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`smartAccount`|`address`|The address of the smartAccount| + + +### attest + +Allows msg.sender to attest to multiple modules' security status. +The AttestationRequest.Data provided should match the attestation +schema defined by the Schema corresponding to the SchemaUID + +*This function will revert if the same module is attested twice by the same attester. +If you want to re-attest, you have to revoke your attestation first, and then attest again.* + + +```solidity +function attest(SchemaUID schemaUID, AttestationRequest calldata request) external; +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`schemaUID`|`SchemaUID`|The SchemaUID of the schema the attestation is based on.| +|`request`|`AttestationRequest`|a single AttestationRequest| + + +### attest + +Allows msg.sender to attest to multiple modules' security status. +The AttestationRequest.Data provided should match the attestation +schema defined by the Schema corresponding to the SchemaUID + +*This function will revert if the same module is attested twice by the same attester. +If you want to re-attest, you have to revoke your attestation first, and then attest again.* + + +```solidity +function attest(SchemaUID schemaUID, AttestationRequest[] calldata requests) external; +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`schemaUID`|`SchemaUID`|The SchemaUID of the schema the attestation is based on.| +|`requests`|`AttestationRequest[]`|An array of AttestationRequest| + + +### attest + +Allows attester to attest by signing an AttestationRequest (ECDSA or ERC1271) +The AttestationRequest.Data provided should match the attestation +schema defined by the Schema corresponding to the SchemaUID + +*This function will revert if the same module is attested twice by the same attester. +If you want to re-attest, you have to revoke your attestation first, and then attest again.* + + +```solidity +function attest(SchemaUID schemaUID, address attester, AttestationRequest calldata request, bytes calldata signature) external; +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`schemaUID`|`SchemaUID`|The SchemaUID of the schema the attestation is based on.| +|`attester`|`address`|The address of the attester| +|`request`|`AttestationRequest`|An AttestationRequest| +|`signature`|`bytes`|The signature of the attester. ECDSA or ERC1271| + + +### attest + +Allows attester to attest by signing an AttestationRequest (ECDSA or ERC1271) +The AttestationRequest.Data provided should match the attestation +schema defined by the Schema corresponding to the SchemaUID + +*This function will revert if the same module is attested twice by the same attester. +If you want to re-attest, you have to revoke your attestation first, and then attest again.* + + +```solidity +function attest(SchemaUID schemaUID, address attester, AttestationRequest[] calldata requests, bytes calldata signature) external; +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`schemaUID`|`SchemaUID`|The SchemaUID of the schema the attestation is based on.| +|`attester`|`address`|The address of the attester| +|`requests`|`AttestationRequest[]`|An array of AttestationRequest| +|`signature`|`bytes`|The signature of the attester. ECDSA or ERC1271| + + +### findAttestation + +Getter function to get AttestationRequest made by one attester + + +```solidity +function findAttestation(address module, address attester) external view returns (AttestationRecord memory attestation); +``` + +### findAttestations + +Getter function to get AttestationRequest made by multiple attesters + + +```solidity +function findAttestations(address module, address[] calldata attesters) external view returns (AttestationRecord[] memory attestations); +``` + +### revoke + +Allows msg.sender to revoke an attstation made by the same msg.sender + +*this function will revert if the attestation is not found* + +*this function will revert if the attestation is already revoked* + + +```solidity +function revoke(RevocationRequest calldata request) external; +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`request`|`RevocationRequest`| the RevocationRequest| + + +### revoke + +Allows msg.sender to revoke multiple attstations made by the same msg.sender + +*this function will revert if the attestation is not found* + +*this function will revert if the attestation is already revoked* + + +```solidity +function revoke(RevocationRequest[] calldata requests) external; +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`requests`|`RevocationRequest[]`|the RevocationRequests| + + +### revoke + +Allows attester to revoke an attestation by signing an RevocationRequest (ECDSA or ERC1271) + + +```solidity +function revoke(address attester, RevocationRequest calldata request, bytes calldata signature) external; +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`attester`|`address`|the signer / revoker| +|`request`|`RevocationRequest`|the RevocationRequest| +|`signature`|`bytes`|ECDSA or ERC1271 signature| + + +### revoke + +Allows attester to revoke an attestation by signing an RevocationRequest (ECDSA or ERC1271) + +*if you want to revoke multiple attestations, but from different attesters, call this function multiple times* + + +```solidity +function revoke(address attester, RevocationRequest[] calldata requests, bytes calldata signature) external; +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`attester`|`address`|the signer / revoker| +|`requests`|`RevocationRequest[]`|array of RevocationRequests| +|`signature`|`bytes`|ECDSA or ERC1271 signature| + + +### deployModule + +This registry implements a CREATE2 factory, that allows module developers to register and deploy module bytecode + + +```solidity +function deployModule( + bytes32 salt, + ResolverUID resolverUID, + bytes calldata initCode, + bytes calldata metadata +) + external + payable + returns (address moduleAddr); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`salt`|`bytes32`|The salt to be used in the CREATE2 factory. This adheres to Pr000xy/Create2Factory.sol salt formatting. The salt's first bytes20 should be the address of the sender or bytes20(0) to bypass the check (this will lose replay protection)| +|`resolverUID`|`ResolverUID`|The resolverUID to be used in the CREATE2 factory| +|`initCode`|`bytes`|The initCode to be used in the CREATE2 factory| +|`metadata`|`bytes`|The metadata to be stored on the registry. This field is optional, and might be used by the module developer to store additional information about the module or facilitate business logic with the Resolver stub| + + +### deployViaFactory + +Registry can use other factories to deploy the module + +This function is used to deploy and register a module using a factory contract. +Since one of the parameters of this function is a unique resolverUID and any +registered module address can only be registered once, +using this function is of risk for a frontrun attack + + +```solidity +function deployViaFactory( + address factory, + bytes calldata callOnFactory, + bytes calldata metadata, + ResolverUID resolverUID +) + external + payable + returns (address moduleAddress); +``` + +### registerModule + +Already deployed module addresses can be registered on the registry + +This function is used to deploy and register an already deployed module. +Since one of the parameters of this function is a unique resolverUID and any +registered module address can only be registered once, +using this function is of risk for a frontrun attack + + +```solidity +function registerModule(ResolverUID resolverUID, address moduleAddress, bytes calldata metadata) external; +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`resolverUID`|`ResolverUID`|The resolverUID to be used for the module| +|`moduleAddress`|`address`|The address of the module to be registered| +|`metadata`|`bytes`|The metadata to be stored on the registry. This field is optional, and might be used by the module developer to store additional information about the module or facilitate business logic with the Resolver stub| + + +### calcModuleAddress + +in conjunction with the deployModule() function, this function let's you +predict the address of a CREATE2 module deployment + + +```solidity +function calcModuleAddress(bytes32 salt, bytes calldata initCode) external view returns (address); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`salt`|`bytes32`|CREATE2 salt| +|`initCode`|`bytes`|module initcode| + +**Returns** + +|Name|Type|Description| +|----|----|-----------| +|``|`address`|moduleAddress counterfactual address of the module deployment| + + +### findModule + +Getter function to get the stored ModuleRecord for a specific module address. + + +```solidity +function findModule(address moduleAddress) external view returns (ModuleRecord memory moduleRecord); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`moduleAddress`|`address`|The address of the module| + + +### registerSchema + +Register Schema and (optional) external IExternalSchemaValidator +Schemas describe the structure of the data of attestations +every attestation made on this registry, will reference a SchemaUID to +make it possible to decode attestation data in human readable form +overrwriting a schema is not allowed, and will revert + + +```solidity +function registerSchema(string calldata schema, IExternalSchemaValidator validator) external returns (SchemaUID uid); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`schema`|`string`|ABI schema used to encode attestations that are made with this schema| +|`validator`|`IExternalSchemaValidator`|(optional) external schema validator that will be used to validate attestations. use address(0), if you dont need an external validator| + +**Returns** + +|Name|Type|Description| +|----|----|-----------| +|`uid`|`SchemaUID`|SchemaUID of the registered schema| + + +### findSchema + +getter function to retrieve SchemaRecord + + +```solidity +function findSchema(SchemaUID uid) external view returns (SchemaRecord memory record); +``` + +### registerResolver + +Allows Marketplace Agents to register external resolvers. + + +```solidity +function registerResolver(IExternalResolver resolver) external returns (ResolverUID uid); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`resolver`|`IExternalResolver`|external resolver contract| + +**Returns** + +|Name|Type|Description| +|----|----|-----------| +|`uid`|`ResolverUID`|ResolverUID of the registered resolver| + + +### setResolver + +Entities that previously regsitered an external resolver, may update the implementation address. + + +```solidity +function setResolver(ResolverUID uid, IExternalResolver resolver) external; +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`uid`|`ResolverUID`|The UID of the resolver.| +|`resolver`|`IExternalResolver`|The new resolver implementation address.| + + +### transferResolverOwnership + +Transfer ownership of resolverUID to a new address + + +```solidity +function transferResolverOwnership(ResolverUID uid, address newOwner) external; +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`uid`|`ResolverUID`|The UID of the resolver to transfer ownership for| +|`newOwner`|`address`|The address of the new owner| + + +### findResolver + +Getter function to get the ResolverRecord of a registerd resolver + + +```solidity +function findResolver(ResolverUID uid) external view returns (ResolverRecord memory record); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`uid`|`ResolverUID`|The UID of the resolver.| + + +## Events +### NewTrustedAttesters + +```solidity +event NewTrustedAttesters(); +``` + +### Revoked + +```solidity +event Revoked(address indexed moduleAddr, address indexed revoker, SchemaUID schema); +``` + +### Attested + +```solidity +event Attested(address indexed moduleAddr, address indexed attester, SchemaUID schemaUID, AttestationDataRef indexed sstore2Pointer); +``` + +### ModuleRegistration + +```solidity +event ModuleRegistration(address indexed implementation, ResolverUID resolverUID, bool deployedViaRegistry); +``` + +### SchemaRegistered + +```solidity +event SchemaRegistered(SchemaUID indexed uid, address indexed registerer); +``` + +### NewResolver + +```solidity +event NewResolver(ResolverUID indexed uid, address indexed resolver); +``` + +### NewResolverOwner + +```solidity +event NewResolverOwner(ResolverUID indexed uid, address newOwner); +``` + +## Errors +### InvalidResolver + +```solidity +error InvalidResolver(IExternalResolver resolver); +``` + +### InvalidResolverUID + +```solidity +error InvalidResolverUID(ResolverUID uid); +``` + +### InvalidTrustedAttesterInput + +```solidity +error InvalidTrustedAttesterInput(); +``` + +### NoTrustedAttestersFound + +```solidity +error NoTrustedAttestersFound(); +``` + +### RevokedAttestation + +```solidity +error RevokedAttestation(address attester); +``` + +### InvalidModuleType + +```solidity +error InvalidModuleType(); +``` + +### AttestationNotFound + +```solidity +error AttestationNotFound(); +``` + +### InsufficientAttestations + +```solidity +error InsufficientAttestations(); +``` + +### AlreadyRevoked + +```solidity +error AlreadyRevoked(); +``` + +### ModuleNotFoundInRegistry + +```solidity +error ModuleNotFoundInRegistry(address module); +``` + +### AccessDenied + +```solidity +error AccessDenied(); +``` + +### InvalidAttestation + +```solidity +error InvalidAttestation(); +``` + +### InvalidExpirationTime + +```solidity +error InvalidExpirationTime(); +``` + +### DifferentResolvers + +```solidity +error DifferentResolvers(); +``` + +### InvalidSignature + +```solidity +error InvalidSignature(); +``` + +### InvalidModuleTypes + +```solidity +error InvalidModuleTypes(); +``` + +### AlreadyRegistered + +```solidity +error AlreadyRegistered(address module); +``` + +### InvalidDeployment + +```solidity +error InvalidDeployment(); +``` + +### ModuleAddressIsNotContract + +```solidity +error ModuleAddressIsNotContract(address moduleAddress); +``` + +### FactoryCallFailed + +```solidity +error FactoryCallFailed(address factory); +``` + +### SchemaAlreadyExists + +```solidity +error SchemaAlreadyExists(SchemaUID uid); +``` + +### InvalidSchema + +```solidity +error InvalidSchema(); +``` + +### InvalidSchemaValidator + +```solidity +error InvalidSchemaValidator(IExternalSchemaValidator validator); +``` + +### ResolverAlreadyExists + +```solidity +error ResolverAlreadyExists(); +``` + +### ExternalError_SchemaValidation + +```solidity +error ExternalError_SchemaValidation(); +``` + +### ExternalError_ResolveAtteststation + +```solidity +error ExternalError_ResolveAtteststation(); +``` + +### ExternalError_ResolveRevocation + +```solidity +error ExternalError_ResolveRevocation(); +``` + +### ExternalError_ModuleRegistration + +```solidity +error ExternalError_ModuleRegistration(); +``` + diff --git a/docs/src/src/README.md b/docs/src/src/README.md new file mode 100644 index 00000000..73d326e6 --- /dev/null +++ b/docs/src/src/README.md @@ -0,0 +1,31 @@ + + +# Contents +- [core](/src/core) +- [external](/src/external) +- [lib](/src/lib) +- [_isContract](Common.sol/function._isContract.md) +- [_time](Common.sol/function._time.md) +- [Common constants](Common.sol/constants.Common.md) +- [AttestationRecord](DataTypes.sol/struct.AttestationRecord.md) +- [ModuleRecord](DataTypes.sol/struct.ModuleRecord.md) +- [SchemaRecord](DataTypes.sol/struct.SchemaRecord.md) +- [ResolverRecord](DataTypes.sol/struct.ResolverRecord.md) +- [TrustedAttesterRecord](DataTypes.sol/struct.TrustedAttesterRecord.md) +- [AttestationRequest](DataTypes.sol/struct.AttestationRequest.md) +- [RevocationRequest](DataTypes.sol/struct.RevocationRequest.md) +- [SchemaUID](DataTypes.sol/type.SchemaUID.md) +- [ResolverUID](DataTypes.sol/type.ResolverUID.md) +- [AttestationDataRef](DataTypes.sol/type.AttestationDataRef.md) +- [PackedModuleTypes](DataTypes.sol/type.PackedModuleTypes.md) +- [ModuleType](DataTypes.sol/type.ModuleType.md) +- [attestationDataRefEq](DataTypes.sol/function.attestationDataRefEq.md) +- [resolverEq](DataTypes.sol/function.resolverEq.md) +- [schemaEq](DataTypes.sol/function.schemaEq.md) +- [moduleTypeEq](DataTypes.sol/function.moduleTypeEq.md) +- [resolverNotEq](DataTypes.sol/function.resolverNotEq.md) +- [moduleTypeNeq](DataTypes.sol/function.moduleTypeNeq.md) +- [schemaNotEq](DataTypes.sol/function.schemaNotEq.md) +- [IERC7484](IRegistry.sol/interface.IERC7484.md) +- [IRegistry](IRegistry.sol/interface.IRegistry.md) +- [Registry](Registry.sol/contract.Registry.md) diff --git a/docs/src/src/Registry.sol/contract.Registry.md b/docs/src/src/Registry.sol/contract.Registry.md new file mode 100644 index 00000000..c731f3b2 --- /dev/null +++ b/docs/src/src/Registry.sol/contract.Registry.md @@ -0,0 +1,10 @@ +# Registry +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/Registry.sol) + +**Inherits:** +[IRegistry](/src/IRegistry.sol/interface.IRegistry.md), [SignedAttestation](/src/core/SignedAttestation.sol/contract.SignedAttestation.md) + +**Author:** +zeroknots + + diff --git a/docs/src/src/core/Attestation.sol/abstract.Attestation.md b/docs/src/src/core/Attestation.sol/abstract.Attestation.md new file mode 100644 index 00000000..aad0467d --- /dev/null +++ b/docs/src/src/core/Attestation.sol/abstract.Attestation.md @@ -0,0 +1,102 @@ +# Attestation +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/core/Attestation.sol) + +**Inherits:** +[IRegistry](/src/IRegistry.sol/interface.IRegistry.md), [AttestationManager](/src/core/AttestationManager.sol/abstract.AttestationManager.md) + + +## Functions +### attest + +Allows msg.sender to attest to multiple modules' security status. +The AttestationRequest.Data provided should match the attestation +schema defined by the Schema corresponding to the SchemaUID + +*This function will revert if the same module is attested twice by the same attester. +If you want to re-attest, you have to revoke your attestation first, and then attest again.* + + +```solidity +function attest(SchemaUID schemaUID, AttestationRequest calldata request) external; +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`schemaUID`|`SchemaUID`|The SchemaUID of the schema the attestation is based on.| +|`request`|`AttestationRequest`|a single AttestationRequest| + + +### attest + +Allows msg.sender to attest to multiple modules' security status. +The AttestationRequest.Data provided should match the attestation +schema defined by the Schema corresponding to the SchemaUID + +*This function will revert if the same module is attested twice by the same attester. +If you want to re-attest, you have to revoke your attestation first, and then attest again.* + + +```solidity +function attest(SchemaUID schemaUID, AttestationRequest[] calldata requests) external; +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`schemaUID`|`SchemaUID`|The SchemaUID of the schema the attestation is based on.| +|`requests`|`AttestationRequest[]`|| + + +### revoke + +Allows msg.sender to revoke an attstation made by the same msg.sender + +*this function will revert if the attestation is not found* + + +```solidity +function revoke(RevocationRequest calldata request) external; +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`request`|`RevocationRequest`| the RevocationRequest| + + +### revoke + +Allows msg.sender to revoke an attstation made by the same msg.sender + +*this function will revert if the attestation is not found* + + +```solidity +function revoke(RevocationRequest[] calldata requests) external; +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`requests`|`RevocationRequest[]`|| + + +### findAttestation + +Getter function to get AttestationRequest made by one attester + + +```solidity +function findAttestation(address module, address attester) external view returns (AttestationRecord memory attestation); +``` + +### findAttestations + +Getter function to get AttestationRequest made by multiple attesters + + +```solidity +function findAttestations(address module, address[] calldata attesters) external view returns (AttestationRecord[] memory attestations); +``` + diff --git a/docs/src/src/core/AttestationManager.sol/abstract.AttestationManager.md b/docs/src/src/core/AttestationManager.sol/abstract.AttestationManager.md new file mode 100644 index 00000000..cdc4d08b --- /dev/null +++ b/docs/src/src/core/AttestationManager.sol/abstract.AttestationManager.md @@ -0,0 +1,146 @@ +# AttestationManager +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/core/AttestationManager.sol) + +**Inherits:** +[IRegistry](/src/IRegistry.sol/interface.IRegistry.md), [ModuleManager](/src/core/ModuleManager.sol/abstract.ModuleManager.md), [SchemaManager](/src/core/SchemaManager.sol/abstract.SchemaManager.md), [TrustManager](/src/core/TrustManager.sol/abstract.TrustManager.md) + +AttestationManager handles the registry's internal storage of new attestations and revocation of attestation + +*This contract is abstract and provides utility functions to store attestations and revocations.* + + +## State Variables +### $moduleToAttesterToAttestations + +```solidity +mapping(address module => mapping(address attester => AttestationRecord attestation)) internal $moduleToAttesterToAttestations; +``` + + +## Functions +### _attest + +Processes an attestation request and stores the attestation in the registry. +If the attestation was made for a module that was not registered, the function will revert. +function will get the external Schema Validator for the supplied SchemaUID +and call it, if an external IExternalSchemaValidator was set +function will get the external IExternalResolver for the module - that the attestation is for +and call it, if an external Resolver was set + + +```solidity +function _attest(address attester, SchemaUID schemaUID, AttestationRequest calldata request) internal; +``` + +### _attest + +Processes an array of attestation requests and stores the attestations in the registry. +If the attestation was made for a module that was not registered, the function will revert. +function will get the external Schema Validator for the supplied SchemaUID +and call it, if an external IExternalSchemaValidator was set +function will get the external IExternalResolver for the module - that the attestation is for +and call it, if an external Resolver was set + + +```solidity +function _attest(address attester, SchemaUID schemaUID, AttestationRequest[] calldata requests) internal; +``` + +### _storeAttestation + +Stores an attestation in the registry storage. +The bytes encoded AttestationRequest.Data is not stored directly into the registry storage, +but rather stored with SSTORE2. SSTORE2/SLOAD2 is writing and reading contract storage +paying a fraction of the cost, it uses contract code as storage, writing data takes the +form of contract creations and reading data uses EXTCODECOPY. +since attestation data is supposed to be immutable, it is a good candidate for SSTORE2 + +*This function will revert if the same module is attested twice by the same attester. +If you want to re-attest, you have to revoke your attestation first, and then attest again.* + + +```solidity +function _storeAttestation( + SchemaUID schemaUID, + address attester, + AttestationRequest calldata request +) + internal + returns (AttestationRecord memory record, ResolverUID resolverUID); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`schemaUID`|`SchemaUID`|| +|`attester`|`address`|The address of the attesting account.| +|`request`|`AttestationRequest`|The AttestationRequest that was supplied via calldata| + +**Returns** + +|Name|Type|Description| +|----|----|-----------| +|`record`|`AttestationRecord`|The AttestationRecord of what was written into registry storage| +|`resolverUID`|`ResolverUID`|The resolverUID in charge for the module| + + +### _revoke + +Revoke a single Revocation Request +This function will write the RevocationRequest into storage, and get the stored RevocationRecord back, +and pass the RevocationRecord to the resolver to check if the revocation is valid + + +```solidity +function _revoke(address attester, RevocationRequest calldata request) internal; +``` + +### _revoke + +Revoke an array Revocation Request +This function will write the RevocationRequest into storage, and get the stored RevocationRecord back, +and pass the RevocationRecord to the resolver to check if the revocation is valid + + +```solidity +function _revoke(address attester, RevocationRequest[] calldata requests) internal; +``` + +### _storeRevocation + +Gets the AttestationRecord for the supplied RevocationRequest and stores the revocation time in the registry storage + + +```solidity +function _storeRevocation( + address revoker, + RevocationRequest calldata request +) + internal + returns (AttestationRecord memory record, ResolverUID resolverUID); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`revoker`|`address`|The address of the attesting account.| +|`request`|`RevocationRequest`|The AttestationRequest that was supplied via calldata| + +**Returns** + +|Name|Type|Description| +|----|----|-----------| +|`record`|`AttestationRecord`|The AttestationRecord of what was written into registry storage| +|`resolverUID`|`ResolverUID`|The resolverUID in charge for the module| + + +### _getAttestation + +Returns the attestation records for the given module and attesters. +This function is expected to be used by TrustManager and TrustManagerExternalAttesterList + + +```solidity +function _getAttestation(address module, address attester) internal view override returns (AttestationRecord storage $attestation); +``` + diff --git a/docs/src/src/core/ModuleManager.sol/abstract.ModuleManager.md b/docs/src/src/core/ModuleManager.sol/abstract.ModuleManager.md new file mode 100644 index 00000000..939452d8 --- /dev/null +++ b/docs/src/src/core/ModuleManager.sol/abstract.ModuleManager.md @@ -0,0 +1,145 @@ +# ModuleManager +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/core/ModuleManager.sol) + +**Inherits:** +[IRegistry](/src/IRegistry.sol/interface.IRegistry.md), [ResolverManager](/src/core/ResolverManager.sol/abstract.ResolverManager.md) + +**Author:** +rhinestone | zeroknots.eth, Konrad Kopp (@kopy-kat) + +*The Module contract is responsible for handling the registration, +storage and retrieval of modules on the Registry. +This contract inherits from the IModule interface* + +*The primary responsibility of the Module is to deploy and manage modules. A module is a smart contract +that has been deployed through the Module. The details of each module, such as its address, code hash, schema ID, +sender address, deploy parameters hash, and additional metadata are stored in +a struct and mapped to the module's address in +the `_modules` mapping for easy access and management.* + +*In conclusion, the Module is a central part of a system to manage, +deploy, and interact with a set of smart contracts +in a structured and controlled manner.* + + +## State Variables +### $moduleAddrToRecords + +```solidity +mapping(address moduleAddress => ModuleRecord moduleRecord) internal $moduleAddrToRecords; +``` + + +## Functions +### deployModule + +This registry implements a CREATE2 factory, that allows module developers to register and deploy module bytecode + + +```solidity +function deployModule( + bytes32 salt, + ResolverUID resolverUID, + bytes calldata initCode, + bytes calldata metadata +) + external + payable + returns (address moduleAddress); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`salt`|`bytes32`|The salt to be used in the CREATE2 factory. This adheres to Pr000xy/Create2Factory.sol salt formatting. The salt's first bytes20 should be the address of the sender or bytes20(0) to bypass the check (this will lose replay protection)| +|`resolverUID`|`ResolverUID`|The resolverUID to be used in the CREATE2 factory| +|`initCode`|`bytes`|The initCode to be used in the CREATE2 factory| +|`metadata`|`bytes`|The metadata to be stored on the registry. This field is optional, and might be used by the module developer to store additional information about the module or facilitate business logic with the Resolver stub| + + +### calcModuleAddress + +in conjunction with the deployModule() function, this function let's you +predict the address of a CREATE2 module deployment + + +```solidity +function calcModuleAddress(bytes32 salt, bytes calldata initCode) external view returns (address); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`salt`|`bytes32`|CREATE2 salt| +|`initCode`|`bytes`|module initcode| + +**Returns** + +|Name|Type|Description| +|----|----|-----------| +|``|`address`|moduleAddress counterfactual address of the module deployment| + + +### registerModule + +Already deployed module addresses can be registered on the registry + + +```solidity +function registerModule(ResolverUID resolverUID, address moduleAddress, bytes calldata metadata) external; +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`resolverUID`|`ResolverUID`|The resolverUID to be used for the module| +|`moduleAddress`|`address`|The address of the module to be registered| +|`metadata`|`bytes`|The metadata to be stored on the registry. This field is optional, and might be used by the module developer to store additional information about the module or facilitate business logic with the Resolver stub| + + +### deployViaFactory + +Registry can use other factories to deploy the module + + +```solidity +function deployViaFactory( + address factory, + bytes calldata callOnFactory, + bytes calldata metadata, + ResolverUID resolverUID +) + external + payable + returns (address moduleAddress); +``` + +### _storeModuleRecord + + +```solidity +function _storeModuleRecord( + address moduleAddress, + address sender, + ResolverUID resolverUID, + bytes calldata metadata +) + internal + returns (ModuleRecord memory moduleRegistration); +``` + +### findModule + +Getter function to get the stored ModuleRecord for a specific module address. + + +```solidity +function findModule(address moduleAddress) external view returns (ModuleRecord memory moduleRecord); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`moduleAddress`|`address`|The address of the module| + + diff --git a/docs/src/src/core/README.md b/docs/src/src/core/README.md new file mode 100644 index 00000000..dd00cb63 --- /dev/null +++ b/docs/src/src/core/README.md @@ -0,0 +1,11 @@ + + +# Contents +- [Attestation](Attestation.sol/abstract.Attestation.md) +- [AttestationManager](AttestationManager.sol/abstract.AttestationManager.md) +- [ModuleManager](ModuleManager.sol/abstract.ModuleManager.md) +- [ResolverManager](ResolverManager.sol/abstract.ResolverManager.md) +- [SchemaManager](SchemaManager.sol/abstract.SchemaManager.md) +- [SignedAttestation](SignedAttestation.sol/contract.SignedAttestation.md) +- [TrustManager](TrustManager.sol/abstract.TrustManager.md) +- [TrustManagerExternalAttesterList](TrustManagerExternalAttesterList.sol/abstract.TrustManagerExternalAttesterList.md) diff --git a/docs/src/src/core/ResolverManager.sol/abstract.ResolverManager.md b/docs/src/src/core/ResolverManager.sol/abstract.ResolverManager.md new file mode 100644 index 00000000..ddcd72ba --- /dev/null +++ b/docs/src/src/core/ResolverManager.sol/abstract.ResolverManager.md @@ -0,0 +1,108 @@ +# ResolverManager +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/core/ResolverManager.sol) + +**Inherits:** +[IRegistry](/src/IRegistry.sol/interface.IRegistry.md) + + +## State Variables +### $resolvers + +```solidity +mapping(ResolverUID uid => ResolverRecord resolver) internal $resolvers; +``` + + +## Functions +### onlyResolverOwner + +*Modifier to require that the caller is the owner of a resolver* + + +```solidity +modifier onlyResolverOwner(ResolverUID uid); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`uid`|`ResolverUID`|The UID of the resolver.| + + +### onlyResolver + +If a resolver is not address(0), we check if it supports the IExternalResolver interface + + +```solidity +modifier onlyResolver(IExternalResolver resolver); +``` + +### registerResolver + +Allows Marketplace Agents to register external resolvers. + + +```solidity +function registerResolver(IExternalResolver resolver) external onlyResolver(resolver) returns (ResolverUID uid); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`resolver`|`IExternalResolver`|external resolver contract| + +**Returns** + +|Name|Type|Description| +|----|----|-----------| +|`uid`|`ResolverUID`|ResolverUID of the registered resolver| + + +### setResolver + +Entities that previously regsitered an external resolver, may update the implementation address. + + +```solidity +function setResolver(ResolverUID uid, IExternalResolver resolver) external onlyResolver(resolver) onlyResolverOwner(uid); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`uid`|`ResolverUID`|The UID of the resolver.| +|`resolver`|`IExternalResolver`|The new resolver implementation address.| + + +### transferResolverOwnership + +Transfer ownership of resolverUID to a new address + + +```solidity +function transferResolverOwnership(ResolverUID uid, address newOwner) external onlyResolverOwner(uid); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`uid`|`ResolverUID`|The UID of the resolver to transfer ownership for| +|`newOwner`|`address`|The address of the new owner| + + +### findResolver + +Getter function to get the ResolverRecord of a registerd resolver + + +```solidity +function findResolver(ResolverUID uid) external view returns (ResolverRecord memory); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`uid`|`ResolverUID`|The UID of the resolver.| + + diff --git a/docs/src/src/core/SchemaManager.sol/abstract.SchemaManager.md b/docs/src/src/core/SchemaManager.sol/abstract.SchemaManager.md new file mode 100644 index 00000000..be54c54e --- /dev/null +++ b/docs/src/src/core/SchemaManager.sol/abstract.SchemaManager.md @@ -0,0 +1,69 @@ +# SchemaManager +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/core/SchemaManager.sol) + +**Inherits:** +[IRegistry](/src/IRegistry.sol/interface.IRegistry.md) + +**Author:** +rhinestone | zeroknots.eth, Konrad Kopp (@kopy-kat) + + +## State Variables +### schemas + +```solidity +mapping(SchemaUID uid => SchemaRecord schemaRecord) internal schemas; +``` + + +## Functions +### registerSchema + +Register Schema and (optional) external IExternalSchemaValidator +Schemas describe the structure of the data of attestations +every attestation made on this registry, will reference a SchemaUID to +make it possible to decode attestation data in human readable form +overrwriting a schema is not allowed, and will revert + + +```solidity +function registerSchema( + string calldata schema, + IExternalSchemaValidator validator +) + external + onlySchemaValidator(validator) + returns (SchemaUID uid); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`schema`|`string`|ABI schema used to encode attestations that are made with this schema| +|`validator`|`IExternalSchemaValidator`|(optional) external schema validator that will be used to validate attestations. use address(0), if you dont need an external validator| + +**Returns** + +|Name|Type|Description| +|----|----|-----------| +|`uid`|`SchemaUID`|SchemaUID of the registered schema| + + +### onlySchemaValidator + +If a validator is not address(0), we check if it supports the IExternalSchemaValidator interface + + +```solidity +modifier onlySchemaValidator(IExternalSchemaValidator validator); +``` + +### findSchema + +getter function to retrieve SchemaRecord + + +```solidity +function findSchema(SchemaUID uid) external view override returns (SchemaRecord memory); +``` + diff --git a/docs/src/src/core/SignedAttestation.sol/contract.SignedAttestation.md b/docs/src/src/core/SignedAttestation.sol/contract.SignedAttestation.md new file mode 100644 index 00000000..ad52879d --- /dev/null +++ b/docs/src/src/core/SignedAttestation.sol/contract.SignedAttestation.md @@ -0,0 +1,137 @@ +# SignedAttestation +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/core/SignedAttestation.sol) + +**Inherits:** +[IRegistry](/src/IRegistry.sol/interface.IRegistry.md), [Attestation](/src/core/Attestation.sol/abstract.Attestation.md), EIP712 + + +## State Variables +### attesterNonce + +```solidity +mapping(address attester => uint256 nonce) public attesterNonce; +``` + + +## Functions +### attest + +Allows msg.sender to attest to multiple modules' security status. +The AttestationRequest.Data provided should match the attestation +schema defined by the Schema corresponding to the SchemaUID + +*This function will revert if the same module is attested twice by the same attester. +If you want to re-attest, you have to revoke your attestation first, and then attest again.* + + +```solidity +function attest(SchemaUID schemaUID, address attester, AttestationRequest calldata request, bytes calldata signature) external; +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`schemaUID`|`SchemaUID`|The SchemaUID of the schema the attestation is based on.| +|`attester`|`address`|| +|`request`|`AttestationRequest`|a single AttestationRequest| +|`signature`|`bytes`|| + + +### attest + +Allows msg.sender to attest to multiple modules' security status. +The AttestationRequest.Data provided should match the attestation +schema defined by the Schema corresponding to the SchemaUID + +*This function will revert if the same module is attested twice by the same attester. +If you want to re-attest, you have to revoke your attestation first, and then attest again.* + + +```solidity +function attest(SchemaUID schemaUID, address attester, AttestationRequest[] calldata requests, bytes calldata signature) external; +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`schemaUID`|`SchemaUID`|The SchemaUID of the schema the attestation is based on.| +|`attester`|`address`|| +|`requests`|`AttestationRequest[]`|| +|`signature`|`bytes`|| + + +### revoke + +Allows msg.sender to revoke an attstation made by the same msg.sender + +*this function will revert if the attestation is not found* + + +```solidity +function revoke(address attester, RevocationRequest calldata request, bytes calldata signature) external; +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`attester`|`address`|| +|`request`|`RevocationRequest`| the RevocationRequest| +|`signature`|`bytes`|| + + +### revoke + +Allows msg.sender to revoke an attstation made by the same msg.sender + +*this function will revert if the attestation is not found* + + +```solidity +function revoke(address attester, RevocationRequest[] calldata requests, bytes calldata signature) external; +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`attester`|`address`|| +|`requests`|`RevocationRequest[]`|| +|`signature`|`bytes`|| + + +### _domainNameAndVersion + +override thats used by Solady's EIP712 cache (constructor) + + +```solidity +function _domainNameAndVersion() internal view virtual override returns (string memory name, string memory version); +``` + +### getDigest + + +```solidity +function getDigest(AttestationRequest calldata request, address attester) external view returns (bytes32 digest); +``` + +### getDigest + + +```solidity +function getDigest(AttestationRequest[] calldata requests, address attester) external view returns (bytes32 digest); +``` + +### getDigest + + +```solidity +function getDigest(RevocationRequest calldata request, address attester) external view returns (bytes32 digest); +``` + +### getDigest + + +```solidity +function getDigest(RevocationRequest[] calldata requests, address attester) external view returns (bytes32 digest); +``` + diff --git a/docs/src/src/core/TrustManager.sol/abstract.TrustManager.md b/docs/src/src/core/TrustManager.sol/abstract.TrustManager.md new file mode 100644 index 00000000..f0efdb8e --- /dev/null +++ b/docs/src/src/core/TrustManager.sol/abstract.TrustManager.md @@ -0,0 +1,121 @@ +# TrustManager +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/core/TrustManager.sol) + +**Inherits:** +[IRegistry](/src/IRegistry.sol/interface.IRegistry.md), [TrustManagerExternalAttesterList](/src/core/TrustManagerExternalAttesterList.sol/abstract.TrustManagerExternalAttesterList.md) + +**Author:** +rhinestone | zeroknots.eth, Konrad Kopp (@kopy-kat) +Implements EIP-7484 to query attestations stored in the registry. + +*This contract is abstract and provides utility functions to query attestations.* + + +## State Variables +### $accountToAttester + +```solidity +mapping(address account => TrustedAttesterRecord attesters) internal $accountToAttester; +``` + + +## Functions +### trustAttesters + +Allows smartaccounts - the end users of the registry - to appoint +one or many attesters as trusted. + + +```solidity +function trustAttesters(uint8 threshold, address[] memory attesters) external; +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`threshold`|`uint8`|The minimum number of attestations required for a module to be considered secure.| +|`attesters`|`address[]`|The addresses of the attesters to be trusted.| + + +### check + + +```solidity +function check(address module) external view; +``` + +### checkForAccount + + +```solidity +function checkForAccount(address smartAccount, address module) external view; +``` + +### check + + +```solidity +function check(address module, ModuleType moduleType) external view; +``` + +### checkForAccount + + +```solidity +function checkForAccount(address smartAccount, address module, ModuleType moduleType) external view; +``` + +### _check + +Internal helper function to check for module's security attestations on behalf of a SmartAccount +will use registy's storage to get the trusted attester(s) of a smart account, and check if the module was attested + + +```solidity +function _check(address smartAccount, address module, ModuleType moduleType) internal view; +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`smartAccount`|`address`|the smart account to check for| +|`module`|`address`|address of the module to check| +|`moduleType`|`ModuleType`|(optional param), setting moduleType = 0, will ignore moduleTypes in attestations| + + +### _requireValidAttestation + +Check that attestationRecord is valid: +- not revoked +- not expired +- correct module type (if not ZERO_MODULE_TYPE) + +this function reverts if the attestationRecord is not valid + + +```solidity +function _requireValidAttestation(ModuleType expectedType, AttestationRecord storage $attestation) internal view; +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`expectedType`|`ModuleType`|the expected module type. if this is ZERO_MODULE_TYPE, types specified in the attestation are ignored| +|`$attestation`|`AttestationRecord`|the storage reference of the attestation record to check| + + +### findTrustedAttesters + +Get trusted attester for a specific smartAccount + + +```solidity +function findTrustedAttesters(address smartAccount) public view returns (address[] memory attesters); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`smartAccount`|`address`|The address of the smartAccount| + + diff --git a/docs/src/src/core/TrustManagerExternalAttesterList.sol/abstract.TrustManagerExternalAttesterList.md b/docs/src/src/core/TrustManagerExternalAttesterList.sol/abstract.TrustManagerExternalAttesterList.md new file mode 100644 index 00000000..42918e62 --- /dev/null +++ b/docs/src/src/core/TrustManagerExternalAttesterList.sol/abstract.TrustManagerExternalAttesterList.md @@ -0,0 +1,33 @@ +# TrustManagerExternalAttesterList +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/core/TrustManagerExternalAttesterList.sol) + +**Inherits:** +[IRegistry](/src/IRegistry.sol/interface.IRegistry.md) + +If smart accounts want to query the registry, and supply a list of trusted attesters in calldata, this component can be used + +*This contract is abstract and provides utility functions to query attestations with a calldata provided list of attesters* + + +## Functions +### check + + +```solidity +function check(address module, address attester) external view returns (uint256 attestedAt); +``` + +### checkN + + +```solidity +function checkN(address module, address[] calldata attesters, uint256 threshold) external view returns (uint256[] memory attestedAtArray); +``` + +### _getAttestation + + +```solidity +function _getAttestation(address module, address attester) internal view virtual returns (AttestationRecord storage $attestation); +``` + diff --git a/docs/src/src/external/IExternalResolver.sol/interface.IExternalResolver.md b/docs/src/src/external/IExternalResolver.sol/interface.IExternalResolver.md new file mode 100644 index 00000000..2672560f --- /dev/null +++ b/docs/src/src/external/IExternalResolver.sol/interface.IExternalResolver.md @@ -0,0 +1,91 @@ +# IExternalResolver +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/external/IExternalResolver.sol) + +**Inherits:** +IERC165 + +*The resolver is responsible for validating the schema and attestation data.* + +*The resolver is also responsible for processing the attestation and revocation requests.* + + +## Functions +### resolveAttestation + +*Processes an attestation and verifies whether it's valid.* + + +```solidity +function resolveAttestation(AttestationRecord calldata attestation) external payable returns (bool); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`attestation`|`AttestationRecord`|The new attestation.| + +**Returns** + +|Name|Type|Description| +|----|----|-----------| +|``|`bool`|Whether the attestation is valid.| + + +### resolveAttestation + + +```solidity +function resolveAttestation(AttestationRecord[] calldata attestation) external payable returns (bool); +``` + +### resolveRevocation + +*Processes an attestation revocation and verifies if it can be revoked.* + + +```solidity +function resolveRevocation(AttestationRecord calldata attestation) external payable returns (bool); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`attestation`|`AttestationRecord`|The existing attestation to be revoked.| + +**Returns** + +|Name|Type|Description| +|----|----|-----------| +|``|`bool`|Whether the attestation can be revoked.| + + +### resolveRevocation + + +```solidity +function resolveRevocation(AttestationRecord[] calldata attestation) external payable returns (bool); +``` + +### resolveModuleRegistration + +*Processes a Module Registration* + + +```solidity +function resolveModuleRegistration(address sender, address moduleAddress, ModuleRecord calldata record) external payable returns (bool); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`sender`|`address`|The msg.sender of the module registration| +|`moduleAddress`|`address`|address of the module| +|`record`|`ModuleRecord`|Module registration artefact| + +**Returns** + +|Name|Type|Description| +|----|----|-----------| +|``|`bool`|Whether the registration is valid| + + diff --git a/docs/src/src/external/IExternalSchemaValidator.sol/interface.IExternalSchemaValidator.md b/docs/src/src/external/IExternalSchemaValidator.sol/interface.IExternalSchemaValidator.md new file mode 100644 index 00000000..b9004f5f --- /dev/null +++ b/docs/src/src/external/IExternalSchemaValidator.sol/interface.IExternalSchemaValidator.md @@ -0,0 +1,26 @@ +# IExternalSchemaValidator +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/external/IExternalSchemaValidator.sol) + +**Inherits:** +IERC165 + + +## Functions +### validateSchema + +Validates an attestation request. + + +```solidity +function validateSchema(AttestationRecord calldata attestation) external returns (bool); +``` + +### validateSchema + +Validates an array of attestation requests. + + +```solidity +function validateSchema(AttestationRecord[] calldata attestations) external returns (bool); +``` + diff --git a/docs/src/src/external/README.md b/docs/src/src/external/README.md new file mode 100644 index 00000000..aaa58c78 --- /dev/null +++ b/docs/src/src/external/README.md @@ -0,0 +1,6 @@ + + +# Contents +- [examples](/src/external/examples) +- [IExternalResolver](IExternalResolver.sol/interface.IExternalResolver.md) +- [IExternalSchemaValidator](IExternalSchemaValidator.sol/interface.IExternalSchemaValidator.md) diff --git a/docs/src/src/external/examples/ERC7512Schema.sol/contract.ERC7512SchemaValidator.md b/docs/src/src/external/examples/ERC7512Schema.sol/contract.ERC7512SchemaValidator.md new file mode 100644 index 00000000..1481e239 --- /dev/null +++ b/docs/src/src/external/examples/ERC7512Schema.sol/contract.ERC7512SchemaValidator.md @@ -0,0 +1,29 @@ +# ERC7512SchemaValidator +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/external/examples/ERC7512Schema.sol) + +**Inherits:** +[IExternalSchemaValidator](/src/external/IExternalSchemaValidator.sol/interface.IExternalSchemaValidator.md), [ERC7512](/src/external/examples/ERC7512Schema.sol/interface.ERC7512.md) + + +## Functions +### supportsInterface + + +```solidity +function supportsInterface(bytes4 interfaceID) external pure override returns (bool); +``` + +### validateSchema + + +```solidity +function validateSchema(AttestationRecord calldata attestation) public view override returns (bool valid); +``` + +### validateSchema + + +```solidity +function validateSchema(AttestationRecord[] calldata attestations) external view override returns (bool valid); +``` + diff --git a/docs/src/src/external/examples/ERC7512Schema.sol/interface.ERC7512.md b/docs/src/src/external/examples/ERC7512Schema.sol/interface.ERC7512.md new file mode 100644 index 00000000..d41a62b6 --- /dev/null +++ b/docs/src/src/external/examples/ERC7512Schema.sol/interface.ERC7512.md @@ -0,0 +1,66 @@ +# ERC7512 +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/external/examples/ERC7512Schema.sol) + + +## Errors +### ERC7512_InvalidModuleAddr + +```solidity +error ERC7512_InvalidModuleAddr(); +``` + +## Structs +### Auditor + +```solidity +struct Auditor { + string name; + string uri; + string[] authors; +} +``` + +### Contract + +```solidity +struct Contract { + bytes32 chainId; + address deployment; +} +``` + +### Signature + +```solidity +struct Signature { + SignatureType sigType; + address signer; + bytes data; +} +``` + +### AuditSummary + +```solidity +struct AuditSummary { + Auditor auditor; + uint256 issuedAt; + uint256[] ercs; + Contract auditedContract; + bytes32 auditHash; + string auditUri; + uint256 signedAt; + Signature auditorSignature; +} +``` + +## Enums +### SignatureType + +```solidity +enum SignatureType { + SECP256K1, + ERC1271 +} +``` + diff --git a/docs/src/src/external/examples/README.md b/docs/src/src/external/examples/README.md new file mode 100644 index 00000000..9affe763 --- /dev/null +++ b/docs/src/src/external/examples/README.md @@ -0,0 +1,7 @@ + + +# Contents +- [ERC7512](ERC7512Schema.sol/interface.ERC7512.md) +- [ERC7512SchemaValidator](ERC7512Schema.sol/contract.ERC7512SchemaValidator.md) +- [ResolverBase](ResolverBase.sol/abstract.ResolverBase.md) +- [TokenizedResolver](TokenizedResolver.sol/contract.TokenizedResolver.md) diff --git a/docs/src/src/external/examples/ResolverBase.sol/abstract.ResolverBase.md b/docs/src/src/external/examples/ResolverBase.sol/abstract.ResolverBase.md new file mode 100644 index 00000000..65f20dcc --- /dev/null +++ b/docs/src/src/external/examples/ResolverBase.sol/abstract.ResolverBase.md @@ -0,0 +1,30 @@ +# ResolverBase +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/external/examples/ResolverBase.sol) + +**Inherits:** +[IExternalResolver](/src/external/IExternalResolver.sol/interface.IExternalResolver.md) + + +## State Variables +### REGISTRY + +```solidity +IRegistry internal immutable REGISTRY; +``` + + +## Functions +### constructor + + +```solidity +constructor(IRegistry _registry); +``` + +### onlyRegistry + + +```solidity +modifier onlyRegistry(); +``` + diff --git a/docs/src/src/external/examples/TokenizedResolver.sol/contract.TokenizedResolver.md b/docs/src/src/external/examples/TokenizedResolver.sol/contract.TokenizedResolver.md new file mode 100644 index 00000000..709a94d2 --- /dev/null +++ b/docs/src/src/external/examples/TokenizedResolver.sol/contract.TokenizedResolver.md @@ -0,0 +1,81 @@ +# TokenizedResolver +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/external/examples/TokenizedResolver.sol) + +**Inherits:** +[ResolverBase](/src/external/examples/ResolverBase.sol/abstract.ResolverBase.md) + + +## State Variables +### TOKEN + +```solidity +IERC20 public immutable TOKEN; +``` + + +### fee + +```solidity +uint256 internal immutable fee = 1e18; +``` + + +## Functions +### constructor + + +```solidity +constructor(IERC20 _token, IRegistry _registry) ResolverBase(_registry); +``` + +### supportsInterface + + +```solidity +function supportsInterface(bytes4 interfaceID) external view override returns (bool); +``` + +### resolveAttestation + + +```solidity +function resolveAttestation(AttestationRecord calldata attestation) external payable override onlyRegistry returns (bool); +``` + +### resolveAttestation + + +```solidity +function resolveAttestation(AttestationRecord[] calldata attestation) external payable override onlyRegistry returns (bool); +``` + +### resolveRevocation + + +```solidity +function resolveRevocation(AttestationRecord calldata attestation) external payable override onlyRegistry returns (bool); +``` + +### resolveRevocation + + +```solidity +function resolveRevocation(AttestationRecord[] calldata attestation) external payable override onlyRegistry returns (bool); +``` + +### resolveModuleRegistration + + +```solidity +function resolveModuleRegistration( + address sender, + address moduleAddress, + ModuleRecord calldata record +) + external + payable + override + onlyRegistry + returns (bool); +``` + diff --git a/docs/src/src/lib/AttestationLib.sol/library.AttestationLib.md b/docs/src/src/lib/AttestationLib.sol/library.AttestationLib.md new file mode 100644 index 00000000..04a030e8 --- /dev/null +++ b/docs/src/src/lib/AttestationLib.sol/library.AttestationLib.md @@ -0,0 +1,72 @@ +# AttestationLib +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/lib/AttestationLib.sol) + + +## State Variables +### ATTEST_TYPEHASH + +```solidity +bytes32 internal constant ATTEST_TYPEHASH = keccak256("AttestationRequest(address,uint48,bytes,uint256[])"); +``` + + +### REVOKE_TYPEHASH + +```solidity +bytes32 internal constant REVOKE_TYPEHASH = keccak256("RevocationRequest(address)"); +``` + + +## Functions +### sload2 + + +```solidity +function sload2(AttestationDataRef dataPointer) internal view returns (bytes memory data); +``` + +### sstore2 + + +```solidity +function sstore2(AttestationRequest calldata request, bytes32 salt) internal returns (AttestationDataRef dataPointer); +``` + +### sstore2Salt + +*We are using CREATE2 to deterministically generate the address of the attestation data. +Checking if an attestation pointer already exists, would cost more GAS in the average case.* + + +```solidity +function sstore2Salt(address attester, address module) internal view returns (bytes32 salt); +``` + +### hash + + +```solidity +function hash(AttestationRequest calldata data, uint256 nonce) internal pure returns (bytes32 _hash); +``` + +### hash + + +```solidity +function hash(AttestationRequest[] calldata data, uint256 nonce) internal pure returns (bytes32 _hash); +``` + +### hash + + +```solidity +function hash(RevocationRequest calldata data, uint256 nonce) internal pure returns (bytes32 _hash); +``` + +### hash + + +```solidity +function hash(RevocationRequest[] calldata data, uint256 nonce) internal pure returns (bytes32 _hash); +``` + diff --git a/docs/src/src/lib/Helpers.sol/library.UIDLib.md b/docs/src/src/lib/Helpers.sol/library.UIDLib.md new file mode 100644 index 00000000..126ea2fb --- /dev/null +++ b/docs/src/src/lib/Helpers.sol/library.UIDLib.md @@ -0,0 +1,47 @@ +# UIDLib +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/lib/Helpers.sol) + + +## Functions +### getUID + +*Calculates a UID for a given schema.* + + +```solidity +function getUID(SchemaRecord memory schemaRecord) internal view returns (SchemaUID); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`schemaRecord`|`SchemaRecord`|The input schema.| + +**Returns** + +|Name|Type|Description| +|----|----|-----------| +|``|`SchemaUID`|schema UID.| + + +### getUID + +*Calculates a UID for a given resolver.* + + +```solidity +function getUID(ResolverRecord memory resolver) internal view returns (ResolverUID); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`resolver`|`ResolverRecord`|The input schema.| + +**Returns** + +|Name|Type|Description| +|----|----|-----------| +|``|`ResolverUID`|ResolverUID.| + + diff --git a/docs/src/src/lib/ModuleDeploymentLib.sol/library.ModuleDeploymentLib.md b/docs/src/src/lib/ModuleDeploymentLib.sol/library.ModuleDeploymentLib.md new file mode 100644 index 00000000..b1da8146 --- /dev/null +++ b/docs/src/src/lib/ModuleDeploymentLib.sol/library.ModuleDeploymentLib.md @@ -0,0 +1,69 @@ +# ModuleDeploymentLib +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/lib/ModuleDeploymentLib.sol) + +**Author:** +zeroknots + +*A library that can be used to deploy the Registry* + + +## Functions +### containsCaller + + +```solidity +modifier containsCaller(bytes32 salt); +``` + +### deploy + + +```solidity +function deploy(bytes calldata _initCode, bytes32 salt) internal containsCaller(salt) returns (address deploymentAddress); +``` + +### calcAddress + +Calculates the deterministic address of a contract that would be deployed using the CREATE2 opcode. + +*The calculated address is based on the contract's code, a salt, and the address of the current contract.* + +*This function uses the formula specified in EIP-1014 (https://eips.ethereum.org/EIPS/eip-1014).* + + +```solidity +function calcAddress(bytes calldata initCode, bytes32 salt) internal view returns (address targetDeploymentAddress); +``` +**Parameters** + +|Name|Type|Description| +|----|----|-----------| +|`initCode`|`bytes`|The contract code that would be deployed.| +|`salt`|`bytes32`|A salt used for the address calculation. This must be the same salt that would be passed to the CREATE2 opcode.| + +**Returns** + +|Name|Type|Description| +|----|----|-----------| +|`targetDeploymentAddress`|`address`|The address that the contract would be deployed at if the CREATE2 opcode was called with the specified _code and _salt.| + + +## Errors +### InvalidSalt + +```solidity +error InvalidSalt(); +``` + +### InvalidAddress + +```solidity +error InvalidAddress(); +``` + +### InvalidDeployment + +```solidity +error InvalidDeployment(); +``` + diff --git a/docs/src/src/lib/ModuleTypeLib.sol/library.ModuleTypeLib.md b/docs/src/src/lib/ModuleTypeLib.sol/library.ModuleTypeLib.md new file mode 100644 index 00000000..8215dfa1 --- /dev/null +++ b/docs/src/src/lib/ModuleTypeLib.sol/library.ModuleTypeLib.md @@ -0,0 +1,26 @@ +# ModuleTypeLib +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/lib/ModuleTypeLib.sol) + + +## Functions +### isType + + +```solidity +function isType(PackedModuleTypes self, ModuleType moduleType) internal pure returns (bool); +``` + +### isType + + +```solidity +function isType(uint32 packed, uint256 check) internal pure returns (bool); +``` + +### pack + + +```solidity +function pack(ModuleType[] memory moduleTypes) internal pure returns (PackedModuleTypes); +``` + diff --git a/docs/src/src/lib/README.md b/docs/src/src/lib/README.md new file mode 100644 index 00000000..6071bb1a --- /dev/null +++ b/docs/src/src/lib/README.md @@ -0,0 +1,8 @@ + + +# Contents +- [AttestationLib](AttestationLib.sol/library.AttestationLib.md) +- [UIDLib](Helpers.sol/library.UIDLib.md) +- [ModuleDeploymentLib](ModuleDeploymentLib.sol/library.ModuleDeploymentLib.md) +- [ModuleTypeLib](ModuleTypeLib.sol/library.ModuleTypeLib.md) +- [StubLib](StubLib.sol/library.StubLib.md) diff --git a/docs/src/src/lib/StubLib.sol/library.StubLib.md b/docs/src/src/lib/StubLib.sol/library.StubLib.md new file mode 100644 index 00000000..e556d31c --- /dev/null +++ b/docs/src/src/lib/StubLib.sol/library.StubLib.md @@ -0,0 +1,80 @@ +# StubLib +[Git Source](https://github.com/rhinestonewtf/registry/blob/350cdd9001705a91cd42a82c8ee3e0cd055714e5/src/lib/StubLib.sol) + +*A library that interacts with IExternalResolver and IExternalSchemaValidator* + + +## Functions +### requireExternalSchemaValidation + +if Schema Validator is set, it will call validateSchema() on the validator + + +```solidity +function requireExternalSchemaValidation(AttestationRecord memory attestationRecord, SchemaRecord storage $schema) internal; +``` + +### requireExternalSchemaValidation + + +```solidity +function requireExternalSchemaValidation(AttestationRecord[] memory attestationRecords, SchemaRecord storage $schema) internal; +``` + +### requireExternalResolverOnAttestation + + +```solidity +function requireExternalResolverOnAttestation(AttestationRecord memory attestationRecord, ResolverRecord storage $resolver) internal; +``` + +### requireExternalResolverOnAttestation + + +```solidity +function requireExternalResolverOnAttestation(AttestationRecord[] memory attestationRecords, ResolverRecord storage $resolver) internal; +``` + +### tryExternalResolverOnRevocation + + +```solidity +function tryExternalResolverOnRevocation( + AttestationRecord memory attestationRecord, + ResolverRecord storage $resolver +) + internal + returns (bool resolved); +``` + +### tryExternalResolverOnRevocation + + +```solidity +function tryExternalResolverOnRevocation( + AttestationRecord[] memory attestationRecords, + ResolverRecord storage $resolver +) + internal + returns (bool resolved); +``` + +### requireExternalResolverOnModuleRegistration + + +```solidity +function requireExternalResolverOnModuleRegistration( + ModuleRecord memory moduleRecord, + address moduleAddress, + ResolverRecord storage $resolver +) + internal; +``` + +## Events +### ResolverRevocationError + +```solidity +event ResolverRevocationError(IExternalResolver resolver); +``` + diff --git a/foundry.toml b/foundry.toml index e554080e..32072b05 100644 --- a/foundry.toml +++ b/foundry.toml @@ -11,6 +11,9 @@ line_length = 140 multiline_func_header = "all" number_underscore="thousands" +[doc] +title = "Rhinestone Registry" + [invariant] # fail_on_revert = true runs = 1200 diff --git a/slither.config.json b/slither.config.json new file mode 100644 index 00000000..0abdc2d3 --- /dev/null +++ b/slither.config.json @@ -0,0 +1,9 @@ +{ + "solc_remaps": [ + "@openzeppelin/=node_modules/@openzeppelin/", + "solmate/=node_modules/solmate/src/", + "solady/=node_modules/solady/src/", + "forge-std/=node_modules/forge-std/src/", + "ds-test/=node_modules/ds-test/src/" + ] +} diff --git a/src/core/AttestationManager.sol b/src/core/AttestationManager.sol index 9e55ff3f..40138483 100644 --- a/src/core/AttestationManager.sol +++ b/src/core/AttestationManager.sol @@ -45,6 +45,9 @@ abstract contract AttestationManager is IRegistry, ModuleManager, SchemaManager, * and call it, if an external IExternalSchemaValidator was set * function will get the external IExternalResolver for the module - that the attestation is for * and call it, if an external Resolver was set + * @param attester The address of the attesting account. + * @param schemaUID the UID of the schema that the attestation is made for + * @param request AttestationRequest send by attester via calldata */ function _attest(address attester, SchemaUID schemaUID, AttestationRequest calldata request) internal { (AttestationRecord memory record, ResolverUID resolverUID) =