forked from cerc-io/cosmos-explorer
add wallet
This commit is contained in:
parent
eb79884c07
commit
b195e72554
14982
package-lock.json
generated
14982
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -40,7 +40,7 @@
|
||||
"md-editor-v3": "^2.8.1",
|
||||
"numeral": "^2.0.6",
|
||||
"osmojs": "^14.0.0-rc.0",
|
||||
"ping-widget": "git+https://github.com/ping-pub/widget.git",
|
||||
"ping-widget": "^0.0.7",
|
||||
"pinia": "^2.0.28",
|
||||
"postcss": "^8.4.23",
|
||||
"prismjs": "^1.29.0",
|
||||
|
@ -172,7 +172,6 @@ const sidebarShow = ref(false);
|
||||
<div class="flex-1 w-0"></div>
|
||||
|
||||
<!-- <NavSearchBar />-->
|
||||
<NavBarNotifications class="hidden md:inline-block" />
|
||||
<NavBarI18n class="hidden md:inline-block" />
|
||||
<NavbarThemeSwitcher class="hidden md:inline-block" />
|
||||
|
||||
|
@ -9,10 +9,24 @@ walletStore.$subscribe((m, s) => {
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<span v-if="walletStore.currentAddress">{{
|
||||
walletStore.currentAddress
|
||||
}}</span>
|
||||
|
||||
<div v-if="walletStore.currentAddress"
|
||||
class="dropdown dropdown-hover ping-connect-dropdown"
|
||||
>
|
||||
<label tabindex="3" class="btn m-1" >{{ walletStore.shortAddress }}</label>
|
||||
<ul
|
||||
tabindex="3"
|
||||
class="dropdown-content menu p-2 shadow bg-base-100 rounded-box w-52"
|
||||
>
|
||||
<li>
|
||||
<a>{{ walletStore.connectedWallet }}</a>
|
||||
</li>
|
||||
<li>
|
||||
<a>{{ walletStore.currentAddress }}</a>
|
||||
</li>
|
||||
<div class="divider"></div>
|
||||
<li><a @click="walletStore.disconnect()">Disconnected</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<label
|
||||
v-else
|
||||
for="PingConnectWallet"
|
||||
|
@ -26,6 +26,9 @@ export class BaseRestClient<R extends AbstractRegistry> {
|
||||
}
|
||||
|
||||
export class CosmosRestClient extends BaseRestClient<RequestRegistry> {
|
||||
constructor(endpoint: string) {
|
||||
super(endpoint, DEFAULT)
|
||||
}
|
||||
// Auth Module
|
||||
async getAuthAccounts() {
|
||||
return this.request(this.registry.auth_accounts, {});
|
||||
|
@ -45,10 +45,10 @@ const validators = computed(() => {
|
||||
|
||||
onMounted(() => {
|
||||
live.value = true;
|
||||
baseStore.fetchLatest().then((block) => {
|
||||
latest.value = block;
|
||||
commits.value.unshift(block.block.last_commit);
|
||||
const height = Number(block.block.header?.height || 0);
|
||||
baseStore.fetchLatest().then(b => {
|
||||
latest.value = b;
|
||||
commits.value.unshift(b.block.last_commit);
|
||||
const height = Number(b.block.header?.height || 0);
|
||||
if (height > 0) {
|
||||
// constructs sequence for loading blocks
|
||||
let promise = Promise.resolve();
|
||||
@ -57,7 +57,7 @@ onMounted(() => {
|
||||
promise = promise.then(
|
||||
() =>
|
||||
new Promise((resolve, reject) => {
|
||||
if (live.value) {
|
||||
if (live.value && commits2.value.length < 50) {
|
||||
// continue only if the page is living
|
||||
baseStore.fetchBlock(i).then((x) => {
|
||||
commits.value.unshift(x.block.last_commit);
|
||||
@ -78,10 +78,18 @@ onMounted(() => {
|
||||
});
|
||||
});
|
||||
|
||||
const commits2 = computed(() => {
|
||||
const la = baseStore.recents.map(b => b.block.last_commit)
|
||||
const all = [...commits.value, ...la]
|
||||
return all.length > 50 ? all.slice(all.length - 50): all
|
||||
})
|
||||
|
||||
|
||||
onUnmounted(() => {
|
||||
live.value = false;
|
||||
});
|
||||
|
||||
|
||||
watchEffect(() => {
|
||||
local.value[chainStore.chainName] = selected.value;
|
||||
localStorage.setItem('uptime-validators', JSON.stringify(local.value));
|
||||
@ -91,7 +99,6 @@ watchEffect(() => {
|
||||
<template>
|
||||
<div class="bg-base-100 px-5 pt-5">
|
||||
<div class="flex items-center gap-x-4">
|
||||
<div class="text-main text-lg">Current Height: {{ latest.block?.header?.height }}</div>
|
||||
<input
|
||||
type="text"
|
||||
v-model="keyword"
|
||||
@ -131,7 +138,7 @@ watchEffect(() => {
|
||||
?.missed_blocks_counter
|
||||
}}
|
||||
</div>
|
||||
<div v-else class="mt-1 badge badge-sm text-white bg-yes">
|
||||
<div v-else class="mt-1 badge badge-sm text-white bg-yes border-0">
|
||||
{{
|
||||
signingInfo[consensusPubkeyToHexAddress(v.consensus_pubkey)]
|
||||
?.missed_blocks_counter
|
||||
@ -139,7 +146,7 @@ watchEffect(() => {
|
||||
</div>
|
||||
</div>
|
||||
<UptimeBar
|
||||
:blocks="commits"
|
||||
:blocks="commits2"
|
||||
:validator="
|
||||
toBase64(fromHex(consensusPubkeyToHexAddress(v.consensus_pubkey)))
|
||||
"
|
||||
|
15
src/modules/wallet/portfollio.vue
Normal file
15
src/modules/wallet/portfollio.vue
Normal file
@ -0,0 +1,15 @@
|
||||
<script lang="ts" setup>
|
||||
import { CosmosRestClient } from '@/libs/client';
|
||||
|
||||
async function tt() {
|
||||
const address = 'echelon1uattqtrtv8944qkmh44ll97qjacj6tgrekqzm9';
|
||||
const validator = 'echelonvaloper1uattqtrtv8944qkmh44ll97qjacj6tgr2cupk4';
|
||||
const client = new CosmosRestClient('https://api.ech.network');
|
||||
let response = await client.getBaseBlockLatest();
|
||||
console.log('response:', response);
|
||||
}
|
||||
tt();
|
||||
</script>
|
||||
<template>
|
||||
<div>Hello wallet</div>
|
||||
</template>
|
@ -71,6 +71,13 @@ export const useWalletStore = defineStore('walletStore', {
|
||||
const chainStore = useBlockchain();
|
||||
return toBech32(chainStore.current?.bech32Prefix || prefix, data);
|
||||
},
|
||||
shortAddress() {
|
||||
const address: string = this.currentAddress
|
||||
if(address.length > 4) {
|
||||
return `${address.substring(address.length -4)}`
|
||||
}
|
||||
return ""
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async loadMyAsset() {
|
||||
@ -105,5 +112,12 @@ export const useWalletStore = defineStore('walletStore', {
|
||||
this.currentAddress
|
||||
);
|
||||
},
|
||||
disconnect() {
|
||||
const chainStore = useBlockchain();
|
||||
const key = chainStore.defaultHDPath;
|
||||
|
||||
localStorage.removeItem(key);
|
||||
this.$reset()
|
||||
}
|
||||
},
|
||||
});
|
||||
|
32
yarn.lock
32
yarn.lock
@ -2248,6 +2248,14 @@
|
||||
case "1.6.3"
|
||||
dotty "0.1.2"
|
||||
|
||||
"@osmonauts/lcd@^0.10.0":
|
||||
version "0.10.0"
|
||||
resolved "https://registry.yarnpkg.com/@osmonauts/lcd/-/lcd-0.10.0.tgz#c982942dc13d7f6ab2a7873b289c7907e2169b14"
|
||||
integrity sha512-PzmXk9x9MHyLn2fUztpAqWqvDmMiEJaQv/JcAoAOE8VdHrD9Hf/KWnE1RZtamuS2ngQRqvQPD0xotCGXW7eTxA==
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.19.0"
|
||||
axios "0.27.2"
|
||||
|
||||
"@osmonauts/lcd@^0.8.0":
|
||||
version "0.8.0"
|
||||
resolved "https://registry.npmjs.org/@osmonauts/lcd/-/lcd-0.8.0.tgz"
|
||||
@ -6569,6 +6577,20 @@ osmojs@^14.0.0-rc.0:
|
||||
long "^5.2.0"
|
||||
protobufjs "^6.11.3"
|
||||
|
||||
osmojs@^15.2.1:
|
||||
version "15.2.1"
|
||||
resolved "https://registry.yarnpkg.com/osmojs/-/osmojs-15.2.1.tgz#d9556d47ea77f95b400656d68f7a4ec69912c15a"
|
||||
integrity sha512-hA4QOlEhs2h0tQPYld5EqH+GhyHVTc9Fye3BAAOlfc9++GQB127pFZdProCGFNvw4kJwHHzhQQtuE98tk1EejA==
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.19.0"
|
||||
"@cosmjs/amino" "0.29.3"
|
||||
"@cosmjs/proto-signing" "0.29.3"
|
||||
"@cosmjs/stargate" "0.29.3"
|
||||
"@cosmjs/tendermint-rpc" "^0.29.3"
|
||||
"@osmonauts/lcd" "^0.10.0"
|
||||
long "^5.2.0"
|
||||
protobufjs "^6.11.3"
|
||||
|
||||
p-limit@^2.2.0:
|
||||
version "2.3.0"
|
||||
resolved "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz"
|
||||
@ -6714,21 +6736,25 @@ pify@^3.0.0:
|
||||
resolved "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz"
|
||||
integrity sha512-C3FsVNH1udSEX48gGX1xfvwTWfsYWj5U+8/uK15BGzIGrKoUpghX8hWZwa/OFnakBiiVNmBvemTJR5mcy7iPcg==
|
||||
|
||||
"ping-widget@git+https://github.com/ping-pub/widget.git":
|
||||
version "0.0.5"
|
||||
resolved "git+https://github.com/ping-pub/widget.git#11de05f773e60430f332fb77b4a37e5ae8c681b2"
|
||||
ping-widget@^0.0.7:
|
||||
version "0.0.7"
|
||||
resolved "https://registry.yarnpkg.com/ping-widget/-/ping-widget-0.0.7.tgz#441fdc03d1447a24bffb8233a2f55e734948820b"
|
||||
integrity sha512-LbMBnXZUxh0goJXSyGHkM1kzdShmlHq5836QNGbIZFS6oSoCbKyYtbhVhR0l7BuqHpiYYpXbnUM+SN60yqOHVQ==
|
||||
dependencies:
|
||||
"@cosmjs/amino" "^0.30.1"
|
||||
"@cosmjs/ledger-amino" "^0.30.1"
|
||||
"@cosmjs/proto-signing" "^0.30.1"
|
||||
"@cosmjs/stargate" "^0.30.1"
|
||||
"@ledgerhq/hw-transport-web-ble" "^6.27.13"
|
||||
"@ping-pub/chain-registry-client" "^0.0.25"
|
||||
"@tharsis/address-converter" "^0.1.8"
|
||||
"@tharsis/eip712" "^0.2.4"
|
||||
"@tharsis/proto" "^0.1.20"
|
||||
"@tharsis/transactions" "^0.2.6"
|
||||
cross-fetch "^3.1.5"
|
||||
daisyui "^2.51.6"
|
||||
dayjs "^1.11.7"
|
||||
osmojs "^15.2.1"
|
||||
vue "^3.2.47"
|
||||
vue3-webcomponent-wrapper "^0.2.0"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user