From fa17dfad40aa6bf7315cc304ee6e572127a6344d Mon Sep 17 00:00:00 2001 From: Chibuotu Amadi Date: Tue, 7 Sep 2021 15:38:02 +0100 Subject: [PATCH] polygon behind staff flag --- app/assets/v2/js/cart-ethereum-polygon.js | 60 +---------------------- app/grants/templates/grants/cart/eth.html | 6 ++- 2 files changed, 6 insertions(+), 60 deletions(-) diff --git a/app/assets/v2/js/cart-ethereum-polygon.js b/app/assets/v2/js/cart-ethereum-polygon.js index 5e29b3d72dc..822f968cfe5 100644 --- a/app/assets/v2/js/cart-ethereum-polygon.js +++ b/app/assets/v2/js/cart-ethereum-polygon.js @@ -337,66 +337,8 @@ Vue.component('grantsCartEthereumPolygon', { // The below heuristics are used instead of `estimateGas()` so we can send the donation // transaction before the approval txs are confirmed, because if the approval txs // are not confirmed then estimateGas will fail. - let networkId = appCart.$refs.cart.networkId; - if (networkId !== '80001' && networkId !== '137' && appCart.$refs.cart.chainId !== '1') { - return; - } - - let gasLimit = 0; - - // If user has enough balance within Polygon, cost equals the minimum amount - let { isBalanceSufficient, requiredAmounts } = await this.hasEnoughBalanceInPolygon(); - - if (!isBalanceSufficient) { - // If we're here, user needs at least one L1 deposit, so let's calculate the total cost - requiredAmounts = objectMap(requiredAmounts, value => { - if (value.isBalanceSufficient == false) { - return value.amount; - } - }); - - for (const tokenSymbol in requiredAmounts) { - if (tokenSymbol === 'ETH') { - gasLimit += 94659; // add ~94.66k gas for ETH deposits - } else { - gasLimit += 103000; // add 103k gas for token deposits - } - } - } - - // If we have a cart where all donations are in Dai, we use a linear regression to - // estimate gas costs based on real checkout transaction data, and add a 50% margin - const donationCurrencies = this.donationInputs.map(donation => donation.token); - const daiAddress = this.getTokenByName('DAI')?.addr; - const isAllDai = donationCurrencies.every((addr) => addr === daiAddress); - - if (isAllDai) { - if (donationCurrencies.length === 1) { - // Special case since we overestimate here otherwise - return gasLimit + 65000; - } - // https://github.com/mds1/Gitcoin-Checkout-Gas-Analysis - return gasLimit + 10000 * donationCurrencies.length + 45000; - } - - /** - * Otherwise, based on contract tests, we use the more conservative heuristic below to get - * a gas estimate. The estimates used here are based on testing the cost of a single - * donation (i.e. one item in the cart). Because gas prices go down with batched - * transactions, whereas this assumes they're constant, this gives us a conservative estimate - */ - gasLimit += this.donationInputs.reduce((accumulator, currentValue) => { - // const tokenAddr = currentValue.token?.toLowerCase(); - - if (currentValue.token === MATIC_ADDRESS) { - return accumulator + 25000; // MATIC donation gas estimate - } - - return accumulator + 70000; // generic token donation gas estimate - }, 0); - - return gasLimit; + return 70000; }, // Returns true if user has enough balance within Polygon to avoid L1 deposit, false otherwise diff --git a/app/grants/templates/grants/cart/eth.html b/app/grants/templates/grants/cart/eth.html index 5de238b46a4..e49b51a60d6 100644 --- a/app/grants/templates/grants/cart/eth.html +++ b/app/grants/templates/grants/cart/eth.html @@ -152,9 +152,11 @@

Summary

zkSync checkout not supported due to [[ zkSyncUnsupportedTokens.join(', ') ]]
+ {% if is_staff %}
Polygon checkout not supported due to [[ polygonUnsupportedTokens.join(', ') ]]
+ {% endif %}
💡 Save ~[[ checkoutRecommendation.savingsInPercent ]]% @@ -166,7 +168,8 @@

Summary

- + + {% if is_staff %} Having issues with depositing funds to Polygon (Matic
+ {% endif %}