diff --git a/.env.example b/.env.example index 8abb5e1903ec1f8a9eddd8ace8e20800156984af..b7525cab9c12080333f563022ae46a3128242856 100644 --- a/.env.example +++ b/.env.example @@ -3,6 +3,9 @@ NUXT_PUBLIC_SNAP_ORIGIN= ## Uncomment this if you want to use a specific version of the Snap runtime: # NUXT_PUBLIC_SNAP_VERSION= +## Uncomment this if you want to show HTM in the menu +# NUXT_PUBLIC_SHOW_HTM_IN_MENU=true + # Custom Tokens API Configuration # Set this to your ctokens-api server URL # Example for local development: http://localhost:3000/ctokens-api diff --git a/nuxt.config.ts b/nuxt.config.ts index 1e7b51af363ebbcd3dc876b6303b52747c2457f7..3fef0e1cf663bcc742b5b3afaaf15757b8d49a5a 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -54,6 +54,7 @@ export default defineNuxtConfig({ }, runtimeConfig: { public: { + showHtmInMenu: false, commitHash: getCommitHash(), ctokensApiUrl: 'https://htm.fqdn.pl:10081', hiveNodeEndpoint: 'https://api.hive.blog', diff --git a/src/components/navigation/AppSidebar.vue b/src/components/navigation/AppSidebar.vue index 29376757dd4ccd2b58e9bd4b194bb47555d33f5a..da762dcf4998b17640bd513626e7a8a7496d9474 100644 --- a/src/components/navigation/AppSidebar.vue +++ b/src/components/navigation/AppSidebar.vue @@ -6,12 +6,13 @@ import { useRouter } from 'vue-router'; import { Button } from '@/components/ui/button'; import { Separator } from '@/components/ui/separator'; import { Sidebar, SidebarContent, SidebarHeader, SidebarFooter, SidebarGroup, SidebarGroupContent, SidebarGroupLabel, SidebarMenu, SidebarMenuButton, SidebarMenuItem , useSidebar } from '@/components/ui/sidebar'; +import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip'; import { useTokensStore } from '@/stores/tokens.store'; import { useWalletStore } from '@/stores/wallet.store'; import { getWax } from '@/stores/wax.store'; import { toastError } from '@/utils/parse-error'; -const { public: { commitHash, snapOrigin, snapVersion } } = useRuntimeConfig(); +const { public: { commitHash, snapOrigin, snapVersion, showHtmInMenu } } = useRuntimeConfig(); const props = defineProps({ forceTokenView: { @@ -30,6 +31,33 @@ const walletStore = useWalletStore(); const isL1BasedView = computed(() => walletStore.hasWallet && !walletStore.isL2Wallet); const hasHTMWallet = computed(() => !!tokensStore.wallet); +const chainId = ref(''); + +const tokenItems: Array<{ title: string; url: string; icon: string; badge?: string; visible?: Ref; disabled?: Ref }> = [ + { + title: 'My HTM Account', + url: '/tokens/my-balance', + icon: mdiWallet, + visible: hasHTMWallet + }, + { + title: 'Tokens List', + url: '/tokens/list', + icon: mdiAccountGroup + }, + { + title: 'My Token Definitions', + url: '/tokens/my-tokens', + icon: mdiViewList, + visible: hasHTMWallet + }, + { + title: 'Register HTM Account', + url: '/tokens/register-account', + icon: mdiAccountPlusOutline + } +]; + const tokensGroups: { title?: string; items: Array<{ title: string; url: string; icon: string; badge?: string; visible?: Ref; disabled?: Ref }> }[] = [{ items: [{ title: 'Back to Hive Bridge', @@ -39,30 +67,7 @@ const tokensGroups: { title?: string; items: Array<{ title: string; url: string; }, { title: 'Tokens', - items: [ - { - title: 'My HTM Account', - url: '/tokens/my-balance', - icon: mdiWallet, - visible: hasHTMWallet - }, - { - title: 'Tokens List', - url: '/tokens/list', - icon: mdiAccountGroup - }, - { - title: 'My Token Definitions', - url: '/tokens/my-tokens', - icon: mdiViewList, - visible: hasHTMWallet - }, - { - title: 'Register HTM Account', - url: '/tokens/register-account', - icon: mdiAccountPlusOutline - } - ] + items: tokenItems }]; const mainGroups: { title: string; items: Array<{ title: string; url: string; icon: string; badge?: string; visible?: Ref; disabled?: Ref }> }[] = [{ @@ -93,7 +98,7 @@ const mainGroups: { title: string; items: Array<{ title: string; url: string; ic ] }, { title: 'Tokens', - items: [ + items: showHtmInMenu ? tokenItems : [ { title: 'My tokens', url: '#', @@ -153,6 +158,8 @@ onMounted(async () => { try { const wax = await getWax(); + /* eslint-disable-next-line @typescript-eslint/no-explicit-any */ + chainId.value = (wax as any).chainId; // XXX: Wait for wax update to expose chainId properly waxVersion.value = wax.getVersion(); } catch(error) { toastError('Failed to get WAX instance:', error); @@ -242,6 +249,19 @@ onMounted(async () => {
@hiveio/wax@{{ waxVersion }}
{{ metamaskVersion }}
Commit Hash: {{ commitHash.substring(0, 7) }}
+ + + +
Chain ID: {{ chainId.substring(0, 10) }}…
+
+ +
Full Chain ID: {{ chainId }}
+
+
+
diff --git a/src/stores/wax.store.ts b/src/stores/wax.store.ts index 4e89d6fbd0b4049db24d353b74434a540bbb7798..93495f35bccf609b4227b0f45e20c028ed628cf2 100644 --- a/src/stores/wax.store.ts +++ b/src/stores/wax.store.ts @@ -1,4 +1,4 @@ -import type { NaiAsset, TWaxRestExtended, TWaxExtended, asset } from '@hiveio/wax'; +import { type NaiAsset, type TWaxRestExtended, type TWaxExtended, type asset, DEFAULT_WAX_OPTIONS } from '@hiveio/wax'; import CTokensApi from '@/utils/wallet/ctokens/api'; @@ -149,7 +149,7 @@ export const getWax = async () => { if (!chain) { const { public: { hiveNodeEndpoint, hiveChainId, ctokensApiUrl } } = useRuntimeConfig(); - const chainId = typeof hiveChainId === 'number' || hiveChainId.length > 0 ? String(hiveChainId) : undefined; + const chainId = typeof hiveChainId === 'number' || hiveChainId.length > 0 ? String(hiveChainId).padEnd(64, '0') : DEFAULT_WAX_OPTIONS.chainId; const apiEndpoint = hiveNodeEndpoint.length > 0 ? hiveNodeEndpoint : undefined; chain = (await (await import('@hiveio/wax')).createHiveChain({ apiEndpoint, chainId })).extend().extendRest(CTokensApi);