From a347e7d2b84adb465a9d902fe7239a56cb4744f9 Mon Sep 17 00:00:00 2001 From: Obiajulu <47371105+ObiajuluM@users.noreply.github.com> Date: Tue, 1 Nov 2022 17:58:01 -0700 Subject: [PATCH] Create check_no_freeze.py --- .../freeze/py/check_no_freeze.py | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 content/_code-samples/freeze/py/check_no_freeze.py diff --git a/content/_code-samples/freeze/py/check_no_freeze.py b/content/_code-samples/freeze/py/check_no_freeze.py new file mode 100644 index 0000000000..e796918d01 --- /dev/null +++ b/content/_code-samples/freeze/py/check_no_freeze.py @@ -0,0 +1,39 @@ +from xrpl.clients import JsonRpcClient +from xrpl.models import AccountInfo + +client = JsonRpcClient("https://xrplcluster.com") # Connect to a network + + +ACCOUNT_ROOT_LEDGER_FLAGS: dict[str, int] = { + "lsfNoFreeze": 0x00200000, + "lsfGlobalFreeze": 0x00400000, + } + +def parse_account_root_flags(flags: int) -> list[str]: + flags_enabled = [] + for flag in ACCOUNT_ROOT_LEDGER_FLAGS: + check_flag = ACCOUNT_ROOT_LEDGER_FLAGS[flag] + if check_flag & flags == check_flag: + flags_enabled.append(flag) + return flags_enabled + +# Issuer address to query for no freeze status +issuer_addr = "rUpy3eEg8rqjqfUoLeBnZkscbKbFsKXC3v" + +# Build account line query +print(f"Checking if the 'No Freeze' flag is enabled for the address {issuer_addr}") +acc_info = AccountInfo(account=issuer_addr, ledger_index="validated") + +# Submit query +response = client.request(acc_info) + +# Parse response for result +result = response.result + +# Query result for no freeze status +if "account_data" in result: + if "Flags" in result["account_data"]: + if "lsfNoFreeze" in parse_account_root_flags(result["account_data"]["Flags"]): + print("No Freeze is enabled") + else: + print("No Freeze is disabled")