Exemple #1
0
    def fulfill_bounty(self, bounty, fulfillment_id, inputs, event_timestamp,
                       transaction_issuer, **kwargs):

        fulfillment = Fulfillment.objects.filter(fulfillment_id=fulfillment_id,
                                                 bounty_id=bounty.bounty_id)

        if fulfillment.exists():
            return

        data_hash = inputs.get('data')
        ipfs_data = map_fulfillment_data(data_hash, bounty.bounty_id,
                                         fulfillment_id)

        fulfillment_data = {
            'fulfillment_id':
            fulfillment_id,
            'fulfiller':
            transaction_issuer.lower(),
            'bounty':
            bounty.bounty_id,
            'accepted':
            False,
            'fulfillment_created':
            datetime.datetime.fromtimestamp(int(event_timestamp)),
        }

        fulfillment_serializer = FulfillmentSerializer(data={
            **fulfillment_data,
            **ipfs_data
        })
        fulfillment_serializer.is_valid(raise_exception=True)
        instance = fulfillment_serializer.save()

        return instance
Exemple #2
0
    def fulfill_bounty(self, bounty, **kwargs):
        fulfillment_id = kwargs.get('fulfillment_id')

        data_hash = kwargs.get('data')
        ipfs_data = map_fulfillment_data(data_hash, bounty.bounty_id,
                                         fulfillment_id)
        fulfillment_data = {
            'contract_version':
            bounty.contract_version,
            'fulfillment_id':
            fulfillment_id,
            'fulfiller_address':
            kwargs.get('fulfillers')[0].lower(),
            'fulfiller':
            kwargs.get('fulfillers')[0].lower(),
            'bounty':
            bounty.pk,
            'accepted':
            False,
            'fulfillment_created':
            datetime.datetime.fromtimestamp(int(
                kwargs.get('event_timestamp'))),
        }

        fulfillment_serializer = FulfillmentSerializer(data={
            **fulfillment_data,
            **ipfs_data
        })

        fulfillment_serializer.is_valid(raise_exception=True)

        return fulfillment_serializer.save()
Exemple #3
0
    def update_fulfillment(self, bounty_id, fulfillment_id, inputs):
        data_hash = inputs.get('data')
        ipfs_data = map_fulfillment_data(data_hash, bounty_id, fulfillment_id)

        fulfillment = Fulfillment.objects.get(fulfillment_id=fulfillment_id,
                                              bounty_id=bounty_id)
        fulfillment_serializer = FulfillmentSerializer(fulfillment,
                                                       data={**ipfs_data},
                                                       partial=True)
        fulfillment_serializer.save()
    def update_fulfillment(self, bounty, fulfillment_id, inputs, **kwargs):
        fulfillment = Fulfillment.objects.get(
            fulfillment_id=fulfillment_id, bounty_id=bounty.bounty_id)

        data_hash = inputs.get('data')
        ipfs_data = map_fulfillment_data(data_hash, bounty.bounty_id, fulfillment_id)

        fulfillment_serializer = FulfillmentSerializer(
            fulfillment, data={**ipfs_data}, partial=True)
        instance = fulfillment_serializer.save()

        return instance
Exemple #5
0
    def update_fulfillment(self, bounty, **kwargs):

        fulfillment_id = kwargs.get('fulfillment_id')
        fulfillment = Fulfillment.objects.get(bounty=bounty.pk,
                                              fulfillment_id=fulfillment_id)

        data_hash = kwargs.get('data')
        ipfs_data = map_fulfillment_data(data_hash, bounty.bounty_id,
                                         fulfillment_id)

        fulfillment_serializer = FulfillmentSerializer(fulfillment,
                                                       data={**ipfs_data},
                                                       partial=True)
        fulfillment_serializer.is_valid(raise_exception=True)
        instance = fulfillment_serializer.save()

        return instance