Skip to content

Commit

Permalink
resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
thelostone-mc committed Sep 21, 2020
2 parents 9eb31fc + 487d709 commit fbdb456
Show file tree
Hide file tree
Showing 40 changed files with 512 additions and 114 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
# Download and cache dependencies
- restore_cache:
keys:
- deps37-{{ .Branch }}-{{ checksum "requirements/base.txt" }}-alpine
- deps37-{{ .Branch }}-{{ checksum "requirements/ci.txt" }}-alpine
# fallback to using the latest cache if no exact match is found
- deps37-{{ .Branch }}-alpine

Expand All @@ -52,7 +52,7 @@ jobs:
echo "Requirements installed!"
- save_cache:
key: deps37-{{ .Branch }}-{{ checksum "requirements/base.txt" }}-alpine
key: deps37-{{ .Branch }}-{{ checksum "requirements/ci.txt" }}-alpine
paths:
- ./venv
- "/usr/local/bin"
Expand Down
4 changes: 2 additions & 2 deletions app/app/templates/search/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<link rel="stylesheet" href={% static "v2/css/users.css" %} />
<link rel="stylesheet" href={% static "v2/css/tag.css" %} />
<link rel="stylesheet" href={% static "v2/css/rating.css" %} />
<link rel="stylesheet" href="https://unpkg.com/vue-innersearch/default-innersearch-theme.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/vue-innersearch@0.0.12/default-innersearch-theme.min.css">
</head>

<body id="{{ explore }}" class="interior {{active}} g-font-muli">
Expand Down Expand Up @@ -156,7 +156,7 @@ <h3 class="is-nlf-title">Number of Hacks Joined : </h3>
{% include 'shared/analytics.html' %}
{% include 'shared/footer_scripts.html' %}
{% include 'shared/footer.html' %}
<script src="https://unpkg.com/[email protected]/vue-innersearch.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/innersearch.min.js"></script>


<script>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
74 changes: 44 additions & 30 deletions app/assets/v2/js/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Vue.component('grants-cart', {
maxPossibleSignatures: 4, // for Flow A, start by assuming 4 -- two logins, set signing key, one transfer
isZkSyncModalLoading: false, // modal requires async actions before loading, so show loading spinner to improve UX
zkSyncWalletState: undefined, // state of user's nominal zkSync wallet
selectedNetwork: undefined, // use to force computed properties to update when document.web3network changes
// SMS validation
csrf: $("input[name='csrfmiddlewaretoken']").val(),
validationStep: 'intro',
Expand Down Expand Up @@ -313,26 +314,28 @@ Vue.component('grants-cart', {
zkSyncBlockExplorerUrl() {
// Flow A, zkScan link
if (this.hasSufficientZkSyncBalance) {
if (document.web3network === 'rinkeby')
return `https://${document.web3network}.zkscan.io/explorer/accounts/${this.userAddress}`;
if (this.selectedNetwork === 'rinkeby')
return `https://${this.selectedNetwork}.zkscan.io/explorer/accounts/${this.userAddress}`;
return `https://zkscan.io/explorer/accounts/${this.userAddress}`;
}

// Flow B, etherscan link
if (!this.zkSyncDepositTxHash)
return undefined;
if (document.web3network === 'rinkeby')
return `https://${document.web3network}.etherscan.io/tx/${this.zkSyncDepositTxHash}`;
if (this.selectedNetwork === 'rinkeby')
return `https://${this.selectedNetwork}.etherscan.io/tx/${this.zkSyncDepositTxHash}`;
return `https://etherscan.io/tx/${this.zkSyncDepositTxHash}`;
},

// Array of supported tokens
zkSyncSupportedTokens() {
if (!document.web3network)
return [];
if (document.web3network === 'rinkeby')
const mainnetTokens = [ 'ETH', 'DAI', 'USDC', 'USDT', 'LINK', 'WBTC', 'PAN', 'SNT' ];

if (!this.selectedNetwork)
return mainnetTokens;
if (this.selectedNetwork === 'rinkeby')
return [ 'ETH', 'USDT', 'LINK' ];
return [ 'ETH', 'DAI', 'USDC', 'USDT', 'LINK', 'WBTC', 'PAN' ];
return mainnetTokens;
},

// Estimated gas limit for zkSync checkout
Expand Down Expand Up @@ -445,6 +448,8 @@ Vue.component('grants-cart', {
},

methods: {
// TODO: SMS related methos and state should be removed and refactored into the component that
// should be shared between the cart and the Trust Bonus tab
dismissVerification() {
localStorage.setItem('dismiss-sms-validation', true);
this.showValidation = false;
Expand Down Expand Up @@ -707,7 +712,7 @@ Vue.component('grants-cart', {
let wei;

try {
wei = web3.utils.toWei(String(number));
wei = Web3.utils.toWei(String(number));
} catch (e) {
// When numbers are too small toWei fails because there's too many decimal places
wei = Math.round(number * 10 ** 18);
Expand Down Expand Up @@ -1599,7 +1604,7 @@ Vue.component('grants-cart', {
// We now need to subtract the fee from this amount, and must ensure there is
// actually enough balance left to send this transfer. Otherwise we do not have enough
// balance to cover the transfer fee

if (amount.gt(fee)) {
// Packed account balance is greater than fee, so we can proceed with transfer
const transferAmount = zksync.utils.closestPackableTransactionAmount(amount.sub(fee));
Expand All @@ -1618,7 +1623,7 @@ Vue.component('grants-cart', {
const receipt = await tx.awaitReceipt();

console.log(' ✅ Got transfer receipt', receipt);

} else {
console.log(' ❗ Remaining balance is less than the fee, skipping this transfer');
continue;
Expand Down Expand Up @@ -2109,7 +2114,7 @@ Vue.component('grants-cart', {
const tokenAmount = await this.getTotalAmountToTransfer(tokenName, tokenDonation.allowance);
const extra = this.zkSyncAdditionalDeposits.filter((x) => x.tokenSymbol === tokenName)[0];
let totalAmount;

if (!extra) {
totalAmount = tokenAmount;
} else {
Expand Down Expand Up @@ -2141,12 +2146,12 @@ Vue.component('grants-cart', {
// Check tokens
for (let i = 0; i < deposits.length; i += 1) {
const tokenAddress = deposits[i][0];

if (tokenAddress === ETH_ADDRESS) {
// Skip ETH because we check it later
continue;
}

const tokenContract = new web3.eth.Contract(token_abi, tokenAddress);
const requiredAmount = deposits[i][1];
const userTokenBalance = await tokenContract.methods.balanceOf(this.userAddress).call({from: this.userAddress});
Expand Down Expand Up @@ -2209,7 +2214,7 @@ Vue.component('grants-cart', {

const extra = this.zkSyncAdditionalDeposits.filter((x) => x.tokenSymbol === tokenDonation.tokenName)[0];
let totalAmount;

if (!extra) {
totalAmount = tokenAmount;
} else {
Expand Down Expand Up @@ -2479,26 +2484,35 @@ Vue.component('grants-cart', {
this.hasSufficientZkSyncBalance = false;

// Show user cart
this.isLoading = false;

// Check zkSync balance. Used to find which checkout option is cheaper
try {
// Setup zkSync and check balances
this.userAddress = (await web3.eth.getAccounts())[0];
await this.setupZkSync();
await this.checkZkSyncBalances();

// See if user was previously interrupted during checkout
await this.checkInterruptStatus();
if (this.zkSyncWasInterrupted) {
this.showZkSyncModal = true;
this.isLoading = false;
window.addEventListener('dataWalletReady', async(e) => {
try {
await needWalletConnection();

// Force re-render so computed properties are updated (some are dependent on
// document.web3network, and Vue cannot watch document.web3network for an update)
this.selectedNetwork = document.web3network;

// Setup zkSync and check balances
this.userAddress = (await web3.eth.getAccounts())[0];
await this.setupZkSync();
await this.checkZkSyncBalances();

// See if user was previously interrupted during checkout
await this.checkInterruptStatus();
if (this.zkSyncWasInterrupted) {
this.showZkSyncModal = true;
}
} catch (e) {
console.error(e);
}
} catch (e) {
console.error(e);
}

}, false);

// Cart is now ready
this.isLoading = false;
// this.isLoading = false;
},

beforeDestroy() {
Expand Down
Loading

0 comments on commit fbdb456

Please sign in to comment.