dipdup-io / dipdup

Modular framework for creating selective indexers and featureful backends for dapps
https://dipdup.io
MIT License
97 stars 52 forks source link

dipdup init does not work as expected with this contract: KT1WgoWgvKJiQ43MkeLoG7LtSZMxeED7Rn8T #255

Closed smak0v closed 2 years ago

smak0v commented 2 years ago
spec_version: 1.2
package: crypto_horses

database:
  kind: sqlite
  path: crypto_horses.sqlite3

contracts:
  crypto_horses_testnet:
    address: KT1WgoWgvKJiQ43MkeLoG7LtSZMxeED7Rn8T
    typename: crypto_horses

datasources:
  tzkt_testnet:
    kind: tzkt
    url: https://hangzhou2net.tzkt.io

indexes:
  crypto_horses:
    kind: operation
    contracts:
      - crypto_horses_testnet
    datasource: tzkt_testnet
    handlers:
      - callback: on_race_launch
        pattern:
          - destination: crypto_horses_testnet
            entrypoint: launch_race
droserasprout commented 2 years ago

Hi, and thanks for reaching out! tzkt_testnet datasource has an incorrect URL. Replace it with https://api.hangzhou2net.tzkt.io (api part is missing in your example). Works fine for me after this change.

smak0v commented 2 years ago

I changed the URL to https://api.hangzhou2net.tzkt.io and it doesn't work for me :(

Here is the error:

INFO     dipdup.codegen       Creating package `crypto_horses`
INFO     dipdup.utils         Creating directory `/Users/smak0v/hackatons/crypto-horses-backend/crypto_horses`
INFO     dipdup.utils         Creating file `/Users/smak0v/hackatons/crypto-horses-backend/crypto_horses/__init__.py`
INFO     dipdup.utils         Writing into file `/Users/smak0v/hackatons/crypto-horses-backend/crypto_horses/models.py`
INFO     dipdup.utils         Creating directory `/Users/smak0v/hackatons/crypto-horses-backend/crypto_horses/handlers`
INFO     dipdup.utils         Creating file `/Users/smak0v/hackatons/crypto-horses-backend/crypto_horses/handlers/__init__.py`
INFO     dipdup.utils         Creating directory `/Users/smak0v/hackatons/crypto-horses-backend/crypto_horses/hooks`
INFO     dipdup.utils         Creating file `/Users/smak0v/hackatons/crypto-horses-backend/crypto_horses/hooks/__init__.py`
INFO     dipdup.utils         Creating directory `/Users/smak0v/hackatons/crypto-horses-backend/crypto_horses/sql`
INFO     dipdup.utils         Creating file `/Users/smak0v/hackatons/crypto-horses-backend/crypto_horses/sql/.keep`
INFO     dipdup.utils         Creating directory `/Users/smak0v/hackatons/crypto-horses-backend/crypto_horses/graphql`
INFO     dipdup.utils         Creating file `/Users/smak0v/hackatons/crypto-horses-backend/crypto_horses/graphql/.keep`
INFO     dipdup.codegen       Initializing project
INFO     dipdup.codegen       Creating `schemas` directory
INFO     dipdup.utils         Creating directory `/Users/smak0v/hackatons/crypto-horses-backend/crypto_horses/schemas`
INFO     dipdup.codegen       Fetching schemas for contract `KT1WgoWgvKJiQ43MkeLoG7LtSZMxeED7Rn8T`
INFO     dipdup.tzkt          tzkt_testnet: Fetching jsonschemas for address `KT1WgoWgvKJiQ43MkeLoG7LtSZMxeED7Rn8T
INFO     dipdup.utils         Creating directory `/Users/smak0v/hackatons/crypto-horses-backend/crypto_horses/schemas/crypto_horses`
Traceback (most recent call last):
  File "/Users/smak0v/Library/Caches/pypoetry/virtualenvs/crypto-horses-backend-bWHOXJn--py3.9/bin/dipdup", line 8, in <module>
    sys.exit(cli())
  File "/Users/smak0v/Library/Caches/pypoetry/virtualenvs/crypto-horses-backend-bWHOXJn--py3.9/lib/python3.9/site-packages/asyncclick/core.py", line 1150, in __call__
    return anyio.run(self._main, main, args, kwargs, **({"backend":_anyio_backend} if _anyio_backend is not None else {}))
  File "/Users/smak0v/Library/Caches/pypoetry/virtualenvs/crypto-horses-backend-bWHOXJn--py3.9/lib/python3.9/site-packages/anyio/_core/_eventloop.py", line 56, in run
    return asynclib.run(func, *args, **backend_options)
  File "/Users/smak0v/Library/Caches/pypoetry/virtualenvs/crypto-horses-backend-bWHOXJn--py3.9/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 233, in run
    return native_run(wrapper(), debug=debug)
  File "/usr/local/Cellar/python@3.9/3.9.8/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/local/Cellar/python@3.9/3.9.8/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/Users/smak0v/Library/Caches/pypoetry/virtualenvs/crypto-horses-backend-bWHOXJn--py3.9/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 228, in wrapper
    return await func(*args)
  File "/Users/smak0v/Library/Caches/pypoetry/virtualenvs/crypto-horses-backend-bWHOXJn--py3.9/lib/python3.9/site-packages/asyncclick/core.py", line 1153, in _main
    return await main(*args, **kwargs)
  File "/Users/smak0v/Library/Caches/pypoetry/virtualenvs/crypto-horses-backend-bWHOXJn--py3.9/lib/python3.9/site-packages/asyncclick/core.py", line 1074, in main
    rv = await self.invoke(ctx)
  File "/Users/smak0v/Library/Caches/pypoetry/virtualenvs/crypto-horses-backend-bWHOXJn--py3.9/lib/python3.9/site-packages/asyncclick/core.py", line 1684, in invoke
    return await _process_result(await sub_ctx.command.invoke(sub_ctx))
  File "/Users/smak0v/Library/Caches/pypoetry/virtualenvs/crypto-horses-backend-bWHOXJn--py3.9/lib/python3.9/site-packages/asyncclick/core.py", line 1420, in invoke
    return await ctx.invoke(self.callback, **ctx.params)
  File "/Users/smak0v/Library/Caches/pypoetry/virtualenvs/crypto-horses-backend-bWHOXJn--py3.9/lib/python3.9/site-packages/asyncclick/core.py", line 774, in invoke
    rv = await rv
  File "/Users/smak0v/Library/Caches/pypoetry/virtualenvs/crypto-horses-backend-bWHOXJn--py3.9/lib/python3.9/site-packages/dipdup/cli.py", line 94, in wrapper
    await fn(*args, **kwargs)
  File "/Users/smak0v/Library/Caches/pypoetry/virtualenvs/crypto-horses-backend-bWHOXJn--py3.9/lib/python3.9/site-packages/dipdup/cli.py", line 226, in init
    await dipdup.init(overwrite_types, keep_schemas)
  File "/Users/smak0v/Library/Caches/pypoetry/virtualenvs/crypto-horses-backend-bWHOXJn--py3.9/lib/python3.9/site-packages/dipdup/dipdup.py", line 338, in init
    await self._codegen.init(overwrite_types, keep_schemas)
  File "/Users/smak0v/Library/Caches/pypoetry/virtualenvs/crypto-horses-backend-bWHOXJn--py3.9/lib/python3.9/site-packages/dipdup/codegen.py", line 112, in init
    await self.fetch_schemas()
  File "/Users/smak0v/Library/Caches/pypoetry/virtualenvs/crypto-horses-backend-bWHOXJn--py3.9/lib/python3.9/site-packages/dipdup/codegen.py", line 183, in fetch_schemas
    storage_schema = preprocess_storage_jsonschema(contract_schemas['storageSchema'])
TypeError: byte indices must be integers or slices, not str
________________________________________________________________________________

Unexpected error occurred!

Please file a bug report at https://github.com/dipdup-net/dipdup/issues and attach the following:

  * `dipdup.yml` config. Make sure to remove sensitive information.
  * Reasonable amount of logs before the crash.
droserasprout commented 2 years ago

Sorry, it appears you also need to run dipdup cache clear command. Due to a bug, an invalid API response was cached on the disk.

smak0v commented 2 years ago

Yeah, it works Thank you!