Skip to content
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

Error calling blockchain.atomicals.list #231

Open
xyunsh opened this issue Sep 27, 2024 · 7 comments
Open

Error calling blockchain.atomicals.list #231

xyunsh opened this issue Sep 27, 2024 · 7 comments

Comments

@xyunsh
Copy link

xyunsh commented Sep 27, 2024

url: 'http://localhost:8080/proxy/blockchain.atomicals.list',
data: '{"params":[50,84350,1]}'

024-09-27 11:59:50 ERROR:HttpSession:Exception during formatting request: POST http://localhost:8080/proxy/blockchain.atomicals.list, exception: Object of type undefined_type is not JSON serializable, stack: Traceback (most recent call last):
2024-09-27 11:59:50   File "/electrumx/electrumx/server/session/http_session.py", line 69, in formatted_request
2024-09-27 11:59:50     return success_resp(result)
2024-09-27 11:59:50   File "/electrumx/electrumx/server/http_middleware.py", line 100, in success_resp
2024-09-27 11:59:50     return web.json_response(data=result)
2024-09-27 11:59:50   File "/usr/local/lib/python3.10/site-packages/aiohttp/web_response.py", line 811, in json_response
2024-09-27 11:59:50     text = dumps(data)
2024-09-27 11:59:50   File "/usr/local/lib/python3.10/json/__init__.py", line 231, in dumps
2024-09-27 11:59:50     return _default_encoder.encode(obj)
2024-09-27 11:59:50   File "/usr/local/lib/python3.10/json/encoder.py", line 199, in encode
2024-09-27 11:59:50     chunks = self.iterencode(o, _one_shot=True)
2024-09-27 11:59:50   File "/usr/local/lib/python3.10/json/encoder.py", line 257, in iterencode
2024-09-27 11:59:50     return _iterencode(o, 0)
2024-09-27 11:59:50   File "/usr/local/lib/python3.10/json/encoder.py", line 179, in default
2024-09-27 11:59:50     raise TypeError(f'Object of type {o.__class__.__name__} '
2024-09-27 11:59:50 TypeError: Object of type undefined_type is not JSON serializable
2024-09-27 11:59:50 
@xyunsh
Copy link
Author

xyunsh commented Sep 27, 2024

@wizz-wallet-dev
Copy link
Collaborator

Which network is serving with?

@xyunsh
Copy link
Author

xyunsh commented Oct 17, 2024

Mainnet

@xyunsh
Copy link
Author

xyunsh commented Oct 17, 2024

@wizz-wallet-dev
Copy link
Collaborator

The cause is 869a5e422e07949728da4ee76b574dd12d2c51d45f2e5a7753f98df787894df8i0.

https://ep.nextdao.xyz/proxy/blockchain.atomicals.get?params=[%22869a5e422e07949728da4ee76b574dd12d2c51d45f2e5a7753f98df787894df8i0%22]

@wizz-wallet-dev
Copy link
Collaborator

Update the auto_encode_bytes_elements in electrumx/lib/utils_atomicals.py can solves the issue:

# Auto encodes data into structured bytes data.
def auto_encode_bytes_elements(state):
    if isinstance(state, bytes):
        return {"$b": state.hex(), "$len": sys.getsizeof(state), "$auto": True}

    if isinstance(state, CBORTag):
        dumped_bytes = dumps(state)
        return auto_encode_bytes_elements(dumped_bytes)

    if isinstance(state, list):
        reformatted_list = []
        for item in state:
            reformatted_list.append(auto_encode_bytes_elements(item))
        return reformatted_list

    if isinstance(state, dict):
        for key, value in state.items():
            state[key] = auto_encode_bytes_elements(value)

+   # Handles unknown undefined type.
+   if type(state).__name__ == 'undefined_type':
+       return None

    return state

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants