Load configuration from JSON file (matching Go's NewConfigFromFile).
(filepath: str)
| 62 | |
| 63 | |
| 64 | def new_config_from_file(filepath: str) -> Config: |
| 65 | """Load configuration from JSON file (matching Go's NewConfigFromFile).""" |
| 66 | try: |
| 67 | config_data = json.loads(Path(filepath).read_text(encoding="utf-8")) |
| 68 | return Config( |
| 69 | chain_id=config_data.get("chainId", 1), |
| 70 | data_dir_path=config_data.get("dataDirPath", "/tmp/plugin/"), |
| 71 | ) |
| 72 | except Exception as err: |
| 73 | raise ValueError(f"Failed to load config from {filepath}: {err}") |
| 74 | |
| 75 | |
| 76 | class Plugin: |