add basic framework
This commit is contained in:
parent
88e36d554d
commit
e011ec0691
@ -15,6 +15,7 @@ import { VerticalNavLayout } from '@layouts';
|
|||||||
import NavBarI18n from './NavBarI18n.vue';
|
import NavBarI18n from './NavBarI18n.vue';
|
||||||
import NavSearchBar from './NavSearchBar.vue';
|
import NavSearchBar from './NavSearchBar.vue';
|
||||||
import NavBarNotifications from './NavBarNotifications.vue';
|
import NavBarNotifications from './NavBarNotifications.vue';
|
||||||
|
import NavBarWallet from './NavBarWallet.vue';
|
||||||
import TheCustomizer from '@/plugins/vuetify/@core/components/TheCustomizer.vue';
|
import TheCustomizer from '@/plugins/vuetify/@core/components/TheCustomizer.vue';
|
||||||
import Breadcrumbs from './Breadcrumbs.vue';
|
import Breadcrumbs from './Breadcrumbs.vue';
|
||||||
import { useBlockchain } from '@/stores';
|
import { useBlockchain } from '@/stores';
|
||||||
@ -68,7 +69,7 @@ blockchain.$subscribe((m, s) => {
|
|||||||
<NavBarNotifications class="hidden md:inline-block" />
|
<NavBarNotifications class="hidden md:inline-block" />
|
||||||
<NavBarI18n class="hidden md:inline-block" />
|
<NavBarI18n class="hidden md:inline-block" />
|
||||||
<NavbarThemeSwitcher class="hidden md:inline-block" />
|
<NavbarThemeSwitcher class="hidden md:inline-block" />
|
||||||
<ConnectWallet class="md:inline-block" />
|
<NavBarWallet class="md:inline-block" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
14
src/layouts/components/NavBarWallet.vue
Normal file
14
src/layouts/components/NavBarWallet.vue
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import { useBlockchain, useWalletStore } from '@/stores';
|
||||||
|
|
||||||
|
const walletStore = useWalletStore()
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<span v-if="walletStore.currentAddress">{{ walletStore.currentAddress }}</span>
|
||||||
|
<ping-connect-wallet v-else class="mt-5" :chain-id="'juno-1'" :hd-path="`m/44'/118/0'/0/0`" />
|
||||||
|
</div>
|
||||||
|
</template>
|
@ -3,7 +3,7 @@ import MdEditor from 'md-editor-v3';
|
|||||||
import PriceMarketChart from '@/components/charts/PriceMarketChart.vue';
|
import PriceMarketChart from '@/components/charts/PriceMarketChart.vue';
|
||||||
|
|
||||||
import { Icon } from '@iconify/vue';
|
import { Icon } from '@iconify/vue';
|
||||||
import { useBlockchain, useFormatter } from '@/stores';
|
import { useBlockchain, useFormatter, useWalletStore } from '@/stores';
|
||||||
import { onMounted, ref } from 'vue';
|
import { onMounted, ref } from 'vue';
|
||||||
import { useIndexModule } from './indexStore';
|
import { useIndexModule } from './indexStore';
|
||||||
import { computed } from '@vue/reactivity';
|
import { computed } from '@vue/reactivity';
|
||||||
@ -13,6 +13,7 @@ import ProposalListItem from '@/components/ProposalListItem.vue';
|
|||||||
|
|
||||||
const blockchain = useBlockchain();
|
const blockchain = useBlockchain();
|
||||||
const store = useIndexModule();
|
const store = useIndexModule();
|
||||||
|
const walletStore = useWalletStore()
|
||||||
|
|
||||||
const coinInfo = computed(() => {
|
const coinInfo = computed(() => {
|
||||||
return store.coinInfo;
|
return store.coinInfo;
|
||||||
@ -62,6 +63,9 @@ const comLinks = [
|
|||||||
href: store.github,
|
href: store.github,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// wallet box
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -216,12 +220,24 @@ const comLinks = [
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ping-connect-wallet class="mt-5" :chain-id="'juno-1'" :hd-path="`m/44'/118/0'/0/0`" />
|
<div class="bg-transparent rounded mt-4 border-2 border-primary">
|
||||||
<div
|
<div class="px-4 pt-4 pb-2 text-lg font-semibold text-secondary">
|
||||||
class="btn btn-primary w-full mt-5 flex items-center bg-transparent text-primary hover:bg-gray-100 hover:bg-transparent"
|
{{ walletStore.currentAddress || "Not Connected" }}
|
||||||
>
|
<span v-if="walletStore.currentAddress" class="float-right font-light text-sm">More</span>
|
||||||
Connect Wallet
|
</div>
|
||||||
|
<div class="grid grid-cols-1 md:grid-cols-4 auto-cols-auto gap-4 px-4 pb-8 py-4">
|
||||||
|
<div class="bg-base-100">1</div>
|
||||||
|
<div class="bg-base-100">2</div>
|
||||||
|
<div class="bg-base-100">1</div>
|
||||||
|
<div class="bg-base-100">2</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -39,6 +39,14 @@ export const useBlockchain = defineStore('blockchain', {
|
|||||||
logo(): string {
|
logo(): string {
|
||||||
return this.current?.logo || '';
|
return this.current?.logo || '';
|
||||||
},
|
},
|
||||||
|
defaultHDPath(): string {
|
||||||
|
const cointype = this.current?.coinType || "118"
|
||||||
|
// if(cointype === "60") {
|
||||||
|
// return `m/44'/${cointype}`
|
||||||
|
// }
|
||||||
|
// return `m/44'/${cointype}/0'/0/0`
|
||||||
|
return "connected-wallet"
|
||||||
|
},
|
||||||
dashboard() {
|
dashboard() {
|
||||||
return useDashboard();
|
return useDashboard();
|
||||||
},
|
},
|
||||||
|
@ -58,6 +58,7 @@ export interface ChainConfig {
|
|||||||
prettyName: string;
|
prettyName: string;
|
||||||
bech32Prefix: string;
|
bech32Prefix: string;
|
||||||
chainId: string;
|
chainId: string;
|
||||||
|
coinType: string;
|
||||||
assets: Asset[];
|
assets: Asset[];
|
||||||
themeColor?: string;
|
themeColor?: string;
|
||||||
endpoints: {
|
endpoints: {
|
||||||
@ -127,6 +128,7 @@ export function fromLocal(lc: LocalConfig): ChainConfig {
|
|||||||
}));
|
}));
|
||||||
conf.bech32Prefix = lc.addr_prefix;
|
conf.bech32Prefix = lc.addr_prefix;
|
||||||
conf.chainName = lc.chain_name;
|
conf.chainName = lc.chain_name;
|
||||||
|
conf.coinType = lc.coin_type;
|
||||||
conf.prettyName = lc.chain_name;
|
conf.prettyName = lc.chain_name;
|
||||||
conf.endpoints = {
|
conf.endpoints = {
|
||||||
rest: apiConverter(lc.api),
|
rest: apiConverter(lc.api),
|
||||||
|
@ -1,9 +1,37 @@
|
|||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
|
import { useBlockchain } from './useBlockchain';
|
||||||
|
import { fromBech32, toBech32 } from '@cosmjs/encoding';
|
||||||
|
|
||||||
export const useWalletStore = defineStore('walletStore', {
|
export const useWalletStore = defineStore('walletStore', {
|
||||||
state: () => {
|
state: () => {
|
||||||
return {};
|
return {};
|
||||||
},
|
},
|
||||||
getters: {},
|
getters: {
|
||||||
actions: {},
|
blockchain() {
|
||||||
|
return useBlockchain();
|
||||||
|
},
|
||||||
|
connectedWallet() {
|
||||||
|
const chainStore = useBlockchain()
|
||||||
|
const key = chainStore.defaultHDPath
|
||||||
|
|
||||||
|
const connected = JSON.parse(localStorage.getItem(key)||"{}")
|
||||||
|
return connected
|
||||||
|
},
|
||||||
|
currentAddress() {
|
||||||
|
const {prefix, data} = fromBech32(this.connectedWallet.cosmosAddress);
|
||||||
|
const chainStore = useBlockchain()
|
||||||
|
return toBech32(chainStore.current?.bech32Prefix || prefix, data)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
actions: {
|
||||||
|
myBalance() {
|
||||||
|
return this.blockchain.rpc.getBankBalances(this.currentAddress)
|
||||||
|
},
|
||||||
|
myDelegations() {
|
||||||
|
return this.blockchain.rpc.getStakingDelegations(this.currentAddress)
|
||||||
|
},
|
||||||
|
myUnbonding() {
|
||||||
|
return this.blockchain.rpc.getStakingDelegatorUnbonding(this.currentAddress)
|
||||||
|
}
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user