How to use the raiden.exceptions.RaidenError function in raiden

To help you get started, we’ve selected a few raiden examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github raiden-network / raiden / raiden / utils / testnet.py View on Github external
Raises:
        MintFailed if anything goes wrong.
    """
    method = contract_method.value

    gas_limit = proxy.estimate_gas("latest", method, *args)
    if gas_limit is None:
        raise MintFailed(
            f"Gas estimation failed. Make sure the token has a "
            f"method named {method} with the expected signature."
        )

    try:
        tx_hash = proxy.transact(method, gas_limit, *args)
    except (RaidenError, ValueError) as e:
        # Re-raise TransactionAlreadyPending etc. as MintFailed.
        # Since the token minting api is not standardized, we also catch ValueErrors
        # that might fall through ContractProxy.transact()'s exception handling.
        raise MintFailed(str(e))

    receipt = client.poll(tx_hash)
    if check_transaction_threw(receipt=receipt):
        raise MintFailed(f"Call to contract method {method}: Transaction failed.")

    return tx_hash
github raiden-network / raiden / raiden / exceptions.py View on Github external
""" Raised if the token address is invalid """


class InvalidTokenNetworkDepositLimit(RaidenError):
    """ Raised when an invalid token network deposit
    limit is passed to the token network registry proxy.
    """


class InvalidChannelParticipantDepositLimit(RaidenError):
    """ Raised when an invalid channel participant
    deposit limit is passed to the token network registry proxy.
    """


class EthNodeInterfaceError(RaidenError):
    """ Raised when the underlying ETH node does not support an rpc interface"""


class AddressWithoutCode(RaidenError):
    """Raised on attempt to execute contract on address without a code."""


class AddressWrongContract(RaidenError):
    """Raised on attempt to execute contract on address that has code but
    is probably not the contract we wanted."""


class DuplicatedChannelError(RaidenRecoverableError):
    """Raised if someone tries to create a channel that already exists."""
github raiden-network / raiden / raiden / exceptions.py View on Github external
"""


class UnknownTokenAddress(RaidenError):
    """ Raised when the token address in unknown. """


class TokenNotRegistered(RaidenError):
    """ Raised if there is no token network for token used when opening a channel  """


class AlreadyRegisteredTokenAddress(RaidenError):
    """ Raised when the token address in already registered with the given network. """


class InvalidToken(RaidenError):
    """ Raised if the token does not follow the ERC20 standard """


class InvalidTokenAddress(RaidenError):
    """ Raised if the token address is invalid """


class InvalidTokenNetworkDepositLimit(RaidenError):
    """ Raised when an invalid token network deposit
    limit is passed to the token network registry proxy.
    """


class InvalidChannelParticipantDepositLimit(RaidenError):
    """ Raised when an invalid channel participant
    deposit limit is passed to the token network registry proxy.
github raiden-network / raiden / raiden / exceptions.py View on Github external
class SamePeerAddress(RaidenError):
    """ Raised when a user tries to create a channel where the address of both
    peers is the same.
    """


class UnknownTokenAddress(RaidenError):
    """ Raised when the token address in unknown. """


class TokenNotRegistered(RaidenError):
    """ Raised if there is no token network for token used when opening a channel  """


class AlreadyRegisteredTokenAddress(RaidenError):
    """ Raised when the token address in already registered with the given network. """


class InvalidToken(RaidenError):
    """ Raised if the token does not follow the ERC20 standard """


class InvalidTokenAddress(RaidenError):
    """ Raised if the token address is invalid """


class InvalidTokenNetworkDepositLimit(RaidenError):
    """ Raised when an invalid token network deposit
    limit is passed to the token network registry proxy.
    """
github raiden-network / raiden / raiden / exceptions.py View on Github external
Either the raiden node is not capable of mediating this payment, or the
    FeeSchedule is outdated/inconsistent."""


class TokenNetworkDeprecated(RaidenError):
    """ Raised when the token network proxy safety switch
    is turned on (i.e deprecated).
    """


class MintFailed(RaidenError):
    """ Raised when an attempt to mint a testnet token failed. """


class SerializationError(RaidenError):
    """ Invalid data are to be (de-)serialized. """


class MatrixSyncMaxTimeoutReached(RaidenRecoverableError):
    """ Raised if processing the matrix response takes longer than the poll timeout. """
github raiden-network / raiden / raiden / ui / startup.py View on Github external
def handle_contract_no_code(name: str, address: Address) -> None:
    hex_addr = to_checksum_address(address)
    raise RaidenError(f"Error: Provided {name} {hex_addr} contract does not contain code")
github raiden-network / raiden / raiden / exceptions.py View on Github external
class InsufficientGasReserve(RaidenError):
    """ Raised when an action cannot be done because the available balance
    is not sufficient for the lifecycles of all active channels.
    """


class InsufficientEth(RaidenError):
    """ Raised when an on-chain action failed because we could not pay for
    the gas. (The case we try to avoid with `InsufficientGasReserve`
    exceptions.)
    """


class BrokenPreconditionError(RaidenError):
    """ Raised when the chain doesn't satisfy transaction preconditions
    that proxies check at the specified block.

    This exception should be used, when the proxy already sees that,
    on the specified block, due to the blockchain state, an assert
    or a revert in the smart contract would be hit for the triggering block.

    This exception should not be used for errors independent of the
    chain state. For example, when an argument needs to be always non-zero,
    violation of this condition is not a BrokenPreconditionError, but
    RaidenValidationError.

    This exception can also be used when preconditions are not satisfied
    on another Raiden node.
    """
github raiden-network / raiden / raiden / network / pathfinding.py View on Github external
if pfs_url == "auto":
        if service_registry is None:
            raise RaidenError(
                "Raiden was started with routing mode set to PFS, the pathfinding service address "
                "set to 'auto' but no service registry address was given. Either specifically "
                "provide a PFS address or provide a service registry address."
            )

        block_hash = service_registry.client.get_confirmed_blockhash()
        maybe_pfs_url = get_random_pfs(
            service_registry=service_registry,
            block_identifier=block_hash,
            pathfinding_max_fee=pathfinding_max_fee,
        )
        if maybe_pfs_url is None:
            raise RaidenError(
                "The Service Registry has no registered Pathfinding Service "
                "and basic routing is not used."
            )
        else:
            pfs_url = maybe_pfs_url

    try:
        pathfinding_service_info = get_pfs_info(pfs_url)
    except ServiceRequestFailed as e:
        raise RaidenError(
            f"There was an error with the Pathfinding Service with address "
            f"{pfs_url}. Raiden will shut down. Please try a different Pathfinding Service. \n"
            f"Error Message: {str(e)}"
        )

    if pathfinding_service_info.price > 0 and not pathfinding_service_info.payment_address:
github raiden-network / raiden / raiden / exceptions.py View on Github external
""" Raised when the requested deposit is over the limit

    Used when a *user* tries to deposit a given amount of token in a channel,
    but the amount is over the testing limit.
    """


class DepositMismatch(RaidenRecoverableError):
    """ Raised when the requested deposit is lower than actual channel deposit

    Used when a *user* tries to deposit a given amount of tokens in a channel,
    but the on-chain amount is already higher.
    """


class InvalidChannelID(RaidenError):
    """ Raised when the user provided value is not a channel id. """


class WithdrawMismatch(RaidenRecoverableError):
    """ Raised when the requested withdraw is larger than actual channel balance. """


class InvalidChecksummedAddress(RaidenError):
    """Raised when the user provided address is not a str or the value is not
    properly checksummed.

    Exception used to enforce the checksummed for external APIs. The address
    provided by a user must be checksummed to avoid errors, the checksummed
    address must be validated at the edges before calling internal functions.
    """
github raiden-network / raiden / raiden / exceptions.py View on Github external
Exception used to enforce the sandwich encoding for python APIs. The
    internal address representation used by Raiden is binary, the binary
    address must be validated at the edges before calling internal functions.
    """


class InvalidSecret(RaidenError):
    """ Raised when the user provided value is not a valid secret. """


class InvalidSecretHash(RaidenError):
    """ Raised when the user provided value is not a valid secrethash. """


class InvalidAmount(RaidenError):
    """ Raised when the user provided value is not a positive integer and
    cannot be used to define a transfer value.
    """


class InvalidSettleTimeout(RaidenError):
    """ Raised when the user provided timeout value is less than the minimum
    settle timeout"""


class InvalidRevealTimeout(RaidenError):
    """ Raised when the channel's settle timeout is less than
    double the user provided reveal timeout value.
    condition: settle_timeout < reveal_timeout * 2
    """