-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexecute_contract.py
More file actions
62 lines (51 loc) · 1.62 KB
/
execute_contract.py
File metadata and controls
62 lines (51 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from __future__ import annotations
import argparse
import json
from pathlib import Path
from typing import Any, Dict
try:
from .runtime_core import (
Slice05RuntimeCore,
default_contract_path,
default_wfrog_path,
execute_slice05_contract,
)
except ImportError: # pragma: no cover
from runtime_core import (
Slice05RuntimeCore,
default_contract_path,
default_wfrog_path,
execute_slice05_contract,
)
def load_runtime(
*,
contract_path: str | Path | None = None,
wfrog_path: str | Path | None = None,
) -> Slice05RuntimeCore:
return Slice05RuntimeCore(contract_path=contract_path, wfrog_path=wfrog_path)
def execute_contract(
control_value: int = 3,
*,
contract_path: str | Path | None = None,
wfrog_path: str | Path | None = None,
) -> Dict[str, Any]:
return execute_slice05_contract(
control_value=control_value,
contract_path=contract_path,
wfrog_path=wfrog_path,
)
def main() -> int:
parser = argparse.ArgumentParser(description="Execute the Example 05 runtime contract in headless mode.")
parser.add_argument("input_value", nargs="?", type=int, default=3)
parser.add_argument("--contract", type=Path, default=default_contract_path())
parser.add_argument("--wfrog", type=Path, default=default_wfrog_path())
args = parser.parse_args()
artifact = execute_contract(
args.input_value,
contract_path=args.contract,
wfrog_path=args.wfrog,
)
print(json.dumps(artifact, indent=2))
return 0
if __name__ == "__main__":
raise SystemExit(main())