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 .contracts import CU, ERC20, ERC721, CULands
from .crawler.networks import Network
from .crawler.utils import Network
from .deployment import find_deployment_block
from .generators.basic import (
generate_contract_cli_content,
@ -123,8 +123,8 @@ def handle_watch(args: argparse.Namespace) -> None:
if args.network is None:
raise ValueError("Please specify --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 (
MoonstreamEthereumStateProvider,
)

Wyświetl plik

@ -3,20 +3,32 @@ from typing import Any, Dict, List, Optional, Union
from eth_typing.evm import ChecksumAddress
from hexbytes.main import HexBytes
from moonstreamdb.db import yield_db_session_ctx
from moonstreamdb.models import (
try:
from moonstreamdb.db import yield_db_session_ctx
from moonstreamdb.models import (
EthereumLabel,
EthereumTransaction,
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.sql.base import NO_ARG
from web3 import Web3
from .ethereum_state_provider import EthereumStateProvider
from .networks import MODELS, Network
from .networks import MODELS
from .utils import Network
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

Wyświetl plik

@ -1,7 +1,7 @@
from enum import Enum
from typing import Dict
from moonstreamdb.models import (
try:
from moonstreamdb.models import (
Base,
EthereumBlock,
EthereumLabel,
@ -12,14 +12,15 @@ from moonstreamdb.models import (
XDaiBlock,
XDaiLabel,
XDaiTransaction,
)
class Network(Enum):
ethereum = "ethereum"
polygon = "polygon"
xdai = "xdai"
)
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 .utils import Network
MODELS: Dict[Network, Dict[str, Base]] = {
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"]
elif evm_type == "bool":
return ["bool"]
elif evm_type == "tuple":
return ["tuple"]
else:
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).
PROTECTED_ARG_NAMES: Set[str] = {
"address",
"block-number",
"block_number",
"chain",
"confirmations",
"gas-price",
@ -170,6 +174,7 @@ PROTECTED_ARG_NAMES: Set[str] = {
"password",
"sender",
"signer",
"value",
}

Wyświetl plik

@ -785,6 +785,13 @@ def generate_cli_generator(
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(
func=cst.Attribute(