Skip to content

Commit 0c6859b

Browse files
thelostone-mcandroolloydowockioctavioamudanlipert
authored
stable -> master (#6910)
* Hackathon Updates - Chat/Performance/Usability updates (#6758) * Hackathon Updates - projects now public chat channels by default - new shortcode for project chat channel creation - moved projects fetch to use django rest framework - project pagination enabled * migration added for short_code * Hackathon Project Model updates - added avg rating calc method - added HackathonProjectFeedbackEntry model * ability to mark winners through the project cards * added migrations * removed reference to the FeedbackRating * updates from review * squashed migrations * fix for opening project channels * restore proper window sizes * chatSocketTest ensures that a user is connected to the chat when they try to access it through an iframe, the user is returned to the location where they initiated the chat. * removing stale file * remove base url from context * restore chat config, fix tribes-vue css * adding chatconfig to gitignore * small changes from review * add chat with team button to the project card drop down menu * restored chat config, again, fix for headers being svg in the brand now * remove generalized first-child css selector * Update index-vue.html Co-authored-by: Aditya Anand M C <[email protected]> * fixes invalid email which was causing segfault in email script https://gitcoincore.slack.com/archives/CAXQ7PT60/p1591722678433300 * make fix * footer links * web3 v1 migration and web3modal integration (#6696) * add ts tips * Menu changes * fix user cards * bounty creation * add wallet connect lib * add wallet connect 98 * rollback version * migrate kudos and tips * fix dashboard request * migrate token settings * fix profiles kudos tab * avatar purchase * avatar to mainnet * ens support * migrate faucet * ens pending * eslint fixes * Dai tips * token enable * token enable * add chains search (crosschain) * fix tokens * change bounty broken featured bounty * increse bounty migration * payout bounty * kudos cleanup unused code * bounty create erc20 fulfill and cancel migration * cleanup * wallets functions and style * fixes for missing nav changes * bad merge fix * add tooltip * ui improv * remove commented code * grant fixes * lint and visuals * authereum cdn is faster Co-authored-by: Aditya Anand M C <[email protected]> * request money restrictions and fixes * sentry errors unlogged users * fix tokens BN and request logic * adds crypto for black lives to new grant form * fix production grants wallet * fix payout * fix for https://gitcoincore.slack.com/archives/CAXQ7PT60/p1592004845498900 * create anon profiles and assign donations, save to db add donations data fix paths clean data, fix csv ingest, disable github age check update pot amount * stop clr calculation (#6848) * eslint * adds migration * recreate migration * append r to regex * updates copy * brings back the right fund.html * fix for the fbpixel code * fix GrantCart * copy * fix for https://bits.owocki.com/4gujmgkw * fix unable to add certain grants * check allowance (#6852) * add missing import * fix for redis * removes circular dependancy cc @thelostone-mc * fix for https://sentry.io/organizations/gitcoin/issues/1715509732/ * fix for verify number not working * store all profile verifications in db regardless of success * fix for twilio 401ing * make fix * fixes the tweet text" * tweet fix * remove to WEI conversion * verify phone number manual script * match amount * typo * removes leftover grants round 5.5 code * fixes #6866 * ; * fix BN calc for fee and bounty amount * updates start and end dates of round * dont request IPFS writes on pageload anymore per #6868 * fixes grant options * various fixes and improvements for grants * bigger allowance during bounty creation for erc20 * fixes the cateogry links * make fix, also re-adds grant counts to sidebar * adding saturation point non-normalization fix (#6872) Co-authored-by: frankchen07 <[email protected]> * cast to BigInt instead of String for erc20 approval * hacky hack for vivek * wrong link * one last issue * new type * comma * contract version => dead grants version * Fix select2 dropdown * fix for only a subset of grants txns being recorded, race condition where later HTTP requests dont happen" * #6871 * fix for keyword namespace collision * various debug things * moves all the contribution processing over to a task, so the backend can recevie more POSTs at once. BOO HOO for canceled http requests https://bits.owocki.com/d5uWvDZW * adds collection list to post checkout, and also share cart to cart page * make fix * whoops * Update front.html * Update clr_estimate.html * https://gitcoincore.slack.com/archives/CAXQ7PT60/p1591753635439500 * share links now include name of person who generated it, an optional title, and view counts * increases daily email number, round end time * fix state bloat issue a la https://gitcoincore.slack.com/archives/CAXFMVDGD/p1592322483246500 * rounds stats script * fixes the celerykudos job * iframe fixes * fix #6895 * makes the gitcoin grant contributions fee price aware, puts management of tx clearing in admin * gas validation * fix for https://gitcoin.co/_administrationgrants/contribution/21315/change/ * one more valuation fix * fixes recontribute email to make it good * a few more small fixes to the recontribute email * fix for admin * fix for vivek https://gitcoincore.slack.com/archives/CBDTKB59A/p1592394041161400" * fix erc20 tips Co-authored-by: Andrew Redden <[email protected]> Co-authored-by: owocki <[email protected]> Co-authored-by: Octavio Amuchástegui <[email protected]> Co-authored-by: Dan Lipert <[email protected]> Co-authored-by: frankchen07 <[email protected]> Co-authored-by: mds <[email protected]>
1 parent 6b76d0f commit 0c6859b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+2389
-1091
lines changed

app/app/services.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from django.conf import settings
44

5-
from app.settings import account_sid, auth_token
5+
from app.settings import account_sid, auth_token, verify_service
66
from redis import Redis
77
from twilio.rest import Client
88

@@ -39,10 +39,7 @@ def __create_connection(self):
3939

4040
if not TwilioService._client:
4141
TwilioService._client = Client(account_sid, auth_token)
42-
friendly_names = settings.TWILIO_FRIENDLY_NAMES
43-
friendly_name = random.choice(friendly_names)
44-
TwilioService._service = TwilioService._client.verify.services.create(friendly_name=friendly_name)
45-
redis.set(f"validation:twilio:sid", TwilioService._service.sid)
42+
TwilioService._service = TwilioService._client.verify.services(verify_service)
4643

4744
def __init__(self):
4845
self.__create_connection()
@@ -54,5 +51,4 @@ def lookups(self):
5451
@property
5552
def verify(self):
5653
redis = RedisService().redis
57-
sid = redis.get(f"validation:twilio:sid")
58-
return TwilioService._client.verify.services(sid.decode('utf-8'))
54+
return TwilioService._client.verify.services(verify_service)

app/app/settings.py

+1
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,7 @@ def callback(request):
836836

837837
account_sid = env('TWILIO_ACCOUNT_SID', default='')
838838
auth_token = env('TWILIO_AUTH_TOKEN', default='')
839+
verify_service = env('TWILIO_VERIFY_SERVICE', default='')
839840

840841
SMS_MAX_VERIFICATION_ATTEMPTS = env('SMS_MAX_VERIFICATION_ATTEMPTS', default=4)
841842
SMS_COOLDOWN_IN_MINUTES = env('SMS_COOLDOWN_IN_MINUTES', default=1)

app/app/urls.py

+1
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,7 @@
681681
url(settings.GITHUB_EVENT_HOOK_URL, gitcoinbot.views.payload, name='payload'),
682682
url(r'^impersonate/', include('impersonate.urls')),
683683
url(r'^api/v0.1/hackathon_project/set_winner/', dashboard.views.set_project_winner, name='project_winner'),
684+
url(r'^api/v0.1/hackathon_project/set_winner/', dashboard.views.set_project_winner, name='project_winner'),
684685

685686
# users
686687
url(r'^api/v0.1/user_bounties/', dashboard.views.get_user_bounties, name='get_user_bounties'),

app/assets/onepager/js/receive.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ $(document).ready(function() {
190190
} else {
191191

192192
// send ERC20
193-
var data = token_contract.methods.transfer(forwarding_address, amount_in_wei.toString()).encodeABI();
193+
var encoded_amount = new web3.utils.BN(BigInt(document.tip['amount_in_wei'])).toString();
194+
var data = token_contract.methods.transfer(forwarding_address, encoded_amount).encodeABI();
194195

195196
rawTx = {
196197
nonce: web3.utils.toHex(nonce),

app/assets/onepager/js/request.js

+31-16
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
11
$(document).ready(function() {
2-
waitforWeb3(function() {
3-
if (!$('#address').val() && web3 && web3.eth.coinbase) {
4-
$('#address').val(web3.eth.coinbase);
5-
}
6-
});
7-
82

93
$('#network').change(function(e) {
104
if ($(this).val() !== 'ETH') {
@@ -17,13 +11,13 @@ $(document).ready(function() {
1711
$('#request').on('click', function(e) {
1812
e.preventDefault();
1913
if ($(this).hasClass('disabled'))
20-
return;
14+
return false;
2115

2216
if (!$('#tos').is(':checked')) {
2317
_alert('Please accept the terms and conditions before submit.', 'warning');
24-
return;
18+
return false;
2519
}
26-
loading_button($(this));
20+
2721
// get form data
2822
const username = $('.username-search').select2('data')[0] ? $('.username-search').select2('data')[0].text : '';
2923
const amount = parseFloat($('#amount').val());
@@ -33,16 +27,30 @@ $(document).ready(function() {
3327

3428
if (!document.contxt['github_handle']) {
3529
_alert('You must be logged in to use this form', 'warning');
36-
return;
30+
return false;
31+
}
32+
33+
if (!provider) {
34+
return onConnect().then(() => {
35+
return false;
36+
});
3737
}
38+
39+
if (!username || !amount || !address) {
40+
_alert('Please fill all the fields.', 'warning');
41+
return false;
42+
}
43+
3844
if (username == document.contxt['github_handle']) {
3945
_alert('You cannot request money from yourself.', 'warning');
40-
return;
46+
return false;
4147
}
4248
if (!comments || comments.length < 5) {
4349
_alert('Please leave a comment describing why this user should send you money.', 'warning');
44-
return;
50+
return false;
4551
}
52+
loading_button($(this));
53+
4654
const tokenAddress = (
4755
($('#token').val() == '0x0') ?
4856
'0x0000000000000000000000000000000000000000'
@@ -118,7 +126,14 @@ function requestFunds(username, amount, comments, tokenAddress, tokenName, netwo
118126
});
119127
}
120128

121-
window.addEventListener('load', function() {
122-
setInterval(listen_for_web3_changes, 5000);
123-
listen_for_web3_changes();
124-
});
129+
window.addEventListener('load', async() => {
130+
if (!provider && !web3Modal.cachedProvider || provider === 'undefined') {
131+
onConnect().then(() => {
132+
$('#address').val(selectedAccount);
133+
});
134+
} else {
135+
web3Modal.on('connect', async(data) => {
136+
$('#address').val(data.selectedAddress);
137+
});
138+
}
139+
});

app/assets/onepager/js/send.js

+22-19
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
11
/* eslint-disable no-console */
2+
3+
function changeTokens() {
4+
if (document.fundRequest && document.fundRequest.token_name) {
5+
const is_token_selected = document.fundRequest.token_name;
6+
7+
$(`#token option:contains(${is_token_selected})`).attr('selected', 'selected');
8+
$('#amount').val(document.fundRequest.amount);
9+
}
10+
$('#token').select2().trigger('change');
11+
}
12+
13+
window.addEventListener('tokensReady', function(e) {
14+
changeTokens();
15+
}, false);
16+
217
var get_gas_price = function() {
318
if (typeof defaultGasPrice != 'undefined') {
419
return defaultGasPrice;
@@ -68,18 +83,21 @@ $(document).ready(function() {
6883
if (typeof userSearch != 'undefined') {
6984
userSearch('.username-search', true);
7085
}
71-
set_metadata();
7286
// jquery bindings
7387
$('#advanced_toggle').on('click', function() {
7488
advancedToggle();
7589
});
7690
$('#amount').on('keyup blur change', updateEstimate);
7791
$('#token').on('change', updateEstimate);
78-
$('#send').on('click', function(e) {
92+
$('#send').on('click', async function(e) {
7993
e.preventDefault();
8094
if ($(this).hasClass('disabled'))
8195
return;
8296
loading_button($(this));
97+
98+
if (!provider) {
99+
await onConnect();
100+
}
83101
// get form data
84102
var email = $('#email').val();
85103
var github_url = $('#issueURL').val();
@@ -139,22 +157,6 @@ $(document).ready(function() {
139157

140158
});
141159

142-
waitforWeb3(function() {
143-
tokens(document.web3network).forEach(function(ele) {
144-
if (ele && ele.addr) {
145-
const is_token_selected = $('#token').data('token') === ele.name ? ' selected' : ' ';
146-
const html = '<option value=' + ele.addr + is_token_selected + '>' + ele.name + '</option>';
147-
148-
$('#token').append(html);
149-
}
150-
});
151-
let addr = tokenNameToDetails(document.web3network, document.default_token)['addr'];
152-
153-
console.log(addr);
154-
$('#token').val(addr).select2();
155-
jQuery('#token').select2();
156-
});
157-
158160
});
159161

160162
function advancedToggle() {
@@ -175,6 +177,7 @@ function isNumeric(n) {
175177

176178

177179
function sendTip(email, github_url, from_name, username, amount, comments_public, comments_priv, from_email, accept_tos, tokenAddress, expires, success_callback, failure_callback, is_for_bounty_fulfiller, noAvailableUser) {
180+
set_metadata();
178181
if (typeof web3 == 'undefined') {
179182
_alert({ message: gettext('You must have a web3 enabled browser to do this. Please download Metamask.') }, 'warning');
180183
failure_callback();
@@ -329,7 +332,7 @@ function sendTip(email, github_url, from_name, username, amount, comments_public
329332
var send_erc20 = function() {
330333
var token_contract = new web3.eth.Contract(token_abi, tokenAddress);
331334

332-
token_contract.methods.transfer(destinationAccount, web3.utils.toHex(amountInDenom)).send({from: fromAccount}, post_send_callback);
335+
token_contract.methods.transfer(destinationAccount, new web3.utils.BN(BigInt(amountInDenom)).toString()).send({from: fromAccount}, post_send_callback);
333336
};
334337
var send_gas_money_and_erc20 = function() {
335338
_alert({ message: gettext('You will now be asked to confirm two transactions. The first is gas money, so your receipient doesnt have to pay it. The second is the actual token transfer. (note: check Metamask extension, sometimes the 2nd confirmation window doesnt popup)') }, 'info');

app/assets/v2/js/base.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ $(document).ready(function() {
1717
});
1818
}
1919

20-
applyCartMenuStyles();
20+
// TODO: MOVE TO GRANTS shared
21+
if (typeof CartData != 'undefined') {
22+
applyCartMenuStyles();
23+
}
2124

2225
$('body').on('click', '.copy_me', function() {
2326
$(this).focus();

app/assets/v2/js/cart-data.js

+30-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,27 @@ class CartData {
1313
return idList.includes(grantId);
1414
}
1515

16+
static share_url(title) {
17+
const donations = this.loadCart();
18+
let bulk_add_cart = 'https://gitcoin.co/grants/cart/bulk-add/';
19+
20+
for (let i = 0; i < donations.length; i += 1) {
21+
const donation = donations[i];
22+
23+
bulk_add_cart += String(donation['grant_id']) + ',';
24+
}
25+
26+
if (document.contxt['github_handle']) {
27+
bulk_add_cart += ':' + document.contxt['github_handle'];
28+
}
29+
30+
if (title && typeof title != 'undefined') {
31+
bulk_add_cart += ':' + encodeURI(title);
32+
}
33+
34+
return bulk_add_cart;
35+
}
36+
1637
static addToCart(grantData) {
1738
if (this.cartContainsGrantWithId(grantData.grant_id)) {
1839
return;
@@ -25,7 +46,15 @@ class CartData {
2546
network = 'mainnet';
2647
}
2748
const acceptsAllTokens = (grantData.grant_token_address === '0x0000000000000000000000000000000000000000');
28-
const accptedTokenName = tokenAddressToDetailsByNetwork(grantData.grant_token_address, network).name;
49+
50+
let accptedTokenName;
51+
52+
try {
53+
accptedTokenName = tokenAddressToDetailsByNetwork(grantData.grant_token_address, network).name;
54+
} catch (e) {
55+
// When numbers are too small toWei fails because there's too many decimal places
56+
accptedTokenName = 'DAI';
57+
}
2958

3059
if (acceptsAllTokens || 'DAI' == accptedTokenName) {
3160
grantData.grant_donation_amount = 5;

app/assets/v2/js/cart.js

+19-7
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,8 @@ Vue.component('grants-cart', {
247247

248248
if (vm.code) {
249249
const verificationRequest = fetchData('/sms/validate/', 'POST', {
250-
code: vm.code
250+
code: vm.code,
251+
phone: vm.phone
251252
}, {'X-CSRFToken': vm.csrf});
252253

253254
$.when(verificationRequest).then(response => {
@@ -337,11 +338,21 @@ Vue.component('grants-cart', {
337338
window.location.href = `${window.location.origin}/login/github/?next=/grants/cart`;
338339
},
339340

341+
confirmClearCart() {
342+
if (confirm('are you sure')) {
343+
this.clearCart();
344+
}
345+
},
346+
340347
clearCart() {
341348
CartData.setCart([]);
342349
this.grantData = [];
343350
update_cart_title();
344351
},
352+
shareCart() {
353+
_alert('Cart URL copied to clipboard', 'success', 1000);
354+
copyToClipboard(CartData.share_url());
355+
},
345356

346357
removeGrantFromCart(id) {
347358
CartData.removeIdFromCart(id);
@@ -629,14 +640,15 @@ Vue.component('grants-cart', {
629640
// Clear cart, redirect back to grants page, and show success alert
630641
localStorage.setItem('contributions_were_successful', 'true');
631642
localStorage.setItem('contributions_count', String(this.grantData.length));
632-
this.clearCart();
633643
var network = document.web3network;
634644

635-
if (network === 'rinkeby') {
636-
window.location.href = `${window.location.origin}/grants/?network=rinkeby&category=`;
637-
} else {
638-
window.location.href = `${window.location.origin}/grants`;
639-
}
645+
setTimeout(function() {
646+
if (network === 'rinkeby') {
647+
window.location.href = `${window.location.origin}/grants/?network=rinkeby&category=`;
648+
} else {
649+
window.location.href = `${window.location.origin}/grants`;
650+
}
651+
}, 1500);
640652
})
641653
.on('error', (error, receipt) => {
642654
// If the transaction was rejected by the network with a receipt, the second parameter will be the receipt.

0 commit comments

Comments
 (0)