@@ -61,23 +61,29 @@ async def handle_command(client: stackcoin.Client, line: str):
6161 amount = int (parts [2 ])
6262 label = " " .join (parts [3 :]) or None
6363 result = await client .send (user_id , amount , label = label )
64- print (f"Sent { result .amount } STK (txn #{ result .transaction_id } ). "
65- f"Your balance: { result .from_new_balance } STK" )
64+ print (
65+ f"Sent { result .amount } STK (txn #{ result .transaction_id } ). "
66+ f"Your balance: { result .from_new_balance } STK"
67+ )
6668
6769 elif cmd == "request" and len (parts ) >= 3 :
6870 user_id = int (parts [1 ])
6971 amount = int (parts [2 ])
7072 label = " " .join (parts [3 :]) or None
7173 result = await client .create_request (user_id , amount , label = label )
72- print (f"Request #{ result .request_id } for { result .amount } STK "
73- f"from { result .responder .username } ({ result .status } )" )
74+ print (
75+ f"Request #{ result .request_id } for { result .amount } STK "
76+ f"from { result .responder .username } ({ result .status } )"
77+ )
7478
7579 elif cmd == "requests" :
7680 status = parts [1 ] if len (parts ) > 1 else None
7781 reqs = await client .get_requests (status = status )
7882 for r in reqs [:10 ]:
79- print (f" #{ r .id } { r .requester .username } -> { r .responder .username } : "
80- f"{ r .amount } STK ({ r .status } )" )
83+ print (
84+ f" #{ r .id } { r .requester .username } -> { r .responder .username } : "
85+ f"{ r .amount } STK ({ r .status } )"
86+ )
8187 print (f"({ len (reqs )} total)" )
8288
8389 elif cmd == "accept" and len (parts ) >= 2 :
@@ -92,8 +98,10 @@ async def handle_command(client: stackcoin.Client, line: str):
9298 txns = await client .get_transactions ()
9399 for t in txns [:10 ]:
94100 label_str = f" ({ t .label } )" if t .label else ""
95- print (f" #{ t .id } { t .from_ .username } -> { t .to .username } : "
96- f"{ t .amount } STK{ label_str } " )
101+ print (
102+ f" #{ t .id } { t .from_ .username } -> { t .to .username } : "
103+ f"{ t .amount } STK{ label_str } "
104+ )
97105 print (f"({ len (txns )} total)" )
98106
99107 elif cmd == "events" :
@@ -129,10 +137,10 @@ async def main():
129137 # Can be omitted to hit production (https://stackcoin.world).
130138 # Set STACKCOIN_BASE_URL for local development, e.g. http://localhost:4000
131139 base_url = os .getenv ("STACKCOIN_BASE_URL" , "https://stackcoin.world" )
132- ws_url = os .getenv ("STACKCOIN_WS_URL" ,
133- base_url . replace ( "https://" , "wss://" )
134- .replace ("http://" , "ws://" )
135- + "/ws" )
140+ ws_url = os .getenv (
141+ "STACKCOIN_WS_URL" ,
142+ base_url . replace ( "https://" , "wss://" ) .replace ("http://" , "ws://" ) + "/ws" ,
143+ )
136144
137145 async with stackcoin .Client (token , base_url = base_url ) as client :
138146 me = await client .get_me ()
@@ -144,14 +152,20 @@ async def main():
144152 @gateway .on ("transfer.completed" )
145153 async def on_transfer (event : stackcoin .TransferCompletedEvent ):
146154 if event .data .role == "sender" :
147- print (f"\n [event] Sent { event .data .amount } STK to user #{ event .data .to_id } " )
155+ print (
156+ f"\n [event] Sent { event .data .amount } STK to user #{ event .data .to_id } "
157+ )
148158 else :
149- print (f"\n [event] Received { event .data .amount } STK from user #{ event .data .from_id } " )
159+ print (
160+ f"\n [event] Received { event .data .amount } STK from user #{ event .data .from_id } "
161+ )
150162 print ("> " , end = "" , flush = True )
151163
152164 @gateway .on ("request.created" )
153165 async def on_request_created (event : stackcoin .RequestCreatedEvent ):
154- print (f"\n [event] New request #{ event .data .request_id } for { event .data .amount } STK" )
166+ print (
167+ f"\n [event] New request #{ event .data .request_id } for { event .data .amount } STK"
168+ )
155169 print ("> " , end = "" , flush = True )
156170
157171 @gateway .on ("request.accepted" )
0 commit comments