Пример #1
0
    def check_valid(self, store, txn):
        if txn.Identifier in store:
            raise InvalidTransactionError("ObjectId already in store")

        if not market_place_object_update.global_is_valid_name(
                store, self._name, self.ObjectType, self._creator_id):
            raise InvalidTransactionError("Name is not valid")

        if not market_place_object_update.global_is_permitted(
                store, txn, self._creator_id, self.CreatorType):
            raise InvalidTransactionError(
                "Creator Address not the same as txn.OriginatorID")

        assettype = asset_type_update.AssetTypeObject.load_from_store(
            store, self._asset_type_id)
        if not assettype:
            logger.debug('missing asset type %s', self._asset_type_id)
            raise InvalidTransactionError(
                "AssetTypeId does not reference an AssetType")

        # if the asset type is restricted then the creator of the asset type
        # is the only one who can create assets of that type
        if assettype.Restricted and assettype.CreatorID != self._creator_id:
            logger.debug('no permission to create an asset of type %s',
                         self._asset_type_id)
            raise InvalidTransactionError(
                "AssetType is restricted and the creator is not the same "
                "as txn creator")
Пример #2
0
    def check_valid(self, store, txn):
        if txn.Identifier in store:
            raise InvalidTransactionError(
                "ObjectId already in store")

        if not market_place_object_update.global_is_valid_name(
                store, self._name, self.ObjectType, self._creator_id):
            raise InvalidTransactionError(
                "Name is not valid")

        if not market_place_object_update.global_is_permitted(
                store, txn, self._creator_id, self.CreatorType):
            raise InvalidTransactionError(
                "Creator Address not the same as txn.OriginatorID")

        assettype = asset_type_update.AssetTypeObject.load_from_store(
            store, self._asset_type_id)
        if not assettype:
            logger.debug('missing asset type %s', self._asset_type_id)
            raise InvalidTransactionError(
                "AssetTypeId does not reference an AssetType")

        # if the asset type is restricted then the creator of the asset type
        # is the only one who can create assets of that type
        if assettype.Restricted and assettype.CreatorID != self._creator_id:
            logger.debug('no permission to create an asset of type %s',
                         self._asset_type_id)
            raise InvalidTransactionError(
                "AssetType is restricted and the creator is not the same "
                "as txn creator")
Пример #3
0
    def check_valid(self, store, txn):
        if txn.Identifier in store:
            raise InvalidTransactionError("ObjectId already in store")

        if not market_place_object_update.global_is_permitted(
                store, txn, self._creator_id, self.CreatorType):
            raise InvalidTransactionError(
                "Creator address is different from txn.OriginatorID")

        if not market_place_object_update.global_is_valid_name(
                store, self._name, self.ObjectType, self._creator_id):
            raise InvalidTransactionError(
                "Name, {}, is not valid".format(self._name))

        if not liability_update.LiabilityObject.is_valid_object(
                store, self._input_id):
            raise InvalidTransactionError(
                "{} is not a Liability".format(self._input_id))

        obj = liability_update.LiabilityObject.get_valid_object(store,
                                                                self._input_id)
        if not self.CreatorType.is_valid_creator(store, obj.get('creator'),
                                                 txn.OriginatorID):
            logger.info('%s does not have permission to modify liability %s',
                        txn.OriginatorID, self._input_id)
            raise InvalidTransactionError(
                "Txn.OriginatorID not allowed to modify liability")

        if not holding_update.HoldingObject.is_valid_object(store,
                                                            self._output_id):
            raise InvalidTransactionError(
                "OutputId is not a valid Holding")

        obj = holding_update.HoldingObject.get_valid_object(
            store, self._output_id)
        if not self.CreatorType.is_valid_creator(store, obj.get('creator'),
                                                 txn.OriginatorID):
            logger.info('%s does not have permission to modify liability %s',
                        txn.OriginatorID, self._output_id)
            raise InvalidTransactionError(
                "Txn.OriginatorID does not have permission to modify "
                "liability")

        if self._ratio <= 0:
            logger.debug('invalid ratio %s in offer %s', self._ratio,
                         txn.Identifier)
            raise InvalidTransactionError(
                "Ratio < 0")

        if self._minimum < 0 or self._maximum < 0 or \
                self._maximum < self._minimum:
            logger.debug('inconsistent range %s < %s in offer %s',
                         self._minimum, self._maximum, txn.Identifier)
            raise InvalidTransactionError(
                "Minimum and Maximum are inconsistent")
        if self._execution not in SellOfferObject.ExecutionStyle:
            logger.debug('invalid execution style %s in offer %s',
                         self._execution, txn.Identifier)
            raise InvalidTransactionError(
                "Execution not a valid ExecutionStyle")
Пример #4
0
    def check_valid(self, store, txn):
        if not self.ObjectType.is_valid_object(store, self._object_id):
            return False

        if not market_place_object_update.global_is_permitted(
                store, txn, self._creator_id, self.CreatorType):
            raise InvalidTransactionError(
                "Creator Address is not the same as txn.OriginatorID")
 def check_valid(self, store, txn):
     if not market_place_object_update.global_is_permitted(
             store,
             txn,
             self._creator_id,
             self.CreatorType):
         raise InvalidTransactionError(
             "Creator Address not the same as txn.OriginatorID"
         )
Пример #6
0
    def check_valid(self, store, txn):
        if txn.Identifier in store:
            raise InvalidTransactionError(
                "ObjectId alread in store")

        if not market_place_object_update.global_is_valid_name(
                store, self._name, self.ObjectType, self._creator_id):
            raise InvalidTransactionError(
                "Name isn't valid")

        if not market_place_object_update.global_is_permitted(
                store,
                txn,
                self._creator_id,
                self.CreatorType):
            raise InvalidTransactionError(
                "Creator Address not the same as txn.OriginatorID")

        if not account_update.AccountObject.is_valid_object(store,
                                                            self._account_id):
            raise InvalidTransactionError(
                "AccountID does not reference an Account")

        if self._count < 0:
            raise InvalidTransactionError(
                "Count is less than 0")

        # make sure we have a valid asset
        asset = asset_update.AssetObject.load_from_store(store, self._asset_id)
        if not asset:
            logger.debug('invalid asset %s in holding', self._asset_id)
            raise InvalidTransactionError(
                "AssetId does not reference an Asset")

        # if the asset is restricted, then only the creator of the asset can
        # create holdings with a count greater than 0
        if asset.Restricted:
            if self._creator_id != asset.CreatorID and 0 < self._count:
                logger.debug(
                    'instances of a restricted asset %s can only be created '
                    'by the owner',
                    self._asset_id)
                raise InvalidTransactionError(
                    "Instances of a restricted asset {} can only be created "
                    "by the owner".format(self._asset_id))

        # if the asset is not consumable then counts dont matter, the only
        # valid counts are 0 or 1
        if not asset.Consumable:
            if 1 < self._count:
                logger.debug(
                    'non consumable assets of type %s are retricted to '
                    'a single instance',
                    self._asset_id)
                raise InvalidTransactionError(
                    "Non consumable assets are restricted to a single "
                    "instance")
Пример #7
0
    def check_valid(self, store, txn):
        assert txn.OriginatorID

        if not self.ObjectType.is_valid_object(store, self._object_id):
            raise InvalidTransactionError("ObjectId is not an AssetType")

        if not market_place_object_update.global_is_permitted(
                store, txn, self._creator_id, self.CreatorType):
            raise InvalidTransactionError(
                "Creator address is not the same as txn.OriginatorID")
Пример #8
0
    def check_valid(self, store, txn):
        if self._creator_id != self._object_id:
            logger.info('creator and object are the same for participant '
                        'unregistration')
            return False

        if not market_place_object_update.global_is_permitted(
                store, txn, self._creator_id, self.CreatorType):
            raise InvalidTransactionError(
                "Creator Address not the same as txn.OriginatorID")
    def check_valid(self, store, txn):
        if self._creator_id != self._object_id:
            logger.info(
                'creator and object are the same for participant '
                'unregistration')
            return False

        if not market_place_object_update.global_is_permitted(
                store, txn, self._creator_id, self.CreatorType):
            raise InvalidTransactionError(
                "Creator Address not the same as txn.OriginatorID")
Пример #10
0
    def check_valid(self, store, txn):
        assert txn.OriginatorID

        if not self.ObjectType.is_valid_object(store, self._object_id):
            raise InvalidTransactionError(
                "ObjectId is not an AssetType")

        if not market_place_object_update.global_is_permitted(
                store, txn, self._creator_id, self.CreatorType):
            raise InvalidTransactionError(
                "Creator address is not the same as txn.OriginatorID")
Пример #11
0
    def check_valid(self, store, txn):
        if txn.Identifier in store:
            raise InvalidTransactionError("Object Id is already in store")

        if not market_place_object_update.global_is_valid_name(
                store, self._name, self.ObjectType, self._creator_id):
            raise InvalidTransactionError("Name isn't valid")

        if not market_place_object_update.global_is_permitted(
                store, txn, self._creator_id, self.CreatorType):
            raise InvalidTransactionError(
                "Creator address is not the same as txn.OriginatorID")
Пример #12
0
    def check_valid(self, store, txn):
        if txn.Identifier in store:
            raise InvalidTransactionError("ObjectId alread in store")

        if not market_place_object_update.global_is_valid_name(
                store, self._name, self.ObjectType, self._creator_id):
            raise InvalidTransactionError("Name isn't valid")

        if not market_place_object_update.global_is_permitted(
                store, txn, self._creator_id, self.CreatorType):
            raise InvalidTransactionError(
                "Creator Address not the same as txn.OriginatorID")

        if not account_update.AccountObject.is_valid_object(
                store, self._account_id):
            raise InvalidTransactionError(
                "AccountID does not reference an Account")

        if self._count < 0:
            raise InvalidTransactionError("Count is less than 0")

        # make sure we have a valid asset
        asset = asset_update.AssetObject.load_from_store(store, self._asset_id)
        if not asset:
            logger.debug('invalid asset %s in holding', self._asset_id)
            raise InvalidTransactionError(
                "AssetId does not reference an Asset")

        # if the asset is restricted, then only the creator of the asset can
        # create holdings with a count greater than 0
        if asset.Restricted:
            if self._creator_id != asset.CreatorID and 0 < self._count:
                logger.debug(
                    'instances of a restricted asset %s can only be created '
                    'by the owner', self._asset_id)
                raise InvalidTransactionError(
                    "Instances of a restricted asset {} can only be created "
                    "by the owner".format(self._asset_id))

        # if the asset is not consumable then counts dont matter, the only
        # valid counts are 0 or 1
        if not asset.Consumable:
            if 1 < self._count:
                logger.debug(
                    'non consumable assets of type %s are retricted to '
                    'a single instance', self._asset_id)
                raise InvalidTransactionError(
                    "Non consumable assets are restricted to a single "
                    "instance")
Пример #13
0
    def check_valid(self, store, txn):
        if txn.Identifier in store:
            raise InvalidTransactionError(
                "ObjectId is already used")

        if not market_place_object_update.global_is_valid_name(
                store, self._name, self.ObjectType,
                self._creator_id):
            raise InvalidTransactionError(
                "Name isn't valid")

        if not market_place_object_update.global_is_permitted(
                store, txn, self._creator_id, self.CreatorType):
            raise InvalidTransactionError(
                "Creator Address not the same as txn.OriginatorId")
Пример #14
0
    def check_valid(self, store, txn):
        if txn.Identifier in store:
            raise InvalidTransactionError(
                "ObjectId already in store")

        if not market_place_object_update.global_is_valid_name(
                store, self._name, self.ObjectType, self._creator_id):
            raise InvalidTransactionError(
                "Name is not valid")

        if not market_place_object_update.global_is_permitted(
                store,
                txn,
                self._creator_id,
                self.CreatorType):
            raise InvalidTransactionError(
                "Creator Address not the same as txn.OriginatorID")

        if not account_update.AccountObject.is_valid_object(store,
                                                            self._account_id):
            raise InvalidTransactionError(
                "AccountId does not reference an Account")

        if not asset_type_update.AssetTypeObject.is_valid_object(
                store, self._asset_type_id):
            raise InvalidTransactionError(
                "AssetTypeid not a valid AssetType")

        if not participant_update.ParticipantObject.is_valid_object(
                store, self._guarantor_id):
            raise InvalidTransactionError(
                "GuarantorID not a valid Participant")

        if self._count < 0:
            raise InvalidTransactionError(
                "Count < 0")

        return True
Пример #15
0
 def check_valid(self, store, txn):
     if not market_place_object_update.global_is_permitted(
             store, txn, self._creator_id, self.CreatorType):
         raise InvalidTransactionError(
             "Creator address not the same as txn.OriginatorID")
Пример #16
0
    def check_valid(self, store, txn):
        if txn.Identifier in store:
            raise InvalidTransactionError("ObjectId already in store")

        if not market_place_object_update.global_is_valid_name(
                store, self._name, self.ObjectType, self._creator_id):
            raise InvalidTransactionError("Name isn't valid")

        if not market_place_object_update.global_is_permitted(
                store, txn, self._creator_id, self.CreatorType):
            logger.debug('failed permission check on offer %s', txn.Identifier)
            raise InvalidTransactionError(
                "Creator address not the same as txn.OriginatorID")

        if not liability_update.LiabilityObject.is_valid_object(
                store, self._input_id):
            logger.debug('input liability %s is not valid in offer %s ',
                         self._input_id, txn.Identifier)
            raise InvalidTransactionError(
                "InputId, {}, is not a liability".format(str(self._input_id)))

        obj = liability_update.LiabilityObject.get_valid_object(
            store, self._input_id)
        if not self.CreatorType.is_valid_creator(store, obj.get('creator'),
                                                 txn.OriginatorID):
            logger.info('%s does not have permission to modify liability %s',
                        txn.OriginatorID, self._input_id)
            raise InvalidTransactionError(
                "txn.OriginatorID is not liability creator")

        if not liability_update.LiabilityObject.is_valid_object(
                store, self._output_id):
            logger.debug('output liability %s is not valid in offer %s ',
                         self._output_id, txn.Identifier)
            raise InvalidTransactionError("OutputID is not a valid liability")

        obj = liability_update.LiabilityObject.get_valid_object(
            store, self._output_id)
        if not self.CreatorType.is_valid_creator(store, obj.get('creator'),
                                                 txn.OriginatorID):
            logger.info('%s does not have permission to modify liability %s',
                        txn.OriginatorID, self._output_id)
            raise InvalidTransactionError(
                "Output Liability creator is not the same as "
                "txn.OriginatorID")

        if self._ratio <= 0:
            logger.debug('invalid ratio %s in offer %s', self._ratio,
                         txn.Identifier)
            raise InvalidTransactionError("Ratio is less than or equal to 0")

        if self._minimum < 0 or self._maximum < 0 or \
                self._maximum < self._minimum:
            logger.debug('inconsistent range %s < %s in offer %s',
                         self._minimum, self._maximum, txn.Identifier)
            raise InvalidTransactionError(
                "Minimum and Maximum are inconsistent")

        if self._execution not in ExchangeOfferObject.ExecutionStyle:
            logger.debug('invalid execution style %s in offer %s',
                         self._execution, txn.Identifier)
            raise InvalidTransactionError(
                "Execution not a valid ExecutionStyle")
    def check_valid(self, store, txn):
        if txn.Identifier in store:
            raise InvalidTransactionError(
                "ObjectId already in store")

        if not market_place_object_update.global_is_valid_name(
                store, self._name, self.ObjectType, self._creator_id):
            raise InvalidTransactionError(
                "Name isn't valid")

        if not market_place_object_update.global_is_permitted(
                store,
                txn,
                self._creator_id,
                self.CreatorType):
            logger.debug('failed permission check on offer %s',
                         txn.Identifier)
            raise InvalidTransactionError(
                "Creator address not the same as txn.OriginatorID")

        if not liability_update.LiabilityObject.is_valid_object(
                store, self._input_id):
            logger.debug('input liability %s is not valid in offer %s ',
                         self._input_id, txn.Identifier)
            raise InvalidTransactionError(
                "InputId, {}, is not a liability".format(str(self._input_id)))

        obj = liability_update.LiabilityObject.get_valid_object(
            store, self._input_id)
        if not self.CreatorType.is_valid_creator(store, obj.get('creator'),
                                                 txn.OriginatorID):
            logger.info('%s does not have permission to modify liability %s',
                        txn.OriginatorID, self._input_id)
            raise InvalidTransactionError(
                "txn.OriginatorID is not liability creator")

        if not liability_update.LiabilityObject.is_valid_object(
                store, self._output_id):
            logger.debug('output liability %s is not valid in offer %s ',
                         self._output_id, txn.Identifier)
            raise InvalidTransactionError(
                "OutputID is not a valid liability")

        obj = liability_update.LiabilityObject.get_valid_object(
            store, self._output_id)
        if not self.CreatorType.is_valid_creator(store, obj.get('creator'),
                                                 txn.OriginatorID):
            logger.info('%s does not have permission to modify liability %s',
                        txn.OriginatorID, self._output_id)
            raise InvalidTransactionError(
                "Output Liability creator is not the same as "
                "txn.OriginatorID")

        if self._ratio <= 0:
            logger.debug('invalid ratio %s in offer %s', self._ratio,
                         txn.Identifier)
            raise InvalidTransactionError(
                "Ratio is less than or equal to 0")

        if self._minimum < 0 or self._maximum < 0 or \
                self._maximum < self._minimum:
            logger.debug('inconsistent range %s < %s in offer %s',
                         self._minimum, self._maximum, txn.Identifier)
            raise InvalidTransactionError(
                "Minimum and Maximum are inconsistent")

        if self._execution not in ExchangeOfferObject.ExecutionStyle:
            logger.debug('invalid execution style %s in offer %s',
                         self._execution, txn.Identifier)
            raise InvalidTransactionError(
                "Execution not a valid ExecutionStyle")