Esempio n. 1
0
class ClientMessageValidator(PClientMessageValidator):

    # extend operation field
    schema = tuple(
        map(
            lambda x: (x[0], ClientOperationField())
            if x[0] == OPERATION else x, PClientMessageValidator.schema))


class LedgerIdField(PLedgerIdField):
    ledger_ids = PLedgerIdField.ledger_ids + (CONFIG_LEDGER_ID, )


class LedgerInfoField(PLedgerInfoField):
    _ledger_id_class = LedgerIdField


# TODO: it is a workaround which helps extend some fields from
# downstream projects, should be removed after we find a better way
# to do this
node_message_factory.update_schemas_by_field_type(PLedgerIdField,
                                                  LedgerIdField)
node_message_factory.update_schemas_by_field_type(PLedgerInfoField,
                                                  LedgerInfoField)


class SafeRequest(Request, ClientMessageValidator):
    def __init__(self, **kwargs):
        self.validate(kwargs)
        super().__init__(**kwargs)
Esempio n. 2
0
class ClientMessageValidator(PClientMessageValidator):

    # extend operation field
    schema = tuple(
        map(lambda x: (x[0], ClientOperationField()) if x[0] == OPERATION else x,
            PClientMessageValidator.schema)
    )


class LedgerIdField(PLedgerIdField):
    ledger_ids = PLedgerIdField.ledger_ids + (CONFIG_LEDGER_ID,)


class LedgerInfoField(PLedgerInfoField):
    _ledger_id_class = LedgerIdField


# TODO: it is a workaround which helps extend some fields from
# downstream projects, should be removed after we find a better way
# to do this
node_message_factory.update_schemas_by_field_type(PLedgerIdField, LedgerIdField)
node_message_factory.update_schemas_by_field_type(PLedgerInfoField, LedgerInfoField)


class SafeRequest(Request, ClientMessageValidator):

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