From 1bd0dbdcadadb0973c7ef10d73ab75db8589f570 Mon Sep 17 00:00:00 2001 From: Obiajulu <47371105+ObiajuluM@users.noreply.github.com> Date: Tue, 6 Sep 2022 21:40:12 -0700 Subject: [PATCH] Update account_checks.py --- .../_code-samples/checks/py/account_checks.py | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/content/_code-samples/checks/py/account_checks.py b/content/_code-samples/checks/py/account_checks.py index a3e53097c2..2a77db8f6e 100644 --- a/content/_code-samples/checks/py/account_checks.py +++ b/content/_code-samples/checks/py/account_checks.py @@ -1,25 +1,14 @@ from xrpl.clients import JsonRpcClient from xrpl.models import AccountObjects -from xrpl.utils import drops_to_xrp, ripple_time_to_datetime +from xrpl.utils import drops_to_xrp, hex_to_str, ripple_time_to_datetime client = JsonRpcClient("https://s.altnet.rippletest.net:51234") # connect to the testnetwork - -"""Helper methods for working with token names""" - -def hex_to_symbol(hex: str = None) -> str: - """token hex_to_symbol.""" - if len(hex) > 3: - bytes_string = bytes.fromhex(str(hex)).decode('utf-8') - return bytes_string.rstrip('\x00') - return hex - - # Query the ledger for all xrp checks an account has created or received # wallet address to query -wallet_addr = str +wallet_addr = "rPKcw5cXUtREMgsQZqSLkxJTfpwMGg7WcP" # dict to store all the checks checks_dict = {} @@ -68,7 +57,7 @@ print(checks_dict) # Query the ledger for all token checks an account has created or received # wallet address to query -wallet_addr = str +wallet_addr = "rPKcw5cXUtREMgsQZqSLkxJTfpwMGg7WcP" # dict to store all the checks checks_dict = {} @@ -96,7 +85,7 @@ if "account_objects" in result: check_data["receiver"] = check["Destination"] if "Expiration" in check: check_data["expiry_date"] = str(ripple_time_to_datetime(check["Expiration"])) - check_data["token"] = hex_to_symbol(check["SendMax"]["currency"]) + check_data["token"] = hex_to_str(check["SendMax"]["currency"]) check_data["issuer"] = check["SendMax"]["issuer"] check_data["amount"] = check["SendMax"]["value"] check_data["check_id"] = check["index"]