Skip to content
Merged
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
"python.autoComplete.extraPaths": [
"/home/manjairo/tcheco/torustrate-interface"
]
}
}
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ poetry add torusdk
## Installation with Nix

To install `torus` the torus cli with Nix

```sh
nix profile install .
```
Expand All @@ -61,7 +62,6 @@ The `torus` offers a variety of features for token management and agent interact
- Agent management for registration, curation and updates
- Participation in governance processes


## CLI Usage

The CLI commands are structured as follows:
Expand Down Expand Up @@ -140,6 +140,14 @@ torus network params
torus misc circulating-supply
```

### Acquiring Tokens from a Testnet Faucet

```sh
# This command will send 15 TOR to the key-name address.
# This command is only available on testnet.
torus --testnet balance run-faucet <key-name>
```

## Completions

You can enable completions for your shell by running:
Expand Down
26 changes: 18 additions & 8 deletions src/torusdk/cli/balance.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import time
from typing import Optional

import typer
from typer import Context

from torusdk.balance import BalanceUnit, format_balance, to_rems
from torusdk.cli._common import (
NOT_IMPLEMENTED_MESSAGE,
make_custom_context,
print_table_from_plain_dict,
)
Expand Down Expand Up @@ -229,14 +229,17 @@ def unstake(ctx: Context, key: str, amount: float, dest: str):
raise ChainTransactionError(response.error_message) # type: ignore


# Ammount of seconds to wait between faucet executions
SLEEP_BETWEEN_FAUCET_EXECUTIONS = 8


@balance_app.command()
def run_faucet(
ctx: Context,
key: str,
num_processes: Optional[int] = None,
num_executions: int = 1,
jobs: Optional[int] = None,
repeat: int = 1,
):
raise NotImplementedError("Faucet " + NOT_IMPLEMENTED_MESSAGE)
context = make_custom_context(ctx)
use_testnet = ctx.obj.use_testnet

Expand All @@ -247,13 +250,13 @@ def run_faucet(
resolved_key = context.load_key(key, None)

client = context.com_client()
for _ in range(num_executions):
for _i in range(repeat):
with context.progress_status("Solving PoW..."):
solution = solve_for_difficulty_fast(
client,
resolved_key,
client.url,
num_processes=num_processes,
num_processes=jobs,
)
with context.progress_status("Sending solution to blockchain"):
params = {
Expand All @@ -262,10 +265,17 @@ def run_faucet(
"work": solution.seal,
"key": resolved_key.ss58_address,
}

client.compose_call(
"faucet",
params=params,
unsigned=True,
module="FaucetModule",
key=resolved_key.ss58_address, # type: ignore
module="Faucet",
key=resolved_key,
wait_for_inclusion=False,
)

context.info(
f"Waiting {SLEEP_BETWEEN_FAUCET_EXECUTIONS} seconds before next execution..."
)
time.sleep(SLEEP_BETWEEN_FAUCET_EXECUTIONS)
Loading
Loading