Skip to content

Commit

Permalink
use chain docs
Browse files Browse the repository at this point in the history
  • Loading branch information
liujun93 committed Dec 2, 2022
1 parent 6185667 commit 7ceb293
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ packages/**/module
packages/example/pages/tmp.tsx
packages/example/utils/tmp.ts
.idea
/.yarnrc
/.yarnrc
/.npmrc
2 changes: 1 addition & 1 deletion packages/core/src/types/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export interface ChainContext {
) => Promise<StdFee | undefined>;
sign: (
messages: EncodeObject[],
fee: StdFee,
fee?: StdFee,
memo?: string,
type?: CosmosClientType
) => Promise<TxRaw | undefined>;
Expand Down
39 changes: 38 additions & 1 deletion packages/docs/pages/use-chain.mdx
Original file line number Diff line number Diff line change
@@ -1 +1,38 @@
TODO Soon...
## Hook - useChain

- required provider: [**ChainProvider**](https://docs.cosmoskit.com/chain-provider)

- return type: [**ChainConext**](#type-chainconext)

## Type - ChainConext

### properties

| Name | Description | Type | Default |
| ----------- | ----------- | -- | -- |
| **chain** | chain registry information | `Chain` | - |
| **assets** | chain assets information | `AssetList \| undefined` | `undefined` |
| **wallet** | current selected wallet registry information | `Wallet \| undefined` | `undefined` |
| **logoUrl** | chain logo url | `string \| undefined` | `undefined` |
| **address** | chain address from current selected wallet | `string \| undefined` | `undefined` |
| **username** | username from current selected wallet | `string \| undefined` | `undefined` |
| **message** | error/warn/info message | `string \| undefined` | `undefined` |
| **status** | wallet status | `WalletStatus` | `Disconnected` |

### methods

| Name | Description | Parameters | Return Type | Is Async |
| ----------- | ----------- | -- | -- | -- |
| **openView** | open modal | - | `void` | N |
| **connect** | connect wallet | **wallet**?: `WalletName` | `void` | Y |
| **disconnect** | disconnect current selected wallet | - | `void` | Y |
| **getRpcEndpoint** | test connection and return valid rpc endpoint | - | `string \| undefined` | Y |
| **getRestEndpoint** | test connection and return valid rest endpoint | - | `string \| undefined` | Y |
| **getStargateClient** | - | - | `StargateClient \| undefined` | Y |
| **getCosmWasmClient** | - | - | `CosmWasmClient \| undefined` | Y |
| **getSigningStargateClient** | - | - | `SigningStargateClient \| undefined` | Y |
| **getSigningCosmWasmClient** | - | - | `SigningCosmWasmClient \| undefined` | Y |
| **estimateFee** | if **type** is `undefined`, default using `SigningStargateClient` | **messages**: `EncodeObject[]`,<br />**type**?: `CosmosClientType`,<br />**memo**?: `string`,<br />**multiplier**?: `number` | `StdFee \| undefined` | Y |
| **sign** | if **type** is `undefined`, default using `SigningStargateClient` | **messages**: `EncodeObject[]`,<br />**fee**?: `StdFee`,<br />**memo**?: `string`,<br />**type**?: `CosmosClientType`, | `TxRaw \| undefined` | Y |
| **broadcast** | if **type** is `undefined`, default using `SigningStargateClient` | **signedMessages**: `TxRaw`,<br />**type**?: `CosmosClientType`, | `DeliverTxResponse \| undefined` | Y |
| **signAndBroadcast** | if **type** is `undefined`, default using `SigningStargateClient` | **messages**: `EncodeObject[]`,<br />**fee**?: `StdFee`,<br />**memo**?: `string`,<br />**type**?: `CosmosClientType`, | `DeliverTxResponse \| undefined` | Y |
2 changes: 1 addition & 1 deletion packages/example/pages/chains/tx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default function Home() {
let rpcEndpoint = await getRpcEndpoint();

if (!rpcEndpoint) {
console.log("no rpc endpoint — using a fallback");
console.info("no rpc endpoint — using a fallback");
rpcEndpoint = `https://rpc.cosmos.directory/${chainName}`;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/example/pages/tx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default function Home() {
let rpcEndpoint = await getRpcEndpoint();

if (!rpcEndpoint) {
console.log("no rpc endpoint — using a fallback");
console.info("no rpc endpoint — using a fallback");
rpcEndpoint = `https://rpc.cosmos.directory/${chainName}`;
}

Expand Down
4 changes: 0 additions & 4 deletions packages/react/src/modal/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,11 @@ export const getModalDetails = (

const { downloadInfo } = wallet;

// const appType = isMobile ? 'App' : 'Extension';

async function handleDisconnect() {
console.info('Disconnecting');
await disconnect();
}

async function handleConnect() {
console.log('Connecting');
await connect();
}

Expand Down

0 comments on commit 7ceb293

Please sign in to comment.