Exemple #1
0
 def process_change(bountyContract, url, txid, network):
     url = normalizeURL(url)
     didChange, old_bounty, new_bounty = syncBountywithWeb3(bountyContract, url, network)
     print("{} changed, {}".format(didChange, url))
     if didChange:
         print("- processing changes")
         process_bounty_changes(old_bounty, new_bounty, txid)
Exemple #2
0
def process_bounty(bounty_data):
    did_change, old_bounty, new_bounty = process_bounty_details(bounty_data)

    if did_change:
        print(f"- processing changes, {old_bounty} => {new_bounty}")
        process_bounty_changes(old_bounty, new_bounty)

    return did_change, old_bounty, new_bounty
Exemple #3
0
def web3_process_bounty(bounty_data):
    did_change, old_bounty, new_bounty = process_bounty_details(bounty_data)

    if did_change and new_bounty:
        _from = old_bounty.pk if old_bounty else None
        print(f"- processing changes, {_from} => {new_bounty.pk}")
        process_bounty_changes(old_bounty, new_bounty)

    return did_change, old_bounty, new_bounty
Exemple #4
0
def web3_process_bounty(bounty_data):
    """Process web3 bounty data by creating new or updated Bounty objects."""
    # Check whether or not the bounty data payload is for mainnet and env is prod or other network and not mainnet.
    if not bounty_data or (settings.DEBUG or settings.ENV != 'prod'
                           ) and bounty_data.get('network') == 'mainnet':
        # This block will return None if running in debug/non-prod env and the network is mainnet.
        return None

    did_change, old_bounty, new_bounty = process_bounty_details(bounty_data)

    if did_change and new_bounty:
        _from = old_bounty.pk if old_bounty else None
        print(f"- processing changes, {_from} => {new_bounty.pk}")
        process_bounty_changes(old_bounty, new_bounty)

    return did_change, old_bounty, new_bounty
Exemple #5
0
def sync_web3(request):

    #setup
    result = {}
    issueURL = request.POST.get('issueURL', False)
    bountydetails = request.POST.getlist('bountydetails[]', [])
    if issueURL:

        issueURL = normalizeURL(issueURL)
        if not len(bountydetails):
            #create a bounty sync request
            result['status'] = 'OK'
            for existing_bsr in BountySyncRequest.objects.filter(github_url=issueURL, processed=False):
                existing_bsr.processed = True
                existing_bsr.save()
        else:
            #normalize data
            bountydetails[0] = int(bountydetails[0])
            bountydetails[1] = str(bountydetails[1])
            bountydetails[2] = str(bountydetails[2])
            bountydetails[3] = str(bountydetails[3])
            bountydetails[4] = bool(bountydetails[4] == 'true')
            bountydetails[5] = bool(bountydetails[5] == 'true')
            bountydetails[6] = str(bountydetails[6])
            bountydetails[7] = int(bountydetails[7])
            bountydetails[8] = str(bountydetails[8])
            bountydetails[9] = int(bountydetails[9])
            bountydetails[10] = str(bountydetails[10])
            print(bountydetails)
            contract_address = request.POST.get('contract_address')
            network = request.POST.get('network')
            didChange, old_bounty, new_bounty = process_bounty_details(bountydetails, issueURL, contract_address, network)

            print("{} changed, {}".format(didChange, issueURL))
            if didChange:
                print("- processing changes");
                process_bounty_changes(old_bounty, new_bounty, None)


        BountySyncRequest.objects.create(
            github_url=issueURL,
            processed=False,
            )



    return JsonResponse(result)
Exemple #6
0
def web3_process_bounty(bounty_data):
    """Process web3 bounty data by creating new or updated Bounty objects."""
    # Check whether or not the bounty data payload is for mainnet and env is prod or other network and not mainnet.
    if not bounty_data or (settings.DEBUG or settings.ENV != 'prod') and bounty_data.get('network') == 'mainnet':
        # This block will return None if running in debug/non-prod env and the network is mainnet.
        print(f"--*--")
        return None

    #semaphor_key = f"bounty_processor_{bounty_data['id']}_1"
    #semaphor = get_semaphor(semaphor_key)
    #with semaphor:
    if True: # KO 20181107 -- removing semaphor processing code for time being, due to downtime last night
        did_change, old_bounty, new_bounty = process_bounty_details(bounty_data)

        if did_change and new_bounty:
            _from = old_bounty.pk if old_bounty else None
            print(f"- processing changes, {_from} => {new_bounty.pk}")
            process_bounty_changes(old_bounty, new_bounty)

        return did_change, old_bounty, new_bounty
Exemple #7
0
def sync_web3(request):
    """ Sync up web3 with the database.  This function has a few different uses.  It is typically
        called from the front end using the javascript `sync_web3` function.  The `issueURL` is
        passed in first, followed optionally by a `bountydetails` argument.
    """
    # setup
    result = {}
    issueURL = request.POST.get('issueURL', False)
    bountydetails = json.loads(request.POST.get('bountydetails', "{}"))

    if issueURL:

        issueURL = normalizeURL(issueURL)

        if not bountydetails:
            # create a bounty sync request
            result['status'] = 'OK'
            for existing_bsr in BountySyncRequest.objects.filter(
                    github_url=issueURL, processed=False):
                existing_bsr.processed = True
                existing_bsr.save()
        else:
            contract_address = request.POST.get('contract_address')
            network = request.POST.get('network')
            didChange, old_bounty, new_bounty = process_bounty_details(
                bountydetails, issueURL, contract_address, network)

            print("{} changed, {}".format(didChange, issueURL))
            if didChange:
                print("- processing changes")
                process_bounty_changes(old_bounty, new_bounty, None)

        BountySyncRequest.objects.create(
            github_url=issueURL,
            processed=False,
        )

    return JsonResponse(result)