From 4f52b980ed73aea8e9cf10cccb8a08a03d5f0b74 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Fri, 18 Aug 2023 15:11:11 +0200 Subject: [PATCH] remove one bridge assumptions --- xbridge_cli/bridge/build.py | 16 ++++++++-------- xbridge_cli/bridge/register.py | 1 - 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/xbridge_cli/bridge/build.py b/xbridge_cli/bridge/build.py index 4b6c8186..1b8e7d21 100644 --- a/xbridge_cli/bridge/build.py +++ b/xbridge_cli/bridge/build.py @@ -338,10 +338,10 @@ def setup_bridge( raise XBridgeCLIException(obj_error) locking_door_objs = locking_objs_result["account_objects"] if len(locking_door_objs) > 0: - assert ( - len(locking_door_objs) == 1 - ), "Cannot have multiple bridges on one account" - if XChainBridge.from_xrpl(locking_door_objs[0]["XChainBridge"]) == bridge_obj: + if any( + XChainBridge.from_xrpl(obj["XChainBridge"]) == bridge_obj + for obj in locking_door_objs + ): locking_bridge_exists = True else: raise XBridgeCLIException( @@ -457,10 +457,10 @@ def setup_bridge( raise XBridgeCLIException(obj_error) issuing_door_objs = issuing_objs_result["account_objects"] if len(issuing_door_objs) > 0: - assert ( - len(issuing_door_objs) == 1 - ), "Cannot have multiple bridges on one account" - if XChainBridge.from_xrpl(issuing_door_objs[0]["XChainBridge"]) == bridge_obj: + if any( + XChainBridge.from_xrpl(obj["XChainBridge"]) == bridge_obj + for obj in issuing_door_objs + ): issuing_bridge_exists = True else: raise XBridgeCLIException( diff --git a/xbridge_cli/bridge/register.py b/xbridge_cli/bridge/register.py index 51737259..c65e658c 100644 --- a/xbridge_cli/bridge/register.py +++ b/xbridge_cli/bridge/register.py @@ -24,7 +24,6 @@ def _get_bridge(client: JsonRpcClient, door_account: str) -> Dict[str, Any]: # TODO: filter by bridge when that's implemented objects = _get_account_objects(client, door_account) bridge_objects = [obj for obj in objects if obj["LedgerEntryType"] == "Bridge"] - assert len(bridge_objects) == 1 return bridge_objects[0]