Пример #1
0
def token_addresses(
    token_amount,
    number_of_tokens,
    private_keys,
    deploy_service,
    token_network_registry_address,
    register_tokens,
    contract_manager,
) -> typing.List[typing.Address]:
    """ Fixture that yields `number_of_tokens` ERC20 token addresses, where the
    `token_amount` (per token) is distributed among the addresses behind `deploy_client` and
    potentially pre-registered with the raiden Registry.
    The following arguments can control the behavior:

    Args:
        token_amount (int): the overall number of units minted per token
        number_of_tokens (int): the number of token instances
        register_tokens (bool): controls if tokens will be registered with raiden Registry
    """

    participants = [privatekey_to_address(key) for key in private_keys]
    token_addresses = deploy_tokens_and_fund_accounts(
        token_amount=token_amount,
        number_of_tokens=number_of_tokens,
        deploy_service=deploy_service,
        participants=participants,
        contract_manager=contract_manager,
    )

    if register_tokens:
        for token in token_addresses:
            deploy_service.token_network_registry(
                token_network_registry_address).add_token(token)

    return token_addresses
Пример #2
0
def token_addresses(
        token_amount,
        number_of_tokens,
        private_keys,
        deploy_service,
        token_network_registry_address,
        register_tokens,
        contract_manager,
) -> typing.List[typing.Address]:
    """ Fixture that yields `number_of_tokens` ERC20 token addresses, where the
    `token_amount` (per token) is distributed among the addresses behind `deploy_client` and
    potentially pre-registered with the raiden Registry.
    The following arguments can control the behavior:

    Args:
        token_amount (int): the overall number of units minted per token
        number_of_tokens (int): the number of token instances
        register_tokens (bool): controls if tokens will be registered with raiden Registry
    """

    participants = [privatekey_to_address(key) for key in private_keys]
    token_addresses = deploy_tokens_and_fund_accounts(
        token_amount=token_amount,
        number_of_tokens=number_of_tokens,
        deploy_service=deploy_service,
        participants=participants,
        contract_manager=contract_manager,
    )

    if register_tokens:
        for token in token_addresses:
            deploy_service.token_network_registry(token_network_registry_address).add_token(token)

    return token_addresses
Пример #3
0
def token_addresses(
    request,
    token_amount,
    number_of_tokens,
    blockchain_services,
    register_tokens,
):
    """ Fixture that yields `number_of_tokens` ERC20 token addresses, where the
    `token_amount` (per token) is distributed among the addresses behind `blockchain_services` and
    potentially pre-registered with the raiden Registry.
    The following arguments can control the behavior:

    Args:
        token_amount (int): the overall number of units minted per token
        number_of_tokens (int): the number of token instances
        register_tokens (bool): controls if tokens will be registered with raiden Registry
    """

    participants = [
        privatekey_to_address(blockchain_service.private_key)
        for blockchain_service in blockchain_services.blockchain_services
    ]
    token_addresses = deploy_tokens_and_fund_accounts(
        token_amount,
        number_of_tokens,
        blockchain_services.deploy_service,
        participants,
    )

    if register_tokens:
        for token in token_addresses:
            blockchain_services.deploy_registry.add_token(token)

    return token_addresses
Пример #4
0
def deploy_all_tokens_register_and_return_their_addresses(
    token_amount,
    number_of_tokens,
    private_keys,
    deploy_service,
    token_network_registry_address,
    register_tokens,
    contract_manager,
) -> typing.List[typing.Address]:
    """ Fixture that yields `number_of_tokens` ERC20 token addresses, where the
    `token_amount` (per token) is distributed among the addresses behind `deploy_client` and
    potentially pre-registered with the raiden Registry.
    The following arguments can control the behavior:

    Args:
        token_amount (int): the overall number of units minted per token
        number_of_tokens (int): the number of token instances
        register_tokens (bool): controls if tokens will be registered with raiden Registry
    """

    participants = [privatekey_to_address(key) for key in private_keys]
    token_addresses = deploy_tokens_and_fund_accounts(
        token_amount=token_amount,
        number_of_tokens=number_of_tokens,
        deploy_service=deploy_service,
        participants=participants,
        contract_manager=contract_manager,
    )

    if register_tokens:
        for token in token_addresses:
            registry = deploy_service.token_network_registry(
                token_network_registry_address)
            if contract_manager.contracts_version == DEVELOPMENT_CONTRACT_VERSION:
                registry.add_token_with_limits(
                    token_address=token,
                    channel_participant_deposit_limit=
                    RED_EYES_PER_CHANNEL_PARTICIPANT_LIMIT,
                    token_network_deposit_limit=
                    RED_EYES_PER_TOKEN_NETWORK_LIMIT,
                )
            else:
                registry.add_token_without_limits(
                    token_address=token,
                    given_block_identifier='latest',
                )

    return token_addresses
Пример #5
0
def deploy_all_tokens_register_and_return_their_addresses(
    token_amount: TokenAmount,
    number_of_tokens: int,
    private_keys: List[PrivateKey],
    proxy_manager: ProxyManager,
    token_network_registry_address: TokenNetworkRegistryAddress,
    register_tokens: bool,
    contract_manager: ContractManager,
    token_contract_name: str,
) -> List[TokenAddress]:
    """ Fixture that yields `number_of_tokens` ERC20 token addresses, where the
    `token_amount` (per token) is distributed among the addresses behind `deploy_client` and
    potentially pre-registered with the Raiden Registry.
    The following arguments can control the behavior:

    Args:
        token_amount: the overall number of units minted per token
        number_of_tokens: the number of token instances
        register_tokens: controls if tokens will be registered with raiden Registry
    """

    participants = [privatekey_to_address(key) for key in private_keys]
    token_addresses = deploy_tokens_and_fund_accounts(
        token_amount=token_amount,
        number_of_tokens=number_of_tokens,
        proxy_manager=proxy_manager,
        participants=participants,
        contract_manager=contract_manager,
        token_contract_name=token_contract_name,
    )

    if register_tokens:
        for token in token_addresses:
            registry = proxy_manager.token_network_registry(
                token_network_registry_address)
            registry.add_token(
                token_address=token,
                channel_participant_deposit_limit=
                RED_EYES_PER_CHANNEL_PARTICIPANT_LIMIT,
                token_network_deposit_limit=RED_EYES_PER_TOKEN_NETWORK_LIMIT,
                block_identifier=proxy_manager.client.
                blockhash_from_blocknumber("latest"),
            )

    return token_addresses