USER STORY: Return basic contract metadata(TZIP-16) for a smart contract
As a developer user, I want to retrieve contract metadata for a contract, so that I can display it in my app or use it as part of the application workflow.
Refer to TZIP-16: https://gitlab.com/tzip/tzip/-/blob/master/proposals/tzip-16/tzip-16.md You can learn from Taquito epic documented here as well: https://www.notion.so/ecad/Epic-TZIP-16-Contract-Metadata-623d88d92747494185dcd9468b0f7dc3#26dfc901dd8a4facb4952bf97be8b677
See Taquito coding and smart contract example here: https://tezostaquito.io/docs/metadata-tzip16/#execute-off-chain-views https://better-call.dev/search?text=KT1EaeTNwTzxkS45kkTuDN4rqAghDTLn95La
For Metadata URI, see the specification of a URI's generic format: https://tools.ietf.org/html/rfc3986
Example:
{ "version": "foo.1.4.2", "license": "ISC", "authors": [ "Seb Mondet <seb@mondet.org>" ], "interfaces": [ "TZIP-12" ], "views": [ // ... see below ... ] // ... potential extensions ...}
Acceptance criteria:
- Contract metadata can be fetched using the existing Account entry point
- Fetch Smart Contract full schema for a given contract
- Fetch full basic Contract metadata for a given contract (excluding views for now)
- name
- description
- version
- license
- name
- details
- authors
- source
- location
- tools
- interfaces
- errors - list or error or view entities, see below
{ "error": {"int": "42"},
"expansion": { "string": "You did something wrong"},
"languages": ["en"] },
{ "view": "translateStringError" }
- Metadata format options: json
- Fetch each of Contract Metadata elements (see names above) from a given contract
- When fetching metadata for a given contract, validate:
- Check if it is located within the top-level tree of nested pairs forming the
storage type
- if validation fails, fail fetching with an error: Metadata not found.
- Check if it is located within the top-level tree of nested pairs forming the
storage type
- Supported cases:
- Storage types:
- tezos-storage:self
- with/without sha256 hash
- tezos-storage: refers to the other smart contract for the current network
- with/without sha256 hash
- tezos-storage: http/https
- with or without sha256
- tezos-storage: ipfs
- tezos-storage:self
- Edge case:
- empty metadata, still TZIP-16
- long string(2000+ characters) as a metadata
- Emojis, Naughty Strings (https://github.com/minimaxir/big-list-of-naughty-strings, ) and other edge cases UTF-8 (French, Chinese characters)
- Failure scenarios:
- Account is not KT1 - do not return anything
- no data - return null
- In all other cases, return Metadata not found.(another option to cover more cases Metadata cannot be read in all other scenarios. That may include:
- Invalid URI
- Invalid JSON
- Invalid metadata type/location error
- Storage types:
OUT OF SCOPE:
- Queries must work for a list of accounts - #262 (closed)
- off-chain views will be handled in a separate issue - #235 (closed)
- caching - #238
- assertMetadata - is there any contracts that use this that could be found in the indexer DB?
IMPLEMENTATION NOTES:
- big_map %metadata is stored in DBIndexer as jsonb. Metadata big_map values are always bytes.
- we should read metadata bigmap in the DB and fetch the metadata for tezos-storage:self or tezos-storage:other contract,
- otherwise for https/https/ipfs there is a possibility to use @taquito-utils https://tezostaquito.io/typedoc/classes/_taquito_http_utils.httpbackend.html