Skip to content

Commit 05eb0cf

Browse files
authored
deploy cleanup (#9509)
* fix standard checkout * handle ganache * handle matic neglible amount * fix * bump * comment * fix tips
1 parent 9932e43 commit 05eb0cf

5 files changed

Lines changed: 42 additions & 6 deletions

File tree

app/assets/v2/js/cart-ethereum-polygon.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,11 +349,15 @@ Vue.component('grantsCartEthereumPolygon', {
349349
*/
350350

351351
let networkId = appCart.$refs.cart.networkId;
352-
353-
if (networkId !== '80001' && networkId !== '137' && appCart.$refs.cart.chainId !== '1' || this.cart.unsupportedTokens.length > 0) {
352+
353+
if (networkId !== '80001' && networkId !== '137' && appCart.$refs.cart.standardCheckoutInitiated == true) {
354354
return;
355355
}
356356

357+
if (this.cart.unsupportedTokens.length > 0) {
358+
return;
359+
}
360+
357361
let gasLimit = 0;
358362

359363
// If user has enough balance within Polygon, cost equals the minimum amount
@@ -468,6 +472,10 @@ Vue.component('grantsCartEthereumPolygon', {
468472
web3.utils.fromWei((gasFeeInWei - userMaticBalance).toString(), 'ether')
469473
).toFixed(5));
470474

475+
if (requiredAmount < 0.01) {
476+
requiredAmount = 0.01; // approximate neglible gas fees to a reasonable minimum
477+
}
478+
471479
if (requiredAmounts['MATIC']) {
472480
requiredAmounts['MATIC'].amount += requiredAmount;
473481
} else {

app/assets/v2/js/cart.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -853,9 +853,10 @@ Vue.component('grants-cart', {
853853
return await onConnect();
854854
}
855855

856-
let supportedTestnets = [ 'rinkeby', 'goerli', 'kovan', 'ropsten' ];
856+
let networkId = String(Number(web3.eth.currentProvider.chainId));
857+
let networkName = getDataChains(networkId, 'chainId')[0] && getDataChains(networkId, 'chainId')[0].network;
857858

858-
if (!supportedTestnets.includes(networkName) || this.networkId !== '1') {
859+
if (networkName == 'mainnet' && networkId !== '1') {
859860
// User MetaMask must be connected to Ethereum mainnet or a supported testnet
860861
try {
861862
await ethereum.request({
@@ -1035,9 +1036,17 @@ Vue.component('grants-cart', {
10351036
}
10361037
},
10371038

1039+
resetNetwork() {
1040+
if (this.nativeCurrency == 'MATIC') {
1041+
this.network = this.network == 'testnet' ? 'rinkeby' : 'mainnet';
1042+
this.networkId = this.networkId == '80001' ? '4' : '1';
1043+
}
1044+
},
1045+
10381046
// Standard L1 checkout flow
10391047
async standardCheckout() {
10401048
this.standardCheckoutInitiated = true;
1049+
this.resetNetwork();
10411050

10421051
try {
10431052
// Setup -----------------------------------------------------------------------------------

app/assets/v2/js/pages/hackathon_new_bounty.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Vue.mixin({
1818
}
1919

2020
let ghIssueUrl;
21+
2122
try {
2223
ghIssueUrl = new URL(url);
2324
} catch (e) {

app/git/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,8 @@ def get_github_event_emails(oauth_token, username):
252252
253253
"""
254254
emails = []
255-
userinfo = get_user(username)
256-
user_name = userinfo.name
255+
userinfo = get_user(username, oauth_token)
256+
user_name = userinfo.name if userinfo else None
257257

258258
try:
259259
gh_client = github_connect(oauth_token)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 2.2.24 on 2021-09-22 17:31
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('grants', '0123_auto_20210726_0703'),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name='contribution',
15+
name='checkout_type',
16+
field=models.CharField(blank=True, choices=[('eth_std', 'eth_std'), ('eth_zksync', 'eth_zksync'), ('eth_polygon', 'eth_polygon'), ('zcash_std', 'zcash_std'), ('celo_std', 'celo_std'), ('zil_std', 'zil_std'), ('polkadot_std', 'polkadot_std'), ('harmony_std', 'harmony_std'), ('binance_std', 'binance_std'), ('rsk_std', 'rsk_std'), ('algorand_std', 'algorand_std')], help_text='The checkout method used while making the contribution', max_length=30, null=True),
17+
),
18+
]

0 commit comments

Comments
 (0)