Ejemplo n.º 1
0
def deploy_monitoring_service(
    token_deploy_result: Callable[[], Contract],
    user_deposit_deploy_result: Callable[[], UserDeposit],
    service_registry_deploy_result: Callable[[], ServiceRegistry],
    token_network_registry_deploy_result: Callable[[], TokenNetworkRegistry],
    deploy_client: JSONRPCClient,
    contract_manager: ContractManager,
    proxy_manager: ProxyManager,
) -> MonitoringService:
    token_contract = token_deploy_result()
    token_network_registry_proxy = token_network_registry_deploy_result()
    user_deposit_proxy = user_deposit_deploy_result()
    service_registry_proxy = service_registry_deploy_result()
    contract, receipt = deploy_client.deploy_single_contract(
        contract_name=CONTRACT_MONITORING_SERVICE,
        contract=contract_manager.get_contract(CONTRACT_MONITORING_SERVICE),
        constructor_parameters=[
            token_contract.address,
            service_registry_proxy.address,
            user_deposit_proxy.address,
            token_network_registry_proxy.address,
        ],
    )
    return proxy_manager.monitoring_service(
        MonitoringServiceAddress(to_canonical_address(contract.address)),
        BlockNumber(receipt["blockNumber"]),
    )
Ejemplo n.º 2
0
def load_deployment_addresses_from_udc(
    proxy_manager: ProxyManager,
    user_deposit_address: UserDepositAddress,
    block_identifier: BlockIdentifier,
) -> DeploymentAddresses:
    """Given a user deposit address, this function returns the list of contract addresses
    which are used as services which are bound to the user deposit contract deployed.
    """
    block_identifier = BLOCK_ID_LATEST
    user_deposit = proxy_manager.user_deposit(
        UserDepositAddress(to_canonical_address(user_deposit_address)),
        block_identifier=block_identifier,
    )
    monitoring_service_address = user_deposit.monitoring_service_address(
        block_identifier)
    one_to_n_address = user_deposit.one_to_n_address(
        block_identifier=block_identifier)

    monitoring_service_proxy = proxy_manager.monitoring_service(
        address=monitoring_service_address, block_identifier=block_identifier)

    token_network_registry_address = monitoring_service_proxy.token_network_registry_address(
        block_identifier=block_identifier)

    token_network_registry_proxy = proxy_manager.token_network_registry(
        token_network_registry_address, block_identifier=block_identifier)
    secret_registry_address = token_network_registry_proxy.get_secret_registry_address(
        block_identifier=block_identifier)
    service_registry_address = monitoring_service_proxy.service_registry_address(
        block_identifier=block_identifier)

    return DeploymentAddresses(
        token_network_registry_address=token_network_registry_address,
        secret_registry_address=secret_registry_address,
        user_deposit_address=user_deposit_address,
        service_registry_address=service_registry_address,
        monitoring_service_address=monitoring_service_address,
        one_to_n_address=one_to_n_address,
    )