diff --git a/src/libs/address.ts b/src/libs/address.ts index b05597b9..a4edcbe2 100644 --- a/src/libs/address.ts +++ b/src/libs/address.ts @@ -1,7 +1,5 @@ import {fromBase64, fromBech32, fromHex, toBase64, toBech32, toHex} from '@cosmjs/encoding' import { Ripemd160, sha256 } from '@cosmjs/crypto' -import { cosmos } from '@ping-pub/codegen' -import type { PubKey } from '@ping-pub/codegen/src/cosmos/crypto/ed25519/keys' export function decodeAddress(address: string) { return fromBech32(address) @@ -25,41 +23,27 @@ export function valoperToPrefix(valoper?: string) { } return toBech32(prefix.replace('valoper', ''), data) } - - export function decodeKey(consensusPubkey: {typeUrl: string, value: Uint8Array}) { - let raw = null - if (consensusPubkey.typeUrl === '/cosmos.crypto.ed25519.PubKey') { - const pubkey = cosmos.crypto.ed25519.PubKey.decode(consensusPubkey.value) - return pubkey - } - - if (consensusPubkey.typeUrl === '/cosmos.crypto.secp256k1.PubKey') { - const pubkey = cosmos.crypto.secp256k1.PubKey.decode(consensusPubkey.value) - return pubkey - } - return raw - - } -export function consensusPubkeyToHexAddress(consensusPubkey?: {typeUrl: string, value: Uint8Array}) { + +export function consensusPubkeyToHexAddress(consensusPubkey?: {"@type": string, key: string}) { if(!consensusPubkey) return "" let raw = "" - if (consensusPubkey.typeUrl === '/cosmos.crypto.ed25519.PubKey') { - const pubkey = decodeKey(consensusPubkey) - if(pubkey) return toHex(sha256(pubkey.key)).slice(0, 40).toUpperCase() + if (consensusPubkey['@type'] === '/cosmos.crypto.ed25519.PubKey') { + const pubkey = fromBase64(consensusPubkey.key) + if(pubkey) return toHex(sha256(pubkey)).slice(0, 40).toUpperCase() } - if (consensusPubkey.typeUrl === '/cosmos.crypto.secp256k1.PubKey') { - const pubkey = decodeKey(consensusPubkey) - if(pubkey) return toHex(new Ripemd160().update(sha256(pubkey.key)).digest()) + if (consensusPubkey['@type'] === '/cosmos.crypto.secp256k1.PubKey') { + const pubkey = fromBase64(consensusPubkey.key) + if(pubkey) return toHex(new Ripemd160().update(sha256(pubkey)).digest()) } return raw } - export function pubKeyToValcons(consensusPubkey: {typeUrl: string, value: Uint8Array}, prefix: string) { - const pubkey = decodeKey(consensusPubkey) + export function pubKeyToValcons(consensusPubkey: {"@type": string, key: string}, prefix: string) { + const pubkey = fromBase64(consensusPubkey.key) if(pubkey) { - const addressData = sha256(pubkey.key).slice(0, 20) + const addressData = sha256(pubkey).slice(0, 20) return toBech32(`${prefix}valcons`, addressData) } } diff --git a/src/libs/extensions/OsmosMintExtention.ts b/src/libs/extensions/OsmosMintExtention.ts deleted file mode 100644 index c5723062..00000000 --- a/src/libs/extensions/OsmosMintExtention.ts +++ /dev/null @@ -1,38 +0,0 @@ -import type { LCDClient } from "@osmonauts/lcd"; -import type { QueryAnnualProvisionsRequest, QueryAnnualProvisionsResponseSDKType, QueryInflationRequest, QueryInflationResponseSDKType, QueryParamsRequest, QueryParamsResponseSDKType } from '@ping-pub/codegen/src/cosmos/mint/v1beta1/query' - -export class OsmosisMintClient { - req: LCDClient; - - constructor({ - requestClient - }: { - requestClient: LCDClient; - }) { - this.req = requestClient; - this.params = this.params.bind(this); - this.inflation = this.inflation.bind(this); - this.annualProvisions = this.annualProvisions.bind(this); - } - /* Params returns the total set of minting parameters. */ - - - async params(_params: QueryParamsRequest = {}): Promise { - const endpoint = `cosmos/mint/v1beta1/params`; - return await this.req.get(endpoint); - } - /* Inflation returns the current minting inflation value. */ - - - async inflation(_params: QueryInflationRequest = {}): Promise { - const endpoint = `cosmos/mint/v1beta1/inflation`; - return await this.req.get(endpoint); - } - /* AnnualProvisions current minting annual provisions value. */ - - - async annualProvisions(_params: QueryAnnualProvisionsRequest = {}): Promise { - const endpoint = `cosmos/mint/v1beta1/annual_provisions`; - return await this.req.get(endpoint); - } -} \ No newline at end of file diff --git a/src/libs/index.ts b/src/libs/index.ts index af58bf6f..42332c20 100644 --- a/src/libs/index.ts +++ b/src/libs/index.ts @@ -1,4 +1,3 @@ export * from './address' -export * from './client' export * from './http' export * from './misc' \ No newline at end of file diff --git a/src/libs/misc.ts b/src/libs/misc.ts index 7d923407..464768e1 100644 --- a/src/libs/misc.ts +++ b/src/libs/misc.ts @@ -1,6 +1,5 @@ import { sha256 } from "@cosmjs/crypto"; import { toHex } from "@cosmjs/encoding"; -import { PageRequest } from "@ping-pub/codegen/src/cosmos/base/query/v1beta1/pagination"; export function newPageRequest(param: { key?: Uint8Array, @@ -9,9 +8,7 @@ export function newPageRequest(param: { countTotal?: boolean, reverse?: boolean }) { - return PageRequest.fromPartial( - param - ) + return param } export function hashTx(raw: Uint8Array) { diff --git a/src/libs/registry.ts b/src/libs/registry.ts index 09aa8fc9..3e396597 100644 --- a/src/libs/registry.ts +++ b/src/libs/registry.ts @@ -9,14 +9,6 @@ export interface Request { adapter: (source: any) => T } -interface User { - -} - -interface Post { - -} - // use snake style, since the all return object use snake style. export interface RequestRegistry { auth_params: Request @@ -66,9 +58,9 @@ export interface RequestRegistry { base_tendermint_validatorsets_latest: Request; base_tendermint_validatorsets_height: Request; - tx_txs: Request; - tx_txs_block: Request; - tx_hash: Request; + tx_txs: Request; + tx_txs_block: Request; + tx_hash: Request; } diff --git a/src/modules/[chain]/block/block.ts b/src/modules/[chain]/block/block.ts index 6c20aa7b..ec2f0b60 100644 --- a/src/modules/[chain]/block/block.ts +++ b/src/modules/[chain]/block/block.ts @@ -1,16 +1,15 @@ import { defineStore } from "pinia"; import { decodeTxRaw, type DecodedTxRaw } from '@cosmjs/proto-signing' -import { createBaseClientForChain } from "@/libs/client"; import { useBlockchain } from "@/stores"; -import type { GetLatestBlockResponse, GetLatestBlockResponseSDKType } from "@ping-pub/codegen/src/cosmos/base/tendermint/v1beta1/query"; import { hashTx } from "@/libs"; +import type { Block } from "@/types"; export const useBlockModule = defineStore('blockModule', { state: () => { return { - latest: {} as GetLatestBlockResponse, - current: {} as GetLatestBlockResponse, - recents: [] as GetLatestBlockResponse[] + latest: {} as Block, + current: {} as Block, + recents: [] as Block[] } }, getters: { diff --git a/src/modules/[chain]/indexStore.ts b/src/modules/[chain]/indexStore.ts index 7cdaf322..b62ec33e 100644 --- a/src/modules/[chain]/indexStore.ts +++ b/src/modules/[chain]/indexStore.ts @@ -2,7 +2,6 @@ import { useBlockchain, useCoingecko, useBaseStore, useBankStore, useFormatter, import { useDistributionStore } from "@/stores/useDistributionStore"; import { useMintStore } from "@/stores/useMintStore"; import { useStakingStore } from "@/stores/useStakingStore"; -import { ProposalStatus, type ProposalSDKType, Proposal } from "@ping-pub/codegen/src/cosmos/gov/v1beta1/gov"; import numeral from "numeral"; import { defineStore } from "pinia"; diff --git a/src/modules/[chain]/staking/[validator].vue b/src/modules/[chain]/staking/[validator].vue index a93ef686..c9e73932 100644 --- a/src/modules/[chain]/staking/[validator].vue +++ b/src/modules/[chain]/staking/[validator].vue @@ -1,13 +1,12 @@ \ No newline at end of file diff --git a/src/pages/index.vue b/src/pages/index.vue index 18801721..16de169c 100644 --- a/src/pages/index.vue +++ b/src/pages/index.vue @@ -4,9 +4,6 @@ import ChainSummary from '@/components/ChainSummary.vue'; import { computed, ref } from 'vue'; import { useBlockchain } from '@/stores'; -import { Tendermint34Client } from "@cosmjs/tendermint-rpc"; -import { QueryClient, setupBankExtension, setupDistributionExtension, setupGovExtension, setupMintExtension, setupStakingExtension } from "@cosmjs/stargate"; - const dashboard = useDashboard() dashboard.$subscribe((mutation, state) => { diff --git a/src/stores/useBlockchain.ts b/src/stores/useBlockchain.ts index 728c74f8..0df64d32 100644 --- a/src/stores/useBlockchain.ts +++ b/src/stores/useBlockchain.ts @@ -1,6 +1,5 @@ import { defineStore } from "pinia"; import { useDashboard, type ChainConfig, type Endpoint, EndpointType } from "./useDashboard"; -import { LCDClient } from '@osmonauts/lcd' import type { VerticalNavItems } from '@/@layouts/types' import { useRouter } from "vue-router"; import { useStakingStore } from "./useStakingStore"; diff --git a/src/stores/useFormatter.ts b/src/stores/useFormatter.ts index 4149c056..df39abb6 100644 --- a/src/stores/useFormatter.ts +++ b/src/stores/useFormatter.ts @@ -1,6 +1,5 @@ import { defineStore } from "pinia"; import { useBlockchain } from "./useBlockchain"; -import Long from "long"; import numeral from "numeral"; import dayjs from 'dayjs'; import duration from 'dayjs/plugin/duration' @@ -9,8 +8,8 @@ import updateLocale from 'dayjs/plugin/updateLocale' import utc from 'dayjs/plugin/utc' import localeData from 'dayjs/plugin/localeData' import { useStakingStore } from "./useStakingStore"; -import { fromBech32, toBase64, toHex } from "@cosmjs/encoding"; -import { consensusPubkeyToHexAddress, operatorAddressToAccount } from "@/libs"; +import { toHex } from "@cosmjs/encoding"; +import { consensusPubkeyToHexAddress } from "@/libs"; dayjs.extend(localeData) dayjs.extend(duration) diff --git a/src/stores/useGovStore.ts b/src/stores/useGovStore.ts index 24a13011..2c76cc5f 100644 --- a/src/stores/useGovStore.ts +++ b/src/stores/useGovStore.ts @@ -1,16 +1,13 @@ import { defineStore } from "pinia"; import { useBlockchain } from "./useBlockchain"; -import { createGovRestClientForChain } from "@/libs/client"; -import { Tendermint34Client } from "@cosmjs/tendermint-rpc"; -import { QueryClient } from "@cosmjs/stargate"; export const useGovStore = defineStore('govStore', { state: () => { return { params: { - deposit: {} as DepositParams, - voting: {} as VotingParams, - tally: {} as TallyParams, + deposit: {}, + voting: {}, + tally: {}, } } },