Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/stable'
Browse files Browse the repository at this point in the history
  • Loading branch information
thelostone-mc committed Jul 1, 2021
2 parents 8a534c4 + 64d136d commit 7f9b77b
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 15 deletions.
6 changes: 5 additions & 1 deletion app/assets/v2/js/grants/ingest-missing-contributions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
8 changes: 6 additions & 2 deletions app/grants/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,9 @@ def txn_url(self, obj):
return format_html("<a href='{}' target='_blank'>{}</a>", tx_url, tx_id)

def profile(self, obj):
return format_html(f"<a href='/{obj.subscription.contributor_profile.handle}'>{obj.subscription.contributor_profile}</a>")
if obj.subscription.contributor_profile:
return format_html(f"<a href='/{obj.subscription.contributor_profile.handle}'>{obj.subscription.contributor_profile}</a>")
return None

def created_on_nt(self, obj):
return naturaltime(obj.created_on)
Expand All @@ -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"<a href={obj.subscription.grant.url}>{obj.subscription.grant.title}</a>")
Expand Down
13 changes: 7 additions & 6 deletions app/grants/clr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))

Expand Down
21 changes: 15 additions & 6 deletions app/grants/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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'):
Expand Down

0 comments on commit 7f9b77b

Please sign in to comment.