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

Bug report: query_account does not support PeriodicVestingAccount. Solution provided. #385

Open
4 tasks done
ayyo2765 opened this issue Jan 14, 2024 · 0 comments
Open
4 tasks done

Comments

@ayyo2765
Copy link

Prerequisites

Expected Behavior

Usage:

account = ledger.query_account(wallet.address())

Issue:
query_account expects a BaseAccount type. Other chains Like Bostrom appear to have a mix of types. My guess is that the account change from BaseAccount to PeriodicVestingAccount happens after a "investmint" event is transacted.

Fix:
Add PeriodicVestingAccount import to https://github.com/fetchai/cosmpy/blob/main/cosmpy/aerial/client/__init__.py

from cosmpy.protos.cosmos.vesting.v1beta1.vesting_pb2 import PeriodicVestingAccount

Change https://github.com/fetchai/cosmpy/blob/main/cosmpy/aerial/client/__init__.py#L313-L316 to

    if response.account.Is(BaseAccount.DESCRIPTOR):
        account = BaseAccount()
        response.account.Unpack(account)
    elif response.account.Is(PeriodicVestingAccount.DESCRIPTOR):
        account = PeriodicVestingAccount() 
        response.account.Unpack(account)
        account = account.base_vesting_account.base_account 
    else:
        raise RuntimeError("Unexpected account type returned from query")

Remarks:
#324 and #328 report the same error message but did not make note of the account type they were using. It is uncertain if this is the cause for their issues as well.

Current Behavior

Traceback (most recent call last):
  File "/workdir/csms.py", line 114, in <module>
    loop.run_until_complete(main())
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/workdir/csms.py", line 62, in main
    account = ledger.query_account(wallet.address())
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/cosmpy/aerial/client/__init__.py", line 315, in query_account
    raise RuntimeError("Unexpected account type returned from query")
RuntimeError: Unexpected account type returned from query

To Reproduce

No response

Context

Debian 12 Bookworm
Python 3.11.6
Cosmpy v0.9.1 & v0.9.2

Failure Logs

No response

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

1 participant