finish all return type
This commit is contained in:
parent
20099d88d8
commit
727f8ea026
@ -7,6 +7,7 @@
|
|||||||
"serve": "vite",
|
"serve": "vite",
|
||||||
"build": "run-p type-check build-only",
|
"build": "run-p type-check build-only",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
|
"test": "jest",
|
||||||
"build-only": "vite build",
|
"build-only": "vite build",
|
||||||
"type-check": "vue-tsc --noEmit",
|
"type-check": "vue-tsc --noEmit",
|
||||||
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"
|
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"
|
||||||
@ -46,6 +47,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@osmonauts/telescope": "^0.88.2",
|
"@osmonauts/telescope": "^0.88.2",
|
||||||
"@rushstack/eslint-patch": "^1.1.4",
|
"@rushstack/eslint-patch": "^1.1.4",
|
||||||
|
"@types/jest": "^29.5.0",
|
||||||
"@types/marked": "^4.0.8",
|
"@types/marked": "^4.0.8",
|
||||||
"@types/node": "^18.11.12",
|
"@types/node": "^18.11.12",
|
||||||
"@types/numeral": "^2.0.2",
|
"@types/numeral": "^2.0.2",
|
||||||
@ -55,6 +57,7 @@
|
|||||||
"@vue/tsconfig": "^0.1.3",
|
"@vue/tsconfig": "^0.1.3",
|
||||||
"eslint": "^8.22.0",
|
"eslint": "^8.22.0",
|
||||||
"eslint-plugin-vue": "^9.3.0",
|
"eslint-plugin-vue": "^9.3.0",
|
||||||
|
"jest": "^29.5.0",
|
||||||
"npm-run-all": "^4.1.5",
|
"npm-run-all": "^4.1.5",
|
||||||
"prettier": "^2.7.1",
|
"prettier": "^2.7.1",
|
||||||
"sass": "^1.58.0",
|
"sass": "^1.58.0",
|
||||||
|
@ -8,22 +8,22 @@ export const DEFAULT: RequestRegistry = {
|
|||||||
bank_balances_address: { url: "/cosmos/bank/v1beta1/balances/{address}", adapter },
|
bank_balances_address: { url: "/cosmos/bank/v1beta1/balances/{address}", adapter },
|
||||||
bank_denoms_metadata: { url: "/cosmos/bank/v1beta1/denoms_metadata", adapter },
|
bank_denoms_metadata: { url: "/cosmos/bank/v1beta1/denoms_metadata", adapter },
|
||||||
bank_supply: { url: "/cosmos/bank/v1beta1/supply", adapter },
|
bank_supply: { url: "/cosmos/bank/v1beta1/supply", adapter },
|
||||||
bank_supply_by_denom: { url: "/cosmos/bank/v1beta1/supply/by_denom", adapter },
|
bank_supply_by_denom: { url: "/cosmos/bank/v1beta1/supply/{denom}", adapter },
|
||||||
distribution_params: { url: "/cosmos/distribution/v1beta1/params", adapter },
|
distribution_params: { url: "/cosmos/distribution/v1beta1/params", adapter },
|
||||||
distribution_validator_commission: { url: "/cosmos/distribution/v1beta1/validators/{validator_address}/commission", 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_outstanding_rewards: { url: "/cosmos/distribution/v1beta1/validators/{validator_address}/outstanding_rewards", adapter },
|
||||||
distribution_validator_slashes: { url: "/cosmos/distribution/v1beta1/validators/{validator_address}/slashes", adapter },
|
distribution_validator_slashes: { url: "/cosmos/distribution/v1beta1/validators/{validator_address}/slashes", adapter },
|
||||||
slashing_params: { url: "/cosmos/slashing/v1beta1/params", adapter },
|
slashing_params: { url: "/cosmos/slashing/v1beta1/params", adapter },
|
||||||
slashing_signing_info: { url: "/cosmos/slashing/v1beta1/signing_infos", adapter },
|
slashing_signing_info: { url: "/cosmos/slashing/v1beta1/signing_infos", adapter },
|
||||||
gov_params_voting: { url: "/cosmos/gov/v1/params/voting", adapter },
|
gov_params_voting: { url: "/cosmos/gov/v1beta1/params/voting", adapter },
|
||||||
gov_params_tally: { url: "/cosmos/gov/v1/params/tallying", adapter },
|
gov_params_tally: { url: "/cosmos/gov/v1beta1/params/tallying", adapter },
|
||||||
gov_params_deposit: { url: "/cosmos/gov/v1/params/deposit", adapter },
|
gov_params_deposit: { url: "/cosmos/gov/v1beta1/params/deposit", adapter },
|
||||||
gov_proposals: { url: "/cosmos/gov/v1/proposals", adapter },
|
gov_proposals: { url: "/cosmos/gov/v1beta1/proposals", adapter },
|
||||||
gov_proposals_proposal_id: {url: "/cosmos/gov/v1/proposals/{proposal_id}", adapter},
|
gov_proposals_proposal_id: {url: "/cosmos/gov/v1beta1/proposals/{proposal_id}", adapter},
|
||||||
gov_proposals_deposits: { url: "/cosmos/gov/v1/proposals/{proposal_id}/deposits", adapter },
|
gov_proposals_deposits: { url: "/cosmos/gov/v1beta1/proposals/{proposal_id}/deposits", adapter },
|
||||||
gov_proposals_tally: { url: "/cosmos/gov/v1/proposals/{proposal_id}/tally", adapter },
|
gov_proposals_tally: { url: "/cosmos/gov/v1beta1/proposals/{proposal_id}/tally", adapter },
|
||||||
gov_proposals_votes: { url: "/cosmos/gov/v1/proposals/{proposal_id}/votes", adapter },
|
gov_proposals_votes: { url: "/cosmos/gov/v1beta1/proposals/{proposal_id}/votes", adapter },
|
||||||
gov_proposals_votes_voter: { url: "/cosmos/gov/v1/proposals/{proposal_id}/votes/{voter}", adapter },
|
gov_proposals_votes_voter: { url: "/cosmos/gov/v1beta1/proposals/{proposal_id}/votes/{voter}", adapter },
|
||||||
staking_deletations: { url: "/cosmos/staking/v1beta1/delegations/{delegator_addr}", 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_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_unbonding_delegations: { url: "/cosmos/staking/v1beta1/delegators/{delegator_addr}/unbonding_delegations", adapter },
|
||||||
|
@ -139,7 +139,7 @@ export class CosmosRestClient {
|
|||||||
return this.request(this.registry.base_tendermint_validatorsets_height, {height})
|
return this.request(this.registry.base_tendermint_validatorsets_height, {height})
|
||||||
}
|
}
|
||||||
async getBaseValidatorsetLatest() {
|
async getBaseValidatorsetLatest() {
|
||||||
return this.request(this.registry.base_tendermint_block_latest, {})
|
return this.request(this.registry.base_tendermint_validatorsets_latest, {})
|
||||||
}
|
}
|
||||||
// tx
|
// tx
|
||||||
async getTxsBySender(sender: string) {
|
async getTxsBySender(sender: string) {
|
||||||
@ -150,7 +150,7 @@ export class CosmosRestClient {
|
|||||||
return this.request(this.registry.tx_txs_block, {height})
|
return this.request(this.registry.tx_txs_block, {height})
|
||||||
}
|
}
|
||||||
async getTx(hash: string) {
|
async getTx(hash: string) {
|
||||||
return this.request(this.registry.tx_hash, {})
|
return this.request(this.registry.tx_hash, {hash})
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
import type { Block, NodeInfo, SlashingSigningInfo } from "@/types";
|
import type { Block, Coin, NodeInfo, PaginatedTendermintValidator, SlashingSigningInfo } from "@/types";
|
||||||
import type { PaginabledAccounts } from "@/types/Auth";
|
import type { AuthAccount, PaginabledAccounts } from "@/types/Auth";
|
||||||
import type { Tx } from "@/types/Tx";
|
import type { PaginatedTxs, Tx, TxResponse } from "@/types/Tx";
|
||||||
import type { Txs } from "@/types/Txs";
|
import type { Txs } from "@/types/Txs";
|
||||||
import type { PaginatedDenomMetadata, PaginatedSupply } from "@/types/bank";
|
import type { BankParams, PaginatedBalances, PaginatedDenomMetadata, PaginatedSupply } from "@/types/bank";
|
||||||
|
import type { DistributionParams, PaginatedSlashes } from "@/types/distribution";
|
||||||
|
import type { GovParams, GovProposal, GovVote, PaginatedProposalDeposit, PaginatedProposalVotes, PaginatedProposals, Tally } from "@/types/gov";
|
||||||
|
import type { Delegation, PaginatedDelegations, PaginatedRedelegations, PaginatedUnbonding, PaginatedValdiators, StakingParam, StakingPool, Validator } from "@/types/staking";
|
||||||
import semver from "semver";
|
import semver from "semver";
|
||||||
|
|
||||||
|
|
||||||
@ -15,54 +18,54 @@ export interface Request<T> {
|
|||||||
export interface RequestRegistry {
|
export interface RequestRegistry {
|
||||||
auth_params: Request<any>
|
auth_params: Request<any>
|
||||||
auth_accounts: Request<PaginabledAccounts>;
|
auth_accounts: Request<PaginabledAccounts>;
|
||||||
auth_account_address: Request<any>;
|
auth_account_address: Request<{account: AuthAccount}>;
|
||||||
|
|
||||||
bank_params: Request<any>;
|
bank_params: Request<BankParams>;
|
||||||
bank_balances_address: Request<any>;
|
bank_balances_address: Request<PaginatedBalances>;
|
||||||
bank_denoms_metadata: Request<PaginatedDenomMetadata>;
|
bank_denoms_metadata: Request<PaginatedDenomMetadata>;
|
||||||
bank_supply: Request<PaginatedSupply>;
|
bank_supply: Request<PaginatedSupply>;
|
||||||
bank_supply_by_denom: Request<any>;
|
bank_supply_by_denom: Request<{amount: Coin}>;
|
||||||
|
|
||||||
distribution_params: Request<any>;
|
distribution_params: Request<DistributionParams>;
|
||||||
distribution_validator_commission: Request<any>;
|
distribution_validator_commission: Request<{commission?: {commission?: Coin[]}}>;
|
||||||
distribution_validator_outstanding_rewards: Request<any>;
|
distribution_validator_outstanding_rewards: Request<{rewards?: {rewards?: Coin[]}}>;
|
||||||
distribution_validator_slashes: Request<any>;
|
distribution_validator_slashes: Request<PaginatedSlashes>;
|
||||||
|
|
||||||
slashing_params: Request<any>;
|
slashing_params: Request<any>;
|
||||||
slashing_signing_info: Request<SlashingSigningInfo>;
|
slashing_signing_info: Request<SlashingSigningInfo>;
|
||||||
|
|
||||||
gov_params_voting: Request<any>;
|
gov_params_voting: Request<GovParams>;
|
||||||
gov_params_tally: Request<any>;
|
gov_params_tally: Request<GovParams>;
|
||||||
gov_params_deposit: Request<any>;
|
gov_params_deposit: Request<GovParams>;
|
||||||
gov_proposals: Request<any>;
|
gov_proposals: Request<PaginatedProposals>;
|
||||||
gov_proposals_proposal_id: Request<any>;
|
gov_proposals_proposal_id: Request<{proposal: GovProposal}>;
|
||||||
gov_proposals_deposits: Request<any>;
|
gov_proposals_deposits: Request<PaginatedProposalDeposit>;
|
||||||
gov_proposals_tally: Request<any>;
|
gov_proposals_tally: Request<Tally>;
|
||||||
gov_proposals_votes: Request<any>;
|
gov_proposals_votes: Request<PaginatedProposalVotes>;
|
||||||
gov_proposals_votes_voter: Request<any>;
|
gov_proposals_votes_voter: Request<{vote: GovVote}>;
|
||||||
|
|
||||||
staking_deletations: Request<any>;
|
staking_deletations: Request<PaginatedDelegations>;
|
||||||
staking_delegator_redelegations: Request<any>;
|
staking_delegator_redelegations: Request<PaginatedRedelegations>;
|
||||||
staking_delegator_unbonding_delegations: Request<any>;
|
staking_delegator_unbonding_delegations: Request<PaginatedUnbonding>;
|
||||||
staking_delegator_validators: Request<any>;
|
staking_delegator_validators: Request<PaginatedValdiators>;
|
||||||
staking_params: Request<any>;
|
staking_params: Request<StakingParam>;
|
||||||
staking_pool: Request<any>;
|
staking_pool: Request<StakingPool>;
|
||||||
staking_validators: Request<any>;
|
staking_validators: Request<PaginatedValdiators>;
|
||||||
staking_validators_address: Request<any>;
|
staking_validators_address: Request<{validator: Validator}>;
|
||||||
staking_validators_delegations: Request<any>;
|
staking_validators_delegations: Request<PaginatedDelegations>;
|
||||||
staking_validators_delegations_delegator: Request<any>;
|
staking_validators_delegations_delegator: Request<{delegation_response: Delegation}>;
|
||||||
staking_validators_delegations_unbonding_delegations: Request<any>;
|
staking_validators_delegations_unbonding_delegations: Request<any>;
|
||||||
|
|
||||||
base_tendermint_abci_query: Request<any>;
|
base_tendermint_abci_query: Request<any>;
|
||||||
base_tendermint_block_latest: Request<Block>;
|
base_tendermint_block_latest: Request<Block>;
|
||||||
base_tendermint_block_height: Request<Block>;
|
base_tendermint_block_height: Request<Block>;
|
||||||
base_tendermint_node_info: Request<NodeInfo>;
|
base_tendermint_node_info: Request<NodeInfo>;
|
||||||
base_tendermint_validatorsets_latest: Request<any>;
|
base_tendermint_validatorsets_latest: Request<PaginatedTendermintValidator>;
|
||||||
base_tendermint_validatorsets_height: Request<any>;
|
base_tendermint_validatorsets_height: Request<PaginatedTendermintValidator>;
|
||||||
|
|
||||||
tx_txs: Request<Txs>;
|
tx_txs: Request<PaginatedTxs>;
|
||||||
tx_txs_block: Request<Txs>;
|
tx_txs_block: Request<Txs>;
|
||||||
tx_hash: Request<Tx>;
|
tx_hash: Request<{tx: Tx, tx_response: TxResponse}>;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,14 @@
|
|||||||
<script lang="ts" setup>
|
<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.getTx("EFF175AF4D46532CFACA4A0F0748DFF1EF8CC1C96DA967D8AFB794EFE048461C");
|
||||||
|
console.log('response:', response)
|
||||||
|
}
|
||||||
|
tt()
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div>Hello wallet</div>
|
<div>Hello wallet</div>
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
export interface Block {
|
|
||||||
|
|
||||||
}
|
|
@ -1,4 +0,0 @@
|
|||||||
export interface Coin {
|
|
||||||
amount: string|number;
|
|
||||||
denom: string;
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
export interface NodeInfo {
|
|
||||||
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
export interface Pagination {
|
|
||||||
key?: string;
|
|
||||||
total?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface PaginatedResponse {
|
|
||||||
pagination: Pagination;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
class PaginatedResponse<T, K extends string> {
|
|
||||||
[key: string]: T[];
|
|
||||||
pagination: Pagination;
|
|
||||||
|
|
||||||
constructor(data: T[], pagination: Pagination, dataFieldName: K) {
|
|
||||||
this.pagination = pagination;
|
|
||||||
this[dataFieldName] = data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// */
|
|
@ -1,5 +0,0 @@
|
|||||||
export class Proposal {
|
|
||||||
type: string = '';
|
|
||||||
title: string = '';
|
|
||||||
description: string = ''
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
export interface SlashingSigningInfo {
|
|
||||||
|
|
||||||
}
|
|
@ -1,3 +1,68 @@
|
|||||||
export interface Tx {
|
import type { Coin, Key, PaginatedResponse } from "./common"
|
||||||
|
|
||||||
|
export interface Tx {
|
||||||
|
"@type"?: string,
|
||||||
|
"body": {
|
||||||
|
"messages": {"@type": string}[],
|
||||||
|
"memo": string,
|
||||||
|
"timeout_height": string,
|
||||||
|
"extension_options": any[],
|
||||||
|
"non_critical_extension_options": any[]
|
||||||
|
},
|
||||||
|
"auth_info": {
|
||||||
|
"signer_infos": [
|
||||||
|
{
|
||||||
|
"public_key": Key,
|
||||||
|
"mode_info": {
|
||||||
|
"single"?: {
|
||||||
|
"mode": string // "SIGN_MODE_DIRECT"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sequence": string
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"fee": {
|
||||||
|
"amount": Coin[],
|
||||||
|
"gas_limit": string,
|
||||||
|
"payer": string,
|
||||||
|
"granter": string
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"signatures": string[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Attributes {
|
||||||
|
index?: boolean,
|
||||||
|
key: string,
|
||||||
|
value: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TxResponse {
|
||||||
|
"height": string,
|
||||||
|
"txhash": string,
|
||||||
|
"codespace": string,
|
||||||
|
"code": number,
|
||||||
|
"data": string,
|
||||||
|
"raw_log": string,
|
||||||
|
"logs": [
|
||||||
|
{
|
||||||
|
"msg_index": number,
|
||||||
|
"log": string,
|
||||||
|
"events": Attributes[]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info": "",
|
||||||
|
"gas_wanted": "204431",
|
||||||
|
"gas_used": "202682",
|
||||||
|
"tx": Tx,
|
||||||
|
"timestamp": "2022-08-13T23:24:54Z",
|
||||||
|
"events": {
|
||||||
|
"type": string,
|
||||||
|
"attributes": Attributes[]
|
||||||
|
}[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PaginatedTxs extends PaginatedResponse {
|
||||||
|
txs: Tx[]
|
||||||
|
tx_responses: TxResponse[]
|
||||||
}
|
}
|
@ -1,3 +0,0 @@
|
|||||||
export interface Txs {
|
|
||||||
|
|
||||||
}
|
|
@ -1,5 +1,5 @@
|
|||||||
import type { PaginatedResponse } from "./Pagination";
|
|
||||||
import type { Key } from "./common";
|
import type { Key, PaginatedResponse } from "./common";
|
||||||
|
|
||||||
export interface AuthAccount {
|
export interface AuthAccount {
|
||||||
"@type": string,
|
"@type": string,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import type { Coin } from "./Coin";
|
|
||||||
import type { PaginatedResponse } from "./Pagination";
|
import type { Coin, PaginatedResponse } from "./common";
|
||||||
|
|
||||||
export interface BankParams {
|
export interface BankParams {
|
||||||
params: {
|
params: {
|
||||||
@ -21,6 +21,10 @@ export interface DenomMetadata {
|
|||||||
"symbol": string
|
"symbol": string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface PaginatedBalances extends PaginatedResponse{
|
||||||
|
balances: Coin[]
|
||||||
|
}
|
||||||
|
|
||||||
export interface PaginatedDenomMetadata extends PaginatedResponse{
|
export interface PaginatedDenomMetadata extends PaginatedResponse{
|
||||||
metadatas: DenomMetadata[]
|
metadatas: DenomMetadata[]
|
||||||
}
|
}
|
||||||
|
53
src/types/base.ts
Normal file
53
src/types/base.ts
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
import type { Key } from "./common"
|
||||||
|
|
||||||
|
export interface NodeInfo {
|
||||||
|
"default_node_info": {
|
||||||
|
"protocol_version": {
|
||||||
|
"p2p": string,
|
||||||
|
"block": string,
|
||||||
|
"app": string
|
||||||
|
},
|
||||||
|
"default_node_id": string,
|
||||||
|
"listen_addr": string,
|
||||||
|
"network": string,
|
||||||
|
"version": string,
|
||||||
|
"channels": string,
|
||||||
|
"moniker": string,
|
||||||
|
"other": {
|
||||||
|
"tx_index": string,
|
||||||
|
"rpc_address": string
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"application_version": {
|
||||||
|
"name": string,
|
||||||
|
"app_name": string,
|
||||||
|
"version": string,
|
||||||
|
"git_commit": string,
|
||||||
|
"build_tags": string,
|
||||||
|
"go_version": string,
|
||||||
|
"build_deps": [
|
||||||
|
{
|
||||||
|
"path": string,
|
||||||
|
"version": string,
|
||||||
|
"sum": string,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"cosmos_sdk_version": string,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Block {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TendermintValidator {
|
||||||
|
"address": string,
|
||||||
|
"pub_key": Key,
|
||||||
|
"voting_power": string,
|
||||||
|
"proposer_priority": string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PaginatedTendermintValidator {
|
||||||
|
validators: TendermintValidator[],
|
||||||
|
block_height: string
|
||||||
|
}
|
@ -2,3 +2,21 @@ export interface Key {
|
|||||||
"@type": string,
|
"@type": string,
|
||||||
"key": string,
|
"key": string,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface Pagination {
|
||||||
|
key?: string;
|
||||||
|
total?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PaginatedResponse {
|
||||||
|
pagination: Pagination;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Response<T> {
|
||||||
|
[key: string]: T
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Coin {
|
||||||
|
amount: string|number;
|
||||||
|
denom: string;
|
||||||
|
}
|
14
src/types/distribution.ts
Normal file
14
src/types/distribution.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import type { PaginatedResponse } from "./common"
|
||||||
|
|
||||||
|
export interface DistributionParams {
|
||||||
|
params: {
|
||||||
|
"community_tax": string,
|
||||||
|
"base_proposer_reward": string,
|
||||||
|
"bonus_proposer_reward": string,
|
||||||
|
"withdraw_addr_enabled": boolean
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PaginatedSlashes extends PaginatedResponse {
|
||||||
|
slashes: any[]
|
||||||
|
}
|
72
src/types/gov.ts
Normal file
72
src/types/gov.ts
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
import type { Coin } from "./Coin"
|
||||||
|
import type { PaginatedResponse } from "./common"
|
||||||
|
|
||||||
|
export interface GovParams {
|
||||||
|
"voting_params": {
|
||||||
|
"voting_period": string,
|
||||||
|
"proposal_voting_periods": any[],
|
||||||
|
"expedited_voting_period": string
|
||||||
|
},
|
||||||
|
"deposit_params": {
|
||||||
|
"min_deposit": Coin[],
|
||||||
|
"max_deposit_period": string,
|
||||||
|
"min_expedited_deposit": Coin[],
|
||||||
|
"min_initial_deposit_ratio": string
|
||||||
|
},
|
||||||
|
"tally_params": {
|
||||||
|
"quorum": string,
|
||||||
|
"threshold": string,
|
||||||
|
"veto_threshold": string,
|
||||||
|
"expedited_threshold": string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GovProposal {
|
||||||
|
"proposal_id": string,
|
||||||
|
"content": {
|
||||||
|
"@type": string,
|
||||||
|
"title": string,
|
||||||
|
"description": string,
|
||||||
|
},
|
||||||
|
"status": string,
|
||||||
|
"final_tally_result": {
|
||||||
|
"yes": string,
|
||||||
|
"abstain": string,
|
||||||
|
"no": string,
|
||||||
|
"no_with_veto": string,
|
||||||
|
},
|
||||||
|
"submit_time": string,
|
||||||
|
"deposit_end_time": string,
|
||||||
|
"total_deposit": Coin[],
|
||||||
|
"voting_start_time": string,
|
||||||
|
"voting_end_time": string,
|
||||||
|
"is_expedited": boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Tally {
|
||||||
|
tally: {
|
||||||
|
yes: string,
|
||||||
|
abstain: string,
|
||||||
|
no: string,
|
||||||
|
no_with_veto: string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GovVote {
|
||||||
|
proposal_id: string,
|
||||||
|
voter: string,
|
||||||
|
option: string,
|
||||||
|
options: { "option": string, "weight": string }[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PaginatedProposals extends PaginatedResponse {
|
||||||
|
proposals: GovProposal[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PaginatedProposalDeposit extends PaginatedResponse {
|
||||||
|
deposits: Coin[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PaginatedProposalVotes extends PaginatedResponse {
|
||||||
|
votes: GovVote[]
|
||||||
|
}
|
@ -1,5 +1,8 @@
|
|||||||
export * from './Coin'
|
|
||||||
export * from './Proposal'
|
export * from './base'
|
||||||
export * from './NodeInfo'
|
export * from './auth'
|
||||||
export * from './Block'
|
export * from './bank'
|
||||||
export * from './SlashingSigningInfo'
|
export * from './common'
|
||||||
|
export * from './distribution'
|
||||||
|
export * from './gov'
|
||||||
|
export * from './staking'
|
76
src/types/staking.ts
Normal file
76
src/types/staking.ts
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
import type { Key, PaginatedResponse, Coin } from "./common"
|
||||||
|
|
||||||
|
export interface Validator {
|
||||||
|
"operator_address": string,
|
||||||
|
"consensus_pubkey": Key,
|
||||||
|
"jailed": boolean,
|
||||||
|
"status": string,
|
||||||
|
"tokens": string,
|
||||||
|
"delegator_shares": string,
|
||||||
|
"description": {
|
||||||
|
"moniker": string,
|
||||||
|
"identity"?: string,
|
||||||
|
"website"?: string,
|
||||||
|
"security_contact"?: string,
|
||||||
|
"details"?: string
|
||||||
|
},
|
||||||
|
"unbonding_height": string,
|
||||||
|
"unbonding_time": string,
|
||||||
|
"commission": {
|
||||||
|
"commission_rates": {
|
||||||
|
"rate": string,
|
||||||
|
"max_rate": string,
|
||||||
|
"max_change_rate": string
|
||||||
|
},
|
||||||
|
"update_time": string
|
||||||
|
},
|
||||||
|
"min_self_delegation": string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Delegation {
|
||||||
|
delegation: {
|
||||||
|
delegator_address: string,
|
||||||
|
validator_address: string,
|
||||||
|
shares: string
|
||||||
|
},
|
||||||
|
balance: Coin
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Redelegation {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface StakingParam {
|
||||||
|
params: {
|
||||||
|
"unbonding_time": string,
|
||||||
|
"max_validators": number,
|
||||||
|
"max_entries": number,
|
||||||
|
"historical_entries": number,
|
||||||
|
"bond_denom": string,
|
||||||
|
"min_commission_rate": string,
|
||||||
|
"min_self_delegation": string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface StakingPool {
|
||||||
|
pool: {
|
||||||
|
not_bonded_tokens: string,
|
||||||
|
bonded_tokens: string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PaginatedDelegations extends PaginatedResponse {
|
||||||
|
delegation_responses: Delegation[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PaginatedRedelegations extends PaginatedResponse {
|
||||||
|
redelegation_responses: Redelegation[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PaginatedUnbonding extends PaginatedResponse {
|
||||||
|
unbonding_responses: any[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PaginatedValdiators extends PaginatedResponse {
|
||||||
|
validators: Validator[]
|
||||||
|
}
|
9
tests/client.test.ts
Normal file
9
tests/client.test.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import { CosmosRestClient } from '../src/libs/client'
|
||||||
|
|
||||||
|
const client = new CosmosRestClient("https://osmosis-rpc.polkachu.com")
|
||||||
|
|
||||||
|
describe('cosmos rest client test', () => {
|
||||||
|
it('node-info', () => {
|
||||||
|
client.getBaseNodeInfo()
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user