We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi, I want to instantiate a program account and then fetch it as documentation.
from my_client.accounts import PostAccount connection = Client("https://api.devnet.solana.com") addr = PublicKey("...") acc = await PostAccount.fetch(connection, addr) if acc is None: raise ValueError("account not found") obj = acc.to_json() print(obj) acc_from_json = PostAccount.from_json(obj)
This is like documentation. And the error:
TypeError Traceback (most recent call last) f:\programming\intelligent_dex\core_calculations\tests.ipynb Cell 8 in <cell line: 4>() [1](vscode-notebook-cell:/f%3A/programming/intelligent_dex/core_calculations/tests.ipynb#X11sZmlsZQ%3D%3D?line=0) # fetch an account [2](vscode-notebook-cell:/f%3A/programming/intelligent_dex/core_calculations/tests.ipynb#X11sZmlsZQ%3D%3D?line=1) addr = PublicKey("FJLoTgfa5QErRQXsKJrx2ULipJQBRfxVd5zs1jzA18W3") ----> [4](vscode-notebook-cell:/f%3A/programming/intelligent_dex/core_calculations/tests.ipynb#X11sZmlsZQ%3D%3D?line=3) acc = await PostAccount.fetch(connection, addr) [5](vscode-notebook-cell:/f%3A/programming/intelligent_dex/core_calculations/tests.ipynb#X11sZmlsZQ%3D%3D?line=4) if acc is None: [6](vscode-notebook-cell:/f%3A/programming/intelligent_dex/core_calculations/tests.ipynb#X11sZmlsZQ%3D%3D?line=5) # the fetch method returns null when the account is uninitialized [7](vscode-notebook-cell:/f%3A/programming/intelligent_dex/core_calculations/tests.ipynb#X11sZmlsZQ%3D%3D?line=6) raise ValueError("account not found") File f:\programming\intelligent_dex\core_calculations\my_client\accounts\post_account.py:52, in PostAccount.fetch(cls, conn, address, commitment, program_id) 44 @classmethod 45 async def fetch( 46 cls, (...) 50 program_id: PublicKey = PROGRAM_ID, 51 ) -> typing.Optional["PostAccount"]: ---> 52 resp = await conn.get_account_info(address, commitment=commitment) 53 info = resp.value 54 if info is None: TypeError: object solders.rpc.responses.GetAccountInfoResp can't be used in 'await' expression
Please help. Thanks
The text was updated successfully, but these errors were encountered:
You need to use AsyncClient, not Client. I recommend using a type checker such as mypy to catch things like this
AsyncClient
Client
Sorry, something went wrong.
No branches or pull requests
Hi, I want to instantiate a program account and then fetch it as documentation.
This is like documentation. And the error:
Please help.
Thanks
The text was updated successfully, but these errors were encountered: