Ejemplo n.º 1
0
class ConnectionsResource(BaseResource):

    put_schema = ConnectionsConnectSchema()
    delete_schema = ConnectionsLeaveSchema()

    @use_kwargs(put_schema)
    def put(
        self,
        token_address,
        funds,
        initial_channel_target,
        joinable_funds_target,
    ):

        return self.rest_api.connect(
            registry_address=self.rest_api.raiden_api.raiden.default_registry.
            address,
            token_address=token_address,
            funds=funds,
            initial_channel_target=initial_channel_target,
            joinable_funds_target=joinable_funds_target,
        )

    @use_kwargs(delete_schema, locations=('json', ))
    def delete(self, token_address, only_receiving_channels):
        return self.rest_api.leave(registry_address=self.rest_api.raiden_api.
                                   raiden.default_registry.address,
                                   token_address=token_address,
                                   only_receiving=only_receiving_channels)
Ejemplo n.º 2
0
class ConnectionsResource(BaseResource):

    put_schema = ConnectionsConnectSchema()
    delete_schema = ConnectionsLeaveSchema()

    @use_kwargs(put_schema)
    @if_api_available
    def put(
        self,
        token_address: TokenAddress,
        funds: TokenAmount,
        initial_channel_target: int,
        joinable_funds_target: float,
    ) -> Response:
        return self.rest_api.connect(
            registry_address=self.rest_api.raiden_api.raiden.default_registry.
            address,
            token_address=token_address,
            funds=funds,
            initial_channel_target=initial_channel_target,
            joinable_funds_target=joinable_funds_target,
        )

    @use_kwargs(delete_schema, locations=("json", ))
    @if_api_available
    def delete(self, token_address: TokenAddress) -> Response:
        return self.rest_api.leave(
            registry_address=self.rest_api.raiden_api.raiden.default_registry.
            address,
            token_address=token_address,
        )
Ejemplo n.º 3
0
class ConnectionsResource(BaseResource):

    put_schema = ConnectionsConnectSchema()
    delete_schema = ConnectionsLeaveSchema()

    def __init__(self, **kwargs):
        super(ConnectionsResource, self).__init__(**kwargs)

    @use_kwargs(put_schema, locations=('json', ))
    def put(self, token_address, funds, initial_channel_target,
            joinable_funds_target):
        return self.rest_api.connect(
            token_address=token_address,
            funds=funds,
            initial_channel_target=initial_channel_target,
            joinable_funds_target=joinable_funds_target,
        )

    @use_kwargs(delete_schema, locations=('json', ))
    def delete(self, token_address, wait_for_settle, timeout):
        return self.rest_api.leave(
            token_address=token_address,
            wait_for_settle=wait_for_settle,
            timeout=timeout,
        )
Ejemplo n.º 4
0
class ConnectionsResource(BaseResource):

    put_schema = ConnectionsConnectSchema()
    delete_schema = ConnectionsLeaveSchema()

    @use_kwargs(put_schema)
    def put(self, token_address, funds, initial_channel_target,
            joinable_funds_target):
        return self.rest_api.connect(
            token_address=token_address,
            funds=funds,
            initial_channel_target=initial_channel_target,
            joinable_funds_target=joinable_funds_target,
        )

    @use_kwargs(delete_schema, locations=('json', ))
    def delete(self, token_address, only_receiving_channels):
        return self.rest_api.leave(token_address=token_address,
                                   only_receiving=only_receiving_channels)

    def get(self, token_address):
        return self.rest_api.get_connection_manager_funds(
            token_address=token_address)