OpenRarity / open-rarity

Reference implementation of the OpenRarity protocol with Python.
Apache License 2.0
218 stars 47 forks source link

Error when parsing, calling lower() to an int #97

Open maxisch opened 2 years ago

maxisch commented 2 years ago

Describe the bug On a few collections there is an issue when parsing it's traits. deadfellaz, cyberbrokers and more

Information

To Reproduce Steps to reproduce the behavior: run: python3 -m scripts.score_real_collections deadfellaz

Expected behavior Int traits should not be lowercased

Environment

Additional context Stacktrace:

python3 -m scripts.score_real_collections deadfellaz
Scoring collections: ['deadfellaz'] with use_cache=True
Output file prefix: score_real_collections_results with type .json
Generating results for: deadfellaz
No opensea cache file found for deadfellaz: cached_data/deadfellaz_cached_os_trait_data.json
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/maximiliano/repos/pixel/localhost/open-rarity/scripts/score_real_collections.py", line 117, in <module>
    score_collection_and_output_results(
  File "/Users/maximiliano/repos/pixel/localhost/open-rarity/scripts/score_real_collections.py", line 47, in score_collection_and_output_results
    collection = get_collection_from_opensea(slug, use_cache=use_cache)
  File "/Users/maximiliano/repos/pixel/localhost/open-rarity/open_rarity/resolver/opensea_api_helpers.py", line 391, in get_collection_from_opensea
    tokens = get_all_collection_tokens(
  File "/Users/maximiliano/repos/pixel/localhost/open-rarity/open_rarity/resolver/opensea_api_helpers.py", line 206, in get_all_collection_tokens
    tokens_batch = get_tokens_from_opensea(
  File "/Users/maximiliano/repos/pixel/localhost/open-rarity/open_rarity/resolver/opensea_api_helpers.py", line 277, in get_tokens_from_opensea
    token_metadata = opensea_traits_to_token_metadata(asset_traits=asset["traits"])
  File "/Users/maximiliano/repos/pixel/localhost/open-rarity/open_rarity/resolver/opensea_api_helpers.py", line 145, in opensea_traits_to_token_metadata
    string_attr[trait["trait_type"]] = StringAttribute(
  File "/Users/maximiliano/repos/pixel/localhost/open-rarity/open_rarity/models/token_metadata.py", line 30, in __init__
    self.value = normalize_attribute_string(value)
  File "/Users/maximiliano/repos/pixel/localhost/open-rarity/open_rarity/models/utils/attribute_utils.py", line 17, in normalize_attribute_string
    return value.lower().strip()
AttributeError: 'int' object has no attribute 'lower'
impreso commented 1 year ago

We will fix this in 1.0.0 release, thanks for reporting.