Parsers
BaseParser
Base protocol for Parser classes
Attributes:
Name | Type | Description |
---|---|---|
_METADATA_STANDARD |
MetadataStandard
|
a class variable defining the metadata standard a parser supports. |
fetcher |
BaseFetcher
|
a fetcher instance responsible for fetching content, mime type, and size by making requests. |
Source code in offchain/metadata/parsers/base_parser.py
gen_parse_metadata(token, raw_data, *args, **kwargs)
async
Given a token and raw data returned from the token uri, return a normalized Metadata object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
token |
Token
|
token to process metadata for. |
required |
raw_data |
dict
|
raw data returned from token uri. |
required |
Returns:
Type | Description |
---|---|
Optional[Metadata]
|
Optional[Metadata]: normalized metadata object, if successfully parsed. |
Source code in offchain/metadata/parsers/base_parser.py
parse_metadata(token, raw_data, *args, **kwargs)
Given a token and raw data returned from the token uri, return a normalized Metadata object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
token |
Token
|
token to process metadata for. |
required |
raw_data |
dict
|
raw data returned from token uri. |
required |
Returns:
Type | Description |
---|---|
Optional[Metadata]
|
Optional[Metadata]: normalized metadata object, if successfully parsed. |
Source code in offchain/metadata/parsers/base_parser.py
should_parse_token(token, raw_data, *args, **kwargs)
Return whether or not a collection parser should parse a given token.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
token |
Token
|
the token whose metadata needs to be parsed. |
required |
raw_data |
dict
|
raw data returned from token uri. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
whether or not the collection parser handles this token. |
Source code in offchain/metadata/parsers/base_parser.py
CollectionParser
Base class for collection parsers
All parsers that handle collection-based metadata parsing will need to inherit from this base class.
Attributes:
Name | Type | Description |
---|---|---|
_COLLECTION_ADDRESSES |
list[str]
|
list of collection addresses that a parser class handles. |
_METADATA_STANDARD |
MetadataStandard
|
(MetadataStandard): metadata standard of all metadata returned by this class of parser. Defaults to MetadataStandard.COLLECTION_STANDARD. |
fetcher |
BaseFetcher
|
a fetcher instance for making network requests. |
contract_caller |
ContractCaller
|
a contract caller instance for fetching data from contracts. |
Source code in offchain/metadata/parsers/collection/collection_parser.py
should_parse_token(token, *args, **kwargs)
Return whether or not a collection parser should parse a given token.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
token |
Token
|
the token whose metadata needs to be parsed. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
whether or not the collection parser handles this token. |
Source code in offchain/metadata/parsers/collection/collection_parser.py
SchemaParser
Base class for schema parsers
All parsers that handle schema-based metadata parsing will need to inherit from this base class.
Attributes:
Name | Type | Description |
---|---|---|
fetcher |
BaseFetcher
|
a fetcher instance for making network requests |