1+ import time
12from typing import Optional
23
34import typer
45from typer import Context
56
67from torusdk .balance import BalanceUnit , format_balance , to_rems
78from torusdk .cli ._common import (
8- NOT_IMPLEMENTED_MESSAGE ,
99 make_custom_context ,
1010 print_table_from_plain_dict ,
1111)
@@ -229,14 +229,17 @@ def unstake(ctx: Context, key: str, amount: float, dest: str):
229229 raise ChainTransactionError (response .error_message ) # type: ignore
230230
231231
232+ # Ammount of seconds to wait between faucet executions
233+ SLEEP_BETWEEN_FAUCET_EXECUTIONS = 8
234+
235+
232236@balance_app .command ()
233237def run_faucet (
234238 ctx : Context ,
235239 key : str ,
236- num_processes : Optional [int ] = None ,
237- num_executions : int = 1 ,
240+ jobs : Optional [int ] = None ,
241+ repeat : int = 1 ,
238242):
239- raise NotImplementedError ("Faucet " + NOT_IMPLEMENTED_MESSAGE )
240243 context = make_custom_context (ctx )
241244 use_testnet = ctx .obj .use_testnet
242245
@@ -247,13 +250,13 @@ def run_faucet(
247250 resolved_key = context .load_key (key , None )
248251
249252 client = context .com_client ()
250- for _ in range (num_executions ):
253+ for _i in range (repeat ):
251254 with context .progress_status ("Solving PoW..." ):
252255 solution = solve_for_difficulty_fast (
253256 client ,
254257 resolved_key ,
255258 client .url ,
256- num_processes = num_processes ,
259+ num_processes = jobs ,
257260 )
258261 with context .progress_status ("Sending solution to blockchain" ):
259262 params = {
@@ -262,10 +265,17 @@ def run_faucet(
262265 "work" : solution .seal ,
263266 "key" : resolved_key .ss58_address ,
264267 }
268+
265269 client .compose_call (
266270 "faucet" ,
267271 params = params ,
268272 unsigned = True ,
269- module = "FaucetModule" ,
270- key = resolved_key .ss58_address , # type: ignore
273+ module = "Faucet" ,
274+ key = resolved_key ,
275+ wait_for_inclusion = False ,
271276 )
277+
278+ context .info (
279+ f"Waiting { SLEEP_BETWEEN_FAUCET_EXECUTIONS } seconds before next execution..."
280+ )
281+ time .sleep (SLEEP_BETWEEN_FAUCET_EXECUTIONS )
0 commit comments