-
Notifications
You must be signed in to change notification settings - Fork 327
ENSIP-16 - CCIP metadata #116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from 24 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
0a7eff8
First draft ccip-metadata
jefflau 61d470f
Add more functions
jefflau d973f53
Add Record Keys
jefflau a43d393
Remove ccip vocab
jefflau 350321b
Update ens-improvement-proposals/ensip-14-ccip-metadata.md
jefflau e52200e
Merge branch 'master' of github.com:ensdomains/docs into ensip-14
jefflau 2ca5e18
Add return types, expand on MUST statement
jefflau ecc5ffe
Switch to graphql data type
jefflau beb8f9d
Merge
jefflau a979c83
Create graphurl endpoint and support for owned node
makoto 67aa91c
Add comments on schema
makoto c697ad7
Add Open Items
makoto 90fa9d4
Fix typo
makoto d27f5db
Fix typo
makoto d8eac7e
Merge pull request #136 from ensdomains/metadata-ensip-withowned-node
jefflau 92c0097
Merge branch 'master' into ensip-14
makoto acbfbe5
Add Context (#142)
makoto 3181488
Remove xx
makoto c7abdad
Modify the graph structure
makoto 751b5ce
Changed the order of address and context
makoto 4b3365f
Shuffle the order of context and dynamic metadata
makoto 16299de
Revert changes
makoto 7c1dae5
Add an explanation of context
makoto 2d7a184
Remove implementation specific requirement for owner
makoto c0aafd9
Address feedbacks
makoto a730620
Apply suggestions from code review
makoto e83d4ad
Address feedback
makoto a388a9c
ADD isApprovedFor to both l1 and l2 contracts
makoto be1bbc1
Add comment
makoto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
167 changes: 167 additions & 0 deletions
167
ens-improvement-proposals/ensip-16-offchain-metadata.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,167 @@ | ||
| --- | ||
| description: Allows metadata to be queried on ERC-3668 enabled names | ||
| --- | ||
|
|
||
| # ENSIP-16: Offchain metadata | ||
|
|
||
| | **Author** | Jeff Lau \<[email protected]> | | ||
| | ------------- | ---------------------------- | | ||
| | **Status** | Draft | | ||
| | **Submitted** | 2022-09-22 | | ||
|
|
||
| ### Abstract | ||
|
|
||
| This ENSIP allows metadata to be queried directly on the resolver for ERC-3668(CCIP Read: Secure offchain data retrieval) enabled names. ERC-3668 will power many of the domains in the future, however since the retrieval mechanism uses wildcard + offchain resolver, there is no standardised way to retrieve important metadata information such as the owner (who can change the records), or which L2/offchain database the records are stored on. | ||
makoto marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### Motivation | ||
|
|
||
| With ERC-3668 subdomains already starting to get used by larger partners in the ENS ecosystem, it is important that there is a way of frontend interfaces to get important metadata to allow a smooth user interface. For instance the owner of a ERC-3668 enabled name would need to be known, for a UI to show whether or not the currently connected account has the rights to edit the records. If the owner was not known, the only way to know would be to make the edit and wait for failure. | ||
makoto marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| This ENSIP addresses this by adding a way of important metadata to be gathered on the offchain resolver, which would likely revert and be also resolved offchain, however there is an option for it to be also left onchain if there value was static and wouldn't need to be changed often. | ||
|
|
||
| ### Specification | ||
|
|
||
| The metadata should include 2 different types of info | ||
|
|
||
| - Offchain data storage location related info: `graphqlUrl` includes the URL to fetch the metadata. | ||
|
|
||
| - Ownership related info: `owner`, `isApprovedForAll` defines who can own or update the given record. | ||
|
|
||
| #### Context | ||
|
|
||
| An optional field "context" is introduced by utilizing an arbitrary bytes string to define the namespace to which a record belongs. | ||
|
|
||
| For example, this "context" can refer to the address of the entity that has set a particular record. By associating records with specific addresses, users can confidently manage their records in a trustless manner on Layer 2 without direct access to the ENS Registry contract on the Ethereum mainnet. Please refer to [ENS-Bedrock-Resolver](https://github.com/corpus-io/ENS-Bedrock-Resolver#context) for the reference integration | ||
|
|
||
| #### Dynamic Metadata | ||
|
|
||
| Metadata serves a crucial role in providing valuable insights about a node owner and their specific resolver. In certain scenarios, resolvers may choose to adopt diverse approaches to resolve data based on the node. An example of this would be handling subdomains of a particular node differently. For instance, we could resolve "optimism.foo.eth" using a contract on optimism and "gnosis.foo.eth" using a contract on gnosis. | ||
| By passing the name through metadata, we empower the resolution process, enabling CcipResolve flows to become remarkably flexible and scalable. This level of adaptability ensures that our system can accommodate a wide array of use cases, making it more user-friendly and accommodating for a diverse range of scenarios. | ||
|
|
||
| ### Implementation | ||
|
|
||
| ```solidity | ||
|
|
||
| interface OffChainResolver { | ||
makoto marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| /** @dev Returns the owner of the resolver on L2 | ||
| * @param node | ||
| * @return owner in bytes32 instead of address to cater for non EVM based owner information | ||
| */ | ||
| owner(bytes32 node) returns (bytes32 owner); | ||
|
|
||
| isApprovedForAll(address account, address operator) returns (boolean); | ||
makoto marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| /** @dev Returns the owner of the resolver on L2 | ||
| * @return name can be l2 chain name or url if offchain | ||
| * @return coinType according to https://github.com/ensdomains/address-encoder | ||
| * @return graphqlUrl url of graphql endpoint that provides additional information about the offchain name and its subdomains | ||
| * @return storageType 0 = EVM, 1 = Non blockchain, 2 = Starknet | ||
| * @storageLocation = l2 contract address | ||
| * @return context = an arbitrary bytes string to define the namespace to which a record belongs such as the name owner. | ||
| */ | ||
| function metadata(bytes calldata name) | ||
| external | ||
| view | ||
| returns (string memory, uint256, string memory, uint8, bytes memory, bytes memory) | ||
| { | ||
| return (name, coinType, graphqlUrl, storageType, storageLocation, context); | ||
| } | ||
|
|
||
| // Optional. If context is dynamic, the event won't be emitted. | ||
| event MetadataChanged( | ||
| string name, | ||
| uint256 coinType, | ||
| string graphqlUrl, | ||
| uint8 storageType, | ||
| bytes storageLocation, | ||
| bytes context | ||
| ); | ||
| } | ||
| ``` | ||
|
|
||
| ```javascript | ||
| const node = namehash('ccipreadsub.example.eth') | ||
| const resolver = await ens.resolver(node) | ||
| const owner = await resolver.owner(node) | ||
| // 0x123... | ||
| const dataLocation = await.resolver.graphqlUrl() | ||
| // { | ||
| // url: 'http://example.com/ens/graphql', | ||
| // } | ||
| ``` | ||
|
|
||
| ##### GgraphQL schema | ||
makoto marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ##### L1 | ||
|
|
||
| ```graphql | ||
|
|
||
| type Domain @entity{ | ||
| id | ||
| metadata: Metadata | ||
| } | ||
|
|
||
| type Metadata @entity { | ||
| "l1 resolver address" | ||
| id: ID! | ||
| "Name of the Chain" | ||
| name: String | ||
| "coin type" | ||
| coinType: BigInt | ||
| "url of the graphql endpoint" | ||
| graphqlUrl: String | ||
| "0 for evm, 1 for non blockchain, 2 for starknet" | ||
| storageType: Int | ||
| "l2 contract address" | ||
| storageLocation: Bytes | ||
| "optional field to store an arbitrary bytes string to define the namespace to which a record belongs" | ||
| context: Bytes | ||
| "optional field if the name has expirty date offchain" | ||
| expiryDate: BigInt | ||
| } | ||
|
|
||
| type Resolver @entity { | ||
| offchain: Offchain | ||
| } | ||
| ``` | ||
|
|
||
| ##### L2 | ||
|
|
||
| ```graphql | ||
| type Domain { | ||
| id: ID! # concatenation of context and namehash delimited by `-` | ||
| context: Bytes | ||
| name: String | ||
| namehash: Bytes | ||
| labelName: String | ||
| labelhash: Bytes | ||
| resolvedAddress: Bytes | ||
| parent: Domain | ||
| subdomains: [Domain] | ||
makoto marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| resolver: Resolver! | ||
| expiryDate: BigInt | ||
| } | ||
|
|
||
| type Resolver @entity { | ||
| id: ID! # concatenation of node, resolver address and context delimited by `-` | ||
| node: Bytes | ||
| context: Bytes | ||
| address: Bytes | ||
| domain: Domain | ||
| addr: Bytes | ||
| contentHash: Bytes | ||
| texts: [String!] | ||
| coinTypes: [BigInt!] | ||
| } | ||
| ``` | ||
|
|
||
| ### Backwards Compatibility | ||
|
|
||
| None | ||
|
|
||
| ### Open Items | ||
|
|
||
| - Should `owner` and `isApprovedForAll` be within graphql or shoud be own metadata function? | ||
|
|
||
| ### Copyright | ||
|
|
||
| Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.