forked from matter-labs/dapp-portal
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
zhiyuan li
authored and
zhiyuan li
committed
Apr 17, 2024
1 parent
20e6316
commit 4aaa20b
Showing
4 changed files
with
173 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { storeToRefs } from "pinia"; | ||
|
||
import type { Token } from "@/types"; | ||
|
||
import { useNetworkStore } from "@/store/network"; | ||
|
||
export default (selectedToken: Ref<Token | undefined>) => { | ||
const { zkSyncNetworks } = useNetworks(); | ||
const { selectedNetwork } = storeToRefs(useNetworkStore()); | ||
const isMNTSelected = computed(() => { | ||
return selectedToken.value?.symbol === "MNT" && selectedNetwork.value.key === "mantle"; | ||
}); | ||
|
||
const isWETHSelected = computed(() => { | ||
let weths: string[] = []; | ||
zkSyncNetworks.forEach((item) => { | ||
if (item.wethContract) { | ||
weths = weths.concat(item.wethContract.map((e) => e.toLowerCase())); | ||
} | ||
}); | ||
console.log( | ||
"isWETHSelected", | ||
selectedToken.value?.address && weths.some((item) => item === selectedToken.value?.address.toLowerCase()) | ||
); | ||
return selectedToken.value?.address && weths.some((item) => item === selectedToken.value?.address.toLowerCase()); | ||
}); | ||
|
||
const isMNTOrWETH = computed(() => { | ||
console.log("isMNTOrWETH", isMNTSelected.value || isWETHSelected.value); | ||
return isMNTSelected.value || isWETHSelected.value; | ||
}); | ||
|
||
const warpTipsTitle = computed(() => { | ||
return isMNTSelected.value ? "Wrap your MNT" : isWETHSelected.value ? "Unwrap your WETH" : ""; | ||
}); | ||
|
||
const warpTipsDesc = computed(() => { | ||
return isMNTSelected.value | ||
? "The zkLink Nova Portal doesn't currently support depositing MNT. You could convert it to WMNT before using the bridge." | ||
: isWETHSelected.value | ||
? "The zkLink Nova Portal doesn't currently encourage depositing WETH. You could convert it to ETH before using the bridge." | ||
: ""; | ||
}); | ||
|
||
const wrapBtnText = computed(() => { | ||
return isMNTSelected.value ? "Wrap" : isWETHSelected.value ? "Unwrap" : ""; | ||
}); | ||
|
||
return { | ||
isMNTSelected, | ||
isWETHSelected, | ||
isMNTOrWETH, | ||
warpTipsTitle, | ||
warpTipsDesc, | ||
wrapBtnText, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters