From 61f13ded5cf25f9e6013fbd56a7b5610bb0aacfd Mon Sep 17 00:00:00 2001 From: Jarsen <31397967+Jarsen136@users.noreply.github.com> Date: Wed, 14 Jun 2023 23:45:49 +0800 Subject: [PATCH] feat: isChain composable (#6203) * feat: isChain composable * fix: computed prefix --- .../common/ConnectWallet/WalletAssetMenu.vue | 3 ++- .../ConnectWallet/WalletAssetPortfolio.vue | 3 ++- composables/useIsChain.ts | 20 +++++++++++++++++++ composables/usePrefix.ts | 5 ----- 4 files changed, 24 insertions(+), 7 deletions(-) create mode 100644 composables/useIsChain.ts diff --git a/components/common/ConnectWallet/WalletAssetMenu.vue b/components/common/ConnectWallet/WalletAssetMenu.vue index 1f352581fa..801abd6d6c 100644 --- a/components/common/ConnectWallet/WalletAssetMenu.vue +++ b/components/common/ConnectWallet/WalletAssetMenu.vue @@ -52,7 +52,8 @@ import { NeoIcon } from '@kodadot1/brick' import { langsFlags } from '@/utils/config/i18n' import { useLangStore } from '@/stores/lang' -const { urlPrefix, isBasilisk } = usePrefix() +const { urlPrefix } = usePrefix() +const { isBasilisk } = useIsChain(urlPrefix) const { toggleColorMode, isDarkMode } = useTheme() const langStore = useLangStore() diff --git a/components/common/ConnectWallet/WalletAssetPortfolio.vue b/components/common/ConnectWallet/WalletAssetPortfolio.vue index 548ec2c494..bd46bb8ceb 100644 --- a/components/common/ConnectWallet/WalletAssetPortfolio.vue +++ b/components/common/ConnectWallet/WalletAssetPortfolio.vue @@ -21,7 +21,8 @@ import { NeoButton } from '@kodadot1/brick' import { RampInstantSDK } from '@ramp-network/ramp-instant-sdk' -const { urlPrefix, isBasilisk } = usePrefix() +const { urlPrefix } = usePrefix() +const { isBasilisk } = useIsChain(urlPrefix) const { accountId } = useAuth() const showRampSDK = () => { diff --git a/composables/useIsChain.ts b/composables/useIsChain.ts new file mode 100644 index 0000000000..c837aea505 --- /dev/null +++ b/composables/useIsChain.ts @@ -0,0 +1,20 @@ +import type { Prefix } from '@kodadot1/static' +import type { ComputedRef } from 'vue' + +export default function (prefix: ComputedRef) { + const isBasilisk = computed( + () => prefix.value === 'bsx' || prefix.value === 'snek' + ) + const isRemark = computed( + () => prefix.value === 'rmrk' || prefix.value === 'ksm' + ) + const isAssetHub = computed( + () => prefix.value === 'stmn' || prefix.value === 'stt' + ) + + return { + isBasilisk, + isRemark, + isAssetHub, + } +} diff --git a/composables/usePrefix.ts b/composables/usePrefix.ts index ef0ff0762b..5c96127e5a 100644 --- a/composables/usePrefix.ts +++ b/composables/usePrefix.ts @@ -40,16 +40,11 @@ export default function () { return useAssetsStore().getAssetById(String(id)) } - const isBasilisk = computed( - () => prefix.value === 'bsx' || prefix.value === 'snek' - ) - return { urlPrefix, setUrlPrefix, client, tokenId, assets, - isBasilisk, } }