Skip to content
This repository has been archived by the owner on Dec 25, 2023. It is now read-only.

Commit

Permalink
Docs v0.0.1
Browse files Browse the repository at this point in the history
* Started Docs, Added queries to docs

* Changed layouting

* Update docs/intro.md

Co-authored-by: Simon Warta <[email protected]>

* Change intro docs

* Reorganize Docs

* Add CosmWasmClient Docs

* Refer to cosmjs docs

* Adding more text to CosmWasmClient docs

* Added simple docs for CosmWasmSigningClient

* Update docs/queries/overview.md

Co-authored-by: Simon Warta <[email protected]>

* Rename intro.md to index.md

* Set theme jekyll-theme-cayman

* Update _config.yml

* Update _config.yml

* Changed some stuff for jekyll

* Fix Doc Navigation

* Fix navigation children

* Adding grandparent

* Update index.md

* Rearrange the docs

* Describe Methods in tables

* Edit configs

* Added more docs

* Typo

* Re-order navigation

* Adding cli docs

* Adding NL

* CLI Docs shouldn't have childs

Co-authored-by: Simon Warta <[email protected]>
  • Loading branch information
msteiner96 and webmaster128 authored Mar 2, 2022
1 parent 2018170 commit 74c529e
Show file tree
Hide file tree
Showing 20 changed files with 730 additions and 0 deletions.
15 changes: 15 additions & 0 deletions docs/_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# General
title: "CosmWasmJS Docs"
description: "CosmWasJS Docs"

#Theming
remote_theme: pmarsceill/just-the-docs
color_scheme: "light"
search_enabled: true
logo: "/logo.png"

# External Links
aux_links:
"CosmWasmJS on Github":
- "//github.com/CosmWasm/CosmWasmJS"
aux_links_new_tab: true
21 changes: 21 additions & 0 deletions docs/cli.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
title: Command Line
nav_order: 5
---

# Command Line Interface (CLI)

## About

With CosmWasmJS also comes a command line client, which (because of NPX) does
not necessarily have to be installed in the project, but can also be installed
globally.

It is completely based on
[@cosmjs/cli](https://www.npmjs.com/package/@cosmjs/cli).

## Usage

```sh
npx cosmwasm
```
76 changes: 76 additions & 0 deletions docs/clients/reading/CosmWasmClient.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
title: CosmWasmClient
nav_order: 1
parent: Reading
---

# CosmWasmClient

## About

The class `CosmWasmClient` is exported from the CosmJS package
`@cosmjs/cosmwasm-stargate` (πŸ”—
[Link](https://github.com/cosmos/cosmjs/tree/main/packages/cosmwasm-stargate)).
It already comes with a handful of methods that can be used to execute
frequently used queries.

It is used only to execute queries. **NOT** to work with signed transactions. If
you are looking for the documentation for this, please see the πŸ”—
[CosmWasmSigningClient documentation](../writing/CosmWasmSigningClient/index.md).

To execute extended queries, please refer to the πŸ”—
[Query documentation](queries/index.md).

## Usage

```ts
import { CosmWasmClient } from "cosmwasm";

// This is your rpc endpoint
const rpcEndpoint = "https://rpc.cliffnet.cosmwasm.com:443/";

async function main() {
const client = await CosmWasmClient.connect(rpcEndpoint);
console.log(client);β€š
}

main();
```

# Available Methods

## General

| Method | Description | Params |
| :------------- | :------------------------------------- | :------------------------------------- |
| .connect() | Returns the client. | _tmClient: Tendermint34Client_ |
| .getChainId() | Get current chain's ID. | _none_ |
| .getHeight() | Get current height of the chain. | _none_ |
| .getAccount() | Get more information about an account. | _searchAddress: string_ |
| .getSequence() | | _address: string_ |
| .getBlock() | | _height?: number_ |
| .getBalance() | | _address: string, searchDenom: string_ |

## Transactions

| Method | Description | Params |
| :---------- | :---------- | :-------------------------------------------------- |
| .getTx() | | _id: string_ |
| .searchTx() | | _query: SearchTxQuery, filter: SearchTxFilter = {}_ |
| .txsQuery() | | _query: string_ |

## Codes

| Method | Description | Params |
| :---------------- | :---------- | :--------------- |
| .getCodes() | | _none_ |
| .getCodeDetails() | | _codeId: number_ |

## Smart Contracts

| Method | Description | Params |
| :-------------------- | :---------- | :--------------------------------------------------- |
| .getContracts() | | _cideId: number_ |
| .getContract() | | _address: string_ |
| .queryContractRaw() | | _address: string, key: Uint8Array_ |
| .queryContractSmart() | | _address: string, queryMsg: Record<string, unknown>_ |
12 changes: 12 additions & 0 deletions docs/clients/reading/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
title: Reading
has_children: true
nav_order: 3
---

# Reading / Queries

We basically distinguish between reading and writing actions. Read actions are
all queries that do not require a signature and therefore do not require a
connected wallet. An example of this is the query of information about a
transaction or the number of tokens of an address.
26 changes: 26 additions & 0 deletions docs/clients/reading/queries/auth.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
title: Auth Queries
parent: Advanced Queries
grand_parent: Reading
nav_order: 1
---

# Auth queries

## Create a queryClient

```ts
// Instantiate tmClient
const tmClient = await Tendermint34Client.connect(rpcUrl);

// Create client with authExtension
const client = QueryClient.withExtensions(tmClient, setupAuthExtension);
```

## Available query methods

| Method | Description | Params |
| :------------ | :---------- | :---------------- |
| .auth.account | | _address: string_ |

πŸ”— [Back to query overview](index.md)
32 changes: 32 additions & 0 deletions docs/clients/reading/queries/bank.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
title: Bank Queries
parent: Advanced Queries
grand_parent: Reading
nav_order: 2
---

# Bank queries

## Create a queryClient

```ts
// Instantiate tmClient
const tmClient = await Tendermint34Client.connect(rpcUrl);

// Create client with bankExtension
const client = QueryClient.withExtensions(tmClient, setupBankExtension);
```

## Available query methods

| Method | Description | Params |
| :------------------- | :---------- | :------------------------------- |
| .auth.account | | _address: string_ |
| .bank.balance | | _address: string, denom: string_ |
| .bank.allBalances | | _address: string_ |
| .bank.totalSupply | | _none_ |
| .bank.supplyOf | | _denom: string_ |
| .bank.denomMetadata | | _denom: string_ |
| .bank.denomsMetadata | | _none_ |

πŸ”— [Back to query overview](index.md)
34 changes: 34 additions & 0 deletions docs/clients/reading/queries/distribution.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
title: Distribution Queries
parent: Advanced Queries
grand_parent: Reading
nav_order: 3
---

# Distribution queries

## Create a queryClient

```ts
// Instantiate tmClient
const tmClient = await Tendermint34Client.connect(rpcUrl);

// Create client with distributionExtension
const client = QueryClient.withExtensions(tmClient, setupDistributionExtension);
```

## Available query methods

| Method | Description | Params |
| :---------------------------------------- | :---------- | :------------------------------------------------------------------------------------------------- |
| .distribution.communityPool | | _none_ |
| .distribution.delegationRewards | | _delegatorAddress: string, validatorAddress: string_ |
| .distribution.delegationTotalRewards | | _delegatorAddress: string_ |
| .distribution.delegatorValidators | | _delegatorAddress: string_ |
| .distribution.delegatorWithdrawAddress | | _delegatorAddress: string_ |
| .distribution.params | | _none_ |
| .distribution.validatorCommission | | _validatorAddress: string_ |
| .distribution.validatorOutstandingRewards | | _validatorAddress: string_ |
| .distribution.validatorSlashes | | _validatorAddress: string, startingHeight: number,endingHeight: number, paginationKey?:Uint8Array_ |

πŸ”— [Back to query overview](index.md)
32 changes: 32 additions & 0 deletions docs/clients/reading/queries/gov.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
title: Gov Queries
parent: Advanced Queries
grand_parent: Reading
nav_order: 4
---

# Gov queries

## Create a queryClient

```ts
// Instantiate tmClient
const tmClient = await Tendermint34Client.connect(rpcUrl);

// Create client with govExtension
const client = QueryClient.withExtensions(tmClient, setupGovExtension);
```

## Available query methods

| Method | Description | Params |
| :------------- | :---------- | :-------------------------------------------------------------------------------------------- |
| .gov.proposals | | _proposalStatus: ProposalStatus,depositor: string, voter: string, paginationKey?: Uint8Array_ |
| .gov.proposal | | _proposalId: GovProposalId_ |
| .gov.deposits | | _proposalId: GovProposalId, paginationKey?:Uint8Array_ |
| .gov.deposit | | _proposalId: GovProposalId, depositorAddress: string_ |
| .gov.tally | | _proposalId: GovProposalId_ |
| .gov.votes | | _proposalId: GovProposalId, paginationKey?: Uint8Array_ |
| .gov.vote | | _proposalId: GovProposalId, voterAddress: string_ |

πŸ”— [Back to query overview](index.md)
80 changes: 80 additions & 0 deletions docs/clients/reading/queries/ibc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
title: Ibc Queries
parent: Advanced Queries
grand_parent: Reading
nav_order: 5
---

# IBC queries

## Create a queryClient

```ts
// Instantiate tmClient
const tmClient = await Tendermint34Client.connect(rpcUrl);

// Create client with authExtension
const client = QueryClient.withExtensions(tmClient, setupAuthExtension);
```

## Available query methods

### Channel Queries

| Method | Description | Params |
| :------------------------------------- | :---------- | :------------------------------------------------------------------------------- |
| .ibc.channel.channel | | _portId: string, channelId: string_ |
| .ibc.channel.channels | | _paginationKey?: Uint8Array_ |
| .ibc.channel.allChannels | | _none_ |
| .ibc.channel.connectionChannels | | _connection: string, paginationKey?: Uint8Array_ |
| .ibc.channel.allConnectionChannels | | _connection: string_ |
| .ibc.channel.clientState | | _portId: string, channelId: string_ |
| .ibc.channel.consensusState | | _portId: string,channelId: string,revisionNumber: number,revisionHeight: number_ |
| .ibc.channel.packetCommitment | | _portId: string, channelId: string, sequence: Long_ |
| .ibc.channel.packetCommitments | | _portId: string,channelId: string,paginationKey?: Uint8Array_ |
| .ibc.channel.allPacketCommitments | | _portId: string, channelId: string_ |
| .ibc.channel.packetReceipt | | _portId: string, channelId: string, sequence: number_ |
| .ibc.channel.packetAcknowledgement | | _portId: string,channelId: string, sequence: number_ |
| .ibc.channel.packetAcknowledgements | | _portId: string,channelId: string,paginationKey?: Uint8Array_ |
| .ibc.channel.allPacketAcknowledgements | | _portId: string, channelId: string_ |
| .ibc.channel.unreceivedPackets | | _portId: string,channelId: string, packetCommitmentSequences: number[]_ |
| .ibc.channel.unreceivedAcks | | _portId: string,channelId: string,packetAckSequences: number[]_ |
| .ibc.channel.nextSequenceReceive | | _portId: string,channelId: string_ |

### Client Queries

| Method | Description | Params |
| :----------------------------- | :---------- | :-------------------------------------------- |
| .ibc.client.state | | _clientId: string_ |
| .ibc.client.states | | _paginationKey?: Uint8Array_ |
| .ibc.client.allStates | | _none_ |
| .ibc.client.consensusState | | _clientId: string, height?: number_ |
| .ibc.client.consensusStates | | _clientId: string,paginationKey?: Uint8Array_ |
| .ibc.client.allConsensusStates | | _clientId: string_ |
| .ibc.client.params | | _none_ |
| .ibc.client.stateTm | | _clientId: string_ |
| .ibc.client.statesTm | | _paginationKey?: Uint8Array_ |
| .ibc.client.allStatesTm | | _none_ |
| .ibc.client.consensusStateTm | | _clientId: string, height?: Height_ |

### Connection Queries

| Method | Description | Params |
| :-------------------------------- | :---------- | :------------------------------------------------------------------- |
| .ibc.connection.connection | | _connectionId: string_ |
| .ibc.connection.connections | | _paginationKey?: Uint8Array_ |
| .ibc.connection.allConnections | | _none_ |
| .ibc.connection.clientConnections | | _clientId: string_ |
| .ibc.connection.clientState | | _connectionId: string_ |
| .ibc.connection.consensusState | | _connectionId: string,revisionNumber: number,revisionHeight: number_ |

### Transfer Queries

| Method | Description | Params |
| :--------------------------- | :---------- | :--------------------------- |
| .ibc.transfer.denomTrace | | _hash: string_ |
| .ibc.transfer.denomTraces | | _paginationKey?: Uint8Array_ |
| .ibc.transfer.allDenomTraces | | _none_ |
| .ibc.transfer.params | | _none_ |

πŸ”— [Back to query overview](index.md)
55 changes: 55 additions & 0 deletions docs/clients/reading/queries/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
title: Advanced Queries
parent: Reading
nav_order: 2
has_children: true
---

# Queries

If the methods of the CosmWasmClient are no longer sufficient, you can also
instantiate a QueryClient yourself. With the help of various extensions,
different types of queries can be executed.

## Example

```ts
import {
SigningCosmWasmClient,
setupStakingExtension,
QueryClient,
} from "cosmwasm";

// Get all delegations of a delegator
const getAllDelegations = async (delegator, rpcUrl) => {
// Instantiate tmClient
const tmClient = await Tendermint34Client.connect(rpcUrl);

// Create client with stakingExtension
const client = QueryClient.withExtensions(tmClient, setupStakingExtension);

return await client?.staking.delegatorDelegations(delegator);
};

const delegations = getAllDelegations("YourDelegatorAddress", "YourRpcUrl");

console.log(delegations);
```

## Extensions

Depending on what query is needed, queries are divided into different
extensions:

- πŸ”— [AuthExtension](auth.md) Information about an account
- πŸ”— [BankExtension](bank.md) Information about account balances, denoms and
supply
- πŸ”— [DistributionExtension](distribution.md) Information about community pools,
delagations/delegators and validators
- πŸ”— [GovExtension](gov.md) Information about proposals, deposits and votes
- πŸ”— [IbcExtension](ibc.md) Information about IBC data
- πŸ”— [MintExtension](mint.md) Information about inflation and provisions
- πŸ”— [StakingExtension](staking.md) All information about staking related stuff
- πŸ”— [TxExtension](tx.md) Information about transactions

πŸ”— [Back to clients overview](clients.md)
Loading

0 comments on commit 74c529e

Please sign in to comment.