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 Nov 17, 2020
2 parents e91dea5 + 03177b6 commit 675162e
Show file tree
Hide file tree
Showing 8 changed files with 139 additions and 52 deletions.
5 changes: 5 additions & 0 deletions app/assets/v2/js/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ Vue.component('grants-cart', {
data: function() {
return {
// Checkout, shared
selectedZcashPayment: 'taddress',
optionsZcashPayment: [
{ text: 'Wallet t-address', value: 'taddress' },
{ text: 'Transaction Hash', value: 'txid' }
],
chainId: '',
network: 'mainnet',
tabSelected: 'ETH',
Expand Down
93 changes: 72 additions & 21 deletions app/grants/sync/zcash.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@


def find_txn_on_zcash_explorer(contribution):

subscription = contribution.subscription
grant = subscription.grant
token_symbol = subscription.token_symbol
Expand All @@ -27,17 +28,27 @@ def find_txn_on_zcash_explorer(contribution):
# Check contributors txn history
if response['status'] == 'success' and response['data'] and response['data']['txs']:
txns = response['data']['txs']

for txn in txns:
if txn.get('outgoing') and txn['outgoing']['outputs']:
for output in txn['outgoing']['outputs']:
if (
output['address'] == to_address and
response['data']['address'] == from_address and
float(output['value']) == float(amount) and
is_txn_done_recently(txn['time']) and
not txn_already_used(txn['txid'], token_symbol)
):
return txn['txid']
if contribution.tx_id and contribution.tx_id != '0x0':
if txn['txid'] == contribution.tx_id:
if (
output['address'] == to_address and
float(output['value']) == float(amount) and
is_txn_done_recently(txn['time'])
):
return txn['txid']
else:
if (
output['address'] == to_address and
response['data']['address'] == from_address and
float(output['value']) == float(amount) and
is_txn_done_recently(txn['time']) and
not txn_already_used(txn['txid'], token_symbol)
):
return txn['txid']


url = f'https://sochain.com/api/v2/address/ZEC/{to_address}'
Expand All @@ -59,7 +70,7 @@ def find_txn_on_zcash_explorer(contribution):
return None


def get_zcash_txn_status(txnid):
def is_zcash_txn_successful(txnid):
if not txnid:
return None

Expand Down Expand Up @@ -90,18 +101,58 @@ def is_txn_done_recently(time_of_txn):
return False


def is_valid_zcash_txn(contribution):

subscription = contribution.subscription
grant = subscription.grant

txn_id = contribution.tx_id
to_address = grant.zcash_payout_address
amount = subscription.amount_per_period
token_symbol = subscription.token_symbol


if not txn_id or txn_id == '0x0':
return None

url = f'https://sochain.com/api/v2/tx/ZEC/{txn_id}'

response = requests.get(url).json()

if (
response['status'] == 'success' and
response['data'] and
response['data']['outputs']
):
for txn in response['data']['outputs']:
if (
txn['address'] == to_address and
float(txn['value']) == float(amount) and
is_txn_done_recently(response['data']['time']) and
not txn_already_used(txn_id, token_symbol)
):
return True

return None


def sync_zcash_payout(contribution):
# if not contribution.tx_id:
txn = find_txn_on_zcash_explorer(contribution)
if txn:
contribution.tx_id = txn
contribution.save()
is_sucessfull_txn = False

# if contribution.tx_id:
is_sucessfull_txn = get_zcash_txn_status(contribution.tx_id)
if is_sucessfull_txn:
contribution.success = True
contribution.tx_cleared = True
contribution.checkout_type = 'zcash_std'
record_contribution_activity(contribution)
if not contribution.tx_id or contribution.tx_id == '0x0':
# user entered t-addr.
txn = find_txn_on_zcash_explorer(contribution)
if txn:
contribution.tx_id = txn
contribution.save()
is_sucessfull_txn = is_zcash_txn_successful(contribution.tx_id)
else:
# user entered txn-id or txn-id picked up by cron.
is_sucessfull_txn = is_valid_zcash_txn(contribution)

if is_sucessfull_txn:
contribution.success = True
contribution.tx_cleared = True
contribution.checkout_type = 'zcash_std'
record_contribution_activity(contribution)
contribution.save()
26 changes: 16 additions & 10 deletions app/grants/templates/grants/cart-vue.html
Original file line number Diff line number Diff line change
Expand Up @@ -533,22 +533,28 @@ <h1 class="col-auto text-left font-bigger-2 black" style="font-weight: bold; mar
</div>
</div>
<div class="bg-white rounded col ml-2 py-3 d-flex flex-column mt-4">
<p class="font-body"><span class="underline">Step 2</span>: Copy and paste your <b>Contributor Address</b> below, and press the confirm button.</p>
<div class="form-row align-items-end">
<!-- <div class="col">
<p class="font-body"><span class="underline">Step 2</span>: Choose between <b>t-address</b> or <b>transaction hash</b> and press the confirm button.</p>

<b-form-radio-group id="radio-slots" v-model="selectedZcashPayment" :options="optionsZcashPayment" name="radio-options-slots">
</b-form-radio-group>

<div class="form-row align-items-center mt-3">
<div class="col" v-show="selectedZcashPayment === 'txid'">
<div class="">
<label :for="`payoutTxId_${grant.grant_id}`" class="font-smaller-1">Transaction Hash:</label>
<input v-model="grant.payoutTxId" :name="`payoutTxId_${grant.grant_id}`" :id="`payoutTxId_${grant.grant_id}`" placeholder="00000..." class="form-control form-control-sm" pattern="[a-zA-Z0-9]{64}$">
<input v-model="grant.payoutTxId" :name="`payoutTxId_${grant.grant_id}`" :id="`payoutTxId_${grant.grant_id}`" placeholder="00000..." class="form-control form-control-sm" pattern="[a-zA-Z0-9]{64}$" :disabled="grant.success">
<small class="form-text text-muted">Paste the transaction id</small>
</div>
</div> -->
<div class="col">
</div>
<div class="col" v-show="selectedZcashPayment === 'taddress'">
<div class="">
<label :for="`contributor_address_${grant.grant_id}`" class="font-smaller-1">Contributor Address:</label>
<input v-model="grant.contributor_address" :name="`contributor_address_${grant.grant_id}`" :id="`contributor_address_${grant.grant_id}`" placeholder="00000..." class="form-control form-control-sm" pattern="^t1[a-zA-Z0-9]{33}$">
<label :for="`contributor_address_${grant.grant_id}`" class="font-smaller-1">Your T-address:</label>
<input v-model="grant.contributor_address" :name="`contributor_address_${grant.grant_id}`" :id="`contributor_address_${grant.grant_id}`" placeholder="t00000..." class="form-control form-control-sm" pattern="^t1[a-zA-Z0-9]{33}$" :disabled="grant.success">
<small class="form-text text-muted">Only t-address are allowed (no z-address support)</small>
</div>
</div>
<div class="">
<button type="submit" class="btn btn-sm btn-gc-blue" :disabled="!grant.contributor_address || grant.loading || grant.success">Confirm</button>
<div class="mt-2">
<button type="submit" class="btn btn-sm btn-gc-blue" :disabled="(selectedZcashPayment === 'taddress' ? !grant.contributor_address : !grant.payoutTxId ) || grant.loading || grant.success">Confirm</button>
</div>
</div>
<div v-if="grant.error" class="font-body text-danger">[[grant.error]]</div>
Expand Down
9 changes: 7 additions & 2 deletions app/grants/templates/grants/transaction.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,13 @@
</div>
</div>
<div class="col-1 my-auto tags font-caption">
{% if not transaction.tx_cleared %} <BR>(Pending) {% endif %}
{% if not transaction.success %} <BR>(Failed) {% endif %}
<span>
{% if not transaction.success %}
( Failed )
{% elif not transaction.tx_cleared %}
( Pending )
{% endif %}
</span>
</div>
{% if not transaction.subscription.contributor_profile.hide_wallet_address %}
<div class="d-none d-md-block col-md-2 font-body my-auto txn-link">
Expand Down
15 changes: 4 additions & 11 deletions app/grants/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2719,21 +2719,15 @@ def contribute_to_grants_v1(request):
continue

contributor_address = contribution.get('contributor_address', None)
if not contributor_address:
tx_id = contribution.get('tx_id', None)

if not contributor_address and not tx_id:
invalid_contributions.append({
'grant_id': grant_id,
'message': 'error: contributor_address is mandatory param'
'message': 'error: either contributor_address or tx_id must be supplied'
})
continue

# tx_id = contribution.get('tx_id', None)
# if not tx_id:
# invalid_contributions.append({
# 'grant_id': grant_id,
# 'message': 'error: tx_id is mandatory param'
# })
# continue

token_symbol = contribution.get('token_symbol', None)
if not token_symbol:
invalid_contributions.append({
Expand Down Expand Up @@ -2765,7 +2759,6 @@ def contribute_to_grants_v1(request):
})
continue

tx_id = contribution.get('tx_id', None)
comment = contribution.get('comment', '')
network = grant.network
hide_wallet_address = contribution.get('hide_wallet_address', None)
Expand Down
12 changes: 6 additions & 6 deletions app/ptokens/templates/buy_a_token.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ <h1 class="font-title">{%trans "Buy a Token" %}</h1>
{%trans "With personal tokens, you can buy a stake of someone's future work potential today." %} <br>
</p>

<h1 class="font-title">{%trans "Reserve an Expert" %}</h1>
<h1 class="font-title">{%trans "Get Specialist's Attention" %}</h1>
<p class="my-3">
{%trans "Eager to work with a top-tier user but not sure what you’ll need them for?" %} <br>
{%trans "Eager to work with a top tier contributor?" %} <br>
</p>
<p class="my-3">
{%trans "Snagging their personal token secures their attention for your next project." %} <br>
{%trans "Securing their personal token opens the opportunity for future work if your request is accepted." %} <br>
</p>

<h1 class="font-title">{%trans "Support a Creator" %}</h1>
Expand Down Expand Up @@ -140,12 +140,12 @@ <h1 class="font-title">{%trans "Get Paid Today for Work Tomorrow" %}</h1>
{%trans "Customize your skillset to match where you excel." %} <br>
</p>

<h1 class="font-title">{%trans "Control Your Worth" %}</h1>
<h1 class="font-title">{%trans "Boost Your Reliability" %}</h1>
<p class="my-3">
{%trans "Determine your own rates and keep 100% of the profits." %} <br>
{%trans "Show funders that you can be trusted to complete specialized tasks." %} <br>
</p>
<p class="my-3">
{%trans "Change your costs to respond to trends and client demand." %} <br>
{%trans "Successfully completing redemptions boosts your ability to receive future work." %} <br>
</p>

<h1 class="font-title">{%trans "Solidify Your Reputation" %}</h1>
Expand Down
3 changes: 1 addition & 2 deletions app/ptokens/templates/personal_tokens.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<div class="col-12 col-md-12 px-md-0">
<h1 class="font-title">{%trans "Why Personal Tokens?" %}</h1>
<p class="my-4">
{%trans "As a freelancer, personal tokens allow you to sell your reputation by borrowing against future work. Issue personal tokens and receive DAI today for work to be performed tomorrow." %} <br>
{%trans "As a freelancer, personal tokens enable pre-payment for future tasks or services. Issue personal tokens and receive DAI today for work to be performed tomorrow." %} <br>
</p>
<p class="my-4">
{%trans "Looking to secure top-tier talent for your next project? Buy a personal token and redeem it for predefined uses from industry-leading professionals before they get booked up." %} <br>
Expand All @@ -79,7 +79,6 @@ <h2 class="font-title">{%trans "What Are Personal Tokens?" %}</h2>
<p>- {%trans "Tokenized IOUs for Gitcoin users time" %}</p>
<p>- {%trans "Used to redeem specialized skills" %}</p>
<p>- {%trans "Unique to each account" %}</p>
<p>- {%trans "Highly reputation based" %}</p>
</div>
<p class="my-3">{%trans "Curious to learn more? Dive in!" %}</p>
<a class="btn btn-gc-blue" href="{% url "ptokens_faq" %}">{%trans "Quick Start" %}</a>
Expand Down
28 changes: 28 additions & 0 deletions scripts/debug/output_weekly_mailing_list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
f = open("output.csv", "w")
import time

from marketing.models import EmailSubscriber
from marketing.utils import func_name, get_or_save_email_subscriber, should_suppress_notification_email

queryset = EmailSubscriber.objects.all()
count = queryset.count()
counter = 0
start_time = time.time()

for email in queryset:
counter += 1
to_email = email.email
f_name = ''
if email.profile:
f_name = email.profile.data.get('name')
if not f_name:
f_name = ''

if not should_suppress_notification_email(to_email, 'roundup'):
pct_done = (round(counter / count, 2) * 100)
if counter % 100 == 0:
speed = counter / (time.time() - start_time)
eta = count / speed
print(f"{pct_done}% - {counter}/{count} ({round(speed, 1)}/s, eta:{round(eta,1)}s)")
f.write(f"\"{f_name}\", \",\", \"{to_email}\"\n")
f.close()

0 comments on commit 675162e

Please sign in to comment.