Ejemplo n.º 1
0
def create_celery(test_config=None):
    # pylint: disable=W0603
    global web3endpoint, web3, abi_values, eth_abi_values, eth_web3
    global solana_client

    web3endpoint = helpers.get_web3_endpoint(shared_config)
    web3 = Web3(HTTPProvider(web3endpoint))
    abi_values = helpers.load_abi_values()
    eth_abi_values = helpers.load_eth_abi_values()
    # Initialize eth_web3 with MultiProvider
    # We use multiprovider to allow for multiple web3 providers and additional resiliency.
    # However, we do not use multiprovider in data web3 because of the effect of disparate block status reads.
    eth_web3 = Web3(MultiProvider(shared_config["web3"]["eth_provider_url"]))

    # Initialize Solana web3 provider
    solana_client = Client(SOLANA_ENDPOINT)

    global registry
    global user_factory
    global track_factory
    global social_feature_factory
    global playlist_factory
    global user_library_factory
    global ipld_blacklist_factory
    global user_replica_set_manager
    global contract_addresses
    # pylint: enable=W0603

    (registry, user_factory, track_factory, social_feature_factory,
     playlist_factory, user_library_factory, ipld_blacklist_factory,
     user_replica_set_manager, contract_addresses) = init_contracts()

    return create(test_config, mode="celery")
Ejemplo n.º 2
0
def create_celery(test_config=None):
    # pylint: disable=W0603
    global web3endpoint, web3, abi_values, eth_abi_values, eth_web3

    web3endpoint = helpers.get_web3_endpoint(shared_config)
    web3 = Web3(HTTPProvider(web3endpoint))
    abi_values = helpers.load_abi_values()
    eth_abi_values = helpers.load_eth_abi_values()
    # Initialize eth web
    eth_web3 = Web3(HTTPProvider(shared_config["web3"]["eth_provider_url"]))

    global registry
    global user_factory
    global track_factory
    global social_feature_factory
    global playlist_factory
    global user_library_factory
    global ipld_blacklist_factory
    global contract_addresses
    # pylint: enable=W0603

    (
        registry,
        user_factory,
        track_factory,
        social_feature_factory,
        playlist_factory,
        user_library_factory,
        ipld_blacklist_factory,
        contract_addresses
    ) = initContracts()

    return create(test_config, mode="celery")
Ejemplo n.º 3
0
import logging
from typing import List

from src.tasks.celery_app import celery
from src.utils.config import shared_config
from src.utils.helpers import load_eth_abi_values
from web3 import HTTPProvider, Web3

logger = logging.getLogger(__name__)

oracle_addresses_key = "oracle_addresses"

eth_abi_values = load_eth_abi_values()
REWARDS_CONTRACT_ABI = eth_abi_values["EthRewardsManager"]["abi"]

eth_web3 = Web3(HTTPProvider(
    shared_config["web3"]["eth_provider_url"]))  # type: ignore
eth_registry_address = eth_web3.toChecksumAddress(
    shared_config["eth_contracts"]["registry"])
eth_registry_instance = eth_web3.eth.contract(
    address=eth_registry_address, abi=eth_abi_values["Registry"]["abi"])


def get_oracle_addresses_from_chain(redis) -> List[str]:
    try:
        # Note: this call will fail until the eth rewards manager contract is deployed
        eth_rewards_manager_address = eth_registry_instance.functions.getContract(
            bytes("EthRewardsManagerProxy", "utf-8")).call()
        eth_rewards_manager_instance = eth_web3.eth.contract(
            address=eth_rewards_manager_address, abi=REWARDS_CONTRACT_ABI)
        oracle_addresses = (eth_rewards_manager_instance.functions.