diff --git a/src/libs/api.ts b/src/libs/api.ts index a6e465c4..c4e845f3 100644 --- a/src/libs/api.ts +++ b/src/libs/api.ts @@ -1,16 +1,57 @@ -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 }, - posts: { url: "https://jsonplaceholder.typicode.com/posts/1", adapter: convert }, - }; + 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 = { "0.46.1": DEFAULT } const NAME_REGISTRY: Registry = { - "evmos": withCustomAdapter(DEFAULT, {users: {url: "another url", adapter: (): User => {}}}) + "evmos": withCustomAdapter(DEFAULT, {}) } diff --git a/src/libs/registry.ts b/src/libs/registry.ts index ef676d93..09aa8fc9 100644 --- a/src/libs/registry.ts +++ b/src/libs/registry.ts @@ -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; - posts: Request; + auth_params: Request + auth_accounts: Request; + auth_account_address: Request; + + bank_params: Request; + bank_balances_address: Request; + bank_denoms_metadata: Request; + bank_supply: Request; + bank_supply_by_denom: Request; + + distribution_params: Request; + distribution_validator_commission: Request; + distribution_validator_outstanding_rewards: Request; + distribution_validator_slashes: Request; + + slashing_params: Request; + slashing_signing_info: Request; + + gov_params_voting: Request; + gov_params_tally: Request; + gov_params_deposit: Request; + gov_proposals: Request; + gov_proposals_proposal_id: Request; + gov_proposals_deposits: Request; + gov_proposals_tally: Request; + gov_proposals_votes: Request; + gov_proposals_votes_voter: Request; + + staking_deletations: Request; + staking_delegator_redelegations: Request; + staking_delegator_unbonding_delegations: Request; + staking_delegator_validators: Request; + staking_params: Request; + staking_pool: Request; + staking_validators: Request; + staking_validators_address: Request; + staking_validators_delegations: Request; + staking_validators_delegations_delegator: Request; + staking_validators_delegations_unbonding_delegations: Request; + + base_tendermint_abci_query: Request; + base_tendermint_block_latest: Request; + base_tendermint_block_height: Request; + base_tendermint_node_info: Request; + base_tendermint_validatorsets_latest: Request; + base_tendermint_validatorsets_height: Request; + + tx_txs: Request; + tx_txs_block: Request; + tx_hash: Request; + } -export function convert(source: any): T { +export function adapter(source: any): T { return source } diff --git a/src/types/Block.ts b/src/types/Block.ts new file mode 100644 index 00000000..795bc90e --- /dev/null +++ b/src/types/Block.ts @@ -0,0 +1,3 @@ +export interface Block { + +} \ No newline at end of file diff --git a/src/types/NodeInfo.ts b/src/types/NodeInfo.ts new file mode 100644 index 00000000..e210e8ec --- /dev/null +++ b/src/types/NodeInfo.ts @@ -0,0 +1,3 @@ +export interface NodeInfo { + +} \ No newline at end of file diff --git a/src/types/SlashingSigningInfo.ts b/src/types/SlashingSigningInfo.ts new file mode 100644 index 00000000..cc07cb84 --- /dev/null +++ b/src/types/SlashingSigningInfo.ts @@ -0,0 +1,3 @@ +export interface SlashingSigningInfo { + +} \ No newline at end of file diff --git a/src/types/Tx.ts b/src/types/Tx.ts new file mode 100644 index 00000000..2e42aee7 --- /dev/null +++ b/src/types/Tx.ts @@ -0,0 +1,3 @@ +export interface Tx { + +} \ No newline at end of file diff --git a/src/types/Txs.ts b/src/types/Txs.ts new file mode 100644 index 00000000..271847f0 --- /dev/null +++ b/src/types/Txs.ts @@ -0,0 +1,3 @@ +export interface Txs { + +} \ No newline at end of file diff --git a/src/types/index.ts b/src/types/index.ts index 143f4e2c..63a82337 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -1,2 +1,5 @@ export * from './Coin' -export * from './Proposal' \ No newline at end of file +export * from './Proposal' +export * from './NodeInfo' +export * from './Block' +export * from './SlashingSigningInfo' \ No newline at end of file