Skip to content

Commit

Permalink
Fix examples (#189)
Browse files Browse the repository at this point in the history
* Fix validator_get_example.py

* Add printing all response fields to validator_post_example.py
  • Loading branch information
piwonskp authored Jul 1, 2024
1 parent 5ae6549 commit 5e416be
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
9 changes: 1 addition & 8 deletions v4-client-py-v2/examples/validator_get_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@

async def test():
node_client = await NodeClient.connect(TESTNET.node)
try:
result = await node_client.get_account_balances(TEST_ADDRESS)
print("Get Account Balances:")
print(result)
except Exception as e:
print("Error in get_account_balances:")
print(f"Error: {e}")

try:
account = await node_client.get_account(TEST_ADDRESS)
Expand All @@ -32,7 +25,7 @@ async def test():
print(f"Error: {e}")

try:
response = await node_client.get_account_balance(TEST_ADDRESS, "usdc")
response = await node_client.get_account_balance(TEST_ADDRESS, "adv4tnt")
print("Get Account Balance:")
print(response)
except Exception as e:
Expand Down
7 changes: 3 additions & 4 deletions v4-client-py-v2/examples/validator_post_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
import time
from pathlib import Path

from dydx_v4_client import MAX_CLIENT_ID, NodeClient, Order, OrderFlags, Wallet
from dydx_v4_client.indexer.rest.indexer_client import IndexerClient
from dydx_v4_client import MAX_CLIENT_ID, NodeClient, Wallet
from dydx_v4_client.network import TESTNET
from dydx_v4_client.node.market import Market
from dydx_v4_client.node.message import order, order_id
from tests.conftest import DYDX_TEST_MNEMONIC, TEST_ADDRESS
from google.protobuf.json_format import MessageToJson

PERPETUAL_PAIR_BTC_USD = 0

Expand Down Expand Up @@ -51,7 +50,7 @@ async def test():
),
)
print("**Order Tx**")
print(place)
print(MessageToJson(place, always_print_fields_with_no_presence=True))
# FIXME: Remove
wallet.sequence += 1
time.sleep(5)
Expand Down

0 comments on commit 5e416be

Please sign in to comment.