99def main ():
1010 """
1111 Sets up an environment for testing purposes by creating an agent that can place trades on behalf of the account.
12- The agent does not have permission to transfer or withdraw funds. You can run this part on a separate machine or
13- change the code to connect the agent via a wallet app instead of using your private key directly in Python.
12+ The agent does not have permission to transfer or withdraw funds. You can run this part on a separate machine or
13+ change the code to connect the agent via a wallet app instead of using your private key directly in Python.
1414 You can also create a named agent using the frontend, which persists the authorization under an agent name.
15-
15+
1616 The main function then proceeds to place a test order with the agent and simulates the process of managing orders
1717 and ensuring that orders that are no longer needed are cleaned up.
1818 Finally, it creates an extra agent that persists beyond the current session and places an order with the extra agent.
@@ -26,15 +26,14 @@ def main():
2626 if exchange .account_address != exchange .wallet .address :
2727 raise Exception ("You should not create an agent using an agent" )
2828
29-
3029 approve_result , agent_key = exchange .approve_agent ()
3130
3231 # Check if the agent approval was successful. If not, log the error and return.
3332 # This prevents proceeding with an agent that isn't properly authorized.
3433 if approve_result ["status" ] != "ok" :
3534 print ("approving agent failed" , approve_result )
3635 return
37-
36+
3837 # Create the agent's local account using the agent's private key.
3938 # We use `eth_account.Account.from_key()` to securely generate the agent's account from its private key.
4039 agent_account : LocalAccount = eth_account .Account .from_key (agent_key )
@@ -59,10 +58,10 @@ def main():
5958 print (cancel_result )
6059
6160 # Create an extra agent that persists beyond the current session.
62- # The "persist" argument ensures that the agent remains available for future interactions and doesn't require re-approval each time.
61+ # The "persist" argument ensures that the agent remains available for future interactions and doesn't require re-approval each time.
6362
6463 approve_result , extra_agent_key = exchange .approve_agent ("persist" )
65-
64+
6665 # Check if the extra agent was successfully approved.
6766 if approve_result ["status" ] != "ok" :
6867 print ("approving extra agent failed" , approve_result )
0 commit comments