diff --git a/package.json b/package.json index eb7b4d42..39f9124f 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "serve": "vite", "build": "run-p type-check build-only", "preview": "vite preview", + "test": "jest", "build-only": "vite build", "type-check": "vue-tsc --noEmit", "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore" @@ -46,6 +47,7 @@ "devDependencies": { "@osmonauts/telescope": "^0.88.2", "@rushstack/eslint-patch": "^1.1.4", + "@types/jest": "^29.5.0", "@types/marked": "^4.0.8", "@types/node": "^18.11.12", "@types/numeral": "^2.0.2", @@ -55,6 +57,7 @@ "@vue/tsconfig": "^0.1.3", "eslint": "^8.22.0", "eslint-plugin-vue": "^9.3.0", + "jest": "^29.5.0", "npm-run-all": "^4.1.5", "prettier": "^2.7.1", "sass": "^1.58.0", diff --git a/src/libs/api.ts b/src/libs/api.ts index 70443fab..21fb7b51 100644 --- a/src/libs/api.ts +++ b/src/libs/api.ts @@ -8,22 +8,22 @@ export const DEFAULT: RequestRegistry = { 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 }, + bank_supply_by_denom: { url: "/cosmos/bank/v1beta1/supply/{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 }, + gov_params_voting: { url: "/cosmos/gov/v1beta1/params/voting", adapter }, + gov_params_tally: { url: "/cosmos/gov/v1beta1/params/tallying", adapter }, + gov_params_deposit: { url: "/cosmos/gov/v1beta1/params/deposit", adapter }, + gov_proposals: { url: "/cosmos/gov/v1beta1/proposals", adapter }, + gov_proposals_proposal_id: {url: "/cosmos/gov/v1beta1/proposals/{proposal_id}", adapter}, + gov_proposals_deposits: { url: "/cosmos/gov/v1beta1/proposals/{proposal_id}/deposits", adapter }, + gov_proposals_tally: { url: "/cosmos/gov/v1beta1/proposals/{proposal_id}/tally", adapter }, + gov_proposals_votes: { url: "/cosmos/gov/v1beta1/proposals/{proposal_id}/votes", 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_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 }, diff --git a/src/libs/client.ts b/src/libs/client.ts index 18f4e10a..706992c3 100644 --- a/src/libs/client.ts +++ b/src/libs/client.ts @@ -139,7 +139,7 @@ export class CosmosRestClient { return this.request(this.registry.base_tendermint_validatorsets_height, {height}) } async getBaseValidatorsetLatest() { - return this.request(this.registry.base_tendermint_block_latest, {}) + return this.request(this.registry.base_tendermint_validatorsets_latest, {}) } // tx async getTxsBySender(sender: string) { @@ -150,7 +150,7 @@ export class CosmosRestClient { return this.request(this.registry.tx_txs_block, {height}) } async getTx(hash: string) { - return this.request(this.registry.tx_hash, {}) + return this.request(this.registry.tx_hash, {hash}) } } diff --git a/src/libs/registry.ts b/src/libs/registry.ts index 456631cf..828aed4f 100644 --- a/src/libs/registry.ts +++ b/src/libs/registry.ts @@ -1,8 +1,11 @@ -import type { Block, NodeInfo, SlashingSigningInfo } from "@/types"; -import type { PaginabledAccounts } from "@/types/Auth"; -import type { Tx } from "@/types/Tx"; +import type { Block, Coin, NodeInfo, PaginatedTendermintValidator, SlashingSigningInfo } from "@/types"; +import type { AuthAccount, PaginabledAccounts } from "@/types/Auth"; +import type { PaginatedTxs, Tx, TxResponse } from "@/types/Tx"; 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"; @@ -15,54 +18,54 @@ export interface Request { export interface RequestRegistry { auth_params: Request auth_accounts: Request; - auth_account_address: Request; + auth_account_address: Request<{account: AuthAccount}>; - bank_params: Request; - bank_balances_address: Request; + bank_params: Request; + bank_balances_address: Request; bank_denoms_metadata: Request; bank_supply: Request; - bank_supply_by_denom: Request; + bank_supply_by_denom: Request<{amount: Coin}>; - distribution_params: Request; - distribution_validator_commission: Request; - distribution_validator_outstanding_rewards: Request; - distribution_validator_slashes: Request; + distribution_params: Request; + distribution_validator_commission: Request<{commission?: {commission?: Coin[]}}>; + distribution_validator_outstanding_rewards: Request<{rewards?: {rewards?: Coin[]}}>; + 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; + gov_params_voting: Request; + gov_params_tally: Request; + gov_params_deposit: Request; + gov_proposals: Request; + gov_proposals_proposal_id: Request<{proposal: GovProposal}>; + gov_proposals_deposits: Request; + gov_proposals_tally: Request; + gov_proposals_votes: Request; + gov_proposals_votes_voter: Request<{vote: GovVote}>; - 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_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<{validator: Validator}>; + staking_validators_delegations: Request; + staking_validators_delegations_delegator: Request<{delegation_response: Delegation}>; 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; + base_tendermint_validatorsets_latest: Request; + base_tendermint_validatorsets_height: Request; - tx_txs: Request; + tx_txs: Request; tx_txs_block: Request; - tx_hash: Request; + tx_hash: Request<{tx: Tx, tx_response: TxResponse}>; } diff --git a/src/modules/wallet/test.vue b/src/modules/wallet/test.vue index a194f107..def77044 100644 --- a/src/modules/wallet/test.vue +++ b/src/modules/wallet/test.vue @@ -1,5 +1,14 @@