fix of various issues

pull/86/head
Yhtyyar Sahatov 2022-08-04 15:27:06 +03:00
rodzic dc397a0384
commit 8be7014bbd
6 zmienionych plików z 62 dodań i 30 usunięć

Wyświetl plik

@ -12,7 +12,7 @@ from moonworm.crawler.ethereum_state_provider import Web3StateProvider
from moonworm.watch import watch_contract from moonworm.watch import watch_contract
from .contracts import CU, ERC20, ERC721, CULands from .contracts import CU, ERC20, ERC721, CULands
from .crawler.networks import Network from .crawler.utils import Network
from .deployment import find_deployment_block from .deployment import find_deployment_block
from .generators.basic import ( from .generators.basic import (
generate_contract_cli_content, generate_contract_cli_content,
@ -123,8 +123,8 @@ def handle_watch(args: argparse.Namespace) -> None:
if args.network is None: if args.network is None:
raise ValueError("Please specify --network") raise ValueError("Please specify --network")
network = Network.__members__[args.network] network = Network.__members__[args.network]
from moonstreamdb.db import yield_db_session_ctx
from moonstreamdb.db import yield_db_session_ctx
from .crawler.moonstream_ethereum_state_provider import ( from .crawler.moonstream_ethereum_state_provider import (
MoonstreamEthereumStateProvider, MoonstreamEthereumStateProvider,
) )

Wyświetl plik

@ -3,20 +3,32 @@ from typing import Any, Dict, List, Optional, Union
from eth_typing.evm import ChecksumAddress from eth_typing.evm import ChecksumAddress
from hexbytes.main import HexBytes from hexbytes.main import HexBytes
from moonstreamdb.db import yield_db_session_ctx
from moonstreamdb.models import ( try:
EthereumLabel, from moonstreamdb.db import yield_db_session_ctx
EthereumTransaction, from moonstreamdb.models import (
PolygonLabel, EthereumLabel,
PolygonTransaction, EthereumTransaction,
XDaiTransaction, PolygonLabel,
) PolygonTransaction,
XDaiTransaction,
)
except ImportError:
print("this feature requires moonstreamdb which is not installed")
print("to enable, run: `pip install -e[moonstream]`")
raise ImportError(
"moonstreamdb not installed, to install, run: `pip install -e[moonstream]`"
)
from sqlalchemy.orm import Session from sqlalchemy.orm import Session
from sqlalchemy.sql.base import NO_ARG from sqlalchemy.sql.base import NO_ARG
from web3 import Web3 from web3 import Web3
from .ethereum_state_provider import EthereumStateProvider from .ethereum_state_provider import EthereumStateProvider
from .networks import MODELS, Network
from .networks import MODELS
from .utils import Network
logging.basicConfig(level=logging.INFO) logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

Wyświetl plik

@ -1,25 +1,26 @@
from enum import Enum
from typing import Dict from typing import Dict
from moonstreamdb.models import ( try:
Base, from moonstreamdb.models import (
EthereumBlock, Base,
EthereumLabel, EthereumBlock,
EthereumTransaction, EthereumLabel,
PolygonBlock, EthereumTransaction,
PolygonLabel, PolygonBlock,
PolygonTransaction, PolygonLabel,
XDaiBlock, PolygonTransaction,
XDaiLabel, XDaiBlock,
XDaiTransaction, XDaiLabel,
) XDaiTransaction,
)
except ImportError:
class Network(Enum): print("this feature requires moonstreamdb which is not installed")
ethereum = "ethereum" print("to enable, run: `pip install -e[moonstream]`")
polygon = "polygon" raise ImportError(
xdai = "xdai" "moonstreamdb not installed, to install, run: `pip install -e[moonstream]`"
)
from .utils import Network
MODELS: Dict[Network, Dict[str, Base]] = { MODELS: Dict[Network, Dict[str, Base]] = {
Network.ethereum: { Network.ethereum: {

Wyświetl plik

@ -0,0 +1,7 @@
from enum import Enum
class Network(Enum):
ethereum = "ethereum"
polygon = "polygon"
xdai = "xdai"

Wyświetl plik

@ -100,6 +100,8 @@ def python_type(evm_type: str) -> List[str]:
return ["ChecksumAddress"] return ["ChecksumAddress"]
elif evm_type == "bool": elif evm_type == "bool":
return ["bool"] return ["bool"]
elif evm_type == "tuple":
return ["tuple"]
else: else:
return ["Any"] return ["Any"]
@ -161,6 +163,8 @@ def generate_contract_class(
# transactions (see "generate_add_default_arguments" in brownie.py for an example of default arguments). # transactions (see "generate_add_default_arguments" in brownie.py for an example of default arguments).
PROTECTED_ARG_NAMES: Set[str] = { PROTECTED_ARG_NAMES: Set[str] = {
"address", "address",
"block-number",
"block_number",
"chain", "chain",
"confirmations", "confirmations",
"gas-price", "gas-price",
@ -170,6 +174,7 @@ PROTECTED_ARG_NAMES: Set[str] = {
"password", "password",
"sender", "sender",
"signer", "signer",
"value",
} }

Wyświetl plik

@ -785,6 +785,13 @@ def generate_cli_generator(
value=cst.parse_expression("bytes_argument_type"), value=cst.parse_expression("bytes_argument_type"),
), ),
) )
elif param["type"] == "tuple":
call_args.append(
cst.Arg(
keyword=cst.Name(value="type"),
value=cst.parse_expression("eval"),
),
)
add_argument_call = cst.Call( add_argument_call = cst.Call(
func=cst.Attribute( func=cst.Attribute(