Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: proper withdrawals finalization #155

Merged
merged 1 commit into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
import { watch } from "vue";
import { useRoute } from "vue-router";

import { useZkSyncWithdrawalsStore } from "@/store/zksync/withdrawals";
import { trackPage } from "@/utils/analytics";

useZkSyncWithdrawalsStore().updateWithdrawalsIfPossible(); // init store to update withdrawals

const route = useRoute();
watch(
() => route.path,
Expand Down
32 changes: 26 additions & 6 deletions components/animations/TransactionProgress.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<template>
<div class="transaction-progress-animation" :class="{ 'transaction-completed': completed }">
<div
class="transaction-progress-animation"
:class="{ 'transaction-completed': state === 'completed', 'stopped-in-the-end': state === 'stopped-in-the-end' }"
>
<div class="no-overflow-container">
<div class="lines-inner">
<div v-for="index in 40" :key="index" class="line"></div>
Expand All @@ -23,10 +26,15 @@
<script lang="ts" setup>
import { CheckIcon } from "@heroicons/vue/24/outline";

import type { PropType } from "vue";

export type AnimationState = "playing" | "stopped-in-the-end" | "completed";

defineProps({
completed: {
type: Boolean,
default: false,
state: {
type: String as PropType<AnimationState>,
default: "playing",
required: true,
},
});
</script>
Expand All @@ -40,10 +48,10 @@ defineProps({
content: "";
}
&::before {
@apply -left-px bg-gradient-to-r;
@apply -left-px bg-gradient-to-r transition;
}
&::after {
@apply -right-px bg-gradient-to-l;
@apply -right-px bg-gradient-to-l transition;
}
&.transaction-completed {
.no-overflow-container {
Expand All @@ -58,6 +66,18 @@ defineProps({
}
}
}
&.stopped-in-the-end {
&::after {
@apply opacity-0;
}
.no-overflow-container {
.airplane {
animation: none;
left: 100%;
transform: translate(-100%, -50%);
}
}
}

.no-overflow-container {
@apply relative h-20 w-full overflow-hidden;
Expand Down
11 changes: 11 additions & 0 deletions components/common/Badge.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<template>
<div class="badge">
<slot />
</div>
</template>

<style lang="scss" scoped>
.badge {
@apply rounded-lg bg-neutral-900 px-2 text-white dark:bg-white dark:text-black;
}
</style>
27 changes: 26 additions & 1 deletion components/common/Spinner.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<template>
<svg
aria-hidden="true"
class="animate-spin fill-primary-300 text-transparent dark:fill-white"
class="spinner animate-spin text-transparent"
:class="`variant-${variant}`"
viewBox="0 0 100 101"
fill="none"
xmlns="http://www.w3.org/2000/svg"
Expand All @@ -16,3 +17,27 @@
/>
</svg>
</template>

<script lang="ts" setup>
import type { PropType } from "vue";

defineProps({
variant: String as PropType<"default" | "text-color" | "dark">,
});
</script>

<style lang="scss" scoped>
.spinner {
&.variant- {
&default {
@apply fill-primary-300 dark:fill-white;
}
&text-color {
@apply fill-neutral-950 dark:fill-white;
}
&dark {
@apply fill-neutral-950;
}
}
}
</style>
18 changes: 17 additions & 1 deletion components/header/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
<NuxtLink class="link-item" :to="{ name: 'transfers' }">
<ArrowsRightLeftIcon class="link-icon" aria-hidden="true" />
Transfers
<transition v-bind="TransitionOpacity()">
<CommonBadge v-if="withdrawalsAvailableForClaiming.length">
{{ withdrawalsAvailableForClaiming.length }}
</CommonBadge>
</transition>
</NuxtLink>
</div>
<div class="right-side">
Expand All @@ -50,6 +55,11 @@
</CommonButton>
<CommonButton class="hamburger-icon" @click="mobileMainNavigationOpened = true">
<Bars3Icon class="h-6 w-6" aria-hidden="true" />
<transition v-bind="TransitionOpacity()">
<CommonBadge v-if="withdrawalsAvailableForClaiming.length" class="action-available-badge">
{{ withdrawalsAvailableForClaiming.length }}
</CommonBadge>
</transition>
</CommonButton>
</div>
</header>
Expand All @@ -72,6 +82,7 @@ import useColorMode from "@/composables/useColorMode";

import { useRoute } from "#imports";
import { useOnboardStore } from "@/store/onboard";
import { useZkSyncWithdrawalsStore } from "@/store/zksync/withdrawals";

const route = useRoute();

Expand All @@ -82,6 +93,7 @@ const routes = {

const onboardStore = useOnboardStore();
const { isConnected } = storeToRefs(onboardStore);
const { withdrawalsAvailableForClaiming } = storeToRefs(useZkSyncWithdrawalsStore());

const mobileMainNavigationOpened = ref(false);
const mobileAccountNavigationOpened = ref(false);
Expand Down Expand Up @@ -128,7 +140,11 @@ const { selectedColorMode, switchColorMode } = useColorMode();
@apply hidden xl:block;
}
.hamburger-icon {
@apply xl:hidden;
@apply relative xl:hidden;

.action-available-badge {
@apply absolute -right-1 -top-1 lg:hidden;
}
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions components/header/MobileMainNavigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@
<ArrowsRightLeftIcon aria-hidden="true" />
</DestinationIconContainer>
</template>
<template #label>
<div class="flex items-center gap-2">
<span>Transfers</span>
<CommonBadge v-if="withdrawalsAvailableForClaiming.length">
{{ withdrawalsAvailableForClaiming.length }}
</CommonBadge>
</div>
</template>
</DestinationItem>
</CommonCardWithLineButtons>

Expand Down Expand Up @@ -106,6 +114,7 @@ import type { ZkSyncNetwork } from "@/data/networks";

import { useRoute } from "#imports";
import { useNetworkStore } from "@/store/network";
import { useZkSyncWithdrawalsStore } from "@/store/zksync/withdrawals";
import { getNetworkUrl } from "@/utils/helpers";
import { TransitionSlideOutToLeft, TransitionSlideOutToRight } from "@/utils/transitions";

Expand All @@ -122,6 +131,8 @@ const emit = defineEmits<{

const route = useRoute();

const { withdrawalsAvailableForClaiming } = storeToRefs(useZkSyncWithdrawalsStore());

const TabsTransition = computed(() =>
openedTab.value === "main" ? TransitionSlideOutToRight : TransitionSlideOutToLeft
);
Expand Down
8 changes: 6 additions & 2 deletions components/transaction/EthereumTransactionFooter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@
class="w-full"
@click="onboardStore.setCorrectNetwork"
>
Change wallet network to {{ l1Network.name }}
<slot v-bind="{ l1Network, walletName }" name="change-network-auto">
Change wallet network to {{ l1Network.name }}
</slot>
</CommonButton>
<CommonButton v-else disabled variant="primary" class="w-full">
Change network manually to {{ l1Network.name }} in your {{ walletName }} wallet
<slot v-bind="{ l1Network, walletName }" name="change-network-manual">
Change network manually to {{ l1Network.name }} in your {{ walletName }} wallet
</slot>
</CommonButton>
</template>
<template v-else>
Expand Down
11 changes: 8 additions & 3 deletions components/transaction/TransactionHashButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@
class="transaction-hash-button"
@click="copy()"
>
Copy hash
<CommonSpinner v-if="!transactionHash" class="transaction-hash-button-icon" aria-hidden="true" />
Copy tx hash
<CommonSpinner
v-if="!transactionHash"
variant="text-color"
class="transaction-hash-button-icon"
aria-hidden="true"
/>
<DocumentDuplicateIcon v-else class="transaction-hash-button-icon" aria-hidden="true" />
</CommonButton>
<template v-else>
Expand All @@ -22,7 +27,7 @@
class="transaction-hash-button"
>
Explorer
<CommonSpinner class="transaction-hash-button-icon" aria-hidden="true" />
<CommonSpinner variant="text-color" class="transaction-hash-button-icon" aria-hidden="true" />
</CommonButton>
<CommonButton
v-else
Expand Down
17 changes: 14 additions & 3 deletions components/transaction/TransactionProgress.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,23 @@
</div>
</template>

<AnimationsTransactionProgress :completed="completed" class="transaction-animation" />
<AnimationsTransactionProgress
:state="animationState ?? (completed ? 'completed' : 'playing')"
class="transaction-animation"
/>

<div v-if="fromExplorerLink || fromTransactionHash" class="info-column bottom-left mt-block-gap-1/2">
<TransactionHashButton :explorer-url="fromExplorerLink" :transaction-hash="fromTransactionHash" />
</div>
<div v-else-if="$slots['from-button']" class="info-column bottom-left mt-block-gap-1/2">
<slot name="from-button" />
</div>
<div v-if="toExplorerLink || toTransactionHash" class="info-column bottom-right mt-block-gap-1/2">
<TransactionHashButton :explorer-url="toExplorerLink" :transaction-hash="toTransactionHash" />
</div>
<div v-else-if="$slots['to-button']" class="info-column bottom-right mt-block-gap-1/2">
<slot name="to-button" />
</div>
</div>
<TransactionHashButton
v-if="explorerLink || transactionHash"
Expand Down Expand Up @@ -97,6 +106,7 @@
<script lang="ts" setup>
import { computed } from "vue";

import type { AnimationState } from "@/components/animations/TransactionProgress.vue";
import type { TransactionDestination } from "@/store/destinations";
import type { TokenAmount } from "@/types";
import type { PropType } from "vue";
Expand Down Expand Up @@ -149,6 +159,9 @@ const props = defineProps({
type: Boolean,
default: false,
},
animationState: {
type: String as PropType<AnimationState>,
},
});

const isSameAddress = computed(() => props.fromAddress === props.toAddress);
Expand Down Expand Up @@ -186,8 +199,6 @@ const isSameAddressDifferentDestination = computed(

.airplane {
@apply absolute h-8 w-8;
// create animation from left opacity 0 to center opacity 100 to right opacity 0
// it should also scale from 0 to 1 to 0
animation: airplane 3s linear infinite;
@keyframes airplane {
0% {
Expand Down
7 changes: 7 additions & 0 deletions components/transaction/TransferLineItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
:explorer-url="blockExplorerUrl"
:transaction-hash="transfer.transactionHash!"
>
<template #icon v-if="inProgress">
<CommonSpinner variant="dark" aria-hidden="true" />
</template>
<template #top-left>{{ label }}</template>
<template #bottom-left>
<template v-if="chainsLabel">
Expand Down Expand Up @@ -64,6 +67,10 @@ const props = defineProps({
type: Object as PropType<Transfer>,
required: true,
},
inProgress: {
type: Boolean,
default: false,
},
});

const { account } = storeToRefs(useOnboardStore());
Expand Down
Loading
Loading