Skip to content

Commit 7edecdc

Browse files
committed
Add basic invoke command
1 parent 3aeb505 commit 7edecdc

4 files changed

Lines changed: 27 additions & 3 deletions

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ soroban.invoke("AAAA...", "increment")
1818
Identity and Network configurations are automatically pulled from the global
1919
or local configuration.
2020

21+
It also provides a CLI
22+
```bash
23+
soroban invoke CC22IAGPHR4DXI73WSI4L65TTB3F5A2DF7FP5PPNIOLVX5NQWSVR4TID version --source-account=...
24+
```
25+
2126
> Note: this repository has no affiliation with the Stellar Developer Foundation.
2227
> The official CLI can be found here https://github.com/stellar/soroban-cli
2328
> Should this become useful, I am happy to transfer it as well!

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "soroban"
7-
version = "1.0.0"
7+
version = "0.2.0"
88
description = "CLI for Soroban contracts in Python"
99
readme = "README.md"
1010
requires-python = ">=3.11"

src/soroban/cli.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
1+
import soroban
12
import typer
23

4+
35
app = typer.Typer()
46

5-
invoke = typer.Typer()
67

7-
app.add_typer(invoke, name="invoke")
8+
@app.command()
9+
def invoke(
10+
contract_id: str,
11+
function_name: str,
12+
source_account: str = None,
13+
):
14+
identity = soroban.Identity(secret_key=source_account)
15+
res = soroban.invoke(
16+
contract_id=contract_id, function_name=function_name, source_account=identity
17+
)
18+
print(res)
19+
20+
21+
# only needed because we have a single command
22+
@app.callback()
23+
def callback():
24+
pass

src/soroban/models.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ def _load_configuration(id: str | pathlib.Path, kind: Literal["identity", "netwo
2121
return local_config
2222
elif global_config.is_file():
2323
return global_config
24+
else:
25+
raise ValueError(f"Cannot find a {kind!r} configuration for {id!r}")
2426

2527

2628
class Identity(BaseSettings):

0 commit comments

Comments
 (0)