kopia lustrzana https://github.com/bugout-dev/moonworm
33 wiersze
983 B
Plaintext
33 wiersze
983 B
Plaintext
# Code generated by moonworm : https://github.com/bugout-dev/moonworm
|
|
# Moonworm version : {moonworm_version}
|
|
|
|
import argparse
|
|
from typing import Any, List, Optional
|
|
from eth_typing.evm import ChecksumAddress
|
|
import os
|
|
import json
|
|
|
|
from brownie import Contract, network, project
|
|
from brownie.network.contract import ContractContainer
|
|
|
|
|
|
PROJECT_DIRECTORY = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
|
|
BUILD_DIRECTORY = os.path.join(PROJECT_DIRECTORY, "build", "contracts")
|
|
PROJECT = project.load(PROJECT_DIRECTORY)
|
|
|
|
|
|
def contract_from_build(abi_name: str) -> ContractContainer:
|
|
abi_full_path = os.path.join(BUILD_DIRECTORY, f"{{abi_name}}.json")
|
|
if not os.path.isfile(abi_full_path):
|
|
raise IOError(
|
|
f"File does not exist: {{abi_full_path}}. Maybe you have to compile the smart contracts?"
|
|
)
|
|
|
|
with open(abi_full_path, "r") as ifp:
|
|
build = json.load(ifp)
|
|
|
|
return ContractContainer(PROJECT, build)
|
|
|
|
|
|
{contract_body}
|