From 0de8abda4325733678cd8ca5e479ce641d838377 Mon Sep 17 00:00:00 2001 From: samtin0x <40127309+samtin0x@users.noreply.github.com> Date: Mon, 8 Jul 2024 15:30:09 +0200 Subject: [PATCH] Update subaccount examples with custom JSON decoding --- v4-client-py-v2/dydx_v4_client/node/client.py | 5 ++--- v4-client-py-v2/examples/validator_get_example.py | 6 ++++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/v4-client-py-v2/dydx_v4_client/node/client.py b/v4-client-py-v2/dydx_v4_client/node/client.py index 47781101..31c0abe4 100644 --- a/v4-client-py-v2/dydx_v4_client/node/client.py +++ b/v4-client-py-v2/dydx_v4_client/node/client.py @@ -239,7 +239,7 @@ async def get_subaccount( response = stub.Subaccount( QueryGetSubaccountRequest(owner=address, number=account_number) ) - return self.encode_response(response) + return response.subaccount async def get_subaccounts(self) -> QuerySubaccountAllResponse: """ @@ -249,8 +249,7 @@ async def get_subaccounts(self) -> QuerySubaccountAllResponse: QuerySubaccountAllResponse: The response containing all subaccounts. """ stub = subaccounts_query_grpc.QueryStub(self.channel) - response = stub.SubaccountAll(QueryAllSubaccountRequest()) - return self.encode_response(response) + return stub.SubaccountAll(QueryAllSubaccountRequest()) async def get_clob_pair(self, pair_id: int) -> clob_pair_type.ClobPair: """ diff --git a/v4-client-py-v2/examples/validator_get_example.py b/v4-client-py-v2/examples/validator_get_example.py index 5ec72179..367521ad 100644 --- a/v4-client-py-v2/examples/validator_get_example.py +++ b/v4-client-py-v2/examples/validator_get_example.py @@ -66,16 +66,18 @@ async def test(): try: subaccount = await node_client.get_subaccount(TEST_ADDRESS, 0) + decoded = node_client.encode_response(subaccount) print("Get Subaccount:") - print(subaccount) + print(decoded) except Exception as e: print("Error in get_subaccount:") print(f"Error: {e}") try: subaccounts = await node_client.get_subaccounts() + decoded = node_client.encode_response(subaccounts) print("Get Subaccounts:") - print(subaccounts) + print(decoded) except Exception as e: print("Error in get_subaccounts:") print(f"Error: {e}")