kopia lustrzana https://github.com/bugout-dev/moonworm
				
				
				
			Move all dependency from moonstreamdb to networks. Will required upper version of moonstreamdb.
							rodzic
							
								
									b2d87ce655
								
							
						
					
					
						commit
						29a3a80a28
					
				|  | @ -1,9 +1,10 @@ | |||
| import argparse | ||||
| import json | ||||
| import os | ||||
| from multiprocessing.sharedctypes import Value | ||||
| from pathlib import Path | ||||
| from shutil import copyfile | ||||
| from types import MappingProxyType | ||||
| from typing import Any | ||||
| 
 | ||||
| from web3.main import Web3 | ||||
| from web3.middleware import geth_poa_middleware | ||||
|  | @ -11,8 +12,7 @@ from web3.middleware import geth_poa_middleware | |||
| from moonworm.crawler.ethereum_state_provider import Web3StateProvider | ||||
| from moonworm.watch import watch_contract | ||||
| 
 | ||||
| from .contracts import CU, ERC20, ERC721, CULands | ||||
| from .crawler.utils import Network | ||||
| from .contracts import CU, ERC20, ERC721 | ||||
| from .deployment import find_deployment_block | ||||
| from .generators.basic import ( | ||||
|     generate_contract_cli_content, | ||||
|  | @ -154,6 +154,9 @@ def handle_watch(args: argparse.Namespace) -> None: | |||
|     if args.db: | ||||
|         if args.network is None: | ||||
|             raise ValueError("Please specify --network") | ||||
| 
 | ||||
|         from .crawler.networks import Network | ||||
| 
 | ||||
|         network = Network.__members__[args.network] | ||||
| 
 | ||||
|         from .crawler.moonstream_ethereum_state_provider import ( | ||||
|  | @ -215,6 +218,14 @@ def generate_argument_parser() -> argparse.ArgumentParser: | |||
|     """ | ||||
|     Generates the command-line argument parser for the "moonworm" command. | ||||
|     """ | ||||
|     networks: MappingProxyType[Any, Any] = MappingProxyType({}) | ||||
|     try: | ||||
|         from .crawler.networks import Network | ||||
| 
 | ||||
|         networks = Network.__members__ | ||||
|     except Exception: | ||||
|         pass | ||||
| 
 | ||||
|     parser = argparse.ArgumentParser(description="Moonworm: Manage your smart contract") | ||||
|     parser.add_argument( | ||||
|         "-v", | ||||
|  | @ -256,7 +267,7 @@ def generate_argument_parser() -> argparse.ArgumentParser: | |||
| 
 | ||||
|     watch_parser.add_argument( | ||||
|         "--network", | ||||
|         choices=Network.__members__, | ||||
|         choices=networks, | ||||
|         default=None, | ||||
|         help="Network name that represents models from db. If --db is set, required", | ||||
|     ) | ||||
|  |  | |||
|  | @ -19,8 +19,8 @@ from .networks import ( | |||
|     WyrmTransaction, | ||||
|     XDaiTransaction, | ||||
|     yield_db_session_ctx, | ||||
|     Network, | ||||
| ) | ||||
| from .utils import Network | ||||
| 
 | ||||
| logging.basicConfig(level=logging.INFO) | ||||
| logger = logging.getLogger(__name__) | ||||
|  |  | |||
|  | @ -14,46 +14,16 @@ try: | |||
|         PolygonLabel, | ||||
|         PolygonTransaction, | ||||
|         WyrmBlock, | ||||
|         Wyrmlabel, | ||||
|         WyrmLabel, | ||||
|         WyrmTransaction, | ||||
|         XDaiBlock, | ||||
|         XDaiLabel, | ||||
|         XDaiTransaction, | ||||
|     ) | ||||
|     from moonstreamdb.moonworm import Network, MODELS, tx_raw_types | ||||
| except ImportError: | ||||
|     print("this feature requires moonstreamdb which is not installed") | ||||
|     print("to enable, run: `pip install moonworm[moonstream]`") | ||||
|     raise ImportError( | ||||
|         "moonstreamdb not installed, to install, run: `pip install moonworm[moonstream]`" | ||||
|     ) | ||||
| 
 | ||||
| 
 | ||||
| from .utils import Network | ||||
| 
 | ||||
| MODELS: Dict[Network, Dict[str, Base]] = { | ||||
|     Network.ethereum: { | ||||
|         "blocks": EthereumBlock, | ||||
|         "labels": EthereumLabel, | ||||
|         "transactions": EthereumTransaction, | ||||
|     }, | ||||
|     Network.mumbai: { | ||||
|         "blocks": MumbaiBlock, | ||||
|         "labels": MumbaiLabel, | ||||
|         "transactions": MumbaiTransaction, | ||||
|     }, | ||||
|     Network.polygon: { | ||||
|         "blocks": PolygonBlock, | ||||
|         "labels": PolygonLabel, | ||||
|         "transactions": PolygonTransaction, | ||||
|     }, | ||||
|     Network.xdai: { | ||||
|         "blocks": XDaiBlock, | ||||
|         "labels": XDaiLabel, | ||||
|         "transactions": XDaiTransaction, | ||||
|     }, | ||||
|     Network.wyrm: { | ||||
|         "blocks": WyrmBlock, | ||||
|         "labels": Wyrmlabel, | ||||
|         "transactions": WyrmTransaction, | ||||
|     }, | ||||
| } | ||||
|  |  | |||
		Ładowanie…
	
		Reference in New Issue
	
	 Andrey
						Andrey