11import logging
22
33import click
4- from algokit_utils import opt_in , opt_out
54from algosdk import error
65from algosdk .v2client .algod import AlgodClient
76
1413 validate_account_balance_to_opt_in ,
1514 validate_address ,
1615)
16+ from algokit .core .utils import get_algorand_client_for_network
1717
1818logger = logging .getLogger (__name__ )
1919
@@ -55,19 +55,24 @@ def opt_in_command(asset_ids: tuple[int], account: str, network: AlgorandNetwork
5555 opt_in_account = get_account_with_private_key (account )
5656 validate_address (opt_in_account .address )
5757 algod_client = load_algod_client (network )
58+ algorand = get_algorand_client_for_network (network )
5859
5960 validate_account_balance_to_opt_in (algod_client , opt_in_account , len (asset_ids_list ))
6061 try :
6162 click .echo ("Performing opt-in. This may take a few seconds..." )
62- response = opt_in (algod_client = algod_client , account = opt_in_account , asset_ids = asset_ids_list )
63+ response = algorand .asset .bulk_opt_in (
64+ account = opt_in_account .address ,
65+ asset_ids = asset_ids_list ,
66+ signer = opt_in_account .signer ,
67+ )
6368 click .echo ("Successfully performed opt-in." )
6469 if len (response ) > 1 :
6570 account_url = get_explorer_url (opt_in_account .address , network , ExplorerEntityType .ADDRESS )
6671 click .echo (f"Check latest transactions on your account at: { account_url } " )
6772 else :
68- for asset_id , txn_id in response . items () :
69- explorer_url = get_explorer_url (txn_id , network , ExplorerEntityType .ASSET )
70- click .echo (f"Check opt-in status for asset { asset_id } at: { explorer_url } " )
73+ for asset_opt_int_result in response :
74+ explorer_url = get_explorer_url (asset_opt_int_result . transaction_id , network , ExplorerEntityType .ASSET )
75+ click .echo (f"Check opt-in status for asset { asset_opt_int_result . asset_id } at: { explorer_url } " )
7176 except error .AlgodHTTPError as err :
7277 raise click .ClickException (str (err )) from err
7378 except ValueError as err :
@@ -106,6 +111,7 @@ def opt_out_command(*, asset_ids: tuple[int], account: str, network: AlgorandNet
106111 opt_out_account = get_account_with_private_key (account )
107112 validate_address (opt_out_account .address )
108113 algod_client = load_algod_client (network )
114+ algorand = get_algorand_client_for_network (network )
109115 asset_ids_list = []
110116 try :
111117 asset_ids_list = _get_zero_balanced_assets (
@@ -119,15 +125,21 @@ def opt_out_command(*, asset_ids: tuple[int], account: str, network: AlgorandNet
119125 raise click .ClickException ("No assets to opt-out of." )
120126
121127 click .echo ("Performing opt-out. This may take a few seconds..." )
122- response = opt_out (algod_client = algod_client , account = opt_out_account , asset_ids = asset_ids_list )
128+ response = algorand .asset .bulk_opt_out (
129+ account = opt_out_account .address ,
130+ asset_ids = asset_ids_list ,
131+ signer = opt_out_account .signer ,
132+ )
123133 click .echo ("Successfully performed opt-out." )
124134 if len (response ) > 1 :
125135 account_url = get_explorer_url (opt_out_account .address , network , ExplorerEntityType .ADDRESS )
126136 click .echo (f"Check latest transactions on your account at: { account_url } " )
127137 else :
128- asset_id , txn_id = response .popitem ()
129- transaction_url = get_explorer_url (txn_id , network , ExplorerEntityType .TRANSACTION )
130- click .echo (f"Check opt-in status for asset { asset_id } at: { transaction_url } " )
138+ asset_opt_out_result = response [0 ]
139+ transaction_url = get_explorer_url (
140+ asset_opt_out_result .transaction_id , network , ExplorerEntityType .TRANSACTION
141+ )
142+ click .echo (f"Check opt-in status for asset { asset_opt_out_result .asset_id } at: { transaction_url } " )
131143 except error .AlgodHTTPError as err :
132144 raise click .ClickException (str (err )) from err
133145 except ConnectionRefusedError as err :
0 commit comments