forked from cerc-io/cosmos-explorer
implement request registry
This commit is contained in:
parent
7f477bcd9f
commit
c89bdd06b4
@ -1,8 +1,49 @@
|
||||
import { type RequestRegistry, type Registry, convert, withCustomAdapter } from "./registry";
|
||||
import { type RequestRegistry, type Registry, adapter, withCustomAdapter } from "./registry";
|
||||
|
||||
const DEFAULT: RequestRegistry = {
|
||||
users: { url: "https://jsonplaceholder.typicode.com/users/1", adapter: convert<User> },
|
||||
posts: { url: "https://jsonplaceholder.typicode.com/posts/1", adapter: convert<Post> },
|
||||
auth_params: { url: "/cosmos/auth/v1beta1/params", adapter },
|
||||
auth_accounts: { url: "/cosmos/auth/v1beta1/accounts", adapter },
|
||||
auth_account_address: { url: "/cosmos/auth/v1beta1/accounts/{address}", adapter },
|
||||
bank_params: { url: "/cosmos/bank/v1beta1/params", adapter },
|
||||
bank_balances_address: { url: "/cosmos/bank/v1beta1/balances/{address}", adapter },
|
||||
bank_denoms_metadata: { url: "/cosmos/bank/v1beta1/denoms_metadata", adapter },
|
||||
bank_supply: { url: "/cosmos/bank/v1beta1/supply", adapter },
|
||||
bank_supply_by_denom: { url: "/cosmos/bank/v1beta1/supply/by_denom", adapter },
|
||||
distribution_params: { url: "/cosmos/distribution/v1beta1/params", adapter },
|
||||
distribution_validator_commission: { url: "/cosmos/distribution/v1beta1/validators/{validator_address}/commission", adapter },
|
||||
distribution_validator_outstanding_rewards: { url: "/cosmos/distribution/v1beta1/validators/{validator_address}/outstanding_rewards", adapter },
|
||||
distribution_validator_slashes: { url: "/cosmos/distribution/v1beta1/validators/{validator_address}/slashes", adapter },
|
||||
slashing_params: { url: "/cosmos/slashing/v1beta1/params", adapter },
|
||||
slashing_signing_info: { url: "/cosmos/slashing/v1beta1/signing_infos", adapter },
|
||||
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 },
|
||||
gov_proposals_proposal_id: {url: "/cosmos/gov/v1/proposals/{proposal_id}", adapter},
|
||||
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 },
|
||||
staking_deletations: { url: "/cosmos/staking/v1beta1/delegations/{delegator_addr}", adapter },
|
||||
staking_delegator_redelegations: { url: "/cosmos/staking/v1beta1/delegators/{delegator_addr}/redelegations", adapter },
|
||||
staking_delegator_unbonding_delegations: { url: "/cosmos/staking/v1beta1/delegators/{delegator_addr}/unbonding_delegations", adapter },
|
||||
staking_delegator_validators: { url: "/cosmos/staking/v1beta1/delegators/{delegator_addr}/validators", adapter },
|
||||
staking_params: { url: "/cosmos/staking/v1beta1/params", adapter },
|
||||
staking_pool: { url: "/cosmos/staking/v1beta1/pool", adapter },
|
||||
staking_validators: { url: "/cosmos/staking/v1beta1/validators", adapter },
|
||||
staking_validators_address: { url: "/cosmos/staking/v1beta1/validators/{validator_addr}", adapter },
|
||||
staking_validators_delegations: { url: "/cosmos/staking/v1beta1/validators/{validator_addr}/delegations", adapter },
|
||||
staking_validators_delegations_delegator: { url: "/cosmos/staking/v1beta1/validators/{validator_addr}/delegations/{delegator_addr}", adapter },
|
||||
staking_validators_delegations_unbonding_delegations: { url: "/cosmos/staking/v1beta1/validators/{validator_addr}/delegations/{delegator_addr}/unbonding_delegation", adapter },
|
||||
base_tendermint_abci_query: { url: "/cosmos/base/tendermint/v1beta1/abci_query", adapter },
|
||||
base_tendermint_block_latest: { url: "/cosmos/base/tendermint/v1beta1/blocks/latest", adapter },
|
||||
base_tendermint_block_height: { url: "/cosmos/base/tendermint/v1beta1/blocks/{height}", adapter },
|
||||
base_tendermint_node_info: { url: "/cosmos/base/tendermint/v1beta1/node_info", adapter },
|
||||
base_tendermint_validatorsets_latest: { url: "/cosmos/base/tendermint/v1beta1/validatorsets/latest", adapter },
|
||||
base_tendermint_validatorsets_height: { url: "/cosmos/base/tendermint/v1beta1/validatorsets/{height}", adapter },
|
||||
tx_txs: { url: "/cosmos/tx/v1beta1/txs", adapter },
|
||||
tx_txs_block: { url: "/cosmos/tx/v1beta1/txs/block/{height}", adapter },
|
||||
tx_hash: { url: "/cosmos/tx/v1beta1/txs/{hash}", adapter },
|
||||
};
|
||||
|
||||
const VERSION_REGISTRY: Registry = {
|
||||
@ -10,7 +51,7 @@ const VERSION_REGISTRY: Registry = {
|
||||
}
|
||||
|
||||
const NAME_REGISTRY: Registry = {
|
||||
"evmos": withCustomAdapter(DEFAULT, {users: {url: "another url", adapter: (): User => {}}})
|
||||
"evmos": withCustomAdapter(DEFAULT, {})
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
import type { Block, NodeInfo, SlashingSigningInfo } from "@/types";
|
||||
import type { Tx } from "@/types/Tx";
|
||||
import type { Txs } from "@/types/Txs";
|
||||
import semver from "semver";
|
||||
|
||||
|
||||
@ -14,12 +17,62 @@ interface Post {
|
||||
|
||||
}
|
||||
|
||||
// use snake style, since the all return object use snake style.
|
||||
export interface RequestRegistry {
|
||||
users: Request<User>;
|
||||
posts: Request<Post>;
|
||||
auth_params: Request<any>
|
||||
auth_accounts: Request<any>;
|
||||
auth_account_address: Request<any>;
|
||||
|
||||
bank_params: Request<any>;
|
||||
bank_balances_address: Request<any>;
|
||||
bank_denoms_metadata: Request<any>;
|
||||
bank_supply: Request<any>;
|
||||
bank_supply_by_denom: Request<any>;
|
||||
|
||||
distribution_params: Request<any>;
|
||||
distribution_validator_commission: Request<any>;
|
||||
distribution_validator_outstanding_rewards: Request<any>;
|
||||
distribution_validator_slashes: Request<any>;
|
||||
|
||||
slashing_params: Request<any>;
|
||||
slashing_signing_info: Request<SlashingSigningInfo>;
|
||||
|
||||
gov_params_voting: Request<any>;
|
||||
gov_params_tally: Request<any>;
|
||||
gov_params_deposit: Request<any>;
|
||||
gov_proposals: Request<any>;
|
||||
gov_proposals_proposal_id: Request<any>;
|
||||
gov_proposals_deposits: Request<any>;
|
||||
gov_proposals_tally: Request<any>;
|
||||
gov_proposals_votes: Request<any>;
|
||||
gov_proposals_votes_voter: Request<any>;
|
||||
|
||||
staking_deletations: Request<any>;
|
||||
staking_delegator_redelegations: Request<any>;
|
||||
staking_delegator_unbonding_delegations: Request<any>;
|
||||
staking_delegator_validators: Request<any>;
|
||||
staking_params: Request<any>;
|
||||
staking_pool: Request<any>;
|
||||
staking_validators: Request<any>;
|
||||
staking_validators_address: Request<any>;
|
||||
staking_validators_delegations: Request<any>;
|
||||
staking_validators_delegations_delegator: Request<any>;
|
||||
staking_validators_delegations_unbonding_delegations: Request<any>;
|
||||
|
||||
base_tendermint_abci_query: Request<any>;
|
||||
base_tendermint_block_latest: Request<Block>;
|
||||
base_tendermint_block_height: Request<Block>;
|
||||
base_tendermint_node_info: Request<NodeInfo>;
|
||||
base_tendermint_validatorsets_latest: Request<any>;
|
||||
base_tendermint_validatorsets_height: Request<any>;
|
||||
|
||||
tx_txs: Request<any>;
|
||||
tx_txs_block: Request<any>;
|
||||
tx_hash: Request<any>;
|
||||
|
||||
}
|
||||
|
||||
export function convert<T>(source: any): T {
|
||||
export function adapter<T>(source: any): T {
|
||||
return source
|
||||
}
|
||||
|
||||
|
3
src/types/Block.ts
Normal file
3
src/types/Block.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export interface Block {
|
||||
|
||||
}
|
3
src/types/NodeInfo.ts
Normal file
3
src/types/NodeInfo.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export interface NodeInfo {
|
||||
|
||||
}
|
3
src/types/SlashingSigningInfo.ts
Normal file
3
src/types/SlashingSigningInfo.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export interface SlashingSigningInfo {
|
||||
|
||||
}
|
3
src/types/Tx.ts
Normal file
3
src/types/Tx.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export interface Tx {
|
||||
|
||||
}
|
3
src/types/Txs.ts
Normal file
3
src/types/Txs.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export interface Txs {
|
||||
|
||||
}
|
@ -1,2 +1,5 @@
|
||||
export * from './Coin'
|
||||
export * from './Proposal'
|
||||
export * from './NodeInfo'
|
||||
export * from './Block'
|
||||
export * from './SlashingSigningInfo'
|
Loading…
Reference in New Issue
Block a user