Skip to content
Permalink
Browse files

eth tips working

  • Loading branch information...
owocki committed Jul 10, 2018
1 parent 77311df commit 40294511f3c12ef1d03f24d67bd0899e3eec51cb
@@ -30,6 +30,7 @@
import dashboard.helpers
import dashboard.ios
import dashboard.views
import dashboard.tip_views
import dataviz.d3_views
import dataviz.views
import enssubdomain.views
@@ -118,14 +119,14 @@
url(r'^funding/details/?', dashboard.views.bounty_details, name='funding_details'),

# Tips
url(r'^tip/receive/v2/(?P<pk>.*)/(?P<txid>.*)/(?P<network>.*)?', dashboard.views.receive_tip_v2, name='receive_tip'),
url(r'^tip/receive/?', dashboard.views.receive_tip_legacy, name='receive_tip_legacy'),
url(r'^tip/send/4/?', dashboard.views.send_tip_4, name='send_tip_4'),
url(r'^tip/send/3/?', dashboard.views.send_tip_3, name='send_tip_3'),
url(r'^tip/send/2/?', dashboard.views.send_tip_2, name='send_tip_2'),
url(r'^tip/send/?', dashboard.views.send_tip, name='send_tip'),
url(r'^send/?', dashboard.views.send_tip, name='tip'),
url(r'^tip/?', dashboard.views.send_tip, name='tip'),
url(r'^tip/receive/v2/(?P<pk>.*)/(?P<txid>.*)/(?P<network>.*)?', dashboard.tip_views.receive_tip_v2, name='receive_tip'),
url(r'^tip/receive/?', dashboard.tip_views.receive_tip_legacy, name='receive_tip_legacy'),
url(r'^tip/send/4/?', dashboard.tip_views.send_tip_4, name='send_tip_4'),
url(r'^tip/send/3/?', dashboard.tip_views.send_tip_3, name='send_tip_3'),
url(r'^tip/send/2/?', dashboard.tip_views.send_tip_2, name='send_tip_2'),
url(r'^tip/send/?', dashboard.tip_views.send_tip, name='send_tip'),
url(r'^send/?', dashboard.tip_views.send_tip, name='tip'),
url(r'^tip/?', dashboard.tip_views.send_tip, name='tip'),

# Legal
url(r'^terms/?', dashboard.views.terms, name='_terms'),

This file was deleted.

@@ -0,0 +1,9 @@
/* eslint-disable no-console */
window.onload = function() {
waitforWeb3(function() {
if(document.web3network != document.network){
_alert({ message: gettext("You are not on the right web3 network. Please switch to ") + document.network }, 'error');
}
$("#network").val(document.web3network);
})
};
@@ -0,0 +1,2 @@
import json
erc20_abi = json.loads('[{"constant":true,"inputs":[],"name":"mintingFinished","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"}],"name":"mint","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"version","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_subtractedValue","type":"uint256"}],"name":"decreaseApproval","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"finishMinting","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_addedValue","type":"uint256"}],"name":"increaseApproval","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"payable":false,"stateMutability":"nonpayable","type":"fallback"},{"anonymous":false,"inputs":[{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"amount","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[],"name":"MintFinished","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"},{"indexed":true,"name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"}]')
@@ -113,7 +113,7 @@ def format_tip(self, tip):
'type': 'tip',
'created_on': tip.created_on,
'last_activity': tip.modified_on,
'amount': tip.get_natural_value() * 10**18,
'amount': tip.amount_in_whole_units,
'denomination': tip.tokenName,
'amount_eth': tip.value_in_eth,
'amount_usdt': tip.value_in_usdt,
@@ -893,6 +893,24 @@ def get_natural_value(self):
def value_true(self):
return self.get_natural_value()

@property
def amount_in_wei(self):
return float(self.amount)

@property
def amount_in_whole_units(self):
return float(self.get_natural_value())

@property
def amount_in_wei(self):

This comment has been minimized.

Copy link
@mbeacom

mbeacom Jul 21, 2018

Contributor

@owocki Which of these methods do we want to use here? Looks like we're redefining amount_in_wei and amount_in_whole_units - the last two?

This comment has been minimized.

Copy link
@owocki

owocki Jul 23, 2018

Author Member

probably amount_in_whole_units since wei is an ETH specific unit of account

token = addr_to_token(self.tokenAddress)
decimals = token['decimals']
return float(self.amount) * 10**decimals

@property
def amount_in_whole_units(self):
return float(self.amount)

@property
def receive_url(self):
if self.web3_type == 'yge':
@@ -89,5 +89,6 @@
}, 1000);
</script>
{% endif %}
{% include 'shared/messages.html' %}
</body>
</html>
@@ -17,17 +17,9 @@
{% endcomment %}
{% load i18n static %}
{% block 'scripts' %}
<script src="{% static "onepager/js/quarantine/ethereumjs-accounts.js" %}"></script>
<script src="{% static "onepager/js/quarantine/web3.js" %}"></script>
<script src="{% static "onepager/js/quarantine/hooked-web3-provider.js" %}"></script>
<script src="{% static "onepager/js/quarantine/tx.js" %}"></script>
<script src="{% static "onepager/js/quarantine/index.js" %}"></script>
<script src="{% static "onepager/js/quarantine/tokens.js" %}"></script>
<script src="{% static "onepager/js/quarantine/pre.js" %}"></script>
<script src="{% static "onepager/js/quarantine/receive.js" %}"></script>
<script src="{% static "onepager/js/quarantine/confetti.js" %}"></script>
<script src="{% static "onepager/js/quarantine/web3alert.js" %}"></script>
<script src="{% static "onepager/js/quarantine/lightwallet.min.js" %}"></script>
<script src="{% static "v2/js/shared.js" %}"></script>
<script src="{% static "onepager/js/receive.js" %}"></script>
<script src="{% static "onepager/js/confetti.js" %}"></script>

{% endblock %}
<!-- Main -->
@@ -43,47 +35,35 @@
</a>
</span>
</header>
<div id="loading">
<h1>{% trans "Loading" %}</h1>
<img src="{% static "onepager/images/loading.gif" %}" style="max-width: 70px; max-height: 70px;">
<p id="loading_txt">{% trans "waiting for web3..." %}</p>
<div id="receove_eth" {% if tip.receive_txid %} style="display:none;" {%endif%} >
<form method="POST">
<h1 id="oneh1">{% trans "You've got" %} {{tip.amount}} {{tip.tokenName}} </h1>
<div>
{% trans "Forward it to a permanent address:" %}
<br>
<input type="hidden" name="network" id="network" value="">
<input type="text" name="forwarding_address" id="forwarding_address" placeholder="0x0" {% if disable_inputs %}disabled=disabled{%endif%}>
</div>
<div>
<br>
<input id="receive" type='submit' class="button button--primary" value="{% trans "Claim" %} {{tip.tokenName}} 🙌" {% if disable_inputs %}disabled=disabled{%endif%} >
<br>
</div>
</form>
</div>
<div id="step_zero" style="display:none;">
<h1 id="zeroh1">{% trans "You've Got ETH!" %}</h1>
<p>{% trans "To claim it, please install MetaMask and refresh the page." %}</p>
<a href="https://metamask.io/?utm_source=gitcoin.co&utm_medium=referral" id="install" class="button button--primary">{% trans "Install Metamask" %} <span class="emoji">🐬</span></a>
<br>
<br>
<h2>{% trans "What is Metamask?" %}</h2>
<iframe width="100%" src="https://www.youtube.com/embed/6Gf_kRE4MJU" frameborder="0" allowfullscreen></iframe>
</div>
<div id="send_eth" style="display:none;">
<h1 id="oneh1">{% trans "Receive Ethereum Now." %}</h1>
<div>
<input type="hidden" placeholder="idx_address" id="idx_address" value="">
</div>
<div>
<input type="hidden" placeholder="private_key" id="private_key" value="">
</div>
<div>
{% trans "Forward it to a permanent address:" %}
<br>
<input type="text" placeholder="forwarding_address" id="forwarding_address" value="0x0">
</div>
<div>
<br>
<a href="#" id="receive" class="button button--primary">{% trans "Claim" %} <span id="tokenName">Eth</span> {% trans "Tip" %} <span class="emoji">🙌</span></a>
<br>
</div>
</div>
<div id="send_eth_done" style="display:none;">
<div id="receove_eth_done" {% if not tip.receive_txid %} style="display:none;" {%endif%}>
<h1>{% trans "Congrats!" %}</h1>
<p>{% blocktrans %}You've received Ethereum via transaction <span id="trans_id"></span>.{% endblocktrans %}</p>
<p>You've received {{tip.amount}} {{tip.tokenName}} via transaction <span id="trans_id">{{tip.receive_txid}}</span>.</p>
</div>
{% if tip.receive_txid and not disable_inputs %}
<script>
setTimeout(function(){
startConfetti();
}, 1000);
</script>
{% endif %}
</section>
<script>
document.pk = '{{tip.metadata.priv_key}}';
document.txid = '{{tip.txid}}';
document.network = '{{tip.network}}';
</script>
{% endblock %}

0 comments on commit 4029451

Please sign in to comment.
You can’t perform that action at this time.