Skip to content

Commit

Permalink
Merge pull request #276 from zkLinkProtocol/feat/intent_url
Browse files Browse the repository at this point in the history
Feat/intent url
  • Loading branch information
zkLeonardo committed Aug 7, 2024
2 parents 96846ff + 7649468 commit c53c13e
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 5 deletions.
19 changes: 17 additions & 2 deletions components/common/input/TransactionAddress.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
<div class="font-bold">{{ label }}</div>
<slot name="dropdown" />
</div>
<div v-if="!addressInputHidden && defaultLabel && isConnected">
<div v-if="receipt">
<span class="font-bold">To account {{ shortenAddress(receipt) }}</span>
</div>
<div v-else-if="!addressInputHidden && defaultLabel && isConnected">
<span class="font-bold">{{ inputVisible ? "To another account" : defaultLabel }}</span>
<CommonButtonLabel variant="light" class="ml-1" @click="toggleCustomValue()">
{{ inputVisible ? "Use my account" : "Change" }}
</CommonButtonLabel>
</div>
</div>
<div v-show="inputVisible" class="mt-4">
<div v-show="inputVisible && !receipt" class="mt-4">
<div class="flex items-center gap-2">
<CommonInputLine
v-model.trim="inputted"
Expand Down Expand Up @@ -70,6 +73,7 @@ import { isAddress } from "viem";
import useEns from "@/composables/useEnsName";
import { useRoute } from "#app";
import { useOnboardStore } from "@/store/onboard";
import { usePreferencesStore } from "@/store/preferences";
import { isMobile } from "@/utils/helpers";
Expand All @@ -92,6 +96,17 @@ const props = defineProps({
},
});
const route = useRoute();
const receipt = computed(() => {
const receipt = route.query.receipt as string;
if (isAddress(receipt)) {
return receipt;
} else {
return "";
}
});
const emit = defineEmits<{
(eventName: "update:error", error?: string): void;
(eventName: "update:modelValue", amount: string): void;
Expand Down
26 changes: 24 additions & 2 deletions views/transactions/Deposit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,9 @@
>
Continue
</CommonButton>
<CommonButton v-if="fromLink" variant="light" class="w-full mt-5" @click="handleGoBack()">
Go Back
</CommonButton>
</template>
<template v-else-if="step === 'confirm'">
<transition v-bind="TransitionAlertScaleInOutTransition">
Expand Down Expand Up @@ -419,6 +422,9 @@
<span v-else>Deposit now</span>
</transition>
</CommonButton>
<CommonButton v-if="fromLink" variant="light" class="w-full mt-5" @click="handleGoBack()">
Go Back
</CommonButton>
<TransactionButtonUnderlineConfirmTransaction :opened="transactionStatus === 'waiting-for-signature'" />
</template>
</template>
Expand Down Expand Up @@ -467,8 +473,8 @@ import { getWaitTime } from "@/data/networks";
import { useDestinationsStore } from "@/store/destinations";
import { useNetworkStore } from "@/store/network";
import { useOnboardStore } from "@/store/onboard";
import { useSearchtokenStore } from "@/store/searchToken";
import { usePreferencesStore } from "@/store/preferences";
import { useSearchtokenStore } from "@/store/searchToken";
import { useZkSyncEthereumBalanceStore } from "@/store/zksync/ethereumBalance";
import { useZkSyncProviderStore } from "@/store/zksync/provider";
import { useZkSyncTokensStore } from "@/store/zksync/tokens";
Expand Down Expand Up @@ -530,6 +536,14 @@ const pageDesc = computed(() => {
return props.isIntegrate ? desc : "";
});

const receipt = computed(() => {
return route.query.receipt;
});

const fromLink = computed(() => {
return route.query.fromLink;
});

const step = ref<"form" | "confirm" | "submitted">("form");
const isMerge = ref<true | false>(true);
const destination = computed(() => destinations.value.nova);
Expand Down Expand Up @@ -662,7 +676,11 @@ const queryAddress = useRouteQuery<string | undefined>("address", undefined, {
transform: String,
mode: "replace",
});
const address = ref((queryAddress.value !== "undefined" && queryAddress.value) || "");
const address = ref(
(receipt.value && isAddress(receipt.value as string)
? (receipt.value as string)
: queryAddress.value !== "undefined" && queryAddress.value) || ""
);
const isAddressInputValid = computed(() => {
if (address.value) {
return isAddress(address.value);
Expand Down Expand Up @@ -829,6 +847,10 @@ const buttonContinue = () => {
}
};

const handleGoBack = () => {
window.open(fromLink.value as string, "_self");
};

const buttonWrap = () => {
if (continueButtonDisabled.value) {
return;
Expand Down
16 changes: 15 additions & 1 deletion views/transactions/DepositSubmitted.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

<EcosystemBlock v-if="eraNetwork.displaySettings?.showPartnerLinks" class="mt-block-gap" />
<CommonButton
v-if="!fromLink"
size="sm"
:as="makeAnotherTransaction ? undefined : 'RouterLink'"
:to="{ name: 'index' }"