diff --git a/app/assets/v2/js/grants/ingest-missing-contributions.js b/app/assets/v2/js/grants/ingest-missing-contributions.js index 4b013d9055d..76e0c02a818 100644 --- a/app/assets/v2/js/grants/ingest-missing-contributions.js +++ b/app/assets/v2/js/grants/ingest-missing-contributions.js @@ -191,7 +191,11 @@ Vue.component('grants-ingest-contributions', { if (!json.success) { console.log('ingestion failed'); this.submitted = false; - throw new Error('Your transactions could not be processed, please try again'); + const msg = json.message ? + 'Error adding contributions as ' + json.message : + 'Error adding contributions, please try again'; + + throw new Error(msg); } else { console.log('ingestion successful'); _alert('Your contributions have been added successfully!', 'success'); diff --git a/app/grants/admin.py b/app/grants/admin.py index 2a8aae97681..6735ac091a6 100644 --- a/app/grants/admin.py +++ b/app/grants/admin.py @@ -348,7 +348,9 @@ def txn_url(self, obj): return format_html("{}", tx_url, tx_id) def profile(self, obj): - return format_html(f"{obj.subscription.contributor_profile}") + if obj.subscription.contributor_profile: + return format_html(f"{obj.subscription.contributor_profile}") + return None def created_on_nt(self, obj): return naturaltime(obj.created_on) @@ -360,7 +362,9 @@ def token(self, obj): return obj.subscription.token_symbol def user_sybil_score(self, obj): - return f"{obj.subscription.contributor_profile.sybil_score} ({obj.subscription.contributor_profile.sybil_score_str})" + if obj.subscription.contributor_profile: + return f"{obj.subscription.contributor_profile.sybil_score} ({obj.subscription.contributor_profile.sybil_score_str})" + return '0' def grant(self, obj): return mark_safe(f"{obj.subscription.grant.title}") diff --git a/app/grants/clr.py b/app/grants/clr.py index 20a7411c176..e8d682eee0f 100644 --- a/app/grants/clr.py +++ b/app/grants/clr.py @@ -145,7 +145,7 @@ def calculate_clr(aggregated_contributions, pair_totals, trust_dict, v_threshold {user_id (str): {user_id (str): pair_total (float)}} trust_dict {user_id (str): trust_score (float)} - v_threshold + v_threshold float uv_threshold float @@ -360,11 +360,12 @@ def populate_data_for_clr(grants, contributions, clr_round): contributions_by_id = {} for c in contribs: prof = c.profile_for_clr - key = prof.id - if key not in contributions_by_id.keys(): - contributions_by_id[key] = [] - contributions_by_id[key].append(c) - contributing_profile_ids.append((prof.id, prof.trust_bonus)) + if prof: + key = prof.id + if key not in contributions_by_id.keys(): + contributions_by_id[key] = [] + contributions_by_id[key].append(c) + contributing_profile_ids.append((prof.id, prof.trust_bonus)) contributing_profile_ids = list(set(contributing_profile_ids)) diff --git a/app/grants/views.py b/app/grants/views.py index be2a32ca137..1779727fdd0 100644 --- a/app/grants/views.py +++ b/app/grants/views.py @@ -3267,6 +3267,12 @@ def ingest_contributions(request): message = request.POST.get('message') network = request.POST.get('network') ingestion_types = [] # after each series of ingestion, we append the ingestion_method to this array + handle = request.POST.get('handle') + + if (profile.is_staff and + ( not handle or Profile.objects.filter(handle=handle).count() == 0) + ): + return JsonResponse({ 'success': False, 'message': 'Profile could not be found' }) # Setup web3 w3 = get_web3(network) @@ -3291,12 +3297,15 @@ def verify_signature(signature, message, expected_address): if recovered_address.lower() != expected_address.lower(): raise Exception("Signature could not be verified") - if txHash != '': - receipt = w3.eth.getTransactionReceipt(txHash) - from_address = receipt['from'] - verify_signature(signature, message, from_address) - if userAddress != '': - verify_signature(signature, message, userAddress) + try: + if txHash != '': + receipt = w3.eth.getTransactionReceipt(txHash) + from_address = receipt['from'] + verify_signature(signature, message, from_address) + if userAddress != '': + verify_signature(signature, message, userAddress) + except: + return JsonResponse({ 'success': False, 'message': 'Signature could not be verified' }) def get_token(w3, network, address): if (address == '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE'):