Skip to content

Commit

Permalink
deploy cleanup (#9509)
Browse files Browse the repository at this point in the history
* fix standard checkout

* handle ganache

* handle matic neglible amount

* fix

* bump

* comment

* fix tips
  • Loading branch information
chibie authored Sep 22, 2021
1 parent 9932e43 commit 05eb0cf
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 6 deletions.
12 changes: 10 additions & 2 deletions app/assets/v2/js/cart-ethereum-polygon.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,11 +349,15 @@ Vue.component('grantsCartEthereumPolygon', {
*/

let networkId = appCart.$refs.cart.networkId;

if (networkId !== '80001' && networkId !== '137' && appCart.$refs.cart.chainId !== '1' || this.cart.unsupportedTokens.length > 0) {
if (networkId !== '80001' && networkId !== '137' && appCart.$refs.cart.standardCheckoutInitiated == true) {
return;
}

if (this.cart.unsupportedTokens.length > 0) {
return;
}

let gasLimit = 0;

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

if (requiredAmount < 0.01) {
requiredAmount = 0.01; // approximate neglible gas fees to a reasonable minimum
}

if (requiredAmounts['MATIC']) {
requiredAmounts['MATIC'].amount += requiredAmount;
} else {
Expand Down
13 changes: 11 additions & 2 deletions app/assets/v2/js/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -853,9 +853,10 @@ Vue.component('grants-cart', {
return await onConnect();
}

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

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

resetNetwork() {
if (this.nativeCurrency == 'MATIC') {
this.network = this.network == 'testnet' ? 'rinkeby' : 'mainnet';
this.networkId = this.networkId == '80001' ? '4' : '1';
}
},

// Standard L1 checkout flow
async standardCheckout() {
this.standardCheckoutInitiated = true;
this.resetNetwork();

try {
// Setup -----------------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions app/assets/v2/js/pages/hackathon_new_bounty.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Vue.mixin({
}

let ghIssueUrl;

try {
ghIssueUrl = new URL(url);
} catch (e) {
Expand Down
4 changes: 2 additions & 2 deletions app/git/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ def get_github_event_emails(oauth_token, username):
"""
emails = []
userinfo = get_user(username)
user_name = userinfo.name
userinfo = get_user(username, oauth_token)
user_name = userinfo.name if userinfo else None

try:
gh_client = github_connect(oauth_token)
Expand Down
18 changes: 18 additions & 0 deletions app/grants/migrations/0124_auto_20210922_1731.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.24 on 2021-09-22 17:31

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('grants', '0123_auto_20210726_0703'),
]

operations = [
migrations.AlterField(
model_name='contribution',
name='checkout_type',
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),
),
]

0 comments on commit 05eb0cf

Please sign in to comment.