{{ showType(item.content['@type']) }}
diff --git a/src/libs/client.ts b/src/libs/client.ts
index 2e4560d7..59a3fdab 100644
--- a/src/libs/client.ts
+++ b/src/libs/client.ts
@@ -6,11 +6,12 @@ import {
type RequestRegistry,
type AbstractRegistry,
findApiProfileByChain,
+ findApiProfileBySDKVersion,
registryChainProfile,
+ registryVersionProfile,
withCustomRequest,
} from './registry';
import { PageRequest,type Coin } from '@/types';
-import { CUSTOM } from './custom_api/evmos'
export class BaseRestClient
{
endpoint: string;
@@ -28,15 +29,37 @@ export class BaseRestClient {
}
}
+// dynamic all custom request implementations
+function registeCustomRequest() {
+ const extensions: Record = import.meta.glob('./clients/*.ts', { eager: true });
+ Object.values(extensions).forEach(m => {
+ if(m.store === 'version') {
+ registryVersionProfile(m.name, withCustomRequest(DEFAULT, m.requests))
+ } else {
+ registryChainProfile(m.name, withCustomRequest(DEFAULT, m.requests));
+ }
+ });
+}
+
+registeCustomRequest()
+
export class CosmosRestClient extends BaseRestClient {
static newDefault(endpoint: string) {
return new CosmosRestClient(endpoint, DEFAULT)
}
static newStrategy(endpoint: string, chain: any) {
- registryChainProfile('evmos', withCustomRequest(DEFAULT, CUSTOM))
- const re = findApiProfileByChain(chain.chainName)
- return new CosmosRestClient(endpoint, re || DEFAULT)
+
+ let req
+ if(chain) {
+ // find by name first
+ req = findApiProfileByChain(chain.chainName)
+ // if not found. try sdk version
+ if(!req && chain.versions?.cosmosSdk) {
+ req = findApiProfileBySDKVersion(chain.versions?.cosmosSdk)
+ }
+ }
+ return new CosmosRestClient(endpoint, req || DEFAULT)
}
// Auth Module
diff --git a/src/libs/custom_api/evmos.ts b/src/libs/clients/evmos.ts
similarity index 55%
rename from src/libs/custom_api/evmos.ts
rename to src/libs/clients/evmos.ts
index 5da78cf5..a4fbd277 100644
--- a/src/libs/custom_api/evmos.ts
+++ b/src/libs/clients/evmos.ts
@@ -1,5 +1,9 @@
import type{ RequestRegistry } from '@/libs/registry'
-import { DEFAULT } from '@/libs'
-export const CUSTOM: Partial = {
+
+// which registry is store
+export const store = 'name' // name or version
+// Blockchain Name
+export const name = 'evmos'
+export const requests: Partial = {
mint_inflation: { url: '/evmos/inflation/v1/inflation_rate', adapter: (data: any) => ({inflation: (Number(data.inflation_rate || 0)/ 100 ).toFixed(2)}) },
}
diff --git a/src/libs/clients/v0.46.0.ts b/src/libs/clients/v0.46.0.ts
new file mode 100644
index 00000000..782147eb
--- /dev/null
+++ b/src/libs/clients/v0.46.0.ts
@@ -0,0 +1,67 @@
+import type { RequestRegistry } from '@/libs/registry'
+import { adapter } from '@/libs/registry'
+import type {
+ GovParams,
+ GovProposal,
+ GovVote,
+ PaginatedProposalDeposit,
+ PaginatedProposalVotes,
+ PaginatedProposals,
+ Tally,
+ } from '@/types/';
+
+// which registry is store
+export const store = 'version' // name or version
+// Blockchain Name
+export const name = 'v0.46.7'
+
+function proposalAdapter(p: any): GovProposal {
+ if(p) {
+ if(p.messages) p.content = p.messages[0].content
+ p.proposal_id = p.id
+ p.final_tally_result = {
+ yes: p.final_tally_result?.yes_count,
+ no: p.final_tally_result?.no_count,
+ no_with_veto: p.final_tally_result?.no_with_veto_count,
+ abstain: p.final_tally_result?.abstain_count,
+ }
+ }
+ return p
+}
+
+export const requests: Partial = {
+ gov_params_voting: { url: '/cosmos/gov/v1/params/voting', adapter },
+ gov_params_tally: { url: '/cosmos/gov/v1/params/tallying', adapter },
+ gov_params_deposit: { url: '/cosmos/gov/v1/params/deposit', adapter },
+ gov_proposals: { url: '/cosmos/gov/v1/proposals', adapter: (source: any): PaginatedProposals => {
+ const proposals = source.proposals.map((p:any) => proposalAdapter(p))
+ return {
+ proposals,
+ pagination: source.pagination
+ }
+ }},
+ gov_proposals_proposal_id: {
+ url: '/cosmos/gov/v1/proposals/{proposal_id}',
+ adapter: (source: any): {proposal: GovProposal} => {
+ return {
+ proposal: proposalAdapter(source.proposal)
+ }
+ },
+ },
+ gov_proposals_deposits: {
+ url: '/cosmos/gov/v1/proposals/{proposal_id}/deposits',
+ adapter,
+ },
+ gov_proposals_tally: {
+ url: '/cosmos/gov/v1/proposals/{proposal_id}/tally',
+ adapter,
+ },
+ gov_proposals_votes: {
+ url: '/cosmos/gov/v1/proposals/{proposal_id}/votes',
+ adapter,
+ },
+ gov_proposals_votes_voter: {
+ url: '/cosmos/gov/v1/proposals/{proposal_id}/votes/{voter}',
+ adapter,
+ },
+}
diff --git a/src/libs/registry.ts b/src/libs/registry.ts
index 45c343a0..6696d12e 100644
--- a/src/libs/registry.ts
+++ b/src/libs/registry.ts
@@ -185,28 +185,26 @@ export function findApiProfileByChain(
// if (!url) {
// throw new Error(`Unsupported version or name: ${name}`);
// }
-
return url;
}
export function findApiProfileBySDKVersion(
version: string,
-): RequestRegistry {
+): RequestRegistry | undefined {
let closestVersion: string | null = null;
- for (const key in VERSION_REGISTRY) {
- if (semver.satisfies(key, version)) {
+ for (const k in VERSION_REGISTRY) {
+ const key = k.replace('v', "")
+ // console.log(semver.gt(key, version), semver.gte(version, key), key, version)
+ if (semver.lte(key, version)) {
if (!closestVersion || semver.gt(key, closestVersion)) {
- closestVersion = key;
+ closestVersion = k;
}
}
}
-
+ // console.log(`Closest version to ${version}: ${closestVersion}`, VERSION_REGISTRY);
if (!closestVersion) {
- throw new Error(`Unsupported version: ${version}`);
+ return undefined;
}
-
- console.log(`Closest version to ${version}: ${closestVersion}`);
-
return VERSION_REGISTRY[closestVersion];
}
diff --git a/src/modules/[chain]/staking/index.vue b/src/modules/[chain]/staking/index.vue
index 7a9c6e90..7d96ff15 100644
--- a/src/modules/[chain]/staking/index.vue
+++ b/src/modules/[chain]/staking/index.vue
@@ -2,7 +2,6 @@
import {
useBaseStore,
useBlockchain,
- useDistributionStore,
useFormatter,
useMintStore,
useStakingStore,
@@ -120,7 +119,7 @@ const calculateRank = function (position: number) {
function isFeatured(endpoints: string[], who?: {website?: string, moniker: string }) {
if(!endpoints || !who) return false
- return endpoints.findIndex(x => who.website && who.website?.substring(0, who.website?.lastIndexOf('.')).endsWith(x) || who?.moniker?.toLowerCase().search(x) > -1) > -1
+ return endpoints.findIndex(x => who.website && who.website?.substring(0, who.website?.lastIndexOf('.')).endsWith(x) || who?.moniker?.toLowerCase().search(x.toLowerCase()) > -1) > -1
}
const list = computed(() => {
@@ -307,7 +306,7 @@ loadAvatars();
-
+
{{ v.description?.moniker }}
-
+
{{
v.description?.website ||
v.description?.identity ||
@@ -357,7 +356,7 @@ loadAvatars();
-
+
{{
format.formatToken(
{
diff --git a/src/modules/[chain]/uptime/customize.vue b/src/modules/[chain]/uptime/customize.vue
index 3629f71a..8703e813 100644
--- a/src/modules/[chain]/uptime/customize.vue
+++ b/src/modules/[chain]/uptime/customize.vue
@@ -179,7 +179,9 @@ function color(v: string) {
-
+
+
+
@@ -212,7 +214,7 @@ function color(v: string) {
-
+
diff --git a/src/modules/wallet/accounts.vue b/src/modules/wallet/accounts.vue
index 01fafc04..91a151a3 100644
--- a/src/modules/wallet/accounts.vue
+++ b/src/modules/wallet/accounts.vue
@@ -228,7 +228,7 @@ async function loadBalances(endpoint: string, address: string) {
-
+
@@ -258,9 +258,9 @@ async function loadBalances(endpoint: string, address: string) {
-
+
-
+
-
+
| |